aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-opensafety.c
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2022-06-23 16:27:44 +0100
committerJoão Valverde <j@v6e.pt>2022-06-23 16:58:07 +0100
commitd7322e757e2665c6b9c0a9cbe3530020147f07a0 (patch)
tree093bdb0dba226a9fb52be998b6970961c7d17b67 /epan/dissectors/packet-opensafety.c
parent00790588376848c382feab3151148aa9f4a85224 (diff)
epan: Use host byte order with AT_NUMERIC
Use host byte-order with AT_NUMERIC to make it more generic and practical. Change openSAFETY to pass addresses in host byte-order (the previous code assumed they were in little-endian). Plus a few cleanups.
Diffstat (limited to 'epan/dissectors/packet-opensafety.c')
-rw-r--r--epan/dissectors/packet-opensafety.c18
1 files changed, 10 insertions, 8 deletions
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);