1/*
2 * Copyright (C) 2000 Lennert Buytenhek
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19#ifndef _LIBBRIDGE_H
20#define _LIBBRIDGE_H
21
22#include <net/if.h>
23#include <linux/if_bridge.h>
24
25struct bridge_id
26{
27	unsigned char prio[2];
28	unsigned char addr[6];
29};
30
31struct bridge_info
32{
33	struct bridge_id designated_root;
34	struct bridge_id bridge_id;
35	unsigned root_path_cost;
36	struct timeval max_age;
37	struct timeval hello_time;
38	struct timeval forward_delay;
39	struct timeval bridge_max_age;
40	struct timeval bridge_hello_time;
41	struct timeval bridge_forward_delay;
42	u_int16_t root_port;
43	unsigned char stp_enabled;
44	unsigned char topology_change;
45	unsigned char topology_change_detected;
46	struct timeval ageing_time;
47	struct timeval hello_timer_value;
48	struct timeval tcn_timer_value;
49	struct timeval topology_change_timer_value;
50	struct timeval gc_timer_value;
51};
52
53struct fdb_entry
54{
55	u_int8_t mac_addr[6];
56	u_int16_t port_no;
57	unsigned char is_local;
58	struct timeval ageing_timer_value;
59};
60
61struct port_info
62{
63	unsigned port_no;
64	struct bridge_id designated_root;
65	struct bridge_id designated_bridge;
66	u_int16_t port_id;
67	u_int16_t designated_port;
68	u_int8_t priority;
69	unsigned char top_change_ack;
70	unsigned char config_pending;
71	unsigned char state;
72	unsigned path_cost;
73	unsigned designated_cost;
74	struct timeval message_age_timer_value;
75	struct timeval forward_delay_timer_value;
76	struct timeval hold_timer_value;
77};
78
79extern int br_init(void);
80extern int br_refresh(void);
81extern void br_shutdown(void);
82
83extern int br_foreach_bridge(int (*iterator)(const char *brname, void *),
84			     void *arg);
85extern int br_foreach_port(const char *brname,
86			   int (*iterator)(const char *brname, const char *port,
87					   void *arg ),
88			   void *arg);
89extern const char *br_get_state_name(int state);
90
91extern int br_get_bridge_info(const char *br, struct bridge_info *info);
92extern int br_get_port_info(const char *brname, const char *port,
93			    struct port_info *info);
94extern int br_add_bridge(const char *brname);
95extern int br_del_bridge(const char *brname);
96extern int br_add_interface(const char *br, const char *dev);
97extern int br_del_interface(const char *br, const char *dev);
98extern int br_set_bridge_forward_delay(const char *br, struct timeval *tv);
99extern int br_set_bridge_hello_time(const char *br, struct timeval *tv);
100extern int br_set_bridge_max_age(const char *br, struct timeval *tv);
101extern int br_set_ageing_time(const char *br, struct timeval *tv);
102extern int br_set_stp_state(const char *br, int stp_state);
103extern int br_set_bridge_priority(const char *br, int bridge_priority);
104extern int br_set_port_priority(const char *br, const char *p,
105				int port_priority);
106extern int br_set_path_cost(const char *br, const char *p,
107			    int path_cost);
108extern int br_read_fdb(const char *br, struct fdb_entry *fdbs,
109		       unsigned long skip, int num);
110#endif
111