Date: Tue, 18 Nov 2003 23:07:45 -0800 From: "Crist J. Clark" <cristjc@comcast.net> To: net@freebsd.org Subject: netgraph(3) NGM_KSOCKET_BIND Message-ID: <20031119070745.GE10828@blossom.cjclark.org>
next in thread | raw e-mail | index | archive | help
OK, an easy one. I am trying to do some netgraph(3) coding in userland. From how I read the documentation, this should work. Before I go learn all of the netraph(4) kernel code to understand the error message, could someone tell me how this is supposed to look? I'm sure it's something obvious that I have missed. The attached test program returns, # ./ngtest ngtest: failed to bind ksocket: Invalid argument The program, #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netinet/in_systm.h> #include <netinet/ip.h> #include <netgraph.h> #include <netgraph/ng_ksocket.h> #include <netgraph/ng_message.h> #include <netgraph/ng_tee.h> #include <err.h> #include <errno.h> #include <stdio.h> #include <string.h> #define DEFAULT_PORT 10000 #define OUR_HOOK_CTL "ctl_hook" int main() { int cs, ds; struct sockaddr_in laddr; struct ngm_mkpeer ngmkp; if (NgMkSockNode(NULL, &cs, &ds) == -1) err(errno, "failed to create netgraph socket"); strcpy(ngmkp.type, NG_KSOCKET_NODE_TYPE); strcpy(ngmkp.ourhook, OUR_HOOK_CTL); strcpy(ngmkp.peerhook, "inet/dgram/udp"); if (NgSendMsg(cs, ".", NGM_GENERIC_COOKIE, NGM_MKPEER, &ngmkp, sizeof ngmkp) == -1) err(errno, "failed to create ksocket node"); bzero(&laddr, sizeof laddr); laddr.sin_family = AF_INET; laddr.sin_addr.s_addr = INADDR_ANY; laddr.sin_port = htons(DEFAULT_PORT); if (NgSendMsg(cs, OUR_HOOK_CTL, NGM_KSOCKET_COOKIE, NGM_KSOCKET_BIND, &laddr, sizeof laddr) == -1) err(errno, "failed to bind ksocket"); return 0; } -- Crist J. Clark | cjclark@alum.mit.edu | cjclark@jhu.edu http://people.freebsd.org/~cjc/ | cjc@freebsd.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031119070745.GE10828>