Text   |  XML   |  ReML   |   Visible Warnings:

Format String  at packet-wps.c:786

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

dissect_wps_tlvs

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-wps.c)expand/collapse
Show more  
 629  dissect_wps_tlvs(proto_tree *eap_tree, tvbuff_t *tvb, int offset,
 630                  gint size, packet_info* pinfo)
 631  {
 632    static const char* fmt_warn_too_long = "Value to long (max. %d)";
 633    static const char* fmt_length_warn = "Value length not %d";  
 634   
 635    guint16 tlv_len = 0;
 636    guint16 tlv_type = 0;
 637   
 638    proto_item* tlv_item = NULL; /* the root item */
 639    proto_tree* tlv_root = NULL;  
 640    proto_item* tmp_item = NULL;
 641   
 642    int hfindex = -1;
 643   
 644    while(size > 0) {
 645   
 646      /* incomplete tlv-entry case */
 647      if (size < 4) {
 648        if (tmp_item != NULL && pinfo)  
 649          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, "Packet to short");
 650        break;
 651      }
 652         
 653      tlv_item = NULL;
 654      tlv_root = NULL;
 655      tmp_item = NULL;
 656      hfindex = -1;
 657   
 658      tlv_type = tvb_get_ntohs(tvb, offset);                                    
 659      tlv_len = tvb_get_ntohs(tvb, offset+2);  
 660   
 661      /* TOP Node for each TLV-item */
 662      tlv_item = proto_tree_add_text(eap_tree, tvb, offset, tlv_len+4, "Unknown Type (0x%04x)", tlv_type);
 663      tlv_root = proto_item_add_subtree(tlv_item, ett_wps_tlv);
 664   
 665      /* analog to Tagged parameters in 802.11 */
 666      proto_tree_add_item(tlv_root, hf_eapwps_tlv_type, tvb, offset,   2, FALSE);  
 667      proto_tree_add_item(tlv_root, hf_eapwps_tlv_len,  tvb, offset+2, 2, FALSE);
 668   
 669      switch(tlv_type) {
 670      case WPS_TLV_TYPE_AP_CHANNEL:
 671        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_ap_channel, tvb, offset+4, 2, FALSE);
 672        hfindex = hf_eapwps_tlv_ap_channel;
 673   
 674        break;
 675   
 676      case WPS_TLV_TYPE_ASSOCIATION_STATE:
 677        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_association_state, tvb, offset+4, 2, FALSE);
 678        hfindex = hf_eapwps_tlv_association_state;
 679   
 680        break;
 681   
 682      case WPS_TLV_TYPE_AUTHENTICATION_TYPE:
 683        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_authentication_type, tvb, offset+4, 2, FALSE);
 684        hfindex = hf_eapwps_tlv_authentication_type;
 685   
 686        break;
 687   
 688      case WPS_TLV_TYPE_AUTHENTICATION_TYPE_FLAGS:
 689        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_authentication_type_flags, tvb, offset+4, 2, FALSE);
 690        hfindex = hf_eapwps_tlv_authentication_type_flags;
 691   
 692        proto_tree_add_item(tlv_root, hf_eapwps_tlv_authentication_type_flags_open,    tvb, offset+4, 2, FALSE);
 693        proto_tree_add_item(tlv_root, hf_eapwps_tlv_authentication_type_flags_wpapsk,  tvb, offset+4, 2, FALSE);
 694        proto_tree_add_item(tlv_root, hf_eapwps_tlv_authentication_type_flags_shared,  tvb, offset+4, 2, FALSE);
 695        proto_tree_add_item(tlv_root, hf_eapwps_tlv_authentication_type_flags_wpa,     tvb, offset+4, 2, FALSE);
 696        proto_tree_add_item(tlv_root, hf_eapwps_tlv_authentication_type_flags_wpa2,    tvb, offset+4, 2, FALSE);
 697        proto_tree_add_item(tlv_root, hf_eapwps_tlv_authentication_type_flags_wpa2psk, tvb, offset+4, 2, FALSE);
 698   
 699        break;
 700   
 701      case WPS_TLV_TYPE_AUTHENTICATOR:
 702        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_authenticator, tvb, offset+4, 8, FALSE);
 703        hfindex = hf_eapwps_tlv_authenticator;
 704   
 705        proto_item_append_text(tmp_item, " (1st 64 bits of HMAC)");
 706        break;
 707   
 708      case WPS_TLV_TYPE_CONFIG_METHODS:
 709        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_config_methods, tvb, offset+4, 2, FALSE);
 710        hfindex = hf_eapwps_tlv_config_methods;
 711   
 712        proto_tree_add_item(tlv_root, hf_eapwps_tlv_config_methods_usba,       tvb, offset+4, 2, FALSE);
 713        proto_tree_add_item(tlv_root, hf_eapwps_tlv_config_methods_ethernet,   tvb, offset+4, 2, FALSE);
 714        proto_tree_add_item(tlv_root, hf_eapwps_tlv_config_methods_label,      tvb, offset+4, 2, FALSE);
 715        proto_tree_add_item(tlv_root, hf_eapwps_tlv_config_methods_display,    tvb, offset+4, 2, FALSE);
 716        proto_tree_add_item(tlv_root, hf_eapwps_tlv_config_methods_nfcext,     tvb, offset+4, 2, FALSE);
 717        proto_tree_add_item(tlv_root, hf_eapwps_tlv_config_methods_nfcint,     tvb, offset+4, 2, FALSE);
 718        proto_tree_add_item(tlv_root, hf_eapwps_tlv_config_methods_nfcinf,     tvb, offset+4, 2, FALSE);
 719        proto_tree_add_item(tlv_root, hf_eapwps_tlv_config_methods_pushbutton, tvb, offset+4, 2, FALSE);
 720        proto_tree_add_item(tlv_root, hf_eapwps_tlv_config_methods_keypad,     tvb, offset+4, 2, FALSE);
 721   
 722        break;
 723   
 724      case WPS_TLV_TYPE_CONFIGURATION_ERROR:
 725        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_configuration_error, tvb, offset+4, 2, FALSE);
 726        hfindex = hf_eapwps_tlv_configuration_error;
 727   
 728        break;
 729   
 730      case WPS_TLV_TYPE_CONFIRMATION_URL4: /* max len is 64 */
 731        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_confirmation_url4, tvb, offset+4, tlv_len, FALSE);
 732        hfindex = hf_eapwps_tlv_confirmation_url4;
 733        if (tlv_len > 64 && pinfo)  
 734          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 735   
 736        break;
 737   
 738      case WPS_TLV_TYPE_CONFIRMATION_URL6: /* max len is 76 */
 739        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_confirmation_url6, tvb, offset+4, tlv_len, FALSE);
 740        hfindex = hf_eapwps_tlv_confirmation_url6;
 741        if (tlv_len > 76 && pinfo)  
 742          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 743   
 744        break;
 745   
 746      case WPS_TLV_TYPE_CONNECTION_TYPE:
 747        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_connection_type, tvb, offset+4, 1, FALSE);
 748        hfindex = hf_eapwps_tlv_connection_type;
 749   
 750        break;
 751   
 752      case WPS_TLV_TYPE_CONNECTION_TYPE_FLAGS:
 753        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_connection_type_flags, tvb, offset+4, 1, FALSE);
 754        hfindex = hf_eapwps_tlv_connection_type_flags;
 755   
 756        proto_tree_add_item(tlv_root, hf_eapwps_tlv_connection_type_flags_ess,  tvb, offset+4, 1, FALSE);
 757        proto_tree_add_item(tlv_root, hf_eapwps_tlv_connection_type_flags_ibss, tvb, offset+4, 1, FALSE);
 758   
 759        break;
 760   
 761      case WPS_TLV_TYPE_CREDENTIAL:
 762        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_credential, tvb, offset+4, tlv_len, FALSE);
 763        hfindex = hf_eapwps_tlv_credential;
 764   
 765        break;
 766   
 767      case WPS_TLV_TYPE_DEVICE_NAME: /* len <= 32, check !  */
 768        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_device_name, tvb, offset+4, tlv_len, FALSE);
 769        hfindex = hf_eapwps_tlv_device_name;
 770        if (tlv_len > 32 && pinfo)  
 771          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 772   
 773        break;
 774   
 775      case WPS_TLV_TYPE_DEVICE_PASSWORD_ID:
 776        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_device_password_id, tvb, offset+4, 2, FALSE);
 777        hfindex = hf_eapwps_tlv_device_password_id;
 778   
 779        break;
 780   
 781      case WPS_TLV_TYPE_E_HASH1:
 782        /* assert tlv_len == 32  */
 783        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_e_hash1, tvb, offset+4, 32, FALSE);
 784        hfindex = hf_eapwps_tlv_e_hash1;
 785        if (tlv_len != 32 && pinfo)  
 786          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_length_warn, 32);
 787   
 788        break;
 789   
 790      case WPS_TLV_TYPE_E_HASH2:
 791        /* assert tlv_len == 32  */
 792        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_e_hash2, tvb, offset+4, 32, FALSE);
 793        hfindex = hf_eapwps_tlv_e_hash2;
 794        if (tlv_len != 32 && pinfo)  
 795          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_length_warn, 32);
 796   
 797        break;
 798   
 799      case WPS_TLV_TYPE_E_SNONCE1:
 800        /* assert tlv_len == 16  */
 801        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_e_snonce1, tvb, offset+4, 16, FALSE);
 802        hfindex = hf_eapwps_tlv_e_snonce1;
 803        if (tlv_len != 16 && pinfo)  
 804          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_length_warn, 16);
 805   
 806        break;
 807   
 808      case WPS_TLV_TYPE_E_SNONCE2:
 809        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_e_snonce2, tvb, offset+4, 16, FALSE);
 810        hfindex = hf_eapwps_tlv_e_snonce2;
 811        if (tlv_len != 16 && pinfo)  
 812          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_length_warn, 16);
 813   
 814        break;
 815   
 816      case WPS_TLV_TYPE_ENCRYPTED_SETTINGS:
 817        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_encrypted_settings, tvb, offset+4, tlv_len, FALSE);
 818        hfindex = hf_eapwps_tlv_encrypted_settings;
 819   
 820        break;
 821   
 822      case WPS_TLV_TYPE_ENCRYPTION_TYPE:
 823        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_encryption_type, tvb, offset+4, 2, FALSE);
 824        hfindex = hf_eapwps_tlv_encryption_type;
 825   
 826        break;
 827   
 828      case WPS_TLV_TYPE_ENCRYPTION_TYPE_FLAGS:
 829        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_encryption_type_flags, tvb, offset+4, 2, FALSE);
 830        hfindex = hf_eapwps_tlv_encryption_type_flags;
 831   
 832        proto_tree_add_item(tlv_root, hf_eapwps_tlv_encryption_type_flags_none,    tvb, offset+4, 2, FALSE);
 833        proto_tree_add_item(tlv_root, hf_eapwps_tlv_encryption_type_flags_wep,     tvb, offset+4, 2, FALSE);
 834        proto_tree_add_item(tlv_root, hf_eapwps_tlv_encryption_type_flags_tkip,    tvb, offset+4, 2, FALSE);
 835        proto_tree_add_item(tlv_root, hf_eapwps_tlv_encryption_type_flags_aes,     tvb, offset+4, 2, FALSE);
 836   
 837        break;
 838   
 839      case WPS_TLV_TYPE_ENROLLEE_NONCE:
 840        /* assert tlv_len == 16  */
 841        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_enrollee_nonce, tvb, offset+4, 16, FALSE);
 842        hfindex = hf_eapwps_tlv_enrollee_nonce;
 843        if (tlv_len != 16 && pinfo)  
 844          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_length_warn, 16);
 845   
 846        break;
 847   
 848      case WPS_TLV_TYPE_FEATURE_ID:
 849        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_feature_id, tvb, offset+4, 4, FALSE);
 850        hfindex = hf_eapwps_tlv_feature_id;
 851   
 852        break;
 853   
 854      case WPS_TLV_TYPE_IDENTITY:
 855        /* check that tlv_len <= 80  */
 856        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_identity, tvb, offset+4, tlv_len, FALSE);
 857        hfindex = hf_eapwps_tlv_identity;
 858        if (tlv_len > 80 && pinfo)  
 859          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 860   
 861        break;
 862   
 863      case WPS_TLV_TYPE_IDENTITY_PROOF:
 864        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_identity_proof, tvb, offset+4, tlv_len, FALSE);
 865        hfindex = hf_eapwps_tlv_identity_proof;
 866   
 867        break;
 868   
 869      case WPS_TLV_TYPE_KEY_WRAP_AUTHENTICATOR:
 870        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_key_wrap_authenticator, tvb, offset+4, 8, FALSE);
 871        hfindex = hf_eapwps_tlv_key_wrap_authenticator;
 872   
 873        break;
 874   
 875      case WPS_TLV_TYPE_KEY_IDENTIFIER:
 876        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_key_identifier, tvb, offset+4, 16, FALSE);
 877        hfindex = hf_eapwps_tlv_key_identifier;
 878   
 879        break;
 880   
 881      case WPS_TLV_TYPE_MAC_ADDRESS:
 882        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_mac_address, tvb, offset+4, 6, FALSE);
 883        hfindex = hf_eapwps_tlv_mac_address;
 884   
 885        break;
 886   
 887      case WPS_TLV_TYPE_MANUFACTURER:
 888        /* check tlv_len <= 64 byte  */
 889        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_manufacturer, tvb, offset+4, tlv_len, FALSE);
 890        hfindex = hf_eapwps_tlv_manufacturer;
 891        if (tlv_len > 64 && pinfo)  
 892          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 893   
 894        break;
 895   
 896      case WPS_TLV_TYPE_MESSAGE_TYPE:
 897        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_message_type, tvb, offset+4, 1, FALSE);
 898        hfindex = hf_eapwps_tlv_message_type;
 899        if (pinfo != NULL && check_col(pinfo->cinfo, COL_INFO))
 900          col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", val_to_str(tvb_get_guint8(tvb, offset+4),
 901                                                                     eapwps_tlv_message_type_vals,
 902                                                                     "Unknown (0x%02x)"));
 903        break;
 904   
 905      case WPS_TLV_TYPE_MODEL_NAME:
 906        /* check tlv_len <= 32 byte  */
 907        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_model_name, tvb, offset+4, tlv_len, FALSE);
 908        hfindex = hf_eapwps_tlv_model_name;
 909        if (tlv_len > 32 && pinfo)  
 910          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 911   
 912        break;
 913   
 914      case WPS_TLV_TYPE_MODEL_NUMBER:
 915        /* check tlv_len <= 32 byte  */
 916        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_model_number, tvb, offset+4, tlv_len, FALSE);
 917        hfindex = hf_eapwps_tlv_model_number;
 918        if (tlv_len > 32 && pinfo)  
 919          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 920   
 921        break;
 922   
 923      case WPS_TLV_TYPE_NETWORK_INDEX:
 924        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_network_index, tvb, offset+4, 1, FALSE);
 925        hfindex = hf_eapwps_tlv_network_index;
 926   
 927        break;
 928   
 929      case WPS_TLV_TYPE_NETWORK_KEY:
 930        /* check tlv_len <= 64 byte  */
 931        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_network_key, tvb, offset+4, tlv_len, FALSE);
 932        hfindex = hf_eapwps_tlv_network_key;
 933        if (tlv_len > 64 && pinfo)  
 934          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 935   
 936        break;
 937   
 938      case WPS_TLV_TYPE_NETWORK_KEY_INDEX:
 939        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_network_key_index, tvb, offset+4, 1, FALSE);
 940        hfindex = hf_eapwps_tlv_network_key_index;
 941   
 942        break;
 943   
 944      case WPS_TLV_TYPE_NEW_DEVICE_NAME:
 945        /* check tlv_len <= 32 byte  */
 946        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_new_device_name, tvb, offset+4, tlv_len, FALSE);
 947        hfindex = hf_eapwps_tlv_new_device_name;
 948        if (tlv_len > 32 && pinfo)  
 949          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 950   
 951        break;
 952   
 953      case WPS_TLV_TYPE_NEW_PASSWORD:
 954        /* check tlv_len <= 64 byte  */
 955        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_new_password, tvb, offset+4, tlv_len, FALSE);
 956        hfindex = hf_eapwps_tlv_new_password;
 957        if (tlv_len > 64 && pinfo)  
 958          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 959   
 960        break;
 961   
 962      case WPS_TLV_TYPE_OOB_DEVICE_PASSWORD:
 963        /* check tlv_len <= 56 byte  */
 964        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_oob_device_password, tvb, offset+4, tlv_len, FALSE);
 965        hfindex = hf_eapwps_tlv_oob_device_password;
 966        if (tlv_len > 56 && pinfo)  
 967          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 968   
 969        break;
 970   
 971      case WPS_TLV_TYPE_OS_VERSION:
 972        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_os_version, tvb, offset+4, 4, FALSE);
 973        hfindex = hf_eapwps_tlv_os_version;
 974   
 975        break;
 976   
 977      case WPS_TLV_TYPE_POWER_LEVEL:
 978        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_power_level, tvb, offset+4, 1, FALSE);
 979        hfindex = hf_eapwps_tlv_power_level;
 980   
 981        break;
 982   
 983      case WPS_TLV_TYPE_PSK_CURRENT:
 984        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_psk_current, tvb, offset+4, 1, FALSE);
 985        hfindex = hf_eapwps_tlv_psk_current;
 986   
 987        break;
 988   
 989      case WPS_TLV_TYPE_PSK_MAX:
 990        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_psk_max, tvb, offset+4, 1, FALSE);
 991        hfindex = hf_eapwps_tlv_psk_max;
 992   
 993        break;
 994   
 995      case WPS_TLV_TYPE_PUBLIC_KEY:
 996        /* check tlv_len == 192 byte  */
 997        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_public_key, tvb, offset+4, 192, FALSE);
 998        hfindex = hf_eapwps_tlv_public_key;
 999        if (tlv_len != 192 && pinfo)  
 1000          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_length_warn, 192);
 1001   
 1002        break;
 1003   
 1004      case WPS_TLV_TYPE_RADIO_ENABLED:
 1005        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_radio_enabled, tvb, offset+4, 2, FALSE);
 1006        hfindex = hf_eapwps_tlv_radio_enabled;
 1007   
 1008        break;
 1009   
 1010      case WPS_TLV_TYPE_REBOOT:
 1011        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_reboot, tvb, offset+4, 2, FALSE);
 1012        hfindex = hf_eapwps_tlv_reboot;
 1013   
 1014        break;
 1015   
 1016      case WPS_TLV_TYPE_REGISTRAR_CURRENT:
 1017        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_registrar_current, tvb, offset+4, 1, FALSE);
 1018        hfindex = hf_eapwps_tlv_registrar_current;
 1019   
 1020        break;
 1021   
 1022      case WPS_TLV_TYPE_REGISTRAR_ESTABLISHED:
 1023        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_registrar_established, tvb, offset+4, 2, FALSE);
 1024        hfindex = hf_eapwps_tlv_registrar_established;
 1025   
 1026        break;
 1027   
 1028      case WPS_TLV_TYPE_REGISTRAR_LIST:
 1029        /* NYI: list is */
 1030        /* - 16 bytes uuid */
 1031        /* - NULL-Terminated device name string  */
 1032        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_registrar_list, tvb, offset+4, tlv_len, FALSE);
 1033        hfindex = hf_eapwps_tlv_registrar_list;
 1034   
 1035        break;
 1036   
 1037      case WPS_TLV_TYPE_REGISTRAR_MAX:
 1038        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_registrar_max, tvb, offset+4, 1, FALSE);
 1039        hfindex = hf_eapwps_tlv_registrar_max;
 1040   
 1041        break;
 1042   
 1043      case WPS_TLV_TYPE_REGISTRAR_NONCE:
 1044        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_registrar_nonce, tvb, offset+4, 16, FALSE);
 1045        hfindex = hf_eapwps_tlv_registrar_nonce;
 1046   
 1047        break;
 1048   
 1049      case WPS_TLV_TYPE_REQUEST_TYPE:
 1050        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_request_type, tvb, offset+4, 1, FALSE);
 1051        hfindex = hf_eapwps_tlv_request_type;
 1052   
 1053        break;
 1054   
 1055      case WPS_TLV_TYPE_RESPONSE_TYPE:
 1056        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_response_type, tvb, offset+4, 1, FALSE);
 1057        hfindex = hf_eapwps_tlv_response_type;
 1058   
 1059        break;
 1060   
 1061      case WPS_TLV_TYPE_RF_BANDS:
 1062        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_rf_bands, tvb, offset+4, 1, FALSE);
 1063        hfindex = hf_eapwps_tlv_rf_bands;
 1064   
 1065        break;
 1066   
 1067      case WPS_TLV_TYPE_R_HASH1:
 1068        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_r_hash1, tvb, offset+4, 32, FALSE);
 1069        hfindex = hf_eapwps_tlv_r_hash1;
 1070   
 1071        break;
 1072   
 1073      case WPS_TLV_TYPE_R_HASH2:
 1074        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_r_hash2, tvb, offset+4, 32, FALSE);
 1075        hfindex = hf_eapwps_tlv_r_hash2;
 1076   
 1077        break;
 1078   
 1079      case WPS_TLV_TYPE_R_SNONCE1:
 1080        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_r_snonce1, tvb, offset+4, 16, FALSE);
 1081        hfindex = hf_eapwps_tlv_r_snonce1;
 1082   
 1083        break;
 1084   
 1085      case WPS_TLV_TYPE_R_SNONCE2:
 1086        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_r_snonce2, tvb, offset+4, 16, FALSE);
 1087        hfindex = hf_eapwps_tlv_r_snonce2;
 1088   
 1089        break;
 1090   
 1091      case WPS_TLV_TYPE_SELECTED_REGISTRAR:
 1092        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_selected_registrar, tvb, offset+4, 1, FALSE);
 1093        hfindex = hf_eapwps_tlv_selected_registrar;
 1094   
 1095        break;
 1096   
 1097      case WPS_TLV_TYPE_SERIAL_NUMBER:
 1098        /* check tlv_len <= 32 bytes  */
 1099        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_serial_number, tvb, offset+4, tlv_len, FALSE);
 1100        hfindex = hf_eapwps_tlv_serial_number;
 1101        if (tlv_len > 32 && pinfo)  
 1102          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 1103   
 1104        break;
 1105   
 1106      case WPS_TLV_TYPE_WIFI_PROTECTED_SETUP_STATE:
 1107        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_wifi_protected_setup_state, tvb, offset+4, 1, FALSE);
 1108        hfindex = hf_eapwps_tlv_wifi_protected_setup_state;
 1109   
 1110        break;
 1111   
 1112      case WPS_TLV_TYPE_SSID:
 1113        /* check tlv_len <= 32 bytes  */
 1114        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_ssid, tvb, offset+4, tlv_len, FALSE);
 1115        hfindex = hf_eapwps_tlv_ssid;
 1116        if (tlv_len > 32 && pinfo)  
 1117          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 1118   
 1119        break;
 1120   
 1121      case WPS_TLV_TYPE_TOTAL_NETWORKS:
 1122        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_total_networks, tvb, offset+4, 1, FALSE);
 1123        hfindex = hf_eapwps_tlv_total_networks;
 1124   
 1125        break;
 1126   
 1127      case WPS_TLV_TYPE_UUID_E:
 1128        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_uuid_e, tvb, offset+4, tlv_len, FALSE);
 1129        hfindex = hf_eapwps_tlv_uuid_e;
 1130        if (tlv_len > 16 && pinfo)  
 1131          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 1132   
 1133        break;
 1134   
 1135      case WPS_TLV_TYPE_UUID_R:
 1136        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_uuid_r, tvb, offset+4, tlv_len, FALSE);
 1137        hfindex = hf_eapwps_tlv_uuid_r;
 1138        if (tlv_len > 16 && pinfo)  
 1139          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 1140   
 1141        break;
 1142   
 1143      case WPS_TLV_TYPE_VENDOR_EXTENSION:
 1144        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_vendor_extension, tvb, offset+4, tlv_len, FALSE);
 1145        hfindex = hf_eapwps_tlv_vendor_extension;
 1146   
 1147        break;
 1148   
 1149      case WPS_TLV_TYPE_VERSION:
 1150        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_version, tvb, offset+4, 1, FALSE);
 1151        hfindex = hf_eapwps_tlv_version;
 1152   
 1153        break;
 1154   
 1155      case WPS_TLV_TYPE_X509_CERTIFICATE_REQUEST:
 1156        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_x509_certificate_request, tvb, offset+4, tlv_len, FALSE);
 1157        hfindex = hf_eapwps_tlv_x509_certificate_request;
 1158   
 1159        break;
 1160   
 1161      case WPS_TLV_TYPE_X509_CERTIFICATE:
 1162        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_x509_certificate, tvb, offset+4, tlv_len, FALSE);
 1163        hfindex = hf_eapwps_tlv_x509_certificate;
 1164   
 1165        break;
 1166   
 1167      case WPS_TLV_TYPE_EAP_IDENTITY:
 1168        /* check tlv_len <= 64 byte  */
 1169        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_eap_identity, tvb, offset+4, tlv_len, FALSE);
 1170        hfindex = hf_eapwps_tlv_eap_identity;
 1171        if (tlv_len > 64 && pinfo)  
 1172          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 1173   
 1174        break;
 1175   
 1176      case WPS_TLV_TYPE_MESSAGE_COUNTER:
 1177        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_message_counter, tvb, offset+4, 8, FALSE);
 1178        hfindex = hf_eapwps_tlv_message_counter;
 1179   
 1180        break;
 1181   
 1182      case WPS_TLV_TYPE_PUBLIC_KEY_HASH:
 1183        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_public_key_hash, tvb, offset+4, 20, FALSE);
 1184        hfindex = hf_eapwps_tlv_public_key_hash;
 1185   
 1186        break;
 1187   
 1188      case WPS_TLV_TYPE_REKEY_KEY:
 1189        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_rekey_key, tvb, offset+4, 32, FALSE);
 1190        hfindex = hf_eapwps_tlv_rekey_key;
 1191   
 1192        break;
 1193   
 1194      case WPS_TLV_TYPE_KEY_LIFETIME:
 1195        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_key_lifetime, tvb, offset+4, 4, FALSE);
 1196        hfindex = hf_eapwps_tlv_key_lifetime;
 1197   
 1198        break;
 1199   
 1200      case WPS_TLV_TYPE_PERMITTED_CONFIG_METHODS:
 1201        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_permitted_config_methods, tvb, offset+4, 2, FALSE);
 1202        hfindex = hf_eapwps_tlv_permitted_config_methods;
 1203   
 1204        dissect_wps_config_methods(tlv_root, tvb, offset, size, pinfo);
 1205   
 1206        break;
 1207   
 1208      case WPS_TLV_TYPE_SELECTED_REGISTRAR_CONFIG_METHODS:
 1209        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_selected_registrar_config_methods, tvb, offset+4, 2, FALSE);
 1210        hfindex = hf_eapwps_tlv_selected_registrar_config_methods;
 1211   
 1212        dissect_wps_config_methods(tlv_root, tvb, offset, size, pinfo);
 1213   
 1214        break;
 1215   
 1216      case WPS_TLV_TYPE_PRIMARY_DEVICE_TYPE:
 1217        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_primary_device_type, tvb, offset+4, 8, FALSE);
 1218        hfindex = hf_eapwps_tlv_primary_device_type;
 1219   
 1220        /* NYI: Implement vals for OUI==WFA  */
 1221        proto_tree_add_item(tlv_root, hf_eapwps_tlv_primary_device_type_category,   tvb, offset+4,  2, FALSE);
 1222        proto_tree_add_item(tlv_root, hf_eapwps_tlv_primary_device_type_oui,        tvb, offset+6,  4, FALSE);
 1223        proto_tree_add_item(tlv_root, hf_eapwps_tlv_primary_device_type_subcategory,tvb, offset+10, 2, FALSE);
 1224   
 1225        break;
 1226   
 1227      case WPS_TLV_TYPE_SECONDARY_DEVICE_TYPE_LIST:
 1228        /* check tlv_len <= 128 byte  */
 1229        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_secondary_device_type_list, tvb, offset+4, tlv_len, FALSE);
 1230        hfindex = hf_eapwps_tlv_secondary_device_type_list;
 1231        if (tlv_len > 128 && pinfo)  
 1232          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 1233   
 1234        break;
 1235   
 1236      case WPS_TLV_TYPE_PORTABLE_DEVICE:
 1237        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_portable_device, tvb, offset+4, 2, FALSE);
 1238        hfindex = hf_eapwps_tlv_portable_device;
 1239   
 1240        break;
 1241   
 1242      case WPS_TLV_TYPE_AP_SETUP_LOCKED:
 1243        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_ap_setup_locked, tvb, offset+4, 2, FALSE);
 1244        hfindex = hf_eapwps_tlv_ap_setup_locked;
 1245   
 1246        break;
 1247   
 1248      case WPS_TLV_TYPE_APPLICATION_EXTENSION:
 1249        /* check tlv_len <= 512 byte  */
 1250        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_application_extension, tvb, offset+4, tlv_len, FALSE);
 1251        hfindex = hf_eapwps_tlv_application_extension;
 1252        if (tlv_len > 512 && pinfo)  
 1253          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 1254   
 1255        break;
 1256   
 1257      case WPS_TLV_TYPE_EAP_TYPE:
 1258        /* check tlv_len <= 8 byte  */
 1259        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_eap_type, tvb, offset+4, tlv_len, FALSE);
 1260        hfindex = hf_eapwps_tlv_eap_type;
 1261        if (tlv_len > 8 && pinfo)  
 1262          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 1263   
 1264        break;
 1265   
 1266      case WPS_TLV_TYPE_INITIALIZATION_VECTOR:
 1267        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_initialization_vector, tvb, offset+4, 32, FALSE);
 1268        hfindex = hf_eapwps_tlv_initialization_vector;
 1269   
 1270        break;
 1271   
 1272      case WPS_TLV_TYPE_KEY_PROVIDED_AUTOMATICALLY:
 1273        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_key_provided_automatically, tvb, offset+4, 2, FALSE);
 1274        hfindex = hf_eapwps_tlv_key_provided_automatically;
 1275   
 1276        break;
 1277   
 1278      case WPS_TLV_TYPE_8021X_ENABLED:
 1279        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_8021x_enabled, tvb, offset+4, 2, FALSE);
 1280        hfindex = hf_eapwps_tlv_8021x_enabled;
 1281   
 1282        break;
 1283   
 1284      case WPS_TLV_TYPE_APPSESSIONKEY:
 1285        /* check tlv_len <= 128 byte  */
 1286        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_appsessionkey, tvb, offset+4, tlv_len, FALSE);
 1287        hfindex = hf_eapwps_tlv_appsessionkey;
 1288        if (tlv_len > 128 && pinfo)  
 1289          expert_add_info_format(pinfo, tmp_item, PI_MALFORMED, PI_ERROR, fmt_warn_too_long, tlv_len);
 1290   
 1291        break;
 1292   
 1293      case WPS_TLV_TYPE_WEPTRANSMITKEY:
 1294        tmp_item = proto_tree_add_item(tlv_root, hf_eapwps_tlv_weptransmitkey, tvb, offset+4, 1, FALSE);
 1295        hfindex = hf_eapwps_tlv_weptransmitkey;
 1296   
 1297        break;
 1298      default:
 1299        /* do something usefull ?  */
 1300        tmp_item = NULL;
 1301        hfindex = -1;
 1302      }
 1303   
 1304      if (tmp_item != NULL && tlv_item != NULL) {
 1305        /* make the tree look nicer :-)  
 1306           tmp_item -> a proto_item specific to the _value_  
 1307           tlv_item ->  root-item grouping 
 1308                        - "Data Element Type"  
 1309                        - "Date Element Length"  
 1310                        - tmp_item */
 1311        guint32 value = -1;
 1312        void* valuep = NULL;
 1313        header_field_info* hf_info = NULL;
 1314        char* fmt = NULL;
 1315   
 1316        proto_item_set_text(tlv_item, "%s",  
 1317                            val_to_str(tlv_type, eapwps_tlv_types, "Unknown (0x%04x)"));
 1318   
 1319        /* Rendered strings for value. Thanks to Stig Bjorlykke */  
 1320        hf_info = proto_registrar_get_nth(hfindex);
 1321        if (hf_info != NULL) {
 1322          switch(hf_info->type) {
 1323          case FT_UINT8:
 1324            fmt = hf_info->strings ? ": %s (0x%02x)": ": 0x%02x";
 1325            value = tvb_get_guint8 (tvb, offset+4);  
 1326            break;
 1327          case FT_UINT16:
 1328            fmt = hf_info->strings ? ": %s (0x%04x)": ": 0x%04x";
 1329            value = tvb_get_ntohs (tvb, offset+4);
 1330            break;
 1331          case FT_UINT32:
 1332            fmt = hf_info->strings ? ": %s (0x%08x)": ": 0x%08x";
 1333            value = tvb_get_ntohl (tvb, offset+4);
 1334            break;
 1335          case FT_STRING:
 1336            fmt = ": %s";
 1337            valuep = tvb_get_ephemeral_string(tvb, offset+4, tlv_len);
 1338            break;
 1339          default:
 1340            /* make compiler happy */
 1341            break;
 1342          }
 1343        }
 1344   
 1345        if (hf_info != NULL && hf_info->strings) {
 1346          /* item has value_string */
 1347          proto_item_append_text(tlv_item, fmt, val_to_str(value,
 1348                                                           hf_info->strings,
 1349                                                           "Unknown: %d"), value);
 1350        } else if (valuep != NULL) {
 1351          /* the string-case */
 1352          proto_item_append_text(tlv_item, fmt, valuep);
 1353        } else if (fmt != NULL) {
 1354          /* field is FT_UINT(8|16|32) but has no value_string */
 1355          proto_item_append_text(tlv_item, fmt, value);
 1356        } else {
 1357          /* field is either FT_ETHER or FT_BYTES, dont do anything */
 1358        }
 1359   
 1360      }
 1361   
 1362      offset += tlv_len + 2 + 2;  
 1363      size   -= tlv_len + 2 + 2;
 1364    }
 1365  }
Show more  




Change Warning 5551.35841 : Format String

Because they are very similar, this warning shares annotations with warning 5551.35843.

Priority:
State:
Finding:
Owner:
Note: