Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys remove too much portability code in KAME, to improve rea...
details: https://anonhg.NetBSD.org/src/rev/c71af99edfc7
branches: trunk
changeset: 480190:c71af99edfc7
user: itojun <itojun%NetBSD.org@localhost>
date: Thu Jan 06 07:31:07 2000 +0000
description:
remove too much portability code in KAME, to improve readability.
diffstat:
sys/netinet/in_gif.c | 19 +----
sys/netinet/ip_ecn.c | 4 +-
sys/netinet6/ah.h | 4 +-
sys/netinet6/ah_core.c | 211 +----------------------------------------------
sys/netinet6/ah_input.c | 18 +---
sys/netinet6/ah_output.c | 6 +-
sys/netinet6/dest6.c | 4 +-
sys/netinet6/esp.h | 4 +-
8 files changed, 8 insertions(+), 262 deletions(-)
diffs (truncated from 758 to 300 lines):
diff -r 0dcc7f887cf9 -r c71af99edfc7 sys/netinet/in_gif.c
--- a/sys/netinet/in_gif.c Thu Jan 06 06:41:18 2000 +0000
+++ b/sys/netinet/in_gif.c Thu Jan 06 07:31:07 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in_gif.c,v 1.7 1999/12/13 15:17:20 itojun Exp $ */
+/* $NetBSD: in_gif.c,v 1.8 2000/01/06 07:31:07 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -33,15 +33,8 @@
* in_gif.c
*/
-#ifdef __FreeBSD__
-#include "opt_mrouting.h"
-#endif
-#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(__NetBSD__)
#include "opt_inet.h"
-#ifdef __NetBSD__ /*XXX*/
#include "opt_ipsec.h"
-#endif
-#endif
#include <sys/param.h>
#include <sys/systm.h>
@@ -49,13 +42,7 @@
#include <sys/sockio.h>
#include <sys/mbuf.h>
#include <sys/errno.h>
-#ifdef __FreeBSD__
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#endif
-#if !defined(__FreeBSD__) || __FreeBSD__ < 3
#include <sys/ioctl.h>
-#endif
#include <sys/protosw.h>
#include <net/if.h>
@@ -90,10 +77,6 @@
#else
int ip_gif_ttl = 0;
#endif
-#ifdef __FreeBSD__
-SYSCTL_INT(_net_inet_ip, IPCTL_GIF_TTL, gifttl, CTLFLAG_RW,
- &ip_gif_ttl, 0, "");
-#endif
int
in_gif_output(ifp, family, m, rt)
diff -r 0dcc7f887cf9 -r c71af99edfc7 sys/netinet/ip_ecn.c
--- a/sys/netinet/ip_ecn.c Thu Jan 06 06:41:18 2000 +0000
+++ b/sys/netinet/ip_ecn.c Thu Jan 06 07:31:07 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_ecn.c,v 1.7 1999/12/12 16:19:40 itojun Exp $ */
+/* $NetBSD: ip_ecn.c,v 1.8 2000/01/06 07:31:08 itojun Exp $ */
/*
* Copyright (C) 1999 WIDE Project.
@@ -35,9 +35,7 @@
* http://www.aciri.org/floyd/papers/draft-ipsec-ecn-00.txt
*/
-#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(__NetBSD__)
#include "opt_inet.h"
-#endif
#include <sys/param.h>
#include <sys/systm.h>
diff -r 0dcc7f887cf9 -r c71af99edfc7 sys/netinet6/ah.h
--- a/sys/netinet6/ah.h Thu Jan 06 06:41:18 2000 +0000
+++ b/sys/netinet6/ah.h Thu Jan 06 07:31:07 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ah.h,v 1.6 1999/12/02 05:08:16 itojun Exp $ */
+/* $NetBSD: ah.h,v 1.7 2000/01/06 07:31:10 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -36,11 +36,9 @@
#ifndef _NETINET6_AH_H_
#define _NETINET6_AH_H_
-#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(__NetBSD__)
#if defined(_KERNEL) && !defined(_LKM)
#include "opt_inet.h"
#endif
-#endif
#include <netkey/keydb.h> /* for struct secas */
diff -r 0dcc7f887cf9 -r c71af99edfc7 sys/netinet6/ah_core.c
--- a/sys/netinet6/ah_core.c Thu Jan 06 06:41:18 2000 +0000
+++ b/sys/netinet6/ah_core.c Thu Jan 06 07:31:07 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ah_core.c,v 1.12 1999/12/15 06:28:44 itojun Exp $ */
+/* $NetBSD: ah_core.c,v 1.13 2000/01/06 07:31:10 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -33,21 +33,14 @@
* RFC1826/2402 authentication header.
*/
-#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(__NetBSD__)
#include "opt_inet.h"
-#ifdef __NetBSD__ /*XXX*/
#include "opt_ipsec.h"
-#endif
-#endif
/* Some of operating systems have standard crypto checksum library */
#ifdef __NetBSD__
#define HAVE_MD5
#define HAVE_SHA1
#endif
-#ifdef __FreeBSD__
-#define HAVE_MD5
-#endif
#include <sys/param.h>
#include <sys/systm.h>
@@ -72,9 +65,7 @@
#ifdef INET6
#include <netinet6/ip6.h>
-#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3)
#include <netinet6/in6_pcb.h>
-#endif
#include <netinet6/ip6_var.h>
#include <netinet6/icmp6.h>
#endif
@@ -86,17 +77,9 @@
#endif
#include <netkey/keyv2.h>
#include <netkey/keydb.h>
-#ifdef HAVE_MD5
#include <sys/md5.h>
-#else
-#include <crypto/md5.h>
-#endif
-#ifdef HAVE_SHA1
#include <sys/sha1.h>
#define SHA1_RESULTLEN 20
-#else
-#include <crypto/sha1.h>
-#endif
#define HMACSIZE 16
@@ -225,24 +208,14 @@
panic("ah_keyed_md5_init: what?");
state->sa = sa;
-#ifdef HAVE_MD5
state->foo = (void *)malloc(sizeof(MD5_CTX), M_TEMP, M_NOWAIT);
if (state->foo == NULL)
panic("ah_keyed_md5_init: what?");
MD5Init((MD5_CTX *)state->foo);
-#else
- state->foo = NULL;
- md5_init();
-#endif
if (state->sa) {
-#ifdef HAVE_MD5
MD5Update((MD5_CTX *)state->foo,
(u_int8_t *)_KEYBUF(state->sa->key_auth),
(u_int)_KEYLEN(state->sa->key_auth));
-#else
- md5_loop((u_int8_t *)_KEYBUF(state->sa->key_auth),
- (u_int)_KEYLEN(state->sa->key_auth));
-#endif
{
/*
@@ -262,39 +235,23 @@
keybitlen *= 8;
buf[0] = 0x80;
-#ifdef HAVE_MD5
MD5Update((MD5_CTX *)state->foo, &buf[0], 1);
-#else
- md5_loop(&buf[0], 1);
-#endif
padlen--;
bzero(buf, sizeof(buf));
while (sizeof(buf) < padlen) {
-#ifdef HAVE_MD5
MD5Update((MD5_CTX *)state->foo, &buf[0], sizeof(buf));
-#else
- md5_loop(&buf[0], sizeof(buf));
-#endif
padlen -= sizeof(buf);
}
if (padlen) {
-#ifdef HAVE_MD5
MD5Update((MD5_CTX *)state->foo, &buf[0], padlen);
-#else
- md5_loop(&buf[0], padlen);
-#endif
}
buf[0] = (keybitlen >> 0) & 0xff;
buf[1] = (keybitlen >> 8) & 0xff;
buf[2] = (keybitlen >> 16) & 0xff;
buf[3] = (keybitlen >> 24) & 0xff;
-#ifdef HAVE_MD5
MD5Update((MD5_CTX *)state->foo, buf, 8);
-#else
- md5_loop(buf, 8);
-#endif
}
}
}
@@ -308,11 +265,7 @@
if (!state)
panic("ah_keyed_md5_loop: what?");
-#ifdef HAVE_MD5
MD5Update((MD5_CTX *)state->foo, addr, len);
-#else
- md5_loop((u_int8_t *)addr, (u_int)len);
-#endif
}
static void
@@ -326,22 +279,12 @@
panic("ah_keyed_md5_result: what?");
if (state->sa) {
-#ifdef HAVE_MD5
MD5Update((MD5_CTX *)state->foo,
(u_int8_t *)_KEYBUF(state->sa->key_auth),
(u_int)_KEYLEN(state->sa->key_auth));
-#else
- md5_loop((u_int8_t *)_KEYBUF(state->sa->key_auth),
- (u_int)_KEYLEN(state->sa->key_auth));
-#endif
}
-#ifdef HAVE_MD5
MD5Final(&digest[0], (MD5_CTX *)state->foo);
free(state->foo, M_TEMP);
-#else
- md5_pad();
- md5_result(&digest[0]);
-#endif
bcopy(&digest[0], (void *)addr, sizeof(digest));
}
@@ -371,40 +314,22 @@
struct ah_algorithm_state *state;
struct secas *sa;
{
-#ifdef HAVE_SHA1
SHA1_CTX *ctxt;
-#else
- struct sha1_ctxt *ctxt;
-#endif
if (!state)
panic("ah_keyed_sha1_init: what?");
state->sa = sa;
-#ifdef HAVE_SHA1
state->foo = (void *)malloc(sizeof(SHA1_CTX), M_TEMP, M_NOWAIT);
-#else
- state->foo = (void *)malloc(sizeof(struct sha1_ctxt), M_TEMP, M_NOWAIT);
-#endif
if (!state->foo)
panic("ah_keyed_sha1_init: what?");
-#ifdef HAVE_SHA1
ctxt = (SHA1_CTX *)state->foo;
SHA1Init(ctxt);
-#else
- ctxt = (struct sha1_ctxt *)state->foo;
- sha1_init(ctxt);
-#endif
if (state->sa) {
-#ifdef HAVE_SHA1
SHA1Update(ctxt, (u_int8_t *)_KEYBUF(state->sa->key_auth),
(u_int)_KEYLEN(state->sa->key_auth));
-#else
- sha1_loop(ctxt, (u_int8_t *)_KEYBUF(state->sa->key_auth),
- (u_int)_KEYLEN(state->sa->key_auth));
-#endif
{
/*
@@ -422,39 +347,23 @@
keybitlen *= 8;
buf[0] = 0x80;
-#ifdef HAVE_SHA1
SHA1Update(ctxt, &buf[0], 1);
-#else
- sha1_loop(ctxt, &buf[0], 1);
-#endif
padlen--;
Home |
Main Index |
Thread Index |
Old Index