summaryrefslogtreecommitdiffstats
path: root/src/ipv4.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipv4.c')
-rw-r--r--src/ipv4.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/ipv4.c b/src/ipv4.c
index 866486c2..7bf7db38 100644
--- a/src/ipv4.c
+++ b/src/ipv4.c
@@ -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)
{