4 #include <sys/socket.h>
8 #include <linux/if_tun.h>
11 /*#define IPNTYPE IPN_BROADCAST*/
12 #define IPNTYPE IPN_VDESWITCH
15 struct sockaddr_un sun
={.sun_family
=AF_IPN
,.sun_path
="/tmp/sockipn"};
18 int s
=socket(AF_IPN
,SOCK_RAW
,IPNTYPE
);
19 int s2
=socket(AF_IPN
,SOCK_RAW
,IPNTYPE
);
22 int flags
=IPN_FLAG_LOSSLESS
;
30 err=setsockopt(s,0,IPN_SO_FLAGS,&flags,sizeof(flags));
33 err=setsockopt(s,0,IPN_SO_MSGPOOLSIZE,&size,sizeof(size));
36 err=setsockopt(s,0,IPN_SO_MODE,&mode,sizeof(mode));
40 err
=bind(s
,(struct sockaddr
*)&sun
,sizeof(sun
));
43 err
=bind(s2
,(struct sockaddr
*)&sun
,sizeof(sun
));
47 err=connect(s,NULL,0);
49 memset(&ifr
, 0, sizeof(ifr
));
50 strncpy(ifr
.ifr_name
, "eth1", IFNAMSIZ
);
51 ifr
.ifr_flags
=IPN_NODEFLAG_GRAB
;
52 err
=ioctl(s
, IPN_CONN_NETDEV
, (void *) &ifr
);
55 memset(&ifr
, 0, sizeof(ifr
));
56 strncpy(ifr
.ifr_name
, "ipn1", IFNAMSIZ
);
57 ifr
.ifr_flags
=IPN_NODEFLAG_TAP
;
58 err
=ioctl(s2
, IPN_CONN_NETDEV
, (void *) &ifr
);
62 while ((len
=read(0,buf
,256)) > 0) {
63 //err=write(s,buf,len);