9 #ifndef __ewf_adapter_bsd_sockets__h__included__
10 #define __ewf_adapter_bsd_sockets__h__included__
12 #include <sys/types.h>
13 #include <sys/socket.h>
14 #include <netinet/in.h>
33 #ifndef EWF_ADAPTER_BSD_SOCKETS_TCP_ENABLED
34 #define EWF_ADAPTER_BSD_SOCKETS_TCP_ENABLED (1)
37 #ifndef EWF_ADAPTER_BSD_SOCKETS_UDP_ENABLED
38 #define EWF_ADAPTER_BSD_SOCKETS_UDP_ENABLED (1)
86 #if EWF_ADAPTER_BSD_SOCKETS_TCP_ENABLED
92 ewf_result ewf_adapter_bsd_sockets_tcp_control(
ewf_socket_tcp* socket_ptr,
const char* control_str,
const uint8_t* buffer_ptr, uint32_t* buffer_length_ptr);
93 ewf_result ewf_adapter_bsd_sockets_tcp_set_tls_configuration(
ewf_socket_tcp* socket_ptr, uint32_t tls_configuration_id);
99 ewf_result ewf_adapter_bsd_sockets_tcp_send(
ewf_socket_tcp* socket_ptr,
const uint8_t* buffer_ptr, uint32_t buffer_length);
100 ewf_result ewf_adapter_bsd_sockets_tcp_receive(
ewf_socket_tcp* socket_ptr, uint8_t* buffer_ptr, uint32_t* buffer_length,
bool wait);
112 #if EWF_ADAPTER_BSD_SOCKETS_UDP_ENABLED
118 ewf_result ewf_adapter_bsd_sockets_udp_control(
ewf_socket_udp* socket_ptr,
const char* control_str,
const uint8_t* buffer_ptr, uint32_t* buffer_length_ptr);
119 ewf_result ewf_adapter_bsd_sockets_udp_set_dtls_configuration(
ewf_socket_udp* socket_ptr, uint32_t dtls_configuration_id);
122 ewf_result ewf_adapter_bsd_sockets_udp_send_to(
ewf_socket_udp* socket_ptr,
const char* remote_address_str, uint32_t remote_port,
const uint8_t* buffer_ptr, uint32_t buffer_length);
123 ewf_result ewf_adapter_bsd_sockets_udp_receive_from(
ewf_socket_udp* socket_ptr,
char* remote_address, uint32_t* remote_address_length_ptr, uint32_t* remote_port_ptr,
char* buffer_ptr, uint32_t* buffer_length_ptr,
bool wait);
151 struct in_addr ipv4_address;
152 struct in_addr ipv4_netmask;
153 struct in_addr ipv4_gateway;
154 struct in_addr ipv4_dns;
166 #ifdef EWF_PARAMETER_CHECKING
167 #define EWF_ADAPTER_BSD_SOCKETS_INITIALIZE_HEADER(adapter_ptr) \
169 (adapter_ptr)->struct_magic = EWF_ADAPTER_STRUCT_MAGIC; \
170 (adapter_ptr)->struct_size = EWF_ADAPTER_STRUCT_SIZE; \
171 (adapter_ptr)->struct_version = EWF_ADAPTER_VERSION; \
172 (adapter_ptr)->struct_type = EWF_ADAPTER_TYPE_BSD_SOCKETS; \
175 #define EWF_ADAPTER_BSD_SOCKETS_INITIALIZE_HEADER(adapter_ptr)
178 #if EWF_ADAPTER_BSD_SOCKETS_TCP_ENABLED
179 #define EWF_ADAPTER_BSD_SOCKETS_INITIALIZE_TCP_API(adapter_ptr) \
181 adapter_ptr->tcp_api_ptr = &ewf_adapter_bsd_sockets_api_tcp; \
184 #define EWF_ADAPTER_BSD_SOCKETS_INITIALIZE_TCP_API(adapter_ptr)
187 #if EWF_ADAPTER_BSD_SOCKETS_UDP_ENABLED
188 #define EWF_ADAPTER_BSD_SOCKETS_INITIALIZE_UDP_API(adapter_ptr) \
190 adapter_ptr->udp_api_ptr = &ewf_adapter_bsd_sockets_api_udp; \
193 #define EWF_ADAPTER_BSD_SOCKETS_INITIALIZE_UDP_API(adapter_ptr)
196 #if EWF_ADAPTER_BSD_SOCKETS_TLS_BASIC_ENABLED
197 #define EWF_ADAPTER_BSD_SOCKETS_INITIALIZE_TLS_BASIC_API(adapter_ptr) \
199 adapter_ptr->tls_basic_api_ptr = &ewf_adapter_bsd_sockets_api_tls_basic; \
202 #define EWF_ADAPTER_BSD_SOCKETS_INITIALIZE_TLS_BASIC_API(adapter_ptr)
205 #if EWF_ADAPTER_BSD_SOCKETS_MQTT_BASIC_ENABLED
206 #define EWF_ADAPTER_BSD_SOCKETS_INITIALIZE_MQTT_BASIC_API(adapter_ptr) \
208 adapter_ptr->mqtt_basic_api_ptr = &ewf_adapter_bsd_sockets_api_mqtt_basic; \
211 #define EWF_ADAPTER_BSD_SOCKETS_INITIALIZE_MQTT_BASIC_API(adapter_ptr)
220 #define EWF_ADAPTER_BSD_SOCKETS_STATIC_DECLARE(adapter_ptr, adapter_name_symb, data_allocator_ptr_param) \
222 static ewf_adapter_bsd_sockets ewf_adapter_bsd_sockets__implementation__##adapter_name_symb = {0}; \
223 static ewf_adapter ewf_adapter_bsd_sockets__##adapter_name_symb = {0}; \
224 ewf_adapter_bsd_sockets__##adapter_name_symb.implementation_ptr = &(ewf_adapter_bsd_sockets__implementation__##adapter_name_symb); \
225 adapter_ptr = &(ewf_adapter_bsd_sockets__##adapter_name_symb); \
226 EWF_ADAPTER_BSD_SOCKETS_INITIALIZE_HEADER(adapter_ptr); \
227 ewf_adapter_bsd_sockets__##adapter_name_symb.control_api_ptr = &ewf_adapter_bsd_sockets_api_control; \
228 ewf_adapter_bsd_sockets__##adapter_name_symb.info_api_ptr = &ewf_adapter_bsd_sockets_api_info; \
229 EWF_ADAPTER_BSD_SOCKETS_INITIALIZE_TCP_API(adapter_ptr); \
230 EWF_ADAPTER_BSD_SOCKETS_INITIALIZE_UDP_API(adapter_ptr); \
231 EWF_ADAPTER_BSD_SOCKETS_INITIALIZE_TLS_BASIC_API(adapter_ptr); \
232 EWF_ADAPTER_BSD_SOCKETS_INITIALIZE_MQTT_BASIC_API(adapter_ptr); \
The Embedded Wireless Framework adapter API implementation.
struct _ewf_adapter_bsd_sockets ewf_adapter_bsd_sockets
The BSD sockets adapter driver data structure.
struct _ewf_adapter_bsd_sockets_socket ewf_adapter_bsd_sockets_socket
Internal structure for socket status
enum _ewf_result ewf_result
Success and error result codes specific to the EWF API.
The adapter control API type.
Definition: ewf_adapter_api_control.h:28
Definition: ewf_adapter_api_info.h:26
The TCP API structure.
Definition: ewf_adapter_api_tcp.h:76
The UDP API type.
Definition: ewf_adapter_api_udp.h:63
Internal structure for socket status
Definition: ewf_adapter_bsd_sockets.h:143
The BSD sockets adapter driver data structure.
Definition: ewf_adapter_bsd_sockets.h:150
The EWF network adapter control structure definition.
Definition: ewf_adapter.h:50
The TCP socket structure definition.
Definition: ewf_adapter_api_tcp.h:47
The UDP socket structure definition.
Definition: ewf_adapter_api_udp.h:40