]> The Tcpdump Group git mirrors - tcpdump/blob - print-beep.c
remove tcpdump's own CVS keywords
[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 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15
16 #include <tcpdump-stdinc.h>
17
18 #ifdef HAVE_MEMORY_H
19 #include <memory.h>
20 #endif
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24
25 #include "interface.h"
26 #include "extract.h"
27
28 /* Check for a string but not go beyond length
29 * Return TRUE on match, FALSE otherwise
30 *
31 * Looks at the first few chars up to tl1 ...
32 */
33
34 static int l_strnstart(const char *, u_int, const char *, u_int);
35
36 static int
37 l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2)
38 {
39
40 if (tl1 > l2)
41 return 0;
42
43 return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0);
44 }
45
46 void
47 beep_print(const u_char *bp, u_int length)
48 {
49
50 if (l_strnstart("MSG", 4, (const char *)bp, length)) /* A REQuest */
51 printf(" BEEP MSG");
52 else if (l_strnstart("RPY ", 4, (const char *)bp, length))
53 printf(" BEEP RPY");
54 else if (l_strnstart("ERR ", 4, (const char *)bp, length))
55 printf(" BEEP ERR");
56 else if (l_strnstart("ANS ", 4, (const char *)bp, length))
57 printf(" BEEP ANS");
58 else if (l_strnstart("NUL ", 4, (const char *)bp, length))
59 printf(" BEEP NUL");
60 else if (l_strnstart("SEQ ", 4, (const char *)bp, length))
61 printf(" BEEP SEQ");
62 else if (l_strnstart("END", 4, (const char *)bp, length))
63 printf(" BEEP END");
64 else
65 printf(" BEEP (payload or undecoded)");
66 }