From: Chris F. <cfr...@no...> - 2004-06-14 22:06:58
|
I'm running 2.6.5 on a dual Powermac G5, with tipc from CVS as of last week some time. 1) I tried testing modified versions of the connectionless client/server from the pdf documentation. Code for these is below. I ran the server first with no problems. When I ran the client, the system hung, no logs were dumped. Any ideas what's going on? 2) Is there any way to eavesdrop on tipc messages? Wildcard registration or anything like that? I'm thinking of something that would be able to dump the contents of all tipc messages seen by a node whether they be inter- or intra- node. Thanks, Chris source code: //client #include <sys/types.h> #include <sys/socket.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <sys/param.h> #include <sys/poll.h> #include <netdb.h> #include <errno.h> #include <fcntl.h> #include <assert.h> #include <tipc.h> int client_sd; //struct name_availability server_subscr = {17777,0,10000}; struct pollfd pfd; char buf[64] = {'T','I','P','C',' ','R','U','L','E','S',0}; int main(int argc, char* argv[], char* dummy[]) { int i; // int tipc_fd = open ("/dev/tipc", O_RDWR); // assert(tipc_fd >= 0); printf("TIPC Client started,waiting for server...\n"); // if(!ioctl(tipc_fd,WAIT_FOR_NAME,&server_subscr)) // assert(!"Server not published"); struct sockaddr_tipc server_addr; server_addr.family = AF_TIPC; server_addr.addrtype = TIPC_ADDR_NAME; server_addr.scope = TIPC_CLUSTER_SCOPE; server_addr.addr.name.name.type = 17777; server_addr.addr.name.name.instance = 0; client_sd = socket(AF_TIPC, SOCK_DGRAM,0); if (0 > sendto(client_sd,buf,strlen(buf)+1,0,(struct sockaddr*)&server_addr,sizeof(server_addr))) assert(!"Send Failed"); printf("TIPC Client sent %i octets connectionless message: %s\n",strlen(buf)+1,buf); pfd.fd = client_sd; pfd.events = 0xffff; if ((poll(&pfd,1,2000000) <= 0) ||(pfd.revents > POLLIN)) { printf("%x\n", pfd.revents); assert(!"Unexpected poll event\n"); } if ((strlen(buf)+1) != recv(client_sd,buf,64, 0)) assert(!"Received wrong size\n"); printf ("TIPC Client received connectionless response msg: %s \n\n",buf); } //server #include <sys/types.h> #include <sys/socket.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <sys/param.h> #include <sys/poll.h> #include <netdb.h> #include <errno.h> #include <fcntl.h> #include <assert.h> #include <tipc.h> char buf[64]; int server_sd; struct sockaddr_tipc client_addr; int msglen; struct pollfd pfd; int addrlen = {sizeof(client_addr)}; int main(int argc, char* argv[], char* dummy[]) { struct sockaddr_tipc server_addr; server_addr.family = AF_TIPC; server_addr.addrtype = TIPC_ADDR_NAME; server_addr.scope = TIPC_CLUSTER_SCOPE; server_addr.addr.name.name.type = 17777; server_addr.addr.name.name.instance = 0; printf("TIPC Server started\n"); server_sd = socket (AF_TIPC, SOCK_DGRAM,0); if (bind (server_sd,(struct sockaddr*)&server_addr,addrlen)) assert(!"Failed to bind\n"); pfd.fd = server_sd; pfd.events = 0xffff; while (1) { if ((poll(&pfd,1,2000000) <= 0)||(pfd.revents > POLLIN)) assert(!"Unexpected poll event\n"); msglen = recvfrom(server_sd,buf,64,0,(struct sockaddr*)&client_addr,&addrlen); if (0 > sendto(server_sd,buf,msglen,0,(struct sockaddr*)&client_addr,addrlen)) assert(!"Send Failed"); printf ("TIPC Server received and responded to connectionless msg: %s\n\n",buf); } } |