]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-udp.c
Fix the pointer tests in the non-ndoified TTEST2() macro as well.
[tcpdump] / print-udp.c
index 828cf8259d3e541a66c2a73e53da702a5b06b897..f3da50c9896b9f311ad19f5a79b56f23eef40e2e 100644 (file)
 #include "bootp.h"
 
 struct rtcphdr {
-       u_int16_t rh_flags;     /* T:2 P:1 CNT:5 PT:8 */
-       u_int16_t rh_len;       /* length of message (in words) */
-       u_int32_t rh_ssrc;      /* synchronization src id */
+       uint16_t rh_flags;      /* T:2 P:1 CNT:5 PT:8 */
+       uint16_t rh_len;        /* length of message (in words) */
+       uint32_t rh_ssrc;       /* synchronization src id */
 };
 
 typedef struct {
-       u_int32_t upper;        /* more significant 32 bits */
-       u_int32_t lower;        /* less significant 32 bits */
+       uint32_t upper; /* more significant 32 bits */
+       uint32_t lower; /* less significant 32 bits */
 } ntp64;
 
 /*
@@ -61,9 +61,9 @@ typedef struct {
  */
 struct rtcp_sr {
        ntp64 sr_ntp;           /* 64-bit ntp timestamp */
-       u_int32_t sr_ts;        /* reference media timestamp */
-       u_int32_t sr_np;        /* no. packets sent */
-       u_int32_t sr_nb;        /* no. bytes sent */
+       uint32_t sr_ts; /* reference media timestamp */
+       uint32_t sr_np; /* no. packets sent */
+       uint32_t sr_nb; /* no. bytes sent */
 };
 
 /*
@@ -71,12 +71,12 @@ struct rtcp_sr {
  * Time stamps are middle 32-bits of ntp timestamp.
  */
 struct rtcp_rr {
-       u_int32_t rr_srcid;     /* sender being reported */
-       u_int32_t rr_nl;        /* no. packets lost */
-       u_int32_t rr_ls;        /* extended last seq number received */
-       u_int32_t rr_dv;        /* jitter (delay variance) */
-       u_int32_t rr_lsr;       /* orig. ts from last rr from this src  */
-       u_int32_t rr_dlsr;      /* time from recpt of last rr to xmit time */
+       uint32_t rr_srcid;      /* sender being reported */
+       uint32_t rr_nl; /* no. packets lost */
+       uint32_t rr_ls; /* extended last seq number received */
+       uint32_t rr_dv; /* jitter (delay variance) */
+       uint32_t rr_lsr;        /* orig. ts from last rr from this src  */
+       uint32_t rr_dlsr;       /* time from recpt of last rr to xmit time */
 };
 
 /*XXX*/
@@ -98,18 +98,18 @@ static void
 vat_print(netdissect_options *ndo, const void *hdr, register const struct udphdr *up)
 {
        /* vat/vt audio */
-       u_int ts = *(u_int16_t *)hdr;
+       u_int ts = *(uint16_t *)hdr;
        if ((ts & 0xf060) != 0) {
                /* probably vt */
                ND_PRINT((ndo, "udp/vt %u %d / %d",
-                            (u_int32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up)),
+                            (uint32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up)),
                             ts & 0x3ff, ts >> 10));
        } else {
                /* probably vat */
-               u_int32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
-               u_int32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
+               uint32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
+               uint32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
                ND_PRINT((ndo, "udp/vat %u c%d %u%s",
-                       (u_int32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8),
+                       (uint32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8),
                        i0 & 0xffff,
                        i1, i0 & 0x800000? "*" : ""));
                /* audio format */
@@ -127,8 +127,8 @@ rtp_print(netdissect_options *ndo, const void *hdr, u_int len,
        /* rtp v1 or v2 */
        u_int *ip = (u_int *)hdr;
        u_int hasopt, hasext, contype, hasmarker;
-       u_int32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
-       u_int32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
+       uint32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]);
+       uint32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]);
        u_int dlen = EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8;
        const char * ptype;
 
@@ -199,7 +199,7 @@ rtcp_print(netdissect_options *ndo, const u_char *hdr, const u_char *ep)
        struct rtcp_sr *sr;
        struct rtcphdr *rh = (struct rtcphdr *)hdr;
        u_int len;
-       u_int16_t flags;
+       uint16_t flags;
        int cnt;
        double ts, dts;
        if ((u_char *)(rh + 1) > ep) {
@@ -272,11 +272,11 @@ rtcp_print(netdissect_options *ndo, const u_char *hdr, const u_char *ep)
        return (hdr + len);
 }
 
-static int udp_cksum(register const struct ip *ip,
+static int udp_cksum(netdissect_options *ndo, register const struct ip *ip,
                     register const struct udphdr *up,
                     register u_int len)
 {
-       return nextproto4_cksum(ip, (const u_int8_t *)(void *)up, len, len,
+       return nextproto4_cksum(ndo, ip, (const uint8_t *)(void *)up, len, len,
                                IPPROTO_UDP);
 }
 
@@ -284,7 +284,7 @@ static int udp_cksum(register const struct ip *ip,
 static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
        u_int len)
 {
-       return nextproto6_cksum(ip6, (const u_int8_t *)(void *)up, len, len,
+       return nextproto6_cksum(ip6, (const uint8_t *)(void *)up, len, len,
            IPPROTO_UDP);
 }
 #endif
@@ -304,13 +304,13 @@ udpipaddr_print(netdissect_options *ndo, const struct ip *ip, int sport, int dpo
                if (ip6->ip6_nxt == IPPROTO_UDP) {
                        if (sport == -1) {
                                ND_PRINT((ndo, "%s > %s: ",
-                                       ip6addr_string(&ip6->ip6_src),
-                                       ip6addr_string(&ip6->ip6_dst)));
+                                       ip6addr_string(ndo, &ip6->ip6_src),
+                                       ip6addr_string(ndo, &ip6->ip6_dst)));
                        } else {
                                ND_PRINT((ndo, "%s.%s > %s.%s: ",
-                                       ip6addr_string(&ip6->ip6_src),
+                                       ip6addr_string(ndo, &ip6->ip6_src),
                                        udpport_string(sport),
-                                       ip6addr_string(&ip6->ip6_dst),
+                                       ip6addr_string(ndo, &ip6->ip6_dst),
                                        udpport_string(dport)));
                        }
                } else {
@@ -326,13 +326,13 @@ udpipaddr_print(netdissect_options *ndo, const struct ip *ip, int sport, int dpo
                if (ip->ip_p == IPPROTO_UDP) {
                        if (sport == -1) {
                                ND_PRINT((ndo, "%s > %s: ",
-                                       ipaddr_string(&ip->ip_src),
-                                       ipaddr_string(&ip->ip_dst)));
+                                       ipaddr_string(ndo, &ip->ip_src),
+                                       ipaddr_string(ndo, &ip->ip_dst)));
                        } else {
                                ND_PRINT((ndo, "%s.%s > %s.%s: ",
-                                       ipaddr_string(&ip->ip_src),
+                                       ipaddr_string(ndo, &ip->ip_src),
                                        udpport_string(sport),
-                                       ipaddr_string(&ip->ip_dst),
+                                       ipaddr_string(ndo, &ip->ip_dst),
                                        udpport_string(dport)));
                        }
                } else {
@@ -353,7 +353,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
        register const struct ip *ip;
        register const u_char *cp;
        register const u_char *ep = bp + length;
-       u_int16_t sport, dport, ulen;
+       uint16_t sport, dport, ulen;
 #ifdef INET6
        register const struct ip6_hdr *ip6;
 #endif
@@ -420,7 +420,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                                sunrpcrequest_print(ndo, (u_char *)rp, length,
                                    (u_char *)ip);
                        else
-                               nfsreply_print((u_char *)rp, length,
+                               nfsreply_print(ndo, (u_char *)rp, length,
                                    (u_char *)ip);                      /*XXX*/
                        break;
 
@@ -437,22 +437,22 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
 
                case PT_SNMP:
                        udpipaddr_print(ndo, ip, sport, dport);
-                       snmp_print((const u_char *)(up + 1), length);
+                       snmp_print(ndo, (const u_char *)(up + 1), length);
                        break;
 
                case PT_CNFP:
                        udpipaddr_print(ndo, ip, sport, dport);
-                       cnfp_print(cp, (const u_char *)ip);
+                       cnfp_print(ndo, cp, (const u_char *)ip);
                        break;
 
                case PT_TFTP:
                        udpipaddr_print(ndo, ip, sport, dport);
-                       tftp_print(cp, length);
+                       tftp_print(ndo, cp, length);
                        break;
 
                case PT_AODV:
                        udpipaddr_print(ndo, ip, sport, dport);
-                       aodv_print((const u_char *)(up + 1), length,
+                       aodv_print(ndo, (const u_char *)(up + 1), length,
 #ifdef INET6
                            ip6 != NULL);
 #else
@@ -493,13 +493,13 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                        direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
                        if (dport == NFS_PORT && direction == SUNRPC_CALL) {
                                ND_PRINT((ndo, "NFS request xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
-                               nfsreq_print_noaddr((u_char *)rp, length,
+                               nfsreq_print_noaddr(ndo, (u_char *)rp, length,
                                    (u_char *)ip);
                                return;
                        }
                        if (sport == NFS_PORT && direction == SUNRPC_REPLY) {
                                ND_PRINT((ndo, "NFS reply xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
-                               nfsreply_print_noaddr((u_char *)rp, length,
+                               nfsreply_print_noaddr(ndo, (u_char *)rp, length,
                                    (u_char *)ip);
                                return;
                        }
@@ -515,14 +515,14 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                    (atalk_port(sport) || atalk_port(dport))) {
                        if (ndo->ndo_vflag)
                                ND_PRINT((ndo, "kip "));
-                       llap_print(cp, length);
+                       llap_print(ndo, cp, length);
                        return;
                }
        }
 
        if (ndo->ndo_vflag && !ndo->ndo_Kflag && !fragmented) {
                 /* Check the checksum, if possible. */
-                u_int16_t sum, udp_sum;
+                uint16_t sum, udp_sum;
 
                /*
                 * XXX - do this even if vflag == 1?
@@ -533,7 +533,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                        if (udp_sum == 0) {
                                ND_PRINT((ndo, "[no cksum] "));
                        } else if (ND_TTEST2(cp[0], length)) {
-                               sum = udp_cksum(ip, up, length + sizeof(struct udphdr));
+                               sum = udp_cksum(ndo, ip, up, length + sizeof(struct udphdr));
 
                                if (sum != 0) {
                                        ND_PRINT((ndo, "[bad udp cksum 0x%04x -> 0x%04x!] ",
@@ -564,19 +564,19 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
        if (!ndo->ndo_qflag) {
 #define ISPORT(p) (dport == (p) || sport == (p))
                if (ISPORT(NAMESERVER_PORT))
-                       ns_print((const u_char *)(up + 1), length, 0);
+                       ns_print(ndo, (const u_char *)(up + 1), length, 0);
                else if (ISPORT(MULTICASTDNS_PORT))
-                       ns_print((const u_char *)(up + 1), length, 1);
+                       ns_print(ndo, (const u_char *)(up + 1), length, 1);
                else if (ISPORT(TIMED_PORT))
-                       timed_print((const u_char *)(up + 1));
+                       timed_print(ndo, (const u_char *)(up + 1));
                else if (ISPORT(TFTP_PORT))
-                       tftp_print((const u_char *)(up + 1), length);
+                       tftp_print(ndo, (const u_char *)(up + 1), length);
                else if (ISPORT(IPPORT_BOOTPC) || ISPORT(IPPORT_BOOTPS))
-                       bootp_print((const u_char *)(up + 1), length);
+                       bootp_print(ndo, (const u_char *)(up + 1), length);
                else if (ISPORT(RIP_PORT))
                        rip_print(ndo, (const u_char *)(up + 1), length);
                else if (ISPORT(AODV_PORT))
-                       aodv_print((const u_char *)(up + 1), length,
+                       aodv_print(ndo, (const u_char *)(up + 1), length,
 #ifdef INET6
                            ip6 != NULL);
 #else
@@ -591,18 +591,18 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                        isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
 #endif
                else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT))
-                       snmp_print((const u_char *)(up + 1), length);
+                       snmp_print(ndo, (const u_char *)(up + 1), length);
                else if (ISPORT(NTP_PORT))
                        ntp_print(ndo, (const u_char *)(up + 1), length);
                else if (ISPORT(KERBEROS_PORT) || ISPORT(KERBEROS_SEC_PORT))
-                       krb_print((const void *)(up + 1));
+                       krb_print(ndo, (const void *)(up + 1));
                else if (ISPORT(L2TP_PORT))
                        l2tp_print(ndo, (const u_char *)(up + 1), length);
 #ifdef TCPDUMP_DO_SMB
                else if (ISPORT(NETBIOS_NS_PORT))
-                       nbt_udp137_print((const u_char *)(up + 1), length);
+                       nbt_udp137_print(ndo, (const u_char *)(up + 1), length);
                else if (ISPORT(NETBIOS_DGRAM_PORT))
-                       nbt_udp138_print((const u_char *)(up + 1), length);
+                       nbt_udp138_print(ndo, (const u_char *)(up + 1), length);
 #endif
                else if (dport == VAT_PORT)
                        vat_print(ndo, (const void *)(up + 1), up);
@@ -614,17 +614,17 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                 */
                else if ((sport >= RX_PORT_LOW && sport <= RX_PORT_HIGH) ||
                         (dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
-                       rx_print((const void *)(up + 1), length, sport, dport,
+                       rx_print(ndo, (const void *)(up + 1), length, sport, dport,
                                 (u_char *) ip);
 #ifdef INET6
                else if (ISPORT(RIPNG_PORT))
                        ripng_print(ndo, (const u_char *)(up + 1), length);
                else if (ISPORT(DHCP6_SERV_PORT) || ISPORT(DHCP6_CLI_PORT))
-                       dhcp6_print((const u_char *)(up + 1), length);
+                       dhcp6_print(ndo, (const u_char *)(up + 1), length);
                else if (ISPORT(AHCP_PORT))
                        ahcp_print(ndo, (const u_char *)(up + 1), length);
                else if (ISPORT(BABEL_PORT) || ISPORT(BABEL_PORT_OLD))
-                       babel_print((const u_char *)(up + 1), length);
+                       babel_print(ndo, (const u_char *)(up + 1), length);
 #endif /*INET6*/
                /*
                 * Kludge in test for whiteboard packets.
@@ -632,7 +632,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                else if (dport == WB_PORT)
                        wb_print(ndo, (const void *)(up + 1), length);
                else if (ISPORT(CISCO_AUTORP_PORT))
-                       cisco_autorp_print((const void *)(up + 1), length);
+                       cisco_autorp_print(ndo, (const void *)(up + 1), length);
                else if (ISPORT(RADIUS_PORT) ||
                         ISPORT(RADIUS_NEW_PORT) ||
                         ISPORT(RADIUS_ACCOUNTING_PORT) ||
@@ -641,18 +641,18 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                else if (dport == HSRP_PORT)
                        hsrp_print(ndo, (const u_char *)(up + 1), length);
                else if (ISPORT(LWRES_PORT))
-                       lwres_print((const u_char *)(up + 1), length);
+                       lwres_print(ndo, (const u_char *)(up + 1), length);
                else if (ISPORT(LDP_PORT))
                        ldp_print(ndo, (const u_char *)(up + 1), length);
                else if (ISPORT(OLSR_PORT))
-                       olsr_print((const u_char *)(up + 1), length,
+                       olsr_print(ndo, (const u_char *)(up + 1), length,
 #if INET6
                                        (IP_V(ip) == 6) ? 1 : 0);
 #else
                                        0);
 #endif
                else if (ISPORT(MPLS_LSP_PING_PORT))
-                       lspping_print((const u_char *)(up + 1), length);
+                       lspping_print(ndo, (const u_char *)(up + 1), length);
                else if (dport == BFD_CONTROL_PORT ||
                         dport == BFD_ECHO_PORT )
                        bfd_print(ndo, (const u_char *)(up+1), length, dport);
@@ -661,7 +661,7 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                else if (ISPORT(VQP_PORT))
                        vqp_print(ndo, (const u_char *)(up + 1), length);
                 else if (ISPORT(SFLOW_PORT))
-                        sflow_print((const u_char *)(up + 1), length);
+                        sflow_print(ndo, (const u_char *)(up + 1), length);
                else if (dport == LWAPP_CONTROL_PORT)
                        lwapp_control_print(ndo, (const u_char *)(up + 1), length, 1);
                 else if (sport == LWAPP_CONTROL_PORT)
@@ -669,19 +669,19 @@ udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
                 else if (ISPORT(LWAPP_DATA_PORT))
                         lwapp_data_print(ndo, (const u_char *)(up + 1), length);
                 else if (ISPORT(SIP_PORT))
-                       sip_print((const u_char *)(up + 1), length);
+                       sip_print(ndo, (const u_char *)(up + 1), length);
                 else if (ISPORT(SYSLOG_PORT))
-                       syslog_print((const u_char *)(up + 1), length);
+                       syslog_print(ndo, (const u_char *)(up + 1), length);
                 else if (ISPORT(OTV_PORT))
                        otv_print(ndo, (const u_char *)(up + 1), length);
                 else if (ISPORT(VXLAN_PORT))
                        vxlan_print(ndo, (const u_char *)(up + 1), length);
                else
                        ND_PRINT((ndo, "UDP, length %u",
-                           (u_int32_t)(ulen - sizeof(*up))));
+                           (uint32_t)(ulen - sizeof(*up))));
 #undef ISPORT
        } else
-               ND_PRINT((ndo, "UDP, length %u", (u_int32_t)(ulen - sizeof(*up))));
+               ND_PRINT((ndo, "UDP, length %u", (uint32_t)(ulen - sizeof(*up))));
 }