]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-udp.c
Fixed some warnings, added print-zep.c to CMakeLists
[tcpdump] / print-udp.c
index 8c558cf5921592b08c0ddae7e84f6adc1f178c20..906dc0d2671581272688a5b365aca75bddfa3c50 100644 (file)
 
 #include "nfs.h"
 
-static const char vat_tstr[] = " [|vat]";
-static const char rtp_tstr[] = " [|rtp]";
-static const char rtcp_tstr[] = " [|rtcp]";
-static const char udp_tstr[] = " [|udp]";
 
 struct rtcphdr {
        nd_uint16_t rh_flags;   /* T:2 P:1 CNT:5 PT:8 */
@@ -102,6 +98,7 @@ vat_print(netdissect_options *ndo, const void *hdr, u_int length)
        /* vat/vt audio */
        u_int ts;
 
+       ndo->ndo_protocol = "vat";
        if (length < 2) {
                ND_PRINT("udp/va/vat, length %u < 2", length);
                return;
@@ -135,9 +132,10 @@ vat_print(netdissect_options *ndo, const void *hdr, u_int length)
                if (i0 & 0x3f000000)
                        ND_PRINT(" s%u", (i0 >> 24) & 0x3f);
        }
+       return;
 
 trunc:
-       ND_PRINT("%s", vat_tstr);
+       nd_print_trunc(ndo);
 }
 
 static void
@@ -149,6 +147,7 @@ rtp_print(netdissect_options *ndo, const void *hdr, u_int len)
        uint32_t i0, i1;
        const char * ptype;
 
+       ndo->ndo_protocol = "rtp";
        if (len < 8) {
                ND_PRINT("udp/rtp, length %u < 8", len);
                return;
@@ -223,9 +222,10 @@ rtp_print(netdissect_options *ndo, const void *hdr, u_int len)
                if (contype == 0x1f) /*XXX H.261 */
                        ND_PRINT(" 0x%04x", EXTRACT_BE_U_4(ip) >> 16);
        }
+       return;
 
 trunc:
-       ND_PRINT("%s", rtp_tstr);
+       nd_print_trunc(ndo);
 }
 
 static const u_char *
@@ -239,6 +239,8 @@ rtcp_print(netdissect_options *ndo, const u_char *hdr, const u_char *ep)
        uint16_t flags;
        u_int cnt;
        double ts, dts;
+
+       ndo->ndo_protocol = "rtcp";
        if ((const u_char *)(rh + 1) > ep)
                goto trunc;
        ND_TCHECK_SIZE(rh);
@@ -307,7 +309,7 @@ rtcp_print(netdissect_options *ndo, const u_char *hdr, const u_char *ep)
        return (hdr + len);
 
 trunc:
-       ND_PRINT("%s", rtcp_tstr);
+       nd_print_trunc(ndo);
        return ep;
 }
 
@@ -390,6 +392,7 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
        uint16_t sport, dport, ulen;
        const struct ip6_hdr *ip6;
 
+       ndo->ndo_protocol = "udp";
        up = (const struct udphdr *)bp;
        ip = (const struct ip *)bp2;
        if (IP_V(ip) == 6)
@@ -448,6 +451,7 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
 
                case PT_RPC:
                        rp = (const struct sunrpc_msg *)(up + 1);
+                       ND_TCHECK_4(rp->rm_direction);
                        direction = (enum sunrpc_msg_type) EXTRACT_BE_U_4(rp->rm_direction);
                        if (direction == SUNRPC_CALL)
                                sunrpc_print(ndo, (const u_char *)rp, length,
@@ -552,6 +556,7 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
                 * TCP does, and we do so for UDP-over-IPv6.
                 */
                if (IP_V(ip) == 4 && (ndo->ndo_vflag > 1)) {
+                       ND_TCHECK_2(up->uh_sum);
                        udp_sum = EXTRACT_BE_U_2(up->uh_sum);
                        if (udp_sum == 0) {
                                ND_PRINT("[no cksum] ");
@@ -570,6 +575,7 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
                        /* for IPv6, UDP checksum is mandatory */
                        if (ND_TTEST_LEN(cp, length)) {
                                sum = udp6_cksum(ndo, ip6, up, length + sizeof(struct udphdr));
+                               ND_TCHECK_2(up->uh_sum);
                                udp_sum = EXTRACT_BE_U_2(up->uh_sum);
 
                                if (sum != 0) {
@@ -609,7 +615,7 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
                else if (IS_SRC_OR_DST_PORT(NTP_PORT))
                        ntp_print(ndo, (const u_char *)(up + 1), length);
                else if (IS_SRC_OR_DST_PORT(KERBEROS_PORT) || IS_SRC_OR_DST_PORT(KERBEROS_SEC_PORT))
-                       krb_print(ndo, (const void *)(up + 1));
+                       krb_print(ndo, (const u_char *)(up + 1));
                else if (IS_SRC_OR_DST_PORT(L2TP_PORT))
                        l2tp_print(ndo, (const u_char *)(up + 1), length);
 #ifdef ENABLE_SMB
@@ -621,14 +627,14 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
                else if (dport == VAT_PORT)
                        vat_print(ndo, (const void *)(up + 1), length);
                else if (IS_SRC_OR_DST_PORT(ZEPHYR_SRV_PORT) || IS_SRC_OR_DST_PORT(ZEPHYR_CLT_PORT))
-                       zephyr_print(ndo, (const void *)(up + 1), length);
+                       zephyr_print(ndo, (const u_char *)(up + 1), length);
                /*
                 * Since there are 10 possible ports to check, I think
                 * a <> test would be more efficient
                 */
                else if ((sport >= RX_PORT_LOW && sport <= RX_PORT_HIGH) ||
                         (dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
-                       rx_print(ndo, (const void *)(up + 1), length, sport, dport,
+                       rx_print(ndo, (const u_char *)(up + 1), length, sport, dport,
                                 (const u_char *) ip);
                else if (IS_SRC_OR_DST_PORT(RIPNG_PORT))
                        ripng_print(ndo, (const u_char *)(up + 1), length);
@@ -646,7 +652,7 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
                else if (dport == WB_PORT)
                        wb_print(ndo, (const u_char *)(up + 1), length);
                else if (IS_SRC_OR_DST_PORT(CISCO_AUTORP_PORT))
-                       cisco_autorp_print(ndo, (const void *)(up + 1), length);
+                       cisco_autorp_print(ndo, (const u_char *)(up + 1), length);
                else if (IS_SRC_OR_DST_PORT(RADIUS_PORT) ||
                         IS_SRC_OR_DST_PORT(RADIUS_NEW_PORT) ||
                         IS_SRC_OR_DST_PORT(RADIUS_ACCOUNTING_PORT) ||
@@ -694,6 +700,8 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
                        lisp_print(ndo, (const u_char *)(up + 1), length);
                else if (IS_SRC_OR_DST_PORT(VXLAN_GPE_PORT))
                        vxlan_gpe_print(ndo, (const u_char *)(up + 1), length);
+               else if (IS_SRC_OR_DST_PORT(ZEP_PORT))
+                       zep_print(ndo, (const u_char *)(up + 1), length);
                else if (ND_TTEST_1(((const struct LAP *)cp)->type) &&
                         EXTRACT_U_1(((const struct LAP *)cp)->type) == lapDDP &&
                         (atalk_port(sport) || atalk_port(dport))) {
@@ -717,13 +725,5 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
        return;
 
 trunc:
-       ND_PRINT("%s", udp_tstr);
+       nd_print_trunc(ndo);
 }
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */