-/*
- * Various code constructs need to know the layout of the packet.
- * These variables give the necessary offsets from the beginning
- * of the packet data.
- */
-
-/*
- * Absolute offset of the beginning of the link-layer header.
- */
-static bpf_abs_offset off_linkhdr;
-
-/*
- * If we're checking a link-layer header for a packet encapsulated in
- * another protocol layer, this is the equivalent information for the
- * previous layers' link-layer header from the beginning of the raw
- * packet data.
- */
-static bpf_abs_offset off_prevlinkhdr;
-
-/*
- * This is the equivalent information for the outermost layers' link-layer
- * header.
- */
-static bpf_abs_offset off_outermostlinkhdr;
-
-/*
- * "Push" the current value of the link-layer header type and link-layer
- * header offset onto a "stack", and set a new value. (It's not a
- * full-blown stack; we keep only the top two items.)
- */
-#define PUSH_LINKHDR(new_linktype, new_is_variable, new_constant_part, new_reg) \
-{ \
- prevlinktype = new_linktype; \
- off_prevlinkhdr = off_linkhdr; \
- linktype = new_linktype; \
- off_linkhdr.is_variable = new_is_variable; \
- off_linkhdr.constant_part = new_constant_part; \
- off_linkhdr.reg = new_reg; \
- is_geneve = 0; \
-}
-
-/*
- * Absolute offset of the beginning of the link-layer payload.
- */
-static bpf_abs_offset off_linkpl;
-
-/*
- * "off_linktype" is the offset to information in the link-layer header
- * giving the packet type. This is an absolute offset from the beginning
- * of the packet.
- *
- * For Ethernet, it's the offset of the Ethernet type field; this
- * means that it must have a value that skips VLAN tags.
- *
- * For link-layer types that always use 802.2 headers, it's the
- * offset of the LLC header; this means that it must have a value
- * that skips VLAN tags.
- *
- * For PPP, it's the offset of the PPP type field.
- *
- * For Cisco HDLC, it's the offset of the CHDLC type field.
- *
- * For BSD loopback, it's the offset of the AF_ value.
- *
- * For Linux cooked sockets, it's the offset of the type field.
- *
- * off_linktype.constant_part is set to -1 for no encapsulation,
- * in which case, IP is assumed.
- */
-static bpf_abs_offset off_linktype;
-
-/*
- * TRUE if the link layer includes an ATM pseudo-header.
- */
-static int is_atm = 0;
-
-/*
- * TRUE if "geneve" appeared in the filter; it causes us to generate
- * code that checks for a Geneve header and assume that later filters
- * apply to the encapsulated payload.
- */
-static int is_geneve = 0;
-
-/*
- * These are offsets for the ATM pseudo-header.
- */
-static u_int off_vpi;
-static u_int off_vci;
-static u_int off_proto;
-
-/*
- * These are offsets for the MTP2 fields.
- */
-static u_int off_li;
-static u_int off_li_hsl;
-
-/*
- * These are offsets for the MTP3 fields.
- */
-static u_int off_sio;
-static u_int off_opc;
-static u_int off_dpc;
-static u_int off_sls;
-
-/*
- * This is the offset of the first byte after the ATM pseudo_header,
- * or -1 if there is no ATM pseudo-header.
- */
-static u_int off_payload;
-
-/*
- * These are offsets to the beginning of the network-layer header.
- * They are relative to the beginning of the link-layer payload (i.e.,
- * they don't include off_linkhdr.constant_part or off_linkpl.constant_part).
- *
- * If the link layer never uses 802.2 LLC:
- *
- * "off_nl" and "off_nl_nosnap" are the same.
- *
- * If the link layer always uses 802.2 LLC:
- *
- * "off_nl" is the offset if there's a SNAP header following
- * the 802.2 header;
- *
- * "off_nl_nosnap" is the offset if there's no SNAP header.
- *
- * If the link layer is Ethernet:
- *
- * "off_nl" is the offset if the packet is an Ethernet II packet
- * (we assume no 802.3+802.2+SNAP);
- *
- * "off_nl_nosnap" is the offset if the packet is an 802.3 packet
- * with an 802.2 header following it.
- */
-static u_int off_nl;
-static u_int off_nl_nosnap;
-
-static int linktype;
-static int prevlinktype;
-static int outermostlinktype;
-