diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2018-01-05 16:06:17 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2018-01-05 16:06:17 +0300 |
commit | 16e4de5b5e7fbbddd3f94a2cfcbdc079a1f00ce9 (patch) | |
tree | 58c1941afb004e1122d6e945e0c0a906f1863580 /accel-pppd/ctrl/ipoe | |
parent | bff66de7a08a6c62d263efc4fd2ef151094c83b7 (diff) | |
download | accel-ppp-16e4de5b5e7fbbddd3f94a2cfcbdc079a1f00ce9.tar.gz accel-ppp-16e4de5b5e7fbbddd3f94a2cfcbdc079a1f00ce9.zip |
ipoe: implemented ipv6 in shared mode
Diffstat (limited to 'accel-pppd/ctrl/ipoe')
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 40 | ||||
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.h | 2 |
2 files changed, 42 insertions, 0 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 640970b1..c0adc7fa 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -214,6 +214,7 @@ static void ipoe_session_create_auto(struct ipoe_serv *serv); static void ipoe_serv_timeout(struct triton_timer_t *t); static struct ipoe_session *ipoe_session_create_up(struct ipoe_serv *serv, struct ethhdr *eth, struct iphdr *iph, struct _arphdr *arph); static void __terminate(struct ap_session *ses); +static void ipoe_ipv6_disable(struct ipoe_serv *serv); static void ipoe_ctx_switch(struct triton_context_t *ctx, void *arg) { @@ -2389,6 +2390,9 @@ static void ipoe_serv_release(struct ipoe_serv *serv) if (serv->arp) arpd_stop(serv->arp); + if (serv->opt_ipv6) + ipoe_ipv6_disable(serv); + while (!list_empty(&serv->disc_list)) { struct disc_item *d = list_entry(serv->disc_list.next, typeof(*d), entry); list_del(&d->entry); @@ -2705,6 +2709,39 @@ static void ipoe_serv_timeout(struct triton_timer_t *t) ipoe_serv_release(serv); } +static void ipoe_ipv6_enable(struct ipoe_serv *serv) +{ + struct ifreq ifr; + + strcpy(ifr.ifr_name, serv->ifname); + + ifr.ifr_hwaddr.sa_family = AF_UNSPEC; + ifr.ifr_hwaddr.sa_data[0] = 0x33; + ifr.ifr_hwaddr.sa_data[1] = 0x33; + *(uint32_t *)(ifr.ifr_hwaddr.sa_data + 2) = htonl(0x02); + ioctl(sock_fd, SIOCADDMULTI, &ifr); + + *(uint32_t *)(ifr.ifr_hwaddr.sa_data + 2) = htonl(0x010002); + ioctl(sock_fd, SIOCADDMULTI, &ifr); +} + +static void ipoe_ipv6_disable(struct ipoe_serv *serv) +{ + struct ifreq ifr; + + strcpy(ifr.ifr_name, serv->ifname); + + ifr.ifr_hwaddr.sa_family = AF_UNSPEC; + ifr.ifr_hwaddr.sa_data[0] = 0x33; + ifr.ifr_hwaddr.sa_data[1] = 0x33; + *(uint32_t *)(ifr.ifr_hwaddr.sa_data + 2) = htonl(0x02); + ioctl(sock_fd, SIOCDELMULTI, &ifr); + + *(uint32_t *)(ifr.ifr_hwaddr.sa_data + 2) = htonl(0x010002); + ioctl(sock_fd, SIOCDELMULTI, &ifr); +} + + static void add_interface(const char *ifname, int ifindex, const char *opt, int parent_ifindex, int vid, int vlan_mon) { char *str0 = NULL, *str, *ptr1, *ptr2; @@ -3012,6 +3049,9 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int if (serv->opt_arp) serv->arp = arpd_start(serv); + if (serv->opt_ipv6 && serv->opt_shared) + ipoe_ipv6_enable(serv); + if (vlan_mon) { serv->vlan_mon = 1; set_vlan_timeout(serv); diff --git a/accel-pppd/ctrl/ipoe/ipoe.h b/accel-pppd/ctrl/ipoe/ipoe.h index fc774f67..b3912beb 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.h +++ b/accel-pppd/ctrl/ipoe/ipoe.h @@ -126,6 +126,8 @@ struct ipoe_session_info { uint32_t peer_addr; }; +int ipoe_ipv6_nd_start(struct ipoe_serv *serv); + #ifdef USE_LUA char *ipoe_lua_get_username(struct ipoe_session *, const char *func); int ipoe_lua_make_vlan_name(const char *func, const char *parent, int svid, int cvid, char *name); |