Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Jul 2000 18:44:27 +0300
From:      Nimrod Mesika <nimrodm@bezeqint.net>
To:        freebsd-questions@freebsd.org
Subject:   DIVERT sockets
Message-ID:  <20000715184427.A1771@localhost.bsd.net.il>

next in thread | raw e-mail | index | archive | help
I'm trying to divert all TCP traffic to/from a certain remote site to
my box. IPFW show lists the following rules:

00050    20     1200 divert 8000 tcp from 212.179.173.176 to 206.168.112.90
00060     0        0 divert 8000 tcp from 206.168.112.90 to 212.179.173.176
00100  2308   635572 allow ip from any to any via lo0
00200     0        0 deny ip from any to 127.0.0.0/8
65000 32247 18345055 allow ip from any to any
65535     0        0 deny ip from any to any

Where 212... is my local address and 206... is the remote address (just
an example). As you can see 20 packets should have been diverted to 
socket 8000.

In my program I use the following code (taken from natd) to receive the
packets:

divertInOut = socket (PF_INET, SOCK_RAW, IPPROTO_DIVERT);
addr.sin_family     = AF_INET;
addr.sin_addr.s_addr= INADDR_ANY;
addr.sin_port       = DIVERT_PORT;
bind(divertInOut, (struct sockaddr*) &addr, sizeof addr);

origBytes = recvfrom (fd, packetBuf, sizeof packetBuf, 0,
                  (struct sockaddr*) &packetAddr, &addrSize);

.. but I get nothing!

Any ideas what I'm doing wrong? Should I be sending this to freebsd-net
mailing list?

-- Nimrod.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000715184427.A1771>