ISC DHCP  4.4.2b1
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-2017 by Internet Systems Consortium, Inc. ("ISC")
7  * Copyright (c) 2001-2003 by Internet Software Consortium
8  *
9  * This Source Code Form is subject to the terms of the Mozilla Public
10  * License, v. 2.0. If a copy of the MPL was not distributed with this
11  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
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;
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);
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 **);
trace_begin
isc_result_t trace_begin(const char *, const char *, int)
tracepacket_t::pad
u_int32_t pad
Definition: trace.h:53
trace_write_packet
isc_result_t trace_write_packet(trace_type_t *, unsigned, const char *, const char *, int)
tracepacket_t::type_index
u_int32_t type_index
Definition: trace.h:48
tracefile_header_t
Definition: trace.h:34
trace_replay_init
void trace_replay_init(void)
trace_stop
void trace_stop(void)
trace_type_register
trace_type_t * trace_type_register(const char *, void *, void(*)(trace_type_t *, unsigned, char *), void(*)(trace_type_t *), const char *, int)
tracefile_header_t::version
u_int32_t version
Definition: trace.h:36
tracefile_header_t::phlen
int32_t phlen
Definition: trace.h:38
trace_type::next
trace_type_t * next
Definition: trace.h:66
trace_index_mapping_t::index
u_int32_t index
Definition: trace.h:58
trace_type::name
char * name
Definition: trace.h:68
tracepacket_t
Definition: trace.h:47
trace_index_map_input
void trace_index_map_input(trace_type_t *, unsigned, char *)
tracepacket_t::length
u_int32_t length
Definition: trace.h:50
trace_addr_t
Definition: trace.h:79
tracefile_header_t::magic
u_int32_t magic
Definition: trace.h:35
trace_iov::len
unsigned len
Definition: trace.h:76
trace_get_packet
isc_result_t trace_get_packet(trace_type_t **, unsigned *, char **)
trace_write_packet_iov
isc_result_t trace_write_packet_iov(trace_type_t *, int, trace_iov_t *, const char *, int)
trace_addr_t::port
u_int16_t port
Definition: trace.h:83
trace_snoop_time
time_t trace_snoop_time(trace_type_t **)
trace_get_file
isc_result_t trace_get_file(trace_type_t *, const char *, unsigned *, char **)
trace_playback
int trace_playback(void)
tracepacket_t::when
u_int32_t when
Definition: trace.h:52
trace_iov
Definition: trace.h:74
trace_type::have_packet
void(* have_packet)(trace_type_t *, unsigned, char *)
Definition: trace.h:70
trace_free_all
void trace_free_all(void)
trace_record
int trace_record(void)
trace_type::index
int index
Definition: trace.h:67
trace_iov_t
struct trace_iov trace_iov_t
trace_type::baggage
void * baggage
Definition: trace.h:69
trace_type
Definition: trace.h:65
trace_index_stop_tracing
void trace_index_stop_tracing(trace_type_t *)
trace_type::stop_tracing
void(* stop_tracing)(trace_type_t *)
Definition: trace.h:71
trace_get_next_packet
isc_result_t trace_get_next_packet(trace_type_t **, tracepacket_t *, char **, unsigned *, unsigned *)
trace_file_replay
void trace_file_replay(const char *)
trace_init
isc_result_t trace_init(void(*set_time)(time_t), const char *, int)
trace_addr_t::addrlen
u_int16_t addrlen
Definition: trace.h:81
trace_type_stash
void trace_type_stash(trace_type_t *)
trace_iov::buf
const char * buf
Definition: trace.h:75
set_time
void set_time(TIME t)
Definition: dispatch.c:36
trace_index_mapping_t
Definition: trace.h:57
trace_addr_t::addrtype
u_int16_t addrtype
Definition: trace.h:80
tracefile_header_t::hlen
int32_t hlen
Definition: trace.h:37