2 * Synchronisation between Wireshark capture parent and child instances
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
14 * Sync mode capture (internal interface).
16 * Will start a new Wireshark child instance which will do the actual capture
20 #ifndef __CAPTURE_SYNC_H__
21 #define __CAPTURE_SYNC_H__
25 #endif /* __cplusplus */
30 * Start a new capture session.
31 * Create a capture child which is doing the real capture work.
32 * The various capture_input_... functions will be called, if something had
35 * Most of the parameters are passed through the global capture_opts.
37 * @param capture_opts the options
38 * @param capture_comments if not NULL, a GPtrArray * to a set of comments
39 * to put in the capture file's Section Header Block if it's a pcapng file
40 * @param cap_session a handle for the capture session
41 * @param cap_data a struct with capture info data
42 * @param update_cb update screen
43 * @return true if a capture could be started, false if not
46 sync_pipe_start(capture_options
*capture_opts
, GPtrArray
*capture_comments
,
47 capture_session
*cap_session
, struct _info_data
* cap_data
,
48 void(*update_cb
)(void));
50 /** User wants to stop capturing, gracefully close the capture child */
52 sync_pipe_stop(capture_session
*cap_session
);
54 /** User wants to stop the program, just kill the child as soon as possible */
56 sync_pipe_kill(ws_process_id fork_child
);
59 * Set wireless channel using dumpcap
60 * On success, *data points to a buffer containing the dumpcap output,
61 * *primary_msg and *secondary_msg are NULL, and 0 is returned. *data
62 * must be freed with g_free().
64 * On failure, *data is NULL, *primary_msg points to an error message,
65 * *secondary_msg either points to an additional error message or is
66 * NULL, and -1 or errno value is returned; *primary_msg, and
67 * *secondary_msg if not NULL must be freed with g_free().
69 * @param iface (monitor) network interface name
70 * @param freq channel control frequency string (in MHz)
71 * @param type channel type string (or NULL if not used)
72 * @param center_freq1 VHT channel center frequency (or NULL if not used)
73 * @param center_freq2 VHT channel center frequency 2 (or NULL if not used)
74 * @param data On success, *data points to a buffer containing the dumpcap output, On failure *data is NULL
75 * @param primary_msg On success NULL, On failure points to an error message
76 * @param secondary_msg On success NULL, On failure either points to an additional error message or is NULL
77 * @param update_cb update callback
78 * @return 0 on success
81 sync_interface_set_80211_chan(const char *iface
, const char *freq
, const char *type
,
82 const char *center_freq1
, const char *center_freq2
,
83 char **data
, char **primary_msg
,
84 char **secondary_msg
, void (*update_cb
)(void));
86 /** Get an interface list using dumpcap */
88 sync_interface_list_open(char **data
, char **primary_msg
,
89 char **secondary_msg
, void (*update_cb
)(void));
91 /** Get interface capabilities using dumpcap */
93 sync_if_capabilities_open(const char *ifname
, bool monitor_mode
, const char* auth
,
94 char **data
, char **primary_msg
,
95 char **secondary_msg
, void (*update_cb
)(void));
98 sync_if_list_capabilities_open(GList
*ifqueries
,
99 char **data
, char **primary_msg
,
100 char **secondary_msg
, void (*update_cb
)(void));
102 /** Start getting interface statistics using dumpcap. */
104 sync_interface_stats_open(int *read_fd
, ws_process_id
*fork_child
, char **data
, char **msg
, void (*update_cb
)(void));
106 /** Stop gathering statistics. */
108 sync_interface_stats_close(int *read_fd
, ws_process_id
*fork_child
, char **msg
);
110 /** Read a line from a pipe, similar to fgets. Non-blocking. */
112 sync_pipe_gets_nonblock(int pipe_fd
, char *bytes
, int max
);
114 /* set a callback to be called after fork with the pid of the forked child */
115 extern void capture_sync_set_fetch_dumpcap_pid_cb(void(*cb
)(ws_process_id pid
));
119 #endif /* __cplusplus */
121 #endif /* __CAPTURE_SYNC_H__ */