revert between 56095 -> 55830 in arch
[AROS.git] / workbench / network / stacks / AROSTCP / dhcp / includes / omapip / trace.h
blobd48c3700ea30da98c648d79ccd430b34c6703a6c
1 /* trace.h
3 Definitions for omapi tracing facility... */
5 /*
6 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
7 * Copyright (c) 2001-2003 by Internet Software Consortium
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.
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.
21 * Internet Systems Consortium, Inc.
22 * 950 Charter Street
23 * Redwood City, CA 94063
24 * <info@isc.org>
25 * http://www.isc.org/
27 * This software has been written for Internet Systems Consortium
28 * by Ted Lemon, as part of a project for Nominum, Inc. To learn more
29 * about Internet Systems Consortium, see http://www.isc.org/. To
30 * learn more about Nominum, Inc., see ``http://www.nominum.com''.
33 #define TRACEFILE_MAGIC 0x64484370UL /* dHCp */
34 #define TRACEFILE_VERSION 1
36 /* The first thing in a trace file is the header, which basically just
37 defines the version of the file. */
38 typedef struct {
39 u_int32_t magic; /* Magic number for trace file. */
40 u_int32_t version; /* Version of file. */
41 int32_t hlen; /* Length of this header. */
42 int32_t phlen; /* Length of packet headers. */
43 } tracefile_header_t;
45 /* The trace file is composed of a bunch of trace packets. Each such packet
46 has a type, followed by a length, followed by a timestamp, followed by
47 the actual contents of the packet. The type indexes are not fixed -
48 they are allocated either on readback or when writing a trace file.
49 One index type is reserved - type zero means that this record is a type
50 name to index mapping. */
51 typedef struct {
52 u_int32_t type_index; /* Index to the type of handler that this
53 packet needs. */
54 u_int32_t length; /* Length of the packet. This includes
55 everything except the fixed header. */
56 u_int32_t when; /* When the packet was written. */
57 u_int32_t pad; /* Round this out to a quad boundary. */
58 } tracepacket_t;
60 #define TRACE_INDEX_MAPPING_SIZE 4 /* trace_index_mapping_t less name. */
61 typedef struct {
62 u_int32_t index;
63 char name [1];
64 } trace_index_mapping_t;
66 struct trace_type; /* forward */
67 typedef struct trace_type trace_type_t;
69 struct trace_type {
70 trace_type_t *next;
71 int index;
72 char *name;
73 void *baggage;
74 void (*have_packet) (trace_type_t *, unsigned, char *);
75 void (*stop_tracing) (trace_type_t *);
78 typedef struct trace_iov {
79 const char *buf;
80 unsigned len;
81 } trace_iov_t;
83 typedef struct {
84 u_int16_t addrtype;
85 u_int16_t addrlen;
86 u_int8_t address [16];
87 u_int16_t port;
88 } trace_addr_t;
90 void trace_free_all (void);
91 int trace_playback (void);
92 int trace_record (void);
93 isc_result_t trace_init (void (*set_time) (u_int32_t), const char *, int);
94 isc_result_t trace_begin (const char *, const char *, int);
95 isc_result_t trace_write_packet (trace_type_t *, unsigned, const char *,
96 const char *, int);
97 isc_result_t trace_write_packet_iov (trace_type_t *, int, trace_iov_t *,
98 const char *, int);
99 void trace_type_stash (trace_type_t *);
100 trace_type_t *trace_type_register (const char *, void *,
101 void (*) (trace_type_t *,
102 unsigned, char *),
103 void (*) (trace_type_t *),
104 const char *, int);
105 void trace_stop (void);
106 void trace_index_map_input (trace_type_t *, unsigned, char *);
107 void trace_index_stop_tracing (trace_type_t *);
108 void trace_replay_init (void);
109 void trace_file_replay (const char *);
110 isc_result_t trace_get_next_packet (trace_type_t **, tracepacket_t *,
111 char **, unsigned *, unsigned *);
112 isc_result_t trace_get_file (trace_type_t *,
113 const char *, unsigned *, char **);
114 isc_result_t trace_get_packet (trace_type_t **, unsigned *, char **);
115 time_t trace_snoop_time (trace_type_t **);