1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-12-13 20:03:19 +03:00

Implement remoteIP and remotePort in WiFiUDP

This commit is contained in:
Ivan Grokhotkov
2015-02-17 01:38:35 +03:00
parent ea90d3ce92
commit 71c705a187
3 changed files with 31 additions and 13 deletions

View File

@@ -102,6 +102,24 @@ public:
return _rx_buf->len - _rx_buf_offset;
}
uint32_t getRemoteAddress()
{
if (!_rx_buf)
return 0;
struct ip_hdr* iphdr = (struct ip_hdr*) (((uint8_t*)_rx_buf->payload) - UDP_HLEN - IP_HLEN);
return iphdr->src.addr;
}
uint16_t getRemotePort()
{
if (!_rx_buf)
return 0;
struct udp_hdr* udphdr = (struct udp_hdr*) (((uint8_t*)_rx_buf->payload) - UDP_HLEN);
return ntohs(udphdr->src);
}
bool next()
{
if (!_rx_buf)