| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
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 uint64_t other; /* Packets not counted in the hash total */
28 uint64_t 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 bool (*capture_dissector_t)(const uint8_t *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 */
44WS_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 */
51WS_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 */
57WS_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 */
65WS_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 */
72WS_DLL_PUBLIC void capture_dissector_add_uint(const char *name, const uint32_t 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 */
85WS_DLL_PUBLIC bool try_capture_dissector(const char* name, const uint32_t pattern, const uint8_t *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 */
96WS_DLL_PUBLIC bool call_capture_dissector(capture_dissector_handle_t handle, const uint8_t *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 */
103WS_DLL_PUBLIC uint64_t 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 */
109WS_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 */
capture_dissector_t
bool(* capture_dissector_t)(const uint8_t *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header)
Definition capture_dissectors.h:38
_capture_packet_info
Definition capture_dissectors.h:31
capture_dissector_handle
Definition capture_dissectors.c:30
packet_counts
Definition capture_dissectors.h:25
wtap_pseudo_header
Definition wtap.h:1281
wtap.h