Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
NetworkInterface Class Reference
[Netsocket]
NetworkInterface class. More...
#include <NetworkInterface.h>
Inherited by CellularInterface, EthInterface, MeshInterface, and WiFiInterface.
Public Member Functions | |
virtual const char * | get_mac_address () |
Get the local MAC address. | |
virtual const char * | get_ip_address () |
Get the local IP address. | |
virtual const char * | get_netmask () |
Get the local network mask. | |
virtual const char * | get_gateway () |
Get the local gateway. | |
virtual nsapi_error_t | set_network (const char *ip_address, const char *netmask, const char *gateway) |
Set a static IP address. | |
virtual nsapi_error_t | set_dhcp (bool dhcp) |
Enable or disable DHCP on the network. | |
virtual nsapi_error_t | connect ()=0 |
Start the interface. | |
virtual nsapi_error_t | disconnect ()=0 |
Stop the interface. | |
virtual nsapi_error_t | gethostbyname (const char *host, SocketAddress *address, nsapi_version_t version=NSAPI_UNSPEC) |
Translates a hostname to an IP address with specific version. | |
virtual nsapi_error_t | add_dns_server (const SocketAddress &address) |
Add a domain name server to list of servers to query. | |
Protected Member Functions | |
virtual NetworkStack * | get_stack ()=0 |
Provide access to the NetworkStack object. | |
Friends | |
class | Socket |
class | UDPSocket |
class | TCPSocket |
class | TCPServer |
class | SocketAddress |
Detailed Description
NetworkInterface class.
Common interface that is shared between network devices
Definition at line 34 of file NetworkInterface.h.
Member Function Documentation
nsapi_error_t add_dns_server | ( | const SocketAddress & | address ) | [virtual] |
Add a domain name server to list of servers to query.
- Parameters:
-
addr Destination for the host address
- Returns:
- 0 on success, negative error code on failure
Definition at line 63 of file NetworkInterface.cpp.
virtual nsapi_error_t connect | ( | ) | [pure virtual] |
Start the interface.
- Returns:
- 0 on success, negative error code on failure
Implemented in EthernetInterface, CellularInterface, and WiFiInterface.
virtual nsapi_error_t disconnect | ( | ) | [pure virtual] |
Stop the interface.
- Returns:
- 0 on success, negative error code on failure
Implemented in EthernetInterface, CellularInterface, WiFiInterface, and EthernetInterface.
const char * get_gateway | ( | ) | [virtual] |
Get the local gateway.
- Returns:
- Null-terminated representation of the local gateway or null if no network mask has been recieved
Reimplemented in EthernetInterface.
Definition at line 38 of file NetworkInterface.cpp.
const char * get_ip_address | ( | ) | [virtual] |
Get the local IP address.
- Returns:
- Null-terminated representation of the local IP address or null if no IP address has been recieved
Reimplemented in EthernetInterface.
Definition at line 28 of file NetworkInterface.cpp.
const char * get_mac_address | ( | ) | [virtual] |
Get the local MAC address.
Provided MAC address is intended for info or debug purposes and may not be provided if the underlying network interface does not provide a MAC address
- Returns:
- Null-terminated representation of the local MAC address or null if no MAC address is available
Reimplemented in EthernetInterface.
Definition at line 23 of file NetworkInterface.cpp.
const char * get_netmask | ( | ) | [virtual] |
Get the local network mask.
- Returns:
- Null-terminated representation of the local network mask or null if no network mask has been recieved
Reimplemented in EthernetInterface.
Definition at line 33 of file NetworkInterface.cpp.
virtual NetworkStack* get_stack | ( | ) | [protected, pure virtual] |
Provide access to the NetworkStack object.
- Returns:
- The underlying NetworkStack object
Implemented in EthernetInterface.
nsapi_error_t gethostbyname | ( | const char * | host, |
SocketAddress * | address, | ||
nsapi_version_t | version = NSAPI_UNSPEC |
||
) | [virtual] |
Translates a hostname to an IP address with specific version.
The hostname may be either a domain name or an IP address. If the hostname is an IP address, no network transactions will be performed.
If no stack-specific DNS resolution is provided, the hostname will be resolve using a UDP socket on the stack.
- Parameters:
-
address Destination for the host SocketAddress host Hostname to resolve version IP version of address to resolve, NSAPI_UNSPEC indicates version is chosen by the stack (defaults to NSAPI_UNSPEC)
- Returns:
- 0 on success, negative error code on failure
Definition at line 58 of file NetworkInterface.cpp.
nsapi_error_t set_dhcp | ( | bool | dhcp ) | [virtual] |
Enable or disable DHCP on the network.
Enables DHCP on connecting the network. Defaults to enabled unless a static IP address has been assigned. Requires that the network is disconnected.
- Parameters:
-
dhcp True to enable DHCP
- Returns:
- 0 on success, negative error code on failure
Reimplemented in EthernetInterface.
Definition at line 48 of file NetworkInterface.cpp.
nsapi_error_t set_network | ( | const char * | ip_address, |
const char * | netmask, | ||
const char * | gateway | ||
) | [virtual] |
Set a static IP address.
Configures this network interface to use a static IP address. Implicitly disables DHCP, which can be enabled in set_dhcp. Requires that the network is disconnected.
- Parameters:
-
address Null-terminated representation of the local IP address netmask Null-terminated representation of the local network mask gateway Null-terminated representation of the local gateway
- Returns:
- 0 on success, negative error code on failure
Reimplemented in EthernetInterface.
Definition at line 43 of file NetworkInterface.cpp.
Generated on Tue Jul 12 2022 11:03:18 by
