2009-06-15 18:56:46 +00:00
|
|
|
/* ascendtext.c
|
1999-09-11 04:53:26 +00:00
|
|
|
*
|
|
|
|
* Wiretap Library
|
2001-11-13 23:55:44 +00:00
|
|
|
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
|
2002-08-28 20:30:45 +00:00
|
|
|
*
|
1999-09-11 04:53:26 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 20:30:45 +00:00
|
|
|
*
|
1999-09-11 04:53:26 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 20:30:45 +00:00
|
|
|
*
|
1999-09-11 04:53:26 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
1999-09-11 04:53:26 +00:00
|
|
|
*/
|
2002-03-04 00:25:35 +00:00
|
|
|
|
1999-09-11 04:53:26 +00:00
|
|
|
#include "config.h"
|
2000-05-19 23:07:04 +00:00
|
|
|
#include "wtap-int.h"
|
1999-09-11 04:53:26 +00:00
|
|
|
#include "buffer.h"
|
2009-06-15 18:56:46 +00:00
|
|
|
#include "ascendtext.h"
|
1999-10-08 07:45:31 +00:00
|
|
|
#include "ascend-int.h"
|
2000-01-13 07:09:20 +00:00
|
|
|
#include "file_wrappers.h"
|
2008-05-22 15:46:27 +00:00
|
|
|
#include <wsutil/file_util.h>
|
1999-09-11 04:53:26 +00:00
|
|
|
|
2002-03-04 00:25:35 +00:00
|
|
|
#include <errno.h>
|
2000-01-10 17:33:17 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
1999-09-11 04:53:26 +00:00
|
|
|
#include <unistd.h>
|
2000-01-10 17:33:17 +00:00
|
|
|
#endif
|
|
|
|
|
1999-09-11 04:53:26 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2005-02-05 17:39:12 +00:00
|
|
|
/* Last updated: Feb 03 2005: Josh Bailey (joshbailey@lucent.com).
|
1999-09-11 04:53:26 +00:00
|
|
|
|
2005-02-05 17:39:12 +00:00
|
|
|
This module reads the text hex dump output of various TAOS
|
|
|
|
(Lucent/Ascend Max, Max TNT, APX, etc) debug commands, including:
|
|
|
|
|
|
|
|
* pridisplay traces primary rate ISDN
|
|
|
|
* ether-display traces Ethernet packets (dangerous! CPU intensive)
|
|
|
|
* wanopening, wandisplay, wannext, wandsess
|
|
|
|
traces PPP or other WAN connections
|
|
|
|
|
2009-06-15 18:56:46 +00:00
|
|
|
Please see ascend.y for examples.
|
2005-02-05 17:39:12 +00:00
|
|
|
|
|
|
|
Detailed documentation on TAOS products is at http://support.lucent.com.
|
|
|
|
|
|
|
|
Support for other commands will be added on an ongoing basis. */
|
1999-09-11 04:53:26 +00:00
|
|
|
|
2005-02-05 17:39:12 +00:00
|
|
|
typedef struct _ascend_magic_string {
|
2005-07-22 07:55:51 +00:00
|
|
|
guint type;
|
2008-05-22 15:46:27 +00:00
|
|
|
const gchar *strptr;
|
2005-02-05 17:39:12 +00:00
|
|
|
} ascend_magic_string;
|
|
|
|
|
|
|
|
#define ASCEND_MAGIC_STRINGS 11
|
|
|
|
#define ASCEND_DATE "Date:"
|
|
|
|
|
|
|
|
/* these magic strings signify the headers of a supported debug commands */
|
|
|
|
static const ascend_magic_string ascend_magic[] = {
|
|
|
|
{ ASCEND_PFX_ISDN_X, "PRI-XMIT-" },
|
|
|
|
{ ASCEND_PFX_ISDN_R, "PRI-RCV-" },
|
|
|
|
{ ASCEND_PFX_WDS_X, "XMIT-" },
|
|
|
|
{ ASCEND_PFX_WDS_R, "RECV-" },
|
|
|
|
{ ASCEND_PFX_WDS_X, "XMIT:" },
|
|
|
|
{ ASCEND_PFX_WDS_R, "RECV:" },
|
|
|
|
{ ASCEND_PFX_WDS_X, "PPP-OUT" },
|
|
|
|
{ ASCEND_PFX_WDS_R, "PPP-IN" },
|
|
|
|
{ ASCEND_PFX_WDD, ASCEND_DATE },
|
|
|
|
{ ASCEND_PFX_WDD, "WD_DIALOUT_DISP:" },
|
|
|
|
{ ASCEND_PFX_ETHER, "ETHER" },
|
|
|
|
};
|
1999-09-11 04:53:26 +00:00
|
|
|
|
2014-05-23 10:50:02 +00:00
|
|
|
static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
|
2006-11-05 22:46:44 +00:00
|
|
|
gint64 *data_offset);
|
2014-05-23 10:50:02 +00:00
|
|
|
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
|
2014-05-09 05:18:49 +00:00
|
|
|
struct wtap_pkthdr *phdr, Buffer *buf,
|
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
|
|
|
int *err, gchar **err_info);
|
1999-09-11 06:49:42 +00:00
|
|
|
|
1999-09-11 04:53:26 +00:00
|
|
|
/* Seeks to the beginning of the next packet, and returns the
|
2005-02-05 17:39:12 +00:00
|
|
|
byte offset at which the header for that packet begins.
|
|
|
|
Returns -1 on failure. */
|
2014-05-09 05:18:49 +00:00
|
|
|
static gint64 ascend_seek(wtap *wth, int *err, gchar **err_info)
|
1999-09-11 04:53:26 +00:00
|
|
|
{
|
2006-07-04 18:27:07 +00:00
|
|
|
int byte;
|
2006-11-05 22:46:44 +00:00
|
|
|
gint64 date_off = -1, cur_off, packet_off;
|
2008-08-14 18:47:38 +00:00
|
|
|
size_t string_level[ASCEND_MAGIC_STRINGS];
|
2005-02-05 17:39:12 +00:00
|
|
|
guint string_i = 0, type = 0;
|
2007-01-14 06:13:07 +00:00
|
|
|
guint excessive_read_count = 262144;
|
2007-10-11 22:07:55 +00:00
|
|
|
|
2005-02-05 17:39:12 +00:00
|
|
|
memset(&string_level, 0, sizeof(string_level));
|
"wtap_loop()" no longer has problems with packet offsets of 0, so we
don't need to work around that.
The offset, for a given packet, at which "ascend_seek()" should start
searching for that packet's header must be computed separately from the
offset, for that packet, at which "ascend_seek()" should start searching
for the *next* packet - if the file is a "wdd" capture, and the packet
has a "Date:" header and a WD_DIALOUT_DISP header, the search for that
packet should start at the beginning of the "Date:" header, but the
search for the next packet should start after the WD_DIALOUT_DISP
header, as if we start it after the "Date:" header, the search will stop
at the packet's own WD_DIALOUT_DISP header, as a packet could have a
WD_DIALOUT_DISP header but no "Date:" header.
svn path=/trunk/; revision=2620
2000-11-12 08:45:28 +00:00
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
while (((byte = file_getc(wth->fh)) != EOF)) {
|
2007-01-14 06:13:07 +00:00
|
|
|
excessive_read_count--;
|
2008-05-22 15:46:27 +00:00
|
|
|
|
2007-01-14 06:13:07 +00:00
|
|
|
if (!excessive_read_count) {
|
2010-10-20 17:07:55 +00:00
|
|
|
*err = 0;
|
2007-01-14 06:13:07 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-10-11 22:07:55 +00:00
|
|
|
|
2005-02-05 17:39:12 +00:00
|
|
|
for (string_i = 0; string_i < ASCEND_MAGIC_STRINGS; string_i++) {
|
2005-07-22 07:55:51 +00:00
|
|
|
const gchar *strptr = ascend_magic[string_i].strptr;
|
2008-08-14 18:47:38 +00:00
|
|
|
size_t len = strlen(strptr);
|
2007-10-11 22:07:55 +00:00
|
|
|
|
2005-02-05 17:39:12 +00:00
|
|
|
if (byte == *(strptr + string_level[string_i])) {
|
|
|
|
string_level[string_i]++;
|
|
|
|
if (string_level[string_i] >= len) {
|
2014-05-09 05:18:49 +00:00
|
|
|
cur_off = file_tell(wth->fh);
|
2005-02-05 17:39:12 +00:00
|
|
|
if (cur_off == -1) {
|
|
|
|
/* Error. */
|
2014-05-09 05:18:49 +00:00
|
|
|
*err = file_error(wth->fh, err_info);
|
2005-02-05 17:39:12 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Date: header is a special case. Remember the offset,
|
|
|
|
but keep looking for other headers. */
|
2014-05-09 05:18:49 +00:00
|
|
|
if (strcmp(strptr, ASCEND_DATE) == 0) {
|
2005-02-05 17:39:12 +00:00
|
|
|
date_off = cur_off - len;
|
|
|
|
} else {
|
2008-05-22 15:46:27 +00:00
|
|
|
if (date_off == -1) {
|
2005-02-05 17:39:12 +00:00
|
|
|
/* Back up over the header we just read; that's where a read
|
|
|
|
of this packet should start. */
|
|
|
|
packet_off = cur_off - len;
|
|
|
|
} else {
|
|
|
|
/* This packet has a date/time header; a read of it should
|
|
|
|
start at the beginning of *that* header. */
|
|
|
|
packet_off = date_off;
|
|
|
|
}
|
|
|
|
|
|
|
|
type = ascend_magic[string_i].type;
|
|
|
|
goto found;
|
|
|
|
}
|
"wtap_loop()" no longer has problems with packet offsets of 0, so we
don't need to work around that.
The offset, for a given packet, at which "ascend_seek()" should start
searching for that packet's header must be computed separately from the
offset, for that packet, at which "ascend_seek()" should start searching
for the *next* packet - if the file is a "wdd" capture, and the packet
has a "Date:" header and a WD_DIALOUT_DISP header, the search for that
packet should start at the beginning of the "Date:" header, but the
search for the next packet should start after the WD_DIALOUT_DISP
header, as if we start it after the "Date:" header, the search will stop
at the packet's own WD_DIALOUT_DISP header, as a packet could have a
WD_DIALOUT_DISP header but no "Date:" header.
svn path=/trunk/; revision=2620
2000-11-12 08:45:28 +00:00
|
|
|
}
|
2005-02-05 17:39:12 +00:00
|
|
|
} else {
|
|
|
|
string_level[string_i] = 0;
|
1999-09-11 04:53:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-02-05 17:39:12 +00:00
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
*err = file_error(wth->fh, err_info);
|
1999-09-11 04:53:26 +00:00
|
|
|
return -1;
|
"wtap_loop()" no longer has problems with packet offsets of 0, so we
don't need to work around that.
The offset, for a given packet, at which "ascend_seek()" should start
searching for that packet's header must be computed separately from the
offset, for that packet, at which "ascend_seek()" should start searching
for the *next* packet - if the file is a "wdd" capture, and the packet
has a "Date:" header and a WD_DIALOUT_DISP header, the search for that
packet should start at the beginning of the "Date:" header, but the
search for the next packet should start after the WD_DIALOUT_DISP
header, as if we start it after the "Date:" header, the search will stop
at the packet's own WD_DIALOUT_DISP header, as a packet could have a
WD_DIALOUT_DISP header but no "Date:" header.
svn path=/trunk/; revision=2620
2000-11-12 08:45:28 +00:00
|
|
|
|
|
|
|
found:
|
|
|
|
/*
|
|
|
|
* Move to where the read for this packet should start, and return
|
|
|
|
* that seek offset.
|
|
|
|
*/
|
2014-05-09 05:18:49 +00:00
|
|
|
if (file_seek(wth->fh, packet_off, SEEK_SET, err) == -1)
|
2002-03-04 00:25:35 +00:00
|
|
|
return -1;
|
2005-02-05 17:39:12 +00:00
|
|
|
|
2012-10-16 21:50:57 +00:00
|
|
|
wth->phdr.pseudo_header.ascend.type = type;
|
2005-02-05 17:39:12 +00:00
|
|
|
|
"wtap_loop()" no longer has problems with packet offsets of 0, so we
don't need to work around that.
The offset, for a given packet, at which "ascend_seek()" should start
searching for that packet's header must be computed separately from the
offset, for that packet, at which "ascend_seek()" should start searching
for the *next* packet - if the file is a "wdd" capture, and the packet
has a "Date:" header and a WD_DIALOUT_DISP header, the search for that
packet should start at the beginning of the "Date:" header, but the
search for the next packet should start after the WD_DIALOUT_DISP
header, as if we start it after the "Date:" header, the search will stop
at the packet's own WD_DIALOUT_DISP header, as a packet could have a
WD_DIALOUT_DISP header but no "Date:" header.
svn path=/trunk/; revision=2620
2000-11-12 08:45:28 +00:00
|
|
|
return packet_off;
|
1999-09-11 04:53:26 +00:00
|
|
|
}
|
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
int ascend_open(wtap *wth, int *err, gchar **err_info)
|
1999-09-11 04:53:26 +00:00
|
|
|
{
|
2006-11-05 22:46:44 +00:00
|
|
|
gint64 offset;
|
2011-05-09 08:12:26 +00:00
|
|
|
ws_statb64 statbuf;
|
2010-02-26 07:59:54 +00:00
|
|
|
ascend_t *ascend;
|
1999-09-11 04:53:26 +00:00
|
|
|
|
"wtap_loop()" no longer has problems with packet offsets of 0, so we
don't need to work around that.
The offset, for a given packet, at which "ascend_seek()" should start
searching for that packet's header must be computed separately from the
offset, for that packet, at which "ascend_seek()" should start searching
for the *next* packet - if the file is a "wdd" capture, and the packet
has a "Date:" header and a WD_DIALOUT_DISP header, the search for that
packet should start at the beginning of the "Date:" header, but the
search for the next packet should start after the WD_DIALOUT_DISP
header, as if we start it after the "Date:" header, the search will stop
at the packet's own WD_DIALOUT_DISP header, as a packet could have a
WD_DIALOUT_DISP header but no "Date:" header.
svn path=/trunk/; revision=2620
2000-11-12 08:45:28 +00:00
|
|
|
/* 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. */
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->priv = NULL;
|
"wtap_loop()" no longer has problems with packet offsets of 0, so we
don't need to work around that.
The offset, for a given packet, at which "ascend_seek()" should start
searching for that packet's header must be computed separately from the
offset, for that packet, at which "ascend_seek()" should start searching
for the *next* packet - if the file is a "wdd" capture, and the packet
has a "Date:" header and a WD_DIALOUT_DISP header, the search for that
packet should start at the beginning of the "Date:" header, but the
search for the next packet should start after the WD_DIALOUT_DISP
header, as if we start it after the "Date:" header, the search will stop
at the packet's own WD_DIALOUT_DISP header, as a packet could have a
WD_DIALOUT_DISP header but no "Date:" header.
svn path=/trunk/; revision=2620
2000-11-12 08:45:28 +00:00
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
offset = ascend_seek(wth, err, err_info);
|
"wtap_loop()" no longer has problems with packet offsets of 0, so we
don't need to work around that.
The offset, for a given packet, at which "ascend_seek()" should start
searching for that packet's header must be computed separately from the
offset, for that packet, at which "ascend_seek()" should start searching
for the *next* packet - if the file is a "wdd" capture, and the packet
has a "Date:" header and a WD_DIALOUT_DISP header, the search for that
packet should start at the beginning of the "Date:" header, but the
search for the next packet should start after the WD_DIALOUT_DISP
header, as if we start it after the "Date:" header, the search will stop
at the packet's own WD_DIALOUT_DISP header, as a packet could have a
WD_DIALOUT_DISP header but no "Date:" header.
svn path=/trunk/; revision=2620
2000-11-12 08:45:28 +00:00
|
|
|
if (offset == -1) {
|
Do not call wtap_file_read_unknown_bytes() or
wtap_file_read_expected_bytes() from an open routine - open routines are
supposed to return -1 on error, 0 if the file doesn't appear to be a
file of the specified type, or 1 if the file does appear to be a file of
the specified type, but those macros will cause the caller to return
FALSE on errors (so that, even if there's an I/O error, it reports "the
file isn't a file of the specified type" rather than "we got an error
trying to read the file").
When doing reads in an open routine before we've concluded that the file
is probably of the right type, return 0, rather than -1, if we get
WTAP_ERR_SHORT_READ - if we don't have enough data to check whether a
file is of a given type, we should keep trying other types, not give up.
For reads done *after* we've concluded the file is probably of the right
type, if a read doesn't return the number of bytes we asked for, but
returns an error of 0, return WTAP_ERR_SHORT_READ - the file is
apparently cut short.
For NetMon and NetXRay/Windows Sniffer files, use a #define for the
magic number size, and use that for both magic numbers.
svn path=/trunk/; revision=46803
2012-12-27 12:19:25 +00:00
|
|
|
if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
|
2002-03-04 00:25:35 +00:00
|
|
|
return -1;
|
Do not call wtap_file_read_unknown_bytes() or
wtap_file_read_expected_bytes() from an open routine - open routines are
supposed to return -1 on error, 0 if the file doesn't appear to be a
file of the specified type, or 1 if the file does appear to be a file of
the specified type, but those macros will cause the caller to return
FALSE on errors (so that, even if there's an I/O error, it reports "the
file isn't a file of the specified type" rather than "we got an error
trying to read the file").
When doing reads in an open routine before we've concluded that the file
is probably of the right type, return 0, rather than -1, if we get
WTAP_ERR_SHORT_READ - if we don't have enough data to check whether a
file is of a given type, we should keep trying other types, not give up.
For reads done *after* we've concluded the file is probably of the right
type, if a read doesn't return the number of bytes we asked for, but
returns an error of 0, return WTAP_ERR_SHORT_READ - the file is
apparently cut short.
For NetMon and NetXRay/Windows Sniffer files, use a #define for the
magic number size, and use that for both magic numbers.
svn path=/trunk/; revision=46803
2012-12-27 12:19:25 +00:00
|
|
|
return 0;
|
1999-09-11 04:53:26 +00:00
|
|
|
}
|
|
|
|
|
2007-10-11 22:07:55 +00:00
|
|
|
/* Do a trial parse of the first packet just found to see if we might really have an Ascend file */
|
|
|
|
init_parse_ascend();
|
2014-05-09 05:18:49 +00:00
|
|
|
if (!check_ascend(wth->fh, &wth->phdr)) {
|
2007-10-11 22:07:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_ASCEND;
|
2005-02-05 17:39:12 +00:00
|
|
|
|
2012-10-16 21:50:57 +00:00
|
|
|
switch(wth->phdr.pseudo_header.ascend.type) {
|
2005-02-05 17:39:12 +00:00
|
|
|
case ASCEND_PFX_ISDN_X:
|
|
|
|
case ASCEND_PFX_ISDN_R:
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->file_encap = WTAP_ENCAP_ISDN;
|
2005-02-05 17:39:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ASCEND_PFX_ETHER:
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->file_encap = WTAP_ENCAP_ETHERNET;
|
2005-02-05 17:39:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->file_encap = WTAP_ENCAP_ASCEND;
|
2005-02-05 17:39:12 +00:00
|
|
|
}
|
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->snapshot_length = ASCEND_MAX_PKT_LEN;
|
|
|
|
wth->subtype_read = ascend_read;
|
|
|
|
wth->subtype_seek_read = ascend_seek_read;
|
2010-02-26 07:59:54 +00:00
|
|
|
ascend = (ascend_t *)g_malloc(sizeof(ascend_t));
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->priv = (void *)ascend;
|
1999-09-11 04:53:26 +00:00
|
|
|
|
"wtap_loop()" no longer has problems with packet offsets of 0, so we
don't need to work around that.
The offset, for a given packet, at which "ascend_seek()" should start
searching for that packet's header must be computed separately from the
offset, for that packet, at which "ascend_seek()" should start searching
for the *next* packet - if the file is a "wdd" capture, and the packet
has a "Date:" header and a WD_DIALOUT_DISP header, the search for that
packet should start at the beginning of the "Date:" header, but the
search for the next packet should start after the WD_DIALOUT_DISP
header, as if we start it after the "Date:" header, the search will stop
at the packet's own WD_DIALOUT_DISP header, as a packet could have a
WD_DIALOUT_DISP header but no "Date:" header.
svn path=/trunk/; revision=2620
2000-11-12 08:45:28 +00:00
|
|
|
/* 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
|
|
|
|
found it. */
|
2010-02-26 07:59:54 +00:00
|
|
|
ascend->next_packet_seek_start = offset;
|
"wtap_loop()" no longer has problems with packet offsets of 0, so we
don't need to work around that.
The offset, for a given packet, at which "ascend_seek()" should start
searching for that packet's header must be computed separately from the
offset, for that packet, at which "ascend_seek()" should start searching
for the *next* packet - if the file is a "wdd" capture, and the packet
has a "Date:" header and a WD_DIALOUT_DISP header, the search for that
packet should start at the beginning of the "Date:" header, but the
search for the next packet should start after the WD_DIALOUT_DISP
header, as if we start it after the "Date:" header, the search will stop
at the packet's own WD_DIALOUT_DISP header, as a packet could have a
WD_DIALOUT_DISP header but no "Date:" header.
svn path=/trunk/; revision=2620
2000-11-12 08:45:28 +00:00
|
|
|
|
2002-08-28 20:30:45 +00:00
|
|
|
/* MAXen and Pipelines report the time since reboot. In order to keep
|
1999-09-11 22:36:38 +00:00
|
|
|
from reporting packet times near the epoch, we subtract the first
|
|
|
|
packet's timestamp from the capture file's ctime, which gives us an
|
|
|
|
offset that we can apply to each packet.
|
|
|
|
*/
|
2014-05-09 05:18:49 +00:00
|
|
|
if (wtap_fstat(wth, &statbuf, err) == -1) {
|
2002-03-04 00:25:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2010-02-26 07:59:54 +00:00
|
|
|
ascend->inittime = statbuf.st_ctime;
|
2013-05-16 21:04:41 +00:00
|
|
|
ascend->adjusted = FALSE;
|
2014-05-09 05:18:49 +00:00
|
|
|
wth->tsprecision = WTAP_FILE_TSPREC_USEC;
|
1999-09-11 04:53:26 +00:00
|
|
|
|
|
|
|
init_parse_ascend();
|
1999-09-11 22:36:38 +00:00
|
|
|
|
1999-09-11 04:53:26 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-04-03 11:00:49 +00:00
|
|
|
/* Read the next packet; called from wtap_read(). */
|
2014-05-09 05:18:49 +00:00
|
|
|
static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
|
2006-11-05 22:46:44 +00:00
|
|
|
gint64 *data_offset)
|
1999-09-11 04:53:26 +00:00
|
|
|
{
|
2014-05-09 05:18:49 +00:00
|
|
|
ascend_t *ascend = (ascend_t *)wth->priv;
|
2006-11-05 22:46:44 +00:00
|
|
|
gint64 offset;
|
1999-09-11 04:53:26 +00:00
|
|
|
|
2005-02-05 17:39:12 +00:00
|
|
|
/* 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. */
|
2014-05-09 05:18:49 +00:00
|
|
|
if (file_seek(wth->fh, ascend->next_packet_seek_start,
|
2002-06-07 07:27:35 +00:00
|
|
|
SEEK_SET, err) == -1)
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2005-02-05 17:39:12 +00:00
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
offset = ascend_seek(wth, err, err_info);
|
2013-05-16 21:04:41 +00:00
|
|
|
if (offset == -1)
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2014-05-09 05:18:49 +00:00
|
|
|
if (parse_ascend(ascend, wth->fh, &wth->phdr, wth->frame_buffer,
|
|
|
|
wth->snapshot_length) != PARSED_RECORD) {
|
2011-12-13 09:53:50 +00:00
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
|
|
|
*err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
1999-09-11 04:53:26 +00:00
|
|
|
}
|
|
|
|
|
2000-09-07 05:34:23 +00:00
|
|
|
*data_offset = offset;
|
2014-05-23 10:50:02 +00:00
|
|
|
return TRUE;
|
1999-09-11 04:53:26 +00:00
|
|
|
}
|
|
|
|
|
2014-05-23 10:50:02 +00:00
|
|
|
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
|
2014-05-09 05:18:49 +00:00
|
|
|
struct wtap_pkthdr *phdr, Buffer *buf,
|
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
|
|
|
int *err, gchar **err_info)
|
1999-09-11 04:53:26 +00:00
|
|
|
{
|
2014-05-09 05:18:49 +00:00
|
|
|
ascend_t *ascend = (ascend_t *)wth->priv;
|
2005-02-05 17:39:12 +00:00
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2014-05-09 05:18:49 +00:00
|
|
|
if (parse_ascend(ascend, wth->random_fh, phdr, buf,
|
|
|
|
wth->snapshot_length) != PARSED_RECORD) {
|
2011-12-13 09:53:50 +00:00
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
Have the Wiretap open, read, and seek-and-read routines return, in
addition to an error code, an error info string, for
WTAP_ERR_UNSUPPORTED, WTAP_ERR_UNSUPPORTED_ENCAP, and
WTAP_ERR_BAD_RECORD errors. Replace the error messages logged with
"g_message()" for those errors with g_strdup()ed or g_strdup_printf()ed
strings returned as the error info string, and change the callers of
those routines to, for those errors, put the info string into the
printed message or alert box for the error.
Add messages for cases where those errors were returned without printing
an additional message.
Nobody uses the error code from "cf_read()" - "cf_read()" puts up the
alert box itself for failures; get rid of the error code, so it just
returns a success/failure indication.
Rename "file_read_error_message()" to "cf_read_error_message()", as it
handles read errors from Wiretap, and have it take an error info string
as an argument. (That handles a lot of the work of putting the info
string into the error message.)
Make some variables in "ascend-grammar.y" static.
Check the return value of "erf_read_header()" in "erf_seek_read()".
Get rid of an unused #define in "i4btrace.c".
svn path=/trunk/; revision=9852
2004-01-25 21:55:17 +00:00
|
|
|
*err_info = g_strdup((ascend_parse_error != NULL) ? ascend_parse_error : "parse error");
|
2014-05-23 10:50:02 +00:00
|
|
|
return FALSE;
|
2002-03-05 05:58:41 +00:00
|
|
|
}
|
2005-02-05 17:39:12 +00:00
|
|
|
|
2014-05-23 10:50:02 +00:00
|
|
|
return TRUE;
|
1999-09-11 04:53:26 +00:00
|
|
|
}
|