1 /* 2 * Linux ethernet bridge 3 * 4 * Authors: 5 * Lennert Buytenhek <buytenh@gnu.org> 6 * 7 * $Id: br_private.h,v 1.6.2.1 2001/12/24 00:59:27 davem Exp $ 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License 11 * as published by the Free Software Foundation; either version 12 * 2 of the License, or (at your option) any later version. 13 */ 14 15 #ifndef _BR_PRIVATE_H 16 #define _BR_PRIVATE_H 17 18 #include <linux/netdevice.h> 19 #include <linux/miscdevice.h> 20 #include <linux/if_bridge.h> 21 #include "br_private_timer.h" 22 23 #define BR_HASH_BITS 8 24 #define BR_HASH_SIZE (1 << BR_HASH_BITS) 25 26 #define BR_HOLD_TIME (1*HZ) 27 28 typedef struct bridge_id bridge_id; 29 typedef struct mac_addr mac_addr; 30 typedef __u16 port_id; 31 32 struct bridge_id 33 { 34 unsigned char prio[2]; 35 unsigned char addr[6]; 36 }; 37 38 struct mac_addr 39 { 40 unsigned char addr[6]; 41 unsigned char pad[2]; 42 }; 43 44 struct net_bridge_fdb_entry 45 { 46 struct net_bridge_fdb_entry *next_hash; 47 struct net_bridge_fdb_entry **pprev_hash; 48 atomic_t use_count; 49 mac_addr addr; 50 struct net_bridge_port *dst; 51 unsigned long ageing_timer; 52 unsigned is_local:1; 53 unsigned is_static:1; 54 }; 55 56 struct net_bridge_port 57 { 58 struct net_bridge_port *next; 59 struct net_bridge *br; 60 struct net_device *dev; 61 int port_no; 62 63 /* STP */ 64 port_id port_id; 65 int state; 66 int path_cost; 67 bridge_id designated_root; 68 int designated_cost; 69 bridge_id designated_bridge; 70 port_id designated_port; 71 unsigned topology_change_ack:1; 72 unsigned config_pending:1; 73 int priority; 74 75 struct br_timer forward_delay_timer; 76 struct br_timer hold_timer; 77 struct br_timer message_age_timer; 78 }; 79 80 struct net_bridge 81 { 82 rwlock_t lock; 83 struct net_bridge_port *port_list; 84 struct net_device dev; 85 struct net_device_stats statistics; 86 rwlock_t hash_lock; 87 struct net_bridge_fdb_entry *hash[BR_HASH_SIZE]; 88 struct timer_list tick; 89 90 /* STP */ 91 bridge_id designated_root; 92 int root_path_cost; 93 int root_port; 94 int max_age; 95 int hello_time; 96 int forward_delay; 97 bridge_id bridge_id; 98 int bridge_max_age; 99 int bridge_hello_time; 100 int bridge_forward_delay; 101 unsigned stp_enabled:1; 102 unsigned topology_change:1; 103 unsigned topology_change_detected:1; 104 105 struct br_timer hello_timer; 106 struct br_timer tcn_timer; 107 struct br_timer topology_change_timer; 108 struct br_timer gc_timer; 109 110 int ageing_time; 111 int gc_interval; 112 }; 113 114 extern struct notifier_block br_device_notifier; 115 extern unsigned char bridge_ula[6]; 116 117 /* br.c */ 118 extern void br_dec_use_count(void); 119 extern void br_inc_use_count(void); 120 121 /* br_device.c */ 122 extern void br_dev_setup(struct net_device *dev); 123 extern int br_dev_xmit(struct sk_buff *skb, struct net_device *dev); 124 125 /* br_fdb.c */ 126 extern void br_fdb_changeaddr(struct net_bridge_port *p, 127 unsigned char *newaddr); 128 extern void br_fdb_cleanup(struct net_bridge *br); 129 extern void br_fdb_delete_by_port(struct net_bridge *br, 130 struct net_bridge_port *p); 131 extern struct net_bridge_fdb_entry *br_fdb_get(struct net_bridge *br, 132 unsigned char *addr); 133 extern void br_fdb_put(struct net_bridge_fdb_entry *ent); 134 extern int br_fdb_get_entries(struct net_bridge *br, 135 unsigned char *_buf, 136 int maxnum, 137 int offset); 138 extern void br_fdb_insert(struct net_bridge *br, 139 struct net_bridge_port *source, 140 unsigned char *addr, 141 int is_local); 142 143 /* br_forward.c */ 144 extern void br_deliver(struct net_bridge_port *to, 145 struct sk_buff *skb); 146 extern void br_forward(struct net_bridge_port *to, 147 struct sk_buff *skb); 148 extern void br_flood_deliver(struct net_bridge *br, 149 struct sk_buff *skb, 150 int clone); 151 extern void br_flood_forward(struct net_bridge *br, 152 struct sk_buff *skb, 153 int clone); 154 155 /* br_if.c */ 156 extern int br_add_bridge(char *name); 157 extern int br_del_bridge(char *name); 158 extern int br_add_if(struct net_bridge *br, 159 struct net_device *dev); 160 extern int br_del_if(struct net_bridge *br, 161 struct net_device *dev); 162 extern int br_get_bridge_ifindices(int *indices, 163 int num); 164 extern void br_get_port_ifindices(struct net_bridge *br, 165 int *ifindices); 166 167 /* br_input.c */ 168 extern void br_handle_frame(struct sk_buff *skb); 169 170 /* br_ioctl.c */ 171 extern int br_ioctl(struct net_bridge *br, 172 unsigned int cmd, 173 unsigned long arg0, 174 unsigned long arg1, 175 unsigned long arg2); 176 extern int br_ioctl_deviceless_stub(unsigned long arg); 177 178 /* br_stp.c */ 179 extern int br_is_root_bridge(struct net_bridge *br); 180 extern struct net_bridge_port *br_get_port(struct net_bridge *br, 181 int port_no); 182 extern void br_init_port(struct net_bridge_port *p); 183 extern port_id br_make_port_id(struct net_bridge_port *p); 184 extern void br_become_designated_port(struct net_bridge_port *p); 185 186 /* br_stp_if.c */ 187 extern void br_stp_enable_bridge(struct net_bridge *br); 188 extern void br_stp_disable_bridge(struct net_bridge *br); 189 extern void br_stp_enable_port(struct net_bridge_port *p); 190 extern void br_stp_disable_port(struct net_bridge_port *p); 191 extern void br_stp_recalculate_bridge_id(struct net_bridge *br); 192 extern void br_stp_set_bridge_priority(struct net_bridge *br, 193 int newprio); 194 extern void br_stp_set_port_priority(struct net_bridge_port *p, 195 int newprio); 196 extern void br_stp_set_path_cost(struct net_bridge_port *p, 197 int path_cost); 198 199 /* br_stp_bpdu.c */ 200 extern int br_stp_handle_bpdu(struct sk_buff *skb); 201 202 #endif 203