Annotation of embedaddon/strongswan/src/libcharon/sa/ikev2/tasks/ike_reauth.c, revision 1.1
1.1 ! misho 1: /*
! 2: * Copyright (C) 2006-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 "ike_reauth.h"
! 17:
! 18: #include <daemon.h>
! 19: #include <sa/ikev2/tasks/ike_delete.h>
! 20:
! 21:
! 22: typedef struct private_ike_reauth_t private_ike_reauth_t;
! 23:
! 24: /**
! 25: * Private members of a ike_reauth_t task.
! 26: */
! 27: struct private_ike_reauth_t {
! 28:
! 29: /**
! 30: * Public methods and task_t interface.
! 31: */
! 32: ike_reauth_t public;
! 33:
! 34: /**
! 35: * Assigned IKE_SA.
! 36: */
! 37: ike_sa_t *ike_sa;
! 38:
! 39: /**
! 40: * reused ike_delete task
! 41: */
! 42: ike_delete_t *ike_delete;
! 43: };
! 44:
! 45: METHOD(task_t, build_i, status_t,
! 46: private_ike_reauth_t *this, message_t *message)
! 47: {
! 48: return this->ike_delete->task.build(&this->ike_delete->task, message);
! 49: }
! 50:
! 51: METHOD(task_t, process_i, status_t,
! 52: private_ike_reauth_t *this, message_t *message)
! 53: {
! 54: /* process delete response first */
! 55: this->ike_delete->task.process(&this->ike_delete->task, message);
! 56:
! 57: /* reestablish the IKE_SA with all children */
! 58: if (this->ike_sa->reestablish(this->ike_sa) != SUCCESS)
! 59: {
! 60: DBG1(DBG_IKE, "reauthenticating IKE_SA failed");
! 61: return FAILED;
! 62: }
! 63:
! 64: /* we always destroy the obsolete IKE_SA */
! 65: return DESTROY_ME;
! 66: }
! 67:
! 68: METHOD(task_t, get_type, task_type_t,
! 69: private_ike_reauth_t *this)
! 70: {
! 71: return TASK_IKE_REAUTH;
! 72: }
! 73:
! 74: METHOD(task_t, migrate, void,
! 75: private_ike_reauth_t *this, ike_sa_t *ike_sa)
! 76: {
! 77: this->ike_delete->task.migrate(&this->ike_delete->task, ike_sa);
! 78: this->ike_sa = ike_sa;
! 79: }
! 80:
! 81: METHOD(task_t, destroy, void,
! 82: private_ike_reauth_t *this)
! 83: {
! 84: this->ike_delete->task.destroy(&this->ike_delete->task);
! 85: free(this);
! 86: }
! 87:
! 88: /*
! 89: * Described in header.
! 90: */
! 91: ike_reauth_t *ike_reauth_create(ike_sa_t *ike_sa)
! 92: {
! 93: private_ike_reauth_t *this;
! 94:
! 95: INIT(this,
! 96: .public = {
! 97: .task = {
! 98: .get_type = _get_type,
! 99: .migrate = _migrate,
! 100: .build = _build_i,
! 101: .process = _process_i,
! 102: .destroy = _destroy,
! 103: },
! 104: },
! 105: .ike_sa = ike_sa,
! 106: .ike_delete = ike_delete_create(ike_sa, TRUE),
! 107: );
! 108:
! 109: return &this->public;
! 110: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>