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 prototypes for API from an operation
1N/A system to the RSTP */
1N/A
1N/A#ifndef _STP_API_H__
1N/A#define _STP_API_H__
1N/A
1N/A#include <sys/types.h>
1N/A
1N/A#define STP_DBG 1
1N/A
1N/A/************************
1N/A * Common base constants
1N/A ************************/
1N/A
1N/A#ifndef INOUT
1N/A# define IN /* consider as comments near 'input' parameters */
1N/A# define OUT /* consider as comments near 'output' parameters */
1N/A# define INOUT /* consider as comments near 'input/output' parameters */
1N/A#endif
1N/A
1N/A#ifndef Zero
1N/A# define Zero 0
1N/A# define One 1
1N/A#endif
1N/A
1N/A#ifndef Bool
1N/A# define Bool int
1N/A# define False 0
1N/A# define True 1
1N/A#endif
1N/A
1N/A/********************************************
1N/A * constants: default values and linitations
1N/A *********************************************/
1N/A
1N/A/* bridge configuration */
1N/A
1N/A#define DEF_BR_PRIO 32768
1N/A#define MIN_BR_PRIO 0
1N/A#define MAX_BR_PRIO 61440
1N/A
1N/A#define DEF_BR_HELLOT 2
1N/A#define MIN_BR_HELLOT 1
1N/A#define MAX_BR_HELLOT 10
1N/A
1N/A#define DEF_BR_MAXAGE 20
1N/A#define MIN_BR_MAXAGE 6
1N/A#define MAX_BR_MAXAGE 40
1N/A
1N/A#define DEF_BR_FWDELAY 15
1N/A#define MIN_BR_FWDELAY 4
1N/A#define MAX_BR_FWDELAY 30
1N/A
1N/A#define IEEE_TIMER_SCALE 256
1N/A
1N/A/* Note that this works with unscaled values */
1N/A#define CHECK_BRIDGE_CONFIG(cfg) \
1N/A (2 * (cfg.forward_delay - 1) >= cfg.max_age && \
1N/A cfg.max_age >= 2 * (cfg.hello_time + 1))
1N/A
1N/A/*
1N/A * These macros provide limits and tests for displaying comprehensible errors.
1N/A */
1N/A#define NO_MAXAGE(cfg) ((cfg.forward_delay - 1) < (cfg.hello_time + 1))
1N/A#define MIN_FWDELAY_NOM(cfg) \
1N/A (cfg.hello_time < MIN_BR_FWDELAY - 2 ? MIN_BR_FWDELAY : \
1N/A cfg.hello_time + 2)
1N/A#define MAX_HELLOTIME_NOM(cfg) \
1N/A (cfg.forward_delay > MAX_BR_HELLOT + 2 ? MAX_BR_HELLOT : \
1N/A cfg.forward_delay - 2)
1N/A
1N/A#define SMALL_MAXAGE(cfg) (cfg.max_age < 2 * (cfg.hello_time + 1))
1N/A#define MIN_MAXAGE(cfg) \
1N/A (cfg.hello_time < (MIN_BR_MAXAGE / 2 - 1) ? MIN_BR_MAXAGE : \
1N/A (2 * (cfg.hello_time + 1)))
1N/A#define MAX_HELLOTIME(cfg) \
1N/A (cfg.max_age > 2 * (MAX_BR_HELLOT + 1) ? MAX_BR_HELLOT : \
1N/A (cfg.max_age / 2 - 1))
1N/A
1N/A#define MIN_FWDELAY(cfg) (cfg.max_age / 2 + 1)
1N/A#define MAX_MAXAGE(cfg) \
1N/A (cfg.forward_delay > (MAX_BR_MAXAGE / 2 + 1) ? MAX_BR_MAXAGE : \
1N/A (2 * (cfg.forward_delay - 1)))
1N/A
1N/A#define CAPPED_MAXAGE(cfg) (cfg.forward_delay < (MAX_BR_MAXAGE / 2 + 1))
1N/A#define FLOORED_MAXAGE(cfg) (cfg.hello_time > (MIN_BR_MAXAGE / 2 - 1))
1N/A
1N/A#define DEF_FORCE_VERS 2 /* NORMAL_RSTP */
1N/A
1N/A/* port configuration */
1N/A
1N/A#define DEF_PORT_PRIO 128
1N/A#define MIN_PORT_PRIO 0
1N/A#define MAX_PORT_PRIO 240 /* in steps of 16 */
1N/A
1N/A#define DEF_ADMIN_NON_STP False
1N/A#define DEF_ADMIN_EDGE True
1N/A#define DEF_LINK_DELAY 3 /* see edge.c */
1N/A#define DEF_P2P P2P_AUTO
1N/A
1N/A#include <uid_stp.h>
1N/A#include <stp_bpdu.h>
1N/A
1N/A#ifndef __STPM_T__
1N/A#define __STPM_T__
1N/Astruct stpm_t;
1N/Atypedef struct stpm_t STPM_T;
1N/A#endif
1N/A#ifndef __STP_VECTORS_T__
1N/A#define __STP_VECTORS_T__
1N/Astruct stp_vectors;
1N/Atypedef struct stp_vectors STP_VECTORS_T;
1N/A#endif
1N/A
1N/A/* Section 1: Create/Delete/Start/Stop the RSTP instance */
1N/A
1N/Avoid /* init the engine */
1N/ASTP_IN_init (STP_VECTORS_T *vectors);
1N/A
1N/Aint
1N/ASTP_IN_stpm_create (int vlan_id, char* name);
1N/A
1N/Aint
1N/ASTP_IN_stpm_delete (int vlan_id);
1N/A
1N/Aint
1N/ASTP_IN_port_add (int vlan_id, int port_index);
1N/A
1N/Aint
1N/ASTP_IN_port_remove (int vlan_id, int port_index);
1N/A
1N/Aint
1N/ASTP_IN_stop_all (void);
1N/A
1N/Aint
1N/ASTP_IN_delete_all (void);
1N/A
1N/A/* Section 2. "Get" management */
1N/A
1N/ABool
1N/ASTP_IN_get_is_stpm_enabled (int vlan_id);
1N/A
1N/Aint
1N/ASTP_IN_stpm_get_vlan_id_by_name (char* name, int* vlan_id);
1N/A
1N/Aint
1N/ASTP_IN_stpm_get_name_by_vlan_id (int vlan_id, char* name, size_t buffsize);
1N/A
1N/Aconst char*
1N/ASTP_IN_get_error_explanation (int rstp_err_no);
1N/A
1N/Aint
1N/ASTP_IN_stpm_get_cfg (int vlan_id, UID_STP_CFG_T* uid_cfg);
1N/A
1N/Aint
1N/ASTP_IN_stpm_get_state (int vlan_id, UID_STP_STATE_T* entry);
1N/A
1N/Aint
1N/ASTP_IN_port_get_cfg (int vlan_id, int port_index, UID_STP_PORT_CFG_T* uid_cfg);
1N/A
1N/Aint
1N/ASTP_IN_port_get_state (int vlan_id, UID_STP_PORT_STATE_T* entry);
1N/A
1N/Aconst char *
1N/ASTP_IN_state2str(RSTP_PORT_STATE);
1N/A
1N/A/* Section 3. "Set" management */
1N/A
1N/Aint
1N/ASTP_IN_stpm_set_cfg (int vlan_id,
1N/A UID_STP_CFG_T* uid_cfg);
1N/A
1N/Aint
1N/ASTP_IN_port_set_cfg (int vlan_id, int port_index,
1N/A UID_STP_PORT_CFG_T* uid_cfg);
1N/A
1N/A#ifdef STP_DBG
1N/Aint STP_IN_dbg_set_port_trace (char *mach_name, int enadis,
1N/A int vlan_id, int port_index);
1N/A#endif
1N/A
1N/A/* Section 4. RSTP functionality events */
1N/A
1N/Aint
1N/ASTP_IN_one_second (void);
1N/A
1N/Aint /* for Link UP/DOWN */
1N/ASTP_IN_enable_port (int port_index, Bool enable);
1N/A
1N/Aint /* call it, when port speed has been changed, speed in Kb/s */
1N/ASTP_IN_changed_port_speed (int port_index, long speed);
1N/A
1N/Aint /* call it, when current port duplex mode has been changed */
1N/ASTP_IN_changed_port_duplex (int port_index);
1N/A
1N/Aint
1N/ASTP_IN_check_bpdu_header (BPDU_T* bpdu, size_t len);
1N/A
1N/Aint
1N/ASTP_IN_rx_bpdu (int vlan_id, int port_index, BPDU_T* bpdu, size_t len);
1N/A
1N/Avoid
1N/ASTP_IN_get_bridge_id(int vlan_id, unsigned short *priority, unsigned char *mac);
1N/A
1N/A#endif /* _STP_API_H__ */