Rizky Ardi Maulana / mbed-os
Embed: (wiki syntax)

« Back to documentation index

EthInterface Class Reference

EthInterface class. More...

#include <EthInterface.h>

Inherits NetworkInterface.

Inherited by EthernetInterface.

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 int set_network (const char *ip_address, const char *netmask, const char *gateway)
 Set a static IP address.
virtual int set_dhcp (bool dhcp)
 Enable or disable DHCP on the network.
virtual int connect ()=0
 Start the interface.
virtual int disconnect ()=0
 Stop the interface.
virtual int gethostbyname (const char *host, SocketAddress *address)
 Translates a hostname to an IP address.
virtual int gethostbyname (const char *host, SocketAddress *address, nsapi_version_t version)
 Translates a hostname to an IP address with specific version.
virtual int add_dns_server (const SocketAddress &address)
 Add a domain name server to list of servers to query.

Protected Member Functions

virtual NetworkStackget_stack ()=0
 Provide access to the NetworkStack object.

Friends

class Socket
class UDPSocket
class TCPSocket
class TCPServer
class SocketAddress

Detailed Description

EthInterface class.

Common interface that is shared between ethernet hardware.

Definition at line 30 of file EthInterface.h.


Member Function Documentation

int add_dns_server ( const SocketAddress address ) [virtual, inherited]

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

Definition at line 68 of file NetworkInterface.cpp.

virtual int connect (  ) [pure virtual, inherited]

Start the interface.

Returns:
0 on success, negative error code on failure

Implemented in EthernetInterface, CellularInterface, and WiFiInterface.

virtual int disconnect (  ) [pure virtual, inherited]

Stop the interface.

Returns:
0 on success, negative error code on failure

Implemented in EthernetInterface, CellularInterface, WiFiInterface, and EthernetInterface.

const char * get_gateway (  ) [virtual, inherited]

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, inherited]

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, inherited]

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, inherited]

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, inherited]

Provide access to the NetworkStack object.

Returns:
The underlying NetworkStack object

Implemented in EthernetInterface.

int gethostbyname ( const char *  host,
SocketAddress address,
nsapi_version_t  version 
) [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:
addressDestination for the host SocketAddress
hostHostname to resolve
versionIP version of address to resolve
Returns:
0 on success, negative error code on failure

Definition at line 63 of file NetworkInterface.cpp.

int gethostbyname ( const char *  host,
SocketAddress address 
) [virtual, inherited]

Translates a hostname to an IP address.

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:
addressDestination for the host SocketAddress
hostHostname to resolve
Returns:
0 on success, negative error code on failure

Definition at line 58 of file NetworkInterface.cpp.

int set_dhcp ( bool  dhcp ) [virtual, inherited]

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:
dhcpTrue to enable DHCP
Returns:
0 on success, negative error code on failure

Reimplemented in EthernetInterface.

Definition at line 48 of file NetworkInterface.cpp.

int set_network ( const char *  ip_address,
const char *  netmask,
const char *  gateway 
) [virtual, inherited]

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:
addressNull-terminated representation of the local IP address
netmaskNull-terminated representation of the local network mask
gatewayNull-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.