From owner-freebsd-questions@FreeBSD.ORG Sat Nov 1 23:21:07 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AF1F9106567B for ; Sat, 1 Nov 2008 23:21:07 +0000 (UTC) (envelope-from bryant.eadon@gmail.com) Received: from mail-gx0-f13.google.com (mail-gx0-f13.google.com [209.85.217.13]) by mx1.freebsd.org (Postfix) with ESMTP id 47B138FC1A for ; Sat, 1 Nov 2008 23:21:06 +0000 (UTC) (envelope-from bryant.eadon@gmail.com) Received: by gxk6 with SMTP id 6so351270gxk.19 for ; Sat, 01 Nov 2008 16:21:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=FLyY2FlWIFr7bjc8ylapo72+IIrTYVM6Hah7neym4IY=; b=Qn7a/FZsC43N+XNTw0y1aGndjE/eKZZZ1JfuexXXv3DFbVASqw9bnwRVhedk6OtgAb EzsYaerUkRfBvmbXMvPzwnZN0dxoMu04+h4kMRZ1qLqNdkJ9GPNN5Lzz293UZcXeYN4q 0aDipOFergJu19gU402auRDqeG+U+CNmF0+Dg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=pVmgJgtZJQnuOwMFx3Z8ok2klM1cKd4bI8iQT8HwwOiwAmLr2QPUcKgcpWMfqMLyvW zciebg6ni0CQQ9+WhxNTqkMWixbWJGPBELOysX832AAKP02AtMrIOnPfE3rJT+3iptGh kk0Lusdm+iL3kvkc6ipOwDYNR+BlVzqx5Vgl0= Received: by 10.151.145.21 with SMTP id x21mr23690907ybn.218.1225581665983; Sat, 01 Nov 2008 16:21:05 -0700 (PDT) Received: from ?192.168.1.4? (itsf207.itsnpt.com [64.119.85.207]) by mx.google.com with ESMTPS id m73sm4804348rnd.0.2008.11.01.16.21.04 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 01 Nov 2008 16:21:05 -0700 (PDT) Message-ID: <490CE454.2020800@gmail.com> Date: Sat, 01 Nov 2008 19:20:52 -0400 From: Bryant Eadon User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: Joe Pellegrino References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: A netgraph question. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: bryant.eadon@gmail.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Nov 2008 23:21:07 -0000 Joe Pellegrino wrote: 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 > Have you looked into how "systat -ifstat" works ?