source: lib/libtrace_int.h @ 72bfe20

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 72bfe20 was 72bfe20, checked in by Daniel Lawson <dlawson@…>, 15 years ago

trace_event fixed

  • Property mode set to 100644
File size: 4.7 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#include "rtserver.h"
43
44#if HAVE_PCAP_BPF_H
45#  include <pcap-bpf.h>
46#else
47#  ifdef HAVE_NET_BPF_H
48#    include <net/bpf.h>
49#  endif
50#endif
51
52#if HAVE_PCAP_H
53#  include <pcap.h>
54#  ifdef HAVE_PCAP_INT_H
55#    include <pcap-int.h>
56#  endif
57#endif
58
59#ifdef HAVE_ZLIB_H
60#  include <zlib.h>
61#endif
62
63
64#include "wag.h"
65
66#ifdef HAVE_DAG_API
67#  include "dagnew.h"
68#  include "dagapi.h"
69#else
70#  include "dagformat.h"
71#endif
72
73typedef enum {SOCKET, TRACE, STDIN, DEVICE, INTERFACE, RT } source_t;
74
75#define RP_BUFSIZE 65536
76
77struct libtrace_format_data_t;
78
79struct libtrace_event_t {
80        struct {
81                void *buffer;
82                int size;
83        } packet;
84        double tdelta;
85//      double trace_start_ts;
86//      double real_start_ts;
87        double trace_last_ts;
88
89//      double last_ts;
90//      double start_ts;
91};
92
93/** The information about traces that are open
94 * @internal
95 */
96struct libtrace_t {
97        struct libtrace_format_t *format; /**< format driver pointer */
98        struct libtrace_format_data_t *format_data; /**<format data pointer */
99        source_t sourcetype;    /**< The type (device,file, etc */
100
101        struct libtrace_event_t event;
102        char *uridata;
103        struct fifo_t *fifo;   
104
105};
106
107struct libtrace_out_t {
108        struct libtrace_format_t *format;
109        struct libtrace_format_data_out_t *format_data;
110
111        char *uridata;
112        struct fifo_t *fifo;
113};
114
115
116struct trace_sll_header_t {
117        uint16_t pkttype;               /* packet type */
118        uint16_t hatype;                /* link-layer address type */
119        uint16_t halen;                 /* link-layer address length */
120        char addr[8];                   /* link-layer address */
121        uint16_t protocol;              /* protocol */
122};
123
124#ifndef PF_RULESET_NAME_SIZE
125#define PF_RULESET_NAME_SIZE 16
126#endif
127
128#ifndef IFNAMSIZ
129#define IFNAMSIZ 16
130#endif
131
132struct trace_pflog_header_t {
133        uint8_t    length;
134        sa_family_t   af;
135        uint8_t    action;
136        uint8_t    reason;
137        char       ifname[IFNAMSIZ];
138        char       ruleset[PF_RULESET_NAME_SIZE];
139        uint32_t   rulenr;
140        uint32_t   subrulenr;
141        uint8_t    dir;
142        uint8_t    pad[3];
143};
144
145struct libtrace_format_t {
146        char *name;
147        char *version;
148        int (*init_input)(struct libtrace_t *libtrace);
149        int (*init_output)(struct libtrace_out_t *libtrace);
150        int (*config_output)(struct libtrace_out_t *libtrace, int argc, char *argv[]);
151        int (*fin_input)(struct libtrace_t *libtrace);
152        int (*fin_output)(struct libtrace_out_t *libtrace);
153//      int (*read)(struct libtrace_t *libtrace, void *buffer, size_t len);
154        int (*read_packet)(struct libtrace_t *libtrace, struct libtrace_packet_t *packet);
155        int (*write_packet)(struct libtrace_out_t *libtrace, struct libtrace_packet_t *packet);
156        void* (*get_link)(const struct libtrace_packet_t *packet);
157        libtrace_linktype_t (*get_link_type)(const struct libtrace_packet_t *packet);
158        int8_t (*get_direction)(const struct libtrace_packet_t *packet);
159        int8_t (*set_direction)(const struct libtrace_packet_t *packet, int8_t direction);
160        uint64_t (*get_erf_timestamp)(const struct libtrace_packet_t *packet);
161        struct timeval (*get_timeval)(const struct libtrace_packet_t *packet);
162        double (*get_seconds)(const struct libtrace_packet_t *packet);
163        int (*get_capture_length)(const struct libtrace_packet_t *packet);
164        int (*get_wire_length)(const struct libtrace_packet_t *packet);
165        size_t (*truncate_packet)(const struct libtrace_packet_t *packet,size_t size);
166        int (*get_fd)(struct libtrace_packet_t *packet);
167        struct libtrace_eventobj_t (*trace_event)(struct libtrace_t *trace, struct libtrace_packet_t *packet); 
168        void (*help)();
169};
170
171extern struct libtrace_format_t *form;
172
173void register_format(struct libtrace_format_t *format);
174       
175#ifdef __cplusplus
176}
177#endif
178
179#endif // LIBTRACE_INT_H
Note: See TracBrowser for help on using the repository browser.