2 * Low-level synchronization pipe routines for use by Wireshark/TShark
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
15 * Low-level sync pipe interfaces.
18 #ifndef __SYNC_PIPE_H__
19 #define __SYNC_PIPE_H__
21 #include <ws_posix_compat.h>
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.
33 #define SP_MAX_MSG_LEN (512 * 1000)
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
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 */
53 * Win32 only: Indications sent out on the signal pipe (from parent to child)
54 * (UNIX-like sends signals for this)
56 #define SP_QUIT 'Q' /* "gracefully" capture quit message (SIGUSR1) */
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. */
63 sync_pipe_write_string_msg(int pipe_fd
, char indicator
, const char *msg
);
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. */
70 sync_pipe_write_uint_msg(int pipe_fd
, char indicator
, unsigned int num
);
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. */
76 sync_pipe_write_int_msg(int pipe_fd
, char indicator
, int num
);
78 /** the child encountered an error, notify the parent */
80 sync_pipe_write_errmsgs_to_parent(int pipe_fd
, const char *error_msg
,
81 const char *secondary_error_msg
);
83 /** Has the parent signalled the child to stop? */
84 #define SIGNAL_PIPE_CTRL_ID_NONE "none"
86 #define SIGNAL_PIPE_FORMAT "\\\\.\\pipe\\wireshark.%s.signal"
89 #endif /* sync_pipe.h */
92 * Editor modelines - https://www.wireshark.org/tools/modelines.html
97 * indent-tabs-mode: nil
100 * vi: set shiftwidth=4 tabstop=8 expandtab:
101 * :indentSize=4:tabSize=8:noTabs=true: