Wireshark  4.3.0
The Wireshark network protocol analyzer
/builds/wireshark/wireshark/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 <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  * SPDX-License-Identifier: GPL-2.0-or-later
10  */
11 
12 
18 #ifndef __SYNC_PIPE_H__
19 #define __SYNC_PIPE_H__
20 
21 #include <ws_posix_compat.h>
22 
23 /*
24  * Maximum length of sync pipe message data. Must be < 2^24, as the
25  * message length is 3 bytes.
26  * XXX - this must be large enough to handle a Really Big Filter
27  * Expression, as the error message for an incorrect filter expression
28  * is a bit larger than the filter expression, and large enough to
29  * handle a large interface list.
30  * 4096 is a typical PIPE_BUF size for atomic writes, but we should have
31  * only one writer and one reader so that shouldn't be an issue.
32  */
33 #define SP_MAX_MSG_LEN 24572
34 
35 /*
36  * Indications sent out on the sync pipe (from child to parent).
37  * We might want to switch to something like Thrift
38  * (http://thrift.apache.org/) or Protocol Buffers
39  * (http://code.google.com/p/protobuf-c/) if we ever need to use more
40  * complex messages.
41  */
42 #define SP_EXEC_FAILED 'X' /* errno value for the exec failing */
43 #define SP_FILE 'F' /* the name of the recently opened file */
44 #define SP_ERROR_MSG 'E' /* error message */
45 #define SP_LOG_MSG 'L' /* log message */
46 #define SP_BAD_FILTER 'B' /* error message for bad capture filter */
47 #define SP_PACKET_COUNT 'P' /* count of packets captured since last message */
48 #define SP_DROPS 'D' /* count of packets dropped in capture */
49 #define SP_SUCCESS 'S' /* success indication, no extra data */
50 #define SP_TOOLBAR_CTRL 'T' /* interface toolbar control packet */
51 #define SP_IFACE_LIST 'I' /* interface list */
52 /*
53  * Win32 only: Indications sent out on the signal pipe (from parent to child)
54  * (UNIX-like sends signals for this)
55  */
56 #define SP_QUIT 'Q' /* "gracefully" capture quit message (SIGUSR1) */
57 
58 /* Write a message, with a string body, to the recipient pipe in the
59  standard format (1-byte message indicator, 3-byte message length
60  (excluding length and indicator field), and the string.
61  If msg is NULL, the message has only a length and indicator. */
62 extern void
63 sync_pipe_write_string_msg(int pipe_fd, char indicator, const char *msg);
64 
65 /* Write a message, with an unsigned integer body, to the recipient
66  pipe in the standard format (1-byte message indicator, 3-byte
67  message length (excluding length and indicator field), and the
68  unsigned integer, as a string. */
69 extern void
70 sync_pipe_write_uint_msg(int pipe_fd, char indicator, unsigned int num);
71 
72 /* Write a message, with an integer body, to the recipient pipe in the
73  standard format (1-byte message indicator, 3-byte message length
74  (excluding length and indicator field), and the integer, as a string. */
75 extern void
76 sync_pipe_write_int_msg(int pipe_fd, char indicator, int num);
77 
79 extern void
80 sync_pipe_write_errmsgs_to_parent(int pipe_fd, const char *error_msg,
81  const char *secondary_error_msg);
82 
84 #define SIGNAL_PIPE_CTRL_ID_NONE "none"
85 #ifdef _WIN32
86 #define SIGNAL_PIPE_FORMAT "\\\\.\\pipe\\wireshark.%s.signal"
87 #endif
88 
89 #endif /* sync_pipe.h */
90 
91 /*
92  * Editor modelines - https://www.wireshark.org/tools/modelines.html
93  *
94  * Local variables:
95  * c-basic-offset: 4
96  * tab-width: 8
97  * indent-tabs-mode: nil
98  * End:
99  *
100  * vi: set shiftwidth=4 tabstop=8 expandtab:
101  * :indentSize=4:tabSize=8:noTabs=true:
102  */
void sync_pipe_write_errmsgs_to_parent(int pipe_fd, const char *error_msg, const char *secondary_error_msg)
Definition: sync_pipe_write.c:121