From owner-freebsd-net@FreeBSD.ORG Wed Nov 19 18:42:14 2003 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B8BB116A4CF for ; Wed, 19 Nov 2003 18:42:14 -0800 (PST) Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [216.148.227.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id C1F1543FDF for ; Wed, 19 Nov 2003 18:42:13 -0800 (PST) (envelope-from cristjc@comcast.net) Received: from blossom.cjclark.org (c-24-6-186-224.client.comcast.net[24.6.186.224]) by comcast.net (rwcrmhc12) with ESMTP id <2003112002421301400ejh2ae>; Thu, 20 Nov 2003 02:42:13 +0000 Received: from blossom.cjclark.org (localhost. [127.0.0.1]) by blossom.cjclark.org (8.12.9p2/8.12.8) with ESMTP id hAK2gWsb048984; Wed, 19 Nov 2003 18:42:32 -0800 (PST) (envelope-from cristjc@comcast.net) Received: (from cjc@localhost) by blossom.cjclark.org (8.12.9p2/8.12.9/Submit) id hAK2gWOX048983; Wed, 19 Nov 2003 18:42:32 -0800 (PST) (envelope-from cristjc@comcast.net) X-Authentication-Warning: blossom.cjclark.org: cjc set sender to cristjc@comcast.net using -f Date: Wed, 19 Nov 2003 18:42:32 -0800 From: "Crist J. Clark" To: John Polstra Message-ID: <20031120024232.GB48914@blossom.cjclark.org> References: <20031119070745.GE10828@blossom.cjclark.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i X-URL: http://people.freebsd.org/~cjc/ cc: net@freebsd.org Subject: Re: netgraph(3) NGM_KSOCKET_BIND X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: cjc@freebsd.org List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Nov 2003 02:42:14 -0000 On Wed, Nov 19, 2003 at 01:14:21PM -0800, John Polstra wrote: > On 19-Nov-2003 Crist J. Clark wrote: > > OK, an easy one. I am trying to do some netgraph(3) coding in > > userland. From how I read the documentation, this should work. Before > > I go learn all of the netraph(4) kernel code to understand the error > > message, could someone tell me how this is supposed to look? I'm sure > > it's something obvious that I have missed. > > > > The attached test program returns, > > > > # ./ngtest > > ngtest: failed to bind ksocket: Invalid argument > [...] > > bzero(&laddr, sizeof laddr); > > laddr.sin_family = AF_INET; > > laddr.sin_addr.s_addr = INADDR_ANY; > > laddr.sin_port = htons(DEFAULT_PORT); > > if (NgSendMsg(cs, OUR_HOOK_CTL, NGM_KSOCKET_COOKIE, NGM_KSOCKET_BIND, > > &laddr, sizeof laddr) == -1) > > err(errno, "failed to bind ksocket"); > > I think the problem might be that you forgot to set the "sin_len" > member of the sockaddr_in struct. I don't see anything else > glaringly wrong. Duh. That was it. Thanks. I didn't think I had messed up the sockaddr_in because I stuck a plain ol' bind(2) call in there as a test, and it worked. It didn't seem to care I forgot to set sin_len. -- Crist J. Clark | cjclark@alum.mit.edu | cjclark@jhu.edu http://people.freebsd.org/~cjc/ | cjc@freebsd.org