EtcPal  0.4.1
ETC Platform Abstraction Layer (EtcPal)
View other versions:
acn_rlp.h
1 /******************************************************************************
2  * Copyright 2022 ETC Inc.
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  * This file is a part of EtcPal. For more information, go to:
17  * https://github.com/ETCLabs/EtcPal
18  ******************************************************************************/
19 
20 /* etcpal/acn_rlp.h: Functions to parse or pack a Root Layer PDU block (as defined in ANSI
21  * E1.17) and its associated preambles. */
22 
23 #ifndef ETCPAL_ACN_RLP_H_
24 #define ETCPAL_ACN_RLP_H_
25 
26 #include <stdbool.h>
27 #include <stddef.h>
28 #include <stdint.h>
29 #include "etcpal/acn_pdu.h"
30 #include "etcpal/acn_prot.h"
31 #include "etcpal/uuid.h"
32 
50 #define ACN_TCP_PREAMBLE_SIZE 16
52 #define ACN_UDP_PREAMBLE_SIZE 16
54 #define ACN_RLP_HEADER_SIZE_NORMAL_LEN 22
56 #define ACN_RLP_HEADER_SIZE_EXT_LEN 23
57 
64 #define ACN_VECTOR_ROOT_SDT ACN_PROTOCOL_SDT
65 #define ACN_VECTOR_ROOT_DRAFT_E131_DATA ACN_PROTOCOL_DRAFT_E131_DATA
66 #define ACN_VECTOR_ROOT_E131_DATA ACN_PROTOCOL_E131_DATA
67 #define ACN_VECTOR_ROOT_E131_EXTENDED ACN_PROTOCOL_E131_EXTENDED
68 #define ACN_VECTOR_ROOT_LLRP ACN_PROTOCOL_LLRP
69 #define ACN_VECTOR_ROOT_BROKER ACN_PROTOCOL_BROKER
70 #define ACN_VECTOR_ROOT_RPT ACN_PROTOCOL_RPT
71 #define ACN_VECTOR_ROOT_EPT ACN_PROTOCOL_EPT
77 typedef struct AcnTcpPreamble
78 {
80  const uint8_t* rlp_block;
82  size_t rlp_block_len;
84 
86 typedef struct AcnUdpPreamble
87 {
89  const uint8_t* rlp_block;
91  size_t rlp_block_len;
93 
95 typedef struct AcnRootLayerPdu
96 {
100  uint32_t vector;
102  const uint8_t* pdata;
104  size_t data_len;
106 
107 #ifdef __cplusplus
108 extern "C" {
109 #endif
110 
111 bool acn_parse_tcp_preamble(const uint8_t* buf, size_t buflen, AcnTcpPreamble* preamble);
112 bool acn_parse_udp_preamble(const uint8_t* buf, size_t buflen, AcnUdpPreamble* preamble);
113 bool acn_parse_root_layer_header(const uint8_t* buf, size_t buflen, AcnRootLayerPdu* pdu, AcnRootLayerPdu* last_pdu);
114 bool acn_parse_root_layer_pdu(const uint8_t* buf, size_t buflen, AcnRootLayerPdu* pdu, AcnPdu* last_pdu);
115 
116 size_t acn_pack_tcp_preamble(uint8_t* buf, size_t buflen, size_t rlp_block_len);
117 size_t acn_pack_udp_preamble(uint8_t* buf, size_t buflen);
118 size_t acn_root_layer_buf_size(const AcnRootLayerPdu* pdu_block, size_t num_pdus);
119 size_t acn_pack_root_layer_header(uint8_t* buf, size_t buflen, const AcnRootLayerPdu* pdu);
120 size_t acn_pack_root_layer_block(uint8_t* buf, size_t buflen, const AcnRootLayerPdu* pdu_block, size_t num_pdus);
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
130 #endif /* ETCPAL_ACN_RLP_H_ */
bool acn_parse_root_layer_header(const uint8_t *buf, size_t buflen, AcnRootLayerPdu *pdu, AcnRootLayerPdu *last_pdu)
Parse only the header of an ACN Root Layer PDU.
Definition: acn_rlp.c:123
bool acn_parse_udp_preamble(const uint8_t *buf, size_t buflen, AcnUdpPreamble *preamble)
Parse an ACN UDP Preamble.
Definition: acn_rlp.c:91
struct AcnTcpPreamble AcnTcpPreamble
Holds the information contained in an ACN TCP Preamble.
struct AcnRootLayerPdu AcnRootLayerPdu
Holds the information contained in an ACN Root Layer PDU.
size_t acn_pack_root_layer_block(uint8_t *buf, size_t buflen, const AcnRootLayerPdu *pdu_block, size_t num_pdus)
Pack a Root Layer PDU block into a buffer.
Definition: acn_rlp.c:369
size_t acn_pack_tcp_preamble(uint8_t *buf, size_t buflen, size_t rlp_block_len)
Pack an ACN TCP Preamble into a buffer.
Definition: acn_rlp.c:280
size_t acn_root_layer_buf_size(const AcnRootLayerPdu *pdu_block, size_t num_pdus)
Get the buffer size to allocate for a Root Layer PDU block.
Definition: acn_rlp.c:303
bool acn_parse_tcp_preamble(const uint8_t *buf, size_t buflen, AcnTcpPreamble *preamble)
Parse an ACN TCP Preamble.
Definition: acn_rlp.c:65
bool acn_parse_root_layer_pdu(const uint8_t *buf, size_t buflen, AcnRootLayerPdu *pdu, AcnPdu *last_pdu)
Parse an ACN Root Layer PDU.
Definition: acn_rlp.c:222
struct AcnUdpPreamble AcnUdpPreamble
Holds the information contained in an ACN UDP Preamble.
size_t acn_pack_udp_preamble(uint8_t *buf, size_t buflen)
Pack an ACN UDP Preamble into a buffer.
Definition: acn_rlp.c:253
size_t acn_pack_root_layer_header(uint8_t *buf, size_t buflen, const AcnRootLayerPdu *pdu)
Pack only the header of a Root Layer PDU block into a buffer.
Definition: acn_rlp.c:329
Holds state data used when parsing multiple PDUs in a PDU block.
Definition: acn_pdu.h:162
Holds the information contained in an ACN Root Layer PDU.
Definition: acn_rlp.h:96
const uint8_t * pdata
A pointer to the Data segment of this PDU.
Definition: acn_rlp.h:102
EtcPalUuid sender_cid
The CID of the component that sent this Root Layer PDU.
Definition: acn_rlp.h:98
uint32_t vector
The Vector indicates the type of data contained in the Data segment.
Definition: acn_rlp.h:100
size_t data_len
The length of the Data segment of this PDU.
Definition: acn_rlp.h:104
Holds the information contained in an ACN TCP Preamble.
Definition: acn_rlp.h:78
const uint8_t * rlp_block
Pointer to the beginning of the Root Layer PDU block.
Definition: acn_rlp.h:80
size_t rlp_block_len
Length of the Root Layer PDU block.
Definition: acn_rlp.h:82
Holds the information contained in an ACN UDP Preamble.
Definition: acn_rlp.h:87
const uint8_t * rlp_block
Pointer to the beginning of the Root Layer PDU block.
Definition: acn_rlp.h:89
size_t rlp_block_len
Length of the Root Layer PDU block.
Definition: acn_rlp.h:91
The UUID type.
Definition: uuid.h:93