diff options
author | Kozlov Dmitry <dima@server> | 2010-10-19 13:08:48 +0400 |
---|---|---|
committer | Kozlov Dmitry <dima@server> | 2010-10-19 13:08:48 +0400 |
commit | b61784a785b48429fe0a75fbcbb9d867eee509f5 (patch) | |
tree | c97d5fb3c198b686717099d7e9ad06c4a6a815f0 /accel-pptpd | |
parent | f7ac3aa1be2fe2a5bf987728e98544c4a20e57fb (diff) | |
download | accel-ppp-b61784a785b48429fe0a75fbcbb9d867eee509f5.tar.gz accel-ppp-b61784a785b48429fe0a75fbcbb9d867eee509f5.zip |
radius: implemented Acct-Terminate-Cause attribute
Diffstat (limited to 'accel-pptpd')
-rw-r--r-- | accel-pptpd/auth/auth_chap_md5.c | 10 | ||||
-rw-r--r-- | accel-pptpd/auth/auth_mschap_v1.c | 10 | ||||
-rw-r--r-- | accel-pptpd/auth/auth_mschap_v2.c | 10 | ||||
-rw-r--r-- | accel-pptpd/auth/auth_pap.c | 2 | ||||
-rw-r--r-- | accel-pptpd/ctrl/l2tp/l2tp.c | 6 | ||||
-rw-r--r-- | accel-pptpd/ctrl/pppoe/pppoe.c | 4 | ||||
-rw-r--r-- | accel-pptpd/ctrl/pptp/pptp.c | 6 | ||||
-rw-r--r-- | accel-pptpd/ppp/ppp.c | 9 | ||||
-rw-r--r-- | accel-pptpd/ppp/ppp.h | 12 | ||||
-rw-r--r-- | accel-pptpd/ppp/ppp_auth.c | 2 | ||||
-rw-r--r-- | accel-pptpd/ppp/ppp_ccp.c | 8 | ||||
-rw-r--r-- | accel-pptpd/ppp/ppp_ipcp.c | 10 | ||||
-rw-r--r-- | accel-pptpd/ppp/ppp_lcp.c | 16 | ||||
-rw-r--r-- | accel-pptpd/radius/acct.c | 18 | ||||
-rw-r--r-- | accel-pptpd/radius/dm_coa.c | 2 | ||||
-rw-r--r-- | accel-pptpd/radius/radius.c | 4 |
16 files changed, 79 insertions, 50 deletions
diff --git a/accel-pptpd/auth/auth_chap_md5.c b/accel-pptpd/auth/auth_chap_md5.c index 4031a9a..0e22908 100644 --- a/accel-pptpd/auth/auth_chap_md5.c +++ b/accel-pptpd/auth/auth_chap_md5.c @@ -157,7 +157,7 @@ static void chap_timeout(struct triton_timer_t *t) if (++d->failure == conf_max_failure) { if (d->started) - ppp_terminate(d->ppp, 0); + ppp_terminate(d->ppp, TERM_USER_ERROR, 0); else auth_failed(d->ppp); } else { @@ -267,13 +267,13 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h if (conf_ppp_verbose) log_ppp_error("chap-md5: id mismatch\n"); chap_send_failure(ad); - ppp_terminate(ad->ppp, 0); + ppp_terminate(ad->ppp, TERM_USER_ERROR, 0); } if (msg->val_size != VALUE_SIZE) { log_ppp_error("chap-md5: incorrect value-size (%i)\n", msg->val_size); chap_send_failure(ad); - ppp_terminate(ad->ppp, 0); + ppp_terminate(ad->ppp, TERM_USER_ERROR, 0); } name = _strndup(msg->name,ntohs(msg->hdr.len) - sizeof(*msg) + 2); @@ -303,7 +303,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h log_ppp_warn("chap-md5: challenge response mismatch\n"); chap_send_failure(ad); if (ad->started) - ppp_terminate(ad->ppp, 0); + ppp_terminate(ad->ppp, TERM_USER_ERROR, 0); else auth_failed(ad->ppp); }else @@ -322,7 +322,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h chap_send_failure(ad); _free(name); if (ad->started) - ppp_terminate(ad->ppp, 0); + ppp_terminate(ad->ppp, TERM_USER_ERROR, 0); else auth_failed(ad->ppp); } else { diff --git a/accel-pptpd/auth/auth_mschap_v1.c b/accel-pptpd/auth/auth_mschap_v1.c index 5b4935e..d1dccef 100644 --- a/accel-pptpd/auth/auth_mschap_v1.c +++ b/accel-pptpd/auth/auth_mschap_v1.c @@ -171,7 +171,7 @@ static void chap_timeout(struct triton_timer_t *t) if (++d->failure == conf_max_failure) { if (d->started) - ppp_terminate(d->ppp, 0); + ppp_terminate(d->ppp, TERM_USER_ERROR, 0); else auth_failed(d->ppp); } else { @@ -281,7 +281,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h log_ppp_error("mschap-v1: id mismatch\n"); chap_send_failure(ad); if (ad->started) - ppp_terminate(ad->ppp, 0); + ppp_terminate(ad->ppp, TERM_USER_ERROR, 0); else auth_failed(ad->ppp); } @@ -290,7 +290,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h log_ppp_error("mschap-v1: incorrect value-size (%i)\n", msg->val_size); chap_send_failure(ad); if (ad->started) - ppp_terminate(ad->ppp, 0); + ppp_terminate(ad->ppp, TERM_AUTH_ERROR, 0); else auth_failed(ad->ppp); } @@ -299,7 +299,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h if (!name) { log_emerg("mschap-v1: out of memory\n"); if (ad->started) - ppp_terminate(ad->ppp, 0); + ppp_terminate(ad->ppp, TERM_NAS_ERROR, 0); else auth_failed(ad->ppp); return; @@ -312,7 +312,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h if (r == PWDB_DENIED) { chap_send_failure(ad); if (ad->started) - ppp_terminate(ad->ppp, 0); + ppp_terminate(ad->ppp, TERM_AUTH_ERROR, 0); else auth_failed(ad->ppp); _free(name); diff --git a/accel-pptpd/auth/auth_mschap_v2.c b/accel-pptpd/auth/auth_mschap_v2.c index a93fad6..3b2da7b 100644 --- a/accel-pptpd/auth/auth_mschap_v2.c +++ b/accel-pptpd/auth/auth_mschap_v2.c @@ -186,7 +186,7 @@ static void chap_timeout(struct triton_timer_t *t) if (++d->failure == conf_max_failure) { if (d->started) - ppp_terminate(d->ppp, 0); + ppp_terminate(d->ppp, TERM_USER_ERROR, 0); else auth_failed(d->ppp); } else { @@ -356,7 +356,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h log_ppp_error("mschap-v2: id mismatch\n"); chap_send_failure(ad); if (ad->started) - ppp_terminate(ad->ppp, 0); + ppp_terminate(ad->ppp, TERM_USER_ERROR, 0); else auth_failed(ad->ppp); } @@ -365,7 +365,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h log_ppp_error("mschap-v2: incorrect value-size (%i)\n", msg->val_size); chap_send_failure(ad); if (ad->started) - ppp_terminate(ad->ppp, 0); + ppp_terminate(ad->ppp, TERM_USER_ERROR, 0); else auth_failed(ad->ppp); } @@ -374,7 +374,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h if (!name) { log_emerg("mschap-v2: out of memory\n"); if (ad->started) - ppp_terminate(ad->ppp, 0); + ppp_terminate(ad->ppp, TERM_NAS_ERROR, 0); else auth_failed(ad->ppp); return; @@ -391,7 +391,7 @@ static void chap_recv_response(struct chap_auth_data_t *ad, struct chap_hdr_t *h if (r == PWDB_DENIED) { chap_send_failure(ad); if (ad->started) - ppp_terminate(ad->ppp, 0); + ppp_terminate(ad->ppp, TERM_AUTH_ERROR, 0); else auth_failed(ad->ppp); _free(name); diff --git a/accel-pptpd/auth/auth_pap.c b/accel-pptpd/auth/auth_pap.c index b044f64..e1b48bd 100644 --- a/accel-pptpd/auth/auth_pap.c +++ b/accel-pptpd/auth/auth_pap.c @@ -210,7 +210,7 @@ static int pap_recv_req(struct pap_auth_data_t *p, struct pap_hdr_t *hdr) log_ppp_warn("PAP: authentication error\n"); pap_send_nak(p, hdr->id); if (p->started) - ppp_terminate(p->ppp, 0); + ppp_terminate(p->ppp, TERM_AUTH_ERROR, 0); else auth_failed(p->ppp); ret=-1; diff --git a/accel-pptpd/ctrl/l2tp/l2tp.c b/accel-pptpd/ctrl/l2tp/l2tp.c index b565e33..3dc9d61 100644 --- a/accel-pptpd/ctrl/l2tp/l2tp.c +++ b/accel-pptpd/ctrl/l2tp/l2tp.c @@ -116,7 +116,7 @@ static void l2tp_disconnect(struct l2tp_conn_t *conn) if (conn->state == STATE_PPP) { conn->state = STATE_FIN; - ppp_terminate(&conn->ppp, 1); + ppp_terminate(&conn->ppp, TERM_USER_REQUEST, 1); } pthread_mutex_lock(&l2tp_lock); @@ -206,7 +206,7 @@ static void l2tp_conn_close(struct triton_context_t *ctx) if (conn->state == STATE_PPP) { conn->state = STATE_FIN; - ppp_terminate(&conn->ppp, 1); + ppp_terminate(&conn->ppp, TERM_ADMIN_RESET, 1); } if (l2tp_terminate(conn, 0, 0)) @@ -793,7 +793,7 @@ static int l2tp_recv_CDN(struct l2tp_conn_t *conn, struct l2tp_packet_t *pack) if (conn->state == STATE_PPP) { conn->state = STATE_FIN; - ppp_terminate(&conn->ppp, 1); + ppp_terminate(&conn->ppp, TERM_USER_REQUEST, 1); } if (l2tp_terminate(conn, 0, 0)) diff --git a/accel-pptpd/ctrl/pppoe/pppoe.c b/accel-pptpd/ctrl/pppoe/pppoe.c index 28c6021..5704f48 100644 --- a/accel-pptpd/ctrl/pppoe/pppoe.c +++ b/accel-pptpd/ctrl/pppoe/pppoe.c @@ -70,7 +70,7 @@ static void disconnect(struct pppoe_conn_t *conn) { if (conn->ppp_started) { conn->ppp_started = 0; - ppp_terminate(&conn->ppp, 1); + ppp_terminate(&conn->ppp, TERM_USER_REQUEST, 1); } pppoe_send_PADT(conn); @@ -120,7 +120,7 @@ static void pppoe_conn_close(struct triton_context_t *ctx) struct pppoe_conn_t *conn = container_of(ctx, typeof(*conn), ctx); if (conn->ppp_started) - ppp_terminate(&conn->ppp, 0); + ppp_terminate(&conn->ppp, TERM_ADMIN_RESET, 0); else disconnect(conn); } diff --git a/accel-pptpd/ctrl/pptp/pptp.c b/accel-pptpd/ctrl/pptp/pptp.c index 1151dab..4a705d5 100644 --- a/accel-pptpd/ctrl/pptp/pptp.c +++ b/accel-pptpd/ctrl/pptp/pptp.c @@ -79,7 +79,7 @@ static void disconnect(struct pptp_conn_t *conn) if (conn->state == STATE_PPP) { conn->state = STATE_CLOSE; - ppp_terminate(&conn->ppp, 1); + ppp_terminate(&conn->ppp, TERM_USER_REQUEST, 1); } triton_event_fire(EV_CTRL_FINISHED, &conn->ppp); @@ -360,7 +360,7 @@ static int pptp_call_clear_rqst(struct pptp_conn_t *conn) if (conn->state == STATE_PPP) { conn->state = STATE_CLOSE; - ppp_terminate(&conn->ppp, 1); + ppp_terminate(&conn->ppp, TERM_USER_REQUEST, 1); } return send_pptp_call_disconnect_notify(conn, 4); @@ -541,7 +541,7 @@ 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, 1); + ppp_terminate(&conn->ppp, TERM_ADMIN_RESET, 1); if (send_pptp_call_disconnect_notify(conn, 3)) { triton_context_call(&conn->ctx, (void (*)(void*))disconnect, conn); return; diff --git a/accel-pptpd/ppp/ppp.c b/accel-pptpd/ppp/ppp.c index bf3635e..d88bbd3 100644 --- a/accel-pptpd/ppp/ppp.c +++ b/accel-pptpd/ppp/ppp.c @@ -352,7 +352,7 @@ void __export ppp_layer_started(struct ppp_t *ppp, struct ppp_layer_data_t *d) list_for_each_entry(d, &n->items, entry) { d->starting = 1; if (d->layer->start(d)) { - ppp_terminate(ppp, 0); + ppp_terminate(ppp, TERM_NAS_ERROR, 0); return; } } @@ -376,12 +376,15 @@ void __export ppp_layer_finished(struct ppp_t *ppp, struct ppp_layer_data_t *d) destablish_ppp(ppp); } -void __export ppp_terminate(struct ppp_t *ppp, int hard) +void __export ppp_terminate(struct ppp_t *ppp, int cause, int hard) { struct layer_node_t *n; struct ppp_layer_data_t *d; int s = 0; + if (!ppp->terminate_cause) + ppp->terminate_cause = cause; + if (ppp->terminating) { if (hard) destablish_ppp(ppp); @@ -520,7 +523,7 @@ static void start_first_layer(struct ppp_t *ppp) list_for_each_entry(d, &n->items, entry) { d->starting = 1; if (d->layer->start(d)) { - ppp_terminate(ppp, 0); + ppp_terminate(ppp, TERM_NAS_ERROR, 0); return; } } diff --git a/accel-pptpd/ppp/ppp.h b/accel-pptpd/ppp/ppp.h index 372520d..dda5244 100644 --- a/accel-pptpd/ppp/ppp.h +++ b/accel-pptpd/ppp/ppp.h @@ -46,6 +46,14 @@ #define PPP_SESSIONID_LEN 32 #define PPP_IFNAME_LEN 10 +#define TERM_USER_REQUEST 1 +#define TERM_SESSION_TIMEOUT 2 +#define TERM_ADMIN_RESET 3 +#define TERM_USER_ERROR 4 +#define TERM_NAS_ERROR 5 +#define TERM_AUTH_ERROR 6 + + struct ppp_t; struct ppp_ctrl_t @@ -86,8 +94,8 @@ struct ppp_t struct ppp_ctrl_t *ctrl; - int log:1; int terminating:1; + int terminate_cause; void *chan_buf; int chan_buf_size; @@ -144,7 +152,7 @@ void ppp_recv_proto_rej(struct ppp_t *ppp, uint16_t proto); struct ppp_fsm_t* ppp_lcp_init(struct ppp_t *ppp); void ppp_layer_started(struct ppp_t *ppp,struct ppp_layer_data_t*); void ppp_layer_finished(struct ppp_t *ppp,struct ppp_layer_data_t*); -void ppp_terminate(struct ppp_t *ppp, int hard); +void ppp_terminate(struct ppp_t *ppp, int hard, int cause); void ppp_register_chan_handler(struct ppp_t *, struct ppp_handler_t *); void ppp_register_unit_handler(struct ppp_t * ,struct ppp_handler_t *); diff --git a/accel-pptpd/ppp/ppp_auth.c b/accel-pptpd/ppp/ppp_auth.c index 65ca223..959dc2f 100644 --- a/accel-pptpd/ppp/ppp_auth.c +++ b/accel-pptpd/ppp/ppp_auth.c @@ -309,7 +309,7 @@ void __export auth_successed(struct ppp_t *ppp, char *username) void __export auth_failed(struct ppp_t *ppp) { - ppp_terminate(ppp, 0); + ppp_terminate(ppp, TERM_AUTH_ERROR, 0); } int __export ppp_auth_register_handler(struct ppp_auth_handler_t *h) diff --git a/accel-pptpd/ppp/ppp_ccp.c b/accel-pptpd/ppp/ppp_ccp.c index af776e4..dd63c71 100644 --- a/accel-pptpd/ppp/ppp_ccp.c +++ b/accel-pptpd/ppp/ppp_ccp.c @@ -182,7 +182,7 @@ static void ccp_layer_up(struct ppp_fsm_t *fsm) if (!ccp->started) { ccp->started = 1; if (ccp_set_flags(ccp->ppp->unit_fd, 1, 1)) { - ppp_terminate(ccp->ppp, 0); + ppp_terminate(ccp->ppp, TERM_NAS_ERROR, 0); return; } ppp_layer_started(ccp->ppp, &ccp->ld); @@ -649,11 +649,11 @@ static void ccp_recv(struct ppp_handler_t*h) send_conf_req(&ccp->fsm); } if (r == CCP_OPT_FAIL) - ppp_terminate(ccp->ppp, 0); + ppp_terminate(ccp->ppp, TERM_USER_ERROR, 0); break; case CONFACK: if (ccp_recv_conf_ack(ccp, (uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN)) - ppp_terminate(ccp->ppp, 0); + ppp_terminate(ccp->ppp, TERM_USER_ERROR, 0); else { ppp_fsm_recv_conf_ack(&ccp->fsm); if (ccp->need_req) @@ -666,7 +666,7 @@ static void ccp_recv(struct ppp_handler_t*h) break; case CONFREJ: if (ccp_recv_conf_rej(ccp, (uint8_t*)(hdr + 1),ntohs(hdr->len) - PPP_HDRLEN)) - ppp_terminate(ccp->ppp, 0); + ppp_terminate(ccp->ppp, TERM_USER_ERROR, 0); else ppp_fsm_recv_conf_rej(&ccp->fsm); break; diff --git a/accel-pptpd/ppp/ppp_ipcp.c b/accel-pptpd/ppp/ppp_ipcp.c index c834873..fe5b39d 100644 --- a/accel-pptpd/ppp/ppp_ipcp.c +++ b/accel-pptpd/ppp/ppp_ipcp.c @@ -156,7 +156,7 @@ static void ipcp_layer_down(struct ppp_fsm_t *fsm) ipcp->started = 0; ppp_layer_finished(ipcp->ppp, &ipcp->ld); } else - ppp_terminate(ipcp->ppp, 1); + ppp_terminate(ipcp->ppp, TERM_NAS_ERROR, 1); } static void print_ropt(struct recv_opt_t *ropt) @@ -584,11 +584,11 @@ static void ipcp_recv(struct ppp_handler_t*h) } ipcp_free_conf_req(ipcp); if (r == IPCP_OPT_FAIL) - ppp_terminate(ipcp->ppp, 0); + ppp_terminate(ipcp->ppp, TERM_USER_ERROR, 0); break; case CONFACK: if (ipcp_recv_conf_ack(ipcp,(uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN)) - ppp_terminate(ipcp->ppp, 0); + ppp_terminate(ipcp->ppp, TERM_USER_ERROR, 0); else ppp_fsm_recv_conf_ack(&ipcp->fsm); break; @@ -598,7 +598,7 @@ static void ipcp_recv(struct ppp_handler_t*h) break; case CONFREJ: if (ipcp_recv_conf_rej(ipcp, (uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN)) - ppp_terminate(ipcp->ppp, 0); + ppp_terminate(ipcp->ppp, TERM_USER_ERROR, 0); else ppp_fsm_recv_conf_rej(&ipcp->fsm); break; @@ -606,7 +606,7 @@ static void ipcp_recv(struct ppp_handler_t*h) if (conf_ppp_verbose) log_ppp_info("recv [IPCP TermReq id=%x]\n", hdr->id); ppp_fsm_recv_term_req(&ipcp->fsm); - ppp_terminate(ipcp->ppp, 0); + ppp_terminate(ipcp->ppp, TERM_USER_REQUEST, 0); break; case TERMACK: if (conf_ppp_verbose) diff --git a/accel-pptpd/ppp/ppp_lcp.c b/accel-pptpd/ppp/ppp_lcp.c index 7a87766..bd04f54 100644 --- a/accel-pptpd/ppp/ppp_lcp.c +++ b/accel-pptpd/ppp/ppp_lcp.c @@ -178,7 +178,7 @@ static void lcp_layer_finished(struct ppp_fsm_t *fsm) lcp->started = 0; ppp_layer_finished(lcp->ppp, &lcp->ld); } else - ppp_terminate(lcp->ppp, 1); + ppp_terminate(lcp->ppp, TERM_NAS_ERROR, 1); } static void print_ropt(struct recv_opt_t *ropt) @@ -559,7 +559,7 @@ static void lcp_recv_echo_repl(struct ppp_lcp_t *lcp, uint8_t *data, int size) if (size != 4) { log_ppp_error("lcp:echo: magic number size mismatch\n"); - ppp_terminate(lcp->ppp, 0); + ppp_terminate(lcp->ppp, TERM_USER_ERROR, 0); } if (conf_ppp_verbose) @@ -567,7 +567,7 @@ static void lcp_recv_echo_repl(struct ppp_lcp_t *lcp, uint8_t *data, int size) if (magic == lcp->magic) { log_ppp_error("lcp: echo: loop-back detected\n"); - ppp_terminate(lcp->ppp, 0); + ppp_terminate(lcp->ppp, TERM_NAS_ERROR, 0); } lcp->echo_sent = 0; @@ -604,7 +604,7 @@ static void send_echo_request(struct triton_timer_t *t) if (++lcp->echo_sent > lcp->echo_failure) { log_ppp_warn("lcp: no echo reply\n"); - ppp_terminate(lcp->ppp, 0); + ppp_terminate(lcp->ppp, TERM_USER_ERROR, 0); } else { if (conf_ppp_verbose) log_ppp_info("send [LCP EchoReq id=%x <magic %x>]\n", msg.hdr.id, msg.magic); @@ -723,11 +723,11 @@ static void lcp_recv(struct ppp_handler_t*h) } lcp_free_conf_req(lcp); if (r == LCP_OPT_FAIL) - ppp_terminate(lcp->ppp, 0); + ppp_terminate(lcp->ppp, TERM_USER_ERROR, 0); break; case CONFACK: if (lcp_recv_conf_ack(lcp,(uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN)) - ppp_terminate(lcp->ppp, 0); + ppp_terminate(lcp->ppp, TERM_USER_ERROR, 0); else if (lcp->fsm.recv_id != lcp->fsm.id) break; @@ -741,7 +741,7 @@ static void lcp_recv(struct ppp_handler_t*h) break; case CONFREJ: if (lcp_recv_conf_rej(lcp,(uint8_t*)(hdr + 1), ntohs(hdr->len) - PPP_HDRLEN)) - ppp_terminate(lcp->ppp, 0); + ppp_terminate(lcp->ppp, TERM_USER_ERROR, 0); else if (lcp->fsm.recv_id != lcp->fsm.id) break; @@ -751,7 +751,7 @@ static void lcp_recv(struct ppp_handler_t*h) if (conf_ppp_verbose) log_ppp_info("recv [LCP TermReq id=%x]\n", hdr->id); ppp_fsm_recv_term_req(&lcp->fsm); - ppp_terminate(lcp->ppp, 0); + ppp_terminate(lcp->ppp, TERM_USER_REQUEST, 0); break; case TERMACK: if (conf_ppp_verbose) diff --git a/accel-pptpd/radius/acct.c b/accel-pptpd/radius/acct.c index 0c914cf..9ebd196 100644 --- a/accel-pptpd/radius/acct.c +++ b/accel-pptpd/radius/acct.c @@ -193,6 +193,24 @@ void rad_acct_stop(struct radius_pd_t *rpd) if (rpd->acct_req->timeout.tpd) triton_timer_del(&rpd->acct_req->timeout); + switch (rpd->ppp->terminate_cause) { + case TERM_USER_REQUEST: + rad_packet_add_val(rpd->acct_req->pack, "Acct-Terminate-Cause", "User-Request"); + break; + case TERM_SESSION_TIMEOUT: + rad_packet_add_val(rpd->acct_req->pack, "Acct-Terminate-Cause", "Session-Timeout"); + break; + case TERM_ADMIN_RESET: + rad_packet_add_val(rpd->acct_req->pack, "Acct-Terminate-Cause", "Admin-Reset"); + break; + case TERM_USER_ERROR: + case TERM_AUTH_ERROR: + rad_packet_add_val(rpd->acct_req->pack, "Acct-Terminate-Cause", "User-Error"); + break; + case TERM_NAS_ERROR: + rad_packet_add_val(rpd->acct_req->pack, "Acct-Terminate-Cause", "NAS-Error"); + break; + } rad_packet_change_val(rpd->acct_req->pack, "Acct-Status-Type", "Stop"); req_set_stat(rpd->acct_req, rpd->ppp); req_set_RA(rpd->acct_req, conf_acct_secret); diff --git a/accel-pptpd/radius/dm_coa.c b/accel-pptpd/radius/dm_coa.c index 2fb023c..84e725b 100644 --- a/accel-pptpd/radius/dm_coa.c +++ b/accel-pptpd/radius/dm_coa.c @@ -136,7 +136,7 @@ static void disconnect_request(struct radius_pd_t *rpd) rad_packet_free(rpd->dm_coa_req); rpd->dm_coa_req = NULL; - ppp_terminate(rpd->ppp, 0); + ppp_terminate(rpd->ppp, TERM_ADMIN_RESET, 0); } static void coa_request(struct radius_pd_t *rpd) diff --git a/accel-pptpd/radius/radius.c b/accel-pptpd/radius/radius.c index 8a4020c..45f0ba9 100644 --- a/accel-pptpd/radius/radius.c +++ b/accel-pptpd/radius/radius.c @@ -120,7 +120,7 @@ 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); + ppp_terminate(rpd->ppp, TERM_SESSION_TIMEOUT, 0); } static void ppp_starting(struct ppp_t *ppp) @@ -143,7 +143,7 @@ static void ppp_started(struct ppp_t *ppp) struct radius_pd_t *rpd = find_pd(ppp); if (rad_acct_start(rpd)) - ppp_terminate(rpd->ppp, 0); + ppp_terminate(rpd->ppp, TERM_NAS_ERROR, 0); if (rpd->session_timeout.expire_tv.tv_sec) { rpd->session_timeout.expire = session_timeout; |