forked from osmocom/wireshark
Revert "Refactor Wiretap"
This reverts commit 1abeb277f5
.
This isn't building, and looks as if it requires significant work to fix.
Change-Id: I622b1bb243e353e874883a302ab419532b7601f2
Reviewed-on: https://code.wireshark.org/review/1568
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
a651f3e5ed
commit
a1b1c8bed5
18
capinfos.c
18
capinfos.c
|
@ -408,7 +408,7 @@ time_string(time_t timer, capture_info *cf_info, gboolean want_lf)
|
|||
g_snprintf(time_string_buf, 20, "%lu%s", (unsigned long)timer, lf);
|
||||
return time_string_buf;
|
||||
} else {
|
||||
time_string_ctime = asctime(localtime(&timer));
|
||||
time_string_ctime = ctime(&timer);
|
||||
if (time_string_ctime == NULL) {
|
||||
g_snprintf(time_string_buf, 20, "Not representable%s", lf);
|
||||
return time_string_buf;
|
||||
|
@ -800,7 +800,7 @@ print_stats_table(const gchar *filename, capture_info *cf_info)
|
|||
}
|
||||
|
||||
static int
|
||||
process_cap_file(wftap *wth, const char *filename)
|
||||
process_cap_file(wtap *wth, const char *filename)
|
||||
{
|
||||
int status = 0;
|
||||
int err;
|
||||
|
@ -868,7 +868,7 @@ process_cap_file(wftap *wth, const char *filename)
|
|||
}
|
||||
|
||||
/* Per-packet encapsulation */
|
||||
if (wftap_file_encap(wth) == WTAP_ENCAP_PER_PACKET) {
|
||||
if (wtap_file_encap(wth) == WTAP_ENCAP_PER_PACKET) {
|
||||
if ((phdr->pkt_encap > 0) && (phdr->pkt_encap < WTAP_NUM_ENCAP_TYPES)) {
|
||||
cf_info.encap_counts[phdr->pkt_encap] += 1;
|
||||
} else {
|
||||
|
@ -905,7 +905,7 @@ process_cap_file(wftap *wth, const char *filename)
|
|||
}
|
||||
|
||||
/* File size */
|
||||
size = wftap_file_size(wth, &err);
|
||||
size = wtap_file_size(wth, &err);
|
||||
if (size == -1) {
|
||||
fprintf(stderr,
|
||||
"capinfos: Can't get size of \"%s\": %s.\n",
|
||||
|
@ -917,14 +917,14 @@ process_cap_file(wftap *wth, const char *filename)
|
|||
cf_info.filesize = size;
|
||||
|
||||
/* File Type */
|
||||
cf_info.file_type = wftap_file_type_subtype(wth);
|
||||
cf_info.iscompressed = wftap_iscompressed(wth);
|
||||
cf_info.file_type = wtap_file_type_subtype(wth);
|
||||
cf_info.iscompressed = wtap_iscompressed(wth);
|
||||
|
||||
/* File Encapsulation */
|
||||
cf_info.file_encap = wftap_file_encap(wth);
|
||||
cf_info.file_encap = wtap_file_encap(wth);
|
||||
|
||||
/* Packet size limit (snaplen) */
|
||||
cf_info.snaplen = wftap_snapshot_length(wth);
|
||||
cf_info.snaplen = wtap_snapshot_length(wth);
|
||||
if (cf_info.snaplen > 0)
|
||||
cf_info.snap_set = TRUE;
|
||||
else
|
||||
|
@ -1098,7 +1098,7 @@ hash_to_str(const unsigned char *hash, size_t length, char *str) {
|
|||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
wftap *wth;
|
||||
wtap *wth;
|
||||
int err;
|
||||
gchar *err_info;
|
||||
int opt;
|
||||
|
|
|
@ -68,7 +68,7 @@ packet_counts *counts, gint wtap_linktype, const guchar *pd, guint32 caplen, uni
|
|||
|
||||
typedef struct _info_data {
|
||||
packet_counts counts; /* several packet type counters */
|
||||
struct wftap* wftap; /* current wftap file */
|
||||
struct wtap* wtap; /* current wtap file */
|
||||
capture_info ui; /* user interface data */
|
||||
} info_data_t;
|
||||
|
||||
|
@ -94,7 +94,7 @@ void capture_info_open(capture_session *cap_session)
|
|||
info_data.counts.i2c_event = 0;
|
||||
info_data.counts.i2c_data = 0;
|
||||
|
||||
info_data.wftap = NULL;
|
||||
info_data.wtap = NULL;
|
||||
info_data.ui.counts = &info_data.counts;
|
||||
|
||||
capture_info_ui_create(&info_data.ui, cap_session);
|
||||
|
@ -216,12 +216,12 @@ gboolean capture_info_new_file(const char *new_filename)
|
|||
gchar *err_msg;
|
||||
|
||||
|
||||
if(info_data.wftap != NULL) {
|
||||
wftap_close(info_data.wftap);
|
||||
if(info_data.wtap != NULL) {
|
||||
wtap_close(info_data.wtap);
|
||||
}
|
||||
|
||||
info_data.wftap = wtap_open_offline(new_filename, WTAP_TYPE_AUTO, &err, &err_info, FALSE);
|
||||
if (!info_data.wftap) {
|
||||
info_data.wtap = wtap_open_offline(new_filename, WTAP_TYPE_AUTO, &err, &err_info, FALSE);
|
||||
if (!info_data.wtap) {
|
||||
err_msg = g_strdup_printf(cf_open_error_message(err, err_info, FALSE, WTAP_FILE_TYPE_SUBTYPE_UNKNOWN),
|
||||
new_filename);
|
||||
g_warning("capture_info_new_file: %d (%s)", err, err_msg);
|
||||
|
@ -249,12 +249,12 @@ void capture_info_new_packets(int to_read)
|
|||
/*g_warning("new packets: %u", to_read);*/
|
||||
|
||||
while (to_read > 0) {
|
||||
wftap_cleareof(info_data.wftap);
|
||||
if (wtap_read(info_data.wftap, &err, &err_info, &data_offset)) {
|
||||
phdr = wtap_phdr(info_data.wftap);
|
||||
wtap_cleareof(info_data.wtap);
|
||||
if (wtap_read(info_data.wtap, &err, &err_info, &data_offset)) {
|
||||
phdr = wtap_phdr(info_data.wtap);
|
||||
pseudo_header = &phdr->pseudo_header;
|
||||
wtap_linktype = phdr->pkt_encap;
|
||||
buf = wftap_buf_ptr(info_data.wftap);
|
||||
buf = wtap_buf_ptr(info_data.wtap);
|
||||
|
||||
capture_info_packet(&info_data.counts, wtap_linktype, buf, phdr->caplen, pseudo_header);
|
||||
|
||||
|
@ -271,8 +271,8 @@ void capture_info_new_packets(int to_read)
|
|||
void capture_info_close(void)
|
||||
{
|
||||
capture_info_ui_destroy(&info_data.ui);
|
||||
if(info_data.wftap)
|
||||
wtap_close(info_data.wftap);
|
||||
if(info_data.wtap)
|
||||
wtap_close(info_data.wtap);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ failure_message(const char *msg_format _U_, va_list ap _U_)
|
|||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
wftap *wth;
|
||||
wtap *wth;
|
||||
int err;
|
||||
gchar *err_info;
|
||||
int i;
|
||||
|
@ -145,8 +145,8 @@ main(int argc, char *argv[])
|
|||
wth = wtap_open_offline(argv[i], WTAP_TYPE_AUTO, &err, &err_info, FALSE);
|
||||
|
||||
if(wth) {
|
||||
printf("%s: %s\n", argv[i], wtap_file_type_subtype_short_string(wftap_file_type_subtype(wth)));
|
||||
wftap_close(wth);
|
||||
printf("%s: %s\n", argv[i], wtap_file_type_subtype_short_string(wtap_file_type_subtype(wth)));
|
||||
wtap_close(wth);
|
||||
} else {
|
||||
if (err == WTAP_ERR_FILE_UNKNOWN_FORMAT)
|
||||
printf("%s: unknown\n", argv[i]);
|
||||
|
|
2
cfile.c
2
cfile.c
|
@ -36,7 +36,7 @@ cap_file_get_interface_name(void *data, guint32 interface_id)
|
|||
wtapng_iface_descriptions_t *idb_info;
|
||||
const wtapng_if_descr_t *wtapng_if_descr = NULL;
|
||||
|
||||
idb_info = wtap_file_get_idb_info(cf->wfth);
|
||||
idb_info = wtap_file_get_idb_info(cf->wth);
|
||||
|
||||
if (interface_id < idb_info->number_of_interfaces)
|
||||
wtapng_if_descr = &g_array_index(idb_info->interface_data, wtapng_if_descr_t, interface_id);
|
||||
|
|
10
cfile.h
10
cfile.h
|
@ -63,11 +63,6 @@ typedef struct {
|
|||
} modified_frame_data;
|
||||
#endif
|
||||
|
||||
typedef union _phdr_t {
|
||||
struct wtap_pkthdr wtap_hdr;
|
||||
/*** Placeholder for ftap_pkthdr */
|
||||
} phdr_t;
|
||||
|
||||
typedef struct _capture_file {
|
||||
epan_t *epan;
|
||||
file_state state; /* Current state of capture file */
|
||||
|
@ -92,7 +87,7 @@ typedef struct _capture_file {
|
|||
nstime_t elapsed_time; /* Elapsed time */
|
||||
gboolean has_snap; /* TRUE if maximum capture packet length is known */
|
||||
int snap; /* Maximum captured packet length */
|
||||
wftap *wfth; /* Tap session */
|
||||
wtap *wth; /* Wiretap session */
|
||||
dfilter_t *rfcode; /* Compiled read filter program */
|
||||
dfilter_t *dfcode; /* Compiled display filter program */
|
||||
gchar *dfilter; /* Display filter string */
|
||||
|
@ -109,7 +104,8 @@ typedef struct _capture_file {
|
|||
search_charset_t scs_type; /* Character set for text search */
|
||||
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 */
|
||||
phdr_t hdr; /* Packet/File header */
|
||||
/* packet data */
|
||||
struct wtap_pkthdr phdr; /* Packet header */
|
||||
Buffer buf; /* Packet data */
|
||||
/* frames */
|
||||
frame_data_sequence *frames; /* Sequence of frames, if we're keeping that information */
|
||||
|
|
32
editcap.c
32
editcap.c
|
@ -310,9 +310,9 @@ selected(int recno)
|
|||
|
||||
/* is the packet in the selected timeframe */
|
||||
static gboolean
|
||||
check_timestamp(wftap *wfth)
|
||||
check_timestamp(wtap *wth)
|
||||
{
|
||||
struct wtap_pkthdr *pkthdr = wtap_phdr(wfth);
|
||||
struct wtap_pkthdr *pkthdr = wtap_phdr(wth);
|
||||
|
||||
return (pkthdr->ts.secs >= starttime) && (pkthdr->ts.secs < stoptime);
|
||||
}
|
||||
|
@ -838,7 +838,7 @@ failure_message(const char *msg_format _U_, va_list ap _U_)
|
|||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
wftap *wth;
|
||||
wtap *wth;
|
||||
int i, j, err;
|
||||
gchar *err_info;
|
||||
int opt;
|
||||
|
@ -847,7 +847,7 @@ main(int argc, char *argv[])
|
|||
guint32 snaplen = 0; /* No limit */
|
||||
chop_t chop = {0, 0, 0, 0, 0, 0}; /* No chop */
|
||||
gboolean adjlen = FALSE;
|
||||
wftap_dumper *pdh = NULL;
|
||||
wtap_dumper *pdh = NULL;
|
||||
unsigned int count = 1;
|
||||
unsigned int duplicate_count = 0;
|
||||
gint64 data_offset;
|
||||
|
@ -1016,7 +1016,7 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
|
||||
case 'E':
|
||||
err_prob = g_strtod(optarg, &p);
|
||||
err_prob = strtod(optarg, &p);
|
||||
if (p == optarg || err_prob < 0.0 || err_prob > 1.0) {
|
||||
fprintf(stderr, "editcap: probability \"%s\" must be between 0.0 and 1.0\n",
|
||||
optarg);
|
||||
|
@ -1165,7 +1165,7 @@ main(int argc, char *argv[])
|
|||
|
||||
if (verbose) {
|
||||
fprintf(stderr, "File %s is a %s capture file.\n", argv[optind],
|
||||
wtap_file_type_subtype_string(wftap_file_type_subtype(wth)));
|
||||
wtap_file_type_subtype_string(wtap_file_type_subtype(wth)));
|
||||
}
|
||||
|
||||
shb_hdr = wtap_file_get_shb_info(wth);
|
||||
|
@ -1178,7 +1178,7 @@ main(int argc, char *argv[])
|
|||
|
||||
if ((argc - optind) >= 2) {
|
||||
if (out_frame_type == -2)
|
||||
out_frame_type = wftap_file_encap(wth);
|
||||
out_frame_type = wtap_file_encap(wth);
|
||||
|
||||
for (i = optind + 2; i < argc; i++)
|
||||
if (add_selection(argv[i]) == FALSE)
|
||||
|
@ -1196,7 +1196,7 @@ main(int argc, char *argv[])
|
|||
read_count++;
|
||||
|
||||
phdr = wtap_phdr(wth);
|
||||
buf = wftap_buf_ptr(wth);
|
||||
buf = wtap_buf_ptr(wth);
|
||||
|
||||
if (nstime_is_unset(&block_start)) { /* should only be the first packet */
|
||||
block_start.secs = phdr->ts.secs;
|
||||
|
@ -1217,7 +1217,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
|
||||
snaplen ? MIN(snaplen, wftap_snapshot_length(wth)) : wftap_snapshot_length(wth),
|
||||
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
|
||||
FALSE /* compressed */, shb_hdr, idb_inf, &err);
|
||||
|
||||
if (pdh == NULL) {
|
||||
|
@ -1234,7 +1234,7 @@ main(int argc, char *argv[])
|
|||
|| (phdr->ts.secs - block_start.secs == secs_per_block
|
||||
&& phdr->ts.nsecs >= block_start.nsecs )) { /* time for the next file */
|
||||
|
||||
if (!wftap_dump_close(pdh, &err)) {
|
||||
if (!wtap_dump_close(pdh, &err)) {
|
||||
fprintf(stderr, "editcap: Error writing to %s: %s\n",
|
||||
filename, wtap_strerror(err));
|
||||
exit(2);
|
||||
|
@ -1248,7 +1248,7 @@ main(int argc, char *argv[])
|
|||
fprintf(stderr, "Continuing writing in file %s\n", filename);
|
||||
|
||||
pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
|
||||
snaplen ? MIN(snaplen, wftap_snapshot_length(wth)) : wftap_snapshot_length(wth),
|
||||
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
|
||||
FALSE /* compressed */, shb_hdr, idb_inf, &err);
|
||||
|
||||
if (pdh == NULL) {
|
||||
|
@ -1262,7 +1262,7 @@ main(int argc, char *argv[])
|
|||
if (split_packet_count > 0) {
|
||||
/* time for the next file? */
|
||||
if (written_count > 0 && written_count % split_packet_count == 0) {
|
||||
if (!wftap_dump_close(pdh, &err)) {
|
||||
if (!wtap_dump_close(pdh, &err)) {
|
||||
fprintf(stderr, "editcap: Error writing to %s: %s\n",
|
||||
filename, wtap_strerror(err));
|
||||
exit(2);
|
||||
|
@ -1276,7 +1276,7 @@ main(int argc, char *argv[])
|
|||
fprintf(stderr, "Continuing writing in file %s\n", filename);
|
||||
|
||||
pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
|
||||
snaplen ? MIN(snaplen, wftap_snapshot_length(wth)) : wftap_snapshot_length(wth),
|
||||
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
|
||||
FALSE /* compressed */, shb_hdr, idb_inf, &err);
|
||||
if (pdh == NULL) {
|
||||
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
|
||||
|
@ -1470,7 +1470,7 @@ main(int argc, char *argv[])
|
|||
int real_data_start = 0;
|
||||
|
||||
/* Protect non-protocol data */
|
||||
if (wftap_file_type_subtype(wth) == WTAP_FILE_TYPE_SUBTYPE_CATAPULT_DCT2000)
|
||||
if (wtap_file_type_subtype(wth) == WTAP_FILE_TYPE_SUBTYPE_CATAPULT_DCT2000)
|
||||
real_data_start = find_dct2000_real_data(buf);
|
||||
|
||||
for (i = real_data_start; i < (int) phdr->caplen; i++) {
|
||||
|
@ -1581,7 +1581,7 @@ main(int argc, char *argv[])
|
|||
filename = g_strdup(argv[optind+1]);
|
||||
|
||||
pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
|
||||
snaplen ? MIN(snaplen, wftap_snapshot_length(wth)): wftap_snapshot_length(wth),
|
||||
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)): wtap_snapshot_length(wth),
|
||||
FALSE /* compressed */, shb_hdr, idb_inf, &err);
|
||||
if (pdh == NULL) {
|
||||
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
|
||||
|
@ -1593,7 +1593,7 @@ main(int argc, char *argv[])
|
|||
g_free(idb_inf);
|
||||
idb_inf = NULL;
|
||||
|
||||
if (!wftap_dump_close(pdh, &err)) {
|
||||
if (!wtap_dump_close(pdh, &err)) {
|
||||
fprintf(stderr, "editcap: Error writing to %s: %s\n", filename,
|
||||
wtap_strerror(err));
|
||||
exit(2);
|
||||
|
|
|
@ -239,19 +239,19 @@ struct _wslua_tap {
|
|||
|
||||
/* a "File" object can be different things under the hood. It can either
|
||||
be a FILE_T from wtap struct, which it is during read operations, or it
|
||||
can be a wftap_dumper struct during write operations. A wtap_dumper struct
|
||||
can be a wtap_dumper struct during write operations. A wtap_dumper struct
|
||||
has a FILE_T member, but we can't only store its pointer here because
|
||||
dump operations need the whole thing to write out with. Ugh. */
|
||||
struct _wslua_file {
|
||||
FILE_T file;
|
||||
wftap_dumper *wdh; /* will be NULL during read usage */
|
||||
wtap_dumper *wdh; /* will be NULL during read usage */
|
||||
gboolean expired;
|
||||
};
|
||||
|
||||
/* a "CaptureInfo" object can also be different things under the hood. */
|
||||
struct _wslua_captureinfo {
|
||||
wftap *wfth; /* will be NULL during write usage */
|
||||
wftap_dumper *wdh; /* will be NULL during read usage */
|
||||
wtap *wth; /* will be NULL during write usage */
|
||||
wtap_dumper *wdh; /* will be NULL during read usage */
|
||||
gboolean expired;
|
||||
};
|
||||
|
||||
|
@ -334,7 +334,7 @@ typedef struct _wslua_captureinfo* CaptureInfoConst;
|
|||
typedef struct _wslua_phdr* FrameInfo;
|
||||
typedef struct _wslua_const_phdr* FrameInfoConst;
|
||||
typedef struct _wslua_filehandler* FileHandler;
|
||||
typedef wftap_dumper* Dumper;
|
||||
typedef wtap_dumper* Dumper;
|
||||
typedef struct lua_pseudo_header* PseudoHeader;
|
||||
typedef tvbparse_t* Parser;
|
||||
typedef tvbparse_wanted_t* Rule;
|
||||
|
|
|
@ -266,7 +266,7 @@ WSLUA_METHOD Dumper_close(lua_State* L) {
|
|||
|
||||
g_hash_table_remove(dumper_encaps,*dp);
|
||||
|
||||
if (!wftap_dump_close(*dp, &err)) {
|
||||
if (!wtap_dump_close(*dp, &err)) {
|
||||
luaL_error(L,"error closing: %s",
|
||||
wtap_strerror(err));
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ WSLUA_METHOD Dumper_flush(lua_State* L) {
|
|||
|
||||
if (!d) return 0;
|
||||
|
||||
wftap_dump_flush(d);
|
||||
wtap_dump_flush(d);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ static int Dumper__gc(lua_State* L) {
|
|||
|
||||
g_hash_table_remove(dumper_encaps,*dp);
|
||||
|
||||
if (!wftap_dump_close(*dp, &err)) {
|
||||
if (!wtap_dump_close(*dp, &err)) {
|
||||
luaL_error(L,"error closing: %s",
|
||||
wtap_strerror(err));
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
#include "wslua.h"
|
||||
#include <errno.h>
|
||||
#include <wiretap/wftap-int.h>
|
||||
#include <wiretap/wtap-int.h>
|
||||
#include <wiretap/file_wrappers.h>
|
||||
#include <epan/addr_resolv.h>
|
||||
|
@ -98,7 +97,7 @@ WSLUA_CLASS_DEFINE(File,FAIL_ON_NULL_OR_EXPIRED("File"),NOP);
|
|||
|
||||
/* a "File" object can be different things under the hood. It can either
|
||||
be a FILE_T from wtap struct, which it is during read operations, or it
|
||||
can be a wftap_dumper struct during write operations. A wtap_dumper struct
|
||||
can be a wtap_dumper struct during write operations. A wtap_dumper struct
|
||||
has a FILE_T member, but we can't only store its pointer here because
|
||||
dump operations need the whole thing to write out with. Ugh. */
|
||||
static File* push_File(lua_State* L, FILE_T ft) {
|
||||
|
@ -109,7 +108,7 @@ static File* push_File(lua_State* L, FILE_T ft) {
|
|||
return pushFile(L,f);
|
||||
}
|
||||
|
||||
static File* push_Wdh(lua_State* L, wftap_dumper *wdh) {
|
||||
static File* push_Wdh(lua_State* L, wtap_dumper *wdh) {
|
||||
File f = (File) g_malloc(sizeof(struct _wslua_file));
|
||||
f->file = (FILE_T)wdh->fh;
|
||||
f->wdh = wdh;
|
||||
|
@ -358,7 +357,7 @@ WSLUA_METHOD File_seek(lua_State* L) {
|
|||
lua_pushnumber(L, (lua_Number)(file_tell(f->file)));
|
||||
}
|
||||
else {
|
||||
offset = wftap_dump_file_seek(f->wdh, offset, mode[op], &err);
|
||||
offset = wtap_dump_file_seek(f->wdh, offset, mode[op], &err);
|
||||
|
||||
if (offset < 0) {
|
||||
lua_pushnil(L); /* error */
|
||||
|
@ -366,7 +365,7 @@ WSLUA_METHOD File_seek(lua_State* L) {
|
|||
return 2;
|
||||
}
|
||||
|
||||
offset = wftap_dump_file_tell(f->wdh, &err);
|
||||
offset = wtap_dump_file_tell(f->wdh, &err);
|
||||
|
||||
if (offset < 0) {
|
||||
lua_pushnil(L); /* error */
|
||||
|
@ -435,7 +434,7 @@ WSLUA_METHOD File_write(lua_State* L) {
|
|||
for (; nargs--; arg++) {
|
||||
size_t len;
|
||||
const char *s = luaL_checklstring(L, arg, &len);
|
||||
status = wftap_dump_file_write(f->wdh, s, len, &err);
|
||||
status = wtap_dump_file_write(f->wdh, s, len, &err);
|
||||
if (!status) break;
|
||||
f->wdh->bytes_dumped += len;
|
||||
}
|
||||
|
@ -516,7 +515,7 @@ int File_register(lua_State* L) {
|
|||
/************
|
||||
* The following is for handling private data for the duration of the file
|
||||
* read_open/read/close cycle, or write_open/write/write_close cycle.
|
||||
* In other words it handles the "priv" member of wtap and wftap_dumper,
|
||||
* In other words it handles the "priv" member of wtap and wtap_dumper,
|
||||
* but for the Lua script's use. A Lua script can set a Lua table
|
||||
* to CaptureInfo/CaptureInfoConst and have it saved and retrievable this way.
|
||||
* We need to offer that, because there needs to be a way for Lua scripts
|
||||
|
@ -532,20 +531,20 @@ typedef struct _file_priv_t {
|
|||
} file_priv_t;
|
||||
|
||||
/* create and set the wtap->priv private data for the file instance */
|
||||
static void create_wth_priv(lua_State* L, wftap *wfth) {
|
||||
static void create_wth_priv(lua_State* L, wtap *wth) {
|
||||
file_priv_t *priv = (file_priv_t*)g_malloc(sizeof(file_priv_t));
|
||||
|
||||
if (wfth->priv != NULL) {
|
||||
if (wth->priv != NULL) {
|
||||
luaL_error(L, "Cannot create wtap private data because there already is private data");
|
||||
return;
|
||||
}
|
||||
priv->table_ref = LUA_NOREF;
|
||||
wfth->priv = (void*) priv;
|
||||
wth->priv = (void*) priv;
|
||||
}
|
||||
|
||||
/* gets the private data table from wtap */
|
||||
static int get_wth_priv_table_ref(lua_State* L, wftap *wfth) {
|
||||
file_priv_t *priv = (file_priv_t*) wfth->priv;
|
||||
static int get_wth_priv_table_ref(lua_State* L, wtap *wth) {
|
||||
file_priv_t *priv = (file_priv_t*) wth->priv;
|
||||
|
||||
if (!priv) {
|
||||
/* shouldn't be possible */
|
||||
|
@ -560,8 +559,8 @@ static int get_wth_priv_table_ref(lua_State* L, wftap *wfth) {
|
|||
}
|
||||
|
||||
/* sets the private data to wtap - the table is presumed on top of stack */
|
||||
static int set_wth_priv_table_ref(lua_State* L, wftap *wfth) {
|
||||
file_priv_t *priv = (file_priv_t*) wfth->priv;
|
||||
static int set_wth_priv_table_ref(lua_State* L, wtap *wth) {
|
||||
file_priv_t *priv = (file_priv_t*) wth->priv;
|
||||
|
||||
if (!priv) {
|
||||
/* shouldn't be possible */
|
||||
|
@ -592,8 +591,8 @@ static int set_wth_priv_table_ref(lua_State* L, wftap *wfth) {
|
|||
}
|
||||
|
||||
/* remove, deref, and free the wtap->priv data */
|
||||
static void remove_wth_priv(lua_State* L, wftap *wfth) {
|
||||
file_priv_t *priv = (file_priv_t*) wfth->priv;
|
||||
static void remove_wth_priv(lua_State* L, wtap *wth) {
|
||||
file_priv_t *priv = (file_priv_t*) wth->priv;
|
||||
|
||||
if (!priv) {
|
||||
/* shouldn't be possible */
|
||||
|
@ -603,29 +602,29 @@ static void remove_wth_priv(lua_State* L, wftap *wfth) {
|
|||
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, priv->table_ref);
|
||||
|
||||
g_free(wfth->priv);
|
||||
wfth->priv = NULL;
|
||||
g_free(wth->priv);
|
||||
wth->priv = NULL;
|
||||
}
|
||||
|
||||
/* create and set the wftap_dumper->priv private data for the file instance */
|
||||
static void create_wdh_priv(lua_State* L, wftap_dumper *wdh) {
|
||||
/* create and set the wtap_dumper->priv private data for the file instance */
|
||||
static void create_wdh_priv(lua_State* L, wtap_dumper *wdh) {
|
||||
file_priv_t *priv = (file_priv_t*)g_malloc(sizeof(file_priv_t));
|
||||
|
||||
if (wdh->priv != NULL) {
|
||||
luaL_error(L, "Cannot create wftap_dumper private data because there already is private data");
|
||||
luaL_error(L, "Cannot create wtap_dumper private data because there already is private data");
|
||||
return;
|
||||
}
|
||||
priv->table_ref = LUA_NOREF;
|
||||
wdh->priv = (void*) priv;
|
||||
}
|
||||
|
||||
/* get the private data from wftap_dumper */
|
||||
static int get_wdh_priv_table_ref(lua_State* L, wftap_dumper *wdh) {
|
||||
/* get the private data from wtap_dumper */
|
||||
static int get_wdh_priv_table_ref(lua_State* L, wtap_dumper *wdh) {
|
||||
file_priv_t *priv = (file_priv_t*) wdh->priv;
|
||||
|
||||
if (!priv) {
|
||||
/* shouldn't be possible */
|
||||
luaL_error(L, "Cannot get wftap_dumper private data: it is null");
|
||||
luaL_error(L, "Cannot get wtap_dumper private data: it is null");
|
||||
return LUA_NOREF;
|
||||
}
|
||||
|
||||
|
@ -636,7 +635,7 @@ static int get_wdh_priv_table_ref(lua_State* L, wftap_dumper *wdh) {
|
|||
}
|
||||
|
||||
/* sets the private data to wtap - the table is presumed on top of stack */
|
||||
static int set_wdh_priv_table_ref(lua_State* L, wftap_dumper *wdh) {
|
||||
static int set_wdh_priv_table_ref(lua_State* L, wtap_dumper *wdh) {
|
||||
file_priv_t *priv = (file_priv_t*) wdh->priv;
|
||||
|
||||
if (!priv) {
|
||||
|
@ -667,22 +666,22 @@ static int set_wdh_priv_table_ref(lua_State* L, wftap_dumper *wdh) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* remove and deref the wftap_dumper->priv data */
|
||||
static void remove_wdh_priv(lua_State* L, wftap_dumper *wdh) {
|
||||
/* remove and deref the wtap_dumper->priv data */
|
||||
static void remove_wdh_priv(lua_State* L, wtap_dumper *wdh) {
|
||||
file_priv_t *priv = (file_priv_t*) wdh->priv;
|
||||
|
||||
if (!priv) {
|
||||
/* shouldn't be possible */
|
||||
luaL_error(L, "Cannot remove wftap_dumper private data: it is null");
|
||||
luaL_error(L, "Cannot remove wtap_dumper private data: it is null");
|
||||
return;
|
||||
}
|
||||
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, priv->table_ref);
|
||||
/* we do NOT free wftap_dumper's priv member - wftap_dump_close() free's it */
|
||||
/* we do NOT free wtap_dumper's priv member - wtap_dump_close() free's it */
|
||||
}
|
||||
|
||||
|
||||
WSLUA_CLASS_DEFINE(CaptureInfo,FAIL_ON_NULL_MEMBER_OR_EXPIRED("CaptureInfo",wfth),NOP);
|
||||
WSLUA_CLASS_DEFINE(CaptureInfo,FAIL_ON_NULL_MEMBER_OR_EXPIRED("CaptureInfo",wth),NOP);
|
||||
/*
|
||||
A `CaptureInfo` object, passed into Lua as an argument by `FileHandler` callback
|
||||
function `read_open()`, `read()`, `seek_read()`, `seq_read_close()`, and `read_close()`.
|
||||
|
@ -697,17 +696,17 @@ WSLUA_CLASS_DEFINE(CaptureInfo,FAIL_ON_NULL_MEMBER_OR_EXPIRED("CaptureInfo",wfth
|
|||
@since 1.11.3
|
||||
*/
|
||||
|
||||
static CaptureInfo* push_CaptureInfo(lua_State* L, wftap *wfth, const gboolean first_time) {
|
||||
static CaptureInfo* push_CaptureInfo(lua_State* L, wtap *wth, const gboolean first_time) {
|
||||
CaptureInfo f = (CaptureInfo) g_malloc0(sizeof(struct _wslua_captureinfo));
|
||||
f->wfth = wfth;
|
||||
f->wth = wth;
|
||||
f->wdh = NULL;
|
||||
f->expired = FALSE;
|
||||
|
||||
if (first_time) {
|
||||
/* XXX: need to do this? */
|
||||
wfth->file_encap = WTAP_ENCAP_UNKNOWN;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_SEC;
|
||||
wfth->snapshot_length = 0;
|
||||
wth->file_encap = WTAP_ENCAP_UNKNOWN;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
|
||||
wth->snapshot_length = 0;
|
||||
}
|
||||
|
||||
return pushCaptureInfo(L,f);
|
||||
|
@ -717,13 +716,12 @@ WSLUA_METAMETHOD CaptureInfo__tostring(lua_State* L) {
|
|||
/* Generates a string of debug info for the CaptureInfo */
|
||||
CaptureInfo fi = toCaptureInfo(L,1);
|
||||
|
||||
if (!fi || !fi->wfth) {
|
||||
if (!fi || !fi->wth) {
|
||||
lua_pushstring(L,"CaptureInfo pointer is NULL!");
|
||||
} else {
|
||||
wftap *wfth = fi->wfth;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
wtap *wth = fi->wth;
|
||||
lua_pushfstring(L, "CaptureInfo: file_type_subtype=%d, snapshot_length=%d, pkt_encap=%d, tsprecision='%s'",
|
||||
wfth->file_type_subtype, wfth->snapshot_length, wth->phdr.pkt_encap, wfth->tsprecision);
|
||||
wth->file_type_subtype, wth->snapshot_length, wth->phdr.pkt_encap, wth->tsprecision);
|
||||
}
|
||||
|
||||
WSLUA_RETURN(1); /* String of debug information. */
|
||||
|
@ -742,24 +740,23 @@ static int CaptureInfo__gc(lua_State* L _U_) {
|
|||
See `wtap_encaps` in `init.lua` for available types. Set to `wtap_encaps.PER_PACKET` if packets can
|
||||
have different types, then later set `FrameInfo.encap` for each packet during `read()`/`seek_read()`.
|
||||
*/
|
||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfo,encap,wfth->file_encap);
|
||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(CaptureInfo,encap,wfth->file_encap,int);
|
||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfo,encap,wth->file_encap);
|
||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(CaptureInfo,encap,wth->file_encap,int);
|
||||
|
||||
/* WSLUA_ATTRIBUTE CaptureInfo_time_precision RW The precision of the packet timestamps in the file.
|
||||
|
||||
See `wtap_file_tsprec` in `init.lua` for available precisions.
|
||||
*/
|
||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfo,time_precision,wfth->tsprecision);
|
||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(CaptureInfo,time_precision,wfth->tsprecision,int);
|
||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfo,time_precision,wth->tsprecision);
|
||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(CaptureInfo,time_precision,wth->tsprecision,int);
|
||||
|
||||
/* WSLUA_ATTRIBUTE CaptureInfo_snapshot_length RW The maximum packet length that could be recorded.
|
||||
|
||||
Setting it to `0` means unknown. Wireshark cannot handle anything bigger than 65535 bytes.
|
||||
*/
|
||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfo,snapshot_length,wfth->snapshot_length);
|
||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(CaptureInfo,snapshot_length,wfth->snapshot_length,guint);
|
||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfo,snapshot_length,wth->snapshot_length);
|
||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(CaptureInfo,snapshot_length,wth->snapshot_length,guint);
|
||||
|
||||
#if FILESHARK /* XXX - FIX ME PLEASE!!!!!! */
|
||||
/* WSLUA_ATTRIBUTE CaptureInfo_comment RW A string comment for the whole capture file,
|
||||
or nil if there is no `comment`. */
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfo,comment,wth->shb_hdr.opt_comment);
|
||||
|
@ -779,7 +776,6 @@ WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(CaptureInfo,os,wth->shb_hdr.shb_os,TRUE);
|
|||
the application used to create the capture, or nil if there is no `user_app` string. */
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfo,user_app,wth->shb_hdr.shb_user_appl);
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(CaptureInfo,user_app,wth->shb_hdr.shb_user_appl,TRUE);
|
||||
#endif
|
||||
|
||||
/* WSLUA_ATTRIBUTE CaptureInfo_hosts WO Sets resolved ip-to-hostname information.
|
||||
|
||||
|
@ -795,8 +791,7 @@ WSLUA_ATTRIBUTE_NAMED_STRING_SETTER(CaptureInfo,user_app,wth->shb_hdr.shb_user_a
|
|||
*/
|
||||
static int CaptureInfo_set_hosts(lua_State* L) {
|
||||
CaptureInfo fi = checkCaptureInfo(L,1);
|
||||
wftap *wfth = fi->wfth;
|
||||
wtap *wth = (wtap*)wfth->tap_specific_data;
|
||||
wtap *wth = fi->wth;
|
||||
const char *addr = NULL;
|
||||
const char *name = NULL;
|
||||
size_t addr_len = 0;
|
||||
|
@ -919,24 +914,22 @@ static int CaptureInfo_set_hosts(lua_State* L) {
|
|||
*/
|
||||
static int CaptureInfo_get_private_table(lua_State* L) {
|
||||
CaptureInfo fi = checkCaptureInfo(L,1);
|
||||
return get_wth_priv_table_ref(L, fi->wfth);
|
||||
return get_wth_priv_table_ref(L, fi->wth);
|
||||
}
|
||||
|
||||
static int CaptureInfo_set_private_table(lua_State* L) {
|
||||
CaptureInfo fi = checkCaptureInfo(L,1);
|
||||
return set_wth_priv_table_ref(L, fi->wfth);
|
||||
return set_wth_priv_table_ref(L, fi->wth);
|
||||
}
|
||||
|
||||
WSLUA_ATTRIBUTES CaptureInfo_attributes[] = {
|
||||
WSLUA_ATTRIBUTE_RWREG(CaptureInfo,encap),
|
||||
WSLUA_ATTRIBUTE_RWREG(CaptureInfo,time_precision),
|
||||
WSLUA_ATTRIBUTE_RWREG(CaptureInfo,snapshot_length),
|
||||
#if FILESHARK /* XXX - FIX ME PLEASE!!!!!! */
|
||||
WSLUA_ATTRIBUTE_RWREG(CaptureInfo,comment),
|
||||
WSLUA_ATTRIBUTE_RWREG(CaptureInfo,hardware),
|
||||
WSLUA_ATTRIBUTE_RWREG(CaptureInfo,os),
|
||||
WSLUA_ATTRIBUTE_RWREG(CaptureInfo,user_app),
|
||||
#endif
|
||||
WSLUA_ATTRIBUTE_WOREG(CaptureInfo,hosts),
|
||||
WSLUA_ATTRIBUTE_RWREG(CaptureInfo,private_table),
|
||||
{ NULL, NULL, NULL }
|
||||
|
@ -970,9 +963,9 @@ WSLUA_CLASS_DEFINE(CaptureInfoConst,FAIL_ON_NULL_MEMBER_OR_EXPIRED("CaptureInfoC
|
|||
@since 1.11.3
|
||||
*/
|
||||
|
||||
static CaptureInfoConst* push_CaptureInfoConst(lua_State* L, wftap_dumper *wdh) {
|
||||
static CaptureInfoConst* push_CaptureInfoConst(lua_State* L, wtap_dumper *wdh) {
|
||||
CaptureInfoConst f = (CaptureInfoConst) g_malloc0(sizeof(struct _wslua_captureinfo));
|
||||
f->wfth = NULL;
|
||||
f->wth = NULL;
|
||||
f->wdh = wdh;
|
||||
f->expired = FALSE;
|
||||
return pushCaptureInfoConst(L,f);
|
||||
|
@ -985,7 +978,7 @@ WSLUA_METAMETHOD CaptureInfoConst__tostring(lua_State* L) {
|
|||
if (!fi || !fi->wdh) {
|
||||
lua_pushstring(L,"CaptureInfoConst pointer is NULL!");
|
||||
} else {
|
||||
wftap_dumper *wdh = fi->wdh;
|
||||
wtap_dumper *wdh = fi->wdh;
|
||||
lua_pushfstring(L, "CaptureInfoConst: file_type_subtype=%d, snaplen=%d, encap=%d, compressed=%d, tsprecision='%s'",
|
||||
wdh->file_type_subtype, wdh->snaplen, wdh->encap, wdh->compressed, wdh->tsprecision);
|
||||
}
|
||||
|
@ -1007,7 +1000,6 @@ WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfoConst,snapshot_length,wdh->snaple
|
|||
have different types, in which case each Frame identifies its type, in `FrameInfo.packet_encap`. */
|
||||
WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfoConst,encap,wdh->encap);
|
||||
|
||||
#if FILESHARK /* XXX - FIX ME PLEASE!!!!!! */
|
||||
/* WSLUA_ATTRIBUTE CaptureInfoConst_comment RW A comment for the whole capture file, if the
|
||||
`wtap_presence_flags.COMMENTS` was set in the presence flags; nil if there is no comment. */
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfoConst,comment,wth->shb_hdr.opt_comment);
|
||||
|
@ -1023,7 +1015,6 @@ WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfoConst,os,wth->shb_hdr.shb_os);
|
|||
/* WSLUA_ATTRIBUTE CaptureInfoConst_user_app RO A string containing the name of
|
||||
the application used to create the capture, or nil if there is no user_app string. */
|
||||
WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfoConst,user_app,wth->shb_hdr.shb_user_appl);
|
||||
#endif
|
||||
|
||||
/* WSLUA_ATTRIBUTE CaptureInfoConst_hosts RO A ip-to-hostname Lua table of two key-ed names: `ipv4_addresses` and `ipv6_addresses`.
|
||||
The value of each of these names are themselves array tables, of key-ed tables, such that the inner table has a key
|
||||
|
@ -1037,8 +1028,7 @@ WSLUA_ATTRIBUTE_NAMED_STRING_GETTER(CaptureInfoConst,user_app,wth->shb_hdr.shb_u
|
|||
be nil. */
|
||||
static int CaptureInfoConst_get_hosts(lua_State* L) {
|
||||
CaptureInfoConst fi = checkCaptureInfoConst(L,1);
|
||||
wftap_dumper *wfdh = fi->wdh;
|
||||
wtap_dumper *wdh = (wtap_dumper*)wfdh->tap_specific_data;
|
||||
wtap_dumper *wdh = fi->wdh;
|
||||
|
||||
/* create the main table to return */
|
||||
lua_newtable(L);
|
||||
|
@ -1136,12 +1126,10 @@ WSLUA_ATTRIBUTES CaptureInfoConst_attributes[] = {
|
|||
WSLUA_ATTRIBUTE_ROREG(CaptureInfoConst,encap),
|
||||
WSLUA_ATTRIBUTE_ROREG(CaptureInfoConst,type),
|
||||
WSLUA_ATTRIBUTE_ROREG(CaptureInfoConst,snapshot_length),
|
||||
#if FILESHARK /* XXX - FIX ME PLEASE!!!!!! */
|
||||
WSLUA_ATTRIBUTE_ROREG(CaptureInfoConst,comment),
|
||||
WSLUA_ATTRIBUTE_ROREG(CaptureInfoConst,hardware),
|
||||
WSLUA_ATTRIBUTE_ROREG(CaptureInfoConst,os),
|
||||
WSLUA_ATTRIBUTE_ROREG(CaptureInfoConst,user_app),
|
||||
#endif
|
||||
WSLUA_ATTRIBUTE_ROREG(CaptureInfoConst,hosts),
|
||||
WSLUA_ATTRIBUTE_RWREG(CaptureInfoConst,private_table),
|
||||
{ NULL, NULL, NULL }
|
||||
|
@ -1430,7 +1418,7 @@ WSLUA_METHOD FrameInfoConst_write_data(lua_State* L) {
|
|||
if (len > fi->phdr->caplen)
|
||||
len = fi->phdr->caplen;
|
||||
|
||||
if (!wftap_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_pushfstring(L, "FrameInfoConst write_data() error: %s", g_strerror(err));
|
||||
lua_pushnumber(L, err);
|
||||
|
@ -1630,16 +1618,16 @@ static gboolean in_routine = FALSE;
|
|||
|
||||
/* some declarations */
|
||||
static gboolean
|
||||
wslua_filehandler_read(wftap *wfth, int *err, gchar **err_info,
|
||||
wslua_filehandler_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean
|
||||
wslua_filehandler_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf,
|
||||
wslua_filehandler_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
||||
int *err, gchar **err_info);
|
||||
static void
|
||||
wslua_filehandler_close(wftap *wfth);
|
||||
wslua_filehandler_close(wtap *wth);
|
||||
static void
|
||||
wslua_filehandler_sequential_close(wftap *wfth);
|
||||
wslua_filehandler_sequential_close(wtap *wth);
|
||||
|
||||
|
||||
/* This is our one-and-only open routine for file handling. When called by
|
||||
|
@ -1654,9 +1642,9 @@ wslua_filehandler_sequential_close(wftap *wfth);
|
|||
* field in the "struct wtap" to the type of the file.
|
||||
*/
|
||||
static int
|
||||
wslua_filehandler_open(wftap *wfth, int *err _U_, gchar **err_info)
|
||||
wslua_filehandler_open(wtap *wth, int *err _U_, gchar **err_info)
|
||||
{
|
||||
FileHandler fh = (FileHandler)(wfth->wslua_data);
|
||||
FileHandler fh = (FileHandler)(wth->wslua_data);
|
||||
int retval = 0;
|
||||
lua_State* L = NULL;
|
||||
File *fp = NULL;
|
||||
|
@ -1664,10 +1652,10 @@ wslua_filehandler_open(wftap *wfth, int *err _U_, gchar **err_info)
|
|||
|
||||
INIT_FILEHANDLER_ROUTINE(read_open,0);
|
||||
|
||||
create_wth_priv(L, wfth);
|
||||
create_wth_priv(L, wth);
|
||||
|
||||
fp = push_File(L, wfth->fh);
|
||||
fc = push_CaptureInfo(L, wfth, TRUE);
|
||||
fp = push_File(L, wth->fh);
|
||||
fc = push_CaptureInfo(L, wth, TRUE);
|
||||
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
switch ( lua_pcall(L,2,1,1) ) {
|
||||
|
@ -1686,32 +1674,32 @@ wslua_filehandler_open(wftap *wfth, int *err _U_, gchar **err_info)
|
|||
/* this is our file type - set the routines and settings into wtap */
|
||||
|
||||
if (fh->read_ref != LUA_NOREF) {
|
||||
wfth->subtype_read = wslua_filehandler_read;
|
||||
wth->subtype_read = wslua_filehandler_read;
|
||||
}
|
||||
else return 0;
|
||||
|
||||
if (fh->seek_read_ref != LUA_NOREF) {
|
||||
wfth->subtype_seek_read = wslua_filehandler_seek_read;
|
||||
wth->subtype_seek_read = wslua_filehandler_seek_read;
|
||||
}
|
||||
else return 0;
|
||||
|
||||
/* it's ok to not have a close routine */
|
||||
if (fh->read_close_ref != LUA_NOREF)
|
||||
wfth->subtype_close = wslua_filehandler_close;
|
||||
wth->subtype_close = wslua_filehandler_close;
|
||||
else
|
||||
wfth->subtype_close = NULL;
|
||||
wth->subtype_close = NULL;
|
||||
|
||||
/* it's ok to not have a sequential close routine */
|
||||
if (fh->seq_read_close_ref != LUA_NOREF)
|
||||
wfth->subtype_sequential_close = wslua_filehandler_sequential_close;
|
||||
wth->subtype_sequential_close = wslua_filehandler_sequential_close;
|
||||
else
|
||||
wfth->subtype_sequential_close = NULL;
|
||||
wth->subtype_sequential_close = NULL;
|
||||
|
||||
wfth->file_type_subtype = fh->file_type;
|
||||
wth->file_type_subtype = fh->file_type;
|
||||
}
|
||||
else {
|
||||
/* not our file type */
|
||||
remove_wth_priv(L, wfth);
|
||||
remove_wth_priv(L, wth);
|
||||
}
|
||||
|
||||
lua_settop(L,0);
|
||||
|
@ -1725,16 +1713,15 @@ wslua_filehandler_open(wftap *wfth, int *err _U_, gchar **err_info)
|
|||
* This will be the seek_off parameter when this frame is re-read.
|
||||
*/
|
||||
static gboolean
|
||||
wslua_filehandler_read(wftap *wfth, int *err, gchar **err_info,
|
||||
wslua_filehandler_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
FileHandler fh = (FileHandler)(wfth->wslua_data);
|
||||
FileHandler fh = (FileHandler)(wth->wslua_data);
|
||||
int retval = -1;
|
||||
lua_State* L = NULL;
|
||||
File *fp = NULL;
|
||||
CaptureInfo *fc = NULL;
|
||||
FrameInfo *fi = NULL;
|
||||
wtap *wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
INIT_FILEHANDLER_ROUTINE(read,FALSE);
|
||||
|
||||
|
@ -1743,9 +1730,9 @@ wslua_filehandler_read(wftap *wfth, int *err, gchar **err_info,
|
|||
|
||||
wth->phdr.opt_comment = NULL;
|
||||
|
||||
fp = push_File(L, wfth->fh);
|
||||
fc = push_CaptureInfo(L, wfth, FALSE);
|
||||
fi = push_FrameInfo(L, &wth->phdr, wfth->frame_buffer);
|
||||
fp = push_File(L, wth->fh);
|
||||
fc = push_CaptureInfo(L, wth, FALSE);
|
||||
fi = push_FrameInfo(L, &wth->phdr, wth->frame_buffer);
|
||||
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
switch ( lua_pcall(L,3,1,1) ) {
|
||||
|
@ -1774,17 +1761,16 @@ wslua_filehandler_read(wftap *wfth, int *err, gchar **err_info,
|
|||
* success, FALSE on error.
|
||||
*/
|
||||
static gboolean
|
||||
wslua_filehandler_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf,
|
||||
wslua_filehandler_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
||||
int *err, gchar **err_info)
|
||||
{
|
||||
FileHandler fh = (FileHandler)(wfth->wslua_data);
|
||||
FileHandler fh = (FileHandler)(wth->wslua_data);
|
||||
int retval = -1;
|
||||
lua_State* L = NULL;
|
||||
File *fp = NULL;
|
||||
CaptureInfo *fc = NULL;
|
||||
FrameInfo *fi = NULL;
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr*)header;
|
||||
|
||||
INIT_FILEHANDLER_ROUTINE(seek_read,FALSE);
|
||||
|
||||
|
@ -1792,8 +1778,8 @@ wslua_filehandler_seek_read(wftap *wfth, gint64 seek_off,
|
|||
*err = errno = 0;
|
||||
phdr->opt_comment = NULL;
|
||||
|
||||
fp = push_File(L, wfth->random_fh);
|
||||
fc = push_CaptureInfo(L, wfth, FALSE);
|
||||
fp = push_File(L, wth->random_fh);
|
||||
fc = push_CaptureInfo(L, wth, FALSE);
|
||||
fi = push_FrameInfo(L, phdr, buf);
|
||||
lua_pushnumber(L, (lua_Number)seek_off);
|
||||
|
||||
|
@ -1826,17 +1812,17 @@ wslua_filehandler_seek_read(wftap *wfth, gint64 seek_off,
|
|||
/* Classic wtap close function, called by wtap core.
|
||||
*/
|
||||
static void
|
||||
wslua_filehandler_close(wftap *wfth)
|
||||
wslua_filehandler_close(wtap *wth)
|
||||
{
|
||||
FileHandler fh = (FileHandler)(wfth->wslua_data);
|
||||
FileHandler fh = (FileHandler)(wth->wslua_data);
|
||||
lua_State* L = NULL;
|
||||
File *fp = NULL;
|
||||
CaptureInfo *fc = NULL;
|
||||
|
||||
INIT_FILEHANDLER_ROUTINE(read_close,);
|
||||
|
||||
fp = push_File(L, wfth->fh);
|
||||
fc = push_CaptureInfo(L, wfth, FALSE);
|
||||
fp = push_File(L, wth->fh);
|
||||
fc = push_CaptureInfo(L, wth, FALSE);
|
||||
|
||||
switch ( lua_pcall(L,2,1,1) ) {
|
||||
case 0:
|
||||
|
@ -1846,7 +1832,7 @@ wslua_filehandler_close(wftap *wfth)
|
|||
|
||||
END_FILEHANDLER_ROUTINE();
|
||||
|
||||
remove_wth_priv(L, wfth);
|
||||
remove_wth_priv(L, wth);
|
||||
|
||||
(*fp)->expired = TRUE;
|
||||
(*fc)->expired = TRUE;
|
||||
|
@ -1858,17 +1844,17 @@ wslua_filehandler_close(wftap *wfth)
|
|||
/* Classic wtap sequential close function, called by wtap core.
|
||||
*/
|
||||
static void
|
||||
wslua_filehandler_sequential_close(wftap *wfth)
|
||||
wslua_filehandler_sequential_close(wtap *wth)
|
||||
{
|
||||
FileHandler fh = (FileHandler)(wfth->wslua_data);
|
||||
FileHandler fh = (FileHandler)(wth->wslua_data);
|
||||
lua_State* L = NULL;
|
||||
File *fp = NULL;
|
||||
CaptureInfo *fc = NULL;
|
||||
|
||||
INIT_FILEHANDLER_ROUTINE(seq_read_close,);
|
||||
|
||||
fp = push_File(L, wfth->fh);
|
||||
fc = push_CaptureInfo(L, wfth, FALSE);
|
||||
fp = push_File(L, wth->fh);
|
||||
fc = push_CaptureInfo(L, wth, FALSE);
|
||||
|
||||
switch ( lua_pcall(L,2,1,1) ) {
|
||||
case 0:
|
||||
|
@ -1932,17 +1918,17 @@ wslua_filehandler_can_write_encap(int encap, void* data)
|
|||
|
||||
/* some declarations */
|
||||
static gboolean
|
||||
wslua_filehandler_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
wslua_filehandler_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err);
|
||||
static gboolean
|
||||
wslua_filehandler_dump_close(wftap_dumper *wdh, int *err);
|
||||
wslua_filehandler_dump_close(wtap_dumper *wdh, int *err);
|
||||
|
||||
|
||||
/* The classic wtap dump_open function.
|
||||
* This returns 1 (TRUE) on success.
|
||||
*/
|
||||
static int
|
||||
wslua_filehandler_dump_open(wftap_dumper *wdh, int *err)
|
||||
wslua_filehandler_dump_open(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
FileHandler fh = (FileHandler)(wdh->wslua_data);
|
||||
int retval = 0;
|
||||
|
@ -2001,7 +1987,7 @@ wslua_filehandler_dump_open(wftap_dumper *wdh, int *err)
|
|||
* else FALSE.
|
||||
*/
|
||||
static gboolean
|
||||
wslua_filehandler_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
wslua_filehandler_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err)
|
||||
{
|
||||
FileHandler fh = (FileHandler)(wdh->wslua_data);
|
||||
|
@ -2041,7 +2027,7 @@ wslua_filehandler_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
* else FALSE.
|
||||
*/
|
||||
static gboolean
|
||||
wslua_filehandler_dump_close(wftap_dumper *wdh, int *err)
|
||||
wslua_filehandler_dump_close(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
FileHandler fh = (FileHandler)(wdh->wslua_data);
|
||||
int retval = -1;
|
||||
|
|
158
file.c
158
file.c
|
@ -237,7 +237,7 @@ cf_timestamp_auto_precision(capture_file *cf)
|
|||
prec == TS_PREC_AUTO_USEC ||
|
||||
prec == TS_PREC_AUTO_NSEC)
|
||||
{
|
||||
switch(wftap_file_tsprecision(cf->wfth)) {
|
||||
switch(wtap_file_tsprecision(cf->wth)) {
|
||||
case(WTAP_FILE_TSPREC_SEC):
|
||||
timestamp_set_precision(TS_PREC_AUTO_SEC);
|
||||
break;
|
||||
|
@ -336,7 +336,7 @@ ws_epan_new(capture_file *cf)
|
|||
cf_status_t
|
||||
cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_tempfile, int *err)
|
||||
{
|
||||
wftap *wth;
|
||||
wtap *wth;
|
||||
gchar *err_info;
|
||||
|
||||
wth = wtap_open_offline(fname, type, err, &err_info, TRUE);
|
||||
|
@ -359,7 +359,7 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
|
|||
/* We're about to start reading the file. */
|
||||
cf->state = FILE_READ_IN_PROGRESS;
|
||||
|
||||
cf->wfth = wth;
|
||||
cf->wth = wth;
|
||||
cf->f_datalen = 0;
|
||||
|
||||
/* Set the file name because we need it to set the follow stream filter.
|
||||
|
@ -375,7 +375,7 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
|
|||
|
||||
cf->computed_elapsed = 0;
|
||||
|
||||
cf->cd_t = wftap_file_type_subtype(cf->wfth);
|
||||
cf->cd_t = wtap_file_type_subtype(cf->wth);
|
||||
cf->open_type = type;
|
||||
cf->linktypes = g_array_sized_new(FALSE, FALSE, (guint) sizeof(int), 1);
|
||||
cf->count = 0;
|
||||
|
@ -386,7 +386,7 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
|
|||
cf->ref_time_count = 0;
|
||||
cf->drops_known = FALSE;
|
||||
cf->drops = 0;
|
||||
cf->snap = wftap_snapshot_length(cf->wfth);
|
||||
cf->snap = wtap_snapshot_length(cf->wth);
|
||||
if (cf->snap == 0) {
|
||||
/* Snapshot length not known. */
|
||||
cf->has_snap = FALSE;
|
||||
|
@ -414,8 +414,8 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
|
|||
ber_set_filename(cf->filename);
|
||||
}
|
||||
|
||||
wtap_set_cb_new_ipv4(cf->wfth, add_ipv4_name);
|
||||
wtap_set_cb_new_ipv6(cf->wfth, (wtap_new_ipv6_callback_t) add_ipv6_name);
|
||||
wtap_set_cb_new_ipv4(cf->wth, add_ipv4_name);
|
||||
wtap_set_cb_new_ipv6(cf->wth, (wtap_new_ipv6_callback_t) add_ipv6_name);
|
||||
|
||||
return CF_OK;
|
||||
|
||||
|
@ -456,9 +456,9 @@ cf_reset_state(capture_file *cf)
|
|||
/* Die if we're in the middle of reading a file. */
|
||||
g_assert(cf->state != FILE_READ_IN_PROGRESS);
|
||||
|
||||
if (cf->wfth) {
|
||||
wtap_close(cf->wfth);
|
||||
cf->wfth = NULL;
|
||||
if (cf->wth) {
|
||||
wtap_close(cf->wth);
|
||||
cf->wth = NULL;
|
||||
}
|
||||
/* We have no file open... */
|
||||
if (cf->filename != NULL) {
|
||||
|
@ -549,12 +549,12 @@ calc_progbar_val(capture_file *cf, gint64 size, gint64 file_pos, gchar *status_s
|
|||
/* The file probably grew while we were reading it.
|
||||
* Update file size, and try again.
|
||||
*/
|
||||
size = wftap_file_size(cf->wfth, NULL);
|
||||
size = wtap_file_size(cf->wth, NULL);
|
||||
|
||||
if (size >= 0)
|
||||
progbar_val = (gfloat) file_pos / (gfloat) size;
|
||||
|
||||
/* If it's still > 1, either "wftap_file_size()" failed (in which
|
||||
/* If it's still > 1, either "wtap_file_size()" failed (in which
|
||||
* case there's not much we can do about it), or the file
|
||||
* *shrank* (in which case there's not much we can do about
|
||||
* it); just clip the progress value at 1.0.
|
||||
|
@ -608,7 +608,7 @@ cf_read(capture_file *cf, gboolean reloading)
|
|||
|
||||
/* Record whether the file is compressed.
|
||||
XXX - do we know this at open time? */
|
||||
cf->iscompressed = wftap_iscompressed(cf->wfth);
|
||||
cf->iscompressed = wtap_iscompressed(cf->wth);
|
||||
|
||||
/* The packet list window will be empty until the file is completly loaded */
|
||||
packet_list_freeze();
|
||||
|
@ -638,7 +638,7 @@ cf_read(capture_file *cf, gboolean reloading)
|
|||
cinfo = (tap_flags & TL_REQUIRES_COLUMNS) ? &cf->cinfo : NULL;
|
||||
|
||||
/* Find the size of the file. */
|
||||
size = wftap_file_size(cf->wfth, NULL);
|
||||
size = wtap_file_size(cf->wth, NULL);
|
||||
|
||||
/* Update the progress bar when it gets to this value. */
|
||||
progbar_nextstep = 0;
|
||||
|
@ -651,10 +651,10 @@ cf_read(capture_file *cf, gboolean reloading)
|
|||
}else
|
||||
progbar_quantum = 0;
|
||||
|
||||
while ((wtap_read(cf->wfth, &err, &err_info, &data_offset))) {
|
||||
while ((wtap_read(cf->wth, &err, &err_info, &data_offset))) {
|
||||
if (size >= 0) {
|
||||
count++;
|
||||
file_pos = wftap_read_so_far(cf->wfth);
|
||||
file_pos = wtap_read_so_far(cf->wth);
|
||||
|
||||
/* Create the progress bar if necessary.
|
||||
* Check whether it should be created or not every MIN_NUMBER_OF_PACKET
|
||||
|
@ -736,7 +736,7 @@ cf_read(capture_file *cf, gboolean reloading)
|
|||
cf->state = FILE_READ_DONE;
|
||||
|
||||
/* Close the sequential I/O side, to free up memory it requires. */
|
||||
wftap_sequential_close(cf->wfth);
|
||||
wtap_sequential_close(cf->wth);
|
||||
|
||||
/* Allow the protocol dissectors to free up memory that they
|
||||
* don't need after the sequential run-through of the packets. */
|
||||
|
@ -749,7 +749,7 @@ cf_read(capture_file *cf, gboolean reloading)
|
|||
we've looked at all the packets, as we don't know until then whether
|
||||
there's more than one type (and thus whether it's
|
||||
WTAP_ENCAP_PER_PACKET). */
|
||||
cf->lnk_t = wftap_file_encap(cf->wfth);
|
||||
cf->lnk_t = wtap_file_encap(cf->wth);
|
||||
|
||||
cf->current_frame = frame_data_sequence_find(cf->frames, cf->first_displayed);
|
||||
cf->current_row = 0;
|
||||
|
@ -874,8 +874,8 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
|
|||
cinfo = (tap_flags & TL_REQUIRES_COLUMNS) ? &cf->cinfo : NULL;
|
||||
|
||||
while (to_read != 0) {
|
||||
wftap_cleareof(cf->wfth);
|
||||
if (!wtap_read(cf->wfth, err, &err_info, &data_offset)) {
|
||||
wtap_cleareof(cf->wth);
|
||||
if (!wtap_read(cf->wth, err, &err_info, &data_offset)) {
|
||||
break;
|
||||
}
|
||||
if (cf->state == FILE_READ_ABORTED) {
|
||||
|
@ -907,7 +907,7 @@ cf_continue_tail(capture_file *cf, volatile int to_read, int *err)
|
|||
|
||||
/* Update the file encapsulation; it might have changed based on the
|
||||
packets we've read. */
|
||||
cf->lnk_t = wftap_file_encap(cf->wfth);
|
||||
cf->lnk_t = wtap_file_encap(cf->wth);
|
||||
|
||||
/* Cleanup and release all dfilter resources */
|
||||
if (dfcode != NULL) {
|
||||
|
@ -981,7 +981,7 @@ cf_finish_tail(capture_file *cf, int *err)
|
|||
create_proto_tree =
|
||||
(dfcode != NULL || have_filtering_tap_listeners() || (tap_flags & TL_REQUIRES_PROTO_TREE));
|
||||
|
||||
if (cf->wfth == NULL) {
|
||||
if (cf->wth == NULL) {
|
||||
cf_close(cf);
|
||||
return CF_READ_ERROR;
|
||||
}
|
||||
|
@ -992,7 +992,7 @@ cf_finish_tail(capture_file *cf, int *err)
|
|||
|
||||
epan_dissect_init(&edt, cf->epan, create_proto_tree, FALSE);
|
||||
|
||||
while ((wtap_read(cf->wfth, err, &err_info, &data_offset))) {
|
||||
while ((wtap_read(cf->wth, err, &err_info, &data_offset))) {
|
||||
if (cf->state == FILE_READ_ABORTED) {
|
||||
/* Well, the user decided to abort the read. Break out of the
|
||||
loop, and let the code below (which is called even if there
|
||||
|
@ -1030,7 +1030,7 @@ cf_finish_tail(capture_file *cf, int *err)
|
|||
|
||||
/* We're done reading sequentially through the file; close the
|
||||
sequential I/O side, to free up memory it requires. */
|
||||
wftap_sequential_close(cf->wfth);
|
||||
wtap_sequential_close(cf->wth);
|
||||
|
||||
/* Allow the protocol dissectors to free up memory that they
|
||||
* don't need after the sequential run-through of the packets. */
|
||||
|
@ -1038,7 +1038,7 @@ cf_finish_tail(capture_file *cf, int *err)
|
|||
|
||||
/* Update the file encapsulation; it might have changed based on the
|
||||
packets we've read. */
|
||||
cf->lnk_t = wftap_file_encap(cf->wfth);
|
||||
cf->lnk_t = wtap_file_encap(cf->wth);
|
||||
|
||||
/* Update the details in the file-set dialog, as the capture file
|
||||
* has likely grown since we first stat-ed it */
|
||||
|
@ -1235,8 +1235,8 @@ static int
|
|||
read_packet(capture_file *cf, dfilter_t *dfcode, epan_dissect_t *edt,
|
||||
column_info *cinfo, gint64 offset)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = wtap_phdr(cf->wfth);
|
||||
const guint8 *buf = wftap_buf_ptr(cf->wfth);
|
||||
struct wtap_pkthdr *phdr = wtap_phdr(cf->wth);
|
||||
const guint8 *buf = wtap_buf_ptr(cf->wth);
|
||||
frame_data fdlocal;
|
||||
guint32 framenum;
|
||||
frame_data *fdata;
|
||||
|
@ -1294,7 +1294,7 @@ cf_merge_files(char **out_filenamep, int in_file_count,
|
|||
char *out_filename;
|
||||
char *tmpname;
|
||||
int out_fd;
|
||||
wftap_dumper *pdh;
|
||||
wtap_dumper *pdh;
|
||||
int open_err, read_err, write_err, close_err;
|
||||
gchar *err_info;
|
||||
int err_fileno;
|
||||
|
@ -1361,7 +1361,7 @@ cf_merge_files(char **out_filenamep, int in_file_count,
|
|||
|
||||
fake_interface_ids = TRUE;
|
||||
/* Create SHB info */
|
||||
shb_hdr = wtap_file_get_shb_info(in_files[0].wfth);
|
||||
shb_hdr = wtap_file_get_shb_info(in_files[0].wth);
|
||||
comment_gstr = g_string_new("");
|
||||
g_string_append_printf(comment_gstr, "%s \n",shb_hdr->opt_comment);
|
||||
g_string_append_printf(comment_gstr, "File created by merging: \n");
|
||||
|
@ -1388,7 +1388,7 @@ cf_merge_files(char **out_filenamep, int in_file_count,
|
|||
idb_inf->interface_data = g_array_new(FALSE, FALSE, sizeof(wtapng_if_descr_t));
|
||||
|
||||
for (i = 0; i < in_file_count; i++) {
|
||||
idb_inf_merge_file = wtap_file_get_idb_info(in_files[i].wfth);
|
||||
idb_inf_merge_file = wtap_file_get_idb_info(in_files[i].wth);
|
||||
/* read the interface data from the in file to our combined interfca data */
|
||||
file_int_data = &g_array_index (idb_inf_merge_file->interface_data, wtapng_if_descr_t, 0);
|
||||
int_data.wtap_encap = file_int_data->wtap_encap;
|
||||
|
@ -1504,7 +1504,7 @@ cf_merge_files(char **out_filenamep, int in_file_count,
|
|||
/* Get the sum of the seek positions in all of the files. */
|
||||
file_pos = 0;
|
||||
for (i = 0; i < in_file_count; i++)
|
||||
file_pos += wftap_read_so_far(in_files[i].wfth);
|
||||
file_pos += wtap_read_so_far(in_files[i].wth);
|
||||
progbar_val = (gfloat) file_pos / (gfloat) f_len;
|
||||
if (progbar_val > 1.0f) {
|
||||
/* Some file probably grew while we were reading it.
|
||||
|
@ -1534,12 +1534,12 @@ cf_merge_files(char **out_filenamep, int in_file_count,
|
|||
if (fake_interface_ids) {
|
||||
struct wtap_pkthdr *phdr;
|
||||
|
||||
phdr = wtap_phdr(in_file->wfth);
|
||||
phdr = wtap_phdr(in_file->wth);
|
||||
phdr->interface_id = in_file->interface_id;
|
||||
phdr->presence_flags = phdr->presence_flags | WTAP_HAS_INTERFACE_ID;
|
||||
}
|
||||
if (!wtap_dump(pdh, wtap_phdr(in_file->wfth),
|
||||
wftap_buf_ptr(in_file->wfth), &write_err)) {
|
||||
if (!wtap_dump(pdh, wtap_phdr(in_file->wth),
|
||||
wtap_buf_ptr(in_file->wth), &write_err)) {
|
||||
got_write_error = TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -1551,7 +1551,7 @@ cf_merge_files(char **out_filenamep, int in_file_count,
|
|||
|
||||
merge_close_in_files(in_file_count, in_files);
|
||||
if (!got_write_error) {
|
||||
if (!wftap_dump_close(pdh, &write_err))
|
||||
if (!wtap_dump_close(pdh, &write_err))
|
||||
got_write_error = TRUE;
|
||||
} else {
|
||||
/*
|
||||
|
@ -1560,7 +1560,7 @@ cf_merge_files(char **out_filenamep, int in_file_count,
|
|||
*
|
||||
* Don't overwrite the earlier write error.
|
||||
*/
|
||||
(void)wftap_dump_close(pdh, &close_err);
|
||||
(void)wtap_dump_close(pdh, &close_err);
|
||||
}
|
||||
|
||||
if (got_read_error) {
|
||||
|
@ -1778,7 +1778,7 @@ cf_read_frame_r(capture_file *cf, const frame_data *fdata,
|
|||
}
|
||||
#endif
|
||||
|
||||
if (!wftap_seek_read(cf->wfth, fdata->file_off, phdr, buf, &err, &err_info)) {
|
||||
if (!wtap_seek_read(cf->wth, fdata->file_off, phdr, buf, &err, &err_info)) {
|
||||
display_basename = g_filename_display_basename(cf->filename);
|
||||
switch (err) {
|
||||
|
||||
|
@ -1809,7 +1809,7 @@ cf_read_frame_r(capture_file *cf, const frame_data *fdata,
|
|||
gboolean
|
||||
cf_read_frame(capture_file *cf, frame_data *fdata)
|
||||
{
|
||||
return cf_read_frame_r(cf, fdata, &cf->hdr.wtap_hdr, &cf->buf);
|
||||
return cf_read_frame_r(cf, fdata, &cf->phdr, &cf->buf);
|
||||
}
|
||||
|
||||
/* Rescan the list of packets, reconstructing the CList.
|
||||
|
@ -2017,7 +2017,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
|
|||
}
|
||||
|
||||
add_packet_to_packet_list(fdata, cf, &edt, dfcode,
|
||||
cinfo, &cf->hdr.wtap_hdr,
|
||||
cinfo, &cf->phdr,
|
||||
buffer_start_ptr(&cf->buf),
|
||||
add_to_packet_list);
|
||||
|
||||
|
@ -3117,7 +3117,7 @@ match_protocol_tree(capture_file *cf, frame_data *fdata, void *criterion)
|
|||
/* Construct the protocol tree, including the displayed text */
|
||||
epan_dissect_init(&edt, cf->epan, TRUE, TRUE);
|
||||
/* We don't need the column information */
|
||||
epan_dissect_run(&edt, &cf->hdr.wtap_hdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata, NULL);
|
||||
epan_dissect_run(&edt, &cf->phdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata, NULL);
|
||||
|
||||
/* Iterate through all the nodes, seeing if they have text that matches. */
|
||||
mdata->cf = cf;
|
||||
|
@ -3221,7 +3221,7 @@ match_summary_line(capture_file *cf, frame_data *fdata, void *criterion)
|
|||
/* Don't bother constructing the protocol tree */
|
||||
epan_dissect_init(&edt, cf->epan, FALSE, FALSE);
|
||||
/* Get the column information */
|
||||
epan_dissect_run(&edt, &cf->hdr.wtap_hdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata,
|
||||
epan_dissect_run(&edt, &cf->phdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata,
|
||||
&cf->cinfo);
|
||||
|
||||
/* Find the Info column */
|
||||
|
@ -3529,7 +3529,7 @@ match_dfilter(capture_file *cf, frame_data *fdata, void *criterion)
|
|||
|
||||
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
||||
epan_dissect_prime_dfilter(&edt, sfcode);
|
||||
epan_dissect_run(&edt, &cf->hdr.wtap_hdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata, NULL);
|
||||
epan_dissect_run(&edt, &cf->phdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata, NULL);
|
||||
result = dfilter_apply_edt(sfcode, &edt) ? MR_MATCHED : MR_NOTMATCHED;
|
||||
epan_dissect_cleanup(&edt);
|
||||
return result;
|
||||
|
@ -3862,7 +3862,7 @@ cf_select_packet(capture_file *cf, int row)
|
|||
cf->edt = epan_dissect_new(cf->epan, TRUE, TRUE);
|
||||
|
||||
tap_build_interesting(cf->edt);
|
||||
epan_dissect_run(cf->edt, &cf->hdr.wtap_hdr, frame_tvbuff_new_buffer(cf->current_frame, &cf->buf),
|
||||
epan_dissect_run(cf->edt, &cf->phdr, frame_tvbuff_new_buffer(cf->current_frame, &cf->buf),
|
||||
cf->current_frame, NULL);
|
||||
|
||||
dfilter_macro_build_ftv_cache(cf->edt->tree);
|
||||
|
@ -3968,7 +3968,7 @@ cf_read_shb_comment(capture_file *cf)
|
|||
const gchar *temp_str;
|
||||
|
||||
/* Get info from SHB */
|
||||
shb_inf = wtap_file_get_shb_info(cf->wfth);
|
||||
shb_inf = wtap_file_get_shb_info(cf->wth);
|
||||
if (shb_inf == NULL)
|
||||
return NULL;
|
||||
temp_str = shb_inf->opt_comment;
|
||||
|
@ -3984,7 +3984,7 @@ cf_update_capture_comment(capture_file *cf, gchar *comment)
|
|||
wtapng_section_t *shb_inf;
|
||||
|
||||
/* Get info from SHB */
|
||||
shb_inf = wtap_file_get_shb_info(cf->wfth);
|
||||
shb_inf = wtap_file_get_shb_info(cf->wth);
|
||||
|
||||
/* See if the comment has changed or not */
|
||||
if (shb_inf && shb_inf->opt_comment) {
|
||||
|
@ -3998,7 +3998,7 @@ cf_update_capture_comment(capture_file *cf, gchar *comment)
|
|||
g_free(shb_inf);
|
||||
|
||||
/* The comment has changed, let's update it */
|
||||
wtap_write_shb_comment(cf->wfth, comment);
|
||||
wtap_write_shb_comment(cf->wth, comment);
|
||||
/* Mark the file as having unsaved changes */
|
||||
cf->unsaved_changes = TRUE;
|
||||
}
|
||||
|
@ -4097,9 +4097,9 @@ cf_comment_types(capture_file *cf)
|
|||
}
|
||||
|
||||
typedef struct {
|
||||
wftap_dumper *pdh;
|
||||
const char *fname;
|
||||
int file_type;
|
||||
wtap_dumper *pdh;
|
||||
const char *fname;
|
||||
int file_type;
|
||||
} save_callback_args_t;
|
||||
|
||||
/*
|
||||
|
@ -4341,7 +4341,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
|
|||
#endif
|
||||
|
||||
/* Close the old handle. */
|
||||
wtap_close(cf->wfth);
|
||||
wtap_close(cf->wth);
|
||||
|
||||
/* Open the new file. */
|
||||
/* XXX: this will go through all open_routines for a matching one. But right
|
||||
|
@ -4349,8 +4349,8 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
|
|||
format than the original, and the user is not given a choice of which
|
||||
reader to use (only which format to save it in), so doing this makes
|
||||
sense for now. */
|
||||
cf->wfth = wtap_open_offline(fname, WTAP_TYPE_AUTO, err, &err_info, TRUE);
|
||||
if (cf->wfth == NULL) {
|
||||
cf->wth = wtap_open_offline(fname, WTAP_TYPE_AUTO, err, &err_info, TRUE);
|
||||
if (cf->wth == NULL) {
|
||||
cf_open_failure_alert_box(fname, *err, err_info, FALSE, 0);
|
||||
return CF_READ_ERROR;
|
||||
}
|
||||
|
@ -4370,10 +4370,10 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
|
|||
/* No user changes yet. */
|
||||
cf->unsaved_changes = FALSE;
|
||||
|
||||
cf->cd_t = wftap_file_type_subtype(cf->wfth);
|
||||
cf->cd_t = wtap_file_type_subtype(cf->wth);
|
||||
cf->linktypes = g_array_sized_new(FALSE, FALSE, (guint) sizeof(int), 1);
|
||||
|
||||
cf->snap = wftap_snapshot_length(cf->wfth);
|
||||
cf->snap = wtap_snapshot_length(cf->wth);
|
||||
if (cf->snap == 0) {
|
||||
/* Snapshot length not known. */
|
||||
cf->has_snap = FALSE;
|
||||
|
@ -4387,10 +4387,10 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
|
|||
|
||||
/* Record whether the file is compressed.
|
||||
XXX - do we know this at open time? */
|
||||
cf->iscompressed = wftap_iscompressed(cf->wfth);
|
||||
cf->iscompressed = wtap_iscompressed(cf->wth);
|
||||
|
||||
/* Find the size of the file. */
|
||||
size = wftap_file_size(cf->wfth, NULL);
|
||||
size = wtap_file_size(cf->wth, NULL);
|
||||
|
||||
/* Update the progress bar when it gets to this value. */
|
||||
progbar_nextstep = 0;
|
||||
|
@ -4407,14 +4407,14 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
|
|||
g_get_current_time(&start_time);
|
||||
|
||||
framenum = 0;
|
||||
phdr = wtap_phdr(cf->wfth);
|
||||
while ((wtap_read(cf->wfth, err, &err_info, &data_offset))) {
|
||||
phdr = wtap_phdr(cf->wth);
|
||||
while ((wtap_read(cf->wth, err, &err_info, &data_offset))) {
|
||||
framenum++;
|
||||
fdata = frame_data_sequence_find(cf->frames, framenum);
|
||||
fdata->file_off = data_offset;
|
||||
if (size >= 0) {
|
||||
count++;
|
||||
file_pos = wftap_read_so_far(cf->wfth);
|
||||
file_pos = wtap_read_so_far(cf->wth);
|
||||
|
||||
/* Create the progress bar if necessary.
|
||||
* Check whether it should be created or not every MIN_NUMBER_OF_PACKET
|
||||
|
@ -4475,7 +4475,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
|
|||
cf->state = FILE_READ_DONE;
|
||||
|
||||
/* Close the sequential I/O side, to free up memory it requires. */
|
||||
wftap_sequential_close(cf->wfth);
|
||||
wtap_sequential_close(cf->wth);
|
||||
|
||||
/* compute the time it took to load the file */
|
||||
compute_elapsed(cf, &start_time);
|
||||
|
@ -4484,7 +4484,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
|
|||
we've looked at all the packets, as we don't know until then whether
|
||||
there's more than one type (and thus whether it's
|
||||
WTAP_ENCAP_PER_PACKET). */
|
||||
cf->lnk_t = wftap_file_encap(cf->wfth);
|
||||
cf->lnk_t = wtap_file_encap(cf->wth);
|
||||
|
||||
cf_callback_invoke(cf_cb_file_rescan_finished, cf);
|
||||
|
||||
|
@ -4557,7 +4557,7 @@ cf_save_packets(capture_file *cf, const char *fname, guint save_format,
|
|||
{
|
||||
gchar *err_info;
|
||||
gchar *fname_new = NULL;
|
||||
wftap_dumper *pdh;
|
||||
wtap_dumper *pdh;
|
||||
frame_data *fdata;
|
||||
addrinfo_lists_t *addr_lists;
|
||||
guint framenum;
|
||||
|
@ -4662,8 +4662,8 @@ cf_save_packets(capture_file *cf, const char *fname, guint save_format,
|
|||
wtapng_iface_descriptions_t *idb_inf = NULL;
|
||||
int encap;
|
||||
|
||||
shb_hdr = wtap_file_get_shb_info(cf->wfth);
|
||||
idb_inf = wtap_file_get_idb_info(cf->wfth);
|
||||
shb_hdr = wtap_file_get_shb_info(cf->wth);
|
||||
idb_inf = wtap_file_get_idb_info(cf->wth);
|
||||
|
||||
/* Determine what file encapsulation type we should use. */
|
||||
encap = wtap_dump_file_encap_type(cf->linktypes);
|
||||
|
@ -4710,7 +4710,7 @@ cf_save_packets(capture_file *cf, const char *fname, guint save_format,
|
|||
If we're writing to a temporary file, remove it.
|
||||
XXX - should we do so even if we're not writing to a
|
||||
temporary file? */
|
||||
wftap_dump_close(pdh, &err);
|
||||
wtap_dump_close(pdh, &err);
|
||||
if (fname_new != NULL)
|
||||
ws_unlink(fname_new);
|
||||
cf_callback_invoke(cf_cb_file_save_stopped, NULL);
|
||||
|
@ -4721,11 +4721,11 @@ cf_save_packets(capture_file *cf, const char *fname, guint save_format,
|
|||
If we're writing to a temporary file, remove it. */
|
||||
if (fname_new != NULL)
|
||||
ws_unlink(fname_new);
|
||||
wftap_dump_close(pdh, &err);
|
||||
wtap_dump_close(pdh, &err);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!wftap_dump_close(pdh, &err)) {
|
||||
if (!wtap_dump_close(pdh, &err)) {
|
||||
cf_close_failure_alert_box(fname, err);
|
||||
goto fail;
|
||||
}
|
||||
|
@ -4739,7 +4739,7 @@ cf_save_packets(capture_file *cf, const char *fname, guint save_format,
|
|||
on Windows. However, on Windows, we first need to close whatever
|
||||
file descriptors we have open for fname. */
|
||||
#ifdef _WIN32
|
||||
wftap_fdclose(cf->wfth);
|
||||
wtap_fdclose(cf->wth);
|
||||
#endif
|
||||
/* Now do the rename. */
|
||||
if (ws_rename(fname_new, fname) == -1) {
|
||||
|
@ -4749,7 +4749,7 @@ cf_save_packets(capture_file *cf, const char *fname, guint save_format,
|
|||
/* Attempt to reopen the random file descriptor using the
|
||||
current file's filename. (At this point, the sequential
|
||||
file descriptor is closed.) */
|
||||
if (!wftap_fdreopen(cf->wfth, cf->filename, &err)) {
|
||||
if (!wtap_fdreopen(cf->wth, cf->filename, &err)) {
|
||||
/* Oh, well, we're screwed. */
|
||||
display_basename = g_filename_display_basename(cf->filename);
|
||||
simple_error_message_box(
|
||||
|
@ -4782,13 +4782,13 @@ cf_save_packets(capture_file *cf, const char *fname, guint save_format,
|
|||
/* We just copied the file, s all the information other than
|
||||
the wtap structure, the filename, and the "is temporary"
|
||||
status applies to the new file; just update that. */
|
||||
wtap_close(cf->wfth);
|
||||
wtap_close(cf->wth);
|
||||
/* Although we're just "copying" and then opening the copy, it will
|
||||
try all open_routine readers to open the copy, so we need to
|
||||
reset the cfile's open_type. */
|
||||
cf->open_type = WTAP_TYPE_AUTO;
|
||||
cf->wfth = wtap_open_offline(fname, WTAP_TYPE_AUTO, &err, &err_info, TRUE);
|
||||
if (cf->wfth == NULL) {
|
||||
cf->wth = wtap_open_offline(fname, WTAP_TYPE_AUTO, &err, &err_info, TRUE);
|
||||
if (cf->wth == NULL) {
|
||||
cf_open_failure_alert_box(fname, err, err_info, FALSE, 0);
|
||||
cf_close(cf);
|
||||
} else {
|
||||
|
@ -4834,7 +4834,7 @@ cf_save_packets(capture_file *cf, const char *fname, guint save_format,
|
|||
/* If we were told to discard the comments, do so. */
|
||||
if (discard_comments) {
|
||||
/* Remove SHB comment, if any. */
|
||||
wtap_write_shb_comment(cf->wfth, NULL);
|
||||
wtap_write_shb_comment(cf->wth, NULL);
|
||||
|
||||
/* remove all user comments */
|
||||
for (framenum = 1; framenum <= cf->count; framenum++) {
|
||||
|
@ -4876,7 +4876,7 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
|
|||
{
|
||||
gchar *fname_new = NULL;
|
||||
int err;
|
||||
wftap_dumper *pdh;
|
||||
wtap_dumper *pdh;
|
||||
save_callback_args_t callback_args;
|
||||
wtapng_section_t *shb_hdr;
|
||||
wtapng_iface_descriptions_t *idb_inf;
|
||||
|
@ -4891,8 +4891,8 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
|
|||
written, don't special-case the operation - read each packet
|
||||
and then write it out if it's one of the specified ones. */
|
||||
|
||||
shb_hdr = wtap_file_get_shb_info(cf->wfth);
|
||||
idb_inf = wtap_file_get_idb_info(cf->wfth);
|
||||
shb_hdr = wtap_file_get_shb_info(cf->wth);
|
||||
idb_inf = wtap_file_get_idb_info(cf->wth);
|
||||
|
||||
/* Determine what file encapsulation type we should use. */
|
||||
encap = wtap_dump_file_encap_type(cf->linktypes);
|
||||
|
@ -4945,7 +4945,7 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
|
|||
If we're writing to a temporary file, remove it.
|
||||
XXX - should we do so even if we're not writing to a
|
||||
temporary file? */
|
||||
wftap_dump_close(pdh, &err);
|
||||
wtap_dump_close(pdh, &err);
|
||||
if (fname_new != NULL)
|
||||
ws_unlink(fname_new);
|
||||
cf_callback_invoke(cf_cb_file_export_specified_packets_stopped, NULL);
|
||||
|
@ -4957,11 +4957,11 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
|
|||
If we're writing to a temporary file, remove it. */
|
||||
if (fname_new != NULL)
|
||||
ws_unlink(fname_new);
|
||||
wftap_dump_close(pdh, &err);
|
||||
wtap_dump_close(pdh, &err);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!wftap_dump_close(pdh, &err)) {
|
||||
if (!wtap_dump_close(pdh, &err)) {
|
||||
cf_close_failure_alert_box(fname, err);
|
||||
goto fail;
|
||||
}
|
||||
|
|
|
@ -538,7 +538,7 @@ ftap* ftap_open_offline(const char *filename, int *err, char **err_info,
|
|||
if (use_stdin) {
|
||||
/*
|
||||
* We dup FD 0, so that we don't have to worry about
|
||||
* a file_close of wfth->fh closing the standard
|
||||
* a file_close of wth->fh closing the standard
|
||||
* input of the process.
|
||||
*/
|
||||
fd = ws_dup(0);
|
||||
|
|
|
@ -378,7 +378,7 @@ ftap_read(ftap *fth, int *err, gchar **err_info, gint64 *data_offset)
|
|||
* *is* FTAP_ENCAP_PER_RECORD, the caller needs to set it
|
||||
* anyway.
|
||||
*/
|
||||
wth->phdr.pkt_encap = wfth->file_encap;
|
||||
wth->phdr.pkt_encap = wth->file_encap;
|
||||
#endif
|
||||
|
||||
if (!fth->subtype_read(fth, err, err_info, data_offset)) {
|
||||
|
@ -460,6 +460,12 @@ wtap_phdr(wtap *wth)
|
|||
{
|
||||
return &wth->phdr;
|
||||
}
|
||||
|
||||
guint8 *
|
||||
wtap_buf_ptr(wtap *wth)
|
||||
{
|
||||
return buffer_start_ptr(wth->frame_buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
gboolean
|
||||
|
|
|
@ -31,14 +31,14 @@
|
|||
#include "frame_tvbuff.h"
|
||||
#include "globals.h"
|
||||
|
||||
#include "wftap-int.h" /* for ->random_fh */
|
||||
#include "wtap-int.h" /* for ->random_fh */
|
||||
|
||||
struct tvb_frame {
|
||||
struct tvbuff tvb;
|
||||
|
||||
Buffer *buf; /* Packet data */
|
||||
|
||||
wftap *wth; /**< Wiretap session */
|
||||
wtap *wth; /**< Wiretap session */
|
||||
gint64 file_off; /**< File offset */
|
||||
|
||||
guint offset;
|
||||
|
@ -51,13 +51,13 @@ frame_read(struct tvb_frame *frame_tvb, struct wtap_pkthdr *phdr, Buffer *buf)
|
|||
gchar *err_info;
|
||||
|
||||
/* sanity check, capture file was closed? */
|
||||
if (cfile.wfth != frame_tvb->wth)
|
||||
if (cfile.wth != frame_tvb->wth)
|
||||
return FALSE;
|
||||
|
||||
/* XXX, what if phdr->caplen isn't equal to
|
||||
* frame_tvb->tvb.length + frame_tvb->offset?
|
||||
*/
|
||||
if (!wftap_seek_read(frame_tvb->wth, frame_tvb->file_off, phdr, buf, &err, &err_info)) {
|
||||
if (!wtap_seek_read(frame_tvb->wth, frame_tvb->file_off, phdr, buf, &err, &err_info)) {
|
||||
switch (err) {
|
||||
case WTAP_ERR_UNSUPPORTED_ENCAP:
|
||||
case WTAP_ERR_BAD_FILE:
|
||||
|
@ -212,12 +212,12 @@ frame_tvbuff_new(const frame_data *fd, const guint8 *buf)
|
|||
frame_tvb = (struct tvb_frame *) tvb;
|
||||
|
||||
/* XXX, wtap_can_seek() */
|
||||
if (cfile.wfth && cfile.wfth->random_fh
|
||||
if (cfile.wth && cfile.wth->random_fh
|
||||
#ifdef WANT_PACKET_EDITOR
|
||||
&& fd->file_off != -1 /* generic clone for modified packets */
|
||||
#endif
|
||||
) {
|
||||
frame_tvb->wth = cfile.wfth;
|
||||
frame_tvb->wth = cfile.wth;
|
||||
frame_tvb->file_off = fd->file_off;
|
||||
frame_tvb->offset = 0;
|
||||
} else
|
||||
|
@ -317,12 +317,12 @@ file_tvbuff_new(const frame_data *fd, const guint8 *buf)
|
|||
frame_tvb = (struct tvb_frame *) tvb;
|
||||
|
||||
/* XXX, wtap_can_seek() */
|
||||
if (cfile.wfth && cfile.wfth->random_fh
|
||||
if (cfile.wth && cfile.wth->random_fh
|
||||
#ifdef WANT_PACKET_EDITOR
|
||||
&& fd->file_off != -1 /* generic clone for modified packets */
|
||||
#endif
|
||||
) {
|
||||
frame_tvb->wth = cfile.wfth;
|
||||
frame_tvb->wth = cfile.wth;
|
||||
frame_tvb->file_off = fd->file_off;
|
||||
frame_tvb->offset = 0;
|
||||
} else
|
||||
|
|
16
mergecap.c
16
mergecap.c
|
@ -225,7 +225,7 @@ main(int argc, char *argv[])
|
|||
merge_in_file_t *in_files = NULL, *in_file;
|
||||
int i;
|
||||
struct wtap_pkthdr *phdr, snap_phdr;
|
||||
wftap_dumper *pdh;
|
||||
wtap_dumper *pdh;
|
||||
int open_err, read_err = 0, write_err, close_err;
|
||||
gchar *err_info;
|
||||
int err_fileno;
|
||||
|
@ -333,7 +333,7 @@ main(int argc, char *argv[])
|
|||
if (verbose) {
|
||||
for (i = 0; i < in_file_count; i++)
|
||||
fprintf(stderr, "mergecap: %s is type %s.\n", argv[optind + i],
|
||||
wtap_file_type_subtype_string(wftap_file_type_subtype(in_files[i].wfth)));
|
||||
wtap_file_type_subtype_string(wtap_file_type_subtype(in_files[i].wth)));
|
||||
}
|
||||
|
||||
if (snaplen == 0) {
|
||||
|
@ -357,9 +357,9 @@ main(int argc, char *argv[])
|
|||
*/
|
||||
int first_frame_type, this_frame_type;
|
||||
|
||||
first_frame_type = wftap_file_encap(in_files[0].wfth);
|
||||
first_frame_type = wtap_file_encap(in_files[0].wth);
|
||||
for (i = 1; i < in_file_count; i++) {
|
||||
this_frame_type = wftap_file_encap(in_files[i].wfth);
|
||||
this_frame_type = wtap_file_encap(in_files[i].wth);
|
||||
if (first_frame_type != this_frame_type) {
|
||||
fprintf(stderr, "mergecap: multiple frame encapsulation types detected\n");
|
||||
fprintf(stderr, " defaulting to WTAP_ENCAP_PER_PACKET\n");
|
||||
|
@ -452,14 +452,14 @@ main(int argc, char *argv[])
|
|||
|
||||
/* We simply write it, perhaps after truncating it; we could do other
|
||||
* things, like modify it. */
|
||||
phdr = wtap_phdr(in_file->wfth);
|
||||
phdr = wtap_phdr(in_file->wth);
|
||||
if (snaplen != 0 && phdr->caplen > snaplen) {
|
||||
snap_phdr = *phdr;
|
||||
snap_phdr.caplen = snaplen;
|
||||
phdr = &snap_phdr;
|
||||
}
|
||||
|
||||
if (!wtap_dump(pdh, phdr, wftap_buf_ptr(in_file->wfth), &write_err)) {
|
||||
if (!wtap_dump(pdh, phdr, wtap_buf_ptr(in_file->wth), &write_err)) {
|
||||
got_write_error = TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -467,7 +467,7 @@ main(int argc, char *argv[])
|
|||
|
||||
merge_close_in_files(in_file_count, in_files);
|
||||
if (!got_write_error) {
|
||||
if (!wftap_dump_close(pdh, &write_err))
|
||||
if (!wtap_dump_close(pdh, &write_err))
|
||||
got_write_error = TRUE;
|
||||
} else {
|
||||
/*
|
||||
|
@ -476,7 +476,7 @@ main(int argc, char *argv[])
|
|||
*
|
||||
* Don't overwrite the earlier write error.
|
||||
*/
|
||||
(void)wftap_dump_close(pdh, &close_err);
|
||||
(void)wtap_dump_close(pdh, &close_err);
|
||||
}
|
||||
|
||||
if (got_read_error) {
|
||||
|
|
|
@ -494,7 +494,7 @@ int
|
|||
main(int argc, char **argv)
|
||||
{
|
||||
|
||||
wftap_dumper *dump;
|
||||
wtap_dumper *dump;
|
||||
struct wtap_pkthdr pkthdr;
|
||||
union wtap_pseudo_header *ps_header = &pkthdr.pseudo_header;
|
||||
int i, j, len_this_pkt, len_random, err;
|
||||
|
@ -620,7 +620,7 @@ main(int argc, char **argv)
|
|||
wtap_dump(dump, &pkthdr, &buffer[0], &err);
|
||||
}
|
||||
|
||||
wftap_dump_close(dump, &err);
|
||||
wtap_dump_close(dump, &err);
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -867,7 +867,7 @@ main(int argc, char *argv[])
|
|||
/* Set timestamp precision; there should arguably be a command-line
|
||||
option to let the user set this. */
|
||||
#if 0
|
||||
switch(wftap_file_tsprecision(cfile.wth)) {
|
||||
switch(wtap_file_tsprecision(cfile.wth)) {
|
||||
case(WTAP_FILE_TSPREC_SEC):
|
||||
timestamp_set_precision(TS_PREC_AUTO_SEC);
|
||||
break;
|
||||
|
@ -1665,7 +1665,7 @@ raw_cf_open(capture_file *cf, const char *fname)
|
|||
epan_free(cf->epan);
|
||||
cf->epan = raw_epan_new(cf);
|
||||
|
||||
cf->wfth = NULL;
|
||||
cf->wth = NULL;
|
||||
cf->f_datalen = 0; /* not used, but set it anyway */
|
||||
|
||||
/* Set the file name because we need it to set the follow stream filter.
|
||||
|
|
16
reordercap.c
16
reordercap.c
|
@ -89,7 +89,7 @@ typedef struct FrameRecord_t {
|
|||
|
||||
|
||||
static void
|
||||
frame_write(FrameRecord_t *frame, wftap *wth, wftap_dumper *pdh, Buffer *buf,
|
||||
frame_write(FrameRecord_t *frame, wtap *wth, wtap_dumper *pdh, Buffer *buf,
|
||||
const char *infile)
|
||||
{
|
||||
int err;
|
||||
|
@ -103,7 +103,7 @@ frame_write(FrameRecord_t *frame, wftap *wth, wftap_dumper *pdh, Buffer *buf,
|
|||
|
||||
|
||||
/* Re-read the first frame from the stored location */
|
||||
if (!wftap_seek_read(wth, frame->offset, &phdr, buf, &err, &err_info)) {
|
||||
if (!wtap_seek_read(wth, frame->offset, &phdr, buf, &err, &err_info)) {
|
||||
if (err != 0) {
|
||||
/* Print a message noting that the read failed somewhere along the line. */
|
||||
fprintf(stderr,
|
||||
|
@ -174,8 +174,8 @@ frames_compare(gconstpointer a, gconstpointer b)
|
|||
/********************************************************************/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
wftap *wth = NULL;
|
||||
wftap_dumper *pdh = NULL;
|
||||
wtap *wth = NULL;
|
||||
wtap_dumper *pdh = NULL;
|
||||
Buffer buf;
|
||||
int err;
|
||||
gchar *err_info;
|
||||
|
@ -241,13 +241,13 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
exit(1);
|
||||
}
|
||||
DEBUG_PRINT("file_type_subtype is %u\n", wftap_file_type_subtype(wth));
|
||||
DEBUG_PRINT("file_type_subtype is %u\n", wtap_file_type_subtype(wth));
|
||||
|
||||
shb_hdr = wtap_file_get_shb_info(wth);
|
||||
idb_inf = wtap_file_get_idb_info(wth);
|
||||
|
||||
/* Open outfile (same filetype/encap as input file) */
|
||||
pdh = wtap_dump_open_ng(outfile, wftap_file_type_subtype(wth), wftap_file_encap(wth),
|
||||
pdh = wtap_dump_open_ng(outfile, wtap_file_type_subtype(wth), wtap_file_encap(wth),
|
||||
65535, FALSE, shb_hdr, idb_inf, &err);
|
||||
g_free(idb_inf);
|
||||
if (pdh == NULL) {
|
||||
|
@ -322,7 +322,7 @@ int main(int argc, char *argv[])
|
|||
g_ptr_array_free(frames, TRUE);
|
||||
|
||||
/* Close outfile */
|
||||
if (!wftap_dump_close(pdh, &err)) {
|
||||
if (!wtap_dump_close(pdh, &err)) {
|
||||
fprintf(stderr, "reordercap: Error closing %s: %s\n", outfile,
|
||||
wtap_strerror(err));
|
||||
g_free(shb_hdr);
|
||||
|
@ -331,7 +331,7 @@ int main(int argc, char *argv[])
|
|||
g_free(shb_hdr);
|
||||
|
||||
/* Finally, close infile */
|
||||
wftap_fdclose(wth);
|
||||
wtap_fdclose(wth);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ summary_fill_in(capture_file *cf, summary_tally *st)
|
|||
st->dfilter = cf->dfilter;
|
||||
|
||||
/* Get info from SHB */
|
||||
shb_inf = wtap_file_get_shb_info(cf->wfth);
|
||||
shb_inf = wtap_file_get_shb_info(cf->wth);
|
||||
if(shb_inf == NULL){
|
||||
st->opt_comment = NULL;
|
||||
st->shb_hardware = NULL;
|
||||
|
@ -171,7 +171,7 @@ summary_fill_in(capture_file *cf, summary_tally *st)
|
|||
}
|
||||
|
||||
st->ifaces = g_array_new(FALSE, FALSE, sizeof(iface_options));
|
||||
idb_info = wtap_file_get_idb_info(cf->wfth);
|
||||
idb_info = wtap_file_get_idb_info(cf->wth);
|
||||
for (i = 0; i < idb_info->number_of_interfaces; i++) {
|
||||
wtapng_if_descr = g_array_index(idb_info->interface_data, wtapng_if_descr_t, i);
|
||||
iface.cfilter = g_strdup(wtapng_if_descr.if_filter_str);
|
||||
|
|
67
tfshark.c
67
tfshark.c
|
@ -89,7 +89,6 @@
|
|||
#include <epan/timestamp.h>
|
||||
#include <epan/ex-opt.h>
|
||||
#include <filetap/ftap.h>
|
||||
#include <wiretap/wftap-int.h>
|
||||
#include <wiretap/wtap-int.h>
|
||||
#include <wiretap/file_wrappers.h>
|
||||
|
||||
|
@ -167,6 +166,28 @@ static void write_failure_message(const char *filename, int err);
|
|||
|
||||
capture_file cfile;
|
||||
|
||||
#if 0
|
||||
struct string_elem {
|
||||
const char *sstr; /* The short string */
|
||||
const char *lstr; /* The long string */
|
||||
};
|
||||
|
||||
static gint
|
||||
string_compare(gconstpointer a, gconstpointer b)
|
||||
{
|
||||
return strcmp(((const struct string_elem *)a)->sstr,
|
||||
((const struct string_elem *)b)->sstr);
|
||||
}
|
||||
|
||||
static void
|
||||
string_elem_print(gpointer data, gpointer not_used _U_)
|
||||
{
|
||||
fprintf(stderr, " %s - %s\n",
|
||||
((struct string_elem *)data)->sstr,
|
||||
((struct string_elem *)data)->lstr);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
print_usage(gboolean print_ver)
|
||||
{
|
||||
|
@ -1124,7 +1145,7 @@ main(int argc, char *argv[])
|
|||
rfilter = optarg;
|
||||
break;
|
||||
case 'S': /* Set the line Separator to be printed between packets */
|
||||
separator = g_strdup(optarg);
|
||||
separator = strdup(optarg);
|
||||
break;
|
||||
case 't': /* Time stamp type */
|
||||
if (strcmp(optarg, "r") == 0)
|
||||
|
@ -1483,7 +1504,7 @@ tfshark_get_frame_ts(void *data, guint32 frame_num)
|
|||
static const char *
|
||||
no_interface_name(void *data _U_, guint32 interface_id _U_)
|
||||
{
|
||||
return NULL;
|
||||
return "";
|
||||
}
|
||||
|
||||
static epan_t *
|
||||
|
@ -1667,13 +1688,13 @@ gboolean
|
|||
local_wtap_read(capture_file *cf, struct wtap_pkthdr* file_phdr, int *err, gchar **err_info, gint64 *data_offset _U_, guint8** data_buffer)
|
||||
{
|
||||
int bytes_read;
|
||||
gint64 packet_size = wftap_file_size(cf->wfth, err);
|
||||
gint64 packet_size = wtap_file_size(cf->wth, err);
|
||||
|
||||
*data_buffer = (guint8*)g_malloc((gsize)packet_size);
|
||||
bytes_read = file_read(*data_buffer, (unsigned int)packet_size, cf->wfth->fh);
|
||||
bytes_read = file_read(*data_buffer, (unsigned int)packet_size, cf->wth->fh);
|
||||
|
||||
if (bytes_read < 0) {
|
||||
*err = file_error(cf->wfth->fh, err_info);
|
||||
*err = file_error(cf->wth->fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = FTAP_ERR_SHORT_READ;
|
||||
return FALSE;
|
||||
|
@ -1696,9 +1717,9 @@ local_wtap_read(capture_file *cf, struct wtap_pkthdr* file_phdr, int *err, gchar
|
|||
* *is* WTAP_ENCAP_PER_PACKET, the caller needs to set it
|
||||
* anyway.
|
||||
*/
|
||||
wth->phdr.pkt_encap = wfth->file_encap;
|
||||
wth->phdr.pkt_encap = wth->file_encap;
|
||||
|
||||
if (!wfth->subtype_read(wth, err, err_info, data_offset)) {
|
||||
if (!wth->subtype_read(wth, err, err_info, data_offset)) {
|
||||
/*
|
||||
* If we didn't get an error indication, we read
|
||||
* the last packet. See if there's any deferred
|
||||
|
@ -1709,7 +1730,7 @@ local_wtap_read(capture_file *cf, struct wtap_pkthdr* file_phdr, int *err, gchar
|
|||
* last packet of the file.
|
||||
*/
|
||||
if (*err == 0)
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return FALSE; /* failure */
|
||||
}
|
||||
|
||||
|
@ -1784,8 +1805,8 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
|||
edt = epan_dissect_new(cf->epan, create_proto_tree, FALSE);
|
||||
}
|
||||
while (local_wtap_read(cf, &file_phdr, &err, &err_info, &data_offset, &raw_data)) {
|
||||
if (process_packet_first_pass(cf, edt, data_offset, &file_phdr/*wtap_phdr(cf->wfth)*/,
|
||||
wftap_buf_ptr(cf->wfth))) {
|
||||
if (process_packet_first_pass(cf, edt, data_offset, &file_phdr/*wtap_phdr(cf->wth)*/,
|
||||
wtap_buf_ptr(cf->wth))) {
|
||||
|
||||
/* Stop reading if we have the maximum number of packets;
|
||||
* When the -c option has not been used, max_packet_count
|
||||
|
@ -1806,7 +1827,7 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
|||
|
||||
#if 0
|
||||
/* Close the sequential I/O side, to free up memory it requires. */
|
||||
wtap_sequential_close(cf->wfth);
|
||||
wtap_sequential_close(cf->wth);
|
||||
#endif
|
||||
|
||||
/* Allow the protocol dissectors to free up memory that they
|
||||
|
@ -1836,12 +1857,12 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
|||
for (framenum = 1; err == 0 && framenum <= cf->count; framenum++) {
|
||||
fdata = frame_data_sequence_find(cf->frames, framenum);
|
||||
#if 0
|
||||
if (wtap_seek_read(cf->wfth, fdata->file_off,
|
||||
if (wtap_seek_read(cf->wth, fdata->file_off,
|
||||
&buf, fdata->cap_len, &err, &err_info)) {
|
||||
process_packet_second_pass(cf, edt, fdata, &cf->hdr.wtap_hdr, &buf, tap_flags);
|
||||
process_packet_second_pass(cf, edt, fdata, &cf->phdr, &buf, tap_flags);
|
||||
}
|
||||
#else
|
||||
process_packet_second_pass(cf, edt, fdata, &cf->hdr.wtap_hdr, &buf, tap_flags);
|
||||
process_packet_second_pass(cf, edt, fdata, &cf->phdr, &buf, tap_flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1875,7 +1896,7 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
|||
|
||||
framenum++;
|
||||
|
||||
process_packet(cf, edt, data_offset, &file_phdr/*wtap_phdr(cf->wfth)*/,
|
||||
process_packet(cf, edt, data_offset, &file_phdr/*wtap_phdr(cf->wth)*/,
|
||||
raw_data, tap_flags);
|
||||
|
||||
/* Stop reading if we have the maximum number of packets;
|
||||
|
@ -1970,8 +1991,8 @@ load_cap_file(capture_file *cf, int max_packet_count, gint64 max_byte_count)
|
|||
}
|
||||
|
||||
out:
|
||||
wtap_close(cf->wfth);
|
||||
cf->wfth = NULL;
|
||||
wtap_close(cf->wth);
|
||||
cf->wth = NULL;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -2488,7 +2509,7 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
|
|||
#if USE_FTAP
|
||||
ftap *fth;
|
||||
#else
|
||||
wftap *wth;
|
||||
wtap *wth;
|
||||
#endif
|
||||
gchar *err_info;
|
||||
char err_msg[2048+1];
|
||||
|
@ -2510,9 +2531,9 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
|
|||
cf->epan = tfshark_epan_new(cf);
|
||||
|
||||
#if USE_FTAP
|
||||
cf->wfth = (struct wtap*)fth; /**** XXX - DOESN'T WORK RIGHT NOW!!!! */
|
||||
cf->wth = (struct wtap*)fth; /**** XXX - DOESN'T WORK RIGHT NOW!!!! */
|
||||
#else
|
||||
cf->wfth = wth;
|
||||
cf->wth = wth;
|
||||
#endif
|
||||
cf->f_datalen = 0; /* not used, but set it anyway */
|
||||
|
||||
|
@ -2527,12 +2548,12 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
|
|||
/* No user changes yet. */
|
||||
cf->unsaved_changes = FALSE;
|
||||
|
||||
cf->cd_t = ftap_file_type_subtype((struct ftap*)cf->wfth); /**** XXX - DOESN'T WORK RIGHT NOW!!!! */
|
||||
cf->cd_t = ftap_file_type_subtype((struct ftap*)cf->wth); /**** XXX - DOESN'T WORK RIGHT NOW!!!! */
|
||||
cf->open_type = type;
|
||||
cf->count = 0;
|
||||
cf->drops_known = FALSE;
|
||||
cf->drops = 0;
|
||||
cf->snap = ftap_snapshot_length((struct ftap*)cf->wfth); /**** XXX - DOESN'T WORK RIGHT NOW!!!! */
|
||||
cf->snap = ftap_snapshot_length((struct ftap*)cf->wth); /**** XXX - DOESN'T WORK RIGHT NOW!!!! */
|
||||
if (cf->snap == 0) {
|
||||
/* Snapshot length not known. */
|
||||
cf->has_snap = FALSE;
|
||||
|
|
80
tshark.c
80
tshark.c
|
@ -2043,7 +2043,7 @@ main(int argc, char *argv[])
|
|||
|
||||
/* Set timestamp precision; there should arguably be a command-line
|
||||
option to let the user set this. */
|
||||
switch(wftap_file_tsprecision(cfile.wfth)) {
|
||||
switch(wtap_file_tsprecision(cfile.wth)) {
|
||||
case(WTAP_FILE_TSPREC_SEC):
|
||||
timestamp_set_precision(TS_PREC_AUTO_SEC);
|
||||
break;
|
||||
|
@ -2611,9 +2611,9 @@ capture_input_new_file(capture_session *cap_session, gchar *new_file)
|
|||
|
||||
/* we start a new capture file, close the old one (if we had one before) */
|
||||
if ( ((capture_file *) cap_session->cf)->state != FILE_CLOSED) {
|
||||
if ( ((capture_file *) cap_session->cf)->wfth != NULL) {
|
||||
wtap_close(((capture_file *) cap_session->cf)->wfth);
|
||||
((capture_file *) cap_session->cf)->wfth = NULL;
|
||||
if ( ((capture_file *) cap_session->cf)->wth != NULL) {
|
||||
wtap_close(((capture_file *) cap_session->cf)->wth);
|
||||
((capture_file *) cap_session->cf)->wth = NULL;
|
||||
}
|
||||
((capture_file *) cap_session->cf)->state = FILE_CLOSED;
|
||||
}
|
||||
|
@ -2694,17 +2694,17 @@ capture_input_new_packets(capture_session *cap_session, int to_read)
|
|||
("packet_details" is true). */
|
||||
edt = epan_dissect_new(cf->epan, create_proto_tree, print_packet_info && print_details);
|
||||
|
||||
while (to_read-- && cf->wfth) {
|
||||
wftap_cleareof(cf->wfth);
|
||||
ret = wtap_read(cf->wfth, &err, &err_info, &data_offset);
|
||||
while (to_read-- && cf->wth) {
|
||||
wtap_cleareof(cf->wth);
|
||||
ret = wtap_read(cf->wth, &err, &err_info, &data_offset);
|
||||
if (ret == FALSE) {
|
||||
/* read from file failed, tell the capture child to stop */
|
||||
sync_pipe_stop(cap_session);
|
||||
wtap_close(cf->wfth);
|
||||
cf->wfth = NULL;
|
||||
wtap_close(cf->wth);
|
||||
cf->wth = NULL;
|
||||
} else {
|
||||
ret = process_packet(cf, edt, data_offset, wtap_phdr(cf->wfth),
|
||||
wftap_buf_ptr(cf->wfth),
|
||||
ret = process_packet(cf, edt, data_offset, wtap_phdr(cf->wth),
|
||||
wtap_buf_ptr(cf->wth),
|
||||
tap_flags);
|
||||
}
|
||||
if (ret != FALSE) {
|
||||
|
@ -2809,8 +2809,8 @@ capture_input_closed(capture_session *cap_session, gchar *msg)
|
|||
|
||||
report_counts();
|
||||
|
||||
if (cf != NULL && cf->wfth != NULL) {
|
||||
wtap_close(cf->wfth);
|
||||
if (cf != NULL && cf->wth != NULL) {
|
||||
wtap_close(cf->wth);
|
||||
if (cf->is_tempfile) {
|
||||
ws_unlink(cf->filename);
|
||||
}
|
||||
|
@ -3060,7 +3060,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
{
|
||||
gint linktype;
|
||||
int snapshot_length;
|
||||
wftap_dumper *pdh;
|
||||
wtap_dumper *pdh;
|
||||
guint32 framenum;
|
||||
int err;
|
||||
gchar *err_info = NULL;
|
||||
|
@ -3077,23 +3077,23 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
|
||||
memset(&phdr, 0, sizeof(struct wtap_pkthdr));
|
||||
|
||||
shb_hdr = wtap_file_get_shb_info(cf->wfth);
|
||||
idb_inf = wtap_file_get_idb_info(cf->wfth);
|
||||
shb_hdr = wtap_file_get_shb_info(cf->wth);
|
||||
idb_inf = wtap_file_get_idb_info(cf->wth);
|
||||
#ifdef PCAP_NG_DEFAULT
|
||||
if (idb_inf->number_of_interfaces > 1) {
|
||||
linktype = WTAP_ENCAP_PER_PACKET;
|
||||
} else {
|
||||
linktype = wftap_file_encap(cf->wfth);
|
||||
linktype = wtap_file_encap(cf->wth);
|
||||
}
|
||||
#else
|
||||
linktype = wftap_file_encap(cf->wfth);
|
||||
linktype = wtap_file_encap(cf->wth);
|
||||
#endif
|
||||
if (save_file != NULL) {
|
||||
/* Get a string that describes what we're writing to */
|
||||
save_file_string = output_file_description(save_file);
|
||||
|
||||
/* Set up to write to the capture file. */
|
||||
snapshot_length = wftap_snapshot_length(cf->wfth);
|
||||
snapshot_length = wtap_snapshot_length(cf->wth);
|
||||
if (snapshot_length == 0) {
|
||||
/* Snapshot length of input file not known. */
|
||||
snapshot_length = WTAP_MAX_PACKET_SIZE;
|
||||
|
@ -3191,9 +3191,9 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
edt = epan_dissect_new(cf->epan, create_proto_tree, FALSE);
|
||||
}
|
||||
|
||||
while (wtap_read(cf->wfth, &err, &err_info, &data_offset)) {
|
||||
if (process_packet_first_pass(cf, edt, data_offset, wtap_phdr(cf->wfth),
|
||||
wftap_buf_ptr(cf->wfth))) {
|
||||
while (wtap_read(cf->wth, &err, &err_info, &data_offset)) {
|
||||
if (process_packet_first_pass(cf, edt, data_offset, wtap_phdr(cf->wth),
|
||||
wtap_buf_ptr(cf->wth))) {
|
||||
/* Stop reading if we have the maximum number of packets;
|
||||
* When the -c option has not been used, max_packet_count
|
||||
* starts at 0, which practically means, never stop reading.
|
||||
|
@ -3212,7 +3212,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
}
|
||||
|
||||
/* Close the sequential I/O side, to free up memory it requires. */
|
||||
wftap_sequential_close(cf->wfth);
|
||||
wtap_sequential_close(cf->wth);
|
||||
|
||||
/* Allow the protocol dissectors to free up memory that they
|
||||
* don't need after the sequential run-through of the packets. */
|
||||
|
@ -3240,7 +3240,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
|
||||
for (framenum = 1; err == 0 && framenum <= cf->count; framenum++) {
|
||||
fdata = frame_data_sequence_find(cf->frames, framenum);
|
||||
if (wftap_seek_read(cf->wfth, fdata->file_off, &phdr, &buf, &err,
|
||||
if (wtap_seek_read(cf->wth, fdata->file_off, &phdr, &buf, &err,
|
||||
&err_info)) {
|
||||
if (process_packet_second_pass(cf, edt, fdata, &phdr, &buf,
|
||||
tap_flags)) {
|
||||
|
@ -3286,7 +3286,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
show_capture_file_io_error(save_file, err, FALSE);
|
||||
break;
|
||||
}
|
||||
wftap_dump_close(pdh, &err);
|
||||
wtap_dump_close(pdh, &err);
|
||||
g_free(shb_hdr);
|
||||
exit(2);
|
||||
}
|
||||
|
@ -3321,17 +3321,17 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
edt = epan_dissect_new(cf->epan, create_proto_tree, print_packet_info && print_details);
|
||||
}
|
||||
|
||||
while (wtap_read(cf->wfth, &err, &err_info, &data_offset)) {
|
||||
while (wtap_read(cf->wth, &err, &err_info, &data_offset)) {
|
||||
framenum++;
|
||||
|
||||
if (process_packet(cf, edt, data_offset, wtap_phdr(cf->wfth),
|
||||
wftap_buf_ptr(cf->wfth),
|
||||
if (process_packet(cf, edt, data_offset, wtap_phdr(cf->wth),
|
||||
wtap_buf_ptr(cf->wth),
|
||||
tap_flags)) {
|
||||
/* Either there's no read filtering or this packet passed the
|
||||
filter, so, if we're writing to a capture file, write
|
||||
this packet out. */
|
||||
if (pdh != NULL) {
|
||||
if (!wtap_dump(pdh, wtap_phdr(cf->wfth), wftap_buf_ptr(cf->wfth), &err)) {
|
||||
if (!wtap_dump(pdh, wtap_phdr(cf->wth), wtap_buf_ptr(cf->wth), &err)) {
|
||||
/* Error writing to a capture file */
|
||||
switch (err) {
|
||||
|
||||
|
@ -3363,7 +3363,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
show_capture_file_io_error(save_file, err, FALSE);
|
||||
break;
|
||||
}
|
||||
wftap_dump_close(pdh, &err);
|
||||
wtap_dump_close(pdh, &err);
|
||||
g_free(shb_hdr);
|
||||
exit(2);
|
||||
}
|
||||
|
@ -3453,13 +3453,13 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
}
|
||||
if (save_file != NULL) {
|
||||
/* Now close the capture file. */
|
||||
if (!wftap_dump_close(pdh, &err))
|
||||
if (!wtap_dump_close(pdh, &err))
|
||||
show_capture_file_io_error(save_file, err, TRUE);
|
||||
}
|
||||
} else {
|
||||
if (save_file != NULL) {
|
||||
/* Now close the capture file. */
|
||||
if (!wftap_dump_close(pdh, &err))
|
||||
if (!wtap_dump_close(pdh, &err))
|
||||
show_capture_file_io_error(save_file, err, TRUE);
|
||||
} else {
|
||||
if (print_packet_info) {
|
||||
|
@ -3472,8 +3472,8 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
}
|
||||
|
||||
out:
|
||||
wtap_close(cf->wfth);
|
||||
cf->wfth = NULL;
|
||||
wtap_close(cf->wth);
|
||||
cf->wth = NULL;
|
||||
|
||||
g_free(save_file_string);
|
||||
g_free(shb_hdr);
|
||||
|
@ -3995,7 +3995,7 @@ write_finale(void)
|
|||
cf_status_t
|
||||
cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_tempfile, int *err)
|
||||
{
|
||||
wftap *wth;
|
||||
wtap *wth;
|
||||
gchar *err_info;
|
||||
char err_msg[2048+1];
|
||||
|
||||
|
@ -4009,7 +4009,7 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
|
|||
epan_free(cf->epan);
|
||||
cf->epan = tshark_epan_new(cf);
|
||||
|
||||
cf->wfth = wth;
|
||||
cf->wth = wth;
|
||||
cf->f_datalen = 0; /* not used, but set it anyway */
|
||||
|
||||
/* Set the file name because we need it to set the follow stream filter.
|
||||
|
@ -4023,12 +4023,12 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
|
|||
/* No user changes yet. */
|
||||
cf->unsaved_changes = FALSE;
|
||||
|
||||
cf->cd_t = wftap_file_type_subtype(cf->wfth);
|
||||
cf->cd_t = wtap_file_type_subtype(cf->wth);
|
||||
cf->open_type = type;
|
||||
cf->count = 0;
|
||||
cf->drops_known = FALSE;
|
||||
cf->drops = 0;
|
||||
cf->snap = wftap_snapshot_length(cf->wfth);
|
||||
cf->snap = wtap_snapshot_length(cf->wth);
|
||||
if (cf->snap == 0) {
|
||||
/* Snapshot length not known. */
|
||||
cf->has_snap = FALSE;
|
||||
|
@ -4042,8 +4042,8 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
|
|||
|
||||
cf->state = FILE_READ_IN_PROGRESS;
|
||||
|
||||
wtap_set_cb_new_ipv4(cf->wfth, add_ipv4_name);
|
||||
wtap_set_cb_new_ipv6(cf->wfth, (wtap_new_ipv6_callback_t) add_ipv6_name);
|
||||
wtap_set_cb_new_ipv4(cf->wth, add_ipv4_name);
|
||||
wtap_set_cb_new_ipv6(cf->wth, (wtap_new_ipv6_callback_t) add_ipv6_name);
|
||||
|
||||
return CF_OK;
|
||||
|
||||
|
|
|
@ -105,11 +105,11 @@ static gboolean color_selected;
|
|||
|
||||
|
||||
/* set a new filename for the preview widget */
|
||||
static wftap *
|
||||
static wtap *
|
||||
preview_set_filename(GtkWidget *prev, const gchar *cf_name)
|
||||
{
|
||||
GtkWidget *label;
|
||||
wftap *wth;
|
||||
wtap *wth;
|
||||
int err = 0;
|
||||
gchar *err_info;
|
||||
gchar string_buff[PREVIEW_STR_MAX];
|
||||
|
@ -150,7 +150,7 @@ preview_set_filename(GtkWidget *prev, const gchar *cf_name)
|
|||
}
|
||||
|
||||
/* Find the size of the file. */
|
||||
filesize = wftap_file_size(wth, &err);
|
||||
filesize = wtap_file_size(wth, &err);
|
||||
if (filesize == -1) {
|
||||
gtk_label_set_text(GTK_LABEL(label), "error getting file size");
|
||||
wtap_close(wth);
|
||||
|
@ -161,7 +161,7 @@ preview_set_filename(GtkWidget *prev, const gchar *cf_name)
|
|||
gtk_label_set_text(GTK_LABEL(label), string_buff);
|
||||
|
||||
/* type */
|
||||
g_strlcpy(string_buff, wtap_file_type_subtype_string(wftap_file_type_subtype(wth)), PREVIEW_STR_MAX);
|
||||
g_strlcpy(string_buff, wtap_file_type_subtype_string(wtap_file_type_subtype(wth)), PREVIEW_STR_MAX);
|
||||
label = (GtkWidget *)g_object_get_data(G_OBJECT(prev), PREVIEW_FORMAT_KEY);
|
||||
gtk_label_set_text(GTK_LABEL(label), string_buff);
|
||||
|
||||
|
@ -171,7 +171,7 @@ preview_set_filename(GtkWidget *prev, const gchar *cf_name)
|
|||
|
||||
/* do a preview run on the currently selected capture file */
|
||||
static void
|
||||
preview_do(GtkWidget *prev, wftap *wth)
|
||||
preview_do(GtkWidget *prev, wtap *wth)
|
||||
{
|
||||
GtkWidget *label;
|
||||
unsigned int elapsed_time;
|
||||
|
@ -299,7 +299,7 @@ file_open_entry_changed(GtkWidget *w _U_, gpointer file_sel)
|
|||
GtkWidget *prev = (GtkWidget *)g_object_get_data(G_OBJECT(file_sel), PREVIEW_TABLE_KEY);
|
||||
gchar *cf_name;
|
||||
gboolean have_preview;
|
||||
wftap *wth;
|
||||
wtap *wth;
|
||||
|
||||
/* get the filename */
|
||||
cf_name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_sel));
|
||||
|
|
|
@ -535,7 +535,7 @@ file_import_open(text_import_info_t *info)
|
|||
read_failure_alert_box(info->import_text_filename, errno);
|
||||
}
|
||||
|
||||
if (!wftap_dump_close(info->wdh, &err)) {
|
||||
if (!wtap_dump_close(info->wdh, &err)) {
|
||||
write_failure_alert_box(capfile_name, err);
|
||||
}
|
||||
|
||||
|
|
|
@ -3715,7 +3715,7 @@ void iax2_analysis_cb(GtkAction *action _U_, gpointer user_data _U_)
|
|||
return; /* error reading the frame */
|
||||
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
||||
epan_dissect_prime_dfilter(&edt, sfcode);
|
||||
epan_dissect_run(&edt, &cf->hdr.wtap_hdr, frame_tvbuff_new_buffer(fdata, &cf->buf),
|
||||
epan_dissect_run(&edt, &cf->phdr, frame_tvbuff_new_buffer(fdata, &cf->buf),
|
||||
fdata, NULL);
|
||||
|
||||
/* if it is not an iax2 frame, show an error dialog */
|
||||
|
|
|
@ -549,7 +549,7 @@ get_ip_address_list_from_packet_list_row(gpointer data)
|
|||
epan_dissect_init(&edt, cfile.epan, FALSE, FALSE);
|
||||
col_custom_prime_edt(&edt, &cfile.cinfo);
|
||||
|
||||
epan_dissect_run(&edt, &cfile.hdr.wtap_hdr, frame_tvbuff_new_buffer(fdata, &cfile.buf),
|
||||
epan_dissect_run(&edt, &cfile.phdr, frame_tvbuff_new_buffer(fdata, &cfile.buf),
|
||||
fdata, &cfile.cinfo);
|
||||
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
|
||||
|
||||
|
@ -590,7 +590,7 @@ get_filter_from_packet_list_row_and_column(gpointer data)
|
|||
epan_dissect_init(&edt, cfile.epan, have_custom_cols(&cfile.cinfo), FALSE);
|
||||
col_custom_prime_edt(&edt, &cfile.cinfo);
|
||||
|
||||
epan_dissect_run(&edt, &cfile.hdr.wtap_hdr, frame_tvbuff_new_buffer(fdata, &cfile.buf),
|
||||
epan_dissect_run(&edt, &cfile.phdr, frame_tvbuff_new_buffer(fdata, &cfile.buf),
|
||||
fdata, &cfile.cinfo);
|
||||
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
|
||||
|
||||
|
|
|
@ -972,7 +972,7 @@ void new_packet_window(GtkWidget *w _U_, gboolean reference, gboolean editable _
|
|||
/* XXX, protect cfile.epan from closing (ref counting?) */
|
||||
DataPtr->epan = cfile.epan;
|
||||
DataPtr->frame = fd;
|
||||
DataPtr->phdr = cfile.hdr.wtap_hdr;
|
||||
DataPtr->phdr = cfile.phdr;
|
||||
DataPtr->pd = (guint8 *)g_malloc(DataPtr->frame->cap_len);
|
||||
memcpy(DataPtr->pd, buffer_start_ptr(&cfile.buf), DataPtr->frame->cap_len);
|
||||
|
||||
|
|
|
@ -917,7 +917,7 @@ static rlc_lte_tap_info *select_rlc_lte_session(capture_file *cf, struct segment
|
|||
|
||||
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
||||
epan_dissect_prime_dfilter(&edt, sfcode);
|
||||
epan_dissect_run_with_taps(&edt, &cf->hdr.wtap_hdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata, NULL);
|
||||
epan_dissect_run_with_taps(&edt, &cf->phdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata, NULL);
|
||||
rel_ts = edt.pi.rel_ts;
|
||||
epan_dissect_cleanup(&edt);
|
||||
remove_tap_listener(&th);
|
||||
|
|
|
@ -3950,7 +3950,7 @@ rtp_analysis_cb(GtkAction *action _U_, gpointer user_data _U_)
|
|||
return; /* error reading the frame */
|
||||
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
||||
epan_dissect_prime_dfilter(&edt, sfcode);
|
||||
epan_dissect_run(&edt, &cf->hdr.wtap_hdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata, NULL);
|
||||
epan_dissect_run(&edt, &cf->phdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata, NULL);
|
||||
|
||||
/* if it is not an rtp frame, show the rtpstream dialog */
|
||||
frame_matched = dfilter_apply_edt(sfcode, &edt);
|
||||
|
|
|
@ -980,7 +980,7 @@ sctp_analyse_cb(struct sctp_analyse *u_data, gboolean ext)
|
|||
|
||||
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
||||
epan_dissect_prime_dfilter(&edt, sfcode);
|
||||
epan_dissect_run(&edt, &cf->hdr.wtap_hdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata, NULL);
|
||||
epan_dissect_run(&edt, &cf->phdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata, NULL);
|
||||
frame_matched = dfilter_apply_edt(sfcode, &edt);
|
||||
|
||||
/* if it is not an sctp frame, show the dialog */
|
||||
|
|
|
@ -786,10 +786,10 @@ void CaptureFileDialog::preview(const QString & path)
|
|||
}
|
||||
|
||||
// Format
|
||||
preview_format_.setText(QString::fromUtf8(wtap_file_type_subtype_string(wftap_file_type_subtype(wth))));
|
||||
preview_format_.setText(QString::fromUtf8(wtap_file_type_subtype_string(wtap_file_type_subtype(wth))));
|
||||
|
||||
// Size
|
||||
preview_size_.setText(QString(tr("%1 bytes")).arg(wftap_file_size(wth, &err)));
|
||||
preview_size_.setText(QString(tr("%1 bytes")).arg(wtap_file_size(wth, &err)));
|
||||
|
||||
time(&time_preview);
|
||||
while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) {
|
||||
|
|
|
@ -142,7 +142,7 @@ void ImportTextDialog::convertTextFile() {
|
|||
read_failure_alert_box(import_info_.import_text_filename, errno);
|
||||
}
|
||||
|
||||
if (!wftap_dump_close(import_info_.wdh, &err))
|
||||
if (!wtap_dump_close(import_info_.wdh, &err))
|
||||
{
|
||||
write_failure_alert_box(capfile_name_.toUtf8().constData(), err);
|
||||
}
|
||||
|
|
|
@ -661,7 +661,7 @@ QString &PacketList::getFilterFromRowAndColumn()
|
|||
epan_dissect_init(&edt, cap_file_->epan, have_custom_cols(&cap_file_->cinfo), FALSE);
|
||||
col_custom_prime_edt(&edt, &cap_file_->cinfo);
|
||||
|
||||
epan_dissect_run(&edt, &cap_file_->hdr.wtap_hdr, frame_tvbuff_new_buffer(fdata, &cap_file_->buf), fdata, &cap_file_->cinfo);
|
||||
epan_dissect_run(&edt, &cap_file_->phdr, frame_tvbuff_new_buffer(fdata, &cap_file_->buf), fdata, &cap_file_->cinfo);
|
||||
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
|
||||
|
||||
if ((cap_file_->cinfo.col_custom_occurrence[ctx_column_]) ||
|
||||
|
|
|
@ -319,7 +319,7 @@ select_tcpip_session(capture_file *cf, struct segment *hdrs)
|
|||
|
||||
epan_dissect_init(&edt, cf->epan, TRUE, FALSE);
|
||||
epan_dissect_prime_dfilter(&edt, sfcode);
|
||||
epan_dissect_run_with_taps(&edt, &cf->hdr.wtap_hdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata, NULL);
|
||||
epan_dissect_run_with_taps(&edt, &cf->phdr, frame_tvbuff_new_buffer(fdata, &cf->buf), fdata, NULL);
|
||||
rel_ts = edt.pi.rel_ts;
|
||||
epan_dissect_cleanup(&edt);
|
||||
remove_tap_listener(&th);
|
||||
|
|
|
@ -154,7 +154,7 @@ exp_pdu_file_open(exp_pdu_t *exp_pdu_tap_data)
|
|||
cf_retap_packets(&cfile);
|
||||
|
||||
|
||||
if (!wftap_dump_close(exp_pdu_tap_data->wdh, &err)) {
|
||||
if (!wtap_dump_close(exp_pdu_tap_data->wdh, &err)) {
|
||||
write_failure_alert_box(capfile_name, err);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ extern "C" {
|
|||
|
||||
typedef struct _exp_pdu_t {
|
||||
int pkt_encap;
|
||||
wftap_dumper* wdh;
|
||||
wtap_dumper* wdh;
|
||||
} exp_pdu_t;
|
||||
|
||||
void exp_pdu_file_open(exp_pdu_t *exp_pdu_tap_data);
|
||||
|
|
|
@ -191,7 +191,7 @@ static guint32 ts_usec = 0;
|
|||
static char *ts_fmt = NULL;
|
||||
static struct tm timecode_default;
|
||||
|
||||
static wftap_dumper* wdh;
|
||||
static wtap_dumper* wdh;
|
||||
|
||||
/* HDR_ETH Offset base to parse */
|
||||
static guint32 offset_base = 16;
|
||||
|
|
|
@ -71,7 +71,7 @@ typedef struct
|
|||
|
||||
/* Import info */
|
||||
guint encapsulation;
|
||||
wftap_dumper* wdh;
|
||||
wtap_dumper* wdh;
|
||||
|
||||
/* Dummy header info (if encapsulation == 1) */
|
||||
enum dummy_header_type dummy_header_type;
|
||||
|
|
|
@ -1114,7 +1114,7 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
|
|||
HWND cur_ctrl;
|
||||
int i;
|
||||
gboolean enable = FALSE;
|
||||
wftap *wth;
|
||||
wtap *wth;
|
||||
const struct wtap_pkthdr *phdr;
|
||||
int err = 0;
|
||||
gchar *err_info;
|
||||
|
@ -1177,10 +1177,10 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
|
|||
|
||||
/* Format */
|
||||
cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_FORMAT);
|
||||
SetWindowText(cur_ctrl, utf_8to16(wtap_file_type_subtype_string(wftap_file_type_subtype(wth))));
|
||||
SetWindowText(cur_ctrl, utf_8to16(wtap_file_type_subtype_string(wtap_file_type_subtype(wth))));
|
||||
|
||||
/* Size */
|
||||
filesize = wftap_file_size(wth, &err);
|
||||
filesize = wtap_file_size(wth, &err);
|
||||
utf_8to16_snprintf(string_buff, PREVIEW_STR_MAX, "%" G_GINT64_FORMAT " bytes", filesize);
|
||||
cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_SIZE);
|
||||
SetWindowText(cur_ctrl, string_buff);
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -100,27 +99,27 @@ typedef struct
|
|||
#define CST_5VW_CAPTURES_RECORD (CST_5VW_SECTION_CAPTURES << 28) /* 0x80000000 */
|
||||
#define CST_5VW_SYSTEM_RECORD 0x00000000U
|
||||
|
||||
static gboolean _5views_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean _5views_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean _5views_seek_read(wftap *wth, gint64 seek_off,
|
||||
static gboolean _5views_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
static int _5views_read_header(wftap *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);
|
||||
|
||||
static gboolean _5views_dump(wftap_dumper *wdh, void* header, const guint8 *pd, int *err);
|
||||
static gboolean _5views_dump_close(wftap_dumper *wdh, int *err);
|
||||
static gboolean _5views_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr, const guint8 *pd, int *err);
|
||||
static gboolean _5views_dump_close(wtap_dumper *wdh, int *err);
|
||||
|
||||
|
||||
int _5views_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int _5views_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
int bytes_read;
|
||||
t_5VW_Capture_Header Capture_Header;
|
||||
int encap = WTAP_ENCAP_UNKNOWN;
|
||||
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(&Capture_Header.Info_Header, sizeof(t_5VW_Info_Header), wfth->fh);
|
||||
bytes_read = file_read(&Capture_Header.Info_Header, sizeof(t_5VW_Info_Header), wth->fh);
|
||||
if (bytes_read != sizeof(t_5VW_Info_Header)) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -172,31 +171,30 @@ int _5views_open(wftap *wfth, int *err, gchar **err_info)
|
|||
}
|
||||
|
||||
/* read the remaining header information */
|
||||
bytes_read = file_read(&Capture_Header.HeaderDateCreation, sizeof (t_5VW_Capture_Header) - sizeof(t_5VW_Info_Header), wfth->fh);
|
||||
bytes_read = file_read(&Capture_Header.HeaderDateCreation, sizeof (t_5VW_Capture_Header) - sizeof(t_5VW_Info_Header), wth->fh);
|
||||
if (bytes_read != sizeof (t_5VW_Capture_Header)- sizeof(t_5VW_Info_Header) ) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* This is a 5views capture file */
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_5VIEWS;
|
||||
wfth->subtype_read = _5views_read;
|
||||
wfth->subtype_seek_read = _5views_seek_read;
|
||||
wfth->file_encap = encap;
|
||||
wfth->snapshot_length = 0; /* not available in header */
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_5VIEWS;
|
||||
wth->subtype_read = _5views_read;
|
||||
wth->subtype_seek_read = _5views_seek_read;
|
||||
wth->file_encap = encap;
|
||||
wth->snapshot_length = 0; /* not available in header */
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Read the next packet */
|
||||
static gboolean
|
||||
_5views_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
_5views_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
{
|
||||
t_5VW_TimeStamped_Header TimeStamped_Header;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
/*
|
||||
* Keep reading until we see a record with a subtype of
|
||||
|
@ -204,10 +202,10 @@ _5views_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
|||
*/
|
||||
do
|
||||
{
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
/* Read record header. */
|
||||
if (!_5views_read_header(wfth, wfth->fh, &TimeStamped_Header,
|
||||
if (!_5views_read_header(wth, wth->fh, &TimeStamped_Header,
|
||||
&wth->phdr, err, err_info))
|
||||
return FALSE;
|
||||
|
||||
|
@ -221,7 +219,7 @@ _5views_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
|||
/*
|
||||
* Not a packet - skip to the next record.
|
||||
*/
|
||||
if (file_seek(wfth->fh, TimeStamped_Header.RecSize, SEEK_CUR, err) == -1)
|
||||
if (file_seek(wth->fh, TimeStamped_Header.RecSize, SEEK_CUR, err) == -1)
|
||||
return FALSE;
|
||||
} while (1);
|
||||
|
||||
|
@ -236,23 +234,23 @@ _5views_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
return wtap_read_packet_bytes(wfth->fh, wfth->frame_buffer,
|
||||
return wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
|
||||
wth->phdr.caplen, err, err_info);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_5views_seek_read(wftap *wfth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||
_5views_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
t_5VW_TimeStamped_Header TimeStamped_Header;
|
||||
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
* Read the header.
|
||||
*/
|
||||
if (!_5views_read_header(wfth, wfth->random_fh, &TimeStamped_Header,
|
||||
if (!_5views_read_header(wth, wth->random_fh, &TimeStamped_Header,
|
||||
phdr, err, err_info)) {
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
|
@ -262,14 +260,14 @@ _5views_seek_read(wftap *wfth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
|||
/*
|
||||
* Read the packet data.
|
||||
*/
|
||||
return wtap_read_packet_bytes(wfth->random_fh, buf, phdr->caplen,
|
||||
return wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen,
|
||||
err, err_info);
|
||||
}
|
||||
|
||||
/* Read the header of the next packet. Return TRUE on success, FALSE
|
||||
on error. */
|
||||
static gboolean
|
||||
_5views_read_header(wftap *wfth, 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)
|
||||
{
|
||||
int bytes_read, bytes_to_read;
|
||||
|
@ -305,7 +303,7 @@ _5views_read_header(wftap *wfth, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
|
|||
phdr->caplen = hdr->RecSize;
|
||||
phdr->len = hdr->RecSize;
|
||||
|
||||
switch (wfth->file_encap) {
|
||||
switch (wth->file_encap) {
|
||||
|
||||
case WTAP_ENCAP_ETHERNET:
|
||||
/* We assume there's no FCS in this frame. */
|
||||
|
@ -342,7 +340,7 @@ int _5views_dump_can_write_encap(int encap)
|
|||
|
||||
/* Returns TRUE on success, FALSE on failure; sets "*err" to an error code on
|
||||
failure */
|
||||
gboolean _5views_dump_open(wftap_dumper *wdh, int *err)
|
||||
gboolean _5views_dump_open(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
_5views_dump_t *_5views;
|
||||
|
||||
|
@ -350,7 +348,7 @@ gboolean _5views_dump_open(wftap_dumper *wdh, int *err)
|
|||
haven't yet written any packets. As we'll have to rewrite
|
||||
the header when we've written out all the packets, we just
|
||||
skip over the header for now. */
|
||||
if (wftap_dump_file_seek(wdh, sizeof(t_5VW_Capture_Header), SEEK_SET, err) == -1)
|
||||
if (wtap_dump_file_seek(wdh, sizeof(t_5VW_Capture_Header), SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
/* This is a 5Views file */
|
||||
|
@ -365,12 +363,12 @@ gboolean _5views_dump_open(wftap_dumper *wdh, int *err)
|
|||
|
||||
/* Write a record for a packet to a dump file.
|
||||
Returns TRUE on success, FALSE on failure. */
|
||||
static gboolean _5views_dump(wftap_dumper *wdh, void* header,
|
||||
static gboolean _5views_dump(wtap_dumper *wdh,
|
||||
const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err)
|
||||
{
|
||||
_5views_dump_t *_5views = (_5views_dump_t *)wdh->priv;
|
||||
t_5VW_TimeStamped_Header HeaderFrame;
|
||||
const struct wtap_pkthdr *phdr = (const struct wtap_pkthdr*)header;
|
||||
|
||||
/* Don't write out something bigger than we can read. */
|
||||
if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
|
||||
|
@ -394,12 +392,12 @@ static gboolean _5views_dump(wftap_dumper *wdh, void* header,
|
|||
HeaderFrame.RecInfo = GUINT32_TO_LE(0);
|
||||
|
||||
/* write the record header */
|
||||
if (!wftap_dump_file_write(wdh, &HeaderFrame,
|
||||
if (!wtap_dump_file_write(wdh, &HeaderFrame,
|
||||
sizeof(t_5VW_TimeStamped_Header), err))
|
||||
return FALSE;
|
||||
|
||||
/* write the data */
|
||||
if (!wftap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
return FALSE;
|
||||
|
||||
_5views->nframes ++;
|
||||
|
@ -407,12 +405,12 @@ static gboolean _5views_dump(wftap_dumper *wdh, void* header,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean _5views_dump_close(wftap_dumper *wdh, int *err)
|
||||
static gboolean _5views_dump_close(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
_5views_dump_t *_5views = (_5views_dump_t *)wdh->priv;
|
||||
t_5VW_Capture_Header file_hdr;
|
||||
|
||||
if (wftap_dump_file_seek(wdh, 0, SEEK_SET, err) == -1)
|
||||
if (wtap_dump_file_seek(wdh, 0, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
/* fill in the Info_Header */
|
||||
|
@ -449,7 +447,7 @@ static gboolean _5views_dump_close(wftap_dumper *wdh, int *err)
|
|||
file_hdr.TramesStockeesInFile = GUINT32_TO_LE(_5views->nframes);
|
||||
|
||||
/* Write the file header. */
|
||||
if (!wftap_dump_file_write(wdh, &file_hdr, sizeof(t_5VW_Capture_Header),
|
||||
if (!wtap_dump_file_write(wdh, &file_hdr, sizeof(t_5VW_Capture_Header),
|
||||
err))
|
||||
return FALSE;
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
#include <glib.h>
|
||||
#include <wtap.h>
|
||||
|
||||
int _5views_open(wftap *wfth, int *err, gchar **err_info);
|
||||
gboolean _5views_dump_open(wftap_dumper *wdh, int *err);
|
||||
int _5views_open(wtap *wth, int *err, gchar **err_info);
|
||||
gboolean _5views_dump_open(wtap_dumper *wdh, int *err);
|
||||
int _5views_dump_can_write_encap(int encap);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -51,8 +51,8 @@ set(CLEAN_FILES
|
|||
libpcap.c
|
||||
logcat.c
|
||||
merge.c
|
||||
mime_file.c
|
||||
mpeg.c
|
||||
mime_file.c
|
||||
mp2t.c
|
||||
netmon.c
|
||||
netscaler.c
|
||||
|
|
|
@ -51,12 +51,12 @@ NONGENERATED_C_FILES = \
|
|||
ipfix.c \
|
||||
iptrace.c \
|
||||
iseries.c \
|
||||
mime_file.c \
|
||||
k12.c \
|
||||
lanalyzer.c \
|
||||
logcat.c \
|
||||
libpcap.c \
|
||||
merge.c \
|
||||
mime_file.c \
|
||||
mpeg.c \
|
||||
mp2t.c \
|
||||
netmon.c \
|
||||
|
@ -69,8 +69,8 @@ NONGENERATED_C_FILES = \
|
|||
packetlogger.c \
|
||||
pcap-common.c \
|
||||
pcapng.c \
|
||||
peekclassic.c \
|
||||
peektagged.c \
|
||||
peekclassic.c \
|
||||
peektagged.c \
|
||||
pppdump.c \
|
||||
radcom.c \
|
||||
snoop.c \
|
||||
|
@ -79,7 +79,7 @@ NONGENERATED_C_FILES = \
|
|||
toshiba.c \
|
||||
visual.c \
|
||||
vms.c \
|
||||
vwr.c \
|
||||
vwr.c \
|
||||
wtap.c
|
||||
|
||||
# Header files that are not generated from other files
|
||||
|
@ -128,7 +128,7 @@ NONGENERATED_HEADER_FILES = \
|
|||
pcap-common.h \
|
||||
pcap-encap.h \
|
||||
pcapng.h \
|
||||
peekclassic.h \
|
||||
peekclassic.h \
|
||||
peektagged.h \
|
||||
pppdump.h \
|
||||
radcom.h \
|
||||
|
@ -138,8 +138,7 @@ NONGENERATED_HEADER_FILES = \
|
|||
toshiba.h \
|
||||
visual.h \
|
||||
vms.h \
|
||||
vwr.h \
|
||||
wftap-int.h \
|
||||
vwr.h \
|
||||
wtap.h \
|
||||
wtap-int.h
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "config.h"
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -113,14 +112,14 @@ typedef struct {
|
|||
time_t start;
|
||||
} aethra_t;
|
||||
|
||||
static gboolean aethra_read(wftap *wfth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean aethra_seek_read(wftap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean aethra_read_rec_header(wftap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
|
||||
struct wtap_pkthdr *phdr, int *err, gchar **err_info);
|
||||
static gboolean aethra_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean aethra_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
|
||||
struct wtap_pkthdr *phdr, int *err, gchar **err_info);
|
||||
|
||||
int aethra_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int aethra_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
int bytes_read;
|
||||
struct aethra_hdr hdr;
|
||||
|
@ -129,9 +128,9 @@ int aethra_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
/* Read in the string that should be at the start of a "aethra" file */
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(hdr.magic, sizeof hdr.magic, wfth->fh);
|
||||
bytes_read = file_read(hdr.magic, sizeof hdr.magic, wth->fh);
|
||||
if (bytes_read != sizeof hdr.magic) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -143,18 +142,18 @@ int aethra_open(wftap *wfth, int *err, gchar **err_info)
|
|||
/* Read the rest of the header. */
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read((char *)&hdr + sizeof hdr.magic,
|
||||
sizeof hdr - sizeof hdr.magic, wfth->fh);
|
||||
sizeof hdr - sizeof hdr.magic, wth->fh);
|
||||
if (bytes_read != sizeof hdr - sizeof hdr.magic) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return -1;
|
||||
}
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_AETHRA;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_AETHRA;
|
||||
aethra = (aethra_t *)g_malloc(sizeof(aethra_t));
|
||||
wfth->priv = (void *)aethra;
|
||||
wfth->subtype_read = aethra_read;
|
||||
wfth->subtype_seek_read = aethra_seek_read;
|
||||
wth->priv = (void *)aethra;
|
||||
wth->subtype_read = aethra_read;
|
||||
wth->subtype_seek_read = aethra_seek_read;
|
||||
|
||||
/*
|
||||
* Convert the time stamp to a "time_t".
|
||||
|
@ -172,9 +171,9 @@ int aethra_open(wftap *wfth, int *err, gchar **err_info)
|
|||
* We've only seen ISDN files, so, for now, we treat all
|
||||
* files as ISDN.
|
||||
*/
|
||||
wfth->file_encap = WTAP_ENCAP_ISDN;
|
||||
wfth->snapshot_length = 0; /* not available in header */
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_MSEC;
|
||||
wth->file_encap = WTAP_ENCAP_ISDN;
|
||||
wth->snapshot_length = 0; /* not available in header */
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_MSEC;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -183,21 +182,20 @@ static guint packet = 0;
|
|||
#endif
|
||||
|
||||
/* Read the next packet */
|
||||
static gboolean aethra_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean aethra_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
struct aethrarec_hdr hdr;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
/*
|
||||
* Keep reading until we see an AETHRA_ISDN_LINK with a subtype
|
||||
* of AETHRA_ISDN_LINK_LAPD record or get an end-of-file.
|
||||
*/
|
||||
for (;;) {
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
/* Read record header. */
|
||||
if (!aethra_read_rec_header(wfth, wfth->fh, &hdr, &wth->phdr, err, err_info))
|
||||
if (!aethra_read_rec_header(wth, wth->fh, &hdr, &wth->phdr, err, err_info))
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
|
@ -205,7 +203,7 @@ static gboolean aethra_read(wftap *wfth, int *err, gchar **err_info,
|
|||
* growing the buffer to handle it.
|
||||
*/
|
||||
if (wth->phdr.caplen != 0) {
|
||||
if (!wtap_read_packet_bytes(wfth->fh, wfth->frame_buffer,
|
||||
if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
|
||||
wth->phdr.caplen, err, err_info))
|
||||
return FALSE; /* Read error */
|
||||
}
|
||||
|
@ -276,15 +274,15 @@ found:
|
|||
}
|
||||
|
||||
static gboolean
|
||||
aethra_seek_read(wftap *wfth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||
aethra_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct aethrarec_hdr hdr;
|
||||
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
if (!aethra_read_rec_header(wfth, wfth->random_fh, &hdr, phdr, err,
|
||||
if (!aethra_read_rec_header(wth, wth->random_fh, &hdr, phdr, err,
|
||||
err_info)) {
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
|
@ -294,17 +292,17 @@ aethra_seek_read(wftap *wfth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
|||
/*
|
||||
* Read the packet data.
|
||||
*/
|
||||
if (!wtap_read_packet_bytes(wfth->random_fh, buf, phdr->caplen, err, err_info))
|
||||
if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err, err_info))
|
||||
return FALSE; /* failed */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
aethra_read_rec_header(wftap *wfth, 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)
|
||||
{
|
||||
aethra_t *aethra = (aethra_t *)wfth->priv;
|
||||
aethra_t *aethra = (aethra_t *)wth->priv;
|
||||
int bytes_read;
|
||||
guint32 rec_size;
|
||||
guint32 packet_size;
|
||||
|
|
|
@ -24,6 +24,6 @@
|
|||
#include <glib.h>
|
||||
#include <wtap.h>
|
||||
|
||||
int aethra_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int aethra_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "buffer.h"
|
||||
#include "ascendtext.h"
|
||||
|
@ -75,27 +74,26 @@ static const ascend_magic_string ascend_magic[] = {
|
|||
{ ASCEND_PFX_ETHER, "ETHER" },
|
||||
};
|
||||
|
||||
static gboolean ascend_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean ascend_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf,
|
||||
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
||||
int *err, gchar **err_info);
|
||||
|
||||
/* Seeks to the beginning of the next packet, and returns the
|
||||
byte offset at which the header for that packet begins.
|
||||
Returns -1 on failure. */
|
||||
static gint64 ascend_seek(wftap *wfth, int *err, gchar **err_info)
|
||||
static gint64 ascend_seek(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
int byte;
|
||||
gint64 date_off = -1, cur_off, packet_off;
|
||||
size_t string_level[ASCEND_MAGIC_STRINGS];
|
||||
guint string_i = 0, type = 0;
|
||||
guint excessive_read_count = 262144;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
memset(&string_level, 0, sizeof(string_level));
|
||||
|
||||
while (((byte = file_getc(wfth->fh)) != EOF)) {
|
||||
while (((byte = file_getc(wth->fh)) != EOF)) {
|
||||
excessive_read_count--;
|
||||
|
||||
if (!excessive_read_count) {
|
||||
|
@ -110,16 +108,16 @@ static gint64 ascend_seek(wftap *wfth, int *err, gchar **err_info)
|
|||
if (byte == *(strptr + string_level[string_i])) {
|
||||
string_level[string_i]++;
|
||||
if (string_level[string_i] >= len) {
|
||||
cur_off = file_tell(wfth->fh);
|
||||
cur_off = file_tell(wth->fh);
|
||||
if (cur_off == -1) {
|
||||
/* Error. */
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Date: header is a special case. Remember the offset,
|
||||
but keep looking for other headers. */
|
||||
if (strcmp(strptr, ASCEND_DATE) == 0) {
|
||||
if (strcmp(strptr, ASCEND_DATE) == 0) {
|
||||
date_off = cur_off - len;
|
||||
} else {
|
||||
if (date_off == -1) {
|
||||
|
@ -142,7 +140,7 @@ static gint64 ascend_seek(wftap *wfth, int *err, gchar **err_info)
|
|||
}
|
||||
}
|
||||
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return -1;
|
||||
|
||||
found:
|
||||
|
@ -150,7 +148,7 @@ found:
|
|||
* Move to where the read for this packet should start, and return
|
||||
* that seek offset.
|
||||
*/
|
||||
if (file_seek(wfth->fh, packet_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->fh, packet_off, SEEK_SET, err) == -1)
|
||||
return -1;
|
||||
|
||||
wth->phdr.pseudo_header.ascend.type = type;
|
||||
|
@ -158,19 +156,18 @@ found:
|
|||
return packet_off;
|
||||
}
|
||||
|
||||
int ascend_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int ascend_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
gint64 offset;
|
||||
ws_statb64 statbuf;
|
||||
ascend_t *ascend;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
/* We haven't yet allocated a data structure for our private stuff;
|
||||
set the pointer to null, so that "ascend_seek()" knows not to
|
||||
fill it in. */
|
||||
wfth->priv = NULL;
|
||||
wth->priv = NULL;
|
||||
|
||||
offset = ascend_seek(wfth, err, err_info);
|
||||
offset = ascend_seek(wth, err, err_info);
|
||||
if (offset == -1) {
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
|
@ -179,31 +176,31 @@ int ascend_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
/* Do a trial parse of the first packet just found to see if we might really have an Ascend file */
|
||||
init_parse_ascend();
|
||||
if (!check_ascend(wfth->fh, &wth->phdr)) {
|
||||
if (!check_ascend(wth->fh, &wth->phdr)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_ASCEND;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_ASCEND;
|
||||
|
||||
switch(wth->phdr.pseudo_header.ascend.type) {
|
||||
case ASCEND_PFX_ISDN_X:
|
||||
case ASCEND_PFX_ISDN_R:
|
||||
wfth->file_encap = WTAP_ENCAP_ISDN;
|
||||
wth->file_encap = WTAP_ENCAP_ISDN;
|
||||
break;
|
||||
|
||||
case ASCEND_PFX_ETHER:
|
||||
wfth->file_encap = WTAP_ENCAP_ETHERNET;
|
||||
wth->file_encap = WTAP_ENCAP_ETHERNET;
|
||||
break;
|
||||
|
||||
default:
|
||||
wfth->file_encap = WTAP_ENCAP_ASCEND;
|
||||
wth->file_encap = WTAP_ENCAP_ASCEND;
|
||||
}
|
||||
|
||||
wfth->snapshot_length = ASCEND_MAX_PKT_LEN;
|
||||
wfth->subtype_read = ascend_read;
|
||||
wfth->subtype_seek_read = ascend_seek_read;
|
||||
wth->snapshot_length = ASCEND_MAX_PKT_LEN;
|
||||
wth->subtype_read = ascend_read;
|
||||
wth->subtype_seek_read = ascend_seek_read;
|
||||
ascend = (ascend_t *)g_malloc(sizeof(ascend_t));
|
||||
wfth->priv = (void *)ascend;
|
||||
wth->priv = (void *)ascend;
|
||||
|
||||
/* The first packet we want to read is the one that "ascend_seek()"
|
||||
just found; start searching for it at the offset at which it
|
||||
|
@ -215,12 +212,12 @@ int ascend_open(wftap *wfth, int *err, gchar **err_info)
|
|||
packet's timestamp from the capture file's ctime, which gives us an
|
||||
offset that we can apply to each packet.
|
||||
*/
|
||||
if (wftap_fstat(wfth, &statbuf, err) == -1) {
|
||||
if (wtap_fstat(wth, &statbuf, err) == -1) {
|
||||
return -1;
|
||||
}
|
||||
ascend->inittime = statbuf.st_ctime;
|
||||
ascend->adjusted = FALSE;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
|
||||
init_parse_ascend();
|
||||
|
||||
|
@ -228,26 +225,25 @@ int ascend_open(wftap *wfth, int *err, gchar **err_info)
|
|||
}
|
||||
|
||||
/* Read the next packet; called from wtap_read(). */
|
||||
static gboolean ascend_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
ascend_t *ascend = (ascend_t *)wfth->priv;
|
||||
ascend_t *ascend = (ascend_t *)wth->priv;
|
||||
gint64 offset;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
/* parse_ascend() will advance the point at which to look for the next
|
||||
packet's header, to just after the last packet's header (ie. at the
|
||||
start of the last packet's data). We have to get past the last
|
||||
packet's header because we might mistake part of it for a new header. */
|
||||
if (file_seek(wfth->fh, ascend->next_packet_seek_start,
|
||||
if (file_seek(wth->fh, ascend->next_packet_seek_start,
|
||||
SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
offset = ascend_seek(wfth, err, err_info);
|
||||
offset = ascend_seek(wth, err, err_info);
|
||||
if (offset == -1)
|
||||
return FALSE;
|
||||
if (parse_ascend(ascend, wfth->fh, &wth->phdr, wfth->frame_buffer,
|
||||
wfth->snapshot_length) != PARSED_RECORD) {
|
||||
if (parse_ascend(ascend, wth->fh, &wth->phdr, wth->frame_buffer,
|
||||
wth->snapshot_length) != PARSED_RECORD) {
|
||||
*err = WTAP_ERR_BAD_FILE;
|
||||
*err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
|
||||
return FALSE;
|
||||
|
@ -257,17 +253,16 @@ static gboolean ascend_read(wftap *wfth, int *err, gchar **err_info,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean ascend_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf,
|
||||
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
||||
int *err, gchar **err_info)
|
||||
{
|
||||
ascend_t *ascend = (ascend_t *)wfth->priv;
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
ascend_t *ascend = (ascend_t *)wth->priv;
|
||||
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
if (parse_ascend(ascend, wfth->random_fh, phdr, buf,
|
||||
wfth->snapshot_length) != PARSED_RECORD) {
|
||||
if (parse_ascend(ascend, wth->random_fh, phdr, buf,
|
||||
wth->snapshot_length) != PARSED_RECORD) {
|
||||
*err = WTAP_ERR_BAD_FILE;
|
||||
*err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
|
||||
return FALSE;
|
||||
|
|
|
@ -27,6 +27,6 @@
|
|||
#define ASCEND_MAX_DATA_COLS 16
|
||||
#define ASCEND_MAX_PKT_LEN (ASCEND_MAX_DATA_ROWS * ASCEND_MAX_DATA_COLS)
|
||||
|
||||
int ascend_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int ascend_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -39,13 +38,13 @@
|
|||
#define BER_UNI_TAG_SEQ 16 /* SEQUENCE, SEQUENCE OF */
|
||||
#define BER_UNI_TAG_SET 17 /* SET, SET OF */
|
||||
|
||||
static gboolean ber_read_file(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||
static gboolean ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
gint64 file_size;
|
||||
int packet_size;
|
||||
|
||||
if ((file_size = wftap_file_size(wfth, err)) == -1)
|
||||
if ((file_size = wtap_file_size(wth, err)) == -1)
|
||||
return FALSE;
|
||||
|
||||
if (file_size > WTAP_MAX_PACKET_SIZE) {
|
||||
|
@ -55,7 +54,7 @@ static gboolean ber_read_file(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr,
|
|||
*/
|
||||
*err = WTAP_ERR_BAD_FILE;
|
||||
*err_info = g_strdup_printf("ber: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u",
|
||||
file_size, WTAP_MAX_PACKET_SIZE);
|
||||
file_size, WTAP_MAX_PACKET_SIZE);
|
||||
return FALSE;
|
||||
}
|
||||
packet_size = (int)file_size;
|
||||
|
@ -71,14 +70,13 @@ static gboolean ber_read_file(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr,
|
|||
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
|
||||
}
|
||||
|
||||
static gboolean ber_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
{
|
||||
gint64 offset;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
*err = 0;
|
||||
|
||||
offset = file_tell(wfth->fh);
|
||||
offset = file_tell(wth->fh);
|
||||
|
||||
/* there is only ever one packet */
|
||||
if (offset != 0)
|
||||
|
@ -86,27 +84,25 @@ static gboolean ber_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_o
|
|||
|
||||
*data_offset = offset;
|
||||
|
||||
return ber_read_file(wfth, wfth->fh, &wth->phdr, wfth->frame_buffer, err, err_info);
|
||||
return ber_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
|
||||
}
|
||||
|
||||
static gboolean ber_seek_read(wftap *wfth, gint64 seek_off, void* header,
|
||||
Buffer *buf, int *err, gchar **err_info)
|
||||
static gboolean ber_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr _U_,
|
||||
Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr*)header;
|
||||
|
||||
/* there is only one packet */
|
||||
if(seek_off > 0) {
|
||||
*err = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
return ber_read_file(wfth, wfth->random_fh, phdr, buf, err, err_info);
|
||||
return ber_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
|
||||
}
|
||||
|
||||
int ber_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int ber_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
#define BER_BYTES_TO_CHECK 8
|
||||
guint8 bytes[BER_BYTES_TO_CHECK];
|
||||
|
@ -120,9 +116,9 @@ int ber_open(wftap *wfth, int *err, gchar **err_info)
|
|||
gint64 file_size;
|
||||
int offset = 0, i;
|
||||
|
||||
bytes_read = file_read(&bytes, BER_BYTES_TO_CHECK, wfth->fh);
|
||||
bytes_read = file_read(&bytes, BER_BYTES_TO_CHECK, wth->fh);
|
||||
if (bytes_read != BER_BYTES_TO_CHECK) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -165,7 +161,7 @@ int ber_open(wftap *wfth, int *err, gchar **err_info)
|
|||
}
|
||||
|
||||
len += (2 + nlb); /* add back Tag and Length bytes */
|
||||
file_size = wftap_file_size(wfth, err);
|
||||
file_size = wtap_file_size(wth, err);
|
||||
|
||||
if(len != file_size) {
|
||||
return 0; /* not ASN.1 */
|
||||
|
@ -175,16 +171,16 @@ int ber_open(wftap *wfth, int *err, gchar **err_info)
|
|||
}
|
||||
|
||||
/* seek back to the start of the file */
|
||||
if (file_seek(wfth->fh, 0, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
|
||||
return -1;
|
||||
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_BER;
|
||||
wfth->file_encap = WTAP_ENCAP_BER;
|
||||
wfth->snapshot_length = 0;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_BER;
|
||||
wth->file_encap = WTAP_ENCAP_BER;
|
||||
wth->snapshot_length = 0;
|
||||
|
||||
wfth->subtype_read = ber_read;
|
||||
wfth->subtype_seek_read = ber_seek_read;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_SEC;
|
||||
wth->subtype_read = ber_read;
|
||||
wth->subtype_seek_read = ber_seek_read;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,6 @@
|
|||
#include <glib.h>
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
int ber_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int ber_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "config.h"
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -74,14 +73,14 @@ struct btsnooprec_hdr {
|
|||
|
||||
static const gint64 KUnixTimeBase = G_GINT64_CONSTANT(0x00dcddb30f2f8000); /* offset from symbian - unix time */
|
||||
|
||||
static gboolean btsnoop_read(wftap *wfth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean btsnoop_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean btsnoop_read_record(wftap *wfth, FILE_T fh,
|
||||
static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
|
||||
int btsnoop_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int btsnoop_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
int bytes_read;
|
||||
char magic[sizeof btsnoop_magic];
|
||||
|
@ -91,9 +90,9 @@ int btsnoop_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
/* Read in the string that should be at the start of a "btsnoop" file */
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(magic, sizeof magic, wfth->fh);
|
||||
bytes_read = file_read(magic, sizeof magic, wth->fh);
|
||||
if (bytes_read != sizeof magic) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -105,9 +104,9 @@ int btsnoop_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
/* Read the rest of the header. */
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(&hdr, sizeof hdr, wfth->fh);
|
||||
bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
|
||||
if (bytes_read != sizeof hdr) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return -1;
|
||||
|
@ -152,36 +151,34 @@ int btsnoop_open(wftap *wfth, int *err, gchar **err_info)
|
|||
return -1;
|
||||
}
|
||||
|
||||
wfth->subtype_read = btsnoop_read;
|
||||
wfth->subtype_seek_read = btsnoop_seek_read;
|
||||
wfth->file_encap = file_encap;
|
||||
wfth->snapshot_length = 0; /* not available in header */
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_BTSNOOP;
|
||||
wth->subtype_read = btsnoop_read;
|
||||
wth->subtype_seek_read = btsnoop_seek_read;
|
||||
wth->file_encap = file_encap;
|
||||
wth->snapshot_length = 0; /* not available in header */
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_BTSNOOP;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static gboolean btsnoop_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
return btsnoop_read_record(wfth, wfth->fh, &wth->phdr, wfth->frame_buffer,
|
||||
return btsnoop_read_record(wth, wth->fh, &wth->phdr, wth->frame_buffer,
|
||||
err, err_info);
|
||||
}
|
||||
|
||||
static gboolean btsnoop_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info)
|
||||
static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
return btsnoop_read_record(wfth, wfth->random_fh, phdr, buf, err, err_info);
|
||||
return btsnoop_read_record(wth, wth->random_fh, phdr, buf, err, err_info);
|
||||
}
|
||||
|
||||
static gboolean btsnoop_read_record(wftap *wfth, FILE_T fh,
|
||||
static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
int bytes_read;
|
||||
|
@ -224,12 +221,10 @@ static gboolean btsnoop_read_record(wftap *wfth, FILE_T fh,
|
|||
phdr->ts.nsecs = (guint)((ts % 1000000) * 1000);
|
||||
phdr->caplen = packet_size;
|
||||
phdr->len = orig_size;
|
||||
switch(wfth->file_encap)
|
||||
if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR)
|
||||
{
|
||||
case WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR:
|
||||
phdr->pseudo_header.p2p.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE;
|
||||
break;
|
||||
case WTAP_ENCAP_BLUETOOTH_HCI:
|
||||
} else if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_HCI) {
|
||||
phdr->pseudo_header.bthci.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE;
|
||||
if(flags & KHciLoggerCommandOrEvent)
|
||||
{
|
||||
|
@ -246,13 +241,12 @@ static gboolean btsnoop_read_record(wftap *wfth, FILE_T fh,
|
|||
{
|
||||
phdr->pseudo_header.bthci.channel = BTHCI_CHANNEL_ACL;
|
||||
}
|
||||
break;
|
||||
case WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR:
|
||||
} else if (wth->file_encap == WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR) {
|
||||
phdr->pseudo_header.btmon.opcode = flags & 0xFFFF;
|
||||
phdr->pseudo_header.btmon.adapter_id = flags >> 16;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Read packet data. */
|
||||
return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info);
|
||||
}
|
||||
|
@ -303,7 +297,7 @@ static guint8 btsnoop_lookup_flags(guint8 hci_type, gboolean sent, guint8 *flags
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean btsnoop_dump_partial_rec_hdr(wftap_dumper *wdh _U_,
|
||||
static gboolean btsnoop_dump_partial_rec_hdr(wtap_dumper *wdh _U_,
|
||||
const struct wtap_pkthdr *phdr,
|
||||
const union wtap_pseudo_header *pseudo_header,
|
||||
const guint8 *pd, int *err,
|
||||
|
@ -330,10 +324,10 @@ static gboolean btsnoop_dump_partial_rec_hdr(wftap_dumper *wdh _U_,
|
|||
}
|
||||
|
||||
/* FIXME: How do we support multiple backends?*/
|
||||
static gboolean btsnoop_dump_h1(wftap_dumper *wdh, void* header,
|
||||
static gboolean btsnoop_dump_h1(wtap_dumper *wdh,
|
||||
const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err)
|
||||
{
|
||||
const struct wtap_pkthdr *phdr = (const struct wtap_pkthdr *)header;
|
||||
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
|
||||
struct btsnooprec_hdr rec_hdr;
|
||||
|
||||
|
@ -352,7 +346,7 @@ static gboolean btsnoop_dump_h1(wftap_dumper *wdh, void* header,
|
|||
rec_hdr.incl_len = GUINT32_TO_BE(phdr->caplen-1);
|
||||
rec_hdr.orig_len = GUINT32_TO_BE(phdr->len-1);
|
||||
|
||||
if (!wftap_dump_file_write(wdh, &rec_hdr, sizeof rec_hdr, err))
|
||||
if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof rec_hdr, err))
|
||||
return FALSE;
|
||||
|
||||
wdh->bytes_dumped += sizeof rec_hdr;
|
||||
|
@ -360,7 +354,7 @@ static gboolean btsnoop_dump_h1(wftap_dumper *wdh, void* header,
|
|||
/* Skip HCI packet type */
|
||||
++pd;
|
||||
|
||||
if (!wftap_dump_file_write(wdh, pd, phdr->caplen-1, err))
|
||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen-1, err))
|
||||
return FALSE;
|
||||
|
||||
wdh->bytes_dumped += phdr->caplen-1;
|
||||
|
@ -368,7 +362,7 @@ static gboolean btsnoop_dump_h1(wftap_dumper *wdh, void* header,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean btsnoop_dump_h4(wftap_dumper *wdh,
|
||||
static gboolean btsnoop_dump_h4(wtap_dumper *wdh,
|
||||
const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err)
|
||||
{
|
||||
|
@ -387,12 +381,12 @@ static gboolean btsnoop_dump_h4(wftap_dumper *wdh,
|
|||
rec_hdr.incl_len = GUINT32_TO_BE(phdr->caplen);
|
||||
rec_hdr.orig_len = GUINT32_TO_BE(phdr->len);
|
||||
|
||||
if (!wftap_dump_file_write(wdh, &rec_hdr, sizeof rec_hdr, err))
|
||||
if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof rec_hdr, err))
|
||||
return FALSE;
|
||||
|
||||
wdh->bytes_dumped += sizeof rec_hdr;
|
||||
|
||||
if (!wftap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
return FALSE;
|
||||
|
||||
wdh->bytes_dumped += phdr->caplen;
|
||||
|
@ -401,7 +395,7 @@ static gboolean btsnoop_dump_h4(wftap_dumper *wdh,
|
|||
}
|
||||
|
||||
/* FIXME: How do we support multiple backends?*/
|
||||
gboolean btsnoop_dump_open_h1(wftap_dumper *wdh, int *err)
|
||||
gboolean btsnoop_dump_open_h1(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
struct btsnoop_hdr file_hdr;
|
||||
|
||||
|
@ -423,7 +417,7 @@ gboolean btsnoop_dump_open_h1(wftap_dumper *wdh, int *err)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!wftap_dump_file_write(wdh, btsnoop_magic, sizeof btsnoop_magic, err))
|
||||
if (!wtap_dump_file_write(wdh, btsnoop_magic, sizeof btsnoop_magic, err))
|
||||
return FALSE;
|
||||
|
||||
wdh->bytes_dumped += sizeof btsnoop_magic;
|
||||
|
@ -433,7 +427,7 @@ gboolean btsnoop_dump_open_h1(wftap_dumper *wdh, int *err)
|
|||
/* HCI type encoded in first byte */
|
||||
file_hdr.datalink = GUINT32_TO_BE(KHciLoggerDatalinkTypeH1);
|
||||
|
||||
if (!wftap_dump_file_write(wdh, &file_hdr, sizeof file_hdr, err))
|
||||
if (!wtap_dump_file_write(wdh, &file_hdr, sizeof file_hdr, err))
|
||||
return FALSE;
|
||||
|
||||
wdh->bytes_dumped += sizeof file_hdr;
|
||||
|
@ -443,7 +437,7 @@ gboolean btsnoop_dump_open_h1(wftap_dumper *wdh, int *err)
|
|||
|
||||
/* Returns TRUE on success, FALSE on failure; sets "*err" to an error code on
|
||||
failure */
|
||||
gboolean btsnoop_dump_open_h4(wftap_dumper *wdh, int *err)
|
||||
gboolean btsnoop_dump_open_h4(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
struct btsnoop_hdr file_hdr;
|
||||
|
||||
|
@ -465,7 +459,7 @@ gboolean btsnoop_dump_open_h4(wftap_dumper *wdh, int *err)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!wftap_dump_file_write(wdh, btsnoop_magic, sizeof btsnoop_magic, err))
|
||||
if (!wtap_dump_file_write(wdh, btsnoop_magic, sizeof btsnoop_magic, err))
|
||||
return FALSE;
|
||||
|
||||
wdh->bytes_dumped += sizeof btsnoop_magic;
|
||||
|
@ -475,7 +469,7 @@ gboolean btsnoop_dump_open_h4(wftap_dumper *wdh, int *err)
|
|||
/* HCI type encoded in first byte */
|
||||
file_hdr.datalink = GUINT32_TO_BE(KHciLoggerDatalinkTypeH4);
|
||||
|
||||
if (!wftap_dump_file_write(wdh, &file_hdr, sizeof file_hdr, err))
|
||||
if (!wtap_dump_file_write(wdh, &file_hdr, sizeof file_hdr, err))
|
||||
return FALSE;
|
||||
|
||||
wdh->bytes_dumped += sizeof file_hdr;
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
#include <glib.h>
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
int btsnoop_open(wftap *wfth, int *err, gchar **err_info);
|
||||
gboolean btsnoop_dump_open_h1(wftap_dumper *wfdh, int *err);
|
||||
gboolean btsnoop_dump_open_h4(wftap_dumper *wfdh, int *err);
|
||||
int btsnoop_open(wtap *wth, int *err, gchar **err_info);
|
||||
gboolean btsnoop_dump_open_h1(wtap_dumper *wdh, int *err);
|
||||
gboolean btsnoop_dump_open_h4(wtap_dumper *wdh, int *err);
|
||||
int btsnoop_dump_can_write_encap(int encap);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -62,7 +62,6 @@
|
|||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include <wtap.h>
|
||||
#include <wftap-int.h>
|
||||
#include <wtap-int.h>
|
||||
#include <file_wrappers.h>
|
||||
#include <buffer.h>
|
||||
|
@ -298,29 +297,28 @@ camins_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
|||
|
||||
|
||||
static gboolean
|
||||
camins_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
camins_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
{
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
return camins_read_packet(wfth->fh, &wth->phdr, wfth->frame_buffer, err,
|
||||
err_info);
|
||||
return camins_read_packet(wth->fh, &wth->phdr, wth->frame_buffer, err,
|
||||
err_info);
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
camins_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info)
|
||||
camins_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *pkthdr, Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *pkthdr = (struct wtap_pkthdr *)header;
|
||||
if (-1 == file_seek(wfth->random_fh, seek_off, SEEK_SET, err))
|
||||
if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err))
|
||||
return FALSE;
|
||||
|
||||
return camins_read_packet(wfth->random_fh, pkthdr, buf, err, err_info);
|
||||
return camins_read_packet(wth->random_fh, pkthdr, buf, err, err_info);
|
||||
}
|
||||
|
||||
|
||||
int camins_open(wftap *wfth, int *err, gchar **err_info _U_)
|
||||
|
||||
int camins_open(wtap *wth, int *err, gchar **err_info _U_)
|
||||
{
|
||||
guint8 found_start_blocks = 0;
|
||||
guint8 count = 0;
|
||||
|
@ -330,7 +328,7 @@ int camins_open(wftap *wfth, int *err, gchar **err_info _U_)
|
|||
/* all CAM Inspector files I've looked at have at least two blocks of
|
||||
0x00 0xE1 within the first 20 bytes */
|
||||
do {
|
||||
bytes_read = file_read(block, sizeof(block), wfth->fh);
|
||||
bytes_read = file_read(block, sizeof(block), wth->fh);
|
||||
if (bytes_read != sizeof(block))
|
||||
break;
|
||||
|
||||
|
@ -344,18 +342,18 @@ int camins_open(wftap *wfth, int *err, gchar **err_info _U_)
|
|||
return 0; /* no CAM Inspector file */
|
||||
|
||||
/* rewind the fh so we re-read from the beginning */
|
||||
if (-1 == file_seek(wfth->fh, 0, SEEK_SET, err))
|
||||
if (-1 == file_seek(wth->fh, 0, SEEK_SET, err))
|
||||
return -1;
|
||||
|
||||
wfth->file_encap = WTAP_ENCAP_DVBCI;
|
||||
wfth->snapshot_length = 0;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_MSEC;
|
||||
wth->file_encap = WTAP_ENCAP_DVBCI;
|
||||
wth->snapshot_length = 0;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_MSEC;
|
||||
|
||||
wfth->priv = NULL;
|
||||
wth->priv = NULL;
|
||||
|
||||
wfth->subtype_read = camins_read;
|
||||
wfth->subtype_seek_read = camins_seek_read;
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_CAMINS;
|
||||
wth->subtype_read = camins_read;
|
||||
wth->subtype_seek_read = camins_seek_read;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_CAMINS;
|
||||
|
||||
*err = 0;
|
||||
return 1;
|
||||
|
|
|
@ -28,6 +28,6 @@
|
|||
#include <glib.h>
|
||||
#include <wiretap/wtap.h>
|
||||
|
||||
int camins_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int camins_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif /* _CAMINS_H */
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -104,15 +103,15 @@ static const gchar catapult_dct2000_magic[] = "Session Transcript";
|
|||
|
||||
/************************************************************/
|
||||
/* Functions called from wiretap core */
|
||||
static gboolean catapult_dct2000_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean catapult_dct2000_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header,
|
||||
static gboolean catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err,
|
||||
gchar **err_info);
|
||||
static void catapult_dct2000_close(wftap *wfth);
|
||||
static void catapult_dct2000_close(wtap *wth);
|
||||
|
||||
static gboolean catapult_dct2000_dump(wftap_dumper *wdh, void* header,
|
||||
static gboolean catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err);
|
||||
|
||||
|
||||
|
@ -132,7 +131,7 @@ static gboolean parse_line(char *linebuff, gint line_length,
|
|||
gchar *context_name, guint8 *context_portp,
|
||||
gchar *protocol_name, gchar *variant_name,
|
||||
gchar *outhdr_name);
|
||||
static void process_parsed_line(wftap *wfth,
|
||||
static void process_parsed_line(wtap *wth,
|
||||
dct2000_file_externals_t *file_externals,
|
||||
struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, gint64 file_offset,
|
||||
|
@ -168,7 +167,7 @@ static gboolean free_line_prefix_info(gpointer key, gpointer value, gpointer use
|
|||
/* Open file (for reading) */
|
||||
/********************************************/
|
||||
int
|
||||
catapult_dct2000_open(wftap *wfth, int *err, gchar **err_info)
|
||||
catapult_dct2000_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
gint64 offset = 0;
|
||||
time_t timestamp;
|
||||
|
@ -185,7 +184,7 @@ catapult_dct2000_open(wftap *wfth, int *err, gchar **err_info)
|
|||
/********************************************************************/
|
||||
/* First line needs to contain at least as many characters as magic */
|
||||
|
||||
if (!read_new_line(wfth->fh, &offset, &firstline_length, linebuff,
|
||||
if (!read_new_line(wth->fh, &offset, &firstline_length, linebuff,
|
||||
sizeof linebuff, err, err_info)) {
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
|
@ -224,7 +223,7 @@ catapult_dct2000_open(wftap *wfth, int *err, gchar **err_info)
|
|||
/* Second line contains file timestamp */
|
||||
/* Store this offset in in file_externals */
|
||||
|
||||
if (!read_new_line(wfth->fh, &offset, &(file_externals->secondline_length),
|
||||
if (!read_new_line(wth->fh, &offset, &(file_externals->secondline_length),
|
||||
linebuff, sizeof linebuff, err, err_info)) {
|
||||
g_free(file_externals);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
|
@ -251,18 +250,18 @@ catapult_dct2000_open(wftap *wfth, int *err, gchar **err_info)
|
|||
/* File is for us. Fill in details so packets can be read */
|
||||
|
||||
/* Set our file type */
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_CATAPULT_DCT2000;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_CATAPULT_DCT2000;
|
||||
|
||||
/* Use our own encapsulation to send all packets to our stub dissector */
|
||||
wfth->file_encap = WTAP_ENCAP_CATAPULT_DCT2000;
|
||||
wth->file_encap = WTAP_ENCAP_CATAPULT_DCT2000;
|
||||
|
||||
/* Callbacks for reading operations */
|
||||
wfth->subtype_read = catapult_dct2000_read;
|
||||
wfth->subtype_seek_read = catapult_dct2000_seek_read;
|
||||
wfth->subtype_close = catapult_dct2000_close;
|
||||
wth->subtype_read = catapult_dct2000_read;
|
||||
wth->subtype_seek_read = catapult_dct2000_seek_read;
|
||||
wth->subtype_close = catapult_dct2000_close;
|
||||
|
||||
/* Choose microseconds (have 4 decimal places...) */
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
|
||||
|
||||
/***************************************************************/
|
||||
|
@ -271,7 +270,7 @@ catapult_dct2000_open(wftap *wfth, int *err, gchar **err_info)
|
|||
g_hash_table_new(packet_offset_hash_func, packet_offset_equal);
|
||||
|
||||
/* Set this wtap to point to the file_externals */
|
||||
wfth->priv = (void*)file_externals;
|
||||
wth->priv = (void*)file_externals;
|
||||
|
||||
*err = errno;
|
||||
return 1;
|
||||
|
@ -335,18 +334,17 @@ static void write_timestamp_string(char *timestamp_string, int secs, int tenthou
|
|||
/* - return TRUE and details if found */
|
||||
/**************************************************/
|
||||
static gboolean
|
||||
catapult_dct2000_read(wftap *wfth, int *err, gchar **err_info,
|
||||
catapult_dct2000_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
gint64 offset = file_tell(wfth->fh);
|
||||
gint64 offset = file_tell(wth->fh);
|
||||
long dollar_offset, before_time_offset, after_time_offset;
|
||||
packet_direction_t direction;
|
||||
int encap;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
/* Get wtap external structure for this wtap */
|
||||
dct2000_file_externals_t *file_externals =
|
||||
(dct2000_file_externals_t*)wfth->priv;
|
||||
(dct2000_file_externals_t*)wth->priv;
|
||||
|
||||
/* Search for a line containing a usable packet */
|
||||
while (1) {
|
||||
|
@ -363,13 +361,13 @@ catapult_dct2000_read(wftap *wfth, int *err, gchar **err_info,
|
|||
gchar outhdr_name[MAX_OUTHDR_NAME+1];
|
||||
|
||||
/* Are looking for first packet after 2nd line */
|
||||
if (file_tell(wfth->fh) == 0) {
|
||||
if (file_tell(wth->fh) == 0) {
|
||||
this_offset += (file_externals->firstline_length+1+
|
||||
file_externals->secondline_length+1);
|
||||
}
|
||||
|
||||
/* Read a new line from file into linebuff */
|
||||
if (!read_new_line(wfth->fh, &offset, &line_length, linebuff,
|
||||
if (!read_new_line(wth->fh, &offset, &line_length, linebuff,
|
||||
sizeof linebuff, err, err_info)) {
|
||||
if (*err != 0)
|
||||
return FALSE; /* error */
|
||||
|
@ -396,9 +394,9 @@ catapult_dct2000_read(wftap *wfth, int *err, gchar **err_info,
|
|||
*/
|
||||
*data_offset = this_offset;
|
||||
|
||||
process_parsed_line(wfth, file_externals,
|
||||
process_parsed_line(wth, file_externals,
|
||||
&wth->phdr,
|
||||
wfth->frame_buffer, this_offset,
|
||||
wth->frame_buffer, this_offset,
|
||||
linebuff, dollar_offset,
|
||||
seconds, useconds, timestamp_string,
|
||||
direction, encap,
|
||||
|
@ -449,8 +447,8 @@ catapult_dct2000_read(wftap *wfth, int *err, gchar **err_info,
|
|||
/* Read & seek function. */
|
||||
/**************************************************/
|
||||
static gboolean
|
||||
catapult_dct2000_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf,
|
||||
catapult_dct2000_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
||||
int *err, gchar **err_info)
|
||||
{
|
||||
gint64 offset = 0;
|
||||
|
@ -468,22 +466,21 @@ catapult_dct2000_seek_read(wftap *wfth, gint64 seek_off,
|
|||
packet_direction_t direction;
|
||||
int encap;
|
||||
int seconds, useconds, data_chars;
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
|
||||
/* Get wtap external structure for this wtap */
|
||||
dct2000_file_externals_t *file_externals =
|
||||
(dct2000_file_externals_t*)wfth->priv;
|
||||
(dct2000_file_externals_t*)wth->priv;
|
||||
|
||||
/* Reset errno */
|
||||
*err = errno = 0;
|
||||
|
||||
/* Seek to beginning of packet */
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1) {
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Re-read whole line (this really should succeed) */
|
||||
if (!read_new_line(wfth->random_fh, &offset, &length, linebuff,
|
||||
if (!read_new_line(wth->random_fh, &offset, &length, linebuff,
|
||||
sizeof linebuff, err, err_info)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -500,7 +497,7 @@ catapult_dct2000_seek_read(wftap *wfth, gint64 seek_off,
|
|||
|
||||
write_timestamp_string(timestamp_string, seconds, useconds/100);
|
||||
|
||||
process_parsed_line(wfth, file_externals,
|
||||
process_parsed_line(wth, file_externals,
|
||||
phdr, buf, seek_off,
|
||||
linebuff, dollar_offset,
|
||||
seconds, useconds, timestamp_string,
|
||||
|
@ -527,11 +524,11 @@ catapult_dct2000_seek_read(wftap *wfth, gint64 seek_off,
|
|||
/* Free dct2000-specific capture info from file that was open for reading */
|
||||
/***************************************************************************/
|
||||
static void
|
||||
catapult_dct2000_close(wftap *wfth)
|
||||
catapult_dct2000_close(wtap *wth)
|
||||
{
|
||||
/* Get externals for this file */
|
||||
dct2000_file_externals_t *file_externals =
|
||||
(dct2000_file_externals_t*)wfth->priv;
|
||||
(dct2000_file_externals_t*)wth->priv;
|
||||
|
||||
/* Free up its line prefix values */
|
||||
g_hash_table_foreach_remove(file_externals->packet_prefix_table,
|
||||
|
@ -557,7 +554,7 @@ typedef struct {
|
|||
/* Set other dump callbacks. */
|
||||
/*****************************************************/
|
||||
gboolean
|
||||
catapult_dct2000_dump_open(wftap_dumper *wdh, int *err _U_)
|
||||
catapult_dct2000_dump_open(wtap_dumper *wdh, int *err _U_)
|
||||
{
|
||||
/* Fill in other dump callbacks */
|
||||
wdh->subtype_write = catapult_dct2000_dump;
|
||||
|
@ -589,7 +586,7 @@ catapult_dct2000_dump_can_write_encap(int encap)
|
|||
/*****************************************/
|
||||
|
||||
static gboolean
|
||||
catapult_dct2000_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
catapult_dct2000_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err)
|
||||
{
|
||||
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
|
||||
|
@ -606,28 +603,28 @@ catapult_dct2000_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
/* Get the file_externals structure for this file */
|
||||
/* Find wtap external structure for this wtap */
|
||||
dct2000_file_externals_t *file_externals =
|
||||
(dct2000_file_externals_t*)pseudo_header->dct2000.wfth->priv;
|
||||
(dct2000_file_externals_t*)pseudo_header->dct2000.wth->priv;
|
||||
|
||||
dct2000 = (dct2000_dump_t *)wdh->priv;
|
||||
if (dct2000 == NULL) {
|
||||
|
||||
/* Write out saved first line */
|
||||
if (!wftap_dump_file_write(wdh, file_externals->firstline,
|
||||
if (!wtap_dump_file_write(wdh, file_externals->firstline,
|
||||
file_externals->firstline_length, err)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (!wftap_dump_file_write(wdh, "\n", 1, err)) {
|
||||
if (!wtap_dump_file_write(wdh, "\n", 1, err)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Also write out saved second line with timestamp corresponding to the
|
||||
opening time of the log.
|
||||
*/
|
||||
if (!wftap_dump_file_write(wdh, file_externals->secondline,
|
||||
if (!wtap_dump_file_write(wdh, file_externals->secondline,
|
||||
file_externals->secondline_length, err)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (!wftap_dump_file_write(wdh, "\n", 1, err)) {
|
||||
if (!wtap_dump_file_write(wdh, "\n", 1, err)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -653,7 +650,7 @@ catapult_dct2000_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
(const void*)&(pseudo_header->dct2000.seek_off));
|
||||
|
||||
/* Write out text before timestamp */
|
||||
if (!wftap_dump_file_write(wdh, prefix->before_time,
|
||||
if (!wtap_dump_file_write(wdh, prefix->before_time,
|
||||
strlen(prefix->before_time), err)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -683,18 +680,18 @@ catapult_dct2000_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
}
|
||||
|
||||
/* Write out the calculated timestamp */
|
||||
if (!wftap_dump_file_write(wdh, time_string, strlen(time_string), err)) {
|
||||
if (!wtap_dump_file_write(wdh, time_string, strlen(time_string), err)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Write out text between timestamp and start of hex data */
|
||||
if (prefix->after_time == NULL) {
|
||||
if (!wftap_dump_file_write(wdh, " l ", strlen(" l "), err)) {
|
||||
if (!wtap_dump_file_write(wdh, " l ", strlen(" l "), err)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!wftap_dump_file_write(wdh, prefix->after_time,
|
||||
if (!wtap_dump_file_write(wdh, prefix->after_time,
|
||||
strlen(prefix->after_time), err)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -736,7 +733,7 @@ catapult_dct2000_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
|
||||
/**************************************/
|
||||
/* Remainder is encapsulated protocol */
|
||||
if (!wftap_dump_file_write(wdh, is_sprint ? " " : "$", 1, err)) {
|
||||
if (!wtap_dump_file_write(wdh, is_sprint ? " " : "$", 1, err)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -748,7 +745,7 @@ catapult_dct2000_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
c[1] = char_from_hex((guint8)(pd[n] & 0x0f));
|
||||
|
||||
/* Write both hex chars of byte together */
|
||||
if (!wftap_dump_file_write(wdh, c, 2, err)) {
|
||||
if (!wtap_dump_file_write(wdh, c, 2, err)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -759,14 +756,14 @@ catapult_dct2000_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
c[0] = pd[n];
|
||||
|
||||
/* Write both hex chars of byte together */
|
||||
if (!wftap_dump_file_write(wdh, c, 1, err)) {
|
||||
if (!wtap_dump_file_write(wdh, c, 1, err)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* End the line */
|
||||
if (!wftap_dump_file_write(wdh, "\n", 1, err)) {
|
||||
if (!wtap_dump_file_write(wdh, "\n", 1, err)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1263,7 +1260,7 @@ parse_line(gchar *linebuff, gint line_length,
|
|||
/* Process results of parse_line() */
|
||||
/***********************************/
|
||||
static void
|
||||
process_parsed_line(wftap *wfth, dct2000_file_externals_t *file_externals,
|
||||
process_parsed_line(wtap *wth, dct2000_file_externals_t *file_externals,
|
||||
struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, gint64 file_offset,
|
||||
char *linebuff, long dollar_offset,
|
||||
|
@ -1364,7 +1361,7 @@ process_parsed_line(wftap *wfth, dct2000_file_externals_t *file_externals,
|
|||
/*****************************************/
|
||||
/* Set packet pseudo-header if necessary */
|
||||
phdr->pseudo_header.dct2000.seek_off = file_offset;
|
||||
phdr->pseudo_header.dct2000.wfth = wfth;
|
||||
phdr->pseudo_header.dct2000.wth = wth;
|
||||
|
||||
switch (encap) {
|
||||
case WTAP_ENCAP_ATM_PDUS_UNTRUNCATED:
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include <glib.h>
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
int catapult_dct2000_open(wftap *wfth, int *err, gchar **err_info);
|
||||
gboolean catapult_dct2000_dump_open(wftap_dumper *wdh, int *err);
|
||||
int catapult_dct2000_open(wtap *wth, int *err, gchar **err_info);
|
||||
gboolean catapult_dct2000_dump_open(wtap_dumper *wdh, int *err);
|
||||
int catapult_dct2000_dump_can_write_encap(int encap);
|
||||
|
||||
#define DCT2000_ENCAP_UNHANDLED 0
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "wtap.h"
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "buffer.h"
|
||||
#include "file_wrappers.h"
|
||||
|
@ -79,20 +78,21 @@ typedef struct commview_header {
|
|||
#define MEDIUM_WIFI 1
|
||||
#define MEDIUM_TOKEN_RING 2
|
||||
|
||||
static gboolean commview_read(wftap *wfth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean commview_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean commview_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean commview_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean commview_read_header(commview_header_t *cv_hdr, FILE_T fh,
|
||||
int *err, gchar **err_info);
|
||||
static gboolean commview_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err);
|
||||
int *err, gchar **err_info);
|
||||
static gboolean commview_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err);
|
||||
|
||||
int commview_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int commview_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
commview_header_t cv_hdr;
|
||||
|
||||
if(!commview_read_header(&cv_hdr, wfth->fh, err, err_info)) {
|
||||
if(!commview_read_header(&cv_hdr, wth->fh, err, err_info)) {
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -114,16 +114,16 @@ int commview_open(wftap *wfth, int *err, gchar **err_info)
|
|||
return 0; /* Not our kind of file */
|
||||
|
||||
/* No file header. Reset the fh to 0 so we can read the first packet */
|
||||
if (file_seek(wfth->fh, 0, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
|
||||
return -1;
|
||||
|
||||
/* Set up the pointers to the handlers for this file type */
|
||||
wfth->subtype_read = commview_read;
|
||||
wfth->subtype_seek_read = commview_seek_read;
|
||||
wth->subtype_read = commview_read;
|
||||
wth->subtype_seek_read = commview_seek_read;
|
||||
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_COMMVIEW;
|
||||
wfth->file_encap = WTAP_ENCAP_PER_PACKET;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_COMMVIEW;
|
||||
wth->file_encap = WTAP_ENCAP_PER_PACKET;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
|
||||
return 1; /* Our kind of file */
|
||||
}
|
||||
|
@ -185,24 +185,22 @@ commview_read_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
commview_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
commview_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
{
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
return commview_read_packet(wfth->fh, &wth->phdr, wfth->frame_buffer, err,
|
||||
return commview_read_packet(wth->fh, &wth->phdr, wth->frame_buffer, err,
|
||||
err_info);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
commview_seek_read(wftap *wfth, gint64 seek_off, void* header,
|
||||
commview_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
if(file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
return commview_read_packet(wfth->random_fh, phdr, buf, err, err_info);
|
||||
return commview_read_packet(wth->random_fh, phdr, buf, err, err_info);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -257,7 +255,7 @@ int commview_dump_can_write_encap(int encap)
|
|||
|
||||
/* Returns TRUE on success, FALSE on failure;
|
||||
sets "*err" to an error code on failure */
|
||||
gboolean commview_dump_open(wftap_dumper *wdh, int *err _U_)
|
||||
gboolean commview_dump_open(wtap_dumper *wdh, int *err _U_)
|
||||
{
|
||||
wdh->subtype_write = commview_dump;
|
||||
wdh->subtype_close = NULL;
|
||||
|
@ -270,7 +268,7 @@ gboolean commview_dump_open(wftap_dumper *wdh, int *err _U_)
|
|||
|
||||
/* Write a record for a packet to a dump file.
|
||||
* Returns TRUE on success, FALSE on failure. */
|
||||
static gboolean commview_dump(wftap_dumper *wdh,
|
||||
static gboolean commview_dump(wtap_dumper *wdh,
|
||||
const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err)
|
||||
{
|
||||
|
@ -328,45 +326,45 @@ static gboolean commview_dump(wftap_dumper *wdh,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.data_len, 2, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.data_len, 2, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.source_data_len, 2, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.source_data_len, 2, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.version, 1, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.version, 1, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.year, 2, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.year, 2, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.month, 1, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.month, 1, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.day, 1, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.day, 1, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.hours, 1, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.hours, 1, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.minutes, 1, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.minutes, 1, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.seconds, 1, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.seconds, 1, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.usecs, 4, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.usecs, 4, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.flags, 1, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.flags, 1, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.signal_level_percent, 1, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.signal_level_percent, 1, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.rate, 1, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.rate, 1, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.band, 1, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.band, 1, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.channel, 1, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.channel, 1, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.direction, 1, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.direction, 1, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.signal_level_dbm, 2, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.signal_level_dbm, 2, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &cv_hdr.noise_level, 2, err))
|
||||
if (!wtap_dump_file_write(wdh, &cv_hdr.noise_level, 2, err))
|
||||
return FALSE;
|
||||
wdh->bytes_dumped += COMMVIEW_HEADER_SIZE;
|
||||
|
||||
if (!wftap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
return FALSE;
|
||||
wdh->bytes_dumped += phdr->caplen;
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
#include <glib.h>
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
int commview_open(wftap *wfth, int *err, gchar **err_info _U_);
|
||||
int commview_open(wtap *wth, int *err, gchar **err_info _U_);
|
||||
int commview_dump_can_write_encap(int encap);
|
||||
gboolean commview_dump_open(wftap_dumper *wdh, int *err);
|
||||
gboolean commview_dump_open(wtap_dumper *wdh, int *err);
|
||||
|
||||
#endif /* __COMMVIEW_H__ */
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "buffer.h"
|
||||
#include "cosine.h"
|
||||
|
@ -164,13 +163,13 @@
|
|||
#define COSINE_MAX_PACKET_LEN 65536
|
||||
|
||||
static gboolean empty_line(const gchar *line);
|
||||
static gint64 cosine_seek_next_packet(wftap *wfth, int *err, gchar **err_info,
|
||||
static gint64 cosine_seek_next_packet(wtap *wth, int *err, gchar **err_info,
|
||||
char *hdr);
|
||||
static gboolean cosine_check_file_type(wftap *wfth, int *err, gchar **err_info);
|
||||
static gboolean cosine_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean cosine_check_file_type(wtap *wth, int *err, gchar **err_info);
|
||||
static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean cosine_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean cosine_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
static int parse_cosine_rec_hdr(struct wtap_pkthdr *phdr, const char *line,
|
||||
int *err, gchar **err_info);
|
||||
static gboolean parse_cosine_hex_dump(FILE_T fh, struct wtap_pkthdr *phdr,
|
||||
|
@ -200,21 +199,21 @@ static gboolean empty_line(const gchar *line)
|
|||
byte offset. Copy the header line to hdr. Returns -1 on failure,
|
||||
and sets "*err" to the error and sets "*err_info" to null or an
|
||||
additional error string. */
|
||||
static gint64 cosine_seek_next_packet(wftap *wfth, int *err, gchar **err_info,
|
||||
static gint64 cosine_seek_next_packet(wtap *wth, int *err, gchar **err_info,
|
||||
char *hdr)
|
||||
{
|
||||
gint64 cur_off;
|
||||
char buf[COSINE_LINE_LENGTH];
|
||||
|
||||
while (1) {
|
||||
cur_off = file_tell(wfth->fh);
|
||||
cur_off = file_tell(wth->fh);
|
||||
if (cur_off == -1) {
|
||||
/* Error */
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return -1;
|
||||
}
|
||||
if (file_gets(buf, sizeof(buf), wfth->fh) == NULL) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
if (file_gets(buf, sizeof(buf), wth->fh) == NULL) {
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return -1;
|
||||
}
|
||||
if (strstr(buf, COSINE_REC_MAGIC_STR1) ||
|
||||
|
@ -233,7 +232,7 @@ static gint64 cosine_seek_next_packet(wftap *wfth, int *err, gchar **err_info,
|
|||
* if we get an I/O error, "*err" will be set to a non-zero value and
|
||||
* "*err_info" will be set to null or an additional error string.
|
||||
*/
|
||||
static gboolean cosine_check_file_type(wftap *wfth, int *err, gchar **err_info)
|
||||
static gboolean cosine_check_file_type(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
char buf[COSINE_LINE_LENGTH];
|
||||
gsize reclen;
|
||||
|
@ -242,9 +241,9 @@ static gboolean cosine_check_file_type(wftap *wfth, int *err, gchar **err_info)
|
|||
buf[COSINE_LINE_LENGTH-1] = '\0';
|
||||
|
||||
for (line = 0; line < COSINE_HEADER_LINES_TO_CHECK; line++) {
|
||||
if (file_gets(buf, COSINE_LINE_LENGTH, wfth->fh) == NULL) {
|
||||
if (file_gets(buf, COSINE_LINE_LENGTH, wth->fh) == NULL) {
|
||||
/* EOF or error. */
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -264,39 +263,38 @@ static gboolean cosine_check_file_type(wftap *wfth, int *err, gchar **err_info)
|
|||
}
|
||||
|
||||
|
||||
int cosine_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int cosine_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
/* Look for CoSine header */
|
||||
if (!cosine_check_file_type(wfth, err, err_info)) {
|
||||
if (!cosine_check_file_type(wth, err, err_info)) {
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (file_seek(wfth->fh, 0L, SEEK_SET, err) == -1) /* rewind */
|
||||
if (file_seek(wth->fh, 0L, SEEK_SET, err) == -1) /* rewind */
|
||||
return -1;
|
||||
|
||||
wfth->file_encap = WTAP_ENCAP_COSINE;
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_COSINE;
|
||||
wfth->snapshot_length = 0; /* not known */
|
||||
wfth->subtype_read = cosine_read;
|
||||
wfth->subtype_seek_read = cosine_seek_read;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_CSEC;
|
||||
wth->file_encap = WTAP_ENCAP_COSINE;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_COSINE;
|
||||
wth->snapshot_length = 0; /* not known */
|
||||
wth->subtype_read = cosine_read;
|
||||
wth->subtype_seek_read = cosine_seek_read;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_CSEC;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Find the next packet and parse it; called from wtap_read(). */
|
||||
static gboolean cosine_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean cosine_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
gint64 offset;
|
||||
int pkt_len;
|
||||
char line[COSINE_LINE_LENGTH];
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
/* Find the next packet */
|
||||
offset = cosine_seek_next_packet(wfth, err, err_info, line);
|
||||
offset = cosine_seek_next_packet(wth, err, err_info, line);
|
||||
if (offset < 0)
|
||||
return FALSE;
|
||||
*data_offset = offset;
|
||||
|
@ -307,24 +305,23 @@ static gboolean cosine_read(wftap *wfth, int *err, gchar **err_info,
|
|||
return FALSE;
|
||||
|
||||
/* Convert the ASCII hex dump to binary data */
|
||||
return parse_cosine_hex_dump(wfth->fh, &wth->phdr, pkt_len,
|
||||
wfth->frame_buffer, err, err_info);
|
||||
return parse_cosine_hex_dump(wth->fh, &wth->phdr, pkt_len,
|
||||
wth->frame_buffer, err, err_info);
|
||||
}
|
||||
|
||||
/* Used to read packets in random-access fashion */
|
||||
static gboolean
|
||||
cosine_seek_read(wftap *wfth, gint64 seek_off, void* header,
|
||||
cosine_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
int pkt_len;
|
||||
char line[COSINE_LINE_LENGTH];
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr*)header;
|
||||
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
if (file_gets(line, COSINE_LINE_LENGTH, wfth->random_fh) == NULL) {
|
||||
*err = file_error(wfth->random_fh, err_info);
|
||||
if (file_gets(line, COSINE_LINE_LENGTH, wth->random_fh) == NULL) {
|
||||
*err = file_error(wth->random_fh, err_info);
|
||||
if (*err == 0) {
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
}
|
||||
|
@ -337,7 +334,7 @@ cosine_seek_read(wftap *wfth, gint64 seek_off, void* header,
|
|||
return FALSE;
|
||||
|
||||
/* Convert the ASCII hex dump to binary data */
|
||||
return parse_cosine_hex_dump(wfth->random_fh, phdr, pkt_len, buf, err,
|
||||
return parse_cosine_hex_dump(wth->random_fh, phdr, pkt_len, buf, err,
|
||||
err_info);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,6 @@
|
|||
#include <wtap.h>
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
int cosine_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int cosine_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "buffer.h"
|
||||
#include "csids.h"
|
||||
|
@ -45,10 +44,10 @@ typedef struct {
|
|||
gboolean byteswapped;
|
||||
} csids_t;
|
||||
|
||||
static gboolean csids_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean csids_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean csids_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean csids_read_packet(FILE_T fh, csids_t *csids,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
|
||||
|
@ -59,7 +58,7 @@ struct csids_header {
|
|||
};
|
||||
|
||||
/* XXX - return -1 on I/O error and actually do something with 'err'. */
|
||||
int csids_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int csids_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
/* There is no file header. There is only a header for each packet
|
||||
* so we read a packet header and compare the caplen with iplen. They
|
||||
|
@ -76,30 +75,30 @@ int csids_open(wftap *wfth, int *err, gchar **err_info)
|
|||
csids_t *csids;
|
||||
|
||||
/* check the file to make sure it is a csids file. */
|
||||
bytesRead = file_read( &hdr, sizeof( struct csids_header), wfth->fh );
|
||||
bytesRead = file_read( &hdr, sizeof( struct csids_header), wth->fh );
|
||||
if( bytesRead != sizeof( struct csids_header) ) {
|
||||
*err = file_error( wfth->fh, err_info );
|
||||
*err = file_error( wth->fh, err_info );
|
||||
if( *err != 0 && *err != WTAP_ERR_SHORT_READ ) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if( hdr.zeropad != 0 || hdr.caplen == 0 ) {
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
hdr.seconds = pntoh32( &hdr.seconds );
|
||||
hdr.caplen = pntoh16( &hdr.caplen );
|
||||
bytesRead = file_read( &tmp, 2, wfth->fh );
|
||||
bytesRead = file_read( &tmp, 2, wth->fh );
|
||||
if( bytesRead != 2 ) {
|
||||
*err = file_error( wfth->fh, err_info );
|
||||
*err = file_error( wth->fh, err_info );
|
||||
if( *err != 0 && *err != WTAP_ERR_SHORT_READ ) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
bytesRead = file_read( &iplen, 2, wfth->fh );
|
||||
bytesRead = file_read( &iplen, 2, wth->fh );
|
||||
if( bytesRead != 2 ) {
|
||||
*err = file_error( wfth->fh, err_info );
|
||||
*err = file_error( wth->fh, err_info );
|
||||
if( *err != 0 && *err != WTAP_ERR_SHORT_READ ) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -128,51 +127,49 @@ int csids_open(wftap *wfth, int *err, gchar **err_info)
|
|||
}
|
||||
|
||||
/* no file header. So reset the fh to 0 so we can read the first packet */
|
||||
if (file_seek(wfth->fh, 0, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
|
||||
return -1;
|
||||
|
||||
csids = (csids_t *)g_malloc(sizeof(csids_t));
|
||||
wfth->priv = (void *)csids;
|
||||
wth->priv = (void *)csids;
|
||||
csids->byteswapped = byteswap;
|
||||
wfth->file_encap = WTAP_ENCAP_RAW_IP;
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_CSIDS;
|
||||
wfth->snapshot_length = 0; /* not known */
|
||||
wfth->subtype_read = csids_read;
|
||||
wfth->subtype_seek_read = csids_seek_read;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_SEC;
|
||||
wth->file_encap = WTAP_ENCAP_RAW_IP;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_CSIDS;
|
||||
wth->snapshot_length = 0; /* not known */
|
||||
wth->subtype_read = csids_read;
|
||||
wth->subtype_seek_read = csids_seek_read;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Find the next packet and parse it; called from wtap_read(). */
|
||||
static gboolean csids_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
csids_t *csids = (csids_t *)wfth->priv;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
csids_t *csids = (csids_t *)wth->priv;
|
||||
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
return csids_read_packet( wfth->fh, csids, &wth->phdr, wfth->frame_buffer,
|
||||
return csids_read_packet( wth->fh, csids, &wth->phdr, wth->frame_buffer,
|
||||
err, err_info );
|
||||
}
|
||||
|
||||
/* Used to read packets in random-access fashion */
|
||||
static gboolean
|
||||
csids_seek_read(wftap *wfth,
|
||||
csids_seek_read(wtap *wth,
|
||||
gint64 seek_off,
|
||||
void* header,
|
||||
struct wtap_pkthdr *phdr,
|
||||
Buffer *buf,
|
||||
int *err,
|
||||
gchar **err_info)
|
||||
{
|
||||
csids_t *csids = (csids_t *)wfth->priv;
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
csids_t *csids = (csids_t *)wth->priv;
|
||||
|
||||
if( file_seek( wfth->random_fh, seek_off, SEEK_SET, err ) == -1 )
|
||||
if( file_seek( wth->random_fh, seek_off, SEEK_SET, err ) == -1 )
|
||||
return FALSE;
|
||||
|
||||
if( !csids_read_packet( wfth->random_fh, csids, phdr, buf, err, err_info ) ) {
|
||||
if( !csids_read_packet( wth->random_fh, csids, phdr, buf, err, err_info ) ) {
|
||||
if( *err == 0 )
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return FALSE;
|
||||
|
|
|
@ -25,6 +25,6 @@
|
|||
#include <wtap.h>
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
int csids_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int csids_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* daintree-sna.c
|
||||
/* daintree_sna.c
|
||||
* Routines for opening .dcf capture files created by Daintree's
|
||||
* Sensor Network Analyzer for 802.15.4 radios
|
||||
* Copyright 2009, Exegin Technologies Limited <fff@exegin.com>
|
||||
|
@ -54,7 +54,6 @@
|
|||
#include <ctype.h>
|
||||
|
||||
#include "wtap.h"
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "buffer.h"
|
||||
#include "file_wrappers.h"
|
||||
|
@ -78,11 +77,11 @@ static const char daintree_magic_text[] =
|
|||
|
||||
#define COMMENT_LINE daintree_magic_text[0]
|
||||
|
||||
static gboolean daintree_sna_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean daintree_sna_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
|
||||
static gboolean daintree_sna_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean daintree_sna_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
|
||||
static gboolean daintree_sna_scan_header(struct wtap_pkthdr *phdr,
|
||||
char *readLine, char *readData, int *err, gchar **err_info);
|
||||
|
@ -91,14 +90,14 @@ static gboolean daintree_sna_process_hex_data(struct wtap_pkthdr *phdr,
|
|||
Buffer *buf, char *readData, int *err, gchar **err_info);
|
||||
|
||||
/* Open a file and determine if it's a Daintree file */
|
||||
int daintree_sna_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int daintree_sna_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
char readLine[DAINTREE_MAX_LINE_SIZE];
|
||||
guint i;
|
||||
|
||||
/* get first line of file header */
|
||||
if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wfth->fh)==NULL) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->fh)==NULL) {
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -112,8 +111,8 @@ int daintree_sna_open(wftap *wfth, int *err, gchar **err_info)
|
|||
}
|
||||
|
||||
/* read second header line */
|
||||
if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wfth->fh)==NULL) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->fh)==NULL) {
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -121,14 +120,14 @@ int daintree_sna_open(wftap *wfth, int *err, gchar **err_info)
|
|||
if (readLine[0] != COMMENT_LINE) return 0; /* daintree files have a two line header */
|
||||
|
||||
/* set up the pointers to the handlers for this file type */
|
||||
wfth->subtype_read = daintree_sna_read;
|
||||
wfth->subtype_seek_read = daintree_sna_seek_read;
|
||||
wth->subtype_read = daintree_sna_read;
|
||||
wth->subtype_seek_read = daintree_sna_seek_read;
|
||||
|
||||
/* set up for file type */
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_DAINTREE_SNA;
|
||||
wfth->file_encap = WTAP_ENCAP_IEEE802_15_4_NOFCS;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wfth->snapshot_length = 0; /* not available in header */
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_DAINTREE_SNA;
|
||||
wth->file_encap = WTAP_ENCAP_IEEE802_15_4_NOFCS;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wth->snapshot_length = 0; /* not available in header */
|
||||
|
||||
return 1; /* it's a Daintree file */
|
||||
}
|
||||
|
@ -136,19 +135,18 @@ int daintree_sna_open(wftap *wfth, int *err, gchar **err_info)
|
|||
/* Read the capture file sequentially
|
||||
* Wireshark scans the file with sequential reads during preview and initial display. */
|
||||
static gboolean
|
||||
daintree_sna_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
daintree_sna_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
{
|
||||
char readLine[DAINTREE_MAX_LINE_SIZE];
|
||||
char readData[READDATA_BUF_SIZE];
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
/* we've only seen file header lines starting with '#', but
|
||||
* if others appear in the file, they are tossed */
|
||||
do {
|
||||
if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wfth->fh) == NULL) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->fh) == NULL) {
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return FALSE; /* all done */
|
||||
}
|
||||
} while (readLine[0] == COMMENT_LINE);
|
||||
|
@ -159,28 +157,27 @@ daintree_sna_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
|||
return FALSE;
|
||||
|
||||
/* process packet data */
|
||||
return daintree_sna_process_hex_data(&wth->phdr, wfth->frame_buffer,
|
||||
return daintree_sna_process_hex_data(&wth->phdr, wth->frame_buffer,
|
||||
readData, err, err_info);
|
||||
}
|
||||
|
||||
/* Read the capture file randomly
|
||||
* Wireshark opens the capture file for random access when displaying user-selected packets */
|
||||
static gboolean
|
||||
daintree_sna_seek_read(wftap *wfth, gint64 seek_off, void* header,
|
||||
daintree_sna_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
char readLine[DAINTREE_MAX_LINE_SIZE];
|
||||
char readData[READDATA_BUF_SIZE];
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
|
||||
if(file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if(file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
/* It appears only file header lines start with '#', but
|
||||
* if we find any others, we toss them */
|
||||
do {
|
||||
if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wfth->random_fh) == NULL) {
|
||||
*err = file_error(wfth->random_fh, err_info);
|
||||
if (file_gets(readLine, DAINTREE_MAX_LINE_SIZE, wth->random_fh) == NULL) {
|
||||
*err = file_error(wth->random_fh, err_info);
|
||||
return FALSE; /* all done */
|
||||
}
|
||||
} while (readLine[0] == COMMENT_LINE);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <wtap.h>
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
int daintree_sna_open(wftap *wfth, int *err, gchar **err_info _U_);
|
||||
int daintree_sna_open(wtap *wth, int *err, gchar **err_info _U_);
|
||||
|
||||
#endif /* __DAINTREE_SNA_H__ */
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "buffer.h"
|
||||
#include "dbs-etherwatch.h"
|
||||
|
@ -85,10 +84,10 @@ static const char dbs_etherwatch_rec_magic[] =
|
|||
*/
|
||||
#define DBS_ETHERWATCH_MAX_PACKET_LEN 16384
|
||||
|
||||
static gboolean dbs_etherwatch_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean dbs_etherwatch_seek_read(wftap *wth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh,
|
||||
Buffer* buf, int *err, gchar **err_info);
|
||||
static guint parse_single_hex_dump_line(char* rec, guint8 *buf,
|
||||
|
@ -98,22 +97,22 @@ static guint parse_hex_dump(char* dump, guint8 *buf, char seperator, char end);
|
|||
/* Seeks to the beginning of the next packet, and returns the
|
||||
byte offset. Returns -1 on failure, and sets "*err" to the error
|
||||
and "*err_info" to null or an additional error string. */
|
||||
static gint64 dbs_etherwatch_seek_next_packet(wftap *wfth, int *err,
|
||||
static gint64 dbs_etherwatch_seek_next_packet(wtap *wth, int *err,
|
||||
gchar **err_info)
|
||||
{
|
||||
int byte;
|
||||
unsigned int level = 0;
|
||||
gint64 cur_off;
|
||||
|
||||
while ((byte = file_getc(wfth->fh)) != EOF) {
|
||||
while ((byte = file_getc(wth->fh)) != EOF) {
|
||||
if (byte == dbs_etherwatch_rec_magic[level]) {
|
||||
level++;
|
||||
if (level >= DBS_ETHERWATCH_REC_MAGIC_SIZE) {
|
||||
/* note: we're leaving file pointer right after the magic characters */
|
||||
cur_off = file_tell(wfth->fh);
|
||||
cur_off = file_tell(wth->fh);
|
||||
if (cur_off == -1) {
|
||||
/* Error. */
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return -1;
|
||||
}
|
||||
return cur_off + 1;
|
||||
|
@ -123,7 +122,7 @@ static gint64 dbs_etherwatch_seek_next_packet(wftap *wfth, int *err,
|
|||
}
|
||||
}
|
||||
/* EOF or error. */
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -137,7 +136,7 @@ static gint64 dbs_etherwatch_seek_next_packet(wftap *wfth, int *err,
|
|||
* if we get an I/O error, "*err" will be set to a non-zero value and
|
||||
* "*err_info" will be set to null or an error string.
|
||||
*/
|
||||
static gboolean dbs_etherwatch_check_file_type(wftap *wfth, int *err,
|
||||
static gboolean dbs_etherwatch_check_file_type(wtap *wth, int *err,
|
||||
gchar **err_info)
|
||||
{
|
||||
char buf[DBS_ETHERWATCH_LINE_LENGTH];
|
||||
|
@ -148,9 +147,9 @@ static gboolean dbs_etherwatch_check_file_type(wftap *wfth, int *err,
|
|||
buf[DBS_ETHERWATCH_LINE_LENGTH-1] = 0;
|
||||
|
||||
for (line = 0; line < DBS_ETHERWATCH_HEADER_LINES_TO_CHECK; line++) {
|
||||
if (file_gets(buf, DBS_ETHERWATCH_LINE_LENGTH, wfth->fh) == NULL) {
|
||||
if (file_gets(buf, DBS_ETHERWATCH_LINE_LENGTH, wth->fh) == NULL) {
|
||||
/* EOF or error. */
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -177,53 +176,51 @@ static gboolean dbs_etherwatch_check_file_type(wftap *wfth, int *err,
|
|||
}
|
||||
|
||||
|
||||
int dbs_etherwatch_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
/* Look for DBS ETHERWATCH header */
|
||||
if (!dbs_etherwatch_check_file_type(wfth, err, err_info)) {
|
||||
if (!dbs_etherwatch_check_file_type(wth, err, err_info)) {
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
wfth->file_encap = WTAP_ENCAP_ETHERNET;
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_DBS_ETHERWATCH;
|
||||
wfth->snapshot_length = 0; /* not known */
|
||||
wfth->subtype_read = dbs_etherwatch_read;
|
||||
wfth->subtype_seek_read = dbs_etherwatch_seek_read;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_CSEC;
|
||||
wth->file_encap = WTAP_ENCAP_ETHERNET;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_DBS_ETHERWATCH;
|
||||
wth->snapshot_length = 0; /* not known */
|
||||
wth->subtype_read = dbs_etherwatch_read;
|
||||
wth->subtype_seek_read = dbs_etherwatch_seek_read;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_CSEC;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Find the next packet and parse it; called from wtap_read(). */
|
||||
static gboolean dbs_etherwatch_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
gint64 offset;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
/* Find the next packet */
|
||||
offset = dbs_etherwatch_seek_next_packet(wfth, err, err_info);
|
||||
offset = dbs_etherwatch_seek_next_packet(wth, err, err_info);
|
||||
if (offset < 1)
|
||||
return FALSE;
|
||||
*data_offset = offset;
|
||||
|
||||
/* Parse the packet */
|
||||
return parse_dbs_etherwatch_packet(&wth->phdr, wfth->fh,
|
||||
wfth->frame_buffer, err, err_info);
|
||||
return parse_dbs_etherwatch_packet(&wth->phdr, wth->fh,
|
||||
wth->frame_buffer, err, err_info);
|
||||
}
|
||||
|
||||
/* Used to read packets in random-access fashion */
|
||||
static gboolean
|
||||
dbs_etherwatch_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info)
|
||||
dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr*)header;
|
||||
if (file_seek(wfth->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 parse_dbs_etherwatch_packet(phdr, wfth->random_fh, buf, err,
|
||||
return parse_dbs_etherwatch_packet(phdr, wth->random_fh, buf, err,
|
||||
err_info);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,6 @@
|
|||
#include <wtap.h>
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
int dbs_etherwatch_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "buffer.h"
|
||||
#include "dct3trace.h"
|
||||
|
@ -74,10 +73,10 @@ static const char dct3trace_magic_end[] = "</dump>";
|
|||
|
||||
#define MAX_PACKET_LEN 23
|
||||
|
||||
static gboolean dct3trace_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean dct3trace_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
|
||||
/*
|
||||
* Following 3 functions taken from gsmdecode-0.7bis, with permission - http://wiki.thc.org/gsm
|
||||
|
@ -156,15 +155,15 @@ xml_get_int(int *val, const char *str, const char *pattern)
|
|||
}
|
||||
|
||||
|
||||
int dct3trace_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int dct3trace_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
char line1[64], line2[64];
|
||||
|
||||
/* Look for Gammu DCT3 trace header */
|
||||
if (file_gets(line1, sizeof(line1), wfth->fh) == NULL ||
|
||||
file_gets(line2, sizeof(line2), wfth->fh) == NULL)
|
||||
if (file_gets(line1, sizeof(line1), wth->fh) == NULL ||
|
||||
file_gets(line2, sizeof(line2), wth->fh) == NULL)
|
||||
{
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -177,12 +176,12 @@ int dct3trace_open(wftap *wfth, int *err, gchar **err_info)
|
|||
return 0;
|
||||
}
|
||||
|
||||
wfth->file_encap = WTAP_ENCAP_GSM_UM;
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_DCT3TRACE;
|
||||
wfth->snapshot_length = 0; /* not known */
|
||||
wfth->subtype_read = dct3trace_read;
|
||||
wfth->subtype_seek_read = dct3trace_seek_read;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_SEC;
|
||||
wth->file_encap = WTAP_ENCAP_GSM_UM;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_DCT3TRACE;
|
||||
wth->snapshot_length = 0; /* not known */
|
||||
wth->subtype_read = dct3trace_read;
|
||||
wth->subtype_seek_read = dct3trace_seek_read;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -347,26 +346,24 @@ baddata:
|
|||
|
||||
|
||||
/* Find the next packet and parse it; called from wtap_read(). */
|
||||
static gboolean dct3trace_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean dct3trace_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
return dct3trace_get_packet(wfth->fh, &wth->phdr, wfth->frame_buffer,
|
||||
return dct3trace_get_packet(wth->fh, &wth->phdr, wth->frame_buffer,
|
||||
err, err_info);
|
||||
}
|
||||
|
||||
|
||||
/* Used to read packets in random-access fashion */
|
||||
static gboolean dct3trace_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info)
|
||||
static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr*)header;
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return dct3trace_get_packet(wfth->random_fh, phdr, buf, err, err_info);
|
||||
return dct3trace_get_packet(wth->random_fh, phdr, buf, err, err_info);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,6 @@
|
|||
#include <wtap.h>
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
int dct3trace_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int dct3trace_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* erf.c
|
||||
/*
|
||||
* Copyright (c) 2003 Endace Technology Ltd, Hamilton, New Zealand.
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -50,7 +50,6 @@
|
|||
|
||||
#include <wsutil/crc32.h>
|
||||
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -65,10 +64,10 @@ static int erf_read_header(FILE_T fh,
|
|||
gchar **err_info,
|
||||
guint32 *bytes_read,
|
||||
guint32 *packet_size);
|
||||
static gboolean erf_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean erf_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf,
|
||||
static gboolean erf_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
||||
int *err, gchar **err_info);
|
||||
|
||||
static const struct {
|
||||
|
@ -87,7 +86,7 @@ static const struct {
|
|||
|
||||
#define NUM_ERF_ENCAPS (sizeof erf_to_wtap_map / sizeof erf_to_wtap_map[0])
|
||||
|
||||
extern int erf_open(wftap *wfth, int *err, gchar **err_info)
|
||||
extern int erf_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
int i, n, records_for_erf_check = RECORDS_FOR_ERF_CHECK;
|
||||
int valid_prev = 0;
|
||||
|
@ -102,7 +101,6 @@ extern int erf_open(wftap *wfth, int *err, gchar **err_info)
|
|||
guint8 type;
|
||||
size_t r;
|
||||
gchar * buffer;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
memset(&prevts, 0, sizeof(prevts));
|
||||
|
||||
|
@ -121,11 +119,11 @@ extern int erf_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
for (i = 0; i < records_for_erf_check; i++) { /* records_for_erf_check */
|
||||
|
||||
r = file_read(&header,sizeof(header),wfth->fh);
|
||||
r = file_read(&header,sizeof(header),wth->fh);
|
||||
|
||||
if (r == 0 ) break;
|
||||
if (r != sizeof(header)) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ) {
|
||||
return -1;
|
||||
} else {
|
||||
|
@ -160,7 +158,7 @@ extern int erf_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
/* Skip PAD records, timestamps may not be set */
|
||||
if ((header.type & 0x7F) == ERF_TYPE_PAD) {
|
||||
if (file_seek(wfth->fh, packet_size, SEEK_CUR, err) == -1) {
|
||||
if (file_seek(wth->fh, packet_size, SEEK_CUR, err) == -1) {
|
||||
return -1;
|
||||
}
|
||||
continue;
|
||||
|
@ -194,8 +192,8 @@ extern int erf_open(wftap *wfth, int *err, gchar **err_info)
|
|||
/* Read over the extension headers */
|
||||
type = header.type;
|
||||
while (type & 0x80){
|
||||
if (file_read(&erf_ext_header, sizeof(erf_ext_header),wfth->fh) != sizeof(erf_ext_header)) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
if (file_read(&erf_ext_header, sizeof(erf_ext_header),wth->fh) != sizeof(erf_ext_header)) {
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return -1;
|
||||
|
@ -215,8 +213,8 @@ extern int erf_open(wftap *wfth, int *err, gchar **err_info)
|
|||
case ERF_TYPE_MC_AAL2:
|
||||
case ERF_TYPE_COLOR_MC_HDLC_POS:
|
||||
case ERF_TYPE_AAL2: /* not an MC type but has a similar 'AAL2 ext' header */
|
||||
if (file_read(&mc_hdr,sizeof(mc_hdr),wfth->fh) != sizeof(mc_hdr)) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
if (file_read(&mc_hdr,sizeof(mc_hdr),wth->fh) != sizeof(mc_hdr)) {
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return -1;
|
||||
}
|
||||
packet_size -= (guint32)sizeof(mc_hdr);
|
||||
|
@ -224,8 +222,8 @@ extern int erf_open(wftap *wfth, int *err, gchar **err_info)
|
|||
case ERF_TYPE_ETH:
|
||||
case ERF_TYPE_COLOR_ETH:
|
||||
case ERF_TYPE_DSM_COLOR_ETH:
|
||||
if (file_read(ð_hdr,sizeof(eth_hdr),wfth->fh) != sizeof(eth_hdr)) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
if (file_read(ð_hdr,sizeof(eth_hdr),wth->fh) != sizeof(eth_hdr)) {
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return -1;
|
||||
}
|
||||
packet_size -= (guint32)sizeof(eth_hdr);
|
||||
|
@ -244,7 +242,7 @@ extern int erf_open(wftap *wfth, int *err, gchar **err_info)
|
|||
return 0;
|
||||
}
|
||||
buffer=(gchar *)g_malloc(packet_size);
|
||||
r = file_read(buffer, packet_size, wfth->fh);
|
||||
r = file_read(buffer, packet_size, wth->fh);
|
||||
g_free(buffer);
|
||||
|
||||
if (r != packet_size) {
|
||||
|
@ -259,22 +257,22 @@ extern int erf_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
} /* records_for_erf_check */
|
||||
|
||||
if (file_seek(wfth->fh, 0L, SEEK_SET, err) == -1) { /* rewind */
|
||||
if (file_seek(wth->fh, 0L, SEEK_SET, err) == -1) { /* rewind */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* This is an ERF file */
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_ERF;
|
||||
wfth->snapshot_length = 0; /* not available in header, only in frame */
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_ERF;
|
||||
wth->snapshot_length = 0; /* not available in header, only in frame */
|
||||
|
||||
/*
|
||||
* Use the encapsulation for ERF records.
|
||||
*/
|
||||
wfth->file_encap = WTAP_ENCAP_ERF;
|
||||
wth->file_encap = WTAP_ENCAP_ERF;
|
||||
|
||||
wfth->subtype_read = erf_read;
|
||||
wfth->subtype_seek_read = erf_seek_read;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
wth->subtype_read = erf_read;
|
||||
wth->subtype_seek_read = erf_seek_read;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
|
||||
erf_populate_interfaces(wth);
|
||||
|
||||
|
@ -282,23 +280,22 @@ extern int erf_open(wftap *wfth, int *err, gchar **err_info)
|
|||
}
|
||||
|
||||
/* Read the next packet */
|
||||
static gboolean erf_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean erf_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
erf_header_t erf_header;
|
||||
guint32 packet_size, bytes_read;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
do {
|
||||
if (!erf_read_header(wfth->fh,
|
||||
if (!erf_read_header(wth->fh,
|
||||
&wth->phdr, &erf_header,
|
||||
err, err_info, &bytes_read, &packet_size)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!wtap_read_packet_bytes(wfth->fh, wfth->frame_buffer, packet_size,
|
||||
if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer, packet_size,
|
||||
err, err_info))
|
||||
return FALSE;
|
||||
|
||||
|
@ -307,24 +304,23 @@ static gboolean erf_read(wftap *wfth, int *err, gchar **err_info,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean erf_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf,
|
||||
static gboolean erf_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
||||
int *err, gchar **err_info)
|
||||
{
|
||||
erf_header_t erf_header;
|
||||
guint32 packet_size;
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr*)header;
|
||||
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
do {
|
||||
if (!erf_read_header(wfth->random_fh, phdr, &erf_header,
|
||||
if (!erf_read_header(wth->random_fh, phdr, &erf_header,
|
||||
err, err_info, NULL, &packet_size))
|
||||
return FALSE;
|
||||
} while ( erf_header.type == ERF_TYPE_PAD );
|
||||
|
||||
return wtap_read_packet_bytes(wfth->random_fh, buf, packet_size,
|
||||
return wtap_read_packet_bytes(wth->random_fh, buf, packet_size,
|
||||
err, err_info);
|
||||
}
|
||||
|
||||
|
@ -506,7 +502,7 @@ static int wtap_wtap_encap_to_erf_encap(int encap)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static gboolean erf_write_phdr(wftap_dumper *wdh, int encap, const union wtap_pseudo_header *pseudo_header, int * err)
|
||||
static gboolean erf_write_phdr(wtap_dumper *wdh, int encap, const union wtap_pseudo_header *pseudo_header, int * err)
|
||||
{
|
||||
guint8 erf_hdr[sizeof(struct erf_mc_phdr)];
|
||||
guint8 erf_subhdr[((sizeof(struct erf_mc_hdr) > sizeof(struct erf_eth_hdr))?
|
||||
|
@ -553,7 +549,7 @@ static gboolean erf_write_phdr(wftap_dumper *wdh, int encap, const union wtap_ps
|
|||
return FALSE;
|
||||
|
||||
}
|
||||
if (!wftap_dump_file_write(wdh, erf_hdr, size, err))
|
||||
if (!wtap_dump_file_write(wdh, erf_hdr, size, err))
|
||||
return FALSE;
|
||||
wdh->bytes_dumped += size;
|
||||
|
||||
|
@ -566,12 +562,12 @@ static gboolean erf_write_phdr(wftap_dumper *wdh, int encap, const union wtap_ps
|
|||
has_more = ehdr[i*8] & 0x80;
|
||||
i++;
|
||||
}while(has_more && i < MAX_ERF_EHDR);
|
||||
if (!wftap_dump_file_write(wdh, ehdr, 8*i, err))
|
||||
if (!wtap_dump_file_write(wdh, ehdr, 8*i, err))
|
||||
return FALSE;
|
||||
wdh->bytes_dumped += 8*i;
|
||||
}
|
||||
|
||||
if(!wftap_dump_file_write(wdh, erf_subhdr, subhdr_size, err))
|
||||
if(!wtap_dump_file_write(wdh, erf_subhdr, subhdr_size, err))
|
||||
return FALSE;
|
||||
wdh->bytes_dumped += subhdr_size;
|
||||
|
||||
|
@ -579,7 +575,7 @@ static gboolean erf_write_phdr(wftap_dumper *wdh, int encap, const union wtap_ps
|
|||
}
|
||||
|
||||
static gboolean erf_dump(
|
||||
wftap_dumper *wdh,
|
||||
wtap_dumper *wdh,
|
||||
const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd,
|
||||
int *err)
|
||||
|
@ -611,7 +607,7 @@ static gboolean erf_dump(
|
|||
|
||||
if(!erf_write_phdr(wdh, encap, pseudo_header, err)) return FALSE;
|
||||
|
||||
if(!wftap_dump_file_write(wdh, pd, phdr->caplen, err)) return FALSE;
|
||||
if(!wtap_dump_file_write(wdh, pd, phdr->caplen, err)) return FALSE;
|
||||
wdh->bytes_dumped += phdr->caplen;
|
||||
|
||||
/*XXX: this pads the record to its original length, which is fine in most
|
||||
|
@ -620,7 +616,7 @@ static gboolean erf_dump(
|
|||
* More than 8 extension headers is unusual though, only the first 8 are
|
||||
* written out anyway and fixing properly would require major refactor.*/
|
||||
while(wdh->bytes_dumped < alignbytes){
|
||||
if(!wftap_dump_file_write(wdh, "", 1, err)) return FALSE;
|
||||
if(!wtap_dump_file_write(wdh, "", 1, err)) return FALSE;
|
||||
wdh->bytes_dumped++;
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -673,18 +669,18 @@ static gboolean erf_dump(
|
|||
}
|
||||
|
||||
if(!erf_write_phdr(wdh, WTAP_ENCAP_ERF, &other_phdr, err)) return FALSE;
|
||||
if(!wftap_dump_file_write(wdh, pd, phdr->caplen - round_down, err)) return FALSE;
|
||||
if(!wtap_dump_file_write(wdh, pd, phdr->caplen - round_down, err)) return FALSE;
|
||||
wdh->bytes_dumped += phdr->caplen - round_down;
|
||||
|
||||
/*add the 4 byte CRC if necessary*/
|
||||
if(must_add_crc){
|
||||
if(!wftap_dump_file_write(wdh, &crc32, 4, err)) return FALSE;
|
||||
if(!wtap_dump_file_write(wdh, &crc32, 4, err)) return FALSE;
|
||||
wdh->bytes_dumped += 4;
|
||||
}
|
||||
/*records should be 8byte aligned, so we add padding*/
|
||||
if(round_down == 0){
|
||||
for(i = (gint16)alignbytes; i > 0; i--){
|
||||
if(!wftap_dump_file_write(wdh, "", 1, err)) return FALSE;
|
||||
if(!wtap_dump_file_write(wdh, "", 1, err)) return FALSE;
|
||||
wdh->bytes_dumped++;
|
||||
}
|
||||
}
|
||||
|
@ -704,7 +700,7 @@ int erf_dump_can_write_encap(int encap)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int erf_dump_open(wftap_dumper *wdh, int *err)
|
||||
int erf_dump_open(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
wdh->subtype_write = erf_dump;
|
||||
wdh->subtype_close = NULL;
|
||||
|
|
|
@ -103,9 +103,9 @@ union erf_subhdr {
|
|||
#define RECORDS_FOR_ERF_CHECK 20
|
||||
#define FCS_BITS 32
|
||||
|
||||
int erf_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int erf_open(wtap *wth, int *err, gchar **err_info);
|
||||
int erf_dump_can_write_encap(int encap);
|
||||
int erf_dump_open(wftap_dumper *wdh, int *err);
|
||||
int erf_dump_open(wtap_dumper *wdh, int *err);
|
||||
|
||||
int erf_populate_interfaces(wtap *wth);
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "buffer.h"
|
||||
#include "eyesdn.h"
|
||||
|
@ -91,47 +90,47 @@ static const unsigned char eyesdn_hdr_magic[] =
|
|||
*/
|
||||
#define EYESDN_MAX_PACKET_LEN 16384
|
||||
|
||||
static gboolean eyesdn_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean eyesdn_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean eyesdn_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
static int read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer* buf,
|
||||
int *err, gchar **err_info);
|
||||
|
||||
/* Seeks to the beginning of the next packet, and returns the
|
||||
byte offset. Returns -1 on failure, and sets "*err" to the error
|
||||
and "*err_info" to null or an additional error string. */
|
||||
static gint64 eyesdn_seek_next_packet(wftap *wfth, int *err, gchar **err_info)
|
||||
static gint64 eyesdn_seek_next_packet(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
int byte;
|
||||
gint64 cur_off;
|
||||
|
||||
while ((byte = file_getc(wfth->fh)) != EOF) {
|
||||
while ((byte = file_getc(wth->fh)) != EOF) {
|
||||
if (byte == 0xff) {
|
||||
cur_off = file_tell(wfth->fh);
|
||||
cur_off = file_tell(wth->fh);
|
||||
if (cur_off == -1) {
|
||||
/* Error. */
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return -1;
|
||||
}
|
||||
return cur_off;
|
||||
}
|
||||
}
|
||||
/* EOF or error. */
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int eyesdn_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int eyesdn_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
int bytes_read;
|
||||
char magic[EYESDN_HDR_MAGIC_SIZE];
|
||||
|
||||
/* Look for eyesdn header */
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(&magic, sizeof magic, wfth->fh);
|
||||
bytes_read = file_read(&magic, sizeof magic, wth->fh);
|
||||
if (bytes_read != sizeof magic) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -139,44 +138,42 @@ int eyesdn_open(wftap *wfth, int *err, gchar **err_info)
|
|||
if (memcmp(magic, eyesdn_hdr_magic, EYESDN_HDR_MAGIC_SIZE) != 0)
|
||||
return 0;
|
||||
|
||||
wfth->file_encap = WTAP_ENCAP_PER_PACKET;
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_EYESDN;
|
||||
wfth->snapshot_length = 0; /* not known */
|
||||
wfth->subtype_read = eyesdn_read;
|
||||
wfth->subtype_seek_read = eyesdn_seek_read;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wth->file_encap = WTAP_ENCAP_PER_PACKET;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_EYESDN;
|
||||
wth->snapshot_length = 0; /* not known */
|
||||
wth->subtype_read = eyesdn_read;
|
||||
wth->subtype_seek_read = eyesdn_seek_read;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Find the next packet and parse it; called from wtap_read(). */
|
||||
static gboolean eyesdn_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean eyesdn_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
gint64 offset;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
/* Find the next record */
|
||||
offset = eyesdn_seek_next_packet(wfth, err, err_info);
|
||||
offset = eyesdn_seek_next_packet(wth, err, err_info);
|
||||
if (offset < 1)
|
||||
return FALSE;
|
||||
*data_offset = offset;
|
||||
|
||||
/* Parse the record */
|
||||
return read_eyesdn_rec(wfth->fh, &wth->phdr, wfth->frame_buffer,
|
||||
return read_eyesdn_rec(wth->fh, &wth->phdr, wth->frame_buffer,
|
||||
err, err_info);
|
||||
}
|
||||
|
||||
/* Used to read packets in random-access fashion */
|
||||
static gboolean
|
||||
eyesdn_seek_read(wftap *wfth, gint64 seek_off, void* header,
|
||||
eyesdn_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
return read_eyesdn_rec(wfth->random_fh, phdr, buf, err, err_info);
|
||||
return read_eyesdn_rec(wth->random_fh, phdr, buf, err, err_info);
|
||||
}
|
||||
|
||||
/* Parses a record. */
|
||||
|
@ -190,8 +187,8 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
|
|||
int usecs;
|
||||
int pkt_len;
|
||||
guint8 channel, direction;
|
||||
int bytes_read;
|
||||
guint8 *pd;
|
||||
int bytes_read;
|
||||
guint8 *pd;
|
||||
|
||||
/* Our file pointer should be at the summary information header
|
||||
* for a packet. Read in that header and extract the useful
|
||||
|
@ -345,7 +342,7 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
|
|||
|
||||
|
||||
static gboolean
|
||||
esc_write(wftap_dumper *wdh, const guint8 *buf, int len, int *err)
|
||||
esc_write(wtap_dumper *wdh, const guint8 *buf, int len, int *err)
|
||||
{
|
||||
int i;
|
||||
guint8 byte;
|
||||
|
@ -357,26 +354,26 @@ esc_write(wftap_dumper *wdh, const guint8 *buf, int len, int *err)
|
|||
/*
|
||||
* Escape the frame delimiter and escape byte.
|
||||
*/
|
||||
if (!wftap_dump_file_write(wdh, &esc, sizeof esc, err))
|
||||
if (!wtap_dump_file_write(wdh, &esc, sizeof esc, err))
|
||||
return FALSE;
|
||||
byte-=2;
|
||||
}
|
||||
if (!wftap_dump_file_write(wdh, &byte, sizeof byte, err))
|
||||
if (!wtap_dump_file_write(wdh, &byte, sizeof byte, err))
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean eyesdn_dump(wftap_dumper *wdh,
|
||||
static gboolean eyesdn_dump(wtap_dumper *wdh,
|
||||
const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err);
|
||||
|
||||
gboolean eyesdn_dump_open(wftap_dumper *wdh, int *err)
|
||||
gboolean eyesdn_dump_open(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
wdh->subtype_write=eyesdn_dump;
|
||||
wdh->subtype_close=NULL;
|
||||
|
||||
if (!wftap_dump_file_write(wdh, eyesdn_hdr_magic,
|
||||
if (!wtap_dump_file_write(wdh, eyesdn_hdr_magic,
|
||||
EYESDN_HDR_MAGIC_SIZE, err))
|
||||
return FALSE;
|
||||
wdh->bytes_dumped += EYESDN_HDR_MAGIC_SIZE;
|
||||
|
@ -404,7 +401,7 @@ int eyesdn_dump_can_write_encap(int encap)
|
|||
|
||||
/* Write a record for a packet to a dump file.
|
||||
* Returns TRUE on success, FALSE on failure. */
|
||||
static gboolean eyesdn_dump(wftap_dumper *wdh,
|
||||
static gboolean eyesdn_dump(wtap_dumper *wdh,
|
||||
const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err)
|
||||
{
|
||||
|
@ -491,7 +488,7 @@ static gboolean eyesdn_dump(wftap_dumper *wdh,
|
|||
phtons(&buf[10], size);
|
||||
|
||||
/* start flag */
|
||||
if (!wftap_dump_file_write(wdh, &start_flag, sizeof start_flag, err))
|
||||
if (!wtap_dump_file_write(wdh, &start_flag, sizeof start_flag, err))
|
||||
return FALSE;
|
||||
if (!esc_write(wdh, buf, 12, err))
|
||||
return FALSE;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <wtap.h>
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
int eyesdn_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int eyesdn_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
enum EyeSDN_TYPES {
|
||||
EYESDN_ENCAP_ISDN=0,
|
||||
|
@ -40,7 +40,7 @@ enum EyeSDN_TYPES {
|
|||
EYESDN_ENCAP_V5_EF
|
||||
};
|
||||
|
||||
gboolean eyesdn_dump_open(wftap_dumper *wdh, int *err);
|
||||
gboolean eyesdn_dump_open(wtap_dumper *wdh, int *err);
|
||||
int eyesdn_dump_can_write_encap(int encap);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
#include <wsutil/file_util.h>
|
||||
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -674,13 +673,12 @@ static gboolean heuristic_uses_extension(unsigned int i, const char *extension)
|
|||
so that it can do sequential I/O to a capture file that's being
|
||||
written to as new packets arrive independently of random I/O done
|
||||
to display protocol trees for packets when they're selected. */
|
||||
wftap* wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_info,
|
||||
wtap* wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_info,
|
||||
gboolean do_random)
|
||||
{
|
||||
int fd;
|
||||
ws_statb64 statb;
|
||||
wtap *wth;
|
||||
wftap *wfth;
|
||||
unsigned int i;
|
||||
gboolean use_stdin = FALSE;
|
||||
gchar *extension;
|
||||
|
@ -744,79 +742,76 @@ wftap* wtap_open_offline(const char *filename, unsigned int type, int *err, char
|
|||
}
|
||||
|
||||
errno = ENOMEM;
|
||||
wfth = (wftap *)g_malloc0(sizeof(wtap));
|
||||
wth = (wtap *)g_malloc0(sizeof(wtap));
|
||||
|
||||
/* Open the file */
|
||||
errno = WTAP_ERR_CANT_OPEN;
|
||||
if (use_stdin) {
|
||||
/*
|
||||
* We dup FD 0, so that we don't have to worry about
|
||||
* a file_close of wfth->fh closing the standard
|
||||
* a file_close of wth->fh closing the standard
|
||||
* input of the process.
|
||||
*/
|
||||
fd = ws_dup(0);
|
||||
if (fd < 0) {
|
||||
*err = errno;
|
||||
g_free(wfth);
|
||||
g_free(wth);
|
||||
return NULL;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
if (_setmode(fd, O_BINARY) == -1) {
|
||||
/* "Shouldn't happen" */
|
||||
*err = errno;
|
||||
g_free(wfth);
|
||||
g_free(wth);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
if (!(wfth->fh = file_fdopen(fd))) {
|
||||
if (!(wth->fh = file_fdopen(fd))) {
|
||||
*err = errno;
|
||||
ws_close(fd);
|
||||
g_free(wfth);
|
||||
g_free(wth);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
if (!(wfth->fh = file_open(filename))) {
|
||||
if (!(wth->fh = file_open(filename))) {
|
||||
*err = errno;
|
||||
g_free(wfth);
|
||||
g_free(wth);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (do_random) {
|
||||
if (!(wfth->random_fh = file_open(filename))) {
|
||||
if (!(wth->random_fh = file_open(filename))) {
|
||||
*err = errno;
|
||||
file_close(wfth->fh);
|
||||
g_free(wfth);
|
||||
file_close(wth->fh);
|
||||
g_free(wth);
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
wfth->random_fh = NULL;
|
||||
|
||||
wth = (wtap *)g_malloc0(sizeof(wtap));
|
||||
wfth->tap_specific_data = wth;
|
||||
wth->random_fh = NULL;
|
||||
|
||||
/* initialization */
|
||||
wfth->file_encap = WTAP_ENCAP_UNKNOWN;
|
||||
wfth->subtype_sequential_close = NULL;
|
||||
wfth->subtype_close = NULL;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wfth->priv = NULL;
|
||||
wfth->wslua_data = NULL;
|
||||
wth->file_encap = WTAP_ENCAP_UNKNOWN;
|
||||
wth->subtype_sequential_close = NULL;
|
||||
wth->subtype_close = NULL;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wth->priv = NULL;
|
||||
wth->wslua_data = NULL;
|
||||
|
||||
if (wfth->random_fh) {
|
||||
wfth->fast_seek = g_ptr_array_new();
|
||||
if (wth->random_fh) {
|
||||
wth->fast_seek = g_ptr_array_new();
|
||||
|
||||
file_set_random_access(wfth->fh, FALSE, wfth->fast_seek);
|
||||
file_set_random_access(wfth->random_fh, TRUE, wfth->fast_seek);
|
||||
file_set_random_access(wth->fh, FALSE, wth->fast_seek);
|
||||
file_set_random_access(wth->random_fh, TRUE, wth->fast_seek);
|
||||
}
|
||||
|
||||
/* 'type' is 1 greater than the array index */
|
||||
if (type != WTAP_TYPE_AUTO && type <= open_info_arr->len) {
|
||||
int result;
|
||||
|
||||
if (file_seek(wfth->fh, 0, SEEK_SET, err) == -1) {
|
||||
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1) {
|
||||
/* I/O error - give up */
|
||||
wtap_close(wfth);
|
||||
wtap_close(wth);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -824,14 +819,14 @@ wftap* wtap_open_offline(const char *filename, unsigned int type, int *err, char
|
|||
* to the file reader, kinda like the priv member but not free'd later.
|
||||
* It's ok for this to copy a NULL.
|
||||
*/
|
||||
wfth->wslua_data = open_routines[type - 1].wslua_data;
|
||||
wth->wslua_data = open_routines[type - 1].wslua_data;
|
||||
|
||||
result = (*open_routines[type - 1].open_routine)(wfth, err, err_info);
|
||||
result = (*open_routines[type - 1].open_routine)(wth, err, err_info);
|
||||
|
||||
switch (result) {
|
||||
case -1:
|
||||
/* I/O error - give up */
|
||||
wtap_close(wfth);
|
||||
wtap_close(wth);
|
||||
return NULL;
|
||||
|
||||
case 0:
|
||||
|
@ -853,9 +848,9 @@ wftap* wtap_open_offline(const char *filename, unsigned int type, int *err, char
|
|||
to start reading at the beginning.
|
||||
|
||||
Initialize the data offset while we're at it. */
|
||||
if (file_seek(wfth->fh, 0, SEEK_SET, err) == -1) {
|
||||
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1) {
|
||||
/* I/O error - give up */
|
||||
wtap_close(wfth);
|
||||
wtap_close(wth);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -863,13 +858,13 @@ wftap* wtap_open_offline(const char *filename, unsigned int type, int *err, char
|
|||
* to the file reader, kinda like the priv member but not free'd later.
|
||||
* It's ok for this to copy a NULL.
|
||||
*/
|
||||
wfth->wslua_data = open_routines[i].wslua_data;
|
||||
wth->wslua_data = open_routines[i].wslua_data;
|
||||
|
||||
switch ((*open_routines[i].open_routine)(wfth, err, err_info)) {
|
||||
switch ((*open_routines[i].open_routine)(wth, err, err_info)) {
|
||||
|
||||
case -1:
|
||||
/* I/O error - give up */
|
||||
wtap_close(wfth);
|
||||
wtap_close(wth);
|
||||
return NULL;
|
||||
|
||||
case 0:
|
||||
|
@ -891,25 +886,25 @@ wftap* wtap_open_offline(const char *filename, unsigned int type, int *err, char
|
|||
/* Does this type use that extension? */
|
||||
if (heuristic_uses_extension(i, extension)) {
|
||||
/* Yes. */
|
||||
if (file_seek(wfth->fh, 0, SEEK_SET, err) == -1) {
|
||||
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1) {
|
||||
/* I/O error - give up */
|
||||
g_free(extension);
|
||||
wtap_close(wfth);
|
||||
wtap_close(wth);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set wth with wslua data if any - this is how we pass the data
|
||||
* to the file reader, kind of like priv but not free'd later.
|
||||
*/
|
||||
wfth->wslua_data = open_routines[i].wslua_data;
|
||||
wth->wslua_data = open_routines[i].wslua_data;
|
||||
|
||||
switch ((*open_routines[i].open_routine)(wfth,
|
||||
switch ((*open_routines[i].open_routine)(wth,
|
||||
err, err_info)) {
|
||||
|
||||
case -1:
|
||||
/* I/O error - give up */
|
||||
g_free(extension);
|
||||
wtap_close(wfth);
|
||||
wtap_close(wth);
|
||||
return NULL;
|
||||
|
||||
case 0:
|
||||
|
@ -929,25 +924,25 @@ wftap* wtap_open_offline(const char *filename, unsigned int type, int *err, char
|
|||
/* Does this type use that extension? */
|
||||
if (!heuristic_uses_extension(i, extension)) {
|
||||
/* No. */
|
||||
if (file_seek(wfth->fh, 0, SEEK_SET, err) == -1) {
|
||||
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1) {
|
||||
/* I/O error - give up */
|
||||
g_free(extension);
|
||||
wtap_close(wfth);
|
||||
wtap_close(wth);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set wth with wslua data if any - this is how we pass the data
|
||||
* to the file reader, kind of like priv but not free'd later.
|
||||
*/
|
||||
wfth->wslua_data = open_routines[i].wslua_data;
|
||||
wth->wslua_data = open_routines[i].wslua_data;
|
||||
|
||||
switch ((*open_routines[i].open_routine)(wfth,
|
||||
switch ((*open_routines[i].open_routine)(wth,
|
||||
err, err_info)) {
|
||||
|
||||
case -1:
|
||||
/* I/O error - give up */
|
||||
g_free(extension);
|
||||
wtap_close(wfth);
|
||||
wtap_close(wth);
|
||||
return NULL;
|
||||
|
||||
case 0:
|
||||
|
@ -966,22 +961,22 @@ wftap* wtap_open_offline(const char *filename, unsigned int type, int *err, char
|
|||
/* No - try all the heuristics types in order. */
|
||||
for (i = heuristic_open_routine_idx; i < open_info_arr->len; i++) {
|
||||
|
||||
if (file_seek(wfth->fh, 0, SEEK_SET, err) == -1) {
|
||||
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1) {
|
||||
/* I/O error - give up */
|
||||
wtap_close(wfth);
|
||||
wtap_close(wth);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set wth with wslua data if any - this is how we pass the data
|
||||
* to the file reader, kind of like priv but not free'd later.
|
||||
*/
|
||||
wfth->wslua_data = open_routines[i].wslua_data;
|
||||
wth->wslua_data = open_routines[i].wslua_data;
|
||||
|
||||
switch ((*open_routines[i].open_routine)(wfth, err, err_info)) {
|
||||
switch ((*open_routines[i].open_routine)(wth, err, err_info)) {
|
||||
|
||||
case -1:
|
||||
/* I/O error - give up */
|
||||
wtap_close(wfth);
|
||||
wtap_close(wth);
|
||||
return NULL;
|
||||
|
||||
case 0:
|
||||
|
@ -998,22 +993,22 @@ wftap* wtap_open_offline(const char *filename, unsigned int type, int *err, char
|
|||
fail:
|
||||
|
||||
/* Well, it's not one of the types of file we know about. */
|
||||
wtap_close(wfth);
|
||||
wtap_close(wth);
|
||||
*err = WTAP_ERR_FILE_UNKNOWN_FORMAT;
|
||||
return NULL;
|
||||
|
||||
success:
|
||||
wfth->frame_buffer = (struct Buffer *)g_malloc(sizeof(struct Buffer));
|
||||
buffer_init(wfth->frame_buffer, 1500);
|
||||
wth->frame_buffer = (struct Buffer *)g_malloc(sizeof(struct Buffer));
|
||||
buffer_init(wth->frame_buffer, 1500);
|
||||
|
||||
if(wfth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP){
|
||||
if(wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP){
|
||||
|
||||
wtapng_if_descr_t descr;
|
||||
|
||||
descr.wtap_encap = wfth->file_encap;
|
||||
descr.wtap_encap = wth->file_encap;
|
||||
descr.time_units_per_second = 1000000; /* default microsecond resolution */
|
||||
descr.link_type = wtap_wtap_encap_to_pcap_encap(wfth->file_encap);
|
||||
descr.snap_len = wfth->snapshot_length;
|
||||
descr.link_type = wtap_wtap_encap_to_pcap_encap(wth->file_encap);
|
||||
descr.snap_len = wth->snapshot_length;
|
||||
descr.opt_comment = NULL;
|
||||
descr.if_name = NULL;
|
||||
descr.if_description = NULL;
|
||||
|
@ -1031,7 +1026,7 @@ success:
|
|||
g_array_append_val(wth->interface_data, descr);
|
||||
|
||||
}
|
||||
return wfth;
|
||||
return wth;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1047,7 +1042,7 @@ success:
|
|||
* reopens the random stream.
|
||||
*/
|
||||
gboolean
|
||||
wftap_fdreopen(wftap *wfth, const char *filename, int *err)
|
||||
wtap_fdreopen(wtap *wth, const char *filename, int *err)
|
||||
{
|
||||
ws_statb64 statb;
|
||||
|
||||
|
@ -1089,7 +1084,7 @@ wftap_fdreopen(wftap *wfth, const char *filename, int *err)
|
|||
|
||||
/* Open the file */
|
||||
errno = WTAP_ERR_CANT_OPEN;
|
||||
if (!file_fdreopen(wfth->random_fh, filename)) {
|
||||
if (!file_fdreopen(wth->random_fh, filename)) {
|
||||
*err = errno;
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1961,40 +1956,31 @@ gboolean wtap_dump_supports_comment_types(int file_type_subtype, guint32 comment
|
|||
}
|
||||
|
||||
static gboolean wtap_dump_open_check(int file_type_subtype, int encap, gboolean comressed, int *err);
|
||||
static wftap_dumper* wtap_dump_alloc_wfdh(int file_type_subtype, int encap, int snaplen,
|
||||
static wtap_dumper* wtap_dump_alloc_wdh(int file_type_subtype, int encap, int snaplen,
|
||||
gboolean compressed, int *err);
|
||||
static gboolean wtap_dump_open_finish(wftap_dumper *wdh, int file_type_subtype, gboolean compressed, int *err);
|
||||
static gboolean wtap_dump_open_finish(wtap_dumper *wdh, int file_type_subtype, gboolean compressed, int *err);
|
||||
|
||||
static WFILE_T wftap_dump_file_open(wftap_dumper *wdh, const char *filename);
|
||||
static WFILE_T wftap_dump_file_fdopen(wftap_dumper *wdh, int fd);
|
||||
static int wtap_dump_file_close(wftap_dumper *wdh);
|
||||
static WFILE_T wtap_dump_file_open(wtap_dumper *wdh, const char *filename);
|
||||
static WFILE_T wtap_dump_file_fdopen(wtap_dumper *wdh, int fd);
|
||||
static int wtap_dump_file_close(wtap_dumper *wdh);
|
||||
|
||||
wftap_dumper* wtap_dump_open(const char *filename, int file_type_subtype, int encap,
|
||||
wtap_dumper* wtap_dump_open(const char *filename, int file_type_subtype, int encap,
|
||||
int snaplen, gboolean compressed, int *err)
|
||||
{
|
||||
return wtap_dump_open_ng(filename, file_type_subtype, encap,snaplen, compressed, NULL, NULL, err);
|
||||
}
|
||||
|
||||
static wftap_dumper *
|
||||
static wtap_dumper *
|
||||
wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean compressed,
|
||||
wtapng_section_t *shb_hdr, wtapng_iface_descriptions_t *idb_inf, int *err)
|
||||
{
|
||||
wftap_dumper *wfdh;
|
||||
wtap_dumper* wdh;
|
||||
wtap_dumper *wdh;
|
||||
|
||||
/* Allocate a data structure for the output stream. */
|
||||
wfdh = wtap_dump_alloc_wfdh(file_type_subtype, encap, snaplen, compressed, err);
|
||||
if (wfdh == NULL)
|
||||
wdh = wtap_dump_alloc_wdh(file_type_subtype, encap, snaplen, compressed, err);
|
||||
if (wdh == NULL)
|
||||
return NULL; /* couldn't allocate it */
|
||||
|
||||
wdh = (wtap_dumper *)g_malloc0(sizeof (wtap_dumper));
|
||||
if (wdh == NULL) {
|
||||
*err = errno;
|
||||
g_free(wfdh);
|
||||
return NULL;
|
||||
}
|
||||
wfdh->tap_specific_data = wdh;
|
||||
|
||||
/* Set Section Header Block data */
|
||||
wdh->shb_hdr = shb_hdr;
|
||||
/* Set Interface Description Block data */
|
||||
|
@ -2024,14 +2010,13 @@ wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean co
|
|||
wdh->interface_data= g_array_new(FALSE, FALSE, sizeof(wtapng_if_descr_t));
|
||||
g_array_append_val(wdh->interface_data, descr);
|
||||
}
|
||||
return wfdh;
|
||||
return wdh;
|
||||
}
|
||||
|
||||
wftap_dumper* wtap_dump_open_ng(const char *filename, int file_type_subtype, int encap,
|
||||
wtap_dumper* wtap_dump_open_ng(const char *filename, int file_type_subtype, int encap,
|
||||
int snaplen, gboolean compressed, wtapng_section_t *shb_hdr, wtapng_iface_descriptions_t *idb_inf, int *err)
|
||||
{
|
||||
wftap_dumper *wfdh;
|
||||
wtap_dumper* wdh;
|
||||
wtap_dumper *wdh;
|
||||
WFILE_T fh;
|
||||
|
||||
/* Check whether we can open a capture file with that file type
|
||||
|
@ -2040,19 +2025,16 @@ wftap_dumper* wtap_dump_open_ng(const char *filename, int file_type_subtype, int
|
|||
return NULL;
|
||||
|
||||
/* Allocate and initialize a data structure for the output stream. */
|
||||
wfdh = wtap_dump_init_dumper(file_type_subtype, encap, snaplen, compressed,
|
||||
wdh = wtap_dump_init_dumper(file_type_subtype, encap, snaplen, compressed,
|
||||
shb_hdr, idb_inf, err);
|
||||
if (wfdh == NULL)
|
||||
if (wdh == NULL)
|
||||
return NULL;
|
||||
|
||||
wdh = wfdh->tap_specific_data;
|
||||
|
||||
/* "-" means stdout */
|
||||
if (strcmp(filename, "-") == 0) {
|
||||
if (compressed) {
|
||||
*err = EINVAL; /* XXX - return a Wiretap error code for this */
|
||||
g_free(wdh);
|
||||
g_free(wfdh);
|
||||
return NULL; /* compress won't work on stdout */
|
||||
}
|
||||
#ifdef _WIN32
|
||||
|
@ -2060,49 +2042,46 @@ wftap_dumper* wtap_dump_open_ng(const char *filename, int file_type_subtype, int
|
|||
/* "Should not happen" */
|
||||
*err = errno;
|
||||
g_free(wdh);
|
||||
g_free(wfdh);
|
||||
return NULL; /* couldn't put standard output in binary mode */
|
||||
}
|
||||
#endif
|
||||
wfdh->fh = stdout;
|
||||
wdh->fh = stdout;
|
||||
} else {
|
||||
/* In case "fopen()" fails but doesn't set "errno", set "errno"
|
||||
to a generic "the open failed" error. */
|
||||
errno = WTAP_ERR_CANT_OPEN;
|
||||
fh = wftap_dump_file_open(wfdh, filename);
|
||||
fh = wtap_dump_file_open(wdh, filename);
|
||||
if (fh == NULL) {
|
||||
*err = errno;
|
||||
g_free(wdh);
|
||||
g_free(wfdh);
|
||||
return NULL; /* can't create file */
|
||||
}
|
||||
wfdh->fh = fh;
|
||||
wdh->fh = fh;
|
||||
}
|
||||
|
||||
if (!wtap_dump_open_finish(wfdh, file_type_subtype, compressed, err)) {
|
||||
if (!wtap_dump_open_finish(wdh, file_type_subtype, compressed, err)) {
|
||||
/* Get rid of the file we created; we couldn't finish
|
||||
opening it. */
|
||||
if (wfdh->fh != stdout) {
|
||||
wtap_dump_file_close(wfdh);
|
||||
if (wdh->fh != stdout) {
|
||||
wtap_dump_file_close(wdh);
|
||||
ws_unlink(filename);
|
||||
}
|
||||
g_free(wdh);
|
||||
g_free(wfdh);
|
||||
return NULL;
|
||||
}
|
||||
return wfdh;
|
||||
return wdh;
|
||||
}
|
||||
|
||||
wftap_dumper* wtap_dump_fdopen(int fd, int file_type_subtype, int encap, int snaplen,
|
||||
wtap_dumper* wtap_dump_fdopen(int fd, int file_type_subtype, int encap, int snaplen,
|
||||
gboolean compressed, int *err)
|
||||
{
|
||||
return wtap_dump_fdopen_ng(fd, file_type_subtype, encap, snaplen, compressed, NULL, NULL, err);
|
||||
}
|
||||
|
||||
wftap_dumper* wtap_dump_fdopen_ng(int fd, int file_type_subtype, int encap, int snaplen,
|
||||
wtap_dumper* wtap_dump_fdopen_ng(int fd, int file_type_subtype, int encap, int snaplen,
|
||||
gboolean compressed, wtapng_section_t *shb_hdr, wtapng_iface_descriptions_t *idb_inf, int *err)
|
||||
{
|
||||
wftap_dumper *wfdh;
|
||||
wtap_dumper *wdh;
|
||||
WFILE_T fh;
|
||||
|
||||
/* Check whether we can open a capture file with that file type
|
||||
|
@ -2111,9 +2090,9 @@ wftap_dumper* wtap_dump_fdopen_ng(int fd, int file_type_subtype, int encap, int
|
|||
return NULL;
|
||||
|
||||
/* Allocate and initialize a data structure for the output stream. */
|
||||
wfdh = wtap_dump_init_dumper(file_type_subtype, encap, snaplen, compressed,
|
||||
wdh = wtap_dump_init_dumper(file_type_subtype, encap, snaplen, compressed,
|
||||
shb_hdr, idb_inf, err);
|
||||
if (wfdh == NULL)
|
||||
if (wdh == NULL)
|
||||
return NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -2121,7 +2100,7 @@ wftap_dumper* wtap_dump_fdopen_ng(int fd, int file_type_subtype, int encap, int
|
|||
if (_setmode(fileno(stdout), O_BINARY) == -1) {
|
||||
/* "Should not happen" */
|
||||
*err = errno;
|
||||
g_free(wfdh);
|
||||
g_free(wdh);
|
||||
return NULL; /* couldn't put standard output in binary mode */
|
||||
}
|
||||
}
|
||||
|
@ -2130,20 +2109,20 @@ wftap_dumper* wtap_dump_fdopen_ng(int fd, int file_type_subtype, int encap, int
|
|||
/* In case "fopen()" fails but doesn't set "errno", set "errno"
|
||||
to a generic "the open failed" error. */
|
||||
errno = WTAP_ERR_CANT_OPEN;
|
||||
fh = wftap_dump_file_fdopen(wfdh, fd);
|
||||
fh = wtap_dump_file_fdopen(wdh, fd);
|
||||
if (fh == NULL) {
|
||||
*err = errno;
|
||||
g_free(wfdh);
|
||||
g_free(wdh);
|
||||
return NULL; /* can't create standard I/O stream */
|
||||
}
|
||||
wfdh->fh = fh;
|
||||
wdh->fh = fh;
|
||||
|
||||
if (!wtap_dump_open_finish(wfdh, file_type_subtype, compressed, err)) {
|
||||
wtap_dump_file_close(wfdh);
|
||||
g_free(wfdh);
|
||||
if (!wtap_dump_open_finish(wdh, file_type_subtype, compressed, err)) {
|
||||
wtap_dump_file_close(wdh);
|
||||
g_free(wdh);
|
||||
return NULL;
|
||||
}
|
||||
return wfdh;
|
||||
return wdh;
|
||||
}
|
||||
|
||||
static gboolean wtap_dump_open_check(int file_type_subtype, int encap, gboolean compressed, int *err)
|
||||
|
@ -2179,12 +2158,12 @@ static gboolean wtap_dump_open_check(int file_type_subtype, int encap, gboolean
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static wftap_dumper* wtap_dump_alloc_wfdh(int file_type_subtype, int encap, int snaplen,
|
||||
static wtap_dumper* wtap_dump_alloc_wdh(int file_type_subtype, int encap, int snaplen,
|
||||
gboolean compressed, int *err)
|
||||
{
|
||||
wftap_dumper *wdh;
|
||||
wtap_dumper *wdh;
|
||||
|
||||
wdh = (wftap_dumper *)g_malloc0(sizeof (wftap_dumper));
|
||||
wdh = (wtap_dumper *)g_malloc0(sizeof (wtap_dumper));
|
||||
if (wdh == NULL) {
|
||||
*err = errno;
|
||||
return NULL;
|
||||
|
@ -2198,7 +2177,7 @@ static wftap_dumper* wtap_dump_alloc_wfdh(int file_type_subtype, int encap, int
|
|||
return wdh;
|
||||
}
|
||||
|
||||
static gboolean wtap_dump_open_finish(wftap_dumper *wdh, int file_type_subtype, gboolean compressed, int *err)
|
||||
static gboolean wtap_dump_open_finish(wtap_dumper *wdh, int file_type_subtype, gboolean compressed, int *err)
|
||||
{
|
||||
int fd;
|
||||
gboolean cant_seek;
|
||||
|
@ -2238,13 +2217,13 @@ static gboolean wtap_dump_open_finish(wftap_dumper *wdh, int file_type_subtype,
|
|||
return TRUE; /* success! */
|
||||
}
|
||||
|
||||
gboolean wtap_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
gboolean wtap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err)
|
||||
{
|
||||
return (wdh->subtype_write)(wdh, (void*)phdr, pd, err);
|
||||
return (wdh->subtype_write)(wdh, phdr, pd, err);
|
||||
}
|
||||
|
||||
void wftap_dump_flush(wftap_dumper *wdh)
|
||||
void wtap_dump_flush(wtap_dumper *wdh)
|
||||
{
|
||||
#ifdef HAVE_LIBZ
|
||||
if(wdh->compressed) {
|
||||
|
@ -2256,7 +2235,7 @@ void wftap_dump_flush(wftap_dumper *wdh)
|
|||
}
|
||||
}
|
||||
|
||||
gboolean wftap_dump_close(wftap_dumper *wdh, int *err)
|
||||
gboolean wtap_dump_close(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
gboolean ret = TRUE;
|
||||
|
||||
|
@ -2280,44 +2259,36 @@ gboolean wftap_dump_close(wftap_dumper *wdh, int *err)
|
|||
}
|
||||
} else {
|
||||
/* as we don't close stdout, at least try to flush it */
|
||||
wftap_dump_flush(wdh);
|
||||
wtap_dump_flush(wdh);
|
||||
}
|
||||
if (wdh->priv != NULL)
|
||||
g_free(wdh->priv);
|
||||
|
||||
if (wdh->tap_specific_data != NULL)
|
||||
g_free(wdh->tap_specific_data);
|
||||
|
||||
g_free(wdh);
|
||||
return ret;
|
||||
}
|
||||
|
||||
gint64 wftap_get_bytes_dumped(wftap_dumper *wdh)
|
||||
gint64 wtap_get_bytes_dumped(wtap_dumper *wdh)
|
||||
{
|
||||
return wdh->bytes_dumped;
|
||||
}
|
||||
|
||||
void wftap_set_bytes_dumped(wftap_dumper *wdh, gint64 bytes_dumped)
|
||||
void wtap_set_bytes_dumped(wtap_dumper *wdh, gint64 bytes_dumped)
|
||||
{
|
||||
wdh->bytes_dumped = bytes_dumped;
|
||||
}
|
||||
|
||||
gboolean wtap_dump_set_addrinfo_list(wftap_dumper *wfdh, addrinfo_lists_t *addrinfo_lists)
|
||||
gboolean wtap_dump_set_addrinfo_list(wtap_dumper *wdh, addrinfo_lists_t *addrinfo_lists)
|
||||
{
|
||||
wtap_dumper *wdh;
|
||||
|
||||
if (!wfdh || wfdh->file_type_subtype < 0 || wfdh->file_type_subtype >= wtap_num_file_types_subtypes
|
||||
|| dump_open_table[wfdh->file_type_subtype].has_name_resolution == FALSE)
|
||||
if (!wdh || wdh->file_type_subtype < 0 || wdh->file_type_subtype >= wtap_num_file_types_subtypes
|
||||
|| dump_open_table[wdh->file_type_subtype].has_name_resolution == FALSE)
|
||||
return FALSE;
|
||||
|
||||
wdh = (wtap_dumper*)wfdh->tap_specific_data;
|
||||
wdh->addrinfo_lists = addrinfo_lists;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* internally open a file for writing (compressed or not) */
|
||||
#ifdef HAVE_LIBZ
|
||||
static WFILE_T wftap_dump_file_open(wftap_dumper *wdh, const char *filename)
|
||||
static WFILE_T wtap_dump_file_open(wtap_dumper *wdh, const char *filename)
|
||||
{
|
||||
if(wdh->compressed) {
|
||||
return gzwfile_open(filename);
|
||||
|
@ -2326,7 +2297,7 @@ static WFILE_T wftap_dump_file_open(wftap_dumper *wdh, const char *filename)
|
|||
}
|
||||
}
|
||||
#else
|
||||
static WFILE_T wftap_dump_file_open(wftap_dumper *wdh _U_, const char *filename)
|
||||
static WFILE_T wtap_dump_file_open(wtap_dumper *wdh _U_, const char *filename)
|
||||
{
|
||||
return ws_fopen(filename, "wb");
|
||||
}
|
||||
|
@ -2334,7 +2305,7 @@ static WFILE_T wftap_dump_file_open(wftap_dumper *wdh _U_, const char *filename)
|
|||
|
||||
/* internally open a file for writing (compressed or not) */
|
||||
#ifdef HAVE_LIBZ
|
||||
static WFILE_T wftap_dump_file_fdopen(wftap_dumper *wdh, int fd)
|
||||
static WFILE_T wtap_dump_file_fdopen(wtap_dumper *wdh, int fd)
|
||||
{
|
||||
if(wdh->compressed) {
|
||||
return gzwfile_fdopen(fd);
|
||||
|
@ -2343,14 +2314,14 @@ static WFILE_T wftap_dump_file_fdopen(wftap_dumper *wdh, int fd)
|
|||
}
|
||||
}
|
||||
#else
|
||||
static WFILE_T wftap_dump_file_fdopen(wftap_dumper *wdh, int fd)
|
||||
static WFILE_T wtap_dump_file_fdopen(wtap_dumper *wdh _U_, int fd)
|
||||
{
|
||||
return fdopen(fd, "wb");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* internally writing raw bytes (compressed or not) */
|
||||
gboolean wftap_dump_file_write(wftap_dumper *wdh, const void *buf, size_t bufsize,
|
||||
gboolean wtap_dump_file_write(wtap_dumper *wdh, const void *buf, size_t bufsize,
|
||||
int *err)
|
||||
{
|
||||
size_t nwritten;
|
||||
|
@ -2385,7 +2356,7 @@ gboolean wftap_dump_file_write(wftap_dumper *wdh, const void *buf, size_t bufsiz
|
|||
}
|
||||
|
||||
/* internally close a file for writing (compressed or not) */
|
||||
static int wtap_dump_file_close(wftap_dumper *wdh)
|
||||
static int wtap_dump_file_close(wtap_dumper *wdh)
|
||||
{
|
||||
#ifdef HAVE_LIBZ
|
||||
if(wdh->compressed) {
|
||||
|
@ -2397,7 +2368,7 @@ static int wtap_dump_file_close(wftap_dumper *wdh)
|
|||
}
|
||||
}
|
||||
|
||||
gint64 wftap_dump_file_seek(wftap_dumper *wdh, gint64 offset, int whence, int *err)
|
||||
gint64 wtap_dump_file_seek(wtap_dumper *wdh, gint64 offset, int whence, int *err)
|
||||
{
|
||||
#ifdef HAVE_LIBZ
|
||||
if(wdh->compressed) {
|
||||
|
@ -2415,7 +2386,7 @@ gint64 wftap_dump_file_seek(wftap_dumper *wdh, gint64 offset, int whence, int *e
|
|||
}
|
||||
}
|
||||
}
|
||||
gint64 wftap_dump_file_tell(wftap_dumper *wdh, int *err)
|
||||
gint64 wtap_dump_file_tell(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
gint64 rval;
|
||||
#ifdef HAVE_LIBZ
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -72,35 +71,33 @@ static gboolean hcidump_process_packet(FILE_T fh, struct wtap_pkthdr *phdr,
|
|||
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
|
||||
}
|
||||
|
||||
static gboolean hcidump_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean hcidump_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
return hcidump_process_packet(wfth->fh, &wth->phdr, wfth->frame_buffer,
|
||||
return hcidump_process_packet(wth->fh, &wth->phdr, wth->frame_buffer,
|
||||
err, err_info);
|
||||
}
|
||||
|
||||
static gboolean hcidump_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info)
|
||||
static gboolean hcidump_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
return hcidump_process_packet(wfth->random_fh, phdr, buf, err, err_info);
|
||||
return hcidump_process_packet(wth->random_fh, phdr, buf, err, err_info);
|
||||
}
|
||||
|
||||
int hcidump_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int hcidump_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
struct dump_hdr dh;
|
||||
guint8 type;
|
||||
int bytes_read;
|
||||
|
||||
bytes_read = file_read(&dh, DUMP_HDR_SIZE, wfth->fh);
|
||||
bytes_read = file_read(&dh, DUMP_HDR_SIZE, wth->fh);
|
||||
if (bytes_read != DUMP_HDR_SIZE) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -110,9 +107,9 @@ int hcidump_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|| GUINT16_FROM_LE(dh.len) < 1)
|
||||
return 0;
|
||||
|
||||
bytes_read = file_read(&type, 1, wfth->fh);
|
||||
bytes_read = file_read(&type, 1, wth->fh);
|
||||
if (bytes_read != 1) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -121,16 +118,16 @@ int hcidump_open(wftap *wfth, int *err, gchar **err_info)
|
|||
if (type < 1 || type > 4)
|
||||
return 0;
|
||||
|
||||
if (file_seek(wfth->fh, 0, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
|
||||
return -1;
|
||||
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_HCIDUMP;
|
||||
wfth->file_encap = WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR;
|
||||
wfth->snapshot_length = 0;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_HCIDUMP;
|
||||
wth->file_encap = WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR;
|
||||
wth->snapshot_length = 0;
|
||||
|
||||
wfth->subtype_read = hcidump_read;
|
||||
wfth->subtype_seek_read = hcidump_seek_read;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wth->subtype_read = hcidump_read;
|
||||
wth->subtype_seek_read = hcidump_seek_read;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@
|
|||
#include <wtap.h>
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
int hcidump_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int hcidump_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -34,11 +33,11 @@ typedef struct {
|
|||
gboolean byte_swapped;
|
||||
} i4btrace_t;
|
||||
|
||||
static gboolean i4btrace_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean i4btrace_seek_read(wftap *wth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info);
|
||||
static int i4b_read_rec(wftap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||
static gboolean i4btrace_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
static int i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err, gchar **err_info);
|
||||
|
||||
/*
|
||||
|
@ -49,7 +48,7 @@ static int i4b_read_rec(wftap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
|||
(unsigned)hdr.unit > 4 || (unsigned)hdr.type > 4 || \
|
||||
(unsigned)hdr.dir > 2 || (unsigned)hdr.trunc > 2048))
|
||||
|
||||
int i4btrace_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int i4btrace_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
int bytes_read;
|
||||
i4b_trace_hdr_t hdr;
|
||||
|
@ -58,9 +57,9 @@ int i4btrace_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
/* I4B trace files have no magic in the header... Sigh */
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(&hdr, sizeof(hdr), wfth->fh);
|
||||
bytes_read = file_read(&hdr, sizeof(hdr), wth->fh);
|
||||
if (bytes_read != sizeof(hdr)) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -90,46 +89,44 @@ int i4btrace_open(wftap *wfth, int *err, gchar **err_info)
|
|||
byte_swapped = TRUE;
|
||||
}
|
||||
|
||||
if (file_seek(wfth->fh, 0, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
|
||||
return -1;
|
||||
|
||||
/* Get capture start time */
|
||||
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_I4BTRACE;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_I4BTRACE;
|
||||
i4btrace = (i4btrace_t *)g_malloc(sizeof(i4btrace_t));
|
||||
wfth->priv = (void *)i4btrace;
|
||||
wfth->subtype_read = i4btrace_read;
|
||||
wfth->subtype_seek_read = i4btrace_seek_read;
|
||||
wfth->snapshot_length = 0; /* not known */
|
||||
wth->priv = (void *)i4btrace;
|
||||
wth->subtype_read = i4btrace_read;
|
||||
wth->subtype_seek_read = i4btrace_seek_read;
|
||||
wth->snapshot_length = 0; /* not known */
|
||||
|
||||
i4btrace->byte_swapped = byte_swapped;
|
||||
|
||||
wfth->file_encap = WTAP_ENCAP_ISDN;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wth->file_encap = WTAP_ENCAP_ISDN;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Read the next packet */
|
||||
static gboolean i4btrace_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean i4btrace_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
return i4b_read_rec(wfth, wfth->fh, &wth->phdr, wfth->frame_buffer,
|
||||
return i4b_read_rec(wth, wth->fh, &wth->phdr, wth->frame_buffer,
|
||||
err, err_info);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
i4btrace_seek_read(wftap *wfth, gint64 seek_off, void* header,
|
||||
i4btrace_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
if (!i4b_read_rec(wfth, wfth->random_fh, phdr, buf, err, err_info)) {
|
||||
if (!i4b_read_rec(wth, wth->random_fh, phdr, buf, err, err_info)) {
|
||||
/* Read error or EOF */
|
||||
if (*err == 0) {
|
||||
/* EOF means "short read" in random-access mode */
|
||||
|
@ -141,10 +138,10 @@ i4btrace_seek_read(wftap *wfth, gint64 seek_off, void* header,
|
|||
}
|
||||
|
||||
static int
|
||||
i4b_read_rec(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||
i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||
int *err, gchar **err_info)
|
||||
{
|
||||
i4btrace_t *i4btrace = (i4btrace_t *)wfth->priv;
|
||||
i4btrace_t *i4btrace = (i4btrace_t *)wth->priv;
|
||||
i4b_trace_hdr_t hdr;
|
||||
int bytes_read;
|
||||
guint32 length;
|
||||
|
|
|
@ -26,6 +26,6 @@
|
|||
#include <wtap.h>
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
int i4btrace_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int i4btrace_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -63,7 +63,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -87,12 +86,13 @@
|
|||
#define RECORDS_FOR_IPFIX_CHECK 20
|
||||
|
||||
static gboolean
|
||||
ipfix_read(wftap *wfth, int *err, gchar **err_info,
|
||||
ipfix_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean
|
||||
ipfix_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info);
|
||||
static void ipfix_close(wftap *wth);
|
||||
ipfix_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
static void
|
||||
ipfix_close(wtap *wth);
|
||||
|
||||
#define IPFIX_VERSION 10
|
||||
|
||||
|
@ -184,7 +184,7 @@ ipfix_read_message(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, g
|
|||
* like malformed format, -1 on bad error like file system
|
||||
*/
|
||||
int
|
||||
ipfix_open(wftap *wfth, int *err, gchar **err_info)
|
||||
ipfix_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
gint i, n, records_for_ipfix_check = RECORDS_FOR_IPFIX_CHECK;
|
||||
gchar *s;
|
||||
|
@ -208,7 +208,7 @@ ipfix_open(wftap *wfth, int *err, gchar **err_info)
|
|||
*/
|
||||
for (i = 0; i < records_for_ipfix_check; i++) {
|
||||
/* read first message header to check version */
|
||||
if (!ipfix_read_message_header(&msg_hdr, wfth->fh, err, err_info)) {
|
||||
if (!ipfix_read_message_header(&msg_hdr, wth->fh, err, err_info)) {
|
||||
ipfix_debug3("ipfix_open: couldn't read message header #%d with err code #%d (%s)",
|
||||
i, *err, *err_info);
|
||||
if (*err == WTAP_ERR_BAD_FILE) {
|
||||
|
@ -232,7 +232,7 @@ ipfix_open(wftap *wfth, int *err, gchar **err_info)
|
|||
*/
|
||||
break;
|
||||
}
|
||||
if (file_seek(wfth->fh, IPFIX_MSG_HDR_SIZE, SEEK_CUR, err) == -1) {
|
||||
if (file_seek(wth->fh, IPFIX_MSG_HDR_SIZE, SEEK_CUR, err) == -1) {
|
||||
ipfix_debug1("ipfix_open: failed seek to next message in file, %d bytes away",
|
||||
msg_hdr.message_length);
|
||||
return 0;
|
||||
|
@ -241,7 +241,7 @@ ipfix_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
/* check each Set in IPFIX Message for sanity */
|
||||
while (checked_len < msg_hdr.message_length) {
|
||||
wtap_file_read_expected_bytes(&set_hdr, IPFIX_SET_HDR_SIZE, wfth->fh, err, err_info);
|
||||
wtap_file_read_expected_bytes(&set_hdr, IPFIX_SET_HDR_SIZE, wth->fh, err, err_info);
|
||||
set_hdr.set_length = g_ntohs(set_hdr.set_length);
|
||||
if ((set_hdr.set_length < IPFIX_SET_HDR_SIZE) ||
|
||||
((set_hdr.set_length + checked_len) > msg_hdr.message_length)) {
|
||||
|
@ -250,7 +250,7 @@ ipfix_open(wftap *wfth, int *err, gchar **err_info)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (file_seek(wfth->fh, set_hdr.set_length - IPFIX_SET_HDR_SIZE,
|
||||
if (file_seek(wth->fh, set_hdr.set_length - IPFIX_SET_HDR_SIZE,
|
||||
SEEK_CUR, err) == -1)
|
||||
{
|
||||
ipfix_debug1("ipfix_open: failed seek to next set in file, %d bytes away",
|
||||
|
@ -262,16 +262,16 @@ ipfix_open(wftap *wfth, int *err, gchar **err_info)
|
|||
}
|
||||
|
||||
/* all's good, this is a IPFIX file */
|
||||
wfth->file_encap = WTAP_ENCAP_RAW_IPFIX;
|
||||
wfth->snapshot_length = 0;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_SEC;
|
||||
wfth->subtype_read = ipfix_read;
|
||||
wfth->subtype_seek_read = ipfix_seek_read;
|
||||
wfth->subtype_close = ipfix_close;
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_IPFIX;
|
||||
wth->file_encap = WTAP_ENCAP_RAW_IPFIX;
|
||||
wth->snapshot_length = 0;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
|
||||
wth->subtype_read = ipfix_read;
|
||||
wth->subtype_seek_read = ipfix_seek_read;
|
||||
wth->subtype_close = ipfix_close;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_IPFIX;
|
||||
|
||||
/* go back to beginning of file */
|
||||
if (file_seek (wfth->fh, 0, SEEK_SET, err) != 0)
|
||||
if (file_seek (wth->fh, 0, SEEK_SET, err) != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -281,13 +281,12 @@ ipfix_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
/* classic wtap: read packet */
|
||||
static gboolean
|
||||
ipfix_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
ipfix_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
{
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
ipfix_debug1("ipfix_read: data_offset is initially %" G_GINT64_MODIFIER "d", *data_offset);
|
||||
|
||||
if (!ipfix_read_message(wfth->fh, &wth->phdr, wfth->frame_buffer, err, err_info)) {
|
||||
if (!ipfix_read_message(wth->fh, &wth->phdr, wth->frame_buffer, err, err_info)) {
|
||||
ipfix_debug2("ipfix_read: couldn't read message header with code: %d\n, and error '%s'",
|
||||
*err, *err_info);
|
||||
return FALSE;
|
||||
|
@ -299,13 +298,11 @@ ipfix_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
|||
|
||||
/* classic wtap: seek to file position and read packet */
|
||||
static gboolean
|
||||
ipfix_seek_read(wftap *wfth, gint64 seek_off, void* header,
|
||||
ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
|
||||
/* seek to the right file position */
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1) {
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
|
||||
ipfix_debug2("ipfix_seek_read: couldn't read message header with code: %d\n, and error '%s'",
|
||||
*err, *err_info);
|
||||
return FALSE; /* Seek error */
|
||||
|
@ -313,7 +310,7 @@ ipfix_seek_read(wftap *wfth, gint64 seek_off, void* header,
|
|||
|
||||
ipfix_debug1("ipfix_seek_read: reading at offset %" G_GINT64_MODIFIER "u", seek_off);
|
||||
|
||||
if (!ipfix_read_message(wfth->random_fh, phdr, buf, err, err_info)) {
|
||||
if (!ipfix_read_message(wth->random_fh, phdr, buf, err, err_info)) {
|
||||
ipfix_debug0("ipfix_seek_read: couldn't read message header");
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
|
@ -325,7 +322,7 @@ ipfix_seek_read(wftap *wfth, gint64 seek_off, void* header,
|
|||
|
||||
/* classic wtap: close capture file */
|
||||
static void
|
||||
ipfix_close(wftap *wth _U_)
|
||||
ipfix_close(wtap *wth _U_)
|
||||
{
|
||||
ipfix_debug0("ipfix_close: closing file");
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@
|
|||
#include <wtap.h>
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
int ipfix_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int ipfix_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -32,15 +31,15 @@
|
|||
#define IPTRACE_IFT_HF 0x3d /* Support for PERCS IP-HFI*/
|
||||
#define IPTRACE_IFT_IB 0xc7 /* IP over Infiniband. Number by IANA */
|
||||
|
||||
static gboolean iptrace_read_1_0(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean iptrace_seek_read_1_0(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
|
||||
static gboolean iptrace_read_2_0(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean iptrace_seek_read_2_0(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
|
||||
static int iptrace_read_rec_header(FILE_T fh, guint8 *header, int header_len,
|
||||
int *err, gchar **err_info);
|
||||
|
@ -50,15 +49,15 @@ static void fill_in_pseudo_header(int encap,
|
|||
union wtap_pseudo_header *pseudo_header, guint8 *header);
|
||||
static int wtap_encap_ift(unsigned int ift);
|
||||
|
||||
int iptrace_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int iptrace_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
int bytes_read;
|
||||
char name[12];
|
||||
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(name, 11, wfth->fh);
|
||||
bytes_read = file_read(name, 11, wth->fh);
|
||||
if (bytes_read != 11) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -66,16 +65,16 @@ int iptrace_open(wftap *wfth, int *err, gchar **err_info)
|
|||
name[11] = '\0';
|
||||
|
||||
if (strcmp(name, "iptrace 1.0") == 0) {
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_IPTRACE_1_0;
|
||||
wfth->subtype_read = iptrace_read_1_0;
|
||||
wfth->subtype_seek_read = iptrace_seek_read_1_0;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_SEC;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_IPTRACE_1_0;
|
||||
wth->subtype_read = iptrace_read_1_0;
|
||||
wth->subtype_seek_read = iptrace_seek_read_1_0;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
|
||||
}
|
||||
else if (strcmp(name, "iptrace 2.0") == 0) {
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_IPTRACE_2_0;
|
||||
wfth->subtype_read = iptrace_read_2_0;
|
||||
wfth->subtype_seek_read = iptrace_seek_read_2_0;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_IPTRACE_2_0;
|
||||
wth->subtype_read = iptrace_read_2_0;
|
||||
wth->subtype_seek_read = iptrace_seek_read_2_0;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
|
@ -215,14 +214,13 @@ iptrace_read_rec_1_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
|||
}
|
||||
|
||||
/* Read the next packet */
|
||||
static gboolean iptrace_read_1_0(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean iptrace_read_1_0(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
/* Read the packet */
|
||||
if (!iptrace_read_rec_1_0(wfth->fh, &wth->phdr, wfth->frame_buffer,
|
||||
if (!iptrace_read_rec_1_0(wth->fh, &wth->phdr, wth->frame_buffer,
|
||||
err, err_info)) {
|
||||
/* Read error or EOF */
|
||||
return FALSE;
|
||||
|
@ -234,25 +232,24 @@ static gboolean iptrace_read_1_0(wftap *wfth, int *err, gchar **err_info,
|
|||
If it *is* known, and it isn't this packet's encapsulation,
|
||||
set it to WTAP_ENCAP_PER_PACKET, as this file doesn't
|
||||
have a single encapsulation for all packets in the file. */
|
||||
if (wfth->file_encap == WTAP_ENCAP_UNKNOWN)
|
||||
wfth->file_encap = wth->phdr.pkt_encap;
|
||||
if (wth->file_encap == WTAP_ENCAP_UNKNOWN)
|
||||
wth->file_encap = wth->phdr.pkt_encap;
|
||||
else {
|
||||
if (wfth->file_encap != wth->phdr.pkt_encap)
|
||||
wfth->file_encap = WTAP_ENCAP_PER_PACKET;
|
||||
if (wth->file_encap != wth->phdr.pkt_encap)
|
||||
wth->file_encap = WTAP_ENCAP_PER_PACKET;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean iptrace_seek_read_1_0(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info)
|
||||
static gboolean iptrace_seek_read_1_0(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
/* Read the packet */
|
||||
if (!iptrace_read_rec_1_0(wfth->random_fh, phdr, buf, err, err_info)) {
|
||||
if (!iptrace_read_rec_1_0(wth->random_fh, phdr, buf, err, err_info)) {
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return FALSE;
|
||||
|
@ -412,14 +409,13 @@ iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
|||
}
|
||||
|
||||
/* Read the next packet */
|
||||
static gboolean iptrace_read_2_0(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean iptrace_read_2_0(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
/* Read the packet */
|
||||
if (!iptrace_read_rec_2_0(wfth->fh, &wth->phdr, wfth->frame_buffer,
|
||||
if (!iptrace_read_rec_2_0(wth->fh, &wth->phdr, wth->frame_buffer,
|
||||
err, err_info)) {
|
||||
/* Read error or EOF */
|
||||
return FALSE;
|
||||
|
@ -431,25 +427,24 @@ static gboolean iptrace_read_2_0(wftap *wfth, int *err, gchar **err_info,
|
|||
If it *is* known, and it isn't this packet's encapsulation,
|
||||
set it to WTAP_ENCAP_PER_PACKET, as this file doesn't
|
||||
have a single encapsulation for all packets in the file. */
|
||||
if (wfth->file_encap == WTAP_ENCAP_UNKNOWN)
|
||||
wfth->file_encap = wth->phdr.pkt_encap;
|
||||
if (wth->file_encap == WTAP_ENCAP_UNKNOWN)
|
||||
wth->file_encap = wth->phdr.pkt_encap;
|
||||
else {
|
||||
if (wfth->file_encap != wth->phdr.pkt_encap)
|
||||
wfth->file_encap = WTAP_ENCAP_PER_PACKET;
|
||||
if (wth->file_encap != wth->phdr.pkt_encap)
|
||||
wth->file_encap = WTAP_ENCAP_PER_PACKET;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean iptrace_seek_read_2_0(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info)
|
||||
static gboolean iptrace_seek_read_2_0(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
/* Read the packet */
|
||||
if (!iptrace_read_rec_2_0(wfth->random_fh, phdr, buf, err, err_info)) {
|
||||
if (!iptrace_read_rec_2_0(wth->random_fh, phdr, buf, err, err_info)) {
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return FALSE;
|
||||
|
|
|
@ -25,6 +25,6 @@
|
|||
#include <glib.h>
|
||||
#include <wtap.h>
|
||||
|
||||
int iptrace_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int iptrace_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -149,7 +149,6 @@ Number S/R Length Timer MAC Address MAC Address
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "buffer.h"
|
||||
#include "iseries.h"
|
||||
|
@ -180,14 +179,15 @@ typedef struct {
|
|||
int format; /* Trace format type */
|
||||
} iseries_t;
|
||||
|
||||
static gboolean iseries_read (wftap* wfth, int *err, gchar ** err_info,
|
||||
static gboolean iseries_read (wtap * wth, int *err, gchar ** err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean iseries_seek_read (wftap * wfth, gint64 seek_off, void* header,
|
||||
static gboolean iseries_seek_read (wtap * wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr,
|
||||
Buffer * buf, int *err, gchar ** err_info);
|
||||
static gboolean iseries_check_file_type (wftap * wth, int *err, gchar **err_info,
|
||||
static gboolean iseries_check_file_type (wtap * wth, int *err, gchar **err_info,
|
||||
int format);
|
||||
static gint64 iseries_seek_next_packet (wftap * wfth, int *err, gchar **err_info);
|
||||
static gboolean iseries_parse_packet (wftap * wfth, FILE_T fh,
|
||||
static gint64 iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info);
|
||||
static gboolean iseries_parse_packet (wtap * wth, FILE_T fh,
|
||||
struct wtap_pkthdr *phdr,
|
||||
Buffer * buf, int *err, gchar ** err_info);
|
||||
static int iseries_UNICODE_to_ASCII (guint8 * buf, guint bytes);
|
||||
|
@ -195,7 +195,7 @@ static gboolean iseries_parse_hex_string (const char * ascii, guint8 * buf,
|
|||
size_t len);
|
||||
|
||||
int
|
||||
iseries_open (wftap* wfth, int *err, gchar ** err_info)
|
||||
iseries_open (wtap * wth, int *err, gchar ** err_info)
|
||||
{
|
||||
int bytes_read;
|
||||
gint offset;
|
||||
|
@ -211,10 +211,10 @@ iseries_open (wftap* wfth, int *err, gchar ** err_info)
|
|||
* by scanning for it in the first line
|
||||
*/
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read (&magic, sizeof magic, wfth->fh);
|
||||
bytes_read = file_read (&magic, sizeof magic, wth->fh);
|
||||
if (bytes_read != sizeof magic)
|
||||
{
|
||||
*err = file_error (wfth->fh, err_info);
|
||||
*err = file_error (wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -227,7 +227,7 @@ iseries_open (wftap* wfth, int *err, gchar ** err_info)
|
|||
while ((unsigned)offset < (ISERIES_LINE_LENGTH - (sizeof unicodemagic)))
|
||||
{
|
||||
if (memcmp (magic + offset, unicodemagic, sizeof unicodemagic) == 0) {
|
||||
if (file_seek (wfth->fh, 0, SEEK_SET, err) == -1)
|
||||
if (file_seek (wth->fh, 0, SEEK_SET, err) == -1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ iseries_open (wftap* wfth, int *err, gchar ** err_info)
|
|||
* Do some basic sanity checking to ensure we can handle the
|
||||
* contents of this trace
|
||||
*/
|
||||
if (!iseries_check_file_type (wfth, err, err_info, ISERIES_FORMAT_UNICODE))
|
||||
if (!iseries_check_file_type (wth, err, err_info, ISERIES_FORMAT_UNICODE))
|
||||
{
|
||||
if (*err == 0)
|
||||
return 0;
|
||||
|
@ -243,14 +243,14 @@ iseries_open (wftap* wfth, int *err, gchar ** err_info)
|
|||
return -1;
|
||||
}
|
||||
|
||||
wfth->file_encap = WTAP_ENCAP_ETHERNET;
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_ISERIES;
|
||||
wfth->snapshot_length = 0;
|
||||
wfth->subtype_read = iseries_read;
|
||||
wfth->subtype_seek_read = iseries_seek_read;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wth->file_encap = WTAP_ENCAP_ETHERNET;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_ISERIES;
|
||||
wth->snapshot_length = 0;
|
||||
wth->subtype_read = iseries_read;
|
||||
wth->subtype_seek_read = iseries_seek_read;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
|
||||
if (file_seek (wfth->fh, 0, SEEK_SET, err) == -1)
|
||||
if (file_seek (wth->fh, 0, SEEK_SET, err) == -1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ iseries_open (wftap* wfth, int *err, gchar ** err_info)
|
|||
{
|
||||
if (memcmp (magic + offset, ISERIES_HDR_MAGIC_STR, ISERIES_HDR_MAGIC_LEN) == 0)
|
||||
{
|
||||
if (file_seek (wfth->fh, 0, SEEK_SET, err) == -1)
|
||||
if (file_seek (wth->fh, 0, SEEK_SET, err) == -1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ iseries_open (wftap* wfth, int *err, gchar ** err_info)
|
|||
* Do some basic sanity checking to ensure we can handle the
|
||||
* contents of this trace
|
||||
*/
|
||||
if (!iseries_check_file_type (wfth, err, err_info, ISERIES_FORMAT_ASCII))
|
||||
if (!iseries_check_file_type (wth, err, err_info, ISERIES_FORMAT_ASCII))
|
||||
{
|
||||
if (*err == 0)
|
||||
return 0;
|
||||
|
@ -283,14 +283,14 @@ iseries_open (wftap* wfth, int *err, gchar ** err_info)
|
|||
return -1;
|
||||
}
|
||||
|
||||
wfth->file_encap = WTAP_ENCAP_ETHERNET;
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_ISERIES;
|
||||
wfth->snapshot_length = 0;
|
||||
wfth->subtype_read = iseries_read;
|
||||
wfth->subtype_seek_read = iseries_seek_read;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wth->file_encap = WTAP_ENCAP_ETHERNET;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_ISERIES;
|
||||
wth->snapshot_length = 0;
|
||||
wth->subtype_read = iseries_read;
|
||||
wth->subtype_seek_read = iseries_seek_read;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
|
||||
if (file_seek (wfth->fh, 0, SEEK_SET, err) == -1)
|
||||
if (file_seek (wth->fh, 0, SEEK_SET, err) == -1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ iseries_open (wftap* wfth, int *err, gchar ** err_info)
|
|||
* requisit requirements and additional information.
|
||||
*/
|
||||
static gboolean
|
||||
iseries_check_file_type (wftap * wfth, int *err, gchar **err_info, int format)
|
||||
iseries_check_file_type (wtap * wth, int *err, gchar **err_info, int format)
|
||||
{
|
||||
guint line;
|
||||
int num_items_scanned;
|
||||
|
@ -318,16 +318,16 @@ iseries_check_file_type (wftap * wfth, int *err, gchar **err_info, int format)
|
|||
|
||||
/* Save trace format for passing between packets */
|
||||
iseries = (iseries_t *) g_malloc (sizeof (iseries_t));
|
||||
wfth->priv = (void *) iseries;
|
||||
wth->priv = (void *) iseries;
|
||||
iseries->have_date = FALSE;
|
||||
iseries->format = format;
|
||||
|
||||
for (line = 0; line < ISERIES_HDR_LINES_TO_CHECK; line++)
|
||||
{
|
||||
if (file_gets (buf, ISERIES_LINE_LENGTH, wfth->fh) == NULL)
|
||||
if (file_gets (buf, ISERIES_LINE_LENGTH, wth->fh) == NULL)
|
||||
{
|
||||
/* EOF or error. */
|
||||
*err = file_error (wfth->fh, err_info);
|
||||
*err = file_error (wth->fh, err_info);
|
||||
if (*err == WTAP_ERR_SHORT_READ)
|
||||
*err = 0;
|
||||
return FALSE;
|
||||
|
@ -371,15 +371,14 @@ iseries_check_file_type (wftap * wfth, int *err, gchar **err_info, int format)
|
|||
* Find the next packet and parse it; called from wtap_read().
|
||||
*/
|
||||
static gboolean
|
||||
iseries_read (wftap* wfth, int *err, gchar ** err_info, gint64 *data_offset)
|
||||
iseries_read (wtap * wth, int *err, gchar ** err_info, gint64 *data_offset)
|
||||
{
|
||||
gint64 offset;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
/*
|
||||
* Locate the next packet
|
||||
*/
|
||||
offset = iseries_seek_next_packet (wfth, err, err_info);
|
||||
offset = iseries_seek_next_packet (wth, err, err_info);
|
||||
if (offset < 0)
|
||||
return FALSE;
|
||||
*data_offset = offset;
|
||||
|
@ -387,7 +386,7 @@ iseries_read (wftap* wfth, int *err, gchar ** err_info, gint64 *data_offset)
|
|||
/*
|
||||
* Parse the packet and extract the various fields
|
||||
*/
|
||||
return iseries_parse_packet (wfth, wfth->fh, &wth->phdr, wfth->frame_buffer,
|
||||
return iseries_parse_packet (wth, wth->fh, &wth->phdr, wth->frame_buffer,
|
||||
err, err_info);
|
||||
}
|
||||
|
||||
|
@ -398,9 +397,9 @@ iseries_read (wftap* wfth, int *err, gchar ** err_info, gint64 *data_offset)
|
|||
* to null or an additional error string.
|
||||
*/
|
||||
static gint64
|
||||
iseries_seek_next_packet (wftap* wfth, int *err, gchar **err_info)
|
||||
iseries_seek_next_packet (wtap * wth, int *err, gchar **err_info)
|
||||
{
|
||||
iseries_t *iseries = (iseries_t *)wfth->priv;
|
||||
iseries_t *iseries = (iseries_t *)wth->priv;
|
||||
char buf[ISERIES_LINE_LENGTH],type[5];
|
||||
int line, num_items_scanned;
|
||||
gint64 cur_off;
|
||||
|
@ -408,10 +407,10 @@ iseries_seek_next_packet (wftap* wfth, int *err, gchar **err_info)
|
|||
|
||||
for (line = 0; line < ISERIES_MAX_TRACE_LEN; line++)
|
||||
{
|
||||
if (file_gets (buf, ISERIES_LINE_LENGTH, wfth->fh) == NULL)
|
||||
if (file_gets (buf, ISERIES_LINE_LENGTH, wth->fh) == NULL)
|
||||
{
|
||||
/* EOF or error. */
|
||||
*err = file_error (wfth->fh, err_info);
|
||||
*err = file_error (wth->fh, err_info);
|
||||
return -1;
|
||||
}
|
||||
/* Convert UNICODE to ASCII if required and determine */
|
||||
|
@ -434,13 +433,13 @@ iseries_seek_next_packet (wftap* wfth, int *err, gchar **err_info)
|
|||
if (num_items_scanned == 1)
|
||||
{
|
||||
/* Rewind to beginning of line */
|
||||
cur_off = file_tell (wfth->fh);
|
||||
cur_off = file_tell (wth->fh);
|
||||
if (cur_off == -1)
|
||||
{
|
||||
*err = file_error (wfth->fh, err_info);
|
||||
*err = file_error (wth->fh, err_info);
|
||||
return -1;
|
||||
}
|
||||
if (file_seek (wfth->fh, cur_off - buflen, SEEK_SET, err) == -1)
|
||||
if (file_seek (wth->fh, cur_off - buflen, SEEK_SET, err) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -459,19 +458,18 @@ iseries_seek_next_packet (wftap* wfth, int *err, gchar **err_info)
|
|||
* Read packets in random-access fashion
|
||||
*/
|
||||
static gboolean
|
||||
iseries_seek_read (wftap* wfth, gint64 seek_off, void* header,
|
||||
iseries_seek_read (wtap * wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||
Buffer * buf, int *err, gchar ** err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
|
||||
/* seek to packet location */
|
||||
if (file_seek (wfth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
|
||||
if (file_seek (wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
* Parse the packet and extract the various fields
|
||||
*/
|
||||
return iseries_parse_packet (wfth, wfth->random_fh, phdr, buf,
|
||||
return iseries_parse_packet (wth, wth->random_fh, phdr, buf,
|
||||
err, err_info);
|
||||
}
|
||||
|
||||
|
@ -557,10 +555,10 @@ done:
|
|||
|
||||
/* Parses a packet. */
|
||||
static gboolean
|
||||
iseries_parse_packet (wftap* wfth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||
iseries_parse_packet (wtap * wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
iseries_t *iseries = (iseries_t *)wfth->priv;
|
||||
iseries_t *iseries = (iseries_t *)wth->priv;
|
||||
gint64 cur_off;
|
||||
gboolean isValid, isCurrentPacket;
|
||||
int num_items_scanned, line, pktline, buflen;
|
||||
|
|
|
@ -24,6 +24,6 @@
|
|||
#include <glib.h>
|
||||
#include <wtap.h>
|
||||
|
||||
int iseries_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int iseries_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "wtap.h"
|
||||
#include "file_wrappers.h"
|
||||
|
@ -624,9 +623,8 @@ process_packet_data(struct wtap_pkthdr *phdr, Buffer *target, guint8 *buffer,
|
|||
phdr->pseudo_header.k12.stuff = k12;
|
||||
}
|
||||
|
||||
static gboolean k12_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset) {
|
||||
k12_t *k12 = (k12_t *)wfth->priv;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
static gboolean k12_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) {
|
||||
k12_t *k12 = (k12_t *)wth->priv;
|
||||
k12_src_desc_t* src_desc;
|
||||
guint8* buffer;
|
||||
gint64 offset;
|
||||
|
@ -634,7 +632,7 @@ static gboolean k12_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_o
|
|||
guint32 type;
|
||||
guint32 src_id;
|
||||
|
||||
offset = file_tell(wfth->fh);
|
||||
offset = file_tell(wth->fh);
|
||||
|
||||
/* ignore the record if it isn't a packet */
|
||||
do {
|
||||
|
@ -642,7 +640,7 @@ static gboolean k12_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_o
|
|||
|
||||
*data_offset = offset;
|
||||
|
||||
len = get_record(k12, wfth->fh, offset, FALSE, err, err_info);
|
||||
len = get_record(k12, wth->fh, offset, FALSE, err, err_info);
|
||||
|
||||
if (len < 0) {
|
||||
/* read error */
|
||||
|
@ -681,26 +679,25 @@ static gboolean k12_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_o
|
|||
|
||||
} while ( ((type & K12_MASK_PACKET) != K12_REC_PACKET && (type & K12_MASK_PACKET) != K12_REC_D0020) || !src_id || !src_desc );
|
||||
|
||||
process_packet_data(&wth->phdr, wfth->frame_buffer, buffer, len, k12);
|
||||
process_packet_data(&wth->phdr, wth->frame_buffer, buffer, len, k12);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static gboolean k12_seek_read(wftap *wfth, gint64 seek_off, void* header, Buffer *buf, int *err, gchar **err_info) {
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
k12_t *k12 = (k12_t *)wfth->priv;
|
||||
static gboolean k12_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info) {
|
||||
k12_t *k12 = (k12_t *)wth->priv;
|
||||
guint8* buffer;
|
||||
gint len;
|
||||
|
||||
K12_DBG(5,("k12_seek_read: ENTER"));
|
||||
|
||||
if ( file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1) {
|
||||
if ( file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
|
||||
K12_DBG(5,("k12_seek_read: SEEK ERROR"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
len = get_record(k12, wfth->random_fh, seek_off, TRUE, err, err_info);
|
||||
len = get_record(k12, wth->random_fh, seek_off, TRUE, err, err_info);
|
||||
if (len < 0) {
|
||||
K12_DBG(5,("k12_seek_read: READ ERROR"));
|
||||
return FALSE;
|
||||
|
@ -758,11 +755,11 @@ static void destroy_k12_file_data(k12_t* fd) {
|
|||
g_free(fd);
|
||||
}
|
||||
|
||||
static void k12_close(wftap *wfth) {
|
||||
k12_t *k12 = (k12_t *)wfth->priv;
|
||||
static void k12_close(wtap *wth) {
|
||||
k12_t *k12 = (k12_t *)wth->priv;
|
||||
|
||||
destroy_k12_file_data(k12);
|
||||
wfth->priv = NULL; /* destroy_k12_file_data freed it */
|
||||
wth->priv = NULL; /* destroy_k12_file_data freed it */
|
||||
#ifdef DEBUG_K12
|
||||
K12_DBG(5,("k12_close: CLOSED"));
|
||||
if (env_file) fclose(dbg_out);
|
||||
|
@ -770,7 +767,7 @@ static void k12_close(wftap *wfth) {
|
|||
}
|
||||
|
||||
|
||||
int k12_open(wftap *wfth, int *err, gchar **err_info) {
|
||||
int k12_open(wtap *wth, int *err, gchar **err_info) {
|
||||
k12_src_desc_t* rec;
|
||||
guint8 header_buffer[0x200];
|
||||
guint8* read_buffer;
|
||||
|
@ -800,9 +797,9 @@ int k12_open(wftap *wfth, int *err, gchar **err_info) {
|
|||
K12_DBG(1,("k12_open: ENTER debug_level=%u",debug_level));
|
||||
#endif
|
||||
|
||||
if ( file_read(header_buffer,0x200,wfth->fh) != 0x200 ) {
|
||||
if ( file_read(header_buffer,0x200,wth->fh) != 0x200 ) {
|
||||
K12_DBG(1,("k12_open: FILE HEADER TOO SHORT OR READ ERROR"));
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -828,7 +825,7 @@ int k12_open(wftap *wfth, int *err, gchar **err_info) {
|
|||
|
||||
do {
|
||||
|
||||
len = get_record(file_data, wfth->fh, offset, FALSE, err, err_info);
|
||||
len = get_record(file_data, wth->fh, offset, FALSE, err, err_info);
|
||||
|
||||
if ( len < 0 ) {
|
||||
K12_DBG(1,("k12_open: BAD HEADER RECORD",len));
|
||||
|
@ -866,7 +863,7 @@ int k12_open(wftap *wfth, int *err, gchar **err_info) {
|
|||
/*
|
||||
* we are at the first packet record, rewind and leave.
|
||||
*/
|
||||
if (file_seek(wfth->fh, offset, SEEK_SET, err) == -1) {
|
||||
if (file_seek(wth->fh, offset, SEEK_SET, err) == -1) {
|
||||
destroy_k12_file_data(file_data);
|
||||
return -1;
|
||||
}
|
||||
|
@ -996,14 +993,14 @@ int k12_open(wftap *wfth, int *err, gchar **err_info) {
|
|||
}
|
||||
} while(1);
|
||||
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_K12;
|
||||
wfth->file_encap = WTAP_ENCAP_K12;
|
||||
wfth->snapshot_length = 0;
|
||||
wfth->subtype_read = k12_read;
|
||||
wfth->subtype_seek_read = k12_seek_read;
|
||||
wfth->subtype_close = k12_close;
|
||||
wfth->priv = (void *)file_data;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_K12;
|
||||
wth->file_encap = WTAP_ENCAP_K12;
|
||||
wth->snapshot_length = 0;
|
||||
wth->subtype_read = k12_read;
|
||||
wth->subtype_seek_read = k12_seek_read;
|
||||
wth->subtype_close = k12_close;
|
||||
wth->priv = (void *)file_data;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -1027,24 +1024,24 @@ int k12_dump_can_write_encap(int encap) {
|
|||
|
||||
static const gchar dumpy_junk[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
|
||||
|
||||
static gboolean k12_dump_record(wftap_dumper *wdh, guint32 len, guint8* buffer, int *err_p) {
|
||||
static gboolean k12_dump_record(wtap_dumper *wdh, guint32 len, guint8* buffer, int *err_p) {
|
||||
k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
|
||||
guint32 junky_offset = (0x2000 - ( (k12->file_offset - 0x200) % 0x2000 )) % 0x2000;
|
||||
|
||||
if (len > junky_offset) {
|
||||
if (junky_offset) {
|
||||
if (! wftap_dump_file_write(wdh, buffer, junky_offset, err_p))
|
||||
if (! wtap_dump_file_write(wdh, buffer, junky_offset, err_p))
|
||||
return FALSE;
|
||||
}
|
||||
if (! wftap_dump_file_write(wdh, dumpy_junk, 0x10, err_p))
|
||||
if (! wtap_dump_file_write(wdh, dumpy_junk, 0x10, err_p))
|
||||
return FALSE;
|
||||
|
||||
if (! wftap_dump_file_write(wdh, buffer+junky_offset, len - junky_offset, err_p))
|
||||
if (! wtap_dump_file_write(wdh, buffer+junky_offset, len - junky_offset, err_p))
|
||||
return FALSE;
|
||||
|
||||
k12->file_offset += len + 0x10;
|
||||
} else {
|
||||
if (! wftap_dump_file_write(wdh, buffer, len, err_p))
|
||||
if (! wtap_dump_file_write(wdh, buffer, len, err_p))
|
||||
return FALSE;
|
||||
k12->file_offset += len;
|
||||
}
|
||||
|
@ -1055,7 +1052,7 @@ static gboolean k12_dump_record(wftap_dumper *wdh, guint32 len, guint8* buffer,
|
|||
|
||||
static void k12_dump_src_setting(gpointer k _U_, gpointer v, gpointer p) {
|
||||
k12_src_desc_t* src_desc = (k12_src_desc_t*)v;
|
||||
wftap_dumper *wdh = (wftap_dumper *)p;
|
||||
wtap_dumper *wdh = (wtap_dumper *)p;
|
||||
guint32 len;
|
||||
guint offset;
|
||||
guint i;
|
||||
|
@ -1161,7 +1158,7 @@ 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 */
|
||||
}
|
||||
|
||||
static gboolean k12_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
static gboolean k12_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err) {
|
||||
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
|
||||
k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
|
||||
|
@ -1211,41 +1208,41 @@ static gboolean k12_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
|
||||
static const guint8 k12_eof[] = {0xff,0xff};
|
||||
|
||||
static gboolean k12_dump_close(wftap_dumper *wdh, int *err) {
|
||||
static gboolean k12_dump_close(wtap_dumper *wdh, int *err) {
|
||||
k12_dump_t *k12 = (k12_dump_t *)wdh->priv;
|
||||
union {
|
||||
guint8 b[sizeof(guint32)];
|
||||
guint32 u;
|
||||
} d;
|
||||
|
||||
if (! wftap_dump_file_write(wdh, k12_eof, 2, err))
|
||||
if (! wtap_dump_file_write(wdh, k12_eof, 2, err))
|
||||
return FALSE;
|
||||
|
||||
if (wftap_dump_file_seek(wdh, 8, SEEK_SET, err) == -1)
|
||||
if (wtap_dump_file_seek(wdh, 8, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
d.u = g_htonl(k12->file_len);
|
||||
|
||||
if (! wftap_dump_file_write(wdh, d.b, 4, err))
|
||||
if (! wtap_dump_file_write(wdh, d.b, 4, err))
|
||||
return FALSE;
|
||||
|
||||
d.u = g_htonl(k12->num_of_records);
|
||||
|
||||
if (! wftap_dump_file_write(wdh, d.b, 4, err))
|
||||
if (! wtap_dump_file_write(wdh, d.b, 4, err))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
gboolean k12_dump_open(wftap_dumper *wdh, int *err) {
|
||||
gboolean k12_dump_open(wtap_dumper *wdh, int *err) {
|
||||
k12_dump_t *k12;
|
||||
|
||||
if ( ! wftap_dump_file_write(wdh, k12_file_magic, 8, err)) {
|
||||
if ( ! wtap_dump_file_write(wdh, k12_file_magic, 8, err)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (wftap_dump_file_seek(wdh, 0x200, SEEK_SET, err) == -1)
|
||||
if (wtap_dump_file_seek(wdh, 0x200, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
wdh->subtype_write = k12_dump;
|
||||
|
|
|
@ -24,12 +24,12 @@
|
|||
#include <glib.h>
|
||||
#include <wtap.h>
|
||||
|
||||
int k12_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int k12_open(wtap *wth, int *err, gchar **err_info);
|
||||
int k12_dump_can_write_encap(int encap);
|
||||
gboolean k12_dump_open(wftap_dumper *wdh, int *err);
|
||||
int k12text_open(wftap *wfth, int *err, gchar **err_info _U_);
|
||||
gboolean k12_dump_open(wtap_dumper *wdh, int *err);
|
||||
int k12text_open(wtap *wth, int *err, gchar **err_info _U_);
|
||||
int k12text_dump_can_write_encap(int encap);
|
||||
gboolean k12text_dump_open(wftap_dumper *wdh, int *err);
|
||||
gboolean k12text_dump_open(wtap_dumper *wdh, int *err);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -72,7 +72,6 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "wtap.h"
|
||||
#include "file_wrappers.h"
|
||||
|
@ -246,10 +245,9 @@ k12text_reset(FILE_T fh)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
k12text_read(wftap *wfth, int *err, char ** err_info, gint64 *data_offset)
|
||||
k12text_read(wtap *wth, int *err, char ** err_info, gint64 *data_offset)
|
||||
{
|
||||
k12text_t *k12text = (k12text_t *)wfth->priv;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
k12text_t *k12text = (k12text_t *)wth->priv;
|
||||
|
||||
/*
|
||||
* We seek to the file position after the end of the previous frame
|
||||
|
@ -260,10 +258,10 @@ k12text_read(wftap *wfth, int *err, char ** err_info, gint64 *data_offset)
|
|||
* init vars set by lexer.
|
||||
*/
|
||||
|
||||
if ( file_seek(wfth->fh, k12text->next_frame_offset, SEEK_SET, err) == -1) {
|
||||
if ( file_seek(wth->fh, k12text->next_frame_offset, SEEK_SET, err) == -1) {
|
||||
return FALSE;
|
||||
}
|
||||
k12text_reset(wfth->fh); /* init lexer buffer and vars set by lexer */
|
||||
k12text_reset(wth->fh); /* init lexer buffer and vars set by lexer */
|
||||
|
||||
BEGIN(NEXT_FRAME);
|
||||
yylex();
|
||||
|
@ -284,20 +282,19 @@ k12text_read(wftap *wfth, int *err, char ** err_info, gint64 *data_offset)
|
|||
|
||||
k12text_set_headers(&wth->phdr);
|
||||
|
||||
buffer_assure_space(wfth->frame_buffer, wth->phdr.caplen);
|
||||
memcpy(buffer_start_ptr(wfth->frame_buffer), bb, wth->phdr.caplen);
|
||||
buffer_assure_space(wth->frame_buffer, wth->phdr.caplen);
|
||||
memcpy(buffer_start_ptr(wth->frame_buffer), bb, wth->phdr.caplen);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
k12text_seek_read(wftap *wfth, gint64 seek_off, void* header, Buffer *buf, int *err, char **err_info)
|
||||
k12text_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, char **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
if ( file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1) {
|
||||
if ( file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1) {
|
||||
return FALSE;
|
||||
}
|
||||
k12text_reset(wfth->random_fh); /* init lexer buffer and vars set by lexer */
|
||||
k12text_reset(wth->random_fh); /* init lexer buffer and vars set by lexer */
|
||||
|
||||
BEGIN(NEXT_FRAME);
|
||||
yylex();
|
||||
|
@ -322,30 +319,30 @@ k12text_seek_read(wftap *wfth, gint64 seek_off, void* header, Buffer *buf, int *
|
|||
}
|
||||
|
||||
int
|
||||
k12text_open(wftap *wfth, int *err, gchar **err_info _U_)
|
||||
k12text_open(wtap *wth, int *err, gchar **err_info _U_)
|
||||
{
|
||||
k12text_t *k12text;
|
||||
|
||||
k12text_reset(wfth->fh); /* init lexer buffer and vars set by lexer */
|
||||
k12text_reset(wth->fh); /* init lexer buffer and vars set by lexer */
|
||||
|
||||
BEGIN(MAGIC);
|
||||
yylex();
|
||||
|
||||
if (! is_k12text) return 0;
|
||||
|
||||
if ( file_seek(wfth->fh, 0, SEEK_SET, err) == -1) {
|
||||
if ( file_seek(wth->fh, 0, SEEK_SET, err) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
k12text = (k12text_t *)g_malloc(sizeof(k12text_t));
|
||||
wfth->priv = (void *)k12text;
|
||||
wth->priv = (void *)k12text;
|
||||
k12text->next_frame_offset = 0;
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_K12TEXT;
|
||||
wfth->file_encap = WTAP_ENCAP_PER_PACKET;
|
||||
wfth->snapshot_length = 0;
|
||||
wfth->subtype_read = k12text_read;
|
||||
wfth->subtype_seek_read = k12text_seek_read;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_K12TEXT;
|
||||
wth->file_encap = WTAP_ENCAP_PER_PACKET;
|
||||
wth->snapshot_length = 0;
|
||||
wth->subtype_read = k12text_read;
|
||||
wth->subtype_seek_read = k12text_seek_read;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -362,7 +359,7 @@ static const struct { int e; const char* s; } encaps[] = {
|
|||
};
|
||||
|
||||
static gboolean
|
||||
k12text_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
k12text_dump(wtap_dumper *wdh _U_, const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err) {
|
||||
#define K12BUF_SIZE 196808
|
||||
char *buf;
|
||||
|
@ -425,7 +422,7 @@ k12text_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
wl = g_snprintf(p, left, "\r\n\r\n");
|
||||
left -= wl;
|
||||
|
||||
ret = wftap_dump_file_write(wdh, buf, K12BUF_SIZE - left, err);
|
||||
ret = wtap_dump_file_write(wdh, buf, K12BUF_SIZE - left, err);
|
||||
|
||||
g_free(buf);
|
||||
return ret;
|
||||
|
@ -433,17 +430,17 @@ k12text_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
|
||||
|
||||
gboolean
|
||||
k12text_dump_open(wftap_dumper *wdh, int *err _U_)
|
||||
k12text_dump_open(wtap_dumper *wdh, int *err _U_)
|
||||
{
|
||||
wdh->subtype_write = k12text_dump;
|
||||
wdh->subtype_write = k12text_dump;
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
k12text_dump_can_write_encap(int encap)
|
||||
{
|
||||
switch (encap) {
|
||||
switch (encap) {
|
||||
case WTAP_ENCAP_PER_PACKET:
|
||||
case WTAP_ENCAP_ETHERNET:
|
||||
case WTAP_ENCAP_MTP3:
|
||||
|
@ -453,7 +450,7 @@ k12text_dump_can_write_encap(int encap)
|
|||
case WTAP_ENCAP_ATM_PDUS:
|
||||
default:
|
||||
return WTAP_ERR_UNSUPPORTED_ENCAP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -271,13 +270,13 @@ typedef struct {
|
|||
time_t start;
|
||||
} lanalyzer_t;
|
||||
|
||||
static gboolean lanalyzer_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean lanalyzer_seek_read(wftap *wth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean lanalyzer_dump_close(wftap_dumper *wdh, int *err);
|
||||
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean lanalyzer_dump_close(wtap_dumper *wdh, int *err);
|
||||
|
||||
int lanalyzer_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
int bytes_read;
|
||||
LA_RecordHeader rec_header;
|
||||
|
@ -290,12 +289,11 @@ int lanalyzer_open(wftap *wfth, int *err, gchar **err_info)
|
|||
guint16 cr_year;
|
||||
struct tm tm;
|
||||
lanalyzer_t *lanalyzer;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(&rec_header, LA_RecordHeaderSize, wfth->fh);
|
||||
bytes_read = file_read(&rec_header, LA_RecordHeaderSize, wth->fh);
|
||||
if (bytes_read != LA_RecordHeaderSize) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -315,9 +313,9 @@ int lanalyzer_open(wftap *wfth, int *err, gchar **err_info)
|
|||
*/
|
||||
return 0;
|
||||
}
|
||||
bytes_read = file_read(&header_fixed, sizeof header_fixed, wfth->fh);
|
||||
bytes_read = file_read(&header_fixed, sizeof header_fixed, wth->fh);
|
||||
if (bytes_read != sizeof header_fixed) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -327,9 +325,9 @@ int lanalyzer_open(wftap *wfth, int *err, gchar **err_info)
|
|||
if (record_length != 0) {
|
||||
/* Read the rest of the record as a comment. */
|
||||
comment = (char *)g_malloc(record_length + 1);
|
||||
bytes_read = file_read(comment, record_length, wfth->fh);
|
||||
bytes_read = file_read(comment, record_length, wth->fh);
|
||||
if (bytes_read != record_length) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -339,22 +337,22 @@ int lanalyzer_open(wftap *wfth, int *err, gchar **err_info)
|
|||
}
|
||||
|
||||
/* If we made it this far, then the file is a LANAlyzer file.
|
||||
* Let's get some info from it. Note that we get wfth->snapshot_length
|
||||
* Let's get some info from it. Note that we get wth->snapshot_length
|
||||
* from a record later in the file. */
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_LANALYZER;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_LANALYZER;
|
||||
lanalyzer = (lanalyzer_t *)g_malloc(sizeof(lanalyzer_t));
|
||||
wfth->priv = (void *)lanalyzer;
|
||||
wfth->subtype_read = lanalyzer_read;
|
||||
wfth->subtype_seek_read = lanalyzer_seek_read;
|
||||
wfth->snapshot_length = 0;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
wth->priv = (void *)lanalyzer;
|
||||
wth->subtype_read = lanalyzer_read;
|
||||
wth->subtype_seek_read = lanalyzer_seek_read;
|
||||
wth->snapshot_length = 0;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
|
||||
/* Read records until we find the start of packets */
|
||||
while (1) {
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(&rec_header, LA_RecordHeaderSize, wfth->fh);
|
||||
bytes_read = file_read(&rec_header, LA_RecordHeaderSize, wth->fh);
|
||||
if (bytes_read != LA_RecordHeaderSize) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return -1;
|
||||
|
@ -369,9 +367,9 @@ int lanalyzer_open(wftap *wfth, int *err, gchar **err_info)
|
|||
case RT_Summary:
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(summary, sizeof summary,
|
||||
wfth->fh);
|
||||
wth->fh);
|
||||
if (bytes_read != sizeof summary) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return -1;
|
||||
|
@ -403,15 +401,15 @@ int lanalyzer_open(wftap *wfth, int *err, gchar **err_info)
|
|||
/*g_message("Day %d Month %d Year %d", tm.tm_mday,
|
||||
tm.tm_mon, tm.tm_year);*/
|
||||
mxslc = pletoh16(&summary[30]);
|
||||
wfth->snapshot_length = mxslc;
|
||||
wth->snapshot_length = mxslc;
|
||||
|
||||
board_type = pletoh16(&summary[188]);
|
||||
switch (board_type) {
|
||||
case BOARD_325:
|
||||
wfth->file_encap = WTAP_ENCAP_ETHERNET;
|
||||
wth->file_encap = WTAP_ENCAP_ETHERNET;
|
||||
break;
|
||||
case BOARD_325TR:
|
||||
wfth->file_encap = WTAP_ENCAP_TOKEN_RING;
|
||||
wth->file_encap = WTAP_ENCAP_TOKEN_RING;
|
||||
break;
|
||||
default:
|
||||
*err = WTAP_ERR_UNSUPPORTED_ENCAP;
|
||||
|
@ -425,13 +423,13 @@ int lanalyzer_open(wftap *wfth, int *err, gchar **err_info)
|
|||
case RT_PacketData:
|
||||
/* Go back header number of bytes so that lanalyzer_read
|
||||
* can read this header */
|
||||
if (file_seek(wfth->fh, -LA_RecordHeaderSize, SEEK_CUR, err) == -1) {
|
||||
if (file_seek(wth->fh, -LA_RecordHeaderSize, SEEK_CUR, err) == -1) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
|
||||
default:
|
||||
if (file_seek(wfth->fh, record_length, SEEK_CUR, err) == -1) {
|
||||
if (file_seek(wth->fh, record_length, SEEK_CUR, err) == -1) {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
@ -441,7 +439,7 @@ int lanalyzer_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
#define DESCRIPTOR_LEN 32
|
||||
|
||||
static gboolean lanalyzer_read_trace_record(wftap *wfth, 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)
|
||||
{
|
||||
int bytes_read;
|
||||
|
@ -533,7 +531,7 @@ static gboolean lanalyzer_read_trace_record(wftap *wfth, FILE_T fh,
|
|||
t = (((guint64)time_low) << 0) + (((guint64)time_med) << 16) +
|
||||
(((guint64)time_high) << 32);
|
||||
tsecs = (time_t) (t/2000000);
|
||||
lanalyzer = (lanalyzer_t *)wfth->priv;
|
||||
lanalyzer = (lanalyzer_t *)wth->priv;
|
||||
phdr->ts.secs = tsecs + lanalyzer->start;
|
||||
phdr->ts.nsecs = ((guint32) (t - tsecs*2000000)) * 500;
|
||||
|
||||
|
@ -549,7 +547,7 @@ static gboolean lanalyzer_read_trace_record(wftap *wfth, FILE_T fh,
|
|||
phdr->len = true_size;
|
||||
phdr->caplen = packet_size;
|
||||
|
||||
switch (wfth->file_encap) {
|
||||
switch (wth->file_encap) {
|
||||
|
||||
case WTAP_ENCAP_ETHERNET:
|
||||
/* We assume there's no FCS in this frame. */
|
||||
|
@ -562,26 +560,24 @@ static gboolean lanalyzer_read_trace_record(wftap *wfth, FILE_T fh,
|
|||
}
|
||||
|
||||
/* Read the next packet */
|
||||
static gboolean lanalyzer_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
/* Read the record */
|
||||
return lanalyzer_read_trace_record(wfth, wfth->fh, &wth->phdr,
|
||||
wfth->frame_buffer, err, err_info);
|
||||
return lanalyzer_read_trace_record(wth, wth->fh, &wth->phdr,
|
||||
wth->frame_buffer, err, err_info);
|
||||
}
|
||||
|
||||
static gboolean lanalyzer_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info)
|
||||
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
/* Read the record */
|
||||
if (!lanalyzer_read_trace_record(wfth, wfth->random_fh, phdr, buf,
|
||||
if (!lanalyzer_read_trace_record(wth, wth->random_fh, phdr, buf,
|
||||
err, err_info)) {
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
|
@ -594,14 +590,14 @@ static gboolean lanalyzer_seek_read(wftap *wfth, gint64 seek_off,
|
|||
* Returns TRUE on success, FALSE on error
|
||||
* Write "cnt" bytes of zero with error control
|
||||
*---------------------------------------------------*/
|
||||
static gboolean s0write(wftap_dumper *wdh, size_t cnt, int *err)
|
||||
static gboolean s0write(wtap_dumper *wdh, size_t cnt, int *err)
|
||||
{
|
||||
size_t snack;
|
||||
|
||||
while (cnt) {
|
||||
snack = cnt > 64 ? 64 : cnt;
|
||||
|
||||
if (!wftap_dump_file_write(wdh, z64, snack, err))
|
||||
if (!wtap_dump_file_write(wdh, z64, snack, err))
|
||||
return FALSE;
|
||||
cnt -= snack;
|
||||
}
|
||||
|
@ -612,25 +608,25 @@ static gboolean s0write(wftap_dumper *wdh, size_t cnt, int *err)
|
|||
* Returns TRUE on success, FALSE on error
|
||||
* Write an 8-bit value with error control
|
||||
*---------------------------------------------------*/
|
||||
static gboolean s8write(wftap_dumper *wdh, const guint8 s8, int *err)
|
||||
static gboolean s8write(wtap_dumper *wdh, const guint8 s8, int *err)
|
||||
{
|
||||
return wftap_dump_file_write(wdh, &s8, 1, err);
|
||||
return wtap_dump_file_write(wdh, &s8, 1, err);
|
||||
}
|
||||
/*---------------------------------------------------
|
||||
* Returns TRUE on success, FALSE on error
|
||||
* Write a 16-bit value with error control
|
||||
*---------------------------------------------------*/
|
||||
static gboolean s16write(wftap_dumper *wdh, const guint16 s16, int *err)
|
||||
static gboolean s16write(wtap_dumper *wdh, const guint16 s16, int *err)
|
||||
{
|
||||
return wftap_dump_file_write(wdh, &s16, 2, err);
|
||||
return wtap_dump_file_write(wdh, &s16, 2, err);
|
||||
}
|
||||
/*---------------------------------------------------
|
||||
* Returns TRUE on success, FALSE on error
|
||||
* Write a 32-bit value with error control
|
||||
*---------------------------------------------------*/
|
||||
static gboolean s32write(wftap_dumper *wdh, const guint32 s32, int *err)
|
||||
static gboolean s32write(wtap_dumper *wdh, const guint32 s32, int *err)
|
||||
{
|
||||
return wftap_dump_file_write(wdh, &s32, 4, err);
|
||||
return wtap_dump_file_write(wdh, &s32, 4, err);
|
||||
}
|
||||
/*---------------------------------------------------
|
||||
*
|
||||
|
@ -653,7 +649,7 @@ static void my_timersub(const struct timeval *a,
|
|||
* Write a record for a packet to a dump file.
|
||||
* Returns TRUE on success, FALSE on failure.
|
||||
*---------------------------------------------------*/
|
||||
static gboolean lanalyzer_dump(wftap_dumper *wdh,
|
||||
static gboolean lanalyzer_dump(wtap_dumper *wdh,
|
||||
const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err)
|
||||
{
|
||||
|
@ -730,7 +726,7 @@ static gboolean lanalyzer_dump(wftap_dumper *wdh,
|
|||
if (!s0write(wdh, 12, err))
|
||||
return FALSE;
|
||||
|
||||
if (!wftap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
return FALSE;
|
||||
|
||||
wdh->bytes_dumped += thisSize;
|
||||
|
@ -761,16 +757,16 @@ int lanalyzer_dump_can_write_encap(int encap)
|
|||
* Returns TRUE on success, FALSE on failure; sets "*err" to an
|
||||
* error code on failure
|
||||
*---------------------------------------------------*/
|
||||
gboolean lanalyzer_dump_open(wftap_dumper *wdh, int *err)
|
||||
gboolean lanalyzer_dump_open(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
int jump;
|
||||
void *tmp;
|
||||
|
||||
tmp = g_malloc(sizeof(LA_TmpInfo));
|
||||
if (!tmp) {
|
||||
*err = errno;
|
||||
return FALSE;
|
||||
}
|
||||
*err = errno;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
((LA_TmpInfo*)tmp)->init = FALSE;
|
||||
wdh->priv = tmp;
|
||||
|
@ -792,8 +788,8 @@ gboolean lanalyzer_dump_open(wftap_dumper *wdh, int *err)
|
|||
+ sizeof (LA_CyclicInformationFake)
|
||||
+ LA_IndexRecordSize;
|
||||
|
||||
if (wftap_dump_file_seek(wdh, jump, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
if (wtap_dump_file_seek(wdh, jump, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
wdh->bytes_dumped = jump;
|
||||
return TRUE;
|
||||
|
@ -802,7 +798,7 @@ gboolean lanalyzer_dump_open(wftap_dumper *wdh, int *err)
|
|||
/*---------------------------------------------------
|
||||
*
|
||||
*---------------------------------------------------*/
|
||||
static gboolean lanalyzer_dump_header(wftap_dumper *wdh, int *err)
|
||||
static gboolean lanalyzer_dump_header(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->priv);
|
||||
guint16 board_type = itmp->encap == WTAP_ENCAP_TOKEN_RING
|
||||
|
@ -822,27 +818,27 @@ static gboolean lanalyzer_dump_header(wftap_dumper *wdh, int *err)
|
|||
if (fT == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (wftap_dump_file_seek(wdh, 0, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
if (wtap_dump_file_seek(wdh, 0, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
if (!wftap_dump_file_write(wdh, &LA_HeaderRegularFake,
|
||||
if (!wtap_dump_file_write(wdh, &LA_HeaderRegularFake,
|
||||
sizeof LA_HeaderRegularFake, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &LA_RxChannelNameFake,
|
||||
return FALSE;
|
||||
if (!wtap_dump_file_write(wdh, &LA_RxChannelNameFake,
|
||||
sizeof LA_RxChannelNameFake, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &LA_TxChannelNameFake,
|
||||
return FALSE;
|
||||
if (!wtap_dump_file_write(wdh, &LA_TxChannelNameFake,
|
||||
sizeof LA_TxChannelNameFake, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &LA_RxTemplateNameFake,
|
||||
return FALSE;
|
||||
if (!wtap_dump_file_write(wdh, &LA_RxTemplateNameFake,
|
||||
sizeof LA_RxTemplateNameFake, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &LA_TxTemplateNameFake,
|
||||
return FALSE;
|
||||
if (!wtap_dump_file_write(wdh, &LA_TxTemplateNameFake,
|
||||
sizeof LA_TxTemplateNameFake, err))
|
||||
return FALSE;
|
||||
if (!wftap_dump_file_write(wdh, &LA_DisplayOptionsFake,
|
||||
return FALSE;
|
||||
if (!wtap_dump_file_write(wdh, &LA_DisplayOptionsFake,
|
||||
sizeof LA_DisplayOptionsFake, err))
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
/*-----------------------------------------------------------------*/
|
||||
if (!s16write(wdh, GUINT16_TO_LE(RT_Summary), err)) /* rid */
|
||||
return FALSE;
|
||||
|
@ -915,7 +911,7 @@ static gboolean lanalyzer_dump_header(wftap_dumper *wdh, int *err)
|
|||
if (!s32write(wdh, GUINT32_TO_LE(itmp->pkts), err)) /* ssr.totpkts */
|
||||
return FALSE;
|
||||
/*-----------------------------------------------------------------*/
|
||||
if (!wftap_dump_file_write(wdh, &LA_CyclicInformationFake,
|
||||
if (!wtap_dump_file_write(wdh, &LA_CyclicInformationFake,
|
||||
sizeof LA_CyclicInformationFake, err))
|
||||
return FALSE;
|
||||
/*-----------------------------------------------------------------*/
|
||||
|
@ -935,7 +931,7 @@ static gboolean lanalyzer_dump_header(wftap_dumper *wdh, int *err)
|
|||
* Finish writing to a dump file.
|
||||
* Returns TRUE on success, FALSE on failure.
|
||||
*---------------------------------------------------*/
|
||||
static gboolean lanalyzer_dump_close(wftap_dumper *wdh, int *err)
|
||||
static gboolean lanalyzer_dump_close(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
lanalyzer_dump_header(wdh,err);
|
||||
return *err ? FALSE : TRUE;
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include <glib.h>
|
||||
#include <wtap.h>
|
||||
|
||||
int lanalyzer_open(wftap *wfth, int *err, gchar **err_info);
|
||||
gboolean lanalyzer_dump_open(wftap_dumper *wdh, int *err);
|
||||
int lanalyzer_open(wtap *wth, int *err, gchar **err_info);
|
||||
gboolean lanalyzer_dump_open(wtap_dumper *wdh, int *err);
|
||||
int lanalyzer_dump_can_write_encap(int encap);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -62,21 +61,21 @@ typedef enum {
|
|||
BAD_READ, /* the file is probably not valid */
|
||||
OTHER_FORMAT /* the file may be valid, but not in this format */
|
||||
} libpcap_try_t;
|
||||
static libpcap_try_t libpcap_try(wftap *wfth, int *err);
|
||||
static libpcap_try_t libpcap_try(wtap *wth, int *err);
|
||||
|
||||
static gboolean libpcap_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean libpcap_seek_read(wftap *wth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info);
|
||||
static int libpcap_read_header(wftap *wfth, FILE_T fh, int *err, gchar **err_info,
|
||||
struct pcaprec_ss990915_hdr *hdr);
|
||||
static void adjust_header(wftap *wfth, struct pcaprec_hdr *hdr);
|
||||
static gboolean libpcap_read_packet(wftap *wfth, FILE_T fh,
|
||||
static gboolean libpcap_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean libpcap_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
static int libpcap_read_header(wtap *wth, FILE_T fh, int *err, gchar **err_info,
|
||||
struct pcaprec_ss990915_hdr *hdr);
|
||||
static void adjust_header(wtap *wth, struct pcaprec_hdr *hdr);
|
||||
static gboolean libpcap_read_packet(wtap *wth, FILE_T fh,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean libpcap_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err);
|
||||
|
||||
int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int libpcap_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
int bytes_read;
|
||||
guint32 magic;
|
||||
|
@ -87,13 +86,12 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
int file_encap;
|
||||
gint64 first_packet_offset;
|
||||
libpcap_t *libpcap;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
/* Read in the number that should be at the start of a "libpcap" file */
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(&magic, sizeof magic, wfth->fh);
|
||||
bytes_read = file_read(&magic, sizeof magic, wth->fh);
|
||||
if (bytes_read != sizeof magic) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -106,7 +104,7 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
a program using either standard or ss990417 libpcap. */
|
||||
byte_swapped = FALSE;
|
||||
modified = FALSE;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
break;
|
||||
|
||||
case PCAP_MODIFIED_MAGIC:
|
||||
|
@ -114,7 +112,7 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
a program using either ss990915 or ss991029 libpcap. */
|
||||
byte_swapped = FALSE;
|
||||
modified = TRUE;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
break;
|
||||
|
||||
case PCAP_SWAPPED_MAGIC:
|
||||
|
@ -123,7 +121,7 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
ss990417 libpcap. */
|
||||
byte_swapped = TRUE;
|
||||
modified = FALSE;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
break;
|
||||
|
||||
case PCAP_SWAPPED_MODIFIED_MAGIC:
|
||||
|
@ -132,7 +130,7 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
or ss991029 libpcap. */
|
||||
byte_swapped = TRUE;
|
||||
modified = TRUE;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
break;
|
||||
|
||||
case PCAP_NSEC_MAGIC:
|
||||
|
@ -141,7 +139,7 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
except that the time stamps have nanosecond resolution. */
|
||||
byte_swapped = FALSE;
|
||||
modified = FALSE;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
break;
|
||||
|
||||
case PCAP_SWAPPED_NSEC_MAGIC:
|
||||
|
@ -151,7 +149,7 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
nanosecond resolution. */
|
||||
byte_swapped = TRUE;
|
||||
modified = FALSE;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -161,9 +159,9 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
/* Read the rest of the header. */
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(&hdr, sizeof hdr, wfth->fh);
|
||||
bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
|
||||
if (bytes_read != sizeof hdr) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return -1;
|
||||
|
@ -258,11 +256,11 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
libpcap->byte_swapped = byte_swapped;
|
||||
libpcap->version_major = hdr.version_major;
|
||||
libpcap->version_minor = hdr.version_minor;
|
||||
wfth->priv = (void *)libpcap;
|
||||
wfth->subtype_read = libpcap_read;
|
||||
wfth->subtype_seek_read = libpcap_seek_read;
|
||||
wfth->file_encap = file_encap;
|
||||
wfth->snapshot_length = hdr.snaplen;
|
||||
wth->priv = (void *)libpcap;
|
||||
wth->subtype_read = libpcap_read;
|
||||
wth->subtype_seek_read = libpcap_seek_read;
|
||||
wth->file_encap = file_encap;
|
||||
wth->snapshot_length = hdr.snaplen;
|
||||
|
||||
/* In file format version 2.3, the order of the "incl_len" and
|
||||
"orig_len" fields in the per-packet header was reversed,
|
||||
|
@ -309,8 +307,8 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
* and for the ERF link-layer header type, and set the
|
||||
* precision to nanosecond precision.
|
||||
*/
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PCAP_AIX;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PCAP_AIX;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -354,9 +352,9 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
*
|
||||
* Try ss991029, the last of his patches, first.
|
||||
*/
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PCAP_SS991029;
|
||||
first_packet_offset = file_tell(wfth->fh);
|
||||
switch (libpcap_try(wfth, err)) {
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PCAP_SS991029;
|
||||
first_packet_offset = file_tell(wth->fh);
|
||||
switch (libpcap_try(wth, err)) {
|
||||
|
||||
case BAD_READ:
|
||||
/*
|
||||
|
@ -370,7 +368,7 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
* Well, it looks as if it might be 991029.
|
||||
* Put the seek pointer back, and finish.
|
||||
*/
|
||||
if (file_seek(wfth->fh, first_packet_offset, SEEK_SET, err) == -1) {
|
||||
if (file_seek(wth->fh, first_packet_offset, SEEK_SET, err) == -1) {
|
||||
return -1;
|
||||
}
|
||||
goto done;
|
||||
|
@ -389,8 +387,8 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
* so we put the seek pointer back and treat
|
||||
* it as 990915.
|
||||
*/
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990915;
|
||||
if (file_seek(wfth->fh, first_packet_offset, SEEK_SET, err) == -1) {
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990915;
|
||||
if (file_seek(wth->fh, first_packet_offset, SEEK_SET, err) == -1) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
|
@ -399,13 +397,13 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
*
|
||||
* Try the standard format first.
|
||||
*/
|
||||
if(wfth->tsprecision == WTAP_FILE_TSPREC_NSEC) {
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC;
|
||||
if(wth->tsprecision == WTAP_FILE_TSPREC_NSEC) {
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC;
|
||||
} else {
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PCAP;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PCAP;
|
||||
}
|
||||
first_packet_offset = file_tell(wfth->fh);
|
||||
switch (libpcap_try(wfth, err)) {
|
||||
first_packet_offset = file_tell(wth->fh);
|
||||
switch (libpcap_try(wth, err)) {
|
||||
|
||||
case BAD_READ:
|
||||
/*
|
||||
|
@ -420,7 +418,7 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
* libpcap file.
|
||||
* Put the seek pointer back, and finish.
|
||||
*/
|
||||
if (file_seek(wfth->fh, first_packet_offset, SEEK_SET, err) == -1) {
|
||||
if (file_seek(wth->fh, first_packet_offset, SEEK_SET, err) == -1) {
|
||||
return -1;
|
||||
}
|
||||
goto done;
|
||||
|
@ -437,11 +435,11 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
* a standard file. Put the seek pointer back and try
|
||||
* ss990417.
|
||||
*/
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990417;
|
||||
if (file_seek(wfth->fh, first_packet_offset, SEEK_SET, err) == -1) {
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PCAP_SS990417;
|
||||
if (file_seek(wth->fh, first_packet_offset, SEEK_SET, err) == -1) {
|
||||
return -1;
|
||||
}
|
||||
switch (libpcap_try(wfth, err)) {
|
||||
switch (libpcap_try(wth, err)) {
|
||||
|
||||
case BAD_READ:
|
||||
/*
|
||||
|
@ -455,7 +453,7 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
* Well, it looks as if it might be ss990417.
|
||||
* Put the seek pointer back, and finish.
|
||||
*/
|
||||
if (file_seek(wfth->fh, first_packet_offset, SEEK_SET, err) == -1) {
|
||||
if (file_seek(wth->fh, first_packet_offset, SEEK_SET, err) == -1) {
|
||||
return -1;
|
||||
}
|
||||
goto done;
|
||||
|
@ -474,8 +472,8 @@ int libpcap_open(wftap *wfth, int *err, gchar **err_info)
|
|||
* to try after that, so we put the seek pointer back
|
||||
* and treat it as a Nokia file.
|
||||
*/
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PCAP_NOKIA;
|
||||
if (file_seek(wfth->fh, first_packet_offset, SEEK_SET, err) == -1) {
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_PCAP_NOKIA;
|
||||
if (file_seek(wth->fh, first_packet_offset, SEEK_SET, err) == -1) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -490,10 +488,10 @@ done:
|
|||
* If this is a Nokia capture, treat 13 as WTAP_ENCAP_ATM_PDUS,
|
||||
* rather than as what we normally treat it.
|
||||
*/
|
||||
if (wfth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP_NOKIA && hdr.network == 13)
|
||||
wfth->file_encap = WTAP_ENCAP_ATM_PDUS;
|
||||
if (wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP_NOKIA && hdr.network == 13)
|
||||
wth->file_encap = WTAP_ENCAP_ATM_PDUS;
|
||||
|
||||
if (wfth->file_encap == WTAP_ENCAP_ERF) {
|
||||
if (wth->file_encap == WTAP_ENCAP_ERF) {
|
||||
/*
|
||||
* Populate set of interface IDs for ERF format.
|
||||
* Currently, this *has* to be done at open time.
|
||||
|
@ -504,7 +502,7 @@ done:
|
|||
}
|
||||
|
||||
/* Try to read the first two records of the capture file. */
|
||||
static libpcap_try_t libpcap_try(wftap *wfth, int *err)
|
||||
static libpcap_try_t libpcap_try(wtap *wth, int *err)
|
||||
{
|
||||
/*
|
||||
* pcaprec_ss990915_hdr is the largest header type.
|
||||
|
@ -515,7 +513,7 @@ static libpcap_try_t libpcap_try(wftap *wfth, int *err)
|
|||
/*
|
||||
* Attempt to read the first record's header.
|
||||
*/
|
||||
if (libpcap_read_header(wfth, wfth->fh, err, NULL, &first_rec_hdr) == -1) {
|
||||
if (libpcap_read_header(wth, wth->fh, err, NULL, &first_rec_hdr) == -1) {
|
||||
if (*err == 0 || *err == WTAP_ERR_SHORT_READ) {
|
||||
/*
|
||||
* EOF or short read - assume the file is in this
|
||||
|
@ -548,13 +546,13 @@ static libpcap_try_t libpcap_try(wftap *wfth, int *err)
|
|||
* Now skip over the first record's data, under the assumption
|
||||
* that the header is sane.
|
||||
*/
|
||||
if (file_seek(wfth->fh, first_rec_hdr.hdr.incl_len, SEEK_CUR, err) == -1)
|
||||
if (file_seek(wth->fh, first_rec_hdr.hdr.incl_len, SEEK_CUR, err) == -1)
|
||||
return BAD_READ;
|
||||
|
||||
/*
|
||||
* Now attempt to read the second record's header.
|
||||
*/
|
||||
if (libpcap_read_header(wfth, wfth->fh, err, NULL, &second_rec_hdr) == -1) {
|
||||
if (libpcap_read_header(wth, wth->fh, err, NULL, &second_rec_hdr) == -1) {
|
||||
if (*err == 0 || *err == WTAP_ERR_SHORT_READ) {
|
||||
/*
|
||||
* EOF or short read - assume the file is in this
|
||||
|
@ -592,25 +590,23 @@ static libpcap_try_t libpcap_try(wftap *wfth, int *err)
|
|||
}
|
||||
|
||||
/* Read the next packet */
|
||||
static gboolean libpcap_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean libpcap_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
return libpcap_read_packet(wfth, wfth->fh, &wth->phdr,
|
||||
wfth->frame_buffer, err, err_info);
|
||||
return libpcap_read_packet(wth, wth->fh, &wth->phdr,
|
||||
wth->frame_buffer, err, err_info);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
libpcap_seek_read(wftap *wfth, gint64 seek_off, void* header,
|
||||
libpcap_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
if (!libpcap_read_packet(wfth, wfth->random_fh, phdr, buf, err,
|
||||
if (!libpcap_read_packet(wth, wth->random_fh, phdr, buf, err,
|
||||
err_info)) {
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
|
@ -620,7 +616,7 @@ libpcap_seek_read(wftap *wfth, gint64 seek_off, void* header,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
libpcap_read_packet(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||
libpcap_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct pcaprec_ss990915_hdr hdr;
|
||||
|
@ -630,7 +626,7 @@ libpcap_read_packet(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr,
|
|||
int phdr_len;
|
||||
libpcap_t *libpcap;
|
||||
|
||||
bytes_read = libpcap_read_header(wfth, fh, err, err_info, &hdr);
|
||||
bytes_read = libpcap_read_header(wth, fh, err, err_info, &hdr);
|
||||
if (bytes_read == -1) {
|
||||
/*
|
||||
* We failed to read the header.
|
||||
|
@ -645,9 +641,9 @@ libpcap_read_packet(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr,
|
|||
* AIX appears to put 3 bytes of padding in front of FDDI
|
||||
* frames; strip that crap off.
|
||||
*/
|
||||
if (wfth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP_AIX &&
|
||||
(wfth->file_encap == WTAP_ENCAP_FDDI ||
|
||||
wfth->file_encap == WTAP_ENCAP_FDDI_BITSWAPPED)) {
|
||||
if (wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP_AIX &&
|
||||
(wth->file_encap == WTAP_ENCAP_FDDI ||
|
||||
wth->file_encap == WTAP_ENCAP_FDDI_BITSWAPPED)) {
|
||||
/*
|
||||
* The packet size is really a record size and includes
|
||||
* the padding.
|
||||
|
@ -662,8 +658,8 @@ libpcap_read_packet(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
phdr_len = pcap_process_pseudo_header(fh, wfth->file_type_subtype,
|
||||
wfth->file_encap, packet_size, TRUE, phdr, err, err_info);
|
||||
phdr_len = pcap_process_pseudo_header(fh, wth->file_type_subtype,
|
||||
wth->file_encap, packet_size, TRUE, phdr, err, err_info);
|
||||
if (phdr_len < 0)
|
||||
return FALSE; /* error */
|
||||
|
||||
|
@ -676,9 +672,9 @@ libpcap_read_packet(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr,
|
|||
phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
||||
|
||||
/* Update the timestamp, if not already done */
|
||||
if (wfth->file_encap != WTAP_ENCAP_ERF) {
|
||||
if (wth->file_encap != WTAP_ENCAP_ERF) {
|
||||
phdr->ts.secs = hdr.hdr.ts_sec;
|
||||
if (wfth->tsprecision == WTAP_FILE_TSPREC_NSEC)
|
||||
if (wth->tsprecision == WTAP_FILE_TSPREC_NSEC)
|
||||
phdr->ts.nsecs = hdr.hdr.ts_usec;
|
||||
else
|
||||
phdr->ts.nsecs = hdr.hdr.ts_usec * 1000;
|
||||
|
@ -696,8 +692,8 @@ libpcap_read_packet(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr,
|
|||
if (!wtap_read_packet_bytes(fh, buf, packet_size, err, err_info))
|
||||
return FALSE; /* failed */
|
||||
|
||||
libpcap = (libpcap_t *)wfth->priv;
|
||||
pcap_read_post_process(wfth->file_type_subtype, wfth->file_encap,
|
||||
libpcap = (libpcap_t *)wth->priv;
|
||||
pcap_read_post_process(wth->file_type_subtype, wth->file_encap,
|
||||
phdr, buffer_start_ptr(buf), libpcap->byte_swapped, -1);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -705,14 +701,14 @@ libpcap_read_packet(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr,
|
|||
/* Read the header of the next packet.
|
||||
|
||||
Return -1 on an error, or the number of bytes of header read on success. */
|
||||
static int libpcap_read_header(wftap *wfth, 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)
|
||||
{
|
||||
int bytes_to_read, bytes_read;
|
||||
|
||||
/* Read record header. */
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
switch (wfth->file_type_subtype) {
|
||||
switch (wth->file_type_subtype) {
|
||||
|
||||
case WTAP_FILE_TYPE_SUBTYPE_PCAP:
|
||||
case WTAP_FILE_TYPE_SUBTYPE_PCAP_AIX:
|
||||
|
@ -746,7 +742,7 @@ static int libpcap_read_header(wftap *wfth, FILE_T fh, int *err, gchar **err_inf
|
|||
return -1;
|
||||
}
|
||||
|
||||
adjust_header(wfth, &hdr->hdr);
|
||||
adjust_header(wth, &hdr->hdr);
|
||||
|
||||
if (hdr->hdr.incl_len > WTAP_MAX_PACKET_SIZE) {
|
||||
/*
|
||||
|
@ -793,7 +789,7 @@ static int libpcap_read_header(wftap *wfth, FILE_T fh, int *err, gchar **err_inf
|
|||
* about fixed-length buffers allocated based on the original
|
||||
* snapshot length. */
|
||||
#if 0
|
||||
if (hdr->hdr.incl_len > wfth->snapshot_length) {
|
||||
if (hdr->hdr.incl_len > wth->snapshot_length) {
|
||||
g_warning("pcap: File has packet larger than file's snapshot length.");
|
||||
}
|
||||
#endif
|
||||
|
@ -802,12 +798,12 @@ static int libpcap_read_header(wftap *wfth, FILE_T fh, int *err, gchar **err_inf
|
|||
}
|
||||
|
||||
static void
|
||||
adjust_header(wftap *wfth, struct pcaprec_hdr *hdr)
|
||||
adjust_header(wtap *wth, struct pcaprec_hdr *hdr)
|
||||
{
|
||||
guint32 temp;
|
||||
libpcap_t *libpcap;
|
||||
|
||||
libpcap = (libpcap_t *)wfth->priv;
|
||||
libpcap = (libpcap_t *)wth->priv;
|
||||
if (libpcap->byte_swapped) {
|
||||
/* Byte-swap the record header fields. */
|
||||
hdr->ts_sec = GUINT32_SWAP_LE_BE(hdr->ts_sec);
|
||||
|
@ -856,7 +852,7 @@ int libpcap_dump_can_write_encap(int encap)
|
|||
|
||||
/* Returns TRUE on success, FALSE on failure; sets "*err" to an error code on
|
||||
failure */
|
||||
gboolean libpcap_dump_open(wftap_dumper *wdh, int *err)
|
||||
gboolean libpcap_dump_open(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
guint32 magic;
|
||||
struct pcap_hdr file_hdr;
|
||||
|
@ -893,7 +889,7 @@ gboolean libpcap_dump_open(wftap_dumper *wdh, int *err)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!wftap_dump_file_write(wdh, &magic, sizeof magic, err))
|
||||
if (!wtap_dump_file_write(wdh, &magic, sizeof magic, err))
|
||||
return FALSE;
|
||||
wdh->bytes_dumped += sizeof magic;
|
||||
|
||||
|
@ -916,7 +912,7 @@ gboolean libpcap_dump_open(wftap_dumper *wdh, int *err)
|
|||
file_hdr.snaplen = (wdh->snaplen != 0) ? wdh->snaplen :
|
||||
WTAP_MAX_PACKET_SIZE;
|
||||
file_hdr.network = wtap_wtap_encap_to_pcap_encap(wdh->encap);
|
||||
if (!wftap_dump_file_write(wdh, &file_hdr, sizeof file_hdr, err))
|
||||
if (!wtap_dump_file_write(wdh, &file_hdr, sizeof file_hdr, err))
|
||||
return FALSE;
|
||||
wdh->bytes_dumped += sizeof file_hdr;
|
||||
|
||||
|
@ -925,7 +921,7 @@ gboolean libpcap_dump_open(wftap_dumper *wdh, int *err)
|
|||
|
||||
/* Write a record for a packet to a dump file.
|
||||
Returns TRUE on success, FALSE on failure. */
|
||||
static gboolean libpcap_dump(wftap_dumper *wdh,
|
||||
static gboolean libpcap_dump(wtap_dumper *wdh,
|
||||
const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err)
|
||||
{
|
||||
|
@ -1018,16 +1014,15 @@ static gboolean libpcap_dump(wftap_dumper *wdh,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!wftap_dump_file_write(wdh, &rec_hdr, hdr_size, err))
|
||||
if (!wtap_dump_file_write(wdh, &rec_hdr, hdr_size, err))
|
||||
return FALSE;
|
||||
wdh->bytes_dumped += hdr_size;
|
||||
|
||||
if (!pcap_write_phdr(wdh, wdh->encap, pseudo_header, err))
|
||||
return FALSE;
|
||||
|
||||
if (!wftap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
return FALSE;
|
||||
|
||||
wdh->bytes_dumped += phdr->caplen;
|
||||
wdh->bytes_dumped += phdr->caplen;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -100,8 +100,8 @@ struct pcaprec_nokia_hdr {
|
|||
guint8 stuff[4]; /* mysterious stuff */
|
||||
};
|
||||
|
||||
int libpcap_open(wftap *wfth, int *err, gchar **err_info);
|
||||
gboolean libpcap_dump_open(wftap_dumper *wdh, int *err);
|
||||
int libpcap_open(wtap *wth, int *err, gchar **err_info);
|
||||
gboolean libpcap_dump_open(wtap_dumper *wdh, int *err);
|
||||
int libpcap_dump_can_write_encap(int encap);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -96,7 +95,7 @@ static gchar *logcat_log(const struct dumper_t *dumper, guint32 seconds,
|
|||
|
||||
}
|
||||
|
||||
static gint detect_version(wftap *wfth, int *err, gchar **err_info)
|
||||
static gint detect_version(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
gint bytes_read;
|
||||
guint16 payload_length;
|
||||
|
@ -107,20 +106,20 @@ static gint detect_version(wftap *wfth, int *err, gchar **err_info)
|
|||
guint32 tag_length;
|
||||
guint16 tmp;
|
||||
|
||||
file_offset = file_tell(wfth->fh);
|
||||
file_offset = file_tell(wth->fh);
|
||||
|
||||
bytes_read = file_read(&tmp, 2, wfth->fh);
|
||||
bytes_read = file_read(&tmp, 2, wth->fh);
|
||||
if (bytes_read != 2) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err == 0 && bytes_read != 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return -1;
|
||||
}
|
||||
payload_length = pletoh16(&tmp);
|
||||
|
||||
bytes_read = file_read(&tmp, 2, wfth->fh);
|
||||
bytes_read = file_read(&tmp, 2, wth->fh);
|
||||
if (bytes_read != 2) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err == 0 && bytes_read != 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return -1;
|
||||
|
@ -128,10 +127,10 @@ static gint detect_version(wftap *wfth, int *err, gchar **err_info)
|
|||
try_header_size = pletoh16(&tmp);
|
||||
|
||||
buffer = (guint8 *) g_malloc(5 * 4 + payload_length);
|
||||
bytes_read = file_read(buffer, 5 * 4 + payload_length, wfth->fh);
|
||||
bytes_read = file_read(buffer, 5 * 4 + payload_length, wth->fh);
|
||||
if (bytes_read != 5 * 4 + payload_length) {
|
||||
if (bytes_read != 4 * 4 + payload_length) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err == 0 && bytes_read != 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
g_free(buffer);
|
||||
|
@ -151,7 +150,7 @@ static gint detect_version(wftap *wfth, int *err, gchar **err_info)
|
|||
tag_length = (guint32)strlen(buffer + 4 * 4 + 1) + 1;
|
||||
log_length = (guint32)strlen(buffer + 4 * 4 + 1 + tag_length) + 1;
|
||||
if (payload_length == 1 + tag_length + log_length) {
|
||||
if (file_seek(wfth->fh, file_offset + 4 * 4 + 1 + tag_length + log_length, SEEK_SET, err) == -1) {
|
||||
if (file_seek(wth->fh, file_offset + 4 * 4 + 1 + tag_length + log_length, SEEK_SET, err) == -1) {
|
||||
g_free(buffer);
|
||||
return -1;
|
||||
}
|
||||
|
@ -215,24 +214,23 @@ static gboolean logcat_read_packet(struct logcat_phdr *logcat, FILE_T fh,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean logcat_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean logcat_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
return logcat_read_packet((struct logcat_phdr *) wfth->priv, wfth->fh,
|
||||
&wth->phdr, wfth->frame_buffer, err, err_info);
|
||||
return logcat_read_packet((struct logcat_phdr *) wth->priv, wth->fh,
|
||||
&wth->phdr, wth->frame_buffer, err, err_info);
|
||||
}
|
||||
|
||||
static gboolean logcat_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info)
|
||||
static gboolean logcat_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
||||
int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
if (!logcat_read_packet((struct logcat_phdr *) wfth->priv, wfth->random_fh,
|
||||
if (!logcat_read_packet((struct logcat_phdr *) wth->priv, wth->random_fh,
|
||||
phdr, buf, err, err_info)) {
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
|
@ -241,7 +239,7 @@ static gboolean logcat_seek_read(wftap *wfth, gint64 seek_off,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int logcat_open(wftap *wfth, int *err, gchar **err_info _U_)
|
||||
int logcat_open(wtap *wth, int *err, gchar **err_info _U_)
|
||||
{
|
||||
int local_err;
|
||||
gchar *local_err_info;
|
||||
|
@ -250,37 +248,37 @@ int logcat_open(wftap *wfth, int *err, gchar **err_info _U_)
|
|||
struct logcat_phdr *logcat;
|
||||
|
||||
/* check first 3 packets (or 2 or 1 if EOF) versions to check file format is correct */
|
||||
version = detect_version(wfth, &local_err, &local_err_info);
|
||||
version = detect_version(wth, &local_err, &local_err_info);
|
||||
if (version <= 0)
|
||||
return 0;
|
||||
|
||||
tmp_version = detect_version(wfth, &local_err, &local_err_info);
|
||||
if (tmp_version < 0 && !file_eof(wfth->fh)) {
|
||||
tmp_version = detect_version(wth, &local_err, &local_err_info);
|
||||
if (tmp_version < 0 && !file_eof(wth->fh)) {
|
||||
return 0;
|
||||
} else if (tmp_version > 0) {
|
||||
if (tmp_version != version)
|
||||
return 0;
|
||||
|
||||
tmp_version = detect_version(wfth, &local_err, &local_err_info);
|
||||
if (tmp_version != version && !file_eof(wfth->fh))
|
||||
tmp_version = detect_version(wth, &local_err, &local_err_info);
|
||||
if (tmp_version != version && !file_eof(wth->fh))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (file_seek(wfth->fh, 0, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
|
||||
return -1;
|
||||
|
||||
logcat = (struct logcat_phdr *) g_malloc(sizeof(struct logcat_phdr));
|
||||
logcat->version = version;
|
||||
|
||||
wfth->priv = logcat;
|
||||
wth->priv = logcat;
|
||||
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_LOGCAT;
|
||||
wfth->file_encap = WTAP_ENCAP_LOGCAT;
|
||||
wfth->snapshot_length = 0;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_LOGCAT;
|
||||
wth->file_encap = WTAP_ENCAP_LOGCAT;
|
||||
wth->snapshot_length = 0;
|
||||
|
||||
wfth->subtype_read = logcat_read;
|
||||
wfth->subtype_seek_read = logcat_seek_read;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
wth->subtype_read = logcat_read;
|
||||
wth->subtype_seek_read = logcat_seek_read;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -296,11 +294,11 @@ int logcat_dump_can_write_encap(int encap)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static gboolean logcat_binary_dump(wftap_dumper *wdh,
|
||||
static gboolean logcat_binary_dump(wtap_dumper *wdh,
|
||||
const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err)
|
||||
{
|
||||
if (!wftap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
return FALSE;
|
||||
|
||||
wdh->bytes_dumped += phdr->caplen;
|
||||
|
@ -308,7 +306,7 @@ static gboolean logcat_binary_dump(wftap_dumper *wdh,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean logcat_binary_dump_open(wftap_dumper *wdh, int *err)
|
||||
gboolean logcat_binary_dump_open(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
wdh->subtype_write = logcat_binary_dump;
|
||||
wdh->subtype_close = NULL;
|
||||
|
@ -326,7 +324,7 @@ gboolean logcat_binary_dump_open(wftap_dumper *wdh, int *err)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean logcat_dump_text(wftap_dumper *wdh,
|
||||
static gboolean logcat_dump_text(wtap_dumper *wdh,
|
||||
const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err)
|
||||
{
|
||||
|
@ -382,7 +380,7 @@ static gboolean logcat_dump_text(wftap_dumper *wdh,
|
|||
g_free(log_part);
|
||||
length = (guint32)strlen(buf);
|
||||
|
||||
if (!wftap_dump_file_write(wdh, buf, length, err)) {
|
||||
if (!wtap_dump_file_write(wdh, buf, length, err)) {
|
||||
g_free(buf);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -406,7 +404,7 @@ static gboolean logcat_dump_text(wftap_dumper *wdh,
|
|||
g_free(log_part);
|
||||
length = (guint32)strlen(buf);
|
||||
|
||||
if (!wftap_dump_file_write(wdh, buf, length, err)) {
|
||||
if (!wtap_dump_file_write(wdh, buf, length, err)) {
|
||||
g_free(buf);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -418,7 +416,7 @@ static gboolean logcat_dump_text(wftap_dumper *wdh,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean logcat_text_brief_dump_open(wftap_dumper *wdh, int *err _U_)
|
||||
gboolean logcat_text_brief_dump_open(wtap_dumper *wdh, int *err _U_)
|
||||
{
|
||||
struct dumper_t *dumper;
|
||||
|
||||
|
@ -432,7 +430,7 @@ gboolean logcat_text_brief_dump_open(wftap_dumper *wdh, int *err _U_)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean logcat_text_process_dump_open(wftap_dumper *wdh, int *err _U_)
|
||||
gboolean logcat_text_process_dump_open(wtap_dumper *wdh, int *err _U_)
|
||||
{
|
||||
struct dumper_t *dumper;
|
||||
|
||||
|
@ -446,7 +444,7 @@ gboolean logcat_text_process_dump_open(wftap_dumper *wdh, int *err _U_)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean logcat_text_tag_dump_open(wftap_dumper *wdh, int *err _U_)
|
||||
gboolean logcat_text_tag_dump_open(wtap_dumper *wdh, int *err _U_)
|
||||
{
|
||||
struct dumper_t *dumper;
|
||||
|
||||
|
@ -460,7 +458,7 @@ gboolean logcat_text_tag_dump_open(wftap_dumper *wdh, int *err _U_)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean logcat_text_time_dump_open(wftap_dumper *wdh, int *err _U_)
|
||||
gboolean logcat_text_time_dump_open(wtap_dumper *wdh, int *err _U_)
|
||||
{
|
||||
struct dumper_t *dumper;
|
||||
|
||||
|
@ -474,7 +472,7 @@ gboolean logcat_text_time_dump_open(wftap_dumper *wdh, int *err _U_)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean logcat_text_thread_dump_open(wftap_dumper *wdh, int *err _U_)
|
||||
gboolean logcat_text_thread_dump_open(wtap_dumper *wdh, int *err _U_)
|
||||
{
|
||||
struct dumper_t *dumper;
|
||||
|
||||
|
@ -488,7 +486,7 @@ gboolean logcat_text_thread_dump_open(wftap_dumper *wdh, int *err _U_)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean logcat_text_threadtime_dump_open(wftap_dumper *wdh, int *err _U_)
|
||||
gboolean logcat_text_threadtime_dump_open(wtap_dumper *wdh, int *err _U_)
|
||||
{
|
||||
struct dumper_t *dumper;
|
||||
|
||||
|
@ -502,7 +500,7 @@ gboolean logcat_text_threadtime_dump_open(wftap_dumper *wdh, int *err _U_)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean logcat_text_long_dump_open(wftap_dumper *wdh, int *err _U_)
|
||||
gboolean logcat_text_long_dump_open(wtap_dumper *wdh, int *err _U_)
|
||||
{
|
||||
struct dumper_t *dumper;
|
||||
|
||||
|
|
|
@ -25,16 +25,16 @@
|
|||
|
||||
#include "wtap.h"
|
||||
|
||||
int logcat_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int logcat_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
gboolean logcat_binary_dump_open(wftap_dumper *wdh, int *err);
|
||||
gboolean logcat_text_brief_dump_open(wftap_dumper *wdh, int *err);
|
||||
gboolean logcat_text_process_dump_open(wftap_dumper *wdh, int *err);
|
||||
gboolean logcat_text_tag_dump_open(wftap_dumper *wdh, int *err);
|
||||
gboolean logcat_text_time_dump_open(wftap_dumper *wdh, int *err);
|
||||
gboolean logcat_text_thread_dump_open(wftap_dumper *wdh, int *err);
|
||||
gboolean logcat_text_threadtime_dump_open(wftap_dumper *wdh, int *err);
|
||||
gboolean logcat_text_long_dump_open(wftap_dumper *wdh, int *err);
|
||||
gboolean logcat_binary_dump_open(wtap_dumper *wdh, int *err);
|
||||
gboolean logcat_text_brief_dump_open(wtap_dumper *wdh, int *err);
|
||||
gboolean logcat_text_process_dump_open(wtap_dumper *wdh, int *err);
|
||||
gboolean logcat_text_tag_dump_open(wtap_dumper *wdh, int *err);
|
||||
gboolean logcat_text_time_dump_open(wtap_dumper *wdh, int *err);
|
||||
gboolean logcat_text_thread_dump_open(wtap_dumper *wdh, int *err);
|
||||
gboolean logcat_text_threadtime_dump_open(wtap_dumper *wdh, int *err);
|
||||
gboolean logcat_text_long_dump_open(wtap_dumper *wdh, int *err);
|
||||
|
||||
int logcat_dump_can_write_encap(int encap);
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/* merge.c
|
||||
* Combine multiple dump files, either by appending or by merging by timestamp
|
||||
/* Combine multiple dump files, either by appending or by merging by timestamp
|
||||
*
|
||||
* Written by Scott Renfro <scott@renfro.org> based on
|
||||
* editcap by Richard Sharpe and Guy Harris
|
||||
|
@ -61,21 +60,21 @@ merge_open_in_files(int in_file_count, char *const *in_file_names,
|
|||
|
||||
for (i = 0; i < in_file_count; i++) {
|
||||
files[i].filename = in_file_names[i];
|
||||
files[i].wfth = wtap_open_offline(in_file_names[i], WTAP_TYPE_AUTO, err, err_info, FALSE);
|
||||
files[i].wth = wtap_open_offline(in_file_names[i], WTAP_TYPE_AUTO, err, err_info, FALSE);
|
||||
files[i].data_offset = 0;
|
||||
files[i].state = PACKET_NOT_PRESENT;
|
||||
files[i].packet_num = 0;
|
||||
if (!files[i].wfth) {
|
||||
if (!files[i].wth) {
|
||||
/* Close the files we've already opened. */
|
||||
for (j = 0; j < i; j++)
|
||||
wtap_close(files[j].wfth);
|
||||
wtap_close(files[j].wth);
|
||||
*err_fileno = i;
|
||||
return FALSE;
|
||||
}
|
||||
size = wftap_file_size(files[i].wfth, err);
|
||||
size = wtap_file_size(files[i].wth, err);
|
||||
if (size == -1) {
|
||||
for (j = 0; j <= i; j++)
|
||||
wtap_close(files[j].wfth);
|
||||
wtap_close(files[j].wth);
|
||||
*err_fileno = i;
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -92,7 +91,7 @@ merge_close_in_files(int count, merge_in_file_t in_files[])
|
|||
{
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
wtap_close(in_files[i].wfth);
|
||||
wtap_close(in_files[i].wth);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,10 +109,10 @@ merge_select_frame_type(int count, merge_in_file_t files[])
|
|||
int i;
|
||||
int selected_frame_type;
|
||||
|
||||
selected_frame_type = wftap_file_encap(files[0].wfth);
|
||||
selected_frame_type = wtap_file_encap(files[0].wth);
|
||||
|
||||
for (i = 1; i < count; i++) {
|
||||
int this_frame_type = wftap_file_encap(files[i].wfth);
|
||||
int this_frame_type = wtap_file_encap(files[i].wth);
|
||||
if (selected_frame_type != this_frame_type) {
|
||||
selected_frame_type = WTAP_ENCAP_PER_PACKET;
|
||||
break;
|
||||
|
@ -134,7 +133,7 @@ merge_max_snapshot_length(int count, merge_in_file_t in_files[])
|
|||
int snapshot_length;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
snapshot_length = wftap_snapshot_length(in_files[i].wfth);
|
||||
snapshot_length = wtap_snapshot_length(in_files[i].wth);
|
||||
if (snapshot_length == 0) {
|
||||
/* Snapshot length of input file not known. */
|
||||
snapshot_length = WTAP_MAX_PACKET_SIZE;
|
||||
|
@ -197,7 +196,7 @@ merge_read_packet(int in_file_count, merge_in_file_t in_files[],
|
|||
* No packet available, and we haven't seen an error or EOF yet,
|
||||
* so try to read the next packet.
|
||||
*/
|
||||
if (!wtap_read(in_files[i].wfth, err, err_info, &in_files[i].data_offset)) {
|
||||
if (!wtap_read(in_files[i].wth, err, err_info, &in_files[i].data_offset)) {
|
||||
if (*err != 0) {
|
||||
in_files[i].state = GOT_ERROR;
|
||||
return &in_files[i];
|
||||
|
@ -208,7 +207,7 @@ merge_read_packet(int in_file_count, merge_in_file_t in_files[],
|
|||
}
|
||||
|
||||
if (in_files[i].state == PACKET_PRESENT) {
|
||||
phdr = wtap_phdr(in_files[i].wfth);
|
||||
phdr = wtap_phdr(in_files[i].wth);
|
||||
if (is_earlier(&phdr->ts, &tv)) {
|
||||
tv = phdr->ts;
|
||||
ei = i;
|
||||
|
@ -261,7 +260,7 @@ merge_append_read_packet(int in_file_count, merge_in_file_t in_files[],
|
|||
for (i = 0; i < in_file_count; i++) {
|
||||
if (in_files[i].state == AT_EOF)
|
||||
continue; /* This file is already at EOF */
|
||||
if (wtap_read(in_files[i].wfth, err, err_info, &in_files[i].data_offset))
|
||||
if (wtap_read(in_files[i].wth, err, err_info, &in_files[i].data_offset))
|
||||
break; /* We have a packet */
|
||||
if (*err != 0) {
|
||||
/* Read error - quit immediately. */
|
||||
|
|
|
@ -41,7 +41,7 @@ typedef enum {
|
|||
*/
|
||||
typedef struct merge_in_file_s {
|
||||
const char *filename;
|
||||
wftap *wfth;
|
||||
wtap *wth;
|
||||
gint64 data_offset;
|
||||
in_file_state_e state;
|
||||
guint32 packet_num; /* current packet number */
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -96,13 +95,13 @@ static const mime_files_t magic_files[] = {
|
|||
#define MAX_FILE_SIZE (16*1024*1024)
|
||||
|
||||
static gboolean
|
||||
mime_read_file(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||
mime_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
gint64 file_size;
|
||||
int packet_size;
|
||||
|
||||
if ((file_size = wftap_file_size(wfth, err)) == -1)
|
||||
if ((file_size = wtap_file_size(wth, err)) == -1)
|
||||
return FALSE;
|
||||
|
||||
if (file_size > MAX_FILE_SIZE) {
|
||||
|
@ -129,14 +128,13 @@ mime_read_file(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
mime_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
mime_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
{
|
||||
gint64 offset;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
*err = 0;
|
||||
|
||||
offset = file_tell(wfth->fh);
|
||||
offset = file_tell(wth->fh);
|
||||
|
||||
/* there is only ever one packet */
|
||||
if (offset != 0)
|
||||
|
@ -144,28 +142,26 @@ mime_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
|||
|
||||
*data_offset = offset;
|
||||
|
||||
return mime_read_file(wfth, wfth->fh, &wth->phdr, wfth->frame_buffer, err, err_info);
|
||||
return mime_read_file(wth, wth->fh, &wth->phdr, wth->frame_buffer, err, err_info);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
mime_seek_read(wftap *wfth, gint64 seek_off, void* header, Buffer *buf, int *err, gchar **err_info)
|
||||
mime_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
|
||||
/* there is only one packet */
|
||||
if (seek_off > 0) {
|
||||
*err = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
return mime_read_file(wfth, wfth->random_fh, phdr, buf, err, err_info);
|
||||
return mime_read_file(wth, wth->random_fh, phdr, buf, err, err_info);
|
||||
}
|
||||
|
||||
int
|
||||
mime_file_open(wftap *wfth, int *err, gchar **err_info)
|
||||
mime_file_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
char magic_buf[128]; /* increase buffer size when needed */
|
||||
int bytes_read;
|
||||
|
@ -179,10 +175,10 @@ mime_file_open(wftap *wfth, int *err, gchar **err_info)
|
|||
read_bytes = MAX(read_bytes, magic_files[i].magic_len);
|
||||
|
||||
read_bytes = (guint)MIN(read_bytes, sizeof(magic_buf));
|
||||
bytes_read = file_read(magic_buf, read_bytes, wfth->fh);
|
||||
bytes_read = file_read(magic_buf, read_bytes, wth->fh);
|
||||
|
||||
if (bytes_read < 0) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return -1;
|
||||
}
|
||||
if (bytes_read == 0)
|
||||
|
@ -202,15 +198,15 @@ mime_file_open(wftap *wfth, int *err, gchar **err_info)
|
|||
if (!found_file)
|
||||
return 0;
|
||||
|
||||
if (file_seek(wfth->fh, 0, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
|
||||
return -1;
|
||||
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_MIME;
|
||||
wfth->file_encap = WTAP_ENCAP_MIME;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_SEC;
|
||||
wfth->subtype_read = mime_read;
|
||||
wfth->subtype_seek_read = mime_seek_read;
|
||||
wfth->snapshot_length = 0;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_MIME;
|
||||
wth->file_encap = WTAP_ENCAP_MIME;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_SEC;
|
||||
wth->subtype_read = mime_read;
|
||||
wth->subtype_seek_read = mime_seek_read;
|
||||
wth->snapshot_length = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,6 @@
|
|||
#include <glib.h>
|
||||
#include <wtap.h>
|
||||
|
||||
int mime_file_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int mime_file_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#include "mp2t.h"
|
||||
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "buffer.h"
|
||||
#include "file_wrappers.h"
|
||||
|
@ -104,23 +103,22 @@ mp2t_read_packet(mp2t_filetype_t *mp2t, FILE_T fh, gint64 offset,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
mp2t_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
mp2t_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
{
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
mp2t_filetype_t *mp2t;
|
||||
|
||||
mp2t = (mp2t_filetype_t*) wfth->priv;
|
||||
mp2t = (mp2t_filetype_t*) wth->priv;
|
||||
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
if (!mp2t_read_packet(mp2t, wfth->fh, *data_offset, &wth->phdr,
|
||||
wfth->frame_buffer, err, err_info)) {
|
||||
if (!mp2t_read_packet(mp2t, wth->fh, *data_offset, &wth->phdr,
|
||||
wth->frame_buffer, err, err_info)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* if there's a trailer, skip it and go to the start of the next packet */
|
||||
if (mp2t->trailer_len!=0) {
|
||||
if (-1 == file_seek(wfth->fh, mp2t->trailer_len, SEEK_CUR, err)) {
|
||||
if (-1 == file_seek(wth->fh, mp2t->trailer_len, SEEK_CUR, err)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -129,19 +127,18 @@ mp2t_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
mp2t_seek_read(wftap *wfth, gint64 seek_off, void* header,
|
||||
mp2t_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
|
||||
Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
mp2t_filetype_t *mp2t;
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
|
||||
if (-1 == file_seek(wfth->random_fh, seek_off, SEEK_SET, err)) {
|
||||
if (-1 == file_seek(wth->random_fh, seek_off, SEEK_SET, err)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
mp2t = (mp2t_filetype_t*) wfth->priv;
|
||||
mp2t = (mp2t_filetype_t*) wth->priv;
|
||||
|
||||
if (!mp2t_read_packet(mp2t, wfth->random_fh, seek_off, phdr, buf,
|
||||
if (!mp2t_read_packet(mp2t, wth->random_fh, seek_off, phdr, buf,
|
||||
err, err_info)) {
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
|
@ -151,7 +148,7 @@ mp2t_seek_read(wftap *wfth, gint64 seek_off, void* header,
|
|||
}
|
||||
|
||||
int
|
||||
mp2t_open(wftap *wfth, int *err, gchar **err_info)
|
||||
mp2t_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
int bytes_read;
|
||||
guint8 buffer[MP2T_SIZE+TRAILER_LEN_MAX];
|
||||
|
@ -163,10 +160,10 @@ mp2t_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(buffer, MP2T_SIZE, wfth->fh);
|
||||
bytes_read = file_read(buffer, MP2T_SIZE, wth->fh);
|
||||
|
||||
if (MP2T_SIZE != bytes_read) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -183,18 +180,18 @@ mp2t_open(wftap *wfth, int *err, gchar **err_info)
|
|||
return 0; /* wrong file type - not an mpeg2 ts file */
|
||||
}
|
||||
|
||||
if (-1 == file_seek(wfth->fh, first, SEEK_SET, err)) {
|
||||
if (-1 == file_seek(wth->fh, first, SEEK_SET, err)) {
|
||||
return -1;
|
||||
}
|
||||
/* read some packets and make sure they all start with a sync byte */
|
||||
do {
|
||||
bytes_read = file_read(buffer, MP2T_SIZE+trailer_len, wfth->fh);
|
||||
bytes_read = file_read(buffer, MP2T_SIZE+trailer_len, wth->fh);
|
||||
if (bytes_read < 0) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
return -1; /* read error */
|
||||
}
|
||||
if (bytes_read < MP2T_SIZE+trailer_len) {
|
||||
if(sync_steps<2) return 0; /* wrong file type - not an mpeg2 ts file */
|
||||
if(sync_steps<2) return 0; /* wrong file type - not an mpeg2 ts file */
|
||||
break; /* end of file, that's ok if we're still in sync */
|
||||
}
|
||||
if (buffer[0] == MP2T_SYNC_BYTE) {
|
||||
|
@ -213,7 +210,7 @@ mp2t_open(wftap *wfth, int *err, gchar **err_info)
|
|||
for (i=0; i<TRAILER_LEN_MAX; i++) {
|
||||
if (buffer[i] == MP2T_SYNC_BYTE) {
|
||||
trailer_len = i;
|
||||
if (-1 == file_seek(wfth->fh, first, SEEK_SET, err)) {
|
||||
if (-1 == file_seek(wth->fh, first, SEEK_SET, err)) {
|
||||
return -1;
|
||||
}
|
||||
sync_steps = 0;
|
||||
|
@ -226,23 +223,23 @@ mp2t_open(wftap *wfth, int *err, gchar **err_info)
|
|||
}
|
||||
} while (sync_steps < SYNC_STEPS);
|
||||
|
||||
if (-1 == file_seek(wfth->fh, first, SEEK_SET, err)) {
|
||||
if (-1 == file_seek(wth->fh, first, SEEK_SET, err)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_MPEG_2_TS;
|
||||
wfth->file_encap = WTAP_ENCAP_MPEG_2_TS;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
wfth->subtype_read = mp2t_read;
|
||||
wfth->subtype_seek_read = mp2t_seek_read;
|
||||
wfth->snapshot_length = 0;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_MPEG_2_TS;
|
||||
wth->file_encap = WTAP_ENCAP_MPEG_2_TS;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
wth->subtype_read = mp2t_read;
|
||||
wth->subtype_seek_read = mp2t_seek_read;
|
||||
wth->snapshot_length = 0;
|
||||
|
||||
mp2t = (mp2t_filetype_t*) g_malloc(sizeof(mp2t_filetype_t));
|
||||
if (NULL == mp2t) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
wfth->priv = mp2t;
|
||||
wth->priv = mp2t;
|
||||
mp2t->start_offset = first;
|
||||
mp2t->trailer_len = trailer_len;
|
||||
|
||||
|
|
|
@ -26,6 +26,6 @@
|
|||
#include <glib.h>
|
||||
#include <wtap.h>
|
||||
|
||||
int mp2t_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int mp2t_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "mpeg.h"
|
||||
#include "wsutil/mpeg-audio.h"
|
||||
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "buffer.h"
|
||||
#include "file_wrappers.h"
|
||||
|
@ -93,10 +92,10 @@ mpeg_read_header(FILE_T fh, int *err, gchar **err_info, guint32 *n)
|
|||
#define SCRHZ 27000000
|
||||
|
||||
static gboolean
|
||||
mpeg_read_packet(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||
mpeg_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
||||
gboolean is_random, int *err, gchar **err_info)
|
||||
{
|
||||
mpeg_t *mpeg = (mpeg_t *)wfth->priv;
|
||||
mpeg_t *mpeg = (mpeg_t *)wth->priv;
|
||||
guint32 n;
|
||||
int bytes_read;
|
||||
unsigned int packet_size;
|
||||
|
@ -222,25 +221,23 @@ mpeg_read_packet(wftap *wfth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
mpeg_read(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
mpeg_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
{
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
return mpeg_read_packet(wfth, wfth->fh, &wth->phdr, wfth->frame_buffer,
|
||||
return mpeg_read_packet(wth, wth->fh, &wth->phdr, wth->frame_buffer,
|
||||
FALSE, err, err_info);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
mpeg_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf,
|
||||
mpeg_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf,
|
||||
int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
if (!mpeg_read_packet(wfth, wfth->random_fh, phdr, buf, TRUE, err,
|
||||
if (!mpeg_read_packet(wth, wth->random_fh, phdr, buf, TRUE, err,
|
||||
err_info)) {
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
|
@ -261,7 +258,7 @@ struct _mpeg_magic {
|
|||
};
|
||||
|
||||
int
|
||||
mpeg_open(wftap *wfth, int *err, gchar **err_info)
|
||||
mpeg_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
int bytes_read;
|
||||
char magic_buf[16];
|
||||
|
@ -269,9 +266,9 @@ mpeg_open(wftap *wfth, int *err, gchar **err_info)
|
|||
mpeg_t *mpeg;
|
||||
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(magic_buf, sizeof magic_buf, wfth->fh);
|
||||
bytes_read = file_read(magic_buf, sizeof magic_buf, wth->fh);
|
||||
if (bytes_read != (int) sizeof magic_buf) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -286,18 +283,18 @@ mpeg_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
good_magic:
|
||||
/* This appears to be a file with MPEG data. */
|
||||
if (file_seek(wfth->fh, 0, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
|
||||
return -1;
|
||||
|
||||
wfth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_MPEG;
|
||||
wfth->file_encap = WTAP_ENCAP_MPEG;
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
wfth->subtype_read = mpeg_read;
|
||||
wfth->subtype_seek_read = mpeg_seek_read;
|
||||
wfth->snapshot_length = 0;
|
||||
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_MPEG;
|
||||
wth->file_encap = WTAP_ENCAP_MPEG;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
wth->subtype_read = mpeg_read;
|
||||
wth->subtype_seek_read = mpeg_seek_read;
|
||||
wth->snapshot_length = 0;
|
||||
|
||||
mpeg = (mpeg_t *)g_malloc(sizeof(mpeg_t));
|
||||
wfth->priv = (void *)mpeg;
|
||||
wth->priv = (void *)mpeg;
|
||||
mpeg->now.secs = 0;
|
||||
mpeg->now.nsecs = 0;
|
||||
mpeg->t0 = mpeg->now.secs;
|
||||
|
|
|
@ -26,6 +26,6 @@
|
|||
#include <glib.h>
|
||||
#include <wtap.h>
|
||||
|
||||
int mpeg_open(wftap *wfth, int *err, gchar **err_info);
|
||||
int mpeg_open(wtap *wth, int *err, gchar **err_info);
|
||||
|
||||
#endif
|
||||
|
|
117
wiretap/netmon.c
117
wiretap/netmon.c
|
@ -21,7 +21,6 @@
|
|||
#include "config.h"
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -176,20 +175,20 @@ static const int netmon_encap[] = {
|
|||
#define NETMON_NET_DNS_CACHE 0xFFFE
|
||||
#define NETMON_NET_NETMON_FILTER 0xFFFF
|
||||
|
||||
static gboolean netmon_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean netmon_seek_read(wftap *wth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean netmon_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
|
||||
static gboolean netmon_read_atm_pseudoheader(FILE_T fh,
|
||||
union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info);
|
||||
static int netmon_read_rec_trailer(FILE_T fh, int trlr_size, int *err,
|
||||
gchar **err_info);
|
||||
static void netmon_sequential_close(wftap *wth);
|
||||
static gboolean netmon_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
static void netmon_sequential_close(wtap *wth);
|
||||
static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err);
|
||||
static gboolean netmon_dump_close(wftap_dumper *wdh, int *err);
|
||||
static gboolean netmon_dump_close(wtap_dumper *wdh, int *err);
|
||||
|
||||
int netmon_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int netmon_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
int bytes_read;
|
||||
char magic[MAGIC_SIZE];
|
||||
|
@ -208,9 +207,9 @@ int netmon_open(wftap *wfth, int *err, gchar **err_info)
|
|||
/* Read in the string that should be at the start of a Network
|
||||
* Monitor file */
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(magic, MAGIC_SIZE, wfth->fh);
|
||||
bytes_read = file_read(magic, MAGIC_SIZE, wth->fh);
|
||||
if (bytes_read != MAGIC_SIZE) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
|
@ -223,9 +222,9 @@ int netmon_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
/* Read the rest of the header. */
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(&hdr, sizeof hdr, wfth->fh);
|
||||
bytes_read = file_read(&hdr, sizeof hdr, wth->fh);
|
||||
if (bytes_read != sizeof hdr) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return -1;
|
||||
|
@ -257,21 +256,21 @@ int netmon_open(wftap *wfth, int *err, gchar **err_info)
|
|||
}
|
||||
|
||||
/* This is a netmon file */
|
||||
wfth->file_type_subtype = file_type;
|
||||
wth->file_type_subtype = file_type;
|
||||
netmon = (netmon_t *)g_malloc(sizeof(netmon_t));
|
||||
wfth->priv = (void *)netmon;
|
||||
wfth->subtype_read = netmon_read;
|
||||
wfth->subtype_seek_read = netmon_seek_read;
|
||||
wfth->subtype_sequential_close = netmon_sequential_close;
|
||||
wth->priv = (void *)netmon;
|
||||
wth->subtype_read = netmon_read;
|
||||
wth->subtype_seek_read = netmon_seek_read;
|
||||
wth->subtype_sequential_close = netmon_sequential_close;
|
||||
|
||||
/* NetMon capture file formats v2.1+ use per-packet encapsulation types. NetMon 3 sets the value in
|
||||
* the header to 1 (Ethernet) for backwards compability. */
|
||||
if((hdr.ver_major == 2 && hdr.ver_minor >= 1) || hdr.ver_major > 2)
|
||||
wfth->file_encap = WTAP_ENCAP_PER_PACKET;
|
||||
wth->file_encap = WTAP_ENCAP_PER_PACKET;
|
||||
else
|
||||
wfth->file_encap = netmon_encap[hdr.network];
|
||||
wth->file_encap = netmon_encap[hdr.network];
|
||||
|
||||
wfth->snapshot_length = 0; /* not available in header */
|
||||
wth->snapshot_length = 0; /* not available in header */
|
||||
/*
|
||||
* Convert the time stamp to a "time_t" and a number of
|
||||
* milliseconds.
|
||||
|
@ -361,7 +360,7 @@ int netmon_open(wftap *wfth, int *err, gchar **err_info)
|
|||
frame_table_length);
|
||||
return -1;
|
||||
}
|
||||
if (file_seek(wfth->fh, frame_table_offset, SEEK_SET, err) == -1) {
|
||||
if (file_seek(wth->fh, frame_table_offset, SEEK_SET, err) == -1) {
|
||||
return -1;
|
||||
}
|
||||
frame_table = (guint32 *)g_try_malloc(frame_table_length);
|
||||
|
@ -370,9 +369,9 @@ int netmon_open(wftap *wfth, int *err, gchar **err_info)
|
|||
return -1;
|
||||
}
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
bytes_read = file_read(frame_table, frame_table_length, wfth->fh);
|
||||
bytes_read = file_read(frame_table, frame_table_length, wth->fh);
|
||||
if ((guint32)bytes_read != frame_table_length) {
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
g_free(frame_table);
|
||||
|
@ -398,7 +397,7 @@ int netmon_open(wftap *wfth, int *err, gchar **err_info)
|
|||
* Version 1.x of the file format supports
|
||||
* millisecond precision.
|
||||
*/
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_MSEC;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_MSEC;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
@ -408,7 +407,7 @@ int netmon_open(wftap *wfth, int *err, gchar **err_info)
|
|||
* currently support that, so say
|
||||
* "nanosecond precision" for now.
|
||||
*/
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
|
@ -477,10 +476,10 @@ netmon_set_pseudo_header_info(int pkt_encap, struct wtap_pkthdr *phdr,
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean netmon_process_rec_header(wftap *wfth, FILE_T fh,
|
||||
static gboolean netmon_process_rec_header(wtap *wth, FILE_T fh,
|
||||
struct wtap_pkthdr *phdr, int *err, gchar **err_info)
|
||||
{
|
||||
netmon_t *netmon = (netmon_t *)wfth->priv;
|
||||
netmon_t *netmon = (netmon_t *)wth->priv;
|
||||
int hdr_size = 0;
|
||||
union {
|
||||
struct netmonrec_1_x_hdr hdr_1_x;
|
||||
|
@ -546,7 +545,7 @@ static gboolean netmon_process_rec_header(wftap *wfth, FILE_T fh,
|
|||
* and the VPI and VCI; read them and generate the pseudo-header
|
||||
* from them.
|
||||
*/
|
||||
switch (wfth->file_encap) {
|
||||
switch (wth->file_encap) {
|
||||
|
||||
case WTAP_ENCAP_ATM_PDUS:
|
||||
if (packet_size < sizeof (struct netmon_atm_hdr)) {
|
||||
|
@ -678,11 +677,10 @@ static process_trailer_retval netmon_process_rec_trailer(netmon_t *netmon,
|
|||
}
|
||||
|
||||
/* Read the next packet */
|
||||
static gboolean netmon_read(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean netmon_read(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset)
|
||||
{
|
||||
netmon_t *netmon = (netmon_t *)wfth->priv;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
netmon_t *netmon = (netmon_t *)wth->priv;
|
||||
gint64 rec_offset;
|
||||
|
||||
again:
|
||||
|
@ -707,19 +705,19 @@ again:
|
|||
file, but set the frame table up so it's the last
|
||||
record in sequence. */
|
||||
rec_offset = netmon->frame_table[netmon->current_frame];
|
||||
if (file_tell(wfth->fh) != rec_offset) {
|
||||
if (file_seek(wfth->fh, rec_offset, SEEK_SET, err) == -1)
|
||||
if (file_tell(wth->fh) != rec_offset) {
|
||||
if (file_seek(wth->fh, rec_offset, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
}
|
||||
netmon->current_frame++;
|
||||
|
||||
*data_offset = file_tell(wfth->fh);
|
||||
*data_offset = file_tell(wth->fh);
|
||||
|
||||
if (!netmon_process_rec_header(wfth, wfth->fh, &wth->phdr,
|
||||
if (!netmon_process_rec_header(wth, wth->fh, &wth->phdr,
|
||||
err, err_info))
|
||||
return FALSE;
|
||||
|
||||
if (!wtap_read_packet_bytes(wfth->fh, wfth->frame_buffer,
|
||||
if (!wtap_read_packet_bytes(wth->fh, wth->frame_buffer,
|
||||
wth->phdr.caplen, err, err_info))
|
||||
return FALSE; /* Read error */
|
||||
|
||||
|
@ -727,7 +725,7 @@ again:
|
|||
* For version 2.1 and later, there's additional information
|
||||
* after the frame data.
|
||||
*/
|
||||
switch (netmon_process_rec_trailer(netmon, wfth->fh, &wth->phdr,
|
||||
switch (netmon_process_rec_trailer(netmon, wth->fh, &wth->phdr,
|
||||
err, err_info)) {
|
||||
|
||||
case RETRY:
|
||||
|
@ -741,28 +739,27 @@ again:
|
|||
}
|
||||
|
||||
netmon_set_pseudo_header_info(wth->phdr.pkt_encap, &wth->phdr,
|
||||
wfth->frame_buffer);
|
||||
wth->frame_buffer);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
netmon_seek_read(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info)
|
||||
netmon_seek_read(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
netmon_t *netmon = (netmon_t *)wfth->priv;
|
||||
netmon_t *netmon = (netmon_t *)wth->priv;
|
||||
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
if (!netmon_process_rec_header(wfth, wfth->random_fh, phdr,
|
||||
if (!netmon_process_rec_header(wth, wth->random_fh, phdr,
|
||||
err, err_info))
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
* Read the packet data.
|
||||
*/
|
||||
if (!wtap_read_packet_bytes(wfth->random_fh, buf, phdr->caplen, err,
|
||||
if (!wtap_read_packet_bytes(wth->random_fh, buf, phdr->caplen, err,
|
||||
err_info))
|
||||
return FALSE;
|
||||
|
||||
|
@ -770,7 +767,7 @@ netmon_seek_read(wftap *wfth, gint64 seek_off,
|
|||
* For version 2.1 and later, there's additional information
|
||||
* after the frame data.
|
||||
*/
|
||||
switch (netmon_process_rec_trailer(netmon, wfth->random_fh, phdr,
|
||||
switch (netmon_process_rec_trailer(netmon, wth->random_fh, phdr,
|
||||
err, err_info)) {
|
||||
|
||||
case RETRY:
|
||||
|
@ -914,9 +911,9 @@ netmon_read_rec_trailer(FILE_T fh, int trlr_size, int *err, gchar **err_info)
|
|||
|
||||
/* Throw away the frame table used by the sequential I/O stream. */
|
||||
static void
|
||||
netmon_sequential_close(wftap *wfth)
|
||||
netmon_sequential_close(wtap *wth)
|
||||
{
|
||||
netmon_t *netmon = (netmon_t *)wfth->priv;
|
||||
netmon_t *netmon = (netmon_t *)wth->priv;
|
||||
|
||||
if (netmon->frame_table != NULL) {
|
||||
g_free(netmon->frame_table);
|
||||
|
@ -983,7 +980,7 @@ int netmon_dump_can_write_encap_2_x(int encap)
|
|||
|
||||
/* Returns TRUE on success, FALSE on failure; sets "*err" to an error code on
|
||||
failure */
|
||||
gboolean netmon_dump_open(wftap_dumper *wdh, int *err)
|
||||
gboolean netmon_dump_open(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
netmon_dump_t *netmon;
|
||||
|
||||
|
@ -991,7 +988,7 @@ gboolean netmon_dump_open(wftap_dumper *wdh, int *err)
|
|||
haven't yet written any packets. As we'll have to rewrite
|
||||
the header when we've written out all the packets, we just
|
||||
skip over the header for now. */
|
||||
if (wftap_dump_file_seek(wdh, CAPTUREFILE_HEADER_SIZE, SEEK_SET, err) == -1)
|
||||
if (wtap_dump_file_seek(wdh, CAPTUREFILE_HEADER_SIZE, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
wdh->subtype_write = netmon_dump;
|
||||
|
@ -1011,7 +1008,7 @@ gboolean netmon_dump_open(wftap_dumper *wdh, int *err)
|
|||
|
||||
/* Write a record for a packet to a dump file.
|
||||
Returns TRUE on success, FALSE on failure. */
|
||||
static gboolean netmon_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
static gboolean netmon_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err)
|
||||
{
|
||||
const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
|
||||
|
@ -1166,7 +1163,7 @@ static gboolean netmon_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
*/
|
||||
rec_size = 0;
|
||||
|
||||
if (!wftap_dump_file_write(wdh, hdrp, hdr_size, err))
|
||||
if (!wtap_dump_file_write(wdh, hdrp, hdr_size, err))
|
||||
return FALSE;
|
||||
rec_size += hdr_size;
|
||||
|
||||
|
@ -1179,12 +1176,12 @@ static gboolean netmon_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
memset(&atm_hdr.src, 0, sizeof atm_hdr.src);
|
||||
atm_hdr.vpi = g_htons(pseudo_header->atm.vpi);
|
||||
atm_hdr.vci = g_htons(pseudo_header->atm.vci);
|
||||
if (!wftap_dump_file_write(wdh, &atm_hdr, sizeof atm_hdr, err))
|
||||
if (!wtap_dump_file_write(wdh, &atm_hdr, sizeof atm_hdr, err))
|
||||
return FALSE;
|
||||
rec_size += sizeof atm_hdr;
|
||||
}
|
||||
|
||||
if (!wftap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
return FALSE;
|
||||
rec_size += phdr->caplen;
|
||||
|
||||
|
@ -1192,7 +1189,7 @@ static gboolean netmon_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
/*
|
||||
* Write out the trailer.
|
||||
*/
|
||||
if (!wftap_dump_file_write(wdh, &rec_2_x_trlr,
|
||||
if (!wtap_dump_file_write(wdh, &rec_2_x_trlr,
|
||||
sizeof rec_2_x_trlr, err))
|
||||
return FALSE;
|
||||
rec_size += sizeof rec_2_x_trlr;
|
||||
|
@ -1252,7 +1249,7 @@ static gboolean netmon_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
|
||||
/* Finish writing to a dump file.
|
||||
Returns TRUE on success, FALSE on failure. */
|
||||
static gboolean netmon_dump_close(wftap_dumper *wdh, int *err)
|
||||
static gboolean netmon_dump_close(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
netmon_dump_t *netmon = (netmon_dump_t *)wdh->priv;
|
||||
size_t n_to_write;
|
||||
|
@ -1264,11 +1261,11 @@ static gboolean netmon_dump_close(wftap_dumper *wdh, int *err)
|
|||
/* Write out the frame table. "netmon->frame_table_index" is
|
||||
the number of entries we've put into it. */
|
||||
n_to_write = netmon->frame_table_index * sizeof *netmon->frame_table;
|
||||
if (!wftap_dump_file_write(wdh, netmon->frame_table, n_to_write, err))
|
||||
if (!wtap_dump_file_write(wdh, netmon->frame_table, n_to_write, err))
|
||||
return FALSE;
|
||||
|
||||
/* Now go fix up the file header. */
|
||||
if (wftap_dump_file_seek(wdh, 0, SEEK_SET, err) == -1)
|
||||
if (wtap_dump_file_seek(wdh, 0, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
memset(&file_hdr, '\0', sizeof file_hdr);
|
||||
switch (wdh->file_type_subtype) {
|
||||
|
@ -1312,7 +1309,7 @@ static gboolean netmon_dump_close(wftap_dumper *wdh, int *err)
|
|||
*err = WTAP_ERR_UNSUPPORTED_FILE_TYPE;
|
||||
return FALSE;
|
||||
}
|
||||
if (!wftap_dump_file_write(wdh, magicp, magic_size, err))
|
||||
if (!wtap_dump_file_write(wdh, magicp, magic_size, err))
|
||||
return FALSE;
|
||||
|
||||
if (wdh->encap == WTAP_ENCAP_PER_PACKET) {
|
||||
|
@ -1346,7 +1343,7 @@ static gboolean netmon_dump_close(wftap_dumper *wdh, int *err)
|
|||
file_hdr.frametableoffset = GUINT32_TO_LE(netmon->frame_table_offset);
|
||||
file_hdr.frametablelength =
|
||||
GUINT32_TO_LE(netmon->frame_table_index * sizeof *netmon->frame_table);
|
||||
if (!wftap_dump_file_write(wdh, &file_hdr, sizeof file_hdr, err))
|
||||
if (!wtap_dump_file_write(wdh, &file_hdr, sizeof file_hdr, err))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include <glib.h>
|
||||
#include <wtap.h>
|
||||
|
||||
int netmon_open(wftap *wfth, int *err, gchar **err_info);
|
||||
gboolean netmon_dump_open(wftap_dumper *wdh, int *err);
|
||||
int netmon_open(wtap *wth, int *err, gchar **err_info);
|
||||
gboolean netmon_dump_open(wtap_dumper *wdh, int *err);
|
||||
int netmon_dump_can_write_encap_1_x(int encap);
|
||||
int netmon_dump_can_write_encap_2_x(int encap);
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "config.h"
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include "wftap-int.h"
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
#include "buffer.h"
|
||||
|
@ -613,30 +612,33 @@ typedef struct {
|
|||
guint64 file_size;
|
||||
} nstrace_t;
|
||||
|
||||
static guint32 nspm_signature_version(wftap*, gchar*, gint32);
|
||||
static gboolean nstrace_read_v10(wftap *wfth, int *err, gchar **err_info,
|
||||
static guint32 nspm_signature_version(wtap*, gchar*, gint32);
|
||||
static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean nstrace_read_v20(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean nstrace_read_v30(wftap *wfth, int *err, gchar **err_info,
|
||||
static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info,
|
||||
gint64 *data_offset);
|
||||
static gboolean nstrace_seek_read_v10(wftap *wth, gint64 seek_off,
|
||||
void* header, Buffer *buf,
|
||||
static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr,
|
||||
Buffer *buf,
|
||||
int *err, gchar **err_info);
|
||||
static gboolean nstrace_seek_read_v20(wftap *wth, gint64 seek_off,
|
||||
void* header, Buffer *buf,
|
||||
static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr,
|
||||
Buffer *buf,
|
||||
int *err, gchar **err_info);
|
||||
static gboolean nstrace_seek_read_v30(wftap *wth, gint64 seek_off,
|
||||
void* header, Buffer *buf,
|
||||
static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr,
|
||||
Buffer *buf,
|
||||
int *err, gchar **err_info);
|
||||
static void nstrace_close(wftap *wth);
|
||||
static void nstrace_close(wtap *wth);
|
||||
|
||||
static gboolean nstrace_set_start_time_v10(wftap *wth);
|
||||
static gboolean nstrace_set_start_time_v20(wftap *wth);
|
||||
static gboolean nstrace_set_start_time(wftap *wth);
|
||||
static gboolean nstrace_set_start_time_v10(wtap *wth);
|
||||
static gboolean nstrace_set_start_time_v20(wtap *wth);
|
||||
static gboolean nstrace_set_start_time(wtap *wth);
|
||||
static guint64 ns_hrtime2nsec(guint32 tm);
|
||||
|
||||
static gboolean nstrace_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err);
|
||||
|
||||
|
||||
|
@ -664,35 +666,34 @@ static guint64 ns_hrtime2nsec(guint32 tm)
|
|||
/*
|
||||
** Netscaler trace format open routines
|
||||
*/
|
||||
int nstrace_open(wftap *wfth, int *err, gchar **err_info)
|
||||
int nstrace_open(wtap *wth, int *err, gchar **err_info)
|
||||
{
|
||||
gchar *nstrace_buf;
|
||||
gint64 file_size;
|
||||
gint32 page_size;
|
||||
nstrace_t *nstrace;
|
||||
int bytes_read;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
errno = WTAP_ERR_CANT_READ;
|
||||
|
||||
if ((file_size = wftap_file_size(wfth, err)) == -1)
|
||||
if ((file_size = wtap_file_size(wth, err)) == -1)
|
||||
return 0;
|
||||
|
||||
nstrace_buf = (gchar *)g_malloc(NSPR_PAGESIZE);
|
||||
page_size = GET_READ_PAGE_SIZE(file_size);
|
||||
|
||||
switch ((wfth->file_type_subtype = nspm_signature_version(wfth, nstrace_buf, page_size)))
|
||||
switch ((wth->file_type_subtype = nspm_signature_version(wth, nstrace_buf, page_size)))
|
||||
{
|
||||
case WTAP_FILE_TYPE_SUBTYPE_NETSCALER_1_0:
|
||||
wfth->file_encap = WTAP_ENCAP_NSTRACE_1_0;
|
||||
wth->file_encap = WTAP_ENCAP_NSTRACE_1_0;
|
||||
break;
|
||||
|
||||
case WTAP_FILE_TYPE_SUBTYPE_NETSCALER_2_0:
|
||||
wfth->file_encap = WTAP_ENCAP_NSTRACE_2_0;
|
||||
wth->file_encap = WTAP_ENCAP_NSTRACE_2_0;
|
||||
break;
|
||||
|
||||
case WTAP_FILE_TYPE_SUBTYPE_NETSCALER_3_0:
|
||||
wfth->file_encap = WTAP_ENCAP_NSTRACE_3_0;
|
||||
wth->file_encap = WTAP_ENCAP_NSTRACE_3_0;
|
||||
g_free(nstrace_buf);
|
||||
nstrace_buf = (gchar *)g_malloc(NSPR_PAGESIZE_TRACE);
|
||||
page_size = GET_READ_PAGE_SIZEV3(file_size);
|
||||
|
@ -700,49 +701,49 @@ int nstrace_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
default:
|
||||
*err = WTAP_ERR_UNSUPPORTED;
|
||||
*err_info = g_strdup_printf("nstrace: file type %d unsupported", wfth->file_type_subtype);
|
||||
*err_info = g_strdup_printf("nstrace: file type %d unsupported", wth->file_type_subtype);
|
||||
g_free(nstrace_buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((file_seek(wfth->fh, 0, SEEK_SET, err)) == -1)
|
||||
if ((file_seek(wth->fh, 0, SEEK_SET, err)) == -1)
|
||||
{
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
g_free(nstrace_buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bytes_read = file_read(nstrace_buf, page_size, wfth->fh);
|
||||
bytes_read = file_read(nstrace_buf, page_size, wth->fh);
|
||||
if (bytes_read != page_size)
|
||||
{
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
g_free(nstrace_buf);
|
||||
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (wfth->file_type_subtype)
|
||||
switch (wth->file_type_subtype)
|
||||
{
|
||||
case WTAP_FILE_TYPE_SUBTYPE_NETSCALER_1_0:
|
||||
wfth->subtype_read = nstrace_read_v10;
|
||||
wfth->subtype_seek_read = nstrace_seek_read_v10;
|
||||
wth->subtype_read = nstrace_read_v10;
|
||||
wth->subtype_seek_read = nstrace_seek_read_v10;
|
||||
break;
|
||||
|
||||
case WTAP_FILE_TYPE_SUBTYPE_NETSCALER_2_0:
|
||||
wfth->subtype_read = nstrace_read_v20;
|
||||
wfth->subtype_seek_read = nstrace_seek_read_v20;
|
||||
wth->subtype_read = nstrace_read_v20;
|
||||
wth->subtype_seek_read = nstrace_seek_read_v20;
|
||||
break;
|
||||
|
||||
case WTAP_FILE_TYPE_SUBTYPE_NETSCALER_3_0:
|
||||
wfth->subtype_read = nstrace_read_v30;
|
||||
wfth->subtype_seek_read = nstrace_seek_read_v30;
|
||||
wth->subtype_read = nstrace_read_v30;
|
||||
wth->subtype_seek_read = nstrace_seek_read_v30;
|
||||
break;
|
||||
}
|
||||
wfth->subtype_close = nstrace_close;
|
||||
wth->subtype_close = nstrace_close;
|
||||
|
||||
nstrace = (nstrace_t *)g_malloc(sizeof(nstrace_t));
|
||||
wfth->priv = (void *)nstrace;
|
||||
wth->priv = (void *)nstrace;
|
||||
nstrace->pnstrace_buf = nstrace_buf;
|
||||
nstrace->xxx_offset = 0;
|
||||
nstrace->nstrace_buflen = page_size;
|
||||
|
@ -755,22 +756,22 @@ int nstrace_open(wftap *wfth, int *err, gchar **err_info)
|
|||
|
||||
|
||||
/* Set the start time by looking for the abstime record */
|
||||
if ((nstrace_set_start_time(wfth)) == FALSE)
|
||||
if ((nstrace_set_start_time(wth)) == FALSE)
|
||||
{
|
||||
/* Reset the read pointer to start of the file. */
|
||||
if ((file_seek(wfth->fh, 0, SEEK_SET, err)) == -1)
|
||||
if ((file_seek(wth->fh, 0, SEEK_SET, err)) == -1)
|
||||
{
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
g_free(nstrace->pnstrace_buf);
|
||||
g_free(nstrace);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Read the first page of data */
|
||||
bytes_read = file_read(nstrace_buf, page_size, wfth->fh);
|
||||
bytes_read = file_read(nstrace_buf, page_size, wth->fh);
|
||||
if (bytes_read != page_size)
|
||||
{
|
||||
*err = file_error(wfth->fh, err_info);
|
||||
*err = file_error(wth->fh, err_info);
|
||||
g_free(nstrace->pnstrace_buf);
|
||||
g_free(nstrace);
|
||||
return 0;
|
||||
|
@ -780,7 +781,7 @@ int nstrace_open(wftap *wfth, int *err, gchar **err_info)
|
|||
nstrace->nstrace_buf_offset = 0;
|
||||
}
|
||||
|
||||
wfth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
wth->tsprecision = WTAP_FILE_TSPREC_NSEC;
|
||||
wth->phdr.ts.secs = nstrace->nspm_curtime;
|
||||
wth->phdr.ts.nsecs = 0;
|
||||
|
||||
|
@ -805,12 +806,12 @@ nspm_signature_func(30)
|
|||
** has to be a file seek to return to the start of the first page.
|
||||
*/
|
||||
static guint32
|
||||
nspm_signature_version(wftap *wfth, gchar *nstrace_buf, gint32 len)
|
||||
nspm_signature_version(wtap *wth, gchar *nstrace_buf, gint32 len)
|
||||
{
|
||||
gchar *dp = nstrace_buf;
|
||||
int bytes_read;
|
||||
|
||||
bytes_read = file_read(dp, len, wfth->fh);
|
||||
bytes_read = file_read(dp, len, wth->fh);
|
||||
if (bytes_read == len) {
|
||||
|
||||
for ( ; len > (gint32)(MIN(sizeof(NSPR_SIGSTR_V10), sizeof(NSPR_SIGSTR_V20))); dp++, len--)
|
||||
|
@ -851,9 +852,9 @@ nspm_signature_version(wftap *wfth, gchar *nstrace_buf, gint32 len)
|
|||
|
||||
|
||||
#define nstrace_set_start_time_ver(ver) \
|
||||
gboolean nstrace_set_start_time_v##ver(wftap *wfth) \
|
||||
gboolean nstrace_set_start_time_v##ver(wtap *wth) \
|
||||
{\
|
||||
nstrace_t *nstrace = (nstrace_t *)wfth->priv;\
|
||||
nstrace_t *nstrace = (nstrace_t *)wth->priv;\
|
||||
gchar* nstrace_buf = nstrace->pnstrace_buf;\
|
||||
gint32 nstrace_buf_offset = nstrace->nstrace_buf_offset;\
|
||||
gint32 nstrace_buflen = nstrace->nstrace_buflen;\
|
||||
|
@ -880,7 +881,7 @@ nspm_signature_version(wftap *wfth, gchar *nstrace_buf, gint32 len)
|
|||
nstrace_buf_offset = 0;\
|
||||
nstrace->xxx_offset += nstrace_buflen;\
|
||||
nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - nstrace->xxx_offset));\
|
||||
}while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wfth->fh)) && bytes_read == nstrace_buflen); \
|
||||
}while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && bytes_read == nstrace_buflen); \
|
||||
return FALSE;\
|
||||
}
|
||||
|
||||
|
@ -896,14 +897,14 @@ nstrace_set_start_time_ver(20)
|
|||
** the next record after the ABSTIME record. Inorder to report correct time values, all trace
|
||||
** records before the ABSTIME record are ignored.
|
||||
*/
|
||||
static gboolean nstrace_set_start_time(wftap *wfth)
|
||||
static gboolean nstrace_set_start_time(wtap *wth)
|
||||
{
|
||||
if (wfth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NETSCALER_1_0)
|
||||
return nstrace_set_start_time_v10(wfth);
|
||||
else if (wfth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NETSCALER_2_0)
|
||||
return nstrace_set_start_time_v20(wfth);
|
||||
else if (wfth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NETSCALER_3_0)
|
||||
return nstrace_set_start_time_v20(wfth);
|
||||
if (wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NETSCALER_1_0)
|
||||
return nstrace_set_start_time_v10(wth);
|
||||
else if (wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NETSCALER_2_0)
|
||||
return nstrace_set_start_time_v20(wth);
|
||||
else if (wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NETSCALER_3_0)
|
||||
return nstrace_set_start_time_v20(wth);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -924,9 +925,9 @@ static gboolean nstrace_set_start_time(wftap *wfth)
|
|||
/*
|
||||
** Netscaler trace format read routines.
|
||||
*/
|
||||
static gboolean nstrace_read_v10(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
static gboolean nstrace_read_v10(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
{
|
||||
nstrace_t *nstrace = (nstrace_t *)wfth->priv;
|
||||
nstrace_t *nstrace = (nstrace_t *)wth->priv;
|
||||
guint64 nsg_creltime = nstrace->nsg_creltime;
|
||||
gchar *nstrace_buf = nstrace->pnstrace_buf;
|
||||
gint32 nstrace_buf_offset = nstrace->nstrace_buf_offset;
|
||||
|
@ -934,7 +935,6 @@ static gboolean nstrace_read_v10(wftap *wfth, int *err, gchar **err_info, gint64
|
|||
nspr_pktracefull_v10_t *fp;
|
||||
nspr_pktracepart_v10_t *pp;
|
||||
int bytes_read;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
*err = 0;
|
||||
*err_info = NULL;
|
||||
|
@ -959,8 +959,8 @@ static gboolean nstrace_read_v10(wftap *wfth, int *err, gchar **err_info, gint64
|
|||
(phdr)->ts.secs = nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);\
|
||||
(phdr)->ts.nsecs = (guint32) (nsg_creltime % 1000000000);\
|
||||
TRACE_FULL_V##type##_REC_LEN_OFF(phdr,v##type##_full,fp,pktracefull_v##type);\
|
||||
buffer_assure_space(wfth->frame_buffer, (phdr)->caplen);\
|
||||
memcpy(buffer_start_ptr(wfth->frame_buffer), fp, (phdr)->caplen);\
|
||||
buffer_assure_space(wth->frame_buffer, (phdr)->caplen);\
|
||||
memcpy(buffer_start_ptr(wth->frame_buffer), fp, (phdr)->caplen);\
|
||||
*data_offset = nstrace->xxx_offset + nstrace_buf_offset;\
|
||||
nstrace->nstrace_buf_offset = nstrace_buf_offset + (phdr)->len;\
|
||||
nstrace->nstrace_buflen = nstrace_buflen;\
|
||||
|
@ -982,8 +982,8 @@ static gboolean nstrace_read_v10(wftap *wfth, int *err, gchar **err_info, gint64
|
|||
(phdr)->ts.secs = nstrace->nspm_curtime + (guint32) (nsg_creltime / 1000000000);\
|
||||
(phdr)->ts.nsecs = (guint32) (nsg_creltime % 1000000000);\
|
||||
TRACE_PART_V##type##_REC_LEN_OFF(phdr,v##type##_part,pp,pktracepart_v##type);\
|
||||
buffer_assure_space(wfth->frame_buffer, (phdr)->caplen);\
|
||||
memcpy(buffer_start_ptr(wfth->frame_buffer), pp, (phdr)->caplen);\
|
||||
buffer_assure_space(wth->frame_buffer, (phdr)->caplen);\
|
||||
memcpy(buffer_start_ptr(wth->frame_buffer), pp, (phdr)->caplen);\
|
||||
*data_offset = nstrace->xxx_offset + nstrace_buf_offset;\
|
||||
nstrace->nstrace_buf_offset = nstrace_buf_offset + (phdr)->caplen;\
|
||||
nstrace->nsg_creltime = nsg_creltime;\
|
||||
|
@ -1028,7 +1028,7 @@ static gboolean nstrace_read_v10(wftap *wfth, int *err, gchar **err_info, gint64
|
|||
nstrace_buf_offset = 0;
|
||||
nstrace->xxx_offset += nstrace_buflen;
|
||||
nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - nstrace->xxx_offset));
|
||||
}while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wfth->fh)) && (bytes_read == nstrace_buflen));
|
||||
}while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1106,8 +1106,8 @@ static gboolean nstrace_read_v10(wftap *wfth, int *err, gchar **err_info, gint64
|
|||
SIZEDEF##ver((phdr),fp,ver);\
|
||||
TRACE_V##ver##_REC_LEN_OFF((phdr),enumprefix,type,structname);\
|
||||
(phdr)->pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##TYPE;\
|
||||
buffer_assure_space(wfth->frame_buffer, (phdr)->caplen);\
|
||||
memcpy(buffer_start_ptr(wfth->frame_buffer), fp, (phdr)->caplen);\
|
||||
buffer_assure_space(wth->frame_buffer, (phdr)->caplen);\
|
||||
memcpy(buffer_start_ptr(wth->frame_buffer), fp, (phdr)->caplen);\
|
||||
*data_offset = nstrace->xxx_offset + nstrace_buf_offset;\
|
||||
nstrace->nstrace_buf_offset = nstrace_buf_offset + nspr_getv20recordsize((nspr_hd_v20_t *)fp);\
|
||||
nstrace->nstrace_buflen = nstrace_buflen;\
|
||||
|
@ -1115,15 +1115,14 @@ static gboolean nstrace_read_v10(wftap *wfth, int *err, gchar **err_info, gint64
|
|||
return TRUE;\
|
||||
}while(0)
|
||||
|
||||
static gboolean nstrace_read_v20(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
static gboolean nstrace_read_v20(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
{
|
||||
nstrace_t *nstrace = (nstrace_t *)wfth->priv;
|
||||
nstrace_t *nstrace = (nstrace_t *)wth->priv;
|
||||
guint64 nsg_creltime = nstrace->nsg_creltime;
|
||||
gchar *nstrace_buf = nstrace->pnstrace_buf;
|
||||
gint32 nstrace_buf_offset = nstrace->nstrace_buf_offset;
|
||||
gint32 nstrace_buflen = nstrace->nstrace_buflen;
|
||||
int bytes_read;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
*err = 0;
|
||||
*err_info = NULL;
|
||||
|
@ -1218,7 +1217,7 @@ static gboolean nstrace_read_v20(wftap *wfth, int *err, gchar **err_info, gint64
|
|||
nstrace_buf_offset = 0;
|
||||
nstrace->xxx_offset += nstrace_buflen;
|
||||
nstrace_buflen = GET_READ_PAGE_SIZE((nstrace->file_size - nstrace->xxx_offset));
|
||||
}while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wfth->fh)) && (bytes_read == nstrace_buflen));
|
||||
}while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1232,7 +1231,7 @@ static gboolean nstrace_read_v20(wftap *wfth, int *err, gchar **err_info, gint64
|
|||
SIZEDEF##ver((phdr),fp,ver);\
|
||||
TRACE_V##ver##_REC_LEN_OFF((phdr),enumprefix,type,structname);\
|
||||
(phdr)->pseudo_header.nstr.rec_type = NSPR_HEADER_VERSION##TYPE;\
|
||||
buffer_assure_space(wfth->frame_buffer, (phdr)->caplen);\
|
||||
buffer_assure_space(wth->frame_buffer, (phdr)->caplen);\
|
||||
*data_offset = nstrace->xxx_offset + nstrace_buf_offset;\
|
||||
while (nstrace_tmpbuff_off < nspr_##structname##_s) {\
|
||||
nstrace_tmpbuff[nstrace_tmpbuff_off++] = nstrace_buf[nstrace_buf_offset++];\
|
||||
|
@ -1247,7 +1246,7 @@ static gboolean nstrace_read_v20(wftap *wfth, int *err, gchar **err_info, gint64
|
|||
}\
|
||||
nstrace_buflen = NSPR_PAGESIZE_TRACE;\
|
||||
nstrace->xxx_offset += nstrace_buflen;\
|
||||
bytes_read = file_read(nstrace_buf, NSPR_PAGESIZE_TRACE, wfth->fh);\
|
||||
bytes_read = file_read(nstrace_buf, NSPR_PAGESIZE_TRACE, wth->fh);\
|
||||
if (bytes_read != NSPR_PAGESIZE_TRACE) {\
|
||||
return FALSE;\
|
||||
} else {\
|
||||
|
@ -1260,16 +1259,16 @@ static gboolean nstrace_read_v20(wftap *wfth, int *err, gchar **err_info, gint64
|
|||
while (nstrace_tmpbuff_off < nst_dataSize) {\
|
||||
nstrace_tmpbuff[nstrace_tmpbuff_off++] = nstrace_buf[nstrace_buf_offset++];\
|
||||
}\
|
||||
memcpy(buffer_start_ptr(wfth->frame_buffer), nstrace_tmpbuff, (phdr)->caplen);\
|
||||
memcpy(buffer_start_ptr(wth->frame_buffer), nstrace_tmpbuff, (phdr)->caplen);\
|
||||
nstrace->nstrace_buf_offset = nstrace_buf_offset;\
|
||||
nstrace->nstrace_buflen = nstrace_buflen = ((gint32)NSPR_PAGESIZE_TRACE);\
|
||||
nstrace->nsg_creltime = nsg_creltime;\
|
||||
return TRUE;\
|
||||
} while(0)
|
||||
|
||||
static gboolean nstrace_read_v30(wftap *wfth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
static gboolean nstrace_read_v30(wtap *wth, int *err, gchar **err_info, gint64 *data_offset)
|
||||
{
|
||||
nstrace_t *nstrace = (nstrace_t *)wfth->priv;
|
||||
nstrace_t *nstrace = (nstrace_t *)wth->priv;
|
||||
guint64 nsg_creltime = nstrace->nsg_creltime;
|
||||
gchar *nstrace_buf = nstrace->pnstrace_buf;
|
||||
gint32 nstrace_buf_offset = nstrace->nstrace_buf_offset;
|
||||
|
@ -1278,8 +1277,6 @@ static gboolean nstrace_read_v30(wftap *wfth, int *err, gchar **err_info, gint64
|
|||
guint32 nstrace_tmpbuff_off=0,nst_dataSize=0,rec_size=0,nsg_nextPageOffset=0;
|
||||
nspr_hd_v20_t *hdp;
|
||||
int bytes_read;
|
||||
wtap* wth = (wtap*)wfth->tap_specific_data;
|
||||
|
||||
*err = 0;
|
||||
*err_info = NULL;
|
||||
|
||||
|
@ -1325,15 +1322,15 @@ static gboolean nstrace_read_v30(wftap *wfth, int *err, gchar **err_info, gint64
|
|||
nstrace_buf_offset = 0;
|
||||
nstrace->xxx_offset += nstrace_buflen;
|
||||
nstrace_buflen = NSPR_PAGESIZE_TRACE;
|
||||
} while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wfth->fh)) && (bytes_read == nstrace_buflen));
|
||||
} while((nstrace_buflen > 0) && (bytes_read = file_read(nstrace_buf, nstrace_buflen, wth->fh)) && (bytes_read == nstrace_buflen));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#undef PACKET_DESCRIBE
|
||||
|
||||
static gboolean nstrace_seek_read_v10(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info)
|
||||
static gboolean nstrace_seek_read_v10(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
nspr_hd_v10_t hdr;
|
||||
int bytes_read;
|
||||
|
@ -1342,19 +1339,18 @@ static gboolean nstrace_seek_read_v10(wftap *wfth, gint64 seek_off,
|
|||
unsigned int bytes_to_read;
|
||||
nspr_pktracefull_v10_t *fp;
|
||||
nspr_pktracepart_v10_t *pp;
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
|
||||
*err = 0;
|
||||
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
** Read the record header.
|
||||
*/
|
||||
bytes_read = file_read((void *)&hdr, sizeof hdr, wfth->random_fh);
|
||||
bytes_read = file_read((void *)&hdr, sizeof hdr, wth->random_fh);
|
||||
if (bytes_read != sizeof hdr) {
|
||||
*err = file_error(wfth->random_fh, err_info);
|
||||
*err = file_error(wth->random_fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return FALSE;
|
||||
|
@ -1372,10 +1368,10 @@ static gboolean nstrace_seek_read_v10(wftap *wfth, gint64 seek_off,
|
|||
pd = buffer_start_ptr(buf);
|
||||
memcpy(pd, (void *)&hdr, sizeof hdr);
|
||||
if (record_length > sizeof hdr) {
|
||||
bytes_to_read = (unsigned int)(record_length - sizeof hdr);
|
||||
bytes_read = file_read(pd + sizeof hdr, bytes_to_read, wfth->random_fh);
|
||||
bytes_to_read = (unsigned int)(record_length - sizeof hdr);
|
||||
bytes_read = file_read(pd + sizeof hdr, bytes_to_read, wth->random_fh);
|
||||
if (bytes_read < 0 || (unsigned int)bytes_read != bytes_to_read) {
|
||||
*err = file_error(wfth->random_fh, err_info);
|
||||
*err = file_error(wth->random_fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return FALSE;
|
||||
|
@ -1424,8 +1420,8 @@ static gboolean nstrace_seek_read_v10(wftap *wfth, gint64 seek_off,
|
|||
return TRUE;\
|
||||
}while(0)
|
||||
|
||||
static gboolean nstrace_seek_read_v20(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info)
|
||||
static gboolean nstrace_seek_read_v20(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
nspr_hd_v20_t hdr;
|
||||
int bytes_read;
|
||||
|
@ -1433,19 +1429,18 @@ static gboolean nstrace_seek_read_v20(wftap *wfth, gint64 seek_off,
|
|||
guint hdrlen;
|
||||
guint8 *pd;
|
||||
unsigned int bytes_to_read;
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
|
||||
*err = 0;
|
||||
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
** Read the first 2 bytes of the record header.
|
||||
*/
|
||||
bytes_read = file_read((void *)&hdr, 2, wfth->random_fh);
|
||||
bytes_read = file_read((void *)&hdr, 2, wth->random_fh);
|
||||
if (bytes_read != 2) {
|
||||
*err = file_error(wfth->random_fh, err_info);
|
||||
*err = file_error(wth->random_fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return FALSE;
|
||||
|
@ -1456,9 +1451,9 @@ static gboolean nstrace_seek_read_v20(wftap *wfth, gint64 seek_off,
|
|||
** Is there a third byte? If so, read it.
|
||||
*/
|
||||
if (hdr.phd_RecordSizeLow & NSPR_V20RECORDSIZE_2BYTES) {
|
||||
bytes_read = file_read((void *)&hdr.phd_RecordSizeHigh, 1, wfth->random_fh);
|
||||
bytes_read = file_read((void *)&hdr.phd_RecordSizeHigh, 1, wth->random_fh);
|
||||
if (bytes_read != 1) {
|
||||
*err = file_error(wfth->random_fh, err_info);
|
||||
*err = file_error(wth->random_fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return FALSE;
|
||||
|
@ -1479,9 +1474,9 @@ static gboolean nstrace_seek_read_v20(wftap *wfth, gint64 seek_off,
|
|||
memcpy(pd, (void *)&hdr, hdrlen);
|
||||
if (record_length > hdrlen) {
|
||||
bytes_to_read = (unsigned int)(record_length - hdrlen);
|
||||
bytes_read = file_read(pd + hdrlen, bytes_to_read, wfth->random_fh);
|
||||
bytes_read = file_read(pd + hdrlen, bytes_to_read, wth->random_fh);
|
||||
if (bytes_read < 0 || (unsigned int)bytes_read != bytes_to_read) {
|
||||
*err = file_error(wfth->random_fh, err_info);
|
||||
*err = file_error(wth->random_fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return FALSE;
|
||||
|
@ -1541,8 +1536,8 @@ static gboolean nstrace_seek_read_v20(wftap *wfth, gint64 seek_off,
|
|||
}
|
||||
|
||||
|
||||
static gboolean nstrace_seek_read_v30(wftap *wfth, gint64 seek_off,
|
||||
void* header, Buffer *buf, int *err, gchar **err_info)
|
||||
static gboolean nstrace_seek_read_v30(wtap *wth, gint64 seek_off,
|
||||
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
|
||||
{
|
||||
nspr_hd_v20_t hdr;
|
||||
int bytes_read;
|
||||
|
@ -1550,18 +1545,17 @@ static gboolean nstrace_seek_read_v30(wftap *wfth, gint64 seek_off,
|
|||
guint hdrlen;
|
||||
guint8 *pd;
|
||||
unsigned int bytes_to_read;
|
||||
struct wtap_pkthdr *phdr = (struct wtap_pkthdr *)header;
|
||||
|
||||
*err = 0;
|
||||
|
||||
if (file_seek(wfth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
||||
return FALSE;
|
||||
/*
|
||||
** Read the first 2 bytes of the record header.
|
||||
*/
|
||||
bytes_read = file_read((void *)&hdr, 2, wfth->random_fh);
|
||||
bytes_read = file_read((void *)&hdr, 2, wth->random_fh);
|
||||
if (bytes_read != 2) {
|
||||
*err = file_error(wfth->random_fh, err_info);
|
||||
*err = file_error(wth->random_fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return FALSE;
|
||||
|
@ -1572,9 +1566,9 @@ static gboolean nstrace_seek_read_v30(wftap *wfth, gint64 seek_off,
|
|||
** Is there a third byte? If so, read it.
|
||||
*/
|
||||
if (hdr.phd_RecordSizeLow & NSPR_V20RECORDSIZE_2BYTES) {
|
||||
bytes_read = file_read((void *)&hdr.phd_RecordSizeHigh, 1, wfth->random_fh);
|
||||
bytes_read = file_read((void *)&hdr.phd_RecordSizeHigh, 1, wth->random_fh);
|
||||
if (bytes_read != 1) {
|
||||
*err = file_error(wfth->random_fh, err_info);
|
||||
*err = file_error(wth->random_fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return FALSE;
|
||||
|
@ -1595,9 +1589,9 @@ static gboolean nstrace_seek_read_v30(wftap *wfth, gint64 seek_off,
|
|||
memcpy(pd, (void *)&hdr, hdrlen);
|
||||
if (record_length > hdrlen) {
|
||||
bytes_to_read = (unsigned int)(record_length - hdrlen);
|
||||
bytes_read = file_read(pd + hdrlen, bytes_to_read, wfth->random_fh);
|
||||
bytes_read = file_read(pd + hdrlen, bytes_to_read, wth->random_fh);
|
||||
if (bytes_read < 0 || (unsigned int)bytes_read != bytes_to_read) {
|
||||
*err = file_error(wfth->random_fh, err_info);
|
||||
*err = file_error(wth->random_fh, err_info);
|
||||
if (*err == 0)
|
||||
*err = WTAP_ERR_SHORT_READ;
|
||||
return FALSE;
|
||||
|
@ -1625,9 +1619,9 @@ static gboolean nstrace_seek_read_v30(wftap *wfth, gint64 seek_off,
|
|||
/*
|
||||
** Netscaler trace format close routines.
|
||||
*/
|
||||
static void nstrace_close(wftap *wfth)
|
||||
static void nstrace_close(wtap *wth)
|
||||
{
|
||||
nstrace_t *nstrace = (nstrace_t *)wfth->priv;
|
||||
nstrace_t *nstrace = (nstrace_t *)wth->priv;
|
||||
|
||||
g_free(nstrace->pnstrace_buf);
|
||||
}
|
||||
|
@ -1672,7 +1666,7 @@ int nstrace_30_dump_can_write_encap(int encap)
|
|||
|
||||
/* Returns TRUE on success, FALSE on failure; sets "*err" to an error code on
|
||||
** failure */
|
||||
gboolean nstrace_dump_open(wftap_dumper *wdh, int *err _U_)
|
||||
gboolean nstrace_dump_open(wtap_dumper *wdh, int *err _U_)
|
||||
{
|
||||
nstrace_dump_t *nstrace;
|
||||
|
||||
|
@ -1688,7 +1682,7 @@ gboolean nstrace_dump_open(wftap_dumper *wdh, int *err _U_)
|
|||
}
|
||||
|
||||
|
||||
static gboolean nstrace_add_signature(wftap_dumper *wdh, int *err)
|
||||
static gboolean nstrace_add_signature(wtap_dumper *wdh, int *err)
|
||||
{
|
||||
nstrace_dump_t *nstrace = (nstrace_dump_t *)wdh->priv;
|
||||
|
||||
|
@ -1706,7 +1700,7 @@ static gboolean nstrace_add_signature(wftap_dumper *wdh, int *err)
|
|||
g_strlcpy(sig10.sig_Signature, NSPR_SIGSTR_V10, NSPR_SIGSIZE_V10);
|
||||
|
||||
/* Write the record into the file */
|
||||
if (!wftap_dump_file_write(wdh, &sig10, nspr_signature_v10_s,
|
||||
if (!wtap_dump_file_write(wdh, &sig10, nspr_signature_v10_s,
|
||||
err))
|
||||
return FALSE;
|
||||
|
||||
|
@ -1722,7 +1716,7 @@ static gboolean nstrace_add_signature(wftap_dumper *wdh, int *err)
|
|||
memcpy(sig20.sig_Signature, NSPR_SIGSTR_V20, sizeof(NSPR_SIGSTR_V20));
|
||||
|
||||
/* Write the record into the file */
|
||||
if (!wftap_dump_file_write(wdh, &sig20, sig20.sig_RecordSize,
|
||||
if (!wtap_dump_file_write(wdh, &sig20, sig20.sig_RecordSize,
|
||||
err))
|
||||
return FALSE;
|
||||
|
||||
|
@ -1738,7 +1732,7 @@ static gboolean nstrace_add_signature(wftap_dumper *wdh, int *err)
|
|||
memcpy(sig30.sig_Signature, NSPR_SIGSTR_V30, sizeof(NSPR_SIGSTR_V30));
|
||||
|
||||
/* Write the record into the file */
|
||||
if (!wftap_dump_file_write(wdh, &sig30, sig30.sig_RecordSize,
|
||||
if (!wtap_dump_file_write(wdh, &sig30, sig30.sig_RecordSize,
|
||||
err))
|
||||
return FALSE;
|
||||
|
||||
|
@ -1755,7 +1749,7 @@ static gboolean nstrace_add_signature(wftap_dumper *wdh, int *err)
|
|||
|
||||
|
||||
static gboolean
|
||||
nstrace_add_abstime(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
nstrace_add_abstime(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err)
|
||||
{
|
||||
nstrace_dump_t *nstrace = (nstrace_dump_t *)wdh->priv;
|
||||
|
@ -1782,7 +1776,7 @@ nstrace_add_abstime(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
memcpy(abs10.abs_Time, &abstime, sizeof abs10.abs_Time);
|
||||
|
||||
/* Write the record into the file */
|
||||
if (!wftap_dump_file_write(wdh, &abs10, nspr_abstime_v10_s, err))
|
||||
if (!wtap_dump_file_write(wdh, &abs10, nspr_abstime_v10_s, err))
|
||||
return FALSE;
|
||||
|
||||
/* Move forward the page offset */
|
||||
|
@ -1805,7 +1799,7 @@ nstrace_add_abstime(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
memcpy(abs20.abs_RelTime, &abstime, sizeof abs20.abs_RelTime);
|
||||
|
||||
/* Write the record into the file */
|
||||
if (!wftap_dump_file_write(wdh, &abs20, nspr_abstime_v20_s, err))
|
||||
if (!wtap_dump_file_write(wdh, &abs20, nspr_abstime_v20_s, err))
|
||||
return FALSE;
|
||||
|
||||
/* Move forward the page offset */
|
||||
|
@ -1823,7 +1817,7 @@ nstrace_add_abstime(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
|
||||
/* Write a record for a packet to a dump file.
|
||||
Returns TRUE on success, FALSE on failure. */
|
||||
static gboolean nstrace_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
||||
const guint8 *pd, int *err)
|
||||
{
|
||||
nstrace_dump_t *nstrace = (nstrace_dump_t *)wdh->priv;
|
||||
|
@ -1862,7 +1856,7 @@ static gboolean nstrace_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
if (nstrace->page_offset + phdr->caplen >= nstrace->page_len)
|
||||
{
|
||||
/* Start on the next page */
|
||||
if (wftap_dump_file_seek(wdh, (nstrace->page_len - nstrace->page_offset), SEEK_CUR, err) == -1)
|
||||
if (wtap_dump_file_seek(wdh, (nstrace->page_len - nstrace->page_offset), SEEK_CUR, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
nstrace->page_offset = 0;
|
||||
|
@ -1873,7 +1867,7 @@ static gboolean nstrace_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
}
|
||||
|
||||
/* Write the actual record as is */
|
||||
if (!wftap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
return FALSE;
|
||||
|
||||
nstrace->page_offset += (guint16) phdr->caplen;
|
||||
|
@ -1901,7 +1895,7 @@ static gboolean nstrace_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
if (nstrace->page_offset + phdr->caplen >= nstrace->page_len)
|
||||
{
|
||||
/* Start on the next page */
|
||||
if (wftap_dump_file_seek(wdh, (nstrace->page_len - nstrace->page_offset), SEEK_CUR, err) == -1)
|
||||
if (wtap_dump_file_seek(wdh, (nstrace->page_len - nstrace->page_offset), SEEK_CUR, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
nstrace->page_offset = 0;
|
||||
|
@ -1912,7 +1906,7 @@ static gboolean nstrace_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
}
|
||||
|
||||
/* Write the actual record as is */
|
||||
if (!wftap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
return FALSE;
|
||||
|
||||
nstrace->page_offset += (guint16) phdr->caplen;
|
||||
|
@ -1934,7 +1928,7 @@ static gboolean nstrace_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
if (nstrace->page_offset + phdr->caplen >= nstrace->page_len)
|
||||
{
|
||||
/* Start on the next page */
|
||||
if (wftap_dump_file_seek(wdh, (nstrace->page_len - nstrace->page_offset), SEEK_CUR, err) == -1)
|
||||
if (wtap_dump_file_seek(wdh, (nstrace->page_len - nstrace->page_offset), SEEK_CUR, err) == -1)
|
||||
return FALSE;
|
||||
|
||||
nstrace->page_offset = 0;
|
||||
|
@ -1945,7 +1939,7 @@ static gboolean nstrace_dump(wftap_dumper *wdh, const struct wtap_pkthdr *phdr,
|
|||
}
|
||||
|
||||
/* Write the actual record as is */
|
||||
if (!wftap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
|
||||
return FALSE;
|
||||
|
||||
nstrace->page_offset += (guint16) phdr->caplen;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue