1 /************************************************************************
2 * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
3 * Copyright (C) 2001-2003 Optical Access
6 * This file is part of RSTP library.
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
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.
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
21 **********************************************************************/
23 /* Port State Transition state machine : 17.24 */
35 #define GET_STATE_NAME STP_sttrans_get_state_name
39 #ifdef STRONGLY_SPEC_802_1W
41 disableLearning (STATE_MACH_T
*this)
43 register PORT_T
*port
= this->owner
.port
;
45 return STP_OUT_set_learning (port
->port_index
, port
->owner
->vlan_id
, False
);
49 enableLearning (STATE_MACH_T
*this)
51 register PORT_T
*port
= this->owner
.port
;
53 return STP_OUT_set_learning (port
->port_index
, port
->owner
->vlan_id
, True
);
57 disableForwarding (STATE_MACH_T
*this)
59 register PORT_T
*port
= this->owner
.port
;
61 return STP_OUT_set_forwarding (port
->port_index
, port
->owner
->vlan_id
, False
);
65 enableForwarding (STATE_MACH_T
*this)
67 register PORT_T
*port
= this->owner
.port
;
69 return STP_OUT_set_forwarding (port
->port_index
, port
->owner
->vlan_id
, True
);
74 STP_sttrans_enter_state (STATE_MACH_T
*this)
76 register PORT_T
*port
= this->owner
.port
;
78 switch (this->State
) {
81 port
->learning
= False
;
82 port
->forwarding
= False
;
83 #ifdef STRONGLY_SPEC_802_1W
84 disableLearning (this);
85 disableForwarding (this);
87 STP_OUT_set_port_state (port
->port_index
, port
->owner
->vlan_id
, UID_PORT_DISCARDING
);
91 port
->learning
= True
;
92 #ifdef STRONGLY_SPEC_802_1W
93 enableLearning (this);
95 STP_OUT_set_port_state (port
->port_index
, port
->owner
->vlan_id
, UID_PORT_LEARNING
);
99 port
->tc
= !port
->operEdge
;
100 port
->forwarding
= True
;
101 #ifdef STRONGLY_SPEC_802_1W
102 enableForwarding (this);
104 STP_OUT_set_port_state (port
->port_index
, port
->owner
->vlan_id
, UID_PORT_FORWARDING
);
112 STP_sttrans_check_conditions (STATE_MACH_T
*this)
114 register PORT_T
*port
= this->owner
.port
;
116 switch (this->State
) {
118 return STP_hop_2_state (this, DISCARDING
);
121 return STP_hop_2_state (this, LEARNING
);
126 return STP_hop_2_state (this, FORWARDING
);
129 return STP_hop_2_state (this, DISCARDING
);
133 if (!port
->forward
) {
134 return STP_hop_2_state (this, DISCARDING
);