ISC DHCP  4.3.2
A reference DHCPv4 and DHCPv6 implementation
trace.h
Go to the documentation of this file.
1 /* trace.h
2 
3  Definitions for omapi tracing facility... */
4 
5 /*
6  * Copyright (c) 2004,2005,2007,2009,2014 by Internet Systems Consortium, Inc. ("ISC")
7  * Copyright (c) 2001-2003 by Internet Software Consortium
8  *
9  * Permission to use, copy, modify, and distribute this software for any
10  * purpose with or without fee is hereby granted, provided that the above
11  * copyright notice and this permission notice appear in all copies.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
14  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
16  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
19  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20  *
21  * Internet Systems Consortium, Inc.
22  * 950 Charter Street
23  * Redwood City, CA 94063
24  * <info@isc.org>
25  * https://www.isc.org/
26  *
27  */
28 
29 #define TRACEFILE_MAGIC 0x64484370UL /* dHCp */
30 #define TRACEFILE_VERSION 1
31 
32 /* The first thing in a trace file is the header, which basically just
33  defines the version of the file. */
34 typedef struct {
35  u_int32_t magic; /* Magic number for trace file. */
36  u_int32_t version; /* Version of file. */
37  int32_t hlen; /* Length of this header. */
38  int32_t phlen; /* Length of packet headers. */
40 
41 /* The trace file is composed of a bunch of trace packets. Each such packet
42  has a type, followed by a length, followed by a timestamp, followed by
43  the actual contents of the packet. The type indexes are not fixed -
44  they are allocated either on readback or when writing a trace file.
45  One index type is reserved - type zero means that this record is a type
46  name to index mapping. */
47 typedef struct {
48  u_int32_t type_index; /* Index to the type of handler that this
49  packet needs. */
50  u_int32_t length; /* Length of the packet. This includes
51  everything except the fixed header. */
52  u_int32_t when; /* When the packet was written. */
53  u_int32_t pad; /* Round this out to a quad boundary. */
55 
56 #define TRACE_INDEX_MAPPING_SIZE 4 /* trace_index_mapping_t less name. */
57 typedef struct {
58  u_int32_t index;
59  char name [1];
61 
62 struct trace_type; /* forward */
63 typedef struct trace_type trace_type_t;
64 
65 struct trace_type {
67  int index;
68  char *name;
69  void *baggage;
70  void (*have_packet) (trace_type_t *, unsigned, char *);
72 };
73 
74 typedef struct trace_iov {
75  const char *buf;
76  unsigned len;
77 } trace_iov_t;
78 
79 typedef struct {
80  u_int16_t addrtype;
81  u_int16_t addrlen;
82  u_int8_t address [16];
83  u_int16_t port;
84 } trace_addr_t;
85 
86 void trace_free_all (void);
87 int trace_playback (void);
88 int trace_record (void);
89 isc_result_t trace_init(void (*set_time)(time_t), const char *, int);
90 isc_result_t trace_begin (const char *, const char *, int);
91 isc_result_t trace_write_packet (trace_type_t *, unsigned, const char *,
92  const char *, int);
93 isc_result_t trace_write_packet_iov (trace_type_t *, int, trace_iov_t *,
94  const char *, int);
96 trace_type_t *trace_type_register (const char *, void *,
97  void (*) (trace_type_t *,
98  unsigned, char *),
99  void (*) (trace_type_t *),
100  const char *, int);
101 void trace_stop (void);
102 void trace_index_map_input (trace_type_t *, unsigned, char *);
104 void trace_replay_init (void);
105 void trace_file_replay (const char *);
107  char **, unsigned *, unsigned *);
108 isc_result_t trace_get_file (trace_type_t *,
109  const char *, unsigned *, char **);
110 isc_result_t trace_get_packet (trace_type_t **, unsigned *, char **);
111 time_t trace_snoop_time (trace_type_t **);
const char * buf
Definition: trace.h:75
int trace_playback(void)
int32_t phlen
Definition: trace.h:38
u_int16_t port
Definition: trace.h:83
isc_result_t trace_write_packet_iov(trace_type_t *, int, trace_iov_t *, const char *, int)
struct trace_iov trace_iov_t
u_int16_t addrlen
Definition: trace.h:81
u_int16_t addrtype
Definition: trace.h:80
time_t trace_snoop_time(trace_type_t **)
u_int32_t type_index
Definition: trace.h:48
isc_result_t trace_get_next_packet(trace_type_t **, tracepacket_t *, char **, unsigned *, unsigned *)
trace_type_t * next
Definition: trace.h:66
void(* have_packet)(trace_type_t *, unsigned, char *)
Definition: trace.h:70
char * name
Definition: trace.h:68
u_int32_t magic
Definition: trace.h:35
void trace_stop(void)
int index
Definition: trace.h:67
unsigned len
Definition: trace.h:76
void trace_free_all(void)
trace_type_t * trace_type_register(const char *, void *, void(*)(trace_type_t *, unsigned, char *), void(*)(trace_type_t *), const char *, int)
void trace_file_replay(const char *)
void set_time(TIME t)
Definition: dispatch.c:36
int trace_record(void)
isc_result_t trace_begin(const char *, const char *, int)
u_int32_t index
Definition: trace.h:58
void(* stop_tracing)(trace_type_t *)
Definition: trace.h:71
void trace_index_map_input(trace_type_t *, unsigned, char *)
void trace_replay_init(void)
u_int32_t pad
Definition: trace.h:53
u_int32_t version
Definition: trace.h:36
int32_t hlen
Definition: trace.h:37
isc_result_t trace_init(void(*set_time)(time_t), const char *, int)
u_int32_t when
Definition: trace.h:52
isc_result_t trace_get_packet(trace_type_t **, unsigned *, char **)
void trace_type_stash(trace_type_t *)
isc_result_t trace_get_file(trace_type_t *, const char *, unsigned *, char **)
isc_result_t trace_write_packet(trace_type_t *, unsigned, const char *, const char *, int)
void * baggage
Definition: trace.h:69
void trace_index_stop_tracing(trace_type_t *)
u_int32_t length
Definition: trace.h:50