From 6db77b000fe58173eeed23b91b32c92c681feda2 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 24 May 2014 11:28:30 -0700 Subject: [PATCH] Allow wtap_read() and wtap_seek_read() to return records other than packets. Add a "record type" field to "struct wtap_pkthdr"; currently, it can be REC_TYPE_PACKET, for a record containing a packet, or REC_TYPE_FILE_TYPE_SPECIFIC, for records containing file-type-specific data. Modify code that reads packets to be able to handle non-packet records, even if that just means ignoring them. Rename some routines to indicate that they handle more than just packets. We don't yet have any libwiretap code that supplies records other than REC_TYPE_PACKET or that supporting writing records other than REC_TYPE_PACKET, or any code to support plugins for handling REC_TYPE_FILE_TYPE_SPECIFIC records; this is just the first step for bug 8590. Change-Id: Idb40b78f17c2c3aea72031bcd252abf9bc11c813 Reviewed-on: https://code.wireshark.org/review/1773 Reviewed-by: Guy Harris --- capinfos.c | 38 +++++++++++---------- editcap.c | 4 +++ epan/epan.c | 4 +-- epan/packet.c | 6 +++- epan/packet.h | 4 +-- epan/wslua/make-init-lua.pl | 10 ++++++ epan/wslua/template-init.lua | 3 ++ epan/wslua/wslua_dumper.c | 5 +++ epan/wslua/wslua_file.c | 19 ++++++++--- file.c | 63 ++++++++++++++++++----------------- file.h | 28 ++++++++-------- proto_hier_stats.c | 20 +++++------ randpkt.c | 1 + test/lua/acme_file.lua | 1 + test/lua/pcap_file.lua | 6 ++-- ui/gtk/capture_file_dlg.c | 6 ++-- ui/gtk/iax2_analysis.c | 12 +++---- ui/gtk/main.c | 6 ++-- ui/gtk/packet_list_store.c | 6 ++-- ui/gtk/packet_win.c | 6 ++-- ui/gtk/rlc_lte_graph.c | 6 ++-- ui/gtk/rtp_analysis.c | 12 +++---- ui/gtk/sctp_assoc_analyse.c | 14 ++++---- ui/qt/main_window.cpp | 6 ++-- ui/qt/packet_list.cpp | 4 +-- ui/qt/packet_list_model.cpp | 6 ++-- ui/tap-tcp-stream.c | 6 ++-- ui/tap_export_pdu.c | 1 + ui/text_import.c | 1 + wiretap/5views.c | 7 ++++ wiretap/aethra.c | 1 + wiretap/ber.c | 1 + wiretap/btsnoop.c | 13 ++++++++ wiretap/camins.c | 1 + wiretap/catapult_dct2000.c | 7 ++++ wiretap/commview.c | 7 ++++ wiretap/cosine.c | 1 + wiretap/csids.c | 1 + wiretap/daintree-sna.c | 1 + wiretap/dbs-etherwatch.c | 1 + wiretap/dct3trace.c | 1 + wiretap/erf.c | 7 ++++ wiretap/eyesdn.c | 7 ++++ wiretap/hcidump.c | 1 + wiretap/i4btrace.c | 1 + wiretap/ipfix.c | 1 + wiretap/iptrace.c | 2 ++ wiretap/iseries.c | 1 + wiretap/k12.c | 7 ++++ wiretap/k12text.l | 1 + wiretap/lanalyzer.c | 9 ++++- wiretap/libpcap.c | 7 ++++ wiretap/logcat.c | 13 ++++++++ wiretap/mime_file.c | 1 + wiretap/mp2t.c | 2 ++ wiretap/mpeg.c | 2 ++ wiretap/netmon.c | 8 +++++ wiretap/netscaler.c | 16 ++++++++- wiretap/netscreen.c | 1 + wiretap/nettl.c | 9 ++++- wiretap/network_instruments.c | 7 ++++ wiretap/netxray.c | 13 ++++++++ wiretap/ngsniffer.c | 7 ++++ wiretap/packetlogger.c | 1 + wiretap/pcapng.c | 8 +++++ wiretap/peekclassic.c | 2 ++ wiretap/peektagged.c | 1 + wiretap/pppdump.c | 3 +- wiretap/radcom.c | 1 + wiretap/snoop.c | 7 ++++ wiretap/stanag4607.c | 2 ++ wiretap/tnef.c | 1 + wiretap/toshiba.c | 1 + wiretap/visual.c | 7 ++++ wiretap/vms.c | 1 + wiretap/vwr.c | 3 ++ wiretap/wtap.c | 4 ++- wiretap/wtap.h | 16 +++++++++ 78 files changed, 389 insertions(+), 138 deletions(-) diff --git a/capinfos.c b/capinfos.c index bad557e2dd..811f5af8bd 100644 --- a/capinfos.c +++ b/capinfos.c @@ -853,26 +853,28 @@ process_cap_file(wtap *wth, const char *filename) order = ORDER_UNKNOWN; } - bytes+=phdr->len; - packet++; + if (phdr->rec_type == REC_TYPE_PACKET) { + bytes+=phdr->len; + packet++; - /* If caplen < len for a rcd, then presumably */ - /* 'Limit packet capture length' was done for this rcd. */ - /* Keep track as to the min/max actual snapshot lengths */ - /* seen for this file. */ - if (phdr->caplen < phdr->len) { - if (phdr->caplen < snaplen_min_inferred) - snaplen_min_inferred = phdr->caplen; - if (phdr->caplen > snaplen_max_inferred) - snaplen_max_inferred = phdr->caplen; - } + /* If caplen < len for a rcd, then presumably */ + /* 'Limit packet capture length' was done for this rcd. */ + /* Keep track as to the min/max actual snapshot lengths */ + /* seen for this file. */ + if (phdr->caplen < phdr->len) { + if (phdr->caplen < snaplen_min_inferred) + snaplen_min_inferred = phdr->caplen; + if (phdr->caplen > snaplen_max_inferred) + snaplen_max_inferred = phdr->caplen; + } - /* Per-packet encapsulation */ - if (wtap_file_encap(wth) == WTAP_ENCAP_PER_PACKET) { - if ((phdr->pkt_encap > 0) && (phdr->pkt_encap < WTAP_NUM_ENCAP_TYPES)) { - cf_info.encap_counts[phdr->pkt_encap] += 1; - } else { - fprintf(stderr, "capinfos: Unknown per-packet encapsulation: %d [frame number: %d]\n", phdr->pkt_encap, packet); + /* Per-packet encapsulation */ + if (wtap_file_encap(wth) == WTAP_ENCAP_PER_PACKET) { + if ((phdr->pkt_encap > 0) && (phdr->pkt_encap < WTAP_NUM_ENCAP_TYPES)) { + cf_info.encap_counts[phdr->pkt_encap] += 1; + } else { + fprintf(stderr, "capinfos: Unknown per-packet encapsulation: %d [frame number: %d]\n", phdr->pkt_encap, packet); + } } } diff --git a/editcap.c b/editcap.c index 79f88d0924..9197e62468 100644 --- a/editcap.c +++ b/editcap.c @@ -1669,6 +1669,10 @@ handle_chopping(chop_t chop, struct wtap_pkthdr *out_phdr, const struct wtap_pkthdr *in_phdr, guint8 **buf, gboolean adjlen) { + /* Only packets can be chopped. */ + if (in_phdr->rec_type != REC_TYPE_PACKET) + return; + /* If we're not chopping anything from one side, then the offset for that * side is meaningless. */ if (chop.len_begin == 0) diff --git a/epan/epan.c b/epan/epan.c index 30b5dd94a8..ae5ea320f6 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -332,7 +332,7 @@ epan_dissect_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr, wslua_prime_dfilter(edt); /* done before entering wmem scope */ #endif wmem_enter_packet_scope(); - dissect_packet(edt, phdr, tvb, fd, cinfo); + dissect_record(edt, phdr, tvb, fd, cinfo); /* free all memory allocated */ ep_free_all(); @@ -345,7 +345,7 @@ epan_dissect_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr, { wmem_enter_packet_scope(); tap_queue_init(edt); - dissect_packet(edt, phdr, tvb, fd, cinfo); + dissect_record(edt, phdr, tvb, fd, cinfo); tap_push_tapped_queue(edt); /* free all memory allocated */ diff --git a/epan/packet.c b/epan/packet.c index 9866f47174..b8026933ea 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -420,7 +420,7 @@ final_registration_all_protocols(void) /* Creates the top-most tvbuff and calls dissect_frame() */ void -dissect_packet(epan_dissect_t *edt, struct wtap_pkthdr *phdr, +dissect_record(epan_dissect_t *edt, struct wtap_pkthdr *phdr, tvbuff_t *tvb, frame_data *fd, column_info *cinfo) { if (cinfo != NULL) @@ -456,6 +456,10 @@ dissect_packet(epan_dissect_t *edt, struct wtap_pkthdr *phdr, else if (fd->flags.has_phdr_comment) edt->pi.pkt_comment = phdr->opt_comment; + if (phdr->rec_type != REC_TYPE_PACKET) { + /* XXX = process these */ + } + EP_CHECK_CANARY(("before dissecting frame %d",fd->num)); TRY { diff --git a/epan/packet.h b/epan/packet.h index f67e3e75b3..e41a3bc0cc 100644 --- a/epan/packet.h +++ b/epan/packet.h @@ -554,9 +554,9 @@ extern void free_data_sources(packet_info *pinfo); WS_DLL_PUBLIC void mark_frame_as_depended_upon(packet_info *pinfo, guint32 frame_num); /* - * Dissectors should never modify the packet data. + * Dissectors should never modify the record data. */ -extern void dissect_packet(struct epan_dissect *edt, +extern void dissect_record(struct epan_dissect *edt, struct wtap_pkthdr *phdr, tvbuff_t *tvb, frame_data *fd, column_info *cinfo); diff --git a/epan/wslua/make-init-lua.pl b/epan/wslua/make-init-lua.pl index 328dd9fc92..29df74019f 100755 --- a/epan/wslua/make-init-lua.pl +++ b/epan/wslua/make-init-lua.pl @@ -34,6 +34,7 @@ my $wtap_encaps_table = ''; my $wtap_filetypes_table = ''; my $wtap_commenttypes_table = ''; my $ft_types_table = ''; +my $wtap_rec_types_table = ''; my $wtap_presence_flags_table = ''; my $bases_table = ''; my $encodings = ''; @@ -48,6 +49,7 @@ my %replacements = %{{ WTAP_FILETYPES => \$wtap_filetypes_table, WTAP_COMMENTTYPES => \$wtap_commenttypes_table, FT_TYPES => \$ft_types_table, + WTAP_REC_TYPES => \$wtap_rec_types_table, WTAP_PRESENCE_FLAGS => \$wtap_presence_flags_table, BASES => \$bases_table, ENCODINGS => \$encodings, @@ -78,6 +80,7 @@ close TEMPLATE; $wtap_encaps_table = "-- Wiretap encapsulations XXX\nwtap_encaps = {\n"; $wtap_filetypes_table = "-- Wiretap file types\nwtap_filetypes = {\n"; $wtap_commenttypes_table = "-- Wiretap file comment types\nwtap_comments = {\n"; +$wtap_rec_types_table = "-- Wiretap record_types\nwtap_rec_types = {\n"; $wtap_presence_flags_table = "-- Wiretap presence flags\nwtap_presence_flags = {\n"; open WTAP_H, "< $WSROOT/wiretap/wtap.h" or die "cannot open '$WSROOT/wiretap/wtap.h': $!"; @@ -96,6 +99,10 @@ while() { $wtap_commenttypes_table .= "\t[\"$1\"] = $2,\n"; } + if ( /^#define REC_TYPE_([A-Z0-9_]+)\s+(\d+)\s+\/\*\*<([^\*]+)\*\// ) { + $wtap_rec_types_table .= "\t[\"$1\"] = $2, --$3\n"; + } + if ( /^#define WTAP_HAS_([A-Z0-9_]+)\s+(0x\d+)\s+\/\*\*<([^\*]+)\*\// ) { my $num = hex($2); $wtap_presence_flags_table .= "\t[\"$1\"] = $num, --$3\n"; @@ -105,6 +112,9 @@ while() { $wtap_encaps_table =~ s/,\n$/\n}\nwtap = wtap_encaps -- for bw compatibility\n/msi; $wtap_filetypes_table =~ s/,\n$/\n}\n/msi; $wtap_commenttypes_table =~ s/,\n$/\n}\n/msi; +# wtap_rec_types_table has comments at the end (not a comma), +# but Lua doesn't care about extra commas so leave it in +$wtap_rec_types_table =~ s/\n$/\n}\n/msi; # wtap_presence_flags_table has comments at the end (not a comma), # but Lua doesn't care about extra commas so leave it in $wtap_presence_flags_table =~ s/\n$/\n}\n/msi; diff --git a/epan/wslua/template-init.lua b/epan/wslua/template-init.lua index 806593739e..3fe2acaf1e 100644 --- a/epan/wslua/template-init.lua +++ b/epan/wslua/template-init.lua @@ -119,6 +119,9 @@ end -- %FT_TYPES% +-- the following table is since 1.12 +-- %WTAP_REC_TYPES% + -- the following table is since 1.11.3 -- %WTAP_PRESENCE_FLAGS% diff --git a/epan/wslua/wslua_dumper.c b/epan/wslua/wslua_dumper.c index 4340304f57..7afec31ec0 100644 --- a/epan/wslua/wslua_dumper.c +++ b/epan/wslua/wslua_dumper.c @@ -325,6 +325,9 @@ WSLUA_METHOD Dumper_dump(lua_State* L) { memset(&pkthdr, 0, sizeof(pkthdr)); + pkthdr.rec_type = REC_TYPE_PACKET; + + pkthdr.presence_flags = WTAP_HAS_TS; pkthdr.ts.secs = (unsigned int)(floor(ts)); pkthdr.ts.nsecs = (unsigned int)(floor((ts - (double)pkthdr.ts.secs) * 1000000000)); @@ -423,6 +426,8 @@ WSLUA_METHOD Dumper_dump_current(lua_State* L) { memset(&pkthdr, 0, sizeof(pkthdr)); + pkthdr.rec_type = REC_TYPE_PACKET; + pkthdr.presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; pkthdr.ts.secs = lua_pinfo->fd->abs_ts.secs; pkthdr.ts.nsecs = lua_pinfo->fd->abs_ts.nsecs; pkthdr.len = tvb_reported_length(tvb); diff --git a/epan/wslua/wslua_file.c b/epan/wslua/wslua_file.c index 04f24d54d0..92d6364ab0 100644 --- a/epan/wslua/wslua_file.c +++ b/epan/wslua/wslua_file.c @@ -1183,8 +1183,8 @@ WSLUA_METAMETHOD FrameInfo__tostring(lua_State* L) { lua_pushstring(L,"FrameInfo pointer is NULL!"); } else { if (fi->phdr) - lua_pushfstring(L, "FrameInfo: presence_flags=%d, caplen=%d, len=%d, pkt_encap=%d, opt_comment='%s'", - fi->phdr->presence_flags, fi->phdr->caplen, fi->phdr->len, fi->phdr->pkt_encap, fi->phdr->opt_comment); + lua_pushfstring(L, "FrameInfo: rec_type=%u, presence_flags=%d, caplen=%d, len=%d, pkt_encap=%d, opt_comment='%s'", + fi->phdr->rec_type, fi->phdr->presence_flags, fi->phdr->caplen, fi->phdr->len, fi->phdr->pkt_encap, fi->phdr->opt_comment); else lua_pushstring(L, "FrameInfo phdr pointer is NULL!"); } @@ -1308,6 +1308,12 @@ static int FrameInfo_get_data (lua_State* L) { WSLUA_RETURN(1); /* A Lua string of the frame buffer's data. */ } +/* WSLUA_ATTRIBUTE FrameInfo_rec_type RW The record type of the packet frame + + See `wtap_rec_types` in `init.lua` for values. */ +WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfo,rec_type,phdr->rec_type); +WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FrameInfo,rec_type,phdr->rec_type,guint); + /* WSLUA_ATTRIBUTE FrameInfo_flags RW The presence flags of the packet frame. See `wtap_presence_flags` in `init.lua` for bit values. */ @@ -1340,6 +1346,7 @@ WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(FrameInfo,comment,phdr->opt_comment,TRUE); * from this table for getting/setting the members. */ WSLUA_ATTRIBUTES FrameInfo_attributes[] = { + WSLUA_ATTRIBUTE_RWREG(FrameInfo,rec_type), WSLUA_ATTRIBUTE_RWREG(FrameInfo,flags), WSLUA_ATTRIBUTE_RWREG(FrameInfo,captured_length), WSLUA_ATTRIBUTE_RWREG(FrameInfo,original_length), @@ -1391,8 +1398,8 @@ WSLUA_METAMETHOD FrameInfoConst__tostring(lua_State* L) { lua_pushstring(L,"FrameInfo pointer is NULL!"); } else { if (fi->phdr && !fi->expired) - lua_pushfstring(L, "FrameInfo: presence_flags=%d, caplen=%d, len=%d, pkt_encap=%d, opt_comment='%s'", - fi->phdr->presence_flags, fi->phdr->caplen, fi->phdr->len, fi->phdr->pkt_encap, fi->phdr->opt_comment); + lua_pushfstring(L, "FrameInfo: rec_type=%u, presence_flags=%d, caplen=%d, len=%d, pkt_encap=%d, opt_comment='%s'", + fi->phdr->rec_type, fi->phdr->presence_flags, fi->phdr->caplen, fi->phdr->len, fi->phdr->pkt_encap, fi->phdr->opt_comment); else lua_pushfstring(L, "FrameInfo has %s", fi->phdr?"expired":"null phdr pointer"); } @@ -1464,6 +1471,9 @@ static int FrameInfoConst_get_data (lua_State* L) { return 1; } +/* WSLUA_ATTRIBUTE FrameInfoConst_rec_type RO The record type of the packet frame - see `wtap_presence_flags` in `init.lua` for values. */ +WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,rec_type,phdr->rec_type); + /* WSLUA_ATTRIBUTE FrameInfoConst_flags RO The presence flags of the packet frame - see `wtap_presence_flags` in `init.lua` for bits. */ WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,flags,phdr->presence_flags); @@ -1482,6 +1492,7 @@ WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,encap,phdr->pkt_encap); WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(FrameInfoConst,comment,phdr->opt_comment); WSLUA_ATTRIBUTES FrameInfoConst_attributes[] = { + WSLUA_ATTRIBUTE_ROREG(FrameInfoConst,rec_type), WSLUA_ATTRIBUTE_ROREG(FrameInfoConst,flags), WSLUA_ATTRIBUTE_ROREG(FrameInfoConst,captured_length), WSLUA_ATTRIBUTE_ROREG(FrameInfoConst,original_length), diff --git a/file.c b/file.c index e75a78d4f9..7630989115 100644 --- a/file.c +++ b/file.c @@ -1754,8 +1754,8 @@ cf_redissect_packets(capture_file *cf) } gboolean -cf_read_frame_r(capture_file *cf, const frame_data *fdata, - struct wtap_pkthdr *phdr, Buffer *buf) +cf_read_record_r(capture_file *cf, const frame_data *fdata, + struct wtap_pkthdr *phdr, Buffer *buf) { int err; gchar *err_info; @@ -1807,9 +1807,9 @@ cf_read_frame_r(capture_file *cf, const frame_data *fdata, } gboolean -cf_read_frame(capture_file *cf, frame_data *fdata) +cf_read_record(capture_file *cf, frame_data *fdata) { - return cf_read_frame_r(cf, fdata, &cf->phdr, &cf->buf); + return cf_read_record_r(cf, fdata, &cf->phdr, &cf->buf); } /* Rescan the list of packets, reconstructing the CList. @@ -2005,7 +2005,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb /* Frame dependencies from the previous dissection/filtering are no longer valid. */ fdata->flags.dependent_of_displayed = 0; - if (!cf_read_frame(cf, fdata)) + if (!cf_read_record(cf, fdata)) break; /* error reading the frame */ /* If the previous frame is displayed, and we haven't yet seen the @@ -2230,7 +2230,7 @@ typedef enum { } psp_return_t; static psp_return_t -process_specified_packets(capture_file *cf, packet_range_t *range, +process_specified_records(capture_file *cf, packet_range_t *range, const char *string1, const char *string2, gboolean terminate_is_stop, gboolean (*callback)(capture_file *, frame_data *, struct wtap_pkthdr *, const guint8 *, void *), @@ -2332,7 +2332,7 @@ process_specified_packets(capture_file *cf, packet_range_t *range, } /* Get the packet */ - if (!cf_read_frame_r(cf, fdata, &phdr, &buf)) { + if (!cf_read_record_r(cf, fdata, &phdr, &buf)) { /* Attempt to get the packet failed. */ ret = PSP_FAILED; break; @@ -2411,7 +2411,7 @@ cf_retap_packets(capture_file *cf) packet_range_init(&range, cf); packet_range_process_init(&range); - ret = process_specified_packets(cf, &range, "Recalculating statistics on", + ret = process_specified_records(cf, &range, "Recalculating statistics on", "all packets", TRUE, retap_packet, &callback_args); @@ -2724,7 +2724,7 @@ cf_print_packets(capture_file *cf, print_args_t *print_args) /* Iterate through the list of packets, printing the packets we were told to print. */ - ret = process_specified_packets(cf, &print_args->range, "Printing", + ret = process_specified_records(cf, &print_args->range, "Printing", "selected packets", TRUE, print_packet, &callback_args); epan_dissect_cleanup(&callback_args.edt); @@ -2815,7 +2815,7 @@ cf_write_pdml_packets(capture_file *cf, print_args_t *print_args) /* Iterate through the list of packets, printing the packets we were told to print. */ - ret = process_specified_packets(cf, &print_args->range, "Writing PDML", + ret = process_specified_records(cf, &print_args->range, "Writing PDML", "selected packets", TRUE, write_pdml_packet, &callback_args); @@ -2896,7 +2896,7 @@ cf_write_psml_packets(capture_file *cf, print_args_t *print_args) /* Iterate through the list of packets, printing the packets we were told to print. */ - ret = process_specified_packets(cf, &print_args->range, "Writing PSML", + ret = process_specified_records(cf, &print_args->range, "Writing PSML", "selected packets", TRUE, write_psml_packet, &callback_args); @@ -2976,7 +2976,7 @@ cf_write_csv_packets(capture_file *cf, print_args_t *print_args) /* Iterate through the list of packets, printing the packets we were told to print. */ - ret = process_specified_packets(cf, &print_args->range, "Writing CSV", + ret = process_specified_records(cf, &print_args->range, "Writing CSV", "selected packets", TRUE, write_csv_packet, &callback_args); @@ -3048,7 +3048,7 @@ cf_write_carrays_packets(capture_file *cf, print_args_t *print_args) /* Iterate through the list of packets, printing the packets we were told to print. */ - ret = process_specified_packets(cf, &print_args->range, + ret = process_specified_records(cf, &print_args->range, "Writing C Arrays", "selected packets", TRUE, write_carrays_packet, &callback_args); @@ -3109,7 +3109,7 @@ match_protocol_tree(capture_file *cf, frame_data *fdata, void *criterion) epan_dissect_t edt; /* Load the frame's data. */ - if (!cf_read_frame(cf, fdata)) { + if (!cf_read_record(cf, fdata)) { /* Attempt to get the packet failed. */ return MR_ERROR; } @@ -3213,7 +3213,7 @@ match_summary_line(capture_file *cf, frame_data *fdata, void *criterion) size_t c_match = 0; /* Load the frame's data. */ - if (!cf_read_frame(cf, fdata)) { + if (!cf_read_record(cf, fdata)) { /* Attempt to get the packet failed. */ return MR_ERROR; } @@ -3311,7 +3311,7 @@ match_narrow_and_wide(capture_file *cf, frame_data *fdata, void *criterion) size_t c_match = 0; /* Load the frame's data. */ - if (!cf_read_frame(cf, fdata)) { + if (!cf_read_record(cf, fdata)) { /* Attempt to get the packet failed. */ return MR_ERROR; } @@ -3359,7 +3359,7 @@ match_narrow(capture_file *cf, frame_data *fdata, void *criterion) size_t c_match = 0; /* Load the frame's data. */ - if (!cf_read_frame(cf, fdata)) { + if (!cf_read_record(cf, fdata)) { /* Attempt to get the packet failed. */ return MR_ERROR; } @@ -3406,7 +3406,7 @@ match_wide(capture_file *cf, frame_data *fdata, void *criterion) size_t c_match = 0; /* Load the frame's data. */ - if (!cf_read_frame(cf, fdata)) { + if (!cf_read_record(cf, fdata)) { /* Attempt to get the packet failed. */ return MR_ERROR; } @@ -3452,7 +3452,7 @@ match_binary(capture_file *cf, frame_data *fdata, void *criterion) size_t c_match = 0; /* Load the frame's data. */ - if (!cf_read_frame(cf, fdata)) { + if (!cf_read_record(cf, fdata)) { /* Attempt to get the packet failed. */ return MR_ERROR; } @@ -3522,7 +3522,7 @@ match_dfilter(capture_file *cf, frame_data *fdata, void *criterion) match_result result; /* Load the frame's data. */ - if (!cf_read_frame(cf, fdata)) { + if (!cf_read_record(cf, fdata)) { /* Attempt to get the packet failed. */ return MR_ERROR; } @@ -3848,7 +3848,7 @@ cf_select_packet(capture_file *cf, int row) } /* Get the data in that frame. */ - if (!cf_read_frame (cf, fdata)) { + if (!cf_read_record (cf, fdata)) { return; } @@ -4028,7 +4028,7 @@ cf_get_comment(capture_file *cf, const frame_data *fd) memset(&phdr, 0, sizeof(struct wtap_pkthdr)); buffer_init(&buf, 1500); - if (!cf_read_frame_r(cf, fd, &phdr, &buf)) + if (!cf_read_record_r(cf, fd, &phdr, &buf)) { /* XXX, what we can do here? */ } buffer_free(&buf); @@ -4110,7 +4110,7 @@ typedef struct { * up a message box for the failure. */ static gboolean -save_packet(capture_file *cf _U_, frame_data *fdata, +save_record(capture_file *cf _U_, frame_data *fdata, struct wtap_pkthdr *phdr, const guint8 *pd, void *argsp) { @@ -4138,6 +4138,7 @@ save_packet(capture_file *cf _U_, frame_data *fdata, For WTAP_HAS_PACK_FLAGS, we currently don't save the FCS length from the packet flags. */ + hdr.rec_type = phdr->rec_type; hdr.presence_flags = 0; if (fdata->flags.has_ts) hdr.presence_flags |= WTAP_HAS_TS; @@ -4147,8 +4148,8 @@ save_packet(capture_file *cf _U_, frame_data *fdata, hdr.presence_flags |= WTAP_HAS_PACK_FLAGS; hdr.ts.secs = fdata->abs_ts.secs; hdr.ts.nsecs = fdata->abs_ts.nsecs; - hdr.caplen = fdata->cap_len; - hdr.len = fdata->pkt_len; + hdr.caplen = phdr->caplen; + hdr.len = phdr->len; hdr.pkt_encap = fdata->lnk_t; /* pcapng */ hdr.interface_id = phdr->interface_id; /* identifier of the interface. */ @@ -4551,7 +4552,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err) } cf_write_status_t -cf_save_packets(capture_file *cf, const char *fname, guint save_format, +cf_save_records(capture_file *cf, const char *fname, guint save_format, gboolean compressed, gboolean discard_comments, gboolean dont_reopen) { @@ -4698,8 +4699,8 @@ cf_save_packets(capture_file *cf, const char *fname, guint save_format, callback_args.pdh = pdh; callback_args.fname = fname; callback_args.file_type = save_format; - switch (process_specified_packets(cf, NULL, "Saving", "packets", - TRUE, save_packet, &callback_args)) { + switch (process_specified_records(cf, NULL, "Saving", "packets", + TRUE, save_record, &callback_args)) { case PSP_FINISHED: /* Completed successfully. */ @@ -4927,14 +4928,14 @@ cf_export_specified_packets(capture_file *cf, const char *fname, told to process. XXX - we've already called "packet_range_process_init(range)", but - "process_specified_packets()" will do it again. Fortunately, + "process_specified_records()" will do it again. Fortunately, that's harmless in this case, as we haven't done anything to "range" since we initialized it. */ callback_args.pdh = pdh; callback_args.fname = fname; callback_args.file_type = save_format; - switch (process_specified_packets(cf, range, "Writing", "specified packets", - TRUE, save_packet, &callback_args)) { + switch (process_specified_records(cf, range, "Writing", "specified records", + TRUE, save_record, &callback_args)) { case PSP_FINISHED: /* Completed successfully. */ diff --git a/file.h b/file.h index 79df1cfd68..37449551eb 100644 --- a/file.h +++ b/file.h @@ -131,35 +131,35 @@ void cf_reload(capture_file *cf); * Read all packets of a capture file into the internal structures. * * @param cf the capture file to be read - * @param from_save reread asked from cf_save_packets + * @param from_save reread asked from cf_save_records * @return one of cf_read_status_t */ cf_read_status_t cf_read(capture_file *cf, gboolean from_save); /** - * Read the pseudo-header and raw data for a packet. It will pop + * Read the metadata and raw data for a record. It will pop * up an alert box if there's an error. * - * @param cf the capture file from which to read the packet - * @param fdata the frame_data structure for the packet in question + * @param cf the capture file from which to read the record + * @param fdata the frame_data structure for the record in question * @param phdr pointer to a wtap_pkthdr structure to contain the - * packet's pseudo-header and other metadata - * @param buf a Buffer into which to read the packet's raw data + * record's metadata + * @param buf a Buffer into which to read the record's raw data * @return TRUE if the read succeeded, FALSE if there was an error */ -gboolean cf_read_frame_r(capture_file *cf, const frame_data *fdata, - struct wtap_pkthdr *phdr, Buffer *buf); +gboolean cf_read_record_r(capture_file *cf, const frame_data *fdata, + struct wtap_pkthdr *phdr, Buffer *buf); /** - * Read the pseudo-header and raw data for a packet into a - * capture_file structure's pseudo_header and buf members. + * Read the metadata and raw data for a record into a + * capture_file structure's phdr and buf members. * It will pop up an alert box if there's an error. * - * @param cf the capture file from which to read the packet - * @param fdata the frame_data structure for the packet in question + * @param cf the capture file from which to read the record + * @param fdata the frame_data structure for the record in question * @return TRUE if the read succeeded, FALSE if there was an error */ -gboolean cf_read_frame(capture_file *cf, frame_data *fdata); +gboolean cf_read_record(capture_file *cf, frame_data *fdata); /** * Read packets from the "end" of a capture file. @@ -239,7 +239,7 @@ gboolean cf_has_unsaved_data(capture_file *cf); * current capture file * @return one of cf_write_status_t */ -cf_write_status_t cf_save_packets(capture_file * cf, const char *fname, +cf_write_status_t cf_save_records(capture_file * cf, const char *fname, guint save_format, gboolean compressed, gboolean discard_comments, gboolean dont_reopen); diff --git a/proto_hier_stats.c b/proto_hier_stats.c index 42ef942220..791e881e31 100644 --- a/proto_hier_stats.c +++ b/proto_hier_stats.c @@ -136,7 +136,7 @@ process_tree(proto_tree *protocol_tree, ph_stats_t* ps, guint pkt_len) } static gboolean -process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps) +process_record(frame_data *frame, column_info *cinfo, ph_stats_t* ps) { epan_dissect_t edt; struct wtap_pkthdr phdr; @@ -145,12 +145,12 @@ process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps) memset(&phdr, 0, sizeof(struct wtap_pkthdr)); - /* Load the frame from the capture file */ + /* Load the record from the capture file */ buffer_init(&buf, 1500); - if (!cf_read_frame_r(&cfile, frame, &phdr, &buf)) + if (!cf_read_record_r(&cfile, frame, &phdr, &buf)) return FALSE; /* failure */ - /* Dissect the frame tree not visible */ + /* Dissect the record tree not visible */ epan_dissect_init(&edt, cfile.epan, TRUE, FALSE); /* Don't fake protocols. We need them for the protocol hierarchy */ epan_dissect_fake_protocols(&edt, FALSE); @@ -162,12 +162,10 @@ process_frame(frame_data *frame, column_info *cinfo, ph_stats_t* ps) if (frame->flags.has_ts) { /* Update times */ cur_time = nstime_to_sec(&frame->abs_ts); - if (cur_time < ps->first_time) { - ps->first_time = cur_time; - } - if (cur_time > ps->last_time){ - ps->last_time = cur_time; - } + if (cur_time < ps->first_time) + ps->first_time = cur_time; + if (cur_time > ps->last_time) + ps->last_time = cur_time; } /* Free our memory. */ @@ -277,7 +275,7 @@ ph_stats_new(void) } /* we don't care about colinfo */ - if (!process_frame(frame, NULL, ps)) { + if (!process_record(frame, NULL, ps)) { /* * Give up, and set "stop_flag" so we * just abort rather than popping up diff --git a/randpkt.c b/randpkt.c index c83e35f800..5393fa9ee1 100644 --- a/randpkt.c +++ b/randpkt.c @@ -578,6 +578,7 @@ main(int argc, char **argv) memset(&pkthdr, 0, sizeof(pkthdr)); memset(buffer, 0, sizeof(buffer)); + pkthdr.rec_type = REC_TYPE_PACKET; pkthdr.presence_flags = WTAP_HAS_TS; pkthdr.pkt_encap = example->sample_wtap_encap; diff --git a/test/lua/acme_file.lua b/test/lua/acme_file.lua index f00f25f0cb..30c328288f 100644 --- a/test/lua/acme_file.lua +++ b/test/lua/acme_file.lua @@ -656,6 +656,7 @@ end function Packet:set_wslua_fields(frame) frame.time = self.timestamp + frame.rec_type = wtap_rec_types.PACKET frame.flags = wtap_presence_flags.TS -- for timestamp if self.comment then frame.comment = self.comment diff --git a/test/lua/pcap_file.lua b/test/lua/pcap_file.lua index 9f42f9700b..d15b648ce4 100644 --- a/test/lua/pcap_file.lua +++ b/test/lua/pcap_file.lua @@ -8,7 +8,7 @@ be as good as the real thing; this is a simplistic implementation to show how to create such file readers, and for testing purposes. - This script requires Wireshark v1.11.3 or newer. + This script requires Wireshark v1.12 or newer. --]] -------------------------------------------------------------------------------- @@ -33,7 +33,7 @@ end local major, minor, micro = get_version():match("(%d+)%.(%d+)%.(%d+)") if major and tonumber(major) <= 1 and ((tonumber(minor) <= 10) or (tonumber(minor) == 11 and tonumber(micro) < 3)) then error( "Sorry, but your " .. wireshark_name .. " version (" .. get_version() .. ") is too old for this script!\n" .. - "This script needs " .. wireshark_name .. "version 1.11.3 or higher.\n" ) + "This script needs " .. wireshark_name .. "version 1.12 or higher.\n" ) end -- verify we have the Struct library in wireshark @@ -576,6 +576,8 @@ parse_rec_header = function(funcname, file, file_settings, frame) caplen = WTAP_MAX_PACKET_SIZE end + frame.rec_type = wtap_rec_types.PACKET + frame.captured_length = caplen frame.original_length = origlen diff --git a/ui/gtk/capture_file_dlg.c b/ui/gtk/capture_file_dlg.c index baef2baed9..672ab91975 100644 --- a/ui/gtk/capture_file_dlg.c +++ b/ui/gtk/capture_file_dlg.c @@ -1454,11 +1454,11 @@ do_file_save(capture_file *cf, gboolean dont_reopen) } /* XXX - cf->filename might get freed out from under us, because - the code path through which cf_save_packets() goes currently + the code path through which cf_save_records() goes currently closes the current file and then opens and reloads the saved file, so make a copy and free it later. */ fname = g_strdup(cf->filename); - status = cf_save_packets(cf, fname, cf->cd_t, cf->iscompressed, + status = cf_save_records(cf, fname, cf->cd_t, cf->iscompressed, discard_comments, dont_reopen); switch (status) { @@ -1896,7 +1896,7 @@ file_save_as_cmd(capture_file *cf, gboolean must_support_all_comments, #endif /* Attempt to save the file */ - status = cf_save_packets(&cfile, file_name->str, file_type, compressed, + status = cf_save_records(&cfile, file_name->str, file_type, compressed, discard_comments, dont_reopen); switch (status) { diff --git a/ui/gtk/iax2_analysis.c b/ui/gtk/iax2_analysis.c index 6f7fe77c73..d132bf35e8 100644 --- a/ui/gtk/iax2_analysis.c +++ b/ui/gtk/iax2_analysis.c @@ -3688,7 +3688,6 @@ void iax2_analysis_cb(GtkAction *action _U_, gpointer user_data _U_) gchar filter_text[256]; dfilter_t *sfcode; capture_file *cf; - gboolean frame_matched; frame_data *fdata; GList *strinfo_list; GList *filtered_list = NULL; @@ -3710,17 +3709,16 @@ void iax2_analysis_cb(GtkAction *action _U_, gpointer user_data _U_) if (fdata == NULL) return; /* if we exit here it's an error */ - /* dissect the current frame */ - if (!cf_read_frame(cf, fdata)) - return; /* error reading the frame */ + /* dissect the current record */ + if (!cf_read_record(cf, fdata)) + return; /* error reading the record */ epan_dissect_init(&edt, cf->epan, TRUE, FALSE); epan_dissect_prime_dfilter(&edt, sfcode); epan_dissect_run(&edt, &cf->phdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata, NULL); - /* if it is not an iax2 frame, show an error dialog */ - frame_matched = dfilter_apply_edt(sfcode, &edt); - if (frame_matched != 1) { + /* if it is not an iax2 packet, show an error dialog */ + if (!dfilter_apply_edt(sfcode, &edt)) { epan_dissect_cleanup(&edt); simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Please select an IAX2 packet."); diff --git a/ui/gtk/main.c b/ui/gtk/main.c index e49e0531a0..69f9aa88c5 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -543,7 +543,7 @@ get_ip_address_list_from_packet_list_row(gpointer data) if (fdata != NULL) { epan_dissect_t edt; - if (!cf_read_frame (&cfile, fdata)) + if (!cf_read_record(&cfile, fdata)) return NULL; /* error reading the frame */ epan_dissect_init(&edt, cfile.epan, FALSE, FALSE); @@ -584,8 +584,8 @@ get_filter_from_packet_list_row_and_column(gpointer data) if (fdata != NULL) { epan_dissect_t edt; - if (!cf_read_frame(&cfile, fdata)) - return NULL; /* error reading the frame */ + if (!cf_read_record(&cfile, fdata)) + return NULL; /* error reading the record */ /* proto tree, visible. We need a proto tree if there's custom columns */ epan_dissect_init(&edt, cfile.epan, have_custom_cols(&cfile.cinfo), FALSE); col_custom_prime_edt(&edt, &cfile.cinfo); diff --git a/ui/gtk/packet_list_store.c b/ui/gtk/packet_list_store.c index dd904b58be..195cab70c4 100644 --- a/ui/gtk/packet_list_store.c +++ b/ui/gtk/packet_list_store.c @@ -1117,9 +1117,9 @@ packet_list_dissect_and_cache_record(PacketList *packet_list, PacketListRecord * cinfo = NULL; buffer_init(&buf, 1500); - if (!cf_read_frame_r(&cfile, fdata, &phdr, &buf)) { + if (!cf_read_record_r(&cfile, fdata, &phdr, &buf)) { /* - * Error reading the frame. + * Error reading the record. * * Don't set the color filter for now (we might want * to colorize it in some fashion to warn that the @@ -1139,7 +1139,7 @@ packet_list_dissect_and_cache_record(PacketList *packet_list, PacketListRecord * record->colorized = TRUE; } buffer_free(&buf); - return; /* error reading the frame */ + return; /* error reading the record */ } create_proto_tree = (dissect_color && color_filters_used()) || diff --git a/ui/gtk/packet_win.c b/ui/gtk/packet_win.c index c25d62b48a..55a82d3a39 100644 --- a/ui/gtk/packet_win.c +++ b/ui/gtk/packet_win.c @@ -960,9 +960,9 @@ void new_packet_window(GtkWidget *w _U_, gboolean reference, gboolean editable _ return; } - /* With the new packetlists "lazy columns" it's necessary to reread the frame */ - if (!cf_read_frame(&cfile, fd)) { - /* error reading the frame */ + /* With the new packetlists "lazy columns" it's necessary to reread the record */ + if (!cf_read_record(&cfile, fd)) { + /* error reading the record */ return; } diff --git a/ui/gtk/rlc_lte_graph.c b/ui/gtk/rlc_lte_graph.c index aeb5b9996b..4862b79858 100644 --- a/ui/gtk/rlc_lte_graph.c +++ b/ui/gtk/rlc_lte_graph.c @@ -902,9 +902,9 @@ static rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf, struct segment return NULL; } - /* dissect the current frame */ - if (!cf_read_frame(cf, fdata)) { - return NULL; /* error reading the frame */ + /* dissect the current record */ + if (!cf_read_record(cf, fdata)) { + return NULL; /* error reading the record */ } error_string = register_tap_listener("rlc-lte", &th, NULL, 0, NULL, tap_lte_rlc_packet, NULL); diff --git a/ui/gtk/rtp_analysis.c b/ui/gtk/rtp_analysis.c index 0305b0a26a..729b8e7992 100644 --- a/ui/gtk/rtp_analysis.c +++ b/ui/gtk/rtp_analysis.c @@ -3923,7 +3923,6 @@ rtp_analysis_cb(GtkAction *action _U_, gpointer user_data _U_) gchar filter_text[256]; dfilter_t *sfcode; capture_file *cf; - gboolean frame_matched; frame_data *fdata; GList *strinfo_list; GList *filtered_list = NULL; @@ -3945,16 +3944,15 @@ rtp_analysis_cb(GtkAction *action _U_, gpointer user_data _U_) if (fdata == NULL) return; /* if we exit here it's an error */ - /* dissect the current frame */ - if (!cf_read_frame(cf, fdata)) - return; /* error reading the frame */ + /* dissect the current record */ + if (!cf_read_record(cf, fdata)) + return; /* error reading the record */ epan_dissect_init(&edt, cf->epan, TRUE, FALSE); epan_dissect_prime_dfilter(&edt, sfcode); epan_dissect_run(&edt, &cf->phdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata, NULL); - /* if it is not an rtp frame, show the rtpstream dialog */ - frame_matched = dfilter_apply_edt(sfcode, &edt); - if (frame_matched != TRUE) { + /* if it is not an rtp packet, show the rtpstream dialog */ + if (!dfilter_apply_edt(sfcode, &edt)) { epan_dissect_cleanup(&edt); simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Please select an RTP packet."); diff --git a/ui/gtk/sctp_assoc_analyse.c b/ui/gtk/sctp_assoc_analyse.c index 2b751f7135..32b80b9787 100644 --- a/ui/gtk/sctp_assoc_analyse.c +++ b/ui/gtk/sctp_assoc_analyse.c @@ -957,7 +957,7 @@ sctp_analyse_cb(struct sctp_analyse *u_data, gboolean ext) dfilter_t *sfcode; capture_file *cf; epan_dissect_t edt; - gboolean frame_matched, frame_found = FALSE; + gboolean frame_found = FALSE; frame_data *fdata; gchar filter_text[256]; @@ -974,18 +974,16 @@ sctp_analyse_cb(struct sctp_analyse *u_data, gboolean ext) if (fdata == NULL) return; /* if we exit here it's an error */ - /* dissect the current frame */ - if (!cf_read_frame(cf, fdata)) - return; /* error reading the frame */ + /* dissect the current record */ + if (!cf_read_record(cf, fdata)) + return; /* error reading the record */ epan_dissect_init(&edt, cf->epan, TRUE, FALSE); epan_dissect_prime_dfilter(&edt, sfcode); epan_dissect_run(&edt, &cf->phdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata, NULL); - frame_matched = dfilter_apply_edt(sfcode, &edt); - /* if it is not an sctp frame, show the dialog */ - - if (frame_matched != 1) { + /* if it is not an sctp packet, show the dialog */ + if (!dfilter_apply_edt(sfcode, &edt)) { epan_dissect_cleanup(&edt); simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Please choose an SCTP packet."); diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index 88fa327a13..e862f01d99 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -766,11 +766,11 @@ void MainWindow::saveCaptureFile(capture_file *cf, bool stay_closed) { } /* XXX - cf->filename might get freed out from under us, because - the code path through which cf_save_packets() goes currently + the code path through which cf_save_records() goes currently closes the current file and then opens and reloads the saved file, so make a copy and free it later. */ file_name = cf->filename; - status = cf_save_packets(cf, file_name.toUtf8().constData(), cf->cd_t, cf->iscompressed, + status = cf_save_records(cf, file_name.toUtf8().constData(), cf->cd_t, cf->iscompressed, discard_comments, stay_closed); switch (status) { @@ -886,7 +886,7 @@ void MainWindow::saveAsCaptureFile(capture_file *cf, bool must_support_comments, //#endif /* Attempt to save the file */ - status = cf_save_packets(cf, file_name.toUtf8().constData(), file_type, compressed, + status = cf_save_records(cf, file_name.toUtf8().constData(), file_type, compressed, discard_comments, stay_closed); switch (status) { diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index 7e9ff94132..8478a12048 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -655,8 +655,8 @@ QString &PacketList::getFilterFromRowAndColumn() if (fdata != NULL) { epan_dissect_t edt; - if (!cf_read_frame(cap_file_, fdata)) - return filter; /* error reading the frame */ + if (!cf_read_record(cap_file_, fdata)) + return filter; /* error reading the record */ /* proto tree, visible. We need a proto tree if there's custom columns */ epan_dissect_init(&edt, cap_file_->epan, have_custom_cols(&cap_file_->cinfo), FALSE); col_custom_prime_edt(&edt, &cap_file_->cinfo); diff --git a/ui/qt/packet_list_model.cpp b/ui/qt/packet_list_model.cpp index a6b68f51bd..1d7a764561 100644 --- a/ui/qt/packet_list_model.cpp +++ b/ui/qt/packet_list_model.cpp @@ -221,9 +221,9 @@ QVariant PacketListModel::data(const QModelIndex &index, int role) const memset(&phdr, 0, sizeof(struct wtap_pkthdr)); buffer_init(&buf, 1500); - if (!cap_file_ || !cf_read_frame_r(cap_file_, fdata, &phdr, &buf)) { + if (!cap_file_ || !cf_read_record_r(cap_file_, fdata, &phdr, &buf)) { /* - * Error reading the frame. + * Error reading the record. * * Don't set the color filter for now (we might want * to colorize it in some fashion to warn that the @@ -247,7 +247,7 @@ QVariant PacketListModel::data(const QModelIndex &index, int role) const // record->colorized = TRUE; } buffer_free(&buf); - return QVariant(); /* error reading the frame */ + return QVariant(); /* error reading the record */ } create_proto_tree = (color_filters_used() && enable_color_) || diff --git a/ui/tap-tcp-stream.c b/ui/tap-tcp-stream.c index 9dd1e46381..5a2098591c 100644 --- a/ui/tap-tcp-stream.c +++ b/ui/tap-tcp-stream.c @@ -304,9 +304,9 @@ select_tcpip_session(capture_file *cf, struct segment *hdrs) return NULL; } - /* dissect the current frame */ - if (!cf_read_frame(cf, fdata)) - return NULL; /* error reading the frame */ + /* dissect the current record */ + if (!cf_read_record(cf, fdata)) + return NULL; /* error reading the record */ error_string=register_tap_listener("tcp", &th, NULL, 0, NULL, tap_tcpip_packet, NULL); diff --git a/ui/tap_export_pdu.c b/ui/tap_export_pdu.c index 4d0e9e21f6..7a9f859623 100644 --- a/ui/tap_export_pdu.c +++ b/ui/tap_export_pdu.c @@ -59,6 +59,7 @@ export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, co if(exp_pdu_data->tvb_length > 0){ tvb_memcpy(exp_pdu_data->pdu_tvb, packet_buf+exp_pdu_data->tlv_buffer_len, 0, exp_pdu_data->tvb_length); } + pkthdr.rec_type = REC_TYPE_PACKET; pkthdr.ts.secs = pinfo->fd->abs_ts.secs; pkthdr.ts.nsecs = pinfo->fd->abs_ts.nsecs; pkthdr.caplen = buffer_len; diff --git a/ui/text_import.c b/ui/text_import.c index 05fcc25b8f..374b5af283 100644 --- a/ui/text_import.c +++ b/ui/text_import.c @@ -522,6 +522,7 @@ write_current_packet (void) memset(&pkthdr, 0, sizeof(struct wtap_pkthdr)); + pkthdr.rec_type = REC_TYPE_PACKET; pkthdr.ts.secs = (guint32)ts_sec; pkthdr.ts.nsecs = ts_usec * 1000; if (ts_fmt == NULL) { ts_usec++; } /* fake packet counter */ diff --git a/wiretap/5views.c b/wiretap/5views.c index db377b1570..c30571096c 100644 --- a/wiretap/5views.c +++ b/wiretap/5views.c @@ -297,6 +297,7 @@ _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr, hdr->Utc = pletoh32(&hdr->Utc); hdr->NanoSecondes = pletoh32(&hdr->NanoSecondes); + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; phdr->ts.secs = hdr->Utc; phdr->ts.nsecs = hdr->NanoSecondes; @@ -370,6 +371,12 @@ static gboolean _5views_dump(wtap_dumper *wdh, _5views_dump_t *_5views = (_5views_dump_t *)wdh->priv; t_5VW_TimeStamped_Header HeaderFrame; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + /* Don't write out something bigger than we can read. */ if (phdr->caplen > WTAP_MAX_PACKET_SIZE) { *err = WTAP_ERR_PACKET_TOO_LARGE; diff --git a/wiretap/aethra.c b/wiretap/aethra.c index a0b783b349..59fbcd55e7 100644 --- a/wiretap/aethra.c +++ b/wiretap/aethra.c @@ -331,6 +331,7 @@ aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr, packet_size = rec_size - (guint32)(sizeof *hdr - sizeof hdr->rec_size); msecs = pletoh32(hdr->timestamp); + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; phdr->ts.secs = aethra->start + (msecs / 1000); phdr->ts.nsecs = (msecs % 1000) * 1000000; diff --git a/wiretap/ber.c b/wiretap/ber.c index 59e7e28f39..8e52e79b06 100644 --- a/wiretap/ber.c +++ b/wiretap/ber.c @@ -59,6 +59,7 @@ static gboolean ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, } packet_size = (int)file_size; + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ phdr->caplen = packet_size; diff --git a/wiretap/btsnoop.c b/wiretap/btsnoop.c index b7c0b4c5c5..9ea165ad4c 100644 --- a/wiretap/btsnoop.c +++ b/wiretap/btsnoop.c @@ -216,6 +216,7 @@ static gboolean btsnoop_read_record(wtap *wth, FILE_T fh, ts = GINT64_FROM_BE(hdr.ts_usec); ts -= KUnixTimeBase; + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; phdr->ts.secs = (guint)(ts / 1000000); phdr->ts.nsecs = (guint)((ts % 1000000) * 1000); @@ -331,6 +332,12 @@ static gboolean btsnoop_dump_h1(wtap_dumper *wdh, const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; struct btsnooprec_hdr rec_hdr; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + /* * Don't write out anything bigger than we can read. * (This will also fail on a caplen of 0, as it should.) @@ -369,6 +376,12 @@ static gboolean btsnoop_dump_h4(wtap_dumper *wdh, const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; struct btsnooprec_hdr rec_hdr; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + /* Don't write out anything bigger than we can read. */ if (phdr->caplen > WTAP_MAX_PACKET_SIZE) { *err = WTAP_ERR_PACKET_TOO_LARGE; diff --git a/wiretap/camins.c b/wiretap/camins.c index ccc618498a..f065f0bd1d 100644 --- a/wiretap/camins.c +++ b/wiretap/camins.c @@ -287,6 +287,7 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, return FALSE; offset += bytes_read; + phdr->rec_type = REC_TYPE_PACKET; phdr->pkt_encap = WTAP_ENCAP_DVBCI; /* timestamps aren't supported for now */ phdr->caplen = offset; diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c index 8b29a23880..be9b75eeee 100644 --- a/wiretap/catapult_dct2000.c +++ b/wiretap/catapult_dct2000.c @@ -605,6 +605,12 @@ catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, dct2000_file_externals_t *file_externals = (dct2000_file_externals_t*)pseudo_header->dct2000.wth->priv; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + dct2000 = (dct2000_dump_t *)wdh->priv; if (dct2000 == NULL) { @@ -1276,6 +1282,7 @@ process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals, gsize length; guint8 *frame_buffer; + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; /* Make sure all packets go to Catapult DCT2000 dissector */ diff --git a/wiretap/commview.c b/wiretap/commview.c index e2a868a6b2..b9ad83bfd0 100644 --- a/wiretap/commview.c +++ b/wiretap/commview.c @@ -173,6 +173,7 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, tm.tm_sec = cv_hdr.seconds; tm.tm_isdst = -1; + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; phdr->len = cv_hdr.data_len; @@ -275,6 +276,12 @@ static gboolean commview_dump(wtap_dumper *wdh, commview_header_t cv_hdr; struct tm *tm; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + /* Don't write out anything bigger than we can read. * (The length field in packet headers is 16 bits, which * imposes a hard limit.) */ diff --git a/wiretap/cosine.c b/wiretap/cosine.c index d937018796..a583e766b0 100644 --- a/wiretap/cosine.c +++ b/wiretap/cosine.c @@ -386,6 +386,7 @@ parse_cosine_rec_hdr(struct wtap_pkthdr *phdr, const char *line, yy = mm = dd = hr = min = sec = csec = 0; } + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; tm.tm_year = yy - 1900; tm.tm_mon = mm - 1; diff --git a/wiretap/csids.c b/wiretap/csids.c index bc640f639d..bdfe8fcd34 100644 --- a/wiretap/csids.c +++ b/wiretap/csids.c @@ -195,6 +195,7 @@ csids_read_packet(FILE_T fh, csids_t *csids, struct wtap_pkthdr *phdr, hdr.seconds = pntoh32(&hdr.seconds); hdr.caplen = pntoh16(&hdr.caplen); + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; phdr->len = hdr.caplen; phdr->caplen = hdr.caplen; diff --git a/wiretap/daintree-sna.c b/wiretap/daintree-sna.c index 23785548d2..ea47993d5f 100644 --- a/wiretap/daintree-sna.c +++ b/wiretap/daintree-sna.c @@ -199,6 +199,7 @@ daintree_sna_scan_header(struct wtap_pkthdr *phdr, char *readLine, guint64 seconds; int useconds; + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; if (sscanf(readLine, "%*s %18" G_GINT64_MODIFIER "u.%9d %9u %" READDATA_MAX_FIELD_SIZE "s", diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c index 0a3e9f57e1..2fb4bc873a 100644 --- a/wiretap/dbs-etherwatch.c +++ b/wiretap/dbs-etherwatch.c @@ -431,6 +431,7 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf, pd[length_pos+1] = (length) & 0xFF; } + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; p = strstr(months, mon); diff --git a/wiretap/dct3trace.c b/wiretap/dct3trace.c index 2a0eb9103a..b1bc62050b 100644 --- a/wiretap/dct3trace.c +++ b/wiretap/dct3trace.c @@ -210,6 +210,7 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr, if( have_data ) { /* We've got a full packet! */ + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = 0; /* no time stamp, no separate "on the wire" length */ phdr->ts.secs = 0; phdr->ts.nsecs = 0; diff --git a/wiretap/erf.c b/wiretap/erf.c index 67b7ccab1d..5800c81650 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -374,6 +374,7 @@ static int erf_read_header(FILE_T fh, { guint64 ts = pletoh64(&erf_header->ts); + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID; phdr->ts.secs = (long) (ts >> 32); ts = ((ts & 0xffffffff) * 1000 * 1000 * 1000); @@ -589,6 +590,12 @@ static gboolean erf_dump( gboolean must_add_crc = FALSE; guint32 crc32 = 0x00000000; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + /* Don't write anything bigger than we're willing to read. */ if(phdr->caplen > WTAP_MAX_PACKET_SIZE) { *err = WTAP_ERR_PACKET_TOO_LARGE; diff --git a/wiretap/eyesdn.c b/wiretap/eyesdn.c index 8bd32c2249..399c02d5b2 100644 --- a/wiretap/eyesdn.c +++ b/wiretap/eyesdn.c @@ -313,6 +313,7 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, return FALSE; } + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; phdr->ts.secs = secs; phdr->ts.nsecs = usecs * 1000; @@ -415,6 +416,12 @@ static gboolean eyesdn_dump(wtap_dumper *wdh, int protocol; int size; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + /* Don't write out anything bigger than we can read. * (The length field in packet headers is 16 bits, which * imposes a hard limit.) */ diff --git a/wiretap/hcidump.c b/wiretap/hcidump.c index cc38a62154..2253134a05 100644 --- a/wiretap/hcidump.c +++ b/wiretap/hcidump.c @@ -60,6 +60,7 @@ static gboolean hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr, return FALSE; } + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; phdr->ts.secs = GUINT32_FROM_LE(dh.ts_sec); phdr->ts.nsecs = GUINT32_FROM_LE(dh.ts_usec) * 1000; diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c index 10b7a83eeb..3cf1da691f 100644 --- a/wiretap/i4btrace.c +++ b/wiretap/i4btrace.c @@ -189,6 +189,7 @@ i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, return FALSE; } + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; phdr->len = length; diff --git a/wiretap/ipfix.c b/wiretap/ipfix.c index 5db06507c2..54fb229e86 100644 --- a/wiretap/ipfix.c +++ b/wiretap/ipfix.c @@ -169,6 +169,7 @@ ipfix_read_message(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, g if (!ipfix_read_message_header(&msg_hdr, fh, err, err_info)) return FALSE; + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; phdr->len = msg_hdr.message_length; phdr->caplen = msg_hdr.message_length; diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c index 67e8e65806..c7fa0249a7 100644 --- a/wiretap/iptrace.c +++ b/wiretap/iptrace.c @@ -200,6 +200,7 @@ iptrace_read_rec_1_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, return FALSE; } + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; phdr->len = packet_size; phdr->caplen = packet_size; @@ -395,6 +396,7 @@ iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, return FALSE; } + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; phdr->len = packet_size; phdr->caplen = packet_size; diff --git a/wiretap/iseries.c b/wiretap/iseries.c index 0a171a6341..729ad7729e 100644 --- a/wiretap/iseries.c +++ b/wiretap/iseries.c @@ -618,6 +618,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr, return FALSE; } + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_CAP_LEN; /* diff --git a/wiretap/k12.c b/wiretap/k12.c index 3da976767e..3bd3d3f533 100644 --- a/wiretap/k12.c +++ b/wiretap/k12.c @@ -553,6 +553,7 @@ process_packet_data(struct wtap_pkthdr *phdr, Buffer *target, guint8 *buffer, guint32 src_id; k12_src_desc_t* src_desc; + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; ts = pntoh64(buffer + K12_PACKET_TIMESTAMP); @@ -1179,6 +1180,12 @@ static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, } record; } obj; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + if (k12->num_of_records == 0) { k12_t* file_data = (k12_t*)pseudo_header->k12.stuff; /* XXX: We'll assume that any fwrite errors in k12_dump_src_setting will */ diff --git a/wiretap/k12text.l b/wiretap/k12text.l index 42de8e6875..fd332f2739 100644 --- a/wiretap/k12text.l +++ b/wiretap/k12text.l @@ -185,6 +185,7 @@ static void finalize_frame(void) { static void k12text_set_headers(struct wtap_pkthdr *phdr) { + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; phdr->ts.secs = 946681200 + (3600*g_h) + (60*g_m) + g_s; diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c index 8c2ce348a1..d00691beac 100644 --- a/wiretap/lanalyzer.c +++ b/wiretap/lanalyzer.c @@ -523,6 +523,7 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh, return FALSE; } + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; time_low = pletoh16(&descriptor[8]); @@ -662,6 +663,12 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh, struct timeval td; int thisSize = phdr->caplen + LA_PacketRecordSize + LA_RecordHeaderSize; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + if (wdh->bytes_dumped + thisSize > LA_ProFileLimit) { /* printf(" LA_ProFileLimit reached\n"); */ *err = EFBIG; @@ -674,7 +681,7 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh, if (len > 65535) { *err = WTAP_ERR_PACKET_TOO_LARGE; return FALSE; - } + } if (!s16write(wdh, GUINT16_TO_LE(0x1005), err)) return FALSE; diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c index fe9c111261..fb920d4e08 100644 --- a/wiretap/libpcap.c +++ b/wiretap/libpcap.c @@ -669,6 +669,7 @@ libpcap_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, orig_size -= phdr_len; packet_size -= phdr_len; + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; /* Update the timestamp, if not already done */ @@ -932,6 +933,12 @@ static gboolean libpcap_dump(wtap_dumper *wdh, phdrsize = pcap_get_phdr_size(wdh->encap, pseudo_header); + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + /* Don't write anything we're not willing to read. */ if (phdr->caplen + phdrsize > WTAP_MAX_PACKET_SIZE) { *err = WTAP_ERR_PACKET_TOO_LARGE; diff --git a/wiretap/logcat.c b/wiretap/logcat.c index a1a41c0689..1aa8058fdd 100644 --- a/wiretap/logcat.c +++ b/wiretap/logcat.c @@ -203,6 +203,7 @@ static gboolean logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh, return FALSE; } + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; phdr->ts.secs = (time_t) pletoh32(pd + 12); phdr->ts.nsecs = (int) pletoh32(pd + 16); @@ -298,6 +299,12 @@ static gboolean logcat_binary_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, const guint8 *pd, int *err) { + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) return FALSE; @@ -343,6 +350,12 @@ static gboolean logcat_dump_text(wtap_dumper *wdh, const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header; const struct dumper_t *dumper = (const struct dumper_t *) wdh->priv; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + if (pseudo_header->logcat.version == 1) { pid = (const gint *) (pd + 4); tid = (const gint *) (pd + 2 * 4); diff --git a/wiretap/mime_file.c b/wiretap/mime_file.c index 3601f23952..52c04ccc69 100644 --- a/wiretap/mime_file.c +++ b/wiretap/mime_file.c @@ -116,6 +116,7 @@ mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, } packet_size = (int)file_size; + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ phdr->caplen = packet_size; diff --git a/wiretap/mp2t.c b/wiretap/mp2t.c index 844fb40a13..103d6fe298 100644 --- a/wiretap/mp2t.c +++ b/wiretap/mp2t.c @@ -79,6 +79,8 @@ mp2t_read_packet(mp2t_filetype_t *mp2t, FILE_T fh, gint64 offset, return FALSE; } + phdr->rec_type = REC_TYPE_PACKET; + /* XXX - relative, not absolute, time stamps */ phdr->presence_flags = WTAP_HAS_TS; diff --git a/wiretap/mpeg.c b/wiretap/mpeg.c index abe87a37fe..b8d867754c 100644 --- a/wiretap/mpeg.c +++ b/wiretap/mpeg.c @@ -209,6 +209,8 @@ mpeg_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info)) return FALSE; + phdr->rec_type = REC_TYPE_PACKET; + /* XXX - relative, not absolute, time stamps */ if (!is_random) { phdr->presence_flags = WTAP_HAS_TS; diff --git a/wiretap/netmon.c b/wiretap/netmon.c index f12bf43a87..85d82a2d22 100644 --- a/wiretap/netmon.c +++ b/wiretap/netmon.c @@ -538,6 +538,8 @@ static gboolean netmon_process_rec_header(wtap *wth, FILE_T fh, return FALSE; } + phdr->rec_type = REC_TYPE_PACKET; + /* * If this is an ATM packet, the first * "sizeof (struct netmon_atm_hdr)" bytes have destination and @@ -1024,6 +1026,12 @@ static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, gint64 secs; gint32 nsecs; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + switch (wdh->file_type_subtype) { case WTAP_FILE_TYPE_SUBTYPE_NETMON_1_x: diff --git a/wiretap/netscaler.c b/wiretap/netscaler.c index c9785ac992..e6df1d1081 100644 --- a/wiretap/netscaler.c +++ b/wiretap/netscaler.c @@ -513,6 +513,7 @@ typedef struct nspr_pktracepart_v26 TRACE_V10_REC_LEN_OFF(phdr,enumprefix,structprefix,structname) #define TRACE_PART_V10_REC_LEN_OFF(phdr,enumprefix,structprefix,structname) \ + (phdr)->rec_type = REC_TYPE_PACKET;\ (phdr)->presence_flags |= WTAP_HAS_CAP_LEN;\ (phdr)->len = pletoh16(&pp->pp_PktSizeOrg) + nspr_pktracepart_v10_s;\ (phdr)->caplen = pletoh16(&pp->nsprRecordSize);\ @@ -954,6 +955,7 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 * * as the time stamps in the records are relative to\ * the previous packet.\ */\ + (phdr)->rec_type = REC_TYPE_PACKET;\ (phdr)->presence_flags = WTAP_HAS_TS;\ nsg_creltime += ns_hrtime2nsec(pletoh32(&fp->fp_RelTimeHr));\ (phdr)->ts.secs = nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);\ @@ -977,6 +979,7 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 * * as the time stamps in the records are relative to\ * the previous packet.\ */\ + (phdr)->rec_type = REC_TYPE_PACKET;\ (phdr)->presence_flags = WTAP_HAS_TS;\ nsg_creltime += ns_hrtime2nsec(pletoh32(&pp->pp_RelTimeHr));\ (phdr)->ts.secs = nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);\ @@ -1035,6 +1038,7 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 * #define TIMEDEFV20(fp,type) \ do {\ + wth->phdr.rec_type = REC_TYPE_PACKET;\ wth->phdr.presence_flags |= WTAP_HAS_TS;\ nsg_creltime += ns_hrtime2nsec(pletoh32(fp->type##_RelTimeHr));\ wth->phdr.ts.secs = nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);\ @@ -1043,6 +1047,7 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 * #define TIMEDEFV23(fp,type) \ do {\ + wth->phdr.rec_type = REC_TYPE_PACKET;\ wth->phdr.presence_flags |= WTAP_HAS_TS;\ /* access _AbsTimeHr as a 64bit value */\ nsg_creltime = pletoh64(fp->type##_AbsTimeHr);\ @@ -1052,6 +1057,7 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 * #define TIMEDEFV30(fp,type) \ do {\ + wth->phdr.rec_type = REC_TYPE_PACKET;\ wth->phdr.presence_flags |= WTAP_HAS_TS;\ /* access _AbsTimeHr as a 64bit value */\ nsg_creltime = pletoh64(fp->type##_AbsTimeHr);\ @@ -1067,6 +1073,7 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 * #define PPSIZEDEFV20(phdr,pp,ver) \ do {\ + (phdr)->rec_type = REC_TYPE_PACKET;\ (phdr)->presence_flags |= WTAP_HAS_CAP_LEN;\ (phdr)->len = pletoh16(&pp->pp_PktSizeOrg) + nspr_pktracepart_v##ver##_s;\ (phdr)->caplen = nspr_getv20recordsize((nspr_hd_v20_t *)pp);\ @@ -1094,9 +1101,10 @@ static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 * #define FPSIZEDEFV30(phdr,fp,ver)\ do {\ + (phdr)->rec_type = REC_TYPE_PACKET;\ + (phdr)->presence_flags |= WTAP_HAS_CAP_LEN;\ (phdr)->len = pletoh16(&fp->fp_PktSizeOrg) + nspr_pktracefull_v##ver##_s;\ (phdr)->caplen = nspr_getv20recordsize((nspr_hd_v20_t *)fp);\ - (phdr)->presence_flags |= WTAP_HAS_CAP_LEN;\ }while(0) #define PACKET_DESCRIBE(phdr,FPTIMEDEF,SIZEDEF,ver,enumprefix,type,structname,TYPE)\ @@ -1822,6 +1830,12 @@ static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, { nstrace_dump_t *nstrace = (nstrace_dump_t *)wdh->priv; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + if (nstrace->page_offset == 0) { /* Add the signature record and abs time record */ diff --git a/wiretap/netscreen.c b/wiretap/netscreen.c index bbb4a535e9..0d07d14c5e 100644 --- a/wiretap/netscreen.c +++ b/wiretap/netscreen.c @@ -297,6 +297,7 @@ parse_netscreen_rec_hdr(struct wtap_pkthdr *phdr, const char *line, char *cap_in char direction[2]; char cap_src[13]; + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; if (sscanf(line, "%9d.%9d: %15[a-z0-9/:.-](%1[io]) len=%9d:%12s->%12s/", diff --git a/wiretap/nettl.c b/wiretap/nettl.c index e5f159ef89..8727db106a 100644 --- a/wiretap/nettl.c +++ b/wiretap/nettl.c @@ -323,7 +323,7 @@ nettl_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) return FALSE; - /* Read record header. */ + /* Read record. */ if (!nettl_read_rec(wth, wth->random_fh, phdr, buf, err, err_info)) { /* Read error or EOF */ if (*err == 0) { @@ -581,6 +581,7 @@ nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, length, padlen); return FALSE; } + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; phdr->len = length - padlen; if (caplen < padlen) { @@ -732,6 +733,12 @@ static gboolean nettl_dump(wtap_dumper *wdh, struct nettlrec_hdr rec_hdr; guint8 dummyc[24]; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + /* Don't write anything we're not willing to read. */ if (phdr->caplen > WTAP_MAX_PACKET_SIZE) { *err = WTAP_ERR_PACKET_TOO_LARGE; diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c index 38abfab2cd..5e95e1826e 100644 --- a/wiretap/network_instruments.c +++ b/wiretap/network_instruments.c @@ -443,6 +443,7 @@ process_packet_header(wtap *wth, packet_entry_header *packet_header, struct wtap_pkthdr *phdr, int *err, gchar **err_info) { /* set the wiretap packet header fields */ + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; phdr->pkt_encap = observer_to_wtap_encap(packet_header->network_type); if(wth->file_encap == WTAP_ENCAP_FIBRE_CHANNEL_FC2_WITH_FRAME_DELIMS) { @@ -695,6 +696,12 @@ static gboolean observer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, packet_entry_header packet_header; guint64 seconds_since_2000; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + /* The captured size field is 16 bits, so there's a hard limit of 65535. */ if (phdr->caplen > 65535) { diff --git a/wiretap/netxray.c b/wiretap/netxray.c index e6dd704bb3..1a7465453d 100644 --- a/wiretap/netxray.c +++ b/wiretap/netxray.c @@ -1590,6 +1590,7 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, break; } + phdr->rec_type = REC_TYPE_PACKET; if (netxray->version_major == 0) { phdr->presence_flags = WTAP_HAS_TS; t = (double)pletoh32(&hdr.old_hdr.timelo) @@ -1738,6 +1739,12 @@ netxray_dump_1_1(wtap_dumper *wdh, guint32 t32; struct netxrayrec_1_x_hdr rec_hdr; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + /* The captured length field is 16 bits, so there's a hard limit of 65535. */ if (phdr->caplen > 65535) { @@ -1911,6 +1918,12 @@ netxray_dump_2_0(wtap_dumper *wdh, guint32 t32; struct netxrayrec_2_x_hdr rec_hdr; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + /* Don't write anything we're not willing to read. */ if (phdr->caplen > WTAP_MAX_PACKET_SIZE) { *err = WTAP_ERR_PACKET_TOO_LARGE; diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c index 8138a31f44..dd341413b9 100644 --- a/wiretap/ngsniffer.c +++ b/wiretap/ngsniffer.c @@ -1347,6 +1347,7 @@ ngsniffer_process_record(wtap *wth, gboolean is_random, guint *padding, *padding = length - size; } + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = true_size ? WTAP_HAS_TS|WTAP_HAS_CAP_LEN : WTAP_HAS_TS; phdr->len = true_size ? true_size : size; phdr->caplen = size; @@ -2073,6 +2074,12 @@ ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, guint16 start_date; struct tm *tm; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + /* The captured length field is 16 bits, so there's a hard limit of 65535. */ if (phdr->caplen > 65535) { diff --git a/wiretap/packetlogger.c b/wiretap/packetlogger.c index 313cf3e5b8..1941e981d8 100644 --- a/wiretap/packetlogger.c +++ b/wiretap/packetlogger.c @@ -157,6 +157,7 @@ packetlogger_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, return FALSE; } + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; phdr->len = pl_hdr.len - 8; diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c index a0be4a9eaa..6fd0a881e2 100644 --- a/wiretap/pcapng.c +++ b/wiretap/pcapng.c @@ -1109,6 +1109,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta iface_info = g_array_index(pn->interfaces, interface_info_t, packet.interface_id); + wblock->packet_header->rec_type = REC_TYPE_PACKET; wblock->packet_header->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID; pcapng_debug3("pcapng_read_packet_block: encapsulation = %d (%s), pseudo header size = %d.", @@ -1388,6 +1389,7 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t * pcap_get_phdr_size(iface_info.wtap_encap, &wblock->packet_header->pseudo_header)); /* No time stamp in a simple packet block; no options, either */ + wblock->packet_header->rec_type = REC_TYPE_PACKET; wblock->packet_header->presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID; wblock->packet_header->interface_id = 0; wblock->packet_header->pkt_encap = iface_info.wtap_encap; @@ -3552,6 +3554,12 @@ static gboolean pcapng_dump(wtap_dumper *wdh, phdr->pkt_encap, wtap_encap_string(phdr->pkt_encap)); + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + /* Flush any hostname resolution info we may have */ pcapng_write_name_resolution_block(wdh, err); diff --git a/wiretap/peekclassic.c b/wiretap/peekclassic.c index a10ae66fd5..4bde81adde 100644 --- a/wiretap/peekclassic.c +++ b/wiretap/peekclassic.c @@ -447,6 +447,7 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh, } /* fill in packet header values */ + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; tsecs = (time_t) (timestamp/1000000); tusecs = (guint32) (timestamp - tsecs*1000000); @@ -580,6 +581,7 @@ static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh, } /* fill in packet header values */ + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; /* timestamp is in milliseconds since reference_time */ phdr->ts.secs = peekclassic->reference_time.tv_sec diff --git a/wiretap/peektagged.c b/wiretap/peektagged.c index 05dc8beaef..ae3881ed90 100644 --- a/wiretap/peektagged.c +++ b/wiretap/peektagged.c @@ -577,6 +577,7 @@ peektagged_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, return -1; } + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; phdr->len = hdr_info.length; phdr->caplen = hdr_info.sliceLength; diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c index 6ba142485b..c22b70a682 100644 --- a/wiretap/pppdump.c +++ b/wiretap/pppdump.c @@ -319,6 +319,7 @@ static void pppdump_set_phdr(struct wtap_pkthdr *phdr, int num_bytes, direction_enum direction) { + phdr->rec_type = REC_TYPE_PACKET; phdr->len = num_bytes; phdr->caplen = num_bytes; phdr->pkt_encap = WTAP_ENCAP_PPP_WITH_PHDR; @@ -369,10 +370,10 @@ pppdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) *data_offset = state->pkt_cnt; state->pkt_cnt++; + pppdump_set_phdr(&wth->phdr, num_bytes, direction); wth->phdr.presence_flags = WTAP_HAS_TS; wth->phdr.ts.secs = state->timestamp; wth->phdr.ts.nsecs = state->tenths * 100000000; - pppdump_set_phdr(&wth->phdr, num_bytes, direction); return TRUE; } diff --git a/wiretap/radcom.c b/wiretap/radcom.c index 3e9883da57..96842d00bd 100644 --- a/wiretap/radcom.c +++ b/wiretap/radcom.c @@ -339,6 +339,7 @@ radcom_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, length = pletoh16(&hdr.length); real_length = pletoh16(&hdr.real_length); + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; tm.tm_year = pletoh16(&hdr.date.year)-1900; diff --git a/wiretap/snoop.c b/wiretap/snoop.c index 265d23f4a2..c6991d064c 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -626,6 +626,7 @@ snoop_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, break; } + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; phdr->ts.secs = g_ntohl(hdr.ts_sec); phdr->ts.nsecs = g_ntohl(hdr.ts_usec) * 1000; @@ -876,6 +877,12 @@ static gboolean snoop_dump(wtap_dumper *wdh, struct snoop_atm_hdr atm_hdr; int atm_hdrsize; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + if (wdh->encap == WTAP_ENCAP_ATM_PDUS) atm_hdrsize = sizeof (struct snoop_atm_hdr); else diff --git a/wiretap/stanag4607.c b/wiretap/stanag4607.c index d4a5ed5317..369bb31654 100644 --- a/wiretap/stanag4607.c +++ b/wiretap/stanag4607.c @@ -72,6 +72,8 @@ static gboolean stanag4607_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *p return FALSE; } + phdr->rec_type = REC_TYPE_PACKET; + /* The next 4 bytes are the packet length */ packet_size = pntoh32(&stanag_pkt_hdr[2]); phdr->caplen = packet_size; diff --git a/wiretap/tnef.c b/wiretap/tnef.c index 5bd2fa1463..b7e834eaaa 100644 --- a/wiretap/tnef.c +++ b/wiretap/tnef.c @@ -51,6 +51,7 @@ static gboolean tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, } packet_size = (int)file_size; + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ phdr->caplen = packet_size; diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c index 6fcf40270b..e649bf8fb3 100644 --- a/wiretap/toshiba.c +++ b/wiretap/toshiba.c @@ -314,6 +314,7 @@ parse_toshiba_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, return FALSE; } + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; phdr->ts.secs = hr * 3600 + min * 60 + sec; phdr->ts.nsecs = csec * 10000000; diff --git a/wiretap/visual.c b/wiretap/visual.c index cfa03bceac..c10594b615 100644 --- a/wiretap/visual.c +++ b/wiretap/visual.c @@ -350,6 +350,7 @@ visual_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, /* Get the included length of data. This includes extra headers + payload */ packet_size = pletoh16(&vpkt_hdr.incl_len); + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN; /* Set the packet time and length. */ @@ -674,6 +675,12 @@ static gboolean visual_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, guint delta_msec; guint32 packet_status; + /* We can only write packet records. */ + if (phdr->rec_type != REC_TYPE_PACKET) { + *err = WTAP_ERR_REC_TYPE_UNSUPPORTED; + return FALSE; + } + /* Don't write anything we're not willing to read. */ if (phdr->caplen > WTAP_MAX_PACKET_SIZE) { *err = WTAP_ERR_PACKET_TOO_LARGE; diff --git a/wiretap/vms.c b/wiretap/vms.c index 3684c3bbbe..4cabfdf3d8 100644 --- a/wiretap/vms.c +++ b/wiretap/vms.c @@ -400,6 +400,7 @@ parse_vms_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gch tm.tm_year -= 1900; tm.tm_isdst = -1; + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; phdr->ts.secs = mktime(&tm); phdr->ts.nsecs = csec * 10000000; diff --git a/wiretap/vwr.c b/wiretap/vwr.c index 7d0b291c62..7dad644fcb 100644 --- a/wiretap/vwr.c +++ b/wiretap/vwr.c @@ -979,6 +979,7 @@ static gboolean vwr_read_s1_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr, phdr->ts.nsecs = (int)(s_usec * 1000); phdr->pkt_encap = WTAP_ENCAP_IXVERIWAVE; + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; buffer_assure_space(buf, phdr->caplen); @@ -1335,6 +1336,7 @@ static gboolean vwr_read_s2_W_rec(vwr_t *vwr, struct wtap_pkthdr *phdr, phdr->ts.nsecs = (int)(s_usec * 1000); phdr->pkt_encap = WTAP_ENCAP_IXVERIWAVE; + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; buffer_assure_space(buf, phdr->caplen); @@ -1628,6 +1630,7 @@ static gboolean vwr_read_rec_data_ethernet(vwr_t *vwr, struct wtap_pkthdr *phdr, phdr->ts.nsecs = (int)(s_usec * 1000); phdr->pkt_encap = WTAP_ENCAP_IXVERIWAVE; + phdr->rec_type = REC_TYPE_PACKET; phdr->presence_flags = WTAP_HAS_TS; /*etap_hdr.vw_ip_length = (guint16)ip_len;*/ diff --git a/wiretap/wtap.c b/wiretap/wtap.c index c32524be80..a0117ab784 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -833,7 +833,9 @@ static const char *wtap_errlist[] = { NULL, "Uncompression error", "Internal error", - "The packet being written is too large for that format" + "The packet being written is too large for that format", + NULL, + "That record type cannot be written in that format" }; #define WTAP_ERRLIST_SIZE (sizeof wtap_errlist / sizeof wtap_errlist[0]) diff --git a/wiretap/wtap.h b/wiretap/wtap.h index 005d748304..4c12eb422c 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -916,7 +916,20 @@ union wtap_pseudo_header { struct logcat_phdr logcat; }; +/* + * Record type values. + * + * This list will expand over time, so don't assume everything will be a + * packet record or a file-type-specific record. + * + * Non-packet records might have a time stamp; other fields may only + * apply to packet records. + */ +#define REC_TYPE_PACKET 0 /**< packet */ +#define REC_TYPE_FILE_TYPE_SPECIFIC 1 /**< file-type-specific record */ + struct wtap_pkthdr { + guint rec_type; /* what type of record is this? */ guint32 presence_flags; /* what stuff do we have? */ nstime_t ts; guint32 caplen; /* data length in the file */ @@ -1634,6 +1647,9 @@ int wtap_register_encap_type(const char* name, const char* short_name); /** Not really an error: the file type being checked is from a Lua plugin, so that the code will call wslua_can_write_encap() instead if it gets this */ +#define WTAP_ERR_REC_TYPE_UNSUPPORTED -26 + /** Specified record type can't be written to that file type */ + #ifdef __cplusplus } #endif /* __cplusplus */