1 /* $NetBSD: moptrace.c,v 1.9 2003/04/20 00:20:29 christos Exp $ */
4 * Copyright (c) 1993-95 Mats O Jansson. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include <sys/cdefs.h>
29 __RCSID("$NetBSD: moptrace.c,v 1.9 2003/04/20 00:20:29 christos Exp $");
33 * moptrace - MOP Trace Utility
35 * Usage: moptrace -a [ -d ] [ -3 | -4 ]
36 * moptrace [ -d ] [ -3 | -4 ] interface
51 * The list of all interfaces that are being listened to.
52 * "selects" on the descriptors in this list.
54 struct if_info
*iflist
;
56 void Usage
__P((void));
57 int main
__P((int, char **));
58 void mopProcess
__P((struct if_info
*, u_char
*));
60 int AllFlag
= 0; /* listen on "all" interfaces */
61 int DebugFlag
= 0; /* print debugging messages */
62 int Not3Flag
= 0; /* Ignore MOP V3 messages */
63 int Not4Flag
= 0; /* Ignore MOP V4 messages */
64 int promisc
= 1; /* Need promisc mode */
76 while ((op
= getopt(argc
, argv
, "34ad")) != -1) {
96 interface
= argv
[optind
++];
98 if ((AllFlag
&& interface
) ||
99 (!AllFlag
&& interface
== 0) ||
100 (Not3Flag
&& Not4Flag
))
106 deviceInitOne(interface
);
116 (void) fprintf(stderr
, "usage: %s -a [ -d ] [ -3 | -4 ]\n",
118 (void) fprintf(stderr
, " %s [ -d ] [ -3 | -4 ] interface\n",
124 * Process incoming packages.
133 /* We don't known which transport, Guess! */
135 trans
= mopGetTrans(pkt
, 0);
137 /* Ok, return if we don't want this message */
139 if ((trans
== TRANS_ETHER
) && Not3Flag
) return;
140 if ((trans
== TRANS_8023
) && Not4Flag
) return;
142 mopPrintHeader(stdout
, pkt
, trans
);
143 mopPrintMopHeader(stdout
, pkt
, trans
);
145 mopDumpDL(stdout
, pkt
, trans
);
146 mopDumpRC(stdout
, pkt
, trans
);
148 fprintf(stdout
, "\n");