From e58f5b6e2ef7ec859b799ba3d58914443ae47efe Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 20 Sep 2010 21:18:30 +0200 Subject: Add support for setting actual device flags * pfinet/ethernet.c (ethernet_change_flags): New function. * pfinet/pfinet.h (ethernet_change_flags): New declaration. * pfinet/iioctl-ops.c (S_iioctl_siocsifflags): Also call `ethernet_change_flags' after calling `dev_change_flags'. --- pfinet/ethernet.c | 16 ++++++++++++++++ pfinet/iioctl-ops.c | 6 +++++- pfinet/pfinet.h | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'pfinet') diff --git a/pfinet/ethernet.c b/pfinet/ethernet.c index d37b90dd..dab5c56f 100644 --- a/pfinet/ethernet.c +++ b/pfinet/ethernet.c @@ -199,6 +199,22 @@ ethernet_xmit (struct sk_buff *skb, struct device *dev) return 0; } +/* Set device flags (e.g. promiscuous) */ +int +ethernet_change_flags (struct device *dev, short flags) +{ + error_t err = 0; +#ifdef NET_FLAGS + int status = flags; + struct ether_device *edev = (struct ether_device *) dev->priv; + err = device_set_status (edev->ether_port, NET_FLAGS, &status, 1); + if (err == D_INVALID_OPERATION) + /* Not supported, ignore. */ + err = 0; +#endif + return err; +} + void setup_ethernet_device (char *name, struct device **device) { diff --git a/pfinet/iioctl-ops.c b/pfinet/iioctl-ops.c index 637e9f5b..c0dd6d5f 100644 --- a/pfinet/iioctl-ops.c +++ b/pfinet/iioctl-ops.c @@ -188,7 +188,11 @@ S_iioctl_siocsifflags (io_t port, else if (!dev) err = ENODEV; else - err = dev_change_flags(dev, flags); + { + err = dev_change_flags (dev, flags); + if (!err) + err = ethernet_change_flags (dev, flags); + } __mutex_unlock (&global_lock); end_using_socket_port (user); diff --git a/pfinet/pfinet.h b/pfinet/pfinet.h index 77027b22..050ba6f7 100644 --- a/pfinet/pfinet.h +++ b/pfinet/pfinet.h @@ -67,6 +67,7 @@ uid_t pfinet_group; void ethernet_initialize (void); int ethernet_demuxer (mach_msg_header_t *, mach_msg_header_t *); +int ethernet_change_flags (struct device *, short); void setup_ethernet_device (char *, struct device **); void setup_dummy_device (char *, struct device **); void setup_tunnel_device (char *, struct device **); -- cgit v1.2.3