Date: Mon, 25 Jan 2010 14:16:36 +0200 From: yavuz <sakncli@gmail.com> To: freebsd-questions@freebsd.org Subject: writing divert sockets Message-ID: <97371e801001250416s1109e3c5hae98cad0db876fe3@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hi all, I have a problem while writing divert sockets. I found a simple application and modified it to compile in freebsd. Simple divert socket application only prints incomming packet and reinject packet to IP stack. My simple application and test codes are available at ( http://forums.freebsd.org/showthread.php?t=10589) I think I have a problem in reinject part, i.e writing packet back to ip stack. I have a server application listening on port 2000 and a client sends packet to port 2000. And I have a ipfw rule as: > ipfw add 1000 divert 2000 tcp from any to any 2000 In divert socket application a divert socket is created and bind to port 2000. Socket receives packet with no problem: > n=recvfrom( fd, packet, BUFSIZE, 0, (struct sockaddr_in *) sin, &sinlen); After receiving packet what I want to do is simply reinjecting packet. >n=sendto(fd, packet, n ,0, (struct sockaddr *) &sin, sinlen); Reinjecting packet is not working in my case. I miss some point:) please help me. In addition to the problem, I couldn't understand a point in man page of divert. "The port part of the socket address passed to the sendto(2) contains a tag that should be meaningful to the diversion module. In the case of ipfw(8) the tag is interpreted as the rule number after which rule processing should restart." If I change the port value of sending address to ipfw rule number, how can server receive the packet? (Assume the rule number is 1000 and server listens port 2000. ) Thanks in advance yavuzg
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?97371e801001250416s1109e3c5hae98cad0db876fe3>