]> The Tcpdump Group git mirrors - tcpdump/blob - print-beep.c
Fix a typo
[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 license that accompanies tcpdump or under the GNU GPL
6 * version 2 or later.
7 *
8 * print-beep.c
9 *
10 */
11
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15
16 #include <tcpdump-stdinc.h>
17
18 #include <string.h>
19
20 #include "netdissect.h"
21
22 /* Check for a string but not go beyond length
23 * Return TRUE on match, FALSE otherwise
24 *
25 * Looks at the first few chars up to tl1 ...
26 */
27
28 static int
29 l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2)
30 {
31
32 if (tl1 > l2)
33 return 0;
34
35 return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0);
36 }
37
38 void
39 beep_print(netdissect_options *ndo, const u_char *bp, u_int length)
40 {
41
42 if (l_strnstart("MSG", 4, (const char *)bp, length)) /* A REQuest */
43 ND_PRINT((ndo, " BEEP MSG"));
44 else if (l_strnstart("RPY ", 4, (const char *)bp, length))
45 ND_PRINT((ndo, " BEEP RPY"));
46 else if (l_strnstart("ERR ", 4, (const char *)bp, length))
47 ND_PRINT((ndo, " BEEP ERR"));
48 else if (l_strnstart("ANS ", 4, (const char *)bp, length))
49 ND_PRINT((ndo, " BEEP ANS"));
50 else if (l_strnstart("NUL ", 4, (const char *)bp, length))
51 ND_PRINT((ndo, " BEEP NUL"));
52 else if (l_strnstart("SEQ ", 4, (const char *)bp, length))
53 ND_PRINT((ndo, " BEEP SEQ"));
54 else if (l_strnstart("END", 4, (const char *)bp, length))
55 ND_PRINT((ndo, " BEEP END"));
56 else
57 ND_PRINT((ndo, " BEEP (payload or undecoded)"));
58 }