Commit | Line | Data |
---|---|---|
5ff67f98 | 1 | /* |
3256e1bb | 2 | * Copyright (c) 1983, 1988 Regents of the University of California. |
0eb85d71 | 3 | * All rights reserved. |
5ff67f98 | 4 | * |
0eb85d71 | 5 | * Redistribution and use in source and binary forms are permitted |
b8c620d6 KB |
6 | * provided that the above copyright notice and this paragraph are |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
0eb85d71 | 16 | * |
787d3210 | 17 | * @(#)trace.h 5.7 (Berkeley) %G% |
5ff67f98 | 18 | */ |
0a225629 SL |
19 | |
20 | /* | |
21 | * Routing table management daemon. | |
22 | */ | |
23 | ||
24 | /* | |
25 | * Trace record format. | |
26 | */ | |
27 | struct iftrace { | |
4033c8f6 | 28 | struct timeval ift_stamp; /* time stamp */ |
0a225629 SL |
29 | struct sockaddr ift_who; /* from/to */ |
30 | char *ift_packet; /* pointer to packet */ | |
31 | short ift_size; /* size of packet */ | |
32 | short ift_metric; /* metric on associated metric */ | |
33 | }; | |
34 | ||
35 | /* | |
36 | * Per interface packet tracing buffers. An incoming and | |
37 | * outgoing circular buffer of packets is maintained, per | |
38 | * interface, for debugging. Buffers are dumped whenever | |
39 | * an interface is marked down. | |
40 | */ | |
41 | struct ifdebug { | |
42 | struct iftrace *ifd_records; /* array of trace records */ | |
43 | struct iftrace *ifd_front; /* next empty trace record */ | |
b7e4f8be | 44 | int ifd_count; /* number of unprinted records */ |
0a225629 SL |
45 | struct interface *ifd_if; /* for locating stuff */ |
46 | }; | |
47 | ||
48 | /* | |
49 | * Packet tracing stuff. | |
50 | */ | |
d4b6a849 | 51 | int tracepackets; /* watch packets as they go by */ |
4033c8f6 | 52 | int tracecontents; /* watch packet contents as they go by */ |
3256e1bb MK |
53 | int traceactions; /* on/off */ |
54 | int tracehistory; /* on/off */ | |
0a225629 | 55 | FILE *ftrace; /* output trace file */ |
d4b6a849 | 56 | |
0a225629 | 57 | #define TRACE_ACTION(action, route) { \ |
3256e1bb MK |
58 | if (traceactions) \ |
59 | traceaction(ftrace, action, route); \ | |
60 | } | |
61 | #define TRACE_NEWMETRIC(route, newmetric) { \ | |
62 | if (traceactions) \ | |
63 | tracenewmetric(ftrace, route, newmetric); \ | |
0a225629 | 64 | } |
787d3210 | 65 | #define TRACE_INPUT(ifp, src, pack, size) { \ |
3256e1bb | 66 | if (tracehistory) { \ |
d4b6a849 | 67 | ifp = if_iflookup(src); \ |
0a225629 | 68 | if (ifp) \ |
787d3210 | 69 | trace(&ifp->int_input, src, pack, size, \ |
55d340a4 | 70 | ntohl(ifp->int_metric)); \ |
0a225629 | 71 | } \ |
4033c8f6 | 72 | if (tracepackets) \ |
787d3210 | 73 | dumppacket(ftrace, "from", src, pack, size, &now); \ |
0a225629 | 74 | } |
d4b6a849 | 75 | #define TRACE_OUTPUT(ifp, dst, size) { \ |
3256e1bb | 76 | if (tracehistory && ifp) \ |
d4b6a849 | 77 | trace(&ifp->int_output, dst, packet, size, ifp->int_metric); \ |
4033c8f6 MK |
78 | if (tracepackets) \ |
79 | dumppacket(ftrace, "to", dst, packet, size, &now); \ | |
0a225629 | 80 | } |