From owner-freebsd-questions Sun Jul 16 4:13:32 2000 Delivered-To: freebsd-questions@freebsd.org Received: from dire.bris.ac.uk (dire.bris.ac.uk [137.222.10.60]) by hub.freebsd.org (Postfix) with ESMTP id 6D9B037B5FD for ; Sun, 16 Jul 2000 04:10:19 -0700 (PDT) (envelope-from Jan.Grant@bristol.ac.uk) Received: from mail.ilrt.bris.ac.uk by dire.bris.ac.uk with SMTP-PRIV with ESMTP; Sun, 16 Jul 2000 12:10:17 +0100 Received: from localhost (cmjg@localhost) by mail.ilrt.bris.ac.uk (8.8.7/8.8.8) with ESMTP id MAA00751; Sun, 16 Jul 2000 12:10:16 +0100 (BST) Date: Sun, 16 Jul 2000 12:10:16 +0100 (BST) From: Jan Grant To: Jan Grant Cc: nimrodm@email.com, freebsd-questions@freebsd.org Subject: Re: DIVERT sockets In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, 16 Jul 2000, Jan Grant wrote: > On Sat, 15 Jul 2000, Nimrod Mesika wrote: > > > 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; > > I don't know what DIVERT_PORT is defined as, but you may need > > htons(DIVERT_PORT) > > (and strictly speaking, htonl(INADDR_ANY) if memory serves) > > - have you checked what socket the process appears to be listening on > when it runs? Actually, you might also want to check that the must-be-zero bytes in addr really are zero; bzero(&addr, sizeof addr) before you use it. I was bitten by this on FBSD recently; trying the code on "other Unix{-a-like} systems" demonstrated a more lax attitude to unused parts of the address structure. In other words, make sure than bind() isn't failing. jan -- jan grant, ILRT, University of Bristol. http://www.ilrt.bris.ac.uk/ Tel +44(0)117 9287163 Fax +44 (0)117 9287112 RFC822 jan.grant@bris.ac.uk My "5k award" entry: http://tribble.ilrt.bris.ac.uk/~cmjg/test/small.html To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message