forked from osmocom/wireshark
Generalize wtap_pkthdr into a structure for packet and non-packet records.
Separate the stuff that any record could have from the stuff that only particular record types have; put the latter into a union, and put all that into a wtap_rec structure. Add some record-type checks as necessary. Change-Id: Id6b3486858f826fce4b096c59231f463e44bfaa2 Reviewed-on: https://code.wireshark.org/review/25696 Reviewed-by: Guy Harris <guy@alum.mit.edu>pespin/amr
parent
e4c5efafb7
commit
1f5f63f8ef
52
capinfos.c
52
capinfos.c
|
@ -1061,7 +1061,7 @@ process_cap_file(wtap *wth, const char *filename)
|
|||
gint64 bytes = 0;
|
||||
guint32 snaplen_min_inferred = 0xffffffff;
|
||||
guint32 snaplen_max_inferred = 0;
|
||||
const struct wtap_pkthdr *phdr;
|
||||
wtap_rec *rec;
|
||||
capture_info cf_info;
|
||||
gboolean have_times = TRUE;
|
||||
nstime_t start_time;
|
||||
|
@ -1103,27 +1103,27 @@ process_cap_file(wtap *wth, const char *filename)
|
|||
|
||||
/* Tally up data that we need to parse through the file to find */
|
||||
while (wtap_read(wth, &err, &err_info, &data_offset)) {
|
||||
phdr = wtap_phdr(wth);
|
||||
if (phdr->presence_flags & WTAP_HAS_TS) {
|
||||
rec = wtap_get_rec(wth);
|
||||
if (rec->presence_flags & WTAP_HAS_TS) {
|
||||
prev_time = cur_time;
|
||||
cur_time = phdr->ts;
|
||||
cur_time = rec->ts;
|
||||
if (packet == 0) {
|
||||
start_time = phdr->ts;
|
||||
start_time_tsprec = phdr->pkt_tsprec;
|
||||
stop_time = phdr->ts;
|
||||
stop_time_tsprec = phdr->pkt_tsprec;
|
||||
prev_time = phdr->ts;
|
||||
start_time = rec->ts;
|
||||
start_time_tsprec = rec->tsprec;
|
||||
stop_time = rec->ts;
|
||||
stop_time_tsprec = rec->tsprec;
|
||||
prev_time = rec->ts;
|
||||
}
|
||||
if (nstime_cmp(&cur_time, &prev_time) < 0) {
|
||||
order = NOT_IN_ORDER;
|
||||
}
|
||||
if (nstime_cmp(&cur_time, &start_time) < 0) {
|
||||
start_time = cur_time;
|
||||
start_time_tsprec = phdr->pkt_tsprec;
|
||||
start_time_tsprec = rec->tsprec;
|
||||
}
|
||||
if (nstime_cmp(&cur_time, &stop_time) > 0) {
|
||||
stop_time = cur_time;
|
||||
stop_time_tsprec = phdr->pkt_tsprec;
|
||||
stop_time_tsprec = rec->tsprec;
|
||||
}
|
||||
} else {
|
||||
have_times = FALSE; /* at least one packet has no time stamp */
|
||||
|
@ -1131,32 +1131,33 @@ process_cap_file(wtap *wth, const char *filename)
|
|||
order = ORDER_UNKNOWN;
|
||||
}
|
||||
|
||||
if (phdr->rec_type == REC_TYPE_PACKET) {
|
||||
bytes+=phdr->len;
|
||||
if (rec->rec_type == REC_TYPE_PACKET) {
|
||||
bytes += rec->rec_header.packet_header.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 (rec->rec_header.packet_header.caplen < rec->rec_header.packet_header.len) {
|
||||
if (rec->rec_header.packet_header.caplen < snaplen_min_inferred)
|
||||
snaplen_min_inferred = rec->rec_header.packet_header.caplen;
|
||||
if (rec->rec_header.packet_header.caplen > snaplen_max_inferred)
|
||||
snaplen_max_inferred = rec->rec_header.packet_header.caplen;
|
||||
}
|
||||
|
||||
if ((phdr->pkt_encap > 0) && (phdr->pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
|
||||
cf_info.encap_counts[phdr->pkt_encap] += 1;
|
||||
if ((rec->rec_header.packet_header.pkt_encap > 0) &&
|
||||
(rec->rec_header.packet_header.pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
|
||||
cf_info.encap_counts[rec->rec_header.packet_header.pkt_encap] += 1;
|
||||
} else {
|
||||
fprintf(stderr, "capinfos: Unknown packet encapsulation %d in frame %u of file \"%s\"\n",
|
||||
phdr->pkt_encap, packet, filename);
|
||||
rec->rec_header.packet_header.pkt_encap, packet, filename);
|
||||
}
|
||||
|
||||
/* Packet interface_id info */
|
||||
if (phdr->presence_flags & WTAP_HAS_INTERFACE_ID) {
|
||||
if (rec->presence_flags & WTAP_HAS_INTERFACE_ID) {
|
||||
/* cf_info.num_interfaces is size, not index, so it's one more than max index */
|
||||
if (phdr->interface_id >= cf_info.num_interfaces) {
|
||||
if (rec->rec_header.packet_header.interface_id >= cf_info.num_interfaces) {
|
||||
/*
|
||||
* OK, re-fetch the number of interfaces, as there might have
|
||||
* been an interface that was in the middle of packets, and
|
||||
|
@ -1171,8 +1172,9 @@ process_cap_file(wtap *wth, const char *filename)
|
|||
g_free(idb_info);
|
||||
idb_info = NULL;
|
||||
}
|
||||
if (phdr->interface_id < cf_info.num_interfaces) {
|
||||
g_array_index(cf_info.interface_packet_counts, guint32, phdr->interface_id) += 1;
|
||||
if (rec->rec_header.packet_header.interface_id < cf_info.num_interfaces) {
|
||||
g_array_index(cf_info.interface_packet_counts, guint32,
|
||||
rec->rec_header.packet_header.interface_id) += 1;
|
||||
}
|
||||
else {
|
||||
cf_info.pkt_interface_id_unknown += 1;
|
||||
|
|
|
@ -40,7 +40,7 @@ void capture_info_new_packets(int to_read, info_data_t* cap_info)
|
|||
int err;
|
||||
gchar *err_info;
|
||||
gint64 data_offset;
|
||||
struct wtap_pkthdr *phdr;
|
||||
wtap_rec *rec;
|
||||
union wtap_pseudo_header *pseudo_header;
|
||||
int wtap_linktype;
|
||||
const guchar *buf;
|
||||
|
@ -53,15 +53,17 @@ void capture_info_new_packets(int to_read, info_data_t* cap_info)
|
|||
while (to_read > 0) {
|
||||
wtap_cleareof(cap_info->wtap);
|
||||
if (wtap_read(cap_info->wtap, &err, &err_info, &data_offset)) {
|
||||
phdr = wtap_phdr(cap_info->wtap);
|
||||
pseudo_header = &phdr->pseudo_header;
|
||||
wtap_linktype = phdr->pkt_encap;
|
||||
buf = wtap_buf_ptr(cap_info->wtap);
|
||||
rec = wtap_get_rec(cap_info->wtap);
|
||||
if (rec->rec_type == REC_TYPE_PACKET) {
|
||||
pseudo_header = &rec->rec_header.packet_header.pseudo_header;
|
||||
wtap_linktype = rec->rec_header.packet_header.pkt_encap;
|
||||
buf = wtap_get_buf_ptr(cap_info->wtap);
|
||||
|
||||
capture_info_packet(cap_info, wtap_linktype, buf, phdr->caplen, pseudo_header);
|
||||
capture_info_packet(cap_info, wtap_linktype, buf, rec->rec_header.packet_header.caplen, pseudo_header);
|
||||
|
||||
/*g_warning("new packet");*/
|
||||
to_read--;
|
||||
/*g_warning("new packet");*/
|
||||
to_read--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
4
cfile.h
4
cfile.h
|
@ -99,8 +99,8 @@ typedef struct _capture_file {
|
|||
search_direction dir; /* Direction in which to do searches */
|
||||
gboolean search_in_progress; /* TRUE if user just clicked OK in the Find dialog or hit <control>N/B */
|
||||
/* packet data */
|
||||
struct wtap_pkthdr phdr; /* Packet header */
|
||||
Buffer buf; /* Packet data */
|
||||
wtap_rec rec; /* Record header */
|
||||
Buffer buf; /* Record data */
|
||||
/* packet provider */
|
||||
struct packet_provider_data provider;
|
||||
/* frames */
|
||||
|
|
332
editcap.c
332
editcap.c
|
@ -174,8 +174,8 @@ static struct time_adjustment strict_time_adj = {{0, 0}, 0}; /* strict
|
|||
static nstime_t previous_time = {0, 0}; /* previous time */
|
||||
|
||||
static int find_dct2000_real_data(guint8 *buf);
|
||||
static void handle_chopping(chop_t chop, struct wtap_pkthdr *out_phdr,
|
||||
const struct wtap_pkthdr *in_phdr, guint8 **buf,
|
||||
static void handle_chopping(chop_t chop, wtap_packet_header *out_phdr,
|
||||
const wtap_packet_header *in_phdr, guint8 **buf,
|
||||
gboolean adjlen);
|
||||
|
||||
static gchar *
|
||||
|
@ -202,7 +202,7 @@ abs_time_to_str_with_sec_resolution(const nstime_t *abs_time)
|
|||
}
|
||||
|
||||
static gchar *
|
||||
fileset_get_filename_by_pattern(guint idx, const struct wtap_pkthdr *phdr,
|
||||
fileset_get_filename_by_pattern(guint idx, const wtap_rec *rec,
|
||||
gchar *fprefix, gchar *fsuffix)
|
||||
{
|
||||
gchar filenum[5+1];
|
||||
|
@ -210,8 +210,8 @@ fileset_get_filename_by_pattern(guint idx, const struct wtap_pkthdr *phdr,
|
|||
gchar *abs_str;
|
||||
|
||||
g_snprintf(filenum, sizeof(filenum), "%05u", idx % RINGBUFFER_MAX_NUM_FILES);
|
||||
if (phdr->presence_flags & WTAP_HAS_TS) {
|
||||
timestr = abs_time_to_str_with_sec_resolution(&phdr->ts);
|
||||
if (rec->presence_flags & WTAP_HAS_TS) {
|
||||
timestr = abs_time_to_str_with_sec_resolution(&rec->ts);
|
||||
abs_str = g_strconcat(fprefix, "_", filenum, "_", timestr, fsuffix, NULL);
|
||||
g_free(timestr);
|
||||
} else
|
||||
|
@ -562,7 +562,7 @@ sll_remove_vlan_info(guint8* fd, guint32* len) {
|
|||
}
|
||||
|
||||
static void
|
||||
remove_vlan_info(const struct wtap_pkthdr *phdr, guint8* fd, guint32* len) {
|
||||
remove_vlan_info(const wtap_packet_header *phdr, guint8* fd, guint32* len) {
|
||||
switch (phdr->pkt_encap) {
|
||||
case WTAP_ENCAP_SLL:
|
||||
sll_remove_vlan_info(fd, len);
|
||||
|
@ -979,12 +979,14 @@ main(int argc, char *argv[])
|
|||
gchar *fsuffix = NULL;
|
||||
guint32 change_offset = 0;
|
||||
guint max_packet_number = 0;
|
||||
const struct wtap_pkthdr *phdr;
|
||||
struct wtap_pkthdr temp_phdr;
|
||||
const wtap_rec *rec;
|
||||
wtap_rec temp_rec;
|
||||
wtapng_iface_descriptions_t *idb_inf = NULL;
|
||||
GArray *shb_hdrs = NULL;
|
||||
GArray *nrb_hdrs = NULL;
|
||||
char *shb_user_appl;
|
||||
gboolean do_mutation;
|
||||
guint32 caplen;
|
||||
int ret = EXIT_SUCCESS;
|
||||
|
||||
cmdarg_err_init(failure_warning_message, failure_message_cont);
|
||||
|
@ -1374,7 +1376,7 @@ main(int argc, char *argv[])
|
|||
|
||||
read_count++;
|
||||
|
||||
phdr = wtap_phdr(wth);
|
||||
rec = wtap_get_rec(wth);
|
||||
|
||||
/* Extra actions for the first packet */
|
||||
if (read_count == 1) {
|
||||
|
@ -1384,7 +1386,7 @@ main(int argc, char *argv[])
|
|||
goto clean_exit;
|
||||
}
|
||||
|
||||
filename = fileset_get_filename_by_pattern(block_cnt++, phdr, fprefix, fsuffix);
|
||||
filename = fileset_get_filename_by_pattern(block_cnt++, rec, fprefix, fsuffix);
|
||||
} else {
|
||||
filename = g_strdup(argv[optind+1]);
|
||||
}
|
||||
|
@ -1409,20 +1411,20 @@ main(int argc, char *argv[])
|
|||
} /* first packet only handling */
|
||||
|
||||
|
||||
buf = wtap_buf_ptr(wth);
|
||||
buf = wtap_get_buf_ptr(wth);
|
||||
|
||||
/*
|
||||
* Not all packets have time stamps. Only process the time
|
||||
* stamp if we have one.
|
||||
*/
|
||||
if (phdr->presence_flags & WTAP_HAS_TS) {
|
||||
if (rec->presence_flags & WTAP_HAS_TS) {
|
||||
if (nstime_is_unset(&block_start)) {
|
||||
block_start = phdr->ts;
|
||||
block_start = rec->ts;
|
||||
}
|
||||
if (secs_per_block != 0) {
|
||||
while (((guint32)(phdr->ts.secs - block_start.secs) > secs_per_block)
|
||||
|| ((guint32)(phdr->ts.secs - block_start.secs) == secs_per_block
|
||||
&& phdr->ts.nsecs >= block_start.nsecs )) { /* time for the next file */
|
||||
while (((guint32)(rec->ts.secs - block_start.secs) > secs_per_block)
|
||||
|| ((guint32)(rec->ts.secs - block_start.secs) == secs_per_block
|
||||
&& rec->ts.nsecs >= block_start.nsecs )) { /* time for the next file */
|
||||
|
||||
if (!wtap_dump_close(pdh, &write_err)) {
|
||||
cfile_close_failure_message(filename, write_err);
|
||||
|
@ -1431,7 +1433,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
block_start.secs = block_start.secs + secs_per_block; /* reset for next interval */
|
||||
g_free(filename);
|
||||
filename = fileset_get_filename_by_pattern(block_cnt++, phdr, fprefix, fsuffix);
|
||||
filename = fileset_get_filename_by_pattern(block_cnt++, rec, fprefix, fsuffix);
|
||||
g_assert(filename);
|
||||
|
||||
if (verbose)
|
||||
|
@ -1462,7 +1464,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
g_free(filename);
|
||||
filename = fileset_get_filename_by_pattern(block_cnt++, phdr, fprefix, fsuffix);
|
||||
filename = fileset_get_filename_by_pattern(block_cnt++, rec, fprefix, fsuffix);
|
||||
g_assert(filename);
|
||||
|
||||
if (verbose)
|
||||
|
@ -1486,8 +1488,8 @@ main(int argc, char *argv[])
|
|||
* Is the packet in the selected timeframe?
|
||||
* If the packet has no time stamp, the answer is "no".
|
||||
*/
|
||||
if (phdr->presence_flags & WTAP_HAS_TS)
|
||||
ts_okay = (phdr->ts.secs >= starttime) && (phdr->ts.secs < stoptime);
|
||||
if (rec->presence_flags & WTAP_HAS_TS)
|
||||
ts_okay = (rec->ts.secs >= starttime) && (rec->ts.secs < stoptime);
|
||||
else
|
||||
ts_okay = FALSE;
|
||||
} else {
|
||||
|
@ -1507,34 +1509,9 @@ main(int argc, char *argv[])
|
|||
/* We simply write it, perhaps after truncating it; we could
|
||||
* do other things, like modify it. */
|
||||
|
||||
phdr = wtap_phdr(wth);
|
||||
rec = wtap_get_rec(wth);
|
||||
|
||||
if (snaplen != 0) {
|
||||
/* Limit capture length to snaplen */
|
||||
if (phdr->caplen > snaplen) {
|
||||
/* Copy and change rather than modify returned phdr */
|
||||
temp_phdr = *phdr;
|
||||
temp_phdr.caplen = snaplen;
|
||||
phdr = &temp_phdr;
|
||||
}
|
||||
/* If -L, also set reported length to snaplen */
|
||||
if (adjlen && phdr->len > snaplen) {
|
||||
/* Copy and change rather than modify returned phdr */
|
||||
temp_phdr = *phdr;
|
||||
temp_phdr.len = snaplen;
|
||||
phdr = &temp_phdr;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* CHOP
|
||||
* Copy and change rather than modify returned phdr.
|
||||
*/
|
||||
temp_phdr = *phdr;
|
||||
handle_chopping(chop, &temp_phdr, phdr, &buf, adjlen);
|
||||
phdr = &temp_phdr;
|
||||
|
||||
if (phdr->presence_flags & WTAP_HAS_TS) {
|
||||
if (rec->presence_flags & WTAP_HAS_TS) {
|
||||
/* Do we adjust timestamps to ensure strict chronological
|
||||
* order? */
|
||||
if (do_strict_time_adjustment) {
|
||||
|
@ -1543,7 +1520,7 @@ main(int argc, char *argv[])
|
|||
nstime_t current;
|
||||
nstime_t delta;
|
||||
|
||||
current = phdr->ts;
|
||||
current = rec->ts;
|
||||
|
||||
nstime_delta(&delta, ¤t, &previous_time);
|
||||
|
||||
|
@ -1555,20 +1532,20 @@ main(int argc, char *argv[])
|
|||
* situation since trace files usually have packets in
|
||||
* chronological order (oldest to newest).
|
||||
* Copy and change rather than modify
|
||||
* returned phdr.
|
||||
* returned rec.
|
||||
*/
|
||||
/* fprintf(stderr, "++out of order, need to adjust this packet!\n"); */
|
||||
temp_phdr = *phdr;
|
||||
temp_phdr.ts.secs = previous_time.secs + strict_time_adj.tv.secs;
|
||||
temp_phdr.ts.nsecs = previous_time.nsecs;
|
||||
if (temp_phdr.ts.nsecs + strict_time_adj.tv.nsecs > ONE_BILLION) {
|
||||
temp_rec = *rec;
|
||||
temp_rec.ts.secs = previous_time.secs + strict_time_adj.tv.secs;
|
||||
temp_rec.ts.nsecs = previous_time.nsecs;
|
||||
if (temp_rec.ts.nsecs + strict_time_adj.tv.nsecs > ONE_BILLION) {
|
||||
/* carry */
|
||||
temp_phdr.ts.secs++;
|
||||
temp_phdr.ts.nsecs += strict_time_adj.tv.nsecs - ONE_BILLION;
|
||||
temp_rec.ts.secs++;
|
||||
temp_rec.ts.nsecs += strict_time_adj.tv.nsecs - ONE_BILLION;
|
||||
} else {
|
||||
temp_phdr.ts.nsecs += strict_time_adj.tv.nsecs;
|
||||
temp_rec.ts.nsecs += strict_time_adj.tv.nsecs;
|
||||
}
|
||||
phdr = &temp_phdr;
|
||||
rec = &temp_rec;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
|
@ -1576,102 +1553,100 @@ main(int argc, char *argv[])
|
|||
* Unconditionally set each timestamp to previous
|
||||
* packet's timestamp plus delta.
|
||||
* Copy and change rather than modify returned
|
||||
* phdr.
|
||||
* rec.
|
||||
*/
|
||||
temp_phdr = *phdr;
|
||||
temp_phdr.ts.secs = previous_time.secs + strict_time_adj.tv.secs;
|
||||
temp_phdr.ts.nsecs = previous_time.nsecs;
|
||||
if (temp_phdr.ts.nsecs + strict_time_adj.tv.nsecs > ONE_BILLION) {
|
||||
temp_rec = *rec;
|
||||
temp_rec.ts.secs = previous_time.secs + strict_time_adj.tv.secs;
|
||||
temp_rec.ts.nsecs = previous_time.nsecs;
|
||||
if (temp_rec.ts.nsecs + strict_time_adj.tv.nsecs > ONE_BILLION) {
|
||||
/* carry */
|
||||
temp_phdr.ts.secs++;
|
||||
temp_phdr.ts.nsecs += strict_time_adj.tv.nsecs - ONE_BILLION;
|
||||
temp_rec.ts.secs++;
|
||||
temp_rec.ts.nsecs += strict_time_adj.tv.nsecs - ONE_BILLION;
|
||||
} else {
|
||||
temp_phdr.ts.nsecs += strict_time_adj.tv.nsecs;
|
||||
temp_rec.ts.nsecs += strict_time_adj.tv.nsecs;
|
||||
}
|
||||
phdr = &temp_phdr;
|
||||
rec = &temp_rec;
|
||||
}
|
||||
}
|
||||
previous_time = phdr->ts;
|
||||
previous_time = rec->ts;
|
||||
}
|
||||
|
||||
if (time_adj.tv.secs != 0) {
|
||||
/* Copy and change rather than modify returned phdr */
|
||||
temp_phdr = *phdr;
|
||||
/* Copy and change rather than modify returned rec */
|
||||
temp_rec = *rec;
|
||||
if (time_adj.is_negative)
|
||||
temp_phdr.ts.secs -= time_adj.tv.secs;
|
||||
temp_rec.ts.secs -= time_adj.tv.secs;
|
||||
else
|
||||
temp_phdr.ts.secs += time_adj.tv.secs;
|
||||
phdr = &temp_phdr;
|
||||
temp_rec.ts.secs += time_adj.tv.secs;
|
||||
rec = &temp_rec;
|
||||
}
|
||||
|
||||
if (time_adj.tv.nsecs != 0) {
|
||||
/* Copy and change rather than modify returned phdr */
|
||||
temp_phdr = *phdr;
|
||||
/* Copy and change rather than modify returned rec */
|
||||
temp_rec = *rec;
|
||||
if (time_adj.is_negative) { /* subtract */
|
||||
if (temp_phdr.ts.nsecs < time_adj.tv.nsecs) { /* borrow */
|
||||
temp_phdr.ts.secs--;
|
||||
temp_phdr.ts.nsecs += ONE_BILLION;
|
||||
if (temp_rec.ts.nsecs < time_adj.tv.nsecs) { /* borrow */
|
||||
temp_rec.ts.secs--;
|
||||
temp_rec.ts.nsecs += ONE_BILLION;
|
||||
}
|
||||
temp_phdr.ts.nsecs -= time_adj.tv.nsecs;
|
||||
temp_rec.ts.nsecs -= time_adj.tv.nsecs;
|
||||
} else { /* add */
|
||||
if (temp_phdr.ts.nsecs + time_adj.tv.nsecs > ONE_BILLION) {
|
||||
if (temp_rec.ts.nsecs + time_adj.tv.nsecs > ONE_BILLION) {
|
||||
/* carry */
|
||||
temp_phdr.ts.secs++;
|
||||
temp_phdr.ts.nsecs += time_adj.tv.nsecs - ONE_BILLION;
|
||||
temp_rec.ts.secs++;
|
||||
temp_rec.ts.nsecs += time_adj.tv.nsecs - ONE_BILLION;
|
||||
} else {
|
||||
temp_phdr.ts.nsecs += time_adj.tv.nsecs;
|
||||
temp_rec.ts.nsecs += time_adj.tv.nsecs;
|
||||
}
|
||||
}
|
||||
phdr = &temp_phdr;
|
||||
rec = &temp_rec;
|
||||
}
|
||||
} /* time stamp adjustment */
|
||||
|
||||
/* remove vlan info */
|
||||
if (rem_vlan) {
|
||||
/* Copy and change rather than modify returned phdr */
|
||||
temp_phdr = *phdr;
|
||||
remove_vlan_info(phdr, buf, &temp_phdr.caplen);
|
||||
phdr = &temp_phdr;
|
||||
}
|
||||
|
||||
/* suppress duplicates by packet window */
|
||||
if (dup_detect) {
|
||||
if (is_duplicate(buf, phdr->caplen)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
|
||||
count, phdr->caplen);
|
||||
for (i = 0; i < 16; i++)
|
||||
fprintf(stderr, "%02x",
|
||||
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
|
||||
fprintf(stderr, "\n");
|
||||
if (rec->rec_type == REC_TYPE_PACKET) {
|
||||
if (snaplen != 0) {
|
||||
/* Limit capture length to snaplen */
|
||||
if (rec->rec_header.packet_header.caplen > snaplen) {
|
||||
/* Copy and change rather than modify returned wtap_rec */
|
||||
temp_rec = *rec;
|
||||
temp_rec.rec_header.packet_header.caplen = snaplen;
|
||||
rec = &temp_rec;
|
||||
}
|
||||
duplicate_count++;
|
||||
count++;
|
||||
continue;
|
||||
} else {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
|
||||
count, phdr->caplen);
|
||||
for (i = 0; i < 16; i++)
|
||||
fprintf(stderr, "%02x",
|
||||
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
|
||||
fprintf(stderr, "\n");
|
||||
/* If -L, also set reported length to snaplen */
|
||||
if (adjlen && rec->rec_header.packet_header.len > snaplen) {
|
||||
/* Copy and change rather than modify returned phdr */
|
||||
temp_rec = *rec;
|
||||
temp_rec.rec_header.packet_header.len = snaplen;
|
||||
rec = &temp_rec;
|
||||
}
|
||||
}
|
||||
} /* suppression of duplicates */
|
||||
|
||||
if (phdr->presence_flags & WTAP_HAS_TS) {
|
||||
/* suppress duplicates by time window */
|
||||
if (dup_detect_by_time) {
|
||||
nstime_t current;
|
||||
/*
|
||||
* CHOP
|
||||
* Copy and change rather than modify returned phdr.
|
||||
*/
|
||||
temp_rec = *rec;
|
||||
handle_chopping(chop, &temp_rec.rec_header.packet_header,
|
||||
&rec->rec_header.packet_header, &buf,
|
||||
adjlen);
|
||||
rec = &temp_rec;
|
||||
|
||||
current.secs = phdr->ts.secs;
|
||||
current.nsecs = phdr->ts.nsecs;
|
||||
/* remove vlan info */
|
||||
if (rem_vlan) {
|
||||
/* Copy and change rather than modify returned rec */
|
||||
temp_rec = *rec;
|
||||
remove_vlan_info(&rec->rec_header.packet_header, buf,
|
||||
&temp_rec.rec_header.packet_header.caplen);
|
||||
rec = &temp_rec;
|
||||
}
|
||||
|
||||
if (is_duplicate_rel_time(buf, phdr->caplen, ¤t)) {
|
||||
/* suppress duplicates by packet window */
|
||||
if (dup_detect) {
|
||||
if (is_duplicate(buf, rec->rec_header.packet_header.caplen)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
|
||||
count, phdr->caplen);
|
||||
count,
|
||||
rec->rec_header.packet_header.caplen);
|
||||
for (i = 0; i < 16; i++)
|
||||
fprintf(stderr, "%02x",
|
||||
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
|
||||
|
@ -1683,32 +1658,93 @@ main(int argc, char *argv[])
|
|||
} else {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
|
||||
count, phdr->caplen);
|
||||
count,
|
||||
rec->rec_header.packet_header.caplen);
|
||||
for (i = 0; i < 16; i++)
|
||||
fprintf(stderr, "%02x",
|
||||
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* suppress duplicates by time window */
|
||||
} /* suppression of duplicates */
|
||||
|
||||
if (change_offset > phdr->caplen) {
|
||||
fprintf(stderr, "change offset %u is longer than caplen %u in packet %u\n",
|
||||
change_offset, phdr->caplen, count);
|
||||
if (rec->presence_flags & WTAP_HAS_TS) {
|
||||
/* suppress duplicates by time window */
|
||||
if (dup_detect_by_time) {
|
||||
nstime_t current;
|
||||
|
||||
current.secs = rec->ts.secs;
|
||||
current.nsecs = rec->ts.nsecs;
|
||||
|
||||
if (is_duplicate_rel_time(buf,
|
||||
rec->rec_header.packet_header.caplen,
|
||||
¤t)) {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
|
||||
count,
|
||||
rec->rec_header.packet_header.caplen);
|
||||
for (i = 0; i < 16; i++)
|
||||
fprintf(stderr, "%02x",
|
||||
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
duplicate_count++;
|
||||
count++;
|
||||
continue;
|
||||
} else {
|
||||
if (verbose) {
|
||||
fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
|
||||
count,
|
||||
rec->rec_header.packet_header.caplen);
|
||||
for (i = 0; i < 16; i++)
|
||||
fprintf(stderr, "%02x",
|
||||
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* suppress duplicates by time window */
|
||||
}
|
||||
|
||||
/* Random error mutation */
|
||||
if (err_prob > 0.0 && change_offset <= phdr->caplen) {
|
||||
do_mutation = FALSE;
|
||||
caplen = 0;
|
||||
if (err_prob > 0.0) {
|
||||
switch (rec->rec_type) {
|
||||
|
||||
case REC_TYPE_PACKET:
|
||||
caplen = rec->rec_header.packet_header.caplen;
|
||||
do_mutation = TRUE;
|
||||
break;
|
||||
|
||||
case REC_TYPE_SYSCALL:
|
||||
caplen = rec->rec_header.syscall_header.caplen;
|
||||
do_mutation = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (change_offset > caplen) {
|
||||
fprintf(stderr, "change offset %u is longer than caplen %u in packet %u\n",
|
||||
change_offset, caplen, count);
|
||||
do_mutation = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (do_mutation) {
|
||||
int real_data_start = 0;
|
||||
|
||||
/* Protect non-protocol data */
|
||||
if (wtap_file_type_subtype(wth) == WTAP_FILE_TYPE_SUBTYPE_CATAPULT_DCT2000)
|
||||
real_data_start = find_dct2000_real_data(buf);
|
||||
switch (rec->rec_type) {
|
||||
|
||||
case REC_TYPE_PACKET:
|
||||
if (wtap_file_type_subtype(wth) == WTAP_FILE_TYPE_SUBTYPE_CATAPULT_DCT2000)
|
||||
real_data_start = find_dct2000_real_data(buf);
|
||||
break;
|
||||
}
|
||||
|
||||
real_data_start += change_offset;
|
||||
|
||||
for (i = real_data_start; i < (int) phdr->caplen; i++) {
|
||||
for (i = real_data_start; i < (int) caplen; i++) {
|
||||
if (rand() <= err_prob * RAND_MAX) {
|
||||
err_type = rand() / (RAND_MAX / ERR_WT_TOTAL + 1);
|
||||
|
||||
|
@ -1734,7 +1770,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (err_type < ERR_WT_FMT) {
|
||||
if ((unsigned int)i < phdr->caplen - 2)
|
||||
if ((unsigned int)i < caplen - 2)
|
||||
g_strlcpy((char*) &buf[i], "%s", 2);
|
||||
err_type = ERR_WT_TOTAL;
|
||||
} else {
|
||||
|
@ -1742,9 +1778,9 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (err_type < ERR_WT_AA) {
|
||||
for (j = i; j < (int) phdr->caplen; j++)
|
||||
for (j = i; j < (int) caplen; j++)
|
||||
buf[j] = 0xAA;
|
||||
i = phdr->caplen;
|
||||
i = caplen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1756,21 +1792,21 @@ main(int argc, char *argv[])
|
|||
(const char*)g_tree_lookup(frames_user_comments, GUINT_TO_POINTER(read_count));
|
||||
/* XXX: What about comment changed to no comment? */
|
||||
if (comment != NULL) {
|
||||
/* Copy and change rather than modify returned phdr */
|
||||
temp_phdr = *phdr;
|
||||
temp_phdr.opt_comment = g_strdup(comment);
|
||||
temp_phdr.has_comment_changed = TRUE;
|
||||
phdr = &temp_phdr;
|
||||
/* Copy and change rather than modify returned rec */
|
||||
temp_rec = *rec;
|
||||
temp_rec.opt_comment = g_strdup(comment);
|
||||
temp_rec.has_comment_changed = TRUE;
|
||||
rec = &temp_rec;
|
||||
} else {
|
||||
/* Copy and change rather than modify returned phdr */
|
||||
temp_phdr = *phdr;
|
||||
temp_phdr.has_comment_changed = FALSE;
|
||||
phdr = &temp_phdr;
|
||||
/* Copy and change rather than modify returned rec */
|
||||
temp_rec = *rec;
|
||||
temp_rec.has_comment_changed = FALSE;
|
||||
rec = &temp_rec;
|
||||
}
|
||||
}
|
||||
|
||||
/* Attempt to dump out current frame to the output file */
|
||||
if (!wtap_dump(pdh, phdr, buf, &write_err, &write_err_info)) {
|
||||
if (!wtap_dump(pdh, rec, buf, &write_err, &write_err_info)) {
|
||||
cfile_write_failure_message("editcap", argv[optind],
|
||||
filename,
|
||||
write_err, write_err_info,
|
||||
|
@ -1875,14 +1911,10 @@ find_dct2000_real_data(guint8 *buf)
|
|||
* positive chop length, and one by the negative chop length.
|
||||
*/
|
||||
static void
|
||||
handle_chopping(chop_t chop, struct wtap_pkthdr *out_phdr,
|
||||
const struct wtap_pkthdr *in_phdr, guint8 **buf,
|
||||
handle_chopping(chop_t chop, wtap_packet_header *out_phdr,
|
||||
const wtap_packet_header *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)
|
||||
|
|
|
@ -121,7 +121,8 @@ dissect_file_record(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
|
|||
|
||||
fh_tree = proto_item_add_subtree(ti, ett_file);
|
||||
|
||||
proto_tree_add_int(fh_tree, hf_file_ftap_encap, tvb, 0, 0, pinfo->phdr->pkt_encap);
|
||||
if (pinfo->rec->rec_type == REC_TYPE_PACKET)
|
||||
proto_tree_add_int(fh_tree, hf_file_ftap_encap, tvb, 0, 0, pinfo->rec->rec_header.packet_header.pkt_encap);
|
||||
|
||||
proto_tree_add_uint(fh_tree, hf_file_record_number, tvb, 0, 0, pinfo->num);
|
||||
|
||||
|
@ -177,12 +178,13 @@ dissect_file_record(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
|
|||
*/
|
||||
__try {
|
||||
#endif
|
||||
if (!dissector_try_uint(file_encap_dissector_table, pinfo->phdr->pkt_encap,
|
||||
if (pinfo->rec->rec_type != REC_TYPE_PACKET ||
|
||||
!dissector_try_uint(file_encap_dissector_table, pinfo->rec->rec_header.packet_header.pkt_encap,
|
||||
tvb, pinfo, parent_tree)) {
|
||||
|
||||
col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNKNOWN");
|
||||
col_add_fstr(pinfo->cinfo, COL_INFO, "FTAP_ENCAP = %d",
|
||||
pinfo->phdr->pkt_encap);
|
||||
pinfo->rec->rec_header.packet_header.pkt_encap);
|
||||
call_data_dissector(tvb, pinfo, parent_tree);
|
||||
}
|
||||
#ifdef _MSC_VER
|
||||
|
|
|
@ -167,8 +167,8 @@ save_command(guint32 cmd, guint32 arg0, guint32 arg1, guint32 data_length,
|
|||
|
||||
frame_number = pinfo->num;
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
else
|
||||
interface_id = 0;
|
||||
|
||||
|
@ -391,8 +391,8 @@ dissect_adb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
|||
return offset;
|
||||
}
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
else
|
||||
interface_id = 0;
|
||||
|
||||
|
|
|
@ -101,8 +101,8 @@ dissect_adb_cs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
|
|||
main_item = proto_tree_add_item(tree, proto_adb_cs, tvb, offset, -1, ENC_NA);
|
||||
main_tree = proto_item_add_subtree(main_item, ett_adb_cs);
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
wireshark_interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
wireshark_interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
|
||||
if (pinfo->destport == server_port) { /* Client sent to Server */
|
||||
client_request_t *client_request;
|
||||
|
@ -117,8 +117,8 @@ dissect_adb_cs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
|
|||
|
||||
col_add_fstr(pinfo->cinfo, COL_INFO, "Client");
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
wireshark_interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
wireshark_interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
|
||||
key[0].length = 1;
|
||||
key[0].key = &wireshark_interface_id;
|
||||
|
@ -182,8 +182,8 @@ dissect_adb_cs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
|
|||
}
|
||||
|
||||
if (!pinfo->fd->flags.visited && length > 0) { /* save Length to client_requests */
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
wireshark_interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
wireshark_interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
|
||||
key[0].length = 1;
|
||||
key[0].key = &wireshark_interface_id;
|
||||
|
@ -209,8 +209,8 @@ dissect_adb_cs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _
|
|||
|
||||
if (!pinfo->fd->flags.visited && (length == -1 || (client_request && client_request->service_in == -1 && tvb_reported_length_remaining(tvb, offset) > 0))) { /* save Service to client_requests */
|
||||
if (!client_request) {
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
wireshark_interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
wireshark_interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
|
||||
key[0].length = 1;
|
||||
key[0].key = &wireshark_interface_id;
|
||||
|
|
|
@ -2679,8 +2679,8 @@ dissect_bluetooth_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
main_tree = proto_item_add_subtree(main_item, ett_bluetooth);
|
||||
|
||||
bluetooth_data = (bluetooth_data_t *) wmem_new(wmem_packet_scope(), bluetooth_data_t);
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
bluetooth_data->interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
bluetooth_data->interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
else
|
||||
bluetooth_data->interface_id = HCI_INTERFACE_DEFAULT;
|
||||
bluetooth_data->adapter_id = HCI_ADAPTER_DEFAULT;
|
||||
|
@ -2761,7 +2761,7 @@ dissect_bluetooth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
|
|||
bluetooth_data->previous_protocol_data_type = BT_PD_NONE;
|
||||
bluetooth_data->previous_protocol_data.none = NULL;
|
||||
|
||||
if (!dissector_try_uint_new(bluetooth_table, pinfo->phdr->pkt_encap, tvb, pinfo, tree, TRUE, bluetooth_data)) {
|
||||
if (!dissector_try_uint_new(bluetooth_table, pinfo->rec->rec_header.packet_header.pkt_encap, tvb, pinfo, tree, TRUE, bluetooth_data)) {
|
||||
call_data_dissector(tvb, pinfo, tree);
|
||||
}
|
||||
|
||||
|
@ -2790,7 +2790,7 @@ dissect_bluetooth_bthci(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
|
|||
bluetooth_data->previous_protocol_data_type = BT_PD_BTHCI;
|
||||
bluetooth_data->previous_protocol_data.bthci = (struct bthci_phdr *)data;
|
||||
|
||||
if (!dissector_try_uint_new(bluetooth_table, pinfo->phdr->pkt_encap, tvb, pinfo, tree, TRUE, bluetooth_data)) {
|
||||
if (!dissector_try_uint_new(bluetooth_table, pinfo->rec->rec_header.packet_header.pkt_encap, tvb, pinfo, tree, TRUE, bluetooth_data)) {
|
||||
call_data_dissector(tvb, pinfo, tree);
|
||||
}
|
||||
|
||||
|
@ -2818,7 +2818,7 @@ dissect_bluetooth_btmon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
|
|||
bluetooth_data->previous_protocol_data_type = BT_PD_BTMON;
|
||||
bluetooth_data->previous_protocol_data.btmon = (struct btmon_phdr *)data;
|
||||
|
||||
if (!dissector_try_uint_new(bluetooth_table, pinfo->phdr->pkt_encap, tvb, pinfo, tree, TRUE, bluetooth_data)) {
|
||||
if (!dissector_try_uint_new(bluetooth_table, pinfo->rec->rec_header.packet_header.pkt_encap, tvb, pinfo, tree, TRUE, bluetooth_data)) {
|
||||
call_data_dissector(tvb, pinfo, tree);
|
||||
}
|
||||
|
||||
|
|
|
@ -705,8 +705,8 @@ dissect_connrequest(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
guint32 chandle;
|
||||
psm_data_t *psm_data;
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
else
|
||||
interface_id = HCI_INTERFACE_DEFAULT;
|
||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_DEFAULT;
|
||||
|
@ -767,8 +767,8 @@ dissect_connrequest(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
guint32 adapter_id;
|
||||
guint32 chandle;
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
else
|
||||
interface_id = HCI_INTERFACE_DEFAULT;
|
||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_DEFAULT;
|
||||
|
@ -859,8 +859,8 @@ dissect_le_credit_based_connrequest(tvbuff_t *tvb, int offset, packet_info *pinf
|
|||
guint32 chandle;
|
||||
psm_data_t *psm_data;
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
else
|
||||
interface_id = HCI_INTERFACE_DEFAULT;
|
||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_DEFAULT;
|
||||
|
@ -920,8 +920,8 @@ dissect_le_credit_based_connrequest(tvbuff_t *tvb, int offset, packet_info *pinf
|
|||
guint32 adapter_id;
|
||||
guint32 chandle;
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
else
|
||||
interface_id = HCI_INTERFACE_DEFAULT;
|
||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_DEFAULT;
|
||||
|
@ -1006,8 +1006,8 @@ dissect_le_credit_based_connresponse(tvbuff_t *tvb, int offset, packet_info *pin
|
|||
guint32 chandle;
|
||||
guint32 cid;
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
else
|
||||
interface_id = HCI_INTERFACE_DEFAULT;
|
||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_DEFAULT;
|
||||
|
@ -1268,8 +1268,8 @@ dissect_configrequest(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
guint32 chandle;
|
||||
guint32 cid;
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
else
|
||||
interface_id = HCI_INTERFACE_DEFAULT;
|
||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_DEFAULT;
|
||||
|
@ -1465,8 +1465,8 @@ dissect_configresponse(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
guint32 chandle;
|
||||
guint32 cid;
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
else
|
||||
interface_id = HCI_INTERFACE_DEFAULT;
|
||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_DEFAULT;
|
||||
|
@ -1556,8 +1556,8 @@ dissect_connresponse(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
guint32 chandle;
|
||||
guint32 cid;
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
else
|
||||
interface_id = HCI_INTERFACE_DEFAULT;
|
||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_DEFAULT;
|
||||
|
@ -1757,8 +1757,8 @@ dissect_disconnrequestresponse(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
guint32 key_scid;
|
||||
guint32 key_dcid;
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
else
|
||||
interface_id = HCI_INTERFACE_DEFAULT;
|
||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_DEFAULT;
|
||||
|
@ -1849,8 +1849,8 @@ dissect_disconnrequestresponse(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
|||
guint32 chandle;
|
||||
guint32 key_dcid;
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
else
|
||||
interface_id = HCI_INTERFACE_DEFAULT;
|
||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_DEFAULT;
|
||||
|
@ -2435,8 +2435,8 @@ dissect_btl2cap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
|||
|
||||
l2cap_data = wmem_new(wmem_packet_scope(), btl2cap_data_t);
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
l2cap_data->interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
l2cap_data->interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
else
|
||||
l2cap_data->interface_id = HCI_INTERFACE_DEFAULT;
|
||||
if (acl_data) {
|
||||
|
@ -2712,8 +2712,8 @@ dissect_btl2cap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
|||
guint32 chandle;
|
||||
guint32 key_cid;
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->phdr->interface_id;
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
else
|
||||
interface_id = HCI_INTERFACE_DEFAULT;
|
||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_DEFAULT;
|
||||
|
|
|
@ -576,8 +576,8 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
|||
|
||||
if (bluetooth_data)
|
||||
interface_id = bluetooth_data->interface_id;
|
||||
else if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->phdr->interface_id;
|
||||
else if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||
else
|
||||
interface_id = HCI_INTERFACE_DEFAULT;
|
||||
|
||||
|
|
|
@ -228,14 +228,14 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
|
|||
|
||||
DISSECTOR_ASSERT(fr_data);
|
||||
|
||||
switch (pinfo->phdr->rec_type) {
|
||||
switch (pinfo->rec->rec_type) {
|
||||
|
||||
case REC_TYPE_PACKET:
|
||||
pinfo->current_proto = "Frame";
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_PACK_FLAGS) {
|
||||
if (pinfo->phdr->pack_flags & 0x00000001)
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_PACK_FLAGS) {
|
||||
if (pinfo->rec->rec_header.packet_header.pack_flags & 0x00000001)
|
||||
pinfo->p2p_dir = P2P_DIR_RECV;
|
||||
if (pinfo->phdr->pack_flags & 0x00000002)
|
||||
if (pinfo->rec->rec_header.packet_header.pack_flags & 0x00000002)
|
||||
pinfo->p2p_dir = P2P_DIR_SENT;
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
|
|||
* overrides the packet record.
|
||||
*/
|
||||
if (pinfo->pseudo_header != NULL) {
|
||||
switch (pinfo->phdr->pkt_encap) {
|
||||
switch (pinfo->rec->rec_header.packet_header.pkt_encap) {
|
||||
|
||||
case WTAP_ENCAP_WFLEET_HDLC:
|
||||
case WTAP_ENCAP_CHDLC_WITH_PHDR:
|
||||
|
@ -340,13 +340,49 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
|
|||
cap_plurality = plurality(cap_len, "", "s");
|
||||
frame_plurality = plurality(frame_len, "", "s");
|
||||
|
||||
switch (pinfo->phdr->rec_type) {
|
||||
switch (pinfo->rec->rec_type) {
|
||||
case REC_TYPE_PACKET:
|
||||
ti = proto_tree_add_protocol_format(tree, proto_frame, tvb, 0, tvb_captured_length(tvb),
|
||||
"Frame %u: %u byte%s on wire",
|
||||
pinfo->num, frame_len, frame_plurality);
|
||||
if (generate_bits_field)
|
||||
proto_item_append_text(ti, " (%u bits)", frame_len * 8);
|
||||
proto_item_append_text(ti, ", %u byte%s captured",
|
||||
cap_len, cap_plurality);
|
||||
if (generate_bits_field) {
|
||||
proto_item_append_text(ti, " (%u bits)",
|
||||
cap_len * 8);
|
||||
}
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID) {
|
||||
proto_item_append_text(ti, " on interface %u",
|
||||
pinfo->rec->rec_header.packet_header.interface_id);
|
||||
}
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_PACK_FLAGS) {
|
||||
if (pinfo->rec->rec_header.packet_header.pack_flags & 0x00000001)
|
||||
proto_item_append_text(ti, " (inbound)");
|
||||
if (pinfo->rec->rec_header.packet_header.pack_flags & 0x00000002)
|
||||
proto_item_append_text(ti, " (outbound)");
|
||||
}
|
||||
break;
|
||||
|
||||
case REC_TYPE_FT_SPECIFIC_EVENT:
|
||||
ti = proto_tree_add_protocol_format(tree, proto_frame, tvb, 0, tvb_captured_length(tvb),
|
||||
"Event %u: %u byte%s on wire",
|
||||
pinfo->num, frame_len, frame_plurality);
|
||||
if (generate_bits_field)
|
||||
proto_item_append_text(ti, " (%u bits)", frame_len * 8);
|
||||
proto_item_append_text(ti, ", %u byte%s captured",
|
||||
cap_len, cap_plurality);
|
||||
if (generate_bits_field) {
|
||||
proto_item_append_text(ti, " (%u bits)",
|
||||
cap_len * 8);
|
||||
}
|
||||
break;
|
||||
|
||||
case REC_TYPE_FT_SPECIFIC_REPORT:
|
||||
ti = proto_tree_add_protocol_format(tree, proto_frame, tvb, 0, tvb_captured_length(tvb),
|
||||
"Frame %u: %u byte%s on wire",
|
||||
pinfo->num, frame_len, frame_plurality);
|
||||
"Report %u: %u byte%s on wire",
|
||||
pinfo->num, frame_len, frame_plurality);
|
||||
if (generate_bits_field)
|
||||
proto_item_append_text(ti, " (%u bits)", frame_len * 8);
|
||||
proto_item_append_text(ti, ", %u byte%s captured",
|
||||
|
@ -366,39 +402,28 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
|
|||
* be preferred?
|
||||
*/
|
||||
ti = proto_tree_add_protocol_format(tree, proto_syscall, tvb, 0, tvb_captured_length(tvb),
|
||||
"System Call %u: %u byte%s",
|
||||
pinfo->num, frame_len, frame_plurality);
|
||||
"System Call %u: %u byte%s",
|
||||
pinfo->num, frame_len, frame_plurality);
|
||||
break;
|
||||
}
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID) {
|
||||
proto_item_append_text(ti, " on interface %u",
|
||||
pinfo->phdr->interface_id);
|
||||
}
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_PACK_FLAGS) {
|
||||
if (pinfo->phdr->pack_flags & 0x00000001)
|
||||
proto_item_append_text(ti, " (inbound)");
|
||||
if (pinfo->phdr->pack_flags & 0x00000002)
|
||||
proto_item_append_text(ti, " (outbound)");
|
||||
}
|
||||
|
||||
fh_tree = proto_item_add_subtree(ti, ett_frame);
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID &&
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID &&
|
||||
(proto_field_is_referenced(tree, hf_frame_interface_id) || proto_field_is_referenced(tree, hf_frame_interface_name) || proto_field_is_referenced(tree, hf_frame_interface_description))) {
|
||||
const char *interface_name = epan_get_interface_name(pinfo->epan, pinfo->phdr->interface_id);
|
||||
const char *interface_description = epan_get_interface_description(pinfo->epan, pinfo->phdr->interface_id);
|
||||
const char *interface_name = epan_get_interface_name(pinfo->epan, pinfo->rec->rec_header.packet_header.interface_id);
|
||||
const char *interface_description = epan_get_interface_description(pinfo->epan, pinfo->rec->rec_header.packet_header.interface_id);
|
||||
proto_tree *if_tree;
|
||||
proto_item *if_item;
|
||||
|
||||
if (interface_name) {
|
||||
if_item = proto_tree_add_uint_format_value(fh_tree, hf_frame_interface_id, tvb, 0, 0,
|
||||
pinfo->phdr->interface_id, "%u (%s)",
|
||||
pinfo->phdr->interface_id, interface_name);
|
||||
pinfo->rec->rec_header.packet_header.interface_id, "%u (%s)",
|
||||
pinfo->rec->rec_header.packet_header.interface_id, interface_name);
|
||||
if_tree = proto_item_add_subtree(if_item, ett_ifname);
|
||||
proto_tree_add_string(if_tree, hf_frame_interface_name, tvb, 0, 0, interface_name);
|
||||
} else {
|
||||
if_item = proto_tree_add_uint(fh_tree, hf_frame_interface_id, tvb, 0, 0, pinfo->phdr->interface_id);
|
||||
if_item = proto_tree_add_uint(fh_tree, hf_frame_interface_id, tvb, 0, 0, pinfo->rec->rec_header.packet_header.interface_id);
|
||||
}
|
||||
|
||||
if (interface_description) {
|
||||
|
@ -407,7 +432,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
|
|||
}
|
||||
}
|
||||
|
||||
if (pinfo->phdr->presence_flags & WTAP_HAS_PACK_FLAGS) {
|
||||
if (pinfo->rec->presence_flags & WTAP_HAS_PACK_FLAGS) {
|
||||
proto_tree *flags_tree;
|
||||
proto_item *flags_item;
|
||||
static const int * flags[] = {
|
||||
|
@ -426,13 +451,13 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
|
|||
NULL
|
||||
};
|
||||
|
||||
flags_item = proto_tree_add_uint(fh_tree, hf_frame_pack_flags, tvb, 0, 0, pinfo->phdr->pack_flags);
|
||||
flags_item = proto_tree_add_uint(fh_tree, hf_frame_pack_flags, tvb, 0, 0, pinfo->rec->rec_header.packet_header.pack_flags);
|
||||
flags_tree = proto_item_add_subtree(flags_item, ett_flags);
|
||||
proto_tree_add_bitmask_list_value(flags_tree, tvb, 0, 0, flags, pinfo->phdr->pack_flags);
|
||||
proto_tree_add_bitmask_list_value(flags_tree, tvb, 0, 0, flags, pinfo->rec->rec_header.packet_header.pack_flags);
|
||||
}
|
||||
|
||||
if (pinfo->phdr->rec_type == REC_TYPE_PACKET)
|
||||
proto_tree_add_int(fh_tree, hf_frame_wtap_encap, tvb, 0, 0, pinfo->phdr->pkt_encap);
|
||||
if (pinfo->rec->rec_type == REC_TYPE_PACKET)
|
||||
proto_tree_add_int(fh_tree, hf_frame_wtap_encap, tvb, 0, 0, pinfo->rec->rec_header.packet_header.pkt_encap);
|
||||
|
||||
if (pinfo->presence_flags & PINFO_HAS_TS) {
|
||||
proto_tree_add_time(fh_tree, hf_frame_arrival_time, tvb,
|
||||
|
@ -512,16 +537,19 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
|
|||
ti = proto_tree_add_boolean(fh_tree, hf_frame_ignored, tvb, 0, 0,pinfo->fd->flags.ignored);
|
||||
PROTO_ITEM_SET_GENERATED(ti);
|
||||
|
||||
/* Check for existences of P2P pseudo header */
|
||||
if (pinfo->p2p_dir != P2P_DIR_UNKNOWN) {
|
||||
proto_tree_add_int(fh_tree, hf_frame_p2p_dir, tvb,
|
||||
0, 0, pinfo->p2p_dir);
|
||||
}
|
||||
if (pinfo->rec->rec_type == REC_TYPE_PACKET) {
|
||||
/* Check for existences of P2P pseudo header */
|
||||
if (pinfo->p2p_dir != P2P_DIR_UNKNOWN) {
|
||||
proto_tree_add_int(fh_tree, hf_frame_p2p_dir, tvb,
|
||||
0, 0, pinfo->p2p_dir);
|
||||
}
|
||||
|
||||
/* Check for existences of MTP2 link number */
|
||||
if ((pinfo->pseudo_header != NULL ) && (pinfo->phdr->pkt_encap == WTAP_ENCAP_MTP2_WITH_PHDR)) {
|
||||
proto_tree_add_uint(fh_tree, hf_link_number, tvb,
|
||||
0, 0, pinfo->link_number);
|
||||
/* Check for existences of MTP2 link number */
|
||||
if ((pinfo->pseudo_header != NULL) &&
|
||||
(pinfo->rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_MTP2_WITH_PHDR)) {
|
||||
proto_tree_add_uint(fh_tree, hf_link_number, tvb,
|
||||
0, 0, pinfo->link_number);
|
||||
}
|
||||
}
|
||||
|
||||
if (show_file_off) {
|
||||
|
@ -552,7 +580,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
|
|||
*/
|
||||
__try {
|
||||
#endif
|
||||
switch (pinfo->phdr->rec_type) {
|
||||
switch (pinfo->rec->rec_type) {
|
||||
|
||||
case REC_TYPE_PACKET:
|
||||
if ((force_docsis_encap) && (docsis_handle)) {
|
||||
|
@ -561,12 +589,12 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
|
|||
(void *)pinfo->pseudo_header);
|
||||
} else {
|
||||
if (!dissector_try_uint_new(wtap_encap_dissector_table,
|
||||
pinfo->phdr->pkt_encap, tvb, pinfo,
|
||||
pinfo->rec->rec_header.packet_header.pkt_encap, tvb, pinfo,
|
||||
parent_tree, TRUE,
|
||||
(void *)pinfo->pseudo_header)) {
|
||||
col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNKNOWN");
|
||||
col_add_fstr(pinfo->cinfo, COL_INFO, "WTAP_ENCAP = %d",
|
||||
pinfo->phdr->pkt_encap);
|
||||
pinfo->rec->rec_header.packet_header.pkt_encap);
|
||||
call_data_dissector(tvb, pinfo, parent_tree);
|
||||
}
|
||||