checkpoint of hacking for mail.cs.berkeley.edu
[unix-history] / usr / src / sbin / XNSrouted / trace.h
CommitLineData
e69f81e0 1/*
3565c602
KB
2 * Copyright (c) 1983 The Regents of the University of California.
3 * All rights reserved.
e69f81e0 4 *
3565c602
KB
5 * This file includes significant work done at Cornell University by
6 * Bill Nesheim. That work included by permission.
e69f81e0 7 *
6ecf3d85 8 * %sccs.include.redist.c%
3565c602 9 *
6ecf3d85 10 * @(#)trace.h 5.6 (Berkeley) %G%
e69f81e0 11 */
42d71268
KS
12
13/*
14 * Xerox Routing Information Protocol.
15 */
16
17/*
18 * Trace record format.
19 */
20struct iftrace {
21 time_t ift_stamp; /* time stamp */
22 struct sockaddr ift_who; /* from/to */
23 char *ift_packet; /* pointer to packet */
24 short ift_size; /* size of packet */
25 short ift_metric; /* metric */
26};
27
28/*
29 * Per interface packet tracing buffers. An incoming and
30 * outgoing circular buffer of packets is maintained, per
31 * interface, for debugging. Buffers are dumped whenever
32 * an interface is marked down.
33 */
34struct ifdebug {
35 struct iftrace *ifd_records; /* array of trace records */
36 struct iftrace *ifd_front; /* next empty trace record */
37 int ifd_count; /* number of unprinted records */
38 struct interface *ifd_if; /* for locating stuff */
39};
40
41/*
42 * Packet tracing stuff.
43 */
44int tracepackets; /* watch packets as they go by */
45int tracing; /* on/off */
46FILE *ftrace; /* output trace file */
47
48#define TRACE_ACTION(action, route) { \
49 if (tracing) \
50 traceaction(ftrace, "action", route); \
51 }
52#define TRACE_INPUT(ifp, src, size) { \
53 if (tracing) { \
54 ifp = if_iflookup(src); \
55 if (ifp) \
56 trace(&ifp->int_input, src, &packet[sizeof(struct idp)], size, \
57 ntohl(ifp->int_metric)); \
58 } \
610b111d
KS
59 if (tracepackets && ftrace) \
60 dumppacket(ftrace, "from", src, &packet[sizeof(struct idp)], size); \
42d71268
KS
61 }
62#define TRACE_OUTPUT(ifp, dst, size) { \
63 if (tracing) { \
64 ifp = if_iflookup(dst); \
65 if (ifp) \
66 trace(&ifp->int_output, dst, &packet[sizeof(struct idp)], size, ifp->int_metric); \
67 } \
610b111d
KS
68 if (tracepackets && ftrace) \
69 dumppacket(ftrace, "to", dst, &packet[sizeof(struct idp)], size); \
42d71268 70 }