本文整理汇总了C++中dev_change_flags函数的典型用法代码示例。如果您正苦于以下问题:C++ dev_change_flags函数的具体用法?C++ dev_change_flags怎么用?C++ dev_change_flags使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dev_change_flags函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: S_iioctl_siocsifflags
/* 16 SIOCSIFFLAGS -- Set flags of a network interface. */
kern_return_t
S_iioctl_siocsifflags (io_t port,
ifname_t ifnam,
short flags)
{
struct sock_user *user = begin_using_socket_port (port);
error_t err = 0;
struct device *dev;
if (!user)
return EOPNOTSUPP;
dev = get_dev (ifnam);
if (!user->isroot)
err = EPERM;
else if (!dev)
err = ENODEV;
else
{
err = dev_change_flags (dev, flags);
if (!err)
err = ethernet_change_flags (dev, flags);
}
__mutex_unlock (&global_lock);
end_using_socket_port (user);
return err;
}
开发者ID:diegonc,项目名称:console-xkb-support,代码行数:30,代码来源:iioctl-ops.c
示例2: ovs_dp_get_net
static struct vport *gre_tnl_create(const struct vport_parms *parms)
{
struct net *net = ovs_dp_get_net(parms->dp);
struct net_device *dev;
struct vport *vport;
int err;
vport = ovs_vport_alloc(0, &ovs_gre_vport_ops, parms);
if (IS_ERR(vport))
return vport;
rtnl_lock();
dev = gretap_fb_dev_create(net, parms->name, NET_NAME_USER);
if (IS_ERR(dev)) {
rtnl_unlock();
ovs_vport_free(vport);
return ERR_CAST(dev);
}
err = dev_change_flags(dev, dev->flags | IFF_UP);
if (err < 0) {
rtnl_delete_link(dev);
rtnl_unlock();
ovs_vport_free(vport);
return ERR_PTR(err);
}
rtnl_unlock();
return vport;
}
开发者ID:Grim-lock,项目名称:ovs,代码行数:30,代码来源:vport-gre.c
示例3: cycle_netdev
/* cycle interface to flush neighbor cache and move routes across tables */
static void cycle_netdev(struct net_device *dev)
{
unsigned int flags = dev->flags;
int ret;
if (!netif_running(dev))
return;
ret = dev_change_flags(dev, flags & ~IFF_UP);
if (ret >= 0)
ret = dev_change_flags(dev, flags);
if (ret < 0) {
netdev_err(dev,
"Failed to cycle device %s; route tables might be wrong!\n",
dev->name);
}
}
开发者ID:513855417,项目名称:linux,代码行数:19,代码来源:vrf.c
示例4: ipoib_set_ring_param
static int ipoib_set_ring_param(struct net_device *dev,
struct ethtool_ringparam *ringparam)
{
struct ipoib_dev_priv *priv = netdev_priv(dev);
unsigned int new_recvq_size, new_sendq_size;
unsigned long priv_current_flags;
unsigned int dev_current_flags;
bool init = false;
if (ringparam->rx_pending <= IPOIB_MAX_QUEUE_SIZE &&
ringparam->rx_pending >= IPOIB_MIN_QUEUE_SIZE) {
new_recvq_size = roundup_pow_of_two(ringparam->rx_pending);
if (ringparam->rx_pending != new_recvq_size)
pr_warn("%s: %s: rx_pending should be power of two. rx_pending is %d\n",
dev->name, __func__, new_recvq_size);
} else {
pr_err(KERN_ERR "rx_pending (%d) is out of bounds [%d-%d]\n",
ringparam->rx_pending,
IPOIB_MIN_QUEUE_SIZE, IPOIB_MAX_QUEUE_SIZE);
return -EINVAL;
}
if (ringparam->tx_pending <= IPOIB_MAX_QUEUE_SIZE &&
ringparam->tx_pending >= IPOIB_MIN_QUEUE_SIZE) {
new_sendq_size = roundup_pow_of_two(ringparam->tx_pending);
if (ringparam->tx_pending != new_sendq_size)
pr_warn("%s: %s: tx_pending should be power of two. tx_pending is %d\n",
dev->name, __func__, new_sendq_size);
} else {
pr_err(KERN_ERR "tx_pending (%d) is out of bounds [%d-%d]\n",
ringparam->tx_pending,
IPOIB_MIN_QUEUE_SIZE, IPOIB_MAX_QUEUE_SIZE);
return -EINVAL;
}
if ((new_recvq_size != priv->recvq_size) ||
(new_sendq_size != priv->sendq_size)) {
priv_current_flags = priv->flags;
dev_current_flags = dev->flags;
dev_change_flags(dev, dev->flags & ~IFF_UP);
ipoib_dev_uninit(dev);
do {
priv->recvq_size = new_recvq_size;
priv->sendq_size = new_sendq_size;
if (ipoib_ethtool_dev_init(dev)) {
new_recvq_size >>= 1;
new_sendq_size >>= 1;
/* keep the values always legal */
new_recvq_size = max_t(unsigned int, new_recvq_size, IPOIB_MIN_QUEUE_SIZE);
new_sendq_size = max_t(unsigned int, new_sendq_size, IPOIB_MIN_QUEUE_SIZE);
} else {
init = true;
}
} while (!init &&
开发者ID:Mellanox,项目名称:dpdk-dev-mlnx-ofed-kernel,代码行数:56,代码来源:ipoib_ethtool.c
示例5: device_set_status
static io_return_t
device_set_status(void *d, dev_flavor_t flavor, dev_status_t status,
mach_msg_type_number_t count)
{
if (flavor == NET_FLAGS)
{
if (count != 1)
return D_INVALID_SIZE;
short flags = status[0];
struct net_data *net = (struct net_data *) d;
dev_change_flags (net->dev, flags);
/* Change the flags of the Mach device, too. */
net->ifnet.if_flags = net->dev->flags;
return D_SUCCESS;
}
if(flavor < SIOCIWFIRST || flavor > SIOCIWLAST)
return D_INVALID_OPERATION;
if(! IW_IS_SET(flavor))
return D_INVALID_OPERATION;
if(count * sizeof(int) < sizeof(struct ifreq))
return D_INVALID_OPERATION;
struct net_data *nd = d;
struct linux_device *dev = nd->dev;
if(! dev->do_ioctl)
return D_INVALID_OPERATION;
if((flavor == SIOCSIWENCODE || flavor == SIOCSIWESSID
|| flavor == SIOCSIWNICKN || flavor == SIOCSIWSPY)
&& ((struct iwreq *) status)->u.data.pointer)
{
struct iw_point *iwp = &((struct iwreq *) status)->u.data;
/* safety check whether the status array is long enough ... */
if(count * sizeof(int) < sizeof(struct ifreq) + iwp->length)
return D_INVALID_OPERATION;
/* make sure, iwp->pointer points to the correct address */
if(iwp->pointer) iwp->pointer = (void *) status + sizeof(struct ifreq);
}
int result = dev->do_ioctl(dev, (struct ifreq *) status, flavor);
return result ? D_IO_ERROR : D_SUCCESS;
}
开发者ID:ctos,项目名称:bpi,代码行数:51,代码来源:net.c
示例6: ovs_dp_get_net
static struct vport *geneve_tnl_create(const struct vport_parms *parms)
{
struct net *net = ovs_dp_get_net(parms->dp);
struct nlattr *options = parms->options;
struct geneve_port *geneve_port;
struct net_device *dev;
struct vport *vport;
struct nlattr *a;
u16 dst_port;
int err;
if (!options) {
err = -EINVAL;
goto error;
}
a = nla_find_nested(options, OVS_TUNNEL_ATTR_DST_PORT);
if (a && nla_len(a) == sizeof(u16)) {
dst_port = nla_get_u16(a);
} else {
/* Require destination port from userspace. */
err = -EINVAL;
goto error;
}
vport = ovs_vport_alloc(sizeof(struct geneve_port),
&ovs_geneve_vport_ops, parms);
if (IS_ERR(vport))
return vport;
geneve_port = geneve_vport(vport);
geneve_port->dst_port = dst_port;
rtnl_lock();
dev = geneve_dev_create_fb(net, parms->name, NET_NAME_USER, dst_port);
if (IS_ERR(dev)) {
rtnl_unlock();
ovs_vport_free(vport);
return ERR_CAST(dev);
}
dev_change_flags(dev, dev->flags | IFF_UP);
rtnl_unlock();
return vport;
error:
return ERR_PTR(err);
}
开发者ID:ALutzG,项目名称:ovs,代码行数:47,代码来源:vport-geneve.c
示例7: vlan_dev_set_mac_address
int vlan_dev_set_mac_address(struct net_device *dev, void *addr_struct_p)
{
struct sockaddr *addr = (struct sockaddr *)(addr_struct_p);
int i;
if (netif_running(dev))
return -EBUSY;
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
printk("%s: Setting MAC address to ", dev->name);
for (i = 0; i < 6; i++)
printk(" %2.2x", dev->dev_addr[i]);
printk(".\n");
if (memcmp(VLAN_DEV_INFO(dev)->real_dev->dev_addr,
dev->dev_addr,
dev->addr_len) != 0) {
if (!(VLAN_DEV_INFO(dev)->real_dev->flags & IFF_PROMISC)) {
int flgs = VLAN_DEV_INFO(dev)->real_dev->flags;
/* Increment our in-use promiscuity counter */
dev_set_promiscuity(VLAN_DEV_INFO(dev)->real_dev, 1);
/* Make PROMISC visible to the user. */
flgs |= IFF_PROMISC;
printk("VLAN (%s): Setting underlying device (%s) to promiscious mode.\n",
dev->name, VLAN_DEV_INFO(dev)->real_dev->name);
dev_change_flags(VLAN_DEV_INFO(dev)->real_dev, flgs);
}
} else {
printk("VLAN (%s): Underlying device (%s) has same MAC, not checking promiscious mode.\n",
dev->name, VLAN_DEV_INFO(dev)->real_dev->name);
}
return 0;
}
开发者ID:BackupTheBerlios,项目名称:tew632-brp-svn,代码行数:37,代码来源:vlan_dev.c
示例8: android_ioctl_siwpriv
//.........这里部分代码省略.........
}
return -1;
} else if (strncasecmp(cmd, "SCAN-CHANNELS ", 14)==0 ||
strncasecmp(cmd, "COUNTRY ", 8)==0) {
/*
* Set the available channels with WMI_SET_CHANNELPARAMS cmd
* However, the channels will be limited by the eeprom regulator domain
* Try to use a regulator domain which will not limited the channels range.
*/
int i;
int chan = 0;
A_UINT16 *clist;
struct ifreq ifr;
char ioBuf[256];
WMI_CHANNEL_PARAMS_CMD *chParamCmd = (WMI_CHANNEL_PARAMS_CMD *)ioBuf;
if (strncasecmp(cmd, "COUNTRY ", 8)==0) {
char *country = cmd + 8;
if (strcasecmp(country, "US")==0) {
chan = 11;
} else if (strcasecmp(country, "JP")==0) {
chan = 14;
} else if (strcasecmp(country, "EU")==0) {
chan = 13;
}
} else if (sscanf(cmd, "%*s %d", &chan) != 1) {
return -1;
}
if ( (chan != 11) && (chan != 13) && (chan != 14)) {
return -1;
}
if (arPriv->arNextMode == AP_NETWORK) {
return -1;
}
A_MEMZERO(&ifr, sizeof(ifr));
A_MEMZERO(ioBuf, sizeof(ioBuf));
chParamCmd->phyMode = WMI_11G_MODE;
clist = chParamCmd->channelList;
chParamCmd->numChannels = chan;
chParamCmd->scanParam = 1;
for (i = 0; i < chan; i++) {
clist[i] = wlan_ieee2freq(i + 1);
}
return android_do_ioctl_direct(dev, AR6000_IOCTL_WMI_SET_CHANNELPARAMS, &ifr, ioBuf);
} else if (strncasecmp(cmd, "BTCOEXMODE ", 11)==0) {
int mode;
if (sscanf(cmd, "%*s %d", &mode)==1) {
/*
* Android disable BT-COEX when obtaining dhcp packet except there is headset is connected
* It enable the BT-COEX after dhcp process is finished
* We ignore since we have our way to do bt-coex during dhcp obtaining.
*/
switch (mode) {
case 1: /* Disable*/
break;
case 0: /* Enable */
/* fall through */
case 2: /* Sense*/
/* fall through */
default:
break;
}
return 0; /* ignore it */
}
return -1;
} else if (strcasecmp(cmd, "BTCOEXSCAN-START")==0) {
/* Android enable or disable Bluetooth coexistence scan mode. When this mode is on,
* some of the low-level scan parameters used by the driver are changed to
* reduce interference with A2DP streaming.
*/
return 0; /* ignore it since we have btfilter */
} else if (strcasecmp(cmd, "BTCOEXSCAN-STOP")==0) {
return 0; /* ignore it since we have btfilter */
} else if (strncasecmp(cmd, "RXFILTER-ADD ", 13)==0) {
return 0; /* ignore it */
} else if (strncasecmp(cmd, "RXFILTER-REMOVE ", 16)==0) {
return 0; /* ignoret it */
} else if (strcasecmp(cmd, "RXFILTER-START")==0 || strcasecmp(cmd, "RXFILTER-STOP")==0) {
unsigned int flags = dev->flags;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)
int mc_count = dev->mc_count;
#else
int mc_count = netdev_mc_count(dev);
#endif
if (strcasecmp(cmd, "RXFILTER-START")==0) {
if (mc_count > 0 || (flags & IFF_MULTICAST) ) {
flags &= ~IFF_MULTICAST;
}
} else {
flags |= IFF_MULTICAST;
}
if (flags != dev->flags) {
dev_change_flags(dev, flags);
}
return 0;
}
return -EOPNOTSUPP;
}
开发者ID:burstlam,项目名称:AR6kSDK.3.1,代码行数:101,代码来源:ar6000_android.c
示例9: android_ioctl_siwpriv
//.........这里部分代码省略.........
strncasecmp(cmd, "COUNTRY ", 8)==0) {
/*
* Set the available channels with WMI_SET_CHANNELPARAMS cmd
* However, the channels will be limited by the eeprom regulator domain
* Try to use a regulator domain which will not limited the channels range.
*/
int i;
int chan = 0;
A_UINT16 *clist;
struct ifreq ifr;
char ioBuf[256];
WMI_CHANNEL_PARAMS_CMD *chParamCmd = (WMI_CHANNEL_PARAMS_CMD *)ioBuf;
if (strncasecmp(cmd, "COUNTRY ", 8)==0) {
char *country = cmd + 8;
if (strcasecmp(country, "US")==0) {
chan = 11;
} else if (strcasecmp(country, "JP")==0) {
chan = 14;
} else if (strcasecmp(country, "EU")==0) {
chan = 13;
}
} else if (sscanf(cmd, "%*s %d", &chan) != 1) {
return -1;
}
if ( (chan != 11) && (chan != 13) && (chan != 14)) {
return -1;
}
if (ar->arNextMode == AP_NETWORK) {
return -1;
}
A_MEMZERO(&ifr, sizeof(ifr));
A_MEMZERO(ioBuf, sizeof(ioBuf));
chParamCmd->phyMode = WMI_11G_MODE;
clist = chParamCmd->channelList;
chParamCmd->numChannels = chan;
chParamCmd->scanParam = 1;
for (i = 0; i < chan; i++) {
clist[i] = wlan_ieee2freq(i + 1);
}
return android_do_ioctl_direct(dev, AR6000_IOCTL_WMI_SET_CHANNELPARAMS, &ifr, ioBuf);
} else if (strncasecmp(cmd, "BTCOEXMODE ", 11)==0) {
int mode;
if (sscanf(cmd, "%*s %d", &mode)==1) {
/*
* Android disable BT-COEX when obtaining dhcp packet except there is headset is connected
* It enable the BT-COEX after dhcp process is finished
* We ignore since we have our way to do bt-coex during dhcp obtaining.
*/
switch (mode) {
case 1: /* Disable*/
break;
case 0: /* Enable */
/* fall through */
case 2: /* Sense*/
/* fall through */
default:
break;
}
return 0; /* ignore it */
}
return -1;
} else if (strcasecmp(cmd, "BTCOEXSCAN-START")==0) {
/* Android enable or disable Bluetooth coexistence scan mode. When this mode is on,
* some of the low-level scan parameters used by the driver are changed to
* reduce interference with A2DP streaming.
*/
return 0; /* ignore it since we have btfilter */
} else if (strcasecmp(cmd, "BTCOEXSCAN-STOP")==0) {
return 0; /* ignore it since we have btfilter */
} else if (strncasecmp(cmd, "RXFILTER-ADD ", 13)==0) {
return 0; /* ignore it */
} else if (strncasecmp(cmd, "RXFILTER-REMOVE ", 16)==0) {
return 0; /* ignoret it */
} else if (strcasecmp(cmd, "RXFILTER-START")==0 || strcasecmp(cmd, "RXFILTER-STOP")==0) {
unsigned int flags = dev->flags;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)
int mc_count = dev->mc_count;
#else
int mc_count = netdev_mc_count(dev);
#endif
if (!(flags & IFF_UP)) {
return -1;
}
if (strcasecmp(cmd, "RXFILTER-START")==0) {
if (mc_count > 0 || (flags & IFF_MULTICAST) ) {
flags &= ~IFF_MULTICAST;
}
} else {
flags |= IFF_MULTICAST;
}
if (flags != dev->flags) {
dev_change_flags(dev, flags);
}
return 0;
}
return -EOPNOTSUPP;
}
开发者ID:dalingrin,项目名称:android_system_wlan_atheros,代码行数:101,代码来源:ar6000_android.c
示例10: vlan_device_event
static int vlan_device_event(struct notifier_block *unused, unsigned long event,
void *ptr)
{
struct net_device *dev = ptr;
struct vlan_group *grp;
struct vlan_info *vlan_info;
int i, flgs;
struct net_device *vlandev;
struct vlan_dev_priv *vlan;
LIST_HEAD(list);
if (is_vlan_dev(dev))
__vlan_device_event(dev, event);
if ((event == NETDEV_UP) &&
(dev->features & NETIF_F_HW_VLAN_FILTER)) {
pr_info("adding VLAN 0 to HW filter on device %s\n",
dev->name);
vlan_vid_add(dev, 0);
}
vlan_info = rtnl_dereference(dev->vlan_info);
if (!vlan_info)
goto out;
grp = &vlan_info->grp;
switch (event) {
case NETDEV_CHANGE:
for (i = 0; i < VLAN_N_VID; i++) {
vlandev = vlan_group_get_device(grp, i);
if (!vlandev)
continue;
netif_stacked_transfer_operstate(dev, vlandev);
}
break;
case NETDEV_CHANGEADDR:
for (i = 0; i < VLAN_N_VID; i++) {
vlandev = vlan_group_get_device(grp, i);
if (!vlandev)
continue;
flgs = vlandev->flags;
if (!(flgs & IFF_UP))
continue;
vlan_sync_address(dev, vlandev);
}
break;
case NETDEV_CHANGEMTU:
for (i = 0; i < VLAN_N_VID; i++) {
vlandev = vlan_group_get_device(grp, i);
if (!vlandev)
continue;
if (vlandev->mtu <= dev->mtu)
continue;
dev_set_mtu(vlandev, dev->mtu);
}
break;
case NETDEV_FEAT_CHANGE:
for (i = 0; i < VLAN_N_VID; i++) {
vlandev = vlan_group_get_device(grp, i);
if (!vlandev)
continue;
vlan_transfer_features(dev, vlandev);
}
break;
case NETDEV_DOWN:
for (i = 0; i < VLAN_N_VID; i++) {
vlandev = vlan_group_get_device(grp, i);
if (!vlandev)
continue;
flgs = vlandev->flags;
if (!(flgs & IFF_UP))
continue;
vlan = vlan_dev_priv(vlandev);
if (!(vlan->flags & VLAN_FLAG_LOOSE_BINDING))
dev_change_flags(vlandev, flgs & ~IFF_UP);
netif_stacked_transfer_operstate(dev, vlandev);
}
break;
case NETDEV_UP:
for (i = 0; i < VLAN_N_VID; i++) {
//.........这里部分代码省略.........
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:101,代码来源:vlan.c
示例11: devinet_ioctl
//.........这里部分代码省略.........
if (ifa == NULL && cmd != SIOCSIFADDR && cmd != SIOCSIFFLAGS) {
ret = -EADDRNOTAVAIL;
goto done;
}
switch(cmd) {
case SIOCGIFADDR: /* Get interface address */
sin->sin_addr.s_addr = ifa->ifa_local;
goto rarok;
case SIOCGIFBRDADDR: /* Get the broadcast address */
sin->sin_addr.s_addr = ifa->ifa_broadcast;
goto rarok;
case SIOCGIFDSTADDR: /* Get the destination address */
sin->sin_addr.s_addr = ifa->ifa_address;
goto rarok;
case SIOCGIFNETMASK: /* Get the netmask for the interface */
sin->sin_addr.s_addr = ifa->ifa_mask;
goto rarok;
case SIOCSIFFLAGS:
if (colon) {
if (ifa == NULL) {
ret = -EADDRNOTAVAIL;
break;
}
if (!(ifr.ifr_flags&IFF_UP))
inet_del_ifa(in_dev, ifap, 1);
break;
}
ret = dev_change_flags(dev, ifr.ifr_flags);
break;
case SIOCSIFADDR: /* Set interface address (and family) */
if (inet_abc_len(sin->sin_addr.s_addr) < 0) {
ret = -EINVAL;
break;
}
if (!ifa) {
if ((ifa = inet_alloc_ifa()) == NULL) {
ret = -ENOBUFS;
break;
}
if (colon)
memcpy(ifa->ifa_label, ifr.ifr_name, IFNAMSIZ);
else
memcpy(ifa->ifa_label, dev->name, IFNAMSIZ);
} else {
ret = 0;
if (ifa->ifa_local == sin->sin_addr.s_addr)
break;
inet_del_ifa(in_dev, ifap, 0);
ifa->ifa_broadcast = 0;
ifa->ifa_anycast = 0;
}
ifa->ifa_address =
ifa->ifa_local = sin->sin_addr.s_addr;
if (!(dev->flags&IFF_POINTOPOINT)) {
ifa->ifa_prefixlen = inet_abc_len(ifa->ifa_address);
ifa->ifa_mask = inet_make_mask(ifa->ifa_prefixlen);
开发者ID:muromec,项目名称:linux-ezxdev,代码行数:67,代码来源:devinet.c
示例12: android_ioctl_siwpriv
//.........这里部分代码省略.........
return -1;
} else if (strncasecmp(cmd, "SCAN-CHANNELS ", 14)==0 ||
strncasecmp(cmd, "COUNTRY ", 8)==0) {
/*
* Set the available channels with WMI_SET_CHANNELPARAMS cmd
* However, the channels will be limited by the eeprom regulator domain
* Try to use a regulator domain which will not limited the channels range.
*/
int i;
int chan = 0;
A_UINT16 *clist;
struct ifreq ifr;
char ioBuf[256];
WMI_CHANNEL_PARAMS_CMD *chParamCmd = (WMI_CHANNEL_PARAMS_CMD *)ioBuf;
if (strncasecmp(cmd, "COUNTRY ", 8)==0) {
char *country = cmd + 8;
if (strcasecmp(country, "US")==0) {
chan = 11;
} else if (strcasecmp(country, "JP")==0) {
chan = 14;
} else if (strcasecmp(country, "EU")==0) {
chan = 13;
}
} else if (sscanf(cmd, "%*s %d", &chan) != 1) {
return -1;
}
if ( (chan != 11) && (chan != 13) && (chan != 14)) {
return -1;
}
if (arPriv->arNextMode == AP_NETWORK) {
return -1;
}
A_MEMZERO(&ifr, sizeof(ifr));
A_MEMZERO(ioBuf, sizeof(ioBuf));
chParamCmd->phyMode = WMI_11G_MODE;
clist = chParamCmd->channelList;
chParamCmd->numChannels = chan;
chParamCmd->scanParam = 1;
for (i = 0; i < chan; i++) {
clist[i] = wlan_ieee2freq(i + 1);
}
return android_do_ioctl_direct(dev, AR6000_IOCTL_WMI_SET_CHANNELPARAMS, &ifr, ioBuf);
} else if (strncasecmp(cmd, "BTCOEXMODE ", 11)==0) {
int mode;
if (sscanf(cmd, "%*s %d", &mode)==1) {
/*
* Android disable BT-COEX when obtaining dhcp packet except there is headset is connected
* It enable the BT-COEX after dhcp process is finished
* We ignore since we have our way to do bt-coex during dhcp obtaining.
*/
switch (mode) {
case 1: /* Disable*/
break;
case 0: /* Enable */
/* fall through */
case 2: /* Sense*/
/* fall through */
default:
break;
}
return 0; /* ignore it */
}
return -1;
} else if (strcasecmp(cmd, "BTCOEXSCAN-START")==0) {
/* Android enable or disable Bluetooth coexistence scan mode. When this mode is on,
* some of the low-level scan parameters used by the driver are changed to
* reduce interference with A2DP streaming.
*/
return 0; /* ignore it since we have btfilter */
} else if (strcasecmp(cmd, "BTCOEXSCAN-STOP")==0) {
return 0; /* ignore it since we have btfilter */
} else if (strncasecmp(cmd, "RXFILTER-ADD ", 13)==0) {
return 0; /* ignore it */
} else if (strncasecmp(cmd, "RXFILTER-REMOVE ", 16)==0) {
return 0; /* ignoret it */
} else if (strcasecmp(cmd, "RXFILTER-START")==0 || strcasecmp(cmd, "RXFILTER-STOP")==0) {
unsigned int flags = dev->flags;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34)
int mc_count = dev->mc_count;
#else
int mc_count = netdev_mc_count(dev);
#endif
if (strcasecmp(cmd, "RXFILTER-START")==0) {
if (mc_count > 0 || (flags & IFF_MULTICAST) ) {
//flags &= ~IFF_MULTICAST; //to always enable multicast
flags |= IFF_MULTICAST;
}
} else {
flags |= IFF_MULTICAST;
}
if (flags != dev->flags) {
dev_change_flags(dev, flags);
}
return 0;
}
return -EOPNOTSUPP;
}
开发者ID:pocketbook,项目名称:801,代码行数:101,代码来源:ar6000_android.c
示例13: rst_restore_netdev
int rst_restore_netdev(struct cpt_context *ctx)
{
struct net *net = get_exec_env()->ve_netns;
int err;
loff_t sec = ctx->sections[CPT_SECT_NET_DEVICE];
loff_t endsec;
struct cpt_section_hdr h;
struct cpt_netdev_image di;
struct net_device *dev;
get_exec_env()->disable_net = 1;
if (sec == CPT_NULL)
return 0;
err = ctx->pread(&h, sizeof(h), ctx, sec);
if (err)
return err;
if (h.cpt_section != CPT_SECT_NET_DEVICE || h.cpt_hdrlen < sizeof(h))
return -EINVAL;
endsec = sec + h.cpt_next;
sec += h.cpt_hdrlen;
while (sec < endsec) {
loff_t pos;
struct net_device *dev_new;
struct netdev_rst *ops;
err = rst_get_object(CPT_OBJ_NET_DEVICE, sec, &di, ctx);
if (err)
return err;
rtnl_lock();
pos = sec + di.cpt_hdrlen;
if (di.cpt_next > sizeof(di)) {
struct cpt_object_hdr hdr;
err = ctx->pread(&hdr, sizeof(struct cpt_object_hdr),
ctx, sec + di.cpt_hdrlen);
if (err)
goto out;
ops = NULL;
while (1) {
ops = netdev_find_rst(hdr.cpt_object, ops);
if (ops == NULL)
break;
err = ops->ndo_rst(sec, &di, &rst_ops, ctx);
if (!err) {
pos += hdr.cpt_next;
break;
} else if (err < 0) {
eprintk_ctx("netdev %d rst failed %d\n",
hdr.cpt_object, err);
goto out;
}
}
}
dev = __dev_get_by_name(net, di.cpt_name);
if (dev) {
if (dev->ifindex != di.cpt_index) {
dev_new = __dev_get_by_index(net, di.cpt_index);
if (!dev_new) {
write_lock_bh(&dev_base_lock);
hlist_del(&dev->index_hlist);
if (dev->iflink == dev->ifindex)
dev->iflink = di.cpt_index;
dev->ifindex = di.cpt_index;
hlist_add_head(&dev->index_hlist,
dev_index_hash(net, dev->ifindex));
write_unlock_bh(&dev_base_lock);
} else {
write_lock_bh(&dev_base_lock);
hlist_del(&dev->index_hlist);
hlist_del(&dev_new->index_hlist);
if (dev_new->iflink == dev_new->ifindex)
dev_new->iflink = dev->ifindex;
dev_new->ifindex = dev->ifindex;
if (dev->iflink == dev->ifindex)
dev->iflink = di.cpt_index;
dev->ifindex = di.cpt_index;
hlist_add_head(&dev->index_hlist,
dev_index_hash(net, dev->ifindex));
hlist_add_head(&dev_new->index_hlist,
dev_index_hash(net, dev_new->ifindex));
write_unlock_bh(&dev_base_lock);
}
}
if (di.cpt_flags^dev->flags) {
err = dev_change_flags(dev, di.cpt_flags);
if (err)
eprintk_ctx("dev_change_flags err: %d\n", err);
}
while (pos < sec + di.cpt_next) {
struct cpt_object_hdr hdr;
err = ctx->pread(&hdr, sizeof(struct cpt_object_hdr),
ctx, pos);
if (err)
goto out;
//.........这里部分代码省略.........
开发者ID:vps2fast,项目名称:openvz-kernel,代码行数:101,代码来源:rst_net.c
示例14: dev_ifsioc
/*
* Perform the SIOCxIFxxx calls, inside rtnl_lock()
*/
static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
{
int err;
struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
const struct net_device_ops *ops;
if (!dev)
return -ENODEV;
ops = dev->netdev_ops;
switch (cmd) {
case SIOCSIFFLAGS: /* Set interface flags */
return dev_change_flags(dev, ifr->ifr_flags);
case SIOCSIFMETRIC: /* Set the metric on the interface
(currently unused) */
return -EOPNOTSUPP;
case SIOCSIFMTU: /* Set the MTU of a device */
return dev_set_mtu(dev, ifr->ifr_mtu);
case SIOCSIFHWADDR:
if (dev->addr_len > sizeof(struct sockaddr))
return -EINVAL;
return dev_set_mac_address(dev, &ifr->ifr_hwaddr);
case SIOCSIFHWBROADCAST:
if (ifr->ifr_hwaddr.sa_family != dev->type)
return -EINVAL;
memcpy(dev->broadcast, ifr->ifr_hwaddr.sa_data,
min(sizeof(ifr->ifr_hwaddr.sa_data),
(size_t)dev->addr_len));
call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
return 0;
case SIOCSIFMAP:
if (ops->ndo_set_config) {
if (!netif_device_present(dev))
return -ENODEV;
return ops->ndo_set_config(dev, &ifr->ifr_map);
}
return -EOPNOTSUPP;
case SIOCADDMULTI:
if (!ops->ndo_set_rx_mode ||
ifr->ifr_hwaddr.sa_family != AF_UNSPEC)
return -EINVAL;
if (!netif_device_present(dev))
return -ENODEV;
return dev_mc_add_global(dev, ifr->ifr_hwaddr.sa_data);
case SIOCDELMULTI:
if (!ops->ndo_set_rx_mode ||
ifr->ifr_hwaddr.sa_family != AF_UNSPEC)
return -EINVAL;
if (!netif_device_present(dev))
return -ENODEV;
return dev_mc_del_global(dev, ifr->ifr_hwaddr.sa_data);
case SIOCSIFTXQLEN:
if (ifr->ifr_qlen < 0)
return -EINVAL;
return dev_change_tx_queue_len(dev, ifr->ifr_qlen);
case SIOCSIFNAME:
ifr->ifr_newname[IFNAMSIZ-1] = '\0';
return dev_change_name(dev, ifr->ifr_newname);
case SIOCSHWTSTAMP:
err = net_hwtstamp_validate(ifr);
if (err)
return err;
/* fall through */
/*
* Unknown or private ioctl
*/
default:
if ((cmd >= SIOCDEVPRIVATE &&
cmd <= SIOCDEVPRIVATE + 15) ||
cmd == SIOCBONDENSLAVE ||
cmd == SIOCBONDRELEASE ||
cmd == SIOCBONDSETHWADDR ||
cmd == SIOCBONDSLAVEINFOQUERY ||
cmd == SIOCBONDINFOQUERY ||
cmd == SIOCBONDCHANGEACTIVE ||
cmd == SIOCGMIIPHY ||
cmd == SIOCGMIIREG ||
cmd == SIOCSMIIREG ||
cmd == SIOCBRADDIF ||
cmd == SIOCBRDELIF ||
cmd == SIOCSHWTSTAMP ||
cmd == SIOCGHWTSTAMP ||
cmd == SIOCWANDEV) {
err = -EOPNOTSUPP;
if (ops->ndo_do_ioctl) {
//.........这里部分代码省略.........
开发者ID:Lyude,项目名称:linux,代码行数:101,代码来源:dev_ioctl.c
示例15: vlan_device_event
static int vlan_device_event(struct notifier_block *unused, unsigned long event, void *ptr)
{
struct net_device *dev = (struct net_device *)(ptr);
struct vlan_group *grp = NULL;
int i, flgs;
struct net_device *vlandev = NULL;
spin_lock_bh(&vlan_group_lock);
grp = __vlan_find_group(dev->ifindex);
spin_unlock_bh(&vlan_group_lock);
if (!grp)
goto out;
/* It is OK that we do not hold the group lock right now,
* as we run under the RTNL lock.
*/
switch (event) {
case NETDEV_CHANGEADDR:
case NETDEV_GOING_DOWN:
/* Ignore for now */
break;
case NETDEV_DOWN:
/* Put all VLANs for this dev in the down state too. */
for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
vlandev = grp->vlan_devices[i];
if (!vlandev)
continue;
flgs = vlandev->flags;
if (!(flgs & IFF_UP))
continue;
dev_change_flags(vlandev, flgs & ~IFF_UP);
}
break;
case NETDEV_UP:
/* Put all VLANs for this dev in the up state too. */
for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
vlandev = grp->vlan_devices[i];
if (!vlandev)
continue;
flgs = vlandev->flags;
if (flgs & IFF_UP)
continue;
dev_change_flags(vlandev, flgs | IFF_UP);
}
break;
case NETDEV_UNREGISTER:
/* Delete all VLANs for this dev. */
for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
int ret;
vlandev = grp->vlan_devices[i];
if (!vlandev)
continue;
ret = unregister_vlan_dev(dev,
VLAN_DEV_INFO(vlandev)->vlan_id);
dev_put(vlandev);
unregister_netdevice(vlandev);
/* Group was destroyed? */
if (ret == 1)
break;
}
break;
};
out:
return NOTIFY_DONE;
}
开发者ID:ProjectZeroSlackr,项目名称:linux-2.4.32-ipod,代码行数:79,代码来源:vlan.c
示例16: vlan_device_event
static int vlan_device_event(struct notifier_block *unused, unsigned long event, void *ptr)
{
struct net_device *dev = ptr;
struct vlan_group *grp = vlan_find_group(dev->ifindex);
int i, flgs;
struct net_device *vlandev;
if (!grp)
goto out;
/* It is OK that we do not hold the group lock right now,
* as we run under the RTNL lock.
*/
switch (event) {
case NETDEV_CHANGE:
/* Propagate real device state to vlan devices */
for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
vlandev = vlan_group_get_device(grp, i);
if (!vlandev)
continue;
vlan_transfer_operstate(dev, vlandev);
}
break;
case NETDEV_DOWN:
/* Put all VLANs for this dev in the down state too. */
for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
vlandev = vlan_group_get_device(grp, i);
if (!vlandev)
continue;
flgs = vlandev->flags;
if (!(flgs & IFF_UP))
continue;
dev_change_flags(vlandev, flgs & ~IFF_UP);
}
break;
case NETDEV_UP:
/* Put all VLANs for this dev in the up state too. */
for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
vlandev = vlan_group_get_device(grp, i);
if (!vlandev)
continue;
flgs = vlandev->flags;
if (flgs & IFF_UP)
continue;
dev_change_flags(vlandev, flgs | IFF_UP);
}
break;
case NETDEV_UNREGISTER:
/* Delete all VLANs for this dev. */
for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
int ret;
vlandev = vlan_group_get_device(grp, i);
if (!vlandev)
continue;
flgs = vlandev->flags;
if (!(flgs & IFF_UP))
continue;
ret = unregister_vlan_dev(dev,
VLAN_DEV_INFO(vlandev)->vlan_id);
unregister_netdevice(vlandev);
/* Group was destroyed? */
if (ret == 1)
break;
}
break;
};
out:
return NOTIFY_DONE;
}
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:84,代码来源:vlan.c
示例17: change_flags
static int change_flags(struct net_device *dev, unsigned long new_flags)
{
return dev_change_flags(dev, (unsigned int)new_flags, NULL);
}
开发者ID:lfd,项目名称:PreemptRT,代码行数:4,代码来源:net-sysfs.c
示例18: ovs_dp_get_net
static struct vport *vxlan_tnl_create(const struct vport_parms *parms)
{
struct net *net = ovs_dp_get_net(parms->dp);
struct nlattr *options = parms->options;
struct net_device *dev;
struct vport *vport;
struct nlattr *a;
int err;
struct vxlan_config conf = {
.no_share = true,
.flags = VXLAN_F_COLLECT_METADATA,
};
if (!options) {
err = -EINVAL;
goto error;
}
a = nla_find_nested(options, OVS_TUNNEL_ATTR_DST_PORT);
if (a && nla_len(a) == sizeof(u16)) {
conf.dst_port = htons(nla_get_u16(a));
} else {
/* Require destination port from userspace. */
err = -EINVAL;
goto error;
}
vport = ovs_vport_alloc(0, &ovs_vxlan_netdev_vport_ops, parms);
if (IS_ERR(vport))
return vport;
a = nla_find_nested(options, OVS_TUNNEL_ATTR_EXTENSION);
if (a) {
err = vxlan_configure_exts(vport, a, &conf);
if (err) {
ovs_vport_free(vport);
goto error;
}
}
rtnl_lock();
dev = vxlan_dev_create(net, parms->name, NET_NAME_USER, &conf);
if (IS_ERR(dev)) {
rtnl_unlock();
ovs_vport_free(vport);
return ERR_CAST(dev);
}
dev_change_flags(dev, dev->flags | IFF_UP);
rtnl_unlock();
return vport;
error:
return ERR_PTR(err);
}
static struct vport *vxlan_create(const struct vport_parms *parms)
{
struct vport *vport;
vport = vxlan_tnl_create(parms);
if (IS_ERR(vport))
return vport;
return ovs_netdev_link(vport, parms->name);
}
static int vxlan_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
struct dp_upcall_info *upcall)
{
struct vxlan_dev *vxlan = netdev_priv(vport->dev);
struct net *net = ovs_dp_get_net(vport->dp);
unsigned short family = ip_tunnel_info_af(upcall->egress_tun_info);
__be16 dst_port = vxlan_dev_dst_port(vxlan, family);
__be16 src_port;
int port_min;
int port_max;
inet_get_local_port_range(net, &port_min, &port_max);
src_port = udp_flow_src_port(net, skb, 0, 0, true);
return ovs_tunnel_get_egress_info(upcall, net,
skb, IPPROTO_UDP,
src_port, dst_port);
}
static struct vport_ops ovs_vxlan_netdev_vport_ops = {
.type = OVS_VPORT_TYPE_VXLAN,
.create = vxlan_create,
.destroy = ovs_netdev_tunnel_destroy,
.get_options = vxlan_get_options,
.send = ovs_netdev_send,
.get_egress_tun_info = vxlan_get_egress_tun_info,
};
static int __init ovs_vxlan_tnl_init(void)
{
return ovs_vport_ops_register(&ovs_vxlan_netdev_vport_ops);
}
static void __exit ovs_vxlan_tnl_exit(void)
//.........这里部分代码省略.........
开发者ID:coralreef2046,项目名称:net-next-nuse,代码行数:101,代码来源:vport-vxlan.c
示例19: vlan_device_event
static int vlan_device_event(struct notifier_block *unused, unsigned long event,
void *ptr)
{
struct net_device *dev = ptr;
struct vlan_group *grp;
struct vlan_info *vlan_info;
int i, flgs;
struct net_device *vlandev;
struct vlan_dev_priv *vlan;
LIST_HEAD(list);
if (is_vlan_dev(dev))
__vlan_device_event(dev, event);
if ((event == NETDEV_UP) &&
(dev->features & NETIF_F_HW_VLAN_FILTER)) {
pr_info("adding VLAN 0 to HW filter on device %s\n",
dev->name);
vlan_vid_add(dev, 0);
}
vlan_info = rtnl_dereference(dev->vlan_info);
if (!vlan_info)
goto out;
grp = &vlan_info->grp;
/* It is OK that we do not hold the group lock right now,
* as we run under the RTNL lock.
*/
switch (event) {
case NETDEV_CHANGE:
/* Propagate real device state to vlan devices */
for (i = 0; i < VLAN_N_VID; i++) {
vlandev = vlan_group_get_device(grp, i);
if (!vlandev)
continue;
netif_stacked_transfer_operstate(dev, vlandev);
}
break;
case NETDEV_CHANGEADDR:
/* Adjust unicast filters on underlying device */
for (i = 0; i < VLAN_N_VID; i++) {
vlandev = vlan_group_get_device(grp, i);
if (!vlandev)
continue;
flgs = vlandev->flags;
if (!(flgs & IFF_UP))
continue;
vlan_sync_address(dev, vlandev);
}
break;
case NETDEV_CHANGEMTU:
for (i = 0; i < VLAN_N_VID; i++) {
vlandev = vlan_group_get_device(grp, i);
if (!vlandev)
continue;
if (vlandev->mtu <= dev->mtu)
continue;
dev_set_mtu(vlandev, dev->mtu);
}
break;
case NETDEV_FEAT_CHANGE:
/* Propagate device features to underlying device */
for (i = 0; i < VLAN_N_VID; i++) {
vlandev = vlan_group_get_device(grp, i);
if (!vlandev)
continue;
vlan_transfer_features(dev, vlandev);
}
break;
case NETDEV_DOWN:
if (dev->features & NETIF_F_HW_VLAN_FILTER)
vlan_vid_del(dev, 0);
/* Put all VLANs for this dev in the down state too. */
for (i = 0; i < VLAN_N_VID; i++) {
vlandev = vlan_group_get_device(grp, i);
if (!vlandev)
continue;
flgs = vlandev->flags;
if (!(flgs & IFF_UP))
continue;
vlan = vlan_dev_priv(vlandev);
if (!(vlan->flags & VLAN_FLAG_LOOSE_BINDING))
dev_change_flags(vlandev, flgs & ~IFF_UP);
netif_stacked_transfer_operstate(dev, vlandev);
//.........这里部分代码省略.........
开发者ID:PterX,项目名称:rt-n56u,代码行数:101,代码来源:vlan.c
|
请发表评论