[rtems-lwip commit] rtemslwip/ifaddrs: Set loopback flag
Joel Sherrill
joel at rtems.org
Wed Mar 29 16:26:33 UTC 2023
Module: rtems-lwip
Branch: master
Commit: c43456fdf681a967f00c71cfefd29b497fdda7ca
Changeset: http://git.rtems.org/rtems-lwip/commit/?id=c43456fdf681a967f00c71cfefd29b497fdda7ca
Author: Kinsey Moore <kinsey.moore at oarcorp.com>
Date: Thu Mar 23 13:58:45 2023 -0500
rtemslwip/ifaddrs: Set loopback flag
Some consumers of getifaddrs() depend on the loopback flag being set
appropriately to filter interfaces. Make sure that requirement is
satisfied.
---
rtemslwip/bsd_compat/ifaddrs.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/rtemslwip/bsd_compat/ifaddrs.c b/rtemslwip/bsd_compat/ifaddrs.c
index dc6b7f2..9b97d4e 100644
--- a/rtemslwip/bsd_compat/ifaddrs.c
+++ b/rtemslwip/bsd_compat/ifaddrs.c
@@ -65,6 +65,12 @@ static struct ifaddrs *create_ifaddr_from_netif(struct netif *netif)
inet_addr_from_ip4addr(&((struct sockaddr_in *)ifaddr->ifa_addr)->sin_addr, &netif->ip_addr.u_addr.ip4);
inet_addr_from_ip4addr(&((struct sockaddr_in *)ifaddr->ifa_netmask)->sin_addr, &netif->netmask.u_addr.ip4);
((struct sockaddr_in *)ifaddr->ifa_netmask)->sin_addr.s_addr = netif->ip_addr.u_addr.ip4.addr & netif->netmask.u_addr.ip4.addr;
+
+ /* Set IFF_LOOPBACK flag if appropriate */
+ if (127 != (ip4_addr_get_u32(&netif->ip_addr.u_addr.ip4) >> 24)) {
+ ifaddr->ifa_flags |= IFF_LOOPBACK;
+ }
+
return ifaddr;
}
More information about the vc
mailing list