0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include "h/types.h"
0018 #include "h/fddi.h"
0019 #include "h/smc.h"
0020 #include "h/smt_p.h"
0021
0022 #define KERNEL
0023 #include "h/smtstate.h"
0024
0025 #ifndef SLIM_SMT
0026
0027 static int smt_authorize(struct s_smc *smc, struct smt_header *sm);
0028 static int smt_check_set_count(struct s_smc *smc, struct smt_header *sm);
0029 static const struct s_p_tab* smt_get_ptab(u_short para);
0030 static int smt_mib_phys(struct s_smc *smc);
0031 static int smt_set_para(struct s_smc *smc, struct smt_para *pa, int index,
0032 int local, int set);
0033 void smt_add_para(struct s_smc *smc, struct s_pcon *pcon, u_short para,
0034 int index, int local);
0035 static SMbuf *smt_build_pmf_response(struct s_smc *smc, struct smt_header *req,
0036 int set, int local);
0037 static int port_to_mib(struct s_smc *smc, int p);
0038
0039 #define MOFFSS(e) offsetof(struct fddi_mib, e)
0040 #define MOFFMS(e) offsetof(struct fddi_mib_m, e)
0041 #define MOFFAS(e) offsetof(struct fddi_mib_a, e)
0042 #define MOFFPS(e) offsetof(struct fddi_mib_p, e)
0043
0044
0045 #define AC_G 0x01
0046 #define AC_GR 0x02
0047 #define AC_S 0x04
0048 #define AC_NA 0x08
0049 #define AC_GROUP 0x10
0050 #define MS2BCLK(x) ((x)*12500L)
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 static const struct s_p_tab {
0064 u_short p_num ;
0065 u_char p_access ;
0066 u_short p_offset ;
0067 char p_swap[3] ;
0068 } p_tab[] = {
0069
0070 { SMT_P100A,AC_GROUP } ,
0071 { SMT_P100B,AC_G, MOFFSS(fddiSMTStationId), "8" } ,
0072 { SMT_P100D,AC_G, MOFFSS(fddiSMTOpVersionId), "S" } ,
0073 { SMT_P100E,AC_G, MOFFSS(fddiSMTHiVersionId), "S" } ,
0074 { SMT_P100F,AC_G, MOFFSS(fddiSMTLoVersionId), "S" } ,
0075 { SMT_P1010,AC_G, MOFFSS(fddiSMTManufacturerData), "D" } ,
0076 { SMT_P1011,AC_GR, MOFFSS(fddiSMTUserData), "D" } ,
0077 { SMT_P1012,AC_G, MOFFSS(fddiSMTMIBVersionId), "S" } ,
0078
0079
0080 { SMT_P1014,AC_GROUP } ,
0081 { SMT_P1015,AC_G, MOFFSS(fddiSMTMac_Ct), "B" } ,
0082 { SMT_P1016,AC_G, MOFFSS(fddiSMTNonMaster_Ct), "B" } ,
0083 { SMT_P1017,AC_G, MOFFSS(fddiSMTMaster_Ct), "B" } ,
0084 { SMT_P1018,AC_G, MOFFSS(fddiSMTAvailablePaths), "B" } ,
0085 { SMT_P1019,AC_G, MOFFSS(fddiSMTConfigCapabilities),"S" } ,
0086 { SMT_P101A,AC_GR, MOFFSS(fddiSMTConfigPolicy), "wS" } ,
0087 { SMT_P101B,AC_GR, MOFFSS(fddiSMTConnectionPolicy),"wS" } ,
0088 { SMT_P101D,AC_GR, MOFFSS(fddiSMTTT_Notify), "wS" } ,
0089 { SMT_P101E,AC_GR, MOFFSS(fddiSMTStatRptPolicy), "bB" } ,
0090 { SMT_P101F,AC_GR, MOFFSS(fddiSMTTrace_MaxExpiration),"lL" } ,
0091 { SMT_P1020,AC_G, MOFFSS(fddiSMTPORTIndexes), "II" } ,
0092 { SMT_P1021,AC_G, MOFFSS(fddiSMTMACIndexes), "I" } ,
0093 { SMT_P1022,AC_G, MOFFSS(fddiSMTBypassPresent), "F" } ,
0094
0095
0096 { SMT_P1028,AC_GROUP } ,
0097 { SMT_P1029,AC_G, MOFFSS(fddiSMTECMState), "E" } ,
0098 { SMT_P102A,AC_G, MOFFSS(fddiSMTCF_State), "E" } ,
0099 { SMT_P102C,AC_G, MOFFSS(fddiSMTRemoteDisconnectFlag),"F" } ,
0100 { SMT_P102D,AC_G, MOFFSS(fddiSMTStationStatus), "E" } ,
0101 { SMT_P102E,AC_G, MOFFSS(fddiSMTPeerWrapFlag), "F" } ,
0102
0103
0104 { SMT_P1032,AC_GROUP } ,
0105 { SMT_P1033,AC_G, MOFFSS(fddiSMTTimeStamp),"P" } ,
0106 { SMT_P1034,AC_G, MOFFSS(fddiSMTTransitionTimeStamp),"P" } ,
0107
0108 { SMT_P1035,AC_G, MOFFSS(fddiSMTSetCount),"4P" } ,
0109 { SMT_P1036,AC_G, MOFFSS(fddiSMTLastSetStationId),"8" } ,
0110
0111 { SMT_P103C,AC_S, 0, "wS" } ,
0112
0113
0114
0115
0116
0117 { SMT_P10F0,AC_GR, MOFFSS(fddiPRPMFPasswd), "8" } ,
0118 { SMT_P10F1,AC_GR, MOFFSS(fddiPRPMFStation), "8" } ,
0119 #ifdef ESS
0120 { SMT_P10F2,AC_GR, MOFFSS(fddiESSPayload), "lL" } ,
0121 { SMT_P10F3,AC_GR, MOFFSS(fddiESSOverhead), "lL" } ,
0122 { SMT_P10F4,AC_GR, MOFFSS(fddiESSMaxTNeg), "lL" } ,
0123 { SMT_P10F5,AC_GR, MOFFSS(fddiESSMinSegmentSize), "lL" } ,
0124 { SMT_P10F6,AC_GR, MOFFSS(fddiESSCategory), "lL" } ,
0125 { SMT_P10F7,AC_GR, MOFFSS(fddiESSSynchTxMode), "wS" } ,
0126 #endif
0127 #ifdef SBA
0128 { SMT_P10F8,AC_GR, MOFFSS(fddiSBACommand), "bF" } ,
0129 { SMT_P10F9,AC_GR, MOFFSS(fddiSBAAvailable), "bF" } ,
0130 #endif
0131
0132 { SMT_P200A,AC_GROUP } ,
0133 { SMT_P200B,AC_G, MOFFMS(fddiMACFrameStatusFunctions),"S" } ,
0134 { SMT_P200D,AC_G, MOFFMS(fddiMACT_MaxCapabilitiy),"T" } ,
0135 { SMT_P200E,AC_G, MOFFMS(fddiMACTVXCapabilitiy),"T" } ,
0136
0137
0138 { SMT_P2014,AC_GROUP } ,
0139 { SMT_P2016,AC_G, MOFFMS(fddiMACAvailablePaths), "B" } ,
0140 { SMT_P2017,AC_G, MOFFMS(fddiMACCurrentPath), "S" } ,
0141 { SMT_P2018,AC_G, MOFFMS(fddiMACUpstreamNbr), "A" } ,
0142 { SMT_P2019,AC_G, MOFFMS(fddiMACDownstreamNbr), "A" } ,
0143 { SMT_P201A,AC_G, MOFFMS(fddiMACOldUpstreamNbr), "A" } ,
0144 { SMT_P201B,AC_G, MOFFMS(fddiMACOldDownstreamNbr),"A" } ,
0145 { SMT_P201D,AC_G, MOFFMS(fddiMACDupAddressTest), "E" } ,
0146 { SMT_P2020,AC_GR, MOFFMS(fddiMACRequestedPaths), "wS" } ,
0147 { SMT_P2021,AC_G, MOFFMS(fddiMACDownstreamPORTType),"E" } ,
0148 { SMT_P2022,AC_G, MOFFMS(fddiMACIndex), "S" } ,
0149
0150
0151 { SMT_P2028,AC_GROUP } ,
0152 { SMT_P2029,AC_G, MOFFMS(fddiMACSMTAddress), "A" } ,
0153
0154
0155 { SMT_P2032,AC_GROUP } ,
0156 { SMT_P2033,AC_G, MOFFMS(fddiMACT_Req), "T" } ,
0157 { SMT_P2034,AC_G, MOFFMS(fddiMACT_Neg), "T" } ,
0158 { SMT_P2035,AC_G, MOFFMS(fddiMACT_Max), "T" } ,
0159 { SMT_P2036,AC_G, MOFFMS(fddiMACTvxValue), "T" } ,
0160 { SMT_P2038,AC_G, MOFFMS(fddiMACT_Pri0), "T" } ,
0161 { SMT_P2039,AC_G, MOFFMS(fddiMACT_Pri1), "T" } ,
0162 { SMT_P203A,AC_G, MOFFMS(fddiMACT_Pri2), "T" } ,
0163 { SMT_P203B,AC_G, MOFFMS(fddiMACT_Pri3), "T" } ,
0164 { SMT_P203C,AC_G, MOFFMS(fddiMACT_Pri4), "T" } ,
0165 { SMT_P203D,AC_G, MOFFMS(fddiMACT_Pri5), "T" } ,
0166 { SMT_P203E,AC_G, MOFFMS(fddiMACT_Pri6), "T" } ,
0167
0168
0169
0170 { SMT_P2046,AC_GROUP } ,
0171 { SMT_P2047,AC_G, MOFFMS(fddiMACFrame_Ct), "C" } ,
0172 { SMT_P2048,AC_G, MOFFMS(fddiMACCopied_Ct), "C" } ,
0173 { SMT_P2049,AC_G, MOFFMS(fddiMACTransmit_Ct), "C" } ,
0174 { SMT_P204A,AC_G, MOFFMS(fddiMACToken_Ct), "C" } ,
0175 { SMT_P2051,AC_G, MOFFMS(fddiMACError_Ct), "C" } ,
0176 { SMT_P2052,AC_G, MOFFMS(fddiMACLost_Ct), "C" } ,
0177 { SMT_P2053,AC_G, MOFFMS(fddiMACTvxExpired_Ct), "C" } ,
0178 { SMT_P2054,AC_G, MOFFMS(fddiMACNotCopied_Ct), "C" } ,
0179 { SMT_P2056,AC_G, MOFFMS(fddiMACRingOp_Ct), "C" } ,
0180
0181
0182 { SMT_P205A,AC_GROUP } ,
0183 { SMT_P205F,AC_GR, MOFFMS(fddiMACFrameErrorThreshold),"wS" } ,
0184 { SMT_P2060,AC_G, MOFFMS(fddiMACFrameErrorRatio), "S" } ,
0185
0186
0187 { SMT_P2064,AC_GROUP } ,
0188 { SMT_P2067,AC_GR, MOFFMS(fddiMACNotCopiedThreshold),"wS" } ,
0189 { SMT_P2069,AC_G, MOFFMS(fddiMACNotCopiedRatio), "S" } ,
0190
0191
0192 { SMT_P206E,AC_GROUP } ,
0193 { SMT_P206F,AC_G, MOFFMS(fddiMACRMTState), "S" } ,
0194 { SMT_P2070,AC_G, MOFFMS(fddiMACDA_Flag), "F" } ,
0195 { SMT_P2071,AC_G, MOFFMS(fddiMACUNDA_Flag), "F" } ,
0196 { SMT_P2072,AC_G, MOFFMS(fddiMACFrameErrorFlag), "F" } ,
0197 { SMT_P2073,AC_G, MOFFMS(fddiMACNotCopiedFlag), "F" } ,
0198 { SMT_P2074,AC_G, MOFFMS(fddiMACMA_UnitdataAvailable),"F" } ,
0199 { SMT_P2075,AC_G, MOFFMS(fddiMACHardwarePresent), "F" } ,
0200 { SMT_P2076,AC_GR, MOFFMS(fddiMACMA_UnitdataEnable),"bF" } ,
0201
0202
0203
0204
0205
0206 { SMT_P20F0,AC_NA } ,
0207 { SMT_P20F1,AC_GR, MOFFMS(fddiMACT_Min), "lT" } ,
0208
0209
0210
0211
0212
0213 { SMT_P320A,AC_GROUP } ,
0214 { SMT_P320B,AC_G, MOFFAS(fddiPATHIndex), "r" } ,
0215 { SMT_P320F,AC_GR, MOFFAS(fddiPATHSbaPayload), "l4" } ,
0216 { SMT_P3210,AC_GR, MOFFAS(fddiPATHSbaOverhead), "l4" } ,
0217
0218 { SMT_P3212,AC_G, 0, "" } ,
0219 { SMT_P3213,AC_GR, MOFFAS(fddiPATHT_Rmode), "lT" } ,
0220 { SMT_P3214,AC_GR, MOFFAS(fddiPATHSbaAvailable), "lL" } ,
0221 { SMT_P3215,AC_GR, MOFFAS(fddiPATHTVXLowerBound), "lT" } ,
0222 { SMT_P3216,AC_GR, MOFFAS(fddiPATHT_MaxLowerBound),"lT" } ,
0223 { SMT_P3217,AC_GR, MOFFAS(fddiPATHMaxT_Req), "lT" } ,
0224
0225
0226
0227 { SMT_P400A,AC_GROUP } ,
0228 { SMT_P400C,AC_G, MOFFPS(fddiPORTMy_Type), "E" } ,
0229 { SMT_P400D,AC_G, MOFFPS(fddiPORTNeighborType), "E" } ,
0230 { SMT_P400E,AC_GR, MOFFPS(fddiPORTConnectionPolicies),"bB" } ,
0231 { SMT_P400F,AC_G, MOFFPS(fddiPORTMacIndicated), "2" } ,
0232 { SMT_P4010,AC_G, MOFFPS(fddiPORTCurrentPath), "E" } ,
0233 { SMT_P4011,AC_GR, MOFFPS(fddiPORTRequestedPaths), "l4" } ,
0234 { SMT_P4012,AC_G, MOFFPS(fddiPORTMACPlacement), "S" } ,
0235 { SMT_P4013,AC_G, MOFFPS(fddiPORTAvailablePaths), "B" } ,
0236 { SMT_P4016,AC_G, MOFFPS(fddiPORTPMDClass), "E" } ,
0237 { SMT_P4017,AC_G, MOFFPS(fddiPORTConnectionCapabilities), "B"} ,
0238 { SMT_P401D,AC_G, MOFFPS(fddiPORTIndex), "R" } ,
0239
0240
0241 { SMT_P401E,AC_GROUP } ,
0242 { SMT_P401F,AC_GR, MOFFPS(fddiPORTMaint_LS), "wE" } ,
0243 { SMT_P4021,AC_G, MOFFPS(fddiPORTBS_Flag), "F" } ,
0244 { SMT_P4022,AC_G, MOFFPS(fddiPORTPC_LS), "E" } ,
0245
0246
0247 { SMT_P4028,AC_GROUP } ,
0248 { SMT_P4029,AC_G, MOFFPS(fddiPORTEBError_Ct), "C" } ,
0249 { SMT_P402A,AC_G, MOFFPS(fddiPORTLCTFail_Ct), "C" } ,
0250
0251
0252 { SMT_P4032,AC_GROUP } ,
0253 { SMT_P4033,AC_G, MOFFPS(fddiPORTLer_Estimate), "F" } ,
0254 { SMT_P4034,AC_G, MOFFPS(fddiPORTLem_Reject_Ct), "C" } ,
0255 { SMT_P4035,AC_G, MOFFPS(fddiPORTLem_Ct), "C" } ,
0256 { SMT_P403A,AC_GR, MOFFPS(fddiPORTLer_Cutoff), "bB" } ,
0257 { SMT_P403B,AC_GR, MOFFPS(fddiPORTLer_Alarm), "bB" } ,
0258
0259
0260 { SMT_P403C,AC_GROUP } ,
0261 { SMT_P403D,AC_G, MOFFPS(fddiPORTConnectState), "E" } ,
0262 { SMT_P403E,AC_G, MOFFPS(fddiPORTPCMStateX), "E" } ,
0263 { SMT_P403F,AC_G, MOFFPS(fddiPORTPC_Withhold), "E" } ,
0264 { SMT_P4040,AC_G, MOFFPS(fddiPORTLerFlag), "F" } ,
0265 { SMT_P4041,AC_G, MOFFPS(fddiPORTHardwarePresent),"F" } ,
0266
0267 { SMT_P4046,AC_S, 0, "wS" } ,
0268
0269 { 0, AC_GROUP } ,
0270 { 0 }
0271 } ;
0272
0273 void smt_pmf_received_pack(struct s_smc *smc, SMbuf *mb, int local)
0274 {
0275 struct smt_header *sm ;
0276 SMbuf *reply ;
0277
0278 sm = smtod(mb,struct smt_header *) ;
0279 DB_SMT("SMT: processing PMF frame at %p len %d", sm, mb->sm_len);
0280 #ifdef DEBUG
0281 dump_smt(smc,sm,"PMF Received") ;
0282 #endif
0283
0284
0285
0286
0287 smt_start_watchdog(smc) ;
0288
0289 if (sm->smt_class == SMT_PMF_GET ||
0290 sm->smt_class == SMT_PMF_SET) {
0291 reply = smt_build_pmf_response(smc,sm,
0292 sm->smt_class == SMT_PMF_SET,local) ;
0293 if (reply) {
0294 sm = smtod(reply,struct smt_header *) ;
0295 #ifdef DEBUG
0296 dump_smt(smc,sm,"PMF Reply") ;
0297 #endif
0298 smt_send_frame(smc,reply,FC_SMT_INFO,local) ;
0299 }
0300 }
0301 }
0302
0303 static SMbuf *smt_build_pmf_response(struct s_smc *smc, struct smt_header *req,
0304 int set, int local)
0305 {
0306 SMbuf *mb ;
0307 struct smt_header *smt ;
0308 struct smt_para *pa ;
0309 struct smt_p_reason *res ;
0310 const struct s_p_tab *pt ;
0311 int len ;
0312 int index ;
0313 int idx_end ;
0314 int error ;
0315 int range ;
0316 SK_LOC_DECL(struct s_pcon,pcon) ;
0317 SK_LOC_DECL(struct s_pcon,set_pcon) ;
0318
0319
0320
0321
0322 if (!(mb = smt_get_mbuf(smc)))
0323 return mb;
0324
0325 smt = smtod(mb, struct smt_header *) ;
0326 smt->smt_dest = req->smt_source ;
0327 smt->smt_class = req->smt_class ;
0328 smt->smt_type = SMT_REPLY ;
0329 smt->smt_version = SMT_VID_2 ;
0330 smt->smt_tid = req->smt_tid ;
0331 smt->smt_pad = 0 ;
0332 smt->smt_len = 0 ;
0333
0334
0335
0336
0337 pcon.pc_len = SMT_MAX_INFO_LEN ;
0338 pcon.pc_err = 0 ;
0339 pcon.pc_badset = 0 ;
0340 pcon.pc_p = (void *) (smt + 1) ;
0341
0342
0343
0344
0345 error = 0 ;
0346 if (set) {
0347 if (!local && smt_authorize(smc,req))
0348 error = SMT_RDF_AUTHOR ;
0349 else if (smt_check_set_count(smc,req))
0350 pcon.pc_badset = SMT_RDF_BADSET ;
0351 }
0352
0353
0354
0355 res = (struct smt_p_reason *) pcon.pc_p ;
0356 smt_add_para(smc,&pcon,(u_short) SMT_P_REASON,0,0) ;
0357 smt_add_para(smc,&pcon,(u_short) SMT_P1033,0,0) ;
0358
0359 set_pcon = pcon ;
0360 smt_add_para(smc,&pcon,(u_short) SMT_P1035,0,0) ;
0361 smt_add_para(smc,&pcon,(u_short) SMT_P1036,0,0) ;
0362
0363 pcon.pc_err = error ;
0364 len = req->smt_len ;
0365 pa = (struct smt_para *) (req + 1) ;
0366
0367
0368
0369 while (!pcon.pc_err && len > 0 ) {
0370 if (((u_short)len < pa->p_len + PARA_LEN) || (pa->p_len & 3)) {
0371 pcon.pc_err = SMT_RDF_LENGTH ;
0372 break ;
0373 }
0374
0375 if (((range = (pa->p_type & 0xf000)) == 0x2000) ||
0376 range == 0x3000 || range == 0x4000) {
0377
0378
0379
0380 index = *((u_char *)pa + PARA_LEN + 3) ;
0381 idx_end = index ;
0382 if (!set && (pa->p_len != 4)) {
0383 pcon.pc_err = SMT_RDF_LENGTH ;
0384 break ;
0385 }
0386 if (!index && !set) {
0387 switch (range) {
0388 case 0x2000 :
0389 index = INDEX_MAC ;
0390 idx_end = index - 1 + NUMMACS ;
0391 break ;
0392 case 0x3000 :
0393 index = INDEX_PATH ;
0394 idx_end = index - 1 + NUMPATHS ;
0395 break ;
0396 case 0x4000 :
0397 index = INDEX_PORT ;
0398 idx_end = index - 1 + NUMPHYS ;
0399 #ifndef CONCENTRATOR
0400 if (smc->s.sas == SMT_SAS)
0401 idx_end = INDEX_PORT ;
0402 #endif
0403 break ;
0404 }
0405 }
0406 }
0407 else {
0408
0409
0410
0411 if (!set && (pa->p_len != 0)) {
0412 pcon.pc_err = SMT_RDF_LENGTH ;
0413 break ;
0414 }
0415 index = 0 ;
0416 idx_end = 0 ;
0417 }
0418 while (index <= idx_end) {
0419
0420
0421
0422
0423 pt = smt_get_ptab(pa->p_type) ;
0424 if (pt && pt->p_access == AC_GROUP && !set) {
0425 pt++ ;
0426 while (pt->p_access == AC_G ||
0427 pt->p_access == AC_GR) {
0428 smt_add_para(smc,&pcon,pt->p_num,
0429 index,local);
0430 pt++ ;
0431 }
0432 }
0433
0434
0435
0436
0437
0438 else if (pa->p_type != SMT_P_AUTHOR &&
0439 (!set || (pa->p_type != SMT_P1035))) {
0440 int st ;
0441 if (pcon.pc_badset) {
0442 smt_add_para(smc,&pcon,pa->p_type,
0443 index,local) ;
0444 }
0445 else if (set) {
0446 st = smt_set_para(smc,pa,index,local,1);
0447
0448
0449
0450 smt_add_para(smc,&pcon,pa->p_type,
0451 index,local) ;
0452 pcon.pc_err = st ;
0453 }
0454 else {
0455 if (pt && pt->p_access == AC_S) {
0456 pcon.pc_err =
0457 SMT_RDF_ILLEGAL ;
0458 }
0459 smt_add_para(smc,&pcon,pa->p_type,
0460 index,local) ;
0461 }
0462 }
0463 if (pcon.pc_err)
0464 break ;
0465 index++ ;
0466 }
0467 len -= pa->p_len + PARA_LEN ;
0468 pa = (struct smt_para *) ((char *)pa + pa->p_len + PARA_LEN) ;
0469 }
0470 smt->smt_len = SMT_MAX_INFO_LEN - pcon.pc_len ;
0471 mb->sm_len = smt->smt_len + sizeof(struct smt_header) ;
0472
0473
0474 res->rdf_reason = pcon.pc_badset ? pcon.pc_badset :
0475 pcon.pc_err ? pcon.pc_err : SMT_RDF_SUCCESS ;
0476 if (set && (res->rdf_reason == SMT_RDF_SUCCESS)) {
0477
0478
0479
0480
0481
0482 smc->mib.fddiSMTSetCount.count++ ;
0483 smt_set_timestamp(smc,smc->mib.fddiSMTSetCount.timestamp) ;
0484 smc->mib.fddiSMTLastSetStationId = req->smt_sid ;
0485 smt_add_para(smc,&set_pcon,(u_short) SMT_P1035,0,0) ;
0486 smt_add_para(smc,&set_pcon,(u_short) SMT_P1036,0,0) ;
0487 }
0488 return mb;
0489 }
0490
0491 static int smt_authorize(struct s_smc *smc, struct smt_header *sm)
0492 {
0493 struct smt_para *pa ;
0494 int i ;
0495 char *p ;
0496
0497
0498
0499
0500 p = (char *) &smc->mib.fddiPRPMFStation ;
0501 for (i = 0 ; i < 8 && !p[i] ; i++)
0502 ;
0503 if (i != 8) {
0504 if (memcmp((char *) &sm->smt_sid,
0505 (char *) &smc->mib.fddiPRPMFStation,8))
0506 return 1;
0507 }
0508
0509
0510
0511 p = (char *) smc->mib.fddiPRPMFPasswd ;
0512 for (i = 0 ; i < 8 && !p[i] ; i++)
0513 ;
0514 if (i != 8) {
0515 pa = (struct smt_para *) sm_to_para(smc,sm,SMT_P_AUTHOR) ;
0516 if (!pa)
0517 return 1;
0518 if (pa->p_len != 8)
0519 return 1;
0520 if (memcmp((char *)(pa+1),(char *)smc->mib.fddiPRPMFPasswd,8))
0521 return 1;
0522 }
0523 return 0;
0524 }
0525
0526 static int smt_check_set_count(struct s_smc *smc, struct smt_header *sm)
0527 {
0528 struct smt_para *pa ;
0529 struct smt_p_setcount *sc ;
0530
0531 pa = (struct smt_para *) sm_to_para(smc,sm,SMT_P1035) ;
0532 if (pa) {
0533 sc = (struct smt_p_setcount *) pa ;
0534 if ((smc->mib.fddiSMTSetCount.count != sc->count) ||
0535 memcmp((char *) smc->mib.fddiSMTSetCount.timestamp,
0536 (char *)sc->timestamp,8))
0537 return 1;
0538 }
0539 return 0;
0540 }
0541
0542 void smt_add_para(struct s_smc *smc, struct s_pcon *pcon, u_short para,
0543 int index, int local)
0544 {
0545 struct smt_para *pa ;
0546 const struct s_p_tab *pt ;
0547 struct fddi_mib_m *mib_m = NULL;
0548 struct fddi_mib_p *mib_p = NULL;
0549 int len ;
0550 int plen ;
0551 char *from ;
0552 char *to ;
0553 const char *swap ;
0554 char c ;
0555 int range ;
0556 char *mib_addr ;
0557 int mac ;
0558 int path ;
0559 int port ;
0560 int sp_len ;
0561
0562
0563
0564
0565 if (pcon->pc_err)
0566 return ;
0567
0568
0569
0570
0571 pt = smt_get_ptab(para) ;
0572 if (pt && pt->p_access == AC_S)
0573 return ;
0574
0575 to = (char *) (pcon->pc_p) ;
0576 len = pcon->pc_len ;
0577 plen = len ;
0578 pa = (struct smt_para *) to ;
0579 to += PARA_LEN ;
0580 len -= PARA_LEN ;
0581
0582
0583
0584 if (((range = (para & 0xf000)) == 0x2000) ||
0585 range == 0x3000 || range == 0x4000) {
0586 if (len < 4)
0587 goto wrong_error ;
0588 to[0] = 0 ;
0589 to[1] = 0 ;
0590 to[2] = 0 ;
0591 to[3] = index ;
0592 len -= 4 ;
0593 to += 4 ;
0594 }
0595 mac = index - INDEX_MAC ;
0596 path = index - INDEX_PATH ;
0597 port = index - INDEX_PORT ;
0598
0599
0600
0601 switch (range) {
0602 case 0x1000 :
0603 default :
0604 mib_addr = (char *) (&smc->mib) ;
0605 break ;
0606 case 0x2000 :
0607 if (mac < 0 || mac >= NUMMACS) {
0608 pcon->pc_err = SMT_RDF_NOPARAM ;
0609 return ;
0610 }
0611 mib_addr = (char *) (&smc->mib.m[mac]) ;
0612 mib_m = (struct fddi_mib_m *) mib_addr ;
0613 break ;
0614 case 0x3000 :
0615 if (path < 0 || path >= NUMPATHS) {
0616 pcon->pc_err = SMT_RDF_NOPARAM ;
0617 return ;
0618 }
0619 mib_addr = (char *) (&smc->mib.a[path]) ;
0620 break ;
0621 case 0x4000 :
0622 if (port < 0 || port >= smt_mib_phys(smc)) {
0623 pcon->pc_err = SMT_RDF_NOPARAM ;
0624 return ;
0625 }
0626 mib_addr = (char *) (&smc->mib.p[port_to_mib(smc,port)]) ;
0627 mib_p = (struct fddi_mib_p *) mib_addr ;
0628 break ;
0629 }
0630
0631
0632
0633 swap = NULL;
0634 switch (para) {
0635 case SMT_P10F0 :
0636 case SMT_P10F1 :
0637 #ifdef ESS
0638 case SMT_P10F2 :
0639 case SMT_P10F3 :
0640 case SMT_P10F4 :
0641 case SMT_P10F5 :
0642 case SMT_P10F6 :
0643 case SMT_P10F7 :
0644 #endif
0645 #ifdef SBA
0646 case SMT_P10F8 :
0647 case SMT_P10F9 :
0648 #endif
0649 case SMT_P20F1 :
0650 if (!local) {
0651 pcon->pc_err = SMT_RDF_NOPARAM ;
0652 return ;
0653 }
0654 break ;
0655 case SMT_P2034 :
0656 case SMT_P2046 :
0657 case SMT_P2047 :
0658 case SMT_P204A :
0659 case SMT_P2051 :
0660 case SMT_P2052 :
0661 mac_update_counter(smc) ;
0662 break ;
0663 case SMT_P4022:
0664 mib_p->fddiPORTPC_LS = LS2MIB(
0665 sm_pm_get_ls(smc,port_to_mib(smc,port))) ;
0666 break ;
0667 case SMT_P_REASON :
0668 *(u32 *)to = 0 ;
0669 sp_len = 4 ;
0670 goto sp_done ;
0671 case SMT_P1033 :
0672 smt_set_timestamp(smc,smc->mib.fddiSMTTimeStamp) ;
0673 break ;
0674
0675 case SMT_P1020:
0676 #if NUMPHYS == 12
0677 swap = "IIIIIIIIIIII" ;
0678 #else
0679 #if NUMPHYS == 2
0680 if (smc->s.sas == SMT_SAS)
0681 swap = "I" ;
0682 else
0683 swap = "II" ;
0684 #else
0685 #if NUMPHYS == 24
0686 swap = "IIIIIIIIIIIIIIIIIIIIIIII" ;
0687 #else
0688 ????
0689 #endif
0690 #endif
0691 #endif
0692 break ;
0693 case SMT_P3212 :
0694 {
0695 sp_len = cem_build_path(smc,to,path) ;
0696 goto sp_done ;
0697 }
0698 case SMT_P1048 :
0699 {
0700 struct smt_p_1048 *sp ;
0701 sp = (struct smt_p_1048 *) to ;
0702 sp->p1048_flag = smc->mib.fddiSMTPeerWrapFlag ;
0703 sp->p1048_cf_state = smc->mib.fddiSMTCF_State ;
0704 sp_len = sizeof(struct smt_p_1048) ;
0705 goto sp_done ;
0706 }
0707 case SMT_P208C :
0708 {
0709 struct smt_p_208c *sp ;
0710 sp = (struct smt_p_208c *) to ;
0711 sp->p208c_flag =
0712 smc->mib.m[MAC0].fddiMACDuplicateAddressCond ;
0713 sp->p208c_dupcondition =
0714 (mib_m->fddiMACDA_Flag ? SMT_ST_MY_DUPA : 0) |
0715 (mib_m->fddiMACUNDA_Flag ? SMT_ST_UNA_DUPA : 0);
0716 sp->p208c_fddilong =
0717 mib_m->fddiMACSMTAddress ;
0718 sp->p208c_fddiunalong =
0719 mib_m->fddiMACUpstreamNbr ;
0720 sp->p208c_pad = 0 ;
0721 sp_len = sizeof(struct smt_p_208c) ;
0722 goto sp_done ;
0723 }
0724 case SMT_P208D :
0725 {
0726 struct smt_p_208d *sp ;
0727 sp = (struct smt_p_208d *) to ;
0728 sp->p208d_flag =
0729 mib_m->fddiMACFrameErrorFlag ;
0730 sp->p208d_frame_ct =
0731 mib_m->fddiMACFrame_Ct ;
0732 sp->p208d_error_ct =
0733 mib_m->fddiMACError_Ct ;
0734 sp->p208d_lost_ct =
0735 mib_m->fddiMACLost_Ct ;
0736 sp->p208d_ratio =
0737 mib_m->fddiMACFrameErrorRatio ;
0738 sp_len = sizeof(struct smt_p_208d) ;
0739 goto sp_done ;
0740 }
0741 case SMT_P208E :
0742 {
0743 struct smt_p_208e *sp ;
0744 sp = (struct smt_p_208e *) to ;
0745 sp->p208e_flag =
0746 mib_m->fddiMACNotCopiedFlag ;
0747 sp->p208e_not_copied =
0748 mib_m->fddiMACNotCopied_Ct ;
0749 sp->p208e_copied =
0750 mib_m->fddiMACCopied_Ct ;
0751 sp->p208e_not_copied_ratio =
0752 mib_m->fddiMACNotCopiedRatio ;
0753 sp_len = sizeof(struct smt_p_208e) ;
0754 goto sp_done ;
0755 }
0756 case SMT_P208F :
0757 {
0758 struct smt_p_208f *sp ;
0759 sp = (struct smt_p_208f *) to ;
0760 sp->p208f_multiple =
0761 mib_m->fddiMACMultiple_N ;
0762 sp->p208f_nacondition =
0763 mib_m->fddiMACDuplicateAddressCond ;
0764 sp->p208f_old_una =
0765 mib_m->fddiMACOldUpstreamNbr ;
0766 sp->p208f_new_una =
0767 mib_m->fddiMACUpstreamNbr ;
0768 sp->p208f_old_dna =
0769 mib_m->fddiMACOldDownstreamNbr ;
0770 sp->p208f_new_dna =
0771 mib_m->fddiMACDownstreamNbr ;
0772 sp->p208f_curren_path =
0773 mib_m->fddiMACCurrentPath ;
0774 sp->p208f_smt_address =
0775 mib_m->fddiMACSMTAddress ;
0776 sp_len = sizeof(struct smt_p_208f) ;
0777 goto sp_done ;
0778 }
0779 case SMT_P2090 :
0780 {
0781 struct smt_p_2090 *sp ;
0782 sp = (struct smt_p_2090 *) to ;
0783 sp->p2090_multiple =
0784 mib_m->fddiMACMultiple_P ;
0785 sp->p2090_availablepaths =
0786 mib_m->fddiMACAvailablePaths ;
0787 sp->p2090_currentpath =
0788 mib_m->fddiMACCurrentPath ;
0789 sp->p2090_requestedpaths =
0790 mib_m->fddiMACRequestedPaths ;
0791 sp_len = sizeof(struct smt_p_2090) ;
0792 goto sp_done ;
0793 }
0794 case SMT_P4050 :
0795 {
0796 struct smt_p_4050 *sp ;
0797 sp = (struct smt_p_4050 *) to ;
0798 sp->p4050_flag =
0799 mib_p->fddiPORTLerFlag ;
0800 sp->p4050_pad = 0 ;
0801 sp->p4050_cutoff =
0802 mib_p->fddiPORTLer_Cutoff ;
0803 sp->p4050_alarm =
0804 mib_p->fddiPORTLer_Alarm ;
0805 sp->p4050_estimate =
0806 mib_p->fddiPORTLer_Estimate ;
0807 sp->p4050_reject_ct =
0808 mib_p->fddiPORTLem_Reject_Ct ;
0809 sp->p4050_ct =
0810 mib_p->fddiPORTLem_Ct ;
0811 sp_len = sizeof(struct smt_p_4050) ;
0812 goto sp_done ;
0813 }
0814
0815 case SMT_P4051 :
0816 {
0817 struct smt_p_4051 *sp ;
0818 sp = (struct smt_p_4051 *) to ;
0819 sp->p4051_multiple =
0820 mib_p->fddiPORTMultiple_U ;
0821 sp->p4051_porttype =
0822 mib_p->fddiPORTMy_Type ;
0823 sp->p4051_connectstate =
0824 mib_p->fddiPORTConnectState ;
0825 sp->p4051_pc_neighbor =
0826 mib_p->fddiPORTNeighborType ;
0827 sp->p4051_pc_withhold =
0828 mib_p->fddiPORTPC_Withhold ;
0829 sp_len = sizeof(struct smt_p_4051) ;
0830 goto sp_done ;
0831 }
0832 case SMT_P4052 :
0833 {
0834 struct smt_p_4052 *sp ;
0835 sp = (struct smt_p_4052 *) to ;
0836 sp->p4052_flag =
0837 mib_p->fddiPORTEB_Condition ;
0838 sp->p4052_eberrorcount =
0839 mib_p->fddiPORTEBError_Ct ;
0840 sp_len = sizeof(struct smt_p_4052) ;
0841 goto sp_done ;
0842 }
0843 case SMT_P4053 :
0844 {
0845 struct smt_p_4053 *sp ;
0846 sp = (struct smt_p_4053 *) to ;
0847 sp->p4053_multiple =
0848 mib_p->fddiPORTMultiple_P ;
0849 sp->p4053_availablepaths =
0850 mib_p->fddiPORTAvailablePaths ;
0851 sp->p4053_currentpath =
0852 mib_p->fddiPORTCurrentPath ;
0853 memcpy( (char *) &sp->p4053_requestedpaths,
0854 (char *) mib_p->fddiPORTRequestedPaths,4) ;
0855 sp->p4053_mytype =
0856 mib_p->fddiPORTMy_Type ;
0857 sp->p4053_neighbortype =
0858 mib_p->fddiPORTNeighborType ;
0859 sp_len = sizeof(struct smt_p_4053) ;
0860 goto sp_done ;
0861 }
0862 default :
0863 break ;
0864 }
0865
0866
0867
0868 if (!pt) {
0869 pcon->pc_err = (para & 0xff00) ? SMT_RDF_NOPARAM :
0870 SMT_RDF_ILLEGAL ;
0871 return ;
0872 }
0873
0874
0875
0876 switch (pt->p_access) {
0877 case AC_G :
0878 case AC_GR :
0879 break ;
0880 default :
0881 pcon->pc_err = SMT_RDF_ILLEGAL ;
0882 return ;
0883 }
0884 from = mib_addr + pt->p_offset ;
0885 if (!swap)
0886 swap = pt->p_swap ;
0887
0888
0889
0890
0891 while ((c = *swap++)) {
0892 switch(c) {
0893 case 'b' :
0894 case 'w' :
0895 case 'l' :
0896 break ;
0897 case 'S' :
0898 case 'E' :
0899 case 'R' :
0900 case 'r' :
0901 if (len < 4)
0902 goto len_error ;
0903 to[0] = 0 ;
0904 to[1] = 0 ;
0905 #ifdef LITTLE_ENDIAN
0906 if (c == 'r') {
0907 to[2] = *from++ ;
0908 to[3] = *from++ ;
0909 }
0910 else {
0911 to[3] = *from++ ;
0912 to[2] = *from++ ;
0913 }
0914 #else
0915 to[2] = *from++ ;
0916 to[3] = *from++ ;
0917 #endif
0918 to += 4 ;
0919 len -= 4 ;
0920 break ;
0921 case 'I' :
0922 if (len < 2)
0923 goto len_error ;
0924 #ifdef LITTLE_ENDIAN
0925 to[1] = *from++ ;
0926 to[0] = *from++ ;
0927 #else
0928 to[0] = *from++ ;
0929 to[1] = *from++ ;
0930 #endif
0931 to += 2 ;
0932 len -= 2 ;
0933 break ;
0934 case 'F' :
0935 case 'B' :
0936 if (len < 4)
0937 goto len_error ;
0938 len -= 4 ;
0939 to[0] = 0 ;
0940 to[1] = 0 ;
0941 to[2] = 0 ;
0942 to[3] = *from++ ;
0943 to += 4 ;
0944 break ;
0945 case 'C' :
0946 case 'T' :
0947 case 'L' :
0948 if (len < 4)
0949 goto len_error ;
0950 #ifdef LITTLE_ENDIAN
0951 to[3] = *from++ ;
0952 to[2] = *from++ ;
0953 to[1] = *from++ ;
0954 to[0] = *from++ ;
0955 #else
0956 to[0] = *from++ ;
0957 to[1] = *from++ ;
0958 to[2] = *from++ ;
0959 to[3] = *from++ ;
0960 #endif
0961 len -= 4 ;
0962 to += 4 ;
0963 break ;
0964 case '2' :
0965 if (len < 4)
0966 goto len_error ;
0967 to[0] = 0 ;
0968 to[1] = 0 ;
0969 to[2] = *from++ ;
0970 to[3] = *from++ ;
0971 len -= 4 ;
0972 to += 4 ;
0973 break ;
0974 case '4' :
0975 if (len < 4)
0976 goto len_error ;
0977 to[0] = *from++ ;
0978 to[1] = *from++ ;
0979 to[2] = *from++ ;
0980 to[3] = *from++ ;
0981 len -= 4 ;
0982 to += 4 ;
0983 break ;
0984 case 'A' :
0985 if (len < 8)
0986 goto len_error ;
0987 to[0] = 0 ;
0988 to[1] = 0 ;
0989 memcpy((char *) to+2,(char *) from,6) ;
0990 to += 8 ;
0991 from += 8 ;
0992 len -= 8 ;
0993 break ;
0994 case '8' :
0995 if (len < 8)
0996 goto len_error ;
0997 memcpy((char *) to,(char *) from,8) ;
0998 to += 8 ;
0999 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' :
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
1030 done:
1031
1032
1033
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
1043 pa->p_type = para ;
1044 pa->p_len = plen - len - PARA_LEN ;
1045
1046 pcon->pc_p = (void *) to ;
1047 pcon->pc_len = len ;
1048 return ;
1049
1050 sp_done:
1051 len -= sp_len ;
1052 to += sp_len ;
1053 goto done ;
1054
1055 len_error:
1056
1057 pcon->pc_err = SMT_RDF_TOOLONG ;
1058 return ;
1059
1060 wrong_error:
1061 pcon->pc_err = SMT_RDF_LENGTH ;
1062 }
1063
1064
1065
1066
1067 static 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 ;
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 ;
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 ;
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 ;
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' :
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
1290
1291 switch (pa->p_type) {
1292 case SMT_P101A:
1293 if (word_val & ~1)
1294 goto val_error ;
1295 IFSET(mib->fddiSMTConfigPolicy = word_val) ;
1296 break ;
1297 case SMT_P101B :
1298 if (!(word_val & POLICY_MM))
1299 goto val_error ;
1300 IFSET(mib->fddiSMTConnectionPolicy = word_val) ;
1301 break ;
1302 case SMT_P101D :
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 :
1308 if (byte_val & ~1)
1309 goto val_error ;
1310 IFSET(mib->fddiSMTStatRptPolicy = byte_val) ;
1311 break ;
1312 case SMT_P101F :
1313
1314
1315
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 :
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 :
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 :
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 :
1345 if (long_val < 1 || long_val > 4478)
1346 goto val_error ;
1347 IFSET(mib->fddiESSMinSegmentSize = long_val) ;
1348 break ;
1349 case SMT_P10F6 :
1350 if ((long_val & 0xffff) != 1)
1351 goto val_error ;
1352 IFSET(mib->fddiESSCategory = long_val) ;
1353 break ;
1354 case SMT_P10F7 :
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 :
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 :
1367 if (byte_val > 100)
1368 goto val_error ;
1369 IFSET(mib->fddiSBAAvailable = byte_val) ;
1370 break ;
1371 #endif
1372 case SMT_P2020 :
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 :
1379
1380 IFSET(mib_m->fddiMACFrameErrorThreshold = word_val) ;
1381 break ;
1382 case SMT_P2067 :
1383
1384 IFSET(mib_m->fddiMACNotCopiedThreshold = word_val) ;
1385 break ;
1386 case SMT_P2076:
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 :
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:
1420
1421
1422
1423 if (set) {
1424 mib_a->fddiPATHT_Rmode = long_val ;
1425 rtm_set_timer(smc) ;
1426 }
1427 break ;
1428 case SMT_P3214 :
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 :
1438 IFSET(mib_a->fddiPATHTVXLowerBound = long_val) ;
1439 goto change_mac_para ;
1440 case SMT_P3216 :
1441 IFSET(mib_a->fddiPATHT_MaxLowerBound = long_val) ;
1442 goto change_mac_para ;
1443 case SMT_P3217 :
1444 IFSET(mib_a->fddiPATHMaxT_Req = long_val) ;
1445
1446 change_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 :
1454 if (byte_val > 1)
1455 goto val_error ;
1456 IFSET(mib_p->fddiPORTConnectionPolicies = byte_val) ;
1457 break ;
1458 case SMT_P4011 :
1459
1460 IFSET(memcpy((char *)mib_p->fddiPORTRequestedPaths,
1461 (char *)&long_val,4)) ;
1462 break ;
1463 case SMT_P401F:
1464 if (word_val > 4)
1465 goto val_error ;
1466 IFSET(mib_p->fddiPORTMaint_LS = word_val) ;
1467 break ;
1468 case SMT_P403A :
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 :
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
1481
1482 case SMT_P103C :
1483 if (smt_action(smc,SMT_STATION_ACTION, (int) word_val, 0))
1484 goto val_error ;
1485 break ;
1486 case SMT_P4046:
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
1496 val_error:
1497
1498 return SMT_RDF_RANGE;
1499
1500 len_error:
1501
1502 return SMT_RDF_LENGTH;
1503
1504 #if 0
1505 no_author_error:
1506
1507
1508
1509
1510
1511 return SMT_RDF_AUTHOR;
1512 #endif
1513 }
1514
1515 static 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
1523 static 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
1536 static 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
1552 void 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
1639 void 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
1652 #endif
1653
1654
1655 #endif