From owner-freebsd-net@FreeBSD.ORG Wed Nov 19 13:14:25 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 53AC716A4CE; Wed, 19 Nov 2003 13:14:25 -0800 (PST) Received: from blake.polstra.com (dsl081-189-066.sea1.dsl.speakeasy.net [64.81.189.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4889843FBF; Wed, 19 Nov 2003 13:14:22 -0800 (PST) (envelope-from jdp@polstra.com) Received: from strings.polstra.com (dsl081-189-067.sea1.dsl.speakeasy.net [64.81.189.67]) by blake.polstra.com (8.12.9p2/8.12.9) with ESMTP id hAJLEL8b087450; Wed, 19 Nov 2003 13:14:21 -0800 (PST) (envelope-from jdp@polstra.com) Message-ID: X-Mailer: XFMail 1.5.4 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20031119070745.GE10828@blossom.cjclark.org> Date: Wed, 19 Nov 2003 13:14:21 -0800 (PST) From: John Polstra To: "Crist J. Clark" X-Bogosity: No, tests=bogofilter, spamicity=0.326135, version=0.14.5 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 List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Nov 2003 21:14:25 -0000 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. John