Beispiel #1
0
int vlan_spanning_tree_enable_on_vlan (int vlan_id, int mode)
{
        struct vlan_static_entry *p = get_vlan_entry (vlan_id);
	int i = 0;

        if (!p) {
                return -1;
        }
	if (p->stp_enabled && p->stp_mode == mode)
		return 0;

	if (mode == MODE_STP) {
		if (stp_create_stp_instance (vlan_id, &p->stp_instance) < 0) {
			debug_vlan ("Unable to enable STP on vlan %d\n", vlan_id);
			return -1;
		}
		for (i = 1; i <= get_max_ports () ; i++) {
			int res = 0;
			IS_PORT_SET_PORT_LIST (p->egress_ports, i,res)
			if (res) {
				stp_create_port (p->stp_instance, i);	
			}
		}	

		stp_set_state (p->stp_instance, 1);

	} else if (mode == MODE_RSTP) {
Beispiel #2
0
        return -1;
    }

    /*Read and update the interface states*/
    if (ioctl(fd, SIOCGIFFLAGS, &ifr) == 0)  {
        p->ifAdminStatus = (ifr.ifr_flags & IFF_UP)? IF_UP: IF_DOWN;
        p->ifOperStatus  = (ifr.ifr_flags & IFF_RUNNING)?IF_UP:IF_DOWN;
    }

    close(fd);
    return 0;
}

void * if_link_monitor (void *arg UNUSED_PARAM)
{
    int max_ports = get_max_ports ();
    struct ifreq ifr;
    int  fd = -1;
    fd =  socket(AF_INET, SOCK_DGRAM, 0);
    if (fd < 0) {
        return NULL;
    }

    memset (&ifr, 0, sizeof(ifr));

    while (1) {
        int i = 0;

        while (i < max_ports) {

            struct interface *p = &port_cdb[i];