summaryrefslogtreecommitdiffstats
path: root/listen/udpdump.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1999-06-07 10:23:42 +0200
committerRalf Baechle <ralf@linux-mips.org>1999-06-07 10:23:42 +0200
commit0fceb64d25ff3d9586549bb43d971c5eef904330 (patch)
treed4799d0fd53a3d8ae342c84f8ad4fb2ca2f14de0 /listen/udpdump.c
Import ax25-apps 0.0.1 from tarballax25-apps-0.0.1
Diffstat (limited to 'listen/udpdump.c')
-rw-r--r--listen/udpdump.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/listen/udpdump.c b/listen/udpdump.c
new file mode 100644
index 0000000..7b1c184
--- /dev/null
+++ b/listen/udpdump.c
@@ -0,0 +1,44 @@
+/* @(#) $Header: udpdump.c,v 1.5 91/05/09 07:39:11 deyke 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;
+ }
+ }
+}