pmf.c 40 KB

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