/src/strongswan/src/libcharon/processing/jobs/acquire_job.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) 2022-2025 Tobias Brunner |
3 | | * Copyright (C) 2006-2009 Martin Willi |
4 | | * |
5 | | * Copyright (C) secunet Security Networks AG |
6 | | * |
7 | | * This program is free software; you can redistribute it and/or modify it |
8 | | * under the terms of the GNU General Public License as published by the |
9 | | * Free Software Foundation; either version 2 of the License, or (at your |
10 | | * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. |
11 | | * |
12 | | * This program is distributed in the hope that it will be useful, but |
13 | | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
14 | | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
15 | | * for more details. |
16 | | */ |
17 | | |
18 | | #include "acquire_job.h" |
19 | | |
20 | | #include <daemon.h> |
21 | | |
22 | | |
23 | | typedef struct private_acquire_job_t private_acquire_job_t; |
24 | | |
25 | | /** |
26 | | * Private data of an acquire_job_t object. |
27 | | */ |
28 | | struct private_acquire_job_t { |
29 | | /** |
30 | | * Public acquire_job_t interface. |
31 | | */ |
32 | | acquire_job_t public; |
33 | | |
34 | | /** |
35 | | * reqid of the triggered policy |
36 | | */ |
37 | | uint32_t reqid; |
38 | | |
39 | | /** |
40 | | * Data from the acquire |
41 | | */ |
42 | | kernel_acquire_data_t *data; |
43 | | }; |
44 | | |
45 | | METHOD(job_t, destroy, void, |
46 | | private_acquire_job_t *this) |
47 | 0 | { |
48 | 0 | kernel_acquire_data_destroy(this->data); |
49 | 0 | free(this); |
50 | 0 | } |
51 | | |
52 | | METHOD(job_t, execute, job_requeue_t, |
53 | | private_acquire_job_t *this) |
54 | 0 | { |
55 | 0 | charon->traps->acquire(charon->traps, this->reqid, this->data); |
56 | 0 | return JOB_REQUEUE_NONE; |
57 | 0 | } |
58 | | |
59 | | METHOD(job_t, get_priority, job_priority_t, |
60 | | private_acquire_job_t *this) |
61 | 0 | { |
62 | 0 | return JOB_PRIO_MEDIUM; |
63 | 0 | } |
64 | | |
65 | | /* |
66 | | * Described in header |
67 | | */ |
68 | | acquire_job_t *acquire_job_create(uint32_t reqid, kernel_acquire_data_t *data) |
69 | 0 | { |
70 | 0 | private_acquire_job_t *this; |
71 | |
|
72 | 0 | INIT(this, |
73 | 0 | .public = { |
74 | 0 | .job_interface = { |
75 | 0 | .execute = _execute, |
76 | 0 | .get_priority = _get_priority, |
77 | 0 | .destroy = _destroy, |
78 | 0 | }, |
79 | 0 | }, |
80 | 0 | .reqid = reqid, |
81 | 0 | .data = kernel_acquire_data_clone(data), |
82 | 0 | ); |
83 | |
|
84 | 0 | return &this->public; |
85 | 0 | } |