kernel-wfp: Add some missing IPv6 GUIDs, fix IPv6 host conversion
authorMartin Willi <martin@revosec.ch>
Wed, 18 Dec 2013 10:56:36 +0000 (11:56 +0100)
committerMartin Willi <martin@revosec.ch>
Wed, 4 Jun 2014 14:32:09 +0000 (16:32 +0200)
src/libcharon/plugins/kernel_wfp/kernel_wfp_compat.c
src/libcharon/plugins/kernel_wfp/kernel_wfp_ipsec.c

index 0565939..2be3691 100644 (file)
@@ -33,15 +33,27 @@ const GUID FWPM_CONDITION_IP_PROTOCOL = {
 const GUID FWPM_LAYER_INBOUND_TRANSPORT_V4 = {
        0x5926dfc8, 0xe3cf, 0x4426, { 0xa2,0x83,0xdc,0x39,0x3f,0x5d,0x0f,0x9d }
 };
+const GUID FWPM_LAYER_INBOUND_TRANSPORT_V6 = {
+       0x634a869f, 0xfc23, 0x4b90, { 0xb0,0xc1,0xbf,0x62,0x0a,0x36,0xae,0x6f }
+};
 const GUID FWPM_LAYER_OUTBOUND_TRANSPORT_V4 = {
        0x09e61aea, 0xd214, 0x46e2, { 0x9b,0x21,0xb2,0x6b,0x0b,0x2f,0x28,0xc8 }
 };
+const GUID FWPM_LAYER_OUTBOUND_TRANSPORT_V6 = {
+       0xe1735bde, 0x013f, 0x4655, { 0xb3,0x51,0xa4,0x9e,0x15,0x76,0x2d,0xf0 }
+};
 const GUID FWPM_CALLOUT_IPSEC_INBOUND_TRANSPORT_V4 = {
        0x5132900d, 0x5e84, 0x4b5f, { 0x80,0xe4,0x01,0x74,0x1e,0x81,0xff,0x10 }
 };
+const GUID FWPM_CALLOUT_IPSEC_INBOUND_TRANSPORT_V6 = {
+       0x49d3ac92, 0x2a6c, 0x4dcf, { 0x95,0x5f,0x1c,0x3b,0xe0,0x09,0xdd,0x99 }
+};
 const GUID FWPM_CALLOUT_IPSEC_OUTBOUND_TRANSPORT_V4 = {
        0x4b46bf0a, 0x4523, 0x4e57, { 0xaa,0x38,0xa8,0x79,0x87,0xc9,0x10,0xd9 }
 };
+const GUID FWPM_CALLOUT_IPSEC_OUTBOUND_TRANSPORT_V6 = {
+       0x38d87722, 0xad83, 0x4f11, { 0xa9,0x1f,0xdf,0x0f,0xb0,0x77,0x22,0x5b }
+};
 
 /**
  * Load a function symbol from a loaded dll
index 3dbbb30..a658fd1 100644 (file)
@@ -804,6 +804,21 @@ static bool install_sa(private_kernel_wfp_ipsec_t *this, entry_t *entry,
 }
 
 /**
+ * Convert an IPv6 host address to WFP representation
+ */
+static void host2address6(host_t *host, void *out)
+{
+       u_int32_t *src, *dst = out;
+
+       src = (u_int32_t*)host->get_address(host).ptr;
+
+       dst[0] = untoh32(&src[3]);
+       dst[1] = untoh32(&src[2]);
+       dst[2] = untoh32(&src[1]);
+       dst[3] = untoh32(&src[0]);
+}
+
+/**
  * Fill in traffic structure from entry addresses
  */
 static bool hosts2traffic(private_kernel_wfp_ipsec_t *this,
@@ -822,8 +837,8 @@ static bool hosts2traffic(private_kernel_wfp_ipsec_t *this,
                        return TRUE;
                case AF_INET6:
                        traffic->ipVersion = FWP_IP_VERSION_V6;
-                       memcpy(&traffic->localV6Address, l->get_address(l).ptr, 16);
-                       memcpy(&traffic->remoteV6Address, r->get_address(r).ptr, 16);
+                       host2address6(l, &traffic->localV6Address);
+                       host2address6(r, &traffic->remoteV6Address);
                        return TRUE;
                default:
                        return FALSE;