diff options
Diffstat (limited to '')
-rw-r--r-- | epan/dissectors/packet-epl.c | 1494 |
1 files changed, 748 insertions, 746 deletions
diff --git a/epan/dissectors/packet-epl.c b/epan/dissectors/packet-epl.c index 4dcd4195..64009a9f 100644 --- a/epan/dissectors/packet-epl.c +++ b/epan/dissectors/packet-epl.c @@ -25,7 +25,7 @@ * - Multiple SOD Read/Write dissection * - Include AInv message type * - Straighten text formatting - * - Remove unneccessary if(tree) checks + * - Remove unnecessary if(tree) checks * * Copyright (c) 2017: Karlsruhe Institute of Technology (KIT) * Institute for Anthropomatics and Robotics (IAR) @@ -69,6 +69,7 @@ #include <epan/proto_data.h> #include <epan/strutil.h> #include <epan/uat.h> +#include <epan/tfs.h> #include <wsutil/strtoi.h> #include <wsutil/file_util.h> #include <wsutil/report_message.h> @@ -125,8 +126,8 @@ static const value_string addr_str_abbr_vals[] _U_ = { {0,NULL} }; /* -static const gchar* addr_str_abbr_cn = " (CN)"; -static const gchar* addr_str_abbr_res = " (res.)"; +static const char* addr_str_abbr_cn = " (CN)"; +static const char* addr_str_abbr_res = " (res.)"; */ @@ -459,36 +460,36 @@ static value_string_ext errorcode_vals_ext = VALUE_STRING_EXT_INIT(errorcode_val /* duplication table key */ typedef struct { - guint8 src; - guint8 dest; - guint8 seq_send; - guint8 seq_recv; + uint8_t src; + uint8_t dest; + uint8_t seq_send; + uint8_t seq_recv; } duplication_key; /* duplication table value */ typedef struct { - guint32 frame; + uint32_t frame; } duplication_data; -static guint32 ct = 0; -static guint32 count = 0; +static uint32_t ct; +static uint32_t count; typedef struct _epl_sdo_reassembly { - guint32 frame[EPL_MAX_SEQUENCE][EPL_MAX_SEQUENCE]; + uint32_t frame[EPL_MAX_SEQUENCE][EPL_MAX_SEQUENCE]; } epl_sdo_reassembly; static struct _epl_segmentation{ - guint8 src; - guint8 dest; - guint8 recv; - guint8 send; + uint8_t src; + uint8_t dest; + uint8_t recv; + uint8_t send; } epl_segmentation; static epl_sdo_reassembly epl_asnd_sdo_reassembly_write; static epl_sdo_reassembly epl_asnd_sdo_reassembly_read; -static gboolean first_read = TRUE; -static gboolean first_write = TRUE; +static bool first_read = true; +static bool first_write = true; /* Priority values for EPL message type "ASnd", "", "", field PR */ #define EPL_PR_GENERICREQUEST 0x03 @@ -591,14 +592,14 @@ static bool epl_uat_fld_uint32hex_check_cb(void *, const char *, unsigned, const struct device_profile_uat_assoc { char *path; - guint device_type; - guint vendor_id; - guint product_code; + unsigned device_type; + unsigned vendor_id; + unsigned product_code; }; -static uat_t *device_profile_uat = NULL; -static struct device_profile_uat_assoc *device_profile_list_uats = NULL; -static guint ndevice_profile_uat = 0; +static uat_t *device_profile_uat; +static struct device_profile_uat_assoc *device_profile_list_uats; +static unsigned ndevice_profile_uat; static void *device_profile_uat_copy_cb(void *, const void *, size_t); static void device_profile_uat_free_cb(void *); @@ -624,19 +625,19 @@ static uat_field_t device_profile_list_uats_flds[] = { struct nodeid_profile_uat_assoc { char *path; - guint8 is_nodeid:1; + uint8_t is_nodeid:1; union { - guint8 id; + uint8_t id; address addr; } node; char *id_str; }; -static uat_t *nodeid_profile_uat = NULL; -static struct nodeid_profile_uat_assoc *nodeid_profile_list_uats = NULL; -static guint nnodeid_profile_uat = 0; +static uat_t *nodeid_profile_uat; +static struct nodeid_profile_uat_assoc *nodeid_profile_list_uats; +static unsigned nnodeid_profile_uat; static void nodeid_profile_list_uats_nodeid_set_cb(void *, const char *, unsigned, const void*, const void*); @@ -1327,22 +1328,22 @@ static const value_string epl_sdo_asnd_commands_short[] = { static value_string_ext epl_sdo_asnd_commands_short_ext = VALUE_STRING_EXT_INIT(epl_sdo_asnd_commands_short); -static const gchar* addr_str_cn = " (Controlled Node)"; -static const gchar* addr_str_res = " (reserved)"; +static const char* addr_str_cn = " (Controlled Node)"; +static const char* addr_str_res = " (reserved)"; struct object_mapping { struct { - guint16 idx; - guint8 subindex; + uint16_t idx; + uint8_t subindex; } pdo, /* The PDO to be mapped */ param; /* The ObjectMapping OD entry that mapped it */ - guint16 bit_offset; - guint16 no_of_bits; + uint16_t bit_offset; + uint16_t no_of_bits; int ett; /* info */ struct { - guint32 first, last; + uint32_t first, last; } frame; /* frames for which object_mapping applies */ const struct od_entry *info; const char *index_name; @@ -1355,32 +1356,32 @@ struct object_mapping { #define CONVO_ALWAYS_CREATE 4 struct read_req { - guint16 idx; - guint8 subindex; + uint16_t idx; + uint8_t subindex; - guint8 sendsequence; + uint8_t sendsequence; const char *index_name; const struct od_entry *info; }; struct epl_convo { - guint8 CN; + uint8_t CN; - guint16 device_type; - guint32 response_time; - guint32 vendor_id; - guint32 product_code; + uint16_t device_type; + uint32_t response_time; + uint32_t vendor_id; + uint32_t product_code; - guint generation; /* FIXME remove */ + unsigned generation; /* FIXME remove */ wmem_array_t *TPDO; /* CN->MN */ wmem_array_t *RPDO; /* MN->CN */ struct profile *profile; - guint32 last_frame; - guint8 next_read_req; - guint8 seq_send; + uint32_t last_frame; + uint8_t next_read_req; + uint8_t seq_send; struct read_req read_reqs[4]; @@ -1391,325 +1392,325 @@ struct epl_convo { }; -static gint dissect_epl_payload(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset, gint len, const struct epl_datatype *type, guint8 msgType); -static gint dissect_epl_soc(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset); -static gint dissect_epl_preq(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset); -static gint dissect_epl_pres(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset); -static gint dissect_epl_soa(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset); - -static gint dissect_epl_asnd_ires(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset); -static gint dissect_epl_asnd_sres(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset); -static gint dissect_epl_asnd_nmtcmd(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset); -static gint dissect_epl_asnd_nmtreq(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset); -static gint dissect_epl_asnd_nmtdna(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset); -static gint dissect_epl_asnd(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset); -static gint dissect_epl_ainv(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset); - -static gint dissect_epl_asnd_sdo(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset); -static gint dissect_epl_asnd_resp(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset); -static gint dissect_epl_sdo_sequence(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset, guint8 *seq); -static gint dissect_epl_sdo_command(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset, guint8 seq); -static gint dissect_epl_sdo_command_write_by_index(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset, guint8 segmented, gboolean response, guint16 segment_size); -static gint dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset, guint8 segmented, gboolean response, guint16 segment_size); -static gint dissect_epl_sdo_command_read_by_index(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset, guint8 segmented, gboolean response, guint16 segment_size); -static gint dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset, guint8 segmented, gboolean response, guint16 segment_size); -static gint dissect_object_mapping(struct profile *profile, wmem_array_t *mappings, proto_tree *epl_tree, tvbuff_t *tvb, guint32 framenum, gint offset, guint16 idx, guint8 subindex); - -static const gchar* decode_epl_address(guchar adr); +static int dissect_epl_payload(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset, int len, const struct epl_datatype *type, uint8_t msgType); +static int dissect_epl_soc(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset); +static int dissect_epl_preq(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset); +static int dissect_epl_pres(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset); +static int dissect_epl_soa(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset); + +static int dissect_epl_asnd_ires(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset); +static int dissect_epl_asnd_sres(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset); +static int dissect_epl_asnd_nmtcmd(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset); +static int dissect_epl_asnd_nmtreq(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset); +static int dissect_epl_asnd_nmtdna(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset); +static int dissect_epl_asnd(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset); +static int dissect_epl_ainv(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset); + +static int dissect_epl_asnd_sdo(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset); +static int dissect_epl_asnd_resp(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset); +static int dissect_epl_sdo_sequence(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset, uint8_t *seq); +static int dissect_epl_sdo_command(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset, uint8_t seq); +static int dissect_epl_sdo_command_write_by_index(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset, uint8_t segmented, bool response, uint16_t segment_size); +static int dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset, uint8_t segmented, bool response, uint16_t segment_size); +static int dissect_epl_sdo_command_read_by_index(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset, uint8_t segmented, bool response, uint16_t segment_size); +static int dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset, uint8_t segmented, bool response, uint16_t segment_size); +static int dissect_object_mapping(struct profile *profile, wmem_array_t *mappings, proto_tree *epl_tree, tvbuff_t *tvb, uint32_t framenum, int offset, uint16_t idx, uint8_t subindex); + +static const char* decode_epl_address(unsigned char adr); /* Initialize the protocol and registered fields */ -static gint proto_epl = -1; +static int proto_epl; -static gint hf_epl_mtyp = -1; -static gint hf_epl_node = -1; -static gint hf_epl_dest = -1; -static gint hf_epl_src = -1; -static gint hf_epl_payload_real = -1; +static int hf_epl_mtyp; +static int hf_epl_node; +static int hf_epl_dest; +static int hf_epl_src; +static int hf_epl_payload_real; /* available epl message types */ -static gint hf_epl_soc = -1; -static gint hf_epl_preq = -1; -static gint hf_epl_pres = -1; -static gint hf_epl_soa = -1; -static gint hf_epl_asnd = -1; -static gint hf_epl_amni = -1; -static gint hf_epl_ainv = -1; - -static gint hf_epl_soc_flags = -1; -static gint hf_epl_soc_mc = -1; -static gint hf_epl_soc_ps = -1; -static gint hf_epl_soc_dna_an = -1; -static gint hf_epl_soc_nettime = -1; -static gint hf_epl_soc_relativetime = -1; - -static gint hf_epl_preq_flags = -1; -static gint hf_epl_preq_ms = -1; -static gint hf_epl_preq_ea = -1; -static gint hf_epl_preq_rd = -1; -static gint hf_epl_preq_sls = -1; -static gint hf_epl_preq_fls = -1; -static gint hf_epl_preq_pdov = -1; -static gint hf_epl_preq_size = -1; - -static gint hf_epl_pres_stat_ms = -1; -static gint hf_epl_pres_stat_cs = -1; -static gint hf_epl_pres_flags = -1; -static gint hf_epl_pres_ms = -1; -static gint hf_epl_pres_en = -1; -static gint hf_epl_pres_rd = -1; -static gint hf_epl_pres_pr = -1; -static gint hf_epl_pres_rs = -1; -static gint hf_epl_pres_sls = -1; -static gint hf_epl_pres_fls = -1; -static gint hf_epl_pres_pdov = -1; -static gint hf_epl_pres_size = -1; - -static gint hf_epl_soa_stat_ms = -1; -static gint hf_epl_soa_stat_cs = -1; -static gint hf_epl_soa_ea = -1; -static gint hf_epl_soa_er = -1; -static gint hf_epl_soa_svid = -1; -static gint hf_epl_soa_svtg = -1; -static gint hf_epl_soa_eplv = -1; -static gint hf_epl_soa_rrflags = -1; -static gint hf_epl_soa_rrflags_mnred = -1; -static gint hf_epl_soa_rrflags_cblred = -1; -static gint hf_epl_soa_rrflags_ringred = -1; -static gint hf_epl_soa_rrflags_ringstat = -1; +static int hf_epl_soc; +static int hf_epl_preq; +static int hf_epl_pres; +static int hf_epl_soa; +static int hf_epl_asnd; +static int hf_epl_amni; +static int hf_epl_ainv; + +static int hf_epl_soc_flags; +static int hf_epl_soc_mc; +static int hf_epl_soc_ps; +static int hf_epl_soc_dna_an; +static int hf_epl_soc_nettime; +static int hf_epl_soc_relativetime; + +static int hf_epl_preq_flags; +static int hf_epl_preq_ms; +static int hf_epl_preq_ea; +static int hf_epl_preq_rd; +static int hf_epl_preq_sls; +static int hf_epl_preq_fls; +static int hf_epl_preq_pdov; +static int hf_epl_preq_size; + +static int hf_epl_pres_stat_ms; +static int hf_epl_pres_stat_cs; +static int hf_epl_pres_flags; +static int hf_epl_pres_ms; +static int hf_epl_pres_en; +static int hf_epl_pres_rd; +static int hf_epl_pres_pr; +static int hf_epl_pres_rs; +static int hf_epl_pres_sls; +static int hf_epl_pres_fls; +static int hf_epl_pres_pdov; +static int hf_epl_pres_size; + +static int hf_epl_soa_stat_ms; +static int hf_epl_soa_stat_cs; +static int hf_epl_soa_ea; +static int hf_epl_soa_er; +static int hf_epl_soa_svid; +static int hf_epl_soa_svtg; +static int hf_epl_soa_eplv; +static int hf_epl_soa_rrflags; +static int hf_epl_soa_rrflags_mnred; +static int hf_epl_soa_rrflags_cblred; +static int hf_epl_soa_rrflags_ringred; +static int hf_epl_soa_rrflags_ringstat; /*SyncRequest*/ -static gint hf_epl_soa_sync = -1; -static gint hf_epl_soa_mac = -1; -static gint hf_epl_soa_pre_fst = -1; -static gint hf_epl_soa_pre_sec = -1; -static gint hf_epl_soa_mnd_fst = -1; -static gint hf_epl_soa_mnd_sec = -1; -static gint hf_epl_soa_pre_tm = -1; -static gint hf_epl_soa_pre_set = -1; -static gint hf_epl_soa_pre_res = -1; -static gint hf_epl_soa_mac_end = -1; -static gint hf_epl_soa_pre_fst_end = -1; -static gint hf_epl_soa_pre_sec_end = -1; -static gint hf_epl_soa_mnd_fst_end = -1; -static gint hf_epl_soa_mnd_sec_end = -1; -static gint hf_epl_soa_pre_tm_end = -1; -static gint hf_epl_soa_dna_an_glb = -1; -static gint hf_epl_soa_dna_an_lcl = -1; +static int hf_epl_soa_sync; +static int hf_epl_soa_mac; +static int hf_epl_soa_pre_fst; +static int hf_epl_soa_pre_sec; +static int hf_epl_soa_mnd_fst; +static int hf_epl_soa_mnd_sec; +static int hf_epl_soa_pre_tm; +static int hf_epl_soa_pre_set; +static int hf_epl_soa_pre_res; +static int hf_epl_soa_mac_end; +static int hf_epl_soa_pre_fst_end; +static int hf_epl_soa_pre_sec_end; +static int hf_epl_soa_mnd_fst_end; +static int hf_epl_soa_mnd_sec_end; +static int hf_epl_soa_pre_tm_end; +static int hf_epl_soa_dna_an_glb; +static int hf_epl_soa_dna_an_lcl; /*SyncResponse*/ -static gint hf_epl_asnd_syncResponse_sync = -1; -static gint hf_epl_asnd_syncResponse_latency = -1; -static gint hf_epl_asnd_syncResponse_node = -1; -static gint hf_epl_asnd_syncResponse_delay = -1; -static gint hf_epl_asnd_syncResponse_pre_fst = -1; -static gint hf_epl_asnd_syncResponse_pre_sec = -1; -static gint hf_epl_asnd_syncResponse_fst_val = -1; -static gint hf_epl_asnd_syncResponse_sec_val = -1; -static gint hf_epl_asnd_syncResponse_mode = -1; - -static gint hf_epl_asnd_svid = -1; -static gint hf_epl_asnd_svtg = -1; -/* static gint hf_epl_asnd_data = -1; */ +static int hf_epl_asnd_syncResponse_sync; +static int hf_epl_asnd_syncResponse_latency; +static int hf_epl_asnd_syncResponse_node; +static int hf_epl_asnd_syncResponse_delay; +static int hf_epl_asnd_syncResponse_pre_fst; +static int hf_epl_asnd_syncResponse_pre_sec; +static int hf_epl_asnd_syncResponse_fst_val; +static int hf_epl_asnd_syncResponse_sec_val; +static int hf_epl_asnd_syncResponse_mode; + +static int hf_epl_asnd_svid; +static int hf_epl_asnd_svtg; +/* static int hf_epl_asnd_data; */ /*IdentResponse*/ -static gint hf_epl_asnd_identresponse_en = -1; -static gint hf_epl_asnd_identresponse_ec = -1; -static gint hf_epl_asnd_identresponse_pr = -1; -static gint hf_epl_asnd_identresponse_rs = -1; -static gint hf_epl_asnd_identresponse_sls = -1; -static gint hf_epl_asnd_identresponse_fls = -1; -static gint hf_epl_asnd_identresponse_stat_ms = -1; -static gint hf_epl_asnd_identresponse_stat_cs = -1; -static gint hf_epl_asnd_identresponse_ever = -1; -static gint hf_epl_asnd_identresponse_feat = -1; -static gint hf_epl_asnd_identresponse_feat_bit0 = -1; -static gint hf_epl_asnd_identresponse_feat_bit1 = -1; -static gint hf_epl_asnd_identresponse_feat_bit2 = -1; -static gint hf_epl_asnd_identresponse_feat_bit3 = -1; -static gint hf_epl_asnd_identresponse_feat_bit4 = -1; -static gint hf_epl_asnd_identresponse_feat_bit5 = -1; -static gint hf_epl_asnd_identresponse_feat_bit6 = -1; -static gint hf_epl_asnd_identresponse_feat_bit7 = -1; -static gint hf_epl_asnd_identresponse_feat_bit8 = -1; -static gint hf_epl_asnd_identresponse_feat_bit9 = -1; -static gint hf_epl_asnd_identresponse_feat_bitA = -1; -static gint hf_epl_asnd_identresponse_feat_bitB = -1; -static gint hf_epl_asnd_identresponse_feat_bitC = -1; -static gint hf_epl_asnd_identresponse_feat_bitD = -1; -static gint hf_epl_asnd_identresponse_feat_bitE = -1; -static gint hf_epl_asnd_identresponse_feat_bitF = -1; -static gint hf_epl_asnd_identresponse_feat_bit10 = -1; -static gint hf_epl_asnd_identresponse_feat_bit11 = -1; -static gint hf_epl_asnd_identresponse_feat_bit12 = -1; -static gint hf_epl_asnd_identresponse_feat_bit13 = -1; -static gint hf_epl_asnd_identresponse_feat_bit14 = -1; -static gint hf_epl_asnd_identresponse_feat_bit21 = -1; -static gint hf_epl_asnd_identresponse_mtu = -1; -static gint hf_epl_asnd_identresponse_pis = -1; -static gint hf_epl_asnd_identresponse_pos = -1; -static gint hf_epl_asnd_identresponse_rst = -1; -static gint hf_epl_asnd_identresponse_dt = -1; -static gint hf_epl_asnd_identresponse_dt_add = -1; -static gint hf_epl_asnd_identresponse_vid = -1; -static gint hf_epl_asnd_identresponse_productcode = -1; -static gint hf_epl_asnd_identresponse_rno = -1; -static gint hf_epl_asnd_identresponse_sno = -1; -static gint hf_epl_asnd_identresponse_vex1 = -1; -static gint hf_epl_asnd_identresponse_vcd = -1; -static gint hf_epl_asnd_identresponse_vct = -1; -static gint hf_epl_asnd_identresponse_ad = -1; -static gint hf_epl_asnd_identresponse_at = -1; -static gint hf_epl_asnd_identresponse_ipa = -1; -static gint hf_epl_asnd_identresponse_snm = -1; -static gint hf_epl_asnd_identresponse_gtw = -1; -static gint hf_epl_asnd_identresponse_hn = -1; -static gint hf_epl_asnd_identresponse_vex2 = -1; +static int hf_epl_asnd_identresponse_en; +static int hf_epl_asnd_identresponse_ec; +static int hf_epl_asnd_identresponse_pr; +static int hf_epl_asnd_identresponse_rs; +static int hf_epl_asnd_identresponse_sls; +static int hf_epl_asnd_identresponse_fls; +static int hf_epl_asnd_identresponse_stat_ms; +static int hf_epl_asnd_identresponse_stat_cs; +static int hf_epl_asnd_identresponse_ever; +static int hf_epl_asnd_identresponse_feat; +static int hf_epl_asnd_identresponse_feat_bit0; +static int hf_epl_asnd_identresponse_feat_bit1; +static int hf_epl_asnd_identresponse_feat_bit2; +static int hf_epl_asnd_identresponse_feat_bit3; +static int hf_epl_asnd_identresponse_feat_bit4; +static int hf_epl_asnd_identresponse_feat_bit5; +static int hf_epl_asnd_identresponse_feat_bit6; +static int hf_epl_asnd_identresponse_feat_bit7; +static int hf_epl_asnd_identresponse_feat_bit8; +static int hf_epl_asnd_identresponse_feat_bit9; +static int hf_epl_asnd_identresponse_feat_bitA; +static int hf_epl_asnd_identresponse_feat_bitB; +static int hf_epl_asnd_identresponse_feat_bitC; +static int hf_epl_asnd_identresponse_feat_bitD; +static int hf_epl_asnd_identresponse_feat_bitE; +static int hf_epl_asnd_identresponse_feat_bitF; +static int hf_epl_asnd_identresponse_feat_bit10; +static int hf_epl_asnd_identresponse_feat_bit11; +static int hf_epl_asnd_identresponse_feat_bit12; +static int hf_epl_asnd_identresponse_feat_bit13; +static int hf_epl_asnd_identresponse_feat_bit14; +static int hf_epl_asnd_identresponse_feat_bit21; +static int hf_epl_asnd_identresponse_mtu; +static int hf_epl_asnd_identresponse_pis; +static int hf_epl_asnd_identresponse_pos; +static int hf_epl_asnd_identresponse_rst; +static int hf_epl_asnd_identresponse_dt; +static int hf_epl_asnd_identresponse_dt_add; +static int hf_epl_asnd_identresponse_vid; +static int hf_epl_asnd_identresponse_productcode; +static int hf_epl_asnd_identresponse_rno; +static int hf_epl_asnd_identresponse_sno; +static int hf_epl_asnd_identresponse_vex1; +static int hf_epl_asnd_identresponse_vcd; +static int hf_epl_asnd_identresponse_vct; +static int hf_epl_asnd_identresponse_ad; +static int hf_epl_asnd_identresponse_at; +static int hf_epl_asnd_identresponse_ipa; +static int hf_epl_asnd_identresponse_snm; +static int hf_epl_asnd_identresponse_gtw; +static int hf_epl_asnd_identresponse_hn; +static int hf_epl_asnd_identresponse_vex2; /*StatusResponse*/ -static gint hf_epl_asnd_statusresponse_en = -1; -static gint hf_epl_asnd_statusresponse_ec = -1; -static gint hf_epl_asnd_statusresponse_pr = -1; -static gint hf_epl_asnd_statusresponse_rs = -1; -static gint hf_epl_asnd_statusresponse_sls = -1; -static gint hf_epl_asnd_statusresponse_fls = -1; -static gint hf_epl_asnd_statusresponse_stat_ms = -1; -static gint hf_epl_asnd_statusresponse_stat_cs = -1; -/* static gint hf_epl_asnd_statusresponse_seb = -1; */ +static int hf_epl_asnd_statusresponse_en; +static int hf_epl_asnd_statusresponse_ec; +static int hf_epl_asnd_statusresponse_pr; +static int hf_epl_asnd_statusresponse_rs; +static int hf_epl_asnd_statusresponse_sls; +static int hf_epl_asnd_statusresponse_fls; +static int hf_epl_asnd_statusresponse_stat_ms; +static int hf_epl_asnd_statusresponse_stat_cs; +/* static int hf_epl_asnd_statusresponse_seb; */ /*StaticErrorBitField */ -static gint hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit0 = -1; -static gint hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit1 = -1; -static gint hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit2 = -1; -static gint hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit3 = -1; -static gint hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit4 = -1; -static gint hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit5 = -1; -static gint hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit7 = -1; -static gint hf_epl_asnd_statusresponse_seb_devicespecific_err = -1; +static int hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit0; +static int hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit1; +static int hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit2; +static int hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit3; +static int hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit4; +static int hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit5; +static int hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit7; +static int hf_epl_asnd_statusresponse_seb_devicespecific_err; /*List of Errors/Events*/ -/* static gint hf_epl_asnd_statusresponse_el = -1; */ -/* static gint hf_epl_asnd_statusresponse_el_entry = -1; */ -static gint hf_epl_asnd_statusresponse_el_entry_type = -1; -static gint hf_epl_asnd_statusresponse_el_entry_type_profile = -1; -static gint hf_epl_asnd_statusresponse_el_entry_type_mode = -1; -static gint hf_epl_asnd_statusresponse_el_entry_type_bit14 = -1; -static gint hf_epl_asnd_statusresponse_el_entry_type_bit15 = -1; -static gint hf_epl_asnd_statusresponse_el_entry_code = -1; -static gint hf_epl_asnd_statusresponse_el_entry_time = -1; -static gint hf_epl_asnd_statusresponse_el_entry_add = -1; +/* static int hf_epl_asnd_statusresponse_el; */ +/* static int hf_epl_asnd_statusresponse_el_entry; */ +static int hf_epl_asnd_statusresponse_el_entry_type; +static int hf_epl_asnd_statusresponse_el_entry_type_profile; +static int hf_epl_asnd_statusresponse_el_entry_type_mode; +static int hf_epl_asnd_statusresponse_el_entry_type_bit14; +static int hf_epl_asnd_statusresponse_el_entry_type_bit15; +static int hf_epl_asnd_statusresponse_el_entry_code; +static int hf_epl_asnd_statusresponse_el_entry_time; +static int hf_epl_asnd_statusresponse_el_entry_add; /*NMTRequest*/ -static gint hf_epl_asnd_nmtrequest_rcid = -1; -static gint hf_epl_asnd_nmtrequest_rct = -1; -static gint hf_epl_asnd_nmtrequest_rcd = -1; +static int hf_epl_asnd_nmtrequest_rcid; +static int hf_epl_asnd_nmtrequest_rct; +static int hf_epl_asnd_nmtrequest_rcd; /*NMTCommand*/ -static gint hf_epl_asnd_nmtcommand_cid = -1; -static gint hf_epl_asnd_nmtcommand_cdat = -1; -static gint hf_epl_asnd_nmtcommand_resetnode_reason = -1; -/*static gint hf_epl_asnd_nmtcommand_nmtnetparameterset_mtu = -1;*/ -static gint hf_epl_asnd_nmtcommand_nmtnethostnameset_hn = -1; -static gint hf_epl_asnd_nmtcommand_nmtflusharpentry_nid = -1; -static gint hf_epl_asnd_nmtcommand_nmtpublishtime_dt = -1; -static gint hf_epl_asnd_nmtcommand_nmtdna = -1; -static gint hf_epl_asnd_nmtcommand_nmtdna_flags = -1; -static gint hf_epl_asnd_nmtcommand_nmtdna_ltv = -1; -static gint hf_epl_asnd_nmtcommand_nmtdna_hpm = -1; -static gint hf_epl_asnd_nmtcommand_nmtdna_nnn = -1; -static gint hf_epl_asnd_nmtcommand_nmtdna_mac = -1; -static gint hf_epl_asnd_nmtcommand_nmtdna_cnn = -1; -static gint hf_epl_asnd_nmtcommand_nmtdna_currmac = -1; -static gint hf_epl_asnd_nmtcommand_nmtdna_hubenmsk = -1; -static gint hf_epl_asnd_nmtcommand_nmtdna_currnn = -1; -static gint hf_epl_asnd_nmtcommand_nmtdna_newnn = -1; -static gint hf_epl_asnd_nmtcommand_nmtdna_leasetime = -1; - - -/*Asynchronuous SDO Sequence Layer*/ -static gint hf_epl_asnd_sdo_seq = -1; -static gint hf_epl_asnd_sdo_seq_receive_sequence_number = -1; -static gint hf_epl_asnd_sdo_seq_receive_con = -1; -static gint hf_epl_asnd_sdo_seq_send_sequence_number = -1; -static gint hf_epl_asnd_sdo_seq_send_con = -1; - -/*Asynchronuous SDO Command Layer*/ -static gint hf_epl_asnd_sdo_cmd = -1; -static gint hf_epl_asnd_sdo_cmd_transaction_id = -1; -static gint hf_epl_asnd_sdo_cmd_response = -1; +static int hf_epl_asnd_nmtcommand_cid; +static int hf_epl_asnd_nmtcommand_cdat; +static int hf_epl_asnd_nmtcommand_resetnode_reason; +/*static int hf_epl_asnd_nmtcommand_nmtnetparameterset_mtu;*/ +static int hf_epl_asnd_nmtcommand_nmtnethostnameset_hn; +static int hf_epl_asnd_nmtcommand_nmtflusharpentry_nid; +static int hf_epl_asnd_nmtcommand_nmtpublishtime_dt; +static int hf_epl_asnd_nmtcommand_nmtdna; +static int hf_epl_asnd_nmtcommand_nmtdna_flags; +static int hf_epl_asnd_nmtcommand_nmtdna_ltv; +static int hf_epl_asnd_nmtcommand_nmtdna_hpm; +static int hf_epl_asnd_nmtcommand_nmtdna_nnn; +static int hf_epl_asnd_nmtcommand_nmtdna_mac; +static int hf_epl_asnd_nmtcommand_nmtdna_cnn; +static int hf_epl_asnd_nmtcommand_nmtdna_currmac; +static int hf_epl_asnd_nmtcommand_nmtdna_hubenmsk; +static int hf_epl_asnd_nmtcommand_nmtdna_currnn; +static int hf_epl_asnd_nmtcommand_nmtdna_newnn; +static int hf_epl_asnd_nmtcommand_nmtdna_leasetime; + + +/*Asynchronous SDO Sequence Layer*/ +static int hf_epl_asnd_sdo_seq; +static int hf_epl_asnd_sdo_seq_receive_sequence_number; +static int hf_epl_asnd_sdo_seq_receive_con; +static int hf_epl_asnd_sdo_seq_send_sequence_number; +static int hf_epl_asnd_sdo_seq_send_con; + +/*Asynchronous SDO Command Layer*/ +static int hf_epl_asnd_sdo_cmd; +static int hf_epl_asnd_sdo_cmd_transaction_id; +static int hf_epl_asnd_sdo_cmd_response; #if 0 -static gint hf_epl_asnd_sdo_resp_in = -1; -static gint hf_epl_asnd_sdo_no_resp = -1; -static gint hf_epl_asnd_sdo_resp_to = -1; +static int hf_epl_asnd_sdo_resp_in; +static int hf_epl_asnd_sdo_no_resp; +static int hf_epl_asnd_sdo_resp_to; #endif -static gint hf_epl_asnd_sdo_cmd_abort = -1; -static gint hf_epl_asnd_sdo_cmd_sub_abort = -1; -static gint hf_epl_asnd_sdo_cmd_segmentation = -1; -static gint hf_epl_asnd_sdo_cmd_command_id = -1; -static gint hf_epl_asnd_sdo_cmd_segment_size = -1; - -static gint hf_epl_asnd_sdo_cmd_data_size = -1; -static gint hf_epl_asnd_sdo_cmd_data_padding = -1; -static gint hf_epl_asnd_sdo_cmd_data_index = -1; -static gint hf_epl_asnd_sdo_cmd_data_subindex = -1; -static gint hf_epl_asnd_sdo_cmd_data_mapping = -1; -static gint hf_epl_asnd_sdo_cmd_data_mapping_index = -1; -static gint hf_epl_asnd_sdo_cmd_data_mapping_subindex = -1; -static gint hf_epl_asnd_sdo_cmd_data_mapping_offset = -1; -static gint hf_epl_asnd_sdo_cmd_data_mapping_length = -1; -/*static gint hf_epl_asnd_sdo_cmd_data_response = -1;*/ - -static gint hf_epl_asnd_sdo_cmd_reassembled = -1; -static gint hf_epl_fragments = -1; -static gint hf_epl_fragment = -1; -static gint hf_epl_fragment_overlap = -1; -static gint hf_epl_fragment_overlap_conflicts = -1; -static gint hf_epl_fragment_multiple_tails = -1; -static gint hf_epl_fragment_too_long_fragment = -1; -static gint hf_epl_fragment_error = -1; -static gint hf_epl_fragment_count = -1; -static gint hf_epl_reassembled_in = -1; -static gint hf_epl_reassembled_length = -1; -static gint hf_epl_reassembled_data = -1; -static gint hf_epl_sdo_multi_param_sub_abort = -1; - -static gint hf_epl_asnd_identresponse_profile_path = -1; +static int hf_epl_asnd_sdo_cmd_abort; +static int hf_epl_asnd_sdo_cmd_sub_abort; +static int hf_epl_asnd_sdo_cmd_segmentation; +static int hf_epl_asnd_sdo_cmd_command_id; +static int hf_epl_asnd_sdo_cmd_segment_size; + +static int hf_epl_asnd_sdo_cmd_data_size; +static int hf_epl_asnd_sdo_cmd_data_padding; +static int hf_epl_asnd_sdo_cmd_data_index; +static int hf_epl_asnd_sdo_cmd_data_subindex; +static int hf_epl_asnd_sdo_cmd_data_mapping; +static int hf_epl_asnd_sdo_cmd_data_mapping_index; +static int hf_epl_asnd_sdo_cmd_data_mapping_subindex; +static int hf_epl_asnd_sdo_cmd_data_mapping_offset; +static int hf_epl_asnd_sdo_cmd_data_mapping_length; +/*static int hf_epl_asnd_sdo_cmd_data_response;*/ + +static int hf_epl_asnd_sdo_cmd_reassembled; +static int hf_epl_fragments; +static int hf_epl_fragment; +static int hf_epl_fragment_overlap; +static int hf_epl_fragment_overlap_conflicts; +static int hf_epl_fragment_multiple_tails; +static int hf_epl_fragment_too_long_fragment; +static int hf_epl_fragment_error; +static int hf_epl_fragment_count; +static int hf_epl_reassembled_in; +static int hf_epl_reassembled_length; +static int hf_epl_reassembled_data; +static int hf_epl_sdo_multi_param_sub_abort; + +static int hf_epl_asnd_identresponse_profile_path; /* EPL OD Data Types */ -static gint hf_epl_pdo = -1; -static gint hf_epl_pdo_index = -1; -static gint hf_epl_pdo_subindex = -1; - -static gint hf_epl_od_meta = -1; -static gint hf_epl_od_meta_mapping_index = -1; -static gint hf_epl_od_meta_mapping_subindex = -1; -static gint hf_epl_od_meta_lifetime_start = -1; -static gint hf_epl_od_meta_lifetime_end = -1; -static gint hf_epl_od_meta_offset = -1; -static gint hf_epl_od_meta_length = -1; - -static gint hf_epl_od_boolean = -1; -static gint hf_epl_od_int = -1; -static gint hf_epl_od_uint = -1; -static gint hf_epl_od_real = -1; -static gint hf_epl_od_string = -1; -static gint hf_epl_od_octet_string = -1; -static gint hf_epl_od_time = -1; +static int hf_epl_pdo; +static int hf_epl_pdo_index; +static int hf_epl_pdo_subindex; + +static int hf_epl_od_meta; +static int hf_epl_od_meta_mapping_index; +static int hf_epl_od_meta_mapping_subindex; +static int hf_epl_od_meta_lifetime_start; +static int hf_epl_od_meta_lifetime_end; +static int hf_epl_od_meta_offset; +static int hf_epl_od_meta_length; + +static int hf_epl_od_boolean; +static int hf_epl_od_int; +static int hf_epl_od_uint; +static int hf_epl_od_real; +static int hf_epl_od_string; +static int hf_epl_od_octet_string; +static int hf_epl_od_time; #if 0 -static gint hf_epl_od_time_difference = -1; -static gint hf_epl_od_domain = -1; +static int hf_epl_od_time_difference; +static int hf_epl_od_domain; #endif -static gint hf_epl_od_mac = -1; -static gint hf_epl_od_ipv4 = -1; +static int hf_epl_od_mac; +static int hf_epl_od_ipv4; #define EPL_PDO_TYPE_COUNT 8 static const struct epl_datatype { const char *name; - gint *hf; - guint encoding; - guint8 len; + int *hf; + unsigned encoding; + uint8_t len; } epl_datatype[] = { { "Boolean", &hf_epl_od_boolean, ENC_LITTLE_ENDIAN , 1 }, /* integer types */ @@ -1752,8 +1753,8 @@ static const struct epl_datatype { }; -static gint ett_epl_fragment = -1; -static gint ett_epl_fragments = -1; +static int ett_epl_fragment; +static int ett_epl_fragments; static const fragment_items epl_frag_items = { /* Fragment subtrees */ @@ -1778,59 +1779,59 @@ static const fragment_items epl_frag_items = { "Message fragments" }; -static gint hf_epl_asnd_sdo_cmd_abort_code = -1; +static int hf_epl_asnd_sdo_cmd_abort_code; #if 0 -static gint hf_epl_asnd_sdo_cmd_abort_flag = -1; -static gint hf_epl_asnd_sdo_cmd_segmentation_flag = -1; -static gint hf_epl_asnd_sdo_cmd_cmd_valid_test = -1; +static int hf_epl_asnd_sdo_cmd_abort_flag; +static int hf_epl_asnd_sdo_cmd_segmentation_flag; +static int hf_epl_asnd_sdo_cmd_cmd_valid_test; -static gint hf_epl_asnd_sdo_actual_command_id = -1; +static int hf_epl_asnd_sdo_actual_command_id; -static gint hf_epl_asnd_sdo_actual_segment_size = -1; -static gint hf_epl_asnd_sdo_actual_payload_size_read = -1; +static int hf_epl_asnd_sdo_actual_segment_size; +static int hf_epl_asnd_sdo_actual_payload_size_read; #endif /* Initialize the subtree pointers */ -static gint ett_epl = -1; -static gint ett_epl_soc = -1; -static gint ett_epl_preq = -1; -static gint ett_epl_pres = -1; -static gint ett_epl_feat = -1; -static gint ett_epl_seb = -1; -static gint ett_epl_el = -1; -static gint ett_epl_el_entry = -1; -static gint ett_epl_el_entry_type = -1; -static gint ett_epl_sdo_entry_type = -1; -static gint ett_epl_asnd_nmt_dna = -1; - -static gint ett_epl_sdo = -1; -static gint ett_epl_sdo_sequence_layer = -1; -static gint ett_epl_sdo_command_layer = -1; -static gint ett_epl_sdo_data = -1; -static gint ett_epl_asnd_sdo_cmd_data_mapping = -1; -static gint ett_epl_soa_sync = -1; -static gint ett_epl_asnd_sync = -1; - -static gint ett_epl_pdo_meta = -1; - -static expert_field ei_duplicated_frame = EI_INIT; -static expert_field ei_recvseq_value = EI_INIT; -static expert_field ei_sendseq_value = EI_INIT; -static expert_field ei_real_length_differs = EI_INIT; +static int ett_epl; +static int ett_epl_soc; +static int ett_epl_preq; +static int ett_epl_pres; +static int ett_epl_feat; +static int ett_epl_seb; +static int ett_epl_el; +static int ett_epl_el_entry; +static int ett_epl_el_entry_type; +static int ett_epl_sdo_entry_type; +static int ett_epl_asnd_nmt_dna; + +static int ett_epl_sdo; +static int ett_epl_sdo_sequence_layer; +static int ett_epl_sdo_command_layer; +static int ett_epl_sdo_data; +static int ett_epl_asnd_sdo_cmd_data_mapping; +static int ett_epl_soa_sync; +static int ett_epl_asnd_sync; + +static int ett_epl_pdo_meta; + +static expert_field ei_duplicated_frame; +static expert_field ei_recvseq_value; +static expert_field ei_sendseq_value; +static expert_field ei_real_length_differs; static dissector_handle_t epl_handle; static dissector_handle_t epl_udp_handle; -static gboolean show_cmd_layer_for_duplicated = FALSE; -static gboolean show_pdo_meta_info = FALSE; -static gboolean use_xdc_mappings = TRUE; -static gboolean interpret_untyped_as_le = TRUE; -static gboolean use_sdo_mappings = TRUE; +static bool show_cmd_layer_for_duplicated; +static bool show_pdo_meta_info; +static bool use_xdc_mappings = true; +static bool interpret_untyped_as_le = true; +static bool use_sdo_mappings = true; -static gint ett_epl_asnd_sdo_data_reassembled = -1; +static int ett_epl_asnd_sdo_data_reassembled; static reassembly_table epl_reassembly_table; -static GHashTable *epl_duplication_table = NULL; +static GHashTable *epl_duplication_table; const struct epl_datatype *epl_type_to_hf(const char *name) @@ -1844,13 +1845,13 @@ epl_datatype *epl_type_to_hf(const char *name) return NULL; } -static guint -epl_address_hash(gconstpointer a) +static unsigned +epl_address_hash(const void *a) { return add_address_to_hash(0, (const address*)a); } static gboolean -epl_address_equal(gconstpointer a, gconstpointer b) +epl_address_equal(const void *a, const void *b) { return addresses_equal((const address*)a, (const address*)b); } @@ -1858,16 +1859,16 @@ epl_address_equal(gconstpointer a, gconstpointer b) /* FIXME * PDO Mappings store object/subobjct pointers and thus need to be * updated after a profile change. We purge them by resetting the - * memory pool. As PDO Mappings are refereneced via Conversations, + * memory pool. As PDO Mappings are referenced via Conversations, * we need to fix up those too. I didn't figure out how to clear * conversations yet, so till now, we keep a variable to tell us * if we have dangling pointers. Courtesy of Peter Wu. */ -guint current_convo_generation = 0; /* FIXME remove */ +unsigned current_convo_generation; /* FIXME remove */ static wmem_allocator_t *pdo_mapping_scope; static struct object_mapping * -get_object_mappings(wmem_array_t *arr, guint *len) +get_object_mappings(wmem_array_t *arr, unsigned *len) { *len = wmem_array_get_count(arr); return (struct object_mapping*)wmem_array_get_raw(arr); @@ -1882,7 +1883,7 @@ object_mapping_cmp(const void *_a, const void *_b) if (a->bit_offset > b->bit_offset) return +1; return 0; } -static gboolean +static bool object_mapping_eq(struct object_mapping *a, struct object_mapping *b) { return a->pdo.idx == b->pdo.idx @@ -1891,12 +1892,12 @@ object_mapping_eq(struct object_mapping *a, struct object_mapping *b) && a->param.idx == b->param.idx && a->param.subindex == b->param.subindex; } -static guint +static unsigned add_object_mapping(wmem_array_t *arr, struct object_mapping *mapping) { /* let's check if this overwrites an existing mapping */ - guint i, len; - /* A bit ineffecient (looping backwards would be better), but it's acyclic anyway */ + unsigned i, len; + /* A bit inefficient (looping backwards would be better), but it's acyclic anyway */ struct object_mapping *old = get_object_mappings(arr, &len); for (i = 0; i < len; i++) { @@ -1919,7 +1920,7 @@ add_object_mapping(wmem_array_t *arr, struct object_mapping *mapping) static wmem_map_t *epl_profiles_by_device, *epl_profiles_by_nodeid, *epl_profiles_by_address; static struct profile *epl_default_profile; -static const char *epl_default_profile_path = NULL, *epl_default_profile_path_last = NULL; +static const char *epl_default_profile_path = NULL, *epl_default_profile_path_last; static bool profile_del_cb(wmem_allocator_t *pool _U_, wmem_cb_event_t event _U_, void *_profile) @@ -1928,7 +1929,7 @@ profile_del_cb(wmem_allocator_t *pool _U_, wmem_cb_event_t event _U_, void *_pro if (profile->parent_map) wmem_map_remove(profile->parent_map, profile->data); wmem_destroy_allocator(profile->scope); - return FALSE; + return false; } static void @@ -1962,11 +1963,11 @@ profile_new(wmem_allocator_t *parent_pool) return profile; } -static struct object *object_lookup(struct profile *profile, guint16 idx); -static const struct subobject *subobject_lookup(struct object *obj, guint8 subindex); +static struct object *object_lookup(struct profile *profile, uint16_t idx); +static const struct subobject *subobject_lookup(struct object *obj, uint8_t subindex); struct object * -epl_profile_object_add(struct profile *profile, guint16 idx) +epl_profile_object_add(struct profile *profile, uint16_t idx) { struct object *object = wmem_new0(profile->scope, struct object); @@ -1977,45 +1978,45 @@ epl_profile_object_add(struct profile *profile, guint16 idx) } struct object * -epl_profile_object_lookup_or_add(struct profile *profile, guint16 idx) +epl_profile_object_lookup_or_add(struct profile *profile, uint16_t idx) { struct object *obj = object_lookup(profile, idx); return obj ? obj : epl_profile_object_add(profile, idx); } -gboolean - epl_profile_object_mapping_add(struct profile *profile, guint16 idx, guint8 subindex, guint64 mapping) +bool + epl_profile_object_mapping_add(struct profile *profile, uint16_t idx, uint8_t subindex, uint64_t mapping) { wmem_array_t *mappings; tvbuff_t *tvb; - guint64 mapping_le; + uint64_t mapping_le; if (!use_xdc_mappings) - return FALSE; + return false; if(idx == EPL_SOD_PDO_RX_MAPP && subindex >= 0x01 && subindex <= 0xfe) mappings = profile->RPDO; else if (idx == EPL_SOD_PDO_TX_MAPP && subindex >= 0x01 && subindex <= 0xfe) mappings = profile->TPDO; else - return FALSE; + return false; mapping_le = GUINT64_TO_LE(mapping); - tvb = tvb_new_real_data((guint8*)&mapping_le, sizeof mapping_le, sizeof mapping_le); + tvb = tvb_new_real_data((uint8_t*)&mapping_le, sizeof mapping_le, sizeof mapping_le); return dissect_object_mapping(profile, mappings, NULL, tvb, 0, 0, idx, subindex) == EPL_OBJECT_MAPPING_SIZE; } -gboolean +bool epl_profile_object_mappings_update(struct profile *profile) { - gboolean updated_any = FALSE; + bool updated_any = false; struct object_mapping *mappings; wmem_array_t *PDOs[3], **PDO; if (!use_xdc_mappings) - return FALSE; + return false; PDOs[0] = profile->RPDO; @@ -2024,7 +2025,7 @@ epl_profile_object_mappings_update(struct profile *profile) for (PDO = PDOs; *PDO; PDO++) { - guint i, len; + unsigned i, len; len = wmem_array_get_count(*PDO); mappings = (struct object_mapping*)wmem_array_get_raw(*PDO); @@ -2038,7 +2039,7 @@ epl_profile_object_mappings_update(struct profile *profile) continue; map->info = &mapping_obj->info; map->index_name = map->info->name; - updated_any = TRUE; + updated_any = true; if (!(mapping_subobj = subobject_lookup(mapping_obj, map->pdo.subindex))) continue; map->info = &mapping_subobj->info; @@ -2049,10 +2050,10 @@ epl_profile_object_mappings_update(struct profile *profile) } static struct read_req * -convo_read_req_get(struct epl_convo *convo, packet_info *pinfo, guint8 SendSequenceNumber) +convo_read_req_get(struct epl_convo *convo, packet_info *pinfo, uint8_t SendSequenceNumber) { - guint i; - guint32 seq_p_key = (ETHERTYPE_EPL_V2 << 16) | convo->seq_send; + unsigned i; + uint32_t seq_p_key = (ETHERTYPE_EPL_V2 << 16) | convo->seq_send; struct read_req *req = (struct read_req*)p_get_proto_data(wmem_file_scope(), pinfo, proto_epl, seq_p_key); if (req) @@ -2072,7 +2073,7 @@ convo_read_req_get(struct epl_convo *convo, packet_info *pinfo, guint8 SendSeque return NULL; } static struct read_req * -convo_read_req_set(struct epl_convo *convo, guint8 SendSequenceNumber) +convo_read_req_set(struct epl_convo *convo, uint8_t SendSequenceNumber) { struct read_req *slot = &convo->read_reqs[convo->next_read_req++]; convo->next_read_req %= array_length(convo->read_reqs); @@ -2082,15 +2083,15 @@ convo_read_req_set(struct epl_convo *convo, guint8 SendSequenceNumber) static int -dissect_epl_pdo(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, guint offset, guint len, guint8 msgType) +dissect_epl_pdo(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, unsigned offset, unsigned len, uint8_t msgType) { wmem_array_t *mapping = msgType == EPL_PRES ? convo->TPDO : convo->RPDO; tvbuff_t *payload_tvb; - guint rem_len, payload_len, payload_len_bits; + unsigned rem_len, payload_len, payload_len_bits; heur_dtbl_entry_t *hdtbl_entry = NULL; proto_item *item; - guint i, maps_count; - guint off = 0; + unsigned i, maps_count; + unsigned off = 0; struct object_mapping *mappings = get_object_mappings(mapping, &maps_count); @@ -2116,7 +2117,7 @@ dissect_epl_pdo(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, pa { proto_tree *pdo_tree; struct object_mapping *map = &mappings[i]; - guint willbe_offset_bits = map->bit_offset + map->no_of_bits; + unsigned willbe_offset_bits = map->bit_offset + map->no_of_bits; if (!(map->frame.first < pinfo->num && pinfo->num < map->frame.last)) continue; @@ -2148,7 +2149,7 @@ dissect_epl_pdo(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, pa proto_tree_add_uint(meta_tree, hf_epl_od_meta_mapping_subindex, tvb, 0, 0, map->param.subindex); proto_tree_add_uint(meta_tree, hf_epl_od_meta_lifetime_start, tvb, 0, 0, map->frame.first); - if (map->frame.last != G_MAXUINT32) + if (map->frame.last != UINT32_MAX) proto_tree_add_uint(meta_tree, hf_epl_od_meta_lifetime_end, tvb, 0, 0, map->frame.last); item = proto_tree_add_uint(meta_tree, hf_epl_od_meta_offset, tvb, 0, 0, map->bit_offset); @@ -2179,7 +2180,7 @@ dissect_epl_pdo(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, pa return offset + payload_len; } -static guint8 epl_placeholder_mac_addr[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; +static uint8_t epl_placeholder_mac_addr[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; static address epl_placeholder_mac = ADDRESS_INIT(AT_ETHER, 6, epl_placeholder_mac_addr); static struct epl_convo * @@ -2187,7 +2188,7 @@ epl_get_convo(packet_info *pinfo, int opts) { struct epl_convo *convo; conversation_t * epan_convo; - guint32 node_port; + uint32_t node_port; address *node_addr = &epl_placeholder_mac; address *node_dl_addr = &epl_placeholder_mac; @@ -2247,7 +2248,7 @@ new_convo_creation: if (convo == NULL) { convo = wmem_new0(wmem_file_scope(), struct epl_convo); - convo->CN = (guint8)node_port; + convo->CN = (uint8_t)node_port; convo->generation = current_convo_generation; /* FIXME remove */ convo->TPDO = wmem_array_new(pdo_mapping_scope, sizeof (struct object_mapping)); @@ -2275,7 +2276,7 @@ new_convo_creation: return convo; } -static gboolean +static bool epl_update_convo_cn_profile(struct epl_convo *convo) { struct profile *candidate; /* Best matching profile */ @@ -2309,13 +2310,13 @@ epl_update_convo_cn_profile(struct epl_convo *convo) wmem_array_get_count(candidate->TPDO) ); } - return TRUE; + return true; } - return FALSE; + return false; } static struct object * -object_lookup(struct profile *profile, guint16 idx) +object_lookup(struct profile *profile, uint16_t idx) { if (profile == NULL) return NULL; @@ -2324,18 +2325,18 @@ object_lookup(struct profile *profile, guint16 idx) } static const struct subobject * -subobject_lookup(struct object *obj, guint8 subindex) +subobject_lookup(struct object *obj, uint8_t subindex) { if (!obj || !obj->subindices) return NULL; return (const struct subobject*)epl_wmem_iarray_find(obj->subindices, subindex); } /* epl duplication table hash function */ -static guint -epl_duplication_hash(gconstpointer k) +static unsigned +epl_duplication_hash(const void *k) { const duplication_key *key = (const duplication_key*)k; - guint hash; + unsigned hash; hash = ((key->src)<<24) | ((key->dest)<<16)| ((key->seq_recv)<<8)|(key->seq_send); @@ -2344,12 +2345,12 @@ epl_duplication_hash(gconstpointer k) } /* epl duplication table equal function */ -static gint -epl_duplication_equal(gconstpointer k1, gconstpointer k2) +static int +epl_duplication_equal(const void *k1, const void *k2) { const duplication_key *key1 = (const duplication_key*)k1; const duplication_key *key2 = (const duplication_key*)k2; - gint hash; + int hash; hash = (key1->src == key2->src)&&(key1->dest == key2->dest)&& (key1->seq_recv == key2->seq_recv)&&(key1->seq_send == key2->seq_send); @@ -2359,7 +2360,7 @@ epl_duplication_equal(gconstpointer k1, gconstpointer k2) /* free the permanent key */ static void -free_key(gpointer ptr) +free_key(void *ptr) { duplication_key *key = (duplication_key *)ptr; g_slice_free(duplication_key, key); @@ -2367,10 +2368,10 @@ free_key(gpointer ptr) /* removes the table entries of a specific transfer */ static void -epl_duplication_remove(GHashTable* table, guint8 src, guint8 dest) +epl_duplication_remove(GHashTable* table, uint8_t src, uint8_t dest) { GHashTableIter iter; - gpointer pkey; + void *pkey; duplication_key *key; g_hash_table_iter_init(&iter, table); @@ -2389,11 +2390,11 @@ epl_duplication_remove(GHashTable* table, guint8 src, guint8 dest) /* insert function */ static void -epl_duplication_insert(GHashTable* table, gpointer ptr, guint32 frame) +epl_duplication_insert(GHashTable* table, void *ptr, uint32_t frame) { duplication_data *data = NULL; duplication_key *key = NULL; - gpointer pdata; + void *pdata; /* check if the values are stored */ if(g_hash_table_lookup_extended(table, ptr, NULL, &pdata)) @@ -2408,13 +2409,13 @@ epl_duplication_insert(GHashTable* table, gpointer ptr, guint32 frame) /* create memory */ data = wmem_new0(wmem_file_scope(), duplication_data); data->frame = frame; - g_hash_table_insert(table,(gpointer)key, data); + g_hash_table_insert(table,(void *)key, data); } } /* create a key*/ -static gpointer -epl_duplication_key(guint8 src, guint8 dest, guint8 seq_recv, guint8 seq_send) +static void * +epl_duplication_key(uint8_t src, uint8_t dest, uint8_t seq_recv, uint8_t seq_send) { duplication_key *key = g_slice_new(duplication_key); @@ -2423,15 +2424,15 @@ epl_duplication_key(guint8 src, guint8 dest, guint8 seq_recv, guint8 seq_send) key->seq_recv = seq_recv; key->seq_send = seq_send; - return (gpointer)key; + return (void *)key; } /* get the saved data */ -static guint32 -epl_duplication_get(GHashTable* table, gpointer ptr) +static uint32_t +epl_duplication_get(GHashTable* table, void *ptr) { duplication_data *data = NULL; - gpointer pdata; + void *pdata; if(g_hash_table_lookup_extended(table, ptr, NULL, &pdata)) { @@ -2468,24 +2469,24 @@ cleanup_dissector(void) g_hash_table_destroy(epl_duplication_table); count = 0; ct = 0; - first_read = TRUE; - first_write = TRUE; + first_read = true; + first_write = true; } /* preference whether or not display the SoC flags in info column */ -gboolean show_soc_flags = FALSE; +bool show_soc_flags; /* Define the tap for epl */ -/*static gint epl_tap = -1;*/ +/*static int epl_tap = -1;*/ -static guint16 +static uint16_t epl_get_sequence_nr(packet_info *pinfo) { - guint16 seqnum = 0x00; - gpointer data = NULL; + uint16_t seqnum = 0x00; + void *data = NULL; if ( ( data = p_get_proto_data ( wmem_file_scope(), pinfo, proto_epl, ETHERTYPE_EPL_V2 ) ) == NULL ) - p_add_proto_data ( wmem_file_scope(), pinfo, proto_epl, ETHERTYPE_EPL_V2, GUINT_TO_POINTER((guint)seqnum) ); + p_add_proto_data ( wmem_file_scope(), pinfo, proto_epl, ETHERTYPE_EPL_V2, GUINT_TO_POINTER((unsigned)seqnum) ); else seqnum = GPOINTER_TO_UINT(data); @@ -2493,30 +2494,30 @@ epl_get_sequence_nr(packet_info *pinfo) } static void -epl_set_sequence_nr(packet_info *pinfo, guint16 seqnum) +epl_set_sequence_nr(packet_info *pinfo, uint16_t seqnum) { if ( p_get_proto_data ( wmem_file_scope(), pinfo, proto_epl, ETHERTYPE_EPL_V2 ) != NULL ) p_remove_proto_data( wmem_file_scope(), pinfo, proto_epl, ETHERTYPE_EPL_V2 ); - p_add_proto_data ( wmem_file_scope(), pinfo, proto_epl, ETHERTYPE_EPL_V2, GUINT_TO_POINTER((guint)seqnum) ); + p_add_proto_data ( wmem_file_scope(), pinfo, proto_epl, ETHERTYPE_EPL_V2, GUINT_TO_POINTER((unsigned)seqnum) ); } static void -elp_version( gchar *result, guint32 version ) +elp_version( char *result, uint32_t version ) { snprintf( result, ITEM_LABEL_LENGTH, "%d.%d", hi_nibble(version), lo_nibble(version)); } /* Code to actually dissect the packets */ static int -dissect_eplpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean udpencap) +dissect_eplpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, bool udpencap) { - guint8 epl_mtyp; - const gchar *src_str, *dest_str; + uint8_t epl_mtyp; + const char *src_str, *dest_str; /* static epl_info_t mi; */ /* Set up structures needed to add the protocol subtree and manage it */ proto_item *ti; proto_tree *epl_tree = NULL, *epl_src_item, *epl_dest_item; - gint offset = 0, size = 0; + int offset = 0, size = 0; heur_dtbl_entry_t *hdtbl_entry; struct epl_convo *convo; proto_item *msg_typ_hidden = NULL; @@ -2528,7 +2529,7 @@ dissect_eplpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean udp } /* Get message type */ - epl_mtyp = tvb_get_guint8(tvb, EPL_MTYP_OFFSET) & 0x7F; + epl_mtyp = tvb_get_uint8(tvb, EPL_MTYP_OFFSET) & 0x7F; /* * In case the packet is a protocol encoded in the basic EPL transport stream, @@ -2565,14 +2566,14 @@ dissect_eplpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean udp * so we need to check we can actually index into the buffer */ if (pinfo->net_dst.type == AT_IPv4) - pinfo->destport = ((const guint8*)pinfo->net_dst.data)[3]; + pinfo->destport = ((const uint8_t*)pinfo->net_dst.data)[3]; if (pinfo->net_src.type == AT_IPv4) - pinfo->srcport = ((const guint8*)pinfo->net_src.data)[3]; + pinfo->srcport = ((const uint8_t*)pinfo->net_src.data)[3]; } else { - pinfo->destport = tvb_get_guint8(tvb, EPL_DEST_OFFSET); - pinfo->srcport = tvb_get_guint8(tvb, EPL_SRC_OFFSET); + pinfo->destport = tvb_get_uint8(tvb, EPL_DEST_OFFSET); + pinfo->srcport = tvb_get_uint8(tvb, EPL_SRC_OFFSET); } epl_segmentation.dest = pinfo->destport; @@ -2728,20 +2729,20 @@ dissect_eplpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean udp static int dissect_epl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - return dissect_eplpdu(tvb, pinfo, tree, FALSE); + return dissect_eplpdu(tvb, pinfo, tree, false); } static int dissect_epludp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - return dissect_eplpdu(tvb, pinfo, tree, TRUE); + return dissect_eplpdu(tvb, pinfo, tree, true); } -static const gchar* -decode_epl_address (guchar adr) +static const char* +decode_epl_address (unsigned char adr) { - const gchar *addr_str; + const char *addr_str; addr_str = try_val_to_str(adr, addr_str_vals); @@ -2762,10 +2763,10 @@ decode_epl_address (guchar adr) } } -static gint -dissect_epl_payload(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset, gint len, const struct epl_datatype *type, guint8 msgType) +static int +dissect_epl_payload(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset, int len, const struct epl_datatype *type, uint8_t msgType) { - gint rem_len = 0, payload_len = 0; + int rem_len = 0, payload_len = 0; tvbuff_t *payload_tvb = NULL; heur_dtbl_entry_t *hdtbl_entry = NULL; proto_item *item = NULL; @@ -2806,7 +2807,7 @@ dissect_epl_payload(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gin * to full 64 bit, which looks kind of ugly, so we add the * HEX part of BASE_DEC_HEX ourselves */ - guint64 val; + uint64_t val; item = proto_tree_add_item_ret_uint64(epl_tree, *type->hf, tvb, offset, type->len, type->encoding, &val); proto_item_append_text(item, " (0x%.*" PRIx64 ")", 2*type->len, val); @@ -2818,9 +2819,9 @@ dissect_epl_payload(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gin else { /* We don't know the type, so let's use appropriate unsignedX */ - if (payload_len < (int)sizeof (guint64) && interpret_untyped_as_le) + if (payload_len < (int)sizeof (uint64_t) && interpret_untyped_as_le) { - guint64 val; + uint64_t val; item = proto_tree_add_item_ret_uint64(epl_tree, hf_epl_od_uint, payload_tvb, 0, payload_len, ENC_LITTLE_ENDIAN, &val); proto_item_append_text(item, " (0x%.*" PRIx64 ")", 2*payload_len, val); @@ -2834,10 +2835,10 @@ dissect_epl_payload(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gin return offset + payload_len; } -static gint -dissect_epl_soc(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset) +static int +dissect_epl_soc(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset) { - guint8 flags; + uint8_t flags; static int * const soc_flags[] = { &hf_epl_soc_mc, &hf_epl_soc_ps, @@ -2847,7 +2848,7 @@ dissect_epl_soc(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint of offset += 1; - flags = tvb_get_guint8(tvb, offset); + flags = tvb_get_uint8(tvb, offset); proto_tree_add_bitmask(epl_tree, tvb, offset, hf_epl_soc_flags, ett_epl_soc, soc_flags, ENC_NA); offset += 2; @@ -2869,12 +2870,12 @@ dissect_epl_soc(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint of -static gint -dissect_epl_preq(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset) +static int +dissect_epl_preq(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset) { - guint16 len; - guint8 pdoversion; - guint8 flags; + uint16_t len; + uint8_t pdoversion; + uint8_t flags; static int * const req_flags[] = { &hf_epl_preq_ms, &hf_epl_preq_ea, @@ -2884,7 +2885,7 @@ dissect_epl_preq(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, p offset += 1; - flags = tvb_get_guint8(tvb, offset); + flags = tvb_get_uint8(tvb, offset); proto_tree_add_bitmask(epl_tree, tvb, offset, hf_epl_preq_flags, ett_epl_preq, req_flags, ENC_NA); offset += 1; @@ -2893,7 +2894,7 @@ dissect_epl_preq(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, p proto_tree_add_item(epl_tree, hf_epl_preq_sls, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - pdoversion = tvb_get_guint8(tvb, offset); + pdoversion = tvb_get_uint8(tvb, offset); proto_tree_add_item(epl_tree, hf_epl_preq_pdov, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 2; @@ -2912,12 +2913,12 @@ dissect_epl_preq(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, p -static gint -dissect_epl_pres(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset) +static int +dissect_epl_pres(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset) { - guint16 len; - guint8 pdoversion; - guint8 state, flags, flags2; + uint16_t len; + uint8_t pdoversion; + uint8_t state, flags, flags2; static int * const res_flags[] = { &hf_epl_pres_ms, &hf_epl_pres_en, @@ -2925,7 +2926,7 @@ dissect_epl_pres(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, p NULL }; - state = tvb_get_guint8(tvb, offset); + state = tvb_get_uint8(tvb, offset); if (pinfo->srcport != EPL_MN_NODEID) /* check if the sender is CN or MN */ { proto_tree_add_item(epl_tree, hf_epl_pres_stat_cs, tvb, offset, 1, ENC_LITTLE_ENDIAN); @@ -2936,11 +2937,11 @@ dissect_epl_pres(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, p } offset += 1; - flags = tvb_get_guint8(tvb, offset); + flags = tvb_get_uint8(tvb, offset); proto_tree_add_bitmask(epl_tree, tvb, offset, hf_epl_pres_flags, ett_epl_pres, res_flags, ENC_NA); offset += 1; - flags2 = tvb_get_guint8(tvb, offset); + flags2 = tvb_get_uint8(tvb, offset); proto_tree_add_item(epl_tree, hf_epl_pres_fls, tvb, offset, 1, ENC_LITTLE_ENDIAN); proto_tree_add_item(epl_tree, hf_epl_pres_sls, tvb, offset, 1, ENC_LITTLE_ENDIAN); @@ -2948,7 +2949,7 @@ dissect_epl_pres(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, p proto_tree_add_item(epl_tree, hf_epl_pres_rs, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - pdoversion = tvb_get_guint8(tvb, offset); + pdoversion = tvb_get_uint8(tvb, offset); proto_tree_add_item(epl_tree, hf_epl_pres_pdov, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 2; @@ -2981,15 +2982,15 @@ dissect_epl_pres(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, p } -static gint -dissect_epl_soa(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset) +static int +dissect_epl_soa(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset) { - guint8 svid, target; - guint8 state, flags; + uint8_t svid, target; + uint8_t state, flags; proto_item *psf_item = NULL; proto_tree *psf_tree = NULL; - state = tvb_get_guint8(tvb, offset); + state = tvb_get_uint8(tvb, offset); if (pinfo->srcport != EPL_MN_NODEID) /* check if CN or MN */ { proto_tree_add_item(epl_tree, hf_epl_soa_stat_cs, tvb, offset, 1, ENC_LITTLE_ENDIAN); @@ -3001,8 +3002,8 @@ dissect_epl_soa(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint of offset += 1; - flags = tvb_get_guint8(tvb, offset); - svid = tvb_get_guint8(tvb, offset + 2); + flags = tvb_get_uint8(tvb, offset); + svid = tvb_get_uint8(tvb, offset + 2); if (svid == EPL_SOA_IDENTREQUEST) { proto_tree_add_item(epl_tree, hf_epl_soa_dna_an_lcl, tvb, offset, 1, ENC_LITTLE_ENDIAN); @@ -3015,7 +3016,7 @@ dissect_epl_soa(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint of proto_tree_add_uint(epl_tree, hf_epl_soa_svid, tvb, offset, 1, svid); offset += 1; - target = tvb_get_guint8(tvb, offset); + target = tvb_get_uint8(tvb, offset); proto_tree_add_uint(epl_tree, hf_epl_soa_svtg, tvb, offset, 1, target); offset += 1; @@ -3107,25 +3108,25 @@ dissect_epl_soa(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint of -static gint -dissect_epl_asnd(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset) +static int +dissect_epl_asnd(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset) { - guint8 svid; - guint8 flags, flags2; - gint size, reported_len; + uint8_t svid; + uint8_t flags, flags2; + int size, reported_len; tvbuff_t *next_tvb; proto_item *item; proto_tree *subtree; struct epl_convo *convo; /* get ServiceID of payload */ - svid = tvb_get_guint8(tvb, offset); + svid = tvb_get_uint8(tvb, offset); item = proto_tree_add_uint(epl_tree, hf_epl_asnd_svid, tvb, offset, 1, svid ); offset += 1; - flags = tvb_get_guint8(tvb, offset); - flags2 = tvb_get_guint8(tvb, offset + 1); + flags = tvb_get_uint8(tvb, offset); + flags2 = tvb_get_uint8(tvb, offset + 1); col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ", rval_to_str_const(svid, asnd_svid_id_vals, "Unknown")); @@ -3181,10 +3182,10 @@ dissect_epl_asnd(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint o return offset; } -static gint -dissect_epl_ainv(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset) +static int +dissect_epl_ainv(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset) { - guint8 svid; + uint8_t svid; proto_item *item; proto_tree *subtree; struct epl_convo *convo; @@ -3204,7 +3205,7 @@ dissect_epl_ainv(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint o proto_tree_add_item(epl_tree, hf_epl_soa_er, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - svid = tvb_get_guint8(tvb, offset); + svid = tvb_get_uint8(tvb, offset); col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ", rval_to_str(svid, asnd_svid_id_vals, "UNKNOWN(%d)")); @@ -3246,12 +3247,12 @@ dissect_epl_ainv(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint o } -static gint -dissect_epl_asnd_nmtreq(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset) +static int +dissect_epl_asnd_nmtreq(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset) { - guint8 rcid; + uint8_t rcid; - rcid = tvb_get_guint8(tvb, offset); + rcid = tvb_get_uint8(tvb, offset); proto_tree_add_uint(epl_tree, hf_epl_asnd_nmtrequest_rcid, tvb, offset, 1, rcid); proto_tree_add_item(epl_tree, hf_epl_asnd_nmtrequest_rct, tvb, offset+1, 1, ENC_LITTLE_ENDIAN); @@ -3265,15 +3266,15 @@ dissect_epl_asnd_nmtreq(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, return offset; } -static gint -dissect_epl_asnd_nmtdna(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset) +static int +dissect_epl_asnd_nmtdna(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset) { proto_item *ti_dna; proto_tree *epl_dna_tree; - guint32 curr_node_num; - guint32 new_node_num; - guint32 lease_time; - guint32 lease_time_s; + uint32_t curr_node_num; + uint32_t new_node_num; + uint32_t lease_time; + uint32_t lease_time_s; nstime_t us; static int * const dna_flags[] = { &hf_epl_asnd_nmtcommand_nmtdna_ltv, @@ -3303,7 +3304,7 @@ dissect_epl_asnd_nmtdna(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, proto_tree_add_item_ret_uint (epl_dna_tree, hf_epl_asnd_nmtcommand_nmtdna_newnn, tvb, offset, 4, ENC_LITTLE_ENDIAN, &new_node_num); offset += 4; - lease_time = tvb_get_guint32(tvb, offset, ENC_LITTLE_ENDIAN); + lease_time = tvb_get_uint32(tvb, offset, ENC_LITTLE_ENDIAN); lease_time_s = lease_time / 1000000; /* us->s */ us.nsecs = (lease_time - lease_time_s * 1000000) * 1000; /* us->ns */ us.secs = lease_time_s; @@ -3316,13 +3317,13 @@ dissect_epl_asnd_nmtdna(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, } -static gint -dissect_epl_asnd_nmtcmd(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset) +static int +dissect_epl_asnd_nmtcmd(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset) { - guint8 epl_asnd_nmtcommand_cid; - guint16 errorcode; + uint8_t epl_asnd_nmtcommand_cid; + uint16_t errorcode; - epl_asnd_nmtcommand_cid = tvb_get_guint8(tvb, offset); + epl_asnd_nmtcommand_cid = tvb_get_uint8(tvb, offset); proto_tree_add_uint(epl_tree, hf_epl_asnd_nmtcommand_cid, tvb, offset, 1, epl_asnd_nmtcommand_cid); offset += 2; @@ -3371,15 +3372,15 @@ dissect_epl_asnd_nmtcmd(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, -static gint -dissect_epl_asnd_ires(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset) +static int +dissect_epl_asnd_ires(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset) { - guint32 epl_asnd_identresponse_ipa, epl_asnd_identresponse_snm, epl_asnd_identresponse_gtw; + uint32_t epl_asnd_identresponse_ipa, epl_asnd_identresponse_snm, epl_asnd_identresponse_gtw; proto_item *ti_feat, *ti; proto_tree *epl_feat_tree; - guint16 device_type; + uint16_t device_type; const char *profile_name = NULL; - guint32 response_time; + uint32_t response_time; proto_tree_add_item(epl_tree, hf_epl_asnd_identresponse_en, tvb, offset, 1, ENC_LITTLE_ENDIAN); proto_tree_add_item(epl_tree, hf_epl_asnd_identresponse_ec, tvb, offset, 1, ENC_LITTLE_ENDIAN); @@ -3525,8 +3526,8 @@ dissect_epl_asnd_ires(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *t return offset; } -static gint -dissect_epl_asnd_resp(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint offset) +static int +dissect_epl_asnd_resp(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo _U_, int offset) { proto_item *psf_item = NULL; proto_tree *psf_tree = NULL; @@ -3578,13 +3579,13 @@ dissect_epl_asnd_resp(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo _U return offset; } -static gint -dissect_epl_asnd_sres(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset) +static int +dissect_epl_asnd_sres(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset) { proto_item *ti_el_entry, *ti_el_entry_type; proto_tree *epl_seb_tree, *epl_el_tree, *epl_el_entry_tree, *epl_el_entry_type_tree; - guint number_of_entries, cnt; /* used for dissection of ErrorCodeList */ - guint8 nmt_state; + unsigned number_of_entries, cnt; /* used for dissection of ErrorCodeList */ + uint8_t nmt_state; proto_tree_add_item(epl_tree, hf_epl_asnd_statusresponse_en, tvb, offset, 1, ENC_LITTLE_ENDIAN); proto_tree_add_item(epl_tree, hf_epl_asnd_statusresponse_ec, tvb, offset, 1, ENC_LITTLE_ENDIAN); @@ -3596,7 +3597,7 @@ dissect_epl_asnd_sres(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, g proto_tree_add_item(epl_tree, hf_epl_asnd_statusresponse_rs, tvb, offset, 1, ENC_LITTLE_ENDIAN); offset += 1; - nmt_state = tvb_get_guint8(tvb, offset); + nmt_state = tvb_get_uint8(tvb, offset); col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", val_to_str(nmt_state, epl_nmt_cs_vals, "Unknown (%d)")); if (pinfo->srcport != EPL_MN_NODEID) /* check if CN or MN */ @@ -3668,17 +3669,17 @@ dissect_epl_asnd_sres(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, g return offset; } -static gint -dissect_epl_asnd_sdo(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset) +static int +dissect_epl_asnd_sdo(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset) { - guint16 seqnum = 0x00; - guint8 seq_read; + uint16_t seqnum = 0x00; + uint8_t seq_read; offset = dissect_epl_sdo_sequence(epl_tree, tvb, pinfo, offset, &seq_read); seqnum = epl_get_sequence_nr(pinfo); /* if a frame is duplicated don't show the command layer */ - if(seqnum == 0x00 || show_cmd_layer_for_duplicated == TRUE ) + if(seqnum == 0x00 || show_cmd_layer_for_duplicated == true ) { if (tvb_reported_length_remaining(tvb, offset) > 0) { @@ -3689,27 +3690,27 @@ dissect_epl_asnd_sdo(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gi return offset; } -static gint -dissect_epl_sdo_sequence(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset, guint8* seq) +static int +dissect_epl_sdo_sequence(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset, uint8_t* seq) { - guint8 seq_recv = 0x00, seq_send = 0x00, rcon = 0x00, scon = 0x00; - guint32 frame = 0x00; + uint8_t seq_recv = 0x00, seq_send = 0x00, rcon = 0x00, scon = 0x00; + uint32_t frame = 0x00; proto_tree *sod_seq_tree; proto_item *item; - guint8 duplication = 0x00; - gpointer key; - guint32 saved_frame; - guint16 seqnum = 0; + uint8_t duplication = 0x00; + void *key; + uint32_t saved_frame; + uint16_t seqnum = 0; /* read buffer */ - seq_recv = tvb_get_guint8(tvb, offset); + seq_recv = tvb_get_uint8(tvb, offset); /* get rcon */ rcon = seq_recv & EPL_ASND_SDO_SEQ_CON_MASK; /* get seq_recv */ seq_recv = seq_recv >> EPL_ASND_SDO_SEQ_MASK; epl_segmentation.recv = seq_recv; /* read buffer */ - seq_send = tvb_get_guint8(tvb, offset+1); + seq_send = tvb_get_uint8(tvb, offset+1); /* get scon */ scon = seq_send & EPL_ASND_SDO_SEQ_CON_MASK; /* get seq_send */ @@ -3801,14 +3802,14 @@ dissect_epl_sdo_sequence(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo free_key(key); item = proto_tree_add_item(epl_tree, hf_epl_asnd_sdo_seq, tvb, offset, 5, ENC_NA); sod_seq_tree = proto_item_add_subtree(item, ett_epl_sdo_sequence_layer); - /* Asynchronuous SDO Sequence Layer */ - seq_recv = tvb_get_guint8(tvb, offset); + /* Asynchronous SDO Sequence Layer */ + seq_recv = tvb_get_uint8(tvb, offset); proto_tree_add_uint(sod_seq_tree, hf_epl_asnd_sdo_seq_receive_sequence_number, tvb, offset, 1, seq_recv); proto_tree_add_uint(sod_seq_tree, hf_epl_asnd_sdo_seq_receive_con, tvb, offset, 1, seq_recv); offset += 1; - *seq = seq_send = tvb_get_guint8(tvb, offset); + *seq = seq_send = tvb_get_uint8(tvb, offset); proto_tree_add_uint(sod_seq_tree, hf_epl_asnd_sdo_seq_send_sequence_number, tvb, offset, 1, seq_send); proto_tree_add_uint(sod_seq_tree, hf_epl_asnd_sdo_seq_send_con, tvb, offset, 1, seq_send); @@ -3826,26 +3827,26 @@ dissect_epl_sdo_sequence(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo return offset; } -static gint -dissect_epl_sdo_command(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset, guint8 seq) +static int +dissect_epl_sdo_command(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset, uint8_t seq) { - gint payload_length; - guint8 segmented, command_id, transaction_id; - gboolean response, abort_flag; - guint32 abort_code = 0; - guint32 fragmentId = 0, remlength = 0; - guint16 segment_size = 0; + int payload_length; + uint8_t segmented, command_id, transaction_id; + bool response, abort_flag; + uint32_t abort_code = 0; + uint32_t fragmentId = 0, remlength = 0; + uint16_t segment_size = 0; proto_tree *sdo_cmd_tree = NULL; proto_item *item; - guint8 sendCon = 0; - guint is_response = 0; + uint8_t sendCon = 0; + unsigned is_response = 0; offset += 1; - sendCon = tvb_get_guint8(tvb, 5) & EPL_ASND_SDO_SEQ_SEND_CON_ERROR_VALID_ACK_REQ; + sendCon = tvb_get_uint8(tvb, 5) & EPL_ASND_SDO_SEQ_SEND_CON_ERROR_VALID_ACK_REQ; - command_id = tvb_get_guint8(tvb, offset + 2); - abort_flag = tvb_get_guint8(tvb, offset + 1) & EPL_ASND_SDO_CMD_ABORT_FILTER; + command_id = tvb_get_uint8(tvb, offset + 2); + abort_flag = tvb_get_uint8(tvb, offset + 1) & EPL_ASND_SDO_CMD_ABORT_FILTER; /* test if CommandField == empty */ if (command_id != 0 || abort_flag) @@ -3853,9 +3854,9 @@ dissect_epl_sdo_command(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, item = proto_tree_add_item(epl_tree, hf_epl_asnd_sdo_cmd, tvb, offset, 0, ENC_NA); sdo_cmd_tree = proto_item_add_subtree(item, ett_epl_sdo_command_layer); - transaction_id = tvb_get_guint8(tvb, offset); - response = tvb_get_guint8(tvb, offset + 1) & EPL_ASND_SDO_CMD_RESPONSE_FILTER; - segmented = (tvb_get_guint8(tvb, offset + 1) & EPL_ASND_SDO_CMD_SEGMENTATION_FILTER) >> 4; + transaction_id = tvb_get_uint8(tvb, offset); + response = tvb_get_uint8(tvb, offset + 1) & EPL_ASND_SDO_CMD_RESPONSE_FILTER; + segmented = (tvb_get_uint8(tvb, offset + 1) & EPL_ASND_SDO_CMD_SEGMENTATION_FILTER) >> 4; segment_size = tvb_get_letohs(tvb, offset + 3); @@ -3897,23 +3898,23 @@ dissect_epl_sdo_command(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, payload_length = tvb_reported_length_remaining(tvb, offset); /* create a key for reassembly => first 16 bit are src-address and last 16 bit are the dest-address */ - fragmentId = (guint32)((((guint32)epl_segmentation.src)<<16)+epl_segmentation.dest); + fragmentId = (uint32_t)((((uint32_t)epl_segmentation.src)<<16)+epl_segmentation.dest); /* set fragmented flag */ - pinfo->fragmented = TRUE; + pinfo->fragmented = true; fragment_add_seq_check(&epl_reassembly_table, tvb, offset, pinfo, - fragmentId, NULL, 0, payload_length, TRUE ); + fragmentId, NULL, 0, payload_length, true ); fragment_add_seq_offset ( &epl_reassembly_table, pinfo, fragmentId, NULL, 0 ); if (command_id == EPL_ASND_SDO_COMMAND_WRITE_BY_INDEX) { - first_write = FALSE; + first_write = false; } else { - first_read = FALSE; + first_read = false; } /* if Segmentation = Initiate then print DataSize */ proto_tree_add_item(sdo_cmd_tree, hf_epl_asnd_sdo_cmd_data_size, tvb, offset, 4, ENC_LITTLE_ENDIAN); - segmented = TRUE; + segmented = true; offset += 4; } @@ -3921,7 +3922,7 @@ dissect_epl_sdo_command(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, { /* if Segmentation = Initiate then print DataSize */ proto_tree_add_item(sdo_cmd_tree, hf_epl_asnd_sdo_cmd_data_size, tvb, offset, 4, ENC_LITTLE_ENDIAN); - segmented = TRUE; + segmented = true; offset += 4; } } @@ -3933,7 +3934,7 @@ dissect_epl_sdo_command(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, /* the SDO response can contain several abort codes for multiple transfers */ while (remlength > 0) { - /* TODO enchance Index and SubIndex with string representation */ + /* TODO enhance Index and SubIndex with string representation */ proto_tree_add_item(sdo_cmd_tree, hf_epl_asnd_sdo_cmd_data_index, tvb, offset, 2, ENC_LITTLE_ENDIAN); offset += 2; @@ -3985,26 +3986,26 @@ dissect_epl_sdo_command(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, break; default: - return FALSE; + return false; } } } return offset; } -static gint -dissect_epl_sdo_command_write_by_index(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset, guint8 segmented, gboolean response, guint16 segment_size) +static int +dissect_epl_sdo_command_write_by_index(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset, uint8_t segmented, bool response, uint16_t segment_size) { - gint size, payload_length, rem_size = 0; - guint16 idx = 0x00, sod_index = 0xFF, error = 0xFF, sub_val = 0x00; - gboolean nosub = FALSE; - guint8 subindex = 0x00; - guint32 fragmentId = 0; - guint32 frame = 0; - gboolean end_segment = FALSE; + int size, payload_length, rem_size = 0; + uint16_t idx = 0x00, sod_index = 0xFF, error = 0xFF, sub_val = 0x00; + bool nosub = false; + uint8_t subindex = 0x00; + uint32_t fragmentId = 0; + uint32_t frame = 0; + bool end_segment = false; proto_item *psf_item, *cmd_payload; proto_tree *payload_tree; - const gchar *index_str, *sub_str, *sub_index_str; + const char *index_str, *sub_str, *sub_index_str; fragment_head *frag_msg = NULL; struct object *obj = NULL; const struct subobject *subobj = NULL; @@ -4038,7 +4039,7 @@ dissect_epl_sdo_command_write_by_index(struct epl_convo *convo, proto_tree *epl_ offset += 2; /* get subindex offset */ - subindex = tvb_get_guint8(tvb, offset); + subindex = tvb_get_uint8(tvb, offset); subobj = subobject_lookup(obj, subindex); @@ -4053,7 +4054,7 @@ dissect_epl_sdo_command_write_by_index(struct epl_convo *convo, proto_tree *epl_ if (obj || sod_index == error) { - const char *name = obj ? obj->info.name : val_to_str_ext_const(((guint32)(idx<<16)), &sod_index_names, "User Defined"); + const char *name = obj ? obj->info.name : val_to_str_ext_const(((uint32_t)(idx<<16)), &sod_index_names, "User Defined"); proto_item_append_text(psf_item, " (%s)", name); col_append_fstr(pinfo->cinfo, COL_INFO, " (%s", name); if (obj) nosub = obj->info.type_class == OD_ENTRY_SCALAR; @@ -4061,7 +4062,7 @@ dissect_epl_sdo_command_write_by_index(struct epl_convo *convo, proto_tree *epl_ else /* string is in list */ { /* add index string to index item */ - proto_item_append_text(psf_item," (%s", val_to_str_ext_const(((guint32)(sod_index<<16)), &sod_index_names, "User Defined")); + proto_item_append_text(psf_item," (%s", val_to_str_ext_const(((uint32_t)(sod_index<<16)), &sod_index_names, "User Defined")); proto_item_append_text(psf_item,"_%02Xh", (idx-sod_index)); if(sod_index == EPL_SOD_PDO_RX_MAPP || sod_index == EPL_SOD_PDO_TX_MAPP) { @@ -4072,15 +4073,15 @@ dissect_epl_sdo_command_write_by_index(struct epl_convo *convo, proto_tree *epl_ proto_item_append_text(psf_item,"_REC)"); } /* info text */ - col_append_fstr(pinfo->cinfo, COL_INFO, " (%s", val_to_str_ext_const(((guint32)(sod_index << 16)), &sod_index_names, "User Defined")); + col_append_fstr(pinfo->cinfo, COL_INFO, " (%s", val_to_str_ext_const(((uint32_t)(sod_index << 16)), &sod_index_names, "User Defined")); col_append_fstr(pinfo->cinfo, COL_INFO, "_%02Xh", (idx-sod_index)); if(sod_index == EPL_SOD_PDO_RX_MAPP || sod_index == EPL_SOD_PDO_TX_MAPP) { - col_append_fstr(pinfo->cinfo, COL_INFO, "_AU64"); + col_append_str(pinfo->cinfo, COL_INFO, "_AU64"); } else { - col_append_fstr(pinfo->cinfo, COL_INFO, "_REC"); + col_append_str(pinfo->cinfo, COL_INFO, "_REC"); } idx = sod_index; } @@ -4110,18 +4111,18 @@ dissect_epl_sdo_command_write_by_index(struct epl_convo *convo, proto_tree *epl_ { psf_item = proto_tree_add_item(epl_tree, hf_epl_asnd_sdo_cmd_data_subindex, tvb, offset, 1, ENC_LITTLE_ENDIAN); proto_item_append_text(psf_item, " (ObjectMapping)"); - col_append_fstr(pinfo->cinfo, COL_INFO, "/ObjectMapping)"); + col_append_str(pinfo->cinfo, COL_INFO, "/ObjectMapping)"); } /* no subindex */ else if(nosub) { - col_append_fstr(pinfo->cinfo, COL_INFO, ")"); + col_append_str(pinfo->cinfo, COL_INFO, ")"); } else if(subindex == 0x00) { psf_item = proto_tree_add_item(epl_tree, hf_epl_asnd_sdo_cmd_data_subindex, tvb, offset, 1, ENC_LITTLE_ENDIAN); proto_item_append_text(psf_item, " (NumberOfEntries)"); - col_append_fstr(pinfo->cinfo, COL_INFO, "/NumberOfEntries)"); + col_append_str(pinfo->cinfo, COL_INFO, "/NumberOfEntries)"); } else { @@ -4136,15 +4137,15 @@ dissect_epl_sdo_command_write_by_index(struct epl_convo *convo, proto_tree *epl_ (segmented == EPL_ASND_SDO_CMD_SEGMENTATION_SEGMENT)) { /* get the fragmentId */ - fragmentId = (guint32)((((guint32)epl_segmentation.src)<<16)+epl_segmentation.dest); + fragmentId = (uint32_t)((((uint32_t)epl_segmentation.src)<<16)+epl_segmentation.dest); /* set the fragmented flag */ - pinfo->fragmented = TRUE; + pinfo->fragmented = true; - /* get payloade size */ + /* get payload size */ payload_length = tvb_reported_length_remaining(tvb, offset); /* if the frame is the last frame */ if(segmented == EPL_ASND_SDO_CMD_SEGMENTATION_TRANSFER_COMPLETE) - end_segment = TRUE; + end_segment = true; /* if the send-sequence-number is at the end or the beginning of a sequence */ if(epl_segmentation.send == 0x3f || epl_segmentation.send <= 0x01 ) @@ -4156,7 +4157,7 @@ dissect_epl_sdo_command_write_by_index(struct epl_convo *convo, proto_tree *epl_ ct += 1; /* add the frame to reassembly_table */ frag_msg = fragment_add_seq_check(&epl_reassembly_table, tvb, offset, pinfo, - fragmentId, NULL, ct, payload_length, end_segment ? FALSE : TRUE ); + fragmentId, NULL, ct, payload_length, end_segment ? false : true ); } else { @@ -4169,21 +4170,21 @@ dissect_epl_sdo_command_write_by_index(struct epl_convo *convo, proto_tree *epl_ if (first_write) { frag_msg = fragment_add_seq_check(&epl_reassembly_table, tvb, offset, pinfo, - fragmentId, NULL, 0, payload_length, end_segment ? FALSE : TRUE ); + fragmentId, NULL, 0, payload_length, end_segment ? false : true ); fragment_add_seq_offset(&epl_reassembly_table, pinfo, fragmentId, NULL, ct); - first_write = FALSE; + first_write = false; } else { frag_msg = fragment_add_seq_check(&epl_reassembly_table, tvb, offset, pinfo, - fragmentId, NULL, ct, payload_length, end_segment ? FALSE : TRUE ); + fragmentId, NULL, ct, payload_length, end_segment ? false : true ); } } else { frag_msg = fragment_add_seq_check(&epl_reassembly_table, tvb, offset, pinfo, - fragmentId, NULL, 0, payload_length, end_segment ? FALSE : TRUE); + fragmentId, NULL, 0, payload_length, end_segment ? false : true); epl_asnd_sdo_reassembly_write.frame[epl_segmentation.recv][epl_segmentation.send] = frame; } } @@ -4197,7 +4198,7 @@ dissect_epl_sdo_command_write_by_index(struct epl_convo *convo, proto_tree *epl_ cmd_payload = proto_tree_add_uint_format(epl_tree, hf_epl_asnd_sdo_cmd_reassembled, tvb, offset, payload_length,0, "Reassembled: %d bytes total (%d bytes in this frame)",frag_msg->len,payload_length); payload_tree = proto_item_add_subtree(cmd_payload, ett_epl_asnd_sdo_data_reassembled); - /* add the reassembley fields */ + /* add the reassembly fields */ process_reassembled_data(tvb, 0, pinfo, "Reassembled Message", frag_msg, &epl_frag_items, NULL, payload_tree ); proto_tree_add_uint_format_value(payload_tree, hf_epl_asnd_sdo_cmd_reassembled, tvb, 0, 0, payload_length, "%d bytes (over all fragments)", frag_msg->len); @@ -4256,8 +4257,8 @@ dissect_epl_sdo_command_write_by_index(struct epl_convo *convo, proto_tree *epl_ } /* epl_tree may be null here, when this function is called from the profile parser */ -static gint -dissect_object_mapping(struct profile *profile, wmem_array_t *mappings, proto_tree *epl_tree, tvbuff_t *tvb, guint32 framenum, gint offset, guint16 idx, guint8 subindex) +static int +dissect_object_mapping(struct profile *profile, wmem_array_t *mappings, proto_tree *epl_tree, tvbuff_t *tvb, uint32_t framenum, int offset, uint16_t idx, uint8_t subindex) { proto_item *ti_obj, *ti_subobj, *psf_item; proto_tree *psf_tree; @@ -4265,7 +4266,7 @@ dissect_object_mapping(struct profile *profile, wmem_array_t *mappings, proto_tr struct object *mapping_obj; int *ett; const struct subobject *mapping_subobj; - gboolean nosub = FALSE; + bool nosub = false; /* If we don't populate the tree or record mappings, skip over it */ if (!epl_tree && !mappings) @@ -4274,7 +4275,7 @@ dissect_object_mapping(struct profile *profile, wmem_array_t *mappings, proto_tr map.param.idx = idx; map.param.subindex = subindex; map.frame.first = framenum; - map.frame.last = G_MAXUINT32; + map.frame.last = UINT32_MAX; psf_item = proto_tree_add_item(epl_tree, hf_epl_asnd_sdo_cmd_data_mapping, tvb, offset, 1, ENC_NA); psf_tree = proto_item_add_subtree(psf_item, ett_epl_asnd_sdo_cmd_data_mapping); @@ -4283,7 +4284,7 @@ dissect_object_mapping(struct profile *profile, wmem_array_t *mappings, proto_tr ti_obj = proto_tree_add_uint_format(psf_tree, hf_epl_asnd_sdo_cmd_data_mapping_index, tvb, offset, 2, map.pdo.idx,"Index: 0x%04X", map.pdo.idx); offset += 2; - map.pdo.subindex = tvb_get_guint8(tvb, offset); + map.pdo.subindex = tvb_get_uint8(tvb, offset); ti_subobj = proto_tree_add_uint_format(psf_tree, hf_epl_asnd_sdo_cmd_data_mapping_subindex, tvb, offset, 1, map.pdo.subindex, "SubIndex: 0x%02X", map.pdo.subindex); offset += 2; @@ -4291,7 +4292,7 @@ dissect_object_mapping(struct profile *profile, wmem_array_t *mappings, proto_tr if ((mapping_obj = object_lookup(profile, map.pdo.idx))) { if (!map.pdo.subindex && mapping_obj->info.type_class == OD_ENTRY_SCALAR) - nosub = TRUE; + nosub = true; map.info = &mapping_obj->info; map.index_name = map.info->name; @@ -4313,7 +4314,7 @@ dissect_object_mapping(struct profile *profile, wmem_array_t *mappings, proto_tr proto_tree_add_uint_format(psf_tree, hf_epl_asnd_sdo_cmd_data_mapping_offset, tvb, offset, 2, map.bit_offset,"Offset: 0x%04X", map.bit_offset); offset += 2; - map.no_of_bits = tvb_get_guint8(tvb, offset); + map.no_of_bits = tvb_get_uint8(tvb, offset); psf_item = proto_tree_add_item(psf_tree, hf_epl_asnd_sdo_cmd_data_mapping_length, tvb, offset, 2, ENC_LITTLE_ENDIAN); proto_item_append_text(psf_item, " bits"); offset += 2; @@ -4339,21 +4340,21 @@ dissect_object_mapping(struct profile *profile, wmem_array_t *mappings, proto_tr return offset; } -static gint -dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset, guint8 segmented, gboolean response, guint16 segment_size) +static int +dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset, uint8_t segmented, bool response, uint16_t segment_size) { - gint dataoffset; - guint8 subindex = 0x00, padding = 0x00; - guint16 idx = 0x00, error = 0xFF, sub_val = 0x00; - gboolean nosub = FALSE; - guint32 size, offsetincrement, datalength, remlength, objectcnt, abort_code = 0; - gboolean lastentry = FALSE, is_abort = FALSE; - const gchar *index_str, *sub_str, *sub_index_str; + int dataoffset; + uint8_t subindex = 0x00, padding = 0x00; + uint16_t idx = 0x00, error = 0xFF, sub_val = 0x00; + bool nosub = false; + uint32_t size, offsetincrement, datalength, remlength, objectcnt, abort_code = 0; + bool lastentry = false, is_abort = false; + const char *index_str, *sub_str, *sub_index_str; proto_item *psf_item; proto_tree *psf_od_tree; struct object *obj = NULL; const struct subobject *subobj = NULL; - guint16 segment_restsize = segment_size; + uint16_t segment_restsize = segment_size; /* Offset is calculated simply by only applying EPL payload offset, not packet offset. @@ -4369,7 +4370,7 @@ dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_t &epl_sdo_asnd_commands_short_ext, "Command(%02X)"), segment_size); - remlength = (guint32)tvb_reported_length_remaining(tvb, offset); + remlength = (uint32_t)tvb_reported_length_remaining(tvb, offset); objectcnt = 0; /* As long as no lastentry has been detected, and we have still bytes left, @@ -4377,12 +4378,12 @@ dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_t * we now use length_remaining, but it is kept to be on the safe side. */ while ( !lastentry && remlength > 0 ) { - guint16 sod_index = error; + uint16_t sod_index = error; offsetincrement = tvb_get_letohl(tvb, offset); - /* the data is aligned in 4-byte increments, therfore maximum padding is 3 */ - padding = tvb_get_guint8 ( tvb, offset + 7 ) & 0x03; + /* the data is aligned in 4-byte increments, therefore maximum padding is 3 */ + padding = tvb_get_uint8 ( tvb, offset + 7 ) & 0x03; /* An offset increment of zero usually indicates, that we are at the end * of the payload. But we cannot ignore the end, because packages are @@ -4390,7 +4391,7 @@ dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_t if (offsetincrement == 0) { datalength = segment_restsize; - lastentry = TRUE; + lastentry = true; } else { @@ -4399,7 +4400,7 @@ dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_t /* decrease restsize */ segment_restsize -= datalength; - /* Possible guint overflow */ + /* Possible unsigned overflow */ if ( datalength > remlength ) break; @@ -4411,7 +4412,7 @@ dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_t /* Guarding against readout of padding. Probability is nearly zero, as * padding was checked above, but to be sure, this remains here */ - if ((guint32)(padding + 8) >= datalength) + if ((uint32_t)(padding + 8) >= datalength) break; /* size of data is datalength - ( entry header size and padding ) */ @@ -4445,13 +4446,13 @@ dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_t if(sod_index == error) { - const char *name = obj ? obj->info.name :val_to_str_ext_const(((guint32)(idx<<16)), &sod_index_names, "User Defined"); + const char *name = obj ? obj->info.name :val_to_str_ext_const(((uint32_t)(idx<<16)), &sod_index_names, "User Defined"); proto_item_append_text(psf_item," (%s)", name); } else { /* add index string */ - proto_item_append_text(psf_item," (%s", val_to_str_ext_const(((guint32)(sod_index<<16)), &sod_index_names, "User Defined")); + proto_item_append_text(psf_item," (%s", val_to_str_ext_const(((uint32_t)(sod_index<<16)), &sod_index_names, "User Defined")); proto_item_append_text(psf_item,"_%02Xh", (idx-sod_index)); if(sod_index == EPL_SOD_PDO_RX_MAPP || sod_index == EPL_SOD_PDO_TX_MAPP) { @@ -4476,7 +4477,7 @@ dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_t idx = sod_index; /* get subindex offset */ - subindex = tvb_get_guint8(tvb, dataoffset); + subindex = tvb_get_uint8(tvb, dataoffset); subobj = subobject_lookup(obj, subindex); proto_item_append_text(psf_od_tree, " SubIdx: 0x%02X", subindex); /* get subindex string */ @@ -4534,7 +4535,7 @@ dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_t { if (nosub) /* no subindex */ - col_append_fstr(pinfo->cinfo, COL_INFO, ")"); + col_append_str(pinfo->cinfo, COL_INFO, ")"); else col_append_fstr(pinfo->cinfo, COL_INFO, "/%d)", subindex); } @@ -4572,7 +4573,7 @@ dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_t offset += datalength; /* calculating the remaining length, based on the current offset */ - remlength = (guint32)tvb_reported_length_remaining(tvb, offset); + remlength = (uint32_t)tvb_reported_length_remaining(tvb, offset); } col_append_fstr(pinfo->cinfo, COL_INFO, " (%d)", objectcnt); @@ -4584,7 +4585,7 @@ dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_t &epl_sdo_asnd_commands_short_ext, "Command(%02X)"), segment_size); - remlength = (guint32)tvb_reported_length_remaining(tvb, offset); + remlength = (uint32_t)tvb_reported_length_remaining(tvb, offset); objectcnt = 0; dataoffset = offset; @@ -4593,9 +4594,9 @@ dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_t * we start the loop. */ while ( remlength > 0 ) { - guint16 sod_index; - if ((tvb_get_guint8 ( tvb, offset + 3 ) & 0x80) == 0x80) - is_abort = TRUE; + uint16_t sod_index; + if ((tvb_get_uint8 ( tvb, offset + 3 ) & 0x80) == 0x80) + is_abort = true; /* add object subtree */ psf_od_tree = proto_tree_add_subtree(epl_tree, tvb, offset, 8, 0, NULL , "OD"); @@ -4627,7 +4628,7 @@ dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_t dataoffset += 2; /* get subindex offset */ - subindex = tvb_get_guint8(tvb, dataoffset); + subindex = tvb_get_uint8(tvb, dataoffset); proto_item_append_text(psf_od_tree, " SubIdx: 0x%02X", subindex); proto_tree_add_uint_format(psf_od_tree, hf_epl_asnd_sdo_cmd_data_mapping_subindex, tvb, dataoffset, 1, idx,"SubIndex: 0x%02X", subindex); @@ -4636,7 +4637,7 @@ dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_t { if (nosub) /* no subindex */ - col_append_fstr(pinfo->cinfo, COL_INFO, ")"); + col_append_str(pinfo->cinfo, COL_INFO, ")"); else col_append_fstr(pinfo->cinfo, COL_INFO, "/%d)", subindex); } @@ -4656,7 +4657,7 @@ dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_t psf_item = proto_tree_add_item(psf_od_tree, hf_epl_sdo_multi_param_sub_abort, tvb, dataoffset, 4, ENC_LITTLE_ENDIAN); proto_item_append_text(psf_item," (%s)", val_to_str_ext_const(abort_code, &sdo_cmd_abort_code_ext, "Unknown")); - is_abort = FALSE; + is_abort = false; } objectcnt++; @@ -4666,29 +4667,29 @@ dissect_epl_sdo_command_write_multiple_by_index(struct epl_convo *convo, proto_t offset += 8; /* calculating the remaining length, based on the current offset */ - remlength = (guint32)tvb_reported_length_remaining(tvb, offset); + remlength = (uint32_t)tvb_reported_length_remaining(tvb, offset); } col_append_fstr(pinfo->cinfo, COL_INFO, " (%d)", objectcnt); } return offset; } -static gint -dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset, guint8 segmented, gboolean response, guint16 segment_size) +static int +dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset, uint8_t segmented, bool response, uint16_t segment_size) { - gint dataoffset; - guint8 subindex = 0x00, padding = 0x00; - guint16 idx = 0x00, error = 0xFF, sub_val = 0x00; - gboolean nosub = FALSE; - guint32 size, offsetincrement, datalength, remlength, objectcnt, abort_code; - gboolean lastentry = FALSE, is_abort = FALSE; - const gchar *index_str, *sub_str, *sub_index_str; + int dataoffset; + uint8_t subindex = 0x00, padding = 0x00; + uint16_t idx = 0x00, error = 0xFF, sub_val = 0x00; + bool nosub = false; + uint32_t size, offsetincrement, datalength, remlength, objectcnt, abort_code; + bool lastentry = false, is_abort = false; + const char *index_str, *sub_str, *sub_index_str; proto_item *psf_item, *psf_od_item; proto_tree *psf_tree, *psf_od_tree; struct object *obj = NULL; const struct subobject *subobj = NULL; const char *name; - guint16 segment_restsize = segment_size; + uint16_t segment_restsize = segment_size; /* Offset is calculated simply by only applying EPL payload offset, not packet offset. * The packet offset is 16, as this is the number of bytes trailing the SDO payload. @@ -4702,7 +4703,7 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr &epl_sdo_asnd_commands_short_ext, "Command(%02X)"), segment_size); - remlength = (guint32)tvb_reported_length_remaining(tvb, offset); + remlength = (uint32_t)tvb_reported_length_remaining(tvb, offset); objectcnt = 0; /* As long as no lastentry has been detected, and we have still bytes left, @@ -4710,15 +4711,15 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr * we now use length_remaining, but it is kept to be on the safe side. */ while ( !lastentry && remlength > 0 ) { - guint16 sod_index = error; + uint16_t sod_index = error; offsetincrement = tvb_get_letohl(tvb, offset); /* the data is aligned in 4-byte increments, therefor maximum padding is 3 */ - padding = tvb_get_guint8 ( tvb, offset + 7 ) & 0x03; + padding = tvb_get_uint8 ( tvb, offset + 7 ) & 0x03; - if ((tvb_get_guint8 ( tvb, offset + 7 ) & 0x80) == 0x80) - is_abort = TRUE; + if ((tvb_get_uint8 ( tvb, offset + 7 ) & 0x80) == 0x80) + is_abort = true; /* An offset increment of zero usually indicates, that we are at the end * of the payload. But we cannot ignore the end, because packages are @@ -4726,7 +4727,7 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr if (offsetincrement == 0) { datalength = segment_restsize; - lastentry = TRUE; + lastentry = true; } else { @@ -4735,7 +4736,7 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr /* decrease restsize */ segment_restsize -= datalength; - /* Possible guint overflow */ + /* Possible unsigned overflow */ if (datalength > remlength) break; @@ -4747,7 +4748,7 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr /* Guarding against readout of padding. Probability is nearly zero, as * padding was checked above, but to be sure, this remains here */ - if ((guint32)(padding + 8) >= datalength) + if ((uint32_t)(padding + 8) >= datalength) break; /* size of data is datalength - ( entry header size and padding ) */ @@ -4784,12 +4785,12 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr } else if(sod_index == error) { - proto_item_append_text(psf_item," (%s)", val_to_str_ext_const(((guint32)(idx<<16)), &sod_index_names, "User Defined")); + proto_item_append_text(psf_item," (%s)", val_to_str_ext_const(((uint32_t)(idx<<16)), &sod_index_names, "User Defined")); } else { /* add index string */ - proto_item_append_text(psf_item," (%s", val_to_str_ext_const(((guint32)(sod_index<<16)), &sod_index_names, "User Defined")); + proto_item_append_text(psf_item," (%s", val_to_str_ext_const(((uint32_t)(sod_index<<16)), &sod_index_names, "User Defined")); proto_item_append_text(psf_item,"_%02Xh", (idx-sod_index)); if(sod_index == EPL_SOD_PDO_RX_MAPP || sod_index == EPL_SOD_PDO_TX_MAPP) { @@ -4814,7 +4815,7 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr dataoffset += 2; /* get subindex offset */ - subindex = tvb_get_guint8(tvb, dataoffset); + subindex = tvb_get_uint8(tvb, dataoffset); subobj = subobject_lookup(obj, subindex); proto_item_append_text(psf_od_tree, " SubIdx: 0x%02X", subindex); /* get subindex string */ @@ -4871,7 +4872,7 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr { if (nosub) /* no subindex */ - col_append_fstr(pinfo->cinfo, COL_INFO, ")"); + col_append_str(pinfo->cinfo, COL_INFO, ")"); else col_append_fstr(pinfo->cinfo, COL_INFO, "/%d)", subindex); } @@ -4895,7 +4896,7 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr psf_item = proto_tree_add_item(psf_od_tree, hf_epl_sdo_multi_param_sub_abort, tvb, dataoffset, 4, ENC_LITTLE_ENDIAN); proto_item_append_text(psf_item," (%s)", val_to_str_ext_const(abort_code, &sdo_cmd_abort_code_ext, "Unknown")); - is_abort = FALSE; + is_abort = false; } else { @@ -4931,7 +4932,7 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr offset += datalength; /* calculating the remaining length, based on the current offset */ - remlength = (guint32)tvb_reported_length_remaining(tvb, offset); + remlength = (uint32_t)tvb_reported_length_remaining(tvb, offset); } col_append_fstr(pinfo->cinfo, COL_INFO, " (%d)", objectcnt); @@ -4943,7 +4944,7 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr &epl_sdo_asnd_commands_short_ext, "Command(%02X)"), segment_size); - remlength = (guint32)tvb_reported_length_remaining(tvb, offset); + remlength = (uint32_t)tvb_reported_length_remaining(tvb, offset); objectcnt = 0; dataoffset = offset; @@ -4952,7 +4953,7 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr * we start the loop. */ while ( remlength > 0 ) { - guint16 sod_index = error; + uint16_t sod_index = error; proto_tree *psf_entry; /* add object subtree */ psf_od_item = proto_tree_add_subtree(epl_tree, tvb, offset, 4, 0, NULL, "OD"); @@ -4992,13 +4993,13 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr } else if(sod_index == error) { - name = val_to_str_ext_const(((guint32)(idx<<16)), &sod_index_names, "User Defined"); + name = val_to_str_ext_const(((uint32_t)(idx<<16)), &sod_index_names, "User Defined"); proto_item_append_text(psf_entry," (%s)", name); } else { /* add index string */ - proto_item_append_text(psf_entry," (%s", val_to_str_ext_const(((guint32)(sod_index<<16)), &sod_index_names, "User Defined")); + proto_item_append_text(psf_entry," (%s", val_to_str_ext_const(((uint32_t)(sod_index<<16)), &sod_index_names, "User Defined")); proto_item_append_text(psf_entry,"_%02Xh", (idx-sod_index)); if(sod_index == EPL_SOD_PDO_RX_MAPP || sod_index == EPL_SOD_PDO_TX_MAPP) { @@ -5014,7 +5015,7 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr dataoffset += 2; /* get subindex offset */ - subindex = tvb_get_guint8(tvb, dataoffset); + subindex = tvb_get_uint8(tvb, dataoffset); proto_item_append_text(psf_od_item, " SubIdx: 0x%02X", subindex); psf_item = proto_tree_add_uint_format(psf_od_item, hf_epl_asnd_sdo_cmd_data_mapping_subindex, tvb, dataoffset, 1, subindex,"SubIndex: 0x%02X", subindex); subobj = subobject_lookup(obj, subindex); @@ -5027,7 +5028,7 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr { if (nosub) /* no subindex */ - col_append_fstr(pinfo->cinfo, COL_INFO, ")"); + col_append_str(pinfo->cinfo, COL_INFO, ")"); else col_append_fstr(pinfo->cinfo, COL_INFO, "/%d)", subindex); } @@ -5041,7 +5042,7 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr offset += 4; /* calculating the remaining length, based on the current offset */ - remlength = (guint32)tvb_reported_length_remaining(tvb, offset); + remlength = (uint32_t)tvb_reported_length_remaining(tvb, offset); } col_append_fstr(pinfo->cinfo, COL_INFO, " (%d)", objectcnt); @@ -5049,16 +5050,16 @@ dissect_epl_sdo_command_read_multiple_by_index(struct epl_convo *convo, proto_tr return offset; } -static gint -dissect_epl_sdo_command_read_by_index(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint offset, guint8 segmented, gboolean response, guint16 segment_size) +static int +dissect_epl_sdo_command_read_by_index(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, int offset, uint8_t segmented, bool response, uint16_t segment_size) { - gint size, payload_length, rem_size = 0; - guint16 idx = 0x00; - guint8 subindex = 0x00; - guint32 fragmentId, frame; + int size, payload_length, rem_size = 0; + uint16_t idx = 0x00; + uint8_t subindex = 0x00; + uint32_t fragmentId, frame; proto_item *psf_item, *cmd_payload; proto_tree *payload_tree; - gboolean end_segment = FALSE; + bool end_segment = false; fragment_head *frag_msg = NULL; struct object *obj = NULL; const struct subobject *subobj = NULL; @@ -5075,12 +5076,12 @@ dissect_epl_sdo_command_read_by_index(struct epl_convo *convo, proto_tree *epl_t psf_item = proto_tree_add_item(epl_tree, hf_epl_asnd_sdo_cmd_data_index, tvb, offset, 2, ENC_LITTLE_ENDIAN); obj = object_lookup(convo->profile, idx); - name = obj ? obj->info.name : val_to_str_ext_const(((guint32)(idx<<16)), &sod_index_names, "User Defined"); + name = obj ? obj->info.name : val_to_str_ext_const(((uint32_t)(idx<<16)), &sod_index_names, "User Defined"); proto_item_append_text(psf_item," (%s)", name); offset += 2; - subindex = tvb_get_guint8(tvb, offset); + subindex = tvb_get_uint8(tvb, offset); psf_item = proto_tree_add_item(epl_tree, hf_epl_asnd_sdo_cmd_data_subindex, tvb, offset, 1, ENC_LITTLE_ENDIAN); subobj = subobject_lookup(obj, subindex); @@ -5093,7 +5094,7 @@ dissect_epl_sdo_command_read_by_index(struct epl_convo *convo, proto_tree *epl_t col_append_fstr(pinfo->cinfo, COL_INFO, "%s[%d]: (0x%04X/%d)", val_to_str_ext(EPL_ASND_SDO_COMMAND_READ_BY_INDEX, &epl_sdo_asnd_commands_short_ext, "Command(%02X)"), segment_size, idx, subindex); - col_append_fstr(pinfo->cinfo, COL_INFO, " (%s", val_to_str_ext_const(((guint32) (idx << 16)), &sod_index_names, "User Defined")); + col_append_fstr(pinfo->cinfo, COL_INFO, " (%s", val_to_str_ext_const(((uint32_t) (idx << 16)), &sod_index_names, "User Defined")); col_append_fstr(pinfo->cinfo, COL_INFO, "/%s)",val_to_str_ext_const((subindex|(idx<<16)), &sod_index_names, "User Defined")); /* Cache object for read in next response */ @@ -5117,14 +5118,14 @@ dissect_epl_sdo_command_read_by_index(struct epl_convo *convo, proto_tree *epl_t if(segmented > 0x01 && segment_size != 0) { /* get the fragmentId */ - fragmentId = (guint32)((((guint32)epl_segmentation.src)<<16)+epl_segmentation.dest); + fragmentId = (uint32_t)((((uint32_t)epl_segmentation.src)<<16)+epl_segmentation.dest); /* set the fragmented flag */ - pinfo->fragmented = TRUE; - /* get payloade size */ + pinfo->fragmented = true; + /* get payload size */ payload_length = tvb_reported_length_remaining(tvb, offset); /* if the frame is the last frame */ if(segmented == EPL_ASND_SDO_CMD_SEGMENTATION_TRANSFER_COMPLETE) - end_segment = TRUE; + end_segment = true; if(epl_asnd_sdo_reassembly_read.frame[epl_segmentation.recv][epl_segmentation.send] == 0x00 || epl_asnd_sdo_reassembly_read.frame[epl_segmentation.recv][epl_segmentation.send] == frame) @@ -5138,15 +5139,15 @@ dissect_epl_sdo_command_read_by_index(struct epl_convo *convo, proto_tree *epl_t if (first_read) { frag_msg = fragment_add_seq_check(&epl_reassembly_table, tvb, offset, pinfo, - fragmentId, NULL, 0, payload_length, end_segment ? FALSE : TRUE ); + fragmentId, NULL, 0, payload_length, end_segment ? false : true ); fragment_add_seq_offset(&epl_reassembly_table, pinfo, fragmentId, NULL, count); - first_read = FALSE; + first_read = false; } else { frag_msg = fragment_add_seq_check(&epl_reassembly_table, tvb, offset, pinfo, - fragmentId, NULL, count, payload_length, end_segment ? FALSE : TRUE ); + fragmentId, NULL, count, payload_length, end_segment ? false : true ); } } @@ -5158,14 +5159,14 @@ dissect_epl_sdo_command_read_by_index(struct epl_convo *convo, proto_tree *epl_t cmd_payload = proto_tree_add_uint_format(epl_tree, hf_epl_asnd_sdo_cmd_reassembled, tvb, offset, payload_length,0, "Reassembled: %d bytes total (%d bytes in this frame)",frag_msg->len,payload_length); payload_tree = proto_item_add_subtree(cmd_payload, ett_epl_asnd_sdo_data_reassembled); - /* add the reassembley fields */ + /* add the reassembly fields */ process_reassembled_data(tvb, 0, pinfo, "Reassembled Message", frag_msg, &epl_frag_items, NULL, payload_tree ); proto_tree_add_uint_format_value(payload_tree, hf_epl_asnd_sdo_cmd_reassembled, tvb, 0, 0, payload_length, "%d bytes (over all fragments)", frag_msg->len); if (frag_msg->reassembled_in == frame) col_append_str(pinfo->cinfo, COL_INFO, " (Message Reassembled)" ); /* reset memory */ - memset(&epl_asnd_sdo_reassembly_read.frame[epl_segmentation.recv], 0, sizeof(guint32) * EPL_MAX_SEQUENCE); + memset(&epl_asnd_sdo_reassembly_read.frame[epl_segmentation.recv], 0, sizeof(uint32_t) * EPL_MAX_SEQUENCE); } else { @@ -5296,31 +5297,31 @@ proto_register_epl(void) /* hotfields for all available EPL message types (depends on EPL MessageType) */ { &hf_epl_soc, { "SoC", "epl.soc", - FT_BOOLEAN, BASE_DEC, NULL, 0x00, NULL, HFILL } + FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } }, { &hf_epl_preq, { "PReq", "epl.preq", - FT_BOOLEAN, BASE_DEC, NULL, 0x00, NULL, HFILL } + FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } }, { &hf_epl_pres, { "PRes", "epl.pres", - FT_BOOLEAN, BASE_DEC, NULL, 0x00, NULL, HFILL } + FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } }, { &hf_epl_soa, { "SoA", "epl.soa", - FT_BOOLEAN, BASE_DEC, NULL, 0x00, NULL, HFILL } + FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } }, { &hf_epl_asnd, { "ASnd", "epl.asnd", - FT_BOOLEAN, BASE_DEC, NULL, 0x00, NULL, HFILL } + FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } }, { &hf_epl_amni, { "AMNI", "epl.amni", - FT_BOOLEAN, BASE_DEC, NULL, 0x00, NULL, HFILL } + FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } }, { &hf_epl_ainv, { "AInv", "epl.ainv", - FT_BOOLEAN, BASE_DEC, NULL, 0x00, NULL, HFILL } + FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } }, /* SoC data fields*/ @@ -5926,7 +5927,8 @@ proto_register_epl(void) }, { &hf_epl_asnd_statusresponse_el_entry_code, { "Error Code", "epl.asnd.sres.el.entry.code", - FT_UINT16, BASE_DEC, NULL, 0x00, NULL, HFILL } + FT_UINT16, BASE_HEX|BASE_EXT_STRING, + &errorcode_vals_ext, 0x00, NULL, HFILL } }, { &hf_epl_asnd_statusresponse_el_entry_time, { "Time Stamp", "epl.asnd.sres.el.entry.time", @@ -6160,20 +6162,20 @@ proto_register_epl(void) }, { &hf_epl_fragment_overlap, { "Message fragment overlap", "epl.asnd.sdo.cmd.fragment.overlap", - FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL } + FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } }, { &hf_epl_fragment_overlap_conflicts, { "Message fragment overlapping with conflicting data", "epl.asnd.sdo.cmd.fragment.overlap.conflicts", - FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL } + FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } }, { &hf_epl_fragment_multiple_tails, { "Message has multiple tail fragments", "epl.asnd.sdo.cmd.fragment.multiple_tails", - FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL } + FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } }, { &hf_epl_fragment_too_long_fragment, { "Message fragment too long", "epl.asnd.sdo.cmd.fragment.too_long_fragment", - FT_BOOLEAN, 0, NULL, 0x00, NULL, HFILL } + FT_BOOLEAN, BASE_NONE, NULL, 0x00, NULL, HFILL } }, { &hf_epl_fragment_error, { "Message defragmentation error", "epl.asnd.sdo.cmd.fragment.error", @@ -6297,7 +6299,7 @@ proto_register_epl(void) }; /* Setup protocol subtree array */ - static gint *ett[] = { + static int *ett[] = { &ett_epl, &ett_epl_soc, &ett_epl_preq, @@ -6348,8 +6350,8 @@ proto_register_epl(void) proto_epl = proto_register_protocol("Ethernet POWERLINK", "EPL", "epl"); /* subdissector code */ - heur_epl_subdissector_list = register_heur_dissector_list("epl", proto_epl); - heur_epl_data_subdissector_list = register_heur_dissector_list("epl_data", proto_epl); + heur_epl_subdissector_list = register_heur_dissector_list_with_description("epl", "Data encapsulated in EPL", proto_epl); + heur_epl_data_subdissector_list = register_heur_dissector_list_with_description("epl_data", "EPL Data", proto_epl); epl_asnd_dissector_table = register_dissector_table("epl.asnd", "Manufacturer specific ASND service", proto_epl, FT_UINT8, BASE_DEC /*, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE*/); @@ -6398,12 +6400,12 @@ proto_register_epl(void) prefs_register_filename_preference(epl_module, "default_profile", "Default Profile to use if no specific profiles exist", "If you have a capture without IdentResponse and many nodes, it's easier to set a default profile here than to add entries for all MAC address or Node IDs", - &epl_default_profile_path, FALSE); + &epl_default_profile_path, false); device_profile_uat = uat_new("Device-Specific Profiles", sizeof (struct device_profile_uat_assoc), "epl_device_profiles", /* filename */ - TRUE, /* from_profile */ + true, /* from_profile */ &device_profile_list_uats, /* data_ptr */ &ndevice_profile_uat, /* numitems_ptr */ UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */ @@ -6425,7 +6427,7 @@ proto_register_epl(void) nodeid_profile_uat = uat_new("NodeID-Specific Profiles", sizeof (struct nodeid_profile_uat_assoc), "epl_nodeid_profiles", /* filename */ - TRUE, /* from_profile */ + true, /* from_profile */ &nodeid_profile_list_uats, /* data_ptr */ &nnodeid_profile_uat, /* numitems_ptr */ UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */ @@ -6463,31 +6465,31 @@ proto_reg_handoff_epl(void) static bool -epl_uat_fld_uint16dec_check_cb(void *_record _U_, const char *str, guint len _U_, const void *chk_data _U_, const void *fld_data _U_, char **err) +epl_uat_fld_uint16dec_check_cb(void *_record _U_, const char *str, unsigned len _U_, const void *chk_data _U_, const void *fld_data _U_, char **err) { - guint16 val; + uint16_t val; if (!ws_strtou16(str, NULL, &val)) { *err = g_strdup("Invalid argument. Expected a decimal between [0-65535]"); - return FALSE; + return false; } - return TRUE; + return true; } static bool -epl_uat_fld_uint32hex_check_cb(void *_record _U_, const char *str, guint len _U_, const void *chk_data _U_, const void *fld_data _U_, char **err) +epl_uat_fld_uint32hex_check_cb(void *_record _U_, const char *str, unsigned len _U_, const void *chk_data _U_, const void *fld_data _U_, char **err) { - guint32 val; + uint32_t val; if (!ws_hexstrtou32(str, NULL, &val)) { *err = g_strdup("Invalid argument. Expected a hexadecimal between [0-ffffffff]"); - return FALSE; + return false; } - return TRUE; + return true; } static bool -epl_profile_uat_fld_fileopen_check_cb(void *record _U_, const char *path, guint len, const void *chk_data _U_, const void *fld_data _U_, char **err) +epl_profile_uat_fld_fileopen_check_cb(void *record _U_, const char *path, unsigned len, const void *chk_data _U_, const void *fld_data _U_, char **err) { const char *supported = "Only" IF_LIBXML(" *.xdd, *.xdc and") " *.eds profiles supported."; ws_statb64 st; @@ -6496,35 +6498,35 @@ epl_profile_uat_fld_fileopen_check_cb(void *record _U_, const char *path, guint if (!path || !len) { *err = g_strdup("No filename given."); - return FALSE; + return false; } if (ws_stat64(path, &st) != 0) { *err = ws_strdup_printf("File '%s' does not exist or access was denied.", path); - return FALSE; + return false; } if (g_str_has_suffix(path, ".eds")) { *err = NULL; - return TRUE; + return true; } if (g_str_has_suffix(path, ".xdd") || g_str_has_suffix(path, ".xdc")) { #ifdef HAVE_LIBXML2 *err = NULL; - return TRUE; + return true; #else *err = ws_strdup_printf("*.xdd and *.xdc support not compiled in. %s", supported); - return FALSE; + return false; #endif } *err = g_strdup(supported); - return FALSE; + return false; } @@ -6542,12 +6544,12 @@ drop_profiles(void *key _U_, void *value, void *user_data _U_) static void device_profile_parse_uat(void) { - guint i; + unsigned i; struct profile *profile = NULL; wmem_map_foreach(epl_profiles_by_device, drop_profiles, NULL); /* PDO Mappings will have stale pointers after a profile change - * so we reset the memory pool. As PDO Mappings are refereneced + * so we reset the memory pool. As PDO Mappings are referenced * via Conversations, we need to fixup those too to avoid a use * after free, preferably by clearing them. * This generation++ is a temporary workaround @@ -6605,7 +6607,7 @@ device_profile_parse_uat(void) static bool device_profile_uat_update_record(void *_record _U_, char **err _U_) { - return TRUE; + return true; } static void @@ -6632,14 +6634,14 @@ device_profile_uat_copy_cb(void *dst_, const void *src_, size_t len _U_) static void nodeid_profile_parse_uat(void) { - guint i; + unsigned i; struct profile *profile = NULL; wmem_map_foreach(epl_profiles_by_nodeid, drop_profiles, NULL); wmem_map_foreach(epl_profiles_by_address, drop_profiles, NULL); /* PDO Mappings will have stale pointers after a profile change - * so we reset the memory pool. As PDO Mappings are refereneced + * so we reset the memory pool. As PDO Mappings are referenced * via Conversations, we need to fixup those too to avoid a use * after free, preferably by clearing them. * This generation++ is a temporary workaround @@ -6689,7 +6691,7 @@ nodeid_profile_parse_uat(void) static bool nodeid_profile_uat_update_record(void *_record _U_, char **err _U_) { - return TRUE; + return true; } static void @@ -6734,23 +6736,23 @@ nodeid_profile_list_uats_nodeid_tostr_cb(void *_rec, char **out_ptr, unsigned *o } static bool -epl_uat_fld_cn_check_cb(void *record _U_, const char *str, guint len _U_, const void *u1 _U_, const void *u2 _U_, char **err) +epl_uat_fld_cn_check_cb(void *record _U_, const char *str, unsigned len _U_, const void *u1 _U_, const void *u2 _U_, char **err) { - guint8 nodeid; + uint8_t nodeid; if (ws_strtou8(str, NULL, &nodeid) && EPL_IS_CN_NODEID(nodeid)) - return TRUE; + return true; GByteArray *addr = g_byte_array_new(); - if (hex_str_to_bytes(str, addr, FALSE) && addr->len == FT_ETHER_LEN) { - g_byte_array_free(addr, TRUE); - return TRUE; + if (hex_str_to_bytes(str, addr, false) && addr->len == FT_ETHER_LEN) { + g_byte_array_free(addr, true); + return true; } - g_byte_array_free(addr, TRUE); + g_byte_array_free(addr, true); *err = g_strdup("Invalid argument. Expected either a CN ID [1-239] or a MAC address"); - return FALSE; + return false; } static void @@ -6759,10 +6761,10 @@ nodeid_profile_list_uats_nodeid_set_cb(void *_rec, const char *str, unsigned len struct nodeid_profile_uat_assoc *rec = (struct nodeid_profile_uat_assoc*)_rec; GByteArray *addr = g_byte_array_new(); - rec->is_nodeid = TRUE; - if (hex_str_to_bytes(str, addr, FALSE) && addr->len == FT_ETHER_LEN) { + rec->is_nodeid = true; + if (hex_str_to_bytes(str, addr, false) && addr->len == FT_ETHER_LEN) { alloc_address_wmem(NULL, &rec->node.addr, AT_ETHER, FT_ETHER_LEN, addr->data); - rec->is_nodeid = FALSE; + rec->is_nodeid = false; } else if (!ws_strtou8(str, NULL, &rec->node.id)) { @@ -6771,7 +6773,7 @@ nodeid_profile_list_uats_nodeid_set_cb(void *_rec, const char *str, unsigned len rec->node.id = 0; } - g_byte_array_free(addr, TRUE); + g_byte_array_free(addr, true); g_free(rec->id_str); rec->id_str = g_strndup(str, len); } |