X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/1c79356b52d46aa6b508fb032f5ae709b1f2897b..2d21ac55c334faf3a56e5634905ed6987fc787d4:/bsd/netkey/key_debug.c diff --git a/bsd/netkey/key_debug.c b/bsd/netkey/key_debug.c index ee55d4789..054edecb1 100644 --- a/bsd/netkey/key_debug.c +++ b/bsd/netkey/key_debug.c @@ -1,7 +1,10 @@ +/* $FreeBSD: src/sys/netkey/key_debug.c,v 1.10.2.5 2002/04/28 05:40:28 suz Exp $ */ +/* $KAME: key_debug.c,v 1.26 2001/06/27 10:46:50 sakane Exp $ */ + /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -13,7 +16,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -27,23 +30,12 @@ * SUCH DAMAGE. */ -/* KAME @(#)$Id: key_debug.c,v 1.2 2000/09/14 20:35:26 lindak Exp $ */ - -#ifdef KERNEL -# define _KERNEL -#endif - -#ifdef KERNEL -#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(__NetBSD__) -#include "opt_inet.h" -#endif -#endif - #include #include -#if defined(KERNEL) +#ifdef KERNEL #include #include +#include #endif #include @@ -55,24 +47,25 @@ #include #include -#if !defined(KERNEL) +#ifndef KERNEL #include #include #include -#endif /* defined(KERNEL) */ +#endif /* !KERNEL */ -#if !defined(_KERNEL) || (defined(_KERNEL) && defined(IPSEC_DEBUG)) +#if !defined(KERNEL) || (defined(KERNEL) && defined(IPSEC_DEBUG)) -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_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 *); #ifdef KERNEL -static void kdebug_secreplay __P((struct secreplay *)); +static void kdebug_secreplay(struct secreplay *); #endif #ifndef KERNEL @@ -96,11 +89,9 @@ kdebug_sadb(base) printf("sadb_msg{ version=%u type=%u errno=%u satype=%u\n", base->sadb_msg_version, base->sadb_msg_type, base->sadb_msg_errno, base->sadb_msg_satype); - printf(" len=%u mode=%u seq=%u pid=%u reqid=%u\n", - base->sadb_msg_len, base->sadb_msg_mode, - base->sadb_msg_seq, base->sadb_msg_pid, base->sadb_msg_reqid); - printf(" reserved1=%u reserved2=%u\n", - base->sadb_msg_reserved1, base->sadb_msg_reserved2); + printf(" len=%u reserved=%u seq=%u pid=%u\n", + base->sadb_msg_len, base->sadb_msg_reserved, + base->sadb_msg_seq, base->sadb_msg_pid); tlen = PFKEY_UNUNIT64(base->sadb_msg_len) - sizeof(struct sadb_msg); ext = (struct sadb_ext *)((caddr_t)base + sizeof(struct sadb_msg)); @@ -155,6 +146,9 @@ kdebug_sadb(base) case SADB_X_EXT_POLICY: kdebug_sadb_x_policy(ext); break; + case SADB_X_EXT_SA2: + kdebug_sadb_x_sa2(ext); + break; default: printf("kdebug_sadb: invalid ext_type %u was passed.\n", ext->sadb_ext_type); @@ -225,7 +219,6 @@ kdebug_sadb_identity(ext) { struct sadb_ident *id = (struct sadb_ident *)ext; int len; - union sadb_x_ident_id *aid; /* sanity check */ if (ext == NULL) @@ -235,16 +228,6 @@ kdebug_sadb_identity(ext) printf("sadb_ident_%s{", id->sadb_ident_exttype == SADB_EXT_IDENTITY_SRC ? "src" : "dst"); switch (id->sadb_ident_type) { - case SADB_X_IDENTTYPE_ADDR: - aid = (union sadb_x_ident_id *)&id->sadb_ident_id; - - printf(" type=%d prefix=%u ul_proto=%u\n", - id->sadb_ident_type, - aid->sadb_x_ident_id_addr.prefix, - aid->sadb_x_ident_id_addr.ul_proto); - kdebug_sockaddr((struct sockaddr *)(id + 1)); - break; - default: printf(" type=%d id=%lu", id->sadb_ident_type, (u_long)id->sadb_ident_id); @@ -387,6 +370,25 @@ kdebug_sadb_key(ext) return; } +static void +kdebug_sadb_x_sa2(ext) + struct sadb_ext *ext; +{ + struct sadb_x_sa2 *sa2 = (struct sadb_x_sa2 *)ext; + + /* sanity check */ + if (ext == NULL) + panic("kdebug_sadb_x_sa2: NULL pointer was passed.\n"); + + printf("sadb_x_sa2{ mode=%u reqid=%u\n", + sa2->sadb_x_sa2_mode, sa2->sadb_x_sa2_reqid); + printf(" reserved1=%u reserved2=%u sequence=%u }\n", + sa2->sadb_x_sa2_reserved1, sa2->sadb_x_sa2_reserved2, + sa2->sadb_x_sa2_sequence); + + return; +} + void kdebug_sadb_x_policy(ext) struct sadb_ext *ext; @@ -398,9 +400,9 @@ kdebug_sadb_x_policy(ext) if (ext == NULL) panic("kdebug_sadb_x_policy: NULL pointer was passed.\n"); - printf("sadb_x_policy{ type=%u dir=%u reserved=%x }\n", + printf("sadb_x_policy{ type=%u dir=%u id=%x }\n", xpl->sadb_x_policy_type, xpl->sadb_x_policy_dir, - xpl->sadb_x_policy_reserved); + xpl->sadb_x_policy_id); if (xpl->sadb_x_policy_type == IPSEC_POLICY_IPSEC) { int tlen; @@ -468,6 +470,7 @@ kdebug_secpolicy(sp) switch (sp->policy) { case IPSEC_POLICY_DISCARD: + case IPSEC_POLICY_GENERATE: printf(" type=discard }\n"); break; case IPSEC_POLICY_NONE: @@ -481,8 +484,6 @@ kdebug_secpolicy(sp) printf(" level=%u\n", isr->level); kdebug_secasindex(&isr->saidx); - if (isr->sav != NULL) - kdebug_secasv(isr->sav); } printf(" }\n"); } @@ -604,7 +605,7 @@ kdebug_secreplay(rpl) return; } - printf("\n bitmap { "); + printf("\n bitmap { "); for (len = 0; len < rpl->wsize; len++) { for (l = 7; l >= 0; l--) @@ -621,7 +622,7 @@ kdebug_mbufhdr(m) { /* sanity check */ if (m == NULL) - panic("debug_mbufhdr: NULL pointer was passed.\n"); + return; printf("mbuf(%p){ m_next:%p m_nextpkt:%p m_data:%p " "m_len:%d m_type:0x%02x m_flags:0x%02x }\n", @@ -633,14 +634,12 @@ kdebug_mbufhdr(m) m->m_pkthdr.len, m->m_pkthdr.rcvif); } -#ifdef __FreeBSD__ if (m->m_flags & M_EXT) { printf(" m_ext{ ext_buf:%p ext_free:%p " "ext_size:%u ext_ref:%p }\n", m->m_ext.ext_buf, m->m_ext.ext_free, - m->m_ext.ext_size, m->m_ext.ext_ref); + m->m_ext.ext_size, m->m_ext.ext_refs); } -#endif return; } @@ -652,19 +651,20 @@ kdebug_mbuf(m0) struct mbuf *m = m0; int i, j; - kdebug_mbufhdr(m); - printf(" m_data=\n"); for (j = 0; m; m = m->m_next) { + kdebug_mbufhdr(m); + printf(" m_data:\n"); for (i = 0; i < m->m_len; i++) { - if (i != 0 && i % 32 == 0) printf("\n"); - if (i % 4 == 0) printf(" "); + if (i && i % 32 == 0) + printf("\n"); + if (i % 4 == 0) + printf(" "); printf("%02x", mtod(m, u_char *)[i]); j++; } + printf("\n"); } - printf("\n"); - return; } #endif /* KERNEL */ @@ -673,31 +673,41 @@ void kdebug_sockaddr(addr) struct sockaddr *addr; { + struct sockaddr_in *sin4; +#ifdef INET6 + struct sockaddr_in6 *sin6; +#endif + /* sanity check */ if (addr == NULL) panic("kdebug_sockaddr: NULL pointer was passed.\n"); /* NOTE: We deal with port number as host byte order. */ - printf("sockaddr{ len=%u family=%u port=%u\n", - addr->sa_len, addr->sa_family, ntohs(_INPORTBYSA(addr))); + printf("sockaddr{ len=%u family=%u", addr->sa_len, addr->sa_family); + switch (addr->sa_family) { + case AF_INET: + sin4 = (struct sockaddr_in *)addr; + printf(" port=%u\n", ntohs(sin4->sin_port)); + ipsec_hexdump((caddr_t)&sin4->sin_addr, sizeof(sin4->sin_addr)); + break; #ifdef INET6 - if (addr->sa_family == PF_INET6) { - struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)addr; + case AF_INET6: + sin6 = (struct sockaddr_in6 *)addr; + printf(" port=%u\n", ntohs(sin6->sin6_port)); printf(" flowinfo=0x%08x, scope_id=0x%08x\n", - in6->sin6_flowinfo, in6->sin6_scope_id); - } + sin6->sin6_flowinfo, sin6->sin6_scope_id); + ipsec_hexdump((caddr_t)&sin6->sin6_addr, + sizeof(sin6->sin6_addr)); + break; #endif - - ipsec_hexdump(_INADDRBYSA(addr), _INALENBYAF(addr->sa_family)); + } printf(" }\n"); return; } -#endif /* !defined(KERNEL) || (defined(KERNEL) && defined(IPSEC_DEBUG)) */ - void ipsec_bindump(buf, len) caddr_t buf; @@ -731,3 +741,4 @@ ipsec_hexdump(buf, len) return; } +#endif /* !defined(KERNEL) || (defined(KERNEL) && defined(IPSEC_DEBUG)) */