From c7c4b3a3997f472d84039c47e1fe90779e704366 Mon Sep 17 00:00:00 2001 From: Juraj Andrassy Date: Sat, 7 Oct 2023 13:16:48 +0200 Subject: [PATCH] EthernetClass hostByName added --- src/Ethernet.cpp | 8 ++++++++ src/Ethernet.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/Ethernet.cpp b/src/Ethernet.cpp index 8d9ce7fd..eef751ba 100644 --- a/src/Ethernet.cpp +++ b/src/Ethernet.cpp @@ -22,6 +22,7 @@ #include "Ethernet.h" #include "utility/w5100.h" #include "Dhcp.h" +#include "Dns.h" IPAddress EthernetClass::_dnsServerAddress; DhcpClass* EthernetClass::_dhcp = NULL; @@ -224,6 +225,13 @@ void EthernetClass::setRetransmissionCount(uint8_t num) SPI.endTransaction(); } +int EthernetClass::hostByName(const char* hostname, IPAddress& result) +{ + int ret = 0; + DNSClient dns; + dns.begin(_dnsServerAddress); + return dns.getHostByName(hostname, result); +} diff --git a/src/Ethernet.h b/src/Ethernet.h index 0045de88..d97117d3 100644 --- a/src/Ethernet.h +++ b/src/Ethernet.h @@ -105,6 +105,8 @@ class EthernetClass { void setRetransmissionTimeout(uint16_t milliseconds); void setRetransmissionCount(uint8_t num); + int hostByName(const char* hostname, IPAddress& result); + friend class EthernetClient; friend class EthernetServer; friend class EthernetUDP;