Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Nov 2008 17:38:03 -0500 (EST)
From:      Joe Pellegrino <jdp@elvis.rowan.edu>
To:        Julian Elischer <julian@elischer.org>
Cc:        freebsd-net@freebsd.org
Subject:   Re: A netgraph question.
Message-ID:  <Pine.GSO.4.64.0811021729030.23578@elvis.rowan.edu>
In-Reply-To: <490D0CFB.5040102@elischer.org>
References:  <Pine.GSO.4.64.0811011759200.4676@elvis.rowan.edu> <490CEF11.4010007@elischer.org> <Pine.GSO.4.64.0811012107200.7887@elvis.rowan.edu> <490D0CFB.5040102@elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <sys/param.h>
#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/mbuf.h>

#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_echo.h>

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")
>
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.64.0811021729030.23578>