summaryrefslogtreecommitdiff
path: root/src/libcharon/plugins/updown
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2010-08-09 08:09:54 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2010-08-09 08:09:54 +0000
commitb8064f4099997a9e2179f3ad4ace605f5ccac3a1 (patch)
tree81778e976b476374c48b4fe83d084b986b890421 /src/libcharon/plugins/updown
parent1ac70afcc1f7d6d2738a34308810719b0976d29f (diff)
downloadvyos-strongswan-b8064f4099997a9e2179f3ad4ace605f5ccac3a1.tar.gz
vyos-strongswan-b8064f4099997a9e2179f3ad4ace605f5ccac3a1.zip
[svn-upgrade] new version strongswan (4.4.1)
Diffstat (limited to 'src/libcharon/plugins/updown')
-rw-r--r--src/libcharon/plugins/updown/Makefile.in2
-rw-r--r--src/libcharon/plugins/updown/updown_listener.c71
2 files changed, 70 insertions, 3 deletions
diff --git a/src/libcharon/plugins/updown/Makefile.in b/src/libcharon/plugins/updown/Makefile.in
index d3c509a32..ce233ad04 100644
--- a/src/libcharon/plugins/updown/Makefile.in
+++ b/src/libcharon/plugins/updown/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11 from Makefile.am.
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff --git a/src/libcharon/plugins/updown/updown_listener.c b/src/libcharon/plugins/updown/updown_listener.c
index 5a6746f92..ea4a792c2 100644
--- a/src/libcharon/plugins/updown/updown_listener.c
+++ b/src/libcharon/plugins/updown/updown_listener.c
@@ -115,7 +115,8 @@ METHOD(listener_t, child_updown, bool,
{
char command[1024];
char *my_client, *other_client, *my_client_mask, *other_client_mask;
- char *pos, *virtual_ip, *iface;
+ char *pos, *virtual_ip, *iface, *mark_in, *mark_out, *udp_enc;
+ mark_t mark;
bool is_host, is_ipv6;
FILE *shell;
@@ -160,6 +161,61 @@ METHOD(listener_t, child_updown, bool,
}
}
+ /* check for the presence of an inbound mark */
+ mark = config->get_mark(config, TRUE);
+ if (mark.value)
+ {
+ if (asprintf(&mark_in, "PLUTO_MARK_IN='%u/0x%08x' ",
+ mark.value, mark.mask ) < 0)
+ {
+ mark_in = NULL;
+ }
+ }
+ else
+ {
+ if (asprintf(&mark_in, "") < 0)
+ {
+ mark_in = NULL;
+ }
+ }
+
+ /* check for the presence of an outbound mark */
+ mark = config->get_mark(config, FALSE);
+ if (mark.value)
+ {
+ if (asprintf(&mark_out, "PLUTO_MARK_OUT='%u/0x%08x' ",
+ mark.value, mark.mask ) < 0)
+ {
+ mark_out = NULL;
+ }
+ }
+ else
+ {
+ if (asprintf(&mark_out, "") < 0)
+ {
+ mark_out = NULL;
+ }
+ }
+
+ /* check for a NAT condition causing ESP_IN_UDP encapsulation */
+ if (ike_sa->has_condition(ike_sa, COND_NAT_ANY))
+ {
+ if (asprintf(&udp_enc, "PLUTO_UDP_ENC='%u' ",
+ other->get_port(other)) < 0)
+ {
+ udp_enc = NULL;
+ }
+
+ }
+ else
+ {
+ if (asprintf(&udp_enc, "") < 0)
+ {
+ udp_enc = NULL;
+ }
+
+ }
+
if (up)
{
iface = charon->kernel_interface->get_interface(
@@ -205,6 +261,9 @@ METHOD(listener_t, child_updown, bool,
"PLUTO_PEER_PROTOCOL='%u' "
"%s"
"%s"
+ "%s"
+ "%s"
+ "%s"
"%s",
up ? "up" : "down",
is_host ? "-host" : "-client",
@@ -223,11 +282,17 @@ METHOD(listener_t, child_updown, bool,
other_ts->get_from_port(other_ts),
other_ts->get_protocol(other_ts),
virtual_ip,
+ mark_in,
+ mark_out,
+ udp_enc,
config->get_hostaccess(config) ? "PLUTO_HOST_ACCESS='1' " : "",
script);
free(my_client);
free(other_client);
free(virtual_ip);
+ free(mark_in);
+ free(mark_out);
+ free(udp_enc);
free(iface);
DBG3(DBG_CHD, "running updown script: %s", command);
@@ -283,7 +348,9 @@ updown_listener_t *updown_listener_create()
INIT(this,
.public = {
- .listener.child_updown = _child_updown,
+ .listener = {
+ .child_updown = _child_updown,
+ },
.destroy = _destroy,
},
.iface_cache = linked_list_create(),