Make the value argument to "gen_ncmp()" a bpf_int32, the same as the
value arguments are to other routines. Do the same with the value argument to "gen_atmfield_code()". "gen_load_a()" can return more than one statement; append to the list of statements it returns with "sappend()", rather than manually appending to the first statement. Fix the argument list to one "gen_ncmp()" call, and get rid of the casts in the other calls, as the arguments already have the right types. Fix the casts in calls to "gen_atmfield_code()".
This commit is contained in:
parent
8b9f740d4c
commit
27cd2f8c65
32
gencode.c
32
gencode.c
|
@ -21,7 +21,7 @@
|
|||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.221.2.11 2005-05-01 04:14:15 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.221.2.12 2005-05-01 08:37:48 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
@ -178,7 +178,7 @@ static struct block *gen_mcmp(enum e_offrel, u_int, u_int, bpf_int32,
|
|||
bpf_u_int32);
|
||||
static struct block *gen_bcmp(enum e_offrel, u_int, u_int, const u_char *);
|
||||
static struct block *gen_ncmp(enum e_offrel, bpf_u_int32, bpf_u_int32,
|
||||
bpf_u_int32, bpf_u_int32, int, bpf_u_int32);
|
||||
bpf_u_int32, bpf_u_int32, int, bpf_int32);
|
||||
static struct slist *gen_load_a(enum e_offrel, u_int, u_int);
|
||||
static struct block *gen_uncond(int);
|
||||
static inline struct block *gen_true(void);
|
||||
|
@ -608,17 +608,19 @@ gen_bcmp(offrel, offset, size, v)
|
|||
static struct block *
|
||||
gen_ncmp(offrel, offset, size, mask, jtype, reverse, v)
|
||||
enum e_offrel offrel;
|
||||
bpf_u_int32 offset, size, mask, jtype, v;
|
||||
bpf_int32 v;
|
||||
bpf_u_int32 offset, size, mask, jtype;
|
||||
int reverse;
|
||||
{
|
||||
struct slist *s;
|
||||
struct slist *s, *s2;
|
||||
struct block *b;
|
||||
|
||||
s = gen_load_a(offrel, offset, size);
|
||||
|
||||
if (mask != 0xffffffff) {
|
||||
s->next = new_stmt(BPF_ALU|BPF_AND|BPF_K);
|
||||
s->next->s.k = mask;
|
||||
s2 = new_stmt(BPF_ALU|BPF_AND|BPF_K);
|
||||
s2->s.k = mask;
|
||||
sappend(s, s2);
|
||||
}
|
||||
|
||||
b = new_block(JMP(jtype));
|
||||
|
@ -5812,7 +5814,7 @@ gen_mpls(label_num)
|
|||
struct block *
|
||||
gen_atmfield_code(atmfield, jvalue, jtype, reverse)
|
||||
int atmfield;
|
||||
bpf_u_int32 jvalue;
|
||||
bpf_int32 jvalue;
|
||||
bpf_u_int32 jtype;
|
||||
int reverse;
|
||||
{
|
||||
|
@ -5825,8 +5827,8 @@ gen_atmfield_code(atmfield, jvalue, jtype, reverse)
|
|||
bpf_error("'vpi' supported only on raw ATM");
|
||||
if (off_vpi == (u_int)-1)
|
||||
abort();
|
||||
b0 = gen_ncmp(OR_LINK, off_vpi, BPF_B, 0xffffffff, (u_int)jtype,
|
||||
(u_int)jvalue, reverse);
|
||||
b0 = gen_ncmp(OR_LINK, off_vpi, BPF_B, 0xffffffff, jtype,
|
||||
reverse, jvalue);
|
||||
break;
|
||||
|
||||
case A_VCI:
|
||||
|
@ -5834,22 +5836,22 @@ gen_atmfield_code(atmfield, jvalue, jtype, reverse)
|
|||
bpf_error("'vci' supported only on raw ATM");
|
||||
if (off_vci == (u_int)-1)
|
||||
abort();
|
||||
b0 = gen_ncmp(OR_LINK, off_vci, BPF_H, 0xffffffff, (u_int)jtype,
|
||||
reverse, (u_int)jvalue);
|
||||
b0 = gen_ncmp(OR_LINK, off_vci, BPF_H, 0xffffffff, jtype,
|
||||
reverse, jvalue);
|
||||
break;
|
||||
|
||||
case A_PROTOTYPE:
|
||||
if (off_proto == (u_int)-1)
|
||||
abort(); /* XXX - this isn't on FreeBSD */
|
||||
b0 = gen_ncmp(OR_LINK, off_proto, BPF_B, 0x0f, (u_int)jtype,
|
||||
reverse, (u_int)jvalue);
|
||||
b0 = gen_ncmp(OR_LINK, off_proto, BPF_B, 0x0f, jtype,
|
||||
reverse, jvalue);
|
||||
break;
|
||||
|
||||
case A_MSGTYPE:
|
||||
if (off_payload == (u_int)-1)
|
||||
abort();
|
||||
b0 = gen_ncmp(OR_LINK, off_payload + MSG_TYPE_POS, BPF_B,
|
||||
0xffffffff, (u_int)jtype, reverse, (u_int)jvalue);
|
||||
0xffffffff, jtype, reverse, jvalue);
|
||||
break;
|
||||
|
||||
case A_CALLREFTYPE:
|
||||
|
@ -5858,7 +5860,7 @@ gen_atmfield_code(atmfield, jvalue, jtype, reverse)
|
|||
if (off_proto == (u_int)-1)
|
||||
abort();
|
||||
b0 = gen_ncmp(OR_LINK, off_proto, BPF_B, 0xffffffff,
|
||||
(u_int)jtype, reverse, (u_int)jvalue);
|
||||
jtype, reverse, jvalue);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -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.60.2.2 2005-04-23 22:27:38 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.60.2.3 2005-05-01 08:37:50 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -280,7 +280,7 @@ 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);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.86.2.1 2005-04-19 04:26:08 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.86.2.2 2005-05-01 08:37:50 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
@ -414,15 +414,15 @@ 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
|
||||
|
|
Reference in New Issue