Hi!everyone.<br><br>I'm doing about creating ipv6 tunnel and encountering a problem.<br>I wrote a program that was similar to "tunnalctl.c" 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'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[] = "ip6tnl0";<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)) < 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, "2001:a:b::1", &(local->in6_u.u6_addr16));<br> inet_pton(AF_INET6, "2001::1", &(remote->in6_u.u6_addr16));<br>
<br> memset(tnl, 0, sizeof(struct mip6_tnl));<br> tnl->users = 1;<br> tnl->parm.proto = IPPROTO_IPV6;<br> tnl->parm.flags = IP6_TNL_F_MIP6_DEV|IP6_TNL_F_IGN_ENCAP_LIMIT;<br> tnl->parm.hop_limit = 64;<br>
tnl->parm.laddr = *local;<br> tnl->parm.raddr = *remote;<br> tnl->parm.link = link;<br><br> strcpy(ifr.ifr_name, basedev);<br> ifr.ifr_ifru.ifru_data = (void *)&tnl->parm;<br> if (ioctl(tnl_fd, SIOCADDTUNNEL, &ifr) < 0) {<br>
printf("SIOCADDTUNNEL failed status %d %s\n", <br> errno, strerror(errno));<br> goto err;<br> }<br> if (!(tnl->parm.flags & IP6_TNL_F_MIP6_DEV)) {<br> printf("tunnel exists,but isn't used for MIPv6\n");<br>
goto err;<br> }<br> strcpy(ifr.ifr_name, tnl-><a href="http://parm.name">parm.name</a>);<br> if (ioctl(tnl_fd, SIOCGIFFLAGS, &ifr) < 0) {<br> printf("SIOCGIFFLAGS failed status %d %s\n", <br>
errno, strerror(errno));<br> goto err;<br> }<br> ifr.ifr_flags |= IFF_UP | IFF_RUNNING;<br> if (ioctl(tnl_fd, SIOCSIFFLAGS, &ifr) < 0) {<br> printf("SIOCSIFFLAGS failed status %d %s\n",<br>
errno, strerror(errno));<br> goto err;<br> }<br> if (!(tnl->ifindex = if_nametoindex(tnl-><a href="http://parm.name">parm.name</a>))) {<br> printf("no device called %s\n", tnl-><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>