diff options
author | Andreas Steffen <andreas.steffen@strongswan.org> | 2011-08-07 00:21:15 +0200 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2011-08-10 09:29:34 +0200 |
commit | 024d2522d54f3ed91ce7fedfbb34b9c0843b2568 (patch) | |
tree | e092f3804ad27e5e61ae883192784c0983530bf3 | |
parent | d13db9f99dcb73d8cd70179b33268a8f494f600c (diff) | |
download | strongswan-024d2522d54f3ed91ce7fedfbb34b9c0843b2568.tar.bz2 strongswan-024d2522d54f3ed91ce7fedfbb34b9c0843b2568.tar.xz |
added some XML syntax checking
-rw-r--r-- | src/libcharon/plugins/tnc_ifmap/tnc_ifmap_listener.c | 95 |
1 files changed, 85 insertions, 10 deletions
diff --git a/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_listener.c b/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_listener.c index 6d20a59d3..175e3d78b 100644 --- a/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_listener.c +++ b/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_listener.c @@ -67,6 +67,8 @@ static bool newSession(private_tnc_ifmap_listener_t *this) axiom_namespace_t *ns; axiom_attribute_t *attr; axis2_char_t *value; + axutil_qname_t *qname; + bool success = FALSE; /* build newSession request */ @@ -87,22 +89,34 @@ static bool newSession(private_tnc_ifmap_listener_t *this) if (node && axiom_node_get_node_type(node, this->env) == AXIOM_ELEMENT) { el = (axiom_element_t *)axiom_node_get_data_element(node, this->env); - value = axiom_element_get_attribute_value_by_name(el, this->env, + qname = axiom_element_get_qname(el, this->env, node); + success = streq("newSessionResult", + axutil_qname_to_string(qname, this->env)); + + /* process the attributes */ + if (success) + { + value = axiom_element_get_attribute_value_by_name(el, this->env, "session-id"); - this->session_id = strdup(value); - value = axiom_element_get_attribute_value_by_name(el, this->env, + this->session_id = strdup(value); + value = axiom_element_get_attribute_value_by_name(el, this->env, "ifmap-publisher-id"); - this->ifmap_publisher_id = strdup(value); + this->ifmap_publisher_id = strdup(value); - DBG1(DBG_TNC, "session-id: %s, ifmap-publisher-id: %s", - this->session_id, this->ifmap_publisher_id); - success = this->session_id && this->ifmap_publisher_id; + DBG1(DBG_TNC, "session-id: %s, ifmap-publisher-id: %s", + this->session_id, this->ifmap_publisher_id); + success = this->session_id && this->ifmap_publisher_id; - value = axiom_element_get_attribute_value_by_name(el, this->env, + value = axiom_element_get_attribute_value_by_name(el, this->env, "max-poll-result-size"); - if (value) + if (value) + { + DBG1(DBG_TNC, "max-poll-result-size: %s", value); + } + } + else { - DBG1(DBG_TNC, "max-poll-result-size: %s", value); + DBG1(DBG_TNC, "%s", axiom_element_to_string(el, this->env, node)); } } axiom_node_free_tree(result, this->env); @@ -116,6 +130,8 @@ static bool purgePublisher(private_tnc_ifmap_listener_t *this) axiom_element_t *el; axiom_namespace_t *ns; axiom_attribute_t *attr; + axutil_qname_t *qname; + bool success = FALSE; /* build purgePublisher request */ ns = axiom_namespace_create(this->env, IFMAP_NAMESPACE, "ifmap"); @@ -137,6 +153,44 @@ static bool purgePublisher(private_tnc_ifmap_listener_t *this) /* process purgePublisherReceived */ node = axiom_node_get_first_child(result, this->env); + if (node && axiom_node_get_node_type(node, this->env) == AXIOM_ELEMENT) + { + el = (axiom_element_t *)axiom_node_get_data_element(node, this->env); + qname = axiom_element_get_qname(el, this->env, node); + success = streq("purgePublisherReceived", + axutil_qname_to_string(qname, this->env)); + if (!success) + { + DBG1(DBG_TNC, "%s", axiom_element_to_string(el, this->env, node)); + } + } + axiom_node_free_tree(result, this->env); + + return success; +} + +static bool publish(private_tnc_ifmap_listener_t *this) +{ + axiom_node_t *request, *result, *node; + axiom_element_t *el; + axiom_namespace_t *ns; + axiom_attribute_t *attr; + + /* build publish request */ + ns = axiom_namespace_create(this->env, IFMAP_NAMESPACE, "ifmap"); + el = axiom_element_create(this->env, NULL, "publish", ns, &request); + attr = axiom_attribute_create(this->env, "session-id", this->session_id, NULL); + axiom_element_add_attribute(el, this->env, attr, request); + + /* send publish request */ + result = axis2_svc_client_send_receive(this->svc_client, this->env, request); + if (!result) + { + return FALSE; + } + + /* process publishReceived */ + node = axiom_node_get_first_child(result, this->env); axiom_node_free_tree(result, this->env); return TRUE; @@ -148,6 +202,8 @@ static bool endSession(private_tnc_ifmap_listener_t *this) axiom_element_t *el; axiom_namespace_t *ns; axiom_attribute_t *attr; + axutil_qname_t *qname; + bool success = FALSE; /* build endSession request */ ns = axiom_namespace_create(this->env, IFMAP_NAMESPACE, "ifmap"); @@ -164,8 +220,21 @@ static bool endSession(private_tnc_ifmap_listener_t *this) /* process endSessionResult */ node = axiom_node_get_first_child(result, this->env); + if (node && axiom_node_get_node_type(node, this->env) == AXIOM_ELEMENT) + { + el = (axiom_element_t *)axiom_node_get_data_element(node, this->env); + qname = axiom_element_get_qname(el, this->env, node); + success = streq("endSessionResult", + axutil_qname_to_string(qname, this->env)); + if (!success) + { + DBG1(DBG_TNC, "%s", axiom_element_to_string(el, this->env, node)); + } + } axiom_node_free_tree(result, this->env); + return success; + return TRUE; } @@ -183,6 +252,12 @@ METHOD(listener_t, child_updown, bool, me = ike_sa->get_my_host(ike_sa); other = ike_sa->get_other_host(ike_sa); + DBG2(DBG_TNC, "sending publish"); + if (!publish(this)) + { + DBG1(DBG_TNC, "publish with MAP server failed"); + } + return TRUE; } |