Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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()".
  • Loading branch information...
commit 68041031879e59f396ae0132eb709da662f01418 1 parent eeadab8
@yuguy yuguy authored
Showing with 23 additions and 21 deletions.
  1. +17 −15 gencode.c
  2. +2 −2 gencode.h
  3. +4 −4 grammar.y
View
32 gencode.c
@@ -21,7 +21,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.237 2005-05-01 04:13:52 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.238 2005-05-01 08:37:04 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:
View
4 gencode.h
@@ -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.62 2005-04-23 22:26:52 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.63 2005-05-01 08:37:06 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);
View
8 grammar.y
@@ -22,7 +22,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.87 2005-04-19 04:25:01 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.88 2005-05-01 08:37:06 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
Please sign in to comment.
Something went wrong with that request. Please try again.