<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">$B$*@$OC$K$J$C$F$*$j$^$9!#(B<br><div><div>On 2009/09/28, at 12:24, Yasushi SHOJI wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>$B$$$/$D$+<ALd$5$;$F$/$@$5$$!#(B<br><br>At Sat, 26 Sep 2009 15:55:39 +0900,<br>joshua45 wrote:<br><blockquote type="cite"><br></blockquote><blockquote type="cite">$B$^$:!"$I$&$b%G%#%P%$%9L>$O(Btun0$B$G$O$J$/(Btunl0$B$H$J$k(B <br></blockquote><blockquote type="cite">$B$h$&$G$9!#$3$l$G(Bifconfig $B$O=PMh$k>uBV$K$J$j$^$7$?!#(B<br></blockquote><blockquote type="cite">$B$3$l$O!"(Bmknod$BEy$r$7$J$/$F$b2DG=$G$9!#(B<br></blockquote><br> - mknod$BEy$K!"(Bopen(2)$B$O4^$^$l$^$9!)(B<br></div></blockquote><div><br></div><div>$BL@<(E*$K(Bmknod$B$9$kJ}K!$G$O!"(B</div><div>$B$3$l$O%3%^%s%I%i%$%s$+$iBG$A$^$7$?!#%7%'%k$N%3%^%s%I$G$9!#(B</div><div><div> mkdir /dev/net</div><div> mknod /dev/net/tun c 10 200</div><div><br></div><div>$B$H$$$&6q9g$G$9!#(Budev$B$rMxMQ$9$k>l9g$O!"Nc$N%U%!%$%k$KA0%a!<%k$N$h$&$K5-=R$7$?$H$$$&$3$H$G$9!#(B</div></div><br><blockquote type="cite"><div> - device node $B$O!"(B/dev$B0J2<$G$9$+!"$=$l$H$b(B /dev/net$B0J2<$G$9$+!)(B<br> - device driver$B$r(B load $B$7$J$/$F$b(B device node$B$OB8:_$7$^$9$+!)(B<br><br></div></blockquote><div><br></div><div>$B%G%#%P%$%9$r0l;~E*$K%m!<%I$7$J$$$h$&$K$9$k$N$O$I$&$7$?$iNI$$$G$7$g$&$+!#(B</div><div>$BM=A[$H$7$F$O%m!<%I$7$J$/$F$b!">e5-$N=hM}$r$9$l$P!"%G%#%P%$%9%N!<%I$OB8:_$7$F$$$k$N$G$O$J$$$+$H;W$o$l$^$9!#(B</div><br><blockquote type="cite"><div><blockquote type="cite">1. $B$J$K$b$7$J$$$G(BTUN$B$r;H$C$?%"%W%j%1!<%7%g%s$r$I$&$5$5(B <br></blockquote><blockquote type="cite">$B$;$?>l9g(B<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">open("/dev/net/tun",O_RDWR);<br></blockquote><blockquote type="cite">$B$G!"(B<br></blockquote><blockquote type="cite">No such file or directory ...<br></blockquote><blockquote type="cite">$B$H$J$j$^$9!#(B<br></blockquote><br>$B!V$J$K$b!W$H$$$&$N$O!"(B</div></blockquote><blockquote type="cite"><div><br> - mknod?<br> - insmod?<br></div></blockquote><div><br></div><div>$B$3$l$O!"%G%#%P%$%9$r%$%s%9%H!<%k$7$?$@$1$G$=$NB>$N:n6H$O$7$J$$!"$H$$$&>uBV$G$9!#(Bmknod,insmod$B$b(Budev$B$N@_Dj$b$7$J$$>uBV$G!"(B</div><div>$B%G%P%$%9$N%m!<%I8e!"(B</div><div>C$B$N%W%m%0%i%`$G(Bopen("/dev....");$B$@$1$r9T$&$H$$$&$3$H$G$9!#(B</div><div><br></div><br><blockquote type="cite"><div><br><blockquote type="cite">2. $B<jF0$G(B/dev/net/tun$B$r:n$kJ}K!(B<br></blockquote><blockquote type="cite">$B%I%-%e%a%s%F!<%7%g%s$K$"$kDL$j<jF0$G!"(B<br></blockquote><blockquote type="cite">mknod /dev/net/tun c 10 100<br></blockquote><blockquote type="cite">$B$r9T$C$F$_$^$7$?$H$3$m!"(Bopen$B$O@.8y$7$^$9$,!"$=$N8e$N(B <br></blockquote><blockquote type="cite">ioctl$B$G(BInvalid argument $B$K$J$j$^$9!#(Bx86 linux$B>e$G(B <br></blockquote><blockquote type="cite">$B$O$&$^$/$$$C$F$$$k%3!<%I$J$N$G!"(Bioctl$B$N0z?t$,(Barm$B$HB>$N(B <br></blockquote><blockquote type="cite">linux$B$G0[$J$k$H$+$"$k$N$+$I$&$+(B....$B!#(B<br></blockquote><br>/dev/net/tunl0 $B$K$9$k$H@5$7$/F0$/$,!">e5-$NJ}K!$G$O(B<br>$BF0$+$J$$$H$$$&$3$H$G$9$+!)(B<br></div></blockquote><div><br></div><div>open("/dev/net/tunl0"...)$B$O$O$M$i$l$F$$$^$9!#$"!"$G$b!"(B</div><div>open("/dev/net/tunl",....)$B$O3N$+$a$F$$$^$;$s!#$3$l$O$d$k2ACM$,$"$k$+$b$7$l$^$;$s!#(B</div><br><blockquote type="cite"><div><br><blockquote type="cite">3. udev$B$r;H$&J}K!(B<br></blockquote><blockquote type="cite">$B0JA0$N(Byashi$B$5$s$N%a!<%k$K=>$C$F!"(Budev$B$K(B/dev/ <br></blockquote><blockquote type="cite">net($B%G%#%l%/%H%j(B)$B$H(B/dev/net/tun $B$rDI2C$7$^$7$?!#(B<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">/dev/net d 755 0 0 - - - <br></blockquote><blockquote type="cite">- -<br></blockquote><blockquote type="cite">/dev/net/tun c 755 0 0 10 200 - <br></blockquote><blockquote type="cite">- -<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">$B$3$l$G%+!<%M%k$H(Bromfs$B$r:F%m!<%I$7$^$7$?!#$J$<$+%+!<%M%k$H(B <br></blockquote><blockquote type="cite">romfs$B$N%;%C%H$r#2%;%C%H%m!<%I$9$k$H$A$c$s$H8+$($k$h$&$K$J$j$^$7(B <br></blockquote><blockquote type="cite">$B$?(B....$B!#(B<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">$B$3$l$G%"%W%j%1!<%7%g%s$rF0$+$9$H(Bopen$B$N$H$3$m$G!"(B<br></blockquote><blockquote type="cite">No such device<br></blockquote><blockquote type="cite">$B$H$$$&%(%i!<$,=P$^$9!#(BNo such file or directory $B$H$O$J(B <br></blockquote><blockquote type="cite">$B$i$J$$$N$O!"(B/dev/net/tun$B$,0l1~%G%P%$%9$H$7$FEPO?$5$l$F(B <br></blockquote><blockquote type="cite">$B$$$k$H$$$&$3$H$J$N$+!)(B<br></blockquote><br>$B$I$3$+$G!"(BENOENT$B$G$O$J$/(B ENODEV$B$,La$C$F$$$k$H$$$&$3$H$J$N$G$9$,!E!#(B<br><br></div></blockquote><div><br></div><div>open("/dev/net/tun",...)$B$GLa$C$F$-$F$$$k$3$H$O3N$+$a$F$$$^$9!#(B</div><br><blockquote type="cite"><div>mknod(1)$B$7$F$b(B udev$B$,(B mknod(2)$B$r$7$F$b5sF0$,0[$J$k$3$H$OL5$$$O$:$G$9!#(B<br></div></blockquote><div><br></div><div>$B$=$&;W$&$s$G$9$,(B.....$B!#(B</div><br><blockquote type="cite"><div>ifconfig$B$,@.8y$9$k>l9g$H!"$7$J$$>e5-$N(B3$B$D$NJ}K!$G$O!"L>A0$,(B tunl$B$H$J$k(B<br>$B$3$H0J30!"0c$$$O$"$j$^$;$s$+!)(B</div></blockquote><br></div><div>$B$$$d!"$$$:$l$b(Bifconfig tunl0 $B$O@.8y$7$^$9!#$^$?!"$$$:$l$b!"(Bifconfig tun0$B!!$O@.8y$7$^$;$s!#(B</div><div><br></div><div>$B$^$:$O$A$g$C$H!"(B</div><div>open("/dev/net/tunl",....)</div><div>$B$3$l$r3N$+$a$F$_$^$9!#(B</div><div><br></div><div>$B?9!!$R$m$R$5(B</div><div><br></div><div><br></div><div>$B!a!a!a!a!a!a!a!a!a!a!a!a!a!a!a!a!a!a!a!a!a!a!a!a!a!a!a!a!a!a(B</div><div>$B;29M$^$G$K;H$C$F$$$k%"%W%j%1!<%7%g%s$N%3!<%I$G$9!#4pK\E*$K(BTUN/TAP$B$N%[!<%`%Z!<%8$+$i$H$C$F$-$?J*$J$N$G!"(BGPL$B$G$7$g$&!#(B</div><div><br></div><div>$B$3$l$r!"(B</div><div><span class="Apple-style-span" style="font-family: Monaco; font-size: 10px; ">tun_open_common("tunl0",1)</span></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;">$B$G8F$S=P$7$F$$$^$9!#(B</span></font></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;">$B:G=i$K(Bopen("/dev/net/tun")$B$,8F$S=P$5$l%(%i!<$,$G$k$H!"(Bopen("/dev/tunl0")$B$,8F$S=P$5$l$k$h$&$K$J$C$F$$$^$9$,!"B?J,$3$l$O%(%i!<$K$J$k$G$7$g$&!#(B</span></font></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;">$B$I$3$G%(%i!<$K$J$C$?$+$O!"$=$NETEY(Bfprintf$B$,F~$C$F$$$k$N$G$3$l$G$o$+$k$h$&$K$J$C$F$$$^$9!#(B</span></font></div><div><br></div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); ">/* </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "> VTun - Virtual Tunnel over TCP/IP network.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "> Copyright (C) 1998-2000 Maxim Krasnyansky <<a href="mailto:max_mk@yahoo.com"><span style="color: #0e0eff">max_mk@yahoo.com</span></a>></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "> VTun has been derived from VPPP package by Maxim Krasnyansky. </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "> This program is free software; you can redistribute it and/or modify</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "> it under the terms of the GNU General Public License as published by</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "> the Free Software Foundation; either version 2 of the License, or</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "> (at your option) any later version.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "> This program is distributed in the hope that it will be useful,</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "> but WITHOUT ANY WARRANTY; without even the implied warranty of</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "> GNU General Public License for more details.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); ">*/</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); ">/*</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "> * $Id: tun_dev.c,v 1.4 2006/12/11 10:45:35 mtbishop Exp $</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "> */<span style="color: #000000"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(196, 26, 22); "><span style="color: #643820">#include </span><unistd.h></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(100, 56, 32); ">#include <span style="color: #c41a16"><fcntl.h></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(196, 26, 22); "><span style="color: #643820">#include </span><stdlib.h></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(100, 56, 32); ">#include <span style="color: #c41a16"><stdio.h></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(196, 26, 22); "><span style="color: #643820">#include </span><string.h></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(196, 26, 22); "><span style="color: #643820">#include </span><syslog.h></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(100, 56, 32); ">#include <span style="color: #c41a16"><errno.h></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(196, 26, 22); "><span style="color: #643820">#include </span><sys/ioctl.h></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(196, 26, 22); "><span style="color: #643820">#include </span><sys/socket.h></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(196, 26, 22); "><span style="color: #643820">#include </span><linux/if.h></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(100, 56, 32); ">#include <span style="color: #c41a16">"vtun.h"</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(100, 56, 32); ">#include <span style="color: #c41a16">"lib.h"</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); ">/* </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "> * Allocate TUN device, returns opened fd. </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "> * Stores dev name in the first arg(must be large enough).</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "> */<span style="color: #000000"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: #aa0d91">static</span> <span style="color: #aa0d91">int</span> tun_open_common0(<span style="color: #aa0d91">char</span> *dev, <span style="color: #aa0d91">int</span> istun)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">char</span> tunname[<span style="color: #1c00cf">14</span>];</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">int</span> i, fd, err;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">if</span>( *dev ) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> sprintf(tunname, <span style="color: #c41a16">"/dev/%s"</span>, dev);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">return</span> open(tunname, O_RDWR);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> sprintf(tunname, <span style="color: #c41a16">"/dev/%s"</span>, istun ? <span style="color: #c41a16">"tun"</span> : <span style="color: #c41a16">"tap"</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> err = <span style="color: #1c00cf">0</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">for</span>(i=<span style="color: #1c00cf">0</span>; i < <span style="color: #1c00cf">255</span>; i++){</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> sprintf(tunname + <span style="color: #1c00cf">8</span>, <span style="color: #c41a16">"%d"</span>, i);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "><span style="color: #000000"> </span>/* Open device */</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">if</span>( (fd=open(tunname, O_RDWR)) > <span style="color: #1c00cf">0</span> ) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> strcpy(dev, tunname + <span style="color: #1c00cf">5</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">return</span> fd;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">else</span> <span style="color: #aa0d91">if</span> (errno != ENOENT)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> err = errno;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "><span style="color: #000000"> </span><span style="color: #aa0d91">else</span><span style="color: #000000"> </span><span style="color: #aa0d91">if</span><span style="color: #000000"> (i)</span>/* don't try all 256 devices */</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">break</span>;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">if</span> (err)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> errno = err;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(170, 13, 145); "><span style="color: #000000"> </span>return<span style="color: #000000"> -</span><span style="color: #1c00cf">1</span><span style="color: #000000">;</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(100, 56, 32); ">#ifdef LINUX</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(196, 26, 22); "><span style="color: #643820">#include </span><linux/if_tun.h></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(100, 56, 32); ">#endif</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(100, 56, 32); ">#ifdef LINUX_ARM</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(196, 26, 22); "><span style="color: #643820">#include </span></usr/include/linux/if_tun.h></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(100, 56, 32); ">#endif</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(100, 56, 32); ">#ifndef OTUNSETNOCSUM</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); ">/* pre 2.4.6 compatibility */</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(100, 56, 32); ">#define OTUNSETNOCSUM ((<span style="color: #1c00cf">'T'</span><< <span style="color: #1c00cf">8</span>) | <span style="color: #1c00cf">200</span>) </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(100, 56, 32); ">#define OTUNSETDEBUG ((<span style="color: #1c00cf">'T'</span><< <span style="color: #1c00cf">8</span>) | <span style="color: #1c00cf">201</span>) </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(100, 56, 32); ">#define OTUNSETIFF ((<span style="color: #1c00cf">'T'</span><< <span style="color: #1c00cf">8</span>) | <span style="color: #1c00cf">202</span>) </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(100, 56, 32); ">#define OTUNSETPERSIST ((<span style="color: #1c00cf">'T'</span><< <span style="color: #1c00cf">8</span>) | <span style="color: #1c00cf">203</span>) </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(100, 56, 32); ">#define OTUNSETOWNER ((<span style="color: #1c00cf">'T'</span><< <span style="color: #1c00cf">8</span>) | <span style="color: #1c00cf">204</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(100, 56, 32); ">#endif</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: #aa0d91">static</span> <span style="color: #aa0d91">int</span> tun_open_common(<span style="color: #aa0d91">char</span> *dev, <span style="color: #aa0d91">int</span> istun)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">struct</span> ifreq ifr;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">int</span> fd;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">if</span> ((fd = open(<span style="color: #c41a16">"/dev/net/tun"</span>, O_RDWR)) < <span style="color: #1c00cf">0</span>) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(196, 26, 22); "><span style="color: #000000"> fprintf(stderr,</span>"tun_open_common err\n"<span style="color: #000000">);</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> perror(<span style="color: #c41a16">"open common"</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">return</span> tun_open_common0(dev, istun);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> memset(&ifr, <span style="color: #1c00cf">0</span>, <span style="color: #aa0d91">sizeof</span>(ifr));</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> ifr.ifr_flags = (istun ? IFF_TUN : IFF_TAP) | IFF_NO_PI;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">if</span> (*dev)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> strncpy(ifr.ifr_name, dev, IFNAMSIZ);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">if</span> (ioctl(fd, TUNSETIFF, (<span style="color: #aa0d91">void</span> *) &ifr) < <span style="color: #1c00cf">0</span>) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">if</span> (errno == EBADFD) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); "><span style="color: #000000"> </span>/* Try old ioctl */</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">if</span> (ioctl(fd, OTUNSETIFF, (<span style="color: #aa0d91">void</span> *) &ifr) < <span style="color: #1c00cf">0</span>) </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #aa0d91">goto</span> failed;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> } <span style="color: #aa0d91">else</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">goto</span> failed;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> } </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> strcpy(dev, ifr.ifr_name);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> <span style="color: #aa0d91">return</span> fd;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> failed:</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "> close(fd);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(170, 13, 145); "><span style="color: #000000"> </span>return<span style="color: #000000"> -</span><span style="color: #1c00cf">1</span><span style="color: #000000">;</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; ">}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: #aa0d91">int</span> tun_open(<span style="color: #aa0d91">char</span> *dev) { <span style="color: #aa0d91">return</span> tun_open_common(dev, <span style="color: #1c00cf">1</span>); }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: #aa0d91">int</span> tap_open(<span style="color: #aa0d91">char</span> *dev) { <span style="color: #aa0d91">return</span> tun_open_common(dev, <span style="color: #1c00cf">0</span>); }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: #aa0d91">int</span> tun_close(<span style="color: #aa0d91">int</span> fd, <span style="color: #aa0d91">char</span> *dev) { <span style="color: #aa0d91">return</span> close(fd); }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: #aa0d91">int</span> tap_close(<span style="color: #aa0d91">int</span> fd, <span style="color: #aa0d91">char</span> *dev) { <span style="color: #aa0d91">return</span> close(fd); }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; color: rgb(0, 116, 0); ">/* Read/write frames from TUN device */</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: #aa0d91">int</span> tun_write(<span style="color: #aa0d91">int</span> fd, <span style="color: #aa0d91">char</span> *buf, <span style="color: #aa0d91">int</span> len) { <span style="color: #aa0d91">return</span> write(fd, buf, len); }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: #aa0d91">int</span> tap_write(<span style="color: #aa0d91">int</span> fd, <span style="color: #aa0d91">char</span> *buf, <span style="color: #aa0d91">int</span> len) { <span style="color: #aa0d91">return</span> write(fd, buf, len); }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: #aa0d91">int</span> tun_read(<span style="color: #aa0d91">int</span> fd, <span style="color: #aa0d91">char</span> *buf, <span style="color: #aa0d91">int</span> len) { <span style="color: #aa0d91">return</span> read(fd, buf, len); }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; "><span style="color: #aa0d91">int</span> tap_read(<span style="color: #aa0d91">int</span> fd, <span style="color: #aa0d91">char</span> *buf, <span style="color: #aa0d91">int</span> len) { <span style="color: #aa0d91">return</span> read(fd, buf, len); }</div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br></span></font></div></div><br></body></html>