/*
* TCPVIEW
*
* Author: Martin Hunt
* Networks and Distributed Computing
* Computing & Communications
* University of Washington
* Administration Building, AG-44
* Seattle, WA 98195
* Internet: martinh@cac.washington.edu
*
*
* Copyright 1992 by the University of Washington
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appears in all copies and that both the
* above copyright notice and this permission notice appear in supporting
* documentation, and that the name of the University of Washington not be
* used in advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. This software is made
* available "as is", and
* THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
* WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND IN
* NO EVENT SHALL THE UNIVERSITY OF WASHINGTON BE LIABLE FOR ANY SPECIAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT
* (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
#ifndef lint
static char rcsid[] =
"@(#) $Header: /usr/staff/martinh/tcpview/RCS/detail-udp.c,v 1.4 1993/04/22 20:17:56 martinh Exp $ (UW)";
#endif
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <arpa/nameser.h>
#include <arpa/tftp.h>
#include <errno.h>
#include <sys/time.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpc/auth.h>
#include <rpc/auth_unix.h>
#include <rpc/svc.h>
#include <rpc/rpc_msg.h>
#include <sys/ucred.h>
#include <sys/mount.h>
#include <nfs/rpcv2.h>
#include <nfs/nfsproto.h>
#include "interface.h"
#include "addrtoname.h"
#include "appletalk.h"
#include "bootp.h"
#include "tcpview.h"
extern u_short D_Src_Port, D_Dst_Port;
extern u_short TFTP_PORT, SNMP_PORT, NTP_PORT, SNMPTRAP_PORT, RIP_PORT, SUNRPC_PORT;
void detail_udp( up, length )
register struct udphdr *up;
u_short length;
{
register u_char *cp = (u_char *)(up + 1);
u_short sport, dport, len;
register struct rpc_msg *rp;
enum msg_type direction;
if (Phdr->caplen-Offset < sizeof(struct udphdr)) {
printf("*** UDP (truncated) ***\n");
hex(0, Phdr->caplen - Offset - 1);
return;
}
D_Src_Port = sport = ntohs(up->uh_sport);
D_Dst_Port = dport = ntohs(up->uh_dport);
len = ntohs(up->uh_ulen);
printf("----- UDP Header -----\n\n");
hex( 0, sizeof(struct udphdr) - 1); /* header */
printf("Source port = %d ( %s )\n",sport,udpport_string(sport));
printf("Destination port = %d ( %s )\n",dport,udpport_string(dport));
if(len == length)
printf("Length = %d\n",len);
else
printf("Length = %d Should be %d according to IP!\n",len,length);
printf("Checksum = %x\n\n",ntohs(up->uh_sum));
hex( -1, -1 ); /* blank line */
hex( 0, 1 ); /* source port */
hex( 2, 3 ); /* dest port */
hex( 4, 5 ); /* length */
hex( 6, 7 ); /* checksum */
hex( -1, -1 ); /* blank line */
length -= sizeof(struct udphdr);
Offset += sizeof(struct udphdr);
/*
rp = (struct rpc_msg *)(up + 1);
direction = (enum msg_type)ntohl(rp->rm_direction);
if (up->uh_dport == NFS_PORT && direction == CALL) {
nfsreq_print(rp, length, ip);
return;
}
else if (up->uh_sport == NFS_PORT && direction==REPLY) {
nfsreply_print(rp, length, ip);
return;
}
else if (cp[2] == 2 && (atalk_port(up->uh_sport) ||
atalk_port(up->uh_dport))) {
ddp_print((struct atDDP *)(&cp[3]), length - 3);
return;
}
*/
#define ISPORT(p) (dport == (p) || sport == (p))
/*
if (ISPORT(NAMESERVER_PORT))
ns_print((HEADER *)(up + 1), length);
else if (ISPORT(TFTP_PORT))
tftp_print((struct tftphdr *)(up + 1), length);
else if (ISPORT(IPPORT_BOOTPC) || ISPORT(IPPORT_BOOTPS))
bootp_print((struct bootp *)(up + 1), length,
up->uh_sport, up->uh_dport);
else
*/
if ( ISPORT(RIP_PORT) )
detail_rip((u_char *)(up + 1), length);
else if ( ISPORT(NAMESERVER_PORT) )
detail_domain((u_char *)(up + 1), length);
else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT))
detail_snmp((u_char *)(up + 1), length);
/*
else if (ISPORT(NTP_PORT))
ntp_print((struct ntpdata *)(up + 1), length);
else
(void)printf(" udp %d", up->uh_ulen - sizeof(*up));
*/
#undef ISPORT
}
syntax highlighted by Code2HTML, v. 0.9.1