From c93d494562c83aeaf960ba067bc0e9c1abcc2f2d Mon Sep 17 00:00:00 2001 From: ru Date: Wed, 12 Apr 2000 18:44:50 +0000 Subject: Make partially specified permanent links without `dst_addr' but with `dst_port' work for outgoing packets. This case was not handled properly when I first fixed this in revision 1.17. This change is also required for the upcoming improved PPTP support patches -- that is how I found the problem. Before this change: # natd -v -a aliasIP \ -redirect_port tcp localIP:localPORT publicIP:publicPORT 0:remotePORT Out [TCP] [TCP] localIP:localPORT -> remoteIP:remotePORT aliased to [TCP] aliasIP:localPORT -> remoteIP:remotePORT After this change: # natd -v -a aliasIP \ -redirect_port tcp localIP:localPORT publicIP:publicPORT 0:remotePORT Out [TCP] [TCP] localIP:localPORT -> remoteIP:remotePORT aliased to [TCP] publicIP:publicPORT -> remoteIP:remotePORT --- lib/libalias/alias_db.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'lib/libalias/alias_db.c') diff --git a/lib/libalias/alias_db.c b/lib/libalias/alias_db.c index b0a2642..86223cd 100644 --- a/lib/libalias/alias_db.c +++ b/lib/libalias/alias_db.c @@ -1046,25 +1046,29 @@ _FindLinkOut(struct in_addr src_addr, } /* Search for partially specified links. */ - if (link == NULL) + if (link == NULL && replace_partial_links) { - if (dst_port != 0) + if (dst_port != 0 && dst_addr.s_addr != INADDR_ANY) { link = _FindLinkOut(src_addr, dst_addr, src_port, 0, link_type, 0); - if (link != NULL && replace_partial_links) - { - link = ReLink(link, - src_addr, dst_addr, link->alias_addr, - src_port, dst_port, link->alias_port, - link_type); - } + if (link == NULL) + link = _FindLinkOut(src_addr, nullAddress, src_port, + dst_port, link_type, 0); } - else if (dst_addr.s_addr != 0) + if (link == NULL && + (dst_port != 0 || dst_addr.s_addr != INADDR_ANY)) { link = _FindLinkOut(src_addr, nullAddress, src_port, 0, link_type, 0); } + if (link != NULL) + { + link = ReLink(link, + src_addr, dst_addr, link->alias_addr, + src_port, dst_port, link->alias_port, + link_type); + } } return(link); @@ -1228,7 +1232,7 @@ _FindLinkIn(struct in_addr dst_addr, } } -struct alias_link * +static struct alias_link * FindLinkIn(struct in_addr dst_addr, struct in_addr alias_addr, u_short dst_port, -- cgit v1.1