Mbed OS Reference
Loading...
Searching...
No Matches
OnboardNetworkStack::Interface Class Referenceabstract

Representation of a stack's view of an interface. More...

#include <OnboardNetworkStack.h>

Inheritance diagram for OnboardNetworkStack::Interface:
Nanostack::Interface Nanostack::EthernetInterface Nanostack::MeshInterface Nanostack::PPPInterface

Public Member Functions

virtual nsapi_error_t set_ip_address (const char *ip, const char *netmask, const char *gw, uint8_t ipv6_flag)
 Set IP address. More...
 
virtual nsapi_error_t bringup (bool dhcp, const char *ip, const char *netmask, const char *gw, nsapi_ip_stack_t stack=DEFAULT_STACK, bool blocking=true)=0
 Connect the interface to the network. More...
 
virtual nsapi_error_t bringdown ()=0
 Disconnect interface from the network. More...
 
virtual void attach (mbed::Callback< void(nsapi_event_t, intptr_t)> status_cb)=0
 Register callback for status reporting. More...
 
virtual nsapi_connection_status_t get_connection_status () const =0
 Get the connection status. More...
 
virtual char * get_interface_name (char *buf)
 Returns interface name. More...
 
virtual char * get_mac_address (char *buf, nsapi_size_t buflen)=0
 Return MAC address of the network interface. More...
 
virtual nsapi_error_t get_ip_address (SocketAddress *address)=0
 Get the local IP address. More...
 
virtual nsapi_error_t get_ipv6_link_local_address (SocketAddress *address)
 Get the IPv6 link local address. More...
 
virtual nsapi_error_t get_netmask (SocketAddress *address)=0
 Writes the netmask of the network interface into a user-supplied SocketAddress. More...
 
virtual nsapi_error_t get_gateway (SocketAddress *address)=0
 Writes the gateway address of the network interface into a user-supplied SocketAddress. More...
 

Detailed Description

Representation of a stack's view of an interface.

Provides facilities required by a driver to implement the application NetworkInterface API.

Definition at line 50 of file OnboardNetworkStack.h.

Member Function Documentation

◆ set_ip_address()

virtual nsapi_error_t set_ip_address ( const char *  ip,
const char *  netmask,
const char *  gw,
uint8_t  ipv6_flag 
)
virtual

Set IP address.

bringup() can only take one IP address and in dual stack case another IP address can be set using this function.

Must be called before bringup().

Parameters
ipIP address to be used for the interface as "W:X:Y:Z" or NULL
netmaskNet mask to be used for the interface as "W:X:Y:Z" or NULL
gwGateway address to be used for the interface as "W:X:Y:Z" or NULL
ipv6_flagProvide this flag for IPv6 state flag override. For example, you can set IP6_ADDR_PREFERRED. For IPv4, this value will be ignored.
Returns
NSAPI_ERROR_OK on success, or error code

Definition at line 69 of file OnboardNetworkStack.h.

◆ bringup()

virtual nsapi_error_t bringup ( bool  dhcp,
const char *  ip,
const char *  netmask,
const char *  gw,
nsapi_ip_stack_t  stack = DEFAULT_STACK,
bool  blocking = true 
)
pure virtual

Connect the interface to the network.

Sets up a connection on specified network interface, using DHCP or provided network details. If the dhcp is set to true all the remaining parameters are ignored.

Parameters
dhcptrue if the network details should be acquired using DHCP
ipIP address to be used for the interface as "W:X:Y:Z" or NULL
netmaskNet mask to be used for the interface as "W:X:Y:Z" or NULL
gwGateway address to be used for the interface as "W:X:Y:Z" or NULL
stackAllow manual selection of IPv4 and/or IPv6.
blockingSpecify whether bringup blocks for connection completion.
Returns
NSAPI_ERROR_OK on success, or error code

Implemented in Nanostack::EthernetInterface, and Nanostack::PPPInterface.

◆ bringdown()

virtual nsapi_error_t bringdown ( )
pure virtual

Disconnect interface from the network.

After this call the network interface is inactive, to use it again user needs to call
bringup again.

Returns
NSAPI_ERROR_OK on success, or error code

Implemented in Nanostack::EthernetInterface, and Nanostack::PPPInterface.

◆ attach()

virtual void attach ( mbed::Callback< void(nsapi_event_t, intptr_t)>  status_cb)
pure virtual

Register callback for status reporting.

The specified status callback function will be called on status changes on the network. The parameters on the callback are the event type and event-type dependent reason parameter.

Parameters
status_cbThe callback for status changes

Implemented in Nanostack::Interface.

◆ get_connection_status()

virtual nsapi_connection_status_t get_connection_status ( ) const
pure virtual

Get the connection status.

Returns
The connection status according to ConnectionStatusType

Implemented in Nanostack::Interface.

◆ get_interface_name()

virtual char * get_interface_name ( char *  buf)
virtual

Returns interface name.

Returns
string containing name of network interface for example "en0"

Reimplemented in Nanostack::MeshInterface, Nanostack::EthernetInterface, and Nanostack::PPPInterface.

Definition at line 125 of file OnboardNetworkStack.h.

◆ get_mac_address()

virtual char * get_mac_address ( char *  buf,
nsapi_size_t  buflen 
)
pure virtual

Return MAC address of the network interface.

Returns
MAC address as "V:W:X:Y:Z"

Implemented in Nanostack::Interface, and Nanostack::EthernetInterface.

◆ get_ip_address()

virtual nsapi_error_t get_ip_address ( SocketAddress address)
pure virtual

Get the local IP address.

Parameters
addressSocketAddress representation of the local IP address
Return values
NSAPI_ERROR_OKon success
NSAPI_ERROR_UNSUPPORTEDif this feature is not supported
NSAPI_ERROR_PARAMETERif the provided pointer is invalid
NSAPI_ERROR_NO_ADDRESSif the address cannot be obtained from stack

Implemented in Nanostack::Interface.

◆ get_ipv6_link_local_address()

virtual nsapi_error_t get_ipv6_link_local_address ( SocketAddress address)
virtual

Get the IPv6 link local address.

Parameters
addressSocketAddress representation of the link local IPv6 address
Return values
NSAPI_ERROR_OKon success
NSAPI_ERROR_UNSUPPORTEDif this feature is not supported
NSAPI_ERROR_PARAMETERif the provided pointer is invalid

Definition at line 140 of file OnboardNetworkStack.h.

◆ get_netmask()

virtual nsapi_error_t get_netmask ( SocketAddress address)
pure virtual

Writes the netmask of the network interface into a user-supplied SocketAddress.

Parameters
addressStructure to write netmask into.
Returns
Error code or success.

Implemented in Nanostack::Interface.

◆ get_gateway()

virtual nsapi_error_t get_gateway ( SocketAddress address)
pure virtual

Writes the gateway address of the network interface into a user-supplied SocketAddress.

Parameters
addressStructure to write netmask into.
Returns
Error code or success.

Implemented in Nanostack::Interface.