]> The Tcpdump Group git mirrors - tcpdump/commitdiff
call ip6addr_string() instead of getname6()
authorDenis Ovsienko <[email protected]>
Mon, 11 Jul 2016 09:26:01 +0000 (10:26 +0100)
committerDenis Ovsienko <[email protected]>
Mon, 11 Jul 2016 10:56:29 +0000 (11:56 +0100)
This replaces a few explicit type casts with one type cast in the macro
and makes the source code mean one thing with one term instead of two.

print-bgp.c
print-icmp6.c
print-lisp.c
print-lldp.c

index fd25ba84cdbf6e475b40e3614374b2c9bfab9832..bcc3f7152b5754847721538ad2e3679763d61b9f 100644 (file)
@@ -1092,7 +1092,7 @@ decode_prefix6(netdissect_options *ndo,
                addr.s6_addr[plenbytes - 1] &=
                        ((0xff00 >> (plen % 8)) & 0xff);
        }
-       snprintf(buf, buflen, "%s/%d", getname6(ndo, (u_char *)&addr), plen);
+       snprintf(buf, buflen, "%s/%d", ip6addr_string(ndo, &addr), plen);
        return 1 + plenbytes;
 
 trunc:
@@ -1133,7 +1133,7 @@ decode_labeled_prefix6(netdissect_options *ndo,
        }
         /* the label may get offsetted by 4 bits so lets shift it right */
        snprintf(buf, buflen, "%s/%d, label:%u %s",
-                 getname6(ndo, (u_char *)&addr),
+                 ip6addr_string(ndo, &addr),
                  plen,
                  EXTRACT_24BITS(pptr+1)>>4,
                  ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1175,7 +1175,7 @@ decode_labeled_vpn_prefix6(netdissect_options *ndo,
         /* the label may get offsetted by 4 bits so lets shift it right */
        snprintf(buf, buflen, "RD: %s, %s/%d, label:%u %s",
                  bgp_vpn_rd_print(ndo, pptr+4),
-                 getname6(ndo, (u_char *)&addr),
+                 ip6addr_string(ndo, &addr),
                  plen,
                  EXTRACT_24BITS(pptr+1)>>4,
                  ((pptr[3]&1)==0) ? "(BOGUS: Bottom of Stack NOT set!)" : "(bottom)" );
@@ -1599,7 +1599,7 @@ bgp_attr_print(netdissect_options *ndo,
                                 tlen = 0;
                             } else {
                                 ND_TCHECK2(tptr[0], sizeof(struct in6_addr));
-                                ND_PRINT((ndo, "%s", getname6(ndo, tptr)));
+                                ND_PRINT((ndo, "%s", ip6addr_string(ndo, tptr)));
                                 tlen -= sizeof(struct in6_addr);
                                 tptr += sizeof(struct in6_addr);
                             }
@@ -1614,7 +1614,7 @@ bgp_attr_print(netdissect_options *ndo,
                                 ND_TCHECK2(tptr[0], sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
                                 ND_PRINT((ndo, "RD: %s, %s",
                                        bgp_vpn_rd_print(ndo, tptr),
-                                       getname6(ndo, tptr+BGP_VPN_RD_LEN)));
+                                       ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN)));
                                 tlen -= (sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
                                 tptr += (sizeof(struct in6_addr)+BGP_VPN_RD_LEN);
                             }
@@ -1658,7 +1658,7 @@ bgp_attr_print(netdissect_options *ndo,
                                     ND_PRINT((ndo, " = %s", getname(ndo, tptr+BGP_VPN_RD_LEN+4)));
                                 /* rfc1888 mapped IPv6 address ? */
                                 else if (EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) ==  0x350000)
-                                    ND_PRINT((ndo, " = %s", getname6(ndo, tptr+BGP_VPN_RD_LEN+3)));
+                                    ND_PRINT((ndo, " = %s", ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN+3)));
                                 tptr += tlen;
                                 tlen = 0;
                             }
index bc8362eec049c2781571a59d8f1f22ba04db18b6..2db36a6d39e5d436a0018481bf1c88471f44e0d7 100644 (file)
@@ -1088,10 +1088,10 @@ icmp6_print(netdissect_options *ndo,
        case ND_REDIRECT:
 #define RDR(i) ((const struct nd_redirect *)(i))
                          ND_TCHECK(RDR(dp)->nd_rd_dst);
-                         ND_PRINT((ndo,", %s", getname6(ndo, (const u_char *)&RDR(dp)->nd_rd_dst)));
+                         ND_PRINT((ndo,", %s", ip6addr_string(ndo, &RDR(dp)->nd_rd_dst)));
                ND_TCHECK(RDR(dp)->nd_rd_target);
                ND_PRINT((ndo," to %s",
-                          getname6(ndo, (const u_char*)&RDR(dp)->nd_rd_target)));
+                          ip6addr_string(ndo, &RDR(dp)->nd_rd_target)));
 #define REDIRECTLEN 40
                if (ndo->ndo_vflag) {
                        icmp6_opt_print(ndo, (const u_char *)dp + REDIRECTLEN,
@@ -1657,7 +1657,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
                                break;
                        }
                        ND_PRINT((ndo,", subject=%s",
-                                  getname6(ndo, (const u_char *)(ni6 + 1))));
+                                  ip6addr_string(ndo, ni6 + 1)));
                        break;
                case ICMP6_NI_SUBJ_FQDN:
                        ND_PRINT((ndo,", subject=DNS name"));
@@ -1782,7 +1782,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
                        while (i < siz) {
                                if (i + sizeof(struct in6_addr) + sizeof(int32_t) > siz)
                                        break;
-                               ND_PRINT((ndo," %s", getname6(ndo, bp + i)));
+                               ND_PRINT((ndo," %s", ip6addr_string(ndo, bp + i)));
                                i += sizeof(struct in6_addr);
                                ND_PRINT((ndo,"(%d)", (int32_t)EXTRACT_32BITS(bp + i)));
                                i += sizeof(int32_t);
index 757326dcf69e1facfb6401e27f02c6ca2bf5e55d..27cca1a707ad76e2b2b37267959b07778663835a 100644 (file)
@@ -311,7 +311,7 @@ void lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
                        break;
                case IPv6_AFI:
                        ND_TCHECK2(*(packet_iterator + packet_offset), 16);
-                       ND_PRINT((ndo, " EID %s/%u,", getname6(ndo,
+                       ND_PRINT((ndo, " EID %s/%u,", ip6addr_string(ndo,
                                packet_iterator + packet_offset), mask_len));
                        packet_offset += 16;
                        break;
@@ -343,7 +343,7 @@ void lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
                                break;
                        case IPv6_AFI:
                                ND_TCHECK2(*(packet_iterator + packet_offset), 16);
-                               ND_PRINT((ndo, " LOC %s", getname6(ndo, loc_ip_pointer)));
+                               ND_PRINT((ndo, " LOC %s", ip6addr_string(ndo, loc_ip_pointer)));
                                packet_offset += 16;
                                break;
                        default:
index 82b7ebec1508e2cf727151c70bf732e1725feae9..458cf95791bef635d4203e128575bd7a95547dea 100644 (file)
@@ -1283,6 +1283,7 @@ lldp_network_addr_print(netdissect_options *ndo, const u_char *tptr, u_int len)
     case AFNUM_INET6:
         if (len < 16)
           return NULL;
+        /* This cannot be assigned to ip6addr_string(), which is a macro. */
         pfunc = getname6;
         break;
     case AFNUM_802: