mzweilin / napt66

Automatically exported from code.google.com/p/napt66
38 stars 12 forks source link

New patch about linux-2.6.37.6-ccs-1.8.1 #23

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have rewrite this fuction,and now it  can work on linux-2.6.37.6.
But I cann't write a patch ,I show this function.

int get_ip6_by_name(char* if_name,struct in6_addr* p_ipv6)
{
    struct net_device *dev;
    struct net *net = NULL;
    struct socket *sock;
    struct inet6_dev *in_dev6;
    struct inet6_ifaddr *ifa6 = NULL;
    struct list_head* list_head_ipv6 = NULL;
    struct inet6_dev* inet6_dev_ipv6=NULL;
    struct list_head* temp;
    sock_create_kern(PF_INET6, SOCK_DGRAM, 0,&sock);
    net = sock_net((const struct sock *)sock->sk);
    dev = dev_get_by_name(net,if_name);

    in_dev6 = (struct inet6_dev *)dev->ip6_ptr;

/*  while (in_dev6){
        ifa6 = in_dev6->addr_list;
      while (ifa6){         
            if(ifa6->scope == IPV6_ADDR_ANY){   
                (*p_ipv6) = ifa6->addr;//addr即为eth0接口的v6地址
                dev_put(dev); 
                return 1;
            }
         ifa6 = ifa6->if_next;
        }      
        in_dev6 = in_dev6->next;*//////
//}
    while (in_dev6){
        temp=&(in_dev6->addr_list);
        list_for_each(list_head_ipv6,temp)
        {
            ifa6=list_entry(list_head_ipv6,struct inet6_ifaddr,if_list);
            if(ifa6)
                if(ifa6->scope == IPV6_ADDR_ANY){
                    (*p_ipv6) = ifa6->addr;//addr即为eth0接口的v6地址
                    dev_put(dev);
                    return 1;
                }
        }
    in_dev6 = in_dev6->next;
    }

    dev_put(dev);  
    return 0;
}

Original issue reported on code.google.com by woshiyuh...@gmail.com on 22 Jun 2011 at 6:08

GoogleCodeExporter commented 9 years ago
这个还没有经过验证。

Original comment by woshiyuh...@gmail.com on 23 Jun 2011 at 1:57

GoogleCodeExporter commented 9 years ago
Great job! But the compatibility of code is important too. So please use 
LINUX_VERSION_CODE and KERNEL_VERSION macro to support different kernel 
versions.

Example:
#ifndef   KERNEL_VERSION
#define   KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#endif 

#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37)
temp=&(in_dev6->addr_list);
#else
ifa6 = in_dev6->addr_list;
#endif

Original comment by Mzwei...@gmail.com on 23 Jun 2011 at 1:08

GoogleCodeExporter commented 9 years ago
我用上面的patch编译了napt66,使用的是trunk版openwrt,内核版本
2.6.39,按这里给的教程制作了一个napt66固件,在路由器上napt66�
��块也能运行,lsmod可以看到,但就是下面的PC连不上ipv6网络�
��刚开始ping 
ipv6地址连不上端口,我把路由防火墙设置成全部允许,但还�
��上不了,ping超时。不知道是不是哪一步做错了,有时间再��
�试吧。

Original comment by tsl0...@gmail.com on 27 Jun 2011 at 6:14

GoogleCodeExporter commented 9 years ago
把你的模块发给我吧。   woshiyuhao0819@gmail.com

Original comment by woshiyuh...@gmail.com on 27 Jun 2011 at 10:47

GoogleCodeExporter commented 9 years ago
我把模块和固件都上传到这里吧。
OpenWrt源码使用的trunk版,linux内核版本2.6.39.1
固件里只编译了使用isatap隧道方式接入ipv6所需要的包,其它�
��式的自行编译吧。
里面的配置是我在自己学校使用的,自己看情况修改。
我现在还没测试成功,路由器里能ipv6,下面PC还是不行。这��
�天考试较多,就留给你们去测试吧,成功了告诉我一声。

Original comment by tsl0...@gmail.com on 28 Jun 2011 at 1:46

Attachments:

GoogleCodeExporter commented 9 years ago
低版本的内核没有sock_net怎么办?2.6.22.19想编译进tomato固件里

Original comment by q741...@gmail.com on 15 Sep 2011 at 5:41