1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
/************************************************************************
* RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
* Copyright (C) 2001-2003 Optical Access
* Author: Alex Rozin
*
* This file is part of RSTP library.
*
* RSTP library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; version 2.1
*
* RSTP library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with RSTP library; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
**********************************************************************/
/* This file contains API from an operation system to the RSTP library */
#include "base.h"
#include "stpm.h"
#include "stp_in.h" /* for bridge defaults */
#include "stp_to.h"
int
STP_IN_stpm_create (int vlan_id, char* name)
{
register STPM_T* this;
int err_code;
UID_STP_CFG_T init_cfg;
stp_trace ("STP_IN_stpm_create(%s)", name);
init_cfg.field_mask = BR_CFG_ALL;
STP_OUT_get_init_stpm_cfg (vlan_id, &init_cfg);
init_cfg.field_mask = 0;
RSTP_CRITICAL_PATH_START;
this = stp_in_stpm_create (vlan_id, name, &err_code);
if (this) {
this->BrId.prio = init_cfg.bridge_priority;
this->BrTimes.MaxAge = init_cfg.max_age;
this->BrTimes.HelloTime = init_cfg.hello_time;
this->BrTimes.ForwardDelay = init_cfg.forward_delay;
this->ForceVersion = (PROTOCOL_VERSION_T) init_cfg.force_version;
}
RSTP_CRITICAL_PATH_END;
return err_code;
}
int
STP_IN_stpm_delete (int vlan_id)
{
register STPM_T* this;
int iret = 0;
RSTP_CRITICAL_PATH_START;
this = stpapi_stpm_find (vlan_id);
if (! this) { /* it had not yet been created :( */
iret = STP_Vlan_Had_Not_Yet_Been_Created;
} else {
if (STP_ENABLED == this->admin_state) {
if (0 != STP_stpm_enable (this, STP_DISABLED)) {/* can't disable :( */
iret = STP_Another_Error;
} else
STP_OUT_set_hardware_mode (vlan_id, STP_DISABLED);
}
if (0 == iret) {
STP_stpm_delete (this);
}
}
RSTP_CRITICAL_PATH_END;
return iret;
}
int
STP_IN_stpm_get_vlan_id_by_name (char* name, int* vlan_id)
{
register STPM_T* stpm;
int iret = STP_Cannot_Find_Vlan;
RSTP_CRITICAL_PATH_START;
for (stpm = STP_stpm_get_the_list (); stpm; stpm = stpm->next) {
if (stpm->name && ! strcmp (stpm->name, name)) {
*vlan_id = stpm->vlan_id;
iret = 0;
break;
}
}
RSTP_CRITICAL_PATH_END;
return iret;
}
Bool
STP_IN_get_is_stpm_enabled (int vlan_id)
{
STPM_T* this;
Bool iret = False;
RSTP_CRITICAL_PATH_START;
this = stpapi_stpm_find (vlan_id);
if (this) {
if (this->admin_state == STP_ENABLED) {
iret = True;
}
#ifdef notdef
} else {
; /* it had not yet been created :( */
#endif
}
RSTP_CRITICAL_PATH_END;
return iret;
}
int
STP_IN_stop_all (void)
{
register STPM_T* stpm;
RSTP_CRITICAL_PATH_START;
for (stpm = STP_stpm_get_the_list (); stpm; stpm = stpm->next) {
if (STP_DISABLED != stpm->admin_state) {
STP_OUT_set_hardware_mode (stpm->vlan_id, STP_DISABLED);
(void) STP_stpm_enable (stpm, STP_DISABLED);
}
}
RSTP_CRITICAL_PATH_END;
return 0;
}
int
STP_IN_delete_all (void)
{
register STPM_T* stpm;
RSTP_CRITICAL_PATH_START;
for (stpm = STP_stpm_get_the_list (); stpm; stpm = stpm->next) {
(void) STP_stpm_enable (stpm, STP_DISABLED);
STP_stpm_delete (stpm);
}
RSTP_CRITICAL_PATH_END;
return 0;
}
|