summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2000-10-30 17:24:12 +0000
committerru <ru@FreeBSD.org>2000-10-30 17:24:12 +0000
commite25226e0c4caaa3e1286b3e6cc56cf4d56b14046 (patch)
tree7972ca1d2c33fe43ba4c6d4cd73e260049eb64ea /sys
parent32aa5600750763e560e98e2d369a7c4d6497078b (diff)
downloadFreeBSD-src-e25226e0c4caaa3e1286b3e6cc56cf4d56b14046.zip
FreeBSD-src-e25226e0c4caaa3e1286b3e6cc56cf4d56b14046.tar.gz
Added boolean argument to link searching functions, indicating
whether they should create a link if lookup has failed or not.
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/libalias/alias.c35
-rw-r--r--sys/netinet/libalias/alias_cuseeme.c2
-rw-r--r--sys/netinet/libalias/alias_db.c87
-rw-r--r--sys/netinet/libalias/alias_ftp.c2
-rw-r--r--sys/netinet/libalias/alias_irc.c7
-rw-r--r--sys/netinet/libalias/alias_local.h14
-rw-r--r--sys/netinet/libalias/alias_smedia.c2
7 files changed, 42 insertions, 107 deletions
diff --git a/sys/netinet/libalias/alias.c b/sys/netinet/libalias/alias.c
index a2ef4bf..fd35221 100644
--- a/sys/netinet/libalias/alias.c
+++ b/sys/netinet/libalias/alias.c
@@ -250,7 +250,7 @@ IcmpAliasIn1(struct ip *pip)
ic = (struct icmp *) ((char *) pip + (pip->ip_hl << 2));
/* Get source address from ICMP data field and restore original data */
- link = FindIcmpIn(pip->ip_src, pip->ip_dst, ic->icmp_id);
+ link = FindIcmpIn(pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
if (link != NULL)
{
u_short original_id;
@@ -306,14 +306,14 @@ IcmpAliasIn2(struct ip *pip)
if (ip->ip_p == IPPROTO_UDP)
link = FindUdpTcpIn(ip->ip_dst, ip->ip_src,
ud->uh_dport, ud->uh_sport,
- IPPROTO_UDP);
+ IPPROTO_UDP, 0);
else if (ip->ip_p == IPPROTO_TCP)
link = FindUdpTcpIn(ip->ip_dst, ip->ip_src,
tc->th_dport, tc->th_sport,
- IPPROTO_TCP);
+ IPPROTO_TCP, 0);
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);
+ link = FindIcmpIn(ip->ip_dst, ip->ip_src, ic2->icmp_id, 0);
else
link = NULL;
} else
@@ -443,7 +443,7 @@ IcmpAliasOut1(struct ip *pip)
ic = (struct icmp *) ((char *) pip + (pip->ip_hl << 2));
/* Save overwritten data for when echo packet returns */
- link = FindIcmpOut(pip->ip_src, pip->ip_dst, ic->icmp_id);
+ link = FindIcmpOut(pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
if (link != NULL)
{
u_short alias_id;
@@ -500,14 +500,14 @@ IcmpAliasOut2(struct ip *pip)
if (ip->ip_p == IPPROTO_UDP)
link = FindUdpTcpOut(ip->ip_dst, ip->ip_src,
ud->uh_dport, ud->uh_sport,
- IPPROTO_UDP);
+ IPPROTO_UDP, 0);
else if (ip->ip_p == IPPROTO_TCP)
link = FindUdpTcpOut(ip->ip_dst, ip->ip_src,
tc->th_dport, tc->th_sport,
- IPPROTO_TCP);
+ IPPROTO_TCP, 0);
else if (ip->ip_p == IPPROTO_ICMP) {
if (ic2->icmp_type == ICMP_ECHO || ic2->icmp_type == ICMP_TSTAMP)
- link = FindIcmpOut(ip->ip_dst, ip->ip_src, ic2->icmp_id);
+ link = FindIcmpOut(ip->ip_dst, ip->ip_src, ic2->icmp_id, 0);
else
link = NULL;
} else
@@ -717,7 +717,7 @@ UdpAliasIn(struct ip *pip)
link = FindUdpTcpIn(pip->ip_src, pip->ip_dst,
ud->uh_sport, ud->uh_dport,
- IPPROTO_UDP);
+ IPPROTO_UDP, 1);
if (link != NULL)
{
struct in_addr alias_address;
@@ -791,7 +791,7 @@ UdpAliasOut(struct ip *pip)
link = FindUdpTcpOut(pip->ip_src, pip->ip_dst,
ud->uh_sport, ud->uh_dport,
- IPPROTO_UDP);
+ IPPROTO_UDP, 1);
if (link != NULL)
{
u_short alias_port;
@@ -857,7 +857,8 @@ TcpAliasIn(struct ip *pip)
link = FindUdpTcpIn(pip->ip_src, pip->ip_dst,
tc->th_sport, tc->th_dport,
- IPPROTO_TCP);
+ IPPROTO_TCP,
+ !(packetAliasMode & PKT_ALIAS_PROXY_ONLY));
if (link != NULL)
{
struct in_addr alias_address;
@@ -1012,7 +1013,7 @@ TcpAliasOut(struct ip *pip, int maxpacketsize)
link = FindUdpTcpOut(pip->ip_src, pip->ip_dst,
tc->th_sport, tc->th_dport,
- IPPROTO_TCP);
+ IPPROTO_TCP, 1);
if (link !=NULL)
{
u_short alias_port;
@@ -1438,15 +1439,15 @@ PacketUnaliasOut(char *ptr, /* valid IP packet */
/* Find a link */
if (pip->ip_p == IPPROTO_UDP)
- link = QueryUdpTcpIn(pip->ip_dst, pip->ip_src,
+ link = FindUdpTcpIn(pip->ip_dst, pip->ip_src,
ud->uh_dport, ud->uh_sport,
- IPPROTO_UDP);
+ IPPROTO_UDP, 0);
else if (pip->ip_p == IPPROTO_TCP)
- link = QueryUdpTcpIn(pip->ip_dst, pip->ip_src,
+ link = FindUdpTcpIn(pip->ip_dst, pip->ip_src,
tc->th_dport, tc->th_sport,
- IPPROTO_TCP);
+ IPPROTO_TCP, 0);
else if (pip->ip_p == IPPROTO_ICMP)
- link = FindIcmpIn(pip->ip_dst, pip->ip_src, ic->icmp_id);
+ link = FindIcmpIn(pip->ip_dst, pip->ip_src, ic->icmp_id, 0);
else
link = NULL;
diff --git a/sys/netinet/libalias/alias_cuseeme.c b/sys/netinet/libalias/alias_cuseeme.c
index 7ac1f83..1a7fbf1 100644
--- a/sys/netinet/libalias/alias_cuseeme.c
+++ b/sys/netinet/libalias/alias_cuseeme.c
@@ -79,7 +79,7 @@ AliasHandleCUSeeMeOut(struct ip *pip, struct alias_link *link)
cu->addr = (u_int32_t)GetAliasAddress(link).s_addr;
cu_link = FindUdpTcpOut(pip->ip_src, GetDestAddress(link),
- ud->uh_dport, 0, IPPROTO_UDP);
+ ud->uh_dport, 0, IPPROTO_UDP, 1);
#ifndef NO_FW_PUNCH
if (cu_link)
diff --git a/sys/netinet/libalias/alias_db.c b/sys/netinet/libalias/alias_db.c
index 7b04548..f926239 100644
--- a/sys/netinet/libalias/alias_db.c
+++ b/sys/netinet/libalias/alias_db.c
@@ -1402,14 +1402,15 @@ FindLinkIn(struct in_addr dst_addr,
struct alias_link *
FindIcmpIn(struct in_addr dst_addr,
struct in_addr alias_addr,
- u_short id_alias)
+ u_short id_alias,
+ int create)
{
struct alias_link *link;
link = FindLinkIn(dst_addr, alias_addr,
NO_DEST_PORT, id_alias,
LINK_ICMP, 0);
- if (link == NULL && !(packetAliasMode & PKT_ALIAS_DENY_INCOMING))
+ if (link == NULL && create && !(packetAliasMode & PKT_ALIAS_DENY_INCOMING))
{
struct in_addr target_addr;
@@ -1426,14 +1427,15 @@ FindIcmpIn(struct in_addr dst_addr,
struct alias_link *
FindIcmpOut(struct in_addr src_addr,
struct in_addr dst_addr,
- u_short id)
+ u_short id,
+ int create)
{
struct alias_link * link;
link = FindLinkOut(src_addr, dst_addr,
id, NO_DEST_PORT,
LINK_ICMP, 0);
- if (link == NULL)
+ if (link == NULL && create)
{
struct in_addr alias_addr;
@@ -1555,7 +1557,8 @@ FindUdpTcpIn(struct in_addr dst_addr,
struct in_addr alias_addr,
u_short dst_port,
u_short alias_port,
- u_char proto)
+ u_char proto,
+ int create)
{
int link_type;
struct alias_link *link;
@@ -1575,11 +1578,9 @@ FindUdpTcpIn(struct in_addr dst_addr,
link = FindLinkIn(dst_addr, alias_addr,
dst_port, alias_port,
- link_type, 1);
+ link_type, create);
- if (!(packetAliasMode & PKT_ALIAS_DENY_INCOMING)
- && !(packetAliasMode & PKT_ALIAS_PROXY_ONLY)
- && link == NULL)
+ if (link == NULL && create && !(packetAliasMode & PKT_ALIAS_DENY_INCOMING))
{
struct in_addr target_addr;
@@ -1598,7 +1599,8 @@ FindUdpTcpOut(struct in_addr src_addr,
struct in_addr dst_addr,
u_short src_port,
u_short dst_port,
- u_char proto)
+ u_char proto,
+ int create)
{
int link_type;
struct alias_link *link;
@@ -1616,9 +1618,9 @@ FindUdpTcpOut(struct in_addr src_addr,
break;
}
- link = FindLinkOut(src_addr, dst_addr, src_port, dst_port, link_type, 1);
+ link = FindLinkOut(src_addr, dst_addr, src_port, dst_port, link_type, create);
- if (link == NULL)
+ if (link == NULL && create)
{
struct in_addr alias_addr;
@@ -1633,67 +1635,6 @@ FindUdpTcpOut(struct in_addr src_addr,
struct alias_link *
-QueryUdpTcpIn(struct in_addr dst_addr,
- struct in_addr alias_addr,
- u_short dst_port,
- u_short alias_port,
- u_char proto)
-{
- int link_type;
- struct alias_link *link;
-
- switch (proto)
- {
- case IPPROTO_UDP:
- link_type = LINK_UDP;
- break;
- case IPPROTO_TCP:
- link_type = LINK_TCP;
- break;
- default:
- return NULL;
- break;
- }
-
- link = FindLinkIn(dst_addr, alias_addr,
- dst_port, alias_port,
- link_type, 0);
-
- return(link);
-}
-
-
-struct alias_link *
-QueryUdpTcpOut(struct in_addr src_addr,
- struct in_addr dst_addr,
- u_short src_port,
- u_short dst_port,
- u_char proto)
-{
- int link_type;
- struct alias_link *link;
-
- switch (proto)
- {
- case IPPROTO_UDP:
- link_type = LINK_UDP;
- break;
- case IPPROTO_TCP:
- link_type = LINK_TCP;
- break;
- default:
- return NULL;
- break;
- }
-
- link = FindLinkOut(src_addr, dst_addr,
- src_port, dst_port,
- link_type, 0);
-
- return(link);
-}
-
-struct alias_link *
AddPptp(struct in_addr src_addr,
struct in_addr dst_addr,
struct in_addr alias_addr,
diff --git a/sys/netinet/libalias/alias_ftp.c b/sys/netinet/libalias/alias_ftp.c
index c4c323f..d5978f9 100644
--- a/sys/netinet/libalias/alias_ftp.c
+++ b/sys/netinet/libalias/alias_ftp.c
@@ -443,7 +443,7 @@ NewFtpMessage(struct ip *pip,
/* Establish link to address and port found in FTP control message. */
ftp_link = FindUdpTcpOut(true_addr, GetDestAddress(link),
- htons(true_port), 0, IPPROTO_TCP);
+ htons(true_port), 0, IPPROTO_TCP, 1);
if (ftp_link != NULL)
{
diff --git a/sys/netinet/libalias/alias_irc.c b/sys/netinet/libalias/alias_irc.c
index 8c52c1f..afd032d 100644
--- a/sys/netinet/libalias/alias_irc.c
+++ b/sys/netinet/libalias/alias_irc.c
@@ -216,10 +216,9 @@ lFOUND_CTCP:
/* Steal the FTP_DATA_PORT - it doesn't really matter, and this
would probably allow it through at least _some_
firewalls. */
- dcc_link = FindUdpTcpOut (true_addr,
- destaddr,
- true_port,
- 0, IPPROTO_TCP);
+ dcc_link = FindUdpTcpOut(true_addr, destaddr,
+ true_port, 0,
+ IPPROTO_TCP, 1);
DBprintf(("Got a DCC link\n"));
if ( dcc_link ) {
struct in_addr alias_address; /* Address from aliasing */
diff --git a/sys/netinet/libalias/alias_local.h b/sys/netinet/libalias/alias_local.h
index bd2aa75..c4292e4 100644
--- a/sys/netinet/libalias/alias_local.h
+++ b/sys/netinet/libalias/alias_local.h
@@ -78,10 +78,10 @@ void DifferentialChecksum(u_short *, u_short *, u_short *, int);
/* Internal data access */
struct alias_link *
-FindIcmpIn(struct in_addr, struct in_addr, u_short);
+FindIcmpIn(struct in_addr, struct in_addr, u_short, int);
struct alias_link *
-FindIcmpOut(struct in_addr, struct in_addr, u_short);
+FindIcmpOut(struct in_addr, struct in_addr, u_short, int);
struct alias_link *
FindFragmentIn1(struct in_addr, struct in_addr, u_short);
@@ -102,10 +102,10 @@ struct alias_link *
FindProtoOut(struct in_addr, struct in_addr, u_char);
struct alias_link *
-FindUdpTcpIn (struct in_addr, struct in_addr, u_short, u_short, u_char);
+FindUdpTcpIn (struct in_addr, struct in_addr, u_short, u_short, u_char, int);
struct alias_link *
-FindUdpTcpOut(struct in_addr, struct in_addr, u_short, u_short, u_char);
+FindUdpTcpOut(struct in_addr, struct in_addr, u_short, u_short, u_char, int);
struct alias_link *
AddPptp(struct in_addr, struct in_addr, struct in_addr, u_int16_t);
@@ -123,12 +123,6 @@ struct alias_link *
FindPptpInByPeerCallId(struct in_addr, struct in_addr, u_int16_t);
struct alias_link *
-QueryUdpTcpIn (struct in_addr, struct in_addr, u_short, u_short, u_char);
-
-struct alias_link *
-QueryUdpTcpOut(struct in_addr, struct in_addr, u_short, u_short, u_char);
-
-struct alias_link *
FindRtspOut(struct in_addr, struct in_addr, u_short, u_short, u_char);
struct in_addr
diff --git a/sys/netinet/libalias/alias_smedia.c b/sys/netinet/libalias/alias_smedia.c
index 9df0578..1cde3e6 100644
--- a/sys/netinet/libalias/alias_smedia.c
+++ b/sys/netinet/libalias/alias_smedia.c
@@ -343,7 +343,7 @@ alias_pna_out(struct ip *pip,
if ((ntohs(msg_id) == 1) || (ntohs(msg_id) == 7)) {
memcpy((char*)&port, (char*)work, 2);
pna_links = FindUdpTcpOut(pip->ip_src, GetDestAddress(link),
- port, 0, IPPROTO_UDP);
+ port, 0, IPPROTO_UDP, 1);
if (pna_links != NULL) {
#ifndef NO_FW_PUNCH
/* Punch hole in firewall */
OpenPOWER on IntegriCloud