Mistake on this page?
Report an issue in GitHub or email us
Data Structures | Macros | Typedefs | Enumerations | Functions
Netsocket

Data Structures

class  EthInterface
 
class  MeshInterface
 
struct  nsapi_addr
 
struct  nsapi_wifi_ap
 
struct  nsapi_stack
 
struct  nsapi_ip_mreq
 
struct  nsapi_stack_api
 
class  Socket
 
class  TCPSocket
 
class  UDPSocket
 

Macros

#define NSAPI_IP_SIZE   NSAPI_IPv6_SIZE
 
#define NSAPI_IP_BYTES   NSAPI_IPv6_BYTES
 
#define NSAPI_MAC_SIZE   18
 
#define NSAPI_MAC_BYTES   6
 
#define NSAPI_IPv4_SIZE   16
 
#define NSAPI_IPv4_BYTES   4
 
#define NSAPI_IPv6_SIZE   40
 
#define NSAPI_IPv6_BYTES   16
 

Typedefs

typedef enum nsapi_connection_status nsapi_connection_status_t
 
typedef enum nsapi_event nsapi_event_t
 
typedef signed int nsapi_error_t
 
typedef unsigned int nsapi_size_t
 
typedef signed int nsapi_size_or_error_t
 
typedef signed int nsapi_value_or_error_t
 
typedef enum nsapi_security nsapi_security_t
 
typedef enum nsapi_version nsapi_version_t
 
typedef struct nsapi_addr nsapi_addr_t
 
typedef void * nsapi_socket_t
 
typedef enum nsapi_protocol nsapi_protocol_t
 
typedef enum nsapi_stack_level nsapi_stack_level_t
 
typedef enum nsapi_stack_option nsapi_stack_option_t
 
typedef enum nsapi_socket_level nsapi_socket_level_t
 
typedef enum nsapi_socket_option nsapi_socket_option_t
 
typedef enum nsapi_ip_stack nsapi_ip_stack_t
 
typedef nsapi_socket_level_t nsapi_level_t
 
typedef nsapi_socket_option_t nsapi_option_t
 
typedef struct nsapi_wifi_ap nsapi_wifi_ap_t
 
typedef struct nsapi_stack nsapi_stack_t
 
typedef struct nsapi_ip_mreq nsapi_ip_mreq_t
 
typedef struct nsapi_stack_api nsapi_stack_api_t
 

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
}
 
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  nsapi_event { NSAPI_EVENT_CONNECTION_STATUS_CHANGE = 0, NSAPI_EVENT_CELLULAR_STATUS_BASE = 0x1000, NSAPI_EVENT_CELLULAR_STATUS_END = 0x1FFF }
 
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_UNKNOWN = 0xFF
}
 
enum  nsapi_version { NSAPI_UNSPEC, NSAPI_IPv4, NSAPI_IPv6 }
 
enum  nsapi_protocol { NSAPI_TCP, NSAPI_UDP }
 
enum  nsapi_stack_level { NSAPI_STACK = 5000 }
 
enum  nsapi_stack_option { NSAPI_IPV4_MRU, NSAPI_IPV6_MRU }
 
enum  nsapi_socket_level { NSAPI_SOCKET = 7000 }
 
enum  nsapi_socket_option {
  NSAPI_REUSEADDR, NSAPI_KEEPALIVE, NSAPI_KEEPIDLE, NSAPI_KEEPINTVL,
  NSAPI_LINGER, NSAPI_SNDBUF, NSAPI_RCVBUF, NSAPI_ADD_MEMBERSHIP,
  NSAPI_DROP_MEMBERSHIP
}
 
enum  nsapi_ip_stack { DEFAULT_STACK = 0, IPV4_STACK, IPV6_STACK, IPV4V6_STACK }
 

Functions

nsapi_error_t nsapi_dns_query (nsapi_stack_t *stack, const char *host, nsapi_addr_t *addr, nsapi_version_t version)
 
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, nsapi_version_t version)
 
nsapi_error_t nsapi_dns_add_server (nsapi_addr_t addr)
 

Detailed Description

NetworkInterface class

Common interface that is shared between network devices

NetworkStack class

Common interface that is shared between hardware that can connect to a network over IP. By implementing the NetworkStack, a network stack can be used as a target for instantiating network sockets.

SocketAddress class

Representation of an IP address and port pair.

TCP socket server

WiFiInterface class

Common interface that is shared between WiFi devices

Macro Definition Documentation

#define NSAPI_IP_BYTES   NSAPI_IPv6_BYTES

Maximum number of bytes for IP address

#define NSAPI_IP_SIZE   NSAPI_IPv6_SIZE

Maximum size of IP address representation

#define NSAPI_IPv4_BYTES   4

Number of bytes in IPv4 address

#define NSAPI_IPv4_SIZE   16

Size of IPv4 representation

#define NSAPI_IPv6_BYTES   16

Number of bytes in IPv6 address

#define NSAPI_IPv6_SIZE   40

Size of IPv6 representation

#define NSAPI_MAC_BYTES   6

Maximum number of bytes for MAC address

#define NSAPI_MAC_SIZE   18

Maximum size of MAC address representation

Typedef Documentation

typedef struct nsapi_addr nsapi_addr_t

IP address structure for passing IP addresses by value

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

nsapi_ip_mreq structure

Enum of encryption types

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

typedef signed int nsapi_size_or_error_t

Type used to represent either a size or error pased 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

typedef unsigned int nsapi_size_t

Type used to represent the size of data passed through sockets

typedef void* nsapi_socket_t

Opaque handle for network sockets

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.

typedef struct nsapi_stack nsapi_stack_t

nsapi_stack structure

Stack structure representing a specific instance of a stack.

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

nsapi_wifi_ap structure

Structure representing a WiFi Access Point

Enumeration Type Documentation

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

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

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 /features/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 /features/cellular/framework/common/CellularCommon.h

Supported IP protocol versions of IP stack

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

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_UNKNOWN 

unknown/unsupported security in scan results

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

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

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

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

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

Function Documentation

nsapi_error_t nsapi_dns_add_server ( nsapi_addr_t  addr)

Add a domain name server to list of servers to query

Parameters
addrDestination for the host address
Returns
0 on success, negative error code on failure
nsapi_error_t nsapi_dns_query ( nsapi_stack_t stack,
const char *  host,
nsapi_addr_t addr,
nsapi_version_t  version 
)

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
Returns
0 on success, negative error code on failure NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
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,
nsapi_version_t  version 
)

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
Returns
Number of addresses found on success, negative error code on failure NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.