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>
This commit is contained in:
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;
|
gint64 bytes = 0;
|
||||||
guint32 snaplen_min_inferred = 0xffffffff;
|
guint32 snaplen_min_inferred = 0xffffffff;
|
||||||
guint32 snaplen_max_inferred = 0;
|
guint32 snaplen_max_inferred = 0;
|
||||||
const struct wtap_pkthdr *phdr;
|
wtap_rec *rec;
|
||||||
capture_info cf_info;
|
capture_info cf_info;
|
||||||
gboolean have_times = TRUE;
|
gboolean have_times = TRUE;
|
||||||
nstime_t start_time;
|
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 */
|
/* Tally up data that we need to parse through the file to find */
|
||||||
while (wtap_read(wth, &err, &err_info, &data_offset)) {
|
while (wtap_read(wth, &err, &err_info, &data_offset)) {
|
||||||
phdr = wtap_phdr(wth);
|
rec = wtap_get_rec(wth);
|
||||||
if (phdr->presence_flags & WTAP_HAS_TS) {
|
if (rec->presence_flags & WTAP_HAS_TS) {
|
||||||
prev_time = cur_time;
|
prev_time = cur_time;
|
||||||
cur_time = phdr->ts;
|
cur_time = rec->ts;
|
||||||
if (packet == 0) {
|
if (packet == 0) {
|
||||||
start_time = phdr->ts;
|
start_time = rec->ts;
|
||||||
start_time_tsprec = phdr->pkt_tsprec;
|
start_time_tsprec = rec->tsprec;
|
||||||
stop_time = phdr->ts;
|
stop_time = rec->ts;
|
||||||
stop_time_tsprec = phdr->pkt_tsprec;
|
stop_time_tsprec = rec->tsprec;
|
||||||
prev_time = phdr->ts;
|
prev_time = rec->ts;
|
||||||
}
|
}
|
||||||
if (nstime_cmp(&cur_time, &prev_time) < 0) {
|
if (nstime_cmp(&cur_time, &prev_time) < 0) {
|
||||||
order = NOT_IN_ORDER;
|
order = NOT_IN_ORDER;
|
||||||
}
|
}
|
||||||
if (nstime_cmp(&cur_time, &start_time) < 0) {
|
if (nstime_cmp(&cur_time, &start_time) < 0) {
|
||||||
start_time = cur_time;
|
start_time = cur_time;
|
||||||
start_time_tsprec = phdr->pkt_tsprec;
|
start_time_tsprec = rec->tsprec;
|
||||||
}
|
}
|
||||||
if (nstime_cmp(&cur_time, &stop_time) > 0) {
|
if (nstime_cmp(&cur_time, &stop_time) > 0) {
|
||||||
stop_time = cur_time;
|
stop_time = cur_time;
|
||||||
stop_time_tsprec = phdr->pkt_tsprec;
|
stop_time_tsprec = rec->tsprec;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
have_times = FALSE; /* at least one packet has no time stamp */
|
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;
|
order = ORDER_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (phdr->rec_type == REC_TYPE_PACKET) {
|
if (rec->rec_type == REC_TYPE_PACKET) {
|
||||||
bytes+=phdr->len;
|
bytes += rec->rec_header.packet_header.len;
|
||||||
packet++;
|
packet++;
|
||||||
|
|
||||||
/* If caplen < len for a rcd, then presumably */
|
/* If caplen < len for a rcd, then presumably */
|
||||||
/* 'Limit packet capture length' was done for this rcd. */
|
/* 'Limit packet capture length' was done for this rcd. */
|
||||||
/* Keep track as to the min/max actual snapshot lengths */
|
/* Keep track as to the min/max actual snapshot lengths */
|
||||||
/* seen for this file. */
|
/* seen for this file. */
|
||||||
if (phdr->caplen < phdr->len) {
|
if (rec->rec_header.packet_header.caplen < rec->rec_header.packet_header.len) {
|
||||||
if (phdr->caplen < snaplen_min_inferred)
|
if (rec->rec_header.packet_header.caplen < snaplen_min_inferred)
|
||||||
snaplen_min_inferred = phdr->caplen;
|
snaplen_min_inferred = rec->rec_header.packet_header.caplen;
|
||||||
if (phdr->caplen > snaplen_max_inferred)
|
if (rec->rec_header.packet_header.caplen > snaplen_max_inferred)
|
||||||
snaplen_max_inferred = phdr->caplen;
|
snaplen_max_inferred = rec->rec_header.packet_header.caplen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((phdr->pkt_encap > 0) && (phdr->pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
|
if ((rec->rec_header.packet_header.pkt_encap > 0) &&
|
||||||
cf_info.encap_counts[phdr->pkt_encap] += 1;
|
(rec->rec_header.packet_header.pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
|
||||||
|
cf_info.encap_counts[rec->rec_header.packet_header.pkt_encap] += 1;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "capinfos: Unknown packet encapsulation %d in frame %u of file \"%s\"\n",
|
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 */
|
/* 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 */
|
/* 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
|
* OK, re-fetch the number of interfaces, as there might have
|
||||||
* been an interface that was in the middle of packets, and
|
* 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);
|
g_free(idb_info);
|
||||||
idb_info = NULL;
|
idb_info = NULL;
|
||||||
}
|
}
|
||||||
if (phdr->interface_id < cf_info.num_interfaces) {
|
if (rec->rec_header.packet_header.interface_id < cf_info.num_interfaces) {
|
||||||
g_array_index(cf_info.interface_packet_counts, guint32, phdr->interface_id) += 1;
|
g_array_index(cf_info.interface_packet_counts, guint32,
|
||||||
|
rec->rec_header.packet_header.interface_id) += 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cf_info.pkt_interface_id_unknown += 1;
|
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;
|
int err;
|
||||||
gchar *err_info;
|
gchar *err_info;
|
||||||
gint64 data_offset;
|
gint64 data_offset;
|
||||||
struct wtap_pkthdr *phdr;
|
wtap_rec *rec;
|
||||||
union wtap_pseudo_header *pseudo_header;
|
union wtap_pseudo_header *pseudo_header;
|
||||||
int wtap_linktype;
|
int wtap_linktype;
|
||||||
const guchar *buf;
|
const guchar *buf;
|
||||||
|
@ -53,15 +53,17 @@ void capture_info_new_packets(int to_read, info_data_t* cap_info)
|
||||||
while (to_read > 0) {
|
while (to_read > 0) {
|
||||||
wtap_cleareof(cap_info->wtap);
|
wtap_cleareof(cap_info->wtap);
|
||||||
if (wtap_read(cap_info->wtap, &err, &err_info, &data_offset)) {
|
if (wtap_read(cap_info->wtap, &err, &err_info, &data_offset)) {
|
||||||
phdr = wtap_phdr(cap_info->wtap);
|
rec = wtap_get_rec(cap_info->wtap);
|
||||||
pseudo_header = &phdr->pseudo_header;
|
if (rec->rec_type == REC_TYPE_PACKET) {
|
||||||
wtap_linktype = phdr->pkt_encap;
|
pseudo_header = &rec->rec_header.packet_header.pseudo_header;
|
||||||
buf = wtap_buf_ptr(cap_info->wtap);
|
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");*/
|
/*g_warning("new packet");*/
|
||||||
to_read--;
|
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 */
|
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 */
|
gboolean search_in_progress; /* TRUE if user just clicked OK in the Find dialog or hit <control>N/B */
|
||||||
/* packet data */
|
/* packet data */
|
||||||
struct wtap_pkthdr phdr; /* Packet header */
|
wtap_rec rec; /* Record header */
|
||||||
Buffer buf; /* Packet data */
|
Buffer buf; /* Record data */
|
||||||
/* packet provider */
|
/* packet provider */
|
||||||
struct packet_provider_data provider;
|
struct packet_provider_data provider;
|
||||||
/* frames */
|
/* 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 nstime_t previous_time = {0, 0}; /* previous time */
|
||||||
|
|
||||||
static int find_dct2000_real_data(guint8 *buf);
|
static int find_dct2000_real_data(guint8 *buf);
|
||||||
static void handle_chopping(chop_t chop, struct wtap_pkthdr *out_phdr,
|
static void handle_chopping(chop_t chop, wtap_packet_header *out_phdr,
|
||||||
const struct wtap_pkthdr *in_phdr, guint8 **buf,
|
const wtap_packet_header *in_phdr, guint8 **buf,
|
||||||
gboolean adjlen);
|
gboolean adjlen);
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
|
@ -202,7 +202,7 @@ abs_time_to_str_with_sec_resolution(const nstime_t *abs_time)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
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 *fprefix, gchar *fsuffix)
|
||||||
{
|
{
|
||||||
gchar filenum[5+1];
|
gchar filenum[5+1];
|
||||||
|
@ -210,8 +210,8 @@ fileset_get_filename_by_pattern(guint idx, const struct wtap_pkthdr *phdr,
|
||||||
gchar *abs_str;
|
gchar *abs_str;
|
||||||
|
|
||||||
g_snprintf(filenum, sizeof(filenum), "%05u", idx % RINGBUFFER_MAX_NUM_FILES);
|
g_snprintf(filenum, sizeof(filenum), "%05u", idx % RINGBUFFER_MAX_NUM_FILES);
|
||||||
if (phdr->presence_flags & WTAP_HAS_TS) {
|
if (rec->presence_flags & WTAP_HAS_TS) {
|
||||||
timestr = abs_time_to_str_with_sec_resolution(&phdr->ts);
|
timestr = abs_time_to_str_with_sec_resolution(&rec->ts);
|
||||||
abs_str = g_strconcat(fprefix, "_", filenum, "_", timestr, fsuffix, NULL);
|
abs_str = g_strconcat(fprefix, "_", filenum, "_", timestr, fsuffix, NULL);
|
||||||
g_free(timestr);
|
g_free(timestr);
|
||||||
} else
|
} else
|
||||||
|
@ -562,7 +562,7 @@ sll_remove_vlan_info(guint8* fd, guint32* len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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) {
|
switch (phdr->pkt_encap) {
|
||||||
case WTAP_ENCAP_SLL:
|
case WTAP_ENCAP_SLL:
|
||||||
sll_remove_vlan_info(fd, len);
|
sll_remove_vlan_info(fd, len);
|
||||||
|
@ -979,12 +979,14 @@ main(int argc, char *argv[])
|
||||||
gchar *fsuffix = NULL;
|
gchar *fsuffix = NULL;
|
||||||
guint32 change_offset = 0;
|
guint32 change_offset = 0;
|
||||||
guint max_packet_number = 0;
|
guint max_packet_number = 0;
|
||||||
const struct wtap_pkthdr *phdr;
|
const wtap_rec *rec;
|
||||||
struct wtap_pkthdr temp_phdr;
|
wtap_rec temp_rec;
|
||||||
wtapng_iface_descriptions_t *idb_inf = NULL;
|
wtapng_iface_descriptions_t *idb_inf = NULL;
|
||||||
GArray *shb_hdrs = NULL;
|
GArray *shb_hdrs = NULL;
|
||||||
GArray *nrb_hdrs = NULL;
|
GArray *nrb_hdrs = NULL;
|
||||||
char *shb_user_appl;
|
char *shb_user_appl;
|
||||||
|
gboolean do_mutation;
|
||||||
|
guint32 caplen;
|
||||||
int ret = EXIT_SUCCESS;
|
int ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
cmdarg_err_init(failure_warning_message, failure_message_cont);
|
cmdarg_err_init(failure_warning_message, failure_message_cont);
|
||||||
|
@ -1374,7 +1376,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
read_count++;
|
read_count++;
|
||||||
|
|
||||||
phdr = wtap_phdr(wth);
|
rec = wtap_get_rec(wth);
|
||||||
|
|
||||||
/* Extra actions for the first packet */
|
/* Extra actions for the first packet */
|
||||||
if (read_count == 1) {
|
if (read_count == 1) {
|
||||||
|
@ -1384,7 +1386,7 @@ main(int argc, char *argv[])
|
||||||
goto clean_exit;
|
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 {
|
} else {
|
||||||
filename = g_strdup(argv[optind+1]);
|
filename = g_strdup(argv[optind+1]);
|
||||||
}
|
}
|
||||||
|
@ -1409,20 +1411,20 @@ main(int argc, char *argv[])
|
||||||
} /* first packet only handling */
|
} /* 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
|
* Not all packets have time stamps. Only process the time
|
||||||
* stamp if we have one.
|
* 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)) {
|
if (nstime_is_unset(&block_start)) {
|
||||||
block_start = phdr->ts;
|
block_start = rec->ts;
|
||||||
}
|
}
|
||||||
if (secs_per_block != 0) {
|
if (secs_per_block != 0) {
|
||||||
while (((guint32)(phdr->ts.secs - block_start.secs) > secs_per_block)
|
while (((guint32)(rec->ts.secs - block_start.secs) > secs_per_block)
|
||||||
|| ((guint32)(phdr->ts.secs - block_start.secs) == secs_per_block
|
|| ((guint32)(rec->ts.secs - block_start.secs) == secs_per_block
|
||||||
&& phdr->ts.nsecs >= block_start.nsecs )) { /* time for the next file */
|
&& rec->ts.nsecs >= block_start.nsecs )) { /* time for the next file */
|
||||||
|
|
||||||
if (!wtap_dump_close(pdh, &write_err)) {
|
if (!wtap_dump_close(pdh, &write_err)) {
|
||||||
cfile_close_failure_message(filename, 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 */
|
block_start.secs = block_start.secs + secs_per_block; /* reset for next interval */
|
||||||
g_free(filename);
|
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);
|
g_assert(filename);
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
|
@ -1462,7 +1464,7 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(filename);
|
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);
|
g_assert(filename);
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
|
@ -1486,8 +1488,8 @@ main(int argc, char *argv[])
|
||||||
* Is the packet in the selected timeframe?
|
* Is the packet in the selected timeframe?
|
||||||
* If the packet has no time stamp, the answer is "no".
|
* If the packet has no time stamp, the answer is "no".
|
||||||
*/
|
*/
|
||||||
if (phdr->presence_flags & WTAP_HAS_TS)
|
if (rec->presence_flags & WTAP_HAS_TS)
|
||||||
ts_okay = (phdr->ts.secs >= starttime) && (phdr->ts.secs < stoptime);
|
ts_okay = (rec->ts.secs >= starttime) && (rec->ts.secs < stoptime);
|
||||||
else
|
else
|
||||||
ts_okay = FALSE;
|
ts_okay = FALSE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1507,34 +1509,9 @@ main(int argc, char *argv[])
|
||||||
/* We simply write it, perhaps after truncating it; we could
|
/* We simply write it, perhaps after truncating it; we could
|
||||||
* do other things, like modify it. */
|
* do other things, like modify it. */
|
||||||
|
|
||||||
phdr = wtap_phdr(wth);
|
rec = wtap_get_rec(wth);
|
||||||
|
|
||||||
if (snaplen != 0) {
|
if (rec->presence_flags & WTAP_HAS_TS) {
|
||||||
/* 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) {
|
|
||||||
/* Do we adjust timestamps to ensure strict chronological
|
/* Do we adjust timestamps to ensure strict chronological
|
||||||
* order? */
|
* order? */
|
||||||
if (do_strict_time_adjustment) {
|
if (do_strict_time_adjustment) {
|
||||||
|
@ -1543,7 +1520,7 @@ main(int argc, char *argv[])
|
||||||
nstime_t current;
|
nstime_t current;
|
||||||
nstime_t delta;
|
nstime_t delta;
|
||||||
|
|
||||||
current = phdr->ts;
|
current = rec->ts;
|
||||||
|
|
||||||
nstime_delta(&delta, ¤t, &previous_time);
|
nstime_delta(&delta, ¤t, &previous_time);
|
||||||
|
|
||||||
|
@ -1555,20 +1532,20 @@ main(int argc, char *argv[])
|
||||||
* situation since trace files usually have packets in
|
* situation since trace files usually have packets in
|
||||||
* chronological order (oldest to newest).
|
* chronological order (oldest to newest).
|
||||||
* Copy and change rather than modify
|
* Copy and change rather than modify
|
||||||
* returned phdr.
|
* returned rec.
|
||||||
*/
|
*/
|
||||||
/* fprintf(stderr, "++out of order, need to adjust this packet!\n"); */
|
/* fprintf(stderr, "++out of order, need to adjust this packet!\n"); */
|
||||||
temp_phdr = *phdr;
|
temp_rec = *rec;
|
||||||
temp_phdr.ts.secs = previous_time.secs + strict_time_adj.tv.secs;
|
temp_rec.ts.secs = previous_time.secs + strict_time_adj.tv.secs;
|
||||||
temp_phdr.ts.nsecs = previous_time.nsecs;
|
temp_rec.ts.nsecs = previous_time.nsecs;
|
||||||
if (temp_phdr.ts.nsecs + strict_time_adj.tv.nsecs > ONE_BILLION) {
|
if (temp_rec.ts.nsecs + strict_time_adj.tv.nsecs > ONE_BILLION) {
|
||||||
/* carry */
|
/* carry */
|
||||||
temp_phdr.ts.secs++;
|
temp_rec.ts.secs++;
|
||||||
temp_phdr.ts.nsecs += strict_time_adj.tv.nsecs - ONE_BILLION;
|
temp_rec.ts.nsecs += strict_time_adj.tv.nsecs - ONE_BILLION;
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
/*
|
/*
|
||||||
|
@ -1576,102 +1553,100 @@ main(int argc, char *argv[])
|
||||||
* Unconditionally set each timestamp to previous
|
* Unconditionally set each timestamp to previous
|
||||||
* packet's timestamp plus delta.
|
* packet's timestamp plus delta.
|
||||||
* Copy and change rather than modify returned
|
* Copy and change rather than modify returned
|
||||||
* phdr.
|
* rec.
|
||||||
*/
|
*/
|
||||||
temp_phdr = *phdr;
|
temp_rec = *rec;
|
||||||
temp_phdr.ts.secs = previous_time.secs + strict_time_adj.tv.secs;
|
temp_rec.ts.secs = previous_time.secs + strict_time_adj.tv.secs;
|
||||||
temp_phdr.ts.nsecs = previous_time.nsecs;
|
temp_rec.ts.nsecs = previous_time.nsecs;
|
||||||
if (temp_phdr.ts.nsecs + strict_time_adj.tv.nsecs > ONE_BILLION) {
|
if (temp_rec.ts.nsecs + strict_time_adj.tv.nsecs > ONE_BILLION) {
|
||||||
/* carry */
|
/* carry */
|
||||||
temp_phdr.ts.secs++;
|
temp_rec.ts.secs++;
|
||||||
temp_phdr.ts.nsecs += strict_time_adj.tv.nsecs - ONE_BILLION;
|
temp_rec.ts.nsecs += strict_time_adj.tv.nsecs - ONE_BILLION;
|
||||||
} else {
|
} 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) {
|
if (time_adj.tv.secs != 0) {
|
||||||
/* Copy and change rather than modify returned phdr */
|
/* Copy and change rather than modify returned rec */
|
||||||
temp_phdr = *phdr;
|
temp_rec = *rec;
|
||||||
if (time_adj.is_negative)
|
if (time_adj.is_negative)
|
||||||
temp_phdr.ts.secs -= time_adj.tv.secs;
|
temp_rec.ts.secs -= time_adj.tv.secs;
|
||||||
else
|
else
|
||||||
temp_phdr.ts.secs += time_adj.tv.secs;
|
temp_rec.ts.secs += time_adj.tv.secs;
|
||||||
phdr = &temp_phdr;
|
rec = &temp_rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time_adj.tv.nsecs != 0) {
|
if (time_adj.tv.nsecs != 0) {
|
||||||
/* Copy and change rather than modify returned phdr */
|
/* Copy and change rather than modify returned rec */
|
||||||
temp_phdr = *phdr;
|
temp_rec = *rec;
|
||||||
if (time_adj.is_negative) { /* subtract */
|
if (time_adj.is_negative) { /* subtract */
|
||||||
if (temp_phdr.ts.nsecs < time_adj.tv.nsecs) { /* borrow */
|
if (temp_rec.ts.nsecs < time_adj.tv.nsecs) { /* borrow */
|
||||||
temp_phdr.ts.secs--;
|
temp_rec.ts.secs--;
|
||||||
temp_phdr.ts.nsecs += ONE_BILLION;
|
temp_rec.ts.nsecs += ONE_BILLION;
|
||||||
}
|
}
|
||||||
temp_phdr.ts.nsecs -= time_adj.tv.nsecs;
|
temp_rec.ts.nsecs -= time_adj.tv.nsecs;
|
||||||
} else { /* add */
|
} 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 */
|
/* carry */
|
||||||
temp_phdr.ts.secs++;
|
temp_rec.ts.secs++;
|
||||||
temp_phdr.ts.nsecs += time_adj.tv.nsecs - ONE_BILLION;
|
temp_rec.ts.nsecs += time_adj.tv.nsecs - ONE_BILLION;
|
||||||
} else {
|
} 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 */
|
} /* time stamp adjustment */
|
||||||
|
|
||||||
/* remove vlan info */
|
if (rec->rec_type == REC_TYPE_PACKET) {
|
||||||
if (rem_vlan) {
|
if (snaplen != 0) {
|
||||||
/* Copy and change rather than modify returned phdr */
|
/* Limit capture length to snaplen */
|
||||||
temp_phdr = *phdr;
|
if (rec->rec_header.packet_header.caplen > snaplen) {
|
||||||
remove_vlan_info(phdr, buf, &temp_phdr.caplen);
|
/* Copy and change rather than modify returned wtap_rec */
|
||||||
phdr = &temp_phdr;
|
temp_rec = *rec;
|
||||||
}
|
temp_rec.rec_header.packet_header.caplen = snaplen;
|
||||||
|
rec = &temp_rec;
|
||||||
/* 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");
|
|
||||||
}
|
}
|
||||||
duplicate_count++;
|
/* If -L, also set reported length to snaplen */
|
||||||
count++;
|
if (adjlen && rec->rec_header.packet_header.len > snaplen) {
|
||||||
continue;
|
/* Copy and change rather than modify returned phdr */
|
||||||
} else {
|
temp_rec = *rec;
|
||||||
if (verbose) {
|
temp_rec.rec_header.packet_header.len = snaplen;
|
||||||
fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
|
rec = &temp_rec;
|
||||||
count, phdr->caplen);
|
|
||||||
for (i = 0; i < 16; i++)
|
|
||||||
fprintf(stderr, "%02x",
|
|
||||||
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* suppression of duplicates */
|
|
||||||
|
|
||||||
if (phdr->presence_flags & WTAP_HAS_TS) {
|
/*
|
||||||
/* suppress duplicates by time window */
|
* CHOP
|
||||||
if (dup_detect_by_time) {
|
* Copy and change rather than modify returned phdr.
|
||||||
nstime_t current;
|
*/
|
||||||
|
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;
|
/* remove vlan info */
|
||||||
current.nsecs = phdr->ts.nsecs;
|
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) {
|
if (verbose) {
|
||||||
fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
|
fprintf(stderr, "Skipped: %u, Len: %u, MD5 Hash: ",
|
||||||
count, phdr->caplen);
|
count,
|
||||||
|
rec->rec_header.packet_header.caplen);
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
fprintf(stderr, "%02x",
|
fprintf(stderr, "%02x",
|
||||||
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
|
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
|
||||||
|
@ -1683,32 +1658,93 @@ main(int argc, char *argv[])
|
||||||
} else {
|
} else {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
|
fprintf(stderr, "Packet: %u, Len: %u, MD5 Hash: ",
|
||||||
count, phdr->caplen);
|
count,
|
||||||
|
rec->rec_header.packet_header.caplen);
|
||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
fprintf(stderr, "%02x",
|
fprintf(stderr, "%02x",
|
||||||
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
|
(unsigned char)fd_hash[cur_dup_entry].digest[i]);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} /* suppression of duplicates */
|
||||||
} /* suppress duplicates by time window */
|
|
||||||
|
|
||||||
if (change_offset > phdr->caplen) {
|
if (rec->presence_flags & WTAP_HAS_TS) {
|
||||||
fprintf(stderr, "change offset %u is longer than caplen %u in packet %u\n",
|
/* suppress duplicates by time window */
|
||||||
change_offset, phdr->caplen, count);
|
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 */
|
/* 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;
|
int real_data_start = 0;
|
||||||
|
|
||||||
/* Protect non-protocol data */
|
/* Protect non-protocol data */
|
||||||
if (wtap_file_type_subtype(wth) == WTAP_FILE_TYPE_SUBTYPE_CATAPULT_DCT2000)
|
switch (rec->rec_type) {
|
||||||
real_data_start = find_dct2000_real_data(buf);
|
|
||||||
|
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;
|
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) {
|
if (rand() <= err_prob * RAND_MAX) {
|
||||||
err_type = rand() / (RAND_MAX / ERR_WT_TOTAL + 1);
|
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 (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);
|
g_strlcpy((char*) &buf[i], "%s", 2);
|
||||||
err_type = ERR_WT_TOTAL;
|
err_type = ERR_WT_TOTAL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1742,9 +1778,9 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err_type < ERR_WT_AA) {
|
if (err_type < ERR_WT_AA) {
|
||||||
for (j = i; j < (int) phdr->caplen; j++)
|
for (j = i; j < (int) caplen; j++)
|
||||||
buf[j] = 0xAA;
|
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));
|
(const char*)g_tree_lookup(frames_user_comments, GUINT_TO_POINTER(read_count));
|
||||||
/* XXX: What about comment changed to no comment? */
|
/* XXX: What about comment changed to no comment? */
|
||||||
if (comment != NULL) {
|
if (comment != NULL) {
|
||||||
/* Copy and change rather than modify returned phdr */
|
/* Copy and change rather than modify returned rec */
|
||||||
temp_phdr = *phdr;
|
temp_rec = *rec;
|
||||||
temp_phdr.opt_comment = g_strdup(comment);
|
temp_rec.opt_comment = g_strdup(comment);
|
||||||
temp_phdr.has_comment_changed = TRUE;
|
temp_rec.has_comment_changed = TRUE;
|
||||||
phdr = &temp_phdr;
|
rec = &temp_rec;
|
||||||
} else {
|
} else {
|
||||||
/* Copy and change rather than modify returned phdr */
|
/* Copy and change rather than modify returned rec */
|
||||||
temp_phdr = *phdr;
|
temp_rec = *rec;
|
||||||
temp_phdr.has_comment_changed = FALSE;
|
temp_rec.has_comment_changed = FALSE;
|
||||||
phdr = &temp_phdr;
|
rec = &temp_rec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Attempt to dump out current frame to the output file */
|
/* 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],
|
cfile_write_failure_message("editcap", argv[optind],
|
||||||
filename,
|
filename,
|
||||||
write_err, write_err_info,
|
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.
|
* positive chop length, and one by the negative chop length.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
handle_chopping(chop_t chop, struct wtap_pkthdr *out_phdr,
|
handle_chopping(chop_t chop, wtap_packet_header *out_phdr,
|
||||||
const struct wtap_pkthdr *in_phdr, guint8 **buf,
|
const wtap_packet_header *in_phdr, guint8 **buf,
|
||||||
gboolean adjlen)
|
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
|
/* If we're not chopping anything from one side, then the offset for that
|
||||||
* side is meaningless. */
|
* side is meaningless. */
|
||||||
if (chop.len_begin == 0)
|
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);
|
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);
|
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 {
|
__try {
|
||||||
#endif
|
#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)) {
|
tvb, pinfo, parent_tree)) {
|
||||||
|
|
||||||
col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNKNOWN");
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNKNOWN");
|
||||||
col_add_fstr(pinfo->cinfo, COL_INFO, "FTAP_ENCAP = %d",
|
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);
|
call_data_dissector(tvb, pinfo, parent_tree);
|
||||||
}
|
}
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
|
@ -167,8 +167,8 @@ save_command(guint32 cmd, guint32 arg0, guint32 arg1, guint32 data_length,
|
||||||
|
|
||||||
frame_number = pinfo->num;
|
frame_number = pinfo->num;
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
interface_id = pinfo->phdr->interface_id;
|
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
else
|
else
|
||||||
interface_id = 0;
|
interface_id = 0;
|
||||||
|
|
||||||
|
@ -391,8 +391,8 @@ dissect_adb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
interface_id = pinfo->phdr->interface_id;
|
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
else
|
else
|
||||||
interface_id = 0;
|
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_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);
|
main_tree = proto_item_add_subtree(main_item, ett_adb_cs);
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
wireshark_interface_id = pinfo->phdr->interface_id;
|
wireshark_interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
|
|
||||||
if (pinfo->destport == server_port) { /* Client sent to Server */
|
if (pinfo->destport == server_port) { /* Client sent to Server */
|
||||||
client_request_t *client_request;
|
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");
|
col_add_fstr(pinfo->cinfo, COL_INFO, "Client");
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
wireshark_interface_id = pinfo->phdr->interface_id;
|
wireshark_interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
|
|
||||||
key[0].length = 1;
|
key[0].length = 1;
|
||||||
key[0].key = &wireshark_interface_id;
|
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->fd->flags.visited && length > 0) { /* save Length to client_requests */
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
wireshark_interface_id = pinfo->phdr->interface_id;
|
wireshark_interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
|
|
||||||
key[0].length = 1;
|
key[0].length = 1;
|
||||||
key[0].key = &wireshark_interface_id;
|
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 (!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 (!client_request) {
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
wireshark_interface_id = pinfo->phdr->interface_id;
|
wireshark_interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
|
|
||||||
key[0].length = 1;
|
key[0].length = 1;
|
||||||
key[0].key = &wireshark_interface_id;
|
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);
|
main_tree = proto_item_add_subtree(main_item, ett_bluetooth);
|
||||||
|
|
||||||
bluetooth_data = (bluetooth_data_t *) wmem_new(wmem_packet_scope(), bluetooth_data_t);
|
bluetooth_data = (bluetooth_data_t *) wmem_new(wmem_packet_scope(), bluetooth_data_t);
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
bluetooth_data->interface_id = pinfo->phdr->interface_id;
|
bluetooth_data->interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
else
|
else
|
||||||
bluetooth_data->interface_id = HCI_INTERFACE_DEFAULT;
|
bluetooth_data->interface_id = HCI_INTERFACE_DEFAULT;
|
||||||
bluetooth_data->adapter_id = HCI_ADAPTER_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_type = BT_PD_NONE;
|
||||||
bluetooth_data->previous_protocol_data.none = NULL;
|
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);
|
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_type = BT_PD_BTHCI;
|
||||||
bluetooth_data->previous_protocol_data.bthci = (struct bthci_phdr *)data;
|
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);
|
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_type = BT_PD_BTMON;
|
||||||
bluetooth_data->previous_protocol_data.btmon = (struct btmon_phdr *)data;
|
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);
|
call_data_dissector(tvb, pinfo, tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -705,8 +705,8 @@ dissect_connrequest(tvbuff_t *tvb, int offset, packet_info *pinfo,
|
||||||
guint32 chandle;
|
guint32 chandle;
|
||||||
psm_data_t *psm_data;
|
psm_data_t *psm_data;
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
interface_id = pinfo->phdr->interface_id;
|
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
else
|
else
|
||||||
interface_id = HCI_INTERFACE_DEFAULT;
|
interface_id = HCI_INTERFACE_DEFAULT;
|
||||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_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 adapter_id;
|
||||||
guint32 chandle;
|
guint32 chandle;
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
interface_id = pinfo->phdr->interface_id;
|
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
else
|
else
|
||||||
interface_id = HCI_INTERFACE_DEFAULT;
|
interface_id = HCI_INTERFACE_DEFAULT;
|
||||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_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;
|
guint32 chandle;
|
||||||
psm_data_t *psm_data;
|
psm_data_t *psm_data;
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
interface_id = pinfo->phdr->interface_id;
|
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
else
|
else
|
||||||
interface_id = HCI_INTERFACE_DEFAULT;
|
interface_id = HCI_INTERFACE_DEFAULT;
|
||||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_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 adapter_id;
|
||||||
guint32 chandle;
|
guint32 chandle;
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
interface_id = pinfo->phdr->interface_id;
|
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
else
|
else
|
||||||
interface_id = HCI_INTERFACE_DEFAULT;
|
interface_id = HCI_INTERFACE_DEFAULT;
|
||||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_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 chandle;
|
||||||
guint32 cid;
|
guint32 cid;
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
interface_id = pinfo->phdr->interface_id;
|
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
else
|
else
|
||||||
interface_id = HCI_INTERFACE_DEFAULT;
|
interface_id = HCI_INTERFACE_DEFAULT;
|
||||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_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 chandle;
|
||||||
guint32 cid;
|
guint32 cid;
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
interface_id = pinfo->phdr->interface_id;
|
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
else
|
else
|
||||||
interface_id = HCI_INTERFACE_DEFAULT;
|
interface_id = HCI_INTERFACE_DEFAULT;
|
||||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_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 chandle;
|
||||||
guint32 cid;
|
guint32 cid;
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
interface_id = pinfo->phdr->interface_id;
|
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
else
|
else
|
||||||
interface_id = HCI_INTERFACE_DEFAULT;
|
interface_id = HCI_INTERFACE_DEFAULT;
|
||||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_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 chandle;
|
||||||
guint32 cid;
|
guint32 cid;
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
interface_id = pinfo->phdr->interface_id;
|
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
else
|
else
|
||||||
interface_id = HCI_INTERFACE_DEFAULT;
|
interface_id = HCI_INTERFACE_DEFAULT;
|
||||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_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_scid;
|
||||||
guint32 key_dcid;
|
guint32 key_dcid;
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
interface_id = pinfo->phdr->interface_id;
|
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
else
|
else
|
||||||
interface_id = HCI_INTERFACE_DEFAULT;
|
interface_id = HCI_INTERFACE_DEFAULT;
|
||||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_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 chandle;
|
||||||
guint32 key_dcid;
|
guint32 key_dcid;
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
interface_id = pinfo->phdr->interface_id;
|
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
else
|
else
|
||||||
interface_id = HCI_INTERFACE_DEFAULT;
|
interface_id = HCI_INTERFACE_DEFAULT;
|
||||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_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);
|
l2cap_data = wmem_new(wmem_packet_scope(), btl2cap_data_t);
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
l2cap_data->interface_id = pinfo->phdr->interface_id;
|
l2cap_data->interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
else
|
else
|
||||||
l2cap_data->interface_id = HCI_INTERFACE_DEFAULT;
|
l2cap_data->interface_id = HCI_INTERFACE_DEFAULT;
|
||||||
if (acl_data) {
|
if (acl_data) {
|
||||||
|
@ -2712,8 +2712,8 @@ dissect_btl2cap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
||||||
guint32 chandle;
|
guint32 chandle;
|
||||||
guint32 key_cid;
|
guint32 key_cid;
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
interface_id = pinfo->phdr->interface_id;
|
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
else
|
else
|
||||||
interface_id = HCI_INTERFACE_DEFAULT;
|
interface_id = HCI_INTERFACE_DEFAULT;
|
||||||
adapter_id = (acl_data) ? acl_data->adapter_id : HCI_ADAPTER_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)
|
if (bluetooth_data)
|
||||||
interface_id = bluetooth_data->interface_id;
|
interface_id = bluetooth_data->interface_id;
|
||||||
else if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
else if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID)
|
||||||
interface_id = pinfo->phdr->interface_id;
|
interface_id = pinfo->rec->rec_header.packet_header.interface_id;
|
||||||
else
|
else
|
||||||
interface_id = HCI_INTERFACE_DEFAULT;
|
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);
|
DISSECTOR_ASSERT(fr_data);
|
||||||
|
|
||||||
switch (pinfo->phdr->rec_type) {
|
switch (pinfo->rec->rec_type) {
|
||||||
|
|
||||||
case REC_TYPE_PACKET:
|
case REC_TYPE_PACKET:
|
||||||
pinfo->current_proto = "Frame";
|
pinfo->current_proto = "Frame";
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_PACK_FLAGS) {
|
if (pinfo->rec->presence_flags & WTAP_HAS_PACK_FLAGS) {
|
||||||
if (pinfo->phdr->pack_flags & 0x00000001)
|
if (pinfo->rec->rec_header.packet_header.pack_flags & 0x00000001)
|
||||||
pinfo->p2p_dir = P2P_DIR_RECV;
|
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;
|
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.
|
* overrides the packet record.
|
||||||
*/
|
*/
|
||||||
if (pinfo->pseudo_header != NULL) {
|
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_WFLEET_HDLC:
|
||||||
case WTAP_ENCAP_CHDLC_WITH_PHDR:
|
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");
|
cap_plurality = plurality(cap_len, "", "s");
|
||||||
frame_plurality = plurality(frame_len, "", "s");
|
frame_plurality = plurality(frame_len, "", "s");
|
||||||
|
|
||||||
switch (pinfo->phdr->rec_type) {
|
switch (pinfo->rec->rec_type) {
|
||||||
case REC_TYPE_PACKET:
|
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:
|
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:
|
case REC_TYPE_FT_SPECIFIC_REPORT:
|
||||||
ti = proto_tree_add_protocol_format(tree, proto_frame, tvb, 0, tvb_captured_length(tvb),
|
ti = proto_tree_add_protocol_format(tree, proto_frame, tvb, 0, tvb_captured_length(tvb),
|
||||||
"Frame %u: %u byte%s on wire",
|
"Report %u: %u byte%s on wire",
|
||||||
pinfo->num, frame_len, frame_plurality);
|
pinfo->num, frame_len, frame_plurality);
|
||||||
if (generate_bits_field)
|
if (generate_bits_field)
|
||||||
proto_item_append_text(ti, " (%u bits)", frame_len * 8);
|
proto_item_append_text(ti, " (%u bits)", frame_len * 8);
|
||||||
proto_item_append_text(ti, ", %u byte%s captured",
|
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?
|
* be preferred?
|
||||||
*/
|
*/
|
||||||
ti = proto_tree_add_protocol_format(tree, proto_syscall, tvb, 0, tvb_captured_length(tvb),
|
ti = proto_tree_add_protocol_format(tree, proto_syscall, tvb, 0, tvb_captured_length(tvb),
|
||||||
"System Call %u: %u byte%s",
|
"System Call %u: %u byte%s",
|
||||||
pinfo->num, frame_len, frame_plurality);
|
pinfo->num, frame_len, frame_plurality);
|
||||||
break;
|
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);
|
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))) {
|
(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_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->phdr->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_tree *if_tree;
|
||||||
proto_item *if_item;
|
proto_item *if_item;
|
||||||
|
|
||||||
if (interface_name) {
|
if (interface_name) {
|
||||||
if_item = proto_tree_add_uint_format_value(fh_tree, hf_frame_interface_id, tvb, 0, 0,
|
if_item = proto_tree_add_uint_format_value(fh_tree, hf_frame_interface_id, tvb, 0, 0,
|
||||||
pinfo->phdr->interface_id, "%u (%s)",
|
pinfo->rec->rec_header.packet_header.interface_id, "%u (%s)",
|
||||||
pinfo->phdr->interface_id, interface_name);
|
pinfo->rec->rec_header.packet_header.interface_id, interface_name);
|
||||||
if_tree = proto_item_add_subtree(if_item, ett_ifname);
|
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);
|
proto_tree_add_string(if_tree, hf_frame_interface_name, tvb, 0, 0, interface_name);
|
||||||
} else {
|
} 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) {
|
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_tree *flags_tree;
|
||||||
proto_item *flags_item;
|
proto_item *flags_item;
|
||||||
static const int * flags[] = {
|
static const int * flags[] = {
|
||||||
|
@ -426,13 +451,13 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
|
||||||
NULL
|
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);
|
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)
|
if (pinfo->rec->rec_type == REC_TYPE_PACKET)
|
||||||
proto_tree_add_int(fh_tree, hf_frame_wtap_encap, tvb, 0, 0, pinfo->phdr->pkt_encap);
|
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) {
|
if (pinfo->presence_flags & PINFO_HAS_TS) {
|
||||||
proto_tree_add_time(fh_tree, hf_frame_arrival_time, tvb,
|
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);
|
ti = proto_tree_add_boolean(fh_tree, hf_frame_ignored, tvb, 0, 0,pinfo->fd->flags.ignored);
|
||||||
PROTO_ITEM_SET_GENERATED(ti);
|
PROTO_ITEM_SET_GENERATED(ti);
|
||||||
|
|
||||||
/* Check for existences of P2P pseudo header */
|
if (pinfo->rec->rec_type == REC_TYPE_PACKET) {
|
||||||
if (pinfo->p2p_dir != P2P_DIR_UNKNOWN) {
|
/* Check for existences of P2P pseudo header */
|
||||||
proto_tree_add_int(fh_tree, hf_frame_p2p_dir, tvb,
|
if (pinfo->p2p_dir != P2P_DIR_UNKNOWN) {
|
||||||
0, 0, pinfo->p2p_dir);
|
proto_tree_add_int(fh_tree, hf_frame_p2p_dir, tvb,
|
||||||
}
|
0, 0, pinfo->p2p_dir);
|
||||||
|
}
|
||||||
|
|
||||||
/* Check for existences of MTP2 link number */
|
/* Check for existences of MTP2 link number */
|
||||||
if ((pinfo->pseudo_header != NULL ) && (pinfo->phdr->pkt_encap == WTAP_ENCAP_MTP2_WITH_PHDR)) {
|
if ((pinfo->pseudo_header != NULL) &&
|
||||||
proto_tree_add_uint(fh_tree, hf_link_number, tvb,
|
(pinfo->rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_MTP2_WITH_PHDR)) {
|
||||||
0, 0, pinfo->link_number);
|
proto_tree_add_uint(fh_tree, hf_link_number, tvb,
|
||||||
|
0, 0, pinfo->link_number);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_file_off) {
|
if (show_file_off) {
|
||||||
|
@ -552,7 +580,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
|
||||||
*/
|
*/
|
||||||
__try {
|
__try {
|
||||||
#endif
|
#endif
|
||||||
switch (pinfo->phdr->rec_type) {
|
switch (pinfo->rec->rec_type) {
|
||||||
|
|
||||||
case REC_TYPE_PACKET:
|
case REC_TYPE_PACKET:
|
||||||
if ((force_docsis_encap) && (docsis_handle)) {
|
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);
|
(void *)pinfo->pseudo_header);
|
||||||
} else {
|
} else {
|
||||||
if (!dissector_try_uint_new(wtap_encap_dissector_table,
|
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,
|
parent_tree, TRUE,
|
||||||
(void *)pinfo->pseudo_header)) {
|
(void *)pinfo->pseudo_header)) {
|
||||||
col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNKNOWN");
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNKNOWN");
|
||||||
col_add_fstr(pinfo->cinfo, COL_INFO, "WTAP_ENCAP = %d",
|
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);
|
call_data_dissector(tvb, pinfo, parent_tree);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ dissect_ipoib(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
|
||||||
guint16 type;
|
guint16 type;
|
||||||
int grh_size = 0;
|
int grh_size = 0;
|
||||||
|
|
||||||
if (pinfo->phdr->pkt_encap == WTAP_ENCAP_IP_OVER_IB_PCAP)
|
if (pinfo->rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_IP_OVER_IB_PCAP)
|
||||||
grh_size = 40;
|
grh_size = 40;
|
||||||
|
|
||||||
/* load the top pane info. This should be overwritten by
|
/* load the top pane info. This should be overwritten by
|
||||||
|
@ -74,7 +74,7 @@ dissect_ipoib(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
|
||||||
fh_tree = proto_item_add_subtree(ti, ett_raw);
|
fh_tree = proto_item_add_subtree(ti, ett_raw);
|
||||||
|
|
||||||
/* for PCAP data populate subtree with GRH pseudo header data */
|
/* for PCAP data populate subtree with GRH pseudo header data */
|
||||||
if (pinfo->phdr->pkt_encap == WTAP_ENCAP_IP_OVER_IB_PCAP) {
|
if (pinfo->rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_IP_OVER_IB_PCAP) {
|
||||||
|
|
||||||
/* Zero means GRH is not valid (unicast). Only destination
|
/* Zero means GRH is not valid (unicast). Only destination
|
||||||
address is set. */
|
address is set. */
|
||||||
|
|
|
@ -227,7 +227,7 @@ dissect_nettl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
|
||||||
0, 0, pinfo->pseudo_header->nettl.uid);
|
0, 0, pinfo->pseudo_header->nettl.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (pinfo->phdr->pkt_encap) {
|
switch (pinfo->rec->rec_header.packet_header.pkt_encap) {
|
||||||
case WTAP_ENCAP_NETTL_ETHERNET:
|
case WTAP_ENCAP_NETTL_ETHERNET:
|
||||||
call_dissector(eth_withoutfcs_handle, tvb, pinfo, tree);
|
call_dissector(eth_withoutfcs_handle, tvb, pinfo, tree);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -268,12 +268,12 @@ dissect_pcap_pktdata(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
|
||||||
* We're passed a pointer to a LINKTYPE_ value.
|
* We're passed a pointer to a LINKTYPE_ value.
|
||||||
* Find the Wiretap encapsulation for that value.
|
* Find the Wiretap encapsulation for that value.
|
||||||
*/
|
*/
|
||||||
pinfo->phdr->pkt_encap = wtap_pcap_encap_to_wtap_encap(*link_type);
|
pinfo->rec->rec_header.packet_header.pkt_encap = wtap_pcap_encap_to_wtap_encap(*link_type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do we know that type?
|
* Do we know that type?
|
||||||
*/
|
*/
|
||||||
if (pinfo->phdr->pkt_encap == WTAP_ENCAP_UNKNOWN) {
|
if (pinfo->rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_UNKNOWN) {
|
||||||
/*
|
/*
|
||||||
* Nothing we know.
|
* Nothing we know.
|
||||||
* Just report that and give up.
|
* Just report that and give up.
|
||||||
|
@ -297,11 +297,11 @@ dissect_pcap_pktdata(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
|
||||||
* pseudo-header from the bytes at the beginning of the
|
* pseudo-header from the bytes at the beginning of the
|
||||||
* packet data.
|
* packet data.
|
||||||
*/
|
*/
|
||||||
if (wtap_encap_requires_phdr(pinfo->phdr->pkt_encap)) {
|
if (wtap_encap_requires_phdr(pinfo->rec->rec_header.packet_header.pkt_encap)) {
|
||||||
/*
|
/*
|
||||||
* It does. Do we have code to do that?
|
* It does. Do we have code to do that?
|
||||||
*/
|
*/
|
||||||
switch (pinfo->phdr->pkt_encap) {
|
switch (pinfo->rec->rec_header.packet_header.pkt_encap) {
|
||||||
|
|
||||||
case WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR:
|
case WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR:
|
||||||
pseudoheader_item = proto_tree_add_item(tree, hf_pcap_pktdata_pseudoheader, tvb, offset, 4, ENC_NA);
|
pseudoheader_item = proto_tree_add_item(tree, hf_pcap_pktdata_pseudoheader, tvb, offset, 4, ENC_NA);
|
||||||
|
@ -353,7 +353,7 @@ dissect_pcap_pktdata(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
|
||||||
* These also require a pseudo-header, but it's not constructed
|
* These also require a pseudo-header, but it's not constructed
|
||||||
* from packet data.
|
* from packet data.
|
||||||
*/
|
*/
|
||||||
switch (pinfo->phdr->pkt_encap) {
|
switch (pinfo->rec->rec_header.packet_header.pkt_encap) {
|
||||||
|
|
||||||
case WTAP_ENCAP_ETHERNET:
|
case WTAP_ENCAP_ETHERNET:
|
||||||
eth.fcs_len = -1; /* Unknown whether we have an FCS */
|
eth.fcs_len = -1; /* Unknown whether we have an FCS */
|
||||||
|
@ -368,7 +368,7 @@ dissect_pcap_pktdata(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
|
||||||
|
|
||||||
next_tvb = tvb_new_subset_remaining(tvb, offset);
|
next_tvb = tvb_new_subset_remaining(tvb, offset);
|
||||||
|
|
||||||
offset = dissector_try_uint_new(wtap_encap_table, pinfo->phdr->pkt_encap, next_tvb, pinfo, tree, TRUE, phdr);
|
offset = dissector_try_uint_new(wtap_encap_table, pinfo->rec->rec_header.packet_header.pkt_encap, next_tvb, pinfo, tree, TRUE, phdr);
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,13 +41,13 @@ dissect_pcapng_block(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
|
||||||
* is one.
|
* is one.
|
||||||
*/
|
*/
|
||||||
if (!dissector_try_uint(pcapng_block_type_dissector_table,
|
if (!dissector_try_uint(pcapng_block_type_dissector_table,
|
||||||
pinfo->pseudo_header->ftsrec.record_type, tvb, pinfo, tree)) {
|
pinfo->rec->rec_header.ft_specific_header.record_type, tvb, pinfo, tree)) {
|
||||||
/*
|
/*
|
||||||
* There isn't one; just do a minimal display.
|
* There isn't one; just do a minimal display.
|
||||||
*/
|
*/
|
||||||
col_set_str(pinfo->cinfo, COL_PROTOCOL, "PCAPNG");
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "PCAPNG");
|
||||||
col_add_fstr(pinfo->cinfo, COL_INFO, "Pcapng block, type %u",
|
col_add_fstr(pinfo->cinfo, COL_INFO, "Pcapng block, type %u",
|
||||||
pinfo->pseudo_header->ftsrec.record_type);
|
pinfo->rec->rec_header.ft_specific_header.record_type);
|
||||||
|
|
||||||
proto_tree_add_item(tree, proto_pcapng_block, tvb, 0, -1, ENC_NA);
|
proto_tree_add_item(tree, proto_pcapng_block, tvb, 0, -1, ENC_NA);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1158,7 +1158,7 @@ snort_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
|
||||||
if (!pinfo->fd->flags.visited && current_session.working) {
|
if (!pinfo->fd->flags.visited && current_session.working) {
|
||||||
int write_err = 0;
|
int write_err = 0;
|
||||||
gchar *err_info;
|
gchar *err_info;
|
||||||
struct wtap_pkthdr wtp;
|
wtap_rec rec;
|
||||||
|
|
||||||
/* First time, open current_session.in to write to for dumping into snort with */
|
/* First time, open current_session.in to write to for dumping into snort with */
|
||||||
if (!current_session.pdh) {
|
if (!current_session.pdh) {
|
||||||
|
@ -1177,7 +1177,7 @@ snort_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
|
||||||
*/
|
*/
|
||||||
current_session.pdh = wtap_dump_fdopen(current_session.in,
|
current_session.pdh = wtap_dump_fdopen(current_session.in,
|
||||||
WTAP_FILE_TYPE_SUBTYPE_PCAP,
|
WTAP_FILE_TYPE_SUBTYPE_PCAP,
|
||||||
pinfo->phdr->pkt_encap,
|
pinfo->rec->rec_header.packet_header.pkt_encap,
|
||||||
WTAP_MAX_PACKET_SIZE_STANDARD,
|
WTAP_MAX_PACKET_SIZE_STANDARD,
|
||||||
FALSE, /* compressed */
|
FALSE, /* compressed */
|
||||||
&open_err);
|
&open_err);
|
||||||
|
@ -1188,24 +1188,24 @@ snort_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start with all same values... */
|
/* Start with all same values... */
|
||||||
memcpy(&wtp, pinfo->phdr, sizeof(wtp));
|
rec = *pinfo->rec;
|
||||||
|
|
||||||
/* Copying packet details into wtp for writing */
|
/* Copying packet details into wtp for writing */
|
||||||
wtp.ts = pinfo->fd->abs_ts;
|
rec.ts = pinfo->fd->abs_ts;
|
||||||
|
|
||||||
/* NB: overwriting wtp.ts.nsecs so we can see packet number back if an alert is written for this frame!!!! */
|
/* NB: overwriting the time stamp so we can see packet number back if an alert is written for this frame!!!! */
|
||||||
/* TODO: does this seriously affect snort's ability to reason about time?
|
/* TODO: does this seriously affect snort's ability to reason about time?
|
||||||
* At least all packets will still be in order... */
|
* At least all packets will still be in order... */
|
||||||
wtp.ts.nsecs = pinfo->fd->num * 1000; /* XXX, max 999'999 frames */
|
rec.ts.nsecs = pinfo->fd->num * 1000; /* XXX, max 999'999 frames */
|
||||||
|
|
||||||
wtp.caplen = tvb_captured_length(tvb);
|
rec.rec_header.packet_header.caplen = tvb_captured_length(tvb);
|
||||||
wtp.len = tvb_reported_length(tvb);
|
rec.rec_header.packet_header.len = tvb_reported_length(tvb);
|
||||||
if (current_session.pdh->encap != wtp.pkt_encap) {
|
if (current_session.pdh->encap != rec.rec_header.packet_header.pkt_encap) {
|
||||||
/* XXX, warning! convert? */
|
/* XXX, warning! convert? */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dump frame into snort's stdin */
|
/* Dump frame into snort's stdin */
|
||||||
if (!wtap_dump(current_session.pdh, &wtp, tvb_get_ptr(tvb, 0, tvb_reported_length(tvb)), &write_err, &err_info)) {
|
if (!wtap_dump(current_session.pdh, &rec, tvb_get_ptr(tvb, 0, tvb_reported_length(tvb)), &write_err, &err_info)) {
|
||||||
current_session.working = FALSE;
|
current_session.working = FALSE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1898,8 +1898,8 @@ dissect_sysdig_event(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
||||||
{
|
{
|
||||||
proto_item *ti;
|
proto_item *ti;
|
||||||
proto_tree *se_tree, *syscall_tree;
|
proto_tree *se_tree, *syscall_tree;
|
||||||
guint event_type = pinfo->phdr->pseudo_header.sysdig_event.event_type;
|
guint event_type = pinfo->rec->rec_header.syscall_header.event_type;
|
||||||
int encoding = pinfo->phdr->pseudo_header.sysdig_event.byte_order == G_BIG_ENDIAN ? ENC_BIG_ENDIAN : ENC_LITTLE_ENDIAN;
|
int encoding = pinfo->rec->rec_header.syscall_header.byte_order == G_BIG_ENDIAN ? ENC_BIG_ENDIAN : ENC_LITTLE_ENDIAN;
|
||||||
const struct _event_col_info *cur_col_info;
|
const struct _event_col_info *cur_col_info;
|
||||||
const struct _event_tree_info *cur_tree_info;
|
const struct _event_tree_info *cur_tree_info;
|
||||||
|
|
||||||
|
@ -1959,9 +1959,9 @@ dissect_sysdig_event(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
||||||
|
|
||||||
se_tree = proto_item_add_subtree(ti, ett_sysdig_event);
|
se_tree = proto_item_add_subtree(ti, ett_sysdig_event);
|
||||||
|
|
||||||
proto_tree_add_uint(se_tree, hf_se_cpu_id, tvb, 0, 0, pinfo->phdr->pseudo_header.sysdig_event.cpu_id);
|
proto_tree_add_uint(se_tree, hf_se_cpu_id, tvb, 0, 0, pinfo->rec->rec_header.syscall_header.cpu_id);
|
||||||
proto_tree_add_uint64(se_tree, hf_se_thread_id, tvb, 0, 0, pinfo->phdr->pseudo_header.sysdig_event.thread_id);
|
proto_tree_add_uint64(se_tree, hf_se_thread_id, tvb, 0, 0, pinfo->rec->rec_header.syscall_header.thread_id);
|
||||||
proto_tree_add_uint(se_tree, hf_se_event_length, tvb, 0, 0, pinfo->phdr->pseudo_header.sysdig_event.event_len);
|
proto_tree_add_uint(se_tree, hf_se_event_length, tvb, 0, 0, pinfo->rec->rec_header.syscall_header.event_len);
|
||||||
ti = proto_tree_add_uint(se_tree, hf_se_event_type, tvb, 0, 0, event_type);
|
ti = proto_tree_add_uint(se_tree, hf_se_event_type, tvb, 0, 0, event_type);
|
||||||
|
|
||||||
syscall_tree = proto_item_add_subtree(ti, ett_sysdig_syscall);
|
syscall_tree = proto_item_add_subtree(ti, ett_sysdig_syscall);
|
||||||
|
@ -1975,7 +1975,7 @@ dissect_sysdig_event(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
||||||
|
|
||||||
/* XXX */
|
/* XXX */
|
||||||
/* return offset; */
|
/* return offset; */
|
||||||
return pinfo->phdr->pseudo_header.sysdig_event.event_len;
|
return pinfo->rec->rec_header.syscall_header.event_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register the protocol with Wireshark.
|
/* Register the protocol with Wireshark.
|
||||||
|
|
16
epan/epan.c
16
epan/epan.c
|
@ -517,14 +517,14 @@ epan_dissect_fake_protocols(epan_dissect_t *edt, const gboolean fake_protocols)
|
||||||
|
|
||||||
void
|
void
|
||||||
epan_dissect_run(epan_dissect_t *edt, int file_type_subtype,
|
epan_dissect_run(epan_dissect_t *edt, int file_type_subtype,
|
||||||
struct wtap_pkthdr *phdr, tvbuff_t *tvb, frame_data *fd,
|
wtap_rec *rec, tvbuff_t *tvb, frame_data *fd,
|
||||||
column_info *cinfo)
|
column_info *cinfo)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LUA
|
#ifdef HAVE_LUA
|
||||||
wslua_prime_dfilter(edt); /* done before entering wmem scope */
|
wslua_prime_dfilter(edt); /* done before entering wmem scope */
|
||||||
#endif
|
#endif
|
||||||
wmem_enter_packet_scope();
|
wmem_enter_packet_scope();
|
||||||
dissect_record(edt, file_type_subtype, phdr, tvb, fd, cinfo);
|
dissect_record(edt, file_type_subtype, rec, tvb, fd, cinfo);
|
||||||
|
|
||||||
/* free all memory allocated */
|
/* free all memory allocated */
|
||||||
wmem_leave_packet_scope();
|
wmem_leave_packet_scope();
|
||||||
|
@ -532,12 +532,12 @@ epan_dissect_run(epan_dissect_t *edt, int file_type_subtype,
|
||||||
|
|
||||||
void
|
void
|
||||||
epan_dissect_run_with_taps(epan_dissect_t *edt, int file_type_subtype,
|
epan_dissect_run_with_taps(epan_dissect_t *edt, int file_type_subtype,
|
||||||
struct wtap_pkthdr *phdr, tvbuff_t *tvb, frame_data *fd,
|
wtap_rec *rec, tvbuff_t *tvb, frame_data *fd,
|
||||||
column_info *cinfo)
|
column_info *cinfo)
|
||||||
{
|
{
|
||||||
wmem_enter_packet_scope();
|
wmem_enter_packet_scope();
|
||||||
tap_queue_init(edt);
|
tap_queue_init(edt);
|
||||||
dissect_record(edt, file_type_subtype, phdr, tvb, fd, cinfo);
|
dissect_record(edt, file_type_subtype, rec, tvb, fd, cinfo);
|
||||||
tap_push_tapped_queue(edt);
|
tap_push_tapped_queue(edt);
|
||||||
|
|
||||||
/* free all memory allocated */
|
/* free all memory allocated */
|
||||||
|
@ -545,26 +545,26 @@ epan_dissect_run_with_taps(epan_dissect_t *edt, int file_type_subtype,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
epan_dissect_file_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
|
epan_dissect_file_run(epan_dissect_t *edt, wtap_rec *rec,
|
||||||
tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
|
tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LUA
|
#ifdef HAVE_LUA
|
||||||
wslua_prime_dfilter(edt); /* done before entering wmem scope */
|
wslua_prime_dfilter(edt); /* done before entering wmem scope */
|
||||||
#endif
|
#endif
|
||||||
wmem_enter_packet_scope();
|
wmem_enter_packet_scope();
|
||||||
dissect_file(edt, phdr, tvb, fd, cinfo);
|
dissect_file(edt, rec, tvb, fd, cinfo);
|
||||||
|
|
||||||
/* free all memory allocated */
|
/* free all memory allocated */
|
||||||
wmem_leave_packet_scope();
|
wmem_leave_packet_scope();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
epan_dissect_file_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
|
epan_dissect_file_run_with_taps(epan_dissect_t *edt, wtap_rec *rec,
|
||||||
tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
|
tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
|
||||||
{
|
{
|
||||||
wmem_enter_packet_scope();
|
wmem_enter_packet_scope();
|
||||||
tap_queue_init(edt);
|
tap_queue_init(edt);
|
||||||
dissect_file(edt, phdr, tvb, fd, cinfo);
|
dissect_file(edt, rec, tvb, fd, cinfo);
|
||||||
tap_push_tapped_queue(edt);
|
tap_push_tapped_queue(edt);
|
||||||
|
|
||||||
/* free all memory allocated */
|
/* free all memory allocated */
|
||||||
|
|
|
@ -200,24 +200,24 @@ epan_dissect_fake_protocols(epan_dissect_t *edt, const gboolean fake_protocols);
|
||||||
WS_DLL_PUBLIC
|
WS_DLL_PUBLIC
|
||||||
void
|
void
|
||||||
epan_dissect_run(epan_dissect_t *edt, int file_type_subtype,
|
epan_dissect_run(epan_dissect_t *edt, int file_type_subtype,
|
||||||
struct wtap_pkthdr *phdr, tvbuff_t *tvb, frame_data *fd,
|
wtap_rec *rec, tvbuff_t *tvb, frame_data *fd,
|
||||||
struct epan_column_info *cinfo);
|
struct epan_column_info *cinfo);
|
||||||
|
|
||||||
WS_DLL_PUBLIC
|
WS_DLL_PUBLIC
|
||||||
void
|
void
|
||||||
epan_dissect_run_with_taps(epan_dissect_t *edt, int file_type_subtype,
|
epan_dissect_run_with_taps(epan_dissect_t *edt, int file_type_subtype,
|
||||||
struct wtap_pkthdr *phdr, tvbuff_t *tvb, frame_data *fd,
|
wtap_rec *rec, tvbuff_t *tvb, frame_data *fd,
|
||||||
struct epan_column_info *cinfo);
|
struct epan_column_info *cinfo);
|
||||||
|
|
||||||
/** run a single file packet dissection */
|
/** run a single file packet dissection */
|
||||||
WS_DLL_PUBLIC
|
WS_DLL_PUBLIC
|
||||||
void
|
void
|
||||||
epan_dissect_file_run(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
|
epan_dissect_file_run(epan_dissect_t *edt, wtap_rec *rec,
|
||||||
tvbuff_t *tvb, frame_data *fd, struct epan_column_info *cinfo);
|
tvbuff_t *tvb, frame_data *fd, struct epan_column_info *cinfo);
|
||||||
|
|
||||||
WS_DLL_PUBLIC
|
WS_DLL_PUBLIC
|
||||||
void
|
void
|
||||||
epan_dissect_file_run_with_taps(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
|
epan_dissect_file_run_with_taps(epan_dissect_t *edt, wtap_rec *rec,
|
||||||
tvbuff_t *tvb, frame_data *fd, struct epan_column_info *cinfo);
|
tvbuff_t *tvb, frame_data *fd, struct epan_column_info *cinfo);
|
||||||
|
|
||||||
/** Prime an epan_dissect_t's proto_tree using the fields/protocols used in a dfilter. */
|
/** Prime an epan_dissect_t's proto_tree using the fields/protocols used in a dfilter. */
|
||||||
|
|
|
@ -151,19 +151,13 @@ frame_data_compare(const struct epan_session *epan, const frame_data *fdata1, co
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
frame_data_init(frame_data *fdata, guint32 num,
|
frame_data_init(frame_data *fdata, guint32 num, const wtap_rec *rec,
|
||||||
const struct wtap_pkthdr *phdr, gint64 offset,
|
gint64 offset, guint32 cum_bytes)
|
||||||
guint32 cum_bytes)
|
|
||||||
{
|
{
|
||||||
fdata->pfd = NULL;
|
fdata->pfd = NULL;
|
||||||
fdata->num = num;
|
fdata->num = num;
|
||||||
fdata->pkt_len = phdr->len;
|
|
||||||
fdata->cum_bytes = cum_bytes + phdr->len;
|
|
||||||
fdata->cap_len = phdr->caplen;
|
|
||||||
fdata->file_off = offset;
|
fdata->file_off = offset;
|
||||||
fdata->subnum = 0;
|
fdata->subnum = 0;
|
||||||
/* To save some memory, we coerce it into a gint16 */
|
|
||||||
g_assert(phdr->pkt_encap <= G_MAXINT16);
|
|
||||||
fdata->flags.passed_dfilter = 0;
|
fdata->flags.passed_dfilter = 0;
|
||||||
fdata->flags.dependent_of_displayed = 0;
|
fdata->flags.dependent_of_displayed = 0;
|
||||||
fdata->flags.encoding = PACKET_CHAR_ENC_CHAR_ASCII;
|
fdata->flags.encoding = PACKET_CHAR_ENC_CHAR_ASCII;
|
||||||
|
@ -171,13 +165,40 @@ frame_data_init(frame_data *fdata, guint32 num,
|
||||||
fdata->flags.marked = 0;
|
fdata->flags.marked = 0;
|
||||||
fdata->flags.ref_time = 0;
|
fdata->flags.ref_time = 0;
|
||||||
fdata->flags.ignored = 0;
|
fdata->flags.ignored = 0;
|
||||||
fdata->flags.has_ts = (phdr->presence_flags & WTAP_HAS_TS) ? 1 : 0;
|
fdata->flags.has_ts = (rec->presence_flags & WTAP_HAS_TS) ? 1 : 0;
|
||||||
fdata->flags.has_phdr_comment = (phdr->opt_comment != NULL);
|
switch (rec->rec_type) {
|
||||||
|
|
||||||
|
case REC_TYPE_PACKET:
|
||||||
|
fdata->pkt_len = rec->rec_header.packet_header.len;
|
||||||
|
fdata->cum_bytes = cum_bytes + rec->rec_header.packet_header.len;
|
||||||
|
fdata->cap_len = rec->rec_header.packet_header.caplen;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case REC_TYPE_FT_SPECIFIC_EVENT:
|
||||||
|
case REC_TYPE_FT_SPECIFIC_REPORT:
|
||||||
|
/*
|
||||||
|
* XXX
|
||||||
|
*/
|
||||||
|
fdata->pkt_len = 0;
|
||||||
|
fdata->cum_bytes = 0;
|
||||||
|
fdata->cap_len = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case REC_TYPE_SYSCALL:
|
||||||
|
fdata->pkt_len = rec->rec_header.syscall_header.len;
|
||||||
|
fdata->cum_bytes = cum_bytes + rec->rec_header.syscall_header.len;
|
||||||
|
fdata->cap_len = rec->rec_header.syscall_header.caplen;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* To save some memory, we coerce it into a gint16 */
|
||||||
|
g_assert(rec->tsprec <= G_MAXINT16);
|
||||||
|
fdata->tsprec = (gint16)rec->tsprec;
|
||||||
|
fdata->abs_ts = rec->ts;
|
||||||
|
fdata->flags.has_phdr_comment = (rec->opt_comment != NULL);
|
||||||
fdata->flags.has_user_comment = 0;
|
fdata->flags.has_user_comment = 0;
|
||||||
fdata->flags.need_colorize = 0;
|
fdata->flags.need_colorize = 0;
|
||||||
fdata->tsprec = (gint16)phdr->pkt_tsprec;
|
|
||||||
fdata->color_filter = NULL;
|
fdata->color_filter = NULL;
|
||||||
fdata->abs_ts = phdr->ts;
|
|
||||||
fdata->shift_offset.secs = 0;
|
fdata->shift_offset.secs = 0;
|
||||||
fdata->shift_offset.nsecs = 0;
|
fdata->shift_offset.nsecs = 0;
|
||||||
fdata->frame_ref_num = 0;
|
fdata->frame_ref_num = 0;
|
||||||
|
|
|
@ -91,7 +91,7 @@ WS_DLL_PUBLIC void frame_data_reset(frame_data *fdata);
|
||||||
WS_DLL_PUBLIC void frame_data_destroy(frame_data *fdata);
|
WS_DLL_PUBLIC void frame_data_destroy(frame_data *fdata);
|
||||||
|
|
||||||
WS_DLL_PUBLIC void frame_data_init(frame_data *fdata, guint32 num,
|
WS_DLL_PUBLIC void frame_data_init(frame_data *fdata, guint32 num,
|
||||||
const struct wtap_pkthdr *phdr, gint64 offset,
|
const wtap_rec *rec, gint64 offset,
|
||||||
guint32 cum_bytes);
|
guint32 cum_bytes);
|
||||||
|
|
||||||
extern void frame_delta_abs_time(const struct epan_session *epan, const frame_data *fdata,
|
extern void frame_delta_abs_time(const struct epan_session *epan, const frame_data *fdata,
|
||||||
|
|
|
@ -466,12 +466,12 @@ final_registration_all_protocols(void)
|
||||||
/* Creates the top-most tvbuff and calls dissect_frame() */
|
/* Creates the top-most tvbuff and calls dissect_frame() */
|
||||||
void
|
void
|
||||||
dissect_record(epan_dissect_t *edt, int file_type_subtype,
|
dissect_record(epan_dissect_t *edt, int file_type_subtype,
|
||||||
struct wtap_pkthdr *phdr, tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
|
wtap_rec *rec, tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
|
||||||
{
|
{
|
||||||
const char *volatile record_type;
|
const char *volatile record_type;
|
||||||
frame_data_t frame_dissector_data;
|
frame_data_t frame_dissector_data;
|
||||||
|
|
||||||
switch (phdr->rec_type) {
|
switch (rec->rec_type) {
|
||||||
|
|
||||||
case REC_TYPE_PACKET:
|
case REC_TYPE_PACKET:
|
||||||
record_type = "Frame";
|
record_type = "Frame";
|
||||||
|
@ -512,9 +512,24 @@ dissect_record(epan_dissect_t *edt, int file_type_subtype,
|
||||||
edt->pi.presence_flags |= PINFO_HAS_TS;
|
edt->pi.presence_flags |= PINFO_HAS_TS;
|
||||||
edt->pi.abs_ts = fd->abs_ts;
|
edt->pi.abs_ts = fd->abs_ts;
|
||||||
}
|
}
|
||||||
|
switch (rec->rec_type) {
|
||||||
|
|
||||||
|
case REC_TYPE_PACKET:
|
||||||
|
edt->pi.pseudo_header = &rec->rec_header.packet_header.pseudo_header;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case REC_TYPE_FT_SPECIFIC_EVENT:
|
||||||
|
case REC_TYPE_FT_SPECIFIC_REPORT:
|
||||||
|
edt->pi.pseudo_header = NULL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case REC_TYPE_SYSCALL:
|
||||||
|
edt->pi.pseudo_header = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
edt->pi.fd = fd;
|
edt->pi.fd = fd;
|
||||||
edt->pi.phdr = phdr;
|
edt->pi.rec = rec;
|
||||||
edt->pi.pseudo_header = &phdr->pseudo_header;
|
|
||||||
clear_address(&edt->pi.dl_src);
|
clear_address(&edt->pi.dl_src);
|
||||||
clear_address(&edt->pi.dl_dst);
|
clear_address(&edt->pi.dl_dst);
|
||||||
clear_address(&edt->pi.net_src);
|
clear_address(&edt->pi.net_src);
|
||||||
|
@ -532,11 +547,11 @@ dissect_record(epan_dissect_t *edt, int file_type_subtype,
|
||||||
|
|
||||||
frame_delta_abs_time(edt->session, fd, fd->frame_ref_num, &edt->pi.rel_ts);
|
frame_delta_abs_time(edt->session, fd, fd->frame_ref_num, &edt->pi.rel_ts);
|
||||||
|
|
||||||
/* pkt comment use first user, later from phdr */
|
/* pkt comment use first user, later from rec */
|
||||||
if (fd->flags.has_user_comment)
|
if (fd->flags.has_user_comment)
|
||||||
frame_dissector_data.pkt_comment = epan_get_user_comment(edt->session, fd);
|
frame_dissector_data.pkt_comment = epan_get_user_comment(edt->session, fd);
|
||||||
else if (fd->flags.has_phdr_comment)
|
else if (fd->flags.has_phdr_comment)
|
||||||
frame_dissector_data.pkt_comment = phdr->opt_comment;
|
frame_dissector_data.pkt_comment = rec->opt_comment;
|
||||||
else
|
else
|
||||||
frame_dissector_data.pkt_comment = NULL;
|
frame_dissector_data.pkt_comment = NULL;
|
||||||
frame_dissector_data.file_type_subtype = file_type_subtype;
|
frame_dissector_data.file_type_subtype = file_type_subtype;
|
||||||
|
@ -567,7 +582,7 @@ dissect_record(epan_dissect_t *edt, int file_type_subtype,
|
||||||
|
|
||||||
/* Creates the top-most tvbuff and calls dissect_file() */
|
/* Creates the top-most tvbuff and calls dissect_file() */
|
||||||
void
|
void
|
||||||
dissect_file(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
|
dissect_file(epan_dissect_t *edt, wtap_rec *rec,
|
||||||
tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
|
tvbuff_t *tvb, frame_data *fd, column_info *cinfo)
|
||||||
{
|
{
|
||||||
file_data_t file_dissector_data;
|
file_data_t file_dissector_data;
|
||||||
|
@ -579,8 +594,8 @@ dissect_file(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
|
||||||
edt->pi.current_proto = "<Missing Filetype Name>";
|
edt->pi.current_proto = "<Missing Filetype Name>";
|
||||||
edt->pi.cinfo = cinfo;
|
edt->pi.cinfo = cinfo;
|
||||||
edt->pi.fd = fd;
|
edt->pi.fd = fd;
|
||||||
edt->pi.phdr = phdr;
|
edt->pi.rec = rec;
|
||||||
edt->pi.pseudo_header = &phdr->pseudo_header;
|
edt->pi.pseudo_header = NULL;
|
||||||
clear_address(&edt->pi.dl_src);
|
clear_address(&edt->pi.dl_src);
|
||||||
clear_address(&edt->pi.dl_dst);
|
clear_address(&edt->pi.dl_dst);
|
||||||
clear_address(&edt->pi.net_src);
|
clear_address(&edt->pi.net_src);
|
||||||
|
@ -601,11 +616,11 @@ dissect_file(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
|
||||||
|
|
||||||
|
|
||||||
TRY {
|
TRY {
|
||||||
/* pkt comment use first user, later from phdr */
|
/* pkt comment use first user, later from rec */
|
||||||
if (fd->flags.has_user_comment)
|
if (fd->flags.has_user_comment)
|
||||||
file_dissector_data.pkt_comment = epan_get_user_comment(edt->session, fd);
|
file_dissector_data.pkt_comment = epan_get_user_comment(edt->session, fd);
|
||||||
else if (fd->flags.has_phdr_comment)
|
else if (fd->flags.has_phdr_comment)
|
||||||
file_dissector_data.pkt_comment = phdr->opt_comment;
|
file_dissector_data.pkt_comment = rec->opt_comment;
|
||||||
else
|
else
|
||||||
file_dissector_data.pkt_comment = NULL;
|
file_dissector_data.pkt_comment = NULL;
|
||||||
file_dissector_data.color_edt = edt; /* Used strictly for "coloring rules" */
|
file_dissector_data.color_edt = edt; /* Used strictly for "coloring rules" */
|
||||||
|
|
|
@ -748,15 +748,13 @@ typedef struct file_data_s
|
||||||
* Dissectors should never modify the record data.
|
* Dissectors should never modify the record data.
|
||||||
*/
|
*/
|
||||||
extern void dissect_record(struct epan_dissect *edt, int file_type_subtype,
|
extern void dissect_record(struct epan_dissect *edt, int file_type_subtype,
|
||||||
struct wtap_pkthdr *phdr, tvbuff_t *tvb,
|
wtap_rec *rec, tvbuff_t *tvb, frame_data *fd, column_info *cinfo);
|
||||||
frame_data *fd, column_info *cinfo);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dissectors should never modify the packet data.
|
* Dissectors should never modify the packet data.
|
||||||
*/
|
*/
|
||||||
extern void dissect_file(struct epan_dissect *edt,
|
extern void dissect_file(struct epan_dissect *edt,
|
||||||
struct wtap_pkthdr *phdr, tvbuff_t *tvb,
|
wtap_rec *rec, tvbuff_t *tvb, frame_data *fd, column_info *cinfo);
|
||||||
frame_data *fd, column_info *cinfo);
|
|
||||||
|
|
||||||
/* Structure passed to the ethertype dissector */
|
/* Structure passed to the ethertype dissector */
|
||||||
typedef struct ethertype_data_s
|
typedef struct ethertype_data_s
|
||||||
|
|
|
@ -50,7 +50,7 @@ typedef struct _packet_info {
|
||||||
nstime_t rel_ts; /**< Relative timestamp (yes, it can be negative) */
|
nstime_t rel_ts; /**< Relative timestamp (yes, it can be negative) */
|
||||||
frame_data *fd;
|
frame_data *fd;
|
||||||
union wtap_pseudo_header *pseudo_header;
|
union wtap_pseudo_header *pseudo_header;
|
||||||
struct wtap_pkthdr *phdr; /**< Record metadata */
|
wtap_rec *rec; /**< Record metadata */
|
||||||
GSList *data_src; /**< Frame data sources */
|
GSList *data_src; /**< Frame data sources */
|
||||||
address dl_src; /**< link-layer source address */
|
address dl_src; /**< link-layer source address */
|
||||||
address dl_dst; /**< link-layer destination address */
|
address dl_dst; /**< link-layer destination address */
|
||||||
|
|
|
@ -267,13 +267,13 @@ struct _wslua_captureinfo {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _wslua_phdr {
|
struct _wslua_phdr {
|
||||||
struct wtap_pkthdr *phdr; /* this also exists in wtap struct, but is different for seek_read ops */
|
wtap_rec *rec; /* this also exists in wtap struct, but is different for seek_read ops */
|
||||||
Buffer *buf; /* can't use the one in wtap because it's different for seek_read ops */
|
Buffer *buf; /* can't use the one in wtap because it's different for seek_read ops */
|
||||||
gboolean expired;
|
gboolean expired;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _wslua_const_phdr {
|
struct _wslua_const_phdr {
|
||||||
const struct wtap_pkthdr *phdr;
|
const wtap_rec *rec;
|
||||||
const guint8 *pd;
|
const guint8 *pd;
|
||||||
gboolean expired;
|
gboolean expired;
|
||||||
};
|
};
|
||||||
|
|
|
@ -81,7 +81,7 @@ WSLUA_METAMETHOD CaptureInfo__tostring(lua_State* L) {
|
||||||
} else {
|
} else {
|
||||||
wtap *wth = fi->wth;
|
wtap *wth = fi->wth;
|
||||||
lua_pushfstring(L, "CaptureInfo: file_type_subtype=%d, snapshot_length=%d, pkt_encap=%d, file_tsprec='%s'",
|
lua_pushfstring(L, "CaptureInfo: file_type_subtype=%d, snapshot_length=%d, pkt_encap=%d, file_tsprec='%s'",
|
||||||
wth->file_type_subtype, wth->snapshot_length, wth->phdr.pkt_encap, wth->file_tsprec);
|
wth->file_type_subtype, wth->snapshot_length, wth->rec.rec_header.packet_header.pkt_encap, wth->file_tsprec);
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* String of debug information. */
|
WSLUA_RETURN(1); /* String of debug information. */
|
||||||
|
|
|
@ -298,7 +298,7 @@ WSLUA_METHOD Dumper_dump(lua_State* L) {
|
||||||
Dumper d = checkDumper(L,1);
|
Dumper d = checkDumper(L,1);
|
||||||
PseudoHeader ph;
|
PseudoHeader ph;
|
||||||
ByteArray ba;
|
ByteArray ba;
|
||||||
struct wtap_pkthdr pkthdr;
|
wtap_rec rec;
|
||||||
double ts;
|
double ts;
|
||||||
int err;
|
int err;
|
||||||
gchar *err_info;
|
gchar *err_info;
|
||||||
|
@ -320,25 +320,25 @@ WSLUA_METHOD Dumper_dump(lua_State* L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&pkthdr, 0, sizeof(pkthdr));
|
memset(&rec, 0, sizeof rec);
|
||||||
|
|
||||||
pkthdr.rec_type = REC_TYPE_PACKET;
|
rec.rec_type = REC_TYPE_PACKET;
|
||||||
|
|
||||||
pkthdr.presence_flags = WTAP_HAS_TS;
|
rec.presence_flags = WTAP_HAS_TS;
|
||||||
pkthdr.ts.secs = (unsigned int)(floor(ts));
|
rec.ts.secs = (unsigned int)(floor(ts));
|
||||||
pkthdr.ts.nsecs = (unsigned int)(floor((ts - (double)pkthdr.ts.secs) * 1000000000));
|
rec.ts.nsecs = (unsigned int)(floor((ts - (double)rec.ts.secs) * 1000000000));
|
||||||
|
|
||||||
pkthdr.len = ba->len;
|
rec.rec_header.packet_header.len = ba->len;
|
||||||
pkthdr.caplen = ba->len;
|
rec.rec_header.packet_header.caplen = ba->len;
|
||||||
pkthdr.pkt_encap = DUMPER_ENCAP(d);
|
rec.rec_header.packet_header.pkt_encap = DUMPER_ENCAP(d);
|
||||||
if (ph->wph) {
|
if (ph->wph) {
|
||||||
pkthdr.pseudo_header = *ph->wph;
|
rec.rec_header.packet_header.pseudo_header = *ph->wph;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Can we get access to pinfo->pkt_comment here somehow? We
|
/* TODO: Can we get access to pinfo->pkt_comment here somehow? We
|
||||||
* should be copying it to pkthdr.opt_comment if we can. */
|
* should be copying it to pkthdr.opt_comment if we can. */
|
||||||
|
|
||||||
if (! wtap_dump(d, &pkthdr, ba->data, &err, &err_info)) {
|
if (! wtap_dump(d, &rec, ba->data, &err, &err_info)) {
|
||||||
switch (err) {
|
switch (err) {
|
||||||
|
|
||||||
case WTAP_ERR_UNWRITABLE_REC_DATA:
|
case WTAP_ERR_UNWRITABLE_REC_DATA:
|
||||||
|
@ -375,7 +375,11 @@ WSLUA_METHOD Dumper_new_for_current(lua_State* L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
encap = lua_pinfo->phdr->pkt_encap;
|
if (lua_pinfo->rec->rec_type != REC_TYPE_PACKET) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
encap = lua_pinfo->rec->rec_header.packet_header.pkt_encap;
|
||||||
|
|
||||||
d = wtap_dump_open(filename, filetype, encap, 0, FALSE, &err);
|
d = wtap_dump_open(filename, filetype, encap, 0, FALSE, &err);
|
||||||
|
|
||||||
|
@ -411,7 +415,7 @@ WSLUA_METHOD Dumper_dump_current(lua_State* L) {
|
||||||
Dumps the current packet as it is.
|
Dumps the current packet as it is.
|
||||||
*/
|
*/
|
||||||
Dumper d = checkDumper(L,1);
|
Dumper d = checkDumper(L,1);
|
||||||
struct wtap_pkthdr pkthdr;
|
wtap_rec rec;
|
||||||
const guchar* data;
|
const guchar* data;
|
||||||
tvbuff_t* tvb;
|
tvbuff_t* tvb;
|
||||||
struct data_source *data_src;
|
struct data_source *data_src;
|
||||||
|
@ -425,32 +429,36 @@ WSLUA_METHOD Dumper_dump_current(lua_State* L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lua_pinfo->rec->rec_type != REC_TYPE_PACKET) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
data_src = (struct data_source*) (lua_pinfo->data_src->data);
|
data_src = (struct data_source*) (lua_pinfo->data_src->data);
|
||||||
if (!data_src)
|
if (!data_src)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
tvb = get_data_source_tvb(data_src);
|
tvb = get_data_source_tvb(data_src);
|
||||||
|
|
||||||
memset(&pkthdr, 0, sizeof(pkthdr));
|
memset(&rec, 0, sizeof rec);
|
||||||
|
|
||||||
pkthdr.rec_type = REC_TYPE_PACKET;
|
rec.rec_type = REC_TYPE_PACKET;
|
||||||
pkthdr.presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
rec.presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
||||||
pkthdr.ts = lua_pinfo->abs_ts;
|
rec.ts = lua_pinfo->abs_ts;
|
||||||
pkthdr.len = tvb_reported_length(tvb);
|
rec.rec_header.packet_header.len = tvb_reported_length(tvb);
|
||||||
pkthdr.caplen = tvb_captured_length(tvb);
|
rec.rec_header.packet_header.caplen = tvb_captured_length(tvb);
|
||||||
pkthdr.pkt_encap = lua_pinfo->phdr->pkt_encap;
|
rec.rec_header.packet_header.pkt_encap = lua_pinfo->rec->rec_header.packet_header.pkt_encap;
|
||||||
pkthdr.pseudo_header = *lua_pinfo->pseudo_header;
|
rec.rec_header.packet_header.pseudo_header = *lua_pinfo->pseudo_header;
|
||||||
|
|
||||||
if (lua_pinfo->fd->flags.has_user_comment) {
|
if (lua_pinfo->fd->flags.has_user_comment) {
|
||||||
pkthdr.opt_comment = wmem_strdup(wmem_packet_scope(), epan_get_user_comment(lua_pinfo->epan, lua_pinfo->fd));
|
rec.opt_comment = wmem_strdup(wmem_packet_scope(), epan_get_user_comment(lua_pinfo->epan, lua_pinfo->fd));
|
||||||
pkthdr.has_comment_changed = TRUE;
|
rec.has_comment_changed = TRUE;
|
||||||
} else if (lua_pinfo->fd->flags.has_phdr_comment) {
|
} else if (lua_pinfo->fd->flags.has_phdr_comment) {
|
||||||
pkthdr.opt_comment = wmem_strdup(wmem_packet_scope(), lua_pinfo->phdr->opt_comment);
|
rec.opt_comment = wmem_strdup(wmem_packet_scope(), lua_pinfo->rec->opt_comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
data = (const guchar *)tvb_memdup(wmem_packet_scope(),tvb,0,pkthdr.caplen);
|
data = (const guchar *)tvb_memdup(wmem_packet_scope(),tvb,0,rec.rec_header.packet_header.caplen);
|
||||||
|
|
||||||
if (! wtap_dump(d, &pkthdr, data, &err, &err_info)) {
|
if (! wtap_dump(d, &rec, data, &err, &err_info)) {
|
||||||
switch (err) {
|
switch (err) {
|
||||||
|
|
||||||
case WTAP_ERR_UNWRITABLE_REC_DATA:
|
case WTAP_ERR_UNWRITABLE_REC_DATA:
|
||||||
|
|
|
@ -68,8 +68,8 @@ extern CaptureInfo* push_CaptureInfo(lua_State* L, wtap *wth, const gboolean fir
|
||||||
extern CaptureInfoConst* push_CaptureInfoConst(lua_State* L, wtap_dumper *wdh);
|
extern CaptureInfoConst* push_CaptureInfoConst(lua_State* L, wtap_dumper *wdh);
|
||||||
extern File* push_File(lua_State* L, FILE_T ft);
|
extern File* push_File(lua_State* L, FILE_T ft);
|
||||||
extern File* push_Wdh(lua_State* L, wtap_dumper *wdh);
|
extern File* push_Wdh(lua_State* L, wtap_dumper *wdh);
|
||||||
extern FrameInfo* push_FrameInfo(lua_State* L, struct wtap_pkthdr *phdr, Buffer* buf);
|
extern FrameInfo* push_FrameInfo(lua_State* L, wtap_rec *rec, Buffer* buf);
|
||||||
extern FrameInfoConst* push_FrameInfoConst(lua_State* L, const struct wtap_pkthdr *phdr, const guint8 *pd);
|
extern FrameInfoConst* push_FrameInfoConst(lua_State* L, const wtap_rec *rec, const guint8 *pd);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -144,7 +144,7 @@ wslua_filehandler_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean
|
static gboolean
|
||||||
wslua_filehandler_seek_read(wtap *wth, gint64 seek_off,
|
wslua_filehandler_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info);
|
int *err, gchar **err_info);
|
||||||
static void
|
static void
|
||||||
wslua_filehandler_close(wtap *wth);
|
wslua_filehandler_close(wtap *wth);
|
||||||
|
@ -272,11 +272,11 @@ wslua_filehandler_read(wtap *wth, int *err, gchar **err_info,
|
||||||
*err = errno = 0;
|
*err = errno = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
wth->phdr.opt_comment = NULL;
|
wth->rec.opt_comment = NULL;
|
||||||
|
|
||||||
fp = push_File(L, wth->fh);
|
fp = push_File(L, wth->fh);
|
||||||
fc = push_CaptureInfo(L, wth, FALSE);
|
fc = push_CaptureInfo(L, wth, FALSE);
|
||||||
fi = push_FrameInfo(L, &wth->phdr, wth->frame_buffer);
|
fi = push_FrameInfo(L, &wth->rec, wth->rec_data);
|
||||||
|
|
||||||
switch ( lua_pcall(L,3,1,1) ) {
|
switch ( lua_pcall(L,3,1,1) ) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -312,7 +312,7 @@ wslua_filehandler_read(wtap *wth, int *err, gchar **err_info,
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
wslua_filehandler_seek_read(wtap *wth, gint64 seek_off,
|
wslua_filehandler_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
FileHandler fh = (FileHandler)(wth->wslua_data);
|
FileHandler fh = (FileHandler)(wth->wslua_data);
|
||||||
|
@ -328,11 +328,11 @@ wslua_filehandler_seek_read(wtap *wth, gint64 seek_off,
|
||||||
if (err) {
|
if (err) {
|
||||||
*err = errno = 0;
|
*err = errno = 0;
|
||||||
}
|
}
|
||||||
phdr->opt_comment = NULL;
|
rec->opt_comment = NULL;
|
||||||
|
|
||||||
fp = push_File(L, wth->random_fh);
|
fp = push_File(L, wth->random_fh);
|
||||||
fc = push_CaptureInfo(L, wth, FALSE);
|
fc = push_CaptureInfo(L, wth, FALSE);
|
||||||
fi = push_FrameInfo(L, phdr, buf);
|
fi = push_FrameInfo(L, rec, buf);
|
||||||
lua_pushnumber(L, (lua_Number)seek_off);
|
lua_pushnumber(L, (lua_Number)seek_off);
|
||||||
|
|
||||||
switch ( lua_pcall(L,4,1,1) ) {
|
switch ( lua_pcall(L,4,1,1) ) {
|
||||||
|
@ -468,7 +468,7 @@ wslua_filehandler_can_write_encap(int encap, void* data)
|
||||||
|
|
||||||
/* some declarations */
|
/* some declarations */
|
||||||
static gboolean
|
static gboolean
|
||||||
wslua_filehandler_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
wslua_filehandler_dump(wtap_dumper *wdh, const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info);
|
const guint8 *pd, int *err, gchar **err_info);
|
||||||
static gboolean
|
static gboolean
|
||||||
wslua_filehandler_dump_finish(wtap_dumper *wdh, int *err);
|
wslua_filehandler_dump_finish(wtap_dumper *wdh, int *err);
|
||||||
|
@ -539,7 +539,7 @@ wslua_filehandler_dump_open(wtap_dumper *wdh, int *err)
|
||||||
* else FALSE.
|
* else FALSE.
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
wslua_filehandler_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
wslua_filehandler_dump(wtap_dumper *wdh, const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info _U_)
|
const guint8 *pd, int *err, gchar **err_info _U_)
|
||||||
{
|
{
|
||||||
FileHandler fh = (FileHandler)(wdh->wslua_data);
|
FileHandler fh = (FileHandler)(wdh->wslua_data);
|
||||||
|
@ -558,7 +558,7 @@ wslua_filehandler_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||||
|
|
||||||
fp = push_Wdh(L, wdh);
|
fp = push_Wdh(L, wdh);
|
||||||
fc = push_CaptureInfoConst(L,wdh);
|
fc = push_CaptureInfoConst(L,wdh);
|
||||||
fi = push_FrameInfoConst(L, phdr, pd);
|
fi = push_FrameInfoConst(L, rec, pd);
|
||||||
|
|
||||||
errno = WTAP_ERR_CANT_WRITE;
|
errno = WTAP_ERR_CANT_WRITE;
|
||||||
switch ( lua_pcall(L,3,1,1) ) {
|
switch ( lua_pcall(L,3,1,1) ) {
|
||||||
|
|
|
@ -52,9 +52,9 @@ WSLUA_CLASS_DEFINE(FrameInfo,FAIL_ON_NULL_OR_EXPIRED("FrameInfo"));
|
||||||
@since 1.11.3
|
@since 1.11.3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FrameInfo* push_FrameInfo(lua_State* L, struct wtap_pkthdr *phdr, Buffer* buf) {
|
FrameInfo* push_FrameInfo(lua_State* L, wtap_rec *rec, Buffer* buf) {
|
||||||
FrameInfo f = (FrameInfo) g_malloc0(sizeof(struct _wslua_phdr));
|
FrameInfo f = (FrameInfo) g_malloc0(sizeof(struct _wslua_phdr));
|
||||||
f->phdr = phdr;
|
f->rec = rec;
|
||||||
f->buf = buf;
|
f->buf = buf;
|
||||||
f->expired = FALSE;
|
f->expired = FALSE;
|
||||||
return pushFrameInfo(L,f);
|
return pushFrameInfo(L,f);
|
||||||
|
@ -67,11 +67,11 @@ WSLUA_METAMETHOD FrameInfo__tostring(lua_State* L) {
|
||||||
if (!fi) {
|
if (!fi) {
|
||||||
lua_pushstring(L,"FrameInfo pointer is NULL!");
|
lua_pushstring(L,"FrameInfo pointer is NULL!");
|
||||||
} else {
|
} else {
|
||||||
if (fi->phdr)
|
if (fi->rec)
|
||||||
lua_pushfstring(L, "FrameInfo: rec_type=%u, presence_flags=%d, caplen=%d, len=%d, pkt_encap=%d, opt_comment='%s'",
|
lua_pushfstring(L, "FrameInfo: rec_type=%u, presence_flags=%d, caplen=%d, len=%d, pkt_encap=%d, opt_comment='%s'",
|
||||||
fi->phdr->rec_type, fi->phdr->presence_flags, fi->phdr->caplen, fi->phdr->len, fi->phdr->pkt_encap, fi->phdr->opt_comment);
|
fi->rec->rec_type, fi->rec->presence_flags, fi->rec->rec_header.packet_header.caplen, fi->rec->rec_header.packet_header.len, fi->rec->rec_header.packet_header.pkt_encap, fi->rec->opt_comment);
|
||||||
else
|
else
|
||||||
lua_pushstring(L, "FrameInfo phdr pointer is NULL!");
|
lua_pushstring(L, "FrameInfo rec pointer is NULL!");
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* String of debug information. */
|
WSLUA_RETURN(1); /* String of debug information. */
|
||||||
|
@ -109,7 +109,7 @@ WSLUA_METHOD FrameInfo_read_data(lua_State* L) {
|
||||||
WSLUA_RETURN(1); /* True if succeeded, else returns false along with the error number and string error description. */
|
WSLUA_RETURN(1); /* True if succeeded, else returns false along with the error number and string error description. */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free the struct we created, but not the phdr/buf it points to */
|
/* free the struct we created, but not the rec/buf it points to */
|
||||||
static int FrameInfo__gc(lua_State* L) {
|
static int FrameInfo__gc(lua_State* L) {
|
||||||
FrameInfo fi = toFrameInfo(L,1);
|
FrameInfo fi = toFrameInfo(L,1);
|
||||||
g_free(fi);
|
g_free(fi);
|
||||||
|
@ -124,10 +124,10 @@ static int FrameInfo_set_time (lua_State* L) {
|
||||||
FrameInfo fi = checkFrameInfo(L,1);
|
FrameInfo fi = checkFrameInfo(L,1);
|
||||||
NSTime nstime = checkNSTime(L,2);
|
NSTime nstime = checkNSTime(L,2);
|
||||||
|
|
||||||
if (!fi->phdr) return 0;
|
if (!fi->rec) return 0;
|
||||||
|
|
||||||
fi->phdr->ts.secs = nstime->secs;
|
fi->rec->ts.secs = nstime->secs;
|
||||||
fi->phdr->ts.nsecs = nstime->nsecs;
|
fi->rec->ts.nsecs = nstime->nsecs;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -138,8 +138,8 @@ static int FrameInfo_get_time (lua_State* L) {
|
||||||
|
|
||||||
if (!nstime) return 0;
|
if (!nstime) return 0;
|
||||||
|
|
||||||
nstime->secs = fi->phdr->ts.secs;
|
nstime->secs = fi->rec->ts.secs;
|
||||||
nstime->nsecs = fi->phdr->ts.nsecs;
|
nstime->nsecs = fi->rec->ts.nsecs;
|
||||||
|
|
||||||
pushNSTime(L,nstime);
|
pushNSTime(L,nstime);
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ static int FrameInfo_get_time (lua_State* L) {
|
||||||
static int FrameInfo_set_data (lua_State* L) {
|
static int FrameInfo_set_data (lua_State* L) {
|
||||||
FrameInfo fi = checkFrameInfo(L,1);
|
FrameInfo fi = checkFrameInfo(L,1);
|
||||||
|
|
||||||
if (!fi->phdr) {
|
if (!fi->rec) {
|
||||||
ws_g_warning("Error in FrameInfo set data: NULL pointer");
|
ws_g_warning("Error in FrameInfo set data: NULL pointer");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -170,8 +170,8 @@ static int FrameInfo_set_data (lua_State* L) {
|
||||||
/* Make sure we have enough room for the packet */
|
/* Make sure we have enough room for the packet */
|
||||||
ws_buffer_assure_space(fi->buf, len);
|
ws_buffer_assure_space(fi->buf, len);
|
||||||
memcpy(ws_buffer_start_ptr(fi->buf), s, len);
|
memcpy(ws_buffer_start_ptr(fi->buf), s, len);
|
||||||
fi->phdr->caplen = (guint32) len;
|
fi->rec->rec_header.packet_header.caplen = (guint32) len;
|
||||||
fi->phdr->len = (guint32) len;
|
fi->rec->rec_header.packet_header.len = (guint32) len;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
luaL_error(L, "FrameInfo's attribute 'data' must be a Lua string");
|
luaL_error(L, "FrameInfo's attribute 'data' must be a Lua string");
|
||||||
|
@ -192,35 +192,35 @@ static int FrameInfo_get_data (lua_State* L) {
|
||||||
/* WSLUA_ATTRIBUTE FrameInfo_rec_type RW The record type of the packet frame
|
/* WSLUA_ATTRIBUTE FrameInfo_rec_type RW The record type of the packet frame
|
||||||
|
|
||||||
See `wtap_rec_types` in `init.lua` for values. */
|
See `wtap_rec_types` in `init.lua` for values. */
|
||||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfo,rec_type,phdr->rec_type);
|
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfo,rec_type,rec->rec_type);
|
||||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FrameInfo,rec_type,phdr->rec_type,guint);
|
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FrameInfo,rec_type,rec->rec_type,guint);
|
||||||
|
|
||||||
/* WSLUA_ATTRIBUTE FrameInfo_flags RW The presence flags of the packet frame.
|
/* WSLUA_ATTRIBUTE FrameInfo_flags RW The presence flags of the packet frame.
|
||||||
|
|
||||||
See `wtap_presence_flags` in `init.lua` for bit values. */
|
See `wtap_presence_flags` in `init.lua` for bit values. */
|
||||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfo,flags,phdr->presence_flags);
|
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfo,flags,rec->presence_flags);
|
||||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FrameInfo,flags,phdr->presence_flags,guint32);
|
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FrameInfo,flags,rec->presence_flags,guint32);
|
||||||
|
|
||||||
/* WSLUA_ATTRIBUTE FrameInfo_captured_length RW The captured packet length,
|
/* WSLUA_ATTRIBUTE FrameInfo_captured_length RW The captured packet length,
|
||||||
and thus the length of the buffer passed to the `FrameInfo.data` field. */
|
and thus the length of the buffer passed to the `FrameInfo.data` field. */
|
||||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfo,captured_length,phdr->caplen);
|
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfo,captured_length,rec->rec_header.packet_header.caplen);
|
||||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FrameInfo,captured_length,phdr->caplen,guint32);
|
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FrameInfo,captured_length,rec->rec_header.packet_header.caplen,guint32);
|
||||||
|
|
||||||
/* WSLUA_ATTRIBUTE FrameInfo_original_length RW The on-the-wire packet length,
|
/* WSLUA_ATTRIBUTE FrameInfo_original_length RW The on-the-wire packet length,
|
||||||
which may be longer than the `captured_length`. */
|
which may be longer than the `captured_length`. */
|
||||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfo,original_length,phdr->len);
|
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfo,original_length,rec->rec_header.packet_header.len);
|
||||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FrameInfo,original_length,phdr->len,guint32);
|
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FrameInfo,original_length,rec->rec_header.packet_header.len,guint32);
|
||||||
|
|
||||||
/* WSLUA_ATTRIBUTE FrameInfo_encap RW The packet encapsulation type for the frame/packet,
|
/* WSLUA_ATTRIBUTE FrameInfo_encap RW The packet encapsulation type for the frame/packet,
|
||||||
if the file supports per-packet types. See `wtap_encaps` in `init.lua` for possible
|
if the file supports per-packet types. See `wtap_encaps` in `init.lua` for possible
|
||||||
packet encapsulation types to use as the value for this field. */
|
packet encapsulation types to use as the value for this field. */
|
||||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfo,encap,phdr->pkt_encap);
|
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfo,encap,rec->rec_header.packet_header.pkt_encap);
|
||||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FrameInfo,encap,phdr->pkt_encap,int);
|
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(FrameInfo,encap,rec->rec_header.packet_header.pkt_encap,int);
|
||||||
|
|
||||||
/* WSLUA_ATTRIBUTE FrameInfo_comment RW A string comment for the packet, if the
|
/* WSLUA_ATTRIBUTE FrameInfo_comment RW A string comment for the packet, if the
|
||||||
`wtap_presence_flags.COMMENTS` was set in the presence flags; nil if there is no comment. */
|
`wtap_presence_flags.COMMENTS` was set in the presence flags; nil if there is no comment. */
|
||||||
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(FrameInfo,comment,phdr->opt_comment);
|
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(FrameInfo,comment,rec->opt_comment);
|
||||||
WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(FrameInfo,comment,phdr->opt_comment,TRUE);
|
WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(FrameInfo,comment,rec->opt_comment,TRUE);
|
||||||
|
|
||||||
/* This table is ultimately registered as a sub-table of the class' metatable,
|
/* This table is ultimately registered as a sub-table of the class' metatable,
|
||||||
* and if __index/__newindex is invoked then it calls the appropriate function
|
* and if __index/__newindex is invoked then it calls the appropriate function
|
||||||
|
@ -263,9 +263,9 @@ WSLUA_CLASS_DEFINE(FrameInfoConst,FAIL_ON_NULL_OR_EXPIRED("FrameInfo"));
|
||||||
@since 1.11.3
|
@since 1.11.3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FrameInfoConst* push_FrameInfoConst(lua_State* L, const struct wtap_pkthdr *phdr, const guint8 *pd) {
|
FrameInfoConst* push_FrameInfoConst(lua_State* L, const wtap_rec *rec, const guint8 *pd) {
|
||||||
FrameInfoConst f = (FrameInfoConst) g_malloc(sizeof(struct _wslua_const_phdr));
|
FrameInfoConst f = (FrameInfoConst) g_malloc(sizeof(struct _wslua_const_phdr));
|
||||||
f->phdr = phdr;
|
f->rec = rec;
|
||||||
f->pd = pd;
|
f->pd = pd;
|
||||||
f->expired = FALSE;
|
f->expired = FALSE;
|
||||||
return pushFrameInfoConst(L,f);
|
return pushFrameInfoConst(L,f);
|
||||||
|
@ -278,11 +278,11 @@ WSLUA_METAMETHOD FrameInfoConst__tostring(lua_State* L) {
|
||||||
if (!fi) {
|
if (!fi) {
|
||||||
lua_pushstring(L,"FrameInfo pointer is NULL!");
|
lua_pushstring(L,"FrameInfo pointer is NULL!");
|
||||||
} else {
|
} else {
|
||||||
if (fi->phdr && !fi->expired)
|
if (fi->rec && !fi->expired)
|
||||||
lua_pushfstring(L, "FrameInfo: rec_type=%u, presence_flags=%d, caplen=%d, len=%d, pkt_encap=%d, opt_comment='%s'",
|
lua_pushfstring(L, "FrameInfo: rec_type=%u, presence_flags=%d, caplen=%d, len=%d, pkt_encap=%d, opt_comment='%s'",
|
||||||
fi->phdr->rec_type, fi->phdr->presence_flags, fi->phdr->caplen, fi->phdr->len, fi->phdr->pkt_encap, fi->phdr->opt_comment);
|
fi->rec->rec_type, fi->rec->presence_flags, fi->rec->rec_header.packet_header.caplen, fi->rec->rec_header.packet_header.len, fi->rec->rec_header.packet_header.pkt_encap, fi->rec->opt_comment);
|
||||||
else
|
else
|
||||||
lua_pushfstring(L, "FrameInfo has %s", fi->phdr?"expired":"null phdr pointer");
|
lua_pushfstring(L, "FrameInfo has %s", fi->rec?"expired":"null rec pointer");
|
||||||
}
|
}
|
||||||
|
|
||||||
WSLUA_RETURN(1); /* String of debug information. */
|
WSLUA_RETURN(1); /* String of debug information. */
|
||||||
|
@ -295,16 +295,16 @@ WSLUA_METHOD FrameInfoConst_write_data(lua_State* L) {
|
||||||
#define WSLUA_OPTARG_FrameInfoConst_write_data_LENGTH 3 /* The number of bytes to write to the file at the current cursor position, or all if not supplied. */
|
#define WSLUA_OPTARG_FrameInfoConst_write_data_LENGTH 3 /* The number of bytes to write to the file at the current cursor position, or all if not supplied. */
|
||||||
FrameInfoConst fi = checkFrameInfoConst(L,1);
|
FrameInfoConst fi = checkFrameInfoConst(L,1);
|
||||||
File fh = checkFile(L,WSLUA_ARG_FrameInfoConst_write_data_FILE);
|
File fh = checkFile(L,WSLUA_ARG_FrameInfoConst_write_data_FILE);
|
||||||
guint32 len = wslua_optguint32(L, WSLUA_OPTARG_FrameInfoConst_write_data_LENGTH, fi->phdr ? fi->phdr->caplen:0);
|
guint32 len = wslua_optguint32(L, WSLUA_OPTARG_FrameInfoConst_write_data_LENGTH, fi->rec ? fi->rec->rec_header.packet_header.caplen:0);
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
if (!fi->pd || !fi->phdr || !fh->wdh) {
|
if (!fi->pd || !fi->rec || !fh->wdh) {
|
||||||
luaL_error(L, "FrameInfoConst write_data() got null buffer or file pointer internally");
|
luaL_error(L, "FrameInfoConst write_data() got null buffer or file pointer internally");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len > fi->phdr->caplen)
|
if (len > fi->rec->rec_header.packet_header.caplen)
|
||||||
len = fi->phdr->caplen;
|
len = fi->rec->rec_header.packet_header.caplen;
|
||||||
|
|
||||||
if (!wtap_dump_file_write(fh->wdh, fi->pd, (size_t)(len), &err)) {
|
if (!wtap_dump_file_write(fh->wdh, fi->pd, (size_t)(len), &err)) {
|
||||||
lua_pushboolean(L, FALSE);
|
lua_pushboolean(L, FALSE);
|
||||||
|
@ -318,7 +318,7 @@ WSLUA_METHOD FrameInfoConst_write_data(lua_State* L) {
|
||||||
WSLUA_RETURN(1); /* True if succeeded, else returns false along with the error number and string error description. */
|
WSLUA_RETURN(1); /* True if succeeded, else returns false along with the error number and string error description. */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free the struct we created, but not the wtap_pkthdr it points to */
|
/* free the struct we created, but not the wtap_rec it points to */
|
||||||
static int FrameInfoConst__gc(lua_State* L) {
|
static int FrameInfoConst__gc(lua_State* L) {
|
||||||
FrameInfoConst fi = toFrameInfoConst(L,1);
|
FrameInfoConst fi = toFrameInfoConst(L,1);
|
||||||
g_free(fi);
|
g_free(fi);
|
||||||
|
@ -332,8 +332,8 @@ static int FrameInfoConst_get_time (lua_State* L) {
|
||||||
|
|
||||||
if (!nstime) return 0;
|
if (!nstime) return 0;
|
||||||
|
|
||||||
nstime->secs = fi->phdr->ts.secs;
|
nstime->secs = fi->rec->ts.secs;
|
||||||
nstime->nsecs = fi->phdr->ts.nsecs;
|
nstime->nsecs = fi->rec->ts.nsecs;
|
||||||
|
|
||||||
pushNSTime(L,nstime);
|
pushNSTime(L,nstime);
|
||||||
|
|
||||||
|
@ -344,32 +344,32 @@ static int FrameInfoConst_get_time (lua_State* L) {
|
||||||
static int FrameInfoConst_get_data (lua_State* L) {
|
static int FrameInfoConst_get_data (lua_State* L) {
|
||||||
FrameInfoConst fi = checkFrameInfoConst(L,1);
|
FrameInfoConst fi = checkFrameInfoConst(L,1);
|
||||||
|
|
||||||
if (!fi->pd || !fi->phdr) return 0;
|
if (!fi->pd || !fi->rec) return 0;
|
||||||
|
|
||||||
lua_pushlstring(L, fi->pd, fi->phdr->caplen);
|
lua_pushlstring(L, fi->pd, fi->rec->rec_header.packet_header.caplen);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* WSLUA_ATTRIBUTE FrameInfoConst_rec_type RO The record type of the packet frame - see `wtap_presence_flags` in `init.lua` for values. */
|
/* WSLUA_ATTRIBUTE FrameInfoConst_rec_type RO The record type of the packet frame - see `wtap_presence_flags` in `init.lua` for values. */
|
||||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,rec_type,phdr->rec_type);
|
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,rec_type,rec->rec_type);
|
||||||
|
|
||||||
/* WSLUA_ATTRIBUTE FrameInfoConst_flags RO The presence flags of the packet frame - see `wtap_presence_flags` in `init.lua` for bits. */
|
/* WSLUA_ATTRIBUTE FrameInfoConst_flags RO The presence flags of the packet frame - see `wtap_presence_flags` in `init.lua` for bits. */
|
||||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,flags,phdr->presence_flags);
|
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,flags,rec->presence_flags);
|
||||||
|
|
||||||
/* WSLUA_ATTRIBUTE FrameInfoConst_captured_length RO The captured packet length, and thus the length of the buffer in the FrameInfoConst.data field. */
|
/* WSLUA_ATTRIBUTE FrameInfoConst_captured_length RO The captured packet length, and thus the length of the buffer in the FrameInfoConst.data field. */
|
||||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,captured_length,phdr->caplen);
|
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,captured_length,rec->rec_header.packet_header.caplen);
|
||||||
|
|
||||||
/* WSLUA_ATTRIBUTE FrameInfoConst_original_length RO The on-the-wire packet length, which may be longer than the `captured_length`. */
|
/* WSLUA_ATTRIBUTE FrameInfoConst_original_length RO The on-the-wire packet length, which may be longer than the `captured_length`. */
|
||||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,original_length,phdr->len);
|
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,original_length,rec->rec_header.packet_header.len);
|
||||||
|
|
||||||
/* WSLUA_ATTRIBUTE FrameInfoConst_encap RO The packet encapsulation type, if the file supports per-packet types.
|
/* WSLUA_ATTRIBUTE FrameInfoConst_encap RO The packet encapsulation type, if the file supports per-packet types.
|
||||||
|
|
||||||
See `wtap_encaps` in `init.lua` for possible packet encapsulation types to use as the value for this field. */
|
See `wtap_encaps` in `init.lua` for possible packet encapsulation types to use as the value for this field. */
|
||||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,encap,phdr->pkt_encap);
|
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(FrameInfoConst,encap,rec->rec_header.packet_header.pkt_encap);
|
||||||
|
|
||||||
/* WSLUA_ATTRIBUTE FrameInfoConst_comment RO A comment for the packet; nil if there is none. */
|
/* WSLUA_ATTRIBUTE FrameInfoConst_comment RO A comment for the packet; nil if there is none. */
|
||||||
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(FrameInfoConst,comment,phdr->opt_comment);
|
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(FrameInfoConst,comment,rec->opt_comment);
|
||||||
|
|
||||||
WSLUA_ATTRIBUTES FrameInfoConst_attributes[] = {
|
WSLUA_ATTRIBUTES FrameInfoConst_attributes[] = {
|
||||||
WSLUA_ATTRIBUTE_ROREG(FrameInfoConst,rec_type),
|
WSLUA_ATTRIBUTE_ROREG(FrameInfoConst,rec_type),
|
||||||
|
|
|
@ -465,20 +465,20 @@ static gboolean extcap_dumper_dump(struct extcap_dumper extcap_dumper,
|
||||||
#else
|
#else
|
||||||
int err = 0;
|
int err = 0;
|
||||||
char *err_info;
|
char *err_info;
|
||||||
struct wtap_pkthdr hdr;
|
wtap_rec rec;
|
||||||
|
|
||||||
hdr.presence_flags = WTAP_HAS_TS;
|
rec.rec_type = REC_TYPE_PACKET;
|
||||||
hdr.caplen = (guint32) captured_length;
|
rec.presence_flags = WTAP_HAS_TS;
|
||||||
hdr.len = (guint32) reported_length;
|
rec.rec_header.packet_header.caplen = (guint32) captured_length;
|
||||||
|
rec.rec_header.packet_header.len = (guint32) reported_length;
|
||||||
|
|
||||||
hdr.ts.secs = seconds;
|
rec.ts.secs = seconds;
|
||||||
hdr.ts.nsecs = (int) nanoseconds;
|
rec.ts.nsecs = (int) nanoseconds;
|
||||||
|
|
||||||
hdr.opt_comment = 0;
|
rec.opt_comment = 0;
|
||||||
hdr.opt_comment = NULL;
|
rec.opt_comment = NULL;
|
||||||
hdr.drop_count = 0;
|
rec.rec_header.packet_header.drop_count = 0;
|
||||||
hdr.pack_flags = 0;
|
rec.rec_header.packet_header.pack_flags = 0;
|
||||||
hdr.rec_type = REC_TYPE_PACKET;
|
|
||||||
|
|
||||||
/* NOTE: Try to handle pseudoheaders manually */
|
/* NOTE: Try to handle pseudoheaders manually */
|
||||||
if (extcap_dumper.encap == EXTCAP_ENCAP_BLUETOOTH_H4_WITH_PHDR) {
|
if (extcap_dumper.encap == EXTCAP_ENCAP_BLUETOOTH_H4_WITH_PHDR) {
|
||||||
|
@ -486,22 +486,22 @@ static gboolean extcap_dumper_dump(struct extcap_dumper extcap_dumper,
|
||||||
|
|
||||||
SET_DATA(direction, value_u32, buffer)
|
SET_DATA(direction, value_u32, buffer)
|
||||||
|
|
||||||
hdr.pseudo_header.bthci.sent = GINT32_FROM_BE(*direction) ? 0 : 1;
|
rec.rec_header.packet_header.pseudo_header.bthci.sent = GINT32_FROM_BE(*direction) ? 0 : 1;
|
||||||
|
|
||||||
hdr.len -= (guint32)sizeof(own_pcap_bluetooth_h4_header);
|
rec.rec_header.packet_header.len -= (guint32)sizeof(own_pcap_bluetooth_h4_header);
|
||||||
hdr.caplen -= (guint32)sizeof(own_pcap_bluetooth_h4_header);
|
rec.rec_header.packet_header.caplen -= (guint32)sizeof(own_pcap_bluetooth_h4_header);
|
||||||
|
|
||||||
buffer += sizeof(own_pcap_bluetooth_h4_header);
|
buffer += sizeof(own_pcap_bluetooth_h4_header);
|
||||||
hdr.pkt_encap = WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR;
|
rec.rec_header.packet_header.pkt_encap = WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR;
|
||||||
}
|
}
|
||||||
else if (extcap_dumper.encap == EXTCAP_ENCAP_ETHERNET) {
|
else if (extcap_dumper.encap == EXTCAP_ENCAP_ETHERNET) {
|
||||||
hdr.pkt_encap = WTAP_ENCAP_ETHERNET;
|
rec.rec_header.packet_header.pkt_encap = WTAP_ENCAP_ETHERNET;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
hdr.pkt_encap = WTAP_ENCAP_WIRESHARK_UPPER_PDU;
|
rec.rec_header.packet_header.pkt_encap = WTAP_ENCAP_WIRESHARK_UPPER_PDU;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wtap_dump(extcap_dumper.dumper.wtap, &hdr, (const guint8 *) buffer, &err, &err_info)) {
|
if (!wtap_dump(extcap_dumper.dumper.wtap, &rec, (const guint8 *) buffer, &err, &err_info)) {
|
||||||
cfile_write_failure_message("androiddump", NULL, fifo, err, err_info,
|
cfile_write_failure_message("androiddump", NULL, fifo, err, err_info,
|
||||||
0, WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC);
|
0, WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
229
file.c
229
file.c
|
@ -75,8 +75,8 @@
|
||||||
gboolean auto_scroll_live; /* GTK+ only? */
|
gboolean auto_scroll_live; /* GTK+ only? */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int read_packet(capture_file *cf, dfilter_t *dfcode, epan_dissect_t *edt,
|
static gboolean read_record(capture_file *cf, dfilter_t *dfcode,
|
||||||
column_info *cinfo, gint64 offset);
|
epan_dissect_t *edt, column_info *cinfo, gint64 offset);
|
||||||
|
|
||||||
static void rescan_packets(capture_file *cf, const char *action, const char *action_item, gboolean redissect);
|
static void rescan_packets(capture_file *cf, const char *action, const char *action_item, gboolean redissect);
|
||||||
|
|
||||||
|
@ -266,8 +266,8 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
|
||||||
and fill in the information for this file. */
|
and fill in the information for this file. */
|
||||||
cf_close(cf);
|
cf_close(cf);
|
||||||
|
|
||||||
/* Initialize the packet header. */
|
/* Initialize the record metadata. */
|
||||||
wtap_phdr_init(&cf->phdr);
|
wtap_rec_init(&cf->rec);
|
||||||
|
|
||||||
/* XXX - we really want to initialize this after we've read all
|
/* XXX - we really want to initialize this after we've read all
|
||||||
the packets, so we know how much we'll ultimately need. */
|
the packets, so we know how much we'll ultimately need. */
|
||||||
|
@ -387,8 +387,8 @@ cf_close(capture_file *cf)
|
||||||
/* no open_routine type */
|
/* no open_routine type */
|
||||||
cf->open_type = WTAP_TYPE_AUTO;
|
cf->open_type = WTAP_TYPE_AUTO;
|
||||||
|
|
||||||
/* Clean up the packet header. */
|
/* Clean up the record metadata. */
|
||||||
wtap_phdr_cleanup(&cf->phdr);
|
wtap_rec_cleanup(&cf->rec);
|
||||||
|
|
||||||
/* Free up the packet buffer. */
|
/* Free up the packet buffer. */
|
||||||
ws_buffer_free(&cf->buf);
|
ws_buffer_free(&cf->buf);
|
||||||
|
@ -621,7 +621,7 @@ cf_read(capture_file *cf, gboolean reloading)
|
||||||
hours even on fast machines) just to see that it was the wrong file. */
|
hours even on fast machines) just to see that it was the wrong file. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
read_packet(cf, dfcode, &edt, cinfo, data_offset);
|
read_record(cf, dfcode, &edt, cinfo, data_offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CATCH(OutOfMemoryError) {
|
CATCH(OutOfMemoryError) {
|
||||||
|
@ -782,7 +782,7 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
|
||||||
aren't any packets left to read) exit. */
|
aren't any packets left to read) exit. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (read_packet(cf, dfcode, &edt, (column_info *) cinfo, data_offset) != -1) {
|
if (read_record(cf, dfcode, &edt, (column_info *) cinfo, data_offset)) {
|
||||||
newly_displayed_packets++;
|
newly_displayed_packets++;
|
||||||
}
|
}
|
||||||
to_read--;
|
to_read--;
|
||||||
|
@ -916,7 +916,7 @@ cf_finish_tail(capture_file *cf, int *err)
|
||||||
aren't any packets left to read) exit. */
|
aren't any packets left to read) exit. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
read_packet(cf, dfcode, &edt, cinfo, data_offset);
|
read_record(cf, dfcode, &edt, cinfo, data_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cleanup and release all dfilter resources */
|
/* Cleanup and release all dfilter resources */
|
||||||
|
@ -1072,13 +1072,11 @@ void cf_set_rfcode(capture_file *cf, dfilter_t *rfcode)
|
||||||
cf->rfcode = rfcode;
|
cf->rfcode = rfcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
|
add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
|
||||||
epan_dissect_t *edt, dfilter_t *dfcode, column_info *cinfo,
|
epan_dissect_t *edt, dfilter_t *dfcode, column_info *cinfo,
|
||||||
struct wtap_pkthdr *phdr, const guint8 *buf, gboolean add_to_packet_list)
|
wtap_rec *rec, const guint8 *buf, gboolean add_to_packet_list)
|
||||||
{
|
{
|
||||||
gint row = -1;
|
|
||||||
|
|
||||||
frame_data_set_before_dissect(fdata, &cf->elapsed_time,
|
frame_data_set_before_dissect(fdata, &cf->elapsed_time,
|
||||||
&cf->provider.ref, cf->provider.prev_dis);
|
&cf->provider.ref, cf->provider.prev_dis);
|
||||||
cf->provider.prev_cap = fdata;
|
cf->provider.prev_cap = fdata;
|
||||||
|
@ -1103,7 +1101,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dissect the frame. */
|
/* Dissect the frame. */
|
||||||
epan_dissect_run_with_taps(edt, cf->cd_t, phdr,
|
epan_dissect_run_with_taps(edt, cf->cd_t, rec,
|
||||||
frame_tvbuff_new(&cf->provider, fdata, buf),
|
frame_tvbuff_new(&cf->provider, fdata, buf),
|
||||||
fdata, cinfo);
|
fdata, cinfo);
|
||||||
|
|
||||||
|
@ -1126,7 +1124,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
|
||||||
|
|
||||||
if (add_to_packet_list) {
|
if (add_to_packet_list) {
|
||||||
/* We fill the needed columns from new_packet_list */
|
/* We fill the needed columns from new_packet_list */
|
||||||
row = packet_list_append(cinfo, fdata);
|
packet_list_append(cinfo, fdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fdata->flags.passed_dfilter || fdata->flags.ref_time)
|
if (fdata->flags.passed_dfilter || fdata->flags.ref_time)
|
||||||
|
@ -1143,22 +1141,23 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf,
|
||||||
}
|
}
|
||||||
|
|
||||||
epan_dissect_reset(edt);
|
epan_dissect_reset(edt);
|
||||||
return row;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read in a new packet */
|
/*
|
||||||
/* returns the row of the new packet in the packet list or -1 if not displayed */
|
* Read in a new record.
|
||||||
static int
|
* Returns TRUE if the packet was added to the packet (record) list,
|
||||||
read_packet(capture_file *cf, dfilter_t *dfcode, epan_dissect_t *edt,
|
* FALSE otherwise.
|
||||||
|
*/
|
||||||
|
static gboolean
|
||||||
|
read_record(capture_file *cf, dfilter_t *dfcode, epan_dissect_t *edt,
|
||||||
column_info *cinfo, gint64 offset)
|
column_info *cinfo, gint64 offset)
|
||||||
{
|
{
|
||||||
struct wtap_pkthdr *phdr = wtap_phdr(cf->provider.wth);
|
wtap_rec *rec = wtap_get_rec(cf->provider.wth);
|
||||||
const guint8 *buf = wtap_buf_ptr(cf->provider.wth);
|
const guint8 *buf = wtap_get_buf_ptr(cf->provider.wth);
|
||||||
frame_data fdlocal;
|
frame_data fdlocal;
|
||||||
guint32 framenum;
|
|
||||||
frame_data *fdata;
|
frame_data *fdata;
|
||||||
gboolean passed = TRUE;
|
gboolean passed = TRUE;
|
||||||
int row = -1;
|
gboolean added = FALSE;
|
||||||
|
|
||||||
/* Add this packet's link-layer encapsulation type to cf->linktypes, if
|
/* Add this packet's link-layer encapsulation type to cf->linktypes, if
|
||||||
it's not already there.
|
it's not already there.
|
||||||
|
@ -1166,20 +1165,20 @@ read_packet(capture_file *cf, dfilter_t *dfcode, epan_dissect_t *edt,
|
||||||
link-layer encapsulation type, it'd be O(N^2) to read the file, but
|
link-layer encapsulation type, it'd be O(N^2) to read the file, but
|
||||||
there are probably going to be a small number of encapsulation types
|
there are probably going to be a small number of encapsulation types
|
||||||
in a file. */
|
in a file. */
|
||||||
cf_add_encapsulation_type(cf, phdr->pkt_encap);
|
if (rec->rec_type == REC_TYPE_PACKET) {
|
||||||
|
cf_add_encapsulation_type(cf, rec->rec_header.packet_header.pkt_encap);
|
||||||
|
}
|
||||||
|
|
||||||
/* The frame number of this packet is one more than the count of
|
/* The frame number of this packet, if we add it to the set of frames,
|
||||||
frames in the file so far. */
|
would be one more than the count of frames in the file so far. */
|
||||||
framenum = cf->count + 1;
|
frame_data_init(&fdlocal, cf->count + 1, rec, offset, cf->cum_bytes);
|
||||||
|
|
||||||
frame_data_init(&fdlocal, framenum, phdr, offset, cf->cum_bytes);
|
|
||||||
|
|
||||||
if (cf->rfcode) {
|
if (cf->rfcode) {
|
||||||
epan_dissect_t rf_edt;
|
epan_dissect_t rf_edt;
|
||||||
|
|
||||||
epan_dissect_init(&rf_edt, cf->epan, TRUE, FALSE);
|
epan_dissect_init(&rf_edt, cf->epan, TRUE, FALSE);
|
||||||
epan_dissect_prime_with_dfilter(&rf_edt, cf->rfcode);
|
epan_dissect_prime_with_dfilter(&rf_edt, cf->rfcode);
|
||||||
epan_dissect_run(&rf_edt, cf->cd_t, phdr,
|
epan_dissect_run(&rf_edt, cf->cd_t, rec,
|
||||||
frame_tvbuff_new(&cf->provider, &fdlocal, buf),
|
frame_tvbuff_new(&cf->provider, &fdlocal, buf),
|
||||||
&fdlocal, NULL);
|
&fdlocal, NULL);
|
||||||
passed = dfilter_apply_edt(cf->rfcode, &rf_edt);
|
passed = dfilter_apply_edt(cf->rfcode, &rf_edt);
|
||||||
|
@ -1187,21 +1186,23 @@ read_packet(capture_file *cf, dfilter_t *dfcode, epan_dissect_t *edt,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (passed) {
|
if (passed) {
|
||||||
|
added = TRUE;
|
||||||
|
|
||||||
/* This does a shallow copy of fdlocal, which is good enough. */
|
/* This does a shallow copy of fdlocal, which is good enough. */
|
||||||
fdata = frame_data_sequence_add(cf->provider.frames, &fdlocal);
|
fdata = frame_data_sequence_add(cf->provider.frames, &fdlocal);
|
||||||
|
|
||||||
cf->count++;
|
cf->count++;
|
||||||
if (phdr->opt_comment != NULL)
|
if (rec->opt_comment != NULL)
|
||||||
cf->packet_comment_count++;
|
cf->packet_comment_count++;
|
||||||
cf->f_datalen = offset + fdlocal.cap_len;
|
cf->f_datalen = offset + fdlocal.cap_len;
|
||||||
|
|
||||||
if (!cf->redissecting) {
|
if (!cf->redissecting) {
|
||||||
row = add_packet_to_packet_list(fdata, cf, edt, dfcode,
|
add_packet_to_packet_list(fdata, cf, edt, dfcode,
|
||||||
cinfo, phdr, buf, TRUE);
|
cinfo, rec, buf, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return row;
|
return added;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1469,12 +1470,12 @@ cf_redissect_packets(capture_file *cf)
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
cf_read_record_r(capture_file *cf, const frame_data *fdata,
|
cf_read_record_r(capture_file *cf, const frame_data *fdata,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf)
|
wtap_rec *rec, Buffer *buf)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
gchar *err_info;
|
gchar *err_info;
|
||||||
|
|
||||||
if (!wtap_seek_read(cf->provider.wth, fdata->file_off, phdr, buf, &err, &err_info)) {
|
if (!wtap_seek_read(cf->provider.wth, fdata->file_off, rec, buf, &err, &err_info)) {
|
||||||
cfile_read_failure_alert_box(cf->filename, err, err_info);
|
cfile_read_failure_alert_box(cf->filename, err, err_info);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1484,7 +1485,7 @@ cf_read_record_r(capture_file *cf, const frame_data *fdata,
|
||||||
gboolean
|
gboolean
|
||||||
cf_read_record(capture_file *cf, frame_data *fdata)
|
cf_read_record(capture_file *cf, frame_data *fdata)
|
||||||
{
|
{
|
||||||
return cf_read_record_r(cf, fdata, &cf->phdr, &cf->buf);
|
return cf_read_record_r(cf, fdata, &cf->rec, &cf->buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Rescan the list of packets, reconstructing the CList.
|
/* Rescan the list of packets, reconstructing the CList.
|
||||||
|
@ -1720,7 +1721,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
|
||||||
}
|
}
|
||||||
|
|
||||||
add_packet_to_packet_list(fdata, cf, &edt, dfcode,
|
add_packet_to_packet_list(fdata, cf, &edt, dfcode,
|
||||||
cinfo, &cf->phdr,
|
cinfo, &cf->rec,
|
||||||
ws_buffer_start_ptr(&cf->buf),
|
ws_buffer_start_ptr(&cf->buf),
|
||||||
add_to_packet_list);
|
add_to_packet_list);
|
||||||
|
|
||||||
|
@ -1939,7 +1940,7 @@ static psp_return_t
|
||||||
process_specified_records(capture_file *cf, packet_range_t *range,
|
process_specified_records(capture_file *cf, packet_range_t *range,
|
||||||
const char *string1, const char *string2, gboolean terminate_is_stop,
|
const char *string1, const char *string2, gboolean terminate_is_stop,
|
||||||
gboolean (*callback)(capture_file *, frame_data *,
|
gboolean (*callback)(capture_file *, frame_data *,
|
||||||
struct wtap_pkthdr *, const guint8 *, void *),
|
wtap_rec *, const guint8 *, void *),
|
||||||
void *callback_args,
|
void *callback_args,
|
||||||
gboolean show_progress_bar)
|
gboolean show_progress_bar)
|
||||||
{
|
{
|
||||||
|
@ -1955,9 +1956,9 @@ process_specified_records(capture_file *cf, packet_range_t *range,
|
||||||
GTimeVal progbar_start_time;
|
GTimeVal progbar_start_time;
|
||||||
gchar progbar_status_str[100];
|
gchar progbar_status_str[100];
|
||||||
range_process_e process_this;
|
range_process_e process_this;
|
||||||
struct wtap_pkthdr phdr;
|
wtap_rec rec;
|
||||||
|
|
||||||
wtap_phdr_init(&phdr);
|
wtap_rec_init(&rec);
|
||||||
ws_buffer_init(&buf, 1500);
|
ws_buffer_init(&buf, 1500);
|
||||||
|
|
||||||
g_timer_start(prog_timer);
|
g_timer_start(prog_timer);
|
||||||
|
@ -2032,13 +2033,13 @@ process_specified_records(capture_file *cf, packet_range_t *range,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the packet */
|
/* Get the packet */
|
||||||
if (!cf_read_record_r(cf, fdata, &phdr, &buf)) {
|
if (!cf_read_record_r(cf, fdata, &rec, &buf)) {
|
||||||
/* Attempt to get the packet failed. */
|
/* Attempt to get the packet failed. */
|
||||||
ret = PSP_FAILED;
|
ret = PSP_FAILED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Process the packet */
|
/* Process the packet */
|
||||||
if (!callback(cf, fdata, &phdr, ws_buffer_start_ptr(&buf), callback_args)) {
|
if (!callback(cf, fdata, &rec, ws_buffer_start_ptr(&buf), callback_args)) {
|
||||||
/* Callback failed. We assume it reported the error appropriately. */
|
/* Callback failed. We assume it reported the error appropriately. */
|
||||||
ret = PSP_FAILED;
|
ret = PSP_FAILED;
|
||||||
break;
|
break;
|
||||||
|
@ -2051,7 +2052,7 @@ process_specified_records(capture_file *cf, packet_range_t *range,
|
||||||
destroy_progress_dlg(progbar);
|
destroy_progress_dlg(progbar);
|
||||||
g_timer_destroy(prog_timer);
|
g_timer_destroy(prog_timer);
|
||||||
|
|
||||||
wtap_phdr_cleanup(&phdr);
|
wtap_rec_cleanup(&rec);
|
||||||
ws_buffer_free(&buf);
|
ws_buffer_free(&buf);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2063,13 +2064,12 @@ typedef struct {
|
||||||
} retap_callback_args_t;
|
} retap_callback_args_t;
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
retap_packet(capture_file *cf, frame_data *fdata,
|
retap_packet(capture_file *cf, frame_data *fdata, wtap_rec *rec,
|
||||||
struct wtap_pkthdr *phdr, const guint8 *pd,
|
const guint8 *pd, void *argsp)
|
||||||
void *argsp)
|
|
||||||
{
|
{
|
||||||
retap_callback_args_t *args = (retap_callback_args_t *)argsp;
|
retap_callback_args_t *args = (retap_callback_args_t *)argsp;
|
||||||
|
|
||||||
epan_dissect_run_with_taps(&args->edt, cf->cd_t, phdr,
|
epan_dissect_run_with_taps(&args->edt, cf->cd_t, rec,
|
||||||
frame_tvbuff_new(&cf->provider, fdata, pd),
|
frame_tvbuff_new(&cf->provider, fdata, pd),
|
||||||
fdata, args->cinfo);
|
fdata, args->cinfo);
|
||||||
epan_dissect_reset(&args->edt);
|
epan_dissect_reset(&args->edt);
|
||||||
|
@ -2163,9 +2163,8 @@ typedef struct {
|
||||||
} print_callback_args_t;
|
} print_callback_args_t;
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
print_packet(capture_file *cf, frame_data *fdata,
|
print_packet(capture_file *cf, frame_data *fdata, wtap_rec *rec,
|
||||||
struct wtap_pkthdr *phdr, const guint8 *pd,
|
const guint8 *pd, void *argsp)
|
||||||
void *argsp)
|
|
||||||
{
|
{
|
||||||
print_callback_args_t *args = (print_callback_args_t *)argsp;
|
print_callback_args_t *args = (print_callback_args_t *)argsp;
|
||||||
int i;
|
int i;
|
||||||
|
@ -2181,12 +2180,12 @@ print_packet(capture_file *cf, frame_data *fdata,
|
||||||
information. */
|
information. */
|
||||||
if (args->print_args->print_summary) {
|
if (args->print_args->print_summary) {
|
||||||
col_custom_prime_edt(&args->edt, &cf->cinfo);
|
col_custom_prime_edt(&args->edt, &cf->cinfo);
|
||||||
epan_dissect_run(&args->edt, cf->cd_t, phdr,
|
epan_dissect_run(&args->edt, cf->cd_t, rec,
|
||||||
frame_tvbuff_new(&cf->provider, fdata, pd),
|
frame_tvbuff_new(&cf->provider, fdata, pd),
|
||||||
fdata, &cf->cinfo);
|
fdata, &cf->cinfo);
|
||||||
epan_dissect_fill_in_columns(&args->edt, FALSE, TRUE);
|
epan_dissect_fill_in_columns(&args->edt, FALSE, TRUE);
|
||||||
} else
|
} else
|
||||||
epan_dissect_run(&args->edt, cf->cd_t, phdr,
|
epan_dissect_run(&args->edt, cf->cd_t, rec,
|
||||||
frame_tvbuff_new(&cf->provider, fdata, pd), fdata, NULL);
|
frame_tvbuff_new(&cf->provider, fdata, pd), fdata, NULL);
|
||||||
|
|
||||||
if (args->print_formfeed) {
|
if (args->print_formfeed) {
|
||||||
|
@ -2502,14 +2501,13 @@ typedef struct {
|
||||||
} write_packet_callback_args_t;
|
} write_packet_callback_args_t;
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
write_pdml_packet(capture_file *cf, frame_data *fdata,
|
write_pdml_packet(capture_file *cf, frame_data *fdata, wtap_rec *rec,
|
||||||
struct wtap_pkthdr *phdr, const guint8 *pd,
|
const guint8 *pd, void *argsp)
|
||||||
void *argsp)
|
|
||||||
{
|
{
|
||||||
write_packet_callback_args_t *args = (write_packet_callback_args_t *)argsp;
|
write_packet_callback_args_t *args = (write_packet_callback_args_t *)argsp;
|
||||||
|
|
||||||
/* Create the protocol tree, but don't fill in the column information. */
|
/* Create the protocol tree, but don't fill in the column information. */
|
||||||
epan_dissect_run(&args->edt, cf->cd_t, phdr,
|
epan_dissect_run(&args->edt, cf->cd_t, rec,
|
||||||
frame_tvbuff_new(&cf->provider, fdata, pd), fdata, NULL);
|
frame_tvbuff_new(&cf->provider, fdata, pd), fdata, NULL);
|
||||||
|
|
||||||
/* Write out the information in that tree. */
|
/* Write out the information in that tree. */
|
||||||
|
@ -2578,15 +2576,14 @@ cf_write_pdml_packets(capture_file *cf, print_args_t *print_args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
write_psml_packet(capture_file *cf, frame_data *fdata,
|
write_psml_packet(capture_file *cf, frame_data *fdata, wtap_rec *rec,
|
||||||
struct wtap_pkthdr *phdr, const guint8 *pd,
|
const guint8 *pd, void *argsp)
|
||||||
void *argsp)
|
|
||||||
{
|
{
|
||||||
write_packet_callback_args_t *args = (write_packet_callback_args_t *)argsp;
|
write_packet_callback_args_t *args = (write_packet_callback_args_t *)argsp;
|
||||||
|
|
||||||
/* Fill in the column information */
|
/* Fill in the column information */
|
||||||
col_custom_prime_edt(&args->edt, &cf->cinfo);
|
col_custom_prime_edt(&args->edt, &cf->cinfo);
|
||||||
epan_dissect_run(&args->edt, cf->cd_t, phdr,
|
epan_dissect_run(&args->edt, cf->cd_t, rec,
|
||||||
frame_tvbuff_new(&cf->provider, fdata, pd),
|
frame_tvbuff_new(&cf->provider, fdata, pd),
|
||||||
fdata, &cf->cinfo);
|
fdata, &cf->cinfo);
|
||||||
epan_dissect_fill_in_columns(&args->edt, FALSE, TRUE);
|
epan_dissect_fill_in_columns(&args->edt, FALSE, TRUE);
|
||||||
|
@ -2663,15 +2660,14 @@ cf_write_psml_packets(capture_file *cf, print_args_t *print_args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
write_csv_packet(capture_file *cf, frame_data *fdata,
|
write_csv_packet(capture_file *cf, frame_data *fdata, wtap_rec *rec,
|
||||||
struct wtap_pkthdr *phdr, const guint8 *pd,
|
const guint8 *pd, void *argsp)
|
||||||
void *argsp)
|
|
||||||
{
|
{
|
||||||
write_packet_callback_args_t *args = (write_packet_callback_args_t *)argsp;
|
write_packet_callback_args_t *args = (write_packet_callback_args_t *)argsp;
|
||||||
|
|
||||||
/* Fill in the column information */
|
/* Fill in the column information */
|
||||||
col_custom_prime_edt(&args->edt, &cf->cinfo);
|
col_custom_prime_edt(&args->edt, &cf->cinfo);
|
||||||
epan_dissect_run(&args->edt, cf->cd_t, phdr,
|
epan_dissect_run(&args->edt, cf->cd_t, rec,
|
||||||
frame_tvbuff_new(&cf->provider, fdata, pd),
|
frame_tvbuff_new(&cf->provider, fdata, pd),
|
||||||
fdata, &cf->cinfo);
|
fdata, &cf->cinfo);
|
||||||
epan_dissect_fill_in_columns(&args->edt, FALSE, TRUE);
|
epan_dissect_fill_in_columns(&args->edt, FALSE, TRUE);
|
||||||
|
@ -2740,13 +2736,12 @@ cf_write_csv_packets(capture_file *cf, print_args_t *print_args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
carrays_write_packet(capture_file *cf, frame_data *fdata,
|
carrays_write_packet(capture_file *cf, frame_data *fdata, wtap_rec *rec,
|
||||||
struct wtap_pkthdr *phdr,
|
const guint8 *pd, void *argsp)
|
||||||
const guint8 *pd, void *argsp)
|
|
||||||
{
|
{
|
||||||
write_packet_callback_args_t *args = (write_packet_callback_args_t *)argsp;
|
write_packet_callback_args_t *args = (write_packet_callback_args_t *)argsp;
|
||||||
|
|
||||||
epan_dissect_run(&args->edt, cf->cd_t, phdr,
|
epan_dissect_run(&args->edt, cf->cd_t, rec,
|
||||||
frame_tvbuff_new(&cf->provider, fdata, pd), fdata, NULL);
|
frame_tvbuff_new(&cf->provider, fdata, pd), fdata, NULL);
|
||||||
write_carrays_hex_data(fdata->num, args->fh, &args->edt);
|
write_carrays_hex_data(fdata->num, args->fh, &args->edt);
|
||||||
epan_dissect_reset(&args->edt);
|
epan_dissect_reset(&args->edt);
|
||||||
|
@ -2802,14 +2797,13 @@ cf_write_carrays_packets(capture_file *cf, print_args_t *print_args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
write_json_packet(capture_file *cf, frame_data *fdata,
|
write_json_packet(capture_file *cf, frame_data *fdata, wtap_rec *rec,
|
||||||
struct wtap_pkthdr *phdr, const guint8 *pd,
|
const guint8 *pd, void *argsp)
|
||||||
void *argsp)
|
|
||||||
{
|
{
|
||||||
write_packet_callback_args_t *args = (write_packet_callback_args_t *)argsp;
|
write_packet_callback_args_t *args = (write_packet_callback_args_t *)argsp;
|
||||||
|
|
||||||
/* Create the protocol tree, but don't fill in the column information. */
|
/* Create the protocol tree, but don't fill in the column information. */
|
||||||
epan_dissect_run(&args->edt, cf->cd_t, phdr,
|
epan_dissect_run(&args->edt, cf->cd_t, rec,
|
||||||
frame_tvbuff_new(&cf->provider, fdata, pd), fdata, NULL);
|
frame_tvbuff_new(&cf->provider, fdata, pd), fdata, NULL);
|
||||||
|
|
||||||
/* Write out the information in that tree. */
|
/* Write out the information in that tree. */
|
||||||
|
@ -2917,7 +2911,7 @@ match_protocol_tree(capture_file *cf, frame_data *fdata, void *criterion)
|
||||||
/* Construct the protocol tree, including the displayed text */
|
/* Construct the protocol tree, including the displayed text */
|
||||||
epan_dissect_init(&edt, cf->epan, TRUE, TRUE);
|
epan_dissect_init(&edt, cf->epan, TRUE, TRUE);
|
||||||
/* We don't need the column information */
|
/* We don't need the column information */
|
||||||
epan_dissect_run(&edt, cf->cd_t, &cf->phdr,
|
epan_dissect_run(&edt, cf->cd_t, &cf->rec,
|
||||||
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
|
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
|
||||||
fdata, NULL);
|
fdata, NULL);
|
||||||
|
|
||||||
|
@ -3031,7 +3025,7 @@ match_summary_line(capture_file *cf, frame_data *fdata, void *criterion)
|
||||||
/* Don't bother constructing the protocol tree */
|
/* Don't bother constructing the protocol tree */
|
||||||
epan_dissect_init(&edt, cf->epan, FALSE, FALSE);
|
epan_dissect_init(&edt, cf->epan, FALSE, FALSE);
|
||||||
/* Get the column information */
|
/* Get the column information */
|
||||||
epan_dissect_run(&edt, cf->cd_t, &cf->phdr,
|
epan_dissect_run(&edt, cf->cd_t, &cf->rec,
|
||||||
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
|
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
|
||||||
fdata, &cf->cinfo);
|
fdata, &cf->cinfo);
|
||||||
|
|
||||||
|
@ -3378,7 +3372,7 @@ match_dfilter(capture_file *cf, frame_data *fdata, void *criterion)
|
||||||
|
|
||||||
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
||||||
epan_dissect_prime_with_dfilter(&edt, sfcode);
|
epan_dissect_prime_with_dfilter(&edt, sfcode);
|
||||||
epan_dissect_run(&edt, cf->cd_t, &cf->phdr,
|
epan_dissect_run(&edt, cf->cd_t, &cf->rec,
|
||||||
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
|
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
|
||||||
fdata, NULL);
|
fdata, NULL);
|
||||||
result = dfilter_apply_edt(sfcode, &edt) ? MR_MATCHED : MR_NOTMATCHED;
|
result = dfilter_apply_edt(sfcode, &edt) ? MR_MATCHED : MR_NOTMATCHED;
|
||||||
|
@ -3666,7 +3660,7 @@ cf_select_packet(capture_file *cf, int row)
|
||||||
cf->edt = epan_dissect_new(cf->epan, TRUE, TRUE);
|
cf->edt = epan_dissect_new(cf->epan, TRUE, TRUE);
|
||||||
|
|
||||||
tap_build_interesting(cf->edt);
|
tap_build_interesting(cf->edt);
|
||||||
epan_dissect_run(cf->edt, cf->cd_t, &cf->phdr,
|
epan_dissect_run(cf->edt, cf->cd_t, &cf->rec,
|
||||||
frame_tvbuff_new_buffer(&cf->provider, cf->current_frame, &cf->buf),
|
frame_tvbuff_new_buffer(&cf->provider, cf->current_frame, &cf->buf),
|
||||||
cf->current_frame, NULL);
|
cf->current_frame, NULL);
|
||||||
|
|
||||||
|
@ -3830,17 +3824,17 @@ cf_get_packet_comment(capture_file *cf, const frame_data *fd)
|
||||||
|
|
||||||
/* fetch phdr comment */
|
/* fetch phdr comment */
|
||||||
if (fd->flags.has_phdr_comment) {
|
if (fd->flags.has_phdr_comment) {
|
||||||
struct wtap_pkthdr phdr; /* Packet header */
|
wtap_rec rec; /* Record metadata */
|
||||||
Buffer buf; /* Packet data */
|
Buffer buf; /* Record data */
|
||||||
|
|
||||||
wtap_phdr_init(&phdr);
|
wtap_rec_init(&rec);
|
||||||
ws_buffer_init(&buf, 1500);
|
ws_buffer_init(&buf, 1500);
|
||||||
|
|
||||||
if (!cf_read_record_r(cf, fd, &phdr, &buf))
|
if (!cf_read_record_r(cf, fd, &rec, &buf))
|
||||||
{ /* XXX, what we can do here? */ }
|
{ /* XXX, what we can do here? */ }
|
||||||
|
|
||||||
comment = phdr.opt_comment;
|
comment = rec.opt_comment;
|
||||||
wtap_phdr_cleanup(&phdr);
|
wtap_rec_cleanup(&rec);
|
||||||
ws_buffer_free(&buf);
|
ws_buffer_free(&buf);
|
||||||
return comment;
|
return comment;
|
||||||
}
|
}
|
||||||
|
@ -3924,67 +3918,36 @@ typedef struct {
|
||||||
* up a message box for the failure.
|
* up a message box for the failure.
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
save_record(capture_file *cf, frame_data *fdata,
|
save_record(capture_file *cf, frame_data *fdata, wtap_rec *rec,
|
||||||
struct wtap_pkthdr *phdr, const guint8 *pd,
|
const guint8 *pd, void *argsp)
|
||||||
void *argsp)
|
|
||||||
{
|
{
|
||||||
save_callback_args_t *args = (save_callback_args_t *)argsp;
|
save_callback_args_t *args = (save_callback_args_t *)argsp;
|
||||||
struct wtap_pkthdr hdr;
|
wtap_rec new_rec;
|
||||||
int err;
|
int err;
|
||||||
gchar *err_info;
|
gchar *err_info;
|
||||||
const char *pkt_comment;
|
const char *pkt_comment;
|
||||||
|
|
||||||
|
/* Copy the record information from what was read in from the file. */
|
||||||
|
new_rec = *rec;
|
||||||
|
|
||||||
|
/* Make changes based on anything that the user has done but that
|
||||||
|
hasn't been saved yet. */
|
||||||
if (fdata->flags.has_user_comment)
|
if (fdata->flags.has_user_comment)
|
||||||
pkt_comment = cap_file_provider_get_user_comment(&cf->provider, fdata);
|
pkt_comment = cap_file_provider_get_user_comment(&cf->provider, fdata);
|
||||||
else
|
else
|
||||||
pkt_comment = phdr->opt_comment;
|
pkt_comment = rec->opt_comment;
|
||||||
|
new_rec.opt_comment = g_strdup(pkt_comment);
|
||||||
|
new_rec.has_comment_changed = fdata->flags.has_user_comment ? TRUE : FALSE;
|
||||||
|
/* XXX - what if times have been shifted? */
|
||||||
|
|
||||||
/* init the wtap header for saving */
|
|
||||||
/* TODO: reuse phdr */
|
|
||||||
/* XXX - these are the only flags that correspond to data that we have
|
|
||||||
in the frame_data structure and that matter on a per-packet basis.
|
|
||||||
|
|
||||||
For WTAP_HAS_CAP_LEN, either the file format has separate "captured"
|
|
||||||
and "on the wire" lengths, or it doesn't.
|
|
||||||
|
|
||||||
For WTAP_HAS_DROP_COUNT, Wiretap doesn't actually supply the value
|
|
||||||
to its callers.
|
|
||||||
|
|
||||||
For WTAP_HAS_PACK_FLAGS, we currently don't save the FCS length
|
|
||||||
from the packet flags. */
|
|
||||||
hdr.rec_type = phdr->rec_type;
|
|
||||||
hdr.presence_flags = 0;
|
|
||||||
if (fdata->flags.has_ts)
|
|
||||||
hdr.presence_flags |= WTAP_HAS_TS;
|
|
||||||
if (phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
|
|
||||||
hdr.presence_flags |= WTAP_HAS_INTERFACE_ID;
|
|
||||||
if (phdr->presence_flags & WTAP_HAS_PACK_FLAGS)
|
|
||||||
hdr.presence_flags |= WTAP_HAS_PACK_FLAGS;
|
|
||||||
hdr.ts = phdr->ts;
|
|
||||||
hdr.caplen = phdr->caplen;
|
|
||||||
hdr.len = phdr->len;
|
|
||||||
hdr.pkt_encap = phdr->pkt_encap;
|
|
||||||
/* pcapng */
|
|
||||||
hdr.interface_id = phdr->interface_id; /* identifier of the interface. */
|
|
||||||
/* options */
|
|
||||||
hdr.pack_flags = phdr->pack_flags;
|
|
||||||
hdr.opt_comment = g_strdup(pkt_comment);
|
|
||||||
hdr.has_comment_changed = fdata->flags.has_user_comment ? TRUE : FALSE;
|
|
||||||
|
|
||||||
/* pseudo */
|
|
||||||
hdr.pseudo_header = phdr->pseudo_header;
|
|
||||||
#if 0
|
|
||||||
hdr.drop_count =
|
|
||||||
hdr.pack_flags = /* XXX - 0 for now (any value for "we don't have it"?) */
|
|
||||||
#endif
|
|
||||||
/* and save the packet */
|
/* and save the packet */
|
||||||
if (!wtap_dump(args->pdh, &hdr, pd, &err, &err_info)) {
|
if (!wtap_dump(args->pdh, &new_rec, pd, &err, &err_info)) {
|
||||||
cfile_write_failure_alert_box(NULL, args->fname, err, err_info, fdata->num,
|
cfile_write_failure_alert_box(NULL, args->fname, err, err_info, fdata->num,
|
||||||
args->file_type);
|
args->file_type);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(hdr.opt_comment);
|
g_free(new_rec.opt_comment);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4099,7 +4062,7 @@ cf_has_unsaved_data(capture_file *cf)
|
||||||
static cf_read_status_t
|
static cf_read_status_t
|
||||||
rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
|
rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
|
||||||
{
|
{
|
||||||
const struct wtap_pkthdr *phdr;
|
const wtap_rec *rec;
|
||||||
int err;
|
int err;
|
||||||
gchar *err_info;
|
gchar *err_info;
|
||||||
gchar *name_ptr;
|
gchar *name_ptr;
|
||||||
|
@ -4166,7 +4129,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
|
||||||
g_get_current_time(&start_time);
|
g_get_current_time(&start_time);
|
||||||
|
|
||||||
framenum = 0;
|
framenum = 0;
|
||||||
phdr = wtap_phdr(cf->provider.wth);
|
rec = wtap_get_rec(cf->provider.wth);
|
||||||
while ((wtap_read(cf->provider.wth, &err, &err_info, &data_offset))) {
|
while ((wtap_read(cf->provider.wth, &err, &err_info, &data_offset))) {
|
||||||
framenum++;
|
framenum++;
|
||||||
fdata = frame_data_sequence_find(cf->provider.frames, framenum);
|
fdata = frame_data_sequence_find(cf->provider.frames, framenum);
|
||||||
|
@ -4211,7 +4174,9 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile)
|
||||||
link-layer encapsulation type, it'd be O(N^2) to read the file, but
|
link-layer encapsulation type, it'd be O(N^2) to read the file, but
|
||||||
there are probably going to be a small number of encapsulation types
|
there are probably going to be a small number of encapsulation types
|
||||||
in a file. */
|
in a file. */
|
||||||
cf_add_encapsulation_type(cf, phdr->pkt_encap);
|
if (rec->rec_type == REC_TYPE_PACKET) {
|
||||||
|
cf_add_encapsulation_type(cf, rec->rec_header.packet_header.pkt_encap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the display name */
|
/* Free the display name */
|
||||||
|
|
4
file.h
4
file.h
|
@ -152,13 +152,13 @@ cf_read_status_t cf_read(capture_file *cf, gboolean from_save);
|
||||||
*
|
*
|
||||||
* @param cf the capture file from which to read the record
|
* @param cf the capture file from which to read the record
|
||||||
* @param fdata the frame_data structure for the record in question
|
* @param fdata the frame_data structure for the record in question
|
||||||
* @param phdr pointer to a wtap_pkthdr structure to contain the
|
* @param rec pointer to a wtap_rec structure to contain the
|
||||||
* record's metadata
|
* record's metadata
|
||||||
* @param buf a Buffer into which to read the record's raw data
|
* @param buf a Buffer into which to read the record's raw data
|
||||||
* @return TRUE if the read succeeded, FALSE if there was an error
|
* @return TRUE if the read succeeded, FALSE if there was an error
|
||||||
*/
|
*/
|
||||||
gboolean cf_read_record_r(capture_file *cf, const frame_data *fdata,
|
gboolean cf_read_record_r(capture_file *cf, const frame_data *fdata,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf);
|
wtap_rec *rec, Buffer *buf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the metadata and raw data for a record into a
|
* Read the metadata and raw data for a record into a
|
||||||
|
|
|
@ -32,7 +32,7 @@ struct tvb_frame {
|
||||||
};
|
};
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
frame_read(struct tvb_frame *frame_tvb, struct wtap_pkthdr *phdr, Buffer *buf)
|
frame_read(struct tvb_frame *frame_tvb, wtap_rec *rec, Buffer *buf)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
gchar *err_info;
|
gchar *err_info;
|
||||||
|
@ -40,7 +40,7 @@ frame_read(struct tvb_frame *frame_tvb, struct wtap_pkthdr *phdr, Buffer *buf)
|
||||||
/* XXX, what if phdr->caplen isn't equal to
|
/* XXX, what if phdr->caplen isn't equal to
|
||||||
* frame_tvb->tvb.length + frame_tvb->offset?
|
* frame_tvb->tvb.length + frame_tvb->offset?
|
||||||
*/
|
*/
|
||||||
if (!wtap_seek_read(frame_tvb->prov->wth, frame_tvb->file_off, phdr, buf, &err, &err_info)) {
|
if (!wtap_seek_read(frame_tvb->prov->wth, frame_tvb->file_off, rec, buf, &err, &err_info)) {
|
||||||
/* XXX - report error! */
|
/* XXX - report error! */
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case WTAP_ERR_BAD_FILE:
|
case WTAP_ERR_BAD_FILE:
|
||||||
|
@ -57,9 +57,9 @@ static GPtrArray *buffer_cache = NULL;
|
||||||
static void
|
static void
|
||||||
frame_cache(struct tvb_frame *frame_tvb)
|
frame_cache(struct tvb_frame *frame_tvb)
|
||||||
{
|
{
|
||||||
struct wtap_pkthdr phdr; /* Packet header */
|
wtap_rec rec; /* Record metadata */
|
||||||
|
|
||||||
wtap_phdr_init(&phdr);
|
wtap_rec_init(&rec);
|
||||||
|
|
||||||
if (frame_tvb->buf == NULL) {
|
if (frame_tvb->buf == NULL) {
|
||||||
if G_UNLIKELY(!buffer_cache) buffer_cache = g_ptr_array_sized_new(1024);
|
if G_UNLIKELY(!buffer_cache) buffer_cache = g_ptr_array_sized_new(1024);
|
||||||
|
@ -72,13 +72,13 @@ frame_cache(struct tvb_frame *frame_tvb)
|
||||||
|
|
||||||
ws_buffer_init(frame_tvb->buf, frame_tvb->tvb.length + frame_tvb->offset);
|
ws_buffer_init(frame_tvb->buf, frame_tvb->tvb.length + frame_tvb->offset);
|
||||||
|
|
||||||
if (!frame_read(frame_tvb, &phdr, frame_tvb->buf))
|
if (!frame_read(frame_tvb, &rec, frame_tvb->buf))
|
||||||
{ /* TODO: THROW(???); */ }
|
{ /* TODO: THROW(???); */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
frame_tvb->tvb.real_data = ws_buffer_start_ptr(frame_tvb->buf) + frame_tvb->offset;
|
frame_tvb->tvb.real_data = ws_buffer_start_ptr(frame_tvb->buf) + frame_tvb->offset;
|
||||||
|
|
||||||
wtap_phdr_cleanup(&phdr);
|
wtap_rec_cleanup(&rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -66,10 +66,10 @@ typedef struct {
|
||||||
static gboolean usbdump_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean usbdump_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean usbdump_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean usbdump_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info);
|
int *err, gchar **err_info);
|
||||||
static gboolean usbdump_read_packet(wtap *wth, FILE_T fh,
|
static gboolean usbdump_read_packet(wtap *wth, FILE_T fh,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info);
|
int *err, gchar **err_info);
|
||||||
|
|
||||||
static int usbdump_file_type_subtype;
|
static int usbdump_file_type_subtype;
|
||||||
|
@ -167,7 +167,7 @@ usbdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
|
|
||||||
/* Try to read a packet worth of data */
|
/* Try to read a packet worth of data */
|
||||||
if (!usbdump_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer,
|
if (!usbdump_read_packet(wth, wth->fh, &wth->rec, wth->rec_data,
|
||||||
err, err_info))
|
err, err_info))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ usbdump_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||||
* in a buffer and fill in the packet header info.
|
* in a buffer and fill in the packet header info.
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
usbdump_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
usbdump_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
/* Seek to the desired file position at the start of the frame */
|
/* Seek to the desired file position at the start of the frame */
|
||||||
|
@ -208,7 +208,7 @@ usbdump_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Try to read a packet worth of data */
|
/* Try to read a packet worth of data */
|
||||||
if (!usbdump_read_packet(wth, wth->random_fh, phdr, buf, err, err_info)) {
|
if (!usbdump_read_packet(wth, wth->random_fh, rec, buf, err, err_info)) {
|
||||||
if (*err == 0)
|
if (*err == 0)
|
||||||
*err = WTAP_ERR_SHORT_READ;
|
*err = WTAP_ERR_SHORT_READ;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -227,7 +227,7 @@ usbdump_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||||
* so that we can find the next multiframe size field.
|
* so that we can find the next multiframe size field.
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
usbdump_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
usbdump_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
usbdump_info_t *usbdump_info = (usbdump_info_t *)wth->priv;
|
usbdump_info_t *usbdump_info = (usbdump_info_t *)wth->priv;
|
||||||
|
@ -259,31 +259,31 @@ usbdump_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup the per packet structure and fill it with info from this frame */
|
/* Setup the per packet structure and fill it with info from this frame */
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS | WTAP_HAS_CAP_LEN;
|
rec->presence_flags = WTAP_HAS_TS | WTAP_HAS_CAP_LEN;
|
||||||
phdr->ts.secs = (guint32)bpf_hdr[3] << 24 | (guint32)bpf_hdr[2] << 16 |
|
rec->ts.secs = (guint32)bpf_hdr[3] << 24 | (guint32)bpf_hdr[2] << 16 |
|
||||||
(guint32)bpf_hdr[1] << 8 | (guint32)bpf_hdr[0];
|
(guint32)bpf_hdr[1] << 8 | (guint32)bpf_hdr[0];
|
||||||
phdr->ts.nsecs = ((guint32)bpf_hdr[7] << 24 | (guint32)bpf_hdr[6] << 16 |
|
rec->ts.nsecs = ((guint32)bpf_hdr[7] << 24 | (guint32)bpf_hdr[6] << 16 |
|
||||||
(guint32)bpf_hdr[5] << 8 | (guint32)bpf_hdr[4]) * 1000;
|
(guint32)bpf_hdr[5] << 8 | (guint32)bpf_hdr[4]) * 1000;
|
||||||
phdr->caplen = (guint32)bpf_hdr[11] << 24 | (guint32)bpf_hdr[10] << 16 |
|
rec->rec_header.packet_header.caplen = (guint32)bpf_hdr[11] << 24 | (guint32)bpf_hdr[10] << 16 |
|
||||||
(guint32)bpf_hdr[9] << 8 | (guint32)bpf_hdr[8];
|
(guint32)bpf_hdr[9] << 8 | (guint32)bpf_hdr[8];
|
||||||
phdr->len = (guint32)bpf_hdr[15] << 24 | (guint32)bpf_hdr[14] << 16 |
|
rec->rec_header.packet_header.len = (guint32)bpf_hdr[15] << 24 | (guint32)bpf_hdr[14] << 16 |
|
||||||
(guint32)bpf_hdr[13] << 8 | (guint32)bpf_hdr[12];
|
(guint32)bpf_hdr[13] << 8 | (guint32)bpf_hdr[12];
|
||||||
|
|
||||||
/* Read the packet data */
|
/* Read the packet data */
|
||||||
if (!wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info))
|
if (!wtap_read_packet_bytes(fh, buf, rec->rec_header.packet_header.caplen, err, err_info))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Keep track of multiframe_size and detect overrun */
|
/* Keep track of multiframe_size and detect overrun */
|
||||||
if (usbdump_info->multiframe_size < phdr->caplen) {
|
if (usbdump_info->multiframe_size < rec->rec_header.packet_header.caplen) {
|
||||||
usbdump_info->multiframe_overrun = TRUE;
|
usbdump_info->multiframe_overrun = TRUE;
|
||||||
} else {
|
} else {
|
||||||
usbdump_info->multiframe_size -= phdr->caplen;
|
usbdump_info->multiframe_size -= rec->rec_header.packet_header.caplen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for and apply alignment as defined in the frame header */
|
/* Check for and apply alignment as defined in the frame header */
|
||||||
guint8 pad_len = (guint32)alignment -
|
guint8 pad_len = (guint32)alignment -
|
||||||
(((guint32)bpf_hdr_len + phdr->caplen) &
|
(((guint32)bpf_hdr_len + rec->rec_header.packet_header.caplen) &
|
||||||
((guint32)alignment - 1));
|
((guint32)alignment - 1));
|
||||||
if (pad_len < alignment) {
|
if (pad_len < alignment) {
|
||||||
/* Read alignment from the file */
|
/* Read alignment from the file */
|
||||||
|
|
|
@ -563,16 +563,16 @@ void randpkt_loop(randpkt_example* example, guint64 produce_count)
|
||||||
gchar* err_info;
|
gchar* err_info;
|
||||||
union wtap_pseudo_header* ps_header;
|
union wtap_pseudo_header* ps_header;
|
||||||
guint8* buffer;
|
guint8* buffer;
|
||||||
struct wtap_pkthdr* pkthdr;
|
wtap_rec* rec;
|
||||||
|
|
||||||
pkthdr = g_new0(struct wtap_pkthdr, 1);
|
rec = g_new0(wtap_rec, 1);
|
||||||
buffer = (guint8*)g_malloc0(65536);
|
buffer = (guint8*)g_malloc0(65536);
|
||||||
|
|
||||||
pkthdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
pkthdr->presence_flags = WTAP_HAS_TS;
|
rec->presence_flags = WTAP_HAS_TS;
|
||||||
pkthdr->pkt_encap = example->sample_wtap_encap;
|
rec->rec_header.packet_header.pkt_encap = example->sample_wtap_encap;
|
||||||
|
|
||||||
ps_header = &pkthdr->pseudo_header;
|
ps_header = &rec->rec_header.packet_header.pseudo_header;
|
||||||
|
|
||||||
/* Load the sample pseudoheader into our pseudoheader buffer */
|
/* Load the sample pseudoheader into our pseudoheader buffer */
|
||||||
if (example->pseudo_buffer)
|
if (example->pseudo_buffer)
|
||||||
|
@ -593,9 +593,9 @@ void randpkt_loop(randpkt_example* example, guint64 produce_count)
|
||||||
|
|
||||||
len_this_pkt = example->sample_length + len_random;
|
len_this_pkt = example->sample_length + len_random;
|
||||||
|
|
||||||
pkthdr->caplen = len_this_pkt;
|
rec->rec_header.packet_header.caplen = len_this_pkt;
|
||||||
pkthdr->len = len_this_pkt;
|
rec->rec_header.packet_header.len = len_this_pkt;
|
||||||
pkthdr->ts.secs = i; /* just for variety */
|
rec->ts.secs = i; /* just for variety */
|
||||||
|
|
||||||
for (j = example->pseudo_length; j < (int) sizeof(*ps_header); j++) {
|
for (j = example->pseudo_length; j < (int) sizeof(*ps_header); j++) {
|
||||||
((guint8*)ps_header)[j] = g_rand_int_range(pkt_rand, 0, 0x100);
|
((guint8*)ps_header)[j] = g_rand_int_range(pkt_rand, 0, 0x100);
|
||||||
|
@ -611,14 +611,14 @@ void randpkt_loop(randpkt_example* example, guint64 produce_count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wtap_dump(example->dump, pkthdr, buffer, &err, &err_info)) {
|
if (!wtap_dump(example->dump, rec, buffer, &err, &err_info)) {
|
||||||
cfile_write_failure_message("randpkt", NULL,
|
cfile_write_failure_message("randpkt", NULL,
|
||||||
example->filename, err, err_info, 0,
|
example->filename, err, err_info, 0,
|
||||||
WTAP_FILE_TYPE_SUBTYPE_PCAP);
|
WTAP_FILE_TYPE_SUBTYPE_PCAP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(pkthdr);
|
g_free(rec);
|
||||||
g_free(buffer);
|
g_free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
56
rawshark.c
56
rawshark.c
|
@ -138,7 +138,7 @@ static gboolean want_pcap_pkthdr;
|
||||||
cf_status_t raw_cf_open(capture_file *cf, const char *fname);
|
cf_status_t raw_cf_open(capture_file *cf, const char *fname);
|
||||||
static gboolean load_cap_file(capture_file *cf);
|
static gboolean load_cap_file(capture_file *cf);
|
||||||
static gboolean process_packet(capture_file *cf, epan_dissect_t *edt, gint64 offset,
|
static gboolean process_packet(capture_file *cf, epan_dissect_t *edt, gint64 offset,
|
||||||
struct wtap_pkthdr *whdr, const guchar *pd);
|
wtap_rec *rec, const guchar *pd);
|
||||||
static void show_print_file_io_error(int err);
|
static void show_print_file_io_error(int err);
|
||||||
|
|
||||||
static void failure_warning_message(const char *msg_format, va_list ap);
|
static void failure_warning_message(const char *msg_format, va_list ap);
|
||||||
|
@ -851,7 +851,7 @@ clean_exit:
|
||||||
* @return TRUE on success, FALSE on failure.
|
* @return TRUE on success, FALSE on failure.
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
raw_pipe_read(struct wtap_pkthdr *phdr, guchar * pd, int *err, gchar **err_info, gint64 *data_offset) {
|
raw_pipe_read(wtap_rec *rec, guchar * pd, int *err, gchar **err_info, gint64 *data_offset) {
|
||||||
struct pcap_pkthdr mem_hdr;
|
struct pcap_pkthdr mem_hdr;
|
||||||
struct pcaprec_hdr disk_hdr;
|
struct pcaprec_hdr disk_hdr;
|
||||||
ssize_t bytes_read = 0;
|
ssize_t bytes_read = 0;
|
||||||
|
@ -899,27 +899,29 @@ raw_pipe_read(struct wtap_pkthdr *phdr, guchar * pd, int *err, gchar **err_info,
|
||||||
ptr += bytes_read;
|
ptr += bytes_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
|
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
||||||
if (want_pcap_pkthdr) {
|
if (want_pcap_pkthdr) {
|
||||||
phdr->ts.secs = mem_hdr.ts.tv_sec;
|
rec->ts.secs = mem_hdr.ts.tv_sec;
|
||||||
phdr->ts.nsecs = (gint32)mem_hdr.ts.tv_usec * 1000;
|
rec->ts.nsecs = (gint32)mem_hdr.ts.tv_usec * 1000;
|
||||||
phdr->caplen = mem_hdr.caplen;
|
rec->rec_header.packet_header.caplen = mem_hdr.caplen;
|
||||||
phdr->len = mem_hdr.len;
|
rec->rec_header.packet_header.len = mem_hdr.len;
|
||||||
} else {
|
} else {
|
||||||
phdr->ts.secs = disk_hdr.ts_sec;
|
rec->ts.secs = disk_hdr.ts_sec;
|
||||||
phdr->ts.nsecs = disk_hdr.ts_usec * 1000;
|
rec->ts.nsecs = disk_hdr.ts_usec * 1000;
|
||||||
phdr->caplen = disk_hdr.incl_len;
|
rec->rec_header.packet_header.caplen = disk_hdr.incl_len;
|
||||||
phdr->len = disk_hdr.orig_len;
|
rec->rec_header.packet_header.len = disk_hdr.orig_len;
|
||||||
}
|
}
|
||||||
bytes_needed = phdr->caplen;
|
bytes_needed = rec->rec_header.packet_header.caplen;
|
||||||
|
|
||||||
phdr->pkt_encap = encap;
|
rec->rec_header.packet_header.pkt_encap = encap;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
printf("mem_hdr: %lu disk_hdr: %lu\n", sizeof(mem_hdr), sizeof(disk_hdr));
|
printf("mem_hdr: %lu disk_hdr: %lu\n", sizeof(mem_hdr), sizeof(disk_hdr));
|
||||||
printf("tv_sec: %u (%04x)\n", (unsigned int) phdr->ts.secs, (unsigned int) phdr->ts.secs);
|
printf("tv_sec: %u (%04x)\n", (unsigned int) rec->ts.secs, (unsigned int) rec->ts.secs);
|
||||||
printf("tv_nsec: %d (%04x)\n", phdr->ts.nsecs, phdr->ts.nsecs);
|
printf("tv_nsec: %d (%04x)\n", rec->ts.nsecs, rec->ts.nsecs);
|
||||||
printf("caplen: %d (%04x)\n", phdr->caplen, phdr->caplen);
|
printf("caplen: %d (%04x)\n", rec->rec_header.packet_header.caplen, rec->rec_header.packet_header.caplen);
|
||||||
printf("len: %d (%04x)\n", phdr->len, phdr->len);
|
printf("len: %d (%04x)\n", rec->rec_header.packet_header.len, rec->rec_header.packet_header.len);
|
||||||
#endif
|
#endif
|
||||||
if (bytes_needed > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
if (bytes_needed > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
||||||
*err = WTAP_ERR_BAD_FILE;
|
*err = WTAP_ERR_BAD_FILE;
|
||||||
|
@ -955,21 +957,21 @@ load_cap_file(capture_file *cf)
|
||||||
gint64 data_offset = 0;
|
gint64 data_offset = 0;
|
||||||
|
|
||||||
guchar *pd;
|
guchar *pd;
|
||||||
struct wtap_pkthdr phdr;
|
wtap_rec rec;
|
||||||
epan_dissect_t edt;
|
epan_dissect_t edt;
|
||||||
|
|
||||||
wtap_phdr_init(&phdr);
|
wtap_rec_init(&rec);
|
||||||
|
|
||||||
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
||||||
|
|
||||||
pd = (guchar*)g_malloc(WTAP_MAX_PACKET_SIZE_STANDARD);
|
pd = (guchar*)g_malloc(WTAP_MAX_PACKET_SIZE_STANDARD);
|
||||||
while (raw_pipe_read(&phdr, pd, &err, &err_info, &data_offset)) {
|
while (raw_pipe_read(&rec, pd, &err, &err_info, &data_offset)) {
|
||||||
process_packet(cf, &edt, data_offset, &phdr, pd);
|
process_packet(cf, &edt, data_offset, &rec, pd);
|
||||||
}
|
}
|
||||||
|
|
||||||
epan_dissect_cleanup(&edt);
|
epan_dissect_cleanup(&edt);
|
||||||
|
|
||||||
wtap_phdr_cleanup(&phdr);
|
wtap_rec_cleanup(&rec);
|
||||||
g_free(pd);
|
g_free(pd);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
/* Print a message noting that the read failed somewhere along the line. */
|
/* Print a message noting that the read failed somewhere along the line. */
|
||||||
|
@ -982,20 +984,20 @@ load_cap_file(capture_file *cf)
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
process_packet(capture_file *cf, epan_dissect_t *edt, gint64 offset,
|
process_packet(capture_file *cf, epan_dissect_t *edt, gint64 offset,
|
||||||
struct wtap_pkthdr *whdr, const guchar *pd)
|
wtap_rec *rec, const guchar *pd)
|
||||||
{
|
{
|
||||||
frame_data fdata;
|
frame_data fdata;
|
||||||
gboolean passed;
|
gboolean passed;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if(whdr->len == 0)
|
if(rec->rec_header.packet_header.len == 0)
|
||||||
{
|
{
|
||||||
/* The user sends an empty packet when he wants to get output from us even if we don't currently have
|
/* The user sends an empty packet when he wants to get output from us even if we don't currently have
|
||||||
packets to process. We spit out a line with the timestamp and the text "void"
|
packets to process. We spit out a line with the timestamp and the text "void"
|
||||||
*/
|
*/
|
||||||
printf("%lu %lu %lu void -\n", (unsigned long int)cf->count,
|
printf("%lu %lu %lu void -\n", (unsigned long int)cf->count,
|
||||||
(unsigned long int)whdr->ts.secs,
|
(unsigned long int)rec->ts.secs,
|
||||||
(unsigned long int)whdr->ts.nsecs);
|
(unsigned long int)rec->ts.nsecs);
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
|
@ -1008,7 +1010,7 @@ process_packet(capture_file *cf, epan_dissect_t *edt, gint64 offset,
|
||||||
/* If we're going to print packet information, or we're going to
|
/* If we're going to print packet information, or we're going to
|
||||||
run a read filter, or we're going to process taps, set up to
|
run a read filter, or we're going to process taps, set up to
|
||||||
do a dissection and do so. */
|
do a dissection and do so. */
|
||||||
frame_data_init(&fdata, cf->count, whdr, offset, cum_bytes);
|
frame_data_init(&fdata, cf->count, rec, offset, cum_bytes);
|
||||||
|
|
||||||
passed = TRUE;
|
passed = TRUE;
|
||||||
|
|
||||||
|
@ -1033,7 +1035,7 @@ process_packet(capture_file *cf, epan_dissect_t *edt, gint64 offset,
|
||||||
/* We only need the columns if we're printing packet info but we're
|
/* We only need the columns if we're printing packet info but we're
|
||||||
*not* verbose; in verbose mode, we print the protocol tree, not
|
*not* verbose; in verbose mode, we print the protocol tree, not
|
||||||
the protocol summary. */
|
the protocol summary. */
|
||||||
epan_dissect_run_with_taps(edt, cf->cd_t, whdr,
|
epan_dissect_run_with_taps(edt, cf->cd_t, rec,
|
||||||
frame_tvbuff_new(&cf->provider, &fdata, pd),
|
frame_tvbuff_new(&cf->provider, &fdata, pd),
|
||||||
&fdata, &cf->cinfo);
|
&fdata, &cf->cinfo);
|
||||||
|
|
||||||
|
|
26
reordercap.c
26
reordercap.c
|
@ -82,7 +82,7 @@ typedef struct FrameRecord_t {
|
||||||
|
|
||||||
static void
|
static void
|
||||||
frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh,
|
frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, const char *infile,
|
wtap_rec *rec, Buffer *buf, const char *infile,
|
||||||
const char *outfile)
|
const char *outfile)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
@ -93,7 +93,7 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh,
|
||||||
|
|
||||||
|
|
||||||
/* Re-read the frame from the stored location */
|
/* Re-read the frame from the stored location */
|
||||||
if (!wtap_seek_read(wth, frame->offset, phdr, buf, &err, &err_info)) {
|
if (!wtap_seek_read(wth, frame->offset, rec, buf, &err, &err_info)) {
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
/* Print a message noting that the read failed somewhere along the line. */
|
/* Print a message noting that the read failed somewhere along the line. */
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -105,12 +105,12 @@ frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy, and set length and timestamp from item. */
|
/* Copy, and set length and timestamp from item. */
|
||||||
/* TODO: remove when wtap_seek_read() fills in phdr,
|
/* TODO: remove when wtap_seek_read() fills in rec,
|
||||||
including time stamps, for all file types */
|
including time stamps, for all file types */
|
||||||
phdr->ts = frame->frame_time;
|
rec->ts = frame->frame_time;
|
||||||
|
|
||||||
/* Dump frame to outfile */
|
/* Dump frame to outfile */
|
||||||
if (!wtap_dump(pdh, phdr, ws_buffer_start_ptr(buf), &err, &err_info)) {
|
if (!wtap_dump(pdh, rec, ws_buffer_start_ptr(buf), &err, &err_info)) {
|
||||||
cfile_write_failure_message("reordercap", infile, outfile, err,
|
cfile_write_failure_message("reordercap", infile, outfile, err,
|
||||||
err_info, frame->num,
|
err_info, frame->num,
|
||||||
wtap_file_type_subtype(wth));
|
wtap_file_type_subtype(wth));
|
||||||
|
@ -168,12 +168,12 @@ main(int argc, char *argv[])
|
||||||
char *init_progfile_dir_error;
|
char *init_progfile_dir_error;
|
||||||
wtap *wth = NULL;
|
wtap *wth = NULL;
|
||||||
wtap_dumper *pdh = NULL;
|
wtap_dumper *pdh = NULL;
|
||||||
struct wtap_pkthdr dump_phdr;
|
wtap_rec dump_rec;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
int err;
|
int err;
|
||||||
gchar *err_info;
|
gchar *err_info;
|
||||||
gint64 data_offset;
|
gint64 data_offset;
|
||||||
const struct wtap_pkthdr *phdr;
|
const wtap_rec *rec;
|
||||||
guint wrong_order_count = 0;
|
guint wrong_order_count = 0;
|
||||||
gboolean write_output_regardless = TRUE;
|
gboolean write_output_regardless = TRUE;
|
||||||
guint i;
|
guint i;
|
||||||
|
@ -316,13 +316,13 @@ main(int argc, char *argv[])
|
||||||
while (wtap_read(wth, &err, &err_info, &data_offset)) {
|
while (wtap_read(wth, &err, &err_info, &data_offset)) {
|
||||||
FrameRecord_t *newFrameRecord;
|
FrameRecord_t *newFrameRecord;
|
||||||
|
|
||||||
phdr = wtap_phdr(wth);
|
rec = wtap_get_rec(wth);
|
||||||
|
|
||||||
newFrameRecord = g_slice_new(FrameRecord_t);
|
newFrameRecord = g_slice_new(FrameRecord_t);
|
||||||
newFrameRecord->num = frames->len + 1;
|
newFrameRecord->num = frames->len + 1;
|
||||||
newFrameRecord->offset = data_offset;
|
newFrameRecord->offset = data_offset;
|
||||||
if (phdr->presence_flags & WTAP_HAS_TS) {
|
if (rec->presence_flags & WTAP_HAS_TS) {
|
||||||
newFrameRecord->frame_time = phdr->ts;
|
newFrameRecord->frame_time = rec->ts;
|
||||||
} else {
|
} else {
|
||||||
nstime_set_unset(&newFrameRecord->frame_time);
|
nstime_set_unset(&newFrameRecord->frame_time);
|
||||||
}
|
}
|
||||||
|
@ -347,18 +347,18 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write out each sorted frame in turn */
|
/* Write out each sorted frame in turn */
|
||||||
wtap_phdr_init(&dump_phdr);
|
wtap_rec_init(&dump_rec);
|
||||||
ws_buffer_init(&buf, 1500);
|
ws_buffer_init(&buf, 1500);
|
||||||
for (i = 0; i < frames->len; i++) {
|
for (i = 0; i < frames->len; i++) {
|
||||||
FrameRecord_t *frame = (FrameRecord_t *)frames->pdata[i];
|
FrameRecord_t *frame = (FrameRecord_t *)frames->pdata[i];
|
||||||
|
|
||||||
/* Avoid writing if already sorted and configured to */
|
/* Avoid writing if already sorted and configured to */
|
||||||
if (write_output_regardless || (wrong_order_count > 0)) {
|
if (write_output_regardless || (wrong_order_count > 0)) {
|
||||||
frame_write(frame, wth, pdh, &dump_phdr, &buf, infile, outfile);
|
frame_write(frame, wth, pdh, &dump_rec, &buf, infile, outfile);
|
||||||
}
|
}
|
||||||
g_slice_free(FrameRecord_t, frame);
|
g_slice_free(FrameRecord_t, frame);
|
||||||
}
|
}
|
||||||
wtap_phdr_cleanup(&dump_phdr);
|
wtap_rec_cleanup(&dump_rec);
|
||||||
ws_buffer_free(&buf);
|
ws_buffer_free(&buf);
|
||||||
|
|
||||||
if (!write_output_regardless && (wrong_order_count == 0)) {
|
if (!write_output_regardless && (wrong_order_count == 0)) {
|
||||||
|
|
62
sharkd.c
62
sharkd.c
|
@ -241,23 +241,19 @@ sharkd_epan_new(capture_file *cf)
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
process_packet(capture_file *cf, epan_dissect_t *edt,
|
process_packet(capture_file *cf, epan_dissect_t *edt,
|
||||||
gint64 offset, struct wtap_pkthdr *whdr,
|
gint64 offset, wtap_rec *rec, const guchar *pd)
|
||||||
const guchar *pd)
|
|
||||||
{
|
{
|
||||||
frame_data fdlocal;
|
frame_data fdlocal;
|
||||||
guint32 framenum;
|
|
||||||
gboolean passed;
|
gboolean passed;
|
||||||
|
|
||||||
/* The frame number of this packet is one more than the count of
|
|
||||||
frames in this packet. */
|
|
||||||
framenum = cf->count + 1;
|
|
||||||
|
|
||||||
/* If we're not running a display filter and we're not printing any
|
/* If we're not running a display filter and we're not printing any
|
||||||
packet information, we don't need to do a dissection. This means
|
packet information, we don't need to do a dissection. This means
|
||||||
that all packets can be marked as 'passed'. */
|
that all packets can be marked as 'passed'. */
|
||||||
passed = TRUE;
|
passed = TRUE;
|
||||||
|
|
||||||
frame_data_init(&fdlocal, framenum, whdr, offset, cum_bytes);
|
/* The frame number of this packet, if we add it to the set of frames,
|
||||||
|
would be one more than the count of frames in the file so far. */
|
||||||
|
frame_data_init(&fdlocal, cf->count + 1, rec, offset, cum_bytes);
|
||||||
|
|
||||||
/* If we're going to print packet information, or we're going to
|
/* If we're going to print packet information, or we're going to
|
||||||
run a read filter, or display filter, or we're going to process taps, set up to
|
run a read filter, or display filter, or we're going to process taps, set up to
|
||||||
|
@ -287,7 +283,7 @@ process_packet(capture_file *cf, epan_dissect_t *edt,
|
||||||
cf->provider.ref = &ref_frame;
|
cf->provider.ref = &ref_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
epan_dissect_run(edt, cf->cd_t, whdr,
|
epan_dissect_run(edt, cf->cd_t, rec,
|
||||||
frame_tvbuff_new(&cf->provider, &fdlocal, pd),
|
frame_tvbuff_new(&cf->provider, &fdlocal, pd),
|
||||||
&fdlocal, NULL);
|
&fdlocal, NULL);
|
||||||
|
|
||||||
|
@ -361,8 +357,8 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (wtap_read(cf->provider.wth, &err, &err_info, &data_offset)) {
|
while (wtap_read(cf->provider.wth, &err, &err_info, &data_offset)) {
|
||||||
if (process_packet(cf, edt, data_offset, wtap_phdr(cf->provider.wth),
|
if (process_packet(cf, edt, data_offset, wtap_get_rec(cf->provider.wth),
|
||||||
wtap_buf_ptr(cf->provider.wth))) {
|
wtap_get_buf_ptr(cf->provider.wth))) {
|
||||||
/* Stop reading if we have the maximum number of packets;
|
/* Stop reading if we have the maximum number of packets;
|
||||||
* When the -c option has not been used, max_packet_count
|
* When the -c option has not been used, max_packet_count
|
||||||
* starts at 0, which practically means, never stop reading.
|
* starts at 0, which practically means, never stop reading.
|
||||||
|
@ -529,8 +525,8 @@ sharkd_dissect_request(guint32 framenum, guint32 frame_ref_num, guint32 prev_dis
|
||||||
column_info *cinfo = (dissect_columns) ? &cfile.cinfo : NULL;
|
column_info *cinfo = (dissect_columns) ? &cfile.cinfo : NULL;
|
||||||
epan_dissect_t edt;
|
epan_dissect_t edt;
|
||||||
gboolean create_proto_tree;
|
gboolean create_proto_tree;
|
||||||
struct wtap_pkthdr phdr; /* Packet header */
|
wtap_rec rec; /* Record metadata */
|
||||||
Buffer buf; /* Packet data */
|
Buffer buf; /* Record data */
|
||||||
|
|
||||||
int err;
|
int err;
|
||||||
char *err_info = NULL;
|
char *err_info = NULL;
|
||||||
|
@ -539,10 +535,10 @@ sharkd_dissect_request(guint32 framenum, guint32 frame_ref_num, guint32 prev_dis
|
||||||
if (fdata == NULL)
|
if (fdata == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
wtap_phdr_init(&phdr);
|
wtap_rec_init(&rec);
|
||||||
ws_buffer_init(&buf, 1500);
|
ws_buffer_init(&buf, 1500);
|
||||||
|
|
||||||
if (!wtap_seek_read(cfile.provider.wth, fdata->file_off, &phdr, &buf, &err, &err_info)) {
|
if (!wtap_seek_read(cfile.provider.wth, fdata->file_off, &rec, &buf, &err, &err_info)) {
|
||||||
ws_buffer_free(&buf);
|
ws_buffer_free(&buf);
|
||||||
return -1; /* error reading the record */
|
return -1; /* error reading the record */
|
||||||
}
|
}
|
||||||
|
@ -560,7 +556,7 @@ sharkd_dissect_request(guint32 framenum, guint32 frame_ref_num, guint32 prev_dis
|
||||||
fdata->flags.ref_time = (framenum == frame_ref_num);
|
fdata->flags.ref_time = (framenum == frame_ref_num);
|
||||||
fdata->frame_ref_num = frame_ref_num;
|
fdata->frame_ref_num = frame_ref_num;
|
||||||
fdata->prev_dis_num = prev_dis_num;
|
fdata->prev_dis_num = prev_dis_num;
|
||||||
epan_dissect_run(&edt, cfile.cd_t, &phdr,
|
epan_dissect_run(&edt, cfile.cd_t, &rec,
|
||||||
frame_tvbuff_new_buffer(&cfile.provider, fdata, &buf),
|
frame_tvbuff_new_buffer(&cfile.provider, fdata, &buf),
|
||||||
fdata, cinfo);
|
fdata, cinfo);
|
||||||
|
|
||||||
|
@ -572,7 +568,7 @@ sharkd_dissect_request(guint32 framenum, guint32 frame_ref_num, guint32 prev_dis
|
||||||
cb(&edt, dissect_tree ? edt.tree : NULL, cinfo, dissect_bytes ? edt.pi.data_src : NULL, data);
|
cb(&edt, dissect_tree ? edt.tree : NULL, cinfo, dissect_bytes ? edt.pi.data_src : NULL, data);
|
||||||
|
|
||||||
epan_dissect_cleanup(&edt);
|
epan_dissect_cleanup(&edt);
|
||||||
wtap_phdr_cleanup(&phdr);
|
wtap_rec_cleanup(&rec);
|
||||||
ws_buffer_free(&buf);
|
ws_buffer_free(&buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -583,16 +579,16 @@ sharkd_dissect_columns(frame_data *fdata, guint32 frame_ref_num, guint32 prev_di
|
||||||
{
|
{
|
||||||
epan_dissect_t edt;
|
epan_dissect_t edt;
|
||||||
gboolean create_proto_tree;
|
gboolean create_proto_tree;
|
||||||
struct wtap_pkthdr phdr; /* Packet header */
|
wtap_rec rec; /* Record metadata */
|
||||||
Buffer buf; /* Packet data */
|
Buffer buf; /* Record data */
|
||||||
|
|
||||||
int err;
|
int err;
|
||||||
char *err_info = NULL;
|
char *err_info = NULL;
|
||||||
|
|
||||||
wtap_phdr_init(&phdr);
|
wtap_rec_init(&rec);
|
||||||
ws_buffer_init(&buf, 1500);
|
ws_buffer_init(&buf, 1500);
|
||||||
|
|
||||||
if (!wtap_seek_read(cfile.provider.wth, fdata->file_off, &phdr, &buf, &err, &err_info)) {
|
if (!wtap_seek_read(cfile.provider.wth, fdata->file_off, &rec, &buf, &err, &err_info)) {
|
||||||
col_fill_in_error(cinfo, fdata, FALSE, FALSE /* fill_fd_columns */);
|
col_fill_in_error(cinfo, fdata, FALSE, FALSE /* fill_fd_columns */);
|
||||||
ws_buffer_free(&buf);
|
ws_buffer_free(&buf);
|
||||||
return -1; /* error reading the record */
|
return -1; /* error reading the record */
|
||||||
|
@ -617,7 +613,7 @@ sharkd_dissect_columns(frame_data *fdata, guint32 frame_ref_num, guint32 prev_di
|
||||||
fdata->flags.ref_time = (fdata->num == frame_ref_num);
|
fdata->flags.ref_time = (fdata->num == frame_ref_num);
|
||||||
fdata->frame_ref_num = frame_ref_num;
|
fdata->frame_ref_num = frame_ref_num;
|
||||||
fdata->prev_dis_num = prev_dis_num;
|
fdata->prev_dis_num = prev_dis_num;
|
||||||
epan_dissect_run(&edt, cfile.cd_t, &phdr,
|
epan_dissect_run(&edt, cfile.cd_t, &rec,
|
||||||
frame_tvbuff_new_buffer(&cfile.provider, fdata, &buf),
|
frame_tvbuff_new_buffer(&cfile.provider, fdata, &buf),
|
||||||
fdata, cinfo);
|
fdata, cinfo);
|
||||||
|
|
||||||
|
@ -627,7 +623,7 @@ sharkd_dissect_columns(frame_data *fdata, guint32 frame_ref_num, guint32 prev_di
|
||||||
}
|
}
|
||||||
|
|
||||||
epan_dissect_cleanup(&edt);
|
epan_dissect_cleanup(&edt);
|
||||||
wtap_phdr_cleanup(&phdr);
|
wtap_rec_cleanup(&rec);
|
||||||
ws_buffer_free(&buf);
|
ws_buffer_free(&buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -638,7 +634,7 @@ sharkd_retap(void)
|
||||||
guint32 framenum;
|
guint32 framenum;
|
||||||
frame_data *fdata;
|
frame_data *fdata;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
struct wtap_pkthdr phdr;
|
wtap_rec rec;
|
||||||
int err;
|
int err;
|
||||||
char *err_info = NULL;
|
char *err_info = NULL;
|
||||||
|
|
||||||
|
@ -664,7 +660,7 @@ sharkd_retap(void)
|
||||||
create_proto_tree =
|
create_proto_tree =
|
||||||
(have_filtering_tap_listeners() || (tap_flags & TL_REQUIRES_PROTO_TREE));
|
(have_filtering_tap_listeners() || (tap_flags & TL_REQUIRES_PROTO_TREE));
|
||||||
|
|
||||||
wtap_phdr_init(&phdr);
|
wtap_rec_init(&rec);
|
||||||
ws_buffer_init(&buf, 1500);
|
ws_buffer_init(&buf, 1500);
|
||||||
epan_dissect_init(&edt, cfile.epan, create_proto_tree, FALSE);
|
epan_dissect_init(&edt, cfile.epan, create_proto_tree, FALSE);
|
||||||
|
|
||||||
|
@ -673,19 +669,19 @@ sharkd_retap(void)
|
||||||
for (framenum = 1; framenum <= cfile.count; framenum++) {
|
for (framenum = 1; framenum <= cfile.count; framenum++) {
|
||||||
fdata = sharkd_get_frame(framenum);
|
fdata = sharkd_get_frame(framenum);
|
||||||
|
|
||||||
if (!wtap_seek_read(cfile.provider.wth, fdata->file_off, &phdr, &buf, &err, &err_info))
|
if (!wtap_seek_read(cfile.provider.wth, fdata->file_off, &rec, &buf, &err, &err_info))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
fdata->flags.ref_time = FALSE;
|
fdata->flags.ref_time = FALSE;
|
||||||
fdata->frame_ref_num = (framenum != 1) ? 1 : 0;
|
fdata->frame_ref_num = (framenum != 1) ? 1 : 0;
|
||||||
fdata->prev_dis_num = framenum - 1;
|
fdata->prev_dis_num = framenum - 1;
|
||||||
epan_dissect_run_with_taps(&edt, cfile.cd_t, &phdr,
|
epan_dissect_run_with_taps(&edt, cfile.cd_t, &rec,
|
||||||
frame_tvbuff_new(&cfile.provider, fdata, ws_buffer_start_ptr(&buf)),
|
frame_tvbuff_new(&cfile.provider, fdata, ws_buffer_start_ptr(&buf)),
|
||||||
fdata, cinfo);
|
fdata, cinfo);
|
||||||
epan_dissect_reset(&edt);
|
epan_dissect_reset(&edt);
|
||||||
}
|
}
|
||||||
|
|
||||||
wtap_phdr_cleanup(&phdr);
|
wtap_rec_cleanup(&rec);
|
||||||
ws_buffer_free(&buf);
|
ws_buffer_free(&buf);
|
||||||
epan_dissect_cleanup(&edt);
|
epan_dissect_cleanup(&edt);
|
||||||
|
|
||||||
|
@ -702,7 +698,7 @@ sharkd_filter(const char *dftext, guint8 **result)
|
||||||
guint32 framenum, prev_dis_num = 0;
|
guint32 framenum, prev_dis_num = 0;
|
||||||
guint32 frames_count;
|
guint32 frames_count;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
struct wtap_pkthdr phdr;
|
wtap_rec rec;
|
||||||
int err;
|
int err;
|
||||||
char *err_info = NULL;
|
char *err_info = NULL;
|
||||||
|
|
||||||
|
@ -718,7 +714,7 @@ sharkd_filter(const char *dftext, guint8 **result)
|
||||||
|
|
||||||
frames_count = cfile.count;
|
frames_count = cfile.count;
|
||||||
|
|
||||||
wtap_phdr_init(&phdr);
|
wtap_rec_init(&rec);
|
||||||
ws_buffer_init(&buf, 1500);
|
ws_buffer_init(&buf, 1500);
|
||||||
epan_dissect_init(&edt, cfile.epan, TRUE, FALSE);
|
epan_dissect_init(&edt, cfile.epan, TRUE, FALSE);
|
||||||
|
|
||||||
|
@ -733,7 +729,7 @@ sharkd_filter(const char *dftext, guint8 **result)
|
||||||
passed_bits = 0;
|
passed_bits = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wtap_seek_read(cfile.provider.wth, fdata->file_off, &phdr, &buf, &err, &err_info))
|
if (!wtap_seek_read(cfile.provider.wth, fdata->file_off, &rec, &buf, &err, &err_info))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* frame_data_set_before_dissect */
|
/* frame_data_set_before_dissect */
|
||||||
|
@ -742,7 +738,7 @@ sharkd_filter(const char *dftext, guint8 **result)
|
||||||
fdata->flags.ref_time = FALSE;
|
fdata->flags.ref_time = FALSE;
|
||||||
fdata->frame_ref_num = (framenum != 1) ? 1 : 0;
|
fdata->frame_ref_num = (framenum != 1) ? 1 : 0;
|
||||||
fdata->prev_dis_num = prev_dis_num;
|
fdata->prev_dis_num = prev_dis_num;
|
||||||
epan_dissect_run(&edt, cfile.cd_t, &phdr,
|
epan_dissect_run(&edt, cfile.cd_t, &rec,
|
||||||
frame_tvbuff_new_buffer(&cfile.provider, fdata, &buf),
|
frame_tvbuff_new_buffer(&cfile.provider, fdata, &buf),
|
||||||
fdata, NULL);
|
fdata, NULL);
|
||||||
|
|
||||||
|
@ -760,7 +756,7 @@ sharkd_filter(const char *dftext, guint8 **result)
|
||||||
framenum--;
|
framenum--;
|
||||||
result_bits[framenum / 8] = passed_bits;
|
result_bits[framenum / 8] = passed_bits;
|
||||||
|
|
||||||
wtap_phdr_cleanup(&phdr);
|
wtap_rec_cleanup(&rec);
|
||||||
ws_buffer_free(&buf);
|
ws_buffer_free(&buf);
|
||||||
epan_dissect_cleanup(&edt);
|
epan_dissect_cleanup(&edt);
|
||||||
|
|
||||||
|
|
|
@ -2825,7 +2825,7 @@ sharkd_session_process_frame_cb(epan_dissect_t *edt, proto_tree *tree, struct ep
|
||||||
if (fdata->flags.has_user_comment)
|
if (fdata->flags.has_user_comment)
|
||||||
pkt_comment = sharkd_get_user_comment(fdata);
|
pkt_comment = sharkd_get_user_comment(fdata);
|
||||||
else if (fdata->flags.has_phdr_comment)
|
else if (fdata->flags.has_phdr_comment)
|
||||||
pkt_comment = pi->phdr->opt_comment;
|
pkt_comment = pi->rec->opt_comment;
|
||||||
|
|
||||||
if (pkt_comment)
|
if (pkt_comment)
|
||||||
{
|
{
|
||||||
|
|
54
tfshark.c
54
tfshark.c
|
@ -123,7 +123,7 @@ static const char *separator = "";
|
||||||
|
|
||||||
static gboolean process_file(capture_file *, int, gint64);
|
static gboolean process_file(capture_file *, int, gint64);
|
||||||
static gboolean process_packet_single_pass(capture_file *cf,
|
static gboolean process_packet_single_pass(capture_file *cf,
|
||||||
epan_dissect_t *edt, gint64 offset, struct wtap_pkthdr *whdr,
|
epan_dissect_t *edt, gint64 offset, wtap_rec *rec,
|
||||||
const guchar *pd, guint tap_flags);
|
const guchar *pd, guint tap_flags);
|
||||||
static void show_print_file_io_error(int err);
|
static void show_print_file_io_error(int err);
|
||||||
static gboolean write_preamble(capture_file *cf);
|
static gboolean write_preamble(capture_file *cf);
|
||||||
|
@ -1048,7 +1048,7 @@ tfshark_epan_new(capture_file *cf)
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
process_packet_first_pass(capture_file *cf, epan_dissect_t *edt,
|
process_packet_first_pass(capture_file *cf, epan_dissect_t *edt,
|
||||||
gint64 offset, struct wtap_pkthdr *whdr,
|
gint64 offset, wtap_rec *rec,
|
||||||
const guchar *pd)
|
const guchar *pd)
|
||||||
{
|
{
|
||||||
frame_data fdlocal;
|
frame_data fdlocal;
|
||||||
|
@ -1064,7 +1064,7 @@ process_packet_first_pass(capture_file *cf, epan_dissect_t *edt,
|
||||||
that all packets can be marked as 'passed'. */
|
that all packets can be marked as 'passed'. */
|
||||||
passed = TRUE;
|
passed = TRUE;
|
||||||
|
|
||||||
frame_data_init(&fdlocal, framenum, whdr, offset, cum_bytes);
|
frame_data_init(&fdlocal, framenum, rec, offset, cum_bytes);
|
||||||
|
|
||||||
/* If we're going to print packet information, or we're going to
|
/* If we're going to print packet information, or we're going to
|
||||||
run a read filter, or display filter, or we're going to process taps, set up to
|
run a read filter, or display filter, or we're going to process taps, set up to
|
||||||
|
@ -1086,7 +1086,7 @@ process_packet_first_pass(capture_file *cf, epan_dissect_t *edt,
|
||||||
cf->provider.ref = &ref_frame;
|
cf->provider.ref = &ref_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
epan_dissect_file_run(edt, whdr,
|
epan_dissect_file_run(edt, rec,
|
||||||
file_tvbuff_new(&cf->provider, &fdlocal, pd),
|
file_tvbuff_new(&cf->provider, &fdlocal, pd),
|
||||||
&fdlocal, NULL);
|
&fdlocal, NULL);
|
||||||
|
|
||||||
|
@ -1122,7 +1122,7 @@ process_packet_first_pass(capture_file *cf, epan_dissect_t *edt,
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
process_packet_second_pass(capture_file *cf, epan_dissect_t *edt,
|
process_packet_second_pass(capture_file *cf, epan_dissect_t *edt,
|
||||||
frame_data *fdata, struct wtap_pkthdr *phdr,
|
frame_data *fdata, wtap_rec *rec,
|
||||||
Buffer *buf, guint tap_flags)
|
Buffer *buf, guint tap_flags)
|
||||||
{
|
{
|
||||||
column_info *cinfo;
|
column_info *cinfo;
|
||||||
|
@ -1167,7 +1167,7 @@ process_packet_second_pass(capture_file *cf, epan_dissect_t *edt,
|
||||||
cf->provider.ref = &ref_frame;
|
cf->provider.ref = &ref_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
epan_dissect_file_run_with_taps(edt, phdr,
|
epan_dissect_file_run_with_taps(edt, rec,
|
||||||
file_tvbuff_new_buffer(&cf->provider, fdata, buf), fdata, cinfo);
|
file_tvbuff_new_buffer(&cf->provider, fdata, buf), fdata, cinfo);
|
||||||
|
|
||||||
/* Run the read/display filter if we have one. */
|
/* Run the read/display filter if we have one. */
|
||||||
|
@ -1205,7 +1205,7 @@ process_packet_second_pass(capture_file *cf, epan_dissect_t *edt,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
local_wtap_read(capture_file *cf, struct wtap_pkthdr* file_phdr _U_, int *err, gchar **err_info _U_, gint64 *data_offset _U_, guint8** data_buffer)
|
local_wtap_read(capture_file *cf, wtap_rec *file_rec _U_, int *err, gchar **err_info _U_, gint64 *data_offset _U_, guint8** data_buffer)
|
||||||
{
|
{
|
||||||
/* int bytes_read; */
|
/* int bytes_read; */
|
||||||
gint64 packet_size = wtap_file_size(cf->provider.wth, err);
|
gint64 packet_size = wtap_file_size(cf->provider.wth, err);
|
||||||
|
@ -1226,8 +1226,8 @@ local_wtap_read(capture_file *cf, struct wtap_pkthdr* file_phdr _U_, int *err, g
|
||||||
|
|
||||||
|
|
||||||
/* XXX - SET FRAME SIZE EQUAL TO TOTAL FILE SIZE */
|
/* XXX - SET FRAME SIZE EQUAL TO TOTAL FILE SIZE */
|
||||||
file_phdr->caplen = (guint32)packet_size;
|
file_rec->rec_header.packet_header.caplen = (guint32)packet_size;
|
||||||
file_phdr->len = (guint32)packet_size;
|
file_rec->rec_header.packet_header.len = (guint32)packet_size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the packet encapsulation to the file's encapsulation
|
* Set the packet encapsulation to the file's encapsulation
|
||||||
|
@ -1237,7 +1237,7 @@ local_wtap_read(capture_file *cf, struct wtap_pkthdr* file_phdr _U_, int *err, g
|
||||||
* *is* WTAP_ENCAP_PER_PACKET, the caller needs to set it
|
* *is* WTAP_ENCAP_PER_PACKET, the caller needs to set it
|
||||||
* anyway.
|
* anyway.
|
||||||
*/
|
*/
|
||||||
wth->phdr.pkt_encap = wth->file_encap;
|
wth->rec.rec_header.packet_header.pkt_encap = wth->file_encap;
|
||||||
|
|
||||||
if (!wth->subtype_read(wth, err, err_info, data_offset)) {
|
if (!wth->subtype_read(wth, err, err_info, data_offset)) {
|
||||||
/*
|
/*
|
||||||
|
@ -1258,8 +1258,8 @@ local_wtap_read(capture_file *cf, struct wtap_pkthdr* file_phdr _U_, int *err, g
|
||||||
* It makes no sense for the captured data length to be bigger
|
* It makes no sense for the captured data length to be bigger
|
||||||
* than the actual data length.
|
* than the actual data length.
|
||||||
*/
|
*/
|
||||||
if (wth->phdr.caplen > wth->phdr.len)
|
if (wth->rec.rec_header.packet_header.caplen > wth->rec.rec_header.packet_header.len)
|
||||||
wth->phdr.caplen = wth->phdr.len;
|
wth->rec.rec_header.packet_header.caplen = wth->rec.rec_header.packet_header.len;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure that it's not WTAP_ENCAP_PER_PACKET, as that
|
* Make sure that it's not WTAP_ENCAP_PER_PACKET, as that
|
||||||
|
@ -1267,7 +1267,7 @@ local_wtap_read(capture_file *cf, struct wtap_pkthdr* file_phdr _U_, int *err, g
|
||||||
* but the read routine didn't set this packet's
|
* but the read routine didn't set this packet's
|
||||||
* encapsulation type.
|
* encapsulation type.
|
||||||
*/
|
*/
|
||||||
g_assert(wth->phdr.pkt_encap != WTAP_ENCAP_PER_PACKET);
|
g_assert(wth->rec.rec_header.packet_header.pkt_encap != WTAP_ENCAP_PER_PACKET);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return TRUE; /* success */
|
return TRUE; /* success */
|
||||||
|
@ -1284,7 +1284,7 @@ process_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
||||||
guint tap_flags;
|
guint tap_flags;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
epan_dissect_t *edt = NULL;
|
epan_dissect_t *edt = NULL;
|
||||||
struct wtap_pkthdr file_phdr;
|
wtap_rec file_rec;
|
||||||
guint8* raw_data;
|
guint8* raw_data;
|
||||||
|
|
||||||
if (print_packet_info) {
|
if (print_packet_info) {
|
||||||
|
@ -1301,10 +1301,10 @@ process_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
||||||
/* Get the union of the flags for all tap listeners. */
|
/* Get the union of the flags for all tap listeners. */
|
||||||
tap_flags = union_of_tap_listener_flags();
|
tap_flags = union_of_tap_listener_flags();
|
||||||
|
|
||||||
wtap_phdr_init(&file_phdr);
|
wtap_rec_init(&file_rec);
|
||||||
|
|
||||||
/* XXX - TEMPORARY HACK TO ELF DISSECTOR */
|
/* XXX - TEMPORARY HACK TO ELF DISSECTOR */
|
||||||
file_phdr.pkt_encap = 1234;
|
file_rec.rec_header.packet_header.pkt_encap = 1234;
|
||||||
|
|
||||||
if (perform_two_pass_analysis) {
|
if (perform_two_pass_analysis) {
|
||||||
frame_data *fdata;
|
frame_data *fdata;
|
||||||
|
@ -1331,9 +1331,9 @@ process_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
||||||
so it's not going to be "visible". */
|
so it's not going to be "visible". */
|
||||||
edt = epan_dissect_new(cf->epan, create_proto_tree, FALSE);
|
edt = epan_dissect_new(cf->epan, create_proto_tree, FALSE);
|
||||||
}
|
}
|
||||||
while (local_wtap_read(cf, &file_phdr, &err, &err_info, &data_offset, &raw_data)) {
|
while (local_wtap_read(cf, &file_rec, &err, &err_info, &data_offset, &raw_data)) {
|
||||||
if (process_packet_first_pass(cf, edt, data_offset, &file_phdr/*wtap_phdr(cf->provider.wth)*/,
|
if (process_packet_first_pass(cf, edt, data_offset, &file_rec/*wtap_get_rec(cf->provider.wth)*/,
|
||||||
wtap_buf_ptr(cf->provider.wth))) {
|
wtap_get_buf_ptr(cf->provider.wth))) {
|
||||||
|
|
||||||
/* Stop reading if we have the maximum number of packets;
|
/* Stop reading if we have the maximum number of packets;
|
||||||
* When the -c option has not been used, max_packet_count
|
* When the -c option has not been used, max_packet_count
|
||||||
|
@ -1397,10 +1397,10 @@ process_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
||||||
#if 0
|
#if 0
|
||||||
if (wtap_seek_read(cf->provider.wth, fdata->file_off,
|
if (wtap_seek_read(cf->provider.wth, fdata->file_off,
|
||||||
&buf, fdata->cap_len, &err, &err_info)) {
|
&buf, fdata->cap_len, &err, &err_info)) {
|
||||||
process_packet_second_pass(cf, edt, fdata, &cf->phdr, &buf, tap_flags);
|
process_packet_second_pass(cf, edt, fdata, &cf->rec, &buf, tap_flags);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (!process_packet_second_pass(cf, edt, fdata, &cf->phdr, &buf,
|
if (!process_packet_second_pass(cf, edt, fdata, &cf->rec, &buf,
|
||||||
tap_flags))
|
tap_flags))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1451,12 +1451,12 @@ process_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
||||||
edt = epan_dissect_new(cf->epan, create_proto_tree, print_packet_info && print_details);
|
edt = epan_dissect_new(cf->epan, create_proto_tree, print_packet_info && print_details);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (local_wtap_read(cf, &file_phdr, &err, &err_info, &data_offset, &raw_data)) {
|
while (local_wtap_read(cf, &file_rec, &err, &err_info, &data_offset, &raw_data)) {
|
||||||
|
|
||||||
framenum++;
|
framenum++;
|
||||||
|
|
||||||
if (!process_packet_single_pass(cf, edt, data_offset,
|
if (!process_packet_single_pass(cf, edt, data_offset,
|
||||||
&file_phdr/*wtap_phdr(cf->provider.wth)*/,
|
&file_rec/*wtap_get_rec(cf->provider.wth)*/,
|
||||||
raw_data, tap_flags))
|
raw_data, tap_flags))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -1477,7 +1477,7 @@ process_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wtap_phdr_cleanup(&file_phdr);
|
wtap_rec_cleanup(&file_rec);
|
||||||
|
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
/*
|
/*
|
||||||
|
@ -1564,7 +1564,7 @@ out:
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
process_packet_single_pass(capture_file *cf, epan_dissect_t *edt, gint64 offset,
|
process_packet_single_pass(capture_file *cf, epan_dissect_t *edt, gint64 offset,
|
||||||
struct wtap_pkthdr *whdr, const guchar *pd,
|
wtap_rec *rec, const guchar *pd,
|
||||||
guint tap_flags)
|
guint tap_flags)
|
||||||
{
|
{
|
||||||
frame_data fdata;
|
frame_data fdata;
|
||||||
|
@ -1579,7 +1579,7 @@ process_packet_single_pass(capture_file *cf, epan_dissect_t *edt, gint64 offset,
|
||||||
that all packets can be marked as 'passed'. */
|
that all packets can be marked as 'passed'. */
|
||||||
passed = TRUE;
|
passed = TRUE;
|
||||||
|
|
||||||
frame_data_init(&fdata, cf->count, whdr, offset, cum_bytes);
|
frame_data_init(&fdata, cf->count, rec, offset, cum_bytes);
|
||||||
|
|
||||||
/* If we're going to print packet information, or we're going to
|
/* If we're going to print packet information, or we're going to
|
||||||
run a read filter, or we're going to process taps, set up to
|
run a read filter, or we're going to process taps, set up to
|
||||||
|
@ -1611,7 +1611,7 @@ process_packet_single_pass(capture_file *cf, epan_dissect_t *edt, gint64 offset,
|
||||||
cf->provider.ref = &ref_frame;
|
cf->provider.ref = &ref_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
epan_dissect_file_run_with_taps(edt, whdr,
|
epan_dissect_file_run_with_taps(edt, rec,
|
||||||
frame_tvbuff_new(&cf->provider, &fdata, pd),
|
frame_tvbuff_new(&cf->provider, &fdata, pd),
|
||||||
&fdata, cinfo);
|
&fdata, cinfo);
|
||||||
|
|
||||||
|
|
|
@ -285,22 +285,22 @@ LLVMFuzzerTestOneInput(const guint8 *buf, size_t real_len)
|
||||||
|
|
||||||
guint32 len = (guint32) real_len;
|
guint32 len = (guint32) real_len;
|
||||||
|
|
||||||
struct wtap_pkthdr whdr;
|
wtap_rec rec;
|
||||||
frame_data fdlocal;
|
frame_data fdlocal;
|
||||||
|
|
||||||
memset(&whdr, 0, sizeof(whdr));
|
memset(&rec, 0, sizeof(rec));
|
||||||
|
|
||||||
whdr.rec_type = REC_TYPE_PACKET;
|
rec.rec_type = REC_TYPE_PACKET;
|
||||||
whdr.caplen = len;
|
rec.rec_header.packet_header.caplen = len;
|
||||||
whdr.len = len;
|
rec.rec_header.packet_header.len = len;
|
||||||
|
|
||||||
/* whdr.pkt_encap = WTAP_ENCAP_ETHERNET; */
|
/* whdr.pkt_encap = WTAP_ENCAP_ETHERNET; */
|
||||||
whdr.pkt_encap = G_MAXINT16;
|
rec.rec_header.packet_header.pkt_encap = G_MAXINT16;
|
||||||
whdr.presence_flags = WTAP_HAS_TS | WTAP_HAS_CAP_LEN; /* most common flags... */
|
rec.presence_flags = WTAP_HAS_TS | WTAP_HAS_CAP_LEN; /* most common flags... */
|
||||||
|
|
||||||
frame_data_init(&fdlocal, ++framenum, &whdr, /* offset */ 0, /* cum_bytes */ 0);
|
frame_data_init(&fdlocal, ++framenum, &rec, /* offset */ 0, /* cum_bytes */ 0);
|
||||||
/* frame_data_set_before_dissect() not needed */
|
/* frame_data_set_before_dissect() not needed */
|
||||||
epan_dissect_run(edt, WTAP_FILE_TYPE_SUBTYPE_UNKNOWN, &whdr, tvb_new_real_data(buf, len, len), &fdlocal, NULL /* &fuzz_cinfo */);
|
epan_dissect_run(edt, WTAP_FILE_TYPE_SUBTYPE_UNKNOWN, &rec, tvb_new_real_data(buf, len, len), &fdlocal, NULL /* &fuzz_cinfo */);
|
||||||
frame_data_destroy(&fdlocal);
|
frame_data_destroy(&fdlocal);
|
||||||
|
|
||||||
epan_dissect_reset(edt);
|
epan_dissect_reset(edt);
|
||||||
|
|
44
tshark.c
44
tshark.c
|
@ -236,7 +236,7 @@ static char *output_file_name;
|
||||||
static void reset_epan_mem(capture_file *cf, epan_dissect_t *edt, gboolean tree, gboolean visual);
|
static void reset_epan_mem(capture_file *cf, epan_dissect_t *edt, gboolean tree, gboolean visual);
|
||||||
static gboolean process_cap_file(capture_file *, char *, int, gboolean, int, gint64);
|
static gboolean process_cap_file(capture_file *, char *, int, gboolean, int, gint64);
|
||||||
static gboolean process_packet_single_pass(capture_file *cf,
|
static gboolean process_packet_single_pass(capture_file *cf,
|
||||||
epan_dissect_t *edt, gint64 offset, struct wtap_pkthdr *whdr,
|
epan_dissect_t *edt, gint64 offset, wtap_rec *rec,
|
||||||
const guchar *pd, guint tap_flags);
|
const guchar *pd, guint tap_flags);
|
||||||
static void show_print_file_io_error(int err);
|
static void show_print_file_io_error(int err);
|
||||||
static gboolean write_preamble(capture_file *cf);
|
static gboolean write_preamble(capture_file *cf);
|
||||||
|
@ -2664,8 +2664,8 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
|
||||||
cf->provider.wth = NULL;
|
cf->provider.wth = NULL;
|
||||||
} else {
|
} else {
|
||||||
ret = process_packet_single_pass(cf, edt, data_offset,
|
ret = process_packet_single_pass(cf, edt, data_offset,
|
||||||
wtap_phdr(cf->provider.wth),
|
wtap_get_rec(cf->provider.wth),
|
||||||
wtap_buf_ptr(cf->provider.wth), tap_flags);
|
wtap_get_buf_ptr(cf->provider.wth), tap_flags);
|
||||||
}
|
}
|
||||||
if (ret != FALSE) {
|
if (ret != FALSE) {
|
||||||
/* packet successfully read and gone through the "Read Filter" */
|
/* packet successfully read and gone through the "Read Filter" */
|
||||||
|
@ -2836,7 +2836,7 @@ capture_cleanup(int signum _U_)
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
process_packet_first_pass(capture_file *cf, epan_dissect_t *edt,
|
process_packet_first_pass(capture_file *cf, epan_dissect_t *edt,
|
||||||
gint64 offset, struct wtap_pkthdr *whdr,
|
gint64 offset, wtap_rec *rec,
|
||||||
const guchar *pd)
|
const guchar *pd)
|
||||||
{
|
{
|
||||||
frame_data fdlocal;
|
frame_data fdlocal;
|
||||||
|
@ -2852,7 +2852,7 @@ process_packet_first_pass(capture_file *cf, epan_dissect_t *edt,
|
||||||
that all packets can be marked as 'passed'. */
|
that all packets can be marked as 'passed'. */
|
||||||
passed = TRUE;
|
passed = TRUE;
|
||||||
|
|
||||||
frame_data_init(&fdlocal, framenum, whdr, offset, cum_bytes);
|
frame_data_init(&fdlocal, framenum, rec, offset, cum_bytes);
|
||||||
|
|
||||||
/* If we're going to run a read filter or a display filter, set up to
|
/* If we're going to run a read filter or a display filter, set up to
|
||||||
do a dissection and do so. (This is the first pass of two passes
|
do a dissection and do so. (This is the first pass of two passes
|
||||||
|
@ -2884,7 +2884,7 @@ process_packet_first_pass(capture_file *cf, epan_dissect_t *edt,
|
||||||
cf->provider.ref = &ref_frame;
|
cf->provider.ref = &ref_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
epan_dissect_run(edt, cf->cd_t, whdr,
|
epan_dissect_run(edt, cf->cd_t, rec,
|
||||||
frame_tvbuff_new(&cf->provider, &fdlocal, pd),
|
frame_tvbuff_new(&cf->provider, &fdlocal, pd),
|
||||||
&fdlocal, NULL);
|
&fdlocal, NULL);
|
||||||
|
|
||||||
|
@ -2924,7 +2924,7 @@ process_packet_first_pass(capture_file *cf, epan_dissect_t *edt,
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
process_packet_second_pass(capture_file *cf, epan_dissect_t *edt,
|
process_packet_second_pass(capture_file *cf, epan_dissect_t *edt,
|
||||||
frame_data *fdata, struct wtap_pkthdr *phdr,
|
frame_data *fdata, wtap_rec *rec,
|
||||||
Buffer *buf, guint tap_flags)
|
Buffer *buf, guint tap_flags)
|
||||||
{
|
{
|
||||||
column_info *cinfo;
|
column_info *cinfo;
|
||||||
|
@ -2976,7 +2976,7 @@ process_packet_second_pass(capture_file *cf, epan_dissect_t *edt,
|
||||||
fdata->flags.need_colorize = 1;
|
fdata->flags.need_colorize = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
epan_dissect_run_with_taps(edt, cf->cd_t, phdr,
|
epan_dissect_run_with_taps(edt, cf->cd_t, rec,
|
||||||
frame_tvbuff_new_buffer(&cf->provider, fdata, buf),
|
frame_tvbuff_new_buffer(&cf->provider, fdata, buf),
|
||||||
fdata, cinfo);
|
fdata, cinfo);
|
||||||
|
|
||||||
|
@ -3031,12 +3031,12 @@ process_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
||||||
GArray *shb_hdrs = NULL;
|
GArray *shb_hdrs = NULL;
|
||||||
wtapng_iface_descriptions_t *idb_inf = NULL;
|
wtapng_iface_descriptions_t *idb_inf = NULL;
|
||||||
GArray *nrb_hdrs = NULL;
|
GArray *nrb_hdrs = NULL;
|
||||||
struct wtap_pkthdr phdr;
|
wtap_rec rec;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
epan_dissect_t *edt = NULL;
|
epan_dissect_t *edt = NULL;
|
||||||
char *shb_user_appl;
|
char *shb_user_appl;
|
||||||
|
|
||||||
wtap_phdr_init(&phdr);
|
wtap_rec_init(&rec);
|
||||||
|
|
||||||
idb_inf = wtap_file_get_idb_info(cf->provider.wth);
|
idb_inf = wtap_file_get_idb_info(cf->provider.wth);
|
||||||
#ifdef PCAP_NG_DEFAULT
|
#ifdef PCAP_NG_DEFAULT
|
||||||
|
@ -3153,8 +3153,8 @@ process_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
||||||
|
|
||||||
tshark_debug("tshark: reading records for first pass");
|
tshark_debug("tshark: reading records for first pass");
|
||||||
while (wtap_read(cf->provider.wth, &err, &err_info, &data_offset)) {
|
while (wtap_read(cf->provider.wth, &err, &err_info, &data_offset)) {
|
||||||
if (process_packet_first_pass(cf, edt, data_offset, wtap_phdr(cf->provider.wth),
|
if (process_packet_first_pass(cf, edt, data_offset, wtap_get_rec(cf->provider.wth),
|
||||||
wtap_buf_ptr(cf->provider.wth))) {
|
wtap_get_buf_ptr(cf->provider.wth))) {
|
||||||
/* Stop reading if we have the maximum number of packets;
|
/* Stop reading if we have the maximum number of packets;
|
||||||
* When the -c option has not been used, max_packet_count
|
* When the -c option has not been used, max_packet_count
|
||||||
* starts at 0, which practically means, never stop reading.
|
* starts at 0, which practically means, never stop reading.
|
||||||
|
@ -3232,17 +3232,17 @@ process_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
||||||
|
|
||||||
for (framenum = 1; err == 0 && framenum <= cf->count; framenum++) {
|
for (framenum = 1; err == 0 && framenum <= cf->count; framenum++) {
|
||||||
fdata = frame_data_sequence_find(cf->provider.frames, framenum);
|
fdata = frame_data_sequence_find(cf->provider.frames, framenum);
|
||||||
if (wtap_seek_read(cf->provider.wth, fdata->file_off, &phdr, &buf, &err,
|
if (wtap_seek_read(cf->provider.wth, fdata->file_off, &rec, &buf, &err,
|
||||||
&err_info)) {
|
&err_info)) {
|
||||||
tshark_debug("tshark: invoking process_packet_second_pass() for frame #%d", framenum);
|
tshark_debug("tshark: invoking process_packet_second_pass() for frame #%d", framenum);
|
||||||
if (process_packet_second_pass(cf, edt, fdata, &phdr, &buf,
|
if (process_packet_second_pass(cf, edt, fdata, &rec, &buf,
|
||||||
tap_flags)) {
|
tap_flags)) {
|
||||||
/* Either there's no read filtering or this packet passed the
|
/* Either there's no read filtering or this packet passed the
|
||||||
filter, so, if we're writing to a capture file, write
|
filter, so, if we're writing to a capture file, write
|
||||||
this packet out. */
|
this packet out. */
|
||||||
if (pdh != NULL) {
|
if (pdh != NULL) {
|
||||||
tshark_debug("tshark: writing packet #%d to outfile", framenum);
|
tshark_debug("tshark: writing packet #%d to outfile", framenum);
|
||||||
if (!wtap_dump(pdh, &phdr, ws_buffer_start_ptr(&buf), &err, &err_info)) {
|
if (!wtap_dump(pdh, &rec, ws_buffer_start_ptr(&buf), &err, &err_info)) {
|
||||||
/* Error writing to a capture file */
|
/* Error writing to a capture file */
|
||||||
tshark_debug("tshark: error writing to a capture file (%d)", err);
|
tshark_debug("tshark: error writing to a capture file (%d)", err);
|
||||||
|
|
||||||
|
@ -3319,14 +3319,14 @@ process_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
||||||
|
|
||||||
reset_epan_mem(cf, edt, create_proto_tree, print_packet_info && print_details);
|
reset_epan_mem(cf, edt, create_proto_tree, print_packet_info && print_details);
|
||||||
|
|
||||||
if (process_packet_single_pass(cf, edt, data_offset, wtap_phdr(cf->provider.wth),
|
if (process_packet_single_pass(cf, edt, data_offset, wtap_get_rec(cf->provider.wth),
|
||||||
wtap_buf_ptr(cf->provider.wth), tap_flags)) {
|
wtap_get_buf_ptr(cf->provider.wth), tap_flags)) {
|
||||||
/* Either there's no read filtering or this packet passed the
|
/* Either there's no read filtering or this packet passed the
|
||||||
filter, so, if we're writing to a capture file, write
|
filter, so, if we're writing to a capture file, write
|
||||||
this packet out. */
|
this packet out. */
|
||||||
if (pdh != NULL) {
|
if (pdh != NULL) {
|
||||||
tshark_debug("tshark: writing packet #%d to outfile", framenum);
|
tshark_debug("tshark: writing packet #%d to outfile", framenum);
|
||||||
if (!wtap_dump(pdh, wtap_phdr(cf->provider.wth), wtap_buf_ptr(cf->provider.wth), &err, &err_info)) {
|
if (!wtap_dump(pdh, wtap_get_rec(cf->provider.wth), wtap_get_buf_ptr(cf->provider.wth), &err, &err_info)) {
|
||||||
/* Error writing to a capture file */
|
/* Error writing to a capture file */
|
||||||
tshark_debug("tshark: error writing to a capture file (%d)", err);
|
tshark_debug("tshark: error writing to a capture file (%d)", err);
|
||||||
cfile_write_failure_message("TShark", cf->filename, save_file,
|
cfile_write_failure_message("TShark", cf->filename, save_file,
|
||||||
|
@ -3357,7 +3357,7 @@ process_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wtap_phdr_cleanup(&phdr);
|
wtap_rec_cleanup(&rec);
|
||||||
|
|
||||||
if (err != 0 || err_pass1 != 0) {
|
if (err != 0 || err_pass1 != 0) {
|
||||||
tshark_debug("tshark: something failed along the line (%d)", err);
|
tshark_debug("tshark: something failed along the line (%d)", err);
|
||||||
|
@ -3430,7 +3430,7 @@ out:
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
process_packet_single_pass(capture_file *cf, epan_dissect_t *edt, gint64 offset,
|
process_packet_single_pass(capture_file *cf, epan_dissect_t *edt, gint64 offset,
|
||||||
struct wtap_pkthdr *whdr, const guchar *pd,
|
wtap_rec *rec, const guchar *pd,
|
||||||
guint tap_flags)
|
guint tap_flags)
|
||||||
{
|
{
|
||||||
frame_data fdata;
|
frame_data fdata;
|
||||||
|
@ -3445,7 +3445,7 @@ process_packet_single_pass(capture_file *cf, epan_dissect_t *edt, gint64 offset,
|
||||||
that all packets can be marked as 'passed'. */
|
that all packets can be marked as 'passed'. */
|
||||||
passed = TRUE;
|
passed = TRUE;
|
||||||
|
|
||||||
frame_data_init(&fdata, cf->count, whdr, offset, cum_bytes);
|
frame_data_init(&fdata, cf->count, rec, offset, cum_bytes);
|
||||||
|
|
||||||
/* If we're going to print packet information, or we're going to
|
/* If we're going to print packet information, or we're going to
|
||||||
run a read filter, or we're going to process taps, set up to
|
run a read filter, or we're going to process taps, set up to
|
||||||
|
@ -3493,7 +3493,7 @@ process_packet_single_pass(capture_file *cf, epan_dissect_t *edt, gint64 offset,
|
||||||
fdata.flags.need_colorize = 1;
|
fdata.flags.need_colorize = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
epan_dissect_run_with_taps(edt, cf->cd_t, whdr,
|
epan_dissect_run_with_taps(edt, cf->cd_t, rec,
|
||||||
frame_tvbuff_new(&cf->provider, &fdata, pd),
|
frame_tvbuff_new(&cf->provider, &fdata, pd),
|
||||||
&fdata, cinfo);
|
&fdata, cinfo);
|
||||||
|
|
||||||
|
|
|
@ -180,14 +180,14 @@ preview_do(GtkWidget *prev, wtap *wth)
|
||||||
gchar first_buff[PREVIEW_STR_MAX];
|
gchar first_buff[PREVIEW_STR_MAX];
|
||||||
time_t ti_time;
|
time_t ti_time;
|
||||||
struct tm *ti_tm;
|
struct tm *ti_tm;
|
||||||
const struct wtap_pkthdr *phdr;
|
const wtap_rec *rec;
|
||||||
|
|
||||||
|
|
||||||
time(&time_preview);
|
time(&time_preview);
|
||||||
while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) {
|
while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) {
|
||||||
phdr = wtap_phdr(wth);
|
rec = wtap_get_rec(wth);
|
||||||
if (phdr->presence_flags & WTAP_HAS_TS) {
|
if (rec->presence_flags & WTAP_HAS_TS) {
|
||||||
cur_time = nstime_to_sec(&phdr->ts);
|
cur_time = nstime_to_sec(&rec->ts);
|
||||||
if (!have_times) {
|
if (!have_times) {
|
||||||
start_time = cur_time;
|
start_time = cur_time;
|
||||||
stop_time = cur_time;
|
stop_time = cur_time;
|
||||||
|
|
|
@ -3569,7 +3569,7 @@ void iax2_analysis_cb(GtkAction *action _U_, gpointer user_data _U_)
|
||||||
return; /* error reading the record */
|
return; /* error reading the record */
|
||||||
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
||||||
epan_dissect_prime_with_dfilter(&edt, sfcode);
|
epan_dissect_prime_with_dfilter(&edt, sfcode);
|
||||||
epan_dissect_run(&edt, cf->cd_t, &cf->phdr,
|
epan_dissect_run(&edt, cf->cd_t, &cf->rec,
|
||||||
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
|
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
|
||||||
fdata, NULL);
|
fdata, NULL);
|
||||||
|
|
||||||
|
|
|
@ -529,7 +529,7 @@ get_ip_address_list_from_packet_list_row(gpointer data)
|
||||||
epan_dissect_init(&edt, cfile.epan, FALSE, FALSE);
|
epan_dissect_init(&edt, cfile.epan, FALSE, FALSE);
|
||||||
col_custom_prime_edt(&edt, &cfile.cinfo);
|
col_custom_prime_edt(&edt, &cfile.cinfo);
|
||||||
|
|
||||||
epan_dissect_run(&edt, cfile.cd_t, &cfile.phdr,
|
epan_dissect_run(&edt, cfile.cd_t, &cfile.rec,
|
||||||
frame_tvbuff_new_buffer(&cfile.provider, fdata, &cfile.buf),
|
frame_tvbuff_new_buffer(&cfile.provider, fdata, &cfile.buf),
|
||||||
fdata, &cfile.cinfo);
|
fdata, &cfile.cinfo);
|
||||||
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
|
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
|
||||||
|
@ -571,7 +571,7 @@ get_filter_from_packet_list_row_and_column(gpointer data)
|
||||||
epan_dissect_init(&edt, cfile.epan, have_custom_cols(&cfile.cinfo), FALSE);
|
epan_dissect_init(&edt, cfile.epan, have_custom_cols(&cfile.cinfo), FALSE);
|
||||||
col_custom_prime_edt(&edt, &cfile.cinfo);
|
col_custom_prime_edt(&edt, &cfile.cinfo);
|
||||||
|
|
||||||
epan_dissect_run(&edt, cfile.cd_t, &cfile.phdr,
|
epan_dissect_run(&edt, cfile.cd_t, &cfile.rec,
|
||||||
frame_tvbuff_new_buffer(&cfile.provider, fdata, &cfile.buf),
|
frame_tvbuff_new_buffer(&cfile.provider, fdata, &cfile.buf),
|
||||||
fdata, &cfile.cinfo);
|
fdata, &cfile.cinfo);
|
||||||
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
|
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
|
||||||
|
|
|
@ -1103,14 +1103,14 @@ packet_list_dissect_and_cache_record(PacketList *packet_list, PacketListRecord *
|
||||||
column_info *cinfo;
|
column_info *cinfo;
|
||||||
gint col;
|
gint col;
|
||||||
gboolean create_proto_tree;
|
gboolean create_proto_tree;
|
||||||
struct wtap_pkthdr phdr; /* Packet header */
|
wtap_rec rec; /* Record metadata */
|
||||||
Buffer buf; /* Packet data */
|
Buffer buf; /* Record data */
|
||||||
gboolean dissect_columns = (record->col_text == NULL);
|
gboolean dissect_columns = (record->col_text == NULL);
|
||||||
|
|
||||||
g_return_if_fail(packet_list);
|
g_return_if_fail(packet_list);
|
||||||
g_return_if_fail(PACKETLIST_IS_LIST(packet_list));
|
g_return_if_fail(PACKETLIST_IS_LIST(packet_list));
|
||||||
|
|
||||||
wtap_phdr_init(&phdr);
|
wtap_rec_init(&rec);
|
||||||
|
|
||||||
fdata = record->fdata;
|
fdata = record->fdata;
|
||||||
|
|
||||||
|
@ -1123,7 +1123,7 @@ packet_list_dissect_and_cache_record(PacketList *packet_list, PacketListRecord *
|
||||||
cinfo = NULL;
|
cinfo = NULL;
|
||||||
|
|
||||||
ws_buffer_init(&buf, 1500);
|
ws_buffer_init(&buf, 1500);
|
||||||
if (!cf_read_record_r(&cfile, fdata, &phdr, &buf)) {
|
if (!cf_read_record_r(&cfile, fdata, &rec, &buf)) {
|
||||||
/*
|
/*
|
||||||
* Error reading the record.
|
* Error reading the record.
|
||||||
*
|
*
|
||||||
|
@ -1176,7 +1176,7 @@ packet_list_dissect_and_cache_record(PacketList *packet_list, PacketListRecord *
|
||||||
* XXX - need to catch an OutOfMemoryError exception and
|
* XXX - need to catch an OutOfMemoryError exception and
|
||||||
* attempt to recover from it.
|
* attempt to recover from it.
|
||||||
*/
|
*/
|
||||||
epan_dissect_run(&edt, cfile.cd_t, &phdr,
|
epan_dissect_run(&edt, cfile.cd_t, &rec,
|
||||||
frame_tvbuff_new_buffer(&cfile.provider, fdata, &buf),
|
frame_tvbuff_new_buffer(&cfile.provider, fdata, &buf),
|
||||||
fdata, cinfo);
|
fdata, cinfo);
|
||||||
|
|
||||||
|
@ -1192,7 +1192,7 @@ packet_list_dissect_and_cache_record(PacketList *packet_list, PacketListRecord *
|
||||||
record->colorized = TRUE;
|
record->colorized = TRUE;
|
||||||
|
|
||||||
epan_dissect_cleanup(&edt);
|
epan_dissect_cleanup(&edt);
|
||||||
wtap_phdr_cleanup(&phdr);
|
wtap_rec_cleanup(&rec);
|
||||||
ws_buffer_free(&buf);
|
ws_buffer_free(&buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,8 +76,8 @@
|
||||||
/* Data structure holding information about a packet-detail window. */
|
/* Data structure holding information about a packet-detail window. */
|
||||||
struct PacketWinData {
|
struct PacketWinData {
|
||||||
frame_data *frame; /* The frame being displayed */
|
frame_data *frame; /* The frame being displayed */
|
||||||
struct wtap_pkthdr phdr; /* Packet header */
|
wtap_rec rec; /* Record metadata */
|
||||||
guint8 *pd; /* Packet data */
|
guint8 *pd; /* Record data */
|
||||||
GtkWidget *main;
|
GtkWidget *main;
|
||||||
GtkWidget *tv_scrollw;
|
GtkWidget *tv_scrollw;
|
||||||
GtkWidget *tree_view;
|
GtkWidget *tree_view;
|
||||||
|
@ -159,7 +159,7 @@ redissect_packet_window(gpointer object, gpointer user_data _U_)
|
||||||
proto_tree_draw(NULL, DataPtr->tree_view);
|
proto_tree_draw(NULL, DataPtr->tree_view);
|
||||||
epan_dissect_cleanup(&(DataPtr->edt));
|
epan_dissect_cleanup(&(DataPtr->edt));
|
||||||
epan_dissect_init(&(DataPtr->edt), cfile.epan, TRUE, TRUE);
|
epan_dissect_init(&(DataPtr->edt), cfile.epan, TRUE, TRUE);
|
||||||
epan_dissect_run(&(DataPtr->edt), cfile.cd_t, &DataPtr->phdr,
|
epan_dissect_run(&(DataPtr->edt), cfile.cd_t, &DataPtr->rec,
|
||||||
frame_tvbuff_new(&cfile.provider, DataPtr->frame, DataPtr->pd),
|
frame_tvbuff_new(&cfile.provider, DataPtr->frame, DataPtr->pd),
|
||||||
DataPtr->frame, NULL);
|
DataPtr->frame, NULL);
|
||||||
add_byte_views(&(DataPtr->edt), DataPtr->tree_view, DataPtr->bv_nb_ptr);
|
add_byte_views(&(DataPtr->edt), DataPtr->tree_view, DataPtr->bv_nb_ptr);
|
||||||
|
@ -224,12 +224,12 @@ void new_packet_window(GtkWidget *w _U_, gboolean reference, gboolean editable _
|
||||||
|
|
||||||
/* XXX, protect cfile.epan from closing (ref counting?) */
|
/* XXX, protect cfile.epan from closing (ref counting?) */
|
||||||
DataPtr->frame = fd;
|
DataPtr->frame = fd;
|
||||||
DataPtr->phdr = cfile.phdr;
|
DataPtr->rec = cfile.rec;
|
||||||
DataPtr->pd = (guint8 *)g_malloc(DataPtr->frame->cap_len);
|
DataPtr->pd = (guint8 *)g_malloc(DataPtr->frame->cap_len);
|
||||||
memcpy(DataPtr->pd, ws_buffer_start_ptr(&cfile.buf), DataPtr->frame->cap_len);
|
memcpy(DataPtr->pd, ws_buffer_start_ptr(&cfile.buf), DataPtr->frame->cap_len);
|
||||||
|
|
||||||
epan_dissect_init(&(DataPtr->edt), cfile.epan, TRUE, TRUE);
|
epan_dissect_init(&(DataPtr->edt), cfile.epan, TRUE, TRUE);
|
||||||
epan_dissect_run(&(DataPtr->edt), cfile.cd_t, &DataPtr->phdr,
|
epan_dissect_run(&(DataPtr->edt), cfile.cd_t, &DataPtr->rec,
|
||||||
frame_tvbuff_new(&cfile.provider, DataPtr->frame, DataPtr->pd),
|
frame_tvbuff_new(&cfile.provider, DataPtr->frame, DataPtr->pd),
|
||||||
DataPtr->frame, &cfile.cinfo);
|
DataPtr->frame, &cfile.cinfo);
|
||||||
epan_dissect_fill_in_columns(&(DataPtr->edt), FALSE, TRUE);
|
epan_dissect_fill_in_columns(&(DataPtr->edt), FALSE, TRUE);
|
||||||
|
|
|
@ -3900,7 +3900,7 @@ rtp_analysis_cb(GtkAction *action _U_, gpointer user_data _U_)
|
||||||
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
||||||
epan_dissect_prime_with_dfilter(&edt, sfcode);
|
epan_dissect_prime_with_dfilter(&edt, sfcode);
|
||||||
epan_dissect_prime_with_hfid(&edt, hfid_rtp_ssrc);
|
epan_dissect_prime_with_hfid(&edt, hfid_rtp_ssrc);
|
||||||
epan_dissect_run(&edt, cf->cd_t, &cf->phdr,
|
epan_dissect_run(&edt, cf->cd_t, &cf->rec,
|
||||||
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
|
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
|
||||||
fdata, NULL);
|
fdata, NULL);
|
||||||
|
|
||||||
|
|
|
@ -1003,7 +1003,7 @@ sctp_analyse_cb(struct sctp_analyse *u_data, gboolean ext)
|
||||||
|
|
||||||
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
||||||
epan_dissect_prime_with_dfilter(&edt, sfcode);
|
epan_dissect_prime_with_dfilter(&edt, sfcode);
|
||||||
epan_dissect_run(&edt, cf->cd_t, &cf->phdr,
|
epan_dissect_run(&edt, cf->cd_t, &cf->rec,
|
||||||
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
|
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
|
||||||
fdata, NULL);
|
fdata, NULL);
|
||||||
|
|
||||||
|
|
|
@ -150,22 +150,22 @@ process_tree(proto_tree *protocol_tree, ph_stats_t* ps)
|
||||||
process_record(capture_file *cf, frame_data *frame, column_info *cinfo, ph_stats_t* ps)
|
process_record(capture_file *cf, frame_data *frame, column_info *cinfo, ph_stats_t* ps)
|
||||||
{
|
{
|
||||||
epan_dissect_t edt;
|
epan_dissect_t edt;
|
||||||
struct wtap_pkthdr phdr;
|
wtap_rec rec;
|
||||||
Buffer buf;
|
Buffer buf;
|
||||||
double cur_time;
|
double cur_time;
|
||||||
|
|
||||||
wtap_phdr_init(&phdr);
|
wtap_rec_init(&rec);
|
||||||
|
|
||||||
/* Load the record from the capture file */
|
/* Load the record from the capture file */
|
||||||
ws_buffer_init(&buf, 1500);
|
ws_buffer_init(&buf, 1500);
|
||||||
if (!cf_read_record_r(cf, frame, &phdr, &buf))
|
if (!cf_read_record_r(cf, frame, &rec, &buf))
|
||||||
return FALSE; /* failure */
|
return FALSE; /* failure */
|
||||||
|
|
||||||
/* Dissect the record tree not visible */
|
/* Dissect the record tree not visible */
|
||||||
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
||||||
/* Don't fake protocols. We need them for the protocol hierarchy */
|
/* Don't fake protocols. We need them for the protocol hierarchy */
|
||||||
epan_dissect_fake_protocols(&edt, FALSE);
|
epan_dissect_fake_protocols(&edt, FALSE);
|
||||||
epan_dissect_run(&edt, cf->cd_t, &phdr,
|
epan_dissect_run(&edt, cf->cd_t, &rec,
|
||||||
frame_tvbuff_new_buffer(&cf->provider, frame, &buf),
|
frame_tvbuff_new_buffer(&cf->provider, frame, &buf),
|
||||||
frame, cinfo);
|
frame, cinfo);
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ process_record(capture_file *cf, frame_data *frame, column_info *cinfo, ph_stats
|
||||||
|
|
||||||
/* Free our memory. */
|
/* Free our memory. */
|
||||||
epan_dissect_cleanup(&edt);
|
epan_dissect_cleanup(&edt);
|
||||||
wtap_phdr_cleanup(&phdr);
|
wtap_rec_cleanup(&rec);
|
||||||
ws_buffer_free(&buf);
|
ws_buffer_free(&buf);
|
||||||
|
|
||||||
return TRUE; /* success */
|
return TRUE; /* success */
|
||||||
|
|
|
@ -69,7 +69,7 @@ void AddressEditorFrame::editAddresses(CaptureFile &cf, int column)
|
||||||
epan_dissect_init(&edt, cap_file_->epan, FALSE, FALSE);
|
epan_dissect_init(&edt, cap_file_->epan, FALSE, FALSE);
|
||||||
col_custom_prime_edt(&edt, &cap_file_->cinfo);
|
col_custom_prime_edt(&edt, &cap_file_->cinfo);
|
||||||
|
|
||||||
epan_dissect_run(&edt, cap_file_->cd_t, &cap_file_->phdr,
|
epan_dissect_run(&edt, cap_file_->cd_t, &cap_file_->rec,
|
||||||
frame_tvbuff_new_buffer(&cap_file_->provider, cap_file_->current_frame, &cap_file_->buf),
|
frame_tvbuff_new_buffer(&cap_file_->provider, cap_file_->current_frame, &cap_file_->buf),
|
||||||
cap_file_->current_frame, &cap_file_->cinfo);
|
cap_file_->current_frame, &cap_file_->cinfo);
|
||||||
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
|
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
|
||||||
|
|
|
@ -236,12 +236,15 @@ gboolean BluetoothAttServerAttributesDialog::tapPacket(void *tapinfo_ptr, packet
|
||||||
if (dialog->file_closed_)
|
if (dialog->file_closed_)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID) {
|
if (pinfo->rec->rec_type != REC_TYPE_PACKET)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID) {
|
||||||
gchar *interface;
|
gchar *interface;
|
||||||
const char *interface_name;
|
const char *interface_name;
|
||||||
|
|
||||||
interface_name = epan_get_interface_name(pinfo->epan, pinfo->phdr->interface_id);
|
interface_name = epan_get_interface_name(pinfo->epan, pinfo->rec->rec_header.packet_header.interface_id);
|
||||||
interface = wmem_strdup_printf(wmem_packet_scope(), "%u: %s", pinfo->phdr->interface_id, interface_name);
|
interface = wmem_strdup_printf(wmem_packet_scope(), "%u: %s", pinfo->rec->rec_header.packet_header.interface_id, interface_name);
|
||||||
|
|
||||||
if (dialog->ui->interfaceComboBox->findText(interface) == -1)
|
if (dialog->ui->interfaceComboBox->findText(interface) == -1)
|
||||||
dialog->ui->interfaceComboBox->addItem(interface);
|
dialog->ui->interfaceComboBox->addItem(interface);
|
||||||
|
@ -261,7 +264,7 @@ gboolean BluetoothAttServerAttributesDialog::tapPacket(void *tapinfo_ptr, packet
|
||||||
|
|
||||||
if (addr && dialog->ui->deviceComboBox->currentIndex() > 0) {
|
if (addr && dialog->ui->deviceComboBox->currentIndex() > 0) {
|
||||||
if (dialog->ui->deviceComboBox->currentText() != addr)
|
if (dialog->ui->deviceComboBox->currentText() != addr)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle.sprintf("0x%04x", tap_handles->handle);
|
handle.sprintf("0x%04x", tap_handles->handle);
|
||||||
|
|
|
@ -265,12 +265,15 @@ gboolean BluetoothDevicesDialog::tapPacket(void *tapinfo_ptr, packet_info *pinfo
|
||||||
if (dialog->file_closed_)
|
if (dialog->file_closed_)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID) {
|
if (pinfo->rec->rec_type != REC_TYPE_PACKET)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID) {
|
||||||
gchar *interface;
|
gchar *interface;
|
||||||
const char *interface_name;
|
const char *interface_name;
|
||||||
|
|
||||||
interface_name = epan_get_interface_name(pinfo->epan, pinfo->phdr->interface_id);
|
interface_name = epan_get_interface_name(pinfo->epan, pinfo->rec->rec_header.packet_header.interface_id);
|
||||||
interface = wmem_strdup_printf(wmem_packet_scope(), "%u: %s", pinfo->phdr->interface_id, interface_name);
|
interface = wmem_strdup_printf(wmem_packet_scope(), "%u: %s", pinfo->rec->rec_header.packet_header.interface_id, interface_name);
|
||||||
|
|
||||||
if (dialog->ui->interfaceComboBox->findText(interface) == -1)
|
if (dialog->ui->interfaceComboBox->findText(interface) == -1)
|
||||||
dialog->ui->interfaceComboBox->addItem(interface);
|
dialog->ui->interfaceComboBox->addItem(interface);
|
||||||
|
|
|
@ -346,14 +346,17 @@ gboolean BluetoothHciSummaryDialog::tapPacket(void *tapinfo_ptr, packet_info *pi
|
||||||
if (dialog->file_closed_)
|
if (dialog->file_closed_)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
if (pinfo->rec->rec_type != REC_TYPE_PACKET)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
name = tr("Unknown");
|
name = tr("Unknown");
|
||||||
|
|
||||||
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID) {
|
if (pinfo->rec->presence_flags & WTAP_HAS_INTERFACE_ID) {
|
||||||
gchar *interface;
|
gchar *interface;
|
||||||
const char *interface_name;
|
const char *interface_name;
|
||||||
|
|
||||||
interface_name = epan_get_interface_name(pinfo->epan, pinfo->phdr->interface_id);
|
interface_name = epan_get_interface_name(pinfo->epan, pinfo->rec->rec_header.packet_header.interface_id);
|
||||||
interface = wmem_strdup_printf(wmem_packet_scope(), "%u: %s", pinfo->phdr->interface_id, interface_name);
|
interface = wmem_strdup_printf(wmem_packet_scope(), "%u: %s", pinfo->rec->rec_header.packet_header.interface_id, interface_name);
|
||||||
|
|
||||||
if (dialog->ui->interfaceComboBox->findText(interface) == -1)
|
if (dialog->ui->interfaceComboBox->findText(interface) == -1)
|
||||||
dialog->ui->interfaceComboBox->addItem(interface);
|
dialog->ui->interfaceComboBox->addItem(interface);
|
||||||
|
|
|
@ -690,7 +690,7 @@ void CaptureFileDialog::preview(const QString & path)
|
||||||
int err = 0;
|
int err = 0;
|
||||||
gchar *err_info;
|
gchar *err_info;
|
||||||
gint64 data_offset;
|
gint64 data_offset;
|
||||||
const struct wtap_pkthdr *phdr;
|
const wtap_rec *rec;
|
||||||
double start_time = 0; /* seconds, with nsec resolution */
|
double start_time = 0; /* seconds, with nsec resolution */
|
||||||
double stop_time = 0; /* seconds, with nsec resolution */
|
double stop_time = 0; /* seconds, with nsec resolution */
|
||||||
gboolean have_times = FALSE;
|
gboolean have_times = FALSE;
|
||||||
|
@ -747,9 +747,9 @@ void CaptureFileDialog::preview(const QString & path)
|
||||||
|
|
||||||
time(&time_preview);
|
time(&time_preview);
|
||||||
while ((wtap_read(wth, &err, &err_info, &data_offset))) {
|
while ((wtap_read(wth, &err, &err_info, &data_offset))) {
|
||||||
phdr = wtap_phdr(wth);
|
rec = wtap_get_rec(wth);
|
||||||
if (phdr->presence_flags & WTAP_HAS_TS) {
|
if (rec->presence_flags & WTAP_HAS_TS) {
|
||||||
cur_time = nstime_to_sec(&phdr->ts);
|
cur_time = nstime_to_sec(&rec->ts);
|
||||||
if (!have_times) {
|
if (!have_times) {
|
||||||
start_time = cur_time;
|
start_time = cur_time;
|
||||||
stop_time = cur_time;
|
stop_time = cur_time;
|
||||||
|
|
|
@ -321,7 +321,7 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) :
|
||||||
|
|
||||||
epan_dissect_init(&edt, cap_file_.capFile()->epan, TRUE, FALSE);
|
epan_dissect_init(&edt, cap_file_.capFile()->epan, TRUE, FALSE);
|
||||||
epan_dissect_prime_with_dfilter(&edt, sfcode);
|
epan_dissect_prime_with_dfilter(&edt, sfcode);
|
||||||
epan_dissect_run(&edt, cap_file_.capFile()->cd_t, &cap_file_.capFile()->phdr,
|
epan_dissect_run(&edt, cap_file_.capFile()->cd_t, &cap_file_.capFile()->rec,
|
||||||
frame_tvbuff_new_buffer(&cap_file_.capFile()->provider, fdata, &cap_file_.capFile()->buf),
|
frame_tvbuff_new_buffer(&cap_file_.capFile()->provider, fdata, &cap_file_.capFile()->buf),
|
||||||
fdata, NULL);
|
fdata, NULL);
|
||||||
|
|
||||||
|
|
|
@ -99,8 +99,8 @@ void PacketListRecord::dissect(capture_file *cap_file, bool dissect_color)
|
||||||
epan_dissect_t edt;
|
epan_dissect_t edt;
|
||||||
column_info *cinfo = NULL;
|
column_info *cinfo = NULL;
|
||||||
gboolean create_proto_tree;
|
gboolean create_proto_tree;
|
||||||
struct wtap_pkthdr phdr; /* Packet header */
|
wtap_rec rec; /* Record metadata */
|
||||||
Buffer buf; /* Packet data */
|
Buffer buf; /* Record data */
|
||||||
|
|
||||||
if (!col_text_) col_text_ = new ColumnTextList;
|
if (!col_text_) col_text_ = new ColumnTextList;
|
||||||
gboolean dissect_columns = col_text_->isEmpty() || data_ver_ != col_data_ver_;
|
gboolean dissect_columns = col_text_->isEmpty() || data_ver_ != col_data_ver_;
|
||||||
|
@ -109,14 +109,14 @@ void PacketListRecord::dissect(capture_file *cap_file, bool dissect_color)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&phdr, 0, sizeof(struct wtap_pkthdr));
|
memset(&rec, 0, sizeof rec);
|
||||||
|
|
||||||
if (dissect_columns) {
|
if (dissect_columns) {
|
||||||
cinfo = &cap_file->cinfo;
|
cinfo = &cap_file->cinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
ws_buffer_init(&buf, 1500);
|
ws_buffer_init(&buf, 1500);
|
||||||
if (!cf_read_record_r(cap_file, fdata_, &phdr, &buf)) {
|
if (!cf_read_record_r(cap_file, fdata_, &rec, &buf)) {
|
||||||
/*
|
/*
|
||||||
* Error reading the record.
|
* Error reading the record.
|
||||||
*
|
*
|
||||||
|
@ -172,7 +172,7 @@ void PacketListRecord::dissect(capture_file *cap_file, bool dissect_color)
|
||||||
* XXX - need to catch an OutOfMemoryError exception and
|
* XXX - need to catch an OutOfMemoryError exception and
|
||||||
* attempt to recover from it.
|
* attempt to recover from it.
|
||||||
*/
|
*/
|
||||||
epan_dissect_run(&edt, cap_file->cd_t, &phdr,
|
epan_dissect_run(&edt, cap_file->cd_t, &rec,
|
||||||
frame_tvbuff_new_buffer(&cap_file->provider, fdata_, &buf),
|
frame_tvbuff_new_buffer(&cap_file->provider, fdata_, &buf),
|
||||||
fdata_, cinfo);
|
fdata_, cinfo);
|
||||||
|
|
||||||
|
|
|
@ -35,13 +35,12 @@ PacketDialog::PacketDialog(QWidget &parent, CaptureFile &cf, frame_data *fdata)
|
||||||
ui(new Ui::PacketDialog),
|
ui(new Ui::PacketDialog),
|
||||||
proto_tree_(NULL),
|
proto_tree_(NULL),
|
||||||
byte_view_tab_(NULL),
|
byte_view_tab_(NULL),
|
||||||
phdr_(wtap_pkthdr()),
|
rec_(wtap_rec()),
|
||||||
packet_data_(NULL)
|
packet_data_(NULL)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
loadGeometry(parent.width() * 4 / 5, parent.height() * 4 / 5);
|
loadGeometry(parent.width() * 4 / 5, parent.height() * 4 / 5);
|
||||||
ui->hintLabel->setSmallText();
|
ui->hintLabel->setSmallText();
|
||||||
phdr_.ft_specific_data = Buffer();
|
|
||||||
edt_.session = NULL;
|
edt_.session = NULL;
|
||||||
edt_.tvb = NULL;
|
edt_.tvb = NULL;
|
||||||
edt_.tree = NULL;
|
edt_.tree = NULL;
|
||||||
|
@ -55,14 +54,14 @@ PacketDialog::PacketDialog(QWidget &parent, CaptureFile &cf, frame_data *fdata)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr_ = cap_file_.capFile()->phdr;
|
rec_ = cap_file_.capFile()->rec;
|
||||||
packet_data_ = (guint8 *) g_memdup(ws_buffer_start_ptr(&(cap_file_.capFile()->buf)), fdata->cap_len);
|
packet_data_ = (guint8 *) g_memdup(ws_buffer_start_ptr(&(cap_file_.capFile()->buf)), fdata->cap_len);
|
||||||
|
|
||||||
/* proto tree, visible. We need a proto tree if there's custom columns */
|
/* proto tree, visible. We need a proto tree if there's custom columns */
|
||||||
epan_dissect_init(&edt_, cap_file_.capFile()->epan, TRUE, TRUE);
|
epan_dissect_init(&edt_, cap_file_.capFile()->epan, TRUE, TRUE);
|
||||||
col_custom_prime_edt(&edt_, &(cap_file_.capFile()->cinfo));
|
col_custom_prime_edt(&edt_, &(cap_file_.capFile()->cinfo));
|
||||||
|
|
||||||
epan_dissect_run(&edt_, cap_file_.capFile()->cd_t, &phdr_,
|
epan_dissect_run(&edt_, cap_file_.capFile()->cd_t, &rec_,
|
||||||
frame_tvbuff_new(&cap_file_.capFile()->provider, fdata, packet_data_),
|
frame_tvbuff_new(&cap_file_.capFile()->provider, fdata, packet_data_),
|
||||||
fdata, &(cap_file_.capFile()->cinfo));
|
fdata, &(cap_file_.capFile()->cinfo));
|
||||||
epan_dissect_fill_in_columns(&edt_, TRUE, TRUE);
|
epan_dissect_fill_in_columns(&edt_, TRUE, TRUE);
|
||||||
|
|
|
@ -44,7 +44,7 @@ private:
|
||||||
ProtoTree *proto_tree_;
|
ProtoTree *proto_tree_;
|
||||||
ByteViewTab *byte_view_tab_;
|
ByteViewTab *byte_view_tab_;
|
||||||
epan_dissect_t edt_;
|
epan_dissect_t edt_;
|
||||||
struct wtap_pkthdr phdr_;
|
wtap_rec rec_;
|
||||||
guint8 *packet_data_;
|
guint8 *packet_data_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -985,7 +985,7 @@ QString PacketList::getFilterFromRowAndColumn()
|
||||||
epan_dissect_init(&edt, cap_file_->epan, have_custom_cols(&cap_file_->cinfo), FALSE);
|
epan_dissect_init(&edt, cap_file_->epan, have_custom_cols(&cap_file_->cinfo), FALSE);
|
||||||
col_custom_prime_edt(&edt, &cap_file_->cinfo);
|
col_custom_prime_edt(&edt, &cap_file_->cinfo);
|
||||||
|
|
||||||
epan_dissect_run(&edt, cap_file_->cd_t, &cap_file_->phdr,
|
epan_dissect_run(&edt, cap_file_->cd_t, &cap_file_->rec,
|
||||||
frame_tvbuff_new_buffer(&cap_file_->provider, fdata, &cap_file_->buf),
|
frame_tvbuff_new_buffer(&cap_file_->provider, fdata, &cap_file_->buf),
|
||||||
fdata, &cap_file_->cinfo);
|
fdata, &cap_file_->cinfo);
|
||||||
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
|
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
|
||||||
|
|
|
@ -1599,7 +1599,7 @@ void RtpAnalysisDialog::findStreams()
|
||||||
epan_dissect_init(&edt, cap_file_.capFile()->epan, TRUE, FALSE);
|
epan_dissect_init(&edt, cap_file_.capFile()->epan, TRUE, FALSE);
|
||||||
epan_dissect_prime_with_dfilter(&edt, sfcode);
|
epan_dissect_prime_with_dfilter(&edt, sfcode);
|
||||||
epan_dissect_prime_with_hfid(&edt, hfid_rtp_ssrc);
|
epan_dissect_prime_with_hfid(&edt, hfid_rtp_ssrc);
|
||||||
epan_dissect_run(&edt, cap_file_.capFile()->cd_t, &cap_file_.capFile()->phdr,
|
epan_dissect_run(&edt, cap_file_.capFile()->cd_t, &cap_file_.capFile()->rec,
|
||||||
frame_tvbuff_new_buffer(&cap_file_.capFile()->provider, fdata, &cap_file_.capFile()->buf),
|
frame_tvbuff_new_buffer(&cap_file_.capFile()->provider, fdata, &cap_file_.capFile()->buf),
|
||||||
fdata, NULL);
|
fdata, NULL);
|
||||||
|
|
||||||
|
|
|
@ -40,14 +40,14 @@ void FrameInformation::loadFrameTree()
|
||||||
if (!cf_read_record(cap_file_->capFile(), fi_))
|
if (!cf_read_record(cap_file_->capFile(), fi_))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
struct wtap_pkthdr phdr_ = cap_file_->capFile()->phdr;
|
wtap_rec rec_ = cap_file_->capFile()->rec;
|
||||||
packet_data_ = (guint8 *) g_memdup(ws_buffer_start_ptr(&(cap_file_->capFile()->buf)), fi_->cap_len);
|
packet_data_ = (guint8 *) g_memdup(ws_buffer_start_ptr(&(cap_file_->capFile()->buf)), fi_->cap_len);
|
||||||
|
|
||||||
/* proto tree, visible. We need a proto tree if there's custom columns */
|
/* proto tree, visible. We need a proto tree if there's custom columns */
|
||||||
epan_dissect_init(&edt_, cap_file_->capFile()->epan, TRUE, TRUE);
|
epan_dissect_init(&edt_, cap_file_->capFile()->epan, TRUE, TRUE);
|
||||||
col_custom_prime_edt(&edt_, &(cap_file_->capFile()->cinfo));
|
col_custom_prime_edt(&edt_, &(cap_file_->capFile()->cinfo));
|
||||||
|
|
||||||
epan_dissect_run(&edt_, cap_file_->capFile()->cd_t, &phdr_,
|
epan_dissect_run(&edt_, cap_file_->capFile()->cd_t, &rec_,
|
||||||
frame_tvbuff_new(&cap_file_->capFile()->provider, fi_, packet_data_),
|
frame_tvbuff_new(&cap_file_->capFile()->provider, fi_, packet_data_),
|
||||||
fi_, &(cap_file_->capFile()->cinfo));
|
fi_, &(cap_file_->capFile()->cinfo));
|
||||||
epan_dissect_fill_in_columns(&edt_, TRUE, TRUE);
|
epan_dissect_fill_in_columns(&edt_, TRUE, TRUE);
|
||||||
|
|
|
@ -130,7 +130,7 @@ rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf,
|
||||||
|
|
||||||
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
||||||
epan_dissect_prime_with_dfilter(&edt, sfcode);
|
epan_dissect_prime_with_dfilter(&edt, sfcode);
|
||||||
epan_dissect_run_with_taps(&edt, cf->cd_t, &cf->phdr,
|
epan_dissect_run_with_taps(&edt, cf->cd_t, &cf->rec,
|
||||||
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
|
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
|
||||||
fdata, NULL);
|
fdata, NULL);
|
||||||
rel_ts = edt.pi.rel_ts;
|
rel_ts = edt.pi.rel_ts;
|
||||||
|
|
|
@ -306,7 +306,7 @@ select_tcpip_session(capture_file *cf, struct segment *hdrs)
|
||||||
|
|
||||||
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
||||||
epan_dissect_prime_with_dfilter(&edt, sfcode);
|
epan_dissect_prime_with_dfilter(&edt, sfcode);
|
||||||
epan_dissect_run_with_taps(&edt, cf->cd_t, &cf->phdr,
|
epan_dissect_run_with_taps(&edt, cf->cd_t, &cf->rec,
|
||||||
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
|
frame_tvbuff_new_buffer(&cf->provider, fdata, &cf->buf),
|
||||||
fdata, NULL);
|
fdata, NULL);
|
||||||
rel_ts = edt.pi.rel_ts;
|
rel_ts = edt.pi.rel_ts;
|
||||||
|
|
|
@ -28,13 +28,13 @@ export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, const
|
||||||
{
|
{
|
||||||
const exp_pdu_data_t *exp_pdu_data = (const exp_pdu_data_t *)data;
|
const exp_pdu_data_t *exp_pdu_data = (const exp_pdu_data_t *)data;
|
||||||
exp_pdu_t *exp_pdu_tap_data = (exp_pdu_t *)tapdata;
|
exp_pdu_t *exp_pdu_tap_data = (exp_pdu_t *)tapdata;
|
||||||
struct wtap_pkthdr pkthdr;
|
wtap_rec rec;
|
||||||
int err;
|
int err;
|
||||||
gchar *err_info;
|
gchar *err_info;
|
||||||
int buffer_len;
|
int buffer_len;
|
||||||
guint8 *packet_buf;
|
guint8 *packet_buf;
|
||||||
|
|
||||||
memset(&pkthdr, 0, sizeof(struct wtap_pkthdr));
|
memset(&rec, 0, sizeof rec);
|
||||||
buffer_len = exp_pdu_data->tvb_captured_length + exp_pdu_data->tlv_buffer_len;
|
buffer_len = exp_pdu_data->tvb_captured_length + exp_pdu_data->tlv_buffer_len;
|
||||||
packet_buf = (guint8 *)g_malloc(buffer_len);
|
packet_buf = (guint8 *)g_malloc(buffer_len);
|
||||||
|
|
||||||
|
@ -45,26 +45,25 @@ export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, const
|
||||||
if(exp_pdu_data->tvb_captured_length > 0){
|
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);
|
tvb_memcpy(exp_pdu_data->pdu_tvb, packet_buf+exp_pdu_data->tlv_buffer_len, 0, exp_pdu_data->tvb_captured_length);
|
||||||
}
|
}
|
||||||
pkthdr.rec_type = REC_TYPE_PACKET;
|
rec.rec_type = REC_TYPE_PACKET;
|
||||||
pkthdr.ts.secs = pinfo->abs_ts.secs;
|
rec.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS|WTAP_HAS_PACK_FLAGS;
|
||||||
pkthdr.ts.nsecs = pinfo->abs_ts.nsecs;
|
rec.ts.secs = pinfo->abs_ts.secs;
|
||||||
pkthdr.caplen = buffer_len;
|
rec.ts.nsecs = pinfo->abs_ts.nsecs;
|
||||||
pkthdr.len = exp_pdu_data->tvb_reported_length + exp_pdu_data->tlv_buffer_len;
|
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;
|
||||||
|
|
||||||
pkthdr.pkt_encap = exp_pdu_tap_data->pkt_encap;
|
rec.rec_header.packet_header.pkt_encap = exp_pdu_tap_data->pkt_encap;
|
||||||
|
|
||||||
if (pinfo->fd->flags.has_user_comment) {
|
if (pinfo->fd->flags.has_user_comment) {
|
||||||
pkthdr.opt_comment = g_strdup(epan_get_user_comment(edt->session, pinfo->fd));
|
rec.opt_comment = g_strdup(epan_get_user_comment(edt->session, pinfo->fd));
|
||||||
pkthdr.has_comment_changed = TRUE;
|
rec.has_comment_changed = TRUE;
|
||||||
} else if (pinfo->fd->flags.has_phdr_comment) {
|
} else if (pinfo->fd->flags.has_phdr_comment) {
|
||||||
pkthdr.opt_comment = g_strdup(pinfo->phdr->opt_comment);
|
rec.opt_comment = g_strdup(pinfo->rec->opt_comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
pkthdr.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS|WTAP_HAS_PACK_FLAGS;
|
/* XXX: should the rec.rec_header.packet_header.pseudo_header be set to the pinfo's pseudo-header? */
|
||||||
|
|
||||||
/* XXX: should the pkthdr.pseudo_header be set to the pinfo's pseudo-header? */
|
|
||||||
/* XXX: report errors! */
|
/* XXX: report errors! */
|
||||||
if (!wtap_dump(exp_pdu_tap_data->wdh, &pkthdr, packet_buf, &err, &err_info)) {
|
if (!wtap_dump(exp_pdu_tap_data->wdh, &rec, packet_buf, &err, &err_info)) {
|
||||||
switch (err) {
|
switch (err) {
|
||||||
|
|
||||||
case WTAP_ERR_UNWRITABLE_REC_DATA:
|
case WTAP_ERR_UNWRITABLE_REC_DATA:
|
||||||
|
@ -77,7 +76,7 @@ export_pdu_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, const
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(packet_buf);
|
g_free(packet_buf);
|
||||||
g_free(pkthdr.opt_comment);
|
g_free(rec.opt_comment);
|
||||||
|
|
||||||
return FALSE; /* Do not redraw */
|
return FALSE; /* Do not redraw */
|
||||||
}
|
}
|
||||||
|
|
|
@ -504,23 +504,23 @@ write_current_packet (void)
|
||||||
|
|
||||||
{
|
{
|
||||||
/* Write the packet */
|
/* Write the packet */
|
||||||
struct wtap_pkthdr pkthdr;
|
wtap_rec rec;
|
||||||
int err;
|
int err;
|
||||||
gchar *err_info;
|
gchar *err_info;
|
||||||
|
|
||||||
memset(&pkthdr, 0, sizeof(struct wtap_pkthdr));
|
memset(&rec, 0, sizeof rec);
|
||||||
|
|
||||||
pkthdr.rec_type = REC_TYPE_PACKET;
|
rec.rec_type = REC_TYPE_PACKET;
|
||||||
pkthdr.ts.secs = (guint32)ts_sec;
|
rec.ts.secs = (guint32)ts_sec;
|
||||||
pkthdr.ts.nsecs = ts_usec * 1000;
|
rec.ts.nsecs = ts_usec * 1000;
|
||||||
if (ts_fmt == NULL) { ts_usec++; } /* fake packet counter */
|
if (ts_fmt == NULL) { ts_usec++; } /* fake packet counter */
|
||||||
pkthdr.caplen = pkthdr.len = prefix_length + curr_offset + eth_trailer_length;
|
rec.rec_header.packet_header.caplen = rec.rec_header.packet_header.len = prefix_length + curr_offset + eth_trailer_length;
|
||||||
pkthdr.pkt_encap = pcap_link_type;
|
rec.rec_header.packet_header.pkt_encap = pcap_link_type;
|
||||||
pkthdr.pack_flags |= direction;
|
rec.rec_header.packet_header.pack_flags |= direction;
|
||||||
pkthdr.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS|WTAP_HAS_PACK_FLAGS;
|
rec.presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID|WTAP_HAS_TS|WTAP_HAS_PACK_FLAGS;
|
||||||
|
|
||||||
/* XXX - report errors! */
|
/* XXX - report errors! */
|
||||||
if (!wtap_dump(wdh, &pkthdr, packet_buf, &err, &err_info)) {
|
if (!wtap_dump(wdh, &rec, packet_buf, &err, &err_info)) {
|
||||||
switch (err) {
|
switch (err) {
|
||||||
|
|
||||||
case WTAP_ERR_UNWRITABLE_REC_DATA:
|
case WTAP_ERR_UNWRITABLE_REC_DATA:
|
||||||
|
|
|
@ -87,12 +87,12 @@ typedef struct
|
||||||
|
|
||||||
static gboolean _5views_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean _5views_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean _5views_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean _5views_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
Buffer *buf, int *err, gchar **err_info);
|
||||||
static int _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
|
static int _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
|
||||||
struct wtap_pkthdr *phdr, int *err, gchar **err_info);
|
wtap_rec *rec, int *err, gchar **err_info);
|
||||||
|
|
||||||
static gboolean _5views_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, const guint8 *pd, int *err, gchar **err_info);
|
static gboolean _5views_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info);
|
||||||
static gboolean _5views_dump_finish(wtap_dumper *wdh, int *err);
|
static gboolean _5views_dump_finish(wtap_dumper *wdh, int *err);
|
||||||
|
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||||
|
|
||||||
/* Read record header. */
|
/* Read record header. */
|
||||||
if (!_5views_read_header(wth, wth->fh, &TimeStamped_Header,
|
if (!_5views_read_header(wth, wth->fh, &TimeStamped_Header,
|
||||||
&wth->phdr, err, err_info))
|
&wth->rec, err, err_info))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (TimeStamped_Header.RecSubType == CST_5VW_FRAME_RECORD) {
|
if (TimeStamped_Header.RecSubType == CST_5VW_FRAME_RECORD) {
|
||||||
|
@ -203,23 +203,23 @@ _5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
if (wth->phdr.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
if (wth->rec.rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
||||||
/*
|
/*
|
||||||
* Probably a corrupt capture file; don't blow up trying
|
* Probably a corrupt capture file; don't blow up trying
|
||||||
* to allocate space for an immensely-large packet.
|
* to allocate space for an immensely-large packet.
|
||||||
*/
|
*/
|
||||||
*err = WTAP_ERR_BAD_FILE;
|
*err = WTAP_ERR_BAD_FILE;
|
||||||
*err_info = g_strdup_printf("5views: File has %u-byte packet, bigger than maximum of %u",
|
*err_info = g_strdup_printf("5views: File has %u-byte packet, bigger than maximum of %u",
|
||||||
wth->phdr.caplen, WTAP_MAX_PACKET_SIZE_STANDARD);
|
wth->rec.rec_header.packet_header.caplen, WTAP_MAX_PACKET_SIZE_STANDARD);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
|
return wtap_read_packet_bytes(wth->fh, wth->rec_data,
|
||||||
wth->phdr.caplen, err, err_info);
|
wth->rec.rec_header.packet_header.caplen, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_5views_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
_5views_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
t_5VW_TimeStamped_Header TimeStamped_Header;
|
t_5VW_TimeStamped_Header TimeStamped_Header;
|
||||||
|
@ -231,7 +231,7 @@ _5views_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||||
* Read the header.
|
* Read the header.
|
||||||
*/
|
*/
|
||||||
if (!_5views_read_header(wth, wth->random_fh, &TimeStamped_Header,
|
if (!_5views_read_header(wth, wth->random_fh, &TimeStamped_Header,
|
||||||
phdr, err, err_info)) {
|
rec, err, err_info)) {
|
||||||
if (*err == 0)
|
if (*err == 0)
|
||||||
*err = WTAP_ERR_SHORT_READ;
|
*err = WTAP_ERR_SHORT_READ;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -240,7 +240,7 @@ _5views_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||||
/*
|
/*
|
||||||
* Read the packet data.
|
* Read the packet data.
|
||||||
*/
|
*/
|
||||||
return wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen,
|
return wtap_read_packet_bytes(wth->random_fh, buf, rec->rec_header.packet_header.caplen,
|
||||||
err, err_info);
|
err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ _5views_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||||
on error. */
|
on error. */
|
||||||
static gboolean
|
static gboolean
|
||||||
_5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
|
_5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
|
||||||
struct wtap_pkthdr *phdr, int *err, gchar **err_info)
|
wtap_rec *rec, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
/* Read record header. */
|
/* Read record header. */
|
||||||
if (!wtap_read_bytes_or_eof(fh, hdr, (unsigned int)sizeof(t_5VW_TimeStamped_Header),
|
if (!wtap_read_bytes_or_eof(fh, hdr, (unsigned int)sizeof(t_5VW_TimeStamped_Header),
|
||||||
|
@ -268,18 +268,18 @@ _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
|
||||||
hdr->Utc = pletoh32(&hdr->Utc);
|
hdr->Utc = pletoh32(&hdr->Utc);
|
||||||
hdr->NanoSecondes = pletoh32(&hdr->NanoSecondes);
|
hdr->NanoSecondes = pletoh32(&hdr->NanoSecondes);
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS;
|
rec->presence_flags = WTAP_HAS_TS;
|
||||||
phdr->ts.secs = hdr->Utc;
|
rec->ts.secs = hdr->Utc;
|
||||||
phdr->ts.nsecs = hdr->NanoSecondes;
|
rec->ts.nsecs = hdr->NanoSecondes;
|
||||||
phdr->caplen = hdr->RecSize;
|
rec->rec_header.packet_header.caplen = hdr->RecSize;
|
||||||
phdr->len = hdr->RecSize;
|
rec->rec_header.packet_header.len = hdr->RecSize;
|
||||||
|
|
||||||
switch (wth->file_encap) {
|
switch (wth->file_encap) {
|
||||||
|
|
||||||
case WTAP_ENCAP_ETHERNET:
|
case WTAP_ENCAP_ETHERNET:
|
||||||
/* We assume there's no FCS in this frame. */
|
/* We assume there's no FCS in this frame. */
|
||||||
phdr->pseudo_header.eth.fcs_len = 0;
|
rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,20 +336,20 @@ gboolean _5views_dump_open(wtap_dumper *wdh, int *err)
|
||||||
/* Write a record for a packet to a dump file.
|
/* Write a record for a packet to a dump file.
|
||||||
Returns TRUE on success, FALSE on failure. */
|
Returns TRUE on success, FALSE on failure. */
|
||||||
static gboolean _5views_dump(wtap_dumper *wdh,
|
static gboolean _5views_dump(wtap_dumper *wdh,
|
||||||
const struct wtap_pkthdr *phdr,
|
const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info _U_)
|
const guint8 *pd, int *err, gchar **err_info _U_)
|
||||||
{
|
{
|
||||||
_5views_dump_t *_5views = (_5views_dump_t *)wdh->priv;
|
_5views_dump_t *_5views = (_5views_dump_t *)wdh->priv;
|
||||||
t_5VW_TimeStamped_Header HeaderFrame;
|
t_5VW_TimeStamped_Header HeaderFrame;
|
||||||
|
|
||||||
/* We can only write packet records. */
|
/* We can only write packet records. */
|
||||||
if (phdr->rec_type != REC_TYPE_PACKET) {
|
if (rec->rec_type != REC_TYPE_PACKET) {
|
||||||
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't write out something bigger than we can read. */
|
/* Don't write out something bigger than we can read. */
|
||||||
if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
||||||
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -364,9 +364,9 @@ static gboolean _5views_dump(wtap_dumper *wdh,
|
||||||
HeaderFrame.RecNb = GUINT32_TO_LE(1);
|
HeaderFrame.RecNb = GUINT32_TO_LE(1);
|
||||||
|
|
||||||
/* record-dependent fields */
|
/* record-dependent fields */
|
||||||
HeaderFrame.Utc = GUINT32_TO_LE(phdr->ts.secs);
|
HeaderFrame.Utc = GUINT32_TO_LE(rec->ts.secs);
|
||||||
HeaderFrame.NanoSecondes = GUINT32_TO_LE(phdr->ts.nsecs);
|
HeaderFrame.NanoSecondes = GUINT32_TO_LE(rec->ts.nsecs);
|
||||||
HeaderFrame.RecSize = GUINT32_TO_LE(phdr->len);
|
HeaderFrame.RecSize = GUINT32_TO_LE(rec->rec_header.packet_header.len);
|
||||||
HeaderFrame.RecInfo = GUINT32_TO_LE(0);
|
HeaderFrame.RecInfo = GUINT32_TO_LE(0);
|
||||||
|
|
||||||
/* write the record header */
|
/* write the record header */
|
||||||
|
@ -375,7 +375,7 @@ static gboolean _5views_dump(wtap_dumper *wdh,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* write the data */
|
/* write the data */
|
||||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
|
if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
_5views->nframes ++;
|
_5views->nframes ++;
|
||||||
|
|
|
@ -105,9 +105,9 @@ typedef struct {
|
||||||
static gboolean aethra_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean aethra_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean aethra_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean aethra_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
static gboolean aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
|
static gboolean aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
|
||||||
struct wtap_pkthdr *phdr, int *err, gchar **err_info);
|
wtap_rec *rec, int *err, gchar **err_info);
|
||||||
|
|
||||||
wtap_open_return_val aethra_open(wtap *wth, int *err, gchar **err_info)
|
wtap_open_return_val aethra_open(wtap *wth, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
|
@ -176,16 +176,16 @@ static gboolean aethra_read(wtap *wth, int *err, gchar **err_info,
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
|
|
||||||
/* Read record header. */
|
/* Read record header. */
|
||||||
if (!aethra_read_rec_header(wth, wth->fh, &hdr, &wth->phdr, err, err_info))
|
if (!aethra_read_rec_header(wth, wth->fh, &hdr, &wth->rec, err, err_info))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX - if this is big, we might waste memory by
|
* XXX - if this is big, we might waste memory by
|
||||||
* growing the buffer to handle it.
|
* growing the buffer to handle it.
|
||||||
*/
|
*/
|
||||||
if (wth->phdr.caplen != 0) {
|
if (wth->rec.rec_header.packet_header.caplen != 0) {
|
||||||
if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
|
if (!wtap_read_packet_bytes(wth->fh, wth->rec_data,
|
||||||
wth->phdr.caplen, err, err_info))
|
wth->rec.rec_header.packet_header.caplen, err, err_info))
|
||||||
return FALSE; /* Read error */
|
return FALSE; /* Read error */
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -235,7 +235,7 @@ fprintf(stderr, " subtype 0x%02x (AETHRA_ISDN_LINK_ALL_ALARMS_CLEARED)\n", hd
|
||||||
default:
|
default:
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, " subtype 0x%02x, packet_size %u, direction 0x%02x\n",
|
fprintf(stderr, " subtype 0x%02x, packet_size %u, direction 0x%02x\n",
|
||||||
hdr.flags & AETHRA_ISDN_LINK_SUBTYPE, wth->phdr.caplen, hdr.flags & AETHRA_U_TO_N);
|
hdr.flags & AETHRA_ISDN_LINK_SUBTYPE, wth->rec.rec_header.packet_header.caplen, hdr.flags & AETHRA_U_TO_N);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ hdr.flags & AETHRA_ISDN_LINK_SUBTYPE, wth->phdr.caplen, hdr.flags & AETHRA_U_TO_
|
||||||
default:
|
default:
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "Packet %u: type 0x%02x, packet_size %u, flags 0x%02x\n",
|
fprintf(stderr, "Packet %u: type 0x%02x, packet_size %u, flags 0x%02x\n",
|
||||||
packet, hdr.rec_type, wth->phdr.caplen, hdr.flags);
|
packet, hdr.rec_type, wth->rec.rec_header.packet_header.caplen, hdr.flags);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ found:
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
aethra_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
aethra_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
struct aethrarec_hdr hdr;
|
struct aethrarec_hdr hdr;
|
||||||
|
@ -263,7 +263,7 @@ aethra_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!aethra_read_rec_header(wth, wth->random_fh, &hdr, phdr, err,
|
if (!aethra_read_rec_header(wth, wth->random_fh, &hdr, rec, err,
|
||||||
err_info)) {
|
err_info)) {
|
||||||
if (*err == 0)
|
if (*err == 0)
|
||||||
*err = WTAP_ERR_SHORT_READ;
|
*err = WTAP_ERR_SHORT_READ;
|
||||||
|
@ -273,7 +273,7 @@ aethra_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||||
/*
|
/*
|
||||||
* Read the packet data.
|
* Read the packet data.
|
||||||
*/
|
*/
|
||||||
if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err, err_info))
|
if (!wtap_read_packet_bytes(wth->random_fh, buf, rec->rec_header.packet_header.caplen, err, err_info))
|
||||||
return FALSE; /* failed */
|
return FALSE; /* failed */
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -281,7 +281,7 @@ aethra_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
|
aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
|
||||||
struct wtap_pkthdr *phdr, int *err, gchar **err_info)
|
wtap_rec *rec, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
aethra_t *aethra = (aethra_t *)wth->priv;
|
aethra_t *aethra = (aethra_t *)wth->priv;
|
||||||
guint32 rec_size;
|
guint32 rec_size;
|
||||||
|
@ -316,14 +316,14 @@ aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
|
||||||
packet_size = rec_size - (guint32)(sizeof *hdr - sizeof hdr->rec_size);
|
packet_size = rec_size - (guint32)(sizeof *hdr - sizeof hdr->rec_size);
|
||||||
|
|
||||||
msecs = pletoh32(hdr->timestamp);
|
msecs = pletoh32(hdr->timestamp);
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS;
|
rec->presence_flags = WTAP_HAS_TS;
|
||||||
phdr->ts.secs = aethra->start + (msecs / 1000);
|
rec->ts.secs = aethra->start + (msecs / 1000);
|
||||||
phdr->ts.nsecs = (msecs % 1000) * 1000000;
|
rec->ts.nsecs = (msecs % 1000) * 1000000;
|
||||||
phdr->caplen = packet_size;
|
rec->rec_header.packet_header.caplen = packet_size;
|
||||||
phdr->len = packet_size;
|
rec->rec_header.packet_header.len = packet_size;
|
||||||
phdr->pseudo_header.isdn.uton = (hdr->flags & AETHRA_U_TO_N);
|
rec->rec_header.packet_header.pseudo_header.isdn.uton = (hdr->flags & AETHRA_U_TO_N);
|
||||||
phdr->pseudo_header.isdn.channel = 0; /* XXX - D channel */
|
rec->rec_header.packet_header.pseudo_header.isdn.channel = 0; /* XXX - D channel */
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ typedef struct {
|
||||||
} ascend_state_t;
|
} ascend_state_t;
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
run_ascend_parser(FILE_T fh, struct wtap_pkthdr *phdr, guint8 *pd,
|
run_ascend_parser(FILE_T fh, wtap_rec *rec, guint8 *pd,
|
||||||
ascend_state_t *parser_state, int *err, gchar **err_info);
|
ascend_state_t *parser_state, int *err, gchar **err_info);
|
||||||
|
|
||||||
#endif /* ! __ASCEND_INT_H__ */
|
#endif /* ! __ASCEND_INT_H__ */
|
||||||
|
|
|
@ -431,7 +431,7 @@ datagroup: dataln
|
||||||
|
|
||||||
/* Run the parser. */
|
/* Run the parser. */
|
||||||
int
|
int
|
||||||
run_ascend_parser(FILE_T fh, struct wtap_pkthdr *phdr, guint8 *pd,
|
run_ascend_parser(FILE_T fh, wtap_rec *rec, guint8 *pd,
|
||||||
ascend_state_t *parser_state, int *err, gchar **err_info)
|
ascend_state_t *parser_state, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
yyscan_t scanner = NULL;
|
yyscan_t scanner = NULL;
|
||||||
|
@ -449,7 +449,7 @@ run_ascend_parser(FILE_T fh, struct wtap_pkthdr *phdr, guint8 *pd,
|
||||||
parser_state->ascend_parse_error = NULL;
|
parser_state->ascend_parse_error = NULL;
|
||||||
parser_state->err = 0;
|
parser_state->err = 0;
|
||||||
parser_state->err_info = NULL;
|
parser_state->err_info = NULL;
|
||||||
parser_state->pseudo_header = &phdr->pseudo_header.ascend;
|
parser_state->pseudo_header = &rec->rec_header.packet_header.pseudo_header.ascend;
|
||||||
parser_state->pkt_data = pd;
|
parser_state->pkt_data = pd;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -65,7 +65,7 @@ static const ascend_magic_string ascend_magic[] = {
|
||||||
static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info);
|
int *err, gchar **err_info);
|
||||||
|
|
||||||
/* Seeks to the beginning of the next packet, and returns the
|
/* Seeks to the beginning of the next packet, and returns the
|
||||||
|
@ -200,7 +200,7 @@ found:
|
||||||
if (file_seek(wth->fh, packet_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->fh, packet_off, SEEK_SET, err) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
wth->phdr.pseudo_header.ascend.type = type;
|
wth->rec.rec_header.packet_header.pseudo_header.ascend.type = type;
|
||||||
|
|
||||||
return packet_off;
|
return packet_off;
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ wtap_open_return_val ascend_open(wtap *wth, int *err, gchar **err_info)
|
||||||
/* Do a trial parse of the first packet just found to see if we might
|
/* Do a trial parse of the first packet just found to see if we might
|
||||||
really have an Ascend file. If it fails with an actual error,
|
really have an Ascend file. If it fails with an actual error,
|
||||||
fail; those will be I/O errors. */
|
fail; those will be I/O errors. */
|
||||||
if (run_ascend_parser(wth->fh, &wth->phdr, buf, &parser_state, err,
|
if (run_ascend_parser(wth->fh, &wth->rec, buf, &parser_state, err,
|
||||||
err_info) != 0 && *err != 0) {
|
err_info) != 0 && *err != 0) {
|
||||||
/* An I/O error. */
|
/* An I/O error. */
|
||||||
return WTAP_OPEN_ERROR;
|
return WTAP_OPEN_ERROR;
|
||||||
|
@ -249,7 +249,7 @@ wtap_open_return_val ascend_open(wtap *wth, int *err, gchar **err_info)
|
||||||
|
|
||||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_ASCEND;
|
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_ASCEND;
|
||||||
|
|
||||||
switch(wth->phdr.pseudo_header.ascend.type) {
|
switch(wth->rec.rec_header.packet_header.pseudo_header.ascend.type) {
|
||||||
case ASCEND_PFX_ISDN_X:
|
case ASCEND_PFX_ISDN_X:
|
||||||
case ASCEND_PFX_ISDN_R:
|
case ASCEND_PFX_ISDN_R:
|
||||||
wth->file_encap = WTAP_ENCAP_ISDN;
|
wth->file_encap = WTAP_ENCAP_ISDN;
|
||||||
|
@ -292,14 +292,14 @@ wtap_open_return_val ascend_open(wtap *wth, int *err, gchar **err_info)
|
||||||
/* Parse the capture file.
|
/* Parse the capture file.
|
||||||
Returns TRUE if we got a packet, FALSE otherwise. */
|
Returns TRUE if we got a packet, FALSE otherwise. */
|
||||||
static gboolean
|
static gboolean
|
||||||
parse_ascend(ascend_t *ascend, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
parse_ascend(ascend_t *ascend, FILE_T fh, wtap_rec *rec, Buffer *buf,
|
||||||
guint length, int *err, gchar **err_info)
|
guint length, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
ascend_state_t parser_state;
|
ascend_state_t parser_state;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
ws_buffer_assure_space(buf, length);
|
ws_buffer_assure_space(buf, length);
|
||||||
retval = run_ascend_parser(fh, phdr, ws_buffer_start_ptr(buf), &parser_state,
|
retval = run_ascend_parser(fh, rec, ws_buffer_start_ptr(buf), &parser_state,
|
||||||
err, err_info);
|
err, err_info);
|
||||||
|
|
||||||
/* did we see any data (hex bytes)? if so, tip off ascend_seek()
|
/* did we see any data (hex bytes)? if so, tip off ascend_seek()
|
||||||
|
@ -342,30 +342,30 @@ parse_ascend(ascend_t *ascend, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
if (ascend->inittime > parser_state.secs)
|
if (ascend->inittime > parser_state.secs)
|
||||||
ascend->inittime -= parser_state.secs;
|
ascend->inittime -= parser_state.secs;
|
||||||
}
|
}
|
||||||
phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
||||||
phdr->ts.secs = parser_state.secs + ascend->inittime;
|
rec->ts.secs = parser_state.secs + ascend->inittime;
|
||||||
phdr->ts.nsecs = parser_state.usecs * 1000;
|
rec->ts.nsecs = parser_state.usecs * 1000;
|
||||||
phdr->caplen = parser_state.caplen;
|
rec->rec_header.packet_header.caplen = parser_state.caplen;
|
||||||
phdr->len = parser_state.wirelen;
|
rec->rec_header.packet_header.len = parser_state.wirelen;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For these types, the encapsulation we use is not WTAP_ENCAP_ASCEND,
|
* For these types, the encapsulation we use is not WTAP_ENCAP_ASCEND,
|
||||||
* so set the pseudo-headers appropriately for the type (WTAP_ENCAP_ISDN
|
* so set the pseudo-headers appropriately for the type (WTAP_ENCAP_ISDN
|
||||||
* or WTAP_ENCAP_ETHERNET).
|
* or WTAP_ENCAP_ETHERNET).
|
||||||
*/
|
*/
|
||||||
switch(phdr->pseudo_header.ascend.type) {
|
switch(rec->rec_header.packet_header.pseudo_header.ascend.type) {
|
||||||
case ASCEND_PFX_ISDN_X:
|
case ASCEND_PFX_ISDN_X:
|
||||||
phdr->pseudo_header.isdn.uton = TRUE;
|
rec->rec_header.packet_header.pseudo_header.isdn.uton = TRUE;
|
||||||
phdr->pseudo_header.isdn.channel = 0;
|
rec->rec_header.packet_header.pseudo_header.isdn.channel = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ASCEND_PFX_ISDN_R:
|
case ASCEND_PFX_ISDN_R:
|
||||||
phdr->pseudo_header.isdn.uton = FALSE;
|
rec->rec_header.packet_header.pseudo_header.isdn.uton = FALSE;
|
||||||
phdr->pseudo_header.isdn.channel = 0;
|
rec->rec_header.packet_header.pseudo_header.isdn.channel = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ASCEND_PFX_ETHER:
|
case ASCEND_PFX_ETHER:
|
||||||
phdr->pseudo_header.eth.fcs_len = 0;
|
rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -408,7 +408,7 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
|
||||||
offset = ascend_seek(wth, err, err_info);
|
offset = ascend_seek(wth, err, err_info);
|
||||||
if (offset == -1)
|
if (offset == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!parse_ascend(ascend, wth->fh, &wth->phdr, wth->frame_buffer,
|
if (!parse_ascend(ascend, wth->fh, &wth->rec, wth->rec_data,
|
||||||
wth->snapshot_length, err, err_info))
|
wth->snapshot_length, err, err_info))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -417,14 +417,14 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
ascend_t *ascend = (ascend_t *)wth->priv;
|
ascend_t *ascend = (ascend_t *)wth->priv;
|
||||||
|
|
||||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!parse_ascend(ascend, wth->random_fh, phdr, buf,
|
if (!parse_ascend(ascend, wth->random_fh, rec, buf,
|
||||||
wth->snapshot_length, err, err_info))
|
wth->snapshot_length, err, err_info))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
|
@ -20,34 +20,34 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
atm_guess_traffic_type(struct wtap_pkthdr *phdr, const guint8 *pd)
|
atm_guess_traffic_type(wtap_rec *rec, const guint8 *pd)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Start out assuming nothing other than that it's AAL5.
|
* Start out assuming nothing other than that it's AAL5.
|
||||||
*/
|
*/
|
||||||
phdr->pseudo_header.atm.aal = AAL_5;
|
rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_5;
|
||||||
phdr->pseudo_header.atm.type = TRAF_UNKNOWN;
|
rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_UNKNOWN;
|
||||||
phdr->pseudo_header.atm.subtype = TRAF_ST_UNKNOWN;
|
rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_UNKNOWN;
|
||||||
|
|
||||||
if (phdr->pseudo_header.atm.vpi == 0) {
|
if (rec->rec_header.packet_header.pseudo_header.atm.vpi == 0) {
|
||||||
/*
|
/*
|
||||||
* Traffic on some PVCs with a VPI of 0 and certain
|
* Traffic on some PVCs with a VPI of 0 and certain
|
||||||
* VCIs is of particular types.
|
* VCIs is of particular types.
|
||||||
*/
|
*/
|
||||||
switch (phdr->pseudo_header.atm.vci) {
|
switch (rec->rec_header.packet_header.pseudo_header.atm.vci) {
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
/*
|
/*
|
||||||
* Signalling AAL.
|
* Signalling AAL.
|
||||||
*/
|
*/
|
||||||
phdr->pseudo_header.atm.aal = AAL_SIGNALLING;
|
rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_SIGNALLING;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 16:
|
case 16:
|
||||||
/*
|
/*
|
||||||
* ILMI.
|
* ILMI.
|
||||||
*/
|
*/
|
||||||
phdr->pseudo_header.atm.type = TRAF_ILMI;
|
rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_ILMI;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,21 +58,21 @@ atm_guess_traffic_type(struct wtap_pkthdr *phdr, const guint8 *pd)
|
||||||
* to guess.
|
* to guess.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (phdr->caplen >= 3) {
|
if (rec->rec_header.packet_header.caplen >= 3) {
|
||||||
if (pd[0] == 0xaa && pd[1] == 0xaa && pd[2] == 0x03) {
|
if (pd[0] == 0xaa && pd[1] == 0xaa && pd[2] == 0x03) {
|
||||||
/*
|
/*
|
||||||
* Looks like a SNAP header; assume it's LLC
|
* Looks like a SNAP header; assume it's LLC
|
||||||
* multiplexed RFC 1483 traffic.
|
* multiplexed RFC 1483 traffic.
|
||||||
*/
|
*/
|
||||||
phdr->pseudo_header.atm.type = TRAF_LLCMX;
|
rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_LLCMX;
|
||||||
} else if ((phdr->pseudo_header.atm.aal5t_len && phdr->pseudo_header.atm.aal5t_len < 16) ||
|
} else if ((rec->rec_header.packet_header.pseudo_header.atm.aal5t_len && rec->rec_header.packet_header.pseudo_header.atm.aal5t_len < 16) ||
|
||||||
phdr->caplen < 16) {
|
rec->rec_header.packet_header.caplen < 16) {
|
||||||
/*
|
/*
|
||||||
* As this cannot be a LANE Ethernet frame (less
|
* As this cannot be a LANE Ethernet frame (less
|
||||||
* than 2 bytes of LANE header + 14 bytes of
|
* than 2 bytes of LANE header + 14 bytes of
|
||||||
* Ethernet header) we can try it as a SSCOP frame.
|
* Ethernet header) we can try it as a SSCOP frame.
|
||||||
*/
|
*/
|
||||||
phdr->pseudo_header.atm.aal = AAL_SIGNALLING;
|
rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_SIGNALLING;
|
||||||
} else if (pd[0] == 0x83 || pd[0] == 0x81) {
|
} else if (pd[0] == 0x83 || pd[0] == 0x81) {
|
||||||
/*
|
/*
|
||||||
* MTP3b headers often encapsulate
|
* MTP3b headers often encapsulate
|
||||||
|
@ -80,32 +80,32 @@ atm_guess_traffic_type(struct wtap_pkthdr *phdr, const guint8 *pd)
|
||||||
* This should cause 0x83 or 0x81
|
* This should cause 0x83 or 0x81
|
||||||
* in the first byte.
|
* in the first byte.
|
||||||
*/
|
*/
|
||||||
phdr->pseudo_header.atm.aal = AAL_SIGNALLING;
|
rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_SIGNALLING;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Assume it's LANE.
|
* Assume it's LANE.
|
||||||
*/
|
*/
|
||||||
phdr->pseudo_header.atm.type = TRAF_LANE;
|
rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_LANE;
|
||||||
atm_guess_lane_type(phdr, pd);
|
atm_guess_lane_type(rec, pd);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Not only VCI 5 is used for signaling. It might be
|
* Not only VCI 5 is used for signaling. It might be
|
||||||
* one of these VCIs.
|
* one of these VCIs.
|
||||||
*/
|
*/
|
||||||
phdr->pseudo_header.atm.aal = AAL_SIGNALLING;
|
rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_SIGNALLING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
atm_guess_lane_type(struct wtap_pkthdr *phdr, const guint8 *pd)
|
atm_guess_lane_type(wtap_rec *rec, const guint8 *pd)
|
||||||
{
|
{
|
||||||
if (phdr->caplen >= 2) {
|
if (rec->rec_header.packet_header.caplen >= 2) {
|
||||||
if (pd[0] == 0xff && pd[1] == 0x00) {
|
if (pd[0] == 0xff && pd[1] == 0x00) {
|
||||||
/*
|
/*
|
||||||
* Looks like LE Control traffic.
|
* Looks like LE Control traffic.
|
||||||
*/
|
*/
|
||||||
phdr->pseudo_header.atm.subtype = TRAF_ST_LANE_LE_CTRL;
|
rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_LANE_LE_CTRL;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* XXX - Ethernet, or Token Ring?
|
* XXX - Ethernet, or Token Ring?
|
||||||
|
@ -115,7 +115,7 @@ atm_guess_lane_type(struct wtap_pkthdr *phdr, const guint8 *pd)
|
||||||
* still be situations where the user has to
|
* still be situations where the user has to
|
||||||
* tell us.
|
* tell us.
|
||||||
*/
|
*/
|
||||||
phdr->pseudo_header.atm.subtype = TRAF_ST_LANE_802_3;
|
rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_LANE_802_3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
atm_guess_traffic_type(struct wtap_pkthdr *phdr, const guint8 *pd);
|
atm_guess_traffic_type(wtap_rec *rec, const guint8 *pd);
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
atm_guess_lane_type(struct wtap_pkthdr *phdr, const guint8 *pd);
|
atm_guess_lane_type(wtap_rec *rec, const guint8 *pd);
|
||||||
|
|
||||||
#endif /* __ATM_H__ */
|
#endif /* __ATM_H__ */
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#define BER_UNI_TAG_SEQ 16 /* SEQUENCE, SEQUENCE OF */
|
#define BER_UNI_TAG_SEQ 16 /* SEQUENCE, SEQUENCE OF */
|
||||||
#define BER_UNI_TAG_SET 17 /* SET, SET OF */
|
#define BER_UNI_TAG_SET 17 /* SET, SET OF */
|
||||||
|
|
||||||
static gboolean ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
static gboolean ber_read_file(wtap *wth, FILE_T fh, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
gint64 file_size;
|
gint64 file_size;
|
||||||
|
@ -43,14 +43,14 @@ static gboolean ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
}
|
}
|
||||||
packet_size = (int)file_size;
|
packet_size = (int)file_size;
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */
|
rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */
|
||||||
|
|
||||||
phdr->caplen = packet_size;
|
rec->rec_header.packet_header.caplen = packet_size;
|
||||||
phdr->len = packet_size;
|
rec->rec_header.packet_header.len = packet_size;
|
||||||
|
|
||||||
phdr->ts.secs = 0;
|
rec->ts.secs = 0;
|
||||||
phdr->ts.nsecs = 0;
|
rec->ts.nsecs = 0;
|
||||||
|
|
||||||
ws_buffer_assure_space(buf, packet_size);
|
ws_buffer_assure_space(buf, packet_size);
|
||||||
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
|
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
|
||||||
|
@ -70,10 +70,10 @@ static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off
|
||||||
|
|
||||||
*data_offset = offset;
|
*data_offset = offset;
|
||||||
|
|
||||||
return ber_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
|
return ber_read_file(wth, wth->fh, &wth->rec, wth->rec_data, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean ber_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
static gboolean ber_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
/* there is only one packet */
|
/* there is only one packet */
|
||||||
|
@ -85,7 +85,7 @@ static gboolean ber_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *ph
|
||||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return ber_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
|
return ber_read_file(wth, wth->random_fh, rec, buf, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
wtap_open_return_val ber_open(wtap *wth, int *err, gchar **err_info)
|
wtap_open_return_val ber_open(wtap *wth, int *err, gchar **err_info)
|
||||||
|
|
|
@ -62,9 +62,9 @@ static const gint64 KUnixTimeBase = G_GINT64_CONSTANT(0x00dcddb30f2f8000); /* of
|
||||||
static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
|
static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
|
|
||||||
wtap_open_return_val btsnoop_open(wtap *wth, int *err, gchar **err_info)
|
wtap_open_return_val btsnoop_open(wtap *wth, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
|
@ -141,21 +141,21 @@ static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
|
||||||
{
|
{
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
|
|
||||||
return btsnoop_read_record(wth, wth->fh, &wth->phdr, wth->frame_buffer,
|
return btsnoop_read_record(wth, wth->fh, &wth->rec, wth->rec_data,
|
||||||
err, err_info);
|
err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return btsnoop_read_record(wth, wth->random_fh, phdr, buf, err, err_info);
|
return btsnoop_read_record(wth, wth->random_fh, rec, buf, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
|
static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
struct btsnooprec_hdr hdr;
|
struct btsnooprec_hdr hdr;
|
||||||
guint32 packet_size;
|
guint32 packet_size;
|
||||||
|
@ -185,40 +185,40 @@ static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
|
||||||
ts = GINT64_FROM_BE(hdr.ts_usec);
|
ts = GINT64_FROM_BE(hdr.ts_usec);
|
||||||
ts -= KUnixTimeBase;
|
ts -= KUnixTimeBase;
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
||||||
phdr->ts.secs = (guint)(ts / 1000000);
|
rec->ts.secs = (guint)(ts / 1000000);
|
||||||
phdr->ts.nsecs = (guint)((ts % 1000000) * 1000);
|
rec->ts.nsecs = (guint)((ts % 1000000) * 1000);
|
||||||
phdr->caplen = packet_size;
|
rec->rec_header.packet_header.caplen = packet_size;
|
||||||
phdr->len = orig_size;
|
rec->rec_header.packet_header.len = orig_size;
|
||||||
if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR)
|
if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR)
|
||||||
{
|
{
|
||||||
phdr->pseudo_header.p2p.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE;
|
rec->rec_header.packet_header.pseudo_header.p2p.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE;
|
||||||
} else if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_HCI) {
|
} else if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_HCI) {
|
||||||
phdr->pseudo_header.bthci.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE;
|
rec->rec_header.packet_header.pseudo_header.bthci.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE;
|
||||||
if(flags & KHciLoggerCommandOrEvent)
|
if(flags & KHciLoggerCommandOrEvent)
|
||||||
{
|
{
|
||||||
if(phdr->pseudo_header.bthci.sent)
|
if(rec->rec_header.packet_header.pseudo_header.bthci.sent)
|
||||||
{
|
{
|
||||||
phdr->pseudo_header.bthci.channel = BTHCI_CHANNEL_COMMAND;
|
rec->rec_header.packet_header.pseudo_header.bthci.channel = BTHCI_CHANNEL_COMMAND;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
phdr->pseudo_header.bthci.channel = BTHCI_CHANNEL_EVENT;
|
rec->rec_header.packet_header.pseudo_header.bthci.channel = BTHCI_CHANNEL_EVENT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
phdr->pseudo_header.bthci.channel = BTHCI_CHANNEL_ACL;
|
rec->rec_header.packet_header.pseudo_header.bthci.channel = BTHCI_CHANNEL_ACL;
|
||||||
}
|
}
|
||||||
} else if (wth->file_encap == WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR) {
|
} else if (wth->file_encap == WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR) {
|
||||||
phdr->pseudo_header.btmon.opcode = flags & 0xFFFF;
|
rec->rec_header.packet_header.pseudo_header.btmon.opcode = flags & 0xFFFF;
|
||||||
phdr->pseudo_header.btmon.adapter_id = flags >> 16;
|
rec->rec_header.packet_header.pseudo_header.btmon.adapter_id = flags >> 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Read packet data. */
|
/* Read packet data. */
|
||||||
return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info);
|
return wtap_read_packet_bytes(fh, buf, rec->rec_header.packet_header.caplen, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns 0 if we could write the specified encapsulation type,
|
/* Returns 0 if we could write the specified encapsulation type,
|
||||||
|
@ -268,7 +268,7 @@ static guint8 btsnoop_lookup_flags(guint8 hci_type, gboolean sent, guint8 *flags
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean btsnoop_format_partial_rec_hdr(
|
static gboolean btsnoop_format_partial_rec_hdr(
|
||||||
const struct wtap_pkthdr *phdr,
|
const wtap_rec *rec,
|
||||||
const union wtap_pseudo_header *pseudo_header,
|
const union wtap_pseudo_header *pseudo_header,
|
||||||
const guint8 *pd, int *err, gchar **err_info,
|
const guint8 *pd, int *err, gchar **err_info,
|
||||||
struct btsnooprec_hdr *rec_hdr)
|
struct btsnooprec_hdr *rec_hdr)
|
||||||
|
@ -285,8 +285,8 @@ static gboolean btsnoop_format_partial_rec_hdr(
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsecs = phdr->ts.nsecs;
|
nsecs = rec->ts.nsecs;
|
||||||
ts_usec = ((gint64) phdr->ts.secs * 1000000) + (nsecs / 1000);
|
ts_usec = ((gint64) rec->ts.secs * 1000000) + (nsecs / 1000);
|
||||||
ts_usec += KUnixTimeBase;
|
ts_usec += KUnixTimeBase;
|
||||||
|
|
||||||
rec_hdr->flags = GUINT32_TO_BE(flags);
|
rec_hdr->flags = GUINT32_TO_BE(flags);
|
||||||
|
@ -298,14 +298,14 @@ static gboolean btsnoop_format_partial_rec_hdr(
|
||||||
|
|
||||||
/* FIXME: How do we support multiple backends?*/
|
/* FIXME: How do we support multiple backends?*/
|
||||||
static gboolean btsnoop_dump_h1(wtap_dumper *wdh,
|
static gboolean btsnoop_dump_h1(wtap_dumper *wdh,
|
||||||
const struct wtap_pkthdr *phdr,
|
const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info)
|
const guint8 *pd, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
|
const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header;
|
||||||
struct btsnooprec_hdr rec_hdr;
|
struct btsnooprec_hdr rec_hdr;
|
||||||
|
|
||||||
/* We can only write packet records. */
|
/* We can only write packet records. */
|
||||||
if (phdr->rec_type != REC_TYPE_PACKET) {
|
if (rec->rec_type != REC_TYPE_PACKET) {
|
||||||
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -314,17 +314,17 @@ static gboolean btsnoop_dump_h1(wtap_dumper *wdh,
|
||||||
* Don't write out anything bigger than we can read.
|
* Don't write out anything bigger than we can read.
|
||||||
* (This will also fail on a caplen of 0, as it should.)
|
* (This will also fail on a caplen of 0, as it should.)
|
||||||
*/
|
*/
|
||||||
if (phdr->caplen-1 > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
if (rec->rec_header.packet_header.caplen-1 > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
||||||
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!btsnoop_format_partial_rec_hdr(phdr, pseudo_header, pd, err, err_info,
|
if (!btsnoop_format_partial_rec_hdr(rec, pseudo_header, pd, err, err_info,
|
||||||
&rec_hdr))
|
&rec_hdr))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
rec_hdr.incl_len = GUINT32_TO_BE(phdr->caplen-1);
|
rec_hdr.incl_len = GUINT32_TO_BE(rec->rec_header.packet_header.caplen-1);
|
||||||
rec_hdr.orig_len = GUINT32_TO_BE(phdr->len-1);
|
rec_hdr.orig_len = GUINT32_TO_BE(rec->rec_header.packet_header.len-1);
|
||||||
|
|
||||||
if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof rec_hdr, err))
|
if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof rec_hdr, err))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -334,49 +334,49 @@ static gboolean btsnoop_dump_h1(wtap_dumper *wdh,
|
||||||
/* Skip HCI packet type */
|
/* Skip HCI packet type */
|
||||||
++pd;
|
++pd;
|
||||||
|
|
||||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen-1, err))
|
if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen-1, err))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
wdh->bytes_dumped += phdr->caplen-1;
|
wdh->bytes_dumped += rec->rec_header.packet_header.caplen-1;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean btsnoop_dump_h4(wtap_dumper *wdh,
|
static gboolean btsnoop_dump_h4(wtap_dumper *wdh,
|
||||||
const struct wtap_pkthdr *phdr,
|
const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info)
|
const guint8 *pd, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
|
const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header;
|
||||||
struct btsnooprec_hdr rec_hdr;
|
struct btsnooprec_hdr rec_hdr;
|
||||||
|
|
||||||
/* We can only write packet records. */
|
/* We can only write packet records. */
|
||||||
if (phdr->rec_type != REC_TYPE_PACKET) {
|
if (rec->rec_type != REC_TYPE_PACKET) {
|
||||||
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't write out anything bigger than we can read. */
|
/* Don't write out anything bigger than we can read. */
|
||||||
if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
||||||
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!btsnoop_format_partial_rec_hdr(phdr, pseudo_header, pd, err, err_info,
|
if (!btsnoop_format_partial_rec_hdr(rec, pseudo_header, pd, err, err_info,
|
||||||
&rec_hdr))
|
&rec_hdr))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
rec_hdr.incl_len = GUINT32_TO_BE(phdr->caplen);
|
rec_hdr.incl_len = GUINT32_TO_BE(rec->rec_header.packet_header.caplen);
|
||||||
rec_hdr.orig_len = GUINT32_TO_BE(phdr->len);
|
rec_hdr.orig_len = GUINT32_TO_BE(rec->rec_header.packet_header.len);
|
||||||
|
|
||||||
if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof rec_hdr, err))
|
if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof rec_hdr, err))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
wdh->bytes_dumped += sizeof rec_hdr;
|
wdh->bytes_dumped += sizeof rec_hdr;
|
||||||
|
|
||||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
|
if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
wdh->bytes_dumped += phdr->caplen;
|
wdh->bytes_dumped += rec->rec_header.packet_header.caplen;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,7 +291,7 @@ create_pseudo_hdr(guint8 *buf, guint8 dat_trans_type, guint16 dat_len)
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
camins_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
guint8 dat_trans_type;
|
guint8 dat_trans_type;
|
||||||
|
@ -327,11 +327,11 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
offset += bytes_read;
|
offset += bytes_read;
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->pkt_encap = WTAP_ENCAP_DVBCI;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_DVBCI;
|
||||||
/* timestamps aren't supported for now */
|
/* timestamps aren't supported for now */
|
||||||
phdr->caplen = offset;
|
rec->rec_header.packet_header.caplen = offset;
|
||||||
phdr->len = offset;
|
rec->rec_header.packet_header.len = offset;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -342,19 +342,19 @@ camins_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||||
{
|
{
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
|
|
||||||
return camins_read_packet(wth->fh, &wth->phdr, wth->frame_buffer, err,
|
return camins_read_packet(wth->fh, &wth->rec, wth->rec_data, err,
|
||||||
err_info);
|
err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
camins_seek_read(wtap *wth, gint64 seek_off,
|
camins_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf,
|
||||||
struct wtap_pkthdr *pkthdr, Buffer *buf, int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err))
|
if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return camins_read_packet(wth->random_fh, pkthdr, buf, err, err_info);
|
return camins_read_packet(wth->random_fh, rec, buf, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -109,8 +109,8 @@ typedef struct {
|
||||||
static gboolean capsa_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean capsa_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean capsa_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean capsa_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
static int capsa_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
static int capsa_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info);
|
Buffer *buf, int *err, gchar **err_info);
|
||||||
|
|
||||||
wtap_open_return_val capsa_open(wtap *wth, int *err, gchar **err_info)
|
wtap_open_return_val capsa_open(wtap *wth, int *err, gchar **err_info)
|
||||||
|
@ -262,8 +262,8 @@ static gboolean capsa_read(wtap *wth, int *err, gchar **err_info,
|
||||||
if (!file_seek(wth->fh, *data_offset, SEEK_SET, err))
|
if (!file_seek(wth->fh, *data_offset, SEEK_SET, err))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
padbytes = capsa_read_packet(wth, wth->fh, &wth->phdr,
|
padbytes = capsa_read_packet(wth, wth->fh, &wth->rec,
|
||||||
wth->frame_buffer, err, err_info);
|
wth->rec_data, err, err_info);
|
||||||
if (padbytes == -1)
|
if (padbytes == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -282,12 +282,12 @@ static gboolean capsa_read(wtap *wth, int *err, gchar **err_info,
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
capsa_seek_read(wtap *wth, gint64 seek_off,
|
capsa_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (capsa_read_packet(wth, wth->random_fh, phdr, buf, err, err_info) == -1) {
|
if (capsa_read_packet(wth, wth->random_fh, rec, buf, err, err_info) == -1) {
|
||||||
if (*err == 0)
|
if (*err == 0)
|
||||||
*err = WTAP_ERR_SHORT_READ;
|
*err = WTAP_ERR_SHORT_READ;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -296,7 +296,7 @@ capsa_seek_read(wtap *wth, gint64 seek_off,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
capsa_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
capsa_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
capsa_t *capsa = (capsa_t *)wth->priv;
|
capsa_t *capsa = (capsa_t *)wth->priv;
|
||||||
|
@ -402,14 +402,14 @@ capsa_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
* We assume there's no FCS in this frame.
|
* We assume there's no FCS in this frame.
|
||||||
* XXX - is there ever one?
|
* XXX - is there ever one?
|
||||||
*/
|
*/
|
||||||
phdr->pseudo_header.eth.fcs_len = 0;
|
rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0;
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->caplen = packet_size;
|
rec->rec_header.packet_header.caplen = packet_size;
|
||||||
phdr->len = orig_size;
|
rec->rec_header.packet_header.len = orig_size;
|
||||||
phdr->presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_TS;
|
rec->presence_flags = WTAP_HAS_CAP_LEN|WTAP_HAS_TS;
|
||||||
phdr->ts.secs = (time_t)(timestamp / 1000000);
|
rec->ts.secs = (time_t)(timestamp / 1000000);
|
||||||
phdr->ts.nsecs = ((int)(timestamp % 1000000))*1000;
|
rec->ts.nsecs = ((int)(timestamp % 1000000))*1000;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the packet data.
|
* Read the packet data.
|
||||||
|
|
|
@ -93,12 +93,12 @@ static const gchar catapult_dct2000_magic[] = "Session Transcript";
|
||||||
static gboolean catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr,
|
wtap_rec *rec,
|
||||||
Buffer *buf, int *err,
|
Buffer *buf, int *err,
|
||||||
gchar **err_info);
|
gchar **err_info);
|
||||||
static void catapult_dct2000_close(wtap *wth);
|
static void catapult_dct2000_close(wtap *wth);
|
||||||
|
|
||||||
static gboolean catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
static gboolean catapult_dct2000_dump(wtap_dumper *wdh, const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info);
|
const guint8 *pd, int *err, gchar **err_info);
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ static gboolean parse_line(char *linebuff, gint line_length,
|
||||||
gchar *outhdr_name);
|
gchar *outhdr_name);
|
||||||
static gboolean process_parsed_line(wtap *wth,
|
static gboolean process_parsed_line(wtap *wth,
|
||||||
dct2000_file_externals_t *file_externals,
|
dct2000_file_externals_t *file_externals,
|
||||||
struct wtap_pkthdr *phdr,
|
wtap_rec *rec,
|
||||||
Buffer *buf, gint64 file_offset,
|
Buffer *buf, gint64 file_offset,
|
||||||
char *linebuff, long dollar_offset,
|
char *linebuff, long dollar_offset,
|
||||||
int seconds, int useconds,
|
int seconds, int useconds,
|
||||||
|
@ -379,8 +379,8 @@ catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
|
||||||
*data_offset = this_offset;
|
*data_offset = this_offset;
|
||||||
|
|
||||||
if (!process_parsed_line(wth, file_externals,
|
if (!process_parsed_line(wth, file_externals,
|
||||||
&wth->phdr,
|
&wth->rec,
|
||||||
wth->frame_buffer, this_offset,
|
wth->rec_data, this_offset,
|
||||||
linebuff, dollar_offset,
|
linebuff, dollar_offset,
|
||||||
seconds, useconds,
|
seconds, useconds,
|
||||||
timestamp_string,
|
timestamp_string,
|
||||||
|
@ -435,7 +435,7 @@ catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
|
||||||
/**************************************************/
|
/**************************************************/
|
||||||
static gboolean
|
static gboolean
|
||||||
catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
|
catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
int length;
|
int length;
|
||||||
|
@ -484,7 +484,7 @@ catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
|
||||||
write_timestamp_string(timestamp_string, seconds, useconds/100);
|
write_timestamp_string(timestamp_string, seconds, useconds/100);
|
||||||
|
|
||||||
if (!process_parsed_line(wth, file_externals,
|
if (!process_parsed_line(wth, file_externals,
|
||||||
phdr, buf, seek_off,
|
rec, buf, seek_off,
|
||||||
linebuff, dollar_offset,
|
linebuff, dollar_offset,
|
||||||
seconds, useconds,
|
seconds, useconds,
|
||||||
timestamp_string,
|
timestamp_string,
|
||||||
|
@ -575,10 +575,10 @@ catapult_dct2000_dump_can_write_encap(int encap)
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
catapult_dct2000_dump(wtap_dumper *wdh, const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info _U_)
|
const guint8 *pd, int *err, gchar **err_info _U_)
|
||||||
{
|
{
|
||||||
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
|
const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header;
|
||||||
guint32 n;
|
guint32 n;
|
||||||
line_prefix_info_t *prefix = NULL;
|
line_prefix_info_t *prefix = NULL;
|
||||||
gchar time_string[16];
|
gchar time_string[16];
|
||||||
|
@ -595,7 +595,7 @@ catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||||
(dct2000_file_externals_t*)pseudo_header->dct2000.wth->priv;
|
(dct2000_file_externals_t*)pseudo_header->dct2000.wth->priv;
|
||||||
|
|
||||||
/* We can only write packet records. */
|
/* We can only write packet records. */
|
||||||
if (phdr->rec_type != REC_TYPE_PACKET) {
|
if (rec->rec_type != REC_TYPE_PACKET) {
|
||||||
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -663,15 +663,15 @@ catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||||
is_comment = (consecutive_slashes == 5);
|
is_comment = (consecutive_slashes == 5);
|
||||||
|
|
||||||
/* Calculate time of this packet to write, relative to start of dump */
|
/* Calculate time of this packet to write, relative to start of dump */
|
||||||
if (phdr->ts.nsecs >= dct2000->start_time.nsecs) {
|
if (rec->ts.nsecs >= dct2000->start_time.nsecs) {
|
||||||
write_timestamp_string(time_string,
|
write_timestamp_string(time_string,
|
||||||
(int)(phdr->ts.secs - dct2000->start_time.secs),
|
(int)(rec->ts.secs - dct2000->start_time.secs),
|
||||||
(phdr->ts.nsecs - dct2000->start_time.nsecs) / 100000);
|
(rec->ts.nsecs - dct2000->start_time.nsecs) / 100000);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
write_timestamp_string(time_string,
|
write_timestamp_string(time_string,
|
||||||
(int)(phdr->ts.secs - dct2000->start_time.secs-1),
|
(int)(rec->ts.secs - dct2000->start_time.secs-1),
|
||||||
((1000000000 + (phdr->ts.nsecs / 100000)) - (dct2000->start_time.nsecs / 100000)) % 10000);
|
((1000000000 + (rec->ts.nsecs / 100000)) - (dct2000->start_time.nsecs / 100000)) % 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write out the calculated timestamp */
|
/* Write out the calculated timestamp */
|
||||||
|
@ -734,7 +734,7 @@ catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||||
|
|
||||||
if (!is_comment) {
|
if (!is_comment) {
|
||||||
/* Each binary byte is written out as 2 hex string chars */
|
/* Each binary byte is written out as 2 hex string chars */
|
||||||
for (; n < phdr->len; n++) {
|
for (; n < rec->rec_header.packet_header.len; n++) {
|
||||||
gchar c[2];
|
gchar c[2];
|
||||||
c[0] = char_from_hex((guint8)(pd[n] >> 4));
|
c[0] = char_from_hex((guint8)(pd[n] >> 4));
|
||||||
c[1] = char_from_hex((guint8)(pd[n] & 0x0f));
|
c[1] = char_from_hex((guint8)(pd[n] & 0x0f));
|
||||||
|
@ -746,7 +746,7 @@ catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (; n < phdr->len; n++) {
|
for (; n < rec->rec_header.packet_header.len; n++) {
|
||||||
char c[1];
|
char c[1];
|
||||||
c[0] = pd[n];
|
c[0] = pd[n];
|
||||||
|
|
||||||
|
@ -1272,7 +1272,7 @@ parse_line(gchar *linebuff, gint line_length,
|
||||||
/***********************************/
|
/***********************************/
|
||||||
static gboolean
|
static gboolean
|
||||||
process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals,
|
process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals,
|
||||||
struct wtap_pkthdr *phdr,
|
wtap_rec *rec,
|
||||||
Buffer *buf, gint64 file_offset,
|
Buffer *buf, gint64 file_offset,
|
||||||
char *linebuff, long dollar_offset,
|
char *linebuff, long dollar_offset,
|
||||||
int seconds, int useconds, gchar *timestamp_string,
|
int seconds, int useconds, gchar *timestamp_string,
|
||||||
|
@ -1288,25 +1288,25 @@ process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals,
|
||||||
gsize length;
|
gsize length;
|
||||||
guint8 *frame_buffer;
|
guint8 *frame_buffer;
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS;
|
rec->presence_flags = WTAP_HAS_TS;
|
||||||
|
|
||||||
/* Make sure all packets go to Catapult DCT2000 dissector */
|
/* Make sure all packets go to Catapult DCT2000 dissector */
|
||||||
phdr->pkt_encap = WTAP_ENCAP_CATAPULT_DCT2000;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_CATAPULT_DCT2000;
|
||||||
|
|
||||||
/* Fill in timestamp (capture base + packet offset) */
|
/* Fill in timestamp (capture base + packet offset) */
|
||||||
phdr->ts.secs = file_externals->start_secs + seconds;
|
rec->ts.secs = file_externals->start_secs + seconds;
|
||||||
if ((file_externals->start_usecs + useconds) >= 1000000) {
|
if ((file_externals->start_usecs + useconds) >= 1000000) {
|
||||||
phdr->ts.secs++;
|
rec->ts.secs++;
|
||||||
}
|
}
|
||||||
phdr->ts.nsecs =
|
rec->ts.nsecs =
|
||||||
((file_externals->start_usecs + useconds) % 1000000) *1000;
|
((file_externals->start_usecs + useconds) % 1000000) *1000;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate the length of the stub info and the packet data.
|
* Calculate the length of the stub info and the packet data.
|
||||||
* The packet data length is half bytestring length.
|
* The packet data length is half bytestring length.
|
||||||
*/
|
*/
|
||||||
phdr->caplen = (guint)strlen(context_name)+1 + /* Context name */
|
rec->rec_header.packet_header.caplen = (guint)strlen(context_name)+1 + /* Context name */
|
||||||
1 + /* port */
|
1 + /* port */
|
||||||
(guint)strlen(timestamp_string)+1 + /* timestamp */
|
(guint)strlen(timestamp_string)+1 + /* timestamp */
|
||||||
(guint)strlen(variant_name)+1 + /* variant */
|
(guint)strlen(variant_name)+1 + /* variant */
|
||||||
|
@ -1315,7 +1315,7 @@ process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals,
|
||||||
1 + /* direction */
|
1 + /* direction */
|
||||||
1 + /* encap */
|
1 + /* encap */
|
||||||
(is_comment ? data_chars : (data_chars/2));
|
(is_comment ? data_chars : (data_chars/2));
|
||||||
if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
||||||
/*
|
/*
|
||||||
* Probably a corrupt capture file; return an error,
|
* Probably a corrupt capture file; return an error,
|
||||||
* so that our caller doesn't blow up trying to allocate
|
* so that our caller doesn't blow up trying to allocate
|
||||||
|
@ -1323,14 +1323,14 @@ process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals,
|
||||||
*/
|
*/
|
||||||
*err = WTAP_ERR_BAD_FILE;
|
*err = WTAP_ERR_BAD_FILE;
|
||||||
*err_info = g_strdup_printf("catapult dct2000: File has %u-byte packet, bigger than maximum of %u",
|
*err_info = g_strdup_printf("catapult dct2000: File has %u-byte packet, bigger than maximum of %u",
|
||||||
phdr->caplen, WTAP_MAX_PACKET_SIZE_STANDARD);
|
rec->rec_header.packet_header.caplen, WTAP_MAX_PACKET_SIZE_STANDARD);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
phdr->len = phdr->caplen;
|
rec->rec_header.packet_header.len = rec->rec_header.packet_header.caplen;
|
||||||
|
|
||||||
/*****************************/
|
/*****************************/
|
||||||
/* Get the data buffer ready */
|
/* Get the data buffer ready */
|
||||||
ws_buffer_assure_space(buf, phdr->caplen);
|
ws_buffer_assure_space(buf, rec->rec_header.packet_header.caplen);
|
||||||
frame_buffer = ws_buffer_start_ptr(buf);
|
frame_buffer = ws_buffer_start_ptr(buf);
|
||||||
|
|
||||||
/******************************************/
|
/******************************************/
|
||||||
|
@ -1386,18 +1386,18 @@ process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals,
|
||||||
|
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
/* Set packet pseudo-header if necessary */
|
/* Set packet pseudo-header if necessary */
|
||||||
phdr->pseudo_header.dct2000.seek_off = file_offset;
|
rec->rec_header.packet_header.pseudo_header.dct2000.seek_off = file_offset;
|
||||||
phdr->pseudo_header.dct2000.wth = wth;
|
rec->rec_header.packet_header.pseudo_header.dct2000.wth = wth;
|
||||||
|
|
||||||
switch (encap) {
|
switch (encap) {
|
||||||
case WTAP_ENCAP_ATM_PDUS_UNTRUNCATED:
|
case WTAP_ENCAP_ATM_PDUS_UNTRUNCATED:
|
||||||
set_aal_info(&phdr->pseudo_header, direction, aal_header_chars);
|
set_aal_info(&rec->rec_header.packet_header.pseudo_header, direction, aal_header_chars);
|
||||||
break;
|
break;
|
||||||
case WTAP_ENCAP_ISDN:
|
case WTAP_ENCAP_ISDN:
|
||||||
set_isdn_info(&phdr->pseudo_header, direction);
|
set_isdn_info(&rec->rec_header.packet_header.pseudo_header, direction);
|
||||||
break;
|
break;
|
||||||
case WTAP_ENCAP_PPP:
|
case WTAP_ENCAP_PPP:
|
||||||
set_ppp_info(&phdr->pseudo_header, direction);
|
set_ppp_info(&rec->rec_header.packet_header.pseudo_header, direction);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -75,11 +75,11 @@ typedef struct commview_header {
|
||||||
static gboolean commview_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean commview_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean commview_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean commview_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr,
|
wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info);
|
Buffer *buf, int *err, gchar **err_info);
|
||||||
static gboolean commview_read_header(commview_header_t *cv_hdr, FILE_T fh,
|
static gboolean commview_read_header(commview_header_t *cv_hdr, FILE_T fh,
|
||||||
int *err, gchar **err_info);
|
int *err, gchar **err_info);
|
||||||
static gboolean commview_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
static gboolean commview_dump(wtap_dumper *wdh, const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info);
|
const guint8 *pd, int *err, gchar **err_info);
|
||||||
|
|
||||||
wtap_open_return_val commview_open(wtap *wth, int *err, gchar **err_info)
|
wtap_open_return_val commview_open(wtap *wth, int *err, gchar **err_info)
|
||||||
|
@ -123,7 +123,7 @@ wtap_open_return_val commview_open(wtap *wth, int *err, gchar **err_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
commview_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
commview_header_t cv_hdr;
|
commview_header_t cv_hdr;
|
||||||
|
@ -141,63 +141,63 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
switch(cv_hdr.flags & FLAGS_MEDIUM) {
|
switch(cv_hdr.flags & FLAGS_MEDIUM) {
|
||||||
|
|
||||||
case MEDIUM_ETHERNET :
|
case MEDIUM_ETHERNET :
|
||||||
phdr->pkt_encap = WTAP_ENCAP_ETHERNET;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ETHERNET;
|
||||||
phdr->pseudo_header.eth.fcs_len = -1; /* Unknown */
|
rec->rec_header.packet_header.pseudo_header.eth.fcs_len = -1; /* Unknown */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MEDIUM_WIFI :
|
case MEDIUM_WIFI :
|
||||||
phdr->pkt_encap = WTAP_ENCAP_IEEE_802_11_WITH_RADIO;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_IEEE_802_11_WITH_RADIO;
|
||||||
memset(&phdr->pseudo_header.ieee_802_11, 0, sizeof(phdr->pseudo_header.ieee_802_11));
|
memset(&rec->rec_header.packet_header.pseudo_header.ieee_802_11, 0, sizeof(rec->rec_header.packet_header.pseudo_header.ieee_802_11));
|
||||||
phdr->pseudo_header.ieee_802_11.fcs_len = -1; /* Unknown */
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.fcs_len = -1; /* Unknown */
|
||||||
phdr->pseudo_header.ieee_802_11.decrypted = FALSE;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.decrypted = FALSE;
|
||||||
phdr->pseudo_header.ieee_802_11.datapad = FALSE;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.datapad = FALSE;
|
||||||
phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_UNKNOWN;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_UNKNOWN;
|
||||||
switch (cv_hdr.band) {
|
switch (cv_hdr.band) {
|
||||||
|
|
||||||
case BAND_11A:
|
case BAND_11A:
|
||||||
phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11A;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11A;
|
||||||
phdr->pseudo_header.ieee_802_11.phy_info.info_11a.has_turbo_type = TRUE;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11a.has_turbo_type = TRUE;
|
||||||
phdr->pseudo_header.ieee_802_11.phy_info.info_11a.turbo_type =
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11a.turbo_type =
|
||||||
PHDR_802_11A_TURBO_TYPE_NORMAL;
|
PHDR_802_11A_TURBO_TYPE_NORMAL;
|
||||||
frequency = ieee80211_chan_to_mhz(cv_hdr.channel, FALSE);
|
frequency = ieee80211_chan_to_mhz(cv_hdr.channel, FALSE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BAND_11B:
|
case BAND_11B:
|
||||||
phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11B;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11B;
|
||||||
frequency = ieee80211_chan_to_mhz(cv_hdr.channel, TRUE);
|
frequency = ieee80211_chan_to_mhz(cv_hdr.channel, TRUE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BAND_11G:
|
case BAND_11G:
|
||||||
phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11G;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11G;
|
||||||
phdr->pseudo_header.ieee_802_11.phy_info.info_11g.has_mode = TRUE;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11g.has_mode = TRUE;
|
||||||
phdr->pseudo_header.ieee_802_11.phy_info.info_11g.mode =
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11g.mode =
|
||||||
PHDR_802_11G_MODE_NORMAL;
|
PHDR_802_11G_MODE_NORMAL;
|
||||||
frequency = ieee80211_chan_to_mhz(cv_hdr.channel, TRUE);
|
frequency = ieee80211_chan_to_mhz(cv_hdr.channel, TRUE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BAND_11A_TURBO:
|
case BAND_11A_TURBO:
|
||||||
phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11A;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11A;
|
||||||
phdr->pseudo_header.ieee_802_11.phy_info.info_11a.has_turbo_type = TRUE;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11a.has_turbo_type = TRUE;
|
||||||
phdr->pseudo_header.ieee_802_11.phy_info.info_11a.turbo_type =
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11a.turbo_type =
|
||||||
PHDR_802_11A_TURBO_TYPE_TURBO;
|
PHDR_802_11A_TURBO_TYPE_TURBO;
|
||||||
frequency = ieee80211_chan_to_mhz(cv_hdr.channel, FALSE);
|
frequency = ieee80211_chan_to_mhz(cv_hdr.channel, FALSE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BAND_SUPERG:
|
case BAND_SUPERG:
|
||||||
phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11G;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11G;
|
||||||
phdr->pseudo_header.ieee_802_11.phy_info.info_11g.has_mode = TRUE;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11g.has_mode = TRUE;
|
||||||
phdr->pseudo_header.ieee_802_11.phy_info.info_11g.mode =
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11g.mode =
|
||||||
PHDR_802_11G_MODE_SUPER_G;
|
PHDR_802_11G_MODE_SUPER_G;
|
||||||
frequency = ieee80211_chan_to_mhz(cv_hdr.channel, TRUE);
|
frequency = ieee80211_chan_to_mhz(cv_hdr.channel, TRUE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BAND_11N_5GHZ:
|
case BAND_11N_5GHZ:
|
||||||
phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11N;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11N;
|
||||||
frequency = ieee80211_chan_to_mhz(cv_hdr.channel, FALSE);
|
frequency = ieee80211_chan_to_mhz(cv_hdr.channel, FALSE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BAND_11N_2_4GHZ:
|
case BAND_11N_2_4GHZ:
|
||||||
phdr->pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11N;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy = PHDR_802_11_PHY_11N;
|
||||||
frequency = ieee80211_chan_to_mhz(cv_hdr.channel, TRUE);
|
frequency = ieee80211_chan_to_mhz(cv_hdr.channel, TRUE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -215,18 +215,18 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (frequency != 0) {
|
if (frequency != 0) {
|
||||||
phdr->pseudo_header.ieee_802_11.has_frequency = TRUE;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_frequency = TRUE;
|
||||||
phdr->pseudo_header.ieee_802_11.frequency = frequency;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.frequency = frequency;
|
||||||
}
|
}
|
||||||
phdr->pseudo_header.ieee_802_11.has_channel = TRUE;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_channel = TRUE;
|
||||||
phdr->pseudo_header.ieee_802_11.channel = cv_hdr.channel;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.channel = cv_hdr.channel;
|
||||||
|
|
||||||
phdr->pseudo_header.ieee_802_11.has_data_rate = TRUE;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_data_rate = TRUE;
|
||||||
phdr->pseudo_header.ieee_802_11.data_rate =
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.data_rate =
|
||||||
cv_hdr.rate | (cv_hdr.direction << 8);
|
cv_hdr.rate | (cv_hdr.direction << 8);
|
||||||
|
|
||||||
phdr->pseudo_header.ieee_802_11.has_signal_percent = TRUE;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_signal_percent = TRUE;
|
||||||
phdr->pseudo_header.ieee_802_11.signal_percent = cv_hdr.signal_level_percent;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.signal_percent = cv_hdr.signal_level_percent;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX - these are positive in captures I've seen; does
|
* XXX - these are positive in captures I've seen; does
|
||||||
|
@ -239,17 +239,17 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
* value is provided.
|
* value is provided.
|
||||||
*/
|
*/
|
||||||
if (cv_hdr.signal_level_dbm != 0) {
|
if (cv_hdr.signal_level_dbm != 0) {
|
||||||
phdr->pseudo_header.ieee_802_11.signal_dbm = -cv_hdr.signal_level_dbm;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.signal_dbm = -cv_hdr.signal_level_dbm;
|
||||||
phdr->pseudo_header.ieee_802_11.has_signal_dbm = TRUE;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_signal_dbm = TRUE;
|
||||||
}
|
}
|
||||||
if (cv_hdr.noise_level != 0) {
|
if (cv_hdr.noise_level != 0) {
|
||||||
phdr->pseudo_header.ieee_802_11.noise_dbm = -cv_hdr.noise_level;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.noise_dbm = -cv_hdr.noise_level;
|
||||||
phdr->pseudo_header.ieee_802_11.has_noise_dbm = TRUE;
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_noise_dbm = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MEDIUM_TOKEN_RING :
|
case MEDIUM_TOKEN_RING :
|
||||||
phdr->pkt_encap = WTAP_ENCAP_TOKEN_RING;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_TOKEN_RING;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
|
@ -267,16 +267,16 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
tm.tm_sec = cv_hdr.seconds;
|
tm.tm_sec = cv_hdr.seconds;
|
||||||
tm.tm_isdst = -1;
|
tm.tm_isdst = -1;
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS;
|
rec->presence_flags = WTAP_HAS_TS;
|
||||||
|
|
||||||
phdr->len = cv_hdr.data_len;
|
rec->rec_header.packet_header.len = cv_hdr.data_len;
|
||||||
phdr->caplen = cv_hdr.data_len;
|
rec->rec_header.packet_header.caplen = cv_hdr.data_len;
|
||||||
|
|
||||||
phdr->ts.secs = mktime(&tm);
|
rec->ts.secs = mktime(&tm);
|
||||||
phdr->ts.nsecs = cv_hdr.usecs * 1000;
|
rec->ts.nsecs = cv_hdr.usecs * 1000;
|
||||||
|
|
||||||
return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info);
|
return wtap_read_packet_bytes(fh, buf, rec->rec_header.packet_header.caplen, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -284,18 +284,18 @@ commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||||
{
|
{
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
|
|
||||||
return commview_read_packet(wth->fh, &wth->phdr, wth->frame_buffer, err,
|
return commview_read_packet(wth->fh, &wth->rec, wth->rec_data, err,
|
||||||
err_info);
|
err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
commview_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
commview_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return commview_read_packet(wth->random_fh, phdr, buf, err, err_info);
|
return commview_read_packet(wth->random_fh, rec, buf, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -381,14 +381,14 @@ gboolean commview_dump_open(wtap_dumper *wdh, int *err _U_)
|
||||||
/* Write a record for a packet to a dump file.
|
/* Write a record for a packet to a dump file.
|
||||||
* Returns TRUE on success, FALSE on failure. */
|
* Returns TRUE on success, FALSE on failure. */
|
||||||
static gboolean commview_dump(wtap_dumper *wdh,
|
static gboolean commview_dump(wtap_dumper *wdh,
|
||||||
const struct wtap_pkthdr *phdr,
|
const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info _U_)
|
const guint8 *pd, int *err, gchar **err_info _U_)
|
||||||
{
|
{
|
||||||
commview_header_t cv_hdr;
|
commview_header_t cv_hdr;
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
|
|
||||||
/* We can only write packet records. */
|
/* We can only write packet records. */
|
||||||
if (phdr->rec_type != REC_TYPE_PACKET) {
|
if (rec->rec_type != REC_TYPE_PACKET) {
|
||||||
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -396,18 +396,18 @@ static gboolean commview_dump(wtap_dumper *wdh,
|
||||||
/* Don't write out anything bigger than we can read.
|
/* Don't write out anything bigger than we can read.
|
||||||
* (The length field in packet headers is 16 bits, which
|
* (The length field in packet headers is 16 bits, which
|
||||||
* imposes a hard limit.) */
|
* imposes a hard limit.) */
|
||||||
if (phdr->caplen > 65535) {
|
if (rec->rec_header.packet_header.caplen > 65535) {
|
||||||
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&cv_hdr, 0, sizeof(cv_hdr));
|
memset(&cv_hdr, 0, sizeof(cv_hdr));
|
||||||
|
|
||||||
cv_hdr.data_len = GUINT16_TO_LE((guint16)phdr->caplen);
|
cv_hdr.data_len = GUINT16_TO_LE((guint16)rec->rec_header.packet_header.caplen);
|
||||||
cv_hdr.source_data_len = GUINT16_TO_LE((guint16)phdr->caplen);
|
cv_hdr.source_data_len = GUINT16_TO_LE((guint16)rec->rec_header.packet_header.caplen);
|
||||||
cv_hdr.version = 0;
|
cv_hdr.version = 0;
|
||||||
|
|
||||||
tm = localtime(&phdr->ts.secs);
|
tm = localtime(&rec->ts.secs);
|
||||||
if (tm != NULL) {
|
if (tm != NULL) {
|
||||||
cv_hdr.year = tm->tm_year + 1900;
|
cv_hdr.year = tm->tm_year + 1900;
|
||||||
cv_hdr.month = tm->tm_mon + 1;
|
cv_hdr.month = tm->tm_mon + 1;
|
||||||
|
@ -415,7 +415,7 @@ static gboolean commview_dump(wtap_dumper *wdh,
|
||||||
cv_hdr.hours = tm->tm_hour;
|
cv_hdr.hours = tm->tm_hour;
|
||||||
cv_hdr.minutes = tm->tm_min;
|
cv_hdr.minutes = tm->tm_min;
|
||||||
cv_hdr.seconds = tm->tm_sec;
|
cv_hdr.seconds = tm->tm_sec;
|
||||||
cv_hdr.usecs = GUINT32_TO_LE(phdr->ts.nsecs / 1000);
|
cv_hdr.usecs = GUINT32_TO_LE(rec->ts.nsecs / 1000);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Second before the Epoch.
|
* Second before the Epoch.
|
||||||
|
@ -429,7 +429,7 @@ static gboolean commview_dump(wtap_dumper *wdh,
|
||||||
cv_hdr.usecs = 0;
|
cv_hdr.usecs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(phdr->pkt_encap) {
|
switch(rec->rec_header.packet_header.pkt_encap) {
|
||||||
|
|
||||||
case WTAP_ENCAP_ETHERNET :
|
case WTAP_ENCAP_ETHERNET :
|
||||||
cv_hdr.flags |= MEDIUM_ETHERNET;
|
cv_hdr.flags |= MEDIUM_ETHERNET;
|
||||||
|
@ -442,15 +442,15 @@ static gboolean commview_dump(wtap_dumper *wdh,
|
||||||
case WTAP_ENCAP_IEEE_802_11_WITH_RADIO :
|
case WTAP_ENCAP_IEEE_802_11_WITH_RADIO :
|
||||||
cv_hdr.flags |= MEDIUM_WIFI;
|
cv_hdr.flags |= MEDIUM_WIFI;
|
||||||
|
|
||||||
switch (phdr->pseudo_header.ieee_802_11.phy) {
|
switch (rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy) {
|
||||||
|
|
||||||
case PHDR_802_11_PHY_11A:
|
case PHDR_802_11_PHY_11A:
|
||||||
/*
|
/*
|
||||||
* If we don't know whether it's turbo, say it's
|
* If we don't know whether it's turbo, say it's
|
||||||
* not.
|
* not.
|
||||||
*/
|
*/
|
||||||
if (!phdr->pseudo_header.ieee_802_11.phy_info.info_11a.has_turbo_type ||
|
if (!rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11a.has_turbo_type ||
|
||||||
phdr->pseudo_header.ieee_802_11.phy_info.info_11a.turbo_type == PHDR_802_11A_TURBO_TYPE_NORMAL)
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11a.turbo_type == PHDR_802_11A_TURBO_TYPE_NORMAL)
|
||||||
cv_hdr.band = BAND_11A;
|
cv_hdr.band = BAND_11A;
|
||||||
else
|
else
|
||||||
cv_hdr.band = BAND_11A_TURBO;
|
cv_hdr.band = BAND_11A_TURBO;
|
||||||
|
@ -465,10 +465,10 @@ static gboolean commview_dump(wtap_dumper *wdh,
|
||||||
* If we don't know whether it's Super G, say it's
|
* If we don't know whether it's Super G, say it's
|
||||||
* not.
|
* not.
|
||||||
*/
|
*/
|
||||||
if (!phdr->pseudo_header.ieee_802_11.phy_info.info_11g.has_mode)
|
if (!rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11g.has_mode)
|
||||||
cv_hdr.band = BAND_11G;
|
cv_hdr.band = BAND_11G;
|
||||||
else {
|
else {
|
||||||
switch (phdr->pseudo_header.ieee_802_11.phy_info.info_11g.mode) {
|
switch (rec->rec_header.packet_header.pseudo_header.ieee_802_11.phy_info.info_11g.mode) {
|
||||||
|
|
||||||
case PHDR_802_11G_MODE_NORMAL:
|
case PHDR_802_11G_MODE_NORMAL:
|
||||||
cv_hdr.band = BAND_11G;
|
cv_hdr.band = BAND_11G;
|
||||||
|
@ -489,8 +489,8 @@ static gboolean commview_dump(wtap_dumper *wdh,
|
||||||
/*
|
/*
|
||||||
* Pick the band based on the frequency.
|
* Pick the band based on the frequency.
|
||||||
*/
|
*/
|
||||||
if (phdr->pseudo_header.ieee_802_11.has_frequency) {
|
if (rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_frequency) {
|
||||||
if (phdr->pseudo_header.ieee_802_11.frequency > 2484) {
|
if (rec->rec_header.packet_header.pseudo_header.ieee_802_11.frequency > 2484) {
|
||||||
/* 5 GHz band */
|
/* 5 GHz band */
|
||||||
cv_hdr.band = BAND_11N_5GHZ;
|
cv_hdr.band = BAND_11N_5GHZ;
|
||||||
} else {
|
} else {
|
||||||
|
@ -512,28 +512,28 @@ static gboolean commview_dump(wtap_dumper *wdh,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cv_hdr.channel =
|
cv_hdr.channel =
|
||||||
phdr->pseudo_header.ieee_802_11.has_channel ?
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_channel ?
|
||||||
phdr->pseudo_header.ieee_802_11.channel :
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.channel :
|
||||||
0;
|
0;
|
||||||
cv_hdr.rate =
|
cv_hdr.rate =
|
||||||
phdr->pseudo_header.ieee_802_11.has_data_rate ?
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_data_rate ?
|
||||||
(guint8)(phdr->pseudo_header.ieee_802_11.data_rate & 0xFF) :
|
(guint8)(rec->rec_header.packet_header.pseudo_header.ieee_802_11.data_rate & 0xFF) :
|
||||||
0;
|
0;
|
||||||
cv_hdr.direction =
|
cv_hdr.direction =
|
||||||
phdr->pseudo_header.ieee_802_11.has_data_rate ?
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_data_rate ?
|
||||||
(guint8)((phdr->pseudo_header.ieee_802_11.data_rate >> 8) & 0xFF) :
|
(guint8)((rec->rec_header.packet_header.pseudo_header.ieee_802_11.data_rate >> 8) & 0xFF) :
|
||||||
0;
|
0;
|
||||||
cv_hdr.signal_level_percent =
|
cv_hdr.signal_level_percent =
|
||||||
phdr->pseudo_header.ieee_802_11.has_signal_percent ?
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_signal_percent ?
|
||||||
phdr->pseudo_header.ieee_802_11.signal_percent :
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.signal_percent :
|
||||||
0;
|
0;
|
||||||
cv_hdr.signal_level_dbm =
|
cv_hdr.signal_level_dbm =
|
||||||
phdr->pseudo_header.ieee_802_11.has_signal_dbm ?
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_signal_dbm ?
|
||||||
-phdr->pseudo_header.ieee_802_11.signal_dbm :
|
-rec->rec_header.packet_header.pseudo_header.ieee_802_11.signal_dbm :
|
||||||
0;
|
0;
|
||||||
cv_hdr.noise_level =
|
cv_hdr.noise_level =
|
||||||
phdr->pseudo_header.ieee_802_11.has_noise_dbm ?
|
rec->rec_header.packet_header.pseudo_header.ieee_802_11.has_noise_dbm ?
|
||||||
-phdr->pseudo_header.ieee_802_11.noise_dbm :
|
-rec->rec_header.packet_header.pseudo_header.ieee_802_11.noise_dbm :
|
||||||
0;
|
0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -584,9 +584,9 @@ static gboolean commview_dump(wtap_dumper *wdh,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
wdh->bytes_dumped += COMMVIEW_HEADER_SIZE;
|
wdh->bytes_dumped += COMMVIEW_HEADER_SIZE;
|
||||||
|
|
||||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
|
if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
wdh->bytes_dumped += phdr->caplen;
|
wdh->bytes_dumped += rec->rec_header.packet_header.caplen;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,8 +152,8 @@ static gboolean cosine_check_file_type(wtap *wth, int *err, gchar **err_info);
|
||||||
static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean cosine_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean cosine_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
static int parse_cosine_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer* buf,
|
static int parse_cosine_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
|
||||||
char *line, int *err, gchar **err_info);
|
char *line, int *err, gchar **err_info);
|
||||||
static int parse_single_hex_dump_line(char* rec, guint8 *buf,
|
static int parse_single_hex_dump_line(char* rec, guint8 *buf,
|
||||||
guint byte_offset);
|
guint byte_offset);
|
||||||
|
@ -280,13 +280,13 @@ static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
|
||||||
*data_offset = offset;
|
*data_offset = offset;
|
||||||
|
|
||||||
/* Parse the header and convert the ASCII hex dump to binary data */
|
/* Parse the header and convert the ASCII hex dump to binary data */
|
||||||
return parse_cosine_packet(wth->fh, &wth->phdr, wth->frame_buffer,
|
return parse_cosine_packet(wth->fh, &wth->rec, wth->rec_data,
|
||||||
line, err, err_info);
|
line, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Used to read packets in random-access fashion */
|
/* Used to read packets in random-access fashion */
|
||||||
static gboolean
|
static gboolean
|
||||||
cosine_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
cosine_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
char line[COSINE_LINE_LENGTH];
|
char line[COSINE_LINE_LENGTH];
|
||||||
|
@ -303,7 +303,7 @@ cosine_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse the header and convert the ASCII hex dump to binary data */
|
/* Parse the header and convert the ASCII hex dump to binary data */
|
||||||
return parse_cosine_packet(wth->random_fh, phdr, buf, line, err,
|
return parse_cosine_packet(wth->random_fh, rec, buf, line, err,
|
||||||
err_info);
|
err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,10 +313,10 @@ cosine_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||||
2) output to PE without date and time
|
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] */
|
l2-tx (FR:3/7/1:1), Length:18, Pro:0, Off:0, Pri:0, RM:0, Err:0 [0x4000, 0x0] */
|
||||||
static gboolean
|
static gboolean
|
||||||
parse_cosine_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
parse_cosine_packet(FILE_T fh, wtap_rec *rec, Buffer *buf,
|
||||||
char *line, int *err, gchar **err_info)
|
char *line, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
|
union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header;
|
||||||
int num_items_scanned;
|
int num_items_scanned;
|
||||||
int yy, mm, dd, hr, min, sec, csec, pkt_len;
|
int yy, mm, dd, hr, min, sec, csec, pkt_len;
|
||||||
int pro, off, pri, rm, error;
|
int pro, off, pri, rm, error;
|
||||||
|
@ -372,8 +372,8 @@ parse_cosine_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
||||||
tm.tm_year = yy - 1900;
|
tm.tm_year = yy - 1900;
|
||||||
tm.tm_mon = mm - 1;
|
tm.tm_mon = mm - 1;
|
||||||
tm.tm_mday = dd;
|
tm.tm_mday = dd;
|
||||||
|
@ -381,9 +381,9 @@ parse_cosine_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
tm.tm_min = min;
|
tm.tm_min = min;
|
||||||
tm.tm_sec = sec;
|
tm.tm_sec = sec;
|
||||||
tm.tm_isdst = -1;
|
tm.tm_isdst = -1;
|
||||||
phdr->ts.secs = mktime(&tm);
|
rec->ts.secs = mktime(&tm);
|
||||||
phdr->ts.nsecs = csec * 10000000;
|
rec->ts.nsecs = csec * 10000000;
|
||||||
phdr->len = pkt_len;
|
rec->rec_header.packet_header.len = pkt_len;
|
||||||
|
|
||||||
/* XXX need to handle other encapsulations like Cisco HDLC,
|
/* XXX need to handle other encapsulations like Cisco HDLC,
|
||||||
Frame Relay and ATM */
|
Frame Relay and ATM */
|
||||||
|
@ -445,7 +445,7 @@ parse_cosine_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
}
|
}
|
||||||
caplen += n;
|
caplen += n;
|
||||||
}
|
}
|
||||||
phdr->caplen = caplen;
|
rec->rec_header.packet_header.caplen = caplen;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,9 @@ typedef struct {
|
||||||
static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean csids_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean csids_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
static gboolean csids_read_packet(FILE_T fh, csids_t *csids,
|
static gboolean csids_read_packet(FILE_T fh, csids_t *csids,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
|
|
||||||
struct csids_header {
|
struct csids_header {
|
||||||
guint32 seconds; /* seconds since epoch */
|
guint32 seconds; /* seconds since epoch */
|
||||||
|
@ -130,7 +130,7 @@ static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
|
||||||
|
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
|
|
||||||
return csids_read_packet( wth->fh, csids, &wth->phdr, wth->frame_buffer,
|
return csids_read_packet( wth->fh, csids, &wth->rec, wth->rec_data,
|
||||||
err, err_info );
|
err, err_info );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
|
||||||
static gboolean
|
static gboolean
|
||||||
csids_seek_read(wtap *wth,
|
csids_seek_read(wtap *wth,
|
||||||
gint64 seek_off,
|
gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr,
|
wtap_rec *rec,
|
||||||
Buffer *buf,
|
Buffer *buf,
|
||||||
int *err,
|
int *err,
|
||||||
gchar **err_info)
|
gchar **err_info)
|
||||||
|
@ -148,7 +148,7 @@ csids_seek_read(wtap *wth,
|
||||||
if( file_seek( wth->random_fh, seek_off, SEEK_SET, err ) == -1 )
|
if( file_seek( wth->random_fh, seek_off, SEEK_SET, err ) == -1 )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if( !csids_read_packet( wth->random_fh, csids, phdr, buf, err, err_info ) ) {
|
if( !csids_read_packet( wth->random_fh, csids, rec, buf, err, err_info ) ) {
|
||||||
if( *err == 0 )
|
if( *err == 0 )
|
||||||
*err = WTAP_ERR_SHORT_READ;
|
*err = WTAP_ERR_SHORT_READ;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -157,7 +157,7 @@ csids_seek_read(wtap *wth,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
csids_read_packet(FILE_T fh, csids_t *csids, struct wtap_pkthdr *phdr,
|
csids_read_packet(FILE_T fh, csids_t *csids, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
struct csids_header hdr;
|
struct csids_header hdr;
|
||||||
|
@ -173,23 +173,23 @@ csids_read_packet(FILE_T fh, csids_t *csids, struct wtap_pkthdr *phdr,
|
||||||
* it.
|
* it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS;
|
rec->presence_flags = WTAP_HAS_TS;
|
||||||
phdr->len = hdr.caplen;
|
rec->rec_header.packet_header.len = hdr.caplen;
|
||||||
phdr->caplen = hdr.caplen;
|
rec->rec_header.packet_header.caplen = hdr.caplen;
|
||||||
phdr->ts.secs = hdr.seconds;
|
rec->ts.secs = hdr.seconds;
|
||||||
phdr->ts.nsecs = 0;
|
rec->ts.nsecs = 0;
|
||||||
|
|
||||||
if( !wtap_read_packet_bytes( fh, buf, phdr->caplen, err, err_info ) )
|
if( !wtap_read_packet_bytes( fh, buf, rec->rec_header.packet_header.caplen, err, err_info ) )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
pd = ws_buffer_start_ptr( buf );
|
pd = ws_buffer_start_ptr( buf );
|
||||||
if( csids->byteswapped ) {
|
if( csids->byteswapped ) {
|
||||||
if( phdr->caplen >= 2 ) {
|
if( rec->rec_header.packet_header.caplen >= 2 ) {
|
||||||
PBSWAP16(pd); /* the ip len */
|
PBSWAP16(pd); /* the ip len */
|
||||||
if( phdr->caplen >= 4 ) {
|
if( rec->rec_header.packet_header.caplen >= 4 ) {
|
||||||
PBSWAP16(pd+2); /* ip id */
|
PBSWAP16(pd+2); /* ip id */
|
||||||
if( phdr->caplen >= 6 )
|
if( rec->rec_header.packet_header.caplen >= 6 )
|
||||||
PBSWAP16(pd+4); /* ip flags and fragoff */
|
PBSWAP16(pd+4); /* ip flags and fragoff */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,9 +61,9 @@ static gboolean daintree_sna_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
|
|
||||||
static gboolean daintree_sna_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean daintree_sna_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
|
|
||||||
static gboolean daintree_sna_read_packet(FILE_T fh, struct wtap_pkthdr *phdr,
|
static gboolean daintree_sna_read_packet(FILE_T fh, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info);
|
Buffer *buf, int *err, gchar **err_info);
|
||||||
|
|
||||||
/* Open a file and determine if it's a Daintree file */
|
/* Open a file and determine if it's a Daintree file */
|
||||||
|
@ -114,21 +114,21 @@ daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
|
|
||||||
/* parse that line and the following packet data */
|
/* parse that line and the following packet data */
|
||||||
return daintree_sna_read_packet(wth->fh, &wth->phdr,
|
return daintree_sna_read_packet(wth->fh, &wth->rec,
|
||||||
wth->frame_buffer, err, err_info);
|
wth->rec_data, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the capture file randomly
|
/* Read the capture file randomly
|
||||||
* Wireshark opens the capture file for random access when displaying user-selected packets */
|
* Wireshark opens the capture file for random access when displaying user-selected packets */
|
||||||
static gboolean
|
static gboolean
|
||||||
daintree_sna_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
daintree_sna_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* parse that line and the following packet data */
|
/* parse that line and the following packet data */
|
||||||
return daintree_sna_read_packet(wth->random_fh, phdr, buf, err,
|
return daintree_sna_read_packet(wth->random_fh, rec, buf, err,
|
||||||
err_info);
|
err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ daintree_sna_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||||
* sanity-check its length against what we assume is the packet length field,
|
* sanity-check its length against what we assume is the packet length field,
|
||||||
* and copy it into a Buffer. */
|
* and copy it into a Buffer. */
|
||||||
static gboolean
|
static gboolean
|
||||||
daintree_sna_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
daintree_sna_read_packet(FILE_T fh, wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
guint64 seconds;
|
guint64 seconds;
|
||||||
|
@ -157,27 +157,27 @@ daintree_sna_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
}
|
}
|
||||||
} while (readLine[0] == COMMENT_LINE);
|
} while (readLine[0] == COMMENT_LINE);
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
||||||
|
|
||||||
if (sscanf(readLine, "%*s %18" G_GINT64_MODIFIER "u.%9d %9u %" READDATA_MAX_FIELD_SIZE "s",
|
if (sscanf(readLine, "%*s %18" G_GINT64_MODIFIER "u.%9d %9u %" READDATA_MAX_FIELD_SIZE "s",
|
||||||
&seconds, &useconds, &phdr->len, readData) != 4) {
|
&seconds, &useconds, &rec->rec_header.packet_header.len, readData) != 4) {
|
||||||
*err = WTAP_ERR_BAD_FILE;
|
*err = WTAP_ERR_BAD_FILE;
|
||||||
*err_info = g_strdup("daintree_sna: invalid read record");
|
*err_info = g_strdup("daintree_sna: invalid read record");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Daintree doesn't store the FCS, but pads end of packet with 0xffff, which we toss */
|
/* Daintree doesn't store the FCS, but pads end of packet with 0xffff, which we toss */
|
||||||
if (phdr->len <= FCS_LENGTH) {
|
if (rec->rec_header.packet_header.len <= FCS_LENGTH) {
|
||||||
*err = WTAP_ERR_BAD_FILE;
|
*err = WTAP_ERR_BAD_FILE;
|
||||||
*err_info = g_strdup_printf("daintree_sna: packet length <= %u bytes, no frame data present",
|
*err_info = g_strdup_printf("daintree_sna: packet length <= %u bytes, no frame data present",
|
||||||
FCS_LENGTH);
|
FCS_LENGTH);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
phdr->len -= FCS_LENGTH;
|
rec->rec_header.packet_header.len -= FCS_LENGTH;
|
||||||
|
|
||||||
phdr->ts.secs = (time_t) seconds;
|
rec->ts.secs = (time_t) seconds;
|
||||||
phdr->ts.nsecs = useconds * 1000; /* convert mS to nS */
|
rec->ts.nsecs = useconds * 1000; /* convert mS to nS */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* READDATA_BUF_SIZE is < WTAP_MAX_PACKET_SIZE_STANDARD, and is the maximum
|
* READDATA_BUF_SIZE is < WTAP_MAX_PACKET_SIZE_STANDARD, and is the maximum
|
||||||
|
@ -227,14 +227,14 @@ daintree_sna_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
bytes -= FCS_LENGTH;
|
bytes -= FCS_LENGTH;
|
||||||
if (bytes > phdr->len) {
|
if (bytes > rec->rec_header.packet_header.len) {
|
||||||
*err = WTAP_ERR_BAD_FILE;
|
*err = WTAP_ERR_BAD_FILE;
|
||||||
*err_info = g_strdup_printf("daintree_sna: capture length (%u) > packet length (%u)",
|
*err_info = g_strdup_printf("daintree_sna: capture length (%u) > packet length (%u)",
|
||||||
bytes, phdr->len);
|
bytes, rec->rec_header.packet_header.len);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr->caplen = bytes;
|
rec->rec_header.packet_header.caplen = bytes;
|
||||||
|
|
||||||
ws_buffer_assure_space(buf, bytes);
|
ws_buffer_assure_space(buf, bytes);
|
||||||
memcpy(ws_buffer_start_ptr(buf), readData, bytes);
|
memcpy(ws_buffer_start_ptr(buf), readData, bytes);
|
||||||
|
|
|
@ -73,8 +73,8 @@ static const char dbs_etherwatch_rec_magic[] =
|
||||||
static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
static gboolean parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh,
|
static gboolean parse_dbs_etherwatch_packet(wtap_rec *rec, FILE_T fh,
|
||||||
Buffer* buf, int *err, gchar **err_info);
|
Buffer* buf, int *err, gchar **err_info);
|
||||||
static guint parse_single_hex_dump_line(char* rec, guint8 *buf,
|
static guint parse_single_hex_dump_line(char* rec, guint8 *buf,
|
||||||
int byte_offset);
|
int byte_offset);
|
||||||
|
@ -194,19 +194,19 @@ static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
|
||||||
*data_offset = offset;
|
*data_offset = offset;
|
||||||
|
|
||||||
/* Parse the packet */
|
/* Parse the packet */
|
||||||
return parse_dbs_etherwatch_packet(&wth->phdr, wth->fh,
|
return parse_dbs_etherwatch_packet(&wth->rec, wth->fh,
|
||||||
wth->frame_buffer, err, err_info);
|
wth->rec_data, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Used to read packets in random-access fashion */
|
/* Used to read packets in random-access fashion */
|
||||||
static gboolean
|
static gboolean
|
||||||
dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
|
dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return parse_dbs_etherwatch_packet(phdr, wth->random_fh, buf, err,
|
return parse_dbs_etherwatch_packet(rec, wth->random_fh, buf, err,
|
||||||
err_info);
|
err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ unnumbered. Unnumbered has length 1, numbered 2.
|
||||||
#define CTL_UNNUMB_MASK 0x03
|
#define CTL_UNNUMB_MASK 0x03
|
||||||
#define CTL_UNNUMB_VALUE 0x03
|
#define CTL_UNNUMB_VALUE 0x03
|
||||||
static gboolean
|
static gboolean
|
||||||
parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
|
parse_dbs_etherwatch_packet(wtap_rec *rec, FILE_T fh, Buffer* buf,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
guint8 *pd;
|
guint8 *pd;
|
||||||
|
@ -423,8 +423,8 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
|
||||||
pd[length_pos+1] = (length) & 0xFF;
|
pd[length_pos+1] = (length) & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
||||||
|
|
||||||
p = strstr(months, mon);
|
p = strstr(months, mon);
|
||||||
if (p)
|
if (p)
|
||||||
|
@ -432,12 +432,12 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
|
||||||
tm.tm_year -= 1900;
|
tm.tm_year -= 1900;
|
||||||
|
|
||||||
tm.tm_isdst = -1;
|
tm.tm_isdst = -1;
|
||||||
phdr->ts.secs = mktime(&tm);
|
rec->ts.secs = mktime(&tm);
|
||||||
phdr->ts.nsecs = csec * 10000000;
|
rec->ts.nsecs = csec * 10000000;
|
||||||
phdr->caplen = eth_hdr_len + pkt_len;
|
rec->rec_header.packet_header.caplen = eth_hdr_len + pkt_len;
|
||||||
phdr->len = eth_hdr_len + pkt_len;
|
rec->rec_header.packet_header.len = eth_hdr_len + pkt_len;
|
||||||
|
|
||||||
if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
||||||
/*
|
/*
|
||||||
* Probably a corrupt capture file; return an error,
|
* Probably a corrupt capture file; return an error,
|
||||||
* so that our caller doesn't blow up trying to allocate
|
* so that our caller doesn't blow up trying to allocate
|
||||||
|
@ -445,18 +445,18 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
|
||||||
*/
|
*/
|
||||||
*err = WTAP_ERR_BAD_FILE;
|
*err = WTAP_ERR_BAD_FILE;
|
||||||
*err_info = g_strdup_printf("dbs_etherwatch: File has %u-byte packet, bigger than maximum of %u",
|
*err_info = g_strdup_printf("dbs_etherwatch: File has %u-byte packet, bigger than maximum of %u",
|
||||||
phdr->caplen, WTAP_MAX_PACKET_SIZE_STANDARD);
|
rec->rec_header.packet_header.caplen, WTAP_MAX_PACKET_SIZE_STANDARD);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure we have enough room, even for an oversized Ethernet packet */
|
/* Make sure we have enough room, even for an oversized Ethernet packet */
|
||||||
ws_buffer_assure_space(buf, phdr->caplen);
|
ws_buffer_assure_space(buf, rec->rec_header.packet_header.caplen);
|
||||||
pd = ws_buffer_start_ptr(buf);
|
pd = ws_buffer_start_ptr(buf);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We don't have an FCS in this frame.
|
* We don't have an FCS in this frame.
|
||||||
*/
|
*/
|
||||||
phdr->pseudo_header.eth.fcs_len = 0;
|
rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0;
|
||||||
|
|
||||||
/* Parse the hex dump */
|
/* Parse the hex dump */
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
|
@ -62,7 +62,7 @@ static const char dct3trace_magic_end[] = "</dump>";
|
||||||
static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Following 3 functions taken from gsmdecode-0.7bis, with permission - http://wiki.thc.org/gsm
|
* Following 3 functions taken from gsmdecode-0.7bis, with permission - http://wiki.thc.org/gsm
|
||||||
|
@ -211,7 +211,7 @@ wtap_open_return_val dct3trace_open(wtap *wth, int *err, gchar **err_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
|
static gboolean dct3trace_get_packet(FILE_T fh, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
char line[1024];
|
char line[1024];
|
||||||
|
@ -234,18 +234,18 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
if( have_data )
|
if( have_data )
|
||||||
{
|
{
|
||||||
/* We've got a full packet! */
|
/* We've got a full packet! */
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = 0; /* no time stamp, no separate "on the wire" length */
|
rec->presence_flags = 0; /* no time stamp, no separate "on the wire" length */
|
||||||
phdr->ts.secs = 0;
|
rec->ts.secs = 0;
|
||||||
phdr->ts.nsecs = 0;
|
rec->ts.nsecs = 0;
|
||||||
phdr->caplen = len;
|
rec->rec_header.packet_header.caplen = len;
|
||||||
phdr->len = len;
|
rec->rec_header.packet_header.len = len;
|
||||||
|
|
||||||
*err = 0;
|
*err = 0;
|
||||||
|
|
||||||
/* Make sure we have enough room for the packet */
|
/* Make sure we have enough room for the packet */
|
||||||
ws_buffer_assure_space(buf, phdr->caplen);
|
ws_buffer_assure_space(buf, rec->rec_header.packet_header.caplen);
|
||||||
memcpy( ws_buffer_start_ptr(buf), databuf, phdr->caplen );
|
memcpy( ws_buffer_start_ptr(buf), databuf, rec->rec_header.packet_header.caplen );
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -263,38 +263,38 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
int channel, tmp;
|
int channel, tmp;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
phdr->pseudo_header.gsm_um.uplink = !strstr(line, "direction=\"down\"");
|
rec->rec_header.packet_header.pseudo_header.gsm_um.uplink = !strstr(line, "direction=\"down\"");
|
||||||
if (!xml_get_int(&channel, line, "logicalchannel", err, err_info))
|
if (!xml_get_int(&channel, line, "logicalchannel", err, err_info))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Parse downlink only fields */
|
/* Parse downlink only fields */
|
||||||
if( !phdr->pseudo_header.gsm_um.uplink )
|
if( !rec->rec_header.packet_header.pseudo_header.gsm_um.uplink )
|
||||||
{
|
{
|
||||||
if (!xml_get_int(&tmp, line, "physicalchannel", err, err_info))
|
if (!xml_get_int(&tmp, line, "physicalchannel", err, err_info))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
phdr->pseudo_header.gsm_um.arfcn = tmp;
|
rec->rec_header.packet_header.pseudo_header.gsm_um.arfcn = tmp;
|
||||||
if (!xml_get_int(&tmp, line, "sequence", err, err_info))
|
if (!xml_get_int(&tmp, line, "sequence", err, err_info))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
phdr->pseudo_header.gsm_um.tdma_frame = tmp;
|
rec->rec_header.packet_header.pseudo_header.gsm_um.tdma_frame = tmp;
|
||||||
if (!xml_get_int(&tmp, line, "bsic", err, err_info))
|
if (!xml_get_int(&tmp, line, "bsic", err, err_info))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
phdr->pseudo_header.gsm_um.bsic = tmp;
|
rec->rec_header.packet_header.pseudo_header.gsm_um.bsic = tmp;
|
||||||
if (!xml_get_int(&tmp, line, "error", err, err_info))
|
if (!xml_get_int(&tmp, line, "error", err, err_info))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
phdr->pseudo_header.gsm_um.error = tmp;
|
rec->rec_header.packet_header.pseudo_header.gsm_um.error = tmp;
|
||||||
if (!xml_get_int(&tmp, line, "timeshift", err, err_info))
|
if (!xml_get_int(&tmp, line, "timeshift", err, err_info))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
phdr->pseudo_header.gsm_um.timeshift = tmp;
|
rec->rec_header.packet_header.pseudo_header.gsm_um.timeshift = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( channel )
|
switch( channel )
|
||||||
{
|
{
|
||||||
case 128: phdr->pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_SDCCH; break;
|
case 128: rec->rec_header.packet_header.pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_SDCCH; break;
|
||||||
case 112: phdr->pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_SACCH; break;
|
case 112: rec->rec_header.packet_header.pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_SACCH; break;
|
||||||
case 176: phdr->pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_FACCH; break;
|
case 176: rec->rec_header.packet_header.pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_FACCH; break;
|
||||||
case 96: phdr->pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_CCCH; break;
|
case 96: rec->rec_header.packet_header.pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_CCCH; break;
|
||||||
case 80: phdr->pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_BCCH; break;
|
case 80: rec->rec_header.packet_header.pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_BCCH; break;
|
||||||
default: phdr->pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_UNKNOWN; break;
|
default: rec->rec_header.packet_header.pseudo_header.gsm_um.channel = GSM_UM_CHANNEL_UNKNOWN; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read data (if have it) into databuf */
|
/* Read data (if have it) into databuf */
|
||||||
|
@ -306,7 +306,7 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
if (len == -1)
|
if (len == -1)
|
||||||
{
|
{
|
||||||
*err = WTAP_ERR_BAD_FILE;
|
*err = WTAP_ERR_BAD_FILE;
|
||||||
*err_info = g_strdup_printf("dct3trace: record length %d too long", phdr->caplen);
|
*err_info = g_strdup_printf("dct3trace: record length %d too long", rec->rec_header.packet_header.caplen);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
* We know we have no data already, so we know
|
* We know we have no data already, so we know
|
||||||
* we have enough room for the header.
|
* we have enough room for the header.
|
||||||
*/
|
*/
|
||||||
if( phdr->pseudo_header.gsm_um.channel == GSM_UM_CHANNEL_SACCH || phdr->pseudo_header.gsm_um.channel == GSM_UM_CHANNEL_FACCH || phdr->pseudo_header.gsm_um.channel == GSM_UM_CHANNEL_SDCCH )
|
if( rec->rec_header.packet_header.pseudo_header.gsm_um.channel == GSM_UM_CHANNEL_SACCH || rec->rec_header.packet_header.pseudo_header.gsm_um.channel == GSM_UM_CHANNEL_FACCH || rec->rec_header.packet_header.pseudo_header.gsm_um.channel == GSM_UM_CHANNEL_SDCCH )
|
||||||
{
|
{
|
||||||
/* Add LAPDm B header */
|
/* Add LAPDm B header */
|
||||||
memset(bufp, 0x1, 2);
|
memset(bufp, 0x1, 2);
|
||||||
|
@ -346,7 +346,7 @@ static gboolean dct3trace_get_packet(FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
if (data_len == -1)
|
if (data_len == -1)
|
||||||
{
|
{
|
||||||
*err = WTAP_ERR_BAD_FILE;
|
*err = WTAP_ERR_BAD_FILE;
|
||||||
*err_info = g_strdup_printf("dct3trace: record length %d too long", phdr->caplen);
|
*err_info = g_strdup_printf("dct3trace: record length %d too long", rec->rec_header.packet_header.caplen);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
len += data_len;
|
len += data_len;
|
||||||
|
@ -371,21 +371,21 @@ static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
|
||||||
{
|
{
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
|
|
||||||
return dct3trace_get_packet(wth->fh, &wth->phdr, wth->frame_buffer,
|
return dct3trace_get_packet(wth->fh, &wth->rec, wth->rec_data,
|
||||||
err, err_info);
|
err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Used to read packets in random-access fashion */
|
/* Used to read packets in random-access fashion */
|
||||||
static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dct3trace_get_packet(wth->random_fh, phdr, buf, err, err_info);
|
return dct3trace_get_packet(wth->random_fh, rec, buf, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
116
wiretap/erf.c
116
wiretap/erf.c
|
@ -70,7 +70,7 @@ static const guint erf_eth_hdr_size = (guint)sizeof(erf_eth_header_t);
|
||||||
|
|
||||||
|
|
||||||
static gboolean erf_read_header(wtap *wth, FILE_T fh,
|
static gboolean erf_read_header(wtap *wth, FILE_T fh,
|
||||||
struct wtap_pkthdr *phdr,
|
wtap_rec *rec,
|
||||||
erf_header_t *erf_header,
|
erf_header_t *erf_header,
|
||||||
int *err,
|
int *err,
|
||||||
gchar **err_info,
|
gchar **err_info,
|
||||||
|
@ -80,12 +80,12 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh,
|
||||||
static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean erf_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean erf_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info);
|
int *err, gchar **err_info);
|
||||||
static void erf_close(wtap *wth);
|
static void erf_close(wtap *wth);
|
||||||
|
|
||||||
static int populate_summary_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo_header *pseudo_header, guint32 packet_size, GPtrArray *anchor_mappings_to_update);
|
static int populate_summary_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo_header *pseudo_header, guint32 packet_size, GPtrArray *anchor_mappings_to_update);
|
||||||
static int erf_update_anchors_from_header(erf_t *erf_priv, struct wtap_pkthdr *phdr, union wtap_pseudo_header *pseudo_header, guint64 host_id, GPtrArray *anchor_mappings_to_update);
|
static int erf_update_anchors_from_header(erf_t *erf_priv, wtap_rec *rec, union wtap_pseudo_header *pseudo_header, guint64 host_id, GPtrArray *anchor_mappings_to_update);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gboolean write_next_extra_meta;
|
gboolean write_next_extra_meta;
|
||||||
|
@ -590,14 +590,14 @@ static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!erf_read_header(wth, wth->fh,
|
if (!erf_read_header(wth, wth->fh,
|
||||||
&wth->phdr, &erf_header,
|
&wth->rec, &erf_header,
|
||||||
err, err_info, &bytes_read, &packet_size,
|
err, err_info, &bytes_read, &packet_size,
|
||||||
anchor_mappings_to_update)) {
|
anchor_mappings_to_update)) {
|
||||||
g_ptr_array_free(anchor_mappings_to_update, TRUE);
|
g_ptr_array_free(anchor_mappings_to_update, TRUE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer, packet_size,
|
if (!wtap_read_packet_bytes(wth->fh, wth->rec_data, packet_size,
|
||||||
err, err_info)) {
|
err, err_info)) {
|
||||||
g_ptr_array_free(anchor_mappings_to_update, TRUE);
|
g_ptr_array_free(anchor_mappings_to_update, TRUE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -610,7 +610,7 @@ static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
|
||||||
*/
|
*/
|
||||||
if ((erf_header.type & 0x7F) == ERF_TYPE_META && packet_size > 0)
|
if ((erf_header.type & 0x7F) == ERF_TYPE_META && packet_size > 0)
|
||||||
{
|
{
|
||||||
populate_summary_info((erf_t*) wth->priv, wth, &wth->phdr.pseudo_header, packet_size, anchor_mappings_to_update);
|
populate_summary_info((erf_t*) wth->priv, wth, &wth->rec.rec_header.packet_header.pseudo_header, packet_size, anchor_mappings_to_update);
|
||||||
}
|
}
|
||||||
|
|
||||||
} while ( erf_header.type == ERF_TYPE_PAD );
|
} while ( erf_header.type == ERF_TYPE_PAD );
|
||||||
|
@ -621,7 +621,7 @@ static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean erf_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean erf_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
erf_header_t erf_header;
|
erf_header_t erf_header;
|
||||||
|
@ -634,7 +634,7 @@ static gboolean erf_seek_read(wtap *wth, gint64 seek_off,
|
||||||
anchor_mappings_to_update = g_ptr_array_new_with_free_func(erf_anchor_mapping_destroy);
|
anchor_mappings_to_update = g_ptr_array_new_with_free_func(erf_anchor_mapping_destroy);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!erf_read_header(wth, wth->random_fh, phdr, &erf_header,
|
if (!erf_read_header(wth, wth->random_fh, rec, &erf_header,
|
||||||
err, err_info, NULL, &packet_size, anchor_mappings_to_update)) {
|
err, err_info, NULL, &packet_size, anchor_mappings_to_update)) {
|
||||||
g_ptr_array_free(anchor_mappings_to_update, TRUE);
|
g_ptr_array_free(anchor_mappings_to_update, TRUE);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -667,7 +667,7 @@ static struct erf_anchor_mapping* erf_find_anchor_mapping(erf_t *priv,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean erf_read_header(wtap *wth, FILE_T fh,
|
static gboolean erf_read_header(wtap *wth, FILE_T fh,
|
||||||
struct wtap_pkthdr *phdr,
|
wtap_rec *rec,
|
||||||
erf_header_t *erf_header,
|
erf_header_t *erf_header,
|
||||||
int *err,
|
int *err,
|
||||||
gchar **err_info,
|
gchar **err_info,
|
||||||
|
@ -675,7 +675,7 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh,
|
||||||
guint32 *packet_size,
|
guint32 *packet_size,
|
||||||
GPtrArray *anchor_mappings_to_update)
|
GPtrArray *anchor_mappings_to_update)
|
||||||
{
|
{
|
||||||
union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
|
union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header;
|
||||||
guint8 erf_exhdr[8];
|
guint8 erf_exhdr[8];
|
||||||
guint64 erf_exhdr_sw;
|
guint64 erf_exhdr_sw;
|
||||||
guint8 type = 0;
|
guint8 type = 0;
|
||||||
|
@ -726,7 +726,7 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh,
|
||||||
guint64 ts = pletoh64(&erf_header->ts);
|
guint64 ts = pletoh64(&erf_header->ts);
|
||||||
|
|
||||||
/*if ((erf_header->type & 0x7f) != ERF_TYPE_META || wth->file_type_subtype != WTAP_FILE_TYPE_SUBTYPE_ERF) {*/
|
/*if ((erf_header->type & 0x7f) != ERF_TYPE_META || wth->file_type_subtype != WTAP_FILE_TYPE_SUBTYPE_ERF) {*/
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
/*
|
/*
|
||||||
* XXX: ERF_TYPE_META records should ideally be FT_SPECIFIC for display
|
* XXX: ERF_TYPE_META records should ideally be FT_SPECIFIC for display
|
||||||
* purposes, but currently ft_specific_record_phdr clashes with erf_mc_phdr
|
* purposes, but currently ft_specific_record_phdr clashes with erf_mc_phdr
|
||||||
|
@ -743,18 +743,18 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh,
|
||||||
* chosen by wth->file_type_subtype?
|
* chosen by wth->file_type_subtype?
|
||||||
*/
|
*/
|
||||||
/* For now just treat all Provenance records as reports */
|
/* For now just treat all Provenance records as reports */
|
||||||
phdr->rec_type = REC_TYPE_FT_SPECIFIC_REPORT;
|
rec->rec_type = REC_TYPE_FT_SPECIFIC_REPORT;
|
||||||
/* XXX: phdr ft_specific_record_phdr? */
|
/* XXX: phdr ft_specific_record_phdr? */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID;
|
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN|WTAP_HAS_INTERFACE_ID;
|
||||||
phdr->ts.secs = (long) (ts >> 32);
|
rec->ts.secs = (long) (ts >> 32);
|
||||||
ts = ((ts & 0xffffffff) * 1000 * 1000 * 1000);
|
ts = ((ts & 0xffffffff) * 1000 * 1000 * 1000);
|
||||||
ts += (ts & 0x80000000) << 1; /* rounding */
|
ts += (ts & 0x80000000) << 1; /* rounding */
|
||||||
phdr->ts.nsecs = ((int) (ts >> 32));
|
rec->ts.nsecs = ((int) (ts >> 32));
|
||||||
if (phdr->ts.nsecs >= 1000000000) {
|
if (rec->ts.nsecs >= 1000000000) {
|
||||||
phdr->ts.nsecs -= 1000000000;
|
rec->ts.nsecs -= 1000000000;
|
||||||
phdr->ts.secs += 1;
|
rec->ts.secs += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if_num = erf_header->flags & 0x03;
|
if_num = erf_header->flags & 0x03;
|
||||||
|
@ -808,10 +808,10 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: erf_priv pointer needs to change if used as common function for other dissectors! */
|
/* XXX: erf_priv pointer needs to change if used as common function for other dissectors! */
|
||||||
phdr->interface_id = (guint) erf_populate_interface((erf_t*) wth->priv, wth, pseudo_header, host_id, source_id, if_num);
|
rec->rec_header.packet_header.interface_id = (guint) erf_populate_interface((erf_t*) wth->priv, wth, pseudo_header, host_id, source_id, if_num);
|
||||||
|
|
||||||
/* Try to find comment links using Anchor ID. Done here after we found the first Host ID and have updated the implicit Host ID. */
|
/* Try to find comment links using Anchor ID. Done here after we found the first Host ID and have updated the implicit Host ID. */
|
||||||
erf_update_anchors_from_header(priv, phdr, pseudo_header, host_id, anchor_mappings_to_update);
|
erf_update_anchors_from_header(priv, rec, pseudo_header, host_id, anchor_mappings_to_update);
|
||||||
|
|
||||||
switch (erf_header->type & 0x7F) {
|
switch (erf_header->type & 0x7F) {
|
||||||
case ERF_TYPE_IPV4:
|
case ERF_TYPE_IPV4:
|
||||||
|
@ -824,8 +824,8 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh,
|
||||||
case ERF_TYPE_OPA_9B:
|
case ERF_TYPE_OPA_9B:
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
phdr->len = g_htons(erf_header->wlen);
|
rec->rec_header.packet_header.len = g_htons(erf_header->wlen);
|
||||||
phdr->caplen = g_htons(erf_header->wlen);
|
rec->rec_header.packet_header.caplen = g_htons(erf_header->wlen);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -887,8 +887,8 @@ static gboolean erf_read_header(wtap *wth, FILE_T fh,
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
phdr->len = g_ntohs(erf_header->wlen);
|
rec->rec_header.packet_header.len = g_ntohs(erf_header->wlen);
|
||||||
phdr->caplen = MIN( g_ntohs(erf_header->wlen),
|
rec->rec_header.packet_header.caplen = MIN( g_ntohs(erf_header->wlen),
|
||||||
g_ntohs(erf_header->rlen) - (guint32)sizeof(*erf_header) - skiplen );
|
g_ntohs(erf_header->rlen) - (guint32)sizeof(*erf_header) - skiplen );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1467,7 +1467,7 @@ static gboolean erf_update_host_id_ext_hdrs_list(erf_dump_t *dump_priv, const un
|
||||||
* @param err the error value
|
* @param err the error value
|
||||||
* @return A gboolean value to indicate whether the dump was successful
|
* @return A gboolean value to indicate whether the dump was successful
|
||||||
*/
|
*/
|
||||||
static gboolean erf_write_anchor_meta_update_phdr(wtap_dumper *wdh, erf_dump_t *dump_priv, const struct wtap_pkthdr *phdr, union wtap_pseudo_header *mutable_hdr, int *err) {
|
static gboolean erf_write_anchor_meta_update_phdr(wtap_dumper *wdh, erf_dump_t *dump_priv, const wtap_rec *rec, union wtap_pseudo_header *mutable_hdr, int *err) {
|
||||||
GArray *meta_ehdrs;
|
GArray *meta_ehdrs;
|
||||||
GPtrArray* sections = NULL;
|
GPtrArray* sections = NULL;
|
||||||
guint8 has_more;
|
guint8 has_more;
|
||||||
|
@ -1651,7 +1651,7 @@ static gboolean erf_write_anchor_meta_update_phdr(wtap_dumper *wdh, erf_dump_t *
|
||||||
|
|
||||||
/* Generate the metadata payload with the packet comment */
|
/* Generate the metadata payload with the packet comment */
|
||||||
sections = g_ptr_array_new_with_free_func(erf_meta_section_free);
|
sections = g_ptr_array_new_with_free_func(erf_meta_section_free);
|
||||||
erf_comment_to_sections(wdh, ERF_META_SECTION_INFO, 0x8000 /*local to record*/, phdr->opt_comment, sections);
|
erf_comment_to_sections(wdh, ERF_META_SECTION_INFO, 0x8000 /*local to record*/, rec->opt_comment, sections);
|
||||||
|
|
||||||
/* Write the metadata record, but not the packet record as what we do depends
|
/* Write the metadata record, but not the packet record as what we do depends
|
||||||
* on the WTAP_ENCAP */
|
* on the WTAP_ENCAP */
|
||||||
|
@ -1770,12 +1770,12 @@ erf_dump_t *erf_dump_priv_create(void) {
|
||||||
|
|
||||||
static gboolean erf_dump(
|
static gboolean erf_dump(
|
||||||
wtap_dumper *wdh,
|
wtap_dumper *wdh,
|
||||||
const struct wtap_pkthdr *phdr,
|
const wtap_rec *rec,
|
||||||
const guint8 *pd,
|
const guint8 *pd,
|
||||||
int *err,
|
int *err,
|
||||||
gchar **err_info _U_)
|
gchar **err_info _U_)
|
||||||
{
|
{
|
||||||
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
|
const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header;
|
||||||
union wtap_pseudo_header other_phdr;
|
union wtap_pseudo_header other_phdr;
|
||||||
int encap;
|
int encap;
|
||||||
int erf_type;
|
int erf_type;
|
||||||
|
@ -1790,20 +1790,20 @@ static gboolean erf_dump(
|
||||||
guint64 non_erf_host_id_ehdr = erf_host_id_ext_hdr(0, 1);
|
guint64 non_erf_host_id_ehdr = erf_host_id_ext_hdr(0, 1);
|
||||||
|
|
||||||
/* Don't write anything bigger than we're willing to read. */
|
/* Don't write anything bigger than we're willing to read. */
|
||||||
if(phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
if(rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
||||||
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(wdh->encap == WTAP_ENCAP_PER_PACKET){
|
if(wdh->encap == WTAP_ENCAP_PER_PACKET){
|
||||||
encap = phdr->pkt_encap;
|
encap = rec->rec_header.packet_header.pkt_encap;
|
||||||
}else{
|
}else{
|
||||||
encap = wdh->encap;
|
encap = wdh->encap;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!dump_priv->gen_time) {
|
if(!dump_priv->gen_time) {
|
||||||
erf_dump_priv_init_gen_time(dump_priv);
|
erf_dump_priv_init_gen_time(dump_priv);
|
||||||
dump_priv->first_frame_time_sec = phdr->ts.secs;
|
dump_priv->first_frame_time_sec = rec->ts.secs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encap != WTAP_ENCAP_ERF) {
|
if (encap != WTAP_ENCAP_ERF) {
|
||||||
|
@ -1812,11 +1812,11 @@ static gboolean erf_dump(
|
||||||
|
|
||||||
/*Non-ERF*/
|
/*Non-ERF*/
|
||||||
|
|
||||||
total_rlen = phdr->caplen+16;
|
total_rlen = rec->rec_header.packet_header.caplen+16;
|
||||||
total_wlen = phdr->len;
|
total_wlen = rec->rec_header.packet_header.len;
|
||||||
|
|
||||||
/* We can only convert packet records. */
|
/* We can only convert packet records. */
|
||||||
if (phdr->rec_type != REC_TYPE_PACKET) {
|
if (rec->rec_type != REC_TYPE_PACKET) {
|
||||||
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1829,11 +1829,11 @@ static gboolean erf_dump(
|
||||||
/* Generate a fake header in other_phdr using data that we know*/
|
/* Generate a fake header in other_phdr using data that we know*/
|
||||||
memset(&other_phdr, 0, sizeof(union wtap_pseudo_header));
|
memset(&other_phdr, 0, sizeof(union wtap_pseudo_header));
|
||||||
/* Convert time erf timestamp format*/
|
/* Convert time erf timestamp format*/
|
||||||
other_phdr.erf.phdr.ts = ((guint64) phdr->ts.secs << 32) + (((guint64) phdr->ts.nsecs <<32) / 1000 / 1000 / 1000);
|
other_phdr.erf.phdr.ts = ((guint64) rec->ts.secs << 32) + (((guint64) rec->ts.nsecs <<32) / 1000 / 1000 / 1000);
|
||||||
other_phdr.erf.phdr.type = (guint8)erf_type;
|
other_phdr.erf.phdr.type = (guint8)erf_type;
|
||||||
/* Support up to 4 interfaces */
|
/* Support up to 4 interfaces */
|
||||||
/* TODO: use multiple Source IDs and metadata records to support >4 interfaces */
|
/* TODO: use multiple Source IDs and metadata records to support >4 interfaces */
|
||||||
other_phdr.erf.phdr.flags = phdr->interface_id % ERF_MAX_INTERFACES;
|
other_phdr.erf.phdr.flags = rec->rec_header.packet_header.interface_id % ERF_MAX_INTERFACES;
|
||||||
other_phdr.erf.phdr.flags |= 0x4; /*vlen flag set because we're creating variable length records*/
|
other_phdr.erf.phdr.flags |= 0x4; /*vlen flag set because we're creating variable length records*/
|
||||||
|
|
||||||
other_phdr.erf.phdr.lctr = 0;
|
other_phdr.erf.phdr.lctr = 0;
|
||||||
|
@ -1847,8 +1847,8 @@ static gboolean erf_dump(
|
||||||
(pseudo_header->eth.fcs_len = 0), or we don't
|
(pseudo_header->eth.fcs_len = 0), or we don't
|
||||||
know whether it has an FCS (= -1). We have to
|
know whether it has an FCS (= -1). We have to
|
||||||
synthesize an FCS.*/
|
synthesize an FCS.*/
|
||||||
if(!(phdr->caplen < phdr->len)){ /*don't add FCS if packet has been snapped off*/
|
if(!(rec->rec_header.packet_header.caplen < rec->rec_header.packet_header.len)){ /*don't add FCS if packet has been snapped off*/
|
||||||
crc32 = crc32_ccitt_seed(pd, phdr->caplen, 0xFFFFFFFF);
|
crc32 = crc32_ccitt_seed(pd, rec->rec_header.packet_header.caplen, 0xFFFFFFFF);
|
||||||
total_rlen += 4; /*4 bytes for added checksum*/
|
total_rlen += 4; /*4 bytes for added checksum*/
|
||||||
total_wlen += 4;
|
total_wlen += 4;
|
||||||
must_add_crc = TRUE;
|
must_add_crc = TRUE;
|
||||||
|
@ -1857,8 +1857,8 @@ static gboolean erf_dump(
|
||||||
break;
|
break;
|
||||||
case ERF_TYPE_HDLC_POS:
|
case ERF_TYPE_HDLC_POS:
|
||||||
/*we assume that it's missing a FCS checksum, make one up*/
|
/*we assume that it's missing a FCS checksum, make one up*/
|
||||||
if(!(phdr->caplen < phdr->len)){ /*unless of course, the packet has been snapped off*/
|
if(!(rec->rec_header.packet_header.caplen < rec->rec_header.packet_header.len)){ /*unless of course, the packet has been snapped off*/
|
||||||
crc32 = crc32_ccitt_seed(pd, phdr->caplen, 0xFFFFFFFF);
|
crc32 = crc32_ccitt_seed(pd, rec->rec_header.packet_header.caplen, 0xFFFFFFFF);
|
||||||
total_rlen += 4; /*4 bytes for added checksum*/
|
total_rlen += 4; /*4 bytes for added checksum*/
|
||||||
total_wlen += 4;
|
total_wlen += 4;
|
||||||
must_add_crc = TRUE; /* XXX - these never have an FCS? */
|
must_add_crc = TRUE; /* XXX - these never have an FCS? */
|
||||||
|
@ -1874,7 +1874,7 @@ static gboolean erf_dump(
|
||||||
total_rlen += 8;
|
total_rlen += 8;
|
||||||
|
|
||||||
padbytes = ERF_PADDING_TO_8(total_rlen); /*calculate how much padding will be required */
|
padbytes = ERF_PADDING_TO_8(total_rlen); /*calculate how much padding will be required */
|
||||||
if(phdr->caplen < phdr->len){ /*if packet has been snapped, we need to round down what we output*/
|
if(rec->rec_header.packet_header.caplen < rec->rec_header.packet_header.len){ /*if packet has been snapped, we need to round down what we output*/
|
||||||
round_down = (8 - padbytes) % 8;
|
round_down = (8 - padbytes) % 8;
|
||||||
total_rlen -= round_down;
|
total_rlen -= round_down;
|
||||||
}else{
|
}else{
|
||||||
|
@ -1921,7 +1921,7 @@ static gboolean erf_dump(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!erf_write_meta_record(wdh, dump_priv, dump_priv->prev_frame_ts, dump_priv->periodic_sections, dump_priv->periodic_extra_ehdrs, err)) return FALSE;
|
if (!erf_write_meta_record(wdh, dump_priv, dump_priv->prev_frame_ts, dump_priv->periodic_sections, dump_priv->periodic_extra_ehdrs, err)) return FALSE;
|
||||||
dump_priv->prev_inserted_time_sec = phdr->ts.secs;
|
dump_priv->prev_inserted_time_sec = rec->ts.secs;
|
||||||
/*TODO: clear accumulated existing extension headers here?*/
|
/*TODO: clear accumulated existing extension headers here?*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1932,8 +1932,8 @@ static gboolean erf_dump(
|
||||||
* read. */
|
* read. */
|
||||||
/* restart searching for next meta record to update capture comment at */
|
/* restart searching for next meta record to update capture comment at */
|
||||||
dump_priv->write_next_extra_meta = FALSE;
|
dump_priv->write_next_extra_meta = FALSE;
|
||||||
} else if (phdr->ts.secs > dump_priv->first_frame_time_sec + 1
|
} else if (rec->ts.secs > dump_priv->first_frame_time_sec + 1
|
||||||
&& dump_priv->prev_inserted_time_sec != phdr->ts.secs) {
|
&& dump_priv->prev_inserted_time_sec != rec->ts.secs) {
|
||||||
/* For compatibility, don't insert metadata for older ERF files with no changed metadata */
|
/* For compatibility, don't insert metadata for older ERF files with no changed metadata */
|
||||||
if (dump_priv->write_next_extra_meta) {
|
if (dump_priv->write_next_extra_meta) {
|
||||||
if (!dump_priv->periodic_sections) {
|
if (!dump_priv->periodic_sections) {
|
||||||
|
@ -1949,8 +1949,8 @@ static gboolean erf_dump(
|
||||||
/* At second boundaries insert either the updated comment (if we've seen some metadata records
|
/* At second boundaries insert either the updated comment (if we've seen some metadata records
|
||||||
* already) or the full metadata */
|
* already) or the full metadata */
|
||||||
if (dump_priv->periodic_sections) {
|
if (dump_priv->periodic_sections) {
|
||||||
if (!erf_write_meta_record(wdh, dump_priv, (guint64)(phdr->ts.secs) << 32, dump_priv->periodic_sections, dump_priv->periodic_extra_ehdrs, err)) return FALSE;
|
if (!erf_write_meta_record(wdh, dump_priv, (guint64)(rec->ts.secs) << 32, dump_priv->periodic_sections, dump_priv->periodic_extra_ehdrs, err)) return FALSE;
|
||||||
dump_priv->prev_inserted_time_sec = phdr->ts.secs;
|
dump_priv->prev_inserted_time_sec = rec->ts.secs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1959,18 +1959,18 @@ static gboolean erf_dump(
|
||||||
* construct a new header with additional Host ID and Anchor ID
|
* construct a new header with additional Host ID and Anchor ID
|
||||||
* and insert a metadata record before that frame */
|
* and insert a metadata record before that frame */
|
||||||
/*XXX: The user may have changed the comment to cleared! */
|
/*XXX: The user may have changed the comment to cleared! */
|
||||||
if(phdr->opt_comment || phdr->has_comment_changed) {
|
if(rec->opt_comment || rec->has_comment_changed) {
|
||||||
if (encap == WTAP_ENCAP_ERF) {
|
if (encap == WTAP_ENCAP_ERF) {
|
||||||
/* XXX: What about ERF-in-pcapng with existing comment (that wasn't
|
/* XXX: What about ERF-in-pcapng with existing comment (that wasn't
|
||||||
* modified)? */
|
* modified)? */
|
||||||
if(phdr->has_comment_changed) {
|
if(rec->has_comment_changed) {
|
||||||
memcpy(&other_phdr, pseudo_header, sizeof(union wtap_pseudo_header));
|
memcpy(&other_phdr, pseudo_header, sizeof(union wtap_pseudo_header));
|
||||||
if(!erf_write_anchor_meta_update_phdr(wdh, dump_priv, phdr, &other_phdr, err)) return FALSE;
|
if(!erf_write_anchor_meta_update_phdr(wdh, dump_priv, rec, &other_phdr, err)) return FALSE;
|
||||||
pseudo_header = &other_phdr;
|
pseudo_header = &other_phdr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Always write the comment if non-ERF */
|
/* Always write the comment if non-ERF */
|
||||||
if(!erf_write_anchor_meta_update_phdr(wdh, dump_priv, phdr, &other_phdr, err)) return FALSE;
|
if(!erf_write_anchor_meta_update_phdr(wdh, dump_priv, rec, &other_phdr, err)) return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1979,8 +1979,8 @@ static gboolean erf_dump(
|
||||||
|
|
||||||
if(!erf_write_phdr(wdh, WTAP_ENCAP_ERF, pseudo_header, err)) return FALSE;
|
if(!erf_write_phdr(wdh, WTAP_ENCAP_ERF, pseudo_header, err)) return FALSE;
|
||||||
|
|
||||||
if(!wtap_dump_file_write(wdh, pd, phdr->caplen - round_down, err)) return FALSE;
|
if(!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen - round_down, err)) return FALSE;
|
||||||
wdh->bytes_dumped += phdr->caplen - round_down;
|
wdh->bytes_dumped += rec->rec_header.packet_header.caplen - round_down;
|
||||||
|
|
||||||
/*add the 4 byte CRC if necessary*/
|
/*add the 4 byte CRC if necessary*/
|
||||||
if(must_add_crc){
|
if(must_add_crc){
|
||||||
|
@ -2203,7 +2203,7 @@ static void erf_set_interface_descr(wtap_block_t block, guint option_id, guint64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int erf_update_anchors_from_header(erf_t *erf_priv, struct wtap_pkthdr *phdr, union wtap_pseudo_header *pseudo_header, guint64 host_id, GPtrArray *anchor_mappings_to_update)
|
static int erf_update_anchors_from_header(erf_t *erf_priv, wtap_rec *rec, union wtap_pseudo_header *pseudo_header, guint64 host_id, GPtrArray *anchor_mappings_to_update)
|
||||||
{
|
{
|
||||||
guint8 type;
|
guint8 type;
|
||||||
guint8 has_more;
|
guint8 has_more;
|
||||||
|
@ -2214,7 +2214,7 @@ static int erf_update_anchors_from_header(erf_t *erf_priv, struct wtap_pkthdr *p
|
||||||
int i = 0;
|
int i = 0;
|
||||||
gchar *comment = NULL;
|
gchar *comment = NULL;
|
||||||
|
|
||||||
if (!phdr || !pseudo_header)
|
if (!rec || !pseudo_header)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Start with the first Host ID that was found on the record
|
/* Start with the first Host ID that was found on the record
|
||||||
|
@ -2279,8 +2279,8 @@ static int erf_update_anchors_from_header(erf_t *erf_priv, struct wtap_pkthdr *p
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comment) {
|
if (comment) {
|
||||||
phdr->opt_comment = g_strdup(comment);
|
rec->opt_comment = g_strdup(comment);
|
||||||
phdr->presence_flags |= WTAP_HAS_COMMENTS;
|
rec->presence_flags |= WTAP_HAS_COMMENTS;
|
||||||
} else {
|
} else {
|
||||||
/* WTAP_HAS_COMMENT has no visible effect?
|
/* WTAP_HAS_COMMENT has no visible effect?
|
||||||
* Need to set opt_comment to NULL to prevent other packets
|
* Need to set opt_comment to NULL to prevent other packets
|
||||||
|
@ -2288,7 +2288,7 @@ static int erf_update_anchors_from_header(erf_t *erf_priv, struct wtap_pkthdr *p
|
||||||
*/
|
*/
|
||||||
/* XXX: We cannot free the old comment because it can be for a different
|
/* XXX: We cannot free the old comment because it can be for a different
|
||||||
* frame and still in use, wiretap should be handling this better! */
|
* frame and still in use, wiretap should be handling this better! */
|
||||||
phdr->opt_comment = NULL;
|
rec->opt_comment = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -3175,7 +3175,7 @@ static int populate_summary_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo_h
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
state.tag_ptr = wth->frame_buffer->data;
|
state.tag_ptr = wth->rec_data->data;
|
||||||
state.remaining_len = packet_size;
|
state.remaining_len = packet_size;
|
||||||
|
|
||||||
/* Read until see next section tag */
|
/* Read until see next section tag */
|
||||||
|
|
|
@ -88,8 +88,8 @@ static const unsigned char eyesdn_hdr_magic[] =
|
||||||
static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean eyesdn_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean eyesdn_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
static int read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer* buf,
|
static int read_eyesdn_rec(FILE_T fh, wtap_rec *rec, Buffer* buf,
|
||||||
int *err, gchar **err_info);
|
int *err, gchar **err_info);
|
||||||
|
|
||||||
/* Seeks to the beginning of the next packet, and returns the
|
/* Seeks to the beginning of the next packet, and returns the
|
||||||
|
@ -152,27 +152,27 @@ static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
|
||||||
*data_offset = offset;
|
*data_offset = offset;
|
||||||
|
|
||||||
/* Parse the record */
|
/* Parse the record */
|
||||||
return read_eyesdn_rec(wth->fh, &wth->phdr, wth->frame_buffer,
|
return read_eyesdn_rec(wth->fh, &wth->rec, wth->rec_data,
|
||||||
err, err_info);
|
err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Used to read packets in random-access fashion */
|
/* Used to read packets in random-access fashion */
|
||||||
static gboolean
|
static gboolean
|
||||||
eyesdn_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
eyesdn_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return read_eyesdn_rec(wth->random_fh, phdr, buf, err, err_info);
|
return read_eyesdn_rec(wth->random_fh, rec, buf, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parses a record. */
|
/* Parses a record. */
|
||||||
static gboolean
|
static gboolean
|
||||||
read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
|
read_eyesdn_rec(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err,
|
||||||
gchar **err_info)
|
gchar **err_info)
|
||||||
{
|
{
|
||||||
union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
|
union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header;
|
||||||
guint8 hdr[EYESDN_HDR_LENGTH];
|
guint8 hdr[EYESDN_HDR_LENGTH];
|
||||||
time_t secs;
|
time_t secs;
|
||||||
int usecs;
|
int usecs;
|
||||||
|
@ -210,20 +210,20 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
|
||||||
pseudo_header->isdn.uton = direction & 1;
|
pseudo_header->isdn.uton = direction & 1;
|
||||||
pseudo_header->isdn.channel = channel;
|
pseudo_header->isdn.channel = channel;
|
||||||
if(channel) { /* bearer channels */
|
if(channel) { /* bearer channels */
|
||||||
phdr->pkt_encap = WTAP_ENCAP_ISDN; /* recognises PPP */
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISDN; /* recognises PPP */
|
||||||
pseudo_header->isdn.uton=!pseudo_header->isdn.uton; /* bug */
|
pseudo_header->isdn.uton=!pseudo_header->isdn.uton; /* bug */
|
||||||
} else { /* D channel */
|
} else { /* D channel */
|
||||||
phdr->pkt_encap = WTAP_ENCAP_ISDN;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISDN;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EYESDN_ENCAP_MSG: /* Layer 1 message */
|
case EYESDN_ENCAP_MSG: /* Layer 1 message */
|
||||||
phdr->pkt_encap = WTAP_ENCAP_LAYER1_EVENT;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_LAYER1_EVENT;
|
||||||
pseudo_header->l1event.uton = (direction & 1);
|
pseudo_header->l1event.uton = (direction & 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EYESDN_ENCAP_LAPB: /* X.25 via LAPB */
|
case EYESDN_ENCAP_LAPB: /* X.25 via LAPB */
|
||||||
phdr->pkt_encap = WTAP_ENCAP_LAPB;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_LAPB;
|
||||||
pseudo_header->x25.flags = (direction & 1) ? 0 : 0x80;
|
pseudo_header->x25.flags = (direction & 1) ? 0 : 0x80;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (file_seek(fh, cur_off, SEEK_SET, err) == -1)
|
if (file_seek(fh, cur_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
phdr->pkt_encap = WTAP_ENCAP_ATM_PDUS_UNTRUNCATED;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ATM_PDUS_UNTRUNCATED;
|
||||||
pseudo_header->atm.flags=ATM_RAW_CELL;
|
pseudo_header->atm.flags=ATM_RAW_CELL;
|
||||||
pseudo_header->atm.aal=AAL_UNKNOWN;
|
pseudo_header->atm.aal=AAL_UNKNOWN;
|
||||||
pseudo_header->atm.type=TRAF_UMTS_FP;
|
pseudo_header->atm.type=TRAF_UMTS_FP;
|
||||||
|
@ -260,31 +260,31 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
|
||||||
pseudo_header->mtp2.sent = direction & 1;
|
pseudo_header->mtp2.sent = direction & 1;
|
||||||
pseudo_header->mtp2.annex_a_used = MTP2_ANNEX_A_USED_UNKNOWN;
|
pseudo_header->mtp2.annex_a_used = MTP2_ANNEX_A_USED_UNKNOWN;
|
||||||
pseudo_header->mtp2.link_number = channel;
|
pseudo_header->mtp2.link_number = channel;
|
||||||
phdr->pkt_encap = WTAP_ENCAP_MTP2_WITH_PHDR;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_MTP2_WITH_PHDR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EYESDN_ENCAP_DPNSS: /* DPNSS */
|
case EYESDN_ENCAP_DPNSS: /* DPNSS */
|
||||||
pseudo_header->isdn.uton = direction & 1;
|
pseudo_header->isdn.uton = direction & 1;
|
||||||
pseudo_header->isdn.channel = channel;
|
pseudo_header->isdn.channel = channel;
|
||||||
phdr->pkt_encap = WTAP_ENCAP_DPNSS;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_DPNSS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EYESDN_ENCAP_DASS2: /* DASS2 frames */
|
case EYESDN_ENCAP_DASS2: /* DASS2 frames */
|
||||||
pseudo_header->isdn.uton = direction & 1;
|
pseudo_header->isdn.uton = direction & 1;
|
||||||
pseudo_header->isdn.channel = channel;
|
pseudo_header->isdn.channel = channel;
|
||||||
phdr->pkt_encap = WTAP_ENCAP_DPNSS;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_DPNSS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EYESDN_ENCAP_BACNET: /* BACNET async over HDLC frames */
|
case EYESDN_ENCAP_BACNET: /* BACNET async over HDLC frames */
|
||||||
pseudo_header->isdn.uton = direction & 1;
|
pseudo_header->isdn.uton = direction & 1;
|
||||||
pseudo_header->isdn.channel = channel;
|
pseudo_header->isdn.channel = channel;
|
||||||
phdr->pkt_encap = WTAP_ENCAP_BACNET_MS_TP_WITH_PHDR;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_BACNET_MS_TP_WITH_PHDR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EYESDN_ENCAP_V5_EF: /* V5EF */
|
case EYESDN_ENCAP_V5_EF: /* V5EF */
|
||||||
pseudo_header->isdn.uton = direction & 1;
|
pseudo_header->isdn.uton = direction & 1;
|
||||||
pseudo_header->isdn.channel = channel;
|
pseudo_header->isdn.channel = channel;
|
||||||
phdr->pkt_encap = WTAP_ENCAP_V5_EF;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_V5_EF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,12 +295,12 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS;
|
rec->presence_flags = WTAP_HAS_TS;
|
||||||
phdr->ts.secs = secs;
|
rec->ts.secs = secs;
|
||||||
phdr->ts.nsecs = usecs * 1000;
|
rec->ts.nsecs = usecs * 1000;
|
||||||
phdr->caplen = pkt_len;
|
rec->rec_header.packet_header.caplen = pkt_len;
|
||||||
phdr->len = pkt_len;
|
rec->rec_header.packet_header.len = pkt_len;
|
||||||
|
|
||||||
/* Make sure we have enough room for the packet */
|
/* Make sure we have enough room for the packet */
|
||||||
ws_buffer_assure_space(buf, pkt_len);
|
ws_buffer_assure_space(buf, pkt_len);
|
||||||
|
@ -336,7 +336,7 @@ esc_write(wtap_dumper *wdh, const guint8 *buf, int len, int *err)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean eyesdn_dump(wtap_dumper *wdh,
|
static gboolean eyesdn_dump(wtap_dumper *wdh,
|
||||||
const struct wtap_pkthdr *phdr,
|
const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info);
|
const guint8 *pd, int *err, gchar **err_info);
|
||||||
|
|
||||||
gboolean eyesdn_dump_open(wtap_dumper *wdh, int *err)
|
gboolean eyesdn_dump_open(wtap_dumper *wdh, int *err)
|
||||||
|
@ -372,11 +372,11 @@ int eyesdn_dump_can_write_encap(int encap)
|
||||||
/* Write a record for a packet to a dump file.
|
/* Write a record for a packet to a dump file.
|
||||||
* Returns TRUE on success, FALSE on failure. */
|
* Returns TRUE on success, FALSE on failure. */
|
||||||
static gboolean eyesdn_dump(wtap_dumper *wdh,
|
static gboolean eyesdn_dump(wtap_dumper *wdh,
|
||||||
const struct wtap_pkthdr *phdr,
|
const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info _U_)
|
const guint8 *pd, int *err, gchar **err_info _U_)
|
||||||
{
|
{
|
||||||
static const guint8 start_flag = 0xff;
|
static const guint8 start_flag = 0xff;
|
||||||
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
|
const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header;
|
||||||
guint8 buf[EYESDN_HDR_LENGTH];
|
guint8 buf[EYESDN_HDR_LENGTH];
|
||||||
int usecs;
|
int usecs;
|
||||||
time_t secs;
|
time_t secs;
|
||||||
|
@ -386,7 +386,7 @@ static gboolean eyesdn_dump(wtap_dumper *wdh,
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
/* We can only write packet records. */
|
/* We can only write packet records. */
|
||||||
if (phdr->rec_type != REC_TYPE_PACKET) {
|
if (rec->rec_type != REC_TYPE_PACKET) {
|
||||||
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -394,18 +394,18 @@ static gboolean eyesdn_dump(wtap_dumper *wdh,
|
||||||
/* Don't write out anything bigger than we can read.
|
/* Don't write out anything bigger than we can read.
|
||||||
* (The length field in packet headers is 16 bits, which
|
* (The length field in packet headers is 16 bits, which
|
||||||
* imposes a hard limit.) */
|
* imposes a hard limit.) */
|
||||||
if (phdr->caplen > 65535) {
|
if (rec->rec_header.packet_header.caplen > 65535) {
|
||||||
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
usecs=phdr->ts.nsecs/1000;
|
usecs=rec->ts.nsecs/1000;
|
||||||
secs=phdr->ts.secs;
|
secs=rec->ts.secs;
|
||||||
size=phdr->caplen;
|
size=rec->rec_header.packet_header.caplen;
|
||||||
origin = pseudo_header->isdn.uton;
|
origin = pseudo_header->isdn.uton;
|
||||||
channel = pseudo_header->isdn.channel;
|
channel = pseudo_header->isdn.channel;
|
||||||
|
|
||||||
switch(phdr->pkt_encap) {
|
switch(rec->rec_header.packet_header.pkt_encap) {
|
||||||
|
|
||||||
case WTAP_ENCAP_ISDN:
|
case WTAP_ENCAP_ISDN:
|
||||||
protocol=EYESDN_ENCAP_ISDN; /* set depending on decoder format and mode */
|
protocol=EYESDN_ENCAP_ISDN; /* set depending on decoder format and mode */
|
||||||
|
|
|
@ -1096,8 +1096,8 @@ fail:
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
success:
|
success:
|
||||||
wth->frame_buffer = (struct Buffer *)g_malloc(sizeof(struct Buffer));
|
wth->rec_data = (struct Buffer *)g_malloc(sizeof(struct Buffer));
|
||||||
ws_buffer_init(wth->frame_buffer, 1500);
|
ws_buffer_init(wth->rec_data, 1500);
|
||||||
|
|
||||||
if ((wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP) ||
|
if ((wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP) ||
|
||||||
(wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC)) {
|
(wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC)) {
|
||||||
|
@ -2538,12 +2538,12 @@ wtap_dump_open_finish(wtap_dumper *wdh, int file_type_subtype, gboolean compress
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
wtap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
wtap_dump(wtap_dumper *wdh, const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info)
|
const guint8 *pd, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
*err = 0;
|
*err = 0;
|
||||||
*err_info = NULL;
|
*err_info = NULL;
|
||||||
return (wdh->subtype_write)(wdh, phdr, pd, err, err_info);
|
return (wdh->subtype_write)(wdh, rec, pd, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -21,7 +21,7 @@ struct dump_hdr {
|
||||||
|
|
||||||
#define DUMP_HDR_SIZE (sizeof(struct dump_hdr))
|
#define DUMP_HDR_SIZE (sizeof(struct dump_hdr))
|
||||||
|
|
||||||
static gboolean hcidump_read_packet(FILE_T fh, struct wtap_pkthdr *phdr,
|
static gboolean hcidump_read_packet(FILE_T fh, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
struct dump_hdr dh;
|
struct dump_hdr dh;
|
||||||
|
@ -42,14 +42,14 @@ static gboolean hcidump_read_packet(FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS;
|
rec->presence_flags = WTAP_HAS_TS;
|
||||||
phdr->ts.secs = GUINT32_FROM_LE(dh.ts_sec);
|
rec->ts.secs = GUINT32_FROM_LE(dh.ts_sec);
|
||||||
phdr->ts.nsecs = GUINT32_FROM_LE(dh.ts_usec) * 1000;
|
rec->ts.nsecs = GUINT32_FROM_LE(dh.ts_usec) * 1000;
|
||||||
phdr->caplen = packet_size;
|
rec->rec_header.packet_header.caplen = packet_size;
|
||||||
phdr->len = packet_size;
|
rec->rec_header.packet_header.len = packet_size;
|
||||||
|
|
||||||
phdr->pseudo_header.p2p.sent = (dh.in ? FALSE : TRUE);
|
rec->rec_header.packet_header.pseudo_header.p2p.sent = (dh.in ? FALSE : TRUE);
|
||||||
|
|
||||||
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
|
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
|
||||||
}
|
}
|
||||||
|
@ -59,17 +59,17 @@ static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info,
|
||||||
{
|
{
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
|
|
||||||
return hcidump_read_packet(wth->fh, &wth->phdr, wth->frame_buffer,
|
return hcidump_read_packet(wth->fh, &wth->rec, wth->rec_data,
|
||||||
err, err_info);
|
err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return hcidump_read_packet(wth->random_fh, phdr, buf, err, err_info);
|
return hcidump_read_packet(wth->random_fh, rec, buf, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
wtap_open_return_val hcidump_open(wtap *wth, int *err, gchar **err_info)
|
wtap_open_return_val hcidump_open(wtap *wth, int *err, gchar **err_info)
|
||||||
|
|
|
@ -23,8 +23,8 @@ typedef struct {
|
||||||
static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
static int i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
static int i4b_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info);
|
Buffer *buf, int *err, gchar **err_info);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -98,18 +98,18 @@ static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
|
||||||
{
|
{
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
|
|
||||||
return i4b_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer,
|
return i4b_read_rec(wth, wth->fh, &wth->rec, wth->rec_data,
|
||||||
err, err_info);
|
err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
i4btrace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
i4btrace_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!i4b_read_rec(wth, wth->random_fh, phdr, buf, err, err_info)) {
|
if (!i4b_read_rec(wth, wth->random_fh, rec, buf, err, err_info)) {
|
||||||
/* Read error or EOF */
|
/* Read error or EOF */
|
||||||
if (*err == 0) {
|
if (*err == 0) {
|
||||||
/* EOF means "short read" in random-access mode */
|
/* EOF means "short read" in random-access mode */
|
||||||
|
@ -121,7 +121,7 @@ i4btrace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
i4b_read_rec(wtap *wth, FILE_T fh, wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
i4btrace_t *i4btrace = (i4btrace_t *)wth->priv;
|
i4btrace_t *i4btrace = (i4btrace_t *)wth->priv;
|
||||||
|
@ -163,14 +163,14 @@ i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS;
|
rec->presence_flags = WTAP_HAS_TS;
|
||||||
|
|
||||||
phdr->len = length;
|
rec->rec_header.packet_header.len = length;
|
||||||
phdr->caplen = length;
|
rec->rec_header.packet_header.caplen = length;
|
||||||
|
|
||||||
phdr->ts.secs = hdr.ts_sec;
|
rec->ts.secs = hdr.ts_sec;
|
||||||
phdr->ts.nsecs = hdr.ts_usec * 1000;
|
rec->ts.nsecs = hdr.ts_usec * 1000;
|
||||||
|
|
||||||
switch (hdr.type) {
|
switch (hdr.type) {
|
||||||
|
|
||||||
|
@ -180,35 +180,35 @@ i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
* as that means it has a 4-byte AF_ type as the
|
* as that means it has a 4-byte AF_ type as the
|
||||||
* encapsulation header.
|
* encapsulation header.
|
||||||
*/
|
*/
|
||||||
phdr->pkt_encap = WTAP_ENCAP_NULL;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_NULL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TRC_CH_D:
|
case TRC_CH_D:
|
||||||
/*
|
/*
|
||||||
* D channel, so it's LAPD; set "p2p.sent".
|
* D channel, so it's LAPD; set "p2p.sent".
|
||||||
*/
|
*/
|
||||||
phdr->pkt_encap = WTAP_ENCAP_ISDN;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISDN;
|
||||||
phdr->pseudo_header.isdn.channel = 0;
|
rec->rec_header.packet_header.pseudo_header.isdn.channel = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TRC_CH_B1:
|
case TRC_CH_B1:
|
||||||
/*
|
/*
|
||||||
* B channel 1.
|
* B channel 1.
|
||||||
*/
|
*/
|
||||||
phdr->pkt_encap = WTAP_ENCAP_ISDN;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISDN;
|
||||||
phdr->pseudo_header.isdn.channel = 1;
|
rec->rec_header.packet_header.pseudo_header.isdn.channel = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TRC_CH_B2:
|
case TRC_CH_B2:
|
||||||
/*
|
/*
|
||||||
* B channel 2.
|
* B channel 2.
|
||||||
*/
|
*/
|
||||||
phdr->pkt_encap = WTAP_ENCAP_ISDN;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ISDN;
|
||||||
phdr->pseudo_header.isdn.channel = 2;
|
rec->rec_header.packet_header.pseudo_header.isdn.channel = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr->pseudo_header.isdn.uton = (hdr.dir == FROM_TE);
|
rec->rec_header.packet_header.pseudo_header.isdn.uton = (hdr.dir == FROM_TE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the packet data.
|
* Read the packet data.
|
||||||
|
|
|
@ -70,7 +70,7 @@ ipfix_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean
|
static gboolean
|
||||||
ipfix_seek_read(wtap *wth, gint64 seek_off,
|
ipfix_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
|
|
||||||
#define IPFIX_VERSION 10
|
#define IPFIX_VERSION 10
|
||||||
|
|
||||||
|
@ -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).
|
* errors (EOF is ok, since return value is still FALSE).
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
ipfix_read_message(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
ipfix_read_message(FILE_T fh, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
ipfix_message_header_t msg_hdr;
|
ipfix_message_header_t msg_hdr;
|
||||||
|
|
||||||
|
@ -153,12 +153,12 @@ ipfix_read_message(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, g
|
||||||
* to check it.
|
* to check it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS;
|
rec->presence_flags = WTAP_HAS_TS;
|
||||||
phdr->len = msg_hdr.message_length;
|
rec->rec_header.packet_header.len = msg_hdr.message_length;
|
||||||
phdr->caplen = msg_hdr.message_length;
|
rec->rec_header.packet_header.caplen = msg_hdr.message_length;
|
||||||
phdr->ts.secs = msg_hdr.export_time_secs;
|
rec->ts.secs = msg_hdr.export_time_secs;
|
||||||
phdr->ts.nsecs = 0;
|
rec->ts.nsecs = 0;
|
||||||
|
|
||||||
return wtap_read_packet_bytes(fh, buf, msg_hdr.message_length, err, err_info);
|
return wtap_read_packet_bytes(fh, buf, msg_hdr.message_length, err, err_info);
|
||||||
}
|
}
|
||||||
|
@ -280,9 +280,10 @@ static gboolean
|
||||||
ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||||
{
|
{
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
ipfix_debug("ipfix_read: data_offset is initially %" G_GINT64_MODIFIER "d", *data_offset);
|
ipfix_debug("ipfix_read: data_offset is initially %" G_GINT64_MODIFIER "d",
|
||||||
|
wth->rec.rec_header.packet_header.file_offset);
|
||||||
|
|
||||||
if (!ipfix_read_message(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info)) {
|
if (!ipfix_read_message(wth->fh, &wth->rec, wth->rec_data, err, err_info)) {
|
||||||
ipfix_debug("ipfix_read: couldn't read message header with code: %d\n, and error '%s'",
|
ipfix_debug("ipfix_read: couldn't read message header with code: %d\n, and error '%s'",
|
||||||
*err, *err_info);
|
*err, *err_info);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -294,7 +295,7 @@ ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||||
|
|
||||||
/* classic wtap: seek to file position and read packet */
|
/* classic wtap: seek to file position and read packet */
|
||||||
static gboolean
|
static gboolean
|
||||||
ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
ipfix_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
/* seek to the right file position */
|
/* seek to the right file position */
|
||||||
|
@ -306,7 +307,7 @@ ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||||
|
|
||||||
ipfix_debug("ipfix_seek_read: reading at offset %" G_GINT64_MODIFIER "u", seek_off);
|
ipfix_debug("ipfix_seek_read: reading at offset %" G_GINT64_MODIFIER "u", seek_off);
|
||||||
|
|
||||||
if (!ipfix_read_message(wth->random_fh, phdr, buf, err, err_info)) {
|
if (!ipfix_read_message(wth->random_fh, rec, buf, err, err_info)) {
|
||||||
ipfix_debug("ipfix_seek_read: couldn't read message header");
|
ipfix_debug("ipfix_seek_read: couldn't read message header");
|
||||||
if (*err == 0)
|
if (*err == 0)
|
||||||
*err = WTAP_ERR_SHORT_READ;
|
*err = WTAP_ERR_SHORT_READ;
|
||||||
|
|
|
@ -21,15 +21,15 @@
|
||||||
static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
|
static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off,
|
static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
|
|
||||||
static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
|
static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
|
static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
|
|
||||||
static gboolean iptrace_read_rec_data(FILE_T fh, Buffer *buf,
|
static gboolean iptrace_read_rec_data(FILE_T fh, Buffer *buf,
|
||||||
struct wtap_pkthdr *phdr, int *err, gchar **err_info);
|
wtap_rec *rec, int *err, gchar **err_info);
|
||||||
static void fill_in_pseudo_header(int encap,
|
static void fill_in_pseudo_header(int encap,
|
||||||
union wtap_pseudo_header *pseudo_header, guint8 *header);
|
union wtap_pseudo_header *pseudo_header, guint8 *header);
|
||||||
static int wtap_encap_ift(unsigned int ift);
|
static int wtap_encap_ift(unsigned int ift);
|
||||||
|
@ -102,7 +102,7 @@ typedef struct {
|
||||||
#define IPTRACE_1_0_PDATA_SIZE 22 /* packet data */
|
#define IPTRACE_1_0_PDATA_SIZE 22 /* packet data */
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
iptrace_read_rec_1_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
iptrace_read_rec_1_0(FILE_T fh, wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
guint8 header[IPTRACE_1_0_PHDR_SIZE];
|
guint8 header[IPTRACE_1_0_PHDR_SIZE];
|
||||||
|
@ -120,8 +120,8 @@ iptrace_read_rec_1_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
* <net/if_types.h> header file.
|
* <net/if_types.h> header file.
|
||||||
*/
|
*/
|
||||||
pkt_hdr.if_type = header[28];
|
pkt_hdr.if_type = header[28];
|
||||||
phdr->pkt_encap = wtap_encap_ift(pkt_hdr.if_type);
|
rec->rec_header.packet_header.pkt_encap = wtap_encap_ift(pkt_hdr.if_type);
|
||||||
if (phdr->pkt_encap == WTAP_ENCAP_UNKNOWN) {
|
if (rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_UNKNOWN) {
|
||||||
*err = WTAP_ERR_UNSUPPORTED;
|
*err = WTAP_ERR_UNSUPPORTED;
|
||||||
*err_info = g_strdup_printf("iptrace: interface type IFT=0x%02x unknown or unsupported",
|
*err_info = g_strdup_printf("iptrace: interface type IFT=0x%02x unknown or unsupported",
|
||||||
pkt_hdr.if_type);
|
pkt_hdr.if_type);
|
||||||
|
@ -146,7 +146,7 @@ iptrace_read_rec_1_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
* AIX appears to put 3 bytes of padding in front of FDDI
|
* AIX appears to put 3 bytes of padding in front of FDDI
|
||||||
* frames; strip that crap off.
|
* frames; strip that crap off.
|
||||||
*/
|
*/
|
||||||
if (phdr->pkt_encap == WTAP_ENCAP_FDDI_BITSWAPPED) {
|
if (rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_FDDI_BITSWAPPED) {
|
||||||
/*
|
/*
|
||||||
* The packet size is really a record size and includes
|
* The packet size is really a record size and includes
|
||||||
* the padding.
|
* the padding.
|
||||||
|
@ -180,18 +180,18 @@ iptrace_read_rec_1_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS;
|
rec->presence_flags = WTAP_HAS_TS;
|
||||||
phdr->len = packet_size;
|
rec->rec_header.packet_header.len = packet_size;
|
||||||
phdr->caplen = packet_size;
|
rec->rec_header.packet_header.caplen = packet_size;
|
||||||
phdr->ts.secs = pntoh32(&header[4]);
|
rec->ts.secs = pntoh32(&header[4]);
|
||||||
phdr->ts.nsecs = 0;
|
rec->ts.nsecs = 0;
|
||||||
|
|
||||||
/* Fill in the pseudo-header. */
|
/* Fill in the pseudo-header. */
|
||||||
fill_in_pseudo_header(phdr->pkt_encap, &phdr->pseudo_header, header);
|
fill_in_pseudo_header(rec->rec_header.packet_header.pkt_encap, &rec->rec_header.packet_header.pseudo_header, header);
|
||||||
|
|
||||||
/* Get the packet data */
|
/* Get the packet data */
|
||||||
return iptrace_read_rec_data(fh, buf, phdr, err, err_info);
|
return iptrace_read_rec_data(fh, buf, rec, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the next packet */
|
/* Read the next packet */
|
||||||
|
@ -201,7 +201,7 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
|
|
||||||
/* Read the packet */
|
/* Read the packet */
|
||||||
if (!iptrace_read_rec_1_0(wth->fh, &wth->phdr, wth->frame_buffer,
|
if (!iptrace_read_rec_1_0(wth->fh, &wth->rec, wth->rec_data,
|
||||||
err, err_info)) {
|
err, err_info)) {
|
||||||
/* Read error or EOF */
|
/* Read error or EOF */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -214,9 +214,9 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
|
||||||
set it to WTAP_ENCAP_PER_PACKET, as this file doesn't
|
set it to WTAP_ENCAP_PER_PACKET, as this file doesn't
|
||||||
have a single encapsulation for all packets in the file. */
|
have a single encapsulation for all packets in the file. */
|
||||||
if (wth->file_encap == WTAP_ENCAP_UNKNOWN)
|
if (wth->file_encap == WTAP_ENCAP_UNKNOWN)
|
||||||
wth->file_encap = wth->phdr.pkt_encap;
|
wth->file_encap = wth->rec.rec_header.packet_header.pkt_encap;
|
||||||
else {
|
else {
|
||||||
if (wth->file_encap != wth->phdr.pkt_encap)
|
if (wth->file_encap != wth->rec.rec_header.packet_header.pkt_encap)
|
||||||
wth->file_encap = WTAP_ENCAP_PER_PACKET;
|
wth->file_encap = WTAP_ENCAP_PER_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,13 +224,13 @@ static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off,
|
static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Read the packet */
|
/* Read the packet */
|
||||||
if (!iptrace_read_rec_1_0(wth->random_fh, phdr, buf, err, err_info)) {
|
if (!iptrace_read_rec_1_0(wth->random_fh, rec, buf, err, err_info)) {
|
||||||
if (*err == 0)
|
if (*err == 0)
|
||||||
*err = WTAP_ERR_SHORT_READ;
|
*err = WTAP_ERR_SHORT_READ;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -277,7 +277,7 @@ typedef struct {
|
||||||
#define IPTRACE_2_0_PDATA_SIZE 32 /* packet data */
|
#define IPTRACE_2_0_PDATA_SIZE 32 /* packet data */
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
iptrace_read_rec_2_0(FILE_T fh, wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
guint8 header[IPTRACE_2_0_PHDR_SIZE];
|
guint8 header[IPTRACE_2_0_PHDR_SIZE];
|
||||||
|
@ -295,7 +295,7 @@ iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
* <net/if_types.h> header file.
|
* <net/if_types.h> header file.
|
||||||
*/
|
*/
|
||||||
pkt_hdr.if_type = header[28];
|
pkt_hdr.if_type = header[28];
|
||||||
phdr->pkt_encap = wtap_encap_ift(pkt_hdr.if_type);
|
rec->rec_header.packet_header.pkt_encap = wtap_encap_ift(pkt_hdr.if_type);
|
||||||
#if 0
|
#if 0
|
||||||
/*
|
/*
|
||||||
* We used to error out if the interface type in iptrace was
|
* We used to error out if the interface type in iptrace was
|
||||||
|
@ -313,7 +313,7 @@ iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
* XXX - what types are there that are used in files but
|
* XXX - what types are there that are used in files but
|
||||||
* that we don't handle?
|
* that we don't handle?
|
||||||
*/
|
*/
|
||||||
if (phdr->pkt_encap == WTAP_ENCAP_UNKNOWN) {
|
if (rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_UNKNOWN) {
|
||||||
*err = WTAP_ERR_UNSUPPORTED;
|
*err = WTAP_ERR_UNSUPPORTED;
|
||||||
*err_info = g_strdup_printf("iptrace: interface type IFT=0x%02x unknown or unsupported",
|
*err_info = g_strdup_printf("iptrace: interface type IFT=0x%02x unknown or unsupported",
|
||||||
pkt_hdr.if_type);
|
pkt_hdr.if_type);
|
||||||
|
@ -339,7 +339,7 @@ iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
* AIX appears to put 3 bytes of padding in front of FDDI
|
* AIX appears to put 3 bytes of padding in front of FDDI
|
||||||
* frames; strip that crap off.
|
* frames; strip that crap off.
|
||||||
*/
|
*/
|
||||||
if (phdr->pkt_encap == WTAP_ENCAP_FDDI_BITSWAPPED) {
|
if (rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_FDDI_BITSWAPPED) {
|
||||||
/*
|
/*
|
||||||
* The packet size is really a record size and includes
|
* The packet size is really a record size and includes
|
||||||
* the padding.
|
* the padding.
|
||||||
|
@ -373,18 +373,18 @@ iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS;
|
rec->presence_flags = WTAP_HAS_TS;
|
||||||
phdr->len = packet_size;
|
rec->rec_header.packet_header.len = packet_size;
|
||||||
phdr->caplen = packet_size;
|
rec->rec_header.packet_header.caplen = packet_size;
|
||||||
phdr->ts.secs = pntoh32(&header[32]);
|
rec->ts.secs = pntoh32(&header[32]);
|
||||||
phdr->ts.nsecs = pntoh32(&header[36]);
|
rec->ts.nsecs = pntoh32(&header[36]);
|
||||||
|
|
||||||
/* Fill in the pseudo_header. */
|
/* Fill in the pseudo_header. */
|
||||||
fill_in_pseudo_header(phdr->pkt_encap, &phdr->pseudo_header, header);
|
fill_in_pseudo_header(rec->rec_header.packet_header.pkt_encap, &rec->rec_header.packet_header.pseudo_header, header);
|
||||||
|
|
||||||
/* Get the packet data */
|
/* Get the packet data */
|
||||||
return iptrace_read_rec_data(fh, buf, phdr, err, err_info);
|
return iptrace_read_rec_data(fh, buf, rec, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the next packet */
|
/* Read the next packet */
|
||||||
|
@ -394,7 +394,7 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
|
|
||||||
/* Read the packet */
|
/* Read the packet */
|
||||||
if (!iptrace_read_rec_2_0(wth->fh, &wth->phdr, wth->frame_buffer,
|
if (!iptrace_read_rec_2_0(wth->fh, &wth->rec, wth->rec_data,
|
||||||
err, err_info)) {
|
err, err_info)) {
|
||||||
/* Read error or EOF */
|
/* Read error or EOF */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -407,9 +407,9 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
|
||||||
set it to WTAP_ENCAP_PER_PACKET, as this file doesn't
|
set it to WTAP_ENCAP_PER_PACKET, as this file doesn't
|
||||||
have a single encapsulation for all packets in the file. */
|
have a single encapsulation for all packets in the file. */
|
||||||
if (wth->file_encap == WTAP_ENCAP_UNKNOWN)
|
if (wth->file_encap == WTAP_ENCAP_UNKNOWN)
|
||||||
wth->file_encap = wth->phdr.pkt_encap;
|
wth->file_encap = wth->rec.rec_header.packet_header.pkt_encap;
|
||||||
else {
|
else {
|
||||||
if (wth->file_encap != wth->phdr.pkt_encap)
|
if (wth->file_encap != wth->rec.rec_header.packet_header.pkt_encap)
|
||||||
wth->file_encap = WTAP_ENCAP_PER_PACKET;
|
wth->file_encap = WTAP_ENCAP_PER_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,13 +417,13 @@ static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
|
static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Read the packet */
|
/* Read the packet */
|
||||||
if (!iptrace_read_rec_2_0(wth->random_fh, phdr, buf, err, err_info)) {
|
if (!iptrace_read_rec_2_0(wth->random_fh, rec, buf, err, err_info)) {
|
||||||
if (*err == 0)
|
if (*err == 0)
|
||||||
*err = WTAP_ERR_SHORT_READ;
|
*err = WTAP_ERR_SHORT_READ;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -432,18 +432,18 @@ static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
iptrace_read_rec_data(FILE_T fh, Buffer *buf, struct wtap_pkthdr *phdr,
|
iptrace_read_rec_data(FILE_T fh, Buffer *buf, wtap_rec *rec,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
if (!wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info))
|
if (!wtap_read_packet_bytes(fh, buf, rec->rec_header.packet_header.caplen, err, err_info))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (phdr->pkt_encap == WTAP_ENCAP_ATM_PDUS) {
|
if (rec->rec_header.packet_header.pkt_encap == WTAP_ENCAP_ATM_PDUS) {
|
||||||
/*
|
/*
|
||||||
* Attempt to guess from the packet data, the VPI,
|
* Attempt to guess from the packet data, the VPI,
|
||||||
* and the VCI information about the type of traffic.
|
* and the VCI information about the type of traffic.
|
||||||
*/
|
*/
|
||||||
atm_guess_traffic_type(phdr, ws_buffer_start_ptr(buf));
|
atm_guess_traffic_type(rec, ws_buffer_start_ptr(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -182,13 +182,13 @@ typedef struct {
|
||||||
static gboolean iseries_read (wtap * wth, int *err, gchar ** err_info,
|
static gboolean iseries_read (wtap * wth, int *err, gchar ** err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean iseries_seek_read (wtap * wth, gint64 seek_off,
|
static gboolean iseries_seek_read (wtap * wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr,
|
wtap_rec *rec,
|
||||||
Buffer * buf, int *err, gchar ** err_info);
|
Buffer * buf, int *err, gchar ** err_info);
|
||||||
static gboolean iseries_check_file_type (wtap * wth, int *err, gchar **err_info,
|
static gboolean iseries_check_file_type (wtap * wth, int *err, gchar **err_info,
|
||||||
int format);
|
int format);
|
||||||
static gint64 iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info);
|
static gint64 iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info);
|
||||||
static gboolean iseries_parse_packet (wtap * wth, FILE_T fh,
|
static gboolean iseries_parse_packet (wtap * wth, FILE_T fh,
|
||||||
struct wtap_pkthdr *phdr,
|
wtap_rec *rec,
|
||||||
Buffer * buf, int *err, gchar ** err_info);
|
Buffer * buf, int *err, gchar ** err_info);
|
||||||
static int iseries_UNICODE_to_ASCII (guint8 * buf, guint bytes);
|
static int iseries_UNICODE_to_ASCII (guint8 * buf, guint bytes);
|
||||||
static gboolean iseries_parse_hex_string (const char * ascii, guint8 * buf,
|
static gboolean iseries_parse_hex_string (const char * ascii, guint8 * buf,
|
||||||
|
@ -391,7 +391,7 @@ iseries_read (wtap * wth, int *err, gchar ** err_info, gint64 *data_offset)
|
||||||
/*
|
/*
|
||||||
* Parse the packet and extract the various fields
|
* Parse the packet and extract the various fields
|
||||||
*/
|
*/
|
||||||
return iseries_parse_packet (wth, wth->fh, &wth->phdr, wth->frame_buffer,
|
return iseries_parse_packet (wth, wth->fh, &wth->rec, wth->rec_data,
|
||||||
err, err_info);
|
err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info)
|
||||||
* Read packets in random-access fashion
|
* Read packets in random-access fashion
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static gboolean
|
||||||
iseries_seek_read (wtap * wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
iseries_seek_read (wtap * wth, gint64 seek_off, wtap_rec *rec,
|
||||||
Buffer * buf, int *err, gchar ** err_info)
|
Buffer * buf, int *err, gchar ** err_info)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -474,7 +474,7 @@ iseries_seek_read (wtap * wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||||
/*
|
/*
|
||||||
* Parse the packet and extract the various fields
|
* Parse the packet and extract the various fields
|
||||||
*/
|
*/
|
||||||
return iseries_parse_packet (wth, wth->random_fh, phdr, buf,
|
return iseries_parse_packet (wth, wth->random_fh, rec, buf,
|
||||||
err, err_info);
|
err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,7 +575,7 @@ csec_multiplier(guint32 csec)
|
||||||
|
|
||||||
/* Parses a packet. */
|
/* Parses a packet. */
|
||||||
static gboolean
|
static gboolean
|
||||||
iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
iseries_parse_packet (wtap * wth, FILE_T fh, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
iseries_t *iseries = (iseries_t *)wth->priv;
|
iseries_t *iseries = (iseries_t *)wth->priv;
|
||||||
|
@ -738,8 +738,8 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_CAP_LEN;
|
rec->presence_flags = WTAP_HAS_CAP_LEN;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we have Wiretap Header then populate it here
|
* If we have Wiretap Header then populate it here
|
||||||
|
@ -749,7 +749,7 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
*/
|
*/
|
||||||
if (iseries->have_date)
|
if (iseries->have_date)
|
||||||
{
|
{
|
||||||
phdr->presence_flags |= WTAP_HAS_TS;
|
rec->presence_flags |= WTAP_HAS_TS;
|
||||||
tm.tm_year = 100 + iseries->year;
|
tm.tm_year = 100 + iseries->year;
|
||||||
tm.tm_mon = iseries->month - 1;
|
tm.tm_mon = iseries->month - 1;
|
||||||
tm.tm_mday = iseries->day;
|
tm.tm_mday = iseries->day;
|
||||||
|
@ -757,13 +757,13 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
tm.tm_min = min;
|
tm.tm_min = min;
|
||||||
tm.tm_sec = sec;
|
tm.tm_sec = sec;
|
||||||
tm.tm_isdst = -1;
|
tm.tm_isdst = -1;
|
||||||
phdr->ts.secs = mktime (&tm);
|
rec->ts.secs = mktime (&tm);
|
||||||
phdr->ts.nsecs = csec * csec_multiplier(csec);
|
rec->ts.nsecs = csec * csec_multiplier(csec);
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr->len = pkt_len;
|
rec->rec_header.packet_header.len = pkt_len;
|
||||||
phdr->pkt_encap = WTAP_ENCAP_ETHERNET;
|
rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_ETHERNET;
|
||||||
phdr->pseudo_header.eth.fcs_len = -1;
|
rec->rec_header.packet_header.pseudo_header.eth.fcs_len = -1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate a buffer big enough to hold the claimed packet length
|
* Allocate a buffer big enough to hold the claimed packet length
|
||||||
|
@ -942,10 +942,10 @@ iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
* XXX - this can happen for IPv6 packets if the next header isn't the
|
* XXX - this can happen for IPv6 packets if the next header isn't the
|
||||||
* last header.
|
* last header.
|
||||||
*/
|
*/
|
||||||
phdr->caplen = ((guint32) ascii_offset)/2;
|
rec->rec_header.packet_header.caplen = ((guint32) ascii_offset)/2;
|
||||||
|
|
||||||
/* Make sure we have enough room for the packet. */
|
/* Make sure we have enough room for the packet. */
|
||||||
ws_buffer_assure_space (buf, phdr->caplen);
|
ws_buffer_assure_space (buf, rec->rec_header.packet_header.caplen);
|
||||||
/* Convert ascii data to binary and return in the frame buffer */
|
/* Convert ascii data to binary and return in the frame buffer */
|
||||||
iseries_parse_hex_string (ascii_buf, ws_buffer_start_ptr (buf), ascii_offset);
|
iseries_parse_hex_string (ascii_buf, ws_buffer_start_ptr (buf), ascii_offset);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "json.h"
|
#include "json.h"
|
||||||
#include <wsutil/wsjsmn.h>
|
#include <wsutil/wsjsmn.h>
|
||||||
|
|
||||||
static gboolean json_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
static gboolean json_read_file(wtap *wth, FILE_T fh, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
gint64 file_size;
|
gint64 file_size;
|
||||||
|
@ -36,19 +36,19 @@ static gboolean json_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
}
|
}
|
||||||
packet_size = (int)file_size;
|
packet_size = (int)file_size;
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */
|
rec->presence_flags = 0; /* yes, we have no bananas^Wtime stamp */
|
||||||
|
|
||||||
phdr->caplen = packet_size;
|
rec->rec_header.packet_header.caplen = packet_size;
|
||||||
phdr->len = packet_size;
|
rec->rec_header.packet_header.len = packet_size;
|
||||||
|
|
||||||
phdr->ts.secs = 0;
|
rec->ts.secs = 0;
|
||||||
phdr->ts.nsecs = 0;
|
rec->ts.nsecs = 0;
|
||||||
|
|
||||||
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
|
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean json_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf,
|
static gboolean json_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
/* there is only one packet */
|
/* there is only one packet */
|
||||||
|
@ -60,7 +60,7 @@ static gboolean json_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *p
|
||||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return json_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
|
return json_read_file(wth, wth->random_fh, rec, buf, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean json_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
static gboolean json_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||||
|
@ -77,7 +77,7 @@ static gboolean json_read(wtap *wth, int *err, gchar **err_info, gint64 *data_of
|
||||||
|
|
||||||
*data_offset = offset;
|
*data_offset = offset;
|
||||||
|
|
||||||
return json_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
|
return json_read_file(wth, wth->fh, &wth->rec, wth->rec_data, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
wtap_open_return_val json_open(wtap *wth, int *err, gchar **err_info)
|
wtap_open_return_val json_open(wtap *wth, int *err, gchar **err_info)
|
||||||
|
|
|
@ -562,7 +562,7 @@ memiszero(const void *ptr, size_t count)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
process_packet_data(struct wtap_pkthdr *phdr, Buffer *target, guint8 *buffer,
|
process_packet_data(wtap_rec *rec, Buffer *target, guint8 *buffer,
|
||||||
guint record_len, k12_t *k12, int *err, gchar **err_info)
|
guint record_len, k12_t *k12, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
guint32 type;
|
guint32 type;
|
||||||
|
@ -590,15 +590,15 @@ process_packet_data(struct wtap_pkthdr *phdr, Buffer *target, guint8 *buffer,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS;
|
rec->presence_flags = WTAP_HAS_TS;
|
||||||
|
|
||||||
ts = pntoh64(buffer + K12_PACKET_TIMESTAMP);
|
ts = pntoh64(buffer + K12_PACKET_TIMESTAMP);
|
||||||
|
|
||||||
phdr->ts.secs = (guint32) ((ts / 2000000) + 631152000);
|
rec->ts.secs = (guint32) ((ts / 2000000) + 631152000);
|
||||||
phdr->ts.nsecs = (guint32) ( (ts % 2000000) * 500 );
|
rec->ts.nsecs = (guint32) ( (ts % 2000000) * 500 );
|
||||||
|
|
||||||
phdr->len = phdr->caplen = length;
|
rec->rec_header.packet_header.len = rec->rec_header.packet_header.caplen = length;
|
||||||
|
|
||||||
ws_buffer_assure_space(target, length);
|
ws_buffer_assure_space(target, length);
|
||||||
memcpy(ws_buffer_start_ptr(target), buffer + buffer_offset, length);
|
memcpy(ws_buffer_start_ptr(target), buffer + buffer_offset, length);
|
||||||
|
@ -608,12 +608,12 @@ process_packet_data(struct wtap_pkthdr *phdr, Buffer *target, guint8 *buffer,
|
||||||
ws_buffer_assure_space(&(k12->extra_info), extra_len);
|
ws_buffer_assure_space(&(k12->extra_info), extra_len);
|
||||||
memcpy(ws_buffer_start_ptr(&(k12->extra_info)),
|
memcpy(ws_buffer_start_ptr(&(k12->extra_info)),
|
||||||
buffer + buffer_offset + length, extra_len);
|
buffer + buffer_offset + length, extra_len);
|
||||||
phdr->pseudo_header.k12.extra_info = (guint8*)ws_buffer_start_ptr(&(k12->extra_info));
|
rec->rec_header.packet_header.pseudo_header.k12.extra_info = (guint8*)ws_buffer_start_ptr(&(k12->extra_info));
|
||||||
phdr->pseudo_header.k12.extra_length = extra_len;
|
rec->rec_header.packet_header.pseudo_header.k12.extra_length = extra_len;
|
||||||
|
|
||||||
src_id = pntoh32(buffer + K12_RECORD_SRC_ID);
|
src_id = pntoh32(buffer + K12_RECORD_SRC_ID);
|
||||||
K12_DBG(5,("process_packet_data: src_id=%.8x",src_id));
|
K12_DBG(5,("process_packet_data: src_id=%.8x",src_id));
|
||||||
phdr->pseudo_header.k12.input = src_id;
|
rec->rec_header.packet_header.pseudo_header.k12.input = src_id;
|
||||||
|
|
||||||
if ( ! (src_desc = (k12_src_desc_t*)g_hash_table_lookup(k12->src_by_id,GUINT_TO_POINTER(src_id))) ) {
|
if ( ! (src_desc = (k12_src_desc_t*)g_hash_table_lookup(k12->src_by_id,GUINT_TO_POINTER(src_id))) ) {
|
||||||
/*
|
/*
|
||||||
|
@ -628,33 +628,33 @@ process_packet_data(struct wtap_pkthdr *phdr, Buffer *target, guint8 *buffer,
|
||||||
|
|
||||||
if (src_desc) {
|
if (src_desc) {
|
||||||
K12_DBG(5,("process_packet_data: input_name='%s' stack_file='%s' type=%x",src_desc->input_name,src_desc->stack_file,src_desc->input_type));
|
K12_DBG(5,("process_packet_data: input_name='%s' stack_file='%s' type=%x",src_desc->input_name,src_desc->stack_file,src_desc->input_type));
|
||||||
phdr->pseudo_header.k12.input_name = src_desc->input_name;
|
rec->rec_header.packet_header.pseudo_header.k12.input_name = src_desc->input_name;
|
||||||
phdr->pseudo_header.k12.stack_file = src_desc->stack_file;
|
rec->rec_header.packet_header.pseudo_header.k12.stack_file = src_desc->stack_file;
|
||||||
phdr->pseudo_header.k12.input_type = src_desc->input_type;
|
rec->rec_header.packet_header.pseudo_header.k12.input_type = src_desc->input_type;
|
||||||
|
|
||||||
switch(src_desc->input_type) {
|
switch(src_desc->input_type) {
|
||||||
case K12_PORT_ATMPVC:
|
case K12_PORT_ATMPVC:
|
||||||
if (buffer_offset + length + K12_PACKET_OFFSET_CID < record_len) {
|
if (buffer_offset + length + K12_PACKET_OFFSET_CID < record_len) {
|
||||||
phdr->pseudo_header.k12.input_info.atm.vp = pntoh16(buffer + buffer_offset + length + K12_PACKET_OFFSET_VP);
|
rec->rec_header.packet_header.pseudo_header.k12.input_info.atm.vp = pntoh16(buffer + buffer_offset + length + K12_PACKET_OFFSET_VP);
|
||||||
phdr->pseudo_header.k12.input_info.atm.vc = pntoh16(buffer + buffer_offset + length + K12_PACKET_OFFSET_VC);
|
rec->rec_header.packet_header.pseudo_header.k12.input_info.atm.vc = pntoh16(buffer + buffer_offset + length + K12_PACKET_OFFSET_VC);
|
||||||
phdr->pseudo_header.k12.input_info.atm.cid = *((unsigned char*)(buffer + buffer_offset + length + K12_PACKET_OFFSET_CID));
|
rec->rec_header.packet_header.pseudo_header.k12.input_info.atm.cid = *((unsigned char*)(buffer + buffer_offset + length + K12_PACKET_OFFSET_CID));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
default:
|
default:
|
||||||
memcpy(&(phdr->pseudo_header.k12.input_info),&(src_desc->input_info),sizeof(src_desc->input_info));
|
memcpy(&(rec->rec_header.packet_header.pseudo_header.k12.input_info),&(src_desc->input_info),sizeof(src_desc->input_info));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
K12_DBG(5,("process_packet_data: NO SRC_RECORD FOUND"));
|
K12_DBG(5,("process_packet_data: NO SRC_RECORD FOUND"));
|
||||||
|
|
||||||
memset(&(phdr->pseudo_header.k12),0,sizeof(phdr->pseudo_header.k12));
|
memset(&(rec->rec_header.packet_header.pseudo_header.k12),0,sizeof(rec->rec_header.packet_header.pseudo_header.k12));
|
||||||
phdr->pseudo_header.k12.input_name = "unknown port";
|
rec->rec_header.packet_header.pseudo_header.k12.input_name = "unknown port";
|
||||||
phdr->pseudo_header.k12.stack_file = "unknown stack file";
|
rec->rec_header.packet_header.pseudo_header.k12.stack_file = "unknown stack file";
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr->pseudo_header.k12.input = src_id;
|
rec->rec_header.packet_header.pseudo_header.k12.input = src_id;
|
||||||
phdr->pseudo_header.k12.stuff = k12;
|
rec->rec_header.packet_header.pseudo_header.k12.stuff = k12;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -721,11 +721,11 @@ static gboolean k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off
|
||||||
|
|
||||||
} while ( ((type & K12_MASK_PACKET) != K12_REC_PACKET && (type & K12_MASK_PACKET) != K12_REC_D0020) || !src_id || !src_desc );
|
} while ( ((type & K12_MASK_PACKET) != K12_REC_PACKET && (type & K12_MASK_PACKET) != K12_REC_D0020) || !src_id || !src_desc );
|
||||||
|
|
||||||
return process_packet_data(&wth->phdr, wth->frame_buffer, buffer, (guint)len, k12, err, err_info);
|
return process_packet_data(&wth->rec, wth->rec_data, buffer, (guint)len, k12, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) {
|
static gboolean k12_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) {
|
||||||
k12_t *k12 = (k12_t *)wth->priv;
|
k12_t *k12 = (k12_t *)wth->priv;
|
||||||
guint8* buffer;
|
guint8* buffer;
|
||||||
gint len;
|
gint len;
|
||||||
|
@ -751,7 +751,7 @@ static gboolean k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *ph
|
||||||
|
|
||||||
buffer = k12->rand_read_buff;
|
buffer = k12->rand_read_buff;
|
||||||
|
|
||||||
status = process_packet_data(phdr, buf, buffer, (guint)len, k12, err, err_info);
|
status = process_packet_data(rec, buf, buffer, (guint)len, k12, err, err_info);
|
||||||
|
|
||||||
K12_DBG(5,("k12_seek_read: DONE OK"));
|
K12_DBG(5,("k12_seek_read: DONE OK"));
|
||||||
|
|
||||||
|
@ -1247,9 +1247,9 @@ static void k12_dump_src_setting(gpointer k _U_, gpointer v, gpointer p) {
|
||||||
k12_dump_record(wdh,len,obj.buffer, &errxxx); /* fwrite errs ignored: see k12_dump below */
|
k12_dump_record(wdh,len,obj.buffer, &errxxx); /* fwrite errs ignored: see k12_dump below */
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
static gboolean k12_dump(wtap_dumper *wdh, const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info _U_) {
|
const guint8 *pd, int *err, gchar **err_info _U_) {
|
||||||
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
|
const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header;
|
||||||
k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
|
k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
|
||||||
guint32 len;
|
guint32 len;
|
||||||
union {
|
union {
|
||||||
|
@ -1269,7 +1269,7 @@ static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||||
} obj;
|
} obj;
|
||||||
|
|
||||||
/* We can only write packet records. */
|
/* We can only write packet records. */
|
||||||
if (phdr->rec_type != REC_TYPE_PACKET) {
|
if (rec->rec_type != REC_TYPE_PACKET) {
|
||||||
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -1283,7 +1283,7 @@ static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||||
/* encountered in k12_dump_src_setting). */
|
/* encountered in k12_dump_src_setting). */
|
||||||
g_hash_table_foreach(file_data->src_by_id,k12_dump_src_setting,wdh);
|
g_hash_table_foreach(file_data->src_by_id,k12_dump_src_setting,wdh);
|
||||||
}
|
}
|
||||||
obj.record.len = 0x20 + phdr->caplen;
|
obj.record.len = 0x20 + rec->rec_header.packet_header.caplen;
|
||||||
obj.record.len += (obj.record.len % 4) ? 4 - obj.record.len % 4 : 0;
|
obj.record.len += (obj.record.len % 4) ? 4 - obj.record.len % 4 : 0;
|
||||||
|
|
||||||
len = obj.record.len;
|
len = obj.record.len;
|
||||||
|
@ -1291,12 +1291,12 @@ static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||||
obj.record.len = g_htonl(obj.record.len);
|
obj.record.len = g_htonl(obj.record.len);
|
||||||
|
|
||||||
obj.record.type = g_htonl(K12_REC_PACKET);
|
obj.record.type = g_htonl(K12_REC_PACKET);
|
||||||
obj.record.frame_len = g_htonl(phdr->caplen);
|
obj.record.frame_len = g_htonl(rec->rec_header.packet_header.caplen);
|
||||||
obj.record.input = g_htonl(pseudo_header->k12.input);
|
obj.record.input = g_htonl(pseudo_header->k12.input);
|
||||||
|
|
||||||
obj.record.ts = GUINT64_TO_BE((((guint64)phdr->ts.secs - 631152000) * 2000000) + (phdr->ts.nsecs / 1000 * 2));
|
obj.record.ts = GUINT64_TO_BE((((guint64)rec->ts.secs - 631152000) * 2000000) + (rec->ts.nsecs / 1000 * 2));
|
||||||
|
|
||||||
memcpy(obj.record.frame,pd,phdr->caplen);
|
memcpy(obj.record.frame,pd,rec->rec_header.packet_header.caplen);
|
||||||
|
|
||||||
return k12_dump_record(wdh,len,obj.buffer, err);
|
return k12_dump_record(wdh,len,obj.buffer, err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,23 +238,23 @@ DIAG_ON(sign-compare)
|
||||||
/* Fill in pkthdr */
|
/* Fill in pkthdr */
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
k12text_set_headers(struct wtap_pkthdr *phdr, k12text_state_t *state,
|
k12text_set_headers(wtap_rec *rec, k12text_state_t *state,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
||||||
|
|
||||||
phdr->ts.secs = 946681200 + (3600*state->g_h) + (60*state->g_m) + state->g_s;
|
rec->ts.secs = 946681200 + (3600*state->g_h) + (60*state->g_m) + state->g_s;
|
||||||
phdr->ts.nsecs = 1000000*state->g_ms + 1000*state->g_ns;
|
rec->ts.nsecs = 1000000*state->g_ms + 1000*state->g_ns;
|
||||||
|
|
||||||
phdr->caplen = phdr->len = state->ii;
|
rec->rec_header.packet_header.caplen = rec->rec_header.packet_header.len = state->ii;
|
||||||
|
|
||||||
phdr->pkt_encap = state->g_encap;
|
rec->rec_header.packet_header.pkt_encap = state->g_encap;
|
||||||
|
|
||||||
/* The file-encap is WTAP_ENCAP_PER_PACKET */
|
/* The file-encap is WTAP_ENCAP_PER_PACKET */
|
||||||
switch(state->g_encap) {
|
switch(state->g_encap) {
|
||||||
case WTAP_ENCAP_ETHERNET:
|
case WTAP_ENCAP_ETHERNET:
|
||||||
phdr->pseudo_header.eth.fcs_len = 0;
|
rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0;
|
||||||
break;
|
break;
|
||||||
case WTAP_ENCAP_MTP3:
|
case WTAP_ENCAP_MTP3:
|
||||||
case WTAP_ENCAP_CHDLC:
|
case WTAP_ENCAP_CHDLC:
|
||||||
|
@ -372,19 +372,19 @@ k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset)
|
||||||
*data_offset = k12text->next_frame_offset; /* file position for beginning of this frame */
|
*data_offset = k12text->next_frame_offset; /* file position for beginning of this frame */
|
||||||
k12text->next_frame_offset += state.file_bytes_read; /* file position after end of this frame */
|
k12text->next_frame_offset += state.file_bytes_read; /* file position after end of this frame */
|
||||||
|
|
||||||
if (!k12text_set_headers(&wth->phdr, &state, err, err_info)) {
|
if (!k12text_set_headers(&wth->rec, &state, err, err_info)) {
|
||||||
g_free(state.bb);
|
g_free(state.bb);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
ws_buffer_assure_space(wth->frame_buffer, wth->phdr.caplen);
|
ws_buffer_assure_space(wth->rec_data, wth->rec.rec_header.packet_header.caplen);
|
||||||
memcpy(ws_buffer_start_ptr(wth->frame_buffer), state.bb, wth->phdr.caplen);
|
memcpy(ws_buffer_start_ptr(wth->rec_data), state.bb, wth->rec.rec_header.packet_header.caplen);
|
||||||
|
|
||||||
g_free(state.bb);
|
g_free(state.bb);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
k12text_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, char **err_info)
|
k12text_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, char **err_info)
|
||||||
{
|
{
|
||||||
k12text_state_t state;
|
k12text_state_t state;
|
||||||
|
|
||||||
|
@ -410,12 +410,12 @@ k12text_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!k12text_set_headers(phdr, &state, err, err_info)) {
|
if (!k12text_set_headers(rec, &state, err, err_info)) {
|
||||||
g_free(state.bb);
|
g_free(state.bb);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
ws_buffer_assure_space(buf, phdr->caplen);
|
ws_buffer_assure_space(buf, rec->rec_header.packet_header.caplen);
|
||||||
memcpy(ws_buffer_start_ptr(buf), state.bb, phdr->caplen);
|
memcpy(ws_buffer_start_ptr(buf), state.bb, rec->rec_header.packet_header.caplen);
|
||||||
|
|
||||||
g_free(state.bb);
|
g_free(state.bb);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -471,7 +471,7 @@ static const struct { int e; const char* s; } encaps[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
k12text_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
k12text_dump(wtap_dumper *wdh, const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info _U_) {
|
const guint8 *pd, int *err, gchar **err_info _U_) {
|
||||||
#define K12BUF_SIZE 196808
|
#define K12BUF_SIZE 196808
|
||||||
char *buf;
|
char *buf;
|
||||||
|
@ -486,14 +486,14 @@ k12text_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||||
struct tm *tmp;
|
struct tm *tmp;
|
||||||
|
|
||||||
/* Don't write anything bigger than we're willing to read. */
|
/* Don't write anything bigger than we're willing to read. */
|
||||||
if (phdr->caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
|
||||||
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
str_enc = NULL;
|
str_enc = NULL;
|
||||||
for(i=0; encaps[i].s; i++) {
|
for(i=0; encaps[i].s; i++) {
|
||||||
if (phdr->pkt_encap == encaps[i].e) {
|
if (rec->rec_header.packet_header.pkt_encap == encaps[i].e) {
|
||||||
str_enc = encaps[i].s;
|
str_enc = encaps[i].s;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -509,10 +509,10 @@ k12text_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||||
buf = (char *)g_malloc(K12BUF_SIZE);
|
buf = (char *)g_malloc(K12BUF_SIZE);
|
||||||
p = buf;
|
p = buf;
|
||||||
|
|
||||||
ms = phdr->ts.nsecs / 1000000;
|
ms = rec->ts.nsecs / 1000000;
|
||||||
ns = (phdr->ts.nsecs - (1000000*ms))/1000;
|
ns = (rec->ts.nsecs - (1000000*ms))/1000;
|
||||||
|
|
||||||
tmp = gmtime(&phdr->ts.secs);
|
tmp = gmtime(&rec->ts.secs);
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
g_snprintf(p, 90, "+---------+---------------+----------+\r\nXX:XX:XX,");
|
g_snprintf(p, 90, "+---------+---------------+----------+\r\nXX:XX:XX,");
|
||||||
else
|
else
|
||||||
|
@ -525,7 +525,7 @@ k12text_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||||
p += wl;
|
p += wl;
|
||||||
left -= wl;
|
left -= wl;
|
||||||
|
|
||||||
for(i = 0; i < phdr->caplen && left > 2; i++) {
|
for(i = 0; i < rec->rec_header.packet_header.caplen && left > 2; i++) {
|
||||||
wl = g_snprintf(p, (gulong)left, "%.2x|", pd[i]);
|
wl = g_snprintf(p, (gulong)left, "%.2x|", pd[i]);
|
||||||
p += wl;
|
p += wl;
|
||||||
left -= wl;
|
left -= wl;
|
||||||
|
|
|
@ -261,7 +261,7 @@ typedef struct {
|
||||||
static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
static gboolean lanalyzer_dump_finish(wtap_dumper *wdh, int *err);
|
static gboolean lanalyzer_dump_finish(wtap_dumper *wdh, int *err);
|
||||||
|
|
||||||
wtap_open_return_val lanalyzer_open(wtap *wth, int *err, gchar **err_info)
|
wtap_open_return_val lanalyzer_open(wtap *wth, int *err, gchar **err_info)
|
||||||
|
@ -424,7 +424,7 @@ wtap_open_return_val lanalyzer_open(wtap *wth, int *err, gchar **err_info)
|
||||||
#define DESCRIPTOR_LEN 32
|
#define DESCRIPTOR_LEN 32
|
||||||
|
|
||||||
static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
|
static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
char LE_record_type[2];
|
char LE_record_type[2];
|
||||||
char LE_record_length[2];
|
char LE_record_length[2];
|
||||||
|
@ -493,8 +493,8 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
||||||
|
|
||||||
time_low = pletoh16(&descriptor[8]);
|
time_low = pletoh16(&descriptor[8]);
|
||||||
time_med = pletoh16(&descriptor[10]);
|
time_med = pletoh16(&descriptor[10]);
|
||||||
|
@ -503,8 +503,8 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
|
||||||
(((guint64)time_high) << 32);
|
(((guint64)time_high) << 32);
|
||||||
tsecs = (time_t) (t/2000000);
|
tsecs = (time_t) (t/2000000);
|
||||||
lanalyzer = (lanalyzer_t *)wth->priv;
|
lanalyzer = (lanalyzer_t *)wth->priv;
|
||||||
phdr->ts.secs = tsecs + lanalyzer->start;
|
rec->ts.secs = tsecs + lanalyzer->start;
|
||||||
phdr->ts.nsecs = ((guint32) (t - tsecs*2000000)) * 500;
|
rec->ts.nsecs = ((guint32) (t - tsecs*2000000)) * 500;
|
||||||
|
|
||||||
if (true_size - 4 >= packet_size) {
|
if (true_size - 4 >= packet_size) {
|
||||||
/*
|
/*
|
||||||
|
@ -515,14 +515,14 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
|
||||||
*/
|
*/
|
||||||
true_size -= 4;
|
true_size -= 4;
|
||||||
}
|
}
|
||||||
phdr->len = true_size;
|
rec->rec_header.packet_header.len = true_size;
|
||||||
phdr->caplen = packet_size;
|
rec->rec_header.packet_header.caplen = packet_size;
|
||||||
|
|
||||||
switch (wth->file_encap) {
|
switch (wth->file_encap) {
|
||||||
|
|
||||||
case WTAP_ENCAP_ETHERNET:
|
case WTAP_ENCAP_ETHERNET:
|
||||||
/* We assume there's no FCS in this frame. */
|
/* We assume there's no FCS in this frame. */
|
||||||
phdr->pseudo_header.eth.fcs_len = 0;
|
rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,18 +537,18 @@ static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
|
|
||||||
/* Read the record */
|
/* Read the record */
|
||||||
return lanalyzer_read_trace_record(wth, wth->fh, &wth->phdr,
|
return lanalyzer_read_trace_record(wth, wth->fh, &wth->rec,
|
||||||
wth->frame_buffer, err, err_info);
|
wth->rec_data, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Read the record */
|
/* Read the record */
|
||||||
if (!lanalyzer_read_trace_record(wth, wth->random_fh, phdr, buf,
|
if (!lanalyzer_read_trace_record(wth, wth->random_fh, rec, buf,
|
||||||
err, err_info)) {
|
err, err_info)) {
|
||||||
if (*err == 0)
|
if (*err == 0)
|
||||||
*err = WTAP_ERR_SHORT_READ;
|
*err = WTAP_ERR_SHORT_READ;
|
||||||
|
@ -622,7 +622,7 @@ static gboolean s48write(wtap_dumper *wdh, const guint64 s48, int *err)
|
||||||
* Returns TRUE on success, FALSE on failure.
|
* Returns TRUE on success, FALSE on failure.
|
||||||
*---------------------------------------------------*/
|
*---------------------------------------------------*/
|
||||||
static gboolean lanalyzer_dump(wtap_dumper *wdh,
|
static gboolean lanalyzer_dump(wtap_dumper *wdh,
|
||||||
const struct wtap_pkthdr *phdr,
|
const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info _U_)
|
const guint8 *pd, int *err, gchar **err_info _U_)
|
||||||
{
|
{
|
||||||
guint64 x;
|
guint64 x;
|
||||||
|
@ -630,10 +630,10 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh,
|
||||||
|
|
||||||
LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->priv);
|
LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->priv);
|
||||||
nstime_t td;
|
nstime_t td;
|
||||||
int thisSize = phdr->caplen + LA_PacketRecordSize + LA_RecordHeaderSize;
|
int thisSize = rec->rec_header.packet_header.caplen + LA_PacketRecordSize + LA_RecordHeaderSize;
|
||||||
|
|
||||||
/* We can only write packet records. */
|
/* We can only write packet records. */
|
||||||
if (phdr->rec_type != REC_TYPE_PACKET) {
|
if (rec->rec_type != REC_TYPE_PACKET) {
|
||||||
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -644,7 +644,7 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh,
|
||||||
return FALSE; /* and don't forget the header */
|
return FALSE; /* and don't forget the header */
|
||||||
}
|
}
|
||||||
|
|
||||||
len = phdr->caplen + (phdr->caplen ? LA_PacketRecordSize : 0);
|
len = rec->rec_header.packet_header.caplen + (rec->rec_header.packet_header.caplen ? LA_PacketRecordSize : 0);
|
||||||
|
|
||||||
/* len goes into a 16-bit field, so there's a hard limit of 65535. */
|
/* len goes into a 16-bit field, so there's a hard limit of 65535. */
|
||||||
if (len > 65535) {
|
if (len > 65535) {
|
||||||
|
@ -661,7 +661,7 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh,
|
||||||
/* collect some information for the
|
/* collect some information for the
|
||||||
* finally written header
|
* finally written header
|
||||||
*/
|
*/
|
||||||
itmp->start = phdr->ts;
|
itmp->start = rec->ts;
|
||||||
itmp->pkts = 0;
|
itmp->pkts = 0;
|
||||||
itmp->init = TRUE;
|
itmp->init = TRUE;
|
||||||
itmp->encap = wdh->encap;
|
itmp->encap = wdh->encap;
|
||||||
|
@ -672,12 +672,12 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!s16write(wdh, 0x0008, err)) /* pr.rx_errors */
|
if (!s16write(wdh, 0x0008, err)) /* pr.rx_errors */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!s16write(wdh, (guint16) (phdr->len + 4), err)) /* pr.rx_frm_len */
|
if (!s16write(wdh, (guint16) (rec->rec_header.packet_header.len + 4), err)) /* pr.rx_frm_len */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!s16write(wdh, (guint16) phdr->caplen, err)) /* pr.rx_frm_sln */
|
if (!s16write(wdh, (guint16) rec->rec_header.packet_header.caplen, err)) /* pr.rx_frm_sln */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
nstime_delta(&td, &phdr->ts, &itmp->start);
|
nstime_delta(&td, &rec->ts, &itmp->start);
|
||||||
|
|
||||||
/* Convert to half-microseconds, rounded up. */
|
/* Convert to half-microseconds, rounded up. */
|
||||||
x = (td.nsecs + 250) / 500; /* nanoseconds -> half-microseconds, rounded */
|
x = (td.nsecs + 250) / 500; /* nanoseconds -> half-microseconds, rounded */
|
||||||
|
@ -695,7 +695,7 @@ static gboolean lanalyzer_dump(wtap_dumper *wdh,
|
||||||
if (!s0write(wdh, 12, err))
|
if (!s0write(wdh, 12, err))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
|
if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
wdh->bytes_dumped += thisSize;
|
wdh->bytes_dumped += thisSize;
|
||||||
|
|
|
@ -46,10 +46,10 @@ static int libpcap_try_header(wtap *wth, FILE_T fh, int *err, gchar **err_info,
|
||||||
static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
|
static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
|
||||||
gint64 *data_offset);
|
gint64 *data_offset);
|
||||||
static gboolean libpcap_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean libpcap_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
static gboolean libpcap_read_packet(wtap *wth, FILE_T fh,
|
static gboolean libpcap_read_packet(wtap *wth, FILE_T fh,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
||||||
static gboolean libpcap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
static gboolean libpcap_dump(wtap_dumper *wdh, const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info);
|
const guint8 *pd, int *err, gchar **err_info);
|
||||||
static int libpcap_read_header(wtap *wth, FILE_T fh, int *err, gchar **err_info,
|
static int libpcap_read_header(wtap *wth, FILE_T fh, int *err, gchar **err_info,
|
||||||
struct pcaprec_ss990915_hdr *hdr);
|
struct pcaprec_ss990915_hdr *hdr);
|
||||||
|
@ -647,18 +647,18 @@ static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
|
||||||
{
|
{
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
|
|
||||||
return libpcap_read_packet(wth, wth->fh, &wth->phdr,
|
return libpcap_read_packet(wth, wth->fh, &wth->rec,
|
||||||
wth->frame_buffer, err, err_info);
|
wth->rec_data, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
libpcap_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
libpcap_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!libpcap_read_packet(wth, wth->random_fh, phdr, buf, err,
|
if (!libpcap_read_packet(wth, wth->random_fh, rec, buf, err,
|
||||||
err_info)) {
|
err_info)) {
|
||||||
if (*err == 0)
|
if (*err == 0)
|
||||||
*err = WTAP_ERR_SHORT_READ;
|
*err = WTAP_ERR_SHORT_READ;
|
||||||
|
@ -668,7 +668,7 @@ libpcap_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
libpcap_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
libpcap_read_packet(wtap *wth, FILE_T fh, wtap_rec *rec,
|
||||||
Buffer *buf, int *err, gchar **err_info)
|
Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
struct pcaprec_ss990915_hdr hdr;
|
struct pcaprec_ss990915_hdr hdr;
|
||||||
|
@ -722,7 +722,7 @@ libpcap_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr_len = pcap_process_pseudo_header(fh, wth->file_type_subtype,
|
phdr_len = pcap_process_pseudo_header(fh, wth->file_type_subtype,
|
||||||
wth->file_encap, packet_size, TRUE, phdr, err, err_info);
|
wth->file_encap, packet_size, TRUE, rec, err, err_info);
|
||||||
if (phdr_len < 0)
|
if (phdr_len < 0)
|
||||||
return FALSE; /* error */
|
return FALSE; /* error */
|
||||||
|
|
||||||
|
@ -732,27 +732,27 @@ libpcap_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
orig_size -= phdr_len;
|
orig_size -= phdr_len;
|
||||||
packet_size -= phdr_len;
|
packet_size -= phdr_len;
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
||||||
|
|
||||||
/* Update the timestamp, if not already done */
|
/* Update the timestamp, if not already done */
|
||||||
if (wth->file_encap != WTAP_ENCAP_ERF) {
|
if (wth->file_encap != WTAP_ENCAP_ERF) {
|
||||||
phdr->ts.secs = hdr.hdr.ts_sec;
|
rec->ts.secs = hdr.hdr.ts_sec;
|
||||||
if (wth->file_tsprec == WTAP_TSPREC_NSEC)
|
if (wth->file_tsprec == WTAP_TSPREC_NSEC)
|
||||||
phdr->ts.nsecs = hdr.hdr.ts_usec;
|
rec->ts.nsecs = hdr.hdr.ts_usec;
|
||||||
else
|
else
|
||||||
phdr->ts.nsecs = hdr.hdr.ts_usec * 1000;
|
rec->ts.nsecs = hdr.hdr.ts_usec * 1000;
|
||||||
} else {
|
} else {
|
||||||
int interface_id;
|
int interface_id;
|
||||||
/* Set interface ID for ERF format */
|
/* Set interface ID for ERF format */
|
||||||
phdr->presence_flags |= WTAP_HAS_INTERFACE_ID;
|
rec->presence_flags |= WTAP_HAS_INTERFACE_ID;
|
||||||
if ((interface_id = erf_populate_interface_from_header((erf_t*) libpcap->encap_priv, wth, &phdr->pseudo_header)) < 0)
|
if ((interface_id = erf_populate_interface_from_header((erf_t*) libpcap->encap_priv, wth, &rec->rec_header.packet_header.pseudo_header)) < 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
phdr->interface_id = (guint) interface_id;
|
rec->rec_header.packet_header.interface_id = (guint) interface_id;
|
||||||
}
|
}
|
||||||
phdr->caplen = packet_size;
|
rec->rec_header.packet_header.caplen = packet_size;
|
||||||
phdr->len = orig_size;
|
rec->rec_header.packet_header.len = orig_size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the packet data.
|
* Read the packet data.
|
||||||
|
@ -761,7 +761,7 @@ libpcap_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
return FALSE; /* failed */
|
return FALSE; /* failed */
|
||||||
|
|
||||||
pcap_read_post_process(wth->file_type_subtype, wth->file_encap,
|
pcap_read_post_process(wth->file_type_subtype, wth->file_encap,
|
||||||
phdr, ws_buffer_start_ptr(buf), libpcap->byte_swapped, -1);
|
rec, ws_buffer_start_ptr(buf), libpcap->byte_swapped, -1);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -921,10 +921,10 @@ gboolean libpcap_dump_open(wtap_dumper *wdh, int *err)
|
||||||
/* Write a record for a packet to a dump file.
|
/* Write a record for a packet to a dump file.
|
||||||
Returns TRUE on success, FALSE on failure. */
|
Returns TRUE on success, FALSE on failure. */
|
||||||
static gboolean libpcap_dump(wtap_dumper *wdh,
|
static gboolean libpcap_dump(wtap_dumper *wdh,
|
||||||
const struct wtap_pkthdr *phdr,
|
const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info _U_)
|
const guint8 *pd, int *err, gchar **err_info _U_)
|
||||||
{
|
{
|
||||||
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
|
const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header;
|
||||||
struct pcaprec_ss990915_hdr rec_hdr;
|
struct pcaprec_ss990915_hdr rec_hdr;
|
||||||
size_t hdr_size;
|
size_t hdr_size;
|
||||||
int phdrsize;
|
int phdrsize;
|
||||||
|
@ -932,7 +932,7 @@ static gboolean libpcap_dump(wtap_dumper *wdh,
|
||||||
phdrsize = pcap_get_phdr_size(wdh->encap, pseudo_header);
|
phdrsize = pcap_get_phdr_size(wdh->encap, pseudo_header);
|
||||||
|
|
||||||
/* We can only write packet records. */
|
/* We can only write packet records. */
|
||||||
if (phdr->rec_type != REC_TYPE_PACKET) {
|
if (rec->rec_type != REC_TYPE_PACKET) {
|
||||||
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -941,32 +941,32 @@ static gboolean libpcap_dump(wtap_dumper *wdh,
|
||||||
* Don't write anything we're not willing to read.
|
* Don't write anything we're not willing to read.
|
||||||
* (The cast is to prevent an overflow.)
|
* (The cast is to prevent an overflow.)
|
||||||
*/
|
*/
|
||||||
if ((guint64)phdr->caplen + phdrsize > wtap_max_snaplen_for_encap(wdh->encap)) {
|
if ((guint64)rec->rec_header.packet_header.caplen + phdrsize > wtap_max_snaplen_for_encap(wdh->encap)) {
|
||||||
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
rec_hdr.hdr.incl_len = phdr->caplen + phdrsize;
|
rec_hdr.hdr.incl_len = rec->rec_header.packet_header.caplen + phdrsize;
|
||||||
rec_hdr.hdr.orig_len = phdr->len + phdrsize;
|
rec_hdr.hdr.orig_len = rec->rec_header.packet_header.len + phdrsize;
|
||||||
|
|
||||||
switch (wdh->file_type_subtype) {
|
switch (wdh->file_type_subtype) {
|
||||||
|
|
||||||
case WTAP_FILE_TYPE_SUBTYPE_PCAP:
|
case WTAP_FILE_TYPE_SUBTYPE_PCAP:
|
||||||
rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs;
|
rec_hdr.hdr.ts_sec = (guint32) rec->ts.secs;
|
||||||
rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000;
|
rec_hdr.hdr.ts_usec = rec->ts.nsecs / 1000;
|
||||||
hdr_size = sizeof (struct pcaprec_hdr);
|
hdr_size = sizeof (struct pcaprec_hdr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC:
|
case WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC:
|
||||||
rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs;
|
rec_hdr.hdr.ts_sec = (guint32) rec->ts.secs;
|
||||||
rec_hdr.hdr.ts_usec = phdr->ts.nsecs;
|
rec_hdr.hdr.ts_usec = rec->ts.nsecs;
|
||||||
hdr_size = sizeof (struct pcaprec_hdr);
|
hdr_size = sizeof (struct pcaprec_hdr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990417: /* modified, but with the old magic, sigh */
|
case WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990417: /* modified, but with the old magic, sigh */
|
||||||
case WTAP_FILE_TYPE_SUBTYPE_PCAP_SS991029:
|
case WTAP_FILE_TYPE_SUBTYPE_PCAP_SS991029:
|
||||||
rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs;
|
rec_hdr.hdr.ts_sec = (guint32) rec->ts.secs;
|
||||||
rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000;
|
rec_hdr.hdr.ts_usec = rec->ts.nsecs / 1000;
|
||||||
/* XXX - what should we supply here?
|
/* XXX - what should we supply here?
|
||||||
|
|
||||||
Alexey's "libpcap" looks up the interface in the system's
|
Alexey's "libpcap" looks up the interface in the system's
|
||||||
|
@ -993,8 +993,8 @@ static gboolean libpcap_dump(wtap_dumper *wdh,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990915: /* new magic, extra crap at the end */
|
case WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990915: /* new magic, extra crap at the end */
|
||||||
rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs;
|
rec_hdr.hdr.ts_sec = (guint32) rec->ts.secs;
|
||||||
rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000;
|
rec_hdr.hdr.ts_usec = rec->ts.nsecs / 1000;
|
||||||
rec_hdr.ifindex = 0;
|
rec_hdr.ifindex = 0;
|
||||||
rec_hdr.protocol = 0;
|
rec_hdr.protocol = 0;
|
||||||
rec_hdr.pkt_type = 0;
|
rec_hdr.pkt_type = 0;
|
||||||
|
@ -1004,8 +1004,8 @@ static gboolean libpcap_dump(wtap_dumper *wdh,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WTAP_FILE_TYPE_SUBTYPE_PCAP_NOKIA: /* old magic, extra crap at the end */
|
case WTAP_FILE_TYPE_SUBTYPE_PCAP_NOKIA: /* old magic, extra crap at the end */
|
||||||
rec_hdr.hdr.ts_sec = (guint32) phdr->ts.secs;
|
rec_hdr.hdr.ts_sec = (guint32) rec->ts.secs;
|
||||||
rec_hdr.hdr.ts_usec = phdr->ts.nsecs / 1000;
|
rec_hdr.hdr.ts_usec = rec->ts.nsecs / 1000;
|
||||||
/* restore the "mysterious stuff" that came with the packet */
|
/* restore the "mysterious stuff" that came with the packet */
|
||||||
memcpy(&rec_hdr.ifindex, pseudo_header->nokia.stuff, 4);
|
memcpy(&rec_hdr.ifindex, pseudo_header->nokia.stuff, 4);
|
||||||
/* not written */
|
/* not written */
|
||||||
|
@ -1031,9 +1031,9 @@ static gboolean libpcap_dump(wtap_dumper *wdh,
|
||||||
if (!pcap_write_phdr(wdh, wdh->encap, pseudo_header, err))
|
if (!pcap_write_phdr(wdh, wdh->encap, pseudo_header, err))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
|
if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
wdh->bytes_dumped += phdr->caplen;
|
wdh->bytes_dumped += rec->rec_header.packet_header.caplen;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ gint logcat_exported_pdu_length(const guint8 *pd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh,
|
static gboolean logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
gint packet_size;
|
gint packet_size;
|
||||||
guint16 payload_length;
|
guint16 payload_length;
|
||||||
|
@ -193,14 +193,14 @@ static gboolean logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->presence_flags = WTAP_HAS_TS;
|
rec->presence_flags = WTAP_HAS_TS;
|
||||||
phdr->ts.secs = (time_t) GINT32_FROM_LE(log_entry->sec);
|
rec->ts.secs = (time_t) GINT32_FROM_LE(log_entry->sec);
|
||||||
phdr->ts.nsecs = GINT32_FROM_LE(log_entry->nsec);
|
rec->ts.nsecs = GINT32_FROM_LE(log_entry->nsec);
|
||||||
phdr->caplen = packet_size;
|
rec->rec_header.packet_header.caplen = packet_size;
|
||||||
phdr->len = packet_size;
|
rec->rec_header.packet_header.len = packet_size;
|
||||||
|
|
||||||
phdr->pseudo_header.logcat.version = logcat->version;
|
rec->rec_header.packet_header.pseudo_header.logcat.version = logcat->version;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -211,18 +211,18 @@ static gboolean logcat_read(wtap *wth, int *err, gchar **err_info,
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
|
|
||||||
return logcat_read_packet((struct logcat_phdr *) wth->priv, wth->fh,
|
return logcat_read_packet((struct logcat_phdr *) wth->priv, wth->fh,
|
||||||
&wth->phdr, wth->frame_buffer, err, err_info);
|
&wth->rec, wth->rec_data, err, err_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean logcat_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean logcat_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
wtap_rec *rec, Buffer *buf,
|
||||||
int *err, gchar **err_info)
|
int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!logcat_read_packet((struct logcat_phdr *) wth->priv, wth->random_fh,
|
if (!logcat_read_packet((struct logcat_phdr *) wth->priv, wth->random_fh,
|
||||||
phdr, buf, err, err_info)) {
|
rec, buf, err, err_info)) {
|
||||||
if (*err == 0)
|
if (*err == 0)
|
||||||
*err = WTAP_ERR_SHORT_READ;
|
*err = WTAP_ERR_SHORT_READ;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -305,18 +305,18 @@ int logcat_dump_can_write_encap(int encap)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean logcat_binary_dump(wtap_dumper *wdh,
|
static gboolean logcat_binary_dump(wtap_dumper *wdh,
|
||||||
const struct wtap_pkthdr *phdr,
|
const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info _U_)
|
const guint8 *pd, int *err, gchar **err_info _U_)
|
||||||
{
|
{
|
||||||
int caplen;
|
int caplen;
|
||||||
|
|
||||||
/* We can only write packet records. */
|
/* We can only write packet records. */
|
||||||
if (phdr->rec_type != REC_TYPE_PACKET) {
|
if (rec->rec_type != REC_TYPE_PACKET) {
|
||||||
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
caplen = phdr->caplen;
|
caplen = rec->rec_header.packet_header.caplen;
|
||||||
|
|
||||||
/* Skip EXPORTED_PDU*/
|
/* Skip EXPORTED_PDU*/
|
||||||
if (wdh->encap == WTAP_ENCAP_WIRESHARK_UPPER_PDU) {
|
if (wdh->encap == WTAP_ENCAP_WIRESHARK_UPPER_PDU) {
|
||||||
|
|
|
@ -150,7 +150,7 @@ static gchar *logcat_log(const struct dumper_t *dumper, guint32 seconds,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_time(gchar *string, struct wtap_pkthdr *phdr) {
|
static void get_time(gchar *string, wtap_rec *rec) {
|
||||||
gint ms;
|
gint ms;
|
||||||
struct tm date;
|
struct tm date;
|
||||||
time_t seconds;
|
time_t seconds;
|
||||||
|
@ -160,17 +160,17 @@ static void get_time(gchar *string, struct wtap_pkthdr *phdr) {
|
||||||
date.tm_year = 70;
|
date.tm_year = 70;
|
||||||
date.tm_mon -= 1;
|
date.tm_mon -= 1;
|
||||||
seconds = mktime(&date);
|
seconds = mktime(&date);
|
||||||
phdr->ts.secs = (time_t) seconds;
|
rec->ts.secs = (time_t) seconds;
|
||||||
phdr->ts.nsecs = (int) (ms * 1e6);
|
rec->ts.nsecs = (int) (ms * 1e6);
|
||||||
phdr->presence_flags = WTAP_HAS_TS;
|
rec->presence_flags = WTAP_HAS_TS;
|
||||||
} else {
|
} else {
|
||||||
phdr->presence_flags = 0;
|
rec->presence_flags = 0;
|
||||||
phdr->ts.secs = (time_t) 0;
|
rec->ts.secs = (time_t) 0;
|
||||||
phdr->ts.nsecs = (int) 0;
|
rec->ts.nsecs = (int) 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean logcat_text_read_packet(FILE_T fh, struct wtap_pkthdr *phdr,
|
static gboolean logcat_text_read_packet(FILE_T fh, wtap_rec *rec,
|
||||||
Buffer *buf, gint file_type) {
|
Buffer *buf, gint file_type) {
|
||||||
gint8 *pd;
|
gint8 *pd;
|
||||||
gchar *cbuff;
|
gchar *cbuff;
|
||||||
|
@ -212,27 +212,27 @@ static gboolean logcat_text_read_packet(FILE_T fh, struct wtap_pkthdr *phdr,
|
||||||
g_free(lbuff);
|
g_free(lbuff);
|
||||||
}
|
}
|
||||||
|
|
||||||
phdr->rec_type = REC_TYPE_PACKET;
|
rec->rec_type = REC_TYPE_PACKET;
|
||||||
phdr->caplen = (guint32)strlen(cbuff);
|
rec->rec_header.packet_header.caplen = (guint32)strlen(cbuff);
|
||||||
phdr->len = phdr->caplen;
|
rec->rec_header.packet_header.len = rec->rec_header.packet_header.caplen;
|
||||||
|
|
||||||
ws_buffer_assure_space(buf, phdr->caplen + 1);
|
ws_buffer_assure_space(buf, rec->rec_header.packet_header.caplen + 1);
|
||||||
pd = ws_buffer_start_ptr(buf);
|
pd = ws_buffer_start_ptr(buf);
|
||||||
if ((WTAP_FILE_TYPE_SUBTYPE_LOGCAT_TIME == file_type
|
if ((WTAP_FILE_TYPE_SUBTYPE_LOGCAT_TIME == file_type
|
||||||
|| WTAP_FILE_TYPE_SUBTYPE_LOGCAT_THREADTIME == file_type
|
|| WTAP_FILE_TYPE_SUBTYPE_LOGCAT_THREADTIME == file_type
|
||||||
|| WTAP_FILE_TYPE_SUBTYPE_LOGCAT_LONG == file_type)
|
|| WTAP_FILE_TYPE_SUBTYPE_LOGCAT_LONG == file_type)
|
||||||
&& '-' != cbuff[0]) { /* the last part filters out the -- beginning of... lines */
|
&& '-' != cbuff[0]) { /* the last part filters out the -- beginning of... lines */
|
||||||
if (WTAP_FILE_TYPE_SUBTYPE_LOGCAT_LONG == file_type) {
|
if (WTAP_FILE_TYPE_SUBTYPE_LOGCAT_LONG == file_type) {
|
||||||
get_time(cbuff+2, phdr);
|
get_time(cbuff+2, rec);
|
||||||
} else {
|
} else {
|
||||||
get_time(cbuff, phdr);
|
get_time(cbuff, rec);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
phdr->presence_flags = 0;
|
rec->presence_flags = 0;
|
||||||
phdr->ts.secs = (time_t) 0;
|
rec->ts.secs = (time_t) 0;
|
||||||
phdr->ts.nsecs = (int) 0;
|
rec->ts.nsecs = (int) 0;
|
||||||
}
|
}
|
||||||
memcpy(pd, cbuff, phdr->caplen + 1);
|
memcpy(pd, cbuff, rec->rec_header.packet_header.caplen + 1);
|
||||||
g_free(cbuff);
|
g_free(cbuff);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -241,16 +241,16 @@ static gboolean logcat_text_read(wtap *wth, int *err _U_ , gchar **err_info _U_,
|
||||||
gint64 *data_offset) {
|
gint64 *data_offset) {
|
||||||
*data_offset = file_tell(wth->fh);
|
*data_offset = file_tell(wth->fh);
|
||||||
|
|
||||||
return logcat_text_read_packet(wth->fh, &wth->phdr, wth->frame_buffer,
|
return logcat_text_read_packet(wth->fh, &wth->rec, wth->rec_data,
|
||||||
wth->file_type_subtype);
|
wth->file_type_subtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean logcat_text_seek_read(wtap *wth, gint64 seek_off,
|
static gboolean logcat_text_seek_read(wtap *wth, gint64 seek_off,
|
||||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info _U_) {
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info _U_) {
|
||||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (!logcat_text_read_packet(wth->random_fh, phdr, buf,
|
if (!logcat_text_read_packet(wth->random_fh, rec, buf,
|
||||||
wth->file_type_subtype)) {
|
wth->file_type_subtype)) {
|
||||||
if (*err == 0)
|
if (*err == 0)
|
||||||
*err = WTAP_ERR_SHORT_READ;
|
*err = WTAP_ERR_SHORT_READ;
|
||||||
|
@ -419,7 +419,7 @@ int logcat_text_long_dump_can_write_encap(int encap) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean logcat_text_dump_text(wtap_dumper *wdh,
|
static gboolean logcat_text_dump_text(wtap_dumper *wdh,
|
||||||
const struct wtap_pkthdr *phdr,
|
const wtap_rec *rec,
|
||||||
const guint8 *pd, int *err, gchar **err_info)
|
const guint8 *pd, int *err, gchar **err_info)
|
||||||
{
|
{
|
||||||
gchar *buf;
|
gchar *buf;
|
||||||
|
@ -443,7 +443,7 @@ static gboolean logcat_text_dump_text(wtap_dumper *wdh,
|
||||||
const struct dumper_t *dumper = (const struct dumper_t *) wdh->priv;
|
const struct dumper_t *dumper = (const struct dumper_t *) wdh->priv;
|
||||||
|
|
||||||
/* We can only write packet records. */
|
/* We can only write packet records. */
|
||||||
if (phdr->rec_type != REC_TYPE_PACKET) {
|
if (rec->rec_type != REC_TYPE_PACKET) {
|
||||||
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -456,7 +456,7 @@ static gboolean logcat_text_dump_text(wtap_dumper *wdh,
|
||||||
skipped_length = logcat_exported_pdu_length(pd);
|
skipped_length = logcat_exported_pdu_length(pd);
|
||||||
pd += skipped_length;
|
pd += skipped_length;
|
||||||
|
|
||||||
if (!wtap_dump_file_write(wdh, (const gchar*) pd, phdr->caplen - skipped_length, err)) {
|
if (!wtap_dump_file_write(wdh, (const gchar*) pd, rec->rec_header.packet_header.caplen - skipped_length, err)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -471,7 +471,7 @@ static gboolean logcat_text_dump_text(wtap_dumper *wdh,
|
||||||
|
|
||||||
logcat_version = buffered_detect_version(pd);
|
logcat_version = buffered_detect_version(pd);
|
||||||
} else {
|
} else {
|
||||||
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
|
const union wtap_pseudo_header *pseudo_header = &rec->rec_header.packet_header.pseudo_header;
|
||||||
|
|
||||||
logcat_version = pseudo_header->logcat.version;
|
logcat_version = pseudo_header->logcat.version;
|
||||||
}
|
}
|
||||||
|
@ -557,7 +557,7 @@ static gboolean logcat_text_dump_text(wtap_dumper *wdh,
|
||||||
case WTAP_ENCAP_LOGCAT_THREADTIME:
|
case WTAP_ENCAP_LOGCAT_THREADTIME:
|
||||||
case WTAP_ENCAP_LOGCAT_LONG:
|
case WTAP_ENCAP_LOGCAT_LONG:
|
||||||
if (dumper->type == wdh->encap) {
|
if (dumper->type == wdh->encap) {
|
||||||
if (!wtap_dump_file_write(wdh, (const gchar*) pd, phdr->caplen, err)) {
|
if (!wtap_dump_file_write(wdh, (const gchar*) pd, rec->rec_header.packet_header.caplen, err)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue