forked from wireshark/wireshark
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathringbuffer.h
More file actions
111 lines (98 loc) · 3.74 KB
/
ringbuffer.h
File metadata and controls
111 lines (98 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/** @file
*
* Definitions for capture ringbuffer files
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __RINGBUFFER_H__
#define __RINGBUFFER_H__
#include <wireshark.h>
#include <writecap/pcapio.h>
#define RINGBUFFER_UNLIMITED_FILES 0
/* Minimum number of ringbuffer files */
#define RINGBUFFER_MIN_NUM_FILES 0
/* Maximum number of ringbuffer files */
/* Avoid crashes on very large numbers. Should be a power of 10 */
#define RINGBUFFER_MAX_NUM_FILES 100000
/* Maximum number for FAT filesystems */
#define RINGBUFFER_WARN_NUM_FILES 65535
/**
* @brief Initialize the ringbuffer system.
*
* Initializes the ringbuffer system with the specified parameters.
*
* @param capture_name The name of the capture file.
* @param num_files The number of files in the ringbuffer.
* @param group_read_access Whether to set group read access for the files.
* @param compress_type The compression type for the files.
* @param nametimenum Whether to include name, time, and number in the filenames.
* @return file descriptor on success, -1 on failure.
*/
int ringbuf_init(const char *capture_name, unsigned num_files, bool group_read_access,
const char *compress_type, bool nametimenum);
/**
* @brief Check if the ringbuffer system is initialized.
*
* Determines whether the ringbuffer system has been initialized.
*
* @return true if the ringbuffer system is initialized, false otherwise.
*/
bool ringbuf_is_initialized(void);
/**
* @brief Get the current filename used by the ringbuffer.
*/
const char *ringbuf_current_filename(void);
/**
* @brief Initialize a libpcap dump file for the ringbuffer.
* Initializes a libpcap dump file for writing captured packets to the ringbuffer.
* @param err Pointer to an integer that will be set to an error code if an error occurs.
* @return A pointer to a ws_cwstream on success, or NULL on failure.
*/
ws_cwstream* ringbuf_init_libpcap_fdopen(int *err);
/**
* @brief Switch the ringbuffer dump file.
* @param pdh Pointer to the current pcap dump handle, which will be updated to the new handle.
* @param save_file Pointer to a string that will be set to the name of the saved file.
* @param save_file_fd Pointer to an integer that will be set to the file descriptor of the saved file.
* @param err Pointer to an integer that will be set to an error code if an error occurs.
* @return true on success, false otherwise.
*/
bool ringbuf_switch_file(ws_cwstream* *pdh, char **save_file, int *save_file_fd,
int *err);
/**
* @brief Close the ringbuffer dump file.
*
* Closes the current ringbuffer dump file and cleans up resources.
*
* @param save_file Pointer to a string that will be set to the name of the saved file.
* @param err Pointer to an integer that will be set to an error code if an error occurs.
* @return true on success, false otherwise.
*/
bool ringbuf_libpcap_dump_close(char **save_file, int *err);
/**
* @brief Frees all memory allocated by the ringbuffer.
*
* Cleans up and frees all resources used by the ringbuffer system.
*/
void ringbuf_free(void);
/**
* @brief Clean up any errors related to the ringbuffer system.
*
* Frees all memory allocated by the ringbuffer and closes any open files.
*/
void ringbuf_error_cleanup(void);
/**
* @brief Set the name for the ringbuffer.
*
* Sets the name of the file to which the ringbuffer will write data.
*
* @param name Pointer to a string that will be set to the name of the capture file.
* @param err Pointer to an integer that will be set to an error code if an error occurs.
* @return true on success, false otherwise.
*/
bool ringbuf_set_print_name(char *name, int *err);
#endif /* ringbuffer.h */