mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-25 00:14:02 +00:00
Use NETIF_FOREACH macro at appropriate places
Use NETIF_FOREACH macro to get some optimizations for LWIP_SINGLE_NETIF case. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: goldsimon <goldsimon@gmx.de>
This commit is contained in:
parent
8c6884b2db
commit
2ff0ef027e
@ -162,7 +162,7 @@ ip4_route(const ip4_addr_t *dest)
|
||||
#endif /* LWIP_MULTICAST_TX_OPTIONS */
|
||||
|
||||
/* iterate through netifs */
|
||||
for (netif = netif_list; netif != NULL; netif = netif->next) {
|
||||
NETIF_FOREACH(netif) {
|
||||
/* is the netif up, does it have a link and a valid address? */
|
||||
if (netif_is_up(netif) && netif_is_link_up(netif) && !ip4_addr_isany_val(*netif_ip4_addr(netif))) {
|
||||
/* network mask matches? */
|
||||
@ -186,7 +186,7 @@ ip4_route(const ip4_addr_t *dest)
|
||||
return netif_default;
|
||||
}
|
||||
/* default netif is not up, just use any netif for loopback traffic */
|
||||
for (netif = netif_list; netif != NULL; netif = netif->next) {
|
||||
NETIF_FOREACH(netif) {
|
||||
if (netif_is_up(netif)) {
|
||||
return netif;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)
|
||||
IP6_ADDR_ZONECHECK(dest);
|
||||
/* Find a netif based on the zone. For custom mappings, one zone may map
|
||||
* to multiple netifs, so find one that can actually send a packet. */
|
||||
for (netif = netif_list; netif != NULL; netif = netif->next) {
|
||||
NETIF_FOREACH(netif) {
|
||||
if (ip6_addr_test_zone(dest, netif) &&
|
||||
netif_is_up(netif) && netif_is_link_up(netif)) {
|
||||
return netif;
|
||||
@ -148,7 +148,7 @@ ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)
|
||||
#if LWIP_IPV6_SCOPES
|
||||
if (ip6_addr_has_zone(src)) {
|
||||
/* Find a netif matching the source zone (relatively cheap). */
|
||||
for (netif = netif_list; netif != NULL; netif = netif->next) {
|
||||
NETIF_FOREACH(netif) {
|
||||
if (netif_is_up(netif) && netif_is_link_up(netif) &&
|
||||
ip6_addr_test_zone(src, netif)) {
|
||||
return netif;
|
||||
@ -158,7 +158,7 @@ ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)
|
||||
#endif /* LWIP_IPV6_SCOPES */
|
||||
{
|
||||
/* Find a netif matching the source address (relatively expensive). */
|
||||
for (netif = netif_list; netif != NULL; netif = netif->next) {
|
||||
NETIF_FOREACH(netif) {
|
||||
if (!netif_is_up(netif) || !netif_is_link_up(netif)) {
|
||||
continue;
|
||||
}
|
||||
@ -191,7 +191,7 @@ ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)
|
||||
* such, the destination address may still match a local address, and so we
|
||||
* still need to check for exact matches here. By (lwIP) policy, statically
|
||||
* configured addresses do always have an implied local /64 subnet. */
|
||||
for (netif = netif_list; netif != NULL; netif = netif->next) {
|
||||
NETIF_FOREACH(netif) {
|
||||
if (!netif_is_up(netif) || !netif_is_link_up(netif)) {
|
||||
continue;
|
||||
}
|
||||
@ -214,7 +214,7 @@ ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)
|
||||
/* Try with the netif that matches the source address. Given the earlier rule
|
||||
* for scoped source addresses, this applies to unscoped addresses only. */
|
||||
if (!ip6_addr_isany(src)) {
|
||||
for (netif = netif_list; netif != NULL; netif = netif->next) {
|
||||
NETIF_FOREACH(netif) {
|
||||
if (!netif_is_up(netif) || !netif_is_link_up(netif)) {
|
||||
continue;
|
||||
}
|
||||
@ -235,7 +235,7 @@ ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)
|
||||
return netif_default;
|
||||
}
|
||||
/* default netif is not up, just use any netif for loopback traffic */
|
||||
for (netif = netif_list; netif != NULL; netif = netif->next) {
|
||||
NETIF_FOREACH(netif) {
|
||||
if (netif_is_up(netif)) {
|
||||
return netif;
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ netif_remove(struct netif *netif)
|
||||
} else {
|
||||
/* look for netif further down the list */
|
||||
struct netif *tmp_netif;
|
||||
for (tmp_netif = netif_list; tmp_netif != NULL; tmp_netif = tmp_netif->next) {
|
||||
NETIF_FOREACH(tmp_netif) {
|
||||
if (tmp_netif->next == netif) {
|
||||
tmp_netif->next = netif->next;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user