includes/omapip/trace.h

Go to the documentation of this file.
00001 /* trace.h
00002 
00003    Definitions for omapi tracing facility... */
00004 
00005 /*
00006  * Copyright (c) 2004,2005,2007,2009,2014 by Internet Systems Consortium, Inc. ("ISC")
00007  * Copyright (c) 2001-2003 by Internet Software Consortium
00008  *
00009  * Permission to use, copy, modify, and distribute this software for any
00010  * purpose with or without fee is hereby granted, provided that the above
00011  * copyright notice and this permission notice appear in all copies.
00012  *
00013  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
00014  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00015  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
00016  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00017  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00018  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
00019  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00020  *
00021  *   Internet Systems Consortium, Inc.
00022  *   950 Charter Street
00023  *   Redwood City, CA 94063
00024  *   <info@isc.org>
00025  *   https://www.isc.org/
00026  *
00027  */
00028 
00029 #define TRACEFILE_MAGIC         0x64484370UL    /* dHCp */
00030 #define TRACEFILE_VERSION       1
00031 
00032 /* The first thing in a trace file is the header, which basically just 
00033    defines the version of the file. */
00034 typedef struct {
00035         u_int32_t magic;        /* Magic number for trace file. */
00036         u_int32_t version;      /* Version of file. */
00037         int32_t hlen;           /* Length of this header. */
00038         int32_t phlen;          /* Length of packet headers. */
00039 } tracefile_header_t;
00040 
00041 /* The trace file is composed of a bunch of trace packets.   Each such packet
00042    has a type, followed by a length, followed by a timestamp, followed by
00043    the actual contents of the packet.   The type indexes are not fixed -
00044    they are allocated either on readback or when writing a trace file.
00045    One index type is reserved - type zero means that this record is a type
00046    name to index mapping. */
00047 typedef struct {
00048         u_int32_t type_index;   /* Index to the type of handler that this
00049                                    packet needs. */
00050         u_int32_t length;       /* Length of the packet.  This includes
00051                                    everything except the fixed header. */
00052         u_int32_t when;         /* When the packet was written. */
00053         u_int32_t pad;          /* Round this out to a quad boundary. */
00054 } tracepacket_t;
00055 
00056 #define TRACE_INDEX_MAPPING_SIZE 4      /* trace_index_mapping_t less name. */
00057 typedef struct {
00058         u_int32_t index;
00059         char name [1];
00060 } trace_index_mapping_t;
00061 
00062 struct trace_type; /* forward */
00063 typedef struct trace_type trace_type_t;
00064 
00065 struct trace_type {
00066         trace_type_t *next;
00067         int index;
00068         char *name;
00069         void *baggage;
00070         void (*have_packet) (trace_type_t *, unsigned, char *);
00071         void (*stop_tracing) (trace_type_t *);
00072 };
00073 
00074 typedef struct trace_iov {
00075         const char *buf;
00076         unsigned len;
00077 } trace_iov_t;
00078 
00079 typedef struct {
00080         u_int16_t addrtype;
00081         u_int16_t addrlen;
00082         u_int8_t address [16];
00083         u_int16_t port;
00084 } trace_addr_t;
00085 
00086 void trace_free_all (void);
00087 int trace_playback (void);
00088 int trace_record (void);
00089 isc_result_t trace_init(void (*set_time)(time_t), const char *, int);
00090 isc_result_t trace_begin (const char *, const char *, int);
00091 isc_result_t trace_write_packet (trace_type_t *, unsigned, const char *,
00092                                  const char *, int);
00093 isc_result_t trace_write_packet_iov (trace_type_t *, int, trace_iov_t *,
00094                                      const char *, int);
00095 void trace_type_stash (trace_type_t *);
00096 trace_type_t *trace_type_register (const char *, void *,
00097                                    void (*) (trace_type_t *,
00098                                              unsigned, char *),
00099                                    void (*) (trace_type_t *),
00100                                    const char *, int);
00101 void trace_stop (void);
00102 void trace_index_map_input (trace_type_t *, unsigned, char *);
00103 void trace_index_stop_tracing (trace_type_t *);
00104 void trace_replay_init (void);
00105 void trace_file_replay (const char *);
00106 isc_result_t trace_get_next_packet (trace_type_t **, tracepacket_t *,
00107                                     char **, unsigned *, unsigned *);
00108 isc_result_t trace_get_file (trace_type_t *,
00109                              const char *, unsigned *, char **);
00110 isc_result_t trace_get_packet (trace_type_t **, unsigned *, char **);
00111 time_t trace_snoop_time (trace_type_t **);

Generated on 5 Apr 2014 for ISC DHCP by  doxygen 1.6.1