Date: Tue, 30 Jan 2007 00:36:38 GMT From: Paolo Pisati <piso@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 113681 for review Message-ID: <200701300036.l0U0acOw070822@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=113681 Change 113681 by piso@piso_newluxor on 2007/01/30 00:36:22 Bring tcp src port from an upper layer: this way we don't need anymore to ip_next() in ProxyEncodeIpHeader(). Affected files ... .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#36 edit .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_local.h#13 edit .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_proxy.c#15 edit Differences ... ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#36 (text+ko) ==== @@ -965,7 +965,7 @@ TcpAliasOut(struct libalias *la, struct ip *pip, int maxpacketsize, int create) { int proxy_type, error; - u_short dest_port; + u_short dest_port, src_port; u_short proxy_server_port; struct in_addr dest_address; struct in_addr proxy_server_address; @@ -975,7 +975,8 @@ LIBALIAS_LOCK_ASSERT(la); tc = (struct tcphdr *)ip_next(pip); dest_port = tc->th_dport; - + src_port = tc->th_sport; + if (create) proxy_type = ProxyCheck(la, pip, &proxy_server_address, &proxy_server_port, dest_port); @@ -1028,7 +1029,8 @@ if (proxy_type != 0) { SetProxyPort(lnk, dest_port); SetProxyAddress(lnk, dest_address); - ProxyModify(la, lnk, pip, maxpacketsize, proxy_type); + ProxyModify(la, lnk, pip, maxpacketsize, proxy_type, + src_port); tc = (struct tcphdr *)ip_next(pip); } /* Get alias address and port */ ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_local.h#13 (text+ko) ==== @@ -324,7 +324,7 @@ u_short * _proxy_server_port, u_short dst_port); void ProxyModify(struct libalias *la, struct alias_link *_lnk, struct ip *_pip, - int _maxpacketsize, int _proxy_type); + int _maxpacketsize, int _proxy_type, u_short src_port); enum alias_tcp_state { ALIAS_TCP_STATE_NOT_CONNECTED, ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_proxy.c#15 (text+ko) ==== @@ -147,7 +147,7 @@ static void RuleDelete(struct proxy_entry *); static int RuleNumberDelete(struct libalias *la, int); static void ProxyEncodeTcpStream(struct alias_link *, struct ip *, int); -static void ProxyEncodeIpHeader(struct ip *); +static void ProxyEncodeIpHeader(struct ip *, u_short sport); #ifdef _KERNEL static int @@ -480,7 +480,7 @@ } static void -ProxyEncodeIpHeader(struct ip *pip) +ProxyEncodeIpHeader(struct ip *pip, u_short sport) { #define OPTION_LEN_BYTES 8 #define OPTION_LEN_INT16 4 @@ -499,7 +499,6 @@ /* Build option and copy into packet */ { u_char *ptr; - struct tcphdr *tc; ptr = (u_char *) pip; ptr += 20; @@ -510,8 +509,7 @@ memcpy(&option[2], (u_char *) & pip->ip_dst, 4); - tc = (struct tcphdr *)ip_next(pip); - memcpy(&option[6], (u_char *) & tc->th_sport, 2); + memcpy(&option[6], (u_char *) & sport, 2); memcpy(ptr, option, 8); } @@ -599,10 +597,8 @@ } void -ProxyModify(struct libalias *la, struct alias_link *lnk, - struct ip *pip, - int maxpacketsize, - int proxy_type) +ProxyModify(struct libalias *la, struct alias_link *lnk, struct ip *pip, + int maxpacketsize, int proxy_type, u_short src_port) { LIBALIAS_LOCK_ASSERT(la); @@ -610,7 +606,7 @@ switch (proxy_type) { case PROXY_TYPE_ENCODE_IPHDR: - ProxyEncodeIpHeader(pip); + ProxyEncodeIpHeader(pip, src_port); break; case PROXY_TYPE_ENCODE_TCPSTREAM:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701300036.l0U0acOw070822>