diff options
Diffstat (limited to 'src/ipv4.c')
| -rw-r--r-- | src/ipv4.c | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -170,6 +170,23 @@ ipv4_iffindmaskaddr(struct interface *ifp, const struct in_addr *addr) return NULL; } +static struct ipv4_addr * +ipv4_iffindmaskbrd(struct interface *ifp, const struct in_addr *addr) +{ + struct ipv4_state *state; + struct ipv4_addr *ap; + + state = IPV4_STATE(ifp); + if (state) { + TAILQ_FOREACH (ap, &state->addrs, next) { + if ((ap->brd.s_addr & ap->mask.s_addr) == + (addr->s_addr & ap->mask.s_addr)) + return ap; + } + } + return NULL; +} + struct ipv4_addr * ipv4_findaddr(struct dhcpcd_ctx *ctx, const struct in_addr *addr) { @@ -198,6 +215,20 @@ ipv4_findmaskaddr(struct dhcpcd_ctx *ctx, const struct in_addr *addr) return NULL; } +struct ipv4_addr * +ipv4_findmaskbrd(struct dhcpcd_ctx *ctx, const struct in_addr *addr) +{ + struct interface *ifp; + struct ipv4_addr *ap; + + TAILQ_FOREACH(ifp, ctx->ifaces, next) { + ap = ipv4_iffindmaskbrd(ifp, addr); + if (ap) + return ap; + } + return NULL; +} + int ipv4_hasaddr(const struct interface *ifp) { |
