From c9e6b5f6b41163ed363e2ad0a1fc354607cb402e Mon Sep 17 00:00:00 2001 From: Kozlov Dmitry Date: Tue, 5 Oct 2010 12:18:48 +0400 Subject: pptp: fixed bug of incorrect administrative termination --- accel-pptpd/accel-pptpd.conf | 2 +- accel-pptpd/ctrl/pptp.c | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) (limited to 'accel-pptpd') diff --git a/accel-pptpd/accel-pptpd.conf b/accel-pptpd/accel-pptpd.conf index 22be345f..380213b1 100644 --- a/accel-pptpd/accel-pptpd.conf +++ b/accel-pptpd/accel-pptpd.conf @@ -55,7 +55,7 @@ gw-ip-address=192.168.100.1 [log] log-file=general.log log-emerg=/dev/stderr -log-debug=/dev/stdout +log-debug=debug.log copy=1 #color=1 #per-user-dir=per_user diff --git a/accel-pptpd/ctrl/pptp.c b/accel-pptpd/ctrl/pptp.c index 641a45f0..36c8e6b1 100644 --- a/accel-pptpd/ctrl/pptp.c +++ b/accel-pptpd/ctrl/pptp.c @@ -330,7 +330,7 @@ static int pptp_out_call_rqst(struct pptp_conn_t *conn) return 0; } -static int send_pptp_call_clear_notify(struct pptp_conn_t *conn, int result) +static int send_pptp_call_disconnect_notify(struct pptp_conn_t *conn, int result) { struct pptp_call_clear_ntfy msg = { .header = PPTP_HEADER_CTRL(PPTP_CALL_CLEAR_NTFY), @@ -341,7 +341,7 @@ static int send_pptp_call_clear_notify(struct pptp_conn_t *conn, int result) }; if (conf_verbose) - log_ppp_info("send [PPTP Call-Clear-Notify ]\n", ntohs(msg.call_id), msg.result_code, msg.error_code, msg.cause_code); + log_ppp_info("send [PPTP Call-Disconnect-Notify ]\n", ntohs(msg.call_id), msg.result_code, msg.error_code, msg.cause_code); return post_msg(conn, &msg, sizeof(msg)); } @@ -358,7 +358,7 @@ static int pptp_call_clear_rqst(struct pptp_conn_t *conn) ppp_terminate(&conn->ppp, 1); } - return send_pptp_call_clear_notify(conn, 4); + return send_pptp_call_disconnect_notify(conn, 4); } static int pptp_echo_rqst(struct pptp_conn_t *conn) @@ -531,17 +531,22 @@ static void pptp_close(struct triton_context_t *ctx) struct pptp_conn_t *conn = container_of(ctx, typeof(*conn), ctx); if (conn->state == STATE_PPP) { conn->state = STATE_CLOSE; - ppp_terminate(&conn->ppp, 0); + ppp_terminate(&conn->ppp, 1); + if (send_pptp_call_disconnect_notify(conn, 3)) { + triton_context_call(&conn->ctx, (void (*)(void*))disconnect, conn); + return; + } } else { - if (send_pptp_stop_ctrl_conn_rqst(conn, 0)) + if (send_pptp_stop_ctrl_conn_rqst(conn, 0)) { triton_context_call(&conn->ctx, (void (*)(void*))disconnect, conn); - else { - if (conn->timeout_timer.tpd) - triton_timer_mod(&conn->timeout_timer, 0); - else - triton_timer_add(ctx, &conn->timeout_timer, 0); + return; } } + + if (conn->timeout_timer.tpd) + triton_timer_mod(&conn->timeout_timer, 0); + else + triton_timer_add(ctx, &conn->timeout_timer, 0); } static void ppp_started(struct ppp_t *ppp) { @@ -555,7 +560,7 @@ static void ppp_finished(struct ppp_t *ppp) log_ppp_debug("ppp_finished\n"); conn->state = STATE_CLOSE; - if (send_pptp_call_clear_notify(conn, 3)) + if (send_pptp_call_disconnect_notify(conn, 3)) triton_context_call(&conn->ctx, (void (*)(void*))disconnect, conn); else if (send_pptp_stop_ctrl_conn_rqst(conn, 0)) triton_context_call(&conn->ctx, (void (*)(void*))disconnect, conn); -- cgit v1.2.3