驱动中获取特定网络接口的信息
上一篇 /
下一篇 2008-07-29 10:51:55
/*这个是我写的*/
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;
}
/*这个是抄过来的,貌似更严谨*/
#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;
}
相关阅读:
- Linux基金会希望NVIDIA显卡驱动开源 (kennycx, 2008-6-24)
- ATI 开源驱动 6.9.0 发布 (kennycx, 2008-6-27)
- 网络办公 看看在线操作系统什么样 (kennycx, 2008-7-05)
- DNS详解 (Dream-AL, 2008-7-07)
- Opera提出网络标准课程 发布标准教育倡议 (kennycx, 2008-7-09)
- AMD 发布 ATI Catalyst 8.7 Linux 驱动 (kennycx, 2008-7-22)
- Eucalyptus项目:开源云计算,兼容EC2接口 (kennycx, 2008-7-23)
- Intel X.Org 2.4.0显示驱动正式发布! (kennycx, 2008-7-24)
- Atheros发布802.11n无线芯片的自由Linux驱动 (kennycx, 2008-7-27)
- flash 读写,我在望网上看到的一篇文章,对我在驱动中读写NAND FLASH 帮助很大 (天堂, 2008-7-28)
导入论坛
收藏
分享给好友
管理
举报
TAG:
获取
接口
驱动
网络