diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2000-10-04 01:59:03 +0000 |
---|---|---|
committer | Marcus Brinkmann <marcus@gnu.org> | 2000-10-04 01:59:03 +0000 |
commit | 898424326fc1188384f67963ab6789f18dd57fd3 (patch) | |
tree | a4085609a66d34f0f0a59647ed236e64d3aa9bfc /pfinet/dummy.c | |
parent | b81d9ec23532ba8b2519ba3b8bf68fcfeb0260c5 (diff) | |
download | hurd-898424326fc1188384f67963ab6789f18dd57fd3.tar.gz hurd-898424326fc1188384f67963ab6789f18dd57fd3.tar.bz2 hurd-898424326fc1188384f67963ab6789f18dd57fd3.zip |
2000-10-04 Marcus Brinkmann <marcus@gnu.org>
* Makefile (SRCS): Add dummy.c
* dummy.c: New file.
* ethernet.c: Moved ETHER_PORT, READPT, READPTNAME to ...
(struct ether_device): ... here. New struct. ETHER_DEV is now a
pointer to a struct ether_device.
(ethernet_demuxer): New variables edev, dev. Iterate over linked
list ETHER_DEV to find correct readptname. Use dev instead
ETHER_DEV for socket buffer manipulation.
(ethernet_open): New variable edev. Use dev->priv to find correct
edev. Use members of edev instead global variables.
(ethernet_xmit): New variable edev. Use dev->priv to find correct
edev.Use member of edev instead global variable ETHER_PORT.
(setup_ethernet_device): New output argument DEVICE. New
variables edev and dev. Allocate memory for edev, add it to the
head of ETHER_DEV. Use dev instead ETHER_DEV. Use members of edev
instead global variables.
* main.c: ALREADY_OPEN removed.
(find_device): Fix comment. Redone to work with multiple devices
by iterating over DEV_BASE.
(enumerate_device): Likewise.
* pfinet.h: Add new argument to prototype of
setup_ethernet_device. Add prototype for setup_dummy_device.
Remove prototype for ETHER_DEV. Add prototype for DEV_BASE.
Diffstat (limited to 'pfinet/dummy.c')
-rw-r--r-- | pfinet/dummy.c | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/pfinet/dummy.c b/pfinet/dummy.c new file mode 100644 index 00000000..523b218f --- /dev/null +++ b/pfinet/dummy.c @@ -0,0 +1,138 @@ +/* + Copyright (C) 1995,96,98,99,2000 Free Software Foundation, Inc. + Written by Michael I. Bushnell, p/BSG. + + 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 <device/device.h> +#include <device/net_status.h> +#include <netinet/in.h> +#include <string.h> +#include <error.h> + +#include <linux/netdevice.h> +#include <linux/etherdevice.h> +#include <linux/if_arp.h> + +struct dummy_device +{ + struct dummy_device *next; + struct device dev; + struct net_device_stats stats; +}; + +/* Linked list of all dummy devices. */ +struct dummy_device *dummy_dev; + +struct net_device_stats * +dummy_get_stats (struct device *dev) +{ + struct dummy_device *ddev = (struct dummy_device *) dev->priv; + return &ddev->stats; +} + +int +dummy_stop (struct device *dev) +{ + return 0; +} + +void +dummy_set_multi (struct device *dev) +{ +} + +int +dummy_open (struct device *dev) +{ + return 0; +} + +int +dummy_xmit (struct sk_buff *skb, struct device *dev) +{ + struct dummy_device *ddev = (struct dummy_device *) dev->priv; + + ddev->stats.tx_packets++; + ddev->stats.tx_bytes += skb->len; + + dev_kfree_skb (skb); + return 0; +} + +void +setup_dummy_device (char *name, struct device **device) +{ + error_t err; + struct dummy_device *ddev; + struct device *dev; + + ddev = calloc (1, sizeof (struct dummy_device)); + if (!ddev) + error (2, ENOMEM, "%s", name); + ddev->next = dummy_dev; + dummy_dev = ddev; + + *device = dev = &ddev->dev; + + dev->name = strdup (name); + + dev->priv = ddev; + dev->get_stats = dummy_get_stats; + + dev->open = dummy_open; + dev->stop = dummy_stop; + dev->hard_start_xmit = dummy_xmit; + dev->set_multicast_list = dummy_set_multi; + + /* These are the ones set by drivers/net/net_init.c::ether_setup. */ + dev->hard_header = eth_header; + dev->rebuild_header = eth_rebuild_header; + dev->hard_header_cache = eth_header_cache; + dev->header_cache_update = eth_header_cache_update; + dev->hard_header_parse = eth_header_parse; + /* We can't do these two (and we never try anyway). */ + /* dev->change_mtu = eth_change_mtu; */ + /* dev->set_mac_address = eth_mac_addr; */ + + /* Some more fields */ + dev->type = ARPHRD_ETHER; + dev->hard_header_len = ETH_HLEN; + dev->addr_len = ETH_ALEN; + memset (dev->broadcast, 0xff, ETH_ALEN); + dev->flags = IFF_BROADCAST | IFF_MULTICAST; + dev_init_buffers (dev); + + dev->mtu = 1500; + dev->tx_queue_len = 0; + dev->flags |= IFF_NOARP; + dev->flags &= ~IFF_MULTICAST; + + /* That should be enough. */ + + /* This call adds the device to the `dev_base' chain, + initializes its `ifindex' member (which matters!), + and tells the protocol stacks about the device. */ + err = - register_netdevice (dev); + assert_perror (err); +} + + + + |