summaryrefslogtreecommitdiff
path: root/accel-pptpd/auth/auth_mschap_v2.c
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pptpd/auth/auth_mschap_v2.c')
-rw-r--r--accel-pptpd/auth/auth_mschap_v2.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/accel-pptpd/auth/auth_mschap_v2.c b/accel-pptpd/auth/auth_mschap_v2.c
index 8e4a7c08..08cdde93 100644
--- a/accel-pptpd/auth/auth_mschap_v2.c
+++ b/accel-pptpd/auth/auth_mschap_v2.c
@@ -109,8 +109,8 @@ struct chap_auth_data_t
static void chap_send_challenge(struct chap_auth_data_t *ad);
static void chap_recv(struct ppp_handler_t *h);
static int chap_check_response(struct chap_auth_data_t *ad, struct chap_response_t *msg, const char *name);
-static void chap_timeout(struct triton_timer_t *t);
-static void chap_restart(struct triton_timer_t *t);
+static void chap_timeout_timer(struct triton_timer_t *t);
+static void chap_restart_timer(struct triton_timer_t *t);
static void print_buf(const uint8_t *buf, int size)
{
@@ -141,6 +141,12 @@ static void auth_data_free(struct ppp_t *ppp, struct auth_data_t *auth)
{
struct chap_auth_data_t *d = container_of(auth, typeof(*d), auth);
+ if (d->timeout.tpd)
+ triton_timer_del(&d->timeout);
+
+ if (d->interval.tpd)
+ triton_timer_del(&d->interval);
+
_free(d);
}
@@ -150,9 +156,9 @@ static int chap_start(struct ppp_t *ppp, struct auth_data_t *auth)
d->h.proto = PPP_CHAP;
d->h.recv = chap_recv;
- d->timeout.expire = chap_timeout;
+ d->timeout.expire = chap_timeout_timer;
d->timeout.period = conf_timeout * 1000;
- d->interval.expire = chap_restart;
+ d->interval.expire = chap_restart_timer;
d->interval.period = conf_interval * 1000;
ppp_register_chan_handler(ppp, &d->h);
@@ -177,7 +183,7 @@ static int chap_finish(struct ppp_t *ppp, struct auth_data_t *auth)
return 0;
}
-static void chap_timeout(struct triton_timer_t *t)
+static void chap_timeout_timer(struct triton_timer_t *t)
{
struct chap_auth_data_t *d = container_of(t, typeof(*d), timeout);
@@ -188,14 +194,14 @@ static void chap_timeout(struct triton_timer_t *t)
if (d->started)
ppp_terminate(d->ppp, TERM_USER_ERROR, 0);
else
- auth_failed(d->ppp);
+ ppp_auth_failed(d->ppp);
} else {
--d->id;
chap_send_challenge(d);
}
}
-static void chap_restart(struct triton_timer_t *t)
+static void chap_restart_timer(struct triton_timer_t *t)
{
struct chap_auth_data_t *d = container_of(t, typeof(*d), interval);
@@ -358,7 +364,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
if (ad->started)
ppp_terminate(ad->ppp, TERM_USER_ERROR, 0);
else
- auth_failed(ad->ppp);
+ ppp_auth_failed(ad->ppp);
}
if (msg->val_size != RESPONSE_VALUE_SIZE) {
@@ -367,7 +373,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
if (ad->started)
ppp_terminate(ad->ppp, TERM_USER_ERROR, 0);
else
- auth_failed(ad->ppp);
+ ppp_auth_failed(ad->ppp);
}
name = _strndup(msg->name, ntohs(msg->hdr.len) - sizeof(*msg) + 2);
@@ -376,7 +382,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
if (ad->started)
ppp_terminate(ad->ppp, TERM_NAS_ERROR, 0);
else
- auth_failed(ad->ppp);
+ ppp_auth_failed(ad->ppp);
return;
}
@@ -395,7 +401,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
if (ad->started)
ppp_terminate(ad->ppp, TERM_AUTH_ERROR, 0);
else
- auth_failed(ad->ppp);
+ ppp_auth_failed(ad->ppp);
_free(name);
} else {
chap_send_success(ad, msg, authenticator);
@@ -403,8 +409,9 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h
ad->started = 1;
if (conf_interval)
triton_timer_add(ad->ppp->ctrl->ctx, &ad->interval, 0);
- auth_successed(ad->ppp, name);
- }
+ ppp_auth_successed(ad->ppp, name);
+ } else
+ _free(name);
}
}
@@ -489,6 +496,15 @@ static int chap_check(uint8_t *ptr)
return *ptr == MSCHAP_V2;
}
+static int chap_restart(struct ppp_t *ppp, struct auth_data_t *auth)
+{
+ struct chap_auth_data_t *d = container_of(auth, typeof(*d), auth);
+
+ chap_send_challenge(d);
+
+ return 0;
+}
+
static struct ppp_auth_handler_t chap=
{
.name = "MSCHAP-v2",
@@ -499,6 +515,7 @@ static struct ppp_auth_handler_t chap=
.start = chap_start,
.finish = chap_finish,
.check = chap_check,
+ .restart = chap_restart,
};
static void chap_recv(struct ppp_handler_t *h)