dect
/
libpcap
Archived
1
0
Fork 0

Add a #define for 0xffffffff as PCAP_NETMASK_UNKNOWN, for use when you

don't know the netmask.  (It also lets you test, at compile time,
whether you can rely on "ip broadcast" failing to compile when you pass
0xffffffff to pcap_compile().)
master
Guy Harris 13 years ago
parent 74b2de364f
commit 117cb5eb2e
  1. 2
      filtertest.c
  2. 7
      gencode.c
  3. 6
      pcap/pcap.h
  4. 4
      pcap_compile.3pcap.in

@ -166,7 +166,7 @@ main(int argc, char **argv)
int Oflag;
long snaplen;
int dlt;
bpf_u_int32 netmask = 0xffffffff;
bpf_u_int32 netmask = PCAP_NETMASK_UNKNOWN;
char *cmdbuf;
pcap_t *pd;
struct bpf_program fcode;

@ -7119,10 +7119,11 @@ gen_broadcast(proto)
case Q_IP:
/*
* We treat a netmask of 0xffffffff as an indication
* that we don't know the netmask, and fail.
* We treat a netmask of PCAP_NETMASK_UNKNOWN (0xffffffff)
* as an indication that we don't know the netmask, and fail
* in that case.
*/
if (netmask == 0xffffffff)
if (netmask == PCAP_NETMASK_UNKNOWN)
bpf_error("netmask not known, so 'ip broadcast' not supported");
b0 = gen_linktype(ETHERTYPE_IP);
hostmask = ~netmask;

@ -253,6 +253,12 @@ typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *,
#define PCAP_WARNING 1 /* generic warning code */
#define PCAP_WARNING_PROMISC_NOTSUP 2 /* this device doesn't support promiscuous mode */
/*
* Value to pass to pcap_compile() as the netmask if you don't know what
* the netmask is.
*/
#define PCAP_NETMASK_UNKNOWN 0xffffffff
char *pcap_lookupdev(char *);
int pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *);

@ -54,8 +54,8 @@ captured; it is used only when checking for IPv4 broadcast addresses in
the filter program. If the netmask of the network on which packets are
being captured isn't known to the program, or if packets are being
captured on the Linux "any" pseudo-interface that can capture on more
than one network, a value of 0xffffffff can be supplied; tests for
IPv4 broadcast addreses will fail to compile, but all other tests in
than one network, a value of PCAP_NETMASK_UNKNOWN can be supplied; tests
for IPv4 broadcast addreses will fail to compile, but all other tests in
the filter program will be OK.
.SH RETURN VALUE
.B pcap_compile()