summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accel-pppd/CMakeLists.txt1
-rw-r--r--accel-pppd/extra/chap-secrets.c6
-rw-r--r--accel-pppd/extra/ippool.c10
-rw-r--r--accel-pppd/ipdb.c37
-rw-r--r--accel-pppd/ipdb.h22
-rw-r--r--accel-pppd/ppp/ipcp_opt_ipaddr.c6
-rw-r--r--accel-pppd/radius/radius.c25
-rw-r--r--accel-pppd/radius/radius_p.h3
8 files changed, 80 insertions, 30 deletions
diff --git a/accel-pppd/CMakeLists.txt b/accel-pppd/CMakeLists.txt
index 8e0af478..10de4bbf 100644
--- a/accel-pppd/CMakeLists.txt
+++ b/accel-pppd/CMakeLists.txt
@@ -65,6 +65,7 @@ ADD_EXECUTABLE(accel-pppd
ppp/ppp_ipcp.c
ppp/ipcp_opt_ipaddr.c
ppp/ipcp_opt_dns.c
+ ppp/ppp_ipv6cp.c
ppp/ppp_ccp.c
ppp/ccp_mppe.c
diff --git a/accel-pppd/extra/chap-secrets.c b/accel-pppd/extra/chap-secrets.c
index a42ab236..3a299ccb 100644
--- a/accel-pppd/extra/chap-secrets.c
+++ b/accel-pppd/extra/chap-secrets.c
@@ -24,7 +24,7 @@ static struct ipdb_t ipdb;
struct cs_pd_t
{
struct ppp_pd_t pd;
- struct ipdb_item_t ip;
+ struct ipv4db_item_t ip;
char *passwd;
char *rate;
};
@@ -212,7 +212,7 @@ static void ev_ppp_pre_up(struct ppp_t *ppp)
}
}
-static struct ipdb_item_t *get_ip(struct ppp_t *ppp)
+static struct ipv4db_item_t *get_ip(struct ppp_t *ppp)
{
struct cs_pd_t *pd;
@@ -244,7 +244,7 @@ static char* get_passwd(struct pwdb_t *pwdb, struct ppp_t *ppp, const char *user
}
static struct ipdb_t ipdb = {
- .get = get_ip,
+ .get_ipv4 = get_ip,
};
static struct pwdb_t pwdb = {
diff --git a/accel-pppd/extra/ippool.c b/accel-pppd/extra/ippool.c
index 20da17c0..2637c6a6 100644
--- a/accel-pppd/extra/ippool.c
+++ b/accel-pppd/extra/ippool.c
@@ -14,7 +14,7 @@
struct ippool_item_t
{
struct list_head entry;
- struct ipdb_item_t it;
+ struct ipv4db_item_t it;
};
struct ipaddr_t
@@ -153,7 +153,7 @@ static void generate_pool(void)
}
}
-static struct ipdb_item_t *get_ip(struct ppp_t *ppp)
+static struct ipv4db_item_t *get_ip(struct ppp_t *ppp)
{
struct ippool_item_t *it;
@@ -168,7 +168,7 @@ static struct ipdb_item_t *get_ip(struct ppp_t *ppp)
return it ? &it->it : NULL;
}
-static void put_ip(struct ppp_t *ppp, struct ipdb_item_t *it)
+static void put_ip(struct ppp_t *ppp, struct ipv4db_item_t *it)
{
struct ippool_item_t *pit = container_of(it, typeof(*pit), it);
@@ -178,8 +178,8 @@ static void put_ip(struct ppp_t *ppp, struct ipdb_item_t *it)
}
static struct ipdb_t ipdb = {
- .get = get_ip,
- .put = put_ip,
+ .get_ipv4 = get_ip,
+ .put_ipv4 = put_ip,
};
static void __init ipool_init(void)
diff --git a/accel-pppd/ipdb.c b/accel-pppd/ipdb.c
index a08d3be2..8054e6bf 100644
--- a/accel-pppd/ipdb.c
+++ b/accel-pppd/ipdb.c
@@ -5,13 +5,15 @@
static LIST_HEAD(ipdb_handlers);
-__export struct ipdb_item_t *ipdb_get(struct ppp_t *ppp)
+struct ipv4db_item_t __export *ipdb_get_ipv4(struct ppp_t *ppp)
{
struct ipdb_t *ipdb;
- struct ipdb_item_t *it;
+ struct ipv4db_item_t *it;
list_for_each_entry(ipdb, &ipdb_handlers, entry) {
- it = ipdb->get(ppp);
+ if (!ipdb->get_ipv4)
+ continue;
+ it = ipdb->get_ipv4(ppp);
if (it)
return it;
}
@@ -19,12 +21,35 @@ __export struct ipdb_item_t *ipdb_get(struct ppp_t *ppp)
return NULL;
}
-void __export ipdb_put(struct ppp_t *ppp, struct ipdb_item_t *it)
+void __export ipdb_put_ipv4(struct ppp_t *ppp, struct ipv4db_item_t *it)
{
- if (it->owner->put)
- it->owner->put(ppp, it);
+ if (it->owner->put_ipv4)
+ it->owner->put_ipv4(ppp, it);
}
+struct ipv6db_item_t __export *ipdb_get_ipv6(struct ppp_t *ppp)
+{
+ struct ipdb_t *ipdb;
+ struct ipv6db_item_t *it;
+
+ list_for_each_entry(ipdb, &ipdb_handlers, entry) {
+ if (!ipdb->get_ipv6)
+ continue;
+ it = ipdb->get_ipv6(ppp);
+ if (it)
+ return it;
+ }
+
+ return NULL;
+}
+
+void __export ipdb_put_ipv6(struct ppp_t *ppp, struct ipv6db_item_t *it)
+{
+ if (it->owner->put_ipv4)
+ it->owner->put_ipv6(ppp, it);
+}
+
+
void __export ipdb_register(struct ipdb_t *ipdb)
{
list_add_tail(&ipdb->entry, &ipdb_handlers);
diff --git a/accel-pppd/ipdb.h b/accel-pppd/ipdb.h
index ebf38853..35394205 100644
--- a/accel-pppd/ipdb.h
+++ b/accel-pppd/ipdb.h
@@ -6,22 +6,34 @@
#include "ppp.h"
#include "list.h"
-struct ipdb_item_t
+struct ipv4db_item_t
{
struct ipdb_t *owner;
in_addr_t addr;
in_addr_t peer_addr;
};
+struct ipv6db_item_t
+{
+ struct ipdb_t *owner;
+ struct in6_addr addr;
+ struct in6_addr peer_addr;
+};
+
+
struct ipdb_t
{
struct list_head entry;
- struct ipdb_item_t *(*get)(struct ppp_t *ppp);
- void (*put)(struct ppp_t *ppp, struct ipdb_item_t *);
+ struct ipv4db_item_t *(*get_ipv4)(struct ppp_t *ppp);
+ void (*put_ipv4)(struct ppp_t *ppp, struct ipv4db_item_t *);
+ struct ipv6db_item_t *(*get_ipv6)(struct ppp_t *ppp);
+ void (*put_ipv6)(struct ppp_t *ppp, struct ipv6db_item_t *);
};
-struct ipdb_item_t *ipdb_get(struct ppp_t *ppp);
-void ipdb_put(struct ppp_t *ppp, struct ipdb_item_t *);
+struct ipv4db_item_t *ipdb_get_ipv4(struct ppp_t *ppp);
+void ipdb_put_ipv4(struct ppp_t *ppp, struct ipv4db_item_t *);
+struct ipv6db_item_t *ipdb_get_ipv6(struct ppp_t *ppp);
+void ipdb_put_ipv6(struct ppp_t *ppp, struct ipv6db_item_t *);
void ipdb_register(struct ipdb_t *);
diff --git a/accel-pppd/ppp/ipcp_opt_ipaddr.c b/accel-pppd/ppp/ipcp_opt_ipaddr.c
index 334f4256..de1186e7 100644
--- a/accel-pppd/ppp/ipcp_opt_ipaddr.c
+++ b/accel-pppd/ppp/ipcp_opt_ipaddr.c
@@ -29,7 +29,7 @@ static void ipaddr_print(void (*print)(const char *fmt,...),struct ipcp_option_t
struct ipaddr_option_t
{
struct ipcp_option_t opt;
- struct ipdb_item_t *ip;
+ struct ipv4db_item_t *ip;
int started:1;
};
@@ -58,7 +58,7 @@ static void ipaddr_free(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *opt)
struct ipaddr_option_t *ipaddr_opt=container_of(opt,typeof(*ipaddr_opt),opt);
if (ipaddr_opt->ip)
- ipdb_put(ipcp->ppp, ipaddr_opt->ip);
+ ipdb_put_ipv4(ipcp->ppp, ipaddr_opt->ip);
_free(ipaddr_opt);
}
@@ -87,7 +87,7 @@ static int ipaddr_send_conf_req(struct ppp_ipcp_t *ipcp, struct ipcp_option_t *o
struct ipcp_opt32_t *opt32=(struct ipcp_opt32_t*)ptr;
if (!ipaddr_opt->ip) {
- ipaddr_opt->ip = ipdb_get(ipcp->ppp);
+ ipaddr_opt->ip = ipdb_get_ipv4(ipcp->ppp);
if (!ipaddr_opt->ip) {
log_ppp_warn("ppp:ipcp: no free IP address\n");
return -1;
diff --git a/accel-pppd/radius/radius.c b/accel-pppd/radius/radius.c
index edf3120e..64ce90f5 100644
--- a/accel-pppd/radius/radius.c
+++ b/accel-pppd/radius/radius.c
@@ -94,9 +94,9 @@ int rad_proc_attrs(struct rad_req_t *req)
if (!conf_gw_ip_address)
log_ppp_warn("radius: gw-ip-address not specified, cann't assign IP address...\n");
else {
- req->rpd->ipaddr.owner = &ipdb;
- req->rpd->ipaddr.peer_addr = attr->val.ipaddr;
- req->rpd->ipaddr.addr = conf_gw_ip_address;
+ req->rpd->ipv4_addr.owner = &ipdb;
+ req->rpd->ipv4_addr.peer_addr = attr->val.ipaddr;
+ req->rpd->ipv4_addr.addr = conf_gw_ip_address;
}
break;
case Acct_Interim_Interval:
@@ -167,15 +167,25 @@ static int check(struct pwdb_t *pwdb, struct ppp_t *ppp, const char *username, i
return r;
}
-static struct ipdb_item_t *get_ip(struct ppp_t *ppp)
+static struct ipv4db_item_t *get_ipv4(struct ppp_t *ppp)
{
struct radius_pd_t *rpd = find_pd(ppp);
- if (rpd->ipaddr.peer_addr)
- return &rpd->ipaddr;
+ if (rpd->ipv4_addr.peer_addr)
+ return &rpd->ipv4_addr;
return NULL;
}
+static struct ipv6db_item_t *get_ipv6(struct ppp_t *ppp)
+{
+ struct radius_pd_t *rpd = find_pd(ppp);
+
+ if (memcmp(&rpd->ipv6_addr.peer_addr, &in6addr_any, sizeof(in6addr_any)))
+ return &rpd->ipv6_addr;
+ return NULL;
+}
+
+
static void session_timeout(struct triton_timer_t *t)
{
struct radius_pd_t *rpd = container_of(t, typeof(*rpd), session_timeout);
@@ -406,7 +416,8 @@ void __export rad_register_plugin(struct ppp_t *ppp, struct rad_plugin_t *plugin
}
static struct ipdb_t ipdb = {
- .get = get_ip,
+ .get_ipv4 = get_ipv4,
+ .get_ipv6 = get_ipv6,
};
static struct pwdb_t pwdb = {
diff --git a/accel-pppd/radius/radius_p.h b/accel-pppd/radius/radius_p.h
index 32acd497..5450b7d0 100644
--- a/accel-pppd/radius/radius_p.h
+++ b/accel-pppd/radius/radius_p.h
@@ -31,7 +31,8 @@ struct radius_pd_t
struct rad_packet_t *dm_coa_req;
struct sockaddr_in dm_coa_addr;
- struct ipdb_item_t ipaddr;
+ struct ipv4db_item_t ipv4_addr;
+ struct ipv6db_item_t ipv6_addr;
int acct_interim_interval;
time_t acct_timestamp;