summaryrefslogtreecommitdiff
path: root/sys/netinet/ip_ah_new.c
diff options
context:
space:
mode:
authorNiels Provos <provos@cvs.openbsd.org>1998-06-03 09:50:23 +0000
committerNiels Provos <provos@cvs.openbsd.org>1998-06-03 09:50:23 +0000
commit4a13cf5c5e7f44da86d7fe42c3e7c3ff925e4f95 (patch)
tree01afb8982e2254e349518f68ee5ee356aa086843 /sys/netinet/ip_ah_new.c
parentd9b92cbaf895bd1dcceb0fd26800ad24987baf69 (diff)
cleanup debug printfs
Diffstat (limited to 'sys/netinet/ip_ah_new.c')
-rw-r--r--sys/netinet/ip_ah_new.c87
1 files changed, 25 insertions, 62 deletions
diff --git a/sys/netinet/ip_ah_new.c b/sys/netinet/ip_ah_new.c
index 736e288f62e..ed8a442d0ce 100644
--- a/sys/netinet/ip_ah_new.c
+++ b/sys/netinet/ip_ah_new.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_ah_new.c,v 1.17 1998/05/18 21:10:33 provos Exp $ */
+/* $OpenBSD: ip_ah_new.c,v 1.18 1998/06/03 09:50:18 provos Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
@@ -71,6 +71,12 @@
#include <netinet/ip_ah.h>
#include <sys/syslog.h>
+#ifdef ENCDEBUG
+#define DPRINTF(x) if (encdebug) printf x
+#else
+#define DPRINTF(x)
+#endif
+
extern void encap_sendnotify(int, struct tdb *, void *);
struct ah_hash ah_new_hash[] = {
@@ -105,10 +111,7 @@ struct ah_hash ah_new_hash[] = {
int
ah_new_attach()
{
-#ifdef ENCDEBUG
- if (encdebug)
- printf("ah_new_attach(): setting up\n");
-#endif /* ENCDEBUG */
+ DPRINTF(("ah_new_attach(): setting up\n"));
return 0;
}
@@ -131,10 +134,7 @@ ah_new_init(struct tdb *tdbp, struct xformsw *xsp, struct mbuf *m)
{
if ((m = m_pullup(m, ENCAP_MSG_FIXED_LEN)) == NULL)
{
-#ifdef ENCDEBUG
- if (encdebug)
- printf("ah_new_init(): m_pullup failed\n");
-#endif /* ENCDEBUG */
+ DPRINTF(("ah_new_init(): m_pullup failed\n"));
return ENOBUFS;
}
}
@@ -160,11 +160,8 @@ ah_new_init(struct tdb *tdbp, struct xformsw *xsp, struct mbuf *m)
log(LOG_WARNING, "ah_new_init(): unsupported authentication algorithm %d specified\n", txd.amx_hash_algorithm);
return EINVAL;
}
-#ifdef ENCDEBUG
- if (encdebug)
- printf("ah_new_init(): initalized TDB with hash algorithm %d: %s\n",
- txd.amx_hash_algorithm, ah_new_hash[i].name);
-#endif /* ENCDEBUG */
+ DPRINTF(("ah_new_init(): initalized TDB with hash algorithm %d: %s\n",
+ txd.amx_hash_algorithm, ah_new_hash[i].name));
thash = &ah_new_hash[i];
blocklen = HMAC_BLOCK_LEN;
@@ -180,10 +177,7 @@ ah_new_init(struct tdb *tdbp, struct xformsw *xsp, struct mbuf *m)
M_XDATA, M_WAITOK);
if (tdbp->tdb_xdata == NULL)
{
-#ifdef ENCDEBUG
- if (encdebug)
- printf("ah_new_init(): MALLOC failed\n");
-#endif /* ENCDEBUG */
+ DPRINTF(("ah_new_init(): MALLOC failed\n"));
return ENOBUFS;
}
@@ -192,10 +186,7 @@ ah_new_init(struct tdb *tdbp, struct xformsw *xsp, struct mbuf *m)
M_TEMP, M_WAITOK);
if (buffer == NULL)
{
-#ifdef ENCDEBUG
- if (encdebug)
- printf("ah_new_init(): MALLOC failed\n");
-#endif /* ENCDEBUG */
+ DPRINTF(("ah_new_init(): MALLOC failed\n"));
free(tdbp->tdb_xdata, M_XDATA);
return ENOBUFS;
}
@@ -254,10 +245,7 @@ ah_new_init(struct tdb *tdbp, struct xformsw *xsp, struct mbuf *m)
int
ah_new_zeroize(struct tdb *tdbp)
{
-#ifdef ENCDEBUG
- if (encdebug)
- printf("ah_new_zeroize(): freeing memory\n");
-#endif /* ENCDEBUG */
+ DPRINTF(("ah_new_zeroize(): freeing memory\n"));
if (tdbp->tdb_xdata)
{
FREE(tdbp->tdb_xdata, M_XDATA);
@@ -299,10 +287,7 @@ ah_new_input(struct mbuf *m, struct tdb *tdb)
if ((m = m_pullup(m, ohlen)) == NULL)
{
ahstat.ahs_hdrops++;
-#ifdef ENCDEBUG
- if (encdebug)
- printf("ah_new_input(): (possibly too short) packet dropped\n");
-#endif /* ENCDEBUG */
+ DPRINTF(("ah_new_input(): (possibly too short) packet dropped\n"));
return NULL;
}
}
@@ -315,10 +300,7 @@ ah_new_input(struct mbuf *m, struct tdb *tdb)
if ((m = m_pullup(m, ohlen - sizeof (struct ip) +
(ip->ip_hl << 2))) == NULL)
{
-#ifdef ENCDEBUG
- if (encdebug)
- printf("ah_new_input(): m_pullup() failed\n");
-#endif /* ENCDEBUG */
+ DPRINTF(("ah_new_input(): m_pullup() failed\n"));
ahstat.ahs_hdrops++;
return NULL;
}
@@ -332,10 +314,7 @@ ah_new_input(struct mbuf *m, struct tdb *tdb)
if (ah->ah_hl * sizeof(u_int32_t) != AH_HMAC_HASHLEN + AH_HMAC_RPLENGTH)
{
-#ifdef ENCDEBUG
- if (encdebug)
- printf("ah_new_input(): bad authenticator length for packet from %x to %x, spi %08x\n", ip->ip_src, ip->ip_dst, ntohl(ah->ah_spi));
-#endif /* ENCDEBUG */
+ DPRINTF(("ah_new_input(): bad authenticator length for packet from %x to %x, spi %08x\n", ip->ip_src, ip->ip_dst, ntohl(ah->ah_spi)));
ahstat.ahs_badauthl++;
m_freem(m);
return NULL;
@@ -573,11 +552,8 @@ ah_new_output(struct mbuf *m, struct sockaddr_encap *gw, struct tdb *tdb,
m = m_pullup(m, sizeof(struct ip));
if (m == NULL)
{
-#ifdef ENCDEBUG
- if (encdebug)
- printf("ah_new_output(): m_pullup() failed, SA %x/%08x\n",
- tdb->tdb_dst, ntohl(tdb->tdb_spi));
-#endif /* ENCDEBUG */
+ DPRINTF(("ah_new_output(): m_pullup() failed, SA %x/%08x\n",
+ tdb->tdb_dst, ntohl(tdb->tdb_spi)));
return ENOBUFS;
}
@@ -589,11 +565,8 @@ ah_new_output(struct mbuf *m, struct sockaddr_encap *gw, struct tdb *tdb,
{
if ((m = m_pullup(m, ip->ip_hl << 2)) == NULL)
{
-#ifdef ENCDEBUG
- if (encdebug)
- printf("ah_new_output(): m_pullup() failed, SA &x/%08x\n",
- tdb->tdb_dst, ntohl(tdb->tdb_spi));
-#endif /* ENCDEBUG */
+ DPRINTF(("ah_new_output(): m_pullup() failed, SA &x/%08x\n",
+ tdb->tdb_dst, ntohl(tdb->tdb_spi)));
ahstat.ahs_hdrops++;
return NULL;
}
@@ -605,11 +578,7 @@ ah_new_output(struct mbuf *m, struct sockaddr_encap *gw, struct tdb *tdb,
m_copydata(m, sizeof(struct ip), (ip->ip_hl << 2) - sizeof(struct ip),
(caddr_t) opts);
-#ifdef ENCDEBUG
- if (encdebug)
- printf("ah_new_output(): using hash algorithm %s\n",
- xd->amx_hash->name);
-#endif /* ENCDEBUG */
+ DPRINTF(("ah_new_output(): using hash algorithm %s\n", xd->amx_hash->name));
ilen = ntohs(ip->ip_len);
@@ -646,7 +615,7 @@ ah_new_output(struct mbuf *m, struct sockaddr_encap *gw, struct tdb *tdb,
aho.ah_rpl = htonl(xd->amx_rpl++);
- bcopy(&(xd->amx_ictx), &ctx, xd->amx_hash->ctxsize);
+ bcopy((caddr_t)&(xd->amx_ictx), (caddr_t)&ctx, xd->amx_hash->ctxsize);
xd->amx_hash->Update(&ctx, (unsigned char *) &ipo, sizeof(struct ip));
/* Options */
@@ -721,20 +690,14 @@ ah_new_output(struct mbuf *m, struct sockaddr_encap *gw, struct tdb *tdb,
M_PREPEND(m, ohlen, M_DONTWAIT);
if (m == NULL)
{
-#ifdef ENCDEBUG
- if (encdebug)
- printf("ah_new_output(): M_PREPEND() failed for packet from %x to %x, spi %08x\n", ipo.ip_src, ipo.ip_dst, ntohl(tdb->tdb_spi));
-#endif /* ENCDEBUG */
+ DPRINTF(("ah_new_output(): M_PREPEND() failed for packet from %x to %x, spi %08x\n", ipo.ip_src, ipo.ip_dst, ntohl(tdb->tdb_spi)));
return ENOBUFS;
}
m = m_pullup(m, ohlen + (ipo.ip_hl << 2));
if (m == NULL)
{
-#ifdef ENCDEBUG
- if (encdebug)
- printf("ah_new_output(): m_pullup() failed for packet from %x to %x, spi %08x\n", ipo.ip_src, ipo.ip_dst, ntohl(tdb->tdb_spi));
-#endif /* ENCDEBUG */
+ DPRINTF(("ah_new_output(): m_pullup() failed for packet from %x to %x, spi %08x\n", ipo.ip_src, ipo.ip_dst, ntohl(tdb->tdb_spi)));
return ENOBUFS;
}