AppDevice.c 179 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386
  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. #define ENABLE_DEBUG_MACROS 0
  26. #include "Types.h"
  27. #include "Debug.h"
  28. #include "IPMI_Main.h"
  29. #include "SharedMem.h"
  30. #include "Support.h"
  31. #include "Message.h"
  32. #include "IPMIDefs.h"
  33. #include "MsgHndlr.h"
  34. #include "IPMI_IPM.h"
  35. #include "IPMI_AppDevice.h"
  36. #include "AppDevice.h"
  37. #include "RMCP.h"
  38. #include "MD.h"
  39. #include "LANIfc.h"
  40. #include "WDT.h"
  41. #include "NVRAccess.h"
  42. #include "Util.h"
  43. //#include "libipmi_struct.h"
  44. //#include "nwcfg.h"
  45. #include "Ethaddr.h"
  46. //#include "IPMIConf.h"
  47. #include "IPMBIfc.h"
  48. #include "IPMI_KCS.h"
  49. //#include "ipmi_userifc.h"
  50. //#include "hmac_md5.h"
  51. //#include "hmac.h"
  52. //#include "MD5_128.h"
  53. #include "Badpasswd.h"
  54. #include "hal_hw.h"
  55. //#include "iniparser.h"
  56. #include "Session.h"
  57. //#include <linux/if.h>
  58. #include "LANConfig.h"
  59. #include <netdb.h> /* getaddrinfo(3) et al. */
  60. #include <netinet/in.h> /* sockaddr_in & sockaddr_in6 definition. */
  61. //#include "userprivilege.h"
  62. #include <ctype.h>
  63. //#include "PDKBridgeMsg.h"
  64. //#include "featuredef.h"
  65. //#include "blowfish.h"
  66. #include "bmc_main.h"
  67. #include "session.h"
  68. #include "bmc_type.h"
  69. #define USER_ID_ENABLED 0x01
  70. #define USER_ID_DISABLED 0x02
  71. #define OP_USERID_ONLY_LENGTH 2
  72. #define OP_ENABLE_USER_ID 1
  73. #define OP_DISABLE_USER_ID 0
  74. #define BIT3_BIT0_MASK 0xf
  75. #define GET_AUTH_TYPE_MASK 0xc0
  76. #define AUTH_TYPE_V15 0x0
  77. #define AUTH_TYPE_V20 0x40
  78. #define AUTH_CODE_V15_MASK 0x0f
  79. #define AUTH_CODE_V15_1 0x1
  80. #define AUTH_CODE_V15_2 0x2
  81. #define AUTH_CODE_V15_3 0x5
  82. #define AUTH_CODE_V20_MASK 0x3f
  83. #define MIN_AUTH_CODE_V20 0x04
  84. #define MAX_AUTH_CODE_V20 0xc0
  85. #define NULL_USER 1
  86. #define ZERO_SETSELECTOR 0x00
  87. #define MAX_TYPE_OF_ENCODING 0x02
  88. #define MAX_STRING_LENGTH_COPY 14
  89. #define ASCII_LATIN1 0x00
  90. #define UTF_8 0x01
  91. #define UNICODE 0x02
  92. /* Reserved bit macro definitions */
  93. #define RESERVED_BITS_SENDMS 0x03 //(BIT1 | BIT0)
  94. /* Auth code length */
  95. #define HMAC_SHA1_96_LEN 12
  96. //#if APP_DEVICE == 1
  97. #define COUNT_INCREASE 1
  98. #define COUNT_DECREASE -1
  99. #define MAX_BT_PKT_LEN 255
  100. #define RESERVED_USERS_FILE "/etc/reservedusers"
  101. /*macro definitions for set user password options*/
  102. #define DISABLE_USER 0
  103. #define ENABLE_USER 1
  104. #define SET_PASSWORD 2
  105. #define TEST_PASSWORD 3
  106. /*** Global variables ***/
  107. _FAR_ INT8U g_TmrRunning;
  108. /*** Module variables ***/
  109. static _FAR_ MsgPkt_T m_MsgPkt; /**< Message Packet for posting and retrieving messaged to/from queue */
  110. static INT8U m_Set_ChReserveBit[] ={0xF0,0x0,0x30};
  111. //extern IfcName_T Ifcnametable[MAX_LAN_CHANNELS];
  112. /**
  113. * @fn CheckReservedUsers
  114. * @brief This function will checks for reserved users.
  115. * @param Username - Username.
  116. * @retval availability of reserved users.
  117. */
  118. static int CheckForReservedUsers(char *Username)
  119. {
  120. //dictionary *dict = NULL;
  121. //char *sectionname = NULL;
  122. //int nsec=0 , i=0;
  123. //TDBG("filename is %s\n",RESERVED_USERS_FILE);
  124. //dict = iniparser_load(RESERVED_USERS_FILE);
  125. //if(dict == NULL)
  126. //{
  127. // TINFO("Unable to parse dummy users file :%s", RESERVED_USERS_FILE);
  128. // return -1;
  129. //}
  130. //nsec = iniparser_getnsec(dict);
  131. //for (i=0;i<nsec;i++)
  132. //{
  133. // sectionname = iniparser_getsecname (dict, i);
  134. // if(NULL == sectionname)
  135. // {
  136. // TINFO("Unable to get setion name of dummy users file :%s",RESERVED_USERS_FILE);
  137. // iniparser_freedict(dict);
  138. // return -1;
  139. // }
  140. // if(strcmp(sectionname, Username)==0)
  141. // {
  142. // iniparser_freedict(dict);
  143. // return -1;
  144. // }
  145. //}
  146. //iniparser_freedict(dict);
  147. return 0;
  148. }
  149. static void UpdateCurrentEnabledUserCount(int value, int bmcInstId)
  150. {
  151. // if (value == 0) return;
  152. //
  153. // _FAR_ ChannelInfo_T* pChannelInfo = NULL;
  154. // _FAR_ ChannelInfo_T* pNvrChannelInfo = NULL;
  155. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[bmcInstId];
  156. // INT8U maxUserCount = pBMCInfo->IpmiConfig.MaxChUsers;
  157. // INT8U channelIndex = 0;
  158. //
  159. //
  160. // for (channelIndex = 0; channelIndex < MAX_NUM_CHANNELS; channelIndex++)
  161. // {
  162. // if (pBMCInfo->ChConfig[channelIndex].ChType == 0xff) continue;
  163. //
  164. // pChannelInfo = (ChannelInfo_T*)&pBMCInfo->ChConfig[channelIndex].ChannelInfo;
  165. //
  166. // if (((value > 0) && ((pChannelInfo->NoCurrentUser + value) > maxUserCount)) ||
  167. // ((value < 0) && ((pChannelInfo->NoCurrentUser + value) < 0)))
  168. // {
  169. // continue;
  170. // }
  171. //
  172. // pNvrChannelInfo = GetNVRChConfigs(pChannelInfo, bmcInstId);
  173. //
  174. // pChannelInfo->NoCurrentUser+=value;
  175. // pNvrChannelInfo->NoCurrentUser+=value;
  176. // FlushChConfigs((INT8U*)pNvrChannelInfo,pNvrChannelInfo->ChannelNumber,bmcInstId);
  177. //}
  178. }
  179. static int IsPrivilegeAvailable(INT8U requestedPrivilege, INT8U channelNumber, int bmcInstId)
  180. {
  181. // //_FAR_ PMConfig_T* pPMConfig = (_FAR_ PMConfig_T*) GetNVRAddr(NVRH_PMCONFIG, bmcInstId);
  182. // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[bmcInstId];
  183. // INT8U EthIndex = GetEthIndex(channelNumber & 0x0F, bmcInstId);
  184. // INT8U privilege = 0x00;
  185. //
  186. // if(0xff == EthIndex) return -1;
  187. //
  188. // //Get requested privilege status (enabled or disabled) from PMConfig by channel
  189. // switch (requestedPrivilege)
  190. // {
  191. // case PRIV_CALLBACK:
  192. // privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeCallBack;
  193. // break;
  194. //
  195. // case PRIV_USER:
  196. // privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeUser;
  197. // break;
  198. //
  199. // case PRIV_OPERATOR:
  200. // privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeOperator;
  201. // break;
  202. //
  203. // case PRIV_ADMIN:
  204. // privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeAdmin;
  205. // break;
  206. //
  207. // case PRIV_OEM:
  208. // privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeOem;
  209. // break;
  210. //
  211. // default:
  212. // return -1;
  213. // }
  214. //
  215. // //All bits are 0 that means privilege level is disabled
  216. // return ((privilege != 0x00) ? 0 : -1);
  217. }
  218. /*-------------------------------------
  219. * ValidateIPMBChksum1
  220. *-------------------------------------*/
  221. /* Function to validate IPMB Checksum1 for SendMessage Cmd */
  222. static int ValidateIPMBChksum1(_NEAR_ INT8U* Data)
  223. {
  224. int i=0;
  225. INT8U chksum=0;
  226. for (i = 0; i < 3; i++)
  227. {
  228. chksum += *(Data + i);
  229. }
  230. if (chksum != 0)
  231. {
  232. return FALSE;
  233. }
  234. return TRUE;
  235. }
  236. /*-------------------------------------
  237. * ResetWDT
  238. *-------------------------------------*/
  239. int
  240. ResetWDT (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  241. {
  242. // INT8U u8ExpirationFlag;
  243. // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  244. //
  245. //
  246. // if (pBMCInfo->Msghndlr.TmrSet == FALSE)
  247. // {
  248. // *pRes = CC_ATTEMPT_TO_RESET_UNIN_WATCHDOG;
  249. // return sizeof (*pRes);
  250. // }
  251. //
  252. // // save the WDT expiration flag for later use
  253. // u8ExpirationFlag = g_WDTTmrMgr.WDTTmr.ExpirationFlag;
  254. //
  255. //
  256. // /* Reset of Watchdog should not happen once
  257. // once pretimeout interrupt interval is reached*/
  258. // if(pBMCInfo->WDTPreTmtStat == TRUE)
  259. // {
  260. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  261. // return sizeof (*pRes);
  262. // }
  263. //
  264. // g_WDTTmrMgr.TmrPresent = TRUE;
  265. // g_WDTTmrMgr.TmrInterval = pBMCInfo->WDTConfig.InitCountDown;
  266. // g_WDTTmrMgr.PreTimeOutInterval = SEC_TO_MS * pBMCInfo->WDTConfig.PreTimeOutInterval;
  267. //
  268. // /* if the pre-timeout interrupt is not configured, adjust the pre-timeout interrupt
  269. // timeout value beyound the regular WDT timeout value so that it won't get triggered
  270. // before the WDT timeout. */
  271. // if ((pBMCInfo->WDTConfig.TmrActions & 0x70) == 0)
  272. // {
  273. // g_WDTTmrMgr.PreTimeOutInterval = g_WDTTmrMgr.TmrInterval+ 1;
  274. // }
  275. //
  276. // _fmemcpy (&g_WDTTmrMgr.WDTTmr, &pBMCInfo->WDTConfig, sizeof (WDTConfig_T));
  277. //
  278. // // restore the WDT expiration flag, don't use the one from the flash
  279. // g_WDTTmrMgr.WDTTmr.ExpirationFlag = u8ExpirationFlag;
  280. //
  281. // // clear WDT sensor event history
  282. // if( g_corefeatures.internal_sensor == ENABLED )
  283. // RestartWD2Sensor(BMCInst);
  284. //
  285. // if(g_corefeatures.wdt_flush_support == ENABLED )
  286. // {
  287. // FlushIPMI((INT8U*)&pBMCInfo->WDTConfig,(INT8U*)&pBMCInfo->WDTConfig,pBMCInfo->IPMIConfLoc.WDTDATAddr,
  288. // sizeof(WDTConfig_T),BMCInst);
  289. // }
  290. //
  291. // if(BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent == FALSE)
  292. // {
  293. // LOCK_BMC_SHARED_MEM(BMCInst);
  294. // BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning=TRUE;
  295. // BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent=TRUE;
  296. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  297. // sem_post(&g_BMCInfo;//[BMCInst].WDTSem);
  298. // }
  299. // else
  300. // {
  301. // LOCK_BMC_SHARED_MEM(BMCInst);
  302. // BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning=TRUE;
  303. // BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent=TRUE;
  304. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  305. // //Set SetWDTUpdated flag to reload initial countdown value.
  306. // g_BMCInfo[BMCInst].SetWDTUpdated = TRUE;
  307. // }
  308. //
  309. //
  310. // *pRes = CC_NORMAL;
  311. //
  312. // return sizeof (*pRes);
  313. }
  314. /*---------------------------------------
  315. * SetWDT
  316. *---------------------------------------*/
  317. int
  318. SetWDT (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  319. {
  320. // _NEAR_ SetWDTReq_T* pSetWDTReq = (_NEAR_ SetWDTReq_T*)pReq;
  321. //#if GET_MSG_FLAGS != UNIMPLEMENTED
  322. // GetMsgFlagsRes_T GetMsgFlagsRes;
  323. //#endif
  324. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  325. //
  326. //
  327. // //Check for Reserved bits
  328. // if((pSetWDTReq->TmrUse & (BIT5 | BIT4 | BIT3)) || !(pSetWDTReq->TmrUse & (BIT2 | BIT1 | BIT0)) || ((pSetWDTReq->TmrUse & (BIT1 | BIT2)) == (BIT1 | BIT2)) ||
  329. // (pSetWDTReq->TmrActions & (BIT7 |BIT6 | BIT3 | BIT2)) || (pSetWDTReq->ExpirationFlag & (BIT7 | BIT6 | BIT0)))
  330. // {
  331. // *pRes = CC_INV_DATA_FIELD;
  332. // return sizeof(*pRes);
  333. // }
  334. //
  335. //#if NO_WDT_PRETIMEOUT_INTERRUPT == 1
  336. // // do not support pre-timeout interrupt
  337. // if (pSetWDTReq->TmrActions & 0x70)
  338. // {
  339. // *pRes = CC_INV_DATA_FIELD;
  340. // return sizeof(*pRes);
  341. // }
  342. //#endif
  343. //
  344. // pSetWDTReq->InitCountDown = htoipmi_u16(pSetWDTReq->InitCountDown);
  345. //
  346. // // error out if the pre-timeout interrupt is greater than the initial countdown value
  347. // if (pSetWDTReq->InitCountDown < 10 * pSetWDTReq->PreTimeOutInterval)
  348. // {
  349. // *pRes = CC_INV_DATA_FIELD;
  350. // return sizeof(*pRes);
  351. // }
  352. //
  353. // // only clear the memory version of the bit(s) when the input bit is set #31175
  354. // g_WDTTmrMgr.WDTTmr.ExpirationFlag &= ~pSetWDTReq->ExpirationFlag;
  355. // pSetWDTReq->ExpirationFlag = g_WDTTmrMgr.WDTTmr.ExpirationFlag;
  356. //
  357. //
  358. // /* Copy the Timer configuration in NVRAM */
  359. // LOCK_BMC_SHARED_MEM(BMCInst);
  360. // _fmemset ((_FAR_ INT8U*)&pBMCInfo->WDTConfig, 0, sizeof (WDTConfig_T));
  361. // _fmemcpy ((_FAR_ INT8U*)&pBMCInfo->WDTConfig, (_FAR_ INT8U*)pSetWDTReq, sizeof (SetWDTReq_T));
  362. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  363. //
  364. // if (TRUE ==BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning)
  365. // {
  366. // /* To check wheather Dont stop bit is set or not */
  367. // if (pSetWDTReq->TmrUse & 0x40)
  368. // {
  369. // /* Set the count down value to given value */
  370. // g_WDTTmrMgr.TmrPresent = TRUE;
  371. // LOCK_BMC_SHARED_MEM(BMCInst);
  372. // BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent =TRUE;
  373. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  374. // g_WDTTmrMgr.TmrInterval= pSetWDTReq->InitCountDown;
  375. // g_WDTTmrMgr.PreTimeOutInterval = (SEC_TO_MS * pSetWDTReq->PreTimeOutInterval);
  376. //
  377. // /* If PreTimeOutInt is set, clear it */
  378. // if (0 != (pSetWDTReq->TmrActions & 0x70))
  379. // {
  380. // pSetWDTReq->TmrActions &= ~0x70;
  381. // }
  382. // else
  383. // {
  384. // // if the pre-timeout interrupt is not configured, adjust the pre-timeout interrupt
  385. // // timeout value beyound the regular WDT timeout value so that it won't get triggered
  386. // // before the WDT timeout.
  387. // g_WDTTmrMgr.PreTimeOutInterval = pSetWDTReq->InitCountDown + 1;
  388. // }
  389. // _fmemcpy (&g_WDTTmrMgr.WDTTmr, pSetWDTReq, sizeof (WDTConfig_T ));
  390. //
  391. // }
  392. // else
  393. // {
  394. // /* Stop the timer */
  395. // g_WDTTmrMgr.TmrPresent = FALSE;
  396. // LOCK_BMC_SHARED_MEM(BMCInst);
  397. // BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning=FALSE;
  398. // BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent =FALSE;
  399. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  400. // g_WDTTmrMgr.TmrInterval= pSetWDTReq->InitCountDown;
  401. // g_WDTTmrMgr.PreTimeOutInterval = SEC_TO_MS * pSetWDTReq->PreTimeOutInterval;
  402. // // clear WDT sensor event history
  403. // if( g_corefeatures.internal_sensor == ENABLED)
  404. // RestartWD2Sensor(BMCInst);
  405. // }
  406. //
  407. // /* Clear the pre-timeout interupt flag */
  408. // LOCK_BMC_SHARED_MEM(BMCInst);
  409. // pBMCInfo->WDTConfig.PreTimeoutActionTaken = 0x00;
  410. // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x08; /* Clear the flag */
  411. //#if GET_MSG_FLAGS != UNIMPLEMENTED
  412. // // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
  413. // GetMsgFlags (NULL, 0, (INT8U *)&GetMsgFlagsRes,BMCInst);
  414. // TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
  415. // GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
  416. // if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
  417. //#else
  418. // if((BMC_GET_SHARED_MEM(BMCInst)->MsgFlags & BIT3_BIT0_MASK) == 0)
  419. //#endif
  420. // {
  421. // /* Clear the SMS_ATN bit */
  422. // if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
  423. // {
  424. // CLEAR_SMS_ATN (0, BMCInst);
  425. // }
  426. // if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
  427. // {
  428. // CLEAR_SMS_ATN (1, BMCInst);
  429. // }
  430. // if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
  431. // {
  432. // CLEAR_SMS_ATN (2, BMCInst);
  433. // }
  434. // }
  435. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  436. //
  437. // }
  438. // else
  439. // {
  440. // g_WDTTmrMgr.TmrInterval = pSetWDTReq->InitCountDown;
  441. // g_WDTTmrMgr.TmrPresent = FALSE;
  442. // LOCK_BMC_SHARED_MEM(BMCInst);
  443. // BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent =FALSE;
  444. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  445. // // clear WDT sensor event history
  446. // if( g_corefeatures.internal_sensor == ENABLED)
  447. // RestartWD2Sensor(BMCInst);
  448. // }
  449. //
  450. // // Modify ARP status to resume the thread
  451. // // after receiving set Watchdog Timer command
  452. // //BMC_GET_SHARED_MEM(BMCInst)->GratArpStatus = RESUME_ARPS;
  453. //
  454. // int i = 0;
  455. //
  456. // for (i = 0; i < MAX_LAN_CHANNELS; i++)
  457. // {
  458. // if((pBMCInfo->LanIfcConfig[i].Enabled == TRUE)
  459. // && (pBMCInfo->LanIfcConfig[i].Up_Status == LAN_IFC_UP))
  460. // {
  461. // BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[i] = RESUME_ARPS;
  462. // UpdateArpStatus(pBMCInfo->LanIfcConfig[i].Ethindex, BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning, BMCInst);
  463. // }
  464. // }
  465. // if(g_corefeatures.wdt_flush_support == ENABLED )
  466. // {
  467. // FlushIPMI((INT8U*)&pBMCInfo->WDTConfig,(INT8U*)&pBMCInfo->WDTConfig,pBMCInfo->IPMIConfLoc.WDTDATAddr,
  468. // sizeof(WDTConfig_T),BMCInst);
  469. // }
  470. // // set the "Don't Log" bit
  471. // g_WDTTmrMgr.WDTTmr.TmrUse &= 0x7F;
  472. // g_WDTTmrMgr.WDTTmr.TmrUse |= (pSetWDTReq->TmrUse & 0x80);
  473. //
  474. // g_BMCInfo[BMCInst].SetWDTUpdated = TRUE;
  475. // g_BMCInfo[BMCInst].Msghndlr.TmrSet = TRUE;
  476. // pBMCInfo->WDTPreTmtStat = FALSE;
  477. // *pRes = CC_NORMAL;
  478. //
  479. // return sizeof (*pRes);
  480. }
  481. /*---------------------------------------
  482. * GetWDT
  483. *---------------------------------------*/
  484. int
  485. GetWDT (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  486. {
  487. // _NEAR_ GetWDTRes_T* pGetWDTRes = (_NEAR_ GetWDTRes_T*)pRes;
  488. // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  489. //
  490. // /* Copy the current settings from the NVRAM */
  491. // LOCK_BMC_SHARED_MEM(BMCInst);
  492. // _fmemcpy ((_FAR_ INT8U*)&pGetWDTRes->CurrentSettings,
  493. // (_FAR_ INT8U*)&pBMCInfo->WDTConfig, sizeof (WDTConfig_T));
  494. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  495. //
  496. // // get the WDT expiration from the global veriable in memory, not from the flash
  497. // pGetWDTRes->CurrentSettings.ExpirationFlag = g_WDTTmrMgr.WDTTmr.ExpirationFlag;
  498. //
  499. // // get the current "Don't Log" bit
  500. // pGetWDTRes->CurrentSettings.TmrUse &= 0x7F;
  501. // pGetWDTRes->CurrentSettings.TmrUse |= (g_WDTTmrMgr.WDTTmr.TmrUse & 0x80);
  502. // if (TRUE == BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent)
  503. // {
  504. // // set the WDT running bit #30235/30467
  505. // pGetWDTRes->CurrentSettings.TmrUse |= 0x40;
  506. // /* Present count down in 1/100 of second */
  507. // }
  508. // else
  509. // {
  510. // // clear the WDT running bit #30235/30467 for Timer Use (ie) WatchDog Timer status
  511. // pGetWDTRes->CurrentSettings.TmrUse &= ~0x40;
  512. // pGetWDTRes->CurrentSettings.ExpirationFlag = (pGetWDTRes->CurrentSettings.ExpirationFlag) & 0x3E;
  513. // }
  514. //
  515. // pGetWDTRes->PresentCountDown = g_WDTTmrMgr.TmrInterval;
  516. // pGetWDTRes->CurrentSettings.InitCountDown = htoipmi_u16(pGetWDTRes->CurrentSettings.InitCountDown);
  517. // pGetWDTRes->CompletionCode = CC_NORMAL;
  518. //
  519. // return sizeof (GetWDTRes_T);
  520. }
  521. /*---------------------------------------
  522. * SetBMCGlobalEnables
  523. *---------------------------------------*/
  524. int
  525. SetBMCGlobalEnables (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  526. {
  527. // INT8U GblEnblByte = *pReq;
  528. // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  529. // MsgPkt_T MsgPkt;
  530. //
  531. // _fmemset (&MsgPkt, 0, sizeof (MsgPkt_T));
  532. //
  533. // /* Check For the reserved bit 4 */
  534. // if ( GblEnblByte & BIT4)
  535. // {
  536. // *pRes = CC_INV_DATA_FIELD;
  537. // return sizeof (*pRes);
  538. // }
  539. //
  540. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
  541. // if (((BMC_GET_SHARED_MEM (BMCInst)->GlobalEnables ^ GblEnblByte)) & 0x20)
  542. // {
  543. // /* OEM 0 puts us in ICTS compatibility mode for IPMIv2,
  544. // * Send a message to lan process so it can change behavior
  545. // */
  546. // MsgPkt.Channel = GetLANChannel(0, BMCInst);
  547. // MsgPkt.Param = LAN_ICTS_MODE;
  548. // MsgPkt.Privilege = PRIV_LOCAL;
  549. // if (GblEnblByte & 0x20)
  550. // MsgPkt.Cmd = 1;
  551. // else
  552. // MsgPkt.Cmd = 0;
  553. // PostMsg(&MsgPkt,LAN_IFC_Q,BMCInst);
  554. // }
  555. //
  556. // BMC_GET_SHARED_MEM (BMCInst)->GlobalEnables = GblEnblByte;
  557. // *pRes = CC_NORMAL;
  558. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  559. return sizeof (*pRes);
  560. }
  561. /*---------------------------------------
  562. * GetBMCGlobalEnables
  563. *---------------------------------------*/
  564. int
  565. GetBMCGlobalEnables (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  566. {
  567. // _NEAR_ GetBMCGblEnblRes_T* pGetBMCGblEnblRes = (_NEAR_ GetBMCGblEnblRes_T*)pRes;
  568. // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  569. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
  570. // pGetBMCGblEnblRes->CompletionCode = CC_NORMAL;
  571. // pGetBMCGblEnblRes->BMCGblEnblByte = BMC_GET_SHARED_MEM (BMCInst)->GlobalEnables;
  572. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  573. // return sizeof (GetBMCGblEnblRes_T);
  574. }
  575. /*---------------------------------------
  576. * ClrMsgFlags
  577. *---------------------------------------*/
  578. int
  579. ClrMsgFlags (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  580. {
  581. // _NEAR_ ClearMsgsFlagReq_T* pClearMsgsFlagReq = (_NEAR_ ClearMsgsFlagReq_T*)pReq;
  582. // INT8U *kcsifcnum;
  583. //#if GET_MSG_FLAGS != UNIMPLEMENTED
  584. // GetMsgFlagsRes_T GetMsgFlagsRes;
  585. //#endif
  586. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  587. //
  588. // //Check for Reserved bits
  589. // if(pClearMsgsFlagReq->Flag & (BIT4 | BIT2))
  590. // {
  591. // *pRes = CC_INV_DATA_FIELD;
  592. // return sizeof(*pRes);
  593. // }
  594. //
  595. // OS_THREAD_TLS_GET(g_tls.CurKCSIfcNum,kcsifcnum);
  596. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
  597. // /* Flush Receive Message Queue */
  598. // if (0 != (pClearMsgsFlagReq->Flag & 0x01))
  599. // {
  600. // while (0 == GetMsg (&m_MsgPkt, &g_RcvMsgQ[*kcsifcnum][0], WAIT_NONE,BMCInst))
  601. // {
  602. // BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum]--;
  603. // }
  604. //
  605. // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x01; /* Clear the flag */
  606. // }
  607. //
  608. // /* Flush Event Message Buffer */
  609. // if (0 != (pClearMsgsFlagReq->Flag & 0x02))
  610. // {
  611. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->EventMutex,WAIT_INFINITE);
  612. // while (0 == GetMsg (&m_MsgPkt, EVT_MSG_Q, WAIT_NONE,BMCInst))
  613. // {
  614. // BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg--;
  615. // }
  616. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
  617. // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x02; /* Clear the flag */
  618. // }
  619. //
  620. // /* Clear WatchdogTimer Interrupt*/
  621. // if (0 != (pClearMsgsFlagReq->Flag & 0x08))
  622. // {
  623. // /* Clear the pre-timeout interupt flag */
  624. // pBMCInfo->WDTConfig.PreTimeoutActionTaken = 0x00;
  625. // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x08; /* Clear the flag */
  626. // if(g_corefeatures.wdt_flush_support == ENABLED )
  627. // {
  628. // FlushIPMI((INT8U*)&pBMCInfo->WDTConfig,(INT8U*)&pBMCInfo->WDTConfig,pBMCInfo->IPMIConfLoc.WDTDATAddr,
  629. // sizeof(WDTConfig_T),BMCInst);
  630. // }
  631. //
  632. // }
  633. //
  634. //#if GET_MSG_FLAGS != UNIMPLEMENTED
  635. // // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
  636. // GetMsgFlags (NULL, 0, (INT8U *)&GetMsgFlagsRes,BMCInst);
  637. // TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
  638. // GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
  639. // if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
  640. //#else
  641. // if((BMC_GET_SHARED_MEM(BMCInst)->MsgFlags & BIT3_BIT0_MASK) == 0)
  642. //#endif
  643. // {
  644. // /* Clear the SMS_ATN bit */
  645. // if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
  646. // {
  647. // CLEAR_SMS_ATN (0, BMCInst);
  648. // }
  649. // if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
  650. // {
  651. // CLEAR_SMS_ATN (1, BMCInst);
  652. // }
  653. // if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
  654. // {
  655. // CLEAR_SMS_ATN (2, BMCInst);
  656. // }
  657. // }
  658. //
  659. // *pRes = CC_NORMAL;
  660. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  661. //
  662. // return sizeof (*pRes);
  663. }
  664. /*---------------------------------------
  665. GetMsgFlags
  666. ---------------------------------------*/
  667. int
  668. GetMsgFlags (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  669. {
  670. // _NEAR_ GetMsgFlagsRes_T* pGetMsgFlagsRes = (_NEAR_ GetMsgFlagsRes_T*)pRes;
  671. // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  672. // INT8U *kcsifcnum;
  673. //
  674. // OS_THREAD_TLS_GET(g_tls.CurKCSIfcNum,kcsifcnum);
  675. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
  676. // /* get the message flags */
  677. // pGetMsgFlagsRes->MsgFlags = BMC_GET_SHARED_MEM (BMCInst)->MsgFlags;
  678. //
  679. // if (BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg >= EVT_MSG_BUF_SIZE)
  680. // {
  681. // /* If Event MessageBuffer is Full set the BIT */
  682. // pGetMsgFlagsRes->MsgFlags |= 0x02;
  683. // }
  684. // else
  685. // {
  686. // /* else reset the Flag */
  687. // pGetMsgFlagsRes->MsgFlags &= ~0x02;
  688. // }
  689. //
  690. // if(kcsifcnum != NULL && 0 != BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum])
  691. // {
  692. // /* if any Message in ReceiveMsgQ set the Flag */
  693. // pGetMsgFlagsRes->MsgFlags |= 0x01;
  694. // }
  695. // else
  696. // {
  697. // /* else reset the Flag */
  698. // pGetMsgFlagsRes->MsgFlags &= ~0x01;
  699. // }
  700. //
  701. // /* get the Pre-Timeout Bits Value & Set it to Response Data */
  702. // //PRETIMEOUT BIT is 3rd bit so changed accordingly
  703. // pGetMsgFlagsRes->MsgFlags |= (pBMCInfo->WDTConfig.PreTimeoutActionTaken & 0x08);
  704. //
  705. // /* Update the Message flags in shared Mem */
  706. // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags |= pGetMsgFlagsRes->MsgFlags;
  707. // pGetMsgFlagsRes->CompletionCode = CC_NORMAL;
  708. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  709. //
  710. // return sizeof (GetMsgFlagsRes_T);
  711. }
  712. /*---------------------------------------
  713. * EnblMsgChannelRcv
  714. *---------------------------------------*/
  715. int
  716. EnblMsgChannelRcv (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  717. {
  718. // _NEAR_ EnblMsgChRcvReq_T* pEnblMsgChRcvReq = (_NEAR_ EnblMsgChRcvReq_T*)pReq;
  719. // _NEAR_ EnblMsgChRcvRes_T* pEnblMsgChRcvRes = (_NEAR_ EnblMsgChRcvRes_T*)pRes;
  720. // _FAR_ ChannelInfo_T* pChannelInfo;
  721. // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  722. //
  723. // //Check for Reserved bits
  724. // if(pEnblMsgChRcvReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4))
  725. // {
  726. // pEnblMsgChRcvRes->CompletionCode = CC_INV_DATA_FIELD;
  727. // return sizeof(*pRes);
  728. // }
  729. //
  730. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  731. // pChannelInfo = getChannelInfo (pEnblMsgChRcvReq->ChannelNum & 0x0F, BMCInst);
  732. //
  733. // TDBG ("ENBL_MSG_CH_RCV: processing..\n");
  734. //
  735. // if (NULL == pChannelInfo)
  736. // {
  737. // pEnblMsgChRcvRes->CompletionCode = CC_INV_DATA_FIELD;
  738. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  739. // return sizeof (*pRes);
  740. // }
  741. //
  742. // switch (pEnblMsgChRcvReq->ChannelState)
  743. // {
  744. // case 0:
  745. // /* disable Receive Message Queue for this Channel */
  746. // pChannelInfo->ReceiveMsgQ = 0x0;
  747. // break;
  748. //
  749. // case 1:
  750. // /*enable Recevive Message Queue for this Channel */
  751. // pChannelInfo->ReceiveMsgQ = 0x1;
  752. // break;
  753. //
  754. // case 2:
  755. // /*get Channel State */
  756. // pEnblMsgChRcvRes->ChannelState = pChannelInfo->ReceiveMsgQ;
  757. // break;
  758. //
  759. // default:
  760. // pEnblMsgChRcvRes->CompletionCode = CC_INV_DATA_FIELD;
  761. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  762. // return sizeof (*pRes);
  763. // }
  764. //
  765. // pEnblMsgChRcvRes->CompletionCode = CC_NORMAL;
  766. //
  767. // /*get Channel Number */
  768. // pEnblMsgChRcvRes->ChannelNum = pEnblMsgChRcvReq->ChannelNum & 0x0F;
  769. //
  770. // pEnblMsgChRcvRes->ChannelState = pChannelInfo->ReceiveMsgQ;
  771. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  772. //
  773. // return sizeof (EnblMsgChRcvRes_T);
  774. }
  775. /*---------------------------------------
  776. * GetMessage
  777. *---------------------------------------*/
  778. int
  779. GetMessage (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  780. {
  781. // _NEAR_ GetMsgRes_T* pGetMsgRes = (_NEAR_ GetMsgRes_T*)pRes;
  782. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  783. // INT8U Index = 0,*kcsifcnum;
  784. //#if GET_MSG_FLAGS != UNIMPLEMENTED
  785. // GetMsgFlagsRes_T GetMsgFlagsRes;
  786. //#endif
  787. //
  788. // OS_THREAD_TLS_GET(g_tls.CurKCSIfcNum,kcsifcnum);
  789. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
  790. // if (0 != GetMsg (&m_MsgPkt, &g_RcvMsgQ[*kcsifcnum][0], WAIT_NONE,BMCInst))
  791. // {
  792. // /* if Queue is Empty */
  793. // pGetMsgRes->CompletionCode = CC_GET_MSG_QUEUE_EMPTY;
  794. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  795. // return sizeof (*pRes);
  796. // }
  797. //
  798. // BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum]--;
  799. //
  800. //#if GET_MSG_FLAGS != UNIMPLEMENTED
  801. // // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
  802. // GetMsgFlags (NULL, 0, (INT8U *)&GetMsgFlagsRes,BMCInst);
  803. // TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
  804. // GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
  805. // if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
  806. //#else
  807. // if (0 == BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum])
  808. //#endif
  809. // {
  810. // /* Clear the SMS_ATN bit */
  811. // CLEAR_SMS_ATN (*kcsifcnum,BMCInst);
  812. // }
  813. //
  814. // /* Completion Code */
  815. // pGetMsgRes->CompletionCode = CC_NORMAL;
  816. // /* Channel number and privilege level */
  817. // pGetMsgRes->ChannelNum = m_MsgPkt.Channel;
  818. //
  819. // Index = sizeof (GetMsgRes_T);
  820. //
  821. // /* First byte should be session handle */
  822. // if(pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)
  823. // {
  824. // if ((PRIMARY_IPMB_CHANNEL != m_MsgPkt.Channel) && (pBMCInfo->SecondaryIPMBCh != m_MsgPkt.Channel))
  825. // {
  826. // pGetMsgRes->ChannelNum |= m_MsgPkt.Privilege << 0x04;
  827. // pRes [Index++] = m_MsgPkt.Param;
  828. // }
  829. // }
  830. // else
  831. // {
  832. // if(PRIMARY_IPMB_CHANNEL != m_MsgPkt.Channel)
  833. // {
  834. // pGetMsgRes->ChannelNum |= m_MsgPkt.Privilege << 0x04;
  835. // pRes [Index++] = m_MsgPkt.Param;
  836. // }
  837. // }
  838. //
  839. // /* copy the Message data */
  840. // _fmemcpy ((_FAR_ INT8U*)&pRes[Index], &m_MsgPkt.Data[1], m_MsgPkt.Size-1);
  841. //
  842. // IPMI_DBG_PRINT ("GetMsg: Sending the following data through requested channel\n");
  843. // IPMI_DBG_PRINT_BUF (pRes, m_MsgPkt.Size + Index);
  844. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  845. //
  846. // return ((m_MsgPkt.Size-1)+ Index); /*+ 2 for completion code & channel No. */
  847. }
  848. /*---------------------------------------
  849. * SendMessage
  850. *---------------------------------------*/
  851. int
  852. SendMessage (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  853. {
  854. // _NEAR_ SendMsgReq_T* pSendMsgReq = (_NEAR_ SendMsgReq_T*)pReq;
  855. // _NEAR_ SendMsgRes_T* pSendMsgRes = (_NEAR_ SendMsgRes_T*)pRes;
  856. // _NEAR_ IPMIMsgHdr_T* pIPMIMsgHdr;
  857. // char QueueName[MAX_STR_LENGTH];
  858. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  859. // INT8U Tracking;
  860. // INT8U Channel=0,resaddr=0;
  861. // INT8U ResLen = 1;
  862. // INT8U RetVal = 0;
  863. // INT8U Offset = 1;
  864. // INT8U SeqNum = pBMCInfo->SendMsgSeqNum;
  865. // INT8U PBTbl = PRIMARY_PB_TBL;
  866. // INT8U SrcSessionHndl = 0;
  867. // _FAR_ ChannelInfo_T* pChannelInfo;
  868. // int tmpBMCInst= 0;
  869. // MsgPkt_T ResPkt;
  870. // _FAR_ SessionInfo_T* pSessionInfo = NULL;
  871. // INT32U *CurSesID;
  872. // INT8U *curprivlevel,*curchannel,*kcsifcnum;
  873. //
  874. // if (ReqLen < 1)
  875. // {
  876. // *pRes = CC_REQ_INV_LEN;
  877. // return sizeof (*pRes);
  878. // }
  879. //
  880. // if(pSendMsgReq->ChNoTrackReq == 0xC0)
  881. // {
  882. // *pRes = CC_INV_DATA_FIELD;
  883. // return sizeof (*pRes);
  884. // }
  885. //
  886. // /* Get the channel number */
  887. // Channel = pSendMsgReq->ChNoTrackReq & 0x0F;
  888. //
  889. // /* Get Tracking field */
  890. // Tracking = pSendMsgReq->ChNoTrackReq >> 6;
  891. //
  892. // if (Tracking == RESERVED_BITS_SENDMS)
  893. // {
  894. // *pRes = CC_INV_DATA_FIELD;
  895. // return sizeof (*pRes);
  896. // }
  897. //
  898. // OS_THREAD_TLS_GET(g_tls.CurSessionID,CurSesID);
  899. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  900. // OS_THREAD_TLS_GET(g_tls.CurKCSIfcNum,kcsifcnum);
  901. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
  902. // if(g_corefeatures.mbmc_single_nic == ENABLED
  903. // && g_corefeatures.ifc_specific_msg_handling != ENABLED)
  904. // {
  905. // ResLen = 0;
  906. // g_MBMCInfo.sbmcinst = BMCInst;
  907. // memset((char *)&ResPkt,0,sizeof(MsgPkt_T));
  908. // pIPMIMsgHdr = (IPMIMsgHdr_T*)(&pBMCInfo->LANConfig.MsgReq.Data[sizeof (IPMIMsgHdr_T) + 1]);
  909. // m_MsgPkt.Param = PARAM_IFC;
  910. // m_MsgPkt.Channel = *curchannel;
  911. // m_MsgPkt.NetFnLUN = pIPMIMsgHdr->NetFnLUN;
  912. // m_MsgPkt.Cmd = pIPMIMsgHdr->Cmd;
  913. // m_MsgPkt.Privilege = PRIV_ADMIN;
  914. // m_MsgPkt.Size = pBMCInfo->LANConfig.MsgReq.Size - sizeof (IPMIMsgHdr_T) - 2;
  915. // _fmemcpy (m_MsgPkt.Data, pIPMIMsgHdr, m_MsgPkt.Size);
  916. //
  917. // if(g_PDKHandle[PDK_MBMCSINGLENICSENDMSG] != NULL)
  918. // {
  919. // tmpBMCInst = ( (int (*)(INT8U,int) ) g_PDKHandle[PDK_MBMCSINGLENICSENDMSG]) ( m_MsgPkt.Data[0],BMCInst);
  920. // }
  921. //
  922. // if(tmpBMCInst == 0)
  923. // {
  924. // resaddr = (m_MsgPkt.Data[0] - pBMCInfo->IpmiConfig.BMCSlaveAddr) >> 1;
  925. // if(0 <= resaddr && resaddr < BMCInstCount && (m_MsgPkt.Data[0] - pBMCInfo->IpmiConfig.BMCSlaveAddr)%2 == 0)
  926. // {
  927. // tmpBMCInst = resaddr + 1;
  928. // }
  929. // else
  930. // {
  931. // *pRes = CC_INV_DATA_FIELD;
  932. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  933. // return sizeof(*pRes);
  934. // }
  935. // }
  936. //
  937. // _fmemcpy(ResPkt.Data,pBMCInfo->LANConfig.MsgReq.Data,sizeof(IPMIMsgHdr_T));
  938. // ResPkt.Param = BRIDGING_REQUEST;
  939. // ResPkt.Cmd = pIPMIMsgHdr->Cmd;
  940. // ((IPMIMsgHdr_T *)ResPkt.Data)->NetFnLUN = ((pBMCInfo->LANConfig.MsgReq.NetFnLUN >> 2) +1) << 2;
  941. // ResPkt.Data [sizeof(IPMIMsgHdr_T)] = CC_NORMAL;
  942. // ResPkt.Size = sizeof (IPMIMsgHdr_T) + 1 + 1; // IPMI Header + Completion Code + Second Checksum
  943. // /* Calculate the Second CheckSum */
  944. // ResPkt.Data[ResPkt.Size - 1] = CalculateCheckSum2 (ResPkt.Data, ResPkt.Size-1);
  945. // if (0 != PostMsg (&ResPkt,LAN_RES_Q,BMCInst))
  946. // {
  947. // TDBG ("SendMsg: Failed to post message to interface queue\n");
  948. // }
  949. //
  950. // pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID,BMCInst);
  951. // if (NULL != pSessionInfo)
  952. // {
  953. // g_MBMCInfo.SrcSessionHndl = pSessionInfo->SessionHandle;
  954. // }
  955. // else
  956. // {
  957. // *pRes = CC_UNSPECIFIED_ERR;
  958. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  959. // return sizeof(*pRes);
  960. // }
  961. //
  962. // memset(QueueName,0,sizeof(QueueName));
  963. // sprintf(QueueName,"%s%d",LAN_IFC_Q,BMCInst);
  964. // strcpy ((char *)m_MsgPkt.SrcQ,QueueName);
  965. //
  966. // /* Post the message to Message Handler */
  967. // if (0 != PostMsg (&m_MsgPkt,MSG_HNDLR_Q,tmpBMCInst))
  968. // {
  969. // TDBG ("SendMsg: Failed to post message to interface queue\n");
  970. // }
  971. // }
  972. // else
  973. // {
  974. // m_MsgPkt.Param = BRIDGING_REQUEST;
  975. // m_MsgPkt.Channel = Channel;
  976. // m_MsgPkt.Size = ReqLen - 1; /* -1 to skip channel num */
  977. //
  978. // /* Copy the message data */
  979. // _fmemcpy (m_MsgPkt.Data, &pReq[1], m_MsgPkt.Size);
  980. // /* Copy the IPMI Message header */
  981. // pIPMIMsgHdr = (_NEAR_ IPMIMsgHdr_T*)&m_MsgPkt.Data[Offset - 1];
  982. // if(ValidateIPMBChksum1((_NEAR_ INT8U*)pIPMIMsgHdr) == FALSE)
  983. // {
  984. // *pRes = CC_INV_DATA_FIELD;
  985. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  986. // return sizeof (*pRes);
  987. // }
  988. //
  989. // if(m_MsgPkt.Data[ReqLen - 2] != CalculateCheckSum2 ((_FAR_ INT8U*)pIPMIMsgHdr, ReqLen - Offset - 1))
  990. // {
  991. // *pRes = CC_INV_DATA_FIELD;
  992. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  993. // return sizeof (*pRes);
  994. // }
  995. //
  996. //#if 0
  997. // printf("SendMsg: ReqLen = %d, size = %ld\n",ReqLen,m_MsgPkt.Size);
  998. //
  999. // for(i = 0; i < m_MsgPkt.Size;i++)
  1000. // printf("MsgPkt_Data %02X\n",m_MsgPkt.Data[i]);
  1001. // printf("\n");
  1002. //#endif
  1003. //
  1004. // if(pBMCInfo->IpmiConfig.LANIfcSupport == 1)
  1005. // {
  1006. // /* To Check the Wheather LAN Channel */
  1007. // if (IsLANChannel(*curchannel & 0xF, BMCInst))
  1008. // {
  1009. // _FAR_ SessionInfo_T* pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID,BMCInst);
  1010. //
  1011. // if (NULL != pSessionInfo)
  1012. // {
  1013. // SrcSessionHndl = pSessionInfo->SessionHandle;
  1014. // }
  1015. //
  1016. // TDBG ("SendMsg: To LAN Interface for reference\n");
  1017. // // Offset++; : causes bridging issues
  1018. // strcpy ((char *)m_MsgPkt.SrcQ, LAN_IFC_Q);
  1019. // }
  1020. // }
  1021. //
  1022. // if(pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
  1023. // {
  1024. // /* To Check the Wheather Serial Channel */
  1025. // if (pBMCInfo->SERIALch != CH_NOT_USED && (*curchannel & 0xF) == pBMCInfo->SERIALch && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
  1026. // {
  1027. // _FAR_ SessionInfo_T* pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID,BMCInst);
  1028. //
  1029. // if (NULL != pSessionInfo)
  1030. // {
  1031. // SrcSessionHndl = pSessionInfo->SessionHandle;
  1032. // }
  1033. //
  1034. // TDBG ("SendMsg: To Serial Interface for reference\n");
  1035. // // Offset++; : causes bridging issues
  1036. // strcpy ((char *)m_MsgPkt.SrcQ, SERIAL_IFC_Q);
  1037. // }
  1038. // }
  1039. //
  1040. // if((Channel == PRIMARY_IPMB_CHANNEL) && pBMCInfo->IpmiConfig.PrimaryIPMBSupport == 1)
  1041. // {
  1042. // TDBG ("SendMsg: To Primary IPMB Interface\n");
  1043. // strcpy ((char *)m_MsgPkt.SrcQ, IPMB_PRIMARY_IFC_Q);
  1044. // }
  1045. // else if((pBMCInfo->SecondaryIPMBCh != CH_NOT_USED && Channel == pBMCInfo->SecondaryIPMBCh) && pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 1)
  1046. // {
  1047. // TDBG ("SendMsg: To SMLink IPMB Interface\n");
  1048. // strcpy ((char *)m_MsgPkt.SrcQ, IPMB_SECONDARY_IFC_Q);
  1049. // }
  1050. // else if ((pBMCInfo->SERIALch != CH_NOT_USED && Channel == pBMCInfo->SERIALch) && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
  1051. // {
  1052. // TDBG ("SendMsg: To Serial Interface\n");
  1053. // Offset++;
  1054. // strcpy ((char *)m_MsgPkt.SrcQ, SERIAL_IFC_Q);
  1055. // }
  1056. // else if ((pBMCInfo->ICMBCh != CH_NOT_USED && Channel == pBMCInfo->ICMBCh) && pBMCInfo->IpmiConfig.ICMBIfcSupport == 1)
  1057. // {
  1058. // TDBG ("SendMsg: To ICMB Interface\n");
  1059. // strcpy ((char *)m_MsgPkt.SrcQ, ICMB_IFC_Q);
  1060. // }
  1061. // else if(pBMCInfo->SYSCh != CH_NOT_USED && Channel == pBMCInfo->SYSCh)
  1062. // {
  1063. // TDBG ("SendMsg: To System Interface\n");
  1064. // /*
  1065. // * According to IPMI Spec v2.0.
  1066. // * It is recommended to send CC_DEST_UNAVAILABLE
  1067. // * completion code, if the channel is disabled for
  1068. // * receiving messages.
  1069. // * */
  1070. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  1071. // pChannelInfo = getChannelInfo(Channel,BMCInst);
  1072. // if(NULL == pChannelInfo)
  1073. // {
  1074. // *pRes = CC_INV_DATA_FIELD;
  1075. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1076. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1077. // return sizeof (*pRes);
  1078. // }
  1079. // if (0x0 == pChannelInfo->ReceiveMsgQ)
  1080. // {
  1081. // printf ("The Channel(0x%x) has been Disabled "
  1082. // "for Receive message\n", Channel);
  1083. // *pRes = CC_DEST_UNAVAILABLE;
  1084. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1085. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1086. // return sizeof (*pRes);
  1087. // }
  1088. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1089. // strcpy ((char *)m_MsgPkt.SrcQ, &g_RcvMsgQ[*kcsifcnum][0]);
  1090. // m_MsgPkt.Param = SrcSessionHndl;
  1091. // }
  1092. // else
  1093. // {
  1094. // printf ("SendMsg: Invalid Channel\n");
  1095. // *pRes = CC_DEST_UNAVAILABLE;
  1096. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1097. // return sizeof (*pRes);
  1098. // }
  1099. //
  1100. // if( (TRUE == pBMCInfo->NMConfig.NMSupport) && (pBMCInfo->NMConfig.NMDevSlaveAddress == pIPMIMsgHdr->ResAddr) &&
  1101. // (Channel == (NM_PRIMARY_IPMB_BUS == pBMCInfo->NMConfig.NM_IPMBBus) ? pBMCInfo->PrimaryIPMBCh : pBMCInfo->SecondaryIPMBCh) )
  1102. // {
  1103. // if( (pBMCInfo->RMCPLAN1Ch == *curchannel) ||
  1104. // (pBMCInfo->RMCPLAN2Ch == *curchannel) ||
  1105. // (pBMCInfo->RMCPLAN3Ch == *curchannel) ||
  1106. // (pBMCInfo->RMCPLAN4Ch == *curchannel) ||
  1107. // (pBMCInfo->SERIALch == *curchannel) )
  1108. // {
  1109. // OS_THREAD_TLS_GET(g_tls.CurPrivLevel,curprivlevel);
  1110. // if(PRIV_ADMIN != *curprivlevel)
  1111. // {
  1112. // TDBG("Insufficient Privilege\n");
  1113. // *pRes = CC_INSUFFIENT_PRIVILEGE;
  1114. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1115. // return sizeof(*pRes);
  1116. // }
  1117. // }
  1118. // }
  1119. //
  1120. // if(g_PDKHandle[PDK_BEFORESENDMESSAGE] != NULL)
  1121. // {
  1122. // RetVal = ( (int (*)(INT8U*, INT8U, INT8U*, int) ) g_PDKHandle[PDK_BEFORESENDMESSAGE]) ( pReq, ReqLen, pRes, BMCInst);
  1123. //
  1124. // if(0 < RetVal)
  1125. // {
  1126. // return RetVal;
  1127. // }
  1128. // }
  1129. //
  1130. // if (1 == Tracking)
  1131. // {
  1132. // /* Response length is set to zero to make MsgHndlr skip responding to this request
  1133. // * The Response will be handled by the ipmb interface after verifying NAK.
  1134. // */
  1135. // ResLen = 0;
  1136. //
  1137. // /* Tracking is not required if originator is System ifc */
  1138. // if (SYS_IFC_CHANNEL == (*curchannel & 0xF))
  1139. // {
  1140. // *pRes = CC_INV_DATA_FIELD;
  1141. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1142. // return sizeof (*pRes);
  1143. // }
  1144. //
  1145. // PBTbl = (Channel == pBMCInfo->SecondaryIPMBCh) ? SECONDARY_PB_TBL : PRIMARY_PB_TBL ;
  1146. //
  1147. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->PendBridgeMutex, WAIT_INFINITE);
  1148. //
  1149. // /* Store in the table for response tracking */
  1150. // while(TRUE)
  1151. // {
  1152. // if (FALSE == m_PendingBridgedResTbl[PBTbl][SeqNum].Used)
  1153. // {
  1154. // m_PendingBridgedResTbl[PBTbl][SeqNum].TimeOut = pBMCInfo->IpmiConfig.SendMsgTimeout;
  1155. // m_PendingBridgedResTbl[PBTbl][SeqNum].ChannelNum = (*curchannel & 0xF);
  1156. // m_PendingBridgedResTbl[PBTbl][SeqNum].OriginSrc = ORIGIN_SENDMSG;
  1157. // pBMCInfo->SendMsgSeqNum = SeqNum;
  1158. //
  1159. // if (1 != Offset)
  1160. // {
  1161. // m_PendingBridgedResTbl[PBTbl][SeqNum].DstSessionHandle = pReq[Offset]; /* Session handle */
  1162. // }
  1163. //
  1164. // m_PendingBridgedResTbl[PBTbl][SeqNum].SrcSessionHandle = SrcSessionHndl;
  1165. //
  1166. // _fmemcpy (&m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr, pIPMIMsgHdr, sizeof (IPMIMsgHdr_T));
  1167. //
  1168. // /* Format the IPMI Msg Hdr */
  1169. // if(Channel == pBMCInfo->PrimaryIPMBCh)
  1170. // {
  1171. // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.PrimaryIPMBAddr;
  1172. // }
  1173. // else if(Channel == pBMCInfo->SecondaryIPMBCh)
  1174. // {
  1175. // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.SecondaryIPMBAddr;
  1176. // }
  1177. // else
  1178. // {
  1179. // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
  1180. // }
  1181. //
  1182. // pIPMIMsgHdr->RqSeqLUN = (pBMCInfo->SendMsgSeqNum << 2) & 0xFC; /* Seq Num and LUN =00 */
  1183. //
  1184. // /* Recalculate the checksum */
  1185. // m_MsgPkt.Data[ReqLen - 2] = CalculateCheckSum2 ((_FAR_ INT8U*)pIPMIMsgHdr, ReqLen - Offset - 1);
  1186. // if(IsLANChannel(*curchannel & 0xF, BMCInst))
  1187. // {
  1188. // memset(QueueName,0,sizeof(QueueName));
  1189. // sprintf(QueueName,"%s%d",LAN_IFC_Q,BMCInst);
  1190. // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
  1191. // }
  1192. // else if (pBMCInfo->SERIALch != CH_NOT_USED && (*curchannel & 0xF) == pBMCInfo->SERIALch && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
  1193. // {
  1194. // memset(QueueName,0,sizeof(QueueName));
  1195. // sprintf(QueueName,"%s%d",SERIAL_IFC_Q,BMCInst);
  1196. // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
  1197. // }
  1198. // else
  1199. // {
  1200. // if(( (*curchannel & 0xF) == PRIMARY_IPMB_CHANNEL) && (pBMCInfo->IpmiConfig.PrimaryIPMBSupport == 1 ))
  1201. // {
  1202. // memset(QueueName,0,sizeof(QueueName));
  1203. // sprintf(QueueName,"%s%d",IPMB_PRIMARY_IFC_Q,BMCInst);
  1204. // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
  1205. // }
  1206. // else if((pBMCInfo->SecondaryIPMBCh != CH_NOT_USED && Channel == pBMCInfo->SecondaryIPMBCh) && pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 1)
  1207. // {
  1208. // memset(QueueName,0,sizeof(QueueName));
  1209. // sprintf(QueueName,"%s%d",IPMB_SECONDARY_IFC_Q,BMCInst);
  1210. // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
  1211. // }
  1212. // else if ((pBMCInfo->SERIALch != CH_NOT_USED && Channel == pBMCInfo->SERIALch) && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
  1213. // {
  1214. // memset(QueueName,0,sizeof(QueueName));
  1215. // sprintf(QueueName,"%s%d",SERIAL_IFC_Q,BMCInst);
  1216. // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
  1217. // }
  1218. // else if((pBMCInfo->SMBUSCh != CH_NOT_USED && Channel == pBMCInfo->SMBUSCh) && pBMCInfo->IpmiConfig.SMBUSIfcSupport == 1)
  1219. // {
  1220. // //strcpy ((char *)m_PendingBridgedResTbl[i].DestQ, NULL);
  1221. // }
  1222. // else if ((pBMCInfo->ICMBCh != CH_NOT_USED && Channel == pBMCInfo->ICMBCh) && pBMCInfo->IpmiConfig.ICMBIfcSupport == 1)
  1223. // {
  1224. // memset(QueueName,0,sizeof(QueueName));
  1225. // sprintf(QueueName,"%s%d",ICMB_IFC_Q,BMCInst);
  1226. // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
  1227. // }
  1228. // }
  1229. // m_PendingBridgedResTbl[PBTbl][SeqNum].Used = TRUE;
  1230. // IPMI_DBG_PRINT_1( "SendMessage: Bridged message added index = %d.\n", SeqNum);
  1231. //
  1232. // break;
  1233. // }
  1234. // else
  1235. // {
  1236. // SeqNum = (SeqNum + 1) & 0x3F;
  1237. //
  1238. // if (SeqNum == pBMCInfo->SendMsgSeqNum)
  1239. // {
  1240. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PendBridgeMutex);
  1241. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1242. // /* If not been added to the Pending Bridge table, an error should be reported back.
  1243. // If not, for internal channel, the thread calling it may end up waiting! */
  1244. // *pRes = CC_NODE_BUSY;
  1245. // return sizeof (*pRes);
  1246. // }
  1247. // }
  1248. // }
  1249. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PendBridgeMutex);
  1250. // }
  1251. //
  1252. // if ((pBMCInfo->SYSCh == (*curchannel & 0xF)) && pBMCInfo->IpmiConfig.SYSIfcSupport == 0x01)
  1253. // {
  1254. //
  1255. // ResLen = 0;
  1256. // /* Format the IPMI Msg Hdr */
  1257. // // Fill the address from Infrastrucure function instead of using PRIMARY_IPMB_ADDR/SECONDARY_IPMB_ADDR
  1258. // if(Channel == pBMCInfo->PrimaryIPMBCh)
  1259. // {
  1260. // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.PrimaryIPMBAddr;
  1261. // }
  1262. // else if(Channel == pBMCInfo->SecondaryIPMBCh)
  1263. // {
  1264. // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.SecondaryIPMBAddr;
  1265. // }
  1266. // else
  1267. // {
  1268. // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
  1269. // }
  1270. //
  1271. // /*Change the encapsulated request's LUN based on originating KCS interface */
  1272. // pIPMIMsgHdr->RqSeqLUN = (pIPMIMsgHdr->RqSeqLUN & 0xFC) | (*kcsifcnum + 0x01);
  1273. // m_MsgPkt.Data[ReqLen - 2] = CalculateCheckSum2 ((_FAR_ INT8U*)pIPMIMsgHdr, ReqLen - Offset - 1);
  1274. // pBMCInfo->BridgeMsgKCSIfc = *kcsifcnum;
  1275. // }
  1276. //
  1277. // IPMI_DBG_PRINT ("SendMsgCmd:Posting to interface");
  1278. // IPMI_DBG_PRINT_BUF (m_MsgPkt.Data, m_MsgPkt.Size);
  1279. //
  1280. // m_MsgPkt.Cmd = PAYLOAD_IPMI_MSG;
  1281. //
  1282. // /* Post the message to interface */
  1283. // if (0 != PostMsg (&m_MsgPkt,(INT8S *)m_MsgPkt.SrcQ, BMCInst))
  1284. // {
  1285. // TDBG ("SendMsg: Failed to post message to interface queue\n");
  1286. // }
  1287. //
  1288. // pSendMsgRes->CompletionCode = CC_NORMAL;
  1289. //
  1290. // if(pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)
  1291. // {
  1292. // if ((PRIMARY_IPMB_CHANNEL== (*curchannel & 0xF) || pBMCInfo->SecondaryIPMBCh == (*curchannel & 0xF)) && 1 == Tracking)
  1293. // {
  1294. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1295. // return 0;
  1296. // }
  1297. // }
  1298. // else
  1299. // {
  1300. // if ( PRIMARY_IPMB_CHANNEL == (*curchannel & 0xF) && (1 == Tracking))
  1301. // {
  1302. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1303. // return 0;
  1304. // }
  1305. // }
  1306. // }
  1307. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1308. // return ResLen;
  1309. }
  1310. /*---------------------------------------
  1311. * ReadEvtMsgBuffer
  1312. *---------------------------------------*/
  1313. int
  1314. ReadEvtMsgBuffer (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1315. {
  1316. // _NEAR_ ReadEvtMsgBufRes_T* pReadEvtMsgBufRes = (_NEAR_ ReadEvtMsgBufRes_T*)pRes;
  1317. //#if GET_MSG_FLAGS != UNIMPLEMENTED
  1318. // GetMsgFlagsRes_T GetMsgFlagsRes;
  1319. //#endif
  1320. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  1321. //
  1322. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
  1323. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->EventMutex,WAIT_INFINITE);
  1324. // if (-2 == GetMsg(&m_MsgPkt, EVT_MSG_Q, WAIT_NONE, BMCInst))
  1325. // {
  1326. // /*If queue is empty */
  1327. // pReadEvtMsgBufRes->CompletionCode = CC_EVT_MSG_QUEUE_EMPTY;/* Queue is empty */
  1328. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
  1329. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1330. // return sizeof (*pRes);
  1331. // }
  1332. //
  1333. // if (BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg == 0)
  1334. // {
  1335. // pReadEvtMsgBufRes->CompletionCode = CC_EVT_MSG_QUEUE_EMPTY;
  1336. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
  1337. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1338. // return sizeof (*pRes);
  1339. // }
  1340. //
  1341. // BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg--;
  1342. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
  1343. //
  1344. //#if GET_MSG_FLAGS != UNIMPLEMENTED
  1345. // // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
  1346. // GetMsgFlags (NULL, 0, (INT8U *)&GetMsgFlagsRes,BMCInst);
  1347. // TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
  1348. // GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
  1349. // if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
  1350. //#else
  1351. // if (0 == BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg)
  1352. //#endif
  1353. // {
  1354. // /* if there is no messssage in buffer reset SMS/EVT ATN bit */
  1355. // // CLEAR_SMS_ATN ();
  1356. // if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
  1357. // {
  1358. // CLEAR_SMS_ATN (0, BMCInst);
  1359. // }
  1360. // if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
  1361. // {
  1362. // CLEAR_SMS_ATN (1, BMCInst);
  1363. // }
  1364. // if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
  1365. // {
  1366. // CLEAR_SMS_ATN (2, BMCInst);
  1367. // }
  1368. // }
  1369. //
  1370. // /* clear EventMessageBuffer full flag */
  1371. // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x02;
  1372. //
  1373. // pReadEvtMsgBufRes->CompletionCode = CC_NORMAL; /* Completion Code */
  1374. //
  1375. // /* copy the Message data */
  1376. // _fmemcpy (pReadEvtMsgBufRes->ResData, m_MsgPkt.Data, m_MsgPkt.Size);
  1377. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1378. //
  1379. // return sizeof (ReadEvtMsgBufRes_T);
  1380. }
  1381. /*---------------------------------------
  1382. * GetBTIfcCap
  1383. *---------------------------------------*/
  1384. int
  1385. GetBTIfcCap (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1386. {
  1387. _NEAR_ GetBTIfcCapRes_T* pGetBTIfcCapRes = (_NEAR_ GetBTIfcCapRes_T*)pRes;
  1388. pGetBTIfcCapRes->CompletionCode = CC_NORMAL;
  1389. pGetBTIfcCapRes->NumReqSupported = 2;
  1390. pGetBTIfcCapRes->InputBufSize = MAX_BT_PKT_LEN;
  1391. pGetBTIfcCapRes->OutputBufSize = MAX_BT_PKT_LEN;
  1392. pGetBTIfcCapRes->RespTime = 1;
  1393. pGetBTIfcCapRes->Retries = 0;
  1394. return sizeof (GetBTIfcCapRes_T);
  1395. }
  1396. /*---------------------------------------
  1397. * GetSystemGUID
  1398. *---------------------------------------*/
  1399. int
  1400. GetSystemGUID (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1401. {
  1402. //_NEAR_ GetSysGUIDRes_T* pGetSysGUIDRes = (_NEAR_ GetSysGUIDRes_T*)pRes;
  1403. //pGetSysGUIDRes->CompletionCode = CC_NORMAL;
  1404. //LOCK_BMC_SHARED_MEM (BMCInst);
  1405. //_fmemcpy (&pGetSysGUIDRes->Node, BMC_GET_SHARED_MEM (BMCInst)->SystemGUID, 16);
  1406. //UNLOCK_BMC_SHARED_MEM (BMCInst);
  1407. //return sizeof (GetSysGUIDRes_T);
  1408. }
  1409. #define SUPPORT_IPMI20 0x02
  1410. #define SUPPORT_IPMI15 0x01
  1411. /*---------------------------------------
  1412. * GetChAuthCap
  1413. *---------------------------------------*/
  1414. int
  1415. GetChAuthCap (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1416. {
  1417. // printf("start GetChAuthCap\n");
  1418. _NEAR_ GetChAuthCapReq_T* pGetChAuthCapReq = (_NEAR_ GetChAuthCapReq_T*)pReq;
  1419. _NEAR_ GetChAuthCapRes_T* pGetChAuthCapRes = (_NEAR_ GetChAuthCapRes_T*)pRes;
  1420. memset (pGetChAuthCapRes, 0, sizeof (GetChAuthCapRes_T));
  1421. pGetChAuthCapRes->CompletionCode=0x00;
  1422. pGetChAuthCapRes->ChannelNum=0x01;
  1423. pGetChAuthCapRes->AuthType=0x36;
  1424. pGetChAuthCapRes->PerMsgUserAuthLoginStatus=0x04;
  1425. SessionSequenceNumberCount=0;
  1426. return sizeof(GetChAuthCapRes_T);
  1427. }
  1428. /*---------------------------------------
  1429. * GetSessionChallenge
  1430. *---------------------------------------*/
  1431. int
  1432. GetSessionChallenge (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1433. {
  1434. // printf("start GetSessionChallenge\n");
  1435. _NEAR_ GetSesChallengeReq_T* pGetSesChalReq = (_NEAR_ GetSesChallengeReq_T*)pReq;
  1436. _NEAR_ GetSesChallengeRes_T* pGetSesChalRes = (_NEAR_ GetSesChallengeRes_T*)pRes;
  1437. INT32U TemId=0xffb52dfb;//0xfb2db5ff
  1438. memset (pGetSesChalRes, 0, sizeof (GetSesChallengeRes_T));
  1439. pGetSesChalRes->CompletionCode=0x00;
  1440. pGetSesChalRes->TempSessionID=TemId;
  1441. pGetSesChalRes->ChallengeString[0]=0x54;
  1442. pGetSesChalRes->ChallengeString[1]=0xdf;
  1443. pGetSesChalRes->ChallengeString[2]=0xe1;
  1444. pGetSesChalRes->ChallengeString[3]=0xbf;
  1445. pGetSesChalRes->ChallengeString[4]=0x56;
  1446. pGetSesChalRes->ChallengeString[5]=0x47;
  1447. pGetSesChalRes->ChallengeString[6]=0x87;
  1448. pGetSesChalRes->ChallengeString[7]=0x88;
  1449. pGetSesChalRes->ChallengeString[8]=0xea;
  1450. pGetSesChalRes->ChallengeString[9]=0x7b;
  1451. pGetSesChalRes->ChallengeString[10]=0xa1;
  1452. pGetSesChalRes->ChallengeString[11]=0x54;
  1453. pGetSesChalRes->ChallengeString[12]=0x37;
  1454. pGetSesChalRes->ChallengeString[13]=0x5b;
  1455. pGetSesChalRes->ChallengeString[14]=0x79;
  1456. pGetSesChalRes->ChallengeString[15]=0xe3;
  1457. // SessionSequenceNumberCount=SessionSequenceNumberCount+1;
  1458. return sizeof (GetSesChallengeRes_T);
  1459. }
  1460. /*---------------------------------------
  1461. * ActivateSession
  1462. *---------------------------------------*/
  1463. int
  1464. ActivateSession (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1465. {
  1466. // printf("start ActivateSession:\n");
  1467. _NEAR_ ActivateSesReq_T* pAcvtSesReq = (_NEAR_ ActivateSesReq_T*)pReq;
  1468. _NEAR_ ActivateSesRes_T* pAcvtSesRes = (_NEAR_ ActivateSesRes_T*)pRes;
  1469. INT32U SesId=0xffb52dfb;//0xfb2db5ff;
  1470. INT32U InbSeq=0x2ae8944a;//0x4a94e82a;
  1471. memset (pAcvtSesRes, 0, sizeof (ActivateSesRes_T));
  1472. pAcvtSesRes->CompletionCode=0x00;
  1473. pAcvtSesRes->AuthType=0x02;
  1474. pAcvtSesRes->SessionID=SesId;
  1475. pAcvtSesRes->InboundSeq=InbSeq;
  1476. pAcvtSesRes->Privilege=0x04;
  1477. SessionSequenceNumberCount=SessionSequenceNumberCount+1;
  1478. return sizeof (ActivateSesRes_T);
  1479. }
  1480. /*---------------------------------------
  1481. * SetSessionPrivLevel
  1482. *---------------------------------------*/
  1483. int
  1484. SetSessionPrivLevel (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1485. {
  1486. _NEAR_ SetSesPrivLevelReq_T* pSetSesPrivLevelReq = (_NEAR_ SetSesPrivLevelReq_T*)pReq;
  1487. _NEAR_ SetSesPrivLevelRes_T* pSetSesPrivLevelRes = (_NEAR_ SetSesPrivLevelRes_T*)pRes;
  1488. memset (pSetSesPrivLevelRes, 0, sizeof (SetSesPrivLevelRes_T));
  1489. pSetSesPrivLevelRes->CompletionCode=0x00;
  1490. pSetSesPrivLevelRes->Privilege=0x04;
  1491. SessionSequenceNumberCount=SessionSequenceNumberCount+1;
  1492. return sizeof (SetSesPrivLevelRes_T);
  1493. }
  1494. /*---------------------------------------
  1495. * CloseSession
  1496. *---------------------------------------*/
  1497. int
  1498. CloseSession (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1499. {
  1500. SessionSequenceNumberCount=SessionSequenceNumberCount+1;
  1501. return sizeof (*pRes);
  1502. }
  1503. //#if GET_SESSION_INFO != UNIMPLEMENTED
  1504. /*---------------------------------------
  1505. * GetSessionInfo
  1506. *---------------------------------------*/
  1507. int
  1508. GetSessionInfo (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1509. {
  1510. // _NEAR_ GetSesInfoReq_T* pGetSesInfoReq = (_NEAR_ GetSesInfoReq_T*)pReq;
  1511. // _NEAR_ GetSesInfoRes_T* pGetSesInfoRes = (_NEAR_ GetSesInfoRes_T*)pRes;
  1512. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  1513. // LANSesInfoRes_T LANSesInfo;
  1514. // LANIPv6SesInfoRes_T LANIPv6SesInfo;
  1515. // _FAR_ SessionInfo_T* pSessInfo;
  1516. // _FAR_ ChannelInfo_T* pChannelInfo;
  1517. // _FAR_ void* SessionArg;
  1518. // INT8U SessionArgAlign[4];
  1519. // INT8U SessionArgType,EthIndex, netindex = 0xFF;
  1520. // char IfcName[IFNAMSIZ];
  1521. // INT32U *CurSesID,*curchannel;
  1522. // int i;
  1523. //
  1524. // *pRes = CC_REQ_INV_LEN;
  1525. //
  1526. // switch (pGetSesInfoReq->SessionIndex)
  1527. // {
  1528. // case 0:
  1529. // /* Get session information for this session */
  1530. // if (1 != ReqLen)
  1531. // {
  1532. // return sizeof (*pRes);
  1533. // }
  1534. // SessionArgType = SESSION_ID_INFO;
  1535. // OS_THREAD_TLS_GET(g_tls.CurSessionID,CurSesID);
  1536. // SessionArg = CurSesID;
  1537. // break;
  1538. //
  1539. // case 0xFF:
  1540. // if (5 != ReqLen)
  1541. // {
  1542. // return sizeof (*pRes);
  1543. // }
  1544. // SessionArgType = SESSION_ID_INFO;
  1545. //
  1546. // SessionArgAlign[0] = pGetSesInfoReq->SessionHandleOrID[0];
  1547. // SessionArgAlign[1] = pGetSesInfoReq->SessionHandleOrID[1];
  1548. // SessionArgAlign[2] = pGetSesInfoReq->SessionHandleOrID[2];
  1549. // SessionArgAlign[3] = pGetSesInfoReq->SessionHandleOrID[3];
  1550. // SessionArg = SessionArgAlign;
  1551. // break;
  1552. //
  1553. // case 0xFE:
  1554. // if (2 != ReqLen)
  1555. // {
  1556. // return sizeof (*pRes);
  1557. // }
  1558. // if (pGetSesInfoReq->SessionHandleOrID[0] == 0)
  1559. // {
  1560. // *pRes=CC_INV_DATA_FIELD;
  1561. // return sizeof (*pRes);
  1562. // }
  1563. // SessionArgType = SESSION_HANDLE_INFO;
  1564. // SessionArgAlign[0] = pGetSesInfoReq->SessionHandleOrID[0];
  1565. // SessionArgAlign[1] = pGetSesInfoReq->SessionHandleOrID[1];
  1566. // SessionArgAlign[2] = pGetSesInfoReq->SessionHandleOrID[2];
  1567. // SessionArgAlign[3] = pGetSesInfoReq->SessionHandleOrID[3];
  1568. // SessionArg = SessionArgAlign;
  1569. // break;
  1570. //
  1571. // default:
  1572. // if (1 != ReqLen)
  1573. // {
  1574. // return sizeof (*pRes);
  1575. // }
  1576. // SessionArgType = SESSION_INDEX_INFO;
  1577. // SessionArg = &pGetSesInfoReq->SessionIndex;
  1578. // break;
  1579. // }
  1580. //
  1581. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SessionTblMutex, WAIT_INFINITE);
  1582. // pSessInfo = getSessionInfo (SessionArgType, SessionArg, BMCInst);
  1583. // if (NULL == pSessInfo)
  1584. // {
  1585. // TDBG ("GetSessionInfo: pSessInfo is NULL\n");
  1586. // /* if there is no active channel for the current session Index
  1587. // * return the following bytes
  1588. // */
  1589. //
  1590. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  1591. // pChannelInfo = getChannelInfo (*curchannel & 0xF, BMCInst);
  1592. // if(NULL == pChannelInfo)
  1593. // {
  1594. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1595. // pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  1596. // return sizeof (*pRes);
  1597. // }
  1598. //
  1599. // pGetSesInfoRes->CompletionCode = CC_NORMAL;
  1600. // pGetSesInfoRes->SessionHandle = BMC_GET_SHARED_MEM (BMCInst)->SessionHandle;
  1601. // pGetSesInfoRes->NumPossibleActiveSession= pBMCInfo->IpmiConfig.MaxSession;
  1602. // pGetSesInfoRes->NumActiveSession = GetNumOfActiveSessions (BMCInst);
  1603. //
  1604. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1605. // return (sizeof (GetSesInfoRes_T) - sizeof (ActiveSesInfo_T) - sizeof (SessionInfoRes_T));
  1606. // }
  1607. //
  1608. // memset (pGetSesInfoRes,0,sizeof(GetSesInfoRes_T));
  1609. // pChannelInfo = getChannelInfo (pSessInfo->Channel, BMCInst);
  1610. // if(NULL == pChannelInfo)
  1611. // {
  1612. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1613. // pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  1614. // return sizeof (*pRes);
  1615. // }
  1616. // pGetSesInfoRes->CompletionCode = CC_NORMAL;
  1617. // pGetSesInfoRes->SessionHandle = pSessInfo->SessionHandle;
  1618. // pGetSesInfoRes->NumPossibleActiveSession = pBMCInfo->IpmiConfig.MaxSession;
  1619. // pGetSesInfoRes->NumActiveSession = GetNumOfActiveSessions (BMCInst);
  1620. // pGetSesInfoRes->ActiveSesinfo.UserID = pSessInfo->UserId & 0x3F;
  1621. // pGetSesInfoRes->ActiveSesinfo.Privilege = pSessInfo->Privilege & 0x0F;
  1622. // /* Set protocol bit as per Auth Type, bit4 must be 1 for IPMIv2.0 RMCP, 0 for IPMIv1.5 */
  1623. // if( AUTHTYPE_RMCP_PLUS_FORMAT == pSessInfo->AuthType )
  1624. // {
  1625. // pGetSesInfoRes->ActiveSesinfo.ChannelNum = (pSessInfo->Channel & 0x0F) | 0x10;
  1626. // }else
  1627. // {
  1628. // pGetSesInfoRes->ActiveSesinfo.ChannelNum = pSessInfo->Channel & 0x0F;
  1629. // }
  1630. // EthIndex= GetEthIndex(pSessInfo->Channel & 0x0F, BMCInst);
  1631. // if(0xff == EthIndex)
  1632. // {
  1633. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1634. // *pRes = CC_INV_DATA_FIELD;
  1635. // DeleteSession (pSessInfo,BMCInst);
  1636. // return sizeof (INT8U);
  1637. // }
  1638. // memset(IfcName,0,sizeof(IfcName));
  1639. // /*Get the EthIndex*/
  1640. // if(GetIfcName(EthIndex,IfcName, BMCInst) == -1)
  1641. // {
  1642. // TCRIT("Error in Getting Ifc name\n");
  1643. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1644. // *pRes = CC_INV_DATA_FIELD;
  1645. // return sizeof (INT8U);
  1646. // }
  1647. //
  1648. // for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
  1649. // {
  1650. // if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
  1651. // {
  1652. // netindex= Ifcnametable[i].Index;
  1653. // break;
  1654. // }
  1655. // }
  1656. //
  1657. // if(netindex == 0xFF)
  1658. // {
  1659. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1660. // *pRes = CC_INV_DATA_FIELD;
  1661. // return sizeof (INT8U);
  1662. // }
  1663. // if (IsLANChannel( pSessInfo->Channel, BMCInst))
  1664. // {
  1665. // if(g_corefeatures.global_ipv6 == ENABLED)
  1666. // {
  1667. // if(GetIPAdrressType(&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[0])==4)
  1668. // {
  1669. // memset(&LANSesInfo,0,sizeof(LANSesInfo));
  1670. // /* IP Address */
  1671. // _fmemcpy (&(LANSesInfo.IPAddress),
  1672. // &pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[sizeof(struct in6_addr)-sizeof(struct in_addr)],
  1673. // sizeof(struct in_addr));
  1674. // /* MAC Address */
  1675. // if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
  1676. // nwGetSrcCacheMacAddr((INT8U*)&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[12],
  1677. // netindex, pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
  1678. //
  1679. // _fmemcpy(LANSesInfo.MACAddress, pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
  1680. // /* Port number */
  1681. // LANSesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
  1682. //
  1683. // _fmemcpy ((pRes+sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)),&LANSesInfo, sizeof (LANSesInfoRes_T));
  1684. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1685. // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)+sizeof (LANSesInfoRes_T));
  1686. // }
  1687. // else
  1688. // {
  1689. // /* IP Address */
  1690. // memset(&LANIPv6SesInfo,0,sizeof(LANIPv6SesInfo));
  1691. // _fmemcpy (&(LANIPv6SesInfo.IPv6Address),
  1692. // pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr,
  1693. // sizeof(struct in6_addr));
  1694. // /* MAC Address */
  1695. // if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
  1696. // nwGetSrcMacAddr_IPV6((INT8U*)&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr,
  1697. // pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
  1698. //
  1699. // _fmemcpy(LANIPv6SesInfo.MACAddress, pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
  1700. // /* Port number */
  1701. // LANIPv6SesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
  1702. //
  1703. // _fmemcpy ((pRes+sizeof (GetSesInfoRes_T) - sizeof(SessionInfoRes_T)),&LANIPv6SesInfo, sizeof (LANIPv6SesInfoRes_T));
  1704. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1705. // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)+sizeof (LANIPv6SesInfoRes_T));
  1706. // }
  1707. // }
  1708. // else
  1709. // {
  1710. //
  1711. // /* IP Address */
  1712. // _fmemcpy (pGetSesInfoRes->SesInfo.LANSesInfo.IPAddress,
  1713. // pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr,
  1714. // sizeof (pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr));
  1715. // /* MAC Address */
  1716. // if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
  1717. // nwGetSrcCacheMacAddr((INT8U*)pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr, netindex,
  1718. // pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
  1719. // _fmemcpy(pGetSesInfoRes->SesInfo.LANSesInfo.MACAddress,
  1720. // pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
  1721. // /* Port number */
  1722. // pGetSesInfoRes->SesInfo.LANSesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
  1723. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1724. // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T) + sizeof (LANSesInfoRes_T));
  1725. // }
  1726. // }
  1727. // else if (pBMCInfo->IpmiConfig.SerialIfcSupport == 1 && pBMCInfo->SERIALch== pSessInfo->Channel)
  1728. // {
  1729. //
  1730. // pChannelInfo = getChannelInfo (pBMCInfo->SERIALch, BMCInst);
  1731. // if(NULL == pChannelInfo)
  1732. // {
  1733. // pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  1734. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1735. // return sizeof (*pRes);
  1736. // }
  1737. //
  1738. // pGetSesInfoRes->SesInfo.SerialSesInfo.SessionActivityType = 0;
  1739. // pGetSesInfoRes->SesInfo.SerialSesInfo.DestinationSelector = 0;
  1740. //
  1741. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1742. // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T) + sizeof (SerialSesInfoRes_T));
  1743. // }
  1744. // else
  1745. // {
  1746. // pChannelInfo = getChannelInfo(pSessInfo->Channel, BMCInst);
  1747. // if(NULL == pChannelInfo)
  1748. // {
  1749. // pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  1750. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1751. // return sizeof (*pRes);
  1752. // }
  1753. //
  1754. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1755. // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T));
  1756. // }
  1757. }
  1758. //#endif
  1759. /**
  1760. * @fn GetAuthCodeForTypeV15
  1761. * @brief This function will use the encryption technique supported
  1762. * in IPMI V1.5 in order to produce Auth Code.
  1763. * @param[in] pUserInfo - Pointer to User info structure.
  1764. * @param[in] pGetAuthCodeReq - Pointer to the structure of request data
  1765. * @param[out] pGetAuthCodeRes - Pointer to the resultant data.
  1766. * @retval size of the result data.
  1767. */
  1768. static int
  1769. GetAuthCodeForTypeV15 (UserInfo_T* pUserInfo,
  1770. GetAuthCodeReq_T* pGetAuthCodeReq,
  1771. GetAuthCodeRes_T* pGetAuthCodeRes,int BMCInst)
  1772. {
  1773. // INT8U AuthCode;
  1774. // INT8U InBuffer[2*IPMI15_MAX_PASSWORD_LEN + HASH_DATA_LENGTH];
  1775. // char UserPswd[MAX_PASSWD_LEN];
  1776. // INT8U PwdEncKey[MAX_SIZE_KEY + 1] = {0};
  1777. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  1778. //
  1779. // memset(&(pGetAuthCodeRes->AuthCode), 0, AUTH_CODE_HASH_LEN);
  1780. // AuthCode = pGetAuthCodeReq->AuthType & AUTH_CODE_V15_MASK;
  1781. // if((pGetAuthCodeReq->AuthType & (BIT5 | BIT4)) ||
  1782. // (AuthCode == AUTHTYPE_RESERVED) || (AuthCode == AUTHTYPE_NONE) ||
  1783. // (AuthCode == AUTHTYPE_STRAIGHT_PASSWORD) ||
  1784. // (AuthCode > AUTHTYPE_OEM_PROPRIETARY))
  1785. // {
  1786. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1787. // return (sizeof (GetAuthCodeRes_T) - 4);
  1788. // }
  1789. //
  1790. // if (g_corefeatures.userpswd_encryption == ENABLED)
  1791. // {
  1792. // /* Get Encryption Key from the MBMCInfo_t structure */
  1793. // LOCK_BMC_SHARED_MEM(BMCInst);
  1794. // memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
  1795. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1796. //
  1797. // if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[pUserInfo->UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
  1798. // {
  1799. // TCRIT("Error in decrypting the IPMI User password for User ID:%d.\n", pUserInfo->UserId);
  1800. // pGetAuthCodeRes->CompletionCode = CC_UNSPECIFIED_ERR;
  1801. // return sizeof(*pGetAuthCodeRes);
  1802. // }
  1803. // memcpy(&InBuffer[0],UserPswd,IPMI15_MAX_PASSWORD_LEN);
  1804. // }
  1805. // else
  1806. // {
  1807. // memcpy(&InBuffer[0],pUserInfo->UserPassword,IPMI15_MAX_PASSWORD_LEN);
  1808. // }
  1809. //
  1810. // LOCK_BMC_SHARED_MEM(BMCInst);
  1811. // switch (AuthCode)
  1812. // {
  1813. // #if 0 // As per IPMIv2 Markup E4, Straight Password key is Reserved
  1814. // case AUTH_TYPE_PASSWORD: /* Straight password */
  1815. // if (0 == _fmemcmp (pUserInfo->UserPassword,pGetAuthCodeReq->HashData,IPMI15_MAX_PASSWORD_LEN))
  1816. // {
  1817. // _fmemcpy (pGetAuthCodeRes->AuthCode, "OK", 2);
  1818. // }
  1819. // else
  1820. // {
  1821. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1822. // }
  1823. // break;
  1824. // #endif
  1825. //
  1826. // case AUTH_TYPE_MD2: /* MD2 */
  1827. // _fmemcpy (&InBuffer[IPMI15_MAX_PASSWORD_LEN],
  1828. // pGetAuthCodeReq->HashData, HASH_DATA_LENGTH);
  1829. // if (g_corefeatures.userpswd_encryption == ENABLED)
  1830. // {
  1831. // _fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
  1832. // UserPswd, IPMI15_MAX_PASSWORD_LEN);
  1833. // }
  1834. // else
  1835. // {
  1836. // _fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
  1837. // pUserInfo->UserPassword, IPMI15_MAX_PASSWORD_LEN);
  1838. // }
  1839. //
  1840. // AuthCodeCalMD2 (InBuffer, pGetAuthCodeRes->AuthCode, sizeof (InBuffer));
  1841. // break;
  1842. //
  1843. // case AUTH_TYPE_MD5: /* MD5 */
  1844. // _fmemcpy (&InBuffer[IPMI15_MAX_PASSWORD_LEN],
  1845. // pGetAuthCodeReq->HashData, HASH_DATA_LENGTH);
  1846. // if (g_corefeatures.userpswd_encryption == ENABLED)
  1847. // {
  1848. // _fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
  1849. // UserPswd,IPMI15_MAX_PASSWORD_LEN);
  1850. // }
  1851. // else
  1852. // {
  1853. // _fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
  1854. // pUserInfo->UserPassword,IPMI15_MAX_PASSWORD_LEN);
  1855. // }
  1856. // AuthCodeCalMD5 (InBuffer, pGetAuthCodeRes->AuthCode, sizeof (InBuffer));
  1857. // break;
  1858. //
  1859. // default:
  1860. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1861. // }
  1862. //
  1863. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1864. // // IPMI V1.5 AuthCode is only 16 byte.
  1865. // return (sizeof (GetAuthCodeRes_T) - 4);
  1866. }
  1867. /**
  1868. * @fn GetAuthCodeForTypeV20
  1869. * @brief This function will use the encryption technique supported
  1870. * in IPMI V2.0 in order to produce Auth Code.
  1871. * @param[in] pUserInfo - Pointer to User info structure.
  1872. * @param[in] pGetAuthCodeReq - Pointer to the structure of request data
  1873. * @param[out] pGetAuthCodeRes - Pointer to the resultant data.
  1874. * @retval size of the result data.
  1875. */
  1876. static int
  1877. GetAuthCodeForTypeV20 (UserInfo_T* pUserInfo,
  1878. GetAuthCodeReq_T* pGetAuthCodeReq,
  1879. GetAuthCodeRes_T* pGetAuthCodeRes,int BMCInst)
  1880. {
  1881. // INT8U AuthCode;
  1882. // INT8U UserPasswdLen=0;
  1883. // INT8U DecVal = 0;
  1884. // _FAR_ INT8U m_SIK [SESSION_INTEGRITY_KEY_SIZE];
  1885. // char UserPswd[MAX_PASSWD_LEN];
  1886. // unsigned char PwdEncKey[MAX_SIZE_KEY + 1] = {0};
  1887. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  1888. //
  1889. // if (g_corefeatures.userpswd_encryption == ENABLED)
  1890. // {
  1891. // /* Get Encryption Key from the MBMCInfo_t structure */
  1892. // LOCK_BMC_SHARED_MEM(BMCInst);
  1893. // memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
  1894. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1895. //
  1896. // if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[pUserInfo->UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
  1897. // {
  1898. // TCRIT("\nError in decrypting the IPMI User password for user with ID:%d.\n", pUserInfo->UserId);
  1899. // pGetAuthCodeRes->CompletionCode = CC_UNSPECIFIED_ERR;
  1900. // return sizeof (*pGetAuthCodeRes);
  1901. // }
  1902. // }
  1903. // else
  1904. // {
  1905. // memcpy(&UserPswd, pUserInfo->UserPassword, MAX_PASSWD_LEN);
  1906. // }
  1907. //
  1908. // /* Calculate password length */
  1909. // UserPasswdLen = _fstrlen ((_FAR_ char*)UserPswd);
  1910. // UserPasswdLen = (UserPasswdLen > MAX_PASSWORD_LEN) ?
  1911. // MAX_PASSWORD_LEN : UserPasswdLen;
  1912. //
  1913. // memset(&(pGetAuthCodeRes->AuthCode), 0, AUTH_CODE_HASH_LEN);
  1914. // AuthCode = pGetAuthCodeReq->AuthType & AUTH_CODE_V20_MASK;
  1915. // /* Validate the Auth Code */
  1916. // if ((AuthCode > MIN_AUTH_CODE_V20) && (AuthCode < MAX_AUTH_CODE_V20))
  1917. // {
  1918. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1919. // return sizeof(GetAuthCodeRes_T);
  1920. // }
  1921. //
  1922. // LOCK_BMC_SHARED_MEM(BMCInst);
  1923. // switch(AuthCode)
  1924. // {
  1925. // case AUTH_NONE: /* none */
  1926. // TDBG ("\nInside AUTH_NONE in GetAuthCode");
  1927. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1928. // break;
  1929. //
  1930. // case AUTH_HMAC_SHA1_96: /* HMAC-SHA1-96 */
  1931. // TDBG ("\nInside AUTH_HMAC_SHA1_96 in GetAuthCode");
  1932. // hmac_sha1 ((INT8U *)UserPswd, UserPasswdLen,
  1933. // (INT8U *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1934. // (INT8U *)m_SIK, SESSION_INTEGRITY_KEY_SIZE);
  1935. //
  1936. // hmac_sha1 ((INT8U *)m_SIK, SESSION_INTEGRITY_KEY_SIZE,
  1937. // (INT8U *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1938. // (INT8U *)&(pGetAuthCodeRes->AuthCode), HMAC_SHA1_96_LEN);
  1939. //
  1940. // DecVal = AUTH_CODE_HASH_LEN - HMAC_SHA1_96_LEN;
  1941. // break;
  1942. //
  1943. // case AUTH_HMAC_MD5_128: /* HMAC-MD5-128 */
  1944. // TDBG ("\nInside AUTH_HMAC_MD5_128 in GetAuthCode");
  1945. // hmac_md5 ((unsigned char*)UserPswd, UserPasswdLen,
  1946. // pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1947. // m_SIK, SESSION_HMAC_MD5_I_KEY_SIZE);
  1948. //
  1949. // hmac_md5 (m_SIK, SESSION_HMAC_MD5_I_KEY_SIZE,
  1950. // pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1951. // (unsigned char *)&(pGetAuthCodeRes->AuthCode),
  1952. // SESSION_HMAC_MD5_I_KEY_SIZE);
  1953. // DecVal = AUTH_CODE_HASH_LEN - SESSION_HMAC_MD5_I_KEY_SIZE;
  1954. // break;
  1955. //
  1956. // case AUTH_MD5_128: /* MD5-128 */
  1957. // TDBG ("\nInside AUTH_MD5_128 in GetAuthCode");
  1958. // MD5_128 ((char *)UserPswd, UserPasswdLen,
  1959. // (char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1960. // (char *)m_SIK, SESSION_MD5_KEY_SIZE);
  1961. //
  1962. // MD5_128 ((char *)m_SIK, SESSION_INTEGRITY_KEY_SIZE,
  1963. // (char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1964. // (char *)&(pGetAuthCodeRes->AuthCode), SESSION_MD5_KEY_SIZE);
  1965. // DecVal = AUTH_CODE_HASH_LEN - SESSION_MD5_KEY_SIZE;
  1966. // break;
  1967. //
  1968. // case AUTH_HMAC_SHA256_128: /* HMAC-SHA256-128 */
  1969. // TDBG ("\nInside AUTH_HMAC_SHA256_128 in GetAuthCode");
  1970. // hmac_sha256 ((unsigned char *)UserPswd, UserPasswdLen,
  1971. // (unsigned char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1972. // (unsigned char *)m_SIK, SHA2_HASH_KEY_SIZE);
  1973. //
  1974. // hmac_sha256 (m_SIK, SHA2_HASH_KEY_SIZE,
  1975. // (unsigned char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1976. // (unsigned char *)&(pGetAuthCodeRes->AuthCode), HMAC_SHA256_128_LEN);
  1977. // DecVal = AUTH_CODE_HASH_LEN - HMAC_SHA256_128_LEN;
  1978. // break;
  1979. //
  1980. // //! TODO: Need support in openssl.
  1981. // default: /* OEM or Reserved */
  1982. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1983. // }
  1984. //
  1985. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1986. // if (DecVal > sizeof(GetAuthCodeRes_T))
  1987. // return sizeof(GetAuthCodeRes_T);
  1988. // else
  1989. // return (sizeof(GetAuthCodeRes_T) - DecVal);
  1990. }
  1991. /**
  1992. * @fn GetAuthCode
  1993. * @brief This function will encrypt the given 16 byte data with
  1994. * the algorithm given and return Auth Code.
  1995. * @param[in] pReq - Request data.
  1996. * @param[in] ReqLen - Length of the request data.
  1997. * @param[out] pRes - Result data
  1998. * @retval size of the result data.
  1999. */
  2000. int
  2001. GetAuthCode (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,int BMCInst)
  2002. {
  2003. _NEAR_ GetAuthCodeReq_T* pGetAuthCodeReq = (_NEAR_ GetAuthCodeReq_T*)pReq;
  2004. _NEAR_ GetAuthCodeRes_T* pGetAuthCodeRes = (_NEAR_ GetAuthCodeRes_T*)pRes;
  2005. BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  2006. _FAR_ UserInfo_T* pUserInfo;
  2007. INT8U AuthType,*curchannel;
  2008. _FAR_ ChannelInfo_T* pChannelInfo;
  2009. int nRetSize = 0;
  2010. // printf("start GetAuthCode\n");
  2011. /* Check for Reserved Bits */
  2012. if((pGetAuthCodeReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4)) ||
  2013. (pGetAuthCodeReq->UserID & (BIT7 | BIT6)))
  2014. {
  2015. pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  2016. return sizeof(*pRes);
  2017. }
  2018. //OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  2019. /* Validate the channel number given */
  2020. if (CURRENT_CHANNEL_NUM == pGetAuthCodeReq->ChannelNum)
  2021. {
  2022. OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  2023. pChannelInfo = getChannelInfo(*curchannel & 0xF,BMCInst);
  2024. }
  2025. else
  2026. pChannelInfo = getChannelInfo(pGetAuthCodeReq->ChannelNum,BMCInst);
  2027. if (NULL == pChannelInfo)
  2028. {
  2029. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2030. *pRes = CC_INV_DATA_FIELD;
  2031. return sizeof(*pRes);
  2032. }
  2033. /* Get the user information for the given userID */
  2034. pUserInfo = getUserIdInfo (pGetAuthCodeReq->UserID,BMCInst);
  2035. if (NULL == pUserInfo)
  2036. {
  2037. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2038. TDBG ("AppDevice.c : GetAuthCode - Invalid user Id\n");
  2039. pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  2040. return sizeof (*pRes);
  2041. }
  2042. AuthType = pGetAuthCodeReq->AuthType & GET_AUTH_TYPE_MASK;
  2043. pGetAuthCodeRes->CompletionCode = CC_NORMAL;
  2044. switch(AuthType)
  2045. {
  2046. case AUTH_TYPE_V15: /* IPMI v1.5 AuthCode Algorithms */
  2047. nRetSize = GetAuthCodeForTypeV15(pUserInfo, pGetAuthCodeReq, pGetAuthCodeRes,BMCInst);
  2048. break;
  2049. case AUTH_TYPE_V20: /* IPMI v2.0/RMCP+ Algorithm Number */
  2050. nRetSize = GetAuthCodeForTypeV20(pUserInfo, pGetAuthCodeReq, pGetAuthCodeRes,BMCInst);
  2051. break;
  2052. default:
  2053. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2054. pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  2055. return sizeof(*pRes);
  2056. }
  2057. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2058. return nRetSize;
  2059. }
  2060. /*---------------------------------------
  2061. * SetChAccess
  2062. *---------------------------------------*/
  2063. int
  2064. SetChAccess (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  2065. {
  2066. // _NEAR_ SetChAccessReq_T* pSetChAccessReq = (_NEAR_ SetChAccessReq_T*)pReq;
  2067. // INT8U ChannelNum, AccessMode;
  2068. // _FAR_ ChannelInfo_T* pNvrChInfo;
  2069. // _FAR_ ChannelInfo_T* pChannelInfo;
  2070. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  2071. // INT8U AccessFlags = 0,i=0,*curchannel;
  2072. //// char ChFilename[MAX_CHFILE_NAME];
  2073. //
  2074. // /* Reserve Bit Checking for Set Channel Acces */
  2075. // for(i=0;i<ReqLen;i++)
  2076. // {
  2077. // if( 0 != (pReq[i] & m_Set_ChReserveBit[i]))
  2078. // {
  2079. // *pRes = CC_INV_DATA_FIELD;
  2080. // return sizeof (*pRes);
  2081. // }
  2082. // }
  2083. // /* Reserve Value checking */
  2084. //
  2085. // if((pReq[1] & 0xC0)== 0xC0 || (pReq[2] & 0xC0) == 0xC0)
  2086. // {
  2087. // *pRes = CC_INV_DATA_FIELD;
  2088. // return sizeof (*pRes);
  2089. // }
  2090. //
  2091. // ChannelNum = pSetChAccessReq->ChannelNum & 0x0F;
  2092. // if (CURRENT_CHANNEL_NUM == ChannelNum)
  2093. // {
  2094. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  2095. // ChannelNum = *curchannel & 0xF;
  2096. // }
  2097. //
  2098. // if (((GetBits (pSetChAccessReq->Privilege, 0x0F)) < PRIV_LEVEL_CALLBACK) ||
  2099. // ((GetBits (pSetChAccessReq->Privilege, 0x0F)) > PRIV_LEVEL_PROPRIETARY))
  2100. // {
  2101. // IPMI_DBG_PRINT_1 ("Invalid Channel Privilege = 0x%x\n", pSetChAccessReq->Privilege);
  2102. // *pRes = CC_INV_DATA_FIELD;
  2103. // return sizeof (*pRes);
  2104. // }
  2105. //
  2106. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  2107. // pChannelInfo = getChannelInfo(ChannelNum, BMCInst);
  2108. // if (NULL == pChannelInfo)
  2109. // {
  2110. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2111. // *pRes = CC_INV_DATA_FIELD;
  2112. // return sizeof (*pRes);
  2113. // }
  2114. //
  2115. // /*point to NVRAM ChannelInfo */
  2116. // pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
  2117. //
  2118. // if (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport)
  2119. // {
  2120. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2121. // /* Channel is sessionless channel this command is not supported */
  2122. // *pRes = CC_SET_CH_COMMAND_NOT_SUPPORTED;
  2123. // return sizeof (*pRes);
  2124. // }
  2125. //
  2126. //
  2127. // AccessMode = pSetChAccessReq->ChannelAccess & 0x07;
  2128. // if(ChannelNum == pBMCInfo->SERIALch)
  2129. // {
  2130. // if( NULL != g_PDKHandle[PDK_SWITCHMUX])
  2131. // {
  2132. // ((void(*)(INT8U, int))(g_PDKHandle[PDK_SWITCHMUX]))(AccessMode ,BMCInst);
  2133. // }
  2134. // }
  2135. //
  2136. // /* if the requested access mode is supported for the given channel */
  2137. // if (0 == (pChannelInfo->AccessModeSupported & (1 << AccessMode)))
  2138. // {
  2139. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2140. // *pRes = CC_SET_CH_ACCES_MODE_NOT_SUPPORTED;
  2141. // return sizeof (*pRes);
  2142. // }
  2143. //
  2144. // AccessFlags = GetBits (pSetChAccessReq->ChannelAccess, 0xC0);
  2145. //
  2146. // switch (AccessFlags)
  2147. // {
  2148. // case 0:
  2149. // /* dont set channel access */
  2150. // break;
  2151. //
  2152. // case 1:
  2153. // /*set in Non volatile Memory and in voatile Memory */
  2154. // pNvrChInfo->Alerting = GetBits (pSetChAccessReq->ChannelAccess , 0x20);
  2155. // pNvrChInfo->PerMessageAuth = GetBits (pSetChAccessReq->ChannelAccess , 0x10);
  2156. // pNvrChInfo->UserLevelAuth = GetBits (pSetChAccessReq->ChannelAccess , 0x08);
  2157. // pNvrChInfo->AccessMode = AccessMode;
  2158. // /* write to NVRAM */
  2159. // FlushChConfigs((INT8U*)pNvrChInfo,pNvrChInfo->ChannelNumber,BMCInst);
  2160. // pChannelInfo->Alerting = pNvrChInfo->Alerting;
  2161. // pChannelInfo->PerMessageAuth= pNvrChInfo->PerMessageAuth;
  2162. // pChannelInfo->UserLevelAuth = pNvrChInfo->UserLevelAuth;
  2163. // pChannelInfo->AccessMode = AccessMode;
  2164. // break;
  2165. //
  2166. // case 2:
  2167. // /*set in volatile Memmory only */
  2168. // pChannelInfo->Alerting = GetBits (pSetChAccessReq->ChannelAccess, 0x20);
  2169. // pChannelInfo->PerMessageAuth= GetBits (pSetChAccessReq->ChannelAccess, 0x10);
  2170. // pChannelInfo->UserLevelAuth = GetBits (pSetChAccessReq->ChannelAccess, 0x08);
  2171. // pChannelInfo->AccessMode = AccessMode;
  2172. // }
  2173. //
  2174. // switch (GetBits (pSetChAccessReq->Privilege, 0xC0))
  2175. // {
  2176. // case 0:
  2177. // /* dont set prilivege level */
  2178. // break;
  2179. //
  2180. // case 1:
  2181. // /* set in non volatile mem and volatile memeory*/ /*set privilege*/
  2182. // pNvrChInfo->MaxPrivilege = GetBits (pSetChAccessReq->Privilege, 0x0F);
  2183. // pChannelInfo->MaxPrivilege = pNvrChInfo->MaxPrivilege;
  2184. // break;
  2185. //
  2186. // case 2:
  2187. // /*set privilege*/
  2188. // /* set in volatile memeory only */
  2189. // pChannelInfo->MaxPrivilege = GetBits (pSetChAccessReq->Privilege, 0x0F);
  2190. // }
  2191. //
  2192. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2193. // *pRes = CC_NORMAL;
  2194. //
  2195. // return sizeof (*pRes);
  2196. }
  2197. /*---------------------------------------
  2198. * GetChAccess
  2199. *---------------------------------------*/
  2200. int
  2201. GetChAccess (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  2202. {
  2203. // _NEAR_ GetChAccessReq_T* pGetChAccessReq = (_NEAR_ GetChAccessReq_T*)pReq;
  2204. // _NEAR_ GetChAccessRes_T* pGetChAccessRes = (_NEAR_ GetChAccessRes_T*)pRes;
  2205. // _FAR_ ChannelInfo_T* pChannelInfo;
  2206. // _FAR_ ChannelInfo_T* pNvrChInfo;
  2207. // INT8U ChannelNum,AccessFlag,*curchannel;
  2208. // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  2209. //
  2210. // /* Check for reserved bits */
  2211. // if((0 != (pGetChAccessReq->ChannelNum & 0xf0)) ||
  2212. // (0 != (pGetChAccessReq-> AccessFlag & 0x3f)))
  2213. // {
  2214. // pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
  2215. // return sizeof (*pRes);
  2216. // }
  2217. //
  2218. // ChannelNum = pGetChAccessReq->ChannelNum & 0x0F;
  2219. // if (CURRENT_CHANNEL_NUM == ChannelNum)
  2220. // {
  2221. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  2222. // ChannelNum = *curchannel & 0xF;
  2223. // }
  2224. //
  2225. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  2226. // pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
  2227. //
  2228. // if (NULL == pChannelInfo)
  2229. // {
  2230. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2231. // pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
  2232. // return sizeof (*pRes);
  2233. // }
  2234. //
  2235. // if (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport)
  2236. // {
  2237. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2238. // /* Channel is sessionless channel this command is not supported */
  2239. // pGetChAccessRes->CompletionCode = CC_GET_CH_COMMAND_NOT_SUPPORTED;
  2240. // return sizeof (*pRes);
  2241. // }
  2242. //
  2243. // AccessFlag = GetBits (pGetChAccessReq->AccessFlag, 0xC0);
  2244. //
  2245. // pGetChAccessRes->CompletionCode = CC_NORMAL;
  2246. //
  2247. // switch (AccessFlag)
  2248. // {
  2249. // case 1:
  2250. // /* Get Channel Information from NVRAM */
  2251. // pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
  2252. //
  2253. // pGetChAccessRes->ChannelAccess = SetBits (0x20, pNvrChInfo->Alerting);
  2254. // pGetChAccessRes->ChannelAccess |= SetBits (0x10, pNvrChInfo->PerMessageAuth);
  2255. // pGetChAccessRes->ChannelAccess |= SetBits (0x08, pNvrChInfo->UserLevelAuth);
  2256. // pGetChAccessRes->ChannelAccess |= SetBits (0x07, pNvrChInfo->AccessMode);
  2257. // pGetChAccessRes->Privilege = SetBits (0x0F, pNvrChInfo->MaxPrivilege);
  2258. // break;
  2259. //
  2260. // case 2:
  2261. // /* Get Channel Information from Volatile RAM */
  2262. // pGetChAccessRes->ChannelAccess = SetBits (0x20, pChannelInfo->Alerting);
  2263. // pGetChAccessRes->ChannelAccess |= SetBits (0x10, pChannelInfo->PerMessageAuth);
  2264. // pGetChAccessRes->ChannelAccess |= SetBits (0x08, pChannelInfo->UserLevelAuth);
  2265. // pGetChAccessRes->ChannelAccess |= SetBits (0x07, pChannelInfo->AccessMode);
  2266. // pGetChAccessRes->Privilege = SetBits (0x0F, pChannelInfo->MaxPrivilege);
  2267. // break;
  2268. //
  2269. // default:
  2270. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2271. // pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
  2272. // return sizeof (*pRes);
  2273. // }
  2274. //
  2275. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2276. // return sizeof (GetChAccessRes_T);
  2277. }
  2278. /*---------------------------------------
  2279. * GetChInfo
  2280. *---------------------------------------*/
  2281. int
  2282. GetChInfo (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  2283. {
  2284. // _NEAR_ GetChInfoReq_T* pGetChInfoReq = (_NEAR_ GetChInfoReq_T*)pReq;
  2285. // _NEAR_ GetChInfoRes_T* pGetChInfoRes = (_NEAR_ GetChInfoRes_T*)pRes;
  2286. // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  2287. // _FAR_ ChannelInfo_T* pChannelInfo;
  2288. // INT8U ChannelNum,*curchannel;
  2289. //
  2290. // if(pGetChInfoReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4)) //Check for Reserved bits
  2291. // {
  2292. // pGetChInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  2293. // return sizeof(*pRes);
  2294. // }
  2295. //
  2296. // ChannelNum = pGetChInfoReq->ChannelNum;
  2297. // if (CURRENT_CHANNEL_NUM == ChannelNum)
  2298. // {
  2299. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  2300. // ChannelNum = *curchannel & 0xF;
  2301. //
  2302. // /* UDS, not being a physical channel, will hold LAN properties */
  2303. // if(UDS_CHANNEL == ChannelNum)
  2304. // {
  2305. // ChannelNum = LAN_RMCP_CHANNEL1_TYPE;
  2306. // }
  2307. // }
  2308. //
  2309. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  2310. // pChannelInfo = getChannelInfo(ChannelNum, BMCInst);
  2311. // if (NULL == pChannelInfo)
  2312. // {
  2313. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2314. // pGetChInfoRes->CompletionCode = CC_INV_DATA_FIELD ;
  2315. // return sizeof (*pRes);
  2316. // }
  2317. //
  2318. // pGetChInfoRes->CompletionCode = CC_NORMAL;
  2319. // pGetChInfoRes->ChannelNum = ChannelNum;
  2320. // pGetChInfoRes->ChannelMedium = pChannelInfo->ChannelMedium;
  2321. // pGetChInfoRes->ChannelProtocol = pChannelInfo->ChannelProtocol;
  2322. // pGetChInfoRes->SessionActiveSupport = pChannelInfo->SessionSupport << 6;
  2323. // pGetChInfoRes->SessionActiveSupport |= pChannelInfo->ActiveSession;
  2324. //
  2325. // _fmemcpy (pGetChInfoRes->VendorID, pChannelInfo->ProtocolVendorId,
  2326. // sizeof (pGetChInfoRes->VendorID));
  2327. // _fmemcpy (pGetChInfoRes->AuxiliaryInfo, pChannelInfo->AuxiliaryInfo,
  2328. // sizeof (pGetChInfoRes->AuxiliaryInfo));
  2329. //
  2330. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2331. //
  2332. // return sizeof (GetChInfoRes_T);
  2333. }
  2334. /*---------------------------------------
  2335. * IsChannelSuppGroups
  2336. *---------------------------------------*/
  2337. INT8U IsChannelSuppGroups(INT8U ChannelNum,int BMCInst)
  2338. {
  2339. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  2340. // _FAR_ ChannelInfo_T* pChannelInfo;
  2341. // if(IsLANChannel(ChannelNum, BMCInst))
  2342. // {
  2343. //
  2344. // pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
  2345. // if(pChannelInfo==NULL)
  2346. // return 0;
  2347. // if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL1_TYPE)
  2348. // {
  2349. // return pChannelInfo->ChannelType;
  2350. // }
  2351. // else
  2352. // {
  2353. // if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL2_TYPE)
  2354. // {
  2355. // return pChannelInfo->ChannelType;
  2356. // }
  2357. // else
  2358. // {
  2359. // if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL3_TYPE)
  2360. // {
  2361. // return pChannelInfo->ChannelType;
  2362. // }
  2363. // else
  2364. // return 0;
  2365. // }
  2366. // }
  2367. // return 0;
  2368. // }
  2369. // else
  2370. // {
  2371. // if (pBMCInfo->IpmiConfig.SerialIfcSupport == 1 && (pBMCInfo->SERIALch != CH_NOT_USED && ChannelNum == pBMCInfo->SERIALch))
  2372. // {
  2373. // pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
  2374. // if(pChannelInfo==NULL)
  2375. // return 0;
  2376. // return pChannelInfo->ChannelType;
  2377. // }
  2378. // else
  2379. // return 0;
  2380. // }
  2381. }
  2382. /*---------------------------------------
  2383. * ModifyUsrGRP
  2384. *---------------------------------------*/
  2385. int
  2386. ModifyUsrGrp(char * UserName,INT8U ChannelNum,INT8U OldAccessLimit, INT8U NewAccessLimit )
  2387. {
  2388. //
  2389. // char oldgrp[20]="",newgrp[20]="";
  2390. //
  2391. // if(0 == NewAccessLimit)
  2392. // {
  2393. // DeleteUsrFromIPMIGrp(UserName);
  2394. // }
  2395. //
  2396. // if(PRIV_LEVEL_NO_ACCESS == OldAccessLimit)
  2397. // {
  2398. // strcpy(oldgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege].grpname);
  2399. // }
  2400. // else if(IGNORE_ADD_OR_REMOVE != OldAccessLimit)
  2401. // {
  2402. // strcpy(oldgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege+OldAccessLimit].grpname);
  2403. // }
  2404. //
  2405. // if(PRIV_LEVEL_NO_ACCESS == NewAccessLimit)
  2406. // {
  2407. // strcpy(newgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege].grpname);
  2408. // }
  2409. // else if(IGNORE_ADD_OR_REMOVE != NewAccessLimit)
  2410. // {
  2411. // strcpy(newgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege+NewAccessLimit].grpname);
  2412. // }
  2413. //
  2414. // AddIPMIUsrtoChGrp(UserName,(char *)oldgrp,(char *)newgrp);
  2415. return 0;
  2416. }
  2417. /*---------------------------------------
  2418. * SetUserAccess
  2419. *---------------------------------------*/
  2420. int
  2421. SetUserAccess (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  2422. {
  2423. // _NEAR_ SetUserAccessReq_T* pSetUserAccessReq = (_NEAR_ SetUserAccessReq_T*)pReq;
  2424. // _FAR_ ChannelUserInfo_T* pChUserInfo;
  2425. // _FAR_ UserInfo_T* pUserInfo;
  2426. // _FAR_ ChannelInfo_T* pChannelInfo;
  2427. // _FAR_ ChannelInfo_T* pNvrChInfo;
  2428. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  2429. // _FAR_ ChannelUserInfo_T * pNVRChUserInfo=NULL;
  2430. //// char ChFilename[MAX_CHFILE_NAME];
  2431. // INT8U Index;
  2432. // INT8U ChannelNum,IPMIMessaging,*curchannel;
  2433. // INT8U OldAccessLimit;
  2434. // int ret=0;
  2435. //
  2436. // if (ReqLen == sizeof(SetUserAccessReq_T) - sizeof(pSetUserAccessReq->SessionLimit) )
  2437. // {
  2438. // pSetUserAccessReq->SessionLimit = 0;
  2439. // }
  2440. // else if(ReqLen == sizeof(SetUserAccessReq_T))
  2441. // {
  2442. // if(0 != pSetUserAccessReq->SessionLimit)
  2443. // {
  2444. // *pRes = CC_INV_DATA_FIELD;
  2445. // return sizeof (*pRes);
  2446. // }
  2447. // }
  2448. // else
  2449. // {
  2450. // *pRes = CC_REQ_INV_LEN;
  2451. // return sizeof (*pRes);
  2452. // }
  2453. //
  2454. // // Check for Reserved bits
  2455. // if((pSetUserAccessReq->UserID & (BIT7 | BIT6)) || (pSetUserAccessReq->SessionLimit & (BIT7 | BIT6 | BIT5 | BIT4)) || (pSetUserAccessReq->AccessLimit == PRIV_LEVEL_RESERVED) || (pSetUserAccessReq->AccessLimit > PRIV_LEVEL_PROPRIETARY && pSetUserAccessReq->AccessLimit != PRIV_LEVEL_NO_ACCESS))
  2456. // {
  2457. // *pRes = CC_INV_DATA_FIELD;
  2458. // return sizeof(*pRes);
  2459. // }
  2460. //
  2461. // ChannelNum = pSetUserAccessReq->ChannelNoUserAccess & 0x0F;
  2462. // if (CURRENT_CHANNEL_NUM == ChannelNum)
  2463. // {
  2464. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  2465. // ChannelNum = *curchannel & 0xF;
  2466. // }
  2467. //
  2468. // /*Removing the Hard coding of admin user
  2469. // if(pSetUserAccessReq->UserID == IPMI_ROOT_USER)
  2470. // {
  2471. // *pRes = CC_INV_DATA_FIELD;
  2472. // return sizeof (*pRes);
  2473. // }
  2474. // */
  2475. //
  2476. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  2477. // pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
  2478. // if((NULL == pChannelInfo) || (pSetUserAccessReq->UserID > pBMCInfo->IpmiConfig.MaxUsers) || (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport))
  2479. // {
  2480. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2481. // *pRes = CC_INV_DATA_FIELD;
  2482. // return sizeof (*pRes);
  2483. // }
  2484. //
  2485. // pUserInfo = getUserIdInfo(pSetUserAccessReq->UserID, BMCInst);
  2486. // if (NULL == pUserInfo)
  2487. // {
  2488. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2489. // TDBG ("AppDevice.c : SetUserAccess - Invalid user Id\n");
  2490. // *pRes = CC_INV_DATA_FIELD;
  2491. // return sizeof (*pRes);
  2492. // }
  2493. //
  2494. //
  2495. // TDBG("pChannle info is %p\n",pChannelInfo);
  2496. // TDBG("UserId id is %d\n",pSetUserAccessReq->UserID);
  2497. // TDBG("pUserInfo->ID is %ld and USERID is %ld\n",pUserInfo->ID,USER_ID);
  2498. //
  2499. // if (pUserInfo->ID != USER_ID)
  2500. // {
  2501. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2502. // TCRIT("Invalid data field\n");
  2503. // *pRes = CC_INV_DATA_FIELD;
  2504. // return sizeof (*pRes);
  2505. // }
  2506. //
  2507. // /* User 's session limit should be lesser than Channel 's session limit */
  2508. // if(pSetUserAccessReq->SessionLimit > pBMCInfo->IpmiConfig.MaxSession)
  2509. // {
  2510. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2511. // *pRes = CC_INV_DATA_FIELD;
  2512. // return sizeof (*pRes);
  2513. // }
  2514. //
  2515. //
  2516. // pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
  2517. // pNVRChUserInfo = GetNVRChUserConfigs(pChannelInfo,BMCInst);
  2518. // pChUserInfo = getChUserIdInfo (pSetUserAccessReq->UserID , &Index, pChannelInfo->ChannelUserInfo, BMCInst);
  2519. //
  2520. // if (NULL == pChUserInfo)
  2521. // {
  2522. // /* Add the user in NVRAM */
  2523. // pChUserInfo = AddChUser (pChannelInfo->ChannelUserInfo, &Index, BMCInst);
  2524. // if(pChUserInfo == NULL)
  2525. // {
  2526. // /*Return proper completion if the user exceeds the max channel users*/
  2527. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2528. // *pRes = CC_INV_DATA_FIELD;
  2529. // return sizeof (*pRes);
  2530. // }
  2531. //
  2532. // pChUserInfo->ID = USER_ID;
  2533. // pChUserInfo->UserId = pSetUserAccessReq->UserID;
  2534. // pNVRChUserInfo[Index].UserId = pSetUserAccessReq->UserID;
  2535. //
  2536. // pChUserInfo->AccessLimit = PRIV_LEVEL_NO_ACCESS;
  2537. // /* Initial depends on the Request Bit */
  2538. // pChUserInfo->IPMIMessaging=FALSE;
  2539. // pChUserInfo->ActivatingSOL=FALSE;
  2540. // pChUserInfo->UserAccessCallback = FALSE;
  2541. // pChUserInfo->LinkAuth = FALSE;
  2542. // pNVRChUserInfo[Index].ID = USER_ID;
  2543. // pNVRChUserInfo[Index].IPMIMessaging=FALSE;
  2544. // pNVRChUserInfo[Index].ActivatingSOL=FALSE;
  2545. // pNVRChUserInfo[Index].UserId = pSetUserAccessReq->UserID;
  2546. // pNVRChUserInfo[Index].LinkAuth = FALSE;
  2547. // pNVRChUserInfo[Index].UserAccessCallback =FALSE;
  2548. // }
  2549. //
  2550. // if (0 != (pSetUserAccessReq->ChannelNoUserAccess & 0x80))
  2551. // {
  2552. // /* set the user access for the channel */
  2553. // IPMIMessaging = GetBits (pSetUserAccessReq->ChannelNoUserAccess, 0x10);
  2554. // if (FALSE == IPMIMessaging)
  2555. // {
  2556. // /* Disable the IPMI Messaging if Its in Enables state */
  2557. // if((TRUE == pChUserInfo->IPMIMessaging)&& (pChannelInfo->NoCurrentUser > 1) )
  2558. // {
  2559. // /* Initialize based on the Request Bit */
  2560. // pChUserInfo->IPMIMessaging=IPMIMessaging;
  2561. // pNVRChUserInfo[Index].IPMIMessaging=IPMIMessaging;
  2562. // }
  2563. // }
  2564. // else
  2565. // {
  2566. // if(TRUE == pChUserInfo->IPMIMessaging)
  2567. // {
  2568. // pChUserInfo->Lock = USER_UNLOCKED;
  2569. // pChUserInfo->LockedTime = 0;
  2570. // pChUserInfo->FailureAttempts = 0;
  2571. // }
  2572. // else if(FALSE == pChUserInfo->IPMIMessaging) /* Enable the IPMI Messaging ,If its in disabled state */
  2573. // {
  2574. // /* Initialize based on the Request Bit */
  2575. // pChUserInfo->IPMIMessaging=IPMIMessaging;
  2576. // pNVRChUserInfo[Index].IPMIMessaging=IPMIMessaging;
  2577. // pChUserInfo->Lock = USER_UNLOCKED;
  2578. // pChUserInfo->LockedTime = 0;
  2579. // pChUserInfo->FailureAttempts = 0;
  2580. // }
  2581. // }
  2582. //
  2583. // /* set in RAM */
  2584. // pChUserInfo->UserAccessCallback = GetBits (pSetUserAccessReq->ChannelNoUserAccess, 0x40);
  2585. // pChUserInfo->LinkAuth = GetBits (pSetUserAccessReq->ChannelNoUserAccess, 0x20);
  2586. //
  2587. // pNVRChUserInfo[Index].UserId = pSetUserAccessReq->UserID;
  2588. // pNVRChUserInfo[Index].LinkAuth =
  2589. // GetBits (pSetUserAccessReq->ChannelNoUserAccess, 0x20);
  2590. // pNVRChUserInfo[Index].UserAccessCallback =
  2591. // GetBits (pSetUserAccessReq->ChannelNoUserAccess, 0x40);
  2592. //
  2593. //
  2594. // }
  2595. // OldAccessLimit=pChUserInfo->AccessLimit;
  2596. // pChUserInfo->AccessLimit = GetBits (pSetUserAccessReq->AccessLimit, 0x0F);
  2597. //
  2598. // ret=ModifyUsrGrp((char *)pUserInfo->UserName,ChannelNum,OldAccessLimit,pChUserInfo->AccessLimit);
  2599. // if(ret < 0)
  2600. // {
  2601. // TCRIT("User Has No LAN or Serial Preivilege!!\n");
  2602. // }
  2603. //
  2604. // pNVRChUserInfo[Index].AccessLimit = pChUserInfo->AccessLimit;
  2605. // /* set in NVRAM */
  2606. // if (0 == (pUserInfo->MaxSession))
  2607. // {
  2608. // /* This is MAX User session Limit */
  2609. // pUserInfo->MaxSession = pBMCInfo->IpmiConfig.MaxSession;
  2610. // }
  2611. //
  2612. //
  2613. // FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0],(INT8U*)&pBMCInfo->UserInfo[0],pBMCInfo->IPMIConfLoc.UserInfoAddr,
  2614. // sizeof(UserInfo_T)*MAX_USER_CFG_MDS,BMCInst);
  2615. // FlushChConfigs((INT8U*)pNvrChInfo,pNvrChInfo->ChannelNumber,BMCInst);
  2616. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2617. //
  2618. // *pRes = CC_NORMAL;
  2619. //
  2620. // return sizeof (*pRes);
  2621. }
  2622. /*---------------------------------------
  2623. * GetUserAccess
  2624. *---------------------------------------*/
  2625. int
  2626. GetUserAccess (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  2627. {
  2628. // _NEAR_ GetUserAccessReq_T* pGetUserAccessReq = (_NEAR_ GetUserAccessReq_T*)pReq;
  2629. // _NEAR_ GetUserAccessRes_T* pGetUserAccessRes = (_NEAR_ GetUserAccessRes_T*)pRes;
  2630. // _FAR_ ChannelUserInfo_T* pChUserInfo;
  2631. // _FAR_ UserInfo_T* pUserInfo;
  2632. // _FAR_ ChannelInfo_T* pChannelInfo;
  2633. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  2634. // INT8U Index,*curchannel;
  2635. //
  2636. // // Check for Reserved bits
  2637. // if((pGetUserAccessReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4)) || (pGetUserAccessReq->UserID & (BIT7 | BIT6)) || (pGetUserAccessReq->UserID == 0x00))
  2638. // {
  2639. // pGetUserAccessRes->CompletionCode = CC_INV_DATA_FIELD;
  2640. // return sizeof(*pRes);
  2641. // }
  2642. //
  2643. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  2644. // if (pGetUserAccessReq->ChannelNum == CURRENT_CHANNEL_NUM)
  2645. // {
  2646. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  2647. // pChannelInfo = getChannelInfo(*curchannel,BMCInst);
  2648. // }
  2649. // else
  2650. // pChannelInfo = getChannelInfo(pGetUserAccessReq->ChannelNum,BMCInst);
  2651. //
  2652. // //TDBG("UserID is %d\n",pGetUserAccessReq->UserID);
  2653. //
  2654. // if ((NULL == pChannelInfo) ||
  2655. // (pGetUserAccessReq->UserID > pBMCInfo->IpmiConfig.MaxUsers) ||
  2656. // (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport))
  2657. // {
  2658. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2659. // pGetUserAccessRes->CompletionCode = CC_INV_DATA_FIELD;
  2660. // return sizeof (*pRes);
  2661. // }
  2662. //
  2663. // pUserInfo = getUserIdInfo (pGetUserAccessReq->UserID, BMCInst);
  2664. //
  2665. // if (NULL == pUserInfo)
  2666. // {
  2667. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2668. // pGetUserAccessRes->CompletionCode = CC_INV_DATA_FIELD;
  2669. // return sizeof (*pRes);
  2670. // }
  2671. //
  2672. // if (TRUE == pUserInfo->UserStatus)
  2673. // {
  2674. // pGetUserAccessRes->CurrentUserID = SetBits (0xC0, USER_ID_ENABLED);
  2675. // }
  2676. // else
  2677. // {
  2678. // pGetUserAccessRes->CurrentUserID = SetBits (0xC0, USER_ID_DISABLED);
  2679. // }
  2680. //
  2681. // pChUserInfo = getChUserIdInfo (pGetUserAccessReq->UserID, &Index, pChannelInfo->ChannelUserInfo ,BMCInst);
  2682. //
  2683. // if (NULL == pChUserInfo)
  2684. // {
  2685. // pGetUserAccessRes->ChannelAccess = SetBits (0x0F, 0x0F);
  2686. // pGetUserAccessRes->ChannelAccess |= SetBits (0x10, FALSE);
  2687. // pGetUserAccessRes->ChannelAccess |= SetBits (0x20, FALSE);
  2688. // pGetUserAccessRes->ChannelAccess |= SetBits (0x40, FALSE);
  2689. // }
  2690. // else
  2691. // {
  2692. // pGetUserAccessRes->ChannelAccess = SetBits (0x0F, pChUserInfo->AccessLimit);
  2693. // pGetUserAccessRes->ChannelAccess |= SetBits (0x10, pChUserInfo->IPMIMessaging);
  2694. // pGetUserAccessRes->ChannelAccess |= SetBits (0x20, pChUserInfo->LinkAuth);
  2695. // pGetUserAccessRes->ChannelAccess |= SetBits (0x40, pChUserInfo->UserAccessCallback);
  2696. // }
  2697. //
  2698. // pGetUserAccessRes->CompletionCode = CC_NORMAL;
  2699. // pGetUserAccessRes->MaxNoUserID = SetBits (0x3F, pChannelInfo->MaxUser);
  2700. // pGetUserAccessRes->CurrentUserID |= SetBits (0x3F, pChannelInfo->NoCurrentUser);
  2701. // pGetUserAccessRes->FixedUserID = SetBits (0x3F, pChannelInfo->NoFixedUser);
  2702. //
  2703. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2704. //
  2705. // return sizeof (GetUserAccessRes_T);
  2706. }
  2707. /*---------------------------------------
  2708. * SetUserName
  2709. *---------------------------------------*/
  2710. int
  2711. SetUserName (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  2712. {
  2713. // _NEAR_ SetUserNameReq_T* pSetUserNameReq = (_NEAR_ SetUserNameReq_T*)pReq;
  2714. // _FAR_ UserInfo_T* pUserInfo;
  2715. // _FAR_ ChannelInfo_T* pChannelInfo=NULL;
  2716. // _FAR_ ChannelInfo_T* pNvrChInfo;
  2717. // _FAR_ ChannelUserInfo_T* pChUserInfo;
  2718. // _FAR_ ChannelUserInfo_T * pNVRChUserInfo=NULL;
  2719. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  2720. // INT8U Ch, Index,Chtype;
  2721. // //INT16S Err;
  2722. // INT8U i;
  2723. // INT8U UserName[MAX_USERNAME_LEN + 1]; //plus 1 for null terminator
  2724. // INT8U InvalidChar[]={ ' ' , ',' , '.' , '/' , ':' , ';' , '\\' , '(', ')' , 0x01 ,
  2725. // 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09, 0x0A ,
  2726. // 0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 , 0x11 , 0x12, 0x13 ,
  2727. // 0x14 , 0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1A , 0x1B, 0x1C ,
  2728. // 0x1D , 0x1E , 0x1F , 0x7F} ;
  2729. //
  2730. //// char ChFilename[MAX_CHFILE_NAME];
  2731. // //INT8U Handle = sizeof(ChInfo_T)-sizeof(ChannelInfo_T);
  2732. //
  2733. // // Check for Reserved bits
  2734. // if(pSetUserNameReq->UserID & (BIT7 | BIT6) || (pSetUserNameReq->UserID == 0x00))
  2735. // {
  2736. // *pRes = CC_INV_DATA_FIELD;
  2737. // return sizeof(*pRes);
  2738. // }
  2739. //
  2740. // /*User Id exceeded the limit or Cant set NULL User */
  2741. // if (pSetUserNameReq->UserID > pBMCInfo->IpmiConfig.MaxUsers )
  2742. // {
  2743. // *pRes = CC_INV_DATA_FIELD ;
  2744. // return sizeof (*pRes);
  2745. // }
  2746. //
  2747. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  2748. // pUserInfo = getUserIdInfo(pSetUserNameReq->UserID, BMCInst);
  2749. //
  2750. // /* If the user is fixed user */
  2751. // if (((pUserInfo != NULL) && (pUserInfo->FixedUser == TRUE)))
  2752. // {
  2753. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2754. // *pRes = CC_INV_DATA_FIELD ;
  2755. // return sizeof (*pRes);
  2756. // }
  2757. //
  2758. // /* We should not set the NULL user */
  2759. // if(0== pSetUserNameReq->UserName [0] )
  2760. // {
  2761. // printf("\n Setting the NULL user :%x",pSetUserNameReq->UserID);
  2762. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2763. // *pRes = CC_INV_DATA_FIELD ;
  2764. // return sizeof (*pRes);
  2765. // }
  2766. //
  2767. // /* check for numeric first char and special chars */
  2768. // if( 0 != isdigit(pSetUserNameReq->UserName[0] ) )
  2769. // {
  2770. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2771. // *pRes = CC_INV_DATA_FIELD;
  2772. // return sizeof(*pRes);
  2773. // }
  2774. // else
  2775. // {
  2776. // for(i=0;i<sizeof(InvalidChar);i++)
  2777. // {
  2778. // strncpy((char *)UserName,(const char *) pSetUserNameReq->UserName, sizeof(pSetUserNameReq->UserName));
  2779. // UserName[MAX_USERNAME_LEN] = '\0';
  2780. // if( NULL != strchr((const char *)UserName, InvalidChar[i] ))
  2781. // {
  2782. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2783. // *pRes = CC_INV_DATA_FIELD;
  2784. // return sizeof(*pRes);
  2785. // }
  2786. // }
  2787. // }
  2788. //
  2789. // //Don't check duplicated user names for 0xFF, this request is for deleting user
  2790. // if(0xFF != pSetUserNameReq->UserName [0])
  2791. // {
  2792. // //checking for Duplicate user names
  2793. // if(CheckForDuplicateUsers(pSetUserNameReq->UserName,BMCInst)==FALSE)
  2794. // {
  2795. // //setting user's name with same name
  2796. // if(!strncmp((char *)pUserInfo->UserName,(char *)pSetUserNameReq->UserName, MAX_USERNAME_LEN))
  2797. // {
  2798. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2799. // *pRes = CC_NORMAL;
  2800. // return sizeof (*pRes);
  2801. // }
  2802. // TINFO("Duplicate ipmi user!!\n");
  2803. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2804. // *pRes = CC_INV_DATA_FIELD;
  2805. // return sizeof (*pRes);
  2806. // }
  2807. // }
  2808. // //checking for reserved user names
  2809. // if(CheckForReservedUsers((char *)pSetUserNameReq->UserName) != 0)
  2810. // {
  2811. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2812. // *pRes = CC_INV_DATA_FIELD;
  2813. // return sizeof (*pRes);
  2814. // }
  2815. //
  2816. //
  2817. // /* Add to Linux data base */
  2818. // //Err = 0;
  2819. //
  2820. // /* If User[0] is 0xFF means the user is requested to delete */
  2821. // if ((0xFF == pSetUserNameReq->UserName [0]) ||
  2822. // (0 == pSetUserNameReq->UserName [0] ))
  2823. // {
  2824. // if ((0 == pUserInfo->CurrentSession) && (0 != disableUser (pSetUserNameReq->UserID,BMCInst)))
  2825. // {
  2826. // /* Delete this user form all the channel */
  2827. // for (Ch = 0; Ch < MAX_NUM_CHANNELS; Ch++)
  2828. // {
  2829. // if(pBMCInfo->ChConfig[Ch].ChType != 0xff)
  2830. // {
  2831. // pChannelInfo = (ChannelInfo_T*)&pBMCInfo->ChConfig[Ch].ChannelInfo;
  2832. // }
  2833. // else
  2834. // {
  2835. // continue;
  2836. // }
  2837. //
  2838. // pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
  2839. // pNVRChUserInfo = GetNVRChUserConfigs(pChannelInfo,BMCInst);
  2840. //
  2841. // pChUserInfo = getChUserIdInfo(pSetUserNameReq->UserID, &Index, pChannelInfo->ChannelUserInfo,BMCInst);
  2842. //
  2843. // if (pChUserInfo != NULL)
  2844. // {
  2845. // ModifyUsrGrp((char *)pUserInfo->UserName,pChannelInfo->ChannelNumber,pChUserInfo->AccessLimit,IGNORE_ADD_OR_REMOVE);
  2846. // AddIPMIUsrtoShellGrp((char *)pUserInfo->UserName, pUserInfo->UserShell, IGNORE_ADD_OR_REMOVE_SHELL);
  2847. // AddIPMIUsrtoFlagsGrp((char *)pUserInfo->UserName,pUserInfo->ExtendedPrivilege,IGNORE_ADD_OR_REMOVE);
  2848. // pNVRChUserInfo[Index].UserId = 0;
  2849. // pNVRChUserInfo[Index].IPMIMessaging=FALSE;
  2850. // pNVRChUserInfo[Index].ActivatingSOL=FALSE;
  2851. // pNVRChUserInfo[Index].ID=0;
  2852. // pChUserInfo->ID=0;
  2853. // pChUserInfo->UserId = 0;
  2854. // pChUserInfo->IPMIMessaging=FALSE;
  2855. // pChUserInfo->ActivatingSOL=FALSE;
  2856. // if( pUserInfo->UserStatus == TRUE)
  2857. // {
  2858. // pChannelInfo->NoCurrentUser--;
  2859. // pNvrChInfo->NoCurrentUser--;
  2860. // }
  2861. // FlushChConfigs((INT8U*)pNvrChInfo,pNvrChInfo->ChannelNumber,BMCInst);
  2862. // }
  2863. // else
  2864. // {
  2865. // if(pUserInfo != NULL)
  2866. // DeleteUsrFromIPMIGrp((char *)pUserInfo->UserName);
  2867. // }
  2868. // }
  2869. //
  2870. // /* Checking for valid user, empty users doesnt conatain user directories*/
  2871. // if (USER_ID == pUserInfo->ID)
  2872. // {
  2873. // //removing the user directory created in add user
  2874. // if(RemoveUsrDir((char *)pUserInfo->UserName)!=0)
  2875. // {
  2876. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2877. // *pRes = CC_UNSPECIFIED_ERR;
  2878. // return sizeof (*pRes);
  2879. // }
  2880. // }
  2881. // /* Delete the user both in Volatile & Non Volatile memory*/
  2882. // pBMCInfo->GenConfig.CurrentNoUser--;
  2883. // _fmemset (pUserInfo, 0, sizeof (UserInfo_T));
  2884. // FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0],(INT8U*)&pBMCInfo->UserInfo[0],pBMCInfo->IPMIConfLoc.UserInfoAddr,
  2885. // sizeof(UserInfo_T)*MAX_USER_CFG_MDS,BMCInst);
  2886. // }
  2887. // else
  2888. // {
  2889. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2890. // *pRes = CC_INV_DATA_FIELD ;
  2891. // return sizeof (*pRes);
  2892. // }
  2893. // }
  2894. // else if (USER_ID != pUserInfo->ID)//adding users
  2895. // {
  2896. // for (i = 0; i < MAX_USERNAME_LEN; i++)
  2897. // {
  2898. // if(!(isascii(pSetUserNameReq->UserName[i])))
  2899. // {
  2900. // *pRes = CC_INV_DATA_FIELD ;
  2901. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2902. // return sizeof (*pRes);
  2903. // }
  2904. // }
  2905. // /* If First time-if user ID does not exist */
  2906. // /* if the user name is set for the first time */
  2907. // pUserInfo->ID = USER_ID;
  2908. // pUserInfo->UserId = pSetUserNameReq->UserID;
  2909. // /* allow for IPMI Mesaging */
  2910. // pUserInfo->UserStatus = FALSE;
  2911. // /* set default max session */
  2912. // pUserInfo->MaxSession = pBMCInfo->IpmiConfig.MaxSession;
  2913. //
  2914. // pBMCInfo->GenConfig.CurrentNoUser++;
  2915. // for (Ch = 0; Ch < MAX_NUM_CHANNELS; Ch++)
  2916. // {
  2917. // if((Chtype = IsChannelSuppGroups(Ch,BMCInst)) == 0)
  2918. // continue;
  2919. // AddUsrtoIPMIGrp((char *)pSetUserNameReq->UserName,Chtype);
  2920. // ModifyUsrGrp((char *)pSetUserNameReq->UserName,Ch,IGNORE_ADD_OR_REMOVE,PRIV_LEVEL_NO_ACCESS);
  2921. // }
  2922. // AddIPMIUsrtoShellGrp((char *)pSetUserNameReq->UserName, IGNORE_ADD_OR_REMOVE_SHELL, pUserInfo->UserShell);
  2923. // AddIPMIUsrtoFlagsGrp((char *)pSetUserNameReq->UserName, IGNORE_ADD_OR_REMOVE, pUserInfo->ExtendedPrivilege);
  2924. // //creating ssh directorys for new user
  2925. // if( CreateSSHUserDir((char *)pSetUserNameReq->UserName) != 0)
  2926. // {
  2927. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2928. // *pRes = CC_UNSPECIFIED_ERR;
  2929. // return sizeof (*pRes);
  2930. // }
  2931. // //creating authentication key for new user
  2932. // if (CreateSSHAuthKeyFile((char *)pSetUserNameReq->UserName)!= 0)
  2933. // {
  2934. // *pRes = CC_UNSPECIFIED_ERR;
  2935. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2936. // return sizeof (*pRes);
  2937. // }
  2938. // TINFO("user folders created successfuy----\n");
  2939. //
  2940. // }
  2941. // else if (USER_ID == pUserInfo->ID)//modifying users
  2942. // {
  2943. // for (i = 0; i < MAX_USERNAME_LEN; i++)
  2944. // {
  2945. // if(!(isascii(pSetUserNameReq->UserName[i])))
  2946. // {
  2947. // *pRes = CC_INV_DATA_FIELD ;
  2948. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2949. // return sizeof (*pRes);
  2950. // }
  2951. // }
  2952. // /* If user name isn't set before we create a folder */
  2953. // if( 0 == pUserInfo->UserName[0] )
  2954. // {
  2955. // CreateSSHUserDir((char *)pSetUserNameReq->UserName);
  2956. // }
  2957. // else
  2958. // {
  2959. // RenameUserDir((char *)pUserInfo->UserName, (char *)pSetUserNameReq->UserName);
  2960. // }
  2961. //
  2962. // for (Ch = 0; Ch < MAX_NUM_CHANNELS; Ch++)
  2963. // {
  2964. // if((Chtype = IsChannelSuppGroups(Ch,BMCInst)) == 0)
  2965. // {
  2966. // continue;
  2967. // }
  2968. // AddUsrtoIPMIGrp((char *)pSetUserNameReq->UserName,Chtype);
  2969. // pChannelInfo = getChannelInfo (Ch, BMCInst);
  2970. // if(NULL == pChannelInfo)
  2971. // {
  2972. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2973. // *pRes = CC_INV_DATA_FIELD;
  2974. // return sizeof (*pRes);
  2975. // }
  2976. //
  2977. // pChUserInfo = getChUserIdInfo(pSetUserNameReq->UserID, &Index, pChannelInfo->ChannelUserInfo,BMCInst);
  2978. // if (pChUserInfo != NULL)
  2979. // {
  2980. // ModifyUsrGrp((char *)pUserInfo->UserName, pChannelInfo->ChannelNumber, pChUserInfo->AccessLimit, IGNORE_ADD_OR_REMOVE);//Remove User
  2981. // ModifyUsrGrp((char *)pSetUserNameReq->UserName, pChannelInfo->ChannelNumber, IGNORE_ADD_OR_REMOVE, pChUserInfo->AccessLimit);//add user
  2982. // }
  2983. // else
  2984. // {
  2985. // ModifyUsrGrp((char *)pUserInfo->UserName, Ch,PRIV_LEVEL_NO_ACCESS, IGNORE_ADD_OR_REMOVE);//Remove User
  2986. // ModifyUsrGrp((char *)pSetUserNameReq->UserName, Ch, IGNORE_ADD_OR_REMOVE, PRIV_LEVEL_NO_ACCESS);//add user
  2987. // }
  2988. // }
  2989. // AddIPMIUsrtoShellGrp((char *)pUserInfo->UserName, pUserInfo->UserShell, IGNORE_ADD_OR_REMOVE_SHELL);//Remove User from Shell Group
  2990. // AddIPMIUsrtoShellGrp((char *)pSetUserNameReq->UserName, IGNORE_ADD_OR_REMOVE_SHELL, pUserInfo->UserShell);//Add User in Shell Group
  2991. // AddIPMIUsrtoFlagsGrp((char *)pUserInfo->UserName, pUserInfo->ExtendedPrivilege, IGNORE_ADD_OR_REMOVE);//Remove User from Flags Group
  2992. // AddIPMIUsrtoFlagsGrp((char *)pSetUserNameReq->UserName, IGNORE_ADD_OR_REMOVE, pUserInfo->ExtendedPrivilege);//Add User in Flags Group
  2993. // }
  2994. // _fmemcpy (pUserInfo->UserName, pSetUserNameReq->UserName, MAX_USERNAME_LEN);
  2995. //
  2996. // FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0],(INT8U*)&pBMCInfo->UserInfo[0],pBMCInfo->IPMIConfLoc.UserInfoAddr,
  2997. // sizeof(UserInfo_T)*MAX_USER_CFG_MDS,BMCInst);
  2998. // FlushIPMI((INT8U*)&pBMCInfo->GenConfig,(INT8U*)&pBMCInfo->GenConfig,pBMCInfo->IPMIConfLoc.GenConfigAddr,
  2999. // sizeof(GENConfig_T),BMCInst);
  3000. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  3001. // *pRes = CC_NORMAL;
  3002. // return sizeof (*pRes);
  3003. }
  3004. /*---------------------------------------
  3005. * GetUserName
  3006. *---------------------------------------*/
  3007. int
  3008. GetUserName (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  3009. {
  3010. // _NEAR_ GetUserNameReq_T* pGetUserNameReq = (_NEAR_ GetUserNameReq_T*)pReq;
  3011. // _NEAR_ GetUserNameRes_T* pGetUserNameRes = (_NEAR_ GetUserNameRes_T*)pRes;
  3012. // _FAR_ UserInfo_T* pUserInfo;
  3013. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  3014. // //INT16S Err;
  3015. //
  3016. // // Check for Reserved bits
  3017. // if(pGetUserNameReq->UserID & (BIT7 | BIT6) || (pGetUserNameReq->UserID == 0x00))
  3018. // {
  3019. // pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
  3020. // return sizeof(*pRes);
  3021. // }
  3022. //
  3023. // if (pGetUserNameReq->UserID > pBMCInfo->IpmiConfig.MaxUsers)
  3024. // {
  3025. // /* if user ID exceeded the Max limit */
  3026. // pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
  3027. // return sizeof (*pRes);/* Invalied user id */
  3028. // }
  3029. //
  3030. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  3031. // pUserInfo = getUserIdInfo(pGetUserNameReq->UserID, BMCInst);
  3032. //
  3033. // /* if User is disabled or if User is not created */
  3034. //
  3035. // //if user is disabled we dont have to return invalid data field
  3036. // //instead we return everything possible about the user
  3037. // // if pUserInfo is NULL then nothing in the structure at all
  3038. // // pUserInfo being NULL is probably not possible
  3039. // // If the signature doesnt match then the useris not yet configured
  3040. // // so reasonable to return an error
  3041. // if ((NULL == pUserInfo) || (pUserInfo->ID != USER_ID))
  3042. // {
  3043. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  3044. // /* User with given ID is disabled */
  3045. // *pRes = CC_INV_DATA_FIELD;
  3046. // return sizeof (*pRes);
  3047. // }
  3048. //
  3049. // //if we are here then the user is just disabled
  3050. // if(FALSE == pUserInfo->UserStatus)
  3051. // {
  3052. // TDBG("user is just dissabled\n");
  3053. // //user is just disabled!!
  3054. // }
  3055. //
  3056. // //Err = 0;
  3057. // pGetUserNameRes->CompletionCode = CC_NORMAL;
  3058. // _fmemcpy (pGetUserNameRes->UserName, pUserInfo->UserName, MAX_USERNAME_LEN);
  3059. //
  3060. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  3061. //
  3062. // return sizeof (GetUserNameRes_T);
  3063. }
  3064. /*---------------------------------------
  3065. * SetUserPassword
  3066. *---------------------------------------*/
  3067. int
  3068. SetUserPassword (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  3069. {
  3070. // _NEAR_ SetUserPswdReq_T* pSetUserPswdReq = (_NEAR_ SetUserPswdReq_T*)pReq;
  3071. // _FAR_ UserInfo_T* pUserInfo;
  3072. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  3073. // INT8U UserId=0, Operation;
  3074. // INT8U UserPswd[MAX_PASSWD_LEN];
  3075. // INT8S EncryptedUserPswd[MAX_ENCRYPTED_PSWD_LEN] = {0};
  3076. // INT8U PwdEncKey[MAX_SIZE_KEY + 1] = {0};
  3077. // INT8U i;
  3078. // INT8U UserPassword[ MAX_PASSWORD_LEN + 1 ];
  3079. // INT8U InvalidChar[] = { 0x01 , 0x02 , 0x03 , 0x04 ,0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0A,
  3080. // 0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 , 0x11 , 0x12 , 0x13 , 0x14,
  3081. // 0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1A , 0x1B , 0x1C , 0x1D , 0x1E ,
  3082. // 0x1F , 0x7F };
  3083. //
  3084. //
  3085. // Operation = pSetUserPswdReq->Operation & 0x03;
  3086. // UserId = pSetUserPswdReq->UserID & 0x3F;
  3087. //
  3088. // if ((((pSetUserPswdReq->UserID & TWENTY_BYTE_PWD) == 0) && (ReqLen != IPMI_15_PASSWORD_LEN))
  3089. // ||(((pSetUserPswdReq->UserID & TWENTY_BYTE_PWD) == TWENTY_BYTE_PWD) && (ReqLen != IPMI_20_PASSWORD_LEN)))
  3090. // {
  3091. // /* For enable or disable using the password field is optional */
  3092. // if (ReqLen == OP_USERID_ONLY_LENGTH)
  3093. // {
  3094. // if ((Operation != OP_ENABLE_USER_ID) && (Operation != OP_DISABLE_USER_ID))
  3095. // {
  3096. // *pRes = CC_REQ_INV_LEN;
  3097. // return sizeof (*pRes); //Invalid operation.
  3098. // }
  3099. // }
  3100. // else
  3101. // {
  3102. // *pRes = CC_REQ_INV_LEN;
  3103. // return sizeof (*pRes); //password len invalid
  3104. // }
  3105. // }
  3106. //
  3107. // /* Reserved bits checking */
  3108. // if((pSetUserPswdReq->UserID & BIT6) || (UserId == 0) || (pSetUserPswdReq->Operation & (BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)))
  3109. // {
  3110. // *pRes = CC_INV_DATA_FIELD;
  3111. // return sizeof (*pRes);
  3112. // }
  3113. //
  3114. // if (ReqLen == IPMI_15_PASSWORD_LEN)
  3115. // {
  3116. // _fmemset (pSetUserPswdReq->Password + 16, 0, 4);
  3117. // }
  3118. // ReqLen -=2;
  3119. //
  3120. // if (UserId > pBMCInfo->IpmiConfig.MaxUsers)
  3121. // {
  3122. // *pRes = CC_INV_DATA_FIELD;
  3123. // return sizeof (*pRes); /*User Id exceeded the limit*/
  3124. // }
  3125. //
  3126. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  3127. // pUserInfo = getUserIdInfo (UserId, BMCInst);
  3128. //
  3129. // if ( NULL == pUserInfo )
  3130. // {
  3131. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  3132. // IPMI_WARNING ("Invalid User Id \n");
  3133. // *pRes = CC_INV_DATA_FIELD;
  3134. // return sizeof (*pRes);
  3135. // }
  3136. //
  3137. // TDBG("pUserInfo is %p\n",pUserInfo);
  3138. //
  3139. // *pRes = CC_NORMAL;
  3140. //
  3141. // switch (Operation)
  3142. // {
  3143. //
  3144. // case DISABLE_USER:
  3145. // TDBG("In disable user for user id %d\n",UserId);
  3146. // /*disable user */
  3147. // if(pUserInfo == NULL)
  3148. // {
  3149. // //the user is already disabled!!
  3150. // //no point in disabling him again
  3151. // }
  3152. // else if(disableUser(UserId, BMCInst) == 0)
  3153. // {
  3154. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  3155. // //we cannot disable this user because he is the only user in the channel
  3156. // TDBG("not disabling user\n");
  3157. // /* cannot disable user since this user is the only user in the channel*/
  3158. // *pRes = CC_SETPASSWORD_CANNOT_DISABLE_USER;
  3159. // return sizeof (*pRes);
  3160. // }
  3161. // else
  3162. // {
  3163. // //here we can disable the user
  3164. //
  3165. // TDBG("will disable user\n");
  3166. //
  3167. // if (pUserInfo->UserStatus == TRUE)
  3168. // {
  3169. // pBMCInfo->GenConfig.CurrentNoUser--;
  3170. // UpdateCurrentEnabledUserCount(COUNT_DECREASE, BMCInst);
  3171. // }
  3172. //
  3173. // pUserInfo->UserStatus = FALSE;
  3174. //
  3175. // //when user is disabled ".ssh" folder of the user is renamed to restrict user login
  3176. // TDBG("renaming the .ssh folder to _.ssh\n");
  3177. // if(RenameUserSSHDir((char *)pUserInfo->UserName)!=0)
  3178. // {
  3179. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  3180. // *pRes = CC_UNSPECIFIED_ERR;
  3181. // return sizeof (*pRes);
  3182. // }
  3183. // }
  3184. //
  3185. // break;
  3186. //
  3187. // case ENABLE_USER:
  3188. // /*enable user */
  3189. // if (USER_ID == pUserInfo->ID)
  3190. // {
  3191. // /* if for the first time then Increment the Current user No */
  3192. // if ( pUserInfo->UserStatus == FALSE )
  3193. // {
  3194. // pBMCInfo->GenConfig.CurrentNoUser++;
  3195. // UpdateCurrentEnabledUserCount(COUNT_INCREASE, BMCInst);
  3196. // }
  3197. // pUserInfo->UserStatus = TRUE;
  3198. //
  3199. // //when user is enabled the pub key is restored to original name to allow login
  3200. // TDBG("restoring the ._ssh folder to .ssh\n");
  3201. // if( RestoreUsrSSHDir((char *)pUserInfo->UserName)!=0)
  3202. // {
  3203. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  3204. // *pRes = CC_UNSPECIFIED_ERR;
  3205. // return sizeof (*pRes);
  3206. // }
  3207. // if (0 == pUserInfo->UserName [0])
  3208. // {
  3209. // TDBG ("The user Name is Not yet set.. So No synching with the linux \n");
  3210. // *pRes = CC_NORMAL;
  3211. // FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0],(INT8U*)&pBMCInfo->UserInfo[0],pBMCInfo->IPMIConfLoc.UserInfoAddr,
  3212. // sizeof(UserInfo_T)*MAX_USER_CFG_MDS,BMCInst);
  3213. // FlushIPMI((INT8U*)&pBMCInfo->GenConfig,(INT8U*)&pBMCInfo->GenConfig,pBMCInfo->IPMIConfLoc.GenConfigAddr,
  3214. // sizeof(GENConfig_T),BMCInst);
  3215. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  3216. // return sizeof (*pRes);
  3217. // }
  3218. // TDBG ("Synching with the Linux User dataBase \n");
  3219. // }
  3220. // else
  3221. // {
  3222. // /* Looks like the User info is not there So just enable the user in the IPMI */
  3223. // /* no need to Ssync with the linux databse since there will b No corresponding user in the linux database */
  3224. // TCRIT("Enable user called on a not yet enabled user!!\n");
  3225. // /* If First time-if user ID does not exist */
  3226. // /* if the user is enabled for the first time */
  3227. // pUserInfo->ID = USER_ID;
  3228. // pUserInfo->UserId = UserId;
  3229. // pUserInfo->UserStatus = TRUE;
  3230. // pUserInfo->MaxSession = pBMCInfo->IpmiConfig.MaxSession;
  3231. //
  3232. // pBMCInfo->GenConfig.CurrentNoUser++;
  3233. // UpdateCurrentEnabledUserCount(COUNT_INCREASE, BMCInst);
  3234. //
  3235. // //when user is enabled the pub key is restored to original name to allow login
  3236. // TDBG("restoring the ._ssh folder to .ssh\n");
  3237. // if(RestoreUsrSSHDir((char *)pUserInfo->UserName)!=0)
  3238. // {
  3239. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  3240. // *pRes = CC_UNSPECIFIED_ERR;
  3241. // return sizeof (*pRes);
  3242. // }
  3243. // memset(pUserInfo->UserName, 0, MAX_USERNAME_LEN);
  3244. // /* If user name isn't set before we save the configuration */
  3245. // FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0], (INT8U*)&pBMCInfo->UserInfo[0], pBMCInfo->IPMIConfLoc.UserInfoAddr,
  3246. // sizeof(UserInfo_T)*MAX_USER_CFG_MDS, BMCInst);
  3247. // FlushIPMI((INT8U*)&pBMCInfo->GenConfig, (INT8U*)&pBMCInfo->GenConfig, pBMCInfo->IPMIConfLoc.GenConfigAddr,
  3248. // sizeof(GENConfig_T), BMCInst);
  3249. // *pRes = CC_NORMAL;
  3250. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  3251. // return sizeof (*pRes);
  3252. // }
  3253. // break;
  3254. //
  3255. // case SET_PASSWORD:
  3256. // /*set password */
  3257. // if (USER_ID == pUserInfo->ID)
  3258. // {
  3259. // /*check for special characters*/
  3260. // for( i = 0 ; i < sizeof(InvalidChar) ; i++ )
  3261. // {
  3262. // strncpy((char *)UserPassword,(const char *) pSetUserPswdReq->Password, sizeof(pSetUserPswdReq->Password));
  3263. // UserPassword[MAX_PASSWORD_LEN] = '\0';
  3264. // if( NULL != strchr((const char *)UserPassword, InvalidChar[i] ))
  3265. // {
  3266. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  3267. // *pRes = CC_INV_DATA_FIELD;
  3268. // return sizeof(*pRes);
  3269. // }
  3270. // }
  3271. //
  3272. // pUserInfo->MaxPasswordSize = ReqLen;
  3273. // if (g_corefeatures.userpswd_encryption == ENABLED)
  3274. // {
  3275. // /* Get Encryption Key from the MBMCInfo_t structure */
  3276. // memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
  3277. //
  3278. // if(EncryptPassword((INT8S *)pSetUserPswdReq->Password, MAX_PASSWORD_LEN, EncryptedUserPswd, MAX_PASSWORD_LEN, PwdEncKey))
  3279. // {
  3280. // TCRIT("Error in encrypting the IPMI User Password for user ID:%d\n", pSetUserPswdReq->UserID);
  3281. // *pRes = CC_UNSPECIFIED_ERR;
  3282. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  3283. // return sizeof(INT8U);
  3284. // }
  3285. // memset(&(pBMCInfo->EncryptedUserInfo[UserId - 1].EncryptedPswd), 0, MAX_ENCRYPTED_PSWD_LEN);
  3286. // memcpy(&(pBMCInfo->EncryptedUserInfo[UserId - 1].EncryptedPswd), EncryptedUserPswd, MAX_ENCRYPTED_PSWD_LEN);
  3287. // memcpy(pBMCInfo->UserInfo[UserId - 1].UserPassword, "$ENCRYPTED$", 11);
  3288. // }
  3289. // else
  3290. // {
  3291. // _fmemcpy (pUserInfo->UserPassword, pSetUserPswdReq->Password, MAX_PASSWORD_LEN);
  3292. // }
  3293. // if(ENABLED != g_corefeatures.disable_empty_passwd_login)
  3294. // {
  3295. // TDBG("\nSet User Password .Password is configured succussfully...\n");
  3296. // pUserInfo->UserPasswdConfigured = 1;
  3297. // }
  3298. // }
  3299. // else
  3300. // {
  3301. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  3302. // *pRes = CC_INV_DATA_FIELD;
  3303. // return sizeof (*pRes);
  3304. // }
  3305. // break;
  3306. //
  3307. // case TEST_PASSWORD:
  3308. // if (g_corefeatures.userpswd_encryption == ENABLED)
  3309. // {
  3310. // /* Get Encryption Key from the MBMCInfo_t structure */
  3311. // memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
  3312. //
  3313. // if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, (char *)UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
  3314. // {
  3315. // TCRIT("Error in Decrypting IPMI User Password for user with ID:%d\n", UserId);
  3316. // *pRes = CC_UNSPECIFIED_ERR;
  3317. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  3318. // return sizeof(*pRes);
  3319. // }
  3320. // }
  3321. // else
  3322. // {
  3323. // _fmemcpy (UserPswd, pUserInfo->UserPassword, MAX_PASSWORD_LEN);
  3324. // }
  3325. // /*Test Password */
  3326. // if( ReqLen != pUserInfo->MaxPasswordSize && (pUserInfo->MaxPasswordSize != 0))
  3327. // {
  3328. // *pRes = CC_PASSWORD_TEST_FAILED_WRONG_SIZE;
  3329. // }
  3330. // else if (((FALSE == pUserInfo->UserStatus) && (pUserInfo->ID != USER_ID)) ||
  3331. // (0 != _fmemcmp (UserPswd, pSetUserPswdReq->Password, MAX_PASSWORD_LEN)))
  3332. // {
  3333. // *pRes = CC_PASSWORD_TEST_FAILED;
  3334. // }
  3335. //
  3336. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  3337. // return sizeof (*pRes);
  3338. // break;
  3339. // }
  3340. //
  3341. // FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0],(INT8U*)&pBMCInfo->UserInfo[0],pBMCInfo->IPMIConfLoc.UserInfoAddr,
  3342. // sizeof(UserInfo_T)*MAX_USER_CFG_MDS,BMCInst);
  3343. // FlushIPMI((INT8U*)&pBMCInfo->GenConfig,(INT8U*)&pBMCInfo->GenConfig,pBMCInfo->IPMIConfLoc.GenConfigAddr,
  3344. // sizeof(GENConfig_T),BMCInst);
  3345. // FlushIPMI((INT8U*)&pBMCInfo->EncryptedUserInfo[0], (INT8U*)&pBMCInfo->EncryptedUserInfo[0], pBMCInfo->IPMIConfLoc.EncUserPasswdAddr,
  3346. // sizeof(EncryptedUserInfo_T) * MAX_USER_CFG_MDS, BMCInst);
  3347. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  3348. // return sizeof (*pRes);
  3349. }
  3350. /*---------------------------------------
  3351. * MasterWriteRead
  3352. *---------------------------------------*/
  3353. int
  3354. MasterWriteRead (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  3355. {
  3356. // _NEAR_ MasterWriteReadReq_T* pMasterWriteReadReq = (_NEAR_ MasterWriteReadReq_T*)pReq;
  3357. // _NEAR_ MasterWriteReadRes_T* pMasterWriteReadRes = (_NEAR_ MasterWriteReadRes_T*)pRes;
  3358. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  3359. // _NEAR_ INT8U* OutBuffer;
  3360. // _NEAR_ INT8U* InBuffer;
  3361. // INT8U ChannelNum, BusID, BusType, SlaveAddr, ReadCount, WriteCount;
  3362. // INT8S BusName[64];
  3363. // int retval = 0;
  3364. // INT8U OrgReadCount;
  3365. // INT8U I2CBusId=0;
  3366. // INT8U DevID = 0; // This will be '0' by Default... /dev/peci0
  3367. // INT8U Target = 0x30; // This is the Client address. 30h = 48 is Default for CPU0
  3368. // INT8U Domain = 0; // Multi-Domain support. Default is '0'
  3369. // INT8U Xmit_Feedback = 0; // If full response is Desired, enable this. Default is '1'
  3370. // INT8U AWFCS = 0; // Enable AWFCS in the Transmitted packet by Hw. Default is '0'
  3371. // INT8U Read_Len = 0; // Number of bytes of read back Data from PECI Client
  3372. // INT8U Write_Len = 0; // Number of bytes of data, host is sending to client
  3373. // INT8U *Write_Data = NULL; // Pointer to the Data sent by User to the PECI Client
  3374. // INT8U *Read_Data = NULL; // Pointer to the Data received from PECI Client to be sent to user
  3375. // int ret_val = 0;
  3376. //
  3377. // if(pMasterWriteReadReq->SlaveAddress & BIT0)
  3378. // {
  3379. // *pRes = CC_INV_DATA_FIELD;
  3380. // return sizeof (*pRes);
  3381. // }
  3382. //
  3383. // ReadCount = pMasterWriteReadReq->ReadCount;
  3384. // ChannelNum = GetBits (pMasterWriteReadReq->BusTypeChNo, 0xF0);
  3385. // BusID = GetBits (pMasterWriteReadReq->BusTypeChNo, 0x0E);
  3386. // BusType = GetBits (pMasterWriteReadReq->BusTypeChNo, 0x01);
  3387. // SlaveAddr = (pMasterWriteReadReq->SlaveAddress >> 1);
  3388. //
  3389. // if ((BusType == 0x00 && BusID != 0x00) || ((BusType == 0x01) && (BusID == 0x00)))
  3390. // {
  3391. // *pRes = CC_INV_DATA_FIELD;
  3392. // return sizeof (*pRes);
  3393. // }
  3394. // // Command order:
  3395. // // ipmitool -H <IP> -I lan -U <Username> -P <Password> bus=7 <Slave_Addr> <Read_Len> <Write_Len> <AWFCS> <Domain> <Data>
  3396. // // <bus=7> : Bus# must be 0x07 for comunicating with PECI over IPMI. Other buses are not for this feature
  3397. // // <Slave_Addr> : This is the PECI Client target address.
  3398. // // <Read_Len> : Number of bytes of data to read from the PECI Response
  3399. // // <Write_Len> : Number of bytes of data being written, as per the PECI Spec. Number of Bytes after Domain.
  3400. // // <AWFCS> : 0x01 or 0x00 indicates enabling or disabling of AWFCS feature respectively
  3401. // // <Domain> : 0x01 or 0x00 indicates domain=1 or domain=0 for multi-domain commands respectively
  3402. // // <Data> : Rest of data like Command, and other params as per the PECI Spec.
  3403. //
  3404. // // If BusType is External (0x01) and BusID is 7, then we consider to communicate with PECI
  3405. //
  3406. // if(g_corefeatures.peci_over_ipmi == ENABLED )
  3407. // {
  3408. // if ((BusType & 0x01) && (BusID == 0x07))
  3409. // {
  3410. // DevID = 0;
  3411. // Xmit_Feedback = 0;
  3412. // Target = pMasterWriteReadReq->SlaveAddress;
  3413. // Read_Len = ReadCount;
  3414. // Write_Len = pMasterWriteReadReq->Data[0];
  3415. // AWFCS = pMasterWriteReadReq->Data[1];
  3416. // Domain = pMasterWriteReadReq->Data[2];
  3417. // Write_Data = &pMasterWriteReadReq->Data[3];
  3418. // Read_Data = &pMasterWriteReadRes->Data[0];
  3419. //
  3420. // memset(&pMasterWriteReadRes->Data[0], 0, sizeof(pMasterWriteReadRes->Data));
  3421. //
  3422. // // Call the PECI Generic Handler for passing the command to the PECI Controller
  3423. // if(g_HALPECIHandle[HAL_PECI_COMMAND] != NULL)
  3424. // {
  3425. // ret_val = ((int(*)(char, char, char, char, char, char *, char, char *, char))g_HALPECIHandle[HAL_PECI_COMMAND]) (DevID, Target,
  3426. // Domain, Xmit_Feedback, AWFCS,
  3427. // (char *)Write_Data, Write_Len,
  3428. // (char *)Read_Data, Read_Len );
  3429. // }
  3430. // else
  3431. // {
  3432. // pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  3433. // return sizeof (*pRes);
  3434. // }
  3435. //
  3436. // /* Check if peci issue command operation is success or not */
  3437. // if (ret_val == -1)
  3438. // {
  3439. // pMasterWriteReadRes->CompletionCode = CC_INV_DATA_FIELD;
  3440. // return sizeof (*pRes);
  3441. // }
  3442. //
  3443. // pMasterWriteReadRes->CompletionCode = CC_NORMAL;
  3444. //
  3445. // return (sizeof (*pRes) + ReadCount);
  3446. // }
  3447. // }
  3448. //
  3449. // if(0 ==BusType){
  3450. // if(PRIMARY_IPMB_CHANNEL == ChannelNum)
  3451. // {
  3452. // I2CBusId=pBMCInfo->IpmiConfig.PrimaryIPMBBusNumber;
  3453. // }
  3454. // else if((pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)&&(pBMCInfo->SecondaryIPMBCh == ChannelNum))
  3455. // {
  3456. // I2CBusId=pBMCInfo->IpmiConfig.SecondaryIPMBBusNumber;
  3457. // }else{
  3458. // *pRes = CC_INV_DATA_FIELD;
  3459. // return sizeof (*pRes);
  3460. // }
  3461. // }
  3462. // else
  3463. // {
  3464. // if(BusID==pBMCInfo->IpmiConfig.PrimaryIPMBBusNumber)
  3465. // {
  3466. // *pRes = CC_INV_DATA_FIELD;
  3467. // return sizeof (*pRes);
  3468. // }else if((pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)&&(BusID==pBMCInfo->IpmiConfig.SecondaryIPMBBusNumber))
  3469. // {
  3470. // *pRes = CC_INV_DATA_FIELD;
  3471. // return sizeof (*pRes);
  3472. // }else{
  3473. // I2CBusId=BusID;
  3474. // }
  3475. // }
  3476. //
  3477. // if (ReqLen < 3)
  3478. // {
  3479. // *pRes = CC_REQ_INV_LEN;
  3480. // return sizeof (*pRes);
  3481. // }
  3482. //
  3483. // /* number of bytes to write
  3484. // * = pMasterWriteReadReq length - 3 for Request Data byte -
  3485. // * BusTypeChNo,SlaveAddr,Readcount + 1 byte for address
  3486. // */
  3487. // WriteCount = ReqLen - 3;
  3488. //
  3489. // OutBuffer = (pMasterWriteReadReq->Data);
  3490. // InBuffer = pMasterWriteReadRes->Data;
  3491. // sprintf(BusName,"/dev/i2c%d",I2CBusId);
  3492. //
  3493. // // Save original ReadCount in case we need to modify it
  3494. // OrgReadCount = ReadCount;
  3495. //
  3496. // // If both ReadCount and WriteCount are zero, then force a read of 1 byte.
  3497. // // If we do not do this, the write command will fail.
  3498. // // Having both counts 0 is a way of "pinging" the given device to see if it
  3499. // // is responding to its address.
  3500. //
  3501. // if (ReadCount == 0 && WriteCount == 0)
  3502. // {
  3503. // ReadCount = 1;
  3504. // }
  3505. //
  3506. // if (ReadCount > 0 && WriteCount == 0)
  3507. // {
  3508. // if(g_HALI2CHandle[HAL_I2C_MR] != NULL)
  3509. // {
  3510. // retval = ((int(*)(char *,u8,u8 *,size_t))g_HALI2CHandle[HAL_I2C_MR]) (BusName, SlaveAddr, InBuffer, ReadCount);
  3511. // if (retval < 0)
  3512. // {
  3513. // pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
  3514. // return sizeof (*pRes);
  3515. // }
  3516. // }
  3517. // else
  3518. // {
  3519. // pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  3520. // return sizeof(*pRes);
  3521. // }
  3522. //
  3523. // ReadCount = OrgReadCount;
  3524. //
  3525. // /* copy the bytes read to Response Data */
  3526. // _fmemcpy (pMasterWriteReadRes->Data, InBuffer, ReadCount);
  3527. // }
  3528. // else if(ReadCount > 0 && WriteCount > 0 )
  3529. // {
  3530. // if(g_HALI2CHandle[HAL_I2C_RW] != NULL)
  3531. // {
  3532. // retval = ((int(*)(char *,u8,u8 *,u8 *,size_t,size_t))g_HALI2CHandle[HAL_I2C_RW]) (BusName, SlaveAddr, OutBuffer, InBuffer, WriteCount, ReadCount);
  3533. // if (retval < 0)
  3534. // {
  3535. // pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
  3536. // return sizeof (*pRes);
  3537. // }
  3538. // }
  3539. // else
  3540. // {
  3541. // pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  3542. // return sizeof(*pRes);
  3543. // }
  3544. //
  3545. // ReadCount = OrgReadCount;
  3546. //
  3547. // /* copy the bytes read to Response Data */
  3548. // _fmemcpy (pMasterWriteReadRes->Data, InBuffer, ReadCount);
  3549. // }
  3550. // else
  3551. // {
  3552. // /* No data to read so use master write instead,
  3553. // * otherwise some devices (EEPROM) that have not finished writing
  3554. // * will fail on the read transaction and possibly corrupt data
  3555. // */
  3556. // if(g_HALI2CHandle[HAL_I2C_MW] != NULL)
  3557. // {
  3558. // retval= ((ssize_t(*)(char *,u8,u8 *,size_t))g_HALI2CHandle[HAL_I2C_MW]) (BusName, SlaveAddr, OutBuffer, WriteCount);
  3559. // if(retval < 0)
  3560. // {
  3561. // pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
  3562. // return sizeof (*pRes);
  3563. // }
  3564. // }
  3565. // else
  3566. // {
  3567. // pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  3568. // return sizeof(*pRes);
  3569. // }
  3570. // }
  3571. //
  3572. // pMasterWriteReadRes->CompletionCode = CC_NORMAL;
  3573. //
  3574. // return (sizeof (*pRes) + ReadCount);
  3575. }
  3576. //#if 0
  3577. /*-------------------------------------------
  3578. * ComputeAuthCode
  3579. *-------------------------------------------*/
  3580. void
  3581. ComputeAuthCode (_FAR_ INT8U* pPassword, _NEAR_ SessionHdr_T* pSessionHdr,
  3582. _NEAR_ IPMIMsgHdr_T* pIPMIMsg, _NEAR_ INT8U* pAuthCode,
  3583. INT8U ChannelType)
  3584. {
  3585. // if (AUTH_TYPE_PASSWORD == pSessionHdr->AuthType)
  3586. // {
  3587. // _fmemcpy (pAuthCode, pPassword, MAX_PASSWORD_LEN);
  3588. // }
  3589. // else
  3590. // {
  3591. // INT8U AuthBuf [MAX_AUTH_PARAM_SIZE];
  3592. // INT16U AuthBufLen = 0;
  3593. // INT8U IPMIMsgLen = *((_NEAR_ INT8U*) pIPMIMsg - 1);
  3594. //
  3595. // /* Password */
  3596. // _fmemcpy (AuthBuf, pPassword, MAX_PASSWORD_LEN);
  3597. // AuthBufLen += MAX_PASSWORD_LEN;
  3598. // /* Session ID */
  3599. // _fmemcpy (AuthBuf + AuthBufLen, &pSessionHdr->SessionID, sizeof (INT32U));
  3600. // AuthBufLen += sizeof (INT32U);
  3601. // /* IPMI Response Message */
  3602. // _fmemcpy (AuthBuf + AuthBufLen, pIPMIMsg, IPMIMsgLen);
  3603. // AuthBufLen += IPMIMsgLen;
  3604. //
  3605. // if (ChannelType == MULTI_SESSION_CHANNEL)
  3606. // {
  3607. // /* Session Sequence Number */
  3608. // _fmemcpy (AuthBuf + AuthBufLen,
  3609. // &pSessionHdr->SessionSeqNum, sizeof (INT32U));
  3610. // AuthBufLen += sizeof (INT32U);
  3611. // }
  3612. // /* Password */
  3613. // _fmemcpy (AuthBuf + AuthBufLen, pPassword, MAX_PASSWORD_LEN);
  3614. // AuthBufLen += MAX_PASSWORD_LEN;
  3615. //
  3616. // switch (pSessionHdr->AuthType)
  3617. // {
  3618. // case AUTH_TYPE_MD2 :
  3619. // AuthCodeCalMD2 (AuthBuf, pAuthCode, AuthBufLen);
  3620. // break;
  3621. //
  3622. // case AUTH_TYPE_MD5 :
  3623. // AuthCodeCalMD5 (AuthBuf, pAuthCode, AuthBufLen);
  3624. // break;
  3625. //
  3626. // default :
  3627. // TDBG ("RMCP: Invalid Authentication Type \n");
  3628. // }
  3629. // }
  3630. }
  3631. //#endif
  3632. /*---------------------------------------
  3633. * GetSystemInfoParam
  3634. *---------------------------------------*/
  3635. int
  3636. GetSystemInfoParam (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  3637. {
  3638. // _NEAR_ GetSystemInfoParamReq_T* pGetSysInfoReq = (_NEAR_ GetSystemInfoParamReq_T*)pReq;
  3639. // _NEAR_ GetSystemInfoParamRes_T* pGetSysInfoRes = ( _NEAR_ GetSystemInfoParamRes_T* ) pRes ;
  3640. // _NEAR_ GetSystemInfoParamOEMRes_T* pGetSysInfoOEMRes = ( _NEAR_ GetSystemInfoParamOEMRes_T* ) pRes ;
  3641. // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  3642. // _FAR_ SystemInfoConfig_T* pSysInfoCfg;
  3643. // INT8U resSize = sizeof(pGetSysInfoRes->CompletionCode) + sizeof(pGetSysInfoRes->ParamRevision);
  3644. // INT8U oem_len;
  3645. // unsigned long oem_addr;
  3646. //
  3647. // // Check for Reserved bits
  3648. // if(pGetSysInfoReq->ParamRev & (BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0))
  3649. // {
  3650. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3651. // return sizeof(pGetSysInfoRes->CompletionCode);
  3652. // }
  3653. //
  3654. // pGetSysInfoRes->CompletionCode = CC_NORMAL;
  3655. //
  3656. // /* Fill the param's older Version and the present version */
  3657. // pGetSysInfoRes->ParamRevision = ((PARAM_OLDER_REVISION << 4) & 0xF0 ) | PARAM_PRESENT_REVISION;
  3658. //
  3659. // /* Check for Revision only parameter */
  3660. // if (pGetSysInfoReq->ParamRev & GET_PARAM_REV_ONLY )
  3661. // {
  3662. // if((MAX_APP_CONF_PARAM >= pGetSysInfoReq->ParamSelector))
  3663. // {
  3664. // return resSize;
  3665. // }
  3666. // else if(( NULL != g_PDKHandle[PDK_GETSYSINFOPARAM]) &&
  3667. // ((MIN_SYSINFO_OEM_CONF_PARAM <= pGetSysInfoReq->ParamSelector) && (MAX_SYSINFO_OEM_CONF_PARAM >= pGetSysInfoReq->ParamSelector)))
  3668. // {
  3669. // oem_len = ((int(*)(INT8U, unsigned long*,int))(g_PDKHandle[PDK_GETSYSINFOPARAM]))(pGetSysInfoReq->ParamSelector, &oem_addr ,BMCInst);
  3670. // if( oem_len == 0)
  3671. // {
  3672. // pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
  3673. // return sizeof(INT8U);
  3674. // }
  3675. // else
  3676. // return resSize;
  3677. // }
  3678. // else
  3679. // {
  3680. // *pRes = CC_PARAM_NOT_SUPPORTED;
  3681. // return sizeof (*pRes);
  3682. // }
  3683. // }
  3684. //
  3685. // /* Get Systen Info parameters from NVRAM */
  3686. // pSysInfoCfg = &pBMCInfo->SystemInfoConfig;
  3687. //
  3688. // switch(pGetSysInfoReq->ParamSelector)
  3689. // {
  3690. // case SET_IN_PROGRESS_PARAM: /*Parameter 0 volatile*/
  3691. // if( (0x00 != pGetSysInfoReq->SetSelector) || (0x00 != pGetSysInfoReq->BlockSelector) )
  3692. // {
  3693. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3694. // return sizeof(pGetSysInfoRes->CompletionCode);
  3695. // }
  3696. //
  3697. // LOCK_BMC_SHARED_MEM(BMCInst);
  3698. // pGetSysInfoRes->SysInfo.SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Sys_SetInProgress;
  3699. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  3700. // resSize++;
  3701. // break;
  3702. //
  3703. // case SYS_FW_VERSION_PARAM:
  3704. // _fmemset(&pGetSysInfoRes->SysInfo.SysVerInfo,0,sizeof(SysVerInfo_T));
  3705. // if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
  3706. // {
  3707. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3708. // return sizeof(pGetSysInfoRes->CompletionCode);
  3709. // }
  3710. //
  3711. // pGetSysInfoRes->SysInfo.SysVerInfo.SetSelector = pGetSysInfoReq->SetSelector;
  3712. // resSize++;
  3713. // if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
  3714. // {
  3715. // pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[0]=pSysInfoCfg->SysFWVersion.TypeOfEncoding;
  3716. // pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[1]=pSysInfoCfg->SysFWVersion.StringLength;
  3717. // _fmemcpy(&pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[2], pSysInfoCfg->SysFWVersion.SysFWVersionName,MAX_STRING_LENGTH_COPY);
  3718. // resSize += MAX_BLOCK_SIZE;
  3719. // }
  3720. // else
  3721. // {
  3722. // _fmemcpy(&pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[0],
  3723. // &pSysInfoCfg->SysFWVersion.SysFWVersionName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
  3724. // resSize += MAX_BLOCK_SIZE;
  3725. // }
  3726. // break;
  3727. //
  3728. // case SYS_NAME_PARAM:
  3729. // if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
  3730. // {
  3731. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3732. // return sizeof(pGetSysInfoRes->CompletionCode);
  3733. // }
  3734. //
  3735. // pGetSysInfoRes->SysInfo.SysNameInfo.SetSelector = pGetSysInfoReq->SetSelector;
  3736. // resSize++;
  3737. // if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
  3738. // {
  3739. // pGetSysInfoRes->SysInfo.SysNameInfo.SysName[0]=pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name;
  3740. // pGetSysInfoRes->SysInfo.SysNameInfo.SysName[1]=pSysInfoCfg->SysName.StringLength_Sys_Name;
  3741. // _fmemcpy(&pGetSysInfoRes->SysInfo.SysNameInfo.SysName[2],&pSysInfoCfg->SysName.SystemName,MAX_STRING_LENGTH_COPY);
  3742. // resSize += MAX_BLOCK_SIZE;
  3743. // }
  3744. // else
  3745. // {
  3746. // _fmemcpy(&pGetSysInfoRes->SysInfo.SysNameInfo.SysName[0],
  3747. // &pSysInfoCfg->SysName.SystemName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2], MAX_BLOCK_SIZE);
  3748. // resSize += MAX_BLOCK_SIZE;
  3749. // }
  3750. // break;
  3751. //
  3752. // case PRIM_OS_NAME_PARAM:
  3753. // if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
  3754. // {
  3755. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3756. // return sizeof(pGetSysInfoRes->CompletionCode);
  3757. // }
  3758. //
  3759. // pGetSysInfoRes->SysInfo.PrimOSInfo.SetSelector = pGetSysInfoReq->SetSelector;
  3760. // resSize++;
  3761. // if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
  3762. // {
  3763. // pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[0]=pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName;
  3764. // pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[1]=pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName;
  3765. // _fmemcpy(&pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[2], &pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName, MAX_STRING_LENGTH_COPY);
  3766. // resSize += MAX_BLOCK_SIZE;
  3767. // }
  3768. // else
  3769. // {
  3770. // _fmemcpy(&pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[0],
  3771. // &pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
  3772. // resSize += MAX_BLOCK_SIZE;
  3773. // }
  3774. // break;
  3775. //
  3776. // case OS_NAME_PARAM:
  3777. // /*Parameter 4 volatile*/
  3778. // _fmemset(&pGetSysInfoRes->SysInfo.OSInfo,0,sizeof(OSInfo_T));
  3779. // if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)||(0x00 != pGetSysInfoReq->BlockSelector))
  3780. // {
  3781. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3782. // return sizeof(pGetSysInfoRes->CompletionCode);
  3783. // }
  3784. // pGetSysInfoRes->SysInfo.OSInfo.SetSelector = pGetSysInfoReq->SetSelector;
  3785. // resSize++;
  3786. // if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
  3787. // {
  3788. // LOCK_BMC_SHARED_MEM(BMCInst);
  3789. // pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[0]=BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName;
  3790. // pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[1]=BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName;
  3791. // _fmemcpy(&pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[2], BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName, MAX_STRING_LENGTH_COPY);
  3792. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  3793. // resSize += MAX_BLOCK_SIZE;
  3794. // }
  3795. // else
  3796. // {
  3797. // LOCK_BMC_SHARED_MEM(BMCInst);
  3798. // _fmemcpy(&pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[0],
  3799. // &BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
  3800. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  3801. // resSize += MAX_BLOCK_SIZE;
  3802. // }
  3803. //
  3804. // break;
  3805. //
  3806. // default:
  3807. // if(g_PDKHandle[PDK_GETSYSINFOPARAM] != NULL &&
  3808. // (pGetSysInfoReq->ParamSelector >= 192 && pGetSysInfoReq->ParamSelector <= 255))
  3809. // {
  3810. // oem_len = ((int(*)(INT8U, unsigned long*,int))(g_PDKHandle[PDK_GETSYSINFOPARAM]))(pGetSysInfoReq->ParamSelector, &oem_addr ,BMCInst);
  3811. // if( oem_len == 0)
  3812. // {
  3813. // pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
  3814. // return sizeof(INT8U);
  3815. // }
  3816. // else
  3817. // {
  3818. // //Acquire the OEM parameters
  3819. // if( oem_len < MSG_PAYLOAD_SIZE - sizeof(GetLanCCRev_T))
  3820. // {
  3821. // memcpy((char*)pGetSysInfoOEMRes + sizeof(GetSystemInfoParamOEMRes_T) ,\
  3822. // (unsigned int*)oem_addr , oem_len);
  3823. // }
  3824. // else
  3825. // {
  3826. // pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
  3827. // return sizeof(INT8U);
  3828. // }
  3829. // return sizeof(GetSystemInfoParamOEMRes_T) + oem_len;
  3830. // }
  3831. // }
  3832. // else
  3833. // {
  3834. // pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
  3835. // return sizeof(pGetSysInfoRes->CompletionCode);
  3836. // }
  3837. // }
  3838. // /* return the size of the response */
  3839. // return resSize;
  3840. }
  3841. int validatestring(INT8U* String,int len,INT8U TOE)
  3842. {
  3843. int i,delimit = 0,strlen = 0;
  3844. for(i=0;i<len;i++)
  3845. {
  3846. if(String[i] == 0)
  3847. {
  3848. delimit++;
  3849. }
  3850. else
  3851. {
  3852. if(delimit != 0)
  3853. {
  3854. if(TOE == UNICODE)
  3855. {
  3856. if(delimit == 2)
  3857. {
  3858. strlen = strlen + 2;
  3859. }
  3860. else
  3861. {
  3862. return -1;
  3863. }
  3864. }
  3865. else
  3866. {
  3867. if(delimit == 1)
  3868. {
  3869. strlen = strlen + 1;
  3870. }
  3871. else
  3872. {
  3873. return -1;
  3874. }
  3875. }
  3876. delimit = 0;
  3877. }
  3878. strlen++;
  3879. }
  3880. }
  3881. return strlen;
  3882. }
  3883. /*---------------------------------------
  3884. * SetSystemInfoParam
  3885. *---------------------------------------*/
  3886. int
  3887. SetSystemInfoParam (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  3888. {
  3889. // _NEAR_ SetSystemInfoParamReq_T* pSetSysInfoReq = (_NEAR_ SetSystemInfoParamReq_T*)pReq;
  3890. // _NEAR_ SetSystemInfoParamOEMReq_T* pSetSysInfoOEMReq = (_NEAR_ SetSystemInfoParamOEMReq_T*)pReq;
  3891. // _NEAR_ SetSystemInfoParamRes_T* pSetSysInfoRes = (_NEAR_ SetSystemInfoParamRes_T*)pRes;
  3892. // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  3893. // _FAR_ SystemInfoConfig_T* pSysInfoCfg;
  3894. // INT8U *pSetInProgress;
  3895. // unsigned long oem_addr[2]={0}; // use oem_addr[1] as read-only/write-only flag
  3896. // int size,strlen,len;
  3897. // INT8U OSName[MAX_OS_NAME_LENGTH] = {0};
  3898. //
  3899. // //If the OEM parameter is existing, then skip the length check.
  3900. // if(g_PDKHandle[PDK_SETSYSINFOPARAM] == NULL && (pSetSysInfoReq->ParamSelector < 192 )){
  3901. // if( !( (SET_IN_PROGRESS_PARAM == pSetSysInfoReq->ParamSelector && ( ReqLen == ( sizeof(pSetSysInfoReq->ParamSelector) + sizeof(INT8U) /* for Data */ ) )) ||
  3902. // ( pSetSysInfoReq->ParamSelector < MAX_PARAM_SELECTOR && ReqLen == ( sizeof(pSetSysInfoReq->ParamSelector) + sizeof(INT8U) /* for set Selector */ + MAX_BLOCK_SIZE))) )
  3903. // {
  3904. // pSetSysInfoRes->CompletionCode = CC_REQ_INV_LEN;
  3905. // return sizeof(pSetSysInfoRes->CompletionCode);
  3906. // }
  3907. // }
  3908. //
  3909. // pSetInProgress = &BMC_GET_SHARED_MEM(BMCInst)->m_Sys_SetInProgress;
  3910. //
  3911. // pSetSysInfoRes->CompletionCode = CC_NORMAL;
  3912. //
  3913. // /*Get NVRAM System Info Configuration parameters */
  3914. // pSysInfoCfg = &pBMCInfo->SystemInfoConfig;
  3915. //
  3916. // switch (pSetSysInfoReq->ParamSelector)
  3917. // {
  3918. // /*Parameter 0 volatile */
  3919. // case SET_IN_PROGRESS_PARAM:
  3920. // LOCK_BMC_SHARED_MEM(BMCInst);
  3921. // /* If Request for Set In progress */
  3922. // if(( SYS_INFO_SET_IN_PROGRESS == *pSetInProgress ) &&
  3923. // ( SYS_INFO_SET_IN_PROGRESS == pSetSysInfoReq->SysInfo.SetInProgress ))
  3924. // {
  3925. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  3926. // /* Trying to SetinProgress when already in set*/
  3927. // pSetSysInfoRes->CompletionCode = CC_SYS_INFO_SET_IN_PROGRESS ;
  3928. // return sizeof(pSetSysInfoRes->CompletionCode);
  3929. // } else if( SYS_INFO_COMMIT_WRITE == pSetSysInfoReq->SysInfo.SetInProgress )
  3930. // {
  3931. // /* Write SysInfoConfig to NVR */
  3932. // FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig,
  3933. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SystemInfoConfig_T),BMCInst);
  3934. // /* Write volatile data to the BMC Shared memory */
  3935. //
  3936. // } else if ( SYS_INFO_SET_COMPLETE == pSetSysInfoReq->SysInfo.SetInProgress )
  3937. // {
  3938. // //PMCONFIG_FILE(BMCInst,PMConfigFile);
  3939. // /* Set it to set Complete */
  3940. // *pSetInProgress = pSetSysInfoReq->SysInfo.SetInProgress;
  3941. // FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig,
  3942. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SystemInfoConfig_T),BMCInst);
  3943. // } else if ( SYS_INFO_SET_IN_PROGRESS != pSetSysInfoReq->SysInfo.SetInProgress )
  3944. // {
  3945. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  3946. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3947. // return sizeof(pSetSysInfoRes->CompletionCode);
  3948. // }
  3949. //
  3950. // *pSetInProgress = pSetSysInfoReq->SysInfo.SetInProgress;
  3951. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  3952. // break;
  3953. //
  3954. // case SYS_FW_VERSION_PARAM:
  3955. //
  3956. // if(pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector >= MAX_BLOCK_SIZE)
  3957. // {
  3958. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3959. // return sizeof(pSetSysInfoRes->CompletionCode);
  3960. // }
  3961. // if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector==ZERO_SETSELECTOR)
  3962. // {
  3963. // if(pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]> MAX_FW_VER_LENGTH)
  3964. // {
  3965. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3966. // return sizeof(pSetSysInfoRes->CompletionCode);
  3967. // }
  3968. // if(pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0] > MAX_TYPE_OF_ENCODING)
  3969. // {
  3970. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3971. // return sizeof(pSetSysInfoRes->CompletionCode);
  3972. // }
  3973. // memset(&pSysInfoCfg->SysFWVersion,0,sizeof(pSysInfoCfg->SysFWVersion));
  3974. // pSysInfoCfg->SysFWVersion.TypeOfEncoding=pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0];
  3975. // pSysInfoCfg->SysFWVersion.StringLength=pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1];
  3976. // /*First character should not be a delimiter*/
  3977. // 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)))
  3978. // {
  3979. // *pRes = CC_INV_DATA_FIELD;
  3980. // return sizeof(INT8U);
  3981. // }
  3982. // strlen = validatestring(&pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0]);
  3983. // if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]) || ((pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]))
  3984. // {
  3985. // *pRes = CC_INV_DATA_FIELD;
  3986. // return sizeof(INT8U);
  3987. // }
  3988. // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
  3989. // {
  3990. // *pRes = CC_INV_DATA_FIELD;
  3991. // return sizeof(INT8U);
  3992. // }
  3993. // _fmemcpy(&pSysInfoCfg->SysFWVersion.SysFWVersionName[0],&pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2], MAX_STRING_LENGTH_COPY);
  3994. // FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig.SysFWVersion,
  3995. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysFWVersion_T),BMCInst);
  3996. // }
  3997. // else
  3998. // {
  3999. // _fmemcpy(&pSysInfoCfg->SysFWVersion.SysFWVersionName[(pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector* MAX_BLOCK_SIZE) - 2],
  4000. // &pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0],MAX_BLOCK_SIZE);
  4001. // len = ((pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
  4002. // strlen = validatestring(&pSysInfoCfg->SysFWVersion.SysFWVersionName[0],len,pSysInfoCfg->SysFWVersion.TypeOfEncoding);
  4003. // if(strlen == -1 || (strlen > pSysInfoCfg->SysFWVersion.StringLength))
  4004. // {
  4005. // *pRes = CC_INV_DATA_FIELD;
  4006. // return sizeof(INT8U);
  4007. // }
  4008. // /*Check the String length*/
  4009. // if(((len < pSysInfoCfg->SysFWVersion.StringLength) && (len != strlen)) || ((len > pSysInfoCfg->SysFWVersion.StringLength) && (pSysInfoCfg->SysFWVersion.StringLength != strlen)))
  4010. // {
  4011. // *pRes = CC_INV_DATA_FIELD;
  4012. // return sizeof(INT8U);
  4013. // }
  4014. // if((len == pSysInfoCfg->SysFWVersion.StringLength) && (pSysInfoCfg->SysFWVersion.StringLength != strlen))
  4015. // {
  4016. // *pRes = CC_INV_DATA_FIELD;
  4017. // return sizeof(INT8U);
  4018. // }
  4019. //
  4020. // FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,
  4021. // (INT8U*)&pBMCInfo->SystemInfoConfig.SysFWVersion,pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysFWVersion_T),BMCInst);
  4022. // }
  4023. // break;
  4024. //
  4025. // case SYS_NAME_PARAM:
  4026. // if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector >= MAX_BLOCK_SIZE )
  4027. // {
  4028. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  4029. // return sizeof(pSetSysInfoRes->CompletionCode);
  4030. // }
  4031. // if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector==ZERO_SETSELECTOR)
  4032. // {
  4033. // if((pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1] > MAX_SYS_NAME_LENGTH))
  4034. // {
  4035. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  4036. // return sizeof(pSetSysInfoRes->CompletionCode);
  4037. // }
  4038. // if(pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0]>MAX_TYPE_OF_ENCODING)
  4039. // {
  4040. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  4041. // return sizeof(pSetSysInfoRes->CompletionCode);
  4042. // }
  4043. // memset(&pSysInfoCfg->SysName,0,sizeof(pSysInfoCfg->SysName));
  4044. // pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name=pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0];
  4045. // pSysInfoCfg->SysName.StringLength_Sys_Name=pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1];
  4046. //
  4047. // /*First character should not be a delimiter*/
  4048. // 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)))
  4049. // {
  4050. // *pRes = CC_INV_DATA_FIELD;
  4051. // return sizeof(INT8U);
  4052. // }
  4053. //
  4054. // strlen = validatestring(&pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0]);
  4055. // if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]) || ((pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]))
  4056. // {
  4057. // *pRes = CC_INV_DATA_FIELD;
  4058. // return sizeof(INT8U);
  4059. // }
  4060. // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
  4061. // {
  4062. // *pRes = CC_INV_DATA_FIELD;
  4063. // return sizeof(INT8U);
  4064. // }
  4065. //
  4066. // _fmemcpy(&pSysInfoCfg->SysName.SystemName[0], &pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2],MAX_STRING_LENGTH_COPY);
  4067. // FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig.SysName,
  4068. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysName_T),BMCInst);
  4069. // }
  4070. // else
  4071. // {
  4072. // _fmemcpy(&pSysInfoCfg->SysName.SystemName[(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector* MAX_BLOCK_SIZE) - 2],
  4073. // &pSetSysInfoReq->SysInfo.SysNameInfo.SysName,MAX_BLOCK_SIZE);
  4074. // len = ((pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
  4075. // strlen = validatestring(&pSysInfoCfg->SysName.SystemName[0],len,pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name);
  4076. // if(strlen == -1 || (strlen > pSysInfoCfg->SysName.StringLength_Sys_Name))
  4077. // {
  4078. // *pRes = CC_INV_DATA_FIELD;
  4079. // return sizeof(INT8U);
  4080. // }
  4081. // /*Check the String length*/
  4082. // if(((len < pSysInfoCfg->SysName.StringLength_Sys_Name) && (len != strlen)) || ((len > pSysInfoCfg->SysName.StringLength_Sys_Name) && (pSysInfoCfg->SysName.StringLength_Sys_Name != strlen)))
  4083. // {
  4084. // *pRes = CC_INV_DATA_FIELD;
  4085. // return sizeof(INT8U);
  4086. // }
  4087. // if((len == pSysInfoCfg->SysName.StringLength_Sys_Name) && (pSysInfoCfg->SysName.StringLength_Sys_Name != strlen))
  4088. // {
  4089. // *pRes = CC_INV_DATA_FIELD;
  4090. // return sizeof(INT8U);
  4091. // }
  4092. //
  4093. // FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig.SysName,
  4094. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysName_T),BMCInst);
  4095. // }
  4096. // break;
  4097. //
  4098. // case PRIM_OS_NAME_PARAM:
  4099. // if(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector >= MAX_BLOCK_SIZE )
  4100. // {
  4101. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  4102. // return sizeof(pSetSysInfoRes->CompletionCode);
  4103. // }
  4104. // if(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector==ZERO_SETSELECTOR)
  4105. // {
  4106. // if((pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1] > MAX_PRIM_OS_NAME_LENGTH))
  4107. // {
  4108. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  4109. // return sizeof(pSetSysInfoRes->CompletionCode);
  4110. //
  4111. // }
  4112. // if(pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0]>MAX_TYPE_OF_ENCODING)
  4113. // {
  4114. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  4115. // return sizeof(pSetSysInfoRes->CompletionCode);
  4116. // }
  4117. // memset(&pSysInfoCfg->PrimaryOSName,0,sizeof(pSysInfoCfg->PrimaryOSName));
  4118. // pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName=pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0];
  4119. // pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName=pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1];
  4120. //
  4121. // /*First character should not be a delimiter*/
  4122. // 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)))
  4123. // {
  4124. // *pRes = CC_INV_DATA_FIELD;
  4125. // return sizeof(INT8U);
  4126. // }
  4127. //
  4128. // strlen = validatestring(&pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0]);
  4129. // if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]) || ((pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]))
  4130. // {
  4131. // *pRes = CC_INV_DATA_FIELD;
  4132. // return sizeof(INT8U);
  4133. // }
  4134. // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
  4135. // {
  4136. // *pRes = CC_INV_DATA_FIELD;
  4137. // return sizeof(INT8U);
  4138. // }
  4139. //
  4140. // _fmemcpy(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[0], &pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2], MAX_STRING_LENGTH_COPY);
  4141. // FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig.PrimaryOSName,
  4142. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(PrimaryOSName_T),BMCInst);
  4143. // }
  4144. // else
  4145. // {
  4146. // _fmemcpy(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector * MAX_BLOCK_SIZE) - 2],
  4147. // &pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName, MAX_BLOCK_SIZE);
  4148. // len = ((pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
  4149. // strlen = validatestring(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[0],len,pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName);
  4150. // if(strlen == -1 || (strlen > pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName))
  4151. // {
  4152. // *pRes = CC_INV_DATA_FIELD;
  4153. // return sizeof(INT8U);
  4154. // }
  4155. // /*Check the String length*/
  4156. // if(((len < pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (len != strlen)) || ((len > pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName != strlen)))
  4157. // {
  4158. // *pRes = CC_INV_DATA_FIELD;
  4159. // return sizeof(INT8U);
  4160. // }
  4161. // if((len == pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName != strlen))
  4162. // {
  4163. // *pRes = CC_INV_DATA_FIELD;
  4164. // return sizeof(INT8U);
  4165. // }
  4166. //
  4167. // FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,
  4168. // (INT8U*)&pBMCInfo->SystemInfoConfig.PrimaryOSName,pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(PrimaryOSName_T),BMCInst);
  4169. // }
  4170. // break;
  4171. //
  4172. // case OS_NAME_PARAM:
  4173. // /*Parameter 4 volatile*/
  4174. // if(pSetSysInfoReq->SysInfo.OSInfo.SetSelector >= MAX_BLOCK_SIZE )
  4175. // {
  4176. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  4177. // return sizeof(pSetSysInfoRes->CompletionCode);
  4178. // }
  4179. // if(pSetSysInfoReq->SysInfo.OSInfo.SetSelector==ZERO_SETSELECTOR)
  4180. // {
  4181. // if(pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1] > MAX_OS_NAME_LENGTH)
  4182. // {
  4183. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  4184. // return sizeof(pSetSysInfoRes->CompletionCode);
  4185. // }
  4186. // if(pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0] > MAX_TYPE_OF_ENCODING)
  4187. // {
  4188. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  4189. // return sizeof(pSetSysInfoRes->CompletionCode);
  4190. // }
  4191. //
  4192. // /*First character should not be a delimiter*/
  4193. // 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)))
  4194. // {
  4195. // *pRes = CC_INV_DATA_FIELD;
  4196. // return sizeof(INT8U);
  4197. // }
  4198. //
  4199. // strlen = validatestring(&pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0]);
  4200. // if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]) || ((pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]))
  4201. // {
  4202. // *pRes = CC_INV_DATA_FIELD;
  4203. // return sizeof(INT8U);
  4204. // }
  4205. // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
  4206. // {
  4207. // *pRes = CC_INV_DATA_FIELD;
  4208. // return sizeof(INT8U);
  4209. // }
  4210. //
  4211. // memset(&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName,0,sizeof(OSName_T));
  4212. // LOCK_BMC_SHARED_MEM(BMCInst);
  4213. // BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName=pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0];
  4214. // BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName=pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1];
  4215. // _fmemcpy(&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName, &pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2],
  4216. // MAX_STRING_LENGTH_COPY);
  4217. // UNLOCK_BMC_SHARED_MEM (BMCInst);
  4218. // }
  4219. // else
  4220. // {
  4221. // LOCK_BMC_SHARED_MEM(BMCInst);
  4222. // _fmemcpy(&OSName[0],&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[0],MAX_OS_NAME_LENGTH);
  4223. // _fmemcpy(&OSName[(pSetSysInfoReq->SysInfo.OSInfo.SetSelector * MAX_BLOCK_SIZE) - 2],&pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName,MAX_BLOCK_SIZE);
  4224. // len = ((pSetSysInfoReq->SysInfo.OSInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
  4225. // strlen = validatestring(&OSName[0],len,BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName);
  4226. // if(strlen == -1 || (strlen > BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName))
  4227. // {
  4228. // *pRes = CC_INV_DATA_FIELD;
  4229. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  4230. // return sizeof(INT8U);
  4231. // }
  4232. // /*Check the String length*/
  4233. // 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)))
  4234. // {
  4235. // *pRes = CC_INV_DATA_FIELD;
  4236. // return sizeof(INT8U);
  4237. // }
  4238. // if((len == BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName) && (BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName != strlen))
  4239. // {
  4240. // *pRes = CC_INV_DATA_FIELD;
  4241. // return sizeof(INT8U);
  4242. // }
  4243. //
  4244. // _fmemcpy(&(BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[(pSetSysInfoReq->SysInfo.OSInfo.SetSelector * MAX_BLOCK_SIZE) - 2]),
  4245. // &pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName,MAX_BLOCK_SIZE);
  4246. // UNLOCK_BMC_SHARED_MEM (BMCInst);
  4247. // }
  4248. // break;
  4249. //
  4250. // default:
  4251. // if(g_PDKHandle[PDK_SETSYSINFOPARAM] != NULL &&
  4252. // (pSetSysInfoReq->ParamSelector >= 192 && pSetSysInfoReq->ParamSelector <= 255))
  4253. // {
  4254. // oem_addr[0] = (unsigned long)((char*)pSetSysInfoOEMReq + sizeof(SetSystemInfoParamOEMReq_T));
  4255. // size = ((int(*)(INT8U, unsigned long*,int))(g_PDKHandle[PDK_SETSYSINFOPARAM]))(pSetSysInfoReq->ParamSelector, oem_addr ,BMCInst);
  4256. // if(size <= 0)
  4257. // {
  4258. // switch (oem_addr[1]) {
  4259. // case CC_SYS_INFO_READ_ONLY_PARAM:
  4260. // pSetSysInfoRes->CompletionCode = CC_SYS_INFO_READ_ONLY_PARAM;
  4261. // break;
  4262. // default:
  4263. // pSetSysInfoRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
  4264. // }
  4265. // }
  4266. // else
  4267. // {
  4268. // pSetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
  4269. // return sizeof(pSetSysInfoRes->CompletionCode);
  4270. // }
  4271. // }
  4272. // }
  4273. // return sizeof(pSetSysInfoRes->CompletionCode);
  4274. }
  4275. //#endif /* APP_DEVICE */