| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
packet.h
Go to the documentation of this file.
1
11#ifndef __PACKET_H__
12#define __PACKET_H__
13
14#include <wsutil/array.h>
15#include <wiretap/wtap_opttypes.h>
16#include "proto.h"
17#include "range.h"
18#include "tvbuff.h"
19#include "epan.h"
20#include "frame_data.h"
21#include "packet_info.h"
22#include "column-utils.h"
23#include "guid-utils.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif /* __cplusplus */
28
29
30
36#define hi_nibble(b) (((b) & 0xf0) >> 4)
37#define lo_nibble(b) ((b) & 0x0f)
38
39/* Check whether the "len" bytes of data starting at "offset" is
40 * entirely inside the captured data for this packet. */
41#define BYTES_ARE_IN_FRAME(offset, captured_len, len) \
42 ((unsigned)(offset) + (unsigned)(len) > (unsigned)(offset) && \
43 (unsigned)(offset) + (unsigned)(len) <= (unsigned)(captured_len))
44
45/* 0 is case sensitive for backwards compatibility with tables that
46 * used false or BASE_NONE for case sensitive, which was the default.
47 */
48#define STRING_CASE_SENSITIVE 0
49#define STRING_CASE_INSENSITIVE 1
50
51extern void packet_init(void);
52extern void packet_cache_proto_handles(void);
53extern void packet_all_tables_sort_handles(void);
54extern void packet_cleanup(void);
55
56/* Handle for dissectors you call directly or register with "dissector_add_uint()".
57 This handle is opaque outside of "packet.c". */
58struct dissector_handle;
59typedef struct dissector_handle *dissector_handle_t;
60
61/* Hash table for matching unsigned integers, or strings, and dissectors;
62 this is opaque outside of "packet.c". */
63struct dissector_table;
64typedef struct dissector_table *dissector_table_t;
65
66/*
67 * Dissector that returns:
68 *
69 * The amount of data in the protocol's PDU, if it was able to
70 * dissect all the data;
71 *
72 * 0, if the tvbuff doesn't contain a PDU for that protocol;
73 *
74 * The negative of the amount of additional data needed, if
75 * we need more data (e.g., from subsequent TCP segments) to
76 * dissect the entire PDU.
77 */
78typedef int (*dissector_t)(tvbuff_t *, packet_info *, proto_tree *, void *);
79
80/* Same as dissector_t with an extra parameter for callback pointer */
81typedef int (*dissector_cb_t)(tvbuff_t *, packet_info *, proto_tree *, void *, void *);
82
90 typedef bool (*heur_dissector_t)(tvbuff_t *tvb, packet_info *pinfo,
91 proto_tree *tree, void *);
92
93typedef enum {
94 HEURISTIC_DISABLE,
95 HEURISTIC_ENABLE
96} heuristic_enable_e;
97
98typedef void (*DATFunc) (const char *table_name, ftenum_t selector_type,
99 void *key, void *value, void *user_data);
100typedef void (*DATFunc_handle) (const char *table_name, void *value,
101 void *user_data);
102typedef void (*DATFunc_table) (const char *table_name, const char *ui_name,
103 void *user_data);
104
105/* Opaque structure - provides type checking but no access to components */
106typedef struct dtbl_entry dtbl_entry_t;
107
108WS_DLL_PUBLIC dissector_handle_t dtbl_entry_get_handle (dtbl_entry_t *dtbl_entry);
109WS_DLL_PUBLIC dissector_handle_t dtbl_entry_get_initial_handle (dtbl_entry_t * entry);
110
120void dissector_table_foreach_changed (const char *table_name, DATFunc func,
121 void *user_data);
122
132WS_DLL_PUBLIC void dissector_table_foreach (const char *table_name, DATFunc func,
133 void *user_data);
134
143WS_DLL_PUBLIC void dissector_all_tables_foreach_changed (DATFunc func,
144 void *user_data);
145
155WS_DLL_PUBLIC void dissector_table_foreach_handle(const char *table_name, DATFunc_handle func,
156 void *user_data);
157
166WS_DLL_PUBLIC void dissector_all_tables_foreach_table (DATFunc_table func,
167 void *user_data, GCompareFunc compare_key_func);
168
169/* a protocol uses the function to register a sub-dissector table
170 *
171 * 'param' is the display base for integer tables, STRING_CASE_SENSITIVE
172 * or STRING_CASE_INSENSITIVE for string tables, and ignored for other
173 * table types.
174 */
175WS_DLL_PUBLIC dissector_table_t register_dissector_table(const char *name,
176 const char *ui_name, const int proto, const ftenum_t type, const int param);
177
178/*
179 * Similar to register_dissector_table, but with a "custom" hash function
180 * to store subdissectors.
181 */
182WS_DLL_PUBLIC dissector_table_t register_custom_dissector_table(const char *name,
183 const char *ui_name, const int proto, GHashFunc hash_func, GEqualFunc key_equal_func,
184 GDestroyNotify key_destroy_func);
185
191WS_DLL_PUBLIC void register_dissector_table_alias(dissector_table_t dissector_table,
192 const char *alias_name);
193
195void deregister_dissector_table(const char *name);
196
197/* Find a dissector table by table name. */
198WS_DLL_PUBLIC dissector_table_t find_dissector_table(const char *name);
199
200/* Get the UI name for a sub-dissector table, given its internal name */
201WS_DLL_PUBLIC const char *get_dissector_table_ui_name(const char *name);
202
203/* Get the field type for values of the selector for a dissector table,
204 given the table's internal name */
205WS_DLL_PUBLIC ftenum_t get_dissector_table_selector_type(const char *name);
206
207/* Get the param set for the sub-dissector table,
208 given the table's internal name */
209WS_DLL_PUBLIC int get_dissector_table_param(const char *name);
210
211/* Dump all dissector tables to the standard output (not the entries,
212 just the information about the tables) */
213WS_DLL_PUBLIC void dissector_dump_dissector_tables(void);
214
215/* Add an entry to a uint dissector table. */
216WS_DLL_PUBLIC void dissector_add_uint(const char *name, const uint32_t pattern,
217 dissector_handle_t handle);
218
219/* Add an entry to a uint dissector table with "preference" automatically added. */
220WS_DLL_PUBLIC void dissector_add_uint_with_preference(const char *name, const uint32_t pattern,
221 dissector_handle_t handle);
222
224WS_DLL_PUBLIC void dissector_add_uint_range(const char *abbrev, range_t *range,
225 dissector_handle_t handle);
226
228WS_DLL_PUBLIC void dissector_add_uint_range_with_preference(const char *abbrev, const char* range_str,
229 dissector_handle_t handle);
230
233WS_DLL_PUBLIC void dissector_delete_uint(const char *name, const uint32_t pattern,
234 dissector_handle_t handle);
235
237WS_DLL_PUBLIC void dissector_delete_uint_range(const char *abbrev, range_t *range,
238 dissector_handle_t handle);
239
241WS_DLL_PUBLIC void dissector_delete_all(const char *name, dissector_handle_t handle);
242
245WS_DLL_PUBLIC void dissector_change_uint(const char *abbrev, const uint32_t pattern,
246 dissector_handle_t handle);
247
249WS_DLL_PUBLIC void dissector_reset_uint(const char *name, const uint32_t pattern);
250
256WS_DLL_PUBLIC bool dissector_is_uint_changed(dissector_table_t const sub_dissectors, const uint32_t uint_val);
257
261WS_DLL_PUBLIC int dissector_try_uint(dissector_table_t sub_dissectors,
262 const uint32_t uint_val, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
263
268WS_DLL_PUBLIC int dissector_try_uint_with_data(dissector_table_t sub_dissectors,
269 const uint32_t uint_val, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const bool add_proto_name, void *data);
270
271WS_DEPRECATED_X("Use dissector_try_uint_with_data instead")
272static inline int dissector_try_uint_new(dissector_table_t sub_dissectors,
273 const uint32_t uint_val, tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, const bool add_proto_name, void* data) \
274{ return dissector_try_uint_with_data(sub_dissectors, uint_val, tvb, pinfo, tree, add_proto_name, data); }
275
283WS_DLL_PUBLIC dissector_handle_t dissector_get_uint_handle(
284 dissector_table_t const sub_dissectors, const uint32_t uint_val);
285
293WS_DLL_PUBLIC dissector_handle_t dissector_get_default_uint_handle(
294 const char *name, const uint32_t uint_val);
295
296/* Add an entry to a string dissector table. */
297WS_DLL_PUBLIC void dissector_add_string(const char *name, const char *pattern,
298 dissector_handle_t handle);
299
300/* Delete the entry for a dissector in a string dissector table
301 with a particular pattern. */
302WS_DLL_PUBLIC void dissector_delete_string(const char *name, const char *pattern,
303 dissector_handle_t handle);
304
305/* Change the entry for a dissector in a string dissector table
306 with a particular pattern to use a new dissector handle. */
307WS_DLL_PUBLIC void dissector_change_string(const char *name, const char *pattern,
308 dissector_handle_t handle);
309
310/* Reset an entry in a string sub-dissector table to its initial value. */
311WS_DLL_PUBLIC void dissector_reset_string(const char *name, const char *pattern);
312
313/* Return true if an entry in a string dissector table is found and has been
314 * changed (i.e. dissector_change_string() has been called, such as from
315 * Decode As), otherwise return false.
316 */
317WS_DLL_PUBLIC bool dissector_is_string_changed(dissector_table_t const subdissectors, const char *string);
318
319
323WS_DLL_PUBLIC int dissector_try_string_with_data(dissector_table_t sub_dissectors,
324 const char* string, tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, const bool add_proto_name, void* data);
325
326/* Look for a given string in a given dissector table and, if found, call
327 the dissector with the arguments supplied, and return the number of
328 bytes consumed, otherwise return 0. */
329WS_DEPRECATED_X("Use dissector_try_string_with_data instead")
330static inline int
331dissector_try_string(dissector_table_t sub_dissectors, const char* string,\
332 tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data) \
333 { return dissector_try_string_with_data(sub_dissectors, string, tvb, pinfo, tree, true, data); }
334
335WS_DEPRECATED_X("Use dissector_try_string_with_data instead")
336static inline int
337dissector_try_string_new(dissector_table_t sub_dissectors, const char* string, \
338 tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, const bool add_proto_name, void* data) \
339{ return dissector_try_string_with_data(sub_dissectors, string, tvb, pinfo, tree, add_proto_name, data); }
340
341
349WS_DLL_PUBLIC dissector_handle_t dissector_get_string_handle(
350 dissector_table_t sub_dissectors, const char *string);
351
359WS_DLL_PUBLIC dissector_handle_t dissector_get_default_string_handle(
360 const char *name, const char *string);
361
362/* Add an entry to a "custom" dissector table. */
363WS_DLL_PUBLIC void dissector_add_custom_table_handle(const char *name, void *pattern,
364 dissector_handle_t handle);
365
373WS_DLL_PUBLIC dissector_handle_t dissector_get_custom_table_handle(
374 dissector_table_t sub_dissectors, void *key);
375/* Key for GUID dissector tables. This is based off of DCE/RPC needs
376 so some dissector tables may not need the ver portion of the hash
377 */
378 typedef struct _guid_key {
379 e_guid_t guid;
380 uint16_t ver;
381} guid_key;
382
383/* Add an entry to a guid dissector table. */
384WS_DLL_PUBLIC void dissector_add_guid(const char *name, guid_key* guid_val,
385 dissector_handle_t handle);
386
390WS_DLL_PUBLIC int dissector_try_guid_with_data(dissector_table_t sub_dissectors,
391 guid_key* guid_val, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const bool add_proto_name, void *data);
392
393/* Delete a GUID from a dissector table. */
394WS_DLL_PUBLIC void dissector_delete_guid(const char *name, guid_key* guid_val,
395 dissector_handle_t handle);
396
404WS_DLL_PUBLIC dissector_handle_t dissector_get_guid_handle(
405 dissector_table_t const sub_dissectors, guid_key* guid_val);
406
407/* Use the currently assigned payload dissector for the dissector table and,
408 if any, call the dissector with the arguments supplied, and return the
409 number of bytes consumed, otherwise return 0. */
410WS_DLL_PUBLIC int dissector_try_payload_with_data(dissector_table_t sub_dissectors,
411 tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const bool add_proto_name, void *data);
412
413WS_DEPRECATED_X("Use dissector_try_payload_with_data instead")
414static inline int dissector_try_payload_new(dissector_table_t sub_dissectors,
415 tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, const bool add_proto_name, void* data){ \
416 return dissector_try_payload_with_data(sub_dissectors, tvb, pinfo, tree, add_proto_name, data); \
417}
418
419/* Use the currently assigned payload dissector for the dissector table and,
420 if any, call the dissector with the arguments supplied, and return the
421 number of bytes consumed, otherwise return 0. */
422WS_DEPRECATED_X("Use dissector_try_payload_with_data instead")
423static inline int dissector_try_payload(dissector_table_t sub_dissectors,
424 tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) {
425 \
426 return dissector_try_payload_with_data(sub_dissectors, tvb, pinfo, tree, true, NULL); \
427}
428
429/* Change the entry for a dissector in a payload (FT_NONE) dissector table
430 with a particular pattern to use a new dissector handle. */
431WS_DLL_PUBLIC void dissector_change_payload(const char *abbrev, dissector_handle_t handle);
432
433/* Reset payload (FT_NONE) dissector table to its initial value. */
434WS_DLL_PUBLIC void dissector_reset_payload(const char *name);
435
436/* Given a payload dissector table (type FT_NONE), return the handle of
437 the dissector that is currently active, i.e. that was selected via
438 Decode As. */
439WS_DLL_PUBLIC dissector_handle_t dissector_get_payload_handle(
440 dissector_table_t const dissector_table);
441
442/* Add a handle to the list of handles that *could* be used with this
443 table. That list is used by the "Decode As"/"-d" code in the UI. */
444WS_DLL_PUBLIC void dissector_add_for_decode_as(const char *name,
445 dissector_handle_t handle);
446
447/* Same as dissector_add_for_decode_as, but adds preference for dissector table value */
448WS_DLL_PUBLIC void dissector_add_for_decode_as_with_preference(const char *name,
449 dissector_handle_t handle);
450
453WS_DLL_PUBLIC GSList *dissector_table_get_dissector_handles(dissector_table_t dissector_table);
454
458WS_DLL_PUBLIC dissector_handle_t dissector_table_get_dissector_handle(dissector_table_t dissector_table, const char* description);
459
462WS_DLL_PUBLIC ftenum_t dissector_table_get_type(dissector_table_t dissector_table);
463
469WS_DLL_PUBLIC void dissector_table_allow_decode_as(dissector_table_t dissector_table);
470
473WS_DLL_PUBLIC bool dissector_table_supports_decode_as(dissector_table_t dissector_table);
474
475/* List of "heuristic" dissectors (which get handed a packet, look at it,
476 and either recognize it as being for their protocol, dissect it, and
477 return true, or don't recognize it and return false) to be called
478 by another dissector.
479
480 This is opaque outside of "packet.c". */
481struct heur_dissector_list;
482typedef struct heur_dissector_list *heur_dissector_list_t;
483
484
485 typedef struct heur_dtbl_entry {
486 heur_dissector_t dissector;
487 protocol_t *protocol; /* this entry's protocol */
488 char *list_name; /* the list name this entry is in the list of */
489 const char *display_name; /* the string used to present heuristic to user */
490 char *short_name; /* string used for "internal" use to uniquely identify heuristic */
491 bool enabled;
492 bool enabled_by_default;
493} heur_dtbl_entry_t;
494
502WS_DLL_PUBLIC heur_dissector_list_t register_heur_dissector_list_with_description(const char *name, const char *ui_name, const int proto);
503
508WS_DLL_PUBLIC const char *heur_dissector_list_get_description(heur_dissector_list_t list);
509
516WS_DLL_PUBLIC heur_dissector_list_t register_heur_dissector_list(const char *name, const int proto);
517
519void deregister_heur_dissector_list(const char *name);
520
521typedef void (*DATFunc_heur) (const char *table_name,
522 struct heur_dtbl_entry *entry, void *user_data);
523typedef void (*DATFunc_heur_table) (const char *table_name,
524 struct heur_dissector_list *table, void *user_data);
525
535WS_DLL_PUBLIC void heur_dissector_table_foreach(const char *table_name,
536 DATFunc_heur func, void *user_data);
537
546WS_DLL_PUBLIC void dissector_all_heur_tables_foreach_table (DATFunc_heur_table func,
547 void *user_data, GCompareFunc compare_key_func);
548
549/* true if a heur_dissector list of that name exists to be registered into */
550WS_DLL_PUBLIC bool has_heur_dissector_list(const char *name);
551
564WS_DLL_PUBLIC bool dissector_try_heuristic(heur_dissector_list_t sub_dissectors,
565 tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, heur_dtbl_entry_t **hdtbl_entry, void *data);
566
572WS_DLL_PUBLIC heur_dissector_list_t find_heur_dissector_list(const char *name);
573
579WS_DLL_PUBLIC heur_dtbl_entry_t* find_heur_dissector_by_unique_short_name(const char *short_name);
580
591WS_DLL_PUBLIC void heur_dissector_add(const char *name, heur_dissector_t dissector,
592 const char *display_name, const char *internal_name, const int proto, heuristic_enable_e enable);
593
601WS_DLL_PUBLIC void heur_dissector_delete(const char *name, heur_dissector_t dissector, const int proto);
602
604WS_DLL_PUBLIC dissector_handle_t register_dissector(const char *name, dissector_t dissector, const int proto);
605
607WS_DLL_PUBLIC dissector_handle_t register_dissector_with_description(const char *name, const char *description, dissector_t dissector, const int proto);
608
610WS_DLL_PUBLIC dissector_handle_t register_dissector_with_data(const char *name, dissector_cb_t dissector, const int proto, void *cb_data);
611
613void deregister_dissector(const char *name);
614
616WS_DLL_PUBLIC const char *dissector_handle_get_protocol_long_name(const dissector_handle_t handle);
617
619WS_DLL_PUBLIC const char *dissector_handle_get_protocol_short_name(const dissector_handle_t handle);
620
621/* For backwards source and binary compatibility */
622G_DEPRECATED_FOR(dissector_handle_get_protocol_short_name)
623WS_DLL_PUBLIC const char *dissector_handle_get_short_name(const dissector_handle_t handle);
624
626WS_DLL_PUBLIC const char *dissector_handle_get_description(const dissector_handle_t handle);
627
629WS_DLL_PUBLIC int dissector_handle_get_protocol_index(const dissector_handle_t handle);
630
632WS_DLL_PUBLIC GList* get_dissector_names(void);
633
635WS_DLL_PUBLIC dissector_handle_t find_dissector(const char *name);
636
638WS_DLL_PUBLIC dissector_handle_t find_dissector_add_dependency(const char *name, const int parent_proto);
639
641WS_DLL_PUBLIC const char *dissector_handle_get_dissector_name(const dissector_handle_t handle);
642
643WS_DLL_PUBLIC const char *dissector_handle_get_pref_suffix(const dissector_handle_t handle);
644
655WS_DLL_PUBLIC dissector_handle_t create_dissector_handle(dissector_t dissector,
656 const int proto);
657
669WS_DLL_PUBLIC dissector_handle_t create_dissector_handle_with_name(dissector_t dissector,
670 const int proto, const char* name);
671
686WS_DLL_PUBLIC dissector_handle_t create_dissector_handle_with_name_and_description(dissector_t dissector,
687 const int proto, const char* name, const char* description);
688WS_DLL_PUBLIC dissector_handle_t create_dissector_handle_with_data(dissector_cb_t dissector,
689 const int proto, void* cb_data);
690
691/* Dump all registered dissectors to the standard output */
692WS_DLL_PUBLIC void dissector_dump_dissectors(void);
693
707WS_DLL_PUBLIC int call_dissector_with_data(dissector_handle_t handle, tvbuff_t *tvb,
708 packet_info *pinfo, proto_tree *tree, void *data);
709WS_DLL_PUBLIC int call_dissector(dissector_handle_t handle, tvbuff_t *tvb,
710 packet_info *pinfo, proto_tree *tree);
711
712WS_DLL_PUBLIC int call_data_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
713
727WS_DLL_PUBLIC int call_dissector_only(dissector_handle_t handle, tvbuff_t *tvb,
728 packet_info *pinfo, proto_tree *tree, void *data);
729
738WS_DLL_PUBLIC void call_heur_dissector_direct(heur_dtbl_entry_t *heur_dtbl_entry, tvbuff_t *tvb,
739 packet_info *pinfo, proto_tree *tree, void *data);
740
741/* This is opaque outside of "packet.c". */
742struct depend_dissector_list;
743typedef struct depend_dissector_list *depend_dissector_list_t;
744
755WS_DLL_PUBLIC bool register_depend_dissector(const char* parent, const char* dependent);
756
766WS_DLL_PUBLIC bool deregister_depend_dissector(const char* parent, const char* dependent);
767
773WS_DLL_PUBLIC depend_dissector_list_t find_depend_dissector_list(const char* name);
774
775/*
776 * Given a tvbuff, and a length from a packet header, adjust the length
777 * of the tvbuff to reflect the specified length.
778 */
779WS_DLL_PUBLIC void set_actual_length(tvbuff_t *tvb, const unsigned specified_len);
780
788WS_DLL_PUBLIC void register_init_routine(void (*func)(void));
789
797WS_DLL_PUBLIC void register_cleanup_routine(void (*func)(void));
798
799/*
800 * Allows protocols to register "shutdown" routines, which are called
801 * once, just before program exit
802 */
803WS_DLL_PUBLIC void register_shutdown_routine(void (*func)(void));
804
805/* Initialize all data structures used for dissection. */
806void init_dissection(const char* app_env_var_prefix);
807
808/* Free data structures allocated for dissection. */
809void cleanup_dissection(void);
810
811/* Allow protocols to register a "cleanup" routine to be
812 * run after the initial sequential run through the packets.
813 * Note that the file can still be open after this; this is not
814 * the final cleanup. */
815WS_DLL_PUBLIC void register_postseq_cleanup_routine(void (*func)(void));
816
817/* Call all the registered "postseq_cleanup" routines. */
818WS_DLL_PUBLIC void postseq_cleanup_all_protocols(void);
819
820/* Allow dissectors to register a "final_registration" routine
821 * that is run like the proto_register_XXX() routine, but the end
822 * end of the epan_init() function; that is, *after* all other
823 * subsystems (such as dfilters) have finished initializing. This is
824 * useful for dissector registration routines which need to compile
825 * display filters. dfilters can't initialize itself until all protocols
826 * have registered themselves. */
827WS_DLL_PUBLIC void
828register_final_registration_routine(void (*func)(void));
829
830/* Call all the registered "final_registration" routines. */
831extern void
832final_registration_all_protocols(void);
833
834// XXX Should we move frame_data.encoding here?
835typedef enum {
836 DS_MEDIA_TYPE_APPLICATION_OCTET_STREAM,
837 DS_MEDIA_TYPE_APPLICATION_JSON,
838} data_source_media_type_e;
839
840struct data_source;
841
851WS_DLL_PUBLIC struct data_source* add_new_data_source(packet_info *pinfo, tvbuff_t *tvb,
852 const char *name);
853
860WS_DLL_PUBLIC void set_data_source_name(packet_info *pinfo, struct data_source *src, const char *name);
861
868WS_DLL_PUBLIC void set_data_source_media_type(struct data_source *src, data_source_media_type_e media_type);
869
870/* Removes the last-added data source, if it turns out it wasn't needed */
871WS_DLL_PUBLIC void remove_last_data_source(packet_info *pinfo);
872
873/*
874 * Return the data source name.
875 */
876WS_DLL_PUBLIC const char *get_data_source_name(const struct data_source *src);
877
878/*
879 * Return the data source description.
880 */
881WS_DLL_PUBLIC char *get_data_source_description(const struct data_source *src);
882
883/*
884 * Return the tvb for the data source.
885 */
886WS_DLL_PUBLIC tvbuff_t *get_data_source_tvb(const struct data_source *src);
887
894WS_DLL_PUBLIC struct data_source *get_data_source_by_name(const packet_info *pinfo, const char *name);
895
902WS_DLL_PUBLIC struct data_source *get_data_source_by_tvb(const packet_info *pinfo, const tvbuff_t *tvb);
903
909WS_DLL_PUBLIC data_source_media_type_e get_data_source_media_type(const struct data_source *src);
910
911/*
912 * Free up a frame's list of data sources.
913 */
914extern void free_data_sources(packet_info *pinfo);
915
916/* Mark another frame as depended upon by the current frame.
917 *
918 * This information is used to ensure that when the current frame is exported
919 * or saved that the depended upon frames necessary for correct dissection are
920 * also exported (along with the frames that those depend upon, in infinite
921 * descent.) The fragment handling functions in reassemble.c mark any frame
922 * used to reassemble the current frame as depended upon; dissectors can also
923 * mark frames themselves.
924 *
925 * In Wireshark, the "Include depended upon packets" checkbox in the Export
926 * Specified Packets dialog (enabled by default) controls whether depended
927 * upon frames of selected frames are also exported. TShark also saves
928 * any depended upon frames when saving filtered packets to a file.
929 */
930WS_DLL_PUBLIC void mark_frame_as_depended_upon(frame_data *fd, uint32_t frame_num);
931
932/* Structure passed to the frame dissector */
933 typedef struct frame_data_s
934{
935 int file_type_subtype;
936 /*
937 * This might be the block from the packet's wtap_rec or it might
938 * be a modified copy of that, as, for example, the comments
939 * might have been edited but not yet saved to the file.
940 */
941 wtap_block_t pkt_block;
942 struct epan_dissect *color_edt;
944} frame_data_t;
945
946/* Structure passed to the file dissector */
947 typedef struct file_data_s
948{
949 wtap_block_t pkt_block;
950 struct epan_dissect *color_edt;
952} file_data_t;
953
954/*
955 * Dissectors should never modify the record data.
956 */
957extern void dissect_record(struct epan_dissect *edt, int file_type_subtype,
958 wtap_rec *rec, frame_data *fd, column_info *cinfo);
959
960/*
961 * Dissectors should never modify the file data.
962 */
963extern void dissect_file(struct epan_dissect *edt,
964 wtap_rec *rec, frame_data *fd, column_info *cinfo);
965
966/* Structure passed to the ethertype dissector */
967 typedef struct ethertype_data_s
968{
969 uint16_t etype;
970 int payload_offset;
971 proto_tree *fh_tree;
972 int trailer_id;
973 int fcs_len;
974} ethertype_data_t;
975
976/*
977 * Dump layer/selector/dissector records in a fashion similar to the
978 * proto_registrar_dump_* routines.
979 */
980WS_DLL_PUBLIC void dissector_dump_decodes(void);
981
982/*
983 * For each heuristic dissector table, dump list of dissectors (filter_names) for that table
984 */
985WS_DLL_PUBLIC void dissector_dump_heur_decodes(void);
986
987/*
988 * postdissectors are to be called by packet-frame.c after every other
989 * dissector has been called.
990 */
991
992/*
993 * Register a postdissector; the argument is the dissector handle for it.
994 */
995WS_DLL_PUBLIC void register_postdissector(dissector_handle_t handle);
996
997/*
998 * Specify a set of hfids that the postdissector will need on the first pass.
999 * This ensures that the fields will not be faked, and can be retrieved with
1000 * proto_get_finfo_ptr_array.
1001 *
1002 * @note There is no way to guarantee that fields added by other postdissectors
1003 * will be available. (Issue #19804) This is for postdissectors that examine
1004 * fields added by other dissectors on the first linear pass, and then store
1005 * their own results in persistent memory for retrieval and adding in later
1006 * passes. Postdissectors that need field values on later passes should call
1007 * something else, like epan_set_always_visible() (which slows dissection.)
1008 *
1009 * @param handle The dissector handle used to register the postdissector.
1010 * @param wanted_hfids An array of hfids (type int), which should be NULL to
1011 * clear the list. This function will take ownership of the array.
1012 */
1013WS_DLL_PUBLIC void set_postdissector_wanted_hfids(dissector_handle_t handle,
1014 GArray *wanted_hfids);
1015
1016/*
1017 * Deregister a postdissector. Not for use in (post)dissectors or
1018 * applications; only to be used by libwireshark itself.
1019 */
1020void deregister_postdissector(dissector_handle_t handle);
1021
1022/*
1023 * Return true if we have at least one postdissector, false if not.
1024 * Not for use in (post)dissectors or applications; only to be used
1025 * by libwireshark itself.
1026 */
1027extern bool have_postdissector(void);
1028
1029/*
1030 * Call all postdissectors, handing them the supplied arguments.
1031 * Not for use in (post)dissectors or applications; only to be used
1032 * by libwireshark itself.
1033 */
1034extern void call_all_postdissectors(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
1035
1036/*
1037 * Return true if at least one postdissector needs at least one hfid,
1038 * false otherwise.
1039 */
1040WS_DLL_PUBLIC bool postdissectors_want_hfids(void);
1041
1042/*
1043 * Prime an epan_dissect_t with all the hfids wanted by postdissectors
1044 * on the first pass. Not for use in (post)dissectors or applications;
1045 * only to be used by libwireshark itself, which will call this automatically
1046 * when dissecting a frame that has not been visited yet.
1047 */
1048extern void
1049prime_epan_dissect_with_postdissector_wanted_hfids(epan_dissect_t *edt);
1050
1057WS_DLL_PUBLIC void increment_dissection_depth(packet_info *pinfo);
1058
1063WS_DLL_PUBLIC void decrement_dissection_depth(packet_info *pinfo);
1064
1067#ifdef __cplusplus
1068}
1069#endif /* __cplusplus */
1070
1071#endif /* packet.h */
array.h
column-utils.h
epan.h
frame_data.h
dissector_table_foreach
WS_DLL_PUBLIC void dissector_table_foreach(const char *table_name, DATFunc func, void *user_data)
Definition packet.c:2608
call_dissector_only
WS_DLL_PUBLIC int call_dissector_only(dissector_handle_t handle, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
Definition packet.c:3679
dissector_handle_get_protocol_long_name
WS_DLL_PUBLIC const char * dissector_handle_get_protocol_long_name(const dissector_handle_t handle)
Definition packet.c:3371
deregister_dissector
void deregister_dissector(const char *name)
Definition packet.c:3663
dissector_get_default_string_handle
WS_DLL_PUBLIC dissector_handle_t dissector_get_default_string_handle(const char *name, const char *string)
Definition packet.c:2111
find_heur_dissector_by_unique_short_name
WS_DLL_PUBLIC heur_dtbl_entry_t * find_heur_dissector_by_unique_short_name(const char *short_name)
Definition packet.c:2948
dissector_table_foreach_changed
void dissector_table_foreach_changed(const char *table_name, DATFunc func, void *user_data)
Definition packet.c:2685
dissector_get_default_uint_handle
WS_DLL_PUBLIC dissector_handle_t dissector_get_default_uint_handle(const char *name, const uint32_t uint_val)
Definition packet.c:1805
find_dissector_add_dependency
WS_DLL_PUBLIC dissector_handle_t find_dissector_add_dependency(const char *name, const int parent_proto)
Definition packet.c:3446
register_dissector
WS_DLL_PUBLIC dissector_handle_t register_dissector(const char *name, dissector_t dissector, const int proto)
Definition packet.c:3617
deregister_dissector_table
void deregister_dissector_table(const char *name)
Definition packet.c:2882
dissector_get_guid_handle
WS_DLL_PUBLIC dissector_handle_t dissector_get_guid_handle(dissector_table_t const sub_dissectors, guid_key *guid_val)
Definition packet.c:2250
register_dissector_with_data
WS_DLL_PUBLIC dissector_handle_t register_dissector_with_data(const char *name, dissector_cb_t dissector, const int proto, void *cb_data)
Definition packet.c:3637
dissector_change_uint
WS_DLL_PUBLIC void dissector_change_uint(const char *abbrev, const uint32_t pattern, dissector_handle_t handle)
Definition packet.c:1633
find_heur_dissector_list
WS_DLL_PUBLIC heur_dissector_list_t find_heur_dissector_list(const char *name)
Definition packet.c:2938
dissector_table_get_type
WS_DLL_PUBLIC ftenum_t dissector_table_get_type(dissector_table_t dissector_table)
Definition packet.c:2485
dissector_try_uint
WS_DLL_PUBLIC int dissector_try_uint(dissector_table_t sub_dissectors, const uint32_t uint_val, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
Definition packet.c:1783
dissector_handle_get_dissector_name
WS_DLL_PUBLIC const char * dissector_handle_get_dissector_name(const dissector_handle_t handle)
Definition packet.c:3459
deregister_heur_dissector_list
void deregister_heur_dissector_list(const char *name)
Definition packet.c:3345
dissector_get_custom_table_handle
WS_DLL_PUBLIC dissector_handle_t dissector_get_custom_table_handle(dissector_table_t sub_dissectors, void *key)
Definition packet.c:2154
get_dissector_names
WS_DLL_PUBLIC GList * get_dissector_names(void)
Definition packet.c:3429
dissector_handle_get_description
WS_DLL_PUBLIC const char * dissector_handle_get_description(const dissector_handle_t handle)
Definition packet.c:3400
dissector_delete_uint
WS_DLL_PUBLIC void dissector_delete_uint(const char *name, const uint32_t pattern, dissector_handle_t handle)
Definition packet.c:1516
dissector_table_supports_decode_as
WS_DLL_PUBLIC bool dissector_table_supports_decode_as(dissector_table_t dissector_table)
Definition packet.c:2500
decrement_dissection_depth
WS_DLL_PUBLIC void decrement_dissection_depth(packet_info *pinfo)
Definition packet.c:4287
register_init_routine
WS_DLL_PUBLIC void register_init_routine(void(*func)(void))
Definition packet.c:354
dissector_get_uint_handle
WS_DLL_PUBLIC dissector_handle_t dissector_get_uint_handle(dissector_table_t const sub_dissectors, const uint32_t uint_val)
Definition packet.c:1793
heur_dissector_delete
WS_DLL_PUBLIC void heur_dissector_delete(const char *name, heur_dissector_t dissector, const int proto)
Definition packet.c:3040
set_data_source_name
WS_DLL_PUBLIC void set_data_source_name(packet_info *pinfo, struct data_source *src, const char *name)
Definition packet.c:454
register_depend_dissector
WS_DLL_PUBLIC bool register_depend_dissector(const char *parent, const char *dependent)
Definition packet.c:3799
register_cleanup_routine
WS_DLL_PUBLIC void register_cleanup_routine(void(*func)(void))
Definition packet.c:360
create_dissector_handle
WS_DLL_PUBLIC dissector_handle_t create_dissector_handle(dissector_t dissector, const int proto)
Definition packet.c:3557
dissector_try_string_with_data
WS_DLL_PUBLIC int dissector_try_string_with_data(dissector_table_t sub_dissectors, const char *string, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const bool add_proto_name, void *data)
Definition packet.c:2040
dissector_handle_get_protocol_short_name
WS_DLL_PUBLIC const char * dissector_handle_get_protocol_short_name(const dissector_handle_t handle)
Definition packet.c:3382
dissector_delete_uint_range
WS_DLL_PUBLIC void dissector_delete_uint_range(const char *abbrev, range_t *range, dissector_handle_t handle)
Definition packet.c:1539
heur_dissector_table_foreach
WS_DLL_PUBLIC void heur_dissector_table_foreach(const char *table_name, DATFunc_heur func, void *user_data)
Definition packet.c:3210
dissector_add_uint_range
WS_DLL_PUBLIC void dissector_add_uint_range(const char *abbrev, range_t *range, dissector_handle_t handle)
Definition packet.c:1359
dissector_table_allow_decode_as
WS_DLL_PUBLIC void dissector_table_allow_decode_as(dissector_table_t dissector_table)
Definition packet.c:2491
get_data_source_by_name
WS_DLL_PUBLIC struct data_source * get_data_source_by_name(const packet_info *pinfo, const char *name)
Definition packet.c:508
find_dissector
WS_DLL_PUBLIC dissector_handle_t find_dissector(const char *name)
Definition packet.c:3440
increment_dissection_depth
WS_DLL_PUBLIC void increment_dissection_depth(packet_info *pinfo)
Definition packet.c:4281
dissector_all_tables_foreach_table
WS_DLL_PUBLIC void dissector_all_tables_foreach_table(DATFunc_table func, void *user_data, GCompareFunc compare_key_func)
Definition packet.c:2740
dissector_all_heur_tables_foreach_table
WS_DLL_PUBLIC void dissector_all_heur_tables_foreach_table(DATFunc_heur_table func, void *user_data, GCompareFunc compare_key_func)
Definition packet.c:3266
dissector_table_get_dissector_handles
WS_DLL_PUBLIC GSList * dissector_table_get_dissector_handles(dissector_table_t dissector_table)
Definition packet.c:2438
dissector_all_tables_foreach_changed
WS_DLL_PUBLIC void dissector_all_tables_foreach_changed(DATFunc func, void *user_data)
Definition packet.c:2669
create_dissector_handle_with_name_and_description
WS_DLL_PUBLIC dissector_handle_t create_dissector_handle_with_name_and_description(dissector_t dissector, const int proto, const char *name, const char *description)
Definition packet.c:3534
dissector_handle_get_protocol_index
WS_DLL_PUBLIC int dissector_handle_get_protocol_index(const dissector_handle_t handle)
Definition packet.c:3411
dissector_is_uint_changed
WS_DLL_PUBLIC bool dissector_is_uint_changed(dissector_table_t const sub_dissectors, const uint32_t uint_val)
Definition packet.c:1711
set_data_source_media_type
WS_DLL_PUBLIC void set_data_source_media_type(struct data_source *src, data_source_media_type_e media_type)
Definition packet.c:461
find_depend_dissector_list
WS_DLL_PUBLIC depend_dissector_list_t find_depend_dissector_list(const char *name)
Definition packet.c:3832
heur_dissector_list_get_description
WS_DLL_PUBLIC const char * heur_dissector_list_get_description(heur_dissector_list_t list)
Definition packet.c:3356
register_dissector_table_alias
WS_DLL_PUBLIC void register_dissector_table_alias(dissector_table_t dissector_table, const char *alias_name)
Definition packet.c:2864
deregister_depend_dissector
WS_DLL_PUBLIC bool deregister_depend_dissector(const char *parent, const char *dependent)
Definition packet.c:3822
add_new_data_source
WS_DLL_PUBLIC struct data_source * add_new_data_source(packet_info *pinfo, tvbuff_t *tvb, const char *name)
Definition packet.c:439
call_dissector_with_data
WS_DLL_PUBLIC int call_dissector_with_data(dissector_handle_t handle, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
Definition packet.c:3693
call_heur_dissector_direct
WS_DLL_PUBLIC void call_heur_dissector_direct(heur_dtbl_entry_t *heur_dtbl_entry, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
Definition packet.c:3726
heur_dissector_add
WS_DLL_PUBLIC void heur_dissector_add(const char *name, heur_dissector_t dissector, const char *display_name, const char *internal_name, const int proto, heuristic_enable_e enable)
Definition packet.c:2954
register_dissector_with_description
WS_DLL_PUBLIC dissector_handle_t register_dissector_with_description(const char *name, const char *description, dissector_t dissector, const int proto)
Definition packet.c:3627
create_dissector_handle_with_name
WS_DLL_PUBLIC dissector_handle_t create_dissector_handle_with_name(dissector_t dissector, const int proto, const char *name)
Definition packet.c:3549
get_data_source_by_tvb
WS_DLL_PUBLIC struct data_source * get_data_source_by_tvb(const packet_info *pinfo, const tvbuff_t *tvb)
Definition packet.c:526
heur_dissector_t
bool(* heur_dissector_t)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *)
Definition packet.h:90
dissector_table_get_dissector_handle
WS_DLL_PUBLIC dissector_handle_t dissector_table_get_dissector_handle(dissector_table_t dissector_table, const char *description)
Definition packet.c:2468
register_heur_dissector_list
WS_DLL_PUBLIC heur_dissector_list_t register_heur_dissector_list(const char *name, const int proto)
Definition packet.c:3339
dissector_try_uint_with_data
WS_DLL_PUBLIC int dissector_try_uint_with_data(dissector_table_t sub_dissectors, const uint32_t uint_val, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const bool add_proto_name, void *data)
Definition packet.c:1726
dissector_table_foreach_handle
WS_DLL_PUBLIC void dissector_table_foreach_handle(const char *table_name, DATFunc_handle func, void *user_data)
Definition packet.c:2627
dissector_try_heuristic
WS_DLL_PUBLIC bool dissector_try_heuristic(heur_dissector_list_t sub_dissectors, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, heur_dtbl_entry_t **hdtbl_entry, void *data)
Definition packet.c:3066
dissector_reset_uint
WS_DLL_PUBLIC void dissector_reset_uint(const char *name, const uint32_t pattern)
Definition packet.c:1678
dissector_try_guid_with_data
WS_DLL_PUBLIC int dissector_try_guid_with_data(dissector_table_t sub_dissectors, guid_key *guid_val, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const bool add_proto_name, void *data)
Definition packet.c:2196
dissector_delete_all
WS_DLL_PUBLIC void dissector_delete_all(const char *name, dissector_handle_t handle)
Definition packet.c:1601
dissector_add_uint_range_with_preference
WS_DLL_PUBLIC void dissector_add_uint_range_with_preference(const char *abbrev, const char *range_str, dissector_handle_t handle)
Definition packet.c:1498
dissector_get_string_handle
WS_DLL_PUBLIC dissector_handle_t dissector_get_string_handle(dissector_table_t sub_dissectors, const char *string)
Definition packet.c:2096
get_data_source_media_type
WS_DLL_PUBLIC data_source_media_type_e get_data_source_media_type(const struct data_source *src)
Definition packet.c:541
register_heur_dissector_list_with_description
WS_DLL_PUBLIC heur_dissector_list_t register_heur_dissector_list_with_description(const char *name, const char *ui_name, const int proto)
Definition packet.c:3320
guid-utils.h
packet_info.h
proto.h
range.h
_e_guid_t
Definition guid-utils.h:23
_guid_key
Definition packet.h:378
_packet_info
Definition packet_info.h:43
_proto_node
Definition proto.h:907
_protocol
Definition proto.c:381
data_source
Definition packet.c:56
depend_dissector_list
Definition packet.c:131
dissector_handle
Definition packet.c:857
dissector_table
Definition packet.c:97
dtbl_entry
Definition packet.c:1202
epan_column_info
Definition column-info.h:62
epan_dissect
Definition epan_dissect.h:28
epan_range
Definition range.h:41
ethertype_data_s
Definition packet.h:968
file_data_s
Definition packet.h:948
file_data_s::pkt_block
wtap_block_t pkt_block
Definition packet.h:949
frame_data_s
Definition packet.h:934
frame_data_s::pkt_block
wtap_block_t pkt_block
Definition packet.h:941
heur_dissector_list
Definition packet.c:188
heur_dtbl_entry
Definition packet.h:485
tvbuff
Definition tvbuff-int.h:35
wtap_block
Definition wtap_opttypes.h:272
wtap_rec
Definition wtap.h:1512
tvbuff.h
wtap_opttypes.h