示例#1
0
文件: session.c 项目: 2pac/kamailio
void cdp_session_cleanup(cdp_session_t* s, AAAMessage* msg) {
    // Here we should drop the session ! and free everything related to it
    // but the generic_data thing should be freed by the callback function registered
    // when the auth session was created
    AAASessionCallback_f *cb;

    LM_DBG("cleaning up session %.*s\n", s->id.len, s->id.s);
    switch (s->type) {
    	case ACCT_CC_CLIENT:
    		if (s->cb) {
    			cb = s->cb;
    			(cb)(ACC_CC_EV_SESSION_TERMINATED, s);
    		}
    		AAADropCCAccSession(s);
    		break;
    	case AUTH_CLIENT_STATEFULL:
    	case AUTH_CLIENT_STATELESS:
			if (s->cb) {
				cb = s->cb;
				(cb)(AUTH_EV_SERVICE_TERMINATED, s);
			}
			AAADropAuthSession(s);
			break;
    	default:
    		LM_WARN("asked to cleanup unknown/unhandled session type [%d]\n", s->type);
    		break;
    }

}
void Session_Cleanup(cdp_session_t* s, AAAMessage* msg)
{
	// Here we should drop the session ! and free everything related to it
	// but the generic_data thing should be freed by the callback function registered
	// when the auth session was created
	AAASessionCallback_f *cb;
	LOG(L_INFO,"cleaning up session %.*s\n",s->id.len,s->id.s);
	if (s->cb) {
		cb = s->cb;
		(cb) (AUTH_EV_SERVICE_TERMINATED,s);
	}
	
	AAADropAuthSession(s);
}
示例#3
0
文件: auth.c 项目: asyn/openvims
/**
 * stateful client state machine
 * @param auth - AAAAuthSession which uses this state machine
 * @param ev   - Event
 * @param req  - AAAMessage
 */
void auth_sm_process_stateful(AAAAuthSession* auth, int ev, 
							  AAAMessage* req, AAAMessage* ans)
{
	int rc;
	
	LOG(L_INFO, "in auth_sm_process_stateful\n");
	switch (*auth->st) {
		case AUTH_ST_IDLE:
			LOG(L_INFO, "INF: auth_sm_process_stateful: IDLE\n");
			switch (ev) {
				case AUTH_EV_SEND_REQ:
					LOG(L_INFO, "INF: send AAR\n");
					*auth->st = AUTH_ST_PENDING;
					*ans = *AAASendRecvMessage(req, auth->fqdn);

					rc = get_result_code(ans);
					if (rc == AAA_SUCCESS) {
						LOG(L_INFO, "INF: receive AAA success\n");
						auth_sm_process_stateful(auth, AUTH_EV_RECV_ANS_SUCCESS,
												 NULL, NULL);
					} else {
						LOG(L_INFO, "INF: receive AAA unsuccess\n");
						auth_sm_process_stateful(auth, 
												 AUTH_EV_RECV_ANS_UNSUCCESS,
												 NULL, NULL);
						//AAAPrintMessage(ans);
					}
					break;	
			}
			break;
		
		case AUTH_ST_PENDING:
			LOG(L_INFO, "INF: auth_sm_process_stateful: PENDING\n");
			switch (ev) {
				case AUTH_EV_RECV_ANS_SUCCESS:
					*auth->st = AUTH_ST_OPEN;
					break;
				case AUTH_EV_RECV_ANS_UNSUCCESS:
					*auth->st = AUTH_ST_IDLE;
					LOG(L_INFO, "INF: terminate auth session\n");
					AAADropAuthSession(auth);
					LOG(L_INFO, "active session number: %d\n", length_auth_list());
					break;
			}
			break;
		
		case AUTH_ST_OPEN:
			LOG(L_INFO, "INF: auth_sm_process_stateful: OPEN\n");
			switch (ev) {
				case AUTH_EV_STR:
					LOG(L_INFO, "send STR\n");
					*auth->st = AUTH_ST_DISCON;
					ans = AAASendRecvMessage(req, auth->fqdn);
					if (ans) {
						LOG(L_INFO, "receive STA successful\n");
						auth_sm_process_stateful(auth, AUTH_EV_STA_SUCCESS, 
												 NULL, NULL);
					} else {
						LOG(L_INFO, "receive STA unsuccessful\n");
						auth_sm_process_stateful(auth, AUTH_EV_STA_UNSUCCESS,
												 NULL, NULL);
					}
					break;
			}
			break;
		
		case AUTH_ST_DISCON:
			LOG(L_INFO, "INF: auth_sm_process_stateful: DISCON\n");
			switch(ev) {
				case AUTH_EV_STA_SUCCESS:
					break;
				case AUTH_EV_STA_UNSUCCESS:
					*auth->st = AUTH_ST_IDLE;
					LOG(L_INFO, "INF: terminate auth session\n");
					AAADropAuthSession(auth);
					LOG(L_INFO, "active session number: %d\n", length_auth_list());
					break;
			}	
			break;
	}
}