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 same node. I thought to do it with the ng_socket node type. I’ve written a program that creates two sockets (data and control) as reported in “All about netgraph”. Then I’ve 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 = -1, s_data = -1; struct sockaddr_ng *sg; s_control = socket(PF_NETGRAPH,SOCK_DGRAM,NG_CONTROL); strcpy(sg->sg_data,"SOCKET"); sg->sg_family = AF_NETGRAPH; sg->sg_len = strlen(sg->sg_data) + 1 + NGSA_OVERHEAD; bind(s_control,(struct sockaddr *)sg,sg->sg_len)<0); … 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 _______________________________________________ freebsd-net@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"