xref: /onnv-gate/usr/src/lib/librstp/common/stpm.h (revision 10491:8893b747ecdf)
1*10491SRishi.Srivatsavai@Sun.COM /************************************************************************
2*10491SRishi.Srivatsavai@Sun.COM  * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
3*10491SRishi.Srivatsavai@Sun.COM  * Copyright (C) 2001-2003 Optical Access
4*10491SRishi.Srivatsavai@Sun.COM  * Author: Alex Rozin
5*10491SRishi.Srivatsavai@Sun.COM  *
6*10491SRishi.Srivatsavai@Sun.COM  * This file is part of RSTP library.
7*10491SRishi.Srivatsavai@Sun.COM  *
8*10491SRishi.Srivatsavai@Sun.COM  * RSTP library is free software; you can redistribute it and/or modify it
9*10491SRishi.Srivatsavai@Sun.COM  * under the terms of the GNU Lesser General Public License as published by the
10*10491SRishi.Srivatsavai@Sun.COM  * Free Software Foundation; version 2.1
11*10491SRishi.Srivatsavai@Sun.COM  *
12*10491SRishi.Srivatsavai@Sun.COM  * RSTP library is distributed in the hope that it will be useful, but
13*10491SRishi.Srivatsavai@Sun.COM  * WITHOUT ANY WARRANTY; without even the implied warranty of
14*10491SRishi.Srivatsavai@Sun.COM  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
15*10491SRishi.Srivatsavai@Sun.COM  * General Public License for more details.
16*10491SRishi.Srivatsavai@Sun.COM  *
17*10491SRishi.Srivatsavai@Sun.COM  * You should have received a copy of the GNU Lesser General Public License
18*10491SRishi.Srivatsavai@Sun.COM  * along with RSTP library; see the file COPYING.  If not, write to the Free
19*10491SRishi.Srivatsavai@Sun.COM  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20*10491SRishi.Srivatsavai@Sun.COM  * 02111-1307, USA.
21*10491SRishi.Srivatsavai@Sun.COM  **********************************************************************/
22*10491SRishi.Srivatsavai@Sun.COM 
23*10491SRishi.Srivatsavai@Sun.COM /* STP machine instance : bridge per VLAN: 17.17 */
24*10491SRishi.Srivatsavai@Sun.COM /* The Clause 17.13 points: "NOTE:The operation of the Bridge as a whole can
25*10491SRishi.Srivatsavai@Sun.COM  * be represented by the interaction between Bridge Ports specified,
26*10491SRishi.Srivatsavai@Sun.COM  * and by parameters of the Bridge stored in �Port 0�. This removes the
27*10491SRishi.Srivatsavai@Sun.COM  * need for any �per Bridge� specification elements, and helps ensure
28*10491SRishi.Srivatsavai@Sun.COM  * the minimum dependencies between Bridge Ports. This in turn supports
29*10491SRishi.Srivatsavai@Sun.COM  * the development of implementations that scale well with increasing
30*10491SRishi.Srivatsavai@Sun.COM  * numbers of Bridge Ports. This shift of focus to �per Port operation�
31*10491SRishi.Srivatsavai@Sun.COM  * for the RSTP is supported by underlying technical changes from the
32*10491SRishi.Srivatsavai@Sun.COM  * Spanning Tree Algorithm and Protocol (Clause 8):"
33*10491SRishi.Srivatsavai@Sun.COM  * Newetheless, it seems to me, the behaviour of of the bridge, its variables
34*10491SRishi.Srivatsavai@Sun.COM  * and functions are so distinct from Port, that I decided to design Bridge
35*10491SRishi.Srivatsavai@Sun.COM  * instance. I called this object 'stpm' from STP machine. I'd like to see
36*10491SRishi.Srivatsavai@Sun.COM  * another procedural model, more corresponding to this note on Clause 17.13 */
37*10491SRishi.Srivatsavai@Sun.COM 
38*10491SRishi.Srivatsavai@Sun.COM #ifndef _STP_MACHINE_H__
39*10491SRishi.Srivatsavai@Sun.COM #define _STP_MACHINE_H__
40*10491SRishi.Srivatsavai@Sun.COM 
41*10491SRishi.Srivatsavai@Sun.COM #include "port.h"
42*10491SRishi.Srivatsavai@Sun.COM #include "rolesel.h"
43*10491SRishi.Srivatsavai@Sun.COM 
44*10491SRishi.Srivatsavai@Sun.COM #define TxHoldCount          3 /* 17.16.6, 17.28.2(Table 17-5) */
45*10491SRishi.Srivatsavai@Sun.COM 
46*10491SRishi.Srivatsavai@Sun.COM typedef enum {/* 17.12, 17.16.1 */
47*10491SRishi.Srivatsavai@Sun.COM   FORCE_STP_COMPAT = 0,
48*10491SRishi.Srivatsavai@Sun.COM   NORMAL_RSTP = 2
49*10491SRishi.Srivatsavai@Sun.COM } PROTOCOL_VERSION_T;
50*10491SRishi.Srivatsavai@Sun.COM 
51*10491SRishi.Srivatsavai@Sun.COM struct stpm_t {
52*10491SRishi.Srivatsavai@Sun.COM   struct stpm_t*        next;
53*10491SRishi.Srivatsavai@Sun.COM 
54*10491SRishi.Srivatsavai@Sun.COM   struct port_t*        ports;
55*10491SRishi.Srivatsavai@Sun.COM 
56*10491SRishi.Srivatsavai@Sun.COM   /* The only "per bridge" state machine */
57*10491SRishi.Srivatsavai@Sun.COM   STATE_MACH_T*         rolesel;   /* the Port Role Selection State machione: 17.22 */
58*10491SRishi.Srivatsavai@Sun.COM   STATE_MACH_T*         machines;
59*10491SRishi.Srivatsavai@Sun.COM 
60*10491SRishi.Srivatsavai@Sun.COM   /* variables */
61*10491SRishi.Srivatsavai@Sun.COM   PROTOCOL_VERSION_T    ForceVersion;   /* 17.12, 17.16.1 */
62*10491SRishi.Srivatsavai@Sun.COM   BRIDGE_ID             BrId;           /* 17.17.2 */
63*10491SRishi.Srivatsavai@Sun.COM   TIMEVALUES_T          BrTimes;        /* 17.17.4 */
64*10491SRishi.Srivatsavai@Sun.COM   PORT_ID               rootPortId;     /* 17.17.5 */
65*10491SRishi.Srivatsavai@Sun.COM   PRIO_VECTOR_T         rootPrio;       /* 17.17.6 */
66*10491SRishi.Srivatsavai@Sun.COM   TIMEVALUES_T          rootTimes;      /* 17.17.7 */
67*10491SRishi.Srivatsavai@Sun.COM 
68*10491SRishi.Srivatsavai@Sun.COM   int                   vlan_id;        /* let's say: tag */
69*10491SRishi.Srivatsavai@Sun.COM   char*                 name;           /* name of the VLAN, maily for debugging */
70*10491SRishi.Srivatsavai@Sun.COM   UID_STP_MODE_T        admin_state;    /* STP_DISABLED or STP_ENABLED; type see in UiD */
71*10491SRishi.Srivatsavai@Sun.COM 
72*10491SRishi.Srivatsavai@Sun.COM   unsigned long         timeSince_Topo_Change; /* 14.8.1.1.3.b */
73*10491SRishi.Srivatsavai@Sun.COM   unsigned long         Topo_Change_Count;     /* 14.8.1.1.3.c */
74*10491SRishi.Srivatsavai@Sun.COM   unsigned char         Topo_Change;           /* 14.8.1.1.3.d */
75*10491SRishi.Srivatsavai@Sun.COM };
76*10491SRishi.Srivatsavai@Sun.COM 
77*10491SRishi.Srivatsavai@Sun.COM #ifndef __STPM_T__
78*10491SRishi.Srivatsavai@Sun.COM #define __STPM_T__
79*10491SRishi.Srivatsavai@Sun.COM typedef struct stpm_t STPM_T;
80*10491SRishi.Srivatsavai@Sun.COM #endif
81*10491SRishi.Srivatsavai@Sun.COM 
82*10491SRishi.Srivatsavai@Sun.COM /* Functions prototypes */
83*10491SRishi.Srivatsavai@Sun.COM 
84*10491SRishi.Srivatsavai@Sun.COM void
85*10491SRishi.Srivatsavai@Sun.COM STP_stpm_one_second (STPM_T* param);
86*10491SRishi.Srivatsavai@Sun.COM 
87*10491SRishi.Srivatsavai@Sun.COM STPM_T*
88*10491SRishi.Srivatsavai@Sun.COM STP_stpm_create (int vlan_id, char* name);
89*10491SRishi.Srivatsavai@Sun.COM 
90*10491SRishi.Srivatsavai@Sun.COM int
91*10491SRishi.Srivatsavai@Sun.COM STP_stpm_enable (STPM_T* this, UID_STP_MODE_T admin_state);
92*10491SRishi.Srivatsavai@Sun.COM 
93*10491SRishi.Srivatsavai@Sun.COM void
94*10491SRishi.Srivatsavai@Sun.COM STP_stpm_delete (STPM_T* this);
95*10491SRishi.Srivatsavai@Sun.COM 
96*10491SRishi.Srivatsavai@Sun.COM int
97*10491SRishi.Srivatsavai@Sun.COM STP_stpm_start (STPM_T* this);
98*10491SRishi.Srivatsavai@Sun.COM 
99*10491SRishi.Srivatsavai@Sun.COM void
100*10491SRishi.Srivatsavai@Sun.COM STP_stpm_stop (STPM_T* this);
101*10491SRishi.Srivatsavai@Sun.COM 
102*10491SRishi.Srivatsavai@Sun.COM int
103*10491SRishi.Srivatsavai@Sun.COM STP_stpm_update (STPM_T* this);
104*10491SRishi.Srivatsavai@Sun.COM 
105*10491SRishi.Srivatsavai@Sun.COM BRIDGE_ID *
106*10491SRishi.Srivatsavai@Sun.COM STP_compute_bridge_id (STPM_T* this);
107*10491SRishi.Srivatsavai@Sun.COM 
108*10491SRishi.Srivatsavai@Sun.COM STPM_T *
109*10491SRishi.Srivatsavai@Sun.COM STP_stpm_get_the_list (void);
110*10491SRishi.Srivatsavai@Sun.COM 
111*10491SRishi.Srivatsavai@Sun.COM void
112*10491SRishi.Srivatsavai@Sun.COM STP_stpm_update_after_bridge_management (STPM_T* this);
113*10491SRishi.Srivatsavai@Sun.COM 
114*10491SRishi.Srivatsavai@Sun.COM int
115*10491SRishi.Srivatsavai@Sun.COM STP_stpm_check_bridge_priority (STPM_T* this);
116*10491SRishi.Srivatsavai@Sun.COM 
117*10491SRishi.Srivatsavai@Sun.COM const char*
118*10491SRishi.Srivatsavai@Sun.COM STP_stpm_get_port_name_by_id (STPM_T* this, PORT_ID port_id);
119*10491SRishi.Srivatsavai@Sun.COM 
120*10491SRishi.Srivatsavai@Sun.COM STPM_T* stpapi_stpm_find (int vlan_id);
121*10491SRishi.Srivatsavai@Sun.COM 
122*10491SRishi.Srivatsavai@Sun.COM int stp_in_stpm_enable (int vlan_id, char* name,
123*10491SRishi.Srivatsavai@Sun.COM                     UID_STP_MODE_T admin_state);
124*10491SRishi.Srivatsavai@Sun.COM void* stp_in_stpm_create (int vlan_id, char *name, int *err_code);
125*10491SRishi.Srivatsavai@Sun.COM 
126*10491SRishi.Srivatsavai@Sun.COM #endif /* _STP_MACHINE_H__ */
127