]> git.saurik.com Git - apple/ipsec.git/blobdiff - ipsec-tools/libipsec/ipsec_get_policylen.c
ipsec-317.tar.gz
[apple/ipsec.git] / ipsec-tools / libipsec / ipsec_get_policylen.c
index 1dca6d2bc66b5829631fd1a55f904c4069783354..8d0174a3de8e313fdd69c0a46fda787162e001ab 100644 (file)
@@ -36,6 +36,7 @@
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/socket.h>
+#include <string.h>
 
 #ifdef HAVE_NETINET6_IPSEC
 #  include <netinet6/ipsec.h>
@@ -44,7 +45,7 @@
 #endif
 
 #ifdef __APPPLE__
-#include <System/net/pfkeyv2.h>
+#include <net/pfkeyv2.h>
 #else
 #include <net/pfkeyv2.h>
 #endif
 #include "ipsec_strerror.h"
 
 int
-ipsec_get_policylen(policy)
-       ipsec_policy_t policy;
+ipsec_get_policylen(ipsec_policy_t policy)
 {
-       return policy ? PFKEY_EXTLEN(policy) : -1;
+    u_int16_t aligned_len;
+    
+    if (policy) {
+        memcpy(&aligned_len, policy, sizeof(u_int16_t));
+        return PFKEY_UNUNIT64(aligned_len);
+    } else
+        return -1;
 }