bugfix: reference to local var was erroneously returned
[vde.git] / ipn / test / test0n.c
blob48ed3efc59623871bbae8a639d7c2e6000466f40
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 s=socket(AF_IPN,SOCK_RAW,IPN_VDESWITCH);
36 int err;
37 int len;
38 int flags=IPN_FLAG_LOSSLESS;
39 int size=128;
40 int mode=0770;
41 if (s< 0)
42 perror("socket");
43 printf("s=%d\n",s);
44 #if 0
45 err=setsockopt(s,0,IPN_SO_FLAGS,&flags,sizeof(flags));
46 if (err<0)
47 perror("setsockopt");
48 err=setsockopt(s,0,IPN_SO_MSGPOOLSIZE,&size,sizeof(size));
49 if (err<0)
50 perror("setsockopt");
51 err=setsockopt(s,0,IPN_SO_MODE,&mode,sizeof(mode));
52 if (err<0)
53 perror("setsockopt");
54 #endif
55 err=bind(s,(struct sockaddr *)&sun,sizeof(sun));
56 if (err<0)
57 perror("bind");
58 #if 0
59 err=connect(s,NULL,0);
60 if (err<0)
61 perror("connect");
62 #endif
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);