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