File: udpdump.c

package info (click to toggle)
ax25-apps 0.0.6-9
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,360 kB
  • ctags: 746
  • sloc: ansic: 9,291; sh: 8,770; makefile: 155
file content (45 lines) | stat: -rw-r--r-- 887 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* @(#) $Header: /cvsroot/ax25/ax25-apps/listen/udpdump.c,v 1.2 2001/09/12 13:18:44 terry Exp $ */

/* UDP packet tracing
 * Copyright 1991 Phil Karn, KA9Q
 */
#include <stdio.h>
#include "listen.h"

#define	RIP_PORT	520

#define	UDPHDR		8

/* Dump a UDP header */
void udp_dump(unsigned char *data, int length, int hexdump)
{
	int hdr_length;
	int source;
	int dest;

	hdr_length = get16(data + 4);
	source = get16(data + 0);
	dest = get16(data + 2);

	lprintf(T_PROTOCOL, "UDP:");

	lprintf(T_TCPHDR, " len %d %s->", hdr_length,
		servname(source, "udp"));
	lprintf(T_TCPHDR, "%s", servname(dest, "udp"));

	if (hdr_length > UDPHDR) {
		length -= UDPHDR;
		data += UDPHDR;

		switch (dest) {
		case RIP_PORT:
			lprintf(T_TCPHDR, "\n");
			rip_dump(data, length);
			break;
		default:
			lprintf(T_TCPHDR, " Data %d\n", length);
			data_dump(data, length, hexdump);
			break;
		}
	}
}