diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c index ab2b05139d..e87f74c6db 100644 --- a/wiretap/iptrace.c +++ b/wiretap/iptrace.c @@ -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 @@ -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; } diff --git a/wiretap/wtap.c b/wiretap/wtap.c index 959878ed35..bc293567af 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -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 @@ -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) { diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 22e76a611c..5ca5d8edfb 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -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 @@ -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);