本文整理汇总了C++中register_netdevice函数的典型用法代码示例。如果您正苦于以下问题:C++ register_netdevice函数的具体用法?C++ register_netdevice怎么用?C++ register_netdevice使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了register_netdevice函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lowpan_register_netdevice
int lowpan_register_netdevice(struct net_device *dev,
enum lowpan_lltypes lltype)
{
int i, ret;
dev->addr_len = EUI64_ADDR_LEN;
dev->type = ARPHRD_6LOWPAN;
dev->mtu = IPV6_MIN_MTU;
dev->priv_flags |= IFF_NO_QUEUE;
lowpan_dev(dev)->lltype = lltype;
spin_lock_init(&lowpan_dev(dev)->ctx.lock);
for (i = 0; i < LOWPAN_IPHC_CTX_TABLE_SIZE; i++)
lowpan_dev(dev)->ctx.table[i].id = i;
dev->ndisc_ops = &lowpan_ndisc_ops;
ret = register_netdevice(dev);
if (ret < 0)
return ret;
ret = lowpan_dev_debugfs_init(dev);
if (ret < 0)
unregister_netdevice(dev);
return ret;
}
示例2: ip_tunnel_newlink
int ip_tunnel_newlink(struct net_device *dev, struct nlattr *tb[],
struct ip_tunnel_parm *p)
{
struct ip_tunnel *nt;
struct net *net = dev_net(dev);
struct ip_tunnel_net *itn;
int mtu;
int err;
nt = netdev_priv(dev);
itn = net_generic(net, nt->ip_tnl_net_id);
if (ip_tunnel_find(itn, p, dev->type))
return -EEXIST;
nt->net = net;
nt->parms = *p;
err = register_netdevice(dev);
if (err)
goto out;
if (dev->type == ARPHRD_ETHER && !tb[IFLA_ADDRESS])
eth_hw_addr_random(dev);
mtu = ip_tunnel_bind_dev(dev);
if (!tb[IFLA_MTU])
dev->mtu = mtu;
ip_tunnel_add(itn, nt);
out:
return err;
}
示例3: alloc_netdev
static struct net_device *ip6mr_reg_vif(struct net *net)
{
struct net_device *dev;
dev = alloc_netdev(0, "pim6reg", reg_vif_setup);
if (dev == NULL)
return NULL;
dev_net_set(dev, net);
if (register_netdevice(dev)) {
free_netdev(dev);
return NULL;
}
dev->iflink = 0;
if (dev_open(dev))
goto failure;
dev_hold(dev);
return dev;
failure:
/* allow the register to be completed before unregistering. */
rtnl_unlock();
rtnl_lock();
unregister_netdevice(dev);
return NULL;
}
示例4: rmnet_vnd_create_dev
int rmnet_vnd_create_dev(int id, struct net_device **new_device)
{
struct net_device *dev;
int rc = 0;
if (id < 0 || id > RMNET_DATA_MAX_VND || rmnet_devices[id] != 0) {
*new_device = 0;
return -EINVAL;
}
dev = alloc_netdev(sizeof(struct rmnet_vnd_private_s),
RMNET_DATA_DEV_NAME_STR,
rmnet_vnd_setup);
if (!dev) {
LOGE("%s(): Failed to to allocate netdev for id %d",
__func__, id);
*new_device = 0;
return -EINVAL;
}
rc = register_netdevice(dev);
if (rc != 0) {
LOGE("%s(): Failed to to register netdev [%s]",
__func__, dev->name);
free_netdev(dev);
*new_device = 0;
} else {
rmnet_devices[id] = dev;
*new_device = dev;
}
LOGM("%s(): Registered device %s\n", __func__, dev->name);
return rc;
}
示例5: au1k_irda_init
static int au1k_irda_init(void)
{
static unsigned version_printed = 0;
struct net_device *dev;
int err;
if (version_printed++ == 0) printk(version);
rtnl_lock();
dev = dev_alloc("irda%d", &err);
if (dev) {
dev->irq = AU1000_IRDA_RX_INT; /* TX has its own interrupt */
dev->init = au1k_irda_net_init;
dev->uninit = au1k_irda_net_uninit;
err = register_netdevice(dev);
if (err)
kfree(dev);
else
ir_devs[0] = dev;
printk(KERN_INFO "IrDA: Registered device %s\n", dev->name);
}
rtnl_unlock();
return err;
}
示例6: alloc_netdev
static struct net_device *ipmr_reg_vif(void)
{
struct net_device *dev;
struct in_device *in_dev;
dev = alloc_netdev(sizeof(struct net_device_stats), "pimreg",
reg_vif_setup);
if (dev == NULL)
return NULL;
if (register_netdevice(dev)) {
free_netdev(dev);
return NULL;
}
dev->iflink = 0;
if ((in_dev = inetdev_init(dev)) == NULL)
goto failure;
in_dev->cnf.rp_filter = 0;
if (dev_open(dev))
goto failure;
return dev;
failure:
unregister_netdevice(dev);
return NULL;
}
示例7: ipip6_tunnel_locate
static struct ip_tunnel * ipip6_tunnel_locate(struct net *net,
struct ip_tunnel_parm *parms, int create)
{
__be32 remote = parms->iph.daddr;
__be32 local = parms->iph.saddr;
struct ip_tunnel *t, **tp, *nt;
struct net_device *dev;
char name[IFNAMSIZ];
struct sit_net *sitn = net_generic(net, sit_net_id);
for (tp = __ipip6_bucket(sitn, parms); (t = *tp) != NULL; tp = &t->next) {
if (local == t->parms.iph.saddr &&
remote == t->parms.iph.daddr &&
parms->link == t->parms.link) {
if (create)
return NULL;
else
return t;
}
}
if (!create)
goto failed;
if (parms->name[0])
strlcpy(name, parms->name, IFNAMSIZ);
else
sprintf(name, "sit%%d");
dev = alloc_netdev(sizeof(*t), name, ipip6_tunnel_setup);
if (dev == NULL)
return NULL;
dev_net_set(dev, net);
if (strchr(name, '%')) {
if (dev_alloc_name(dev, name) < 0)
goto failed_free;
}
nt = netdev_priv(dev);
nt->parms = *parms;
ipip6_tunnel_init(dev);
if (parms->i_flags & SIT_ISATAP)
dev->priv_flags |= IFF_ISATAP;
if (register_netdevice(dev) < 0)
goto failed_free;
dev_hold(dev);
ipip6_tunnel_link(sitn, nt);
return nt;
failed_free:
free_netdev(dev);
failed:
return NULL;
}
示例8: ifb_init_one
static int __init ifb_init_one(int index)
{
struct net_device *dev_ifb;
struct ifb_private *dp;
int err;
dev_ifb = alloc_netdev(sizeof(struct ifb_private),
"ifb%d", ifb_setup);
if (!dev_ifb)
return -ENOMEM;
dp = netdev_priv(dev_ifb);
u64_stats_init(&dp->rsync);
u64_stats_init(&dp->tsync);
dev_ifb->rtnl_link_ops = &ifb_link_ops;
err = register_netdevice(dev_ifb);
if (err < 0)
goto err;
return 0;
err:
free_netdev(dev_ifb);
return err;
}
示例9: ifb_init_one
static int __init ifb_init_one(int index)
{
struct net_device *dev_ifb;
int err;
dev_ifb = alloc_netdev(sizeof(struct ifb_private),
"ifb%d", ifb_setup);
if (!dev_ifb)
return -ENOMEM;
err = dev_alloc_name(dev_ifb, dev_ifb->name);
if (err < 0)
goto err;
dev_ifb->rtnl_link_ops = &ifb_link_ops;
err = register_netdevice(dev_ifb);
if (err < 0)
goto err;
return 0;
err:
free_netdev(dev_ifb);
return err;
}
示例10: net_profile_init
int __init net_profile_init(void)
{
int i;
#ifdef CONFIG_PROC_FS
create_proc_read_entry("net/profile", 0, 0, profile_read_proc, NULL);
#endif
register_netdevice(&whitehole_dev);
printk("Evaluating net profiler cost ...");
#ifdef __alpha__
alpha_tick(0);
#endif
for (i=0; i<1024; i++) {
NET_PROFILE_ENTER(total);
NET_PROFILE_LEAVE(total);
}
if (net_prof_total.accumulator.tv_sec) {
printk(" too high!\n");
} else {
net_profile_adjust.tv_usec = net_prof_total.accumulator.tv_usec>>10;
printk("%ld units\n", net_profile_adjust.tv_usec);
}
net_prof_total.hits = 0;
net_profile_stamp(&net_prof_total.entered);
return 0;
}
示例11: alloc_netdev
static struct net_device *ipmr_reg_vif(void)
{
struct net_device *dev;
struct in_device *in_dev;
dev = alloc_netdev(sizeof(struct net_device_stats), "pimreg",
reg_vif_setup);
if (dev == NULL)
return NULL;
if (register_netdevice(dev)) {
free_netdev(dev);
return NULL;
}
dev->iflink = 0;
if ((in_dev = inetdev_init(dev)) == NULL)
goto failure;
in_dev->cnf.rp_filter = 0;
if (dev_open(dev))
goto failure;
return dev;
failure:
/* allow the register to be completed before unregistering. */
rtnl_unlock();
rtnl_lock();
unregister_netdevice(dev);
return NULL;
}
示例12: vrf_newlink
static int vrf_newlink(struct net *src_net, struct net_device *dev,
struct nlattr *tb[], struct nlattr *data[])
{
struct net_vrf *vrf = netdev_priv(dev);
int err;
if (!data || !data[IFLA_VRF_TABLE])
return -EINVAL;
vrf->tb_id = nla_get_u32(data[IFLA_VRF_TABLE]);
if (vrf->tb_id == RT_TABLE_UNSPEC)
return -EINVAL;
dev->priv_flags |= IFF_L3MDEV_MASTER;
err = register_netdevice(dev);
if (err)
goto out;
if (add_fib_rules) {
err = vrf_add_fib_rules(dev);
if (err) {
unregister_netdevice(dev);
goto out;
}
add_fib_rules = false;
}
out:
return err;
}
示例13: rmnet_vnd_newlink
int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
struct rmnet_port *port,
struct net_device *real_dev)
{
struct rmnet_priv *priv;
int rc;
if (port->rmnet_devices[id])
return -EINVAL;
rc = register_netdevice(rmnet_dev);
if (!rc) {
port->rmnet_devices[id] = rmnet_dev;
port->nr_rmnet_devs++;
rmnet_dev->rtnl_link_ops = &rmnet_link_ops;
priv = netdev_priv(rmnet_dev);
priv->mux_id = id;
priv->real_dev = real_dev;
netdev_dbg(rmnet_dev, "rmnet dev created\n");
}
return rc;
}
示例14: ipip_tunnel_locate
struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int create)
{
u32 remote = parms->iph.daddr;
u32 local = parms->iph.saddr;
struct ip_tunnel *t, **tp, *nt;
struct device *dev;
unsigned h = 0;
int prio = 0;
if (remote) {
prio |= 2;
h ^= HASH(remote);
}
if (local) {
prio |= 1;
h ^= HASH(local);
}
for (tp = &tunnels[prio][h]; (t = *tp) != NULL; tp = &t->next) {
if (local == t->parms.iph.saddr && remote == t->parms.iph.daddr)
return t;
}
if (!create)
return NULL;
MOD_INC_USE_COUNT;
dev = kmalloc(sizeof(*dev) + sizeof(*t), GFP_KERNEL);
if (dev == NULL) {
MOD_DEC_USE_COUNT;
return NULL;
}
memset(dev, 0, sizeof(*dev) + sizeof(*t));
dev->priv = (void*)(dev+1);
nt = (struct ip_tunnel*)dev->priv;
nt->dev = dev;
dev->name = nt->parms.name;
dev->init = ipip_tunnel_init;
memcpy(&nt->parms, parms, sizeof(*parms));
if (dev->name[0] == 0) {
int i;
for (i=1; i<100; i++) {
sprintf(dev->name, "tunl%d", i);
if (dev_get(dev->name) == NULL)
break;
}
if (i==100)
goto failed;
memcpy(parms->name, dev->name, IFNAMSIZ);
}
if (register_netdevice(dev) < 0)
goto failed;
ipip_tunnel_link(nt);
/* Do not decrement MOD_USE_COUNT here. */
return nt;
failed:
kfree(dev);
MOD_DEC_USE_COUNT;
return NULL;
}
示例15: alloc_etherdev
/**
* @brief WILC_WFI_init_mon_interface
* @details
* @param[in]
* @return int : Return 0 on Success
* @author mdaftedar
* @date 12 JUL 2012
* @version 1.0
*/
struct net_device *WILC_WFI_init_mon_interface(const char *name,
struct net_device *real_dev)
{
u32 ret = 0;
struct WILC_WFI_mon_priv *priv;
/*If monitor interface is already initialized, return it*/
if (wilc_wfi_mon)
return wilc_wfi_mon;
wilc_wfi_mon = alloc_etherdev(sizeof(struct WILC_WFI_mon_priv));
if (!wilc_wfi_mon)
return NULL;
wilc_wfi_mon->type = ARPHRD_IEEE80211_RADIOTAP;
strncpy(wilc_wfi_mon->name, name, IFNAMSIZ);
wilc_wfi_mon->name[IFNAMSIZ - 1] = 0;
wilc_wfi_mon->netdev_ops = &wilc_wfi_netdev_ops;
ret = register_netdevice(wilc_wfi_mon);
if (ret) {
netdev_err(real_dev, "register_netdevice failed\n");
return NULL;
}
priv = netdev_priv(wilc_wfi_mon);
if (!priv)
return NULL;
priv->real_ndev = real_dev;
return wilc_wfi_mon;
}