From: Andreas Steffen Date: Sat, 30 Mar 2013 07:10:39 +0000 (+0100) Subject: added IF-MAP SOAP error handling X-Git-Tag: 5.0.3~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=14bf3cc1bd6dd6b175ebe7667769d3a24e01d346;p=thirdparty%2Fstrongswan.git added IF-MAP SOAP error handling --- diff --git a/src/libcharon/plugins/tnc_ifmap2/tnc_ifmap2_soap_msg.c b/src/libcharon/plugins/tnc_ifmap2/tnc_ifmap2_soap_msg.c index 7bea62d836..b7f8a5ed74 100644 --- a/src/libcharon/plugins/tnc_ifmap2/tnc_ifmap2_soap_msg.c +++ b/src/libcharon/plugins/tnc_ifmap2/tnc_ifmap2_soap_msg.c @@ -51,8 +51,8 @@ struct private_tnc_ifmap2_soap_msg_t { /** * Send HTTP POST request and receive HTTP response */ -static bool http_send_receive(private_tnc_ifmap2_soap_msg_t *this, - chunk_t out, chunk_t *in) +static bool http_post(private_tnc_ifmap2_soap_msg_t *this, chunk_t out, + chunk_t *in) { char header[] = "POST /ifmap HTTP/1.1\r\n" @@ -150,9 +150,9 @@ METHOD(tnc_ifmap2_soap_msg_t, post, bool, char *result_name, xmlNodePtr *result) { xmlDocPtr doc; - xmlNodePtr env, body, cur; + xmlNodePtr env, body, cur, response; xmlNsPtr ns; - xmlChar *xml; + xmlChar *xml, *errorCode, *errorString; int len; chunk_t in, out; @@ -176,8 +176,8 @@ METHOD(tnc_ifmap2_soap_msg_t, post, bool, DBG3(DBG_TNC, "%.*s", len, xml); out = chunk_create(xml, len); - /* Send SOAP-XML request via HTTP */ - if (!http_send_receive(this, out, &in)) + /* Send SOAP-XML request via HTTP POST */ + if (!http_post(this, out, &in)) { xmlFree(xml); return FALSE; @@ -217,16 +217,39 @@ METHOD(tnc_ifmap2_soap_msg_t, post, bool, } /* get IF-MAP response */ - cur = find_child(cur, "response"); - if (!cur) + response = find_child(cur, "response"); + if (!response) { return FALSE; } /* get IF-MAP result */ - cur = find_child(cur, result_name); + cur = find_child(response, result_name); if (!cur) { + cur = find_child(response, "errorResult"); + if (cur) + { + DBG1(DBG_TNC, "received errorResult"); + + errorCode = xmlGetProp(cur, "errorCode"); + if (errorCode) + { + DBG1(DBG_TNC, " %s", errorCode); + xmlFree(errorCode); + } + + cur = find_child(cur, "errorString"); + if (cur) + { + errorString = xmlNodeGetContent(cur); + if (errorString) + { + DBG1(DBG_TNC, " %s", errorString); + xmlFree(errorString); + } + } + } return FALSE; }