blob: 7982feb5c362333c1bb246fd0480a0f5517ddc23 [file] [log] [blame]
The Android Open Source Project2949f582009-03-03 19:30:46 -08001/*
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
Elliott Hughes892a68b2015-10-19 14:43:53 -070012#define NETDISSECT_REWORKED
The Android Open Source Project2949f582009-03-03 19:30:46 -080013#ifdef HAVE_CONFIG_H
14#include "config.h"
15#endif
16
17#include <tcpdump-stdinc.h>
18
The Android Open Source Project2949f582009-03-03 19:30:46 -080019#include <string.h>
20
21#include "interface.h"
The Android Open Source Project2949f582009-03-03 19:30:46 -080022
23/* Check for a string but not go beyond length
24 * Return TRUE on match, FALSE otherwise
25 *
26 * Looks at the first few chars up to tl1 ...
27 */
28
The Android Open Source Project2949f582009-03-03 19:30:46 -080029static int
30l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2)
31{
32
33 if (tl1 > l2)
34 return 0;
35
36 return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0);
37}
38
39void
Elliott Hughes892a68b2015-10-19 14:43:53 -070040beep_print(netdissect_options *ndo, const u_char *bp, u_int length)
The Android Open Source Project2949f582009-03-03 19:30:46 -080041{
42
43 if (l_strnstart("MSG", 4, (const char *)bp, length)) /* A REQuest */
Elliott Hughes892a68b2015-10-19 14:43:53 -070044 ND_PRINT((ndo, " BEEP MSG"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080045 else if (l_strnstart("RPY ", 4, (const char *)bp, length))
Elliott Hughes892a68b2015-10-19 14:43:53 -070046 ND_PRINT((ndo, " BEEP RPY"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080047 else if (l_strnstart("ERR ", 4, (const char *)bp, length))
Elliott Hughes892a68b2015-10-19 14:43:53 -070048 ND_PRINT((ndo, " BEEP ERR"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080049 else if (l_strnstart("ANS ", 4, (const char *)bp, length))
Elliott Hughes892a68b2015-10-19 14:43:53 -070050 ND_PRINT((ndo, " BEEP ANS"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080051 else if (l_strnstart("NUL ", 4, (const char *)bp, length))
Elliott Hughes892a68b2015-10-19 14:43:53 -070052 ND_PRINT((ndo, " BEEP NUL"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080053 else if (l_strnstart("SEQ ", 4, (const char *)bp, length))
Elliott Hughes892a68b2015-10-19 14:43:53 -070054 ND_PRINT((ndo, " BEEP SEQ"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080055 else if (l_strnstart("END", 4, (const char *)bp, length))
Elliott Hughes892a68b2015-10-19 14:43:53 -070056 ND_PRINT((ndo, " BEEP END"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080057 else
Elliott Hughes892a68b2015-10-19 14:43:53 -070058 ND_PRINT((ndo, " BEEP (payload or undecoded)"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080059}