diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2021-09-08 16:59:16 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2021-09-08 16:59:16 +0300 |
commit | faf7d93f34f588e0a8b1f1acc9ab421702831dc4 (patch) | |
tree | 0654ec1ee794b3d03119f5ef3f6c5af7a7228bab /accel-pppd/ctrl/ipoe/ipoe.c | |
parent | 5daf0f6782b769600855f745aa0a2e514a06a8aa (diff) | |
download | accel-ppp-faf7d93f34f588e0a8b1f1acc9ab421702831dc4.tar.gz accel-ppp-faf7d93f34f588e0a8b1f1acc9ab421702831dc4.zip |
ipoe: check for local-net in arp requests
Diffstat (limited to 'accel-pppd/ctrl/ipoe/ipoe.c')
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 2645fbc6..dbc3f19f 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -237,6 +237,21 @@ static void ipoe_ctx_switch(struct triton_context_t *ctx, void *arg) log_switch(ctx, arg); } +int ipoe_check_localnet(in_addr_t addr) +{ + struct local_net *n; + + if (list_empty(&local_nets)) + return 1; + + list_for_each_entry(n, &local_nets, entry) { + if ((addr & n->mask) == n->addr) + return 1; + } + + return 0; +} + static struct ipoe_session *ipoe_session_lookup(struct ipoe_serv *serv, struct dhcpv4_packet *pack, struct ipoe_session **opt82_ses) { struct ipoe_session *ses, *res = NULL; @@ -3731,6 +3746,9 @@ static void parse_local_net(const char *opt) mask = 24; } + mask = htonl(mask ? ~0 << (32 - mask) : 0); + addr = addr & mask; + list_for_each_entry(n, &local_nets, entry) { if (n->addr == addr && n->mask == mask) { n->active = 1; @@ -3744,7 +3762,7 @@ static void parse_local_net(const char *opt) n->active = 1; list_add_tail(&n->entry, &local_nets); - ipoe_nl_add_net(addr, mask); + ipoe_nl_add_net(addr, ntohl(mask)); return; |