nrfxlib API 2.7.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_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)   ((uint16_t) ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8)))
 Host to network byte-orders on half word.
 
#define NRF_HTONL(x)
 Host to network byte-orders on full word.
 
#define NRF_NTOHS(x)   NRF_HTONS(x)
 Network to host byte-orders on half word.
 
#define NRF_NTOHL(x)   NRF_HTONL(x)
 Network to host byte-orders on full word.
 
#define nrf_htons(x)   NRF_HTONS(x)
 
#define nrf_htonl(x)   NRF_HTONL(x)
 
#define nrf_ntohs(x)   NRF_NTOHS(x)
 
#define nrf_ntohl(x)   NRF_NTOHL(x)
 
#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
 Write-only socket option to select the security tags to be used. This option accepts a list of.
 
#define NRF_SO_SEC_HOSTNAME   2
 Socket option to set the hostname used for peer verification. This option accepts a string containing the hostname, and its length. The length may be set to zero to disable hostname verification.
 
#define NRF_SO_SEC_CIPHERSUITE_LIST   3
 Write-only socket option to select which ciphersuites to use. This option accepts a prioritized array of selected cipher suites. See TLS Cipher suites for a list of allowed values.
 
#define NRF_SO_SEC_CIPHERSUITE_USED   4
 Socket option to retrieve the cipher suite used during the TLS/DTLS handshake.
 
#define NRF_SO_SEC_PEER_VERIFY   5
 Socket option to set peer verification level. See TLS peer verification options for a list of allowed values.
 
#define NRF_SO_SEC_ROLE   6
 Write-only socket option to set role for the connection. See Role for the socket connection for a list of allowed values.
 
#define NRF_SO_SEC_SESSION_CACHE   12
 Socket option to control TLS session caching. See TLS session cache options for a list of allowed values.
 
#define NRF_SO_SEC_SESSION_CACHE_PURGE   13
 Socket option to purge session cache immediately. This option accepts any value.
 
#define NRF_SO_SEC_DTLS_HANDSHAKE_TIMEO   14
 Socket option to set DTLS handshake timeout value. See DTLS handshake timeout values for allowed values.
 
#define NRF_SO_SEC_DTLS_CID   15
 Socket option to enable/disable the connection ID. See DTLS Connection ID settings for allowed values.
 
#define NRF_SO_SEC_DTLS_CID_STATUS   16
 Socket option to get the connection ID status. See DTLS Connection ID statuses for allowed values.
 
#define NRF_SO_SEC_DTLS_CONN_SAVE   17
 Socket option to save DTLS connection.
 
#define NRF_SO_SEC_DTLS_CONN_LOAD   18
 Socket option to load DTLS connection.
 
#define NRF_SO_SEC_HANDSHAKE_STATUS   19
 Socket option to get end status of last completed TLS/DTLS handshake procedure. See TLS/DTLS Handshake statuses for allowed values.
 
#define NRF_SO_REUSEADDR   2
 
#define NRF_SO_ERROR   4
 
#define NRF_SO_RCVTIMEO   20
 
#define NRF_SO_SNDTIMEO   21
 
#define NRF_SO_SILENCE_ALL   30
 
#define NRF_SO_IP_ECHO_REPLY   31
 
#define NRF_SO_IPV6_ECHO_REPLY   32
 
#define NRF_SO_EXCEPTIONAL_DATA   33
 
#define NRF_SO_KEEPOPEN   34
 
#define NRF_SO_BINDTOPDN   40
 
#define NRF_SO_TCP_SRV_SESSTIMEO   55
 
#define NRF_SO_POLLCB   60
 
#define NRF_SO_RAI   61
 
#define NRF_SO_RAI_NO_DATA   50
 
#define NRF_SO_RAI_LAST   51
 
#define NRF_SO_RAI_ONE_RESP   52
 
#define NRF_SO_RAI_ONGOING   53
 
#define NRF_SO_RAI_WAIT_MORE   54
 
#define NRF_SOL_SOCKET   1
 
#define NRF_SOL_SECURE   282
 
#define NRF_MSG_PEEK   0x02
 
#define NRF_MSG_DONTWAIT   0x40
 
#define NRF_MSG_WAITALL   0x100
 
#define NRF_MSG_WAITACK   0x200
 
#define NRF_F_GETFL   3
 
#define NRF_F_SETFL   4
 
#define NRF_O_NONBLOCK   0x01
 
#define NRF_RAI_NO_DATA   1
 
#define NRF_RAI_LAST   2
 
#define NRF_RAI_ONE_RESP   3
 
#define NRF_RAI_ONGOING   4
 
#define NRF_RAI_WAIT_MORE   5
 
#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
 
#define NRF_SO_SEC_DTLS_CID_SUPPORTED   1
 
#define NRF_SO_SEC_DTLS_CID_ENABLED   2
 
#define NRF_SO_SEC_DTLS_CID_STATUS_DISABLED   0
 
#define NRF_SO_SEC_DTLS_CID_STATUS_DOWNLINK   1
 
#define NRF_SO_SEC_DTLS_CID_STATUS_UPLINK   2
 
#define NRF_SO_SEC_DTLS_CID_STATUS_BIDIRECTIONAL   3
 
#define NRF_SO_SEC_HANDSHAKE_STATUS_FULL   0
 
#define NRF_SO_SEC_HANDSHAKE_STATUS_CACHED   1
 
#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_AI_CANONNAME   0x2
 
#define NRF_AI_NUMERICSERV   0x400
 
#define NRF_AI_PDNSERV   0x1000
 
#define NRF_POLLIN   0x1
 
#define NRF_POLLOUT   0x4
 
#define NRF_POLLERR   0x8
 
#define NRF_POLLHUP   0x10
 
#define NRF_POLLNVAL   0x20
 

Typedefs

typedef int32_t ssize_t
 
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_role_t
 TLS role for the connection.
 
typedef uint32_t nrf_sec_tag_t
 Security tags used on the TLS socket.
 
typedef uint32_t nrf_sec_session_cache_t
 Session cache configuration for the TLS connection.
 
typedef uint32_t nrf_sec_peer_verify_t
 Peer verification level for the TLS connection.
 
typedef uint32_t nrf_sec_cipher_t
 An IANA cipher suite identifier.
 
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 a secondary DNS address.
 

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.