Deleted Added
full compact
22c22
< * $FreeBSD: head/contrib/libpcap/gencode.c 75110 2001-04-03 04:32:48Z fenner $
---
> * $FreeBSD: head/contrib/libpcap/gencode.c 98533 2002-06-21 01:38:14Z fenner $
26c26
< "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.140.2.1 2001/01/14 06:48:35 guy Exp $ (LBL)";
---
> "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.160 2001/11/30 07:25:48 guy Exp $ (LBL)";
55a56
> #include "llc.h"
58a60
> #include "arcnet.h"
65,67d66
< #define LLC_SNAP_LSAP 0xaa
< #define LLC_ISO_LSAP 0xfe
<
70a70,73
> #ifndef IPPROTO_SCTP
> #define IPPROTO_SCTP 132
> #endif
>
80a84,86
> /* Hack for updating VLAN offsets. */
> static u_int orig_linktype = -1, orig_nl = -1;
>
148a155
> static struct block *gen_ahostop(const u_char *, int);
552a560,562
> orig_linktype = -1;
> orig_nl = -1;
>
554a565,569
> case DLT_ARCNET:
> off_linktype = 2;
> off_nl = 6; /* XXX in reality, variable! */
> return;
>
583,584c598,599
< case DLT_C_HDLC:
< case DLT_PPP_SERIAL:
---
> case DLT_C_HDLC: /* BSD/OS Cisco HDLC */
> case DLT_PPP_SERIAL: /* NetBSD sync/async serial PPP */
588a604,612
> case DLT_PPP_ETHER:
> /*
> * This does no include the Ethernet header, and
> * only covers session state.
> */
> off_linktype = 6;
> off_nl = 8;
> return;
>
597,598c621
< * We assume that SSAP = SNAP is being used and pick
< * out the encapsulated Ethernet type.
---
> * We set "off_linktype" to the offset of the LLC header.
599a623,624
> * To check for Ethernet types, we assume that SSAP = SNAP
> * is being used and pick out the encapsulated Ethernet type.
602c627
< off_linktype = 19;
---
> off_linktype = 13;
615,616c640
< * We assume that SSAP = SNAP is being used and pick
< * out the encapsulated Ethernet type.
---
> * We set "off_linktype" to the offset of the LLC header.
617a642,643
> * To check for Ethernet types, we assume that SSAP = SNAP
> * is being used and pick out the encapsulated Ethernet type.
635c661
< off_linktype = 20;
---
> off_linktype = 14;
638a665,696
> case DLT_IEEE802_11:
> /*
> * 802.11 doesn't really have a link-level type field.
> * We set "off_linktype" to the offset of the LLC header.
> *
> * To check for Ethernet types, we assume that SSAP = SNAP
> * is being used and pick out the encapsulated Ethernet type.
> * XXX - should we generate code to check for SNAP?
> *
> * XXX - the header is actually variable-length. We
> * assume a 24-byte link-layer header, as appears in
> * data frames in networks with no bridges.
> */
> off_linktype = 24;
> off_nl = 30;
> return;
>
> case DLT_PRISM_HEADER:
> /*
> * Same as 802.11, but with an additional header before
> * the 802.11 header, containing a bunch of additional
> * information including radio-level information.
> *
> * The header is 144 bytes long.
> *
> * XXX - same variable-length header problem; at least
> * the Prism header is fixed-length.
> */
> off_linktype = 144+24;
> off_nl = 144+30;
> return;
>
661a720,729
>
> case DLT_LTALK:
> /*
> * LocalTalk does have a 1-byte type field in the LLAP header,
> * but really it just indicates whether there is a "short" or
> * "long" DDP packet following.
> */
> off_linktype = -1;
> off_nl = 0;
> return;
708,711d775
< /* If we're not using encapsulation, we're done */
< if (off_linktype == -1)
< return gen_true();
<
715,718d778
< /*
< * XXX - handle other LLC-encapsulated protocols here
< * (IPX, OSI)?
< */
721c781
< case LLC_ISO_LSAP:
---
> case LLCSAP_ISONS:
723a784,786
> * XXX - should we check both the DSAP and the
> * SSAP, like this, or should we check just the
> * DSAP?
728c791
< ((LLC_ISO_LSAP << 8) | LLC_ISO_LSAP));
---
> ((LLCSAP_ISONS << 8) | LLCSAP_ISONS));
731a795,879
> case LLCSAP_NETBEUI:
> /*
> * NetBEUI always uses 802.2 encapsulation.
> * XXX - should we check both the DSAP and the
> * SSAP, like this, or should we check just the
> * DSAP?
> */
> b0 = gen_cmp_gt(off_linktype, BPF_H, ETHERMTU);
> gen_not(b0);
> b1 = gen_cmp(off_linktype + 2, BPF_H, (bpf_int32)
> ((LLCSAP_NETBEUI << 8) | LLCSAP_NETBEUI));
> gen_and(b0, b1);
> return b1;
>
> case LLCSAP_IPX:
> /*
> * Check for;
> *
> * Ethernet_II frames, which are Ethernet
> * frames with a frame type of ETHERTYPE_IPX;
> *
> * Ethernet_802.3 frames, which are 802.3
> * frames (i.e., the type/length field is
> * a length field, <= ETHERMTU, rather than
> * a type field) with the first two bytes
> * after the Ethernet/802.3 header being
> * 0xFFFF;
> *
> * Ethernet_802.2 frames, which are 802.3
> * frames with an 802.2 LLC header and
> * with the IPX LSAP as the DSAP in the LLC
> * header;
> *
> * Ethernet_SNAP frames, which are 802.3
> * frames with an LLC header and a SNAP
> * header and with an OUI of 0x000000
> * (encapsulated Ethernet) and a protocol
> * ID of ETHERTYPE_IPX in the SNAP header.
> *
> * XXX - should we generate the same code both
> * for tests for LLCSAP_IPX and for ETHERTYPE_IPX?
> */
>
> /*
> * This generates code to check both for the
> * IPX LSAP (Ethernet_802.2) and for Ethernet_802.3.
> */
> b0 = gen_cmp(off_linktype + 2, BPF_B,
> (bpf_int32)LLCSAP_IPX);
> b1 = gen_cmp(off_linktype + 2, BPF_H,
> (bpf_int32)0xFFFF);
> gen_or(b0, b1);
>
> /*
> * Now we add code to check for SNAP frames with
> * ETHERTYPE_IPX, i.e. Ethernet_SNAP.
> */
> b0 = gen_snap(0x000000, ETHERTYPE_IPX, 14);
> gen_or(b0, b1);
>
> /*
> * Now we generate code to check for 802.3
> * frames in general.
> */
> b0 = gen_cmp_gt(off_linktype, BPF_H, ETHERMTU);
> gen_not(b0);
>
> /*
> * Now add the check for 802.3 frames before the
> * check for Ethernet_802.2 and Ethernet_802.3,
> * as those checks should only be done on 802.3
> * frames, not on Ethernet frames.
> */
> gen_and(b0, b1);
>
> /*
> * Now add the check for Ethernet_II frames, and
> * do that before checking for the other frame
> * types.
> */
> b0 = gen_cmp(off_linktype, BPF_H,
> (bpf_int32)ETHERTYPE_IPX);
> gen_or(b0, b1);
> return b1;
>
772a921,950
>
> default:
> if (proto <= ETHERMTU) {
> /*
> * This is an LLC SAP value, so the frames
> * that match would be 802.2 frames.
> * Check that the frame is an 802.2 frame
> * (i.e., that the length/type field is
> * a length field, <= ETHERMTU) and
> * then check the DSAP.
> */
> b0 = gen_cmp_gt(off_linktype, BPF_H, ETHERMTU);
> gen_not(b0);
> b1 = gen_cmp(off_linktype + 2, BPF_B,
> (bpf_int32)proto);
> gen_and(b0, b1);
> return b1;
> } else {
> /*
> * This is an Ethernet type, so compare
> * the length/type field with it (if
> * the frame is an 802.2 frame, the length
> * field will be <= ETHERMTU, and, as
> * "proto" is > ETHERMTU, this test
> * will fail and the frame won't match,
> * which is what we want).
> */
> return gen_cmp(off_linktype, BPF_H,
> (bpf_int32)proto);
> }
775a954,1189
> case DLT_IEEE802_11:
> case DLT_PRISM_HEADER:
> case DLT_FDDI:
> case DLT_IEEE802:
> case DLT_ATM_RFC1483:
> case DLT_ATM_CLIP:
> /*
> * XXX - handle token-ring variable-length header.
> */
> switch (proto) {
>
> case LLCSAP_ISONS:
> return gen_cmp(off_linktype, BPF_H, (long)
> ((LLCSAP_ISONS << 8) | LLCSAP_ISONS));
>
> case LLCSAP_NETBEUI:
> return gen_cmp(off_linktype, BPF_H, (long)
> ((LLCSAP_NETBEUI << 8) | LLCSAP_NETBEUI));
>
> case LLCSAP_IPX:
> /*
> * XXX - are there ever SNAP frames for IPX on
> * non-Ethernet 802.x networks?
> */
> return gen_cmp(off_linktype, BPF_B,
> (bpf_int32)LLCSAP_IPX);
>
> case ETHERTYPE_ATALK:
> /*
> * 802.2-encapsulated ETHERTYPE_ATALK packets are
> * SNAP packets with an organization code of
> * 0x080007 (Apple, for Appletalk) and a protocol
> * type of ETHERTYPE_ATALK (Appletalk).
> *
> * XXX - check for an organization code of
> * encapsulated Ethernet as well?
> */
> return gen_snap(0x080007, ETHERTYPE_ATALK,
> off_linktype);
> break;
>
> default:
> /*
> * XXX - we don't have to check for IPX 802.3
> * here, but should we check for the IPX Ethertype?
> */
> if (proto <= ETHERMTU) {
> /*
> * This is an LLC SAP value, so check
> * the DSAP.
> */
> return gen_cmp(off_linktype, BPF_B,
> (bpf_int32)proto);
> } else {
> /*
> * This is an Ethernet type; we assume
> * that it's unlikely that it'll
> * appear in the right place at random,
> * and therefore check only the
> * location that would hold the Ethernet
> * type in a SNAP frame with an organization
> * code of 0x000000 (encapsulated Ethernet).
> *
> * XXX - if we were to check for the SNAP DSAP
> * and LSAP, as per XXX, and were also to check
> * for an organization code of 0x000000
> * (encapsulated Ethernet), we'd do
> *
> * return gen_snap(0x000000, proto,
> * off_linktype);
> *
> * here; for now, we don't, as per the above.
> * I don't know whether it's worth the
> * extra CPU time to do the right check
> * or not.
> */
> return gen_cmp(off_linktype+6, BPF_H,
> (bpf_int32)proto);
> }
> }
> break;
>
> case DLT_LINUX_SLL:
> switch (proto) {
>
> case LLCSAP_ISONS:
> /*
> * OSI protocols always use 802.2 encapsulation.
> * XXX - should we check both the DSAP and the
> * LSAP, like this, or should we check just the
> * DSAP?
> */
> b0 = gen_cmp(off_linktype, BPF_H, LINUX_SLL_P_802_2);
> b1 = gen_cmp(off_linktype + 2, BPF_H, (bpf_int32)
> ((LLCSAP_ISONS << 8) | LLCSAP_ISONS));
> gen_and(b0, b1);
> return b1;
>
> case LLCSAP_NETBEUI:
> /*
> * NetBEUI always uses 802.2 encapsulation.
> * XXX - should we check both the DSAP and the
> * LSAP, like this, or should we check just the
> * DSAP?
> */
> b0 = gen_cmp(off_linktype, BPF_H, LINUX_SLL_P_802_2);
> b1 = gen_cmp(off_linktype + 2, BPF_H, (bpf_int32)
> ((LLCSAP_NETBEUI << 8) | LLCSAP_NETBEUI));
> gen_and(b0, b1);
> return b1;
>
> case LLCSAP_IPX:
> /*
> * Ethernet_II frames, which are Ethernet
> * frames with a frame type of ETHERTYPE_IPX;
> *
> * Ethernet_802.3 frames, which have a frame
> * type of LINUX_SLL_P_802_3;
> *
> * Ethernet_802.2 frames, which are 802.3
> * frames with an 802.2 LLC header (i.e, have
> * a frame type of LINUX_SLL_P_802_2) and
> * with the IPX LSAP as the DSAP in the LLC
> * header;
> *
> * Ethernet_SNAP frames, which are 802.3
> * frames with an LLC header and a SNAP
> * header and with an OUI of 0x000000
> * (encapsulated Ethernet) and a protocol
> * ID of ETHERTYPE_IPX in the SNAP header.
> *
> * First, do the checks on LINUX_SLL_P_802_2
> * frames; generate the check for either
> * Ethernet_802.2 or Ethernet_SNAP frames, and
> * then put a check for LINUX_SLL_P_802_2 frames
> * before it.
> */
> b0 = gen_cmp(off_linktype + 2, BPF_B,
> (bpf_int32)LLCSAP_IPX);
> b1 = gen_snap(0x000000, ETHERTYPE_IPX,
> off_linktype + 2);
> gen_or(b0, b1);
> b0 = gen_cmp(off_linktype, BPF_H, LINUX_SLL_P_802_2);
> gen_and(b0, b1);
>
> /*
> * Now check for 802.3 frames and OR that with
> * the previous test.
> */
> b0 = gen_cmp(off_linktype, BPF_H, LINUX_SLL_P_802_3);
> gen_or(b0, b1);
>
> /*
> * Now add the check for Ethernet_II frames, and
> * do that before checking for the other frame
> * types.
> */
> b0 = gen_cmp(off_linktype, BPF_H,
> (bpf_int32)ETHERTYPE_IPX);
> gen_or(b0, b1);
> return b1;
>
> case ETHERTYPE_ATALK:
> case ETHERTYPE_AARP:
> /*
> * EtherTalk (AppleTalk protocols on Ethernet link
> * layer) may use 802.2 encapsulation.
> */
>
> /*
> * Check for 802.2 encapsulation (EtherTalk phase 2?);
> * we check for the 802.2 protocol type in the
> * "Ethernet type" field.
> */
> b0 = gen_cmp(off_linktype, BPF_H, LINUX_SLL_P_802_2);
>
> /*
> * 802.2-encapsulated ETHERTYPE_ATALK packets are
> * SNAP packets with an organization code of
> * 0x080007 (Apple, for Appletalk) and a protocol
> * type of ETHERTYPE_ATALK (Appletalk).
> *
> * 802.2-encapsulated ETHERTYPE_AARP packets are
> * SNAP packets with an organization code of
> * 0x000000 (encapsulated Ethernet) and a protocol
> * type of ETHERTYPE_AARP (Appletalk ARP).
> */
> if (proto == ETHERTYPE_ATALK)
> b1 = gen_snap(0x080007, ETHERTYPE_ATALK,
> off_linktype + 2);
> else /* proto == ETHERTYPE_AARP */
> b1 = gen_snap(0x000000, ETHERTYPE_AARP,
> off_linktype + 2);
> gen_and(b0, b1);
>
> /*
> * Check for Ethernet encapsulation (Ethertalk
> * phase 1?); we just check for the Ethernet
> * protocol type.
> */
> b0 = gen_cmp(off_linktype, BPF_H, (bpf_int32)proto);
>
> gen_or(b0, b1);
> return b1;
>
> default:
> if (proto <= ETHERMTU) {
> /*
> * This is an LLC SAP value, so the frames
> * that match would be 802.2 frames.
> * Check for the 802.2 protocol type
> * in the "Ethernet type" field, and
> * then check the DSAP.
> */
> b0 = gen_cmp(off_linktype, BPF_H,
> LINUX_SLL_P_802_2);
> b1 = gen_cmp(off_linktype + 2, BPF_B,
> (bpf_int32)proto);
> gen_and(b0, b1);
> return b1;
> } else {
> /*
> * This is an Ethernet type, so compare
> * the length/type field with it (if
> * the frame is an 802.2 frame, the length
> * field will be <= ETHERMTU, and, as
> * "proto" is > ETHERMTU, this test
> * will fail and the frame won't match,
> * which is what we want).
> */
> return gen_cmp(off_linktype, BPF_H,
> (bpf_int32)proto);
> }
> }
> break;
>
777c1191,1200
< return gen_false();
---
> case DLT_SLIP_BSDOS:
> case DLT_RAW:
> /*
> * These types don't provide any type field; packets
> * are always IP.
> *
> * XXX - for IPv4, check for a version number of 4, and,
> * for IPv6, check for a version number of 6?
> */
> switch (proto) {
778a1202,1212
> case ETHERTYPE_IP:
> #ifdef INET6
> case ETHERTYPE_IPV6:
> #endif
> return gen_true(); /* always true */
>
> default:
> return gen_false(); /* always false */
> }
> break;
>
780a1215
> case DLT_PPP_ETHER:
809c1244
< case LLC_ISO_LSAP:
---
> case LLCSAP_ISONS:
811a1247,1259
>
> case LLCSAP_8021D:
> /*
> * I'm assuming the "Bridging PDU"s that go
> * over PPP are Spanning Tree Protocol
> * Bridging PDUs.
> */
> proto = PPP_BRPDU;
> break;
>
> case LLCSAP_IPX:
> proto = PPP_IPX;
> break;
849c1297
< case LLC_ISO_LSAP:
---
> case LLCSAP_ISONS:
851a1300,1312
>
> case LLCSAP_8021D:
> /*
> * I'm assuming the "Bridging PDU"s that go
> * over PPP are Spanning Tree Protocol
> * Bridging PDUs.
> */
> proto = PPP_BRPDU;
> break;
>
> case LLCSAP_IPX:
> proto = PPP_IPX;
> break;
915a1377,1419
>
> case DLT_ARCNET:
> /*
> * XXX should we check for first fragment if the protocol
> * uses PHDS?
> */
> switch(proto) {
> default:
> return gen_false();
> #ifdef INET6
> case ETHERTYPE_IPV6:
> return(gen_cmp(2, BPF_B,
> (bpf_int32)htonl(ARCTYPE_INET6)));
> #endif /* INET6 */
> case ETHERTYPE_IP:
> b0 = gen_cmp(2, BPF_B, (bpf_int32)htonl(ARCTYPE_IP));
> b1 = gen_cmp(2, BPF_B,
> (bpf_int32)htonl(ARCTYPE_IP_OLD));
> gen_or(b0, b1);
> return(b1);
> case ETHERTYPE_ARP:
> b0 = gen_cmp(2, BPF_B, (bpf_int32)htonl(ARCTYPE_ARP));
> b1 = gen_cmp(2, BPF_B,
> (bpf_int32)htonl(ARCTYPE_ARP_OLD));
> gen_or(b0, b1);
> return(b1);
> case ETHERTYPE_REVARP:
> return(gen_cmp(2, BPF_B,
> (bpf_int32)htonl(ARCTYPE_REVARP)));
> case ETHERTYPE_ATALK:
> return(gen_cmp(2, BPF_B,
> (bpf_int32)htonl(ARCTYPE_ATALK)));
> }
> break;
>
> case DLT_LTALK:
> switch (proto) {
> case ETHERTYPE_ATALK:
> return gen_true();
> default:
> return gen_false();
> }
> break;
916a1421,1443
>
> /*
> * All the types that have no encapsulation should either be
> * handled as DLT_SLIP, DLT_SLIP_BSDOS, and DLT_RAW are, if
> * all packets are IP packets, or should be handled in some
> * special case, if none of them are (if some are and some
> * aren't, the lack of encapsulation is a problem, as we'd
> * have to find some other way of determining the packet type).
> *
> * Therefore, if "off_linktype" is -1, there's an error.
> */
> if (off_linktype == -1)
> abort();
>
> /*
> * Any type not handled above should always have an Ethernet
> * type at an offset of "off_linktype". (PPP is partially
> * handled above - the protocol type is mapped from the
> * Ethernet and LLC types we use internally to the corresponding
> * PPP type - but the PPP type is always specified by a value
> * at "off_linktype", so we don't have to do the code generation
> * above.)
> */
935,936c1462,1463
< snapblock[0] = LLC_SNAP_LSAP; /* DSAP = SNAP */
< snapblock[1] = LLC_SNAP_LSAP; /* SSAP = SNAP */
---
> snapblock[0] = LLCSAP_SNAP; /* DSAP = SNAP */
> snapblock[1] = LLCSAP_SNAP; /* SSAP = SNAP */
1275a1803,1805
> case Q_SCTP:
> bpf_error("'sctp' modifier applied to host");
>
1290a1821,1823
> case Q_VRRP:
> bpf_error("'vrrp' modifier applied to host");
>
1337a1871,1879
> case Q_STP:
> bpf_error("'stp' modifier applied to host");
>
> case Q_IPX:
> bpf_error("IPX host filtering not implemented");
>
> case Q_NETBEUI:
> bpf_error("'netbeui' modifier applied to host");
>
1365a1908,1910
> case Q_SCTP:
> bpf_error("'sctp' modifier applied to host");
>
1383a1929,1931
> case Q_VRRP:
> bpf_error("'vrrp' modifier applied to host");
>
1429a1978,1986
> case Q_STP:
> bpf_error("'stp' modifier applied to host");
>
> case Q_IPX:
> bpf_error("IPX host filtering not implemented");
>
> case Q_NETBEUI:
> bpf_error("'netbeui' modifier applied to host");
>
1490a2048,2055
> case Q_SCTP:
> b1 = gen_proto(IPPROTO_SCTP, Q_IP, Q_DEFAULT);
> #ifdef INET6
> b0 = gen_proto(IPPROTO_SCTP, Q_IPV6, Q_DEFAULT);
> gen_or(b0, b1);
> #endif
> break;
>
1537a2103,2110
> #ifndef IPPROTO_VRRP
> #define IPPROTO_VRRP 112
> #endif
>
> case Q_VRRP:
> b1 = gen_proto(IPPROTO_VRRP, Q_IP, Q_DEFAULT);
> break;
>
1617c2190
< b1 = gen_linktype(LLC_ISO_LSAP);
---
> b1 = gen_linktype(LLCSAP_ISONS);
1631a2205,2216
> case Q_STP:
> b1 = gen_linktype(LLCSAP_8021D);
> break;
>
> case Q_IPX:
> b1 = gen_linktype(LLCSAP_IPX);
> break;
>
> case Q_NETBEUI:
> b1 = gen_linktype(LLCSAP_NETBEUI);
> break;
>
1740a2326
> case IPPROTO_SCTP:
1747a2334,2335
> tmp = gen_portop(port, IPPROTO_SCTP, dir);
> gen_or(tmp, b1);
1810a2399
> case IPPROTO_SCTP:
1817a2407,2408
> tmp = gen_portop6(port, IPPROTO_SCTP, dir);
> gen_or(tmp, b1);
1838a2430
> case Q_IPV6:
2203c2795
< b0 = gen_linktype(LLC_ISO_LSAP);
---
> b0 = gen_linktype(LLCSAP_ISONS);
2250a2843,2846
> case Q_SCTP:
> bpf_error("'sctp proto' is bogus");
> /* NOTREACHED */
>
2266a2863,2866
> case Q_VRRP:
> bpf_error("'vrrp proto' is bogus");
> /* NOTREACHED */
>
2287a2888,2896
> case Q_STP:
> bpf_error("'stp proto' is bogus");
>
> case Q_IPX:
> bpf_error("'ipx proto' is bogus");
>
> case Q_NETBEUI:
> bpf_error("'netbeui proto' is bogus");
>
2341c2950,2952
< return gen_ehostop(eaddr, dir);
---
> b = gen_ehostop(eaddr, dir);
> free(eaddr);
> return b;
2348c2959,2961
< return gen_fhostop(eaddr, dir);
---
> b = gen_fhostop(eaddr, dir);
> free(eaddr);
> return b;
2355c2968,2970
< return gen_thostop(eaddr, dir);
---
> b = gen_thostop(eaddr, dir);
> free(eaddr);
> return b;
2415a3031,3032
> default:
> continue;
2433c3050,3051
< if (proto != Q_DEFAULT && proto != Q_UDP && proto != Q_TCP)
---
> if (proto != Q_DEFAULT &&
> proto != Q_UDP && proto != Q_TCP && proto != Q_SCTP)
2439a3058,3059
> else if (real_proto == IPPROTO_SCTP)
> bpf_error("port '%s' is sctp", name);
2446a3067,3069
>
> else if (real_proto == IPPROTO_SCTP)
> bpf_error("port '%s' is sctp", name);
2450a3074,3083
> if (proto == Q_SCTP) {
> if (real_proto == IPPROTO_UDP)
> bpf_error("port '%s' is udp", name);
>
> else if (real_proto == IPPROTO_TCP)
> bpf_error("port '%s' is tcp", name);
> else
> /* override PROTO_UNDEF */
> real_proto = IPPROTO_SCTP;
> }
2471c3104,3106
< return gen_gateway(eaddr, alist, proto, dir);
---
> b = gen_gateway(eaddr, alist, proto, dir);
> free(eaddr);
> return b;
2587a3223,3224
> else if (proto == Q_SCTP)
> proto = IPPROTO_SCTP;
2649a3287
> memset(&mask, 0, sizeof(mask));
2799a3438
> case Q_SCTP:
2805a3445
> case Q_VRRP:
3079a3720,3721
> static u_char abroadcast[] = { 0x0 };
>
3091a3734,3735
> if (linktype == DLT_ARCNET)
> return gen_ahostop(abroadcast, Q_DST);
3124a3769,3772
> if (linktype == DLT_ARCNET)
> /* all ARCnet multicasts use the same address */
> return gen_ahostop(abroadcast, Q_DST);
>
3201a3850,3894
> struct block *
> gen_acode(eaddr, q)
> register const u_char *eaddr;
> struct qual q;
> {
> if ((q.addr == Q_HOST || q.addr == Q_DEFAULT) && q.proto == Q_LINK) {
> if (linktype == DLT_ARCNET)
> return gen_ahostop(eaddr, (int)q.dir);
> }
> bpf_error("ARCnet address used in non-arc expression");
> /* NOTREACHED */
> }
>
> static struct block *
> gen_ahostop(eaddr, dir)
> register const u_char *eaddr;
> register int dir;
> {
> register struct block *b0, *b1;
>
> switch (dir) {
> /* src comes first, different from Ethernet */
> case Q_SRC:
> return gen_bcmp(0, 1, eaddr);
>
> case Q_DST:
> return gen_bcmp(1, 1, eaddr);
>
> case Q_AND:
> b0 = gen_ahostop(eaddr, Q_SRC);
> b1 = gen_ahostop(eaddr, Q_DST);
> gen_and(b0, b1);
> return b1;
>
> case Q_DEFAULT:
> case Q_OR:
> b0 = gen_ahostop(eaddr, Q_SRC);
> b1 = gen_ahostop(eaddr, Q_DST);
> gen_or(b0, b1);
> return b1;
> }
> abort();
> /* NOTREACHED */
> }
>
3209d3901
< static u_int orig_linktype = -1, orig_nl = -1;