resolve merge conflicts

Approved by:	re (scottl)
This commit is contained in:
Sam Leffler 2005-07-11 03:43:25 +00:00
parent 8930d062b6
commit 4238c2cd94
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=147897
10 changed files with 1554 additions and 542 deletions

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $FreeBSD$
* @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.60 2004/06/16 08:20:30 hannes Exp $ (LBL)
* @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.60.2.5 2005/06/20 21:30:17 guy Exp $ (LBL)
*/
/*
@ -56,6 +56,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef HAVE___ATTRIBUTE__
#define __attribute__(x)
#endif /* HAVE___ATTRIBUTE__ */
/* Address qualifiers. */
#define Q_HOST 1
@ -64,6 +68,7 @@
#define Q_GATEWAY 4
#define Q_PROTO 5
#define Q_PROTOCHAIN 6
#define Q_PORTRANGE 7
/* Protocol qualifiers. */
@ -120,6 +125,8 @@
#define Q_ISIS_PSNP 38
#define Q_ISIS_LSP 39
#define Q_RADIO 40
/* Directional qualifiers. */
#define Q_SRC 1
@ -167,6 +174,13 @@
end-to-end circuits, ILMI circuits or
connection signalling circuit. */
/*MTP3 field types */
#define M_SIO 1
#define M_OPC 2
#define M_DPC 3
#define M_SLS 4
struct slist;
struct stmt {
@ -276,10 +290,12 @@ struct block *gen_inbound(int);
struct block *gen_vlan(int);
struct block *gen_mpls(int);
struct block *gen_atmfield_code(int atmfield, bpf_u_int32 jvalue, bpf_u_int32 jtype, int reverse);
struct block *gen_atmfield_code(int atmfield, bpf_int32 jvalue, bpf_u_int32 jtype, int reverse);
struct block *gen_atmtype_abbrev(int type);
struct block *gen_atmmulti_abbrev(int type);
struct block *gen_mtp3field_code(int mtp3field, bpf_u_int32 jvalue, bpf_u_int32 jtype, int reverse);
struct block *gen_pf_ifname(const char *);
struct block *gen_pf_rnr(int);
struct block *gen_pf_srnr(int);
@ -290,10 +306,7 @@ struct block *gen_pf_dir(int);
void bpf_optimize(struct block **);
void bpf_error(const char *, ...)
#if HAVE___ATTRIBUTE__
__attribute__((noreturn, format (printf, 1, 2)))
#endif
;
__attribute__((noreturn, format (printf, 1, 2)));
void finish_parse(struct block *);
char *sdup(const char *);

View File

@ -23,7 +23,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.86 2004/12/18 08:49:23 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.86.2.4 2005/06/20 21:30:17 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -98,6 +98,7 @@ pcap_parse()
struct {
struct qual q;
int atmfieldtype;
int mtp3fieldtype;
struct block *b;
} blk;
struct block *rblk;
@ -113,9 +114,12 @@ pcap_parse()
%type <i> atmtype atmmultitype
%type <blk> atmfield
%type <blk> atmfieldvalue atmvalue atmlistvalue
%type <blk> mtp3field
%type <blk> mtp3fieldvalue mtp3value mtp3listvalue
%token DST SRC HOST GATEWAY
%token NET NETMASK PORT LESS GREATER PROTO PROTOCHAIN CBYTE
%token NET NETMASK PORT PORTRANGE LESS GREATER PROTO PROTOCHAIN CBYTE
%token ARP RARP IP SCTP TCP UDP ICMP IGMP IGRP PIM VRRP
%token ATALK AARP DECNET LAT SCA MOPRC MOPDL
%token TK_BROADCAST TK_MULTICAST
@ -135,6 +139,8 @@ pcap_parse()
%token LANE LLC METAC BCC SC ILMIC OAMF4EC OAMF4SC
%token OAM OAMF4 CONNECTMSG METACONNECT
%token VPI VCI
%token RADIO
%token SIO OPC DPC SLS
%type <s> ID
%type <e> EID
@ -255,6 +261,7 @@ rterm: head id { $$ = $2; }
| atmtype { $$.b = gen_atmtype_abbrev($1); $$.q = qerr; }
| atmmultitype { $$.b = gen_atmmulti_abbrev($1); $$.q = qerr; }
| atmfield atmvalue { $$.b = $2.b; $$.q = qerr; }
| mtp3field mtp3value { $$.b = $2.b; $$.q = qerr; }
;
/* protocol level qualifiers */
pqual: pname
@ -272,6 +279,7 @@ dqual: SRC { $$ = Q_SRC; }
aqual: HOST { $$ = Q_HOST; }
| NET { $$ = Q_NET; }
| PORT { $$ = Q_PORT; }
| PORTRANGE { $$ = Q_PORTRANGE; }
;
/* non-directional address type qualifiers */
ndaqual: GATEWAY { $$ = Q_GATEWAY; }
@ -313,6 +321,7 @@ pname: LINK { $$ = Q_LINK; }
| STP { $$ = Q_STP; }
| IPX { $$ = Q_IPX; }
| NETBEUI { $$ = Q_NETBEUI; }
| RADIO { $$ = Q_RADIO; }
;
other: pqual TK_BROADCAST { $$ = gen_broadcast($1); }
| pqual TK_MULTICAST { $$ = gen_multicast($1); }
@ -414,18 +423,41 @@ 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); }
| relop NUM { $$.b = gen_atmfield_code($<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$1, 0); }
| irelop NUM { $$.b = gen_atmfield_code($<blk>0.atmfieldtype, (bpf_int32)$2, (bpf_u_int32)$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);
$$.b = gen_atmfield_code($$.atmfieldtype, (bpf_int32) $1, BPF_JEQ, 0);
}
;
atmlistvalue: atmfieldvalue
| atmlistvalue or atmfieldvalue { gen_or($1.b, $3.b); $$ = $3; }
;
/* MTP3 field types quantifier */
mtp3field: SIO { $$.mtp3fieldtype = M_SIO; }
| OPC { $$.mtp3fieldtype = M_OPC; }
| DPC { $$.mtp3fieldtype = M_DPC; }
| SLS { $$.mtp3fieldtype = M_SLS; }
;
mtp3value: mtp3fieldvalue
| relop NUM { $$.b = gen_mtp3field_code($<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 0); }
| irelop NUM { $$.b = gen_mtp3field_code($<blk>0.mtp3fieldtype, (u_int)$2, (u_int)$1, 1); }
| paren mtp3listvalue ')' { $$.b = $2.b; $$.q = qerr; }
;
mtp3fieldvalue: NUM {
$$.mtp3fieldtype = $<blk>0.mtp3fieldtype;
if ($$.mtp3fieldtype == M_SIO ||
$$.mtp3fieldtype == M_OPC ||
$$.mtp3fieldtype == M_DPC ||
$$.mtp3fieldtype == M_SLS )
$$.b = gen_mtp3field_code($$.mtp3fieldtype, (u_int) $1, BPF_JEQ, 0);
}
;
mtp3listvalue: mtp3fieldvalue
| mtp3listvalue or mtp3fieldvalue { gen_or($1.b, $3.b); $$ = $3; }
;
%%

View File

@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.77 2005/03/27 22:26:25 guy Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.77.2.3 2005/04/20 11:13:51 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -76,7 +76,7 @@ struct rtentry; /* declarations in <net/if.h> */
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <stdio.h>
#include "pcap-int.h"
@ -218,6 +218,51 @@ pcap_nametoport(const char *name, int *port, int *proto)
return 0;
}
/*
* Convert a string in the form PPP-PPP, where correspond to ports, to
* a starting and ending port in a port range.
* Return 0 on failure.
*/
int
pcap_nametoportrange(const char *name, int *port1, int *port2, int *proto)
{
u_int p1, p2;
char *off, *cpy;
int save_proto;
if (sscanf(name, "%d-%d", &p1, &p2) != 2) {
if ((cpy = strdup(name)) == NULL)
return 0;
if ((off = strchr(cpy, '-')) == NULL) {
free(cpy);
return 0;
}
*off = '\0';
if (pcap_nametoport(cpy, port1, proto) == 0) {
free(cpy);
return 0;
}
save_proto = *proto;
if (pcap_nametoport(off + 1, port2, proto) == 0) {
free(cpy);
return 0;
}
if (*proto != save_proto)
*proto = PROTO_UNDEF;
} else {
*port1 = p1;
*port2 = p2;
*proto = PROTO_UNDEF;
}
return 1;
}
int
pcap_nametoproto(const char *str)
{
@ -424,6 +469,11 @@ pcap_ether_hostton(const char *name)
#else
#if !defined(HAVE_DECL_ETHER_HOSTTON) || !HAVE_DECL_ETHER_HOSTTON
#ifndef HAVE_STRUCT_ETHER_ADDR
struct ether_addr {
unsigned char ether_addr_octet[6];
};
#endif
extern int ether_hostton(const char *, struct ether_addr *);
#endif

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* $FreeBSD$
* @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.68 2004/12/18 08:52:10 guy Exp $ (LBL)
* @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.68.2.2 2005/05/03 18:54:36 guy Exp $ (LBL)
*/
#ifndef pcap_int_h
@ -100,6 +100,14 @@ struct pcap_md {
#endif
};
/*
* Ultrix, DEC OSF/1^H^H^H^H^H^H^H^H^HDigital UNIX^H^H^H^H^H^H^H^H^H^H^H^H
* Tru64 UNIX, and NetBSD pad to make everything line up on a nice boundary.
*/
#if defined(ultrix) || defined(__osf__) || (defined(__NetBSD__) && __NetBSD_Version__ > 106000000)
#define PCAP_FDDIPAD 3
#endif
struct pcap {
#ifdef WIN32
ADAPTER *adapter;
@ -143,12 +151,16 @@ struct pcap {
*/
u_char *pkt;
/* We're accepting only packets in this direction/these directions. */
direction_t direction;
/*
* Methods.
*/
int (*read_op)(pcap_t *, int cnt, pcap_handler, u_char *);
int (*inject_op)(pcap_t *, const void *, size_t);
int (*setfilter_op)(pcap_t *, struct bpf_program *);
int (*setdirection_op)(pcap_t *, direction_t);
int (*set_datalink_op)(pcap_t *, int);
int (*getnonblock_op)(pcap_t *, char *);
int (*setnonblock_op)(pcap_t *, int, char *);
@ -239,13 +251,11 @@ int yylex(void);
int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *);
int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *);
/*
* Ultrix, DEC OSF/1^H^H^H^H^H^H^H^H^HDigital UNIX^H^H^H^H^H^H^H^H^H^H^H^H
* Tru64 UNIX, and NetBSD pad to make everything line up on a nice boundary.
*/
#if defined(ultrix) || defined(__osf__) || defined(__NetBSD__)
#define PCAP_FDDIPAD 3
#ifndef HAVE_STRLCPY
#define strlcpy(x, y, z) \
(strncpy((x), (y), (z)), \
((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \
strlen((y)))
#endif
#include <stdarg.h>

View File

@ -66,6 +66,7 @@ struct addrinfo *pcap_nametoaddrinfo(const char *);
bpf_u_int32 pcap_nametonetaddr(const char *);
int pcap_nametoport(const char *, int *, int *);
int pcap_nametoportrange(const char *, int *, int *, int *);
int pcap_nametoproto(const char *);
int pcap_nametoeproto(const char *);
int pcap_nametollc(const char *);

View File

@ -1,4 +1,4 @@
.\" @(#) $Header: /tcpdump/master/libpcap/pcap.3,v 1.64 2004/12/17 21:27:54 guy Exp $
.\" @(#) $Header: /tcpdump/master/libpcap/pcap.3,v 1.64.2.4 2005/06/03 20:36:56 guy Exp $
.\"
.\" Copyright (c) 1994, 1996, 1997
.\" The Regents of the University of California. All rights reserved.
@ -61,6 +61,10 @@ bpf_u_int32 *maskp, char *errbuf)
.ft
.LP
.ft B
typedef void (*pcap_handler)(u_char *user, const struct pcap_pkthdr *h,
.ti +8
const u_char *bytes);
.ft B
int pcap_dispatch(pcap_t *p, int cnt,
.ti +8
pcap_handler callback, u_char *user)
@ -77,7 +81,8 @@ int pcap_compile(pcap_t *p, struct bpf_program *fp,
.ti +8
char *str, int optimize, bpf_u_int32 netmask)
int pcap_setfilter(pcap_t *p, struct bpf_program *fp)
void pcap_freecode(struct bpf_program *);
void pcap_freecode(struct bpf_program *)
int pcap_setdirection(pcap_t *p, direction_t d)
.ft
.LP
.ft B
@ -120,6 +125,7 @@ const char *pcap_lib_version(void)
.ft B
void pcap_close(pcap_t *p)
int pcap_dump_flush(pcap_dumper_t *p)
long pcap_dump_ftell(pcap_dumper_t *p)
FILE *pcap_dump_file(pcap_dumper_t *p)
void pcap_dump_close(pcap_dumper_t *p)
.ft
@ -775,6 +781,31 @@ when that BPF program is no longer needed, for example after it
has been made the filter program for a pcap structure by a call to
.BR pcap_setfilter() .
.PP
.B pcap_setdirection()
is used to specify a direction that packets will be captured.
.I direction_t
is one of the constants
.BR D_IN ,
.B D_OUT
or
.BR D_INOUT .
.B D_IN
will only capture packets received by the device,
.B D_OUT
will only capture packets sent by the device and
.B D_INOUT
will capture packets received by or sent by the device.
.B D_INOUT
is the default setting if this function is not called. This isn't
necessarily supported on all platforms; some platforms might return an
error, and some other platforms might not support
.BR D_OUT .
This operation is not supported if a ``savefile'' is being read.
.B \-1
is returned on failure,
.B 0
is returned on success.
.PP
.B pcap_datalink()
returns the link layer type; link layer types it can return include:
.PP
@ -1250,6 +1281,15 @@ but not yet written to the ``savefile'' will be written.
.B \-1
is returned on error, 0 on success.
.PP
.B pcap_dump_ftell()
returns the current file position for the ``savefile'', representing the
number of bytes written by
.B pcap_dump_open()
and
.BR pcap_dump() .
.B \-1
is returned on error.
.PP
.B pcap_dump_close()
closes the ``savefile.''
.PP

View File

@ -112,6 +112,12 @@ struct pcap_file_header {
bpf_u_int32 linktype; /* data link type (LINKTYPE_*) */
};
typedef enum {
D_INOUT = 0,
D_IN,
D_OUT
} direction_t;
/*
* Each packet in the dump file is prepended with this generic header.
* This gets around the problem of different headers for different
@ -210,6 +216,7 @@ int pcap_next_ex(pcap_t *, struct pcap_pkthdr **, const u_char **);
void pcap_breakloop(pcap_t *);
int pcap_stats(pcap_t *, struct pcap_stat *);
int pcap_setfilter(pcap_t *, struct bpf_program *);
int pcap_setdirection(pcap_t *, direction_t);
int pcap_getnonblock(pcap_t *, char *);
int pcap_setnonblock(pcap_t *, int, char *);
void pcap_perror(pcap_t *, char *);
@ -239,10 +246,11 @@ int pcap_fileno(pcap_t *);
pcap_dumper_t *pcap_dump_open(pcap_t *, const char *);
pcap_dumper_t *pcap_dump_fopen(pcap_t *, FILE *fp);
FILE *pcap_dump_file(pcap_dumper_t *);
long pcap_dump_ftell(pcap_dumper_t *);
int pcap_dump_flush(pcap_dumper_t *);
void pcap_dump_close(pcap_dumper_t *);
void pcap_dump(u_char *, const struct pcap_pkthdr *, const u_char *);
FILE *pcap_dump_file(pcap_dumper_t *);
int pcap_findalldevs(pcap_if_t **, char *);
void pcap_freealldevs(pcap_if_t *);

View File

@ -1,105 +0,0 @@
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
/*
* Copyright (c) 2003 - The tcpdump group.
*
* 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. Neither the name of the University nor of the Laboratory 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.
*
* @(#) $Header: /tcpdump/master/libpcap/rawss7.h,v 1.1 2003/09/10 19:55:36 mcr Exp $ (LBL)
*/
/*
* This file is never used in libpcap or tcpdump. It is provided as
* documentation linktypes 139 through 142 only.
*/
/*
* Date: Tue, 09 Sep 2003 09:41:04 -0400
* From: Jeff Morriss <jeff.morriss[AT]ulticom.com>
* To: tcpdump-workers@tcpdump.org
* Subject: [tcpdump-workers] request for LINKTYPE_
*
* We've had some discussion over on ethereal-dev about a "fake link" or
* "raw SS7" dissector that allows dumping an arbitrary protocol into a
* file without any (otherwise necessary) lower level protocols. The
* common example has been dumping MTP3 into a file without, well, MTP2 or
* M2PA.
*
* We want to store these protocols directly in PCAP file format because
* it's well defined and there isn't another (popular) file format for
* capturing SS7 messages that we can reverse engineer (and we want to read
* these files into Ethereal). Rather than creating a new file format, it's
* a lot easier to just allocate a LINKTYPE_.
*
* Here is the original post thread:
*
* http://ethereal.com/lists/ethereal-dev/200306/threads.html#00200
*
* July's thread on the subject:
*
* http://ethereal.com/lists/ethereal-dev/200307/threads.html#00124
*
* August's thread:
*
* http://ethereal.com/lists/ethereal-dev/200308/threads.html#00193
*
*
* and one of the last messages--which is why I'm mailing you today:
*
* http://ethereal.com/lists/ethereal-dev/200308/msg00193.html
*
*
* Based on the message in the last URL, I'd like to request a new
* LINKTYPE_: LINKTYPE_RAWSS7.
*
* This packets in this file type will contain a header:
*/
typedef struct _rawss7_hdr {
/* NOTE: These are in network-byte order. */
guint32 type;
guint16 length;
guint16 spare;
} rawss7_hdr;
/*
*
* followed by protocol data for whatever protocol 'type' indicates.
*
* There was some discussion about these protocol 'type's being allocated by
* tcpdump-workers as well. In fact it would be handy to have one place to
* allocate such numbers, so what do you think about allocating 3 more (for
* now) LINKTYPE_'s:
*/
#define LINKTYPE_RAWSS7_MTP2 140
#define LINKTYPE_RAWSS7_MTP3 141
#define LINKTYPE_RAWSS7_SCCP 142
/*
*
* There is no reason this can't be used to store non-SS7 protocols, but
* it's what we need to use it for now...
*
*/

View File

@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] _U_ =
"@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.99 2004/06/16 08:20:28 hannes Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.99.2.3 2005/06/20 21:30:19 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@ -184,6 +184,7 @@ igmp return IGMP;
igrp return IGRP;
pim return PIM;
vrrp return VRRP;
radio return RADIO;
ip6 {
#ifdef INET6
@ -235,6 +236,7 @@ host return HOST;
net return NET;
mask return NETMASK;
port return PORT;
portrange return PORTRANGE;
proto return PROTO;
protochain {
#ifdef NO_PROTOCHAIN
@ -285,6 +287,11 @@ srnr|subrulenum return PF_SRNR;
reason return PF_REASON;
action return PF_ACTION;
sio return SIO;
opc return OPC;
dpc return DPC;
sls return SLS;
[ \r\n\t] ;
[+\-*/:\[\]!<>()&|=] return yytext[0];
">=" return GEQ;