summaryrefslogtreecommitdiffstats
path: root/lib/libalias/alias.c
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2000-10-30 12:39:41 +0000
committerru <ru@FreeBSD.org>2000-10-30 12:39:41 +0000
commit390de194cd65ae4f4284ca22f4b0c0bf48c41b04 (patch)
treed2c51d699062565136879cc42dc72ff6ccab67a5 /lib/libalias/alias.c
parenta2cdf6684f245866048a91f755248dcaedc075bc (diff)
downloadFreeBSD-src-390de194cd65ae4f4284ca22f4b0c0bf48c41b04.zip
FreeBSD-src-390de194cd65ae4f4284ca22f4b0c0bf48c41b04.tar.gz
A significant rewrite of PPTP aliasing code.
PPTP links are no longer dropped by simple (and inappropriate in this case) "inactivity timeout" procedure, only when requested through the control connection. It is now possible to have multiple PPTP servers running behind NAT. Just redirect the incoming TCP traffic to port 1723, everything else is done transparently. Problems were reported and the fix was tested by: Michael Adler <Michael.Adler@compaq.com>, David Andersen <dga@lcs.mit.edu>
Diffstat (limited to 'lib/libalias/alias.c')
-rw-r--r--lib/libalias/alias.c51
1 files changed, 12 insertions, 39 deletions
diff --git a/lib/libalias/alias.c b/lib/libalias/alias.c
index 4dc1800..a2ef4bf 100644
--- a/lib/libalias/alias.c
+++ b/lib/libalias/alias.c
@@ -185,7 +185,6 @@ TcpMonitorOut(struct ip *pip, struct alias_link *link)
ProtoAliasIn(), ProtoAliasOut()
UdpAliasIn(), UdpAliasOut()
TcpAliasIn(), TcpAliasOut()
- GreAliasIn()
These routines handle protocol specific details of packet aliasing.
One may observe a certain amount of repetitive arithmetic in these
@@ -237,8 +236,6 @@ static int UdpAliasIn (struct ip *);
static int TcpAliasOut(struct ip *, int);
static int TcpAliasIn (struct ip *);
-static int GreAliasIn(struct ip *);
-
static int
IcmpAliasIn1(struct ip *pip)
@@ -707,40 +704,6 @@ ProtoAliasOut(struct ip *pip)
static int
-GreAliasIn(struct ip *pip)
-{
- u_short call_id;
- struct alias_link *link;
-
-/* Return if proxy-only mode is enabled. */
- if (packetAliasMode & PKT_ALIAS_PROXY_ONLY)
- return (PKT_ALIAS_OK);
-
- if (PptpGetCallID(pip, &call_id)) {
- if ((link = FindPptpIn(pip->ip_src, pip->ip_dst, call_id)) != NULL) {
- struct in_addr alias_address;
- struct in_addr original_address;
-
- alias_address = GetAliasAddress(link);
- original_address = GetOriginalAddress(link);
- PptpSetCallID(pip, GetOriginalPort(link));
-
- /* Restore original IP address. */
- DifferentialChecksum(&pip->ip_sum,
- (u_short *)&original_address,
- (u_short *)&pip->ip_dst,
- 2);
- pip->ip_dst = original_address;
-
- return (PKT_ALIAS_OK);
- } else
- return (PKT_ALIAS_IGNORED);
- } else
- return ProtoAliasIn(pip);
-}
-
-
-static int
UdpAliasIn(struct ip *pip)
{
struct udphdr *ud;
@@ -1318,8 +1281,12 @@ PacketAliasIn(char *ptr, int maxpacketsize)
iresult = TcpAliasIn(pip);
break;
case IPPROTO_GRE:
- iresult = GreAliasIn(pip);
- break;
+ if (packetAliasMode & PKT_ALIAS_PROXY_ONLY ||
+ AliasHandlePptpGreIn(pip) == 0)
+ iresult = PKT_ALIAS_OK;
+ else
+ iresult = ProtoAliasIn(pip);
+ break;
default:
iresult = ProtoAliasIn(pip);
break;
@@ -1426,6 +1393,12 @@ PacketAliasOut(char *ptr, /* valid IP packet */
case IPPROTO_TCP:
iresult = TcpAliasOut(pip, maxpacketsize);
break;
+ case IPPROTO_GRE:
+ if (AliasHandlePptpGreOut(pip) == 0)
+ iresult = PKT_ALIAS_OK;
+ else
+ iresult = ProtoAliasOut(pip);
+ break;
default:
iresult = ProtoAliasOut(pip);
break;
OpenPOWER on IntegriCloud