Add "wtap_file_encap()", to return the encapsulation of packets in the
file (which could be WTAP_ENCAP_UNKNOWN, if we couldn't determine it, or WTAP_ENCAP_PER_PACKET, if we could determine the encapsulation of packets in the file, but they didn't all have the same encapsulation). This may be useful in the future, if we allow files to be saved in different capture file formats - we'd have to specify, when creating the capture file, the per-file encapsulation, for those formats that don't support per-packet encapsulations (we wouldn't be able to save a multi-encapsulation capture in those formats). Make the code to read "iptrace" files set the per-file packet encapsulation - set it to the type of the first packet seen, and, if any subsequent packets have a different encapsulation, set it to WTAP_ENCAP_PER_PACKET. svn path=/trunk/; revision=772
This commit is contained in:
parent
0161298edd
commit
0d43b16fdd
|
@ -1,6 +1,6 @@
|
|||
/* iptrace.c
|
||||
*
|
||||
* $Id: iptrace.c,v 1.13 1999/10/05 07:06:05 guy Exp $
|
||||
* $Id: iptrace.c,v 1.14 1999/10/06 03:29:36 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
|
||||
|
@ -132,5 +132,18 @@ static int iptrace_read(wtap *wth, int *err)
|
|||
*err = WTAP_ERR_BAD_RECORD;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* If the per-file encapsulation isn't known, set it to this
|
||||
packet's encapsulation.
|
||||
|
||||
If it *is* known, and it isn't this packet's encapsulation,
|
||||
set it to WTAP_ENCAP_PER_PACKET, as this file doesn't
|
||||
have a single encapsulation for all packets in the file. */
|
||||
if (wth->file_encap == WTAP_ENCAP_UNKNOWN)
|
||||
wth->file_encap = wth->phdr.pkt_encap;
|
||||
else {
|
||||
if (wth->file_encap != wth->phdr.pkt_encap)
|
||||
wth->file_encap= WTAP_ENCAP_PER_PACKET;
|
||||
}
|
||||
return data_offset;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* wtap.c
|
||||
*
|
||||
* $Id: wtap.c,v 1.24 1999/10/05 07:22:53 guy Exp $
|
||||
* $Id: wtap.c,v 1.25 1999/10/06 03:29:35 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
|
||||
|
@ -51,6 +51,11 @@ int wtap_snapshot_length(wtap *wth)
|
|||
return wth->snapshot_length;
|
||||
}
|
||||
|
||||
int wtap_file_encap(wtap *wth)
|
||||
{
|
||||
return wth->file_encap;
|
||||
}
|
||||
|
||||
const char *wtap_file_type_string(wtap *wth)
|
||||
{
|
||||
switch (wth->file_type) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* wtap.h
|
||||
*
|
||||
* $Id: wtap.h,v 1.42 1999/10/05 07:06:08 guy Exp $
|
||||
* $Id: wtap.h,v 1.43 1999/10/06 03:29:36 guy Exp $
|
||||
*
|
||||
* Wiretap Library
|
||||
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
|
||||
|
@ -31,6 +31,8 @@
|
|||
* "wtap_dump_fd_open()" to indicate that there is no single encapsulation
|
||||
* type for all packets in the file; this may cause those routines to
|
||||
* fail if the capture file format being written can't support that.
|
||||
* It's also returned by "wtap_file_encap()" for capture files that
|
||||
* don't have a single encapsulation type for all packets in the file.
|
||||
*
|
||||
* WTAP_ENCAP_UNKNOWN is returned by "wtap_pcap_encap_to_wtap_encap()"
|
||||
* if it's handed an unknown encapsulation.
|
||||
|
@ -345,6 +347,7 @@ FILE* wtap_file(wtap *wth);
|
|||
int wtap_fd(wtap *wth);
|
||||
int wtap_snapshot_length(wtap *wth); /* per file */
|
||||
int wtap_file_type(wtap *wth);
|
||||
int wtap_file_encap(wtap *wth);
|
||||
const char *wtap_file_type_string(wtap *wth);
|
||||
const char *wtap_strerror(int err);
|
||||
void wtap_close(wtap *wth);
|
||||
|
|
Loading…
Reference in New Issue