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