]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/tcpdump/print-bxxp.c
This commit was generated by cvs2svn to compensate for changes in r98524,
[FreeBSD/FreeBSD.git] / contrib / 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/print-bxxp.c,v 1.3 2000/10/05 04:10:01 itojun 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 "interface.h"
33 #include "extract.h"
34
35 /* Check for a string but not go beyond length
36  * Return TRUE on match, FALSE otherwise
37  * 
38  * Looks at the first few chars up to tl1 ...
39  */
40
41 int l_strnstart(const u_char *, u_int, const u_char *, u_int);
42
43 int
44 l_strnstart(register const u_char *tstr1, register u_int tl1,
45           register const u_char *str2, register u_int l2)
46 {
47
48   if (tl1 > l2)
49     return 0;
50   
51   return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0);
52
53 }
54
55 void
56 bxxp_print(register const u_char *bp, register u_int length)
57 {
58
59   if (l_strnstart("REQ ", 4, bp, length)) { /* A REQuest */
60
61     printf(" BXXP REQ");
62
63   } 
64   else if (l_strnstart("RSP ", 4, bp, length)) {
65
66     printf(" BXXP RSP");
67
68   }
69   else if (l_strnstart("SEQ ", 4, bp, length)) {
70
71     printf(" BXXP SEQ");
72
73   }
74   else if (l_strnstart("END", 4, bp, length)) {
75
76     printf(" BXXP END");
77
78   }
79   else 
80     printf(" BXXP (payload or undecoded)");
81
82 }