summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2011-08-20 10:05:23 +0400
committerDmitry Kozlov <xeb@mail.ru>2011-08-20 10:05:23 +0400
commita93e43804c9a37b3cc2141d5ada3158653a7a221 (patch)
tree96e51396d3d7cd2c2ba69d274faa7a9760df457e /accel-pppd
parent5ef49162ea9763ca9878c22e3736766d8f1db014 (diff)
parentef1d4c04584076dc77fc8df62c996feb1ac10c41 (diff)
downloadaccel-ppp-a93e43804c9a37b3cc2141d5ada3158653a7a221.tar.gz
accel-ppp-a93e43804c9a37b3cc2141d5ada3158653a7a221.zip
Merge branch 'ipv6'
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/CMakeLists.txt2
-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/ccp_mppe.c1
-rw-r--r--accel-pppd/ppp/ipcp_opt_ipaddr.c6
-rw-r--r--accel-pppd/ppp/ppp.c1
-rw-r--r--accel-pppd/ppp/ppp.h5
-rw-r--r--accel-pppd/ppp/ppp_ccp.c1
-rw-r--r--accel-pppd/radius/radius.c25
-rw-r--r--accel-pppd/radius/radius_p.h3
12 files changed, 86 insertions, 33 deletions
diff --git a/accel-pppd/CMakeLists.txt b/accel-pppd/CMakeLists.txt
index 39d57944..45a070fe 100644
--- a/accel-pppd/CMakeLists.txt
+++ b/accel-pppd/CMakeLists.txt
@@ -65,6 +65,8 @@ ADD_EXECUTABLE(accel-pppd
ppp/ppp_ipcp.c
ppp/ipcp_opt_ipaddr.c
ppp/ipcp_opt_dns.c
+ ppp/ipv6cp_opt_intfid.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 20565b97..61cd2a91 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 6f07e5f8..d49f0f44 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 ippool_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/ccp_mppe.c b/accel-pppd/ppp/ccp_mppe.c
index ba86ef47..7d9aab21 100644
--- a/accel-pppd/ppp/ccp_mppe.c
+++ b/accel-pppd/ppp/ccp_mppe.c
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include "linux_ppp.h"
diff --git a/accel-pppd/ppp/ipcp_opt_ipaddr.c b/accel-pppd/ppp/ipcp_opt_ipaddr.c
index d584fd7f..217a0806 100644
--- a/accel-pppd/ppp/ipcp_opt_ipaddr.c
+++ b/accel-pppd/ppp/ipcp_opt_ipaddr.c
@@ -30,7 +30,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;
};
@@ -59,7 +59,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);
}
@@ -88,7 +88,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/ppp/ppp.c b/accel-pppd/ppp/ppp.c
index 5c529489..b541ba50 100644
--- a/accel-pppd/ppp/ppp.c
+++ b/accel-pppd/ppp/ppp.c
@@ -494,6 +494,7 @@ static int get_layer_order(const char *name)
if (!strcmp(name,"auth")) return 1;
if (!strcmp(name,"ccp")) return 2;
if (!strcmp(name,"ipcp")) return 2;
+ if (!strcmp(name,"ipv6cp")) return 2;
return -1;
}
diff --git a/accel-pppd/ppp/ppp.h b/accel-pppd/ppp/ppp.h
index c0ebe834..ae2a7c99 100644
--- a/accel-pppd/ppp/ppp.h
+++ b/accel-pppd/ppp/ppp.h
@@ -3,7 +3,6 @@
#include <sys/types.h>
#include <time.h>
-#include <netinet/in.h>
#include <pthread.h>
#include "triton.h"
@@ -99,8 +98,8 @@ struct ppp_t
time_t start_time;
time_t stop_time;
char *username;
- in_addr_t ipaddr;
- in_addr_t peer_ipaddr;
+ uint32_t ipaddr;
+ uint32_t peer_ipaddr;
struct ppp_ctrl_t *ctrl;
diff --git a/accel-pppd/ppp/ppp_ccp.c b/accel-pppd/ppp/ppp_ccp.c
index c277f9f9..79b0c32d 100644
--- a/accel-pppd/ppp/ppp_ccp.c
+++ b/accel-pppd/ppp/ppp_ccp.c
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include "linux_ppp.h"
diff --git a/accel-pppd/radius/radius.c b/accel-pppd/radius/radius.c
index 0fc42cd1..5f507cb4 100644
--- a/accel-pppd/radius/radius.c
+++ b/accel-pppd/radius/radius.c
@@ -90,9 +90,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:
@@ -163,15 +163,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);
@@ -402,7 +412,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 8c3a10d5..578c7770 100644
--- a/accel-pppd/radius/radius_p.h
+++ b/accel-pppd/radius/radius_p.h
@@ -33,7 +33,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;