1"""
2  Copyright (c) 2024, The OpenThread Authors.
3  All rights reserved.
4
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are met:
7  1. Redistributions of source code must retain the above copyright
8     notice, this list of conditions and the following disclaimer.
9  2. Redistributions in binary form must reproduce the above copyright
10     notice, this list of conditions and the following disclaimer in the
11     documentation and/or other materials provided with the distribution.
12  3. Neither the name of the copyright holder nor the
13     names of its contributors may be used to endorse or promote products
14     derived from this software without specific prior written permission.
15
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  POSSIBILITY OF SUCH DAMAGE.
27"""
28
29from enum import Enum
30
31
32class MeshcopTlvType(Enum):
33    CHANNEL = 0
34    PANID = 1
35    EXTPANID = 2
36    NETWORKNAME = 3
37    PSKC = 4
38    NETWORKKEY = 5
39    NETWORK_KEY_SEQUENCE = 6
40    MESHLOCALPREFIX = 7
41    STEERING_DATA = 8
42    BORDER_AGENT_RLOC = 9
43    COMMISSIONER_ID = 10
44    COMM_SESSION_ID = 11
45    SECURITYPOLICY = 12
46    GET = 13
47    ACTIVETIMESTAMP = 14
48    COMMISSIONER_UDP_PORT = 15
49    STATE = 16
50    JOINER_DTLS = 17
51    JOINER_UDP_PORT = 18
52    JOINER_IID = 19
53    JOINER_RLOC = 20
54    JOINER_ROUTER_KEK = 21
55    PROVISIONING_URL = 32
56    VENDOR_NAME_TLV = 33
57    VENDOR_MODEL_TLV = 34
58    VENDOR_SW_VERSION_TLV = 35
59    VENDOR_DATA_TLV = 36
60    VENDOR_STACK_VERSION_TLV = 37
61    UDP_ENCAPSULATION_TLV = 48
62    IPV6_ADDRESS_TLV = 49
63    PENDINGTIMESTAMP = 51
64    DELAYTIMER = 52
65    CHANNELMASK = 53
66    COUNT = 54
67    PERIOD = 55
68    SCAN_DURATION = 56
69    ENERGY_LIST = 57
70    DISCOVERYREQUEST = 128
71    DISCOVERYRESPONSE = 129
72    JOINERADVERTISEMENT = 241
73
74    @classmethod
75    def from_value(cls, value: int):
76        return cls._value2member_map_.get(value)
77
78    def to_bytes(self):
79        return bytes([self.value])
80