pmf.c 40 KB

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