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 <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2014-05-24 11:28:30 -07:00
parent 33ae4cb024
commit 6db77b000f
78 changed files with 389 additions and 138 deletions

View File

@ -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);
}
}
}

View File

@ -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)

View File

@ -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 */

View File

@ -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 {

View File

@ -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);

View File

@ -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_H>) {
$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_H>) {
$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;

View File

@ -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%

View File

@ -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);

View File

@ -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),

63
file.c
View File

@ -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. */

28
file.h
View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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) {

View File

@ -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.");

View File

@ -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);

View File

@ -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()) ||

View File

@ -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;
}

View File

@ -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);

View File

@ -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.");

View File

@ -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.");

View File

@ -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) {

View File

@ -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);

View File

@ -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_) ||

View File

@ -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);

View File

@ -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;

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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 */

View File

@ -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.) */

View File

@ -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;

View File

@ -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;

View File

@ -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",

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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.) */

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
/*

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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:

View File

@ -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 */

View File

@ -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/",

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;*/

View File

@ -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])

View File

@ -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 */