blob: ed502b96cabc8e31e68eaec2aa72d7796494ccff [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
Elliott Hughese2e3bd12017-05-15 10:59:29 -07005 * BSD-style license that accompanies tcpdump or under the GNU GPL
The Android Open Source Project2949f582009-03-03 19:30:46 -08006 * version 2 or later.
7 *
8 * print-beep.c
9 *
10 */
11
Elliott Hughese2e3bd12017-05-15 10:59:29 -070012/* \summary: Blocks Extensible Exchange Protocol (BEEP) printer */
13
The Android Open Source Project2949f582009-03-03 19:30:46 -080014#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
Elliott Hughese2e3bd12017-05-15 10:59:29 -070018#include <netdissect-stdinc.h>
The Android Open Source Project2949f582009-03-03 19:30:46 -080019
The Android Open Source Project2949f582009-03-03 19:30:46 -080020#include <string.h>
21
Elliott Hughese2e3bd12017-05-15 10:59:29 -070022#include "netdissect.h"
The Android Open Source Project2949f582009-03-03 19:30:46 -080023
24/* Check for a string but not go beyond length
25 * Return TRUE on match, FALSE otherwise
26 *
27 * Looks at the first few chars up to tl1 ...
28 */
29
The Android Open Source Project2949f582009-03-03 19:30:46 -080030static int
31l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2)
32{
33
34 if (tl1 > l2)
35 return 0;
36
37 return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0);
38}
39
40void
Elliott Hughes892a68b2015-10-19 14:43:53 -070041beep_print(netdissect_options *ndo, const u_char *bp, u_int length)
The Android Open Source Project2949f582009-03-03 19:30:46 -080042{
43
44 if (l_strnstart("MSG", 4, (const char *)bp, length)) /* A REQuest */
Elliott Hughes892a68b2015-10-19 14:43:53 -070045 ND_PRINT((ndo, " BEEP MSG"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080046 else if (l_strnstart("RPY ", 4, (const char *)bp, length))
Elliott Hughes892a68b2015-10-19 14:43:53 -070047 ND_PRINT((ndo, " BEEP RPY"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080048 else if (l_strnstart("ERR ", 4, (const char *)bp, length))
Elliott Hughes892a68b2015-10-19 14:43:53 -070049 ND_PRINT((ndo, " BEEP ERR"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080050 else if (l_strnstart("ANS ", 4, (const char *)bp, length))
Elliott Hughes892a68b2015-10-19 14:43:53 -070051 ND_PRINT((ndo, " BEEP ANS"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080052 else if (l_strnstart("NUL ", 4, (const char *)bp, length))
Elliott Hughes892a68b2015-10-19 14:43:53 -070053 ND_PRINT((ndo, " BEEP NUL"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080054 else if (l_strnstart("SEQ ", 4, (const char *)bp, length))
Elliott Hughes892a68b2015-10-19 14:43:53 -070055 ND_PRINT((ndo, " BEEP SEQ"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080056 else if (l_strnstart("END", 4, (const char *)bp, length))
Elliott Hughes892a68b2015-10-19 14:43:53 -070057 ND_PRINT((ndo, " BEEP END"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080058 else
Elliott Hughes892a68b2015-10-19 14:43:53 -070059 ND_PRINT((ndo, " BEEP (payload or undecoded)"));
The Android Open Source Project2949f582009-03-03 19:30:46 -080060}