#include <signal.h>
#ifdef _WIN32
-#include "epan/unicode-utils.h"
+#include <wsutil/unicode-utils.h>
#endif
#ifdef HAVE_SYS_WAIT_H
#include "capture-wpcap.h"
#endif
#include "ui_util.h"
-#include "file_util.h"
+#include <wsutil/file_util.h>
#include "log.h"
#ifdef _WIN32
report_failure("We don't know where to find dumpcap.");
return FALSE;
}
-
+
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "argv[0]: %s", argv[0]);
argv = sync_pipe_add_arg(argv, &argc, "-i");
if (capture_opts->linktype != -1) {
argv = sync_pipe_add_arg(argv, &argc, "-y");
-#ifdef HAVE_PCAP_DATALINK_VAL_TO_NAME
g_snprintf(sdlt, ARGV_NUMBER_LEN, "%s",linktype_val_to_name(capture_opts->linktype));
-#else
- /* we can't get the type name, just treat it as a number */
- g_snprintf(sdlt, ARGV_NUMBER_LEN, "%d",capture_opts->linktype);
-#endif
argv = sync_pipe_add_arg(argv, &argc, sdlt);
}
#ifdef _WIN32
argv = sync_pipe_add_arg(argv, &argc, "-B");
+#ifdef HAVE_PCAP_REMOTE
+ if (capture_opts->src_type == CAPTURE_IFREMOTE)
+ /* No buffer size when using remote interfaces */
+ g_snprintf(buffer_size, ARGV_NUMBER_LEN, "%d", 1);
+ else
+#endif
g_snprintf(buffer_size, ARGV_NUMBER_LEN, "%d",capture_opts->buffer_size);
argv = sync_pipe_add_arg(argv, &argc, buffer_size);
#endif
* it just capture with the specified capture parameters
*/
dup2(sync_pipe[PIPE_WRITE], 2);
- eth_close(sync_pipe[PIPE_READ]);
+ ws_close(sync_pipe[PIPE_READ]);
execv(argv[0], (gpointer)argv);
g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
argv[0], strerror(errno));
#ifdef _WIN32
CloseHandle(sync_pipe_write);
#else
- eth_close(sync_pipe[PIPE_WRITE]);
+ ws_close(sync_pipe[PIPE_WRITE]);
#endif
if (capture_opts->fork_child == -1) {
/* We couldn't even create the child process. */
report_failure("Couldn't create child process: %s", strerror(errno));
- eth_close(sync_pipe_read_fd);
+ ws_close(sync_pipe_read_fd);
#ifdef _WIN32
- eth_close(capture_opts->signal_pipe_write_fd);
+ ws_close(capture_opts->signal_pipe_write_fd);
#endif
return FALSE;
}
* it just capture with the specified capture parameters
*/
dup2(sync_pipe[PIPE_WRITE], 1);
- eth_close(sync_pipe[PIPE_READ]);
+ ws_close(sync_pipe[PIPE_READ]);
execv(argv[0], (gpointer)argv);
g_snprintf(errmsg, sizeof errmsg, "Couldn't run %s in child process: %s",
argv[0], strerror(errno));
#ifdef _WIN32
CloseHandle(sync_pipe_write);
#else
- eth_close(sync_pipe[PIPE_WRITE]);
+ ws_close(sync_pipe[PIPE_WRITE]);
#endif
if (*fork_child == -1) {
/* We couldn't even create the child process. */
*msg = g_strdup_printf("Couldn't create child process: %s", strerror(errno));
- eth_close(*read_fd);
+ ws_close(*read_fd);
return CANT_RUN_DUMPCAP;
}
#endif
int fork_child_status;
- eth_close(*read_fd);
+ ws_close(*read_fd);
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_close_command: wait till child closed");
/* We were able to set up to read dumpcap's output. Do so and
return its exit value. */
msg_buf = g_string_new("");
- while ((count = eth_read(sync_pipe_read_fd, buf, PIPE_BUF_SIZE)) > 0) {
+ while ((count = ws_read(sync_pipe_read_fd, buf, PIPE_BUF_SIZE)) > 0) {
buf[count] = '\0';
g_string_append(msg_buf, buf);
}
/* currently be sent as is to stderr resulting in garbled output. */
/* ToDo: Revise this code to be similar to sync_pipe_start so that 'dumpcap -Z' */
/* special format error messages to stderr are captured and returned to caller */
- /* (eg: so can be processed and displayed in a pop-up box). */
+ /* (eg: so can be processed and displayed in a pop-up box). */
#ifndef DEBUG_CHILD
argv = sync_pipe_add_arg(argv, &argc, "-Z");
argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE);
/* currently be sent as is to stderr resulting in garbled output. */
/* ToDo: Revise this code to be similar to sync_pipe_start so that 'dumpcap -Z' */
/* special format error messages to stderr are captured and returned to caller */
- /* (eg: so can be processed and displayed in a pop-up box). */
+ /* (eg: so can be processed and displayed in a pop-up box). */
#ifndef DEBUG_CHILD
argv = sync_pipe_add_arg(argv, &argc, "-Z");
argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE);
/* currently be sent as is to stderr resulting in garbled output. */
/* ToDo: Revise this code to be similar to sync_pipe_start so that 'dumpcap -Z' */
/* special format error messages to stderr are captured and returned to caller */
- /* (eg: so can be processed and displayed in a pop-up box). */
+ /* (eg: so can be processed and displayed in a pop-up box). */
#ifndef DEBUG_CHILD
argv = sync_pipe_add_arg(argv, &argc, "-Z");
argv = sync_pipe_add_arg(argv, &argc, SIGNAL_PIPE_CTRL_ID_NONE);
/* Read a line from a pipe, similar to fgets */
int
-sync_pipe_gets_nonblock(int pipe, char *bytes, int max) {
+sync_pipe_gets_nonblock(int pipe_fd, char *bytes, int max) {
int newly;
int offset = -1;
while(offset < max - 1) {
offset++;
- if (! pipe_data_available(pipe))
+ if (! pipe_data_available(pipe_fd))
break;
- newly = read(pipe, &bytes[offset], 1);
+ newly = read(pipe_fd, &bytes[offset], 1);
if (newly == 0) {
/* EOF - not necessarily an error */
break;
} else if (newly < 0) {
/* error */
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
- "read from pipe %d: error(%u): %s", pipe, errno, strerror(errno));
+ "read from pipe %d: error(%u): %s", pipe_fd, errno, strerror(errno));
return newly;
} else if (bytes[offset] == '\n') {
break;
sync_pipe_wait_for_child(capture_opts);
#ifdef _WIN32
- eth_close(capture_opts->signal_pipe_write_fd);
+ ws_close(capture_opts->signal_pipe_write_fd);
#endif
capture_input_closed(capture_opts);
return FALSE;
/* We weren't able to open the new capture file; user has been
alerted. Close the sync pipe. */
- eth_close(source);
+ ws_close(source);
/* the child has send us a filename which we couldn't open.
this probably means, the child is creating files faster than we can handle it.
/* the capture child will close the sync_pipe, nothing to do for now */
break;
case SP_DROPS:
- capture_input_drops(capture_opts, atoi(buffer));
+ capture_input_drops(capture_opts, (guint32)strtoul(buffer, NULL, 10));
break;
default:
g_assert_not_reached();