1 /************************************************************************
2 * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
3 * Copyright (C) 2001-2003 Optical Access
6 * This file is part of RSTP library.
8 * RSTP library is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by the
10 * Free Software Foundation; version 2.1
12 * RSTP library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
15 * General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with RSTP library; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 **********************************************************************/
23 /* This file contains system dependent API
24 from the RStp to a operation system (see stp_to.h) */
26 /* stp_to API for Linux */
39 extern BITMAP_T enabled_ports
;
43 stp_trace (const char *format, ...)
45 #define MAX_MSG_LEN 128
46 char msg[MAX_MSG_LEN];
49 va_start(args, format);
50 vsnprintf (msg, MAX_MSG_LEN-1, format, args);
57 #ifdef STRONGLY_SPEC_802_1W
59 STP_OUT_set_learning (int port_index
, int vlan_id
, int enable
)
65 STP_OUT_set_forwarding (int port_index
, int vlan_id
, int enable
)
71 * In many kinds of hardware the state of ports may
72 * be changed with another method
75 STP_OUT_set_port_state (IN
int port_index
, IN
int vlan_id
,
76 IN RSTP_PORT_STATE state
)
79 //return AR_INT_STP_set_port_state (port_index, vlan_id, state);
85 STP_OUT_get_port_mac (int port_index
, unsigned char *mac
)
88 static unsigned char mac_beg
[] = {'\0', '\0', '\0', '\0', '\0', '\0'};
92 memcpy (mac_beg
+ 1, &pid
, 4);
94 memcpy (mac
, mac_beg
, 5);
96 //memcpy (mac, STP_MAIN_get_port_mac (port_index), 6);
99 int /* 1- Up, 0- Down */
100 STP_OUT_get_port_link_status (int port_index
)
102 if (BitmapGetBit (&enabled_ports
, (port_index
- 1))) return 1;
107 STP_OUT_flush_lt (IN
int port_index
, IN
int vlan_id
, LT_FLASH_TYPE_T type
, char* reason
)
110 stp_trace("clearFDB (%d, %s, '%s')",
112 (type == LT_FLASH_ALL_PORTS_EXCLUDE_THIS) ? "Exclude" : "Only",
120 STP_OUT_set_hardware_mode (int vlan_id
, UID_STP_MODE_T mode
)
123 //return AR_INT_STP_set_mode (vlan_id, mode);
128 STP_OUT_tx_bpdu (int port_index
, int vlan_id
,
129 unsigned char *bpdu
, size_t bpdu_len
)
131 extern int bridge_tx_bpdu (int port_index
, unsigned char *bpdu
, size_t bpdu_len
);
132 return bridge_tx_bpdu (port_index
, bpdu
, bpdu_len
);
136 STP_OUT_get_port_name (IN
int port_index
)
139 sprintf (tmp
, "p%02d", (int) port_index
);
141 //return port2str (port_index, &sys_config);
145 STP_OUT_get_deafult_port_path_cost (IN
unsigned int portNo
)
150 unsigned long STP_OUT_get_port_oper_speed (unsigned int portNo
)
158 int /* 1- Full, 0- Half */
159 STP_OUT_get_duplex (IN
int port_index
)
165 STP_OUT_get_init_stpm_cfg (IN
int vlan_id
,
166 INOUT UID_STP_CFG_T
* cfg
)
168 cfg
->bridge_priority
= DEF_BR_PRIO
;
169 cfg
->max_age
= DEF_BR_MAXAGE
;
170 cfg
->hello_time
= DEF_BR_HELLOT
;
171 cfg
->forward_delay
= DEF_BR_FWDELAY
;
172 cfg
->force_version
= NORMAL_RSTP
;
179 STP_OUT_get_init_port_cfg (IN
int vlan_id
,
181 INOUT UID_STP_PORT_CFG_T
* cfg
)
183 cfg
->port_priority
= DEF_PORT_PRIO
;
184 cfg
->admin_non_stp
= DEF_ADMIN_NON_STP
;
185 cfg
->admin_edge
= DEF_ADMIN_EDGE
;
186 cfg
->admin_port_path_cost
= ADMIN_PORT_PATH_COST_AUTO
;
187 cfg
->admin_point2point
= DEF_P2P
;