• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2016-2022, 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 
29 /**
30  * @file
31  *   This file includes types and constants for IPv6 processing.
32  */
33 
34 #ifndef IP6_TYPES_HPP_
35 #define IP6_TYPES_HPP_
36 
37 #include "openthread-core-config.h"
38 
39 #include <stddef.h>
40 #include <stdint.h>
41 
42 namespace ot {
43 namespace Ip6 {
44 
45 /**
46  * @addtogroup core-ip6-ip6
47  *
48  * @brief
49  *   This module includes definitions for core IPv6 networking.
50  *
51  * @{
52  */
53 
54 // Internet Protocol Numbers
55 static constexpr uint8_t kProtoHopOpts  = OT_IP6_PROTO_HOP_OPTS; ///< IPv6 Hop-by-Hop Option
56 static constexpr uint8_t kProtoTcp      = OT_IP6_PROTO_TCP;      ///< Transmission Control Protocol
57 static constexpr uint8_t kProtoUdp      = OT_IP6_PROTO_UDP;      ///< User Datagram
58 static constexpr uint8_t kProtoIp6      = OT_IP6_PROTO_IP6;      ///< IPv6 encapsulation
59 static constexpr uint8_t kProtoRouting  = OT_IP6_PROTO_ROUTING;  ///< Routing Header for IPv6
60 static constexpr uint8_t kProtoFragment = OT_IP6_PROTO_FRAGMENT; ///< Fragment Header for IPv6
61 static constexpr uint8_t kProtoIcmp6    = OT_IP6_PROTO_ICMP6;    ///< ICMP for IPv6
62 static constexpr uint8_t kProtoNone     = OT_IP6_PROTO_NONE;     ///< No Next Header for IPv6
63 static constexpr uint8_t kProtoDstOpts  = OT_IP6_PROTO_DST_OPTS; ///< Destination Options for IPv6
64 
65 /**
66  * The max datagram length (in bytes) of an IPv6 message.
67  */
68 static constexpr uint16_t kMaxDatagramLength = OPENTHREAD_CONFIG_IP6_MAX_DATAGRAM_LENGTH;
69 
70 /**
71  * The max datagram length (in bytes) of an unfragmented IPv6 message.
72  */
73 static constexpr uint16_t kMaxAssembledDatagramLength = OPENTHREAD_CONFIG_IP6_MAX_ASSEMBLED_DATAGRAM;
74 
75 /**
76  * 6-bit Differentiated Services Code Point (DSCP) values.
77  */
78 enum IpDscpCs : uint8_t
79 {
80     kDscpCs0    = 0,    ///< Class selector codepoint 0
81     kDscpCs1    = 8,    ///< Class selector codepoint 8
82     kDscpCs2    = 16,   ///< Class selector codepoint 16
83     kDscpCs3    = 24,   ///< Class selector codepoint 24
84     kDscpCs4    = 32,   ///< Class selector codepoint 32
85     kDscpCs5    = 40,   ///< Class selector codepoint 40
86     kDscpCs6    = 48,   ///< Class selector codepoint 48
87     kDscpCs7    = 56,   ///< Class selector codepoint 56
88     kDscpCsMask = 0x38, ///< Class selector mask (0b111000)
89 
90     // DSCP values to use within Thread mesh (from local codepoint space 0bxxxx11 [RFC 2474 - section 6]).
91 
92     kDscpTmfNetPriority    = 0x07, ///< TMF network priority (0b000111).
93     kDscpTmfNormalPriority = 0x0f, ///< TMF normal priority  (0b001111).
94     kDscpTmfLowPriority    = 0x17, ///< TMF low priority     (0b010111).
95 };
96 
97 /**
98  * Represents the 2-bit Explicit Congestion Notification (ECN) values.
99  */
100 enum Ecn : uint8_t
101 {
102     kEcnNotCapable = OT_ECN_NOT_CAPABLE, ///< Non ECN-Capable Transport (ECT).
103     kEcnCapable0   = OT_ECN_CAPABLE_0,   ///< ECN Capable Transport, ECT(0).
104     kEcnCapable1   = OT_ECN_CAPABLE_1,   ///< ECN Capable Transport, ECT(1).
105     kEcnMarked     = OT_ECN_MARKED,      ///< Congestion encountered.
106 };
107 
108 /**
109  * @}
110  */
111 
112 } // namespace Ip6
113 } // namespace ot
114 
115 #endif // IP6_TYPES_HPP_
116