1 /************************************************************************
2 * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
3 * Copyright (C) 2001-2003 Optical Access
6 * This file is part of RSTP library.
8 * RSTP library is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by the
10 * Free Software Foundation; version 2.1
12 * RSTP library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
15 * General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with RSTP library; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 **********************************************************************/
23 /* This file contains prototypes for API from an operation
29 /************************
30 * Common base constants
31 ************************/
34 # define IN /* consider as comments near 'input' parameters */
35 # define OUT /* consider as comments near 'output' parameters */
36 # define INOUT /* consider as comments near 'input/output' parameters */
50 /********************************************
51 * constants: default values and linitations
52 *********************************************/
54 /* bridge configuration */
56 #define DEF_BR_PRIO 32768
58 #define MAX_BR_PRIO 61440
59 #define MASK_BR_PRIO 0xf000
61 #define DEF_BR_HELLOT 2
62 #define MIN_BR_HELLOT 1
63 #define MAX_BR_HELLOT 10
65 #define DEF_BR_MAXAGE 20
66 #define MIN_BR_MAXAGE 6
67 #define MAX_BR_MAXAGE 40
69 #define DEF_BR_FWDELAY 15
70 #define MIN_BR_FWDELAY 4
71 #define MAX_BR_FWDELAY 30
73 #define DEF_FORCE_VERS 2 /* NORMAL_RSTP */
75 /* port configuration */
77 #define DEF_PORT_PRIO 128
78 #define MIN_PORT_PRIO 0
79 #define MAX_PORT_PRIO 240 /* in steps of 16 */
80 #define MASK_PORT_PRIO 0xf0
82 #define DEF_ADMIN_NON_STP False
83 #define DEF_ADMIN_EDGE True
84 #define DEF_LINK_DELAY 3 /* see edge.c */
85 #define DEF_P2P P2P_AUTO
87 #define MAX_PORT_PCOST 200000000
89 /* Section 1: Create/Delete/Start/Stop the RSTP instance */
91 void /* init the engine */
92 STP_IN_init (int max_port_index
);
96 STP_IN_stpm_create (int vlan_id
, char* name
, BITMAP_T
* port_bmp
);
100 STP_IN_stpm_delete (int vlan_id
);
103 STP_IN_stop_all (void);
106 STP_IN_delete_all (void);
108 /* Port create/delete */
110 int STP_IN_port_create(int vlan_id
, int port_index
);
112 int STP_IN_port_delete(int vlan_id
, int port_index
);
114 /* Section 2. "Get" management */
117 STP_IN_get_is_stpm_enabled (int vlan_id
);
120 STP_IN_stpm_get_vlan_id_by_name (char* name
, int* vlan_id
);
123 STP_IN_stpm_get_name_by_vlan_id (int vlan_id
, char* name
, size_t buffsize
);
126 STP_IN_get_error_explanation (int rstp_err_no
);
130 STP_IN_stpm_get_cfg (int vlan_id
, UID_STP_CFG_T
* uid_cfg
);
133 STP_IN_stpm_get_state (int vlan_id
, UID_STP_STATE_T
* entry
);
136 STP_IN_port_get_cfg (int vlan_id
, int port_index
, UID_STP_PORT_CFG_T
* uid_cfg
);
139 STP_IN_port_get_state (int vlan_id
, UID_STP_PORT_STATE_T
* entry
);
142 /* Section 3. "Set" management */
145 STP_IN_stpm_set_cfg (int vlan_id
,
147 UID_STP_CFG_T
* uid_cfg
);
151 STP_IN_set_port_cfg (int vlan_id
,
152 UID_STP_PORT_CFG_T
* uid_cfg
);
155 STP_IN_set_port_cfg (int vlan_id
, int port_index
,
156 UID_STP_PORT_CFG_T
* uid_cfg
);
160 int STP_IN_dbg_set_port_trace (char* mach_name
, int enadis
,
161 int vlan_id
, BITMAP_T
* ports
,
165 /* Section 4. RSTP functionality events */
168 STP_IN_one_second (void);
170 int /* for Link UP/DOWN */
171 STP_IN_enable_port (int port_index
, Bool enable
);
173 int /* call it, when port speed has been changed, speed in Kb/s */
174 STP_IN_changed_port_speed (int port_index
, long speed
);
176 int /* call it, when current port duplex mode has been changed */
177 STP_IN_changed_port_duplex (int port_index
);
181 STP_IN_check_bpdu_header (BPDU_T
* bpdu
, size_t len
);
184 STP_IN_rx_bpdu (int vlan_id
, int port_index
, BPDU_T
* bpdu
, size_t len
);
187 /*--- For multiple STP instances - non multithread use ---*/
190 /* Create struct to hold STP instance state and initialize it.
191 A copy of all global state in the library. */
192 struct stp_instance
*STP_IN_instance_create(void);
193 /* Set context from this STP instance */
194 void STP_IN_instance_begin(struct stp_instance
*p
);
195 /* Save context back to this STP instance */
196 void STP_IN_instance_end(struct stp_instance
*p
);
197 /* Delete this STP instance */
198 void STP_IN_instance_delete(struct stp_instance
*p
);
200 #ifdef _STP_MACHINE_H__
201 /* Inner usage definitions & functions */
206 # define RSTP_INIT_CRITICAL_PATH_PROTECTIO
207 # define RSTP_CRITICAL_PATH_START
208 # define RSTP_CRITICAL_PATH_END
210 # define RSTP_INIT_CRITICAL_PATH_PROTECTIO STP_OUT_psos_init_semaphore ()
211 # define RSTP_CRITICAL_PATH_START STP_OUT_psos_close_semaphore ()
212 # define RSTP_CRITICAL_PATH_END STP_OUT_psos_open_semaphore ()
213 extern void STP_OUT_psos_init_semaphore (void);
214 extern void STP_OUT_psos_close_semaphore (void);
215 extern void STP_OUT_psos_open_semaphore (void);
218 STPM_T
* stpapi_stpm_find (int vlan_id
);
220 int stp_in_stpm_enable (int vlan_id
, char* name
,
222 UID_STP_MODE_T admin_state
);
223 void* stp_in_stpm_create (int vlan_id
, char* name
, BITMAP_T
* port_bmp
,
226 #endif /* _STP_MACHINE_H__ */
229 #endif /* _STP_API_H__ */