summaryrefslogtreecommitdiff
path: root/accel-pptpd/radius
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2010-09-27 23:55:11 +0400
committerDmitry Kozlov <xeb@mail.ru>2010-09-27 23:55:11 +0400
commit2902ea733331c1a083487666dbdd847518a0f117 (patch)
treec0d9239c735a5ef14561af4e6e866f16c154c723 /accel-pptpd/radius
parentf9bc7d57b20a0165862cfab7259f6147fcb15733 (diff)
parent0325cc5f07ac992414129b4f47ae4aae017dbd2b (diff)
downloadaccel-ppp-2902ea733331c1a083487666dbdd847518a0f117.tar.gz
accel-ppp-2902ea733331c1a083487666dbdd847518a0f117.zip
radius: implemented Session-Timeout attribute
Diffstat (limited to 'accel-pptpd/radius')
-rw-r--r--accel-pptpd/radius/auth.c2
-rw-r--r--accel-pptpd/radius/dict/dictionary2
-rw-r--r--accel-pptpd/radius/dm_coa.c1
-rw-r--r--accel-pptpd/radius/radius.c22
-rw-r--r--accel-pptpd/radius/radius_p.h2
5 files changed, 28 insertions, 1 deletions
diff --git a/accel-pptpd/radius/auth.c b/accel-pptpd/radius/auth.c
index ccb8fc0..9b61ecc 100644
--- a/accel-pptpd/radius/auth.c
+++ b/accel-pptpd/radius/auth.c
@@ -173,7 +173,7 @@ int rad_auth_mschap_v1(struct radius_pd_t *rpd, const char *username, va_list ar
const uint8_t *nt_response = va_arg(args, const uint8_t *);
int flags = va_arg(args, int);
- req = rad_req_alloc(rpd, CODE_ACCESS_ACCEPT, username);
+ req = rad_req_alloc(rpd, CODE_ACCESS_REQUEST, username);
if (!req)
return PWDB_DENIED;
diff --git a/accel-pptpd/radius/dict/dictionary b/accel-pptpd/radius/dict/dictionary
index 8d4a797..64db18f 100644
--- a/accel-pptpd/radius/dict/dictionary
+++ b/accel-pptpd/radius/dict/dictionary
@@ -74,3 +74,5 @@ $INCLUDE dictionary.rfc5176
$INCLUDE dictionary.microsoft
+
+ATTRIBUTE Traffic-Shape-in 231 integer
diff --git a/accel-pptpd/radius/dm_coa.c b/accel-pptpd/radius/dm_coa.c
index 32466bb..d94596f 100644
--- a/accel-pptpd/radius/dm_coa.c
+++ b/accel-pptpd/radius/dm_coa.c
@@ -235,6 +235,7 @@ static void dm_coa_close(struct triton_context_t *ctx)
struct dm_coa_serv_t *serv = container_of(ctx, typeof(*serv), ctx);
triton_md_unregister_handler(&serv->hnd);
close(serv->hnd.fd);
+ triton_context_unregister(ctx);
}
static struct dm_coa_serv_t serv = {
diff --git a/accel-pptpd/radius/radius.c b/accel-pptpd/radius/radius.c
index 38ace95..42b39a5 100644
--- a/accel-pptpd/radius/radius.c
+++ b/accel-pptpd/radius/radius.c
@@ -59,6 +59,8 @@ void rad_proc_attrs(struct rad_req_t *req)
}
} else if (!strcmp(attr->attr->name, "Acct-Interim-Interval"))
req->rpd->acct_interim_interval = attr->val.integer;
+ else if (!strcmp(attr->attr->name, "Session-Timeout"))
+ req->rpd->session_timeout.expire_tv.tv_sec = attr->val.integer;
}
}
@@ -105,6 +107,14 @@ static struct ipdb_item_t *get_ip(struct ppp_t *ppp)
return NULL;
}
+static void session_timeout(struct triton_timer_t *t)
+{
+ struct radius_pd_t *rpd = container_of(t, typeof(*rpd), session_timeout);
+
+ log_ppp_msg("radius: session timed out\n");
+ ppp_terminate(rpd->ppp, 0);
+}
+
static void ppp_starting(struct ppp_t *ppp)
{
struct radius_pd_t *rpd = mempool_alloc(rpd_pool);
@@ -126,6 +136,11 @@ static void ppp_started(struct ppp_t *ppp)
if (rad_acct_start(rpd))
ppp_terminate(rpd->ppp, 0);
+
+ if (rpd->session_timeout.expire_tv.tv_sec) {
+ rpd->session_timeout.expire = session_timeout;
+ triton_timer_add(ppp->ctrl->ctx, &rpd->session_timeout, 0);
+ }
}
static void ppp_finishing(struct ppp_t *ppp)
{
@@ -149,6 +164,9 @@ static void ppp_finished(struct ppp_t *ppp)
if (rpd->dm_coa_req)
rad_packet_free(rpd->dm_coa_req);
+ if (rpd->session_timeout.tpd)
+ triton_timer_del(&rpd->session_timeout);
+
list_del(&rpd->pd.entry);
mempool_free(rpd);
@@ -302,6 +320,10 @@ static void __init radius_init(void)
if (opt)
conf_nas_ip_address = opt;
+ opt = conf_get_opt("radius", "nas-identifier");
+ if (opt)
+ conf_nas_identifier = opt;
+
opt = conf_get_opt("radius", "gw-ip-address");
if (opt)
conf_gw_ip_address = opt;
diff --git a/accel-pptpd/radius/radius_p.h b/accel-pptpd/radius/radius_p.h
index ae44223..9537641 100644
--- a/accel-pptpd/radius/radius_p.h
+++ b/accel-pptpd/radius/radius_p.h
@@ -23,6 +23,8 @@ struct radius_pd_t
uint32_t acct_input_gigawords;
uint32_t acct_output_gigawords;
+ struct triton_timer_t session_timeout;
+
struct rad_packet_t *dm_coa_req;
struct sockaddr_in dm_coa_addr;