3 * Linux ethernet bridge
6 * Lennert Buytenhek <buytenh@gnu.org>
8 * $Id: br_device.c,v 1.6 2001/12/24 00:59:55 davem Exp $
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
16 #include <linux/kernel.h>
17 #include <linux/netdevice.h>
18 #include <linux/module.h>
19 #include <asm/uaccess.h>
20 #include "br_private.h"
22 static struct net_device_stats *br_dev_get_stats(struct net_device *dev)
24 struct net_bridge *br = netdev_priv(dev);
25 return &br->statistics;
28 int br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
30 struct net_bridge *br = netdev_priv(dev);
31 const unsigned char *dest = skb->data;
32 struct net_bridge_fdb_entry *dst;
34 br->statistics.tx_packets++;
35 br->statistics.tx_bytes += skb->len;
37 skb->mac.raw = skb->data;
38 skb_pull(skb, ETH_HLEN);
42 br_flood_deliver(br, skb, 0);
43 else if ((dst = __br_fdb_get(br, dest)) != NULL)
44 br_deliver(dst->dst, skb);
46 br_flood_deliver(br, skb, 0);
52 static int br_dev_open(struct net_device *dev)
54 struct net_bridge *br = netdev_priv(dev);
56 br_features_recompute(br);
57 netif_start_queue(dev);
58 br_stp_enable_bridge(br);
63 static void br_dev_set_multicast_list(struct net_device *dev)
67 static int br_dev_stop(struct net_device *dev)
69 br_stp_disable_bridge(netdev_priv(dev));
71 netif_stop_queue(dev);
76 static int br_change_mtu(struct net_device *dev, int new_mtu)
78 if (new_mtu < 68 || new_mtu > br_min_mtu(netdev_priv(dev)))
85 void br_dev_setup(struct net_device *dev)
87 memset(dev->dev_addr, 0, ETH_ALEN);
91 dev->do_ioctl = br_dev_ioctl;
92 dev->get_stats = br_dev_get_stats;
93 dev->hard_start_xmit = br_dev_xmit;
94 dev->open = br_dev_open;
95 dev->set_multicast_list = br_dev_set_multicast_list;
96 dev->change_mtu = br_change_mtu;
97 dev->destructor = free_netdev;
98 SET_MODULE_OWNER(dev);
99 dev->stop = br_dev_stop;
100 dev->tx_queue_len = 0;
101 dev->set_mac_address = NULL;
102 dev->priv_flags = IFF_EBRIDGE;