METHOD(tnc_ifmap_listener_t, destroy, void,
private_tnc_ifmap_listener_t *this)
{
- DESTROY_IF(this->ifmap);
+ if (this->ifmap)
+ {
+ if (this->ifmap->get_session_id(this->ifmap))
+ {
+ this->ifmap->endSession(this->ifmap);
+ }
+ this->ifmap->destroy(this->ifmap);
+ }
free(this);
}
"%s.plugins.tnc-ifmap.renew_session_interval",
IFMAP_RENEW_SESSION_INTERVAL, charon->name);
- job = (job_t*)tnc_ifmap_renew_session_job_create(this->ifmap, reschedule);
+ job = (job_t*)tnc_ifmap_renew_session_job_create(
+ this->ifmap->get_ref(this->ifmap), reschedule);
lib->scheduler->schedule_job(lib->scheduler, job, reschedule);
return &this->public;
METHOD(job_t, execute, job_requeue_t,
private_tnc_ifmap_renew_session_job_t *this)
{
- this->ifmap->renewSession(this->ifmap);
-
- return JOB_RESCHEDULE(this->reschedule);
+ char *session_id;
+
+ if (this->ifmap->orphaned(this->ifmap))
+ {
+ session_id = this->ifmap->get_session_id(this->ifmap);
+ DBG2(DBG_TNC, "removing orphaned ifmap renewSession job for '%s'",
+ session_id);
+ this->ifmap->destroy(this->ifmap);
+ return JOB_REQUEUE_NONE;
+ }
+ else
+ {
+ if (!this->ifmap->renewSession(this->ifmap))
+ {
+ DBG1(DBG_TNC, "sending ifmap renewSession failed");
+ /* TODO take some action */
+ }
+ return JOB_RESCHEDULE(this->reschedule);
+ }
}
METHOD(job_t, get_priority, job_priority_t,
*/
mem_cred_t *creds;
+ /**
+ * reference count
+ */
+ refcount_t ref;
+
};
METHOD(tnc_ifmap_soap_t, newSession, bool,
this->ifmap_publisher_id = xmlGetProp(result, "ifmap-publisher-id");
soap_msg->destroy(soap_msg);
- DBG1(DBG_TNC, "session-id: %s, ifmap-publisher-id: %s",
+ DBG1(DBG_TNC, "created ifmap session '%s' as publisher '%s'",
this->session_id, this->ifmap_publisher_id);
/* set PEP and PDP device name (defaults to IF-MAP Publisher ID) */
/* extract relevant data from IKE_SA*/
ike_sa_id = ike_sa->get_unique_id(ike_sa);
+ host = ike_sa->get_other_host(ike_sa);
id = ike_sa->get_other_id(ike_sa);
eap_id = ike_sa->get_other_eap_id(ike_sa);
- host = ike_sa->get_other_host(ike_sa);
/* in the presence of an EAP Identity, treat it as a username */
if (!id->equals(id, eap_id))
}
/**
- * update or delete access-request-ip metadata
+ * update or delete access-request-ip metadata for physical IP address
*/
if (up)
{
success = soap_msg->post(soap_msg, request, "endSessionResult", NULL);
soap_msg->destroy(soap_msg);
+ DBG1(DBG_TNC, "ended ifmap session '%s' as publisher '%s'",
+ this->session_id, this->ifmap_publisher_id);
+
return success;
}
+METHOD(tnc_ifmap_soap_t, get_session_id, char*,
+ private_tnc_ifmap_soap_t *this)
+{
+ return this->session_id;
+}
+
+METHOD(tnc_ifmap_soap_t, orphaned, bool,
+ private_tnc_ifmap_soap_t *this)
+{
+ return this->ref == 1;
+}
+
+METHOD(tnc_ifmap_soap_t, get_ref, tnc_ifmap_soap_t*,
+ private_tnc_ifmap_soap_t *this)
+{
+ ref_get(&this->ref);
+ return &this->public;
+}
+
METHOD(tnc_ifmap_soap_t, destroy, void,
private_tnc_ifmap_soap_t *this)
{
- if (this->session_id)
+ if (ref_put(&this->ref))
{
- endSession(this);
- xmlFree(this->session_id);
- xmlFree(this->ifmap_publisher_id);
- free(this->device_name);
- }
- DESTROY_IF(this->tls);
- DESTROY_IF(this->host);
+ if (this->session_id)
+ {
+ xmlFree(this->session_id);
+ xmlFree(this->ifmap_publisher_id);
+ free(this->device_name);
+ }
+ DESTROY_IF(this->tls);
+ DESTROY_IF(this->host);
- if (this->fd != IFMAP_NO_FD)
- {
- close(this->fd);
+ if (this->fd != IFMAP_NO_FD)
+ {
+ close(this->fd);
+ }
+ lib->credmgr->remove_set(lib->credmgr, &this->creds->set);
+ this->creds->destroy(this->creds);
+ free(this->user_pass.ptr);
+ free(this);
}
- lib->credmgr->remove_set(lib->credmgr, &this->creds->set);
- this->creds->destroy(this->creds);
- free(this->user_pass.ptr);
- free(this);
}
static bool soap_init(private_tnc_ifmap_soap_t *this)
.publish_device_ip = _publish_device_ip,
.publish_enforcement_report = _publish_enforcement_report,
.endSession = _endSession,
+ .get_session_id = _get_session_id,
+ .orphaned = _orphaned,
+ .get_ref = _get_ref,
.destroy = _destroy,
},
.fd = IFMAP_NO_FD,
.creds = mem_cred_create(),
+ .ref = 1,
);
lib->credmgr->add_set(lib->credmgr, &this->creds->set);