Merge pcap_fill_in_pseudo_header() into pcap_read_post_process().
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 1 Sep 2011 19:58:25 +0000 (19:58 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 1 Sep 2011 19:58:25 +0000 (19:58 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@38844 f5534014-38df-0310-8fa8-9805f1628bb7

wiretap/libpcap.c
wiretap/pcap-common.c
wiretap/pcap-common.h
wiretap/pcapng.c

index 424f4324c17d5067a90e4a3842cdefbfc5e5a4e3..c8e5cb7d7409775c5d2d97f6d094437b8600a078 100644 (file)
@@ -673,12 +673,9 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
        wth->phdr.caplen = packet_size;
        wth->phdr.len = orig_size;
 
-       pcap_fill_in_pseudo_header(wth->file_type, wth->file_encap,
-           buffer_start_ptr(wth->frame_buffer), wth->phdr.caplen,
-           &wth->pseudo_header, -1);
-
-       pcap_read_post_process(wth->file_encap, wth->phdr.caplen,
-           libpcap->byte_swapped, buffer_start_ptr(wth->frame_buffer));
+       pcap_read_post_process(wth->file_type, wth->file_encap,
+           &wth->pseudo_header, buffer_start_ptr(wth->frame_buffer),
+           wth->phdr.caplen, libpcap->byte_swapped, -1);
        return TRUE;
 }
 
@@ -705,11 +702,8 @@ libpcap_seek_read(wtap *wth, gint64 seek_off,
        if (!libpcap_read_rec_data(wth->random_fh, pd, length, err, err_info))
                return FALSE;   /* failed */
 
-       pcap_fill_in_pseudo_header(wth->file_type, wth->file_encap, pd,
-           length, pseudo_header, -1);
-
-       pcap_read_post_process(wth->file_encap, length,
-           libpcap->byte_swapped, pd);
+       pcap_read_post_process(wth->file_type, wth->file_encap,
+           pseudo_header, pd, length, libpcap->byte_swapped, -1);
        return TRUE;
 }
 
index c9b9ba27dc139011f0c3d457d55681092171ebb6..899ad9a111503685a9fc6ab0c5415da27d37b587 100644 (file)
@@ -1623,8 +1623,9 @@ pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap,
 }
 
 void
-pcap_fill_in_pseudo_header(int file_type, int wtap_encap, guint8 *pd, int length,
-    union wtap_pseudo_header *pseudo_header, int fcs_len)
+pcap_read_post_process(int file_type, int wtap_encap,
+    union wtap_pseudo_header *pseudo_header,
+    guint8 *pd, guint packet_size, gboolean bytes_swapped, int fcs_len)
 {
        switch (wtap_encap) {
 
@@ -1636,7 +1637,7 @@ pcap_fill_in_pseudo_header(int file_type, int wtap_encap, guint8 *pd, int length
                         * Guess the traffic type based on the packet
                         * contents.
                         */
-                       atm_guess_traffic_type(pd, length, pseudo_header);
+                       atm_guess_traffic_type(pd, packet_size, pseudo_header);
                } else {
                        /*
                         * SunATM.
@@ -1646,7 +1647,8 @@ pcap_fill_in_pseudo_header(int file_type, int wtap_encap, guint8 *pd, int length
                         * contents.
                         */
                        if (pseudo_header->atm.type == TRAF_LANE)
-                               atm_guess_lane_type(pd, length, pseudo_header);
+                               atm_guess_lane_type(pd, packet_size,
+                                   pseudo_header);
                }
                break;
 
@@ -1654,17 +1656,6 @@ pcap_fill_in_pseudo_header(int file_type, int wtap_encap, guint8 *pd, int length
                pseudo_header->eth.fcs_len = fcs_len;
                break;
 
-       default:
-               break;
-       }
-}
-
-void
-pcap_read_post_process(int wtap_encap, guint packet_size,
-    gboolean bytes_swapped, guint8 *pd)
-{
-       switch (wtap_encap) {
-
        case WTAP_ENCAP_USB_LINUX:
                pcap_process_linux_usb_pseudoheader(packet_size,
                    bytes_swapped, FALSE, pd);
index 587fdfb8379952c0ca6f54f51a049e3d3f6d759c..2b4d7cad88a164e4c09e9a6aeff347994e2f0779 100644 (file)
@@ -34,12 +34,9 @@ extern int pcap_process_pseudo_header(FILE_T fh, int file_type, int wtap_encap,
     guint packet_size, gboolean check_packet_size, struct wtap_pkthdr *phdr,
     union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
 
-extern void pcap_fill_in_pseudo_header(int file_type, int wtap_encap,
-    guint8 *pd, int length, union wtap_pseudo_header *pseudo_header,
-    int fcs_len);
-
-extern void pcap_read_post_process(int wtap_encap, guint packet_size,
-       gboolean bytes_swapped, guint8 *pd);
+extern void pcap_read_post_process(int file_type, int wtap_encap,
+    union wtap_pseudo_header *pseudo_header,
+    guint8 *pd, guint packet_size, gboolean bytes_swapped, int fcs_len);
 
 extern int pcap_get_phdr_size(int encap,
     const union wtap_pseudo_header *pseudo_header);
index c7aec3035fde7c755958a37a3863fb5471f22df9..c1b4efe0d22c2b3104fc6ef401c9d0b5d5233220 100644 (file)
@@ -981,14 +981,11 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
                }
        }
 
-       pcap_fill_in_pseudo_header(WTAP_FILE_PCAPNG, wtap_encap,
+       pcap_read_post_process(WTAP_FILE_PCAPNG, wtap_encap,
+           (union wtap_pseudo_header *)wblock->pseudo_header,
            (guint8 *) (wblock->frame_buffer),
            (int) (wblock->data.packet.cap_len - pseudo_header_len),
-           (union wtap_pseudo_header *)wblock->pseudo_header, fcslen);
-
-       pcap_read_post_process(wtap_encap,
-           (int) (wblock->data.packet.cap_len - pseudo_header_len),
-           pn->byte_swapped, (guint8 *) (wblock->frame_buffer));
+           pn->byte_swapped, fcslen);
        return block_read;
 }
 
@@ -1089,14 +1086,11 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *
                block_read += 4 - (wblock->data.simple_packet.cap_len % 4);
        }
 
-       pcap_fill_in_pseudo_header(WTAP_FILE_PCAPNG, encap,
+       pcap_read_post_process(WTAP_FILE_PCAPNG, encap,
+           (union wtap_pseudo_header *)wblock->pseudo_header,
            (guint8 *) (wblock->frame_buffer),
            (int) wblock->data.simple_packet.cap_len,
-           (union wtap_pseudo_header *)wblock->pseudo_header,
-           pn->if_fcslen);
-
-       pcap_read_post_process(encap, (int) wblock->data.simple_packet.cap_len,
-           pn->byte_swapped, (guint8 *) (wblock->frame_buffer));
+           pn->byte_swapped, pn->if_fcslen);
        return block_read;
 }