Mbed OS Reference
Loading...
Searching...
No Matches

Mbed OS Socket API. More...

Modules

 Network Interfaces
 Network Interface classes.
 

Data Structures

class  CellularNonIPSocket
 Socket implementation for cellular Non-IP data delivery(NIDD). More...
 
class  DNS
 Base class for DNS provider. More...
 
class  DTLSSocket
 DTLSSocket implement DTLS stream over UDP Socket. More...
 
class  DTLSSocketWrapper
 DTLSSocketWrapper implement DTLS stream over the existing Socket transport. More...
 
class  ICMPSocket
 ICMP socket implementation. More...
 
class  InternetDatagramSocket
 InternetDatagramSocket socket implementation. More...
 
class  InternetSocket
 Socket implementation that uses IP network stack. More...
 
class  NetworkStack
 NetworkStack class. More...
 
struct  nsapi_addr
 IP address structure for passing IP addresses by value. More...
 
struct  nsapi_wifi_ap
 nsapi_wifi_ap structure More...
 
struct  nsapi_stack
 nsapi_stack structure More...
 
struct  nsapi_ip_mreq
 nsapi_ip_mreq structure More...
 
struct  nsapi_latency_req
 nsapi_latency_req structure More...
 
struct  nsapi_stagger_req
 nsapi_stagger_req structure More...
 
struct  nsapi_msghdr
 Header structure for control info. More...
 
struct  nsapi_pktinfo
 nsapi_pktinfo structure More...
 
struct  nsapi_stack_api
 nsapi_stack_api structure More...
 
class  Socket
 Socket interface. More...
 
class  SocketAddress
 SocketAddress class. More...
 
class  TCPSocket
 TCP socket connection. More...
 
class  TLSSocket
 TLSSocket is a wrapper around TCPSocket for interacting with TLS servers. More...
 
class  TLSSocketWrapper
 TLSSocket is a wrapper around Socket for interacting with TLS servers. More...
 
class  UDPSocket
 UDP socket implementation. More...
 

Macros

#define NSAPI_INTERFACE_PREFIX_SIZE   2
 Size of 2 char network interface name from driver. More...
 
#define NSAPI_INTERFACE_NAME_MAX_SIZE   6
 Maximum size of network interface name. More...
 
#define NSAPI_IP_SIZE   NSAPI_IPv6_SIZE
 Maximum size of IP address representation. More...
 
#define NSAPI_IP_BYTES   NSAPI_IPv6_BYTES
 Maximum number of bytes for IP address. More...
 
#define NSAPI_HOSTNAME_SIZE   64
 Maximum size of hostname. More...
 
#define NSAPI_MAC_SIZE   18
 Maximum size of MAC address representation. More...
 
#define NSAPI_MAC_BYTES   6
 Maximum number of bytes for MAC address. More...
 
#define NSAPI_IPv4_SIZE   16
 Size of IPv4 representation. More...
 
#define NSAPI_IPv4_BYTES   4
 Number of bytes in IPv4 address. More...
 
#define NSAPI_IPv6_SIZE   40
 Size of IPv6 representation. More...
 
#define NSAPI_IPv6_BYTES   16
 Number of bytes in IPv6 address. More...
 

Typedefs

typedef signed int nsapi_error_t
 Type used to represent error codes. More...
 
typedef unsigned int nsapi_size_t
 Type used to represent the size of data passed through sockets. More...
 
typedef signed int nsapi_size_or_error_t
 Type used to represent either a size or error passed through sockets. More...
 
typedef signed int nsapi_value_or_error_t
 Type used to represent either a value or error. More...
 
typedef enum nsapi_security nsapi_security_t
 Enum of encryption types. More...
 
typedef struct nsapi_addr nsapi_addr_t
 IP address structure for passing IP addresses by value. More...
 
typedef void * nsapi_socket_t
 Opaque handle for network sockets. More...
 
typedef struct nsapi_wifi_ap nsapi_wifi_ap_t
 nsapi_wifi_ap structure More...
 
typedef struct nsapi_stack nsapi_stack_t
 nsapi_stack structure More...
 
typedef struct nsapi_ip_mreq nsapi_ip_mreq_t
 nsapi_ip_mreq structure More...
 
typedef struct nsapi_latency_req nsapi_latency_req_t
 nsapi_latency_req structure More...
 
typedef struct nsapi_stagger_req nsapi_stagger_req_t
 nsapi_stagger_req structure More...
 
typedef struct nsapi_msghdr nsapi_msghdr_t
 Header structure for control info. More...
 
typedef struct nsapi_pktinfo nsapi_pktinfo_t
 nsapi_pktinfo structure More...
 
typedef struct nsapi_stack_api nsapi_stack_api_t
 nsapi_stack_api structure More...
 

Enumerations

enum  nsapi_error {
  NSAPI_ERROR_OK = 0 , NSAPI_ERROR_WOULD_BLOCK = -3001 , NSAPI_ERROR_UNSUPPORTED = -3002 , NSAPI_ERROR_PARAMETER = -3003 ,
  NSAPI_ERROR_NO_CONNECTION = -3004 , NSAPI_ERROR_NO_SOCKET = -3005 , NSAPI_ERROR_NO_ADDRESS = -3006 , NSAPI_ERROR_NO_MEMORY = -3007 ,
  NSAPI_ERROR_NO_SSID = -3008 , NSAPI_ERROR_DNS_FAILURE = -3009 , NSAPI_ERROR_DHCP_FAILURE = -3010 , NSAPI_ERROR_AUTH_FAILURE = -3011 ,
  NSAPI_ERROR_DEVICE_ERROR = -3012 , NSAPI_ERROR_IN_PROGRESS = -3013 , NSAPI_ERROR_ALREADY = -3014 , NSAPI_ERROR_IS_CONNECTED = -3015 ,
  NSAPI_ERROR_CONNECTION_LOST = -3016 , NSAPI_ERROR_CONNECTION_TIMEOUT = -3017 , NSAPI_ERROR_ADDRESS_IN_USE = -3018 , NSAPI_ERROR_TIMEOUT = -3019 ,
  NSAPI_ERROR_BUSY = -3020
}
 Enum of standardized error codes. More...
 
enum  nsapi_connection_status { NSAPI_STATUS_LOCAL_UP = 0 , NSAPI_STATUS_GLOBAL_UP = 1 , NSAPI_STATUS_DISCONNECTED = 2 , NSAPI_STATUS_CONNECTING = 3 , NSAPI_STATUS_ERROR_UNSUPPORTED = NSAPI_ERROR_UNSUPPORTED }
 Enum of connection status types. More...
 
enum  nsapi_event { NSAPI_EVENT_CONNECTION_STATUS_CHANGE = 0 , NSAPI_EVENT_CELLULAR_STATUS_BASE = 0x1000 , NSAPI_EVENT_CELLULAR_STATUS_END = 0x1FFF }
 Enum of event types. More...
 
enum  nsapi_security {
  NSAPI_SECURITY_NONE = 0x0 , NSAPI_SECURITY_WEP = 0x1 , NSAPI_SECURITY_WPA = 0x2 , NSAPI_SECURITY_WPA2 = 0x3 ,
  NSAPI_SECURITY_WPA_WPA2 = 0x4 , NSAPI_SECURITY_PAP = 0x5 , NSAPI_SECURITY_CHAP = 0x6 , NSAPI_SECURITY_EAP_TLS = 0x7 ,
  NSAPI_SECURITY_PEAP = 0x8 , NSAPI_SECURITY_WPA2_ENT = 0x9 , NSAPI_SECURITY_WPA3 = 0xA , NSAPI_SECURITY_WPA3_WPA2 = 0xB ,
  NSAPI_SECURITY_UNKNOWN = 0xFF
}
 Enum of encryption types. More...
 
enum  nsapi_version { NSAPI_UNSPEC , NSAPI_IPv4 , NSAPI_IPv6 }
 Enum of IP address versions. More...
 
enum  nsapi_protocol { NSAPI_TCP , NSAPI_UDP , NSAPI_ICMP }
 Enum of socket protocols. More...
 
enum  nsapi_stack_level { NSAPI_STACK = 5000 }
 Enum of standardized stack option levels for use with NetworkStack::setstackopt and getstackopt. More...
 
enum  nsapi_stack_option { NSAPI_IPV4_MRU , NSAPI_IPV6_MRU }
 Enum of standardized stack option names for level NSAPI_STACK of NetworkStack::setstackopt and getstackopt. More...
 
enum  nsapi_socket_level { NSAPI_SOCKET = 7000 }
 Enum of standardized socket option levels for use with Socket::setsockopt and getsockopt. More...
 
enum  nsapi_socket_option {
  NSAPI_REUSEADDR , NSAPI_KEEPALIVE , NSAPI_KEEPIDLE , NSAPI_KEEPINTVL ,
  NSAPI_LINGER , NSAPI_SNDBUF , NSAPI_RCVBUF , NSAPI_ADD_MEMBERSHIP ,
  NSAPI_DROP_MEMBERSHIP , NSAPI_BIND_TO_DEVICE , NSAPI_LATENCY , NSAPI_STAGGER ,
  NSAPI_IPTOS , NSAPI_BROADCAST , NSAPI_PKTINFO
}
 Enum of standardized socket option names for level NSAPI_SOCKET of Socket::setsockopt and getsockopt. More...
 
enum  nsapi_tlssocket_level { NSAPI_TLSSOCKET_LEVEL = 7099 }
 
enum  nsapi_tlssocket_option {
  NSAPI_TLSSOCKET_SET_HOSTNAME , NSAPI_TLSSOCKET_SET_CACERT , NSAPI_TLSSOCKET_SET_CLCERT , NSAPI_TLSSOCKET_SET_CLKEY ,
  NSAPI_TLSSOCKET_ENABLE
}
 
enum  nsapi_ip_stack
 Supported IP protocol versions of IP stack. More...
 

Functions

NetworkStacknsapi_create_stack (nsapi_stack_t *stack)
 Convert a raw nsapi_stack_t object into a C++ NetworkStack object. More...
 
nsapi_error_t nsapi_dns_query (NetworkStack *stack, const char *host, SocketAddress *addr, nsapi_version_t version=NSAPI_IPv4)
 Query a domain name server for an IP address of a given hostname. More...
 
nsapi_error_t nsapi_dns_query (NetworkStack *stack, const char *host, SocketAddress *addr, const char *interface_name, nsapi_version_t version=NSAPI_IPv4)
 Query a domain name server for an IP address of a given hostname using Network interface name. More...
 
nsapi_error_t nsapi_dns_query_async (NetworkStack *stack, const char *host, NetworkStack::hostbyname_cb_t callback, NetworkStack::call_in_callback_cb_t call_in_cb, nsapi_version_t version=NSAPI_IPv4)
 Query a domain name server for an IP address of a given hostname. More...
 
nsapi_error_t nsapi_dns_query_async (NetworkStack *stack, const char *host, NetworkStack::hostbyname_cb_t callback, NetworkStack::call_in_callback_cb_t call_in_cb, const char *interface_name, nsapi_version_t version=NSAPI_IPv4)
 Query a domain name server for an IP address of a given hostname using Network interface name. More...
 
nsapi_error_t nsapi_dns_query (nsapi_stack_t *stack, const char *host, nsapi_addr_t *addr, nsapi_version_t version=NSAPI_IPv4)
 Query a domain name server for an IP address of a given hostname (asynchronous) More...
 
template<typename S >
nsapi_error_t nsapi_dns_query (S *stack, const char *host, SocketAddress *addr, nsapi_version_t version=NSAPI_IPv4)
 Query a domain name server for an IP address of a given hostname. More...
 
nsapi_size_or_error_t nsapi_dns_query_multiple (NetworkStack *stack, const char *host, SocketAddress *addr, nsapi_size_t addr_count, const char *interface_name, nsapi_version_t version=NSAPI_IPv4)
 Query a domain name server for multiple IP address of a given hostname. More...
 
nsapi_size_or_error_t nsapi_dns_query_multiple_async (NetworkStack *stack, const char *host, NetworkStack::hostbyname_cb_t callback, nsapi_size_t addr_count, NetworkStack::call_in_callback_cb_t call_in_cb, const char *interface_name, nsapi_version_t version=NSAPI_IPv4)
 Query a domain name server for an IP address of a given hostname (asynchronous) More...
 
nsapi_size_or_error_t nsapi_dns_query_multiple (nsapi_stack_t *stack, const char *host, nsapi_addr_t *addr, nsapi_size_t addr_count, const char *interface_name, nsapi_version_t version=NSAPI_IPv4)
 Query a domain name server for multiple IP address of a given hostname. More...
 
template<typename S >
nsapi_size_or_error_t nsapi_dns_query_multiple (S *stack, const char *host, SocketAddress *addr, nsapi_size_t addr_count, nsapi_version_t version=NSAPI_IPv4)
 Query a domain name server for multiple IP address of a given hostname. More...
 
nsapi_error_t nsapi_dns_query_async_cancel (nsapi_size_or_error_t id)
 Cancels asynchronous hostname translation. More...
 
void nsapi_dns_call_in_set (NetworkStack::call_in_callback_cb_t callback)
 Set a call in callback. More...
 
void nsapi_dns_reset ()
 nsapi_dns_reset Resets all internal states and frees reserved memory, see NOTE! Can be used to clean up system resources when there is no need for network connections. More...
 
nsapi_error_t nsapi_dns_add_server (nsapi_addr_t addr, const char *interface_name)
 Add a domain name server to list of servers to query. More...
 

Detailed Description

Mbed OS Socket API.

Macro Definition Documentation

◆ NSAPI_INTERFACE_PREFIX_SIZE

#define NSAPI_INTERFACE_PREFIX_SIZE   2

Size of 2 char network interface name from driver.

Definition at line 185 of file nsapi_types.h.

◆ NSAPI_INTERFACE_NAME_MAX_SIZE

#define NSAPI_INTERFACE_NAME_MAX_SIZE   6

Maximum size of network interface name.

Definition at line 189 of file nsapi_types.h.

◆ NSAPI_IP_SIZE

#define NSAPI_IP_SIZE   NSAPI_IPv6_SIZE

Maximum size of IP address representation.

Definition at line 193 of file nsapi_types.h.

◆ NSAPI_IP_BYTES

#define NSAPI_IP_BYTES   NSAPI_IPv6_BYTES

Maximum number of bytes for IP address.

Definition at line 197 of file nsapi_types.h.

◆ NSAPI_HOSTNAME_SIZE

#define NSAPI_HOSTNAME_SIZE   64

Maximum size of hostname.

According to RFC 1034 [1], Section 3.1 "Name space specifications and terminology", 63 is the maximum size of a hostname. +1 for the string terminator.

[1] https://www.rfc-editor.org/rfc/rfc1034

Definition at line 207 of file nsapi_types.h.

◆ NSAPI_MAC_SIZE

#define NSAPI_MAC_SIZE   18

Maximum size of MAC address representation.

Definition at line 211 of file nsapi_types.h.

◆ NSAPI_MAC_BYTES

#define NSAPI_MAC_BYTES   6

Maximum number of bytes for MAC address.

Definition at line 215 of file nsapi_types.h.

◆ NSAPI_IPv4_SIZE

#define NSAPI_IPv4_SIZE   16

Size of IPv4 representation.

Definition at line 219 of file nsapi_types.h.

◆ NSAPI_IPv4_BYTES

#define NSAPI_IPv4_BYTES   4

Number of bytes in IPv4 address.

Definition at line 223 of file nsapi_types.h.

◆ NSAPI_IPv6_SIZE

#define NSAPI_IPv6_SIZE   40

Size of IPv6 representation.

Definition at line 227 of file nsapi_types.h.

◆ NSAPI_IPv6_BYTES

#define NSAPI_IPv6_BYTES   16

Number of bytes in IPv6 address.

Definition at line 231 of file nsapi_types.h.

Typedef Documentation

◆ nsapi_error_t

typedef signed int nsapi_error_t

Type used to represent error codes.

This is a separate type from enum nsapi_error to avoid breaking compatibility in type-sensitive overloads

Definition at line 142 of file nsapi_types.h.

◆ nsapi_size_t

typedef unsigned int nsapi_size_t

Type used to represent the size of data passed through sockets.

Definition at line 146 of file nsapi_types.h.

◆ nsapi_size_or_error_t

typedef signed int nsapi_size_or_error_t

Type used to represent either a size or error passed through sockets.

A valid nsapi_size_or_error_t is either a non-negative size or a negative error code from the nsapi_error_t

Definition at line 153 of file nsapi_types.h.

◆ nsapi_value_or_error_t

typedef signed int nsapi_value_or_error_t

Type used to represent either a value or error.

A valid nsapi_value_or_error_t is either a non-negative value or a negative error code from the nsapi_error_t

Definition at line 160 of file nsapi_types.h.

◆ nsapi_security_t

Enum of encryption types.

The security type specifies a particular security to use when connected to a WiFi network

◆ nsapi_addr_t

typedef struct nsapi_addr nsapi_addr_t

IP address structure for passing IP addresses by value.

◆ nsapi_socket_t

typedef void* nsapi_socket_t

Opaque handle for network sockets.

Definition at line 264 of file nsapi_types.h.

◆ nsapi_wifi_ap_t

nsapi_wifi_ap structure

Structure representing a WiFi Access Point

◆ nsapi_stack_t

typedef struct nsapi_stack nsapi_stack_t

nsapi_stack structure

Stack structure representing a specific instance of a stack.

◆ nsapi_ip_mreq_t

nsapi_ip_mreq structure

◆ nsapi_latency_req_t

◆ nsapi_stagger_req_t

◆ nsapi_msghdr_t

typedef struct nsapi_msghdr nsapi_msghdr_t

Header structure for control info.

See MsgHeaderIterator.

◆ nsapi_pktinfo_t

nsapi_pktinfo structure

◆ nsapi_stack_api_t

nsapi_stack_api structure

Common api structure for network stack operations. A network stack can provide a nsapi_stack_api structure filled out with the appropriate implementation.

Unsupported operations can be left as null pointers.

Enumeration Type Documentation

◆ nsapi_error

Enum of standardized error codes.

Valid error codes have negative values and may be returned by any network operation.

Enumerator
NSAPI_ERROR_OK 

no error

NSAPI_ERROR_WOULD_BLOCK 

no data is not available but call is non-blocking

NSAPI_ERROR_UNSUPPORTED 

unsupported functionality

NSAPI_ERROR_PARAMETER 

invalid configuration

NSAPI_ERROR_NO_CONNECTION 

not connected to a network

NSAPI_ERROR_NO_SOCKET 

socket not available for use

NSAPI_ERROR_NO_ADDRESS 

IP address is not known

NSAPI_ERROR_NO_MEMORY 

memory resource not available

NSAPI_ERROR_NO_SSID 

ssid not found

NSAPI_ERROR_DNS_FAILURE 

DNS failed to complete successfully

NSAPI_ERROR_DHCP_FAILURE 

DHCP failed to complete successfully

NSAPI_ERROR_AUTH_FAILURE 

connection to access point failed

NSAPI_ERROR_DEVICE_ERROR 

failure interfacing with the network processor

NSAPI_ERROR_IN_PROGRESS 

operation (eg connect) in progress

NSAPI_ERROR_ALREADY 

operation (eg connect) already in progress

NSAPI_ERROR_IS_CONNECTED 

socket is already connected

NSAPI_ERROR_CONNECTION_LOST 

connection lost

NSAPI_ERROR_CONNECTION_TIMEOUT 

connection timed out

NSAPI_ERROR_ADDRESS_IN_USE 

Address already in use

NSAPI_ERROR_TIMEOUT 

operation timed out

NSAPI_ERROR_BUSY 

device is busy and cannot accept new operation

Definition at line 84 of file nsapi_types.h.

◆ nsapi_connection_status

Enum of connection status types.

Valid error codes have negative values.

Enumerator
NSAPI_STATUS_LOCAL_UP 

local IP address set

NSAPI_STATUS_GLOBAL_UP 

global IP address set

NSAPI_STATUS_DISCONNECTED 

no connection to network

NSAPI_STATUS_CONNECTING 

connecting to network

Definition at line 115 of file nsapi_types.h.

◆ nsapi_event

Enum of event types.

Event callbacks are accompanied with an event-dependent parameter passed as an intptr_t.

Enumerator
NSAPI_EVENT_CONNECTION_STATUS_CHANGE 

network connection status has changed, the parameter = new status (nsapi_connection_status_t)

NSAPI_EVENT_CELLULAR_STATUS_BASE 

Cellular modem status has changed, See the enum values from enum cellular_connection_status_t in /connectivity/cellular/framework/common/CellularCommon.h

NSAPI_EVENT_CELLULAR_STATUS_END 

cellular modem status has changed, See the enum values from enum cellular_connection_status_t in /connectivity/cellular/framework/common/CellularCommon.h

Definition at line 130 of file nsapi_types.h.

◆ nsapi_security

Enum of encryption types.

The security type specifies a particular security to use when connected to a WiFi network

Enumerator
NSAPI_SECURITY_NONE 

open access point

NSAPI_SECURITY_WEP 

phrase conforms to WEP

NSAPI_SECURITY_WPA 

phrase conforms to WPA

NSAPI_SECURITY_WPA2 

phrase conforms to WPA2

NSAPI_SECURITY_WPA_WPA2 

phrase conforms to WPA/WPA2

NSAPI_SECURITY_PAP 

phrase conforms to PPP authentication context

NSAPI_SECURITY_CHAP 

phrase conforms to PPP authentication context

NSAPI_SECURITY_EAP_TLS 

phrase conforms to EAP-TLS

NSAPI_SECURITY_PEAP 

phrase conforms to PEAP

NSAPI_SECURITY_WPA2_ENT 

phrase conforms to WPA2-AES and WPA-TKIP with enterprise security

NSAPI_SECURITY_WPA3 

phrase conforms to WPA3

NSAPI_SECURITY_WPA3_WPA2 

phrase conforms to WPA3_WPA2

NSAPI_SECURITY_UNKNOWN 

unknown/unsupported security in scan results

Definition at line 167 of file nsapi_types.h.

◆ nsapi_version

Enum of IP address versions.

The IP version specifies the type of an IP address.

Enumerator
NSAPI_UNSPEC 

Address is unspecified

NSAPI_IPv4 

Address is IPv4

NSAPI_IPv6 

Address is IPv6

Definition at line 239 of file nsapi_types.h.

◆ nsapi_protocol

Enum of socket protocols.

The socket protocol specifies a particular protocol to be used with a newly created socket.

Enumerator
NSAPI_TCP 

Socket is of TCP type

NSAPI_UDP 

Socket is of UDP type

NSAPI_ICMP 

Socket is of ICMP type

Definition at line 274 of file nsapi_types.h.

◆ nsapi_stack_level

Enum of standardized stack option levels for use with NetworkStack::setstackopt and getstackopt.

Enumerator
NSAPI_STACK 

Stack option level - see nsapi_stack_option_t for options

Definition at line 285 of file nsapi_types.h.

◆ nsapi_stack_option

Enum of standardized stack option names for level NSAPI_STACK of NetworkStack::setstackopt and getstackopt.

These options may not be supported on all stacks, in which case NSAPI_ERROR_UNSUPPORTED may be returned.

Enumerator
NSAPI_IPV4_MRU 

Sets/gets size of largest IPv4 fragmented datagram to reassemble

NSAPI_IPV6_MRU 

Sets/gets size of largest IPv6 fragmented datagram to reassemble

Definition at line 297 of file nsapi_types.h.

◆ nsapi_socket_level

Enum of standardized socket option levels for use with Socket::setsockopt and getsockopt.

Enumerator
NSAPI_SOCKET 

Socket option level - see nsapi_socket_option_t for options

Definition at line 307 of file nsapi_types.h.

◆ nsapi_socket_option

Enum of standardized socket option names for level NSAPI_SOCKET of Socket::setsockopt and getsockopt.

These options may not be supported on all stacks, in which case NSAPI_ERROR_UNSUPPORTED may be returned.

Enumerator
NSAPI_REUSEADDR 

Allow bind to reuse local addresses

NSAPI_KEEPALIVE 

Enables sending of keepalive messages

NSAPI_KEEPIDLE 

Sets timeout value to initiate keepalive

NSAPI_KEEPINTVL 

Sets timeout value for keepalive

NSAPI_LINGER 

Keeps close from returning until queues empty

NSAPI_SNDBUF 

Sets send buffer size

NSAPI_RCVBUF 

Sets recv buffer size

NSAPI_ADD_MEMBERSHIP 

Add membership to multicast address

NSAPI_DROP_MEMBERSHIP 

Drop membership to multicast address

NSAPI_BIND_TO_DEVICE 

Bind socket network interface name

NSAPI_LATENCY 

Read estimated latency to destination

NSAPI_STAGGER 

Read estimated stagger value to destination

NSAPI_IPTOS 

Set IP type of service to set specific precedence

NSAPI_BROADCAST 

Set broadcast flag for UDP socket

NSAPI_PKTINFO 

Get additional information when using sendto_control/recvfrom_control

Definition at line 319 of file nsapi_types.h.

◆ nsapi_tlssocket_level

Enumerator
NSAPI_TLSSOCKET_LEVEL 

TLSSocket option level - see nsapi_tlssocket_option_t for options

Definition at line 337 of file nsapi_types.h.

◆ nsapi_tlssocket_option

Enumerator
NSAPI_TLSSOCKET_SET_HOSTNAME 

Set host name

NSAPI_TLSSOCKET_SET_CACERT 

Set server CA certificate

NSAPI_TLSSOCKET_SET_CLCERT 

Set client certificate

NSAPI_TLSSOCKET_SET_CLKEY 

Set client key

NSAPI_TLSSOCKET_ENABLE 

Enable TLSSocket

Definition at line 341 of file nsapi_types.h.

◆ nsapi_ip_stack

Supported IP protocol versions of IP stack.

Definition at line 353 of file nsapi_types.h.

Function Documentation

◆ nsapi_create_stack()

NetworkStack * nsapi_create_stack ( nsapi_stack_t stack)

Convert a raw nsapi_stack_t object into a C++ NetworkStack object.

Parameters
stackPointer to an object that can be converted to a stack
  • A raw nsapi_stack_t object
  • A pointer to a network stack
  • A pointer to a network interface
Returns
Pointer to the underlying network stack

◆ nsapi_dns_query() [1/4]

nsapi_error_t nsapi_dns_query ( NetworkStack stack,
const char *  host,
SocketAddress addr,
nsapi_version_t  version = NSAPI_IPv4 
)

Query a domain name server for an IP address of a given hostname.

Parameters
stackNetwork stack as target for DNS query
hostHostname to resolve
addrDestination for the host address
versionIP version to resolve (defaults to NSAPI_IPv4)
Returns
0 on success, negative error code on failure NSAPI_ERROR_DNS_FAILURE indicates the host could not be found

◆ nsapi_dns_query() [2/4]

nsapi_error_t nsapi_dns_query ( NetworkStack stack,
const char *  host,
SocketAddress addr,
const char *  interface_name,
nsapi_version_t  version = NSAPI_IPv4 
)

Query a domain name server for an IP address of a given hostname using Network interface name.

Parameters
stackNetwork stack as target for DNS query
hostHostname to resolve
addrDestination for the host address
interface_nameIf not NULL, only this interface is used to make the DNS query.
versionIP version to resolve (defaults to NSAPI_IPv4)
Returns
See nsapi_dns_query_multiple

◆ nsapi_dns_query_async() [1/2]

nsapi_error_t nsapi_dns_query_async ( NetworkStack stack,
const char *  host,
NetworkStack::hostbyname_cb_t  callback,
NetworkStack::call_in_callback_cb_t  call_in_cb,
nsapi_version_t  version = NSAPI_IPv4 
)

Query a domain name server for an IP address of a given hostname.

Parameters
stackNetwork stack as target for DNS query
hostHostname to resolve
callbackCallback that is called for result
versionIP version to resolve (defaults to NSAPI_IPv4)
call_in_cbCall-in callback from the network stack (see NetworkStack::call_in_callback_cb_t)
Returns
0 on success, negative error code on failure or an unique id that represents the hostname translation operation and can be passed to cancel, NSAPI_ERROR_DNS_FAILURE indicates the host could not be found

◆ nsapi_dns_query_async() [2/2]

nsapi_error_t nsapi_dns_query_async ( NetworkStack stack,
const char *  host,
NetworkStack::hostbyname_cb_t  callback,
NetworkStack::call_in_callback_cb_t  call_in_cb,
const char *  interface_name,
nsapi_version_t  version = NSAPI_IPv4 
)

Query a domain name server for an IP address of a given hostname using Network interface name.

Parameters
stackNetwork stack as target for DNS query
hostHostname to resolve
callbackCallback that is called for result
call_in_cbCall-in callback from the network stack (see NetworkStack::call_in_callback_cb_t)
interface_nameIf not NULL, only this interface is used to make the DNS query.
versionIP version to resolve (defaults to NSAPI_IPv4)
Returns
0 on success, negative error code on failure or an unique id that represents the hostname translation operation and can be passed to cancel, NSAPI_ERROR_DNS_FAILURE indicates the host could not be found

◆ nsapi_dns_query() [3/4]

nsapi_error_t nsapi_dns_query ( nsapi_stack_t stack,
const char *  host,
nsapi_addr_t addr,
nsapi_version_t  version = NSAPI_IPv4 
)

Query a domain name server for an IP address of a given hostname (asynchronous)

Parameters
stackNetwork stack as target for DNS query
hostHostname to resolve
addrDestination for the host address
versionIP version to resolve (defaults to NSAPI_IPv4)
Returns
0 on success, negative error code on failure NSAPI_ERROR_DNS_FAILURE indicates the host could not be found

◆ nsapi_dns_query() [4/4]

nsapi_error_t nsapi_dns_query ( S *  stack,
const char *  host,
SocketAddress addr,
nsapi_version_t  version = NSAPI_IPv4 
)

Query a domain name server for an IP address of a given hostname.

Parameters
stackNetwork stack as target for DNS query
hostHostname to resolve
addrDestination for the host address
versionIP version to resolve (defaults to NSAPI_IPv4)
Returns
0 on success, negative error code on failure NSAPI_ERROR_DNS_FAILURE indicates the host could not be found

Definition at line 149 of file nsapi_dns.h.

◆ nsapi_dns_query_multiple() [1/3]

nsapi_size_or_error_t nsapi_dns_query_multiple ( NetworkStack stack,
const char *  host,
SocketAddress addr,
nsapi_size_t  addr_count,
const char *  interface_name,
nsapi_version_t  version = NSAPI_IPv4 
)

Query a domain name server for multiple IP address of a given hostname.

Parameters
stackNetwork stack as target for DNS query
hostHostname to resolve
addrArray for the host addresses
addr_countNumber of addresses allocated in the array
interface_nameIf not NULL, only this interface is used to make the DNS query.
versionIP version to resolve (defaults to NSAPI_IPv4)
Returns
Positive number of addresses found on success
Return values
NSAPI_ERROR_PARAMETERif provided parameters are invalid
NSAPI_ERROR_NO_MEMORYif allocation fails due to lack of memory
NSAPI_ERROR_DNS_FAILUREif DNS resolution fails
NSAPI_ERROR_WOULD_BLOCKin case non-blocking mode is enabled and DNS cannot be resolved immediately.

◆ nsapi_dns_query_multiple_async()

nsapi_size_or_error_t nsapi_dns_query_multiple_async ( NetworkStack stack,
const char *  host,
NetworkStack::hostbyname_cb_t  callback,
nsapi_size_t  addr_count,
NetworkStack::call_in_callback_cb_t  call_in_cb,
const char *  interface_name,
nsapi_version_t  version = NSAPI_IPv4 
)

Query a domain name server for an IP address of a given hostname (asynchronous)

Parameters
stackNetwork stack as target for DNS query
hostHostname to resolve
callbackCallback that is called for result
addr_countNumber of addresses allocated in the array
call_in_cbCall-in callback from the network stack (see NetworkStack::call_in_callback_cb_t)
versionIP version to resolve (defaults to NSAPI_IPv4)
interface_nameIf not NULL, only this interface is used to make the DNS query.
Returns
0 on success, negative error code on failure or an unique id that represents the hostname translation operation and can be passed to cancel, NSAPI_ERROR_DNS_FAILURE indicates the host could not be found

◆ nsapi_dns_query_multiple() [2/3]

nsapi_size_or_error_t nsapi_dns_query_multiple ( nsapi_stack_t stack,
const char *  host,
nsapi_addr_t addr,
nsapi_size_t  addr_count,
const char *  interface_name,
nsapi_version_t  version = NSAPI_IPv4 
)

Query a domain name server for multiple IP address of a given hostname.

Parameters
stackNetwork stack as target for DNS query
hostHostname to resolve
addrArray for the host addresses
addr_countNumber of addresses allocated in the array
interface_nameIf not NULL, only this interface is used to make the DNS query.
versionIP version to resolve (defaults to NSAPI_IPv4)
Returns
Number of addresses found on success, negative error code on failure NSAPI_ERROR_DNS_FAILURE indicates the host could not be found

◆ nsapi_dns_query_multiple() [3/3]

nsapi_size_or_error_t nsapi_dns_query_multiple ( S *  stack,
const char *  host,
SocketAddress addr,
nsapi_size_t  addr_count,
nsapi_version_t  version = NSAPI_IPv4 
)

Query a domain name server for multiple IP address of a given hostname.

Parameters
stackNetwork stack as target for DNS query
hostHostname to resolve
addrArray for the host addresses
addr_countNumber of addresses allocated in the array
versionIP version to resolve (defaults to NSAPI_IPv4)
Returns
Number of addresses found on success, negative error code on failure NSAPI_ERROR_DNS_FAILURE indicates the host could not be found

Definition at line 217 of file nsapi_dns.h.

◆ nsapi_dns_query_async_cancel()

nsapi_error_t nsapi_dns_query_async_cancel ( nsapi_size_or_error_t  id)

Cancels asynchronous hostname translation.

When translation is cancelled, callback will not be called.

Parameters
idUnique id of the hostname translation operation
Returns
0 on success, negative error code on failure

◆ nsapi_dns_call_in_set()

void nsapi_dns_call_in_set ( NetworkStack::call_in_callback_cb_t  callback)

Set a call in callback.

Can be used to provide an application specific call in callback to DNS resolver. When callback is set it is used instead of stack specific call in callbacks.

Parameters
callbackCallback

◆ nsapi_dns_reset()

void nsapi_dns_reset ( )

nsapi_dns_reset Resets all internal states and frees reserved memory, see NOTE! Can be used to clean up system resources when there is no need for network connections.

NOTE: Does NOT clear asynchronous ongoing operations! Currently only cleans up DNS cache (if used)

◆ nsapi_dns_add_server()

nsapi_error_t nsapi_dns_add_server ( nsapi_addr_t  addr,
const char *  interface_name 
)

Add a domain name server to list of servers to query.

Parameters
addrDestination for the host address
interface_nameCurrently unused, the server is added for all interfaces.
Returns
0 on success, negative error code on failure