From owner-freebsd-questions Wed Nov 12 16:31:59 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id QAA24165 for questions-outgoing; Wed, 12 Nov 1997 16:31:59 -0800 (PST) (envelope-from owner-freebsd-questions) Received: from awfulhak.demon.co.uk (awfulhak.demon.co.uk [158.152.17.1]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id QAA24157 for ; Wed, 12 Nov 1997 16:31:52 -0800 (PST) (envelope-from brian@awfulhak.org) Received: from gate.lan.awfulhak.org (localhost [127.0.0.1]) by awfulhak.demon.co.uk (8.8.7/8.8.5) with ESMTP id WAA06756; Wed, 12 Nov 1997 22:12:48 GMT Message-Id: <199711122212.WAA06756@awfulhak.demon.co.uk> X-Mailer: exmh version 2.0zeta 7/24/97 To: Feiyi Wang cc: questions@FreeBSD.ORG Subject: Re: divert socket problem In-reply-to: Your message of "Wed, 12 Nov 1997 15:05:50 EST." <346A0C1E.687@eos.ncsu.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 12 Nov 1997 22:12:48 +0000 From: Brian Somers Sender: owner-freebsd-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > Hi, there > > 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 Do you mean /sbin/ipfw add divert 50000 all from any 89 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, ....) Do you mean recvfrom() ? If so, this looks ok except for the above ipfw command. > > Thanks > > /Feiyi -- Brian , , Don't _EVER_ lose your sense of humour....