9 #ifndef __ewf_adapter_tcp__h__included__
10 #define __ewf_adapter_tcp__h__included__
54 #define EWF_VALIDATE_TCP_SOCKET_POINTER(socket_ptr) \
56 if ((socket_ptr == NULL) || \
57 (socket_ptr->adapter_ptr == NULL)) \
59 EWF_LOG_ERROR("The TCP socket pointer is invalid.\n"); \
60 return EWF_RESULT_INVALID_FUNCTION_ARGUMENT; \
64 #define EWF_ADAPTER_TCP_SOCKET_CONTROL_SET_CONTEXT_ID ("!SetContextId")
65 #define EWF_ADAPTER_TCP_SOCKET_CONTROL_SET_CONNECTION_TIMEOUT ("!SetConnectionTimeout")
66 #define EWF_ADAPTER_TCP_SOCKET_CONTROL_IS_CONNECTED ("!IsConnected")
67 #define EWF_ADAPTER_TCP_SOCKET_CONTROL_IS_BOUND ("!IsBound")
68 #define EWF_ADAPTER_TCP_SOCKET_CONTROL_USES_TLS ("!UsesTLS")
69 #define EWF_ADAPTER_TCP_SOCKET_CONTROL_PEER_ADDRESSS ("!PeerAddress")
70 #define EWF_ADAPTER_TCP_SOCKET_CONTROL_LOCAL_ADDRESSS ("!LocalAddress")
71 #define EWF_ADAPTER_TCP_SOCKET_CONTROL_SENT_BYTES ("!SentBytes")
72 #define EWF_ADAPTER_TCP_SOCKET_CONTROL_RECEIVED_BYTES ("!ReceivedBytes")
80 ewf_result(*control)(
ewf_socket_tcp* socket_ptr,
const char* control_str,
const uint8_t* buffer_ptr, uint32_t* buffer_length_ptr);
The Embedded Wireless Framework.
ewf_result ewf_adapter_tcp_set_tls_configuration(ewf_socket_tcp *socket_ptr, uint32_t tls_configuration_id)
Set the TLS context for the socket.
Definition: ewf_adapter_api_tcp.c:46
ewf_result ewf_adapter_tcp_send(ewf_socket_tcp *socket_ptr, const uint8_t *buffer_ptr, uint32_t buffer_length)
Send data over a TCP socket.
Definition: ewf_adapter_api_tcp.c:100
ewf_result ewf_adapter_tcp_connect(ewf_socket_tcp *socket_ptr, const char *server_str, uint32_t port)
Connect a TCP socket to a server.
Definition: ewf_adapter_api_tcp.c:82
struct _ewf_adapter_api_tcp ewf_adapter_api_tcp
The TCP API structure.
ewf_result ewf_adapter_tcp_listen(ewf_socket_tcp *socket_ptr)
Listens to incomming connections on a socket.
Definition: ewf_adapter_api_tcp.c:64
ewf_result ewf_adapter_tcp_shutdown(ewf_socket_tcp *socket_ptr)
Shutdown a TCP socket.
Definition: ewf_adapter_api_tcp.c:91
ewf_result(* ewf_adapter_tcp_disconnect_callback)(ewf_socket_tcp *socket_ptr)
A function pointer type for TCP disconnect callbacks.
Definition: ewf_adapter_api_tcp.h:43
ewf_result ewf_adapter_tcp_receive_callback_set(ewf_socket_tcp *socket_ptr, ewf_adapter_tcp_receive_callback callback)
Register a user TCP receive callback function.
Definition: ewf_adapter_api_tcp.c:118
ewf_result ewf_adapter_tcp_receive(ewf_socket_tcp *socket_ptr, uint8_t *buffer_ptr, uint32_t *buffer_length, bool wait)
Receive data over a TCP socket.
Definition: ewf_adapter_api_tcp.c:109
ewf_result ewf_adapter_tcp_control(ewf_socket_tcp *socket_ptr, const char *control_str, const uint8_t *buffer_ptr, uint32_t *buffer_length_ptr)
Control a TCP socket This is mainly used to funnel implementation specific functionality.
Definition: ewf_adapter_api_tcp.c:37
ewf_result ewf_adapter_tcp_bind(ewf_socket_tcp *socket_ptr, uint32_t port)
Binds a TCP socket to a port.
Definition: ewf_adapter_api_tcp.c:55
ewf_result ewf_adapter_tcp_accept(ewf_socket_tcp *socket_ptr, ewf_socket_tcp *socket_new_ptr)
Accept a new connection on a listening TCP socket.
Definition: ewf_adapter_api_tcp.c:73
ewf_result ewf_adapter_tcp_close(ewf_socket_tcp *socket_ptr)
Close a TCP socket.
Definition: ewf_adapter_api_tcp.c:28
ewf_result ewf_adapter_tcp_open(ewf_adapter *adapter_ptr, ewf_socket_tcp *socket_ptr)
Open a TCP socket.
Definition: ewf_adapter_api_tcp.c:21
ewf_result(* ewf_adapter_tcp_receive_callback)(ewf_socket_tcp *socket_ptr, const uint8_t *buffer_ptr, uint32_t buffer_length)
A function pointer type for TCP receive callbacks.
Definition: ewf_adapter_api_tcp.h:37
ewf_result ewf_adapter_tcp_disconnect_callback_set(ewf_socket_tcp *socket_ptr, ewf_adapter_tcp_disconnect_callback callback)
Register a user TCP disconnect callback function.
Definition: ewf_adapter_api_tcp.c:125
enum _ewf_result ewf_result
Success and error result codes specific to the EWF API.
The TCP API structure.
Definition: ewf_adapter_api_tcp.h:76
The EWF network adapter control structure definition.
Definition: ewf_adapter.h:50
The TCP socket structure definition.
Definition: ewf_adapter_api_tcp.h:47