]> The Tcpdump Group git mirrors - libpcap/commitdiff
In gencode.c use SWAPLONG() from pcap-util.h.
authorDenis Ovsienko <[email protected]>
Mon, 9 Dec 2024 23:02:10 +0000 (23:02 +0000)
committerDenis Ovsienko <[email protected]>
Tue, 10 Dec 2024 01:41:10 +0000 (01:41 +0000)
Add a header guard to pcap-util.h while at it.

gencode.c
pcap-util.h

index 3ddd8b4c18e99a3d61bfa84a99394258371e3da5..7cd144cd816118dd57a11db98a1c26f67d5aac87 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -47,6 +47,7 @@
 #include "pcap/sll.h"
 #include "pcap/ipnet.h"
 #include "diag-control.h"
+#include "pcap-util.h"
 
 #include "scanner.h"
 
@@ -2097,14 +2098,6 @@ gen_false(compiler_state_t *cstate)
        return gen_uncond(cstate, 0);
 }
 
-/*
- * Byte-swap a 32-bit number.
- * ("htonl()" or "ntohl()" won't work - we want to byte-swap even on
- * big-endian platforms.)
- */
-#define        SWAPLONG(y) \
-((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
-
 /*
  * Generate code to match a particular packet type.
  *
index 5b40e45b962d6442c91b8f218b8ea2d5391b1847..7c4d88c8855046765735885e9b43be9dad10fcd3 100644 (file)
@@ -21,6 +21,9 @@
  * pcap-util.h - common code for various files
  */
 
+#ifndef pcap_util_h
+#define pcap_util_h
+
 /*
  * We use the "receiver-makes-right" approach to byte order;
  * because time is at a premium when we are writing the file.
@@ -49,3 +52,5 @@
 
 extern void pcapint_post_process(int linktype, int swapped,
     struct pcap_pkthdr *hdr, u_char *data);
+
+#endif // pcap_util_h