cec8191eb66f5a150f4fbb2f610223033819ff47
[metze/wireshark/wip.git] / epan / epan.h
1 /* epan.h
2  *
3  * $Id$
4  *
5  * Wireshark Protocol Analyzer Library
6  *
7  * Copyright (c) 2001 by Gerald Combs <gerald@wireshark.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23
24 #ifndef __EPAN_H__
25 #define __EPAN_H__
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
30
31 #include <glib.h>
32 #include "frame_data.h"
33 #include "column_info.h"
34 #include "register.h"
35 #include "ws_symbol_export.h"
36
37 typedef struct _epan_dissect_t epan_dissect_t;
38
39 #include "dfilter/dfilter.h"
40
41 /**
42         @mainpage Wireshark EPAN the packet analyzing engine. Source code can be found in the epan directory
43
44         @section Introduction
45
46         XXX
47
48         @b Sections:
49         - \ref proto_pub
50 */
51 /*
52 Ref 1
53 Epan
54 Ethereal Packet ANalyzer (XXX - is this correct?) the packet analyzing engine. Source code can be found in the epan directory.
55
56 Protocol-Tree - Keep data of the capture file protocol information.
57
58 Dissectors - The various protocol dissectors in epan/dissectors.
59
60 Plugins - Some of the protocol dissectors are implemented as plugins. Source code can be found at plugins.
61
62 Display-Filters - the display filter engine at epan/dfilter
63
64
65
66 Ref2 for further edits - delete when done
67         \section Introduction
68
69         This document describes the data structures and the functions exported by the CACE Technologies AirPcap library.
70         The AirPcap library provides low-level access to the AirPcap driver including advanced capabilities such as channel setting,
71         link type control and WEP configuration.<br>
72         This manual includes the following sections:
73
74         \note throughout this documentation, \e device refers to a physical USB AirPcap device, while \e adapter is an open API
75         instance. Most of the AirPcap API operations are adapter-specific but some of them, like setting the channel, are
76         per-device and will be reflected on all the open adapters. These functions will have "Device" in their name, e.g.
77         AirpcapSetDeviceChannel().
78
79         \b Sections:
80
81         - \ref airpcapfuncs
82         - \ref airpcapdefs
83         - \ref radiotap
84 */
85 /** init the whole epan module, this is used to be called only once in a program */
86 WS_DLL_PUBLIC
87 void epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_data),
88                void (*register_all_handoffs_func)(register_cb cb, gpointer client_data),
89                register_cb cb,
90                void *client_data,
91                void (*report_failure_fcn_p)(const char *, va_list),
92                void (*report_open_failure_fcn_p)(const char *, int, gboolean),
93                void (*report_read_failure_fcn_p)(const char *, int),
94                void (*report_write_failure_fcn_p)(const char *, int));
95
96 /** cleanup the whole epan module, this is used to be called only once in a program */
97 WS_DLL_PUBLIC
98 void epan_cleanup(void);
99
100 /**
101  * Initialize the table of conversations.  Conversations are identified by
102  * their endpoints; they are used for protocols such as IP, TCP, and UDP,
103  * where packets contain endpoint information but don't contain a single
104  * value indicating to which flow the packet belongs.
105  */
106 void epan_conversation_init(void);
107 void epan_conversation_cleanup(void);
108
109 /**
110  * Initialize the table of circuits.  Circuits are identified by a
111  * circuit ID; they are used for protocols where packets *do* contain
112  * a circuit ID value indicating to which flow the packet belongs.
113  *
114  * We might want to make a superclass for both endpoint-specified
115  * conversations and circuit ID-specified circuits, so we can attach
116  * information either to a circuit or a conversation with common
117  * code.
118  */
119 void epan_circuit_init(void);
120 void epan_circuit_cleanup(void);
121
122 /** A client will create one epan_t for an entire dissection session.
123  * A single epan_t will be used to analyze the entire sequence of packets,
124  * sequentially, in a single session. A session corresponds to a single
125  * packet trace file. The reaons epan_t exists is that some packets in
126  * some protocols cannot be decoded without knowledge of previous packets.
127  * This inter-packet "state" is stored in the epan_t.
128  */
129 /* XXX - NOTE: epan_t, epan_new and epan_free are currently unused! */
130 typedef struct epan_session epan_t;
131
132 epan_t*
133 epan_new(void);
134
135 void
136 epan_free(epan_t*);
137
138 WS_DLL_PUBLIC const gchar*
139 epan_get_version(void);
140
141 /** initialize an existing single packet dissection */
142 WS_DLL_PUBLIC
143 epan_dissect_t*
144 epan_dissect_init(epan_dissect_t        *edt, const gboolean create_proto_tree, const gboolean proto_tree_visible);
145
146 /** get a new single packet dissection
147  * should be freed using epan_dissect_free() after packet dissection completed
148  */
149 WS_DLL_PUBLIC
150 epan_dissect_t*
151 epan_dissect_new(const gboolean create_proto_tree, const gboolean proto_tree_visible);
152
153 /** Indicate whether we should fake protocols or not */
154 WS_DLL_PUBLIC
155 void
156 epan_dissect_fake_protocols(epan_dissect_t *edt, const gboolean fake_protocols);
157
158 /** run a single packet dissection */
159 WS_DLL_PUBLIC
160 void
161 epan_dissect_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
162         const guint8* data, frame_data *fd, column_info *cinfo);
163
164 WS_DLL_PUBLIC
165 void
166 epan_dissect_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
167         const guint8* data, frame_data *fd, column_info *cinfo);
168
169 /** Prime a proto_tree using the fields/protocols used in a dfilter. */
170 WS_DLL_PUBLIC
171 void
172 epan_dissect_prime_dfilter(epan_dissect_t *edt, const dfilter_t *dfcode);
173
174 /** fill the dissect run output into the packet list columns */
175 WS_DLL_PUBLIC
176 void
177 epan_dissect_fill_in_columns(epan_dissect_t *edt, const gboolean fill_col_exprs, const gboolean fill_fd_colums);
178
179 /** releases resources attached to the packet dissection. DOES NOT free the actual pointer */
180 WS_DLL_PUBLIC
181 void
182 epan_dissect_cleanup(epan_dissect_t* edt);
183
184 /** free a single packet dissection */
185 WS_DLL_PUBLIC
186 void
187 epan_dissect_free(epan_dissect_t* edt);
188
189 /** Sets custom column */
190 const gchar *
191 epan_custom_set(epan_dissect_t *edt, int id, gint occurrence,
192                                 gchar *result, gchar *expr, const int size);
193
194 /**
195  * Get compile-time information for libraries used by libwireshark.
196  */
197 WS_DLL_PUBLIC
198 void
199 epan_get_compiled_version_info(GString *str);
200
201 /**
202  * Get runtime information for libraries used by libwireshark.
203  */
204 WS_DLL_PUBLIC
205 void
206 epan_get_runtime_version_info(GString *str);
207
208 #ifdef __cplusplus
209 }
210 #endif /* __cplusplus */
211
212 #endif /* __EPAN_H__ */