summaryrefslogtreecommitdiff
path: root/libhw_cr/w5500.c
diff options
context:
space:
mode:
Diffstat (limited to 'libhw_cr/w5500.c')
-rw-r--r--libhw_cr/w5500.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libhw_cr/w5500.c b/libhw_cr/w5500.c
index b7c2ad1..c318819 100644
--- a/libhw_cr/w5500.c
+++ b/libhw_cr/w5500.c
@@ -8,6 +8,7 @@
* https://github.com/Wiznet/ioLibrary_Driver/blob/b981401e7f3d07015619adf44c13998e13e777f9/Ethernet/W5500/w5500.h
* https://github.com/Wiznet/ioLibrary_Driver/blob/b981401e7f3d07015619adf44c13998e13e777f9/Ethernet/W5500/w5500.c
* https://github.com/Wiznet/ioLibrary_Driver/blob/b981401e7f3d07015619adf44c13998e13e777f9/Ethernet/socket.c
+ * https://github.com/Wiznet/ioLibrary_Driver/blob/b981401e7f3d07015619adf44c13998e13e777f9/Internet/DHCP/dhcp.c
*
* Copyright (c) 2013, WIZnet Co., LTD.
* All rights reserved.
@@ -67,6 +68,8 @@
* SPDX-License-Identifier: MIT
*/
+#include <string.h> /* for memcmp() */
+
/* TODO: Write a <libhw/generic/gpio.h> to avoid w5500.c being
* pico-sdk-specific. */
#include "rp2040_gpioirq.h"
@@ -545,6 +548,22 @@ static lo_interface net_packet_conn w5500_if_udp_conn(struct w5500 *chip, uint16
return lo_box_w5500_udp_as_net_packet_conn(socket);
}
+static bool w5500_if_arp_ping(struct w5500 *chip, struct net_ip4_addr addr) {
+ /* FIXME: This arp_ping implementation is really bad (and
+ * assumes that a UDP socket is open, which is "safe" because
+ * I only use it from inside of a DHCP client). */
+ assert(chip);
+ struct _w5500_socket *sock = NULL;
+ for (size_t i = 0; i < LM_ARRAY_LEN(chip->sockets) && !sock; i++) {
+ if (chip->sockets[i].mode == W5500_MODE_UDP)
+ sock = &chip->sockets[i];
+ }
+ assert(sock);
+ ssize_t v = w5500_udp_sendto(sock, "BOGUS_PACKET_TO_TRIGGER_AN_ARP", 17, addr, 5000);
+ log_debugln("arp_ping => ", v);
+ return v != -NET_EARP_TIMEOUT;
+}
+
/* tcp_listener methods *******************************************************/
static lo_interface net_stream_conn w5500_tcplist_accept(struct _w5500_socket *socket) {