Annotation of embedaddon/strongswan/src/libcharon/processing/jobs/update_sa_job.c, revision 1.1
1.1 ! misho 1: /*
! 2: * Copyright (C) 2008 Martin Willi
! 3: * HSR Hochschule fuer Technik Rapperswil
! 4: *
! 5: * This program is free software; you can redistribute it and/or modify it
! 6: * under the terms of the GNU General Public License as published by the
! 7: * Free Software Foundation; either version 2 of the License, or (at your
! 8: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
! 9: *
! 10: * This program is distributed in the hope that it will be useful, but
! 11: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
! 12: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
! 13: * for more details.
! 14: */
! 15:
! 16: #include <stdlib.h>
! 17:
! 18: #include "update_sa_job.h"
! 19:
! 20: #include <sa/ike_sa.h>
! 21: #include <daemon.h>
! 22:
! 23:
! 24: typedef struct private_update_sa_job_t private_update_sa_job_t;
! 25:
! 26: /**
! 27: * Private data of an update_sa_job_t Object
! 28: */
! 29: struct private_update_sa_job_t {
! 30:
! 31: /**
! 32: * public update_sa_job_t interface
! 33: */
! 34: update_sa_job_t public;
! 35:
! 36: /**
! 37: * protocol of the CHILD_SA (ESP/AH)
! 38: */
! 39: protocol_id_t protocol;
! 40:
! 41: /**
! 42: * SPI of the CHILD_SA
! 43: */
! 44: uint32_t spi;
! 45:
! 46: /**
! 47: * Old SA destination address
! 48: */
! 49: host_t *dst;
! 50:
! 51: /**
! 52: * New SA address and port
! 53: */
! 54: host_t *new;
! 55: };
! 56:
! 57: METHOD(job_t, destroy, void,
! 58: private_update_sa_job_t *this)
! 59: {
! 60: this->dst->destroy(this->dst);
! 61: this->new->destroy(this->new);
! 62: free(this);
! 63: }
! 64:
! 65: METHOD(job_t, execute, job_requeue_t,
! 66: private_update_sa_job_t *this)
! 67: {
! 68: ike_sa_t *ike_sa;
! 69:
! 70: ike_sa = charon->child_sa_manager->checkout(charon->child_sa_manager,
! 71: this->protocol, this->spi, this->dst, NULL);
! 72: if (ike_sa == NULL)
! 73: {
! 74: DBG1(DBG_JOB, "CHILD_SA %N/0x%08x/%H not found for update",
! 75: protocol_id_names, this->protocol, htonl(this->spi), this->dst);
! 76: }
! 77: else
! 78: {
! 79: ike_sa->update_hosts(ike_sa, NULL, this->new, FALSE);
! 80: charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
! 81: }
! 82: return JOB_REQUEUE_NONE;
! 83: }
! 84:
! 85: METHOD(job_t, get_priority, job_priority_t,
! 86: private_update_sa_job_t *this)
! 87: {
! 88: return JOB_PRIO_MEDIUM;
! 89: }
! 90:
! 91: /*
! 92: * Described in header
! 93: */
! 94: update_sa_job_t *update_sa_job_create(protocol_id_t protocol,
! 95: uint32_t spi, host_t *dst, host_t *new)
! 96: {
! 97: private_update_sa_job_t *this;
! 98:
! 99: INIT(this,
! 100: .public = {
! 101: .job_interface = {
! 102: .execute = _execute,
! 103: .get_priority = _get_priority,
! 104: .destroy = _destroy,
! 105: },
! 106: },
! 107: .protocol = protocol,
! 108: .spi = spi,
! 109: .dst = dst->clone(dst),
! 110: .new = new->clone(new),
! 111: );
! 112:
! 113: return &this->public;
! 114: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>