From Florent Drouin: add support for filtering on MTP2 frame types.
This commit is contained in:
parent
7bf28e7fd2
commit
7589e0abc3
1
CREDITS
1
CREDITS
|
@ -32,6 +32,7 @@ Additional people who have contributed patches:
|
||||||
Dug Song <dugsong@monkey.org>
|
Dug Song <dugsong@monkey.org>
|
||||||
Eric Anderson <anderse@hpl.hp.com>
|
Eric Anderson <anderse@hpl.hp.com>
|
||||||
Erik de Castro Lopo <erik.de.castro.lopo@sensorynetworks.com>
|
Erik de Castro Lopo <erik.de.castro.lopo@sensorynetworks.com>
|
||||||
|
Florent Drouin <Florent.Drouin@alcatel-lucent.fr>
|
||||||
Franz Schaefer <schaefer@mond.at>
|
Franz Schaefer <schaefer@mond.at>
|
||||||
Gianluca Varenni <varenni@netgroup-serv.polito.it>
|
Gianluca Varenni <varenni@netgroup-serv.polito.it>
|
||||||
Gilbert Hoyek <gil_hoyek@hotmail.com>
|
Gilbert Hoyek <gil_hoyek@hotmail.com>
|
||||||
|
|
50
gencode.c
50
gencode.c
|
@ -21,7 +21,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] _U_ =
|
static const char rcsid[] _U_ =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.274 2006-12-20 08:20:27 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.275 2006-12-21 19:44:06 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -724,6 +724,11 @@ static u_int off_vpi;
|
||||||
static u_int off_vci;
|
static u_int off_vci;
|
||||||
static u_int off_proto;
|
static u_int off_proto;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These are offsets for the MTP2 fields.
|
||||||
|
*/
|
||||||
|
static u_int off_li;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These are offsets for the MTP3 fields.
|
* These are offsets for the MTP3 fields.
|
||||||
*/
|
*/
|
||||||
|
@ -790,6 +795,7 @@ init_linktype(p)
|
||||||
/*
|
/*
|
||||||
* And assume we're not doing SS7.
|
* And assume we're not doing SS7.
|
||||||
*/
|
*/
|
||||||
|
off_li = -1;
|
||||||
off_sio = -1;
|
off_sio = -1;
|
||||||
off_opc = -1;
|
off_opc = -1;
|
||||||
off_dpc = -1;
|
off_dpc = -1;
|
||||||
|
@ -1217,6 +1223,7 @@ init_linktype(p)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case DLT_MTP2:
|
case DLT_MTP2:
|
||||||
|
off_li = 2;
|
||||||
off_sio = 3;
|
off_sio = 3;
|
||||||
off_opc = 4;
|
off_opc = 4;
|
||||||
off_dpc = 4;
|
off_dpc = 4;
|
||||||
|
@ -6757,6 +6764,47 @@ gen_atmtype_abbrev(type)
|
||||||
return b1;
|
return b1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Filtering for MTP2 messages based on li value
|
||||||
|
* FISU, length is null
|
||||||
|
* LSU, length is 1 or 2
|
||||||
|
* MSU, length is 3 or more
|
||||||
|
*/
|
||||||
|
struct block *
|
||||||
|
gen_mtp2type_abbrev(type)
|
||||||
|
int type;
|
||||||
|
{
|
||||||
|
struct block *b0, *b1;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
|
||||||
|
case M_FISU:
|
||||||
|
if (linktype != DLT_MTP2)
|
||||||
|
bpf_error("'fisu' supported only on MTP2");
|
||||||
|
/* gen_ncmp(offrel, offset, size, mask, jtype, reverse, value) */
|
||||||
|
b0 = gen_ncmp(OR_PACKET, off_li, BPF_B, 0x3f, BPF_JEQ, 0, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case M_LSU:
|
||||||
|
if (linktype != DLT_MTP2)
|
||||||
|
bpf_error("'lsu' supported only on MTP2");
|
||||||
|
b0 = gen_ncmp(OR_PACKET, off_li, BPF_B, 0x3f, BPF_JGT, 1, 2);
|
||||||
|
b1 = gen_ncmp(OR_PACKET, off_li, BPF_B, 0x3f, BPF_JGT, 0, 0);
|
||||||
|
gen_and(b1, b0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case M_MSU:
|
||||||
|
if (linktype != DLT_MTP2)
|
||||||
|
bpf_error("'msu' supported only on MTP2");
|
||||||
|
b0 = gen_ncmp(OR_PACKET, off_li, BPF_B, 0x3f, BPF_JGT, 0, 2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
return b0;
|
||||||
|
}
|
||||||
|
|
||||||
struct block *
|
struct block *
|
||||||
gen_mtp3field_code(mtp3field, jvalue, jtype, reverse)
|
gen_mtp3field_code(mtp3field, jvalue, jtype, reverse)
|
||||||
int mtp3field;
|
int mtp3field;
|
||||||
|
|
18
gencode.h
18
gencode.h
|
@ -18,7 +18,7 @@
|
||||||
* 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.66 2005-09-05 09:07:00 guy Exp $ (LBL)
|
* @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.67 2006-12-21 19:44:06 guy Exp $ (LBL)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -173,11 +173,16 @@
|
||||||
end-to-end circuits, ILMI circuits or
|
end-to-end circuits, ILMI circuits or
|
||||||
connection signalling circuit. */
|
connection signalling circuit. */
|
||||||
|
|
||||||
/*MTP3 field types */
|
/* MTP2 types */
|
||||||
#define M_SIO 1
|
#define M_FISU 22 /* FISU */
|
||||||
#define M_OPC 2
|
#define M_LSU 23 /* LSU */
|
||||||
#define M_DPC 3
|
#define M_MSU 24 /* MSU */
|
||||||
#define M_SLS 4
|
|
||||||
|
/* MTP3 field types */
|
||||||
|
#define M_SIO 1
|
||||||
|
#define M_OPC 2
|
||||||
|
#define M_DPC 3
|
||||||
|
#define M_SLS 4
|
||||||
|
|
||||||
|
|
||||||
struct slist;
|
struct slist;
|
||||||
|
@ -296,6 +301,7 @@ struct block *gen_atmfield_code(int atmfield, bpf_int32 jvalue, bpf_u_int32 jtyp
|
||||||
struct block *gen_atmtype_abbrev(int type);
|
struct block *gen_atmtype_abbrev(int type);
|
||||||
struct block *gen_atmmulti_abbrev(int type);
|
struct block *gen_atmmulti_abbrev(int type);
|
||||||
|
|
||||||
|
struct block *gen_mtp2type_abbrev(int type);
|
||||||
struct block *gen_mtp3field_code(int mtp3field, bpf_u_int32 jvalue, bpf_u_int32 jtype, int reverse);
|
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_ifname(const char *);
|
||||||
|
|
16
grammar.y
16
grammar.y
|
@ -22,7 +22,7 @@
|
||||||
*/
|
*/
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] _U_ =
|
static const char rcsid[] _U_ =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.93 2006-10-04 18:09:22 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.94 2006-12-21 19:44:06 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -113,8 +113,9 @@ pcap_parse()
|
||||||
%type <i> atmtype atmmultitype
|
%type <i> atmtype atmmultitype
|
||||||
%type <blk> atmfield
|
%type <blk> atmfield
|
||||||
%type <blk> atmfieldvalue atmvalue atmlistvalue
|
%type <blk> atmfieldvalue atmvalue atmlistvalue
|
||||||
%type <blk> mtp3field
|
%type <i> mtp2type
|
||||||
%type <blk> mtp3fieldvalue mtp3value mtp3listvalue
|
%type <blk> mtp3field
|
||||||
|
%type <blk> mtp3fieldvalue mtp3value mtp3listvalue
|
||||||
|
|
||||||
|
|
||||||
%token DST SRC HOST GATEWAY
|
%token DST SRC HOST GATEWAY
|
||||||
|
@ -140,7 +141,8 @@ pcap_parse()
|
||||||
%token OAM OAMF4 CONNECTMSG METACONNECT
|
%token OAM OAMF4 CONNECTMSG METACONNECT
|
||||||
%token VPI VCI
|
%token VPI VCI
|
||||||
%token RADIO
|
%token RADIO
|
||||||
%token SIO OPC DPC SLS
|
%token FISU LSU MSU
|
||||||
|
%token SIO OPC DPC SLS
|
||||||
|
|
||||||
%type <s> ID
|
%type <s> ID
|
||||||
%type <e> EID
|
%type <e> EID
|
||||||
|
@ -269,6 +271,7 @@ rterm: head id { $$ = $2; }
|
||||||
| atmtype { $$.b = gen_atmtype_abbrev($1); $$.q = qerr; }
|
| atmtype { $$.b = gen_atmtype_abbrev($1); $$.q = qerr; }
|
||||||
| atmmultitype { $$.b = gen_atmmulti_abbrev($1); $$.q = qerr; }
|
| atmmultitype { $$.b = gen_atmmulti_abbrev($1); $$.q = qerr; }
|
||||||
| atmfield atmvalue { $$.b = $2.b; $$.q = qerr; }
|
| atmfield atmvalue { $$.b = $2.b; $$.q = qerr; }
|
||||||
|
| mtp2type { $$.b = gen_mtp2type_abbrev($1); $$.q = qerr; }
|
||||||
| mtp3field mtp3value { $$.b = $2.b; $$.q = qerr; }
|
| mtp3field mtp3value { $$.b = $2.b; $$.q = qerr; }
|
||||||
;
|
;
|
||||||
/* protocol level qualifiers */
|
/* protocol level qualifiers */
|
||||||
|
@ -447,6 +450,11 @@ atmfieldvalue: NUM {
|
||||||
atmlistvalue: atmfieldvalue
|
atmlistvalue: atmfieldvalue
|
||||||
| atmlistvalue or atmfieldvalue { gen_or($1.b, $3.b); $$ = $3; }
|
| atmlistvalue or atmfieldvalue { gen_or($1.b, $3.b); $$ = $3; }
|
||||||
;
|
;
|
||||||
|
/* MTP2 types quantifier */
|
||||||
|
mtp2type: FISU { $$ = M_FISU; }
|
||||||
|
| LSU { $$ = M_LSU; }
|
||||||
|
| MSU { $$ = M_MSU; }
|
||||||
|
;
|
||||||
/* MTP3 field types quantifier */
|
/* MTP3 field types quantifier */
|
||||||
mtp3field: SIO { $$.mtp3fieldtype = M_SIO; }
|
mtp3field: SIO { $$.mtp3fieldtype = M_SIO; }
|
||||||
| OPC { $$.mtp3fieldtype = M_OPC; }
|
| OPC { $$.mtp3fieldtype = M_OPC; }
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char rcsid[] _U_ =
|
static const char rcsid[] _U_ =
|
||||||
"@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.106 2006-10-04 18:09:22 guy Exp $ (LBL)";
|
"@(#) $Header: /tcpdump/master/libpcap/scanner.l,v 1.107 2006-12-21 19:44:06 guy Exp $ (LBL)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
|
@ -288,6 +288,9 @@ srnr|subrulenum return PF_SRNR;
|
||||||
reason return PF_REASON;
|
reason return PF_REASON;
|
||||||
action return PF_ACTION;
|
action return PF_ACTION;
|
||||||
|
|
||||||
|
fisu return FISU;
|
||||||
|
lsu return LSU;
|
||||||
|
msu return MSU;
|
||||||
sio return SIO;
|
sio return SIO;
|
||||||
opc return OPC;
|
opc return OPC;
|
||||||
dpc return DPC;
|
dpc return DPC;
|
||||||
|
|
Reference in New Issue