Add support to soap session into function
This commit is contained in:
parent
6b424c5406
commit
46857e8864
@ -77,9 +77,11 @@ application: {
|
||||
};
|
||||
|
||||
backend: {
|
||||
id = "1";
|
||||
version = "1.0";
|
||||
server: (
|
||||
{ url = "http://localhost/csoap.php"; },
|
||||
{ url = "https://localhost/csoap.php"; x509: { calist = "/etc/capwap/ca.crt"; certificate = "/etc/capwap/ac.crt"; privatekey = "/etc/capwap/ac.key"; privatekeypassword = ""; }; }
|
||||
{ url = "http://127.0.0.1/csoap.php"; }
|
||||
#{ url = "https://127.0.0.1/csoap.php"; x509: { calist = "/etc/capwap/casoap.crt"; certificate = "/etc/capwap/clientsoap.crt"; privatekey = "/etc/capwap/clientsoap.key"; privatekeypassword = ""; }; }
|
||||
);
|
||||
};
|
||||
|
||||
|
20
src/ac/ac.c
20
src/ac/ac.c
@ -103,6 +103,14 @@ static void ac_destroy(void) {
|
||||
capwap_list_free(g_ac.datasessionshandshake);
|
||||
|
||||
/* Backend */
|
||||
if (g_ac.backendacid) {
|
||||
capwap_free(g_ac.backendacid);
|
||||
}
|
||||
|
||||
if (g_ac.backendversion) {
|
||||
capwap_free(g_ac.backendversion);
|
||||
}
|
||||
|
||||
for (i = 0; i < g_ac.availablebackends->count; i++) {
|
||||
ac_soapclient_free_server(*(struct ac_http_soap_server**)capwap_array_get_item_pointer(g_ac.availablebackends, i));
|
||||
}
|
||||
@ -570,6 +578,18 @@ static int ac_parsing_configuration_1_0(config_t* config) {
|
||||
}
|
||||
|
||||
/* Backend */
|
||||
if (config_lookup_string(config, "backend.id", &configString) == CONFIG_TRUE) {
|
||||
if (strlen(configString) > 0) {
|
||||
g_ac.backendacid = capwap_duplicate_string(configString);
|
||||
}
|
||||
}
|
||||
|
||||
if (config_lookup_string(config, "backend.version", &configString) == CONFIG_TRUE) {
|
||||
if (strlen(configString) > 0) {
|
||||
g_ac.backendversion = capwap_duplicate_string(configString);
|
||||
}
|
||||
}
|
||||
|
||||
configSetting = config_lookup(config, "backend.server");
|
||||
if (configSetting) {
|
||||
int count = config_setting_length(configSetting);
|
||||
|
@ -107,6 +107,9 @@ struct ac_t {
|
||||
struct capwap_dtls_context dtlscontext;
|
||||
|
||||
/* Backend Management */
|
||||
char* backendacid;
|
||||
char* backendversion;
|
||||
char* backendsessionid;
|
||||
struct capwap_array* availablebackends;
|
||||
};
|
||||
|
||||
|
@ -32,6 +32,7 @@ static int ac_backend_soap_join(void) {
|
||||
struct ac_soap_request* request;
|
||||
struct ac_http_soap_server* server;
|
||||
|
||||
ASSERT(g_ac.backendsessionid == NULL);
|
||||
ASSERT(g_ac_backend.soaprequest == NULL);
|
||||
|
||||
/* Get HTTP Soap Server */
|
||||
@ -44,6 +45,8 @@ static int ac_backend_soap_join(void) {
|
||||
if (!g_ac_backend.endthread) {
|
||||
request = ac_soapclient_create_request("joinBackend", SOAP_NAMESPACE_URI);
|
||||
if (request) {
|
||||
ac_soapclient_add_param(request, "xs:string", "acid", g_ac.backendacid);
|
||||
ac_soapclient_add_param(request, "xs:string", "version", g_ac.backendversion);
|
||||
g_ac_backend.soaprequest = ac_soapclient_prepare_request(request, server);
|
||||
}
|
||||
}
|
||||
@ -66,7 +69,11 @@ static int ac_backend_soap_join(void) {
|
||||
/* Get join result */
|
||||
if ((response->responsecode == HTTP_RESULT_OK) && response->xmlResponseReturn) {
|
||||
xmlChar* xmlResult = xmlNodeGetContent(response->xmlResponseReturn);
|
||||
result = atoi((const char*)xmlResult);
|
||||
if (xmlStrlen(xmlResult)) {
|
||||
result = 1;
|
||||
g_ac.backendsessionid = capwap_duplicate_string((const char*)xmlResult);
|
||||
}
|
||||
|
||||
xmlFree(xmlResult);
|
||||
}
|
||||
|
||||
@ -94,6 +101,7 @@ static int ac_backend_soap_waitevent(void) {
|
||||
struct ac_http_soap_server* server;
|
||||
|
||||
ASSERT(g_ac_backend.soaprequest == NULL);
|
||||
ASSERT(g_ac.backendsessionid != NULL);
|
||||
|
||||
/* Get HTTP Soap Server */
|
||||
server = *(struct ac_http_soap_server**)capwap_array_get_item_pointer(g_ac.availablebackends, g_ac_backend.activebackend);
|
||||
@ -105,6 +113,7 @@ static int ac_backend_soap_waitevent(void) {
|
||||
if (!g_ac_backend.endthread) {
|
||||
request = ac_soapclient_create_request("waitBackendEvent", SOAP_NAMESPACE_URI);
|
||||
if (request) {
|
||||
ac_soapclient_add_param(request, "xs:string", "sessionid", g_ac.backendsessionid);
|
||||
g_ac_backend.soaprequest = ac_soapclient_prepare_request(request, server);
|
||||
|
||||
/* Change result timeout */
|
||||
@ -158,7 +167,7 @@ static void ac_backend_soap_leave(void) {
|
||||
ASSERT(g_ac_backend.soaprequest == NULL);
|
||||
|
||||
/* */
|
||||
if (!g_ac_backend.backendstatus) {
|
||||
if (!g_ac_backend.backendstatus || !g_ac.backendsessionid) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -171,6 +180,7 @@ static void ac_backend_soap_leave(void) {
|
||||
/* Build Soap Request */
|
||||
request = ac_soapclient_create_request("leaveBackend", SOAP_NAMESPACE_URI);
|
||||
if (request) {
|
||||
ac_soapclient_add_param(request, "xs:string", "sessionid", g_ac.backendsessionid);
|
||||
g_ac_backend.soaprequest = ac_soapclient_prepare_request(request, server);
|
||||
}
|
||||
|
||||
@ -214,13 +224,20 @@ static void ac_backend_run(void) {
|
||||
if (connected) {
|
||||
result = ac_backend_soap_waitevent();
|
||||
if (result < 0) {
|
||||
if (!g_ac_backend.endthread) {
|
||||
capwap_logging_debug("Lost connection with Backend Server");
|
||||
if (g_ac_backend.endthread) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Connection error, change Backend Server */
|
||||
connected = 0;
|
||||
capwap_logging_debug("Lost connection with Backend Server");
|
||||
capwap_lock_enter(&g_ac_backend.backendlock);
|
||||
|
||||
/* Lost session id */
|
||||
capwap_free(g_ac.backendsessionid);
|
||||
g_ac.backendsessionid = NULL;
|
||||
|
||||
/* Change backend */
|
||||
g_ac_backend.activebackend = (g_ac_backend.activebackend + 1) % g_ac.availablebackends->count;
|
||||
}
|
||||
} else {
|
||||
@ -259,6 +276,12 @@ static void ac_backend_run(void) {
|
||||
ac_backend_soap_leave();
|
||||
g_ac_backend.backendstatus = 0;
|
||||
|
||||
/* */
|
||||
if (g_ac.backendsessionid) {
|
||||
capwap_free(g_ac.backendsessionid);
|
||||
g_ac.backendsessionid = NULL;
|
||||
}
|
||||
|
||||
/* */
|
||||
if (!connected) {
|
||||
capwap_lock_exit(&g_ac_backend.backendlock);
|
||||
@ -304,7 +327,13 @@ int ac_backend_start(void) {
|
||||
memset(&g_ac_backend, 0, sizeof(struct ac_backend_t));
|
||||
|
||||
/* */
|
||||
if (!g_ac.availablebackends->count) {
|
||||
if (!g_ac.backendacid) {
|
||||
capwap_logging_error("AC Backend ID isn't set");
|
||||
return 0;
|
||||
} else if (!g_ac.backendversion) {
|
||||
capwap_logging_error("Backend Protocol Version isn't set");
|
||||
return 0;
|
||||
} else if (!g_ac.availablebackends->count) {
|
||||
capwap_logging_error("List of available backends is empty");
|
||||
return 0;
|
||||
}
|
||||
|
@ -748,9 +748,12 @@ struct ac_soap_response* ac_session_send_soap_request(struct ac_session_t* sessi
|
||||
/* Critical section */
|
||||
capwap_lock_enter(&session->sessionlock);
|
||||
|
||||
ASSERT(g_ac.backendsessionid != NULL);
|
||||
|
||||
/* Build Soap Request */
|
||||
request = ac_soapclient_create_request(method, SOAP_NAMESPACE_URI);
|
||||
if (request) {
|
||||
ac_soapclient_add_param(request, "xs:string", "sessionid", g_ac.backendsessionid);
|
||||
session->soaprequest = ac_soapclient_prepare_request(request, server);
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ int ac_dfa_state_dead(struct ac_session_t* session, struct capwap_parsed_packet*
|
||||
|
||||
/* Soap function */
|
||||
struct ac_soap_response* ac_session_send_soap_request(struct ac_session_t* session, char* method, int numparam, ...);
|
||||
#define ac_soap_authorizejoin(s, id) ac_session_send_soap_request((s), "authorizeJoin", 1, "xs:string", "idwtp", id)
|
||||
#define ac_soap_authorizejoin(s, wtpid) ac_session_send_soap_request((s), "authorizeJoin", 1, "xs:string", "wtpid", wtpid)
|
||||
|
||||
|
||||
#endif /* __AC_SESSION_HEADER__ */
|
||||
|
@ -4,18 +4,28 @@
|
||||
<wsdl:types>
|
||||
<xs:schema targetNamespace="http://smartcapwap/namespace" elementFormDefault="qualified"/>
|
||||
</wsdl:types>
|
||||
<wsdl:message name="joinBackend"/>
|
||||
<wsdl:message name="joinBackendResponse">
|
||||
<wsdl:part name="return" type="xs:int"/>
|
||||
<wsdl:message name="joinBackend">
|
||||
<wsdl:part name="acid" type="xs:string"/>
|
||||
<wsdl:part name="version" type="xs:string"/>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="joinBackendResponse">
|
||||
<wsdl:part name="return" type="xs:string"/>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="leaveBackend">
|
||||
<wsdl:part name="sessionid" type="xs:string"/>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="leaveBackend"/>
|
||||
<wsdl:message name="leaveBackendResponse"/>
|
||||
<wsdl:message name="waitBackendEvent"/>
|
||||
<wsdl:message name="waitBackendEvent">
|
||||
<wsdl:part name="sessionid" type="xs:string"/>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="waitBackendEventResponse"/>
|
||||
<wsdl:message name="authorizeJoin">
|
||||
<wsdl:part name="sessionid" type="xs:string"/>
|
||||
<wsdl:part name="wtpid" type="xs:string"/>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="authorizeJoinResponse"/>
|
||||
<wsdl:message name="waitBackendEventFault"/>
|
||||
<wsdl:message name="authorizeJoinFault"/>
|
||||
<wsdl:portType name="Presence">
|
||||
<wsdl:operation name="joinBackend">
|
||||
<wsdl:input message="tns:joinBackend"/>
|
||||
@ -30,12 +40,14 @@
|
||||
<wsdl:operation name="waitBackendEvent">
|
||||
<wsdl:input message="tns:waitBackendEvent"/>
|
||||
<wsdl:output message="tns:waitBackendEventResponse"/>
|
||||
<wsdl:fault name="waitBackendEventFault" message="tns:waitBackendEventFault"/>
|
||||
</wsdl:operation>
|
||||
</wsdl:portType>
|
||||
<wsdl:portType name="AccessController">
|
||||
<wsdl:operation name="authorizeJoin">
|
||||
<wsdl:input message="tns:authorizeJoin"/>
|
||||
<wsdl:output message="tns:authorizeJoinResponse"/>
|
||||
<wsdl:fault name="authorizeJoinFault" message="tns:authorizeJoinFault"/>
|
||||
</wsdl:operation>
|
||||
</wsdl:portType>
|
||||
<wsdl:binding name="Presence" type="tns:Presence">
|
||||
@ -69,6 +81,7 @@
|
||||
<wsdl:output>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:output>
|
||||
<wsdl:fault name="waitBackendEventFault"/>
|
||||
</wsdl:operation>
|
||||
</wsdl:binding>
|
||||
<wsdl:binding name="AccessController" type="tns:AccessController">
|
||||
@ -81,6 +94,7 @@
|
||||
<wsdl:output>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:output>
|
||||
<wsdl:fault name="authorizeJoinFault"/>
|
||||
</wsdl:operation>
|
||||
</wsdl:binding>
|
||||
<wsdl:service name="SmartCAPWAP">
|
||||
|
Loading…
Reference in New Issue
Block a user