diff options
Diffstat (limited to 'epan/dissectors/packet-epl.c')
-rw-r--r-- | epan/dissectors/packet-epl.c | 778 |
1 files changed, 392 insertions, 386 deletions
diff --git a/epan/dissectors/packet-epl.c b/epan/dissectors/packet-epl.c index 6b0cbfc036..eff4a1fb54 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) @@ -67,6 +67,7 @@ #include <epan/expert.h> #include <epan/reassemble.h> #include <epan/proto_data.h> +#include <epan/strutil.h> #include <epan/uat.h> #include <wsutil/strtoi.h> #include <wsutil/file_util.h> @@ -581,10 +582,10 @@ static const value_string epl_device_profiles[] = { /* EPL Device Profiles loading */ /* User Access Table Checkers */ -static gboolean epl_profile_uat_fld_fileopen_check_cb(void *, const char *, unsigned, const void *, const void *, char **); -static gboolean epl_uat_fld_cn_check_cb(void *, const char *, unsigned, const void *, const void *, char **); -static gboolean epl_uat_fld_uint16dec_check_cb(void *, const char *, unsigned, const void *, const void *, char **); -static gboolean epl_uat_fld_uint32hex_check_cb(void *, const char *, unsigned, const void *, const void *, char **); +static bool epl_profile_uat_fld_fileopen_check_cb(void *, const char *, unsigned, const void *, const void *, char **); +static bool epl_uat_fld_cn_check_cb(void *, const char *, unsigned, const void *, const void *, char **); +static bool epl_uat_fld_uint16dec_check_cb(void *, const char *, unsigned, const void *, const void *, char **); +static bool epl_uat_fld_uint32hex_check_cb(void *, const char *, unsigned, const void *, const void *, char **); /* DeviceType:Path User Access Table */ struct device_profile_uat_assoc { @@ -601,7 +602,7 @@ static guint ndevice_profile_uat = 0; static void *device_profile_uat_copy_cb(void *, const void *, size_t); static void device_profile_uat_free_cb(void *); -static gboolean device_profile_uat_update_record(void *, char **); +static bool device_profile_uat_update_record(void *, char **); static void device_profile_parse_uat(void); UAT_DEC_CB_DEF(device_profile_list_uats, device_type, struct device_profile_uat_assoc) @@ -642,7 +643,7 @@ static void nodeid_profile_list_uats_nodeid_set_cb(void *, const char *, unsigne static void nodeid_profile_list_uats_nodeid_tostr_cb(void *, char **, unsigned *, const void*, const void*); static void *nodeid_profile_uat_copy_cb(void *, const void *, size_t); static void nodeid_profile_uat_free_cb(void *); -static gboolean nodeid_profile_uat_update_record(void *, char **); +static bool nodeid_profile_uat_update_record(void *, char **); static void nodeid_profile_parse_uat(void); UAT_FILENAME_CB_DEF(nodeid_profile_list_uats, path, struct nodeid_profile_uat_assoc) @@ -960,7 +961,8 @@ static const value_string sod_idx_names[] = { {0x10300009, "Valid_BOOL"}, {0x10500000, "NMT_RelativeLatencyDiff_AU32"}, - {0x10500000, "RelativeLatencyDiff"}, + /* TODO: same value, so effectively hidden. Is there another value? + {0x10500000, "RelativeLatencyDiff"}, */ {0x11010000, "DIA_NMTTelegrCount_REC"}, {0x11010001, "IsochrCyc_U32"}, @@ -1416,290 +1418,290 @@ static gint dissect_object_mapping(struct profile *profile, wmem_array_t *mappin static const gchar* decode_epl_address(guchar adr); /* Initialize the protocol and registered fields */ -static gint proto_epl = -1; +static gint 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 gint hf_epl_mtyp; +static gint hf_epl_node; +static gint hf_epl_dest; +static gint hf_epl_src; +static gint 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 gint hf_epl_soc; +static gint hf_epl_preq; +static gint hf_epl_pres; +static gint hf_epl_soa; +static gint hf_epl_asnd; +static gint hf_epl_amni; +static gint hf_epl_ainv; + +static gint hf_epl_soc_flags; +static gint hf_epl_soc_mc; +static gint hf_epl_soc_ps; +static gint hf_epl_soc_dna_an; +static gint hf_epl_soc_nettime; +static gint hf_epl_soc_relativetime; + +static gint hf_epl_preq_flags; +static gint hf_epl_preq_ms; +static gint hf_epl_preq_ea; +static gint hf_epl_preq_rd; +static gint hf_epl_preq_sls; +static gint hf_epl_preq_fls; +static gint hf_epl_preq_pdov; +static gint hf_epl_preq_size; + +static gint hf_epl_pres_stat_ms; +static gint hf_epl_pres_stat_cs; +static gint hf_epl_pres_flags; +static gint hf_epl_pres_ms; +static gint hf_epl_pres_en; +static gint hf_epl_pres_rd; +static gint hf_epl_pres_pr; +static gint hf_epl_pres_rs; +static gint hf_epl_pres_sls; +static gint hf_epl_pres_fls; +static gint hf_epl_pres_pdov; +static gint hf_epl_pres_size; + +static gint hf_epl_soa_stat_ms; +static gint hf_epl_soa_stat_cs; +static gint hf_epl_soa_ea; +static gint hf_epl_soa_er; +static gint hf_epl_soa_svid; +static gint hf_epl_soa_svtg; +static gint hf_epl_soa_eplv; +static gint hf_epl_soa_rrflags; +static gint hf_epl_soa_rrflags_mnred; +static gint hf_epl_soa_rrflags_cblred; +static gint hf_epl_soa_rrflags_ringred; +static gint 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 gint hf_epl_soa_sync; +static gint hf_epl_soa_mac; +static gint hf_epl_soa_pre_fst; +static gint hf_epl_soa_pre_sec; +static gint hf_epl_soa_mnd_fst; +static gint hf_epl_soa_mnd_sec; +static gint hf_epl_soa_pre_tm; +static gint hf_epl_soa_pre_set; +static gint hf_epl_soa_pre_res; +static gint hf_epl_soa_mac_end; +static gint hf_epl_soa_pre_fst_end; +static gint hf_epl_soa_pre_sec_end; +static gint hf_epl_soa_mnd_fst_end; +static gint hf_epl_soa_mnd_sec_end; +static gint hf_epl_soa_pre_tm_end; +static gint hf_epl_soa_dna_an_glb; +static gint 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 gint hf_epl_asnd_syncResponse_sync; +static gint hf_epl_asnd_syncResponse_latency; +static gint hf_epl_asnd_syncResponse_node; +static gint hf_epl_asnd_syncResponse_delay; +static gint hf_epl_asnd_syncResponse_pre_fst; +static gint hf_epl_asnd_syncResponse_pre_sec; +static gint hf_epl_asnd_syncResponse_fst_val; +static gint hf_epl_asnd_syncResponse_sec_val; +static gint hf_epl_asnd_syncResponse_mode; + +static gint hf_epl_asnd_svid; +static gint hf_epl_asnd_svtg; +/* static gint 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 gint hf_epl_asnd_identresponse_en; +static gint hf_epl_asnd_identresponse_ec; +static gint hf_epl_asnd_identresponse_pr; +static gint hf_epl_asnd_identresponse_rs; +static gint hf_epl_asnd_identresponse_sls; +static gint hf_epl_asnd_identresponse_fls; +static gint hf_epl_asnd_identresponse_stat_ms; +static gint hf_epl_asnd_identresponse_stat_cs; +static gint hf_epl_asnd_identresponse_ever; +static gint hf_epl_asnd_identresponse_feat; +static gint hf_epl_asnd_identresponse_feat_bit0; +static gint hf_epl_asnd_identresponse_feat_bit1; +static gint hf_epl_asnd_identresponse_feat_bit2; +static gint hf_epl_asnd_identresponse_feat_bit3; +static gint hf_epl_asnd_identresponse_feat_bit4; +static gint hf_epl_asnd_identresponse_feat_bit5; +static gint hf_epl_asnd_identresponse_feat_bit6; +static gint hf_epl_asnd_identresponse_feat_bit7; +static gint hf_epl_asnd_identresponse_feat_bit8; +static gint hf_epl_asnd_identresponse_feat_bit9; +static gint hf_epl_asnd_identresponse_feat_bitA; +static gint hf_epl_asnd_identresponse_feat_bitB; +static gint hf_epl_asnd_identresponse_feat_bitC; +static gint hf_epl_asnd_identresponse_feat_bitD; +static gint hf_epl_asnd_identresponse_feat_bitE; +static gint hf_epl_asnd_identresponse_feat_bitF; +static gint hf_epl_asnd_identresponse_feat_bit10; +static gint hf_epl_asnd_identresponse_feat_bit11; +static gint hf_epl_asnd_identresponse_feat_bit12; +static gint hf_epl_asnd_identresponse_feat_bit13; +static gint hf_epl_asnd_identresponse_feat_bit14; +static gint hf_epl_asnd_identresponse_feat_bit21; +static gint hf_epl_asnd_identresponse_mtu; +static gint hf_epl_asnd_identresponse_pis; +static gint hf_epl_asnd_identresponse_pos; +static gint hf_epl_asnd_identresponse_rst; +static gint hf_epl_asnd_identresponse_dt; +static gint hf_epl_asnd_identresponse_dt_add; +static gint hf_epl_asnd_identresponse_vid; +static gint hf_epl_asnd_identresponse_productcode; +static gint hf_epl_asnd_identresponse_rno; +static gint hf_epl_asnd_identresponse_sno; +static gint hf_epl_asnd_identresponse_vex1; +static gint hf_epl_asnd_identresponse_vcd; +static gint hf_epl_asnd_identresponse_vct; +static gint hf_epl_asnd_identresponse_ad; +static gint hf_epl_asnd_identresponse_at; +static gint hf_epl_asnd_identresponse_ipa; +static gint hf_epl_asnd_identresponse_snm; +static gint hf_epl_asnd_identresponse_gtw; +static gint hf_epl_asnd_identresponse_hn; +static gint 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 gint hf_epl_asnd_statusresponse_en; +static gint hf_epl_asnd_statusresponse_ec; +static gint hf_epl_asnd_statusresponse_pr; +static gint hf_epl_asnd_statusresponse_rs; +static gint hf_epl_asnd_statusresponse_sls; +static gint hf_epl_asnd_statusresponse_fls; +static gint hf_epl_asnd_statusresponse_stat_ms; +static gint hf_epl_asnd_statusresponse_stat_cs; +/* static gint 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 gint hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit0; +static gint hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit1; +static gint hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit2; +static gint hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit3; +static gint hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit4; +static gint hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit5; +static gint hf_epl_asnd_statusresponse_seb_err_errorregister_u8_bit7; +static gint 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 gint hf_epl_asnd_statusresponse_el; */ +/* static gint hf_epl_asnd_statusresponse_el_entry; */ +static gint hf_epl_asnd_statusresponse_el_entry_type; +static gint hf_epl_asnd_statusresponse_el_entry_type_profile; +static gint hf_epl_asnd_statusresponse_el_entry_type_mode; +static gint hf_epl_asnd_statusresponse_el_entry_type_bit14; +static gint hf_epl_asnd_statusresponse_el_entry_type_bit15; +static gint hf_epl_asnd_statusresponse_el_entry_code; +static gint hf_epl_asnd_statusresponse_el_entry_time; +static gint 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 gint hf_epl_asnd_nmtrequest_rcid; +static gint hf_epl_asnd_nmtrequest_rct; +static gint 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; +static gint hf_epl_asnd_nmtcommand_cid; +static gint hf_epl_asnd_nmtcommand_cdat; +static gint hf_epl_asnd_nmtcommand_resetnode_reason; +/*static gint hf_epl_asnd_nmtcommand_nmtnetparameterset_mtu;*/ +static gint hf_epl_asnd_nmtcommand_nmtnethostnameset_hn; +static gint hf_epl_asnd_nmtcommand_nmtflusharpentry_nid; +static gint hf_epl_asnd_nmtcommand_nmtpublishtime_dt; +static gint hf_epl_asnd_nmtcommand_nmtdna; +static gint hf_epl_asnd_nmtcommand_nmtdna_flags; +static gint hf_epl_asnd_nmtcommand_nmtdna_ltv; +static gint hf_epl_asnd_nmtcommand_nmtdna_hpm; +static gint hf_epl_asnd_nmtcommand_nmtdna_nnn; +static gint hf_epl_asnd_nmtcommand_nmtdna_mac; +static gint hf_epl_asnd_nmtcommand_nmtdna_cnn; +static gint hf_epl_asnd_nmtcommand_nmtdna_currmac; +static gint hf_epl_asnd_nmtcommand_nmtdna_hubenmsk; +static gint hf_epl_asnd_nmtcommand_nmtdna_currnn; +static gint hf_epl_asnd_nmtcommand_nmtdna_newnn; +static gint hf_epl_asnd_nmtcommand_nmtdna_leasetime; /*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; +static gint hf_epl_asnd_sdo_seq; +static gint hf_epl_asnd_sdo_seq_receive_sequence_number; +static gint hf_epl_asnd_sdo_seq_receive_con; +static gint hf_epl_asnd_sdo_seq_send_sequence_number; +static gint hf_epl_asnd_sdo_seq_send_con; /*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 gint hf_epl_asnd_sdo_cmd; +static gint hf_epl_asnd_sdo_cmd_transaction_id; +static gint 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 gint hf_epl_asnd_sdo_resp_in; +static gint hf_epl_asnd_sdo_no_resp; +static gint 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 gint hf_epl_asnd_sdo_cmd_abort; +static gint hf_epl_asnd_sdo_cmd_sub_abort; +static gint hf_epl_asnd_sdo_cmd_segmentation; +static gint hf_epl_asnd_sdo_cmd_command_id; +static gint hf_epl_asnd_sdo_cmd_segment_size; + +static gint hf_epl_asnd_sdo_cmd_data_size; +static gint hf_epl_asnd_sdo_cmd_data_padding; +static gint hf_epl_asnd_sdo_cmd_data_index; +static gint hf_epl_asnd_sdo_cmd_data_subindex; +static gint hf_epl_asnd_sdo_cmd_data_mapping; +static gint hf_epl_asnd_sdo_cmd_data_mapping_index; +static gint hf_epl_asnd_sdo_cmd_data_mapping_subindex; +static gint hf_epl_asnd_sdo_cmd_data_mapping_offset; +static gint hf_epl_asnd_sdo_cmd_data_mapping_length; +/*static gint hf_epl_asnd_sdo_cmd_data_response;*/ + +static gint hf_epl_asnd_sdo_cmd_reassembled; +static gint hf_epl_fragments; +static gint hf_epl_fragment; +static gint hf_epl_fragment_overlap; +static gint hf_epl_fragment_overlap_conflicts; +static gint hf_epl_fragment_multiple_tails; +static gint hf_epl_fragment_too_long_fragment; +static gint hf_epl_fragment_error; +static gint hf_epl_fragment_count; +static gint hf_epl_reassembled_in; +static gint hf_epl_reassembled_length; +static gint hf_epl_reassembled_data; +static gint hf_epl_sdo_multi_param_sub_abort; + +static gint 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 gint hf_epl_pdo; +static gint hf_epl_pdo_index; +static gint hf_epl_pdo_subindex; + +static gint hf_epl_od_meta; +static gint hf_epl_od_meta_mapping_index; +static gint hf_epl_od_meta_mapping_subindex; +static gint hf_epl_od_meta_lifetime_start; +static gint hf_epl_od_meta_lifetime_end; +static gint hf_epl_od_meta_offset; +static gint hf_epl_od_meta_length; + +static gint hf_epl_od_boolean; +static gint hf_epl_od_int; +static gint hf_epl_od_uint; +static gint hf_epl_od_real; +static gint hf_epl_od_string; +static gint hf_epl_od_octet_string; +static gint hf_epl_od_time; #if 0 -static gint hf_epl_od_time_difference = -1; -static gint hf_epl_od_domain = -1; +static gint hf_epl_od_time_difference; +static gint hf_epl_od_domain; #endif -static gint hf_epl_od_mac = -1; -static gint hf_epl_od_ipv4 = -1; +static gint hf_epl_od_mac; +static gint hf_epl_od_ipv4; #define EPL_PDO_TYPE_COUNT 8 @@ -1750,8 +1752,8 @@ static const struct epl_datatype { }; -static gint ett_epl_fragment = -1; -static gint ett_epl_fragments = -1; +static gint ett_epl_fragment; +static gint ett_epl_fragments; static const fragment_items epl_frag_items = { /* Fragment subtrees */ @@ -1776,47 +1778,48 @@ static const fragment_items epl_frag_items = { "Message fragments" }; -static gint hf_epl_asnd_sdo_cmd_abort_code = -1; +static gint 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 gint hf_epl_asnd_sdo_cmd_abort_flag; +static gint hf_epl_asnd_sdo_cmd_segmentation_flag; +static gint hf_epl_asnd_sdo_cmd_cmd_valid_test; -static gint hf_epl_asnd_sdo_actual_command_id = -1; +static gint 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 gint hf_epl_asnd_sdo_actual_segment_size; +static gint 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 gint ett_epl; +static gint ett_epl_soc; +static gint ett_epl_preq; +static gint ett_epl_pres; +static gint ett_epl_feat; +static gint ett_epl_seb; +static gint ett_epl_el; +static gint ett_epl_el_entry; +static gint ett_epl_el_entry_type; +static gint ett_epl_sdo_entry_type; +static gint ett_epl_asnd_nmt_dna; + +static gint ett_epl_sdo; +static gint ett_epl_sdo_sequence_layer; +static gint ett_epl_sdo_command_layer; +static gint ett_epl_sdo_data; +static gint ett_epl_asnd_sdo_cmd_data_mapping; +static gint ett_epl_soa_sync; +static gint ett_epl_asnd_sync; + +static gint 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; @@ -1824,7 +1827,7 @@ static gboolean use_xdc_mappings = TRUE; static gboolean interpret_untyped_as_le = TRUE; static gboolean use_sdo_mappings = TRUE; -static gint ett_epl_asnd_sdo_data_reassembled = -1; +static gint ett_epl_asnd_sdo_data_reassembled; static reassembly_table epl_reassembly_table; static GHashTable *epl_duplication_table = NULL; @@ -1855,7 +1858,7 @@ 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. @@ -1918,7 +1921,7 @@ static wmem_map_t *epl_profiles_by_device, *epl_profiles_by_nodeid, *epl_profile static struct profile *epl_default_profile; static const char *epl_default_profile_path = NULL, *epl_default_profile_path_last = NULL; -static gboolean +static bool profile_del_cb(wmem_allocator_t *pool _U_, wmem_cb_event_t event _U_, void *_profile) { struct profile *profile = (struct profile*)_profile; @@ -2219,7 +2222,7 @@ epl_get_convo(packet_info *pinfo, int opts) node_addr = &epl_placeholder_mac; if ((epan_convo = find_conversation(pinfo->num, node_addr, node_addr, - conversation_pt_to_endpoint_type(pinfo->ptype), node_port, node_port, NO_ADDR_B|NO_PORT_B))) + conversation_pt_to_conversation_type(pinfo->ptype), node_port, node_port, NO_ADDR_B|NO_PORT_B))) { /* XXX Do I need to check setup_frame != pinfo->num in order to not * create unnecessary new conversations? @@ -2236,7 +2239,7 @@ epl_get_convo(packet_info *pinfo, int opts) { new_convo_creation: epan_convo = conversation_new(pinfo->num, node_addr, node_addr, - conversation_pt_to_endpoint_type(pinfo->ptype), node_port, node_port, NO_ADDR2|NO_PORT2); + conversation_pt_to_conversation_type(pinfo->ptype), node_port, node_port, NO_ADDR2|NO_PORT2); } convo = (struct epl_convo*)conversation_get_proto_data(epan_convo, proto_epl); @@ -2501,7 +2504,7 @@ epl_set_sequence_nr(packet_info *pinfo, guint16 seqnum) static void elp_version( gchar *result, guint32 version ) { - g_snprintf( result, ITEM_LABEL_LENGTH, "%d.%d", hi_nibble(version), lo_nibble(version)); + snprintf( result, ITEM_LABEL_LENGTH, "%d.%d", hi_nibble(version), lo_nibble(version)); } /* Code to actually dissect the packets */ static int @@ -2521,12 +2524,9 @@ dissect_eplpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean udp if (tvb_reported_length(tvb) < 3) { /* Not enough data for an EPL header; don't try to interpret it */ - return FALSE; + return 0; } - /* Make entries in Protocol column and Info column on summary display */ - col_set_str(pinfo->cinfo, COL_PROTOCOL, udpencap ? "POWERLINK/UDP" : "POWERLINK"); - /* Get message type */ epl_mtyp = tvb_get_guint8(tvb, EPL_MTYP_OFFSET) & 0x7F; @@ -2536,7 +2536,15 @@ dissect_eplpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean udp * to dissect it as a normal EPL packet. */ if (dissector_try_heuristic(heur_epl_subdissector_list, tvb, pinfo, tree, &hdtbl_entry, &epl_mtyp)) - return TRUE; + return tvb_reported_length(tvb); + + if (!try_val_to_str(epl_mtyp, mtyp_vals)) { + /* Not an EPL packet */ + return 0; + } + + /* Make entries in Protocol column and Info column on summary display */ + col_set_str(pinfo->cinfo, COL_PROTOCOL, udpencap ? "POWERLINK/UDP" : "POWERLINK"); /* tap */ /* mi.epl_mtyp = epl_mtyp; @@ -2607,7 +2615,7 @@ dissect_eplpdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean udp break; default: /* no valid EPL packet */ - return FALSE; + return 0; } if (tree) @@ -2801,7 +2809,7 @@ dissect_epl_payload(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gin guint64 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%.*" G_GINT64_MODIFIER "x)", 2*type->len, val); + proto_item_append_text(item, " (0x%.*" PRIx64 ")", 2*type->len, val); } } /* If a mapping uses a type of fixed width that's not equal to @@ -2815,7 +2823,7 @@ dissect_epl_payload(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gin guint64 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%.*" G_GINT64_MODIFIER "x)", 2*payload_len, val); + proto_item_append_text(item, " (0x%.*" PRIx64 ")", 2*payload_len, val); } else { @@ -3012,7 +3020,7 @@ dissect_epl_soa(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint of offset += 1; col_append_fstr(pinfo->cinfo, COL_INFO, "(%s)->%3d", - rval_to_str(svid, soa_svid_id_vals, "Unknown"), target); + rval_to_str_const(svid, soa_svid_id_vals, "Unknown"), target); /* append info entry with flag information */ col_append_fstr(pinfo->cinfo, COL_INFO, " F:EA=%d,ER=%d ", @@ -3120,7 +3128,7 @@ dissect_epl_asnd(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo, gint o flags2 = tvb_get_guint8(tvb, offset + 1); col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ", - rval_to_str(svid, asnd_svid_id_vals, "Unknown")); + rval_to_str_const(svid, asnd_svid_id_vals, "Unknown")); /* append info entry with flag information for sres/ires frames */ if ((svid == EPL_ASND_IDENTRESPONSE) || (svid == EPL_ASND_STATUSRESPONSE)) @@ -3506,7 +3514,7 @@ dissect_epl_asnd_ires(struct epl_convo *convo, proto_tree *epl_tree, tvbuff_t *t proto_tree_add_ipv4(epl_tree , hf_epl_asnd_identresponse_gtw, tvb, offset, 4, epl_asnd_identresponse_gtw); offset += 4; - proto_tree_add_item(epl_tree, hf_epl_asnd_identresponse_hn, tvb, offset, 32, ENC_ASCII|ENC_NA); + proto_tree_add_item(epl_tree, hf_epl_asnd_identresponse_hn, tvb, offset, 32, ENC_ASCII); offset += 32; proto_tree_add_item(epl_tree, hf_epl_asnd_identresponse_vex2, tvb, offset, 48, ENC_NA); @@ -3807,13 +3815,13 @@ dissect_epl_sdo_sequence(proto_tree *epl_tree, tvbuff_t *tvb, packet_info *pinfo offset += 3; col_append_fstr(pinfo->cinfo, COL_INFO, "Seq:%02d%s,%02d%s", - seq_recv >> EPL_ASND_SDO_SEQ_MASK, val_to_str(seq_recv & EPL_ASND_SDO_SEQ_CON_MASK, epl_sdo_init_abbr_vals, "x"), - seq_send >> EPL_ASND_SDO_SEQ_MASK, val_to_str(seq_send & EPL_ASND_SDO_SEQ_CON_MASK, epl_sdo_init_abbr_vals, "x")); + seq_recv >> EPL_ASND_SDO_SEQ_MASK, val_to_str_const(seq_recv & EPL_ASND_SDO_SEQ_CON_MASK, epl_sdo_init_abbr_vals, "x"), + seq_send >> EPL_ASND_SDO_SEQ_MASK, val_to_str_const(seq_send & EPL_ASND_SDO_SEQ_CON_MASK, epl_sdo_init_abbr_vals, "x")); seq_recv &= EPL_ASND_SDO_SEQ_CON_MASK; seq_send &= EPL_ASND_SDO_SEQ_CON_MASK; - col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ", val_to_str((seq_recv << 8) | seq_send, epl_sdo_init_con_vals, "Invalid")); + col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ", val_to_str_const((seq_recv << 8) | seq_send, epl_sdo_init_con_vals, "Invalid")); return offset; } @@ -4324,9 +4332,9 @@ dissect_object_mapping(struct profile *profile, wmem_array_t *mappings, proto_tr { /* TODO One could think of a better string here? */ if (nosub) - g_snprintf(map.title, sizeof(map.title), "PDO - %04X", map.pdo.idx); + snprintf(map.title, sizeof(map.title), "PDO - %04X", map.pdo.idx); else - g_snprintf(map.title, sizeof(map.title), "PDO - %04X:%02X", map.pdo.idx, map.pdo.subindex); + snprintf(map.title, sizeof(map.title), "PDO - %04X:%02X", map.pdo.idx, map.pdo.subindex); add_object_mapping(mappings, &map); } @@ -5291,31 +5299,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*/ @@ -5605,87 +5613,87 @@ proto_register_epl(void) }, { &hf_epl_asnd_identresponse_feat_bit0, { "Isochronous", "epl.asnd.ires.features.bit0", - FT_BOOLEAN, 32, NULL, 0x0001, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00000001, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bit1, { "SDO by UDP/IP", "epl.asnd.ires.features.bit1", - FT_BOOLEAN, 32, NULL, 0x0002, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00000002, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bit2, { "SDO by ASnd", "epl.asnd.ires.features.bit2", - FT_BOOLEAN, 32, NULL, 0x0004, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00000004, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bit3, { "SDO by PDO", "epl.asnd.ires.features.bit3", - FT_BOOLEAN, 32, NULL, 0x0008, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00000008, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bit4, { "NMT Info Services", "epl.asnd.ires.features.bit4", - FT_BOOLEAN, 32, NULL, 0x0010, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00000010, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bit5, { "Ext. NMT State Commands", "epl.asnd.ires.features.bit5", - FT_BOOLEAN, 32, NULL, 0x0020, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00000020, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bit6, { "Dynamic PDO Mapping", "epl.asnd.ires.features.bit6", - FT_BOOLEAN, 32, NULL, 0x0040, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00000040, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bit7, { "NMT Service by UDP/IP", "epl.asnd.ires.features.bit7", - FT_BOOLEAN, 32, NULL, 0x0080, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00000080, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bit8, { "Configuration Manager", "epl.asnd.ires.features.bit8", - FT_BOOLEAN, 32, NULL, 0x0100, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00000100, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bit9, { "Multiplexed Access", "epl.asnd.ires.features.bit9", - FT_BOOLEAN, 32, NULL, 0x0200, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00000200, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bitA, { "NodeID setup by SW", "epl.asnd.ires.features.bitA", - FT_BOOLEAN, 32, NULL, 0x0400, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00000400, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bitB, { "MN Basic Ethernet Mode", "epl.asnd.ires.features.bitB", - FT_BOOLEAN, 32, NULL, 0x0800, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00000800, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bitC, { "Routing Type 1 Support", "epl.asnd.ires.features.bitC", - FT_BOOLEAN, 32, NULL, 0x1000, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00001000, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bitD, { "Routing Type 2 Support", "epl.asnd.ires.features.bitD", - FT_BOOLEAN, 32, NULL, 0x2000, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00002000, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bitE, { "SDO Read/Write All", "epl.asnd.ires.features.bitE", - FT_BOOLEAN, 32, NULL, 0x4000, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00004000, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bitF, { "SDO Read/Write Multiple", "epl.asnd.ires.features.bitF", - FT_BOOLEAN, 32, NULL, 0x8000, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00008000, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bit10, { "Multiple-ASend Support", "epl.asnd.ires.features.bit10", - FT_BOOLEAN, 32, NULL, 0x010000, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00010000, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bit11, { "Ring Redundancy", "epl.asnd.ires.features.bit11", - FT_BOOLEAN, 32, NULL, 0x020000, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00020000, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bit12, { "PResChaining", "epl.asnd.ires.features.bit12", - FT_BOOLEAN, 32, NULL, 0x040000, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00040000, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bit13, { "Multiple PReq/PRes", "epl.asnd.ires.features.bit13", - FT_BOOLEAN, 32, NULL, 0x080000, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00080000, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bit14, { "Dynamic Node Allocation", "epl.asnd.ires.features.bit14", - FT_BOOLEAN, 32, NULL, 0x100000, NULL, HFILL } + FT_BOOLEAN, 32, NULL, 0x00100000, NULL, HFILL } }, { &hf_epl_asnd_identresponse_feat_bit21, { "Modular Device", "epl.asnd.ires.features.bit21", @@ -5717,7 +5725,7 @@ proto_register_epl(void) }, { &hf_epl_asnd_identresponse_profile_path, { "Profile Path", "epl.asnd.ires.profilepath", - FT_STRING, STR_UNICODE, NULL, 0x00, NULL, HFILL } + FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL } }, { &hf_epl_asnd_identresponse_vid, { "VendorId", "epl.asnd.ires.vendorid", @@ -5921,7 +5929,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", @@ -6114,7 +6123,7 @@ proto_register_epl(void) }, { &hf_epl_asnd_sdo_cmd_abort_code, { "SDO Transfer Abort", "epl.asnd.sdo.cmd.abort.code", - FT_UINT8, BASE_HEX | BASE_EXT_STRING, + FT_UINT32, BASE_HEX | BASE_EXT_STRING, &sdo_cmd_abort_code_ext, 0x00, NULL, HFILL } }, { &hf_epl_asnd_sdo_cmd_data_index, @@ -6155,20 +6164,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", @@ -6202,7 +6211,7 @@ proto_register_epl(void) /* EPL Data types */ { &hf_epl_pdo, { "PDO", "epl.pdo", - FT_STRING, STR_ASCII, NULL, 0x00, NULL, HFILL } + FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL } }, { &hf_epl_pdo_index, { "Index", "epl.pdo.index", @@ -6260,7 +6269,7 @@ proto_register_epl(void) }, { &hf_epl_od_string, { "Data", "epl.od.data.string", - FT_STRING, STR_UNICODE, NULL, 0x00, NULL, HFILL } + FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL } }, { &hf_epl_od_octet_string, { "Data", "epl.od.data.bytestring", @@ -6343,13 +6352,14 @@ 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 encapsuated 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*/); /* Registering protocol to be called by another dissector */ epl_handle = register_dissector("epl", dissect_epl, proto_epl); + epl_udp_handle = register_dissector("epl.udp", dissect_epludp, proto_epl); /* Required function calls to register the header fields and subtrees used */ proto_register_field_array(proto_epl, hf, array_length(hf)); @@ -6444,8 +6454,6 @@ proto_register_epl(void) void proto_reg_handoff_epl(void) { - dissector_handle_t epl_udp_handle = create_dissector_handle(dissect_epludp, proto_epl); - dissector_add_uint("ethertype", ETHERTYPE_EPL_V2, epl_handle); dissector_add_uint_with_preference("udp.port", UDP_PORT_EPL, epl_udp_handle); apply_prefs(); @@ -6458,7 +6466,7 @@ proto_reg_handoff_epl(void) } -static gboolean +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) { guint16 val; @@ -6470,7 +6478,7 @@ epl_uat_fld_uint16dec_check_cb(void *_record _U_, const char *str, guint len _U_ return TRUE; } -static gboolean +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) { guint32 val; @@ -6482,7 +6490,7 @@ epl_uat_fld_uint32hex_check_cb(void *_record _U_, const char *str, guint len _U_ return TRUE; } -static gboolean +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) { const char *supported = "Only" IF_LIBXML(" *.xdd, *.xdc and") " *.eds profiles supported."; @@ -6497,7 +6505,7 @@ epl_profile_uat_fld_fileopen_check_cb(void *record _U_, const char *path, guint if (ws_stat64(path, &st) != 0) { - *err = g_strdup_printf("File '%s' does not exist or access was denied.", path); + *err = ws_strdup_printf("File '%s' does not exist or access was denied.", path); return FALSE; } @@ -6514,7 +6522,7 @@ epl_profile_uat_fld_fileopen_check_cb(void *record _U_, const char *path, guint *err = NULL; return TRUE; #else - *err = g_strdup_printf("*.xdd and *.xdc support not compiled in. %s", supported); + *err = ws_strdup_printf("*.xdd and *.xdc support not compiled in. %s", supported); return FALSE; #endif } @@ -6543,7 +6551,7 @@ device_profile_parse_uat(void) 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 @@ -6598,7 +6606,7 @@ device_profile_parse_uat(void) } } -static gboolean +static bool device_profile_uat_update_record(void *_record _U_, char **err _U_) { return TRUE; @@ -6635,7 +6643,7 @@ nodeid_profile_parse_uat(void) /* 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 @@ -6682,7 +6690,7 @@ nodeid_profile_parse_uat(void) } -static gboolean +static bool nodeid_profile_uat_update_record(void *_record _U_, char **err _U_) { return TRUE; @@ -6729,18 +6737,22 @@ nodeid_profile_list_uats_nodeid_tostr_cb(void *_rec, char **out_ptr, unsigned *o } } -static gboolean +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) { - unsigned int c; guint8 nodeid; if (ws_strtou8(str, NULL, &nodeid) && EPL_IS_CN_NODEID(nodeid)) return TRUE; - if (sscanf(str, "%*02x%*c%*02x%*c%*02x%*c%*02x%*c%*02x%*c%02x", &c) > 0) + 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; + } + g_byte_array_free(addr, TRUE); *err = g_strdup("Invalid argument. Expected either a CN ID [1-239] or a MAC address"); return FALSE; } @@ -6749,27 +6761,21 @@ static void nodeid_profile_list_uats_nodeid_set_cb(void *_rec, const char *str, unsigned len, const void *set_data _U_, const void *fld_data _U_) { struct nodeid_profile_uat_assoc *rec = (struct nodeid_profile_uat_assoc*)_rec; - guint8 addr[6]; + GByteArray *addr = g_byte_array_new(); - if (ws_strtou8(str, NULL, &addr[0])) - { - rec->is_nodeid = TRUE; - rec->node.id = addr[0]; + 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; } - else + else if (!ws_strtou8(str, NULL, &rec->node.id)) { - unsigned i; - const char *endptr = str; - for (i = 0; i < 6; i++) - { - ws_hexstrtou8(endptr, &endptr, &addr[i]); - endptr++; - } - - alloc_address_wmem(NULL, &rec->node.addr, AT_ETHER, 6, addr); - rec->is_nodeid = FALSE; + /* Invalid input. Set this to a bad value and let + * epl_uat_fld_cn_check_cb return an error message. */ + rec->node.id = 0; } + g_byte_array_free(addr, TRUE); g_free(rec->id_str); rec->id_str = g_strndup(str, len); } |