mirror of https://github.com/ARMmbed/mbed-os.git
Added methods to retrieve gateway and netmask from DHCP assignment
parent
53edc82f73
commit
d3963de05d
|
@ -33,6 +33,8 @@ static struct netif lpcNetif;
|
|||
|
||||
static char mac_addr[19];
|
||||
static char ip_addr[17] = "\0";
|
||||
static char gateway[17] = "\0";
|
||||
static char networkmask[17] = "\0";
|
||||
static bool use_dhcp = false;
|
||||
|
||||
static Semaphore tcpip_inited(0);
|
||||
|
@ -52,6 +54,8 @@ static void netif_link_callback(struct netif *netif) {
|
|||
static void netif_status_callback(struct netif *netif) {
|
||||
if (netif_is_up(netif)) {
|
||||
strcpy(ip_addr, inet_ntoa(netif->ip_addr));
|
||||
strcpy(gateway, inet_ntoa(netif->gw));
|
||||
strcpy(networkmask, inet_ntoa(netif->netmask));
|
||||
netif_up.release();
|
||||
}
|
||||
}
|
||||
|
@ -142,3 +146,13 @@ char* EthernetInterface::getMACAddress() {
|
|||
char* EthernetInterface::getIPAddress() {
|
||||
return ip_addr;
|
||||
}
|
||||
|
||||
char* EthernetInterface::getGateway() {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
char* EthernetInterface::getNetworkMask() {
|
||||
return networkmask;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -69,6 +69,16 @@ public:
|
|||
* \return a pointer to a string containing the IP address
|
||||
*/
|
||||
static char* getIPAddress();
|
||||
|
||||
/** Get the Gateway address of your Ethernet interface
|
||||
* \return a pointer to a string containing the Gateway address
|
||||
*/
|
||||
static char* getGateway();
|
||||
|
||||
/** Get the Network mask of your Ethernet interface
|
||||
* \return a pointer to a string containing the Network mask
|
||||
*/
|
||||
static char* getNetworkMask();
|
||||
};
|
||||
|
||||
#include "TCPSocketConnection.h"
|
||||
|
|
Loading…
Reference in New Issue