use proto_tree_add_item()

Change-Id: I7642295721e886eef4682c602ad96b61bc85b3b6
Reviewed-on: https://code.wireshark.org/review/3128
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
This commit is contained in:
Martin Kaiser 2014-07-16 19:55:35 +02:00
parent ab2922b7e5
commit 450f491652
1 changed files with 122 additions and 218 deletions

View File

@ -1370,9 +1370,6 @@ static void
dissect_oampdu_event_notification(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) dissect_oampdu_event_notification(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{ {
guint8 raw_octet; guint8 raw_octet;
guint16 raw_word;
guint32 dword;
guint64 big;
guint8 event_type; guint8 event_type;
guint32 offset; guint32 offset;
@ -1384,10 +1381,8 @@ dissect_oampdu_event_notification(tvbuff_t *tvb, packet_info *pinfo, proto_tree
offset = OAMPDU_HEADER_SIZE; offset = OAMPDU_HEADER_SIZE;
/* Display the sequence number before displaying the TLVs */ /* Display the sequence number before displaying the TLVs */
raw_word = tvb_get_ntohs(tvb, offset); proto_tree_add_item(tree, hf_oampdu_event_sequence,
proto_tree_add_uint(tree, hf_oampdu_event_sequence, tvb, offset, 2, ENC_BIG_ENDIAN);
tvb, offset, 2, raw_word);
offset += OAMPDU_EVENT_SEQUENCE_SZ; offset += OAMPDU_EVENT_SEQUENCE_SZ;
while (1) while (1)
@ -1407,200 +1402,137 @@ dissect_oampdu_event_notification(tvbuff_t *tvb, packet_info *pinfo, proto_tree
switch (event_type) switch (event_type)
{ {
case OAMPDU_EVENT_TYPE_ESPE: case OAMPDU_EVENT_TYPE_ESPE:
{ event_tree = proto_item_add_subtree(event_item,
event_tree = proto_item_add_subtree(event_item, ett_oampdu_event_espe);
ett_oampdu_event_espe);
raw_octet = tvb_get_guint8(tvb, offset); proto_tree_add_item(event_tree, hf_oampdu_event_length,
proto_tree_add_uint(event_tree, hf_oampdu_event_length, tvb, offset, 1, ENC_BIG_ENDIAN);
tvb, offset, 1, raw_octet); offset += OAMPDU_EVENT_LENGTH_SZ;
offset += OAMPDU_EVENT_LENGTH_SZ; proto_tree_add_item(event_tree, hf_oampdu_event_timeStamp,
tvb, offset, 2, ENC_BIG_ENDIAN);
offset += OAMPDU_EVENT_TIMESTAMP_SZ;
raw_word = tvb_get_ntohs(tvb, offset); proto_tree_add_item(event_tree, hf_oampdu_event_espeWindow,
proto_tree_add_uint(event_tree, hf_oampdu_event_timeStamp, tvb, offset, 8, ENC_BIG_ENDIAN);
tvb, offset, 2, raw_word); offset += OAMPDU_ESPE_WINDOW_SZ;
offset += OAMPDU_EVENT_TIMESTAMP_SZ; proto_tree_add_item(event_tree, hf_oampdu_event_espeThreshold,
tvb, offset, 8, ENC_BIG_ENDIAN);
offset += OAMPDU_ESPE_THRESHOLD_SZ;
big = tvb_get_ntoh64(tvb, offset); proto_tree_add_item(event_tree, hf_oampdu_event_espeErrors,
proto_tree_add_uint64(event_tree, hf_oampdu_event_espeWindow, tvb, offset, 8, ENC_BIG_ENDIAN);
tvb, offset, 8, big); offset += OAMPDU_ESPE_ERRORS_SZ;
offset += OAMPDU_ESPE_WINDOW_SZ; proto_tree_add_item(event_tree, hf_oampdu_event_espeTotalErrors,
tvb, offset, 8, ENC_BIG_ENDIAN);
offset += OAMPDU_ESPE_ERR_TOTAL_SZ;
big = tvb_get_ntoh64(tvb, offset); proto_tree_add_item(event_tree, hf_oampdu_event_espeTotalEvents,
proto_tree_add_uint64(event_tree, hf_oampdu_event_espeThreshold, tvb, offset, 4, ENC_BIG_ENDIAN);
tvb, offset, 8, big); offset += OAMPDU_ESPE_TOTAL_SZ;
break;
offset += OAMPDU_ESPE_THRESHOLD_SZ;
big = tvb_get_ntoh64(tvb, offset);
proto_tree_add_uint64(event_tree, hf_oampdu_event_espeErrors,
tvb, offset, 8, big);
offset += OAMPDU_ESPE_ERRORS_SZ;
big = tvb_get_ntoh64(tvb, offset);
proto_tree_add_uint64(event_tree, hf_oampdu_event_espeTotalErrors,
tvb, offset, 8, big);
offset += OAMPDU_ESPE_ERR_TOTAL_SZ;
dword = tvb_get_ntohl(tvb, offset);
proto_tree_add_uint(event_tree, hf_oampdu_event_espeTotalEvents,
tvb, offset, 4, dword);
offset += OAMPDU_ESPE_TOTAL_SZ;
break;
}
case OAMPDU_EVENT_TYPE_EFE: case OAMPDU_EVENT_TYPE_EFE:
{ event_tree = proto_item_add_subtree(event_item,
event_tree = proto_item_add_subtree(event_item, ett_oampdu_event_efe);
ett_oampdu_event_efe);
raw_octet = tvb_get_guint8(tvb, offset); proto_tree_add_item(event_tree, hf_oampdu_event_length,
proto_tree_add_uint(event_tree, hf_oampdu_event_length, tvb, offset, 1, ENC_BIG_ENDIAN);
tvb, offset, 1, raw_octet); offset += OAMPDU_EVENT_LENGTH_SZ;
offset += OAMPDU_EVENT_LENGTH_SZ; proto_tree_add_item(event_tree, hf_oampdu_event_timeStamp,
tvb, offset, 2, ENC_BIG_ENDIAN);
offset += OAMPDU_EVENT_TIMESTAMP_SZ;
raw_word = tvb_get_ntohs(tvb, offset); proto_tree_add_item(event_tree, hf_oampdu_event_efeWindow,
proto_tree_add_uint(event_tree, hf_oampdu_event_timeStamp, tvb, offset, 2, ENC_BIG_ENDIAN);
tvb, offset, 2, raw_word); offset += OAMPDU_EFE_WINDOW_SZ;
offset += OAMPDU_EVENT_TIMESTAMP_SZ; proto_tree_add_item(event_tree, hf_oampdu_event_efeThreshold,
tvb, offset, 4, ENC_BIG_ENDIAN);
offset += OAMPDU_EFE_THRESHOLD_SZ;
raw_word = tvb_get_ntohs(tvb, offset); proto_tree_add_item(event_tree, hf_oampdu_event_efeErrors,
proto_tree_add_uint(event_tree, hf_oampdu_event_efeWindow, tvb, offset, 4, ENC_BIG_ENDIAN);
tvb, offset, 2, raw_word); offset += OAMPDU_EFE_ERRORS_SZ;
offset += OAMPDU_EFE_WINDOW_SZ; proto_tree_add_item(event_tree, hf_oampdu_event_efeTotalErrors,
tvb, offset, 8, ENC_BIG_ENDIAN);
offset += OAMPDU_EFE_ERR_TOTAL_SZ;
dword = tvb_get_ntohl(tvb, offset); proto_tree_add_item(event_tree, hf_oampdu_event_efeTotalEvents,
proto_tree_add_uint(event_tree, hf_oampdu_event_efeThreshold, tvb, offset, 4, ENC_BIG_ENDIAN);
tvb, offset, 4, dword); offset += OAMPDU_EFE_TOTAL_SZ;
break;
offset += OAMPDU_EFE_THRESHOLD_SZ;
dword = tvb_get_ntohl(tvb, offset);
proto_tree_add_uint(event_tree, hf_oampdu_event_efeErrors,
tvb, offset, 4, dword);
offset += OAMPDU_EFE_ERRORS_SZ;
big = tvb_get_ntoh64(tvb, offset);
proto_tree_add_uint64(event_tree, hf_oampdu_event_efeTotalErrors,
tvb, offset, 8, big);
offset += OAMPDU_EFE_ERR_TOTAL_SZ;
dword = tvb_get_ntohl(tvb, offset);
proto_tree_add_uint(event_tree, hf_oampdu_event_efeTotalEvents,
tvb, offset, 4, dword);
offset += OAMPDU_EFE_TOTAL_SZ;
break;
}
case OAMPDU_EVENT_TYPE_EFPE: case OAMPDU_EVENT_TYPE_EFPE:
{ event_tree = proto_item_add_subtree(event_item,
event_tree = proto_item_add_subtree(event_item, ett_oampdu_event_efpe);
ett_oampdu_event_efpe);
raw_octet = tvb_get_guint8(tvb, offset); proto_tree_add_item(event_tree, hf_oampdu_event_length,
proto_tree_add_uint(event_tree, hf_oampdu_event_length, tvb, offset, 1, ENC_BIG_ENDIAN);
tvb, offset, 1, raw_octet); offset += OAMPDU_EVENT_LENGTH_SZ;
offset += OAMPDU_EVENT_LENGTH_SZ; proto_tree_add_item(event_tree, hf_oampdu_event_timeStamp,
tvb, offset, 2, ENC_BIG_ENDIAN);
offset += OAMPDU_EVENT_TIMESTAMP_SZ;
raw_word = tvb_get_ntohs(tvb, offset); proto_tree_add_item(event_tree, hf_oampdu_event_efpeWindow,
proto_tree_add_uint(event_tree, hf_oampdu_event_timeStamp, tvb, offset, 4, ENC_BIG_ENDIAN);
tvb, offset, 2, raw_word); offset += OAMPDU_EFPE_WINDOW_SZ;
offset += OAMPDU_EVENT_TIMESTAMP_SZ; proto_tree_add_item(event_tree, hf_oampdu_event_efpeThreshold,
tvb, offset, 4, ENC_BIG_ENDIAN);
offset += OAMPDU_EFPE_THRESHOLD_SZ;
dword = tvb_get_ntohl(tvb, offset); proto_tree_add_item(event_tree, hf_oampdu_event_efpeErrors,
proto_tree_add_uint(event_tree, hf_oampdu_event_efpeWindow, tvb, offset, 4, ENC_BIG_ENDIAN);
tvb, offset, 4, dword); offset += OAMPDU_EFPE_ERRORS_SZ;
offset += OAMPDU_EFPE_WINDOW_SZ; proto_tree_add_item(event_tree, hf_oampdu_event_efpeTotalErrors,
tvb, offset, 8, ENC_BIG_ENDIAN);
offset += OAMPDU_EFPE_ERR_TOTAL_SZ;
dword = tvb_get_ntohl(tvb, offset); proto_tree_add_item(event_tree, hf_oampdu_event_efpeTotalEvents,
proto_tree_add_uint(event_tree, hf_oampdu_event_efpeThreshold, tvb, offset, 4, ENC_BIG_ENDIAN);
tvb, offset, 4, dword); offset += OAMPDU_EFPE_TOTAL_SZ;
break;
offset += OAMPDU_EFPE_THRESHOLD_SZ;
dword = tvb_get_ntohl(tvb, offset);
proto_tree_add_uint(event_tree, hf_oampdu_event_efpeErrors,
tvb, offset, 4, dword);
offset += OAMPDU_EFPE_ERRORS_SZ;
big = tvb_get_ntoh64(tvb, offset);
proto_tree_add_uint64(event_tree, hf_oampdu_event_efpeTotalErrors,
tvb, offset, 8, big);
offset += OAMPDU_EFPE_ERR_TOTAL_SZ;
dword = tvb_get_ntohl(tvb, offset);
proto_tree_add_uint(event_tree, hf_oampdu_event_efpeTotalEvents,
tvb, offset, 4, dword);
offset += OAMPDU_EFPE_TOTAL_SZ;
break;
}
case OAMPDU_EVENT_TYPE_EFSSE: case OAMPDU_EVENT_TYPE_EFSSE:
{ event_tree = proto_item_add_subtree(event_item,
event_tree = proto_item_add_subtree(event_item, ett_oampdu_event_efsse);
ett_oampdu_event_efsse);
raw_octet = tvb_get_guint8(tvb, offset); proto_tree_add_item(event_tree, hf_oampdu_event_length,
proto_tree_add_uint(event_tree, hf_oampdu_event_length, tvb, offset, 1, ENC_BIG_ENDIAN);
tvb, offset, 1, raw_octet); offset += OAMPDU_EVENT_LENGTH_SZ;
offset += OAMPDU_EVENT_LENGTH_SZ; proto_tree_add_item(event_tree, hf_oampdu_event_timeStamp,
tvb, offset, 2, ENC_BIG_ENDIAN);
offset += OAMPDU_EVENT_TIMESTAMP_SZ;
raw_word = tvb_get_ntohs(tvb, offset); proto_tree_add_item(event_tree, hf_oampdu_event_efsseWindow,
proto_tree_add_uint(event_tree, hf_oampdu_event_timeStamp, tvb, offset, 2, ENC_BIG_ENDIAN);
tvb, offset, 2, raw_word); offset += OAMPDU_EFSSE_WINDOW_SZ;
offset += OAMPDU_EVENT_TIMESTAMP_SZ; proto_tree_add_item(event_tree, hf_oampdu_event_efsseThreshold,
tvb, offset, 2, ENC_BIG_ENDIAN);
offset += OAMPDU_EFSSE_THRESHOLD_SZ;
raw_word = tvb_get_ntohs(tvb, offset); proto_tree_add_item(event_tree, hf_oampdu_event_efsseErrors,
proto_tree_add_uint(event_tree, hf_oampdu_event_efsseWindow, tvb, offset, 2, ENC_BIG_ENDIAN);
tvb, offset, 2, raw_word); offset += OAMPDU_EFSSE_ERRORS_SZ;
offset += OAMPDU_EFSSE_WINDOW_SZ; proto_tree_add_item(event_tree, hf_oampdu_event_efsseTotalErrors,
tvb, offset, 4, ENC_BIG_ENDIAN);
offset += OAMPDU_EFSSE_ERR_TOTAL_SZ;
dword = tvb_get_ntohs(tvb, offset); proto_tree_add_item(event_tree, hf_oampdu_event_efsseTotalEvents,
proto_tree_add_uint(event_tree, hf_oampdu_event_efsseThreshold, tvb, offset, 4, ENC_BIG_ENDIAN);
tvb, offset, 2, dword); offset += OAMPDU_EFSSE_TOTAL_SZ;
break;
offset += OAMPDU_EFSSE_THRESHOLD_SZ;
dword = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(event_tree, hf_oampdu_event_efsseErrors,
tvb, offset, 2, dword);
offset += OAMPDU_EFSSE_ERRORS_SZ;
dword = tvb_get_ntohl(tvb, offset);
proto_tree_add_uint(event_tree, hf_oampdu_event_efsseTotalErrors,
tvb, offset, 4, dword);
offset += OAMPDU_EFSSE_ERR_TOTAL_SZ;
dword = tvb_get_ntohl(tvb, offset);
proto_tree_add_uint(event_tree, hf_oampdu_event_efsseTotalEvents,
tvb, offset, 4, dword);
offset += OAMPDU_EFSSE_TOTAL_SZ;
break;
}
case OAMPDU_EVENT_TYPE_OSE: case OAMPDU_EVENT_TYPE_OSE:
{ {
event_tree = proto_item_add_subtree(event_item, event_tree = proto_item_add_subtree(event_item,
@ -1649,7 +1581,6 @@ dissect_oampdu_event_notification(tvbuff_t *tvb, packet_info *pinfo, proto_tree
static void static void
dissect_oampdu_variable_request(tvbuff_t *tvb, proto_tree *tree) dissect_oampdu_variable_request(tvbuff_t *tvb, proto_tree *tree)
{ {
guint16 raw_word;
guint8 raw_octet; guint8 raw_octet;
guint32 offset; guint32 offset;
@ -1670,33 +1601,21 @@ dissect_oampdu_variable_request(tvbuff_t *tvb, proto_tree *tree)
switch (raw_octet) switch (raw_octet)
{ {
case OAMPDU_VARS_OBJECT: case OAMPDU_VARS_OBJECT:
{ proto_tree_add_item(tree, hf_oampdu_variable_object,
raw_word = tvb_get_ntohs(tvb, offset); tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_uint(tree, hf_oampdu_variable_object, break;
tvb, offset, 2, raw_word);
break;
}
case OAMPDU_VARS_PACKAGE: case OAMPDU_VARS_PACKAGE:
{ proto_tree_add_item(tree, hf_oampdu_variable_package,
raw_word = tvb_get_ntohs(tvb, offset); tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_uint(tree, hf_oampdu_variable_package, break;
tvb, offset, 2, raw_word);
break;
}
case OAMPDU_VARS_BINDING: case OAMPDU_VARS_BINDING:
{ proto_tree_add_item(tree, hf_oampdu_variable_binding,
raw_word = tvb_get_ntohs(tvb, offset); tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_uint(tree, hf_oampdu_variable_binding, break;
tvb, offset, 2, raw_word);
break;
}
case OAMPDU_VARS_ATTRIBUTE: case OAMPDU_VARS_ATTRIBUTE:
{ proto_tree_add_item(tree, hf_oampdu_variable_attribute,
raw_word = tvb_get_ntohs(tvb, offset); tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_uint(tree, hf_oampdu_variable_attribute, break;
tvb, offset, 2, raw_word);
break;
}
default: default:
break; break;
} }
@ -1726,11 +1645,9 @@ dissect_oampdu_variable_request(tvbuff_t *tvb, proto_tree *tree)
static void static void
dissect_oampdu_variable_response(tvbuff_t *tvb, proto_tree *tree) dissect_oampdu_variable_response(tvbuff_t *tvb, proto_tree *tree)
{ {
guint16 raw_word;
guint8 branch, raw_octet; guint8 branch, raw_octet;
guint32 offset; guint32 offset;
offset = OAMPDU_HEADER_SIZE; offset = OAMPDU_HEADER_SIZE;
while (1) while (1)
@ -1747,37 +1664,24 @@ dissect_oampdu_variable_response(tvbuff_t *tvb, proto_tree *tree)
switch (branch) switch (branch)
{ {
case OAMPDU_VARS_OBJECT: case OAMPDU_VARS_OBJECT:
{ proto_tree_add_item(tree, hf_oampdu_variable_object,
raw_word = tvb_get_ntohs(tvb, offset); tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_uint(tree, hf_oampdu_variable_object, break;
tvb, offset, 2, raw_word);
break;
}
case OAMPDU_VARS_PACKAGE: case OAMPDU_VARS_PACKAGE:
{ proto_tree_add_item(tree, hf_oampdu_variable_package,
raw_word = tvb_get_ntohs(tvb, offset); tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_uint(tree, hf_oampdu_variable_package, break;
tvb, offset, 2, raw_word);
break;
}
case OAMPDU_VARS_BINDING: case OAMPDU_VARS_BINDING:
{ proto_tree_add_item(tree, hf_oampdu_variable_binding,
raw_word = tvb_get_ntohs(tvb, offset); tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_uint(tree, hf_oampdu_variable_binding, break;
tvb, offset, 2, raw_word);
break;
}
case OAMPDU_VARS_ATTRIBUTE: case OAMPDU_VARS_ATTRIBUTE:
{ proto_tree_add_item(tree, hf_oampdu_variable_attribute,
raw_word = tvb_get_ntohs(tvb, offset); tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_uint(tree, hf_oampdu_variable_attribute, break;
tvb, offset, 2, raw_word);
break;
}
default: default:
break; break;
} }
offset+=2; offset+=2;
do { do {