#ifndef lint
-static char sccsid[] = "@(#)main.c 4.2 %G%";
+static char sccsid[] = "@(#)main.c 4.3 %G%";
#endif
/*
#endif
argv0 = argv;
-#ifndef DEBUG
- if (fork())
- exit(0);
- for (cc = 0; cc < 10; cc++)
- (void) close(cc);
- (void) open("/", 0);
- (void) dup2(0, 1);
- (void) dup2(0, 2);
- { int t = open("/dev/tty", 2);
- if (t >= 0) {
- ioctl(t, TIOCNOTTY, (char *)0);
- (void) close(t);
- }
- }
-#endif
sp = getservbyname("router", "udp");
if (sp == NULL) {
fprintf(stderr, "routed: router/udp: unknown service\n");
#endif
argv++, argc--;
while (argc > 0 && **argv == '-') {
- if (!strcmp(*argv, "-s") == 0) {
+ if (strcmp(*argv, "-s") == 0) {
supplier = 1;
argv++, argc--;
continue;
}
- if (!strcmp(*argv, "-q") == 0) {
+ if (strcmp(*argv, "-q") == 0) {
supplier = 0;
argv++, argc--;
continue;
}
- fprintf(stderr, "usage: routed [ -s ] [ -q ]\n");
+ if (strcmp(*argv, "-t") == 0) {
+ tracepackets++;
+ argv++, argc--;
+ continue;
+ }
+ fprintf(stderr, "usage: routed [ -s ] [ -q ] [ -t ]\n");
exit(1);
}
+#ifndef DEBUG
+ if (!tracepackets) {
+ int t;
+
+ if (fork())
+ exit(0);
+ for (cc = 0; cc < 10; cc++)
+ (void) close(cc);
+ (void) open("/", 0);
+ (void) dup2(0, 1);
+ (void) dup2(0, 2);
+ t = open("/dev/tty", 2);
+ if (t >= 0) {
+ ioctl(t, TIOCNOTTY, (char *)0);
+ (void) close(t);
+ }
+ }
+#endif
/*
* Any extra argument is considered
* a tracing log file.
-/* trace.h 4.1 83/01/11 */
+/* trace.h 4.2 83/01/31 */
/*
* Routing table management daemon.
/*
* Packet tracing stuff.
*/
+int tracepackets; /* watch packets as they go by */
int tracing; /* on/off */
FILE *ftrace; /* output trace file */
+
#define TRACE_ACTION(action, route) { \
if (tracing) \
traceaction(ftrace, "action", route); \
}
-#define TRACE_INPUT(ifp, from, size) { \
+#define TRACE_INPUT(ifp, src, size) { \
if (tracing) { \
- ifp = if_iflookup(from); \
+ ifp = if_iflookup(src); \
if (ifp) \
- trace(&ifp->int_input, from, packet, size, \
+ trace(&ifp->int_input, src, packet, size, \
ifp->int_metric); \
} \
+ if (tracepackets) \
+ dumppacket(stdout, "from", src, packet, size); \
}
-#define TRACE_OUTPUT(ifp, to, size) { \
+#define TRACE_OUTPUT(ifp, dst, size) { \
if (tracing) \
- trace(&ifp->int_output, to, packet, size, ifp->int_metric); \
+ trace(&ifp->int_output, dst, packet, size, ifp->int_metric); \
+ if (tracepackets) \
+ dumppacket(stdout, "to", dst, packet, size); \
}