diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/net/skfp/pmf.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/net/skfp/pmf.c')
-rw-r--r-- | drivers/net/skfp/pmf.c | 1671 |
1 files changed, 1671 insertions, 0 deletions
diff --git a/drivers/net/skfp/pmf.c b/drivers/net/skfp/pmf.c new file mode 100644 index 000000000000..f2b446d8b0bf --- /dev/null +++ b/drivers/net/skfp/pmf.c | |||
@@ -0,0 +1,1671 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * (C)Copyright 1998,1999 SysKonnect, | ||
4 | * a business unit of Schneider & Koch & Co. Datensysteme GmbH. | ||
5 | * | ||
6 | * See the file "skfddi.c" for further information. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * The information in this file is provided "AS IS" without warranty. | ||
14 | * | ||
15 | ******************************************************************************/ | ||
16 | |||
17 | /* | ||
18 | Parameter Management Frame processing for SMT 7.2 | ||
19 | */ | ||
20 | |||
21 | #include "h/types.h" | ||
22 | #include "h/fddi.h" | ||
23 | #include "h/smc.h" | ||
24 | #include "h/smt_p.h" | ||
25 | |||
26 | #define KERNEL | ||
27 | #include "h/smtstate.h" | ||
28 | |||
29 | #ifndef SLIM_SMT | ||
30 | |||
31 | #ifndef lint | ||
32 | static const char ID_sccs[] = "@(#)pmf.c 1.37 97/08/04 (C) SK " ; | ||
33 | #endif | ||
34 | |||
35 | static int smt_authorize(struct s_smc *smc, struct smt_header *sm); | ||
36 | static int smt_check_set_count(struct s_smc *smc, struct smt_header *sm); | ||
37 | static const struct s_p_tab* smt_get_ptab(u_short para); | ||
38 | static int smt_mib_phys(struct s_smc *smc); | ||
39 | int smt_set_para(struct s_smc *smc, struct smt_para *pa, int index, int local, | ||
40 | int set); | ||
41 | void smt_add_para(struct s_smc *smc, struct s_pcon *pcon, u_short para, | ||
42 | int index, int local); | ||
43 | static SMbuf *smt_build_pmf_response(struct s_smc *smc, struct smt_header *req, | ||
44 | int set, int local); | ||
45 | |||
46 | #define MOFFSS(e) ((int)&(((struct fddi_mib *)0)->e)) | ||
47 | #define MOFFSA(e) ((int) (((struct fddi_mib *)0)->e)) | ||
48 | |||
49 | #define MOFFMS(e) ((int)&(((struct fddi_mib_m *)0)->e)) | ||
50 | #define MOFFMA(e) ((int) (((struct fddi_mib_m *)0)->e)) | ||
51 | |||
52 | #define MOFFAS(e) ((int)&(((struct fddi_mib_a *)0)->e)) | ||
53 | #define MOFFAA(e) ((int) (((struct fddi_mib_a *)0)->e)) | ||
54 | |||
55 | #define MOFFPS(e) ((int)&(((struct fddi_mib_p *)0)->e)) | ||
56 | #define MOFFPA(e) ((int) (((struct fddi_mib_p *)0)->e)) | ||
57 | |||
58 | |||
59 | #define AC_G 0x01 /* Get */ | ||
60 | #define AC_GR 0x02 /* Get/Set */ | ||
61 | #define AC_S 0x04 /* Set */ | ||
62 | #define AC_NA 0x08 | ||
63 | #define AC_GROUP 0x10 /* Group */ | ||
64 | #define MS2BCLK(x) ((x)*12500L) | ||
65 | /* | ||
66 | F LFag (byte) | ||
67 | B byte | ||
68 | S u_short 16 bit | ||
69 | C Counter 32 bit | ||
70 | L Long 32 bit | ||
71 | T Timer_2 32 bit | ||
72 | P TimeStamp ; | ||
73 | A LongAddress (6 byte) | ||
74 | E Enum 16 bit | ||
75 | R ResId 16 Bit | ||
76 | */ | ||
77 | static const struct s_p_tab { | ||
78 | u_short p_num ; /* parameter code */ | ||
79 | u_char p_access ; /* access rights */ | ||
80 | u_short p_offset ; /* offset in mib */ | ||
81 | char p_swap[3] ; /* format string */ | ||
82 | } p_tab[] = { | ||
83 | /* StationIdGrp */ | ||
84 | { SMT_P100A,AC_GROUP } , | ||
85 | { SMT_P100B,AC_G, MOFFSS(fddiSMTStationId), "8" } , | ||
86 | { SMT_P100D,AC_G, MOFFSS(fddiSMTOpVersionId), "S" } , | ||
87 | { SMT_P100E,AC_G, MOFFSS(fddiSMTHiVersionId), "S" } , | ||
88 | { SMT_P100F,AC_G, MOFFSS(fddiSMTLoVersionId), "S" } , | ||
89 | { SMT_P1010,AC_G, MOFFSA(fddiSMTManufacturerData), "D" } , | ||
90 | { SMT_P1011,AC_GR, MOFFSA(fddiSMTUserData), "D" } , | ||
91 | { SMT_P1012,AC_G, MOFFSS(fddiSMTMIBVersionId), "S" } , | ||
92 | |||
93 | /* StationConfigGrp */ | ||
94 | { SMT_P1014,AC_GROUP } , | ||
95 | { SMT_P1015,AC_G, MOFFSS(fddiSMTMac_Ct), "B" } , | ||
96 | { SMT_P1016,AC_G, MOFFSS(fddiSMTNonMaster_Ct), "B" } , | ||
97 | { SMT_P1017,AC_G, MOFFSS(fddiSMTMaster_Ct), "B" } , | ||
98 | { SMT_P1018,AC_G, MOFFSS(fddiSMTAvailablePaths), "B" } , | ||
99 | { SMT_P1019,AC_G, MOFFSS(fddiSMTConfigCapabilities),"S" } , | ||
100 | { SMT_P101A,AC_GR, MOFFSS(fddiSMTConfigPolicy), "wS" } , | ||
101 | { SMT_P101B,AC_GR, MOFFSS(fddiSMTConnectionPolicy),"wS" } , | ||
102 | { SMT_P101D,AC_GR, MOFFSS(fddiSMTTT_Notify), "wS" } , | ||
103 | { SMT_P101E,AC_GR, MOFFSS(fddiSMTStatRptPolicy), "bB" } , | ||
104 | { SMT_P101F,AC_GR, MOFFSS(fddiSMTTrace_MaxExpiration),"lL" } , | ||
105 | { SMT_P1020,AC_G, MOFFSA(fddiSMTPORTIndexes), "II" } , | ||
106 | { SMT_P1021,AC_G, MOFFSS(fddiSMTMACIndexes), "I" } , | ||
107 | { SMT_P1022,AC_G, MOFFSS(fddiSMTBypassPresent), "F" } , | ||
108 | |||
109 | /* StatusGrp */ | ||
110 | { SMT_P1028,AC_GROUP } , | ||
111 | { SMT_P1029,AC_G, MOFFSS(fddiSMTECMState), "E" } , | ||
112 | { SMT_P102A,AC_G, MOFFSS(fddiSMTCF_State), "E" } , | ||
113 | { SMT_P102C,AC_G, MOFFSS(fddiSMTRemoteDisconnectFlag),"F" } , | ||
114 | { SMT_P102D,AC_G, MOFFSS(fddiSMTStationStatus), "E" } , | ||
115 | { SMT_P102E,AC_G, MOFFSS(fddiSMTPeerWrapFlag), "F" } , | ||
116 | |||
117 | /* MIBOperationGrp */ | ||
118 | { SMT_P1032,AC_GROUP } , | ||
119 | { SMT_P1033,AC_G, MOFFSA(fddiSMTTimeStamp),"P" } , | ||
120 | { SMT_P1034,AC_G, MOFFSA(fddiSMTTransitionTimeStamp),"P" } , | ||
121 | /* NOTE : SMT_P1035 is already swapped ! SMT_P_SETCOUNT */ | ||
122 | { SMT_P1035,AC_G, MOFFSS(fddiSMTSetCount),"4P" } , | ||
123 | { SMT_P1036,AC_G, MOFFSS(fddiSMTLastSetStationId),"8" } , | ||
124 | |||
125 | { SMT_P103C,AC_S, 0, "wS" } , | ||
126 | |||
127 | /* | ||
128 | * PRIVATE EXTENSIONS | ||
129 | * only accessible locally to get/set passwd | ||
130 | */ | ||
131 | { SMT_P10F0,AC_GR, MOFFSA(fddiPRPMFPasswd), "8" } , | ||
132 | { SMT_P10F1,AC_GR, MOFFSS(fddiPRPMFStation), "8" } , | ||
133 | #ifdef ESS | ||
134 | { SMT_P10F2,AC_GR, MOFFSS(fddiESSPayload), "lL" } , | ||
135 | { SMT_P10F3,AC_GR, MOFFSS(fddiESSOverhead), "lL" } , | ||
136 | { SMT_P10F4,AC_GR, MOFFSS(fddiESSMaxTNeg), "lL" } , | ||
137 | { SMT_P10F5,AC_GR, MOFFSS(fddiESSMinSegmentSize), "lL" } , | ||
138 | { SMT_P10F6,AC_GR, MOFFSS(fddiESSCategory), "lL" } , | ||
139 | { SMT_P10F7,AC_GR, MOFFSS(fddiESSSynchTxMode), "wS" } , | ||
140 | #endif | ||
141 | #ifdef SBA | ||
142 | { SMT_P10F8,AC_GR, MOFFSS(fddiSBACommand), "bF" } , | ||
143 | { SMT_P10F9,AC_GR, MOFFSS(fddiSBAAvailable), "bF" } , | ||
144 | #endif | ||
145 | /* MAC Attributes */ | ||
146 | { SMT_P200A,AC_GROUP } , | ||
147 | { SMT_P200B,AC_G, MOFFMS(fddiMACFrameStatusFunctions),"S" } , | ||
148 | { SMT_P200D,AC_G, MOFFMS(fddiMACT_MaxCapabilitiy),"T" } , | ||
149 | { SMT_P200E,AC_G, MOFFMS(fddiMACTVXCapabilitiy),"T" } , | ||
150 | |||
151 | /* ConfigGrp */ | ||
152 | { SMT_P2014,AC_GROUP } , | ||
153 | { SMT_P2016,AC_G, MOFFMS(fddiMACAvailablePaths), "B" } , | ||
154 | { SMT_P2017,AC_G, MOFFMS(fddiMACCurrentPath), "S" } , | ||
155 | { SMT_P2018,AC_G, MOFFMS(fddiMACUpstreamNbr), "A" } , | ||
156 | { SMT_P2019,AC_G, MOFFMS(fddiMACDownstreamNbr), "A" } , | ||
157 | { SMT_P201A,AC_G, MOFFMS(fddiMACOldUpstreamNbr), "A" } , | ||
158 | { SMT_P201B,AC_G, MOFFMS(fddiMACOldDownstreamNbr),"A" } , | ||
159 | { SMT_P201D,AC_G, MOFFMS(fddiMACDupAddressTest), "E" } , | ||
160 | { SMT_P2020,AC_GR, MOFFMS(fddiMACRequestedPaths), "wS" } , | ||
161 | { SMT_P2021,AC_G, MOFFMS(fddiMACDownstreamPORTType),"E" } , | ||
162 | { SMT_P2022,AC_G, MOFFMS(fddiMACIndex), "S" } , | ||
163 | |||
164 | /* AddressGrp */ | ||
165 | { SMT_P2028,AC_GROUP } , | ||
166 | { SMT_P2029,AC_G, MOFFMS(fddiMACSMTAddress), "A" } , | ||
167 | |||
168 | /* OperationGrp */ | ||
169 | { SMT_P2032,AC_GROUP } , | ||
170 | { SMT_P2033,AC_G, MOFFMS(fddiMACT_Req), "T" } , | ||
171 | { SMT_P2034,AC_G, MOFFMS(fddiMACT_Neg), "T" } , | ||
172 | { SMT_P2035,AC_G, MOFFMS(fddiMACT_Max), "T" } , | ||
173 | { SMT_P2036,AC_G, MOFFMS(fddiMACTvxValue), "T" } , | ||
174 | { SMT_P2038,AC_G, MOFFMS(fddiMACT_Pri0), "T" } , | ||
175 | { SMT_P2039,AC_G, MOFFMS(fddiMACT_Pri1), "T" } , | ||
176 | { SMT_P203A,AC_G, MOFFMS(fddiMACT_Pri2), "T" } , | ||
177 | { SMT_P203B,AC_G, MOFFMS(fddiMACT_Pri3), "T" } , | ||
178 | { SMT_P203C,AC_G, MOFFMS(fddiMACT_Pri4), "T" } , | ||
179 | { SMT_P203D,AC_G, MOFFMS(fddiMACT_Pri5), "T" } , | ||
180 | { SMT_P203E,AC_G, MOFFMS(fddiMACT_Pri6), "T" } , | ||
181 | |||
182 | |||
183 | /* CountersGrp */ | ||
184 | { SMT_P2046,AC_GROUP } , | ||
185 | { SMT_P2047,AC_G, MOFFMS(fddiMACFrame_Ct), "C" } , | ||
186 | { SMT_P2048,AC_G, MOFFMS(fddiMACCopied_Ct), "C" } , | ||
187 | { SMT_P2049,AC_G, MOFFMS(fddiMACTransmit_Ct), "C" } , | ||
188 | { SMT_P204A,AC_G, MOFFMS(fddiMACToken_Ct), "C" } , | ||
189 | { SMT_P2051,AC_G, MOFFMS(fddiMACError_Ct), "C" } , | ||
190 | { SMT_P2052,AC_G, MOFFMS(fddiMACLost_Ct), "C" } , | ||
191 | { SMT_P2053,AC_G, MOFFMS(fddiMACTvxExpired_Ct), "C" } , | ||
192 | { SMT_P2054,AC_G, MOFFMS(fddiMACNotCopied_Ct), "C" } , | ||
193 | { SMT_P2056,AC_G, MOFFMS(fddiMACRingOp_Ct), "C" } , | ||
194 | |||
195 | /* FrameErrorConditionGrp */ | ||
196 | { SMT_P205A,AC_GROUP } , | ||
197 | { SMT_P205F,AC_GR, MOFFMS(fddiMACFrameErrorThreshold),"wS" } , | ||
198 | { SMT_P2060,AC_G, MOFFMS(fddiMACFrameErrorRatio), "S" } , | ||
199 | |||
200 | /* NotCopiedConditionGrp */ | ||
201 | { SMT_P2064,AC_GROUP } , | ||
202 | { SMT_P2067,AC_GR, MOFFMS(fddiMACNotCopiedThreshold),"wS" } , | ||
203 | { SMT_P2069,AC_G, MOFFMS(fddiMACNotCopiedRatio), "S" } , | ||
204 | |||
205 | /* StatusGrp */ | ||
206 | { SMT_P206E,AC_GROUP } , | ||
207 | { SMT_P206F,AC_G, MOFFMS(fddiMACRMTState), "S" } , | ||
208 | { SMT_P2070,AC_G, MOFFMS(fddiMACDA_Flag), "F" } , | ||
209 | { SMT_P2071,AC_G, MOFFMS(fddiMACUNDA_Flag), "F" } , | ||
210 | { SMT_P2072,AC_G, MOFFMS(fddiMACFrameErrorFlag), "F" } , | ||
211 | { SMT_P2073,AC_G, MOFFMS(fddiMACNotCopiedFlag), "F" } , | ||
212 | { SMT_P2074,AC_G, MOFFMS(fddiMACMA_UnitdataAvailable),"F" } , | ||
213 | { SMT_P2075,AC_G, MOFFMS(fddiMACHardwarePresent), "F" } , | ||
214 | { SMT_P2076,AC_GR, MOFFMS(fddiMACMA_UnitdataEnable),"bF" } , | ||
215 | |||
216 | /* | ||
217 | * PRIVATE EXTENSIONS | ||
218 | * only accessible locally to get/set TMIN | ||
219 | */ | ||
220 | { SMT_P20F0,AC_NA } , | ||
221 | { SMT_P20F1,AC_GR, MOFFMS(fddiMACT_Min), "lT" } , | ||
222 | |||
223 | /* Path Attributes */ | ||
224 | /* | ||
225 | * DON't swap 320B,320F,3210: they are already swapped in swap_para() | ||
226 | */ | ||
227 | { SMT_P320A,AC_GROUP } , | ||
228 | { SMT_P320B,AC_G, MOFFAS(fddiPATHIndex), "r" } , | ||
229 | { SMT_P320F,AC_GR, MOFFAS(fddiPATHSbaPayload), "l4" } , | ||
230 | { SMT_P3210,AC_GR, MOFFAS(fddiPATHSbaOverhead), "l4" } , | ||
231 | /* fddiPATHConfiguration */ | ||
232 | { SMT_P3212,AC_G, 0, "" } , | ||
233 | { SMT_P3213,AC_GR, MOFFAS(fddiPATHT_Rmode), "lT" } , | ||
234 | { SMT_P3214,AC_GR, MOFFAS(fddiPATHSbaAvailable), "lL" } , | ||
235 | { SMT_P3215,AC_GR, MOFFAS(fddiPATHTVXLowerBound), "lT" } , | ||
236 | { SMT_P3216,AC_GR, MOFFAS(fddiPATHT_MaxLowerBound),"lT" } , | ||
237 | { SMT_P3217,AC_GR, MOFFAS(fddiPATHMaxT_Req), "lT" } , | ||
238 | |||
239 | /* Port Attributes */ | ||
240 | /* ConfigGrp */ | ||
241 | { SMT_P400A,AC_GROUP } , | ||
242 | { SMT_P400C,AC_G, MOFFPS(fddiPORTMy_Type), "E" } , | ||
243 | { SMT_P400D,AC_G, MOFFPS(fddiPORTNeighborType), "E" } , | ||
244 | { SMT_P400E,AC_GR, MOFFPS(fddiPORTConnectionPolicies),"bB" } , | ||
245 | { SMT_P400F,AC_G, MOFFPS(fddiPORTMacIndicated), "2" } , | ||
246 | { SMT_P4010,AC_G, MOFFPS(fddiPORTCurrentPath), "E" } , | ||
247 | { SMT_P4011,AC_GR, MOFFPA(fddiPORTRequestedPaths), "l4" } , | ||
248 | { SMT_P4012,AC_G, MOFFPS(fddiPORTMACPlacement), "S" } , | ||
249 | { SMT_P4013,AC_G, MOFFPS(fddiPORTAvailablePaths), "B" } , | ||
250 | { SMT_P4016,AC_G, MOFFPS(fddiPORTPMDClass), "E" } , | ||
251 | { SMT_P4017,AC_G, MOFFPS(fddiPORTConnectionCapabilities), "B"} , | ||
252 | { SMT_P401D,AC_G, MOFFPS(fddiPORTIndex), "R" } , | ||
253 | |||
254 | /* OperationGrp */ | ||
255 | { SMT_P401E,AC_GROUP } , | ||
256 | { SMT_P401F,AC_GR, MOFFPS(fddiPORTMaint_LS), "wE" } , | ||
257 | { SMT_P4021,AC_G, MOFFPS(fddiPORTBS_Flag), "F" } , | ||
258 | { SMT_P4022,AC_G, MOFFPS(fddiPORTPC_LS), "E" } , | ||
259 | |||
260 | /* ErrorCtrsGrp */ | ||
261 | { SMT_P4028,AC_GROUP } , | ||
262 | { SMT_P4029,AC_G, MOFFPS(fddiPORTEBError_Ct), "C" } , | ||
263 | { SMT_P402A,AC_G, MOFFPS(fddiPORTLCTFail_Ct), "C" } , | ||
264 | |||
265 | /* LerGrp */ | ||
266 | { SMT_P4032,AC_GROUP } , | ||
267 | { SMT_P4033,AC_G, MOFFPS(fddiPORTLer_Estimate), "F" } , | ||
268 | { SMT_P4034,AC_G, MOFFPS(fddiPORTLem_Reject_Ct), "C" } , | ||
269 | { SMT_P4035,AC_G, MOFFPS(fddiPORTLem_Ct), "C" } , | ||
270 | { SMT_P403A,AC_GR, MOFFPS(fddiPORTLer_Cutoff), "bB" } , | ||
271 | { SMT_P403B,AC_GR, MOFFPS(fddiPORTLer_Alarm), "bB" } , | ||
272 | |||
273 | /* StatusGrp */ | ||
274 | { SMT_P403C,AC_GROUP } , | ||
275 | { SMT_P403D,AC_G, MOFFPS(fddiPORTConnectState), "E" } , | ||
276 | { SMT_P403E,AC_G, MOFFPS(fddiPORTPCMStateX), "E" } , | ||
277 | { SMT_P403F,AC_G, MOFFPS(fddiPORTPC_Withhold), "E" } , | ||
278 | { SMT_P4040,AC_G, MOFFPS(fddiPORTLerFlag), "F" } , | ||
279 | { SMT_P4041,AC_G, MOFFPS(fddiPORTHardwarePresent),"F" } , | ||
280 | |||
281 | { SMT_P4046,AC_S, 0, "wS" } , | ||
282 | |||
283 | { 0, AC_GROUP } , | ||
284 | { 0 } | ||
285 | } ; | ||
286 | |||
287 | void smt_pmf_received_pack(struct s_smc *smc, SMbuf *mb, int local) | ||
288 | { | ||
289 | struct smt_header *sm ; | ||
290 | SMbuf *reply ; | ||
291 | |||
292 | sm = smtod(mb,struct smt_header *) ; | ||
293 | DB_SMT("SMT: processing PMF frame at %x len %d\n",sm,mb->sm_len) ; | ||
294 | #ifdef DEBUG | ||
295 | dump_smt(smc,sm,"PMF Received") ; | ||
296 | #endif | ||
297 | /* | ||
298 | * Start the watchdog: It may be a long, long packet and | ||
299 | * maybe the watchdog occurs ... | ||
300 | */ | ||
301 | smt_start_watchdog(smc) ; | ||
302 | |||
303 | if (sm->smt_class == SMT_PMF_GET || | ||
304 | sm->smt_class == SMT_PMF_SET) { | ||
305 | reply = smt_build_pmf_response(smc,sm, | ||
306 | sm->smt_class == SMT_PMF_SET,local) ; | ||
307 | if (reply) { | ||
308 | sm = smtod(reply,struct smt_header *) ; | ||
309 | #ifdef DEBUG | ||
310 | dump_smt(smc,sm,"PMF Reply") ; | ||
311 | #endif | ||
312 | smt_send_frame(smc,reply,FC_SMT_INFO,local) ; | ||
313 | } | ||
314 | } | ||
315 | } | ||
316 | |||
317 | static SMbuf *smt_build_pmf_response(struct s_smc *smc, struct smt_header *req, | ||
318 | int set, int local) | ||
319 | { | ||
320 | SMbuf *mb ; | ||
321 | struct smt_header *smt ; | ||
322 | struct smt_para *pa ; | ||
323 | struct smt_p_reason *res ; | ||
324 | const struct s_p_tab *pt ; | ||
325 | int len ; | ||
326 | int index ; | ||
327 | int idx_end ; | ||
328 | int error ; | ||
329 | int range ; | ||
330 | SK_LOC_DECL(struct s_pcon,pcon) ; | ||
331 | SK_LOC_DECL(struct s_pcon,set_pcon) ; | ||
332 | |||
333 | /* | ||
334 | * build SMT header | ||
335 | */ | ||
336 | if (!(mb = smt_get_mbuf(smc))) | ||
337 | return(mb) ; | ||
338 | |||
339 | smt = smtod(mb, struct smt_header *) ; | ||
340 | smt->smt_dest = req->smt_source ; /* DA == source of request */ | ||
341 | smt->smt_class = req->smt_class ; /* same class (GET/SET) */ | ||
342 | smt->smt_type = SMT_REPLY ; | ||
343 | smt->smt_version = SMT_VID_2 ; | ||
344 | smt->smt_tid = req->smt_tid ; /* same TID */ | ||
345 | smt->smt_pad = 0 ; | ||
346 | smt->smt_len = 0 ; | ||
347 | |||
348 | /* | ||
349 | * setup parameter status | ||
350 | */ | ||
351 | pcon.pc_len = SMT_MAX_INFO_LEN ; /* max para length */ | ||
352 | pcon.pc_err = 0 ; /* no error */ | ||
353 | pcon.pc_badset = 0 ; /* no bad set count */ | ||
354 | pcon.pc_p = (void *) (smt + 1) ; /* paras start here */ | ||
355 | |||
356 | /* | ||
357 | * check authoriziation and set count | ||
358 | */ | ||
359 | error = 0 ; | ||
360 | if (set) { | ||
361 | if (!local && smt_authorize(smc,req)) | ||
362 | error = SMT_RDF_AUTHOR ; | ||
363 | else if (smt_check_set_count(smc,req)) | ||
364 | pcon.pc_badset = SMT_RDF_BADSET ; | ||
365 | } | ||
366 | /* | ||
367 | * add reason code and all mandatory parameters | ||
368 | */ | ||
369 | res = (struct smt_p_reason *) pcon.pc_p ; | ||
370 | smt_add_para(smc,&pcon,(u_short) SMT_P_REASON,0,0) ; | ||
371 | smt_add_para(smc,&pcon,(u_short) SMT_P1033,0,0) ; | ||
372 | /* update 1035 and 1036 later if set */ | ||
373 | set_pcon = pcon ; | ||
374 | smt_add_para(smc,&pcon,(u_short) SMT_P1035,0,0) ; | ||
375 | smt_add_para(smc,&pcon,(u_short) SMT_P1036,0,0) ; | ||
376 | |||
377 | pcon.pc_err = error ; | ||
378 | len = req->smt_len ; | ||
379 | pa = (struct smt_para *) (req + 1) ; | ||
380 | /* | ||
381 | * process list of paras | ||
382 | */ | ||
383 | while (!pcon.pc_err && len > 0 ) { | ||
384 | if (((u_short)len < pa->p_len + PARA_LEN) || (pa->p_len & 3)) { | ||
385 | pcon.pc_err = SMT_RDF_LENGTH ; | ||
386 | break ; | ||
387 | } | ||
388 | |||
389 | if (((range = (pa->p_type & 0xf000)) == 0x2000) || | ||
390 | range == 0x3000 || range == 0x4000) { | ||
391 | /* | ||
392 | * get index for PART,MAC ad PATH group | ||
393 | */ | ||
394 | index = *((u_char *)pa + PARA_LEN + 3) ;/* index */ | ||
395 | idx_end = index ; | ||
396 | if (!set && (pa->p_len != 4)) { | ||
397 | pcon.pc_err = SMT_RDF_LENGTH ; | ||
398 | break ; | ||
399 | } | ||
400 | if (!index && !set) { | ||
401 | switch (range) { | ||
402 | case 0x2000 : | ||
403 | index = INDEX_MAC ; | ||
404 | idx_end = index - 1 + NUMMACS ; | ||
405 | break ; | ||
406 | case 0x3000 : | ||
407 | index = INDEX_PATH ; | ||
408 | idx_end = index - 1 + NUMPATHS ; | ||
409 | break ; | ||
410 | case 0x4000 : | ||
411 | index = INDEX_PORT ; | ||
412 | idx_end = index - 1 + NUMPHYS ; | ||
413 | #ifndef CONCENTRATOR | ||
414 | if (smc->s.sas == SMT_SAS) | ||
415 | idx_end = INDEX_PORT ; | ||
416 | #endif | ||
417 | break ; | ||
418 | } | ||
419 | } | ||
420 | } | ||
421 | else { | ||
422 | /* | ||
423 | * smt group has no index | ||
424 | */ | ||
425 | if (!set && (pa->p_len != 0)) { | ||
426 | pcon.pc_err = SMT_RDF_LENGTH ; | ||
427 | break ; | ||
428 | } | ||
429 | index = 0 ; | ||
430 | idx_end = 0 ; | ||
431 | } | ||
432 | while (index <= idx_end) { | ||
433 | /* | ||
434 | * if group | ||
435 | * add all paras of group | ||
436 | */ | ||
437 | pt = smt_get_ptab(pa->p_type) ; | ||
438 | if (pt && pt->p_access == AC_GROUP && !set) { | ||
439 | pt++ ; | ||
440 | while (pt->p_access == AC_G || | ||
441 | pt->p_access == AC_GR) { | ||
442 | smt_add_para(smc,&pcon,pt->p_num, | ||
443 | index,local); | ||
444 | pt++ ; | ||
445 | } | ||
446 | } | ||
447 | /* | ||
448 | * ignore | ||
449 | * AUTHORIZATION in get/set | ||
450 | * SET COUNT in set | ||
451 | */ | ||
452 | else if (pa->p_type != SMT_P_AUTHOR && | ||
453 | (!set || (pa->p_type != SMT_P1035))) { | ||
454 | int st ; | ||
455 | if (pcon.pc_badset) { | ||
456 | smt_add_para(smc,&pcon,pa->p_type, | ||
457 | index,local) ; | ||
458 | } | ||
459 | else if (set) { | ||
460 | st = smt_set_para(smc,pa,index,local,1); | ||
461 | /* | ||
462 | * return para even if error | ||
463 | */ | ||
464 | smt_add_para(smc,&pcon,pa->p_type, | ||
465 | index,local) ; | ||
466 | pcon.pc_err = st ; | ||
467 | } | ||
468 | else { | ||
469 | if (pt && pt->p_access == AC_S) { | ||
470 | pcon.pc_err = | ||
471 | SMT_RDF_ILLEGAL ; | ||
472 | } | ||
473 | smt_add_para(smc,&pcon,pa->p_type, | ||
474 | index,local) ; | ||
475 | } | ||
476 | } | ||
477 | if (pcon.pc_err) | ||
478 | break ; | ||
479 | index++ ; | ||
480 | } | ||
481 | len -= pa->p_len + PARA_LEN ; | ||
482 | pa = (struct smt_para *) ((char *)pa + pa->p_len + PARA_LEN) ; | ||
483 | } | ||
484 | smt->smt_len = SMT_MAX_INFO_LEN - pcon.pc_len ; | ||
485 | mb->sm_len = smt->smt_len + sizeof(struct smt_header) ; | ||
486 | |||
487 | /* update reason code */ | ||
488 | res->rdf_reason = pcon.pc_badset ? pcon.pc_badset : | ||
489 | pcon.pc_err ? pcon.pc_err : SMT_RDF_SUCCESS ; | ||
490 | if (set && (res->rdf_reason == SMT_RDF_SUCCESS)) { | ||
491 | /* | ||
492 | * increment set count | ||
493 | * set time stamp | ||
494 | * store station id of last set | ||
495 | */ | ||
496 | smc->mib.fddiSMTSetCount.count++ ; | ||
497 | smt_set_timestamp(smc,smc->mib.fddiSMTSetCount.timestamp) ; | ||
498 | smc->mib.fddiSMTLastSetStationId = req->smt_sid ; | ||
499 | smt_add_para(smc,&set_pcon,(u_short) SMT_P1035,0,0) ; | ||
500 | smt_add_para(smc,&set_pcon,(u_short) SMT_P1036,0,0) ; | ||
501 | } | ||
502 | return(mb) ; | ||
503 | } | ||
504 | |||
505 | static int smt_authorize(struct s_smc *smc, struct smt_header *sm) | ||
506 | { | ||
507 | struct smt_para *pa ; | ||
508 | int i ; | ||
509 | char *p ; | ||
510 | |||
511 | /* | ||
512 | * check source station id if not zero | ||
513 | */ | ||
514 | p = (char *) &smc->mib.fddiPRPMFStation ; | ||
515 | for (i = 0 ; i < 8 && !p[i] ; i++) | ||
516 | ; | ||
517 | if (i != 8) { | ||
518 | if (memcmp((char *) &sm->smt_sid, | ||
519 | (char *) &smc->mib.fddiPRPMFStation,8)) | ||
520 | return(1) ; | ||
521 | } | ||
522 | /* | ||
523 | * check authoriziation parameter if passwd not zero | ||
524 | */ | ||
525 | p = (char *) smc->mib.fddiPRPMFPasswd ; | ||
526 | for (i = 0 ; i < 8 && !p[i] ; i++) | ||
527 | ; | ||
528 | if (i != 8) { | ||
529 | pa = (struct smt_para *) sm_to_para(smc,sm,SMT_P_AUTHOR) ; | ||
530 | if (!pa) | ||
531 | return(1) ; | ||
532 | if (pa->p_len != 8) | ||
533 | return(1) ; | ||
534 | if (memcmp((char *)(pa+1),(char *)smc->mib.fddiPRPMFPasswd,8)) | ||
535 | return(1) ; | ||
536 | } | ||
537 | return(0) ; | ||
538 | } | ||
539 | |||
540 | static int smt_check_set_count(struct s_smc *smc, struct smt_header *sm) | ||
541 | { | ||
542 | struct smt_para *pa ; | ||
543 | struct smt_p_setcount *sc ; | ||
544 | |||
545 | pa = (struct smt_para *) sm_to_para(smc,sm,SMT_P1035) ; | ||
546 | if (pa) { | ||
547 | sc = (struct smt_p_setcount *) pa ; | ||
548 | if ((smc->mib.fddiSMTSetCount.count != sc->count) || | ||
549 | memcmp((char *) smc->mib.fddiSMTSetCount.timestamp, | ||
550 | (char *)sc->timestamp,8)) | ||
551 | return(1) ; | ||
552 | } | ||
553 | return(0) ; | ||
554 | } | ||
555 | |||
556 | void smt_add_para(struct s_smc *smc, struct s_pcon *pcon, u_short para, | ||
557 | int index, int local) | ||
558 | { | ||
559 | struct smt_para *pa ; | ||
560 | const struct s_p_tab *pt ; | ||
561 | struct fddi_mib_m *mib_m = NULL; | ||
562 | struct fddi_mib_p *mib_p = NULL; | ||
563 | int len ; | ||
564 | int plen ; | ||
565 | char *from ; | ||
566 | char *to ; | ||
567 | const char *swap ; | ||
568 | char c ; | ||
569 | int range ; | ||
570 | char *mib_addr ; | ||
571 | int mac ; | ||
572 | int path ; | ||
573 | int port ; | ||
574 | int sp_len ; | ||
575 | |||
576 | /* | ||
577 | * skip if errror | ||
578 | */ | ||
579 | if (pcon->pc_err) | ||
580 | return ; | ||
581 | |||
582 | /* | ||
583 | * actions don't have a value | ||
584 | */ | ||
585 | pt = smt_get_ptab(para) ; | ||
586 | if (pt && pt->p_access == AC_S) | ||
587 | return ; | ||
588 | |||
589 | to = (char *) (pcon->pc_p) ; /* destination pointer */ | ||
590 | len = pcon->pc_len ; /* free space */ | ||
591 | plen = len ; /* remember start length */ | ||
592 | pa = (struct smt_para *) to ; /* type/length pointer */ | ||
593 | to += PARA_LEN ; /* skip smt_para */ | ||
594 | len -= PARA_LEN ; | ||
595 | /* | ||
596 | * set index if required | ||
597 | */ | ||
598 | if (((range = (para & 0xf000)) == 0x2000) || | ||
599 | range == 0x3000 || range == 0x4000) { | ||
600 | if (len < 4) | ||
601 | goto wrong_error ; | ||
602 | to[0] = 0 ; | ||
603 | to[1] = 0 ; | ||
604 | to[2] = 0 ; | ||
605 | to[3] = index ; | ||
606 | len -= 4 ; | ||
607 | to += 4 ; | ||
608 | } | ||
609 | mac = index - INDEX_MAC ; | ||
610 | path = index - INDEX_PATH ; | ||
611 | port = index - INDEX_PORT ; | ||
612 | /* | ||
613 | * get pointer to mib | ||
614 | */ | ||
615 | switch (range) { | ||
616 | case 0x1000 : | ||
617 | default : | ||
618 | mib_addr = (char *) (&smc->mib) ; | ||
619 | break ; | ||
620 | case 0x2000 : | ||
621 | if (mac < 0 || mac >= NUMMACS) { | ||
622 | pcon->pc_err = SMT_RDF_NOPARAM ; | ||
623 | return ; | ||
624 | } | ||
625 | mib_addr = (char *) (&smc->mib.m[mac]) ; | ||
626 | mib_m = (struct fddi_mib_m *) mib_addr ; | ||
627 | break ; | ||
628 | case 0x3000 : | ||
629 | if (path < 0 || path >= NUMPATHS) { | ||
630 | pcon->pc_err = SMT_RDF_NOPARAM ; | ||
631 | return ; | ||
632 | } | ||
633 | mib_addr = (char *) (&smc->mib.a[path]) ; | ||
634 | break ; | ||
635 | case 0x4000 : | ||
636 | if (port < 0 || port >= smt_mib_phys(smc)) { | ||
637 | pcon->pc_err = SMT_RDF_NOPARAM ; | ||
638 | return ; | ||
639 | } | ||
640 | mib_addr = (char *) (&smc->mib.p[port_to_mib(smc,port)]) ; | ||
641 | mib_p = (struct fddi_mib_p *) mib_addr ; | ||
642 | break ; | ||
643 | } | ||
644 | /* | ||
645 | * check special paras | ||
646 | */ | ||
647 | swap = NULL; | ||
648 | switch (para) { | ||
649 | case SMT_P10F0 : | ||
650 | case SMT_P10F1 : | ||
651 | #ifdef ESS | ||
652 | case SMT_P10F2 : | ||
653 | case SMT_P10F3 : | ||
654 | case SMT_P10F4 : | ||
655 | case SMT_P10F5 : | ||
656 | case SMT_P10F6 : | ||
657 | case SMT_P10F7 : | ||
658 | #endif | ||
659 | #ifdef SBA | ||
660 | case SMT_P10F8 : | ||
661 | case SMT_P10F9 : | ||
662 | #endif | ||
663 | case SMT_P20F1 : | ||
664 | if (!local) { | ||
665 | pcon->pc_err = SMT_RDF_NOPARAM ; | ||
666 | return ; | ||
667 | } | ||
668 | break ; | ||
669 | case SMT_P2034 : | ||
670 | case SMT_P2046 : | ||
671 | case SMT_P2047 : | ||
672 | case SMT_P204A : | ||
673 | case SMT_P2051 : | ||
674 | case SMT_P2052 : | ||
675 | mac_update_counter(smc) ; | ||
676 | break ; | ||
677 | case SMT_P4022: | ||
678 | mib_p->fddiPORTPC_LS = LS2MIB( | ||
679 | sm_pm_get_ls(smc,port_to_mib(smc,port))) ; | ||
680 | break ; | ||
681 | case SMT_P_REASON : | ||
682 | * (u_long *) to = 0 ; | ||
683 | sp_len = 4 ; | ||
684 | goto sp_done ; | ||
685 | case SMT_P1033 : /* time stamp */ | ||
686 | smt_set_timestamp(smc,smc->mib.fddiSMTTimeStamp) ; | ||
687 | break ; | ||
688 | |||
689 | case SMT_P1020: /* port indexes */ | ||
690 | #if NUMPHYS == 12 | ||
691 | swap = "IIIIIIIIIIII" ; | ||
692 | #else | ||
693 | #if NUMPHYS == 2 | ||
694 | if (smc->s.sas == SMT_SAS) | ||
695 | swap = "I" ; | ||
696 | else | ||
697 | swap = "II" ; | ||
698 | #else | ||
699 | #if NUMPHYS == 24 | ||
700 | swap = "IIIIIIIIIIIIIIIIIIIIIIII" ; | ||
701 | #else | ||
702 | ???? | ||
703 | #endif | ||
704 | #endif | ||
705 | #endif | ||
706 | break ; | ||
707 | case SMT_P3212 : | ||
708 | { | ||
709 | sp_len = cem_build_path(smc,to,path) ; | ||
710 | goto sp_done ; | ||
711 | } | ||
712 | case SMT_P1048 : /* peer wrap condition */ | ||
713 | { | ||
714 | struct smt_p_1048 *sp ; | ||
715 | sp = (struct smt_p_1048 *) to ; | ||
716 | sp->p1048_flag = smc->mib.fddiSMTPeerWrapFlag ; | ||
717 | sp->p1048_cf_state = smc->mib.fddiSMTCF_State ; | ||
718 | sp_len = sizeof(struct smt_p_1048) ; | ||
719 | goto sp_done ; | ||
720 | } | ||
721 | case SMT_P208C : | ||
722 | { | ||
723 | struct smt_p_208c *sp ; | ||
724 | sp = (struct smt_p_208c *) to ; | ||
725 | sp->p208c_flag = | ||
726 | smc->mib.m[MAC0].fddiMACDuplicateAddressCond ; | ||
727 | sp->p208c_dupcondition = | ||
728 | (mib_m->fddiMACDA_Flag ? SMT_ST_MY_DUPA : 0) | | ||
729 | (mib_m->fddiMACUNDA_Flag ? SMT_ST_UNA_DUPA : 0); | ||
730 | sp->p208c_fddilong = | ||
731 | mib_m->fddiMACSMTAddress ; | ||
732 | sp->p208c_fddiunalong = | ||
733 | mib_m->fddiMACUpstreamNbr ; | ||
734 | sp->p208c_pad = 0 ; | ||
735 | sp_len = sizeof(struct smt_p_208c) ; | ||
736 | goto sp_done ; | ||
737 | } | ||
738 | case SMT_P208D : /* frame error condition */ | ||
739 | { | ||
740 | struct smt_p_208d *sp ; | ||
741 | sp = (struct smt_p_208d *) to ; | ||
742 | sp->p208d_flag = | ||
743 | mib_m->fddiMACFrameErrorFlag ; | ||
744 | sp->p208d_frame_ct = | ||
745 | mib_m->fddiMACFrame_Ct ; | ||
746 | sp->p208d_error_ct = | ||
747 | mib_m->fddiMACError_Ct ; | ||
748 | sp->p208d_lost_ct = | ||
749 | mib_m->fddiMACLost_Ct ; | ||
750 | sp->p208d_ratio = | ||
751 | mib_m->fddiMACFrameErrorRatio ; | ||
752 | sp_len = sizeof(struct smt_p_208d) ; | ||
753 | goto sp_done ; | ||
754 | } | ||
755 | case SMT_P208E : /* not copied condition */ | ||
756 | { | ||
757 | struct smt_p_208e *sp ; | ||
758 | sp = (struct smt_p_208e *) to ; | ||
759 | sp->p208e_flag = | ||
760 | mib_m->fddiMACNotCopiedFlag ; | ||
761 | sp->p208e_not_copied = | ||
762 | mib_m->fddiMACNotCopied_Ct ; | ||
763 | sp->p208e_copied = | ||
764 | mib_m->fddiMACCopied_Ct ; | ||
765 | sp->p208e_not_copied_ratio = | ||
766 | mib_m->fddiMACNotCopiedRatio ; | ||
767 | sp_len = sizeof(struct smt_p_208e) ; | ||
768 | goto sp_done ; | ||
769 | } | ||
770 | case SMT_P208F : /* neighbor change event */ | ||
771 | { | ||
772 | struct smt_p_208f *sp ; | ||
773 | sp = (struct smt_p_208f *) to ; | ||
774 | sp->p208f_multiple = | ||
775 | mib_m->fddiMACMultiple_N ; | ||
776 | sp->p208f_nacondition = | ||
777 | mib_m->fddiMACDuplicateAddressCond ; | ||
778 | sp->p208f_old_una = | ||
779 | mib_m->fddiMACOldUpstreamNbr ; | ||
780 | sp->p208f_new_una = | ||
781 | mib_m->fddiMACUpstreamNbr ; | ||
782 | sp->p208f_old_dna = | ||
783 | mib_m->fddiMACOldDownstreamNbr ; | ||
784 | sp->p208f_new_dna = | ||
785 | mib_m->fddiMACDownstreamNbr ; | ||
786 | sp->p208f_curren_path = | ||
787 | mib_m->fddiMACCurrentPath ; | ||
788 | sp->p208f_smt_address = | ||
789 | mib_m->fddiMACSMTAddress ; | ||
790 | sp_len = sizeof(struct smt_p_208f) ; | ||
791 | goto sp_done ; | ||
792 | } | ||
793 | case SMT_P2090 : | ||
794 | { | ||
795 | struct smt_p_2090 *sp ; | ||
796 | sp = (struct smt_p_2090 *) to ; | ||
797 | sp->p2090_multiple = | ||
798 | mib_m->fddiMACMultiple_P ; | ||
799 | sp->p2090_availablepaths = | ||
800 | mib_m->fddiMACAvailablePaths ; | ||
801 | sp->p2090_currentpath = | ||
802 | mib_m->fddiMACCurrentPath ; | ||
803 | sp->p2090_requestedpaths = | ||
804 | mib_m->fddiMACRequestedPaths ; | ||
805 | sp_len = sizeof(struct smt_p_2090) ; | ||
806 | goto sp_done ; | ||
807 | } | ||
808 | case SMT_P4050 : | ||
809 | { | ||
810 | struct smt_p_4050 *sp ; | ||
811 | sp = (struct smt_p_4050 *) to ; | ||
812 | sp->p4050_flag = | ||
813 | mib_p->fddiPORTLerFlag ; | ||
814 | sp->p4050_pad = 0 ; | ||
815 | sp->p4050_cutoff = | ||
816 | mib_p->fddiPORTLer_Cutoff ; ; | ||
817 | sp->p4050_alarm = | ||
818 | mib_p->fddiPORTLer_Alarm ; ; | ||
819 | sp->p4050_estimate = | ||
820 | mib_p->fddiPORTLer_Estimate ; | ||
821 | sp->p4050_reject_ct = | ||
822 | mib_p->fddiPORTLem_Reject_Ct ; | ||
823 | sp->p4050_ct = | ||
824 | mib_p->fddiPORTLem_Ct ; | ||
825 | sp_len = sizeof(struct smt_p_4050) ; | ||
826 | goto sp_done ; | ||
827 | } | ||
828 | |||
829 | case SMT_P4051 : | ||
830 | { | ||
831 | struct smt_p_4051 *sp ; | ||
832 | sp = (struct smt_p_4051 *) to ; | ||
833 | sp->p4051_multiple = | ||
834 | mib_p->fddiPORTMultiple_U ; | ||
835 | sp->p4051_porttype = | ||
836 | mib_p->fddiPORTMy_Type ; | ||
837 | sp->p4051_connectstate = | ||
838 | mib_p->fddiPORTConnectState ; ; | ||
839 | sp->p4051_pc_neighbor = | ||
840 | mib_p->fddiPORTNeighborType ; | ||
841 | sp->p4051_pc_withhold = | ||
842 | mib_p->fddiPORTPC_Withhold ; | ||
843 | sp_len = sizeof(struct smt_p_4051) ; | ||
844 | goto sp_done ; | ||
845 | } | ||
846 | case SMT_P4052 : | ||
847 | { | ||
848 | struct smt_p_4052 *sp ; | ||
849 | sp = (struct smt_p_4052 *) to ; | ||
850 | sp->p4052_flag = | ||
851 | mib_p->fddiPORTEB_Condition ; | ||
852 | sp->p4052_eberrorcount = | ||
853 | mib_p->fddiPORTEBError_Ct ; | ||
854 | sp_len = sizeof(struct smt_p_4052) ; | ||
855 | goto sp_done ; | ||
856 | } | ||
857 | case SMT_P4053 : | ||
858 | { | ||
859 | struct smt_p_4053 *sp ; | ||
860 | sp = (struct smt_p_4053 *) to ; | ||
861 | sp->p4053_multiple = | ||
862 | mib_p->fddiPORTMultiple_P ; ; | ||
863 | sp->p4053_availablepaths = | ||
864 | mib_p->fddiPORTAvailablePaths ; | ||
865 | sp->p4053_currentpath = | ||
866 | mib_p->fddiPORTCurrentPath ; | ||
867 | memcpy( (char *) &sp->p4053_requestedpaths, | ||
868 | (char *) mib_p->fddiPORTRequestedPaths,4) ; | ||
869 | sp->p4053_mytype = | ||
870 | mib_p->fddiPORTMy_Type ; | ||
871 | sp->p4053_neighbortype = | ||
872 | mib_p->fddiPORTNeighborType ; | ||
873 | sp_len = sizeof(struct smt_p_4053) ; | ||
874 | goto sp_done ; | ||
875 | } | ||
876 | default : | ||
877 | break ; | ||
878 | } | ||
879 | /* | ||
880 | * in table ? | ||
881 | */ | ||
882 | if (!pt) { | ||
883 | pcon->pc_err = (para & 0xff00) ? SMT_RDF_NOPARAM : | ||
884 | SMT_RDF_ILLEGAL ; | ||
885 | return ; | ||
886 | } | ||
887 | /* | ||
888 | * check access rights | ||
889 | */ | ||
890 | switch (pt->p_access) { | ||
891 | case AC_G : | ||
892 | case AC_GR : | ||
893 | break ; | ||
894 | default : | ||
895 | pcon->pc_err = SMT_RDF_ILLEGAL ; | ||
896 | return ; | ||
897 | } | ||
898 | from = mib_addr + pt->p_offset ; | ||
899 | if (!swap) | ||
900 | swap = pt->p_swap ; /* pointer to swap string */ | ||
901 | |||
902 | /* | ||
903 | * copy values | ||
904 | */ | ||
905 | while ((c = *swap++)) { | ||
906 | switch(c) { | ||
907 | case 'b' : | ||
908 | case 'w' : | ||
909 | case 'l' : | ||
910 | break ; | ||
911 | case 'S' : | ||
912 | case 'E' : | ||
913 | case 'R' : | ||
914 | case 'r' : | ||
915 | if (len < 4) | ||
916 | goto len_error ; | ||
917 | to[0] = 0 ; | ||
918 | to[1] = 0 ; | ||
919 | #ifdef LITTLE_ENDIAN | ||
920 | if (c == 'r') { | ||
921 | to[2] = *from++ ; | ||
922 | to[3] = *from++ ; | ||
923 | } | ||
924 | else { | ||
925 | to[3] = *from++ ; | ||
926 | to[2] = *from++ ; | ||
927 | } | ||
928 | #else | ||
929 | to[2] = *from++ ; | ||
930 | to[3] = *from++ ; | ||
931 | #endif | ||
932 | to += 4 ; | ||
933 | len -= 4 ; | ||
934 | break ; | ||
935 | case 'I' : /* for SET of port indexes */ | ||
936 | if (len < 2) | ||
937 | goto len_error ; | ||
938 | #ifdef LITTLE_ENDIAN | ||
939 | to[1] = *from++ ; | ||
940 | to[0] = *from++ ; | ||
941 | #else | ||
942 | to[0] = *from++ ; | ||
943 | to[1] = *from++ ; | ||
944 | #endif | ||
945 | to += 2 ; | ||
946 | len -= 2 ; | ||
947 | break ; | ||
948 | case 'F' : | ||
949 | case 'B' : | ||
950 | if (len < 4) | ||
951 | goto len_error ; | ||
952 | len -= 4 ; | ||
953 | to[0] = 0 ; | ||
954 | to[1] = 0 ; | ||
955 | to[2] = 0 ; | ||
956 | to[3] = *from++ ; | ||
957 | to += 4 ; | ||
958 | break ; | ||
959 | case 'C' : | ||
960 | case 'T' : | ||
961 | case 'L' : | ||
962 | if (len < 4) | ||
963 | goto len_error ; | ||
964 | #ifdef LITTLE_ENDIAN | ||
965 | to[3] = *from++ ; | ||
966 | to[2] = *from++ ; | ||
967 | to[1] = *from++ ; | ||
968 | to[0] = *from++ ; | ||
969 | #else | ||
970 | to[0] = *from++ ; | ||
971 | to[1] = *from++ ; | ||
972 | to[2] = *from++ ; | ||
973 | to[3] = *from++ ; | ||
974 | #endif | ||
975 | len -= 4 ; | ||
976 | to += 4 ; | ||
977 | break ; | ||
978 | case '2' : /* PortMacIndicated */ | ||
979 | if (len < 4) | ||
980 | goto len_error ; | ||
981 | to[0] = 0 ; | ||
982 | to[1] = 0 ; | ||
983 | to[2] = *from++ ; | ||
984 | to[3] = *from++ ; | ||
985 | len -= 4 ; | ||
986 | to += 4 ; | ||
987 | break ; | ||
988 | case '4' : | ||
989 | if (len < 4) | ||
990 | goto len_error ; | ||
991 | to[0] = *from++ ; | ||
992 | to[1] = *from++ ; | ||
993 | to[2] = *from++ ; | ||
994 | to[3] = *from++ ; | ||
995 | len -= 4 ; | ||
996 | to += 4 ; | ||
997 | break ; | ||
998 | case 'A' : | ||
999 | if (len < 8) | ||
1000 | goto len_error ; | ||
1001 | to[0] = 0 ; | ||
1002 | to[1] = 0 ; | ||
1003 | memcpy((char *) to+2,(char *) from,6) ; | ||
1004 | to += 8 ; | ||
1005 | from += 8 ; | ||
1006 | len -= 8 ; | ||
1007 | break ; | ||
1008 | case '8' : | ||
1009 | if (len < 8) | ||
1010 | goto len_error ; | ||
1011 | memcpy((char *) to,(char *) from,8) ; | ||
1012 | to += 8 ; | ||
1013 | from += 8 ; | ||
1014 | len -= 8 ; | ||
1015 | break ; | ||
1016 | case 'D' : | ||
1017 | if (len < 32) | ||
1018 | goto len_error ; | ||
1019 | memcpy((char *) to,(char *) from,32) ; | ||
1020 | to += 32 ; | ||
1021 | from += 32 ; | ||
1022 | len -= 32 ; | ||
1023 | break ; | ||
1024 | case 'P' : /* timestamp is NOT swapped */ | ||
1025 | if (len < 8) | ||
1026 | goto len_error ; | ||
1027 | to[0] = *from++ ; | ||
1028 | to[1] = *from++ ; | ||
1029 | to[2] = *from++ ; | ||
1030 | to[3] = *from++ ; | ||
1031 | to[4] = *from++ ; | ||
1032 | to[5] = *from++ ; | ||
1033 | to[6] = *from++ ; | ||
1034 | to[7] = *from++ ; | ||
1035 | to += 8 ; | ||
1036 | len -= 8 ; | ||
1037 | break ; | ||
1038 | default : | ||
1039 | SMT_PANIC(smc,SMT_E0119, SMT_E0119_MSG) ; | ||
1040 | break ; | ||
1041 | } | ||
1042 | } | ||
1043 | |||
1044 | done: | ||
1045 | /* | ||
1046 | * make it even (in case of 'I' encoding) | ||
1047 | * note: len is DECREMENTED | ||
1048 | */ | ||
1049 | if (len & 3) { | ||
1050 | to[0] = 0 ; | ||
1051 | to[1] = 0 ; | ||
1052 | to += 4 - (len & 3 ) ; | ||
1053 | len = len & ~ 3 ; | ||
1054 | } | ||
1055 | |||
1056 | /* set type and length */ | ||
1057 | pa->p_type = para ; | ||
1058 | pa->p_len = plen - len - PARA_LEN ; | ||
1059 | /* return values */ | ||
1060 | pcon->pc_p = (void *) to ; | ||
1061 | pcon->pc_len = len ; | ||
1062 | return ; | ||
1063 | |||
1064 | sp_done: | ||
1065 | len -= sp_len ; | ||
1066 | to += sp_len ; | ||
1067 | goto done ; | ||
1068 | |||
1069 | len_error: | ||
1070 | /* parameter does not fit in frame */ | ||
1071 | pcon->pc_err = SMT_RDF_TOOLONG ; | ||
1072 | return ; | ||
1073 | |||
1074 | wrong_error: | ||
1075 | pcon->pc_err = SMT_RDF_LENGTH ; | ||
1076 | } | ||
1077 | |||
1078 | /* | ||
1079 | * set parameter | ||
1080 | */ | ||
1081 | int smt_set_para(struct s_smc *smc, struct smt_para *pa, int index, int local, | ||
1082 | int set) | ||
1083 | { | ||
1084 | #define IFSET(x) if (set) (x) | ||
1085 | |||
1086 | const struct s_p_tab *pt ; | ||
1087 | int len ; | ||
1088 | char *from ; | ||
1089 | char *to ; | ||
1090 | const char *swap ; | ||
1091 | char c ; | ||
1092 | char *mib_addr ; | ||
1093 | struct fddi_mib *mib ; | ||
1094 | struct fddi_mib_m *mib_m = NULL; | ||
1095 | struct fddi_mib_a *mib_a = NULL; | ||
1096 | struct fddi_mib_p *mib_p = NULL; | ||
1097 | int mac ; | ||
1098 | int path ; | ||
1099 | int port ; | ||
1100 | SK_LOC_DECL(u_char,byte_val) ; | ||
1101 | SK_LOC_DECL(u_short,word_val) ; | ||
1102 | SK_LOC_DECL(u_long,long_val) ; | ||
1103 | |||
1104 | mac = index - INDEX_MAC ; | ||
1105 | path = index - INDEX_PATH ; | ||
1106 | port = index - INDEX_PORT ; | ||
1107 | len = pa->p_len ; | ||
1108 | from = (char *) (pa + 1 ) ; | ||
1109 | |||
1110 | mib = &smc->mib ; | ||
1111 | switch (pa->p_type & 0xf000) { | ||
1112 | case 0x1000 : | ||
1113 | default : | ||
1114 | mib_addr = (char *) mib ; | ||
1115 | break ; | ||
1116 | case 0x2000 : | ||
1117 | if (mac < 0 || mac >= NUMMACS) { | ||
1118 | return(SMT_RDF_NOPARAM) ; | ||
1119 | } | ||
1120 | mib_m = &smc->mib.m[mac] ; | ||
1121 | mib_addr = (char *) mib_m ; | ||
1122 | from += 4 ; /* skip index */ | ||
1123 | len -= 4 ; | ||
1124 | break ; | ||
1125 | case 0x3000 : | ||
1126 | if (path < 0 || path >= NUMPATHS) { | ||
1127 | return(SMT_RDF_NOPARAM) ; | ||
1128 | } | ||
1129 | mib_a = &smc->mib.a[path] ; | ||
1130 | mib_addr = (char *) mib_a ; | ||
1131 | from += 4 ; /* skip index */ | ||
1132 | len -= 4 ; | ||
1133 | break ; | ||
1134 | case 0x4000 : | ||
1135 | if (port < 0 || port >= smt_mib_phys(smc)) { | ||
1136 | return(SMT_RDF_NOPARAM) ; | ||
1137 | } | ||
1138 | mib_p = &smc->mib.p[port_to_mib(smc,port)] ; | ||
1139 | mib_addr = (char *) mib_p ; | ||
1140 | from += 4 ; /* skip index */ | ||
1141 | len -= 4 ; | ||
1142 | break ; | ||
1143 | } | ||
1144 | switch (pa->p_type) { | ||
1145 | case SMT_P10F0 : | ||
1146 | case SMT_P10F1 : | ||
1147 | #ifdef ESS | ||
1148 | case SMT_P10F2 : | ||
1149 | case SMT_P10F3 : | ||
1150 | case SMT_P10F4 : | ||
1151 | case SMT_P10F5 : | ||
1152 | case SMT_P10F6 : | ||
1153 | case SMT_P10F7 : | ||
1154 | #endif | ||
1155 | #ifdef SBA | ||
1156 | case SMT_P10F8 : | ||
1157 | case SMT_P10F9 : | ||
1158 | #endif | ||
1159 | case SMT_P20F1 : | ||
1160 | if (!local) { | ||
1161 | return(SMT_RDF_NOPARAM) ; | ||
1162 | } | ||
1163 | break ; | ||
1164 | } | ||
1165 | pt = smt_get_ptab(pa->p_type) ; | ||
1166 | if (!pt) { | ||
1167 | return( (pa->p_type & 0xff00) ? SMT_RDF_NOPARAM : | ||
1168 | SMT_RDF_ILLEGAL ) ; | ||
1169 | } | ||
1170 | switch (pt->p_access) { | ||
1171 | case AC_GR : | ||
1172 | case AC_S : | ||
1173 | break ; | ||
1174 | default : | ||
1175 | return(SMT_RDF_ILLEGAL) ; | ||
1176 | } | ||
1177 | to = mib_addr + pt->p_offset ; | ||
1178 | swap = pt->p_swap ; /* pointer to swap string */ | ||
1179 | |||
1180 | while (swap && (c = *swap++)) { | ||
1181 | switch(c) { | ||
1182 | case 'b' : | ||
1183 | to = (char *) &byte_val ; | ||
1184 | break ; | ||
1185 | case 'w' : | ||
1186 | to = (char *) &word_val ; | ||
1187 | break ; | ||
1188 | case 'l' : | ||
1189 | to = (char *) &long_val ; | ||
1190 | break ; | ||
1191 | case 'S' : | ||
1192 | case 'E' : | ||
1193 | case 'R' : | ||
1194 | case 'r' : | ||
1195 | if (len < 4) { | ||
1196 | goto len_error ; | ||
1197 | } | ||
1198 | if (from[0] | from[1]) | ||
1199 | goto val_error ; | ||
1200 | #ifdef LITTLE_ENDIAN | ||
1201 | if (c == 'r') { | ||
1202 | to[0] = from[2] ; | ||
1203 | to[1] = from[3] ; | ||
1204 | } | ||
1205 | else { | ||
1206 | to[1] = from[2] ; | ||
1207 | to[0] = from[3] ; | ||
1208 | } | ||
1209 | #else | ||
1210 | to[0] = from[2] ; | ||
1211 | to[1] = from[3] ; | ||
1212 | #endif | ||
1213 | from += 4 ; | ||
1214 | to += 2 ; | ||
1215 | len -= 4 ; | ||
1216 | break ; | ||
1217 | case 'F' : | ||
1218 | case 'B' : | ||
1219 | if (len < 4) { | ||
1220 | goto len_error ; | ||
1221 | } | ||
1222 | if (from[0] | from[1] | from[2]) | ||
1223 | goto val_error ; | ||
1224 | to[0] = from[3] ; | ||
1225 | len -= 4 ; | ||
1226 | from += 4 ; | ||
1227 | to += 4 ; | ||
1228 | break ; | ||
1229 | case 'C' : | ||
1230 | case 'T' : | ||
1231 | case 'L' : | ||
1232 | if (len < 4) { | ||
1233 | goto len_error ; | ||
1234 | } | ||
1235 | #ifdef LITTLE_ENDIAN | ||
1236 | to[3] = *from++ ; | ||
1237 | to[2] = *from++ ; | ||
1238 | to[1] = *from++ ; | ||
1239 | to[0] = *from++ ; | ||
1240 | #else | ||
1241 | to[0] = *from++ ; | ||
1242 | to[1] = *from++ ; | ||
1243 | to[2] = *from++ ; | ||
1244 | to[3] = *from++ ; | ||
1245 | #endif | ||
1246 | len -= 4 ; | ||
1247 | to += 4 ; | ||
1248 | break ; | ||
1249 | case 'A' : | ||
1250 | if (len < 8) | ||
1251 | goto len_error ; | ||
1252 | if (set) | ||
1253 | memcpy((char *) to,(char *) from+2,6) ; | ||
1254 | to += 8 ; | ||
1255 | from += 8 ; | ||
1256 | len -= 8 ; | ||
1257 | break ; | ||
1258 | case '4' : | ||
1259 | if (len < 4) | ||
1260 | goto len_error ; | ||
1261 | if (set) | ||
1262 | memcpy((char *) to,(char *) from,4) ; | ||
1263 | to += 4 ; | ||
1264 | from += 4 ; | ||
1265 | len -= 4 ; | ||
1266 | break ; | ||
1267 | case '8' : | ||
1268 | if (len < 8) | ||
1269 | goto len_error ; | ||
1270 | if (set) | ||
1271 | memcpy((char *) to,(char *) from,8) ; | ||
1272 | to += 8 ; | ||
1273 | from += 8 ; | ||
1274 | len -= 8 ; | ||
1275 | break ; | ||
1276 | case 'D' : | ||
1277 | if (len < 32) | ||
1278 | goto len_error ; | ||
1279 | if (set) | ||
1280 | memcpy((char *) to,(char *) from,32) ; | ||
1281 | to += 32 ; | ||
1282 | from += 32 ; | ||
1283 | len -= 32 ; | ||
1284 | break ; | ||
1285 | case 'P' : /* timestamp is NOT swapped */ | ||
1286 | if (set) { | ||
1287 | to[0] = *from++ ; | ||
1288 | to[1] = *from++ ; | ||
1289 | to[2] = *from++ ; | ||
1290 | to[3] = *from++ ; | ||
1291 | to[4] = *from++ ; | ||
1292 | to[5] = *from++ ; | ||
1293 | to[6] = *from++ ; | ||
1294 | to[7] = *from++ ; | ||
1295 | } | ||
1296 | to += 8 ; | ||
1297 | len -= 8 ; | ||
1298 | break ; | ||
1299 | default : | ||
1300 | SMT_PANIC(smc,SMT_E0120, SMT_E0120_MSG) ; | ||
1301 | return(SMT_RDF_ILLEGAL) ; | ||
1302 | } | ||
1303 | } | ||
1304 | /* | ||
1305 | * actions and internal updates | ||
1306 | */ | ||
1307 | switch (pa->p_type) { | ||
1308 | case SMT_P101A: /* fddiSMTConfigPolicy */ | ||
1309 | if (word_val & ~1) | ||
1310 | goto val_error ; | ||
1311 | IFSET(mib->fddiSMTConfigPolicy = word_val) ; | ||
1312 | break ; | ||
1313 | case SMT_P101B : /* fddiSMTConnectionPolicy */ | ||
1314 | if (!(word_val & POLICY_MM)) | ||
1315 | goto val_error ; | ||
1316 | IFSET(mib->fddiSMTConnectionPolicy = word_val) ; | ||
1317 | break ; | ||
1318 | case SMT_P101D : /* fddiSMTTT_Notify */ | ||
1319 | if (word_val < 2 || word_val > 30) | ||
1320 | goto val_error ; | ||
1321 | IFSET(mib->fddiSMTTT_Notify = word_val) ; | ||
1322 | break ; | ||
1323 | case SMT_P101E : /* fddiSMTStatRptPolicy */ | ||
1324 | if (byte_val & ~1) | ||
1325 | goto val_error ; | ||
1326 | IFSET(mib->fddiSMTStatRptPolicy = byte_val) ; | ||
1327 | break ; | ||
1328 | case SMT_P101F : /* fddiSMTTrace_MaxExpiration */ | ||
1329 | /* | ||
1330 | * note: lower limit trace_max = 6.001773... s | ||
1331 | * NO upper limit | ||
1332 | */ | ||
1333 | if (long_val < (long)0x478bf51L) | ||
1334 | goto val_error ; | ||
1335 | IFSET(mib->fddiSMTTrace_MaxExpiration = long_val) ; | ||
1336 | break ; | ||
1337 | #ifdef ESS | ||
1338 | case SMT_P10F2 : /* fddiESSPayload */ | ||
1339 | if (long_val > 1562) | ||
1340 | goto val_error ; | ||
1341 | if (set && smc->mib.fddiESSPayload != long_val) { | ||
1342 | smc->ess.raf_act_timer_poll = TRUE ; | ||
1343 | smc->mib.fddiESSPayload = long_val ; | ||
1344 | } | ||
1345 | break ; | ||
1346 | case SMT_P10F3 : /* fddiESSOverhead */ | ||
1347 | if (long_val < 50 || long_val > 5000) | ||
1348 | goto val_error ; | ||
1349 | if (set && smc->mib.fddiESSPayload && | ||
1350 | smc->mib.fddiESSOverhead != long_val) { | ||
1351 | smc->ess.raf_act_timer_poll = TRUE ; | ||
1352 | smc->mib.fddiESSOverhead = long_val ; | ||
1353 | } | ||
1354 | break ; | ||
1355 | case SMT_P10F4 : /* fddiESSMaxTNeg */ | ||
1356 | if (long_val > -MS2BCLK(5) || long_val < -MS2BCLK(165)) | ||
1357 | goto val_error ; | ||
1358 | IFSET(mib->fddiESSMaxTNeg = long_val) ; | ||
1359 | break ; | ||
1360 | case SMT_P10F5 : /* fddiESSMinSegmentSize */ | ||
1361 | if (long_val < 1 || long_val > 4478) | ||
1362 | goto val_error ; | ||
1363 | IFSET(mib->fddiESSMinSegmentSize = long_val) ; | ||
1364 | break ; | ||
1365 | case SMT_P10F6 : /* fddiESSCategory */ | ||
1366 | if ((long_val & 0xffff) != 1) | ||
1367 | goto val_error ; | ||
1368 | IFSET(mib->fddiESSCategory = long_val) ; | ||
1369 | break ; | ||
1370 | case SMT_P10F7 : /* fddiESSSyncTxMode */ | ||
1371 | if (word_val > 1) | ||
1372 | goto val_error ; | ||
1373 | IFSET(mib->fddiESSSynchTxMode = word_val) ; | ||
1374 | break ; | ||
1375 | #endif | ||
1376 | #ifdef SBA | ||
1377 | case SMT_P10F8 : /* fddiSBACommand */ | ||
1378 | if (byte_val != SB_STOP && byte_val != SB_START) | ||
1379 | goto val_error ; | ||
1380 | IFSET(mib->fddiSBACommand = byte_val) ; | ||
1381 | break ; | ||
1382 | case SMT_P10F9 : /* fddiSBAAvailable */ | ||
1383 | if (byte_val > 100) | ||
1384 | goto val_error ; | ||
1385 | IFSET(mib->fddiSBAAvailable = byte_val) ; | ||
1386 | break ; | ||
1387 | #endif | ||
1388 | case SMT_P2020 : /* fddiMACRequestedPaths */ | ||
1389 | if ((word_val & (MIB_P_PATH_PRIM_PREFER | | ||
1390 | MIB_P_PATH_PRIM_ALTER)) == 0 ) | ||
1391 | goto val_error ; | ||
1392 | IFSET(mib_m->fddiMACRequestedPaths = word_val) ; | ||
1393 | break ; | ||
1394 | case SMT_P205F : /* fddiMACFrameErrorThreshold */ | ||
1395 | /* 0 .. ffff acceptable */ | ||
1396 | IFSET(mib_m->fddiMACFrameErrorThreshold = word_val) ; | ||
1397 | break ; | ||
1398 | case SMT_P2067 : /* fddiMACNotCopiedThreshold */ | ||
1399 | /* 0 .. ffff acceptable */ | ||
1400 | IFSET(mib_m->fddiMACNotCopiedThreshold = word_val) ; | ||
1401 | break ; | ||
1402 | case SMT_P2076: /* fddiMACMA_UnitdataEnable */ | ||
1403 | if (byte_val & ~1) | ||
1404 | goto val_error ; | ||
1405 | if (set) { | ||
1406 | mib_m->fddiMACMA_UnitdataEnable = byte_val ; | ||
1407 | queue_event(smc,EVENT_RMT,RM_ENABLE_FLAG) ; | ||
1408 | } | ||
1409 | break ; | ||
1410 | case SMT_P20F1 : /* fddiMACT_Min */ | ||
1411 | IFSET(mib_m->fddiMACT_Min = long_val) ; | ||
1412 | break ; | ||
1413 | case SMT_P320F : | ||
1414 | if (long_val > 1562) | ||
1415 | goto val_error ; | ||
1416 | IFSET(mib_a->fddiPATHSbaPayload = long_val) ; | ||
1417 | #ifdef ESS | ||
1418 | if (set) | ||
1419 | ess_para_change(smc) ; | ||
1420 | #endif | ||
1421 | break ; | ||
1422 | case SMT_P3210 : | ||
1423 | if (long_val > 5000) | ||
1424 | goto val_error ; | ||
1425 | |||
1426 | if (long_val != 0 && mib_a->fddiPATHSbaPayload == 0) | ||
1427 | goto val_error ; | ||
1428 | |||
1429 | IFSET(mib_a->fddiPATHSbaOverhead = long_val) ; | ||
1430 | #ifdef ESS | ||
1431 | if (set) | ||
1432 | ess_para_change(smc) ; | ||
1433 | #endif | ||
1434 | break ; | ||
1435 | case SMT_P3213: /* fddiPATHT_Rmode */ | ||
1436 | /* no limit : | ||
1437 | * 0 .. 343.597 => 0 .. 2e32 * 80nS | ||
1438 | */ | ||
1439 | if (set) { | ||
1440 | mib_a->fddiPATHT_Rmode = long_val ; | ||
1441 | rtm_set_timer(smc) ; | ||
1442 | } | ||
1443 | break ; | ||
1444 | case SMT_P3214 : /* fddiPATHSbaAvailable */ | ||
1445 | if (long_val > 0x00BEBC20L) | ||
1446 | goto val_error ; | ||
1447 | #ifdef SBA | ||
1448 | if (set && mib->fddiSBACommand == SB_STOP) | ||
1449 | goto val_error ; | ||
1450 | #endif | ||
1451 | IFSET(mib_a->fddiPATHSbaAvailable = long_val) ; | ||
1452 | break ; | ||
1453 | case SMT_P3215 : /* fddiPATHTVXLowerBound */ | ||
1454 | IFSET(mib_a->fddiPATHTVXLowerBound = long_val) ; | ||
1455 | goto change_mac_para ; | ||
1456 | case SMT_P3216 : /* fddiPATHT_MaxLowerBound */ | ||
1457 | IFSET(mib_a->fddiPATHT_MaxLowerBound = long_val) ; | ||
1458 | goto change_mac_para ; | ||
1459 | case SMT_P3217 : /* fddiPATHMaxT_Req */ | ||
1460 | IFSET(mib_a->fddiPATHMaxT_Req = long_val) ; | ||
1461 | |||
1462 | change_mac_para: | ||
1463 | if (set && smt_set_mac_opvalues(smc)) { | ||
1464 | RS_SET(smc,RS_EVENT) ; | ||
1465 | smc->sm.please_reconnect = 1 ; | ||
1466 | queue_event(smc,EVENT_ECM,EC_DISCONNECT) ; | ||
1467 | } | ||
1468 | break ; | ||
1469 | case SMT_P400E : /* fddiPORTConnectionPolicies */ | ||
1470 | if (byte_val > 1) | ||
1471 | goto val_error ; | ||
1472 | IFSET(mib_p->fddiPORTConnectionPolicies = byte_val) ; | ||
1473 | break ; | ||
1474 | case SMT_P4011 : /* fddiPORTRequestedPaths */ | ||
1475 | /* all 3*8 bits allowed */ | ||
1476 | IFSET(memcpy((char *)mib_p->fddiPORTRequestedPaths, | ||
1477 | (char *)&long_val,4)) ; | ||
1478 | break ; | ||
1479 | case SMT_P401F: /* fddiPORTMaint_LS */ | ||
1480 | if (word_val > 4) | ||
1481 | goto val_error ; | ||
1482 | IFSET(mib_p->fddiPORTMaint_LS = word_val) ; | ||
1483 | break ; | ||
1484 | case SMT_P403A : /* fddiPORTLer_Cutoff */ | ||
1485 | if (byte_val < 4 || byte_val > 15) | ||
1486 | goto val_error ; | ||
1487 | IFSET(mib_p->fddiPORTLer_Cutoff = byte_val) ; | ||
1488 | break ; | ||
1489 | case SMT_P403B : /* fddiPORTLer_Alarm */ | ||
1490 | if (byte_val < 4 || byte_val > 15) | ||
1491 | goto val_error ; | ||
1492 | IFSET(mib_p->fddiPORTLer_Alarm = byte_val) ; | ||
1493 | break ; | ||
1494 | |||
1495 | /* | ||
1496 | * Actions | ||
1497 | */ | ||
1498 | case SMT_P103C : /* fddiSMTStationAction */ | ||
1499 | if (smt_action(smc,SMT_STATION_ACTION, (int) word_val, 0)) | ||
1500 | goto val_error ; | ||
1501 | break ; | ||
1502 | case SMT_P4046: /* fddiPORTAction */ | ||
1503 | if (smt_action(smc,SMT_PORT_ACTION, (int) word_val, | ||
1504 | port_to_mib(smc,port))) | ||
1505 | goto val_error ; | ||
1506 | break ; | ||
1507 | default : | ||
1508 | break ; | ||
1509 | } | ||
1510 | return(0) ; | ||
1511 | |||
1512 | val_error: | ||
1513 | /* parameter value in frame is out of range */ | ||
1514 | return(SMT_RDF_RANGE) ; | ||
1515 | |||
1516 | len_error: | ||
1517 | /* parameter value in frame is too short */ | ||
1518 | return(SMT_RDF_LENGTH) ; | ||
1519 | |||
1520 | #if 0 | ||
1521 | no_author_error: | ||
1522 | /* parameter not setable, because the SBA is not active | ||
1523 | * Please note: we give the return code 'not authorizeed | ||
1524 | * because SBA denied is not a valid return code in the | ||
1525 | * PMF protocol. | ||
1526 | */ | ||
1527 | return(SMT_RDF_AUTHOR) ; | ||
1528 | #endif | ||
1529 | } | ||
1530 | |||
1531 | static const struct s_p_tab *smt_get_ptab(u_short para) | ||
1532 | { | ||
1533 | const struct s_p_tab *pt ; | ||
1534 | for (pt = p_tab ; pt->p_num && pt->p_num != para ; pt++) | ||
1535 | ; | ||
1536 | return(pt->p_num ? pt : NULL) ; | ||
1537 | } | ||
1538 | |||
1539 | static int smt_mib_phys(struct s_smc *smc) | ||
1540 | { | ||
1541 | #ifdef CONCENTRATOR | ||
1542 | SK_UNUSED(smc) ; | ||
1543 | |||
1544 | return(NUMPHYS) ; | ||
1545 | #else | ||
1546 | if (smc->s.sas == SMT_SAS) | ||
1547 | return(1) ; | ||
1548 | return(NUMPHYS) ; | ||
1549 | #endif | ||
1550 | } | ||
1551 | |||
1552 | int port_to_mib(struct s_smc *smc, int p) | ||
1553 | { | ||
1554 | #ifdef CONCENTRATOR | ||
1555 | SK_UNUSED(smc) ; | ||
1556 | |||
1557 | return(p) ; | ||
1558 | #else | ||
1559 | if (smc->s.sas == SMT_SAS) | ||
1560 | return(PS) ; | ||
1561 | return(p) ; | ||
1562 | #endif | ||
1563 | } | ||
1564 | |||
1565 | |||
1566 | #ifdef DEBUG | ||
1567 | #ifndef BOOT | ||
1568 | void dump_smt(struct s_smc *smc, struct smt_header *sm, char *text) | ||
1569 | { | ||
1570 | int len ; | ||
1571 | struct smt_para *pa ; | ||
1572 | char *c ; | ||
1573 | int n ; | ||
1574 | int nn ; | ||
1575 | #ifdef LITTLE_ENDIAN | ||
1576 | int smtlen ; | ||
1577 | #endif | ||
1578 | |||
1579 | SK_UNUSED(smc) ; | ||
1580 | |||
1581 | #ifdef DEBUG_BRD | ||
1582 | if (smc->debug.d_smtf < 2) | ||
1583 | #else | ||
1584 | if (debug.d_smtf < 2) | ||
1585 | #endif | ||
1586 | return ; | ||
1587 | #ifdef LITTLE_ENDIAN | ||
1588 | smtlen = sm->smt_len + sizeof(struct smt_header) ; | ||
1589 | #endif | ||
1590 | printf("SMT Frame [%s]:\nDA ",text) ; | ||
1591 | dump_hex((char *) &sm->smt_dest,6) ; | ||
1592 | printf("\tSA ") ; | ||
1593 | dump_hex((char *) &sm->smt_source,6) ; | ||
1594 | printf(" Class %x Type %x Version %x\n", | ||
1595 | sm->smt_class,sm->smt_type,sm->smt_version) ; | ||
1596 | printf("TID %lx\t\tSID ",sm->smt_tid) ; | ||
1597 | dump_hex((char *) &sm->smt_sid,8) ; | ||
1598 | printf(" LEN %x\n",sm->smt_len) ; | ||
1599 | |||
1600 | len = sm->smt_len ; | ||
1601 | pa = (struct smt_para *) (sm + 1) ; | ||
1602 | while (len > 0 ) { | ||
1603 | int plen ; | ||
1604 | #ifdef UNIX | ||
1605 | printf("TYPE %x LEN %x VALUE\t",pa->p_type,pa->p_len) ; | ||
1606 | #else | ||
1607 | printf("TYPE %04x LEN %2x VALUE\t",pa->p_type,pa->p_len) ; | ||
1608 | #endif | ||
1609 | n = pa->p_len ; | ||
1610 | if ( (n < 0 ) || (n > (int)(len - PARA_LEN))) { | ||
1611 | n = len - PARA_LEN ; | ||
1612 | printf(" BAD LENGTH\n") ; | ||
1613 | break ; | ||
1614 | } | ||
1615 | #ifdef LITTLE_ENDIAN | ||
1616 | smt_swap_para(sm,smtlen,0) ; | ||
1617 | #endif | ||
1618 | if (n < 24) { | ||
1619 | dump_hex((char *)(pa+1),(int) n) ; | ||
1620 | printf("\n") ; | ||
1621 | } | ||
1622 | else { | ||
1623 | int first = 0 ; | ||
1624 | c = (char *)(pa+1) ; | ||
1625 | dump_hex(c,16) ; | ||
1626 | printf("\n") ; | ||
1627 | n -= 16 ; | ||
1628 | c += 16 ; | ||
1629 | while (n > 0) { | ||
1630 | nn = (n > 16) ? 16 : n ; | ||
1631 | if (n > 64) { | ||
1632 | if (first == 0) | ||
1633 | printf("\t\t\t...\n") ; | ||
1634 | first = 1 ; | ||
1635 | } | ||
1636 | else { | ||
1637 | printf("\t\t\t") ; | ||
1638 | dump_hex(c,nn) ; | ||
1639 | printf("\n") ; | ||
1640 | } | ||
1641 | n -= nn ; | ||
1642 | c += 16 ; | ||
1643 | } | ||
1644 | } | ||
1645 | #ifdef LITTLE_ENDIAN | ||
1646 | smt_swap_para(sm,smtlen,1) ; | ||
1647 | #endif | ||
1648 | plen = (pa->p_len + PARA_LEN + 3) & ~3 ; | ||
1649 | len -= plen ; | ||
1650 | pa = (struct smt_para *)((char *)pa + plen) ; | ||
1651 | } | ||
1652 | printf("-------------------------------------------------\n\n") ; | ||
1653 | } | ||
1654 | |||
1655 | void dump_hex(char *p, int len) | ||
1656 | { | ||
1657 | int n = 0 ; | ||
1658 | while (len--) { | ||
1659 | n++ ; | ||
1660 | #ifdef UNIX | ||
1661 | printf("%x%s",*p++ & 0xff,len ? ( (n & 7) ? " " : "-") : "") ; | ||
1662 | #else | ||
1663 | printf("%02x%s",*p++ & 0xff,len ? ( (n & 7) ? " " : "-") : "") ; | ||
1664 | #endif | ||
1665 | } | ||
1666 | } | ||
1667 | #endif /* no BOOT */ | ||
1668 | #endif /* DEBUG */ | ||
1669 | |||
1670 | |||
1671 | #endif /* no SLIM_SMT */ | ||