1 /* $NetBSD: trace.h,v 1.1.1.3 2014/07/12 11:57:57 spz Exp $ */
4 Definitions for omapi tracing facility... */
7 * Copyright (c) 2004,2005,2007,2009,2014 by Internet Systems Consortium, Inc. ("ISC")
8 * Copyright (c) 2001-2003 by Internet Software Consortium
10 * Permission to use, copy, modify, and distribute this software for any
11 * purpose with or without fee is hereby granted, provided that the above
12 * copyright notice and this permission notice appear in all copies.
14 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
20 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 * Internet Systems Consortium, Inc.
24 * Redwood City, CA 94063
26 * https://www.isc.org/
30 #define TRACEFILE_MAGIC 0x64484370UL /* dHCp */
31 #define TRACEFILE_VERSION 1
33 /* The first thing in a trace file is the header, which basically just
34 defines the version of the file. */
36 u_int32_t magic
; /* Magic number for trace file. */
37 u_int32_t version
; /* Version of file. */
38 int32_t hlen
; /* Length of this header. */
39 int32_t phlen
; /* Length of packet headers. */
42 /* The trace file is composed of a bunch of trace packets. Each such packet
43 has a type, followed by a length, followed by a timestamp, followed by
44 the actual contents of the packet. The type indexes are not fixed -
45 they are allocated either on readback or when writing a trace file.
46 One index type is reserved - type zero means that this record is a type
47 name to index mapping. */
49 u_int32_t type_index
; /* Index to the type of handler that this
51 u_int32_t length
; /* Length of the packet. This includes
52 everything except the fixed header. */
53 u_int32_t when
; /* When the packet was written. */
54 u_int32_t pad
; /* Round this out to a quad boundary. */
57 #define TRACE_INDEX_MAPPING_SIZE 4 /* trace_index_mapping_t less name. */
61 } trace_index_mapping_t
;
63 struct trace_type
; /* forward */
64 typedef struct trace_type trace_type_t
;
71 void (*have_packet
) (trace_type_t
*, unsigned, char *);
72 void (*stop_tracing
) (trace_type_t
*);
75 typedef struct trace_iov
{
83 u_int8_t address
[16];
87 void trace_free_all (void);
88 int trace_playback (void);
89 int trace_record (void);
90 isc_result_t
trace_init(void (*set_time
)(time_t), const char *, int);
91 isc_result_t
trace_begin (const char *, const char *, int);
92 isc_result_t
trace_write_packet (trace_type_t
*, unsigned, const char *,
94 isc_result_t
trace_write_packet_iov (trace_type_t
*, int, trace_iov_t
*,
96 void trace_type_stash (trace_type_t
*);
97 trace_type_t
*trace_type_register (const char *, void *,
98 void (*) (trace_type_t
*,
100 void (*) (trace_type_t
*),
102 void trace_stop (void);
103 void trace_index_map_input (trace_type_t
*, unsigned, char *);
104 void trace_index_stop_tracing (trace_type_t
*);
105 void trace_replay_init (void);
106 void trace_file_replay (const char *);
107 isc_result_t
trace_get_next_packet (trace_type_t
**, tracepacket_t
*,
108 char **, unsigned *, unsigned *);
109 isc_result_t
trace_get_file (trace_type_t
*,
110 const char *, unsigned *, char **);
111 isc_result_t
trace_get_packet (trace_type_t
**, unsigned *, char **);
112 time_t trace_snoop_time (trace_type_t
**);