ISC DHCP 4.4.3-P1
A reference DHCPv4 and DHCPv6 implementation
 
Loading...
Searching...
No Matches
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-2022 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 * PO Box 360
23 * Newmarket, NH 03857 USA
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. */
34typedef 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. */
47typedef 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. */
57typedef struct {
58 u_int32_t index;
59 char name [1];
61
62struct trace_type; /* forward */
63typedef struct trace_type trace_type_t;
64
65struct trace_type {
67 int index;
68 char *name;
69 void *baggage;
70 void (*have_packet) (trace_type_t *, unsigned, char *);
72};
73
74typedef struct trace_iov {
75 const char *buf;
76 unsigned len;
78
79typedef struct {
80 u_int16_t addrtype;
81 u_int16_t addrlen;
82 u_int8_t address [16];
83 u_int16_t port;
85
86void trace_free_all (void);
87int trace_playback (void);
88int trace_record (void);
89isc_result_t trace_init(void (*set_time)(time_t), const char *, int);
90isc_result_t trace_begin (const char *, const char *, int);
91isc_result_t trace_write_packet (trace_type_t *, unsigned, const char *,
92 const char *, int);
94 const char *, int);
96trace_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);
101void trace_stop (void);
102void trace_index_map_input (trace_type_t *, unsigned, char *);
105void trace_file_replay (const char *);
107 char **, unsigned *, unsigned *);
109 const char *, unsigned *, char **);
110isc_result_t trace_get_packet (trace_type_t **, unsigned *, char **);
void set_time(TIME t)
Definition dispatch.c:36
u_int16_t addrtype
Definition trace.h:80
u_int16_t addrlen
Definition trace.h:81
u_int16_t port
Definition trace.h:83
u_int8_t address[16]
Definition trace.h:82
u_int32_t index
Definition trace.h:58
unsigned len
Definition trace.h:76
const char * buf
Definition trace.h:75
trace_type_t * next
Definition trace.h:66
void * baggage
Definition trace.h:69
void(* stop_tracing)(trace_type_t *)
Definition trace.h:71
void(* have_packet)(trace_type_t *, unsigned, char *)
Definition trace.h:70
int index
Definition trace.h:67
char * name
Definition trace.h:68
u_int32_t magic
Definition trace.h:35
u_int32_t version
Definition trace.h:36
int32_t phlen
Definition trace.h:38
int32_t hlen
Definition trace.h:37
u_int32_t when
Definition trace.h:52
u_int32_t type_index
Definition trace.h:48
u_int32_t length
Definition trace.h:50
u_int32_t pad
Definition trace.h:53
isc_result_t trace_get_file(trace_type_t *, const char *, unsigned *, char **)
int trace_record(void)
struct trace_iov trace_iov_t
trace_type_t * trace_type_register(const char *, void *, void(*)(trace_type_t *, unsigned, char *), void(*)(trace_type_t *), const char *, int)
void trace_index_map_input(trace_type_t *, unsigned, char *)
void trace_index_stop_tracing(trace_type_t *)
isc_result_t trace_get_packet(trace_type_t **, unsigned *, char **)
void trace_free_all(void)
isc_result_t trace_begin(const char *, const char *, int)
isc_result_t trace_write_packet(trace_type_t *, unsigned, const char *, const char *, int)
void trace_file_replay(const char *)
void trace_type_stash(trace_type_t *)
struct trace_type trace_type_t
Definition trace.h:63
void trace_replay_init(void)
isc_result_t trace_write_packet_iov(trace_type_t *, int, trace_iov_t *, const char *, int)
isc_result_t trace_get_next_packet(trace_type_t **, tracepacket_t *, char **, unsigned *, unsigned *)
time_t trace_snoop_time(trace_type_t **)
void trace_stop(void)
isc_result_t trace_init(void(*set_time)(time_t), const char *, int)
int trace_playback(void)