Separate close action from generic action list.
Now generic action list can execute only if don't wait capwap respone.
This commit is contained in:
parent
992b742478
commit
33d262398a
@ -143,9 +143,4 @@ int ac_execute(void);
|
|||||||
int ac_valid_binding(unsigned short binding);
|
int ac_valid_binding(unsigned short binding);
|
||||||
void ac_update_statistics(void);
|
void ac_update_statistics(void);
|
||||||
|
|
||||||
int ac_has_sessionid(struct capwap_sessionid_element* sessionid);
|
|
||||||
int ac_has_wtpid(char* wtpid);
|
|
||||||
char* ac_get_printable_wtpid(struct capwap_wtpboarddata_element* wtpboarddata);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __CAPWAP_AC_HEADER__ */
|
#endif /* __CAPWAP_AC_HEADER__ */
|
||||||
|
@ -20,11 +20,3 @@ int ac_dfa_state_teardown(struct ac_session_t* session, struct capwap_parsed_pac
|
|||||||
ac_dfa_change_state(session, CAPWAP_DEAD_STATE);
|
ac_dfa_change_state(session, CAPWAP_DEAD_STATE);
|
||||||
return AC_DFA_DROP_PACKET;
|
return AC_DFA_DROP_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* */
|
|
||||||
int ac_dfa_state_dead(struct ac_session_t* session, struct capwap_parsed_packet* packet) {
|
|
||||||
ASSERT(session != NULL);
|
|
||||||
ASSERT(packet == NULL);
|
|
||||||
|
|
||||||
return AC_DFA_DEAD;
|
|
||||||
}
|
|
||||||
|
@ -160,7 +160,7 @@ static void ac_session_add_packet(struct ac_session_t* session, char* buffer, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Add action to session */
|
/* Add action to session */
|
||||||
static void ac_session_send_action(struct ac_session_t* session, long action, long param, void* data, long length) {
|
void ac_session_send_action(struct ac_session_t* session, long action, long param, void* data, long length) {
|
||||||
struct capwap_list_item* item;
|
struct capwap_list_item* item;
|
||||||
struct ac_session_action* actionsession;
|
struct ac_session_action* actionsession;
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ static struct ac_session_t* ac_search_session_from_wtpaddress(struct sockaddr_st
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find WTP session id */
|
/* Find session from session id */
|
||||||
struct ac_session_t* ac_search_session_from_sessionid(struct capwap_sessionid_element* sessionid) {
|
struct ac_session_t* ac_search_session_from_sessionid(struct capwap_sessionid_element* sessionid) {
|
||||||
struct ac_session_t* result = NULL;
|
struct ac_session_t* result = NULL;
|
||||||
struct capwap_list_item* search;
|
struct capwap_list_item* search;
|
||||||
@ -251,6 +251,39 @@ struct ac_session_t* ac_search_session_from_sessionid(struct capwap_sessionid_el
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Find session from wtp id */
|
||||||
|
struct ac_session_t* ac_search_session_from_wtpid(const char* wtpid) {
|
||||||
|
struct ac_session_t* result = NULL;
|
||||||
|
struct capwap_list_item* search;
|
||||||
|
|
||||||
|
ASSERT(wtpid != NULL);
|
||||||
|
|
||||||
|
capwap_rwlock_rdlock(&g_ac.sessionslock);
|
||||||
|
|
||||||
|
search = g_ac.sessions->first;
|
||||||
|
while (search != NULL) {
|
||||||
|
struct ac_session_t* session = (struct ac_session_t*)search->item;
|
||||||
|
ASSERT(session != NULL);
|
||||||
|
|
||||||
|
if (!strcmp(session->wtpid, wtpid)) {
|
||||||
|
/* Increment session count */
|
||||||
|
capwap_lock_enter(&session->sessionlock);
|
||||||
|
session->count++;
|
||||||
|
capwap_lock_exit(&session->sessionlock);
|
||||||
|
|
||||||
|
/* */
|
||||||
|
result = session;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
search = search->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
capwap_rwlock_exit(&g_ac.sessionslock);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
int ac_has_sessionid(struct capwap_sessionid_element* sessionid) {
|
int ac_has_sessionid(struct capwap_sessionid_element* sessionid) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
@ -279,7 +312,7 @@ int ac_has_sessionid(struct capwap_sessionid_element* sessionid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
int ac_has_wtpid(char* wtpid) {
|
int ac_has_wtpid(const char* wtpid) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
struct capwap_list_item* search;
|
struct capwap_list_item* search;
|
||||||
|
|
||||||
@ -395,6 +428,14 @@ static struct ac_session_t* ac_get_session_from_keepalive(void* buffer, int buff
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* */
|
||||||
|
void ac_session_close(struct ac_session_t* session) {
|
||||||
|
capwap_lock_enter(&session->sessionlock);
|
||||||
|
session->running = 0;
|
||||||
|
capwap_event_signal(&session->waitpacket);
|
||||||
|
capwap_lock_exit(&session->sessionlock);
|
||||||
|
}
|
||||||
|
|
||||||
/* Close sessions */
|
/* Close sessions */
|
||||||
static void ac_close_sessions() {
|
static void ac_close_sessions() {
|
||||||
struct capwap_list_item* search;
|
struct capwap_list_item* search;
|
||||||
@ -406,7 +447,7 @@ static void ac_close_sessions() {
|
|||||||
struct ac_session_t* session = (struct ac_session_t*)search->item;
|
struct ac_session_t* session = (struct ac_session_t*)search->item;
|
||||||
ASSERT(session != NULL);
|
ASSERT(session != NULL);
|
||||||
|
|
||||||
ac_session_send_action(session, AC_SESSION_ACTION_CLOSE, 0, NULL, 0);
|
ac_session_close(session);
|
||||||
|
|
||||||
search = search->next;
|
search = search->next;
|
||||||
}
|
}
|
||||||
@ -548,6 +589,7 @@ static struct ac_session_t* ac_create_session(struct sockaddr_storage* wtpaddres
|
|||||||
memset(session, 0, sizeof(struct ac_session_t));
|
memset(session, 0, sizeof(struct ac_session_t));
|
||||||
|
|
||||||
session->itemlist = itemlist;
|
session->itemlist = itemlist;
|
||||||
|
session->running = 1;
|
||||||
session->count = 2;
|
session->count = 2;
|
||||||
memcpy(&session->acctrladdress, acaddress, sizeof(struct sockaddr_storage));
|
memcpy(&session->acctrladdress, acaddress, sizeof(struct sockaddr_storage));
|
||||||
memcpy(&session->wtpctrladdress, wtpaddress, sizeof(struct sockaddr_storage));
|
memcpy(&session->wtpctrladdress, wtpaddress, sizeof(struct sockaddr_storage));
|
||||||
|
@ -12,12 +12,14 @@
|
|||||||
static int ac_session_action_execute(struct ac_session_t* session, struct ac_session_action* action) {
|
static int ac_session_action_execute(struct ac_session_t* session, struct ac_session_action* action) {
|
||||||
int result = ACTION_SESSION;
|
int result = ACTION_SESSION;
|
||||||
|
|
||||||
|
/*
|
||||||
switch (action->action) {
|
switch (action->action) {
|
||||||
case AC_SESSION_ACTION_CLOSE: {
|
case AC_SESSION_ACTION_CLOSE: {
|
||||||
result = DTLS_SHUTDOWN;
|
result = DTLS_SHUTDOWN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -36,7 +38,9 @@ static int ac_network_read(struct ac_session_t* session, void* buffer, int lengt
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
capwap_lock_enter(&session->sessionlock);
|
capwap_lock_enter(&session->sessionlock);
|
||||||
|
|
||||||
if (session->actionsession->count > 0) {
|
if (!session->running) {
|
||||||
|
return DTLS_SHUTDOWN;
|
||||||
|
} else if (!session->waitresponse && (session->actionsession->count > 0)) {
|
||||||
struct capwap_list_item* itemaction;
|
struct capwap_list_item* itemaction;
|
||||||
|
|
||||||
itemaction = capwap_itemlist_remove_head(session->actionsession);
|
itemaction = capwap_itemlist_remove_head(session->actionsession);
|
||||||
@ -254,11 +258,6 @@ static int ac_dfa_execute(struct ac_session_t* session, struct capwap_parsed_pac
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CAPWAP_DTLS_TEARDOWN_STATE: {
|
|
||||||
action = ac_dfa_state_teardown(session, packet);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case CAPWAP_DTLS_TEARDOWN_TO_IDLE_STATE: {
|
case CAPWAP_DTLS_TEARDOWN_TO_IDLE_STATE: {
|
||||||
/* Never called with this state */
|
/* Never called with this state */
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
@ -382,11 +381,6 @@ static int ac_dfa_execute(struct ac_session_t* session, struct capwap_parsed_pac
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CAPWAP_DEAD_STATE: {
|
|
||||||
action = ac_dfa_state_dead(session, packet);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
capwap_logging_debug("Unknown action event: %lu", session->state);
|
capwap_logging_debug("Unknown action event: %lu", session->state);
|
||||||
break;
|
break;
|
||||||
@ -565,7 +559,7 @@ static void ac_session_run(struct ac_session_t* session) {
|
|||||||
capwap_set_timeout(session->dfa.rfcWaitJoin, &session->timeout, CAPWAP_TIMER_CONTROL_CONNECTION);
|
capwap_set_timeout(session->dfa.rfcWaitJoin, &session->timeout, CAPWAP_TIMER_CONTROL_CONNECTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (action != AC_DFA_DEAD) {
|
while (session->state != CAPWAP_DTLS_TEARDOWN_STATE) {
|
||||||
/* Get packet */
|
/* Get packet */
|
||||||
if ((action == AC_DFA_ACCEPT_PACKET) || (action == AC_DFA_DROP_PACKET)) {
|
if ((action == AC_DFA_ACCEPT_PACKET) || (action == AC_DFA_DROP_PACKET)) {
|
||||||
length = ac_network_read(session, buffer, sizeof(buffer), &isctrlsocket, &session->timeout);
|
length = ac_network_read(session, buffer, sizeof(buffer), &isctrlsocket, &session->timeout);
|
||||||
@ -573,7 +567,7 @@ static void ac_session_run(struct ac_session_t* session) {
|
|||||||
if (length == PACKET_TIMEOUT) {
|
if (length == PACKET_TIMEOUT) {
|
||||||
action = ac_dfa_execute(session, NULL); /* Timeout */
|
action = ac_dfa_execute(session, NULL); /* Timeout */
|
||||||
} else if (length == DTLS_SHUTDOWN) {
|
} else if (length == DTLS_SHUTDOWN) {
|
||||||
action = ac_session_teardown_connection(session);
|
ac_session_teardown_connection(session);
|
||||||
} else if (length == ACTION_SESSION) {
|
} else if (length == ACTION_SESSION) {
|
||||||
/* Nothing */
|
/* Nothing */
|
||||||
}
|
}
|
||||||
@ -664,6 +658,10 @@ static void ac_session_run(struct ac_session_t* session) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Wait teardown timeout before kill session */
|
||||||
|
capwap_wait_timeout(&session->timeout, CAPWAP_TIMER_CONTROL_CONNECTION);
|
||||||
|
ac_dfa_state_teardown(session, NULL);
|
||||||
|
|
||||||
/* Release reference session */
|
/* Release reference session */
|
||||||
ac_session_destroy(session);
|
ac_session_destroy(session);
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,6 @@
|
|||||||
#define AC_DFA_DROP_PACKET 2
|
#define AC_DFA_DROP_PACKET 2
|
||||||
#define AC_DFA_DEAD 3
|
#define AC_DFA_DEAD 3
|
||||||
|
|
||||||
/* */
|
|
||||||
#define AC_SESSION_ACTION_CLOSE 0
|
|
||||||
|
|
||||||
/* AC packet */
|
/* AC packet */
|
||||||
struct ac_packet {
|
struct ac_packet {
|
||||||
int plainbuffer;
|
int plainbuffer;
|
||||||
@ -44,6 +41,8 @@ struct ac_session_t {
|
|||||||
|
|
||||||
/* */
|
/* */
|
||||||
char* wtpid;
|
char* wtpid;
|
||||||
|
int running;
|
||||||
|
int waitresponse;
|
||||||
|
|
||||||
unsigned long count;
|
unsigned long count;
|
||||||
struct sockaddr_storage acctrladdress;
|
struct sockaddr_storage acctrladdress;
|
||||||
@ -86,8 +85,20 @@ struct ac_session_t {
|
|||||||
|
|
||||||
/* */
|
/* */
|
||||||
void* ac_session_thread(void* param);
|
void* ac_session_thread(void* param);
|
||||||
|
void ac_session_send_action(struct ac_session_t* session, long action, long param, void* data, long length);
|
||||||
|
|
||||||
|
/* */
|
||||||
|
int ac_has_sessionid(struct capwap_sessionid_element* sessionid);
|
||||||
struct ac_session_t* ac_search_session_from_sessionid(struct capwap_sessionid_element* sessionid);
|
struct ac_session_t* ac_search_session_from_sessionid(struct capwap_sessionid_element* sessionid);
|
||||||
|
int ac_has_wtpid(const char* wtpid);
|
||||||
|
struct ac_session_t* ac_search_session_from_wtpid(const char* wtpid);
|
||||||
|
|
||||||
|
/* */
|
||||||
|
char* ac_get_printable_wtpid(struct capwap_wtpboarddata_element* wtpboarddata);
|
||||||
|
|
||||||
|
/* */
|
||||||
int ac_session_teardown_connection(struct ac_session_t* session);
|
int ac_session_teardown_connection(struct ac_session_t* session);
|
||||||
|
void ac_session_close(struct ac_session_t* session);
|
||||||
void ac_session_release_reference(struct ac_session_t* session);
|
void ac_session_release_reference(struct ac_session_t* session);
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
@ -140,7 +151,6 @@ int ac_dfa_state_reset_to_dtlsteardown(struct ac_session_t* session, struct capw
|
|||||||
|
|
||||||
/* */
|
/* */
|
||||||
int ac_dfa_state_teardown(struct ac_session_t* session, struct capwap_parsed_packet* packet);
|
int ac_dfa_state_teardown(struct ac_session_t* session, struct capwap_parsed_packet* packet);
|
||||||
int ac_dfa_state_dead(struct ac_session_t* session, struct capwap_parsed_packet* packet);
|
|
||||||
|
|
||||||
/* Soap function */
|
/* Soap function */
|
||||||
struct ac_soap_response* ac_session_send_soap_request(struct ac_session_t* session, char* method, int numparam, ...);
|
struct ac_soap_response* ac_session_send_soap_request(struct ac_session_t* session, char* method, int numparam, ...);
|
||||||
|
Loading…
Reference in New Issue
Block a user