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

📄 rstp_cli.c

📁 rstp for switch in vxworks
💻 C
📖 第 1 页 / 共 4 页
字号:
    i = stp_STPDomainForwardDelay_get("default");
    	
    free(ppcMacAddress);
}



int rstp_port_priority_get(short port_no)
{


	UID_STP_STATE_T uid_state;
       struct net_bridge *br;
	struct net_bridge_port * port;
	int rc;
	UID_STP_PORT_CFG_T uid_cfg;
	UID_STP_PORT_STATE_T uid_port;

	port = br_get_port_byno(port_no);

	if(!port)
	{
		return -1;
	}

      br = port->br;

    
	
	rc = STP_IN_stpm_get_state (br, &uid_state);
	if (rc)
	{
		return -1;
		
	}

	uid_port.port_no = port->port_no;
	rc = STP_IN_port_get_state (port, &uid_port);
	if (rc)
	{
		return -1;
	}

	memset (&uid_cfg, 0, sizeof (UID_STP_PORT_CFG_T));
	rc = STP_IN_port_get_cfg (port, &uid_cfg);
	if (rc)
	{
		return -1;
	}

	return (int) (uid_port.port_id >> 8);

}

/*role[12]*/
int rstp_port_role_get(short port_no)
{


	UID_STP_STATE_T uid_state;
       struct net_bridge *br;
	struct net_bridge_port * port;
	int rc;
	int ret;
	UID_STP_PORT_CFG_T uid_cfg;
	UID_STP_PORT_STATE_T uid_port;

	port = br_get_port_byno(port_no);

	if(!port)
	{
		return -1;
	}

      br = port->br;
 
	
	rc = STP_IN_stpm_get_state (br, &uid_state);
	if (rc)
	{
		return -1;
		
	}

	uid_port.port_no = port->port_no;
	rc = STP_IN_port_get_state (port, &uid_port);
	if (rc)
	{
		return -1;
	}

	memset (&uid_cfg, 0, sizeof (UID_STP_PORT_CFG_T));
	rc = STP_IN_port_get_cfg (port, &uid_cfg);
	if (rc)
	{
		return -1;
	}

	

	switch (uid_port.role)
	{
		case 'A':
			ret = 1;
			break;
		case 'B':
			ret = 2;
			break;
		case 'R':
			ret = 3;
			break;
		case 'D':
			ret = 4;
			break;
		case '-':
			ret = 5;
			break;
		default:
			ret = 6;
			break;
	}

	
	return ret;

}



/*state[12]*/
int rstp_port_state_get(short port_no)
{


	UID_STP_STATE_T uid_state;
       struct net_bridge *br;
	struct net_bridge_port * port;
	int rc;
	UID_STP_PORT_CFG_T uid_cfg;
	UID_STP_PORT_STATE_T uid_port;

	port = br_get_port_byno(port_no);

	if(!port)
	{
		return -1;
	}

      br = port->br;

   
	
	rc = STP_IN_stpm_get_state (br, &uid_state);
	if (rc)
	{
		return -1;
		
	}

	uid_port.port_no = port->port_no;
	rc = STP_IN_port_get_state (port, &uid_port);
	if (rc)
	{
		return -1;
	}

	memset (&uid_cfg, 0, sizeof (UID_STP_PORT_CFG_T));
	rc = STP_IN_port_get_cfg (port, &uid_cfg);
	if (rc)
	{
		return -1;
	}

	
	if (br->admin_state !=STP_ENABLED)
	{
		return 1;
	}
	else
	{
		return uid_port.state+1;
	}



}





/*state[12]*/
int rstp_port_pathcost_get(short port_no)
{


	UID_STP_STATE_T uid_state;
       struct net_bridge *br;
	struct net_bridge_port * port;
	int rc;
	UID_STP_PORT_CFG_T uid_cfg;
	UID_STP_PORT_STATE_T uid_port;

	port = br_get_port_byno(port_no);

	if(!port)
	{
		return -1;
	}

      br = port->br;

    
	
	rc = STP_IN_stpm_get_state (br, &uid_state);
	if (rc)
	{
		return -1;
		
	}

	uid_port.port_no = port->port_no;
	rc = STP_IN_port_get_state (port, &uid_port);
	if (rc)
	{
		return -1;
	}

	memset (&uid_cfg, 0, sizeof (UID_STP_PORT_CFG_T));
	rc = STP_IN_port_get_cfg (port, &uid_cfg);
	if (rc)
	{
		return -1;
	}

	return uid_port.oper_port_path_cost;



}


int rstp_port_partner_get(short port_no,char *partner)
{


	UID_STP_STATE_T uid_state;
       struct net_bridge *br;
	struct net_bridge_port * port;
	int rc;
	UID_STP_PORT_CFG_T uid_cfg;
	UID_STP_PORT_STATE_T uid_port;

	port = br_get_port_byno(port_no);

	if(!port)
	{
		return -1;
	}

      br = port->br;

    
	
	rc = STP_IN_stpm_get_state (br, &uid_state);
	if (rc)
	{
		return -1;
		
	}

	uid_port.port_no = port->port_no;
	rc = STP_IN_port_get_state (port, &uid_port);
	if (rc)
	{
		return -1;
	}

	memset (&uid_cfg, 0, sizeof (UID_STP_PORT_CFG_T));
	rc = STP_IN_port_get_cfg (port, &uid_cfg);
	if (rc)
	{
		return -1;
	}


	sprintf(partner,"%s",uid_port.oper_stp_neigb ? "Slow" : "Rapid");
	return 0;

}


int rstp_port_designated_root_priority_get(short port_no)
{

	UID_STP_STATE_T uid_state;
       struct net_bridge *br;
	struct net_bridge_port * port;
	int rc;
	UID_STP_PORT_CFG_T uid_cfg;
	UID_STP_PORT_STATE_T uid_port;

	port = br_get_port_byno(port_no);

	if(!port)
	{
		return -1;
	}

      br = port->br;

   
	
	rc = STP_IN_stpm_get_state (br, &uid_state);
	if (rc)
	{
		return -1;
		
	}

	uid_port.port_no = port->port_no;
	rc = STP_IN_port_get_state (port, &uid_port);
	if (rc)
	{
		return -1;
	}

	memset (&uid_cfg, 0, sizeof (UID_STP_PORT_CFG_T));
	rc = STP_IN_port_get_cfg (port, &uid_cfg);
	if (rc)
	{
		return -1;
	}

	return uid_port.designated_root.prio;;

}


int rstp_port_designated_root_mac_get(short port_no,unsigned char *mac)
{

       UID_STP_STATE_T uid_state;
       struct net_bridge *br;
	struct net_bridge_port * port;
	int rc;
	UID_STP_PORT_CFG_T uid_cfg;
	UID_STP_PORT_STATE_T uid_port;

	port = br_get_port_byno(port_no);

	if(!port)
	{
		return -1;
	}

      br = port->br;

	rc = STP_IN_stpm_get_state (br, &uid_state);
	if (rc)
	{
		return -1;
		
	}

	uid_port.port_no = port->port_no;
	rc = STP_IN_port_get_state (port, &uid_port);
	if (rc)
	{
		return -1;
	}

	memset (&uid_cfg, 0, sizeof (UID_STP_PORT_CFG_T));
	rc = STP_IN_port_get_cfg (port, &uid_cfg);
	if (rc)
	{
		return -1;
	}

	memcpy(mac,&uid_port.designated_root.addr[0],6);

/*	mac[0]= uid_port.designated_bridge.addr[0];
	mac[1]=uid_port.designated_bridge.addr[1]);
	sprintf(&pcMacAddress[2],"%2x", uid_port.designated_bridge.addr[2]);
	sprintf(&pcMacAddress[3],"%2x", uid_port.designated_bridge.addr[3]);
	sprintf(&pcMacAddress[4],"%2x", uid_port.designated_bridge.addr[4]);
	sprintf(&pcMacAddress[5],"%2x", uid_port.designated_bridge.addr[5]);

	genMacaddrBycharstr (mac, &pcMacAddress[0]);
	*/


}



int rstp_port_designated_bridge_priority_get(short port_no)
{
UID_STP_STATE_T uid_state;
       struct net_bridge *br;
	struct net_bridge_port * port;
	int rc;
	UID_STP_PORT_CFG_T uid_cfg;
	UID_STP_PORT_STATE_T uid_port;

	port = br_get_port_byno(port_no);

	if(!port)
	{
		return -1;
	}

      br = port->br;

  
	
	rc = STP_IN_stpm_get_state (br, &uid_state);
	if (rc)
	{
		return -1;
		
	}

	uid_port.port_no = port->port_no;
	rc = STP_IN_port_get_state (port, &uid_port);
	if (rc)
	{
		return -1;
	}

	memset (&uid_cfg, 0, sizeof (UID_STP_PORT_CFG_T));
	rc = STP_IN_port_get_cfg (port, &uid_cfg);
	if (rc)
	{
		return -1;
	}

	return uid_port.designated_bridge.prio;;
 
}
 
int rstp_port_designated_bridge_mac_get(short port_no,char *mac)
{
 	UID_STP_STATE_T uid_state;
       struct net_bridge *br;
	struct net_bridge_port * port;
	int rc;
	UID_STP_PORT_CFG_T uid_cfg;
	UID_STP_PORT_STATE_T uid_port;

	port = br_get_port_byno(port_no);

	if(!port)
	{
		return -1;
	}

      br = port->br;

  	
	rc = STP_IN_stpm_get_state (br, &uid_state);
	if (rc)
	{
		return -1;
		
	}

	uid_port.port_no = port->port_no;
	rc = STP_IN_port_get_state (port, &uid_port);
	if (rc)
	{
		return -1;
	}

	memset (&uid_cfg, 0, sizeof (UID_STP_PORT_CFG_T));
	rc = STP_IN_port_get_cfg (port, &uid_cfg);
	if (rc)
	{
		return -1;
	}

	memcpy(mac,&uid_port.designated_bridge.addr[0],6);

/*	mac[0]= uid_port.designated_bridge.addr[0];
	mac[1]=uid_port.designated_bridge.addr[1]);
	sprintf(&pcMacAddress[2],"%2x", uid_port.designated_bridge.addr[2]);
	sprintf(&pcMacAddress[3],"%2x", uid_port.designated_bridge.addr[3]);
	sprintf(&pcMacAddress[4],"%2x", uid_port.designated_bridge.addr[4]);
	sprintf(&pcMacAddress[5],"%2x", uid_port.designated_bridge.addr[5]);

	genMacaddrBycharstr (mac, &pcMacAddress[0]);
	*/
}
int rstp_port_designated_cost_get(short port_no)
{

       UID_STP_STATE_T uid_state;
       struct net_bridge *br;
	struct net_bridge_port * port;
	int rc;
	UID_STP_PORT_CFG_T uid_cfg;
	UID_STP_PORT_STATE_T uid_port;

	port = br_get_port_byno(port_no);

	if(!port)
	{
		return -1;
	}

      br = port->br;


	rc = STP_IN_stpm_get_state (br, &uid_state);
	if (rc)
	{
		return -1;
		
	}

	uid_port.port_no = port->port_no;
	rc = STP_IN_port_get_state (port, &uid_port);
	if (rc)
	{
		return -1;
	}

	memset (&uid_cfg, 0, sizeof (UID_STP_PORT_CFG_T));
	rc = STP_IN_port_get_cfg (port, &uid_cfg);
	if (rc)
	{
		return -1;
	}

	return (unsigned long) uid_port.designated_cost;

}

 int rstp_DesignatedPort_get(short port_no)
{
	UID_STP_STATE_T uid_state;
       struct net_bridge *br;
	struct net_bridge_port * port;
	int rc;
	UID_STP_PORT_CFG_T uid_cfg;
	UID_STP_PORT_STATE_T uid_port;

	port = br_get_port_byno(port_no);

	if(!port)
	{
		return -1;
	}

      br = port->br;

    	rc = STP_IN_stpm_get_state (br, &uid_state);
	if (rc)
	{
		return -1;
		
	}

	uid_port.port_no = port->port_no;
	rc = STP_IN_port_get_state (port, &uid_port);
	if (rc)
	{
		return -1;
	}

	memset (&uid_cfg, 0, sizeof (UID_STP_PORT_CFG_T));
	rc = STP_IN_port_get_cfg (port, &uid_cfg);
	if (rc)
	{
		return -1;
	}


	return (int) (uid_port.designated_port&0xff);
}



int rstp_DesignatedPortPriority_get(short port_no)
{
	UID_STP_STATE_T uid_state;
       struct net_bridge *br;
	struct net_bridge_port * port;
	int rc;
	UID_STP_PORT_CFG_T uid_cfg;
	UID_STP_PORT_STATE_T uid_port;

	port = br_get_port_byno(port_no);

	if(!port)
	{
		return -1;
	}

      br = port->br;

    	
	rc = STP_IN_stpm_get_state (br, &uid_state);
	if (rc)
	{
		return -1;
		
	}

	uid_port.port_no = port->port_no;
	rc = STP_IN_port_get_state (port, &uid_port);
	if (rc)
	{
		return -1;
	}

	memset (&uid_cfg, 0, sizeof (UID_STP_PORT_CFG_T));
	rc = STP_IN_port_get_cfg (port, &uid_cfg);
	if (rc)
	{
		return -1;
	}


	return (int) (uid_port.designated_port>> 8);
}


#if 0
int ldu_upgrade_epon()
{
return 1;
}

void has_fan_trap()
{}

void has_optical_trap()
{}

int slotAlarmBitMap;

#endif

⌨️ 快捷键说明

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