Warren Young's patch to add a "Print" button to the "Follow TCP Stream"

data window.

Some (belated) man page updates.

svn path=/trunk/; revision=950
This commit is contained in:
Guy Harris 1999-10-30 06:42:10 +00:00
parent 149c40fec9
commit b99cfa28c8
5 changed files with 137 additions and 16 deletions

View File

@ -162,6 +162,10 @@ Uwe Girlich <Uwe.Girlich@philosys.de> {
ONC RPC and NFS support ONC RPC and NFS support
} }
Warren Young <tangent@mail.com> {
"Print" button support in "Tools:Follow TCP Stream" window
}
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to
give his permission to use his version of snprintf.c. give his permission to use his version of snprintf.c.

View File

@ -47,11 +47,13 @@ shows a summary line, briefly describing what the packet is. A protocol tree is
you to drill down to exact protocol or field that you interested in. Finally, a hex dump you to drill down to exact protocol or field that you interested in. Finally, a hex dump
shows you exactly what the packet looks like when it goes over the wire. shows you exactly what the packet looks like when it goes over the wire.
In addition, B<Ethereal> has some features that make it unique. It can assemble all In addition, B<Ethereal> has some features that make it unique. It can
the packets in a TCP conversation and show you the ASCII data in that conversation. Display assemble all the packets in a TCP conversation and show you the ASCII
filters in B<Ethereal> are very powerful; more fields are filterable in Ethereal than in other (or EBCDIC) data in that conversation. Display filters in B<Ethereal>
protocol analyzers, and the syntax you can use to create your filters is richer. As Ethereal are very powerful; more fields are filterable in Ethereal than in other
progresses, expect more and more protocol fields to be allowed in display filters. protocol analyzers, and the syntax you can use to create your filters is
richer. As Ethereal progresses, expect more and more protocol fields to
be allowed in display filters.
Packet capturing is performed with the pcap library. The capture filter syntax follows Packet capturing is performed with the pcap library. The capture filter syntax follows
the rules of the pcap library. This syntax is different from the display filter syntax. the rules of the pcap library. This syntax is different from the display filter syntax.
@ -93,7 +95,8 @@ should match one of the names listed in "B<netstat -i>" or "B<ifconfig -a>".
=item -k =item -k
Starts the capture session immediately; this option requires Starts the capture session immediately; this option requires
the B<-i> and B<-w> parameters. the B<-i> parameter, specifying the interface on which the capture
should be done.
=item -m =item -m
@ -237,12 +240,18 @@ Expands all branches of the protocol tree.
=item Tools:Follow TCP Stream =item Tools:Follow TCP Stream
If you have a TCP packet selected, it will display the contents of the TCP If you have a TCP packet selected, it will display the contents of the
data stream in a separate window. This has the side-effect of leaving data stream for the TCP connection to which that packet belongs, as
the list of packets in a filtered state; only those packets that make up text, in a separate window, and will leave the list of packets in a
the TCP stream are shown. You can revert to your old view by pressing filtered state, with only those packets that are part of that TCP
ENTER in the display filter text box, thereby invoking your old connection being displayed. You can revert to your old view by pressing
display filter (or resetting it back to no display filter). ENTER in the display filter text box, thereby invoking your old display
filter (or resetting it back to no display filter).
The window in which the data stream is displayed lets you select whether
the data being displayed is to be treated as ASCII or EBCDIC text, and
lets you print the text, using the same print options that are used for
the I<File:Print Packet> menu item.
=back =back
@ -623,6 +632,7 @@ B<http://ethereal.zing.org>.
Tomislav Vujec <tvujec@carnet.hr> Tomislav Vujec <tvujec@carnet.hr>
Kojak <kojak@bigwig.net> Kojak <kojak@bigwig.net>
Uwe Girlich <Uwe.Girlich@philosys.de> Uwe Girlich <Uwe.Girlich@philosys.de>
Warren Young <tangent@mail.com>
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to give his Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to give his
permission to use his version of snprintf.c. permission to use his version of snprintf.c.

View File

@ -1,6 +1,6 @@
/* main.c /* main.c
* *
* $Id: main.c,v 1.29 1999/10/29 01:04:44 guy Exp $ * $Id: main.c,v 1.30 1999/10/30 06:41:51 guy Exp $
* *
* Ethereal - Network traffic analyzer * Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org> * By Gerald Combs <gerald@zing.org>
@ -118,6 +118,7 @@ static gint tree_selected_start=-1, tree_selected_len=-1;
static void follow_destroy_cb(GtkWidget *win, gpointer data); static void follow_destroy_cb(GtkWidget *win, gpointer data);
static void follow_charset_toggle_cb(GtkWidget *w, gpointer parent_w); static void follow_charset_toggle_cb(GtkWidget *w, gpointer parent_w);
static void follow_load_text(GtkWidget *text, char *filename, gboolean show_ascii); static void follow_load_text(GtkWidget *text, char *filename, gboolean show_ascii);
static void follow_print_stream(GtkWidget *w, gpointer parent_w);
/* About Ethereal window */ /* About Ethereal window */
void void
@ -157,6 +158,7 @@ about_ethereal( GtkWidget *w, gpointer data ) {
"Tomislav Vujec <tvujec@carnet.hr>\n" "Tomislav Vujec <tvujec@carnet.hr>\n"
"Kojak <kojak@bigwig.net>\n" "Kojak <kojak@bigwig.net>\n"
"Uwe Girlich <Uwe.Girlich@philosys.de>\n" "Uwe Girlich <Uwe.Girlich@philosys.de>\n"
"Warren Young <tangent@mail.com>\n"
"\nSee http://ethereal.zing.org for more information", "\nSee http://ethereal.zing.org for more information",
VERSION, comp_info_str); VERSION, comp_info_str);
@ -169,7 +171,7 @@ void
follow_stream_cb( GtkWidget *w, gpointer data ) { follow_stream_cb( GtkWidget *w, gpointer data ) {
char filename1[128+1]; char filename1[128+1];
GtkWidget *streamwindow, *box, *text, *vscrollbar, *table; GtkWidget *streamwindow, *box, *text, *vscrollbar, *table;
GtkWidget *hbox, *close_bt, *button; GtkWidget *hbox, *close_bt, *print_bt, *button;
int tmp_fd; int tmp_fd;
gchar *follow_filter; gchar *follow_filter;
@ -282,6 +284,13 @@ follow_stream_cb( GtkWidget *w, gpointer data ) {
gtk_box_pack_end( GTK_BOX(hbox), close_bt, FALSE, FALSE, 0); gtk_box_pack_end( GTK_BOX(hbox), close_bt, FALSE, FALSE, 0);
gtk_widget_show( close_bt ); gtk_widget_show( close_bt );
/* Create Print Button */
print_bt = gtk_button_new_with_label("Print");
gtk_signal_connect(GTK_OBJECT(print_bt), "clicked",
GTK_SIGNAL_FUNC(follow_print_stream),
GTK_OBJECT(streamwindow));
gtk_box_pack_end( GTK_BOX(hbox), print_bt, FALSE, FALSE, 0);
gtk_widget_show( print_bt );
/* create the scrollbar */ /* create the scrollbar */
vscrollbar = gtk_vscrollbar_new( GTK_TEXT(text)->vadj ); vscrollbar = gtk_vscrollbar_new( GTK_TEXT(text)->vadj );
@ -350,6 +359,65 @@ follow_charset_toggle_cb(GtkWidget *w, gpointer parent_w)
follow_load_text(text, filename, show_ascii); follow_load_text(text, filename, show_ascii);
} }
static void follow_print_stream(GtkWidget *w, gpointer parent_w)
{
FILE *fh = NULL;
int to_file = -1;
char* print_dest = NULL;
char* filename;
switch (prefs.pr_dest) {
case PR_DEST_CMD:
print_dest = prefs.pr_cmd;
to_file = FALSE;
break;
case PR_DEST_FILE:
print_dest = prefs.pr_file;
to_file = TRUE;
break;
}
if (print_dest != NULL) {
fh = open_print_dest(to_file, print_dest);
}
if (fh == NULL) {
switch (to_file) {
case -1:
simple_dialog(ESD_TYPE_WARN, NULL,
"Couldn't figure out where to send the print "
"job. Check your preferences.");
break;
case FALSE:
simple_dialog(ESD_TYPE_WARN, NULL,
"Couldn't run print command %s.", prefs.pr_cmd);
break;
case TRUE:
simple_dialog(ESD_TYPE_WARN, NULL,
file_write_error_message(errno),
prefs.pr_file);
break;
}
return;
}
filename = (char*) gtk_object_get_data(GTK_OBJECT(parent_w),
E_FOLLOW_FILENAME_KEY);
if (filename != NULL) {
print_preamble(fh);
print_file(fh, filename);
print_finale(fh);
close_print_dest(to_file, fh);
}
else {
simple_dialog(ESD_TYPE_WARN, NULL, "Could not find data to print.");
}
}
static void static void
follow_load_text(GtkWidget *text, char *filename, gboolean show_ascii) follow_load_text(GtkWidget *text, char *filename, gboolean show_ascii)
{ {

40
print.c
View File

@ -1,7 +1,7 @@
/* print.c /* print.c
* Routines for printing packet analysis trees. * Routines for printing packet analysis trees.
* *
* $Id: print.c,v 1.21 1999/09/29 22:19:13 guy Exp $ * $Id: print.c,v 1.22 1999/10/30 06:41:36 guy Exp $
* *
* Gilbert Ramirez <gram@verdict.uthscsa.edu> * Gilbert Ramirez <gram@verdict.uthscsa.edu>
* *
@ -47,6 +47,8 @@ static void proto_tree_print_node_ps(GNode *node, gpointer data);
static void ps_clean_string(unsigned char *out, const unsigned char *in, static void ps_clean_string(unsigned char *out, const unsigned char *in,
int outbuf_size); int outbuf_size);
static void print_hex_data_ps(FILE *fh, register const u_char *cp, register u_int length); static void print_hex_data_ps(FILE *fh, register const u_char *cp, register u_int length);
static void print_ps_file(FILE* target_fh, FILE* source_fh);
static void print_text_file(FILE* target_fh, FILE* source_fh);
extern int proto_data; /* in packet-data.c */ extern int proto_data; /* in packet-data.c */
@ -93,6 +95,20 @@ void print_finale(FILE *fh)
print_ps_finale(fh); print_ps_finale(fh);
} }
void print_file(FILE* fh, const char* filename)
{
FILE* fh2 = fopen(filename, "r");
if (fh2 == NULL) {
fprintf(stderr, "Could not open file %s for reading.\n", filename);
return;
}
if (prefs.pr_format == PR_FMT_PS)
print_ps_file(fh, fh2);
else
print_text_file(fh, fh2);
}
void proto_tree_print(gboolean print_one_packet, print_args_t *print_args, void proto_tree_print(gboolean print_one_packet, print_args_t *print_args,
GNode *protocol_tree, const u_char *pd, frame_data *fd, FILE *fh) GNode *protocol_tree, const u_char *pd, frame_data *fd, FILE *fh)
{ {
@ -317,3 +333,25 @@ void print_hex_data_ps(FILE *fh, register const u_char *cp, register u_int lengt
return; return;
} }
static
void print_text_file(FILE* target_fh, FILE* source_fh)
{
gchar buffer[MAX_LINE_LENGTH];
while (fgets(buffer, sizeof(buffer), source_fh) != NULL) {
fputs(buffer, target_fh);
}
}
static
void print_ps_file(FILE* target_fh, FILE* source_fh)
{
gchar buffer[MAX_LINE_LENGTH];
gchar ps_buffer[MAX_LINE_LENGTH];
while (fgets(buffer, sizeof(buffer), source_fh) != NULL) {
ps_clean_string(ps_buffer, buffer, MAX_LINE_LENGTH);
fputs(ps_buffer, target_fh);
}
}

View File

@ -1,7 +1,7 @@
/* print.h /* print.h
* Definitions for printing packet analysis trees. * Definitions for printing packet analysis trees.
* *
* $Id: print.h,v 1.13 1999/09/29 22:19:13 guy Exp $ * $Id: print.h,v 1.14 1999/10/30 06:41:36 guy Exp $
* *
* Gilbert Ramirez <gram@verdict.uthscsa.edu> * Gilbert Ramirez <gram@verdict.uthscsa.edu>
* *
@ -46,6 +46,7 @@ FILE *open_print_dest(int to_file, const char *dest);
void close_print_dest(int to_file, FILE *fh); void close_print_dest(int to_file, FILE *fh);
void print_preamble(FILE *fh); void print_preamble(FILE *fh);
void print_finale(FILE *fh); void print_finale(FILE *fh);
void print_file(FILE* fh, const char* filename);
void proto_tree_print(gboolean print_one_packet, print_args_t *print_args, void proto_tree_print(gboolean print_one_packet, print_args_t *print_args,
GNode *protocol_tree, const u_char *pd, frame_data *fd, FILE *fh); GNode *protocol_tree, const u_char *pd, frame_data *fd, FILE *fh);
void print_hex_data(FILE *fh, register const u_char *cp, void print_hex_data(FILE *fh, register const u_char *cp,