nrfxlib API 3.3.99
Loading...
Searching...
No Matches
nrf_socket.h File Reference
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  nrf_modem_sendcb_params
 This structure is used to describe the parameters to a send callback function. More...
 
struct  nrf_modem_sendcb
 
struct  nrf_timeval
 Structure specifying time interval. More...
 
struct  nrf_in6_addr
 IPv6 address. More...
 
struct  nrf_in_addr
 IPv4 address structure. More...
 
struct  nrf_sockaddr_in6
 Address record for IPv6 addresses. More...
 
struct  nrf_sockaddr_in
 Address record for IPv4 addresses. More...
 
struct  nrf_sockaddr
 Generic socket address. More...
 
struct  nrf_addrinfo
 Address information. More...
 
struct  nrf_ifaddrs
 Interface address information. More...
 
struct  nrf_pollfd
 This structure is used to describe which events to poll for a given socket. More...
 
struct  nrf_modem_pollcb
 

Macros

#define NRF_MODEM_MAX_SOCKET_COUNT   8
 
#define NRF_HTONS(x)
 Host to network byte-orders on half word.
 
#define NRF_HTONL(x)
 Host to network byte-orders on full word.
 
#define NRF_NTOHS(x)
 Network to host byte-orders on half word.
 
#define NRF_NTOHL(x)
 Network to host byte-orders on full word.
 
#define nrf_htons(x)
 Convert byte order from host to network (short).
 
#define nrf_htonl(x)
 Convert byte order from host to network (long).
 
#define nrf_ntohs(x)
 Convert byte order from network to host (short).
 
#define nrf_ntohl(x)
 Convert byte order from network to host (long).
 
#define NRF_INET_ADDRSTRLEN   16
 Maximum length of IPv4 in string form, including null-termination character.
 
#define NRF_INET6_ADDRSTRLEN   46
 Maximum length of IPv6 in string form, including null-termination character.
 
#define NRF_AF_UNSPEC   0
 
#define NRF_AF_INET   1
 
#define NRF_AF_INET6   2
 
#define NRF_AF_PACKET   3
 
#define NRF_SOCK_STREAM   1
 
#define NRF_SOCK_DGRAM   2
 
#define NRF_SOCK_RAW   3
 
#define NRF_IPPROTO_IP   0
 
#define NRF_IPPROTO_TCP   6
 
#define NRF_IPPROTO_UDP   17
 
#define NRF_IPPROTO_IPV6   41
 
#define NRF_IPPROTO_RAW   255
 
#define NRF_IPPROTO_ALL   512
 
#define NRF_SPROTO_TLS1v2   258
 
#define NRF_SPROTO_DTLS1v2   273
 
#define NRF_SOCKET_TLS_MAX_MESSAGE_SIZE   2048
 Maximum TLS message size in bytes.
 
#define NRF_SOCKET_TLS_MAX_SEC_TAG_LIST_SIZE   7
 Maximum number of security tags that can be associated with a socket.
 
#define NRF_SO_SEC_TAG_LIST   1
 Select an array of security tags to use for credentials when connecting.
 
#define NRF_SO_SEC_HOSTNAME   2
 Configure the hostname used for peer verification.
 
#define NRF_SO_SEC_CIPHERSUITE_LIST   3
 Select which cipher suites are allowed to be used during the TLS handshake.
 
#define NRF_SO_SEC_CIPHERSUITE_USED   4
 Retrieve the cipher suite used during the TLS/DTLS handshake (Read-only).
 
#define NRF_SO_SEC_PEER_VERIFY   5
 Configure peer verification level.
 
#define NRF_SO_SEC_ROLE   6
 Configure the role for the connection.
 
#define NRF_SO_SEC_SESSION_CACHE   12
 Enable/disable TLS session caching.
 
#define NRF_SO_SEC_SESSION_CACHE_PURGE   13
 Purge TLS session cache (write-only).
 
#define NRF_SO_SEC_DTLS_HANDSHAKE_TIMEO   14
 Configure the DTLS handshake timeout value.
 
#define NRF_SO_SEC_DTLS_CID   15
 Enable/disable the DTLS connection ID.
 
#define NRF_SO_SEC_DTLS_CID_STATUS   16
 Get the DTLS connection ID status (read-only).
 
#define NRF_SO_SEC_DTLS_CONN_SAVE   17
 Save DTLS connection (Write-only).
 
#define NRF_SO_SEC_DTLS_CONN_LOAD   18
 load DTLS connection (Write-only)
 
#define NRF_SO_SEC_HANDSHAKE_STATUS   19
 Get the end status of the last completed TLS/DTLS handshake procedure (Read-only).
 
#define NRF_SO_SEC_DTLS_FRAG_EXT   20
 Enable/disable the DTLS fragmentation extension.
 
#define NRF_SO_REUSEADDR   2
 Enable reuse of server addresses (write-only).
 
#define NRF_SO_ERROR   4
 Request and clear pending error information on the socket (read-only).
 
#define NRF_SO_RCVTIMEO   20
 Timeout value for a socket receive and accept operations.
 
#define NRF_SO_SNDTIMEO   21
 Timeout value for a socket send operation.
 
#define NRF_SO_SILENCE_ALL   30
 Disable ICMP echo replies on both IPv4 and IPv6.
 
#define NRF_SO_IP_ECHO_REPLY   31
 Enable ICMP echo replies on IPv4.
 
#define NRF_SO_IPV6_ECHO_REPLY   32
 Enable ICMP echo replies on IPv6.
 
#define NRF_SO_EXCEPTIONAL_DATA   33
 Send data on a socket as part of an exceptional event.
 
#define NRF_SO_KEEPOPEN   34
 Keep the socket open when its PDN connection is lost, or the device is set to flight mode.
 
#define NRF_SO_BINDTOPDN   40
 Bind a socket to a Packet Data Network (PDN) ID (write-only)
 
#define NRF_SO_TCP_SRV_SESSTIMEO   55
 Configure the TCP server session inactivity timeout for a socket.
 
#define NRF_SO_POLLCB   60
 Set a callback for nrf_poll events on sockets (write-only).
 
#define NRF_SO_RAI   61
 Release Assistance Indication (RAI) (write-only).
 
#define NRF_SO_IPV6_DELAYED_ADDR_REFRESH   62
 Delay IPv6 address refresh during power saving mode.
 
#define NRF_SO_SENDCB   63
 Callback to be called when a send request is acknowledged.
 
#define NRF_SOL_SOCKET   1
 
#define NRF_SOL_SECURE   282
 
#define NRF_MSG_PEEK   0x02
 Return data from the beginning of receive queue without removing data from the input queue.
 
#define NRF_MSG_DONTWAIT   0x40
 Enables non-blocking operation for this specific function call.
 
#define NRF_MSG_WAITALL   0x100
 Requests that the function blocks read operation until the full amount of data requested has been received.
 
#define NRF_MSG_WAITACK   0x200
 Request a blocking send operation until the request is acknowledged.
 
#define NRF_F_GETFL   3
 
#define NRF_F_SETFL   4
 
#define NRF_O_NONBLOCK   0x01
 
#define NRF_RAI_NO_DATA   1
 Indicate that the application does not intend to send more data.
 
#define NRF_RAI_LAST   2
 Indicate that the application does not intend to send more data after the next call to nrf_send() or nrf_sendto().
 
#define NRF_RAI_ONE_RESP   3
 Indicate that the application is expecting to receive just one data packet after the next call to nrf_send() or nrf_sendto().
 
#define NRF_RAI_ONGOING   4
 Indicate that the socket is in active use by a client application.
 
#define NRF_RAI_WAIT_MORE   5
 Indicate that the socket is in active use by a server application.
 
#define NRF_SO_SEC_PEER_VERIFY_NONE   0
 
#define NRF_SO_SEC_PEER_VERIFY_OPTIONAL   1
 
#define NRF_SO_SEC_PEER_VERIFY_REQUIRED   2
 
#define NRF_SO_SEC_ROLE_CLIENT   0
 
#define NRF_SO_SEC_ROLE_SERVER   1
 
#define NRF_SO_SEC_SESSION_CACHE_DISABLED   0
 
#define NRF_SO_SEC_SESSION_CACHE_ENABLED   1
 
#define NRF_SO_SEC_DTLS_HANDSHAKE_TIMEOUT_NONE   0
 
#define NRF_SO_SEC_DTLS_HANDSHAKE_TIMEOUT_1S   1
 
#define NRF_SO_SEC_DTLS_HANDSHAKE_TIMEOUT_3S   3
 
#define NRF_SO_SEC_DTLS_HANDSHAKE_TIMEOUT_7S   7
 
#define NRF_SO_SEC_DTLS_HANDSHAKE_TIMEOUT_15S   15
 
#define NRF_SO_SEC_DTLS_HANDSHAKE_TIMEOUT_31S   31
 
#define NRF_SO_SEC_DTLS_HANDSHAKE_TIMEOUT_63S   63
 
#define NRF_SO_SEC_DTLS_HANDSHAKE_TIMEOUT_123S   123
 
#define NRF_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384   0xC024
 
#define NRF_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA   0xC00A
 
#define NRF_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256   0xC023
 
#define NRF_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA   0xC009
 
#define NRF_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA   0xC014
 
#define NRF_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256   0xC027
 
#define NRF_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA   0xC013
 
#define NRF_TLS_PSK_WITH_AES_256_CBC_SHA   0x008D
 
#define NRF_TLS_PSK_WITH_AES_128_CBC_SHA256   0x00AE
 
#define NRF_TLS_PSK_WITH_AES_128_CBC_SHA   0x008C
 
#define NRF_TLS_PSK_WITH_AES_128_CCM_8   0xC0A8
 
#define NRF_TLS_EMPTY_RENEGOTIATIONINFO_SCSV   0x00FF
 
#define NRF_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256   0xC02B
 
#define NRF_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384   0xC030
 
#define NRF_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256   0xC02F
 
#define NRF_SO_SEC_DTLS_CID_DISABLED   0
 Disabled - The connection ID extension is not included in the Client Hello, so the DTLS connection ID is not used.
 
#define NRF_SO_SEC_DTLS_CID_SUPPORTED   1
 Supported - The connection ID extension with a zero-length CID is included in the Client Hello, so the modem will accept a DTLS connection ID from the server.
 
#define NRF_SO_SEC_DTLS_CID_ENABLED   2
 Enabled - The connection ID extension with a valid CID is included in the Client Hello, so the modem will request DTLS connection ID support.
 
#define NRF_SO_SEC_DTLS_CID_STATUS_DISABLED   0
 Disabled - The DTLS connection ID is not included in DTLS records sent to and from the modem. This status is returned before the DTLS handshake is complete.
 
#define NRF_SO_SEC_DTLS_CID_STATUS_DOWNLINK   1
 Downlink - The DTLS connection ID is included only in DTLS records sent to the modem.
 
#define NRF_SO_SEC_DTLS_CID_STATUS_UPLINK   2
 Uplink - The DTLS connection ID is included only in DTLS records sent from the modem.
 
#define NRF_SO_SEC_DTLS_CID_STATUS_BIDIRECTIONAL   3
 Bidirectional - The DTLS connection ID is included in DTLS records sent to and from the modem.
 
#define NRF_SO_SEC_HANDSHAKE_STATUS_FULL   0
 Full handshake.
 
#define NRF_SO_SEC_HANDSHAKE_STATUS_CACHED   1
 The latest TLS/DTLS attach negotiation was completed successfully with cached session data.
 
#define NRF_SO_SEC_DTLS_FRAG_EXT_DISABLED   0
 Disabled - The DTLS fragmentation extension is not included in the Client Hello.
 
#define NRF_SO_SEC_DTLS_FRAG_EXT_512_ENABLED   1
 Enabled - The DTLS fragmentation extension is included in the Client Hello with the fragment size of 512 bytes.
 
#define NRF_SO_SEC_DTLS_FRAG_EXT_1024_ENABLED   2
 Enabled - The DTLS fragmentation extension is included in the Client Hello with the fragment size of 1024 bytes.
 
#define NRF_SEC_TAG_TLS_DECRYPT_BASE   2147483648
 
#define NRF_SEC_TAG_TLS_DECRYPT_0   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 0)
 
#define NRF_SEC_TAG_TLS_DECRYPT_1   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 1)
 
#define NRF_SEC_TAG_TLS_DECRYPT_2   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 2)
 
#define NRF_SEC_TAG_TLS_DECRYPT_3   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 3)
 
#define NRF_SEC_TAG_TLS_DECRYPT_4   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 4)
 
#define NRF_SEC_TAG_TLS_DECRYPT_5   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 5)
 
#define NRF_SEC_TAG_TLS_DECRYPT_6   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 6)
 
#define NRF_SEC_TAG_TLS_DECRYPT_7   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 7)
 
#define NRF_SEC_TAG_TLS_DECRYPT_8   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 8)
 
#define NRF_SEC_TAG_TLS_DECRYPT_9   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 9)
 
#define NRF_SEC_TAG_TLS_DECRYPT_10   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 10)
 
#define NRF_SEC_TAG_TLS_DECRYPT_11   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 11)
 
#define NRF_SEC_TAG_TLS_DECRYPT_12   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 12)
 
#define NRF_SEC_TAG_TLS_DECRYPT_13   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 13)
 
#define NRF_SEC_TAG_TLS_DECRYPT_14   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 14)
 
#define NRF_SEC_TAG_TLS_DECRYPT_15   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 15)
 
#define NRF_SEC_TAG_TLS_DECRYPT_16   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 16)
 
#define NRF_SEC_TAG_TLS_DECRYPT_17   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 17)
 
#define NRF_SEC_TAG_TLS_DECRYPT_18   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 18)
 
#define NRF_SEC_TAG_TLS_DECRYPT_19   (NRF_SEC_TAG_TLS_DECRYPT_BASE + 19)
 
#define NRF_SEC_TAG_TLS_INVALID   0xFFFFFFFF
 
#define NRF_AI_CANONNAME   0x2
 
#define NRF_AI_NUMERICSERV   0x400
 
#define NRF_AI_PDNSERV   0x1000
 
#define NRF_POLLIN   0x1
 Data other than high-priority data may be read without blocking.
 
#define NRF_POLLOUT   0x4
 Data may be written without blocking.
 
#define NRF_POLLERR   0x8
 An error has occurred (revents only)
 
#define NRF_POLLHUP   0x10
 Device has been disconnected (revents only)
 
#define NRF_POLLNVAL   0x20
 Invalid fd member (revents only)
 

Typedefs

typedef int32_t ssize_t
 
typedef void(* nrf_modem_sendcb_t) (const struct nrf_modem_sendcb_params *params)
 
typedef uint16_t nrf_in_port_t
 Socket port type.
 
typedef unsigned short int nrf_sa_family_t
 Socket families.
 
typedef uint32_t nrf_in_addr_t
 IPv4 address.
 
typedef uint32_t nrf_socklen_t
 
typedef uint32_t nrf_nfds_t
 
typedef uint32_t nrf_sec_tag_t
 Security tags used on the TLS socket.
 
typedef void(* nrf_modem_pollcb_t) (struct nrf_pollfd *pollfd)
 

Functions

int nrf_socket (int family, int type, int protocol)
 Create a network socket.
 
int nrf_close (int fildes)
 Close a network socket.
 
int nrf_fcntl (int fd, int cmd, int flags)
 Function for controlling file descriptor options.
 
int nrf_connect (int socket, const struct nrf_sockaddr *address, nrf_socklen_t address_len)
 Connect a socket.
 
ssize_t nrf_send (int socket, const void *buffer, size_t length, int flags)
 Send a message on a connected socket.
 
ssize_t nrf_sendto (int socket, const void *message, size_t length, int flags, const struct nrf_sockaddr *dest_addr, nrf_socklen_t dest_len)
 Send a message on a socket.
 
ssize_t nrf_recv (int socket, void *buffer, size_t length, int flags)
 Receive a message from a connected socket.
 
ssize_t nrf_recvfrom (int socket, void *restrict buffer, size_t length, int flags, struct nrf_sockaddr *restrict address, nrf_socklen_t *restrict address_len)
 Receive a message from a socket.
 
int nrf_poll (struct nrf_pollfd fds[], nrf_nfds_t nfds, int timeout)
 Poll multiple sockets for events.
 
int nrf_setsockopt (int socket, int level, int option_name, const void *option_value, nrf_socklen_t option_len)
 Set the socket options.
 
int nrf_getsockopt (int socket, int level, int option_name, void *restrict option_value, nrf_socklen_t *restrict option_len)
 Get the socket options.
 
int nrf_bind (int socket, const struct nrf_sockaddr *address, nrf_socklen_t address_len)
 Bind a name to a socket.
 
int nrf_listen (int sock, int backlog)
 Listen for socket connections and limit the queue of incoming connections.
 
int nrf_accept (int socket, struct nrf_sockaddr *restrict address, nrf_socklen_t *restrict address_len)
 Accept a new connection a socket.
 
int nrf_inet_pton (int af, const char *restrict src, void *restrict dst)
 Convert IPv4 and IPv6 addresses between binary and text form.
 
const char * nrf_inet_ntop (int af, const void *restrict src, char *restrict dst, nrf_socklen_t size)
 Convert IPv4 and IPv6 addresses between binary and text form.
 
int nrf_getaddrinfo (const char *restrict nodename, const char *restrict servname, const struct nrf_addrinfo *restrict hints, struct nrf_addrinfo **restrict res)
 Get address information.
 
void nrf_freeaddrinfo (struct nrf_addrinfo *ai)
 Free address information returned by nrf_getaddrinfo().
 
int nrf_getifaddrs (struct nrf_ifaddrs **ifa)
 Get interface address information.
 
void nrf_freeifaddrs (struct nrf_ifaddrs *ifa)
 Free address information returned by nrf_getifaddrs().
 
int nrf_setdnsaddr (int family, const void *in_addr, nrf_socklen_t in_size)
 Set or unset a fallback DNS address.
 
int nrf_socket_data_enabled_set (bool enabled)
 Enable or disable data traffic through the socket interface.
 
bool nrf_socket_data_enabled_get (void)
 Get the current data enabled state.
 

Variables

const struct nrf_in6_addr nrf_in6addr_any
 Global IPv6 any-address.
 
const struct nrf_in_addr nrf_inaddr_any
 Global IPv4 any-address.