From owner-freebsd-net@FreeBSD.ORG Sun Nov 2 22:38:05 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 8E9F4106568A for ; Sun, 2 Nov 2008 22:38:05 +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 3796C8FC19 for ; Sun, 2 Nov 2008 22:38:04 +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 mA2Mc45p029869; Sun, 2 Nov 2008 17:38:04 -0500 (EST) Received: from localhost (jdp@localhost) by elvis.rowan.edu (8.13.8+Sun/8.13.8/Submit) with ESMTP id mA2Mc33J029865; Sun, 2 Nov 2008 17:38:03 -0500 (EST) Date: Sun, 2 Nov 2008 17:38:03 -0500 (EST) From: Joe Pellegrino To: Julian Elischer In-Reply-To: <490D0CFB.5040102@elischer.org> Message-ID: References: <490CEF11.4010007@elischer.org> <490D0CFB.5040102@elischer.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-net@freebsd.org Subject: Re: 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: Sun, 02 Nov 2008 22:38:05 -0000 On Sat, 1 Nov 2008, Julian Elischer wrote: > Joe Pellegrino wrote: >> On Sat, 1 Nov 2008, Julian Elischer wrote: >> > have you done man 3 netgraph to look at the netgraph management library? > Looked at that today and I might be able to get something going. I tried to use the ng_echo node in a module. The code looked something like this: #include #include #include #include #include #include #include #include extern struct ng_type typestruct; static int event_handler(struct module *module, int event, void *arg) { int e = 0; /* Error, 0 for normal return status */ switch (event) { case MOD_LOAD: uprintf("Hello Free Software Magazine Readers! \n"); ng_newtype(&typestruct); break; case MOD_UNLOAD: uprintf("Bye Bye FSM reader, be sure to check http://freesoftwar emagazine.com !\n"); break; default: e = EOPNOTSUPP; /* Error, Operation Not Supported */ break; } return(e); } /* The second argument of DECLARE_MODULE. */ static moduledata_t hello_conf = { "hello_fsm", /* module name */ event_handler, /* event handler */ NULL /* extra data */ }; DECLARE_MODULE(hello_fsm, hello_conf, SI_SUB_DRIVERS, SI_ORDER_MIDDLE); However, trying to load this module results in: # kldload ./hello_fsm.ko kldload: can't load ./hello_fsm.ko: No such file or directory So to start, how can I use ng_echo in a module? According to the man 4 of netgraph the ng_newtype should construct a new node right? And I presume once I get that module running and an ng_echo module loaded, I'll try to communicate with it from userspace but what about the above is incorrect? Thanks. :) ---jdp > for example programs, see: > /usr/src/usr.sbin/nghook > /usr/src/usr.sbin/ngctl > /usr/ports/net/mpd (you'll need to download the sources with "make") > >