/*
* 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:
* 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
* 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 <sys/types.h>
#include <sys/param.h>
-#if defined(KERNEL)
+#ifdef KERNEL
#include <sys/systm.h>
#include <sys/mbuf.h>
+#include <sys/queue.h>
#endif
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet6/ipsec.h>
-#if !defined(KERNEL)
+#ifndef KERNEL
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
-#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_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 *));
#ifdef KERNEL
static void kdebug_secreplay __P((struct secreplay *));
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));
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);
{
struct sadb_ident *id = (struct sadb_ident *)ext;
int len;
- union sadb_x_ident_id *aid;
/* sanity check */
if (ext == NULL)
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);
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 reserved3=%u }\n",
+ sa2->sadb_x_sa2_reserved1, sa2->sadb_x_sa2_reserved1,
+ sa2->sadb_x_sa2_reserved1);
+
+ return;
+}
+
void
kdebug_sadb_x_policy(ext)
struct sadb_ext *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;
return;
}
- printf("\n bitmap { ");
+ printf("\n bitmap { ");
for (len = 0; len < rpl->wsize; len++) {
for (l = 7; l >= 0; l--)
{
/* 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",
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;
}
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 */
kdebug_sockaddr(addr)
struct sockaddr *addr;
{
+ struct sockaddr_in *sin;
+#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:
+ sin = (struct sockaddr_in *)addr;
+ printf(" port=%u\n", ntohs(sin->sin_port));
+ ipsec_hexdump((caddr_t)&sin->sin_addr, sizeof(sin->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;
return;
}
+#endif /* !defined(KERNEL) || (defined(KERNEL) && defined(IPSEC_DEBUG)) */