Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Nov 1997 16:24:22 -0800 (PST)
From:      Archie Cobbs <archie@whistle.com>
To:        fwang2@eos.ncsu.edu (Feiyi Wang)
Cc:        questions@FreeBSD.ORG
Subject:   Re: divert socket problem
Message-ID:  <199711130024.QAA11868@bubba.whistle.com>
In-Reply-To: <346A0C1E.687@eos.ncsu.edu> from Feiyi Wang at "Nov 12, 97 03:05:50 pm"

next in thread | previous in thread | raw e-mail | index | archive | help

Feiyi Wang writes:
> 
> I am playing with DIVERT socket. Basically, I want to divert a
> particular protocol stream to another port, and read it from my program.
> The firewall rules I am using is pretty simple. 89 is the protocol
> number.
> 
> /sbin/ipfw -f flush
> /sbin/ipfw divert 50000 89 from any to any
> /sbin/ipfw pass all from any to any
> 
> From /sbin/ipfw show, I can see there ARE packets which match the rule 2
> and diverted. But I can't read anything, recvfrom() blocks.  Am I
> missing something here? Anybody can help me out?
> 
> sockfd = socket(AF_INET,SOCK_RAW, IPPROTO_DIVERT)
> 
> addr.sin_family = AF_INET
> addr.sin_addr.s_addr=INADDR_ANY
> addr.sin_port=50000 
> 
> bind(sockfd, (struct sockaddr *)&addr, sizeof addr)
> 
> readfrom(sockfd, ....)

Hmm.. it looks like this should work alright.

 1. Did you compile your kernel with "options DIVERT" ?
 2. Are you checking the return values from socket(), bind(), readfrom()..?

If #1 and #2 are OK (sounds like it), then..

 3. What version of FreeBSD are you using?

-Archie

___________________________________________________________________________
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com



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