diff options
author | Kozlov Dmitry <dima@server> | 2010-10-05 14:18:52 +0400 |
---|---|---|
committer | Kozlov Dmitry <dima@server> | 2010-10-05 14:18:52 +0400 |
commit | 7f16563bd5a4ef21b970e8dcbab0e5cbe02bfe97 (patch) | |
tree | 573a053112cb4c4b0980d0688a2fe63ef79fd1c0 | |
parent | c9e6b5f6b41163ed363e2ad0a1fc354607cb402e (diff) | |
download | accel-ppp-7f16563bd5a4ef21b970e8dcbab0e5cbe02bfe97.tar.gz accel-ppp-7f16563bd5a4ef21b970e8dcbab0e5cbe02bfe97.zip |
bug fixes
-rw-r--r-- | accel-pptpd/auth/auth_chap_md5.c | 8 | ||||
-rw-r--r-- | accel-pptpd/auth/auth_mschap_v1.c | 10 | ||||
-rw-r--r-- | accel-pptpd/auth/auth_mschap_v2.c | 8 | ||||
-rw-r--r-- | accel-pptpd/auth/auth_pap.c | 4 | ||||
-rw-r--r-- | accel-pptpd/ctrl/pptp.c | 6 | ||||
-rw-r--r-- | accel-pptpd/ppp/ppp_auth.c | 15 | ||||
-rw-r--r-- | accel-pptpd/ppp/ppp_ccp.c | 13 | ||||
-rw-r--r-- | accel-pptpd/ppp/ppp_fsm.c | 2 | ||||
-rw-r--r-- | accel-pptpd/ppp/ppp_ipcp.c | 9 | ||||
-rw-r--r-- | accel-pptpd/ppp/ppp_ipcp.h | 1 | ||||
-rw-r--r-- | accel-pptpd/ppp/ppp_lcp.c | 12 | ||||
-rw-r--r-- | accel-pptpd/ppp/ppp_lcp.h | 1 |
12 files changed, 59 insertions, 30 deletions
diff --git a/accel-pptpd/auth/auth_chap_md5.c b/accel-pptpd/auth/auth_chap_md5.c index ba12295..e0fe2d4 100644 --- a/accel-pptpd/auth/auth_chap_md5.c +++ b/accel-pptpd/auth/auth_chap_md5.c @@ -31,9 +31,9 @@ #define HDR_LEN (sizeof(struct chap_hdr_t)-2) -static int conf_timeout = 3; +static int conf_timeout = 5; static int conf_interval = 0; -static int conf_max_failure = 2; +static int conf_max_failure = 3; static int urandom_fd; @@ -122,9 +122,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_tv.tv_sec = conf_timeout; + d->timeout.period = conf_timeout * 1000; d->interval.expire = chap_restart; - d->interval.expire_tv.tv_sec = conf_interval; + d->interval.period = conf_interval * 1000; ppp_register_chan_handler(ppp,&d->h); diff --git a/accel-pptpd/auth/auth_mschap_v1.c b/accel-pptpd/auth/auth_mschap_v1.c index ac8edd7..203c25e 100644 --- a/accel-pptpd/auth/auth_mschap_v1.c +++ b/accel-pptpd/auth/auth_mschap_v1.c @@ -34,9 +34,9 @@ #define HDR_LEN (sizeof(struct chap_hdr_t)-2) -static int conf_timeout = 3; +static int conf_timeout = 5; static int conf_interval = 0; -static int conf_max_failure = 2; +static int conf_max_failure = 3; static int urandom_fd; @@ -136,9 +136,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_tv.tv_sec = conf_timeout; + d->timeout.period = conf_timeout * 1000; d->interval.expire = chap_restart; - d->interval.expire_tv.tv_sec = conf_interval; + d->interval.period = conf_interval * 1000; ppp_register_chan_handler(ppp,&d->h); @@ -294,7 +294,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h name = _strndup(msg->name,ntohs(msg->hdr.len)-sizeof(*msg)+2); if (!name) { - log_emerg("mschap-v2: out of memory\n"); + log_emerg("mschap-v1: out of memory\n"); if (ad->started) ppp_terminate(ad->ppp, 0); else diff --git a/accel-pptpd/auth/auth_mschap_v2.c b/accel-pptpd/auth/auth_mschap_v2.c index 4b5e9a0..44a67ca 100644 --- a/accel-pptpd/auth/auth_mschap_v2.c +++ b/accel-pptpd/auth/auth_mschap_v2.c @@ -35,9 +35,9 @@ #define HDR_LEN (sizeof(struct chap_hdr_t)-2) -static int conf_timeout = 3; +static int conf_timeout = 5; static int conf_interval = 0; -static int conf_max_failure = 2; +static int conf_max_failure = 3; static int urandom_fd; @@ -152,9 +152,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_tv.tv_sec = conf_timeout; + d->timeout.period = conf_timeout * 1000; d->interval.expire = chap_restart; - d->interval.expire_tv.tv_sec = conf_interval; + d->interval.period = conf_interval * 1000; ppp_register_chan_handler(ppp,&d->h); diff --git a/accel-pptpd/auth/auth_pap.c b/accel-pptpd/auth/auth_pap.c index 42ef66b..0fd6e7f 100644 --- a/accel-pptpd/auth/auth_pap.c +++ b/accel-pptpd/auth/auth_pap.c @@ -20,7 +20,7 @@ #define PAP_ACK 2 #define PAP_NAK 3 -static int conf_timeout = 3; +static int conf_timeout = 5; static struct auth_data_t* auth_data_init(struct ppp_t *ppp); static void auth_data_free(struct ppp_t*, struct auth_data_t*); @@ -91,7 +91,7 @@ static int pap_start(struct ppp_t *ppp, struct auth_data_t *auth) d->h.proto = PPP_PAP; d->h.recv = pap_recv; d->timeout.expire = pap_timeout; - d->timeout.expire_tv.tv_sec = conf_timeout; + d->timeout.period = conf_timeout * 1000; triton_timer_add(ppp->ctrl->ctx, &d->timeout, 0); diff --git a/accel-pptpd/ctrl/pptp.c b/accel-pptpd/ctrl/pptp.c index 36c8e6b..2c3f73c 100644 --- a/accel-pptpd/ctrl/pptp.c +++ b/accel-pptpd/ctrl/pptp.c @@ -51,7 +51,7 @@ struct pptp_conn_t struct ppp_t ppp; }; -static int conf_timeout = 3; +static int conf_timeout = 5; static int conf_echo_interval = 0; static int conf_echo_failure = 3; static int conf_verbose = 0; @@ -460,8 +460,10 @@ static int pptp_read(struct triton_md_handler_t *h) log_ppp_error("pptp: read: %s\n",strerror(errno)); goto drop; } - if (n == 0) + if (n == 0) { + log_ppp_debug("pptp: disconnect by peer\n"); goto drop; + } conn->in_size += n; if (conn->in_size >= sizeof(*hdr)) { if (hdr->magic != htonl(PPTP_MAGIC)) { diff --git a/accel-pptpd/ppp/ppp_auth.c b/accel-pptpd/ppp/ppp_auth.c index dfa5415..ada01ad 100644 --- a/accel-pptpd/ppp/ppp_auth.c +++ b/accel-pptpd/ppp/ppp_auth.c @@ -41,6 +41,7 @@ struct auth_layer_data_t struct ppp_layer_data_t ld; struct auth_option_t auth_opt; struct ppp_t *ppp; + int started:1; }; static struct lcp_option_handler_t auth_opt_hnd= @@ -269,14 +270,15 @@ static int auth_layer_start(struct ppp_layer_data_t *ld) log_ppp_debug("auth_layer_start\n"); + ad->started = 1; + if (ad->auth_opt.auth) ad->auth_opt.auth->h->start(ad->ppp,ad->auth_opt.auth); - else - { + else { log_ppp_debug("auth_layer_started\n"); ppp_layer_started(ad->ppp,ld); } - + return 0; } @@ -289,6 +291,8 @@ static void auth_layer_finish(struct ppp_layer_data_t *ld) if (ad->auth_opt.auth) ad->auth_opt.auth->h->finish(ad->ppp,ad->auth_opt.auth); + ad->started = 0; + log_ppp_debug("auth_layer_finished\n"); ppp_layer_finished(ad->ppp,ld); } @@ -298,6 +302,9 @@ static void auth_layer_free(struct ppp_layer_data_t *ld) struct auth_layer_data_t *ad=container_of(ld,typeof(*ad),ld); log_ppp_debug("auth_layer_free\n"); + + if (ad->started && ad->auth_opt.auth) + ad->auth_opt.auth->h->finish(ad->ppp,ad->auth_opt.auth); _free(ad); } @@ -307,8 +314,8 @@ void __export auth_successed(struct ppp_t *ppp, char *username) struct auth_layer_data_t *ad=container_of(ppp_find_layer_data(ppp,&auth_layer),typeof(*ad),ld); log_ppp_debug("auth_layer_started\n"); ppp->username = username; - triton_event_fire(EV_PPP_AUTHORIZED, ppp); ppp_layer_started(ppp,&ad->ld); + triton_event_fire(EV_PPP_AUTHORIZED, ppp); } void __export auth_failed(struct ppp_t *ppp) diff --git a/accel-pptpd/ppp/ppp_ccp.c b/accel-pptpd/ppp/ppp_ccp.c index 36db6f9..ca12892 100644 --- a/accel-pptpd/ppp/ppp_ccp.c +++ b/accel-pptpd/ppp/ppp_ccp.c @@ -176,12 +176,15 @@ static void ccp_layer_up(struct ppp_fsm_t *fsm) { struct ppp_ccp_t *ccp=container_of(fsm,typeof(*ccp),fsm); log_ppp_debug("ccp_layer_started\n"); - ccp->started = 1; - if (ccp_set_flags(ccp->ppp->unit_fd, 1, 1)) { - ppp_terminate(ccp->ppp, 0); - return; + + if (!ccp->started) { + ccp->started = 1; + if (ccp_set_flags(ccp->ppp->unit_fd, 1, 1)) { + ppp_terminate(ccp->ppp, 0); + return; + } + ppp_layer_started(ccp->ppp,&ccp->ld); } - ppp_layer_started(ccp->ppp,&ccp->ld); } static void ccp_layer_down(struct ppp_fsm_t *fsm) diff --git a/accel-pptpd/ppp/ppp_fsm.c b/accel-pptpd/ppp/ppp_fsm.c index 6efc2e0..4769dc8 100644 --- a/accel-pptpd/ppp/ppp_fsm.c +++ b/accel-pptpd/ppp/ppp_fsm.c @@ -13,7 +13,7 @@ static int conf_max_terminate = 2; static int conf_max_configure = 5; static int conf_max_failure = 5; -static int conf_timeout = 3; +static int conf_timeout = 5; void send_term_req(struct ppp_fsm_t *layer); void send_term_ack(struct ppp_fsm_t *layer); diff --git a/accel-pptpd/ppp/ppp_ipcp.c b/accel-pptpd/ppp/ppp_ipcp.c index 795cbc0..f8d0a3f 100644 --- a/accel-pptpd/ppp/ppp_ipcp.c +++ b/accel-pptpd/ppp/ppp_ipcp.c @@ -139,7 +139,10 @@ static void ipcp_layer_up(struct ppp_fsm_t *fsm) { struct ppp_ipcp_t *ipcp=container_of(fsm,typeof(*ipcp),fsm); log_ppp_debug("ipcp_layer_started\n"); - ppp_layer_started(ipcp->ppp,&ipcp->ld); + if (!ipcp->started) { + ipcp->started = 1; + ppp_layer_started(ipcp->ppp,&ipcp->ld); + } } static void ipcp_layer_down(struct ppp_fsm_t *fsm) @@ -147,6 +150,10 @@ static void ipcp_layer_down(struct ppp_fsm_t *fsm) struct ppp_ipcp_t *ipcp=container_of(fsm,typeof(*ipcp),fsm); log_ppp_debug("ipcp_layer_finished\n"); ppp_layer_finished(ipcp->ppp,&ipcp->ld); + if (ipcp->started) + ipcp->started = 0; + else + ppp_terminate(ipcp->ppp, 1); } static void print_ropt(struct recv_opt_t *ropt) diff --git a/accel-pptpd/ppp/ppp_ipcp.h b/accel-pptpd/ppp/ppp_ipcp.h index 266ab7d..c955987 100644 --- a/accel-pptpd/ppp/ppp_ipcp.h +++ b/accel-pptpd/ppp/ppp_ipcp.h @@ -87,6 +87,7 @@ struct ppp_ipcp_t int ropt_len; int conf_req_len; + int started:1; }; int ipcp_option_register(struct ipcp_option_handler_t *h); diff --git a/accel-pptpd/ppp/ppp_lcp.c b/accel-pptpd/ppp/ppp_lcp.c index 1328764..90141aa 100644 --- a/accel-pptpd/ppp/ppp_lcp.c +++ b/accel-pptpd/ppp/ppp_lcp.c @@ -152,9 +152,13 @@ static void lcp_layer_up(struct ppp_fsm_t *fsm) { struct ppp_lcp_t *lcp=container_of(fsm,typeof(*lcp),fsm); log_ppp_debug("lcp_layer_started\n"); - ppp_layer_started(lcp->ppp,&lcp->ld); - start_echo(lcp); + if (!lcp->started) { + lcp->started = 1; + ppp_layer_started(lcp->ppp,&lcp->ld); + + start_echo(lcp); + } } static void lcp_layer_down(struct ppp_fsm_t *fsm) @@ -171,6 +175,10 @@ static void lcp_layer_finished(struct ppp_fsm_t *fsm) log_ppp_debug("lcp_layer_finished\n"); stop_echo(lcp); ppp_layer_finished(lcp->ppp,&lcp->ld); + if (lcp->started) + lcp->started = 0; + else + ppp_terminate(lcp->ppp, 1); } static void print_ropt(struct recv_opt_t *ropt) diff --git a/accel-pptpd/ppp/ppp_lcp.h b/accel-pptpd/ppp/ppp_lcp.h index 661f200..6d67b69 100644 --- a/accel-pptpd/ppp/ppp_lcp.h +++ b/accel-pptpd/ppp/ppp_lcp.h @@ -127,6 +127,7 @@ struct ppp_lcp_t int ropt_len; int conf_req_len; + int started:1; }; int lcp_option_register(struct lcp_option_handler_t *h); |