]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-udp.c
UDP: Add two missing return
[tcpdump] / print-udp.c
index 44933f6bb073c93a80f3ae2809678e05adcc84ae..47838307f4c57a9fb060e33716d7722e50214f5b 100644 (file)
@@ -22,7 +22,7 @@
 /* \summary: UDP printer */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
 #include "netdissect-stdinc.h"
 
 #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;
 }
 
@@ -340,13 +342,13 @@ udpipaddr_print(netdissect_options *ndo, const struct ip *ip, int sport, int dpo
                if (EXTRACT_U_1(ip6->ip6_nxt) == IPPROTO_UDP) {
                        if (sport == -1) {
                                ND_PRINT("%s > %s: ",
-                                       ip6addr_string(ndo, &ip6->ip6_src),
-                                       ip6addr_string(ndo, &ip6->ip6_dst));
+                                       ip6addr_string(ndo, ip6->ip6_src),
+                                       ip6addr_string(ndo, ip6->ip6_dst));
                        } else {
                                ND_PRINT("%s.%s > %s.%s: ",
-                                       ip6addr_string(ndo, &ip6->ip6_src),
+                                       ip6addr_string(ndo, ip6->ip6_src),
                                        udpport_string(ndo, sport),
-                                       ip6addr_string(ndo, &ip6->ip6_dst),
+                                       ip6addr_string(ndo, ip6->ip6_dst),
                                        udpport_string(ndo, dport));
                        }
                } else {
@@ -360,13 +362,13 @@ udpipaddr_print(netdissect_options *ndo, const struct ip *ip, int sport, int dpo
                if (EXTRACT_U_1(ip->ip_p) == IPPROTO_UDP) {
                        if (sport == -1) {
                                ND_PRINT("%s > %s: ",
-                                       ipaddr_string(ndo, &ip->ip_src),
-                                       ipaddr_string(ndo, &ip->ip_dst));
+                                       ipaddr_string(ndo, ip->ip_src),
+                                       ipaddr_string(ndo, ip->ip_dst));
                        } else {
                                ND_PRINT("%s.%s > %s.%s: ",
-                                       ipaddr_string(ndo, &ip->ip_src),
+                                       ipaddr_string(ndo, ip->ip_src),
                                        udpport_string(ndo, sport),
-                                       ipaddr_string(ndo, &ip->ip_dst),
+                                       ipaddr_string(ndo, ip->ip_dst),
                                        udpport_string(ndo, dport));
                        }
                } else {
@@ -386,12 +388,11 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
        const struct udphdr *up;
        const struct ip *ip;
        const u_char *cp;
-       const u_char *ep = bp + length;
+       const u_char *ep = ndo->ndo_snapend;
        uint16_t sport, dport, ulen;
        const struct ip6_hdr *ip6;
 
-       if (ep > ndo->ndo_snapend)
-               ep = ndo->ndo_snapend;
+       ndo->ndo_protocol = "udp";
        up = (const struct udphdr *)bp;
        ip = (const struct ip *)bp2;
        if (IP_V(ip) == 6)
@@ -719,13 +720,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:
- */