Windows: Wait for dumpcap to initialize.
[metze/wireshark/wip.git] / sync_pipe.h
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  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23
24
25 /** @file
26  *
27  *  Low-level sync pipe interfaces.
28  */
29
30 #ifndef __SYNC_PIPE_H__
31 #define __SYNC_PIPE_H__
32
33
34 /*
35  * Maximum length of sync pipe message data.  Must be < 2^24, as the
36  * message length is 3 bytes.
37  * XXX - this must be large enough to handle a Really Big Filter
38  * Expression, as the error message for an incorrect filter expression
39  * is a bit larger than the filter expression.
40  */
41 #define SP_MAX_MSG_LEN  4096
42
43
44 /* Size of buffer to hold decimal representation of
45    signed/unsigned 64-bit int */
46 #define SP_DECISIZE 20
47
48 /*
49  * Indications sent out on the sync pipe (from child to parent).
50  * We might want to switch to something like Thrift
51  * (http://thrift.apache.org/) or Protocol Buffers
52  * (http://code.google.com/p/protobuf-c/) if we ever need to use more
53  * complex messages.
54  */
55 #define SP_FILE         'F'     /* the name of the recently opened file */
56 #define SP_ERROR_MSG    'E'     /* error message */
57 #define SP_BAD_FILTER   'B'     /* error message for bad capture filter */
58 #define SP_PACKET_COUNT 'P'     /* count of packets captured since last message */
59 #define SP_DROPS        'D'     /* count of packets dropped in capture */
60 #define SP_SUCCESS      'S'     /* success indication, no extra data */
61 /*
62  * Win32 only: Indications sent out on the signal pipe (from parent to child)
63  * (UNIX-like sends signals for this)
64  */
65 #define SP_INIT         'I'     /* child process initialized */
66 #define SP_QUIT         'Q'     /* "gracefully" capture quit message (SIGUSR1) */
67
68 /* write a single message header to the recipient pipe */
69 extern ssize_t
70 pipe_write_header(int pipe_fd, char indicator, int length);
71
72 /* write a message to the recipient pipe in the standard format
73    (3 digit message length (excluding length and indicator field),
74    1 byte message indicator and the rest is the message).
75    If msg is NULL, the message has only a length and indicator. */
76 extern void
77 pipe_write_block(int pipe_fd, char indicator, const char *msg);
78
79 /** the child encountered an error, notify the parent */
80 extern void
81 sync_pipe_errmsg_to_parent(int pipe_fd, const char *error_msg,
82                            const char *secondary_error_msg);
83
84 /** Has the parent signalled the child to stop? */
85 #define SIGNAL_PIPE_CTRL_ID_NONE "none"
86 #ifdef _WIN32
87 #define SIGNAL_PIPE_FORMAT "\\\\.\\pipe\\wireshark.%s.signal"
88 #endif
89
90 #endif /* sync_pipe.h */
91
92 /*
93  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
94  *
95  * Local variables:
96  * c-basic-offset: 4
97  * tab-width: 8
98  * indent-tabs-mode: nil
99  * End:
100  *
101  * vi: set shiftwidth=4 tabstop=8 expandtab:
102  * :indentSize=4:tabSize=8:noTabs=true:
103  */