]> git.ipfire.org Git - people/ms/rstp.git/blame - rstplib/stp_in.h
Initial commit
[people/ms/rstp.git] / rstplib / stp_in.h
CommitLineData
ad02a0eb
SH
1/************************************************************************
2 * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
3 * Copyright (C) 2001-2003 Optical Access
4 * Author: Alex Rozin
5 *
6 * This file is part of RSTP library.
7 *
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
11 *
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.
16 *
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
20 * 02111-1307, USA.
21 **********************************************************************/
22
23 /* This file contains prototypes for API from an operation
24 system to the RSTP */
25
26#ifndef _STP_API_H__
27#define _STP_API_H__
28
29/************************
30 * Common base constants
31 ************************/
32
33#ifndef INOUT
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 */
37#endif
38
39#ifndef Zero
40# define Zero 0
41# define One 1
42#endif
43
44#ifndef Bool
45# define Bool int
46# define False 0
47# define True 1
48#endif
49
50/********************************************
51 * constants: default values and linitations
52 *********************************************/
53
54/* bridge configuration */
55
56#define DEF_BR_PRIO 32768
57#define MIN_BR_PRIO 0
58#define MAX_BR_PRIO 61440
59#define MASK_BR_PRIO 0xf000
60
61#define DEF_BR_HELLOT 2
62#define MIN_BR_HELLOT 1
63#define MAX_BR_HELLOT 10
64
65#define DEF_BR_MAXAGE 20
66#define MIN_BR_MAXAGE 6
67#define MAX_BR_MAXAGE 40
68
69#define DEF_BR_FWDELAY 15
70#define MIN_BR_FWDELAY 4
71#define MAX_BR_FWDELAY 30
72
73#define DEF_FORCE_VERS 2 /* NORMAL_RSTP */
74
75/* port configuration */
76
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
81
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
86
87#define MAX_PORT_PCOST 200000000
88
89/* Section 1: Create/Delete/Start/Stop the RSTP instance */
90
91void /* init the engine */
92STP_IN_init (int max_port_index);
93
94#ifdef __BITMAP_H
95int
96STP_IN_stpm_create (int vlan_id, char* name, BITMAP_T* port_bmp);
97#endif
98
99int
100STP_IN_stpm_delete (int vlan_id);
101
102int
103STP_IN_stop_all (void);
104
105int
106STP_IN_delete_all (void);
107
108/* Port create/delete */
109
110int STP_IN_port_create(int vlan_id, int port_index);
111
112int STP_IN_port_delete(int vlan_id, int port_index);
113
114/* Section 2. "Get" management */
115
116Bool
117STP_IN_get_is_stpm_enabled (int vlan_id);
118
119int
120STP_IN_stpm_get_vlan_id_by_name (char* name, int* vlan_id);
121
122int
123STP_IN_stpm_get_name_by_vlan_id (int vlan_id, char* name, size_t buffsize);
124
125const char*
126STP_IN_get_error_explanation (int rstp_err_no);
127
128#ifdef _UID_STP_H__
129int
130STP_IN_stpm_get_cfg (int vlan_id, UID_STP_CFG_T* uid_cfg);
131
132int
133STP_IN_stpm_get_state (int vlan_id, UID_STP_STATE_T* entry);
134
135int
136STP_IN_port_get_cfg (int vlan_id, int port_index, UID_STP_PORT_CFG_T* uid_cfg);
137
138int
139STP_IN_port_get_state (int vlan_id, UID_STP_PORT_STATE_T* entry);
140#endif
141
142/* Section 3. "Set" management */
143
144int
145STP_IN_stpm_set_cfg (int vlan_id,
146 BITMAP_T* port_bmp,
147 UID_STP_CFG_T* uid_cfg);
148
149#ifdef ORIG
150int
151STP_IN_set_port_cfg (int vlan_id,
152 UID_STP_PORT_CFG_T* uid_cfg);
153#else
154int
155STP_IN_set_port_cfg (int vlan_id, int port_index,
156 UID_STP_PORT_CFG_T* uid_cfg);
157#endif
158
159#ifdef STP_DBG
160int STP_IN_dbg_set_port_trace (char* mach_name, int enadis,
161 int vlan_id, BITMAP_T* ports,
162 int is_print_err);
163#endif
164
165/* Section 4. RSTP functionality events */
166
167int
168STP_IN_one_second (void);
169
170int /* for Link UP/DOWN */
171STP_IN_enable_port (int port_index, Bool enable);
172
173int /* call it, when port speed has been changed, speed in Kb/s */
174STP_IN_changed_port_speed (int port_index, long speed);
175
176int /* call it, when current port duplex mode has been changed */
177STP_IN_changed_port_duplex (int port_index);
178
179#ifdef _STP_BPDU_H__
180int
181STP_IN_check_bpdu_header (BPDU_T* bpdu, size_t len);
182
183int
184STP_IN_rx_bpdu (int vlan_id, int port_index, BPDU_T* bpdu, size_t len);
185#endif
186
187/*--- For multiple STP instances - non multithread use ---*/
188
189struct stp_instance;
190/* Create struct to hold STP instance state and initialize it.
191 A copy of all global state in the library. */
192struct stp_instance *STP_IN_instance_create(void);
193/* Set context from this STP instance */
194void STP_IN_instance_begin(struct stp_instance *p);
195/* Save context back to this STP instance */
196void STP_IN_instance_end(struct stp_instance *p);
197/* Delete this STP instance */
198void STP_IN_instance_delete(struct stp_instance *p);
199
200#ifdef _STP_MACHINE_H__
201/* Inner usage definitions & functions */
202
203extern int max_port;
204
205#ifdef __LINUX__
206# define RSTP_INIT_CRITICAL_PATH_PROTECTIO
207# define RSTP_CRITICAL_PATH_START
208# define RSTP_CRITICAL_PATH_END
209#else
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);
216#endif
217
218STPM_T* stpapi_stpm_find (int vlan_id);
219
220int stp_in_stpm_enable (int vlan_id, char* name,
221 BITMAP_T* port_bmp,
222 UID_STP_MODE_T admin_state);
223void* stp_in_stpm_create (int vlan_id, char* name, BITMAP_T* port_bmp,
224 int* err_code);
225
226#endif /* _STP_MACHINE_H__ */
227
228
229#endif /* _STP_API_H__ */