summaryrefslogtreecommitdiffstats
path: root/wiretap/autosar_dlt.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--wiretap/autosar_dlt.c112
1 files changed, 56 insertions, 56 deletions
diff --git a/wiretap/autosar_dlt.c b/wiretap/autosar_dlt.c
index 5310443c..721da3c7 100644
--- a/wiretap/autosar_dlt.c
+++ b/wiretap/autosar_dlt.c
@@ -26,34 +26,34 @@
#include "file_wrappers.h"
#include "wtap-int.h"
-static const guint8 dlt_magic[] = { 'D', 'L', 'T', 0x01 };
+static const uint8_t dlt_magic[] = { 'D', 'L', 'T', 0x01 };
static int autosar_dlt_file_type_subtype = -1;
void register_autosar_dlt(void);
-static gboolean autosar_dlt_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info, gint64 *data_offset);
-static gboolean autosar_dlt_seek_read(wtap *wth, gint64 seek_off, wtap_rec* rec, Buffer *buf, int *err, gchar **err_info);
+static bool autosar_dlt_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, char **err_info, int64_t *data_offset);
+static bool autosar_dlt_seek_read(wtap *wth, int64_t seek_off, wtap_rec* rec, Buffer *buf, int *err, char **err_info);
static void autosar_dlt_close(wtap *wth);
typedef struct autosar_dlt_blockheader {
- guint8 magic[4];
- guint32 timestamp_s;
- guint32 timestamp_us;
- guint8 ecu_id[4];
+ uint8_t magic[4];
+ uint32_t timestamp_s;
+ uint32_t timestamp_us;
+ uint8_t ecu_id[4];
} autosar_dlt_blockheader_t;
typedef struct autosar_dlt_itemheader {
- guint8 header_type;
- guint8 counter;
- guint16 length;
+ uint8_t header_type;
+ uint8_t counter;
+ uint16_t length;
} autosar_dlt_itemheader_t;
typedef struct autosar_dlt_data {
GHashTable *ecu_to_iface_ht;
- guint32 next_interface_id;
+ uint32_t next_interface_id;
} autosar_dlt_t;
typedef struct autosar_dlt_params {
@@ -65,18 +65,18 @@ typedef struct autosar_dlt_params {
autosar_dlt_t *dlt_data;
} autosar_dlt_params_t;
-static gint
-autosar_dlt_calc_key(guint8 ecu[4]) {
- return (gint)(ecu[0] << 24 | ecu[1] << 16 | ecu[2] << 8 | ecu[3]);
+static int
+autosar_dlt_calc_key(uint8_t ecu[4]) {
+ return (int)(ecu[0] << 24 | ecu[1] << 16 | ecu[2] << 8 | ecu[3]);
}
-static guint32
-autosar_dlt_add_interface(autosar_dlt_params_t *params, guint8 ecu[4]) {
+static uint32_t
+autosar_dlt_add_interface(autosar_dlt_params_t *params, uint8_t ecu[4]) {
wtap_block_t int_data = wtap_block_create(WTAP_BLOCK_IF_ID_AND_INFO);
wtapng_if_descr_mandatory_t *if_descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data);
if_descr_mand->wtap_encap = WTAP_ENCAP_AUTOSAR_DLT;
- wtap_block_add_string_option(int_data, OPT_IDB_NAME, (gchar *)ecu, 4);
+ wtap_block_add_string_option(int_data, OPT_IDB_NAME, (char *)ecu, 4);
if_descr_mand->time_units_per_second = 1000 * 1000 * 1000;
if_descr_mand->tsprecision = WTAP_TSPREC_NSEC;
wtap_block_add_uint8_option(int_data, OPT_IDB_TSRESOL, 9);
@@ -93,23 +93,23 @@ autosar_dlt_add_interface(autosar_dlt_params_t *params, guint8 ecu[4]) {
}
}
- gint32 key = autosar_dlt_calc_key(ecu);
- guint32 iface_id = params->dlt_data->next_interface_id++;
+ int32_t key = autosar_dlt_calc_key(ecu);
+ uint32_t iface_id = params->dlt_data->next_interface_id++;
g_hash_table_insert(params->dlt_data->ecu_to_iface_ht, GINT_TO_POINTER(key), GUINT_TO_POINTER(iface_id));
return iface_id;
}
-static guint32
-autosar_dlt_lookup_interface(autosar_dlt_params_t *params, guint8 ecu[4]) {
- gint32 key = autosar_dlt_calc_key(ecu);
+static uint32_t
+autosar_dlt_lookup_interface(autosar_dlt_params_t *params, uint8_t ecu[4]) {
+ int32_t key = autosar_dlt_calc_key(ecu);
if (params->dlt_data->ecu_to_iface_ht == NULL) {
return 0;
}
- gpointer iface = NULL;
- gboolean found = g_hash_table_lookup_extended(params->dlt_data->ecu_to_iface_ht, GINT_TO_POINTER(key), NULL, &iface);
+ void *iface = NULL;
+ bool found = g_hash_table_lookup_extended(params->dlt_data->ecu_to_iface_ht, GINT_TO_POINTER(key), NULL, &iface);
if (found) {
return GPOINTER_TO_UINT(iface);
@@ -129,8 +129,8 @@ fix_endianness_autosar_dlt_itemheader(autosar_dlt_itemheader_t *header) {
header->length = GUINT16_FROM_BE(header->length);
}
-static gboolean
-autosar_dlt_read_block(autosar_dlt_params_t *params, gint64 start_pos, int *err, gchar **err_info) {
+static bool
+autosar_dlt_read_block(autosar_dlt_params_t *params, int64_t start_pos, int *err, char **err_info) {
autosar_dlt_blockheader_t header;
autosar_dlt_itemheader_t item_header;
@@ -143,7 +143,7 @@ autosar_dlt_read_block(autosar_dlt_params_t *params, gint64 start_pos, int *err,
g_free(*err_info);
*err_info = ws_strdup_printf("AUTOSAR DLT: Capture file cut short! Cannot find storage header at pos 0x%" PRIx64 "!", start_pos);
}
- return FALSE;
+ return false;
}
fix_endianness_autosar_dlt_blockheader(&header);
@@ -151,33 +151,33 @@ autosar_dlt_read_block(autosar_dlt_params_t *params, gint64 start_pos, int *err,
if (memcmp(header.magic, dlt_magic, sizeof(dlt_magic))) {
*err = WTAP_ERR_BAD_FILE;
*err_info = ws_strdup_printf("AUTOSAR DLT: Bad capture file! Object magic is not DLT\\x01 at pos 0x%" PRIx64 "!", start_pos);
- return FALSE;
+ return false;
}
/* Set to the byte after the magic. */
- guint64 current_start_of_item = file_tell(params->fh) - sizeof header + 4;
+ uint64_t current_start_of_item = file_tell(params->fh) - sizeof header + 4;
if (!wtap_read_bytes_or_eof(params->fh, &item_header, sizeof item_header, err, err_info)) {
*err = WTAP_ERR_BAD_FILE;
g_free(*err_info);
*err_info = ws_strdup_printf("AUTOSAR DLT: Capture file cut short! Not enough bytes for item header at pos 0x%" PRIx64 "!", start_pos);
- return FALSE;
+ return false;
}
fix_endianness_autosar_dlt_itemheader(&item_header);
if (file_seek(params->fh, current_start_of_item, SEEK_SET, err) < 0) {
- return FALSE;
+ return false;
}
- ws_buffer_assure_space(params->buf, (gsize)(item_header.length + sizeof header));
+ ws_buffer_assure_space(params->buf, (size_t)(item_header.length + sizeof header));
/* Creating AUTOSAR DLT Encapsulation Header:
- * guint32 time_s
- * guint32 time_us
- * guint8[4] ecuname
- * guint8[1] 0x00 (termination)
- * guint8[3] reserved
+ * uint32_t time_s
+ * uint32_t time_us
+ * uint8_t[4] ecuname
+ * uint8_t[1] 0x00 (termination)
+ * uint8_t[3] reserved
*/
void *tmpbuf = g_malloc0(sizeof header);
if (!wtap_read_bytes_or_eof(params->fh, tmpbuf, sizeof header - 4, err, err_info)) {
@@ -185,24 +185,24 @@ autosar_dlt_read_block(autosar_dlt_params_t *params, gint64 start_pos, int *err,
*err = WTAP_ERR_BAD_FILE;
g_free(*err_info);
*err_info = ws_strdup_printf("AUTOSAR DLT: Internal Error! Not enough bytes for storage header at pos 0x%" PRIx64 "!", start_pos);
- return FALSE;
+ return false;
}
- ws_buffer_append(params->buf, tmpbuf, (gsize)(sizeof header));
+ ws_buffer_append(params->buf, tmpbuf, (size_t)(sizeof header));
g_free(tmpbuf);
tmpbuf = g_try_malloc0(item_header.length);
if (tmpbuf == NULL) {
*err = ENOMEM; /* we assume we're out of memory */
- return FALSE;
+ return false;
}
if (!wtap_read_bytes_or_eof(params->fh, tmpbuf, item_header.length, err, err_info)) {
*err = WTAP_ERR_BAD_FILE;
g_free(*err_info);
*err_info = ws_strdup_printf("AUTOSAR DLT: Capture file cut short! Not enough bytes for item at pos 0x%" PRIx64 "!", start_pos);
- return FALSE;
+ return false;
}
- ws_buffer_append(params->buf, tmpbuf, (gsize)(item_header.length));
+ ws_buffer_append(params->buf, tmpbuf, (size_t)(item_header.length));
g_free(tmpbuf);
params->rec->rec_type = REC_TYPE_PACKET;
@@ -212,18 +212,18 @@ autosar_dlt_read_block(autosar_dlt_params_t *params, gint64 start_pos, int *err,
params->rec->ts.secs = header.timestamp_s;
params->rec->ts.nsecs = header.timestamp_us * 1000;
- params->rec->rec_header.packet_header.caplen = (guint32)(item_header.length + sizeof header);
- params->rec->rec_header.packet_header.len = (guint32)(item_header.length + sizeof header);
+ params->rec->rec_header.packet_header.caplen = (uint32_t)(item_header.length + sizeof header);
+ params->rec->rec_header.packet_header.len = (uint32_t)(item_header.length + sizeof header);
params->rec->rec_header.packet_header.pkt_encap = WTAP_ENCAP_AUTOSAR_DLT;
params->rec->rec_header.packet_header.interface_id = autosar_dlt_lookup_interface(params, header.ecu_id);
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
-static gboolean autosar_dlt_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info, gint64 *data_offset) {
+static bool autosar_dlt_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err, char **err_info, int64_t *data_offset) {
autosar_dlt_params_t dlt_tmp;
dlt_tmp.wth = wth;
@@ -236,13 +236,13 @@ static gboolean autosar_dlt_read(wtap *wth, wtap_rec *rec, Buffer *buf, int *err
if (!autosar_dlt_read_block(&dlt_tmp, *data_offset, err, err_info)) {
ws_debug("couldn't read packet block (data_offset is %" PRId64 ")", *data_offset);
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
-static gboolean autosar_dlt_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec, Buffer *buf, int *err, gchar **err_info) {
+static bool autosar_dlt_seek_read(wtap *wth, int64_t seek_off, wtap_rec *rec, Buffer *buf, int *err, char **err_info) {
autosar_dlt_params_t dlt_tmp;
dlt_tmp.wth = wth;
@@ -252,14 +252,14 @@ static gboolean autosar_dlt_seek_read(wtap *wth, gint64 seek_off, wtap_rec *rec,
dlt_tmp.dlt_data = (autosar_dlt_t *)wth->priv;
if (file_seek(wth->random_fh, seek_off, SEEK_SET, err) == -1)
- return FALSE;
+ return false;
if (!autosar_dlt_read_block(&dlt_tmp, seek_off, err, err_info)) {
ws_debug("couldn't read packet block (seek_off: %" PRId64 ") (err=%d).", seek_off, *err);
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
static void autosar_dlt_close(wtap *wth) {
@@ -277,8 +277,8 @@ static void autosar_dlt_close(wtap *wth) {
}
wtap_open_return_val
-autosar_dlt_open(wtap *wth, int *err, gchar **err_info) {
- guint8 magic[4];
+autosar_dlt_open(wtap *wth, int *err, char **err_info) {
+ uint8_t magic[4];
autosar_dlt_t *dlt;
ws_debug("opening file");
@@ -329,7 +329,7 @@ static const struct supported_block_type dlt_blocks_supported[] = {
static const struct file_type_subtype_info dlt_info = {
"AUTOSAR DLT Logfile", "dlt", "dlt", NULL,
- FALSE, BLOCKS_SUPPORTED(dlt_blocks_supported),
+ false, BLOCKS_SUPPORTED(dlt_blocks_supported),
NULL, NULL, NULL
};