bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The patch of gnumach to enable the user to set the network device in


From: zhengda
Subject: Re: The patch of gnumach to enable the user to set the network device into the promiscuous mode
Date: Sun, 10 Aug 2008 20:29:55 +0200
User-agent: Thunderbird 2.0.0.16 (X11/20080707)

Samuel Thibault wrote:
About changelogs, please really read the GNU coding style (or re-read
it): you _need_ to give the name for the added macros for instance,
that's precisely the purpose of the ChangeLog file.

Samuel
Sorry, here goes the patch again.

Needed for GNU Mach 1.2

2008-07-29 Zheng Da <zhengda1936@gmail.com>

   * include/device/net_status.h (NET_FLAGS): Macro defined.

* linux/dev/glue/net.c (device_get_status, device_set_status): Handle NET_FLAGS.

   * linux/dev/net/core/dev.c (dev_change_flags): New function.

diff -ur gnumach.old/include/device/net_status.h gnumach/include/device/net_status.h --- gnumach.old/include/device/net_status.h 2006-04-27 02:56:34.570000000 +0200 +++ gnumach/include/device/net_status.h 2008-07-12 05:53:02.240000000 +0200
@@ -72,6 +72,7 @@

#define    NET_DSTADDR        (('n'<<16) + 3)

+#define NET_FLAGS               (('n'<<16) + 4)

/*
 * Input packet filter definition
diff -ur gnumach.old/linux/dev/glue/net.c gnumach/linux/dev/glue/net.c
--- gnumach.old/linux/dev/glue/net.c    2007-10-09 09:44:17.200000000 +0200
+++ gnumach/linux/dev/glue/net.c    2008-07-30 06:43:48.410000000 +0200
@@ -533,6 +533,17 @@
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 @@
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 -ur gnumach.old/linux/dev/include/linux/netdevice.h gnumach/linux/dev/include/linux/netdevice.h --- gnumach.old/linux/dev/include/linux/netdevice.h 1999-04-26 07:47:56.630000000 +0200 +++ gnumach/linux/dev/include/linux/netdevice.h 2008-07-12 05:52:01.630000000 +0200
@@ -271,6 +271,7 @@
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 -ur gnumach.old/linux/dev/net/core/dev.c gnumach/linux/dev/net/core/dev.c --- gnumach.old/linux/dev/net/core/dev.c 1999-04-26 07:50:13.810000000 +0200
+++ gnumach/linux/dev/net/core/dev.c    2008-07-12 05:16:32.810000000 +0200
@@ -1618,3 +1618,31 @@
    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;
+}
+





reply via email to

[Prev in Thread] Current Thread [Next in Thread]