]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/netkey/key_debug.c
xnu-4903.221.2.tar.gz
[apple/xnu.git] / bsd / netkey / key_debug.c
index 2366598b3f8a6737ea914447f3f39cc915a1b0fb..f1be1810444ff21bea28c378935b04ec33f9b6e2 100644 (file)
@@ -1,3 +1,6 @@
+/*     $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.
 
 #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_x_sa2 __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
@@ -146,6 +149,12 @@ 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;
                default:
                        printf("kdebug_sadb: invalid ext_type %u was passed.\n",
                            ext->sadb_ext_type);
@@ -194,15 +203,15 @@ kdebug_sadb_prop(ext)
                        "soft_bytes=%lu hard_bytes=%lu\n",
                        comb->sadb_comb_soft_allocations,
                        comb->sadb_comb_hard_allocations,
-                       (unsigned long)comb->sadb_comb_soft_bytes,
-                       (unsigned long)comb->sadb_comb_hard_bytes);
+                       (u_int32_t)comb->sadb_comb_soft_bytes,
+                       (u_int32_t)comb->sadb_comb_hard_bytes);
 
                printf("  soft_alloc=%lu hard_alloc=%lu "
                        "soft_bytes=%lu hard_bytes=%lu }\n",
-                       (unsigned long)comb->sadb_comb_soft_addtime,
-                       (unsigned long)comb->sadb_comb_hard_addtime,
-                       (unsigned long)comb->sadb_comb_soft_usetime,
-                       (unsigned long)comb->sadb_comb_hard_usetime);
+                       (u_int32_t)comb->sadb_comb_soft_addtime,
+                       (u_int32_t)comb->sadb_comb_hard_addtime,
+                       (u_int32_t)comb->sadb_comb_soft_usetime,
+                       (u_int32_t)comb->sadb_comb_hard_usetime);
                comb++;
        }
        printf("}\n");
@@ -227,7 +236,7 @@ kdebug_sadb_identity(ext)
        switch (id->sadb_ident_type) {
        default:
                printf(" type=%d id=%lu",
-                       id->sadb_ident_type, (u_long)id->sadb_ident_id);
+                       id->sadb_ident_type, (u_int32_t)id->sadb_ident_id);
                if (len) {
 #ifdef KERNEL
                        ipsec_hexdump((caddr_t)(id + 1), len); /*XXX cast ?*/
@@ -379,9 +388,50 @@ kdebug_sadb_x_sa2(ext)
 
        printf("sadb_x_sa2{ mode=%u reqid=%u\n",
            sa2->sadb_x_sa2_mode, sa2->sadb_x_sa2_reqid);
-       printf("  reserved1=%u reserved2=%u reserved3=%u }\n",
-           sa2->sadb_x_sa2_reserved1, sa2->sadb_x_sa2_reserved1,
-           sa2->sadb_x_sa2_reserved1);
+       printf("  reserved1=%u reserved2=%u sequence=%u }\n",
+           sa2->sadb_x_sa2_reserved1, sa2->sadb_x_sa2_reserved2,
+           sa2->sadb_x_sa2_sequence);
+
+       return;
+}
+
+static void
+kdebug_sadb_session_id(ext)
+       struct sadb_ext *ext;
+{
+       struct sadb_session_id *p = (__typeof__(p))ext;
+
+       /* sanity check */
+       if (ext == NULL)
+               panic("kdebug_sadb_session_id: NULL pointer was passed.\n");
+
+       printf("sadb_session_id{ id0=%llx, id1=%llx}\n",
+               p->sadb_session_id_v[0],
+               p->sadb_session_id_v[1]);
+
+       return;
+}
+
+static void
+kdebug_sadb_sastat(ext)
+       struct sadb_ext *ext;
+{
+       struct sadb_sastat *p = (__typeof__(p))ext;
+       struct sastat      *stats;
+       int    i;
+
+       /* sanity check */
+       if (ext == NULL)
+               panic("kdebug_sadb_sastat: NULL pointer was passed.\n");
+
+       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");
 
        return;
 }
@@ -467,6 +517,7 @@ kdebug_secpolicy(sp)
 
        switch (sp->policy) {
        case IPSEC_POLICY_DISCARD:
+       case IPSEC_POLICY_GENERATE:
                printf("  type=discard }\n");
                break;
        case IPSEC_POLICY_NONE:
@@ -480,8 +531,6 @@ kdebug_secpolicy(sp)
                        printf("  level=%u\n", isr->level);
                        kdebug_secasindex(&isr->saidx);
 
-                       if (isr->sav != NULL)
-                               kdebug_secasv(isr->sav);
                }
                printf("  }\n");
            }
@@ -509,8 +558,9 @@ kdebug_secpolicyindex(spidx)
        if (spidx == NULL)
                panic("kdebug_secpolicyindex: NULL pointer was passed.\n");
 
-       printf("secpolicyindex{ dir=%u prefs=%u prefd=%u ul_proto=%u\n",
-               spidx->dir, spidx->prefs, spidx->prefd, spidx->ul_proto);
+       printf("secpolicyindex{ dir=%u prefs=%u prefd=%u ul_proto=%u internal_if=%s\n",
+               spidx->dir, spidx->prefs, spidx->prefd, spidx->ul_proto,
+           (spidx->internal_if) ? spidx->internal_if->if_xname : "N/A");
 
        ipsec_hexdump((caddr_t)&spidx->src,
                ((struct sockaddr *)&spidx->src)->sa_len);
@@ -622,21 +672,27 @@ kdebug_mbufhdr(m)
        if (m == NULL)
                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",
-               m, m->m_next, m->m_nextpkt, m->m_data,
-               m->m_len, m->m_type, m->m_flags);
+       printf("mbuf(0x%llx){ m_next:0x%llx m_nextpkt:0x%llx m_data:0x%llx "
+           "m_len:%d m_type:0x%02x m_flags:0x%02x }\n",
+           (uint64_t)VM_KERNEL_ADDRPERM(m),
+           (uint64_t)VM_KERNEL_ADDRPERM(m->m_next),
+           (uint64_t)VM_KERNEL_ADDRPERM(m->m_nextpkt),
+           (uint64_t)VM_KERNEL_ADDRPERM(m->m_data),
+           m->m_len, m->m_type, m->m_flags);
 
        if (m->m_flags & M_PKTHDR) {
-               printf("  m_pkthdr{ len:%d rcvif:%p }\n",
-                   m->m_pkthdr.len, m->m_pkthdr.rcvif);
+               printf("  m_pkthdr{ len:%d rcvif:0x%llx }\n",
+                   m->m_pkthdr.len,
+                   (uint64_t)VM_KERNEL_ADDRPERM(m->m_pkthdr.rcvif));
        }
 
        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_refs);
+               printf("  m_ext{ ext_buf:0x%llx ext_free:0x%llx "
+                      "ext_size:%u ext_ref:0x%llx }\n",
+                       (uint64_t)VM_KERNEL_ADDRPERM(m->m_ext.ext_buf),
+                       (uint64_t)VM_KERNEL_ADDRPERM(m_get_ext_free(m)),
+                       m->m_ext.ext_size,
+                       (uint64_t)VM_KERNEL_ADDRPERM(m_get_rfa(m));
        }
 
        return;
@@ -671,7 +727,7 @@ void
 kdebug_sockaddr(addr)
        struct sockaddr *addr;
 {
-       struct sockaddr_in *sin;
+       struct sockaddr_in *sin4;
 #ifdef INET6
        struct sockaddr_in6 *sin6;
 #endif
@@ -685,9 +741,9 @@ kdebug_sockaddr(addr)
 
        switch (addr->sa_family) {
        case AF_INET:
-               sin = (struct sockaddr_in *)addr;
-               printf(" port=%u\n", ntohs(sin->sin_port));
-               ipsec_hexdump((caddr_t)&sin->sin_addr, sizeof(sin->sin_addr));
+               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
        case AF_INET6: