Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
sync_pipe.h
Go to the documentation of this file.
1/* sync_pipe.h
2 * Low-level synchronization pipe routines for use by Wireshark/TShark
3 * and dumpcap
4 *
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <[email protected]>
7 * Copyright 1998 Gerald Combs
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
12
17
18#ifndef __SYNC_PIPE_H__
19#define __SYNC_PIPE_H__
20
21#include <ws_posix_compat.h>
22#include <glib.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif /* __cplusplus */
27
28/*
29 * Maximum length of sync pipe message data. Must be < 2^24, as the
30 * message length is 3 bytes.
31 * XXX - this must be large enough to handle a Really Big Filter
32 * Expression, as the error message for an incorrect filter expression
33 * is a bit larger than the filter expression, and large enough to
34 * handle a large interface list.
35 * 4096 is a typical PIPE_BUF size for atomic writes, but we should have
36 * only one writer and one reader so that shouldn't be an issue.
37 */
38#define SP_MAX_MSG_LEN (512 * 1000)
39
40/*
41 * Indications sent out on the sync pipe (from child to parent).
42 * We might want to switch to something like Thrift
43 * (http://thrift.apache.org/) or Protocol Buffers
44 * (http://code.google.com/p/protobuf-c/) if we ever need to use more
45 * complex messages.
46 */
47#define SP_EXEC_FAILED 'X' /* errno value for the exec failing */
48#define SP_FILE 'F' /* the name of the recently opened file */
49#define SP_ERROR_MSG 'E' /* error message */
50#define SP_WARNING_MSG 'W' /* warning message */
51#define SP_LOG_MSG 'L' /* log message */
52#define SP_BAD_FILTER 'B' /* error message for bad capture filter */
53#define SP_PACKET_COUNT 'P' /* count of packets captured since last message */
54#define SP_DROPS 'D' /* count of packets dropped in capture */
55#define SP_SUCCESS 'S' /* success indication, no extra data */
56#define SP_TOOLBAR_CTRL 'T' /* interface toolbar control packet */
57#define SP_IFACE_LIST 'I' /* interface list */
58/*
59 * Win32 only: Indications sent out on the signal pipe (from parent to child)
60 * (UNIX-like sends signals for this)
61 */
62#define SP_QUIT 'Q' /* "gracefully" capture quit message (SIGUSR1) */
63
64extern void
65sync_pipe_convert_header(const unsigned char *header, char *indicator, unsigned *block_len);
66extern ssize_t
67sync_pipe_read_block(GIOChannel *pipe_io, char *indicator, unsigned len, char *msg,
68 char **err_msg);
69
82extern void
83sync_pipe_write_string_msg(int pipe_fd, char indicator, const char *msg);
84
97extern void
98sync_pipe_write_uint_msg(int pipe_fd, char indicator, unsigned int num);
99
112extern void
113sync_pipe_write_int_msg(int pipe_fd, char indicator, int num);
114
121extern void
122sync_pipe_write_errmsgs_to_parent(int pipe_fd, const char *error_msg,
123 const char *secondary_error_msg);
124
131extern void
132sync_pipe_write_warnmsgs_to_parent(int pipe_fd, const char *warning_msg,
133 const char *secondary_warning_msg);
134
136#define SIGNAL_PIPE_CTRL_ID_NONE "none"
137#ifdef _WIN32
138#define SIGNAL_PIPE_FORMAT "\\\\.\\pipe\\wireshark.%s.signal"
139#endif
140
141#ifdef __cplusplus
142}
143#endif /* __cplusplus */
144
145#endif /* sync_pipe.h */
146
147/*
148 * Editor modelines - https://www.wireshark.org/tools/modelines.html
149 *
150 * Local variables:
151 * c-basic-offset: 4
152 * tab-width: 8
153 * indent-tabs-mode: nil
154 * End:
155 *
156 * vi: set shiftwidth=4 tabstop=8 expandtab:
157 * :indentSize=4:tabSize=8:noTabs=true:
158 */
void sync_pipe_write_uint_msg(int pipe_fd, char indicator, unsigned int num)
Writes a string message to the recipient pipe.
Definition sync_pipe_write.c:91
void sync_pipe_write_int_msg(int pipe_fd, char indicator, int num)
Writes a string message to the recipient pipe.
Definition sync_pipe_write.c:104
void sync_pipe_write_errmsgs_to_parent(int pipe_fd, const char *error_msg, const char *secondary_error_msg)
Notify the parent that the child encountered an error.
Definition sync_pipe_write.c:120
void sync_pipe_write_warnmsgs_to_parent(int pipe_fd, const char *warning_msg, const char *secondary_warning_msg)
Notify the parent that the child encountered an warning indication.
Definition sync_pipe_write.c:137
void sync_pipe_write_string_msg(int pipe_fd, char indicator, const char *msg)
Writes a string message to the recipient pipe.
Definition sync_pipe_write.c:48