]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-chdlc.c
Avoid collison with error(), clean up code a bit.
[tcpdump] / print-chdlc.c
index c2bb24c699dda290dd924ba213e8e88896b20c90..766ae3810c306148a1e10d8e7aeff08396fb9a09 100644 (file)
@@ -19,7 +19,6 @@
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#define NETDISSECT_REWORKED
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -56,7 +55,8 @@ chdlc_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, register co
 }
 
 u_int
-chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length) {
+chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length)
+{
        u_int proto;
 
        proto = EXTRACT_16BITS(&p[2]);
@@ -75,11 +75,9 @@ chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length) {
        case ETHERTYPE_IP:
                ip_print(ndo, p, length);
                break;
-#ifdef INET6
        case ETHERTYPE_IPV6:
                ip6_print(ndo, p, length);
                break;
-#endif
        case CHDLC_TYPE_SLARP:
                chdlc_slarp_print(ndo, p, length);
                break;
@@ -97,9 +95,9 @@ chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length) {
                 if (*(p+1) == 0x81 ||
                     *(p+1) == 0x82 ||
                     *(p+1) == 0x83)
-                    isoclns_print(p+1, length-1, length-1);
+                    isoclns_print(ndo, p + 1, length - 1, length - 1);
                 else
-                    isoclns_print(p, length, length);
+                    isoclns_print(ndo, p, length, length);
                 break;
        default:
                 if (!ndo->ndo_eflag)
@@ -114,19 +112,19 @@ chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length) {
  * The fixed-length portion of a SLARP packet.
  */
 struct cisco_slarp {
-       u_int8_t code[4];
+       uint8_t code[4];
 #define SLARP_REQUEST  0
 #define SLARP_REPLY    1
 #define SLARP_KEEPALIVE        2
        union {
                struct {
-                       u_int8_t addr[4];
-                       u_int8_t mask[4];
+                       uint8_t addr[4];
+                       uint8_t mask[4];
                } addr;
                struct {
-                       u_int8_t myseq[4];
-                       u_int8_t yourseq[4];
-                       u_int8_t rel[2];
+                       uint8_t myseq[4];
+                       uint8_t yourseq[4];
+                       uint8_t rel[2];
                } keep;
        } un;
 };
@@ -161,8 +159,8 @@ chdlc_slarp_print(netdissect_options *ndo, const u_char *cp, u_int length)
                break;
        case SLARP_REPLY:
                ND_PRINT((ndo, "reply %s/%s",
-                       ipaddr_string(&slarp->un.addr.addr),
-                       ipaddr_string(&slarp->un.addr.mask)));
+                       ipaddr_string(ndo, &slarp->un.addr.addr),
+                       ipaddr_string(ndo, &slarp->un.addr.mask)));
                break;
        case SLARP_KEEPALIVE:
                ND_PRINT((ndo, "keepalive: mineseen=0x%08x, yourseen=0x%08x, reliability=0x%04x",
@@ -172,8 +170,7 @@ chdlc_slarp_print(netdissect_options *ndo, const u_char *cp, u_int length)
 
                 if (length >= SLARP_MAX_LEN) { /* uptime-stamp is optional */
                         cp += SLARP_MIN_LEN;
-                        if (!ND_TTEST2(*cp, 4))
-                                goto trunc;
+                        ND_TCHECK2(*cp, 4);
                         sec = EXTRACT_32BITS(cp) / 1000;
                         min = sec / 60; sec -= min * 60;
                         hrs = min / 60; min -= hrs * 60;