Return to rekey_child_sa_job.c CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / strongswan / src / libcharon / processing / jobs |
1.1 misho 1: /* 2: * Copyright (C) 2006 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 "rekey_child_sa_job.h" 17: 18: #include <daemon.h> 19: 20: 21: typedef struct private_rekey_child_sa_job_t private_rekey_child_sa_job_t; 22: 23: /** 24: * Private data of an rekey_child_sa_job_t object. 25: */ 26: struct private_rekey_child_sa_job_t { 27: 28: /** 29: * Public rekey_child_sa_job_t interface. 30: */ 31: rekey_child_sa_job_t public; 32: 33: /** 34: * protocol of the CHILD_SA (ESP/AH) 35: */ 36: protocol_id_t protocol; 37: 38: /** 39: * inbound SPI of the CHILD_SA 40: */ 41: uint32_t spi; 42: 43: /** 44: * SA destination address 45: */ 46: host_t *dst; 47: }; 48: 49: METHOD(job_t, destroy, void, 50: private_rekey_child_sa_job_t *this) 51: { 52: this->dst->destroy(this->dst); 53: free(this); 54: } 55: 56: METHOD(job_t, execute, job_requeue_t, 57: private_rekey_child_sa_job_t *this) 58: { 59: ike_sa_t *ike_sa; 60: 61: ike_sa = charon->child_sa_manager->checkout(charon->child_sa_manager, 62: this->protocol, this->spi, this->dst, NULL); 63: if (ike_sa == NULL) 64: { 65: DBG1(DBG_JOB, "CHILD_SA %N/0x%08x/%H not found for rekey", 66: protocol_id_names, this->protocol, htonl(this->spi), this->dst); 67: } 68: else 69: { 70: if (ike_sa->get_state(ike_sa) != IKE_PASSIVE) 71: { 72: ike_sa->rekey_child_sa(ike_sa, this->protocol, this->spi); 73: } 74: charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa); 75: } 76: return JOB_REQUEUE_NONE; 77: } 78: 79: METHOD(job_t, get_priority, job_priority_t, 80: private_rekey_child_sa_job_t *this) 81: { 82: return JOB_PRIO_MEDIUM; 83: } 84: 85: /* 86: * Described in header 87: */ 88: rekey_child_sa_job_t *rekey_child_sa_job_create(protocol_id_t protocol, 89: uint32_t spi, host_t *dst) 90: { 91: private_rekey_child_sa_job_t *this; 92: 93: INIT(this, 94: .public = { 95: .job_interface = { 96: .execute = _execute, 97: .get_priority = _get_priority, 98: .destroy = _destroy, 99: }, 100: }, 101: .protocol = protocol, 102: .spi = spi, 103: .dst = dst->clone(dst), 104: ); 105: 106: return &this->public; 107: }