Chinaunix首页 | 论坛 | 博客
  • 博客访问: 438756
  • 博文数量: 78
  • 博客积分: 2030
  • 博客等级: 大尉
  • 技术积分: 1002
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-28 15:25
文章分类

全部博文(78)

文章存档

2012年(1)

2011年(1)

2010年(4)

2009年(12)

2008年(60)

我的朋友

分类:

2008-10-29 18:00:29

/*This func is written by me*/
static int find_dev_mac(char *name, unsigned char *mac)
{
       struct net_device *dev, *nxt;

       if (!mac || !name){
              return -1;
      }
 
      for (dev = dev_base; dev; dev = nxt) {
               nxt = dev->next;
              if (!strcmp(dev->name, name)){
                     DBG("find %s in kernel dev_base", name);
                     memcpy(mac, dev->dev_addr, 6);
                     return 0;
              }
       }

      return -1; 
}
/*This func orignates from other engineer, it seems to look more strict*/
#define IP_INTERFACE "br0"
static void
ath_find_own_ip(u_int32_t *u_ownIp)
{
    struct in_device *in_dev;
    struct in_ifaddr **ifap = NULL;
    struct in_ifaddr *ifa = NULL;
    struct net_device *dev;
   
    if ((dev = dev_get_by_name(IP_INTERFACE)) == NULL) {
        return;
    }
    if ((in_dev=(struct in_device*)dev->ip_ptr) != NULL) {
        if (ifa == NULL) {
            for (ifap=&in_dev->ifa_list; (ifa=*ifap) != NULL; ifap=&ifa->ifa_next)
                if (strcmp(IP_INTERFACE, ifa->ifa_label) == 0)
                    break;
        }
    }
    if (ifa == NULL)
        return;
    *u_ownIp = ifa->ifa_local;
   
}
阅读(999) | 评论(0) | 转发(0) |
0

上一篇:spin_lock使用不当的后果

下一篇:PHY's crystal

给主人留下些什么吧!~~