IPN patch updated with the module for 2.6.25.4
[vde.git] / ipn / test / test0.c
bloba9d2c430bd9345915871e2df9e9ae4382ccd0baf
1 #include <stdio.h>
2 #include <errno.h>
3 #include <sys/types.h>
4 #include <sys/socket.h>
5 #include <sys/un.h>
7 #define AF_IPN 34
8 #define PF_IPN AF_IPN
9 #define AF_IPNS AF_NETBEUI
10 #define PF_IPNS AF_IPNS
11 #define IPN_ANY 0
12 #define IPN_BROADCAST 1
13 #define IPN_HUB 1
14 #define IPN_VDESWITCH 2
15 #define IPN_VDESWITCH_L3 3
17 #define IPN_SO_PREBIND 0x80
18 #define IPN_SO_PORT 0
19 #define IPN_SO_DESCR 1
20 #define IPN_SO_MTU (IPN_SO_PREBIND | 0)
21 #define IPN_SO_NUMNODES (IPN_SO_PREBIND | 1)
22 #define IPN_SO_MSGPOOLSIZE (IPN_SO_PREBIND | 2)
23 #define IPN_SO_FLAGS (IPN_SO_PREBIND | 3)
24 #define IPN_SO_MODE (IPN_SO_PREBIND | 4)
26 #define IPN_PORTNO_ANY -1
28 #define IPN_DESCRLEN 32
30 #define IPN_FLAG_LOSSLESS 1
32 char buf[256];
33 struct sockaddr_un sun={.sun_family=AF_IPN,.sun_path="/tmp/sockipn"};
34 main()
36 int s=socket(AF_IPN,SOCK_RAW,IPN_BROADCAST);
37 int err;
38 int len;
39 int flags=IPN_FLAG_LOSSLESS;
40 int size=128;
41 int mode=0770;
42 if (s< 0) {
43 s=socket(AF_IPNS,SOCK_RAW,IPN_BROADCAST);
44 if (s< 0)
45 perror("socket");
47 printf("s=%d\n",s);
48 #if 0
49 err=setsockopt(s,0,IPN_SO_FLAGS,&flags,sizeof(flags));
50 if (err<0)
51 perror("setsockopt");
52 err=setsockopt(s,0,IPN_SO_MSGPOOLSIZE,&size,sizeof(size));
53 if (err<0)
54 perror("setsockopt");
55 #endif
56 err=setsockopt(s,0,IPN_SO_MODE,&mode,sizeof(mode));
57 if (err<0)
58 perror("setsockopt");
59 err=bind(s,(struct sockaddr *)&sun,sizeof(sun));
60 if (err<0)
61 perror("bind");
62 err=connect(s,NULL,0);
63 if (err<0)
64 perror("connect");
65 while ((len=read(0,buf,256)) > 0) {
66 err=write(s,buf,len);
67 if (err<0)
68 perror("write sock");
70 if (len < 0)
71 perror("read stdin");
72 close(s);