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