1 /* 2 * Copyright (C) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef OHOS_WIFI_MSG_H 16 #define OHOS_WIFI_MSG_H 17 18 #include <algorithm> 19 #include <cstring> 20 #include <ctime> 21 #include <iomanip> 22 #include <map> 23 #include <sstream> 24 #include <string> 25 #include <vector> 26 #include "ip_tools.h" 27 #include "wifi_scan_msg.h" 28 #include "securec.h" 29 30 namespace OHOS { 31 namespace Wifi { 32 #define WIFI_COUNTRY_CODE_LEN 2 33 #define WEPKEYS_SIZE 4 34 #define INVALID_NETWORK_ID (-1) 35 #define WIFI_INVALID_UID (-1) 36 #define INVALID_SIGNAL_LEVEL (-1) 37 #define IPV4_ADDRESS_TYPE 0 38 #define IPV6_ADDRESS_TYPE 1 39 #define WIFI_INVALID_SIM_ID (0) 40 #define WIFI_EAP_OPEN_EXTERNAL_SIM 1 41 #define WIFI_EAP_CLOSE_EXTERNAL_SIM 0 42 #define WIFI_PASSWORD_LEN 128 43 #define MAX_PID_LIST_SIZE 128 44 45 const std::string KEY_MGMT_NONE = "NONE"; 46 const std::string KEY_MGMT_WEP = "WEP"; 47 const std::string KEY_MGMT_WPA_PSK = "WPA-PSK"; 48 const std::string KEY_MGMT_SAE = "SAE"; 49 const std::string KEY_MGMT_EAP = "WPA-EAP"; 50 const std::string KEY_MGMT_SUITE_B_192 = "WPA-EAP-SUITE-B-192"; 51 const std::string KEY_MGMT_WAPI_CERT = "WAPI-CERT"; 52 const std::string KEY_MGMT_WAPI_PSK = "WAPI-PSK"; 53 const std::string KEY_MGMT_WAPI = "WAPI"; 54 55 const std::string EAP_METHOD_NONE = "NONE"; 56 const std::string EAP_METHOD_PEAP = "PEAP"; 57 const std::string EAP_METHOD_TLS = "TLS"; 58 const std::string EAP_METHOD_TTLS = "TTLS"; 59 const std::string EAP_METHOD_PWD = "PWD"; 60 const std::string EAP_METHOD_SIM = "SIM"; 61 const std::string EAP_METHOD_AKA = "AKA"; 62 const std::string EAP_METHOD_AKA_PRIME = "AKA'"; 63 64 enum class SupplicantState { 65 DISCONNECTED = 0, 66 INTERFACE_DISABLED = 1, 67 INACTIVE = 2, 68 SCANNING = 3, 69 AUTHENTICATING = 4, 70 ASSOCIATING = 5, 71 ASSOCIATED = 6, 72 FOUR_WAY_HANDSHAKE = 7, 73 GROUP_HANDSHAKE = 8, 74 COMPLETED = 9, 75 UNKNOWN = 10, 76 77 INVALID = 0xFF, 78 }; 79 80 enum class DetailedState { 81 AUTHENTICATING = 0, 82 BLOCKED = 1, 83 CAPTIVE_PORTAL_CHECK = 2, 84 CONNECTED = 3, 85 CONNECTING = 4, 86 DISCONNECTED = 5, 87 DISCONNECTING = 6, 88 FAILED = 7, 89 IDLE = 8, 90 OBTAINING_IPADDR = 9, 91 WORKING = 10, 92 NOTWORKING = 11, 93 SCANNING = 12, 94 SUSPENDED = 13, 95 VERIFYING_POOR_LINK = 14, 96 PASSWORD_ERROR = 15, 97 CONNECTION_REJECT = 16, 98 CONNECTION_FULL = 17, 99 CONNECTION_TIMEOUT = 18, 100 OBTAINING_IPADDR_FAIL = 19, 101 INVALID = 0xFF, 102 }; 103 104 enum ConnState { 105 /** The device is searching for an available AP. */ 106 SCANNING, 107 108 /** The Wi-Fi connection is being set up. */ 109 CONNECTING, 110 111 /** The Wi-Fi connection is being authenticated. */ 112 AUTHENTICATING, 113 114 /** The IP address of the Wi-Fi connection is being obtained. */ 115 OBTAINING_IPADDR, 116 117 /** The Wi-Fi connection has been set up. */ 118 CONNECTED, 119 120 /** The Wi-Fi connection is being torn down. */ 121 DISCONNECTING, 122 123 /** The Wi-Fi connection has been torn down. */ 124 DISCONNECTED, 125 126 /** The Wi-Fi special connection. */ 127 SPECIAL_CONNECT, 128 129 /** Failed to set up the Wi-Fi connection. */ 130 UNKNOWN 131 }; 132 133 enum class DisconnectedReason { 134 /* Default reason */ 135 DISC_REASON_DEFAULT = 0, 136 137 /* Password is wrong */ 138 DISC_REASON_WRONG_PWD = 1, 139 140 /* The number of router's connection reaches the maximum number limit */ 141 DISC_REASON_CONNECTION_FULL = 2, 142 143 /* Connection Rejected */ 144 DISC_REASON_CONNECTION_REJECTED = 3 145 }; 146 147 enum class WifiOperateType { 148 STA_OPEN, 149 STA_CLOSE, 150 STA_CONNECT, 151 STA_ASSOC, 152 STA_AUTH, 153 STA_DHCP, 154 STA_SEMI_OPEN 155 }; 156 157 enum class WifiOperateState { 158 STA_OPENING, 159 STA_OPENED, 160 STA_CONNECTING, 161 STA_CONNECTED, 162 STA_CONNECT_EXCEPTION, 163 STA_DISCONNECTED, 164 STA_ASSOCIATING, 165 STA_ASSOCIATED, 166 STA_ASSOC_FULL_REJECT, 167 STA_AUTHING, 168 STA_AUTHED, 169 STA_DHCP, 170 STA_DHCP_SUCCESS, 171 STA_DISCONNECT, 172 STA_DHCP_FAIL, 173 STA_CLOSING, 174 STA_CLOSED, 175 STA_SEMI_OPENING, 176 STA_SEMI_OPENED, 177 }; 178 179 enum class DisconnectDetailReason { 180 UNUSED = 0, 181 UNSPECIFIED = 1, 182 PREV_AUTH_NOT_VALID = 2, 183 DEAUTH_STA_IS_LEFING = 3, 184 DISASSOC_DUE_TO_INACTIVITY = 4, 185 DISASSOC_AP_BUSY = 5, 186 DISASSOC_STA_HAS_LEFT = 8, 187 DISASSOC_IEEE_802_1X_AUTH_FAILED = 23, 188 DISASSOC_LOW_ACK = 34 189 }; 190 191 struct WifiLinkedInfo { 192 int networkId; 193 std::string ssid; 194 std::string bssid; 195 int rssi; /* signal level */ 196 int band; /* 2.4G / 5G */ 197 int frequency; 198 int linkSpeed; /* units: Mbps */ 199 std::string macAddress; 200 int macType; 201 unsigned int ipAddress; 202 ConnState connState; 203 bool ifHiddenSSID; 204 int rxLinkSpeed; /* Downstream network speed */ 205 int txLinkSpeed; /* Upstream network speed */ 206 int chload; 207 int snr; /* Signal-to-Noise Ratio */ 208 int isDataRestricted; 209 std::string platformType; 210 std::string portalUrl; 211 SupplicantState supplicantState; /* wpa_supplicant state */ 212 DetailedState detailedState; /* connection state */ 213 int wifiStandard; /* wifi standard */ 214 int maxSupportedRxLinkSpeed; 215 int maxSupportedTxLinkSpeed; 216 WifiChannelWidth channelWidth; /* curr ap channel width */ 217 int lastPacketDirection; 218 int lastRxPackets; 219 int lastTxPackets; 220 bool isAncoConnected; 221 WifiCategory supportedWifiCategory; 222 bool isMloConnected; 223 bool isHiLinkNetwork; 224 int c0Rssi; 225 int c1Rssi; WifiLinkedInfoWifiLinkedInfo226 WifiLinkedInfo() 227 { 228 networkId = INVALID_NETWORK_ID; 229 rssi = 0; 230 band = 0; 231 frequency = 0; 232 linkSpeed = 0; 233 macType = 0; 234 ipAddress = 0; 235 connState = ConnState::UNKNOWN; 236 ifHiddenSSID = false; 237 rxLinkSpeed = 0; 238 txLinkSpeed = 0; 239 chload = 0; 240 snr = 0; 241 isDataRestricted = 0; 242 supplicantState = SupplicantState::INVALID; 243 detailedState = DetailedState::INVALID; 244 wifiStandard = 0; 245 maxSupportedRxLinkSpeed = 0; 246 maxSupportedTxLinkSpeed = 0; 247 channelWidth = WifiChannelWidth::WIDTH_INVALID; 248 lastPacketDirection = 0; 249 lastRxPackets = 0; 250 lastTxPackets = 0; 251 isAncoConnected = false; 252 isHiLinkNetwork = false; 253 supportedWifiCategory = WifiCategory::DEFAULT; 254 isMloConnected = false; 255 c0Rssi = 0; 256 c1Rssi = 0; 257 } 258 }; 259 260 /* use WPS type */ 261 enum class SetupMethod { 262 PBC = 0, 263 DISPLAY = 1, 264 KEYPAD = 2, 265 LABEL = 3, 266 INVALID = 4, 267 }; 268 269 /* WPS config */ 270 struct WpsConfig { 271 SetupMethod setup; /* WPS type */ 272 std::string pin; /* pin code */ 273 std::string bssid; /* KEYPAD mode pin code */ 274 WpsConfigWpsConfig275 WpsConfig() 276 { 277 setup = SetupMethod::INVALID; 278 } 279 }; 280 281 enum class WifiDeviceConfigStatus { 282 ENABLED, /* enable */ 283 DISABLED, /* disabled */ 284 PERMEMANTLY_DISABLED, /* permanently disabled */ 285 UNKNOWN 286 }; 287 288 enum class AssignIpMethod { DHCP, STATIC, UNASSIGNED }; 289 290 enum class ConfigChange { 291 CONFIG_ADD = 0, 292 CONFIG_UPDATE = 1, 293 CONFIG_REMOVE = 2, 294 }; 295 296 class WifiIpAddress { 297 public: 298 int family; /* ip type */ 299 unsigned int addressIpv4; /* IPv4 */ 300 std::vector<unsigned char> addressIpv6; /* IPv6 */ 301 WifiIpAddress()302 WifiIpAddress() 303 { 304 family = -1; 305 addressIpv4 = 0; 306 } 307 ~WifiIpAddress()308 ~WifiIpAddress() 309 {} 310 GetIpv4Address()311 std::string GetIpv4Address() 312 { 313 return IpTools::ConvertIpv4Address(addressIpv4); 314 } 315 SetIpv4Address(const std::string & address)316 void SetIpv4Address(const std::string &address) 317 { 318 addressIpv4 = IpTools::ConvertIpv4Address(address); 319 if (addressIpv4 != 0) { 320 family = IPV4_ADDRESS_TYPE; 321 } 322 return; 323 } 324 GetIpv6Address()325 std::string GetIpv6Address() 326 { 327 return IpTools::ConvertIpv6Address(addressIpv6); 328 } 329 SetIpv6Address(const std::string & address)330 void SetIpv6Address(const std::string &address) 331 { 332 IpTools::ConvertIpv6Address(address, addressIpv6); 333 if (addressIpv6.size() != 0) { 334 family = IPV6_ADDRESS_TYPE; 335 } 336 return; 337 } 338 }; 339 340 class WifiLinkAddress { 341 public: 342 WifiIpAddress address; /* IP address */ 343 int prefixLength; 344 int flags; 345 int scope; 346 WifiLinkAddress()347 WifiLinkAddress() 348 { 349 prefixLength = 0; 350 flags = 0; 351 scope = 0; 352 } 353 ~WifiLinkAddress()354 ~WifiLinkAddress() 355 {} 356 }; 357 358 class StaticIpAddress { 359 public: 360 WifiLinkAddress ipAddress; 361 WifiIpAddress gateway; 362 WifiIpAddress dnsServer1; /* main DNS */ 363 WifiIpAddress dnsServer2; /* backup DNS */ 364 std::string domains; 365 GetIpv4Mask()366 std::string GetIpv4Mask() 367 { 368 return IpTools::ConvertIpv4Mask(ipAddress.prefixLength); 369 } 370 GetIpv6Mask()371 std::string GetIpv6Mask() 372 { 373 return IpTools::ConvertIpv6Mask(ipAddress.prefixLength); 374 } 375 }; 376 377 class WifiIpConfig { 378 public: 379 AssignIpMethod assignMethod; 380 StaticIpAddress staticIpAddress; 381 WifiIpConfig()382 WifiIpConfig() 383 { 384 assignMethod = AssignIpMethod::DHCP; 385 } ~WifiIpConfig()386 ~WifiIpConfig() 387 {} 388 }; 389 390 enum class EapMethod { 391 EAP_NONE = 0, 392 EAP_PEAP = 1, 393 EAP_TLS = 2, 394 EAP_TTLS = 3, 395 EAP_PWD = 4, 396 EAP_SIM = 5, 397 EAP_AKA = 6, 398 EAP_AKA_PRIME = 7, 399 EAP_UNAUTH_TLS = 8 400 }; 401 402 enum class Phase2Method { 403 NONE = 0, 404 PAP = 1, // only EAP-TTLS support this mode 405 MSCHAP = 2, // only EAP-TTLS support this mode 406 MSCHAPV2 = 3, // only EAP-PEAP/EAP-TTLS support this mode 407 GTC = 4, // only EAP-PEAP/EAP-TTLS support this mode 408 SIM = 5, // only EAP-PEAP support this mode 409 AKA = 6, // only EAP-PEAP support this mode 410 AKA_PRIME = 7 // only EAP-PEAP support this mode 411 }; 412 413 class WifiEapConfig { 414 public: 415 std::string eap; /* EAP authentication mode:PEAP/TLS/TTLS/PWD/SIM/AKA/AKA' */ 416 Phase2Method phase2Method; /* Second stage authentication method */ 417 std::string identity; /* Identity information */ 418 std::string anonymousIdentity; /* Anonymous identity information */ 419 std::string password; /* EAP mode password */ 420 std::string encryptedData; /* EAP mode password encryptedData */ 421 std::string IV; /* EAP mode password encrypted IV */ 422 423 std::string caCertPath; /* CA certificate path */ 424 std::string caCertAlias; /* CA certificate alias */ 425 std::vector<uint8_t> certEntry; /* CA certificate entry */ 426 427 std::string clientCert; /* Client certificate */ 428 char certPassword[WIFI_PASSWORD_LEN]; /* Certificate password */ 429 std::string privateKey; /* Client certificate private key */ 430 431 std::string altSubjectMatch; /* Alternative topic matching */ 432 std::string domainSuffixMatch; /* Domain suffix matching */ 433 std::string realm; /* The field of passport credentials */ 434 std::string plmn; /* PLMN */ 435 int eapSubId; /* Sub ID of SIM card */ 436 WifiEapConfig()437 WifiEapConfig() 438 { 439 phase2Method = Phase2Method::NONE; 440 (void) memset_s(certPassword, sizeof(certPassword), 0, sizeof(certPassword)); 441 eapSubId = -1; 442 } ~WifiEapConfig()443 ~WifiEapConfig() 444 {} 445 /** 446 * @Description convert Phase2Method to string 447 * 448 * @param eap - eap method 449 * @param method - phase2method 450 * @return string 451 */ 452 static std::string Phase2MethodToStr(const std::string& eap, const int& method); 453 454 /** 455 * @Description convert string to Phase2Method 456 * 457 * @param str - phase2method string 458 * @return Phase2Method 459 */ 460 static Phase2Method Phase2MethodFromStr(const std::string& str); 461 462 /** 463 * @Description convert string to EapMethod 464 * 465 * @param str - EapMethod string 466 * @return EapMethod 467 */ 468 static EapMethod Str2EapMethod(const std::string& str); 469 }; 470 471 enum class ConfigureProxyMethod { CLOSED, AUTOCONFIGUE, MANUALCONFIGUE }; 472 473 class AutoProxyConfig { 474 public: 475 std::string pacWebAddress; 476 }; 477 478 class ManualProxyConfig { 479 public: 480 std::string serverHostName; 481 int serverPort; 482 std::string exclusionObjectList; 483 GetExclusionObjectList(std::vector<std::string> & exclusionList)484 void GetExclusionObjectList(std::vector<std::string> &exclusionList) 485 { 486 IpTools::GetExclusionObjectList(exclusionObjectList, exclusionList); 487 return; 488 } 489 ManualProxyConfig()490 ManualProxyConfig() 491 { 492 serverPort = 0; 493 } ~ManualProxyConfig()494 ~ManualProxyConfig() 495 {} 496 }; 497 498 class WifiProxyConfig { 499 public: 500 ConfigureProxyMethod configureMethod; 501 AutoProxyConfig autoProxyConfig; 502 ManualProxyConfig manualProxyConfig; 503 WifiProxyConfig()504 WifiProxyConfig() 505 { 506 configureMethod = ConfigureProxyMethod::CLOSED; 507 } ~WifiProxyConfig()508 ~WifiProxyConfig() 509 {} 510 }; 511 512 enum class WifiPrivacyConfig { RANDOMMAC, DEVICEMAC }; 513 514 enum class DisabledReason { 515 DISABLED_UNKNOWN_REASON = -1, 516 DISABLED_NONE = 0, 517 DISABLED_ASSOCIATION_REJECTION = 1, 518 DISABLED_AUTHENTICATION_FAILURE = 2, 519 DISABLED_DHCP_FAILURE = 3, 520 DISABLED_NO_INTERNET_TEMPORARY = 4, 521 DISABLED_AUTHENTICATION_NO_CREDENTIALS = 5, 522 DISABLED_NO_INTERNET_PERMANENT = 6, 523 DISABLED_BY_WIFI_MANAGER = 7, 524 DISABLED_BY_WRONG_PASSWORD = 8, 525 DISABLED_AUTHENTICATION_NO_SUBSCRIPTION = 9, 526 DISABLED_AUTHENTICATION_PRIVATE_EAP_ERROR = 10, 527 DISABLED_NETWORK_NOT_FOUND = 11, 528 DISABLED_CONSECUTIVE_FAILURES = 12, 529 DISABLED_BY_SYSTEM = 13, 530 DISABLED_EAP_AKA_FAILURE = 14, 531 DISABLED_DISASSOC_REASON = 15, 532 NETWORK_SELECTION_DISABLED_MAX = 16 533 }; 534 535 struct NetworkSelectionStatus { 536 WifiDeviceConfigStatus status; 537 DisabledReason networkSelectionDisableReason; 538 int64_t networkDisableTimeStamp; 539 int networkDisableCount; NetworkSelectionStatusNetworkSelectionStatus540 NetworkSelectionStatus() 541 { 542 status = WifiDeviceConfigStatus::ENABLED; 543 networkSelectionDisableReason = DisabledReason::DISABLED_NONE; 544 networkDisableTimeStamp = -1; 545 networkDisableCount = 0; 546 } 547 }; 548 549 class WifiWapiConfig { 550 public: 551 int wapiPskType; 552 std::string wapiAsCertData; 553 std::string wapiUserCertData; 554 std::string encryptedAsCertData; 555 std::string asCertDataIV; 556 std::string encryptedUserCertData; 557 std::string userCertDataIV; 558 WifiWapiConfig()559 WifiWapiConfig() 560 { 561 wapiPskType = -1; 562 } 563 ~WifiWapiConfig()564 ~WifiWapiConfig() 565 {} 566 }; 567 568 /* DHCP info */ 569 struct IpInfo { 570 unsigned int ipAddress; /* ip address */ 571 unsigned int gateway; /* gate */ 572 unsigned int netmask; /* mask */ 573 unsigned int primaryDns; /* main dns */ 574 unsigned int secondDns; /* backup dns */ 575 unsigned int serverIp; /* DHCP server's address */ 576 unsigned int leaseDuration; 577 std::vector<unsigned int> dnsAddr; 578 IpInfoIpInfo579 IpInfo() 580 { 581 ipAddress = 0; 582 gateway = 0; 583 netmask = 0; 584 primaryDns = 0; 585 secondDns = 0; 586 serverIp = 0; 587 leaseDuration = 0; 588 dnsAddr.clear(); 589 } 590 }; 591 592 /* Network configuration information */ 593 struct WifiDeviceConfig { 594 int instanceId; 595 int networkId; 596 /* 0: CURRENT, using 1: DISABLED 2: ENABLED */ 597 int status; 598 /* network selection status*/ 599 NetworkSelectionStatus networkSelectionStatus; 600 /* mac address */ 601 std::string bssid; 602 /* bssid type. */ 603 int bssidType; 604 /* network name */ 605 std::string ssid; 606 int band; 607 int channel; 608 int frequency; 609 /* Signal strength */ 610 int rssi; 611 /** 612 * signal level, 613 * rssi<=-100 level : 0 614 * (-100, -88] level : 1 615 * (-88, -77] level : 2 616 * (-66, -55] level : 3 617 * rssi>=-55 level : 4 618 */ 619 int level; 620 /* Is Passpoint network */ 621 bool isPasspoint; 622 /* is ephemeral network */ 623 bool isEphemeral; 624 /* WPA-PSK mode pre shared key */ 625 std::string preSharedKey; 626 std::string encryptedData; 627 std::string IV; 628 /* Encryption Mode */ 629 std::string keyMgmt; 630 /* WEP mode key, max size: 4 */ 631 std::string wepKeys[WEPKEYS_SIZE]; 632 /* use WEP key index */ 633 int wepTxKeyIndex; 634 std::string encryWepKeys[WEPKEYS_SIZE]; 635 std::string IVWep; 636 /* network priority */ 637 int priority; 638 /* is hidden network */ 639 bool hiddenSSID; 640 /* Random mac address */ 641 std::string macAddress; 642 int uid; 643 time_t lastConnectTime; 644 int numRebootsSinceLastUse; 645 int numAssociation; 646 int connFailedCount; 647 unsigned int networkStatusHistory; 648 bool isPortal; 649 time_t portalAuthTime; 650 time_t lastHasInternetTime; 651 bool noInternetAccess; 652 /* save select mac address */ 653 std::string userSelectBssid; 654 WifiIpConfig wifiIpConfig; 655 WifiEapConfig wifiEapConfig; 656 WifiProxyConfig wifiProxyconfig; 657 WifiPrivacyConfig wifiPrivacySetting; 658 std::string callProcessName; 659 std::string ancoCallProcessName; 660 std::string internetSelfCureHistory; 661 int isReassocSelfCureWithFactoryMacAddress; 662 int version; 663 bool randomizedMacSuccessEver; 664 bool everConnected; 665 bool acceptUnvalidated; 666 WifiWapiConfig wifiWapiConfig; 667 IpInfo lastDhcpResult; 668 bool isShared; 669 int64_t lastTrySwitchWifiTimestamp { -1 }; 670 WifiDeviceConfigWifiDeviceConfig671 WifiDeviceConfig() 672 { 673 instanceId = 0; 674 networkId = INVALID_NETWORK_ID; 675 status = static_cast<int>(WifiDeviceConfigStatus::DISABLED); 676 bssidType = REAL_DEVICE_ADDRESS; 677 band = 0; 678 channel = 0; 679 frequency = 0; 680 level = 0; 681 isPasspoint = false; 682 isEphemeral = false; 683 wepTxKeyIndex = 0; 684 priority = 0; 685 hiddenSSID = false; 686 wifiPrivacySetting = WifiPrivacyConfig::RANDOMMAC; 687 rssi = -100; 688 uid = WIFI_INVALID_UID; 689 lastConnectTime = -1; 690 numRebootsSinceLastUse = 0; 691 numAssociation = 0; 692 connFailedCount = 0; 693 networkStatusHistory = 0; 694 isPortal = false; 695 portalAuthTime = -1; 696 lastHasInternetTime = -1; 697 noInternetAccess = false; 698 callProcessName = ""; 699 ancoCallProcessName = ""; 700 internetSelfCureHistory = ""; 701 isReassocSelfCureWithFactoryMacAddress = 0; 702 version = -1; 703 randomizedMacSuccessEver = false; 704 isShared = false; 705 everConnected = false; 706 acceptUnvalidated = false; 707 } 708 }; 709 710 enum class WifiState { DISABLING = 0, DISABLED = 1, ENABLING = 2, ENABLED = 3, UNKNOWN = 4 }; 711 712 enum class WifiDetailState { 713 STATE_UNKNOWN = -1, 714 STATE_INACTIVE = 0, 715 STATE_ACTIVATED = 1, 716 STATE_ACTIVATING = 2, 717 STATE_DEACTIVATING = 3, 718 STATE_SEMI_ACTIVATING = 4, 719 STATE_SEMI_ACTIVE = 5 720 }; 721 722 /* wps state */ 723 enum class WpsStartState { 724 START_PBC_SUCCEED = 0, 725 START_PIN_SUCCEED = 1, 726 START_PBC_FAILED = 2, 727 PBC_STARTED_ALREADY = 3, 728 START_PIN_FAILED = 4, 729 PIN_STARTED_ALREADY = 5, 730 STOP_PBC_SUCCEED = 6, 731 STOP_PBC_FAILED = 7, 732 STOP_PIN_SUCCEED = 8, 733 STOP_PIN_FAILED = 9, 734 START_PBC_FAILED_OVERLAP = 10, 735 START_WPS_FAILED = 11, 736 WPS_TIME_OUT = 12, 737 START_AP_PIN_SUCCEED = 13, 738 START_AP_PIN_FAILED = 14, 739 STOP_AP_PIN_SUCCEED = 15, 740 STOP_AP_PIN_FAILED = 16, 741 }; 742 743 enum class StreamDirection { 744 STREAM_DIRECTION_NONE = 0, 745 STREAM_DIRECTION_DOWN = 1, 746 STREAM_DIRECTION_UP = 2, 747 STREAM_DIRECTION_UPDOWN = 3, 748 }; 749 750 /* WifiProtectType */ 751 enum class WifiProtectType { 752 WIFI_PROTECT_MULTICAST = 0, 753 WIFI_PROTECT_COMMON = 1 754 }; 755 756 /* WifiProtectMode */ 757 enum class WifiProtectMode { 758 WIFI_PROTECT_FULL = 0, 759 WIFI_PROTECT_SCAN_ONLY = 1, 760 WIFI_PROTECT_FULL_HIGH_PERF = 2, 761 WIFI_PROTECT_FULL_LOW_LATENCY = 3, 762 WIFI_PROTECT_NO_HELD = 4 763 }; 764 765 /* DHCP IpV6Info */ 766 struct IpV6Info { 767 std::string linkIpV6Address; 768 std::string globalIpV6Address; 769 std::string randGlobalIpV6Address; 770 std::string gateway; 771 std::string netmask; 772 std::string primaryDns; 773 std::string secondDns; 774 std::string uniqueLocalAddress1; 775 std::string uniqueLocalAddress2; 776 std::vector<std::string> dnsAddr; 777 IpV6InfoIpV6Info778 IpV6Info() 779 { 780 linkIpV6Address = ""; 781 globalIpV6Address = ""; 782 randGlobalIpV6Address = ""; 783 gateway = ""; 784 netmask = ""; 785 primaryDns = ""; 786 secondDns = ""; 787 uniqueLocalAddress1 = ""; 788 uniqueLocalAddress2 = ""; 789 dnsAddr.clear(); 790 } 791 }; 792 793 struct WifiCategoryBlackListInfo { 794 /* 0:HTC, 1:WIFI6, -1:invalid */ 795 /* 0:MLD, 1:WIFI7, -1:invalid */ 796 int actionType = -1; 797 int64_t updateTime = 0; 798 WifiCategoryBlackListInfoWifiCategoryBlackListInfo799 WifiCategoryBlackListInfo() {} 800 WifiCategoryBlackListInfoWifiCategoryBlackListInfo801 WifiCategoryBlackListInfo(int type, int64_t time) 802 { 803 this->actionType = type; 804 this->updateTime = time; 805 } 806 }; 807 808 struct WifiCategoryConnectFailInfo { 809 /* 0:MLD, 1:WIFI7, 2:Cure Fail,-1:invalid */ 810 int actionType = -1; 811 int connectFailTimes = 0; 812 int64_t updateTime = 0; 813 WifiCategoryConnectFailInfoWifiCategoryConnectFailInfo814 WifiCategoryConnectFailInfo() {} 815 WifiCategoryConnectFailInfoWifiCategoryConnectFailInfo816 WifiCategoryConnectFailInfo(int type, int failTimes, int64_t time) 817 { 818 this->actionType = type; 819 this->connectFailTimes = failTimes; 820 this->updateTime = time; 821 } 822 }; 823 824 // SIM authentication 825 struct EapSimGsmAuthParam { 826 std::vector<std::string> rands; 827 }; 828 829 // AKA/AKA' authentication 830 struct EapSimUmtsAuthParam { 831 std::string rand; 832 std::string autn; EapSimUmtsAuthParamEapSimUmtsAuthParam833 EapSimUmtsAuthParam() 834 { 835 rand = ""; 836 autn = ""; 837 } 838 }; 839 840 typedef enum { 841 BG_LIMIT_CONTROL_ID_GAME = 1, 842 BG_LIMIT_CONTROL_ID_STREAM, 843 BG_LIMIT_CONTROL_ID_TEMP, 844 BG_LIMIT_CONTROL_ID_MODULE_FOREGROUND_OPT, 845 } BgLimitControl; 846 847 typedef enum { 848 BG_LIMIT_OFF = 0, 849 BG_LIMIT_LEVEL_1, 850 BG_LIMIT_LEVEL_2, 851 BG_LIMIT_LEVEL_3, 852 BG_LIMIT_LEVEL_4, 853 BG_LIMIT_LEVEL_5, 854 BG_LIMIT_LEVEL_6, 855 BG_LIMIT_LEVEL_7, 856 BG_LIMIT_LEVEL_8, 857 BG_LIMIT_LEVEL_9, 858 BG_LIMIT_LEVEL_10, 859 BG_LIMIT_LEVEL_11, 860 } BgLimitLevel; 861 862 enum class WapiPskType { 863 WAPI_PSK_ASCII = 0, 864 WAPI_PSK_HEX = 1, 865 }; 866 867 868 typedef struct { 869 std::string ifName; 870 int scene; 871 int rssiThreshold; 872 std::string peerMacaddr; 873 std::string powerParam; 874 int powerParamLen; 875 } WifiLowPowerParam; 876 877 enum class OperationCmd { 878 DHCP_OFFER_ADD, 879 DHCP_OFFER_SIZE_GET, 880 DHCP_OFFER_CLEAR, 881 }; 882 883 enum class WifiSelfcureType { 884 DNS_ABNORMAL, 885 TCP_RX_ABNORMAL, 886 ROAMING_ABNORMAL, 887 GATEWAY_ABNORMAL, 888 DNS_SELFCURE_SUCC, 889 STATIC_IP_SELFCURE_SUCC, 890 REASSOC_SELFCURE_SUCC, 891 RESET_SELFCURE_SUCC, 892 REDHCP_SELFCURE_SUCC, 893 }; 894 } // namespace Wifi 895 } // namespace OHOS 896 #endif 897