]> The Tcpdump Group git mirrors - tcpdump/blob - print-beep.c
Get rid of unneeded includes of <netinet/in_systm.h> and <netinet/ip.h>.
[tcpdump] / print-beep.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-beep.c
9 *
10 */
11
12 #ifndef lint
13 static const char rcsid[] =
14 "@(#) $Header: /tcpdump/master/tcpdump/print-beep.c,v 1.1 2001-12-10 08:21:24 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 "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 static int l_strnstart(const char *, u_int, const char *, u_int);
42
43 static int
44 l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2)
45 {
46
47 if (tl1 > l2)
48 return 0;
49
50 return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0);
51 }
52
53 void
54 beep_print(const u_char *bp, u_int length)
55 {
56
57 if (l_strnstart("MSG", 4, bp, length)) /* A REQuest */
58 printf(" BEEP MSG");
59 else if (l_strnstart("RPY ", 4, bp, length))
60 printf(" BEEP RPY");
61 else if (l_strnstart("ERR ", 4, bp, length))
62 printf(" BEEP ERR");
63 else if (l_strnstart("ANS ", 4, bp, length))
64 printf(" BEEP ANS");
65 else if (l_strnstart("NUL ", 4, bp, length))
66 printf(" BEEP NUL");
67 else if (l_strnstart("SEQ ", 4, bp, length))
68 printf(" BEEP SEQ");
69 else if (l_strnstart("END", 4, bp, length))
70 printf(" BEEP END");
71 else
72 printf(" BEEP (payload or undecoded)");
73 }