Add SunATM support, based on code from Yen Yen Lim at North Dakota State
University.
This commit is contained in:
parent
0d02000200
commit
243b20ec55
1
CREDITS
1
CREDITS
|
@ -54,6 +54,7 @@ Additional people who have contributed patches:
|
||||||
Uns Lider <unslider@miranda.org>
|
Uns Lider <unslider@miranda.org>
|
||||||
Uwe Girlich <Uwe.Girlich@philosys.de>
|
Uwe Girlich <Uwe.Girlich@philosys.de>
|
||||||
Xianjie Zhang <xzhang@cup.hp.com>
|
Xianjie Zhang <xzhang@cup.hp.com>
|
||||||
|
Yen Yen Lim
|
||||||
|
|
||||||
The original LBL crew:
|
The original LBL crew:
|
||||||
Steve McCanne
|
Steve McCanne
|
||||||
|
|
2
FILES
2
FILES
|
@ -15,6 +15,7 @@ SUNOS4/nit_if.o.sun4c.4.0.3c
|
||||||
VERSION
|
VERSION
|
||||||
aclocal.m4
|
aclocal.m4
|
||||||
arcnet.h
|
arcnet.h
|
||||||
|
atmuni31.h
|
||||||
bpf/net/bpf.h
|
bpf/net/bpf.h
|
||||||
bpf/net/bpf_filter.c
|
bpf/net/bpf_filter.c
|
||||||
bpf_dump.c
|
bpf_dump.c
|
||||||
|
@ -63,3 +64,4 @@ ppp.h
|
||||||
savefile.c
|
savefile.c
|
||||||
scanner.l
|
scanner.l
|
||||||
sll.h
|
sll.h
|
||||||
|
sunatmpos.h
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1997 Yen Yen Lim and North Dakota State University
|
||||||
|
* 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 Yen Yen Lim and
|
||||||
|
North Dakota State University
|
||||||
|
* 4. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||||
|
*
|
||||||
|
* @(#) $Header: /tcpdump/master/libpcap/atmuni31.h,v 1.1 2002-07-11 09:06:32 guy Exp $ (LBL)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Based on UNI3.1 standard by ATM Forum */
|
||||||
|
|
||||||
|
/* ATM traffic types based on VPI=0 and (the following VCI */
|
||||||
|
#define PPC 0x05 /* Point-to-point signal msg */
|
||||||
|
#define BCC 0x02 /* Broadcast signal msg */
|
||||||
|
#define OAMF4SC 0x03 /* Segment OAM F4 flow cell */
|
||||||
|
#define OAMF4EC 0x04 /* End-to-end OAM F4 flow cell */
|
||||||
|
#define METAC 0x01 /* Meta signal msg */
|
||||||
|
#define ILMIC 0x10 /* ILMI msg */
|
||||||
|
|
||||||
|
/* Q.2931 signalling messages */
|
||||||
|
#define CALL_PROCEED 0x02 /* call proceeding */
|
||||||
|
#define CONNECT 0x07 /* connect */
|
||||||
|
#define CONNECT_ACK 0x0f /* connect_ack */
|
||||||
|
#define SETUP 0x05 /* setup */
|
||||||
|
#define RELEASE 0x4d /* release */
|
||||||
|
#define RELEASE_DONE 0x5a /* release_done */
|
||||||
|
#define RESTART 0x46 /* restart */
|
||||||
|
#define RESTART_ACK 0x4e /* restart ack */
|
||||||
|
#define STATUS 0x7d /* status */
|
||||||
|
#define STATUS_ENQ 0x75 /* status ack */
|
||||||
|
#define ADD_PARTY 0x80 /* add party */
|
||||||
|
#define ADD_PARTY_ACK 0x81 /* add party ack */
|
||||||
|
#define ADD_PARTY_REJ 0x82 /* add party rej */
|
||||||
|
#define DROP_PARTY 0x83 /* drop party */
|
||||||
|
#define DROP_PARTY_ACK 0x84 /* drop party ack */
|
||||||
|
|
||||||
|
/* Information Element Parameters in the signalling messages */
|
||||||
|
#define CAUSE 0x08 /* cause */
|
||||||
|
#define ENDPT_REF 0x54 /* endpoint reference */
|
||||||
|
#define AAL_PARA 0x58 /* ATM adaptation layer parameters */
|
||||||
|
#define TRAFF_DESCRIP 0x59 /* atm traffic descriptors */
|
||||||
|
#define CONNECT_ID 0x5a /* connection identifier */
|
||||||
|
#define QOS_PARA 0x5c /* quality of service parameters */
|
||||||
|
#define B_HIGHER 0x5d /* broadband higher layer information */
|
||||||
|
#define B_BEARER 0x5e /* broadband bearer capability */
|
||||||
|
#define B_LOWER 0x5f /* broadband lower information */
|
||||||
|
#define CALLING_PARTY 0x6c /* calling party number */
|
||||||
|
#define CALLED_PARTY 0x70 /* called party nmber */
|
||||||
|
|
||||||
|
#define Q2931 0x09
|
||||||
|
|
||||||
|
/* Q.2931 signalling general messages format */
|
||||||
|
#define PROTO_POS 0 /* offset of protocol discriminator */
|
||||||
|
#define CALL_REF_POS 2 /* offset of call reference value */
|
||||||
|
#define MSG_TYPE_POS 5 /* offset of message type */
|
||||||
|
#define MSG_LEN_POS 7 /* offset of mesage length */
|
||||||
|
#define IE_BEGIN_POS 9 /* offset of first information element */
|
||||||
|
|
||||||
|
/* format of signalling messages */
|
||||||
|
#define TYPE_POS 0
|
||||||
|
#define LEN_POS 2
|
||||||
|
#define FIELD_BEGIN_POS 4
|
|
@ -37,7 +37,7 @@
|
||||||
*
|
*
|
||||||
* @(#)bpf.h 7.1 (Berkeley) 5/7/91
|
* @(#)bpf.h 7.1 (Berkeley) 5/7/91
|
||||||
*
|
*
|
||||||
* @(#) $Header: /tcpdump/master/libpcap/bpf/net/Attic/bpf.h,v 1.60 2002-07-11 07:56:45 guy Exp $ (LBL)
|
* @(#) $Header: /tcpdump/master/libpcap/bpf/net/Attic/bpf.h,v 1.61 2002-07-11 09:06:47 guy Exp $ (LBL)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BPF_MAJOR_VERSION
|
#ifndef BPF_MAJOR_VERSION
|
||||||
|
@ -351,7 +351,18 @@ struct bpf_hdr {
|
||||||
#define DLT_IP_OVER_FC 122
|
#define DLT_IP_OVER_FC 122
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reserved for capturing on Solaris with SunATM.
|
* This is for Full Frontal ATM on Solaris with SunATM, with a
|
||||||
|
* pseudo-header followed by an AALn PDU.
|
||||||
|
*
|
||||||
|
* There may be other forms of Full Frontal ATM on other OSes,
|
||||||
|
* with different pseudo-headers.
|
||||||
|
*
|
||||||
|
* If ATM software returns a pseudo-header with VPI/VCI information
|
||||||
|
* (and, ideally, packet type information, e.g. signalling, ILMI,
|
||||||
|
* LANE, LLC-multiplexed traffic, etc.), it should not use
|
||||||
|
* DLT_ATM_RFC1483, but should get a new DLT_ value, so tcpdump
|
||||||
|
* and the like don't have to infer the presence or absence of a
|
||||||
|
* pseudo-header and the form of the pseudo-header.
|
||||||
*/
|
*/
|
||||||
#define DLT_SUNATM 123 /* Solaris+SunATM */
|
#define DLT_SUNATM 123 /* Solaris+SunATM */
|
||||||
|
|
||||||
|
|
482
gencode.c
482
gencode.c
|
@ -21,7 +21,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.168 2002-07-11 07:56:44 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.169 2002-07-11 09:06:32 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -53,6 +53,8 @@ struct rtentry; /* declarations in <net/if.h> */
|
||||||
#include "nlpid.h"
|
#include "nlpid.h"
|
||||||
#include "llc.h"
|
#include "llc.h"
|
||||||
#include "gencode.h"
|
#include "gencode.h"
|
||||||
|
#include "atmuni31.h"
|
||||||
|
#include "sunatmpos.h"
|
||||||
#include "ppp.h"
|
#include "ppp.h"
|
||||||
#include "sll.h"
|
#include "sll.h"
|
||||||
#include "arcnet.h"
|
#include "arcnet.h"
|
||||||
|
@ -139,11 +141,14 @@ static struct block *gen_cmp(u_int, u_int, bpf_int32);
|
||||||
static struct block *gen_cmp_gt(u_int, u_int, bpf_int32);
|
static struct block *gen_cmp_gt(u_int, u_int, bpf_int32);
|
||||||
static struct block *gen_mcmp(u_int, u_int, bpf_int32, bpf_u_int32);
|
static struct block *gen_mcmp(u_int, u_int, bpf_int32, bpf_u_int32);
|
||||||
static struct block *gen_bcmp(u_int, u_int, const u_char *);
|
static struct block *gen_bcmp(u_int, u_int, const u_char *);
|
||||||
|
static struct block *gen_ncmp(bpf_u_int32, bpf_u_int32, bpf_u_int32,
|
||||||
|
bpf_u_int32, bpf_u_int32, int);
|
||||||
static struct block *gen_uncond(int);
|
static struct block *gen_uncond(int);
|
||||||
static inline struct block *gen_true(void);
|
static inline struct block *gen_true(void);
|
||||||
static inline struct block *gen_false(void);
|
static inline struct block *gen_false(void);
|
||||||
static struct block *gen_linktype(int);
|
static struct block *gen_linktype(int);
|
||||||
static struct block *gen_snap(bpf_u_int32, bpf_u_int32, u_int);
|
static struct block *gen_snap(bpf_u_int32, bpf_u_int32, u_int);
|
||||||
|
static struct block *gen_llc(int);
|
||||||
static struct block *gen_hostop(bpf_u_int32, bpf_u_int32, int, int, u_int, u_int);
|
static struct block *gen_hostop(bpf_u_int32, bpf_u_int32, int, int, u_int, u_int);
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
static struct block *gen_hostop6(struct in6_addr *, struct in6_addr *, int, int, u_int, u_int);
|
static struct block *gen_hostop6(struct in6_addr *, struct in6_addr *, int, int, u_int, u_int);
|
||||||
|
@ -178,6 +183,8 @@ static struct slist *xfer_to_x(struct arth *);
|
||||||
static struct slist *xfer_to_a(struct arth *);
|
static struct slist *xfer_to_a(struct arth *);
|
||||||
static struct block *gen_len(int, int);
|
static struct block *gen_len(int, int);
|
||||||
|
|
||||||
|
static struct block *gen_msg_abbrev(int type);
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
newchunk(n)
|
newchunk(n)
|
||||||
u_int n;
|
u_int n;
|
||||||
|
@ -538,6 +545,30 @@ gen_bcmp(offset, size, v)
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct block *
|
||||||
|
gen_ncmp(datasize, offset, mask, jtype, jvalue, reverse)
|
||||||
|
bpf_u_int32 datasize, offset, mask, jtype, jvalue;
|
||||||
|
int reverse;
|
||||||
|
{
|
||||||
|
struct slist *s;
|
||||||
|
struct block *b;
|
||||||
|
|
||||||
|
s = new_stmt(BPF_LD|datasize|BPF_ABS);
|
||||||
|
s->s.k = offset;
|
||||||
|
|
||||||
|
if (mask != 0xffffffff) {
|
||||||
|
s->next = new_stmt(BPF_ALU|BPF_AND|BPF_K);
|
||||||
|
s->next->s.k = mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
b = new_block(JMP(jtype));
|
||||||
|
b->stmts = s;
|
||||||
|
b->s.k = jvalue;
|
||||||
|
if (reverse && (jtype == BPF_JGT || jtype == BPF_JGE))
|
||||||
|
gen_not(b);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Various code constructs need to know the layout of the data link
|
* Various code constructs need to know the layout of the data link
|
||||||
* layer. These variables give the necessary offsets.
|
* layer. These variables give the necessary offsets.
|
||||||
|
@ -564,6 +595,23 @@ gen_bcmp(offset, size, v)
|
||||||
*/
|
*/
|
||||||
static u_int off_linktype;
|
static u_int off_linktype;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TRUE if the link layer includes an ATM pseudo-header.
|
||||||
|
*/
|
||||||
|
static int is_atm = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These are offsets for the ATM pseudo-header.
|
||||||
|
*/
|
||||||
|
static u_int off_vpi;
|
||||||
|
static u_int off_vci;
|
||||||
|
static u_int off_proto;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the offset to the message type for Q.2931 messages.
|
||||||
|
*/
|
||||||
|
static u_int off_msg_type;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These are offsets to the beginning of the network-layer header.
|
* These are offsets to the beginning of the network-layer header.
|
||||||
*
|
*
|
||||||
|
@ -597,6 +645,15 @@ init_linktype(type)
|
||||||
{
|
{
|
||||||
linktype = type;
|
linktype = type;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Assume it's not raw ATM with a pseudo-header, for now.
|
||||||
|
*/
|
||||||
|
is_atm = 0;
|
||||||
|
off_vpi = -1;
|
||||||
|
off_vci = -1;
|
||||||
|
off_proto = -1;
|
||||||
|
off_msg_type = -1;
|
||||||
|
|
||||||
orig_linktype = -1;
|
orig_linktype = -1;
|
||||||
orig_nl = -1;
|
orig_nl = -1;
|
||||||
orig_nl_nosnap = -1;
|
orig_nl_nosnap = -1;
|
||||||
|
@ -759,6 +816,21 @@ init_linktype(type)
|
||||||
off_nl_nosnap = 3; /* 802.2 */
|
off_nl_nosnap = 3; /* 802.2 */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case DLT_SUNATM:
|
||||||
|
/*
|
||||||
|
* Full Frontal ATM; you get AALn PDUs with an ATM
|
||||||
|
* pseudo-header.
|
||||||
|
*/
|
||||||
|
is_atm = 1;
|
||||||
|
off_linktype = SUNATM_PKT_BEGIN_POS;
|
||||||
|
off_vpi = SUNATM_VPI_POS;
|
||||||
|
off_vci = SUNATM_VCI_POS;
|
||||||
|
off_proto = PROTO_POS;
|
||||||
|
off_msg_type = SUNATM_PKT_BEGIN_POS+MSG_TYPE_POS;
|
||||||
|
off_nl = SUNATM_PKT_BEGIN_POS+8; /* 802.2+SNAP */
|
||||||
|
off_nl_nosnap = SUNATM_PKT_BEGIN_POS+3; /* 802.2 */
|
||||||
|
return;
|
||||||
|
|
||||||
case DLT_RAW:
|
case DLT_RAW:
|
||||||
off_linktype = -1;
|
off_linktype = -1;
|
||||||
off_nl = 0;
|
off_nl = 0;
|
||||||
|
@ -1021,81 +1093,19 @@ gen_linktype(proto)
|
||||||
case DLT_IEEE802:
|
case DLT_IEEE802:
|
||||||
case DLT_ATM_RFC1483:
|
case DLT_ATM_RFC1483:
|
||||||
case DLT_ATM_CLIP:
|
case DLT_ATM_CLIP:
|
||||||
/*
|
return gen_llc(proto);
|
||||||
* 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;
|
break;
|
||||||
|
|
||||||
default:
|
case DLT_SUNATM:
|
||||||
/*
|
/*
|
||||||
* XXX - we don't have to check for IPX 802.3
|
* Check for LLC encapsulation and then check the protocol.
|
||||||
* here, but should we check for the IPX Ethertype?
|
* XXX - also check for LANE and then check for an Ethernet
|
||||||
|
* type?
|
||||||
*/
|
*/
|
||||||
if (proto <= ETHERMTU) {
|
b0 = gen_atmfield_code(A_PROTOTYPE, PT_LLC, BPF_JEQ, 0);
|
||||||
/*
|
b1 = gen_llc(proto);
|
||||||
* This is an LLC SAP value, so check
|
gen_and(b0, b1);
|
||||||
* the DSAP.
|
return b1;
|
||||||
*/
|
|
||||||
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:
|
case DLT_LINUX_SLL:
|
||||||
switch (proto) {
|
switch (proto) {
|
||||||
|
@ -1579,6 +1589,82 @@ gen_snap(orgcode, ptype, offset)
|
||||||
return gen_bcmp(offset, 8, snapblock);
|
return gen_bcmp(offset, 8, snapblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check for a given protocol value assuming an 802.2 LLC header.
|
||||||
|
*/
|
||||||
|
static struct block *
|
||||||
|
gen_llc(proto)
|
||||||
|
int proto;
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static struct block *
|
static struct block *
|
||||||
gen_hostop(addr, mask, dir, proto, src_off, dst_off)
|
gen_hostop(addr, mask, dir, proto, src_off, dst_off)
|
||||||
bpf_u_int32 addr;
|
bpf_u_int32 addr;
|
||||||
|
@ -4075,3 +4161,255 @@ gen_vlan(vlan_num)
|
||||||
|
|
||||||
return (b0);
|
return (b0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct block *
|
||||||
|
gen_atmfield_code(atmfield, jvalue, jtype, reverse)
|
||||||
|
int atmfield;
|
||||||
|
bpf_u_int32 jvalue;
|
||||||
|
bpf_u_int32 jtype;
|
||||||
|
int reverse;
|
||||||
|
{
|
||||||
|
struct block *b0;
|
||||||
|
|
||||||
|
switch (atmfield) {
|
||||||
|
|
||||||
|
case A_VPI:
|
||||||
|
if (!is_atm)
|
||||||
|
bpf_error("'vpi' supported only on raw ATM");
|
||||||
|
if (off_vpi == -1)
|
||||||
|
abort();
|
||||||
|
b0 = gen_ncmp(BPF_B, off_vpi, 0xffffffff, (u_int)jtype,
|
||||||
|
(u_int)jvalue, reverse);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_VCI:
|
||||||
|
if (!is_atm)
|
||||||
|
bpf_error("'vci' supported only on raw ATM");
|
||||||
|
if (off_vci == -1)
|
||||||
|
abort();
|
||||||
|
b0 = gen_ncmp(BPF_H, off_vci, 0xffffffff, (u_int)jtype,
|
||||||
|
(u_int)jvalue, reverse);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_PROTOTYPE:
|
||||||
|
if (off_proto == -1)
|
||||||
|
abort(); /* XXX - this isn't on FreeBSD */
|
||||||
|
b0 = gen_ncmp(BPF_B, off_proto, 0x0f, (u_int)jtype,
|
||||||
|
(u_int)jvalue, reverse);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_MSGTYPE:
|
||||||
|
if (off_msg_type == -1)
|
||||||
|
abort();
|
||||||
|
b0 = gen_ncmp(BPF_B, off_msg_type, 0xffffffff,
|
||||||
|
(u_int)jtype, (u_int)jvalue, reverse);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_CALLREFTYPE:
|
||||||
|
if (!is_atm)
|
||||||
|
bpf_error("'callref' supported only on raw ATM");
|
||||||
|
if (off_proto == -1)
|
||||||
|
abort();
|
||||||
|
b0 = gen_ncmp(BPF_B, off_proto, 0xffffffff, (u_int)jtype,
|
||||||
|
(u_int)jvalue, reverse);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return b0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct block *
|
||||||
|
gen_atmtype_abbrev(type)
|
||||||
|
int type;
|
||||||
|
{
|
||||||
|
struct block *b0, *b1;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
|
||||||
|
case A_METAC:
|
||||||
|
/* Get all packets in Meta signalling Circuit */
|
||||||
|
if (!is_atm)
|
||||||
|
bpf_error("'metac' supported only on raw ATM");
|
||||||
|
b0 = gen_atmfield_code(A_VPI, 0, BPF_JEQ, 0);
|
||||||
|
b1 = gen_atmfield_code(A_VCI, 1, BPF_JEQ, 0);
|
||||||
|
gen_and(b0, b1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_BCC:
|
||||||
|
/* Get all packets in Broadcast Circuit*/
|
||||||
|
if (!is_atm)
|
||||||
|
bpf_error("'bcc' supported only on raw ATM");
|
||||||
|
b0 = gen_atmfield_code(A_VPI, 0, BPF_JEQ, 0);
|
||||||
|
b1 = gen_atmfield_code(A_VCI, 2, BPF_JEQ, 0);
|
||||||
|
gen_and(b0, b1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_OAMF4SC:
|
||||||
|
/* Get all cells in Segment OAM F4 circuit*/
|
||||||
|
if (!is_atm)
|
||||||
|
bpf_error("'oam4sc' supported only on raw ATM");
|
||||||
|
b0 = gen_atmfield_code(A_VPI, 0, BPF_JEQ, 0);
|
||||||
|
b1 = gen_atmfield_code(A_VCI, 3, BPF_JEQ, 0);
|
||||||
|
gen_and(b0, b1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_OAMF4EC:
|
||||||
|
/* Get all cells in End-to-End OAM F4 Circuit*/
|
||||||
|
if (!is_atm)
|
||||||
|
bpf_error("'oam4ec' supported only on raw ATM");
|
||||||
|
b0 = gen_atmfield_code(A_VPI, 0, BPF_JEQ, 0);
|
||||||
|
b1 = gen_atmfield_code(A_VCI, 4, BPF_JEQ, 0);
|
||||||
|
gen_and(b0, b1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_SC:
|
||||||
|
/* Get all packets in connection Signalling Circuit */
|
||||||
|
if (!is_atm)
|
||||||
|
bpf_error("'sc' supported only on raw ATM");
|
||||||
|
b0 = gen_atmfield_code(A_VPI, 0, BPF_JEQ, 0);
|
||||||
|
b1 = gen_atmfield_code(A_VCI, 5, BPF_JEQ, 0);
|
||||||
|
gen_and(b0, b1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_ILMIC:
|
||||||
|
/* Get all packets in ILMI Circuit */
|
||||||
|
if (!is_atm)
|
||||||
|
bpf_error("'ilmic' supported only on raw ATM");
|
||||||
|
b0 = gen_atmfield_code(A_VPI, 0, BPF_JEQ, 0);
|
||||||
|
b1 = gen_atmfield_code(A_VCI, 16, BPF_JEQ, 0);
|
||||||
|
gen_and(b0, b1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_LANE:
|
||||||
|
/* Get all LANE packets */
|
||||||
|
if (!is_atm)
|
||||||
|
bpf_error("'lane' supported only on raw ATM");
|
||||||
|
b1 = gen_atmfield_code(A_PROTOTYPE, PT_LANE, BPF_JEQ, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_LLC:
|
||||||
|
/* Get all LLC-encapsulated packets */
|
||||||
|
if (!is_atm)
|
||||||
|
bpf_error("'llc' supported only on raw ATM");
|
||||||
|
b1 = gen_atmfield_code(A_PROTOTYPE, PT_LLC, BPF_JEQ, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return b1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static struct block *
|
||||||
|
gen_msg_abbrev(type)
|
||||||
|
int type;
|
||||||
|
{
|
||||||
|
struct block *b1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Q.2931 signalling protocol messages for handling virtual circuits
|
||||||
|
* establishment and teardown
|
||||||
|
*/
|
||||||
|
switch (type) {
|
||||||
|
|
||||||
|
case A_SETUP:
|
||||||
|
b1 = gen_atmfield_code(A_MSGTYPE, SETUP, BPF_JEQ, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_CALLPROCEED:
|
||||||
|
b1 = gen_atmfield_code(A_MSGTYPE, CALL_PROCEED, BPF_JEQ, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_CONNECT:
|
||||||
|
b1 = gen_atmfield_code(A_MSGTYPE, CONNECT, BPF_JEQ, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_CONNECTACK:
|
||||||
|
b1 = gen_atmfield_code(A_MSGTYPE, CONNECT_ACK, BPF_JEQ, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_RELEASE:
|
||||||
|
b1 = gen_atmfield_code(A_MSGTYPE, RELEASE, BPF_JEQ, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_RELEASE_DONE:
|
||||||
|
b1 = gen_atmfield_code(A_MSGTYPE, RELEASE_DONE, BPF_JEQ, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return b1;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct block *
|
||||||
|
gen_atmmulti_abbrev(type)
|
||||||
|
int type;
|
||||||
|
{
|
||||||
|
struct block *b0, *b1;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
|
||||||
|
case A_OAM:
|
||||||
|
if (!is_atm)
|
||||||
|
bpf_error("'oam' supported only on raw ATM");
|
||||||
|
b1 = gen_atmmulti_abbrev(A_OAMF4);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_OAMF4:
|
||||||
|
if (!is_atm)
|
||||||
|
bpf_error("'oamf4' supported only on raw ATM");
|
||||||
|
/* OAM F4 type */
|
||||||
|
b0 = gen_atmfield_code(A_VCI, 3, BPF_JEQ, 0);
|
||||||
|
b1 = gen_atmfield_code(A_VCI, 4, BPF_JEQ, 0);
|
||||||
|
gen_or(b0, b1);
|
||||||
|
b0 = gen_atmfield_code(A_VPI, 0, BPF_JEQ, 0);
|
||||||
|
gen_and(b0, b1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_CONNECTMSG:
|
||||||
|
/*
|
||||||
|
* Get Q.2931 signalling messages for switched
|
||||||
|
* virtual connection
|
||||||
|
*/
|
||||||
|
if (!is_atm)
|
||||||
|
bpf_error("'connectmsg' supported only on raw ATM");
|
||||||
|
b0 = gen_msg_abbrev(A_SETUP);
|
||||||
|
b1 = gen_msg_abbrev(A_CALLPROCEED);
|
||||||
|
gen_or(b0, b1);
|
||||||
|
b0 = gen_msg_abbrev(A_CONNECT);
|
||||||
|
gen_or(b0, b1);
|
||||||
|
b0 = gen_msg_abbrev(A_CONNECTACK);
|
||||||
|
gen_or(b0, b1);
|
||||||
|
b0 = gen_msg_abbrev(A_RELEASE);
|
||||||
|
gen_or(b0, b1);
|
||||||
|
b0 = gen_msg_abbrev(A_RELEASE_DONE);
|
||||||
|
gen_or(b0, b1);
|
||||||
|
b0 = gen_atmtype_abbrev(A_SC);
|
||||||
|
gen_and(b0, b1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case A_METACONNECT:
|
||||||
|
if (!is_atm)
|
||||||
|
bpf_error("'metaconnect' supported only on raw ATM");
|
||||||
|
b0 = gen_msg_abbrev(A_SETUP);
|
||||||
|
b1 = gen_msg_abbrev(A_CALLPROCEED);
|
||||||
|
gen_or(b0, b1);
|
||||||
|
b0 = gen_msg_abbrev(A_CONNECT);
|
||||||
|
gen_or(b0, b1);
|
||||||
|
b0 = gen_msg_abbrev(A_RELEASE);
|
||||||
|
gen_or(b0, b1);
|
||||||
|
b0 = gen_msg_abbrev(A_RELEASE_DONE);
|
||||||
|
gen_or(b0, b1);
|
||||||
|
b0 = gen_atmtype_abbrev(A_METAC);
|
||||||
|
gen_and(b0, b1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return b1;
|
||||||
|
}
|
||||||
|
|
77
gencode.h
77
gencode.h
|
@ -18,7 +18,41 @@
|
||||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
* @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.54 2002-06-11 17:04:45 itojun Exp $ (LBL)
|
* @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.55 2002-07-11 09:06:34 guy Exp $ (LBL)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ATM support:
|
||||||
|
*
|
||||||
|
* Copyright (c) 1997 Yen Yen Lim and North Dakota State University
|
||||||
|
* 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 Yen Yen Lim and
|
||||||
|
* North Dakota State University
|
||||||
|
* 4. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Address qualifiers. */
|
/* Address qualifiers. */
|
||||||
|
@ -83,6 +117,43 @@
|
||||||
#define Q_DEFAULT 0
|
#define Q_DEFAULT 0
|
||||||
#define Q_UNDEF 255
|
#define Q_UNDEF 255
|
||||||
|
|
||||||
|
/* ATM types */
|
||||||
|
#define A_METAC 22 /* Meta signalling Circuit */
|
||||||
|
#define A_BCC 23 /* Broadcast Circuit */
|
||||||
|
#define A_OAMF4SC 24 /* Segment OAM F4 Circuit */
|
||||||
|
#define A_OAMF4EC 25 /* End-to-End OAM F4 Circuit */
|
||||||
|
#define A_SC 26 /* Signalling Circuit*/
|
||||||
|
#define A_ILMIC 27 /* ILMI Circuit */
|
||||||
|
#define A_OAM 28 /* OAM cells : F4 only */
|
||||||
|
#define A_OAMF4 29 /* OAM F4 cells: Segment + End-to-end */
|
||||||
|
#define A_LANE 30 /* LANE traffic */
|
||||||
|
#define A_LLC 31 /* LLC-encapsulated traffic */
|
||||||
|
|
||||||
|
/* Based on Q.2931 signalling protocol */
|
||||||
|
#define A_SETUP 41 /* Setup message */
|
||||||
|
#define A_CALLPROCEED 42 /* Call proceeding message */
|
||||||
|
#define A_CONNECT 43 /* Connect message */
|
||||||
|
#define A_CONNECTACK 44 /* Connect Ack message */
|
||||||
|
#define A_RELEASE 45 /* Release message */
|
||||||
|
#define A_RELEASE_DONE 46 /* Release message */
|
||||||
|
|
||||||
|
/* ATM field types */
|
||||||
|
#define A_VPI 51
|
||||||
|
#define A_VCI 52
|
||||||
|
#define A_PROTOTYPE 53
|
||||||
|
#define A_MSGTYPE 54
|
||||||
|
#define A_CALLREFTYPE 55
|
||||||
|
|
||||||
|
#define A_CONNECTMSG 70 /* returns Q.2931 signalling messages for
|
||||||
|
establishing and destroying switched
|
||||||
|
virtual connection */
|
||||||
|
#define A_METACONNECT 71 /* returns Q.2931 signalling messages for
|
||||||
|
establishing and destroying predefined
|
||||||
|
virtual circuits, such as broadcast
|
||||||
|
circuit, oamf4 segment circuit, oamf4
|
||||||
|
end-to-end circuits, ILMI circuits or
|
||||||
|
connection signalling circuit. */
|
||||||
|
|
||||||
struct slist;
|
struct slist;
|
||||||
|
|
||||||
struct stmt {
|
struct stmt {
|
||||||
|
@ -191,6 +262,10 @@ struct block *gen_inbound(int);
|
||||||
|
|
||||||
struct block *gen_vlan(int);
|
struct block *gen_vlan(int);
|
||||||
|
|
||||||
|
struct block *gen_atmfield_code(int atmfield, bpf_u_int32 jvalue, bpf_u_int32 jtype, int reverse);
|
||||||
|
struct block *gen_atmtype_abbrev(int type);
|
||||||
|
struct block *gen_atmmulti_abbrev(int type);
|
||||||
|
|
||||||
void bpf_optimize(struct block **);
|
void bpf_optimize(struct block **);
|
||||||
void bpf_error(const char *, ...)
|
void bpf_error(const char *, ...)
|
||||||
#if HAVE___ATTRIBUTE__
|
#if HAVE___ATTRIBUTE__
|
||||||
|
|
60
grammar.y
60
grammar.y
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.71 2001-07-03 19:15:48 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.72 2002-07-11 09:06:35 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -91,6 +91,7 @@ pcap_parse()
|
||||||
struct arth *a;
|
struct arth *a;
|
||||||
struct {
|
struct {
|
||||||
struct qual q;
|
struct qual q;
|
||||||
|
int atmfieldtype;
|
||||||
struct block *b;
|
struct block *b;
|
||||||
} blk;
|
} blk;
|
||||||
struct block *rblk;
|
struct block *rblk;
|
||||||
|
@ -103,6 +104,10 @@ pcap_parse()
|
||||||
%type <i> byteop pname pnum relop irelop
|
%type <i> byteop pname pnum relop irelop
|
||||||
%type <blk> and or paren not null prog
|
%type <blk> and or paren not null prog
|
||||||
%type <rblk> other
|
%type <rblk> other
|
||||||
|
%type <blk> gexpr
|
||||||
|
%type <i> atmtype atmmultitype
|
||||||
|
%type <blk> atmexpr atmfield atmhead ratmhead
|
||||||
|
%type <blk> atmfieldvalue atmvalue atmlistvalue
|
||||||
|
|
||||||
%token DST SRC HOST GATEWAY
|
%token DST SRC HOST GATEWAY
|
||||||
%token NET MASK PORT LESS GREATER PROTO PROTOCHAIN BYTE
|
%token NET MASK PORT LESS GREATER PROTO PROTOCHAIN BYTE
|
||||||
|
@ -121,6 +126,9 @@ pcap_parse()
|
||||||
%token STP
|
%token STP
|
||||||
%token IPX
|
%token IPX
|
||||||
%token NETBEUI
|
%token NETBEUI
|
||||||
|
%token LANE LLC METAC BCC SC ILMIC OAMF4EC OAMF4SC
|
||||||
|
%token OAM OAMF4 CONNECTMSG METACONNECT
|
||||||
|
%token VPI VCI
|
||||||
|
|
||||||
%type <s> ID
|
%type <s> ID
|
||||||
%type <e> EID
|
%type <e> EID
|
||||||
|
@ -137,7 +145,7 @@ pcap_parse()
|
||||||
%left '*' '/'
|
%left '*' '/'
|
||||||
%nonassoc UMINUS
|
%nonassoc UMINUS
|
||||||
%%
|
%%
|
||||||
prog: null expr
|
prog: null gexpr
|
||||||
{
|
{
|
||||||
finish_parse($2.b);
|
finish_parse($2.b);
|
||||||
}
|
}
|
||||||
|
@ -145,6 +153,9 @@ prog: null expr
|
||||||
;
|
;
|
||||||
null: /* null */ { $$.q = qerr; }
|
null: /* null */ { $$.q = qerr; }
|
||||||
;
|
;
|
||||||
|
gexpr: expr
|
||||||
|
| atmexpr
|
||||||
|
;
|
||||||
expr: term
|
expr: term
|
||||||
| expr and term { gen_and($1.b, $3.b); $$ = $3; }
|
| expr and term { gen_and($1.b, $3.b); $$ = $3; }
|
||||||
| expr and id { gen_and($1.b, $3.b); $$ = $3; }
|
| expr and id { gen_and($1.b, $3.b); $$ = $3; }
|
||||||
|
@ -334,4 +345,49 @@ byteop: '&' { $$ = '&'; }
|
||||||
pnum: NUM
|
pnum: NUM
|
||||||
| paren pnum ')' { $$ = $2; }
|
| paren pnum ')' { $$ = $2; }
|
||||||
;
|
;
|
||||||
|
atmexpr: atmhead
|
||||||
|
| atmexpr and atmhead { gen_and($1.b, $3.b); $$ = $3; }
|
||||||
|
| atmexpr or atmhead { gen_or($1.b, $3.b); $$ = $3; }
|
||||||
|
;
|
||||||
|
atmhead: ratmhead
|
||||||
|
| not atmhead { gen_not($2.b); $$ = $2; }
|
||||||
|
;
|
||||||
|
ratmhead: atmtype { $$.b = gen_atmtype_abbrev($1); $$.q = qerr; }
|
||||||
|
| atmmultitype { $$.b = gen_atmmulti_abbrev($1); $$.q = qerr; }
|
||||||
|
| atmfield atmvalue { $$.b = $2.b; }
|
||||||
|
| paren atmexpr ')' { $$.b = $2.b; $$.q = qerr; }
|
||||||
|
;
|
||||||
|
atmtype: LANE { $$ = A_LANE; }
|
||||||
|
| LLC { $$ = A_LLC; }
|
||||||
|
| METAC { $$ = A_METAC; }
|
||||||
|
| BCC { $$ = A_BCC; }
|
||||||
|
| OAMF4EC { $$ = A_OAMF4EC; }
|
||||||
|
| OAMF4SC { $$ = A_OAMF4SC; }
|
||||||
|
| SC { $$ = A_SC; }
|
||||||
|
| ILMIC { $$ = A_ILMIC; }
|
||||||
|
;
|
||||||
|
atmmultitype: OAM { $$ = A_OAM; }
|
||||||
|
| OAMF4 { $$ = A_OAMF4; }
|
||||||
|
| CONNECTMSG { $$ = A_CONNECTMSG; }
|
||||||
|
| METACONNECT { $$ = A_METACONNECT; }
|
||||||
|
;
|
||||||
|
/* ATM field types quantifier */
|
||||||
|
atmfield: VPI { $$.atmfieldtype = A_VPI; }
|
||||||
|
| VCI { $$.atmfieldtype = A_VCI; }
|
||||||
|
;
|
||||||
|
atmvalue: atmfieldvalue
|
||||||
|
| relop NUM { $$.b = gen_atmfield_code($<blk>0.atmfieldtype, (u_int)$2, (u_int)$1, 0); }
|
||||||
|
| irelop NUM { $$.b = gen_atmfield_code($<blk>0.atmfieldtype, (u_int)$2, (u_int)$1, 1); }
|
||||||
|
| paren atmlistvalue ')' { $$.b = $2.b; $$.q = qerr; }
|
||||||
|
;
|
||||||
|
atmfieldvalue: NUM {
|
||||||
|
$$.atmfieldtype = $<blk>0.atmfieldtype;
|
||||||
|
if ($$.atmfieldtype == A_VPI ||
|
||||||
|
$$.atmfieldtype == A_VCI)
|
||||||
|
$$.b = gen_atmfield_code($$.atmfieldtype, (u_int) $1, BPF_JEQ, 0);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
atmlistvalue: atmfieldvalue
|
||||||
|
| atmlistvalue or atmfieldvalue { gen_or($1.b, $3.b); $$ = $3; }
|
||||||
|
;
|
||||||
%%
|
%%
|
||||||
|
|
25
inet.c
25
inet.c
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.47 2002-06-11 17:04:45 itojun Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.48 2002-07-11 09:06:35 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -111,11 +111,6 @@ struct rtentry; /* declarations in <net/if.h> */
|
||||||
#endif /* HAVE_SOCKADDR_SA_LEN */
|
#endif /* HAVE_SOCKADDR_SA_LEN */
|
||||||
#endif /* SA_LEN */
|
#endif /* SA_LEN */
|
||||||
|
|
||||||
/*
|
|
||||||
* Description string for the "any" device.
|
|
||||||
*/
|
|
||||||
static const char any_descr[] = "Pseudo-device that captures on all interfaces";
|
|
||||||
|
|
||||||
static struct sockaddr *
|
static struct sockaddr *
|
||||||
dup_sockaddr(struct sockaddr *sa)
|
dup_sockaddr(struct sockaddr *sa)
|
||||||
{
|
{
|
||||||
|
@ -431,7 +426,7 @@ add_addr_to_iflist(pcap_if_t **alldevs, char *name, u_int flags,
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int
|
||||||
pcap_add_if(pcap_if_t **devlist, char *name, u_int flags,
|
pcap_add_if(pcap_if_t **devlist, char *name, u_int flags,
|
||||||
const char *description, char *errbuf)
|
const char *description, char *errbuf)
|
||||||
{
|
{
|
||||||
|
@ -517,10 +512,10 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
|
||||||
|
|
||||||
if (ret != -1) {
|
if (ret != -1) {
|
||||||
/*
|
/*
|
||||||
* We haven't had any errors yet; add the "any" device,
|
* We haven't had any errors yet; do any platform-specific
|
||||||
* if we can open it.
|
* operations to add devices.
|
||||||
*/
|
*/
|
||||||
if (pcap_add_if(&devlist, "any", 0, any_descr, errbuf) < 0)
|
if (pcap_platform_finddevs(&devlist, errbuf) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -874,16 +869,12 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
|
||||||
|
|
||||||
if (ret != -1) {
|
if (ret != -1) {
|
||||||
/*
|
/*
|
||||||
* We haven't had any errors yet; add the "any" device,
|
* We haven't had any errors yet; do any platform-specific
|
||||||
* if we can open it.
|
* operations to add devices.
|
||||||
*/
|
|
||||||
if (pcap_add_if(&devlist, "any", 0, any_descr, errbuf) < 0) {
|
|
||||||
/*
|
|
||||||
* Oops, we had a fatal error.
|
|
||||||
*/
|
*/
|
||||||
|
if (pcap_platform_finddevs(&devlist, errbuf) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.50 2002-06-07 04:17:15 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.51 2002-07-11 09:06:36 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -420,6 +420,12 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pcap_setfilter(pcap_t *p, struct bpf_program *fp)
|
pcap_setfilter(pcap_t *p, struct bpf_program *fp)
|
||||||
{
|
{
|
||||||
|
|
103
pcap-dlpi.c
103
pcap-dlpi.c
|
@ -23,7 +23,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Packet capture routine for dlpi under SunOS 5
|
* Packet capture routine for DLPI under SunOS 5, HP-UX 9/10/11, and AIX.
|
||||||
*
|
*
|
||||||
* Notes:
|
* Notes:
|
||||||
*
|
*
|
||||||
|
@ -33,12 +33,12 @@
|
||||||
* length results in data being left of the front of the packet.
|
* length results in data being left of the front of the packet.
|
||||||
*
|
*
|
||||||
* - It might be desirable to use pfmod(7) to filter packets in the
|
* - It might be desirable to use pfmod(7) to filter packets in the
|
||||||
* kernel.
|
* kernel when possible.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-dlpi.c,v 1.78 2002-06-11 17:04:46 itojun Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-dlpi.c,v 1.79 2002-07-11 09:06:37 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -247,12 +247,31 @@ pcap_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||||
return (n);
|
return (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DL_IPATM
|
||||||
|
#define DL_IPATM 0x12 /* ATM Classical IP interface */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SOLARIS
|
||||||
|
/*
|
||||||
|
* For SunATM.
|
||||||
|
*/
|
||||||
|
#ifndef A_GET_UNITS
|
||||||
|
#define A_GET_UNITS (('A'<<8)|118)
|
||||||
|
#endif /* A_GET_UNITS */
|
||||||
|
#ifndef A_PROMISCON_REQ
|
||||||
|
#define A_PROMISCON_REQ (('A'<<8)|121)
|
||||||
|
#endif /* A_PROMISCON_REQ */
|
||||||
|
#endif /* HAVE_SOLARIS */
|
||||||
|
|
||||||
pcap_t *
|
pcap_t *
|
||||||
pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
{
|
{
|
||||||
register char *cp;
|
register char *cp;
|
||||||
register pcap_t *p;
|
register pcap_t *p;
|
||||||
int ppa;
|
int ppa;
|
||||||
|
#ifdef HAVE_SOLARIS
|
||||||
|
int isatm = 0;
|
||||||
|
#endif
|
||||||
register dl_info_ack_t *infop;
|
register dl_info_ack_t *infop;
|
||||||
#ifdef HAVE_SYS_BUFMOD_H
|
#ifdef HAVE_SYS_BUFMOD_H
|
||||||
bpf_u_int32 ss, flag;
|
bpf_u_int32 ss, flag;
|
||||||
|
@ -376,6 +395,10 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
dlinfoack(p->fd, (char *)buf, ebuf) < 0)
|
dlinfoack(p->fd, (char *)buf, ebuf) < 0)
|
||||||
goto bad;
|
goto bad;
|
||||||
infop = &((union DL_primitives *)buf)->info_ack;
|
infop = &((union DL_primitives *)buf)->info_ack;
|
||||||
|
#ifdef HAVE_SOLARIS
|
||||||
|
if (infop->dl_mac_type == DL_IPATM)
|
||||||
|
isatm = 1;
|
||||||
|
#endif
|
||||||
if (infop->dl_provider_style == DL_STYLE2 &&
|
if (infop->dl_provider_style == DL_STYLE2 &&
|
||||||
(dlattachreq(p->fd, ppa, ebuf) < 0 ||
|
(dlattachreq(p->fd, ppa, ebuf) < 0 ||
|
||||||
dlokack(p->fd, "attach", (char *)buf, ebuf) < 0))
|
dlokack(p->fd, "attach", (char *)buf, ebuf) < 0))
|
||||||
|
@ -411,6 +434,21 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
goto bad;
|
goto bad;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SOLARIS
|
||||||
|
if (isatm) {
|
||||||
|
/*
|
||||||
|
** Have to turn on some special ATM promiscuous mode
|
||||||
|
** for SunATM.
|
||||||
|
** Do *NOT* turn regular promiscuous mode on; it doesn't
|
||||||
|
** help, and may break things.
|
||||||
|
*/
|
||||||
|
if (strioctl(p->fd, A_PROMISCON_REQ, 0, NULL) < 0) {
|
||||||
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "A_PROMISCON_REQ: %s",
|
||||||
|
pcap_strerror(errno));
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
if (promisc) {
|
if (promisc) {
|
||||||
/*
|
/*
|
||||||
** Enable promiscuous
|
** Enable promiscuous
|
||||||
|
@ -433,12 +471,16 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
** Try to enable sap (when not in promiscuous mode when using
|
** Try to enable sap (when not in promiscuous mode when using
|
||||||
** using HP-UX and never under SINIX)
|
** using HP-UX, when not doing SunATM on Solaris, and never
|
||||||
|
** under SINIX)
|
||||||
*/
|
*/
|
||||||
#ifndef sinix
|
#ifndef sinix
|
||||||
if (
|
if (
|
||||||
#ifdef __hpux
|
#ifdef __hpux
|
||||||
!promisc &&
|
!promisc &&
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SOLARIS
|
||||||
|
!isatm &&
|
||||||
#endif
|
#endif
|
||||||
(dlpromisconreq(p->fd, DL_PROMISC_SAP, ebuf) < 0 ||
|
(dlpromisconreq(p->fd, DL_PROMISC_SAP, ebuf) < 0 ||
|
||||||
dlokack(p->fd, "promisc_sap", (char *)buf, ebuf) < 0)) {
|
dlokack(p->fd, "promisc_sap", (char *)buf, ebuf) < 0)) {
|
||||||
|
@ -487,6 +529,13 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
p->offset = 2;
|
p->offset = 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef HAVE_SOLARIS
|
||||||
|
case DL_IPATM:
|
||||||
|
p->linktype = DLT_SUNATM;
|
||||||
|
p->offset = 0; /* works for LANE and LLC encapsulation */
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "unknown mac type %lu",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "unknown mac type %lu",
|
||||||
(unsigned long)infop->dl_mac_type);
|
(unsigned long)infop->dl_mac_type);
|
||||||
|
@ -495,7 +544,8 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
|
|
||||||
#ifdef DLIOCRAW
|
#ifdef DLIOCRAW
|
||||||
/*
|
/*
|
||||||
** This is a non standard SunOS hack to get the ethernet header.
|
** This is a non standard SunOS hack to get the full raw link-layer
|
||||||
|
** header.
|
||||||
*/
|
*/
|
||||||
if (strioctl(p->fd, DLIOCRAW, 0, NULL) < 0) {
|
if (strioctl(p->fd, DLIOCRAW, 0, NULL) < 0) {
|
||||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "DLIOCRAW: %s",
|
snprintf(ebuf, PCAP_ERRBUF_SIZE, "DLIOCRAW: %s",
|
||||||
|
@ -630,6 +680,49 @@ split_dname(char *device, int *unitp, char *ebuf)
|
||||||
return (cp);
|
return (cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_SOLARIS
|
||||||
|
int fd;
|
||||||
|
union {
|
||||||
|
u_int nunits;
|
||||||
|
char pad[516]; /* XXX - must be at least 513; is 516
|
||||||
|
in "atmgetunits" */
|
||||||
|
} buf;
|
||||||
|
char baname[2+1+1];
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We may have to do special magic to get ATM devices.
|
||||||
|
*/
|
||||||
|
if ((fd = open("/dev/ba", O_RDWR)) < 0) {
|
||||||
|
/*
|
||||||
|
* We couldn't open the "ba" device.
|
||||||
|
* For now, just give up; perhaps we should
|
||||||
|
* return an error if the problem is neither
|
||||||
|
* a "that device doesn't exist" error (ENOENT,
|
||||||
|
* ENXIO, etc.) or a "you're not allowed to do
|
||||||
|
* that" error (EPERM, EACCES).
|
||||||
|
*/
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strioctl(fd, A_GET_UNITS, sizeof(buf), (char *)&buf) < 0) {
|
||||||
|
snprintf(errbuf, PCAP_ERRBUF_SIZE, "A_GET_UNITS: %s",
|
||||||
|
pcap_strerror(errno));
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
for (i = 0; i < buf.nunits; i++) {
|
||||||
|
snprintf(baname, sizeof baname, "ba%u", i);
|
||||||
|
if (pcap_add_if(alldevsp, baname, 0, NULL, errbuf) < 0)
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pcap_setfilter(pcap_t *p, struct bpf_program *fp)
|
pcap_setfilter(pcap_t *p, struct bpf_program *fp)
|
||||||
{
|
{
|
||||||
|
|
15
pcap-int.h
15
pcap-int.h
|
@ -30,7 +30,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.34 2002-06-11 17:04:46 itojun Exp $ (LBL)
|
* @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.35 2002-07-11 09:06:38 guy Exp $ (LBL)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef pcap_int_h
|
#ifndef pcap_int_h
|
||||||
|
@ -193,6 +193,19 @@ int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *);
|
||||||
strlen((y)))
|
strlen((y)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Internal interfaces for "pcap_findalldevs()".
|
||||||
|
*
|
||||||
|
* "pcap_platform_finddevs()" is a platform-dependent routine to
|
||||||
|
* add devices not found by the "standard" mechanisms (SIOCGIFCONF,
|
||||||
|
* "getifaddrs()", etc..
|
||||||
|
*
|
||||||
|
* "pcap_add_if()" adds an interface to the list of interfaces.
|
||||||
|
*/
|
||||||
|
int pcap_platform_finddevs(pcap_if_t **, char *);
|
||||||
|
int pcap_add_if(pcap_if_t **, char *, u_int, const char *, char *);
|
||||||
|
|
||||||
|
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
void pcap_close_linux(pcap_t *);
|
void pcap_close_linux(pcap_t *);
|
||||||
#endif
|
#endif
|
||||||
|
|
16
pcap-linux.c
16
pcap-linux.c
|
@ -26,7 +26,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.82 2002-07-06 21:22:35 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.83 2002-07-11 09:06:38 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -736,6 +736,20 @@ pcap_stats(pcap_t *handle, struct pcap_stat *stats)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Description string for the "any" device.
|
||||||
|
*/
|
||||||
|
static const char any_descr[] = "Pseudo-device that captures on all interfaces";
|
||||||
|
|
||||||
|
int
|
||||||
|
pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
||||||
|
{
|
||||||
|
if (pcap_add_if(&devlist, "any", 0, any_descr, errbuf) < 0)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attach the given BPF code to the packet capture device.
|
* Attach the given BPF code to the packet capture device.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.41 2001-12-10 07:14:18 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.42 2002-07-11 09:06:39 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -257,6 +257,12 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pcap_setfilter(pcap_t *p, struct bpf_program *fp)
|
pcap_setfilter(pcap_t *p, struct bpf_program *fp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-null.c,v 1.13 2000-10-28 00:01:29 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-null.c,v 1.14 2002-07-11 09:06:41 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -60,6 +60,12 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pcap_setfilter(pcap_t *p, struct bpf_program *fp)
|
pcap_setfilter(pcap_t *p, struct bpf_program *fp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.66 2002-06-11 17:04:47 itojun Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.67 2002-07-11 09:06:42 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -392,6 +392,12 @@ your system may not be properly configured; see \"man packetfilter(4)\"\n",
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pcap_setfilter(pcap_t *p, struct bpf_program *fp)
|
pcap_setfilter(pcap_t *p, struct bpf_program *fp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.56 2001-12-10 07:14:20 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.57 2002-07-11 09:06:43 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -315,6 +315,12 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pcap_setfilter(pcap_t *p, struct bpf_program *fp)
|
pcap_setfilter(pcap_t *p, struct bpf_program *fp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.35 2002-03-08 11:10:40 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.36 2002-07-11 09:06:43 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -291,6 +291,12 @@ pcap_open_live(char *device, int snaplen, int promisc, int to_ms, char *ebuf)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
||||||
|
{
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pcap_setfilter(pcap_t *p, struct bpf_program *fp)
|
pcap_setfilter(pcap_t *p, struct bpf_program *fp)
|
||||||
{
|
{
|
||||||
|
|
38
pcap.3
38
pcap.3
|
@ -1,4 +1,4 @@
|
||||||
.\" @(#) $Header: /tcpdump/master/libpcap/Attic/pcap.3,v 1.33 2002-07-11 08:12:34 guy Exp $
|
.\" @(#) $Header: /tcpdump/master/libpcap/Attic/pcap.3,v 1.34 2002-07-11 09:06:44 guy Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 1994, 1996, 1997
|
.\" Copyright (c) 1994, 1996, 1997
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
.\" The Regents of the University of California. All rights reserved.
|
||||||
|
@ -688,6 +688,42 @@ header or 4 for frames beginning with an 802.2 LLC header.
|
||||||
.TP 5
|
.TP 5
|
||||||
.B DLT_LTALK
|
.B DLT_LTALK
|
||||||
Apple LocalTalk; the packet begins with an AppleTalk LLAP header
|
Apple LocalTalk; the packet begins with an AppleTalk LLAP header
|
||||||
|
.TP 5
|
||||||
|
.B DLT_SUNATM
|
||||||
|
SunATM devices; the link layer header contains, in order:
|
||||||
|
.RS 10
|
||||||
|
.LP
|
||||||
|
a 1-byte flag field, containing a direction flag in the uppermost bit,
|
||||||
|
which is set for packets transmitted by the machine and clear for
|
||||||
|
packets received by the machine, and a 4-byte traffic type in the
|
||||||
|
low-order 4 bits, which is one of:
|
||||||
|
.RS 5
|
||||||
|
.TP 5
|
||||||
|
0
|
||||||
|
raw traffic
|
||||||
|
.TP 5
|
||||||
|
1
|
||||||
|
LANE traffic
|
||||||
|
.TP 5
|
||||||
|
2
|
||||||
|
LLC-encapsulated traffic
|
||||||
|
.TP 5
|
||||||
|
3
|
||||||
|
MARS traffic
|
||||||
|
.TP 5
|
||||||
|
4
|
||||||
|
IFMP traffic
|
||||||
|
.TP 5
|
||||||
|
5
|
||||||
|
ILMI traffic
|
||||||
|
.TP 5
|
||||||
|
6
|
||||||
|
Q.2931 traffic
|
||||||
|
.RE
|
||||||
|
.LP
|
||||||
|
a 1-byte VPI value;
|
||||||
|
.LP
|
||||||
|
a 2-byte VCI field, in network byte order.
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
.B pcap_snapshot()
|
.B pcap_snapshot()
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.63 2002-06-07 04:31:12 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.64 2002-07-11 09:06:46 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -163,6 +163,7 @@ static const char rcsid[] =
|
||||||
#define LINKTYPE_CISCO_IOS 118 /* For Cisco-internal use */
|
#define LINKTYPE_CISCO_IOS 118 /* For Cisco-internal use */
|
||||||
#define LINKTYPE_PRISM_HEADER 119 /* 802.11+Prism II monitor mode */
|
#define LINKTYPE_PRISM_HEADER 119 /* 802.11+Prism II monitor mode */
|
||||||
#define LINKTYPE_AIRONET_HEADER 120 /* FreeBSD Aironet driver stuff */
|
#define LINKTYPE_AIRONET_HEADER 120 /* FreeBSD Aironet driver stuff */
|
||||||
|
#define LINKTYPE_SUNATM 123 /* Solaris+SunATM */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These types are reserved for future use.
|
* These types are reserved for future use.
|
||||||
|
|
17
scanner.l
17
scanner.l
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] =
|
static const char rcsid[] =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.85 2002-06-29 07:44:38 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.86 2002-07-11 09:06:46 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -244,6 +244,21 @@ outbound return OUTBOUND;
|
||||||
|
|
||||||
vlan return VLAN;
|
vlan return VLAN;
|
||||||
|
|
||||||
|
lane return LANE;
|
||||||
|
llc return LLC;
|
||||||
|
metac return METAC;
|
||||||
|
bcc return BCC;
|
||||||
|
oam return OAM;
|
||||||
|
oamf4 return OAMF4;
|
||||||
|
oamf4ec return OAMF4EC;
|
||||||
|
oamf4sc return OAMF4SC;
|
||||||
|
sc return SC;
|
||||||
|
ilmic return ILMIC;
|
||||||
|
vpi return VPI;
|
||||||
|
vci return VCI;
|
||||||
|
connectmsg return CONNECTMSG;
|
||||||
|
metaconnect return METACONNECT;
|
||||||
|
|
||||||
[ \n\t] ;
|
[ \n\t] ;
|
||||||
[+\-*/:\[\]!<>()&|=] return yytext[0];
|
[+\-*/:\[\]!<>()&|=] return yytext[0];
|
||||||
">=" return GEQ;
|
">=" return GEQ;
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1997 Yen Yen Lim and North Dakota State University
|
||||||
|
* 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 Yen Yen Lim and
|
||||||
|
North Dakota State University
|
||||||
|
* 4. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||||
|
*
|
||||||
|
* @(#) $Header: /tcpdump/master/libpcap/sunatmpos.h,v 1.1 2002-07-11 09:06:47 guy Exp $ (LBL)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* SunATM header for ATM packet */
|
||||||
|
#define SUNATM_DIR_POS 0
|
||||||
|
#define SUNATM_VPI_POS 1
|
||||||
|
#define SUNATM_VCI_POS 2
|
||||||
|
#define SUNATM_PKT_BEGIN_POS 4 /* Start of ATM packet */
|
||||||
|
|
||||||
|
/* Protocol type values in the bottom for bits of the byte at SUNATM_DIR_POS. */
|
||||||
|
#define PT_LANE 0x01 /* LANE */
|
||||||
|
#define PT_LLC 0x02 /* LLC encapsulation */
|
||||||
|
#define PT_ILMI 0x05 /* ILMI */
|
||||||
|
#define PT_QSAAL 0x06 /* Q.SAAL */
|
Reference in New Issue