Wireshark  4.3.0
The Wireshark network protocol analyzer
packet.h
Go to the documentation of this file.
1 
11 #ifndef __PACKET_H__
12 #define __PACKET_H__
13 #include <wireshark.h>
14 
15 #include <wiretap/wtap_opttypes.h>
16 #include "proto.h"
17 #include "tvbuff.h"
18 #include "epan.h"
19 #include "value_string.h"
20 #include "frame_data.h"
21 #include "packet_info.h"
22 #include "column-utils.h"
23 #include "guid-utils.h"
24 #include "tfs.h"
25 #include "unit_strings.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
30 
31 struct epan_range;
32 
38 #define hi_nibble(b) (((b) & 0xf0) >> 4)
39 #define lo_nibble(b) ((b) & 0x0f)
40 
41 /* Useful when you have an array whose size you can tell at compile-time */
42 #define array_length(x) (sizeof x / sizeof x[0])
43 
44 /* Check whether the "len" bytes of data starting at "offset" is
45  * entirely inside the captured data for this packet. */
46 #define BYTES_ARE_IN_FRAME(offset, captured_len, len) \
47  ((guint)(offset) + (guint)(len) > (guint)(offset) && \
48  (guint)(offset) + (guint)(len) <= (guint)(captured_len))
49 
50 /* 0 is case insenstive for backwards compatibility with tables that
51  * used FALSE or BASE_NONE for case sensitive, which was the default.
52  */
53 #define STRING_CASE_SENSITIVE 0
54 #define STRING_CASE_INSENSITIVE 1
55 
56 extern void packet_init(void);
57 extern void packet_cache_proto_handles(void);
58 extern void packet_cleanup(void);
59 
60 /* Handle for dissectors you call directly or register with "dissector_add_uint()".
61  This handle is opaque outside of "packet.c". */
62 struct dissector_handle;
63 typedef struct dissector_handle *dissector_handle_t;
64 
65 /* Hash table for matching unsigned integers, or strings, and dissectors;
66  this is opaque outside of "packet.c". */
67 struct dissector_table;
68 typedef struct dissector_table *dissector_table_t;
69 
70 /*
71  * Dissector that returns:
72  *
73  * The amount of data in the protocol's PDU, if it was able to
74  * dissect all the data;
75  *
76  * 0, if the tvbuff doesn't contain a PDU for that protocol;
77  *
78  * The negative of the amount of additional data needed, if
79  * we need more data (e.g., from subsequent TCP segments) to
80  * dissect the entire PDU.
81  */
82 typedef int (*dissector_t)(tvbuff_t *, packet_info *, proto_tree *, void *);
83 
84 /* Same as dissector_t with an extra parameter for callback pointer */
85 typedef int (*dissector_cb_t)(tvbuff_t *, packet_info *, proto_tree *, void *, void *);
86 
94 typedef gboolean (*heur_dissector_t)(tvbuff_t *tvb, packet_info *pinfo,
95  proto_tree *tree, void *);
96 
97 typedef enum {
98  HEURISTIC_DISABLE,
99  HEURISTIC_ENABLE
100 } heuristic_enable_e;
101 
102 typedef void (*DATFunc) (const gchar *table_name, ftenum_t selector_type,
103  gpointer key, gpointer value, gpointer user_data);
104 typedef void (*DATFunc_handle) (const gchar *table_name, gpointer value,
105  gpointer user_data);
106 typedef void (*DATFunc_table) (const gchar *table_name, const gchar *ui_name,
107  gpointer user_data);
108 
109 /* Opaque structure - provides type checking but no access to components */
110 typedef struct dtbl_entry dtbl_entry_t;
111 
112 WS_DLL_PUBLIC dissector_handle_t dtbl_entry_get_handle (dtbl_entry_t *dtbl_entry);
113 WS_DLL_PUBLIC dissector_handle_t dtbl_entry_get_initial_handle (dtbl_entry_t * entry);
114 
124 void dissector_table_foreach_changed (const char *table_name, DATFunc func,
125  gpointer user_data);
126 
136 WS_DLL_PUBLIC void dissector_table_foreach (const char *table_name, DATFunc func,
137  gpointer user_data);
138 
147 WS_DLL_PUBLIC void dissector_all_tables_foreach_changed (DATFunc func,
148  gpointer user_data);
149 
159 WS_DLL_PUBLIC void dissector_table_foreach_handle(const char *table_name, DATFunc_handle func,
160  gpointer user_data);
161 
170 WS_DLL_PUBLIC void dissector_all_tables_foreach_table (DATFunc_table func,
171  gpointer user_data, GCompareFunc compare_key_func);
172 
173 /* a protocol uses the function to register a sub-dissector table
174  *
175  * 'param' is the display base for integer tables, STRING_CASE_SENSITIVE
176  * or STRING_CASE_INSENSITIVE for string tables, and ignored for other
177  * table types.
178  */
179 WS_DLL_PUBLIC dissector_table_t register_dissector_table(const char *name,
180  const char *ui_name, const int proto, const ftenum_t type, const int param);
181 
182 /*
183  * Similar to register_dissector_table, but with a "custom" hash function
184  * to store subdissectors.
185  */
186 WS_DLL_PUBLIC dissector_table_t register_custom_dissector_table(const char *name,
187  const char *ui_name, const int proto, GHashFunc hash_func, GEqualFunc key_equal_func,
188  GDestroyNotify key_destroy_func);
189 
196  const char *alias_name);
197 
199 void deregister_dissector_table(const char *name);
200 
201 /* Find a dissector table by table name. */
202 WS_DLL_PUBLIC dissector_table_t find_dissector_table(const char *name);
203 
204 /* Get the UI name for a sub-dissector table, given its internal name */
205 WS_DLL_PUBLIC const char *get_dissector_table_ui_name(const char *name);
206 
207 /* Get the field type for values of the selector for a dissector table,
208  given the table's internal name */
209 WS_DLL_PUBLIC ftenum_t get_dissector_table_selector_type(const char *name);
210 
211 /* Get the param set for the sub-dissector table,
212  given the table's internal name */
213 WS_DLL_PUBLIC int get_dissector_table_param(const char *name);
214 
215 /* Dump all dissector tables to the standard output (not the entries,
216  just the information about the tables) */
217 WS_DLL_PUBLIC void dissector_dump_dissector_tables(void);
218 
219 /* Add an entry to a uint dissector table. */
220 WS_DLL_PUBLIC void dissector_add_uint(const char *name, const guint32 pattern,
221  dissector_handle_t handle);
222 
223 /* Add an entry to a uint dissector table with "preference" automatically added. */
224 WS_DLL_PUBLIC void dissector_add_uint_with_preference(const char *name, const guint32 pattern,
225  dissector_handle_t handle);
226 
227 /* Add an range of entries to a uint dissector table. */
228 WS_DLL_PUBLIC void dissector_add_uint_range(const char *abbrev, struct epan_range *range,
229  dissector_handle_t handle);
230 
231 /* Add an range of entries to a uint dissector table with "preference" automatically added. */
232 WS_DLL_PUBLIC void dissector_add_uint_range_with_preference(const char *abbrev, const char* range_str,
233  dissector_handle_t handle);
234 
235 /* Delete the entry for a dissector in a uint dissector table
236  with a particular pattern. */
237 WS_DLL_PUBLIC void dissector_delete_uint(const char *name, const guint32 pattern,
238  dissector_handle_t handle);
239 
240 /* Delete an range of entries from a uint dissector table. */
241 WS_DLL_PUBLIC void dissector_delete_uint_range(const char *abbrev, struct epan_range *range,
242  dissector_handle_t handle);
243 
244 /* Delete all entries from a dissector table. */
245 WS_DLL_PUBLIC void dissector_delete_all(const char *name, dissector_handle_t handle);
246 
247 /* Change the entry for a dissector in a uint dissector table
248  with a particular pattern to use a new dissector handle. */
249 WS_DLL_PUBLIC void dissector_change_uint(const char *abbrev, const guint32 pattern,
250  dissector_handle_t handle);
251 
252 /* Reset an entry in a uint dissector table to its initial value. */
253 WS_DLL_PUBLIC void dissector_reset_uint(const char *name, const guint32 pattern);
254 
255 /* Return TRUE if an entry in a uint dissector table is found and has been
256  * changed (i.e. dissector_change_uint() has been called, such as from
257  * Decode As, prefs registered via dissector_add_uint_[range_]with_preference),
258  * etc.), otherwise return FALSE.
259  */
260 WS_DLL_PUBLIC gboolean dissector_is_uint_changed(dissector_table_t const sub_dissectors, const guint32 uint_val);
261 
262 /* Look for a given value in a given uint dissector table and, if found,
263  call the dissector with the arguments supplied, and return the number
264  of bytes consumed, otherwise return 0. */
265 WS_DLL_PUBLIC int dissector_try_uint(dissector_table_t sub_dissectors,
266  const guint32 uint_val, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
267 
268 /* Look for a given value in a given uint dissector table and, if found,
269  call the dissector with the arguments supplied, and return the number
270  of bytes consumed, otherwise return 0. */
271 WS_DLL_PUBLIC int dissector_try_uint_new(dissector_table_t sub_dissectors,
272  const guint32 uint_val, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const gboolean add_proto_name, void *data);
273 
282  dissector_table_t const sub_dissectors, const guint32 uint_val);
283 
292  const char *name, const guint32 uint_val);
293 
294 /* Add an entry to a string dissector table. */
295 WS_DLL_PUBLIC void dissector_add_string(const char *name, const gchar *pattern,
296  dissector_handle_t handle);
297 
298 /* Delete the entry for a dissector in a string dissector table
299  with a particular pattern. */
300 WS_DLL_PUBLIC void dissector_delete_string(const char *name, const gchar *pattern,
301  dissector_handle_t handle);
302 
303 /* Change the entry for a dissector in a string dissector table
304  with a particular pattern to use a new dissector handle. */
305 WS_DLL_PUBLIC void dissector_change_string(const char *name, const gchar *pattern,
306  dissector_handle_t handle);
307 
308 /* Reset an entry in a string sub-dissector table to its initial value. */
309 WS_DLL_PUBLIC void dissector_reset_string(const char *name, const gchar *pattern);
310 
311 /* Return TRUE if an entry in a string dissector table is found and has been
312  * changed (i.e. dissector_change_string() has been called, such as from
313  * Decode As), otherwise return FALSE.
314  */
315 WS_DLL_PUBLIC gboolean dissector_is_string_changed(dissector_table_t const subdissectors, const gchar *string);
316 
317 /* Look for a given string in a given dissector table and, if found, call
318  the dissector with the arguments supplied, and return the number of
319  bytes consumed, otherwise return 0. */
320 WS_DLL_PUBLIC int dissector_try_string(dissector_table_t sub_dissectors,
321  const gchar *string, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data);
322 
323 /* Look for a given string in a given dissector table and, if found, call
324  the dissector with the arguments supplied, and return the number of
325  bytes consumed, otherwise return 0. */
326 WS_DLL_PUBLIC int dissector_try_string_new(dissector_table_t sub_dissectors,
327  const gchar *string, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const gboolean add_proto_name,void *data);
328 
337  dissector_table_t sub_dissectors, const gchar *string);
338 
347  const char *name, const gchar *string);
348 
349 /* Add an entry to a "custom" dissector table. */
350 WS_DLL_PUBLIC void dissector_add_custom_table_handle(const char *name, void *pattern,
351  dissector_handle_t handle);
352 
361  dissector_table_t sub_dissectors, void *key);
362 /* Key for GUID dissector tables. This is based off of DCE/RPC needs
363  so some dissector tables may not need the ver portion of the hash
364  */
365 typedef struct _guid_key {
366  e_guid_t guid;
367  guint16 ver;
368 } guid_key;
369 
370 /* Add an entry to a guid dissector table. */
371 WS_DLL_PUBLIC void dissector_add_guid(const char *name, guid_key* guid_val,
372  dissector_handle_t handle);
373 
374 /* Look for a given value in a given guid dissector table and, if found,
375  call the dissector with the arguments supplied, and return TRUE,
376  otherwise return FALSE. */
377 WS_DLL_PUBLIC int dissector_try_guid(dissector_table_t sub_dissectors,
378  guid_key* guid_val, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
379 
380 /* Look for a given value in a given guid dissector table and, if found,
381  call the dissector with the arguments supplied, and return TRUE,
382  otherwise return FALSE. */
383 WS_DLL_PUBLIC int dissector_try_guid_new(dissector_table_t sub_dissectors,
384  guid_key* guid_val, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const gboolean add_proto_name, void *data);
385 
386 /* Delete a GUID from a dissector table. */
387 WS_DLL_PUBLIC void dissector_delete_guid(const char *name, guid_key* guid_val,
388  dissector_handle_t handle);
389 
398  dissector_table_t const sub_dissectors, guid_key* guid_val);
399 
400 /* Use the currently assigned payload dissector for the dissector table and,
401  if any, call the dissector with the arguments supplied, and return the
402  number of bytes consumed, otherwise return 0. */
403 WS_DLL_PUBLIC int dissector_try_payload(dissector_table_t sub_dissectors,
404  tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
405 
406 /* Use the currently assigned payload dissector for the dissector table and,
407  if any, call the dissector with the arguments supplied, and return the
408  number of bytes consumed, otherwise return 0. */
409 WS_DLL_PUBLIC int dissector_try_payload_new(dissector_table_t sub_dissectors,
410  tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, const gboolean add_proto_name, void *data);
411 
412 /* Change the entry for a dissector in a payload (FT_NONE) dissector table
413  with a particular pattern to use a new dissector handle. */
414 WS_DLL_PUBLIC void dissector_change_payload(const char *abbrev, dissector_handle_t handle);
415 
416 /* Reset payload (FT_NONE) dissector table to its initial value. */
417 WS_DLL_PUBLIC void dissector_reset_payload(const char *name);
418 
419 /* Given a payload dissector table (type FT_NONE), return the handle of
420  the dissector that is currently active, i.e. that was selected via
421  Decode As. */
422 WS_DLL_PUBLIC dissector_handle_t dissector_get_payload_handle(
424 
425 /* Add a handle to the list of handles that *could* be used with this
426  table. That list is used by the "Decode As"/"-d" code in the UI. */
427 WS_DLL_PUBLIC void dissector_add_for_decode_as(const char *name,
428  dissector_handle_t handle);
429 
430 /* Same as dissector_add_for_decode_as, but adds preference for dissector table value */
431 WS_DLL_PUBLIC void dissector_add_for_decode_as_with_preference(const char *name,
432  dissector_handle_t handle);
433 
437 
442 
446 
450 
454 
455 /* List of "heuristic" dissectors (which get handed a packet, look at it,
456  and either recognize it as being for their protocol, dissect it, and
457  return TRUE, or don't recognize it and return FALSE) to be called
458  by another dissector.
459 
460  This is opaque outside of "packet.c". */
461 struct heur_dissector_list;
463 
464 
465 typedef struct heur_dtbl_entry {
466  heur_dissector_t dissector;
467  protocol_t *protocol; /* this entry's protocol */
468  gchar *list_name; /* the list name this entry is in the list of */
469  const gchar *display_name; /* the string used to present heuristic to user */
470  gchar *short_name; /* string used for "internal" use to uniquely identify heuristic */
471  gboolean enabled;
472  bool enabled_by_default;
474 
482 WS_DLL_PUBLIC heur_dissector_list_t register_heur_dissector_list_with_description(const char *name, const char *ui_name, const int proto);
483 
488 WS_DLL_PUBLIC const char *heur_dissector_list_get_description(heur_dissector_list_t list);
489 
496 WS_DLL_PUBLIC heur_dissector_list_t register_heur_dissector_list(const char *name, const int proto);
497 
498 typedef void (*DATFunc_heur) (const gchar *table_name,
499  struct heur_dtbl_entry *entry, gpointer user_data);
500 typedef void (*DATFunc_heur_table) (const char *table_name,
501  struct heur_dissector_list *table, gpointer user_data);
502 
512 WS_DLL_PUBLIC void heur_dissector_table_foreach(const char *table_name,
513  DATFunc_heur func, gpointer user_data);
514 
523 WS_DLL_PUBLIC void dissector_all_heur_tables_foreach_table (DATFunc_heur_table func,
524  gpointer user_data, GCompareFunc compare_key_func);
525 
526 /* true if a heur_dissector list of that name exists to be registered into */
527 WS_DLL_PUBLIC gboolean has_heur_dissector_list(const gchar *name);
528 
541 WS_DLL_PUBLIC gboolean dissector_try_heuristic(heur_dissector_list_t sub_dissectors,
542  tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, heur_dtbl_entry_t **hdtbl_entry, void *data);
543 
549 WS_DLL_PUBLIC heur_dissector_list_t find_heur_dissector_list(const char *name);
550 
556 WS_DLL_PUBLIC heur_dtbl_entry_t* find_heur_dissector_by_unique_short_name(const char *short_name);
557 
568 WS_DLL_PUBLIC void heur_dissector_add(const char *name, heur_dissector_t dissector,
569  const char *display_name, const char *internal_name, const int proto, heuristic_enable_e enable);
570 
578 WS_DLL_PUBLIC void heur_dissector_delete(const char *name, heur_dissector_t dissector, const int proto);
579 
581 WS_DLL_PUBLIC dissector_handle_t register_dissector(const char *name, dissector_t dissector, const int proto);
582 
584 WS_DLL_PUBLIC dissector_handle_t register_dissector_with_description(const char *name, const char *description, dissector_t dissector, const int proto);
585 
587 WS_DLL_PUBLIC dissector_handle_t register_dissector_with_data(const char *name, dissector_cb_t dissector, const int proto, void *cb_data);
588 
590 void deregister_dissector(const char *name);
591 
593 WS_DLL_PUBLIC const char *dissector_handle_get_protocol_long_name(const dissector_handle_t handle);
594 
596 WS_DLL_PUBLIC const char *dissector_handle_get_protocol_short_name(const dissector_handle_t handle);
597 
598 /* For backwards source and binary compatibility */
600 WS_DLL_PUBLIC const char *dissector_handle_get_short_name(const dissector_handle_t handle);
601 
603 WS_DLL_PUBLIC const char *dissector_handle_get_description(const dissector_handle_t handle);
604 
606 WS_DLL_PUBLIC int dissector_handle_get_protocol_index(const dissector_handle_t handle);
607 
609 WS_DLL_PUBLIC GList* get_dissector_names(void);
610 
612 WS_DLL_PUBLIC dissector_handle_t find_dissector(const char *name);
613 
615 WS_DLL_PUBLIC dissector_handle_t find_dissector_add_dependency(const char *name, const int parent_proto);
616 
618 WS_DLL_PUBLIC const char *dissector_handle_get_dissector_name(const dissector_handle_t handle);
619 
621 WS_DLL_PUBLIC dissector_handle_t create_dissector_handle(dissector_t dissector,
622  const int proto);
623 WS_DLL_PUBLIC dissector_handle_t create_dissector_handle_with_name(dissector_t dissector,
624  const int proto, const char* name);
625 WS_DLL_PUBLIC dissector_handle_t create_dissector_handle_with_name_and_description(dissector_t dissector,
626  const int proto, const char* name, const char* description);
627 WS_DLL_PUBLIC dissector_handle_t create_dissector_handle_with_data(dissector_cb_t dissector,
628  const int proto, void* cb_data);
629 
630 /* Dump all registered dissectors to the standard output */
631 WS_DLL_PUBLIC void dissector_dump_dissectors(void);
632 
646 WS_DLL_PUBLIC int call_dissector_with_data(dissector_handle_t handle, tvbuff_t *tvb,
647  packet_info *pinfo, proto_tree *tree, void *data);
648 WS_DLL_PUBLIC int call_dissector(dissector_handle_t handle, tvbuff_t *tvb,
649  packet_info *pinfo, proto_tree *tree);
650 
651 WS_DLL_PUBLIC int call_data_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
652 
666 WS_DLL_PUBLIC int call_dissector_only(dissector_handle_t handle, tvbuff_t *tvb,
667  packet_info *pinfo, proto_tree *tree, void *data);
668 
678  packet_info *pinfo, proto_tree *tree, void *data);
679 
680 /* This is opaque outside of "packet.c". */
681 struct depend_dissector_list;
683 
694 WS_DLL_PUBLIC gboolean register_depend_dissector(const char* parent, const char* dependent);
695 
705 WS_DLL_PUBLIC gboolean deregister_depend_dissector(const char* parent, const char* dependent);
706 
712 WS_DLL_PUBLIC depend_dissector_list_t find_depend_dissector_list(const char* name);
713 
714 
715 /* Do all one-time initialization. */
716 extern void dissect_init(void);
717 
718 extern void dissect_cleanup(void);
719 
720 /*
721  * Given a tvbuff, and a length from a packet header, adjust the length
722  * of the tvbuff to reflect the specified length.
723  */
724 WS_DLL_PUBLIC void set_actual_length(tvbuff_t *tvb, const guint specified_len);
725 
733 WS_DLL_PUBLIC void register_init_routine(void (*func)(void));
734 
742 WS_DLL_PUBLIC void register_cleanup_routine(void (*func)(void));
743 
744 /*
745  * Allows protocols to register "shutdown" routines, which are called
746  * once, just before program exit
747  */
748 WS_DLL_PUBLIC void register_shutdown_routine(void (*func)(void));
749 
750 /* Initialize all data structures used for dissection. */
751 void init_dissection(void);
752 
753 /* Free data structures allocated for dissection. */
754 void cleanup_dissection(void);
755 
756 /* Allow protocols to register a "cleanup" routine to be
757  * run after the initial sequential run through the packets.
758  * Note that the file can still be open after this; this is not
759  * the final cleanup. */
760 WS_DLL_PUBLIC void register_postseq_cleanup_routine(void (*func)(void));
761 
762 /* Call all the registered "postseq_cleanup" routines. */
763 WS_DLL_PUBLIC void postseq_cleanup_all_protocols(void);
764 
765 /* Allow dissectors to register a "final_registration" routine
766  * that is run like the proto_register_XXX() routine, but the end
767  * end of the epan_init() function; that is, *after* all other
768  * subsystems, liked dfilters, have finished initializing. This is
769  * useful for dissector registration routines which need to compile
770  * display filters. dfilters can't initialize itself until all protocols
771  * have registered themselves. */
772 WS_DLL_PUBLIC void
773 register_final_registration_routine(void (*func)(void));
774 
775 /* Call all the registered "final_registration" routines. */
776 extern void
777 final_registration_all_protocols(void);
778 
779 /*
780  * Add a new data source to the list of data sources for a frame, given
781  * the tvbuff for the data source and its name.
782  */
783 WS_DLL_PUBLIC void add_new_data_source(packet_info *pinfo, tvbuff_t *tvb,
784  const char *name);
785 /* Removes the last-added data source, if it turns out it wasn't needed */
786 WS_DLL_PUBLIC void remove_last_data_source(packet_info *pinfo);
787 
788 /*
789  * Return the data source name, tvb.
790  */
791 struct data_source;
792 WS_DLL_PUBLIC char *get_data_source_name(const struct data_source *src);
793 WS_DLL_PUBLIC tvbuff_t *get_data_source_tvb(const struct data_source *src);
794 WS_DLL_PUBLIC tvbuff_t *get_data_source_tvb_by_name(packet_info *pinfo, const char *name);
795 
796 /*
797  * Free up a frame's list of data sources.
798  */
799 extern void free_data_sources(packet_info *pinfo);
800 
801 /* Mark another frame as depended upon by the current frame.
802  *
803  * This information is used to ensure that the depended-upon frame is saved
804  * if the user does a File->Save-As of only the Displayed packets and the
805  * current frame passed the display filter.
806  */
807 WS_DLL_PUBLIC void mark_frame_as_depended_upon(frame_data *fd, guint32 frame_num);
808 
809 /* Structure passed to the frame dissector */
810 typedef struct frame_data_s
811 {
812  int file_type_subtype;
814  struct epan_dissect *color_edt;
816 } frame_data_t;
817 
818 /* Structure passed to the file dissector */
819 typedef struct file_data_s
820 {
822  struct epan_dissect *color_edt;
824 } file_data_t;
825 
826 /*
827  * Dissectors should never modify the record data.
828  */
829 extern void dissect_record(struct epan_dissect *edt, int file_type_subtype,
830  wtap_rec *rec, tvbuff_t *tvb, frame_data *fd, column_info *cinfo);
831 
832 /*
833  * Dissectors should never modify the packet data.
834  */
835 extern void dissect_file(struct epan_dissect *edt,
836  wtap_rec *rec, tvbuff_t *tvb, frame_data *fd, column_info *cinfo);
837 
838 /* Structure passed to the ethertype dissector */
839 typedef struct ethertype_data_s
840 {
841  guint16 etype;
842  int payload_offset;
843  proto_tree *fh_tree;
844  int trailer_id;
845  int fcs_len;
847 
848 /*
849  * Dump layer/selector/dissector records in a fashion similar to the
850  * proto_registrar_dump_* routines.
851  */
852 WS_DLL_PUBLIC void dissector_dump_decodes(void);
853 
854 /*
855  * For each heuristic dissector table, dump list of dissectors (filter_names) for that table
856  */
857 WS_DLL_PUBLIC void dissector_dump_heur_decodes(void);
858 
859 /*
860  * postdissectors are to be called by packet-frame.c after every other
861  * dissector has been called.
862  */
863 
864 /*
865  * Register a postdissector; the argument is the dissector handle for it.
866  */
867 WS_DLL_PUBLIC void register_postdissector(dissector_handle_t handle);
868 
869 /*
870  * Specify a set of hfids that the postdissector will need.
871  * The GArray is an array of hfids (type int) and should be NULL to clear the
872  * list. This function will take ownership of the memory.
873  */
874 WS_DLL_PUBLIC void set_postdissector_wanted_hfids(dissector_handle_t handle,
875  GArray *wanted_hfids);
876 
877 /*
878  * Deregister a postdissector. Not for use in (post)dissectors or
879  * applications; only to be used by libwireshark itself.
880  */
881 void deregister_postdissector(dissector_handle_t handle);
882 
883 /*
884  * Return TRUE if we have at least one postdissector, FALSE if not.
885  * Not for use in (post)dissectors or applications; only to be used
886  * by libwireshark itself.
887  */
888 extern gboolean have_postdissector(void);
889 
890 /*
891  * Call all postdissectors, handing them the supplied arguments.
892  * Not for use in (post)dissectors or applications; only to be used
893  * by libwireshark itself.
894  */
895 extern void call_all_postdissectors(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
896 
897 /*
898  * Return TRUE if at least one postdissector needs at least one hfid,
899  * FALSE otherwise.
900  */
901 WS_DLL_PUBLIC gboolean postdissectors_want_hfids(void);
902 
903 /*
904  * Prime an epan_dissect_t with all the hfids wanted by postdissectors.
905  */
906 WS_DLL_PUBLIC void
907 prime_epan_dissect_with_postdissector_wanted_hfids(epan_dissect_t *edt);
908 
915 WS_DLL_PUBLIC void increment_dissection_depth(packet_info *pinfo);
916 
921 WS_DLL_PUBLIC void decrement_dissection_depth(packet_info *pinfo);
922 
925 #ifdef __cplusplus
926 }
927 #endif /* __cplusplus */
928 
929 #endif /* packet.h */
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:3540
void deregister_dissector(const char *name)
Definition: packet.c:3523
void dissector_table_foreach_changed(const char *table_name, DATFunc func, gpointer user_data)
Definition: packet.c:2593
WS_DLL_PUBLIC dissector_handle_t dissector_get_string_handle(dissector_table_t sub_dissectors, const gchar *string)
Definition: packet.c:1969
WS_DLL_PUBLIC dissector_handle_t find_dissector_add_dependency(const char *name, const int parent_proto)
Definition: packet.c:3345
WS_DLL_PUBLIC dissector_handle_t register_dissector(const char *name, dissector_t dissector, const int proto)
Definition: packet.c:3466
void deregister_dissector_table(const char *name)
Definition: packet.c:2792
WS_DLL_PUBLIC gboolean deregister_depend_dissector(const char *parent, const char *dependent)
Definition: packet.c:3695
WS_DLL_PUBLIC const char * dissector_handle_get_dissector_name(const dissector_handle_t handle)
Definition: packet.c:3358
WS_DLL_PUBLIC dissector_handle_t dissector_get_default_uint_handle(const char *name, const guint32 uint_val)
Definition: packet.c:1654
WS_DLL_PUBLIC dissector_handle_t dissector_get_uint_handle(dissector_table_t const sub_dissectors, const guint32 uint_val)
Definition: packet.c:1642
WS_DLL_PUBLIC dissector_handle_t dissector_get_guid_handle(dissector_table_t const sub_dissectors, guid_key *guid_val)
Definition: packet.c:2165
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:3486
WS_DLL_PUBLIC heur_dissector_list_t find_heur_dissector_list(const char *name)
Definition: packet.c:2848
WS_DLL_PUBLIC ftenum_t dissector_table_get_type(dissector_table_t dissector_table)
Definition: packet.c:2398
WS_DLL_PUBLIC const char * dissector_handle_get_protocol_long_name(const dissector_handle_t handle)
Definition: packet.c:3273
WS_DLL_PUBLIC void dissector_table_foreach(const char *table_name, DATFunc func, gpointer user_data)
Definition: packet.c:2516
WS_DLL_PUBLIC dissector_handle_t dissector_get_custom_table_handle(dissector_table_t sub_dissectors, void *key)
Definition: packet.c:2044
WS_DLL_PUBLIC dissector_handle_t dissector_get_default_string_handle(const char *name, const gchar *string)
Definition: packet.c:1984
WS_DLL_PUBLIC void decrement_dissection_depth(packet_info *pinfo)
Definition: packet.c:4053
WS_DLL_PUBLIC void register_init_routine(void(*func)(void))
Definition: packet.c:321
WS_DLL_PUBLIC void heur_dissector_delete(const char *name, heur_dissector_t dissector, const int proto)
Definition: packet.c:2954
WS_DLL_PUBLIC void register_cleanup_routine(void(*func)(void))
Definition: packet.c:327
WS_DLL_PUBLIC dissector_handle_t create_dissector_handle(dissector_t dissector, const int proto)
Definition: packet.c:3398
WS_DLL_PUBLIC void dissector_all_tables_foreach_table(DATFunc_table func, gpointer user_data, GCompareFunc compare_key_func)
Definition: packet.c:2648
WS_DLL_PUBLIC gboolean dissector_table_supports_decode_as(dissector_table_t dissector_table)
Definition: packet.c:2410
WS_DLL_PUBLIC void dissector_table_allow_decode_as(dissector_table_t dissector_table)
Definition: packet.c:2404
WS_DLL_PUBLIC dissector_handle_t find_dissector(const char *name)
Definition: packet.c:3339
WS_DLL_PUBLIC gboolean 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:2980
WS_DLL_PUBLIC void dissector_all_tables_foreach_changed(DATFunc func, gpointer user_data)
Definition: packet.c:2577
WS_DLL_PUBLIC gboolean register_depend_dissector(const char *parent, const char *dependent)
Definition: packet.c:3667
WS_DLL_PUBLIC const char * heur_dissector_list_get_description(heur_dissector_list_t list)
Definition: packet.c:3258
WS_DLL_PUBLIC const char * dissector_handle_get_description(const dissector_handle_t handle)
Definition: packet.c:3302
WS_DLL_PUBLIC void increment_dissection_depth(packet_info *pinfo)
Definition: packet.c:4047
gboolean(* heur_dissector_t)(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *)
Definition: packet.h:94
WS_DLL_PUBLIC int dissector_handle_get_protocol_index(const dissector_handle_t handle)
Definition: packet.c:3310
WS_DLL_PUBLIC depend_dissector_list_t find_depend_dissector_list(const char *name)
Definition: packet.c:3705
WS_DLL_PUBLIC void register_dissector_table_alias(dissector_table_t dissector_table, const char *alias_name)
Definition: packet.c:2774
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:3554
WS_DLL_PUBLIC void dissector_table_foreach_handle(const char *table_name, DATFunc_handle func, gpointer user_data)
Definition: packet.c:2535
WS_DLL_PUBLIC GList * get_dissector_names(void)
Definition: packet.c:3328
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:3588
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:2864
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:3476
WS_DLL_PUBLIC void dissector_all_heur_tables_foreach_table(DATFunc_heur_table func, gpointer user_data, GCompareFunc compare_key_func)
Definition: packet.c:3177
WS_DLL_PUBLIC GSList * dissector_table_get_dissector_handles(dissector_table_t dissector_table)
Definition: packet.c:2356
WS_DLL_PUBLIC const char * dissector_handle_get_protocol_short_name(const dissector_handle_t handle)
Definition: packet.c:3284
WS_DLL_PUBLIC dissector_handle_t dissector_table_get_dissector_handle(dissector_table_t dissector_table, const gchar *description)
Definition: packet.c:2386
WS_DLL_PUBLIC heur_dissector_list_t register_heur_dissector_list(const char *name, const int proto)
Definition: packet.c:3252
WS_DLL_PUBLIC void heur_dissector_table_foreach(const char *table_name, DATFunc_heur func, gpointer user_data)
Definition: packet.c:3121
WS_DLL_PUBLIC heur_dtbl_entry_t * find_heur_dissector_by_unique_short_name(const char *short_name)
Definition: packet.c:2858
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:3231
Definition: guid-utils.h:22
Definition: packet.h:365
Definition: packet_info.h:44
Definition: proto.h:904
Definition: proto.c:371
Definition: packet.c:56
Definition: packet.c:115
Definition: packet.c:763
Definition: packet.c:86
Definition: packet.c:1104
Definition: column-info.h:63
Definition: epan_dissect.h:28
Definition: range.h:42
Definition: packet.h:840
Definition: packet.h:820
wtap_block_t pkt_block
Definition: packet.h:821
Definition: packet.h:811
wtap_block_t pkt_block
Definition: packet.h:813
Definition: packet.c:160
Definition: packet.h:465
Definition: tvbuff-int.h:35
Definition: wtap_opttypes.c:85
Definition: wtap.h:1395