aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2015-01-01 19:45:22 -0500
committerBill Meier <wmeier@newsguy.com>2015-01-02 00:49:09 +0000
commit454fd6e9eb3009cd346443ba06498904d6cea228 (patch)
treed7b5e3e699e0992a0d767b7017fbac44a0531069
parent887cce4a5f4a03a74899d8f7388550aeaed7edc5 (diff)
Add "Editor modelines"; Adjust whitespace as needed.
Change-Id: Ic5a5acb0f36d3aa144edbfb1ae71097b18426db4 Reviewed-on: https://code.wireshark.org/review/6216 Reviewed-by: Bill Meier <wmeier@newsguy.com>
-rw-r--r--epan/afn.c81
-rw-r--r--epan/print_stream.c13
-rw-r--r--wiretap/5views.c13
-rw-r--r--wiretap/aethra.c13
-rw-r--r--wiretap/ascendtext.c55
-rw-r--r--wiretap/atm.c13
-rw-r--r--wiretap/ber.c41
-rw-r--r--wiretap/btsnoop.c325
-rw-r--r--wiretap/capsa.c13
-rw-r--r--wiretap/catapult_dct2000.c13
-rw-r--r--wiretap/commview.c13
-rw-r--r--wiretap/cosine.c13
-rw-r--r--wiretap/csids.c27
-rw-r--r--wiretap/daintree-sna.c13
-rw-r--r--wiretap/dbs-etherwatch.c837
-rw-r--r--wiretap/dct3trace.c13
-rw-r--r--wiretap/erf.c13
-rw-r--r--wiretap/erf.h13
-rw-r--r--wiretap/eyesdn.c37
-rw-r--r--wiretap/file_access.c15
-rw-r--r--wiretap/hcidump.c13
-rw-r--r--wiretap/i4btrace.c13
-rw-r--r--wiretap/ipfix.c13
-rw-r--r--wiretap/iptrace.c13
-rw-r--r--wiretap/k12.c83
-rw-r--r--wiretap/lanalyzer.c549
-rw-r--r--wiretap/libpcap.c45
-rw-r--r--wiretap/merge.c13
-rw-r--r--wiretap/mime_file.c13
-rw-r--r--wiretap/mp2t.c15
-rw-r--r--wiretap/mpeg.c13
-rw-r--r--wiretap/netmon.c13
-rw-r--r--wiretap/netscaler.c13
-rw-r--r--wiretap/netscreen.c47
-rw-r--r--wiretap/nettl.c417
-rw-r--r--wiretap/network_instruments.c13
-rw-r--r--wiretap/ngsniffer.c13
-rw-r--r--wiretap/packetlogger.c13
-rw-r--r--wiretap/pcap-common.c275
-rw-r--r--wiretap/peekclassic.c13
-rw-r--r--wiretap/peektagged.c765
-rw-r--r--wiretap/pppdump.c13
-rw-r--r--wiretap/radcom.c13
-rw-r--r--wiretap/snoop.c13
-rw-r--r--wiretap/stanag4607.c13
-rw-r--r--wiretap/tnef.c15
-rw-r--r--wiretap/toshiba.c61
-rw-r--r--wiretap/visual.c31
-rw-r--r--wiretap/vms.c217
-rw-r--r--wiretap/wtap.c13
50 files changed, 2489 insertions, 1839 deletions
diff --git a/epan/afn.c b/epan/afn.c
index 13049871c3..e1a70d17e1 100644
--- a/epan/afn.c
+++ b/epan/afn.c
@@ -26,40 +26,53 @@
#include <epan/afn.h>
const value_string afn_vals[] = {
- { AFNUM_RESERVED, "Reserved" },
- { AFNUM_INET, "IPv4" },
- { AFNUM_INET6, "IPv6" },
- { AFNUM_NSAP, "NSAP" },
- { AFNUM_HDLC, "HDLC (8-bit multidrop)" },
- { AFNUM_BBN1822, "BBN 1822" },
- { AFNUM_802, "802 (includes all 802 media plus Ethernet)" },
- { AFNUM_E163, "E.163" },
- { AFNUM_E164, "E.164 (SMDS, Frame Relay, ATM)" },
- { AFNUM_F69, "F.69 (Telex)" },
- { AFNUM_X121, "X.121 (X.25, Frame Relay)" },
- { AFNUM_IPX, "IPX" },
- { AFNUM_ATALK, "Appletalk" },
- { AFNUM_DECNET, "Decnet IV" },
- { AFNUM_BANYAN, "Banyan Vines" },
- { AFNUM_E164NSAP, "E.164 with NSAP subaddress" },
- { AFNUM_DNS, "DNS (Domain Name System)" },
- { AFNUM_DISTNAME, "Distinguished Name" },
- { AFNUM_AS_NUMBER, "AS Number" },
- { AFNUM_XTP_IP4, "XTP over IP version 4" },
- { AFNUM_XTP_IP6, "XTP over IP version 6" },
- { AFNUM_XTP, "XTP native mode XTP" },
- { AFNUM_FC_WWPN, "Fibre Channel World-Wide Port Name" },
- { AFNUM_FC_WWNN, "Fibre Channel World-Wide Node Name" },
- { AFNUM_GWID, "GWID" },
- { AFNUM_L2VPN, "Layer-2 VPN" },
- { AFNUM_L2VPN_OLD, "Layer-2 VPN (old)" },
+ { AFNUM_RESERVED, "Reserved" },
+ { AFNUM_INET, "IPv4" },
+ { AFNUM_INET6, "IPv6" },
+ { AFNUM_NSAP, "NSAP" },
+ { AFNUM_HDLC, "HDLC (8-bit multidrop)" },
+ { AFNUM_BBN1822, "BBN 1822" },
+ { AFNUM_802, "802 (includes all 802 media plus Ethernet)" },
+ { AFNUM_E163, "E.163" },
+ { AFNUM_E164, "E.164 (SMDS, Frame Relay, ATM)" },
+ { AFNUM_F69, "F.69 (Telex)" },
+ { AFNUM_X121, "X.121 (X.25, Frame Relay)" },
+ { AFNUM_IPX, "IPX" },
+ { AFNUM_ATALK, "Appletalk" },
+ { AFNUM_DECNET, "Decnet IV" },
+ { AFNUM_BANYAN, "Banyan Vines" },
+ { AFNUM_E164NSAP, "E.164 with NSAP subaddress" },
+ { AFNUM_DNS, "DNS (Domain Name System)" },
+ { AFNUM_DISTNAME, "Distinguished Name" },
+ { AFNUM_AS_NUMBER, "AS Number" },
+ { AFNUM_XTP_IP4, "XTP over IP version 4" },
+ { AFNUM_XTP_IP6, "XTP over IP version 6" },
+ { AFNUM_XTP, "XTP native mode XTP" },
+ { AFNUM_FC_WWPN, "Fibre Channel World-Wide Port Name" },
+ { AFNUM_FC_WWNN, "Fibre Channel World-Wide Node Name" },
+ { AFNUM_GWID, "GWID" },
+ { AFNUM_L2VPN, "Layer-2 VPN" },
+ { AFNUM_L2VPN_OLD, "Layer-2 VPN (old)" },
{ AFNUM_EIGRP_COMMON, "EIGRP Common Service Family" },
- { AFNUM_EIGRP_IPV4, "EIGRP IPv4 Service Family" },
- { AFNUM_EIGRP_IPV6, "EIGRP IPv6 Service Family" },
- { AFNUM_LCAF, "LISP Canonical Address Format (LCAF)" },
- { AFNUM_LINK_STATE, "Link State and TE information" },
- { AFNUM_EUI48, "48-bit MAC Address" },
- { AFNUM_EUI64, "64-bit MAC Address" },
- { 65535, "Reserved" },
+ { AFNUM_EIGRP_IPV4, "EIGRP IPv4 Service Family" },
+ { AFNUM_EIGRP_IPV6, "EIGRP IPv6 Service Family" },
+ { AFNUM_LCAF, "LISP Canonical Address Format (LCAF)" },
+ { AFNUM_LINK_STATE, "Link State and TE information" },
+ { AFNUM_EUI48, "48-bit MAC Address" },
+ { AFNUM_EUI64, "64-bit MAC Address" },
+ { 65535, "Reserved" },
{ 0, NULL },
};
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/epan/print_stream.c b/epan/print_stream.c
index 5be569510d..f53965c75b 100644
--- a/epan/print_stream.c
+++ b/epan/print_stream.c
@@ -365,3 +365,16 @@ print_stream_ps_stdio_new(FILE *fh)
{
return print_stream_ps_alloc(TRUE, fh);
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/5views.c b/wiretap/5views.c
index 287181f1a4..05a1865b80 100644
--- a/wiretap/5views.c
+++ b/wiretap/5views.c
@@ -445,3 +445,16 @@ static gboolean _5views_dump_close(wtap_dumper *wdh, int *err)
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/aethra.c b/wiretap/aethra.c
index 09e4b90025..5a9e909d16 100644
--- a/wiretap/aethra.c
+++ b/wiretap/aethra.c
@@ -326,3 +326,16 @@ aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/ascendtext.c b/wiretap/ascendtext.c
index d35e44df29..c54bdb23dc 100644
--- a/wiretap/ascendtext.c
+++ b/wiretap/ascendtext.c
@@ -39,10 +39,10 @@
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)
+ * pridisplay traces primary rate ISDN
+ * ether-display traces Ethernet packets (dangerous! CPU intensive)
* wanopening, wandisplay, wannext, wandsess
- traces PPP or other WAN connections
+ traces PPP or other WAN connections
Please see ascend.y for examples.
@@ -55,29 +55,29 @@ typedef struct _ascend_magic_string {
const gchar *strptr;
} ascend_magic_string;
-#define ASCEND_MAGIC_STRINGS 11
-#define ASCEND_DATE "Date:"
+#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_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" },
+ { ASCEND_PFX_WDD, ASCEND_DATE },
+ { ASCEND_PFX_WDD, "WD_DIALOUT_DISP:" },
+ { ASCEND_PFX_ETHER, "ETHER" },
};
static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+ gint64 *data_offset);
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr, Buffer *buf,
- int *err, gchar **err_info);
+ struct wtap_pkthdr *phdr, Buffer *buf,
+ int *err, gchar **err_info);
/* Seeks to the beginning of the next packet, and returns the
byte offset at which the header for that packet begins.
@@ -116,7 +116,7 @@ static gint64 ascend_seek(wtap *wth, int *err, gchar **err_info)
/* Date: header is a special case. Remember the offset,
but keep looking for other headers. */
- if (strcmp(strptr, ASCEND_DATE) == 0) {
+ if (strcmp(strptr, ASCEND_DATE) == 0) {
date_off = cur_off - len;
} else {
if (date_off == -1) {
@@ -225,7 +225,7 @@ wtap_open_return_val ascend_open(wtap *wth, int *err, gchar **err_info)
/* Read the next packet; called from wtap_read(). */
static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+ gint64 *data_offset)
{
ascend_t *ascend = (ascend_t *)wth->priv;
gint64 offset;
@@ -253,8 +253,8 @@ static gboolean ascend_read(wtap *wth, int *err, gchar **err_info,
}
static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr, Buffer *buf,
- int *err, gchar **err_info)
+ struct wtap_pkthdr *phdr, Buffer *buf,
+ int *err, gchar **err_info)
{
ascend_t *ascend = (ascend_t *)wth->priv;
@@ -269,3 +269,16 @@ static gboolean ascend_seek_read(wtap *wth, gint64 seek_off,
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local Variables:
+ * c-basic-offset: 2
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=2 tabstop=8 expandtab:
+ * :indentSize=2:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/atm.c b/wiretap/atm.c
index dbf768167c..83789e9c22 100644
--- a/wiretap/atm.c
+++ b/wiretap/atm.c
@@ -131,3 +131,16 @@ atm_guess_lane_type(struct wtap_pkthdr *phdr, const guint8 *pd)
}
}
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/ber.c b/wiretap/ber.c
index 74e87d7dbd..c147f543fc 100644
--- a/wiretap/ber.c
+++ b/wiretap/ber.c
@@ -31,12 +31,12 @@
#include "ber.h"
-#define BER_CLASS_UNI 0
-#define BER_CLASS_APP 1
-#define BER_CLASS_CON 2
+#define BER_CLASS_UNI 0
+#define BER_CLASS_APP 1
+#define BER_CLASS_CON 2
-#define BER_UNI_TAG_SEQ 16 /* SEQUENCE, SEQUENCE OF */
-#define BER_UNI_TAG_SET 17 /* SET, SET OF */
+#define BER_UNI_TAG_SEQ 16 /* SEQUENCE, SEQUENCE OF */
+#define BER_UNI_TAG_SET 17 /* SET, SET OF */
static gboolean ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
Buffer *buf, int *err, gchar **err_info)
@@ -54,7 +54,7 @@ static gboolean ber_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
*/
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("ber: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u",
- file_size, WTAP_MAX_PACKET_SIZE);
+ file_size, WTAP_MAX_PACKET_SIZE);
return FALSE;
}
packet_size = (int)file_size;
@@ -89,7 +89,7 @@ static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off
}
static gboolean ber_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr _U_,
- Buffer *buf, int *err, gchar **err_info)
+ Buffer *buf, int *err, gchar **err_info)
{
/* there is only one packet */
if(seek_off > 0) {
@@ -133,7 +133,7 @@ wtap_open_return_val ber_open(wtap *wth, int *err, gchar **err_info)
/* XXX: do we also want to allow APPLICATION */
if(!(ber_pc &&
(((ber_class == BER_CLASS_UNI) && ((ber_tag == BER_UNI_TAG_SET) || (ber_tag == BER_UNI_TAG_SEQ))) ||
- ((ber_class == BER_CLASS_CON) && (ber_tag < 32)))))
+ ((ber_class == BER_CLASS_CON) && (ber_tag < 32)))))
return WTAP_OPEN_NOT_MINE;
/* now check the length */
@@ -149,12 +149,12 @@ wtap_open_return_val ber_open(wtap *wth, int *err, gchar **err_info)
nlb = oct & 0x7F; /* number of length bytes */
if((nlb > 0) && (nlb <= (BER_BYTES_TO_CHECK - 2))) {
- /* not indefinite length and we have read enough bytes to compute the length */
- i = nlb;
- while(i--) {
- oct = bytes[offset++];
- len = (len<<8) + oct;
- }
+ /* not indefinite length and we have read enough bytes to compute the length */
+ i = nlb;
+ while(i--) {
+ oct = bytes[offset++];
+ len = (len<<8) + oct;
+ }
}
}
@@ -182,3 +182,16 @@ wtap_open_return_val ber_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local Variables:
+ * c-basic-offset: 2
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=2 tabstop=8 expandtab:
+ * :indentSize=2:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/btsnoop.c b/wiretap/btsnoop.c
index 98e151d9cd..9d026e4c64 100644
--- a/wiretap/btsnoop.c
+++ b/wiretap/btsnoop.c
@@ -34,42 +34,42 @@
/* Magic number in "btsnoop" files. */
static const char btsnoop_magic[] = {
- 'b', 't', 's', 'n', 'o', 'o', 'p', '\0'
+ 'b', 't', 's', 'n', 'o', 'o', 'p', '\0'
};
/* "btsnoop" file header (minus magic number). */
struct btsnoop_hdr {
- guint32 version; /* version number (should be 1) */
- guint32 datalink; /* datalink type */
+ guint32 version; /* version number (should be 1) */
+ guint32 datalink; /* datalink type */
};
/* "btsnoop" record header. */
struct btsnooprec_hdr {
- guint32 orig_len; /* actual length of packet */
- guint32 incl_len; /* number of octets captured in file */
- guint32 flags; /* packet flags */
- guint32 cum_drops; /* cumulative number of dropped packets */
- gint64 ts_usec; /* timestamp microseconds */
+ guint32 orig_len; /* actual length of packet */
+ guint32 incl_len; /* number of octets captured in file */
+ guint32 flags; /* packet flags */
+ guint32 cum_drops; /* cumulative number of dropped packets */
+ gint64 ts_usec; /* timestamp microseconds */
};
/* H1 is unframed data with the packet type encoded in the flags field of capture header */
/* It can be used for any datalink by placing logging above the datalink layer of HCI */
-#define KHciLoggerDatalinkTypeH1 1001
+#define KHciLoggerDatalinkTypeH1 1001
/* H4 is the serial HCI with packet type encoded in the first byte of each packet */
-#define KHciLoggerDatalinkTypeH4 1002
+#define KHciLoggerDatalinkTypeH4 1002
/* CSR's PPP derived bluecore serial protocol - in practice we log in H1 format after deframing */
-#define KHciLoggerDatalinkTypeBCSP 1003
+#define KHciLoggerDatalinkTypeBCSP 1003
/* H5 is the official three wire serial protocol derived from BCSP*/
-#define KHciLoggerDatalinkTypeH5 1004
+#define KHciLoggerDatalinkTypeH5 1004
/* Linux Monitor */
-#define KHciLoggerDatalinkLinuxMonitor 2001
+#define KHciLoggerDatalinkLinuxMonitor 2001
/* BlueZ 5 Simulator */
-#define KHciLoggerDatalinkBlueZ5Simulator 2002
+#define KHciLoggerDatalinkBlueZ5Simulator 2002
-#define KHciLoggerHostToController 0
-#define KHciLoggerControllerToHost 0x00000001
-#define KHciLoggerACLDataFrame 0
-#define KHciLoggerCommandOrEvent 0x00000002
+#define KHciLoggerHostToController 0
+#define KHciLoggerControllerToHost 0x00000001
+#define KHciLoggerACLDataFrame 0
+#define KHciLoggerCommandOrEvent 0x00000002
static const gint64 KUnixTimeBase = G_GINT64_CONSTANT(0x00dcddb30f2f8000); /* offset from symbian - unix time */
@@ -82,158 +82,158 @@ static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
wtap_open_return_val btsnoop_open(wtap *wth, int *err, gchar **err_info)
{
- char magic[sizeof btsnoop_magic];
- struct btsnoop_hdr hdr;
-
- int file_encap=WTAP_ENCAP_UNKNOWN;
-
- /* Read in the string that should be at the start of a "btsnoop" file */
- if (!wtap_read_bytes(wth->fh, magic, sizeof magic, err, err_info)) {
- if (*err != WTAP_ERR_SHORT_READ)
- return WTAP_OPEN_ERROR;
- return WTAP_OPEN_NOT_MINE;
- }
-
- if (memcmp(magic, btsnoop_magic, sizeof btsnoop_magic) != 0) {
- return WTAP_OPEN_NOT_MINE;
- }
-
- /* Read the rest of the header. */
- if (!wtap_read_bytes(wth->fh, &hdr, sizeof hdr, err, err_info))
- return WTAP_OPEN_ERROR;
-
- /*
- * Make sure it's a version we support.
- */
- hdr.version = g_ntohl(hdr.version);
- if (hdr.version != 1) {
- *err = WTAP_ERR_UNSUPPORTED;
- *err_info = g_strdup_printf("btsnoop: version %u unsupported", hdr.version);
- return WTAP_OPEN_ERROR;
- }
-
- hdr.datalink = g_ntohl(hdr.datalink);
- switch (hdr.datalink) {
- case KHciLoggerDatalinkTypeH1:
- file_encap=WTAP_ENCAP_BLUETOOTH_HCI;
- break;
- case KHciLoggerDatalinkTypeH4:
- file_encap=WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR;
- break;
- case KHciLoggerDatalinkTypeBCSP:
- *err = WTAP_ERR_UNSUPPORTED;
- *err_info = g_strdup_printf("btsnoop: BCSP capture logs unsupported");
- return WTAP_OPEN_ERROR;
- case KHciLoggerDatalinkTypeH5:
- *err = WTAP_ERR_UNSUPPORTED;
- *err_info = g_strdup_printf("btsnoop: H5 capture logs unsupported");
- return WTAP_OPEN_ERROR;
- case KHciLoggerDatalinkLinuxMonitor:
- file_encap=WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR;
- break;
- case KHciLoggerDatalinkBlueZ5Simulator:
- *err = WTAP_ERR_UNSUPPORTED;
- *err_info = g_strdup_printf("btsnoop: BlueZ 5 Simulator capture logs unsupported");
- return WTAP_OPEN_ERROR;
- default:
- *err = WTAP_ERR_UNSUPPORTED;
- *err_info = g_strdup_printf("btsnoop: datalink type %u unknown or unsupported", hdr.datalink);
- return WTAP_OPEN_ERROR;
- }
-
- wth->subtype_read = btsnoop_read;
- wth->subtype_seek_read = btsnoop_seek_read;
- wth->file_encap = file_encap;
- wth->snapshot_length = 0; /* not available in header */
- wth->file_tsprec = WTAP_TSPREC_USEC;
- wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_BTSNOOP;
- return WTAP_OPEN_MINE;
+ char magic[sizeof btsnoop_magic];
+ struct btsnoop_hdr hdr;
+
+ int file_encap=WTAP_ENCAP_UNKNOWN;
+
+ /* Read in the string that should be at the start of a "btsnoop" file */
+ if (!wtap_read_bytes(wth->fh, magic, sizeof magic, err, err_info)) {
+ if (*err != WTAP_ERR_SHORT_READ)
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
+ }
+
+ if (memcmp(magic, btsnoop_magic, sizeof btsnoop_magic) != 0) {
+ return WTAP_OPEN_NOT_MINE;
+ }
+
+ /* Read the rest of the header. */
+ if (!wtap_read_bytes(wth->fh, &hdr, sizeof hdr, err, err_info))
+ return WTAP_OPEN_ERROR;
+
+ /*
+ * Make sure it's a version we support.
+ */
+ hdr.version = g_ntohl(hdr.version);
+ if (hdr.version != 1) {
+ *err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("btsnoop: version %u unsupported", hdr.version);
+ return WTAP_OPEN_ERROR;
+ }
+
+ hdr.datalink = g_ntohl(hdr.datalink);
+ switch (hdr.datalink) {
+ case KHciLoggerDatalinkTypeH1:
+ file_encap=WTAP_ENCAP_BLUETOOTH_HCI;
+ break;
+ case KHciLoggerDatalinkTypeH4:
+ file_encap=WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR;
+ break;
+ case KHciLoggerDatalinkTypeBCSP:
+ *err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("btsnoop: BCSP capture logs unsupported");
+ return WTAP_OPEN_ERROR;
+ case KHciLoggerDatalinkTypeH5:
+ *err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("btsnoop: H5 capture logs unsupported");
+ return WTAP_OPEN_ERROR;
+ case KHciLoggerDatalinkLinuxMonitor:
+ file_encap=WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR;
+ break;
+ case KHciLoggerDatalinkBlueZ5Simulator:
+ *err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("btsnoop: BlueZ 5 Simulator capture logs unsupported");
+ return WTAP_OPEN_ERROR;
+ default:
+ *err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("btsnoop: datalink type %u unknown or unsupported", hdr.datalink);
+ return WTAP_OPEN_ERROR;
+ }
+
+ wth->subtype_read = btsnoop_read;
+ wth->subtype_seek_read = btsnoop_seek_read;
+ wth->file_encap = file_encap;
+ wth->snapshot_length = 0; /* not available in header */
+ wth->file_tsprec = WTAP_TSPREC_USEC;
+ wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_BTSNOOP;
+ return WTAP_OPEN_MINE;
}
static gboolean btsnoop_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+ gint64 *data_offset)
{
- *data_offset = file_tell(wth->fh);
+ *data_offset = file_tell(wth->fh);
- return btsnoop_read_record(wth, wth->fh, &wth->phdr, wth->frame_buffer,
- err, err_info);
+ return btsnoop_read_record(wth, wth->fh, &wth->phdr, wth->frame_buffer,
+ err, err_info);
}
static gboolean btsnoop_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
+ struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
{
- if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
- return FALSE;
+ if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
+ return FALSE;
- return btsnoop_read_record(wth, wth->random_fh, phdr, buf, err, err_info);
+ return btsnoop_read_record(wth, wth->random_fh, phdr, buf, err, err_info);
}
static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
- struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
+ struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
{
- struct btsnooprec_hdr hdr;
- guint32 packet_size;
- guint32 flags;
- guint32 orig_size;
- gint64 ts;
-
- /* Read record header. */
-
- if (!wtap_read_bytes_or_eof(fh, &hdr, sizeof hdr, err, err_info))
- return FALSE;
-
- packet_size = g_ntohl(hdr.incl_len);
- orig_size = g_ntohl(hdr.orig_len);
- flags = g_ntohl(hdr.flags);
- if (packet_size > WTAP_MAX_PACKET_SIZE) {
- /*
- * Probably a corrupt capture file; don't blow up trying
- * to allocate space for an immensely-large packet.
- */
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup_printf("btsnoop: File has %u-byte packet, bigger than maximum of %u",
- packet_size, WTAP_MAX_PACKET_SIZE);
- return FALSE;
- }
-
- ts = GINT64_FROM_BE(hdr.ts_usec);
- ts -= KUnixTimeBase;
-
- phdr->rec_type = REC_TYPE_PACKET;
- phdr->pkt_encap = wth->file_encap;
- phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
- phdr->ts.secs = (guint)(ts / 1000000);
- phdr->ts.nsecs = (guint)((ts % 1000000) * 1000);
- phdr->caplen = packet_size;
- phdr->len = orig_size;
- if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR)
- {
- phdr->pseudo_header.p2p.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE;
- } else if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_HCI) {
- phdr->pseudo_header.bthci.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE;
- if(flags & KHciLoggerCommandOrEvent)
- {
- if(phdr->pseudo_header.bthci.sent)
- {
- phdr->pseudo_header.bthci.channel = BTHCI_CHANNEL_COMMAND;
- }
- else
- {
- phdr->pseudo_header.bthci.channel = BTHCI_CHANNEL_EVENT;
- }
- }
- else
- {
- phdr->pseudo_header.bthci.channel = BTHCI_CHANNEL_ACL;
- }
- } else if (wth->file_encap == WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR) {
- phdr->pseudo_header.btmon.opcode = flags & 0xFFFF;
- phdr->pseudo_header.btmon.adapter_id = flags >> 16;
- }
-
-
- /* Read packet data. */
- return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info);
+ struct btsnooprec_hdr hdr;
+ guint32 packet_size;
+ guint32 flags;
+ guint32 orig_size;
+ gint64 ts;
+
+ /* Read record header. */
+
+ if (!wtap_read_bytes_or_eof(fh, &hdr, sizeof hdr, err, err_info))
+ return FALSE;
+
+ packet_size = g_ntohl(hdr.incl_len);
+ orig_size = g_ntohl(hdr.orig_len);
+ flags = g_ntohl(hdr.flags);
+ if (packet_size > WTAP_MAX_PACKET_SIZE) {
+ /*
+ * Probably a corrupt capture file; don't blow up trying
+ * to allocate space for an immensely-large packet.
+ */
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup_printf("btsnoop: File has %u-byte packet, bigger than maximum of %u",
+ packet_size, WTAP_MAX_PACKET_SIZE);
+ return FALSE;
+ }
+
+ ts = GINT64_FROM_BE(hdr.ts_usec);
+ ts -= KUnixTimeBase;
+
+ phdr->rec_type = REC_TYPE_PACKET;
+ phdr->pkt_encap = wth->file_encap;
+ phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
+ phdr->ts.secs = (guint)(ts / 1000000);
+ phdr->ts.nsecs = (guint)((ts % 1000000) * 1000);
+ phdr->caplen = packet_size;
+ phdr->len = orig_size;
+ if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_H4_WITH_PHDR)
+ {
+ phdr->pseudo_header.p2p.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE;
+ } else if(wth->file_encap == WTAP_ENCAP_BLUETOOTH_HCI) {
+ phdr->pseudo_header.bthci.sent = (flags & KHciLoggerControllerToHost) ? FALSE : TRUE;
+ if(flags & KHciLoggerCommandOrEvent)
+ {
+ if(phdr->pseudo_header.bthci.sent)
+ {
+ phdr->pseudo_header.bthci.channel = BTHCI_CHANNEL_COMMAND;
+ }
+ else
+ {
+ phdr->pseudo_header.bthci.channel = BTHCI_CHANNEL_EVENT;
+ }
+ }
+ else
+ {
+ phdr->pseudo_header.bthci.channel = BTHCI_CHANNEL_ACL;
+ }
+ } else if (wth->file_encap == WTAP_ENCAP_BLUETOOTH_LINUX_MONITOR) {
+ phdr->pseudo_header.btmon.opcode = flags & 0xFFFF;
+ phdr->pseudo_header.btmon.adapter_id = flags >> 16;
+ }
+
+
+ /* Read packet data. */
+ return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info);
}
/* Returns 0 if we could write the specified encapsulation type,
@@ -478,3 +478,16 @@ gboolean btsnoop_dump_open_h4(wtap_dumper *wdh, int *err)
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/capsa.c b/wiretap/capsa.c
index 227df2113a..f496cf80a1 100644
--- a/wiretap/capsa.c
+++ b/wiretap/capsa.c
@@ -445,3 +445,16 @@ capsa_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
return rec_size - (header_size + packet_size);
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/catapult_dct2000.c b/wiretap/catapult_dct2000.c
index 90439b9a8b..cc9cc3a471 100644
--- a/wiretap/catapult_dct2000.c
+++ b/wiretap/catapult_dct2000.c
@@ -1654,3 +1654,16 @@ free_line_prefix_info(gpointer key, gpointer value,
/* Item will always be removed from table */
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/commview.c b/wiretap/commview.c
index d2d178a250..47d3e53336 100644
--- a/wiretap/commview.c
+++ b/wiretap/commview.c
@@ -440,3 +440,16 @@ static gboolean commview_dump(wtap_dumper *wdh,
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/cosine.c b/wiretap/cosine.c
index 4ce5437245..d04b3c6083 100644
--- a/wiretap/cosine.c
+++ b/wiretap/cosine.c
@@ -504,3 +504,16 @@ parse_single_hex_dump_line(char* rec, guint8 *buf, guint byte_offset)
return num_items_scanned;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/csids.c b/wiretap/csids.c
index 7c0551a95c..fc8e386f1a 100644
--- a/wiretap/csids.c
+++ b/wiretap/csids.c
@@ -41,7 +41,7 @@
*/
typedef struct {
- gboolean byteswapped;
+ gboolean byteswapped;
} csids_t;
static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
@@ -81,7 +81,7 @@ wtap_open_return_val csids_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_NOT_MINE;
}
if( hdr.zeropad != 0 || hdr.caplen == 0 ) {
- return WTAP_OPEN_NOT_MINE;
+ return WTAP_OPEN_NOT_MINE;
}
hdr.seconds = pntoh32( &hdr.seconds );
hdr.caplen = pntoh16( &hdr.caplen );
@@ -151,11 +151,11 @@ static gboolean csids_read(wtap *wth, int *err, gchar **err_info,
/* Used to read packets in random-access fashion */
static gboolean
csids_seek_read(wtap *wth,
- gint64 seek_off,
- struct wtap_pkthdr *phdr,
- Buffer *buf,
- int *err,
- gchar **err_info)
+ gint64 seek_off,
+ struct wtap_pkthdr *phdr,
+ Buffer *buf,
+ int *err,
+ gchar **err_info)
{
csids_t *csids = (csids_t *)wth->priv;
@@ -206,3 +206,16 @@ csids_read_packet(FILE_T fh, csids_t *csids, struct wtap_pkthdr *phdr,
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local Variables:
+ * c-basic-offset: 2
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=2 tabstop=8 expandtab:
+ * :indentSize=2:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/daintree-sna.c b/wiretap/daintree-sna.c
index 555a054d0d..f43cf2dc33 100644
--- a/wiretap/daintree-sna.c
+++ b/wiretap/daintree-sna.c
@@ -287,3 +287,16 @@ daintree_sna_process_hex_data(struct wtap_pkthdr *phdr, Buffer *buf,
memcpy(ws_buffer_start_ptr(buf), readData, bytes);
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c
index f3029e2c10..6fa6145e4d 100644
--- a/wiretap/dbs-etherwatch.c
+++ b/wiretap/dbs-etherwatch.c
@@ -76,57 +76,57 @@ static const char dbs_etherwatch_hdr_magic[] =
static const char dbs_etherwatch_rec_magic[] =
{'F', 'r', 'o', 'm', ' '};
#define DBS_ETHERWATCH_REC_MAGIC_SIZE \
- (sizeof dbs_etherwatch_rec_magic / sizeof dbs_etherwatch_rec_magic[0])
+ (sizeof dbs_etherwatch_rec_magic / sizeof dbs_etherwatch_rec_magic[0])
/*
* XXX - is this the biggest packet we can get?
*/
-#define DBS_ETHERWATCH_MAX_PACKET_LEN 16384
+#define DBS_ETHERWATCH_MAX_PACKET_LEN 16384
static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+ gint64 *data_offset);
static gboolean dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
+ struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
static gboolean parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh,
- Buffer* buf, int *err, gchar **err_info);
+ Buffer* buf, int *err, gchar **err_info);
static guint parse_single_hex_dump_line(char* rec, guint8 *buf,
- int byte_offset);
+ int byte_offset);
static guint parse_hex_dump(char* dump, guint8 *buf, char seperator, char end);
/* Seeks to the beginning of the next packet, and returns the
byte offset. Returns -1 on failure, and sets "*err" to the error
and "*err_info" to null or an additional error string. */
static gint64 dbs_etherwatch_seek_next_packet(wtap *wth, int *err,
- gchar **err_info)
+ gchar **err_info)
{
- int byte;
- unsigned int level = 0;
- gint64 cur_off;
-
- while ((byte = file_getc(wth->fh)) != EOF) {
- if (byte == dbs_etherwatch_rec_magic[level]) {
- level++;
- if (level >= DBS_ETHERWATCH_REC_MAGIC_SIZE) {
- /* note: we're leaving file pointer right after the magic characters */
- cur_off = file_tell(wth->fh);
- if (cur_off == -1) {
- /* Error. */
- *err = file_error(wth->fh, err_info);
- return -1;
+ int byte;
+ unsigned int level = 0;
+ gint64 cur_off;
+
+ while ((byte = file_getc(wth->fh)) != EOF) {
+ if (byte == dbs_etherwatch_rec_magic[level]) {
+ level++;
+ if (level >= DBS_ETHERWATCH_REC_MAGIC_SIZE) {
+ /* note: we're leaving file pointer right after the magic characters */
+ cur_off = file_tell(wth->fh);
+ if (cur_off == -1) {
+ /* Error. */
+ *err = file_error(wth->fh, err_info);
+ return -1;
+ }
+ return cur_off + 1;
+ }
+ } else {
+ level = 0;
}
- return cur_off + 1;
- }
- } else {
- level = 0;
}
- }
- /* EOF or error. */
- *err = file_error(wth->fh, err_info);
- return -1;
+ /* EOF or error. */
+ *err = file_error(wth->fh, err_info);
+ return -1;
}
-#define DBS_ETHERWATCH_HEADER_LINES_TO_CHECK 200
-#define DBS_ETHERWATCH_LINE_LENGTH 240
+#define DBS_ETHERWATCH_HEADER_LINES_TO_CHECK 200
+#define DBS_ETHERWATCH_LINE_LENGTH 240
/* Look through the first part of a file to see if this is
* a DBS Ethertrace text trace file.
@@ -138,89 +138,89 @@ static gint64 dbs_etherwatch_seek_next_packet(wtap *wth, int *err,
static gboolean dbs_etherwatch_check_file_type(wtap *wth, int *err,
gchar **err_info)
{
- char buf[DBS_ETHERWATCH_LINE_LENGTH];
- int line, byte;
- gsize reclen;
- unsigned int i, level;
-
- buf[DBS_ETHERWATCH_LINE_LENGTH-1] = 0;
-
- for (line = 0; line < DBS_ETHERWATCH_HEADER_LINES_TO_CHECK; line++) {
- if (file_gets(buf, DBS_ETHERWATCH_LINE_LENGTH, wth->fh) == NULL) {
- /* EOF or error. */
- *err = file_error(wth->fh, err_info);
- return FALSE;
- }
-
- reclen = strlen(buf);
- if (reclen < DBS_ETHERWATCH_HDR_MAGIC_SIZE)
- continue;
-
- level = 0;
- for (i = 0; i < reclen; i++) {
- byte = buf[i];
- if (byte == dbs_etherwatch_hdr_magic[level]) {
- level++;
- if (level >=
- DBS_ETHERWATCH_HDR_MAGIC_SIZE) {
- return TRUE;
- }
- }
- else
- level = 0;
- }
- }
- *err = 0;
- return FALSE;
+ char buf[DBS_ETHERWATCH_LINE_LENGTH];
+ int line, byte;
+ gsize reclen;
+ unsigned int i, level;
+
+ buf[DBS_ETHERWATCH_LINE_LENGTH-1] = 0;
+
+ for (line = 0; line < DBS_ETHERWATCH_HEADER_LINES_TO_CHECK; line++) {
+ if (file_gets(buf, DBS_ETHERWATCH_LINE_LENGTH, wth->fh) == NULL) {
+ /* EOF or error. */
+ *err = file_error(wth->fh, err_info);
+ return FALSE;
+ }
+
+ reclen = strlen(buf);
+ if (reclen < DBS_ETHERWATCH_HDR_MAGIC_SIZE)
+ continue;
+
+ level = 0;
+ for (i = 0; i < reclen; i++) {
+ byte = buf[i];
+ if (byte == dbs_etherwatch_hdr_magic[level]) {
+ level++;
+ if (level >=
+ DBS_ETHERWATCH_HDR_MAGIC_SIZE) {
+ return TRUE;
+ }
+ }
+ else
+ level = 0;
+ }
+ }
+ *err = 0;
+ return FALSE;
}
wtap_open_return_val dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info)
{
- /* Look for DBS ETHERWATCH header */
- if (!dbs_etherwatch_check_file_type(wth, err, err_info)) {
- if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return WTAP_OPEN_ERROR;
- return WTAP_OPEN_NOT_MINE;
- }
-
- wth->file_encap = WTAP_ENCAP_ETHERNET;
- wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_DBS_ETHERWATCH;
- wth->snapshot_length = 0; /* not known */
- wth->subtype_read = dbs_etherwatch_read;
- wth->subtype_seek_read = dbs_etherwatch_seek_read;
- wth->file_tsprec = WTAP_TSPREC_CSEC;
-
- return WTAP_OPEN_MINE;
+ /* Look for DBS ETHERWATCH header */
+ if (!dbs_etherwatch_check_file_type(wth, err, err_info)) {
+ if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
+ }
+
+ wth->file_encap = WTAP_ENCAP_ETHERNET;
+ wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_DBS_ETHERWATCH;
+ wth->snapshot_length = 0; /* not known */
+ wth->subtype_read = dbs_etherwatch_read;
+ wth->subtype_seek_read = dbs_etherwatch_seek_read;
+ wth->file_tsprec = WTAP_TSPREC_CSEC;
+
+ return WTAP_OPEN_MINE;
}
/* Find the next packet and parse it; called from wtap_read(). */
static gboolean dbs_etherwatch_read(wtap *wth, int *err, gchar **err_info,
gint64 *data_offset)
{
- gint64 offset;
+ gint64 offset;
- /* Find the next packet */
- offset = dbs_etherwatch_seek_next_packet(wth, err, err_info);
- if (offset < 1)
- return FALSE;
- *data_offset = offset;
+ /* Find the next packet */
+ offset = dbs_etherwatch_seek_next_packet(wth, err, err_info);
+ if (offset < 1)
+ return FALSE;
+ *data_offset = offset;
- /* Parse the packet */
- return parse_dbs_etherwatch_packet(&wth->phdr, wth->fh,
- wth->frame_buffer, err, err_info);
+ /* Parse the packet */
+ return parse_dbs_etherwatch_packet(&wth->phdr, wth->fh,
+ wth->frame_buffer, err, err_info);
}
/* Used to read packets in random-access fashion */
static gboolean
dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
+ struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
{
- if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
- return FALSE;
+ if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
+ return FALSE;
- return parse_dbs_etherwatch_packet(phdr, wth->random_fh, buf, err,
- err_info);
+ return parse_dbs_etherwatch_packet(phdr, wth->random_fh, buf, err,
+ err_info);
}
/* Parse a packet */
@@ -231,22 +231,22 @@ Packet header:
From 00-D0-C0-D2-4D-60 [MF1] to AA-00-04-00-FC-94 [PSERVB]
Protocol 08-00 00 00-00-00-00-00, 50 byte buffer at 10-OCT-2001 10:20:45.17
*/
-#define MAC_ADDR_LENGTH 6 /* Length MAC address */
-#define DEST_MAC_PREFIX "] to " /* Prefix to the dest. MAC address */
-#define PROTOCOL_LENGTH 2 /* Length protocol */
-#define PROTOCOL_POS 9 /* Position protocol */
-#define SAP_LENGTH 2 /* Length DSAP+SSAP */
-#define SAP_POS 9 /* Position DSAP+SSAP */
-#define CTL_UNNUMB_LENGTH 1 /* Length unnumbered control field */
-#define CTL_NUMB_LENGTH 2 /* Length numbered control field */
-#define CTL_POS 15 /* Position control field */
-#define PID_LENGTH 5 /* Length PID */
-#define PID_POS 18 /* Position PID */
-#define LENGTH_POS 33 /* Position length */
-#define HEX_HDR_SPR '-' /* Seperator char header hex values */
-#define HEX_HDR_END ' ' /* End char hdr. hex val. except PID */
-#define HEX_PID_END ',' /* End char PID hex value */
-#define IEEE802_LEN_LEN 2 /* Length of the IEEE 802 len. field */
+#define MAC_ADDR_LENGTH 6 /* Length MAC address */
+#define DEST_MAC_PREFIX "] to " /* Prefix to the dest. MAC address */
+#define PROTOCOL_LENGTH 2 /* Length protocol */
+#define PROTOCOL_POS 9 /* Position protocol */
+#define SAP_LENGTH 2 /* Length DSAP+SSAP */
+#define SAP_POS 9 /* Position DSAP+SSAP */
+#define CTL_UNNUMB_LENGTH 1 /* Length unnumbered control field */
+#define CTL_NUMB_LENGTH 2 /* Length numbered control field */
+#define CTL_POS 15 /* Position control field */
+#define PID_LENGTH 5 /* Length PID */
+#define PID_POS 18 /* Position PID */
+#define LENGTH_POS 33 /* Position length */
+#define HEX_HDR_SPR '-' /* Seperator char header hex values */
+#define HEX_HDR_END ' ' /* End char hdr. hex val. except PID */
+#define HEX_PID_END ',' /* End char PID hex value */
+#define IEEE802_LEN_LEN 2 /* Length of the IEEE 802 len. field */
/*
To check whether it is Ethernet II or IEEE 802 we check the values of the
control field and PID, when they are all 0's we assume it is Ethernet II
@@ -259,220 +259,220 @@ length in the IEEE data we have to construct.
To check whether it IEEE 802.3 with SNAP we check that both the DSAP & SSAP
values are 0xAA and the control field 0x03.
*/
-#define SNAP_CHECK_POS 9
-#define SNAP_CHECK_STR "AA-AA 03"
+#define SNAP_CHECK_POS 9
+#define SNAP_CHECK_STR "AA-AA 03"
/*
To check whether the control field is 1 or two octets we check if it is
unnumbered. Unnumbered has length 1, numbered 2.
*/
-#define CTL_UNNUMB_MASK 0x03
-#define CTL_UNNUMB_VALUE 0x03
+#define CTL_UNNUMB_MASK 0x03
+#define CTL_UNNUMB_VALUE 0x03
static gboolean
parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
int *err, gchar **err_info)
{
- guint8 *pd;
- char line[DBS_ETHERWATCH_LINE_LENGTH];
- int num_items_scanned;
- int eth_hdr_len, pkt_len, csec;
- int length_pos, length_from, length;
- struct tm tm;
- char mon[4] = "xxx";
- gchar *p;
- static const gchar months[] = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
- int count, line_count;
-
- /* Make sure we have enough room for the packet */
- ws_buffer_assure_space(buf, DBS_ETHERWATCH_MAX_PACKET_LEN);
- pd = ws_buffer_start_ptr(buf);
-
- eth_hdr_len = 0;
- memset(&tm, 0, sizeof(tm));
- /* Our file pointer should be on the first line containing the
- * summary information for a packet. Read in that line and
- * extract the useful information
- */
- if (file_gets(line, DBS_ETHERWATCH_LINE_LENGTH, fh) == NULL) {
- *err = file_error(fh, err_info);
- if (*err == 0) {
- *err = WTAP_ERR_SHORT_READ;
- }
- return FALSE;
- }
-
- /* Get the destination address */
- p = strstr(line, DEST_MAC_PREFIX);
- if(!p) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("dbs_etherwatch: destination address not found");
- return FALSE;
- }
- p += strlen(DEST_MAC_PREFIX);
- if(parse_hex_dump(p, &pd[eth_hdr_len], HEX_HDR_SPR, HEX_HDR_END)
- != MAC_ADDR_LENGTH) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("dbs_etherwatch: destination address not valid");
- return FALSE;
- }
- eth_hdr_len += MAC_ADDR_LENGTH;
-
- /* Get the source address */
- /*
- * Since the first part of the line is already skipped in order to find
- * the start of the record we cannot index, just look for the first
- * 'HEX' character
- */
- p = line;
- while(!g_ascii_isxdigit(*p)) {
- p++;
- }
- if(parse_hex_dump(p, &pd[eth_hdr_len], HEX_HDR_SPR,
- HEX_HDR_END) != MAC_ADDR_LENGTH) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("dbs_etherwatch: source address not valid");
- return FALSE;
- }
- eth_hdr_len += MAC_ADDR_LENGTH;
-
- /* Read the next line of the record header */
- if (file_gets(line, DBS_ETHERWATCH_LINE_LENGTH, fh) == NULL) {
- *err = file_error(fh, err_info);
- if (*err == 0) {
- *err = WTAP_ERR_SHORT_READ;
- }
- return FALSE;
- }
-
- /* Check the lines is as least as long as the length position */
- if(strlen(line) < LENGTH_POS) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("dbs_etherwatch: line too short");
- return FALSE;
- }
-
- num_items_scanned = sscanf(line + LENGTH_POS,
- "%9d byte buffer at %2d-%3s-%4d %2d:%2d:%2d.%9d",
- &pkt_len,
- &tm.tm_mday, mon,
- &tm.tm_year, &tm.tm_hour, &tm.tm_min,
- &tm.tm_sec, &csec);
-
- if (num_items_scanned != 8) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("dbs_etherwatch: header line not valid");
- return FALSE;
- }
-
- /* Determine whether it is Ethernet II or IEEE 802 */
- if(strncmp(&line[ETH_II_CHECK_POS], ETH_II_CHECK_STR,
- strlen(ETH_II_CHECK_STR)) == 0) {
- /* Ethernet II */
- /* Get the Protocol */
- if(parse_hex_dump(&line[PROTOCOL_POS], &pd[eth_hdr_len], HEX_HDR_SPR,
- HEX_HDR_END) != PROTOCOL_LENGTH) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("dbs_etherwatch: Ethernet II protocol value not valid");
- return FALSE;
- }
- eth_hdr_len += PROTOCOL_LENGTH;
- } else {
- /* IEEE 802 */
- /* Remember where to put the length in the header */
- length_pos = eth_hdr_len;
- /* Leave room in the header for the length */
- eth_hdr_len += IEEE802_LEN_LEN;
- /* Remember how much of the header should not be added to the length */
- length_from = eth_hdr_len;
- /* Get the DSAP + SSAP */
- if(parse_hex_dump(&line[SAP_POS], &pd[eth_hdr_len], HEX_HDR_SPR,
- HEX_HDR_END) != SAP_LENGTH) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("dbs_etherwatch: 802.2 DSAP+SSAP value not valid");
- return FALSE;
- }
- eth_hdr_len += SAP_LENGTH;
- /* Get the (first part of the) control field */
- if(parse_hex_dump(&line[CTL_POS], &pd[eth_hdr_len], HEX_HDR_SPR,
- HEX_HDR_END) != CTL_UNNUMB_LENGTH) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("dbs_etherwatch: 802.2 control field first part not valid");
- return FALSE;
- }
- /* Determine whether the control is numbered, and thus longer */
- if((pd[eth_hdr_len] & CTL_UNNUMB_MASK) != CTL_UNNUMB_VALUE) {
- /* Get the rest of the control field, the first octet in the PID */
- if(parse_hex_dump(&line[PID_POS],
- &pd[eth_hdr_len + CTL_UNNUMB_LENGTH], HEX_HDR_END,
- HEX_HDR_SPR) != CTL_NUMB_LENGTH - CTL_UNNUMB_LENGTH) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("dbs_etherwatch: 802.2 control field second part value not valid");
- return FALSE;
- }
- eth_hdr_len += CTL_NUMB_LENGTH;
- } else {
- eth_hdr_len += CTL_UNNUMB_LENGTH;
- }
- /* Determine whether it is SNAP */
- if(strncmp(&line[SNAP_CHECK_POS], SNAP_CHECK_STR,
- strlen(SNAP_CHECK_STR)) == 0) {
- /* Get the PID */
- if(parse_hex_dump(&line[PID_POS], &pd[eth_hdr_len], HEX_HDR_SPR,
- HEX_PID_END) != PID_LENGTH) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("dbs_etherwatch: 802.2 PID value not valid");
- return FALSE;
- }
- eth_hdr_len += PID_LENGTH;
- }
- /* Write the length in the header */
- length = eth_hdr_len - length_from + pkt_len;
- pd[length_pos] = (length) >> 8;
- pd[length_pos+1] = (length) & 0xFF;
- }
-
- phdr->rec_type = REC_TYPE_PACKET;
- phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
-
- p = strstr(months, mon);
- if (p)
- tm.tm_mon = (int)(p - months) / 3;
- tm.tm_year -= 1900;
-
- tm.tm_isdst = -1;
- phdr->ts.secs = mktime(&tm);
- phdr->ts.nsecs = csec * 10000000;
- phdr->caplen = eth_hdr_len + pkt_len;
- phdr->len = eth_hdr_len + pkt_len;
-
- /*
- * We don't have an FCS in this frame.
- */
- phdr->pseudo_header.eth.fcs_len = 0;
-
- /* Parse the hex dump */
- count = 0;
- while (count < pkt_len) {
- if (file_gets(line, DBS_ETHERWATCH_LINE_LENGTH, fh) == NULL) {
- *err = file_error(fh, err_info);
- if (*err == 0) {
- *err = WTAP_ERR_SHORT_READ;
- }
- return FALSE;
- }
- if (!(line_count = parse_single_hex_dump_line(line,
- &pd[eth_hdr_len + count], count))) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("dbs_etherwatch: packet data value not valid");
- return FALSE;
- }
- count += line_count;
- if (count > pkt_len) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("dbs_etherwatch: packet data value has too many bytes");
- return FALSE;
- }
- }
- return TRUE;
+ guint8 *pd;
+ char line[DBS_ETHERWATCH_LINE_LENGTH];
+ int num_items_scanned;
+ int eth_hdr_len, pkt_len, csec;
+ int length_pos, length_from, length;
+ struct tm tm;
+ char mon[4] = "xxx";
+ gchar *p;
+ static const gchar months[] = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
+ int count, line_count;
+
+ /* Make sure we have enough room for the packet */
+ ws_buffer_assure_space(buf, DBS_ETHERWATCH_MAX_PACKET_LEN);
+ pd = ws_buffer_start_ptr(buf);
+
+ eth_hdr_len = 0;
+ memset(&tm, 0, sizeof(tm));
+ /* Our file pointer should be on the first line containing the
+ * summary information for a packet. Read in that line and
+ * extract the useful information
+ */
+ if (file_gets(line, DBS_ETHERWATCH_LINE_LENGTH, fh) == NULL) {
+ *err = file_error(fh, err_info);
+ if (*err == 0) {
+ *err = WTAP_ERR_SHORT_READ;
+ }
+ return FALSE;
+ }
+
+ /* Get the destination address */
+ p = strstr(line, DEST_MAC_PREFIX);
+ if(!p) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("dbs_etherwatch: destination address not found");
+ return FALSE;
+ }
+ p += strlen(DEST_MAC_PREFIX);
+ if(parse_hex_dump(p, &pd[eth_hdr_len], HEX_HDR_SPR, HEX_HDR_END)
+ != MAC_ADDR_LENGTH) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("dbs_etherwatch: destination address not valid");
+ return FALSE;
+ }
+ eth_hdr_len += MAC_ADDR_LENGTH;
+
+ /* Get the source address */
+ /*
+ * Since the first part of the line is already skipped in order to find
+ * the start of the record we cannot index, just look for the first
+ * 'HEX' character
+ */
+ p = line;
+ while(!g_ascii_isxdigit(*p)) {
+ p++;
+ }
+ if(parse_hex_dump(p, &pd[eth_hdr_len], HEX_HDR_SPR,
+ HEX_HDR_END) != MAC_ADDR_LENGTH) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("dbs_etherwatch: source address not valid");
+ return FALSE;
+ }
+ eth_hdr_len += MAC_ADDR_LENGTH;
+
+ /* Read the next line of the record header */
+ if (file_gets(line, DBS_ETHERWATCH_LINE_LENGTH, fh) == NULL) {
+ *err = file_error(fh, err_info);
+ if (*err == 0) {
+ *err = WTAP_ERR_SHORT_READ;
+ }
+ return FALSE;
+ }
+
+ /* Check the lines is as least as long as the length position */
+ if(strlen(line) < LENGTH_POS) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("dbs_etherwatch: line too short");
+ return FALSE;
+ }
+
+ num_items_scanned = sscanf(line + LENGTH_POS,
+ "%9d byte buffer at %2d-%3s-%4d %2d:%2d:%2d.%9d",
+ &pkt_len,
+ &tm.tm_mday, mon,
+ &tm.tm_year, &tm.tm_hour, &tm.tm_min,
+ &tm.tm_sec, &csec);
+
+ if (num_items_scanned != 8) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("dbs_etherwatch: header line not valid");
+ return FALSE;
+ }
+
+ /* Determine whether it is Ethernet II or IEEE 802 */
+ if(strncmp(&line[ETH_II_CHECK_POS], ETH_II_CHECK_STR,
+ strlen(ETH_II_CHECK_STR)) == 0) {
+ /* Ethernet II */
+ /* Get the Protocol */
+ if(parse_hex_dump(&line[PROTOCOL_POS], &pd[eth_hdr_len], HEX_HDR_SPR,
+ HEX_HDR_END) != PROTOCOL_LENGTH) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("dbs_etherwatch: Ethernet II protocol value not valid");
+ return FALSE;
+ }
+ eth_hdr_len += PROTOCOL_LENGTH;
+ } else {
+ /* IEEE 802 */
+ /* Remember where to put the length in the header */
+ length_pos = eth_hdr_len;
+ /* Leave room in the header for the length */
+ eth_hdr_len += IEEE802_LEN_LEN;
+ /* Remember how much of the header should not be added to the length */
+ length_from = eth_hdr_len;
+ /* Get the DSAP + SSAP */
+ if(parse_hex_dump(&line[SAP_POS], &pd[eth_hdr_len], HEX_HDR_SPR,
+ HEX_HDR_END) != SAP_LENGTH) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("dbs_etherwatch: 802.2 DSAP+SSAP value not valid");
+ return FALSE;
+ }
+ eth_hdr_len += SAP_LENGTH;
+ /* Get the (first part of the) control field */
+ if(parse_hex_dump(&line[CTL_POS], &pd[eth_hdr_len], HEX_HDR_SPR,
+ HEX_HDR_END) != CTL_UNNUMB_LENGTH) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("dbs_etherwatch: 802.2 control field first part not valid");
+ return FALSE;
+ }
+ /* Determine whether the control is numbered, and thus longer */
+ if((pd[eth_hdr_len] & CTL_UNNUMB_MASK) != CTL_UNNUMB_VALUE) {
+ /* Get the rest of the control field, the first octet in the PID */
+ if(parse_hex_dump(&line[PID_POS],
+ &pd[eth_hdr_len + CTL_UNNUMB_LENGTH], HEX_HDR_END,
+ HEX_HDR_SPR) != CTL_NUMB_LENGTH - CTL_UNNUMB_LENGTH) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("dbs_etherwatch: 802.2 control field second part value not valid");
+ return FALSE;
+ }
+ eth_hdr_len += CTL_NUMB_LENGTH;
+ } else {
+ eth_hdr_len += CTL_UNNUMB_LENGTH;
+ }
+ /* Determine whether it is SNAP */
+ if(strncmp(&line[SNAP_CHECK_POS], SNAP_CHECK_STR,
+ strlen(SNAP_CHECK_STR)) == 0) {
+ /* Get the PID */
+ if(parse_hex_dump(&line[PID_POS], &pd[eth_hdr_len], HEX_HDR_SPR,
+ HEX_PID_END) != PID_LENGTH) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("dbs_etherwatch: 802.2 PID value not valid");
+ return FALSE;
+ }
+ eth_hdr_len += PID_LENGTH;
+ }
+ /* Write the length in the header */
+ length = eth_hdr_len - length_from + pkt_len;
+ pd[length_pos] = (length) >> 8;
+ pd[length_pos+1] = (length) & 0xFF;
+ }
+
+ phdr->rec_type = REC_TYPE_PACKET;
+ phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
+
+ p = strstr(months, mon);
+ if (p)
+ tm.tm_mon = (int)(p - months) / 3;
+ tm.tm_year -= 1900;
+
+ tm.tm_isdst = -1;
+ phdr->ts.secs = mktime(&tm);
+ phdr->ts.nsecs = csec * 10000000;
+ phdr->caplen = eth_hdr_len + pkt_len;
+ phdr->len = eth_hdr_len + pkt_len;
+
+ /*
+ * We don't have an FCS in this frame.
+ */
+ phdr->pseudo_header.eth.fcs_len = 0;
+
+ /* Parse the hex dump */
+ count = 0;
+ while (count < pkt_len) {
+ if (file_gets(line, DBS_ETHERWATCH_LINE_LENGTH, fh) == NULL) {
+ *err = file_error(fh, err_info);
+ if (*err == 0) {
+ *err = WTAP_ERR_SHORT_READ;
+ }
+ return FALSE;
+ }
+ if (!(line_count = parse_single_hex_dump_line(line,
+ &pd[eth_hdr_len + count], count))) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("dbs_etherwatch: packet data value not valid");
+ return FALSE;
+ }
+ count += line_count;
+ if (count > pkt_len) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("dbs_etherwatch: packet data value has too many bytes");
+ return FALSE;
+ }
+ }
+ return TRUE;
}
/* Parse a hex dump line */
@@ -496,14 +496,14 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
*/
-#define TYPE_CHECK_POS 2 /* Position to check the type of hex dump */
-#define TYPE_CHECK_BOTH '[' /* Value at pos. that indicates BOTH type */
-#define COUNT_POS_BOTH 21 /* Count position BOTH type */
-#define COUNT_POS_HEX 1 /* Count position HEX type */
-#define COUNT_SIZE 5 /* Length counter */
-#define HEX_DUMP_START '[' /* Start char */
-#define HEX_DUMP_SPR ' ' /* Seperator char */
-#define HEX_DUMP_END ']' /* End char */
+#define TYPE_CHECK_POS 2 /* Position to check the type of hex dump */
+#define TYPE_CHECK_BOTH '[' /* Value at pos. that indicates BOTH type */
+#define COUNT_POS_BOTH 21 /* Count position BOTH type */
+#define COUNT_POS_HEX 1 /* Count position HEX type */
+#define COUNT_SIZE 5 /* Length counter */
+#define HEX_DUMP_START '[' /* Start char */
+#define HEX_DUMP_SPR ' ' /* Seperator char */
+#define HEX_DUMP_END ']' /* End char */
/* Take a string representing one line from a hex dump and converts the
* text to binary data. We check the printed offset with the offset
@@ -515,97 +515,110 @@ parse_dbs_etherwatch_packet(struct wtap_pkthdr *phdr, FILE_T fh, Buffer* buf,
static guint
parse_single_hex_dump_line(char* rec, guint8 *buf, int byte_offset) {
- int pos, i;
- int value;
-
-
- /* Check that the record is as least as long as the check offset */
- for(i = 0; i < TYPE_CHECK_POS; i++)
- {
- if(rec[i] == '\0') {
- return 0;
- }
- }
- /* determine the format and thus the counter offset and hex dump length */
- if(rec[TYPE_CHECK_POS] == TYPE_CHECK_BOTH)
- {
- pos = COUNT_POS_BOTH;
- }
- else
- {
- pos = COUNT_POS_HEX;
- }
-
- /* Check that the record is as least as long as the start position */
- while(i < pos)
- {
- if(rec[i] == '\0') {
- return 0;
- }
- i++;
- }
-
- /* Get the byte_offset directly from the record */
- value = 0;
- for(i = 0; i < COUNT_SIZE; i++) {
- if(!g_ascii_isspace(rec[pos])) {
- if(g_ascii_isdigit(rec[pos])) {
- value *= 10;
- value += rec[pos] - '0';
- } else {
- return 0;
- }
- }
- pos++;
- }
-
- if (value != byte_offset) {
- return 0;
- }
-
- /* find the start of the hex dump */
- while(rec[pos] != HEX_DUMP_START) {
- if(rec[pos] == '\0') {
- return 0;
- }
- pos++;
- }
- pos++;
- return parse_hex_dump(&rec[pos], buf, HEX_DUMP_SPR, HEX_DUMP_END);
+ int pos, i;
+ int value;
+
+
+ /* Check that the record is as least as long as the check offset */
+ for(i = 0; i < TYPE_CHECK_POS; i++)
+ {
+ if(rec[i] == '\0') {
+ return 0;
+ }
+ }
+ /* determine the format and thus the counter offset and hex dump length */
+ if(rec[TYPE_CHECK_POS] == TYPE_CHECK_BOTH)
+ {
+ pos = COUNT_POS_BOTH;
+ }
+ else
+ {
+ pos = COUNT_POS_HEX;
+ }
+
+ /* Check that the record is as least as long as the start position */
+ while(i < pos)
+ {
+ if(rec[i] == '\0') {
+ return 0;
+ }
+ i++;
+ }
+
+ /* Get the byte_offset directly from the record */
+ value = 0;
+ for(i = 0; i < COUNT_SIZE; i++) {
+ if(!g_ascii_isspace(rec[pos])) {
+ if(g_ascii_isdigit(rec[pos])) {
+ value *= 10;
+ value += rec[pos] - '0';
+ } else {
+ return 0;
+ }
+ }
+ pos++;
+ }
+
+ if (value != byte_offset) {
+ return 0;
+ }
+
+ /* find the start of the hex dump */
+ while(rec[pos] != HEX_DUMP_START) {
+ if(rec[pos] == '\0') {
+ return 0;
+ }
+ pos++;
+ }
+ pos++;
+ return parse_hex_dump(&rec[pos], buf, HEX_DUMP_SPR, HEX_DUMP_END);
}
/* Parse a hex dump */
static guint
parse_hex_dump(char* dump, guint8 *buf, char seperator, char end) {
- int pos, count;
-
- /* Parse the hex dump */
- pos = 0;
- count = 0;
- while(dump[pos] != end) {
- /* Check the hex value */
- if(!(g_ascii_isxdigit(dump[pos]) &&
- g_ascii_isxdigit(dump[pos + 1]))) {
- return 0;
- }
- /* Get the hex value value */
- if(g_ascii_isdigit(dump[pos])) {
- buf[count] = (dump[pos] - '0') << 4;
- } else {
- buf[count] = (g_ascii_toupper(dump[pos]) - 'A' + 10) << 4;
- }
- pos++;
- if(g_ascii_isdigit(dump[pos])) {
- buf[count] += dump[pos] - '0';
- } else {
- buf[count] += g_ascii_toupper(dump[pos]) - 'A' + 10;
- }
- pos++;
- count++;
- /* Skip the seperator characters */
- while(dump[pos] == seperator) {
- pos++;
- }
- }
- return count;
+ int pos, count;
+
+ /* Parse the hex dump */
+ pos = 0;
+ count = 0;
+ while(dump[pos] != end) {
+ /* Check the hex value */
+ if(!(g_ascii_isxdigit(dump[pos]) &&
+ g_ascii_isxdigit(dump[pos + 1]))) {
+ return 0;
+ }
+ /* Get the hex value value */
+ if(g_ascii_isdigit(dump[pos])) {
+ buf[count] = (dump[pos] - '0') << 4;
+ } else {
+ buf[count] = (g_ascii_toupper(dump[pos]) - 'A' + 10) << 4;
+ }
+ pos++;
+ if(g_ascii_isdigit(dump[pos])) {
+ buf[count] += dump[pos] - '0';
+ } else {
+ buf[count] += g_ascii_toupper(dump[pos]) - 'A' + 10;
+ }
+ pos++;
+ count++;
+ /* Skip the seperator characters */
+ while(dump[pos] == seperator) {
+ pos++;
+ }
+ }
+ return count;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/dct3trace.c b/wiretap/dct3trace.c
index 6f35fb9416..e8c01e3bed 100644
--- a/wiretap/dct3trace.c
+++ b/wiretap/dct3trace.c
@@ -367,3 +367,16 @@ static gboolean dct3trace_seek_read(wtap *wth, gint64 seek_off,
return dct3trace_get_packet(wth->random_fh, phdr, buf, err, err_info);
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/erf.c b/wiretap/erf.c
index bbd20b906b..129684d2dc 100644
--- a/wiretap/erf.c
+++ b/wiretap/erf.c
@@ -783,3 +783,16 @@ int erf_populate_interfaces(wtap *wth)
return 0;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local Variables:
+ * c-basic-offset: 2
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=2 tabstop=8 expandtab:
+ * :indentSize=2:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/erf.h b/wiretap/erf.h
index a123898bea..20d7303f54 100644
--- a/wiretap/erf.h
+++ b/wiretap/erf.h
@@ -110,3 +110,16 @@ int erf_dump_open(wtap_dumper *wdh, int *err);
int erf_populate_interfaces(wtap *wth);
#endif /* __W_ERF_H__ */
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/eyesdn.c b/wiretap/eyesdn.c
index ac8f2f879d..59bcae3ab3 100644
--- a/wiretap/eyesdn.c
+++ b/wiretap/eyesdn.c
@@ -197,7 +197,7 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
int usecs;
int pkt_len;
guint8 channel, direction;
- guint8 *pd;
+ guint8 *pd;
/* Our file pointer should be at the summary information header
* for a packet. Read in that header and extract the useful
@@ -206,21 +206,21 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
if (!esc_read(fh, hdr, EYESDN_HDR_LENGTH, err, err_info))
return FALSE;
- /* extract information from header */
- usecs = pntoh24(&hdr[0]);
+ /* extract information from header */
+ usecs = pntoh24(&hdr[0]);
#ifdef TV64BITS
- secs = hdr[3];
+ secs = hdr[3];
#else
- secs = 0;
+ secs = 0;
#endif
- secs = (secs << 8) | hdr[4];
- secs = (secs << 8) | hdr[5];
- secs = (secs << 8) | hdr[6];
- secs = (secs << 8) | hdr[7];
+ secs = (secs << 8) | hdr[4];
+ secs = (secs << 8) | hdr[5];
+ secs = (secs << 8) | hdr[6];
+ secs = (secs << 8) | hdr[7];
- channel = hdr[8];
- direction = hdr[9];
- pkt_len = pntoh16(&hdr[10]);
+ channel = hdr[8];
+ direction = hdr[9];
+ pkt_len = pntoh16(&hdr[10]);
switch(direction >> 1) {
@@ -492,3 +492,16 @@ static gboolean eyesdn_dump(wtap_dumper *wdh,
return FALSE;
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 730698b919..d80e8e6153 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -1154,7 +1154,7 @@ static const struct file_type_subtype_info dump_open_table_base[] = {
NULL, NULL, NULL },
/* WTAP_FILE_TYPE_SUBTYPE_PCAP */
- /* Gianluca Varenni suggests that we add "deprecated" to the description. */
+ /* Gianluca Varenni suggests that we add "deprecated" to the description. */
{ "Wireshark/tcpdump/... - pcap", "pcap", "pcap", "cap;dmp",
FALSE, FALSE, 0,
libpcap_dump_can_write_encap, libpcap_dump_open, NULL },
@@ -2522,3 +2522,16 @@ wtap_dump_file_tell(wtap_dumper *wdh, int *err)
}
}
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/hcidump.c b/wiretap/hcidump.c
index 5f7634abb2..02742cac00 100644
--- a/wiretap/hcidump.c
+++ b/wiretap/hcidump.c
@@ -122,3 +122,16 @@ wtap_open_return_val hcidump_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c
index 8920f10c29..f0d4d6e508 100644
--- a/wiretap/i4btrace.c
+++ b/wiretap/i4btrace.c
@@ -228,3 +228,16 @@ i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
*/
return wtap_read_packet_bytes(fh, buf, length, err, err_info);
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/ipfix.c b/wiretap/ipfix.c
index a0fac7ddb2..b65cf96c5e 100644
--- a/wiretap/ipfix.c
+++ b/wiretap/ipfix.c
@@ -329,3 +329,16 @@ ipfix_seek_read(wtap *wth, gint64 seek_off, struct wtap_pkthdr *phdr,
}
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/iptrace.c b/wiretap/iptrace.c
index f92241fefd..a55d4c9fcd 100644
--- a/wiretap/iptrace.c
+++ b/wiretap/iptrace.c
@@ -604,3 +604,16 @@ wtap_encap_ift(unsigned int ift)
}
}
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/k12.c b/wiretap/k12.c
index 611026829e..ab1d9d4390 100644
--- a/wiretap/k12.c
+++ b/wiretap/k12.c
@@ -71,9 +71,9 @@ void k12_fprintf(const char* fmt, ...) {
#define CAT(a,b) a##b
#define K12_DBG(level,args) do { if (level <= debug_level) { \
- fprintf(dbg_out,"%s:%d: ",CAT(__FI,LE__),CAT(__LI,NE__)); \
- k12_fprintf args ; \
- fprintf(dbg_out,"\n"); \
+ fprintf(dbg_out,"%s:%d: ",CAT(__FI,LE__),CAT(__LI,NE__)); \
+ k12_fprintf args ; \
+ fprintf(dbg_out,"\n"); \
} } while(0)
void k12_hex_ascii_dump(guint level, gint64 offset, const char* label, const unsigned char* b, unsigned int len) {
@@ -240,30 +240,30 @@ typedef struct _k12_src_desc_t {
* with the "group" code followe by the "type" code. The "group" values
* are:
*
- * 0x0001 - "data event"
- * 0x0002 - "text or L1 event"
- * 0x0007 - "configuration event"
+ * 0x0001 - "data event"
+ * 0x0002 - "text or L1 event"
+ * 0x0007 - "configuration event"
*
* and the "type" values are:
*
* data events:
- * 0x0020 - "frame" (i.e., "an actual packet")
- * 0x0021 - "transparent frame"
- * 0x0022 - "bit data (TRAU frame)"
- * 0x0024 - "used to mark the frame which is a fragment"
- * 0x0026 - "used to mark the frame which is a fragment"
- * 0x0028 - "used to mark the frame which is generated by the LSA"
- * 0x002A - "used to mark the frame which is generated by the LSA"
+ * 0x0020 - "frame" (i.e., "an actual packet")
+ * 0x0021 - "transparent frame"
+ * 0x0022 - "bit data (TRAU frame)"
+ * 0x0024 - "used to mark the frame which is a fragment"
+ * 0x0026 - "used to mark the frame which is a fragment"
+ * 0x0028 - "used to mark the frame which is generated by the LSA"
+ * 0x002A - "used to mark the frame which is generated by the LSA"
*
* text or L1 events:
- * 0x0030 - "text event"
- * 0x0031 - "L1 event"
- * 0x0032 - "L1 event (BAI)"
- * 0x0033 - "L1 event (VX)"
+ * 0x0030 - "text event"
+ * 0x0031 - "L1 event"
+ * 0x0032 - "L1 event (BAI)"
+ * 0x0033 - "L1 event (VX)"
*
* configuration events:
- * 0x0040 - Logical Data Source configuration event
- * 0x0041 - Logical Link configuration event
+ * 0x0040 - Logical Data Source configuration event
+ * 0x0041 - Logical Link configuration event
*/
/* so far we've seen these types of records */
#define K12_REC_PACKET 0x00010020 /* an actual packet */
@@ -567,10 +567,10 @@ memiszero(const void *ptr, size_t count)
const guint8 *p = (const guint8 *)ptr;
while (count != 0) {
- if (*p != 0)
- return FALSE;
- p++;
- count--;
+ if (*p != 0)
+ return FALSE;
+ p++;
+ count--;
}
return TRUE;
}
@@ -801,7 +801,7 @@ static void k12_close(wtap *wth) {
k12_t *k12 = (k12_t *)wth->priv;
destroy_k12_file_data(k12);
- wth->priv = NULL; /* destroy_k12_file_data freed it */
+ wth->priv = NULL; /* destroy_k12_file_data freed it */
#ifdef DEBUG_K12
K12_DBG(5,("k12_close: CLOSED"));
if (env_file) fclose(dbg_out);
@@ -828,14 +828,14 @@ wtap_open_return_val k12_open(wtap *wth, int *err, gchar **err_info) {
gchar* env_level = getenv("K12_DEBUG_LEVEL");
env_file = getenv("K12_DEBUG_FILENAME");
if ( env_file ) {
- dbg_out = ws_fopen(env_file,"w");
- if (dbg_out == NULL) {
- dbg_out = stderr;
- K12_DBG(1,("unable to open K12 DEBUG FILENAME for writing! Logging to standard error"));
- }
+ dbg_out = ws_fopen(env_file,"w");
+ if (dbg_out == NULL) {
+ dbg_out = stderr;
+ K12_DBG(1,("unable to open K12 DEBUG FILENAME for writing! Logging to standard error"));
+ }
}
else
- dbg_out = stderr;
+ dbg_out = stderr;
if ( env_level ) debug_level = (unsigned int)strtoul(env_level,NULL,10);
K12_DBG(1,("k12_open: ENTER debug_level=%u",debug_level));
#endif
@@ -861,8 +861,8 @@ wtap_open_return_val k12_open(wtap *wth, int *err, gchar **err_info) {
if (memiszero(header_buffer + 0x10, K12_FILE_HDR_LEN - 0x10)) {
/*
* The rest of the file header is all zeroes. That means
- * this is a file written by the old Wireshark code, and
- * a count of records in the file is at an offset of 0x0C.
+ * this is a file written by the old Wireshark code, and
+ * a count of records in the file is at an offset of 0x0C.
*/
file_data->num_of_records = pntoh32( header_buffer + 0x0C );
} else {
@@ -1094,9 +1094,9 @@ wtap_open_return_val k12_open(wtap *wth, int *err, gchar **err_info) {
}
typedef struct {
- guint32 file_len;
- guint32 num_of_records;
- guint32 file_offset;
+ guint32 file_len;
+ guint32 num_of_records;
+ guint32 file_offset;
} k12_dump_t;
int k12_dump_can_write_encap(int encap) {
@@ -1372,3 +1372,16 @@ gboolean k12_dump_open(wtap_dumper *wdh, int *err) {
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c
index ae535d31c6..dfa7f7cc00 100644
--- a/wiretap/lanalyzer.c
+++ b/wiretap/lanalyzer.c
@@ -35,8 +35,8 @@
/* Record header format */
typedef struct {
- guint8 record_type[2];
- guint8 record_length[2];
+ guint8 record_type[2];
+ guint8 record_length[2];
} LA_RecordHeader;
#define LA_RecordHeaderSize 4
@@ -278,286 +278,286 @@ static gboolean lanalyzer_dump_close(wtap_dumper *wdh, int *err);
wtap_open_return_val lanalyzer_open(wtap *wth, int *err, gchar **err_info)
{
- LA_RecordHeader rec_header;
- char header_fixed[2];
- char *comment;
- char summary[210];
- guint16 board_type, mxslc;
- guint16 record_type, record_length;
- guint8 cr_day, cr_month;
- guint16 cr_year;
- struct tm tm;
- 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 */
- if (record_length < 2) {
- /*
- * 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)) {
- if (*err != WTAP_ERR_SHORT_READ)
- return WTAP_OPEN_ERROR;
- return WTAP_OPEN_NOT_MINE;
- }
- comment[record_length] = '\0';
- wth->shb_hdr.opt_comment = comment;
- }
-
- /* If we made it this far, then the file is a LANAlyzer file.
- * Let's get some info from it. Note that we get wth->snapshot_length
- * from a record later in the file. */
- wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_LANALYZER;
- lanalyzer = (lanalyzer_t *)g_malloc(sizeof(lanalyzer_t));
- wth->priv = (void *)lanalyzer;
- wth->subtype_read = lanalyzer_read;
- wth->subtype_seek_read = lanalyzer_seek_read;
- wth->snapshot_length = 0;
- wth->file_tsprec = WTAP_TSPREC_NSEC;
-
- /* Read records until we find the start of packets */
- 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.
- */
- return WTAP_OPEN_MINE;
- }
- return WTAP_OPEN_ERROR;
- }
-
- record_type = pletoh16(rec_header.record_type);
- record_length = pletoh16(rec_header.record_length);
-
- /*g_message("Record 0x%04X Length %d", record_type, record_length);*/
- switch (record_type) {
- /* Trace Summary Record */
- case RT_Summary:
- 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]);
- /*g_message("Day %d Month %d Year %d (%04X)", cr_day, cr_month,
- 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;
- lanalyzer->start = mktime(&tm);
- /*g_message("Day %d Month %d Year %d", tm.tm_mday,
- tm.tm_mon, tm.tm_year);*/
- mxslc = pletoh16(&summary[30]);
- wth->snapshot_length = mxslc;
-
- board_type = pletoh16(&summary[188]);
- switch (board_type) {
- case BOARD_325:
- wth->file_encap = WTAP_ENCAP_ETHERNET;
- break;
- case BOARD_325TR:
- wth->file_encap = WTAP_ENCAP_TOKEN_RING;
- break;
- default:
- *err = WTAP_ERR_UNSUPPORTED;
- *err_info = g_strdup_printf("lanalyzer: board type %u unknown",
+ LA_RecordHeader rec_header;
+ char header_fixed[2];
+ char *comment;
+ char summary[210];
+ guint16 board_type, mxslc;
+ guint16 record_type, record_length;
+ guint8 cr_day, cr_month;
+ guint16 cr_year;
+ struct tm tm;
+ 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 */
+ if (record_length < 2) {
+ /*
+ * 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)) {
+ if (*err != WTAP_ERR_SHORT_READ)
+ return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_NOT_MINE;
+ }
+ comment[record_length] = '\0';
+ wth->shb_hdr.opt_comment = comment;
+ }
+
+ /* If we made it this far, then the file is a LANAlyzer file.
+ * Let's get some info from it. Note that we get wth->snapshot_length
+ * from a record later in the file. */
+ wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_LANALYZER;
+ lanalyzer = (lanalyzer_t *)g_malloc(sizeof(lanalyzer_t));
+ wth->priv = (void *)lanalyzer;
+ wth->subtype_read = lanalyzer_read;
+ wth->subtype_seek_read = lanalyzer_seek_read;
+ wth->snapshot_length = 0;
+ wth->file_tsprec = WTAP_TSPREC_NSEC;
+
+ /* Read records until we find the start of packets */
+ 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.
+ */
+ return WTAP_OPEN_MINE;
+ }
+ return WTAP_OPEN_ERROR;
+ }
+
+ record_type = pletoh16(rec_header.record_type);
+ record_length = pletoh16(rec_header.record_length);
+
+ /*g_message("Record 0x%04X Length %d", record_type, record_length);*/
+ switch (record_type) {
+ /* Trace Summary Record */
+ case RT_Summary:
+ 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]);
+ /*g_message("Day %d Month %d Year %d (%04X)", cr_day, cr_month,
+ 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;
+ lanalyzer->start = mktime(&tm);
+ /*g_message("Day %d Month %d Year %d", tm.tm_mday,
+ tm.tm_mon, tm.tm_year);*/
+ mxslc = pletoh16(&summary[30]);
+ wth->snapshot_length = mxslc;
+
+ board_type = pletoh16(&summary[188]);
+ switch (board_type) {
+ case BOARD_325:
+ wth->file_encap = WTAP_ENCAP_ETHERNET;
+ break;
+ case BOARD_325TR:
+ wth->file_encap = WTAP_ENCAP_TOKEN_RING;
+ break;
+ default:
+ *err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("lanalyzer: board type %u unknown",
board_type);
- return WTAP_OPEN_ERROR;
- }
- 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;
- }
- return WTAP_OPEN_MINE;
-
- default:
- if (file_seek(wth->fh, record_length, SEEK_CUR, err) == -1) {
- return WTAP_OPEN_ERROR;
- }
- break;
- }
- }
+ return WTAP_OPEN_ERROR;
+ }
+ 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;
+ }
+ return WTAP_OPEN_MINE;
+
+ default:
+ if (file_seek(wth->fh, record_length, SEEK_CUR, err) == -1) {
+ return WTAP_OPEN_ERROR;
+ }
+ break;
+ }
+ }
}
#define DESCRIPTOR_LEN 32
static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
- struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
+ struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
{
- 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;
-
- /* 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;
+ 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;
+
+ /* 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;
+ *err_info = g_strdup_printf("lanalyzer: record type %u seen after trace summary record",
+ record_type);
+ return FALSE;
+ }
- record_type = pletoh16(LE_record_type);
- record_length = pletoh16(LE_record_length);
+ if (record_length < DESCRIPTOR_LEN) {
+ /*
+ * Uh-oh, the record isn't big enough to even have a
+ * descriptor.
+ */
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup_printf("lanalyzer: file has a %u-byte record, too small to have even a packet descriptor",
+ record_length);
+ return FALSE;
+ }
+ record_data_size = record_length - DESCRIPTOR_LEN;
- /* 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;
- *err_info = g_strdup_printf("lanalyzer: record type %u seen after trace summary record",
- record_type);
- return FALSE;
- }
-
- if (record_length < DESCRIPTOR_LEN) {
- /*
- * Uh-oh, the record isn't big enough to even have a
- * descriptor.
- */
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup_printf("lanalyzer: file has a %u-byte record, too small to have even a packet descriptor",
- record_length);
- return FALSE;
- }
- record_data_size = record_length - DESCRIPTOR_LEN;
+ /* Read the descriptor data */
+ if (!wtap_read_bytes(fh, descriptor, DESCRIPTOR_LEN, err, err_info))
+ return FALSE;
- /* Read the descriptor data */
- if (!wtap_read_bytes(fh, descriptor, DESCRIPTOR_LEN, err, err_info))
- return FALSE;
+ true_size = pletoh16(&descriptor[4]);
+ packet_size = pletoh16(&descriptor[6]);
- true_size = pletoh16(&descriptor[4]);
- packet_size = pletoh16(&descriptor[6]);
-
- /*
- * OK, is the frame data size greater than than what's left of the
- * 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;
- }
+ /*
+ * OK, is the frame data size greater than than what's left of the
+ * 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;
+ }
- phdr->rec_type = REC_TYPE_PACKET;
- phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
+ phdr->rec_type = REC_TYPE_PACKET;
+ phdr->presence_flags = WTAP_HAS_TS|WTAP_HAS_CAP_LEN;
- time_low = pletoh16(&descriptor[8]);
- time_med = pletoh16(&descriptor[10]);
- time_high = pletoh16(&descriptor[12]);
- t = (((guint64)time_low) << 0) + (((guint64)time_med) << 16) +
+ time_low = pletoh16(&descriptor[8]);
+ time_med = pletoh16(&descriptor[10]);
+ time_high = pletoh16(&descriptor[12]);
+ t = (((guint64)time_low) << 0) + (((guint64)time_med) << 16) +
(((guint64)time_high) << 32);
- tsecs = (time_t) (t/2000000);
- lanalyzer = (lanalyzer_t *)wth->priv;
- phdr->ts.secs = tsecs + lanalyzer->start;
- phdr->ts.nsecs = ((guint32) (t - tsecs*2000000)) * 500;
-
- 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;
- }
- phdr->len = true_size;
- phdr->caplen = packet_size;
-
- switch (wth->file_encap) {
-
- case WTAP_ENCAP_ETHERNET:
- /* We assume there's no FCS in this frame. */
- phdr->pseudo_header.eth.fcs_len = 0;
- break;
- }
-
- /* Read the packet data */
- return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
+ tsecs = (time_t) (t/2000000);
+ lanalyzer = (lanalyzer_t *)wth->priv;
+ phdr->ts.secs = tsecs + lanalyzer->start;
+ phdr->ts.nsecs = ((guint32) (t - tsecs*2000000)) * 500;
+
+ 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;
+ }
+ phdr->len = true_size;
+ phdr->caplen = packet_size;
+
+ switch (wth->file_encap) {
+
+ case WTAP_ENCAP_ETHERNET:
+ /* We assume there's no FCS in this frame. */
+ phdr->pseudo_header.eth.fcs_len = 0;
+ break;
+ }
+
+ /* Read the packet data */
+ return wtap_read_packet_bytes(fh, buf, packet_size, err, err_info);
}
/* Read the next packet */
static gboolean lanalyzer_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset)
+ gint64 *data_offset)
{
- *data_offset = file_tell(wth->fh);
+ *data_offset = file_tell(wth->fh);
- /* Read the record */
- return lanalyzer_read_trace_record(wth, wth->fh, &wth->phdr,
- wth->frame_buffer, err, err_info);
+ /* Read the record */
+ return lanalyzer_read_trace_record(wth, wth->fh, &wth->phdr,
+ wth->frame_buffer, err, err_info);
}
static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
+ struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
{
- if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
- return FALSE;
+ if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
+ return FALSE;
- /* Read the record */
- if (!lanalyzer_read_trace_record(wth, wth->random_fh, phdr, buf,
- err, err_info)) {
- if (*err == 0)
- *err = WTAP_ERR_SHORT_READ;
- return FALSE;
- }
- return TRUE;
+ /* Read the record */
+ if (!lanalyzer_read_trace_record(wth, wth->random_fh, phdr, buf,
+ err, err_info)) {
+ if (*err == 0)
+ *err = WTAP_ERR_SHORT_READ;
+ return FALSE;
+ }
+ return TRUE;
}
/*---------------------------------------------------
@@ -566,16 +566,16 @@ static gboolean lanalyzer_seek_read(wtap *wth, gint64 seek_off,
*---------------------------------------------------*/
static gboolean s0write(wtap_dumper *wdh, size_t cnt, int *err)
{
- size_t snack;
+ size_t snack;
- while (cnt) {
- snack = cnt > 64 ? 64 : cnt;
+ while (cnt) {
+ snack = cnt > 64 ? 64 : cnt;
- if (!wtap_dump_file_write(wdh, z64, snack, err))
- return FALSE;
- cnt -= snack;
- }
- return TRUE; /* ok */
+ if (!wtap_dump_file_write(wdh, z64, snack, err))
+ return FALSE;
+ cnt -= snack;
+ }
+ return TRUE; /* ok */
}
/*---------------------------------------------------
@@ -584,7 +584,7 @@ static gboolean s0write(wtap_dumper *wdh, size_t cnt, int *err)
*---------------------------------------------------*/
static gboolean s8write(wtap_dumper *wdh, const guint8 s8, int *err)
{
- return wtap_dump_file_write(wdh, &s8, 1, err);
+ return wtap_dump_file_write(wdh, &s8, 1, err);
}
/*---------------------------------------------------
* Returns TRUE on success, FALSE on error
@@ -592,7 +592,7 @@ static gboolean s8write(wtap_dumper *wdh, const guint8 s8, int *err)
*---------------------------------------------------*/
static gboolean s16write(wtap_dumper *wdh, const guint16 s16, int *err)
{
- return wtap_dump_file_write(wdh, &s16, 2, err);
+ return wtap_dump_file_write(wdh, &s16, 2, err);
}
/*---------------------------------------------------
* Returns TRUE on success, FALSE on error
@@ -600,7 +600,7 @@ static gboolean s16write(wtap_dumper *wdh, const guint16 s16, int *err)
*---------------------------------------------------*/
static gboolean s32write(wtap_dumper *wdh, const guint32 s32, int *err)
{
- return wtap_dump_file_write(wdh, &s32, 4, err);
+ return wtap_dump_file_write(wdh, &s32, 4, err);
}
/*---------------------------------------------------
*
@@ -916,3 +916,16 @@ static gboolean lanalyzer_dump_close(wtap_dumper *wdh, int *err)
lanalyzer_dump_header(wdh,err);
return *err ? FALSE : TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * 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:
+ */
diff --git a/wiretap/libpcap.c b/wiretap/libpcap.c
index 19712f1ee5..065f85d448 100644
--- a/wiretap/libpcap.c
+++ b/wiretap/libpcap.c
@@ -566,21 +566,21 @@ static int libpcap_try_header(wtap *wth, FILE_T fh, int *err, gchar **err_info,
ret++;
}
- if (hdr->hdr.orig_len > 64*1024*1024) {
- /*
- * In theory I guess the on-the-wire packet size can be
- * arbitrarily large, and it can certainly be larger than the
- * maximum snapshot length which bounds the snapshot size,
- * but any file claiming 64MB in a single packet is *probably*
- * corrupt, and treating them as such makes the heuristics
- * much more reliable. See, for example,
- *
- * https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9634
- *
- * (64MB is an arbitrary size at this point).
- */
- ret++;
- }
+ if (hdr->hdr.orig_len > 64*1024*1024) {
+ /*
+ * In theory I guess the on-the-wire packet size can be
+ * arbitrarily large, and it can certainly be larger than the
+ * maximum snapshot length which bounds the snapshot size,
+ * but any file claiming 64MB in a single packet is *probably*
+ * corrupt, and treating them as such makes the heuristics
+ * much more reliable. See, for example,
+ *
+ * https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9634
+ *
+ * (64MB is an arbitrary size at this point).
+ */
+ ret++;
+ }
if (hdr->hdr.incl_len > wth->snapshot_length) {
/*
@@ -995,6 +995,19 @@ static gboolean libpcap_dump(wtap_dumper *wdh,
if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
return FALSE;
- wdh->bytes_dumped += phdr->caplen;
+ wdh->bytes_dumped += phdr->caplen;
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/merge.c b/wiretap/merge.c
index bf10f4ccdc..3b320fa53b 100644
--- a/wiretap/merge.c
+++ b/wiretap/merge.c
@@ -284,3 +284,16 @@ merge_append_read_packet(int in_file_count, merge_in_file_t in_files[],
*err = 0;
return &in_files[i];
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local Variables:
+ * c-basic-offset: 2
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=2 tabstop=8 expandtab:
+ * :indentSize=2:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/mime_file.c b/wiretap/mime_file.c
index f42ac76b9d..a22c8b7120 100644
--- a/wiretap/mime_file.c
+++ b/wiretap/mime_file.c
@@ -211,3 +211,16 @@ mime_file_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/mp2t.c b/wiretap/mp2t.c
index da82a2c809..f7d7f26920 100644
--- a/wiretap/mp2t.c
+++ b/wiretap/mp2t.c
@@ -85,7 +85,7 @@ mp2t_read_packet(mp2t_filetype_t *mp2t, FILE_T fh, gint64 offset,
*
* It would be really cool to be able to configure the bitrate...
*/
- tmp = ((guint64)(offset - mp2t->start_offset) * 8); /* offset, in bits */
+ tmp = ((guint64)(offset - mp2t->start_offset) * 8); /* offset, in bits */
phdr->ts.secs = (time_t)(tmp / MP2T_QAM256_BITRATE);
phdr->ts.nsecs = (int)((tmp % MP2T_QAM256_BITRATE) * 1000000000 / MP2T_QAM256_BITRATE);
@@ -227,3 +227,16 @@ mp2t_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/mpeg.c b/wiretap/mpeg.c
index 304d1d73cc..f572237ea2 100644
--- a/wiretap/mpeg.c
+++ b/wiretap/mpeg.c
@@ -272,3 +272,16 @@ good_magic:
return WTAP_OPEN_MINE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/netmon.c b/wiretap/netmon.c
index 3bb57763a7..d672378f8d 100644
--- a/wiretap/netmon.c
+++ b/wiretap/netmon.c
@@ -1338,3 +1338,16 @@ static gboolean netmon_dump_close(wtap_dumper *wdh, int *err)
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/netscaler.c b/wiretap/netscaler.c
index 9b9000c281..29850281a6 100644
--- a/wiretap/netscaler.c
+++ b/wiretap/netscaler.c
@@ -1912,3 +1912,16 @@ static gboolean nstrace_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/netscreen.c b/wiretap/netscreen.c
index cce6924463..11c5fea7fd 100644
--- a/wiretap/netscreen.c
+++ b/wiretap/netscreen.c
@@ -389,8 +389,8 @@ parse_netscreen_hex_dump(FILE_T fh, int pkt_len, const char *cap_int,
*/
if(offset > pkt_len) {
*err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("netscreen: too much hex-data");
- return FALSE;
+ *err_info = g_strdup("netscreen: too much hex-data");
+ return FALSE;
}
}
@@ -398,23 +398,23 @@ parse_netscreen_hex_dump(FILE_T fh, int pkt_len, const char *cap_int,
* Determine the encapsulation type, based on the
* first 4 characters of the interface name
*
- * XXX convert this to a 'case' structure when adding more
- * (non-ethernet) interfacetypes
+ * XXX convert this to a 'case' structure when adding more
+ * (non-ethernet) interfacetypes
*/
if (strncmp(cap_int, "adsl", 4) == 0) {
- /* The ADSL interface can be bridged with or without
- * PPP encapsulation. Check whether the first six bytes
- * of the hex data are the same as the destination mac
- * address in the header. If they are, assume ethernet
- * LinkLayer or else PPP
- */
- g_snprintf(dststr, 13, "%02x%02x%02x%02x%02x%02x",
- pd[0], pd[1], pd[2], pd[3], pd[4], pd[5]);
- if (strncmp(dststr, cap_dst, 12) == 0)
- phdr->pkt_encap = WTAP_ENCAP_ETHERNET;
- else
- phdr->pkt_encap = WTAP_ENCAP_PPP;
- }
+ /* The ADSL interface can be bridged with or without
+ * PPP encapsulation. Check whether the first six bytes
+ * of the hex data are the same as the destination mac
+ * address in the header. If they are, assume ethernet
+ * LinkLayer or else PPP
+ */
+ g_snprintf(dststr, 13, "%02x%02x%02x%02x%02x%02x",
+ pd[0], pd[1], pd[2], pd[3], pd[4], pd[5]);
+ if (strncmp(dststr, cap_dst, 12) == 0)
+ phdr->pkt_encap = WTAP_ENCAP_ETHERNET;
+ else
+ phdr->pkt_encap = WTAP_ENCAP_PPP;
+ }
else if (strncmp(cap_int, "seri", 4) == 0)
phdr->pkt_encap = WTAP_ENCAP_PPP;
else
@@ -476,3 +476,16 @@ parse_single_hex_dump_line(char* rec, guint8 *buf, guint byte_offset)
return num_items_scanned;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/nettl.c b/wiretap/nettl.c
index 8c93af940d..9880ff5872 100644
--- a/wiretap/nettl.c
+++ b/wiretap/nettl.c
@@ -34,7 +34,7 @@
/* HP nettl file header */
/* Magic number size */
-#define MAGIC_SIZE 12
+#define MAGIC_SIZE 12
/* HP-UX 9.x */
static const guint8 nettl_magic_hpux9[MAGIC_SIZE] = {
@@ -45,37 +45,37 @@ static const guint8 nettl_magic_hpux10[MAGIC_SIZE] = {
0x54, 0x52, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80
};
-#define FILE_HDR_SIZE 128
+#define FILE_HDR_SIZE 128
#define NETTL_FILENAME_SIZE 56
struct nettl_file_hdr {
- guint8 magic[MAGIC_SIZE];
- gchar file_name[NETTL_FILENAME_SIZE];
- gchar tz[20];
- gchar host_name[9];
- gchar os_vers[9];
- guint8 os_v;
- guint8 xxa[8];
- gchar model[11];
- guint16 unknown; /* just padding to 128 bytes? */
+ guint8 magic[MAGIC_SIZE];
+ gchar file_name[NETTL_FILENAME_SIZE];
+ gchar tz[20];
+ gchar host_name[9];
+ gchar os_vers[9];
+ guint8 os_v;
+ guint8 xxa[8];
+ gchar model[11];
+ guint16 unknown; /* just padding to 128 bytes? */
};
/* HP nettl record header */
/* see /usr/include/sys/netdiag1.h for hints */
struct nettlrec_hdr {
- guint16 hdr_len;
- guint16 subsys;
- guint32 devid;
- guint8 xxa[4];
- guint32 kind;
- guint8 xxb[16];
- guint32 caplen;
- guint32 length;
- guint32 sec;
- guint32 usec;
- guint32 pid;
- guint8 xxc[10];
- guint16 uid;
+ guint16 hdr_len;
+ guint16 subsys;
+ guint32 devid;
+ guint8 xxa[4];
+ guint32 kind;
+ guint8 xxb[16];
+ guint32 caplen;
+ guint32 length;
+ guint32 sec;
+ guint32 usec;
+ guint32 pid;
+ guint8 xxc[10];
+ guint16 uid;
};
/*
@@ -83,20 +83,20 @@ struct nettlrec_hdr {
* It is *not* necessarily the same as sizeof(struct nettlrec_hdr),
* because it doesn't include any padding added to the structure.
*/
-#define NETTL_REC_HDR_LEN 64
+#define NETTL_REC_HDR_LEN 64
/* HP nettl record header for the SX25L2 subsystem - The FCS is not included
in the file. */
struct nettlrec_sx25l2_hdr {
- guint8 xxa[8];
- guint8 from_dce;
- guint8 xxb[55];
- guint8 caplen[2];
- guint8 length[2];
- guint8 xxc[4];
- guint8 sec[4];
- guint8 usec[4];
- guint8 xxd[4];
+ guint8 xxa[8];
+ guint8 from_dce;
+ guint8 xxb[55];
+ guint8 caplen[2];
+ guint8 length[2];
+ guint8 xxc[4];
+ guint8 sec[4];
+ guint8 usec[4];
+ guint8 xxd[4];
};
/* NL_LS_DRIVER :
@@ -145,21 +145,21 @@ distinguish between different types of link specific headers.
For now, the subheader for 100baseT seems to be
- 4-5 captured length
- 6-7 actual length
- 8-11 unknown
- 12-15 secs
- 16-19 usecs
- 20-21 unknown
+ 4-5 captured length
+ 6-7 actual length
+ 8-11 unknown
+ 12-15 secs
+ 16-19 usecs
+ 20-21 unknown
*/
struct nettlrec_ns_ls_drv_eth_hdr {
- guint8 xxa[4];
+ guint8 xxa[4];
guint8 caplen[2];
guint8 length[2];
- guint8 xxb[4];
- guint8 sec[4];
- guint8 usec[4];
- guint8 xxc[2];
+ guint8 xxb[4];
+ guint8 sec[4];
+ guint8 usec[4];
+ guint8 xxc[2];
};
/*
@@ -167,21 +167,21 @@ struct nettlrec_ns_ls_drv_eth_hdr {
* the same as sizeof(struct nettlrec_ns_ls_drv_eth_hdr), because it
* doesn't include any padding added to the structure.
*/
-#define NS_LS_DRV_ETH_HDR_LEN 22
+#define NS_LS_DRV_ETH_HDR_LEN 22
/* header is followed by data and once again the total length (2 bytes) ! */
typedef struct {
- gboolean is_hpux_11;
+ gboolean is_hpux_11;
} nettl_t;
static gboolean nettl_read(wtap *wth, int *err, gchar **err_info,
- gint64 *data_offset);
+ gint64 *data_offset);
static gboolean nettl_seek_read(wtap *wth, gint64 seek_off,
- struct wtap_pkthdr *phdr, Buffer *buf,
- int *err, gchar **err_info);
+ struct wtap_pkthdr *phdr, Buffer *buf,
+ int *err, gchar **err_info);
static gboolean nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
- Buffer *buf, int *err, gchar **err_info);
+ Buffer *buf, int *err, gchar **err_info);
static gboolean nettl_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const guint8 *pd, int *err, gchar **err_info);
@@ -203,25 +203,25 @@ wtap_open_return_val nettl_open(wtap *wth, int *err, gchar **err_info)
if (memcmp(file_hdr.magic, nettl_magic_hpux9, MAGIC_SIZE) &&
memcmp(file_hdr.magic, nettl_magic_hpux10, MAGIC_SIZE)) {
- return WTAP_OPEN_NOT_MINE;
+ return WTAP_OPEN_NOT_MINE;
}
/* Read the rest of the file header */
if (!wtap_read_bytes(wth->fh, file_hdr.file_name, FILE_HDR_SIZE - MAGIC_SIZE,
err, err_info))
- return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_ERROR;
/* This is an nettl file */
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_NETTL;
nettl = g_new(nettl_t,1);
wth->priv = (void *)nettl;
if (file_hdr.os_vers[2] == '1' && file_hdr.os_vers[3] == '1')
- nettl->is_hpux_11 = TRUE;
+ nettl->is_hpux_11 = TRUE;
else
- nettl->is_hpux_11 = FALSE;
+ nettl->is_hpux_11 = FALSE;
wth->subtype_read = nettl_read;
wth->subtype_seek_read = nettl_seek_read;
- wth->snapshot_length = 0; /* not available */
+ wth->snapshot_length = 0; /* not available */
/* read the first header to take a guess at the file encap */
if (!wtap_read_bytes_or_eof(wth->fh, dummy, 4, err, err_info)) {
@@ -627,27 +627,27 @@ nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
int nettl_dump_can_write_encap(int encap)
{
- switch (encap) {
- case WTAP_ENCAP_ETHERNET:
- case WTAP_ENCAP_FDDI_BITSWAPPED:
- case WTAP_ENCAP_TOKEN_RING:
- case WTAP_ENCAP_NETTL_ETHERNET:
- case WTAP_ENCAP_NETTL_FDDI:
- case WTAP_ENCAP_NETTL_TOKEN_RING:
- case WTAP_ENCAP_NETTL_RAW_IP:
- case WTAP_ENCAP_NETTL_RAW_ICMP:
- case WTAP_ENCAP_NETTL_RAW_ICMPV6:
- case WTAP_ENCAP_NETTL_RAW_TELNET:
+ switch (encap) {
+ case WTAP_ENCAP_ETHERNET:
+ case WTAP_ENCAP_FDDI_BITSWAPPED:
+ case WTAP_ENCAP_TOKEN_RING:
+ case WTAP_ENCAP_NETTL_ETHERNET:
+ case WTAP_ENCAP_NETTL_FDDI:
+ case WTAP_ENCAP_NETTL_TOKEN_RING:
+ case WTAP_ENCAP_NETTL_RAW_IP:
+ case WTAP_ENCAP_NETTL_RAW_ICMP:
+ case WTAP_ENCAP_NETTL_RAW_ICMPV6:
+ case WTAP_ENCAP_NETTL_RAW_TELNET:
/*
- case WTAP_ENCAP_NETTL_X25:
+ case WTAP_ENCAP_NETTL_X25:
*/
- case WTAP_ENCAP_PER_PACKET:
- case WTAP_ENCAP_UNKNOWN:
- case WTAP_ENCAP_NETTL_UNKNOWN:
- return 0;
- default:
- return WTAP_ERR_UNWRITABLE_ENCAP;
- }
+ case WTAP_ENCAP_PER_PACKET:
+ case WTAP_ENCAP_UNKNOWN:
+ case WTAP_ENCAP_NETTL_UNKNOWN:
+ return 0;
+ default:
+ return WTAP_ERR_UNWRITABLE_ENCAP;
+ }
}
@@ -655,151 +655,164 @@ int nettl_dump_can_write_encap(int encap)
sets "*err" to an error code on failure */
gboolean nettl_dump_open(wtap_dumper *wdh, int *err)
{
- struct nettl_file_hdr file_hdr;
-
- /* This is a nettl file */
- wdh->subtype_write = nettl_dump;
- wdh->subtype_close = NULL;
-
- /* Write the file header. */
- memset(&file_hdr,0,sizeof(file_hdr));
- memcpy(file_hdr.magic,nettl_magic_hpux10,sizeof(file_hdr.magic));
- g_strlcpy(file_hdr.file_name,"/tmp/wireshark.TRC000",NETTL_FILENAME_SIZE);
- g_strlcpy(file_hdr.tz,"UTC",20);
- g_strlcpy(file_hdr.host_name,"",9);
- g_strlcpy(file_hdr.os_vers,"B.11.11",9);
- file_hdr.os_v=0x55;
- g_strlcpy(file_hdr.model,"9000/800",11);
- file_hdr.unknown=g_htons(0x406);
- if (!wtap_dump_file_write(wdh, &file_hdr, sizeof file_hdr, err))
- return FALSE;
- wdh->bytes_dumped += sizeof(file_hdr);
+ struct nettl_file_hdr file_hdr;
+
+ /* This is a nettl file */
+ wdh->subtype_write = nettl_dump;
+ wdh->subtype_close = NULL;
+
+ /* Write the file header. */
+ memset(&file_hdr,0,sizeof(file_hdr));
+ memcpy(file_hdr.magic,nettl_magic_hpux10,sizeof(file_hdr.magic));
+ g_strlcpy(file_hdr.file_name,"/tmp/wireshark.TRC000",NETTL_FILENAME_SIZE);
+ g_strlcpy(file_hdr.tz,"UTC",20);
+ g_strlcpy(file_hdr.host_name,"",9);
+ g_strlcpy(file_hdr.os_vers,"B.11.11",9);
+ file_hdr.os_v=0x55;
+ g_strlcpy(file_hdr.model,"9000/800",11);
+ file_hdr.unknown=g_htons(0x406);
+ if (!wtap_dump_file_write(wdh, &file_hdr, sizeof file_hdr, err))
+ return FALSE;
+ wdh->bytes_dumped += sizeof(file_hdr);
- return TRUE;
+ return TRUE;
}
/* Write a record for a packet to a dump file.
Returns TRUE on success, FALSE on failure. */
static gboolean nettl_dump(wtap_dumper *wdh,
- const struct wtap_pkthdr *phdr,
- const guint8 *pd, int *err, gchar **err_info _U_)
+ const struct wtap_pkthdr *phdr,
+ const guint8 *pd, int *err, gchar **err_info _U_)
{
- const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
- struct nettlrec_hdr rec_hdr;
- guint8 dummyc[24];
+ const union wtap_pseudo_header *pseudo_header = &phdr->pseudo_header;
+ struct nettlrec_hdr rec_hdr;
+ guint8 dummyc[24];
- /* We can only write packet records. */
- if (phdr->rec_type != REC_TYPE_PACKET) {
- *err = WTAP_ERR_UNWRITABLE_REC_TYPE;
- return FALSE;
- }
+ /* We can only write packet records. */
+ if (phdr->rec_type != REC_TYPE_PACKET) {
+ *err = WTAP_ERR_UNWRITABLE_REC_TYPE;
+ return FALSE;
+ }
- /* Don't write anything we're not willing to read. */
- if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
- *err = WTAP_ERR_PACKET_TOO_LARGE;
- return FALSE;
- }
+ /* Don't write anything we're not willing to read. */
+ if (phdr->caplen > WTAP_MAX_PACKET_SIZE) {
+ *err = WTAP_ERR_PACKET_TOO_LARGE;
+ return FALSE;
+ }
- memset(&rec_hdr,0,sizeof(rec_hdr));
- /* HP-UX 11.X header should be 68 bytes */
- rec_hdr.hdr_len = g_htons(sizeof(rec_hdr) + 4);
- rec_hdr.kind = g_htonl(NETTL_HDR_PDUIN);
- rec_hdr.sec = g_htonl(phdr->ts.secs);
- rec_hdr.usec = g_htonl(phdr->ts.nsecs/1000);
- rec_hdr.caplen = g_htonl(phdr->caplen);
- rec_hdr.length = g_htonl(phdr->len);
- rec_hdr.devid = -1;
- rec_hdr.pid = -1;
- rec_hdr.uid = -1;
-
- switch (phdr->pkt_encap) {
-
- case WTAP_ENCAP_NETTL_FDDI:
- /* account for pad bytes */
- rec_hdr.caplen = g_htonl(phdr->caplen + 3);
- rec_hdr.length = g_htonl(phdr->len + 3);
- /* fall through and fill the rest of the fields */
- case WTAP_ENCAP_NETTL_ETHERNET:
- case WTAP_ENCAP_NETTL_TOKEN_RING:
- case WTAP_ENCAP_NETTL_RAW_IP:
- case WTAP_ENCAP_NETTL_RAW_ICMP:
- case WTAP_ENCAP_NETTL_RAW_ICMPV6:
- case WTAP_ENCAP_NETTL_RAW_TELNET:
- case WTAP_ENCAP_NETTL_UNKNOWN:
- rec_hdr.subsys = g_htons(pseudo_header->nettl.subsys);
- rec_hdr.devid = g_htonl(pseudo_header->nettl.devid);
- rec_hdr.kind = g_htonl(pseudo_header->nettl.kind);
- rec_hdr.pid = g_htonl(pseudo_header->nettl.pid);
- rec_hdr.uid = g_htons(pseudo_header->nettl.uid);
- break;
-
- case WTAP_ENCAP_RAW_IP:
- rec_hdr.subsys = g_htons(NETTL_SUBSYS_NS_LS_IP);
- break;
-
- case WTAP_ENCAP_ETHERNET:
- rec_hdr.subsys = g_htons(NETTL_SUBSYS_BTLAN);
- break;
-
- case WTAP_ENCAP_FDDI_BITSWAPPED:
- rec_hdr.subsys = g_htons(NETTL_SUBSYS_PCI_FDDI);
- /* account for pad bytes */
- rec_hdr.caplen = g_htonl(phdr->caplen + 3);
- rec_hdr.length = g_htonl(phdr->len + 3);
- break;
-
- case WTAP_ENCAP_TOKEN_RING:
- rec_hdr.subsys = g_htons(NETTL_SUBSYS_PCI_TR);
- break;
+ memset(&rec_hdr,0,sizeof(rec_hdr));
+ /* HP-UX 11.X header should be 68 bytes */
+ rec_hdr.hdr_len = g_htons(sizeof(rec_hdr) + 4);
+ rec_hdr.kind = g_htonl(NETTL_HDR_PDUIN);
+ rec_hdr.sec = g_htonl(phdr->ts.secs);
+ rec_hdr.usec = g_htonl(phdr->ts.nsecs/1000);
+ rec_hdr.caplen = g_htonl(phdr->caplen);
+ rec_hdr.length = g_htonl(phdr->len);
+ rec_hdr.devid = -1;
+ rec_hdr.pid = -1;
+ rec_hdr.uid = -1;
+
+ switch (phdr->pkt_encap) {
+
+ case WTAP_ENCAP_NETTL_FDDI:
+ /* account for pad bytes */
+ rec_hdr.caplen = g_htonl(phdr->caplen + 3);
+ rec_hdr.length = g_htonl(phdr->len + 3);
+ /* fall through and fill the rest of the fields */
+ case WTAP_ENCAP_NETTL_ETHERNET:
+ case WTAP_ENCAP_NETTL_TOKEN_RING:
+ case WTAP_ENCAP_NETTL_RAW_IP:
+ case WTAP_ENCAP_NETTL_RAW_ICMP:
+ case WTAP_ENCAP_NETTL_RAW_ICMPV6:
+ case WTAP_ENCAP_NETTL_RAW_TELNET:
+ case WTAP_ENCAP_NETTL_UNKNOWN:
+ rec_hdr.subsys = g_htons(pseudo_header->nettl.subsys);
+ rec_hdr.devid = g_htonl(pseudo_header->nettl.devid);
+ rec_hdr.kind = g_htonl(pseudo_header->nettl.kind);
+ rec_hdr.pid = g_htonl(pseudo_header->nettl.pid);
+ rec_hdr.uid = g_htons(pseudo_header->nettl.uid);
+ break;
+
+ case WTAP_ENCAP_RAW_IP:
+ rec_hdr.subsys = g_htons(NETTL_SUBSYS_NS_LS_IP);
+ break;
+
+ case WTAP_ENCAP_ETHERNET:
+ rec_hdr.subsys = g_htons(NETTL_SUBSYS_BTLAN);
+ break;
+
+ case WTAP_ENCAP_FDDI_BITSWAPPED:
+ rec_hdr.subsys = g_htons(NETTL_SUBSYS_PCI_FDDI);
+ /* account for pad bytes */
+ rec_hdr.caplen = g_htonl(phdr->caplen + 3);
+ rec_hdr.length = g_htonl(phdr->len + 3);
+ break;
+
+ case WTAP_ENCAP_TOKEN_RING:
+ rec_hdr.subsys = g_htons(NETTL_SUBSYS_PCI_TR);
+ break;
#if 0
- case WTAP_ENCAP_NETTL_X25:
- rec_hdr.caplen = g_htonl(phdr->caplen + 24);
- rec_hdr.length = g_htonl(phdr->len + 24);
- rec_hdr.subsys = g_htons(pseudo_header->nettl.subsys);
- rec_hdr.devid = g_htonl(pseudo_header->nettl.devid);
- rec_hdr.kind = g_htonl(pseudo_header->nettl.kind);
- rec_hdr.pid = g_htonl(pseudo_header->nettl.pid);
- rec_hdr.uid = g_htons(pseudo_header->nettl.uid);
- break;
+ case WTAP_ENCAP_NETTL_X25:
+ rec_hdr.caplen = g_htonl(phdr->caplen + 24);
+ rec_hdr.length = g_htonl(phdr->len + 24);
+ rec_hdr.subsys = g_htons(pseudo_header->nettl.subsys);
+ rec_hdr.devid = g_htonl(pseudo_header->nettl.devid);
+ rec_hdr.kind = g_htonl(pseudo_header->nettl.kind);
+ rec_hdr.pid = g_htonl(pseudo_header->nettl.pid);
+ rec_hdr.uid = g_htons(pseudo_header->nettl.uid);
+ break;
#endif
- default:
- /* found one we don't support */
- *err = WTAP_ERR_UNWRITABLE_ENCAP;
- return FALSE;
- }
+ default:
+ /* found one we don't support */
+ *err = WTAP_ERR_UNWRITABLE_ENCAP;
+ return FALSE;
+ }
- if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof(rec_hdr), err))
- return FALSE;
- wdh->bytes_dumped += sizeof(rec_hdr);
+ if (!wtap_dump_file_write(wdh, &rec_hdr, sizeof(rec_hdr), err))
+ return FALSE;
+ wdh->bytes_dumped += sizeof(rec_hdr);
- /* Write out 4 extra bytes of unknown stuff for HP-UX11
- * header format.
- */
- memset(dummyc, 0, sizeof dummyc);
- if (!wtap_dump_file_write(wdh, dummyc, 4, err))
- return FALSE;
- wdh->bytes_dumped += 4;
+ /* Write out 4 extra bytes of unknown stuff for HP-UX11
+ * header format.
+ */
+ memset(dummyc, 0, sizeof dummyc);
+ if (!wtap_dump_file_write(wdh, dummyc, 4, err))
+ return FALSE;
+ wdh->bytes_dumped += 4;
- if ((phdr->pkt_encap == WTAP_ENCAP_FDDI_BITSWAPPED) ||
- (phdr->pkt_encap == WTAP_ENCAP_NETTL_FDDI)) {
- /* add those weird 3 bytes of padding */
- if (!wtap_dump_file_write(wdh, dummyc, 3, err))
- return FALSE;
- wdh->bytes_dumped += 3;
- }
+ if ((phdr->pkt_encap == WTAP_ENCAP_FDDI_BITSWAPPED) ||
+ (phdr->pkt_encap == WTAP_ENCAP_NETTL_FDDI)) {
+ /* add those weird 3 bytes of padding */
+ if (!wtap_dump_file_write(wdh, dummyc, 3, err))
+ return FALSE;
+ wdh->bytes_dumped += 3;
+ }
/*
- } else if (phdr->pkt_encap == WTAP_ENCAP_NETTL_X25) {
- if (!wtap_dump_file_write(wdh, dummyc, 24, err))
- return FALSE;
- wdh->bytes_dumped += 24;
- }
+ } else if (phdr->pkt_encap == WTAP_ENCAP_NETTL_X25) {
+ if (!wtap_dump_file_write(wdh, dummyc, 24, err))
+ return FALSE;
+ wdh->bytes_dumped += 24;
+ }
*/
- /* write actual PDU data */
+ /* write actual PDU data */
- if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
- return FALSE;
- wdh->bytes_dumped += phdr->caplen;
+ if (!wtap_dump_file_write(wdh, pd, phdr->caplen, err))
+ return FALSE;
+ wdh->bytes_dumped += phdr->caplen;
- return TRUE;
+ return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/network_instruments.c b/wiretap/network_instruments.c
index 8c3753427e..c873b24a4c 100644
--- a/wiretap/network_instruments.c
+++ b/wiretap/network_instruments.c
@@ -767,3 +767,16 @@ static gint wtap_to_observer_encap(int wtap_encap)
}
return OBSERVER_UNDEFINED;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/ngsniffer.c b/wiretap/ngsniffer.c
index 2eda7663e8..95e117c923 100644
--- a/wiretap/ngsniffer.c
+++ b/wiretap/ngsniffer.c
@@ -2754,3 +2754,16 @@ ng_file_seek_rand(wtap *wth, gint64 offset, int *err, gchar **err_info)
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/packetlogger.c b/wiretap/packetlogger.c
index d863315b46..ebf52d065c 100644
--- a/wiretap/packetlogger.c
+++ b/wiretap/packetlogger.c
@@ -170,3 +170,16 @@ packetlogger_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer
return wtap_read_packet_bytes(fh, buf, phdr->caplen, err, err_info);
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/pcap-common.c b/wiretap/pcap-common.c
index c71ba76f57..263af672fe 100644
--- a/wiretap/pcap-common.c
+++ b/wiretap/pcap-common.c
@@ -801,8 +801,8 @@ wtap_encap_requires_phdr(int encap) {
* I2C link-layer on-disk format
*/
struct i2c_file_hdr {
- guint8 bus;
- guint8 flags[4];
+ guint8 bus;
+ guint8 flags[4];
};
static gboolean
@@ -1065,8 +1065,8 @@ pcap_read_sita_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
* This structure is 8 bytes long.
*/
struct iso_rec {
- gint32 error_count;
- gint32 numdesc;
+ gint32 error_count;
+ gint32 numdesc;
};
/*
@@ -1077,53 +1077,53 @@ struct iso_rec {
* The values are in *host* byte order.
*/
struct linux_usb_phdr {
- guint64 id; /* urb id, to link submission and completion events */
- guint8 event_type; /* Submit ('S'), Completed ('C'), Error ('E') */
- guint8 transfer_type; /* ISO (0), Intr, Control, Bulk (3) */
- guint8 endpoint_number; /* Endpoint number (0-15) and transfer direction */
- guint8 device_address; /* 0-127 */
- guint16 bus_id;
- gint8 setup_flag; /* 0, if the urb setup header is meaningful */
- gint8 data_flag; /* 0, if urb data is present */
- gint64 ts_sec;
- gint32 ts_usec;
- gint32 status;
- guint32 urb_len; /* whole len of urb this event refers to */
- guint32 data_len; /* amount of urb data really present in this event */
-
- /*
- * Packet-type-dependent data.
- * USB setup information of setup_flag is true.
- * Otherwise, some isochronous transfer information.
- */
- union {
- guint8 data[8];
- struct iso_rec iso;
- } s;
-
- /*
- * This data is provided by Linux 2.6.31 and later kernels.
- *
- * For WTAP_ENCAP_USB_LINUX, it's not in the pseudo-header, so
- * the pseudo-header is always 48 bytes long, including the
- * packet-type-dependent data.
- *
- * For WTAP_ENCAP_USB_LINUX_MMAPPED, the pseudo-header is always
- * 64 bytes long, with the packet-type-dependent data preceding
- * these last 16 bytes. In pre-2.6.31 kernels, it's zero padding;
- * in 2.6.31 and later, it's the following data.
- */
- gint32 interval; /* only for Interrupt and Isochronous events */
- gint32 start_frame; /* for Isochronous */
- guint32 xfer_flags; /* copy of URB's transfer_flags */
- guint32 ndesc; /* actual number of isochronous descriptors */
+ guint64 id; /* urb id, to link submission and completion events */
+ guint8 event_type; /* Submit ('S'), Completed ('C'), Error ('E') */
+ guint8 transfer_type; /* ISO (0), Intr, Control, Bulk (3) */
+ guint8 endpoint_number; /* Endpoint number (0-15) and transfer direction */
+ guint8 device_address; /* 0-127 */
+ guint16 bus_id;
+ gint8 setup_flag; /* 0, if the urb setup header is meaningful */
+ gint8 data_flag; /* 0, if urb data is present */
+ gint64 ts_sec;
+ gint32 ts_usec;
+ gint32 status;
+ guint32 urb_len; /* whole len of urb this event refers to */
+ guint32 data_len; /* amount of urb data really present in this event */
+
+ /*
+ * Packet-type-dependent data.
+ * USB setup information of setup_flag is true.
+ * Otherwise, some isochronous transfer information.
+ */
+ union {
+ guint8 data[8];
+ struct iso_rec iso;
+ } s;
+
+ /*
+ * This data is provided by Linux 2.6.31 and later kernels.
+ *
+ * For WTAP_ENCAP_USB_LINUX, it's not in the pseudo-header, so
+ * the pseudo-header is always 48 bytes long, including the
+ * packet-type-dependent data.
+ *
+ * For WTAP_ENCAP_USB_LINUX_MMAPPED, the pseudo-header is always
+ * 64 bytes long, with the packet-type-dependent data preceding
+ * these last 16 bytes. In pre-2.6.31 kernels, it's zero padding;
+ * in 2.6.31 and later, it's the following data.
+ */
+ gint32 interval; /* only for Interrupt and Isochronous events */
+ gint32 start_frame; /* for Isochronous */
+ guint32 xfer_flags; /* copy of URB's transfer_flags */
+ guint32 ndesc; /* actual number of isochronous descriptors */
};
struct linux_usb_isodesc {
- gint32 iso_status;
- guint32 iso_off;
- guint32 iso_len;
- guint32 _pad;
+ gint32 iso_status;
+ guint32 iso_off;
+ guint32 iso_len;
+ guint32 _pad;
};
/*
@@ -1134,11 +1134,11 @@ struct linux_usb_isodesc {
* This structure is 8 bytes long.
*/
struct usb_device_setup_hdr {
- gint8 bmRequestType;
- guint8 bRequest;
- guint16 wValue;
- guint16 wIndex;
- guint16 wLength;
+ gint8 bmRequestType;
+ guint8 bRequest;
+ guint16 wValue;
+ guint16 wIndex;
+ guint16 wLength;
};
@@ -1389,34 +1389,34 @@ pcap_read_ppp_pseudoheader(FILE_T fh,
static gboolean
pcap_read_erf_pseudoheader(FILE_T fh, struct wtap_pkthdr *whdr,
- union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
+ union wtap_pseudo_header *pseudo_header, int *err, gchar **err_info)
{
- guint8 erf_hdr[sizeof(struct erf_phdr)];
-
- if (!wtap_read_bytes(fh, erf_hdr, sizeof(struct erf_phdr), err, err_info))
- return FALSE;
- pseudo_header->erf.phdr.ts = pletoh64(&erf_hdr[0]); /* timestamp */
- pseudo_header->erf.phdr.type = erf_hdr[8];
- pseudo_header->erf.phdr.flags = erf_hdr[9];
- pseudo_header->erf.phdr.rlen = pntoh16(&erf_hdr[10]);
- pseudo_header->erf.phdr.lctr = pntoh16(&erf_hdr[12]);
- pseudo_header->erf.phdr.wlen = pntoh16(&erf_hdr[14]);
-
- /* The high 32 bits of the timestamp contain the integer number of seconds
- * while the lower 32 bits contain the binary fraction of the second.
- * This allows an ultimate resolution of 1/(2^32) seconds, or approximately 233 picoseconds */
- if (whdr) {
- guint64 ts = pseudo_header->erf.phdr.ts;
- whdr->ts.secs = (guint32) (ts >> 32);
- ts = ((ts & 0xffffffff) * 1000 * 1000 * 1000);
- ts += (ts & 0x80000000) << 1; /* rounding */
- whdr->ts.nsecs = ((guint32) (ts >> 32));
- if ( whdr->ts.nsecs >= 1000000000) {
- whdr->ts.nsecs -= 1000000000;
- whdr->ts.secs += 1;
- }
- }
- return TRUE;
+ guint8 erf_hdr[sizeof(struct erf_phdr)];
+
+ if (!wtap_read_bytes(fh, erf_hdr, sizeof(struct erf_phdr), err, err_info))
+ return FALSE;
+ pseudo_header->erf.phdr.ts = pletoh64(&erf_hdr[0]); /* timestamp */
+ pseudo_header->erf.phdr.type = erf_hdr[8];
+ pseudo_header->erf.phdr.flags = erf_hdr[9];
+ pseudo_header->erf.phdr.rlen = pntoh16(&erf_hdr[10]);
+ pseudo_header->erf.phdr.lctr = pntoh16(&erf_hdr[12]);
+ pseudo_header->erf.phdr.wlen = pntoh16(&erf_hdr[14]);
+
+ /* The high 32 bits of the timestamp contain the integer number of seconds
+ * while the lower 32 bits contain the binary fraction of the second.
+ * This allows an ultimate resolution of 1/(2^32) seconds, or approximately 233 picoseconds */
+ if (whdr) {
+ guint64 ts = pseudo_header->erf.phdr.ts;
+ whdr->ts.secs = (guint32) (ts >> 32);
+ ts = ((ts & 0xffffffff) * 1000 * 1000 * 1000);
+ ts += (ts & 0x80000000) << 1; /* rounding */
+ whdr->ts.nsecs = ((guint32) (ts >> 32));
+ if ( whdr->ts.nsecs >= 1000000000) {
+ whdr->ts.nsecs -= 1000000000;
+ whdr->ts.secs += 1;
+ }
+ }
+ return TRUE;
}
/*
@@ -1425,26 +1425,26 @@ pcap_read_erf_pseudoheader(FILE_T fh, struct wtap_pkthdr *whdr,
*/
static gboolean
pcap_read_erf_exheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
- int *err, gchar **err_info, guint * psize)
+ int *err, gchar **err_info, guint * psize)
{
- guint8 erf_exhdr[8];
- guint64 erf_exhdr_sw;
- int i = 0, max = sizeof(pseudo_header->erf.ehdr_list)/sizeof(struct erf_ehdr);
- guint8 type;
- *psize = 0;
- if (pseudo_header->erf.phdr.type & 0x80){
- do{
- if (!wtap_read_bytes(fh, erf_exhdr, 8, err, err_info))
- return FALSE;
- type = erf_exhdr[0];
- erf_exhdr_sw = pntoh64(erf_exhdr);
- if (i < max)
- memcpy(&pseudo_header->erf.ehdr_list[i].ehdr, &erf_exhdr_sw, sizeof(erf_exhdr_sw));
- *psize += 8;
- i++;
- } while (type & 0x80);
- }
- return TRUE;
+ guint8 erf_exhdr[8];
+ guint64 erf_exhdr_sw;
+ int i = 0, max = sizeof(pseudo_header->erf.ehdr_list)/sizeof(struct erf_ehdr);
+ guint8 type;
+ *psize = 0;
+ if (pseudo_header->erf.phdr.type & 0x80){
+ do{
+ if (!wtap_read_bytes(fh, erf_exhdr, 8, err, err_info))
+ return FALSE;
+ type = erf_exhdr[0];
+ erf_exhdr_sw = pntoh64(erf_exhdr);
+ if (i < max)
+ memcpy(&pseudo_header->erf.ehdr_list[i].ehdr, &erf_exhdr_sw, sizeof(erf_exhdr_sw));
+ *psize += 8;
+ i++;
+ } while (type & 0x80);
+ }
+ return TRUE;
}
/*
@@ -1453,39 +1453,39 @@ pcap_read_erf_exheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
*/
static gboolean
pcap_read_erf_subheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
- int *err, gchar **err_info, guint * psize)
+ int *err, gchar **err_info, guint * psize)
{
- guint8 erf_subhdr[sizeof(union erf_subhdr)];
-
- *psize=0;
- switch(pseudo_header->erf.phdr.type & 0x7F) {
- case ERF_TYPE_MC_HDLC:
- case ERF_TYPE_MC_RAW:
- case ERF_TYPE_MC_ATM:
- case ERF_TYPE_MC_RAW_CHANNEL:
- case ERF_TYPE_MC_AAL5:
- case ERF_TYPE_MC_AAL2:
- case ERF_TYPE_COLOR_MC_HDLC_POS:
- /* Extract the Multi Channel header to include it in the pseudo header part */
- if (!wtap_read_bytes(fh, erf_subhdr, sizeof(erf_mc_header_t), err, err_info))
- return FALSE;
- pseudo_header->erf.subhdr.mc_hdr = pntoh32(&erf_subhdr[0]);
- *psize = sizeof(erf_mc_header_t);
- break;
- case ERF_TYPE_ETH:
- case ERF_TYPE_COLOR_ETH:
- case ERF_TYPE_DSM_COLOR_ETH:
- /* Extract the Ethernet additional header to include it in the pseudo header part */
- if (!wtap_read_bytes(fh, erf_subhdr, sizeof(erf_eth_header_t), err, err_info))
- return FALSE;
- pseudo_header->erf.subhdr.eth_hdr = pntoh16(&erf_subhdr[0]);
- *psize = sizeof(erf_eth_header_t);
- break;
- default:
- /* No optional pseudo header for this ERF type */
- break;
- }
- return TRUE;
+ guint8 erf_subhdr[sizeof(union erf_subhdr)];
+
+ *psize=0;
+ switch(pseudo_header->erf.phdr.type & 0x7F) {
+ case ERF_TYPE_MC_HDLC:
+ case ERF_TYPE_MC_RAW:
+ case ERF_TYPE_MC_ATM:
+ case ERF_TYPE_MC_RAW_CHANNEL:
+ case ERF_TYPE_MC_AAL5:
+ case ERF_TYPE_MC_AAL2:
+ case ERF_TYPE_COLOR_MC_HDLC_POS:
+ /* Extract the Multi Channel header to include it in the pseudo header part */
+ if (!wtap_read_bytes(fh, erf_subhdr, sizeof(erf_mc_header_t), err, err_info))
+ return FALSE;
+ pseudo_header->erf.subhdr.mc_hdr = pntoh32(&erf_subhdr[0]);
+ *psize = sizeof(erf_mc_header_t);
+ break;
+ case ERF_TYPE_ETH:
+ case ERF_TYPE_COLOR_ETH:
+ case ERF_TYPE_DSM_COLOR_ETH:
+ /* Extract the Ethernet additional header to include it in the pseudo header part */
+ if (!wtap_read_bytes(fh, erf_subhdr, sizeof(erf_eth_header_t), err, err_info))
+ return FALSE;
+ pseudo_header->erf.subhdr.eth_hdr = pntoh16(&erf_subhdr[0]);
+ *psize = sizeof(erf_eth_header_t);
+ break;
+ default:
+ /* No optional pseudo header for this ERF type */
+ break;
+ }
+ return TRUE;
}
static gboolean
@@ -2167,3 +2167,16 @@ pcap_write_phdr(wtap_dumper *wdh, int encap, const union wtap_pseudo_header *pse
}
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/peekclassic.c b/wiretap/peekclassic.c
index 1802a7781d..3065d88810 100644
--- a/wiretap/peekclassic.c
+++ b/wiretap/peekclassic.c
@@ -598,3 +598,16 @@ static gboolean peekclassic_read_packet_v56(wtap *wth, FILE_T fh,
/* read the packet data */
return wtap_read_packet_bytes(fh, buf, sliceLength, err, err_info);
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/peektagged.c b/wiretap/peektagged.c
index 8317f67c36..47e2ee7d53 100644
--- a/wiretap/peektagged.c
+++ b/wiretap/peektagged.c
@@ -72,9 +72,9 @@
* by the raw packet data.
*/
typedef struct peektagged_section_header {
- gint8 section_id[4]; /* string identifying the section */
- guint32 section_len; /* little-endian section length */
- guint32 section_const; /* little-endian 0x00000200 */
+ gint8 section_id[4]; /* string identifying the section */
+ guint32 section_len; /* little-endian section length */
+ guint32 section_const; /* little-endian 0x00000200 */
} peektagged_section_header_t;
/*
@@ -84,34 +84,34 @@ typedef struct peektagged_section_header {
* network adapter types, with some adapters supplying the FCS and others
* not supplying the FCS?
*/
-#define PEEKTAGGED_NST_ETHERNET 0
-#define PEEKTAGGED_NST_802_11 1 /* 802.11 with 0's at the end */
-#define PEEKTAGGED_NST_802_11_2 2 /* 802.11 with 0's at the end */
-#define PEEKTAGGED_NST_802_11_WITH_FCS 3 /* 802.11 with FCS at the end */
+#define PEEKTAGGED_NST_ETHERNET 0
+#define PEEKTAGGED_NST_802_11 1 /* 802.11 with 0's at the end */
+#define PEEKTAGGED_NST_802_11_2 2 /* 802.11 with 0's at the end */
+#define PEEKTAGGED_NST_802_11_WITH_FCS 3 /* 802.11 with FCS at the end */
/* tags for fields in packet header */
-#define TAG_PEEKTAGGED_LENGTH 0x0000
-#define TAG_PEEKTAGGED_TIMESTAMP_LOWER 0x0001
-#define TAG_PEEKTAGGED_TIMESTAMP_UPPER 0x0002
-#define TAG_PEEKTAGGED_FLAGS_AND_STATUS 0x0003 /* upper 24 bits unused? */
-#define TAG_PEEKTAGGED_CHANNEL 0x0004
-#define TAG_PEEKTAGGED_DATA_RATE_OR_MCS_INDEX 0x0005
-#define TAG_PEEKTAGGED_SIGNAL_PERC 0x0006
-#define TAG_PEEKTAGGED_SIGNAL_DBM 0x0007
-#define TAG_PEEKTAGGED_NOISE_PERC 0x0008
-#define TAG_PEEKTAGGED_NOISE_DBM 0x0009
-#define TAG_PEEKTAGGED_UNKNOWN_0x000A 0x000A
-#define TAG_PEEKTAGGED_CENTER_FREQUENCY 0x000D /* Frequency */
-#define TAG_PEEKTAGGED_UNKNOWN_0x000E 0x000E
-#define TAG_PEEKTAGGED_UNKNOWN_0x000F 0x000F /* 000F-0013 - dBm values? */
-#define TAG_PEEKTAGGED_UNKNOWN_0x0010 0x0010
-#define TAG_PEEKTAGGED_UNKNOWN_0x0011 0x0011
-#define TAG_PEEKTAGGED_UNKNOWN_0x0012 0x0012
-#define TAG_PEEKTAGGED_UNKNOWN_0x0013 0x0013
-#define TAG_PEEKTAGGED_UNKNOWN_0x0014 0x0014
-#define TAG_PEEKTAGGED_EXT_FLAGS 0x0015 /* Extended flags for 802.11n and beyond */
-
-#define TAG_PEEKTAGGED_SLICE_LENGTH 0xffff
+#define TAG_PEEKTAGGED_LENGTH 0x0000
+#define TAG_PEEKTAGGED_TIMESTAMP_LOWER 0x0001
+#define TAG_PEEKTAGGED_TIMESTAMP_UPPER 0x0002
+#define TAG_PEEKTAGGED_FLAGS_AND_STATUS 0x0003 /* upper 24 bits unused? */
+#define TAG_PEEKTAGGED_CHANNEL 0x0004
+#define TAG_PEEKTAGGED_DATA_RATE_OR_MCS_INDEX 0x0005
+#define TAG_PEEKTAGGED_SIGNAL_PERC 0x0006
+#define TAG_PEEKTAGGED_SIGNAL_DBM 0x0007
+#define TAG_PEEKTAGGED_NOISE_PERC 0x0008
+#define TAG_PEEKTAGGED_NOISE_DBM 0x0009
+#define TAG_PEEKTAGGED_UNKNOWN_0x000A 0x000A
+#define TAG_PEEKTAGGED_CENTER_FREQUENCY 0x000D /* Frequency */
+#define TAG_PEEKTAGGED_UNKNOWN_0x000E 0x000E
+#define TAG_PEEKTAGGED_UNKNOWN_0x000F 0x000F /* 000F-0013 - dBm values? */
+#define TAG_PEEKTAGGED_UNKNOWN_0x0010 0x0010
+#define TAG_PEEKTAGGED_UNKNOWN_0x0011 0x0011
+#define TAG_PEEKTAGGED_UNKNOWN_0x0012 0x0012
+#define TAG_PEEKTAGGED_UNKNOWN_0x0013 0x0013
+#define TAG_PEEKTAGGED_UNKNOWN_0x0014 0x0014
+#define TAG_PEEKTAGGED_EXT_FLAGS 0x0015 /* Extended flags for 802.11n and beyond */
+
+#define TAG_PEEKTAGGED_SLICE_LENGTH 0xffff
/*
* Flags.
@@ -119,18 +119,18 @@ typedef struct peektagged_section_header {
* We're assuming here that the "remote Peek" flags from bug 9586 are
* the same as the "Peek tagged" flags.
*/
-#define FLAGS_CONTROL_FRAME 0x01 /* Frame is a control frame */
-#define FLAGS_HAS_CRC_ERROR 0x02 /* Frame has a CRC error */
-#define FLAGS_HAS_FRAME_ERROR 0x04 /* Frame has a frame error */
+#define FLAGS_CONTROL_FRAME 0x01 /* Frame is a control frame */
+#define FLAGS_HAS_CRC_ERROR 0x02 /* Frame has a CRC error */
+#define FLAGS_HAS_FRAME_ERROR 0x04 /* Frame has a frame error */
/*
* Status.
*
* Is this in the next 8 bits of the "flags and status" field?
*/
-#define STATUS_PROTECTED 0x0400 /* Frame is protected (encrypted) */
-#define STATUS_DECRYPT_ERROR 0x0800 /* Error decrypting protected frame */
-#define STATUS_SHORT_PREAMBLE 0x4000 /* Short preamble */
+#define STATUS_PROTECTED 0x0400 /* Frame is protected (encrypted) */
+#define STATUS_DECRYPT_ERROR 0x0800 /* Error decrypting protected frame */
+#define STATUS_SHORT_PREAMBLE 0x4000 /* Short preamble */
/*
* Extended flags.
@@ -141,17 +141,17 @@ typedef struct peektagged_section_header {
* use the same bits (which wouldn't be too surprising, as they
* both come from Wildpackets).
*/
-#define EXT_FLAG_20_MHZ_LOWER 0x00000001
-#define EXT_FLAG_20_MHZ_UPPER 0x00000002
-#define EXT_FLAG_40_MHZ 0x00000004
-#define EXT_FLAGS_BANDWIDTH 0x00000007
-#define EXT_FLAG_HALF_GI 0x00000008
-#define EXT_FLAG_FULL_GI 0x00000010
-#define EXT_FLAGS_GI 0x00000018
-#define EXT_FLAG_AMPDU 0x00000020
-#define EXT_FLAG_AMSDU 0x00000040
-#define EXT_FLAG_802_11ac 0x00000080
-#define EXT_FLAG_MCS_INDEX_USED 0x00000100
+#define EXT_FLAG_20_MHZ_LOWER 0x00000001
+#define EXT_FLAG_20_MHZ_UPPER 0x00000002
+#define EXT_FLAG_40_MHZ 0x00000004
+#define EXT_FLAGS_BANDWIDTH 0x00000007
+#define EXT_FLAG_HALF_GI 0x00000008
+#define EXT_FLAG_FULL_GI 0x00000010
+#define EXT_FLAGS_GI 0x00000018
+#define EXT_FLAG_AMPDU 0x00000020
+#define EXT_FLAG_AMSDU 0x00000040
+#define EXT_FLAG_802_11ac 0x00000080
+#define EXT_FLAG_MCS_INDEX_USED 0x00000100
/*
* XXX - mapping to radiotap, for fields that don't just map to wiretap
@@ -211,12 +211,12 @@ typedef struct peektagged_section_header {
/* 64-bit time in nanoseconds from the (Windows FILETIME) epoch */
typedef struct peektagged_utime {
- guint32 upper;
- guint32 lower;
+ guint32 upper;
+ guint32 lower;
} peektagged_utime;
typedef struct {
- gboolean has_fcs;
+ gboolean has_fcs;
} peektagged_t;
static gboolean peektagged_read(wtap *wth, int *err, gchar **err_info,
@@ -225,7 +225,7 @@ static gboolean peektagged_seek_read(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info);
static int wtap_file_read_pattern (wtap *wth, const char *pattern, int *err,
- gchar **err_info)
+ gchar **err_info)
{
int c;
const char *cp;
@@ -233,31 +233,31 @@ static int wtap_file_read_pattern (wtap *wth, const char *pattern, int *err,
cp = pattern;
while (*cp)
{
- c = file_getc(wth->fh);
- if (c == EOF)
- {
- *err = file_error(wth->fh, err_info);
- if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1; /* error */
- return 0; /* EOF */
- }
- if (c == *cp)
- cp++;
- else
- {
- if (c == pattern[0])
- cp = &pattern[1];
- else
- cp = pattern;
- }
+ c = file_getc(wth->fh);
+ if (c == EOF)
+ {
+ *err = file_error(wth->fh, err_info);
+ if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
+ return -1; /* error */
+ return 0; /* EOF */
+ }
+ if (c == *cp)
+ cp++;
+ else
+ {
+ if (c == pattern[0])
+ cp = &pattern[1];
+ else
+ cp = pattern;
+ }
}
return (*cp == '\0' ? 1 : 0);
}
static int wtap_file_read_till_separator (wtap *wth, char *buffer, int buflen,
- const char *separators, int *err,
- gchar **err_info)
+ const char *separators, int *err,
+ gchar **err_info)
{
int c;
char *cp;
@@ -265,28 +265,28 @@ static int wtap_file_read_till_separator (wtap *wth, char *buffer, int buflen,
for (cp = buffer, i = 0; i < buflen; i++, cp++)
{
- c = file_getc(wth->fh);
- if (c == EOF)
- {
- *err = file_error(wth->fh, err_info);
- if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
- return -1; /* error */
- return 0; /* EOF */
- }
- if (strchr (separators, c) != NULL)
- {
- *cp = '\0';
- break;
- }
- else
- *cp = c;
+ c = file_getc(wth->fh);
+ if (c == EOF)
+ {
+ *err = file_error(wth->fh, err_info);
+ if (*err != 0 && *err != WTAP_ERR_SHORT_READ)
+ return -1; /* error */
+ return 0; /* EOF */
+ }
+ if (strchr (separators, c) != NULL)
+ {
+ *cp = '\0';
+ break;
+ }
+ else
+ *cp = c;
}
return i;
}
static int wtap_file_read_number (wtap *wth, guint32 *num, int *err,
- gchar **err_info)
+ gchar **err_info)
{
int ret;
char str_num[12];
@@ -294,15 +294,15 @@ static int wtap_file_read_number (wtap *wth, guint32 *num, int *err,
char *p;
ret = wtap_file_read_till_separator (wth, str_num, sizeof (str_num)-1, "<",
- err, err_info);
+ err, err_info);
if (ret == 0 || ret == -1) {
- /* 0 means EOF, which means "not a valid Peek tagged file";
- -1 means error, and "err" has been set. */
- return ret;
+ /* 0 means EOF, which means "not a valid Peek tagged file";
+ -1 means error, and "err" has been set. */
+ return ret;
}
value = strtoul (str_num, &p, 10);
if (p == str_num || value > G_MAXUINT32)
- return 0;
+ return 0;
*num = (guint32)value;
return 1;
}
@@ -317,10 +317,10 @@ wtap_open_return_val peektagged_open(wtap *wth, int *err, gchar **err_info)
guint32 mediaSubType = 0;
int file_encap;
static const int peektagged_encap[] = {
- WTAP_ENCAP_ETHERNET,
- WTAP_ENCAP_IEEE_802_11_WITH_RADIO,
- WTAP_ENCAP_IEEE_802_11_WITH_RADIO,
- WTAP_ENCAP_IEEE_802_11_WITH_RADIO
+ WTAP_ENCAP_ETHERNET,
+ WTAP_ENCAP_IEEE_802_11_WITH_RADIO,
+ WTAP_ENCAP_IEEE_802_11_WITH_RADIO,
+ WTAP_ENCAP_IEEE_802_11_WITH_RADIO
};
#define NUM_PEEKTAGGED_ENCAPS (sizeof peektagged_encap / sizeof peektagged_encap[0])
peektagged_t *peektagged;
@@ -332,7 +332,7 @@ wtap_open_return_val peektagged_open(wtap *wth, int *err, gchar **err_info)
}
if (memcmp (ap_hdr.section_id, "\177ver", sizeof(ap_hdr.section_id)) != 0)
- return WTAP_OPEN_NOT_MINE; /* doesn't begin with a "\177ver" section */
+ return WTAP_OPEN_NOT_MINE; /* doesn't begin with a "\177ver" section */
/*
* XXX - we should get the length of the "\177ver" section, check
@@ -344,26 +344,26 @@ wtap_open_return_val peektagged_open(wtap *wth, int *err, gchar **err_info)
*/
ret = wtap_file_read_pattern (wth, "<FileVersion>", err, err_info);
if (ret == -1)
- return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_ERROR;
if (ret == 0) {
- /* 0 means EOF, which means "not a valid Peek tagged file" */
- return WTAP_OPEN_NOT_MINE;
+ /* 0 means EOF, which means "not a valid Peek tagged file" */
+ return WTAP_OPEN_NOT_MINE;
}
ret = wtap_file_read_number (wth, &fileVersion, err, err_info);
if (ret == -1)
- return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_ERROR;
if (ret == 0) {
- /* 0 means EOF, which means "not a valid Peek tagged file" */
- return WTAP_OPEN_NOT_MINE;
+ /* 0 means EOF, which means "not a valid Peek tagged file" */
+ return WTAP_OPEN_NOT_MINE;
}
/* If we got this far, we assume it's a Peek tagged file. */
if (fileVersion != 9) {
- /* We only support version 9. */
- *err = WTAP_ERR_UNSUPPORTED;
- *err_info = g_strdup_printf("peektagged: version %u unsupported",
- fileVersion);
- return WTAP_OPEN_ERROR;
+ /* We only support version 9. */
+ *err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("peektagged: version %u unsupported",
+ fileVersion);
+ return WTAP_OPEN_ERROR;
}
/*
@@ -378,58 +378,58 @@ wtap_open_return_val peektagged_open(wtap *wth, int *err, gchar **err_info)
*/
ret = wtap_file_read_pattern (wth, "<MediaType>", err, err_info);
if (ret == -1)
- return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_ERROR;
if (ret == 0) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("peektagged: <MediaType> tag not found");
- return WTAP_OPEN_ERROR;
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("peektagged: <MediaType> tag not found");
+ return WTAP_OPEN_ERROR;
}
/* XXX - this appears to be 0 in both the EtherPeek and AiroPeek
files we've seen; should we require it to be 0? */
ret = wtap_file_read_number (wth, &mediaType, err, err_info);
if (ret == -1)
- return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_ERROR;
if (ret == 0) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("peektagged: <MediaType> value not found");
- return WTAP_OPEN_ERROR;
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("peektagged: <MediaType> value not found");
+ return WTAP_OPEN_ERROR;
}
ret = wtap_file_read_pattern (wth, "<MediaSubType>", err, err_info);
if (ret == -1)
- return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_ERROR;
if (ret == 0) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("peektagged: <MediaSubType> tag not found");
- return WTAP_OPEN_ERROR;
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("peektagged: <MediaSubType> tag not found");
+ return WTAP_OPEN_ERROR;
}
ret = wtap_file_read_number (wth, &mediaSubType, err, err_info);
if (ret == -1)
- return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_ERROR;
if (ret == 0) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("peektagged: <MediaSubType> value not found");
- return WTAP_OPEN_ERROR;
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("peektagged: <MediaSubType> value not found");
+ return WTAP_OPEN_ERROR;
}
if (mediaSubType >= NUM_PEEKTAGGED_ENCAPS
|| peektagged_encap[mediaSubType] == WTAP_ENCAP_UNKNOWN) {
- *err = WTAP_ERR_UNSUPPORTED;
- *err_info = g_strdup_printf("peektagged: network type %u unknown or unsupported",
- mediaSubType);
- return WTAP_OPEN_ERROR;
+ *err = WTAP_ERR_UNSUPPORTED;
+ *err_info = g_strdup_printf("peektagged: network type %u unknown or unsupported",
+ mediaSubType);
+ return WTAP_OPEN_ERROR;
}
ret = wtap_file_read_pattern (wth, "pkts", err, err_info);
if (ret == -1)
- return WTAP_OPEN_ERROR;
+ return WTAP_OPEN_ERROR;
if (ret == 0) {
- *err = WTAP_ERR_SHORT_READ;
- return WTAP_OPEN_ERROR;
+ *err = WTAP_ERR_SHORT_READ;
+ return WTAP_OPEN_ERROR;
}
/* skip 8 zero bytes */
if (file_seek (wth->fh, 8L, SEEK_CUR, err) == -1)
- return WTAP_OPEN_NOT_MINE;
+ return WTAP_OPEN_NOT_MINE;
/*
* This is an Peek tagged file.
@@ -449,12 +449,12 @@ wtap_open_return_val peektagged_open(wtap *wth, int *err, gchar **err_info)
case PEEKTAGGED_NST_ETHERNET:
case PEEKTAGGED_NST_802_11:
case PEEKTAGGED_NST_802_11_2:
- peektagged->has_fcs = FALSE;
- break;
+ peektagged->has_fcs = FALSE;
+ break;
case PEEKTAGGED_NST_802_11_WITH_FCS:
- peektagged->has_fcs = TRUE;
- break;
+ peektagged->has_fcs = TRUE;
+ break;
}
wth->snapshot_length = 0; /* not available in header */
@@ -508,169 +508,169 @@ peektagged_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
/* Extract the fields from the packet header */
do {
- /* Get the tag and value.
- XXX - this assumes all values are 4 bytes long. */
- if (!wtap_read_bytes_or_eof(fh, tag_value, sizeof tag_value, err, err_info)) {
- if (*err == 0) {
- /*
- * Short read if we've read something already;
- * just an EOF if we haven't.
- */
- if (read_a_tag)
- *err = WTAP_ERR_SHORT_READ;
- }
- return -1;
- }
- read_a_tag = TRUE;
- tag = pletoh16(&tag_value[0]);
- switch (tag) {
-
- case TAG_PEEKTAGGED_LENGTH:
- if (saw_length) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("peektagged: record has two length fields");
- return -1;
- }
- length = pletoh32(&tag_value[2]);
- saw_length = TRUE;
- break;
-
- case TAG_PEEKTAGGED_TIMESTAMP_LOWER:
- if (saw_timestamp_lower) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("peektagged: record has two timestamp-lower fields");
- return -1;
- }
- timestamp.lower = pletoh32(&tag_value[2]);
- saw_timestamp_lower = TRUE;
- break;
-
- case TAG_PEEKTAGGED_TIMESTAMP_UPPER:
- if (saw_timestamp_upper) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("peektagged: record has two timestamp-upper fields");
- return -1;
- }
- timestamp.upper = pletoh32(&tag_value[2]);
- saw_timestamp_upper = TRUE;
- break;
-
- case TAG_PEEKTAGGED_FLAGS_AND_STATUS:
- /* XXX - not used yet */
- break;
-
- case TAG_PEEKTAGGED_CHANNEL:
- ieee_802_11.presence_flags |= PHDR_802_11_HAS_CHANNEL;
- ieee_802_11.channel = pletoh32(&tag_value[2]);
- break;
-
- case TAG_PEEKTAGGED_DATA_RATE_OR_MCS_INDEX:
- data_rate_or_mcs_index = pletoh32(&tag_value[2]);
- saw_data_rate_or_mcs_index = TRUE;
- break;
-
- case TAG_PEEKTAGGED_SIGNAL_PERC:
- ieee_802_11.presence_flags |= PHDR_802_11_HAS_SIGNAL_PERCENT;
- ieee_802_11.signal_percent = pletoh32(&tag_value[2]);
- break;
-
- case TAG_PEEKTAGGED_SIGNAL_DBM:
- ieee_802_11.presence_flags |= PHDR_802_11_HAS_SIGNAL_DBM;
- ieee_802_11.signal_dbm = pletoh32(&tag_value[2]);
- break;
-
- case TAG_PEEKTAGGED_NOISE_PERC:
- ieee_802_11.presence_flags |= PHDR_802_11_HAS_NOISE_PERCENT;
- ieee_802_11.noise_percent = pletoh32(&tag_value[2]);
- break;
-
- case TAG_PEEKTAGGED_NOISE_DBM:
- ieee_802_11.presence_flags |= PHDR_802_11_HAS_NOISE_DBM;
- ieee_802_11.noise_dbm = pletoh32(&tag_value[2]);
- break;
-
- case TAG_PEEKTAGGED_UNKNOWN_0x000A:
- /* XXX - seen in an OmniPeek 802.11n capture; value unknown */
- break;
-
- case TAG_PEEKTAGGED_CENTER_FREQUENCY:
- /* XXX - also seen in an EtherPeek capture; value unknown */
- ieee_802_11.presence_flags |= PHDR_802_11_HAS_FREQUENCY;
- ieee_802_11.frequency = pletoh32(&tag_value[2]);
- break;
-
- case TAG_PEEKTAGGED_UNKNOWN_0x000E:
- /* XXX - seen in an AiroPeek/OmniPeek capture; value unknown */
- break;
-
- case TAG_PEEKTAGGED_UNKNOWN_0x000F:
- /* XXX - seen in an AiroPeek/OmniPeek capture; dBm value? */
- break;
-
- case TAG_PEEKTAGGED_UNKNOWN_0x0010:
- /* XXX - seen in an AiroPeek/OmniPeek capture; dBm value? */
- break;
-
- case TAG_PEEKTAGGED_UNKNOWN_0x0011:
- /* XXX - seen in an AiroPeek/OmniPeek capture; dBm value? */
- break;
-
- case TAG_PEEKTAGGED_UNKNOWN_0x0012:
- /* XXX - seen in an AiroPeek/OmniPeek capture; dBm value? */
- break;
-
- case TAG_PEEKTAGGED_UNKNOWN_0x0013:
- /* XXX - seen in an AiroPeek/OmniPeek capture; dBm value? */
- break;
-
- case TAG_PEEKTAGGED_UNKNOWN_0x0014:
- /* XXX - seen in an AiroPeek/OmniPeek capture; value unknown */
- break;
-
- case TAG_PEEKTAGGED_EXT_FLAGS:
- ext_flags = pletoh32(&tag_value[2]);
- break;
-
- case TAG_PEEKTAGGED_SLICE_LENGTH:
- sliceLength = pletoh32(&tag_value[2]);
- break;
-
- default:
- break;
+ /* Get the tag and value.
+ XXX - this assumes all values are 4 bytes long. */
+ if (!wtap_read_bytes_or_eof(fh, tag_value, sizeof tag_value, err, err_info)) {
+ if (*err == 0) {
+ /*
+ * Short read if we've read something already;
+ * just an EOF if we haven't.
+ */
+ if (read_a_tag)
+ *err = WTAP_ERR_SHORT_READ;
+ }
+ return -1;
+ }
+ read_a_tag = TRUE;
+ tag = pletoh16(&tag_value[0]);
+ switch (tag) {
+
+ case TAG_PEEKTAGGED_LENGTH:
+ if (saw_length) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("peektagged: record has two length fields");
+ return -1;
+ }
+ length = pletoh32(&tag_value[2]);
+ saw_length = TRUE;
+ break;
+
+ case TAG_PEEKTAGGED_TIMESTAMP_LOWER:
+ if (saw_timestamp_lower) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("peektagged: record has two timestamp-lower fields");
+ return -1;
+ }
+ timestamp.lower = pletoh32(&tag_value[2]);
+ saw_timestamp_lower = TRUE;
+ break;
+
+ case TAG_PEEKTAGGED_TIMESTAMP_UPPER:
+ if (saw_timestamp_upper) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("peektagged: record has two timestamp-upper fields");
+ return -1;
+ }
+ timestamp.upper = pletoh32(&tag_value[2]);
+ saw_timestamp_upper = TRUE;
+ break;
+
+ case TAG_PEEKTAGGED_FLAGS_AND_STATUS:
+ /* XXX - not used yet */
+ break;
+
+ case TAG_PEEKTAGGED_CHANNEL:
+ ieee_802_11.presence_flags |= PHDR_802_11_HAS_CHANNEL;
+ ieee_802_11.channel = pletoh32(&tag_value[2]);
+ break;
+
+ case TAG_PEEKTAGGED_DATA_RATE_OR_MCS_INDEX:
+ data_rate_or_mcs_index = pletoh32(&tag_value[2]);
+ saw_data_rate_or_mcs_index = TRUE;
+ break;
+
+ case TAG_PEEKTAGGED_SIGNAL_PERC:
+ ieee_802_11.presence_flags |= PHDR_802_11_HAS_SIGNAL_PERCENT;
+ ieee_802_11.signal_percent = pletoh32(&tag_value[2]);
+ break;
+
+ case TAG_PEEKTAGGED_SIGNAL_DBM:
+ ieee_802_11.presence_flags |= PHDR_802_11_HAS_SIGNAL_DBM;
+ ieee_802_11.signal_dbm = pletoh32(&tag_value[2]);
+ break;
+
+ case TAG_PEEKTAGGED_NOISE_PERC:
+ ieee_802_11.presence_flags |= PHDR_802_11_HAS_NOISE_PERCENT;
+ ieee_802_11.noise_percent = pletoh32(&tag_value[2]);
+ break;
+
+ case TAG_PEEKTAGGED_NOISE_DBM:
+ ieee_802_11.presence_flags |= PHDR_802_11_HAS_NOISE_DBM;
+ ieee_802_11.noise_dbm = pletoh32(&tag_value[2]);
+ break;
+
+ case TAG_PEEKTAGGED_UNKNOWN_0x000A:
+ /* XXX - seen in an OmniPeek 802.11n capture; value unknown */
+ break;
+
+ case TAG_PEEKTAGGED_CENTER_FREQUENCY:
+ /* XXX - also seen in an EtherPeek capture; value unknown */
+ ieee_802_11.presence_flags |= PHDR_802_11_HAS_FREQUENCY;
+ ieee_802_11.frequency = pletoh32(&tag_value[2]);
+ break;
+
+ case TAG_PEEKTAGGED_UNKNOWN_0x000E:
+ /* XXX - seen in an AiroPeek/OmniPeek capture; value unknown */
+ break;
+
+ case TAG_PEEKTAGGED_UNKNOWN_0x000F:
+ /* XXX - seen in an AiroPeek/OmniPeek capture; dBm value? */
+ break;
+
+ case TAG_PEEKTAGGED_UNKNOWN_0x0010:
+ /* XXX - seen in an AiroPeek/OmniPeek capture; dBm value? */
+ break;
+
+ case TAG_PEEKTAGGED_UNKNOWN_0x0011:
+ /* XXX - seen in an AiroPeek/OmniPeek capture; dBm value? */
+ break;
+
+ case TAG_PEEKTAGGED_UNKNOWN_0x0012:
+ /* XXX - seen in an AiroPeek/OmniPeek capture; dBm value? */
+ break;
+
+ case TAG_PEEKTAGGED_UNKNOWN_0x0013:
+ /* XXX - seen in an AiroPeek/OmniPeek capture; dBm value? */
+ break;
+
+ case TAG_PEEKTAGGED_UNKNOWN_0x0014:
+ /* XXX - seen in an AiroPeek/OmniPeek capture; value unknown */
+ break;
+
+ case TAG_PEEKTAGGED_EXT_FLAGS:
+ ext_flags = pletoh32(&tag_value[2]);
+ break;
+
+ case TAG_PEEKTAGGED_SLICE_LENGTH:
+ sliceLength = pletoh32(&tag_value[2]);
+ break;
+
+ default:
+ break;
}
- } while (tag != TAG_PEEKTAGGED_SLICE_LENGTH); /* last tag */
+ } while (tag != TAG_PEEKTAGGED_SLICE_LENGTH); /* last tag */
if (!saw_length) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("peektagged: record has no length field");
- return -1;
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("peektagged: record has no length field");
+ return -1;
}
if (!saw_timestamp_lower) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("peektagged: record has no timestamp-lower field");
- return -1;
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("peektagged: record has no timestamp-lower field");
+ return -1;
}
if (!saw_timestamp_upper) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup("peektagged: record has no timestamp-upper field");
- return -1;
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup("peektagged: record has no timestamp-upper field");
+ return -1;
}
/*
* If sliceLength is 0, force it to be the actual length of the packet.
*/
if (sliceLength == 0)
- sliceLength = length;
+ sliceLength = length;
if (sliceLength > WTAP_MAX_PACKET_SIZE) {
- /*
- * Probably a corrupt capture file; don't blow up trying
- * to allocate space for an immensely-large packet.
- */
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup_printf("peektagged: File has %u-byte packet, bigger than maximum of %u",
- sliceLength, WTAP_MAX_PACKET_SIZE);
- return -1;
+ /*
+ * Probably a corrupt capture file; don't blow up trying
+ * to allocate space for an immensely-large packet.
+ */
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup_printf("peektagged: File has %u-byte packet, bigger than maximum of %u",
+ sliceLength, WTAP_MAX_PACKET_SIZE);
+ return -1;
}
phdr->rec_type = REC_TYPE_PACKET;
@@ -680,7 +680,7 @@ peektagged_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
/* calculate and fill in packet time stamp */
t = (double) timestamp.lower +
- (double) timestamp.upper * 4294967296.0;
+ (double) timestamp.upper * 4294967296.0;
t *= 1.0e-9;
t -= TIME_FIXUP_CONSTANT;
phdr->ts.secs = (time_t) t;
@@ -689,96 +689,96 @@ peektagged_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
switch (wth->file_encap) {
case WTAP_ENCAP_IEEE_802_11_WITH_RADIO:
- if (saw_data_rate_or_mcs_index) {
- if (ext_flags & EXT_FLAG_MCS_INDEX_USED) {
- /* It's an MCS index. */
- ieee_802_11.presence_flags |= PHDR_802_11_HAS_MCS_INDEX;
- ieee_802_11.mcs_index = data_rate_or_mcs_index;
-
- /*
- * Fill in other 802.11n information.
- */
- switch (ext_flags & EXT_FLAGS_BANDWIDTH) {
-
- case 0:
- ieee_802_11.presence_flags |= PHDR_802_11_HAS_BANDWIDTH;
- ieee_802_11.bandwidth = PHDR_802_11_BANDWIDTH_20_MHZ;
- break;
-
- case EXT_FLAG_20_MHZ_LOWER:
- ieee_802_11.presence_flags |= PHDR_802_11_HAS_BANDWIDTH;
- ieee_802_11.bandwidth = PHDR_802_11_BANDWIDTH_20_20L;
- break;
-
- case EXT_FLAG_20_MHZ_UPPER:
- ieee_802_11.presence_flags |= PHDR_802_11_HAS_BANDWIDTH;
- ieee_802_11.bandwidth = PHDR_802_11_BANDWIDTH_20_20U;
- break;
-
- case EXT_FLAG_40_MHZ:
- ieee_802_11.presence_flags |= PHDR_802_11_HAS_BANDWIDTH;
- ieee_802_11.bandwidth = PHDR_802_11_BANDWIDTH_40_MHZ;
- break;
-
- default:
- /* Mutually exclusive flags set */
- break;
- }
-
- switch (ext_flags & EXT_FLAGS_GI) {
-
- case EXT_FLAG_HALF_GI:
- ieee_802_11.presence_flags |= PHDR_802_11_HAS_SHORT_GI;
- ieee_802_11.short_gi = 1;
- break;
-
- case EXT_FLAG_FULL_GI:
- ieee_802_11.presence_flags |= PHDR_802_11_HAS_SHORT_GI;
- ieee_802_11.short_gi = 0;
- break;
-
- default:
- /* Mutually exclusive flags set */
- break;
- }
- } else {
- /* It's a data rate */
- ieee_802_11.presence_flags |= PHDR_802_11_HAS_DATA_RATE;
- ieee_802_11.data_rate = data_rate_or_mcs_index;
- }
- }
- phdr->pseudo_header.ieee_802_11 = ieee_802_11;
- if (peektagged->has_fcs)
- phdr->pseudo_header.ieee_802_11.fcs_len = 4;
- else {
- if (phdr->len < 4 || phdr->caplen < 4) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup_printf("peektagged: 802.11 packet has length < 4");
- return FALSE;
- }
- phdr->pseudo_header.ieee_802_11.fcs_len = 0;
- phdr->len -= 4;
- phdr->caplen -= 4;
- skip_len = 4;
- }
- phdr->pseudo_header.ieee_802_11.decrypted = FALSE;
- break;
+ if (saw_data_rate_or_mcs_index) {
+ if (ext_flags & EXT_FLAG_MCS_INDEX_USED) {
+ /* It's an MCS index. */
+ ieee_802_11.presence_flags |= PHDR_802_11_HAS_MCS_INDEX;
+ ieee_802_11.mcs_index = data_rate_or_mcs_index;
+
+ /*
+ * Fill in other 802.11n information.
+ */
+ switch (ext_flags & EXT_FLAGS_BANDWIDTH) {
+
+ case 0:
+ ieee_802_11.presence_flags |= PHDR_802_11_HAS_BANDWIDTH;
+ ieee_802_11.bandwidth = PHDR_802_11_BANDWIDTH_20_MHZ;
+ break;
+
+ case EXT_FLAG_20_MHZ_LOWER:
+ ieee_802_11.presence_flags |= PHDR_802_11_HAS_BANDWIDTH;
+ ieee_802_11.bandwidth = PHDR_802_11_BANDWIDTH_20_20L;
+ break;
+
+ case EXT_FLAG_20_MHZ_UPPER:
+ ieee_802_11.presence_flags |= PHDR_802_11_HAS_BANDWIDTH;
+ ieee_802_11.bandwidth = PHDR_802_11_BANDWIDTH_20_20U;
+ break;
+
+ case EXT_FLAG_40_MHZ:
+ ieee_802_11.presence_flags |= PHDR_802_11_HAS_BANDWIDTH;
+ ieee_802_11.bandwidth = PHDR_802_11_BANDWIDTH_40_MHZ;
+ break;
+
+ default:
+ /* Mutually exclusive flags set */
+ break;
+ }
+
+ switch (ext_flags & EXT_FLAGS_GI) {
+
+ case EXT_FLAG_HALF_GI:
+ ieee_802_11.presence_flags |= PHDR_802_11_HAS_SHORT_GI;
+ ieee_802_11.short_gi = 1;
+ break;
+
+ case EXT_FLAG_FULL_GI:
+ ieee_802_11.presence_flags |= PHDR_802_11_HAS_SHORT_GI;
+ ieee_802_11.short_gi = 0;
+ break;
+
+ default:
+ /* Mutually exclusive flags set */
+ break;
+ }
+ } else {
+ /* It's a data rate */
+ ieee_802_11.presence_flags |= PHDR_802_11_HAS_DATA_RATE;
+ ieee_802_11.data_rate = data_rate_or_mcs_index;
+ }
+ }
+ phdr->pseudo_header.ieee_802_11 = ieee_802_11;
+ if (peektagged->has_fcs)
+ phdr->pseudo_header.ieee_802_11.fcs_len = 4;
+ else {
+ if (phdr->len < 4 || phdr->caplen < 4) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup_printf("peektagged: 802.11 packet has length < 4");
+ return FALSE;
+ }
+ phdr->pseudo_header.ieee_802_11.fcs_len = 0;
+ phdr->len -= 4;
+ phdr->caplen -= 4;
+ skip_len = 4;
+ }
+ phdr->pseudo_header.ieee_802_11.decrypted = FALSE;
+ break;
case WTAP_ENCAP_ETHERNET:
- /*
- * The last 4 bytes appear to be 0 in the captures I've seen;
- * are there any captures where it's an FCS?
- */
- if (phdr->len < 4 || phdr->caplen < 4) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup_printf("peektagged: Ethernet packet has length < 4");
- return FALSE;
- }
- phdr->pseudo_header.eth.fcs_len = 0;
- phdr->len -= 4;
- phdr->caplen -= 4;
- skip_len = 4;
- break;
+ /*
+ * The last 4 bytes appear to be 0 in the captures I've seen;
+ * are there any captures where it's an FCS?
+ */
+ if (phdr->len < 4 || phdr->caplen < 4) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup_printf("peektagged: Ethernet packet has length < 4");
+ return FALSE;
+ }
+ phdr->pseudo_header.eth.fcs_len = 0;
+ phdr->len -= 4;
+ phdr->caplen -= 4;
+ skip_len = 4;
+ break;
}
/* Read the packet data. */
@@ -799,12 +799,12 @@ static gboolean peektagged_read(wtap *wth, int *err, gchar **err_info,
skip_len = peektagged_read_packet(wth, wth->fh, &wth->phdr,
wth->frame_buffer, err, err_info);
if (skip_len == -1)
- return FALSE;
+ return FALSE;
if (skip_len != 0) {
- /* Skip extra junk at the end of the packet data. */
+ /* Skip extra junk at the end of the packet data. */
if (!file_skip(wth->fh, skip_len, err))
- return FALSE;
+ return FALSE;
}
return TRUE;
@@ -815,13 +815,26 @@ peektagged_seek_read(wtap *wth, gint64 seek_off,
struct wtap_pkthdr *phdr, Buffer *buf, int *err, gchar **err_info)
{
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
- return FALSE;
+ return FALSE;
/* Read the packet. */
if (peektagged_read_packet(wth, wth->random_fh, phdr, buf, err, err_info) == -1) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
- return FALSE;
+ return FALSE;
}
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/pppdump.c b/wiretap/pppdump.c
index 3e64ab1783..5b1981fcd9 100644
--- a/wiretap/pppdump.c
+++ b/wiretap/pppdump.c
@@ -793,3 +793,16 @@ pppdump_close(wtap *wth)
g_ptr_array_free(state->pids, TRUE);
}
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/radcom.c b/wiretap/radcom.c
index 53f5505434..95e0df36cf 100644
--- a/wiretap/radcom.c
+++ b/wiretap/radcom.c
@@ -360,3 +360,16 @@ radcom_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/snoop.c b/wiretap/snoop.c
index bba1b29411..099d52c901 100644
--- a/wiretap/snoop.c
+++ b/wiretap/snoop.c
@@ -904,3 +904,16 @@ static gboolean snoop_dump(wtap_dumper *wdh,
return FALSE;
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/stanag4607.c b/wiretap/stanag4607.c
index a3c0a207aa..59e5acc06c 100644
--- a/wiretap/stanag4607.c
+++ b/wiretap/stanag4607.c
@@ -188,3 +188,16 @@ wtap_open_return_val stanag4607_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local Variables:
+ * c-basic-offset: 2
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=2 tabstop=8 expandtab:
+ * :indentSize=2:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/tnef.c b/wiretap/tnef.c
index 85115a11b2..05f2a388b9 100644
--- a/wiretap/tnef.c
+++ b/wiretap/tnef.c
@@ -46,7 +46,7 @@ static gboolean tnef_read_file(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
*/
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup_printf("tnef: File has %" G_GINT64_MODIFIER "d-byte packet, bigger than maximum of %u",
- file_size, WTAP_MAX_PACKET_SIZE);
+ file_size, WTAP_MAX_PACKET_SIZE);
return FALSE;
}
packet_size = (int)file_size;
@@ -121,3 +121,16 @@ int tnef_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_MINE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local Variables:
+ * c-basic-offset: 2
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=2 tabstop=8 expandtab:
+ * :indentSize=2:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c
index e8383a9808..e3c3501702 100644
--- a/wiretap/toshiba.c
+++ b/wiretap/toshiba.c
@@ -119,30 +119,30 @@ static gboolean parse_toshiba_packet(FILE_T fh, struct wtap_pkthdr *phdr,
and "*err_info" to null or an additional error string. */
static gint64 toshiba_seek_next_packet(wtap *wth, int *err, gchar **err_info)
{
- int byte;
- guint level = 0;
- gint64 cur_off;
-
- while ((byte = file_getc(wth->fh)) != EOF) {
- if (byte == toshiba_rec_magic[level]) {
- level++;
- if (level >= TOSHIBA_REC_MAGIC_SIZE) {
- /* note: we're leaving file pointer right after the magic characters */
- cur_off = file_tell(wth->fh);
- if (cur_off == -1) {
- /* Error. */
- *err = file_error(wth->fh, err_info);
- return -1;
- }
- return cur_off + 1;
- }
- } else {
- level = 0;
- }
- }
- /* EOF or error. */
- *err = file_error(wth->fh, err_info);
- return -1;
+ int byte;
+ guint level = 0;
+ gint64 cur_off;
+
+ while ((byte = file_getc(wth->fh)) != EOF) {
+ if (byte == toshiba_rec_magic[level]) {
+ level++;
+ if (level >= TOSHIBA_REC_MAGIC_SIZE) {
+ /* note: we're leaving file pointer right after the magic characters */
+ cur_off = file_tell(wth->fh);
+ if (cur_off == -1) {
+ /* Error. */
+ *err = file_error(wth->fh, err_info);
+ return -1;
+ }
+ return cur_off + 1;
+ }
+ } else {
+ level = 0;
+ }
+ }
+ /* EOF or error. */
+ *err = file_error(wth->fh, err_info);
+ return -1;
}
#define TOSHIBA_HEADER_LINES_TO_CHECK 200
@@ -429,3 +429,16 @@ parse_single_hex_dump_line(char* rec, guint8 *buf, guint byte_offset) {
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */
diff --git a/wiretap/visual.c b/wiretap/visual.c
index 3bb8043e86..1a6a8675f6 100644
--- a/wiretap/visual.c
+++ b/wiretap/visual.c
@@ -215,28 +215,28 @@ wtap_open_return_val visual_open(wtap *wth, int *err, gchar **err_info)
XXX - should we use WTAP_ENCAP_PER_PACKET for that? */
switch (pletoh16(&vfile_hdr.media_type))
{
- case 6: /* ethernet-csmacd */
+ case 6: /* ethernet-csmacd */
encap = WTAP_ENCAP_ETHERNET;
break;
- case 9: /* IEEE802.5 */
+ case 9: /* IEEE802.5 */
encap = WTAP_ENCAP_TOKEN_RING;
break;
- case 16: /* lapb */
+ case 16: /* lapb */
encap = WTAP_ENCAP_LAPB;
break;
- case 22: /* propPointToPointSerial */
- case 118: /* HDLC */
+ case 22: /* propPointToPointSerial */
+ case 118: /* HDLC */
encap = WTAP_ENCAP_CHDLC_WITH_PHDR;
break;
- case 32: /* frame-relay */
+ case 32: /* frame-relay */
encap = WTAP_ENCAP_FRELAY_WITH_PHDR;
break;
- case 37: /* ATM */
+ case 37: /* ATM */
encap = WTAP_ENCAP_ATM_PDUS;
break;
@@ -633,7 +633,7 @@ gboolean visual_dump_open(wtap_dumper *wdh, int *err)
just skip over it for now. It will be created after all
of the packets have been written. */
if (wtap_dump_file_seek(wdh, CAPTUREFILE_HEADER_SIZE, SEEK_SET, err) == -1)
- return FALSE;
+ return FALSE;
return TRUE;
}
@@ -793,7 +793,7 @@ static gboolean visual_dump_close(wtap_dumper *wdh, int *err)
/* Write the magic number at the start of the file. */
if (wtap_dump_file_seek(wdh, 0, SEEK_SET, err) == -1)
- return FALSE;
+ return FALSE;
magicp = visual_magic;
magic_size = sizeof visual_magic;
if (!wtap_dump_file_write(wdh, magicp, magic_size, err))
@@ -862,3 +862,16 @@ static void visual_dump_free(wtap_dumper *wdh)
g_free(visual->index_table);
}
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/vms.c b/wiretap/vms.c
index f3d14a4c23..db5848f770 100644
--- a/wiretap/vms.c
+++ b/wiretap/vms.c
@@ -126,14 +126,14 @@ to handle them.
/* Magic text to check for VMS-ness of file using possible utility names
*
*/
-#define VMS_HDR_MAGIC_STR1 "TCPIPtrace"
-#define VMS_HDR_MAGIC_STR2 "TCPtrace"
-#define VMS_HDR_MAGIC_STR3 "INTERnet trace"
+#define VMS_HDR_MAGIC_STR1 "TCPIPtrace"
+#define VMS_HDR_MAGIC_STR2 "TCPtrace"
+#define VMS_HDR_MAGIC_STR3 "INTERnet trace"
/* Magic text for start of packet */
-#define VMS_REC_MAGIC_STR1 VMS_HDR_MAGIC_STR1
-#define VMS_REC_MAGIC_STR2 VMS_HDR_MAGIC_STR2
-#define VMS_REC_MAGIC_STR3 VMS_HDR_MAGIC_STR3
+#define VMS_REC_MAGIC_STR1 VMS_HDR_MAGIC_STR1
+#define VMS_REC_MAGIC_STR2 VMS_HDR_MAGIC_STR2
+#define VMS_REC_MAGIC_STR3 VMS_HDR_MAGIC_STR3
#define VMS_HEADER_LINES_TO_CHECK 200
#define VMS_LINE_LENGTH 240
@@ -301,16 +301,16 @@ isdumpline( gchar *line )
int i, j;
while (*line && !g_ascii_isalnum(*line))
- line++;
+ line++;
for (j=0; j<4; j++) {
- for (i=0; i<8; i++, line++)
- if (! g_ascii_isxdigit(*line))
- return FALSE;
+ for (i=0; i<8; i++, line++)
+ if (! g_ascii_isxdigit(*line))
+ return FALSE;
- for (i=0; i<3; i++, line++)
- if (*line != ' ')
- return FALSE;
+ for (i=0; i<3; i++, line++)
+ if (*line != ' ')
+ return FALSE;
}
return g_ascii_isspace(*line);
@@ -322,9 +322,9 @@ parse_vms_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gch
{
char line[VMS_LINE_LENGTH + 1];
int num_items_scanned;
- int pkt_len = 0;
- int pktnum;
- int csec = 101;
+ int pkt_len = 0;
+ int pktnum;
+ int csec = 101;
struct tm tm;
char mon[4] = {'J', 'A', 'N', 0};
gchar *p;
@@ -344,58 +344,58 @@ parse_vms_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gch
do {
if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) {
*err = file_error(fh, err_info);
- if ((*err == 0) && (csec != 101)) {
- *err = WTAP_ERR_SHORT_READ;
+ if ((*err == 0) && (csec != 101)) {
+ *err = WTAP_ERR_SHORT_READ;
}
return FALSE;
}
- line[VMS_LINE_LENGTH] = '\0';
-
- if ((csec == 101) && (p = strstr(line, "packet ")) != NULL
- && (! strstr(line, "could not save "))) {
- /* Find text in line starting with "packet ". */
-
- /* First look for the Format 1 type sequencing */
- num_items_scanned = sscanf(p,
- "packet %9d at %2d-%3s-%4d %2d:%2d:%2d.%9d",
- &pktnum, &tm.tm_mday, mon,
- &tm.tm_year, &tm.tm_hour,
- &tm.tm_min, &tm.tm_sec, &csec);
- /* Next look for the Format 2 type sequencing */
- if (num_items_scanned != 8) {
- num_items_scanned = sscanf(p,
- "packet seq # = %9d at %2d-%3s-%4d %2d:%2d:%2d.%9d",
- &pktnum, &tm.tm_mday, mon,
- &tm.tm_year, &tm.tm_hour,
- &tm.tm_min, &tm.tm_sec, &csec);
- }
- /* if unknown format then exit with error */
- /* We will need to add code to handle new format */
- if (num_items_scanned != 8) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup_printf("vms: header line not valid");
- return FALSE;
- }
- }
- if ( (! pkt_len) && (p = strstr(line, "Length"))) {
- p += sizeof("Length ");
- while (*p && ! g_ascii_isdigit(*p))
- p++;
-
- if ( !*p ) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup_printf("vms: Length field not valid");
- return FALSE;
- }
-
- pkt_len = atoi(p);
- break;
- }
+ line[VMS_LINE_LENGTH] = '\0';
+
+ if ((csec == 101) && (p = strstr(line, "packet ")) != NULL
+ && (! strstr(line, "could not save "))) {
+ /* Find text in line starting with "packet ". */
+
+ /* First look for the Format 1 type sequencing */
+ num_items_scanned = sscanf(p,
+ "packet %9d at %2d-%3s-%4d %2d:%2d:%2d.%9d",
+ &pktnum, &tm.tm_mday, mon,
+ &tm.tm_year, &tm.tm_hour,
+ &tm.tm_min, &tm.tm_sec, &csec);
+ /* Next look for the Format 2 type sequencing */
+ if (num_items_scanned != 8) {
+ num_items_scanned = sscanf(p,
+ "packet seq # = %9d at %2d-%3s-%4d %2d:%2d:%2d.%9d",
+ &pktnum, &tm.tm_mday, mon,
+ &tm.tm_year, &tm.tm_hour,
+ &tm.tm_min, &tm.tm_sec, &csec);
+ }
+ /* if unknown format then exit with error */
+ /* We will need to add code to handle new format */
+ if (num_items_scanned != 8) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup_printf("vms: header line not valid");
+ return FALSE;
+ }
+ }
+ if ( (! pkt_len) && (p = strstr(line, "Length"))) {
+ p += sizeof("Length ");
+ while (*p && ! g_ascii_isdigit(*p))
+ p++;
+
+ if ( !*p ) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup_printf("vms: Length field not valid");
+ return FALSE;
+ }
+
+ pkt_len = atoi(p);
+ break;
+ }
} while (! isdumpline(line));
p = strstr(months, mon);
if (p)
- tm.tm_mon = (int) (p - months) / 3;
+ tm.tm_mon = (int) (p - months) / 3;
tm.tm_year -= 1900;
tm.tm_isdst = -1;
@@ -412,34 +412,34 @@ parse_vms_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gch
/* Convert the ASCII hex dump to binary data */
for (i = 0; i < pkt_len; i += 16) {
- if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) {
- *err = file_error(fh, err_info);
- if (*err == 0) {
- *err = WTAP_ERR_SHORT_READ;
- }
- return FALSE;
- }
- line[VMS_LINE_LENGTH] = '\0';
- if (i == 0) {
- while (! isdumpline(line)) { /* advance to start of hex data */
- if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) {
- *err = file_error(fh, err_info);
- if (*err == 0) {
- *err = WTAP_ERR_SHORT_READ;
- }
- return FALSE;
- }
- line[VMS_LINE_LENGTH] = '\0';
- }
- while (line[offset] && !g_ascii_isxdigit(line[offset]))
- offset++;
- }
- if (!parse_single_hex_dump_line(line, pd, i,
- offset, pkt_len - i)) {
- *err = WTAP_ERR_BAD_FILE;
- *err_info = g_strdup_printf("vms: hex dump not valid");
- return FALSE;
- }
+ if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) {
+ *err = file_error(fh, err_info);
+ if (*err == 0) {
+ *err = WTAP_ERR_SHORT_READ;
+ }
+ return FALSE;
+ }
+ line[VMS_LINE_LENGTH] = '\0';
+ if (i == 0) {
+ while (! isdumpline(line)) { /* advance to start of hex data */
+ if (file_gets(line, VMS_LINE_LENGTH, fh) == NULL) {
+ *err = file_error(fh, err_info);
+ if (*err == 0) {
+ *err = WTAP_ERR_SHORT_READ;
+ }
+ return FALSE;
+ }
+ line[VMS_LINE_LENGTH] = '\0';
+ }
+ while (line[offset] && !g_ascii_isxdigit(line[offset]))
+ offset++;
+ }
+ if (!parse_single_hex_dump_line(line, pd, i,
+ offset, pkt_len - i)) {
+ *err = WTAP_ERR_BAD_FILE;
+ *err_info = g_strdup_printf("vms: hex dump not valid");
+ return FALSE;
+ }
}
/* Avoid TCPIPTRACE-W-BUFFERSFUL, TCPIPtrace could not save n packets.
* errors.
@@ -448,13 +448,13 @@ parse_vms_packet(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err, gch
* Wiretap API, we should parse those lines and return "n" as
* a packet drop count. */
if (!file_gets(line, VMS_LINE_LENGTH, fh)) {
- *err = file_error(fh, err_info);
- if (*err == 0) {
- /* There is no next line, so there's no "TCPIPtrace could not
- * save n packets" line; not an error. */
- return TRUE;
- }
- return FALSE;
+ *err = file_error(fh, err_info);
+ if (*err == 0) {
+ /* There is no next line, so there's no "TCPIPtrace could not
+ * save n packets" line; not an error. */
+ return TRUE;
+ }
+ return FALSE;
}
return TRUE;
}
@@ -489,25 +489,38 @@ parse_single_hex_dump_line(char* rec, guint8 *buf, long byte_offset,
/* Get the byte_offset directly from the record */
s = rec;
- value = (int)strtoul(s + 45 + in_off, NULL, 16); /* XXX - error check? */
+ value = (int)strtoul(s + 45 + in_off, NULL, 16); /* XXX - error check? */
if (value != byte_offset) {
- return FALSE;
+ return FALSE;
}
if (remaining > 16)
- remaining = 16;
+ remaining = 16;
/* Read the octets right to left, as that is how they are displayed
* in VMS.
*/
for (i = 0; i < remaining; i++) {
- lbuf[0] = rec[offsets[i] + in_off];
- lbuf[1] = rec[offsets[i] + 1 + in_off];
+ lbuf[0] = rec[offsets[i] + in_off];
+ lbuf[1] = rec[offsets[i] + 1 + in_off];
- buf[byte_offset + i] = (guint8) strtoul(lbuf, NULL, 16);
+ buf[byte_offset + i] = (guint8) strtoul(lbuf, NULL, 16);
}
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index dd7d5aed9c..6dc8a5c150 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -1221,3 +1221,16 @@ wtap_seek_read(wtap *wth, gint64 seek_off,
return TRUE;
}
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 8
+ * tab-width: 8
+ * indent-tabs-mode: t
+ * End:
+ *
+ * vi: set shiftwidth=8 tabstop=8 noexpandtab:
+ * :indentSize=8:tabSize=8:noTabs=false:
+ */