]> The Tcpdump Group git mirrors - libpcap/commitdiff
Make the value argument to "gen_ncmp()" a bpf_int32, the same as the
authorguy <guy>
Sun, 1 May 2005 08:37:04 +0000 (08:37 +0000)
committerguy <guy>
Sun, 1 May 2005 08:37:04 +0000 (08:37 +0000)
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()".

gencode.c
gencode.h
grammar.y

index fbc1bd263924f9f146317a4504bc3425924de346..02a3155618e8c0a3f9d41fdc51d95b31a7ce66fc 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -21,7 +21,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
  */
 #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
 #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);
 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);
 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;
 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;
 {
        int reverse;
 {
-       struct slist *s;
+       struct slist *s, *s2;
        struct block *b;
 
        s = gen_load_a(offrel, offset, size);
 
        if (mask != 0xffffffff) {
        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));
        }
 
        b = new_block(JMP(jtype));
@@ -5812,7 +5814,7 @@ gen_mpls(label_num)
 struct block *
 gen_atmfield_code(atmfield, jvalue, jtype, reverse)
        int atmfield;
 struct block *
 gen_atmfield_code(atmfield, jvalue, jtype, reverse)
        int atmfield;
-       bpf_u_int32 jvalue;
+       bpf_int32 jvalue;
        bpf_u_int32 jtype;
        int reverse;
 {
        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();
                        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:
                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();
                        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 */
                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,
                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:
                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,
                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:
                break;
 
        default:
index 6c3ebf9d22aac2eca18b4b7e066232b166c976c9..c18dea58c63593126f20b89fc3ae4d3b4a144338 100644 (file)
--- a/gencode.h
+++ b/gencode.h
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * 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_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_atmtype_abbrev(int type);
 struct block *gen_atmmulti_abbrev(int type);
 
index 1a86044f0825e310be8e58a029c2880f636b935a..5fad9bd481b742cb5f5263c4b59c00f7d06c9d3b 100644 (file)
--- a/grammar.y
+++ b/grammar.y
@@ -22,7 +22,7 @@
  */
 #ifndef lint
 static const char rcsid[] _U_ =
  */
 #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
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -414,15 +414,15 @@ atmfield: VPI                     { $$.atmfieldtype = A_VPI; }
        | VCI                   { $$.atmfieldtype = A_VCI; }
        ;
 atmvalue: atmfieldvalue
        | 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)
        | 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: atmfieldvalue