ARCNet support, from NetBSD.
This commit is contained in:
parent
80788ad380
commit
38b97b7e84
1
FILES
1
FILES
|
@ -13,6 +13,7 @@ SUNOS4/nit_if.o.sun3
|
|||
SUNOS4/nit_if.o.sun4c.4.0.3c
|
||||
VERSION
|
||||
aclocal.m4
|
||||
arcnet.h
|
||||
bpf/net/bpf.h
|
||||
bpf/net/bpf_filter.c
|
||||
bpf_dump.c
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 1982, 1986, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#) $$ (LBL)
|
||||
*/
|
||||
|
||||
/* RFC 1051 */
|
||||
#define ARCTYPE_IP_OLD 240 /* IP protocol */
|
||||
#define ARCTYPE_ARP_OLD 241 /* address resolution protocol */
|
||||
|
||||
/* RFC 1201 */
|
||||
#define ARCTYPE_IP 212 /* IP protocol */
|
||||
#define ARCTYPE_ARP 213 /* address resolution protocol */
|
||||
#define ARCTYPE_REVARP 214 /* reverse addr resolution protocol */
|
||||
|
||||
#define ARCTYPE_ATALK 221 /* Appletalk */
|
||||
#define ARCTYPE_BANIAN 247 /* Banyan Vines */
|
||||
#define ARCTYPE_IPX 250 /* Novell IPX */
|
||||
|
||||
#define ARCTYPE_INET6 0xc4 /* IPng */
|
||||
#define ARCTYPE_DIAGNOSE 0x80 /* as per ANSI/ATA 878.1 */
|
96
gencode.c
96
gencode.c
|
@ -21,7 +21,7 @@
|
|||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.150 2001-04-17 08:10:00 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.151 2001-04-17 08:25:21 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
@ -55,6 +55,7 @@ struct rtentry;
|
|||
#include "gencode.h"
|
||||
#include "ppp.h"
|
||||
#include "sll.h"
|
||||
#include "arcnet.h"
|
||||
#include <pcap-namedb.h>
|
||||
#ifdef INET6
|
||||
#include <netdb.h>
|
||||
|
@ -141,6 +142,7 @@ static struct block *gen_hostop(bpf_u_int32, bpf_u_int32, int, int, u_int, u_int
|
|||
#ifdef INET6
|
||||
static struct block *gen_hostop6(struct in6_addr *, struct in6_addr *, int, int, u_int, u_int);
|
||||
#endif
|
||||
static struct block *gen_ahostop(const u_char *, int);
|
||||
static struct block *gen_ehostop(const u_char *, int);
|
||||
static struct block *gen_fhostop(const u_char *, int);
|
||||
static struct block *gen_thostop(const u_char *, int);
|
||||
|
@ -547,6 +549,11 @@ init_linktype(type)
|
|||
|
||||
switch (type) {
|
||||
|
||||
case DLT_ARCNET:
|
||||
off_linktype = 2;
|
||||
off_nl = 6; /* XXX in reality, variable! */
|
||||
return;
|
||||
|
||||
case DLT_EN10MB:
|
||||
off_linktype = 12;
|
||||
off_nl = 14;
|
||||
|
@ -1310,6 +1317,40 @@ gen_linktype(proto)
|
|||
proto = htonl(proto);
|
||||
}
|
||||
return (gen_cmp(0, BPF_W, (bpf_int32)proto));
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3557,6 +3598,8 @@ gen_byteop(op, idx, val)
|
|||
return b;
|
||||
}
|
||||
|
||||
static u_char abroadcast[] = { 0x0 };
|
||||
|
||||
struct block *
|
||||
gen_broadcast(proto)
|
||||
int proto;
|
||||
|
@ -3569,6 +3612,8 @@ gen_broadcast(proto)
|
|||
|
||||
case Q_DEFAULT:
|
||||
case Q_LINK:
|
||||
if (linktype == DLT_ARCNET)
|
||||
return gen_ahostop(abroadcast, Q_DST);
|
||||
if (linktype == DLT_EN10MB)
|
||||
return gen_ehostop(ebroadcast, Q_DST);
|
||||
if (linktype == DLT_FDDI)
|
||||
|
@ -3602,6 +3647,10 @@ gen_multicast(proto)
|
|||
|
||||
case Q_DEFAULT:
|
||||
case Q_LINK:
|
||||
if (linktype == DLT_ARCNET)
|
||||
/* all ARCnet multicasts use the same address */
|
||||
return gen_ahostop(abroadcast, Q_DST);
|
||||
|
||||
if (linktype == DLT_EN10MB) {
|
||||
/* ether[0] & 1 != 0 */
|
||||
s = new_stmt(BPF_LD|BPF_B|BPF_ABS);
|
||||
|
@ -3679,6 +3728,51 @@ gen_inbound(dir)
|
|||
return (b0);
|
||||
}
|
||||
|
||||
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 */
|
||||
}
|
||||
|
||||
/*
|
||||
* support IEEE 802.1Q VLAN trunk over ethernet
|
||||
*/
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.51 2001-02-21 09:33:05 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.52 2001-04-17 08:25:22 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/* Address qualifiers. */
|
||||
|
@ -173,6 +173,7 @@ void gen_not(struct block *);
|
|||
|
||||
struct block *gen_scode(const char *, struct qual);
|
||||
struct block *gen_ecode(const u_char *, struct qual);
|
||||
struct block *gen_acode(const u_char *, struct qual);
|
||||
struct block *gen_mcode(const char *, const char *, int, struct qual);
|
||||
#ifdef INET6
|
||||
struct block *gen_mcode6(const char *, const char *, int, struct qual);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.68 2001-02-21 09:33:05 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.69 2001-04-17 08:25:23 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
@ -112,7 +112,7 @@ pcap_parse()
|
|||
%token NUM INBOUND OUTBOUND
|
||||
%token LINK
|
||||
%token GEQ LEQ NEQ
|
||||
%token ID EID HID HID6
|
||||
%token ID EID HID HID6 AID
|
||||
%token LSH RSH
|
||||
%token LEN
|
||||
%token IPV6 ICMPV6 AH ESP
|
||||
|
@ -124,6 +124,7 @@ pcap_parse()
|
|||
|
||||
%type <s> ID
|
||||
%type <e> EID
|
||||
%type <e> AID
|
||||
%type <s> HID HID6
|
||||
%type <i> NUM
|
||||
|
||||
|
@ -188,6 +189,7 @@ nid: ID { $$.b = gen_scode($1, $$.q = $<blk>0.q); }
|
|||
#endif /*INET6*/
|
||||
}
|
||||
| EID { $$.b = gen_ecode($1, $$.q = $<blk>0.q); }
|
||||
| AID { $$.b = gen_acode($1, $$.q = $<blk>0.q); }
|
||||
| not id { gen_not($2.b); $$ = $2; }
|
||||
;
|
||||
not: '!' { $$ = $<blk>0; }
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.75 2001-02-24 18:21:14 mcr Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.76 2001-04-17 08:25:23 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
@ -243,6 +243,8 @@ vlan return VLAN;
|
|||
"==" return '=';
|
||||
"<<" return LSH;
|
||||
">>" return RSH;
|
||||
${B} { yylval.e = pcap_ether_aton(((char *)yytext)+1);
|
||||
return AID; }
|
||||
{N} { yylval.i = stoi((char *)yytext); return NUM; }
|
||||
({N}\.{N})|({N}\.{N}\.{N})|({N}\.{N}\.{N}\.{N}) {
|
||||
yylval.s = sdup((char *)yytext); return HID; }
|
||||
|
|
Reference in New Issue