source: lib/libtrace_int.h @ 6eb91ff

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

Replace DEVICE/RT/TRACE/SOCKET/etc with TRACE_SOURCE_DEVICE/TRACE_SOURCE_RT/
TRACE_SOURCE_TRACE/TRACE_SOURCE_SOCKET/etc

  • Property mode set to 100644
File size: 5.3 KB
RevLine 
[4dedc28]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
[9e2a109]31#ifndef LIBTRACE_INT_H
32#define LIBTRACE_INT_H
[4dedc28]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"
[f9374e9]64#include "daglegacy.h"
65       
[4dedc28]66#ifdef HAVE_DAG_API
67#  include "dagnew.h"
68#  include "dagapi.h"
69#else
70#  include "dagformat.h"
71#endif
72
[37195b4]73#include <stdbool.h>
74
[6eb91ff]75typedef enum {
76        TRACE_SOURCE_SOCKET, 
77        TRACE_SOURCE_TRACE, 
78        TRACE_SOURCE_STDIN, 
79        TRACE_SOURCE_DEVICE, 
80        TRACE_SOURCE_INTERFACE, 
81        TRACE_SOURCE_RT
82} 
83        source_t;
[4dedc28]84
[ffc8c8d]85
[f1a1f5e]86extern struct trace_err_t{
[7068467]87        int err_num;            /* error code */
88        char problem[255];      /* the format, uri etc that caused the error for reporting purposes */
[ffc8c8d]89} trace_err;
90
91
[4dedc28]92#define RP_BUFSIZE 65536
93
[9e2a109]94struct libtrace_format_data_t;
[4dedc28]95
[9e2a109]96struct libtrace_event_t {
[4dedc28]97        struct {
98                void *buffer;
99                int size;
100        } packet;
101        double tdelta;
102        double trace_last_ts;
103};
104
[9e2a109]105/** The information about traces that are open
106 * @internal
107 */
108struct libtrace_t {
109        struct libtrace_format_t *format; /**< format driver pointer */
110        struct libtrace_format_data_t *format_data; /**<format data pointer */
111        source_t sourcetype;    /**< The type (device,file, etc */
[37195b4]112        bool started;
[1fc2f6a]113
[9e2a109]114        struct libtrace_event_t event;
[91ebc50]115        char *uridata;
[b5cd711]116        struct tracefifo_t *fifo;   
[1fc2f6a]117
[9e2a109]118};
[1fc2f6a]119
[9e2a109]120struct libtrace_out_t {
121        struct libtrace_format_t *format;
122        struct libtrace_format_data_out_t *format_data;
[1fc2f6a]123
[9e2a109]124        char *uridata;
[b5cd711]125        struct tracefifo_t *fifo;
[1fc2f6a]126};
127
128
[4dedc28]129struct trace_sll_header_t {
130        uint16_t pkttype;               /* packet type */
131        uint16_t hatype;                /* link-layer address type */
132        uint16_t halen;                 /* link-layer address length */
133        char addr[8];                   /* link-layer address */
134        uint16_t protocol;              /* protocol */
135};
136
137#ifndef PF_RULESET_NAME_SIZE
138#define PF_RULESET_NAME_SIZE 16
139#endif
140
141#ifndef IFNAMSIZ
142#define IFNAMSIZ 16
143#endif
144
145struct trace_pflog_header_t {
146        uint8_t    length;
147        sa_family_t   af;
148        uint8_t    action;
149        uint8_t    reason;
150        char       ifname[IFNAMSIZ];
151        char       ruleset[PF_RULESET_NAME_SIZE];
152        uint32_t   rulenr;
153        uint32_t   subrulenr;
154        uint8_t    dir;
155        uint8_t    pad[3];
156};
157
[9e2a109]158struct libtrace_format_t {
[4dedc28]159        char *name;
160        char *version;
[1974620]161        char *type;
[4dedc28]162        int (*init_input)(struct libtrace_t *libtrace);
[7068467]163        int (*config_input)(struct libtrace_t *libtrace,trace_option_t option,void *value);
[37195b4]164        int (*start_input)(struct libtrace_t *libtrace);
[4dedc28]165        int (*init_output)(struct libtrace_out_t *libtrace);
[7068467]166        int (*config_output)(struct libtrace_out_t *libtrace, trace_option_output_t, void *);
[37195b4]167        int (*start_output)(struct libtrace_out_t *libtrace);
[4dedc28]168        int (*fin_input)(struct libtrace_t *libtrace);
[7050c10]169        int (*fin_output)(struct libtrace_out_t *libtrace);
[4dedc28]170        int (*read_packet)(struct libtrace_t *libtrace, struct libtrace_packet_t *packet);
[31709e8d]171        int (*write_packet)(struct libtrace_out_t *libtrace, const struct libtrace_packet_t *packet);
[4dedc28]172        libtrace_linktype_t (*get_link_type)(const struct libtrace_packet_t *packet);
173        int8_t (*get_direction)(const struct libtrace_packet_t *packet);
174        int8_t (*set_direction)(const struct libtrace_packet_t *packet, int8_t direction);
175        uint64_t (*get_erf_timestamp)(const struct libtrace_packet_t *packet);
176        struct timeval (*get_timeval)(const struct libtrace_packet_t *packet);
177        double (*get_seconds)(const struct libtrace_packet_t *packet);
178        int (*get_capture_length)(const struct libtrace_packet_t *packet);
179        int (*get_wire_length)(const struct libtrace_packet_t *packet);
[7c8eacf]180        int (*get_framing_length)(const struct libtrace_packet_t *packet);
[c95b923]181        size_t (*set_capture_length)(struct libtrace_packet_t *packet,size_t size);
[9c6aa95]182        int (*get_fd)(const struct libtrace_packet_t *packet);
[72bfe20]183        struct libtrace_eventobj_t (*trace_event)(struct libtrace_t *trace, struct libtrace_packet_t *packet); 
[dd22d84]184        void (*help)();
[4dedc28]185};
186
[9e2a109]187extern struct libtrace_format_t *form;
[4dedc28]188
[9e2a109]189void register_format(struct libtrace_format_t *format);
[7068467]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
[4dedc28]196       
197#ifdef __cplusplus
198}
199#endif
200
[7068467]201#endif /* LIBTRACE_INT_H */
Note: See TracBrowser for help on using the repository browser.