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
43 /*#define IPNTYPE IPN_BROADCAST*/
44 #define IPNTYPE IPN_VDESWITCH
47 struct sockaddr_un sun
={.sun_family
=AF_IPN
,.sun_path
="/tmp/sockipn"};
50 int s
=socket(AF_IPN
,SOCK_RAW
,IPNTYPE
);
51 int s2
=socket(AF_IPN
,SOCK_RAW
,IPNTYPE
);
54 int flags
=IPN_FLAG_LOSSLESS
;
62 err=setsockopt(s,0,IPN_SO_FLAGS,&flags,sizeof(flags));
65 err=setsockopt(s,0,IPN_SO_MSGPOOLSIZE,&size,sizeof(size));
68 err=setsockopt(s,0,IPN_SO_MODE,&mode,sizeof(mode));
72 err
=bind(s
,(struct sockaddr
*)&sun
,sizeof(sun
));
75 err
=bind(s2
,(struct sockaddr
*)&sun
,sizeof(sun
));
79 err=connect(s,NULL,0);
81 memset(&ifr
, 0, sizeof(ifr
));
82 strncpy(ifr
.ifr_name
, "eth1", IFNAMSIZ
);
83 ifr
.ifr_flags
=IPN_NODEFLAG_GRAB
;
84 err
=ioctl(s
, IPN_CONN_NETDEV
, (void *) &ifr
);
87 memset(&ifr
, 0, sizeof(ifr
));
88 strncpy(ifr
.ifr_name
, "ipn1", IFNAMSIZ
);
89 ifr
.ifr_flags
=IPN_NODEFLAG_TAP
;
90 err
=ioctl(s2
, IPN_CONN_NETDEV
, (void *) &ifr
);
94 while ((len
=read(0,buf
,256)) > 0) {
95 //err=write(s,buf,len);
100 perror("read stdin");