Annotation of embedaddon/dhcp/includes/omapip/trace.h, revision 1.1.1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>