Return to retry_initiate_job.c CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / strongswan / src / libcharon / processing / jobs |
1.1 misho 1: /* 2: * Copyright (C) 2012 Tobias Brunner 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 "retry_initiate_job.h" 17: 18: #include <daemon.h> 19: 20: typedef struct private_retry_initiate_job_t private_retry_initiate_job_t; 21: 22: /** 23: * Private data of an retry_initiate_job_t object. 24: */ 25: struct private_retry_initiate_job_t { 26: /** 27: * Public retry_initiate_job_t interface. 28: */ 29: retry_initiate_job_t public; 30: 31: /** 32: * ID of the IKE_SA to re-initiate 33: */ 34: ike_sa_id_t *ike_sa_id; 35: }; 36: 37: METHOD(job_t, destroy, void, 38: private_retry_initiate_job_t *this) 39: { 40: this->ike_sa_id->destroy(this->ike_sa_id); 41: free(this); 42: } 43: 44: METHOD(job_t, execute, job_requeue_t, 45: private_retry_initiate_job_t *this) 46: { 47: ike_sa_t *ike_sa; 48: 49: ike_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager, 50: this->ike_sa_id); 51: if (ike_sa == NULL) 52: { 53: DBG2(DBG_JOB, "IKE_SA to initiate not found"); 54: } 55: else 56: { 57: if (ike_sa->retry_initiate(ike_sa) == DESTROY_ME) 58: { 59: charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager, 60: ike_sa); 61: } 62: else 63: { 64: charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa); 65: } 66: } 67: return JOB_REQUEUE_NONE; 68: } 69: 70: METHOD(job_t, get_priority, job_priority_t, 71: private_retry_initiate_job_t *this) 72: { 73: return JOB_PRIO_HIGH; 74: } 75: 76: /* 77: * Described in header 78: */ 79: retry_initiate_job_t *retry_initiate_job_create(ike_sa_id_t *ike_sa_id) 80: { 81: private_retry_initiate_job_t *this; 82: 83: INIT(this, 84: .public = { 85: .job_interface = { 86: .execute = _execute, 87: .get_priority = _get_priority, 88: .destroy = _destroy, 89: }, 90: }, 91: .ike_sa_id = ike_sa_id->clone(ike_sa_id), 92: ); 93: 94: return &(this->public); 95: }