diff options
author | Kozlov Dmitry <dima@server> | 2011-08-23 18:02:22 +0400 |
---|---|---|
committer | Kozlov Dmitry <dima@server> | 2011-08-23 18:02:22 +0400 |
commit | 9bc3fa4216fb2ad043232584b5a5e134e64830ed (patch) | |
tree | 910b5a0809a272d8525ff1ed2c1265b7f7d53c3d /accel-pppd/extra | |
parent | e281cbf20eb2e8f36ef5037e138fdf3798f1897d (diff) | |
download | accel-ppp-9bc3fa4216fb2ad043232584b5a5e134e64830ed.tar.gz accel-ppp-9bc3fa4216fb2ad043232584b5a5e134e64830ed.zip |
ppp: ipv6: multiple prefixes, route option, rdnss option implementation
Diffstat (limited to 'accel-pppd/extra')
-rw-r--r-- | accel-pppd/extra/ipv6pool.c | 37 | ||||
-rw-r--r-- | accel-pppd/extra/net-snmp/sessionTable_data_access.c | 3 | ||||
-rw-r--r-- | accel-pppd/extra/net-snmp/terminate.c | 3 | ||||
-rw-r--r-- | accel-pppd/extra/pppd_compat.c | 5 |
4 files changed, 33 insertions, 15 deletions
diff --git a/accel-pppd/extra/ipv6pool.c b/accel-pppd/extra/ipv6pool.c index 306d5bdd..5a1a6065 100644 --- a/accel-pppd/extra/ipv6pool.c +++ b/accel-pppd/extra/ipv6pool.c @@ -39,6 +39,7 @@ static void generate_pool(struct in6_addr *addr, int mask, int prefix_len) { struct ippool_item_t *it; uint64_t ip, endip, step; + struct ipv6db_addr_t *a; ip = be64toh(*(uint64_t *)addr->s6_addr); endip = ip | ((1llu << (64 - mask)) - 1); @@ -46,8 +47,13 @@ static void generate_pool(struct in6_addr *addr, int mask, int prefix_len) for (; ip <= endip; ip += step) { it = malloc(sizeof(*it)); - *(uint64_t *)it->it.addr.s6_addr = htobe64(ip); - it->it.prefix_len = prefix_len; + INIT_LIST_HEAD(&it->it.addr_list); + INIT_LIST_HEAD(&it->it.route_list); + a = malloc(sizeof(*a)); + memset(a, 0, sizeof(*a)); + *(uint64_t *)a->addr.s6_addr = htobe64(ip); + a->prefix_len = prefix_len; + list_add_tail(&a->entry, &it->it.addr_list); list_add_tail(&it->entry, &ippool); } } @@ -97,27 +103,36 @@ err: _free(val); } -static void generate_intf_id(struct ppp_t *ppp, struct in6_addr *addr) +static uint64_t generate_intf_id(struct ppp_t *ppp) { char str[4]; int i, n; + union { + uint64_t intf_id; + uint16_t addr16[4]; + } u; switch (conf_intf_id) { case INTF_ID_FIXED: - *(uint64_t *)(&addr->s6_addr32[2]) = conf_intf_id_val; + return conf_intf_id_val; break; case INTF_ID_RANDOM: - read(urandom_fd, &addr->s6_addr32[2], 8); + read(urandom_fd, &u, sizeof(u)); break; case INTF_ID_CSID: break; case INTF_ID_IPV4: - for (i = 0; i < 4; i++) { - sprintf(str, "%i", (ppp->peer_ipaddr >> (i*8)) & 0xff); - sscanf(str, "%x", &n); - addr->s6_addr16[4 + i] = htons(n); - } + if (ppp->ipv4) { + for (i = 0; i < 4; i++) { + sprintf(str, "%i", (ppp->ipv4->peer_addr >> (i*8)) & 0xff); + sscanf(str, "%x", &n); + u.addr16[i] = htons(n); + } + } else + read(urandom_fd, &u, sizeof(u)); } + + return u.intf_id; } static struct ipv6db_item_t *get_ip(struct ppp_t *ppp) @@ -133,7 +148,7 @@ static struct ipv6db_item_t *get_ip(struct ppp_t *ppp) spin_unlock(&pool_lock); if (it) - generate_intf_id(ppp, &it->it.addr); + it->it.intf_id = generate_intf_id(ppp); return it ? &it->it : NULL; } diff --git a/accel-pppd/extra/net-snmp/sessionTable_data_access.c b/accel-pppd/extra/net-snmp/sessionTable_data_access.c index 847197af..0d38e5df 100644 --- a/accel-pppd/extra/net-snmp/sessionTable_data_access.c +++ b/accel-pppd/extra/net-snmp/sessionTable_data_access.c @@ -16,6 +16,7 @@ #include "sessionTable_data_access.h" #include "ppp.h" +#include "ipdb.h" /** @ingroup interface * @addtogroup data_access data_access: Routines to access data @@ -227,7 +228,7 @@ sessionTable_container_load(netsnmp_container *container) else ppp->username = strdup(""); - rowreq_ctx->data->peer_addr = ppp->peer_ipaddr; + rowreq_ctx->data->peer_addr = ppp->ipv4 ? ppp->ipv4->peer_addr : 0; rowreq_ctx->data->type = ppp->ctrl->type; rowreq_ctx->data->state = ppp->state; rowreq_ctx->data->uptime = (ppp->stop_time ? ppp->stop_time : t) - ppp->start_time; diff --git a/accel-pppd/extra/net-snmp/terminate.c b/accel-pppd/extra/net-snmp/terminate.c index bd385772..abe92df0 100644 --- a/accel-pppd/extra/net-snmp/terminate.c +++ b/accel-pppd/extra/net-snmp/terminate.c @@ -12,6 +12,7 @@ #include "triton.h" #include "ppp.h" +#include "ipdb.h" #include "terminate.h" @@ -65,7 +66,7 @@ static void terminate_by_ip(const char *val, size_t len) pthread_rwlock_rdlock(&ppp_lock); list_for_each_entry(ppp, &ppp_list, entry) { - if (ppp->peer_ipaddr != addr) + if (!ppp->ipv4 || ppp->ipv4->peer_addr != addr) continue; triton_context_call(ppp->ctrl->ctx, (triton_event_func)__terminate, ppp); break; diff --git a/accel-pppd/extra/pppd_compat.c b/accel-pppd/extra/pppd_compat.c index aa6f6b59..32a5def9 100644 --- a/accel-pppd/extra/pppd_compat.c +++ b/accel-pppd/extra/pppd_compat.c @@ -14,6 +14,7 @@ #include "events.h" #include "ppp.h" +#include "ipdb.h" #include "log.h" #include "utils.h" #include "sigchld.h" @@ -480,8 +481,8 @@ static void fill_argv(char **argv, struct ppp_t *ppp, char *path) argv[1] = ppp->ifname; argv[2] = "none"; argv[3] = "0"; - u_inet_ntoa(ppp->ipaddr, argv[4]); - u_inet_ntoa(ppp->peer_ipaddr, argv[5]); + u_inet_ntoa(ppp->ipv4 ? ppp->ipv4->addr : 0, argv[4]); + u_inet_ntoa(ppp->ipv4 ? ppp->ipv4->peer_addr : 0, argv[5]); argv[6] = ppp->ctrl->calling_station_id; argv[7] = NULL; } |