S2OPC OPCUA Toolkit
Loading...
Searching...
No Matches
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 <limits.h>
31#include <stdbool.h>
32#include <stdint.h>
33#include <stdio.h>
34
36
39{
40 /* TCP UA configuration */
41 uint32_t buffer_size;
46
47 /* OPC UA types configuration */
48 int32_t max_string_length; // reception only
49 int32_t max_array_length; // reception only
53
60
72
80
82#ifndef SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE
83#define SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE UINT16_MAX
84#endif /* SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE */
85
89#ifndef SOPC_DEFAULT_RECEIVE_MAX_NB_CHUNKS
90#define SOPC_DEFAULT_RECEIVE_MAX_NB_CHUNKS 5
91#endif /* SOPC_DEFAULT_RECEIVE_MAX_NB_CHUNKS */
92
96#ifndef SOPC_DEFAULT_RECEIVE_MAX_MESSAGE_LENGTH
97#define SOPC_DEFAULT_RECEIVE_MAX_MESSAGE_LENGTH SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE* SOPC_DEFAULT_RECEIVE_MAX_NB_CHUNKS
98#endif /* SOPC_DEFAULT_RECEIVE_MAX_MESSAGE_LENGTH */
99
103#ifndef SOPC_DEFAULT_SEND_MAX_NB_CHUNKS
104#define SOPC_DEFAULT_SEND_MAX_NB_CHUNKS 12
105#endif /* SOPC_DEFAULT_SEND_MAX_NB_CHUNKS */
106
110#ifndef SOPC_DEFAULT_SEND_MAX_MESSAGE_LENGTH
111#define SOPC_DEFAULT_SEND_MAX_MESSAGE_LENGTH SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE* SOPC_DEFAULT_SEND_MAX_NB_CHUNKS
112#endif /* SOPC_DEFAULT_SEND_MAX_MESSAGE_LENGTH */
113
115#ifndef SOPC_DEFAULT_MAX_STRING_LENGTH
116#define SOPC_DEFAULT_MAX_STRING_LENGTH UINT16_MAX
117#endif /* SOPC_DEFAULT_MAX_STRING_LENGTH */
118
120#ifndef SOPC_DEFAULT_MAX_ARRAY_LENGTH
121#define SOPC_DEFAULT_MAX_ARRAY_LENGTH 1000000
122#endif /* SOPC_DEFAULT_MAX_ARRAY_LENGTH */
123
127#ifndef SOPC_DEFAULT_MAX_DIAG_INFO_NESTED_LEVEL
128#define SOPC_DEFAULT_MAX_DIAG_INFO_NESTED_LEVEL 100
129#endif /* SOPC_DEFAULT_MAX_DIAG_INFO_NESTED_LEVEL */
130
133#ifndef SOPC_DEFAULT_MAX_STRUCT_NESTED_LEVEL
134#define SOPC_DEFAULT_MAX_STRUCT_NESTED_LEVEL 50
135#endif /* SOPC_DEFAULT_MAX_STRUCT_NESTED_LEVEL */
136
137/* @brief Maximum number of elements in Async Queue */
138#ifndef SOPC_MAX_NB_ELEMENTS_ASYNC_QUEUE
139#define SOPC_MAX_NB_ELEMENTS_ASYNC_QUEUE 5000
140#endif /* SOPC_MAX_NB_ELEMENTS_ASYNC_QUEUE */
141
142#ifndef SOPC_MAX_NB_ELEMENTS_ASYNC_QUEUE_WARNING_ONLY
143#define SOPC_MAX_NB_ELEMENTS_ASYNC_QUEUE_WARNING_ONLY true
144#endif /* SOPC_MAX_NB_ELEMENTS_ASYNC_QUEUE_WARNING_ONLY */
145
147#ifndef SOPC_LOG_MAX_USER_LINE_LENGTH
148#define SOPC_LOG_MAX_USER_LINE_LENGTH 512
149#endif /* SOPC_LOG_MAX_USER_LINE_LENGTH */
150
152#ifndef SOPC_HAS_FILESYSTEM
153#define SOPC_HAS_FILESYSTEM true
154#endif /* SOPC_HAS_FILESYSTEM */
155
157#ifndef SOPC_MAX_TIMERS
158#define SOPC_MAX_TIMERS UINT8_MAX /* TODO: avoid static maximum (see monitoredItems Id creation) */
159#endif
160
167#ifndef SOPC_CONSOLE_PRINTF
168#define SOPC_CONSOLE_PRINTF printf
169#endif /* SOPC_CONSOLE_PRINTF */
170
172#ifndef SOPC_IS_LITTLE_ENDIAN
173#define SOPC_IS_LITTLE_ENDIAN 1
174#endif /* SOPC_IS_LITTLE_ENDIAN */
175
179#ifndef SOPC_IS_DOUBLE_MIDDLE_ENDIAN
180#define SOPC_IS_DOUBLE_MIDDLE_ENDIAN 0
181#endif /* SOPC_IS_DOUBLE_MIDDLE_ENDIAN */
182
183/* Check use of uintptr_t is not an issue on the current platform */
184#if UINTPTR_MAX < UINT32_MAX
185#error "UINTPTR_MAX < UINT32_MAX whereas uintptr_t are used to store uint32_t values"
186#endif
187
188/* Check casts from uint32_t / int32_t to size_t are valid without verification */
189#if SIZE_MAX < UINT32_MAX
190#error "SIZE_MAX < UINT32_MAX whereas uint32_t are casted to size_t values"
191#endif
192
193/* Check casts from long to size_t are valid without verification */
194#if SIZE_MAX < LONG_MAX
195#error "SIZE_MAX < LONG_MAX whereas long are casted to size_t values"
196#endif
197
198/* Check that the message buffer is large enough to hold the minimal TCP UA chunk */
199#if SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE < SOPC_TCP_UA_MIN_BUFFER_SIZE
200#error "SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE is not large enough, must be >= SOPC_TCP_UA_MIN_BUFFER_SIZE"
201#endif
202
203/* Check that the message buffer is large enough to hold the minimal TCP UA chunk */
204#if 0 != SOPC_DEFAULT_RECEIVE_MAX_MESSAGE_LENGTH && \
205 (SOPC_DEFAULT_RECEIVE_MAX_MESSAGE_LENGTH < SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE)
206#error "SOPC_DEFAULT_RECEIVE_MAX_MESSAGE_LENGTH is not large enough, must be >= SOPC_TCP_UA_MAX_BUFFER_SIZE"
207#endif
208
209/* Check that both number of chunks and message length are not defined to 0
210 * Note: it is required to have a maximum size of message body buffer defined
211 */
212#if 0 == SOPC_DEFAULT_RECEIVE_MAX_MESSAGE_LENGTH && 0 == SOPC_DEFAULT_RECEIVE_MAX_NB_CHUNKS
213#error \
214 "It is forbidden to define both SOPC_DEFAULT_RECEIVE_MAX_MESSAGE_LENGTH and SOPC_DEFAULT_RECEIVE_MAX_NB_CHUNKS to value 0 (no limit)"
215#endif
216
217/* Check that the message buffer is large enough to hold the minimal TCP UA chunk */
218#if 0 != SOPC_DEFAULT_SEND_MAX_MESSAGE_LENGTH && \
219 (SOPC_DEFAULT_SEND_MAX_MESSAGE_LENGTH < SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE)
220#error "SOPC_DEFAULT_SEND_MAX_MESSAGE_LENGTH is not large enough, must be >= SOPC_DEFAULT_TCP_UA_MAX_BUFFER_SIZE"
221#endif
222
223/* Check that both number of chunks and message length are not defined to 0
224 * Note: it is required to have a maximum size of message body buffer defined
225 */
226#if 0 == SOPC_DEFAULT_SEND_MAX_MESSAGE_LENGTH && 0 == SOPC_DEFAULT_SEND_MAX_NB_CHUNKS
227#error \
228 "It is forbidden to define both SOPC_DEFAULT_SEND_MAX_MESSAGE_LENGTH and SOPC_DEFAULT_SEND_MAX_NB_CHUNKS to value 0 (no limit)"
229#endif
230
231/* \brief Internal use only */
233
234/* \brief Internal use to check properties at runtime */
236
237#endif /* SOPC_COMMON_CONSTANTS_H_ */
SOPC_Common_EncodingConstants SOPC_Common_GetDefaultEncodingConstants(void)
Get the default encoding constants (contains values below by default)
bool SOPC_Common_SetEncodingConstants(SOPC_Common_EncodingConstants config)
Set the encodings constants with current structure value. It shall be done before initialization and ...
struct SOPC_Common_EncodingConstants SOPC_Common_EncodingConstants
Configuration structure of message and types encoding limits.
bool SOPC_Common_EncodingConstantsGetInitialized(void)
Retrieve the S2OPC encoding constants "initialized" state.
const SOPC_Common_EncodingConstants * SOPC_Internal_Common_GetEncodingConstants(void)
bool SOPC_Internal_Common_Constants_RuntimeCheck(void)
OPC-UA specific constants.
Configuration structure of message and types encoding limits.
Definition sopc_common_constants.h:39
uint32_t buffer_size
Definition sopc_common_constants.h:41
uint32_t max_nested_struct
Definition sopc_common_constants.h:51
uint32_t max_nested_diag_info
Definition sopc_common_constants.h:50
uint32_t send_max_nb_chunks
Definition sopc_common_constants.h:45
int32_t max_array_length
Definition sopc_common_constants.h:49
uint32_t send_max_msg_size
Definition sopc_common_constants.h:44
uint32_t receive_max_nb_chunks
Definition sopc_common_constants.h:43
uint32_t receive_max_msg_size
Definition sopc_common_constants.h:42
int32_t max_string_length
Definition sopc_common_constants.h:48