Ejemplo n.º 1
0
void CREATE_RSTP_INSTANCE()
   {
  	 int               The_EOR;
	   UID_STP_CFG_T 	   uid_cfg;
	   BITMAP_T          ports;
	          
//init the port number for the bridges and set the bits high for the port creation
		STP_IN_init(NUMBER_OF_PORTS);
		BitmapClear(&enabled_ports);
    BitmapClear(&ports);
		for (The_EOR = 1; The_EOR <= NUMBER_OF_PORTS; The_EOR++) 
		    {
               BitmapSetBit(&ports, The_EOR - 1);
			}
		uid_cfg.field_mask      = BR_CFG_STATE;
		uid_cfg.stp_enabled	    = STP_ENABLED;		

//set the init  info for my bridge instanse,including creatation of the bridge
		The_EOR = STP_IN_stpm_set_cfg (VLAN_ID,&ports,&uid_cfg);  

#ifdef MY_PRINT_RSTP
			if(The_EOR  == STP_OK)
			  printf("Yes! The configuration is done!!!\n");
			else 		    
			  printf("No! I'm a litter upset for the set failure!!!\n");
#endif
    } 	
Ejemplo n.º 2
0
int bridge_start(void)
{
	BITMAP_T ports;
	UID_MSG_T msg;
	UID_STP_CFG_T uid_cfg;
	register int iii;

	//rl_callback_handler_install(get_prompt(), rl_read_cli);

	if (0 != UiD_SocketInit(&uid_socket, UID_REPL_PATH,
				UID_BIND_AS_CLIENT)) {
		printf("FATAL: can't init the connection\n");
		exit(-3);
	}

	/* send HANDSHAKE */
	msg.header.sender_pid = my_pid;
	msg.header.cmd_type = UID_CNTRL;
	msg.body.cntrl.cmd = UID_BRIDGE_HANDSHAKE;
	msg.body.cntrl.param1 = NUMBER_OF_PORTS;
	iii = UiD_SocketSendto(&uid_socket, &msg, sizeof(UID_MSG_T));
	if (iii < 0) {
		printf("can't send HANDSHAKE: %s\n", strerror(errno));
		printf("May be 'mngr' is not alive ? :(\n");
		return (-4);
	}

	stp_cli_init();

	STP_IN_init(NUMBER_OF_PORTS);
	BitmapClear(&enabled_ports);
	BitmapClear(&ports);
	for (iii = 1; iii <= NUMBER_OF_PORTS; iii++) {
		BitmapSetBit(&ports, iii - 1);
	}

	uid_cfg.field_mask = BR_CFG_STATE;
	uid_cfg.stp_enabled = STP_ENABLED;
	snprintf(uid_cfg.vlan_name, NAME_LEN - 1, "B%ld", (long)my_pid);
	iii = STP_IN_stpm_set_cfg(0, &ports, &uid_cfg);
	if (STP_OK != iii) {
		printf("FATAL: can't enable:%s\n",
		       STP_IN_get_error_explanation (iii));
		return (-1);
	}
	return 0;
}