2 * capture info functions
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0+
17 #include <epan/packet.h>
18 #include <wiretap/wtap.h>
20 #include "capture_info.h"
22 #include <epan/capture_dissectors.h>
25 capture_info_packet(info_data_t* cap_info, gint wtap_linktype, const guchar *pd, guint32 caplen, union wtap_pseudo_header *pseudo_header)
27 capture_packet_info_t cpinfo;
29 /* Setup the capture packet structure */
30 cpinfo.counts = cap_info->counts.counts_hash;
32 cap_info->counts.total++;
33 if (!try_capture_dissector("wtap_encap", wtap_linktype, pd, 0, caplen, &cpinfo, pseudo_header))
34 cap_info->counts.other++;
37 /* new packets arrived */
38 void capture_info_new_packets(int to_read, info_data_t* cap_info)
43 struct wtap_pkthdr *phdr;
44 union wtap_pseudo_header *pseudo_header;
49 cap_info->ui.new_packets = to_read;
51 /*g_warning("new packets: %u", to_read);*/
54 wtap_cleareof(cap_info->wtap);
55 if (wtap_read(cap_info->wtap, &err, &err_info, &data_offset)) {
56 phdr = wtap_phdr(cap_info->wtap);
57 pseudo_header = &phdr->pseudo_header;
58 wtap_linktype = phdr->pkt_encap;
59 buf = wtap_buf_ptr(cap_info->wtap);
61 capture_info_packet(cap_info, wtap_linktype, buf, phdr->caplen, pseudo_header);
63 /*g_warning("new packet");*/
68 capture_info_ui_update(&cap_info->ui);
73 void capture_info_close(info_data_t* cap_info)
75 capture_info_ui_destroy(&cap_info->ui);
77 wtap_close(cap_info->wtap);
80 #endif /* HAVE_LIBPCAP */
83 * Editor modelines - http://www.wireshark.org/tools/modelines.html
88 * indent-tabs-mode: nil
91 * vi: set shiftwidth=4 tabstop=8 expandtab:
92 * :indentSize=4:tabSize=8:noTabs=true: