[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SIOCGIFHWADDR support for pfinet
From: |
Marcus Brinkmann |
Subject: |
Re: SIOCGIFHWADDR support for pfinet |
Date: |
Wed, 09 Feb 2005 16:15:24 +0100 |
User-agent: |
Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/21.3 (i386-pc-linux-gnu) MULE/5.0 (SAKAKI) |
At Tue, 03 Aug 2004 16:03:11 +0200,
Marco Gerards wrote:
> On debian-hurd someone noticed SIOCGIFHWADDR does not exist for
> GNU/Hurd. I have included the required patches for the Hurd and glibc
> with this email. Or can someone suggest a better way to read the
> hardware address?
It seems basically ok to me. However, I think that two small changes
could/should be made.
1. Only copy dev->addr_len bytes into the user buffer. It's best to
give out less information than more.
2. Independent of that, do we need to check if there even is a
hardware address? For example, what is the dev_addr of the
loopback interface? How does Linux ifconfig detect that the
loopback interface doesn't have a valid MAC? Do we initialize it
correctly in loopback.c and does your code deal with it in a
compatible way?
I didn't do much to try to answer the second question, although the
answer should be readily available by looking at Linux and net-tools
source code. Once we have determined that unconditionally copying the
dev_addr field is ok, or did an appropriate check, it can go in (with
the addr_len change mentioned above).
Thanks,
Marcus
> 2004-08-03 Marco Gerards <metgerards@student.han.nl>
>
> * sysdeps/mach/hurd/bits/ioctls.h (SIOCGIFHWADDR): New macro.
>
>
> Index: sysdeps/mach/hurd/bits/ioctls.h
> ===================================================================
> RCS file: /cvs/glibc/libc/sysdeps/mach/hurd/bits/ioctls.h,v
> retrieving revision 1.7
> diff -u -p -u -p -r1.7 ioctls.h
> --- sysdeps/mach/hurd/bits/ioctls.h 6 Jul 2001 04:55:58 -0000 1.7
> +++ sysdeps/mach/hurd/bits/ioctls.h 3 Aug 2004 13:55:34 -0000
> @@ -226,6 +226,7 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_
> #define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet
> address */
> #define OSIOCGIFADDR _IOWR('i',13, struct ifreq) /* get ifnet
> address */
> #define SIOCGIFADDR _IOWR('i',33, struct ifreq) /* get ifnet
> address */
> +#define SIOCGIFHWADDR _IOWR('i',39, struct ifreq) /* get
> hwaddress */
> #define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p
> address */
> #define OSIOCGIFDSTADDR _IOWR('i',15, struct ifreq) /* get p-p
> address */
> #define SIOCGIFDSTADDR _IOWR('i',34, struct ifreq) /* get p-p
> address */
>
>
>
> 2004-08-03 Marco Gerards <metgerards@student.han.nl>
>
> * iioctl.defs (iioctl_siocgifhwaddr): New RPC.
>
> Index: iioctl.defs
> ===================================================================
> RCS file: /cvsroot/hurd/hurd/hurd/iioctl.defs,v
> retrieving revision 1.1
> diff -u -p -r1.1 iioctl.defs
> --- iioctl.defs 11 Jan 2001 22:28:29 -0000 1.1
> +++ iioctl.defs 3 Aug 2004 13:12:34 -0000
> @@ -131,7 +131,14 @@ routine iioctl_siocgifnetmask (
> inout ifnam: ifname_t;
> inout netmask: sockaddr_t);
>
> -skip; skip; skip; skip; /* 38, 39, 40, 41 unused */
> +skip; /* 38 SIOCGARP -- Not implemented yet */
> +
> +routine iioctl_siocgifhwaddr (
> + reqport: io_t;
> + inout ifnam: ifname_t;
> + inout netmask: sockaddr_t);
> +
> +skip; skip; /* 40, 41 unused */
> skip; skip; skip; skip; /* 42, 43, 44, 45 unused */
> skip; skip; skip; skip; /* 46, 47, 48, 49 unused */
> skip; /* 50 unused */
>
>
>
> 2004-08-03 Marco Gerards <metgerards@student.han.nl>
>
> * iioctl-ops.c (S_iioctl_siocgifhwaddr): New function.
>
>
> Index: iioctl-ops.c
> ===================================================================
> RCS file: /cvsroot/hurd/hurd/pfinet/iioctl-ops.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 iioctl-ops.c
> --- iioctl-ops.c 17 Jan 2001 01:37:51 -0000 1.2
> +++ iioctl-ops.c 3 Aug 2004 13:11:45 -0000
> @@ -361,3 +361,28 @@ S_iioctl_siocgifname (io_t port,
>
> return err;
> }
> +
> +error_t
> +S_iioctl_siocgifhwaddr (io_t port,
> + ifname_t ifname,
> + sockaddr_t *addr)
> +{
> + error_t err = 0;
> + struct device *dev;
> +
> + if (!port)
> + return EOPNOTSUPP;
> +
> + dev = get_dev (ifname);
> + if (!dev)
> + err = ENODEV;
> + else
> + {
> + memcpy (addr->sa_data, dev->dev_addr, MAX_ADDR_LEN);
> + addr->sa_family = dev->type;
> +
> + }
> +
> + __mutex_unlock (&global_lock);
> + return err;
> +}
>
>
>
> _______________________________________________
> Bug-hurd mailing list
> Bug-hurd@gnu.org
> http://lists.gnu.org/mailman/listinfo/bug-hurd
>
- Re: SIOCGIFHWADDR support for pfinet,
Marcus Brinkmann <=