コード例 #1
0
ファイル: stpmgmt.c プロジェクト: anlaneg/rstp
int STP_IN_delete_all(void)
{
	register STPM_T *stpm, *next;

	RSTP_CRITICAL_PATH_START;
	for (stpm = STP_stpm_get_the_list (); stpm; stpm = next) {
		next = stpm->next;
		STP_stpm_enable (stpm, STP_DISABLED);
		STP_stpm_delete (stpm);
	}

	RSTP_CRITICAL_PATH_END;
	return 0;
}
コード例 #2
0
ファイル: rstpt.c プロジェクト: JasonYSU/VETH3000Switch
void SIMULATE_TCN(int port_index)
  {
	 PORT_T* my_port;
	 STPM_T* this;
     this = STP_stpm_get_the_list();
//At first,find my dest port      
     for(my_port = this->ports; my_port ; my_port= my_port -> next)
		 {
		     if(my_port->port_index == port_index)  break;
		 }
//then change some of variables	 
	my_port->rx_tcn_bpdu_cnt++;
	my_port->rcvdBpdu = True;
    my_port->msgBpduVersion = 2;
    my_port->msgBpduType = 0x01; 
  }
コード例 #3
0
ファイル: stpmgmt.c プロジェクト: anlaneg/rstp
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);
			STP_stpm_enable (stpm, STP_DISABLED);
		}
	}

	RSTP_CRITICAL_PATH_END;
	return 0;
}
コード例 #4
0
ファイル: stpmgmt.c プロジェクト: anlaneg/rstp
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;
}
コード例 #5
0
ファイル: rstpt.c プロジェクト: JasonYSU/VETH3000Switch
void SIMULATE_CONFIGURE(int port_index)
 {
	  PORT_T*      my_port;
	  STPM_T*      this;
	  BPDU_BODY_T  body;
	  
      /*!!! Here need to assign the body !!!*/	  
	  this = STP_stpm_get_the_list();
//find the right dest port
      for(my_port =this -> ports; my_port ; my_port = my_port->next )
	   {
	   	   if(my_port -> port_index == port_index) break;  
	   }
//then do the changing for the information from outside BPDUS
      my_port->rx_cfg_bpdu_cnt++;
      my_port->rcvdBpdu = True;
	    my_port->msgBpduVersion = 2;
      my_port->msgBpduType =    0x00;
      my_port->msgFlags =       body.flags; // here rserved
	  STP_VECT_get_vector(&body, &my_port->msgPrio);
      my_port->msgPrio.bridge_port = my_port->port_id;
      /* 17.18.12 */
      STP_get_times(&body, &my_port->msgTimes);
 }
コード例 #6
0
ファイル: rstpt.c プロジェクト: JasonYSU/VETH3000Switch
void SIMULATE_RSTBPDU(int port_index)
  {
      PORT_T*      my_port;
	    STPM_T*      this;
      BPDU_BODY_T  body;
    uint8_t rootid[8]    = {0x80,0x00,0x00,0x05,0xd1,0x12,0x40,0x00};
	  uint8_t pacost[4]    = {0x00,0x03,0x0d,0x40};
	  uint8_t bridgeid[8]  = {0x80,0x00,0x00,0x05,0xd1,0x12,0x40,0x00};
    uint8_t portid[2]    = {0x80,0x01};
	  uint8_t message[2]	= {0x00,0x03}; 
	  uint8_t maxage[2]	= {0x00,0x14};
	  uint8_t hellotime[2]	= {0x00,0x02};
	  uint8_t frddelay[2]  = {0x00,0x0f};       
//Here forms the simulation body
#ifdef MY_PRINT_RSTP   
		printf("Is the smulate in ?\n");    
#endif  	   				  
//	   body.flags = 0x4e;
//	   strncpy(body.root_id,rootid,8);       
//	   strncpy(body.root_path_cost,pacost,4); 
//	   strncpy(body.bridge_id,bridgeid,8);
//	   strncpy(body.port_id,portid,2);
//	   strncpy(body.message_age,message,2);
//	   strncpy(body.max_age,maxage,2);
//	   strncpy(body.hello_time,hellotime,2);
//	   strncpy(body.forward_delay,frddelay,2);    

//find this port  
  	  this = STP_stpm_get_the_list();
  	  for(my_port = this->ports; my_port ; my_port= my_port -> next)
		 {
		     if(my_port->port_index == port_index)  break;
		 }
     // printf("MY port role:\n");
	 // printf("%d",my_port->role);
//check some value of  my port	  
     // tev = RSTP_PORT_RX_T; INCR100(nev);
//      if (STP_DISABLED == this->admin_state) 
//	   {/* the stpm had not yet been enabled :( */
//         return STP_Had_Not_Yet_Been_Enabled_On_The_Vlan;
//       }
	 if (my_port->operEdge && ! my_port->lnkWhile && my_port->portEnabled)  
       	 { //printf("TC true!\n");
		   my_port->tc = True;
		 }
//	  if (! my_port->portEnabled) 
//	    {/* port link change indication will come later :( */
//          _stp_in_enable_port_on_stpm (this, my_port->port_index, True);
//        }
       my_port->operEdge = False;
       my_port->wasInitBpdu = True;
//then let the variables change for the result of the RSTBPDU      
	  my_port->rx_rstp_bpdu_cnt++;
  	  if (my_port->owner->ForceVersion >= NORMAL_RSTP) 
	  {
		 my_port->rcvdBpdu = True;
  	  }
  	  else  
	      {//printf("confirmed\n");
			 return;
		  }
      my_port->msgBpduVersion  =  2;
      my_port->msgBpduType  =  0x02;
      my_port->msgFlags =      body.flags;
      /* 17.18.11 */
      STP_VECT_get_vector (&body, &my_port->msgPrio);
      my_port->msgPrio.bridge_port = my_port->port_id;
      /* 17.18.12 */
      STP_get_times (&body, &my_port->msgTimes);
#ifdef MY_PRINT_RSTP
      printf("tellme why?\n");
#endif
			//printf("The information Got\n");
  }