aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-12-03 22:13:38 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-12-03 22:13:38 +0100
commit66b80cc8f5ea4e99dab1b36f122d75395129a74e (patch)
tree9d856d508cc5625708d81163a7a405ede6cae1f2
parentfbdcf593f80d4fe5330376674136fd76fcef5ea2 (diff)
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?
-rw-r--r--include/osmo-pcap/wireformat.h12
-rw-r--r--src/osmo_client_network.c9
2 files changed, 18 insertions, 3 deletions
diff --git a/include/osmo-pcap/wireformat.h b/include/osmo-pcap/wireformat.h
index f094051..3f92ee8 100644
--- a/include/osmo-pcap/wireformat.h
+++ b/include/osmo-pcap/wireformat.h
@@ -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
diff --git a/src/osmo_client_network.c b/src/osmo_client_network.c
index d4cde47..c488d65 100644
--- a/src/osmo_client_network.c
+++ b/src/osmo_client_network.c
@@ -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);