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