summaryrefslogtreecommitdiffstats
path: root/wiretap/5views.c
diff options
context:
space:
mode:
Diffstat (limited to 'wiretap/5views.c')
-rw-r--r--wiretap/5views.c152
1 files changed, 76 insertions, 76 deletions
diff --git a/wiretap/5views.c b/wiretap/5views.c
index c474804a..c04e3063 100644
--- a/wiretap/5views.c
+++ b/wiretap/5views.c
@@ -7,28 +7,28 @@
*/
#include "config.h"
+#include "5views.h"
+
#include <string.h>
#include "wtap-int.h"
#include "file_wrappers.h"
-#include "5views.h"
-
typedef struct
{
- guint32 Signature;
- guint32 Size; /* Total size of Header in bytes (included Signature) */
- guint32 Version; /* Identify version and so the format of this record */
- guint32 DataSize; /* Total size of data included in the Info Record (except the header size) */
- guint32 FileType; /* Type of the file */
- guint32 Reserved[3]; /* Reserved for future use */
+ uint32_t Signature;
+ uint32_t Size; /* Total size of Header in bytes (included Signature) */
+ uint32_t Version; /* Identify version and so the format of this record */
+ uint32_t DataSize; /* Total size of data included in the Info Record (except the header size) */
+ uint32_t FileType; /* Type of the file */
+ uint32_t Reserved[3]; /* Reserved for future use */
}t_5VW_Info_Header;
typedef struct
{
- guint32 Type; /* Id of the attribute */
- guint16 Size; /* Size of the data part of the attribute (not including header size) */
- guint16 Nb; /* Number of elements */
+ uint32_t Type; /* Id of the attribute */
+ uint16_t Size; /* Size of the data part of the attribute (not including header size) */
+ uint16_t Nb; /* Number of elements */
}t_5VW_Attributes_Header;
@@ -58,23 +58,23 @@ typedef struct
{
t_5VW_Info_Header Info_Header;
t_5VW_Attributes_Header HeaderDateCreation;
- guint32 Time;
+ uint32_t Time;
t_5VW_Attributes_Header HeaderNbFrames;
- guint32 TramesStockeesInFile;
+ uint32_t TramesStockeesInFile;
}t_5VW_Capture_Header;
typedef struct
{
- guint32 Key; /* 0x3333EEEE */
- guint16 HeaderSize; /* Actual size of this header in bytes (32) */
- guint16 HeaderType; /* Exact type of this header (0x4000) */
- guint32 RecType; /* Type of record */
- guint32 RecSubType; /* Subtype of record */
- guint32 RecSize; /* Size of one record */
- guint32 RecNb; /* Number of records */
- guint32 Utc;
- guint32 NanoSecondes;
- guint32 RecInfo; /* Info about Alarm / Event / Frame captured */
+ uint32_t Key; /* 0x3333EEEE */
+ uint16_t HeaderSize; /* Actual size of this header in bytes (32) */
+ uint16_t HeaderType; /* Exact type of this header (0x4000) */
+ uint32_t RecType; /* Type of record */
+ uint32_t RecSubType; /* Subtype of record */
+ uint32_t RecSize; /* Size of one record */
+ uint32_t RecNb; /* Number of records */
+ uint32_t Utc;
+ uint32_t NanoSecondes;
+ uint32_t RecInfo; /* Info about Alarm / Event / Frame captured */
}t_5VW_TimeStamped_Header;
@@ -84,22 +84,22 @@ typedef struct
#define CST_5VW_CAPTURES_RECORD (CST_5VW_SECTION_CAPTURES << 28) /* 0x80000000 */
#define CST_5VW_SYSTEM_RECORD 0x00000000U
-static gboolean _5views_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
- gchar **err_info, gint64 *data_offset);
-static gboolean _5views_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
- Buffer *buf, int *err, gchar **err_info);
-static int _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
- wtap_rec *rec, int *err, gchar **err_info);
+static bool _5views_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
+ char **err_info, int64_t *data_offset);
+static bool _5views_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
+ Buffer *buf, int *err, char **err_info);
+static bool _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
+ wtap_rec *rec, int *err, char **err_info);
-static gboolean _5views_dump(wtap_dumper *wdh, const wtap_rec *rec, const guint8 *pd, int *err, gchar **err_info);
-static gboolean _5views_dump_finish(wtap_dumper *wdh, int *err, gchar **err_info);
+static bool _5views_dump(wtap_dumper *wdh, const wtap_rec *rec, const uint8_t *pd, int *err, char **err_info);
+static bool _5views_dump_finish(wtap_dumper *wdh, int *err, char **err_info);
static int _5views_file_type_subtype = -1;
void register_5views(void);
wtap_open_return_val
-_5views_open(wtap *wth, int *err, gchar **err_info)
+_5views_open(wtap *wth, int *err, char **err_info)
{
t_5VW_Capture_Header Capture_Header;
int encap = WTAP_ENCAP_UNKNOWN;
@@ -181,9 +181,9 @@ _5views_open(wtap *wth, int *err, gchar **err_info)
}
/* Read the next packet */
-static gboolean
+static bool
_5views_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
- gchar **err_info, gint64 *data_offset)
+ char **err_info, int64_t *data_offset)
{
t_5VW_TimeStamped_Header TimeStamped_Header;
@@ -198,7 +198,7 @@ _5views_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
/* Read record header. */
if (!_5views_read_header(wth, wth->fh, &TimeStamped_Header,
rec, err, err_info))
- return FALSE;
+ return false;
if (TimeStamped_Header.RecSubType == CST_5VW_FRAME_RECORD) {
/*
@@ -211,7 +211,7 @@ _5views_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
* Not a packet - skip to the next record.
*/
if (!wtap_read_bytes(wth->fh, NULL, TimeStamped_Header.RecSize, err, err_info))
- return FALSE;
+ return false;
} while (1);
if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
@@ -222,21 +222,21 @@ _5views_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err,
*err = WTAP_ERR_BAD_FILE;
*err_info = ws_strdup_printf("5views: 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;
}
return wtap_read_packet_bytes(wth->fh, buf,
rec->rec_header.packet_header.caplen, err, err_info);
}
-static gboolean
-_5views_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
- Buffer *buf, int *err, gchar **err_info)
+static bool
+_5views_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec,
+ Buffer *buf, int *err, char **err_info)
{
t_5VW_TimeStamped_Header TimeStamped_Header;
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
- return FALSE;
+ return false;
/*
* Read the header.
@@ -245,7 +245,7 @@ _5views_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
rec, err, err_info)) {
if (*err == 0)
*err = WTAP_ERR_SHORT_READ;
- return FALSE;
+ return false;
}
/*
@@ -255,23 +255,23 @@ _5views_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
err, err_info);
}
-/* Read the header of the next packet. Return TRUE on success, FALSE
+/* Read the header of the next packet. Return true on success, false
on error. */
-static gboolean
+static bool
_5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
- wtap_rec *rec, int *err, gchar **err_info)
+ wtap_rec *rec, int *err, char **err_info)
{
/* Read record header. */
if (!wtap_read_bytes_or_eof(fh, hdr, (unsigned int)sizeof(t_5VW_TimeStamped_Header),
err, err_info))
- return FALSE;
+ return false;
hdr->Key = pletoh32(&hdr->Key);
if (hdr->Key != CST_5VW_RECORDS_HEADER_KEY) {
*err = WTAP_ERR_BAD_FILE;
*err_info = ws_strdup_printf("5views: Time-stamped header has bad key value 0x%08X",
hdr->Key);
- return FALSE;
+ return false;
}
hdr->RecSubType = pletoh32(&hdr->RecSubType);
@@ -295,18 +295,18 @@ _5views_read_header(wtap *wth, FILE_T fh, t_5VW_TimeStamped_Header *hdr,
break;
}
- return TRUE;
+ return true;
}
typedef struct {
- guint32 nframes;
+ uint32_t nframes;
} _5views_dump_t;
static const int wtap_encap[] = {
-1, /* WTAP_ENCAP_UNKNOWN -> unsupported */
CST_5VW_CAPTURE_ETH_FILEID, /* WTAP_ENCAP_ETHERNET -> Ethernet */
};
-#define NUM_WTAP_ENCAPS (sizeof wtap_encap / sizeof wtap_encap[0])
+#define NUM_WTAP_ENCAPS array_length(wtap_encap)
/* Returns 0 if we could write the specified encapsulation type,
an error indication otherwise. */
@@ -322,9 +322,9 @@ static int _5views_dump_can_write_encap(int encap)
return 0;
}
-/* Returns TRUE on success, FALSE on failure; sets "*err" to an error code on
+/* Returns true on success, false on failure; sets "*err" to an error code on
failure */
-static gboolean _5views_dump_open(wtap_dumper *wdh, int *err, gchar **err_info _U_)
+static bool _5views_dump_open(wtap_dumper *wdh, int *err, char **err_info _U_)
{
_5views_dump_t *_5views;
@@ -333,7 +333,7 @@ static gboolean _5views_dump_open(wtap_dumper *wdh, int *err, gchar **err_info _
the header when we've written out all the packets, we just
skip over the header for now. */
if (wtap_dump_file_seek(wdh, sizeof(t_5VW_Capture_Header), SEEK_SET, err) == -1)
- return FALSE;
+ return false;
/* This is a 5Views file */
wdh->subtype_write = _5views_dump;
@@ -342,14 +342,14 @@ static gboolean _5views_dump_open(wtap_dumper *wdh, int *err, gchar **err_info _
wdh->priv = (void *)_5views;
_5views->nframes = 0;
- return TRUE;
+ return true;
}
/* Write a record for a packet to a dump file.
- Returns TRUE on success, FALSE on failure. */
-static gboolean _5views_dump(wtap_dumper *wdh,
+ Returns true on success, false on failure. */
+static bool _5views_dump(wtap_dumper *wdh,
const wtap_rec *rec,
- const guint8 *pd, int *err, gchar **err_info _U_)
+ const uint8_t *pd, int *err, char **err_info _U_)
{
_5views_dump_t *_5views = (_5views_dump_t *)wdh->priv;
t_5VW_TimeStamped_Header HeaderFrame;
@@ -357,7 +357,7 @@ static gboolean _5views_dump(wtap_dumper *wdh,
/* We can only write packet records. */
if (rec->rec_type != REC_TYPE_PACKET) {
*err = WTAP_ERR_UNWRITABLE_REC_TYPE;
- return FALSE;
+ return false;
}
/*
@@ -366,13 +366,13 @@ static gboolean _5views_dump(wtap_dumper *wdh,
*/
if (wdh->file_encap != rec->rec_header.packet_header.pkt_encap) {
*err = WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED;
- return FALSE;
+ return false;
}
/* Don't write out something bigger than we can read. */
if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
*err = WTAP_ERR_PACKET_TOO_LARGE;
- return FALSE;
+ return false;
}
/* Frame Header */
@@ -387,14 +387,14 @@ static gboolean _5views_dump(wtap_dumper *wdh,
/* record-dependent fields */
/*
* XXX - is the frame time signed, or unsigned? If it's signed,
- * we should check against G_MININT32 and G_MAXINT32 and make
- * Utc a gint32.
+ * we should check against INT32_MIN and INT32_MAX and make
+ * Utc an int32_t.
*/
if (rec->ts.secs < 0 || rec->ts.secs > WTAP_NSTIME_32BIT_SECS_MAX) {
*err = WTAP_ERR_TIME_STAMP_NOT_SUPPORTED;
- return FALSE;
+ return false;
}
- HeaderFrame.Utc = GUINT32_TO_LE((guint32)rec->ts.secs);
+ HeaderFrame.Utc = GUINT32_TO_LE((uint32_t)rec->ts.secs);
HeaderFrame.NanoSecondes = GUINT32_TO_LE(rec->ts.nsecs);
HeaderFrame.RecSize = GUINT32_TO_LE(rec->rec_header.packet_header.len);
HeaderFrame.RecInfo = GUINT32_TO_LE(0);
@@ -402,33 +402,33 @@ static gboolean _5views_dump(wtap_dumper *wdh,
/* write the record header */
if (!wtap_dump_file_write(wdh, &HeaderFrame,
sizeof(t_5VW_TimeStamped_Header), err))
- return FALSE;
+ return false;
/* write the data */
if (!wtap_dump_file_write(wdh, pd, rec->rec_header.packet_header.caplen, err))
- return FALSE;
+ return false;
_5views->nframes ++;
- return TRUE;
+ return true;
}
-static gboolean _5views_dump_finish(wtap_dumper *wdh, int *err, gchar **err_info _U_)
+static bool _5views_dump_finish(wtap_dumper *wdh, int *err, char **err_info _U_)
{
_5views_dump_t *_5views = (_5views_dump_t *)wdh->priv;
t_5VW_Capture_Header file_hdr;
if (wtap_dump_file_seek(wdh, 0, SEEK_SET, err) == -1)
- return FALSE;
+ return false;
/* fill in the Info_Header */
file_hdr.Info_Header.Signature = GUINT32_TO_LE(CST_5VW_INFO_HEADER_KEY);
file_hdr.Info_Header.Size = GUINT32_TO_LE(sizeof(t_5VW_Info_Header)); /* Total size of Header in bytes (included Signature) */
file_hdr.Info_Header.Version = GUINT32_TO_LE(CST_5VW_INFO_RECORD_VERSION); /* Identify version and so the format of this record */
file_hdr.Info_Header.DataSize = GUINT32_TO_LE(sizeof(t_5VW_Attributes_Header)
- + sizeof(guint32)
+ + sizeof(uint32_t)
+ sizeof(t_5VW_Attributes_Header)
- + sizeof(guint32));
+ + sizeof(uint32_t));
/* Total size of data included in the Info Record (except the header size) */
file_hdr.Info_Header.FileType = GUINT32_TO_LE(wtap_encap[wdh->file_encap]); /* Type of the file */
file_hdr.Info_Header.Reserved[0] = 0; /* Reserved for future use */
@@ -437,7 +437,7 @@ static gboolean _5views_dump_finish(wtap_dumper *wdh, int *err, gchar **err_info
/* fill in the HeaderDateCreation */
file_hdr.HeaderDateCreation.Type = GUINT32_TO_LE(CST_5VW_IA_DATE_CREATION); /* Id of the attribute */
- file_hdr.HeaderDateCreation.Size = GUINT16_TO_LE(sizeof(guint32)); /* Size of the data part of the attribute (not including header size) */
+ file_hdr.HeaderDateCreation.Size = GUINT16_TO_LE(sizeof(uint32_t)); /* Size of the data part of the attribute (not including header size) */
file_hdr.HeaderDateCreation.Nb = GUINT16_TO_LE(1); /* Number of elements */
/* fill in the Time field */
@@ -448,7 +448,7 @@ static gboolean _5views_dump_finish(wtap_dumper *wdh, int *err, gchar **err_info
/* fill in the Time field */
file_hdr.HeaderNbFrames.Type = GUINT32_TO_LE(CST_5VW_IA_CAP_INF_NB_TRAMES_STOCKEES); /* Id of the attribute */
- file_hdr.HeaderNbFrames.Size = GUINT16_TO_LE(sizeof(guint32)); /* Size of the data part of the attribute (not including header size) */
+ file_hdr.HeaderNbFrames.Size = GUINT16_TO_LE(sizeof(uint32_t)); /* Size of the data part of the attribute (not including header size) */
file_hdr.HeaderNbFrames.Nb = GUINT16_TO_LE(1); /* Number of elements */
/* fill in the number of frames saved */
@@ -457,9 +457,9 @@ static gboolean _5views_dump_finish(wtap_dumper *wdh, int *err, gchar **err_info
/* Write the file header. */
if (!wtap_dump_file_write(wdh, &file_hdr, sizeof(t_5VW_Capture_Header),
err))
- return FALSE;
+ return false;
- return TRUE;
+ return true;
}
static const struct supported_block_type _5views_blocks_supported[] = {
@@ -471,7 +471,7 @@ static const struct supported_block_type _5views_blocks_supported[] = {
static const struct file_type_subtype_info _5views_info = {
"InfoVista 5View capture", "5views", "5vw", NULL,
- TRUE, BLOCKS_SUPPORTED(_5views_blocks_supported),
+ true, BLOCKS_SUPPORTED(_5views_blocks_supported),
_5views_dump_can_write_encap, _5views_dump_open, NULL
};