debug keys
[metze/wireshark/wip.git] / epan / epan.h
1 /* epan.h
2  *
3  * Wireshark Protocol Analyzer Library
4  *
5  * Copyright (c) 2001 by Gerald Combs <gerald@wireshark.org>
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9
10 #ifndef __EPAN_H__
11 #define __EPAN_H__
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif /* __cplusplus */
16
17 #include <glib.h>
18 #include <epan/tvbuff.h>
19 #include <epan/prefs.h>
20 #include <epan/frame_data.h>
21 #include <wsutil/plugins.h>
22 #include <epan/register.h>
23 #include "ws_symbol_export.h"
24
25 typedef struct epan_dissect epan_dissect_t;
26
27 struct epan_dfilter;
28 struct epan_column_info;
29
30 /*
31  * Opaque structure provided when an epan_t is created; it contains
32  * information needed to allow the user of libwireshark to provide
33  * time stamps, comments, and other information outside the packet
34  * data itself.
35  */
36 struct packet_provider_data;
37
38 /*
39  * Structure containing pointers to functions supplied by the user
40  * of libwireshark.
41  */
42 struct packet_provider_funcs {
43         const nstime_t *(*get_frame_ts)(struct packet_provider_data *prov, guint32 frame_num);
44         const char *(*get_interface_name)(struct packet_provider_data *prov, guint32 interface_id);
45         const char *(*get_interface_description)(struct packet_provider_data *prov, guint32 interface_id);
46         const char *(*get_user_comment)(struct packet_provider_data *prov, const frame_data *fd);
47 };
48
49 #ifdef HAVE_PLUGINS
50 extern plugins_t *libwireshark_plugins;
51 #endif
52
53 /**
54         @section Epan The Enhanced Packet ANalyzer
55
56         XXX
57
58         @b Sections:
59 */
60 /*
61 Ref 1
62 Epan
63 Enhanced Packet ANalyzer, aka the packet analyzing engine. Source code can be found in the epan directory.
64
65 Protocol-Tree - Keep data of the capture file protocol information.
66
67 Dissectors - The various protocol dissectors in epan/dissectors.
68
69 Plugins - Some of the protocol dissectors are implemented as plugins. Source code can be found at plugins.
70
71 Display-Filters - the display filter engine at epan/dfilter
72
73
74
75 Ref2 for further edits - delete when done
76         \section Introduction
77
78         This document describes the data structures and the functions exported by the CACE Technologies AirPcap library.
79         The AirPcap library provides low-level access to the AirPcap driver including advanced capabilities such as channel setting,
80         link type control and WEP configuration.<br>
81         This manual includes the following sections:
82
83         \note throughout this documentation, \e device refers to a physical USB AirPcap device, while \e adapter is an open API
84         instance. Most of the AirPcap API operations are adapter-specific but some of them, like setting the channel, are
85         per-device and will be reflected on all the open adapters. These functions will have "Device" in their name, e.g.
86         AirpcapSetDeviceChannel().
87
88         \b Sections:
89
90         - \ref airpcapfuncs
91         - \ref airpcapdefs
92         - \ref radiotap
93 */
94
95 /**
96  * Init the whole epan module.
97  *
98  * Must be called only once in a program.
99  *
100  * Returns TRUE on success, FALSE on failure.
101  */
102 WS_DLL_PUBLIC
103 gboolean epan_init(register_cb cb, void *client_data, gboolean load_plugins);
104
105 /**
106  * Load all settings, from the current profile, that affect epan.
107  */
108 WS_DLL_PUBLIC
109 e_prefs *epan_load_settings(void);
110
111 /** cleanup the whole epan module, this is used to be called only once in a program */
112 WS_DLL_PUBLIC
113 void epan_cleanup(void);
114
115 #ifdef HAVE_PLUGINS
116 typedef struct {
117         void (*init)(void);
118         void (*dissect_init)(epan_dissect_t *);
119         void (*dissect_cleanup)(epan_dissect_t *);
120         void (*cleanup)(void);
121         void (*register_all_protocols)(register_cb, gpointer);
122         void (*register_all_handoffs)(register_cb, gpointer);
123 } epan_plugin;
124
125 WS_DLL_PUBLIC void epan_register_plugin(const epan_plugin *plugin);
126 #endif
127 /**
128  * Initialize the table of conversations.  Conversations are identified by
129  * their endpoints; they are used for protocols such as IP, TCP, and UDP,
130  * where packets contain endpoint information but don't contain a single
131  * value indicating to which flow the packet belongs.
132  */
133 void epan_conversation_init(void);
134
135 /** A client will create one epan_t for an entire dissection session.
136  * A single epan_t will be used to analyze the entire sequence of packets,
137  * sequentially, in a single session. A session corresponds to a single
138  * packet trace file. The reasons epan_t exists is that some packets in
139  * some protocols cannot be decoded without knowledge of previous packets.
140  * This inter-packet "state" is stored in the epan_t.
141  */
142 typedef struct epan_session epan_t;
143
144 WS_DLL_PUBLIC epan_t *epan_new(struct packet_provider_data *prov,
145     const struct packet_provider_funcs *funcs);
146
147 WS_DLL_PUBLIC const char *epan_get_user_comment(const epan_t *session, const frame_data *fd);
148
149 WS_DLL_PUBLIC const char *epan_get_interface_name(const epan_t *session, guint32 interface_id);
150
151 WS_DLL_PUBLIC const char *epan_get_interface_description(const epan_t *session, guint32 interface_id);
152
153 const nstime_t *epan_get_frame_ts(const epan_t *session, guint32 frame_num);
154
155 WS_DLL_PUBLIC void epan_free(epan_t *session);
156
157 WS_DLL_PUBLIC const gchar*
158 epan_get_version(void);
159
160 WS_DLL_PUBLIC void epan_get_version_number(int *major, int *minor, int *micro);
161
162 /**
163  * Set/unset the tree to always be visible when epan_dissect_init() is called.
164  * This state change sticks until cleared, rather than being done per function call.
165  * This is currently used when Lua scripts request all fields be generated.
166  * By default it only becomes visible if epan_dissect_init() makes it so, usually
167  * only when a packet is selected.
168  * Setting this overrides that so it's always visible, although it will still not be
169  * created if create_proto_tree is false in the call to epan_dissect_init().
170  * Clearing this reverts the decision to epan_dissect_init() and proto_tree_visible.
171  */
172 void epan_set_always_visible(gboolean force);
173
174 /** initialize an existing single packet dissection */
175 WS_DLL_PUBLIC
176 void
177 epan_dissect_init(epan_dissect_t *edt, epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible);
178
179 /** get a new single packet dissection
180  * should be freed using epan_dissect_free() after packet dissection completed
181  */
182 WS_DLL_PUBLIC
183 epan_dissect_t*
184 epan_dissect_new(epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible);
185
186 WS_DLL_PUBLIC
187 void
188 epan_dissect_reset(epan_dissect_t *edt);
189
190 /** Indicate whether we should fake protocols or not */
191 WS_DLL_PUBLIC
192 void
193 epan_dissect_fake_protocols(epan_dissect_t *edt, const gboolean fake_protocols);
194
195 /** run a single packet dissection */
196 WS_DLL_PUBLIC
197 void
198 epan_dissect_run(epan_dissect_t *edt, int file_type_subtype,
199         wtap_rec *rec, tvbuff_t *tvb, frame_data *fd,
200         struct epan_column_info *cinfo);
201
202 WS_DLL_PUBLIC
203 void
204 epan_dissect_run_with_taps(epan_dissect_t *edt, int file_type_subtype,
205         wtap_rec *rec, tvbuff_t *tvb, frame_data *fd,
206         struct epan_column_info *cinfo);
207
208 /** run a single file packet dissection */
209 WS_DLL_PUBLIC
210 void
211 epan_dissect_file_run(epan_dissect_t *edt, wtap_rec *rec,
212         tvbuff_t *tvb, frame_data *fd, struct epan_column_info *cinfo);
213
214 WS_DLL_PUBLIC
215 void
216 epan_dissect_file_run_with_taps(epan_dissect_t *edt, wtap_rec *rec,
217         tvbuff_t *tvb, frame_data *fd, struct epan_column_info *cinfo);
218
219 /** Prime an epan_dissect_t's proto_tree using the fields/protocols used in a dfilter. */
220 WS_DLL_PUBLIC
221 void
222 epan_dissect_prime_with_dfilter(epan_dissect_t *edt, const struct epan_dfilter *dfcode);
223
224 /** Prime an epan_dissect_t's proto_tree with a field/protocol specified by its hfid */
225 WS_DLL_PUBLIC
226 void
227 epan_dissect_prime_with_hfid(epan_dissect_t *edt, int hfid);
228
229 /** Prime an epan_dissect_t's proto_tree with a set of fields/protocols specified by their hfids in a GArray */
230 WS_DLL_PUBLIC
231 void
232 epan_dissect_prime_with_hfid_array(epan_dissect_t *edt, GArray *hfids);
233
234 /** fill the dissect run output into the packet list columns */
235 WS_DLL_PUBLIC
236 void
237 epan_dissect_fill_in_columns(epan_dissect_t *edt, const gboolean fill_col_exprs, const gboolean fill_fd_colums);
238
239 /** Check whether a dissected packet contains a given named field */
240 WS_DLL_PUBLIC
241 gboolean
242 epan_dissect_packet_contains_field(epan_dissect_t* edt,
243                                    const char *field_name);
244
245 /** releases resources attached to the packet dissection. DOES NOT free the actual pointer */
246 WS_DLL_PUBLIC
247 void
248 epan_dissect_cleanup(epan_dissect_t* edt);
249
250 /** free a single packet dissection */
251 WS_DLL_PUBLIC
252 void
253 epan_dissect_free(epan_dissect_t* edt);
254
255 /** Sets custom column */
256 const gchar *
257 epan_custom_set(epan_dissect_t *edt, GSList *ids, gint occurrence,
258                                 gchar *result, gchar *expr, const int size);
259
260 /**
261  * Get compile-time information for libraries used by libwireshark.
262  */
263 WS_DLL_PUBLIC
264 void
265 epan_get_compiled_version_info(GString *str);
266
267 /**
268  * Get runtime information for libraries used by libwireshark.
269  */
270 WS_DLL_PUBLIC
271 void
272 epan_get_runtime_version_info(GString *str);
273
274 #ifdef __cplusplus
275 }
276 #endif /* __cplusplus */
277
278 #endif /* __EPAN_H__ */