summaryrefslogtreecommitdiff
path: root/usr.sbin/ppp
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>1999-03-09 23:43:02 +0000
committerbrian <brian@cvs.openbsd.org>1999-03-09 23:43:02 +0000
commit4330184bb887f19442e1e58133094252d62eb5fa (patch)
treebc3067d0f41764101d3999e96b0161fecc7904a0 /usr.sbin/ppp
parent56c7fa6704da8e2d272cd64ea3574bedeaf9ef5b (diff)
Remove all PacketAlias diagnostics to stdout/stderr with
#ifdef DEBUG. Statify functions in alias_nbt.c
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r--usr.sbin/ppp/ppp/alias_db.c28
-rw-r--r--usr.sbin/ppp/ppp/alias_ftp.c2
-rw-r--r--usr.sbin/ppp/ppp/alias_nbt.c34
-rw-r--r--usr.sbin/ppp/ppp/alias_proxy.c12
4 files changed, 54 insertions, 22 deletions
diff --git a/usr.sbin/ppp/ppp/alias_db.c b/usr.sbin/ppp/ppp/alias_db.c
index bd730ba5b15..d01188e9cd6 100644
--- a/usr.sbin/ppp/ppp/alias_db.c
+++ b/usr.sbin/ppp/ppp/alias_db.c
@@ -579,8 +579,10 @@ GetNewPort(struct alias_link *link, int alias_port_param)
}
else
{
+#ifdef DEBUG
fprintf(stderr, "PacketAlias/GetNewPort(): ");
fprintf(stderr, "input parameter error\n");
+#endif
return(-1);
}
@@ -626,8 +628,10 @@ GetNewPort(struct alias_link *link, int alias_port_param)
port_net = htons(port_sys);
}
+#ifdef DEBUG
fprintf(stderr, "PacketAlias/GetnewPort(): ");
fprintf(stderr, "could not find free port\n");
+#endif
return(-1);
}
@@ -646,15 +650,19 @@ GetSocket(u_short port_net, int *sockfd, int link_type)
sock = socket(AF_INET, SOCK_DGRAM, 0);
else
{
+#ifdef DEBUG
fprintf(stderr, "PacketAlias/GetSocket(): ");
fprintf(stderr, "incorrect link type\n");
+#endif
return(0);
}
if (sock < 0)
{
+#ifdef DEBUG
fprintf(stderr, "PacketAlias/GetSocket(): ");
fprintf(stderr, "socket() error %d\n", *sockfd);
+#endif
return(0);
}
@@ -962,8 +970,10 @@ AddLink(struct in_addr src_addr,
}
else
{
+#ifdef DEBUG
fprintf(stderr, "PacketAlias/AddLink: ");
fprintf(stderr, " cannot allocate auxiliary TCP data\n");
+#endif
}
break;
case LINK_FRAGMENT_ID:
@@ -976,8 +986,10 @@ AddLink(struct in_addr src_addr,
}
else
{
+#ifdef DEBUG
fprintf(stderr, "PacketAlias/AddLink(): ");
fprintf(stderr, "malloc() call failed.\n");
+#endif
}
if (packetAliasMode & PKT_ALIAS_LOG)
@@ -1781,8 +1793,10 @@ SetExpire(struct alias_link *link, int expire)
}
else
{
+#ifdef DEBUG
fprintf(stderr, "PacketAlias/SetExpire(): ");
fprintf(stderr, "error in expire parameter\n");
+#endif
}
}
@@ -1851,8 +1865,10 @@ HouseKeeping(void)
}
else if (n < 0)
{
+#ifdef DEBUG
fprintf(stderr, "PacketAlias/HouseKeeping(): ");
fprintf(stderr, "something unexpected in time values\n");
+#endif
lastCleanupTime = timeStamp;
houseKeepingResidual = 0;
}
@@ -1924,8 +1940,10 @@ PacketAliasRedirectPort(struct in_addr src_addr, u_short src_port,
link_type = LINK_TCP;
break;
default:
+#ifdef DEBUG
fprintf(stderr, "PacketAliasRedirectPort(): ");
fprintf(stderr, "only TCP and UDP protocols allowed\n");
+#endif
return NULL;
}
@@ -1937,11 +1955,13 @@ PacketAliasRedirectPort(struct in_addr src_addr, u_short src_port,
{
link->flags |= LINK_PERMANENT;
}
+#ifdef DEBUG
else
{
fprintf(stderr, "PacketAliasRedirectPort(): "
"call to AddLink() failed\n");
}
+#endif
return link;
}
@@ -1981,11 +2001,13 @@ PacketAliasRedirectAddr(struct in_addr src_addr,
{
link->flags |= LINK_PERMANENT;
}
+#ifdef DEBUG
else
{
fprintf(stderr, "PacketAliasRedirectAddr(): "
"call to AddLink() failed\n");
}
+#endif
return link;
}
@@ -2220,7 +2242,9 @@ PunchFWHole(struct alias_link *link) {
if (fwhole == fireWallActiveNum) {
/* No rule point empty - we can't punch more holes. */
fireWallActiveNum = fireWallBaseNum;
+#ifdef DEBUG
fprintf(stderr, "libalias: Unable to create firewall hole!\n");
+#endif
return;
}
}
@@ -2247,15 +2271,19 @@ PunchFWHole(struct alias_link *link) {
clear optimization) */
if (rule.fw_uar.fw_pts[0] != 0 && rule.fw_uar.fw_pts[1] != 0) {
r = setsockopt(fireWallFD, IPPROTO_IP, IP_FW_ADD, &rule, sizeof rule);
+#ifdef DEBUG
if (r)
err(1, "alias punch inbound(1) setsockopt(IP_FW_ADD)");
+#endif
rule.fw_src = GetDestAddress(link);
rule.fw_dst = GetOriginalAddress(link);
rule.fw_uar.fw_pts[0] = ntohs(GetDestPort(link));
rule.fw_uar.fw_pts[1] = ntohs(GetOriginalPort(link));
r = setsockopt(fireWallFD, IPPROTO_IP, IP_FW_ADD, &rule, sizeof rule);
+#ifdef DEBUG
if (r)
err(1, "alias punch inbound(2) setsockopt(IP_FW_ADD)");
+#endif
}
/* Indicate hole applied */
link->data.tcp->fwhole = fwhole;
diff --git a/usr.sbin/ppp/ppp/alias_ftp.c b/usr.sbin/ppp/ppp/alias_ftp.c
index c6d449d0572..73769fdc624 100644
--- a/usr.sbin/ppp/ppp/alias_ftp.c
+++ b/usr.sbin/ppp/ppp/alias_ftp.c
@@ -221,7 +221,9 @@ NewFtpPortCommand(struct ip *pip,
}
else
{
+#ifdef DEBUG
fprintf(stderr,
"PacketAlias/HandleFtpOut: Cannot allocate FTP data port\n");
+#endif
}
}
diff --git a/usr.sbin/ppp/ppp/alias_nbt.c b/usr.sbin/ppp/ppp/alias_nbt.c
index adefebdbf49..4bcbb4e7773 100644
--- a/usr.sbin/ppp/ppp/alias_nbt.c
+++ b/usr.sbin/ppp/ppp/alias_nbt.c
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: alias_nbt.c,v 1.2 1999/03/08 01:40:22 brian Exp $
+ * $Id: alias_nbt.c,v 1.3 1999/03/09 23:43:01 brian Exp $
*
* TODO:
* oClean up.
@@ -101,15 +101,9 @@ typedef struct {
#define ACT_ERR 0x6
#define CFT_ERR 0x7
-/*******************************************************************
- * copy an IP address from one buffer to another *
- *******************************************************************/
-void putip(void *dest,void *src)
-{
- memcpy(dest,src,4);
-}
-void PrintRcode( u_char rcode ) {
+#ifdef DEBUG
+static void PrintRcode( u_char rcode ) {
switch (rcode) {
case FMT_ERR:
@@ -129,10 +123,11 @@ void PrintRcode( u_char rcode ) {
}
}
+#endif
/* Handling Name field */
-u_char *AliasHandleName ( u_char *p, char *pmax ) {
+static u_char *AliasHandleName ( u_char *p, char *pmax ) {
u_char *s;
u_char c;
@@ -282,7 +277,7 @@ typedef struct {
u_short class; /* The class of Request */
} NBTNsQuestion;
-u_char *
+static u_char *
AliasHandleQuestion(
u_short count,
NBTNsQuestion *q,
@@ -306,7 +301,9 @@ AliasHandleQuestion(
q= q+1;
break;
default:
+#ifdef DEBUG
printf("\nUnknown Type on Question %0x\n", ntohs(q->type) );
+#endif
break;
}
count--;
@@ -337,7 +334,7 @@ typedef struct {
struct in_addr addr;
} NBTNsRNB;
-u_char *
+static u_char *
AliasHandleResourceNB(
NBTNsResource *q,
char *pmax,
@@ -406,7 +403,7 @@ typedef struct {
struct in_addr addr;
} NBTNsResourceA;
-u_char *
+static u_char *
AliasHandleResourceA(
NBTNsResource *q,
char *pmax,
@@ -463,7 +460,7 @@ typedef struct {
u_short opcode:4, flags:8, resv:4;
} NBTNsResourceNULL;
-u_char *
+static u_char *
AliasHandleResourceNULL(
NBTNsResource *q,
char *pmax,
@@ -496,7 +493,7 @@ AliasHandleResourceNULL(
return ((u_char *)n);
}
-u_char *
+static u_char *
AliasHandleResourceNS(
NBTNsResource *q,
char *pmax,
@@ -527,7 +524,7 @@ typedef struct {
u_short numnames;
} NBTNsResourceNBSTAT;
-u_char *
+static u_char *
AliasHandleResourceNBSTAT(
NBTNsResource *q,
char *pmax,
@@ -551,7 +548,7 @@ AliasHandleResourceNBSTAT(
return ((u_char *)n + bcount);
}
-u_char *
+static u_char *
AliasHandleResource(
u_short count,
NBTNsResource *q,
@@ -607,10 +604,12 @@ AliasHandleResource(
);
break;
default:
+#ifdef DEBUG
printf(
"\nUnknown Type of Resource %0x\n",
ntohs(q->type)
);
+#endif
break;
}
count--;
@@ -710,4 +709,3 @@ int AliasHandleUdpNbtNS(
#endif
return ((p == NULL) ? -1 : 0);
}
-
diff --git a/usr.sbin/ppp/ppp/alias_proxy.c b/usr.sbin/ppp/ppp/alias_proxy.c
index 27a56c25dae..41f016cd62b 100644
--- a/usr.sbin/ppp/ppp/alias_proxy.c
+++ b/usr.sbin/ppp/ppp/alias_proxy.c
@@ -347,8 +347,10 @@ ProxyEncodeIpHeader(struct ip *pip,
#define OPTION_LEN_INT32 2
u_char option[OPTION_LEN_BYTES];
-fprintf(stdout, " ip cksum 1 = %x\n", (u_int) IpChecksum(pip));
-fprintf(stdout, "tcp cksum 1 = %x\n", (u_int) TcpChecksum(pip));
+#ifdef DEBUG
+ fprintf(stdout, " ip cksum 1 = %x\n", (u_int) IpChecksum(pip));
+ fprintf(stdout, "tcp cksum 1 = %x\n", (u_int) TcpChecksum(pip));
+#endif
/* Check to see that there is room to add an IP option */
if (pip->ip_hl > (0x0f - OPTION_LEN_INT32))
@@ -399,8 +401,10 @@ fprintf(stdout, "tcp cksum 1 = %x\n", (u_int) TcpChecksum(pip));
#undef OPTION_LEN_BYTES
#undef OPTION_LEN_INT16
#undef OPTION_LEN_INT32
-fprintf(stdout, " ip cksum 2 = %x\n", (u_int) IpChecksum(pip));
-fprintf(stdout, "tcp cksum 2 = %x\n", (u_int) TcpChecksum(pip));
+#ifdef DEBUG
+ fprintf(stdout, " ip cksum 2 = %x\n", (u_int) IpChecksum(pip));
+ fprintf(stdout, "tcp cksum 2 = %x\n", (u_int) TcpChecksum(pip));
+#endif
}