source: lib/libtrace_int.h @ 2e223eca

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 2e223eca was 2e223eca, checked in by Perry Lorier <perry@…>, 16 years ago

Documentation, and cleanup use of 64bit constants

  • Property mode set to 100644
File size: 5.9 KB
Line 
1/*
2 * This file is part of libtrace
3 *
4 * Copyright (c) 2004 The University of Waikato, Hamilton, New Zealand.
5 * Authors: Daniel Lawson
6 *          Perry Lorier
7 *         
8 * All rights reserved.
9 *
10 * This code has been developed by the University of Waikato WAND
11 * research group. For further information please see http://www.wand.net.nz/
12 *
13 * libtrace is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * libtrace is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with libtrace; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 *
27 * $Id$
28 *
29 */
30
31#ifndef LIBTRACE_INT_H
32#define LIBTRACE_INT_H
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38#include "common.h"
39#include "config.h"
40#include "libtrace.h"
41#include "fifo.h"
42       
43#if HAVE_PCAP_BPF_H
44#  include <pcap-bpf.h>
45#else
46#  ifdef HAVE_NET_BPF_H
47#    include <net/bpf.h>
48#  endif
49#endif
50
51#if HAVE_PCAP_H
52#  include <pcap.h>
53#  ifdef HAVE_PCAP_INT_H
54#    include <pcap-int.h>
55#  endif
56#endif
57
58#ifdef HAVE_ZLIB_H
59#  include <zlib.h>
60#endif
61
62
63#include "wag.h"
64#include "daglegacy.h"
65       
66#ifdef HAVE_DAG_API
67#  include "dagnew.h"
68#  include "dagapi.h"
69#else
70#  include "dagformat.h"
71#endif
72
73#include <stdbool.h>
74
75
76
77#define RP_BUFSIZE 65536
78
79struct libtrace_format_data_t;
80
81struct libtrace_event_t {
82        struct {
83                void *buffer;
84                int size;
85        } packet;
86        double tdelta;
87        double trace_last_ts;
88};
89
90/** The information about traces that are open
91 * @internal
92 */
93struct libtrace_t {
94        struct libtrace_format_t *format; /**< format driver pointer */
95        struct libtrace_format_data_t *format_data; /**<format data pointer */
96        bool started;                   /**< if this trace has started */
97        libtrace_err_t err;             /**< error information */
98        struct libtrace_event_t event;  /**< the next event */
99        char *uridata;                  /**< the uri of this trace */
100        struct tracefifo_t *fifo;       /**< fifo used in this trace */
101        struct libtrace_filter_t *filter; /**< used by libtrace if the module
102                                            * doesn't support filters natively
103                                            */
104        int snaplen;                    /**< used by libtrace if the module
105                                          * doesn't support snapping natively
106                                          */
107};
108
109/** Information about output traces
110 * @internal
111 */
112struct libtrace_out_t {
113        struct libtrace_format_t *format;       /**< format driver */
114        struct libtrace_format_data_out_t *format_data; /**< format data */
115        bool started;
116        libtrace_err_t err;             /**< Associated error */
117        char *uridata;                  /**< URI associated with this trace */
118};
119
120void trace_set_err(libtrace_t *trace, int errcode,const char *msg,...);
121void trace_set_err_out(libtrace_out_t *trace, int errcode, const char *msg,...);
122
123struct trace_sll_header_t {
124        uint16_t pkttype;               /* packet type */
125        uint16_t hatype;                /* link-layer address type */
126        uint16_t halen;                 /* link-layer address length */
127        char addr[8];                   /* link-layer address */
128        uint16_t protocol;              /* protocol */
129};
130
131#ifndef PF_RULESET_NAME_SIZE
132#define PF_RULESET_NAME_SIZE 16
133#endif
134
135#ifndef IFNAMSIZ
136#define IFNAMSIZ 16
137#endif
138
139struct trace_pflog_header_t {
140        uint8_t    length;
141        sa_family_t   af;
142        uint8_t    action;
143        uint8_t    reason;
144        char       ifname[IFNAMSIZ];
145        char       ruleset[PF_RULESET_NAME_SIZE];
146        uint32_t   rulenr;
147        uint32_t   subrulenr;
148        uint8_t    dir;
149        uint8_t    pad[3];
150};
151
152struct libtrace_format_t {
153        char *name;
154        char *version;
155        enum base_format_t type;
156        int (*init_input)(libtrace_t *libtrace);
157        int (*config_input)(libtrace_t *libtrace,trace_option_t option,void *value);
158        int (*start_input)(libtrace_t *libtrace);
159        int (*pause_input)(libtrace_t *libtrace);
160        int (*init_output)(libtrace_out_t *libtrace);
161        int (*config_output)(libtrace_out_t *libtrace, trace_option_output_t, void *);
162        int (*start_output)(libtrace_out_t *libtrace);
163        int (*fin_input)(libtrace_t *libtrace);
164        int (*fin_output)(libtrace_out_t *libtrace);
165        int (*read_packet)(libtrace_t *libtrace, struct libtrace_packet_t *packet);
166        int (*write_packet)(libtrace_out_t *libtrace, const libtrace_packet_t *packet);
167        libtrace_linktype_t (*get_link_type)(const libtrace_packet_t *packet);
168        int8_t (*get_direction)(const libtrace_packet_t *packet);
169        int8_t (*set_direction)(const libtrace_packet_t *packet, int8_t direction);
170        uint64_t (*get_erf_timestamp)(const libtrace_packet_t *packet);
171        struct timeval (*get_timeval)(const libtrace_packet_t *packet);
172        double (*get_seconds)(const libtrace_packet_t *packet);
173        int (*seek_erf)(libtrace_t *trace, uint64_t timestamp);
174        int (*seek_timeval)(libtrace_t *trace, struct timeval tv);
175        int (*seek_seconds)(libtrace_t *trace, double seconds);
176        int (*get_capture_length)(const libtrace_packet_t *packet);
177        int (*get_wire_length)(const libtrace_packet_t *packet);
178        int (*get_framing_length)(const libtrace_packet_t *packet);
179        size_t (*set_capture_length)(struct libtrace_packet_t *packet,size_t size);
180        int (*get_fd)(const libtrace_t *trace);
181        struct libtrace_eventobj_t (*trace_event)(libtrace_t *trace, libtrace_packet_t *packet);       
182        void (*help)();
183};
184
185extern struct libtrace_format_t *form;
186
187void register_format(struct libtrace_format_t *format);
188
189libtrace_linktype_t pcap_dlt_to_libtrace(int dlt);
190char libtrace_to_pcap_dlt(libtrace_linktype_t type);
191libtrace_linktype_t erf_type_to_libtrace(char erf);
192char libtrace_to_erf_type(libtrace_linktype_t linktype);
193
194#if HAVE_BPF
195/* A type encapsulating a bpf filter
196 * This type covers the compiled bpf filter, as well as the original filter
197 * string
198 *
199 */
200struct libtrace_filter_t {
201        struct bpf_program filter;
202        int flag;
203        char * filterstring;
204};
205#endif
206       
207#ifdef __cplusplus
208}
209#endif
210
211#endif /* LIBTRACE_INT_H */
Note: See TracBrowser for help on using the repository browser.