aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/address.h6
-rw-r--r--epan/address_types.c17
-rw-r--r--epan/dissectors/packet-opensafety.c18
3 files changed, 20 insertions, 21 deletions
diff --git a/epan/address.h b/epan/address.h
index 21f5768b59..4196a6655e 100644
--- a/epan/address.h
+++ b/epan/address.h
@@ -30,10 +30,8 @@ extern "C" {
* from address_types.h
*
* AT_NUMERIC - a numeric address type can consist of a guint8, guint16, guint32 or guint64
- * little-endian value. If no correct length is provided, to avoid data bleed, a guint8 is
- * assumed. If the value represented is originating from a big-endian system, it is the
- * responsibility of the dissector to do the proper conversion. Only representation (aka
- * conversion of value to string) is implemented for this type.
+ * value. If no correct length is provided, to avoid data bleed, a guint8 is
+ * assumed. Only representation (aka conversion of value to string) is implemented for this type.
*/
typedef enum {
AT_NONE, /* no link-layer address */
diff --git a/epan/address_types.c b/epan/address_types.c
index aa0801771a..e4424ef817 100644
--- a/epan/address_types.c
+++ b/epan/address_types.c
@@ -532,7 +532,7 @@ const size_t MAX_UINT32_WIDTH = 11;
const size_t MAX_UINT16_WIDTH = 6;
const size_t MAX_UINT8_WIDTH = 4;
-static int numeric_addr_str_len(const address* addr _U_)
+static int numeric_addr_str_len(const address* addr)
{
if (addr->len == (int) sizeof(guint64)) {
return (int) MAX_UINT64_WIDTH;
@@ -545,22 +545,21 @@ static int numeric_addr_str_len(const address* addr _U_)
return (int) MAX_UINT8_WIDTH;
}
-static int numeric_addr_to_str(const address* addr, gchar *buf, int buf_len _U_)
+static int numeric_addr_to_str(const address* addr, gchar *buf, int buf_len)
{
- int len = numeric_addr_str_len(addr);
+ int ret;
- memset(buf, '\0', len);
if (addr->len == (int) sizeof(guint64)) {
- snprintf(buf, len, "%"PRIu64, pletoh64(addr->data));
+ ret = snprintf(buf, buf_len, "%"PRIu64, *(guint64 *)addr->data);
} else if (addr->len == (int) sizeof(guint32)) {
- snprintf(buf, len, "%u", pletoh32(addr->data));
+ ret = snprintf(buf, buf_len, "%"PRIu32, *(guint32 *)addr->data);
} else if (addr->len == (int) sizeof(guint16)) {
- snprintf(buf, len, "%u", pletoh16(addr->data));
+ ret = snprintf(buf, buf_len, "%"PRIu16, *(guint16 *)addr->data);
} else {
- snprintf(buf, len, "%u", *((guint8*) (addr->data)));
+ ret = snprintf(buf, buf_len, "%"PRIu8, *(guint8 *)addr->data);
}
- return len;
+ return ret + 1;
}
/******************************************************************************
diff --git a/epan/dissectors/packet-opensafety.c b/epan/dissectors/packet-opensafety.c
index 97ffec649d..3c8f337a2e 100644
--- a/epan/dissectors/packet-opensafety.c
+++ b/epan/dissectors/packet-opensafety.c
@@ -1988,19 +1988,20 @@ static hostlist_dissector_info_t opensafety_dissector_info = {&opensafety_get_f
static tap_packet_status
opensafety_conversation_packet(void *pct, packet_info *pinfo,
- epan_dissect_t *edt _U_, const void *vip _U_, tap_flags_t flags)
+ epan_dissect_t *edt _U_, const void *vip, tap_flags_t flags)
{
address *src = (address *)wmem_alloc0(pinfo->pool, sizeof(address));
address *dst = (address *)wmem_alloc0(pinfo->pool, sizeof(address));
conv_hash_t *hash = (conv_hash_t*) pct;
- opensafety_packet_info * osinfo = (opensafety_packet_info *)vip;
- guint16 receiver = osinfo->receiver;
+ const opensafety_packet_info *osinfo = (const opensafety_packet_info *)vip;
+ guint16 receiver = GUINT16_FROM_LE(osinfo->receiver);
if (osinfo->msg_type == OPENSAFETY_SPDO_MESSAGE_TYPE)
receiver = OSS_BROADCAST_ADDRESS;
+ guint16 sender = GUINT16_FROM_LE(osinfo->sender);
hash->flags = flags;
- alloc_address_wmem(pinfo->pool, src, AT_NUMERIC, (int) sizeof(guint16), &osinfo->sender);
+ alloc_address_wmem(pinfo->pool, src, AT_NUMERIC, (int) sizeof(guint16), &sender);
alloc_address_wmem(pinfo->pool, dst, AT_NUMERIC, (int) sizeof(guint16), &receiver);
add_conversation_table_data(hash, src, dst, 0, 0, 1, osinfo->msg_len, &pinfo->rel_ts, &pinfo->abs_ts,
@@ -2011,19 +2012,20 @@ opensafety_conversation_packet(void *pct, packet_info *pinfo,
static tap_packet_status
opensafety_hostlist_packet(void *pit, packet_info *pinfo,
- epan_dissect_t *edt _U_, const void *vip _U_, tap_flags_t flags)
+ epan_dissect_t *edt _U_, const void *vip, tap_flags_t flags)
{
address *src = (address *)wmem_alloc0(pinfo->pool, sizeof(address));
address *dst = (address *)wmem_alloc0(pinfo->pool, sizeof(address));
conv_hash_t *hash = (conv_hash_t*) pit;
- opensafety_packet_info * osinfo = (opensafety_packet_info *)vip;
- guint16 receiver = osinfo->receiver;
+ const opensafety_packet_info *osinfo = (const opensafety_packet_info *)vip;
+ guint16 receiver = GUINT16_FROM_LE(osinfo->receiver);
if (osinfo->msg_type == OPENSAFETY_SPDO_MESSAGE_TYPE)
receiver = OSS_BROADCAST_ADDRESS;
+ guint16 sender = GUINT16_FROM_LE(osinfo->sender);
hash->flags = flags;
- alloc_address_wmem(pinfo->pool, src, AT_NUMERIC, (int) sizeof(guint16), &osinfo->sender);
+ alloc_address_wmem(pinfo->pool, src, AT_NUMERIC, (int) sizeof(guint16), &sender);
alloc_address_wmem(pinfo->pool, dst, AT_NUMERIC, (int) sizeof(guint16), &receiver);
add_hostlist_table_data(hash, src, 0, TRUE, 1, osinfo->msg_len, &opensafety_dissector_info, ENDPOINT_NONE);