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
EthernetInterface Class Reference
EthernetInterface class Implementation of the NetworkStack for LWIP. More...
#include <EthernetInterface.h>
Inherits EthInterface.
Public Member Functions | |
EthernetInterface () | |
EthernetInterface lifetime. | |
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 () |
Start the interface. | |
virtual nsapi_error_t | disconnect () |
Stop the interface. | |
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 gateways. | |
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. | |
Static Public Member Functions | |
static int | init () |
Initialize the interface with DHCP. | |
static int | init (const char *ip, const char *mask, const char *gateway) |
Initialize the interface with a static IP address. | |
static int | connect (unsigned int timeout_ms=15000) |
Connect Bring the interface up, start DHCP if needed. | |
static int | disconnect () |
Disconnect Bring the interface down. | |
static char * | getMACAddress () |
Get the MAC address of your Ethernet interface. | |
static char * | getIPAddress () |
Get the IP address of your Ethernet interface. | |
static char * | getGateway () |
Get the Gateway address of your Ethernet interface. | |
static char * | getNetworkMask () |
Get the Network mask of your Ethernet interface. | |
Protected Member Functions | |
virtual NetworkStack * | get_stack () |
Provide access to the underlying stack. | |
Friends | |
class | Socket |
class | UDPSocket |
class | TCPSocket |
class | TCPServer |
class | SocketAddress |
Detailed Description
EthernetInterface class Implementation of the NetworkStack for LWIP.
Interface using Ethernet to connect to an IP-based network.
Definition at line 31 of file FEATURE_LWIP/lwip-interface/EthernetInterface.h.
Constructor & Destructor Documentation
EthernetInterface lifetime.
Definition at line 22 of file FEATURE_LWIP/lwip-interface/EthernetInterface.cpp.
Member Function Documentation
nsapi_error_t add_dns_server | ( | const SocketAddress & | address ) | [virtual, inherited] |
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.
nsapi_error_t connect | ( | ) | [virtual] |
Start the interface.
- Returns:
- 0 on success, negative on failure
Implements NetworkInterface.
Definition at line 42 of file FEATURE_LWIP/lwip-interface/EthernetInterface.cpp.
int connect | ( | unsigned int | timeout_ms = 15000 ) |
[static] |
Connect Bring the interface up, start DHCP if needed.
- Parameters:
-
timeout_ms timeout in ms (default: (15)s).
- Returns:
- 0 on success, a negative number on failure
Definition at line 107 of file unsupported/net/eth/EthernetInterface/EthernetInterface.cpp.
int disconnect | ( | ) | [virtual] |
Stop the interface.
- Returns:
- 0 on success, negative on failure
Implements NetworkInterface.
Definition at line 50 of file FEATURE_LWIP/lwip-interface/EthernetInterface.cpp.
static int disconnect | ( | ) | [static, virtual] |
Disconnect Bring the interface down.
- Returns:
- 0 on success, a negative number on failure
Implements NetworkInterface.
const char * get_gateway | ( | ) | [virtual] |
Get the local gateways.
- Returns:
- Null-terminated representation of the local gateway or null if no network mask has been recieved
Reimplemented from NetworkInterface.
Definition at line 78 of file FEATURE_LWIP/lwip-interface/EthernetInterface.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 from NetworkInterface.
Definition at line 60 of file FEATURE_LWIP/lwip-interface/EthernetInterface.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 from NetworkInterface.
Definition at line 55 of file FEATURE_LWIP/lwip-interface/EthernetInterface.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 from NetworkInterface.
Definition at line 69 of file FEATURE_LWIP/lwip-interface/EthernetInterface.cpp.
NetworkStack * get_stack | ( | void | ) | [protected, virtual] |
Provide access to the underlying stack.
- Returns:
- The underlying network stack
Implements NetworkInterface.
Definition at line 87 of file FEATURE_LWIP/lwip-interface/EthernetInterface.cpp.
char * getGateway | ( | ) | [static] |
Get the Gateway address of your Ethernet interface.
- Returns:
- a pointer to a string containing the Gateway address
Definition at line 148 of file unsupported/net/eth/EthernetInterface/EthernetInterface.cpp.
nsapi_error_t gethostbyname | ( | const char * | host, |
SocketAddress * | address, | ||
nsapi_version_t | version = NSAPI_UNSPEC |
||
) | [virtual, inherited] |
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.
char * getIPAddress | ( | ) | [static] |
Get the IP address of your Ethernet interface.
- Returns:
- a pointer to a string containing the IP address
Definition at line 144 of file unsupported/net/eth/EthernetInterface/EthernetInterface.cpp.
char * getMACAddress | ( | ) | [static] |
Get the MAC address of your Ethernet interface.
- Returns:
- a pointer to a string containing the MAC address
Definition at line 140 of file unsupported/net/eth/EthernetInterface/EthernetInterface.cpp.
char * getNetworkMask | ( | ) | [static] |
Get the Network mask of your Ethernet interface.
- Returns:
- a pointer to a string containing the Network mask
Definition at line 152 of file unsupported/net/eth/EthernetInterface/EthernetInterface.cpp.
int init | ( | ) | [static] |
Initialize the interface with DHCP.
Initialize the interface and configure it to use DHCP (no connection at this point).
- Returns:
- 0 on success, a negative number on failure
Definition at line 85 of file unsupported/net/eth/EthernetInterface/EthernetInterface.cpp.
int init | ( | const char * | ip, |
const char * | mask, | ||
const char * | gateway | ||
) | [static] |
Initialize the interface with a static IP address.
Initialize the interface and configure it with the following static configuration (no connection at this point).
- Parameters:
-
ip the IP address to use mask the IP address mask gateway the gateway to use
- Returns:
- 0 on success, a negative number on failure
Definition at line 92 of file unsupported/net/eth/EthernetInterface/EthernetInterface.cpp.
nsapi_error_t set_dhcp | ( | bool | dhcp ) | [virtual] |
Enable or disable DHCP on the network.
Requires that the network is disconnected
- Parameters:
-
dhcp False to disable dhcp (defaults to enabled)
- Returns:
- 0 on success, negative error code on failure
Reimplemented from NetworkInterface.
Definition at line 36 of file FEATURE_LWIP/lwip-interface/EthernetInterface.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 from NetworkInterface.
Definition at line 27 of file FEATURE_LWIP/lwip-interface/EthernetInterface.cpp.
Generated on Tue Jul 12 2022 11:03:17 by
