summaryrefslogtreecommitdiffstats
path: root/lib/libalias
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1998-04-19 21:42:07 +0000
committerbrian <brian@FreeBSD.org>1998-04-19 21:42:07 +0000
commit182404b2741d5b0d2de788e163aa2b0595d340b0 (patch)
treeadf7bc6bf6fe73ee0112ffe8e0866989b626b5ab /lib/libalias
parent12bba629029991b4891ee96a822a3990bc9886c7 (diff)
downloadFreeBSD-src-182404b2741d5b0d2de788e163aa2b0595d340b0.zip
FreeBSD-src-182404b2741d5b0d2de788e163aa2b0595d340b0.tar.gz
o Support a compile-time -DNO_FW_PUNCH for portability
(and those of us that don't want the functionality). o Don't assume sizeof(long) == 4. Ok'd by: Charles Mott <cmott@srv.net>
Diffstat (limited to 'lib/libalias')
-rw-r--r--lib/libalias/alias.c4
-rw-r--r--lib/libalias/alias.h6
-rw-r--r--lib/libalias/alias_db.c15
-rw-r--r--lib/libalias/alias_irc.c2
4 files changed, 23 insertions, 4 deletions
diff --git a/lib/libalias/alias.c b/lib/libalias/alias.c
index c8ef65a..8ae038b 100644
--- a/lib/libalias/alias.c
+++ b/lib/libalias/alias.c
@@ -318,12 +318,12 @@ IcmpAliasIn2(struct ip *pip)
link = FindUdpTcpIn(ip->ip_dst, ip->ip_src,
tc->th_dport, tc->th_sport,
IPPROTO_TCP);
- else if (ip->ip_p == IPPROTO_ICMP)
+ else if (ip->ip_p == IPPROTO_ICMP) {
if (ic2->icmp_type == ICMP_ECHO || ic2->icmp_type == ICMP_TSTAMP)
link = FindIcmpIn(ip->ip_dst, ip->ip_src, ic2->icmp_id);
else
link = NULL;
- else
+ } else
link = NULL;
if (link != NULL)
diff --git a/lib/libalias/alias.h b/lib/libalias/alias.h
index 5bec4c9..010db98 100644
--- a/lib/libalias/alias.h
+++ b/lib/libalias/alias.h
@@ -7,7 +7,7 @@
This software is placed into the public domain with no restrictions
on its distribution.
- $Id$
+ $Id: alias.h,v 1.7 1998/01/16 12:56:07 bde Exp $
*/
@@ -36,8 +36,10 @@ struct alias_link;
extern unsigned int
PacketAliasSetMode(unsigned int, unsigned int);
+#ifndef NO_FW_PUNCH
extern void
PacketAliasSetFWBase(unsigned int, unsigned int);
+#endif
/* Packet Handling */
extern int
@@ -150,6 +152,7 @@ extern u_short InternetChecksum(u_short *, int);
bit is set after a call to PacketAliasInit(). */
#define PKT_ALIAS_RESET_ON_ADDR_CHANGE 0x20
+#ifndef NO_FW_PUNCH
/* If PKT_ALIAS_PUNCH_FW is set, active FTP and IRC DCC connections
will create a 'hole' in the firewall to allow the transfers to
work. Where (IPFW "line-numbers") the hole is created is
@@ -157,6 +160,7 @@ extern u_short InternetChecksum(u_short *, int);
attached to that particular alias_link, so when the link goes away
so do the hole. */
#define PKT_ALIAS_PUNCH_FW 0x40
+#endif
/* Return Codes */
#define PKT_ALIAS_ERROR -1
diff --git a/lib/libalias/alias_db.c b/lib/libalias/alias_db.c
index 18983d2..7bbb191 100644
--- a/lib/libalias/alias_db.c
+++ b/lib/libalias/alias_db.c
@@ -340,11 +340,13 @@ static int newDefaultLink; /* Indicates if a new aliasing */
/* link has been created after a */
/* call to PacketAliasIn/Out(). */
+#ifndef NO_FW_PUNCH
static int fireWallFD = -1; /* File descriptor to be able to */
/* control firewall. Opened by */
/* PacketAliasSetMode on first */
/* setting the PKT_ALIAS_PUNCH_FW */
/* flag. */
+#endif
@@ -375,10 +377,12 @@ static int SeqDiff(u_long, u_long);
static void ShowAliasStats(void);
+#ifndef NO_FW_PUNCH
/* Firewall control */
static void InitPunchFW(void);
static void UninitPunchFW(void);
static void ClearFWHole(struct alias_link *link);
+#endif
/* Log file control */
static void InitPacketAliasLog(void);
@@ -750,8 +754,10 @@ DeleteLink(struct alias_link *link)
if (deleteAllLinks == 0 && link->flags & LINK_PERMANENT)
return;
+#ifndef NO_FW_PUNCH
/* Delete associatied firewall hole, if any */
ClearFWHole(link);
+#endif
/* Adjust output table pointers */
link_last = link->last_out;
@@ -987,12 +993,14 @@ ReLink(struct alias_link *old_link,
new_link = AddLink(src_addr, dst_addr, alias_addr,
src_port, dst_port, alias_port_param,
link_type);
+#ifndef NO_FW_PUNCH
if (new_link != NULL &&
old_link->link_type == LINK_TCP &&
old_link->data.tcp &&
old_link->data.tcp->fwhole > 0) {
PunchFWHole(new_link);
}
+#endif
DeleteLink(old_link);
return new_link;
}
@@ -2005,7 +2013,9 @@ PacketAliasUninit(void) {
CleanupAliasData();
deleteAllLinks = 0;
UninitPacketAliasLog();
+#ifndef NO_FW_PUNCH
UninitPunchFW();
+#endif
}
@@ -2027,6 +2037,7 @@ PacketAliasSetMode(
UninitPacketAliasLog();
}
+#ifndef NO_FW_PUNCH
/* Start punching holes in the firewall? */
if (flags & mask & PKT_ALIAS_PUNCH_FW) {
InitPunchFW();
@@ -2035,6 +2046,7 @@ PacketAliasSetMode(
if (~flags & mask & PKT_ALIAS_PUNCH_FW) {
UninitPunchFW();
}
+#endif
/* Other flags can be set/cleared without special action */
packetAliasMode = (flags & mask) | (packetAliasMode & ~mask);
@@ -2049,6 +2061,8 @@ PacketAliasCheckNewLink(void)
}
+#ifndef NO_FW_PUNCH
+
/*****************
Code to support firewall punching. This shouldn't really be in this
file, but making variables global is evil too.
@@ -2222,3 +2236,4 @@ ClearAllFWHoles(void) {
}
memset(fireWallField, 0, fireWallNumNums);
}
+#endif
diff --git a/lib/libalias/alias_irc.c b/lib/libalias/alias_irc.c
index 933e3c6..73a02e5 100644
--- a/lib/libalias/alias_irc.c
+++ b/lib/libalias/alias_irc.c
@@ -229,7 +229,7 @@ lFOUND_CTCP:
alias_address = GetAliasAddress(link);
iCopy += snprintf(&newpacket[iCopy],
sizeof(newpacket)-iCopy,
- "%lu ", htonl(alias_address.s_addr));
+ "%lu ", (u_long)htonl(alias_address.s_addr));
if( iCopy >= sizeof(newpacket) ) { /* Truncated/fit exactly - bad news */
DBprintf(("DCC constructed packet overflow.\n"));
goto lBAD_CTCP;
OpenPOWER on IntegriCloud