Date: Tue, 13 Apr 2010 16:41:08 +0200 From: serena zanetta <sz3003@gmail.com> To: freebsd-net@freebsd.org Subject: kernel - userspace communication, ng_socket Message-ID: <t2hb2ecfd381004130741xf2d5b93cw2264b292dc1f9d7e@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
I have a question involving the userspace and kernel communication. I need to get a point where I can exchange data between netgraph nodes and = a program in the userland. I have a netgraph node which receives network packets and sends them to the program to be processed. The modified packets are then sent back to the sam= e node. I thought to do it with the ng_socket node type. I=92ve written a program t= hat creates two sockets (data and control) as reported in =93All about netgraph= =94. Then I=92ve tried to assign the node a name with bind(), as follow: #include <stdio.h> #include <errno.h> #include <netdb.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <ctype.h> #include <err.h> #include <stddef.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netgraph/ng_socket.h> #define NGSA_OVERHEAD (offsetof(struct sockaddr_ng, sg_data)) int main() { int s_control =3D -1, s_data =3D -1; struct sockaddr_ng *sg; s_control =3D socket(PF_NETGRAPH,SOCK_DGRAM,NG_CONTROL); strcpy(sg->sg_data,"SOCKET"); sg->sg_family =3D AF_NETGRAPH; sg->sg_len =3D strlen(sg->sg_data) + 1 + NGSA_OVERHEAD; bind(s_control,(struct sockaddr *)sg,sg->sg_len)<0); =85 return 0; } If I look at ngctl to verify the ng_socket creation, no trace of it can be found. So I don't know how to proceed .. any suggestion? Thank you, Serena
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?t2hb2ecfd381004130741xf2d5b93cw2264b292dc1f9d7e>