]> The Tcpdump Group git mirrors - tcpdump/blob - print-bxxp.c
BXXP support, from Richard Sharpe <[email protected]>.
[tcpdump] / print-bxxp.c
1 /*
2 * Copyright (C) 2000, Richard Sharpe
3 *
4 * This software may be distributed either under the terms of the
5 * BSD-style licence that accompanies tcpdump or under the GNU GPL
6 * version 2 or later.
7 *
8 * print-bxxp.c
9 *
10 */
11
12 #ifndef lint
13 static const char rcsid[] =
14 "@(#) $Header: /tcpdump/master/tcpdump/Attic/print-bxxp.c,v 1.1 2000-09-30 03:35:56 guy Exp $";
15 #endif
16
17 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
20
21 #include <sys/param.h>
22 #include <sys/time.h>
23
24 #ifdef HAVE_MEMORY_H
25 #include <memory.h>
26 #endif
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <unistd.h>
31
32 #include "extract.h"
33
34 /* Check for a string but not go beyond length
35 * Return TRUE on match, FALSE otherwise
36 *
37 * Looks at the first few chars up to tl1 ...
38 */
39 int
40 l_strnstart(register const u_char *tstr1, register u_int tl1,
41 register const u_char *str2, register u_int l2)
42 {
43
44 if (tl1 > l2)
45 return 0;
46
47 return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0);
48
49 }
50
51 void
52 bxxp_print(register const u_char *bp, register u_int length)
53 {
54
55 if (l_strnstart("REQ ", 4, bp, length)) { /* A REQuest */
56
57 printf(" BXXP REQ");
58
59 }
60 else if (l_strnstart("RSP ", 4, bp, length)) {
61
62 printf(" BXXP RSP");
63
64 }
65 else if (l_strnstart("SEQ ", 4, bp, length)) {
66
67 printf(" BXXP SEQ");
68
69 }
70 else if (l_strnstart("END", 4, bp, length)) {
71
72 printf(" BXXP END");
73
74 }
75 else
76 printf(" BXXP (payload or undecoded)");
77
78 }