static void insert_compute_vloffsets(compiler_state_t *, struct block *);
static struct slist *gen_abs_offset_varpart(compiler_state_t *,
bpf_abs_offset *);
-static bpf_u_int32 ethertype_to_ppptype(bpf_u_int32);
+static uint16_t ethertype_to_ppptype(compiler_state_t *, bpf_u_int32);
static struct block *gen_linktype(compiler_state_t *, bpf_u_int32);
static struct block *gen_snap(compiler_state_t *, bpf_u_int32, bpf_u_int32);
static struct block *gen_llc_linktype(compiler_state_t *, bpf_u_int32);
default:
if (ll_proto <= ETHERMTU) {
+ assert_maxval(cstate, "LLC DSAP", ll_proto, UINT8_MAX);
/*
* This is an LLC SAP value, so the frames
* that match would be 802.2 frames.
gen_and(b0, b1);
return b1;
} else {
+ assert_maxval(cstate, "EtherType", ll_proto, UINT16_MAX);
/*
* This is an Ethernet type, so compare
* the length/type field with it (if
default:
if (ll_proto <= ETHERMTU) {
+ assert_maxval(cstate, "LLC DSAP", ll_proto, UINT8_MAX);
/*
* This is an LLC SAP value, so the frames
* that match would be 802.2 frames.
gen_and(b0, b1);
return b1;
} else {
+ assert_maxval(cstate, "EtherType", ll_proto, UINT16_MAX);
/*
* This is an Ethernet type, so compare
* the length/type field with it (if
/*
* Map an Ethernet type to the equivalent PPP type.
*/
-static bpf_u_int32
-ethertype_to_ppptype(bpf_u_int32 ll_proto)
+static uint16_t
+ethertype_to_ppptype(compiler_state_t *cstate, bpf_u_int32 ll_proto)
{
switch (ll_proto) {
case LLCSAP_IPX:
return PPP_IPX;
}
- return (ll_proto);
+ assert_maxval(cstate, "PPP protocol", ll_proto, UINT16_MAX);
+ return (uint16_t)ll_proto;
}
/*
case DLT_C_HDLC:
case DLT_HDLC:
+ assert_maxval(cstate, "HDLC protocol", ll_proto, UINT16_MAX);
switch (ll_proto) {
case LLCSAP_ISONS:
* map them to the corresponding PPP protocol types.
*/
return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H,
- ethertype_to_ppptype(ll_proto));
+ ethertype_to_ppptype(cstate, ll_proto));
/*NOTREACHED*/
case DLT_PPP_BSDOS:
default:
return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H,
- ethertype_to_ppptype(ll_proto));
+ ethertype_to_ppptype(cstate, ll_proto));
}
/*NOTREACHED*/
* it's not, it needs to be handled specially
* above.)
*/
+ assert_maxval(cstate, "EtherType", ll_proto, UINT16_MAX);
return gen_cmp(cstate, OR_LINKTYPE, 0, BPF_H, ll_proto);
/*NOTREACHED */
}
* here, but should we check for the IPX Ethertype?
*/
if (ll_proto <= ETHERMTU) {
+ assert_maxval(cstate, "LLC DSAP", ll_proto, UINT8_MAX);
/*
* This is an LLC SAP value, so check
* the DSAP.
*/
return gen_cmp(cstate, OR_LLC, 0, BPF_B, ll_proto);
} else {
+ assert_maxval(cstate, "EtherType", ll_proto, UINT16_MAX);
/*
* This is an Ethernet type; we assume that it's
* unlikely that it'll appear in the right place
expr => 'geneve 123456789',
errstr => 'Geneve VNI 123456789 greater than maximum 16777215',
},
+ # gen_linktype()
+ {
+ name => 'link_proto_65536_C_HDLC',
+ DLT => 'C_HDLC',
+ expr => 'link proto 65536',
+ errstr => 'HDLC protocol 65536 greater than maximum 65535',
+ },
+ {
+ name => 'link_proto_65536_PPP',
+ DLT => 'PPP',
+ expr => 'link proto 65536',
+ errstr => 'PPP protocol 65536 greater than maximum 65535',
+ },
+ {
+ name => 'link_proto_65536_PPP_BSDOS',
+ DLT => 'PPP_BSDOS',
+ expr => 'link proto 65536',
+ errstr => 'PPP protocol 65536 greater than maximum 65535',
+ },
+ {
+ name => 'link_proto_65536_APPLE_IP_OVER_IEEE1394',
+ DLT => 'APPLE_IP_OVER_IEEE1394', # the default case
+ expr => 'link proto 65536',
+ errstr => 'EtherType 65536 greater than maximum 65535',
+ },
+ # gen_ether_linktype()
+ {
+ name => 'link_proto_65536_EN10MB',
+ DLT => 'EN10MB',
+ expr => 'link proto 65536',
+ errstr => 'EtherType 65536 greater than maximum 65535',
+ },
+ {
+ name => 'link_proto_1500_EN10MB',
+ DLT => 'EN10MB',
+ expr => 'link proto 1500',
+ errstr => 'LLC DSAP 1500 greater than maximum 255',
+ },
+ # gen_llc_linktype
+ {
+ name => 'link_proto_65536_IP_OVER_FC',
+ DLT => 'IP_OVER_FC',
+ expr => 'link proto 65536',
+ errstr => 'EtherType 65536 greater than maximum 65535',
+ },
+ {
+ name => 'link_proto_1500_IP_OVER_FC',
+ DLT => 'IP_OVER_FC',
+ expr => 'link proto 1500',
+ errstr => 'LLC DSAP 1500 greater than maximum 255',
+ },
+ # gen_linux_sll_linktype
+ {
+ name => 'link_proto_65536_LINUX_SLL',
+ DLT => 'LINUX_SLL',
+ expr => 'link proto 65536',
+ errstr => 'EtherType 65536 greater than maximum 65535',
+ },
+ {
+ name => 'link_proto_1500_LINUX_SLL',
+ DLT => 'LINUX_SLL',
+ expr => 'link proto 1500',
+ errstr => 'LLC DSAP 1500 greater than maximum 255',
+ },
);
push @reject_tests, {