ike: Remove redundant check for local NAT when handling changed NAT mappings
[strongswan.git] / src / libcharon / processing / jobs / update_sa_job.c
1 /*
2 * Copyright (C) 2008 Martin Willi
3 * 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 <stdlib.h>
17
18 #include "update_sa_job.h"
19
20 #include <sa/ike_sa.h>
21 #include <daemon.h>
22
23
24 typedef struct private_update_sa_job_t private_update_sa_job_t;
25
26 /**
27 * Private data of an update_sa_job_t Object
28 */
29 struct private_update_sa_job_t {
30 /**
31 * public update_sa_job_t interface
32 */
33 update_sa_job_t public;
34
35 /**
36 * reqid of the CHILD_SA
37 */
38 u_int32_t reqid;
39
40 /**
41 * New SA address and port
42 */
43 host_t *new;
44 };
45
46 METHOD(job_t, destroy, void,
47 private_update_sa_job_t *this)
48 {
49 this->new->destroy(this->new);
50 free(this);
51 }
52
53 METHOD(job_t, execute, job_requeue_t,
54 private_update_sa_job_t *this)
55 {
56 ike_sa_t *ike_sa;
57
58 ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
59 this->reqid, TRUE);
60 if (ike_sa == NULL)
61 {
62 DBG1(DBG_JOB, "CHILD_SA with reqid %d not found for update", this->reqid);
63 }
64 else
65 {
66 ike_sa->update_hosts(ike_sa, NULL, this->new, FALSE);
67 charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
68 }
69 return JOB_REQUEUE_NONE;
70 }
71
72 METHOD(job_t, get_priority, job_priority_t,
73 private_update_sa_job_t *this)
74 {
75 return JOB_PRIO_MEDIUM;
76 }
77
78 /*
79 * Described in header
80 */
81 update_sa_job_t *update_sa_job_create(u_int32_t reqid, host_t *new)
82 {
83 private_update_sa_job_t *this;
84
85 INIT(this,
86 .public = {
87 .job_interface = {
88 .execute = _execute,
89 .get_priority = _get_priority,
90 .destroy = _destroy,
91 },
92 },
93 .reqid = reqid,
94 .new = new,
95 );
96
97 return &this->public;
98 }
99