]> The Tcpdump Group git mirrors - libpcap/commitdiff
compiler: remove unneeded argument from gen_mcode6().
authorGuy Harris <[email protected]>
Sat, 6 May 2023 22:50:41 +0000 (15:50 -0700)
committerGuy Harris <[email protected]>
Sat, 6 May 2023 22:50:41 +0000 (15:50 -0700)
We don't support "<ipv6net> mask <ipv6mask>", so no need to pass an
<ipv6mask> argument.

gencode.c
gencode.h
grammar.y.in

index f6a2cac2e94f6b830f1d859c181778798d0039f1..138ed3ac2f0f96af59b40b8d2c128a830c5c2cd7 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -7188,8 +7188,8 @@ gen_ncode(compiler_state_t *cstate, const char *s, bpf_u_int32 v, struct qual q)
 
 #ifdef INET6
 struct block *
-gen_mcode6(compiler_state_t *cstate, const char *s1, const char *s2,
-    bpf_u_int32 masklen, struct qual q)
+gen_mcode6(compiler_state_t *cstate, const char *s, bpf_u_int32 masklen,
+    struct qual q)
 {
        struct addrinfo *res;
        struct in6_addr *addr;
@@ -7204,15 +7204,12 @@ gen_mcode6(compiler_state_t *cstate, const char *s1, const char *s2,
        if (setjmp(cstate->top_ctx))
                return (NULL);
 
-       if (s2)
-               bpf_error(cstate, "no mask %s supported", s2);
-
-       res = pcap_nametoaddrinfo(s1);
+       res = pcap_nametoaddrinfo(s);
        if (!res)
-               bpf_error(cstate, "invalid ip6 address %s", s1);
+               bpf_error(cstate, "invalid ip6 address %s", s);
        cstate->ai = res;
        if (res->ai_next)
-               bpf_error(cstate, "%s resolved to multiple address", s1);
+               bpf_error(cstate, "%s resolved to multiple address", s);
        addr = &((struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
 
        if (masklen > sizeof(mask.s6_addr) * 8)
@@ -7228,7 +7225,7 @@ gen_mcode6(compiler_state_t *cstate, const char *s1, const char *s2,
        memcpy(m, &mask, sizeof(m));
        if ((a[0] & ~m[0]) || (a[1] & ~m[1])
         || (a[2] & ~m[2]) || (a[3] & ~m[3])) {
-               bpf_error(cstate, "non-network bits set in \"%s/%d\"", s1, masklen);
+               bpf_error(cstate, "non-network bits set in \"%s/%d\"", s, masklen);
        }
 
        switch (q.addr) {
index 93ca5216b55614403c90ad964bbe93e5b9166e2d..b8296ab2fb0eeb69f348d73f474e51687ad89705 100644 (file)
--- a/gencode.h
+++ b/gencode.h
@@ -327,8 +327,8 @@ struct block *gen_acode(compiler_state_t *, const char *, struct qual);
 struct block *gen_mcode(compiler_state_t *, const char *, const char *,
     bpf_u_int32, struct qual);
 #ifdef INET6
-struct block *gen_mcode6(compiler_state_t *, const char *, const char *,
-    bpf_u_int32, struct qual);
+struct block *gen_mcode6(compiler_state_t *, const char *, bpf_u_int32,
+    struct qual);
 #endif
 struct block *gen_ncode(compiler_state_t *, const char *, bpf_u_int32,
     struct qual);
index 2360d3c7c3c2f8a5191157dfe78bb956c53a88a1..b8dabf7ee6147ecc9e02bc2b453c1bfce3ecc43d 100644 (file)
@@ -472,7 +472,7 @@ nid:          ID                    { CHECK_PTR_VAL($1); CHECK_PTR_VAL(($$.b = gen_scode(cstate, $1, $$.
        | HID6 '/' NUM          {
                                  CHECK_PTR_VAL($1);
 #ifdef INET6
-                                 CHECK_PTR_VAL(($$.b = gen_mcode6(cstate, $1, NULL, $3,
+                                 CHECK_PTR_VAL(($$.b = gen_mcode6(cstate, $1, $3,
                                    $$.q = $<blk>0.q)));
 #else
                                  bpf_set_error(cstate, "'ip6addr/prefixlen' not supported "
@@ -483,7 +483,7 @@ nid:          ID                    { CHECK_PTR_VAL($1); CHECK_PTR_VAL(($$.b = gen_scode(cstate, $1, $$.
        | HID6                  {
                                  CHECK_PTR_VAL($1);
 #ifdef INET6
-                                 CHECK_PTR_VAL(($$.b = gen_mcode6(cstate, $1, 0, 128,
+                                 CHECK_PTR_VAL(($$.b = gen_mcode6(cstate, $1, 128,
                                    $$.q = $<blk>0.q)));
 #else
                                  bpf_set_error(cstate, "'ip6addr' not supported "