(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-zbee-aps.c) |
| |
| 289 | | | dissect_zbee_aps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) |
| 290 | | | { |
| 291 | | | tvbuff_t *payload_tvb = NULL; |
| 292 | | | dissector_handle_t profile_handle = NULL; |
| 293 | | | |
| 294 | | | proto_tree *aps_tree = NULL; |
| 295 | | | proto_tree *field_tree = NULL; |
| 296 | | | proto_item *proto_root = NULL; |
| 297 | | | proto_item *ti; |
| 298 | | | |
| 299 | | | zbee_aps_packet packet; |
| 300 | | | zbee_nwk_packet *nwk = pinfo->private_data; |
| 301 | | | |
| 302 | | | guint8 fcf; |
| 303 | | | guint8 offset = 0; |
| 304 | | | |
| 305 | | | |
| 306 | | | memset(&packet, 0, sizeof(zbee_aps_packet)); |
| 307 | | | |
| 308 | | | |
| 309 | | | if(tree){ |
| 310 | | | proto_root = proto_tree_add_protocol_format(tree, proto_zbee_aps, tvb, offset, tvb_length(tvb), "ZigBee Application Support Layer"); |
| 311 | | | aps_tree = proto_item_add_subtree(proto_root, ett_zbee_aps); |
| 312 | | | } |
| 313 | | | |
| 314 | | | if (check_col(pinfo->cinfo, COL_PROTOCOL)) { |
| 315 | | | col_set_str(pinfo->cinfo, COL_PROTOCOL, "ZigBee"); |
| 316 | | | } |
| 317 | | | |
| 318 | | | |
| 319 | | | fcf = tvb_get_guint8(tvb, offset); |
| 320 | | | packet.type = zbee_get_bit_field(fcf, ZBEE_APS_FCF_FRAME_TYPE); |
| 321 | | | packet.delivery = zbee_get_bit_field(fcf, ZBEE_APS_FCF_DELIVERY_MODE); |
| 322 | | | packet.indirect_mode = zbee_get_bit_field(fcf, ZBEE_APS_FCF_INDIRECT_MODE); |
| 323 | | | packet.ack_mode = zbee_get_bit_field(fcf, ZBEE_APS_FCF_ACK_MODE); |
| 324 | | | packet.security = zbee_get_bit_field(fcf, ZBEE_APS_FCF_SECURITY); |
| 325 | | | packet.ack_req = zbee_get_bit_field(fcf, ZBEE_APS_FCF_ACK_REQ); |
| 326 | | | packet. = zbee_get_bit_field(fcf, ); |
| 327 | | | |
| 328 | | | |
| 329 | | | if (tree) { |
| 330 | | | proto_item_append_text(proto_root, " %s", val_to_str(packet.type, zbee_aps_frame_types, "Unknown Type")); |
| 331 | | | } |
| 332 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 333 | | | col_clear(pinfo->cinfo, COL_INFO); |
| 334 | | | col_append_str(pinfo->cinfo, COL_INFO, val_to_str(packet.type, zbee_aps_frame_types, "Unknown Frame Type")); |
| 335 | | | } |
| 336 | | | |
| 337 | | | |
| 338 | | | if (tree) { |
| 339 | | | |
| 340 | | | ti = proto_tree_add_text(aps_tree, tvb, offset, sizeof(guint8), "Frame Control Field: %s (0x%02x)", |
| 341 | | | val_to_str(packet.type, zbee_aps_frame_types, "Unknown"), fcf); |
| 342 | | | field_tree = proto_item_add_subtree(ti, ett_zbee_aps_fcf); |
| 343 | | | |
| 344 | | | |
| 345 | | | proto_tree_add_uint(field_tree, hf_zbee_aps_fcf_frame_type, tvb, offset, sizeof(guint8), fcf & ZBEE_APS_FCF_FRAME_TYPE); |
| 346 | | | proto_tree_add_uint(field_tree, hf_zbee_aps_fcf_delivery, tvb, offset, sizeof(guint8), fcf & ZBEE_APS_FCF_DELIVERY_MODE); |
| 347 | | | |
| 348 | | | if (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) {
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-zbee.h |
| |
49 | #define ZBEE_VERSION_2007 2 /* Re: 053474r17ZB_TSC-ZigBeeSpecification.pdf */ |
| |
|
| 349 | | | |
| 350 | | | if (packet.type == ZBEE_APS_FCF_ACK) { |
| 351 | | | proto_tree_add_boolean(field_tree, hf_zbee_aps_fcf_ack_mode, tvb, offset, sizeof(guint8), fcf & ZBEE_APS_FCF_ACK_MODE); |
| 352 | | | } |
| 353 | | | } |
| 354 | | | else { |
| 355 | | | |
| 356 | | | if (packet.delivery == ZBEE_APS_FCF_INDIRECT) { |
| 357 | | | proto_tree_add_boolean(field_tree, hf_zbee_aps_fcf_indirect_mode, tvb, offset, sizeof(guint8), fcf & ZBEE_APS_FCF_INDIRECT_MODE); |
| 358 | | | } |
| 359 | | | } |
| 360 | | | |
| 361 | | | |
| 362 | | | proto_tree_add_boolean(field_tree, hf_zbee_aps_fcf_security, tvb, offset, sizeof(guint8), fcf & ZBEE_APS_FCF_SECURITY); |
| 363 | | | proto_tree_add_boolean(field_tree, hf_zbee_aps_fcf_ack_req, tvb, offset, sizeof(guint8), fcf & ZBEE_APS_FCF_ACK_REQ); |
| 364 | | | proto_tree_add_boolean(field_tree, , tvb, offset, sizeof(guint8), fcf & ); |
| 365 | | | } |
| 366 | | | offset += sizeof(guint8); |
| 367 | | | |
| 368 | | | |
| 369 | | | switch (packet.type) { |
| 370 | | | case ZBEE_APS_FCF_DATA: |
| 371 | | | |
| 372 | | | break; |
| 373 | | | |
| 374 | | | case ZBEE_APS_FCF_ACK: |
| 375 | | | if ((pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) && (packet.ack_mode)) {
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-zbee.h |
| |
49 | #define ZBEE_VERSION_2007 2 /* Re: 053474r17ZB_TSC-ZigBeeSpecification.pdf */ |
| |
|
| 376 | | | |
| 377 | | | goto dissect_zbee_aps_no_endpt; |
| 378 | | | } |
| 379 | | | break; |
| 380 | | | |
| 381 | | | default: |
| 382 | | | case ZBEE_APS_FCF_CMD: |
| 383 | | | |
| 384 | | | goto dissect_zbee_aps_no_endpt; |
| 385 | | | } |
| 386 | | | |
| 387 | | | |
| 388 | | | |
| 389 | | | |
| 390 | | | if ((packet.delivery == ZBEE_APS_FCF_UNICAST) || (packet.delivery == ZBEE_APS_FCF_BCAST)) { |
| 391 | | | |
| 392 | | | |
| 393 | | | |
| 394 | | | |
| 395 | | | packet.dst_present = TRUE; |
| 396 | | | packet.src_present = TRUE; |
| 397 | | | } |
| 398 | | | else if ((packet.delivery == ZBEE_APS_FCF_INDIRECT) && (pinfo->zbee_stack_vers <= ZBEE_VERSION_2004)) {
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-zbee.h |
| |
48 | #define ZBEE_VERSION_2004 1 /* Re: 053474r06ZB_TSC-ZigBeeSpecification.pdf */ |
| |
|
| 399 | | | |
| 400 | | | |
| 401 | | | |
| 402 | | | |
| 403 | | | |
| 404 | | | |
| 405 | | | packet.dst_present = (!packet.indirect_mode); |
| 406 | | | packet.src_present = (packet.indirect_mode); |
| 407 | | | } |
| 408 | | | else if ((packet.delivery == ZBEE_APS_FCF_GROUP) && (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007)) {
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-zbee.h |
| |
49 | #define ZBEE_VERSION_2007 2 /* Re: 053474r17ZB_TSC-ZigBeeSpecification.pdf */ |
| |
|
| 409 | | | |
| 410 | | | |
| 411 | | | |
| 412 | | | packet.dst_present = FALSE; |
| 413 | | | packet.src_present = TRUE; |
| 414 | | | } |
| 415 | | | else { |
| 416 | | | |
| 417 | | | expert_add_info_format(pinfo, proto_root, PI_MALFORMED, PI_WARN, "Invalid Delivery Mode"); |
| 418 | | | return; |
| 419 | | | |
| 420 | | | } |
| 421 | | | |
| 422 | | | |
| 423 | | | if (packet.dst_present) { |
| 424 | | | packet.dst = tvb_get_guint8(tvb, offset); |
| 425 | | | if (tree) { |
| 426 | | | proto_tree_add_uint(aps_tree, hf_zbee_aps_dst, tvb, offset, sizeof(guint8), packet.dst); |
| 427 | | | proto_item_append_text(proto_root, ", Dst Endpt: %d", packet.dst); |
| 428 | | | } |
| 429 | | | offset += sizeof(guint8); |
| 430 | | | |
| 431 | | | |
| 432 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 433 | | | col_append_fstr(pinfo->cinfo, COL_INFO, ", Dst Endpt: %d", packet.dst); |
| 434 | | | } |
| 435 | | | } |
| 436 | | | |
| 437 | | | |
| 438 | | | if (packet.delivery == ZBEE_APS_FCF_GROUP) { |
| 439 | | | packet.group = tvb_get_letohs(tvb, offset); |
| 440 | | | if (tree) { |
| 441 | | | proto_tree_add_uint(aps_tree, hf_zbee_aps_group, tvb, offset, sizeof(guint16), packet.group); |
| 442 | | | proto_item_append_text(proto_root, ", Group: 0x%04x", packet.group); |
| 443 | | | } |
| 444 | | | offset += sizeof(guint16); |
| 445 | | | |
| 446 | | | |
| 447 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 448 | | | col_append_fstr(pinfo->cinfo, COL_INFO, ", Group: 0x%04x", packet.group); |
| 449 | | | } |
| 450 | | | } |
| 451 | | | |
| 452 | | | |
| 453 | | | if (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) {
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-zbee.h |
| |
49 | #define ZBEE_VERSION_2007 2 /* Re: 053474r17ZB_TSC-ZigBeeSpecification.pdf */ |
| |
|
| 454 | | | |
| 455 | | | pinfo->zbee_cluster_id = packet.cluster = tvb_get_letohs(tvb, offset); |
| 456 | | | if (tree) { |
| 457 | | | proto_tree_add_uint(aps_tree, hf_zbee_aps_cluster, tvb, offset, sizeof(guint16), packet.cluster); |
| 458 | | | } |
| 459 | | | offset += sizeof(guint16); |
| 460 | | | } |
| 461 | | | else { |
| 462 | | | |
| 463 | | | pinfo->zbee_cluster_id = packet.cluster = tvb_get_guint8(tvb, offset); |
| 464 | | | if (tree) { |
| 465 | | | #if 0 |
| 466 | | | proto_tree_add_uint(aps_tree, hf_zbee_aps_cluster, tvb, offset, sizeof(guint8), packet.cluster); |
| 467 | | | #endif |
| 468 | | | proto_tree_add_uint_format_value(aps_tree, hf_zbee_aps_cluster, tvb, offset, sizeof(guint8), packet.cluster, "0x%02x", packet.cluster); |
| 469 | | | } |
| 470 | | | offset += sizeof(guint8); |
| 471 | | | } |
| 472 | | | |
| 473 | | | |
| 474 | | | packet.profile = tvb_get_letohs(tvb, offset); |
| 475 | | | profile_handle = dissector_get_port_handle(zbee_aps_dissector_table, packet.profile); |
| 476 | | | if (tree) { |
| 477 | | | ti = proto_tree_add_uint(aps_tree, hf_zbee_aps_profile, tvb, offset, sizeof(guint16), packet.profile); |
| 478 | | | if (profile_handle) { |
| 479 | | | int proto = dissector_handle_get_protocol_index(profile_handle); |
| 480 | | | proto_item_append_text(ti, " (%s)", proto_get_protocol_name(proto)); |
| 481 | | | } |
| 482 | | | offset += sizeof(guint16); |
| 483 | | | |
| 484 | | | |
| 485 | | | |
| 486 | | | } |
| 487 | | | |
| 488 | | | |
| 489 | | | if ((packet.delivery != ZBEE_APS_FCF_INDIRECT) || (!packet.indirect_mode)) { |
| 490 | | | packet.src = tvb_get_guint8(tvb, offset); |
| 491 | | | if (tree) { |
| 492 | | | proto_tree_add_uint(aps_tree, hf_zbee_aps_src, tvb, offset, sizeof(guint8), packet.src); |
| 493 | | | proto_item_append_text(proto_root, ", Src Endpt: %d", packet.src); |
| 494 | | | } |
| 495 | | | offset += sizeof(guint8); |
| 496 | | | |
| 497 | | | |
| 498 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 499 | | | col_append_fstr(pinfo->cinfo, COL_INFO, ", Src Endpt: %d", packet.src); |
| 500 | | | } |
| 501 | | | } |
| 502 | | | |
| 503 | | | |
| 504 | | | if (packet.type == ZBEE_APS_FCF_DATA) { |
| 505 | | | if (tree) { |
| 506 | | | proto_item_append_text(proto_root, ", Profile: 0x%04x", packet.profile); |
| 507 | | | } |
| 508 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 509 | | | col_append_fstr(pinfo->cinfo, COL_INFO, ", Profile: 0x%04x", packet.profile); |
| 510 | | | } |
| 511 | | | } |
| 512 | | | |
| 513 | | | |
| 514 | | | dissect_zbee_aps_no_endpt: |
| 515 | | | |
| 516 | | | |
| 517 | | | if (pinfo->zbee_stack_vers >= ZBEE_VERSION_2007) {
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-zbee.h |
| |
49 | #define ZBEE_VERSION_2007 2 /* Re: 053474r17ZB_TSC-ZigBeeSpecification.pdf */ |
| |
|
| 518 | | | packet.counter = tvb_get_guint8(tvb, offset); |
| 519 | | | if (tree) { |
| 520 | | | proto_tree_add_uint(aps_tree, hf_zbee_aps_counter, tvb, offset, sizeof(guint8), packet.counter); |
| 521 | | | } |
| 522 | | | offset += sizeof(guint8); |
| 523 | | | } |
| 524 | | | |
| 525 | | | |
| 526 | | | |
| 527 | | | if (packet.) { |
| 528 | | | fcf = tvb_get_guint8(tvb, offset); |
| 529 | | | packet.fragmentation = fcf & ZBEE_APS_EXT_FCF_FRAGMENT; |
| 530 | | | if (tree) { |
| 531 | | | |
| 532 | | | ti = proto_tree_add_text(aps_tree, tvb, offset, sizeof(guint8), "Extended Frame Control Field (0x%02x)", fcf); |
| 533 | | | field_tree = proto_item_add_subtree(ti, ett_zbee_aps_fcf); |
| 534 | | | |
| 535 | | | |
| 536 | | | proto_tree_add_uint(field_tree, hf_zbee_aps_fragmentation, tvb, offset, sizeof(guint8), packet.fragmentation); |
| 537 | | | } |
| 538 | | | offset += sizeof(guint8); |
| 539 | | | |
| 540 | | | |
| 541 | | | if (packet.fragmentation != ZBEE_APS_EXT_FCF_FRAGMENT_NONE) { |
| 542 | | | packet.block_number = tvb_get_guint8(tvb, offset); |
| 543 | | | if (tree) { |
| 544 | | | proto_tree_add_uint(field_tree, hf_zbee_aps_block_number, tvb, offset, sizeof(guint8), packet.block_number); |
| 545 | | | } |
| 546 | | | offset += sizeof(guint8); |
| 547 | | | } |
| 548 | | | |
| 549 | | | |
| 550 | | | |
| 551 | | | |
| 552 | | | if ((packet.fragmentation != ZBEE_APS_EXT_FCF_FRAGMENT_NONE) && (packet.type == ZBEE_APS_FCF_ACK)) { |
| 553 | | | packet.ack_bitfield = tvb_get_guint8(tvb, offset); |
| 554 | | | if (tree) { |
| 555 | | | int i, mask; |
| 556 | | | gchar tmp[16]; |
| 557 | | | for (i=0; i<8; i++) { |
| 558 | | | mask = (1<<i); |
| 559 | | | decode_bitfield_value(tmp, packet.ack_bitfield, mask, 8); |
| 560 | | | proto_tree_add_text(field_tree, tvb, offset, sizeof(guint8), "%sBlock %d: %s", |
| 561 | | | tmp, packet.block_number+i, (packet.ack_bitfield & mask)?"Acknowledged":"Not Acknowledged"); |
| 562 | | | } |
| 563 | | | } |
| 564 | | | offset += sizeof(guint8); |
| 565 | | | } |
| 566 | | | } |
| 567 | | | else { |
| 568 | | | |
| 569 | | | |
| 570 | | | |
| 571 | | | packet.fragmentation = ZBEE_APS_EXT_FCF_FRAGMENT_NONE; |
| 572 | | | } |
| 573 | | | |
| 574 | | | |
| 575 | | | if ((offset < tvb_length(tvb)) && packet.security) { |
| 576 | | | payload_tvb = dissect_zbee_secure(tvb, pinfo, aps_tree, offset, 0); |
| 577 | | | if (payload_tvb == NULL) { |
| 578 | | | |
| 579 | | | return; |
| 580 | | | } |
| 581 | | | } |
| 582 | | | |
| 583 | | | else if (offset < tvb_length(tvb)) { |
| 584 | | | payload_tvb = tvb_new_subset(tvb, offset, -1, -1); |
| 585 | | | } |
| 586 | | | |
| 587 | | | |
| 588 | | | if ((payload_tvb) && (packet.fragmentation != ZBEE_APS_EXT_FCF_FRAGMENT_NONE)) { |
| 589 | | | guint32 msg_id; |
| 590 | | | guint32 block_num; |
| 591 | | | fragment_data *frag_msg = NULL; |
| 592 | | | tvbuff_t *new_tvb; |
| 593 | | | |
| 594 | | | |
| 595 | | | pinfo->fragmented = TRUE; |
| 596 | | | |
| 597 | | | |
| 598 | | | |
| 599 | | | |
| 600 | | | |
| 601 | | | msg_id = ((nwk->src)<<8) + packet.counter; |
| 602 | | | |
| 603 | | | |
| 604 | | | |
| 605 | | | |
| 606 | | | |
| 607 | | | if (packet.fragmentation == ZBEE_APS_EXT_FCF_FRAGMENT_FIRST) { |
| 608 | | | fragment_set_tot_len(pinfo, msg_id, zbee_aps_fragment_table, packet.block_number); |
| 609 | | | block_num = 0; |
| 610 | | | } |
| 611 | | | else { |
| 612 | | | block_num = packet.block_number; |
| 613 | | | } |
| 614 | | | |
| 615 | | | |
| 616 | | | frag_msg = fragment_add_seq_check(payload_tvb, 0, pinfo, msg_id, zbee_aps_fragment_table, |
| 617 | | | zbee_aps_reassembled_table, block_num, tvb_length(payload_tvb), TRUE); |
| 618 | | | |
| 619 | | | new_tvb = process_reassembled_data(payload_tvb, 0, pinfo, "Reassembled Packet" , |
| 620 | | | frag_msg, &zbee_aps_frag_items, NULL, aps_tree); |
| 621 | | | |
| 622 | | | |
| 623 | | | if (check_col(pinfo->cinfo, COL_INFO)) { |
| 624 | | | if (frag_msg) col_append_str(pinfo->cinfo, COL_INFO, " (Message Reassembled)"); |
| 625 | | | else col_append_fstr(pinfo->cinfo, COL_INFO, " (Message fragment %u)", packet.counter); |
| 626 | | | } |
| 627 | | | |
| 628 | | | if (new_tvb) { |
| 629 | | | |
| 630 | | | payload_tvb = new_tvb; |
| 631 | | | } |
| 632 | | | else { |
| 633 | | | |
| 634 | | | call_dissector(data_handle, payload_tvb, pinfo, tree); |
| 635 | | | return; |
| 636 | | | } |
| 637 | | | } |
| 638 | | | |
| 639 | | | |
| 640 | | | switch (packet.type) { |
| 641 | | | case ZBEE_APS_FCF_DATA: |
| 642 | | | if (!payload_tvb) { |
| 643 | | | break; |
| 644 | | | } |
| 645 | | | if (pinfo->zbee_stack_vers <= ZBEE_VERSION_2004) {
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-zbee.h |
| |
48 | #define ZBEE_VERSION_2004 1 /* Re: 053474r06ZB_TSC-ZigBeeSpecification.pdf */ |
| |
|
| 646 | | | |
| 647 | | | |
| 648 | | | |
| 649 | | | |
| 650 | | | pinfo->private_data = profile_handle; |
| 651 | | | profile_handle = zbee_apf_handle; |
| 652 | | | } |
| 653 | | | else if (profile_handle == NULL) { |
| 654 | | | |
| 655 | | | break; |
| 656 | | | } |
| 657 | | | call_dissector(profile_handle, payload_tvb, pinfo, tree); |
| 658 | | | return; |
| 659 | | | |
| 660 | | | case ZBEE_APS_FCF_CMD: |
| 661 | | | if (!payload_tvb) { |
| 662 | | | |
| 663 | | | expert_add_info_format(pinfo, proto_root, PI_MALFORMED, PI_ERROR, "Missing Payload"); |
| 664 | | | THROW(BoundsError);
x /home/sate/Testcases/c/cve/wireshark-1.2.0/epan/exceptions.h |
| |
223 | #define THROW(x) \ |
224 | except_throw(XCEPT_GROUP_WIRESHARK, (x), NULL) |
| |
|
| 665 | | | return; |
Unreachable Control Flow
The highlighted code will not execute under any circumstances. |
|
| 666 | | | } |
| 667 | | | dissect_zbee_aps_cmd(payload_tvb, pinfo, aps_tree); |
| 668 | | | return; |
| 669 | | | |
| 670 | | | case ZBEE_APS_FCF_ACK: |
| 671 | | | |
| 672 | | | break; |
| 673 | | | |
| 674 | | | default: |
| 675 | | | |
| 676 | | | break; |
| 677 | | | } |
| 678 | | | |
| 679 | | | |
| 680 | | | |
| 681 | | | |
| 682 | | | if (payload_tvb) { |
| 683 | | | call_dissector(data_handle, payload_tvb, pinfo, tree); |
| 684 | | | } |
| 685 | | | } |
| |