Commit | Line | Data |
---|---|---|
5ff67f98 | 1 | /* |
3256e1bb | 2 | * Copyright (c) 1983, 1988 Regents of the University of California. |
0eb85d71 | 3 | * All rights reserved. |
5ff67f98 | 4 | * |
d60d530a | 5 | * %sccs.include.redist.c% |
0eb85d71 | 6 | * |
d60d530a | 7 | * @(#)trace.h 5.8 (Berkeley) %G% |
5ff67f98 | 8 | */ |
0a225629 SL |
9 | |
10 | /* | |
11 | * Routing table management daemon. | |
12 | */ | |
13 | ||
14 | /* | |
15 | * Trace record format. | |
16 | */ | |
17 | struct iftrace { | |
4033c8f6 | 18 | struct timeval ift_stamp; /* time stamp */ |
0a225629 SL |
19 | struct sockaddr ift_who; /* from/to */ |
20 | char *ift_packet; /* pointer to packet */ | |
21 | short ift_size; /* size of packet */ | |
22 | short ift_metric; /* metric on associated metric */ | |
23 | }; | |
24 | ||
25 | /* | |
26 | * Per interface packet tracing buffers. An incoming and | |
27 | * outgoing circular buffer of packets is maintained, per | |
28 | * interface, for debugging. Buffers are dumped whenever | |
29 | * an interface is marked down. | |
30 | */ | |
31 | struct ifdebug { | |
32 | struct iftrace *ifd_records; /* array of trace records */ | |
33 | struct iftrace *ifd_front; /* next empty trace record */ | |
b7e4f8be | 34 | int ifd_count; /* number of unprinted records */ |
0a225629 SL |
35 | struct interface *ifd_if; /* for locating stuff */ |
36 | }; | |
37 | ||
38 | /* | |
39 | * Packet tracing stuff. | |
40 | */ | |
d4b6a849 | 41 | int tracepackets; /* watch packets as they go by */ |
4033c8f6 | 42 | int tracecontents; /* watch packet contents as they go by */ |
3256e1bb MK |
43 | int traceactions; /* on/off */ |
44 | int tracehistory; /* on/off */ | |
0a225629 | 45 | FILE *ftrace; /* output trace file */ |
d4b6a849 | 46 | |
0a225629 | 47 | #define TRACE_ACTION(action, route) { \ |
3256e1bb MK |
48 | if (traceactions) \ |
49 | traceaction(ftrace, action, route); \ | |
50 | } | |
51 | #define TRACE_NEWMETRIC(route, newmetric) { \ | |
52 | if (traceactions) \ | |
53 | tracenewmetric(ftrace, route, newmetric); \ | |
0a225629 | 54 | } |
787d3210 | 55 | #define TRACE_INPUT(ifp, src, pack, size) { \ |
3256e1bb | 56 | if (tracehistory) { \ |
d4b6a849 | 57 | ifp = if_iflookup(src); \ |
0a225629 | 58 | if (ifp) \ |
787d3210 | 59 | trace(&ifp->int_input, src, pack, size, \ |
55d340a4 | 60 | ntohl(ifp->int_metric)); \ |
0a225629 | 61 | } \ |
4033c8f6 | 62 | if (tracepackets) \ |
787d3210 | 63 | dumppacket(ftrace, "from", src, pack, size, &now); \ |
0a225629 | 64 | } |
d4b6a849 | 65 | #define TRACE_OUTPUT(ifp, dst, size) { \ |
3256e1bb | 66 | if (tracehistory && ifp) \ |
d4b6a849 | 67 | trace(&ifp->int_output, dst, packet, size, ifp->int_metric); \ |
4033c8f6 MK |
68 | if (tracepackets) \ |
69 | dumppacket(ftrace, "to", dst, packet, size, &now); \ | |
0a225629 | 70 | } |