xref: /onnv-gate/usr/src/lib/librstp/common/vector.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 priority vectors API : 17.4.2 */
24*10491SRishi.Srivatsavai@Sun.COM 
25*10491SRishi.Srivatsavai@Sun.COM #ifndef _PRIO_VECTOR_H__
26*10491SRishi.Srivatsavai@Sun.COM #define _PRIO_VECTOR_H__
27*10491SRishi.Srivatsavai@Sun.COM 
28*10491SRishi.Srivatsavai@Sun.COM #define STP_DBG 1
29*10491SRishi.Srivatsavai@Sun.COM 
30*10491SRishi.Srivatsavai@Sun.COM typedef struct bridge_id
31*10491SRishi.Srivatsavai@Sun.COM {
32*10491SRishi.Srivatsavai@Sun.COM   unsigned short    prio;
33*10491SRishi.Srivatsavai@Sun.COM   unsigned char     addr[6];
34*10491SRishi.Srivatsavai@Sun.COM } BRIDGE_ID;
35*10491SRishi.Srivatsavai@Sun.COM 
36*10491SRishi.Srivatsavai@Sun.COM typedef unsigned short  PORT_ID;
37*10491SRishi.Srivatsavai@Sun.COM 
38*10491SRishi.Srivatsavai@Sun.COM typedef struct prio_vector_t {
39*10491SRishi.Srivatsavai@Sun.COM   BRIDGE_ID root_bridge;
40*10491SRishi.Srivatsavai@Sun.COM   unsigned long root_path_cost;
41*10491SRishi.Srivatsavai@Sun.COM   BRIDGE_ID design_bridge;
42*10491SRishi.Srivatsavai@Sun.COM   PORT_ID   design_port;
43*10491SRishi.Srivatsavai@Sun.COM   PORT_ID   bridge_port;
44*10491SRishi.Srivatsavai@Sun.COM } PRIO_VECTOR_T;
45*10491SRishi.Srivatsavai@Sun.COM 
46*10491SRishi.Srivatsavai@Sun.COM void
47*10491SRishi.Srivatsavai@Sun.COM STP_VECT_create (OUT PRIO_VECTOR_T* t,
48*10491SRishi.Srivatsavai@Sun.COM                  IN BRIDGE_ID* root_br,
49*10491SRishi.Srivatsavai@Sun.COM                  IN unsigned long root_path_cost,
50*10491SRishi.Srivatsavai@Sun.COM                  IN BRIDGE_ID* design_bridge,
51*10491SRishi.Srivatsavai@Sun.COM                  IN PORT_ID design_port,
52*10491SRishi.Srivatsavai@Sun.COM                  IN PORT_ID bridge_port);
53*10491SRishi.Srivatsavai@Sun.COM void
54*10491SRishi.Srivatsavai@Sun.COM STP_VECT_copy (OUT PRIO_VECTOR_T* t, IN PRIO_VECTOR_T* f);
55*10491SRishi.Srivatsavai@Sun.COM 
56*10491SRishi.Srivatsavai@Sun.COM int
57*10491SRishi.Srivatsavai@Sun.COM STP_VECT_compare_bridge_id (IN BRIDGE_ID* b1, IN BRIDGE_ID* b2);
58*10491SRishi.Srivatsavai@Sun.COM 
59*10491SRishi.Srivatsavai@Sun.COM int
60*10491SRishi.Srivatsavai@Sun.COM STP_VECT_compare_vector (IN PRIO_VECTOR_T* v1, IN PRIO_VECTOR_T* v2);
61*10491SRishi.Srivatsavai@Sun.COM 
62*10491SRishi.Srivatsavai@Sun.COM void
63*10491SRishi.Srivatsavai@Sun.COM STP_VECT_get_vector (IN BPDU_BODY_T* b, OUT PRIO_VECTOR_T* v);
64*10491SRishi.Srivatsavai@Sun.COM 
65*10491SRishi.Srivatsavai@Sun.COM void
66*10491SRishi.Srivatsavai@Sun.COM STP_VECT_set_vector (IN PRIO_VECTOR_T* v, OUT BPDU_BODY_T* b);
67*10491SRishi.Srivatsavai@Sun.COM 
68*10491SRishi.Srivatsavai@Sun.COM #ifdef STP_DBG
69*10491SRishi.Srivatsavai@Sun.COM void
70*10491SRishi.Srivatsavai@Sun.COM STP_VECT_print (IN char* title, IN PRIO_VECTOR_T* v);
71*10491SRishi.Srivatsavai@Sun.COM 
72*10491SRishi.Srivatsavai@Sun.COM void
73*10491SRishi.Srivatsavai@Sun.COM STP_VECT_br_id_print (IN char *title, IN BRIDGE_ID* br_id, IN Bool cr);
74*10491SRishi.Srivatsavai@Sun.COM 
75*10491SRishi.Srivatsavai@Sun.COM #endif
76*10491SRishi.Srivatsavai@Sun.COM 
77*10491SRishi.Srivatsavai@Sun.COM #endif /* _PRIO_VECTOR_H__ */
78*10491SRishi.Srivatsavai@Sun.COM 
79*10491SRishi.Srivatsavai@Sun.COM 
80