2 * Copyright (C) 2007 Martin Willi
3 * Hochschule fuer Technik Rapperswil
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>.
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
20 #include <sa/ike_sa.h>
24 typedef struct private_roam_job_t private_roam_job_t
;
27 * Private data of an roam_job_t Object
29 struct private_roam_job_t
{
31 * public roam_job_t interface
36 * has the address list changed, or the routing only?
41 METHOD(job_t
, destroy
, void,
42 private_roam_job_t
*this)
47 METHOD(job_t
, execute
, void,
48 private_roam_job_t
*this)
53 enumerator_t
*enumerator
;
55 /* enumerator over all IKE_SAs gives us no way to checkin_and_destroy
56 * after a DESTROY_ME, so we check out each available IKE_SA by hand. */
57 list
= linked_list_create();
58 enumerator
= charon
->ike_sa_manager
->create_enumerator(charon
->ike_sa_manager
);
59 while (enumerator
->enumerate(enumerator
, &ike_sa
))
61 id
= ike_sa
->get_id(ike_sa
);
62 list
->insert_last(list
, id
->clone(id
));
64 enumerator
->destroy(enumerator
);
66 while (list
->remove_last(list
, (void**)&id
) == SUCCESS
)
68 ike_sa
= charon
->ike_sa_manager
->checkout(charon
->ike_sa_manager
, id
);
71 if (ike_sa
->roam(ike_sa
, this->address
) == DESTROY_ME
)
73 charon
->ike_sa_manager
->checkin_and_destroy(
74 charon
->ike_sa_manager
, ike_sa
);
78 charon
->ike_sa_manager
->checkin(charon
->ike_sa_manager
, ike_sa
);
88 METHOD(job_t
, get_priority
, job_priority_t
,
89 private_roam_job_t
*this)
91 return JOB_PRIO_MEDIUM
;
97 roam_job_t
*roam_job_create(bool address
)
99 private_roam_job_t
*this;
105 .get_priority
= _get_priority
,
112 return &this->public;