From owner-freebsd-hackers Wed Jan 6 22:50:54 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id WAA15619 for freebsd-hackers-outgoing; Wed, 6 Jan 1999 22:50:54 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from ss1000.ms.mff.cuni.cz (ss1000.ms.mff.cuni.cz [195.113.19.221]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id WAA15612 for ; Wed, 6 Jan 1999 22:50:52 -0800 (PST) (envelope-from mkop5230@ss1000.ms.mff.cuni.cz) Received: from beta.ms.mff.cuni.cz (mkop5230@beta.ms.mff.cuni.cz [195.113.16.70]) by ss1000.ms.mff.cuni.cz (8.8.8/8.8.8) with ESMTP id HAA32607; Thu, 7 Jan 1999 07:50:21 +0100 Received: from localhost (mkop5230@localhost) by beta.ms.mff.cuni.cz (980427.SGI.8.8.8/8.8.8) with SMTP id HAA20874; Thu, 7 Jan 1999 07:50:21 +0100 (MET) Date: Thu, 7 Jan 1999 07:50:20 +0100 (MET) From: Milan Kopacka Reply-To: Milan Kopacka To: freebsd-hackers@FreeBSD.ORG cc: Konference o transparentni proxy Subject: Specifying local IP in connect() In-Reply-To: <199901062115.OAA27539@usr08.primenet.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi, for our school project I need to design and implement TCP/IP's connect() extension, which allows me to specify the local IP adress of TCP connection. The connect() call takes as an argument pointer to struct sockaddr_in , which is defined as follows: struct sockaddr_in { u_char sin_len; u_char sin_family; u_short sin_port; struct in_addr sin_addr; char sin_zero[8]; }; Here are 8 unused bytes, which can be easily used to extend connect() capabilites to specify both remote and local IP adresses. Such as: (the names are just for example, the idea is important here) struct sockaddr_in_connect_ext { u_char sin_len; u_char sin_family; u_short sin_port; struct in_addr sin_addr; struct in_addr local_addr; /* local IP */ char sin_pad[4]; /* 4 bytes left */ }; The memory holding former sin_zero field remains there deep enough, so I can in tcp_connect() kernel routine easily use specified local IP to be assigned to connection. The second thing I need to do is to allow incoming packets for these connections to be received and add some "goto ours" to ip_input() kernel routine. "Local" IP's which have not yet anything to do with our machine must not be forgotten. :) So the application has now a way to act like IP a.b.c.d while still being able to communicate with machine a.b.c.d. Now I see I have to explain our project goal. The project consists of implementing a fully transparent www proxy cache. Such a thing needs to catch connections going to www servers like proxy server. It also needs to initiate connections to www servers under the client IP adress. This can't be done without help of a router. Think about a situation like that. (client machines) | | ( router)----(transparent proxy) | | (WWW servers) Situation: client initiates the connection, router redirects it to proxy, proxy (acting like client) opens connection to WWW server and makes the rest of caching work. Proxy needs to communicate with both the servers under client's IP and with client under server's IP. However, this is impossible without the change (or improvement :) of TCP/IP on proxy machine, like that above. Please tell me * about the chance of thing like this to get into FreeBSD kernel * if somebody ever uses sin_zero to do some other work * any other ideas Thanks, Milan Kopacka -- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message