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