Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / tcpdump / print-beep.c
blob6d3991f63c3c8c5d9d6e5a29c700051404d42253
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2000, Richard Sharpe
6 * This software may be distributed either under the terms of the
7 * BSD-style licence that accompanies tcpdump or under the GNU GPL
8 * version 2 or later.
10 * print-beep.c
14 #include <sys/cdefs.h>
15 #ifndef lint
16 #if 0
17 static const char rcsid[] _U_ =
18 "@(#) Header: /tcpdump/master/tcpdump/print-beep.c,v 1.6 2003/11/16 09:36:13 guy Exp";
19 #else
20 __RCSID("$NetBSD: tcpdump2rcsid.ex,v 1.1 2001/06/25 20:09:58 itojun Exp $");
21 #endif
22 #endif
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
28 #include <tcpdump-stdinc.h>
30 #ifdef HAVE_MEMORY_H
31 #include <memory.h>
32 #endif
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
37 #include "interface.h"
38 #include "extract.h"
40 /* Check for a string but not go beyond length
41 * Return TRUE on match, FALSE otherwise
43 * Looks at the first few chars up to tl1 ...
46 static int l_strnstart(const char *, u_int, const char *, u_int);
48 static int
49 l_strnstart(const char *tstr1, u_int tl1, const char *str2, u_int l2)
52 if (tl1 > l2)
53 return 0;
55 return (strncmp(tstr1, str2, tl1) == 0 ? 1 : 0);
58 void
59 beep_print(const u_char *bp, u_int length)
62 if (l_strnstart("MSG", 4, (const char *)bp, length)) /* A REQuest */
63 printf(" BEEP MSG");
64 else if (l_strnstart("RPY ", 4, (const char *)bp, length))
65 printf(" BEEP RPY");
66 else if (l_strnstart("ERR ", 4, (const char *)bp, length))
67 printf(" BEEP ERR");
68 else if (l_strnstart("ANS ", 4, (const char *)bp, length))
69 printf(" BEEP ANS");
70 else if (l_strnstart("NUL ", 4, (const char *)bp, length))
71 printf(" BEEP NUL");
72 else if (l_strnstart("SEQ ", 4, (const char *)bp, length))
73 printf(" BEEP SEQ");
74 else if (l_strnstart("END", 4, (const char *)bp, length))
75 printf(" BEEP END");
76 else
77 printf(" BEEP (payload or undecoded)");