MFC: Fix our ancient tcpslice for >2GB limits [1].
Also, mention that tcpslice in the base system is being deprecated, and encourage users to install it from the ports collection. PR: bin/13691 Submitted by: Bruce A. Mah Approved by: re (bmah)
This commit is contained in:
parent
b87630abda
commit
f0a2a5b62f
@ -52,6 +52,13 @@ time_t gwtm2secs( struct tm *tm )
|
||||
else
|
||||
year += 2000;
|
||||
|
||||
/* Make sure our year is still >= 1970. We fix 3-digit years
|
||||
* this way, because localtime(3) can return tm_year >= 100,
|
||||
* starting in year 2000.
|
||||
*/
|
||||
if ( year < 1970 )
|
||||
year += 1900;
|
||||
|
||||
days = 0;
|
||||
for ( i = 1970; i < year; ++i )
|
||||
{
|
||||
|
@ -281,7 +281,7 @@ sf_find_end( pcap_t *p, struct timeval *first_timestamp,
|
||||
* end of the file.
|
||||
*/
|
||||
num_bytes = MAX_BYTES_FOR_DEFINITE_HEADER;
|
||||
if ( fseek( pcap_file( p ), (long) -num_bytes, 2 ) < 0 )
|
||||
if ( fseeko( pcap_file( p ), (off_t)-num_bytes, 2 ) < 0 )
|
||||
return 0;
|
||||
|
||||
buf = (u_char *)malloc((u_int) num_bytes);
|
||||
@ -346,8 +346,8 @@ sf_find_end( pcap_t *p, struct timeval *first_timestamp,
|
||||
status = 1;
|
||||
|
||||
/* Seek so that the next read will start at last valid packet. */
|
||||
if ( fseek( pcap_file( p ), (long) -(bufend - hdrpos), 2 ) < 0 )
|
||||
error( "final fseek() failed in sf_find_end()" );
|
||||
if ( fseeko( pcap_file( p ), (off_t) -(bufend - hdrpos), 2 ) < 0 )
|
||||
error( "final fseeko() failed in sf_find_end()" );
|
||||
|
||||
done:
|
||||
free( (char *) buf );
|
||||
@ -412,14 +412,14 @@ read_up_to( pcap_t *p, struct timeval *desired_time )
|
||||
{
|
||||
struct pcap_pkthdr hdr;
|
||||
const u_char *buf;
|
||||
long pos;
|
||||
fpos_t pos;
|
||||
int status;
|
||||
|
||||
for ( ; ; )
|
||||
{
|
||||
struct timeval *timestamp;
|
||||
|
||||
pos = ftell( pcap_file( p ) );
|
||||
fgetpos( pcap_file( p ), &pos );
|
||||
buf = pcap_next( p, &hdr );
|
||||
|
||||
if ( buf == 0 )
|
||||
@ -443,8 +443,8 @@ read_up_to( pcap_t *p, struct timeval *desired_time )
|
||||
}
|
||||
}
|
||||
|
||||
if ( fseek( pcap_file( p ), pos, 0 ) < 0 )
|
||||
error( "fseek() failed in read_up_to()" );
|
||||
if ( fsetpos( pcap_file( p ), &pos ) < 0 )
|
||||
error( "fsetpos() failed in read_up_to()" );
|
||||
|
||||
return (status);
|
||||
}
|
||||
@ -474,7 +474,7 @@ sf_find_packet( pcap_t *p,
|
||||
struct timeval min_time_copy, max_time_copy;
|
||||
u_int num_bytes = MAX_BYTES_FOR_DEFINITE_HEADER;
|
||||
int num_bytes_read;
|
||||
long desired_pos, present_pos;
|
||||
fpos_t desired_pos, present_pos;
|
||||
u_char *buf, *hdrpos;
|
||||
struct pcap_pkthdr hdr;
|
||||
|
||||
@ -501,7 +501,7 @@ sf_find_packet( pcap_t *p,
|
||||
break;
|
||||
}
|
||||
|
||||
present_pos = ftell( pcap_file( p ) );
|
||||
fgetpos( pcap_file( p ), &present_pos );
|
||||
|
||||
if ( present_pos <= desired_pos &&
|
||||
desired_pos - present_pos < STRAIGHT_SCAN_THRESHOLD )
|
||||
@ -517,8 +517,8 @@ sf_find_packet( pcap_t *p,
|
||||
if ( desired_pos < min_pos )
|
||||
desired_pos = min_pos;
|
||||
|
||||
if ( fseek( pcap_file( p ), desired_pos, 0 ) < 0 )
|
||||
error( "fseek() failed in sf_find_packet()" );
|
||||
if ( fsetpos( pcap_file( p ), &desired_pos ) < 0 )
|
||||
error( "fsetpos() failed in sf_find_packet()" );
|
||||
|
||||
num_bytes_read =
|
||||
fread( (char *) buf, 1, num_bytes, pcap_file( p ) );
|
||||
@ -540,8 +540,8 @@ sf_find_packet( pcap_t *p,
|
||||
desired_pos += (hdrpos - buf);
|
||||
|
||||
/* Seek to the beginning of the header. */
|
||||
if ( fseek( pcap_file( p ), desired_pos, 0 ) < 0 )
|
||||
error( "fseek() failed in sf_find_packet()" );
|
||||
if ( fsetpos( pcap_file( p ), &desired_pos ) < 0 )
|
||||
error( "fsetpos() failed in sf_find_packet()" );
|
||||
|
||||
if ( sf_timestamp_less_than( &hdr.ts, desired_time ) )
|
||||
{ /* too early in the file */
|
||||
|
@ -19,7 +19,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd October 14, 1991
|
||||
.Dd October 17, 2006
|
||||
.Dt TCPSLICE 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -239,6 +239,15 @@ Direct the output to
|
||||
rather than
|
||||
.Pa stdout .
|
||||
.El
|
||||
.Sh COMPATIBILITY
|
||||
.Pp
|
||||
This version of the
|
||||
.Nm
|
||||
utility is deprecated and will be removed from the base system in
|
||||
.Fx 7.0 .
|
||||
A more recent (and maintained) version can be found in the
|
||||
.Fx
|
||||
Ports Collection.
|
||||
.Sh SEE ALSO
|
||||
.Xr tcpdump 1
|
||||
.Sh AUTHORS
|
||||
|
@ -453,7 +453,7 @@ void
|
||||
extract_slice(char filename[], char write_file_name[],
|
||||
struct timeval *start_time, struct timeval *stop_time)
|
||||
{
|
||||
long start_pos, stop_pos;
|
||||
off_t start_pos, stop_pos;
|
||||
struct timeval file_start_time, file_stop_time;
|
||||
struct pcap_pkthdr hdr;
|
||||
pcap_t *p;
|
||||
@ -464,7 +464,7 @@ extract_slice(char filename[], char write_file_name[],
|
||||
error( "bad tcpdump file %s: %s", filename, errbuf );
|
||||
|
||||
snaplen = pcap_snapshot( p );
|
||||
start_pos = ftell( pcap_file( p ) );
|
||||
fgetpos( pcap_file( p ), &start_pos );
|
||||
|
||||
if ( ! dumper )
|
||||
{
|
||||
@ -485,7 +485,7 @@ extract_slice(char filename[], char write_file_name[],
|
||||
error( "problems finding end packet of file %s",
|
||||
filename );
|
||||
|
||||
stop_pos = ftell( pcap_file( p ) );
|
||||
fgetpos( pcap_file( p ), &stop_pos );
|
||||
|
||||
|
||||
/* sf_find_packet() requires that the time it's passed as its last
|
||||
|
Loading…
x
Reference in New Issue
Block a user