From owner-freebsd-hackers Mon Dec 8 07:00:20 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id HAA12195 for hackers-outgoing; Mon, 8 Dec 1997 07:00:20 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from loki.csc.ncsu.edu (loki.csc.ncsu.edu [152.1.213.138]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id HAA12174 for ; Mon, 8 Dec 1997 07:00:09 -0800 (PST) (envelope-from fwang2@unity.ncsu.edu) Received: from localhost (fwang2@localhost) by loki.csc.ncsu.edu (8.8.4/EC02Jan97) with SMTP id JAA17022; Mon, 8 Dec 1997 09:54:54 -0500 (EST) X-Authentication-Warning: loki.csc.ncsu.edu: fwang2 owned process doing -bs Date: Mon, 8 Dec 1997 09:54:53 -0500 (EST) From: Feiyi Wang X-Sender: fwang2@loki.csc.ncsu.edu To: Ruslan Ermilov cc: hackers@FreeBSD.ORG Subject: Re: help: divert sockets question In-Reply-To: <199712081231.OAA07525@relay.ucb.crimea.ua> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Hi, It will work. Here is the way I did it -- snip -- /* this is readIncoming() */ inbytes = recvfrom( fd, inPacketBuf, sizeof inPacketBuf, 0, (struct sockaddr*) &inPacketAddr, &addrsize); /* this is writeIncoming() */ writeIncoming(int fd) { int wrote; wrote = sendto( fd, inPacketBuf, inPacketLen, 0, (struct sockaddr *) &inPacketAddr, sizeof inPacketAddr); if ( wrote != inPacketLen ) fprintf(stderr, "failed to write packet back\n"); else return wrote; } On Mon, 8 Dec 1997, Ruslan Ermilov wrote: > Hi, Hackers! > > I'm in process of writing a small `iptunnel' program > which lets me tunnel IP traffic thru UDP. > > My program uses two sockets: UDP and divert. > > It reads IP-packet from divert socket and > sends it to the remote machine thru UDP. > Remote machine then reads it from UDP and > reinjects the IP-packet by writing it to the > divert socket. > > And vice versa. > > It works greatly! > > Problem: > > I want to reinject received thru UDP IP-packet > as incoming. `man ipdivert' says that I should > use sendto() syscall with a destination address > equal to IP address of some my local interface. > > I did it and it doesn't works. > > It seems to me like a kernel is just dropping such a packet. > But no error returned from sendto(), no packets travel > thru the firewall. > > Can anyone point me a way to write packet as incoming? > Should I change some IP-packet fields? > > TIA, > -- > Ruslan A. Ermilov System Administrator > ru@ucb.crimea.ua United Commercial Bank > +380-652-247647 Simferopol, Crimea > 2426679 ICQ Network, UIN >