From Pascal Quantin via bug 1723:

Make ASCII text dump identification optional.

svn path=/trunk/; revision=38886
This commit is contained in:
Stig Bjørlykke 2011-09-05 20:03:03 +00:00
parent bd82608737
commit c8a187390d
2 changed files with 65 additions and 43 deletions

View File

@ -19,6 +19,7 @@ S<[ B<-T> E<lt>srcportE<gt>,E<lt>destportE<gt> ]>
S<[ B<-s> E<lt>srcportE<gt>,E<lt>destportE<gt>,E<lt>tagE<gt> ]>
S<[ B<-S> E<lt>srcportE<gt>,E<lt>destportE<gt>,E<lt>ppiE<gt> ]>
S<[ B<-t> E<lt>timefmtE<gt> ]>
S<[ B<-a> ]>
E<lt>I<infile>E<gt>|-
E<lt>I<outfile>E<gt>|-
@ -197,6 +198,13 @@ a second.
B<NOTE:> Date/time fields from the current date/time are
used as the default for unspecified fields.
=item -a
Enables ASCII text dump identification. It allows to identify the start of
the ASCII text dump and not include it in the packet even if it looks like HEX.
B<NOTE:> Do not enable it if the input file does not contain the ASCII text dump.
=back
=head1 SEE ALSO

View File

@ -178,6 +178,8 @@ static unsigned short hdr_data_chunk_sid = 0;
static unsigned short hdr_data_chunk_ssn = 0;
static unsigned long hdr_data_chunk_ppid = 0;
/* ASCII text dump identification */
static int identify_ascii = FALSE;
/*--- Local date -----------------------------------------------------------------*/
@ -1063,6 +1065,7 @@ parse_token (token_t token, char *str)
by_eol = 1;
state = START_OF_LINE;
}
if (identify_ascii) {
/* Here a line of pkt bytes reading is finished
compare the ascii and hex to avoid such situation:
"61 62 20 ab ", when ab is ascii dump then it should
@ -1108,6 +1111,7 @@ parse_token (token_t token, char *str)
}
}
g_free(s2);
}
break;
default:
break;
@ -1168,6 +1172,12 @@ usage (void)
" number is assumed to be fractions of a second.\n"
" NOTE: Date/time fields from the current date/time are\n"
" used as the default for unspecified fields.\n"
" -a enable ASCII text dump identification.\n"
" It allows to identify the start of the ASCII text\n"
" dump and not include it in the packet even if it\n"
" looks like HEX dump.\n"
" NOTE: Do not enable it if the input file does not\n"
" contain the ASCII text dump.\n"
"\n"
"Output:\n"
" -l <typenum> link-layer type number; default is 1 (Ethernet).\n"
@ -1229,7 +1239,7 @@ parse_options (int argc, char *argv[])
#endif /* _WIN32 */
/* Scan CLI parameters */
while ((c = getopt(argc, argv, "Ddhqe:i:l:m:o:u:s:S:t:T:")) != -1) {
while ((c = getopt(argc, argv, "Ddhqe:i:l:m:o:u:s:S:t:T:a")) != -1) {
switch(c) {
case '?': usage(); break;
case 'h': usage(); break;
@ -1395,6 +1405,10 @@ parse_options (int argc, char *argv[])
hdr_ethernet_proto = 0x800;
break;
case 'a':
identify_ascii = TRUE;
break;
default:
usage();
}