client: Deal with external representation for pcap files

We need to convert the 64bit timeval on a 64bit userspace (or on
OpenBSD) into a 32bit truncated value for being able to write the
file. This means we have 2038 issue here?
This commit is contained in:
Holger Hans Peter Freyther 2015-12-03 22:13:38 +01:00
parent fbdcf593f8
commit 66b80cc8f5
2 changed files with 18 additions and 3 deletions

View File

@ -43,4 +43,16 @@ struct osmo_pcap_data {
uint8_t data[0];
} __attribute__((packed));
/**
* struct timeval is not the same across different
* architectures and for the external format it must
* be a 32bit value. We have a 2038 issue here?
*/
struct osmo_pcap_pkthdr {
uint32_t ts_sec;
uint32_t ts_usec;
uint32_t caplen;
uint32_t len;
} __attribute__((packed));
#endif

View File

@ -100,7 +100,7 @@ void osmo_client_send_data(struct osmo_pcap_client *client,
struct pcap_pkthdr *in_hdr, const uint8_t *data)
{
struct osmo_pcap_data *om_hdr;
struct pcap_pkthdr *hdr;
struct osmo_pcap_pkthdr *hdr;
struct msgb *msg;
if (in_hdr->caplen > 9000) {
@ -119,8 +119,11 @@ void osmo_client_send_data(struct osmo_pcap_client *client,
om_hdr->type = PKT_LINK_DATA;
msg->l2h = msgb_put(msg, sizeof(*hdr));
hdr = (struct pcap_pkthdr *) msg->l2h;
*hdr = *in_hdr;
hdr = (struct osmo_pcap_pkthdr *) msg->l2h;
hdr->ts_sec = in_hdr->ts.tv_sec;
hdr->ts_usec = in_hdr->ts.tv_usec;
hdr->caplen = in_hdr->caplen;
hdr->len = in_hdr->len;
msg->l3h = msgb_put(msg, in_hdr->caplen);
memcpy(msg->l3h, data, in_hdr->caplen);