]> git.ipfire.org Git - people/ms/rstp.git/blob - rstplib/stpm.h
Use new RSTP library.
[people/ms/rstp.git] / rstplib / stpm.h
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 /* STP machine instance : bridge per VLAN: 17.17 */
24 /* The Clause 17.13 points: "NOTE:The operation of the Bridge as a whole can
25 * be represented by the interaction between Bridge Ports specified,
26 * and by parameters of the Bridge stored in \91Port 0\92. This removes the
27 * need for any \91per Bridge\92 specification elements, and helps ensure
28 * the minimum dependencies between Bridge Ports. This in turn supports
29 * the development of implementations that scale well with increasing
30 * numbers of Bridge Ports. This shift of focus to \91per Port operation\92
31 * for the RSTP is supported by underlying technical changes from the
32 * Spanning Tree Algorithm and Protocol (Clause 8):"
33 * Newetheless, it seems to me, the behaviour of of the bridge, its variables
34 * and functions are so distinct from Port, that I decided to design Bridge
35 * instance. I called this object 'stpm' from STP machine. I'd like to see
36 * another procedural model, more corresponding to this note on Clause 17.13 */
37
38 #ifndef _STP_MACHINE_H__
39 #define _STP_MACHINE_H__
40
41 #include "port.h"
42 #include "rolesel.h"
43
44 #define TxHoldCount 3 /* 17.16.6, 17.28.2(Table 17-5) */
45
46 typedef enum {/* 17.12, 17.16.1 */
47 FORCE_STP_COMPAT = 0,
48 NORMAL_RSTP = 2
49 } PROTOCOL_VERSION_T;
50
51 typedef struct stpm_t {
52 struct stpm_t* next;
53
54 struct port_t* ports;
55
56 /* The only "per bridge" state machine */
57 STATE_MACH_T* rolesel; /* the Port Role Selection State machione: 17.22 */
58 STATE_MACH_T* machines;
59
60 /* variables */
61 PROTOCOL_VERSION_T ForceVersion; /* 17.12, 17.16.1 */
62 BRIDGE_ID BrId; /* 17.17.2 */
63 TIMEVALUES_T BrTimes; /* 17.17.4 */
64 PORT_ID rootPortId; /* 17.17.5 */
65 PRIO_VECTOR_T rootPrio; /* 17.17.6 */
66 TIMEVALUES_T rootTimes; /* 17.17.7 */
67
68 int vlan_id; /* let's say: tag */
69 char* name; /* name of the VLAN, maily for debugging */
70 UID_STP_MODE_T admin_state; /* STP_DISABLED or STP_ENABLED; type see in UiD */
71
72 unsigned long timeSince_Topo_Change; /* 14.8.1.1.3.b */
73 unsigned long Topo_Change_Count; /* 14.8.1.1.3.c */
74 unsigned char Topo_Change; /* 14.8.1.1.3.d */
75 } STPM_T;
76
77 /* Functions prototypes */
78
79 void
80 STP_stpm_one_second (STPM_T* param);
81
82 STPM_T*
83 STP_stpm_create (int vlan_id, char* name);
84
85 int
86 STP_stpm_enable (STPM_T* this, UID_STP_MODE_T admin_state);
87
88 void
89 STP_stpm_delete (STPM_T* this);
90
91 int
92 STP_stpm_start (STPM_T* this);
93
94 void
95 STP_stpm_stop (STPM_T* this);
96
97 int
98 STP_stpm_update (STPM_T* this);
99
100 BRIDGE_ID *
101 STP_compute_bridge_id (STPM_T* this);
102
103 STPM_T *
104 STP_stpm_get_the_list (void);
105
106 extern STPM_T *bridges;
107
108 void
109 STP_stpm_update_after_bridge_management (STPM_T* this);
110
111 int
112 STP_stpm_check_bridge_priority (STPM_T* this);
113
114 const char*
115 STP_stpm_get_port_name_by_id (STPM_T* this, PORT_ID port_id);
116
117 #endif /* _STP_MACHINE_H__ */