]>
Commit | Line | Data |
---|---|---|
45f76a7d MW |
1 | /** |
2 | * @file acquire_job.c | |
3 | * | |
4 | * @brief Implementation of acquire_job_t. | |
5 | * | |
6 | */ | |
7 | ||
8 | /* | |
9 | * Copyright (C) 2006 Martin Willi | |
10 | * Hochschule fuer Technik Rapperswil | |
11 | * | |
12 | * This program is free software; you can redistribute it and/or modify it | |
13 | * under the terms of the GNU General Public License as published by the | |
14 | * Free Software Foundation; either version 2 of the License, or (at your | |
15 | * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. | |
16 | * | |
17 | * This program is distributed in the hope that it will be useful, but | |
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
19 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
20 | * for more details. | |
21 | */ | |
22 | ||
23 | #include "acquire_job.h" | |
24 | ||
25 | #include <daemon.h> | |
26 | ||
27 | ||
28 | typedef struct private_acquire_job_t private_acquire_job_t; | |
29 | ||
30 | /** | |
31 | * Private data of an acquire_job_t object. | |
32 | */ | |
33 | struct private_acquire_job_t { | |
34 | /** | |
35 | * Public acquire_job_t interface. | |
36 | */ | |
37 | acquire_job_t public; | |
38 | ||
39 | /** | |
40 | * reqid of the child to rekey | |
41 | */ | |
42 | u_int32_t reqid; | |
45f76a7d MW |
43 | }; |
44 | ||
45 | /** | |
46 | * Implementation of job_t.get_type. | |
47 | */ | |
48 | static job_type_t get_type(private_acquire_job_t *this) | |
49 | { | |
50 | return ACQUIRE; | |
51 | } | |
52 | ||
53 | /** | |
54 | * Implementation of job_t.execute. | |
55 | */ | |
56 | static status_t execute(private_acquire_job_t *this) | |
57 | { | |
58 | ike_sa_t *ike_sa; | |
59 | ||
c60c7694 MW |
60 | ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager, |
61 | this->reqid, TRUE); | |
45f76a7d MW |
62 | if (ike_sa == NULL) |
63 | { | |
b83806d8 | 64 | DBG2(DBG_JOB, "CHILD_SA with reqid %d not found for acquiring", |
60356f33 | 65 | this->reqid); |
45f76a7d MW |
66 | return DESTROY_ME; |
67 | } | |
68 | ike_sa->acquire(ike_sa, this->reqid); | |
69 | ||
70 | charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa); | |
71 | return DESTROY_ME; | |
72 | } | |
73 | ||
74 | /** | |
75 | * Implementation of job_t.destroy. | |
76 | */ | |
77 | static void destroy(private_acquire_job_t *this) | |
78 | { | |
79 | free(this); | |
80 | } | |
81 | ||
82 | /* | |
83 | * Described in header | |
84 | */ | |
85 | acquire_job_t *acquire_job_create(u_int32_t reqid) | |
86 | { | |
87 | private_acquire_job_t *this = malloc_thing(private_acquire_job_t); | |
88 | ||
89 | /* interface functions */ | |
90 | this->public.job_interface.get_type = (job_type_t (*) (job_t *)) get_type; | |
91 | this->public.job_interface.execute = (status_t (*) (job_t *)) execute; | |
92 | this->public.job_interface.destroy = (void (*)(job_t*)) destroy; | |
93 | ||
94 | /* private variables */ | |
95 | this->reqid = reqid; | |
45f76a7d MW |
96 | |
97 | return &(this->public); | |
98 | } |