diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-27 18:07:34 -0400 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-27 19:23:14 -0400 |
commit | 203f2b67c0bea9646b4cf18bafba6e735df4efe3 (patch) | |
tree | cf164c300fbb0d843ef3cc238cb15fa40610edae /libhw_cr/w5500.c | |
parent | 7dd869b107af520a5ce6870efab8becce5d81b15 (diff) |
Pull the ARP-ping from libdhcp to net_iface
Diffstat (limited to 'libhw_cr/w5500.c')
-rw-r--r-- | libhw_cr/w5500.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libhw_cr/w5500.c b/libhw_cr/w5500.c index 8bdb95b..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. @@ -547,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) { |