diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2001-01-11 22:28:29 +0000 |
---|---|---|
committer | Marcus Brinkmann <marcus@gnu.org> | 2001-01-11 22:28:29 +0000 |
commit | 2a0220f19b262f122bc8dc7b68e6f4c0a5a16cae (patch) | |
tree | 933d00b5e3b4b7371ccf1b10f2a24affa2bfc70d /pfinet/pfinet-ops.c | |
parent | f63be3bda31acdc2a88e1cd64770966e73ca0b5d (diff) | |
download | hurd-2a0220f19b262f122bc8dc7b68e6f4c0a5a16cae.tar.gz hurd-2a0220f19b262f122bc8dc7b68e6f4c0a5a16cae.tar.bz2 hurd-2a0220f19b262f122bc8dc7b68e6f4c0a5a16cae.zip |
hurd/
2001-01-07 Marcus Brinkmann <marcus@gnu.org>
* ioctl_types.h: Include <net/if.h>, define types sockaddr_t and
ifname_t for iioctl.defs.
* iioctl.defs: New file for network interface ioctls.
* pfinet.defs: Remove old RPCs, fix subsystem number, add RPC for
SIOCGIFCONF.
pfinet/
2001-01-07 Marcus Brinkmann <marcus@gnu.org>
* pfinet-ops.c: New file to implement hurd/pfinet.defs.
* iioctl-ops.c: New file to implement iioctl.defs.
* linux-src/net/core/dev.c: If _HURD_, don't define netdev_chain as
static.
* glue-include/linux/if.h: New file, to avoid conflict between
<net/if.h> (imported by iioctl.defs) and linux version of it.
* main.c (pfinet_demuxer): Prototype pfinet_server and
iioctl_server, use them.
* pfinet.h: New global variables pfinetctl, pfinet_owner
and pfinet_group.
* main.c (main): New variable ST. Request pfinetctl from
trivfs_startup. Use it to determine the owner and group
of the underlying node.
* io-ops.c (S_io_reauthenticate): New index variable j. Set
newuser->isroot also for owners of the underlying file and
group owners.
(S_io_restrict_auth): Likewise.
* socket-ops.c: Include <sys/stat.h> and <hurd/fshelp.h>.
(S_socket_create): New variable isroot. If master->isroot is
not set, use fshelp_isowner to check ownership and if to set it.
Pass isroot to make_sock_user instead master->isroot.
* linux-src/net/ipv4/devinet.c (configure_device): Accept new parameter
BROADCAST, set ifa_broadcast if this is not INADDR_NONE.
(inquire_device): Accept new parameter broadcast, set it.
* main.c: Add new paramter to prototype of configure_device.
(main): Add new parameter to call to configure_device.
* options.c: Add new parameters to prototypes of configure_device
and inquire_device.
(trivfs_append_args): Define new variable BROAD, use its address
as the new parameter for inquire_device.
* linux-src/net/core/dev.c (dev_ifconf): Don't declare static
if _HURD_.
* linux-src/net/ipv4/devinet.c (inet_gifconf): If _HURD_, set
sin_len member.
* Makefile (MIGSRCS): Add pfinetServer.c and iioctlServer.c.
(SRCS): Add pfinet-ops.c, iioctl-ops.c.
Diffstat (limited to 'pfinet/pfinet-ops.c')
-rw-r--r-- | pfinet/pfinet-ops.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/pfinet/pfinet-ops.c b/pfinet/pfinet-ops.c new file mode 100644 index 00000000..594b5ac7 --- /dev/null +++ b/pfinet/pfinet-ops.c @@ -0,0 +1,93 @@ +/* + Copyright (C) 2000 Free Software Foundation, Inc. + Written by Marcus Brinkmann. + + This file is part of the GNU Hurd. + + The GNU Hurd is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + The GNU Hurd is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ + +#include "pfinet.h" + +#include <linux/netdevice.h> +#include <linux/notifier.h> + +#include "pfinet_S.h" +#include <netinet/in.h> +#include <fcntl.h> +#include <string.h> +#include <unistd.h> +#include <mach/notify.h> +#include <sys/mman.h> + +#include <sys/ioctl.h> +#include <net/if.h> + +extern int dev_ifconf(char *arg); + +/* Return the list of devices in the format provided by SIOCGIFCONF + in IFR, but don't return more then AMOUNT bytes. If AMOUNT is + negative, there is no limit. */ +error_t +S_pfinet_siocgifconf (io_t port, + int amount, + char **ifr, + mach_msg_type_number_t *len) +{ + error_t err = 0; + struct ifconf ifc; + + __mutex_lock (&global_lock); + if (amount < 0) + { + /* Get the needed buffer length. */ + ifc.ifc_buf = NULL; + ifc.ifc_len = 0; + err = dev_ifconf ((char *) &ifc); + if (err) + { + __mutex_unlock (&global_lock); + return -err; + } + amount = ifc.ifc_len; + } + else + ifc.ifc_len = amount; + + if (amount > 0) + { + /* Possibly allocate a new buffer. */ + if (*len < amount) + ifc.ifc_buf = (char *) mmap (0, amount, PROT_READ|PROT_WRITE, + MAP_ANON, 0, 0); + else + ifc.ifc_buf = *ifr; + err = dev_ifconf ((char *) &ifc); + } + + if (err) + { + *len = 0; + if (ifc.ifc_buf != *ifr) + munmap (ifc.ifc_buf, amount); + } + else + { + *len = ifc.ifc_len; + *ifr = ifc.ifc_buf; + } + + __mutex_unlock (&global_lock); + return err; +} |