From 74b52dbf78e8511d4dfc0747c6242896a75f26de 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 | 7 +++++++ src/Ethernet.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/Ethernet.cpp b/src/Ethernet.cpp index 8d9ce7fd..b5ef5780 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,12 @@ void EthernetClass::setRetransmissionCount(uint8_t num) SPI.endTransaction(); } +int EthernetClass::hostByName(const char* hostname, IPAddress& result) +{ + 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;