/************************************************************************
* RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
* Copyright (C) 2001-2003 Optical Access
* Author: Alex Rozin
*
* This file is part of RSTP library.
*
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; version 2.1
*
* RSTP library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with RSTP library; see the file COPYING. If not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
**********************************************************************/
/* This file contains API from an operation system to the RSTP library */
#include "base.h"
#include "stpm.h"
#include "stp_in.h"
#include "stp_to.h"
void *
{
/* stp_trace ("stp_in_stpm_create(%s)", name); */
if (this) { /* it had just been created :( */
return this;
}
if (! this) { /* can't create stpm :( */
return NULL;
}
return this;
}
int
{
/* stp_trace ("_stp_in_stpm_enable(%s)", name); */
if (STP_DISABLED != admin_state) {
if (! vlan_id) { /* STP_IN_stop_all (); */
}
}
}
}
if (! this) { /* it had not yet been created */
if (! this) {
}
created_here = True;
} else {/* try to disable nothing ? */
return 0;
}
}
return 0;
}
if (! rc) {
}
if (rc && created_here) {
}
return rc;
}
STPM_T *
{
return this;
return NULL;
}
static PORT_T *
{
return port;
}
return NULL;
}
static void
{
(void) memcpy (t, f, sizeof (UID_BRIDGE_ID_T));
}
static int
{
return STP_Small_Bridge_Priority;
}
return STP_Large_Bridge_Priority;
}
return STP_Small_Hello_Time;
}
return STP_Large_Hello_Time;
}
return STP_Small_Max_Age;
}
return STP_Large_Max_Age;
}
return STP_Small_Forward_Delay;
}
return STP_Large_Forward_Delay;
}
}
}
return 0;
}
static void
{
if (! port) return;
return;
}
if (enable) { /* clear port statistics */
port->rx_tcn_bpdu_cnt = 0;
}
#ifdef STP_DBG
stp_trace ("Port %s became '%s' adminEdge=%c",
}
#endif
}
void
{
}
int
{
uid_cfg->field_mask = 0;
if (!this) { /* it had not yet been created :( */
}
}
}
}
}
}
}
return 0;
}
int
{
if (!this) { /* it had not yet been created :( */
}
if (! port) {/* port is absent in the stpm :( */
return STP_Port_Is_Absent_In_The_Vlan;
}
uid_cfg->field_mask = 0;
return 0;
}
int
{
if (!this) { /* it had not yet been created :( */
}
if (! port) {/* port is absent in the stpm :( */
return STP_Port_Is_Absent_In_The_Vlan;
}
} else {
}
}
entry->designated_cost = 0;
}
entry->oper_stp_neigb = 0;
} else {
}
return 0;
}
int
{
if (!this) { /* it had not yet been created :( */
}
return 0;
}
int
{
else
iret = 0;
break;
}
}
return iret;
}
{
if (! enable) {
#ifdef STP_DBG
stp_trace("%s (p%02d, all, %s, '%s')",
#endif
}
/* STP_stpm_update (stpm);*/
}
return 0;
}
int /* call it, when port speed has been changed, speed in Kb/s */
{
if (! port) continue;
#ifdef STP_DBG
}
#endif
}
return 0;
}
int /* call it, when port duplex mode has been changed */
{
if (! port) continue;
#ifdef STP_DBG
}
#endif
}
return 0;
}
int
{
unsigned short len8023;
/* LINTED: alignment */
return STP_Big_len8023_Format;
}
return STP_Small_len8023_Format;
}
return STP_len8023_Format_Gt_Len;
}
/* this is not a proper 802.3 pkt! :( */
return STP_Not_Proper_802_3_Packet;
}
return STP_Invalid_Protocol;
}
#if 0
return STP_Invalid_Version;
}
#endif
/* see also 9.3.4: think & TBD :( */
return 0;
}
#ifdef STP_DBG
int dbg_rstp_deny = 0;
#endif
int
{
int iret;
#ifdef STP_DBG
if (1 == dbg_rstp_deny) {
return 0;
}
#endif
if (! this) { /* the stpm had not yet been created :( */
}
}
if (! port) {/* port is absent in the stpm :( */
#ifdef STP_DBG
stp_trace ("RX bpdu vlan_id=%d port=%d port is absent in the stpm :(", (int) vlan_id, (int) port_index);
#endif
return STP_Port_Is_Absent_In_The_Vlan;
}
#ifdef STP_DBG
stp_trace ("port %s stop rx skipping",
else
stp_trace ("port %s skip rx %d",
return STP_Nothing_To_Do;
}
#endif
#ifdef STP_DBG
}
#endif
}
/* port link change indication will come later :( */
if (! port->portEnabled &&
}
#ifdef STP_DBG
}
#endif
(void) STP_stpm_update (this);
return iret;
}
int
STP_IN_one_second (void)
{
register int dbg_cnt = 0;
/* stp_trace ("STP_IN_one_second vlan_id=%d", (int) stpm->vlan_id); */
dbg_cnt++;
}
}
return dbg_cnt;
}
int
{
/* stp_trace ("STP_IN_stpm_set_cfg"); */
}
}
}
}
}
}
if (0 != rc) {
return rc;
}
if (0 != rc) {
return rc;
}
if (! uid_cfg->field_mask) {
return 0;
}
}
/* get current state */
if (! this) { /* it had not yet been created */
if (! this) {
return err_code;
}
}
if (0 != STP_stpm_check_bridge_priority (this)) {
return STP_Invalid_Bridge_Priority;
}
}
if (0 != rc) {
if (created_here) {
}
return rc;
}
enabled_here = True;
}
}
return 0;
}
int
{
if (! this) { /* it had not yet been created :( */
}
if (! port) {/* port is absent in the stpm :( */
return STP_Port_Is_Absent_In_The_Vlan;
}
}
}
}
}
#ifdef STP_DBG
stp_trace ("port %s is operEdge=%c in STP_IN_port_set_cfg",
}
#endif
}
#ifdef STP_DBG
stp_trace ("port %s is adminNonStp=%c in STP_IN_port_set_cfg",
}
#endif
}
#ifdef STP_DBG
}
}
#endif
(void) STP_stpm_update (this);
return 0;
}
#ifdef STP_DBG
int
{
int rc;
if (! this) { /* it had not yet been created :( */
}
if (! port) {/* port is absent in the stpm :( */
return STP_Port_Is_Absent_In_The_Vlan;
}
return rc;
}
#endif
const char*
{
#define CHOOSE(a) #a
if (rstp_err_no < STP_OK) {
return "Too small error code :(";
}
if (rstp_err_no >= STP_LAST_DUMMY) {
return "Too big error code :(";
}
return rstp_error_names[rstp_err_no];
}
int
{
if (!this) { /* it had not yet been created :( */
}
/* can't add port :( */
}
if (!port)
return rc;
}
int
{
if (!this) { /* it had not yet been created :( */
}
if (! port) {/* port is absent in the stpm :( */
return STP_Port_Is_Absent_In_The_Vlan;
}
return STP_OK;
}
void
{
}
const char *
{
switch (state) {
case UID_PORT_DISABLED:
return ("disabled");
case UID_PORT_DISCARDING:
return ("discarding");
case UID_PORT_LEARNING:
return ("learning");
case UID_PORT_FORWARDING:
return ("forwarding");
case UID_PORT_NON_STP:
return ("non-stp");
case UID_PORT_BADSDU: /* synthetic state used by daemon */
return ("bad-mtu");
}
return ("unknown");
}