mirror of https://gerrit.osmocom.org/osmo-pcap
wireformat: Send the length in the network order..
this is a format change. but it is necessary now.
This commit is contained in:
parent
59bfb5854d
commit
9df7dc5f69
|
@ -38,8 +38,8 @@
|
||||||
|
|
||||||
struct osmo_pcap_data {
|
struct osmo_pcap_data {
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
uint8_t spare[3];
|
uint8_t spare;
|
||||||
uint32_t len;
|
uint16_t len;
|
||||||
uint8_t data[0];
|
uint8_t data[0];
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ void osmo_client_send_data(struct osmo_pcap_client *client,
|
||||||
msg->l3h = msgb_put(msg, in_hdr->caplen);
|
msg->l3h = msgb_put(msg, in_hdr->caplen);
|
||||||
memcpy(msg->l3h, data, in_hdr->caplen);
|
memcpy(msg->l3h, data, in_hdr->caplen);
|
||||||
|
|
||||||
om_hdr->len = msgb_l2len(msg);
|
om_hdr->len = htons(msgb_l2len(msg));
|
||||||
|
|
||||||
write_data(client, msg);
|
write_data(client, msg);
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ void osmo_client_send_link(struct osmo_pcap_client *client)
|
||||||
|
|
||||||
om_hdr = (struct osmo_pcap_data *) msgb_put(msg, sizeof(*om_hdr));
|
om_hdr = (struct osmo_pcap_data *) msgb_put(msg, sizeof(*om_hdr));
|
||||||
om_hdr->type = PKT_LINK_HDR;
|
om_hdr->type = PKT_LINK_HDR;
|
||||||
om_hdr->len = sizeof(*hdr);
|
om_hdr->len = htons(sizeof(*hdr));
|
||||||
|
|
||||||
hdr = (struct pcap_file_header *) msgb_put(msg, sizeof(*hdr));
|
hdr = (struct pcap_file_header *) msgb_put(msg, sizeof(*hdr));
|
||||||
hdr->magic = 0xa1b2c3d4;
|
hdr->magic = 0xa1b2c3d4;
|
||||||
|
|
|
@ -188,6 +188,7 @@ static int read_cb(struct osmo_fd *fd, unsigned int what)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data->len = ntohs(data->len);
|
||||||
if (data->len > 2000) {
|
if (data->len > 2000) {
|
||||||
LOGP(DSERVER, LOGL_ERROR, "Unplausible result %u\n", data->len);
|
LOGP(DSERVER, LOGL_ERROR, "Unplausible result %u\n", data->len);
|
||||||
close_connection(conn);
|
close_connection(conn);
|
||||||
|
|
Loading…
Reference in New Issue