(/home/sate/Testcases/c/cve/wireshark-1.2.0/plugins/wimax/wimax_utils.c) |
| |
| 3471 | | | guint wimax_common_tlv_encoding_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) |
| 3472 | | | { |
| 3473 | | | guint offset, value; |
| 3474 | | | guint tvb_len, tlv_len, tlv_value_offset; |
| 3475 | | | gint tlv_type; |
| 3476 | | | proto_tree *tlv_tree = NULL; |
| 3477 | | | tlv_info_t tlv_info; |
| 3478 | | | gfloat current_power; |
| 3479 | | | |
| 3480 | | | |
| 3481 | | | tvb_len = tvb_reported_length(tvb); |
| 3482 | | | |
| 3483 | | | if(!tvb_len) |
| 3484 | | | return 0; |
| 3485 | | | |
| 3486 | | | if(tvb_len < 2) |
| 3487 | | | { |
| 3488 | | | if(check_col(pinfo->cinfo, COL_INFO)) |
| 3489 | | | { |
| 3490 | | | col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Invalid Common TLV encoding"); |
| 3491 | | | } |
| 3492 | | | proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, 0, tvb_len, FALSE); |
| 3493 | | | return 0; |
| 3494 | | | } |
| 3495 | | | |
| 3496 | | | for(offset = 0; offset < tvb_len; ) |
| 3497 | | | { |
| 3498 | | | |
| 3499 | | | init_tlv_info(&tlv_info, tvb, offset); |
| 3500 | | | |
| 3501 | | | tlv_type = get_tlv_type(&tlv_info); |
| 3502 | | | |
| 3503 | | | tlv_len = get_tlv_length(&tlv_info); |
| 3504 | | | if(tlv_type == -1 || tlv_len > MAX_TLV_LEN || tlv_len < 1) |
| 3505 | | | { |
| 3506 | | | if(check_col(pinfo->cinfo, COL_INFO)) |
| 3507 | | | { |
| 3508 | | | col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, "Common TLV encoding TLV error"); |
| 3509 | | | } |
| 3510 | | | proto_tree_add_item(tree, hf_cst_invalid_tlv, tvb, offset, (tvb_len - offset), FALSE); |
| 3511 | | | break; |
| 3512 | | | } |
| 3513 | | | |
| 3514 | | | tlv_value_offset = get_tlv_value_offset(&tlv_info); |
| 3515 | | | #ifdef DEBUG |
| 3516 | | | proto_tree_add_protocol_format(tree, proto_wimax_utility_decoders, tvb, offset, (tlv_len + tlv_value_offset), "Common TLV Encoding TLV Type: %u (%u bytes, offset=%u, tvb_len=%u)", tlv_type, (tlv_len + tlv_value_offset), offset, tvb_len); |
| 3517 | | | #endif |
| 3518 | | | |
| 3519 | | | offset += tlv_value_offset; |
| 3520 | | | |
| 3521 | | | switch (tlv_type) |
| 3522 | | | { |
| 3523 | | | case VENDOR_SPECIFIC_INFO: |
| 3524 | | | |
| 3525 | | | |
| 3526 | | | tlv_tree = add_protocol_subtree(&tlv_info, ett_vendor_specific_info_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "Vendor-Specific Information (%u bytes)", tlv_len); |
| 3527 | | | |
| 3528 | | | wimax_vendor_specific_information_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree); |
| 3529 | | | break; |
| 3530 | | | case VENDOR_ID_ENCODING: |
| 3531 | | | |
| 3532 | | | |
| 3533 | | | tlv_tree = add_protocol_subtree(&tlv_info, ett_vendor_specific_info_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "Vendor ID Encoding (%u bytes)", tlv_len); |
| 3534 | | | |
| 3535 | | | proto_tree_add_item(tlv_tree, hf_common_tlv_vendor_id, tvb, offset, tlv_len, FALSE); |
| 3536 | | | break; |
| 3537 | | | case DSx_UPLINK_FLOW: |
| 3538 | | | |
| 3539 | | | |
| 3540 | | | tlv_tree = add_protocol_subtree(&tlv_info, ett_ul_service_flow_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "Uplink Service Flow Encodings (%u bytes)", tlv_len); |
| 3541 | | | |
| 3542 | | | wimax_service_flow_encodings_decoder(tvb_new_subset(tvb, offset, tlv_len, tlv_len), pinfo, tlv_tree); |
| 3543 | | | break; |
| 3544 | | | case DSx_DOWNLINK_FLOW: |
| 3545 | | | |
| 3546 | | | |
| 3547 | | | tlv_tree = add_protocol_subtree(&tlv_info, ett_dl_service_flow_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "Downlink Service Flow Encodings (%u bytes)", tlv_len); |
| 3548 | | | |
| 3549 | | | wimax_service_flow_encodings_decoder(tvb_new_subset(tvb,offset, tlv_len, tlv_len), pinfo, tlv_tree); |
| 3550 | | | break; |
| 3551 | | | case CURRENT_TX_POWER: |
| 3552 | | | tlv_tree = add_protocol_subtree(&tlv_info, ett_dl_service_flow_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "Current Transmitted Power (%u byte(s))", tlv_len); |
| 3553 | | | value = tvb_get_guint8(tvb, offset); |
| 3554 | | | current_power = (gfloat)(value - 128) / 2; |
| 3555 | | | proto_tree_add_text(tlv_tree, tvb, offset, 1, "Current Transmitted Power: %.2f dBm (Value: 0x%x)", (gdouble)current_power, value); |
| 3556 | | | break; |
| 3557 | | | case MAC_VERSION_ENCODING: |
| 3558 | | | |
| 3559 | | | |
| 3560 | | | tlv_tree = add_protocol_subtree(&tlv_info, ett_vendor_specific_info_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "MAC Version Encoding (%u byte)", tlv_len); |
| 3561 | | | |
| 3562 | | | proto_tree_add_item(tlv_tree, hf_common_tlv_mac_version, tvb, offset, tlv_len, FALSE); |
| 3563 | | | break; |
| 3564 | | | case HMAC_TUPLE: |
| 3565 | | | tlv_tree = add_protocol_subtree(&tlv_info, ett_vendor_specific_info_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "HMAC Tuple (%u byte(s))", tlv_len); |
| 3566 | | | |
| 3567 | | | wimax_hmac_tuple_decoder(tlv_tree, tvb, offset, tlv_len); |
| 3568 | | | break; |
| 3569 | | | case CMAC_TUPLE: |
| 3570 | | | tlv_tree = add_protocol_subtree(&tlv_info, ett_vendor_specific_info_decoder, tree, proto_wimax_utility_decoders, tvb, offset, tlv_len, "HMAC Tuple (%u byte(s))", tlv_len); |
| 3571 | | | |
| 3572 | | | wimax_cmac_tuple_decoder(tlv_tree, tvb, offset, tlv_len); |
| 3573 | | | break; |
| 3574 | | | default: |
| 3575 | | | |
| 3576 | | | return offset - tlv_value_offset; |
| 3577 | | | break; |
Unreachable Control Flow
The highlighted code will not execute under any circumstances. This may be because of: |
|
| 3578 | | | } |
| 3579 | | | offset += tlv_len; |
| 3580 | | | } |
| 3581 | | | return offset; |
| 3582 | | | } |
| |