S2OPC OPCUA Toolkit
sopc_common_constants.h
Go to the documentation of this file.
1 /*
2  * Licensed to Systerel under one or more contributor license
3  * agreements. See the NOTICE file distributed with this work
4  * for additional information regarding copyright ownership.
5  * Systerel licenses this file to you under the Apache
6  * License, Version 2.0 (the "License"); you may not use this
7  * file except in compliance with the License. You may obtain
8  * a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
27 #ifndef SOPC_COMMON_CONSTANTS_H_
28 #define SOPC_COMMON_CONSTANTS_H_
29 
30 #include <stdbool.h>
31 #include <stdint.h>
32 
34 
37 {
38  /* TCP UA configuration */
39  uint32_t buffer_size;
44 
45  /* OPC UA types configuration */
46  int32_t max_string_length; // reception only
47  int32_t max_array_length; // reception only
51 
58 
70 
72 #ifndef SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE
73 #define SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE UINT16_MAX
74 #endif /* SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE */
75 
79 #ifndef SOPC_DEFAULT_RECEIVE_MAX_NB_CHUNKS
80 #define SOPC_DEFAULT_RECEIVE_MAX_NB_CHUNKS 5
81 #endif /* SOPC_DEFAULT_RECEIVE_MAX_NB_CHUNKS */
82 
86 #ifndef SOPC_DEFAULT_RECEIVE_MAX_MESSAGE_LENGTH
87 #define SOPC_DEFAULT_RECEIVE_MAX_MESSAGE_LENGTH SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE* SOPC_DEFAULT_RECEIVE_MAX_NB_CHUNKS
88 #endif /* SOPC_DEFAULT_RECEIVE_MAX_MESSAGE_LENGTH */
89 
93 #ifndef SOPC_DEFAULT_SEND_MAX_NB_CHUNKS
94 #define SOPC_DEFAULT_SEND_MAX_NB_CHUNKS 12
95 #endif /* SOPC_DEFAULT_SEND_MAX_NB_CHUNKS */
96 
100 #ifndef SOPC_DEFAULT_SEND_MAX_MESSAGE_LENGTH
101 #define SOPC_DEFAULT_SEND_MAX_MESSAGE_LENGTH SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE* SOPC_DEFAULT_SEND_MAX_NB_CHUNKS
102 #endif /* SOPC_DEFAULT_SEND_MAX_MESSAGE_LENGTH */
103 
105 #ifndef SOPC_DEFAULT_MAX_STRING_LENGTH
106 #define SOPC_DEFAULT_MAX_STRING_LENGTH UINT16_MAX
107 #endif /* SOPC_DEFAULT_MAX_STRING_LENGTH */
108 
110 #ifndef SOPC_DEFAULT_MAX_ARRAY_LENGTH
111 #define SOPC_DEFAULT_MAX_ARRAY_LENGTH 1000000
112 #endif /* SOPC_DEFAULT_MAX_ARRAY_LENGTH */
113 
117 #ifndef SOPC_DEFAULT_MAX_DIAG_INFO_NESTED_LEVEL
118 #define SOPC_DEFAULT_MAX_DIAG_INFO_NESTED_LEVEL 100
119 #endif /* SOPC_DEFAULT_MAX_DIAG_INFO_NESTED_LEVEL */
120 
123 #ifndef SOPC_DEFAULT_MAX_STRUCT_NESTED_LEVEL
124 #define SOPC_DEFAULT_MAX_STRUCT_NESTED_LEVEL 50
125 #endif /* SOPC_DEFAULT_MAX_STRUCT_NESTED_LEVEL */
126 
127 /* @brief Maximum number of elements in Async Queue */
128 #ifndef SOPC_MAX_NB_ELEMENTS_ASYNC_QUEUE
129 #define SOPC_MAX_NB_ELEMENTS_ASYNC_QUEUE 5000
130 #endif /* SOPC_MAX_NB_ELEMENTS_ASYNC_QUEUE */
131 
132 #ifndef SOPC_MAX_NB_ELEMENTS_ASYNC_QUEUE_WARNING_ONLY
133 #define SOPC_MAX_NB_ELEMENTS_ASYNC_QUEUE_WARNING_ONLY true
134 #endif /* SOPC_MAX_NB_ELEMENTS_ASYNC_QUEUE_WARNING_ONLY */
135 
137 #ifndef SOPC_LOG_MAX_USER_LINE_LENGTH
138 #define SOPC_LOG_MAX_USER_LINE_LENGTH 512
139 #endif /* SOPC_LOG_MAX_USER_LINE_LENGTH */
140 
142 #ifndef SOPC_HAS_FILESYSTEM
143 #define SOPC_HAS_FILESYSTEM true
144 #endif /* SOPC_HAS_FILESYSTEM */
145 
147 #ifndef SOPC_MAX_TIMERS
148 #define SOPC_MAX_TIMERS UINT8_MAX /* TODO: avoid static maximum (see monitoredItems Id creation) */
149 #endif
150 
157 #ifndef SOPC_CONSOLE_PRINTF
158 #define SOPC_CONSOLE_PRINTF printf
159 #endif /* SOPC_CONSOLE_PRINTF */
160 
161 /* Check use of uintptr_t is not an issue on the current platform */
162 #if UINTPTR_MAX < UINT32_MAX
163 #error "UINTPTR_MAX < UINT32_MAX whereas uintptr_t are used to store uint32_t values"
164 #endif
165 
166 /* Check casts from uint32_t / int32_t to size_t are valid without verification */
167 #if SIZE_MAX < UINT32_MAX
168 #error "SIZE_MAX < UINT32_MAX whereas uint32_t are casted to size_t values"
169 #endif
170 
171 /* Check casts from long to size_t are valid without verification */
172 #if SIZE_MAX < LONG_MAX
173 #error "SIZE_MAX < LONG_MAX whereas long are casted to size_t values"
174 #endif
175 
176 /* Check that the message buffer is large enough to hold the minimal TCP UA chunk */
177 #if SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE < SOPC_TCP_UA_MIN_BUFFER_SIZE
178 #error "SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE is not large enough, must be >= SOPC_TCP_UA_MIN_BUFFER_SIZE"
179 #endif
180 
181 /* Check that the message buffer is large enough to hold the minimal TCP UA chunk */
182 #if 0 != SOPC_DEFAULT_RECEIVE_MAX_MESSAGE_LENGTH && \
183  (SOPC_DEFAULT_RECEIVE_MAX_MESSAGE_LENGTH < SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE)
184 #error "SOPC_DEFAULT_RECEIVE_MAX_MESSAGE_LENGTH is not large enough, must be >= SOPC_TCP_UA_MAX_BUFFER_SIZE"
185 #endif
186 
187 /* Check that both number of chunks and message length are not defined to 0
188  * Note: it is required to have a maximum size of message body buffer defined
189  */
190 #if 0 == SOPC_DEFAULT_RECEIVE_MAX_MESSAGE_LENGTH && 0 == SOPC_DEFAULT_RECEIVE_MAX_NB_CHUNKS
191 #error \
192  "It is forbidden to define both SOPC_DEFAULT_RECEIVE_MAX_MESSAGE_LENGTH and SOPC_DEFAULT_RECEIVE_MAX_NB_CHUNKS to value 0 (no limit)"
193 #endif
194 
195 /* Check that the message buffer is large enough to hold the minimal TCP UA chunk */
196 #if 0 != SOPC_DEFAULT_SEND_MAX_MESSAGE_LENGTH && \
197  (SOPC_DEFAULT_SEND_MAX_MESSAGE_LENGTH < SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE)
198 #error "SOPC_DEFAULT_SEND_MAX_MESSAGE_LENGTH is not large enough, must be >= SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE"
199 #endif
200 
201 /* Check that both number of chunks and message length are not defined to 0
202  * Note: it is required to have a maximum size of message body buffer defined
203  */
204 #if 0 == SOPC_DEFAULT_SEND_MAX_MESSAGE_LENGTH && 0 == SOPC_DEFAULT_SEND_MAX_NB_CHUNKS
205 #error \
206  "It is forbidden to define both SOPC_DEFAULT_SEND_MAX_MESSAGE_LENGTH and SOPC_DEFAULT_SEND_MAX_NB_CHUNKS to value 0 (no limit)"
207 #endif
208 
209 /* \brief Internal use only */
211 
212 /* \brief Internal use to check properties at runtime */
214 
215 #endif /* SOPC_COMMON_CONSTANTS_H_ */
SOPC_Common_EncodingConstants
struct SOPC_Common_EncodingConstants SOPC_Common_EncodingConstants
Configuration structure of message and types encoding limits.
SOPC_Common_EncodingConstants::max_nested_struct
uint32_t max_nested_struct
Definition: sopc_common_constants.h:49
SOPC_Internal_Common_Constants_RuntimeCheck
bool SOPC_Internal_Common_Constants_RuntimeCheck(void)
SOPC_Internal_Common_GetEncodingConstants
const SOPC_Common_EncodingConstants * SOPC_Internal_Common_GetEncodingConstants(void)
SOPC_Common_SetEncodingConstants
bool SOPC_Common_SetEncodingConstants(SOPC_Common_EncodingConstants config)
Set the encodings constants with current structure value. It shall be done before initialization and ...
SOPC_Common_EncodingConstants::max_array_length
int32_t max_array_length
Definition: sopc_common_constants.h:47
SOPC_Common_EncodingConstants::receive_max_msg_size
uint32_t receive_max_msg_size
Definition: sopc_common_constants.h:40
SOPC_Common_GetDefaultEncodingConstants
SOPC_Common_EncodingConstants SOPC_Common_GetDefaultEncodingConstants(void)
Get the default encoding constants (contains values below by default)
sopc_protocol_constants.h
OPC-UA specific constants.
SOPC_Common_EncodingConstants::buffer_size
uint32_t buffer_size
Definition: sopc_common_constants.h:39
SOPC_Common_EncodingConstants::receive_max_nb_chunks
uint32_t receive_max_nb_chunks
Definition: sopc_common_constants.h:41
SOPC_Common_EncodingConstants::max_string_length
int32_t max_string_length
Definition: sopc_common_constants.h:46
SOPC_Common_EncodingConstants
Configuration structure of message and types encoding limits.
Definition: sopc_common_constants.h:37
SOPC_Common_EncodingConstants::send_max_nb_chunks
uint32_t send_max_nb_chunks
Definition: sopc_common_constants.h:43
SOPC_Common_EncodingConstants::send_max_msg_size
uint32_t send_max_msg_size
Definition: sopc_common_constants.h:42
SOPC_Common_EncodingConstants::max_nested_diag_info
uint32_t max_nested_diag_info
Definition: sopc_common_constants.h:48