diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2008-08-09 14:35:27 +0000 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gnu.org> | 2009-06-18 00:27:18 +0200 |
commit | 5a97027c99163974a16614363dafc18a63b990e0 (patch) | |
tree | 544f2bea96a5d04c238b51b08ffb54b5f87421bf /linux | |
parent | 511300311b1a57ad7279f91ab11d1bcf6fe202da (diff) |
2008-07-29 Zheng Da <zhengda1936@gmail.com>
Manuel Menal <mmenal@hurdfr.org>
* include/device/net_status.h (NET_FLAGS): New macro.
* linux/dev/glue/net.c (device_get_status): Handle NET_FLAGS case.
(device_set_status): Likewise, calls dev_change_flags.
* linux/dev/include/linux/netdevice.h (dev_change_flags): Declare
function.
* linux/dev/net/core/dev.c (dev_change_flags): Add function.
Diffstat (limited to 'linux')
-rw-r--r-- | linux/dev/glue/net.c | 26 | ||||
-rw-r--r-- | linux/dev/include/linux/netdevice.h | 1 | ||||
-rw-r--r-- | linux/dev/net/core/dev.c | 28 |
3 files changed, 55 insertions, 0 deletions
diff --git a/linux/dev/glue/net.c b/linux/dev/glue/net.c index b76e098..20ce754 100644 --- a/linux/dev/glue/net.c +++ b/linux/dev/glue/net.c @@ -533,6 +533,17 @@ static io_return_t device_get_status (void *d, dev_flavor_t flavor, dev_status_t status, mach_msg_type_number_t *count) { + if (flavor == NET_FLAGS) + { + struct net_data *net = (struct net_data *) d; + + if (*count != sizeof(short)) + return D_INVALID_SIZE; + + *(short *) status = net->dev->flags; + return D_SUCCESS; + } + if(flavor >= SIOCIWFIRST && flavor <= SIOCIWLAST) { /* handle wireless ioctl */ @@ -592,6 +603,21 @@ 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 != sizeof(short)) + return D_INVALID_SIZE; + + short flags = *(short *) status; + 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; diff --git a/linux/dev/include/linux/netdevice.h b/linux/dev/include/linux/netdevice.h index ff25df1..e1a9a34 100644 --- a/linux/dev/include/linux/netdevice.h +++ b/linux/dev/include/linux/netdevice.h @@ -271,6 +271,7 @@ extern void net_bh(void); extern void dev_tint(struct linux_device *dev); #endif +extern int dev_change_flags(struct linux_device *dev, short flags); extern int dev_get_info(char *buffer, char **start, off_t offset, int length, int dummy); extern int dev_ioctl(unsigned int cmd, void *); diff --git a/linux/dev/net/core/dev.c b/linux/dev/net/core/dev.c index efe0246..cbdf8cc 100644 --- a/linux/dev/net/core/dev.c +++ b/linux/dev/net/core/dev.c @@ -1618,3 +1618,31 @@ int net_dev_init(void) init_bh(NET_BH, net_bh); return 0; } + +/* + * Change the flags of device DEV to FLAGS. + */ +int dev_change_flags (struct device *dev, short flags) +{ + if (securelevel > 0) + flags &= ~IFF_PROMISC; + + /* + * Set the flags on our device. + */ + + dev->flags = (flags & + (IFF_BROADCAST | IFF_DEBUG | IFF_LOOPBACK | + IFF_POINTOPOINT | IFF_NOTRAILERS | IFF_RUNNING | + IFF_NOARP | IFF_PROMISC | IFF_ALLMULTI | IFF_SLAVE + | IFF_MASTER | IFF_MULTICAST)) + | (dev->flags & (IFF_SOFTHEADERS|IFF_UP)); + + /* The flags are taken into account (multicast, promiscuous, ...) + in the set_multicast_list handler. */ + if ((dev->flags & IFF_UP) && dev->set_multicast_list != NULL) + dev->set_multicast_list (dev); + + return 0; +} + |