Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / include / platform / internal / DeviceNetworkInfo.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    Copyright (c) 2018 Nest Labs, Inc.
5  *    All rights reserved.
6  *
7  *    Licensed under the Apache License, Version 2.0 (the "License");
8  *    you may not use this file except in compliance with the License.
9  *    You may obtain a copy of the License at
10  *
11  *        http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *    Unless required by applicable law or agreed to in writing, software
14  *    distributed under the License is distributed on an "AS IS" BASIS,
15  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *    See the License for the specific language governing permissions and
17  *    limitations under the License.
18  */
19
20 #pragma once
21
22 #include <stddef.h>
23 #include <stdint.h>
24
25 namespace chip {
26 namespace DeviceLayer {
27 namespace Internal {
28
29 /**
30  * Constants for common network metadata entries
31  */
32 // ---- WiFi-specific Limits ----
33 constexpr size_t kMaxWiFiSSIDLength = 32;
34 constexpr size_t kMaxWiFiKeyLength  = 64;
35
36 // ---- Thread-specific Limits ----
37 constexpr size_t kMaxThreadNetworkNameLength = 16;
38 constexpr size_t kThreadExtendedPANIdLength  = 8;
39 constexpr size_t kThreadMeshPrefixLength     = 8;
40 constexpr size_t kThreadMasterKeyLength      = 16;
41 constexpr size_t kThreadPSKcLength           = 16;
42 constexpr size_t kThreadChannel_NotSpecified = UINT8_MAX;
43 constexpr size_t kThreadPANId_NotSpecified   = UINT16_MAX;
44
45 /**
46  * Ids for well-known network provision types.
47  */
48 enum
49 {
50     kThreadNetworkId      = 1,
51     kWiFiStationNetworkId = 2,
52 };
53
54 /**
55  * WiFi Security Modes.
56  */
57 enum WiFiAuthSecurityType : int8_t
58 {
59     kWiFiSecurityType_NotSpecified = -1,
60
61     kWiFiSecurityType_None                = 1,
62     kWiFiSecurityType_WEP                 = 2,
63     kWiFiSecurityType_WPAPersonal         = 3,
64     kWiFiSecurityType_WPA2Personal        = 4,
65     kWiFiSecurityType_WPA2MixedPersonal   = 5,
66     kWiFiSecurityType_WPAEnterprise       = 6,
67     kWiFiSecurityType_WPA2Enterprise      = 7,
68     kWiFiSecurityType_WPA2MixedEnterprise = 8,
69     kWiFiSecurityType_WPA3Personal        = 9,
70     kWiFiSecurityType_WPA3MixedPersonal   = 10,
71     kWiFiSecurityType_WPA3Enterprise      = 11,
72     kWiFiSecurityType_WPA3MixedEnterprise = 12,
73 };
74
75 class DeviceNetworkInfo
76 {
77 public:
78     uint32_t NetworkId; /**< The network id assigned to the network by the device. */
79
80     struct
81     {
82         bool NetworkId : 1;           /**< True if the NetworkId field is present. */
83         bool ThreadExtendedPANId : 1; /**< True if the ThreadExtendedPANId field is present. */
84         bool ThreadMeshPrefix : 1;    /**< True if the ThreadMeshPrefix field is present. */
85         bool ThreadPSKc : 1;          /**< True if the ThreadPSKc field is present. */
86     } FieldPresent;
87
88     // ---- WiFi-specific Fields ----
89     char WiFiSSID[kMaxWiFiSSIDLength + 1]; /**< The WiFi SSID as a NULL-terminated string. */
90     uint8_t WiFiKey[kMaxWiFiKeyLength];    /**< The WiFi key (NOT NULL-terminated). */
91     uint8_t WiFiKeyLen;                    /**< The length in bytes of the WiFi key. */
92     WiFiAuthSecurityType WiFiSecurityType; /**< The WiFi security type. */
93
94     // ---- Thread-specific Fields ----
95     char ThreadNetworkName[kMaxThreadNetworkNameLength + 1];
96     /**< The Thread network name as a NULL-terminated string. */
97     uint8_t ThreadExtendedPANId[kThreadExtendedPANIdLength];
98     /**< The Thread extended PAN ID. */
99     uint8_t ThreadMeshPrefix[kThreadMeshPrefixLength];
100     /**< The Thread mesh prefix. */
101     uint8_t ThreadMasterKey[kThreadMasterKeyLength];
102     /**< The Thread master key (NOT NULL-terminated). */
103     uint8_t ThreadPSKc[kThreadPSKcLength];
104     /**< The Thread pre-shared commissioner key (NOT NULL-terminated). */
105     uint16_t ThreadPANId;            /**< The 16-bit Thread PAN ID, or kThreadPANId_NotSpecified */
106     uint8_t ThreadChannel;           /**< The Thread channel (currently [11..26]), or kThreadChannel_NotSpecified */
107     uint64_t ThreadDatasetTimestamp; /**< Thread active dataset timestamp */
108 };
109
110 } // namespace Internal
111 } // namespace DeviceLayer
112 } // namespace chip