Constify a character array;
[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 */
50 /*
51 Ref 1
52 Epan
53 Ethereal Packet ANalyzer (XXX - is this correct?) the packet analyzing engine. Source code can be found in the epan directory.
54
55 Protocol-Tree - Keep data of the capture file protocol information.
56
57 Dissectors - The various protocol dissectors in epan/dissectors.
58
59 Plugins - Some of the protocol dissectors are implemented as plugins. Source code can be found at plugins.
60
61 Display-Filters - the display filter engine at epan/dfilter
62
63
64
65 Ref2 for further edits - delete when done
66         \section Introduction
67
68         This document describes the data structures and the functions exported by the CACE Technologies AirPcap library.
69         The AirPcap library provides low-level access to the AirPcap driver including advanced capabilities such as channel setting,
70         link type control and WEP configuration.<br>
71         This manual includes the following sections:
72
73         \note throughout this documentation, \e device refers to a physical USB AirPcap device, while \e adapter is an open API
74         instance. Most of the AirPcap API operations are adapter-specific but some of them, like setting the channel, are
75         per-device and will be reflected on all the open adapters. These functions will have "Device" in their name, e.g.
76         AirpcapSetDeviceChannel().
77
78         \b Sections:
79
80         - \ref airpcapfuncs
81         - \ref airpcapdefs
82         - \ref radiotap
83 */
84 /** init the whole epan module, this is used to be called only once in a program */
85 WS_DLL_PUBLIC
86 void epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_data),
87                void (*register_all_handoffs_func)(register_cb cb, gpointer client_data),
88                register_cb cb,
89                void *client_data,
90                void (*report_failure_fcn_p)(const char *, va_list),
91                void (*report_open_failure_fcn_p)(const char *, int, gboolean),
92                void (*report_read_failure_fcn_p)(const char *, int),
93                void (*report_write_failure_fcn_p)(const char *, int));
94
95 /** cleanup the whole epan module, this is used to be called only once in a program */
96 WS_DLL_PUBLIC
97 void epan_cleanup(void);
98
99 /**
100  * Initialize the table of conversations.  Conversations are identified by
101  * their endpoints; they are used for protocols such as IP, TCP, and UDP,
102  * where packets contain endpoint information but don't contain a single
103  * value indicating to which flow the packet belongs.
104  */
105 void epan_conversation_init(void);
106 void epan_conversation_cleanup(void);
107
108 /**
109  * Initialize the table of circuits.  Circuits are identified by a
110  * circuit ID; they are used for protocols where packets *do* contain
111  * a circuit ID value indicating to which flow the packet belongs.
112  *
113  * We might want to make a superclass for both endpoint-specified
114  * conversations and circuit ID-specified circuits, so we can attach
115  * information either to a circuit or a conversation with common
116  * code.
117  */
118 void epan_circuit_init(void);
119 void epan_circuit_cleanup(void);
120
121 /** A client will create one epan_t for an entire dissection session.
122  * A single epan_t will be used to analyze the entire sequence of packets,
123  * sequentially, in a single session. A session corresponds to a single
124  * packet trace file. The reaons epan_t exists is that some packets in
125  * some protocols cannot be decoded without knowledge of previous packets.
126  * This inter-packet "state" is stored in the epan_t.
127  */
128 typedef struct epan_session epan_t;
129
130 WS_DLL_PUBLIC epan_t *epan_new(void);
131
132 const char *epan_get_user_comment(const epan_t *session, const frame_data *fd);
133
134 const char *epan_get_interface_name(const epan_t *session, guint32 interface_id);
135
136 const nstime_t *epan_get_frame_ts(const epan_t *session, guint32 frame_num);
137
138 WS_DLL_PUBLIC void epan_free(epan_t *session);
139
140 WS_DLL_PUBLIC const gchar*
141 epan_get_version(void);
142
143 /** initialize an existing single packet dissection */
144 WS_DLL_PUBLIC
145 epan_dissect_t*
146 epan_dissect_init(epan_dissect_t *edt, epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible);
147
148 /** get a new single packet dissection
149  * should be freed using epan_dissect_free() after packet dissection completed
150  */
151 WS_DLL_PUBLIC
152 epan_dissect_t*
153 epan_dissect_new(epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible);
154
155 WS_DLL_PUBLIC
156 void
157 epan_dissect_reset(epan_dissect_t *edt);
158
159 /** Indicate whether we should fake protocols or not */
160 WS_DLL_PUBLIC
161 void
162 epan_dissect_fake_protocols(epan_dissect_t *edt, const gboolean fake_protocols);
163
164 /** run a single packet dissection */
165 WS_DLL_PUBLIC
166 void
167 epan_dissect_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
168         tvbuff_t *tvb, frame_data *fd, column_info *cinfo);
169
170 WS_DLL_PUBLIC
171 void
172 epan_dissect_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
173         tvbuff_t *tvb, frame_data *fd, column_info *cinfo);
174
175 /** Prime a proto_tree using the fields/protocols used in a dfilter. */
176 WS_DLL_PUBLIC
177 void
178 epan_dissect_prime_dfilter(epan_dissect_t *edt, const dfilter_t *dfcode);
179
180 /** fill the dissect run output into the packet list columns */
181 WS_DLL_PUBLIC
182 void
183 epan_dissect_fill_in_columns(epan_dissect_t *edt, const gboolean fill_col_exprs, const gboolean fill_fd_colums);
184
185 /** Check whether a dissected packet contains a given named field */
186 WS_DLL_PUBLIC
187 gboolean
188 epan_dissect_packet_contains_field(epan_dissect_t* edt,
189                                    const char *field_name);
190
191 /** releases resources attached to the packet dissection. DOES NOT free the actual pointer */
192 WS_DLL_PUBLIC
193 void
194 epan_dissect_cleanup(epan_dissect_t* edt);
195
196 /** free a single packet dissection */
197 WS_DLL_PUBLIC
198 void
199 epan_dissect_free(epan_dissect_t* edt);
200
201 /** Sets custom column */
202 const gchar *
203 epan_custom_set(epan_dissect_t *edt, int id, gint occurrence,
204                                 gchar *result, gchar *expr, const int size);
205
206 /**
207  * Get compile-time information for libraries used by libwireshark.
208  */
209 WS_DLL_PUBLIC
210 void
211 epan_get_compiled_version_info(GString *str);
212
213 /**
214  * Get runtime information for libraries used by libwireshark.
215  */
216 WS_DLL_PUBLIC
217 void
218 epan_get_runtime_version_info(GString *str);
219
220 #ifdef __cplusplus
221 }
222 #endif /* __cplusplus */
223
224 #endif /* __EPAN_H__ */