On Sat, 1 Nov 2008, Julian Elischer wrote:

I'll try answer your questions..

Hooks are created on demand..
you need to send a 'connect' or 'mkpeer' message to the node(s)
on which you want t script level, you just use the ngctl program
to do it for you.

Hooks are always made in pairs. so you need two nodes to connect.
The mkpeer message does this for you, and creates a new node and connects them together by two hooks of the names you specify.

Have you looked at the sample netgraph scripts in /usr/share/examples/netgraph?


Yep, I've looked at those but if I recall they are all scripts. I am looking for some C or C++ example. Basically on the userland side I have something like:

#include <..>
#include <netgraph/ng_socket.h>

int main () {
  int s1 = socket (PF_NETGRAPH, SOCK_DGRAM, NG_CONTROL)
  int s2 = socket (PF_NETGRAPH, SOCK_DGRAM, NG_DATA)
  bind(...);

}

This gives me a node with a name, set with bind, of type socket and no hooks.

The kernel module I don't have any netgraph code yet but I figure it will involve a set of calls similar to the userland program. So if I want to interact with the socket the userland program created, what kind of node do I create in the module? Another ng_socket or a ng_ksocket or something different. Then how do I go about connecting the two hooks?

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?

for fun you could use the ng_echo node type which would send everything you want back to you..

Alternatively when you kldload the ng-ether node type, then all the ethernets will grow nodes to match them so you can connect to them directly.

You could connect an ng_bpf (packet filter) node to the ng_ether node
and pass specific packets only on to the socket.


I'll look into this for the other half of what I am playing with. I looked at bpf by itself and it seemed to me it made a copy of the packet, with the original continuing up the stack rather than diverting the packet. But I am getting ahead of myself. I'd like to get the userland <-> module part together first. :) And all the example code are scripts. Am I missing someting?

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.

not sure what netlink does..
(will look on google :-)


Thanks for your help, there is a reasonable entry in the wiki about it.

---jdp
_______________________________________________
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to