5 * Wireshark Protocol Analyzer Library
7 * Copyright (c) 2001 by Gerald Combs <gerald@wireshark.org>
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 #if (defined(HAVE_LIBGCRYPT) || defined(HAVE_LIBGNUTLS)) && defined(_WIN32)
29 #include <winposixtype.h>
34 #endif /* HAVE_LIBGCRYPT */
37 #include <gnutls/gnutls.h>
38 #endif /* HAVE_LIBGNUTLS */
43 #include "epan_dissect.h"
44 #include "report_err.h"
46 #include "conversation.h"
50 #include "column-utils.h"
52 #include "addr_resolv.h"
53 #include "oid_resolv.h"
58 int wslua_init(void*);
61 static void (*report_failure_func)(const char *, va_list);
62 static void (*report_open_failure_func)(const char *, int, gboolean);
63 static void (*report_read_failure_func)(const char *, int);
66 epan_get_version(void) {
71 epan_init(void (*register_all_protocols)(void),
72 void (*register_all_handoffs)(void),
73 void (*report_failure)(const char *, va_list),
74 void (*report_open_failure)(const char *, int, gboolean),
75 void (*report_read_failure)(const char *, int))
77 report_failure_func = report_failure;
78 report_open_failure_func = report_open_failure;
79 report_read_failure_func = report_read_failure;
81 /* initialize memory allocation subsystem */
85 /* initialize the GUID to name mapping table */
91 #elif defined(HAVE_LIBGCRYPT)
92 gcry_check_version(NULL);
97 proto_init(register_all_protocols, register_all_handoffs);
100 final_registration_all_protocols();
101 host_name_lookup_init();
116 oid_resolv_cleanup();
118 #ifdef HAVE_LIBGNUTLS
119 gnutls_global_deinit();
122 host_name_lookup_cleanup();
126 epan_conversation_init(void)
132 epan_circuit_init(void)
138 * Report a general error.
141 report_failure(const char *msg_format, ...)
145 va_start(ap, msg_format);
146 (*report_failure_func)(msg_format, ap);
151 * Report an error when trying to open or create a file.
152 * "err" is assumed to be an error code from Wiretap; positive values are
153 * UNIX-style errnos, so this can be used for open failures not from
154 * Wiretap as long as the failue code is just an errno.
157 report_open_failure(const char *filename, int err,
158 gboolean for_writing)
160 (*report_open_failure_func)(filename, err, for_writing);
164 * Report an error when trying to read a file.
165 * "err" is assumed to be a UNIX-style errno.
168 report_read_failure(const char *filename, int err)
170 (*report_read_failure_func)(filename, err);
174 epan_dissect_new(gboolean create_proto_tree, gboolean proto_tree_visible)
178 edt = g_new(epan_dissect_t, 1);
180 if (create_proto_tree) {
181 edt->tree = proto_tree_create_root();
182 proto_tree_set_visible(edt->tree, proto_tree_visible);
192 epan_dissect_run(epan_dissect_t *edt, void* pseudo_header,
193 const guint8* data, frame_data *fd, column_info *cinfo)
195 /* free all memory allocated during previous packet */
198 dissect_packet(edt, pseudo_header, data, fd, cinfo);
203 epan_dissect_free(epan_dissect_t* edt)
205 /* Free the data sources list. */
206 free_data_sources(&edt->pi);
208 /* Free all tvb's created from this tvb, unless dissector
209 * wanted to store the pointer (in which case, the dissector
210 * would have incremented the usage count on that tvbuff_t*) */
211 tvb_free_chain(edt->tvb);
214 proto_tree_free(edt->tree);
221 epan_dissect_prime_dfilter(epan_dissect_t *edt, const dfilter_t* dfcode)
223 dfilter_prime_proto_tree(dfcode, edt->tree);
227 epan_dissect_fill_in_columns(epan_dissect_t *edt)
229 col_fill_in(&edt->pi);