Wirefilter: new markov mode (see man page)
[vde.git] / ipn / test / test0.c
blobe01f4904abe5d7de5c2ef9d98e6a64fe673c52a4
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 AF_NETBEUI
8 #define PF_IPN AF_IPN
9 #define IPN_ANY 0
10 #define IPN_BROADCAST 1
11 #define IPN_HUB 1
12 #define IPN_VDESWITCH 2
13 #define IPN_VDESWITCH_L3 3
15 #define IPN_SO_PREBIND 0x80
16 #define IPN_SO_PORT 0
17 #define IPN_SO_DESCR 1
18 #define IPN_SO_MTU (IPN_SO_PREBIND | 0)
19 #define IPN_SO_NUMNODES (IPN_SO_PREBIND | 1)
20 #define IPN_SO_MSGPOOLSIZE (IPN_SO_PREBIND | 2)
21 #define IPN_SO_FLAGS (IPN_SO_PREBIND | 3)
22 #define IPN_SO_MODE (IPN_SO_PREBIND | 4)
24 #define IPN_PORTNO_ANY -1
26 #define IPN_DESCRLEN 32
28 #define IPN_FLAG_LOSSLESS 1
30 char buf[256];
31 struct sockaddr_un sun={.sun_family=AF_IPN,.sun_path="/tmp/sockipn"};
32 main()
34 int s=socket(AF_IPN,SOCK_RAW,IPN_BROADCAST);
35 int err;
36 int len;
37 int flags=IPN_FLAG_LOSSLESS;
38 int size=128;
39 int mode=0770;
40 if (s< 0) {
41 s=socket(AF_IPN,SOCK_RAW,IPN_BROADCAST);
42 if (s< 0)
43 perror("socket");
45 printf("s=%d\n",s);
46 #if 0
47 err=setsockopt(s,0,IPN_SO_FLAGS,&flags,sizeof(flags));
48 if (err<0)
49 perror("setsockopt");
50 err=setsockopt(s,0,IPN_SO_MSGPOOLSIZE,&size,sizeof(size));
51 if (err<0)
52 perror("setsockopt");
53 #endif
54 err=setsockopt(s,0,IPN_SO_MODE,&mode,sizeof(mode));
55 if (err<0)
56 perror("setsockopt");
57 err=bind(s,(struct sockaddr *)&sun,sizeof(sun));
58 if (err<0)
59 perror("bind");
60 err=connect(s,NULL,0);
61 if (err<0)
62 perror("connect");
63 while ((len=read(0,buf,256)) > 0) {
64 err=write(s,buf,len);
65 if (err<0)
66 perror("write sock");
68 if (len < 0)
69 perror("read stdin");
70 close(s);