X-Git-Url: https://git.saurik.com/apple/ipsec.git/blobdiff_plain/52b7d2ce06d68d0a9160d16f6e7c08c21c149d0d..c8d8bee0bee0298e25cb827876f57e58cc0a938c:/ipsec-tools/Common/key_debug.c diff --git a/ipsec-tools/Common/key_debug.c b/ipsec-tools/Common/key_debug.c index 06a9d4b..8b03d7e 100644 --- a/ipsec-tools/Common/key_debug.c +++ b/ipsec-tools/Common/key_debug.c @@ -67,26 +67,29 @@ #endif /* !_KERNEL */ #include "config.h" +#include "var.h" #include "libpfkey.h" -static void kdebug_sadb_prop __P((struct sadb_ext *)); -static void kdebug_sadb_identity __P((struct sadb_ext *)); -static void kdebug_sadb_supported __P((struct sadb_ext *)); -static void kdebug_sadb_lifetime __P((struct sadb_ext *)); -static void kdebug_sadb_sa __P((struct sadb_ext *)); -static void kdebug_sadb_address __P((struct sadb_ext *)); -static void kdebug_sadb_key __P((struct sadb_ext *)); -static void kdebug_sadb_x_sa2 __P((struct sadb_ext *)); -static void kdebug_sadb_x_policy __P((struct sadb_ext *ext)); -static void kdebug_sockaddr __P((struct sockaddr *addr)); - +static void kdebug_sadb_prop (struct sadb_ext *); +static void kdebug_sadb_identity (struct sadb_ext *); +static void kdebug_sadb_supported (struct sadb_ext *); +static void kdebug_sadb_lifetime (struct sadb_ext *); +static void kdebug_sadb_sa (struct sadb_ext *); +static void kdebug_sadb_address (struct sadb_ext *); +static void kdebug_sadb_key (struct sadb_ext *); +static void kdebug_sadb_x_sa2 (struct sadb_ext *); +static void kdebug_sadb_session_id (struct sadb_ext *); +static void kdebug_sadb_sastat (struct sadb_ext *); +static void kdebug_sadb_x_policy (struct sadb_ext *ext); +static void kdebug_sockaddr (struct sockaddr_storage *addr); +static void kdebug_sadb_x_ipsecif (struct sadb_ext *ext); #ifdef SADB_X_EXT_NAT_T_TYPE -static void kdebug_sadb_x_nat_t_type __P((struct sadb_ext *ext)); -static void kdebug_sadb_x_nat_t_port __P((struct sadb_ext *ext)); +static void kdebug_sadb_x_nat_t_type (struct sadb_ext *ext); +static void kdebug_sadb_x_nat_t_port (struct sadb_ext *ext); #endif #ifdef _KERNEL -static void kdebug_secreplay __P((struct secreplay *)); +static void kdebug_secreplay (struct secreplay *); #endif #ifndef _KERNEL @@ -143,6 +146,10 @@ kdebug_sadb(base) case SADB_EXT_ADDRESS_SRC: case SADB_EXT_ADDRESS_DST: case SADB_EXT_ADDRESS_PROXY: + case SADB_X_EXT_ADDR_RANGE_SRC_START: + case SADB_X_EXT_ADDR_RANGE_SRC_END: + case SADB_X_EXT_ADDR_RANGE_DST_START: + case SADB_X_EXT_ADDR_RANGE_DST_END: kdebug_sadb_address(ext); break; case SADB_EXT_KEY_AUTH: @@ -171,6 +178,15 @@ kdebug_sadb(base) case SADB_X_EXT_SA2: kdebug_sadb_x_sa2(ext); break; + case SADB_EXT_SESSION_ID: + kdebug_sadb_session_id(ext); + break; + case SADB_EXT_SASTAT: + kdebug_sadb_sastat(ext); + break; + case SADB_X_EXT_IPSECIF: + kdebug_sadb_x_ipsecif(ext); + break; #ifdef SADB_X_EXT_NAT_T_TYPE case SADB_X_EXT_NAT_T_TYPE: kdebug_sadb_x_nat_t_type(ext); @@ -423,12 +439,67 @@ kdebug_sadb_x_sa2(ext) return; } +static void +kdebug_sadb_session_id(ext) +struct sadb_ext *ext; +{ + struct sadb_session_id *p = ALIGNED_CAST(__typeof__(p))ext; // Wcast-align fix (void*) - sadb structs come from and aligned buffer + + /* sanity check */ + if (ext == NULL) { + printf("kdebug_sadb_session_id: NULL pointer was passed.\n"); + return; + } + + printf("sadb_session_id{ id0=%llx, id1=%llx}\n", + p->sadb_session_id_v[0], + p->sadb_session_id_v[1]); +} + +static void +kdebug_sadb_x_ipsecif(struct sadb_ext *ext) +{ + struct sadb_x_ipsecif *p = ALIGNED_CAST(__typeof__(p))ext; + + if (ext == NULL) { + printf("sadb_x_ipsecif: NULL pointer was passed.\n"); + return; + } + + printf("sadb_x_ipsec_if{ ipsecif=%s outgoing=%s\n", p->sadb_x_ipsecif_ipsec_if, p->sadb_x_ipsecif_outgoing_if); + printf(" internal=%s disabled=%d }\n", p->sadb_x_ipsecif_internal_if, p->sadb_x_ipsecif_init_disabled); +} + +static void +kdebug_sadb_sastat(ext) +struct sadb_ext *ext; +{ + struct sadb_sastat *p = ALIGNED_CAST(__typeof__(p))ext; // Wcast-align fix (void*) - sadb structs come from and aligned buffer + struct sastat *stats; + int i; + + /* sanity check */ + if (ext == NULL) { + printf("kdebug_sadb_sastat: NULL pointer was passed.\n"); + return; + } + + printf("sadb_sastat{ dir=%u num=%u\n", + p->sadb_sastat_dir, p->sadb_sastat_list_len); + stats = (__typeof__(stats))(p + 1); + for (i = 0; i < p->sadb_sastat_list_len; i++) { + printf(" spi=%x,\n", + stats[i].spi); + } + printf("}\n"); +} + void kdebug_sadb_x_policy(ext) struct sadb_ext *ext; { struct sadb_x_policy *xpl = (void *)ext; - struct sockaddr *addr; + struct sockaddr_storage *addr; /* sanity check */ if (ext == NULL) @@ -465,7 +536,7 @@ kdebug_sadb_x_policy(ext) addr = (void *)(xisr + 1); kdebug_sockaddr(addr); addr = (void *)((caddr_t)(void *)addr - + sysdep_sa_len(addr)); + + sysdep_sa_len((struct sockaddr *)addr)); kdebug_sockaddr(addr); } @@ -749,7 +820,7 @@ kdebug_mbuf(m0) static void kdebug_sockaddr(addr) - struct sockaddr *addr; + struct sockaddr_storage *addr; { struct sockaddr_in *sin4; #ifdef INET6 @@ -761,9 +832,9 @@ kdebug_sockaddr(addr) panic("kdebug_sockaddr: NULL pointer was passed.\n"); /* NOTE: We deal with port number as host byte order. */ - printf("sockaddr{ len=%u family=%u", sysdep_sa_len(addr), addr->sa_family); + printf("sockaddr_storage{ len=%u family=%u", sysdep_sa_len((struct sockaddr *)addr), addr->ss_family); - switch (addr->sa_family) { + switch (addr->ss_family) { case AF_INET: sin4 = (void *)addr; printf(" port=%u\n", ntohs(sin4->sin_port));