Hi!everyone.<br><br>I&#39;m doing about creating ipv6 tunnel and encountering a problem.<br>I wrote a program that was similar to &quot;tunnalctl.c&quot; in nepl.<br><br>As i run the NEPL and build up the tunnel ,the information is <br>
<br>Sun Nov 15 11:29:22 __tunnel_add: created tunnel ip6tnl3 (18) from 2001:a:b:0:0:0:0:1 to 2001:a:b:0:0:0:0:1000 user count 1<br>Sun Nov 15 11:29:22 tnl_dump: name: ip6tnl3<br>link: 3<br>proto: 41<br>encap_limit: 0<br>hop_limit: 64<br>
flowinfo: 0<br>flags: 30009<br>laddr: 2001:a:b:0:0:0:0:1<br>raddr: 2001:a:b:0:0:0:0:1000<br>ifindex: 18<br>users: 1<br>Sun Nov 15 11:29:22 conf_home_addr_info: Home address 2001:a:b:0:0:0:0:1<br>Sun Nov 15 11:29:22 flag_hoa: set HoA 2001:a:b:0:0:0:0:1/128 iif 18 flags 12 preferred_time 4294967295 valid_time 4294967295<br>
Sun Nov 15 11:29:22 conf_home_addr_info: Added new home_addr_info successfully<br><br>I look at the ifconfig infomation about ip6tnl3:<br><br>ip6tnl3   Link encap:UNSPEC  HWaddr 20-01-00-0A-00-0B-00-00-00-00-00-00-00-00-00-00  <br>
          inet6 addr: fe80::212:f0ff:fe08:72ce/64 Scope:Link<br>          inet6 addr: 2001:a:b::1/128 Scope:Global<br>          UP POINTOPOINT RUNNING NOARP  MTU:1460  Metric:1<br>          RX packets:0 errors:0 dropped:0 overruns:0 frame:0<br>
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0<br>          collisions:0 txqueuelen:0 <br>          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)<br><br>but I wrote my program following above information,and I use the tnl_dump to get the tunnel information:<br>
name: ip6tnl6<br>link: 0<br>proto: 41<br>encap_limit: 0<br>hop_limit: 64<br>flowinfo: 0<br>flags: 30009<br>laddr: 2001:a:b:0:0:0:0:1<br>raddr: 2001:0:0:0:0:0:0:1000<br>ifindex: 20<br>users: 1<br><br>It&#39;s right,<br>but I look at information of ifconfig of the ip6tnl6.<br>
<br>ip6tnl6   Link encap:UNSPEC  HWaddr 20-01-00-0A-00-0B-00-00-00-00-00-00-00-00-00-00  <br>          inet6 addr: fe80::212:f0ff:fe08:72ce/64 Scope:Link<br>          UP POINTOPOINT RUNNING NOARP  MTU:1460  Metric:1<br>          RX packets:0 errors:0 dropped:0 overruns:0 frame:0<br>
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0<br>          collisions:0 txqueuelen:0 <br>          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)<br><br><br>the  inet6 addr: 2001:a:b::1/128 Scope:Global is gone!! Orz..<br>
<br>why?<br><br>This is my code below:<br><br>int main()<br>{<br>        const char basedev[] = &quot;ip6tnl0&quot;;<br>    struct mip6_tnl *tnl = NULL;<br>    struct ifreq ifr;<br>    struct in6_addr *local, *remote;<br>
    int link=0;<br><br>    if ((tnl_fd = socket(AF_INET6, SOCK_DGRAM, 0)) &lt; 0)<br>        return -1;<br><br>    local=malloc( sizeof(struct in6_addr) );<br>    remote=malloc( sizeof(struct in6_addr) );<br>    if ((tnl = malloc(sizeof(struct mip6_tnl))) == NULL)<br>
        return NULL;<br><br>    memset(local,0,sizeof(struct in6_addr));<br>    memset(remote,0,sizeof(struct in6_addr));<br><br>    inet_pton(AF_INET6, &quot;2001:a:b::1&quot;, &amp;(local-&gt;in6_u.u6_addr16));<br>    inet_pton(AF_INET6, &quot;2001::1&quot;, &amp;(remote-&gt;in6_u.u6_addr16));<br>
    <br>    memset(tnl, 0, sizeof(struct mip6_tnl));<br>    tnl-&gt;users = 1;<br>    tnl-&gt;parm.proto = IPPROTO_IPV6;<br>    tnl-&gt;parm.flags = IP6_TNL_F_MIP6_DEV|IP6_TNL_F_IGN_ENCAP_LIMIT;<br>    tnl-&gt;parm.hop_limit = 64;<br>
    tnl-&gt;parm.laddr = *local;<br>    tnl-&gt;parm.raddr = *remote;<br>    tnl-&gt;parm.link = link;<br><br>    strcpy(ifr.ifr_name, basedev);<br>    ifr.ifr_ifru.ifru_data = (void *)&amp;tnl-&gt;parm;<br>    if (ioctl(tnl_fd, SIOCADDTUNNEL, &amp;ifr) &lt; 0) {<br>
        printf(&quot;SIOCADDTUNNEL failed status %d %s\n&quot;, <br>         errno, strerror(errno));<br>        goto err;<br>    }<br>    if (!(tnl-&gt;parm.flags &amp; IP6_TNL_F_MIP6_DEV)) {<br>        printf(&quot;tunnel exists,but isn&#39;t used for MIPv6\n&quot;);<br>
        goto err;<br>    }<br>    strcpy(ifr.ifr_name, tnl-&gt;<a href="http://parm.name">parm.name</a>);<br>    if (ioctl(tnl_fd, SIOCGIFFLAGS, &amp;ifr) &lt; 0) {<br>        printf(&quot;SIOCGIFFLAGS failed status %d %s\n&quot;, <br>
             errno, strerror(errno));<br>        goto err;<br>    }<br>    ifr.ifr_flags |= IFF_UP | IFF_RUNNING;<br>    if (ioctl(tnl_fd, SIOCSIFFLAGS, &amp;ifr) &lt; 0) {<br>        printf(&quot;SIOCSIFFLAGS failed status %d %s\n&quot;,<br>
             errno, strerror(errno));<br>        goto err;<br>    }<br>    if (!(tnl-&gt;ifindex = if_nametoindex(tnl-&gt;<a href="http://parm.name">parm.name</a>))) {<br>        printf(&quot;no device called %s\n&quot;, tnl-&gt;<a href="http://parm.name">parm.name</a>);<br>
        goto err;<br>    }<br>    tnl_dump(tnl);<br><br><br>    return tnl;<br>err:<br>    free(tnl);<br>    return NULL;<br>}<br><br>Thank to  everybody viewing and replying.<br>