diff options
author | Michael Mann <mmann78@netscape.net> | 2012-07-19 01:00:49 +0000 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2012-07-19 01:00:49 +0000 |
commit | 7184dac548a97c3ebc0ff41a617cbcfe3e58306b (patch) | |
tree | 7779bf726f712bf5e941a42c8c25e6b07e12ec39 /wiretap | |
parent | 757361f4d4befb4d8eb64d39a55ec740db7f6ee9 (diff) |
Addresses https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3895. Note that this doesn't write a Nokia file type properly, it just doesn't corrupt an existing one (read in by Wireshark) if resaved.
svn path=/trunk/; revision=43815
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/libpcap.c | 4 | ||||
-rw-r--r-- | wiretap/pcap-common.c | 47 | ||||
-rw-r--r-- | wiretap/wtap.h | 7 |
3 files changed, 57 insertions, 1 deletions
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index f659db6a50..08cf091ce2 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -1014,7 +1014,9 @@ static gboolean libpcap_dump(wtap_dumper *wdh, break; case WTAP_FILE_PCAP_NOKIA: /* old magic, extra crap at the end */ - rec_hdr.ifindex = 0; + /* restore the "mysterious stuff" that came with the packet */ + memcpy(&rec_hdr.ifindex, pseudo_header->nokia.stuff, 4); + /* not written */ rec_hdr.protocol = 0; rec_hdr.pkt_type = 0; rec_hdr.cpu1 = 0; diff --git a/wiretap/pcap-common.c b/wiretap/pcap-common.c index 204f609112..88ee1461b3 100644 --- a/wiretap/pcap-common.c +++ b/wiretap/pcap-common.c @@ -682,6 +682,11 @@ wtap_wtap_encap_to_pcap_encap(int encap) #define NOKIAATM_LEN 4 /* length of the header */ /* + * The link-layer header on Nokia IPSO packets. + */ +#define NOKIA_LEN 4 /* length of the header */ + +/* * The fake link-layer header of IrDA packets as introduced by Jean Tourrilhes * to libpcap. */ @@ -861,6 +866,39 @@ pcap_read_nokiaatm_pseudoheader(FILE_T fh, } static gboolean +pcap_read_nokia_pseudoheader(FILE_T fh, + union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info) +{ + guint8 phdr[NOKIA_LEN]; + int bytes_read; + + errno = WTAP_ERR_CANT_READ; + + /* backtrack to read the 4 mysterious bytes that aren't considered + * part of the packet size + */ + if (file_seek(fh, -NOKIA_LEN, SEEK_CUR, err) == -1) + { + *err = file_error(fh, err_info); + if (*err == 0) + *err = WTAP_ERR_SHORT_READ; + return FALSE; + } + + bytes_read = file_read(phdr, NOKIA_LEN, fh); + if (bytes_read != NOKIA_LEN) { + *err = file_error(fh, err_info); + if (*err == 0) + *err = WTAP_ERR_SHORT_READ; + return FALSE; + } + + memcpy(pseudo_header->nokia.stuff, phdr, NOKIA_LEN); + + return TRUE; +} + +static gboolean pcap_read_irda_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info) { @@ -1472,6 +1510,15 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap, break; case WTAP_ENCAP_ETHERNET: + if (file_type == WTAP_FILE_PCAP_NOKIA) { + /* + * Nokia IPSO. Psuedo header has already been read, but its not considered + * part of the packet size, so reread it to store the data for later (when saving) + */ + if (!pcap_read_nokia_pseudoheader(fh, pseudo_header, err, err_info)) + return -1; /* Read error */ + } + /* * We don't know whether there's an FCS in this frame or not. */ diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 70b974b274..74e7db254e 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -468,6 +468,12 @@ struct atm_phdr { guint32 aal5t_chksum; /* checksum for AAL5 packet */ }; +/* Packet "pseudo-header" for Nokia output */ +struct nokia_phdr { + struct eth_phdr eth; + guint8 stuff[4]; /* mysterious stuff */ +}; + /* Packet "pseudo-header" for the output from "wandsession", "wannext", "wandisplay", and similar commands on Lucent/Ascend access equipment. */ @@ -835,6 +841,7 @@ union wtap_pseudo_header { struct i2c_phdr i2c; struct gsm_um_phdr gsm_um; struct nstr_phdr nstr; + struct nokia_phdr nokia; struct llcp_phdr llcp; }; |