⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 migrate.c

📁 rstp for switch in vxworks
💻 C
字号:

/************************************************************************ 
 * 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. 
 **********************************************************************/

/* Port Protocol Migration state machine : 17.26 */

#include "base.h"
#include "stpm.h"

#define STATES { \
  CHOOSE(INIT),     \
  CHOOSE(SEND_RSTP),    \
  CHOOSE(SENDING_RSTP), \
  CHOOSE(SEND_STP), \
  CHOOSE(SENDING_STP),  \
}

#define INIT           2
#define SEND_RSTP      3
#define SENDING_RSTP   4
#define SEND_STP       5
#define SENDING_STP    6



#define GET_STATE_NAME STP_migrate_get_state_name
#include "choose.h"

#define MigrateTime 3	/* 17,16.4 */

/**********************************************************************************
  Port Protocol Migration 状态机
    Configuration和TCN BPDU都是只有STP才识别.RSTP则识别三种不同的BPDU
    包,
    d)  在没有Configuration和TCN的BPDU收到的端口上(edge port或者仅仅连接
         到RSTP桥上),并且如果ForceVersion 被设置成2或者更多,仅仅由RSTP
         包可以使用,利用TC flag来在必要的时候标记拓扑变化
    e)  在曾经收到过Configuration和Notification的BPDU的端口上(Port连接到一个
         或者多个不支持RSTP的桥),或者ForceVersion变量小于2,则使用普通
         的RSTP包

    为了达到这个结果,支持RSTP的系统必须对仅仅支持STP的桥保持
    敏感性.必须注意ForceVersion的参数,并且相应地调节对BPDU的使用.
    

***********************************************************************************/

/************************************************************************************
  函数名称:  
  输入参数:  
  输出参数:  
  功能描述:  Port Protocol Migratiion 状态机的状态操作函数
  返回值     :
  备注           :   17.26
  作者           :  
  日期           :
  ************************************************************************************/


void STP_migrate_enter_state (STATE_MACH_T * this)
{
	register struct net_bridge_port *port = this->owner.port;

	switch (this->State)
	{
		case BEGIN:
		case INIT:
			port->initPm = True;
			port->mcheck = False;
			break;
		case SEND_RSTP:
			port->mdelayWhile = MigrateTime;
			port->mcheck = port->initPm = False;     
			port->sendRSTP = True;/*该变量可以使交换机发送RSTP包*/
			break;
		case SENDING_RSTP:
			port->rcvdRSTP = port->rcvdSTP = False;
			break;
		case SEND_STP:
			port->mdelayWhile = MigrateTime;/*使状态机忽略所有收到的BPDU*/
			port->sendRSTP = False;
			port->initPm = False;     
			break;
		case SENDING_STP:
			port->rcvdRSTP = port->rcvdSTP = False;
			break;
	}
}

/***********************************************************************************
 *  function:
    purpose:  Port Protocol Migration 状态机转移
    input:
    output:
    return:
    remark:
 *
 *
***********************************************************************************/
Bool STP_migrate_check_conditions (STATE_MACH_T * this)
{
	register struct net_bridge_port *port = this->owner.port;

	if ((!port->portEnabled && !port->initPm) || BEGIN == this->State)
		return STP_hop_2_state (this, INIT);

	switch (this->State)
	{
		case INIT:
			if (port->portEnabled)
			{
				return STP_hop_2_state (this,
					(port->br->ForceVersion >= 2) ? SEND_RSTP : SEND_STP);
			}
			break;
		case SEND_RSTP:
			return STP_hop_2_state (this, SENDING_RSTP);
		case SENDING_RSTP:
			if (port->mcheck)
				return STP_hop_2_state (this, SEND_RSTP);
			if (port->mdelayWhile && (port->rcvdSTP || port->rcvdRSTP))
			{
				return STP_hop_2_state (this, SENDING_RSTP);
			}

			if (!port->mdelayWhile && port->rcvdSTP)
			{
				return STP_hop_2_state (this, SEND_STP);
			}

			if (port->br->ForceVersion < 2)
			{
				return STP_hop_2_state (this, SEND_STP);
			}

			break;
		case SEND_STP:
			return STP_hop_2_state (this, SENDING_STP);
		case SENDING_STP:
			if (port->mcheck)
				return STP_hop_2_state (this, SEND_RSTP);
			if (port->mdelayWhile && (port->rcvdSTP || port->rcvdRSTP))
				return STP_hop_2_state (this, SENDING_STP);
			if (!port->mdelayWhile && port->rcvdRSTP)
				return STP_hop_2_state (this, SEND_RSTP);
			break;
	}
	return False;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -