Commit | Line | Data |
---|---|---|
d4b6a849 | 1 | /* trace.h 4.2 83/01/31 */ |
0a225629 SL |
2 | |
3 | /* | |
4 | * Routing table management daemon. | |
5 | */ | |
6 | ||
7 | /* | |
8 | * Trace record format. | |
9 | */ | |
10 | struct iftrace { | |
11 | time_t ift_stamp; /* time stamp */ | |
12 | struct sockaddr ift_who; /* from/to */ | |
13 | char *ift_packet; /* pointer to packet */ | |
14 | short ift_size; /* size of packet */ | |
15 | short ift_metric; /* metric on associated metric */ | |
16 | }; | |
17 | ||
18 | /* | |
19 | * Per interface packet tracing buffers. An incoming and | |
20 | * outgoing circular buffer of packets is maintained, per | |
21 | * interface, for debugging. Buffers are dumped whenever | |
22 | * an interface is marked down. | |
23 | */ | |
24 | struct ifdebug { | |
25 | struct iftrace *ifd_records; /* array of trace records */ | |
26 | struct iftrace *ifd_front; /* next empty trace record */ | |
27 | struct interface *ifd_if; /* for locating stuff */ | |
28 | }; | |
29 | ||
30 | /* | |
31 | * Packet tracing stuff. | |
32 | */ | |
d4b6a849 | 33 | int tracepackets; /* watch packets as they go by */ |
0a225629 SL |
34 | int tracing; /* on/off */ |
35 | FILE *ftrace; /* output trace file */ | |
d4b6a849 | 36 | |
0a225629 SL |
37 | #define TRACE_ACTION(action, route) { \ |
38 | if (tracing) \ | |
39 | traceaction(ftrace, "action", route); \ | |
40 | } | |
d4b6a849 | 41 | #define TRACE_INPUT(ifp, src, size) { \ |
0a225629 | 42 | if (tracing) { \ |
d4b6a849 | 43 | ifp = if_iflookup(src); \ |
0a225629 | 44 | if (ifp) \ |
d4b6a849 | 45 | trace(&ifp->int_input, src, packet, size, \ |
0a225629 SL |
46 | ifp->int_metric); \ |
47 | } \ | |
d4b6a849 SL |
48 | if (tracepackets) \ |
49 | dumppacket(stdout, "from", src, packet, size); \ | |
0a225629 | 50 | } |
d4b6a849 | 51 | #define TRACE_OUTPUT(ifp, dst, size) { \ |
0a225629 | 52 | if (tracing) \ |
d4b6a849 SL |
53 | trace(&ifp->int_output, dst, packet, size, ifp->int_metric); \ |
54 | if (tracepackets) \ | |
55 | dumppacket(stdout, "to", dst, packet, size); \ | |
0a225629 | 56 | } |