xref: /dpdk/lib/net/rte_dtls.h (revision fba9875559906e04eaeb74532f4cfd51194259a2)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2023 Marvell.
3  */
4 
5 #ifndef RTE_DTLS_H
6 #define RTE_DTLS_H
7 
8 /**
9  * @file
10  *
11  * Datagram transport layer security (DTLS) related defines.
12  */
13 
14 #include <rte_byteorder.h>
15 
16 #define RTE_DTLS_TYPE_INVALID               0 /**< Invalid DTLS message type. */
17 #define RTE_DTLS_TYPE_CHANGE_CIPHER_SPEC   20 /**< Change cipher spec message. */
18 #define RTE_DTLS_TYPE_ALERT                21 /**< Alert message. */
19 #define RTE_DTLS_TYPE_HANDSHAKE            22 /**< Handshake message for DTLS. */
20 #define RTE_DTLS_TYPE_APPDATA              23 /**< DTLS application data message. */
21 #define RTE_DTLS_TYPE_HEARTBEAT            24 /**< DTLS 1.3 heartbeat message. */
22 #define RTE_DTLS_TYPE_CIPHERTEXT_WITH_CID  25 /**< DTLS 1.3 ciphertext with CID message. */
23 #define RTE_DTLS_TYPE_ACK                  26 /**< DTLS 1.3 ACK message. */
24 #define RTE_DTLS_TYPE_MAX                 255 /**< Maximum value as DTLS content type. */
25 
26 #define RTE_DTLS_VERSION_1_2    0xFEFD /**< DTLS 1.2 version. 1's complement of 1.2. */
27 #define RTE_DTLS_VERSION_1_3    0xFEFC /**< DTLS 1.3 version. 1's complement of 1.3. */
28 
29 /**
30  * DTLS Header
31  */
32 __extension__
33 struct __rte_packed_begin rte_dtls_hdr {
34 	/** Content type of DTLS packet. Defined as RTE_DTLS_TYPE_*. */
35 	uint8_t type;
36 	/** DTLS Version defined as RTE_DTLS_VERSION*. */
37 	rte_be16_t version;
38 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
39 	/** The sequence number for the DTLS record. */
40 	uint64_t sequence_number : 48;
41 	/** A counter value that is incremented on every cipher state change. */
42 	uint64_t epoch : 16;
43 #elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
44 	/** A counter value that is incremented on every cipher state change. */
45 	uint64_t epoch : 16;
46 	/** The sequence number for the DTLS record. */
47 	uint64_t sequence_number : 48;
48 #endif
49 	/** The length (in bytes) of the following DTLS packet. */
50 	rte_be16_t length;
51 } __rte_packed_end;
52 
53 #endif /* RTE_DTLS_H */
54