BPF filter size is unsigned int

This commit is contained in:
Roy Marples 2014-03-31 20:00:06 +00:00
parent f751cdf6d3
commit 1eb3fab10e
2 changed files with 4 additions and 4 deletions

View File

@ -47,7 +47,7 @@ static const struct bpf_insn arp_bpf_filter [] = {
/* Otherwise, drop it. */
BPF_STMT(BPF_RET + BPF_K, 0),
};
static const size_t arp_bpf_filter_len =
static const unsigned int arp_bpf_filter_len =
sizeof(arp_bpf_filter) / sizeof(arp_bpf_filter[0]);
@ -97,5 +97,5 @@ static const struct bpf_insn dhcp_bpf_filter [] = {
/* Otherwise, drop it. */
BPF_STMT(BPF_RET + BPF_K, 0),
};
static const size_t dhcp_bpf_filter_len =
static const unsigned int dhcp_bpf_filter_len =
sizeof(dhcp_bpf_filter) / sizeof(dhcp_bpf_filter[0]);

4
lpf.c
View File

@ -92,10 +92,10 @@ ipv4_opensocket(struct interface *ifp, int protocol)
memset(&pf, 0, sizeof(pf));
if (protocol == ETHERTYPE_ARP) {
pf.filter = UNCONST(arp_bpf_filter);
pf.len = (unsigned int)arp_bpf_filter_len;
pf.len = arp_bpf_filter_len;
} else {
pf.filter = UNCONST(dhcp_bpf_filter);
pf.len = (unsigned int)dhcp_bpf_filter_len;
pf.len = dhcp_bpf_filter_len;
}
if (setsockopt(s, SOL_SOCKET, SO_ATTACH_FILTER, &pf, sizeof(pf)) != 0)
goto eexit;