implemented PASS and DROP shunt policies

This commit is contained in:
Andreas Steffen
2011-06-28 19:42:54 +02:00
parent 6a5c8ee7a5
commit f87991704e
38 changed files with 1230 additions and 27 deletions
@@ -328,6 +328,9 @@ static auth_cfg_t *build_auth_cfg(private_stroke_config_t *this,
case AUTH_CLASS_EAP:
auth = "eap";
break;
case AUTH_CLASS_ANY:
auth = "any";
break;
}
}
else
+39 -7
View File
@@ -15,7 +15,9 @@
#include "stroke_control.h"
#include <hydra.h>
#include <daemon.h>
#include <processing/jobs/delete_ike_sa_job.h>
#include <processing/jobs/rekey_ike_sa_job.h>
#include <processing/jobs/rekey_child_sa_job.h>
@@ -521,18 +523,37 @@ METHOD(stroke_control_t, purge_ike, void,
}
/**
* call charon to install a trap
* call charon to install a shunt or trap
*/
static void charon_route(peer_cfg_t *peer_cfg, child_cfg_t *child_cfg,
char *name, FILE *out)
{
if (charon->traps->install(charon->traps, peer_cfg, child_cfg))
ipsec_mode_t mode;
mode = child_cfg->get_mode(child_cfg);
if (mode == MODE_PASS || mode == MODE_DROP)
{
fprintf(out, "'%s' routed\n", name);
if (charon->shunts->install(charon->shunts, child_cfg))
{
fprintf(out, "'%s' shunt %N policy installed\n",
name, ipsec_mode_names, mode);
}
else
{
fprintf(out, "'%s' shunt %N policy installation failed\n",
name, ipsec_mode_names, mode);
}
}
else
{
fprintf(out, "routing '%s' failed\n", name);
{
if (charon->traps->install(charon->traps, peer_cfg, child_cfg))
{
fprintf(out, "'%s' routed\n", name);
}
else
{
fprintf(out, "routing '%s' failed\n", name);
}
}
}
@@ -614,6 +635,13 @@ METHOD(stroke_control_t, unroute, void,
child_sa_t *child_sa;
enumerator_t *enumerator;
u_int32_t id;
bool found = FALSE;
if (charon->shunts->uninstall(charon->shunts, msg->unroute.name))
{
fprintf(out, "shunt policy '%s' uninstalled\n", msg->unroute.name);
return;
}
enumerator = charon->traps->create_enumerator(charon->traps);
while (enumerator->enumerate(enumerator, NULL, &child_sa))
@@ -624,11 +652,15 @@ METHOD(stroke_control_t, unroute, void,
enumerator->destroy(enumerator);
charon->traps->uninstall(charon->traps, id);
fprintf(out, "configuration '%s' unrouted\n", msg->unroute.name);
return;
found = TRUE;
}
}
enumerator->destroy(enumerator);
fprintf(out, "configuration '%s' not found\n", msg->unroute.name);
if (!found)
{
fprintf(out, "configuration '%s' not found\n", msg->unroute.name);
}
}
METHOD(stroke_control_t, destroy, void,
+33 -4
View File
@@ -398,6 +398,7 @@ METHOD(stroke_list_t, status, void,
child_cfg_t *child_cfg;
child_sa_t *child_sa;
ike_sa_t *ike_sa;
linked_list_t *my_ts, *other_ts;
bool first, found = FALSE;
char *name = msg->status.name;
u_int half_open;
@@ -503,12 +504,11 @@ METHOD(stroke_list_t, status, void,
children = peer_cfg->create_child_cfg_enumerator(peer_cfg);
while (children->enumerate(children, &child_cfg))
{
linked_list_t *my_ts, *other_ts;
my_ts = child_cfg->get_traffic_selectors(child_cfg, TRUE, NULL, NULL);
other_ts = child_cfg->get_traffic_selectors(child_cfg, FALSE, NULL, NULL);
fprintf(out, "%12s: child: %#R=== %#R", child_cfg->get_name(child_cfg),
my_ts, other_ts);
fprintf(out, "%12s: child: %#R=== %#R%N",
child_cfg->get_name(child_cfg), my_ts, other_ts,
ipsec_mode_names, child_cfg->get_mode(child_cfg));
my_ts->destroy_offset(my_ts, offsetof(traffic_selector_t, destroy));
other_ts->destroy_offset(other_ts, offsetof(traffic_selector_t, destroy));
@@ -524,10 +524,39 @@ METHOD(stroke_list_t, status, void,
enumerator->destroy(enumerator);
}
/* Enumerate shunt policies */
first = TRUE;
enumerator = charon->shunts->create_enumerator(charon->shunts);
while (enumerator->enumerate(enumerator, &child_cfg))
{
if (name && !streq(name, child_cfg->get_name(child_cfg)))
{
continue;
}
if (first)
{
fprintf(out, "Shunted Connections:\n");
first = FALSE;
}
my_ts = child_cfg->get_traffic_selectors(child_cfg, TRUE, NULL, NULL);
other_ts = child_cfg->get_traffic_selectors(child_cfg, FALSE, NULL, NULL);
fprintf(out, "%12s: %#R=== %#R%N\n",
child_cfg->get_name(child_cfg), my_ts, other_ts,
ipsec_mode_names, child_cfg->get_mode(child_cfg));
my_ts->destroy_offset(my_ts, offsetof(traffic_selector_t, destroy));
other_ts->destroy_offset(other_ts, offsetof(traffic_selector_t, destroy));
}
enumerator->destroy(enumerator);
/* Enumerate traps */
first = TRUE;
enumerator = charon->traps->create_enumerator(charon->traps);
while (enumerator->enumerate(enumerator, NULL, &child_sa))
{
if (name && !streq(name, child_sa->get_name(child_sa)))
{
continue;
}
if (first)
{
fprintf(out, "Routed Connections:\n");