diff options
-rw-r--r-- | usr.sbin/tcpdump/Makefile | 4 | ||||
-rw-r--r-- | usr.sbin/tcpdump/interface.h | 5 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-timed.c | 122 | ||||
-rw-r--r-- | usr.sbin/tcpdump/print-udp.c | 7 |
4 files changed, 132 insertions, 6 deletions
diff --git a/usr.sbin/tcpdump/Makefile b/usr.sbin/tcpdump/Makefile index 52e4c803887..7062907afba 100644 --- a/usr.sbin/tcpdump/Makefile +++ b/usr.sbin/tcpdump/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.25 2000/12/07 22:36:45 mickey Exp $ +# $OpenBSD: Makefile,v 1.26 2000/12/07 22:52:00 mickey Exp $ # # Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994 # The Regents of the University of California. All rights reserved. @@ -36,7 +36,7 @@ DPADD+= ${LIBL} ${LIBPCAP} SRCS= tcpdump.c addrtoname.c \ print-ether.c print-ip.c print-arp.c print-tcp.c print-udp.c \ print-atalk.c print-domain.c print-tftp.c print-bootp.c print-nfs.c \ - print-icmp.c print-sl.c print-ppp.c print-rip.c \ + print-icmp.c print-sl.c print-ppp.c print-rip.c print-timed.c \ print-snmp.c print-ntp.c print-null.c print-egp.c print-ospf.c \ print-fddi.c print-llc.c print-smb.c smbutil.c print-sunrpc.c \ print-vrrp.c print-wb.c print-decnet.c print-isoclns.c print-ipx.c \ diff --git a/usr.sbin/tcpdump/interface.h b/usr.sbin/tcpdump/interface.h index 4f2d24937d1..de1013a2264 100644 --- a/usr.sbin/tcpdump/interface.h +++ b/usr.sbin/tcpdump/interface.h @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.h,v 1.20 2000/12/07 22:36:45 mickey Exp $ */ +/* $OpenBSD: interface.h,v 1.21 2000/12/07 22:52:00 mickey Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -20,7 +20,7 @@ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * @(#) $Header: /home/cvs/src/usr.sbin/tcpdump/interface.h,v 1.20 2000/12/07 22:36:45 mickey Exp $ (LBL) + * @(#) $Header: /home/cvs/src/usr.sbin/tcpdump/interface.h,v 1.21 2000/12/07 22:52:00 mickey Exp $ (LBL) */ #ifndef tcpdump_interface_h @@ -226,6 +226,7 @@ extern void sunrpcrequest_print(const u_char *, u_int, const u_char *); extern void cnfp_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 void isakmp_print(const u_char *, u_int); diff --git a/usr.sbin/tcpdump/print-timed.c b/usr.sbin/tcpdump/print-timed.c new file mode 100644 index 00000000000..3f47fd54d67 --- /dev/null +++ b/usr.sbin/tcpdump/print-timed.c @@ -0,0 +1,122 @@ +/* $OpenBSD: print-timed.c,v 1.1 2000/12/07 22:52:00 mickey Exp $ */ + +/* + * Copyright (c) 2000 Ben Smithurst <ben@scientia.demon.co.uk> + * 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. + * + * from tcpdump.org: + * Header: /tcpdump/master/tcpdump/print-timed.c,v 1.1 2000/10/06 05:35:37 guy Exp + * + */ + +#ifndef lint +static const char rcsid[] = + "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-timed.c,v 1.1 2000/12/07 22:52:00 mickey Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <sys/param.h> +#include <sys/time.h> + +#include <netinet/in.h> + +#include <protocols/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("%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); + } +} diff --git a/usr.sbin/tcpdump/print-udp.c b/usr.sbin/tcpdump/print-udp.c index ebee613b14f..8c126daf39a 100644 --- a/usr.sbin/tcpdump/print-udp.c +++ b/usr.sbin/tcpdump/print-udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print-udp.c,v 1.16 2000/12/07 22:36:46 mickey Exp $ */ +/* $OpenBSD: print-udp.c,v 1.17 2000/12/07 22:52:00 mickey Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996 @@ -23,7 +23,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-udp.c,v 1.16 2000/12/07 22:36:46 mickey Exp $ (LBL)"; + "@(#) $Header: /home/cvs/src/usr.sbin/tcpdump/print-udp.c,v 1.17 2000/12/07 22:52:00 mickey Exp $ (LBL)"; #endif #include <sys/param.h> @@ -349,6 +349,7 @@ static int udp_cksum(register const struct ip *ip, #define KERBEROS_SEC_PORT 750 /*XXX*/ #define L2TP_PORT 1701 /*XXX*/ #define ISAKMP_PORT 500 /*XXX*/ +#define TIMED_PORT 525 /*XXX*/ #define NETBIOS_NS_PORT 137 /*XXX*/ #define NETBIOS_DGRAM_PORT 138 /*XXX*/ #define OLD_RADIUS_AUTH_PORT 1645 @@ -561,6 +562,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)) |