2 * Copyright (C) 2011 Andreas Steffen
3 * HSR 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
16 #include "start_action_job.h"
21 typedef struct private_start_action_job_t private_start_action_job_t
;
24 * Private data of an start_action_job_t object.
26 struct private_start_action_job_t
{
28 * Public start_action_job_t interface.
30 start_action_job_t
public;
33 METHOD(job_t
, destroy
, void,
34 private_start_action_job_t
*this)
39 METHOD(job_t
, execute
, void,
40 private_start_action_job_t
*this)
42 enumerator_t
*enumerator
, *children
;
44 child_cfg_t
*child_cfg
;
48 enumerator
= charon
->backends
->create_peer_cfg_enumerator(charon
->backends
,
49 NULL
, NULL
, NULL
, NULL
);
50 while (enumerator
->enumerate(enumerator
, &peer_cfg
))
52 if (peer_cfg
->get_ike_version(peer_cfg
) != 2)
57 children
= peer_cfg
->create_child_cfg_enumerator(peer_cfg
);
58 while (children
->enumerate(children
, &child_cfg
))
60 name
= child_cfg
->get_name(child_cfg
);
62 switch (child_cfg
->get_start_action(child_cfg
))
65 DBG1(DBG_JOB
, "start action: initiate '%s'", name
);
66 charon
->controller
->initiate(charon
->controller
,
67 peer_cfg
->get_ref(peer_cfg
),
68 child_cfg
->get_ref(child_cfg
),
72 DBG1(DBG_JOB
, "start action: route '%s'", name
);
73 mode
= child_cfg
->get_mode(child_cfg
);
74 if (mode
== MODE_PASS
|| mode
== MODE_DROP
)
76 charon
->shunts
->install(charon
->shunts
, child_cfg
);
80 charon
->traps
->install(charon
->traps
, peer_cfg
,
88 children
->destroy(children
);
90 enumerator
->destroy(enumerator
);
94 METHOD(job_t
, get_priority
, job_priority_t
,
95 private_start_action_job_t
*this)
97 return JOB_PRIO_MEDIUM
;
101 * Described in header
103 start_action_job_t
*start_action_job_create(void)
105 private_start_action_job_t
*this;
111 .get_priority
= _get_priority
,
116 return &this->public;