diff options
author | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2012-10-17 20:28:22 +0000 |
---|---|---|
committer | Jakub Zawadzki <darkjames-ws@darkjames.pl> | 2012-10-17 20:28:22 +0000 |
commit | 6b5045dd7b15c2b405e125bba24afae1410dcde2 (patch) | |
tree | 1abfe076c33148ad44fab0144357c8b36969d583 /wiretap/eyesdn.c | |
parent | 016a518728a09941d15b3cc930ea7a0cff969881 (diff) |
Fill some phdr values also when doing random read
svn path=/trunk/; revision=45619
Diffstat (limited to 'wiretap/eyesdn.c')
-rw-r--r-- | wiretap/eyesdn.c | 69 |
1 files changed, 25 insertions, 44 deletions
diff --git a/wiretap/eyesdn.c b/wiretap/eyesdn.c index 841a58d2f7..6f8c835f15 100644 --- a/wiretap/eyesdn.c +++ b/wiretap/eyesdn.c @@ -99,8 +99,8 @@ static gboolean eyesdn_seek_read(wtap *wth, gint64 seek_off, int *err, gchar **err_info); static gboolean parse_eyesdn_packet_data(FILE_T fh, int pkt_len, guint8* buf, int *err, gchar **err_info); -static int parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh, - union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info); +static int parse_eyesdn_rec_hdr(FILE_T fh, + struct wtap_pkthdr *phdr, int *err, gchar **err_info); /* Seeks to the beginning of the next packet, and returns the byte offset. Returns -1 on failure, and sets "*err" to the error @@ -172,8 +172,7 @@ static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info, return FALSE; /* Parse the header */ - pkt_len = parse_eyesdn_rec_hdr(wth, wth->fh, &wth->phdr.pseudo_header, err, - err_info); + pkt_len = parse_eyesdn_rec_hdr(wth->fh, &wth->phdr, err, err_info); if (pkt_len == -1) return FALSE; @@ -195,14 +194,12 @@ eyesdn_seek_read (wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, guint8 *pd, int len, int *err, gchar **err_info) { - union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; int pkt_len; if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - pkt_len = parse_eyesdn_rec_hdr(NULL, wth->random_fh, pseudo_header, - err, err_info); + pkt_len = parse_eyesdn_rec_hdr(wth->random_fh, phdr, err, err_info); if (pkt_len != len) { if (pkt_len != -1) { @@ -219,9 +216,10 @@ eyesdn_seek_read (wtap *wth, gint64 seek_off, /* Parses a packet record header. */ static int -parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh, - union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info) +parse_eyesdn_rec_hdr(FILE_T fh, struct wtap_pkthdr *phdr, + int *err, gchar **err_info) { + union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; guint8 hdr[EYESDN_HDR_LENGTH]; time_t secs; int usecs; @@ -262,28 +260,23 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh, pseudo_header->isdn.uton = direction & 1; pseudo_header->isdn.channel = channel; if(channel) { /* bearer channels */ - if(wth) { - wth->phdr.pkt_encap = WTAP_ENCAP_ISDN; /* recognises PPP */ + { + phdr->pkt_encap = WTAP_ENCAP_ISDN; /* recognises PPP */ pseudo_header->isdn.uton=!pseudo_header->isdn.uton; /* bug */ } + } else { /* D channel */ - if(wth) { - wth->phdr.pkt_encap = WTAP_ENCAP_ISDN; - } + phdr->pkt_encap = WTAP_ENCAP_ISDN; } break; case EYESDN_ENCAP_MSG: /* Layer 1 message */ - if(wth) { - wth->phdr.pkt_encap = WTAP_ENCAP_LAYER1_EVENT; - } + phdr->pkt_encap = WTAP_ENCAP_LAYER1_EVENT; pseudo_header->l1event.uton = (direction & 1); break; case EYESDN_ENCAP_LAPB: /* X.25 via LAPB */ - if(wth) { - wth->phdr.pkt_encap = WTAP_ENCAP_LAPB; - } + phdr->pkt_encap = WTAP_ENCAP_LAPB; pseudo_header->x25.flags = (direction & 1) ? 0 : 0x80; break; @@ -309,9 +302,7 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh, } if (file_seek(fh, cur_off, SEEK_SET, err) == -1) return -1; - if(wth) { - wth->phdr.pkt_encap = WTAP_ENCAP_ATM_PDUS_UNTRUNCATED; - } + phdr->pkt_encap = WTAP_ENCAP_ATM_PDUS_UNTRUNCATED; pseudo_header->atm.flags=ATM_RAW_CELL; pseudo_header->atm.aal=AAL_UNKNOWN; pseudo_header->atm.type=TRAF_UMTS_FP; @@ -326,41 +317,31 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh, pseudo_header->mtp2.sent = direction & 1; pseudo_header->mtp2.annex_a_used = MTP2_ANNEX_A_USED_UNKNOWN; pseudo_header->mtp2.link_number = channel; - if(wth) { - wth->phdr.pkt_encap = WTAP_ENCAP_MTP2_WITH_PHDR; - } + phdr->pkt_encap = WTAP_ENCAP_MTP2_WITH_PHDR; break; case EYESDN_ENCAP_DPNSS: /* DPNSS */ pseudo_header->isdn.uton = direction & 1; pseudo_header->isdn.channel = channel; - if(wth) { - wth->phdr.pkt_encap = WTAP_ENCAP_DPNSS; - } + phdr->pkt_encap = WTAP_ENCAP_DPNSS; break; case EYESDN_ENCAP_DASS2: /* DASS2 frames */ pseudo_header->isdn.uton = direction & 1; pseudo_header->isdn.channel = channel; - if(wth) { - wth->phdr.pkt_encap = WTAP_ENCAP_DPNSS; - } + phdr->pkt_encap = WTAP_ENCAP_DPNSS; break; case EYESDN_ENCAP_BACNET: /* BACNET async over HDLC frames */ pseudo_header->isdn.uton = direction & 1; pseudo_header->isdn.channel = channel; - if(wth) { - wth->phdr.pkt_encap = WTAP_ENCAP_BACNET_MS_TP_WITH_PHDR; - } + phdr->pkt_encap = WTAP_ENCAP_BACNET_MS_TP_WITH_PHDR; break; case EYESDN_ENCAP_V5_EF: /* V5EF */ pseudo_header->isdn.uton = direction & 1; pseudo_header->isdn.channel = channel; - if(wth) { - wth->phdr.pkt_encap = WTAP_ENCAP_V5_EF; - } + phdr->pkt_encap = WTAP_ENCAP_V5_EF; break; } @@ -371,12 +352,12 @@ parse_eyesdn_rec_hdr(wtap *wth, FILE_T fh, return -1; } - if (wth) { - wth->phdr.presence_flags = WTAP_HAS_TS; - wth->phdr.ts.secs = secs; - wth->phdr.ts.nsecs = usecs * 1000; - wth->phdr.caplen = pkt_len; - wth->phdr.len = pkt_len; + { + phdr->presence_flags = WTAP_HAS_TS; + phdr->ts.secs = secs; + phdr->ts.nsecs = usecs * 1000; + phdr->caplen = pkt_len; + phdr->len = pkt_len; } return pkt_len; |