Date: Sun, 4 Jan 2009 17:27:12 +0000 (UTC) From: Paolo Pisati <piso@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r186742 - user/piso/sys/netinet/libalias Message-ID: <200901041727.n04HRCTW063867@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: piso Date: Sun Jan 4 17:27:11 2009 New Revision: 186742 URL: http://svn.freebsd.org/changeset/base/186742 Log: -protect kernel code only with _KERNEL -move FindSctpRedirectAddress to alias_local.h together with all the others Find* functions -style Modified: user/piso/sys/netinet/libalias/alias.h user/piso/sys/netinet/libalias/alias_db.c user/piso/sys/netinet/libalias/alias_local.h user/piso/sys/netinet/libalias/alias_sctp.c Modified: user/piso/sys/netinet/libalias/alias.h ============================================================================== --- user/piso/sys/netinet/libalias/alias.h Sun Jan 4 17:26:59 2009 (r186741) +++ user/piso/sys/netinet/libalias/alias.h Sun Jan 4 17:27:11 2009 (r186742) @@ -36,13 +36,6 @@ * distribution. */ -/** - * Modifications to add sctp functionality by David A. Hayes - * $Id: alias.h 122 2008-06-25 06:50:47Z dhayes $ - * All are inclosed in #ifdef _ALIAS_SCTP - * - */ - #ifndef _ALIAS_H_ #define _ALIAS_H_ @@ -52,11 +45,6 @@ #define LIBALIAS_BUF_SIZE 128 #ifdef _KERNEL - -#ifndef _ALIAS_SCTP -#define _ALIAS_SCTP //if ALIAS_SCTP code is to be included -#endif - /* * The kernel version of libalias does not support these features. */ Modified: user/piso/sys/netinet/libalias/alias_db.c ============================================================================== --- user/piso/sys/netinet/libalias/alias_db.c Sun Jan 4 17:26:59 2009 (r186741) +++ user/piso/sys/netinet/libalias/alias_db.c Sun Jan 4 17:27:11 2009 (r186742) @@ -141,12 +141,6 @@ __FBSDID("$FreeBSD$"); See HISTORY file for additional revisions. */ -/** - * Modifications to add sctp functionality by David A. Hayes - * $Id: alias_db.c 177 2008-07-14 04:33:47Z dhayes $ - * All are inclosed in #ifdef _ALIAS_SCTP - * - */ #ifdef _KERNEL @@ -173,9 +167,6 @@ __FBSDID("$FreeBSD$"); #include <netinet/libalias/alias.h> #include <netinet/libalias/alias_local.h> #include <netinet/libalias/alias_mod.h> -#ifdef _ALIAS_SCTP -#include <netinet/libalias/alias_sctp.h> -#endif #include <net/if.h> #else #include "alias.h" @@ -383,7 +374,6 @@ static moduledata_t alias_mod = { }; DECLARE_MODULE(alias, alias_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND); - #endif /* Internal utility routines (used only in alias_db.c) @@ -421,10 +411,6 @@ static void ClearFWHole(struct alias_lin static void ShowAliasStats(struct libalias *); static int InitPacketAliasLog(struct libalias *); static void UninitPacketAliasLog(struct libalias *); -#ifdef _ALIAS_SCTP -struct in_addr FindSctpRedirectAddress(struct libalias *la, struct sctp_nat_msg *sm); -void SctpShowAliasStats(struct libalias *la); -#endif static u_int StartPointIn(struct in_addr alias_addr, @@ -504,25 +490,17 @@ ShowAliasStats(struct libalias *la) /* Used for debugging */ if (la->logDesc) { int tot = la->icmpLinkCount + la->udpLinkCount + -#ifdef _ALIAS_SCTP (la->sctpLinkCount>>1) + /* sctp counts half associations */ -#endif la->tcpLinkCount + la->pptpLinkCount + la->protoLinkCount + la->fragmentIdLinkCount + la->fragmentPtrLinkCount; AliasLog(la->logDesc, -#ifdef _ALIAS_SCTP "icmp=%u, udp=%u, tcp=%u, sctp=%u, pptp=%u, proto=%u, frag_id=%u frag_ptr=%u / tot=%u", -#else - "icmp=%u, udp=%u, tcp=%u, pptp=%u, proto=%u, frag_id=%u frag_ptr=%u / tot=%u", -#endif la->icmpLinkCount, la->udpLinkCount, la->tcpLinkCount, -#ifdef _ALIAS_SCTP la->sctpLinkCount>>1, /* sctp counts half associations */ -#endif la->pptpLinkCount, la->protoLinkCount, la->fragmentIdLinkCount, @@ -533,13 +511,6 @@ ShowAliasStats(struct libalias *la) } } -#ifdef _ALIAS_SCTP -void SctpShowAliasStats(struct libalias *la) -{ - ShowAliasStats(la); -} -#endif - /* Internal routines for finding, deleting and adding links Port Allocation: @@ -1003,10 +974,6 @@ AddLink(struct libalias *la, struct in_a case LINK_TCP: lnk->expire_time = TCP_EXPIRE_INITIAL; break; -#ifdef _ALIAS_SCTP - case LINK_SCTP: /* treat like LINK_ADDR */ - break; -#endif case LINK_PPTP: lnk->flags |= LINK_PERMANENT; /* no timeout. */ break; @@ -1067,10 +1034,6 @@ AddLink(struct libalias *la, struct in_a return (NULL); } break; -#ifdef _ALIAS_SCTP - case LINK_SCTP: /* treat like LINK_ADDR */ - break; -#endif case LINK_PPTP: la->pptpLinkCount++; break; @@ -1317,17 +1280,17 @@ _FindLinkIn(struct libalias *la, struct src_addr = lnk->src_addr; src_port = lnk->src_port; } -#ifdef _ALIAS_SCTP - if(link_type == LINK_SCTP) { +#ifdef _KERNEL + if (link_type == LINK_SCTP) { lnk->src_addr = src_addr; lnk->src_port = src_port; return(lnk); } #endif - lnk = ReLink(lnk, - src_addr, dst_addr, alias_addr, - src_port, dst_port, alias_port, - link_type); + lnk = ReLink(lnk, + src_addr, dst_addr, alias_addr, + src_port, dst_port, alias_port, + link_type); } return (lnk); } @@ -2323,7 +2286,7 @@ LibAliasRedirectPort(struct libalias *la case IPPROTO_TCP: link_type = LINK_TCP; break; -#ifdef _ALIAS_SCTP +#ifdef _KERNEL case IPPROTO_SCTP: link_type = LINK_SCTP; break; @@ -2547,8 +2510,8 @@ LibAliasInit(struct libalias *la) LIST_INIT(&la->linkTableOut[i]); for (i = 0; i < LINK_TABLE_IN_SIZE; i++) LIST_INIT(&la->linkTableIn[i]); -#ifdef _ALIAS_SCTP - AliasSctpInit(la);//*** +#ifdef _KERNEL + AliasSctpInit(la); #endif LIBALIAS_LOCK_INIT(la); LIBALIAS_LOCK(la); @@ -2557,7 +2520,7 @@ LibAliasInit(struct libalias *la) la->deleteAllLinks = 1; CleanupAliasData(la); la->deleteAllLinks = 0; -#ifdef _ALIAS_SCTP +#ifdef _KERNEL AliasSctpTerm(la); AliasSctpInit(la); #endif @@ -2569,9 +2532,7 @@ LibAliasInit(struct libalias *la) la->icmpLinkCount = 0; la->udpLinkCount = 0; la->tcpLinkCount = 0; -#ifdef _ALIAS_SCTP la->sctpLinkCount = 0; -#endif la->pptpLinkCount = 0; la->protoLinkCount = 0; la->fragmentIdLinkCount = 0; @@ -2600,7 +2561,7 @@ LibAliasUninit(struct libalias *la) { LIBALIAS_LOCK(la); -#ifdef _ALIAS_SCTP +#ifdef _KERNEL AliasSctpTerm(la); #endif la->deleteAllLinks = 1; @@ -2943,7 +2904,7 @@ LibAliasSetSkinnyPort(struct libalias *l la->skinnyPort = port; LIBALIAS_UNLOCK(la); } -#ifdef _ALIAS_SCTP + /** * @brief Find the address to redirect incoming packets * @@ -2978,4 +2939,3 @@ FindSctpRedirectAddress(struct libalias return(redir); /* address redirect */ } } -#endif Modified: user/piso/sys/netinet/libalias/alias_local.h ============================================================================== --- user/piso/sys/netinet/libalias/alias_local.h Sun Jan 4 17:26:59 2009 (r186741) +++ user/piso/sys/netinet/libalias/alias_local.h Sun Jan 4 17:27:11 2009 (r186742) @@ -42,12 +42,6 @@ * * <updated several times by original author and Eivind Eklund> */ -/** - * Modifications to add sctp functionality by David A. Hayes - * $Id: alias_local.h 122 2008-06-25 06:50:47Z dhayes $ - * All are inclosed in #ifdef _ALIAS_SCTP - * - */ #ifndef _ALIAS_LOCAL_H_ #define _ALIAS_LOCAL_H_ @@ -56,16 +50,6 @@ #include <sys/sysctl.h> #ifdef _KERNEL -/* if alias_sctp is not required, #define _ALIAS_SCTP should be commented out */ -#ifndef _ALIAS_SCTP -#define _ALIAS_SCTP -#endif -#ifdef _ALIAS_SCTP -#include <netinet/libalias/alias_sctp.h> -#endif -#endif - -#ifdef _KERNEL #include <sys/malloc.h> #include <sys/param.h> #include <sys/lock.h> @@ -73,6 +57,10 @@ /* XXX: LibAliasSetTarget() uses this constant. */ #define INADDR_NONE 0xffffffff + +#include <netinet/libalias/alias_sctp.h> +#else +#include "alias_sctp.h" #endif /* Sizes of input and output link tables */ @@ -163,33 +151,29 @@ struct libalias { struct in_addr true_addr; /* in network byte order. */ u_short true_port; /* in host byte order. */ - /* - * - *alias_sctp code - */ -#ifdef _ALIAS_SCTP - /*counts associations that have progressed to UP and not yet removed */ - int sctpLinkCount; - /*Timing queue for keeping track of association timeouts */ - struct sctp_nat_timer sctpNatTimer; - - /* Size of hash table used in this instance*/ - u_int sctpNatTableSize; -/** - * @brief Local look up table - * - * lookup table of sctp_nat_assoc sorted by l_vtag/l_port - */ - LIST_HEAD(sctpNatTableL, sctp_nat_assoc) *sctpTableLocal; -/** - * @brief Global look up table - * - * lookup table of sctp_nat_assoc sorted by g_vtag/g_port - */ - LIST_HEAD(sctpNatTableG, sctp_nat_assoc) *sctpTableGlobal; -#endif + /* + * sctp code support + */ + + /* counts associations that have progressed to UP and not yet removed */ + int sctpLinkCount; #ifdef _KERNEL + /* timing queue for keeping track of association timeouts */ + struct sctp_nat_timer sctpNatTimer; + + /* size of hash table used in this instance */ + u_int sctpNatTableSize; + +/* + * local look up table sorted by l_vtag/l_port + */ + LIST_HEAD(sctpNatTableL, sctp_nat_assoc) *sctpTableLocal; +/* + * global look up table sorted by g_vtag/g_port + */ + LIST_HEAD(sctpNatTableG, sctp_nat_assoc) *sctpTableGlobal; + /* * avoid races in libalias: every public function has to use it. */ @@ -240,21 +224,13 @@ struct libalias { /* Prototypes */ - /* - * - *alias_sctp code - */ -#ifdef _ALIAS_SCTP /* * SctpFunction prototypes * */ void AliasSctpInit(struct libalias *la); void AliasSctpTerm(struct libalias *la); - int SctpAlias(struct libalias *la, struct ip *ip, int direction); -//int SctpAliasOut(struct libalias *la, struct ip *ip); -#endif /* * We do not calculate TCP checksums when libalias is a kernel @@ -322,6 +298,8 @@ struct in_addr FindOriginalAddress(struct libalias *la, struct in_addr _alias_addr); struct in_addr FindAliasAddress(struct libalias *la, struct in_addr _original_addr); +struct in_addr +FindSctpRedirectAddress(struct libalias *la, struct sctp_nat_msg *sm); /* External data access/modification */ int Modified: user/piso/sys/netinet/libalias/alias_sctp.c ============================================================================== --- user/piso/sys/netinet/libalias/alias_sctp.c Sun Jan 4 17:26:59 2009 (r186741) +++ user/piso/sys/netinet/libalias/alias_sctp.c Sun Jan 4 17:27:11 2009 (r186742) @@ -189,22 +189,6 @@ static void SctpAliasLog(const char *for */ void SctpShowAliasStats(struct libalias *la); -/** @ingroup external - * @brief Find the address to redirect incoming packets - * - * This function is defined in alias_db.c, since it calls static functions in - * this file - * - * Given a destination port for incoming packets to the NAT, discover what - * (if any) internal IP address this packet should be re-directed to - * - * @param la Pointer to the libalias instance - * @param sm Pointer to the incoming message - * - * @return Address to redirect an incoming INIT to - */ -struct in_addr FindSctpRedirectAddress(struct libalias *la, struct sctp_nat_msg *sm); - #ifdef _KERNEL MALLOC_DEFINE(M_SCTPNAT, "sctpnat", "sctp nat dbs");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901041727.n04HRCTW063867>