diff options
author | Andreas Steffen <andreas.steffen@strongswan.org> | 2012-03-21 14:25:19 +0100 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2012-03-21 14:25:19 +0100 |
commit | 80abe22f659e0922c40f9327103926772716b341 (patch) | |
tree | bd931bb1a96525b55347c4b9dc166272fc5c6a8e /src | |
parent | 3cea55b0c819f90045a7ae5657ed476834b74746 (diff) | |
download | strongswan-80abe22f659e0922c40f9327103926772716b341.tar.bz2 strongswan-80abe22f659e0922c40f9327103926772716b341.tar.xz |
fixed parsing of IF-MAP SOAP responses
Diffstat (limited to 'src')
-rw-r--r-- | src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap.c | 65 |
1 files changed, 30 insertions, 35 deletions
diff --git a/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap.c b/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap.c index 8607e5d9b..913cdab12 100644 --- a/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap.c +++ b/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_soap.c @@ -70,15 +70,14 @@ struct private_tnc_ifmap_soap_t { /** * Send request and receive result via SOAP */ -static bool send_receive(private_tnc_ifmap_soap_t *this, - char *request_qname, axiom_node_t *request, - char *receipt_qname, axiom_node_t **result) +static axiom_element_t* send_receive(private_tnc_ifmap_soap_t *this, + char *request_qname, axiom_node_t *request, + char *receipt_qname, axiom_node_t **result) { axiom_node_t *parent, *node; - axiom_element_t *el; + axiom_element_t *parent_el, *el; axutil_qname_t *qname; - bool success = FALSE; /* send request and receive result */ DBG2(DBG_TNC, "sending ifmap %s", request_qname); @@ -87,45 +86,44 @@ static bool send_receive(private_tnc_ifmap_soap_t *this, if (!parent) { DBG1(DBG_TNC, "no ifmap %s received from MAP server", receipt_qname); - return FALSE; + return NULL; } + DBG2(DBG_TNC, "received ifmap %s", receipt_qname); + + /* extract the parent element */ + parent_el = (axiom_element_t*)axiom_node_get_data_element(parent, this->env); - /* pre-process result */ - node = axiom_node_get_first_child(parent, this->env); - if (node && axiom_node_get_node_type(node, this->env) == AXIOM_ELEMENT) + /* look for a child node with the given receipt qname */ + qname = axutil_qname_create_from_string(this->env, strdup(receipt_qname)); + el = axiom_element_get_first_child_with_qname(parent_el, this->env, qname, + parent, &node); + axutil_qname_free(qname, this->env); + + if (el) { - el = (axiom_element_t *)axiom_node_get_data_element(node, this->env); - - qname = axiom_element_get_qname(el, this->env, node); - success = streq(receipt_qname, axutil_qname_to_string(qname, this->env)); - if (success) - { - DBG2(DBG_TNC, "received ifmap %s", receipt_qname); - if (result) - { - *result = parent; - } - else - { - /* no further processing requested */ - axiom_node_free_tree(parent, this->env); - } - return TRUE; + if (result) + { + *result = parent; } - /* TODO proper error handling */ - DBG1(DBG_TNC, "%s", axiom_element_to_string(el, this->env, node)); + else + { + /* no further processing requested */ + axiom_node_free_tree(parent, this->env); + } + return el; } + DBG1(DBG_TNC, "child node with qname '%s' not found", receipt_qname); /* free parent in the error case */ axiom_node_free_tree(parent, this->env); - return FALSE; + return NULL; } METHOD(tnc_ifmap_soap_t, newSession, bool, private_tnc_ifmap_soap_t *this) { - axiom_node_t *request, *result, *node; + axiom_node_t *request, *result; axiom_element_t *el; axiom_namespace_t *ns; axis2_char_t *value; @@ -136,15 +134,12 @@ METHOD(tnc_ifmap_soap_t, newSession, bool, el = axiom_element_create(this->env, NULL, "newSession", ns, &request); /* send newSession request and receive newSessionResult */ - if (!send_receive(this, "newSession", request, "newSessionResult", &result)) + el = send_receive(this, "newSession", request, "newSessionResult", &result); + if (!el) { return FALSE; } - /* process newSessionResult */ - node = axiom_node_get_first_child(result, this->env); - el = (axiom_element_t *)axiom_node_get_data_element(node, this->env); - /* get session-id */ value = axiom_element_get_attribute_value_by_name(el, this->env, "session-id"); |