]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ppp.c
Fix spaces
[tcpdump] / print-ppp.c
index 83f0066b0a6883625985ccf9d8878b662a95ba2e..86581ce05e231848af9623e28f89af91dd72747f 100644 (file)
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif
 
-#include <netdissect-stdinc.h>
+#include "netdissect-stdinc.h"
 
 #ifdef __bsdi__
 #include <net/slcompress.h>
 #include "chdlc.h"
 #include "ethertype.h"
 #include "oui.h"
+#include "netdissect-alloc.h"
 
 /*
- * The following constatns are defined by IANA. Please refer to
+ * The following constants are defined by IANA. Please refer to
  *    http://www.isi.edu/in-notes/iana/assignments/ppp-numbers
  * for the up-to-date information.
  */
@@ -213,7 +214,7 @@ static const char *lcpconfopts[] = {
        "PPP-Muxing",           /* (30) */
 };
 
-#define NUM_LCPOPTS    (sizeof lcpconfopts / sizeof lcpconfopts[0])
+#define NUM_LCPOPTS    (sizeof(lcpconfopts) / sizeof(lcpconfopts[0]))
 
 /* ECP - to be supported */
 
@@ -561,7 +562,7 @@ handle_ctrl_proto(netdissect_options *ndo,
                /* RFC 1661 says this is intended to be human readable */
                if (len > 8) {
                        ND_PRINT("\n\t  Message\n\t    ");
-                       if (fn_printn(ndo, tptr + 4, len - 4, ndo->ndo_snapend))
+                       if (nd_printn(ndo, tptr + 4, len - 4, ndo->ndo_snapend))
                                goto trunc;
                }
                break;
@@ -900,7 +901,7 @@ handle_chap(netdissect_options *ndo,
                ND_PRINT(", Name ");
                for (i = 0; i < name_size; i++) {
                        ND_TCHECK_1(p);
-                       safeputchar(ndo, EXTRACT_U_1(p));
+                       fn_print_char(ndo, EXTRACT_U_1(p));
                        p++;
                }
                break;
@@ -910,7 +911,7 @@ handle_chap(netdissect_options *ndo,
                ND_PRINT(", Msg ");
                for (i = 0; i< msg_size; i++) {
                        ND_TCHECK_1(p);
-                       safeputchar(ndo, EXTRACT_U_1(p));
+                       fn_print_char(ndo, EXTRACT_U_1(p));
                        p++;
                }
                break;
@@ -981,7 +982,7 @@ handle_pap(netdissect_options *ndo,
                ND_PRINT(", Peer ");
                for (i = 0; i < peerid_len; i++) {
                        ND_TCHECK_1(p);
-                       safeputchar(ndo, EXTRACT_U_1(p));
+                       fn_print_char(ndo, EXTRACT_U_1(p));
                        p++;
                }
 
@@ -995,7 +996,7 @@ handle_pap(netdissect_options *ndo,
                ND_PRINT(", Name ");
                for (i = 0; i < passwd_len; i++) {
                        ND_TCHECK_1(p);
-                       safeputchar(ndo, EXTRACT_U_1(p));
+                       fn_print_char(ndo, EXTRACT_U_1(p));
                        p++;
                }
                break;
@@ -1018,7 +1019,7 @@ handle_pap(netdissect_options *ndo,
                ND_PRINT(", Msg ");
                for (i = 0; i< msg_len; i++) {
                        ND_TCHECK_1(p);
-                       safeputchar(ndo, EXTRACT_U_1(p));
+                       fn_print_char(ndo, EXTRACT_U_1(p));
                        p++;
                }
                break;
@@ -1401,7 +1402,7 @@ ppp_hdlc(netdissect_options *ndo,
         if (length == 0)
                 return;
 
-       b = (u_char *)malloc(length);
+       b = (u_char *)nd_malloc(ndo, length);
        if (b == NULL)
                return;
 
@@ -1464,13 +1465,11 @@ ppp_hdlc(netdissect_options *ndo,
 
 cleanup:
        ndo->ndo_snapend = se;
-       free(b);
         return;
 
 trunc:
        ndo->ndo_snapend = se;
-       free(b);
-       ND_PRINT("[|ppp]");
+       nd_print_trunc(ndo);
 }
 
 
@@ -1545,6 +1544,7 @@ ppp_print(netdissect_options *ndo,
         u_int olen = length; /* _o_riginal length */
        u_int hdr_len = 0;
 
+       ndo->ndo_protocol = "ppp";
        /*
         * Here, we assume that p points to the Address and Control
         * field (if they present).
@@ -1602,7 +1602,7 @@ ppp_print(netdissect_options *ndo,
        handle_ppp(ndo, proto, p, length);
        return (hdr_len);
 trunc:
-       ND_PRINT("[|ppp]");
+       nd_print_trunc(ndo);
        return (0);
 }
 
@@ -1615,8 +1615,9 @@ ppp_if_print(netdissect_options *ndo,
        u_int length = h->len;
        u_int caplen = h->caplen;
 
+       ndo->ndo_protocol = "ppp_if";
        if (caplen < PPP_HDRLEN) {
-               ND_PRINT("[|ppp]");
+               nd_print_trunc(ndo);
                return (caplen);
        }
 
@@ -1685,8 +1686,9 @@ ppp_hdlc_if_print(netdissect_options *ndo,
        u_int proto;
        u_int hdrlen = 0;
 
+       ndo->ndo_protocol = "ppp_hdlc_if";
        if (caplen < 2) {
-               ND_PRINT("[|ppp]");
+               nd_print_trunc(ndo);
                return (caplen);
        }
 
@@ -1694,7 +1696,7 @@ ppp_hdlc_if_print(netdissect_options *ndo,
 
        case PPP_ADDRESS:
                if (caplen < 4 || length < 4) {
-                       ND_PRINT("[|ppp]");
+                       nd_print_trunc(ndo);
                        return (caplen);
                }
 
@@ -1720,7 +1722,7 @@ ppp_hdlc_if_print(netdissect_options *ndo,
 
        default:
                if (caplen < 4) {
-                       ND_PRINT("[|ppp]");
+                       nd_print_trunc(ndo);
                        return (caplen);
                }
 
@@ -1759,8 +1761,9 @@ ppp_bsdos_if_print(netdissect_options *ndo _U_,
        const u_char *q;
        u_int i;
 
+       ndo->ndo_protocol = "ppp_bsdos_if";
        if (caplen < PPP_BSDI_HDRLEN) {
-               ND_PRINT("[|ppp]");
+               nd_print_trunc(ndo);
                return (caplen);
        }
 
@@ -1903,11 +1906,3 @@ printx:
 #endif /* __bsdi__ */
        return (hdrlength);
 }
-
-
-/*
- * Local Variables:
- * c-style: whitesmith
- * c-basic-offset: 8
- * End:
- */