summaryrefslogtreecommitdiffstats
path: root/sys/netinet
diff options
context:
space:
mode:
authorpiso <piso@FreeBSD.org>2008-03-12 11:58:29 +0000
committerpiso <piso@FreeBSD.org>2008-03-12 11:58:29 +0000
commit0c792dea7078c0f11e629f340594d1c41e1305b9 (patch)
treee4a417890b7b162677089f40ec60b1d2c2a031a0 /sys/netinet
parent3bf9edde52181999929276ee02cda96133467d2f (diff)
downloadFreeBSD-src-0c792dea7078c0f11e629f340594d1c41e1305b9.zip
FreeBSD-src-0c792dea7078c0f11e629f340594d1c41e1305b9.tar.gz
-Don't pass down the entire pkt to ProtoAliasIn, ProtoAliasOut, FragmentIn
and FragmentOut. -Axe the old PacketAlias API: it has been deprecated since 5.x.
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/libalias/alias.c78
-rw-r--r--sys/netinet/libalias/alias.h54
-rw-r--r--sys/netinet/libalias/alias_old.c216
3 files changed, 43 insertions, 305 deletions
diff --git a/sys/netinet/libalias/alias.c b/sys/netinet/libalias/alias.c
index dbc384f..8000e3b 100644
--- a/sys/netinet/libalias/alias.c
+++ b/sys/netinet/libalias/alias.c
@@ -264,8 +264,11 @@ static int IcmpAliasOut1(struct libalias *, struct ip *, int create);
static int IcmpAliasOut2(struct libalias *, struct ip *);
static int IcmpAliasOut(struct libalias *, struct ip *, int create);
-static int ProtoAliasIn(struct libalias *, struct ip *);
-static int ProtoAliasOut(struct libalias *, struct ip *, int create);
+static int ProtoAliasIn(struct libalias *la, struct in_addr ip_src,
+ struct in_addr *ip_dst, u_char ip_p, u_short *ip_sum);
+static int ProtoAliasOut(struct libalias *la, struct in_addr *ip_src,
+ struct in_addr ip_dst, u_char ip_p, u_short *ip_sum,
+ int create);
static int UdpAliasIn(struct libalias *, struct ip *);
static int UdpAliasOut(struct libalias *, struct ip *, int create);
@@ -639,10 +642,9 @@ IcmpAliasOut(struct libalias *la, struct ip *pip, int create)
return (iresult);
}
-
-// XXX ip free
static int
-ProtoAliasIn(struct libalias *la, struct ip *pip)
+ProtoAliasIn(struct libalias *la, struct in_addr ip_src,
+ struct in_addr *ip_dst, u_char ip_p, u_short *ip_sum)
{
/*
Handle incoming IP packets. The
@@ -657,25 +659,25 @@ ProtoAliasIn(struct libalias *la, struct ip *pip)
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return (PKT_ALIAS_OK);
- lnk = FindProtoIn(la, pip->ip_src, pip->ip_dst, pip->ip_p);
+ lnk = FindProtoIn(la, ip_src, *ip_dst, ip_p);
if (lnk != NULL) {
struct in_addr original_address;
original_address = GetOriginalAddress(lnk);
/* Restore original IP address */
- DifferentialChecksum(&pip->ip_sum,
- &original_address, &pip->ip_dst, 2);
- pip->ip_dst = original_address;
+ DifferentialChecksum(ip_sum,
+ &original_address, ip_dst, 2);
+ *ip_dst = original_address;
return (PKT_ALIAS_OK);
}
return (PKT_ALIAS_IGNORED);
}
-// XXX ip free
static int
-ProtoAliasOut(struct libalias *la, struct ip *pip, int create)
+ProtoAliasOut(struct libalias *la, struct in_addr *ip_src,
+ struct in_addr ip_dst, u_char ip_p, u_short *ip_sum, int create)
{
/*
Handle outgoing IP packets. The
@@ -691,16 +693,16 @@ ProtoAliasOut(struct libalias *la, struct ip *pip, int create)
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return (PKT_ALIAS_OK);
- lnk = FindProtoOut(la, pip->ip_src, pip->ip_dst, pip->ip_p);
+ lnk = FindProtoOut(la, *ip_src, ip_dst, ip_p);
if (lnk != NULL) {
struct in_addr alias_address;
alias_address = GetAliasAddress(lnk);
/* Change source address */
- DifferentialChecksum(&pip->ip_sum,
- &alias_address, &pip->ip_src, 2);
- pip->ip_src = alias_address;
+ DifferentialChecksum(ip_sum,
+ &alias_address, ip_src, 2);
+ *ip_src = alias_address;
return (PKT_ALIAS_OK);
}
@@ -1089,41 +1091,42 @@ saved and recalled when a header fragment is seen.
*/
/* Local prototypes */
-static int FragmentIn(struct libalias *, struct ip *);
-static int FragmentOut(struct libalias *, struct ip *);
+static int FragmentIn(struct libalias *la, struct in_addr ip_src,
+ struct in_addr *ip_dst, u_char ip_p, u_short *ip_sum);
+static int FragmentOut(struct libalias *, struct in_addr *ip_src,
+ u_short *ip_sum);
-// XXX ip free
static int
-FragmentIn(struct libalias *la, struct ip *pip)
+FragmentIn(struct libalias *la, struct in_addr ip_src, struct in_addr *ip_dst,
+ u_char ip_id, u_short *ip_sum)
{
struct alias_link *lnk;
LIBALIAS_LOCK_ASSERT(la);
- lnk = FindFragmentIn2(la, pip->ip_src, pip->ip_dst, pip->ip_id);
+ lnk = FindFragmentIn2(la, ip_src, *ip_dst, ip_id);
if (lnk != NULL) {
struct in_addr original_address;
GetFragmentAddr(lnk, &original_address);
- DifferentialChecksum(&pip->ip_sum,
- &original_address, &pip->ip_dst, 2);
- pip->ip_dst = original_address;
+ DifferentialChecksum(ip_sum,
+ &original_address, ip_dst, 2);
+ *ip_dst = original_address;
return (PKT_ALIAS_OK);
}
return (PKT_ALIAS_UNRESOLVED_FRAGMENT);
}
-// XXX ip free
static int
-FragmentOut(struct libalias *la, struct ip *pip)
+FragmentOut(struct libalias *la, struct in_addr *ip_src, u_short *ip_sum)
{
struct in_addr alias_address;
LIBALIAS_LOCK_ASSERT(la);
- alias_address = FindAliasAddress(la, pip->ip_src);
- DifferentialChecksum(&pip->ip_sum,
- &alias_address, &pip->ip_src, 2);
- pip->ip_src = alias_address;
+ alias_address = FindAliasAddress(la, *ip_src);
+ DifferentialChecksum(ip_sum,
+ &alias_address, ip_src, 2);
+ *ip_src = alias_address;
return (PKT_ALIAS_OK);
}
@@ -1283,11 +1286,13 @@ LibAliasInLocked(struct libalias *la, char *ptr, int maxpacketsize)
if (error == 0)
iresult = PKT_ALIAS_OK;
else
- iresult = ProtoAliasIn(la, pip);
+ iresult = ProtoAliasIn(la, pip->ip_src,
+ &pip->ip_dst, pip->ip_p, &pip->ip_sum);
}
break;
default:
- iresult = ProtoAliasIn(la, pip);
+ iresult = ProtoAliasIn(la, pip->ip_src, &pip->ip_dst,
+ pip->ip_p, &pip->ip_sum);
break;
}
@@ -1303,7 +1308,8 @@ LibAliasInLocked(struct libalias *la, char *ptr, int maxpacketsize)
}
}
} else {
- iresult = FragmentIn(la, pip);
+ iresult = FragmentIn(la, pip->ip_src, &pip->ip_dst, pip->ip_id,
+ &pip->ip_sum);
}
getout:
@@ -1424,15 +1430,17 @@ LibAliasOutLocked(struct libalias *la, char *ptr, /* valid IP packet */
if (error == 0)
iresult = PKT_ALIAS_OK;
else
- iresult = ProtoAliasOut(la, pip, create);
+ iresult = ProtoAliasOut(la, &pip->ip_src,
+ pip->ip_dst, pip->ip_p, &pip->ip_sum, create);
}
break;
default:
- iresult = ProtoAliasOut(la, pip, create);
+ iresult = ProtoAliasOut(la, &pip->ip_src,
+ pip->ip_dst, pip->ip_p, &pip->ip_sum, create);
break;
}
} else {
- iresult = FragmentOut(la, pip);
+ iresult = FragmentOut(la, &pip->ip_src, &pip->ip_sum);
}
SetDefaultAliasAddress(la, addr_save);
diff --git a/sys/netinet/libalias/alias.h b/sys/netinet/libalias/alias.h
index 358109c..2aed829 100644
--- a/sys/netinet/libalias/alias.h
+++ b/sys/netinet/libalias/alias.h
@@ -81,60 +81,6 @@ struct libalias;
*/
struct alias_link;
-
-/* OLD API */
-
-/* Initialization and control functions. */
-void PacketAliasInit(void);
-void PacketAliasSetAddress(struct in_addr _addr);
-void PacketAliasSetFWBase(unsigned int _base, unsigned int _num);
-void PacketAliasSetSkinnyPort(unsigned int _port);
-unsigned int
- PacketAliasSetMode(unsigned int _flags, unsigned int _mask);
-void PacketAliasUninit(void);
-
-/* Packet Handling functions. */
-int PacketAliasIn(char *_ptr, int _maxpacketsize);
-int PacketAliasOut(char *_ptr, int _maxpacketsize);
-int PacketUnaliasOut(char *_ptr, int _maxpacketsize);
-
-/* Port and address redirection functions. */
-
-
-int
-PacketAliasAddServer(struct alias_link *_lnk,
- struct in_addr _addr, unsigned short _port);
-struct alias_link *
-PacketAliasRedirectAddr(struct in_addr _src_addr,
- struct in_addr _alias_addr);
-int PacketAliasRedirectDynamic(struct alias_link *_lnk);
-void PacketAliasRedirectDelete(struct alias_link *_lnk);
-struct alias_link *
-PacketAliasRedirectPort(struct in_addr _src_addr,
- unsigned short _src_port, struct in_addr _dst_addr,
- unsigned short _dst_port, struct in_addr _alias_addr,
- unsigned short _alias_port, unsigned char _proto);
-struct alias_link *
-PacketAliasRedirectProto(struct in_addr _src_addr,
- struct in_addr _dst_addr, struct in_addr _alias_addr,
- unsigned char _proto);
-
-/* Fragment Handling functions. */
-void PacketAliasFragmentIn(char *_ptr, char *_ptr_fragment);
-char *PacketAliasGetFragment(char *_ptr);
-int PacketAliasSaveFragment(char *_ptr);
-
-/* Miscellaneous functions. */
-int PacketAliasCheckNewLink(void);
-unsigned short
- PacketAliasInternetChecksum(unsigned short *_ptr, int _nbytes);
-void PacketAliasSetTarget(struct in_addr _target_addr);
-
-/* Transparent proxying routines. */
-int PacketAliasProxyRule(const char *_cmd);
-
-/* NEW API */
-
/* Initialization and control functions. */
struct libalias *LibAliasInit(struct libalias *);
void LibAliasSetAddress(struct libalias *, struct in_addr _addr);
diff --git a/sys/netinet/libalias/alias_old.c b/sys/netinet/libalias/alias_old.c
deleted file mode 100644
index 528f6be..0000000
--- a/sys/netinet/libalias/alias_old.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*-
- * Copyright (c) 2004 Poul-Henning Kamp <phk@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#ifdef _KERNEL
-#include <sys/param.h>
-#include <sys/proc.h>
-#else
-#include <sys/types.h>
-#include <stdlib.h>
-#endif
-
-#include <netinet/in.h>
-
-#ifdef _KERNEL
-#include <netinet/libalias/alias.h>
-#else
-#include "alias.h"
-#endif
-
-/*
- * These functions are for backwards compatibility and because apps may
- * be linked against shlib versions, they have to be actual functions,
- * we cannot inline them.
- */
-
-static struct libalias *la;
-
-void
-PacketAliasInit(void)
-{
-
- la = LibAliasInit(la);
-}
-
-void
-PacketAliasSetAddress(struct in_addr _addr)
-{
-
- LibAliasSetAddress(la, _addr);
-}
-
-void
-PacketAliasSetFWBase(unsigned int _base, unsigned int _num)
-{
-
- LibAliasSetFWBase(la, _base, _num);
-}
-
-void
-PacketAliasSetSkinnyPort(unsigned int _port)
-{
-
- LibAliasSetSkinnyPort(la, _port);
-}
-
-unsigned int
-PacketAliasSetMode(unsigned int _flags, unsigned int _mask)
-{
-
- return LibAliasSetMode(la, _flags, _mask);
-}
-
-void
-PacketAliasUninit(void)
-{
-
- LibAliasUninit(la);
- la = NULL;
-}
-
-int
-PacketAliasIn(char *_ptr, int _maxpacketsize)
-{
- return LibAliasIn(la, _ptr, _maxpacketsize);
-}
-
-int
-PacketAliasOut(char *_ptr, int _maxpacketsize)
-{
-
- return LibAliasOut(la, _ptr, _maxpacketsize);
-}
-
-int
-PacketUnaliasOut(char *_ptr, int _maxpacketsize)
-{
-
- return LibAliasUnaliasOut(la, _ptr, _maxpacketsize);
-}
-
-int
-PacketAliasAddServer(struct alias_link *_lnk,
- struct in_addr _addr, unsigned short _port)
-{
-
- return LibAliasAddServer(la, _lnk, _addr, _port);
-}
-
-struct alias_link *
-PacketAliasRedirectAddr(struct in_addr _src_addr,
- struct in_addr _alias_addr)
-{
-
- return LibAliasRedirectAddr(la, _src_addr, _alias_addr);
-}
-
-
-int
-PacketAliasRedirectDynamic(struct alias_link *_lnk)
-{
-
- return LibAliasRedirectDynamic(la, _lnk);
-}
-
-void
-PacketAliasRedirectDelete(struct alias_link *_lnk)
-{
-
- LibAliasRedirectDelete(la, _lnk);
-}
-
-struct alias_link *
-PacketAliasRedirectPort(struct in_addr _src_addr,
- unsigned short _src_port, struct in_addr _dst_addr,
- unsigned short _dst_port, struct in_addr _alias_addr,
- unsigned short _alias_port, unsigned char _proto)
-{
-
- return LibAliasRedirectPort(la, _src_addr, _src_port, _dst_addr,
- _dst_port, _alias_addr, _alias_port, _proto);
-}
-
-struct alias_link *
-PacketAliasRedirectProto(struct in_addr _src_addr,
- struct in_addr _dst_addr, struct in_addr _alias_addr,
- unsigned char _proto)
-{
-
- return LibAliasRedirectProto(la, _src_addr, _dst_addr, _alias_addr,
- _proto);
-}
-
-void
-PacketAliasFragmentIn(char *_ptr, char *_ptr_fragment)
-{
-
- LibAliasFragmentIn(la, _ptr, _ptr_fragment);
-}
-
-char *
-PacketAliasGetFragment(char *_ptr)
-{
-
- return LibAliasGetFragment(la, _ptr);
-}
-
-int
-PacketAliasSaveFragment(char *_ptr)
-{
- return LibAliasSaveFragment(la, _ptr);
-}
-
-int
-PacketAliasCheckNewLink(void)
-{
-
- return LibAliasCheckNewLink(la);
-}
-
-unsigned short
-PacketAliasInternetChecksum(unsigned short *_ptr, int _nbytes)
-{
-
- return LibAliasInternetChecksum(la, _ptr, _nbytes);
-}
-
-void
-PacketAliasSetTarget(struct in_addr _target_addr)
-{
-
- LibAliasSetTarget(la, _target_addr);
-}
-
-/* Transparent proxying routines. */
-int
-PacketAliasProxyRule(const char *_cmd)
-{
-
- return LibAliasProxyRule(la, _cmd);
-}
OpenPOWER on IntegriCloud