1998-11-12 06:01:27 +00:00
|
|
|
/* lanalyzer.c
|
|
|
|
*
|
|
|
|
* Wiretap Library
|
2001-11-13 23:55:44 +00:00
|
|
|
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
|
2002-06-27 22:46:48 +00:00
|
|
|
*
|
2018-02-07 11:26:45 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
1998-11-12 06:01:27 +00:00
|
|
|
*/
|
2002-03-04 00:25:35 +00:00
|
|
|
|
1999-07-13 02:53:26 +00:00
|
|
|
#include "config.h"
|
1998-11-15 05:29:17 +00:00
|
|
|
#include <stdlib.h>
|
Have the per-capture-file-type open routines "wtap_open_offline()" calls
return 1 on success, -1 if they got an error, and 0 if the file isn't of
the type that file is checking for, and supply an error code if they
return -1; have "wtap_open_offline()" use that error code. Also, have
the per-capture-file-type open routines treat errors accessing the file
as errors, and return -1, rather than just returning 0 so that we try
another file type.
Have the per-capture-file-type read routines "wtap_loop()" calls return
-1 and supply an error code on error (and not, as they did in some
cases, call "g_error()" and abort), and have "wtap_loop()", if the read
routine returned an error, return FALSE (and pass an error-code-pointer
argument onto the read routines, so they fill it in), and return TRUE on
success.
Add some new error codes for them to return.
Now that "wtap_loop()" can return a success/failure indication and an
error code, in "read_cap_file()" put up a message box if we get an error
reading the file, and return the error code.
Handle the additional errors we can get when opening a capture file.
If the attempt to open a capture file succeeds, but the attempt to read
it fails, don't treat that as a complete failure - we may have managed
to read some of the capture file, and we should display what we managed
to read.
svn path=/trunk/; revision=516
1999-08-19 05:31:38 +00:00
|
|
|
#include <errno.h>
|
2000-05-19 23:07:04 +00:00
|
|
|
#include "wtap-int.h"
|
2000-01-13 07:09:20 +00:00
|
|
|
#include "file_wrappers.h"
|
1998-11-12 06:01:27 +00:00
|
|
|
#include "lanalyzer.h"
|
|
|
|
|
Have the per-capture-file-type open routines "wtap_open_offline()" calls
return 1 on success, -1 if they got an error, and 0 if the file isn't of
the type that file is checking for, and supply an error code if they
return -1; have "wtap_open_offline()" use that error code. Also, have
the per-capture-file-type open routines treat errors accessing the file
as errors, and return -1, rather than just returning 0 so that we try
another file type.
Have the per-capture-file-type read routines "wtap_loop()" calls return
-1 and supply an error code on error (and not, as they did in some
cases, call "g_error()" and abort), and have "wtap_loop()", if the read
routine returned an error, return FALSE (and pass an error-code-pointer
argument onto the read routines, so they fill it in), and return TRUE on
success.
Add some new error codes for them to return.
Now that "wtap_loop()" can return a success/failure indication and an
error code, in "read_cap_file()" put up a message box if we get an error
reading the file, and return the error code.
Handle the additional errors we can get when opening a capture file.
If the attempt to open a capture file succeeds, but the attempt to read
it fails, don't treat that as a complete failure - we may have managed
to read some of the capture file, and we should display what we managed
to read.
svn path=/trunk/; revision=516
1999-08-19 05:31:38 +00:00
|
|
|
/* The LANalyzer format is documented (at least in part) in Novell document
|
|
|
|
TID022037, which can be found at, among other places:
|
|
|
|
|
2019-07-28 04:20:27 +00:00
|
|
|
http://www.blacksheepnetworks.com/security/info/nw/lan/trace.txt
|
Have the per-capture-file-type open routines "wtap_open_offline()" calls
return 1 on success, -1 if they got an error, and 0 if the file isn't of
the type that file is checking for, and supply an error code if they
return -1; have "wtap_open_offline()" use that error code. Also, have
the per-capture-file-type open routines treat errors accessing the file
as errors, and return -1, rather than just returning 0 so that we try
another file type.
Have the per-capture-file-type read routines "wtap_loop()" calls return
-1 and supply an error code on error (and not, as they did in some
cases, call "g_error()" and abort), and have "wtap_loop()", if the read
routine returned an error, return FALSE (and pass an error-code-pointer
argument onto the read routines, so they fill it in), and return TRUE on
success.
Add some new error codes for them to return.
Now that "wtap_loop()" can return a success/failure indication and an
error code, in "read_cap_file()" put up a message box if we get an error
reading the file, and return the error code.
Handle the additional errors we can get when opening a capture file.
If the attempt to open a capture file succeeds, but the attempt to read
it fails, don't treat that as a complete failure - we may have managed
to read some of the capture file, and we should display what we managed
to read.
svn path=/trunk/; revision=516
1999-08-19 05:31:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-07-10 22:57:59 +00:00
|
|
|
/* Record header format */
|
|
|
|
|
|
|
|
typedef struct {
|
2015-02-13 17:05:26 +00:00
|
|
|
guint8 record_type[2];
|
|
|
|
guint8 record_length[2];
|
2011-07-10 22:57:59 +00:00
|
|
|
} LA_RecordHeader;
|
|
|
|
|
|
|
|
#define LA_RecordHeaderSize 4
|
|
|
|
|
|
|
|
/* Record type codes: */
|
|
|
|
|
|
|
|
#define RT_HeaderRegular 0x1001
|
|
|
|
#define RT_HeaderCyclic 0x1007
|
|
|
|
#define RT_RxChannelName 0x1006
|
|
|
|
#define RT_TxChannelName 0x100b
|
|
|
|
#define RT_FilterName 0x1032
|
|
|
|
#define RT_RxTemplateName 0x1035
|
|
|
|
#define RT_TxTemplateName 0x1036
|
|
|
|
#define RT_DisplayOptions 0x100a
|
|
|
|
#define RT_Summary 0x1002
|
|
|
|
#define RT_SubfileSummary 0x1003
|
|
|
|
#define RT_CyclicInformation 0x1009
|
|
|
|
#define RT_Index 0x1004
|
|
|
|
#define RT_PacketData 0x1005
|
|
|
|
|
|
|
|
#define LA_ProFileLimit (1024 * 1024 * 32)
|
|
|
|
|
|
|
|
typedef guint8 Eadr[6];
|
|
|
|
typedef guint16 TimeStamp[3]; /* 0.5 microseconds since start of trace */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* These records have only 2-byte alignment for 4-byte quantities,
|
|
|
|
* so the structures aren't necessarily valid; they're kept as comments
|
|
|
|
* for reference purposes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* typedef struct {
|
|
|
|
* guint8 day;
|
|
|
|
* guint8 mon;
|
|
|
|
* gint16 year;
|
|
|
|
* } Date;
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* typedef struct {
|
|
|
|
* guint8 second;
|
|
|
|
* guint8 minute;
|
|
|
|
* guint8 hour;
|
|
|
|
* guint8 day;
|
|
|
|
* gint16 reserved;
|
|
|
|
* } Time;
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RT_Summary:
|
|
|
|
*
|
|
|
|
* typedef struct {
|
|
|
|
* Date datcre;
|
|
|
|
* Date datclo;
|
|
|
|
* Time timeopn;
|
|
|
|
* Time timeclo;
|
|
|
|
* Eadr statadr;
|
|
|
|
* gint16 mxseqno;
|
|
|
|
* gint16 slcoff;
|
|
|
|
* gint16 mxslc;
|
|
|
|
* gint32 totpktt;
|
|
|
|
* gint32 statrg;
|
|
|
|
* gint32 stptrg;
|
|
|
|
* gint32 mxpkta[36];
|
|
|
|
* gint16 board_type;
|
|
|
|
* gint16 board_version;
|
|
|
|
* gint8 reserved[18];
|
|
|
|
* } Summary;
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SummarySize (18+22+(4*36)+6+6+6+4+4)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* typedef struct {
|
|
|
|
* gint16 rid;
|
|
|
|
* gint16 rlen;
|
|
|
|
* Summary s;
|
|
|
|
* } LA_SummaryRecord;
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define LA_SummaryRecordSize (SummarySize + 4)
|
|
|
|
|
Have the per-capture-file-type open routines "wtap_open_offline()" calls
return 1 on success, -1 if they got an error, and 0 if the file isn't of
the type that file is checking for, and supply an error code if they
return -1; have "wtap_open_offline()" use that error code. Also, have
the per-capture-file-type open routines treat errors accessing the file
as errors, and return -1, rather than just returning 0 so that we try
another file type.
Have the per-capture-file-type read routines "wtap_loop()" calls return
-1 and supply an error code on error (and not, as they did in some
cases, call "g_error()" and abort), and have "wtap_loop()", if the read
routine returned an error, return FALSE (and pass an error-code-pointer
argument onto the read routines, so they fill it in), and return TRUE on
success.
Add some new error codes for them to return.
Now that "wtap_loop()" can return a success/failure indication and an
error code, in "read_cap_file()" put up a message box if we get an error
reading the file, and return the error code.
Handle the additional errors we can get when opening a capture file.
If the attempt to open a capture file succeeds, but the attempt to read
it fails, don't treat that as a complete failure - we may have managed
to read some of the capture file, and we should display what we managed
to read.
svn path=/trunk/; revision=516
1999-08-19 05:31:38 +00:00
|
|
|
/* LANalyzer board types (which indicate the type of network on which
|
|
|
|
the capture was done). */
|
2015-02-13 17:05:26 +00:00
|
|
|
#define BOARD_325 226 /* LANalyzer 325 (Ethernet) */
|
|
|
|
#define BOARD_325TR 227 /* LANalyzer 325TR (Token-ring) */
|
Have the per-capture-file-type open routines "wtap_open_offline()" calls
return 1 on success, -1 if they got an error, and 0 if the file isn't of
the type that file is checking for, and supply an error code if they
return -1; have "wtap_open_offline()" use that error code. Also, have
the per-capture-file-type open routines treat errors accessing the file
as errors, and return -1, rather than just returning 0 so that we try
another file type.
Have the per-capture-file-type read routines "wtap_loop()" calls return
-1 and supply an error code on error (and not, as they did in some
cases, call "g_error()" and abort), and have "wtap_loop()", if the read
routine returned an error, return FALSE (and pass an error-code-pointer
argument onto the read routines, so they fill it in), and return TRUE on
success.
Add some new error codes for them to return.
Now that "wtap_loop()" can return a success/failure indication and an
error code, in "read_cap_file()" put up a message box if we get an error
reading the file, and return the error code.
Handle the additional errors we can get when opening a capture file.
If the attempt to open a capture file succeeds, but the attempt to read
it fails, don't treat that as a complete failure - we may have managed
to read some of the capture file, and we should display what we managed
to read.
svn path=/trunk/; revision=516
1999-08-19 05:31:38 +00:00
|
|
|
|
2002-06-27 22:46:48 +00:00
|
|
|
|
2011-07-10 22:57:59 +00:00
|
|
|
/*
|
|
|
|
* typedef struct {
|
|
|
|
* gint16 rid;
|
|
|
|
* gint16 rlen;
|
|
|
|
* gint16 seqno;
|
|
|
|
* gint32 totpktf;
|
|
|
|
* } LA_SubfileSummaryRecord;
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define LA_SubfileSummaryRecordSize 10
|
|
|
|
|
|
|
|
|
|
|
|
#define LA_IndexSize 500
|
|
|
|
|
|
|
|
/*
|
|
|
|
* typedef struct {
|
|
|
|
* gint16 rid;
|
|
|
|
* gint16 rlen;
|
|
|
|
* gint16 idxsp; = LA_IndexSize
|
|
|
|
* gint16 idxct;
|
|
|
|
* gint8 idxgranu;
|
|
|
|
* gint8 idxvd;
|
|
|
|
* gint32 trcidx[LA_IndexSize + 2]; +2 undocumented but used by La 2.2
|
|
|
|
* } LA_IndexRecord;
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define LA_IndexRecordSize (10 + 4 * (LA_IndexSize + 2))
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* typedef struct {
|
|
|
|
* guint16 rx_channels;
|
|
|
|
* guint16 rx_errors;
|
|
|
|
* gint16 rx_frm_len;
|
|
|
|
* gint16 rx_frm_sln;
|
|
|
|
* TimeStamp rx_time;
|
|
|
|
* guint32 pktno;
|
|
|
|
* gint16 prvlen;
|
|
|
|
* gint16 offset;
|
|
|
|
* gint16 tx_errs;
|
|
|
|
* gint16 rx_filters;
|
|
|
|
* gint8 unused[2];
|
|
|
|
* gint16 hwcolls;
|
|
|
|
* gint16 hwcollschans;
|
|
|
|
* Packetdata ....;
|
|
|
|
* } LA_PacketRecord;
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define LA_PacketRecordSize 32
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
gboolean init;
|
2015-02-28 02:23:14 +00:00
|
|
|
nstime_t start;
|
2011-07-10 22:57:59 +00:00
|
|
|
guint32 pkts;
|
|
|
|
int encap;
|
|
|
|
int lastlen;
|
|
|
|
} LA_TmpInfo;
|
|
|
|
|
2003-12-29 00:25:39 +00:00
|
|
|
static const guint8 LA_HeaderRegularFake[] = {
|
2002-06-27 22:46:48 +00:00
|
|
|
0x01,0x10,0x4c,0x00,0x01,0x05,0x54,0x72,0x61,0x63,0x65,0x20,0x44,0x69,0x73,0x70,
|
|
|
|
0x6c,0x61,0x79,0x20,0x54,0x72,0x61,0x63,0x65,0x20,0x46,0x69,0x6c,0x65,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
|
|
|
};
|
|
|
|
|
2003-12-29 00:25:39 +00:00
|
|
|
static const guint8 LA_RxChannelNameFake[] = {
|
|
|
|
0x06,0x10,0x80,0x00,0x43,0x68,0x61,0x6e ,0x6e,0x65,0x6c,0x31,0x00,0x43,0x68,0x61,
|
2002-06-27 22:46:48 +00:00
|
|
|
0x6e,0x6e,0x65,0x6c,0x32,0x00,0x43,0x68 ,0x61,0x6e,0x6e,0x65,0x6c,0x33,0x00,0x43,
|
|
|
|
0x68,0x61,0x6e,0x6e,0x65,0x6c,0x34,0x00 ,0x43,0x68,0x61,0x6e,0x6e,0x65,0x6c,0x35,
|
|
|
|
0x00,0x43,0x68,0x61,0x6e,0x6e,0x65,0x6c ,0x36,0x00,0x43,0x68,0x61,0x6e,0x6e,0x65,
|
|
|
|
0x6c,0x37,0x00,0x43,0x68,0x61,0x6e,0x6e ,0x65,0x6c,0x38,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00
|
|
|
|
};
|
|
|
|
|
2003-12-29 00:25:39 +00:00
|
|
|
static const guint8 LA_TxChannelNameFake[] = {
|
2002-06-27 22:46:48 +00:00
|
|
|
0x0b,0x10,0x36,0x00 ,0x54,0x72,0x61,0x6e,0x73,0x31,0x00,0x00,
|
|
|
|
0x00,0x54,0x72,0x61,0x6e,0x73,0x32,0x00 ,0x00,0x00,0x54,0x72,0x61,0x6e,0x73,0x33,
|
|
|
|
0x00,0x00,0x00,0x54,0x72,0x61,0x6e,0x73 ,0x34,0x00,0x00,0x00,0x54,0x72,0x61,0x6e,
|
|
|
|
0x73,0x35,0x00,0x00,0x00,0x54,0x72,0x61 ,0x6e,0x73,0x36,0x00,0x00,0x00
|
|
|
|
};
|
|
|
|
|
2003-12-29 00:25:39 +00:00
|
|
|
static const guint8 LA_RxTemplateNameFake[] = {
|
2002-06-27 22:46:48 +00:00
|
|
|
0x35,0x10,
|
2003-12-29 00:25:39 +00:00
|
|
|
0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
2002-06-27 22:46:48 +00:00
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00
|
|
|
|
};
|
|
|
|
|
2003-12-29 00:25:39 +00:00
|
|
|
static const guint8 LA_TxTemplateNameFake[] = {
|
2002-06-27 22:46:48 +00:00
|
|
|
0x36,0x10,0x36,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00
|
|
|
|
};
|
|
|
|
|
2003-12-29 00:25:39 +00:00
|
|
|
static const guint8 LA_DisplayOptionsFake[] = {
|
2002-06-27 22:46:48 +00:00
|
|
|
0x0a,0x10,0x0a,0x01,
|
|
|
|
0x00,0x00,0x01,0x00,0x01,0x02,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00
|
|
|
|
};
|
|
|
|
|
2003-12-29 00:25:39 +00:00
|
|
|
static const guint8 LA_CyclicInformationFake[] = {
|
2002-06-27 22:46:48 +00:00
|
|
|
0x09,0x10,0x1a,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
|
|
|
};
|
|
|
|
|
2013-03-17 09:20:13 +00:00
|
|
|
static const guint8 z64[64] = {
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
|
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
|
|
|
};
|
|
|
|
|
2010-02-24 07:21:17 +00:00
|
|
|
typedef struct {
|
2015-02-13 17:05:26 +00:00
|
|
|
time_t start;
|
2010-02-24 07:21:17 +00:00
|
|
|
} lanalyzer_t;
|
|
|
|
|
2019-04-05 01:56:27 +00:00
|
|
|
static gboolean lanalyzer_read(wtap *wth, wtap_rec *rec,
|
|
|
|
Buffer *buf, int *err, gchar **err_info, gint64 *data_offset);
|
2014-05-23 10:50:02 +00:00
|
|
|
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
|
2018-02-09 00:19:12 +00:00
|
|
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
|
2020-10-14 01:48:46 +00:00
|
|
|
static gboolean lanalyzer_dump_finish(wtap_dumper *wdh, int *err,
|
|
|
|
gchar **err_info);
|
Have the per-capture-file-type open routines "wtap_open_offline()" calls
return 1 on success, -1 if they got an error, and 0 if the file isn't of
the type that file is checking for, and supply an error code if they
return -1; have "wtap_open_offline()" use that error code. Also, have
the per-capture-file-type open routines treat errors accessing the file
as errors, and return -1, rather than just returning 0 so that we try
another file type.
Have the per-capture-file-type read routines "wtap_loop()" calls return
-1 and supply an error code on error (and not, as they did in some
cases, call "g_error()" and abort), and have "wtap_loop()", if the read
routine returned an error, return FALSE (and pass an error-code-pointer
argument onto the read routines, so they fill it in), and return TRUE on
success.
Add some new error codes for them to return.
Now that "wtap_loop()" can return a success/failure indication and an
error code, in "read_cap_file()" put up a message box if we get an error
reading the file, and return the error code.
Handle the additional errors we can get when opening a capture file.
If the attempt to open a capture file succeeds, but the attempt to read
it fails, don't treat that as a complete failure - we may have managed
to read some of the capture file, and we should display what we managed
to read.
svn path=/trunk/; revision=516
1999-08-19 05:31:38 +00:00
|
|
|
|
wiretap: register most built-in file types from its module.
Remove most of the built-in file types from the table in
wiretap/file_access.c and, instead, have the file types register
themselves, using wtap_register_file_type_subtypes().
This reduces the source code changes needed to add a new file type from
three (add the handler, add the file type to the table in file_access.c,
add a #define for the file type in wiretap/wtap.h) to one (add the
handler). (It also requires adding the handler's source file to
wiretap/CMakeLists.txt, but that's required in both cases.)
A few remain because the WTAP_FILE_TYPE_SUBTYPE_ #define is used
elsewhere; that needs to be fixed.
Fix the wiretap/CMakefile.txt file to scan k12text.l, as that now
contains a registration routine. In the process, avoid scanning files
that don't implement a file type and won't ever have a registration
routine.
Add a Lua routine to fetch the total number of file types; we use that
in some code to construct the wtap_filetypes table, which we need to do
in order to continue to have all the values that used to come from the
WTAP_FILE_TYPE_SUBTYPE_ types.
While we're at it, add modelines to a file that lacked them.
2021-02-14 08:34:10 +00:00
|
|
|
static int lanalyzer_file_type_subtype = -1;
|
|
|
|
|
|
|
|
void register_lanalyzer(void);
|
|
|
|
|
2014-10-09 23:44:15 +00:00
|
|
|
wtap_open_return_val lanalyzer_open(wtap *wth, int *err, gchar **err_info)
|
1998-11-12 06:01:27 +00:00
|
|
|
{
|
2015-01-02 00:45:22 +00:00
|
|
|
LA_RecordHeader rec_header;
|
|
|
|
char header_fixed[2];
|
|
|
|
char *comment;
|
2020-04-12 01:42:58 +00:00
|
|
|
gboolean found_summary;
|
2015-01-02 00:45:22 +00:00
|
|
|
char summary[210];
|
|
|
|
guint16 board_type, mxslc;
|
|
|
|
guint16 record_type, record_length;
|
|
|
|
guint8 cr_day, cr_month;
|
|
|
|
guint16 cr_year;
|
|
|
|
struct tm tm;
|
2020-04-12 01:42:58 +00:00
|
|
|
time_t start;
|
|
|
|
int file_encap;
|
2015-01-02 00:45:22 +00:00
|
|
|
lanalyzer_t *lanalyzer;
|
|
|
|
|
|
|
|
if (!wtap_read_bytes(wth->fh, &rec_header, LA_RecordHeaderSize,
|
|
|
|
err, err_info)) {
|
|
|
|
if (*err != WTAP_ERR_SHORT_READ)
|
|
|
|
return WTAP_OPEN_ERROR;
|
|
|
|
return WTAP_OPEN_NOT_MINE;
|
|
|
|
}
|
|
|
|
record_type = pletoh16(rec_header.record_type);
|
|
|
|
record_length = pletoh16(rec_header.record_length); /* make sure to do this for while() loop */
|
|
|
|
|
|
|
|
if (record_type != RT_HeaderRegular && record_type != RT_HeaderCyclic) {
|
|
|
|
return WTAP_OPEN_NOT_MINE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read the major and minor version numbers */
|
2020-04-12 21:55:52 +00:00
|
|
|
if (record_length < sizeof header_fixed) {
|
2015-01-02 00:45:22 +00:00
|
|
|
/*
|
|
|
|
* Not enough room for the major and minor version numbers.
|
|
|
|
* Just treat that as a "not a LANalyzer file" indication.
|
|
|
|
*/
|
|
|
|
return WTAP_OPEN_NOT_MINE;
|
|
|
|
}
|
|
|
|
if (!wtap_read_bytes(wth->fh, &header_fixed, sizeof header_fixed,
|
|
|
|
err, err_info)) {
|
|
|
|
if (*err != WTAP_ERR_SHORT_READ)
|
|
|
|
return WTAP_OPEN_ERROR;
|
|
|
|
return WTAP_OPEN_NOT_MINE;
|
|
|
|
}
|
|
|
|
record_length -= sizeof header_fixed;
|
|
|
|
|
|
|
|
if (record_length != 0) {
|
|
|
|
/* Read the rest of the record as a comment. */
|
|
|
|
comment = (char *)g_malloc(record_length + 1);
|
|
|
|
if (!wtap_read_bytes(wth->fh, comment, record_length,
|
|
|
|
err, err_info)) {
|
2016-05-20 02:28:43 +00:00
|
|
|
if (*err != WTAP_ERR_SHORT_READ) {
|
|
|
|
g_free(comment);
|
|
|
|
return WTAP_OPEN_ERROR;
|
|
|
|
}
|
|
|
|
g_free(comment);
|
2015-01-02 00:45:22 +00:00
|
|
|
return WTAP_OPEN_NOT_MINE;
|
|
|
|
}
|
2016-07-14 23:01:57 +00:00
|
|
|
wtap_block_add_string_option(g_array_index(wth->shb_hdrs, wtap_block_t, 0), OPT_COMMENT, comment, record_length);
|
2016-05-20 02:28:43 +00:00
|
|
|
g_free(comment);
|
2015-01-02 00:45:22 +00:00
|
|
|
}
|
|
|
|
|
2020-04-12 01:42:58 +00:00
|
|
|
/*
|
|
|
|
* Read records until we find the start of packets.
|
|
|
|
* The document cited above claims that the first 11 records are
|
|
|
|
* in a particular sequence of types, but at least one capture
|
|
|
|
* doesn't have all the types listed in the order listed.
|
|
|
|
*
|
2020-04-12 21:36:29 +00:00
|
|
|
* If we don't have a summary record, we don't know the link-layer
|
2020-04-12 01:42:58 +00:00
|
|
|
* header type, so we can't read the file.
|
|
|
|
*/
|
|
|
|
found_summary = FALSE;
|
2015-01-02 00:45:22 +00:00
|
|
|
while (1) {
|
|
|
|
if (!wtap_read_bytes_or_eof(wth->fh, &rec_header,
|
|
|
|
LA_RecordHeaderSize, err, err_info)) {
|
|
|
|
if (*err == 0) {
|
|
|
|
/*
|
|
|
|
* End of file and no packets;
|
|
|
|
* accept this file.
|
|
|
|
*/
|
2020-04-12 20:26:59 +00:00
|
|
|
break;
|
2015-01-02 00:45:22 +00:00
|
|
|
}
|
|
|
|
return WTAP_OPEN_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
record_type = pletoh16(rec_header.record_type);
|
|
|
|
record_length = pletoh16(rec_header.record_length);
|
|
|
|
|
2021-06-14 23:06:02 +00:00
|
|
|
/*ws_message("Record 0x%04X Length %d", record_type, record_length);*/
|
2015-01-02 00:45:22 +00:00
|
|
|
switch (record_type) {
|
|
|
|
/* Trace Summary Record */
|
|
|
|
case RT_Summary:
|
2020-04-12 21:55:52 +00:00
|
|
|
if (record_length < sizeof summary) {
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
2021-12-18 18:48:20 +00:00
|
|
|
*err_info = ws_strdup_printf("lanalyzer: summary record length %u is too short",
|
2020-04-12 21:55:52 +00:00
|
|
|
record_length);
|
|
|
|
return WTAP_OPEN_ERROR;
|
|
|
|
}
|
2015-01-02 00:45:22 +00:00
|
|
|
if (!wtap_read_bytes(wth->fh, summary,
|
|
|
|
sizeof summary, err, err_info))
|
|
|
|
return WTAP_OPEN_ERROR;
|
|
|
|
|
|
|
|
/* Assume that the date of the creation of the trace file
|
|
|
|
* is the same date of the trace. Lanalyzer doesn't
|
|
|
|
* store the creation date/time of the trace, but only of
|
|
|
|
* the file. Unless you traced at 11:55 PM and saved at 00:05
|
|
|
|
* AM, the assumption that trace.date == file.date is true.
|
|
|
|
*/
|
|
|
|
cr_day = summary[0];
|
|
|
|
cr_month = summary[1];
|
|
|
|
cr_year = pletoh16(&summary[2]);
|
2021-06-14 23:06:02 +00:00
|
|
|
/*ws_message("Day %d Month %d Year %d (%04X)", cr_day, cr_month,
|
2015-01-02 00:45:22 +00:00
|
|
|
cr_year, cr_year);*/
|
|
|
|
|
|
|
|
/* Get capture start time. I learned how to do
|
|
|
|
* this from Guy's code in ngsniffer.c
|
|
|
|
*/
|
|
|
|
tm.tm_year = cr_year - 1900;
|
|
|
|
tm.tm_mon = cr_month - 1;
|
|
|
|
tm.tm_mday = cr_day;
|
|
|
|
tm.tm_hour = 0;
|
|
|
|
tm.tm_min = 0;
|
|
|
|
tm.tm_sec = 0;
|
|
|
|
tm.tm_isdst = -1;
|
2020-04-12 01:42:58 +00:00
|
|
|
start = mktime(&tm);
|
2021-06-14 23:06:02 +00:00
|
|
|
/*ws_message("Day %d Month %d Year %d", tm.tm_mday,
|
2015-01-02 00:45:22 +00:00
|
|
|
tm.tm_mon, tm.tm_year);*/
|
|
|
|
mxslc = pletoh16(&summary[30]);
|
|
|
|
|
|
|
|
board_type = pletoh16(&summary[188]);
|
|
|
|
switch (board_type) {
|
|
|
|
case BOARD_325:
|
2020-04-12 01:42:58 +00:00
|
|
|
file_encap = WTAP_ENCAP_ETHERNET;
|
2015-01-02 00:45:22 +00:00
|
|
|
break;
|
|
|
|
case BOARD_325TR:
|
2020-04-12 01:42:58 +00:00
|
|
|
file_encap = WTAP_ENCAP_TOKEN_RING;
|
2015-01-02 00:45:22 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*err = WTAP_ERR_UNSUPPORTED;
|
2021-12-18 18:48:20 +00:00
|
|
|
*err_info = ws_strdup_printf("lanalyzer: board type %u unknown",
|
2015-02-13 17:05:26 +00:00
|
|
|
board_type);
|
2015-01-02 00:45:22 +00:00
|
|
|
return WTAP_OPEN_ERROR;
|
|
|
|
}
|
2020-04-12 01:42:58 +00:00
|
|
|
|
|
|
|
if (found_summary) {
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
2021-12-18 18:48:20 +00:00
|
|
|
*err_info = ws_strdup_printf("lanalyzer: file has more than one summary record");
|
2020-04-12 01:42:58 +00:00
|
|
|
return WTAP_OPEN_ERROR;
|
|
|
|
}
|
|
|
|
found_summary = TRUE;
|
2020-04-12 21:55:52 +00:00
|
|
|
|
|
|
|
/* Skip the rest of the record */
|
|
|
|
record_length -= sizeof summary;
|
|
|
|
if (record_length != 0) {
|
|
|
|
if (!wtap_read_bytes(wth->fh, NULL, record_length, err, err_info)) {
|
|
|
|
return WTAP_OPEN_ERROR;
|
|
|
|
}
|
|
|
|
}
|
2015-01-02 00:45:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Trace Packet Data Record */
|
|
|
|
case RT_PacketData:
|
|
|
|
/* Go back header number of bytes so that lanalyzer_read
|
|
|
|
* can read this header */
|
|
|
|
if (file_seek(wth->fh, -LA_RecordHeaderSize, SEEK_CUR, err) == -1) {
|
|
|
|
return WTAP_OPEN_ERROR;
|
|
|
|
}
|
2020-04-12 01:42:58 +00:00
|
|
|
goto done;
|
2015-01-02 00:45:22 +00:00
|
|
|
|
|
|
|
default:
|
2016-09-29 04:35:12 +00:00
|
|
|
/* Unknown record type - skip it */
|
|
|
|
if (!wtap_read_bytes(wth->fh, NULL, record_length, err, err_info)) {
|
2015-01-02 00:45:22 +00:00
|
|
|
return WTAP_OPEN_ERROR;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-04-12 01:42:58 +00:00
|
|
|
|
|
|
|
done:
|
|
|
|
if (!found_summary) {
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
2021-12-18 18:48:20 +00:00
|
|
|
*err_info = ws_strdup_printf("lanalyzer: file has no summary record");
|
2020-04-12 01:42:58 +00:00
|
|
|
return WTAP_OPEN_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we made it this far, then the file is a readable LANAlyzer file.
|
|
|
|
* Let's get some info from it. Note that we get wth->snapshot_length
|
|
|
|
* from a record later in the file. */
|
wiretap: register most built-in file types from its module.
Remove most of the built-in file types from the table in
wiretap/file_access.c and, instead, have the file types register
themselves, using wtap_register_file_type_subtypes().
This reduces the source code changes needed to add a new file type from
three (add the handler, add the file type to the table in file_access.c,
add a #define for the file type in wiretap/wtap.h) to one (add the
handler). (It also requires adding the handler's source file to
wiretap/CMakeLists.txt, but that's required in both cases.)
A few remain because the WTAP_FILE_TYPE_SUBTYPE_ #define is used
elsewhere; that needs to be fixed.
Fix the wiretap/CMakefile.txt file to scan k12text.l, as that now
contains a registration routine. In the process, avoid scanning files
that don't implement a file type and won't ever have a registration
routine.
Add a Lua routine to fetch the total number of file types; we use that
in some code to construct the wtap_filetypes table, which we need to do
in order to continue to have all the values that used to come from the
WTAP_FILE_TYPE_SUBTYPE_ types.
While we're at it, add modelines to a file that lacked them.
2021-02-14 08:34:10 +00:00
|
|
|
wth->file_type_subtype = lanalyzer_file_type_subtype;
|
2020-12-21 02:30:28 +00:00
|
|
|
lanalyzer = g_new(lanalyzer_t, 1);
|
2020-04-12 01:42:58 +00:00
|
|
|
lanalyzer->start = start;
|
|
|
|
wth->priv = (void *)lanalyzer;
|
|
|
|
wth->subtype_read = lanalyzer_read;
|
|
|
|
wth->subtype_seek_read = lanalyzer_seek_read;
|
|
|
|
wth->file_encap = file_encap;
|
|
|
|
wth->snapshot_length = mxslc;
|
|
|
|
wth->file_tsprec = WTAP_TSPREC_NSEC;
|
2020-07-29 08:30:54 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add an IDB; we don't know how many interfaces were involved,
|
|
|
|
* so we just say one interface, about which we only know
|
|
|
|
* the link-layer type, snapshot length, and time stamp
|
|
|
|
* resolution.
|
|
|
|
*/
|
|
|
|
wtap_add_generated_idb(wth);
|
|
|
|
|
2020-04-12 01:42:58 +00:00
|
|
|
return WTAP_OPEN_MINE;
|
1998-11-12 06:01:27 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 17:05:26 +00:00
|
|
|
#define DESCRIPTOR_LEN 32
|
Have the per-capture-file-type open routines "wtap_open_offline()" calls
return 1 on success, -1 if they got an error, and 0 if the file isn't of
the type that file is checking for, and supply an error code if they
return -1; have "wtap_open_offline()" use that error code. Also, have
the per-capture-file-type open routines treat errors accessing the file
as errors, and return -1, rather than just returning 0 so that we try
another file type.
Have the per-capture-file-type read routines "wtap_loop()" calls return
-1 and supply an error code on error (and not, as they did in some
cases, call "g_error()" and abort), and have "wtap_loop()", if the read
routine returned an error, return FALSE (and pass an error-code-pointer
argument onto the read routines, so they fill it in), and return TRUE on
success.
Add some new error codes for them to return.
Now that "wtap_loop()" can return a success/failure indication and an
error code, in "read_cap_file()" put up a message box if we get an error
reading the file, and return the error code.
Handle the additional errors we can get when opening a capture file.
If the attempt to open a capture file succeeds, but the attempt to read
it fails, don't treat that as a complete failure - we may have managed
to read some of the capture file, and we should display what we managed
to read.
svn path=/trunk/; revision=516
1999-08-19 05:31:38 +00:00
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
|
2018-02-09 00:19:12 +00:00
|
|
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
1998-11-12 06:01:27 +00:00
|
|
|
{
|
2015-02-13 17:05:26 +00:00
|
|
|
char LE_record_type[2];
|
|
|
|
char LE_record_length[2];
|
|
|
|
guint16 record_type, record_length;
|
|
|
|
int record_data_size;
|
|
|
|
int packet_size;
|
|
|
|
gchar descriptor[DESCRIPTOR_LEN];
|
|
|
|
lanalyzer_t *lanalyzer;
|
|
|
|
guint16 time_low, time_med, time_high, true_size;
|
|
|
|
guint64 t;
|
|
|
|
time_t tsecs;
|
2015-01-02 00:45:22 +00:00
|
|
|
|
|
|
|
/* read the record type and length. */
|
|
|
|
if (!wtap_read_bytes_or_eof(fh, LE_record_type, 2, err, err_info))
|
|
|
|
return FALSE;
|
|
|
|
if (!wtap_read_bytes(fh, LE_record_length, 2, err, err_info))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
record_type = pletoh16(LE_record_type);
|
|
|
|
record_length = pletoh16(LE_record_length);
|
|
|
|
|
|
|
|
/* Only Trace Packet Data Records should occur now that we're in
|
|
|
|
* the middle of reading packets. If any other record type exists
|
|
|
|
* after a Trace Packet Data Record, mark it as an error. */
|
|
|
|
if (record_type != RT_PacketData) {
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
2021-12-18 18:48:20 +00:00
|
|
|
*err_info = ws_strdup_printf("lanalyzer: record type %u seen after trace summary record",
|
2015-01-02 00:45:22 +00:00
|
|
|
record_type);
|
|
|
|
return FALSE;
|
|
|
|
}
|
1998-11-12 06:01:27 +00:00
|
|
|
|
2015-01-02 00:45:22 +00:00
|
|
|
if (record_length < DESCRIPTOR_LEN) {
|
|
|
|
/*
|
|
|
|
* Uh-oh, the record isn't big enough to even have a
|
|
|
|
* descriptor.
|
|
|
|
*/
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
2021-12-18 18:48:20 +00:00
|
|
|
*err_info = ws_strdup_printf("lanalyzer: file has a %u-byte record, too small to have even a packet descriptor",
|
2015-01-02 00:45:22 +00:00
|
|
|
record_length);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
record_data_size = record_length - DESCRIPTOR_LEN;
|
1998-11-12 06:01:27 +00:00
|
|
|
|
2015-01-02 00:45:22 +00:00
|
|
|
/* Read the descriptor data */
|
|
|
|
if (!wtap_read_bytes(fh, descriptor, DESCRIPTOR_LEN, err, err_info))
|
|
|
|
return FALSE;
|
1998-11-12 06:01:27 +00:00
|
|
|
|
2015-01-02 00:45:22 +00:00
|
|
|
true_size = pletoh16(&descriptor[4]);
|
|
|
|
packet_size = pletoh16(&descriptor[6]);
|
2016-04-30 02:04:17 +00:00
|
|
|
/*
|
|
|
|
* The maximum value of packet_size is 65535, which is less than
|
Allow bigger snapshot lengths for D-Bus captures.
Use WTAP_MAX_PACKET_SIZE_STANDARD, set to 256KB, for everything except
for D-Bus captures. Use WTAP_MAX_PACKET_SIZE_DBUS, set to 128MB, for
them, because that's the largest possible D-Bus message size. See
https://bugs.freedesktop.org/show_bug.cgi?id=100220
for an example of the problems caused by limiting the snapshot length to
256KB for D-Bus.
Have a snapshot length of 0 in a capture_file structure mean "there is
no snapshot length for the file"; we don't need the has_snap field in
that case, a value of 0 mean "no, we don't have a snapshot length".
In dumpcap, start out with a pipe buffer size of 2KB, and grow it as
necessary. When checking for a too-big packet from a pipe, check
against the appropriate maximum - 128MB for DLT_DBUS, 256KB for
everything else.
Change-Id: Ib2ce7a0cf37b971fbc0318024fd011e18add8b20
Reviewed-on: https://code.wireshark.org/review/21952
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-05 01:58:40 +00:00
|
|
|
* WTAP_MAX_PACKET_SIZE_STANDARD will ever be, so we don't need to check
|
2016-04-30 02:04:17 +00:00
|
|
|
* it.
|
|
|
|
*/
|
1998-11-12 06:01:27 +00:00
|
|
|
|
2015-01-02 00:45:22 +00:00
|
|
|
/*
|
2021-12-20 02:40:23 +00:00
|
|
|
* OK, is the frame data size greater than what's left of the
|
2015-01-02 00:45:22 +00:00
|
|
|
* record?
|
|
|
|
*/
|
|
|
|
if (packet_size > record_data_size) {
|
|
|
|
/*
|
|
|
|
* Yes - treat this as an error.
|
|
|
|
*/
|
|
|
|
*err = WTAP_ERR_BAD_FILE;
|
|
|
|
*err_info = g_strdup("lanalyzer: Record length is less than packet size");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-06-30 00:41:33 +00:00
|
|
|
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->rec_type = REC_TYPE_PACKET;
|
2021-08-30 02:12:13 +00:00
|
|
|
rec->block = wtap_block_create(WTAP_BLOCK_PACKET);
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
|
2012-02-25 23:24:34 +00:00
|
|
|
|
2015-01-02 00:45:22 +00:00
|
|
|
time_low = pletoh16(&descriptor[8]);
|
|
|
|
time_med = pletoh16(&descriptor[10]);
|
|
|
|
time_high = pletoh16(&descriptor[12]);
|
|
|
|
t = (((guint64)time_low) << 0) + (((guint64)time_med) << 16) +
|
2015-02-13 17:05:26 +00:00
|
|
|
(((guint64)time_high) << 32);
|
2015-01-02 00:45:22 +00:00
|
|
|
tsecs = (time_t) (t/2000000);
|
|
|
|
lanalyzer = (lanalyzer_t *)wth->priv;
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->ts.secs = tsecs + lanalyzer->start;
|
|
|
|
rec->ts.nsecs = ((guint32) (t - tsecs*2000000)) * 500;
|
2015-01-02 00:45:22 +00:00
|
|
|
|
|
|
|
if (true_size - 4 >= packet_size) {
|
|
|
|
/*
|
|
|
|
* It appears that the "true size" includes the FCS;
|
|
|
|
* make it reflect the non-FCS size (the "packet size"
|
|
|
|
* appears never to include the FCS, even if no slicing
|
|
|
|
* is done).
|
|
|
|
*/
|
|
|
|
true_size -= 4;
|
|
|
|
}
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->rec_header.packet_header.len = true_size;
|
|
|
|
rec->rec_header.packet_header.caplen = packet_size;
|
2015-01-02 00:45:22 +00:00
|
|
|
|
|
|
|
switch (wth->file_encap) {
|
|
|
|
|
|
|
|
case WTAP_ENCAP_ETHERNET:
|
|
|
|
/* We assume there's no FCS in this frame. */
|
2018-02-09 00:19:12 +00:00
|
|
|
rec->rec_header.packet_header.pseudo_header.eth.fcs_len = 0;
|
2015-01-02 00:45:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read the packet data */
|
|
|
|
return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
|
2003-10-01 07:11:49 +00:00
|
|
|
}
|
|
|
|
|
2013-05-18 00:08:43 +00:00
|
|
|
/* Read the next packet */
|
2019-04-05 01:56:27 +00:00
|
|
|
static gboolean lanalyzer_read(wtap *wth, wtap_rec *rec, Buffer *buf,
|
|
|
|
int *err, gchar **err_info, gint64 *data_offset)
|
2013-05-18 00:08:43 +00:00
|
|
|
{
|
2015-01-02 00:45:22 +00:00
|
|
|
*data_offset = file_tell(wth->fh);
|
2013-05-18 00:08:43 +00:00
|
|
|
|
2015-01-02 00:45:22 +00:00
|
|
|
/* Read the record */
|
2019-04-05 01:56:27 +00:00
|
|
|
return lanalyzer_read_trace_record(wth, wth->fh, rec, buf, err,
|
|
|
|
err_info);
|
2013-05-18 00:08:43 +00:00
|
|
|
}
|
|
|
|
|
2014-05-23 10:50:02 +00:00
|
|
|
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
|
2018-02-09 00:19:12 +00:00
|
|
|
wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
|
2003-10-01 07:11:49 +00:00
|
|
|
{
|
2015-01-02 00:45:22 +00:00
|
|
|
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
|
|
|
|
return FALSE;
|
2003-10-01 07:11:49 +00:00
|
|
|
|
2015-01-02 00:45:22 +00:00
|
|
|
/* Read the record */
|
2018-02-09 00:19:12 +00:00
|
|
|
if (!lanalyzer_read_trace_record(wth, wth->random_fh, rec, buf,
|
2015-01-02 00:45:22 +00:00
|
|
|
err, err_info)) {
|
|
|
|
if (*err == 0)
|
|
|
|
*err = WTAP_ERR_SHORT_READ;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
1998-11-12 06:01:27 +00:00
|
|
|
}
|
2000-03-22 07:06:59 +00:00
|
|
|
|
2002-06-27 22:46:48 +00:00
|
|
|
/*---------------------------------------------------
|
2010-06-06 22:19:30 +00:00
|
|
|
* Returns TRUE on success, FALSE on error
|
|
|
|
* Write "cnt" bytes of zero with error control
|
2002-06-27 22:46:48 +00:00
|
|
|
*---------------------------------------------------*/
|
2014-05-09 05:18:49 +00:00
|
|
|
static gboolean s0write(wtap_dumper *wdh, size_t cnt, int *err)
|
2002-06-27 22:46:48 +00:00
|
|
|
{
|
2015-01-02 00:45:22 +00:00
|
|
|
size_t snack;
|
2002-06-27 22:46:48 +00:00
|
|
|
|
2015-01-02 00:45:22 +00:00
|
|
|
while (cnt) {
|
|
|
|
snack = cnt > 64 ? 64 : cnt;
|
2010-06-06 22:19:30 +00:00
|
|
|
|
2015-01-02 00:45:22 +00:00
|
|
|
if (!wtap_dump_file_write(wdh, z64, snack, err))
|
|
|
|
return FALSE;
|
|
|
|
cnt -= snack;
|
|
|
|
}
|
|
|
|
return TRUE; /* ok */
|
2002-06-27 22:46:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------
|
2010-06-06 22:19:30 +00:00
|
|
|
* Returns TRUE on success, FALSE on error
|
2015-02-28 02:23:14 +00:00
|
|
|
* Write an 8-bit value
|
2002-06-27 22:46:48 +00:00
|
|
|
*---------------------------------------------------*/
|
2014-05-09 05:18:49 +00:00
|
|
|
static gboolean s8write(wtap_dumper *wdh, const guint8 s8, int *err)
|
2002-06-27 22:46:48 +00:00
|
|
|
{
|
2015-01-02 00:45:22 +00:00
|
|
|
return wtap_dump_file_write(wdh, &s8, 1, err);
|
2002-06-27 22:46:48 +00:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------
|
2010-06-06 22:19:30 +00:00
|
|
|
* Returns TRUE on success, FALSE on error
|
2015-02-28 02:23:14 +00:00
|
|
|
* Write a 16-bit value as little-endian
|
2002-06-27 22:46:48 +00:00
|
|
|
*---------------------------------------------------*/
|
2014-05-09 05:18:49 +00:00
|
|
|
static gboolean s16write(wtap_dumper *wdh, const guint16 s16, int *err)
|
2002-06-27 22:46:48 +00:00
|
|
|
{
|
2015-02-28 02:23:14 +00:00
|
|
|
guint16 s16_le = GUINT16_TO_LE(s16);
|
|
|
|
return wtap_dump_file_write(wdh, &s16_le, 2, err);
|
2002-06-27 22:46:48 +00:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------
|
2010-06-06 22:19:30 +00:00
|
|
|
* Returns TRUE on success, FALSE on error
|
2015-02-28 02:23:14 +00:00
|
|
|
* Write a 32-bit value as little-endian
|
2002-06-27 22:46:48 +00:00
|
|
|
*---------------------------------------------------*/
|
2014-05-09 05:18:49 +00:00
|
|
|
static gboolean s32write(wtap_dumper *wdh, const guint32 s32, int *err)
|
2002-06-27 22:46:48 +00:00
|
|
|
{
|
2015-02-28 02:23:14 +00:00
|
|
|
guint32 s32_le = GUINT32_TO_LE(s32);
|
|
|
|
return wtap_dump_file_write(wdh, &s32_le, 4, err);
|
2002-06-27 22:46:48 +00:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------
|
2015-02-28 02:23:14 +00:00
|
|
|
* Returns TRUE on success, FALSE on error
|
|
|
|
* Write a 48-bit value as little-endian
|
2002-06-27 22:46:48 +00:00
|
|
|
*---------------------------------------------------*/
|
2015-02-28 02:23:14 +00:00
|
|
|
static gboolean s48write(wtap_dumper *wdh, const guint64 s48, int *err)
|
2002-06-27 22:46:48 +00:00
|
|
|
{
|
2018-03-13 17:15:25 +00:00
|
|
|
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
2015-02-28 02:23:14 +00:00
|
|
|
guint16 s48_upper_le = GUINT16_SWAP_LE_BE((guint16) (s48 >> 32));
|
|
|
|
guint32 s48_lower_le = GUINT32_SWAP_LE_BE((guint32) (s48 & 0xFFFFFFFF));
|
|
|
|
#else
|
|
|
|
guint16 s48_upper_le = (guint16) (s48 >> 32);
|
|
|
|
guint32 s48_lower_le = (guint32) (s48 & 0xFFFFFFFF);
|
|
|
|
#endif
|
|
|
|
return wtap_dump_file_write(wdh, &s48_lower_le, 4, err) &&
|
|
|
|
wtap_dump_file_write(wdh, &s48_upper_le, 2, err);
|
2002-06-27 22:46:48 +00:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------
|
|
|
|
* Write a record for a packet to a dump file.
|
|
|
|
* Returns TRUE on success, FALSE on failure.
|
|
|
|
*---------------------------------------------------*/
|
2014-05-09 05:18:49 +00:00
|
|
|
static gboolean lanalyzer_dump(wtap_dumper *wdh,
|
2018-02-09 00:19:12 +00:00
|
|
|
const wtap_rec *rec,
|
2015-02-13 17:05:26 +00:00
|
|
|
const guint8 *pd, int *err, gchar **err_info _U_)
|
2002-06-27 22:46:48 +00:00
|
|
|
{
|
2015-02-28 02:23:14 +00:00
|
|
|
guint64 x;
|
2002-06-27 22:46:48 +00:00
|
|
|
int len;
|
|
|
|
|
2010-02-26 07:59:54 +00:00
|
|
|
LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->priv);
|
2015-02-28 02:23:14 +00:00
|
|
|
nstime_t td;
|
2018-02-09 00:19:12 +00:00
|
|
|
int thisSize = rec->rec_header.packet_header.caplen + LA_PacketRecordSize + LA_RecordHeaderSize;
|
2002-06-27 22:46:48 +00:00
|
|
|
|
2014-05-24 18:28:30 +00:00
|
|
|
/* We can only write packet records. */
|
2018-02-09 00:19:12 +00:00
|
|
|
if (rec->rec_type != REC_TYPE_PACKET) {
|
2014-12-18 00:31:49 +00:00
|
|
|
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
|
2014-05-24 18:28:30 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
Catch attempts to write multiple encapsulation types if unsupported.
If, in the process of opening the input file, we determine that it has
packets of more than one link-layer type, we can catch attempts to write
that file to a file of a format that doesn't support more than one
link-layer type at the time we try to open the output file.
If, however, we don't discover that the file has more than one
link-layer type until we've already created the output file - for
example, if we have a pcapng file with a new IDB, with a different
link-layer type from previous IDBs, after packet blocks for the earlier
interfces - we can't catch that until we try to write the packet.
Currently, that causes the packet's data to be written out as is, so the
output file claims it's of the file's link-layer type, causing programs
reading the file to misdissect the packet.
Report WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED on the write attempt
instead, and have a nicer error message for
WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED on a write.
Change-Id: Ic41f2e4367cfe5667eb30c88cc6d3bfe422462f6
Reviewed-on: https://code.wireshark.org/review/30617
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-11-14 03:38:12 +00:00
|
|
|
/*
|
|
|
|
* Make sure this packet doesn't have a link-layer type that
|
|
|
|
* differs from the one for the file.
|
|
|
|
*/
|
|
|
|
if (wdh->encap != rec->rec_header.packet_header.pkt_encap) {
|
|
|
|
*err = WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-06-27 22:46:48 +00:00
|
|
|
if (wdh->bytes_dumped + thisSize > LA_ProFileLimit) {
|
|
|
|
/* printf(" LA_ProFileLimit reached\n"); */
|
|
|
|
*err = EFBIG;
|
|
|
|
return FALSE; /* and don't forget the header */
|
|
|
|
}
|
|
|
|
|
2018-02-09 00:19:12 +00:00
|
|
|
len = rec->rec_header.packet_header.caplen + (rec->rec_header.packet_header.caplen ? LA_PacketRecordSize : 0);
|
2002-06-27 22:46:48 +00:00
|
|
|
|
2014-01-22 00:26:36 +00:00
|
|
|
/* len goes into a 16-bit field, so there's a hard limit of 65535. */
|
|
|
|
if (len > 65535) {
|
|
|
|
*err = WTAP_ERR_PACKET_TOO_LARGE;
|
|
|
|
return FALSE;
|
2014-05-24 18:28:30 +00:00
|
|
|
}
|
2014-01-22 00:26:36 +00:00
|
|
|
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, 0x1005, err))
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, (guint16)len, err))
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!itmp->init) {
|
|
|
|
/* collect some information for the
|
|
|
|
* finally written header
|
|
|
|
*/
|
2018-02-09 00:19:12 +00:00
|
|
|
itmp->start = rec->ts;
|
2002-06-27 22:46:48 +00:00
|
|
|
itmp->pkts = 0;
|
|
|
|
itmp->init = TRUE;
|
|
|
|
itmp->encap = wdh->encap;
|
|
|
|
itmp->lastlen = 0;
|
|
|
|
}
|
|
|
|
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, 0x0001, err)) /* pr.rx_channels */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, 0x0008, err)) /* pr.rx_errors */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2018-02-09 00:19:12 +00:00
|
|
|
if (!s16write(wdh, (guint16) (rec->rec_header.packet_header.len + 4), err)) /* pr.rx_frm_len */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2018-02-09 00:19:12 +00:00
|
|
|
if (!s16write(wdh, (guint16) rec->rec_header.packet_header.caplen, err)) /* pr.rx_frm_sln */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2018-02-09 00:19:12 +00:00
|
|
|
nstime_delta(&td, &rec->ts, &itmp->start);
|
2015-02-28 02:23:14 +00:00
|
|
|
|
|
|
|
/* Convert to half-microseconds, rounded up. */
|
|
|
|
x = (td.nsecs + 250) / 500; /* nanoseconds -> half-microseconds, rounded */
|
|
|
|
x += td.secs * 2000000; /* seconds -> half-microseconds */
|
|
|
|
|
|
|
|
if (!s48write(wdh, x, err)) /* pr.rx_time[i] */
|
|
|
|
return FALSE;
|
2002-06-27 22:46:48 +00:00
|
|
|
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s32write(wdh, ++itmp->pkts, err)) /* pr.pktno */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, (guint16)itmp->lastlen, err)) /* pr.prlen */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
|
|
|
itmp->lastlen = len;
|
|
|
|
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s0write(wdh, 12, err))
|
|
|
|
return FALSE;
|
2002-06-27 22:46:48 +00:00
|
|
|
|
2018-02-09 00:19:12 +00:00
|
|
|
if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err))
|
2010-06-06 22:19:30 +00:00
|
|
|
return FALSE;
|
2002-06-27 22:46:48 +00:00
|
|
|
|
|
|
|
wdh->bytes_dumped += thisSize;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------
|
|
|
|
* Returns 0 if we could write the specified encapsulation type,
|
|
|
|
* an error indication otherwise.
|
|
|
|
*---------------------------------------------------*/
|
2021-04-16 18:24:52 +00:00
|
|
|
static int lanalyzer_dump_can_write_encap(int encap)
|
2002-06-27 22:46:48 +00:00
|
|
|
{
|
|
|
|
/* Per-packet encapsulations aren't supported. */
|
|
|
|
if (encap == WTAP_ENCAP_PER_PACKET)
|
|
|
|
return WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED;
|
|
|
|
|
|
|
|
if ( encap != WTAP_ENCAP_ETHERNET
|
|
|
|
&& encap != WTAP_ENCAP_TOKEN_RING )
|
2014-12-17 06:40:45 +00:00
|
|
|
return WTAP_ERR_UNWRITABLE_ENCAP;
|
2002-06-27 22:46:48 +00:00
|
|
|
/*
|
|
|
|
* printf("lanalyzer_dump_can_write_encap(%d)\n",encap);
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------
|
|
|
|
* Returns TRUE on success, FALSE on failure; sets "*err" to an
|
|
|
|
* error code on failure
|
|
|
|
*---------------------------------------------------*/
|
2021-04-16 18:24:52 +00:00
|
|
|
static gboolean lanalyzer_dump_open(wtap_dumper *wdh, int *err, gchar **err_info _U_)
|
2002-06-27 22:46:48 +00:00
|
|
|
{
|
|
|
|
int jump;
|
|
|
|
void *tmp;
|
|
|
|
|
|
|
|
tmp = g_malloc(sizeof(LA_TmpInfo));
|
|
|
|
if (!tmp) {
|
2015-02-13 17:05:26 +00:00
|
|
|
*err = errno;
|
|
|
|
return FALSE;
|
2014-05-09 05:18:49 +00:00
|
|
|
}
|
2002-06-27 22:46:48 +00:00
|
|
|
|
|
|
|
((LA_TmpInfo*)tmp)->init = FALSE;
|
2015-11-09 19:54:18 +00:00
|
|
|
wdh->priv = tmp;
|
|
|
|
wdh->subtype_write = lanalyzer_dump;
|
|
|
|
wdh->subtype_finish = lanalyzer_dump_finish;
|
2002-06-27 22:46:48 +00:00
|
|
|
|
|
|
|
/* Some of the fields in the file header aren't known yet so
|
|
|
|
just skip over it for now. It will be created after all
|
|
|
|
of the packets have been written. */
|
|
|
|
|
|
|
|
jump = sizeof (LA_HeaderRegularFake)
|
|
|
|
+ sizeof (LA_RxChannelNameFake)
|
|
|
|
+ sizeof (LA_TxChannelNameFake)
|
|
|
|
+ sizeof (LA_RxTemplateNameFake)
|
|
|
|
+ sizeof (LA_TxTemplateNameFake)
|
|
|
|
+ sizeof (LA_DisplayOptionsFake)
|
|
|
|
+ LA_SummaryRecordSize
|
|
|
|
+ LA_SubfileSummaryRecordSize
|
|
|
|
+ sizeof (LA_CyclicInformationFake)
|
|
|
|
+ LA_IndexRecordSize;
|
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
if (wtap_dump_file_seek(wdh, jump, SEEK_SET, err) == -1)
|
2015-02-13 17:05:26 +00:00
|
|
|
return FALSE;
|
2013-03-17 09:20:13 +00:00
|
|
|
|
2002-06-27 22:46:48 +00:00
|
|
|
wdh->bytes_dumped = jump;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------
|
|
|
|
*
|
|
|
|
*---------------------------------------------------*/
|
2014-05-09 05:18:49 +00:00
|
|
|
static gboolean lanalyzer_dump_header(wtap_dumper *wdh, int *err)
|
2002-06-27 22:46:48 +00:00
|
|
|
{
|
2010-02-26 07:59:54 +00:00
|
|
|
LA_TmpInfo *itmp = (LA_TmpInfo*)(wdh->priv);
|
2002-06-27 22:46:48 +00:00
|
|
|
guint16 board_type = itmp->encap == WTAP_ENCAP_TOKEN_RING
|
|
|
|
? BOARD_325TR /* LANalyzer Board Type */
|
|
|
|
: BOARD_325; /* LANalyzer Board Type */
|
2011-02-25 00:40:22 +00:00
|
|
|
struct tm *fT;
|
|
|
|
|
2015-02-28 02:23:14 +00:00
|
|
|
fT = localtime(&itmp->start.secs);
|
2011-02-25 00:40:22 +00:00
|
|
|
if (fT == NULL)
|
|
|
|
return FALSE;
|
2002-06-27 22:46:48 +00:00
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
if (wtap_dump_file_seek(wdh, 0, SEEK_SET, err) == -1)
|
2015-02-13 17:05:26 +00:00
|
|
|
return FALSE;
|
2002-06-27 22:46:48 +00:00
|
|
|
|
2014-05-09 05:18:49 +00:00
|
|
|
if (!wtap_dump_file_write(wdh, &LA_HeaderRegularFake,
|
2010-06-06 22:19:30 +00:00
|
|
|
sizeof LA_HeaderRegularFake, err))
|
2015-02-13 17:05:26 +00:00
|
|
|
return FALSE;
|
2014-05-09 05:18:49 +00:00
|
|
|
if (!wtap_dump_file_write(wdh, &LA_RxChannelNameFake,
|
2010-06-06 22:19:30 +00:00
|
|
|
sizeof LA_RxChannelNameFake, err))
|
2015-02-13 17:05:26 +00:00
|
|
|
return FALSE;
|
2014-05-09 05:18:49 +00:00
|
|
|
if (!wtap_dump_file_write(wdh, &LA_TxChannelNameFake,
|
2010-06-06 22:19:30 +00:00
|
|
|
sizeof LA_TxChannelNameFake, err))
|
2015-02-13 17:05:26 +00:00
|
|
|
return FALSE;
|
2014-05-09 05:18:49 +00:00
|
|
|
if (!wtap_dump_file_write(wdh, &LA_RxTemplateNameFake,
|
2010-06-06 22:19:30 +00:00
|
|
|
sizeof LA_RxTemplateNameFake, err))
|
2015-02-13 17:05:26 +00:00
|
|
|
return FALSE;
|
2014-05-09 05:18:49 +00:00
|
|
|
if (!wtap_dump_file_write(wdh, &LA_TxTemplateNameFake,
|
2010-06-06 22:19:30 +00:00
|
|
|
sizeof LA_TxTemplateNameFake, err))
|
2015-02-13 17:05:26 +00:00
|
|
|
return FALSE;
|
2014-05-09 05:18:49 +00:00
|
|
|
if (!wtap_dump_file_write(wdh, &LA_DisplayOptionsFake,
|
2010-06-06 22:19:30 +00:00
|
|
|
sizeof LA_DisplayOptionsFake, err))
|
2015-02-13 17:05:26 +00:00
|
|
|
return FALSE;
|
2002-06-27 22:46:48 +00:00
|
|
|
/*-----------------------------------------------------------------*/
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, RT_Summary, err)) /* rid */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, SummarySize, err)) /* rlen */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s8write(wdh, (guint8) fT->tm_mday, err)) /* s.datcre.day */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s8write(wdh, (guint8) (fT->tm_mon+1), err)) /* s.datcre.mon */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, (guint16) (fT->tm_year + 1900), err)) /* s.datcre.year */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s8write(wdh, (guint8) fT->tm_mday, err)) /* s.datclo.day */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s8write(wdh, (guint8) (fT->tm_mon+1), err)) /* s.datclo.mon */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, (guint16) (fT->tm_year + 1900), err)) /* s.datclo.year */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s8write(wdh, (guint8) fT->tm_sec, err)) /* s.timeopn.second */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s8write(wdh, (guint8) fT->tm_min, err)) /* s.timeopn.minute */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s8write(wdh, (guint8) fT->tm_hour, err)) /* s.timeopn.hour */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s8write(wdh, (guint8) fT->tm_mday, err)) /* s.timeopn.mday */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s0write(wdh, 2, err))
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s8write(wdh, (guint8) fT->tm_sec, err)) /* s.timeclo.second */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s8write(wdh, (guint8) fT->tm_min, err)) /* s.timeclo.minute */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s8write(wdh, (guint8) fT->tm_hour, err)) /* s.timeclo.hour */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s8write(wdh, (guint8) fT->tm_mday, err)) /* s.timeclo.mday */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s0write(wdh, 2, err))
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s0write(wdh, 6, err)) /* EAddr == 0 */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, 1, err)) /* s.mxseqno */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, 0, err)) /* s.slcoffo */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, 1514, err)) /* s.mxslc */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s32write(wdh, itmp->pkts, err)) /* s.totpktt */
|
2010-06-06 22:19:30 +00:00
|
|
|
return FALSE;
|
|
|
|
/*
|
|
|
|
* statrg == 0; ? -1
|
|
|
|
* stptrg == 0; ? -1
|
|
|
|
* s.mxpkta[0]=0
|
|
|
|
*/
|
|
|
|
if (!s0write(wdh, 12, err))
|
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s32write(wdh, itmp->pkts, err)) /* sr.s.mxpkta[1] */
|
2010-06-06 22:19:30 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s0write(wdh, 34*4, err)) /* s.mxpkta[2-33]=0 */
|
2010-06-06 22:19:30 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, board_type, err))
|
2010-06-06 22:19:30 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s0write(wdh, 20, err)) /* board_version == 0 */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
|
|
|
/*-----------------------------------------------------------------*/
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, RT_SubfileSummary, err)) /* ssr.rid */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, LA_SubfileSummaryRecordSize-4, err)) /* ssr.rlen */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, 1, err)) /* ssr.seqno */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s32write(wdh, itmp->pkts, err)) /* ssr.totpkts */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
|
|
|
/*-----------------------------------------------------------------*/
|
2014-05-09 05:18:49 +00:00
|
|
|
if (!wtap_dump_file_write(wdh, &LA_CyclicInformationFake,
|
2010-06-06 22:19:30 +00:00
|
|
|
sizeof LA_CyclicInformationFake, err))
|
|
|
|
return FALSE;
|
2002-06-27 22:46:48 +00:00
|
|
|
/*-----------------------------------------------------------------*/
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, RT_Index, err)) /* rid */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, LA_IndexRecordSize -4, err)) /* rlen */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2015-02-28 02:23:14 +00:00
|
|
|
if (!s16write(wdh, LA_IndexSize, err)) /* idxsp */
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
2010-06-06 22:19:30 +00:00
|
|
|
if (!s0write(wdh, LA_IndexRecordSize - 6, err))
|
2002-06-27 22:46:48 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------------------------------------------
|
|
|
|
* Finish writing to a dump file.
|
|
|
|
* Returns TRUE on success, FALSE on failure.
|
|
|
|
*---------------------------------------------------*/
|
2020-10-14 01:48:46 +00:00
|
|
|
static gboolean lanalyzer_dump_finish(wtap_dumper *wdh, int *err,
|
|
|
|
gchar **err_info _U_)
|
2002-06-27 22:46:48 +00:00
|
|
|
{
|
2003-07-29 20:30:00 +00:00
|
|
|
lanalyzer_dump_header(wdh,err);
|
2002-06-27 22:46:48 +00:00
|
|
|
return *err ? FALSE : TRUE;
|
|
|
|
}
|
2015-01-02 00:45:22 +00:00
|
|
|
|
wiretap: have file handlers advertise blocks and options supported.
Instead of a "supports name resolution" Boolean and bitflags for types of
comments supported, provide a list of block types that the file
type/subtype supports, with each block type having a list of options
supported. Indicate whether "supported" means "one instance" or
"multiple instances".
"Supports" doesn't just mean "can be written", it also means "could be
read".
Rename WTAP_BLOCK_IF_DESCRIPTION to WTAP_BLOCK_IF_ID_AND_INFO, to
indicate that it provides, in addition to information about the
interface, an ID (implicitly, in pcapng files, by its ordinal number)
that is associated with every packet in the file. Emphasize that in
comments - just because your capture file format can list the interfaces
on which a capture was done, that doesn't mean it supports this; it
doesn't do so if the file doesn't indicate, for every packet, on which
of those interfaces it was captured (I'm looking at *you*, Microsoft
Network Monitor...).
Use APIs to query that information to do what the "does this file
type/subtype support name resolution information", "does this file
type/subtype support all of these comment types", and "does this file
type/subtype support - and require - interface IDs" APIs did.
Provide backwards compatibility for Lua.
This allows us to eliminate the WTAP_FILE_TYPE_SUBTYPE_ values for IBM's
iptrace; do so.
2021-02-21 22:18:04 +00:00
|
|
|
static const struct supported_block_type lanalyzer_blocks_supported[] = {
|
|
|
|
/*
|
|
|
|
* We support packet blocks, with no comments or other options.
|
|
|
|
*/
|
|
|
|
{ WTAP_BLOCK_PACKET, MULTIPLE_BLOCKS_SUPPORTED, NO_OPTIONS_SUPPORTED }
|
|
|
|
};
|
|
|
|
|
wiretap: register most built-in file types from its module.
Remove most of the built-in file types from the table in
wiretap/file_access.c and, instead, have the file types register
themselves, using wtap_register_file_type_subtypes().
This reduces the source code changes needed to add a new file type from
three (add the handler, add the file type to the table in file_access.c,
add a #define for the file type in wiretap/wtap.h) to one (add the
handler). (It also requires adding the handler's source file to
wiretap/CMakeLists.txt, but that's required in both cases.)
A few remain because the WTAP_FILE_TYPE_SUBTYPE_ #define is used
elsewhere; that needs to be fixed.
Fix the wiretap/CMakefile.txt file to scan k12text.l, as that now
contains a registration routine. In the process, avoid scanning files
that don't implement a file type and won't ever have a registration
routine.
Add a Lua routine to fetch the total number of file types; we use that
in some code to construct the wtap_filetypes table, which we need to do
in order to continue to have all the values that used to come from the
WTAP_FILE_TYPE_SUBTYPE_ types.
While we're at it, add modelines to a file that lacked them.
2021-02-14 08:34:10 +00:00
|
|
|
static const struct file_type_subtype_info lanalyzer_info = {
|
|
|
|
"Novell LANalyzer","lanalyzer", "tr1", NULL,
|
wiretap: have file handlers advertise blocks and options supported.
Instead of a "supports name resolution" Boolean and bitflags for types of
comments supported, provide a list of block types that the file
type/subtype supports, with each block type having a list of options
supported. Indicate whether "supported" means "one instance" or
"multiple instances".
"Supports" doesn't just mean "can be written", it also means "could be
read".
Rename WTAP_BLOCK_IF_DESCRIPTION to WTAP_BLOCK_IF_ID_AND_INFO, to
indicate that it provides, in addition to information about the
interface, an ID (implicitly, in pcapng files, by its ordinal number)
that is associated with every packet in the file. Emphasize that in
comments - just because your capture file format can list the interfaces
on which a capture was done, that doesn't mean it supports this; it
doesn't do so if the file doesn't indicate, for every packet, on which
of those interfaces it was captured (I'm looking at *you*, Microsoft
Network Monitor...).
Use APIs to query that information to do what the "does this file
type/subtype support name resolution information", "does this file
type/subtype support all of these comment types", and "does this file
type/subtype support - and require - interface IDs" APIs did.
Provide backwards compatibility for Lua.
This allows us to eliminate the WTAP_FILE_TYPE_SUBTYPE_ values for IBM's
iptrace; do so.
2021-02-21 22:18:04 +00:00
|
|
|
TRUE, BLOCKS_SUPPORTED(lanalyzer_blocks_supported),
|
wiretap: register most built-in file types from its module.
Remove most of the built-in file types from the table in
wiretap/file_access.c and, instead, have the file types register
themselves, using wtap_register_file_type_subtypes().
This reduces the source code changes needed to add a new file type from
three (add the handler, add the file type to the table in file_access.c,
add a #define for the file type in wiretap/wtap.h) to one (add the
handler). (It also requires adding the handler's source file to
wiretap/CMakeLists.txt, but that's required in both cases.)
A few remain because the WTAP_FILE_TYPE_SUBTYPE_ #define is used
elsewhere; that needs to be fixed.
Fix the wiretap/CMakefile.txt file to scan k12text.l, as that now
contains a registration routine. In the process, avoid scanning files
that don't implement a file type and won't ever have a registration
routine.
Add a Lua routine to fetch the total number of file types; we use that
in some code to construct the wtap_filetypes table, which we need to do
in order to continue to have all the values that used to come from the
WTAP_FILE_TYPE_SUBTYPE_ types.
While we're at it, add modelines to a file that lacked them.
2021-02-14 08:34:10 +00:00
|
|
|
lanalyzer_dump_can_write_encap, lanalyzer_dump_open, NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
void register_lanalyzer(void)
|
|
|
|
{
|
2021-02-24 03:10:35 +00:00
|
|
|
lanalyzer_file_type_subtype = wtap_register_file_type_subtype(&lanalyzer_info);
|
wiretap: more work on file type/subtypes.
Provide a wiretap routine to get an array of all savable file
type/subtypes, sorted with pcap and pcapng at the top, followed by the
other types, sorted either by the name or the description.
Use that routine to list options for the -F flag for various commands
Rename wtap_get_savable_file_types_subtypes() to
wtap_get_savable_file_types_subtypes_for_file(), to indicate that it
provides an array of all file type/subtypes in which a given file can be
saved. Have it sort all types, other than the default type/subtype and,
if there is one, the "other" type (both of which are put at the top), by
the name or the description.
Don't allow wtap_register_file_type_subtypes() to override any existing
registrations; have them always register a new type. In that routine,
if there are any emply slots in the table, due to an entry being
unregistered, use it rather than allocating a new slot.
Don't allow unregistration of built-in types.
Rename the "dump open table" to the "file type/subtype table", as it has
entries for all types/subtypes, even if we can't write them.
Initialize that table in a routine that pre-allocates the GArray before
filling it with built-in types/subtypes, so it doesn't keep getting
reallocated.
Get rid of wtap_num_file_types_subtypes - it's just a copy of the size
of the GArray.
Don't have wtap_file_type_subtype_description() crash if handed an
file type/subtype that isn't a valid array index - just return NULL, as
we do with wtap_file_type_subtype_name().
In wtap_name_to_file_type_subtype(), don't use WTAP_FILE_TYPE_SUBTYPE_
names for the backwards-compatibility names - map those names to the
current names, and then look them up. This reduces the number of
uses of hardwired WTAP_FILE_TYPE_SUBTYPE_ values.
Clean up the type of wtap_module_count - it has no need to be a gulong.
Have built-in wiretap file handlers register names to be used for their
file type/subtypes, rather than building the table in init.lua.
Add a new Lua C function get_wtap_filetypes() to construct the
wtap_filetypes table, based on the registered names, and use it in
init.lua.
Add a #define WSLUA_INTERNAL_FUNCTION to register functions intended
only for internal use in init.lua, so they can be made available from
Lua without being documented.
Get rid of WTAP_NUM_FILE_TYPES_SUBTYPES - most code has no need to use
it, as it can just request arrays of types, and the space of
type/subtype codes can be sparse due to registration in any case, so
code has to be careful using it.
wtap_get_num_file_types_subtypes() is no longer used, so remove it. It
returns the number of elements in the file type/subtype array, which is
not necessarily the name of known file type/subtypes, as there may have
been some deregistered types, and those types do *not* get removed from
the array, they just get cleared so that they're available for future
allocation (we don't want the indices of any registered types to changes
if another type is deregistered, as those indicates are the type/subtype
values, so we can't shrink the array).
Clean up white space and remove some comments that shouldn't have been
added.
2021-02-17 06:24:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Register name for backwards compatibility with the
|
|
|
|
* wtap_filetypes table in Lua.
|
|
|
|
*/
|
|
|
|
wtap_register_backwards_compatibility_lua_name("LANALYZER",
|
|
|
|
lanalyzer_file_type_subtype);
|
wiretap: register most built-in file types from its module.
Remove most of the built-in file types from the table in
wiretap/file_access.c and, instead, have the file types register
themselves, using wtap_register_file_type_subtypes().
This reduces the source code changes needed to add a new file type from
three (add the handler, add the file type to the table in file_access.c,
add a #define for the file type in wiretap/wtap.h) to one (add the
handler). (It also requires adding the handler's source file to
wiretap/CMakeLists.txt, but that's required in both cases.)
A few remain because the WTAP_FILE_TYPE_SUBTYPE_ #define is used
elsewhere; that needs to be fixed.
Fix the wiretap/CMakefile.txt file to scan k12text.l, as that now
contains a registration routine. In the process, avoid scanning files
that don't implement a file type and won't ever have a registration
routine.
Add a Lua routine to fetch the total number of file types; we use that
in some code to construct the wtap_filetypes table, which we need to do
in order to continue to have all the values that used to come from the
WTAP_FILE_TYPE_SUBTYPE_ types.
While we're at it, add modelines to a file that lacked them.
2021-02-14 08:34:10 +00:00
|
|
|
}
|
|
|
|
|
2015-01-02 00:45:22 +00:00
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2015-01-02 00:45:22 +00:00
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 6
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=6 tabstop=8 expandtab:
|
|
|
|
* :indentSize=6:tabSize=8:noTabs=true:
|
|
|
|
*/
|