Wireshark 2.9.0-477-g68ec514b The Wireshark network protocol analyzer

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

capture_dissectors.h
Go to the documentation of this file.
1 /* capture_dissectors.h
2 * Routines for handling capture dissectors
3 *
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
7 *
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
10
11 #ifndef __CAPTURE_DISSECTORS_H__
12 #define __CAPTURE_DISSECTORS_H__
13
14 #include "ws_symbol_export.h"
15 #include <wiretap/wtap.h>
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif /* __cplusplus */
20
25 typedef struct {
26 GHashTable* counts_hash; /* packet counters keyed by proto */
27 gint other; /* Packets not counted in the hash total */
28 gint total; /* Cache of total packets */
29 } packet_counts;
30
31 typedef struct _capture_packet_info {
32 GHashTable *counts;
33 } capture_packet_info_t;
34
35 typedef struct capture_dissector_handle* capture_dissector_handle_t;
36
38 typedef gboolean (*capture_dissector_t)(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
39
40 /* a protocol uses the function to register a capture sub-dissector table
41 * @param[in] name Name of capture sub-dissector table.
42 * @param[in] ui_name Name string used when referring to capture sub-dissector table in UI.
43 */
44 WS_DLL_PUBLIC void register_capture_dissector_table(const char *name, const char *ui_name);
45
46 /* Create an anonymous handle for a capture dissector
47 * @param[in] dissector capture dissector function.
48 * @param[in] proto Protocol associated with capture dissector function.
49 * @return Handle created for capture dissector
50 */
51 WS_DLL_PUBLIC capture_dissector_handle_t create_capture_dissector_handle(capture_dissector_t dissector, const int proto);
52
53 /* Find a dissector by name
54 * @param[in] name Name of capture dissector
55 * @return Handle for capture dissector if found, NULL otherwise
56 */
57 WS_DLL_PUBLIC capture_dissector_handle_t find_capture_dissector(const char *name);
58
59 /* Register a new capture dissector
60 * @param[in] name Name of capture dissector function.
61 * @param[in] dissector capture dissector function.
62 * @param[in] proto Protocol associated with capture dissector function.
63 * @return Handle created for capture dissector
64 */
65 WS_DLL_PUBLIC capture_dissector_handle_t register_capture_dissector(const char *name, capture_dissector_t dissector, int proto);
66
67 /* Add an entry to a uint capture dissector table
68 * @param[in] name Name of capture dissector table
69 * @param[in] pattern Numerical value associated with capture dissector
70 * @param[in] handle Handle to capture dissector
71 */
72 WS_DLL_PUBLIC void capture_dissector_add_uint(const char *name, const guint32 pattern, capture_dissector_handle_t handle);
73
74 /* Look for a given value in a given uint capture dissector table and, if found,
75 * call the dissector with the arguments supplied, and return TRUE,
76 * otherwise return FALSE
77 * @param[in] name Name of capture dissector table
78 * @param[in] pattern Numerical value associated with capture dissector
79 * @param[in] pd Data buffer of captured bytes
80 * @param[in] offset Current offset into pd
81 * @param[in] len Length of pd
82 * @param[in] cpinfo Capture statistics
83 * @param[in] pseudo_header Wiretap pseudo header information
84 */
85 WS_DLL_PUBLIC gboolean try_capture_dissector(const char* name, const guint32 pattern, const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
86
87 /* Call a capture dissector through a handle. If handle is value return TRUE,
88 * otherwise return FALSE
89 * @param[in] handle Capture dissector handle
90 * @param[in] pd Data buffer of captured bytes
91 * @param[in] offset Current offset into pd
92 * @param[in] len Length of pd
93 * @param[in] cpinfo Capture statistics
94 * @param[in] pseudo_header Wiretap pseudo header information
95 */
96 WS_DLL_PUBLIC gboolean call_capture_dissector(capture_dissector_handle_t handle, const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header);
97
98 /* Get current capture packet count for a particular protocol
99 * @param[in] counts Packet count structure
100 * @param[in] proto Protocol to retrieve packet count from
101 * @return Number of packets captured for a particular protocol
102 */
103 WS_DLL_PUBLIC guint32 capture_dissector_get_count(packet_counts* counts, const int proto);
104
105 /* Increment packet capture count by 1 for a particular protocol.
106 * @param[in] cpinfo Capture statistics
107 * @param[in] proto Protocol to increment packet count
108 */
109 WS_DLL_PUBLIC void capture_dissector_increment_count(capture_packet_info_t *cpinfo, const int proto);
110
111 extern void capture_dissector_init(void);
112 extern void capture_dissector_cleanup(void);
113
114 #ifdef __cplusplus
115 }
116 #endif /* __cplusplus */
117
118 #endif /* capture_dissectors.h */
wtap_pseudo_header
Definition: wtap.h:1157
capture_dissector_handle
Definition: capture_dissectors.c:25
_capture_packet_info
Definition: capture_dissectors.h:31
capture_dissector_t
gboolean(* capture_dissector_t)(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header)
Definition: capture_dissectors.h:38
packet_counts
Definition: capture_dissectors.h:25