]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-udp.c
switch from shell script to complex test
[tcpdump] / print-udp.c
index 231d8b4fdc92e7ac694447b14ab43a1a6a0d74b7..8c05217435a63a28228d32bcaf93a3af34e3d7c4 100644 (file)
@@ -389,7 +389,8 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
        const struct ip *ip;
        const u_char *cp;
        const u_char *ep = ndo->ndo_snapend;
-       uint16_t sport, dport, ulen;
+       uint16_t sport, dport;
+       u_int ulen;
        const struct ip6_hdr *ip6;
 
        ndo->ndo_protocol = "udp";
@@ -417,6 +418,13 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
                goto trunc;
        }
        ulen = GET_BE_U_2(up->uh_ulen);
+       /*
+        * IPv6 Jumbo Datagrams; see RFC 2675.
+        * If the length is zero, and the length provided to us is
+        * > 65535, use the provided length as the length.
+        */
+       if (ulen == 0 && length > 65535)
+               ulen = length;
        if (ulen < sizeof(struct udphdr)) {
                udpipaddr_print(ndo, ip, sport, dport);
                ND_PRINT("truncated-udplength %u", ulen);
@@ -512,6 +520,10 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
                        udpipaddr_print(ndo, ip, sport, dport);
                        lmp_print(ndo, cp, length);
                        break;
+               case PT_PTP:
+                       udpipaddr_print(ndo, ip, sport, dport);
+                       ptp_print(ndo, cp, length);
+                       break;
                }
                return;
        }
@@ -571,7 +583,7 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
                                        ND_PRINT("[udp sum ok] ");
                        }
                }
-               else if (IP_V(ip) == 6 && ip6->ip6_plen) {
+               else if (IP_V(ip) == 6) {
                        /* for IPv6, UDP checksum is mandatory */
                        if (ND_TTEST_LEN(cp, length)) {
                                sum = udp6_cksum(ndo, ip6, up, length + sizeof(struct udphdr));
@@ -710,7 +722,10 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
                        if (ndo->ndo_vflag)
                                ND_PRINT("kip ");
                        llap_print(ndo, cp, length);
-               } else {
+                } else if (IS_SRC_OR_DST_PORT(PTP_EVENT_PORT) ||
+                        IS_SRC_OR_DST_PORT(PTP_GENERAL_PORT)) {
+                        ptp_print(ndo, cp, length);
+                } else {
                        if (ulen > length)
                                ND_PRINT("UDP, bad length %u > %u",
                                    ulen, length);