forked from osmocom/wireshark
EPL: Fix for Write Multiple by index
Write multiple by index now correctly resolves OD names. Change-Id: I4d2aad584a47e3682716b95bdda0bc49c3a29d96 Signed-off-by: Lukas Emersberger <lukas.emersberger@gmail.com> Reviewed-on: https://code.wireshark.org/review/3223 Reviewed-by: Roland Knall <rknall@gmail.com> Reviewed-by: Lukas Emersberger <lukas.emersberger@br-automation.co.at> Reviewed-by: Evan Huus <eapache@gmail.com>
This commit is contained in:
parent
4a1bd421c4
commit
eece1c521d
|
@ -2547,17 +2547,25 @@ dissect_epl_sdo_command_write_by_index(proto_tree *epl_tree, tvbuff_t *tvb, pack
|
|||
|
||||
if (segmented <= EPL_ASND_SDO_CMD_SEGMENTATION_INITIATE_TRANSFER)
|
||||
{
|
||||
/* get index offset */
|
||||
idx = tvb_get_letohs(tvb, offset);
|
||||
/* add index item */
|
||||
psf_item = proto_tree_add_uint_format(epl_tree, hf_epl_asnd_sdo_cmd_data_index, tvb, offset, 2, idx, "OD Index: 0x%04X", idx);
|
||||
|
||||
/* info text */
|
||||
col_append_fstr(pinfo->cinfo, COL_INFO, " Req. %s", val_to_str(segmented, epl_sdo_asnd_cmd_segmentation, " User Defined (%d)"));
|
||||
/* value to string */
|
||||
index_str = rval_to_str_const(idx, sod_cmd_str, "unknown");
|
||||
/* get index string value */
|
||||
sod_index = str_to_val(index_str, sod_cmd_str_val, error);
|
||||
/* get subindex string */
|
||||
sub_index_str = val_to_str_ext_const(idx, &sod_cmd_no_sub, "unknown");
|
||||
/* get subindex string value*/
|
||||
nosub = str_to_val(sub_index_str, sod_cmd_str_no_sub,error);
|
||||
|
||||
/* string is in list */
|
||||
if(sod_index != error)
|
||||
{
|
||||
/* add ondex 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,"_%02Xh", (idx-sod_index));
|
||||
if(sod_index == EPL_SOD_PDO_RX_MAPP || sod_index == EPL_SOD_PDO_TX_MAPP)
|
||||
|
@ -2569,6 +2577,7 @@ dissect_epl_sdo_command_write_by_index(proto_tree *epl_tree, tvbuff_t *tvb, pack
|
|||
{
|
||||
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, "_%02Xh", (idx-sod_index));
|
||||
if(sod_index == EPL_SOD_PDO_RX_MAPP || sod_index == EPL_SOD_PDO_TX_MAPP)
|
||||
|
@ -2588,41 +2597,42 @@ dissect_epl_sdo_command_write_by_index(proto_tree *epl_tree, tvbuff_t *tvb, pack
|
|||
}
|
||||
|
||||
offset += 2;
|
||||
/* get subindex offset */
|
||||
subindex = tvb_get_guint8(tvb, offset);
|
||||
/* get subindex string */
|
||||
sub_str = val_to_str_ext_const(idx, &sod_cmd_sub_str, "unknown");
|
||||
/* get string value */
|
||||
sub_val = str_to_val(sub_str, sod_cmd_sub_str_val,error);
|
||||
|
||||
if(sub_val != error)
|
||||
idx = sub_val;
|
||||
|
||||
/* if the subindex is a EPL_SOD_STORE_PARAM */
|
||||
if(idx == EPL_SOD_STORE_PARAM && subindex <= 0x7F && subindex >= 0x04)
|
||||
{
|
||||
psf_item = proto_tree_add_uint_format(epl_tree, hf_epl_asnd_sdo_cmd_data_subindex, tvb, offset, 1, subindex, "OD SubIndex: 0x%02X", subindex);
|
||||
proto_item_append_text(psf_item, " (ManufacturerParam_%02Xh_U32)",subindex);
|
||||
col_append_fstr(pinfo->cinfo, COL_INFO, " | ManufacturerParam_%02Xh_U32]",subindex);
|
||||
}
|
||||
/* if the subindex is a EPL_SOD_RESTORE_PARAM */
|
||||
else if(idx == EPL_SOD_RESTORE_PARAM && subindex <= 0x7F && subindex >= 0x04)
|
||||
{
|
||||
psf_item = proto_tree_add_uint_format(epl_tree, hf_epl_asnd_sdo_cmd_data_subindex, tvb, offset, 1, subindex, "OD SubIndex: 0x%02X", subindex);
|
||||
proto_item_append_text(psf_item, " (ManufacturerParam_%02Xh_U32)",subindex);
|
||||
col_append_fstr(pinfo->cinfo, COL_INFO, " | ManufacturerParam_%02Xh_U32]",subindex);
|
||||
}
|
||||
/* no subindex */
|
||||
else if(nosub != error)
|
||||
{
|
||||
col_append_fstr(pinfo->cinfo, COL_INFO, "]");
|
||||
}
|
||||
/* if the subindex has the value 0x00 */
|
||||
else if(subindex == entries)
|
||||
{
|
||||
psf_item = proto_tree_add_uint_format(epl_tree, hf_epl_asnd_sdo_cmd_data_subindex, tvb, offset, 1, subindex, "OD SubIndex: 0x%02X", subindex);
|
||||
proto_item_append_text(psf_item, " (NumberOfEntries)");
|
||||
col_append_fstr(pinfo->cinfo, COL_INFO, " | NumberOfEntries]");
|
||||
}
|
||||
else if(sod_sub_index != entries)
|
||||
{
|
||||
psf_item = proto_tree_add_uint_format(epl_tree, hf_epl_asnd_sdo_cmd_data_subindex, tvb, offset, 1, subindex, "OD SubIndex: 0x%02X", subindex);
|
||||
proto_item_append_text(psf_item, " (%s)", val_to_str_ext_const((sod_sub_index|(idx<<16)), &sod_index_names, "User Defined"));
|
||||
col_append_fstr(pinfo->cinfo, COL_INFO, " | %s]",val_to_str_ext_const((sod_sub_index|(idx<<16)), &sod_index_names, "User Defined"));
|
||||
}
|
||||
else
|
||||
{
|
||||
psf_item = proto_tree_add_uint_format(epl_tree, hf_epl_asnd_sdo_cmd_data_subindex, tvb, offset, 1, subindex, "OD SubIndex: 0x%02X", subindex);
|
||||
|
@ -2694,6 +2704,7 @@ dissect_epl_sdo_command_write_by_index(proto_tree *epl_tree, tvbuff_t *tvb, pack
|
|||
|
||||
size = tvb_reported_length_remaining(tvb, offset);
|
||||
|
||||
/* if the index is a R/TPDO and its not a segmentation initiated transfer */
|
||||
if((idx == EPL_SOD_PDO_TX_MAPP && subindex > entries) ||(idx == EPL_SOD_PDO_RX_MAPP && subindex > entries))
|
||||
{
|
||||
psf_item = proto_tree_add_item(epl_tree, hf_epl_asnd_sdo_cmd_data_mapping, tvb, offset, 1, ENC_NA);
|
||||
|
@ -2728,10 +2739,13 @@ dissect_epl_sdo_command_write_multiple_by_index(proto_tree *epl_tree, tvbuff_t *
|
|||
{
|
||||
gint dataoffset;
|
||||
guint8 subindex = 0x00, padding = 0x00;
|
||||
guint16 idx = 0x00;
|
||||
guint16 idx = 0x00, sod_index = 0x00, nosub = 0x00 ,sod_sub_index = 0x00, error = 0xFF, entries = 0x00, sub_val = 0x00;
|
||||
guint32 size, offsetincrement, datalength, remlength;
|
||||
gboolean lastentry = FALSE;
|
||||
const gchar *index_str, *sub_str, *sub_index_str;
|
||||
proto_item *psf_item;
|
||||
proto_tree *psf_tree;
|
||||
|
||||
|
||||
/* 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.
|
||||
|
@ -2801,22 +2815,119 @@ dissect_epl_sdo_command_write_multiple_by_index(proto_tree *epl_tree, tvbuff_t *
|
|||
|
||||
if (segmented <= EPL_ASND_SDO_CMD_SEGMENTATION_INITIATE_TRANSFER)
|
||||
{
|
||||
/* get SDO index value */
|
||||
idx = tvb_get_letohs(tvb, dataoffset);
|
||||
psf_item = proto_tree_add_item(epl_tree, hf_epl_asnd_sdo_cmd_data_index, tvb, dataoffset, 2, ENC_LITTLE_ENDIAN);
|
||||
proto_item_append_text(psf_item," (%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(((guint32) (idx << 16)), &sod_index_names, "User Defined"));
|
||||
/* add index item */
|
||||
psf_item = proto_tree_add_uint_format(epl_tree, hf_epl_asnd_sdo_cmd_data_index, tvb, offset+4, 2, idx, "OD Index: 0x%04X", idx);
|
||||
/* value to string */
|
||||
index_str = rval_to_str_const(idx, sod_cmd_str, "unknown");
|
||||
/* get index string value */
|
||||
sod_index = str_to_val(index_str, sod_cmd_str_val, error);
|
||||
/* get subindex string */
|
||||
sub_index_str = val_to_str_ext_const(idx, &sod_cmd_no_sub, "unknown");
|
||||
/* get subindex string value*/
|
||||
nosub = str_to_val(sub_index_str, sod_cmd_str_no_sub,error);
|
||||
|
||||
if(sod_index != error)
|
||||
{
|
||||
/* 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,"_%02Xh", (idx-sod_index));
|
||||
if(sod_index == EPL_SOD_PDO_RX_MAPP || sod_index == EPL_SOD_PDO_TX_MAPP)
|
||||
{
|
||||
proto_item_append_text(psf_item,"_AU64)");
|
||||
sod_sub_index = 0x01;
|
||||
}
|
||||
else
|
||||
{
|
||||
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, "_%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");
|
||||
}
|
||||
else
|
||||
{
|
||||
col_append_fstr(pinfo->cinfo, COL_INFO, "_REC");
|
||||
}
|
||||
idx = sod_index;
|
||||
}
|
||||
else
|
||||
{
|
||||
proto_item_append_text(psf_item," (%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(((guint32) (idx << 16)), &sod_index_names, "User Defined"));
|
||||
}
|
||||
dataoffset += 2;
|
||||
|
||||
/* get subindex offset */
|
||||
subindex = tvb_get_guint8(tvb, dataoffset);
|
||||
psf_item = proto_tree_add_item(epl_tree, hf_epl_asnd_sdo_cmd_data_subindex, tvb, dataoffset, 1, ENC_LITTLE_ENDIAN);
|
||||
proto_item_append_text(psf_item, " (%s)", val_to_str_ext_const((subindex|(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"));
|
||||
/* get subindex string */
|
||||
sub_str = val_to_str_ext_const(idx, &sod_cmd_sub_str, "unknown");
|
||||
/* get string value */
|
||||
sub_val = str_to_val(sub_str, sod_cmd_sub_str_val,error);
|
||||
|
||||
if(sub_val != error)
|
||||
idx = sub_val;
|
||||
|
||||
/* if the subindex is a EPL_SOD_STORE_PARAM */
|
||||
if(idx == EPL_SOD_STORE_PARAM && subindex <= 0x7F && subindex >= 0x04)
|
||||
{
|
||||
psf_item = proto_tree_add_uint_format(epl_tree, hf_epl_asnd_sdo_cmd_data_subindex, tvb, dataoffset, 1, subindex, "OD SubIndex: 0x%02X", subindex);
|
||||
proto_item_append_text(psf_item, " (ManufacturerParam_%02Xh_U32)",subindex);
|
||||
col_append_fstr(pinfo->cinfo, COL_INFO, " | ManufacturerParam_%02Xh_U32]",subindex);
|
||||
}
|
||||
/* if the subindex is a EPL_SOD_RESTORE_PARAM */
|
||||
else if(idx == EPL_SOD_RESTORE_PARAM && subindex <= 0x7F && subindex >= 0x04)
|
||||
{
|
||||
psf_item = proto_tree_add_uint_format(epl_tree, hf_epl_asnd_sdo_cmd_data_subindex, tvb, dataoffset, 1, subindex, "OD SubIndex: 0x%02X", subindex);
|
||||
proto_item_append_text(psf_item, " (ManufacturerParam_%02Xh_U32)",subindex);
|
||||
col_append_fstr(pinfo->cinfo, COL_INFO, " | ManufacturerParam_%02Xh_U32]",subindex);
|
||||
}
|
||||
/* no subindex */
|
||||
else if(nosub != error)
|
||||
{
|
||||
col_append_fstr(pinfo->cinfo, COL_INFO, "]");
|
||||
}
|
||||
/* if the subindex has the value 0x00 */
|
||||
else if(subindex == entries)
|
||||
{
|
||||
psf_item = proto_tree_add_uint_format(epl_tree, hf_epl_asnd_sdo_cmd_data_subindex, tvb, dataoffset, 1, subindex, "OD SubIndex: 0x%02X", subindex);
|
||||
proto_item_append_text(psf_item, " (NumberOfEntries)");
|
||||
col_append_fstr(pinfo->cinfo, COL_INFO, " | NumberOfEntries]");
|
||||
}
|
||||
/* subindex */
|
||||
else
|
||||
{
|
||||
psf_item = proto_tree_add_uint_format(epl_tree, hf_epl_asnd_sdo_cmd_data_subindex, tvb, dataoffset, 1, subindex, "OD SubIndex: 0x%02X", subindex);
|
||||
proto_item_append_text(psf_item, " (%s)", val_to_str_ext_const((subindex|(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"));
|
||||
}
|
||||
dataoffset += 1;
|
||||
|
||||
proto_tree_add_uint(epl_tree, hf_epl_asnd_sdo_cmd_data_padding, tvb, dataoffset, 1, padding);
|
||||
dataoffset += 1;
|
||||
}
|
||||
|
||||
/* if the index is a R/TPDO and its not a segmentation initiated transfer */
|
||||
if((idx == EPL_SOD_PDO_TX_MAPP && subindex > entries) ||(idx == EPL_SOD_PDO_RX_MAPP && subindex > entries))
|
||||
{
|
||||
psf_item = proto_tree_add_item(epl_tree, hf_epl_asnd_sdo_cmd_data_mapping, tvb, dataoffset, 1, ENC_NA);
|
||||
psf_tree = proto_item_add_subtree(psf_item, ett_epl_asnd_sdo_cmd_data_mapping);
|
||||
idx = tvb_get_letohs(tvb, offset);
|
||||
proto_tree_add_uint_format(psf_tree, hf_epl_asnd_sdo_cmd_data_mapping_index, tvb, dataoffset, 2, idx,"Index: 0x%04X", idx);
|
||||
dataoffset += 2;
|
||||
idx = tvb_get_letohs(tvb, offset);
|
||||
proto_tree_add_uint_format(psf_tree, hf_epl_asnd_sdo_cmd_data_mapping_subindex, tvb, dataoffset, 2, idx,"SubIndex: 0x%02X", idx);
|
||||
dataoffset += 2;
|
||||
idx = tvb_get_letohs(tvb, offset);
|
||||
proto_tree_add_uint_format(psf_tree, hf_epl_asnd_sdo_cmd_data_mapping_offset, tvb, dataoffset, 2, idx,"Offset: 0x%04X", idx);
|
||||
dataoffset += 2;
|
||||
proto_tree_add_item(psf_tree, hf_epl_asnd_sdo_cmd_data_mapping_length, tvb, dataoffset, 2, ENC_LITTLE_ENDIAN);
|
||||
dataoffset += 2;
|
||||
}
|
||||
/* dissect the payload */
|
||||
dissect_epl_payload ( epl_tree, tvb, pinfo, dataoffset, size, EPL_ASND);
|
||||
|
||||
|
|
Loading…
Reference in New Issue