4 #include <sys/socket.h>
8 #include <linux/if_tun.h>
12 struct sockaddr_un sun
={.sun_family
=AF_IPN
,.sun_path
="/tmp/sockipn"};
15 int s
=socket(AF_IPN
,SOCK_RAW
,IPN_BROADCAST
);
16 //int s=socket(AF_IPN,SOCK_RAW,IPN_VDESWITCH);
19 int flags
=IPN_FLAG_LOSSLESS
;
27 err=setsockopt(s,0,IPN_SO_FLAGS,&flags,sizeof(flags));
30 err=setsockopt(s,0,IPN_SO_MSGPOOLSIZE,&size,sizeof(size));
33 err=setsockopt(s,0,IPN_SO_MODE,&mode,sizeof(mode));
37 err
=bind(s
,(struct sockaddr
*)&sun
,sizeof(sun
));
41 err=connect(s,NULL,0);
43 memset(&ifr
, 0, sizeof(ifr
));
44 strncpy(ifr
.ifr_name
, "ipn0", IFNAMSIZ
);
45 ifr
.ifr_flags
=IPN_NODEFLAG_TAP
;
46 err
=ioctl(s
, IPN_CONN_NETDEV
, (void *) &ifr
);
49 while ((len
=read(0,buf
,256)) > 0) {
50 /*err=write(s,buf,len);
52 perror("write sock");*/