4 #include <sys/socket.h>
8 #include <linux/if_tun.h>
10 #define AF_IPN AF_NETBEUI
13 #define IPN_BROADCAST 1
15 #define IPN_VDESWITCH 2
16 #define IPN_VDESWITCH_L3 3
18 #define IPN_SO_PREBIND 0x80
20 #define IPN_SO_DESCR 1
21 #define IPN_SO_MTU (IPN_SO_PREBIND | 0)
22 #define IPN_SO_NUMNODES (IPN_SO_PREBIND | 1)
23 #define IPN_SO_MSGPOOLSIZE (IPN_SO_PREBIND | 2)
24 #define IPN_SO_FLAGS (IPN_SO_PREBIND | 3)
25 #define IPN_SO_MODE (IPN_SO_PREBIND | 4)
28 #define IPN_SETPERSIST_NETDEV _IOW('I', 200, int)
29 #define IPN_CLRPERSIST_NETDEV _IOW('I', 201, int)
30 #define IPN_CONN_NETDEV _IOW('I', 202, int)
31 #define IPN_JOIN_NETDEV _IOW('I', 203, int)
32 #define IPN_SETPERSIST _IOW('I', 204, int)
34 #define IPN_NODEFLAG_TAP 0x10 /* This is a tap interface */
35 #define IPN_NODEFLAG_GRAB 0x20 /* This is a grab of a real interface */
37 #define IPN_PORTNO_ANY -1
39 #define IPN_DESCRLEN 32
41 #define IPN_FLAG_LOSSLESS 1
44 struct sockaddr_un sun
={.sun_family
=AF_IPN
,.sun_path
="/tmp/sockipn"};
47 //int s=socket(AF_IPN,SOCK_RAW,IPN_BROADCAST);
48 int s
=socket(AF_IPN
,SOCK_RAW
,IPN_BROADCAST
);
51 int flags
=IPN_FLAG_LOSSLESS
;
59 err=setsockopt(s,0,IPN_SO_FLAGS,&flags,sizeof(flags));
62 err=setsockopt(s,0,IPN_SO_MSGPOOLSIZE,&size,sizeof(size));
65 err=setsockopt(s,0,IPN_SO_MODE,&mode,sizeof(mode));
69 err
=bind(s
,(struct sockaddr
*)&sun
,sizeof(sun
));
73 err=connect(s,NULL,0);
75 memset(&ifr
, 0, sizeof(ifr
));
76 strncpy(ifr
.ifr_name
, "eth0", IFNAMSIZ
);
77 ifr
.ifr_flags
=IPN_NODEFLAG_GRAB
;
78 err
=ioctl(s
, IPN_CONN_NETDEV
, (void *) &ifr
);
81 while ((len
=read(0,buf
,256)) > 0) {
82 //err=write(s,buf,len);