Clean up unused variables.
[vde.git] / ipn / test / test2.c
blobbc016e77bc0ffd45600588ec021ccef9c312c4ef
1 #include <stdio.h>
2 #include <errno.h>
3 #include <sys/types.h>
4 #include <sys/socket.h>
5 #include <sys/un.h>
6 #include <sys/ioctl.h>
7 #include <linux/if.h>
8 #include <linux/if_tun.h>
9 #include <af_ipn.h>
11 char buf[256];
12 struct sockaddr_un sun={.sun_family=AF_IPN,.sun_path="/tmp/sockipn"};
13 main()
15 int s=socket(AF_IPN,SOCK_RAW,IPN_BROADCAST);
16 //int s=socket(AF_IPN,SOCK_RAW,IPN_VDESWITCH);
17 int err;
18 int len;
19 int flags=IPN_FLAG_LOSSLESS;
20 int size=128;
21 int mode=0770;
22 struct ifreq ifr;
23 if (s< 0)
24 perror("socket");
25 printf("s=%d\n",s);
27 err=setsockopt(s,0,IPN_SO_FLAGS,&flags,sizeof(flags));
28 if (err<0)
29 perror("setsockopt");
30 err=setsockopt(s,0,IPN_SO_MSGPOOLSIZE,&size,sizeof(size));
31 if (err<0)
32 perror("setsockopt");
33 err=setsockopt(s,0,IPN_SO_MODE,&mode,sizeof(mode));
34 if (err<0)
35 perror("setsockopt");
37 err=bind(s,(struct sockaddr *)&sun,sizeof(sun));
38 if (err<0)
39 perror("bind");
41 err=connect(s,NULL,0);
43 memset(&ifr, 0, sizeof(ifr));
44 strncpy(ifr.ifr_name, "ipn0", IFNAMSIZ);
45 ifr.ifr_flags=IPN_NODEFLAG_TAP;
46 err=ioctl(s, IPN_CONN_NETDEV, (void *) &ifr);
47 if (err<0)
48 perror("connect");
49 while ((len=read(0,buf,256)) > 0) {
50 /*err=write(s,buf,len);
51 if (err<0)
52 perror("write sock");*/
54 if (len < 0)
55 perror("read stdin");
56 close(s);