summaryrefslogtreecommitdiffstats
path: root/sys/netkey/key_debug.c
diff options
context:
space:
mode:
authoritojun <itojun@FreeBSD.org>1998-02-27 10:02:49 +0000
committeritojun <itojun@FreeBSD.org>1998-02-27 10:02:49 +0000
commit74e335fcf267f7e61d607cd06a428f6046b70006 (patch)
tree693f15d89b842a20863f4d1ed8fc8c0e0c0f9443 /sys/netkey/key_debug.c
parent68d701fa4292eab00ec75bf375116d55009499b5 (diff)
downloadFreeBSD-src-74e335fcf267f7e61d607cd06a428f6046b70006.zip
FreeBSD-src-74e335fcf267f7e61d607cd06a428f6046b70006.tar.gz
make sys/netkey/key{,_debug}.c compile. I believe it works but not tested.
I'll polish the code later on.
Diffstat (limited to 'sys/netkey/key_debug.c')
-rw-r--r--sys/netkey/key_debug.c226
1 files changed, 128 insertions, 98 deletions
diff --git a/sys/netkey/key_debug.c b/sys/netkey/key_debug.c
index c928c84..8819e09 100644
--- a/sys/netkey/key_debug.c
+++ b/sys/netkey/key_debug.c
@@ -1,4 +1,7 @@
/*
+ * modified by Jun-ichiro itojun Itoh <itojun@itojun.org>, 1997
+ */
+/*
* in6_debug.c -- Insipired by Craig Metz's Net/2 in6_debug.c, but
* not quite as heavyweight (initially, anyway).
*
@@ -68,17 +71,25 @@ Research Laboratory (NRL).
#define INET6_DEBUG_C
-#include <netkey/osdep_44bsd.h>
+#include "opt_key.h"
+
+#ifdef KEY
+#ifdef KEY_DEBUG /*wraps the whole code*/
+
+/*#include <netkey/osdep_44bsd.h>*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/mbuf.h>
+#include <sys/systm.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/route.h>
+#include <netinet/in.h>
+
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/in_pcb.h>
@@ -86,9 +97,10 @@ Research Laboratory (NRL).
#ifdef INET6
#include <netinet6/in6.h>
#include <netinet6/in6_var.h>
-#include <netinet6/ipv6.h>
-#include <netinet6/ipv6_var.h>
-#include <netinet6/ipv6_icmp.h>
+#include <netinet6/ip6.h>
+#include <netinet6/ip6_var.h>
+#include <netinet6/icmp6.h>
+#include <netinet6/in6_pcb.h>
#else /* INET6 */
#if 0
#include "in6_types.h"
@@ -100,6 +112,7 @@ Research Laboratory (NRL).
#ifdef KEY_DEBUG
#include <netkey/key.h>
+#include <netkey/key_debug.h>
#endif /* KEY_DEBUG */
#ifdef IPSEC_DEBUG
#include <netsec/ipsec.h>
@@ -109,11 +122,6 @@ Research Laboratory (NRL).
#include <netinet6/in6_debug.h>
#endif
-#ifndef DEFARGS
-#define DEFARGS(arglist, args) arglist args;
-#define AND ;
-#endif /* DEFARGS */
-
/*
* Globals
*/
@@ -126,7 +134,7 @@ unsigned int in6_debug_level = IDL_FINISHED + 1; /* 0 is no debugging */
* Functions and macros.
*/
-void in6_debug_init DEFARGS((), void)
+void in6_debug_init()
{
/* For now, nothing. */
}
@@ -141,14 +149,14 @@ void in6_debug_init DEFARGS((), void)
/*----------------------------------------------------------------------
* Dump an IPv6 address. Don't compress 0's out because of debugging.
----------------------------------------------------------------------*/
-void dump_in_addr6 DEFARGS((in_addr6),
- struct in_addr6 *in_addr6)
+void dump_in6_addr(in6_addr)
+ struct in6_addr *in6_addr;
{
- u_short *shorts = (u_short *)in_addr6;
+ u_short *shorts = (u_short *)in6_addr;
int i = 0;
- if (!in_addr6) {
- printf("Dereference a NULL in_addr6? I don't think so.\n");
+ if (!in6_addr) {
+ printf("Dereference a NULL in6_addr? I don't think so.\n");
return;
}
@@ -162,8 +170,8 @@ void dump_in_addr6 DEFARGS((in_addr6),
/*----------------------------------------------------------------------
* Dump and IPv4 address in x.x.x.x form.
----------------------------------------------------------------------*/
-void dump_in_addr DEFARGS((in_addr),
- struct in_addr *in_addr)
+void dump_in_addr(in_addr)
+ struct in_addr *in_addr;
{
u_char *chars = (u_char *)in_addr;
int i = 0;
@@ -182,8 +190,8 @@ void dump_in_addr DEFARGS((in_addr),
/*----------------------------------------------------------------------
* Dump an IPv6 socket address.
----------------------------------------------------------------------*/
-void dump_sockaddr_in6 DEFARGS((sin6),
- struct sockaddr_in6 *sin6)
+void dump_sockaddr_in6(sin6)
+ struct sockaddr_in6 *sin6;
{
if (!sin6) {
printf("Dereference a NULL sockaddr_in6? I don't think so.\n");
@@ -195,15 +203,15 @@ void dump_sockaddr_in6 DEFARGS((sin6),
htons(sin6->sin6_port));
printf("sin6_flowinfo = 0x%x\n",sin6->sin6_flowinfo);
printf("sin6_addr = ");
- dump_in_addr6(&sin6->sin6_addr);
+ dump_in6_addr(&sin6->sin6_addr);
}
#endif /* INET6 */
/*----------------------------------------------------------------------
* Dump an IPv4 socket address.
----------------------------------------------------------------------*/
-void dump_sockaddr_in DEFARGS((sin),
- struct sockaddr_in *sin)
+void dump_sockaddr_in(sin)
+ struct sockaddr_in *sin;
{
int i;
@@ -230,8 +238,8 @@ void dump_sockaddr_in DEFARGS((sin),
* Dump a generic socket address. Use if no family-specific routine is
* available.
----------------------------------------------------------------------*/
-void dump_sockaddr DEFARGS((sa),
-SOCKADDR *sa)
+void dump_sockaddr(sa)
+ struct sockaddr *sa;
{
if (!sa) {
printf("Dereference a NULL sockaddr? I don't think so.\n");
@@ -257,8 +265,8 @@ SOCKADDR *sa)
* Dump a link-layer socket address. (Not that there are user-level link
* layer sockets, but there are plenty of link-layer addresses in the kernel.)
----------------------------------------------------------------------*/
-void dump_sockaddr_dl DEFARGS((sdl),
- struct sockaddr_dl *sdl)
+void dump_sockaddr_dl(sdl)
+ struct sockaddr_dl *sdl;
{
char buf[256];
@@ -299,8 +307,8 @@ void dump_sockaddr_dl DEFARGS((sdl),
/*----------------------------------------------------------------------
* Dump a socket address, calling a family-specific routine if available.
----------------------------------------------------------------------*/
-void dump_smart_sockaddr DEFARGS((sa),
-SOCKADDR *sa)
+void dump_smart_sockaddr(sa)
+ struct sockaddr *sa;
{
DPRINTF(IDL_MAJOR_EVENT, ("Entering dump_smart_sockaddr\n"));
if (!sa) {
@@ -331,30 +339,30 @@ SOCKADDR *sa)
/*----------------------------------------------------------------------
* Dump an IPv6 header.
----------------------------------------------------------------------*/
-void dump_ipv6 DEFARGS((ipv6),
- struct ipv6 *ipv6)
+void dump_ipv6(ip6)
+ struct ip6 *ip6;
{
- if (!ipv6) {
- printf("Dereference a NULL ipv6? I don't think so.\n");
+ if (!ip6) {
+ printf("Dereference a NULL ip6? I don't think so.\n");
return;
}
- printf("Vers & flow label (conv to host order) 0x%x\n",
- htonl(ipv6->ipv6_versfl));
+ printf("Vers = %d, pri = 0x%x, flow label = 0x%x\n",
+ ip6->ip6_v, ip6->ip6_pri, htonl(ip6->ip6_flbl));
printf("Length (conv) = %d, nexthdr = %d, hoplimit = %d.\n",
- htons(ipv6->ipv6_length),ipv6->ipv6_nexthdr,ipv6->ipv6_hoplimit);
+ htons(ip6->ip6_len),ip6->ip6_nh,ip6->ip6_hlim);
printf("Src: ");
- dump_in_addr6(&ipv6->ipv6_src);
+ dump_in6_addr(&ip6->ip6_src);
printf("Dst: ");
- dump_in_addr6(&ipv6->ipv6_dst);
+ dump_in6_addr(&ip6->ip6_dst);
}
/*----------------------------------------------------------------------
* Dump an ICMPv6 header. This function is not very smart beyond the
* type, code, and checksum.
----------------------------------------------------------------------*/
-dump_ipv6_icmp DEFARGS((icp),
- struct ipv6_icmp *icp)
+void dump_ipv6_icmp(icp)
+ struct icmp6 *icp;
{
int i;
@@ -363,12 +371,9 @@ dump_ipv6_icmp DEFARGS((icp),
return;
}
- printf("type %d, code %d, cksum (conv) = 0x%x\n",icp->icmp_type,
- icp->icmp_code,htons(icp->icmp_cksum));
- printf("First four bytes: 0x%x",htonl(icp->icmp_unused));
- printf("Next four bytes: 0x");
- for (i=0;i<4;i++)
- printf("%x",icp->icmp_echodata[i]);
+ printf("type %d, code %d, cksum (conv) = 0x%x\n",icp->icmp6_type,
+ icp->icmp6_code,htons(icp->icmp6_cksum));
+ printf("First four bytes: 0x%x",htonl(icp->icmp6_flags));
printf("\n");
}
#endif /* INET6 */
@@ -376,8 +381,8 @@ dump_ipv6_icmp DEFARGS((icp),
/*----------------------------------------------------------------------
* Dump only the header fields of a single mbuf.
----------------------------------------------------------------------*/
-void dump_mbuf_hdr DEFARGS((m),
- struct mbuf *m)
+void dump_mbuf_hdr(m)
+ struct mbuf *m;
{
if (!m) {
printf("Dereference a NULL mbuf? I don't think so.\n");
@@ -399,8 +404,8 @@ void dump_mbuf_hdr DEFARGS((m),
/*----------------------------------------------------------------------
* Dump the entire contents of a single mbuf.
----------------------------------------------------------------------*/
-void dump_mbuf DEFARGS((m),
- struct mbuf *m)
+void dump_mbuf(m)
+ struct mbuf *m;
{
int i;
@@ -415,8 +420,8 @@ void dump_mbuf DEFARGS((m),
* Dump the contents of an mbuf chain. (WARNING: Lots of text may
* result.
----------------------------------------------------------------------*/
-void dump_mchain DEFARGS((m),
- struct mbuf *m)
+void dump_mchain(m)
+ struct mbuf *m;
{
struct mbuf *walker;
int i;
@@ -429,8 +434,8 @@ void dump_mchain DEFARGS((m),
/*----------------------------------------------------------------------
* Dump an mbuf chain's data in a format similar to tcpdump(8).
----------------------------------------------------------------------*/
-void dump_tcpdump DEFARGS((m),
- struct mbuf *m)
+void dump_tcpdump(m)
+ struct mbuf *m;
{
struct mbuf *walker;
int i, j, count;
@@ -441,18 +446,18 @@ void dump_tcpdump DEFARGS((m),
printf("\n\t\t\t");
if (!(count % 2))
printf(" ");
- printf("%02x", (u_int8)(m->m_data[j]));
+ printf("%02x", (u_int8_t)(m->m_data[j]));
}
}
}
-#ifdef INET6
+#if 0
/*----------------------------------------------------------------------
* Dump an IPv6 header index table, which is terminated by an entry with
* a NULL mbuf pointer.
----------------------------------------------------------------------*/
-void dump_ihitab DEFARGS((ihi),
- struct in6_hdrindex *ihi)
+void dump_ihitab(ihi)
+ struct in6_hdrindex *ihi;
{
int i=0;
@@ -474,8 +479,8 @@ void dump_ihitab DEFARGS((ihi),
/*----------------------------------------------------------------------
* Dump an interface address.
----------------------------------------------------------------------*/
-void dump_ifa DEFARGS((ifa),
- struct ifaddr *ifa)
+void dump_ifa(ifa)
+ struct ifaddr *ifa;
{
if (ifa == NULL)
{
@@ -492,8 +497,8 @@ void dump_ifa DEFARGS((ifa),
/*----------------------------------------------------------------------
* Dump an interface structure.
----------------------------------------------------------------------*/
-void dump_ifp DEFARGS((ifp),
- struct ifnet *ifp)
+void dump_ifp(ifp)
+ struct ifnet *ifp;
{
if (!ifp) {
printf("Dereference a NULL ifnet/ifp? I don't think so.\n");
@@ -508,8 +513,8 @@ void dump_ifp DEFARGS((ifp),
/*----------------------------------------------------------------------
* Dump a route structure (sockaddr/rtentry pair).
----------------------------------------------------------------------*/
-void dump_route DEFARGS((ro),
- struct route *ro)
+void dump_route(ro)
+ struct route *ro;
{
if (!ro) {
printf("Dereference a NULL route? I don't think so.\n");
@@ -523,8 +528,8 @@ void dump_route DEFARGS((ro),
/*----------------------------------------------------------------------
* Dump a routing entry.
----------------------------------------------------------------------*/
-void dump_rtentry DEFARGS((rt),
- struct rtentry *rt)
+void dump_rtentry(rt)
+ struct rtentry *rt;
{
if (!rt) {
printf("Dereference a NULL rtentry? I don't think so.\n");
@@ -546,36 +551,27 @@ void dump_rtentry DEFARGS((rt),
}
/*----------------------------------------------------------------------
- * Dump an Internet (v4/v6) protocol control block.
+ * Dump an Internet v4 protocol control block.
----------------------------------------------------------------------*/
-void dump_inpcb DEFARGS((inp),
- struct inpcb *inp)
+void dump_inpcb(inp)
+ struct inpcb *inp;
{
if (!inp) {
printf("Dereference a NULL inpcb? I don't think so.\n");
return;
}
- printf("inp_next = 0x%x, inp_prev = 0x%x, inp_head = 0x%x.\n",inp->inp_next,
- inp->inp_prev, inp->inp_head);
+#if 0
+ printf("inp_next = 0x%x, inp_prev = 0x%x, inp_head = 0x%x.\n",
+ inp->inp_next, inp->inp_prev, inp->inp_head);
+#endif
printf("inp_socket = 0x%x, inp_ppcb\n",inp->inp_socket,inp->inp_ppcb);
-#ifdef INET6
- printf("faddr, faddr6:\n");
- dump_in_addr(&inp->inp_faddr); dump_in_addr6(&inp->inp_faddr6);
- printf("laddr, laddr6:\n");
- dump_in_addr(&inp->inp_laddr); dump_in_addr6(&inp->inp_laddr6);
-#else /* INET6 */
printf("faddr:\n");
dump_in_addr(&inp->inp_faddr);
printf("laddr:\n");
dump_in_addr(&inp->inp_laddr);
-#endif /* INET6 */
printf("inp_route: ");
dump_route(&inp->inp_route);
-#ifdef INET6
- printf("inp_ipv6:");
- dump_ipv6(&inp->inp_ipv6);
-#endif /* INET6 */
printf("inp_ip:");
printf("<Coming soon.>\n");
printf("inp_options = 0x%x, inp_moptions{6,} = 0x%x,\n",inp->inp_options,
@@ -586,10 +582,41 @@ void dump_inpcb DEFARGS((inp),
#ifdef INET6
/*----------------------------------------------------------------------
+ * Dump an Internet v6 protocol control block.
+ ----------------------------------------------------------------------*/
+void dump_in6pcb(in6p)
+ struct in6pcb *in6p;
+{
+ if (!in6p) {
+ printf("Dereference a NULL in6pcb? I don't think so.\n");
+ return;
+ }
+
+ printf("in6p_next = 0x%x, in6p_prev = 0x%x, in6p_head = 0x%x.\n",
+ in6p->in6p_next, in6p->in6p_prev, in6p->in6p_head);
+ printf("in6p_socket = 0x%x, in6p_ppcb\n",
+ in6p->in6p_socket, in6p->in6p_ppcb);
+ printf("faddr:\n");
+ dump_in6_addr(&in6p->in6p_faddr);
+ printf("laddr:\n");
+ dump_in6_addr(&in6p->in6p_laddr);
+ printf("in6p_route: ");
+ dump_route(&in6p->in6p_route);
+ printf("in6p_ip6:");
+ dump_ipv6(&in6p->in6p_ip6);
+ printf("in6p_options = 0x%x, in6p_moptions{6,} = 0x%x,\n",
+ in6p->in6p_options, in6p->in6p_moptions);
+ printf("in6p_flags = 0x%x, in6p_fport = %d, in6p_lport = %d.\n",
+ (unsigned)in6p->in6p_flags, in6p->in6p_fport, in6p->in6p_lport);
+}
+#endif /*INET6*/
+
+#if 0
+/*----------------------------------------------------------------------
* Dump an IPv6 discovery queue structure.
----------------------------------------------------------------------*/
-void dump_discq DEFARGS((dq),
- struct discq *dq)
+void dump_discq(dq)
+ struct discq *dq;
{
if (!dq) {
printf("Dereference a NULL discq? I don't think so.\n");
@@ -607,15 +634,15 @@ void dump_discq DEFARGS((dq),
/*----------------------------------------------------------------------
* Dump a data buffer
----------------------------------------------------------------------*/
-void dump_buf DEFARGS((buf, len),
- char *buf AND
- int len)
+void dump_buf(buf, len)
+ char *buf;
+ int len;
{
int i;
printf("buf=0x%x len=%d:\n", (unsigned int)buf, len);
for (i = 0; i < len; i++) {
- printf("0x%x ", (u_int8)*(buf+i));
+ printf("0x%x ", (u_int8_t)*(buf+i));
}
printf("\n");
}
@@ -624,8 +651,8 @@ void dump_buf DEFARGS((buf, len),
/*----------------------------------------------------------------------
* Dump a key_tblnode structrue
----------------------------------------------------------------------*/
-void dump_keytblnode DEFARGS((ktblnode),
- struct key_tblnode *ktblnode)
+void dump_keytblnode(ktblnode)
+ struct key_tblnode *ktblnode;
{
if (!ktblnode) {
printf("NULL key table node pointer!\n");
@@ -639,10 +666,10 @@ void dump_keytblnode DEFARGS((ktblnode),
/*----------------------------------------------------------------------
* Dump an ipsec_assoc structure
----------------------------------------------------------------------*/
-void dump_secassoc DEFARGS((seca),
-struct key_secassoc *seca)
+void dump_secassoc(seca)
+ struct key_secassoc *seca;
{
- u_int8 *p;
+ u_int8_t *p;
int i;
if (seca) {
@@ -656,11 +683,11 @@ struct key_secassoc *seca)
printf("secassoc_algorithm=%u ", seca->algorithm);
printf("secassoc_lifetype=%u\n", seca->lifetype);
printf("secassoc_iv=0x%x:\n", (unsigned int)seca->iv);
- p = (u_int8 *)(seca->iv);
+ p = (u_int8_t *)(seca->iv);
for (i = 0 ; i < seca->ivlen; i++)
printf("0x%x ", *(p + i));
printf("secassoc_key=0x%x:\n", (unsigned int)seca->key);
- p = (u_int8 *)(seca->key);
+ p = (u_int8_t *)(seca->key);
for (i = 0 ; i < seca->keylen; i++)
printf("0x%x ", *(p + i));
printf("secassoc_lifetime1=%u ", (unsigned int)seca->lifetime1);
@@ -676,8 +703,8 @@ struct key_secassoc *seca)
/*----------------------------------------------------------------------
* Dump a key_msghdr structure
----------------------------------------------------------------------*/
-void dump_keymsghdr DEFARGS((km),
- struct key_msghdr *km)
+void dump_keymsghdr(km)
+ struct key_msghdr *km;
{
if (km) {
printf("key_msglen=%d\n", km->key_msglen);
@@ -704,8 +731,8 @@ void dump_keymsghdr DEFARGS((km),
/*----------------------------------------------------------------------
* Dump a key_msgdata structure
----------------------------------------------------------------------*/
-void dump_keymsginfo DEFARGS((kp),
- struct key_msgdata *kp)
+void dump_keymsginfo(kp)
+ struct key_msgdata *kp;
{
int i;
@@ -728,3 +755,6 @@ void dump_keymsginfo DEFARGS((kp),
} else
printf("key_msgdata point is NULL!\n");
}
+
+#endif /*KEY_DEBUG*/
+#endif /*KEY*/
OpenPOWER on IntegriCloud