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 /* Mutual RSTP definitions */
38 # include <netinet/in.h>
46 # include "Bitmap/bitmap.h"
47 # include "Bitmap/bitmap.x"
48 # include "Ui/uid_stp.h"
52 # define IN /* consider as comments near 'input' parameters */
53 # define OUT /* consider as comments near 'output' parameters */
54 # define INOUT /* consider as comments near 'input/output' parameters */
72 #define RSTP_ERRORS { \
74 CHOOSE(STP_Cannot_Find_Vlan), \
75 CHOOSE(STP_Imlicite_Instance_Create_Failed), \
76 CHOOSE(STP_Small_Bridge_Priority), \
77 CHOOSE(STP_Large_Bridge_Priority), \
78 CHOOSE(STP_Bridge_Priority_Not_A_Multiple_Of_4096), \
79 CHOOSE(STP_Small_Hello_Time), \
80 CHOOSE(STP_Large_Hello_Time), \
81 CHOOSE(STP_Small_Max_Age), \
82 CHOOSE(STP_Large_Max_Age), \
83 CHOOSE(STP_Small_Forward_Delay), \
84 CHOOSE(STP_Large_Forward_Delay), \
85 CHOOSE(STP_Forward_Delay_And_Max_Age_Are_Inconsistent),\
86 CHOOSE(STP_Hello_Time_And_Max_Age_Are_Inconsistent), \
87 CHOOSE(STP_Small_Port_Priority), \
88 CHOOSE(STP_Large_Port_Priority), \
89 CHOOSE(STP_Port_Priority_Not_A_Multiple_Of_16), \
90 CHOOSE(STP_Large_Port_PCost), \
91 CHOOSE(STP_Vlan_Had_Not_Yet_Been_Created), \
92 CHOOSE(STP_Port_Is_Absent_In_The_Vlan), \
93 CHOOSE(STP_Big_len8023_Format), \
94 CHOOSE(STP_Small_len8023_Format), \
95 CHOOSE(STP_len8023_Format_Gt_Len), \
96 CHOOSE(STP_Not_Proper_802_3_Packet), \
97 CHOOSE(STP_Invalid_Protocol), \
98 CHOOSE(STP_Invalid_Version), \
99 CHOOSE(STP_Had_Not_Yet_Been_Enabled_On_The_Vlan), \
100 CHOOSE(STP_Cannot_Create_Instance_For_Vlan), \
101 CHOOSE(STP_Cannot_Create_Instance_For_Port), \
102 CHOOSE(STP_Invalid_Bridge_Priority), \
103 CHOOSE(STP_There_Are_No_Ports), \
104 CHOOSE(STP_Cannot_Compute_Bridge_Prio), \
105 CHOOSE(STP_Another_Error), \
106 CHOOSE(STP_Nothing_To_Do), \
107 CHOOSE(STP_LAST_DUMMY), \
111 typedef enum RSTP_ERRORS RSTP_ERRORS_T
;
115 extern char* strdup (const char *s
);
117 extern USHORT
Ntohs (USHORT n
);
118 extern ULONG
Htonl (ULONG h
);
119 extern USHORT
Htons (USHORT h
);
120 extern ULONG
Ntohl (ULONG n
);
130 #define STP_FATAL(TXT, MSG, EXCOD) \
131 {stp_trace ("FATAL:%s failed: %s:%d", TXT, MSG, EXCOD); \
134 #define STP_FATAL(TXT, MSG, EXCOD) \
135 Print ("FATAL: %s code %s:%d\n", TXT, MSG, EXCOD)
138 #define STP_MALLOC(PTR, TYPE, MSG) \
140 PTR = (TYPE*) calloc (1, sizeof (TYPE)); \
142 STP_FATAL("malloc", MSG, -6); \
146 #define STP_FREE(PTR, MSG) \
149 STP_FATAL("free", MSG, -66); \
155 #define STP_STRDUP(PTR, SRC, MSG) \
157 PTR = strdup (SRC); \
159 STP_FATAL("strdup", MSG, -7); \
163 #define STP_NEW_IN_LIST(WHAT, TYPE, LIST, MSG) \
165 STP_MALLOC(WHAT, TYPE, MSG); \
178 RSTP_EVENT_LAST_DUMMY
182 /* for debug trace messages */
184 #ifdef __LINUX__USE_PRINTF_FOR_STRACE
185 extern char* sprint_time_stump (void);
186 #define stp_trace(F, B...) printf("%s:" F "\n", sprint_time_stump(), ##B)
188 extern void stp_trace (const char* fmt
, ...);
191 #endif /* _STP_BASE_H__ */