deal with the timeval -> bpf_timeval change

testing by pvalchev@, wilfried@
This commit is contained in:
naddy 2001-10-18 15:12:40 +00:00
parent 49357e0481
commit ba77515b9f
3 changed files with 216 additions and 0 deletions

View File

@ -0,0 +1,80 @@
$OpenBSD: patch-search_c,v 1.1 2001/10/18 15:12:40 naddy Exp $
--- search.c.orig Fri Oct 12 18:21:37 2001
+++ search.c Fri Oct 12 18:22:45 2001
@@ -279,8 +279,8 @@ find_header( pcap_t *p, u_char *buf, int
* present in the dump file.
*/
int
-sf_find_end( pcap_t *p, struct timeval *first_timestamp,
- struct timeval *last_timestamp )
+sf_find_end( pcap_t *p, struct bpf_timeval *first_timestamp,
+ struct bpf_timeval *last_timestamp )
{
u_int32_t first_time = first_timestamp->tv_sec;
int num_bytes;
@@ -373,7 +373,7 @@ sf_find_end( pcap_t *p, struct timeval *
/* Takes two timeval's and returns the difference, tv2 - tv1, as a double. */
static double
-timeval_diff( struct timeval *tv1, struct timeval *tv2 )
+timeval_diff( struct bpf_timeval *tv1, struct bpf_timeval *tv2 )
{
double result = (tv2->tv_sec - tv1->tv_sec);
result += (tv2->tv_usec - tv1->tv_usec) / 1000000.0;
@@ -385,7 +385,7 @@ timeval_diff( struct timeval *tv1, struc
/* Returns true if timestamp t1 is chronologically less than timestamp t2. */
int
-sf_timestamp_less_than( struct timeval *t1, struct timeval *t2 )
+sf_timestamp_less_than( struct bpf_timeval *t1, struct bpf_timeval *t2 )
{
return t1->tv_sec < t2->tv_sec ||
(t1->tv_sec == t2->tv_sec &&
@@ -399,9 +399,9 @@ sf_timestamp_less_than( struct timeval *
*/
static off_t
-interpolated_position( struct timeval *min_time, off_t min_pos,
- struct timeval *max_time, off_t max_pos,
- struct timeval *desired_time )
+interpolated_position( struct bpf_timeval *min_time, off_t min_pos,
+ struct bpf_timeval *max_time, off_t max_pos,
+ struct bpf_timeval *desired_time )
{
double full_span = timeval_diff( max_time, min_time );
double desired_span = timeval_diff( desired_time, min_time );
@@ -422,7 +422,7 @@ interpolated_position( struct timeval *m
*/
static int
-read_up_to( pcap_t *p, struct timeval *desired_time )
+read_up_to( pcap_t *p, struct bpf_timeval *desired_time )
{
struct pcap_pkthdr hdr;
const u_char *buf;
@@ -431,7 +431,7 @@ read_up_to( pcap_t *p, struct timeval *d
for ( ; ; )
{
- struct timeval *timestamp;
+ struct bpf_timeval *timestamp;
pos = ftell( pcap_file( p ) );
buf = pcap_next( p, &hdr );
@@ -480,12 +480,12 @@ read_up_to( pcap_t *p, struct timeval *d
int
sf_find_packet( pcap_t *p,
- struct timeval *min_time, off_t min_pos,
- struct timeval *max_time, off_t max_pos,
- struct timeval *desired_time )
+ struct bpf_timeval *min_time, off_t min_pos,
+ struct bpf_timeval *max_time, off_t max_pos,
+ struct bpf_timeval *desired_time )
{
int status = 1;
- struct timeval min_time_copy, max_time_copy;
+ struct bpf_timeval min_time_copy, max_time_copy;
u_int num_bytes = MAX_BYTES_FOR_DEFINITE_HEADER;
int num_bytes_read;
off_t desired_pos, present_pos;

View File

@ -0,0 +1,114 @@
$OpenBSD: patch-tcpslice_c,v 1.1 2001/10/18 15:12:40 naddy Exp $
--- tcpslice.c.orig Fri Oct 12 18:24:23 2001
+++ tcpslice.c Fri Oct 12 18:28:45 2001
@@ -71,14 +71,14 @@ enum stamp_styles timestamp_style = TIME
int is_timestamp( char *str );
-struct timeval parse_time(char *time_string, struct timeval base_time);
+struct bpf_timeval parse_time(char *time_string, struct bpf_timeval base_time);
void fill_tm(char *time_string, int is_delta, struct tm *t, time_t *usecs_addr);
void get_file_range( char filename[], pcap_t **p,
- struct timeval *first_time, struct timeval *last_time );
-struct timeval first_packet_time(char filename[], pcap_t **p_addr);
+ struct bpf_timeval *first_time, struct bpf_timeval *last_time );
+struct bpf_timeval first_packet_time(char filename[], pcap_t **p_addr);
void extract_slice(char filename[], char write_file_name[],
- struct timeval *start_time, struct timeval *stop_time);
-char *timestamp_to_string(struct timeval *timestamp);
+ struct bpf_timeval *start_time, struct bpf_timeval *stop_time);
+char *timestamp_to_string(struct bpf_timeval *timestamp);
void dump_times(pcap_t **p, char filename[]);
__dead void usage(void)__attribute__((volatile));
@@ -98,7 +98,7 @@ main(int argc, char **argv)
char *start_time_string = 0;
char *stop_time_string = 0;
char *write_file_name = "-"; /* default is stdout */
- struct timeval first_time, start_time, stop_time;
+ struct bpf_timeval first_time, start_time, stop_time;
pcap_t *pcap;
char ebuf[PCAP_ERRBUF_SIZE];
@@ -223,15 +223,19 @@ int is_timestamp( char *str )
* containing the specified time.
*/
-struct timeval
-parse_time(char *time_string, struct timeval base_time)
+struct bpf_timeval
+parse_time(char *time_string, struct bpf_timeval base_time)
{
- struct tm *bt = localtime((time_t *) &base_time.tv_sec);
+ struct tm *bt;
struct tm t;
- struct timeval result;
+ struct bpf_timeval result;
+ time_t secs;
time_t usecs = 0;
int is_delta = (time_string[0] == '+');
+ secs = base_time.tv_sec;
+ bt = localtime(&secs);
+
if ( is_delta )
++time_string; /* skip over '+' sign */
@@ -412,7 +416,7 @@ fill_tm(char *time_string, int is_delta,
*/
void
get_file_range( char filename[], pcap_t **p,
- struct timeval *first_time, struct timeval *last_time )
+ struct bpf_timeval *first_time, struct bpf_timeval *last_time )
{
*first_time = first_packet_time( filename, p );
@@ -427,7 +431,7 @@ int snaplen;
* reading.
*/
-struct timeval
+struct bpf_timeval
first_packet_time(char filename[], pcap_t **p_addr)
{
struct pcap_pkthdr hdr;
@@ -457,10 +461,10 @@ first_packet_time(char filename[], pcap_
void
extract_slice(char filename[], char write_file_name[],
- struct timeval *start_time, struct timeval *stop_time)
+ struct bpf_timeval *start_time, struct bpf_timeval *stop_time)
{
off_t start_pos, stop_pos;
- struct timeval file_start_time, file_stop_time;
+ struct bpf_timeval file_start_time, file_stop_time;
struct pcap_pkthdr hdr;
pcap_t *p;
char errbuf[PCAP_ERRBUF_SIZE];
@@ -511,7 +515,7 @@ extract_slice(char filename[], char writ
for ( ; ; )
{
- struct timeval *timestamp;
+ struct bpf_timeval *timestamp;
const u_char *pkt = pcap_next( p, &hdr );
if ( pkt == 0 )
@@ -554,7 +558,7 @@ extract_slice(char filename[], char writ
*/
char *
-timestamp_to_string(struct timeval *timestamp)
+timestamp_to_string(struct bpf_timeval *timestamp)
{
struct tm *t;
#define NUM_BUFFERS 2
@@ -599,7 +603,7 @@ timestamp_to_string(struct timeval *time
void
dump_times(pcap_t **p, char filename[])
{
- struct timeval first_time, last_time;
+ struct bpf_timeval first_time, last_time;
get_file_range( filename, p, &first_time, &last_time );

View File

@ -0,0 +1,22 @@
$OpenBSD: patch-tcpslice_h,v 1.1 2001/10/18 15:12:40 naddy Exp $
--- tcpslice.h.orig Fri Oct 12 18:23:11 2001
+++ tcpslice.h Fri Oct 12 18:24:17 2001
@@ -22,12 +22,12 @@
time_t gwtm2secs( struct tm *tm );
-int sf_find_end( struct pcap *p, struct timeval *first_timestamp,
- struct timeval *last_timestamp );
-int sf_timestamp_less_than( struct timeval *t1, struct timeval *t2 );
+int sf_find_end( struct pcap *p, struct bpf_timeval *first_timestamp,
+ struct bpf_timeval *last_timestamp );
+int sf_timestamp_less_than( struct bpf_timeval *t1, struct bpf_timeval *t2 );
int sf_find_packet( struct pcap *p,
- struct timeval *min_time, off_t min_pos,
- struct timeval *max_time, off_t max_pos,
- struct timeval *desired_time );
+ struct bpf_timeval *min_time, off_t min_pos,
+ struct bpf_timeval *max_time, off_t max_pos,
+ struct bpf_timeval *desired_time );
void error(const char *fmt, ...);