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