S2OPC OPCUA Toolkit
Loading...
Searching...
No Matches
sopc_sockets_internal_ctx.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
20#ifndef SOPC_SOCKETS_INTERNAL_CTX_H_
21#define SOPC_SOCKETS_INTERNAL_CTX_H_
22
23#include <stdbool.h>
24
25#include "sopc_async_queue.h"
26#include "sopc_event_handler.h"
27#include "sopc_mutexes.h"
28#include "sopc_raw_sockets.h"
29#include "sopc_sockets_api.h"
31
42
43typedef struct SOPC_InternalSocket
44{
45 uint32_t socketIdx; /* Index in the socket array */
46 uint32_t connectionId; /* High-level associated connection id
47 (secure channel connection index when state = CONNECTING/CONNECTED only
48 OR endpoint description configuration index when state = LISTENING only) */
51 bool isNotWritable; // Indicates when a write attempt blocked, the flag is set until a write event occurs on socket
52 bool isUsed; /* Indicates if the socket is free (false) or used (true) */
53 // false if it is a client connection, otherwise it is a server connection (linked to a listener)
56 // addresses for connection
57 void* connectAddrs; // Possible connection addresses (to free on connection)
58 void* curConnectAttemptAddr; // Current connection attempt address
59 void* nextConnectAttemptAddr; // Next connection attempt address
60 // number of connection for a listener (state = LISTENING)
62 // define if isServerConnection != false
64 // socket address
67
70
72
73extern uint32_t maxBufferSize;
74
77
80
86
90
94void SOPC_Sockets_Emit(SOPC_Sockets_OutputEvent event, uint32_t eltId, uintptr_t params, uintptr_t auxParam);
95
100 uint32_t id,
101 uintptr_t params,
102 uintptr_t auxParam);
103
109
110#endif /* SOPC_SOCKETS_INTERNAL_CTX_H_ */
An asynchronous and thread-safe queue implementation.
struct SOPC_AsyncQueue SOPC_AsyncQueue
Definition sopc_async_queue.h:31
enum _SOPC_ReturnStatus SOPC_ReturnStatus
Common enumerations for S2OPC.
struct _SOPC_EventHandler SOPC_EventHandler
Processes messages from a queue.
Definition sopc_event_handler.h:35
A platform independent API to use sockets.
Event oriented API of the Services layer.
SOPC_Sockets_OutputEvent
Definition sopc_sockets_api.h:75
SOPC_Sockets_InputEvent
Definition sopc_sockets_api.h:37
void SOPC_SocketsInternalContext_Clear(void)
Clear the array of sockets.
SOPC_Socket_State
Definition sopc_sockets_internal_ctx.h:33
@ SOCKET_STATE_LISTENING
Definition sopc_sockets_internal_ctx.h:39
@ SOCKET_STATE_CONNECTING
Definition sopc_sockets_internal_ctx.h:35
@ SOCKET_STATE_CLOSED
Definition sopc_sockets_internal_ctx.h:34
@ SOCKET_STATE_ACCEPTED
Definition sopc_sockets_internal_ctx.h:40
@ SOCKET_STATE_CONNECTED
Definition sopc_sockets_internal_ctx.h:37
SOPC_ReturnStatus SOPC_Sockets_EnqueueInputEvent(SOPC_Sockets_InputEvent socketEvent, uint32_t id, uintptr_t params, uintptr_t auxParam)
Enqueues an input event to the queue of events managed by the socket event manager.
void SOPC_Sockets_Emit(SOPC_Sockets_OutputEvent event, uint32_t eltId, uintptr_t params, uintptr_t auxParam)
Emits an output event to the recorded output event handler socketsEventHandler.
SOPC_InternalSocket * SOPC_SocketsInternalContext_GetFreeSocket(bool isListener)
Returns an unused socket from the array of sockets or NULL if none available In case socket is not a ...
SOPC_EventHandler * socketsEventHandler
struct SOPC_InternalSocket SOPC_InternalSocket
uint32_t maxBufferSize
SOPC_InternalSocket socketsArray[SOPC_MAX_SOCKETS]
Array containing all sockets that can be used.
void SOPC_SocketsInternalContext_Initialize(void)
Initialize the array of sockets.
SOPC_ReturnStatus SOPC_Sockets_DequeueAndDispatchInputEvent(void)
Dequeues an input event of the queue of events and call the event dispatcher of the socket event mana...
void SOPC_SocketsInternalContext_CloseSocket(uint32_t socketIdx)
Close the socket and set it as not used anymore.
Contains the configuration constants used by the Tookit. Those constants could be modified for specif...
#define SOPC_MAX_SOCKETS
Maximum number of TCP sockets (listeners and connections)
Definition sopc_toolkit_config_constants.h:49
Definition sopc_sockets_internal_ctx.h:44
bool isServerConnection
Definition sopc_sockets_internal_ctx.h:54
uint32_t connectionId
Definition sopc_sockets_internal_ctx.h:46
uint32_t listenerConnections
Definition sopc_sockets_internal_ctx.h:61
void * curConnectAttemptAddr
Definition sopc_sockets_internal_ctx.h:58
void * connectAddrs
Definition sopc_sockets_internal_ctx.h:57
SOPC_Socket_Address * addr
Definition sopc_sockets_internal_ctx.h:65
bool isNotWritable
Definition sopc_sockets_internal_ctx.h:51
SOPC_Socket_State state
Definition sopc_sockets_internal_ctx.h:55
bool isUsed
Definition sopc_sockets_internal_ctx.h:52
SOPC_AsyncQueue * writeQueue
Definition sopc_sockets_internal_ctx.h:50
uint32_t socketIdx
Definition sopc_sockets_internal_ctx.h:45
uint32_t listenerSocketIdx
Definition sopc_sockets_internal_ctx.h:63
void * nextConnectAttemptAddr
Definition sopc_sockets_internal_ctx.h:59
SOPC_Socket sock
Definition sopc_sockets_internal_ctx.h:49
Socket address information on a connected socket.
Definition p_sopc_sockets.h:55
Socket base type.
Definition p_sopc_sockets.h:36