]> The Tcpdump Group git mirrors - tcpdump/commitdiff
"timed" dissector, from Ben Smithurst.
authorguy <guy>
Fri, 6 Oct 2000 05:35:36 +0000 (05:35 +0000)
committerguy <guy>
Fri, 6 Oct 2000 05:35:36 +0000 (05:35 +0000)
CREDITS
FILES
Makefile.in
interface.h
print-timed.c [new file with mode: 0644]
print-udp.c
timed.h [new file with mode: 0644]

diff --git a/CREDITS b/CREDITS
index cea3ddbfebd25f64929eba020de3386112ac7667..852ede73e8e5ab51b682392c74f0bb1f71eb204f 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -13,6 +13,7 @@ Additional people who have contributed patches:
 
        Alfredo Andres                  <[email protected]>
        Andrew Tridgell                 <[email protected]>
+        Ben Smithurst                  <[email protected]>
        Chris G. Demetriou              <[email protected]>
        Craig Rodrigues                 <[email protected]>
        Francisco Matias Cuenca-Acuna   <[email protected]>
diff --git a/FILES b/FILES
index 76091e5fde31615254db6d4b541d28c910b69659..a30a75cafce0ed4109313a4b57e29c442ceecf05 100644 (file)
--- a/FILES
+++ b/FILES
@@ -144,6 +144,7 @@ print-sunrpc.c
 print-tcp.c
 print-telnet.c
 print-tftp.c
+print-timed.c
 print-token.c
 print-udp.c
 print-vjc.c
@@ -163,6 +164,7 @@ strcasecmp.c
 tcp.h
 tcpdump.1
 tcpdump.c
+timed.h
 token.h
 udp.h
 util.c
index c08689b77bfb68cad702e589cc22c6109c463ebd..397de442e451a1a8966ebef4c0bbbf6e43c654b2 100644 (file)
@@ -17,7 +17,7 @@
 #  WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 #
-# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.240 2000-09-30 03:35:55 guy Exp $ (LBL)
+# @(#) $Header: /tcpdump/master/tcpdump/Makefile.in,v 1.241 2000-10-06 05:35:36 guy Exp $ (LBL)
 
 #
 # Various configurable paths (remember to edit Makefile.in, not Makefile)
@@ -79,7 +79,7 @@ CSRC =        tcpdump.c \
        print-ipcomp.c print-mobile.c print-l2tp.c print-bgp.c print-rx.c \
        print-lane.c print-cip.c print-pppoe.c print-lcp.c \
        print-smb.c smbutil.c print-ascii.c print-telnet.c print-cnfp.c \
-       print-vrrp.c print-cdp.c print-token.c print-bxxp.c
+       print-vrrp.c print-cdp.c print-token.c print-bxxp.c print-timed.c
 
 LOCALSRC = @LOCALSRC@
 GENSRC = version.c
index 7893d5fec914071c9ed7568550090e96008c1137..3281db8e5f9c07393dd38d7541684f3413e84ff6 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.138 2000-10-05 04:10:00 itojun Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.139 2000-10-06 05:35:37 guy Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -261,6 +261,7 @@ extern void snmp_print(const u_char *, u_int);
 extern void sunrpcrequest_print(const u_char *, u_int, const u_char *);
 extern void tcp_print(const u_char *, u_int, const u_char *);
 extern void tftp_print(const u_char *, u_int);
+extern void timed_print(const u_char *, u_int);
 extern void udp_print(const u_char *, u_int, const u_char *);
 extern void wb_print(const void *, u_int);
 extern int ah_print(register const u_char *, register const u_char *);
diff --git a/print-timed.c b/print-timed.c
new file mode 100644 (file)
index 0000000..35ab4b0
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2000 Ben Smithurst <[email protected]>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
+ * the University nor the names of its contributors may be used to endorse
+ * or promote products derived from this software without specific prior
+ * written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static const char rcsid[] =
+    "@(#) $Header: /tcpdump/master/tcpdump/print-timed.c,v 1.1 2000-10-06 05:35:37 guy Exp $";
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/param.h>
+#include <sys/time.h>
+
+#include <netinet/in.h>
+#include "ip.h"
+#include "udp.h"
+#include "tcp.h"
+
+#include "timed.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include "interface.h"
+#include "addrtoname.h"
+#include "extract.h"                    /* must come after interface.h */
+
+static char *tsptype[TSPTYPENUMBER] =
+  { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP",
+  "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT",
+  "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ",
+  "TEST", "SETDATE", "SETDATEREQ", "LOOP" };
+
+void
+timed_print(register const u_char *bp, u_int length)
+{
+#define endof(x) ((u_char *)&(x) + sizeof (x))
+       struct tsp *tsp = (struct tsp *)bp;
+       long sec, usec;
+       const u_char *end;
+
+       if (endof(tsp->tsp_type) > snapend) {
+               fputs("[|timed]", stdout);
+               return;
+       }
+       if (tsp->tsp_type < TSPTYPENUMBER)
+               printf("TSP_%s", tsptype[tsp->tsp_type]);
+       else
+               printf("(tsp_type %#x)", tsp->tsp_type);
+
+       if (endof(tsp->tsp_vers) > snapend) {
+               fputs(" [|timed]", stdout);
+               return;
+       }
+       printf(" vers %d", tsp->tsp_vers);
+
+       if (endof(tsp->tsp_seq) > snapend) {
+               fputs(" [|timed]", stdout);
+               return;
+       }
+       printf(" seq %d", tsp->tsp_seq);
+
+       if (tsp->tsp_type == TSP_LOOP) {
+               if (endof(tsp->tsp_hopcnt) > snapend) {
+                       fputs(" [|timed]", stdout);
+                       return;
+               }
+               printf(" hopcnt %d", tsp->tsp_hopcnt);
+       } else if (tsp->tsp_type == TSP_SETTIME ||
+         tsp->tsp_type == TSP_ADJTIME ||
+         tsp->tsp_type == TSP_SETDATE ||
+         tsp->tsp_type == TSP_SETDATEREQ) {
+               if (endof(tsp->tsp_time) > snapend) {
+                       fputs(" [|timed]", stdout);
+                       return;
+               }
+               sec = ntohl((long)tsp->tsp_time.tv_sec);
+               usec = ntohl((long)tsp->tsp_time.tv_usec);
+               if (usec < 0)
+                       /* corrupt, skip the rest of the packet */
+                       return;
+               fputs(" time ", stdout);
+               if (sec < 0 && usec != 0) {
+                       sec++;
+                       if (sec == 0)
+                               fputc('-', stdout);
+                       usec = 1000000 - usec;
+               }
+               printf("%ld.%06ld", sec, usec);
+       }
+
+       end = memchr(tsp->tsp_name, '\0', snapend - (u_char *)tsp->tsp_name);
+       if (end == NULL)
+               fputs(" [|timed]", stdout);
+       else {
+               fputs(" name ", stdout);
+               fwrite(tsp->tsp_name, end - (u_char *)tsp->tsp_name, 1, stdout);
+       }
+}
index d7eec1d9d8943319d7822d2b2e79d548137b0f56..2a99488a910f96939d1b1d27c216907f8e8c10a3 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.82 2000-10-03 04:19:08 itojun Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-udp.c,v 1.83 2000-10-06 05:35:37 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -394,6 +394,7 @@ static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
 #define NTP_PORT 123           /*XXX*/
 #define SNMPTRAP_PORT 162      /*XXX*/
 #define ISAKMP_PORT 500                /*XXX*/
+#define TIMED_PORT 525         /*XXX*/
 #define RIP_PORT 520           /*XXX*/
 #define KERBEROS_SEC_PORT 750  /*XXX*/
 #define L2TP_PORT 1701         /*XXX*/
@@ -628,6 +629,8 @@ udp_print(register const u_char *bp, u_int length, register const u_char *bp2)
 #define ISPORT(p) (dport == (p) || sport == (p))
                if (ISPORT(NAMESERVER_PORT))
                        ns_print((const u_char *)(up + 1), length);
+               else if (ISPORT(TIMED_PORT))
+                       timed_print((const u_char *)(up + 1), length);
                else if (ISPORT(TFTP_PORT))
                        tftp_print((const u_char *)(up + 1), length);
                else if (ISPORT(IPPORT_BOOTPC) || ISPORT(IPPORT_BOOTPS))
diff --git a/timed.h b/timed.h
new file mode 100644 (file)
index 0000000..7ff8293
--- /dev/null
+++ b/timed.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 1983, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)timed.h     8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef        _PROTOCOLS_TIMED_H_
+#define        _PROTOCOLS_TIMED_H_
+
+/*
+ * Time Synchronization Protocol
+ */
+
+#define        TSPVERSION      1
+#define ANYADDR        NULL
+
+struct tsp {
+       u_char  tsp_type;
+       u_char  tsp_vers;
+       u_short tsp_seq;
+       union {
+               struct timeval tspu_time;
+               char tspu_hopcnt;
+       } tsp_u;
+       char tsp_name[MAXHOSTNAMELEN];
+};
+
+#define        tsp_time        tsp_u.tspu_time
+#define        tsp_hopcnt      tsp_u.tspu_hopcnt
+
+/*
+ * Command types.
+ */
+#define        TSP_ANY                 0       /* match any types */
+#define        TSP_ADJTIME             1       /* send adjtime */
+#define        TSP_ACK                 2       /* generic acknowledgement */
+#define        TSP_MASTERREQ           3       /* ask for master's name */
+#define        TSP_MASTERACK           4       /* acknowledge master request */
+#define        TSP_SETTIME             5       /* send network time */
+#define        TSP_MASTERUP            6       /* inform slaves that master is up */
+#define        TSP_SLAVEUP             7       /* slave is up but not polled */
+#define        TSP_ELECTION            8       /* advance candidature for master */
+#define        TSP_ACCEPT              9       /* support candidature of master */
+#define        TSP_REFUSE              10      /* reject candidature of master */
+#define        TSP_CONFLICT            11      /* two or more masters present */
+#define        TSP_RESOLVE             12      /* masters' conflict resolution */
+#define        TSP_QUIT                13      /* reject candidature if master is up */
+#define        TSP_DATE                14      /* reset the time (date command) */
+#define        TSP_DATEREQ             15      /* remote request to reset the time */
+#define        TSP_DATEACK             16      /* acknowledge time setting  */
+#define        TSP_TRACEON             17      /* turn tracing on */
+#define        TSP_TRACEOFF            18      /* turn tracing off */
+#define        TSP_MSITE               19      /* find out master's site */
+#define        TSP_MSITEREQ            20      /* remote master's site request */
+#define        TSP_TEST                21      /* for testing election algo */
+#define        TSP_SETDATE             22      /* New from date command */
+#define        TSP_SETDATEREQ          23      /* New remote for above */
+#define        TSP_LOOP                24      /* loop detection packet */
+
+#define        TSPTYPENUMBER           25
+
+#endif /* !_TIMED_H_ */