Do expert "telegrams lost" only of field is > 0;

Don't call expert...() under 'if (tree)'

svn path=/trunk/; revision=43683
This commit is contained in:
Bill Meier 2012-07-12 20:08:34 +00:00
parent d5b965176a
commit 5150511879
1 changed files with 129 additions and 129 deletions

View File

@ -119,19 +119,19 @@ dissect_esio(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{ {
/* Set up structures needed to add the protocol subtree and manage it */ /* Set up structures needed to add the protocol subtree and manage it */
proto_item *ti, *et, *hi; proto_item *ti, *et;
proto_tree *esio_tree, *esio_header_tree, *esio_transfer_header_tree, proto_tree *esio_tree, *esio_header_tree, *esio_transfer_header_tree,
*esio_data_tansfer_tree, *esio_data_tree; *esio_data_tansfer_tree, *esio_data_tree;
gint i; gint i;
gint offset; gint offset;
guint8 esio_nbr_data_transfers; guint8 esio_nbr_data_transfers;
guint16 esio_telegram_type; guint16 esio_telegram_type;
guint16 esio_tlg_type; guint16 esio_tlg_type;
guint16 esio_transfer_length; guint16 esio_transfer_length;
guint32 esio_transfer_dest_id; guint32 esio_transfer_dest_id;
guint32 esio_src_id; guint32 esio_src_id;
guint32 esio_dst_id; guint32 esio_dst_id;
/* does this look like an sbus pdu? */ /* does this look like an sbus pdu? */
if (!is_esio_pdu(tvb)) { if (!is_esio_pdu(tvb)) {
@ -144,134 +144,134 @@ dissect_esio(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
esio_telegram_type = tvb_get_guint8(tvb,5); esio_telegram_type = tvb_get_guint8(tvb,5);
if (check_col(pinfo->cinfo, COL_INFO)) { if (check_col(pinfo->cinfo, COL_INFO)) {
switch (esio_telegram_type) { switch (esio_telegram_type) {
case ESIO_TRANSFER: case ESIO_TRANSFER:
esio_src_id = tvb_get_ntohl(tvb,16); esio_src_id = tvb_get_ntohl(tvb,16);
esio_nbr_data_transfers = tvb_get_guint8(tvb, 20); esio_nbr_data_transfers = tvb_get_guint8(tvb, 20);
esio_dst_id = tvb_get_ntohl(tvb,26); esio_dst_id = tvb_get_ntohl(tvb,26);
col_add_fstr( pinfo->cinfo, COL_INFO, col_add_fstr( pinfo->cinfo, COL_INFO,
"Data transfer: Src ID: %d, Dst ID(s): %d", "Data transfer: Src ID: %d, Dst ID(s): %d",
esio_src_id, esio_dst_id); esio_src_id, esio_dst_id);
if (esio_nbr_data_transfers > 1) { if (esio_nbr_data_transfers > 1) {
col_append_fstr( pinfo->cinfo, COL_INFO, col_append_fstr( pinfo->cinfo, COL_INFO,
" ..."); " ...");
} }
break; break;
case ESIO_STATUS: case ESIO_STATUS:
esio_src_id = tvb_get_ntohl(tvb,16); esio_src_id = tvb_get_ntohl(tvb,16);
col_add_fstr( pinfo->cinfo, COL_INFO, col_add_fstr( pinfo->cinfo, COL_INFO,
"Status/diag telegram: Src ID: %d", "Status/diag telegram: Src ID: %d",
esio_src_id); esio_src_id);
break; break;
default: default:
/* All other telegrams */ /* All other telegrams */
col_set_str( pinfo->cinfo, COL_INFO, col_set_str( pinfo->cinfo, COL_INFO,
"Unknown telegram"); "Unknown telegram");
break; break;
} }
} }
/* create display subtree for the protocol */ /* create display subtree for the protocol */
if (tree) { offset = 0;
offset =0; ti = proto_tree_add_item(tree, proto_esio, tvb, offset, -1, ENC_NA);
ti = proto_tree_add_item(tree, proto_esio, tvb, offset, -1, ENC_NA); esio_tree = proto_item_add_subtree(ti, ett_esio);
esio_tree = proto_item_add_subtree(ti, ett_esio);
/*Add subtree for Ether-S-I/O header*/ /*Add subtree for Ether-S-I/O header*/
et = proto_tree_add_text(esio_tree, tvb, offset, 12, "Ether-S-I/O header"); et = proto_tree_add_text(esio_tree, tvb, offset, 12, "Ether-S-I/O header");
esio_header_tree = proto_item_add_subtree(et, ett_esio_header); esio_header_tree = proto_item_add_subtree(et, ett_esio_header);
offset +=4; /*first four bytes are "ESIO"*/ offset += 4; /*first four bytes are "ESIO"*/
/* add items to the Ether-S-I/O header subtree*/ /* add items to the Ether-S-I/O header subtree*/
esio_tlg_type = tvb_get_ntohs(tvb,offset); esio_tlg_type = tvb_get_ntohs(tvb,offset);
proto_tree_add_item(esio_header_tree, proto_tree_add_item(esio_header_tree,
hf_esio_type, tvb, offset, 2, ENC_BIG_ENDIAN); hf_esio_type, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2; offset += 2;
proto_tree_add_item(esio_header_tree, proto_tree_add_item(esio_header_tree,
hf_esio_version, tvb, offset, 2, ENC_BIG_ENDIAN); hf_esio_version, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2; offset += 2;
proto_tree_add_item(esio_header_tree, proto_tree_add_item(esio_header_tree,
hf_esio_length, tvb, offset, 2, ENC_BIG_ENDIAN); hf_esio_length, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2; offset += 2;
proto_tree_add_item(esio_header_tree, proto_tree_add_item(esio_header_tree,
hf_esio_transaction_id, tvb, offset, 2, ENC_BIG_ENDIAN); hf_esio_transaction_id, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2; offset += 2;
switch (esio_tlg_type) { switch (esio_tlg_type) {
case ESIO_TRANSFER: case ESIO_TRANSFER:
/*Add subtree for Ether-S-I/O header*/ if (tree) {
et = proto_tree_add_text(esio_tree, tvb, offset, 12, "Transfer header"); /*Add subtree for Ether-S-I/O header*/
esio_transfer_header_tree = proto_item_add_subtree(et, ett_esio_transfer_header); et = proto_tree_add_text(esio_tree, tvb, offset, 12, "Transfer header");
proto_tree_add_item(esio_transfer_header_tree, esio_transfer_header_tree = proto_item_add_subtree(et, ett_esio_transfer_header);
hf_esio_tlg_id, tvb, offset, 4, ENC_BIG_ENDIAN); proto_tree_add_item(esio_transfer_header_tree,
hf_esio_tlg_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(esio_transfer_header_tree,
hf_esio_src_stn_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
esio_nbr_data_transfers = tvb_get_guint8(tvb,offset);
proto_tree_add_item(esio_transfer_header_tree,
hf_esio_data_nbr, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
proto_tree_add_item(esio_transfer_header_tree,
hf_esio_data_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
for (i=((esio_nbr_data_transfers)); i>0; i--) {
/*Add subtree(s) for Ether-S-I/O data transfers*/
esio_transfer_dest_id = tvb_get_ntohl(tvb,(offset+4));
esio_transfer_length = tvb_get_ntohs(tvb,(offset+8));
et = proto_tree_add_text(esio_tree, tvb, offset,
(esio_transfer_length + 10), "Data transfer to ID: %d ",
esio_transfer_dest_id);
esio_data_tansfer_tree = proto_item_add_subtree(et, ett_esio_transfer_data);
proto_tree_add_item(esio_data_tansfer_tree,
hf_esio_data_transfer_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4; offset += 4;
proto_tree_add_item(esio_transfer_header_tree, proto_tree_add_item(esio_data_tansfer_tree,
hf_esio_src_stn_id, tvb, offset, 4, ENC_BIG_ENDIAN); hf_esio_data_dest_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4; offset += 4;
esio_nbr_data_transfers = tvb_get_guint8(tvb,offset); proto_tree_add_item(esio_data_tansfer_tree,
proto_tree_add_item(esio_transfer_header_tree, hf_esio_data_length, tvb, offset, 2, ENC_BIG_ENDIAN);
hf_esio_data_nbr, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 2;
offset += 1; /*here comes the data*/
proto_tree_add_item(esio_transfer_header_tree, et = proto_tree_add_text(esio_data_tansfer_tree, tvb, offset,
hf_esio_data_flags, tvb, offset, 1, ENC_BIG_ENDIAN); esio_transfer_length, "Data bytes ");
offset += 1; esio_data_tree = proto_item_add_subtree(et, ett_esio_data);
for (i=((esio_nbr_data_transfers)); i>0; i--) { for (i=((esio_transfer_length)); i>0; i--) {
/*Add subtree(s) for Ether-S-I/O data transfers*/ proto_tree_add_item(esio_data_tree,
esio_transfer_dest_id = tvb_get_ntohl(tvb,(offset+4)); hf_esio_data, tvb, offset,
esio_transfer_length = tvb_get_ntohs(tvb,(offset+8)); 1, ENC_BIG_ENDIAN);
et = proto_tree_add_text(esio_tree, tvb, offset, offset += 1;
(esio_transfer_length + 10), "Data transfer to ID: %d ",
esio_transfer_dest_id);
esio_data_tansfer_tree = proto_item_add_subtree(et, ett_esio_transfer_data);
proto_tree_add_item(esio_data_tansfer_tree,
hf_esio_data_transfer_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(esio_data_tansfer_tree,
hf_esio_data_dest_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
proto_tree_add_item(esio_data_tansfer_tree,
hf_esio_data_length, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
/*here comes the data*/
et = proto_tree_add_text(esio_data_tansfer_tree, tvb, offset,
esio_transfer_length, "Data bytes ");
esio_data_tree = proto_item_add_subtree(et, ett_esio_data);
for (i=((esio_transfer_length)); i>0; i--) {
proto_tree_add_item(esio_data_tree,
hf_esio_data, tvb, offset,
1, ENC_BIG_ENDIAN);
offset += 1;
}
} }
break; }
case ESIO_STATUS: } /* if (tree) */
proto_tree_add_item(esio_tree, break;
hf_esio_sts_type, tvb, offset, 2, ENC_BIG_ENDIAN); case ESIO_STATUS: {
offset += 2; proto_item *hi = NULL;
proto_tree_add_item(esio_tree, if (tree) {
hf_esio_sts_size, tvb, offset, 2, ENC_BIG_ENDIAN); proto_tree_add_item(esio_tree,
offset += 2; hf_esio_sts_type, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(esio_tree, proto_tree_add_item(esio_tree,
hf_esio_src_stn_id, tvb, offset, 4, ENC_BIG_ENDIAN); hf_esio_sts_size, tvb, offset+2, 2, ENC_BIG_ENDIAN);
offset += 4; proto_tree_add_item(esio_tree,
proto_tree_add_item(esio_tree, hf_esio_src_stn_id, tvb, offset+4, 4, ENC_BIG_ENDIAN);
hf_esio_rio_sts, tvb, offset, proto_tree_add_item(esio_tree,
1, ENC_BIG_ENDIAN); hf_esio_rio_sts, tvb, offset+8,
offset += 1; 1, ENC_BIG_ENDIAN);
hi = proto_tree_add_item(esio_tree, hi = proto_tree_add_item(esio_tree,
hf_esio_rio_tlgs_lost, tvb, offset, hf_esio_rio_tlgs_lost, tvb, offset+9,
1, ENC_BIG_ENDIAN); 1, ENC_BIG_ENDIAN);
expert_add_info_format(pinfo, hi, PI_SEQUENCE, PI_NOTE, proto_tree_add_item(esio_tree,
"Telegram(s) lost"); hf_esio_rio_diag, tvb, offset+10,
offset += 1; 1, ENC_BIG_ENDIAN);
proto_tree_add_item(esio_tree, proto_tree_add_item(esio_tree,
hf_esio_rio_diag, tvb, offset, hf_esio_rio_flags, tvb, offset+11, 1, ENC_BIG_ENDIAN);
1, ENC_BIG_ENDIAN); } /* if (tree) */
offset += 1; if (tvb_get_guint8(tvb, offset + 9) > 0) {
proto_tree_add_item(esio_tree, expert_add_info_format(pinfo, hi, PI_SEQUENCE, PI_NOTE,
hf_esio_rio_flags, tvb, offset, 1, ENC_BIG_ENDIAN); "Telegram(s) lost");
offset += 1;
break;
default:
break;
} }
} /*end of tree*/ break;
}
default:
break;
} /* switch() */
return tvb_length(tvb); return tvb_length(tvb);
/*End of dissect_sbus*/ /*End of dissect_sbus*/
} }