fix nfq_get_timestamp() to use struct timeval and be endian correct
author/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org </C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org>
Sun, 6 Nov 2005 09:58:03 +0000 (09:58 +0000)
committerr.kubiak <r.kubiak@samsung.com>
Mon, 16 Nov 2015 13:12:05 +0000 (14:12 +0100)
include/libnetfilter_queue/libnetfilter_queue.h
src/libnetfilter_queue.c

index 93331e1..3b2c374 100644 (file)
@@ -68,8 +68,7 @@ extern struct nfqnl_msg_packet_hdr *
 
 extern u_int32_t nfq_get_nfmark(struct nfq_data *nfad);
 
-extern struct nfq_msg_packet_timestamp *
-                               nfq_get_timestamp(struct nfq_data *nfad);
+extern int nfq_get_timestamp(struct nfq_data *nfad, struct timeval *tv);
 
 /* return 0 if not set */
 extern u_int32_t nfq_get_indev(struct nfq_data *nfad);
index 8844012..7fa0643 100644 (file)
@@ -335,10 +335,18 @@ uint32_t nfq_get_nfmark(struct nfq_data *nfad)
        return ntohl(nfnl_get_data(nfad->data, NFQA_MARK, u_int32_t));
 }
 
-struct nfq_msg_packet_timestamp *nfq_get_timestamp(struct nfq_data *nfad)
+int nfq_get_timestamp(struct nfq_data *nfad, struct timeval *tv)
 {
-       return nfnl_get_pointer_to_data(nfad->data, NFQA_TIMESTAMP,
-                                       struct nfq_msg_packet_timestamp);
+       struct nfqnl_msg_packet_timestamp *qpt;
+       qpt = nfnl_get_pointer_to_data(nfad->data, NFQA_TIMESTAMP,
+                                       struct nfqnl_msg_packet_timestamp);
+       if (!qpt)
+               return -1;
+
+       tv->tv_sec = __be64_to_cpu(qpt->sec);
+       tv->tv_usec = __be64_to_cpu(qpt->usec);
+
+       return 0;
 }
 
 /* all nfq_get_*dev() functions return 0 if not set, since linux only allows