Skip to content

Commit ec782d0

Browse files
committed
filter compiler: fix handling of some DLT_ values.
Add explicit cases for the remaining assigned values, supporting only raw "link[N:M]" filtering. For values that aren't assigned, don't put a range in the error message; there are valid values outside that range (e.g., 1 is used for some obscure technology DEC, Intel, and Xerox standardized, running on a thick yellow cable, and its successors).
1 parent 6db7039 commit ec782d0

File tree

1 file changed

+79
-2
lines changed

1 file changed

+79
-2
lines changed

gencode.c

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,6 +2135,83 @@ init_linktype(compiler_state_t *cstate, pcap_t *p)
21352135
cstate->off_nl_nosnap = 3; /* 802.3+802.2 */
21362136
break;
21372137

2138+
case DLT_EN3MB:
2139+
/*
2140+
* Currently, only raw "link[N:M]" filtering is supported.
2141+
*/
2142+
cstate->off_linktype.constant_part = OFFSET_NOT_SET; /* variable, min 15, max 71 steps of 7 */
2143+
cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
2144+
cstate->off_nl = OFFSET_NOT_SET; /* variable, min 16, max 71 steps of 7 */
2145+
cstate->off_nl_nosnap = OFFSET_NOT_SET; /* no 802.2 LLC */
2146+
break;
2147+
2148+
case DLT_AX25:
2149+
/*
2150+
* Currently, only raw "link[N:M]" filtering is supported.
2151+
*/
2152+
cstate->off_linktype.constant_part = OFFSET_NOT_SET; /* variable, min 15, max 71 steps of 7 */
2153+
cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
2154+
cstate->off_nl = OFFSET_NOT_SET; /* variable, min 16, max 71 steps of 7 */
2155+
cstate->off_nl_nosnap = OFFSET_NOT_SET; /* no 802.2 LLC */
2156+
break;
2157+
2158+
case DLT_PRONET:
2159+
/*
2160+
* Currently, only raw "link[N:M]" filtering is supported.
2161+
*/
2162+
cstate->off_linktype.constant_part = OFFSET_NOT_SET; /* variable, min 15, max 71 steps of 7 */
2163+
cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
2164+
cstate->off_nl = OFFSET_NOT_SET; /* variable, min 16, max 71 steps of 7 */
2165+
cstate->off_nl_nosnap = OFFSET_NOT_SET; /* no 802.2 LLC */
2166+
break;
2167+
2168+
case DLT_CHAOS:
2169+
/*
2170+
* Currently, only raw "link[N:M]" filtering is supported.
2171+
*/
2172+
cstate->off_linktype.constant_part = OFFSET_NOT_SET; /* variable, min 15, max 71 steps of 7 */
2173+
cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
2174+
cstate->off_nl = OFFSET_NOT_SET; /* variable, min 16, max 71 steps of 7 */
2175+
cstate->off_nl_nosnap = OFFSET_NOT_SET; /* no 802.2 LLC */
2176+
break;
2177+
2178+
#ifdef DLT_HIPPI
2179+
case DLT_HIPPI:
2180+
/*
2181+
* Currently, only raw "link[N:M]" filtering is supported.
2182+
*/
2183+
cstate->off_linktype.constant_part = OFFSET_NOT_SET; /* variable, min 15, max 71 steps of 7 */
2184+
cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
2185+
cstate->off_nl = OFFSET_NOT_SET; /* variable, min 16, max 71 steps of 7 */
2186+
cstate->off_nl_nosnap = OFFSET_NOT_SET; /* no 802.2 LLC */
2187+
break;
2188+
2189+
#endif
2190+
2191+
case DLT_REDBACK_SMARTEDGE:
2192+
/*
2193+
* Currently, only raw "link[N:M]" filtering is supported.
2194+
*/
2195+
cstate->off_linktype.constant_part = OFFSET_NOT_SET; /* variable, min 15, max 71 steps of 7 */
2196+
cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
2197+
cstate->off_nl = OFFSET_NOT_SET; /* variable, min 16, max 71 steps of 7 */
2198+
cstate->off_nl_nosnap = OFFSET_NOT_SET; /* no 802.2 LLC */
2199+
break;
2200+
2201+
2202+
#ifdef DLT_HHDLC
2203+
case DLT_HHDLC:
2204+
/*
2205+
* Currently, only raw "link[N:M]" filtering is supported.
2206+
*/
2207+
cstate->off_linktype.constant_part = OFFSET_NOT_SET; /* variable, min 15, max 71 steps of 7 */
2208+
cstate->off_linkpl.constant_part = OFFSET_NOT_SET;
2209+
cstate->off_nl = OFFSET_NOT_SET; /* variable, min 16, max 71 steps of 7 */
2210+
cstate->off_nl_nosnap = OFFSET_NOT_SET; /* no 802.2 LLC */
2211+
break;
2212+
2213+
#endif
2214+
21382215
default:
21392216
/*
21402217
* For values in the range in which we've assigned new
@@ -2147,8 +2224,8 @@ init_linktype(compiler_state_t *cstate, pcap_t *p)
21472224
cstate->off_nl = OFFSET_NOT_SET;
21482225
cstate->off_nl_nosnap = OFFSET_NOT_SET;
21492226
} else {
2150-
bpf_set_error(cstate, "unknown data link type %d (min %d, max %d)",
2151-
cstate->linktype, DLT_HIGH_MATCHING_MIN, DLT_HIGH_MATCHING_MAX);
2227+
bpf_set_error(cstate, "unknown data link type %d",
2228+
cstate->linktype);
21522229
return (-1);
21532230
}
21542231
break;

0 commit comments

Comments
 (0)