forked from espressif/arduino-esp32
Add generic IP utilities (#3038)
* Add generic IP calculations Add: calculateNetworkID(IPAddress ip, IPAddress subnet) => Calculate the network id using the ip and subnet (e.g. 192.168.0.0) calculateBroadcast(IPAddress ip, IPAddress subnet) => Calculate the broadcast ip using the ip and subnet (e.g. 192.168.0.255) calculateSubnetCIDR(IPAddress subnetMask) => Calculate the subnet CIDR using the subnet (e.g. 24) Add: broadcastIP() => Retrieve the network id (e.g. 192.168.0.0) networkID() => Retrieve the broadcast IP (e.g. 192.168.0.255) subnetCIDR() => Retrieve the subnet CIDR (e.g. 24) Add: broadcastIP() => Retrieve the network id (e.g. 192.168.0.0) networkID() => Retrieve the broadcast IP (e.g. 192.168.0.255) subnetCIDR() => Retrieve the subnet CIDR (e.g. 24) Add: softAPBroadcastIP() => Retrieve the network id (e.g. 192.168.0.0) softAPNetwrokID() => Retrieve the broadcast IP (e.g. 192.168.0.255) softAPSubnetCIDR() => Retrieve the subnet CIDR (e.g. 24)
This commit is contained in:
committed by
Me No Dev
parent
2a1fde7736
commit
91b9fae111
@ -197,6 +197,33 @@ IPAddress ETHClass::dnsIP(uint8_t dns_no)
|
||||
return IPAddress(dns_ip.u_addr.ip4.addr);
|
||||
}
|
||||
|
||||
IPAddress ETHClass::broadcastIP()
|
||||
{
|
||||
tcpip_adapter_ip_info_t ip;
|
||||
if(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)){
|
||||
return IPAddress();
|
||||
}
|
||||
return WiFiGenericClass::calculateBroadcast(IPAddress(ip.gw.addr), IPAddress(ip.netmask.addr));
|
||||
}
|
||||
|
||||
IPAddress ETHClass::networkID()
|
||||
{
|
||||
tcpip_adapter_ip_info_t ip;
|
||||
if(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)){
|
||||
return IPAddress();
|
||||
}
|
||||
return WiFiGenericClass::calculateNetworkID(IPAddress(ip.gw.addr), IPAddress(ip.netmask.addr));
|
||||
}
|
||||
|
||||
uint8_t ETHClass::subnetCIDR()
|
||||
{
|
||||
tcpip_adapter_ip_info_t ip;
|
||||
if(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)){
|
||||
return (uint8_t)0;
|
||||
}
|
||||
return WiFiGenericClass::calculateSubnetCIDR(IPAddress(ip.netmask.addr));
|
||||
}
|
||||
|
||||
const char * ETHClass::getHostname()
|
||||
{
|
||||
const char * hostname;
|
||||
|
Reference in New Issue
Block a user