]> git.ipfire.org Git - people/ms/rstp.git/blame - rstplib/stp_to.c
remove ifdef'd code
[people/ms/rstp.git] / rstplib / stp_to.c
CommitLineData
ad02a0eb
SH
1/************************************************************************
2 * RSTP library - Rapid Spanning Tree (802.1t, 802.1w)
3 * Copyright (C) 2001-2003 Optical Access
4 * Author: Alex Rozin
5 *
6 * This file is part of RSTP library.
7 *
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
11 *
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.
16 *
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
20 * 02111-1307, USA.
21 **********************************************************************/
22
23/* This file contains system dependent API
24 from the RStp to a operation system (see stp_to.h) */
25
26/* stp_to API for Linux */
27
28#include <stddef.h>
29#include <stdio.h>
30#include <stdarg.h>
31#include <time.h>
32#include <unistd.h>
33
34#include "base.h"
35#include "stpm.h"
36#include "stp_in.h"
37#include "stp_to.h"
38
39extern BITMAP_T enabled_ports;
40
41/*************
42void
43stp_trace (const char *format, ...)
44{
45 #define MAX_MSG_LEN 128
46 char msg[MAX_MSG_LEN];
47 va_list args;
48
49 va_start(args, format);
50 vsnprintf (msg, MAX_MSG_LEN-1, format, args);
51 printf ("%s\n", msg);
52 va_end(args);
53
54}
55***********/
56
57#ifdef STRONGLY_SPEC_802_1W
58int
59STP_OUT_set_learning (int port_index, int vlan_id, int enable)
60{
61 return STP_OK;
62}
63
64int
65STP_OUT_set_forwarding (int port_index, int vlan_id, int enable)
66{
67 return STP_OK;
68}
69#else
70/*
71 * In many kinds of hardware the state of ports may
72 * be changed with another method
73 */
74int
75STP_OUT_set_port_state (IN int port_index, IN int vlan_id,
76 IN RSTP_PORT_STATE state)
77{
78 return STP_OK;
79 //return AR_INT_STP_set_port_state (port_index, vlan_id, state);
80}
81#endif
82
83
84void
85STP_OUT_get_port_mac (int port_index, unsigned char *mac)
86{
87 static long pid = -1;
88 static unsigned char mac_beg[] = {'\0', '\0', '\0', '\0', '\0', '\0'};
89
90 if (pid < 0) {
91 pid = getpid ();
92 memcpy (mac_beg + 1, &pid, 4);
93 }
94 memcpy (mac, mac_beg, 5);
95 mac[5] = port_index;
96 //memcpy (mac, STP_MAIN_get_port_mac (port_index), 6);
97}
98
99int /* 1- Up, 0- Down */
100STP_OUT_get_port_link_status (int port_index)
101{
102 if (BitmapGetBit (&enabled_ports, (port_index - 1))) return 1;
103 return 0;
104}
105
106int
107STP_OUT_flush_lt (IN int port_index, IN int vlan_id, LT_FLASH_TYPE_T type, char* reason)
108{
109/****
110 stp_trace("clearFDB (%d, %s, '%s')",
111 port_index,
112 (type == LT_FLASH_ALL_PORTS_EXCLUDE_THIS) ? "Exclude" : "Only",
113 reason);
114****/
115
116 return STP_OK;
117}
118
119int
120STP_OUT_set_hardware_mode (int vlan_id, UID_STP_MODE_T mode)
121{
122 return STP_OK;
123 //return AR_INT_STP_set_mode (vlan_id, mode);
124}
125
126
127int
128STP_OUT_tx_bpdu (int port_index, int vlan_id,
129 unsigned char *bpdu, size_t bpdu_len)
130{
131extern int bridge_tx_bpdu (int port_index, unsigned char *bpdu, size_t bpdu_len);
132 return bridge_tx_bpdu (port_index, bpdu, bpdu_len);
133}
134
135const char *
136STP_OUT_get_port_name (IN int port_index)
137{
138 static char tmp[4];
139 sprintf (tmp, "p%02d", (int) port_index);
140 return tmp;
141 //return port2str (port_index, &sys_config);
142}
143
144unsigned long
145STP_OUT_get_deafult_port_path_cost (IN unsigned int portNo)
146{
147 return 20000;
148}
149
150unsigned long STP_OUT_get_port_oper_speed (unsigned int portNo)
151{
152 if (portNo <= 2)
153 return 1000000L;
154 else
155 return 1000L;
156}
157
158int /* 1- Full, 0- Half */
159STP_OUT_get_duplex (IN int port_index)
160{
161 return 1;
162}
163
164int
165STP_OUT_get_init_stpm_cfg (IN int vlan_id,
166 INOUT UID_STP_CFG_T* cfg)
167{
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;
173
174 return STP_OK;
175}
176
177
178int
179STP_OUT_get_init_port_cfg (IN int vlan_id,
180 IN int port_index,
181 INOUT UID_STP_PORT_CFG_T* cfg)
182{
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;
188
189 return STP_OK;
190}
191
192
193