Wireshark 4.7.4
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
epan.h
Go to the documentation of this file.
1
9#pragma once
10#include <wsutil/feature_list.h>
11#include <epan/tvbuff.h>
12#include <epan/prefs.h>
13#include <epan/frame_data.h>
14#include <epan/register.h>
16
17#ifdef __cplusplus
18extern "C" {
19#endif /* __cplusplus */
20
28extern bool wireshark_abort_on_dissector_bug;
29
37extern bool wireshark_abort_on_too_many_items;
38
45WS_DLL_PUBLIC void ws_dissector_bug(const char *format, ...)
46 G_GNUC_PRINTF(1,2);
47
54#define ws_dissector_oops(_fmt, ...) ws_dissector_bug("OOPS: " _fmt, __VA_ARGS__)
55
63
64struct epan_dfilter;
65struct epan_column_info;
66
74
89 const nstime_t *(*get_frame_ts)(struct packet_provider_data *prov, uint32_t frame_num);
90
97 const nstime_t *(*get_start_ts)(struct packet_provider_data *prov);
98
105 const nstime_t *(*get_end_ts)(struct packet_provider_data *prov);
106
115 const char *(*get_interface_name)(struct packet_provider_data *prov, uint32_t interface_id, unsigned section_number);
116
125 const char *(*get_interface_description)(struct packet_provider_data *prov, uint32_t interface_id, unsigned section_number);
126
134 wtap_block_t (*get_modified_block)(struct packet_provider_data *prov, const frame_data *fd);
135
144 int32_t (*get_process_id)(struct packet_provider_data *prov, uint32_t process_info_id, unsigned section_number);
145
154 const char *(*get_process_name)(struct packet_provider_data *prov, uint32_t process_info_id, unsigned section_number);
155
165 const uint8_t *(*get_process_uuid)(struct packet_provider_data *prov, uint32_t process_info_id, unsigned section_number, size_t *uuid_size);
166
175 const char *(*get_process_path)(struct packet_provider_data *prov, uint32_t process_info_id, unsigned section_number);
176
186 const uint8_t *(*get_process_cmdline)(struct packet_provider_data *prov, uint32_t process_info_id, unsigned section_number, size_t *cmdline_size);
187
197 bool (*get_process_parent_id)(struct packet_provider_data *prov, uint32_t process_info_id, unsigned section_number, uint32_t *parent_process_id);
198
208 bool (*get_process_user_id)(struct packet_provider_data *prov, uint32_t process_info_id, unsigned section_number, uint32_t *user_id);
209
218 const char *(*get_process_user_name)(struct packet_provider_data *prov, uint32_t process_info_id, unsigned section_number);
219
229 bool (*get_process_start_time)(struct packet_provider_data *prov, uint32_t process_info_id, unsigned section_number, nstime_t *start_time);
230
242 bool (*find_process_info)(struct packet_provider_data *prov, uint32_t process_id, unsigned section_number, const nstime_t *ts, int64_t file_off, uint32_t *process_info_id);
243};
244
252/*
253Ref 1
254Epan
255Enhanced Packet ANalyzer, aka the packet analyzing engine. Source code can be found in the epan directory.
256
257Protocol-Tree - Keep data of the capture file protocol information.
258
259Dissectors - The various protocol dissectors in epan/dissectors.
260
261Plugins - Some of the protocol dissectors are implemented as plugins. Source code can be found at plugins.
262
263Display-Filters - the display filter engine at epan/dfilter
264
265*/
266
270typedef struct {
271 const char* env_var_prefix;
272 const char** col_fmt;
274 register_entity_func register_func;
275 register_entity_func handoff_func;
278
290WS_DLL_PUBLIC
291bool epan_init(register_cb cb, void *client_data, bool load_plugins, epan_app_data_t* app_data);
292
298WS_DLL_PUBLIC
300
307WS_DLL_PUBLIC
308void epan_cleanup(void);
309
310
318typedef struct {
322 void (*init)(void);
323
327 void (*post_init)(void);
328
333
338
342 void (*cleanup)(void);
343
350 void (*register_all_protocols)(register_cb cb, void *user_data);
351
358 void (*register_all_handoffs)(register_cb cb, void *user_data);
359
365
378WS_DLL_PUBLIC void epan_register_plugin(const epan_plugin *plugin);
379
388WS_DLL_PUBLIC int epan_plugins_supported(void);
389
397void epan_conversation_init(void);
398
399
400typedef struct epan_session epan_t;
411typedef struct epan_session epan_t;
412
426WS_DLL_PUBLIC epan_t *epan_new(struct packet_provider_data *prov,
427 const struct packet_provider_funcs *funcs);
428
441WS_DLL_PUBLIC wtap_block_t epan_get_modified_block(const epan_t *session, const frame_data *fd);
442
458WS_DLL_PUBLIC const char *epan_get_interface_name(const epan_t *session, uint32_t interface_id, unsigned section_number);
459
474WS_DLL_PUBLIC const char *epan_get_interface_description(const epan_t *session, uint32_t interface_id, unsigned section_number);
475
492WS_DLL_PUBLIC int32_t epan_get_process_id(const epan_t *session, uint32_t process_info_id, unsigned section_number);
493
510WS_DLL_PUBLIC const char *epan_get_process_name(const epan_t *session, uint32_t process_info_id, unsigned section_number);
511
529WS_DLL_PUBLIC const uint8_t *epan_get_process_uuid(const epan_t *session, uint32_t process_info_id, unsigned section_number, size_t *uuid_size);
530
540WS_DLL_PUBLIC const char *epan_get_process_path(const epan_t *session, uint32_t process_info_id, unsigned section_number);
541
555WS_DLL_PUBLIC const uint8_t *epan_get_process_cmdline(const epan_t *session, uint32_t process_info_id, unsigned section_number, size_t *cmdline_size);
556
567WS_DLL_PUBLIC bool epan_get_process_parent_id(const epan_t *session, uint32_t process_info_id, unsigned section_number, uint32_t *parent_process_id);
568
579WS_DLL_PUBLIC bool epan_get_process_user_id(const epan_t *session, uint32_t process_info_id, unsigned section_number, uint32_t *user_id);
580
590WS_DLL_PUBLIC const char *epan_get_process_user_name(const epan_t *session, uint32_t process_info_id, unsigned section_number);
591
602WS_DLL_PUBLIC bool epan_get_process_start_time(const epan_t *session, uint32_t process_info_id, unsigned section_number, nstime_t *start_time);
603
622WS_DLL_PUBLIC bool epan_find_process_info(const epan_t *session, uint32_t process_id, unsigned section_number, const nstime_t *ts, int64_t file_off, uint32_t *process_info_id);
623
636const nstime_t *epan_get_frame_ts(const epan_t *session, uint32_t frame_num);
637
648const nstime_t *epan_get_start_ts(const epan_t *session);
649
659WS_DLL_PUBLIC void epan_free(epan_t *session);
660
671WS_DLL_PUBLIC const char* epan_get_version(void);
672
686WS_DLL_PUBLIC void epan_get_version_number(int *major, int *minor, int *micro);
687
696WS_DLL_PUBLIC const char* epan_get_environment_prefix(void);
697
712WS_DLL_PUBLIC
713void epan_set_always_visible(bool force);
714
723WS_DLL_PUBLIC
724void
725epan_dissect_init(epan_dissect_t *edt, epan_t *session, const bool create_proto_tree, const bool proto_tree_visible);
726
739WS_DLL_PUBLIC
741epan_dissect_new(epan_t *session, const bool create_proto_tree, const bool proto_tree_visible);
742
752WS_DLL_PUBLIC
753void
755
762WS_DLL_PUBLIC
763void
764epan_dissect_fake_protocols(epan_dissect_t *edt, const bool fake_protocols);
765
779WS_DLL_PUBLIC
780void
781epan_dissect_run(epan_dissect_t *edt, int file_type_subtype,
782 wtap_rec *rec, frame_data *fd, struct epan_column_info *cinfo);
783
800WS_DLL_PUBLIC
801void
802epan_dissect_run_with_taps(epan_dissect_t *edt, int file_type_subtype,
803 wtap_rec *rec, frame_data *fd, struct epan_column_info *cinfo);
804
820WS_DLL_PUBLIC
821void
823 frame_data *fd, struct epan_column_info *cinfo);
824
841WS_DLL_PUBLIC
842void
844 frame_data *fd, struct epan_column_info *cinfo);
845
862WS_DLL_PUBLIC
863void
865
879WS_DLL_PUBLIC
880void
882
896WS_DLL_PUBLIC
897void
899
913WS_DLL_PUBLIC
914void
916
929WS_DLL_PUBLIC
930void
931epan_dissect_fill_in_columns(epan_dissect_t *edt, const bool fill_col_exprs, const bool fill_fd_columns);
932
948WS_DLL_PUBLIC
949bool
951 const char *field_name);
952
966WS_DLL_PUBLIC
967void
969
980WS_DLL_PUBLIC
981void
983
1001const char *
1002epan_custom_set(epan_dissect_t *edt, GSList *ids, int occurrence, bool display_details,
1003 char *result, char *expr, const int size);
1004
1010WS_DLL_PUBLIC
1011void
1013
1019WS_DLL_PUBLIC
1020void
1022
1023#ifdef __cplusplus
1024}
1025#endif /* __cplusplus */
WS_DLL_PUBLIC void epan_dissect_init(epan_dissect_t *edt, epan_t *session, const bool create_proto_tree, const bool proto_tree_visible)
Initialize an existing single packet dissection.
Definition epan.c:742
WS_DLL_PUBLIC void epan_dissect_fake_protocols(epan_dissect_t *edt, const bool fake_protocols)
Indicate whether protocols should be faked during dissection.
Definition epan.c:811
WS_DLL_PUBLIC int32_t epan_get_process_id(const epan_t *session, uint32_t process_info_id, unsigned section_number)
Retrieve the process ID associated with a given process info record.
Definition epan.c:611
WS_DLL_PUBLIC const uint8_t * epan_get_process_cmdline(const epan_t *session, uint32_t process_info_id, unsigned section_number, size_t *cmdline_size)
Retrieve the command line of a process.
Definition epan.c:656
WS_DLL_PUBLIC bool epan_init(register_cb cb, void *client_data, bool load_plugins, epan_app_data_t *app_data)
Initialize the entire epan module.
Definition epan.c:294
void epan_conversation_init(void)
Initialize the table of conversations.
Definition epan.c:721
WS_DLL_PUBLIC void epan_dissect_file_run(epan_dissect_t *edt, wtap_rec *rec, frame_data *fd, struct epan_column_info *cinfo)
Run a dissection of file-based packet data.
Definition epan.c:848
WS_DLL_PUBLIC void epan_gather_compile_info(feature_list l)
Get compile-time information for libraries used by libwireshark.
Definition epan.c:979
WS_DLL_PUBLIC void epan_dissect_cleanup(epan_dissect_t *edt)
Release resources associated with a packet dissection context.
Definition epan.c:875
struct epan_session epan_t
Represents a dissection session state.
Definition epan.h:400
WS_DLL_PUBLIC const char * epan_get_process_name(const epan_t *session, uint32_t process_info_id, unsigned section_number)
Retrieve the name of a process associated with a given process info record.
Definition epan.c:629
WS_DLL_PUBLIC void epan_dissect_fill_in_columns(epan_dissect_t *edt, const bool fill_col_exprs, const bool fill_fd_columns)
Populate packet list columns with dissection output.
Definition epan.c:950
WS_DLL_PUBLIC epan_t * epan_new(struct packet_provider_data *prov, const struct packet_provider_funcs *funcs)
Create a new epan dissection session.
Definition epan.c:538
WS_DLL_PUBLIC const char * epan_get_interface_description(const epan_t *session, uint32_t interface_id, unsigned section_number)
Retrieve the description of a network interface.
Definition epan.c:571
WS_DLL_PUBLIC e_prefs * epan_load_settings(void)
Load all settings from the current profile that affect epan.
Definition epan.c:437
WS_DLL_PUBLIC void epan_free(epan_t *session)
Free an epan dissection session.
Definition epan.c:710
WS_DLL_PUBLIC void epan_dissect_prime_with_hfid(epan_dissect_t *edt, int hfid)
Prime a dissection context's protocol tree with a specific field or protocol.
Definition epan.c:922
struct epan_dissect epan_dissect_t
Opaque type representing a single packet dissection context.
Definition epan.h:62
WS_DLL_PUBLIC void epan_dissect_reset(epan_dissect_t *edt)
Reset a dissection context for reuse.
Definition epan.c:771
WS_DLL_PUBLIC int epan_plugins_supported(void)
Check plugin support status for libwireshark components.
Definition epan.c:277
WS_DLL_PUBLIC const char * epan_get_process_path(const epan_t *session, uint32_t process_info_id, unsigned section_number)
Retrieve the path of the executable image of a process.
Definition epan.c:647
WS_DLL_PUBLIC bool epan_find_process_info(const epan_t *session, uint32_t process_id, unsigned section_number, const nstime_t *ts, int64_t file_off, uint32_t *process_info_id)
Find the process information for a process ID.
Definition epan.c:701
WS_DLL_PUBLIC void epan_cleanup(void)
Clean up the entire epan module.
Definition epan.c:456
WS_DLL_PUBLIC void epan_dissect_free(epan_dissect_t *edt)
Free a single packet dissection context.
Definition epan.c:903
WS_DLL_PUBLIC bool epan_get_process_parent_id(const epan_t *session, uint32_t process_info_id, unsigned section_number, uint32_t *parent_process_id)
Retrieve the ID of the parent of a process.
Definition epan.c:665
WS_DLL_PUBLIC void epan_get_version_number(int *major, int *minor, int *micro)
Retrieve the version number of the epan library.
Definition epan.c:154
WS_DLL_PUBLIC wtap_block_t epan_get_modified_block(const epan_t *session, const frame_data *fd)
Retrieve a modified capture block associated with a specific frame.
Definition epan.c:553
WS_DLL_PUBLIC const char * epan_get_process_user_name(const epan_t *session, uint32_t process_info_id, unsigned section_number)
Retrieve the name of the user a process runs as.
Definition epan.c:683
WS_DLL_PUBLIC const char * epan_get_environment_prefix(void)
Retrieve the environment prefix string used by epan.
Definition epan.c:165
WS_DLL_PUBLIC bool epan_dissect_packet_contains_field(epan_dissect_t *edt, const char *field_name)
Check whether a dissected packet contains a specific named field.
Definition epan.c:957
const nstime_t * epan_get_frame_ts(const epan_t *session, uint32_t frame_num)
Retrieve the timestamp of a specific frame.
Definition epan.c:580
WS_DLL_PUBLIC void epan_dissect_prime_with_dfilter(epan_dissect_t *edt, const struct epan_dfilter *dfcode)
Prime a dissection context's protocol tree using a display filter.
WS_DLL_PUBLIC const uint8_t * epan_get_process_uuid(const epan_t *session, uint32_t process_info_id, unsigned section_number, size_t *uuid_size)
Retrieve the UUID of a process associated with a given process info record.
Definition epan.c:638
const nstime_t * epan_get_start_ts(const epan_t *session)
Retrieve the start timestamp of the capture session.
Definition epan.c:595
WS_DLL_PUBLIC void epan_dissect_run(epan_dissect_t *edt, int file_type_subtype, wtap_rec *rec, frame_data *fd, struct epan_column_info *cinfo)
Run a single packet dissection.
Definition epan.c:818
WS_DLL_PUBLIC void epan_gather_runtime_info(feature_list l)
Get runtime information for libraries used by libwireshark.
Definition epan.c:1084
WS_DLL_PUBLIC void epan_dissect_prime_with_hfid_array(epan_dissect_t *edt, GArray *hfids)
Prime a dissection context's protocol tree with a set of fields or protocols.
Definition epan.c:928
WS_DLL_PUBLIC void ws_dissector_bug(const char *format,...)
Report a dissector bug (and optionally abort).
Definition epan.c:128
WS_DLL_PUBLIC const char * epan_get_version(void)
Retrieve the epan library's version as a string.
Definition epan.c:149
WS_DLL_PUBLIC epan_dissect_t * epan_dissect_new(epan_t *session, const bool create_proto_tree, const bool proto_tree_visible)
Create a new single packet dissection.
Definition epan.c:800
WS_DLL_PUBLIC bool epan_get_process_start_time(const epan_t *session, uint32_t process_info_id, unsigned section_number, nstime_t *start_time)
Retrieve the start time of a process.
Definition epan.c:692
WS_DLL_PUBLIC void epan_dissect_prime_with_dfilter_print(epan_dissect_t *edt, const struct epan_dfilter *dfcode)
Prime a dissection context's protocol tree using a display filter, marking fields for print output.
WS_DLL_PUBLIC void epan_dissect_file_run_with_taps(epan_dissect_t *edt, wtap_rec *rec, frame_data *fd, struct epan_column_info *cinfo)
Run a dissection of file-based packet data and invoke tap listeners.
Definition epan.c:862
WS_DLL_PUBLIC void epan_set_always_visible(bool force)
Set or unset the tree to always be visible when epan_dissect_init() is called.
Definition epan.c:733
WS_DLL_PUBLIC void epan_dissect_run_with_taps(epan_dissect_t *edt, int file_type_subtype, wtap_rec *rec, frame_data *fd, struct epan_column_info *cinfo)
Run a single packet dissection and invoke tap listeners.
Definition epan.c:835
const char * epan_custom_set(epan_dissect_t *edt, GSList *ids, int occurrence, bool display_details, char *result, char *expr, const int size)
Set the value of a custom column based on specified fields and expression.
Definition epan.c:940
WS_DLL_PUBLIC void epan_register_plugin(const epan_plugin *plugin)
Register an epan plugin with the dissection engine.
WS_DLL_PUBLIC bool epan_get_process_user_id(const epan_t *session, uint32_t process_info_id, unsigned section_number, uint32_t *user_id)
Retrieve the numeric ID of the user a process runs as.
Definition epan.c:674
WS_DLL_PUBLIC const char * epan_get_interface_name(const epan_t *session, uint32_t interface_id, unsigned section_number)
Retrieve the name of a network interface.
Definition epan.c:562
GList ** feature_list
Semi-opaque handle to a list of features or dependencies.
Definition feature_list.h:33
DIAG_OFF_PEDANTIC struct _frame_data frame_data
Frame data structure.
struct _e_prefs e_prefs
Global Wireshark preferences structure holding all persistent configuration settings.
Describes a single built-in tap registration entry, pairing a tap name with its registration callback...
Definition tap.h:90
Definition packet-bt-dht.c:97
Information about the application that wants to use epan.
Definition epan.h:270
register_entity_func register_func
Definition epan.h:274
int num_cols
Definition epan.h:273
const char * env_var_prefix
Definition epan.h:271
struct _tap_reg const * tap_reg_listeners
Definition epan.h:276
const char ** col_fmt
Definition epan.h:272
register_entity_func handoff_func
Definition epan.h:275
Definition column-info.h:59
The compiled display filter object passed back to the user.
Definition dfilter-int.h:46
Holds all state for the dissection of a single byte array, including session, buffer,...
Definition epan_dissect.h:28
Plugin interface for EPAN modules.
Definition epan.h:318
void(* dissect_init)(epan_dissect_t *)
Called before each dissection begins.
Definition epan.h:332
void(* post_init)(void)
Called at the end of epan_init().
Definition epan.h:327
void(* register_all_tap_listeners)(void)
Register all tap listeners.
Definition epan.h:363
void(* register_all_handoffs)(register_cb cb, void *user_data)
Register all protocol handoffs.
Definition epan.h:358
void(* init)(void)
Called before proto_init().
Definition epan.h:322
void(* cleanup)(void)
Called during EPAN shutdown.
Definition epan.h:342
void(* dissect_cleanup)(epan_dissect_t *)
Called after each dissection completes.
Definition epan.h:337
void(* register_all_protocols)(register_cb cb, void *user_data)
Register all protocols with the core.
Definition epan.h:350
Definition epan.c:532
Definition nstime.h:26
Packet provider context for programs operating on a capture file.
Definition cfile.h:72
Structure containing pointers to functions supplied by the user of libwireshark.
Definition epan.h:81
bool(* find_process_info)(struct packet_provider_data *prov, uint32_t process_id, unsigned section_number, const nstime_t *ts, int64_t file_off, uint32_t *process_info_id)
Find the process information for a process ID.
Definition epan.h:242
bool(* get_process_parent_id)(struct packet_provider_data *prov, uint32_t process_info_id, unsigned section_number, uint32_t *parent_process_id)
Get the ID of the parent of a process.
Definition epan.h:197
bool(* get_process_user_id)(struct packet_provider_data *prov, uint32_t process_info_id, unsigned section_number, uint32_t *user_id)
Get the numeric ID of the user a process runs as.
Definition epan.h:208
wtap_block_t(* get_modified_block)(struct packet_provider_data *prov, const frame_data *fd)
Get a modified WTAP block for a given frame.
Definition epan.h:134
bool(* get_process_start_time)(struct packet_provider_data *prov, uint32_t process_info_id, unsigned section_number, nstime_t *start_time)
Get the start time of a process.
Definition epan.h:229
int32_t(* get_process_id)(struct packet_provider_data *prov, uint32_t process_info_id, unsigned section_number)
Get the process ID associated with a packet.
Definition epan.h:144
Represents a single capture record read from or written to a capture file, regardless of record type.
Definition wtap.h:1601