]> The Tcpdump Group git mirrors - tcpdump/commitdiff
* print-rt6.c: make IPv6 routing header printing work with new 2292bis
authoritojun <itojun>
Wed, 22 Dec 1999 06:27:19 +0000 (06:27 +0000)
committeritojun <itojun>
Wed, 22 Dec 1999 06:27:19 +0000 (06:27 +0000)
  API.
* print-bgp.c: improve options printing.  ugly code exists for
  unaligned option parsing (need some fix).
* const poisoning in SMB decoder.
* make dump format back to original.  someone may want to add an
  option to do ascii printing, but keep the default behavior as is
  for scripts used in many places.
* -Wall -Werror clean checks.

19 files changed:
CHANGES
interface.h
isakmp.h
print-bgp.c
print-dhcp6.c
print-frag6.c
print-ip.c
print-l2tp.c
print-llc.c
print-null.c
print-ppp.c
print-rt6.c
print-smb.c
print-snmp.c
print-tcp.c
print-udp.c
smb.h
smbutil.c
tcpdump.c

diff --git a/CHANGES b/CHANGES
index 5c3aeb3c782cf06bfc41c014b0de228b48e4beeb..f219403905a92b418a88e30168a4adc95f823fc8 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,14 @@
+Wed Dec 22 13:06:17 JST 1999  [email protected]
+       * print-rt6.c: make IPv6 routing header printing work with new 2292bis
+         API.
+       * print-bgp.c: improve options printing.  ugly code exists for
+         unaligned option parsing (need some fix).
+       * const poisoning in SMB decoder.
+       * make dump format back to original.  someone may want to add an
+         option to do ascii printing, but keep the default behavior as is
+         for scripts used in many places.
+       * -Wall -Werror clean checks.
+
 1999-11-21  Assar Westerlund  <[email protected]>
 
        * Add SMB printing code from Andrew Tridgell <[email protected]>
@@ -543,4 +554,4 @@ v2.0 Sun Jan 13 12:20:40 PST 1991
 
 - Initial public release.
 
-@(#) $Header: /tcpdump/master/tcpdump/CHANGES,v 1.61 1999-11-21 15:58:53 assar Exp $ (LBL)
+@(#) $Header: /tcpdump/master/tcpdump/CHANGES,v 1.62 1999-12-22 06:27:19 itojun Exp $ (LBL)
index a7a0661e8d99ff028352e5817bb90ce2bb6d9579..52316132c94a9ffa64b60217f8d3e2482fa5778d 100644 (file)
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.116 1999-12-15 07:55:42 fenner Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.117 1999-12-22 06:27:20 itojun Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -48,6 +48,7 @@ extern int tflag;             /* print packet arrival time */
 extern int vflag;              /* verbose */
 extern int xflag;              /* print packet in hex */
 
+extern char *ahsecret;
 extern char *espsecret;
 
 extern int packettype;         /* as specified by -T */
@@ -231,13 +232,13 @@ extern int esp_print(register const u_char *, register const u_char *, int *);
 extern void isakmp_print(const u_char *, u_int, const u_char *);
 extern int ipcomp_print(register const u_char *, register const u_char *, int *);
 extern void rx_print(register const u_char *, int, int, int, u_char *);
-extern void netbeui_print(u_char *, u_char *);
-extern void ipx_netbios_print(u_char *, u_char *);
-extern void nbt_tcp_print(u_char *, int);
-extern void nbt_udp137_print(u_char *data, int);
-extern void nbt_udp138_print(u_char *data, int);
+extern void netbeui_print(const u_char *, const u_char *);
+extern void ipx_netbios_print(const u_char *, const u_char *);
+extern void nbt_tcp_print(const u_char *, int);
+extern void nbt_udp137_print(const u_char *data, int);
+extern void nbt_udp138_print(const u_char *data, int);
 extern char *smb_errstr(int, int);
-extern void print_data(unsigned char *, int);
+extern void print_data(const unsigned char *, int);
 extern void l2tp_print(const u_char *, u_int);
 extern void lcp_print(const u_char *, u_int);
 
index e8c7bd55975cc313071fc6b6e7da748c6ed09f10..da793e1ff1749b6ada605c08da63fa8c2900537c 100644 (file)
--- a/isakmp.h
+++ b/isakmp.h
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-/* YIPS @(#)$Id: isakmp.h,v 1.3 1999-11-17 04:14:50 assar Exp $ */
+/* YIPS @(#)$Id: isakmp.h,v 1.4 1999-12-22 06:27:20 itojun Exp $ */
 
 /* refer to RFC 2408 */
 
@@ -98,20 +98,20 @@ typedef struct { /* i_cookie + r_cookie */
         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 */
 struct isakmp {
-       cookie_t i_ck;     /* Initiator Cookie */
-       cookie_t r_ck;     /* Responder Cookie */
-       u_int8_t   np;       /* Next Payload Type */
+       cookie_t i_ck;          /* Initiator Cookie */
+       cookie_t r_ck;          /* Responder Cookie */
+       u_int8_t np;            /* Next Payload Type */
 #if defined(WORDS_BIGENDIAN) || (defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN))
-       u_int   v_maj:4,  /* MnVer */
-                v_min:4;  /* MjVer */
+       u_int v_maj:4,          /* MnVer */
+               v_min:4;        /* MjVer */
 #else
-       u_int   v_min:4,  /* MnVer */
-                v_maj:4;  /* MjVer */
+       u_int v_min:4,          /* MnVer */
+               v_maj:4;        /* MjVer */
 #endif
-       u_int8_t   etype;    /* Exchange Type */
-       u_int8_t   flags;    /* Flags */
-       msgid_t  msgid;
-       u_int32_t  len;      /* Length */
+       u_int8_t etype;         /* Exchange Type */
+       u_int8_t flags;         /* Flags */
+       msgid_t msgid;
+       u_int32_t len;          /* Length */
 };
 
 /* Next Payload Type */
index d1a938bee291c4f5f2161cc3e654d603ff5a1921..37ea9cb01b898d7254011823b91ef86c04d54969 100644 (file)
@@ -74,6 +74,12 @@ struct bgp_open {
        /* options should follow */
 };
 
+struct bgp_opt {
+       u_int8_t bgpopt_type;
+       u_int8_t bgpopt_len;
+       /* variable length */
+};
+
 struct bgp_notification {
        u_int8_t bgpn_marker[16];
        u_int16_t bgpn_len;
@@ -104,6 +110,12 @@ struct bgp_attr {
 #define BGPTYPE_LOCAL_PREF             5
 #define BGPTYPE_ATOMIC_AGGREGATE       6
 #define BGPTYPE_AGGREGATOR             7
+#define        BGPTYPE_COMMUNITIES             8       /* RFC1997 */
+#define        BGPTYPE_ORIGINATOR_ID           9       /* RFC1998 */
+#define        BGPTYPE_CLUSTER_LIST            10      /* RFC1998 */
+#define        BGPTYPE_DPA                     11      /* work in progress */
+#define        BGPTYPE_ADVERTISERS             12      /* RFC1863 */
+#define        BGPTYPE_RCID_PATH               13      /* RFC1863 */
 #define BGPTYPE_MP_REACH_NLRI          14      /* RFC2283 */
 #define BGPTYPE_MP_UNREACH_NLRI                15      /* RFC2283 */
 
@@ -113,6 +125,12 @@ static const char *bgptype[] = {
 };
 #define bgp_type(x) num_or_str(bgptype, sizeof(bgptype)/sizeof(bgptype[0]), (x))
 
+static const char *bgpopt_type[] = {
+       NULL, "Authentication Information",
+};
+#define bgp_opttype(x) \
+       num_or_str(bgpopt_type, sizeof(bgpopt_type)/sizeof(bgpopt_type[0]), (x))
+
 static const char *bgpnotify_major[] = {
        NULL, "Message Header Error",
        "OPEN Message Error", "UPDATE Message Error",
@@ -163,8 +181,8 @@ static const char *bgpattr_origin[] = {
 static const char *bgpattr_type[] = {
        NULL, "ORIGIN", "AS_PATH", "NEXT_HOP",
        "MULTI_EXIT_DISC", "LOCAL_PREF", "ATOMIC_AGGREGATE", "AGGREGATOR",
-       NULL, NULL, NULL, NULL,
-       NULL, NULL, "MP_REACH_NLRI", "MP_UNREACH_NLRI",
+       "COMMUNITIES", "ORIGINATOR_ID", "CLUSTER_LIST", "DPA",
+       "ADVERTISERS", "RCID_PATH", "MP_REACH_NLRI", "MP_UNREACH_NLRI",
 };
 #define bgp_attr_type(x) \
        num_or_str(bgpattr_type, \
@@ -178,6 +196,11 @@ static const char *bgpattr_nlri_safi[] = {
        num_or_str(bgpattr_nlri_safi, \
                sizeof(bgpattr_nlri_safi)/sizeof(bgpattr_nlri_safi[0]), (x))
 
+/* well-known community */
+#define BGP_COMMUNITY_NO_EXPORT                        0xffffff01
+#define BGP_COMMUNITY_NO_ADVERT                        0xffffff02
+#define BGP_COMMUNITY_NO_EXPORT_SUBCONFED      0xffffff03
+
 /* RFC1700 address family numbers */
 #define AFNUM_INET     1
 #define AFNUM_INET6    2
@@ -311,8 +334,23 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
                        printf(" invalid len");
                        break;
                }
-               for (i = 0; i < len; i += 2)
-                       printf(" %u", ntohs(*(u_int16_t *)&p[i]));
+               while (p < dat + len) {
+                       /*
+                        * under RFC1965, p[0] means:
+                        * 1: AS_SET 2: AS_SEQUENCE
+                        * 3: AS_CONFED_SET 4: AS_CONFED_SEQUENCE
+                        */
+                       printf(" ");
+                       if (p[0] == 3 || p[0] == 4)
+                               printf("confed");
+                       printf("%s", (p[0] & 1) ? "{" : "");
+                       for (i = 0; i < p[1]; i += 2) {
+                               printf("%s%u", i == 0 ? "" : " ",
+                                       ntohs(*(u_int16_t *)&p[2 + i]));
+                       }
+                       printf("%s", (p[0] & 1) ? "}" : "");
+                       p += 2 + p[1] * 2;
+               }
                break;
        case BGPTYPE_NEXT_HOP:
                if (len != 4)
@@ -339,6 +377,31 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len)
                printf(" AS #%u, origin %s", ntohs(*(u_int16_t *)p),
                        getname(p + 2));
                break;
+       case BGPTYPE_COMMUNITIES:
+               if (len % 4) {
+                       printf(" invalid len");
+                       break;
+               }
+               for (i = 0; i < len; i++) {
+                       u_int32_t comm;
+                       comm = (u_int32_t)ntohl(*(u_int32_t *)&p[i]);
+                       switch (comm) {
+                       case BGP_COMMUNITY_NO_EXPORT:
+                               printf(" NO_EXPORT");
+                               break;
+                       case BGP_COMMUNITY_NO_ADVERT:
+                               printf(" NO_ADVERTISE");
+                               break;
+                       case BGP_COMMUNITY_NO_EXPORT_SUBCONFED:
+                               printf(" NO_EXPORT_SUBCONFED");
+                               break;
+                       default:
+                               printf(" (AS #%d value 0x%04x)",
+                                       (comm >> 16) & 0xffff, comm & 0xfffff);
+                               break;
+                       }
+               }
+               break;
        case BGPTYPE_MP_REACH_NLRI:
                af = ntohs(*(u_int16_t *)p);
                safi = p[2];
@@ -440,7 +503,10 @@ static void
 bgp_open_print(const u_char *dat, int length)
 {
        struct bgp_open bgpo;
+       struct bgp_opt bgpopt;
        int hlen;
+       const u_char *opt;
+       int i;
 
        memcpy(&bgpo, dat, sizeof(bgpo));
        hlen = ntohs(bgpo.bgpo_len);
@@ -450,6 +516,22 @@ bgp_open_print(const u_char *dat, int length)
        printf(" Holdtime %u,", ntohs(bgpo.bgpo_holdtime));
        printf(" ID %s,", getname((char *)&bgpo.bgpo_id));
        printf(" Option length %u", bgpo.bgpo_optlen);
+
+       /* ugly! */
+       opt = &((struct bgp_open *)dat)->bgpo_optlen;
+       opt++;
+
+       for (i = 0; i < bgpo.bgpo_optlen; i++) {
+               memcpy(&bgpopt, &opt[i], sizeof(bgpopt));
+               if (i + 2 + bgpopt.bgpopt_len > bgpo.bgpo_optlen) {
+                       printf(" [|opt %d %d]", bgpopt.bgpopt_len, bgpopt.bgpopt_type);
+                       break;
+               }
+
+               printf(" (option %s, len=%d)", bgp_opttype(bgpopt.bgpopt_type),
+                       bgpopt.bgpopt_len);
+               i += sizeof(bgpopt) + bgpopt.bgpopt_len;
+       }
 }
 
 static void
@@ -505,14 +587,6 @@ bgp_update_print(const u_char *dat, int length)
                        bgp_attr_print(&bgpa, &p[i + aoff], alen);
                        newline = 1;
 
-#if 0
-           default:
-               proto_tree_add_text(subtree2, p - pd + i + aoff, alen,
-                       "Unknown (%d bytes)", alen);
-               break;
-           }
-#endif
-
                        /* ( */
                        printf(")");    
 
@@ -524,6 +598,22 @@ bgp_update_print(const u_char *dat, int length)
        }
        p += 2 + len;
 
+       if (len && dat + length > p)
+               printf("\n\t\t");
+       if (dat + length > p) {
+               printf("(NLRI:");       /* ) */
+               while (dat + length > p) {
+                       char buf[256];
+                       i = decode_prefix4(p, buf, sizeof(buf));
+                       printf(" %s", buf);
+                       if (i < 0)
+                               break;
+                       p += i;
+               }
+
+               /* ( */
+               printf(")");
+       }
 }
 
 static void
index 0885771c8e67cd17256650df7af6f38547909742..1e3be6befc3309ba4847ce5224c18a4ecec8f7df 100644 (file)
@@ -29,7 +29,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.2 1999-11-21 09:36:50 fenner Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-dhcp6.c,v 1.3 1999-12-22 06:27:20 itojun Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -54,6 +54,7 @@ struct rtentry;
 #endif
 #include <stdio.h>
 #include <string.h>
+#include <arpa/inet.h>
 
 #include "interface.h"
 #include "addrtoname.h"
@@ -62,8 +63,8 @@ struct rtentry;
 
 #if 0
 static void dhcp6opttab_init __P((void));
-#endif
 static struct dhcp6_opt *dhcp6opttab_byname __P((char *));
+#endif
 static struct dhcp6_opt *dhcp6opttab_bycode __P((u_int));
 
 static char tstr[] = " [|dhcp6]";
@@ -122,6 +123,7 @@ dhcp6opttab_init()
 }
 #endif
 
+#if 0
 static struct dhcp6_opt *
 dhcp6opttab_byname(name)
        char *name;
@@ -133,6 +135,7 @@ dhcp6opttab_byname(name)
                        return p;
        return NULL;
 }
+#endif
 
 static struct dhcp6_opt *
 dhcp6opttab_bycode(code)
@@ -151,7 +154,6 @@ dhcp6ext_print(u_char *cp, u_char *ep)
 {
        u_int16_t code, len;
        struct dhcp6_opt *p;
-       char *q;
        char buf[BUFSIZ];
        int i;
 
index ddfc3b4960a6a011f7354fc440e9eb619adeef1d..a8bc0b20e162eec52b09fa6f78016fe3de3800a8 100644 (file)
@@ -74,16 +74,16 @@ frag6_print(register const u_char *bp, register const u_char *bp2)
        TCHECK(dp->ip6f_offlg);
 
        if (vflag) {
-               printf("frag (0x%08x:%d|%d)",
-                      ntohl(dp->ip6f_ident),
+               printf("frag (0x%08x:%d|%ld)",
+                      (u_int32_t)ntohl(dp->ip6f_ident),
                       ntohs(dp->ip6f_offlg & IP6F_OFF_MASK),
                       sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) -
-                              (bp - bp2) - sizeof(struct ip6_frag));
+                              (long)(bp - bp2) - sizeof(struct ip6_frag));
        } else {
-               printf("frag (%d|%d)",
+               printf("frag (%d|%ld)",
                       ntohs(dp->ip6f_offlg & IP6F_OFF_MASK),
                       sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen) -
-                              (bp - bp2) - sizeof(struct ip6_frag));
+                              (long)(bp - bp2) - sizeof(struct ip6_frag));
        }
 
 #if 0
index 1eddff59f24dfaa6e3ccc5641535375d3772b88a..2ae036afe3966bb08283e70fa02cb08122f94079 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.78 1999-12-15 00:34:10 fenner Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.79 1999-12-22 06:27:21 itojun Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -119,8 +119,8 @@ static void print_mtrace(register const u_char *bp, register u_int len)
 {
        register struct tr_query *tr = (struct tr_query *)(bp + 8);
 
-       printf("mtrace %ld: %s to %s reply-to %s",
-               TR_GETQID(ntohl(tr->tr_rttlqid)),
+       printf("mtrace %lu: %s to %s reply-to %s",
+               (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
                ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
                ipaddr_string(&tr->tr_raddr));
        if (IN_CLASSD(ntohl(tr->tr_raddr)))
@@ -131,8 +131,8 @@ static void print_mresp(register const u_char *bp, register u_int len)
 {
        register struct tr_query *tr = (struct tr_query *)(bp + 8);
 
-       printf("mresp %ld: %s to %s reply-to %s",
-               TR_GETQID(ntohl(tr->tr_rttlqid)),
+       printf("mresp %lu: %s to %s reply-to %s",
+               (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
                ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
                ipaddr_string(&tr->tr_raddr));
        if (IN_CLASSD(ntohl(tr->tr_raddr)))
index 0a28d6616410b4b26a3d71781a0edab268452577..fa6c43654a1c64992b9f39dcf0b5e00bd79ad04a 100644 (file)
@@ -23,7 +23,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.5 1999-12-15 06:55:43 fenner Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-l2tp.c,v 1.6 1999-12-22 06:27:21 itojun Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -156,6 +156,7 @@ static struct l2tp_avp_vec l2tp_avp[] = {
 #define L2TP_MAX_AVP_INDEX     40
 };
 
+#if 0
 static char *l2tp_result_code_StopCCN[] = {
          "Reserved",
          "General request to clear control connection",
@@ -167,7 +168,9 @@ static char *l2tp_result_code_StopCCN[] = {
          "Finite State Machine error"
 #define L2TP_MAX_RESULT_CODE_STOPCC_INDEX      8
 };
+#endif
 
+#if 0
 static char *l2tp_result_code_CDN[] = {
        "Reserved",
        "Call disconnected due to loss of carrier",
@@ -185,7 +188,9 @@ static char *l2tp_result_code_CDN[] = {
        "Call was connected but no appropriate framing was detected"
 #define L2TP_MAX_RESULT_CODE_CDN_INDEX 12
 };
+#endif
 
+#if 0
 static char *l2tp_error_code_general[] = {
        "No general error",
        "No control connection exists yet for this LAC-LNS pair",
@@ -198,6 +203,7 @@ static char *l2tp_error_code_general[] = {
        "Try another"
 #define L2TP_MAX_ERROR_CODE_GENERAL_INDEX      8
 };
+#endif
 
 /******************************/
 /* generic print out routines */
@@ -223,13 +229,13 @@ print_octets(const u_char *dat, u_int length)
 static void
 print_short(const u_short *dat)
 {
-       printf("%d", ntohs(*dat));
+       printf("%u", ntohs(*dat));
 }
 
 static void
 print_int(const u_int *dat)
 {
-       printf("%d", ntohl(*dat));
+       printf("%lu", (u_long)ntohl(*dat));
 }
 
 /**********************************/
@@ -252,11 +258,11 @@ l2tp_result_code_print(const u_char *dat, u_int length)
        u_short *ptr = (u_short *)dat;
        
        if (length == 2) {              /* result code */
-               printf("%d", ntohs(*ptr));      
+               printf("%u", ntohs(*ptr));      
        } else if (length == 4) {       /* result & error code */
-               printf("%d/%d", ntohs(*ptr), ntohs(*(ptr+1)));
+               printf("%u/%u", ntohs(*ptr), ntohs(*(ptr+1)));
        } else if (length > 4) {        /* result & error code & msg */
-               printf("%d/%d ", ntohs(*ptr), ntohs(*(ptr+1)));
+               printf("%u/%u ", ntohs(*ptr), ntohs(*(ptr+1)));
                print_string((u_char *)(ptr+2), length - 4);
        }
 }
@@ -340,7 +346,7 @@ static void
 l2tp_q931_cc_print(const u_char *dat, u_int length)
 {
        print_short((u_short *)dat);
-       printf(",%02x", dat+2);
+       printf(", %02x", dat[2]);
        if (length > 3) {
                printf(" ");
                print_string(dat+3, length-3);
@@ -503,7 +509,7 @@ l2tp_proxy_auth_id_print(const u_char *dat, u_int length)
 {
        u_short *ptr = (u_short *)dat;
 
-       printf("%d", ntohs(*ptr) & L2TP_PROXY_AUTH_ID_MASK);
+       printf("%u", ntohs(*ptr) & L2TP_PROXY_AUTH_ID_MASK);
 }
 
 static void
@@ -602,7 +608,7 @@ l2tp_avp_print(const u_char *dat, u_int length)
                        }
                        printf(")");
                } else {
-                       printf(" invalid AVP %d", ntohs(*ptr));
+                       printf(" invalid AVP %u", ntohs(*ptr));
                }
 
                l2tp_avp_print(dat + len, length - len);
@@ -676,13 +682,13 @@ l2tp_print(const u_char *dat, u_int length)
                l2tp_len = 0;
        }
 
-       printf("(%d/", ntohs(*ptr++));          /* Tunnel ID */
-       printf("%d)",  ntohs(*ptr++));          /* Session ID */
+       printf("(%u/", ntohs(*ptr++));          /* Tunnel ID */
+       printf("%u)",  ntohs(*ptr++));          /* Session ID */
        cnt += 4;
 
        if (flag_s) {
-               printf("Ns=%d,", ntohs(*ptr++));
-               printf("Nr=%d",  ntohs(*ptr++));
+               printf("Ns=%u,", ntohs(*ptr++));
+               printf("Nr=%u",  ntohs(*ptr++));
                cnt += 4;
        }
 
index 4df0f9f93e3525bd32ad571fbe8a1d3042238655..59a76e5868e67276a96047ae3d3e993191248872 100644 (file)
@@ -24,7 +24,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.26 1999-11-21 15:57:52 assar Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-llc.c,v 1.27 1999-12-22 06:27:21 itojun Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -83,11 +83,14 @@ llc_print(const u_char *p, u_int length, u_int caplen,
                ipx_print(p, length);
                return (1);
        }
-       else if (p[0] == 0xf0 && p[1] == 0xf0) {
-         /* we don't actually have a full netbeui parser yet, but the
-            smb parser can handle many smb-in-netbeui packets, which
-            is very useful, so we call that */
-         netbeui_print(p+2,p+min(caplen,length));
+       if (llc.ssap == 0xf0 && llc.dsap == 0xf0) {
+               /*
+                * we don't actually have a full netbeui parser yet, but the
+                * smb parser can handle many smb-in-netbeui packets, which
+                * is very useful, so we call that
+                */
+               netbeui_print(p + 2, p + min(caplen, length));
+               return (1);
        }
        if (llc.ssap == LLCSAP_ISONS && llc.dsap == LLCSAP_ISONS
            && llc.llcui == LLC_UI) {
@@ -98,9 +101,9 @@ llc_print(const u_char *p, u_int length, u_int caplen,
        if (llc.ssap == LLCSAP_SNAP && llc.dsap == LLCSAP_SNAP
            && llc.llcui == LLC_UI) {
                if (caplen < sizeof(llc)) {
-                   (void)printf("[|llc-snap]");
-                   default_print((u_char *)p, caplen);
-                   return (0);
+                       (void)printf("[|llc-snap]");
+                       default_print((u_char *)p, caplen);
+                       return (0);
                }
                if (vflag)
                        (void)printf("snap %s ", protoid_string(llc.llcpi));
@@ -142,11 +145,11 @@ llc_print(const u_char *p, u_int length, u_int caplen,
                char f;
                m = tok2str(cmd2str, "%02x", LLC_U_CMD(llc.llcu));
                switch ((llc.ssap & LLC_GSAP) | (llc.llcu & LLC_U_POLL)) {
-                   case 0:                     f = 'C'; break;
-                   case LLC_GSAP:              f = 'R'; break;
-                   case LLC_U_POLL:            f = 'P'; break;
-                   case LLC_GSAP|LLC_U_POLL:   f = 'F'; break;
-                   default:                    f = '?'; break;
+                       case 0:                 f = 'C'; break;
+                       case LLC_GSAP:          f = 'R'; break;
+                       case LLC_U_POLL:        f = 'P'; break;
+                       case LLC_GSAP|LLC_U_POLL: f = 'F'; break;
+                       default:                f = '?'; break;
                }
 
                printf("%s/%c", m, f);
@@ -156,29 +159,31 @@ llc_print(const u_char *p, u_int length, u_int caplen,
                caplen -= 3;
 
                if ((llc.llcu & ~LLC_U_POLL) == LLC_XID) {
-                   if (*p == LLC_XID_FI) {
-                       printf(": %02x %02x", p[1], p[2]);
-                       p += 3;
-                       length -= 3;
-                       caplen -= 3;
-                   }
+                       if (*p == LLC_XID_FI) {
+                               printf(": %02x %02x", p[1], p[2]);
+                               p += 3;
+                               length -= 3;
+                               caplen -= 3;
+                       }
                }
 
                if (!strcmp(m,"ui") && f=='C') {
-                 /* we don't have a proper ipx decoder yet, but there
-                     is a partial one in the smb code */
-                 ipx_netbios_print(p,p+min(caplen,length));
+                       /*
+                        * we don't have a proper ipx decoder yet, but there
+                        * is a partial one in the smb code
+                        */
+                       ipx_netbios_print(p,p+min(caplen,length));
                }
 
        } else {
                char f;
                llc.llcis = ntohs(llc.llcis);
                switch ((llc.ssap & LLC_GSAP) | (llc.llcu & LLC_U_POLL)) {
-                   case 0:                     f = 'C'; break;
-                   case LLC_GSAP:              f = 'R'; break;
-                   case LLC_U_POLL:            f = 'P'; break;
-                   case LLC_GSAP|LLC_U_POLL:   f = 'F'; break;
-                   default:                    f = '?'; break;
+                       case 0:                 f = 'C'; break;
+                       case LLC_GSAP:          f = 'R'; break;
+                       case LLC_U_POLL:        f = 'P'; break;
+                       case LLC_GSAP|LLC_U_POLL: f = 'F'; break;
+                       default:                f = '?'; break;
                }
 
                if ((llc.llcu & LLC_S_FMT) == LLC_S_FMT) {
index 26a343ac2c21631fa76fb9c6385f74e26f9871ec..7089eb9d08b96c9ab7175b3a82c8e25adc93c466 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.29 1999-11-21 12:38:24 itojun Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-null.c,v 1.30 1999-12-22 06:27:21 itojun Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -128,15 +128,15 @@ null_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
                null_print(p, ip, length);
 
        switch (ip->ip_v) {
-       case 4 :
-               ip_print((const void *)ip, length);
+       case 4:
+               ip_print((const u_char *)ip, length);
                break;
 #ifdef INET6
        case 6:
-               ip6_print((const void *)ip, length);
+               ip6_print((const u_char *)ip, length);
                break;
 #endif /* INET6 */
-       default :
+       default:
                printf("ip v%d", ip->ip_v);
                break;
        }
index 505cb40827fafc4f51bb3a4166f94de5d9cc5ab2..1d242efc26259ca462ee41a55928a121a1562e38 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.32 1999-12-15 07:52:15 fenner Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ppp.c,v 1.33 1999-12-22 06:27:22 itojun Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -481,7 +481,7 @@ ppp_if_print(u_char *user, const struct pcap_pkthdr *h,
        ip = (struct ip *)(p + PPP_HDRLEN);
        switch (proto) {
        case PPP_LCP:
-               handle_lcp (p, length);
+               handle_lcp(p, length);
                break;
        case PPP_CHAP:
                handle_chap(p, length);
@@ -512,36 +512,36 @@ out:
 }
 
 struct tok ppptype2str[] = {
-  { PPP_IP,    "IP" },
-  { PPP_OSI,   "OSI" },
-  { PPP_NS,    "NS" },
-  { PPP_DECNET,        "DECNET" },
-  { PPP_APPLE, "APPLE" },
-  { PPP_IPX,   "IPX" },
-  { PPP_VJC,   "VJC" },
-  { PPP_VJNC,  "VJNC" },
-  { PPP_BRPDU, "BRPDU" },
-  { PPP_STII,  "STII" },
-  { PPP_VINES, "VINES" },
-
-  { PPP_HELLO, "HELLO" },
-  { PPP_LUXCOM,        "LUXCOM" },
-  { PPP_SNS,   "SNS" },
-  { PPP_IPCP,  "IPCP" },
-  { PPP_OSICP, "OSICP" },
-  { PPP_NSCP,  "NSCP" },
-  { PPP_DECNETCP, "DECNETCP" },
-  { PPP_APPLECP, "APPLECP" },
-  { PPP_IPXCP, "IPXCP" },
-  { PPP_STIICP,        "STIICP" },
-  { PPP_VINESCP, "VINESCP" },
-
-  { PPP_LCP,   "LCP" },
-  { PPP_PAP,   "PAP" },
-  { PPP_LQM,   "LQM" },
-  { PPP_CHAP,  "CHAP" },
-  { 0,         NULL }
- };
+       { PPP_IP,       "IP" },
+       { PPP_OSI,      "OSI" },
+       { PPP_NS,       "NS" },
+       { PPP_DECNET,   "DECNET" },
+       { PPP_APPLE,    "APPLE" },
+       { PPP_IPX,      "IPX" },
+       { PPP_VJC,      "VJC" },
+       { PPP_VJNC,     "VJNC" },
+       { PPP_BRPDU,    "BRPDU" },
+       { PPP_STII,     "STII" },
+       { PPP_VINES,    "VINES" },
+
+       { PPP_HELLO,    "HELLO" },
+       { PPP_LUXCOM,   "LUXCOM" },
+       { PPP_SNS,      "SNS" },
+       { PPP_IPCP,     "IPCP" },
+       { PPP_OSICP,    "OSICP" },
+       { PPP_NSCP,     "NSCP" },
+       { PPP_DECNETCP, "DECNETCP" },
+       { PPP_APPLECP, "APPLECP" },
+       { PPP_IPXCP,    "IPXCP" },
+       { PPP_STIICP,   "STIICP" },
+       { PPP_VINESCP, "VINESCP" },
+
+       { PPP_LCP,      "LCP" },
+       { PPP_PAP,      "PAP" },
+       { PPP_LQM,      "LQM" },
+       { PPP_CHAP,     "CHAP" },
+       { 0,            NULL }
+};
 
 #define PPP_BSDI_HDRLEN 24
 
index b8e16d599544e8ad88a9d431d086b46e38100d1f..a0750e0bcff4592be290b62b9032888d5224010d 100644 (file)
@@ -57,20 +57,15 @@ static const char rcsid[] =
 int
 rt6_print(register const u_char *bp, register const u_char *bp2)
 {
-       register const struct ip6_rthdr0 *dp;
+       register const struct ip6_rthdr *dp;
+       register const struct ip6_rthdr0 *dp0;
        register const struct ip6_hdr *ip;
        register const u_char *ep;
-       u_long bitmap = 0x0800;
-       u_long slmap;
        int i, len;
 
-#if 0
-#define TCHECK(var) if ((u_char *)&(var) >= ep - sizeof(var)) goto trunc
-#endif
-
-       dp = (struct ip6_rthdr0 *)bp;
+       dp = (struct ip6_rthdr *)bp;
        ip = (struct ip6_hdr *)bp2;
-       len = dp->ip6r0_len;
+       len = dp->ip6r_len;
 
        /* 'ep' points to the end of avaible data. */
        ep = snapend;
@@ -78,43 +73,48 @@ rt6_print(register const u_char *bp, register const u_char *bp2)
         printf("%s > %s: ",
               ip6addr_string(&ip->ip6_src),
               ip6addr_string(&ip->ip6_dst));
-       
-       TCHECK(dp->ip6r0_slmap[2]);
-       printf("srcrt (len=%d, ", dp->ip6r0_len);
-       printf("type=%d, ", dp->ip6r0_type);
-       printf("segleft=%d, ", dp->ip6r0_segleft);
-       if (dp->ip6r0_type != 0)
-               goto trunc;
-       slmap = (dp->ip6r0_slmap[0] << 16)
-             | (dp->ip6r0_slmap[1] <<  8)
-             | (dp->ip6r0_slmap[2]);
-       printf("bitmap=");
-       for (i = 24; i > 0; i--) {
-               if (slmap & bitmap)
-                       printf("S");
-               else
-                       printf("L");
-               bitmap >>= 1;
-       }
-       if (len % 2 == 1)
-               goto trunc;
-       len >>= 1;
-       printf(", ");
-       for (i = 0; i < len; i++) {
-               if ((((u_char *)&(dp->ip6r0_reserved)) + sizeof(u_long)
-                    + (i<<4)) > ep) goto trunc;
-               printf(" [%d]%s", i,
-                      ip6addr_string(((u_char *)&(dp->ip6r0_reserved)) +
-                                     sizeof(u_long) + (i<<4)));
-               if (i != len - 1)
-                       printf(", ");
+
+       TCHECK(dp->ip6r_segleft);
+
+       printf("srcrt (len=%d, ", dp->ip6r_len);
+       printf("type=%d, ", dp->ip6r_type);
+       printf("segleft=%d, ", dp->ip6r_segleft);
+
+       switch(dp->ip6r_type) {
+       case IPV6_RTHDR_TYPE_0:
+               dp0 = (struct ip6_rthdr0 *)dp;
+
+               TCHECK(dp0->ip6r0_reserved);
+               if (dp0->ip6r0_reserved || vflag) {
+                       printf("rsv=0x%0x, ",
+                               (u_int32_t)ntohl(dp0->ip6r0_reserved));
+               }
+
+               if (len % 2 == 1)
+                       goto trunc;
+               len >>= 1;
+               for (i = 0; i < len; i++) {
+                       struct in6_addr *addr;
+
+                       addr = ((struct in6_addr *)(dp0 + 1)) + i;
+                       if ((u_char *)addr > ep - sizeof(*addr))
+                               goto trunc;
+
+                       printf("[%d]%s", i, ip6addr_string((u_char *)addr));
+                       if (i != len - 1)
+                               printf(", ");
                   
+               }
+               printf(")");
+               return((dp0->ip6r0_len + 1) << 3);
+               break;
+       default:
+               goto trunc;
+               break;
        }
-       printf(")");
-       return((dp->ip6r0_len + 1) << 3);
+
  trunc:
        fputs("[|srcrt]", stdout);
-       return 65535;
-#undef TCHECK
+       return 65535;           /* XXX */
 }
 #endif /* INET6 */
index 4f8af9d07e5cd7a9841bfc25d32512b955cde815..9810cda90467946535b0a7ab104cc1c1d606af4f 100644 (file)
@@ -18,7 +18,7 @@
 
 static int request=0;
 
-uchar *startbuf=NULL;
+const uchar *startbuf=NULL;
 
 struct smbdescript
 {
@@ -179,9 +179,9 @@ static void print_trans2(uchar *words,uchar *dat,uchar *buf,uchar *maxbuf)
 }
 
 
-static void print_browse(uchar *param,int paramlen,uchar *data,int datalen)
+static void print_browse(uchar *param,int paramlen,const uchar *data,int datalen)
 {
-  uchar *maxbuf = data + datalen;
+  const uchar *maxbuf = data + datalen;
   int command = CVAL(data,0);
 
   fdata(param,"BROWSE PACKET\n|Param ",param+paramlen);
@@ -605,10 +605,10 @@ NULL,NULL}},
 /*******************************************************************
 print a SMB message
 ********************************************************************/
-static void print_smb(uchar *buf,uchar *maxbuf)
+static void print_smb(const uchar *buf, const uchar *maxbuf)
 {
   int command;
-  uchar *words, *data;
+  const uchar *words, *data;
   struct smbfns *fn;
   char *fmt_smbheader = 
 "[P4]SMB Command   =  [B]\nError class   =  [BP1]\nError code    =  [d]\nFlags1        =  [B]\nFlags2        =  [B][P13]\nTree ID       =  [d]\nProc ID       =  [d]\nUID           =  [d]\nMID           =  [d]\nWord Count    =  [b]\n";
@@ -673,7 +673,7 @@ static void print_smb(uchar *buf,uchar *maxbuf)
          printf("smb_bcc=%d\n",bcc);
          if (bcc>0) {
            printf("smb_buf[]=\n");
-           print_data(data+2,MIN(bcc,PTR_DIFF(maxbuf,data+2)));
+           print_data(data + 2, MIN(bcc,PTR_DIFF(maxbuf,data+2)));
          }
        }
       }
@@ -698,11 +698,12 @@ static void print_smb(uchar *buf,uchar *maxbuf)
 /*
    print a NBT packet received across tcp on port 139
 */
-void nbt_tcp_print(uchar *data,int length)
+void nbt_tcp_print(const uchar *data,int length)
 {
-  uchar *maxbuf = data + length;
+  const uchar *maxbuf = data + length;
   int flags = CVAL(data,0);
   int nbt_len = RSVAL(data,2);
+
   startbuf = data;
   if (maxbuf <= data) return;
 
@@ -715,7 +716,7 @@ void nbt_tcp_print(uchar *data,int length)
     data = fdata(data,"NBT Session Packet\nFlags=[rw]\nLength=[rd]\n",data+4);
     if (memcmp(data,"\377SMB",4)==0) {
       if (nbt_len>PTR_DIFF(maxbuf,data))
-       printf("WARNING: Short packet. Try increasing the snap length (%d)\n",
+       printf("WARNING: Short packet. Try increasing the snap length (%ld)\n",
               PTR_DIFF(maxbuf,data));
       print_smb(data,maxbuf>data+nbt_len?data+nbt_len:maxbuf);
     } else {
@@ -771,9 +772,9 @@ void nbt_tcp_print(uchar *data,int length)
 /*
    print a NBT packet received across udp on port 137
 */
-void nbt_udp137_print(uchar *data,int length)
+void nbt_udp137_print(const uchar *data, int length)
 {
-  uchar *maxbuf = data + length;
+  const uchar *maxbuf = data + length;
   int name_trn_id = RSVAL(data,0);
   int response = (CVAL(data,2)>>7);
   int opcode = (CVAL(data,2) >> 3) & 0xF;
@@ -785,7 +786,7 @@ void nbt_udp137_print(uchar *data,int length)
   int arcount = RSVAL(data,10);
   char des[1024];
   char *opcodestr="OPUNKNOWN";  
-  char *p;
+  const char *p;
 
   startbuf = data;
 
@@ -897,9 +898,9 @@ void nbt_udp137_print(uchar *data,int length)
 /*
    print a NBT packet received across udp on port 138
 */
-void nbt_udp138_print(uchar *data,int length)
+void nbt_udp138_print(const uchar *data, int length)
 {
-  uchar *maxbuf = data + length;
+  const uchar *maxbuf = data + length;
   startbuf = data;
   if (maxbuf <= data) return;
 
@@ -916,11 +917,11 @@ void nbt_udp138_print(uchar *data,int length)
 /*
    print netbeui frames 
 */
-void netbeui_print(uchar *data,uchar *maxbuf)
+void netbeui_print(const uchar *data, const uchar *maxbuf)
 {
   int len = SVAL(data,1);
   int command = CVAL(data,5);
-  uchar *data2 = data + 1 + len;
+  const uchar *data2 = data + 1 + len;
 
   startbuf = data;
 
@@ -984,7 +985,7 @@ void netbeui_print(uchar *data,uchar *maxbuf)
 /*
    print IPX-Netbios frames 
 */
-void ipx_netbios_print(uchar *data,uchar *maxbuf)
+void ipx_netbios_print(const uchar *data, const uchar *maxbuf)
 {
   /* this is a hack till I work out how to parse the rest of the IPX stuff */
   int i;
index a546d5d722fc94a6e672a2eea4c653cd80130cb0..b5835dc1033c06f5e29d73242a73ea8950582163 100644 (file)
@@ -45,7 +45,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.38 1999-12-13 18:06:14 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.39 1999-12-22 06:27:22 itojun Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -721,11 +721,19 @@ asn1_print(struct be *elem)
                d = elem->data.uns64.high * 4294967296.0;       /* 2^32 */
                if (elem->data.uns64.high <= 0x1fffff) { 
                        d += elem->data.uns64.low;
+#if 0 /*is looks illegal, but what is the intention???*/
                        printf("%.f", d);
+#else
+                       printf("%f", d);
+#endif
                        break;
                }
                d += (elem->data.uns64.low & 0xfffff000);
+#if 0 /*is looks illegal, but what is the intention???*/
                sprintf(first, "%.f", d);
+#else
+               sprintf(first, "%f", d);
+#endif
                sprintf(last, "%5.5d", elem->data.uns64.low & 0xfff);
                for (carry = 0, cpf = first+strlen(first)-1, cpl = last+4;
                     cpl >= last;
index 895be3bf6fee27e457ae31eade0052ef782e8b72..1561cdc3a01edfa32af1d0059382bf2aa15a4f7b 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.61 1999-11-22 04:27:10 fenner Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.62 1999-12-22 06:27:23 itojun Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -108,6 +108,9 @@ struct tcp_seq_hash {
 static struct tcp_seq_hash tcp_seq_hash[TSEQ_HASHSIZE];
 
 
+#ifndef BGP_PORT
+#define BGP_PORT       179
+#endif
 #define NETBIOS_SSN_PORT 139
 
 void
@@ -184,10 +187,11 @@ tcp_print(register const u_char *bp, register u_int length,
                return;
        }
 #ifdef TH_ECN
-       if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH|TH_ECN)) {
+       if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH|TH_ECN))
 #else
-       if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH)) {
+       if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH))
 #endif
+       {
                if (flags & TH_SYN)
                        putchar('S');
                if (flags & TH_FIN)
@@ -487,7 +491,7 @@ tcp_print(register const u_char *bp, register u_int length,
         * Decode payload if necessary.
         */
        bp += (tp->th_off * 4);
-       if (sport == 179 || dport == 179)
+       if (sport == BGP_PORT || dport == BGP_PORT)
                bgp_print(bp, length);
        if (sport == NETBIOS_SSN_PORT || dport == NETBIOS_SSN_PORT)
                nbt_tcp_print(bp, length);
index 7b4e535ea873230b1af72fd6b642b531af0c3b09..13e571c5b9e03f68a7b021466ed8d72395e171a7 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.69 1999-11-23 08:27:41 fenner Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.70 1999-12-22 06:27:23 itojun Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -514,10 +514,10 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
                else if (ISPORT(L2TP_PORT))
                        l2tp_print((const u_char *)(up + 1), length);
                else if (ISPORT(NETBIOS_NS_PORT)) {
-                 nbt_udp137_print((const u_char *)(up + 1), length);
+                       nbt_udp137_print((const u_char *)(up + 1), length);
                }
                else if (ISPORT(NETBIOS_DGRAM_PORT)) {
-                 nbt_udp138_print((const u_char *)(up + 1), length);
+                       nbt_udp138_print((const u_char *)(up + 1), length);
                }
                else if (dport == 3456)
                        vat_print((const void *)(up + 1), length, up);
diff --git a/smb.h b/smb.h
index ae47037ca44111143322f169f07ead04f7572d46..0c5461acd6dca1c985bb44a5b31e890b7818f7d8 100644 (file)
--- a/smb.h
+++ b/smb.h
 #define PTR_DIFF(p1,p2) ((unsigned long)(((char *)(p1)) - (char *)(p2)))
 
 /* some protos */
-uchar *fdata(uchar *buf,char *fmt,uchar *maxbuf);
+const uchar *fdata(const uchar *buf, const char *fmt, const uchar *maxbuf);
index 3b72d86f166292b6407bd776f4fc3be75959c253..bcea660e592141e8f5fde27f527fdf965032afed 100644 (file)
--- a/smbutil.c
+++ b/smbutil.c
@@ -50,7 +50,7 @@ static void interpret_dos_date(uint32 date,int *year,int *month,int *day,int *ho
 /*******************************************************************
   create a unix date from a dos date
 ********************************************************************/
-static time_t make_unix_date(void *date_ptr)
+static time_t make_unix_date(const void *date_ptr)
 {
   uint32 dos_date=0;
   struct tm t;
@@ -71,7 +71,7 @@ static time_t make_unix_date(void *date_ptr)
 /*******************************************************************
   create a unix date from a dos date
 ********************************************************************/
-static time_t make_unix_date2(void *date_ptr)
+static time_t make_unix_date2(const void *date_ptr)
 {
   uint32 x,x2;
 
@@ -86,7 +86,7 @@ static time_t make_unix_date2(void *date_ptr)
 interpret an 8 byte "filetime" structure to a time_t
 It's originally in "100ns units since jan 1st 1601"
 ****************************************************************************/
-static time_t interpret_long_date(char *p)
+static time_t interpret_long_date(const char *p)
 {
   double d;
   time_t ret;
@@ -167,9 +167,9 @@ static int name_extract(char *buf,int ofs,char *name)
 /****************************************************************************
 return the total storage length of a mangled name
 ****************************************************************************/
-static int name_len(unsigned char *s)
+static int name_len(const unsigned char *s)
 {
-  char *s0 = s;
+  const char *s0 = s;
   unsigned char c = *(unsigned char *)s;
   if ((c & 0xC0) == 0xC0)
     return(2);  
@@ -177,7 +177,7 @@ static int name_len(unsigned char *s)
   return(PTR_DIFF(s,s0)+1);
 }
 
-static void print_asc(unsigned char *buf,int len)
+static void print_asc(const unsigned char *buf,int len)
 {
   int i;
   for (i=0;i<len;i++)
@@ -199,7 +199,7 @@ static char *name_type_str(int name_type)
   return(f);
 }
 
-void print_data(unsigned char *buf,int len)
+void print_data(const unsigned char *buf, int len)
 {
   int i=0;
   if (len<=0) return;
@@ -246,7 +246,7 @@ static void write_bits(unsigned int val,char *fmt)
 }
 
 /* convert a unicode string */
-static char *unistr(char *s, int *len)
+static const char *unistr(const char *s, int *len)
 {
        static char buf[1000];
        int l=0;
@@ -283,7 +283,7 @@ static char *unistr(char *s, int *len)
        return buf;
 }
 
-static uchar *fdata1(uchar *buf,char *fmt,uchar *maxbuf)
+static const uchar *fdata1(const uchar *buf, const char *fmt, const uchar *maxbuf)
 {
   int reverse=0;
   char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|";
@@ -482,7 +482,7 @@ static uchar *fdata1(uchar *buf,char *fmt,uchar *maxbuf)
   return(buf);
 }
 
-uchar *fdata(uchar *buf,char *fmt,uchar *maxbuf)
+const uchar *fdata(const uchar *buf, const char *fmt, const uchar *maxbuf)
 {
   static int depth=0;
   char s[128];
@@ -493,7 +493,7 @@ uchar *fdata(uchar *buf,char *fmt,uchar *maxbuf)
     case '*':
       fmt++;
       while (buf < maxbuf) {
-       uchar *buf2;
+       const uchar *buf2;
        depth++;
        buf2 = fdata(buf,fmt,maxbuf);
        depth--;
index f331cf8ca0af592bad29815d2dc4c44730504269..714b19ee5efa285b5fba443ab24365b9e52923b8 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -24,7 +24,7 @@ static const char copyright[] =
     "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997\n\
 The Regents of the University of California.  All rights reserved.\n";
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.136 1999-12-13 18:06:15 mcr Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/tcpdump.c,v 1.137 1999-12-22 06:27:24 itojun Exp $ (LBL)";
 #endif
 
 /*
@@ -50,6 +50,7 @@ static const char rcsid[] =
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <ctype.h>
 
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
@@ -444,7 +445,25 @@ cleanup(int signo)
 void
 default_print_unaligned(register const u_char *cp, register u_int length)
 {
-  register u_int i, s;
+#if 1
+       register u_int i, s;
+       register int nshorts;
+
+       nshorts = (u_int) length / sizeof(u_short);
+       i = 0;
+       while (--nshorts >= 0) {
+               if ((i++ % 8) == 0)
+                       (void)printf("\n\t\t\t");
+               s = *cp++;
+               (void)printf(" %02x%02x", s, *cp++);
+       }
+       if (length & 1) {
+               if ((i % 8) == 0)
+                       (void)printf("\n\t\t\t");
+               (void)printf(" %02x", *cp);
+       }
+#else
+  register u_int i;
   register int nshorts;
 
   char line[81];
@@ -480,6 +499,7 @@ default_print_unaligned(register const u_char *cp, register u_int length)
     cp += 2;
     nshorts--;
   }
+#endif
 }
 
 /*
@@ -490,10 +510,6 @@ default_print_unaligned(register const u_char *cp, register u_int length)
 void
 default_print(register const u_char *bp, register u_int length)
 {
-       register const u_short *sp;
-       register u_int i;
-       register int nshorts;
-
        default_print_unaligned(bp, length);
 }