Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / controller / python / chip / internal / thread.py
1 #
2 #    Copyright (c) 2021 Project CHIP Authors
3 #
4 #    Licensed under the Apache License, Version 2.0 (the "License");
5 #    you may not use this file except in compliance with the License.
6 #    You may obtain a copy of the License at
7 #
8 #        http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #    Unless required by applicable law or agreed to in writing, software
11 #    distributed under the License is distributed on an "AS IS" BASIS,
12 #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #    See the License for the specific language governing permissions and
14 #    limitations under the License.
15 #
16
17 # Contains type definition to help with thread credentials.
18 # Generally thread credentials are assumed to be binary objects, however for 
19 # testing purposes, we expose the internal structure here.
20
21 from construct import BitStruct, Byte, Bytes, Enum, Flag, Int16ul, Int32ul, Int64ul, PaddedString, Padding, Struct
22
23 ThreadDeviceNetworkInfo = Struct(
24     "NetworkId" / Int32ul,
25     "FieldPresent" / BitStruct (
26         "NetworkId" / Flag,
27         "ThreadExtendedPANId" / Flag,
28         "ThreadMeshPrefix" / Flag,
29         "ThreadPSKc" / Flag,
30         "Padding" / Padding(4),
31     ),
32     "WiFiSSID" / PaddedString(33, 'utf8'),
33     "WiFikey" / Bytes(64),
34     "WiFiKeyLen" / Byte,
35     "WiFiAuthSecurityType" / Enum(Byte, 
36        # NotAvailable is the same as None/NotSpecified in DeviceNetworkInfo.h
37        # Used this name because 'None' is reserved in python
38        NotAvailable        = 1, 
39        WEP                 = 2,
40        WPAPersonal         = 3,
41        WPA2Personal        = 4,
42        WPA2MixedPersonal   = 5,
43        WPAEnterprise       = 6,
44        WPA2Enterprise      = 7,
45        WPA2MixedEnterprise = 8,
46        WPA3Personal        = 9,
47        WPA3MixedPersonal   = 10,
48        WPA3Enterprise      = 11,
49        WPA3MixedEnterprise = 12,
50     ),
51     "ThreadNetworkName" / PaddedString(17, 'utf8'),
52     "ThreadExtendedPANId" / Bytes(8),
53     "ThreadMeshPrefix" / Bytes(8),
54     "ThreadMasterKey" / Bytes(16),
55     "ThreadPSKc" / Bytes(16),
56     "_ThreadPANIdPadding" / Padding(1), # Aligns ThreadPANId
57     "ThreadPANId" / Int16ul,
58     "ThreadChannel" / Byte,
59     "_ThreadDatasetTimestampPadding" / Padding(3), # Aligns ThreadDAtasetTimestamp
60     "ThreadDatasetTimestamp" / Int64ul,
61 )
62