summaryrefslogtreecommitdiffstats
path: root/wiretap/dbs-etherwatch.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--wiretap/dbs-etherwatch.c116
1 files changed, 58 insertions, 58 deletions
diff --git a/wiretap/dbs-etherwatch.c b/wiretap/dbs-etherwatch.c
index 4147b039..2ee92eb5 100644
--- a/wiretap/dbs-etherwatch.c
+++ b/wiretap/dbs-etherwatch.c
@@ -7,8 +7,8 @@
*/
#include "config.h"
-#include "wtap-int.h"
#include "dbs-etherwatch.h"
+#include "wtap-int.h"
#include "file_wrappers.h"
#include <stdlib.h>
@@ -56,13 +56,13 @@ Protocol 08-00 00 00-00-00-00-00, 50 byte buffer at 10-OCT-2001 10:20:45.17
static const char dbs_etherwatch_hdr_magic[] =
{ 'E', 'T', 'H', 'E', 'R', 'W', 'A', 'T', 'C', 'H', ' '};
#define DBS_ETHERWATCH_HDR_MAGIC_SIZE \
- (sizeof dbs_etherwatch_hdr_magic / sizeof dbs_etherwatch_hdr_magic[0])
+ array_length(dbs_etherwatch_hdr_magic)
/* Magic text for start of packet */
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])
+ array_length(dbs_etherwatch_rec_magic)
/*
* Default packet size - maximum normal Ethernet packet size, without an
@@ -70,15 +70,15 @@ static const char dbs_etherwatch_rec_magic[] =
*/
#define DBS_ETHERWATCH_MAX_ETHERNET_PACKET_LEN 1514
-static gboolean dbs_etherwatch_read(wtap *wth, wtap_rec *rec,
- Buffer *buf, int *err, gchar **err_info, gint64 *data_offset);
-static gboolean dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
- wtap_rec *rec, Buffer *buf, int *err, gchar **err_info);
-static gboolean parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec,
- Buffer* buf, int *err, gchar **err_info);
-static guint parse_single_hex_dump_line(char* rec, guint8 *buf,
+static bool dbs_etherwatch_read(wtap *wth, wtap_rec *rec,
+ Buffer *buf, int *err, char **err_info, int64_t *data_offset);
+static bool dbs_etherwatch_seek_read(wtap *wth, int64_t seek_off,
+ wtap_rec *rec, Buffer *buf, int *err, char **err_info);
+static bool parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec,
+ Buffer* buf, int *err, char **err_info);
+static unsigned parse_single_hex_dump_line(char* rec, uint8_t *buf,
int byte_offset);
-static guint parse_hex_dump(char* dump, guint8 *buf, char separator, char end);
+static unsigned parse_hex_dump(char* dump, uint8_t *buf, char separator, char end);
static int dbs_etherwatch_file_type_subtype = -1;
@@ -87,12 +87,12 @@ void register_dbs_etherwatch(void);
/* 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)
+static int64_t dbs_etherwatch_seek_next_packet(wtap *wth, int *err,
+ char **err_info)
{
int byte;
unsigned int level = 0;
- gint64 cur_off;
+ int64_t cur_off;
while ((byte = file_getc(wth->fh)) != EOF) {
if (byte == dbs_etherwatch_rec_magic[level]) {
@@ -122,16 +122,16 @@ static gint64 dbs_etherwatch_seek_next_packet(wtap *wth, int *err,
/* Look through the first part of a file to see if this is
* a DBS Ethertrace text trace file.
*
- * Returns TRUE if it is, FALSE if it isn't or if we get an I/O error;
+ * Returns true if it is, false if it isn't or if we get an I/O error;
* if we get an I/O error, "*err" will be set to a non-zero value and
* "*err_info" will be set to null or an error string.
*/
-static gboolean dbs_etherwatch_check_file_type(wtap *wth, int *err,
- gchar **err_info)
+static bool dbs_etherwatch_check_file_type(wtap *wth, int *err,
+ char **err_info)
{
char buf[DBS_ETHERWATCH_LINE_LENGTH];
int line, byte;
- gsize reclen;
+ size_t reclen;
unsigned int i, level;
buf[DBS_ETHERWATCH_LINE_LENGTH-1] = 0;
@@ -140,7 +140,7 @@ static gboolean dbs_etherwatch_check_file_type(wtap *wth, int *err,
if (file_gets(buf, DBS_ETHERWATCH_LINE_LENGTH, wth->fh) == NULL) {
/* EOF or error. */
*err = file_error(wth->fh, err_info);
- return FALSE;
+ return false;
}
reclen = strlen(buf);
@@ -154,7 +154,7 @@ static gboolean dbs_etherwatch_check_file_type(wtap *wth, int *err,
level++;
if (level >=
DBS_ETHERWATCH_HDR_MAGIC_SIZE) {
- return TRUE;
+ return true;
}
}
else
@@ -162,11 +162,11 @@ static gboolean dbs_etherwatch_check_file_type(wtap *wth, int *err,
}
}
*err = 0;
- return FALSE;
+ return false;
}
-wtap_open_return_val dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info)
+wtap_open_return_val dbs_etherwatch_open(wtap *wth, int *err, char **err_info)
{
/* Look for DBS ETHERWATCH header */
if (!dbs_etherwatch_check_file_type(wth, err, err_info)) {
@@ -194,15 +194,15 @@ wtap_open_return_val dbs_etherwatch_open(wtap *wth, int *err, gchar **err_info)
}
/* Find the next packet and parse it; called from wtap_read(). */
-static gboolean dbs_etherwatch_read(wtap *wth, wtap_rec *rec,
- Buffer *buf, int *err, gchar **err_info, gint64 *data_offset)
+static bool dbs_etherwatch_read(wtap *wth, wtap_rec *rec,
+ Buffer *buf, int *err, char **err_info, int64_t *data_offset)
{
- gint64 offset;
+ int64_t offset;
/* Find the next packet */
offset = dbs_etherwatch_seek_next_packet(wth, err, err_info);
if (offset < 1)
- return FALSE;
+ return false;
*data_offset = offset;
/* Parse the packet */
@@ -210,12 +210,12 @@ static gboolean dbs_etherwatch_read(wtap *wth, wtap_rec *rec,
}
/* Used to read packets in random-access fashion */
-static gboolean
-dbs_etherwatch_seek_read(wtap *wth, gint64 seek_off,
- wtap_rec *rec, Buffer *buf, int *err, gchar **err_info)
+static bool
+dbs_etherwatch_seek_read(wtap *wth, int64_t seek_off,
+ wtap_rec *rec, Buffer *buf, int *err, char **err_info)
{
if (file_seek(wth->random_fh, seek_off - 1, SEEK_SET, err) == -1)
- return FALSE;
+ return false;
return parse_dbs_etherwatch_packet(wth->random_fh, rec, buf, err,
err_info);
@@ -265,19 +265,19 @@ unnumbered. Unnumbered has length 1, numbered 2.
*/
#define CTL_UNNUMB_MASK 0x03
#define CTL_UNNUMB_VALUE 0x03
-static gboolean
+static bool
parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
- int *err, gchar **err_info)
+ int *err, char **err_info)
{
- guint8 *pd;
+ uint8_t *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";
+ char *p;
+ static const char months[] = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
int count, line_count;
/* Make sure we have enough room for a regular Ethernet packet */
@@ -295,7 +295,7 @@ parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
- return FALSE;
+ return false;
}
/* Get the destination address */
@@ -303,14 +303,14 @@ parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
if(!p) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup("dbs_etherwatch: destination address not found");
- return FALSE;
+ 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;
+ return false;
}
eth_hdr_len += MAC_ADDR_LENGTH;
@@ -328,7 +328,7 @@ parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
HEX_HDR_END) != MAC_ADDR_LENGTH) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup("dbs_etherwatch: source address not valid");
- return FALSE;
+ return false;
}
eth_hdr_len += MAC_ADDR_LENGTH;
@@ -338,14 +338,14 @@ parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
- return FALSE;
+ 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;
+ return false;
}
num_items_scanned = sscanf(line + LENGTH_POS,
@@ -358,13 +358,13 @@ parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
if (num_items_scanned != 8) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup("dbs_etherwatch: header line not valid");
- return FALSE;
+ return false;
}
if (pkt_len < 0) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup("dbs_etherwatch: packet header has a negative packet length");
- return FALSE;
+ return false;
}
/* Determine whether it is Ethernet II or IEEE 802 */
@@ -376,7 +376,7 @@ parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
HEX_HDR_END) != PROTOCOL_LENGTH) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup("dbs_etherwatch: Ethernet II protocol value not valid");
- return FALSE;
+ return false;
}
eth_hdr_len += PROTOCOL_LENGTH;
} else {
@@ -392,7 +392,7 @@ parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
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;
+ return false;
}
eth_hdr_len += SAP_LENGTH;
/* Get the (first part of the) control field */
@@ -400,7 +400,7 @@ parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
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;
+ return false;
}
/* Determine whether the control is numbered, and thus longer */
if((pd[eth_hdr_len] & CTL_UNNUMB_MASK) != CTL_UNNUMB_VALUE) {
@@ -410,7 +410,7 @@ parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
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;
+ return false;
}
eth_hdr_len += CTL_NUMB_LENGTH;
} else {
@@ -424,7 +424,7 @@ parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
HEX_PID_END) != PID_LENGTH) {
*err = WTAP_ERR_BAD_FILE;
*err_info = g_strdup("dbs_etherwatch: 802.2 PID value not valid");
- return FALSE;
+ return false;
}
eth_hdr_len += PID_LENGTH;
}
@@ -458,7 +458,7 @@ parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
*err = WTAP_ERR_BAD_FILE;
*err_info = ws_strdup_printf("dbs_etherwatch: File has %u-byte packet, bigger than maximum of %u",
rec->rec_header.packet_header.caplen, WTAP_MAX_PACKET_SIZE_STANDARD);
- return FALSE;
+ return false;
}
/* Make sure we have enough room, even for an oversized Ethernet packet */
@@ -478,22 +478,22 @@ parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
if (*err == 0) {
*err = WTAP_ERR_SHORT_READ;
}
- return FALSE;
+ 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;
+ 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 false;
}
}
- return TRUE;
+ return true;
}
/* Parse a hex dump line */
@@ -533,8 +533,8 @@ parse_dbs_etherwatch_packet(FILE_T fh, wtap_rec *rec, Buffer* buf,
*
* Returns length parsed if a good hex dump, 0 if bad.
*/
-static guint
-parse_single_hex_dump_line(char* rec, guint8 *buf, int byte_offset) {
+static unsigned
+parse_single_hex_dump_line(char* rec, uint8_t *buf, int byte_offset) {
int pos, i;
int value;
@@ -596,8 +596,8 @@ parse_single_hex_dump_line(char* rec, guint8 *buf, int byte_offset) {
}
/* Parse a hex dump */
-static guint
-parse_hex_dump(char* dump, guint8 *buf, char separator, char end) {
+static unsigned
+parse_hex_dump(char* dump, uint8_t *buf, char separator, char end) {
int pos, count;
/* Parse the hex dump */
@@ -640,7 +640,7 @@ static const struct supported_block_type dbs_etherwatch_blocks_supported[] = {
static const struct file_type_subtype_info dbs_etherwatch_info = {
"DBS Etherwatch (VMS)", "etherwatch", "txt", NULL,
- FALSE, BLOCKS_SUPPORTED(dbs_etherwatch_blocks_supported),
+ false, BLOCKS_SUPPORTED(dbs_etherwatch_blocks_supported),
NULL, NULL, NULL
};