xref: /titanic_50/usr/src/lib/librstp/common/uid_stp.h (revision cc31cba96d9862a1075a8ec47d6149e04c7ad62d)
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 /* External management communication API definitions */
24 
25 #ifndef _UID_STP_H__
26 #define _UID_STP_H__
27 
28 #define STP_DBG 1
29 
30 #define NAME_LEN    20
31 
32 typedef enum {
33   STP_DISABLED,
34   STP_ENABLED
35 } UID_STP_MODE_T;
36 
37 typedef struct {
38   unsigned short  prio;
39   unsigned char   addr[6];
40 } UID_BRIDGE_ID_T;
41 
42 typedef struct {
43   char      vlan_name[NAME_LEN]; /* name of the VLAN, key of the bridge */
44   char      action; /* 1-create, 0- delete */
45 } UID_STP_BR_CTRL_T;
46 
47 #define BR_CFG_STATE        (1L << 0)
48 #define BR_CFG_PRIO         (1L << 1)
49 #define BR_CFG_AGE          (1L << 2)
50 #define BR_CFG_HELLO        (1L << 3)
51 #define BR_CFG_DELAY        (1L << 4)
52 #define BR_CFG_FORCE_VER    (1L << 5)
53 #define BR_CFG_AGE_MODE     (1L << 6)
54 #define BR_CFG_AGE_TIME     (1L << 7)
55 #define BR_CFG_HOLD_TIME    (1L << 8)
56 #define BR_CFG_ALL BR_CFG_STATE     | \
57                    BR_CFG_PRIO      | \
58                    BR_CFG_AGE       | \
59                    BR_CFG_HELLO     | \
60                    BR_CFG_DELAY     | \
61                    BR_CFG_FORCE_VER | \
62                    BR_CFG_AGE_MODE  | \
63                    BR_CFG_AGE_TIME  | \
64                    BR_CFG_HOLD_TIME
65 
66 typedef struct {
67   /* service data */
68   unsigned long     field_mask; /* which fields to change */
69   UID_STP_MODE_T    stp_enabled;
70   char              vlan_name[NAME_LEN]; /* name of the VLAN, key of the bridge */
71 
72   /* protocol data */
73   int           bridge_priority;
74   int           max_age;
75   int           hello_time;
76   int           forward_delay;
77   int           force_version;
78   int           hold_time;
79 } UID_STP_CFG_T;
80 
81 typedef struct {
82   /* service data */
83   char              vlan_name[NAME_LEN]; /* name of the VLAN, key of the bridge */
84   unsigned long     vlan_id;
85   UID_STP_MODE_T    stp_enabled;
86 
87   /* protocol data */
88   UID_BRIDGE_ID_T   designated_root;
89   unsigned long     root_path_cost;
90 
91   unsigned long     timeSince_Topo_Change; /* 14.8.1.1.3.b: TBD */
92   unsigned long     Topo_Change_Count;     /* 14.8.1.1.3.c: TBD */
93   unsigned char     Topo_Change;           /* 14.8.1.1.3.d: TBD */
94 
95   unsigned short    root_port;
96   int               max_age;
97   int               hello_time;
98   int               forward_delay;
99   UID_BRIDGE_ID_T   bridge_id;
100 } UID_STP_STATE_T;
101 
102 typedef enum {
103   UID_PORT_DISABLED = 0,
104   UID_PORT_DISCARDING,
105   UID_PORT_LEARNING,
106   UID_PORT_FORWARDING,
107   UID_PORT_NON_STP,
108   UID_PORT_BADSDU
109 } RSTP_PORT_STATE;
110 
111 typedef unsigned short  UID_PORT_ID;
112 
113 typedef enum {
114   P2P_FORCE_TRUE,
115   P2P_FORCE_FALSE,
116   P2P_AUTO
117 } ADMIN_P2P_T;
118 
119 #define PT_CFG_STATE    (1L << 0)
120 #define PT_CFG_COST     (1L << 1)
121 #define PT_CFG_PRIO     (1L << 2)
122 #define PT_CFG_P2P      (1L << 3)
123 #define PT_CFG_EDGE     (1L << 4)
124 #define PT_CFG_MCHECK   (1L << 5)
125 #define PT_CFG_NON_STP  (1L << 6)
126 #ifdef STP_DBG
127 #define PT_CFG_DBG_SKIP_RX (1L << 16)
128 #define PT_CFG_DBG_SKIP_TX (1L << 17)
129 #endif
130 
131 #define PT_CFG_ALL PT_CFG_STATE  | \
132                    PT_CFG_COST   | \
133                    PT_CFG_PRIO   | \
134                    PT_CFG_P2P    | \
135                    PT_CFG_EDGE   | \
136                    PT_CFG_MCHECK | \
137                    PT_CFG_NON_STP
138 
139 #define ADMIN_PORT_PATH_COST_AUTO   0
140 
141 typedef struct {
142   /* service data */
143   unsigned long field_mask; /* which fields to change */
144   char          vlan_name[NAME_LEN]; /* name of the VLAN, key of the bridge */
145 
146   /* protocol data */
147   int           port_priority;
148   unsigned long admin_port_path_cost; /* ADMIN_PORT_PATH_COST_AUTO - auto sence */
149   ADMIN_P2P_T   admin_point2point;
150   unsigned char admin_edge;
151   unsigned char admin_non_stp; /* 1- doesn't participate in STP, 1 - regular */
152 #ifdef STP_DBG
153   unsigned int	skip_rx;
154   unsigned int	skip_tx;
155 #endif
156 
157 } UID_STP_PORT_CFG_T;
158 
159 typedef struct {
160   /* service data */
161   char              vlan_name[NAME_LEN]; /* name of the VLAN, key of the bridge */
162   unsigned int      port_no; /* key of the entry */
163 
164   /* protocol data */
165   UID_PORT_ID       port_id;
166   RSTP_PORT_STATE   state;
167   unsigned long     path_cost;
168 
169   UID_BRIDGE_ID_T   designated_root;
170   unsigned long     designated_cost;
171   UID_BRIDGE_ID_T   designated_bridge;
172   UID_PORT_ID       designated_port;
173 
174 #if 0
175   int               infoIs;
176   unsigned short    handshake_flags;
177 #endif
178 
179   unsigned long     rx_cfg_bpdu_cnt;
180   unsigned long     rx_rstp_bpdu_cnt;
181   unsigned long     rx_tcn_bpdu_cnt;
182   int               fdWhile;      /* 17.15.1 */
183   int               helloWhen;    /* 17.15.2 */
184   int               mdelayWhile;  /* 17.15.3 */
185   int               rbWhile;      /* 17.15.4 */
186   int               rcvdInfoWhile;/* 17.15.5 */
187   int               rrWhile;      /* 17.15.6 */
188   int               tcWhile;      /* 17.15.7 */
189   int               txCount;      /* 17.18.40 */
190   int               lnkWhile;
191 
192   unsigned long     uptime;       /* 14.8.2.1.3.a */
193   unsigned long     oper_port_path_cost;
194   unsigned char     role;
195   unsigned char     oper_point2point;
196   unsigned char     oper_edge;
197   unsigned char     oper_stp_neigb;
198   unsigned char     top_change_ack;
199   unsigned char     tc;
200 } UID_STP_PORT_STATE_T;
201 
202 #endif
203