IPN patch updated with the module for 2.6.25.4
[vde.git] / ipn / test / test1.c
blob0ff1b725a776b80aed570dc8eceb420ff2180d48
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 char buf[256];
18 struct sockaddr_un sun={.sun_family=AF_IPN,.sun_path="/tmp/sockipn"};
19 main()
21 int s=socket(AF_IPN,SOCK_RAW,IPN_BROADCAST);
22 int err;
23 int len;
24 if (s< 0) {
25 s=socket(AF_IPNS,SOCK_RAW,IPN_BROADCAST);
26 if (s< 0)
27 perror("socket");
29 printf("s=%d\n",s);
30 err=connect(s,(struct sockaddr *)&sun,sizeof(sun));
31 if (err<0)
32 perror("connect");
33 while ((len=read(s,buf,256)) > 0) {
34 write(1,buf,len);
36 if (len < 0)
37 perror("read");
38 close(s);