From owner-freebsd-net@FreeBSD.ORG Sat Nov 1 22:15:36 2008 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 99EF51065670 for ; Sat, 1 Nov 2008 22:15:36 +0000 (UTC) (envelope-from jdp@elvis.rowan.edu) Received: from elvis.rowan.edu (elvis.rowan.edu [150.250.64.69]) by mx1.freebsd.org (Postfix) with ESMTP id 5F8308FC19 for ; Sat, 1 Nov 2008 22:15:36 +0000 (UTC) (envelope-from jdp@elvis.rowan.edu) Received: from elvis.rowan.edu (localhost [127.0.0.1]) by elvis.rowan.edu (8.13.8+Sun/8.13.8) with ESMTP id mA1Lxd0T004692 for ; Sat, 1 Nov 2008 17:59:39 -0400 (EDT) Received: from localhost (jdp@localhost) by elvis.rowan.edu (8.13.8+Sun/8.13.8/Submit) with ESMTP id mA1LxdY5004686 for ; Sat, 1 Nov 2008 17:59:39 -0400 (EDT) Date: Sat, 1 Nov 2008 17:59:39 -0400 (EDT) From: Joe Pellegrino To: freebsd-net@freebsd.org Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Subject: A netgraph question. X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Nov 2008 22:15:36 -0000 OK so here it goes. I actually have two seperate questions involving netgraph, I am new to this subject so please bare with me. If there is a better way to achieve these goals too, please suggest them but I think netgraph is the way to go. The first part involves allowing a userland program to communicate with a kernel module, similar to how netlink works in Linux. The second part involves intercepting network packets and possibly manipulating them before they are allowed to proceed, similar to how netfilter works. I believe I can do both of these with the netgraph (ng_socket and possibly ng_ether). I haven't looked closely at ng_ether yet so I'll focus on ng_socket. I have been able to create a ng_socket (Control and Data) using the socket call as described in "All About NetGraphs" and the man page. I've also been able to 'name' the node using bind. I was able to verify this using ngctl. I know (from the man page) I should eventually be able to send/receive using the sendto/recvfrom functions once the connection is established. But beyond this I don't know how to proceed. So the question is what are the next steps. For example: Although I see a named netgraph node there are no hooks. ng_socket says it supports an arbitrary number of hooks so how do I create the hooks? Then of course how do I connect them. Of course I realize that I proabably need to create a node on the kernel side so which type of netgraph node would be suggested? How is it created and then hooked to the ng_socket? Again I am looking to allow some IPC between a userland program and a kernel module similar to the Linux netlink. I've been through most man pages and can't seem to find a lot of good documentation or example code so I am hoping to get some pointers here. BTW If this is the wrong list please directly to the right place to ask. Thanks in advance. ---jdp