From Gisle Vanem:
[obnox/wireshark/wip.git] / plugins / plugin_api_list.c
1 /* plugin_api_list.c
2  * Used to generate various included files for plugin API
3  *
4  * $Id: plugin_api_list.c,v 1.13 2003/11/02 23:12:34 gerald Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@ethereal.com>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include <epan/packet.h>
30 #include <epan/conversation.h>
31 #include <epan/filesystem.h>
32 #include "prefs.h"
33 #include "reassemble.h"
34 #include "packet-giop.h"
35 #include "packet-per.h"
36 #include "packet-tpkt.h"
37 #include "packet-tcp.h"
38 #include "tap.h"
39 #include "asn1.h"
40 #include "epan/except.h"
41
42 gint check_col(column_info*, gint);
43 void col_clear(column_info*, gint);
44 void col_add_fstr(column_info*, gint, const gchar*, ...);
45 void col_append_fstr(column_info*, gint, const gchar*, ...);
46 void col_prepend_fstr(column_info*, gint, const gchar*, ...);
47 void col_add_str(column_info*, gint, const gchar*);
48 void col_append_str(column_info*, gint, const gchar*);
49 void col_set_str(column_info*, gint, gchar*);
50
51 void register_init_routine(void (*func)(void));
52 void register_postseq_cleanup_routine(void (*func)(void));
53
54 gchar* match_strval(guint32, const value_string*);
55 gchar* val_to_str(guint32, const value_string *, const char *);
56
57 conversation_t *conversation_new(address *, address *,
58     port_type, guint32, guint32, guint);
59 conversation_t *find_conversation(address *, address *,
60     port_type, guint32, guint32, guint);
61 void conversation_set_dissector(conversation_t *,
62     dissector_handle_t);
63
64 int proto_register_protocol(char*, char*, char*);
65 void proto_register_field_array(int, hf_register_info*, int);
66 void proto_register_subtree_array(int**, int);
67
68 void dissector_add(const char *, guint32, dissector_handle_t);
69 void dissector_delete(const char *, guint32,
70     dissector_handle_t);
71 void dissector_add_handle(const char *,
72     dissector_handle_t);
73
74 void heur_dissector_add(const char *, heur_dissector_t, int);
75
76 void register_dissector(const char *, dissector_t, int);
77 dissector_handle_t find_dissector(const char *);
78 dissector_handle_t create_dissector_handle(dissector_t dissector,
79     int proto);
80 int call_dissector(dissector_handle_t, tvbuff_t *,
81     packet_info *, proto_tree *);
82
83 void tcp_dissect_pdus(tvbuff_t *, packet_info *, proto_tree *,
84     gboolean, guint, guint (*)(tvbuff_t *, int),
85     void (*)(tvbuff_t *, packet_info *, proto_tree *));
86
87 gboolean proto_is_protocol_enabled(int);
88
89 int proto_item_get_len(proto_item*);
90 void proto_item_set_len(proto_item*, gint);
91 void proto_item_set_text(proto_item*, const char*, ...);
92 void proto_item_append_text(proto_item*, const char*, ...);
93 proto_tree* proto_item_add_subtree(proto_item*, gint);
94 proto_item* proto_tree_add_item(proto_tree*, int, tvbuff_t*, gint, gint, gboolean);
95 proto_item* proto_tree_add_item_hidden(proto_tree*, int, tvbuff_t*, gint, gint, gboolean);
96 proto_item* proto_tree_add_protocol_format(proto_tree*, int, tvbuff_t*, gint, gint, const char*, ...);
97
98 proto_item* proto_tree_add_bytes(proto_tree*, int, tvbuff_t*, gint, gint, const guint8*);
99 proto_item* proto_tree_add_bytes_hidden(proto_tree*, int, tvbuff_t*, gint, gint, const guint8*);
100 proto_item* proto_tree_add_bytes_format(proto_tree*, int, tvbuff_t*, gint, gint, const guint8*, const char*, ...);
101
102 proto_item* proto_tree_add_time(proto_tree*, int, tvbuff_t*, gint, gint, nstime_t*);
103 proto_item* proto_tree_add_time_hidden(proto_tree*, int, tvbuff_t*, gint, gint, nstime_t*);
104 proto_item* proto_tree_add_time_format(proto_tree*, int, tvbuff_t*, gint, gint, nstime_t*, const char*, ...);
105
106 proto_item* proto_tree_add_ipxnet(proto_tree*, int, tvbuff_t*, gint, gint, guint32);
107 proto_item* proto_tree_add_ipxnet_hidden(proto_tree*, int, tvbuff_t*, gint, gint, guint32);
108 proto_item* proto_tree_add_ipxnet_format(proto_tree*, int, tvbuff_t*, gint, gint, guint32, const char*, ...);
109
110 proto_item* proto_tree_add_ipv4(proto_tree*, int, tvbuff_t*, gint, gint, guint32);
111 proto_item* proto_tree_add_ipv4_hidden(proto_tree*, int, tvbuff_t*, gint, gint, guint32);
112 proto_item* proto_tree_add_ipv4_format(proto_tree*, int, tvbuff_t*, gint, gint, guint32, const char*, ...);
113
114 proto_item* proto_tree_add_ipv6(proto_tree*, int, tvbuff_t*, gint, gint, const guint8*);
115 proto_item* proto_tree_add_ipv6_hidden(proto_tree*, int, tvbuff_t*, gint, gint, const guint8*);
116 proto_item* proto_tree_add_ipv6_format(proto_tree*, int, tvbuff_t*, gint, gint, const guint8*, const char*, ...);
117
118 proto_item* proto_tree_add_ether(proto_tree*, int, tvbuff_t*, gint, gint, const guint8*);
119 proto_item* proto_tree_add_ether_hidden(proto_tree*, int, tvbuff_t*, gint, gint, const guint8*);
120 proto_item* proto_tree_add_ether_format(proto_tree*, int, tvbuff_t*, gint, gint, const guint8*, const char*, ...);
121
122 proto_item* proto_tree_add_string(proto_tree*, int, tvbuff_t*, gint, gint, const char*);
123 proto_item* proto_tree_add_string_hidden(proto_tree*, int, tvbuff_t*, gint, gint, const char*);
124 proto_item* proto_tree_add_string_format(proto_tree*, int, tvbuff_t*, gint, gint, const char*, const char*, ...);
125
126 proto_item* proto_tree_add_boolean(proto_tree*, int, tvbuff_t*, gint, gint, guint32);
127 proto_item* proto_tree_add_boolean_hidden(proto_tree*, int, tvbuff_t*, gint, gint, guint32);
128 proto_item* proto_tree_add_boolean_format(proto_tree*, int, tvbuff_t*, gint, gint, guint32, const char*, ...);
129
130 proto_item* proto_tree_add_double(proto_tree*, int, tvbuff_t*, gint, gint, double);
131 proto_item* proto_tree_add_double_hidden(proto_tree*, int, tvbuff_t*, gint, gint, double);
132 proto_item* proto_tree_add_double_format(proto_tree*, int, tvbuff_t*, gint, gint, double, const char*, ...);
133
134 proto_item* proto_tree_add_uint(proto_tree*, int, tvbuff_t*, gint, gint, guint32);
135 proto_item* proto_tree_add_uint_hidden(proto_tree*, int, tvbuff_t*, gint, gint, guint32);
136 proto_item* proto_tree_add_uint_format(proto_tree*, int, tvbuff_t*, gint, gint, guint32, const char*, ...);
137
138 proto_item* proto_tree_add_int(proto_tree*, int, tvbuff_t*, gint, gint, gint32);
139 proto_item* proto_tree_add_int_hidden(proto_tree*, int, tvbuff_t*, gint, gint, gint32);
140 proto_item* proto_tree_add_int_format(proto_tree*, int, tvbuff_t*, gint, gint, gint32, const char*, ...);
141
142 proto_item* proto_tree_add_text(proto_tree*, tvbuff_t*, gint, gint, const char*, ...);
143
144 tvbuff_t* tvb_new_subset(tvbuff_t*, gint, gint, gint);
145
146 void tvb_set_free_cb(tvbuff_t*, tvbuff_free_cb_t);
147 void tvb_set_child_real_data_tvbuff(tvbuff_t*, tvbuff_t*);
148 tvbuff_t* tvb_new_real_data(const guint8*, guint, gint);
149
150 guint tvb_length(tvbuff_t*);
151 gint tvb_length_remaining(tvbuff_t*, gint);
152 gboolean tvb_bytes_exist(tvbuff_t*, gint, gint);
153 gboolean tvb_offset_exists(tvbuff_t*, gint);
154 guint tvb_reported_length(tvbuff_t*);
155 gint tvb_reported_length_remaining(tvbuff_t*, gint);
156
157 guint8 tvb_get_guint8(tvbuff_t*, gint);
158
159 guint16 tvb_get_ntohs(tvbuff_t*, gint);
160 guint32 tvb_get_ntoh24(tvbuff_t*, gint);
161 guint32 tvb_get_ntohl(tvbuff_t*, gint);
162
163 guint16 tvb_get_letohs(tvbuff_t*, gint);
164 guint32 tvb_get_letoh24(tvbuff_t*, gint);
165 guint32 tvb_get_letohl(tvbuff_t*, gint);
166
167 guint8* tvb_memcpy(tvbuff_t*, guint8* target, gint, gint);
168 guint8* tvb_memdup(tvbuff_t*, gint, gint);
169
170 const guint8* tvb_get_ptr(tvbuff_t*, gint, gint);
171
172 gint tvb_find_guint8(tvbuff_t*, gint, gint, guint8);
173 gint tvb_pbrk_guint8(tvbuff_t *, gint, gint, guint8 *);
174
175 gint tvb_strnlen(tvbuff_t*, gint, guint);
176
177 guint8 * tvb_format_text(tvbuff_t*, gint, gint);
178
179 gint tvb_get_nstringz(tvbuff_t*, gint, guint, guint8*);
180 gint tvb_get_nstringz0(tvbuff_t*, gint, guint, guint8*);
181
182 gint tvb_find_line_end(tvbuff_t*, gint, int, gint *, gboolean);
183 gint tvb_find_line_end_unquoted(tvbuff_t*, gint, int, gint *);
184
185 gint tvb_strneql(tvbuff_t*, gint, const guint8 *, gint);
186 gint tvb_strncaseeql(tvbuff_t*, gint, const guint8 *, gint);
187
188 gchar *tvb_bytes_to_str(tvbuff_t*, gint, gint len);
189
190 struct pref_module *prefs_register_protocol(int,
191     void (*)(void));
192 void prefs_register_uint_preference(struct pref_module *,
193     const char *, const char *, const char *, guint, guint *);
194 void prefs_register_bool_preference(struct pref_module *,
195     const char *, const char *, const char *, gboolean *);
196 void prefs_register_enum_preference(struct pref_module *,
197     const char *, const char *, const char *, gint *, const enum_val_t *,
198     gboolean);
199 void prefs_register_string_preference(struct pref_module *,
200     const char *, const char *, const char *, char**);
201
202 void register_giop_user(giop_sub_dissector_t *, gchar *, int);
203 gboolean is_big_endian(MessageHeader *);
204 guint32 get_CDR_encap_info(tvbuff_t *, proto_tree *, gint *,
205                 gboolean, guint32, gboolean *, guint32 *);
206 void get_CDR_any(tvbuff_t *, proto_tree *, gint *,
207                 gboolean, int, MessageHeader *);
208 gboolean get_CDR_boolean(tvbuff_t *, int *);
209 guint8 get_CDR_char(tvbuff_t *, int *);
210 gdouble get_CDR_double(tvbuff_t *, int *, gboolean, int);
211 guint32 get_CDR_enum(tvbuff_t *, int *, gboolean, int);
212 void get_CDR_fixed(tvbuff_t *, gchar **, gint *, guint32,
213                 gint32);
214 gfloat get_CDR_float(tvbuff_t *, int *, gboolean, int);
215 void get_CDR_interface(tvbuff_t *, packet_info *, proto_tree *,
216                 int *, gboolean, int);
217 gint32 get_CDR_long(tvbuff_t *, int *, gboolean, int);
218 void get_CDR_object(tvbuff_t *, packet_info *, proto_tree *,
219                 int *, gboolean, int);
220 guint8 get_CDR_octet(tvbuff_t *, int *);
221 void get_CDR_octet_seq(tvbuff_t *, gchar **, int *, guint32);
222 gint16 get_CDR_short(tvbuff_t *, int *, gboolean, int);
223 guint32 get_CDR_string(tvbuff_t *, gchar **, int *, gboolean,
224                 int);
225 guint32 get_CDR_typeCode(tvbuff_t *, proto_tree *, gint *,
226         gboolean, int, MessageHeader *);
227 guint32 get_CDR_ulong(tvbuff_t *, int *, gboolean, int);
228 guint16 get_CDR_ushort(tvbuff_t *, int *, gboolean, int);
229 gint get_CDR_wchar(tvbuff_t *, gchar **, int *,
230                 MessageHeader *);
231 guint32 get_CDR_wstring(tvbuff_t *, gchar **, int *, gboolean,
232                 int, MessageHeader *);
233
234 int is_tpkt(tvbuff_t *, int);
235 void dissect_tpkt_encap(tvbuff_t *, packet_info *,
236     proto_tree *, gboolean, dissector_handle_t);
237
238 void set_actual_length(tvbuff_t *, guint);
239
240 const char *decode_boolean_bitfield(guint32, guint32, int,
241     const char *, const char *);
242 const char *decode_numeric_bitfield(guint32, guint32, int,
243     const char *);
244 const char *decode_enumerated_bitfield(guint32, guint32, int,
245     const value_string *, const char *);
246
247 dissector_table_t register_dissector_table(const char *, char *, ftenum_t ,int );
248 void except_throw(long, long, const char *);
249 gboolean dissector_try_port(dissector_table_t, guint32, tvbuff_t *, packet_info *, proto_tree *);
250
251 void conversation_add_proto_data(conversation_t *, int, void *);
252 void *conversation_get_proto_data(conversation_t *, int);
253 void conversation_delete_proto_data(conversation_t *, int);
254 void p_add_proto_data(frame_data *, int, void *);
255 void *p_get_proto_data(frame_data *, int);
256
257 gchar*  ip_to_str(const guint8 *);
258 char*   ip6_to_str(const struct e_in6_addr *);
259 gchar*  time_secs_to_str(guint32);
260 gchar*  time_msecs_to_str(guint32);
261 gchar*  abs_time_to_str(nstime_t*);
262
263 int proto_get_id_by_filter_name(gchar* filter_name);
264 char *proto_get_protocol_name(int n);
265 char *proto_get_protocol_short_name(int proto_id);
266 char *proto_get_protocol_filter_name(int proto_id);
267
268 void prefs_register_obsolete_preference(module_t *, const char *);
269
270 void add_new_data_source(packet_info *, tvbuff_t *, char *);
271
272 void fragment_table_init(GHashTable **);
273 void reassembled_table_init(GHashTable **);
274 fragment_data *fragment_add(tvbuff_t *, int, packet_info *, guint32,
275                         GHashTable *, guint32, guint32, gboolean);
276 fragment_data *fragment_add_seq(tvbuff_t *, int, packet_info *, guint32,
277                         GHashTable *, guint32, guint32, gboolean);
278 fragment_data *fragment_add_seq_check(tvbuff_t *, int, packet_info *, guint32 id,
279                         GHashTable *, GHashTable *, guint32, guint32, gboolean);
280 fragment_data *fragment_add_seq_next(tvbuff_t *, int, packet_info *, guint32,
281                         GHashTable *, GHashTable *, guint32, gboolean);
282 fragment_data *fragment_get(packet_info *, guint32, GHashTable *);
283 void fragment_set_tot_len(packet_info *, guint32, GHashTable *, guint32);
284 guint32 fragment_get_tot_len(packet_info *, guint32, GHashTable *);
285 void fragment_set_partial_reassembly(packet_info *, guint32, GHashTable *);
286 unsigned char *fragment_delete(packet_info *, guint32, GHashTable *);
287 gboolean show_fragment_tree(fragment_data *, const fragment_items *, proto_tree *, packet_info *, tvbuff_t *);
288 gboolean show_fragment_seq_tree(fragment_data *, const fragment_items *, proto_tree *, packet_info *, tvbuff_t *);
289
290 int register_tap(char *);
291 void tap_queue_packet(int, packet_info *, void *);
292
293 void asn1_open(ASN1_SCK *, tvbuff_t *, int );
294 void asn1_close(ASN1_SCK *, int *);
295 int asn1_octet_decode(ASN1_SCK *, guchar *);
296 int asn1_tag_decode(ASN1_SCK *, guint *);
297 int asn1_id_decode(ASN1_SCK *, guint *, guint *, guint *);
298 int asn1_length_decode(ASN1_SCK *, gboolean *, guint *);
299 int asn1_header_decode(ASN1_SCK *, guint *, guint *, guint *,
300                         gboolean *, guint *);
301 int asn1_eoc(ASN1_SCK *, int );
302 int asn1_eoc_decode(ASN1_SCK *, int );
303 int asn1_null_decode(ASN1_SCK *, int );
304 int asn1_bool_decode(ASN1_SCK *, int , gboolean *);
305 int asn1_int32_value_decode(ASN1_SCK *, int , gint32 *);
306 int asn1_int32_decode(ASN1_SCK *, gint32 *, guint *);
307 int asn1_uint32_value_decode(ASN1_SCK *, int , guint *);
308 int asn1_uint32_decode(ASN1_SCK *, guint32 *, guint *);
309 int asn1_bits_decode(ASN1_SCK *, int , guchar **,
310                              guint *, guchar *);
311 int asn1_string_value_decode(ASN1_SCK *, int ,
312                         guchar **);
313 int asn1_string_decode(ASN1_SCK *, guchar **, guint *,
314                         guint *, guint );
315 int asn1_octet_string_decode(ASN1_SCK *, guchar **, guint *,
316                         guint *);
317 int asn1_subid_decode(ASN1_SCK *, subid_t *);
318 int asn1_oid_value_decode(ASN1_SCK *, int , subid_t **,
319                         guint *);
320 int asn1_oid_decode( ASN1_SCK *, subid_t **, guint *, guint *);
321 int asn1_sequence_decode( ASN1_SCK *, guint *, guint *);
322
323 char *asn1_err_to_str(int );
324
325 void proto_item_set_end(proto_item*, tvbuff_t *, gint);
326
327 proto_item* proto_tree_add_none_format(proto_tree*, int, tvbuff_t*, gint, gint, const char*, ...);
328
329 int except_init(void);
330 void except_deinit(void);
331 void except_rethrow(except_t *);
332 void except_throwd(long, long, const char *, void *);
333 void except_throwf(long, long, const char *, ...);
334 void (*except_unhandled_catcher(void (*)(except_t *)))(except_t *);
335 void *except_take_data(except_t *);
336 void except_set_allocator(void *(*)(size_t), void (*)(void *));
337 void *except_alloc(size_t);
338 void except_free(void *);
339 struct except_stacknode *except_pop(void);
340 void except_setup_try(struct except_stacknode *, struct except_catch *, const except_id_t [], size_t);
341
342 void col_set_fence(column_info*, gint);
343
344 guint8 *tvb_get_string(tvbuff_t *, gint, gint);
345 guint8 *tvb_get_stringz(tvbuff_t *, gint, gint *);
346
347 dissector_table_t find_dissector_table(const char *);
348 dissector_handle_t dissector_get_port_handle(dissector_table_t, guint32);
349 char *dissector_handle_get_short_name(dissector_handle_t);
350 int dissector_handle_get_protocol_index(dissector_handle_t);
351 void new_register_dissector(const char *, new_dissector_t, int); 
352 dissector_handle_t new_create_dissector_handle(new_dissector_t, int);
353
354 void register_giop_user_module(giop_sub_dissector_t *sub, gchar *name, gchar *module, int sub_proto);
355
356 guint32 dissect_per_GeneralString(tvbuff_t*, guint32, packet_info*, proto_tree*, int);
357 guint32 dissect_per_sequence_of(tvbuff_t*, guint32, packet_info*, proto_tree*, int, gint, int (*)(tvbuff_t*, int, packet_info*, proto_tree*));
358 guint32 dissect_per_IA5String(tvbuff_t*, guint32, packet_info*, proto_tree*, int, int, int);
359 guint32 dissect_per_NumericString(tvbuff_t*, guint32, packet_info*, proto_tree*, int, int, int);
360 guint32 dissect_per_PrintableString(tvbuff_t*, guint32, packet_info*, proto_tree*, int, int, int);
361 guint32 dissect_per_BMPString(tvbuff_t*, guint32, packet_info*, proto_tree*, int, int, int);
362 guint32 dissect_per_constrained_sequence_of(tvbuff_t*, guint32, packet_info*, proto_tree*, int, gint, int (*)(tvbuff_t*, int, packet_info*, proto_tree*), int, int);
363 guint32 dissect_per_constrained_set_of(tvbuff_t*, guint32, packet_info*, proto_tree *parent_tree, int, gint, int (*)(tvbuff_t*, int, packet_info*, proto_tree*), int, int);
364 guint32 dissect_per_set_of(tvbuff_t*, guint32, packet_info*, proto_tree *parent_tree, int, gint, int (*)(tvbuff_t*, int, packet_info*, proto_tree*));
365 guint32 dissect_per_object_identifier(tvbuff_t*, guint32, packet_info*, proto_tree*, int, char*);
366 guint32 dissect_per_boolean(tvbuff_t*, guint32, packet_info *pinfo, proto_tree*, int, gboolean*, proto_item**);
367 guint32 dissect_per_integer(tvbuff_t*, guint32, packet_info*, proto_tree*, int, gint32*, proto_item**);
368 guint32 dissect_per_constrained_integer(tvbuff_t*, guint32, packet_info*, proto_tree*, int, guint32, guint32, guint32*, proto_item**, gboolean);
369 guint32 dissect_per_choice(tvbuff_t*, guint32, packet_info*, proto_tree*, int, gint, per_choice_t*, char*, guint32*);
370 guint32 dissect_per_sequence(tvbuff_t*, guint32, packet_info*, proto_tree *parent_tree, int, gint, per_sequence_t*);
371 guint32 dissect_per_octet_string(tvbuff_t*, guint32, packet_info*, proto_tree*, int, int, int, guint32*, guint32*);
372 guint32 dissect_per_restricted_character_string(tvbuff_t*, guint32, packet_info*, proto_tree*, int, int, int, char*, int);
373
374 void dissector_add_string(const char*, gchar*, dissector_handle_t);
375 void dissector_delete_string(const char*, const gchar*, dissector_handle_t);
376 void dissector_change_string(const char*, gchar *, dissector_handle_t);
377 void dissector_reset_string(const char*, const gchar*);
378 gboolean dissector_try_string(dissector_table_t, const gchar*, tvbuff_t*, packet_info*, proto_tree*);
379 dissector_handle_t dissector_get_string_handle(dissector_table_t, const gchar*);
380
381 char *get_datafile_path(const char *filename);
382 char *get_tempfile_path(const char *filename);
383
384 void register_heur_dissector_list(const char *name,
385     heur_dissector_list_t *list);
386 gboolean dissector_try_heuristic(heur_dissector_list_t sub_dissectors,
387     tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);