Get rid of "-F" - "-S" works, and has a more convenient UI.
Print a usage message if an illegal command-line flag is seen. Clean up the usage message a bit. svn path=/trunk/; revision=755
This commit is contained in:
parent
37aa821603
commit
79ec5a3ba9
138
capture.c
138
capture.c
|
@ -1,7 +1,7 @@
|
|||
/* capture.c
|
||||
* Routines for packet capture windows
|
||||
*
|
||||
* $Id: capture.c,v 1.78 1999/10/02 19:24:18 guy Exp $
|
||||
* $Id: capture.c,v 1.79 1999/10/02 19:57:23 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -90,9 +90,8 @@
|
|||
|
||||
int sync_mode; /* fork a child to do the capture, and sync between them */
|
||||
int sync_pipe[2]; /* used to sync father */
|
||||
int fork_mode; /* fork a child to do the capture */
|
||||
int quit_after_cap; /* Makes a "capture only mode". Implies -k */
|
||||
gboolean capture_child; /* if this is the child for "-F"/"-S" */
|
||||
gboolean capture_child; /* if this is the child for "-S" */
|
||||
|
||||
static void capture_stop_cb(GtkWidget *, gpointer);
|
||||
static void capture_pcap_cb(u_char *, const struct pcap_pkthdr *,
|
||||
|
@ -148,7 +147,7 @@ do_capture(char *capfile_name)
|
|||
cf.save_file = capfile_name;
|
||||
cf.user_saved = !is_temp_file;
|
||||
|
||||
if (sync_mode || fork_mode) { /* use fork() for capture */
|
||||
if (sync_mode) { /* use fork() for capture */
|
||||
int fork_child;
|
||||
char ssnap[24];
|
||||
char scount[24]; /* need a constant for len of numbers */
|
||||
|
@ -158,97 +157,82 @@ do_capture(char *capfile_name)
|
|||
sprintf(scount,"%d",cf.count);
|
||||
sprintf(save_file_fd,"%d",cf.save_file_fd);
|
||||
signal(SIGCHLD, SIG_IGN);
|
||||
if (sync_mode)
|
||||
pipe(sync_pipe);
|
||||
pipe(sync_pipe);
|
||||
if ((fork_child = fork()) == 0) {
|
||||
/* args: -i interface specification
|
||||
* -w file to write
|
||||
* -W file descriptor to write
|
||||
* -c count to capture
|
||||
* -s snaplen
|
||||
* -S sync mode
|
||||
* -m / -b fonts
|
||||
* -f "filter expression"
|
||||
*/
|
||||
if (sync_mode) {
|
||||
close(1);
|
||||
dup(sync_pipe[1]);
|
||||
close(sync_pipe[0]);
|
||||
execlp(ethereal_path, CHILD_NAME, "-i", cf.iface,
|
||||
close(1);
|
||||
dup(sync_pipe[1]);
|
||||
close(sync_pipe[0]);
|
||||
execlp(ethereal_path, CHILD_NAME, "-i", cf.iface,
|
||||
"-w", cf.save_file, "-W", save_file_fd,
|
||||
"-c", scount, "-s", ssnap, "-S",
|
||||
"-c", scount, "-s", ssnap,
|
||||
"-m", medium_font, "-b", bold_font,
|
||||
(cf.cfilter == NULL)? 0 : "-f",
|
||||
(cf.cfilter == NULL)? 0 : cf.cfilter,
|
||||
(const char *)NULL);
|
||||
}
|
||||
else {
|
||||
execlp(ethereal_path, CHILD_NAME, "-i", cf.iface,
|
||||
"-w", cf.save_file, "-W", save_file_fd,
|
||||
"-c", scount, "-s", ssnap,
|
||||
"-m", medium_font, "-b", bold_font,
|
||||
(cf.cfilter == NULL)? 0 : "-f",
|
||||
(cf.cfilter == NULL)? 0 : cf.cfilter,
|
||||
(const char *)NULL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
cf.filename = cf.save_file;
|
||||
if (sync_mode) {
|
||||
close(sync_pipe[1]);
|
||||
cf.filename = cf.save_file;
|
||||
close(sync_pipe[1]);
|
||||
|
||||
/* Read a byte count from "sync_pipe[0]", terminated with a
|
||||
colon; if the count is 0, the child process created the
|
||||
capture file and we should start reading from it, otherwise
|
||||
the capture couldn't start and the count is a count of bytes
|
||||
of error message, and we should display the message. */
|
||||
byte_count = 0;
|
||||
for (;;) {
|
||||
i = read(sync_pipe[0], &c, 1);
|
||||
if (i == 0) {
|
||||
/* EOF - the child process died.
|
||||
XXX - reap it and report the status. */
|
||||
simple_dialog(ESD_TYPE_WARN, NULL, "Capture child process died");
|
||||
return;
|
||||
}
|
||||
if (c == ';')
|
||||
break;
|
||||
if (!isdigit(c)) {
|
||||
/* Child process handed us crap. */
|
||||
simple_dialog(ESD_TYPE_WARN, NULL,
|
||||
"Capture child process sent us a bad message");
|
||||
return;
|
||||
}
|
||||
byte_count = byte_count*10 + c - '0';
|
||||
}
|
||||
if (byte_count == 0) {
|
||||
/* Success. */
|
||||
err = tail_cap_file(cf.save_file, &cf);
|
||||
if (err != 0) {
|
||||
simple_dialog(ESD_TYPE_WARN, NULL,
|
||||
/* Read a byte count from "sync_pipe[0]", terminated with a
|
||||
colon; if the count is 0, the child process created the
|
||||
capture file and we should start reading from it, otherwise
|
||||
the capture couldn't start and the count is a count of bytes
|
||||
of error message, and we should display the message. */
|
||||
byte_count = 0;
|
||||
for (;;) {
|
||||
i = read(sync_pipe[0], &c, 1);
|
||||
if (i == 0) {
|
||||
/* EOF - the child process died.
|
||||
XXX - reap it and report the status. */
|
||||
simple_dialog(ESD_TYPE_WARN, NULL, "Capture child process died");
|
||||
return;
|
||||
}
|
||||
if (c == ';')
|
||||
break;
|
||||
if (!isdigit(c)) {
|
||||
/* Child process handed us crap. */
|
||||
simple_dialog(ESD_TYPE_WARN, NULL,
|
||||
"Capture child process sent us a bad message");
|
||||
return;
|
||||
}
|
||||
byte_count = byte_count*10 + c - '0';
|
||||
}
|
||||
if (byte_count == 0) {
|
||||
/* Success. */
|
||||
err = tail_cap_file(cf.save_file, &cf);
|
||||
if (err != 0) {
|
||||
simple_dialog(ESD_TYPE_WARN, NULL,
|
||||
file_open_error_message(err, FALSE), cf.save_file);
|
||||
}
|
||||
} else {
|
||||
/* Failure. */
|
||||
msg = g_malloc(byte_count + 1);
|
||||
if (msg == NULL) {
|
||||
simple_dialog(ESD_TYPE_WARN, NULL,
|
||||
"Capture child process failed, but its error message was too big.");
|
||||
} else {
|
||||
i = read(sync_pipe[0], msg, byte_count);
|
||||
if (i < 0) {
|
||||
simple_dialog(ESD_TYPE_WARN, NULL,
|
||||
}
|
||||
} else {
|
||||
/* Failure. */
|
||||
msg = g_malloc(byte_count + 1);
|
||||
if (msg == NULL) {
|
||||
simple_dialog(ESD_TYPE_WARN, NULL,
|
||||
"Capture child process failed, but its error message was too big.");
|
||||
} else {
|
||||
i = read(sync_pipe[0], msg, byte_count);
|
||||
if (i < 0) {
|
||||
simple_dialog(ESD_TYPE_WARN, NULL,
|
||||
"Capture child process failed: Error %s reading its error message.",
|
||||
strerror(errno));
|
||||
} else if (i == 0) {
|
||||
simple_dialog(ESD_TYPE_WARN, NULL,
|
||||
} else if (i == 0) {
|
||||
simple_dialog(ESD_TYPE_WARN, NULL,
|
||||
"Capture child process failed: EOF reading its error message.");
|
||||
} else
|
||||
simple_dialog(ESD_TYPE_WARN, NULL, msg);
|
||||
g_free(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
simple_dialog(ESD_TYPE_WARN, NULL, msg);
|
||||
g_free(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -376,7 +360,7 @@ capture(void)
|
|||
goto error;
|
||||
}
|
||||
|
||||
if (capture_child && sync_mode) {
|
||||
if (capture_child) {
|
||||
/* Well, we should be able to start capturing.
|
||||
|
||||
This is the child process for a sync mode capture, so sync out
|
||||
|
@ -487,7 +471,7 @@ capture(void)
|
|||
|
||||
/* do sync here, too */
|
||||
fflush(wtap_dump_file(ld.pdh));
|
||||
if (capture_child && sync_mode && ld.sync_packets) {
|
||||
if (capture_child && ld.sync_packets) {
|
||||
/* This is the child process for a sync mode capture, so send
|
||||
our parent a message saying we've written out "ld.sync_packets"
|
||||
packets to the capture file. */
|
||||
|
@ -546,7 +530,7 @@ error:
|
|||
/* We couldn't even start the capture, so get rid of the capture
|
||||
file. */
|
||||
unlink(cf.save_file); /* silently ignore error */
|
||||
if (capture_child && sync_mode) {
|
||||
if (capture_child) {
|
||||
/* This is the child process for a sync mode capture.
|
||||
Send the error message to our parent, so they can display a
|
||||
dialog box containing it. */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* capture.h
|
||||
* Definitions for packet capture windows
|
||||
*
|
||||
* $Id: capture.h,v 1.20 1999/10/02 19:24:19 guy Exp $
|
||||
* $Id: capture.h,v 1.21 1999/10/02 19:57:24 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -28,14 +28,13 @@
|
|||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
|
||||
/* Name we give to the child process when doing a "-S" or "-F" capture. */
|
||||
/* Name we give to the child process when doing a "-S" capture. */
|
||||
#define CHILD_NAME "ethereal-capture"
|
||||
|
||||
extern int sync_mode; /* allow sync */
|
||||
extern int sync_mode; /* fork a child to do the capture, and sync between them */
|
||||
extern int sync_pipe[2]; /* used to sync father */
|
||||
extern int fork_mode; /* fork a child to do the capture */
|
||||
extern int quit_after_cap; /* Makes a "capture only mode". Implies -k */
|
||||
extern gboolean capture_child; /* if this is the child for "-F"/"-S" */
|
||||
extern gboolean capture_child; /* if this is the child for "-S" */
|
||||
|
||||
/* Open a specified file, or create a temporary file, and start a capture
|
||||
to the file in question. */
|
||||
|
|
|
@ -9,7 +9,6 @@ B<ethereal>
|
|||
S<[ B<-B> byte view height ]>
|
||||
S<[ B<-b> bold font ]>
|
||||
S<[ B<-c> count ]>
|
||||
S<[ B<-F> ]>
|
||||
S<[ B<-f> filter expression ]>
|
||||
S<[ B<-h> ]>
|
||||
S<[ B<-i> interface ]>
|
||||
|
@ -77,12 +76,6 @@ pane that corresponds to the field selected in the protocol tree pane.
|
|||
Sets the default number of packets to read when capturing live
|
||||
data.
|
||||
|
||||
=item -F
|
||||
|
||||
Specifies that the live packet capture will be performed in a separate
|
||||
process. It is then possible to open/reload the file to display the
|
||||
packets actually captured.
|
||||
|
||||
=item -f
|
||||
|
||||
Sets the capture filter expression.
|
||||
|
@ -134,9 +127,8 @@ the filter are discarded.
|
|||
=item -S
|
||||
|
||||
Specifies that the live packet capture will be performed in a separate
|
||||
process (same as option B<-F>) and that the packet displaying should be
|
||||
synchronized with the capture session without human operation
|
||||
(i.e. without load/reload).
|
||||
process, and that the packet display will automatically be updated as
|
||||
packets are seen.
|
||||
|
||||
=item -s
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* file_dlg.c
|
||||
* Dialog boxes for handling files
|
||||
*
|
||||
* $Id: file_dlg.c,v 1.5 1999/10/02 19:24:27 guy Exp $
|
||||
* $Id: file_dlg.c,v 1.6 1999/10/02 19:57:31 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -109,7 +109,7 @@ file_open_cmd_cb(GtkWidget *w, gpointer data) {
|
|||
gtk_widget_destroy, GTK_OBJECT (file_sel));
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
if ((sync_mode || fork_mode) && (cf.save_file != NULL))
|
||||
if (sync_mode && (cf.save_file != NULL))
|
||||
#else
|
||||
if (cf.save_file != NULL)
|
||||
#endif
|
||||
|
|
20
gtk/main.c
20
gtk/main.c
|
@ -1,6 +1,6 @@
|
|||
/* main.c
|
||||
*
|
||||
* $Id: main.c,v 1.16 1999/10/02 19:33:14 guy Exp $
|
||||
* $Id: main.c,v 1.17 1999/10/02 19:57:30 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -442,11 +442,11 @@ print_usage(void) {
|
|||
|
||||
fprintf(stderr, "This is GNU %s %s, compiled with %s\n", PACKAGE,
|
||||
VERSION, comp_info_str);
|
||||
fprintf(stderr, "%s [-vh] [-FkQS] [-b bold font] [-B byte view height] [-c count]\n",
|
||||
fprintf(stderr, "%s [-vh] [-kQS] [-b <bold font>] [-B <byte view height>] [-c count]\n",
|
||||
PACKAGE);
|
||||
fprintf(stderr, " [-f \"filter expression\"] [-i interface] [-m medium font] [-n]\n");
|
||||
fprintf(stderr, " [-P packet list height] [-r infile] [-s snaplen]\n");
|
||||
fprintf(stderr, " [-t <time stamp format>] [-T tree view height] [-w savefile] \n");
|
||||
fprintf(stderr, " [-f <filter expression>] [-i interface] [-m <medium font>] [-n]\n");
|
||||
fprintf(stderr, " [-P <packet list height>] [-r infile] [-s snaplen]\n");
|
||||
fprintf(stderr, " [-t <time stamp format>] [-T <tree view height>] [-w savefile] \n");
|
||||
}
|
||||
|
||||
/* And now our feature presentation... [ fade to music ] */
|
||||
|
@ -499,7 +499,7 @@ main(int argc, char *argv[])
|
|||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
/* Set "capture_child" to indicate whether this is going to be a child
|
||||
process for a "-S" or "-F" capture? */
|
||||
process for a "-S" capture? */
|
||||
capture_child = (strcmp(command_name, CHILD_NAME) == 0);
|
||||
#endif
|
||||
|
||||
|
@ -556,7 +556,7 @@ main(int argc, char *argv[])
|
|||
|
||||
#ifndef WIN32
|
||||
/* Now get our args */
|
||||
while ((opt = getopt(argc, argv, "b:B:c:f:Fhi:km:nP:Qr:R:Ss:t:T:w:W:v")) != EOF) {
|
||||
while ((opt = getopt(argc, argv, "b:B:c:f:hi:km:nP:Qr:R:Ss:t:T:w:W:v")) != EOF) {
|
||||
switch (opt) {
|
||||
case 'b': /* Bold font */
|
||||
bold_font = g_strdup(optarg);
|
||||
|
@ -571,9 +571,6 @@ main(int argc, char *argv[])
|
|||
case 'f':
|
||||
cf.cfilter = g_strdup(optarg);
|
||||
break;
|
||||
case 'F': /* Fork to capture */
|
||||
fork_mode = TRUE;
|
||||
break;
|
||||
#endif
|
||||
case 'h': /* Print help and exit */
|
||||
print_usage();
|
||||
|
@ -646,6 +643,9 @@ main(int argc, char *argv[])
|
|||
cf.save_file_fd = atoi(optarg);
|
||||
break;
|
||||
#endif
|
||||
case '?': /* Bad flag - print usage message */
|
||||
print_usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue