source: lib/libtrace_int.h @ f03fc17

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

Get rid of ->sourcetype, it was never used.
Cleanup some of the wag stuff

  • Property mode set to 100644
File size: 5.4 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
77extern struct trace_err_t{
78        int err_num;            /* error code */
79        char problem[255];      /* the format, uri etc that caused the error for reporting purposes */
80} trace_err;
81
82void trace_set_error(int errcode,const char *msg,...);
83
84#define RP_BUFSIZE 65536
85
86struct libtrace_format_data_t;
87
88struct libtrace_event_t {
89        struct {
90                void *buffer;
91                int size;
92        } packet;
93        double tdelta;
94        double trace_last_ts;
95};
96
97/** The information about traces that are open
98 * @internal
99 */
100struct libtrace_t {
101        struct libtrace_format_t *format; /**< format driver pointer */
102        struct libtrace_format_data_t *format_data; /**<format data pointer */
103        bool started;
104
105        struct libtrace_event_t event;
106        char *uridata;
107        struct tracefifo_t *fifo;   
108        struct libtrace_filter_t *filter; /**< used by libtrace if the module
109                                            * doesn't support filters natively
110                                            */
111        int snaplen;                    /**< used by libtrace if the module
112                                          * doesn't support snapping natively
113                                          */
114};
115
116struct libtrace_out_t {
117        struct libtrace_format_t *format;
118        struct libtrace_format_data_out_t *format_data;
119
120        char *uridata;
121        struct tracefifo_t *fifo;
122};
123
124
125struct trace_sll_header_t {
126        uint16_t pkttype;               /* packet type */
127        uint16_t hatype;                /* link-layer address type */
128        uint16_t halen;                 /* link-layer address length */
129        char addr[8];                   /* link-layer address */
130        uint16_t protocol;              /* protocol */
131};
132
133#ifndef PF_RULESET_NAME_SIZE
134#define PF_RULESET_NAME_SIZE 16
135#endif
136
137#ifndef IFNAMSIZ
138#define IFNAMSIZ 16
139#endif
140
141struct trace_pflog_header_t {
142        uint8_t    length;
143        sa_family_t   af;
144        uint8_t    action;
145        uint8_t    reason;
146        char       ifname[IFNAMSIZ];
147        char       ruleset[PF_RULESET_NAME_SIZE];
148        uint32_t   rulenr;
149        uint32_t   subrulenr;
150        uint8_t    dir;
151        uint8_t    pad[3];
152};
153
154struct libtrace_format_t {
155        char *name;
156        char *version;
157        char *type;
158        int (*init_input)(libtrace_t *libtrace);
159        int (*config_input)(libtrace_t *libtrace,trace_option_t option,void *value);
160        int (*start_input)(libtrace_t *libtrace);
161        int (*pause_input)(libtrace_t *libtrace);
162        int (*init_output)(libtrace_out_t *libtrace);
163        int (*config_output)(libtrace_out_t *libtrace, trace_option_output_t, void *);
164        int (*start_output)(libtrace_out_t *libtrace);
165        int (*fin_input)(libtrace_t *libtrace);
166        int (*fin_output)(libtrace_out_t *libtrace);
167        int (*read_packet)(libtrace_t *libtrace, struct libtrace_packet_t *packet);
168        int (*write_packet)(libtrace_out_t *libtrace, const libtrace_packet_t *packet);
169        libtrace_linktype_t (*get_link_type)(const libtrace_packet_t *packet);
170        int8_t (*get_direction)(const libtrace_packet_t *packet);
171        int8_t (*set_direction)(const libtrace_packet_t *packet, int8_t direction);
172        uint64_t (*get_erf_timestamp)(const libtrace_packet_t *packet);
173        struct timeval (*get_timeval)(const libtrace_packet_t *packet);
174        double (*get_seconds)(const libtrace_packet_t *packet);
175        int (*seek_erf)(libtrace_t *trace, uint64_t timestamp);
176        int (*seek_timeval)(libtrace_t *trace, struct timeval tv);
177        int (*seek_seconds)(libtrace_t *trace, double seconds);
178        int (*get_capture_length)(const libtrace_packet_t *packet);
179        int (*get_wire_length)(const libtrace_packet_t *packet);
180        int (*get_framing_length)(const libtrace_packet_t *packet);
181        size_t (*set_capture_length)(struct libtrace_packet_t *packet,size_t size);
182        int (*get_fd)(const libtrace_packet_t *packet);
183        struct libtrace_eventobj_t (*trace_event)(libtrace_t *trace, libtrace_packet_t *packet);       
184        void (*help)();
185};
186
187extern struct libtrace_format_t *form;
188
189void register_format(struct libtrace_format_t *format);
190
191libtrace_linktype_t pcap_dlt_to_libtrace(int dlt);
192char libtrace_to_pcap_dlt(libtrace_linktype_t type);
193libtrace_linktype_t erf_type_to_libtrace(char erf);
194char libtrace_to_erf_type(libtrace_linktype_t linktype);
195
196       
197#ifdef __cplusplus
198}
199#endif
200
201#endif /* LIBTRACE_INT_H */
Note: See TracBrowser for help on using the repository browser.