xref: /illumos-gate/usr/src/lib/librstp/common/stp_vectors.h (revision e00bdde3c6d406f40f53f3025defadc22f7ec31a)
1 /************************************************************************
2  * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
3  * Copyright (C) 2001-2003 Optical Access
4  * Author: Alex Rozin
5  *
6  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
7  * Use is subject to license terms.
8  *
9  * This file is part of RSTP library.
10  *
11  * RSTP library is free software; you can redistribute it and/or modify it
12  * under the terms of the GNU Lesser General Public License as published by the
13  * Free Software Foundation; version 2.1
14  *
15  * RSTP library is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
18  * General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with RSTP library; see the file COPYING.  If not, write to the Free
22  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23  * 02111-1307, USA.
24  **********************************************************************/
25 
26 #ifndef __STP_VECTORS_H__
27 #define	__STP_VECTORS_H__
28 
29 /* This file defines callback vectors to be supplied by library user */
30 
31 /* In the best case: clean all Learning entries with
32  the vlan_id and the port (if 'exclude'=0) or for all ports,
33  exclude the port (if ''exclude'=1). If 'port'=0, delete all
34  entries with the vlan_id, don't care to 'exclude'  */
35 typedef enum {
36   LT_FLASH_ALL_PORTS_EXCLUDE_THIS,
37   LT_FLASH_ONLY_THE_PORT
38 } LT_FLASH_TYPE_T;
39 
40 struct stp_vectors {
41 	int (*flush_lt)(IN int port_index, IN int vlan_id,
42 	    IN LT_FLASH_TYPE_T type, IN char* reason);
43 
44 	/* for bridge id calculation */
45 	void (*get_port_mac) (IN int port_index, OUT unsigned char* mac);
46 
47 	unsigned long (*get_port_oper_speed) (IN unsigned int portNo);
48 
49 	/* 1- Up, 0- Down */
50 	int (*get_port_link_status) (IN int port_index);
51 
52 	/* 1- Full, 0- Half */
53 	int (*get_duplex) (IN int port_index);
54 
55 #ifdef STRONGLY_SPEC_802_1W
56 	int (*set_learning) (IN int port_index, IN int vlan_id, IN int enable);
57 	int (*set_forwarding) (IN int port_index, IN int vlan_id,
58 	    IN int enable);
59 #else
60 /*
61  * In many kinds of hardware the state of ports may
62  * be changed with another method
63  */
64 	int (*set_port_state) (IN int port_index, IN int vlan_id,
65 	    IN RSTP_PORT_STATE state);
66 #endif
67 
68 	int (*set_hardware_mode) (int vlan_id, UID_STP_MODE_T mode);
69 	int (*tx_bpdu) (IN int port_index, IN int vlan_id,
70                  IN unsigned char* bpdu,
71                  IN size_t bpdu_len);
72 	const char *(*get_port_name) (IN int port_index);
73 	int (*get_init_stpm_cfg) (IN int vlan_id,
74 	    INOUT UID_STP_CFG_T* cfg);
75 	int (*get_init_port_cfg) (IN int vlan_id,
76 		IN int port_index,
77 		INOUT UID_STP_PORT_CFG_T* cfg);
78 	void (*trace)(const char *fmt, ...);
79 };
80 
81 #ifndef __STP_VECTORS_T__
82 #define __STP_VECTORS_T__
83 typedef struct stp_vectors STP_VECTORS_T;
84 #endif
85 
86 #ifdef __STP_INTERNAL__
87 extern STP_VECTORS_T *stp_vectors;
88 #endif
89 
90 #endif /* __STP_VECTORS_H__ */
91