wiretap: add a routine to set up REC_TYPE_PACKET records.

It sets the rec_type to REC_TYPE_PACKET, and also sets the
rec_header.packet_header.pkt_encap field to the link-layer encapsulation
value provided.  That way, wtap_reset_rec(), which doesn't know what the
type of the record will be, isn't setting a union member that might not
be the right one.

We probably want to have it set rec->block appropriately, too.

This routine could set other things in the future, as appropriate.
This commit is contained in:
Guy Harris 2025-05-17 13:04:25 -07:00
parent b737ee7e25
commit 000727ab39
75 changed files with 300 additions and 276 deletions

View File

@ -385,7 +385,7 @@ WSLUA_METHOD Dumper_dump(lua_State* L) {
wtap_rec_init(&rec, ba->len);
rec.rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(&rec, DUMPER_ENCAP(d));
rec.presence_flags = WTAP_HAS_TS;
rec.ts.secs = (unsigned int)(floor(ts));
@ -393,7 +393,6 @@ WSLUA_METHOD Dumper_dump(lua_State* L) {
rec.rec_header.packet_header.len = ba->len;
rec.rec_header.packet_header.caplen = ba->len;
rec.rec_header.packet_header.pkt_encap = DUMPER_ENCAP(d);
if (ph->wph) {
rec.rec_header.packet_header.pseudo_header = *ph->wph;
}
@ -547,12 +546,11 @@ WSLUA_METHOD Dumper_dump_current(lua_State* L) {
wtap_rec_init(&rec, tvb_captured_length(tvb));
rec.rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(&rec, lua_pinfo->rec->rec_header.packet_header.pkt_encap);
rec.presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
rec.ts = lua_pinfo->abs_ts;
rec.rec_header.packet_header.len = tvb_reported_length(tvb);
rec.rec_header.packet_header.caplen = tvb_captured_length(tvb);
rec.rec_header.packet_header.pkt_encap = lua_pinfo->rec->rec_header.packet_header.pkt_encap;
rec.rec_header.packet_header.pseudo_header = *lua_pinfo->pseudo_header;
/*

View File

@ -64,6 +64,24 @@ WSLUA_METAMETHOD FrameInfo__tostring(lua_State* L) {
WSLUA_RETURN(1); /* String of debug information. */
}
WSLUA_METHOD FrameInfo_setup_packet_rec(lua_State* L) {
/* calls wtap_setup_packet_rec() */
#define WSLUA_ARG_FrameInfo_setup_packet_rec_ENCAP 2 /* The encapsulation type to use. */
FrameInfo fi = checkFrameInfo(L,1);
int encap = wslua_checkuint32(L, WSLUA_ARG_FrameInfo_setup_packet_rec_ENCAP);
wtap_setup_packet_rec(fi->rec, encap);
/*
* Always succeeds.
*
* XXX - can a method return nothing?
*/
lua_pushboolean(L, true);
WSLUA_RETURN(1);
}
/* XXX: should this function be a method of File instead? */
WSLUA_METHOD FrameInfo_read_data(lua_State* L) {
/* Tells Wireshark to read directly from given file into frame data buffer, for length bytes. Returns true if succeeded, else false. */
@ -292,6 +310,7 @@ WSLUA_ATTRIBUTES FrameInfo_attributes[] = {
};
WSLUA_METHODS FrameInfo_methods[] = {
WSLUA_CLASS_FNREG(FrameInfo,setup_packet_rec),
WSLUA_CLASS_FNREG(FrameInfo,read_data),
{ NULL, NULL }
};

View File

@ -491,10 +491,9 @@ static bool extcap_dumper_dump(struct extcap_dumper extcap_dumper,
wtap_rec rec;
wtap_rec_init(&rec, captured_length);
wtap_setup_packet_rec(&rec, extcap_dumper.encap);
rec.rec_type = REC_TYPE_PACKET;
rec.presence_flags = WTAP_HAS_TS;
rec.ts.secs = seconds;
rec.ts.nsecs = (int) nanoseconds;
@ -513,8 +512,6 @@ static bool extcap_dumper_dump(struct extcap_dumper extcap_dumper,
rec.rec_header.packet_header.caplen = (uint32_t) captured_length;
rec.rec_header.packet_header.len = (uint32_t) reported_length;
rec.rec_header.packet_header.pkt_encap = extcap_dumper.encap;
ws_buffer_append(&rec.data, buffer, captured_length);
if (!wtap_dump(extcap_dumper.dumper.wtap, &rec, &err, &err_info)) {

View File

@ -612,9 +612,9 @@ void wtap_etl_rec_dump(char* etl_record, ULONG total_packet_length, ULONG origin
wtap_rec rec = { 0 };
wtap_rec_init(&rec, 2048); // Appropriate size?
wtap_setup_packet_rec(&rec, pkt_encap);
rec.rec_header.packet_header.caplen = total_packet_length;
rec.rec_header.packet_header.len = original_packet_length;
rec.rec_header.packet_header.pkt_encap = pkt_encap;
rec.rec_header.packet_header.interface_id = interface_id;
rec.presence_flags = WTAP_HAS_INTERFACE_ID;
rec.block = wtap_block_create(WTAP_BLOCK_PACKET);

View File

@ -350,12 +350,11 @@ LLVMFuzzerTestOneInput(const uint8_t *buf, size_t real_len)
wtap_rec_init(&rec, len);
rec.rec_type = REC_TYPE_PACKET;
/* wtap_setup_packet_rec(&rec, WTAP_ENCAP_ETHERNET); */
wtap_setup_packet_rec(&rec, INT16_MAX);
rec.rec_header.packet_header.caplen = len;
rec.rec_header.packet_header.len = len;
/* whdr.pkt_encap = WTAP_ENCAP_ETHERNET; */
rec.rec_header.packet_header.pkt_encap = INT16_MAX;
rec.presence_flags = WTAP_HAS_TS | WTAP_HAS_CAP_LEN; /* most common flags... */
ws_buffer_append(&rec.data, buf, real_len);

View File

@ -259,7 +259,7 @@ usbdump_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
}
/* Setup the per packet structure and fill it with info from this frame */
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS | WTAP_HAS_CAP_LEN;
rec->ts.secs = (uint32_t)bpf_hdr[3] << 24 | (uint32_t)bpf_hdr[2] << 16 |

View File

@ -567,9 +567,8 @@ void randpkt_loop(randpkt_example* example, uint64_t produce_count, uint64_t pac
wtap_rec_init(&rec, example->sample_length);
rec.rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(&rec, example->sample_wtap_encap);
rec.presence_flags = WTAP_HAS_TS;
rec.rec_header.packet_header.pkt_encap = example->sample_wtap_encap;
ps_header = &rec.rec_header.packet_header.pseudo_header;

View File

@ -867,7 +867,7 @@ raw_pipe_read(wtap_rec *rec, int *err, char **err_info, int64_t *data_offset) {
ptr += bytes_read;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, encap);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
if (want_pcap_pkthdr) {
rec->ts.secs = mem_hdr.ts.tv_sec;
@ -882,8 +882,6 @@ raw_pipe_read(wtap_rec *rec, int *err, char **err_info, int64_t *data_offset) {
}
bytes_needed = rec->rec_header.packet_header.caplen;
rec->rec_header.packet_header.pkt_encap = encap;
#if 0
printf("mem_hdr: %lu disk_hdr: %lu\n", sizeof(mem_hdr), sizeof(disk_hdr));
printf("tv_sec: %d (%04x)\n", (unsigned int) rec->ts.secs, (unsigned int) rec->ts.secs);

View File

@ -662,9 +662,9 @@ function Packet:set_comment(comment)
self["comment"] = comment
end
function Packet:set_wslua_fields(frame)
function Packet:set_wslua_fields(frame, capture)
frame:setup_packet_rec(capture.encap)
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
@ -1375,7 +1375,7 @@ local function read_common(funcname, file, capture, frame, position, seeking)
dprint2(funcname,": calling class object's read_data()")
phdr:read_data(file, frame, line, seeking)
if not phdr:set_wslua_fields(frame) then
if not phdr:set_wslua_fields(frame, capture) then
dprint(funcname, "failed to set Wireshark packet header info")
return
end

View File

@ -49,15 +49,13 @@ export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, const
if(exp_pdu_data->tvb_captured_length > 0){
tvb_memcpy(exp_pdu_data->pdu_tvb, packet_buf+exp_pdu_data->tlv_buffer_len, 0, exp_pdu_data->tvb_captured_length);
}
rec.rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(&rec, exp_pdu_tap_data->pkt_encap);
rec.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS;
rec.ts.secs = pinfo->abs_ts.secs;
rec.ts.nsecs = pinfo->abs_ts.nsecs;
rec.rec_header.packet_header.caplen = buffer_len;
rec.rec_header.packet_header.len = exp_pdu_data->tvb_reported_length + exp_pdu_data->tlv_buffer_len;
rec.rec_header.packet_header.pkt_encap = exp_pdu_tap_data->pkt_encap;
/* rec.opt_block is not modified by wtap_dump, but if for some reason the
* epan_get_modified_block() or pinfo->rec->block are invalidated,
* copying it here does not hurt. (Can invalidation really happen?) */

View File

@ -754,12 +754,11 @@ write_current_packet(bool cont)
* aren't really used when writing, it doesn't matter.
*/
} else {
rec.rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(&rec, info_p->encapsulation);
rec.block = wtap_block_create(WTAP_BLOCK_PACKET);
rec.rec_header.packet_header.caplen = rec.rec_header.packet_header.len = data_length;
rec.ts.secs = ts_sec;
rec.ts.nsecs = ts_nsec;
rec.rec_header.packet_header.pkt_encap = info_p->encapsulation;
rec.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS;
if (has_direction) {
wtap_block_add_uint32_option(rec.block, OPT_PKT_FLAGS, direction);

View File

@ -279,7 +279,7 @@ _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
hdr->Utc = pletoh32(&hdr->Utc);
hdr->NanoSecondes = pletoh32(&hdr->NanoSecondes);
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->ts.secs = hdr->Utc;

View File

@ -329,10 +329,10 @@ aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
packet_size = rec_size - (uint32_t)(sizeof *hdr - sizeof hdr->rec_size);
msecs = pletoh32(hdr->timestamp);
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
msecs = pletoh32(hdr->timestamp);
rec->ts.secs = aethra->start + (msecs / 1000);
rec->ts.nsecs = (msecs % 1000) * 1000000;
rec->rec_header.packet_header.caplen = packet_size;

View File

@ -303,14 +303,13 @@ wtap_open_return_val ascend_open(wtap *wth, int *err, char **err_info)
/* Parse the capture file.
Returns true if we got a packet, false otherwise. */
static bool
parse_ascend(ascend_t *ascend, FILE_T fh, wtap_rec *rec,
unsigned length, int64_t *next_packet_seek_start_ret,
int *err, char **err_info)
parse_ascend(ascend_t *ascend, wtap *wth, FILE_T fh, wtap_rec *rec,
int64_t *next_packet_seek_start_ret, int *err, char **err_info)
{
ascend_state_t parser_state = {0};
int retval;
ws_buffer_assure_space(&rec->data, length);
ws_buffer_assure_space(&rec->data, wth->snapshot_length);
parser_state.fh = fh;
parser_state.pseudo_header = &rec->rec_header.packet_header.pseudo_header.ascend;
@ -366,7 +365,7 @@ parse_ascend(ascend_t *ascend, FILE_T fh, wtap_rec *rec,
if (ascend->inittime > parser_state.secs)
ascend->inittime -= parser_state.secs;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
rec->ts.secs = parser_state.secs + ascend->inittime;
@ -416,7 +415,7 @@ static bool ascend_read(wtap *wth, wtap_rec *rec, int *err,
/* EOF or read error */
return false;
}
if (!parse_ascend(ascend, wth->fh, rec, wth->snapshot_length,
if (!parse_ascend(ascend, wth, wth->fh, rec,
&ascend->next_packet_seek_start, err, err_info))
return false;
@ -440,8 +439,7 @@ static bool ascend_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return false;
if (!parse_ascend(ascend, wth->random_fh, rec, wth->snapshot_length,
NULL, err, err_info))
if (!parse_ascend(ascend, wth, wth->random_fh, rec, NULL, err, err_info))
return false;
/* Flex might have gotten an EOF and caused *err to be set to

View File

@ -196,7 +196,7 @@ autosar_dlt_read_block(autosar_dlt_params_t *params, int64_t start_pos, int *err
ws_buffer_append(&params->rec->data, tmpbuf, (size_t)(item_header.length));
g_free(tmpbuf);
params->rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(params->rec, WTAP_ENCAP_AUTOSAR_DLT);
params->rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
params->rec->presence_flags = WTAP_HAS_TS | WTAP_HAS_CAP_LEN | WTAP_HAS_INTERFACE_ID;
params->rec->tsprec = WTAP_TSPREC_USEC;
@ -205,7 +205,6 @@ autosar_dlt_read_block(autosar_dlt_params_t *params, int64_t start_pos, int *err
params->rec->rec_header.packet_header.caplen = (uint32_t)(item_header.length + sizeof header);
params->rec->rec_header.packet_header.len = (uint32_t)(item_header.length + sizeof header);
params->rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_AUTOSAR_DLT;
params->rec->rec_header.packet_header.interface_id = autosar_dlt_lookup_interface(params, header.ecu_id);
return true;

View File

@ -1298,7 +1298,7 @@ blf_read_bytes(blf_params_t *params, uint64_t real_pos, void *target_buffer, uin
static void
blf_init_rec(blf_params_t *params, uint32_t flags, uint64_t object_timestamp, int pkt_encap, uint16_t channel, uint16_t hwchannel, unsigned caplen, unsigned len) {
params->rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(params->rec, pkt_encap);
params->rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
params->rec->presence_flags = WTAP_HAS_CAP_LEN | WTAP_HAS_INTERFACE_ID;
params->rec->ts_rel_cap_valid = false;
@ -1343,7 +1343,6 @@ blf_init_rec(blf_params_t *params, uint32_t flags, uint64_t object_timestamp, in
tmp_ts.nsecs = params->blf_data->start_offset_ns % (1000 * 1000 * 1000);
nstime_delta(&params->rec->ts_rel_cap, &params->rec->ts, &tmp_ts);
params->rec->rec_header.packet_header.pkt_encap = pkt_encap;
params->rec->rec_header.packet_header.interface_id = blf_lookup_interface(params, pkt_encap, channel, hwchannel, NULL);
/* TODO: before we had to remove comments and verdict here to not leak memory but APIs have changed ... */

View File

@ -202,7 +202,7 @@ static bool btsnoop_read_record(wtap *wth, FILE_T fh,
ts = GINT64_FROM_BE(hdr.ts_usec);
ts -= KUnixTimeBase;
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
rec->ts.secs = (unsigned)(ts / 1000000);

View File

@ -47,7 +47,8 @@ void register_busmaster(void);
*/
static bool
busmaster_gen_packet(wtap_rec *rec,
busmaster_gen_packet(wtap *wth,
wtap_rec *rec,
const busmaster_priv_t *priv_entry, const msg_t *msg,
int *err, char **err_info)
{
@ -155,7 +156,7 @@ busmaster_gen_packet(wtap_rec *rec,
has_ts = true;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = has_ts ? WTAP_HAS_TS : 0;
rec->ts.secs = secs;
@ -362,7 +363,7 @@ busmaster_read(wtap *wth, wtap_rec *rec, int *err, char **err_info,
case LOG_ENTRY_MSG:
is_msg = true;
priv_entry = busmaster_find_priv_entry(wth->priv, *data_offset);
is_ok = busmaster_gen_packet(rec, priv_entry, &state.msg, err, err_info);
is_ok = busmaster_gen_packet(wth, rec, priv_entry, &state.msg, err, err_info);
break;
case LOG_ENTRY_EOF:
case LOG_ENTRY_ERROR:
@ -416,7 +417,7 @@ busmaster_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
return false;
}
return busmaster_gen_packet(rec, priv_entry, &state.msg, err, err_info);
return busmaster_gen_packet(wth, rec, priv_entry, &state.msg, err, err_info);
}
static const struct supported_block_type busmaster_blocks_supported[] = {

View File

@ -347,7 +347,7 @@ create_pseudo_hdr(uint8_t *buf, uint8_t dat_trans_type, uint16_t dat_len,
static bool
camins_read_packet(FILE_T fh, wtap_rec *rec,
camins_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
uint64_t *time_us, int *err, char **err_info)
{
uint8_t dat_trans_type;
@ -384,10 +384,9 @@ camins_read_packet(FILE_T fh, wtap_rec *rec,
return false;
offset += bytes_read;
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = 0; /* we may or may not have a time stamp */
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_DVBCI;
if (time_us) {
rec->presence_flags = WTAP_HAS_TS;
rec->ts.secs = (time_t)(*time_us / (1000 * 1000));
@ -406,7 +405,7 @@ camins_read(wtap *wth, wtap_rec *rec, int *err,
{
*data_offset = file_tell(wth->fh);
return camins_read_packet(wth->fh, rec, (uint64_t *)(wth->priv),
return camins_read_packet(wth, wth->fh, rec, (uint64_t *)(wth->priv),
err, err_info);
}
@ -418,7 +417,7 @@ camins_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err))
return false;
return camins_read_packet(wth->random_fh, rec, NULL, err, err_info);
return camins_read_packet(wth, wth->random_fh, rec, NULL, err, err_info);
}

View File

@ -36,7 +36,7 @@ void register_candump(void);
*/
static bool
candump_gen_packet(wtap_rec *rec, const msg_t *msg, int *err, char **err_info)
candump_gen_packet(wtap *wth, wtap_rec *rec, const msg_t *msg, int *err, char **err_info)
{
/* Generate Exported PDU tags for the packet info */
ws_buffer_clean(&rec->data);
@ -87,7 +87,7 @@ candump_gen_packet(wtap_rec *rec, const msg_t *msg, int *err, char **err_info)
ws_buffer_append(&rec->data, (uint8_t *)&can_frame, sizeof(can_frame));
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->ts = msg->ts;
@ -203,7 +203,7 @@ candump_read(wtap *wth, wtap_rec *rec, int *err, char **err_info,
candump_debug_printf("%s: Stopped at offset %" PRIi64 "\n", G_STRFUNC, file_tell(wth->fh));
#endif
return candump_gen_packet(rec, &msg, err, err_info);
return candump_gen_packet(wth, rec, &msg, err, err_info);
}
static bool
@ -227,7 +227,7 @@ candump_seek_read(wtap *wth , int64_t seek_off, wtap_rec *rec,
if (!candump_parse(wth->random_fh, &msg, NULL, err, err_info))
return false;
return candump_gen_packet(rec, &msg, err, err_info);
return candump_gen_packet(wth, rec, &msg, err, err_info);
}
static const struct supported_block_type candump_blocks_supported[] = {

View File

@ -419,7 +419,7 @@ capsa_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
*/
rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0;
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->rec_header.packet_header.caplen = packet_size;
rec->rec_header.packet_header.len = orig_size;

View File

@ -1287,13 +1287,10 @@ process_parsed_line(wtap *wth, const dct2000_file_externals_t *file_externals,
size_t length;
uint8_t *frame_buffer;
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
/* Make sure all packets go to Catapult DCT2000 dissector */
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_CATAPULT_DCT2000;
/* Fill in timestamp (capture base + packet offset) */
rec->ts.secs = file_externals->start_secs + seconds;
if ((file_externals->start_usecs + useconds) >= 1000000) {

View File

@ -789,7 +789,7 @@ cllog_read_common(wtap *wth, FILE_T fh, wtap_rec *rec, int *err, char **err_info
return false;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;

View File

@ -148,6 +148,10 @@ commview_ncf_read_packet(FILE_T fh, wtap_rec *rec,
if(!commview_ncf_read_header(&cv_hdr, fh, err, err_info))
return false;
wtap_setup_packet_rec(rec, WTAP_ENCAP_UNKNOWN);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
/*
* The maximum value of cv_hdr.data_len is 65535, which is less
* than WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to
@ -314,8 +318,6 @@ commview_ncf_read_packet(FILE_T fh, wtap_rec *rec,
tm.tm_sec = cv_hdr.seconds;
tm.tm_isdst = -1;
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->rec_header.packet_header.len = cv_hdr.data_len;
@ -790,6 +792,9 @@ commview_ncfx_read_packet(FILE_T fh, wtap_rec *rec,
if (!commview_ncfx_read_header(&cv_hdr, fh, err, err_info))
return false;
wtap_setup_packet_rec(rec, WTAP_ENCAP_UNKNOWN);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
/* Amount of data remaining in the record, after the header */
length_remaining = cv_hdr.data_len - COMMVIEW_NCFX_HEADER_SIZE;
@ -1012,8 +1017,6 @@ commview_ncfx_read_packet(FILE_T fh, wtap_rec *rec,
tm.tm_sec = cv_hdr.seconds;
tm.tm_isdst = -1;
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
if (length_remaining > WTAP_MAX_PACKET_SIZE_STANDARD) {

View File

@ -153,7 +153,7 @@ static bool cosine_read(wtap *wth, wtap_rec *rec,
int *err, char **err_info, int64_t *data_offset);
static bool cosine_seek_read(wtap *wth, int64_t seek_off,
wtap_rec *rec, int *err, char **err_info);
static bool parse_cosine_packet(FILE_T fh, wtap_rec *rec,
static bool parse_cosine_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
char *line, int *err, char **err_info);
static int parse_single_hex_dump_line(char* rec, uint8_t *buf,
unsigned byte_offset);
@ -291,7 +291,7 @@ static bool cosine_read(wtap *wth, wtap_rec *rec,
*data_offset = offset;
/* Parse the header and convert the ASCII hex dump to binary data */
return parse_cosine_packet(wth->fh, rec, line, err, err_info);
return parse_cosine_packet(wth, wth->fh, rec, line, err, err_info);
}
/* Used to read packets in random-access fashion */
@ -313,7 +313,7 @@ cosine_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
}
/* Parse the header and convert the ASCII hex dump to binary data */
return parse_cosine_packet(wth->random_fh, rec, line, err, err_info);
return parse_cosine_packet(wth, wth->random_fh, rec, line, err, err_info);
}
/* Parses a packet record header. There are two possible formats:
@ -322,7 +322,7 @@ cosine_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
2) output to PE without date and time
l2-tx (FR:3/7/1:1), Length:18, Pro:0, Off:0, Pri:0, RM:0, Err:0 [0x4000, 0x0] */
static bool
parse_cosine_packet(FILE_T fh, wtap_rec *rec,
parse_cosine_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
char *line, int *err, char **err_info)
{
union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header;
@ -381,7 +381,7 @@ parse_cosine_packet(FILE_T fh, wtap_rec *rec,
return false;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
tm.tm_year = yy - 1900;

View File

@ -34,7 +34,7 @@ static bool csids_read(wtap *wth, wtap_rec *rec,
int *err, char **err_info, int64_t *data_offset);
static bool csids_seek_read(wtap *wth, int64_t seek_off,
wtap_rec *rec, int *err, char **err_info);
static bool csids_read_packet(FILE_T fh, csids_t *csids,
static bool csids_read_packet(wtap *wth, FILE_T fh, csids_t *csids,
wtap_rec *rec, int *err, char **err_info);
struct csids_header {
@ -142,7 +142,7 @@ static bool csids_read(wtap *wth, wtap_rec *rec,
*data_offset = file_tell(wth->fh);
return csids_read_packet( wth->fh, csids, rec, err, err_info );
return csids_read_packet( wth, wth->fh, csids, rec, err, err_info );
}
/* Used to read packets in random-access fashion */
@ -158,7 +158,7 @@ csids_seek_read(wtap *wth,
if( file_seek( wth->random_fh, seek_off, SEEK_SET, err ) == -1 )
return false;
if( !csids_read_packet( wth->random_fh, csids, rec, err, err_info ) ) {
if( !csids_read_packet( wth, wth->random_fh, csids, rec, err, err_info ) ) {
if( *err == 0 )
*err = WTAP_ERR_SHORT_READ;
return false;
@ -167,7 +167,7 @@ csids_seek_read(wtap *wth,
}
static bool
csids_read_packet(FILE_T fh, csids_t *csids, wtap_rec *rec,
csids_read_packet(wtap *wth, FILE_T fh, csids_t *csids, wtap_rec *rec,
int *err, char **err_info)
{
struct csids_header hdr;
@ -183,7 +183,7 @@ csids_read_packet(FILE_T fh, csids_t *csids, wtap_rec *rec,
* it.
*/
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->rec_header.packet_header.len = hdr.caplen;

View File

@ -63,7 +63,7 @@ static bool daintree_sna_read(wtap *wth, wtap_rec *rec,
static bool daintree_sna_seek_read(wtap *wth, int64_t seek_off,
wtap_rec *rec, int *err, char **err_info);
static bool daintree_sna_read_packet(FILE_T fh, wtap_rec *rec,
static bool daintree_sna_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
int *err, char **err_info);
static int daintree_sna_file_type_subtype = -1;
@ -127,7 +127,7 @@ daintree_sna_read(wtap *wth, wtap_rec *rec,
*data_offset = file_tell(wth->fh);
/* parse that line and the following packet data */
return daintree_sna_read_packet(wth->fh, rec, err, err_info);
return daintree_sna_read_packet(wth, wth->fh, rec, err, err_info);
}
/* Read the capture file randomly
@ -140,7 +140,7 @@ daintree_sna_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
return false;
/* parse that line and the following packet data */
return daintree_sna_read_packet(wth->random_fh, rec, err, err_info);
return daintree_sna_read_packet(wth, wth->random_fh, rec, err, err_info);
}
/* Read a header line, scan it, and fill in a struct wtap_rec.
@ -148,7 +148,7 @@ daintree_sna_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
* sanity-check its length against what we assume is the packet length field,
* and copy it into a Buffer. */
static bool
daintree_sna_read_packet(FILE_T fh, wtap_rec *rec, int *err, char **err_info)
daintree_sna_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, int *err, char **err_info)
{
uint64_t seconds;
int useconds;
@ -167,7 +167,7 @@ daintree_sna_read_packet(FILE_T fh, wtap_rec *rec, int *err, char **err_info)
}
} while (readLine[0] == COMMENT_LINE);
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;

View File

@ -74,7 +74,7 @@ static bool dbs_etherwatch_read(wtap *wth, wtap_rec *rec,
int *err, char **err_info, int64_t *data_offset);
static bool dbs_etherwatch_seek_read(wtap *wth, int64_t seek_off,
wtap_rec *rec, int *err, char **err_info);
static bool parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec,
static bool parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
int *err, char **err_info);
static unsigned parse_single_hex_dump_line(char* rec, uint8_t *buf,
int byte_offset);
@ -206,7 +206,7 @@ static bool dbs_etherwatch_read(wtap *wth, wtap_rec *rec,
*data_offset = offset;
/* Parse the packet */
return parse_dbs_etherwatch_packet(wth->fh, rec, err, err_info);
return parse_dbs_etherwatch_packet(wth, wth->fh, rec, err, err_info);
}
/* Used to read packets in random-access fashion */
@ -217,7 +217,7 @@ dbs_etherwatch_seek_read(wtap *wth, int64_t seek_off,
if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
return false;
return parse_dbs_etherwatch_packet(wth->random_fh, rec, err, err_info);
return parse_dbs_etherwatch_packet(wth, wth->random_fh, rec, err, err_info);
}
/* Parse a packet */
@ -265,7 +265,7 @@ unnumbered. Unnumbered has length 1, numbered 2.
#define CTL_UNNUMB_MASK 0x03
#define CTL_UNNUMB_VALUE 0x03
static bool
parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec,
parse_dbs_etherwatch_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
int *err, char **err_info)
{
uint8_t *pd;
@ -433,7 +433,7 @@ parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec,
pd[length_pos+1] = (length) & 0xFF;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;

View File

@ -226,7 +226,7 @@ wtap_open_return_val dct3trace_open(wtap *wth, int *err, char **err_info)
}
static bool dct3trace_get_packet(FILE_T fh, wtap_rec *rec,
static bool dct3trace_get_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
int *err, char **err_info)
{
char line[1024];
@ -249,7 +249,7 @@ static bool dct3trace_get_packet(FILE_T fh, wtap_rec *rec,
if( have_data )
{
/* We've got a full packet! */
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = 0; /* no time stamp, no separate "on the wire" length */
rec->ts.secs = 0;
@ -386,7 +386,7 @@ static bool dct3trace_read(wtap *wth, wtap_rec *rec,
{
*data_offset = file_tell(wth->fh);
return dct3trace_get_packet(wth->fh, rec, err, err_info);
return dct3trace_get_packet(wth, wth->fh, rec, err, err_info);
}
@ -399,7 +399,7 @@ static bool dct3trace_seek_read(wtap *wth, int64_t seek_off,
return false;
}
return dct3trace_get_packet(wth->random_fh, rec, err, err_info);
return dct3trace_get_packet(wth, wth->random_fh, rec, err, err_info);
}
static const struct supported_block_type dct3trace_blocks_supported[] = {

View File

@ -105,7 +105,7 @@ static bool dpa400_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
get_ts(&hdr, &rec->ts);
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->rec_header.packet_header.caplen = rec->rec_header.packet_header.len = 0;
@ -134,7 +134,7 @@ static bool dpa400_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
ws_buffer_append(&rec->data, &chunk[0], 1);
ctr++;
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->rec_header.packet_header.caplen = rec->rec_header.packet_header.len = ctr;
@ -172,7 +172,7 @@ static bool dpa400_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
ws_buffer_append(&rec->data, &chunk[0], 1);
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->rec_header.packet_header.caplen = rec->rec_header.packet_header.len = ctr;
@ -183,7 +183,7 @@ static bool dpa400_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
case DPA400_TS_OVERFLOW: {
get_ts_overflow(&rec->ts);
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->rec_header.packet_header.caplen = rec->rec_header.packet_header.len = ctr;

View File

@ -142,7 +142,7 @@ wtap_open_return_val ems_open(wtap *wth, int *err, char **err_info) {
return WTAP_OPEN_NOT_MINE;
}
static bool ems_read_message(FILE_T fh, wtap_rec *rec,
static bool ems_read_message(wtap *wth, FILE_T fh, wtap_rec *rec,
int *err, char **err_info) {
ems_line line;
@ -162,7 +162,7 @@ static bool ems_read_message(FILE_T fh, wtap_rec *rec,
ws_buffer_append(&rec->data, line, end - line);
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->rec_header.packet_header.len = (uint32_t) (end - line);
@ -186,7 +186,7 @@ static bool ems_read(wtap *wth, wtap_rec *rec, int *err, char **err_info,
*offset = file_tell(wth->fh);
ws_debug("reading at offset %" PRId64, *offset);
if (!ems_read_message(wth->fh, rec, err, err_info)) {
if (!ems_read_message(wth, wth->fh, rec, err, err_info)) {
return false;
}
@ -201,7 +201,7 @@ static bool ems_seek_read(wtap *wth, int64_t offset, wtap_rec *rec,
return false;
}
if (!ems_read_message(wth->random_fh, rec, err, err_info)) {
if (!ems_read_message(wth, wth->random_fh, rec, err, err_info)) {
return false;
}

View File

@ -722,7 +722,7 @@ static bool erf_read_header(wtap *wth, FILE_T fh,
uint64_t ts = pletoh64(&erf_header->ts);
/*if ((erf_header->type & 0x7f) != ERF_TYPE_META || wth->file_type_subtype != file_type_subtype_erf) {*/
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
/*
* XXX: ERF_TYPE_META records should ideally be FT_SPECIFIC for display

View File

@ -22,7 +22,7 @@ void register_eri_enb_log(void);
#define MAX_LINE_LENGTH 131072
static bool eri_enb_log_get_packet(FILE_T fh, wtap_rec* rec,
static bool eri_enb_log_get_packet(wtap *wth, FILE_T fh, wtap_rec* rec,
int* err _U_, char** err_info _U_)
{
static char line[MAX_LINE_LENGTH];
@ -57,7 +57,7 @@ static bool eri_enb_log_get_packet(FILE_T fh, wtap_rec* rec,
rec->presence_flags = 0; /* no time stamp, no separate "on the wire" length */
}
/* We've got a full packet! */
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->rec_header.packet_header.caplen = length;
rec->rec_header.packet_header.len = length;
@ -79,7 +79,7 @@ static bool eri_enb_log_read(wtap* wth, wtap_rec* rec,
{
*data_offset = file_tell(wth->fh);
return eri_enb_log_get_packet(wth->fh, rec, err, err_info);
return eri_enb_log_get_packet(wth, wth->fh, rec, err, err_info);
}
/* Used to read packets in random-access fashion */
@ -91,7 +91,7 @@ static bool eri_enb_log_seek_read(wtap* wth, int64_t seek_off,
return false;
}
return eri_enb_log_get_packet(wth->random_fh, rec, err, err_info);
return eri_enb_log_get_packet(wth, wth->random_fh, rec, err, err_info);
}
wtap_open_return_val

View File

@ -188,6 +188,9 @@ read_eyesdn_rec(FILE_T fh, wtap_rec *rec, int *err, char **err_info)
if (!esc_read(fh, hdr, EYESDN_HDR_LENGTH, err, err_info))
return false;
wtap_setup_packet_rec(rec, WTAP_ENCAP_UNKNOWN);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
/* extract information from header */
usecs = pntoh24(&hdr[0]);
#ifdef TV64BITS
@ -296,8 +299,6 @@ read_eyesdn_rec(FILE_T fh, wtap_rec *rec, int *err, char **err_info)
return false;
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->ts.secs = secs;
rec->ts.nsecs = usecs * 1000;

View File

@ -25,7 +25,7 @@ struct dump_hdr {
#define DUMP_HDR_SIZE (sizeof(struct dump_hdr))
static bool hcidump_read_packet(FILE_T fh, wtap_rec *rec,
static bool hcidump_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
int *err, char **err_info)
{
struct dump_hdr dh;
@ -46,7 +46,7 @@ static bool hcidump_read_packet(FILE_T fh, wtap_rec *rec,
return false;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->ts.secs = GUINT32_FROM_LE(dh.ts_sec);
@ -64,7 +64,7 @@ static bool hcidump_read(wtap *wth, wtap_rec *rec,
{
*data_offset = file_tell(wth->fh);
return hcidump_read_packet(wth->fh, rec, err, err_info);
return hcidump_read_packet(wth, wth->fh, rec, err, err_info);
}
static bool hcidump_seek_read(wtap *wth, int64_t seek_off,
@ -73,7 +73,7 @@ static bool hcidump_seek_read(wtap *wth, int64_t seek_off,
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return false;
return hcidump_read_packet(wth->random_fh, rec, err, err_info);
return hcidump_read_packet(wth, wth->random_fh, rec, err, err_info);
}
wtap_open_return_val hcidump_open(wtap *wth, int *err, char **err_info)

View File

@ -242,7 +242,7 @@ i4b_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec, int *err, char **err_info)
return false;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;

View File

@ -141,7 +141,7 @@ ipfix_read_message_header(ipfix_message_header_t *pfx_hdr, FILE_T fh, int *err,
* errors (EOF is ok, since return value is still false).
*/
static bool
ipfix_read_message(FILE_T fh, wtap_rec *rec, int *err, char **err_info)
ipfix_read_message(wtap *wth, FILE_T fh, wtap_rec *rec, int *err, char **err_info)
{
ipfix_message_header_t msg_hdr;
@ -153,7 +153,7 @@ ipfix_read_message(FILE_T fh, wtap_rec *rec, int *err, char **err_info)
* to check it.
*/
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->rec_header.packet_header.len = msg_hdr.message_length;
@ -292,7 +292,7 @@ ipfix_read(wtap *wth, wtap_rec *rec, int *err, char **err_info,
*data_offset = file_tell(wth->fh);
ws_debug("offset is initially %" PRId64, *data_offset);
if (!ipfix_read_message(wth->fh, rec, err, err_info)) {
if (!ipfix_read_message(wth, wth->fh, rec, err, err_info)) {
ws_debug("couldn't read message header with code: %d\n, and error '%s'",
*err, *err_info);
return false;
@ -316,7 +316,7 @@ ipfix_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
ws_debug("reading at offset %" PRIu64, seek_off);
if (!ipfix_read_message(wth->random_fh, rec, err, err_info)) {
if (!ipfix_read_message(wth, wth->random_fh, rec, err, err_info)) {
ws_debug("couldn't read message header");
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;

View File

@ -232,6 +232,9 @@ iptrace_read_rec_1_0(wtap *wth, FILE_T fh, wtap_rec *rec,
return false;
}
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
/*
* The if_type field of the frame header appears to be an SNMP
* ifType value giving the type of the interface. Check out the
@ -287,8 +290,6 @@ iptrace_read_rec_1_0(wtap *wth, FILE_T fh, wtap_rec *rec,
return false;
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS | WTAP_HAS_INTERFACE_ID;
rec->rec_header.packet_header.len = packet_size;
rec->rec_header.packet_header.caplen = packet_size;
@ -486,6 +487,9 @@ iptrace_read_rec_2_0(wtap *wth, FILE_T fh, wtap_rec *rec,
return false;
}
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
/*
* The if_type field of the frame header appears to be an SNMP
* ifType value giving the type of the interface. Check out the
@ -559,8 +563,6 @@ iptrace_read_rec_2_0(wtap *wth, FILE_T fh, wtap_rec *rec,
return false;
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS | WTAP_HAS_INTERFACE_ID;
rec->rec_header.packet_header.len = packet_size;
rec->rec_header.packet_header.caplen = packet_size;

View File

@ -765,7 +765,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, wtap_rec *rec,
return false;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_CAP_LEN;
@ -790,7 +790,6 @@ iseries_parse_packet (wtap * wth, FILE_T fh, wtap_rec *rec,
}
rec->rec_header.packet_header.len = pkt_len;
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ETHERNET;
rec->rec_header.packet_header.pseudo_header.eth.fcs_len = -1;
/*

View File

@ -567,7 +567,7 @@ memiszero(const void *ptr, size_t count)
}
static bool
process_packet_data(wtap_rec *rec, uint8_t *buffer,
process_packet_data(wtap *wth, wtap_rec *rec, uint8_t *buffer,
unsigned record_len, k12_t *k12, int *err, char **err_info)
{
uint32_t type;
@ -595,7 +595,7 @@ process_packet_data(wtap_rec *rec, uint8_t *buffer,
return false;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
@ -725,7 +725,7 @@ static bool k12_read(wtap *wth, wtap_rec *rec, int *err, char **err_info, int64_
} while ( ((type & K12_MASK_PACKET) != K12_REC_PACKET && (type & K12_MASK_PACKET) != K12_REC_D0020) || !src_id || !src_desc );
return process_packet_data(rec, buffer, (unsigned)len, k12, err, err_info);
return process_packet_data(wth, rec, buffer, (unsigned)len, k12, err, err_info);
}
@ -755,7 +755,7 @@ static bool k12_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec, int *err,
buffer = k12->rand_read_buff;
status = process_packet_data(rec, buffer, (unsigned)len, k12, err, err_info);
status = process_packet_data(wth, rec, buffer, (unsigned)len, k12, err, err_info);
K12_DBG(5,("k12_seek_read: DONE OK"));

View File

@ -251,7 +251,7 @@ static bool
k12text_set_headers(wtap_rec *rec, k12text_state_t *state,
int *err, char **err_info)
{
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, state->g_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
@ -260,8 +260,6 @@ k12text_set_headers(wtap_rec *rec, k12text_state_t *state,
rec->rec_header.packet_header.caplen = rec->rec_header.packet_header.len = state->ii;
rec->rec_header.packet_header.pkt_encap = state->g_encap;
/* The file-encap is WTAP_ENCAP_PER_PACKET */
switch(state->g_encap) {
case WTAP_ENCAP_ETHERNET:

View File

@ -551,7 +551,7 @@ static bool lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
return false;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;

View File

@ -1366,7 +1366,7 @@ libpcap_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
orig_size -= phdr_len;
packet_size -= phdr_len;
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;

View File

@ -262,9 +262,7 @@ bool log3gpp_read(wtap* wth, wtap_rec* rec,
snprintf(timestamp_string, 32, "%d.%04d", seconds, useconds/100);
/* All packets go to 3GPP protocol stub dissector */
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_LOG_3GPP;
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
@ -387,9 +385,7 @@ log3gpp_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
char timestamp_string[32];
snprintf(timestamp_string, 32, "%d.%04d", seconds, useconds/100);
/* Make sure all packets go to log3gpp dissector */
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_LOG_3GPP;
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;

View File

@ -156,9 +156,10 @@ int logcat_exported_pdu_length(const uint8_t *pd) {
return length;
}
static bool logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh,
wtap_rec *rec, int *err, char **err_info)
static bool logcat_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
int *err, char **err_info)
{
struct logcat_phdr *logcat = (struct logcat_phdr *) wth->priv;
int packet_size;
uint16_t payload_length;
unsigned tmp[2];
@ -196,7 +197,7 @@ static bool logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh,
return false;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->ts.secs = (time_t) GINT32_FROM_LE(log_entry->sec);
@ -214,8 +215,7 @@ static bool logcat_read(wtap *wth, wtap_rec *rec,
{
*data_offset = file_tell(wth->fh);
return logcat_read_packet((struct logcat_phdr *) wth->priv, wth->fh,
rec, err, err_info);
return logcat_read_packet(wth, wth->fh, rec, err, err_info);
}
static bool logcat_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
@ -224,8 +224,7 @@ static bool logcat_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return false;
if (!logcat_read_packet((struct logcat_phdr *) wth->priv, wth->random_fh,
rec, err, err_info)) {
if (!logcat_read_packet(wth, wth->random_fh, rec, err, err_info)) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return false;

View File

@ -181,7 +181,7 @@ static void get_time(char *string, wtap_rec *rec) {
}
}
static bool logcat_text_read_packet(FILE_T fh, wtap_rec *rec,
static bool logcat_text_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
int file_type) {
int8_t *pd;
char *cbuff;
@ -223,7 +223,7 @@ static bool logcat_text_read_packet(FILE_T fh, wtap_rec *rec,
g_free(lbuff);
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->rec_header.packet_header.caplen = (uint32_t)strlen(cbuff);
rec->rec_header.packet_header.len = rec->rec_header.packet_header.caplen;
@ -253,7 +253,7 @@ static bool logcat_text_read(wtap *wth, wtap_rec *rec,
int *err _U_ , char **err_info _U_, int64_t *data_offset) {
*data_offset = file_tell(wth->fh);
return logcat_text_read_packet(wth->fh, rec, wth->file_type_subtype);
return logcat_text_read_packet(wth, wth->fh, rec, wth->file_type_subtype);
}
static bool logcat_text_seek_read(wtap *wth, int64_t seek_off,
@ -261,7 +261,7 @@ static bool logcat_text_seek_read(wtap *wth, int64_t seek_off,
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
return false;
if (!logcat_text_read_packet(wth->random_fh, rec, wth->file_type_subtype)) {
if (!logcat_text_read_packet(wth, wth->random_fh, rec, wth->file_type_subtype)) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return false;

View File

@ -52,12 +52,14 @@ static int mp2t_file_type_subtype = -1;
void register_mp2t(void);
static bool
mp2t_read_packet(mp2t_filetype_t *mp2t, FILE_T fh, int64_t offset,
wtap_rec *rec, int *err,
mp2t_read_packet(wtap *wth, FILE_T fh, int64_t offset, wtap_rec *rec, int *err,
char **err_info)
{
mp2t_filetype_t *mp2t;
uint64_t tmp;
mp2t = (mp2t_filetype_t*) wth->priv;
/*
* MP2T_SIZE will always be less than WTAP_MAX_PACKET_SIZE_STANDARD, so
* we don't have to worry about the packet being too big.
@ -66,7 +68,7 @@ mp2t_read_packet(mp2t_filetype_t *mp2t, FILE_T fh, int64_t offset,
if (!wtap_read_bytes_or_eof(fh, ws_buffer_start_ptr(&rec->data), MP2T_SIZE, err, err_info))
return false;
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
/* XXX - relative, not absolute, time stamps */
@ -118,7 +120,7 @@ mp2t_read(wtap *wth, wtap_rec *rec, int *err,
*data_offset = file_tell(wth->fh);
if (!mp2t_read_packet(mp2t, wth->fh, *data_offset, rec, err, err_info)) {
if (!mp2t_read_packet(wth, wth->fh, *data_offset, rec, err, err_info)) {
return false;
}
@ -136,15 +138,11 @@ static bool
mp2t_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
int *err, char **err_info)
{
mp2t_filetype_t *mp2t;
if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err)) {
return false;
}
mp2t = (mp2t_filetype_t*) wth->priv;
if (!mp2t_read_packet(mp2t, wth->random_fh, seek_off, rec, err, err_info)) {
if (!mp2t_read_packet(wth, wth->random_fh, seek_off, rec, err, err_info)) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return false;

View File

@ -238,7 +238,7 @@ mpeg_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
if (!wtap_read_bytes_buffer(fh, &rec->data, packet_size, err, err_info))
return false;
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = 0; /* we may or may not have a time stamp */

View File

@ -90,7 +90,7 @@ void register_mplog(void);
- if two blocks of our packet's block type are more than 200us apart,
we treat this as a packet boundary as described above
*/
static bool mplog_read_packet(FILE_T fh, wtap_rec *rec,
static bool mplog_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
int *err, char **err_info)
{
uint8_t *p, *start_p;
@ -173,9 +173,8 @@ static bool mplog_read_packet(FILE_T fh, wtap_rec *rec,
start_p[2] = pkt_bytes >> 8;
start_p[3] = pkt_bytes & 0xFF;
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISO14443;
rec->presence_flags = WTAP_HAS_TS | WTAP_HAS_CAP_LEN;
rec->ts.secs = (time_t)((pkt_ctr*10)/(1000*1000*1000));
rec->ts.nsecs = (int)((pkt_ctr*10)%(1000*1000*1000));
@ -192,7 +191,7 @@ mplog_read(wtap *wth, wtap_rec *rec, int *err, char **err_info,
{
*data_offset = file_tell(wth->fh);
return mplog_read_packet(wth->fh, rec, err, err_info);
return mplog_read_packet(wth, wth->fh, rec, err, err_info);
}
@ -203,7 +202,7 @@ mplog_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err))
return false;
if (!mplog_read_packet(wth->random_fh, rec, err, err_info)) {
if (!mplog_read_packet(wth, wth->random_fh, rec, err, err_info)) {
/* Even if we got an immediate EOF, that's an error. */
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;

View File

@ -1082,7 +1082,7 @@ netmon_process_record(wtap *wth, FILE_T fh, wtap_rec *rec,
return FAILURE;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
/*

View File

@ -1156,7 +1156,7 @@ static bool nstrace_set_start_time(wtap *wth, int file_version, int *err,
*err_info = g_strdup("nstrace: record size is less than record header size");\
return false;\
}\
(rec)->rec_type = REC_TYPE_PACKET;\
wtap_setup_packet_rec((rec), (wth)->file_encap);\
(rec)->block = wtap_block_create(WTAP_BLOCK_PACKET);\
TIMEDEFV##ver((rec),fp,type);\
FULLPART##SIZEDEFV##ver((rec),type,ver);\
@ -1342,7 +1342,7 @@ static bool nstrace_read_v10(wtap *wth, wtap_rec *rec,
*err_info = g_strdup("nstrace: record size is less than record header size");\
return false;\
}\
(rec)->rec_type = REC_TYPE_PACKET;\
wtap_setup_packet_rec((rec), (wth)->file_encap);\
(rec)->block = wtap_block_create(WTAP_BLOCK_PACKET);\
TIMEDEFV##ver((rec),fp,type);\
FULLPART##SIZEDEFV##ver((rec),fp,ver);\
@ -1543,7 +1543,7 @@ static bool nstrace_read_v20(wtap *wth, wtap_rec *rec,
return false;\
}\
nspr_##structname##_t *fp = (nspr_##structname##_t *) &nstrace_buf[nstrace_buf_offset];\
(rec)->rec_type = REC_TYPE_PACKET;\
wtap_setup_packet_rec((rec), (wth)->file_encap);\
(rec)->block = wtap_block_create(WTAP_BLOCK_PACKET);\
TIMEDEFV##ver((rec),fp,type);\
FULLPART##SIZEDEFV##ver((rec),fp,ver);\
@ -1742,7 +1742,7 @@ static bool nstrace_read_v30(wtap *wth, wtap_rec *rec,
#define PACKET_DESCRIBE(rec,FULLPART,fullpart,ver,type,HEADERVER) \
do {\
nspr_pktrace##fullpart##_v##ver##_t *type = (nspr_pktrace##fullpart##_v##ver##_t *) pd;\
(rec)->rec_type = REC_TYPE_PACKET;\
wtap_setup_packet_rec((rec), (wth)->file_encap);\
(rec)->block = wtap_block_create(WTAP_BLOCK_PACKET);\
TIMEDEFV##ver((rec),fp,type);\
FULLPART##SIZEDEFV##ver((rec),type,ver);\
@ -1837,7 +1837,7 @@ static bool nstrace_seek_read_v10(wtap *wth, int64_t seek_off,
#define PACKET_DESCRIBE(rec,FULLPART,ver,enumprefix,type,structname,HEADERVER)\
do {\
nspr_##structname##_t *fp= (nspr_##structname##_t*)pd;\
(rec)->rec_type = REC_TYPE_PACKET;\
wtap_setup_packet_rec((rec), (wth)->file_encap);\
(rec)->block = wtap_block_create(WTAP_BLOCK_PACKET);\
TIMEDEFV##ver((rec),fp,type);\
FULLPART##SIZEDEFV##ver((rec),fp,ver);\
@ -1962,7 +1962,7 @@ static bool nstrace_seek_read_v20(wtap *wth, int64_t seek_off,
#define PACKET_DESCRIBE(rec,FULLPART,ver,enumprefix,type,structname,HEADERVER)\
do {\
nspr_##structname##_t *fp= (nspr_##structname##_t*)pd;\
(rec)->rec_type = REC_TYPE_PACKET;\
wtap_setup_packet_rec((rec), (wth)->file_encap);\
(rec)->block = wtap_block_create(WTAP_BLOCK_PACKET);\
TIMEDEFV##ver((rec),fp,type);\
SETETHOFFSET_##ver(rec);\

View File

@ -296,7 +296,7 @@ parse_netscreen_packet(FILE_T fh, wtap_rec *rec, char *line,
int offset = 0;
char dststr[13];
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, WTAP_ENCAP_UNKNOWN);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
/* Suppress compiler warnings */

View File

@ -347,6 +347,9 @@ nettl_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec, int *err, char **err_info)
if (!wtap_read_bytes(fh, NULL, hdr_len, err, err_info))
return false;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
if ( (pntoh32(&rec_hdr.kind) & NETTL_HDR_PDU_MASK) == 0 ) {
/* not actually a data packet (PDU) trace record */
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_NETTL_RAW_IP;
@ -538,8 +541,6 @@ nettl_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec, int *err, char **err_info)
length, padlen);
return false;
}
rec->rec_type = REC_TYPE_PACKET;
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
rec->rec_header.packet_header.len = length - padlen;
if (caplen < padlen) {

View File

@ -229,11 +229,12 @@ nettrace_parse_address(char* curr_pos, char* next_pos, bool is_src_addr, exporte
/* Parse a <msg ...><rawMsg ...>XXXX</rawMsg></msg> into packet data. */
static bool
nettrace_msg_to_packet(nettrace_3gpp_32_423_file_info_t *file_info, wtap_rec *rec, uint8_t *input, size_t len, int *err, char **err_info)
nettrace_msg_to_packet(wtap *wth, wtap_rec *rec, uint8_t *input, size_t len, int *err, char **err_info)
{
/* Convenience macro. haystack must be >= input! */
#define STRNSTR(haystack, needle) g_strstr_len(haystack, (len - ((uint8_t*)(haystack) - (uint8_t*)input)), needle)
nettrace_3gpp_32_423_file_info_t *file_info = (nettrace_3gpp_32_423_file_info_t *)wth->priv;
bool status = true;
char *curr_pos, *next_msg_pos, *next_pos, *prev_pos;
exported_pdu_info_t exported_pdu_info = {0};
@ -262,7 +263,7 @@ nettrace_msg_to_packet(nettrace_3gpp_32_423_file_info_t *file_info, wtap_rec *re
curr_pos = input + CLEN(c_s_msg);
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = 0; /* start out assuming no special features */
rec->ts.secs = 0;
@ -625,7 +626,7 @@ nettrace_read(wtap *wth, wtap_rec *rec, int *err, char **err_info, int64_t *data
*data_offset = file_info->start_offset + msg_offset;
/* pass all of <msg....</msg> to nettrace_msg_to_packet() */
status = nettrace_msg_to_packet(file_info, rec, msg_start, msg_len, err, err_info);
status = nettrace_msg_to_packet(wth, rec, msg_start, msg_len, err, err_info);
/* Finally, shift our buffer to the end of this message to get ready for the next one.
* Re-use msg_len to get the length of the data we're done with.
@ -669,7 +670,7 @@ nettrace_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec, int *err, char **
msg_end += CLEN(c_e_msg);
msg_len = (unsigned)(msg_end - file_info->buffer->data);
status = nettrace_msg_to_packet(file_info, rec, file_info->buffer->data, msg_len, err, err_info);
status = nettrace_msg_to_packet(wth, rec, file_info->buffer->data, msg_len, err, err_info);
g_byte_array_set_size(file_info->buffer, 0);
return status;
}

View File

@ -1615,7 +1615,7 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, wtap_rec *rec,
break;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
if (netxray->version_major == 0) {
rec->presence_flags = WTAP_HAS_TS;

View File

@ -1208,7 +1208,7 @@ process_frame_record(wtap *wth, bool is_random, unsigned *padding,
rec_length_remaining = hdr->length;
/* Initialize - we'll be setting some presence flags below. */
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = 0;

View File

@ -542,11 +542,18 @@ static bool
process_packet_header(wtap *wth, packet_entry_header *packet_header,
wtap_rec *rec, int *err, char **err_info)
{
/* set the wiretap record metadata fields */
rec->rec_type = REC_TYPE_PACKET;
/*
* Set the wiretap record metadata fields.
*
* XXX - the link=layer type is per-packet, as it's in the packet
* header, but there's also a link-layer type in the file header,
* from which we get the file's encapsulation. What relationship
* does the latter have to the former? Do we ever need to make
* the file's encapsulation WTAP_ENCAP_PER_PACKET?
*/
wtap_setup_packet_rec(rec, observer_to_wtap_encap(packet_header->network_type));
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
rec->rec_header.packet_header.pkt_encap = observer_to_wtap_encap(packet_header->network_type);
if(wth->file_encap == WTAP_ENCAP_FIBRE_CHANNEL_FC2_WITH_FRAME_DELIMS) {
rec->rec_header.packet_header.len = packet_header->network_size;
rec->rec_header.packet_header.caplen = packet_header->captured_size;

View File

@ -368,7 +368,7 @@ packetlogger_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
return false;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;

View File

@ -2192,7 +2192,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh,
return false;
}
wblock->rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(wblock->rec, iface_info.wtap_encap);
wblock->rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID;
ws_debug("encapsulation = %d (%s), pseudo header size = %d.",
@ -2200,7 +2200,6 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh,
wtap_encap_description(iface_info.wtap_encap),
pcap_get_phdr_size(iface_info.wtap_encap, &wblock->rec->rec_header.packet_header.pseudo_header));
wblock->rec->rec_header.packet_header.interface_id = packet.interface_id;
wblock->rec->rec_header.packet_header.pkt_encap = iface_info.wtap_encap;
wblock->rec->tsprec = iface_info.tsprecision;
memset((void *)&wblock->rec->rec_header.packet_header.pseudo_header, 0, sizeof(union wtap_pseudo_header));
@ -2386,10 +2385,9 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh,
pcap_get_phdr_size(iface_info.wtap_encap, &wblock->rec->rec_header.packet_header.pseudo_header));
/* No time stamp in a simple packet block; no options, either */
wblock->rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(wblock->rec, iface_info.wtap_encap);
wblock->rec->presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID;
wblock->rec->rec_header.packet_header.interface_id = 0;
wblock->rec->rec_header.packet_header.pkt_encap = iface_info.wtap_encap;
wblock->rec->tsprec = iface_info.tsprecision;
wblock->rec->ts.secs = 0;
wblock->rec->ts.nsecs = 0;

View File

@ -115,8 +115,8 @@ static peak_trc_column_map_t colmap[] = {
void register_peak_trc(void);
static bool
peak_trc_write_packet(wtap_rec *rec, const peak_trc_msg_t *msg, int *err,
gchar **err_info)
peak_trc_write_packet(wtap* wth, wtap_rec *rec, const peak_trc_msg_t *msg,
int *err, gchar **err_info)
{
(void)err;
(void)err_info;
@ -168,7 +168,7 @@ peak_trc_write_packet(wtap_rec *rec, const peak_trc_msg_t *msg, int *err,
sizeof(can_frame));
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->ts.secs = msg->ts.secs;
@ -762,7 +762,9 @@ static bool peak_trc_read_packet_v2(peak_trc_state_t* state, peak_trc_msg_t* msg
}
static bool
peak_trc_read_packet(FILE_T fh, peak_trc_state_t* state, wtap_rec *rec, int *err, gchar **err_info, gint64 *data_offset)
peak_trc_read_packet(wtap *wth, FILE_T fh, peak_trc_state_t* state,
wtap_rec *rec, int *err, gchar **err_info,
gint64 *data_offset)
{
peak_trc_msg_t msg = {0};
char line_buffer[PEAK_TRC_MAX_LINE_SIZE];
@ -815,7 +817,7 @@ peak_trc_read_packet(FILE_T fh, peak_trc_state_t* state, wtap_rec *rec, int *err
}
}
return peak_trc_write_packet(rec, &msg, err, err_info);
return peak_trc_write_packet(wth, rec, &msg, err, err_info);
}
return false;
@ -831,7 +833,7 @@ peak_trc_read(wtap *wth, wtap_rec *rec, int *err, char **err_info,
peak_trc_debug_printf("%s: Try reading at offset %" PRIi64 "\n", G_STRFUNC, file_tell(wth->fh));
#endif
return peak_trc_read_packet(wth->fh, state, rec, err, err_info, data_offset);
return peak_trc_read_packet(wth, wth->fh, state, rec, err, err_info, data_offset);
}
static bool peak_trc_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec, int *err, char **err_info)
@ -849,7 +851,7 @@ static bool peak_trc_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec, int *
return false;
}
return peak_trc_read_packet(wth->random_fh, state, rec, err, err_info, NULL);
return peak_trc_read_packet(wth, wth->random_fh, state, rec, err, err_info, NULL);
}
static void peak_trc_close(wtap* wth)

View File

@ -450,7 +450,7 @@ static int peekclassic_read_packet_v7(wtap *wth, FILE_T fh, wtap_rec *rec,
*/
/* fill in packet header values */
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
tsecs = (time_t) (timestamp/1000000);
@ -662,7 +662,7 @@ static bool peekclassic_read_packet_v56(wtap *wth, FILE_T fh, wtap_rec *rec,
*/
/* fill in packet header values */
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
/* timestamp is in milliseconds since reference_time */

View File

@ -253,7 +253,6 @@ wtap_open_return_val peektagged_open(wtap *wth, int *err, char **err_info)
uint32_t fileVersion = 0;
uint32_t mediaType;
uint32_t mediaSubType = 0;
int file_encap;
static const int peektagged_encap[] = {
WTAP_ENCAP_ETHERNET,
WTAP_ENCAP_IEEE_802_11_WITH_RADIO,
@ -373,10 +372,8 @@ wtap_open_return_val peektagged_open(wtap *wth, int *err, char **err_info)
/*
* This is an Peek tagged file.
*/
file_encap = peektagged_encap[mediaSubType];
wth->file_type_subtype = peektagged_file_type_subtype;
wth->file_encap = file_encap;
wth->file_encap = peektagged_encap[mediaSubType];
wth->subtype_read = peektagged_read;
wth->subtype_seek_read = peektagged_seek_read;
wth->file_tsprec = WTAP_TSPREC_NSEC;
@ -730,7 +727,7 @@ peektagged_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
return -1;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
rec->rec_header.packet_header.len = length;

View File

@ -317,13 +317,12 @@ pppdump_open(wtap *wth, int *err, char **err_info)
/* Set part of the struct wtap_rec. */
static void
pppdump_set_phdr(wtap_rec *rec, int num_bytes, direction_enum direction)
pppdump_set_phdr(wtap *wth, wtap_rec *rec, int num_bytes, direction_enum direction)
{
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->rec_header.packet_header.len = num_bytes;
rec->rec_header.packet_header.caplen = num_bytes;
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_PPP_WITH_PHDR;
rec->rec_header.packet_header.pseudo_header.p2p.sent = (direction == DIRECTION_SENT ? true : false);
}
@ -368,7 +367,7 @@ pppdump_read(wtap *wth, wtap_rec *rec, int *err, char **err_info,
*data_offset = state->pkt_cnt;
state->pkt_cnt++;
pppdump_set_phdr(rec, num_bytes, direction);
pppdump_set_phdr(wth, rec, num_bytes, direction);
rec->presence_flags = WTAP_HAS_TS;
rec->ts.secs = state->timestamp;
rec->ts.nsecs = state->tenths * 100000000;
@ -773,7 +772,7 @@ pppdump_seek_read(wtap *wth,
num_bytes_to_skip = 0;
} while (direction != pid->dir);
pppdump_set_phdr(rec, num_bytes, pid->dir);
pppdump_set_phdr(wth, rec, num_bytes, pid->dir);
return true;
}

View File

@ -315,7 +315,7 @@ radcom_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec, int *err, char **err_info)
* it.
*/
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;

View File

@ -80,7 +80,7 @@ static bool rfc7468_read_line(FILE_T fh, enum line_type *line_type,
return true;
}
static bool rfc7468_read_impl(FILE_T fh, wtap_rec *rec,
static bool rfc7468_read_impl(wtap *wth, FILE_T fh, wtap_rec *rec,
int *err, char **err_info)
{
ws_buffer_clean(&rec->data);
@ -105,7 +105,7 @@ static bool rfc7468_read_impl(FILE_T fh, wtap_rec *rec,
}
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->presence_flags = 0;
rec->ts.secs = 0;
rec->ts.nsecs = 0;
@ -120,7 +120,7 @@ static bool rfc7468_read(wtap *wth, wtap_rec *rec,
{
*data_offset = file_tell(wth->fh);
return rfc7468_read_impl(wth->fh, rec, err, err_info);
return rfc7468_read_impl(wth, wth->fh, rec, err, err_info);
}
static bool rfc7468_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
@ -129,7 +129,7 @@ static bool rfc7468_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) < 0)
return false;
return rfc7468_read_impl(wth->random_fh, rec, err, err_info);
return rfc7468_read_impl(wth, wth->random_fh, rec, err, err_info);
}
wtap_open_return_val rfc7468_open(wtap *wth, int *err, char **err_info)

View File

@ -304,6 +304,8 @@ rtpdump_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
}
epdu_len = wtap_buffer_append_epdu_end(&rec->data);
wtap_setup_packet_rec(rec, wth->file_encap);
/* Offset is milliseconds since the start of recording */
ts.secs = offset / 1000;
ts.nsecs = (offset % 1000) * 1000000;
@ -311,7 +313,6 @@ rtpdump_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
rec->presence_flags |= WTAP_HAS_TS | WTAP_HAS_CAP_LEN;
rec->rec_header.packet_header.caplen = epdu_len + plen;
rec->rec_header.packet_header.len = epdu_len + length;
rec->rec_type = REC_TYPE_PACKET;
return wtap_read_bytes_buffer(fh, &rec->data, length, err, err_info);
}

View File

@ -608,7 +608,7 @@ snoop_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
break;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
rec->ts.secs = g_ntohl(hdr.ts_sec);

View File

@ -64,7 +64,7 @@ static bool stanag4607_read_file(wtap *wth, FILE_T fh, wtap_rec *rec,
return false;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
/* The next 4 bytes are the packet length */

View File

@ -311,7 +311,7 @@ parse_toshiba_packet(FILE_T fh, wtap_rec *rec, int *err, char **err_info)
return false;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, WTAP_ENCAP_UNKNOWN);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
rec->ts.secs = hr * 3600 + min * 60 + sec;

View File

@ -1570,7 +1570,7 @@ static const ttl_addr_to_iface_entry_t* ttl_lookup_interface_int(wtap* wth, uint
static void
ttl_init_rec(wtap_rec* rec, uint64_t timestamp, uint16_t addr, int pkt_encap, uint32_t iface_id, uint32_t caplen, uint32_t len) {
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, pkt_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_CAP_LEN | WTAP_HAS_INTERFACE_ID | WTAP_HAS_TS;
rec->tsprec = WTAP_TSPREC_USEC;
@ -1581,7 +1581,6 @@ ttl_init_rec(wtap_rec* rec, uint64_t timestamp, uint16_t addr, int pkt_encap, ui
rec->ts_rel_cap_valid = false;
rec->rec_header.packet_header.pkt_encap = pkt_encap;
rec->rec_header.packet_header.interface_id = iface_id;
wtap_block_add_uint32_option(rec->block, OPT_PKT_QUEUE, addr);

View File

@ -329,7 +329,7 @@ static bool visual_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
/* Get the included length of data. This includes extra headers + payload */
packet_size = pletoh16(&vpkt_hdr.incl_len);
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
@ -504,8 +504,13 @@ static bool visual_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
/* Not sure about token ring. Just leaving alone for now. */
case WTAP_ENCAP_TOKEN_RING:
default:
break;
default:
*err = WTAP_ERR_INTERNAL;
*err_info = ws_strdup_printf("visual: Unknown per-file encapsulation %d",
wth->file_encap);
return false;
}
rec->rec_header.packet_header.caplen = packet_size;

View File

@ -132,7 +132,7 @@ static bool vms_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
int *err, char **err_info);
static bool parse_single_hex_dump_line(char* rec, uint8_t *buf,
long byte_offset, int in_off, int remaining_bytes);
static bool parse_vms_packet(FILE_T fh, wtap_rec *rec, int *err,
static bool parse_vms_packet(wtap *wth, FILE_T fh, wtap_rec *rec, int *err,
char **err_info);
static int vms_file_type_subtype = -1;
@ -272,7 +272,7 @@ static bool vms_read(wtap *wth, wtap_rec *rec, int *err,
*data_offset = offset;
/* Parse the packet */
return parse_vms_packet(wth->fh, rec, err, err_info);
return parse_vms_packet(wth, wth->fh, rec, err, err_info);
}
/* Used to read packets in random-access fashion */
@ -282,7 +282,7 @@ static bool vms_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
return false;
if (!parse_vms_packet(wth->random_fh, rec, err, err_info)) {
if (!parse_vms_packet(wth, wth->random_fh, rec, err, err_info)) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
return false;
@ -317,7 +317,7 @@ isdumpline( char *line )
/* Parses a packet record. */
static bool
parse_vms_packet(FILE_T fh, wtap_rec *rec, int *err, char **err_info)
parse_vms_packet(wtap *wth, FILE_T fh, wtap_rec *rec, int *err, char **err_info)
{
char line[VMS_LINE_LENGTH + 1];
int num_items_scanned;
@ -421,7 +421,7 @@ parse_vms_packet(FILE_T fh, wtap_rec *rec, int *err, char **err_info)
tm.tm_year -= 1900;
tm.tm_isdst = -1;
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
rec->presence_flags = WTAP_HAS_TS;
rec->ts.secs = mktime(&tm);

View File

@ -781,21 +781,21 @@ static bool vwr_seek_read(wtap *, int64_t, wtap_rec *, int *, char **);
static bool vwr_read_rec_header(vwr_t *, FILE_T, int *, int *, int *,
int *, char **);
static bool vwr_process_rec_data(FILE_T fh, int rec_size,
wtap_rec *record, vwr_t *vwr,
int IS_TX, int log_mode, int *err,
static bool vwr_process_rec_data(wtap *wth, FILE_T fh, int rec_size,
wtap_rec *record, int IS_TX,
int log_mode, int *err,
char **err_info);
static int vwr_get_fpga_version(wtap *, int *, char **);
static bool vwr_read_s1_W_rec(vwr_t *, wtap_rec *, const uint8_t *,
static bool vwr_read_s1_W_rec(wtap *, wtap_rec *, const uint8_t *,
int, int *, char **);
static bool vwr_read_s2_W_rec(vwr_t *, wtap_rec *, const uint8_t *,
static bool vwr_read_s2_W_rec(wtap *, wtap_rec *, const uint8_t *,
int, int, int *, char **);
/* For FPGA version >= 48 (OCTO Platform), following function will be used */
static bool vwr_read_s3_W_rec(vwr_t *, wtap_rec *, const uint8_t *,
static bool vwr_read_s3_W_rec(wtap *, wtap_rec *, const uint8_t *,
int, int, int, int *, char **);
static bool vwr_read_rec_data_ethernet(vwr_t *, wtap_rec *,
static bool vwr_read_rec_data_ethernet(wtap *, wtap_rec *,
const uint8_t *, int,
int, int *, char **);
@ -885,7 +885,7 @@ static bool vwr_read(wtap *wth, wtap_rec *rec, int *err, char **err_info,
*data_offset = (file_tell(wth->fh) - VW_RECORD_HEADER_LENGTH);
/* got a frame record; read and process it */
if (!vwr_process_rec_data(wth->fh, rec_size, rec, vwr, IS_TX, log_mode,
if (!vwr_process_rec_data(wth, wth->fh, rec_size, rec, IS_TX, log_mode,
err, err_info))
return false;
@ -908,7 +908,7 @@ static bool vwr_seek_read(wtap *wth, int64_t seek_off, wtap_rec *record,
if (!vwr_read_rec_header(vwr, wth->random_fh, &rec_size, &IS_TX, &log_mode, err, err_info))
return false; /* Read error or EOF */
return vwr_process_rec_data(wth->random_fh, rec_size, record, vwr, IS_TX,
return vwr_process_rec_data(wth, wth->random_fh, rec_size, record, IS_TX,
log_mode, err, err_info);
}
@ -1137,10 +1137,11 @@ static int vwr_get_fpga_version(wtap *wth, int *err, char **err_info)
/* The packet is constructed as a 38-byte VeriWave metadata header plus the raw */
/* MAC octets. */
static bool vwr_read_s1_W_rec(vwr_t *vwr, wtap_rec *record,
static bool vwr_read_s1_W_rec(wtap *wth, wtap_rec *record,
const uint8_t *rec, int rec_size,
int *err, char **err_info)
{
vwr_t *vwr = (vwr_t *)wth->priv;
uint8_t *data_ptr;
int bytes_written = 0; /* bytes output to buf so far */
const uint8_t *s_ptr, *m_ptr; /* stats pointer */
@ -1279,7 +1280,11 @@ static bool vwr_read_s1_W_rec(vwr_t *vwr, wtap_rec *record,
/*
* Fill up the per-packet header.
*
*/
wtap_setup_packet_rec(record, wth->file_encap);
record->block = wtap_block_create(WTAP_BLOCK_PACKET);
/*
* We include the length of the metadata headers in the packet lengths.
*
* The maximum value of actual_octets is 8191, which, even after
@ -1289,13 +1294,9 @@ static bool vwr_read_s1_W_rec(vwr_t *vwr, wtap_rec *record,
record->rec_header.packet_header.len = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets;
record->rec_header.packet_header.caplen = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets;
record->presence_flags = WTAP_HAS_TS;
record->ts.secs = (time_t)s_sec;
record->ts.nsecs = (int)(s_usec * 1000);
record->rec_header.packet_header.pkt_encap = WTAP_ENCAP_IXVERIWAVE;
record->rec_type = REC_TYPE_PACKET;
record->block = wtap_block_create(WTAP_BLOCK_PACKET);
record->presence_flags = WTAP_HAS_TS;
ws_buffer_assure_space(&record->data, record->rec_header.packet_header.caplen);
data_ptr = ws_buffer_start_ptr(&record->data);
@ -1414,10 +1415,11 @@ static bool vwr_read_s1_W_rec(vwr_t *vwr, wtap_rec *record,
}
static bool vwr_read_s2_W_rec(vwr_t *vwr, wtap_rec *record,
static bool vwr_read_s2_W_rec(wtap *wth, wtap_rec *record,
const uint8_t *rec, int rec_size,
int IS_TX, int *err, char **err_info)
{
vwr_t *vwr = (vwr_t *)wth->priv;
uint8_t *data_ptr;
int bytes_written = 0; /* bytes output to buf so far */
const uint8_t *s_start_ptr,*s_trail_ptr, *plcp_ptr, *m_ptr; /* stats & MPDU ptr */
@ -1696,7 +1698,11 @@ static bool vwr_read_s2_W_rec(vwr_t *vwr, wtap_rec *record,
/*
* Fill up the per-packet header.
*
*/
wtap_setup_packet_rec(record, wth->file_encap);
record->block = wtap_block_create(WTAP_BLOCK_PACKET);
/*
* We include the length of the metadata headers in the packet lengths.
*
* The maximum value of actual_octets is 8191, which, even after
@ -1706,13 +1712,10 @@ static bool vwr_read_s2_W_rec(vwr_t *vwr, wtap_rec *record,
record->rec_header.packet_header.len = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets;
record->rec_header.packet_header.caplen = STATS_COMMON_FIELDS_LEN + EXT_WLAN_FIELDS_LEN + actual_octets;
record->presence_flags = WTAP_HAS_TS;
record->ts.secs = (time_t)s_sec;
record->ts.nsecs = (int)(s_usec * 1000);
record->rec_type = REC_TYPE_PACKET;
record->block = wtap_block_create(WTAP_BLOCK_PACKET);
record->presence_flags = WTAP_HAS_TS;
ws_buffer_assure_space(&record->data, record->rec_header.packet_header.caplen);
data_ptr = ws_buffer_start_ptr(&record->data);
@ -1830,11 +1833,12 @@ static bool vwr_read_s2_W_rec(vwr_t *vwr, wtap_rec *record,
return true;
}
static bool vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record,
static bool vwr_read_s3_W_rec(wtap *wth, wtap_rec *record,
const uint8_t *rec, int rec_size,
int IS_TX, int log_mode, int *err,
char **err_info)
{
vwr_t *vwr = (vwr_t *)wth->priv;
uint8_t *data_ptr;
int bytes_written = 0; /* bytes output to buf so far */
int i;
@ -1878,7 +1882,11 @@ static bool vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record,
/*
* Fill up the per-packet header.
*
*/
wtap_setup_packet_rec(record, wth->file_encap);
record->block = wtap_block_create(WTAP_BLOCK_PACKET);
/*
* We include the length of the metadata headers in the packet lengths.
*
* OCTO_MODIFIED_RF_LEN + 1 is less than WTAP_MAX_PACKET_SIZE_STANDARD will
@ -1887,13 +1895,10 @@ static bool vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record,
record->rec_header.packet_header.len = OCTO_MODIFIED_RF_LEN + 1; /* 1st octet is reserved for detecting type of frame while displaying in wireshark */
record->rec_header.packet_header.caplen = OCTO_MODIFIED_RF_LEN + 1;
record->presence_flags = WTAP_HAS_TS;
record->ts.secs = (time_t)s_sec;
record->ts.nsecs = (int)(s_usec * 1000);
record->rec_type = REC_TYPE_PACKET;
record->block = wtap_block_create(WTAP_BLOCK_PACKET);
record->presence_flags = WTAP_HAS_TS;
ws_buffer_assure_space(&record->data, record->rec_header.packet_header.caplen);
data_ptr = ws_buffer_start_ptr(&record->data);
@ -2198,7 +2203,11 @@ static bool vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record,
/*
* Fill up the per-packet header.
*
*/
wtap_setup_packet_rec(record, wth->file_encap);
record->block = wtap_block_create(WTAP_BLOCK_PACKET);
/*
* We include the length of the metadata headers in the packet lengths.
*/
if (IS_TX == 4) {
@ -2220,13 +2229,10 @@ static bool vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record,
return false;
}
record->presence_flags = WTAP_HAS_TS;
record->ts.secs = (time_t)s_sec;
record->ts.nsecs = (int)(s_usec * 1000);
record->rec_type = REC_TYPE_PACKET;
record->block = wtap_block_create(WTAP_BLOCK_PACKET);
record->presence_flags = WTAP_HAS_TS;
ws_buffer_assure_space(&record->data, record->rec_header.packet_header.caplen);
data_ptr = ws_buffer_start_ptr(&record->data);
}
@ -2549,11 +2555,12 @@ static bool vwr_read_s3_W_rec(vwr_t *vwr, wtap_rec *record,
/* Copy the actual packet data from the capture file into the target data block. */
/* The packet is constructed as a 38-byte VeriWave-extended Radiotap header plus the raw */
/* MAC octets. */
static bool vwr_read_rec_data_ethernet(vwr_t *vwr, wtap_rec *record,
static bool vwr_read_rec_data_ethernet(wtap *wth, wtap_rec *record,
const uint8_t *rec, int rec_size,
int IS_TX, int *err,
char **err_info)
{
vwr_t *vwr = (vwr_t *)wth->priv;
uint8_t *data_ptr;
int bytes_written = 0; /* bytes output to buf so far */
const uint8_t *s_ptr, *m_ptr; /* stats and MPDU pointers */
@ -2720,7 +2727,11 @@ static bool vwr_read_rec_data_ethernet(vwr_t *vwr, wtap_rec *record,
/*
* Fill up the per-packet header.
*
*/
wtap_setup_packet_rec(record, wth->file_encap);
record->block = wtap_block_create(WTAP_BLOCK_PACKET);
/*
* We include the length of the metadata headers in the packet lengths.
*
* The maximum value of actual_octets is 65535, which, even after
@ -2730,13 +2741,10 @@ static bool vwr_read_rec_data_ethernet(vwr_t *vwr, wtap_rec *record,
record->rec_header.packet_header.len = STATS_COMMON_FIELDS_LEN + EXT_ETHERNET_FIELDS_LEN + actual_octets;
record->rec_header.packet_header.caplen = STATS_COMMON_FIELDS_LEN + EXT_ETHERNET_FIELDS_LEN + actual_octets;
record->presence_flags = WTAP_HAS_TS;
record->ts.secs = (time_t)s_sec;
record->ts.nsecs = (int)(s_usec * 1000);
record->rec_type = REC_TYPE_PACKET;
record->block = wtap_block_create(WTAP_BLOCK_PACKET);
record->presence_flags = WTAP_HAS_TS;
/*etap_hdr.vw_ip_length = (uint16_t)ip_len;*/
ws_buffer_assure_space(&record->data, record->rec_header.packet_header.caplen);
@ -3342,9 +3350,10 @@ get_vht_rate(uint8_t mcs_index, uint16_t rflags, uint8_t nss)
}
static bool
vwr_process_rec_data(FILE_T fh, int rec_size, wtap_rec *record, vwr_t *vwr,
vwr_process_rec_data(wtap *wth, FILE_T fh, int rec_size, wtap_rec *record,
int IS_TX, int log_mode, int *err, char **err_info)
{
vwr_t* vwr = (vwr_t *)wth->priv;
uint8_t* rec; /* local buffer (holds input record) */
bool ret = false;
@ -3362,17 +3371,17 @@ vwr_process_rec_data(FILE_T fh, int rec_size, wtap_rec *record, vwr_t *vwr,
switch (vwr->FPGA_VERSION)
{
case S1_W_FPGA:
ret = vwr_read_s1_W_rec(vwr, record, rec, rec_size, err, err_info);
ret = vwr_read_s1_W_rec(wth, record, rec, rec_size, err, err_info);
break;
case S2_W_FPGA:
ret = vwr_read_s2_W_rec(vwr, record, rec, rec_size, IS_TX, err, err_info);
ret = vwr_read_s2_W_rec(wth, record, rec, rec_size, IS_TX, err, err_info);
break;
case S3_W_FPGA:
ret = vwr_read_s3_W_rec(vwr, record, rec, rec_size, IS_TX, log_mode, err, err_info);
ret = vwr_read_s3_W_rec(wth, record, rec, rec_size, IS_TX, log_mode, err, err_info);
break;
case vVW510012_E_FPGA:
case vVW510024_E_FPGA:
ret = vwr_read_rec_data_ethernet(vwr, record, rec, rec_size, IS_TX, err, err_info);
ret = vwr_read_rec_data_ethernet(wth, record, rec, rec_size, IS_TX, err, err_info);
break;
default:
g_free(rec);

View File

@ -1711,16 +1711,10 @@ static void
wtap_reset_rec(wtap *wth, wtap_rec *rec)
{
/*
* Set the packet encapsulation to the file's encapsulation
* value; if that's not WTAP_ENCAP_PER_PACKET, it's the
* right answer (and means that the read routine for this
* capture file type doesn't have to set it), and if it
* *is* WTAP_ENCAP_PER_PACKET, the caller needs to set it
* anyway.
*
* Do the same for the packet time stamp resolution.
* Set the time stamp precision to the file's time stamp
* precision value, as a default. If it's per-packet,
* the read routine must override it.
*/
rec->rec_header.packet_header.pkt_encap = wth->file_encap;
rec->tsprec = wth->file_tsprec;
rec->block = NULL;
rec->block_was_modified = false;
@ -1739,6 +1733,16 @@ wtap_reset_rec(wtap *wth, wtap_rec *rec)
ws_buffer_clean(&rec->data);
}
/**
* Set up a wtap_rec for a packet (REC_TYPE_PACKET).
*/
void
wtap_setup_packet_rec(wtap_rec *rec, int encap)
{
rec->rec_type = REC_TYPE_PACKET;
rec->rec_header.packet_header.pkt_encap = encap;
}
bool
wtap_read(wtap *wth, wtap_rec *rec, int *err, char **err_info, int64_t *offset)
{
@ -2043,7 +2047,7 @@ wtap_full_file_read_file(wtap *wth, FILE_T fh, wtap_rec *rec,
buffer_size += block_size;
}
rec->rec_type = REC_TYPE_PACKET;
wtap_setup_packet_rec(rec, wth->file_encap);
rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */
rec->ts.secs = 0;
rec->ts.nsecs = 0;

View File

@ -1969,6 +1969,12 @@ void wtap_rec_reset(wtap_rec *rec);
WS_DLL_PUBLIC
void wtap_rec_cleanup(wtap_rec *rec);
/**
* Set up a wtap_rec for a packet (REC_TYPE_PACKET).
*/
WS_DLL_PUBLIC
void wtap_setup_packet_rec(wtap_rec *rec, int encap);
/*
* Types of compression for a file, including "none".
*/