/*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;
}
阅读(1028) | 评论(0) | 转发(0) |