summaryrefslogtreecommitdiff
path: root/wiretap/pcap-common.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2012-07-19 01:00:49 +0000
committerMichael Mann <mmann78@netscape.net>2012-07-19 01:00:49 +0000
commit7184dac548a97c3ebc0ff41a617cbcfe3e58306b (patch)
tree7779bf726f712bf5e941a42c8c25e6b07e12ec39 /wiretap/pcap-common.c
parent757361f4d4befb4d8eb64d39a55ec740db7f6ee9 (diff)
downloadwireshark-7184dac548a97c3ebc0ff41a617cbcfe3e58306b.tar.gz
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/pcap-common.c')
-rw-r--r--wiretap/pcap-common.c47
1 files changed, 47 insertions, 0 deletions
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.
*/