- 论坛徽章:
- 0
|
我想用dev_get_by_name来看现在网卡的情况
好像不能用阿~~
请大家指点
我的代码:
#include <stdio.h>
#include <linux/netdevice.h>
#include <linux/if_vlan.h>
extern struct net_device *dev_get_by_name(struct net *net, const char *name);
#define VLAN_DEV_INFO(x) ((struct vlan_dev_info *)(x->priv))
int main()
{
struct net_device *dev ={0};// NULL;
struct net *net ={0};// NULL;
//const char *vlan_IF_name = "eth0";
int ret = 0;
dev = dev_get_by_name(net, "eth0");//vlan_IF_name);
ret = (int)dev;
if (dev) {
if (dev->priv_flags & IFF_802_1Q_VLAN) {
printf("Features=%d\n",VLAN_DEV_INFO(dev)->real_dev->features);
}
else
{
printf("ERROR:dev->priv_flags=%d\n",dev->priv_flags);
}
}
else
{
printf("ERROR:Get name error\n");
}
dev_put(dev);
return ret;
} |
|