X-Git-Url: https://git.saurik.com/apple/ipsec.git/blobdiff_plain/52b7d2ce06d68d0a9160d16f6e7c08c21c149d0d..7ebaebe21b526e3d6ce7f5237b574332785dd198:/ipsec-tools/libipsec/ipsec_get_policylen.c diff --git a/ipsec-tools/libipsec/ipsec_get_policylen.c b/ipsec-tools/libipsec/ipsec_get_policylen.c index 1dca6d2..8d0174a 100644 --- a/ipsec-tools/libipsec/ipsec_get_policylen.c +++ b/ipsec-tools/libipsec/ipsec_get_policylen.c @@ -36,6 +36,7 @@ #include #include #include +#include #ifdef HAVE_NETINET6_IPSEC # include @@ -44,7 +45,7 @@ #endif #ifdef __APPPLE__ -#include +#include #else #include #endif @@ -53,8 +54,13 @@ #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; }