AppDevice.c 152 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768
  1. /****************************************************************
  2. ****************************************************************
  3. ** **
  4. ** (C)Copyright 2005-2006, American Megatrends Inc. **
  5. ** **
  6. ** All Rights Reserved. **
  7. ** **
  8. ** 6145-F, Northbelt Parkway, Norcross, **
  9. ** **
  10. ** Georgia - 30071, USA. Phone-(770)-246-8600. **
  11. ** **
  12. ****************************************************************
  13. ****************************************************************/
  14. /*****************************************************************
  15. *
  16. * AppDevice.c
  17. * AppDevice Commands Handler
  18. *
  19. * Author: Govind Kothandapani <govindk@ami.com>
  20. * : Rama Bisa <ramab@ami.com>
  21. * : Basavaraj Astekar <basavaraja@ami.com>
  22. * : Bakka Ravinder Reddy <bakkar@ami.com>
  23. *
  24. *****************************************************************/
  25. #include "com_BmcType.h"
  26. #include "Support.h"
  27. #include "com_IPMIDefs.h"
  28. #include "com_IPMI_IPM.h"
  29. #include "com_IPMI_AppDevice.h"
  30. #include "AppDevice.h"
  31. #include "RMCP.h"
  32. #include "Session.h"
  33. #include "libipmi_struct.h"
  34. #include "PMConfig.h"
  35. #include "main.h"
  36. #include <string.h>
  37. #define USER_ID_ENABLED 0x01
  38. #define USER_ID_DISABLED 0x02
  39. #define OP_USERID_ONLY_LENGTH 2
  40. #define OP_ENABLE_USER_ID 1
  41. #define OP_DISABLE_USER_ID 0
  42. #define BIT3_BIT0_MASK 0xf
  43. #define GET_AUTH_TYPE_MASK 0xc0
  44. #define AUTH_TYPE_V15 0x0
  45. #define AUTH_TYPE_V20 0x40
  46. #define AUTH_CODE_V15_MASK 0x0f
  47. #define AUTH_CODE_V15_1 0x1
  48. #define AUTH_CODE_V15_2 0x2
  49. #define AUTH_CODE_V15_3 0x5
  50. #define AUTH_CODE_V20_MASK 0x3f
  51. #define MIN_AUTH_CODE_V20 0x04
  52. #define MAX_AUTH_CODE_V20 0xc0
  53. #define NULL_USER 1
  54. #define ZERO_SETSELECTOR 0x00
  55. #define MAX_TYPE_OF_ENCODING 0x02
  56. #define MAX_STRING_LENGTH_COPY 14
  57. #define ASCII_LATIN1 0x00
  58. #define UTF_8 0x01
  59. #define UNICODE 0x02
  60. /* Reserved bit macro definitions */
  61. #define RESERVED_BITS_SENDMS 0x03 //(BIT1 | BIT0)
  62. /* Auth code length */
  63. #define HMAC_SHA1_96_LEN 12
  64. #if APP_DEVICE == 1
  65. #define COUNT_INCREASE 1
  66. #define COUNT_DECREASE -1
  67. #define MAX_BT_PKT_LEN 255
  68. /*macro definitions for set user password options*/
  69. #define DISABLE_USER 0
  70. #define ENABLE_USER 1
  71. #define SET_PASSWORD 2
  72. #define TEST_PASSWORD 3
  73. /*** Global variables ***/
  74. uint8_t g_TmrRunning;
  75. /*** Module variables ***/
  76. static MsgPkt_T m_MsgPkt; /**< Message Packet for posting and retrieving messaged to/from queue */
  77. static uint8_t m_Set_ChReserveBit[] ={0xF0,0x0,0x30};
  78. //extern IfcName_T Ifcnametable[MAX_LAN_CHANNELS];
  79. //static void UpdateCurrentEnabledUserCount(int value, int bmcInstId)
  80. //{
  81. // if (value == 0) return;
  82. // ChannelInfo_T* pChannelInfo = NULL;
  83. // ChannelInfo_T* pNvrChannelInfo = NULL;
  84. // BMCInfo_t* pBMCInfo = &g_BMCInfo[bmcInstId];
  85. // uint8_t maxUserCount = pBMCInfo->IpmiConfig.MaxChUsers;
  86. // uint8_t channelIndex = 0;
  87. // for (channelIndex = 0; channelIndex < MAX_NUM_CHANNELS; channelIndex++)
  88. // {
  89. // if (pBMCInfo->ChConfig[channelIndex].ChType == 0xff) continue;
  90. // pChannelInfo = (ChannelInfo_T*)&pBMCInfo->ChConfig[channelIndex].ChannelInfo;
  91. // if (((value > 0) && ((pChannelInfo->NoCurrentUser + value) > maxUserCount)) ||
  92. // ((value < 0) && ((pChannelInfo->NoCurrentUser + value) < 0)))
  93. // {
  94. // continue;
  95. // }
  96. // pNvrChannelInfo = GetNVRChConfigs(pChannelInfo, bmcInstId);
  97. // pChannelInfo->NoCurrentUser+=value;
  98. // pNvrChannelInfo->NoCurrentUser+=value;
  99. // FlushChConfigs((uint8_t*)pNvrChannelInfo,pNvrChannelInfo->ChannelNumber,bmcInstId);
  100. //}
  101. //}
  102. //static int IsPrivilegeAvailable(uint8_t requestedPrivilege, uint8_t channelNumber, int bmcInstId)
  103. //{
  104. // // PMConfig_T* pPMConfig = ( PMConfig_T*) GetNVRAddr(NVRH_PMCONFIG, bmcInstId);
  105. // BMCInfo_t *pBMCInfo = &g_BMCInfo[bmcInstId];
  106. // uint8_t EthIndex = GetEthIndex(channelNumber & 0x0F, bmcInstId);
  107. // uint8_t privilege = 0x00;
  108. //
  109. // if(0xff == EthIndex) return -1;
  110. //
  111. // //Get requested privilege status (enabled or disabled) from PMConfig by channel
  112. // switch (requestedPrivilege)
  113. // {
  114. // case PRIV_CALLBACK:
  115. // privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeCallBack;
  116. // break;
  117. //
  118. // case PRIV_USER:
  119. // privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeUser;
  120. // break;
  121. //
  122. // case PRIV_OPERATOR:
  123. // privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeOperator;
  124. // break;
  125. //
  126. // case PRIV_ADMIN:
  127. // privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeAdmin;
  128. // break;
  129. //
  130. // case PRIV_OEM:
  131. // privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeOem;
  132. // break;
  133. //
  134. // default:
  135. // return -1;
  136. // }
  137. //
  138. // //All bits are 0 that means privilege level is disabled
  139. // return ((privilege != 0x00) ? 0 : -1);
  140. //}
  141. /*-------------------------------------
  142. * ValidateIPMBChksum1
  143. *-------------------------------------*/
  144. /* Function to validate IPMB Checksum1 for SendMessage Cmd */
  145. static int ValidateIPMBChksum1( uint8_t* Data)
  146. {
  147. int i=0;
  148. uint8_t chksum=0;
  149. for (i = 0; i < 3; i++)
  150. {
  151. chksum += *(Data + i);
  152. }
  153. if (chksum != 0)
  154. {
  155. return FALSE;
  156. }
  157. return TRUE;
  158. }
  159. ///*-------------------------------------
  160. //* ResetWDT
  161. //*-------------------------------------*/
  162. //int
  163. //ResetWDT ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  164. //{
  165. // uint8_t u8ExpirationFlag;
  166. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  167. // if (pBMCInfo->Msghndlr.TmrSet == FALSE)
  168. // {
  169. // *pRes = CC_ATTEMPT_TO_RESET_UNIN_WATCHDOG;
  170. // return sizeof (*pRes);
  171. // }
  172. // // save the WDT expiration flag for later use
  173. // u8ExpirationFlag = g_WDTTmrMgr.WDTTmr.ExpirationFlag;
  174. // /* Reset of Watchdog should not happen once
  175. // once pretimeout interrupt interval is reached*/
  176. // if(pBMCInfo->WDTPreTmtStat == TRUE)
  177. // {
  178. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  179. // return sizeof (*pRes);
  180. // }
  181. // g_WDTTmrMgr.TmrPresent = TRUE;
  182. // g_WDTTmrMgr.TmrInterval = pBMCInfo->WDTConfig.InitCountDown;
  183. // g_WDTTmrMgr.PreTimeOutInterval = SEC_TO_MS * pBMCInfo->WDTConfig.PreTimeOutInterval;
  184. // /* if the pre-timeout interrupt is not configured, adjust the pre-timeout interrupt
  185. // timeout value beyound the regular WDT timeout value so that it won't get triggered
  186. // before the WDT timeout. */
  187. // if ((pBMCInfo->WDTConfig.TmrActions & 0x70) == 0)
  188. // {
  189. // g_WDTTmrMgr.PreTimeOutInterval = g_WDTTmrMgr.TmrInterval+ 1;
  190. // }
  191. // _fmemcpy (&g_WDTTmrMgr.WDTTmr, &pBMCInfo->WDTConfig, sizeof (WDTConfig_T));
  192. // // restore the WDT expiration flag, don't use the one from the flash
  193. // g_WDTTmrMgr.WDTTmr.ExpirationFlag = u8ExpirationFlag;
  194. // // clear WDT sensor event history
  195. // if( g_corefeatures.internal_sensor == ENABLED )
  196. // RestartWD2Sensor(BMCInst);
  197. // if(g_corefeatures.wdt_flush_support == ENABLED )
  198. // {
  199. // FlushIPMI((uint8_t*)&pBMCInfo->WDTConfig,(uint8_t*)&pBMCInfo->WDTConfig,pBMCInfo->IPMIConfLoc.WDTDATAddr,
  200. // sizeof(WDTConfig_T),BMCInst);
  201. // }
  202. // if(BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent == FALSE)
  203. // {
  204. // LOCK_BMC_SHARED_MEM(BMCInst);
  205. // BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning=TRUE;
  206. // BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent=TRUE;
  207. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  208. // sem_post(&g_BMCInfo[BMCInst].WDTSem);
  209. // }
  210. // else
  211. // {
  212. // LOCK_BMC_SHARED_MEM(BMCInst);
  213. // BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning=TRUE;
  214. // BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent=TRUE;
  215. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  216. // //Set SetWDTUpdated flag to reload initial countdown value.
  217. // g_BMCInfo[BMCInst].SetWDTUpdated = TRUE;
  218. // }
  219. // *pRes = CC_NORMAL;
  220. // return sizeof (*pRes);
  221. //}
  222. ///*---------------------------------------
  223. //* SetWDT
  224. //*---------------------------------------*/
  225. //int
  226. //SetWDT ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  227. //{
  228. // SetWDTReq_T* pSetWDTReq = ( SetWDTReq_T*)pReq;
  229. //#if GET_MSG_FLAGS != UNIMPLEMENTED
  230. // GetMsgFlagsRes_T GetMsgFlagsRes;
  231. //#endif
  232. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  233. // //Check for Reserved bits
  234. // if((pSetWDTReq->TmrUse & (BIT5 | BIT4 | BIT3)) || !(pSetWDTReq->TmrUse & (BIT2 | BIT1 | BIT0)) || ((pSetWDTReq->TmrUse & (BIT1 | BIT2)) == (BIT1 | BIT2)) ||
  235. // (pSetWDTReq->TmrActions & (BIT7 |BIT6 | BIT3 | BIT2)) || (pSetWDTReq->ExpirationFlag & (BIT7 | BIT6 | BIT0)))
  236. // {
  237. // *pRes = CC_INV_DATA_FIELD;
  238. // return sizeof(*pRes);
  239. // }
  240. //#if NO_WDT_PRETIMEOUT_INTERRUPT == 1
  241. // // do not support pre-timeout interrupt
  242. // if (pSetWDTReq->TmrActions & 0x70)
  243. // {
  244. // *pRes = CC_INV_DATA_FIELD;
  245. // return sizeof(*pRes);
  246. // }
  247. //#endif
  248. // pSetWDTReq->InitCountDown = htoipmi_u16(pSetWDTReq->InitCountDown);
  249. // // error out if the pre-timeout interrupt is greater than the initial countdown value
  250. // if (pSetWDTReq->InitCountDown < 10 * pSetWDTReq->PreTimeOutInterval)
  251. // {
  252. // *pRes = CC_INV_DATA_FIELD;
  253. // return sizeof(*pRes);
  254. // }
  255. // // only clear the memory version of the bit(s) when the input bit is set #31175
  256. // g_WDTTmrMgr.WDTTmr.ExpirationFlag &= ~pSetWDTReq->ExpirationFlag;
  257. // pSetWDTReq->ExpirationFlag = g_WDTTmrMgr.WDTTmr.ExpirationFlag;
  258. // /* Copy the Timer configuration in NVRAM */
  259. // LOCK_BMC_SHARED_MEM(BMCInst);
  260. // _fmemset (( uint8_t*)&pBMCInfo->WDTConfig, 0, sizeof (WDTConfig_T));
  261. // _fmemcpy (( uint8_t*)&pBMCInfo->WDTConfig, ( uint8_t*)pSetWDTReq, sizeof (SetWDTReq_T));
  262. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  263. // if (TRUE ==BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning)
  264. // {
  265. // /* To check wheather Dont stop bit is set or not */
  266. // if (pSetWDTReq->TmrUse & 0x40)
  267. // {
  268. // /* Set the count down value to given value */
  269. // g_WDTTmrMgr.TmrPresent = TRUE;
  270. // LOCK_BMC_SHARED_MEM(BMCInst);
  271. // BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent =TRUE;
  272. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  273. // g_WDTTmrMgr.TmrInterval= pSetWDTReq->InitCountDown;
  274. // g_WDTTmrMgr.PreTimeOutInterval = (SEC_TO_MS * pSetWDTReq->PreTimeOutInterval);
  275. // /* If PreTimeOutInt is set, clear it */
  276. // if (0 != (pSetWDTReq->TmrActions & 0x70))
  277. // {
  278. // pSetWDTReq->TmrActions &= ~0x70;
  279. // }
  280. // else
  281. // {
  282. // // if the pre-timeout interrupt is not configured, adjust the pre-timeout interrupt
  283. // // timeout value beyound the regular WDT timeout value so that it won't get triggered
  284. // // before the WDT timeout.
  285. // g_WDTTmrMgr.PreTimeOutInterval = pSetWDTReq->InitCountDown + 1;
  286. // }
  287. // _fmemcpy (&g_WDTTmrMgr.WDTTmr, pSetWDTReq, sizeof (WDTConfig_T ));
  288. // }
  289. // else
  290. // {
  291. // /* Stop the timer */
  292. // g_WDTTmrMgr.TmrPresent = FALSE;
  293. // LOCK_BMC_SHARED_MEM(BMCInst);
  294. // BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning=FALSE;
  295. // BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent =FALSE;
  296. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  297. // g_WDTTmrMgr.TmrInterval= pSetWDTReq->InitCountDown;
  298. // g_WDTTmrMgr.PreTimeOutInterval = SEC_TO_MS * pSetWDTReq->PreTimeOutInterval;
  299. // // clear WDT sensor event history
  300. // if( g_corefeatures.internal_sensor == ENABLED)
  301. // RestartWD2Sensor(BMCInst);
  302. // }
  303. // /* Clear the pre-timeout interupt flag */
  304. // LOCK_BMC_SHARED_MEM(BMCInst);
  305. // pBMCInfo->WDTConfig.PreTimeoutActionTaken = 0x00;
  306. // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x08; /* Clear the flag */
  307. //#if GET_MSG_FLAGS != UNIMPLEMENTED
  308. // // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
  309. // GetMsgFlags (NULL, 0, (uint8_t *)&GetMsgFlagsRes,BMCInst);
  310. // TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
  311. // GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
  312. // if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
  313. //#else
  314. // if((BMC_GET_SHARED_MEM(BMCInst)->MsgFlags & BIT3_BIT0_MASK) == 0)
  315. //#endif
  316. // {
  317. // /* Clear the SMS_ATN bit */
  318. // if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
  319. // {
  320. // CLEAR_SMS_ATN (0, BMCInst);
  321. // }
  322. // if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
  323. // {
  324. // CLEAR_SMS_ATN (1, BMCInst);
  325. // }
  326. // if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
  327. // {
  328. // CLEAR_SMS_ATN (2, BMCInst);
  329. // }
  330. // }
  331. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  332. // }
  333. // else
  334. // {
  335. // g_WDTTmrMgr.TmrInterval = pSetWDTReq->InitCountDown;
  336. // g_WDTTmrMgr.TmrPresent = FALSE;
  337. // LOCK_BMC_SHARED_MEM(BMCInst);
  338. // BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent =FALSE;
  339. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  340. // // clear WDT sensor event history
  341. // if( g_corefeatures.internal_sensor == ENABLED)
  342. // RestartWD2Sensor(BMCInst);
  343. // }
  344. // // Modify ARP status to resume the thread
  345. // // after receiving set Watchdog Timer command
  346. // //BMC_GET_SHARED_MEM(BMCInst)->GratArpStatus = RESUME_ARPS;
  347. //
  348. // int i = 0;
  349. // for (i = 0; i < MAX_LAN_CHANNELS; i++)
  350. // {
  351. // if((pBMCInfo->LanIfcConfig[i].Enabled == TRUE)
  352. // && (pBMCInfo->LanIfcConfig[i].Up_Status == LAN_IFC_UP))
  353. // {
  354. // BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[i] = RESUME_ARPS;
  355. // UpdateArpStatus(pBMCInfo->LanIfcConfig[i].Ethindex, BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning, BMCInst);
  356. // }
  357. // }
  358. // if(g_corefeatures.wdt_flush_support == ENABLED )
  359. // {
  360. // FlushIPMI((uint8_t*)&pBMCInfo->WDTConfig,(uint8_t*)&pBMCInfo->WDTConfig,pBMCInfo->IPMIConfLoc.WDTDATAddr,
  361. // sizeof(WDTConfig_T),BMCInst);
  362. // }
  363. // // set the "Don't Log" bit
  364. // g_WDTTmrMgr.WDTTmr.TmrUse &= 0x7F;
  365. // g_WDTTmrMgr.WDTTmr.TmrUse |= (pSetWDTReq->TmrUse & 0x80);
  366. // g_BMCInfo[BMCInst].SetWDTUpdated = TRUE;
  367. // g_BMCInfo[BMCInst].Msghndlr.TmrSet = TRUE;
  368. // pBMCInfo->WDTPreTmtStat = FALSE;
  369. // *pRes = CC_NORMAL;
  370. // return sizeof (*pRes);
  371. //}
  372. ///*---------------------------------------
  373. //* GetWDT
  374. //*---------------------------------------*/
  375. //int
  376. //GetWDT ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  377. //{
  378. // GetWDTRes_T* pGetWDTRes = ( GetWDTRes_T*)pRes;
  379. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  380. // /* Copy the current settings from the NVRAM */
  381. // LOCK_BMC_SHARED_MEM(BMCInst);
  382. // _fmemcpy (( uint8_t*)&pGetWDTRes->CurrentSettings,
  383. // ( uint8_t*)&pBMCInfo->WDTConfig, sizeof (WDTConfig_T));
  384. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  385. // // get the WDT expiration from the global veriable in memory, not from the flash
  386. // pGetWDTRes->CurrentSettings.ExpirationFlag = g_WDTTmrMgr.WDTTmr.ExpirationFlag;
  387. // // get the current "Don't Log" bit
  388. // pGetWDTRes->CurrentSettings.TmrUse &= 0x7F;
  389. // pGetWDTRes->CurrentSettings.TmrUse |= (g_WDTTmrMgr.WDTTmr.TmrUse & 0x80);
  390. // if (TRUE == BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent)
  391. // {
  392. // // set the WDT running bit #30235/30467
  393. // pGetWDTRes->CurrentSettings.TmrUse |= 0x40;
  394. // /* Present count down in 1/100 of second */
  395. // }
  396. // else
  397. // {
  398. // // clear the WDT running bit #30235/30467 for Timer Use (ie) WatchDog Timer status
  399. // pGetWDTRes->CurrentSettings.TmrUse &= ~0x40;
  400. // pGetWDTRes->CurrentSettings.ExpirationFlag = (pGetWDTRes->CurrentSettings.ExpirationFlag) & 0x3E;
  401. // }
  402. // pGetWDTRes->PresentCountDown = g_WDTTmrMgr.TmrInterval;
  403. // pGetWDTRes->CurrentSettings.InitCountDown = htoipmi_u16(pGetWDTRes->CurrentSettings.InitCountDown);
  404. // pGetWDTRes->CompletionCode = CC_NORMAL;
  405. // return sizeof (GetWDTRes_T);
  406. //}
  407. ///*---------------------------------------
  408. //* SetBMCGlobalEnables
  409. //*---------------------------------------*/
  410. //int
  411. //SetBMCGlobalEnables ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  412. //{
  413. // uint8_t GblEnblByte = *pReq;
  414. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  415. // MsgPkt_T MsgPkt;
  416. // _fmemset (&MsgPkt, 0, sizeof (MsgPkt_T));
  417. // /* Check For the reserved bit 4 */
  418. // if ( GblEnblByte & BIT4)
  419. // {
  420. // *pRes = CC_INV_DATA_FIELD;
  421. // return sizeof (*pRes);
  422. // }
  423. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
  424. // if (((BMC_GET_SHARED_MEM (BMCInst)->GlobalEnables ^ GblEnblByte)) & 0x20)
  425. // {
  426. // /* OEM 0 puts us in ICTS compatibility mode for IPMIv2,
  427. // * Send a message to lan process so it can change behavior
  428. // */
  429. // MsgPkt.Channel = GetLANChannel(0, BMCInst);
  430. // MsgPkt.Param = LAN_ICTS_MODE;
  431. // MsgPkt.Privilege = PRIV_LOCAL;
  432. // if (GblEnblByte & 0x20)
  433. // MsgPkt.Cmd = 1;
  434. // else
  435. // MsgPkt.Cmd = 0;
  436. // PostMsg(&MsgPkt,LAN_IFC_Q,BMCInst);
  437. // }
  438. // BMC_GET_SHARED_MEM (BMCInst)->GlobalEnables = GblEnblByte;
  439. // *pRes = CC_NORMAL;
  440. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  441. // return sizeof (*pRes);
  442. //}
  443. ///*---------------------------------------
  444. //* GetBMCGlobalEnables
  445. //*---------------------------------------*/
  446. //int
  447. //GetBMCGlobalEnables ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  448. //{
  449. // GetBMCGblEnblRes_T* pGetBMCGblEnblRes = ( GetBMCGblEnblRes_T*)pRes;
  450. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  451. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
  452. // pGetBMCGblEnblRes->CompletionCode = CC_NORMAL;
  453. // pGetBMCGblEnblRes->BMCGblEnblByte = BMC_GET_SHARED_MEM (BMCInst)->GlobalEnables;
  454. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  455. // return sizeof (GetBMCGblEnblRes_T);
  456. //}
  457. ///*---------------------------------------
  458. //* ClrMsgFlags
  459. //*---------------------------------------*/
  460. //int
  461. //ClrMsgFlags ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  462. //{
  463. // ClearMsgsFlagReq_T* pClearMsgsFlagReq = ( ClearMsgsFlagReq_T*)pReq;
  464. // uint8_t *kcsifcnum;
  465. //#if GET_MSG_FLAGS != UNIMPLEMENTED
  466. // GetMsgFlagsRes_T GetMsgFlagsRes;
  467. //#endif
  468. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  469. // //Check for Reserved bits
  470. // if(pClearMsgsFlagReq->Flag & (BIT4 | BIT2))
  471. // {
  472. // *pRes = CC_INV_DATA_FIELD;
  473. // return sizeof(*pRes);
  474. // }
  475. // OS_THREAD_TLS_GET(g_tls.CurKCSIfcNum,kcsifcnum);
  476. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
  477. // /* Flush Receive Message Queue */
  478. // if (0 != (pClearMsgsFlagReq->Flag & 0x01))
  479. // {
  480. // while (0 == GetMsg (&m_MsgPkt, &g_RcvMsgQ[*kcsifcnum][0], WAIT_NONE,BMCInst))
  481. // {
  482. // BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum]--;
  483. // }
  484. // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x01; /* Clear the flag */
  485. // }
  486. // /* Flush Event Message Buffer */
  487. // if (0 != (pClearMsgsFlagReq->Flag & 0x02))
  488. // {
  489. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->EventMutex,WAIT_INFINITE);
  490. // while (0 == GetMsg (&m_MsgPkt, EVT_MSG_Q, WAIT_NONE,BMCInst))
  491. // {
  492. // BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg--;
  493. // }
  494. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
  495. // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x02; /* Clear the flag */
  496. // }
  497. // /* Clear WatchdogTimer Interrupt*/
  498. // if (0 != (pClearMsgsFlagReq->Flag & 0x08))
  499. // {
  500. // /* Clear the pre-timeout interupt flag */
  501. // pBMCInfo->WDTConfig.PreTimeoutActionTaken = 0x00;
  502. // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x08; /* Clear the flag */
  503. // if(g_corefeatures.wdt_flush_support == ENABLED )
  504. // {
  505. // FlushIPMI((uint8_t*)&pBMCInfo->WDTConfig,(uint8_t*)&pBMCInfo->WDTConfig,pBMCInfo->IPMIConfLoc.WDTDATAddr,
  506. // sizeof(WDTConfig_T),BMCInst);
  507. // }
  508. // }
  509. //#if GET_MSG_FLAGS != UNIMPLEMENTED
  510. // // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
  511. // GetMsgFlags (NULL, 0, (uint8_t *)&GetMsgFlagsRes,BMCInst);
  512. // TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
  513. // GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
  514. // if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
  515. //#else
  516. // if((BMC_GET_SHARED_MEM(BMCInst)->MsgFlags & BIT3_BIT0_MASK) == 0)
  517. //#endif
  518. // {
  519. // /* Clear the SMS_ATN bit */
  520. // if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
  521. // {
  522. // CLEAR_SMS_ATN (0, BMCInst);
  523. // }
  524. // if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
  525. // {
  526. // CLEAR_SMS_ATN (1, BMCInst);
  527. // }
  528. // if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
  529. // {
  530. // CLEAR_SMS_ATN (2, BMCInst);
  531. // }
  532. // }
  533. // *pRes = CC_NORMAL;
  534. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  535. // return sizeof (*pRes);
  536. //}
  537. // /*---------------------------------------
  538. // GetMsgFlags
  539. // ---------------------------------------*/
  540. // int
  541. // GetMsgFlags ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  542. // {
  543. // GetMsgFlagsRes_T* pGetMsgFlagsRes = ( GetMsgFlagsRes_T*)pRes;
  544. // uint8_t *kcsifcnum;
  545. // /* get the message flags */
  546. // pGetMsgFlagsRes->MsgFlags = BMC_GET_SHARED_MEM (BMCInst)->MsgFlags;
  547. // if (BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg >= EVT_MSG_BUF_SIZE)
  548. // {
  549. // /* If Event MessageBuffer is Full set the BIT */
  550. // pGetMsgFlagsRes->MsgFlags |= 0x02;
  551. // }
  552. // else
  553. // {
  554. // /* else reset the Flag */
  555. // pGetMsgFlagsRes->MsgFlags &= ~0x02;
  556. // }
  557. // if(kcsifcnum != NULL && 0 != BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum])
  558. // {
  559. // /* if any Message in ReceiveMsgQ set the Flag */
  560. // pGetMsgFlagsRes->MsgFlags |= 0x01;
  561. // }
  562. // else
  563. // {
  564. // /* else reset the Flag */
  565. // pGetMsgFlagsRes->MsgFlags &= ~0x01;
  566. // }
  567. // /* get the Pre-Timeout Bits Value & Set it to Response Data */
  568. // //PRETIMEOUT BIT is 3rd bit so changed accordingly
  569. // pGetMsgFlagsRes->MsgFlags |= (pBMCInfo->WDTConfig.PreTimeoutActionTaken & 0x08);
  570. // /* Update the Message flags in shared Mem */
  571. // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags |= pGetMsgFlagsRes->MsgFlags;
  572. // pGetMsgFlagsRes->CompletionCode = CC_NORMAL;
  573. // return sizeof (GetMsgFlagsRes_T);
  574. // }
  575. ///*---------------------------------------
  576. //* EnblMsgChannelRcv
  577. //*---------------------------------------*/
  578. //int
  579. //EnblMsgChannelRcv ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  580. //{
  581. // EnblMsgChRcvReq_T* pEnblMsgChRcvReq = ( EnblMsgChRcvReq_T*)pReq;
  582. // EnblMsgChRcvRes_T* pEnblMsgChRcvRes = ( EnblMsgChRcvRes_T*)pRes;
  583. // ChannelInfo_T* pChannelInfo;
  584. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  585. // //Check for Reserved bits
  586. // if(pEnblMsgChRcvReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4))
  587. // {
  588. // pEnblMsgChRcvRes->CompletionCode = CC_INV_DATA_FIELD;
  589. // return sizeof(*pRes);
  590. // }
  591. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  592. // pChannelInfo = getChannelInfo (pEnblMsgChRcvReq->ChannelNum & 0x0F, BMCInst);
  593. // TDBG ("ENBL_MSG_CH_RCV: processing..\n");
  594. // if (NULL == pChannelInfo)
  595. // {
  596. // pEnblMsgChRcvRes->CompletionCode = CC_INV_DATA_FIELD;
  597. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  598. // return sizeof (*pRes);
  599. // }
  600. // switch (pEnblMsgChRcvReq->ChannelState)
  601. // {
  602. // case 0:
  603. // /* disable Receive Message Queue for this Channel */
  604. // pChannelInfo->ReceiveMsgQ = 0x0;
  605. // break;
  606. // case 1:
  607. // /*enable Recevive Message Queue for this Channel */
  608. // pChannelInfo->ReceiveMsgQ = 0x1;
  609. // break;
  610. // case 2:
  611. // /*get Channel State */
  612. // pEnblMsgChRcvRes->ChannelState = pChannelInfo->ReceiveMsgQ;
  613. // break;
  614. // default:
  615. // pEnblMsgChRcvRes->CompletionCode = CC_INV_DATA_FIELD;
  616. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  617. // return sizeof (*pRes);
  618. // }
  619. // pEnblMsgChRcvRes->CompletionCode = CC_NORMAL;
  620. // /*get Channel Number */
  621. // pEnblMsgChRcvRes->ChannelNum = pEnblMsgChRcvReq->ChannelNum & 0x0F;
  622. // pEnblMsgChRcvRes->ChannelState = pChannelInfo->ReceiveMsgQ;
  623. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  624. // return sizeof (EnblMsgChRcvRes_T);
  625. //}
  626. /*---------------------------------------
  627. * GetMessage
  628. *---------------------------------------*/
  629. int
  630. GetMessage ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  631. {
  632. GetMsgRes_T* pGetMsgRes = ( GetMsgRes_T*)pRes;
  633. uint8_t Index = 0,*kcsifcnum;
  634. #if GET_MSG_FLAGS != UNIMPLEMENTED
  635. GetMsgFlagsRes_T GetMsgFlagsRes;
  636. #endif
  637. printf("GetMessage!\n");
  638. // if (0 != GetMsg (&m_MsgPkt, &g_RcvMsgQ[*kcsifcnum][0], WAIT_NONE))
  639. // {
  640. // /* if Queue is Empty */
  641. // pGetMsgRes->CompletionCode = CC_GET_MSG_QUEUE_EMPTY;
  642. // return sizeof (*pRes);
  643. // }
  644. // #if GET_MSG_FLAGS != UNIMPLEMENTED
  645. // // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
  646. // GetMsgFlags (NULL, 0, (uint8_t *)&GetMsgFlagsRes,BMCInst);
  647. // TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
  648. // GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
  649. // if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
  650. // #else
  651. // if (0 == BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum])
  652. // #endif
  653. // {
  654. // /* Clear the SMS_ATN bit */
  655. // CLEAR_SMS_ATN (*kcsifcnum,BMCInst);
  656. // }
  657. // /* Completion Code */
  658. // pGetMsgRes->CompletionCode = CC_NORMAL;
  659. // /* Channel number and privilege level */
  660. // pGetMsgRes->ChannelNum = m_MsgPkt.Channel;
  661. // Index = sizeof (GetMsgRes_T);
  662. // /* First byte should be session handle */
  663. // if(pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)
  664. // {
  665. // if ((PRIMARY_IPMB_CHANNEL != m_MsgPkt.Channel) && (pBMCInfo->SecondaryIPMBCh != m_MsgPkt.Channel))
  666. // {
  667. // pGetMsgRes->ChannelNum |= m_MsgPkt.Privilege << 0x04;
  668. // pRes [Index++] = m_MsgPkt.Param;
  669. // }
  670. // }
  671. // else
  672. // {
  673. // if(PRIMARY_IPMB_CHANNEL != m_MsgPkt.Channel)
  674. // {
  675. // pGetMsgRes->ChannelNum |= m_MsgPkt.Privilege << 0x04;
  676. // pRes [Index++] = m_MsgPkt.Param;
  677. // }
  678. // }
  679. // /* copy the Message data */
  680. // _fmemcpy (( uint8_t*)&pRes[Index], &m_MsgPkt.Data[1], m_MsgPkt.Size-1);
  681. // IPMI_DBG_PRINT ("GetMsg: Sending the following data through requested channel\n");
  682. // IPMI_DBG_PRINT_BUF (pRes, m_MsgPkt.Size + Index);
  683. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  684. // return ((m_MsgPkt.Size-1)+ Index); /*+ 2 for completion code & channel No. */
  685. return 1;
  686. }
  687. /*---------------------------------------
  688. * SendMessage
  689. *---------------------------------------*/
  690. int
  691. SendMessage ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  692. {
  693. SendMsgReq_T* pSendMsgReq = ( SendMsgReq_T*)pReq;
  694. SendMsgRes_T* pSendMsgRes = ( SendMsgRes_T*)pRes;
  695. IPMIMsgHdr_T* pIPMIMsgHdr;
  696. int Queuefd = 0;
  697. uint8_t Tracking;
  698. uint8_t Channel=0,resaddr=0;
  699. uint8_t ResLen = 1;
  700. uint8_t RetVal = 0;
  701. uint8_t Offset = 1;
  702. uint8_t SeqNum = g_BMCInfo.SendMsgSeqNum;
  703. uint8_t PBTbl = PRIMARY_PB_TBL;
  704. uint8_t SrcSessionHndl = 0;
  705. ChannelInfo_T* pChannelInfo;
  706. MsgPkt_T ResPkt;
  707. SessionInfo_T* pSessionInfo = NULL;
  708. uint32_t *CurSesID;
  709. uint8_t *curprivlevel,*curchannel,*kcsifcnum;
  710. if (ReqLen < 1)
  711. {
  712. *pRes = CC_REQ_INV_LEN;
  713. return sizeof (*pRes);
  714. }
  715. if(pSendMsgReq->ChNoTrackReq == 0xC0)
  716. {
  717. *pRes = CC_INV_DATA_FIELD;
  718. return sizeof (*pRes);
  719. }
  720. /* Get the channel number */
  721. Channel = pSendMsgReq->ChNoTrackReq & 0x0F;
  722. /* Get Tracking field */
  723. Tracking = pSendMsgReq->ChNoTrackReq >> 6;
  724. if (Tracking == RESERVED_BITS_SENDMS)
  725. {
  726. *pRes = CC_INV_DATA_FIELD;
  727. return sizeof (*pRes);
  728. }
  729. CurSesID = pthread_getspecific(g_tls.CurSessionID);
  730. curchannel = pthread_getspecific(g_tls.CurChannel);
  731. kcsifcnum = pthread_getspecific(g_tls.CurKCSIfcNum);
  732. // if(g_corefeatures.mbmc_single_nic == ENABLED
  733. // && g_corefeatures.ifc_specific_msg_handling != ENABLED)
  734. // {
  735. // ResLen = 0;
  736. // g_MBMCInfo.sbmcinst = BMCInst;
  737. // memset((char *)&ResPkt,0,sizeof(MsgPkt_T));
  738. // pIPMIMsgHdr = (IPMIMsgHdr_T*)(&pBMCInfo->LANConfig.MsgReq.Data[sizeof (IPMIMsgHdr_T) + 1]);
  739. // m_MsgPkt.Param = PARAM_IFC;
  740. // m_MsgPkt.Channel = *curchannel;
  741. // m_MsgPkt.NetFnLUN = pIPMIMsgHdr->NetFnLUN;
  742. // m_MsgPkt.Cmd = pIPMIMsgHdr->Cmd;
  743. // m_MsgPkt.Privilege = PRIV_ADMIN;
  744. // m_MsgPkt.Size = pBMCInfo->LANConfig.MsgReq.Size - sizeof (IPMIMsgHdr_T) - 2;
  745. // _fmemcpy (m_MsgPkt.Data, pIPMIMsgHdr, m_MsgPkt.Size);
  746. // if(g_PDKHandle[PDK_MBMCSINGLENICSENDMSG] != NULL)
  747. // {
  748. // tmpBMCInst = ( (int (*)(uint8_t,int) ) g_PDKHandle[PDK_MBMCSINGLENICSENDMSG]) ( m_MsgPkt.Data[0],BMCInst);
  749. // }
  750. // if(tmpBMCInst == 0)
  751. // {
  752. // resaddr = (m_MsgPkt.Data[0] - pBMCInfo->IpmiConfig.BMCSlaveAddr) >> 1;
  753. // if(0 <= resaddr && resaddr < BMCInstCount && (m_MsgPkt.Data[0] - pBMCInfo->IpmiConfig.BMCSlaveAddr)%2 == 0)
  754. // {
  755. // tmpBMCInst = resaddr + 1;
  756. // }
  757. // else
  758. // {
  759. // *pRes = CC_INV_DATA_FIELD;
  760. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  761. // return sizeof(*pRes);
  762. // }
  763. // }
  764. // _fmemcpy(ResPkt.Data,pBMCInfo->LANConfig.MsgReq.Data,sizeof(IPMIMsgHdr_T));
  765. // ResPkt.Param = BRIDGING_REQUEST;
  766. // ResPkt.Cmd = pIPMIMsgHdr->Cmd;
  767. // ((IPMIMsgHdr_T *)ResPkt.Data)->NetFnLUN = ((pBMCInfo->LANConfig.MsgReq.NetFnLUN >> 2) +1) << 2;
  768. // ResPkt.Data [sizeof(IPMIMsgHdr_T)] = CC_NORMAL;
  769. // ResPkt.Size = sizeof (IPMIMsgHdr_T) + 1 + 1; // IPMI Header + Completion Code + Second Checksum
  770. // /* Calculate the Second CheckSum */
  771. // ResPkt.Data[ResPkt.Size - 1] = CalculateCheckSum2 (ResPkt.Data, ResPkt.Size-1);
  772. // if (0 != PostMsg (&ResPkt,LAN_RES_Q,BMCInst))
  773. // {
  774. // TDBG ("SendMsg: Failed to post message to interface queue\n");
  775. // }
  776. // pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID,BMCInst);
  777. // if (NULL != pSessionInfo)
  778. // {
  779. // g_MBMCInfo.SrcSessionHndl = pSessionInfo->SessionHandle;
  780. // }
  781. // else
  782. // {
  783. // *pRes = CC_UNSPECIFIED_ERR;
  784. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  785. // return sizeof(*pRes);
  786. // }
  787. // memset(QueueName,0,sizeof(QueueName));
  788. // sprintf(QueueName,"%s%d",LAN_IFC_Q,BMCInst);
  789. // strcpy ((char *)m_MsgPkt.SrcQ,QueueName);
  790. // /* Post the message to Message Handler */
  791. // if (0 != PostMsg (&m_MsgPkt,MSG_HNDLR_Q,tmpBMCInst))
  792. // {
  793. // TDBG ("SendMsg: Failed to post message to interface queue\n");
  794. // }
  795. // }
  796. // else
  797. {
  798. m_MsgPkt.Param = BRIDGING_REQUEST;
  799. m_MsgPkt.Channel = Channel;
  800. m_MsgPkt.Size = ReqLen - 1; /* -1 to skip channel num */
  801. /* Copy the message data */
  802. memcpy (m_MsgPkt.Data, &pReq[1], m_MsgPkt.Size);
  803. /* Copy the IPMI Message header */
  804. pIPMIMsgHdr = ( IPMIMsgHdr_T*)&m_MsgPkt.Data[Offset - 1];
  805. if(ValidateIPMBChksum1(( uint8_t*)pIPMIMsgHdr) == FALSE)
  806. {
  807. *pRes = CC_INV_DATA_FIELD;
  808. return sizeof (*pRes);
  809. }
  810. if(m_MsgPkt.Data[ReqLen - 2] != CalculateCheckSum2 (( uint8_t*)pIPMIMsgHdr, ReqLen - Offset - 1))
  811. {
  812. *pRes = CC_INV_DATA_FIELD;
  813. return sizeof (*pRes);
  814. }
  815. #if 1
  816. printf("SendMsg: ReqLen = %d, size = %ld\n",ReqLen,m_MsgPkt.Size);
  817. int z;
  818. printf("m_MsgPkt: \n");
  819. for(z = 0; z < m_MsgPkt.Size;z++)
  820. printf("%02x ", m_MsgPkt.Data[z]);
  821. printf("\n");
  822. #endif
  823. // if(pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
  824. // {
  825. // /* To Check the Wheather Serial Channel */
  826. // if (pBMCInfo->SERIALch != CH_NOT_USED && (*curchannel & 0xF) == pBMCInfo->SERIALch && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
  827. // {
  828. // SessionInfo_T* pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID,BMCInst);
  829. // if (NULL != pSessionInfo)
  830. // {
  831. // SrcSessionHndl = pSessionInfo->SessionHandle;
  832. // }
  833. // TDBG ("SendMsg: To Serial Interface for reference\n");
  834. // // Offset++; : causes bridging issues
  835. // strcpy ((char *)m_MsgPkt.SrcQ, SERIAL_IFC_Q);
  836. // }
  837. // }
  838. printf("curchannel: %d, Channel: %d\n", *curchannel, Channel);
  839. if(g_BMCInfo.IpmiConfig.LANIfcSupport == 1)
  840. {
  841. /* To Check the Wheather LAN Channel */
  842. //if (IsLANChannel(*curchannel & 0xF, BMCInst))
  843. if(*curchannel&0xf == LAN_RMCP_CHANNEL) //jimbo
  844. {
  845. SessionInfo_T* pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID);
  846. if (NULL != pSessionInfo)
  847. {
  848. SrcSessionHndl = pSessionInfo->SessionHandle;
  849. }
  850. printf ("SendMsg: To LAN Interface for reference\n");
  851. // Offset++; : causes bridging issues
  852. strcpy ((char *)m_MsgPkt.SrcQ, LAN_IFC_Q);
  853. }
  854. }
  855. if((Channel == PRIMARY_IPMB_CHANNEL) && g_BMCInfo.IpmiConfig.PrimaryIPMBSupport == 1)
  856. {
  857. printf ("SendMsg: To Primary IPMB Interface\n");
  858. m_MsgPkt.SrcQ = gFd_PrimaryIpmbIfcQ;
  859. }
  860. else if(( Channel == SECONDARY_IPMB_CHANNEL) && (g_BMCInfo.IpmiConfig.SecondaryIPMBSupport == 1))
  861. {
  862. printf ("SendMsg: To SMLink IPMB Interface\n");
  863. m_MsgPkt.SrcQ = gFd_SecondaryIpmbIfcQ;
  864. }
  865. // else if ((pBMCInfo->SERIALch != CH_NOT_USED && Channel == pBMCInfo->SERIALch) && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
  866. // {
  867. // TDBG ("SendMsg: To Serial Interface\n");
  868. // Offset++;
  869. // strcpy ((char *)m_MsgPkt.SrcQ, SERIAL_IFC_Q);
  870. // }
  871. // else if ((pBMCInfo->ICMBCh != CH_NOT_USED && Channel == pBMCInfo->ICMBCh) && pBMCInfo->IpmiConfig.ICMBIfcSupport == 1)
  872. // {
  873. // TDBG ("SendMsg: To ICMB Interface\n");
  874. // strcpy ((char *)m_MsgPkt.SrcQ, ICMB_IFC_Q);
  875. // }
  876. // else if(pBMCInfo->SYSCh != CH_NOT_USED && Channel == pBMCInfo->SYSCh)
  877. // {
  878. // TDBG ("SendMsg: To System Interface\n");
  879. // /*
  880. // * According to IPMI Spec v2.0.
  881. // * It is recommended to send CC_DEST_UNAVAILABLE
  882. // * completion code, if the channel is disabled for
  883. // * receiving messages.
  884. // * */
  885. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  886. // pChannelInfo = getChannelInfo(Channel,BMCInst);
  887. // if(NULL == pChannelInfo)
  888. // {
  889. // *pRes = CC_INV_DATA_FIELD;
  890. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  891. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  892. // return sizeof (*pRes);
  893. // }
  894. // if (0x0 == pChannelInfo->ReceiveMsgQ)
  895. // {
  896. // printf ("The Channel(0x%x) has been Disabled "
  897. // "for Receive message\n", Channel);
  898. // *pRes = CC_DEST_UNAVAILABLE;
  899. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  900. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  901. // return sizeof (*pRes);
  902. // }
  903. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  904. // strcpy ((char *)m_MsgPkt.SrcQ, &g_RcvMsgQ[*kcsifcnum][0]);
  905. // m_MsgPkt.Param = SrcSessionHndl;
  906. // }
  907. else
  908. {
  909. printf ("SendMsg: Invalid Channel\n");
  910. *pRes = CC_DEST_UNAVAILABLE;
  911. return sizeof (*pRes);
  912. }
  913. // if( (TRUE == pBMCInfo->NMConfig.NMSupport) && (pBMCInfo->NMConfig.NMDevSlaveAddress == pIPMIMsgHdr->ResAddr) &&
  914. // (Channel == (NM_PRIMARY_IPMB_BUS == pBMCInfo->NMConfig.NM_IPMBBus) ? pBMCInfo->PrimaryIPMBCh : pBMCInfo->SecondaryIPMBCh) )
  915. // {
  916. // if( (pBMCInfo->RMCPLAN1Ch == *curchannel) ||
  917. // (pBMCInfo->RMCPLAN2Ch == *curchannel) ||
  918. // (pBMCInfo->RMCPLAN3Ch == *curchannel) ||
  919. // (pBMCInfo->RMCPLAN4Ch == *curchannel) ||
  920. // (pBMCInfo->SERIALch == *curchannel) )
  921. // {
  922. // OS_THREAD_TLS_GET(g_tls.CurPrivLevel,curprivlevel);
  923. // if(PRIV_ADMIN != *curprivlevel)
  924. // {
  925. // TDBG("Insufficient Privilege\n");
  926. // *pRes = CC_INSUFFIENT_PRIVILEGE;
  927. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  928. // return sizeof(*pRes);
  929. // }
  930. // }
  931. // }
  932. if (1 == Tracking)
  933. {
  934. /* Response length is set to zero to make MsgHndlr skip responding to this request
  935. * The Response will be handled by the ipmb interface after verifying NAK.
  936. */
  937. ResLen = 0;
  938. /* Tracking is not required if originator is System ifc */
  939. if (SYS_IFC_CHANNEL == (*curchannel & 0xF))
  940. {
  941. *pRes = CC_INV_DATA_FIELD;
  942. return sizeof (*pRes);
  943. }
  944. PBTbl = (Channel == SECONDARY_IPMB_CHANNEL) ? SECONDARY_PB_TBL : PRIMARY_PB_TBL ;
  945. /* Store in the table for response tracking */
  946. while(TRUE)
  947. {
  948. if (FALSE == m_PendingBridgedResTbl[PBTbl][SeqNum].Used)
  949. {
  950. m_PendingBridgedResTbl[PBTbl][SeqNum].TimeOut = g_BMCInfo.IpmiConfig.SendMsgTimeout;
  951. m_PendingBridgedResTbl[PBTbl][SeqNum].ChannelNum = (*curchannel & 0xF);
  952. m_PendingBridgedResTbl[PBTbl][SeqNum].OriginSrc = ORIGIN_SENDMSG;
  953. g_BMCInfo.SendMsgSeqNum = SeqNum;
  954. if (1 != Offset)
  955. {
  956. m_PendingBridgedResTbl[PBTbl][SeqNum].DstSessionHandle = pReq[Offset]; /* Session handle */
  957. }
  958. m_PendingBridgedResTbl[PBTbl][SeqNum].SrcSessionHandle = SrcSessionHndl;
  959. memcpy (&m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr, pIPMIMsgHdr, sizeof (IPMIMsgHdr_T));
  960. /* Format the IPMI Msg Hdr */
  961. if(Channel == PRIMARY_IPMB_CHANNEL)
  962. {
  963. pIPMIMsgHdr->ReqAddr = g_BMCInfo.IpmiConfig.PrimaryIPMBAddr;
  964. }
  965. else if(Channel == SECONDARY_IPMB_CHANNEL)
  966. {
  967. pIPMIMsgHdr->ReqAddr = g_BMCInfo.IpmiConfig.SecondaryIPMBAddr;
  968. }
  969. else
  970. {
  971. printf("Invalid channel %d\n", Channel);//pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
  972. }
  973. pIPMIMsgHdr->RqSeqLUN = (g_BMCInfo.SendMsgSeqNum << 2) & 0xFC; /* Seq Num and LUN =00 */
  974. /* Recalculate the checksum */
  975. m_MsgPkt.Data[ReqLen - 2] = CalculateCheckSum2 (( uint8_t*)pIPMIMsgHdr, ReqLen - Offset - 1);
  976. if((*curchannel & 0xF) == LAN_RMCP_CHANNEL)
  977. {
  978. m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ = gFd_LanIfcQ;
  979. }
  980. // else if (pBMCInfo->SERIALch != CH_NOT_USED && (*curchannel & 0xF) == pBMCInfo->SERIALch && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
  981. // {
  982. // memset(QueueName,0,sizeof(QueueName));
  983. // sprintf(QueueName,"%s%d",SERIAL_IFC_Q,BMCInst);
  984. // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
  985. // }
  986. else
  987. {
  988. if(( (*curchannel & 0xF) == PRIMARY_IPMB_CHANNEL) && (g_BMCInfo.IpmiConfig.PrimaryIPMBSupport == 1 ))
  989. {
  990. m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ = gFd_PrimaryIpmbIfcQ;
  991. }
  992. else if(((*curchannel & 0xF) == SECONDARY_IPMB_CHANNEL) && g_BMCInfo.IpmiConfig.SecondaryIPMBSupport == 1)
  993. {
  994. m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ = gFd_SecondaryIpmbIfcQ;
  995. }
  996. // else if ((pBMCInfo->SERIALch != CH_NOT_USED && Channel == pBMCInfo->SERIALch) && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
  997. // {
  998. // memset(QueueName,0,sizeof(QueueName));
  999. // sprintf(QueueName,"%s%d",SERIAL_IFC_Q,BMCInst);
  1000. // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
  1001. // }
  1002. // else if((pBMCInfo->SMBUSCh != CH_NOT_USED && Channel == pBMCInfo->SMBUSCh) && pBMCInfo->IpmiConfig.SMBUSIfcSupport == 1)
  1003. // {
  1004. // //strcpy ((char *)m_PendingBridgedResTbl[i].DestQ, NULL);
  1005. // }
  1006. // else if ((pBMCInfo->ICMBCh != CH_NOT_USED && Channel == pBMCInfo->ICMBCh) && pBMCInfo->IpmiConfig.ICMBIfcSupport == 1)
  1007. // {
  1008. // memset(QueueName,0,sizeof(QueueName));
  1009. // sprintf(QueueName,"%s%d",ICMB_IFC_Q,BMCInst);
  1010. // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
  1011. // }
  1012. }
  1013. m_PendingBridgedResTbl[PBTbl][SeqNum].Used = TRUE;
  1014. printf( "SendMessage: Bridged message added index = %d.\n", SeqNum);
  1015. break;
  1016. }
  1017. else
  1018. {
  1019. SeqNum = (SeqNum + 1) & 0x3F;
  1020. if (SeqNum == g_BMCInfo.SendMsgSeqNum)
  1021. {
  1022. /* If not been added to the Pending Bridge table, an error should be reported back.
  1023. If not, for internal channel, the thread calling it may end up waiting! */
  1024. *pRes = CC_NODE_BUSY;
  1025. return sizeof (*pRes);
  1026. }
  1027. }
  1028. }
  1029. }
  1030. // if ((pBMCInfo->SYSCh == (*curchannel & 0xF)) && pBMCInfo->IpmiConfig.SYSIfcSupport == 0x01)
  1031. // {
  1032. // ResLen = 0;
  1033. // /* Format the IPMI Msg Hdr */
  1034. // // Fill the address from Infrastrucure function instead of using PRIMARY_IPMB_ADDR/SECONDARY_IPMB_ADDR
  1035. // if(Channel == pBMCInfo->PrimaryIPMBCh)
  1036. // {
  1037. // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.PrimaryIPMBAddr;
  1038. // }
  1039. // else if(Channel == pBMCInfo->SecondaryIPMBCh)
  1040. // {
  1041. // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.SecondaryIPMBAddr;
  1042. // }
  1043. // else
  1044. // {
  1045. // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
  1046. // }
  1047. // /*Change the encapsulated request's LUN based on originating KCS interface */
  1048. // pIPMIMsgHdr->RqSeqLUN = (pIPMIMsgHdr->RqSeqLUN & 0xFC) | (*kcsifcnum + 0x01);
  1049. // m_MsgPkt.Data[ReqLen - 2] = CalculateCheckSum2 (( uint8_t*)pIPMIMsgHdr, ReqLen - Offset - 1);
  1050. // pBMCInfo->BridgeMsgKCSIfc = *kcsifcnum;
  1051. // }
  1052. printf ("SendMsgCmd:Posting to interface ");
  1053. int y;
  1054. for(y=0;y<m_MsgPkt.Size;y++)
  1055. printf("%#x ", m_MsgPkt.Data[y]);
  1056. printf("\n");
  1057. m_MsgPkt.Cmd = PAYLOAD_IPMI_MSG;
  1058. /* Post the message to interface */
  1059. if (0 != PostMsg (m_MsgPkt.SrcQ, &m_MsgPkt))
  1060. {
  1061. printf ("SendMsg: Failed to post message to interface queue\n");
  1062. }
  1063. pSendMsgRes->CompletionCode = CC_NORMAL;
  1064. }
  1065. return ResLen;
  1066. }
  1067. ///*---------------------------------------
  1068. //* ReadEvtMsgBuffer
  1069. //*---------------------------------------*/
  1070. //int
  1071. //ReadEvtMsgBuffer ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1072. //{
  1073. // ReadEvtMsgBufRes_T* pReadEvtMsgBufRes = ( ReadEvtMsgBufRes_T*)pRes;
  1074. //#if GET_MSG_FLAGS != UNIMPLEMENTED
  1075. // GetMsgFlagsRes_T GetMsgFlagsRes;
  1076. //#endif
  1077. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1078. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
  1079. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->EventMutex,WAIT_INFINITE);
  1080. // if (-2 == GetMsg(&m_MsgPkt, EVT_MSG_Q, WAIT_NONE, BMCInst))
  1081. // {
  1082. // /*If queue is empty */
  1083. // pReadEvtMsgBufRes->CompletionCode = CC_EVT_MSG_QUEUE_EMPTY;/* Queue is empty */
  1084. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
  1085. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1086. // return sizeof (*pRes);
  1087. // }
  1088. // if (BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg == 0)
  1089. // {
  1090. // pReadEvtMsgBufRes->CompletionCode = CC_EVT_MSG_QUEUE_EMPTY;
  1091. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
  1092. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1093. // return sizeof (*pRes);
  1094. // }
  1095. // BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg--;
  1096. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
  1097. //#if GET_MSG_FLAGS != UNIMPLEMENTED
  1098. // // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
  1099. // GetMsgFlags (NULL, 0, (uint8_t *)&GetMsgFlagsRes,BMCInst);
  1100. // TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
  1101. // GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
  1102. // if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
  1103. //#else
  1104. // if (0 == BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg)
  1105. //#endif
  1106. // {
  1107. // /* if there is no messssage in buffer reset SMS/EVT ATN bit */
  1108. // // CLEAR_SMS_ATN ();
  1109. // if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
  1110. // {
  1111. // CLEAR_SMS_ATN (0, BMCInst);
  1112. // }
  1113. // if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
  1114. // {
  1115. // CLEAR_SMS_ATN (1, BMCInst);
  1116. // }
  1117. // if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
  1118. // {
  1119. // CLEAR_SMS_ATN (2, BMCInst);
  1120. // }
  1121. // }
  1122. // /* clear EventMessageBuffer full flag */
  1123. // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x02;
  1124. // pReadEvtMsgBufRes->CompletionCode = CC_NORMAL; /* Completion Code */
  1125. // /* copy the Message data */
  1126. // _fmemcpy (pReadEvtMsgBufRes->ResData, m_MsgPkt.Data, m_MsgPkt.Size);
  1127. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1128. // return sizeof (ReadEvtMsgBufRes_T);
  1129. //}
  1130. ///*---------------------------------------
  1131. //* GetBTIfcCap
  1132. //*---------------------------------------*/
  1133. //int
  1134. //GetBTIfcCap ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1135. //{
  1136. // GetBTIfcCapRes_T* pGetBTIfcCapRes = ( GetBTIfcCapRes_T*)pRes;
  1137. // pGetBTIfcCapRes->CompletionCode = CC_NORMAL;
  1138. // pGetBTIfcCapRes->NumReqSupported = 2;
  1139. // pGetBTIfcCapRes->InputBufSize = MAX_BT_PKT_LEN;
  1140. // pGetBTIfcCapRes->OutputBufSize = MAX_BT_PKT_LEN;
  1141. // pGetBTIfcCapRes->RespTime = 1;
  1142. // pGetBTIfcCapRes->Retries = 0;
  1143. // return sizeof (GetBTIfcCapRes_T);
  1144. //}
  1145. ///*---------------------------------------
  1146. //* GetSystemGUID
  1147. //*---------------------------------------*/
  1148. //int
  1149. //GetSystemGUID ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1150. //{
  1151. // GetSysGUIDRes_T* pGetSysGUIDRes = ( GetSysGUIDRes_T*)pRes;
  1152. // pGetSysGUIDRes->CompletionCode = CC_NORMAL;
  1153. // LOCK_BMC_SHARED_MEM (BMCInst);
  1154. // _fmemcpy (&pGetSysGUIDRes->Node, BMC_GET_SHARED_MEM (BMCInst)->SystemGUID, 16);
  1155. // UNLOCK_BMC_SHARED_MEM (BMCInst);
  1156. // return sizeof (GetSysGUIDRes_T);
  1157. //}
  1158. #define SUPPORT_IPMI20 0x02
  1159. #define SUPPORT_IPMI15 0x01
  1160. /*---------------------------------------
  1161. * GetChAuthCap
  1162. *---------------------------------------*/
  1163. int
  1164. GetChAuthCap ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  1165. {
  1166. //TODO: dummy data
  1167. // GetChAuthCapReq_T* pGetChAuthCapReq = ( GetChAuthCapReq_T*)pReq;
  1168. GetChAuthCapRes_T* pGetChAuthCapRes = ( GetChAuthCapRes_T*)pRes;
  1169. pGetChAuthCapRes->CompletionCode = CC_NORMAL;
  1170. pGetChAuthCapRes->ChannelNum = LAN_RMCP_CHANNEL;
  1171. pGetChAuthCapRes->AuthType = 0x36;
  1172. pGetChAuthCapRes->PerMsgUserAuthLoginStatus = 0x04;
  1173. pGetChAuthCapRes->ExtCap = 0;
  1174. pGetChAuthCapRes->OEMID[0] = 0;
  1175. pGetChAuthCapRes->OEMID[1] = 0;
  1176. pGetChAuthCapRes->OEMID[2] = 0;
  1177. pGetChAuthCapRes->OEMAuxData = 0;
  1178. return sizeof (GetChAuthCapRes_T);
  1179. }
  1180. /*---------------------------------------
  1181. * GetSessionChallenge
  1182. * Create session in this function
  1183. *---------------------------------------*/
  1184. int
  1185. GetSessionChallenge ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  1186. {
  1187. GetSesChallengeReq_T* pGetSesChalReq = ( GetSesChallengeReq_T*)pReq;
  1188. GetSesChallengeRes_T* pGetSesChalRes = ( GetSesChallengeRes_T*)pRes;
  1189. uint8_t Index;
  1190. uint8_t ChallengeString[CHALLENGE_STR_LEN];
  1191. UserInfo_T *pUserInfo;
  1192. // // Check for Reserved bits
  1193. // if((pGetSesChalReq->AuthType == AUTHTYPE_RESERVED) || (pGetSesChalReq->AuthType > AUTHTYPE_OEM_PROPRIETARY))
  1194. // {
  1195. // pGetSesChalRes->CompletionCode = CC_INV_DATA_FIELD;
  1196. // return sizeof (*pRes);
  1197. // }
  1198. if(pGetSesChalReq->UserName[0] == 0)
  1199. {
  1200. pGetSesChalRes->CompletionCode = 0x82;
  1201. return sizeof (*pRes);
  1202. }
  1203. g_BMCInfo.pUserInfo = NULL;
  1204. pUserInfo = getUserNameInfo(pGetSesChalReq->UserName);
  1205. if(pUserInfo == NULL)
  1206. {
  1207. pGetSesChalRes->CompletionCode = 0x81;
  1208. return sizeof (*pRes);
  1209. }
  1210. // if((pUserInfo->ID != USER_ID) || (pUserInfo->UserStatus == FALSE))
  1211. // {
  1212. // pGetSesChalRes->CompletionCode = 0x81;
  1213. // return sizeof (*pRes);
  1214. // }
  1215. g_BMCInfo.pUserInfo = pUserInfo;
  1216. g_BMCInfo.LanSession.AuthType = pGetSesChalReq->AuthType;
  1217. g_BMCInfo.LanSession.SessionID = 0x1234;//trng_get_true_random_data();
  1218. pGetSesChalRes->CompletionCode = CC_NORMAL;
  1219. pGetSesChalRes->TempSessionID = g_BMCInfo.LanSession.SessionID;
  1220. /* generate Randam Challenge String */
  1221. for(Index=0;Index < CHALLENGE_STR_LEN;Index++)
  1222. {
  1223. ChallengeString[Index] = 0x56;//trng_get_true_random_data()&0xff;
  1224. }
  1225. memcpy(pGetSesChalRes->ChallengeString, ChallengeString, CHALLENGE_STR_LEN);
  1226. return sizeof (GetSesChallengeRes_T);
  1227. }
  1228. /*---------------------------------------
  1229. * ActivateSession
  1230. *---------------------------------------*/
  1231. int
  1232. ActivateSession ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  1233. {
  1234. //TODO: dummy data
  1235. ActivateSesReq_T* pAcvtSesReq = ( ActivateSesReq_T*)pReq;
  1236. ActivateSesRes_T* pAcvtSesRes = ( ActivateSesRes_T*)pRes;
  1237. // /* Initial Outbound Sequence Number cannot be null */
  1238. // if (pAcvtSesReq->OutboundSeq == 0)
  1239. // {
  1240. // pAcvtSesRes->CompletionCode = CC_ACTIVATE_SESS_SEQ_OUT_OF_RANGE;
  1241. // return sizeof(*pRes);
  1242. // }
  1243. // // Check for Reserved bitss
  1244. // if((pAcvtSesReq->AuthType == AUTHTYPE_RESERVED) || (pAcvtSesReq->AuthType > AUTHTYPE_OEM_PROPRIETARY))
  1245. // {
  1246. // pAcvtSesRes->CompletionCode = CC_INV_DATA_FIELD;
  1247. // return sizeof (*pRes);
  1248. // }
  1249. // if ((pAcvtSesReq->Privilege == PRIV_LEVEL_RESERVED) || (pAcvtSesReq->Privilege > PRIV_LEVEL_PROPRIETARY))
  1250. // {
  1251. // pAcvtSesRes->CompletionCode = CC_INV_DATA_FIELD;/* Privilege is Reserved */
  1252. // return sizeof (*pRes);
  1253. // }
  1254. pAcvtSesRes->CompletionCode = CC_NORMAL;
  1255. pAcvtSesRes->AuthType = g_BMCInfo.LanSession.AuthType;
  1256. pAcvtSesRes->SessionID = g_BMCInfo.LanSession.SessionID;
  1257. pAcvtSesRes->InboundSeq = 0x78;//trng_get_true_random_data();
  1258. pAcvtSesRes->Privilege = 0x04;
  1259. return sizeof (ActivateSesRes_T);
  1260. }
  1261. /*---------------------------------------
  1262. * SetSessionPrivLevel
  1263. *---------------------------------------*/
  1264. int
  1265. SetSessionPrivLevel ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  1266. {
  1267. SetSesPrivLevelReq_T* pSetSesPrivLevelReq = ( SetSesPrivLevelReq_T*)pReq;
  1268. SetSesPrivLevelRes_T* pSetSesPrivLevelRes = ( SetSesPrivLevelRes_T*)pRes;
  1269. //Check for Reserved bits
  1270. if((pSetSesPrivLevelReq->Privilege == PRIV_LEVEL_CALLBACK) || (pSetSesPrivLevelReq->Privilege > PRIV_LEVEL_PROPRIETARY))
  1271. {
  1272. pSetSesPrivLevelRes->CompletionCode = CC_INV_DATA_FIELD;
  1273. return sizeof(SetSesPrivLevelRes_T);
  1274. }
  1275. /* According to the IPMI 2.0 Priv Level =1 is reserved */
  1276. if((PRIV_USER != pSetSesPrivLevelReq->Privilege) &&
  1277. (PRIV_OPERATOR != pSetSesPrivLevelReq->Privilege) &&
  1278. (PRIV_ADMIN != pSetSesPrivLevelReq->Privilege) &&
  1279. (PRIV_OEM != pSetSesPrivLevelReq->Privilege))
  1280. {
  1281. /*Requested Privilege exceeds ChannelPrivilege Limit */
  1282. pSetSesPrivLevelRes->CompletionCode = CC_INV_DATA_FIELD;
  1283. return sizeof (*pRes);
  1284. }
  1285. pSetSesPrivLevelRes->CompletionCode = CC_NORMAL;
  1286. pSetSesPrivLevelRes->Privilege = pSetSesPrivLevelReq->Privilege;
  1287. return sizeof (SetSesPrivLevelRes_T);
  1288. }
  1289. /*---------------------------------------
  1290. * CloseSession
  1291. *---------------------------------------*/
  1292. int
  1293. CloseSession ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  1294. {
  1295. //TODO: dymmy data
  1296. *pRes = CC_NORMAL;
  1297. return sizeof (*pRes);
  1298. }
  1299. //#if GET_SESSION_INFO != UNIMPLEMENTED
  1300. ///*---------------------------------------
  1301. //* GetSessionInfo
  1302. //*---------------------------------------*/
  1303. //int
  1304. //GetSessionInfo ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1305. //{
  1306. // GetSesInfoReq_T* pGetSesInfoReq = ( GetSesInfoReq_T*)pReq;
  1307. // GetSesInfoRes_T* pGetSesInfoRes = ( GetSesInfoRes_T*)pRes;
  1308. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1309. // LANSesInfoRes_T LANSesInfo;
  1310. // LANIPv6SesInfoRes_T LANIPv6SesInfo;
  1311. // SessionInfo_T* pSessInfo;
  1312. // ChannelInfo_T* pChannelInfo;
  1313. // void* SessionArg;
  1314. // uint8_t SessionArgAlign[4];
  1315. // uint8_t SessionArgType,EthIndex, netindex = 0xFF;
  1316. // char IfcName[IFNAMSIZ];
  1317. // uint32_t *CurSesID,*curchannel;
  1318. // int i;
  1319. // *pRes = CC_REQ_INV_LEN;
  1320. // switch (pGetSesInfoReq->SessionIndex)
  1321. // {
  1322. // case 0:
  1323. // /* Get session information for this session */
  1324. // if (1 != ReqLen)
  1325. // {
  1326. // return sizeof (*pRes);
  1327. // }
  1328. // SessionArgType = SESSION_ID_INFO;
  1329. // OS_THREAD_TLS_GET(g_tls.CurSessionID,CurSesID);
  1330. // SessionArg = CurSesID;
  1331. // break;
  1332. // case 0xFF:
  1333. // if (5 != ReqLen)
  1334. // {
  1335. // return sizeof (*pRes);
  1336. // }
  1337. // SessionArgType = SESSION_ID_INFO;
  1338. // SessionArgAlign[0] = pGetSesInfoReq->SessionHandleOrID[0];
  1339. // SessionArgAlign[1] = pGetSesInfoReq->SessionHandleOrID[1];
  1340. // SessionArgAlign[2] = pGetSesInfoReq->SessionHandleOrID[2];
  1341. // SessionArgAlign[3] = pGetSesInfoReq->SessionHandleOrID[3];
  1342. // SessionArg = SessionArgAlign;
  1343. // break;
  1344. // case 0xFE:
  1345. // if (2 != ReqLen)
  1346. // {
  1347. // return sizeof (*pRes);
  1348. // }
  1349. // if (pGetSesInfoReq->SessionHandleOrID[0] == 0)
  1350. // {
  1351. // *pRes=CC_INV_DATA_FIELD;
  1352. // return sizeof (*pRes);
  1353. // }
  1354. // SessionArgType = SESSION_HANDLE_INFO;
  1355. // SessionArgAlign[0] = pGetSesInfoReq->SessionHandleOrID[0];
  1356. // SessionArgAlign[1] = pGetSesInfoReq->SessionHandleOrID[1];
  1357. // SessionArgAlign[2] = pGetSesInfoReq->SessionHandleOrID[2];
  1358. // SessionArgAlign[3] = pGetSesInfoReq->SessionHandleOrID[3];
  1359. // SessionArg = SessionArgAlign;
  1360. // break;
  1361. // default:
  1362. // if (1 != ReqLen)
  1363. // {
  1364. // return sizeof (*pRes);
  1365. // }
  1366. // SessionArgType = SESSION_INDEX_INFO;
  1367. // SessionArg = &pGetSesInfoReq->SessionIndex;
  1368. // break;
  1369. // }
  1370. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SessionTblMutex, WAIT_INFINITE);
  1371. // pSessInfo = getSessionInfo (SessionArgType, SessionArg, BMCInst);
  1372. // if (NULL == pSessInfo)
  1373. // {
  1374. // TDBG ("GetSessionInfo: pSessInfo is NULL\n");
  1375. // /* if there is no active channel for the current session Index
  1376. // * return the following bytes
  1377. // */
  1378. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  1379. // pChannelInfo = getChannelInfo (*curchannel & 0xF, BMCInst);
  1380. // if(NULL == pChannelInfo)
  1381. // {
  1382. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1383. // pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  1384. // return sizeof (*pRes);
  1385. // }
  1386. // pGetSesInfoRes->CompletionCode = CC_NORMAL;
  1387. // pGetSesInfoRes->SessionHandle = BMC_GET_SHARED_MEM (BMCInst)->SessionHandle;
  1388. // pGetSesInfoRes->NumPossibleActiveSession= pBMCInfo->IpmiConfig.MaxSession;
  1389. // pGetSesInfoRes->NumActiveSession = GetNumOfActiveSessions (BMCInst);
  1390. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1391. // return (sizeof (GetSesInfoRes_T) - sizeof (ActiveSesInfo_T) - sizeof (SessionInfoRes_T));
  1392. // }
  1393. // memset (pGetSesInfoRes,0,sizeof(GetSesInfoRes_T));
  1394. // pChannelInfo = getChannelInfo (pSessInfo->Channel, BMCInst);
  1395. // if(NULL == pChannelInfo)
  1396. // {
  1397. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1398. // pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  1399. // return sizeof (*pRes);
  1400. // }
  1401. // pGetSesInfoRes->CompletionCode = CC_NORMAL;
  1402. // pGetSesInfoRes->SessionHandle = pSessInfo->SessionHandle;
  1403. // pGetSesInfoRes->NumPossibleActiveSession = pBMCInfo->IpmiConfig.MaxSession;
  1404. // pGetSesInfoRes->NumActiveSession = GetNumOfActiveSessions (BMCInst);
  1405. // pGetSesInfoRes->ActiveSesinfo.UserID = pSessInfo->UserId & 0x3F;
  1406. // pGetSesInfoRes->ActiveSesinfo.Privilege = pSessInfo->Privilege & 0x0F;
  1407. // /* Set protocol bit as per Auth Type, bit4 must be 1 for IPMIv2.0 RMCP, 0 for IPMIv1.5 */
  1408. // if( AUTHTYPE_RMCP_PLUS_FORMAT == pSessInfo->AuthType )
  1409. // {
  1410. // pGetSesInfoRes->ActiveSesinfo.ChannelNum = (pSessInfo->Channel & 0x0F) | 0x10;
  1411. // }else
  1412. // {
  1413. // pGetSesInfoRes->ActiveSesinfo.ChannelNum = pSessInfo->Channel & 0x0F;
  1414. // }
  1415. // EthIndex= GetEthIndex(pSessInfo->Channel & 0x0F, BMCInst);
  1416. // if(0xff == EthIndex)
  1417. // {
  1418. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1419. // *pRes = CC_INV_DATA_FIELD;
  1420. // DeleteSession (pSessInfo,BMCInst);
  1421. // return sizeof (uint8_t);
  1422. // }
  1423. // memset(IfcName,0,sizeof(IfcName));
  1424. // /*Get the EthIndex*/
  1425. // if(GetIfcName(EthIndex,IfcName, BMCInst) == -1)
  1426. // {
  1427. // TCRIT("Error in Getting Ifc name\n");
  1428. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1429. // *pRes = CC_INV_DATA_FIELD;
  1430. // return sizeof (uint8_t);
  1431. // }
  1432. // for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
  1433. // {
  1434. // if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
  1435. // {
  1436. // netindex= Ifcnametable[i].Index;
  1437. // break;
  1438. // }
  1439. // }
  1440. // if(netindex == 0xFF)
  1441. // {
  1442. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1443. // *pRes = CC_INV_DATA_FIELD;
  1444. // return sizeof (uint8_t);
  1445. // }
  1446. // if (IsLANChannel( pSessInfo->Channel, BMCInst))
  1447. // {
  1448. // if(g_corefeatures.global_ipv6 == ENABLED)
  1449. // {
  1450. // if(GetIPAdrressType(&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[0])==4)
  1451. // {
  1452. // memset(&LANSesInfo,0,sizeof(LANSesInfo));
  1453. // /* IP Address */
  1454. // _fmemcpy (&(LANSesInfo.IPAddress),
  1455. // &pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[sizeof(struct in6_addr)-sizeof(struct in_addr)],
  1456. // sizeof(struct in_addr));
  1457. // /* MAC Address */
  1458. // if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
  1459. // nwGetSrcCacheMacAddr((uint8_t*)&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[12],
  1460. // netindex, pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
  1461. // _fmemcpy(LANSesInfo.MACAddress, pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
  1462. // /* Port number */
  1463. // LANSesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
  1464. // _fmemcpy ((pRes+sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)),&LANSesInfo, sizeof (LANSesInfoRes_T));
  1465. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1466. // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)+sizeof (LANSesInfoRes_T));
  1467. // }
  1468. // else
  1469. // {
  1470. // /* IP Address */
  1471. // memset(&LANIPv6SesInfo,0,sizeof(LANIPv6SesInfo));
  1472. // _fmemcpy (&(LANIPv6SesInfo.IPv6Address),
  1473. // pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr,
  1474. // sizeof(struct in6_addr));
  1475. // /* MAC Address */
  1476. // if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
  1477. // nwGetSrcMacAddr_IPV6((uint8_t*)&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr,
  1478. // pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
  1479. // _fmemcpy(LANIPv6SesInfo.MACAddress, pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
  1480. // /* Port number */
  1481. // LANIPv6SesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
  1482. // _fmemcpy ((pRes+sizeof (GetSesInfoRes_T) - sizeof(SessionInfoRes_T)),&LANIPv6SesInfo, sizeof (LANIPv6SesInfoRes_T));
  1483. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1484. // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)+sizeof (LANIPv6SesInfoRes_T));
  1485. // }
  1486. // }
  1487. // else
  1488. // {
  1489. // /* IP Address */
  1490. // _fmemcpy (pGetSesInfoRes->SesInfo.LANSesInfo.IPAddress,
  1491. // pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr,
  1492. // sizeof (pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr));
  1493. // /* MAC Address */
  1494. // if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
  1495. // nwGetSrcCacheMacAddr((uint8_t*)pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr, netindex,
  1496. // pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
  1497. // _fmemcpy(pGetSesInfoRes->SesInfo.LANSesInfo.MACAddress,
  1498. // pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
  1499. // /* Port number */
  1500. // pGetSesInfoRes->SesInfo.LANSesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
  1501. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1502. // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T) + sizeof (LANSesInfoRes_T));
  1503. // }
  1504. // }
  1505. // else if (pBMCInfo->IpmiConfig.SerialIfcSupport == 1 && pBMCInfo->SERIALch== pSessInfo->Channel)
  1506. // {
  1507. // pChannelInfo = getChannelInfo (pBMCInfo->SERIALch, BMCInst);
  1508. // if(NULL == pChannelInfo)
  1509. // {
  1510. // pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  1511. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1512. // return sizeof (*pRes);
  1513. // }
  1514. // pGetSesInfoRes->SesInfo.SerialSesInfo.SessionActivityType = 0;
  1515. // pGetSesInfoRes->SesInfo.SerialSesInfo.DestinationSelector = 0;
  1516. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1517. // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T) + sizeof (SerialSesInfoRes_T));
  1518. // }
  1519. // else
  1520. // {
  1521. // pChannelInfo = getChannelInfo(pSessInfo->Channel, BMCInst);
  1522. // if(NULL == pChannelInfo)
  1523. // {
  1524. // pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  1525. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1526. // return sizeof (*pRes);
  1527. // }
  1528. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1529. // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T));
  1530. // }
  1531. //}
  1532. //#endif
  1533. ///**
  1534. // * @fn GetAuthCodeForTypeV15
  1535. // * @brief This function will use the encryption technique supported
  1536. // * in IPMI V1.5 in order to produce Auth Code.
  1537. // * @param[in] pUserInfo - Pointer to User info structure.
  1538. // * @param[in] pGetAuthCodeReq - Pointer to the structure of request data
  1539. // * @param[out] pGetAuthCodeRes - Pointer to the resultant data.
  1540. // * @retval size of the result data.
  1541. // */
  1542. //static int
  1543. //GetAuthCodeForTypeV15 (UserInfo_T* pUserInfo,
  1544. // GetAuthCodeReq_T* pGetAuthCodeReq,
  1545. // GetAuthCodeRes_T* pGetAuthCodeRes )
  1546. //{
  1547. // uint8_t AuthCode;
  1548. // uint8_t InBuffer[2*IPMI15_MAX_PASSWORD_LEN + HASH_DATA_LENGTH];
  1549. // char UserPswd[MAX_PASSWD_LEN];
  1550. // uint8_t PwdEncKey[MAX_SIZE_KEY + 1] = {0};
  1551. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1552. // memset(&(pGetAuthCodeRes->AuthCode), 0, AUTH_CODE_HASH_LEN);
  1553. // AuthCode = pGetAuthCodeReq->AuthType & AUTH_CODE_V15_MASK;
  1554. // if((pGetAuthCodeReq->AuthType & (BIT5 | BIT4)) ||
  1555. // (AuthCode == AUTHTYPE_RESERVED) || (AuthCode == AUTHTYPE_NONE) ||
  1556. // (AuthCode == AUTHTYPE_STRAIGHT_PASSWORD) ||
  1557. // (AuthCode > AUTHTYPE_OEM_PROPRIETARY))
  1558. // {
  1559. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1560. // return (sizeof (GetAuthCodeRes_T) - 4);
  1561. // }
  1562. // if (g_corefeatures.userpswd_encryption == ENABLED)
  1563. // {
  1564. // /* Get Encryption Key from the MBMCInfo_t structure */
  1565. // LOCK_BMC_SHARED_MEM(BMCInst);
  1566. // memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
  1567. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1568. // if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[pUserInfo->UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
  1569. // {
  1570. // TCRIT("Error in decrypting the IPMI User password for User ID:%d.\n", pUserInfo->UserId);
  1571. // pGetAuthCodeRes->CompletionCode = CC_UNSPECIFIED_ERR;
  1572. // return sizeof(*pGetAuthCodeRes);
  1573. // }
  1574. // memcpy(&InBuffer[0],UserPswd,IPMI15_MAX_PASSWORD_LEN);
  1575. // }
  1576. // else
  1577. // {
  1578. // memcpy(&InBuffer[0],pUserInfo->UserPassword,IPMI15_MAX_PASSWORD_LEN);
  1579. // }
  1580. // LOCK_BMC_SHARED_MEM(BMCInst);
  1581. // switch (AuthCode)
  1582. // {
  1583. // #if 0 // As per IPMIv2 Markup E4, Straight Password key is Reserved
  1584. // case AUTH_TYPE_PASSWORD: /* Straight password */
  1585. // if (0 == _fmemcmp (pUserInfo->UserPassword,pGetAuthCodeReq->HashData,IPMI15_MAX_PASSWORD_LEN))
  1586. // {
  1587. // _fmemcpy (pGetAuthCodeRes->AuthCode, "OK", 2);
  1588. // }
  1589. // else
  1590. // {
  1591. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1592. // }
  1593. // break;
  1594. // #endif
  1595. // case AUTH_TYPE_MD2: /* MD2 */
  1596. // _fmemcpy (&InBuffer[IPMI15_MAX_PASSWORD_LEN],
  1597. // pGetAuthCodeReq->HashData, HASH_DATA_LENGTH);
  1598. // if (g_corefeatures.userpswd_encryption == ENABLED)
  1599. // {
  1600. // _fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
  1601. // UserPswd, IPMI15_MAX_PASSWORD_LEN);
  1602. // }
  1603. // else
  1604. // {
  1605. // _fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
  1606. // pUserInfo->UserPassword, IPMI15_MAX_PASSWORD_LEN);
  1607. // }
  1608. // AuthCodeCalMD2 (InBuffer, pGetAuthCodeRes->AuthCode, sizeof (InBuffer));
  1609. // break;
  1610. // case AUTH_TYPE_MD5: /* MD5 */
  1611. // _fmemcpy (&InBuffer[IPMI15_MAX_PASSWORD_LEN],
  1612. // pGetAuthCodeReq->HashData, HASH_DATA_LENGTH);
  1613. // if (g_corefeatures.userpswd_encryption == ENABLED)
  1614. // {
  1615. // _fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
  1616. // UserPswd,IPMI15_MAX_PASSWORD_LEN);
  1617. // }
  1618. // else
  1619. // {
  1620. // _fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
  1621. // pUserInfo->UserPassword,IPMI15_MAX_PASSWORD_LEN);
  1622. // }
  1623. // AuthCodeCalMD5 (InBuffer, pGetAuthCodeRes->AuthCode, sizeof (InBuffer));
  1624. // break;
  1625. // default:
  1626. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1627. // }
  1628. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1629. // // IPMI V1.5 AuthCode is only 16 byte.
  1630. // return (sizeof (GetAuthCodeRes_T) - 4);
  1631. //}
  1632. ///**
  1633. // * @fn GetAuthCodeForTypeV20
  1634. // * @brief This function will use the encryption technique supported
  1635. // * in IPMI V2.0 in order to produce Auth Code.
  1636. // * @param[in] pUserInfo - Pointer to User info structure.
  1637. // * @param[in] pGetAuthCodeReq - Pointer to the structure of request data
  1638. // * @param[out] pGetAuthCodeRes - Pointer to the resultant data.
  1639. // * @retval size of the result data.
  1640. // */
  1641. //static int
  1642. //GetAuthCodeForTypeV20 (UserInfo_T* pUserInfo,
  1643. // GetAuthCodeReq_T* pGetAuthCodeReq,
  1644. // GetAuthCodeRes_T* pGetAuthCodeRes )
  1645. //{
  1646. // uint8_t AuthCode;
  1647. // uint8_t UserPasswdLen=0;
  1648. // uint8_t DecVal = 0;
  1649. // uint8_t m_SIK [SESSION_INTEGRITY_KEY_SIZE];
  1650. // char UserPswd[MAX_PASSWD_LEN];
  1651. // unsigned char PwdEncKey[MAX_SIZE_KEY + 1] = {0};
  1652. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1653. // if (g_corefeatures.userpswd_encryption == ENABLED)
  1654. // {
  1655. // /* Get Encryption Key from the MBMCInfo_t structure */
  1656. // LOCK_BMC_SHARED_MEM(BMCInst);
  1657. // memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
  1658. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1659. // if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[pUserInfo->UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
  1660. // {
  1661. // TCRIT("\nError in decrypting the IPMI User password for user with ID:%d.\n", pUserInfo->UserId);
  1662. // pGetAuthCodeRes->CompletionCode = CC_UNSPECIFIED_ERR;
  1663. // return sizeof (*pGetAuthCodeRes);
  1664. // }
  1665. // }
  1666. // else
  1667. // {
  1668. // memcpy(&UserPswd, pUserInfo->UserPassword, MAX_PASSWD_LEN);
  1669. // }
  1670. // /* Calculate password length */
  1671. // UserPasswdLen = _fstrlen (( char*)UserPswd);
  1672. // UserPasswdLen = (UserPasswdLen > MAX_PASSWORD_LEN) ?
  1673. // MAX_PASSWORD_LEN : UserPasswdLen;
  1674. // memset(&(pGetAuthCodeRes->AuthCode), 0, AUTH_CODE_HASH_LEN);
  1675. // AuthCode = pGetAuthCodeReq->AuthType & AUTH_CODE_V20_MASK;
  1676. // /* Validate the Auth Code */
  1677. // if ((AuthCode > MIN_AUTH_CODE_V20) && (AuthCode < MAX_AUTH_CODE_V20))
  1678. // {
  1679. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1680. // return sizeof(GetAuthCodeRes_T);
  1681. // }
  1682. // LOCK_BMC_SHARED_MEM(BMCInst);
  1683. // switch(AuthCode)
  1684. // {
  1685. // case AUTH_NONE: /* none */
  1686. // TDBG ("\nInside AUTH_NONE in GetAuthCode");
  1687. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1688. // break;
  1689. // case AUTH_HMAC_SHA1_96: /* HMAC-SHA1-96 */
  1690. // TDBG ("\nInside AUTH_HMAC_SHA1_96 in GetAuthCode");
  1691. // hmac_sha1 ((uint8_t *)UserPswd, UserPasswdLen,
  1692. // (uint8_t *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1693. // (uint8_t *)m_SIK, SESSION_INTEGRITY_KEY_SIZE);
  1694. // hmac_sha1 ((uint8_t *)m_SIK, SESSION_INTEGRITY_KEY_SIZE,
  1695. // (uint8_t *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1696. // (uint8_t *)&(pGetAuthCodeRes->AuthCode), HMAC_SHA1_96_LEN);
  1697. // DecVal = AUTH_CODE_HASH_LEN - HMAC_SHA1_96_LEN;
  1698. // break;
  1699. // case AUTH_HMAC_MD5_128: /* HMAC-MD5-128 */
  1700. // TDBG ("\nInside AUTH_HMAC_MD5_128 in GetAuthCode");
  1701. // hmac_md5 ((unsigned char*)UserPswd, UserPasswdLen,
  1702. // pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1703. // m_SIK, SESSION_HMAC_MD5_I_KEY_SIZE);
  1704. // hmac_md5 (m_SIK, SESSION_HMAC_MD5_I_KEY_SIZE,
  1705. // pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1706. // (unsigned char *)&(pGetAuthCodeRes->AuthCode),
  1707. // SESSION_HMAC_MD5_I_KEY_SIZE);
  1708. // DecVal = AUTH_CODE_HASH_LEN - SESSION_HMAC_MD5_I_KEY_SIZE;
  1709. // break;
  1710. // case AUTH_MD5_128: /* MD5-128 */
  1711. // TDBG ("\nInside AUTH_MD5_128 in GetAuthCode");
  1712. // MD5_128 ((char *)UserPswd, UserPasswdLen,
  1713. // (char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1714. // (char *)m_SIK, SESSION_MD5_KEY_SIZE);
  1715. // MD5_128 ((char *)m_SIK, SESSION_INTEGRITY_KEY_SIZE,
  1716. // (char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1717. // (char *)&(pGetAuthCodeRes->AuthCode), SESSION_MD5_KEY_SIZE);
  1718. // DecVal = AUTH_CODE_HASH_LEN - SESSION_MD5_KEY_SIZE;
  1719. // break;
  1720. // case AUTH_HMAC_SHA256_128: /* HMAC-SHA256-128 */
  1721. // TDBG ("\nInside AUTH_HMAC_SHA256_128 in GetAuthCode");
  1722. // hmac_sha256 ((unsigned char *)UserPswd, UserPasswdLen,
  1723. // (unsigned char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1724. // (unsigned char *)m_SIK, SHA2_HASH_KEY_SIZE);
  1725. // hmac_sha256 (m_SIK, SHA2_HASH_KEY_SIZE,
  1726. // (unsigned char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1727. // (unsigned char *)&(pGetAuthCodeRes->AuthCode), HMAC_SHA256_128_LEN);
  1728. // DecVal = AUTH_CODE_HASH_LEN - HMAC_SHA256_128_LEN;
  1729. // break;
  1730. // //! TODO: Need support in openssl.
  1731. // default: /* OEM or Reserved */
  1732. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1733. // }
  1734. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1735. // if (DecVal > sizeof(GetAuthCodeRes_T))
  1736. // return sizeof(GetAuthCodeRes_T);
  1737. // else
  1738. // return (sizeof(GetAuthCodeRes_T) - DecVal);
  1739. //}
  1740. ///**
  1741. // * @fn GetAuthCode
  1742. // * @brief This function will encrypt the given 16 byte data with
  1743. // * the algorithm given and return Auth Code.
  1744. // * @param[in] pReq - Request data.
  1745. // * @param[in] ReqLen - Length of the request data.
  1746. // * @param[out] pRes - Result data
  1747. // * @retval size of the result data.
  1748. // */
  1749. //int
  1750. //GetAuthCode ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes )
  1751. //{
  1752. // GetAuthCodeReq_T* pGetAuthCodeReq = ( GetAuthCodeReq_T*)pReq;
  1753. // GetAuthCodeRes_T* pGetAuthCodeRes = ( GetAuthCodeRes_T*)pRes;
  1754. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  1755. // UserInfo_T* pUserInfo;
  1756. // uint8_t AuthType,*curchannel;
  1757. // ChannelInfo_T* pChannelInfo;
  1758. // int nRetSize = 0;
  1759. // /* Check for Reserved Bits */
  1760. // if((pGetAuthCodeReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4)) ||
  1761. // (pGetAuthCodeReq->UserID & (BIT7 | BIT6)))
  1762. // {
  1763. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1764. // return sizeof(*pRes);
  1765. // }
  1766. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  1767. // /* Validate the channel number given */
  1768. // if (CURRENT_CHANNEL_NUM == pGetAuthCodeReq->ChannelNum)
  1769. // {
  1770. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  1771. // pChannelInfo = getChannelInfo(*curchannel & 0xF,BMCInst);
  1772. // }
  1773. // else
  1774. // pChannelInfo = getChannelInfo(pGetAuthCodeReq->ChannelNum,BMCInst);
  1775. // if (NULL == pChannelInfo)
  1776. // {
  1777. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1778. // *pRes = CC_INV_DATA_FIELD;
  1779. // return sizeof(*pRes);
  1780. // }
  1781. // /* Get the user information for the given userID */
  1782. // pUserInfo = getUserIdInfo (pGetAuthCodeReq->UserID,BMCInst);
  1783. // if (NULL == pUserInfo)
  1784. // {
  1785. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1786. // TDBG ("AppDevice.c : GetAuthCode - Invalid user Id\n");
  1787. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1788. // return sizeof (*pRes);
  1789. // }
  1790. // AuthType = pGetAuthCodeReq->AuthType & GET_AUTH_TYPE_MASK;
  1791. // pGetAuthCodeRes->CompletionCode = CC_NORMAL;
  1792. // switch(AuthType)
  1793. // {
  1794. // case AUTH_TYPE_V15: /* IPMI v1.5 AuthCode Algorithms */
  1795. // nRetSize = GetAuthCodeForTypeV15(pUserInfo, pGetAuthCodeReq, pGetAuthCodeRes,BMCInst);
  1796. // break;
  1797. // case AUTH_TYPE_V20: /* IPMI v2.0/RMCP+ Algorithm Number */
  1798. // nRetSize = GetAuthCodeForTypeV20(pUserInfo, pGetAuthCodeReq, pGetAuthCodeRes,BMCInst);
  1799. // break;
  1800. // default:
  1801. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1802. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1803. // return sizeof(*pRes);
  1804. // }
  1805. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1806. // return nRetSize;
  1807. //}
  1808. ///*---------------------------------------
  1809. //* SetChAccess
  1810. //*---------------------------------------*/
  1811. //int
  1812. //SetChAccess ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1813. //{
  1814. // SetChAccessReq_T* pSetChAccessReq = ( SetChAccessReq_T*)pReq;
  1815. // uint8_t ChannelNum, AccessMode;
  1816. // ChannelInfo_T* pNvrChInfo;
  1817. // ChannelInfo_T* pChannelInfo;
  1818. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1819. // uint8_t AccessFlags = 0,i=0,*curchannel;
  1820. //// char ChFilename[MAX_CHFILE_NAME];
  1821. // /* Reserve Bit Checking for Set Channel Acces */
  1822. // for(i=0;i<ReqLen;i++)
  1823. // {
  1824. // if( 0 != (pReq[i] & m_Set_ChReserveBit[i]))
  1825. // {
  1826. // *pRes = CC_INV_DATA_FIELD;
  1827. // return sizeof (*pRes);
  1828. // }
  1829. // }
  1830. // /* Reserve Value checking */
  1831. // if((pReq[1] & 0xC0)== 0xC0 || (pReq[2] & 0xC0) == 0xC0)
  1832. // {
  1833. // *pRes = CC_INV_DATA_FIELD;
  1834. // return sizeof (*pRes);
  1835. // }
  1836. // ChannelNum = pSetChAccessReq->ChannelNum & 0x0F;
  1837. // if (CURRENT_CHANNEL_NUM == ChannelNum)
  1838. // {
  1839. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  1840. // ChannelNum = *curchannel & 0xF;
  1841. // }
  1842. // if (((GetBits (pSetChAccessReq->Privilege, 0x0F)) < PRIV_LEVEL_CALLBACK) ||
  1843. // ((GetBits (pSetChAccessReq->Privilege, 0x0F)) > PRIV_LEVEL_PROPRIETARY))
  1844. // {
  1845. // IPMI_DBG_PRINT_1 ("Invalid Channel Privilege = 0x%x\n", pSetChAccessReq->Privilege);
  1846. // *pRes = CC_INV_DATA_FIELD;
  1847. // return sizeof (*pRes);
  1848. // }
  1849. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  1850. // pChannelInfo = getChannelInfo(ChannelNum, BMCInst);
  1851. // if (NULL == pChannelInfo)
  1852. // {
  1853. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1854. // *pRes = CC_INV_DATA_FIELD;
  1855. // return sizeof (*pRes);
  1856. // }
  1857. // /*point to NVRAM ChannelInfo */
  1858. // pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
  1859. // if (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport)
  1860. // {
  1861. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1862. // /* Channel is sessionless channel this command is not supported */
  1863. // *pRes = CC_SET_CH_COMMAND_NOT_SUPPORTED;
  1864. // return sizeof (*pRes);
  1865. // }
  1866. // AccessMode = pSetChAccessReq->ChannelAccess & 0x07;
  1867. // if(ChannelNum == pBMCInfo->SERIALch)
  1868. // {
  1869. // if( NULL != g_PDKHandle[PDK_SWITCHMUX])
  1870. // {
  1871. // ((void(*)(uint8_t, int))(g_PDKHandle[PDK_SWITCHMUX]))(AccessMode ,BMCInst);
  1872. // }
  1873. // }
  1874. // /* if the requested access mode is supported for the given channel */
  1875. // if (0 == (pChannelInfo->AccessModeSupported & (1 << AccessMode)))
  1876. // {
  1877. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1878. // *pRes = CC_SET_CH_ACCES_MODE_NOT_SUPPORTED;
  1879. // return sizeof (*pRes);
  1880. // }
  1881. // AccessFlags = GetBits (pSetChAccessReq->ChannelAccess, 0xC0);
  1882. // switch (AccessFlags)
  1883. // {
  1884. // case 0:
  1885. // /* dont set channel access */
  1886. // break;
  1887. // case 1:
  1888. // /*set in Non volatile Memory and in voatile Memory */
  1889. // pNvrChInfo->Alerting = GetBits (pSetChAccessReq->ChannelAccess , 0x20);
  1890. // pNvrChInfo->PerMessageAuth = GetBits (pSetChAccessReq->ChannelAccess , 0x10);
  1891. // pNvrChInfo->UserLevelAuth = GetBits (pSetChAccessReq->ChannelAccess , 0x08);
  1892. // pNvrChInfo->AccessMode = AccessMode;
  1893. // /* write to NVRAM */
  1894. // FlushChConfigs((uint8_t*)pNvrChInfo,pNvrChInfo->ChannelNumber,BMCInst);
  1895. // pChannelInfo->Alerting = pNvrChInfo->Alerting;
  1896. // pChannelInfo->PerMessageAuth= pNvrChInfo->PerMessageAuth;
  1897. // pChannelInfo->UserLevelAuth = pNvrChInfo->UserLevelAuth;
  1898. // pChannelInfo->AccessMode = AccessMode;
  1899. // break;
  1900. // case 2:
  1901. // /*set in volatile Memmory only */
  1902. // pChannelInfo->Alerting = GetBits (pSetChAccessReq->ChannelAccess, 0x20);
  1903. // pChannelInfo->PerMessageAuth= GetBits (pSetChAccessReq->ChannelAccess, 0x10);
  1904. // pChannelInfo->UserLevelAuth = GetBits (pSetChAccessReq->ChannelAccess, 0x08);
  1905. // pChannelInfo->AccessMode = AccessMode;
  1906. // }
  1907. // switch (GetBits (pSetChAccessReq->Privilege, 0xC0))
  1908. // {
  1909. // case 0:
  1910. // /* dont set prilivege level */
  1911. // break;
  1912. // case 1:
  1913. // /* set in non volatile mem and volatile memeory*/ /*set privilege*/
  1914. // pNvrChInfo->MaxPrivilege = GetBits (pSetChAccessReq->Privilege, 0x0F);
  1915. // pChannelInfo->MaxPrivilege = pNvrChInfo->MaxPrivilege;
  1916. // break;
  1917. // case 2:
  1918. // /*set privilege*/
  1919. // /* set in volatile memeory only */
  1920. // pChannelInfo->MaxPrivilege = GetBits (pSetChAccessReq->Privilege, 0x0F);
  1921. // }
  1922. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1923. // *pRes = CC_NORMAL;
  1924. // return sizeof (*pRes);
  1925. //}
  1926. ///*---------------------------------------
  1927. //* GetChAccess
  1928. //*---------------------------------------*/
  1929. //int
  1930. //GetChAccess ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1931. //{
  1932. // GetChAccessReq_T* pGetChAccessReq = ( GetChAccessReq_T*)pReq;
  1933. // GetChAccessRes_T* pGetChAccessRes = ( GetChAccessRes_T*)pRes;
  1934. // ChannelInfo_T* pChannelInfo;
  1935. // ChannelInfo_T* pNvrChInfo;
  1936. // uint8_t ChannelNum,AccessFlag,*curchannel;
  1937. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  1938. // /* Check for reserved bits */
  1939. // if((0 != (pGetChAccessReq->ChannelNum & 0xf0)) ||
  1940. // (0 != (pGetChAccessReq-> AccessFlag & 0x3f)))
  1941. // {
  1942. // pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
  1943. // return sizeof (*pRes);
  1944. // }
  1945. // ChannelNum = pGetChAccessReq->ChannelNum & 0x0F;
  1946. // if (CURRENT_CHANNEL_NUM == ChannelNum)
  1947. // {
  1948. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  1949. // ChannelNum = *curchannel & 0xF;
  1950. // }
  1951. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  1952. // pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
  1953. // if (NULL == pChannelInfo)
  1954. // {
  1955. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1956. // pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
  1957. // return sizeof (*pRes);
  1958. // }
  1959. // if (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport)
  1960. // {
  1961. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1962. // /* Channel is sessionless channel this command is not supported */
  1963. // pGetChAccessRes->CompletionCode = CC_GET_CH_COMMAND_NOT_SUPPORTED;
  1964. // return sizeof (*pRes);
  1965. // }
  1966. // AccessFlag = GetBits (pGetChAccessReq->AccessFlag, 0xC0);
  1967. // pGetChAccessRes->CompletionCode = CC_NORMAL;
  1968. // switch (AccessFlag)
  1969. // {
  1970. // case 1:
  1971. // /* Get Channel Information from NVRAM */
  1972. // pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
  1973. // pGetChAccessRes->ChannelAccess = SetBits (0x20, pNvrChInfo->Alerting);
  1974. // pGetChAccessRes->ChannelAccess |= SetBits (0x10, pNvrChInfo->PerMessageAuth);
  1975. // pGetChAccessRes->ChannelAccess |= SetBits (0x08, pNvrChInfo->UserLevelAuth);
  1976. // pGetChAccessRes->ChannelAccess |= SetBits (0x07, pNvrChInfo->AccessMode);
  1977. // pGetChAccessRes->Privilege = SetBits (0x0F, pNvrChInfo->MaxPrivilege);
  1978. // break;
  1979. // case 2:
  1980. // /* Get Channel Information from Volatile RAM */
  1981. // pGetChAccessRes->ChannelAccess = SetBits (0x20, pChannelInfo->Alerting);
  1982. // pGetChAccessRes->ChannelAccess |= SetBits (0x10, pChannelInfo->PerMessageAuth);
  1983. // pGetChAccessRes->ChannelAccess |= SetBits (0x08, pChannelInfo->UserLevelAuth);
  1984. // pGetChAccessRes->ChannelAccess |= SetBits (0x07, pChannelInfo->AccessMode);
  1985. // pGetChAccessRes->Privilege = SetBits (0x0F, pChannelInfo->MaxPrivilege);
  1986. // break;
  1987. // default:
  1988. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1989. // pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
  1990. // return sizeof (*pRes);
  1991. // }
  1992. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1993. // return sizeof (GetChAccessRes_T);
  1994. //}
  1995. ///*---------------------------------------
  1996. //* GetChInfo
  1997. //*---------------------------------------*/
  1998. //int
  1999. //GetChInfo ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  2000. //{
  2001. // GetChInfoReq_T* pGetChInfoReq = ( GetChInfoReq_T*)pReq;
  2002. // GetChInfoRes_T* pGetChInfoRes = ( GetChInfoRes_T*)pRes;
  2003. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  2004. // ChannelInfo_T* pChannelInfo;
  2005. // uint8_t ChannelNum,*curchannel;
  2006. // if(pGetChInfoReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4)) //Check for Reserved bits
  2007. // {
  2008. // pGetChInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  2009. // return sizeof(*pRes);
  2010. // }
  2011. // ChannelNum = pGetChInfoReq->ChannelNum;
  2012. // if (CURRENT_CHANNEL_NUM == ChannelNum)
  2013. // {
  2014. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  2015. // ChannelNum = *curchannel & 0xF;
  2016. //
  2017. // /* UDS, not being a physical channel, will hold LAN properties */
  2018. // if(UDS_CHANNEL == ChannelNum)
  2019. // {
  2020. // ChannelNum = LAN_RMCP_CHANNEL1_TYPE;
  2021. // }
  2022. // }
  2023. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  2024. // pChannelInfo = getChannelInfo(ChannelNum, BMCInst);
  2025. // if (NULL == pChannelInfo)
  2026. // {
  2027. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2028. // pGetChInfoRes->CompletionCode = CC_INV_DATA_FIELD ;
  2029. // return sizeof (*pRes);
  2030. // }
  2031. // pGetChInfoRes->CompletionCode = CC_NORMAL;
  2032. // pGetChInfoRes->ChannelNum = ChannelNum;
  2033. // pGetChInfoRes->ChannelMedium = pChannelInfo->ChannelMedium;
  2034. // pGetChInfoRes->ChannelProtocol = pChannelInfo->ChannelProtocol;
  2035. // pGetChInfoRes->SessionActiveSupport = pChannelInfo->SessionSupport << 6;
  2036. // pGetChInfoRes->SessionActiveSupport |= pChannelInfo->ActiveSession;
  2037. // _fmemcpy (pGetChInfoRes->VendorID, pChannelInfo->ProtocolVendorId,
  2038. // sizeof (pGetChInfoRes->VendorID));
  2039. // _fmemcpy (pGetChInfoRes->AuxiliaryInfo, pChannelInfo->AuxiliaryInfo,
  2040. // sizeof (pGetChInfoRes->AuxiliaryInfo));
  2041. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2042. // return sizeof (GetChInfoRes_T);
  2043. //}
  2044. ///*---------------------------------------
  2045. //* IsChannelSuppGroups
  2046. //*---------------------------------------*/
  2047. //uint8_t IsChannelSuppGroups(uint8_t ChannelNum )
  2048. //{
  2049. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  2050. // ChannelInfo_T* pChannelInfo;
  2051. // if(IsLANChannel(ChannelNum, BMCInst))
  2052. // {
  2053. //
  2054. // pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
  2055. // if(pChannelInfo==NULL)
  2056. // return 0;
  2057. // if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL1_TYPE)
  2058. // {
  2059. // return pChannelInfo->ChannelType;
  2060. // }
  2061. // else
  2062. // {
  2063. // if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL2_TYPE)
  2064. // {
  2065. // return pChannelInfo->ChannelType;
  2066. // }
  2067. // else
  2068. // {
  2069. // if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL3_TYPE)
  2070. // {
  2071. // return pChannelInfo->ChannelType;
  2072. // }
  2073. // else
  2074. // return 0;
  2075. // }
  2076. // }
  2077. // return 0;
  2078. // }
  2079. // else
  2080. // {
  2081. // if (pBMCInfo->IpmiConfig.SerialIfcSupport == 1 && (pBMCInfo->SERIALch != CH_NOT_USED && ChannelNum == pBMCInfo->SERIALch))
  2082. // {
  2083. // pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
  2084. // if(pChannelInfo==NULL)
  2085. // return 0;
  2086. // return pChannelInfo->ChannelType;
  2087. // }
  2088. // else
  2089. // return 0;
  2090. // }
  2091. //}
  2092. ///*---------------------------------------
  2093. //* ModifyUsrGRP
  2094. //*---------------------------------------*/
  2095. //int
  2096. //ModifyUsrGrp(char * UserName,uint8_t ChannelNum,uint8_t OldAccessLimit, uint8_t NewAccessLimit )
  2097. //{
  2098. // char oldgrp[20]="",newgrp[20]="";
  2099. // if(0 == NewAccessLimit)
  2100. // {
  2101. // DeleteUsrFromIPMIGrp(UserName);
  2102. // }
  2103. // if(PRIV_LEVEL_NO_ACCESS == OldAccessLimit)
  2104. // {
  2105. // strcpy(oldgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege].grpname);
  2106. // }
  2107. // else if(IGNORE_ADD_OR_REMOVE != OldAccessLimit)
  2108. // {
  2109. // strcpy(oldgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege+OldAccessLimit].grpname);
  2110. // }
  2111. // if(PRIV_LEVEL_NO_ACCESS == NewAccessLimit)
  2112. // {
  2113. // strcpy(newgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege].grpname);
  2114. // }
  2115. // else if(IGNORE_ADD_OR_REMOVE != NewAccessLimit)
  2116. // {
  2117. // strcpy(newgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege+NewAccessLimit].grpname);
  2118. // }
  2119. // AddIPMIUsrtoChGrp(UserName,(char *)oldgrp,(char *)newgrp);
  2120. // return 0;
  2121. //}
  2122. /*---------------------------------------
  2123. * SetUserAccess
  2124. *---------------------------------------*/
  2125. int
  2126. SetUserAccess ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  2127. {
  2128. SetUserAccessReq_T* pSetUserAccessReq = ( SetUserAccessReq_T*)pReq;
  2129. UserInfo_T* pUserInfo;
  2130. if (ReqLen == sizeof(SetUserAccessReq_T) - sizeof(pSetUserAccessReq->SessionLimit) )
  2131. {
  2132. pSetUserAccessReq->SessionLimit = 0;
  2133. }
  2134. else if(ReqLen == sizeof(SetUserAccessReq_T))
  2135. {
  2136. if(0 != pSetUserAccessReq->SessionLimit)
  2137. {
  2138. *pRes = CC_INV_DATA_FIELD;
  2139. return sizeof (*pRes);
  2140. }
  2141. }
  2142. else
  2143. {
  2144. *pRes = CC_REQ_INV_LEN;
  2145. return sizeof (*pRes);
  2146. }
  2147. pUserInfo = getUserIdInfo(pSetUserAccessReq->UserID);
  2148. if (NULL == pUserInfo)
  2149. {
  2150. printf ("AppDevice.c : SetUserAccess - Invalid user Id\n");
  2151. *pRes = CC_INV_DATA_FIELD;
  2152. return sizeof (*pRes);
  2153. }
  2154. // if (pUserInfo->ID != USER_ID)
  2155. // {
  2156. // printf("Invalid data field\n");
  2157. // *pRes = CC_INV_DATA_FIELD;
  2158. // return sizeof (*pRes);
  2159. // }
  2160. // pUserInfo->ChannelAccess = (pSetUserAccessReq->ChannelNoUserAccess&0x70) | (pSetUserAccessReq->AccessLimit&0x0f);
  2161. *pRes = CC_NORMAL;
  2162. return sizeof (*pRes);
  2163. }
  2164. /*---------------------------------------
  2165. * GetUserAccess
  2166. *---------------------------------------*/
  2167. int
  2168. GetUserAccess ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  2169. {
  2170. GetUserAccessReq_T* pGetUserAccessReq = ( GetUserAccessReq_T*)pReq;
  2171. GetUserAccessRes_T* pGetUserAccessRes = ( GetUserAccessRes_T*)pRes;
  2172. UserInfo_T* pUserInfo;
  2173. pUserInfo = getUserIdInfo (pGetUserAccessReq->UserID);
  2174. if (NULL == pUserInfo)
  2175. {
  2176. pGetUserAccessRes->CompletionCode = CC_INV_DATA_FIELD;
  2177. return sizeof (*pRes);
  2178. }
  2179. pGetUserAccessRes->CompletionCode = CC_NORMAL;
  2180. pGetUserAccessRes->MaxNoUserID = MAX_USER_NUM;
  2181. pGetUserAccessRes->CurrentUserID = g_BMCInfo.CurrentNoUser;
  2182. pGetUserAccessRes->FixedUserID = 0;
  2183. //pGetUserAccessRes->ChannelAccess = pUserInfo->ChannelAccess;
  2184. return sizeof (GetUserAccessRes_T);
  2185. }
  2186. /*---------------------------------------
  2187. * SetUserName
  2188. *---------------------------------------*/
  2189. int
  2190. SetUserName ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  2191. {
  2192. // SetUserNameReq_T* pSetUserNameReq = ( SetUserNameReq_T*)pReq;
  2193. // UserInfo_T* pUserInfo;
  2194. // uint8_t i;
  2195. // uint8_t UserName[MAX_USERNAME_LEN + 1]; //plus 1 for null terminator
  2196. // uint8_t InvalidChar[]={ ' ' , ',' , '.' , '/' , ':' , ';' , '\\' , '(', ')' , 0x01 ,
  2197. // 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09, 0x0A ,
  2198. // 0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 , 0x11 , 0x12, 0x13 ,
  2199. // 0x14 , 0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1A , 0x1B, 0x1C ,
  2200. // 0x1D , 0x1E , 0x1F , 0x7F} ;
  2201. // // Check for Reserved bits
  2202. // if(pSetUserNameReq->UserID & (BIT7 | BIT6) || (pSetUserNameReq->UserID == 0x00))
  2203. // {
  2204. // *pRes = CC_INV_DATA_FIELD;
  2205. // return sizeof(*pRes);
  2206. // }
  2207. // /*User Id exceeded the limit or Cant set NULL User */
  2208. // if (pSetUserNameReq->UserID > MAX_USER_NUM )
  2209. // {
  2210. // *pRes = CC_INV_DATA_FIELD ;
  2211. // return sizeof (*pRes);
  2212. // }
  2213. // pUserInfo = getUserIdInfo(pSetUserNameReq->UserID);
  2214. // /* We should not set the NULL user */
  2215. // if(0== pSetUserNameReq->UserName [0] )
  2216. // {
  2217. // printf("\n Setting the NULL user :%x",pSetUserNameReq->UserID);
  2218. // *pRes = CC_INV_DATA_FIELD ;
  2219. // return sizeof (*pRes);
  2220. // }
  2221. // /* check for numeric first char and special chars */
  2222. // if( (pSetUserNameReq->UserName[0] >= '0') && (pSetUserNameReq->UserName[0] <= '9') )
  2223. // {
  2224. // *pRes = CC_INV_DATA_FIELD;
  2225. // return sizeof(*pRes);
  2226. // }
  2227. // else
  2228. // {
  2229. // strncpy((char *)UserName,(const char *) pSetUserNameReq->UserName, sizeof(pSetUserNameReq->UserName));
  2230. // UserName[MAX_USERNAME_LEN] = '\0';
  2231. // for(i=0;i<sizeof(InvalidChar);i++)
  2232. // {
  2233. // if( NULL != strchr((const char *)UserName, InvalidChar[i] ))
  2234. // {
  2235. // *pRes = CC_INV_DATA_FIELD;
  2236. // return sizeof(*pRes);
  2237. // }
  2238. // }
  2239. // }
  2240. // //Don't check duplicated user names for 0xFF, this request is for deleting user
  2241. // if(0xFF != pSetUserNameReq->UserName [0])
  2242. // {
  2243. // //checking for Duplicate user names
  2244. // if(CheckForDuplicateUsers(pSetUserNameReq->UserName)==FALSE)
  2245. // {
  2246. // //setting user's name with same name
  2247. // if(!strncmp((char *)pUserInfo->UserName,(char *)pSetUserNameReq->UserName, MAX_USERNAME_LEN))
  2248. // {
  2249. // *pRes = CC_NORMAL;
  2250. // return sizeof (*pRes);
  2251. // }
  2252. // printf("Duplicate ipmi user!!\n");
  2253. // *pRes = CC_INV_DATA_FIELD;
  2254. // return sizeof (*pRes);
  2255. // }
  2256. // }
  2257. // /* If User[0] is 0xFF means the user is requested to delete */
  2258. // if (0xFF == pSetUserNameReq->UserName [0]) //delete user
  2259. // {
  2260. // if( (g_BMCInfo.IpmiConfig.CurrentNoUser > 1) && (USER_ID == pUserInfo->ID))
  2261. // {
  2262. // if(pUserInfo->UserStatus == TRUE)
  2263. // {
  2264. // g_BMCInfo.IpmiConfig.CurrentNoUser--;
  2265. // }
  2266. // /* Delete the user both in Volatile & Non Volatile memory*/
  2267. // memset (pUserInfo, 0, sizeof (UserInfo_T));
  2268. // }
  2269. // else
  2270. // {
  2271. // *pRes = CC_INV_DATA_FIELD ;
  2272. // return sizeof (*pRes);
  2273. // }
  2274. // }
  2275. // else if(USER_ID != pUserInfo->ID) //add user
  2276. // {
  2277. // /* If First time-if user ID does not exist */
  2278. // /* if the user name is set for the first time */
  2279. // pUserInfo->ID = USER_ID;
  2280. // pUserInfo->UserId = pSetUserNameReq->UserID;
  2281. // pUserInfo->UserStatus = FALSE;
  2282. // memcpy(pUserInfo->UserName, pSetUserNameReq->UserName, MAX_USERNAME_LEN);
  2283. // //g_BMCInfo.IpmiConfig.CurrentNoUser++;
  2284. // }
  2285. // else if (USER_ID == pUserInfo->ID)//modifying users
  2286. // {
  2287. // memcpy (pUserInfo->UserName, pSetUserNameReq->UserName, MAX_USERNAME_LEN);
  2288. // }
  2289. // UpdateFlash();
  2290. *pRes = CC_NORMAL;
  2291. return sizeof (*pRes);
  2292. }
  2293. /*---------------------------------------
  2294. * GetUserName
  2295. *---------------------------------------*/
  2296. int
  2297. GetUserName ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  2298. {
  2299. GetUserNameReq_T* pGetUserNameReq = ( GetUserNameReq_T*)pReq;
  2300. GetUserNameRes_T* pGetUserNameRes = ( GetUserNameRes_T*)pRes;
  2301. UserInfo_T* pUserInfo;
  2302. // // Check for Reserved bits
  2303. // if(pGetUserNameReq->UserID & (BIT7 | BIT6) || (pGetUserNameReq->UserID == 0x00))
  2304. // {
  2305. // pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
  2306. // return sizeof(*pRes);
  2307. // }
  2308. if (pGetUserNameReq->UserID >= MAX_USER_NUM)
  2309. {
  2310. /* if user ID exceeded the Max limit */
  2311. pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
  2312. return sizeof (*pRes);/* Invalied user id */
  2313. }
  2314. pUserInfo = getUserIdInfo(pGetUserNameReq->UserID);
  2315. /* if User is disabled or if User is not created */
  2316. //if user is disabled we dont have to return invalid data field
  2317. //instead we return everything possible about the user
  2318. // if pUserInfo is NULL then nothing in the structure at all
  2319. // pUserInfo being NULL is probably not possible
  2320. // If the signature doesnt match then the useris not yet configured
  2321. // so reasonable to return an error
  2322. // if ((NULL == pUserInfo) || (pUserInfo->ID != USER_ID))
  2323. // {
  2324. // /* User with given ID is disabled */
  2325. // *pRes = CC_INV_DATA_FIELD;
  2326. // return sizeof (*pRes);
  2327. // }
  2328. // //if we are here then the user is just disabled
  2329. // if(FALSE == pUserInfo->UserStatus)
  2330. // {
  2331. // printf("user is just dissabled\n");
  2332. // //user is just disabled!!
  2333. // }
  2334. //Err = 0;
  2335. pGetUserNameRes->CompletionCode = CC_NORMAL;
  2336. memcpy (pGetUserNameRes->UserName, pUserInfo->UserName, MAX_USERNAME_LEN);
  2337. return sizeof (GetUserNameRes_T);
  2338. }
  2339. /*---------------------------------------
  2340. * SetUserPassword
  2341. *---------------------------------------*/
  2342. int
  2343. SetUserPassword ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  2344. {
  2345. // SetUserPswdReq_T* pSetUserPswdReq = ( SetUserPswdReq_T*)pReq;
  2346. // UserInfo_T* pUserInfo;
  2347. // uint8_t UserId=0, Operation;
  2348. // uint8_t i;
  2349. // uint8_t UserPassword[ MAX_PASSWORD_LEN + 1 ];
  2350. // uint8_t InvalidChar[] = { 0x01 , 0x02 , 0x03 , 0x04 ,0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0A,
  2351. // 0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 , 0x11 , 0x12 , 0x13 , 0x14,
  2352. // 0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1A , 0x1B , 0x1C , 0x1D , 0x1E ,
  2353. // 0x1F , 0x7F };
  2354. // Operation = pSetUserPswdReq->Operation & 0x03;
  2355. // UserId = pSetUserPswdReq->UserID & 0x3F;
  2356. // /* Reserved bits checking */
  2357. // if((pSetUserPswdReq->UserID & BIT6) || (UserId == 0) || (pSetUserPswdReq->Operation & (BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)))
  2358. // {
  2359. // *pRes = CC_INV_DATA_FIELD;
  2360. // return sizeof (*pRes);
  2361. // }
  2362. // if (ReqLen == IPMI_15_PASSWORD_LEN)
  2363. // {
  2364. // memset (pSetUserPswdReq->Password + 16, 0, 4);
  2365. // }
  2366. // ReqLen -=2;
  2367. // if (UserId > MAX_USER_NUM)
  2368. // {
  2369. // *pRes = CC_INV_DATA_FIELD;
  2370. // return sizeof (*pRes); /*User Id exceeded the limit*/
  2371. // }
  2372. // pUserInfo = getUserIdInfo (UserId);
  2373. // if ( NULL == pUserInfo )
  2374. // {
  2375. // printf ("Invalid User Id \n");
  2376. // *pRes = CC_INV_DATA_FIELD;
  2377. // return sizeof (*pRes);
  2378. // }
  2379. // *pRes = CC_NORMAL;
  2380. // switch (Operation)
  2381. // {
  2382. // case DISABLE_USER:
  2383. // /*disable user */
  2384. // if(pUserInfo == NULL)
  2385. // {
  2386. // //the user is already disabled!!
  2387. // //no point in disabling him again
  2388. // }
  2389. // else
  2390. // {
  2391. // //here we can disable the user
  2392. // if ((pUserInfo->UserStatus == TRUE) && (USER_ID == pUserInfo->ID) && (g_BMCInfo.IpmiConfig.CurrentNoUser > 1))
  2393. // {
  2394. // pUserInfo->UserStatus = FALSE;
  2395. // pUserInfo->ChannelAccess &= 0x0f;
  2396. // g_BMCInfo.IpmiConfig.CurrentNoUser--;
  2397. // UpdateFlash();
  2398. // }
  2399. // }
  2400. // break;
  2401. // case ENABLE_USER:
  2402. // /*enable user */
  2403. // if (USER_ID == pUserInfo->ID)
  2404. // {
  2405. // /* if for the first time then Increment the Current user No */
  2406. // if ( pUserInfo->UserStatus == FALSE )
  2407. // {
  2408. // pUserInfo->UserStatus = TRUE;
  2409. // pUserInfo->ChannelAccess |= 0x70;
  2410. // g_BMCInfo.IpmiConfig.CurrentNoUser++;
  2411. // UpdateFlash();
  2412. // }
  2413. // }
  2414. // else
  2415. // {
  2416. // *pRes = CC_UNSPECIFIED_ERR;
  2417. // return sizeof (*pRes);
  2418. // }
  2419. // break;
  2420. // case SET_PASSWORD:
  2421. // /*set password */
  2422. // if (USER_ID == pUserInfo->ID)
  2423. // {
  2424. // /*check for special characters*/
  2425. // strncpy((char *)UserPassword,(const char *) pSetUserPswdReq->Password, sizeof(pSetUserPswdReq->Password));
  2426. // UserPassword[MAX_PASSWORD_LEN] = '\0';
  2427. // for( i = 0 ; i < sizeof(InvalidChar) ; i++ )
  2428. // {
  2429. // if( NULL != strchr((const char *)UserPassword, InvalidChar[i] ))
  2430. // {
  2431. // *pRes = CC_INV_DATA_FIELD;
  2432. // return sizeof(*pRes);
  2433. // }
  2434. // }
  2435. // pUserInfo->MaxPasswordSize = ReqLen;
  2436. // memcpy (pUserInfo->UserPassword, pSetUserPswdReq->Password, MAX_PASSWORD_LEN);
  2437. // UpdateFlash();
  2438. // }
  2439. // else
  2440. // {
  2441. // *pRes = CC_INV_DATA_FIELD;
  2442. // return sizeof (*pRes);
  2443. // }
  2444. // break;
  2445. // case TEST_PASSWORD:
  2446. // memcpy (UserPassword, pUserInfo->UserPassword, MAX_PASSWORD_LEN);
  2447. // /*Test Password */
  2448. // if( ReqLen != pUserInfo->MaxPasswordSize && (pUserInfo->MaxPasswordSize != 0))
  2449. // {
  2450. // *pRes = CC_PASSWORD_TEST_FAILED_WRONG_SIZE;
  2451. // }
  2452. // else if (((FALSE == pUserInfo->UserStatus) && (pUserInfo->ID != USER_ID)) ||
  2453. // (0 != memcmp (UserPassword, pSetUserPswdReq->Password, MAX_PASSWORD_LEN)))
  2454. // {
  2455. // *pRes = CC_PASSWORD_TEST_FAILED;
  2456. // }
  2457. // break;
  2458. // }
  2459. return sizeof (*pRes);
  2460. }
  2461. ///*---------------------------------------
  2462. //* MasterWriteRead
  2463. //*---------------------------------------*/
  2464. //int
  2465. //MasterWriteRead ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  2466. //{
  2467. // MasterWriteReadReq_T* pMasterWriteReadReq = ( MasterWriteReadReq_T*)pReq;
  2468. // MasterWriteReadRes_T* pMasterWriteReadRes = ( MasterWriteReadRes_T*)pRes;
  2469. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  2470. // uint8_t* OutBuffer;
  2471. // uint8_t* InBuffer;
  2472. // uint8_t ChannelNum, BusID, BusType, SlaveAddr, ReadCount, WriteCount;
  2473. // INT8S BusName[64];
  2474. // int retval = 0;
  2475. // uint8_t OrgReadCount;
  2476. // uint8_t I2CBusId=0;
  2477. // uint8_t DevID = 0; // This will be '0' by Default... /dev/peci0
  2478. // uint8_t Target = 0x30; // This is the Client address. 30h = 48 is Default for CPU0
  2479. // uint8_t Domain = 0; // Multi-Domain support. Default is '0'
  2480. // uint8_t Xmit_Feedback = 0; // If full response is Desired, enable this. Default is '1'
  2481. // uint8_t AWFCS = 0; // Enable AWFCS in the Transmitted packet by Hw. Default is '0'
  2482. // uint8_t Read_Len = 0; // Number of bytes of read back Data from PECI Client
  2483. // uint8_t Write_Len = 0; // Number of bytes of data, host is sending to client
  2484. // uint8_t *Write_Data = NULL; // Pointer to the Data sent by User to the PECI Client
  2485. // uint8_t *Read_Data = NULL; // Pointer to the Data received from PECI Client to be sent to user
  2486. // int ret_val = 0;
  2487. // if(pMasterWriteReadReq->SlaveAddress & BIT0)
  2488. // {
  2489. // *pRes = CC_INV_DATA_FIELD;
  2490. // return sizeof (*pRes);
  2491. // }
  2492. // ReadCount = pMasterWriteReadReq->ReadCount;
  2493. // ChannelNum = GetBits (pMasterWriteReadReq->BusTypeChNo, 0xF0);
  2494. // BusID = GetBits (pMasterWriteReadReq->BusTypeChNo, 0x0E);
  2495. // BusType = GetBits (pMasterWriteReadReq->BusTypeChNo, 0x01);
  2496. // SlaveAddr = (pMasterWriteReadReq->SlaveAddress >> 1);
  2497. // if ((BusType == 0x00 && BusID != 0x00) || ((BusType == 0x01) && (BusID == 0x00)))
  2498. // {
  2499. // *pRes = CC_INV_DATA_FIELD;
  2500. // return sizeof (*pRes);
  2501. // }
  2502. // // Command order:
  2503. // // ipmitool -H <IP> -I lan -U <Username> -P <Password> bus=7 <Slave_Addr> <Read_Len> <Write_Len> <AWFCS> <Domain> <Data>
  2504. // // <bus=7> : Bus# must be 0x07 for comunicating with PECI over IPMI. Other buses are not for this feature
  2505. // // <Slave_Addr> : This is the PECI Client target address.
  2506. // // <Read_Len> : Number of bytes of data to read from the PECI Response
  2507. // // <Write_Len> : Number of bytes of data being written, as per the PECI Spec. Number of Bytes after Domain.
  2508. // // <AWFCS> : 0x01 or 0x00 indicates enabling or disabling of AWFCS feature respectively
  2509. // // <Domain> : 0x01 or 0x00 indicates domain=1 or domain=0 for multi-domain commands respectively
  2510. // // <Data> : Rest of data like Command, and other params as per the PECI Spec.
  2511. // // If BusType is External (0x01) and BusID is 7, then we consider to communicate with PECI
  2512. //
  2513. // if(g_corefeatures.peci_over_ipmi == ENABLED )
  2514. // {
  2515. // if ((BusType & 0x01) && (BusID == 0x07))
  2516. // {
  2517. // DevID = 0;
  2518. // Xmit_Feedback = 0;
  2519. // Target = pMasterWriteReadReq->SlaveAddress;
  2520. // Read_Len = ReadCount;
  2521. // Write_Len = pMasterWriteReadReq->Data[0];
  2522. // AWFCS = pMasterWriteReadReq->Data[1];
  2523. // Domain = pMasterWriteReadReq->Data[2];
  2524. // Write_Data = &pMasterWriteReadReq->Data[3];
  2525. // Read_Data = &pMasterWriteReadRes->Data[0];
  2526. // memset(&pMasterWriteReadRes->Data[0], 0, sizeof(pMasterWriteReadRes->Data));
  2527. //
  2528. // // Call the PECI Generic Handler for passing the command to the PECI Controller
  2529. // if(g_HALPECIHandle[HAL_PECI_COMMAND] != NULL)
  2530. // {
  2531. // ret_val = ((int(*)(char, char, char, char, char, char *, char, char *, char))g_HALPECIHandle[HAL_PECI_COMMAND]) (DevID, Target,
  2532. // Domain, Xmit_Feedback, AWFCS,
  2533. // (char *)Write_Data, Write_Len,
  2534. // (char *)Read_Data, Read_Len );
  2535. // }
  2536. // else
  2537. // {
  2538. // pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  2539. // return sizeof (*pRes);
  2540. // }
  2541. // /* Check if peci issue command operation is success or not */
  2542. // if (ret_val == -1)
  2543. // {
  2544. // pMasterWriteReadRes->CompletionCode = CC_INV_DATA_FIELD;
  2545. // return sizeof (*pRes);
  2546. // }
  2547. // pMasterWriteReadRes->CompletionCode = CC_NORMAL;
  2548. // return (sizeof (*pRes) + ReadCount);
  2549. // }
  2550. // }
  2551. // if(0 ==BusType){
  2552. // if(PRIMARY_IPMB_CHANNEL == ChannelNum)
  2553. // {
  2554. // I2CBusId=pBMCInfo->IpmiConfig.PrimaryIPMBBusNumber;
  2555. // }
  2556. // else if((pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)&&(pBMCInfo->SecondaryIPMBCh == ChannelNum))
  2557. // {
  2558. // I2CBusId=pBMCInfo->IpmiConfig.SecondaryIPMBBusNumber;
  2559. // }else{
  2560. // *pRes = CC_INV_DATA_FIELD;
  2561. // return sizeof (*pRes);
  2562. // }
  2563. // }
  2564. // else
  2565. // {
  2566. // if(BusID==pBMCInfo->IpmiConfig.PrimaryIPMBBusNumber)
  2567. // {
  2568. // *pRes = CC_INV_DATA_FIELD;
  2569. // return sizeof (*pRes);
  2570. // }else if((pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)&&(BusID==pBMCInfo->IpmiConfig.SecondaryIPMBBusNumber))
  2571. // {
  2572. // *pRes = CC_INV_DATA_FIELD;
  2573. // return sizeof (*pRes);
  2574. // }else{
  2575. // I2CBusId=BusID;
  2576. // }
  2577. // }
  2578. // if (ReqLen < 3)
  2579. // {
  2580. // *pRes = CC_REQ_INV_LEN;
  2581. // return sizeof (*pRes);
  2582. // }
  2583. // /* number of bytes to write
  2584. // * = pMasterWriteReadReq length - 3 for Request Data byte -
  2585. // * BusTypeChNo,SlaveAddr,Readcount + 1 byte for address
  2586. // */
  2587. // WriteCount = ReqLen - 3;
  2588. // OutBuffer = (pMasterWriteReadReq->Data);
  2589. // InBuffer = pMasterWriteReadRes->Data;
  2590. // sprintf(BusName,"/dev/i2c%d",I2CBusId);
  2591. // // Save original ReadCount in case we need to modify it
  2592. // OrgReadCount = ReadCount;
  2593. // // If both ReadCount and WriteCount are zero, then force a read of 1 byte.
  2594. // // If we do not do this, the write command will fail.
  2595. // // Having both counts 0 is a way of "pinging" the given device to see if it
  2596. // // is responding to its address.
  2597. //
  2598. // if (ReadCount == 0 && WriteCount == 0)
  2599. // {
  2600. // ReadCount = 1;
  2601. // }
  2602. // if (ReadCount > 0 && WriteCount == 0)
  2603. // {
  2604. // if(g_HALI2CHandle[HAL_I2C_MR] != NULL)
  2605. // {
  2606. // retval = ((int(*)(char *,u8,u8 *,size_t))g_HALI2CHandle[HAL_I2C_MR]) (BusName, SlaveAddr, InBuffer, ReadCount);
  2607. // if (retval < 0)
  2608. // {
  2609. // pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
  2610. // return sizeof (*pRes);
  2611. // }
  2612. // }
  2613. // else
  2614. // {
  2615. // pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  2616. // return sizeof(*pRes);
  2617. // }
  2618. // ReadCount = OrgReadCount;
  2619. // /* copy the bytes read to Response Data */
  2620. // _fmemcpy (pMasterWriteReadRes->Data, InBuffer, ReadCount);
  2621. // }
  2622. // else if(ReadCount > 0 && WriteCount > 0 )
  2623. // {
  2624. // if(g_HALI2CHandle[HAL_I2C_RW] != NULL)
  2625. // {
  2626. // retval = ((int(*)(char *,u8,u8 *,u8 *,size_t,size_t))g_HALI2CHandle[HAL_I2C_RW]) (BusName, SlaveAddr, OutBuffer, InBuffer, WriteCount, ReadCount);
  2627. // if (retval < 0)
  2628. // {
  2629. // pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
  2630. // return sizeof (*pRes);
  2631. // }
  2632. // }
  2633. // else
  2634. // {
  2635. // pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  2636. // return sizeof(*pRes);
  2637. // }
  2638. // ReadCount = OrgReadCount;
  2639. // /* copy the bytes read to Response Data */
  2640. // _fmemcpy (pMasterWriteReadRes->Data, InBuffer, ReadCount);
  2641. // }
  2642. // else
  2643. // {
  2644. // /* No data to read so use master write instead,
  2645. // * otherwise some devices (EEPROM) that have not finished writing
  2646. // * will fail on the read transaction and possibly corrupt data
  2647. // */
  2648. // if(g_HALI2CHandle[HAL_I2C_MW] != NULL)
  2649. // {
  2650. // retval= ((ssize_t(*)(char *,u8,u8 *,size_t))g_HALI2CHandle[HAL_I2C_MW]) (BusName, SlaveAddr, OutBuffer, WriteCount);
  2651. // if(retval < 0)
  2652. // {
  2653. // pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
  2654. // return sizeof (*pRes);
  2655. // }
  2656. // }
  2657. // else
  2658. // {
  2659. // pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  2660. // return sizeof(*pRes);
  2661. // }
  2662. // }
  2663. // pMasterWriteReadRes->CompletionCode = CC_NORMAL;
  2664. // return (sizeof (*pRes) + ReadCount);
  2665. //}
  2666. //#if 0
  2667. ///*-------------------------------------------
  2668. //* ComputeAuthCode
  2669. //*-------------------------------------------*/
  2670. //void
  2671. //ComputeAuthCode ( uint8_t* pPassword, SessionHdr_T* pSessionHdr,
  2672. // IPMIMsgHdr_T* pIPMIMsg, uint8_t* pAuthCode,
  2673. // uint8_t ChannelType)
  2674. //{
  2675. // if (AUTH_TYPE_PASSWORD == pSessionHdr->AuthType)
  2676. // {
  2677. // _fmemcpy (pAuthCode, pPassword, MAX_PASSWORD_LEN);
  2678. // }
  2679. // else
  2680. // {
  2681. // uint8_t AuthBuf [MAX_AUTH_PARAM_SIZE];
  2682. // uint16_t AuthBufLen = 0;
  2683. // uint8_t IPMIMsgLen = *(( uint8_t*) pIPMIMsg - 1);
  2684. // /* Password */
  2685. // _fmemcpy (AuthBuf, pPassword, MAX_PASSWORD_LEN);
  2686. // AuthBufLen += MAX_PASSWORD_LEN;
  2687. // /* Session ID */
  2688. // _fmemcpy (AuthBuf + AuthBufLen, &pSessionHdr->SessionID, sizeof (uint32_t));
  2689. // AuthBufLen += sizeof (uint32_t);
  2690. // /* IPMI Response Message */
  2691. // _fmemcpy (AuthBuf + AuthBufLen, pIPMIMsg, IPMIMsgLen);
  2692. // AuthBufLen += IPMIMsgLen;
  2693. // if (ChannelType == MULTI_SESSION_CHANNEL)
  2694. // {
  2695. // /* Session Sequence Number */
  2696. // _fmemcpy (AuthBuf + AuthBufLen,
  2697. // &pSessionHdr->SessionSeqNum, sizeof (uint32_t));
  2698. // AuthBufLen += sizeof (uint32_t);
  2699. // }
  2700. // /* Password */
  2701. // _fmemcpy (AuthBuf + AuthBufLen, pPassword, MAX_PASSWORD_LEN);
  2702. // AuthBufLen += MAX_PASSWORD_LEN;
  2703. // switch (pSessionHdr->AuthType)
  2704. // {
  2705. // case AUTH_TYPE_MD2 :
  2706. // AuthCodeCalMD2 (AuthBuf, pAuthCode, AuthBufLen);
  2707. // break;
  2708. // case AUTH_TYPE_MD5 :
  2709. // AuthCodeCalMD5 (AuthBuf, pAuthCode, AuthBufLen);
  2710. // break;
  2711. // default :
  2712. // TDBG ("RMCP: Invalid Authentication Type \n");
  2713. // }
  2714. // }
  2715. //}
  2716. //#endif
  2717. ///*---------------------------------------
  2718. //* GetSystemInfoParam
  2719. //*---------------------------------------*/
  2720. //int
  2721. //GetSystemInfoParam ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  2722. //{
  2723. // GetSystemInfoParamReq_T* pGetSysInfoReq = ( GetSystemInfoParamReq_T*)pReq;
  2724. // GetSystemInfoParamRes_T* pGetSysInfoRes = ( GetSystemInfoParamRes_T* ) pRes ;
  2725. // GetSystemInfoParamOEMRes_T* pGetSysInfoOEMRes = ( GetSystemInfoParamOEMRes_T* ) pRes ;
  2726. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  2727. // SystemInfoConfig_T* pSysInfoCfg;
  2728. // uint8_t resSize = sizeof(pGetSysInfoRes->CompletionCode) + sizeof(pGetSysInfoRes->ParamRevision);
  2729. // uint8_t oem_len;
  2730. // unsigned long oem_addr;
  2731. // // Check for Reserved bits
  2732. // if(pGetSysInfoReq->ParamRev & (BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0))
  2733. // {
  2734. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  2735. // return sizeof(pGetSysInfoRes->CompletionCode);
  2736. // }
  2737. // pGetSysInfoRes->CompletionCode = CC_NORMAL;
  2738. // /* Fill the param's older Version and the present version */
  2739. // pGetSysInfoRes->ParamRevision = ((PARAM_OLDER_REVISION << 4) & 0xF0 ) | PARAM_PRESENT_REVISION;
  2740. // /* Check for Revision only parameter */
  2741. // if (pGetSysInfoReq->ParamRev & GET_PARAM_REV_ONLY )
  2742. // {
  2743. // if((MAX_APP_CONF_PARAM >= pGetSysInfoReq->ParamSelector))
  2744. // {
  2745. // return resSize;
  2746. // }
  2747. // else if(( NULL != g_PDKHandle[PDK_GETSYSINFOPARAM]) &&
  2748. // ((MIN_SYSINFO_OEM_CONF_PARAM <= pGetSysInfoReq->ParamSelector) && (MAX_SYSINFO_OEM_CONF_PARAM >= pGetSysInfoReq->ParamSelector)))
  2749. // {
  2750. // oem_len = ((int(*)(uint8_t, unsigned long*,int))(g_PDKHandle[PDK_GETSYSINFOPARAM]))(pGetSysInfoReq->ParamSelector, &oem_addr ,BMCInst);
  2751. // if( oem_len == 0)
  2752. // {
  2753. // pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
  2754. // return sizeof(uint8_t);
  2755. // }
  2756. // else
  2757. // return resSize;
  2758. // }
  2759. // else
  2760. // {
  2761. // *pRes = CC_PARAM_NOT_SUPPORTED;
  2762. // return sizeof (*pRes);
  2763. // }
  2764. // }
  2765. // /* Get Systen Info parameters from NVRAM */
  2766. // pSysInfoCfg = &pBMCInfo->SystemInfoConfig;
  2767. // switch(pGetSysInfoReq->ParamSelector)
  2768. // {
  2769. // case SET_IN_PROGRESS_PARAM: /*Parameter 0 volatile*/
  2770. // if( (0x00 != pGetSysInfoReq->SetSelector) || (0x00 != pGetSysInfoReq->BlockSelector) )
  2771. // {
  2772. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  2773. // return sizeof(pGetSysInfoRes->CompletionCode);
  2774. // }
  2775. // LOCK_BMC_SHARED_MEM(BMCInst);
  2776. // pGetSysInfoRes->SysInfo.SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Sys_SetInProgress;
  2777. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  2778. // resSize++;
  2779. // break;
  2780. // case SYS_FW_VERSION_PARAM:
  2781. // _fmemset(&pGetSysInfoRes->SysInfo.SysVerInfo,0,sizeof(SysVerInfo_T));
  2782. // if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
  2783. // {
  2784. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  2785. // return sizeof(pGetSysInfoRes->CompletionCode);
  2786. // }
  2787. // pGetSysInfoRes->SysInfo.SysVerInfo.SetSelector = pGetSysInfoReq->SetSelector;
  2788. // resSize++;
  2789. // if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
  2790. // {
  2791. // pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[0]=pSysInfoCfg->SysFWVersion.TypeOfEncoding;
  2792. // pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[1]=pSysInfoCfg->SysFWVersion.StringLength;
  2793. // _fmemcpy(&pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[2], pSysInfoCfg->SysFWVersion.SysFWVersionName,MAX_STRING_LENGTH_COPY);
  2794. // resSize += MAX_BLOCK_SIZE;
  2795. // }
  2796. // else
  2797. // {
  2798. // _fmemcpy(&pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[0],
  2799. // &pSysInfoCfg->SysFWVersion.SysFWVersionName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
  2800. // resSize += MAX_BLOCK_SIZE;
  2801. // }
  2802. // break;
  2803. // case SYS_NAME_PARAM:
  2804. // if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
  2805. // {
  2806. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  2807. // return sizeof(pGetSysInfoRes->CompletionCode);
  2808. // }
  2809. // pGetSysInfoRes->SysInfo.SysNameInfo.SetSelector = pGetSysInfoReq->SetSelector;
  2810. // resSize++;
  2811. // if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
  2812. // {
  2813. // pGetSysInfoRes->SysInfo.SysNameInfo.SysName[0]=pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name;
  2814. // pGetSysInfoRes->SysInfo.SysNameInfo.SysName[1]=pSysInfoCfg->SysName.StringLength_Sys_Name;
  2815. // _fmemcpy(&pGetSysInfoRes->SysInfo.SysNameInfo.SysName[2],&pSysInfoCfg->SysName.SystemName,MAX_STRING_LENGTH_COPY);
  2816. // resSize += MAX_BLOCK_SIZE;
  2817. // }
  2818. // else
  2819. // {
  2820. // _fmemcpy(&pGetSysInfoRes->SysInfo.SysNameInfo.SysName[0],
  2821. // &pSysInfoCfg->SysName.SystemName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2], MAX_BLOCK_SIZE);
  2822. // resSize += MAX_BLOCK_SIZE;
  2823. // }
  2824. // break;
  2825. // case PRIM_OS_NAME_PARAM:
  2826. // if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
  2827. // {
  2828. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  2829. // return sizeof(pGetSysInfoRes->CompletionCode);
  2830. // }
  2831. // pGetSysInfoRes->SysInfo.PrimOSInfo.SetSelector = pGetSysInfoReq->SetSelector;
  2832. // resSize++;
  2833. // if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
  2834. // {
  2835. // pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[0]=pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName;
  2836. // pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[1]=pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName;
  2837. // _fmemcpy(&pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[2], &pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName, MAX_STRING_LENGTH_COPY);
  2838. // resSize += MAX_BLOCK_SIZE;
  2839. // }
  2840. // else
  2841. // {
  2842. // _fmemcpy(&pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[0],
  2843. // &pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
  2844. // resSize += MAX_BLOCK_SIZE;
  2845. // }
  2846. // break;
  2847. // case OS_NAME_PARAM:
  2848. // /*Parameter 4 volatile*/
  2849. // _fmemset(&pGetSysInfoRes->SysInfo.OSInfo,0,sizeof(OSInfo_T));
  2850. // if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)||(0x00 != pGetSysInfoReq->BlockSelector))
  2851. // {
  2852. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  2853. // return sizeof(pGetSysInfoRes->CompletionCode);
  2854. // }
  2855. // pGetSysInfoRes->SysInfo.OSInfo.SetSelector = pGetSysInfoReq->SetSelector;
  2856. // resSize++;
  2857. // if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
  2858. // {
  2859. // LOCK_BMC_SHARED_MEM(BMCInst);
  2860. // pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[0]=BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName;
  2861. // pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[1]=BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName;
  2862. // _fmemcpy(&pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[2], BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName, MAX_STRING_LENGTH_COPY);
  2863. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  2864. // resSize += MAX_BLOCK_SIZE;
  2865. // }
  2866. // else
  2867. // {
  2868. // LOCK_BMC_SHARED_MEM(BMCInst);
  2869. // _fmemcpy(&pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[0],
  2870. // &BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
  2871. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  2872. // resSize += MAX_BLOCK_SIZE;
  2873. // }
  2874. //
  2875. // break;
  2876. // default:
  2877. // if(g_PDKHandle[PDK_GETSYSINFOPARAM] != NULL &&
  2878. // (pGetSysInfoReq->ParamSelector >= 192 && pGetSysInfoReq->ParamSelector <= 255))
  2879. // {
  2880. // oem_len = ((int(*)(uint8_t, unsigned long*,int))(g_PDKHandle[PDK_GETSYSINFOPARAM]))(pGetSysInfoReq->ParamSelector, &oem_addr ,BMCInst);
  2881. // if( oem_len == 0)
  2882. // {
  2883. // pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
  2884. // return sizeof(uint8_t);
  2885. // }
  2886. // else
  2887. // {
  2888. // //Acquire the OEM parameters
  2889. // if( oem_len < MSG_PAYLOAD_SIZE - sizeof(GetLanCCRev_T))
  2890. // {
  2891. // memcpy((char*)pGetSysInfoOEMRes + sizeof(GetSystemInfoParamOEMRes_T) ,\
  2892. // (unsigned int*)oem_addr , oem_len);
  2893. // }
  2894. // else
  2895. // {
  2896. // pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
  2897. // return sizeof(uint8_t);
  2898. // }
  2899. // return sizeof(GetSystemInfoParamOEMRes_T) + oem_len;
  2900. // }
  2901. // }
  2902. // else
  2903. // {
  2904. // pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
  2905. // return sizeof(pGetSysInfoRes->CompletionCode);
  2906. // }
  2907. // }
  2908. // /* return the size of the response */
  2909. // return resSize;
  2910. //}
  2911. //int validatestring(uint8_t* String,int len,uint8_t TOE)
  2912. //{
  2913. // int i,delimit = 0,strlen = 0;
  2914. // for(i=0;i<len;i++)
  2915. // {
  2916. // if(String[i] == 0)
  2917. // {
  2918. // delimit++;
  2919. // }
  2920. // else
  2921. // {
  2922. // if(delimit != 0)
  2923. // {
  2924. // if(TOE == UNICODE)
  2925. // {
  2926. // if(delimit == 2)
  2927. // {
  2928. // strlen = strlen + 2;
  2929. // }
  2930. // else
  2931. // {
  2932. // return -1;
  2933. // }
  2934. // }
  2935. // else
  2936. // {
  2937. // if(delimit == 1)
  2938. // {
  2939. // strlen = strlen + 1;
  2940. // }
  2941. // else
  2942. // {
  2943. // return -1;
  2944. // }
  2945. // }
  2946. // delimit = 0;
  2947. // }
  2948. // strlen++;
  2949. // }
  2950. // }
  2951. // return strlen;
  2952. //}
  2953. ///*---------------------------------------
  2954. //* SetSystemInfoParam
  2955. //*---------------------------------------*/
  2956. //int
  2957. //SetSystemInfoParam ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  2958. //{
  2959. // SetSystemInfoParamReq_T* pSetSysInfoReq = ( SetSystemInfoParamReq_T*)pReq;
  2960. // SetSystemInfoParamOEMReq_T* pSetSysInfoOEMReq = ( SetSystemInfoParamOEMReq_T*)pReq;
  2961. // SetSystemInfoParamRes_T* pSetSysInfoRes = ( SetSystemInfoParamRes_T*)pRes;
  2962. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  2963. // SystemInfoConfig_T* pSysInfoCfg;
  2964. // uint8_t *pSetInProgress;
  2965. // unsigned long oem_addr[2]={0}; // use oem_addr[1] as read-only/write-only flag
  2966. // int size,strlen,len;
  2967. // uint8_t OSName[MAX_OS_NAME_LENGTH] = {0};
  2968. // //If the OEM parameter is existing, then skip the length check.
  2969. // if(g_PDKHandle[PDK_SETSYSINFOPARAM] == NULL && (pSetSysInfoReq->ParamSelector < 192 )){
  2970. // if( !( (SET_IN_PROGRESS_PARAM == pSetSysInfoReq->ParamSelector && ( ReqLen == ( sizeof(pSetSysInfoReq->ParamSelector) + sizeof(uint8_t) /* for Data */ ) )) ||
  2971. // ( pSetSysInfoReq->ParamSelector < MAX_PARAM_SELECTOR && ReqLen == ( sizeof(pSetSysInfoReq->ParamSelector) + sizeof(uint8_t) /* for set Selector */ + MAX_BLOCK_SIZE))) )
  2972. // {
  2973. // pSetSysInfoRes->CompletionCode = CC_REQ_INV_LEN;
  2974. // return sizeof(pSetSysInfoRes->CompletionCode);
  2975. // }
  2976. // }
  2977. // pSetInProgress = &BMC_GET_SHARED_MEM(BMCInst)->m_Sys_SetInProgress;
  2978. // pSetSysInfoRes->CompletionCode = CC_NORMAL;
  2979. // /*Get NVRAM System Info Configuration parameters */
  2980. // pSysInfoCfg = &pBMCInfo->SystemInfoConfig;
  2981. // switch (pSetSysInfoReq->ParamSelector)
  2982. // {
  2983. // /*Parameter 0 volatile */
  2984. // case SET_IN_PROGRESS_PARAM:
  2985. // LOCK_BMC_SHARED_MEM(BMCInst);
  2986. // /* If Request for Set In progress */
  2987. // if(( SYS_INFO_SET_IN_PROGRESS == *pSetInProgress ) &&
  2988. // ( SYS_INFO_SET_IN_PROGRESS == pSetSysInfoReq->SysInfo.SetInProgress ))
  2989. // {
  2990. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  2991. // /* Trying to SetinProgress when already in set*/
  2992. // pSetSysInfoRes->CompletionCode = CC_SYS_INFO_SET_IN_PROGRESS ;
  2993. // return sizeof(pSetSysInfoRes->CompletionCode);
  2994. // } else if( SYS_INFO_COMMIT_WRITE == pSetSysInfoReq->SysInfo.SetInProgress )
  2995. // {
  2996. // /* Write SysInfoConfig to NVR */
  2997. // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig,
  2998. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SystemInfoConfig_T),BMCInst);
  2999. // /* Write volatile data to the BMC Shared memory */
  3000. //
  3001. // } else if ( SYS_INFO_SET_COMPLETE == pSetSysInfoReq->SysInfo.SetInProgress )
  3002. // {
  3003. // //PMCONFIG_FILE(BMCInst,PMConfigFile);
  3004. // /* Set it to set Complete */
  3005. // *pSetInProgress = pSetSysInfoReq->SysInfo.SetInProgress;
  3006. // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig,
  3007. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SystemInfoConfig_T),BMCInst);
  3008. // } else if ( SYS_INFO_SET_IN_PROGRESS != pSetSysInfoReq->SysInfo.SetInProgress )
  3009. // {
  3010. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  3011. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3012. // return sizeof(pSetSysInfoRes->CompletionCode);
  3013. // }
  3014. // *pSetInProgress = pSetSysInfoReq->SysInfo.SetInProgress;
  3015. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  3016. // break;
  3017. // case SYS_FW_VERSION_PARAM:
  3018. //
  3019. // if(pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector >= MAX_BLOCK_SIZE)
  3020. // {
  3021. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3022. // return sizeof(pSetSysInfoRes->CompletionCode);
  3023. // }
  3024. // if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector==ZERO_SETSELECTOR)
  3025. // {
  3026. // if(pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]> MAX_FW_VER_LENGTH)
  3027. // {
  3028. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3029. // return sizeof(pSetSysInfoRes->CompletionCode);
  3030. // }
  3031. // if(pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0] > MAX_TYPE_OF_ENCODING)
  3032. // {
  3033. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3034. // return sizeof(pSetSysInfoRes->CompletionCode);
  3035. // }
  3036. // memset(&pSysInfoCfg->SysFWVersion,0,sizeof(pSysInfoCfg->SysFWVersion));
  3037. // pSysInfoCfg->SysFWVersion.TypeOfEncoding=pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0];
  3038. // pSysInfoCfg->SysFWVersion.StringLength=pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1];
  3039. // /*First character should not be a delimiter*/
  3040. // if(pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2] == 0x0 || ((pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0] == UNICODE) && (pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2] == 0x0 || pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[3] == 0x0)))
  3041. // {
  3042. // *pRes = CC_INV_DATA_FIELD;
  3043. // return sizeof(uint8_t);
  3044. // }
  3045. // strlen = validatestring(&pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0]);
  3046. // if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]) || ((pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]))
  3047. // {
  3048. // *pRes = CC_INV_DATA_FIELD;
  3049. // return sizeof(uint8_t);
  3050. // }
  3051. // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
  3052. // {
  3053. // *pRes = CC_INV_DATA_FIELD;
  3054. // return sizeof(uint8_t);
  3055. // }
  3056. // _fmemcpy(&pSysInfoCfg->SysFWVersion.SysFWVersionName[0],&pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2], MAX_STRING_LENGTH_COPY);
  3057. // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig.SysFWVersion,
  3058. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysFWVersion_T),BMCInst);
  3059. // }
  3060. // else
  3061. // {
  3062. // _fmemcpy(&pSysInfoCfg->SysFWVersion.SysFWVersionName[(pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector* MAX_BLOCK_SIZE) - 2],
  3063. // &pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0],MAX_BLOCK_SIZE);
  3064. // len = ((pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
  3065. // strlen = validatestring(&pSysInfoCfg->SysFWVersion.SysFWVersionName[0],len,pSysInfoCfg->SysFWVersion.TypeOfEncoding);
  3066. // if(strlen == -1 || (strlen > pSysInfoCfg->SysFWVersion.StringLength))
  3067. // {
  3068. // *pRes = CC_INV_DATA_FIELD;
  3069. // return sizeof(uint8_t);
  3070. // }
  3071. // /*Check the String length*/
  3072. // if(((len < pSysInfoCfg->SysFWVersion.StringLength) && (len != strlen)) || ((len > pSysInfoCfg->SysFWVersion.StringLength) && (pSysInfoCfg->SysFWVersion.StringLength != strlen)))
  3073. // {
  3074. // *pRes = CC_INV_DATA_FIELD;
  3075. // return sizeof(uint8_t);
  3076. // }
  3077. // if((len == pSysInfoCfg->SysFWVersion.StringLength) && (pSysInfoCfg->SysFWVersion.StringLength != strlen))
  3078. // {
  3079. // *pRes = CC_INV_DATA_FIELD;
  3080. // return sizeof(uint8_t);
  3081. // }
  3082. // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,
  3083. // (uint8_t*)&pBMCInfo->SystemInfoConfig.SysFWVersion,pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysFWVersion_T),BMCInst);
  3084. // }
  3085. // break;
  3086. // case SYS_NAME_PARAM:
  3087. // if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector >= MAX_BLOCK_SIZE )
  3088. // {
  3089. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3090. // return sizeof(pSetSysInfoRes->CompletionCode);
  3091. // }
  3092. // if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector==ZERO_SETSELECTOR)
  3093. // {
  3094. // if((pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1] > MAX_SYS_NAME_LENGTH))
  3095. // {
  3096. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3097. // return sizeof(pSetSysInfoRes->CompletionCode);
  3098. // }
  3099. // if(pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0]>MAX_TYPE_OF_ENCODING)
  3100. // {
  3101. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3102. // return sizeof(pSetSysInfoRes->CompletionCode);
  3103. // }
  3104. // memset(&pSysInfoCfg->SysName,0,sizeof(pSysInfoCfg->SysName));
  3105. // pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name=pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0];
  3106. // pSysInfoCfg->SysName.StringLength_Sys_Name=pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1];
  3107. // /*First character should not be a delimiter*/
  3108. // if(pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2] == 0x0 || ((pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0] == UNICODE) && (pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2] == 0x0 || pSetSysInfoReq->SysInfo.SysNameInfo.SysName[3] == 0x0)))
  3109. // {
  3110. // *pRes = CC_INV_DATA_FIELD;
  3111. // return sizeof(uint8_t);
  3112. // }
  3113. // strlen = validatestring(&pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0]);
  3114. // if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]) || ((pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]))
  3115. // {
  3116. // *pRes = CC_INV_DATA_FIELD;
  3117. // return sizeof(uint8_t);
  3118. // }
  3119. // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
  3120. // {
  3121. // *pRes = CC_INV_DATA_FIELD;
  3122. // return sizeof(uint8_t);
  3123. // }
  3124. // _fmemcpy(&pSysInfoCfg->SysName.SystemName[0], &pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2],MAX_STRING_LENGTH_COPY);
  3125. // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig.SysName,
  3126. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysName_T),BMCInst);
  3127. // }
  3128. // else
  3129. // {
  3130. // _fmemcpy(&pSysInfoCfg->SysName.SystemName[(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector* MAX_BLOCK_SIZE) - 2],
  3131. // &pSetSysInfoReq->SysInfo.SysNameInfo.SysName,MAX_BLOCK_SIZE);
  3132. // len = ((pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
  3133. // strlen = validatestring(&pSysInfoCfg->SysName.SystemName[0],len,pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name);
  3134. // if(strlen == -1 || (strlen > pSysInfoCfg->SysName.StringLength_Sys_Name))
  3135. // {
  3136. // *pRes = CC_INV_DATA_FIELD;
  3137. // return sizeof(uint8_t);
  3138. // }
  3139. // /*Check the String length*/
  3140. // if(((len < pSysInfoCfg->SysName.StringLength_Sys_Name) && (len != strlen)) || ((len > pSysInfoCfg->SysName.StringLength_Sys_Name) && (pSysInfoCfg->SysName.StringLength_Sys_Name != strlen)))
  3141. // {
  3142. // *pRes = CC_INV_DATA_FIELD;
  3143. // return sizeof(uint8_t);
  3144. // }
  3145. // if((len == pSysInfoCfg->SysName.StringLength_Sys_Name) && (pSysInfoCfg->SysName.StringLength_Sys_Name != strlen))
  3146. // {
  3147. // *pRes = CC_INV_DATA_FIELD;
  3148. // return sizeof(uint8_t);
  3149. // }
  3150. // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig.SysName,
  3151. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysName_T),BMCInst);
  3152. // }
  3153. // break;
  3154. // case PRIM_OS_NAME_PARAM:
  3155. // if(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector >= MAX_BLOCK_SIZE )
  3156. // {
  3157. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3158. // return sizeof(pSetSysInfoRes->CompletionCode);
  3159. // }
  3160. // if(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector==ZERO_SETSELECTOR)
  3161. // {
  3162. // if((pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1] > MAX_PRIM_OS_NAME_LENGTH))
  3163. // {
  3164. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3165. // return sizeof(pSetSysInfoRes->CompletionCode);
  3166. //
  3167. // }
  3168. // if(pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0]>MAX_TYPE_OF_ENCODING)
  3169. // {
  3170. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3171. // return sizeof(pSetSysInfoRes->CompletionCode);
  3172. // }
  3173. // memset(&pSysInfoCfg->PrimaryOSName,0,sizeof(pSysInfoCfg->PrimaryOSName));
  3174. // pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName=pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0];
  3175. // pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName=pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1];
  3176. // /*First character should not be a delimiter*/
  3177. // if(pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2] == 0x0 || ((pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0] == UNICODE) && (pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2] == 0x0 || pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[3] == 0x0)))
  3178. // {
  3179. // *pRes = CC_INV_DATA_FIELD;
  3180. // return sizeof(uint8_t);
  3181. // }
  3182. // strlen = validatestring(&pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0]);
  3183. // if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]) || ((pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]))
  3184. // {
  3185. // *pRes = CC_INV_DATA_FIELD;
  3186. // return sizeof(uint8_t);
  3187. // }
  3188. // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
  3189. // {
  3190. // *pRes = CC_INV_DATA_FIELD;
  3191. // return sizeof(uint8_t);
  3192. // }
  3193. // _fmemcpy(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[0], &pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2], MAX_STRING_LENGTH_COPY);
  3194. // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig.PrimaryOSName,
  3195. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(PrimaryOSName_T),BMCInst);
  3196. // }
  3197. // else
  3198. // {
  3199. // _fmemcpy(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector * MAX_BLOCK_SIZE) - 2],
  3200. // &pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName, MAX_BLOCK_SIZE);
  3201. // len = ((pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
  3202. // strlen = validatestring(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[0],len,pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName);
  3203. // if(strlen == -1 || (strlen > pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName))
  3204. // {
  3205. // *pRes = CC_INV_DATA_FIELD;
  3206. // return sizeof(uint8_t);
  3207. // }
  3208. // /*Check the String length*/
  3209. // if(((len < pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (len != strlen)) || ((len > pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName != strlen)))
  3210. // {
  3211. // *pRes = CC_INV_DATA_FIELD;
  3212. // return sizeof(uint8_t);
  3213. // }
  3214. // if((len == pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName != strlen))
  3215. // {
  3216. // *pRes = CC_INV_DATA_FIELD;
  3217. // return sizeof(uint8_t);
  3218. // }
  3219. // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,
  3220. // (uint8_t*)&pBMCInfo->SystemInfoConfig.PrimaryOSName,pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(PrimaryOSName_T),BMCInst);
  3221. // }
  3222. // break;
  3223. // case OS_NAME_PARAM:
  3224. // /*Parameter 4 volatile*/
  3225. // if(pSetSysInfoReq->SysInfo.OSInfo.SetSelector >= MAX_BLOCK_SIZE )
  3226. // {
  3227. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3228. // return sizeof(pSetSysInfoRes->CompletionCode);
  3229. // }
  3230. // if(pSetSysInfoReq->SysInfo.OSInfo.SetSelector==ZERO_SETSELECTOR)
  3231. // {
  3232. // if(pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1] > MAX_OS_NAME_LENGTH)
  3233. // {
  3234. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3235. // return sizeof(pSetSysInfoRes->CompletionCode);
  3236. // }
  3237. // if(pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0] > MAX_TYPE_OF_ENCODING)
  3238. // {
  3239. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3240. // return sizeof(pSetSysInfoRes->CompletionCode);
  3241. // }
  3242. // /*First character should not be a delimiter*/
  3243. // if(pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2] == 0x0 || ((pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0] == UNICODE) && (pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2] == 0x0 || pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[3] == 0x0)))
  3244. // {
  3245. // *pRes = CC_INV_DATA_FIELD;
  3246. // return sizeof(uint8_t);
  3247. // }
  3248. // strlen = validatestring(&pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0]);
  3249. // if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]) || ((pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]))
  3250. // {
  3251. // *pRes = CC_INV_DATA_FIELD;
  3252. // return sizeof(uint8_t);
  3253. // }
  3254. // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
  3255. // {
  3256. // *pRes = CC_INV_DATA_FIELD;
  3257. // return sizeof(uint8_t);
  3258. // }
  3259. // memset(&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName,0,sizeof(OSName_T));
  3260. // LOCK_BMC_SHARED_MEM(BMCInst);
  3261. // BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName=pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0];
  3262. // BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName=pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1];
  3263. // _fmemcpy(&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName, &pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2],
  3264. // MAX_STRING_LENGTH_COPY);
  3265. // UNLOCK_BMC_SHARED_MEM (BMCInst);
  3266. // }
  3267. // else
  3268. // {
  3269. // LOCK_BMC_SHARED_MEM(BMCInst);
  3270. // _fmemcpy(&OSName[0],&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[0],MAX_OS_NAME_LENGTH);
  3271. // _fmemcpy(&OSName[(pSetSysInfoReq->SysInfo.OSInfo.SetSelector * MAX_BLOCK_SIZE) - 2],&pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName,MAX_BLOCK_SIZE);
  3272. // len = ((pSetSysInfoReq->SysInfo.OSInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
  3273. // strlen = validatestring(&OSName[0],len,BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName);
  3274. // if(strlen == -1 || (strlen > BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName))
  3275. // {
  3276. // *pRes = CC_INV_DATA_FIELD;
  3277. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  3278. // return sizeof(uint8_t);
  3279. // }
  3280. // /*Check the String length*/
  3281. // if(((len < BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName) && (len != strlen)) || ((len > BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName) && (BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName != strlen)))
  3282. // {
  3283. // *pRes = CC_INV_DATA_FIELD;
  3284. // return sizeof(uint8_t);
  3285. // }
  3286. // if((len == BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName) && (BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName != strlen))
  3287. // {
  3288. // *pRes = CC_INV_DATA_FIELD;
  3289. // return sizeof(uint8_t);
  3290. // }
  3291. // _fmemcpy(&(BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[(pSetSysInfoReq->SysInfo.OSInfo.SetSelector * MAX_BLOCK_SIZE) - 2]),
  3292. // &pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName,MAX_BLOCK_SIZE);
  3293. // UNLOCK_BMC_SHARED_MEM (BMCInst);
  3294. // }
  3295. // break;
  3296. // default:
  3297. // if(g_PDKHandle[PDK_SETSYSINFOPARAM] != NULL &&
  3298. // (pSetSysInfoReq->ParamSelector >= 192 && pSetSysInfoReq->ParamSelector <= 255))
  3299. // {
  3300. // oem_addr[0] = (unsigned long)((char*)pSetSysInfoOEMReq + sizeof(SetSystemInfoParamOEMReq_T));
  3301. // size = ((int(*)(uint8_t, unsigned long*,int))(g_PDKHandle[PDK_SETSYSINFOPARAM]))(pSetSysInfoReq->ParamSelector, oem_addr ,BMCInst);
  3302. // if(size <= 0)
  3303. // {
  3304. // switch (oem_addr[1]) {
  3305. // case CC_SYS_INFO_READ_ONLY_PARAM:
  3306. // pSetSysInfoRes->CompletionCode = CC_SYS_INFO_READ_ONLY_PARAM;
  3307. // break;
  3308. // default:
  3309. // pSetSysInfoRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
  3310. // }
  3311. // }
  3312. // else
  3313. // {
  3314. // pSetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
  3315. // return sizeof(pSetSysInfoRes->CompletionCode);
  3316. // }
  3317. // }
  3318. // }
  3319. // return sizeof(pSetSysInfoRes->CompletionCode);
  3320. //}
  3321. #endif /* APP_DEVICE */