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 #include <sys/types.h>
33 /************************
34 * Common base constants
35 ************************/
38 # define IN /* consider as comments near 'input' parameters */
39 # define OUT /* consider as comments near 'output' parameters */
40 # define INOUT /* consider as comments near 'input/output' parameters */
54 /********************************************
55 * constants: default values and linitations
56 *********************************************/
58 /* bridge configuration */
60 #define DEF_BR_PRIO 32768
62 #define MAX_BR_PRIO 61440
64 #define DEF_BR_HELLOT 2
65 #define MIN_BR_HELLOT 1
66 #define MAX_BR_HELLOT 10
68 #define DEF_BR_MAXAGE 20
69 #define MIN_BR_MAXAGE 6
70 #define MAX_BR_MAXAGE 40
72 #define DEF_BR_FWDELAY 15
73 #define MIN_BR_FWDELAY 4
74 #define MAX_BR_FWDELAY 30
76 #define IEEE_TIMER_SCALE 256
78 /* Note that this works with unscaled values */
79 #define CHECK_BRIDGE_CONFIG(cfg) \
80 (2 * (cfg.forward_delay - 1) >= cfg.max_age && \
81 cfg.max_age >= 2 * (cfg.hello_time + 1))
84 * These macros provide limits and tests for displaying comprehensible errors.
86 #define NO_MAXAGE(cfg) ((cfg.forward_delay - 1) < (cfg.hello_time + 1))
87 #define MIN_FWDELAY_NOM(cfg) \
88 (cfg.hello_time < MIN_BR_FWDELAY - 2 ? MIN_BR_FWDELAY : \
90 #define MAX_HELLOTIME_NOM(cfg) \
91 (cfg.forward_delay > MAX_BR_HELLOT + 2 ? MAX_BR_HELLOT : \
92 cfg.forward_delay - 2)
94 #define SMALL_MAXAGE(cfg) (cfg.max_age < 2 * (cfg.hello_time + 1))
95 #define MIN_MAXAGE(cfg) \
96 (cfg.hello_time < (MIN_BR_MAXAGE / 2 - 1) ? MIN_BR_MAXAGE : \
97 (2 * (cfg.hello_time + 1)))
98 #define MAX_HELLOTIME(cfg) \
99 (cfg.max_age > 2 * (MAX_BR_HELLOT + 1) ? MAX_BR_HELLOT : \
100 (cfg.max_age / 2 - 1))
102 #define MIN_FWDELAY(cfg) (cfg.max_age / 2 + 1)
103 #define MAX_MAXAGE(cfg) \
104 (cfg.forward_delay > (MAX_BR_MAXAGE / 2 + 1) ? MAX_BR_MAXAGE : \
105 (2 * (cfg.forward_delay - 1)))
107 #define CAPPED_MAXAGE(cfg) (cfg.forward_delay < (MAX_BR_MAXAGE / 2 + 1))
108 #define FLOORED_MAXAGE(cfg) (cfg.hello_time > (MIN_BR_MAXAGE / 2 - 1))
110 #define DEF_FORCE_VERS 2 /* NORMAL_RSTP */
112 /* port configuration */
114 #define DEF_PORT_PRIO 128
115 #define MIN_PORT_PRIO 0
116 #define MAX_PORT_PRIO 240 /* in steps of 16 */
118 #define DEF_ADMIN_NON_STP False
119 #define DEF_ADMIN_EDGE True
120 #define DEF_LINK_DELAY 3 /* see edge.c */
121 #define DEF_P2P P2P_AUTO
124 #include <stp_bpdu.h>
129 typedef struct stpm_t STPM_T
;
131 #ifndef __STP_VECTORS_T__
132 #define __STP_VECTORS_T__
134 typedef struct stp_vectors STP_VECTORS_T
;
137 /* Section 1: Create/Delete/Start/Stop the RSTP instance */
139 void /* init the engine */
140 STP_IN_init (STP_VECTORS_T
*vectors
);
143 STP_IN_stpm_create (int vlan_id
, char* name
);
146 STP_IN_stpm_delete (int vlan_id
);
149 STP_IN_port_add (int vlan_id
, int port_index
);
152 STP_IN_port_remove (int vlan_id
, int port_index
);
155 STP_IN_stop_all (void);
158 STP_IN_delete_all (void);
160 /* Section 2. "Get" management */
163 STP_IN_get_is_stpm_enabled (int vlan_id
);
166 STP_IN_stpm_get_vlan_id_by_name (char* name
, int* vlan_id
);
169 STP_IN_stpm_get_name_by_vlan_id (int vlan_id
, char* name
, size_t buffsize
);
172 STP_IN_get_error_explanation (int rstp_err_no
);
175 STP_IN_stpm_get_cfg (int vlan_id
, UID_STP_CFG_T
* uid_cfg
);
178 STP_IN_stpm_get_state (int vlan_id
, UID_STP_STATE_T
* entry
);
181 STP_IN_port_get_cfg (int vlan_id
, int port_index
, UID_STP_PORT_CFG_T
* uid_cfg
);
184 STP_IN_port_get_state (int vlan_id
, UID_STP_PORT_STATE_T
* entry
);
187 STP_IN_state2str(RSTP_PORT_STATE
);
189 /* Section 3. "Set" management */
192 STP_IN_stpm_set_cfg (int vlan_id
,
193 UID_STP_CFG_T
* uid_cfg
);
196 STP_IN_port_set_cfg (int vlan_id
, int port_index
,
197 UID_STP_PORT_CFG_T
* uid_cfg
);
200 int STP_IN_dbg_set_port_trace (char *mach_name
, int enadis
,
201 int vlan_id
, int port_index
);
204 /* Section 4. RSTP functionality events */
207 STP_IN_one_second (void);
209 int /* for Link UP/DOWN */
210 STP_IN_enable_port (int port_index
, Bool enable
);
212 int /* call it, when port speed has been changed, speed in Kb/s */
213 STP_IN_changed_port_speed (int port_index
, long speed
);
215 int /* call it, when current port duplex mode has been changed */
216 STP_IN_changed_port_duplex (int port_index
);
219 STP_IN_check_bpdu_header (BPDU_T
* bpdu
, size_t len
);
222 STP_IN_rx_bpdu (int vlan_id
, int port_index
, BPDU_T
* bpdu
, size_t len
);
225 STP_IN_get_bridge_id(int vlan_id
, unsigned short *priority
, unsigned char *mac
);
227 #endif /* _STP_API_H__ */