From: Denis Ovsienko Date: Mon, 9 Dec 2024 23:02:10 +0000 (+0000) Subject: In gencode.c use SWAPLONG() from pcap-util.h. X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/4fc98f5dd4c64a98de233abec602b59601280204 In gencode.c use SWAPLONG() from pcap-util.h. Add a header guard to pcap-util.h while at it. --- diff --git a/gencode.c b/gencode.c index 3ddd8b4c..7cd144cd 100644 --- 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. * diff --git a/pcap-util.h b/pcap-util.h index 5b40e45b..7c4d88c8 100644 --- a/pcap-util.h +++ b/pcap-util.h @@ -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