Return to retransmit_job.c CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / strongswan / src / libcharon / processing / jobs |
1.1 misho 1: /* 2: * Copyright (C) 2005-2007 Martin Willi 3: * Copyright (C) 2005 Jan Hutter 4: * HSR Hochschule fuer Technik Rapperswil 5: * 6: * This program is free software; you can redistribute it and/or modify it 7: * under the terms of the GNU General Public License as published by the 8: * Free Software Foundation; either version 2 of the License, or (at your 9: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. 10: * 11: * This program is distributed in the hope that it will be useful, but 12: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14: * for more details. 15: */ 16: 17: #include "retransmit_job.h" 18: 19: #include <daemon.h> 20: 21: typedef struct private_retransmit_job_t private_retransmit_job_t; 22: 23: /** 24: * Private data of an retransmit_job_t Object. 25: */ 26: struct private_retransmit_job_t { 27: /** 28: * Public retransmit_job_t interface. 29: */ 30: retransmit_job_t public; 31: 32: /** 33: * Message ID of the request to resend. 34: */ 35: uint32_t message_id; 36: 37: /** 38: * ID of the IKE_SA which the message belongs to. 39: */ 40: ike_sa_id_t *ike_sa_id; 41: }; 42: 43: METHOD(job_t, destroy, void, 44: private_retransmit_job_t *this) 45: { 46: this->ike_sa_id->destroy(this->ike_sa_id); 47: free(this); 48: } 49: 50: METHOD(job_t, execute, job_requeue_t, 51: private_retransmit_job_t *this) 52: { 53: ike_sa_t *ike_sa; 54: 55: ike_sa = charon->ike_sa_manager->checkout(charon->ike_sa_manager, 56: this->ike_sa_id); 57: if (ike_sa) 58: { 59: if (ike_sa->retransmit(ike_sa, this->message_id) == DESTROY_ME) 60: { 61: /* retransmitted to many times, giving up */ 62: charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager, 63: ike_sa); 64: } 65: else 66: { 67: charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa); 68: } 69: } 70: return JOB_REQUEUE_NONE; 71: } 72: 73: METHOD(job_t, get_priority, job_priority_t, 74: private_retransmit_job_t *this) 75: { 76: return JOB_PRIO_HIGH; 77: } 78: 79: /* 80: * Described in header. 81: */ 82: retransmit_job_t *retransmit_job_create(uint32_t message_id,ike_sa_id_t *ike_sa_id) 83: { 84: private_retransmit_job_t *this; 85: 86: INIT(this, 87: .public = { 88: .job_interface = { 89: .execute = _execute, 90: .get_priority = _get_priority, 91: .destroy = _destroy, 92: }, 93: }, 94: .message_id = message_id, 95: .ike_sa_id = ike_sa_id->clone(ike_sa_id), 96: ); 97: 98: return &this->public; 99: }