1N/A/************************************************************************
1N/A * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
1N/A * Copyright (C) 2001-2003 Optical Access
1N/A * Author: Alex Rozin
1N/A *
1N/A * This file is part of RSTP library.
1N/A *
1N/A * RSTP library is free software; you can redistribute it and/or modify it
1N/A * under the terms of the GNU Lesser General Public License as published by the
1N/A * Free Software Foundation; version 2.1
1N/A *
1N/A * RSTP library is distributed in the hope that it will be useful, but
1N/A * WITHOUT ANY WARRANTY; without even the implied warranty of
1N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
1N/A * General Public License for more details.
1N/A *
1N/A * You should have received a copy of the GNU Lesser General Public License
1N/A * along with RSTP library; see the file COPYING. If not, write to the Free
1N/A * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
1N/A * 02111-1307, USA.
1N/A **********************************************************************/
1N/A
1N/A/* This file contains API from an operation system to the RSTP library */
1N/A
1N/A#include "base.h"
1N/A#include "stpm.h"
1N/A#include "stp_in.h" /* for bridge defaults */
1N/A#include "stp_to.h"
1N/A
1N/A
1N/Aint
1N/ASTP_IN_stpm_create (int vlan_id, char* name)
1N/A{
1N/A register STPM_T* this;
1N/A int err_code;
1N/A UID_STP_CFG_T init_cfg;
1N/A
1N/A stp_trace ("STP_IN_stpm_create(%s)", name);
1N/A
1N/A init_cfg.field_mask = BR_CFG_ALL;
1N/A STP_OUT_get_init_stpm_cfg (vlan_id, &init_cfg);
1N/A init_cfg.field_mask = 0;
1N/A
1N/A RSTP_CRITICAL_PATH_START;
1N/A this = stp_in_stpm_create (vlan_id, name, &err_code);
1N/A if (this) {
1N/A this->BrId.prio = init_cfg.bridge_priority;
1N/A this->BrTimes.MaxAge = init_cfg.max_age;
1N/A this->BrTimes.HelloTime = init_cfg.hello_time;
1N/A this->BrTimes.ForwardDelay = init_cfg.forward_delay;
1N/A this->ForceVersion = (PROTOCOL_VERSION_T) init_cfg.force_version;
1N/A }
1N/A
1N/A RSTP_CRITICAL_PATH_END;
1N/A return err_code;
1N/A}
1N/A
1N/Aint
1N/ASTP_IN_stpm_delete (int vlan_id)
1N/A{
1N/A register STPM_T* this;
1N/A int iret = 0;
1N/A
1N/A RSTP_CRITICAL_PATH_START;
1N/A this = stpapi_stpm_find (vlan_id);
1N/A
1N/A if (! this) { /* it had not yet been created :( */
1N/A iret = STP_Vlan_Had_Not_Yet_Been_Created;
1N/A } else {
1N/A
1N/A if (STP_ENABLED == this->admin_state) {
1N/A if (0 != STP_stpm_enable (this, STP_DISABLED)) {/* can't disable :( */
1N/A iret = STP_Another_Error;
1N/A } else
1N/A STP_OUT_set_hardware_mode (vlan_id, STP_DISABLED);
1N/A }
1N/A
1N/A if (0 == iret) {
1N/A STP_stpm_delete (this);
1N/A }
1N/A }
1N/A RSTP_CRITICAL_PATH_END;
1N/A return iret;
1N/A}
1N/A
1N/Aint
1N/ASTP_IN_stpm_get_vlan_id_by_name (char* name, int* vlan_id)
1N/A{
1N/A register STPM_T* stpm;
1N/A int iret = STP_Cannot_Find_Vlan;
1N/A
1N/A RSTP_CRITICAL_PATH_START;
1N/A for (stpm = STP_stpm_get_the_list (); stpm; stpm = stpm->next) {
1N/A if (stpm->name && ! strcmp (stpm->name, name)) {
1N/A *vlan_id = stpm->vlan_id;
1N/A iret = 0;
1N/A break;
1N/A }
1N/A }
1N/A RSTP_CRITICAL_PATH_END;
1N/A
1N/A return iret;
1N/A}
1N/A
1N/A
1N/ABool
1N/ASTP_IN_get_is_stpm_enabled (int vlan_id)
1N/A{
1N/A STPM_T* this;
1N/A Bool iret = False;
1N/A
1N/A RSTP_CRITICAL_PATH_START;
1N/A this = stpapi_stpm_find (vlan_id);
1N/A
1N/A if (this) {
1N/A if (this->admin_state == STP_ENABLED) {
1N/A iret = True;
1N/A }
1N/A#ifdef notdef
1N/A } else {
1N/A ; /* it had not yet been created :( */
1N/A#endif
1N/A }
1N/A
1N/A RSTP_CRITICAL_PATH_END;
1N/A return iret;
1N/A}
1N/A
1N/Aint
1N/ASTP_IN_stop_all (void)
1N/A{
1N/A register STPM_T* stpm;
1N/A
1N/A RSTP_CRITICAL_PATH_START;
1N/A
1N/A for (stpm = STP_stpm_get_the_list (); stpm; stpm = stpm->next) {
1N/A if (STP_DISABLED != stpm->admin_state) {
1N/A STP_OUT_set_hardware_mode (stpm->vlan_id, STP_DISABLED);
1N/A (void) STP_stpm_enable (stpm, STP_DISABLED);
1N/A }
1N/A }
1N/A
1N/A RSTP_CRITICAL_PATH_END;
1N/A return 0;
1N/A}
1N/A
1N/Aint
1N/ASTP_IN_delete_all (void)
1N/A{
1N/A register STPM_T* stpm;
1N/A
1N/A RSTP_CRITICAL_PATH_START;
1N/A for (stpm = STP_stpm_get_the_list (); stpm; stpm = stpm->next) {
1N/A (void) STP_stpm_enable (stpm, STP_DISABLED);
1N/A STP_stpm_delete (stpm);
1N/A }
1N/A
1N/A RSTP_CRITICAL_PATH_END;
1N/A return 0;
1N/A}
1N/A