123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386 |
- /****************************************************************
- ****************************************************************
- ** **
- ** (C)Copyright 2005-2006, American Megatrends Inc. **
- ** **
- ** All Rights Reserved. **
- ** **
- ** 6145-F, Northbelt Parkway, Norcross, **
- ** **
- ** Georgia - 30071, USA. Phone-(770)-246-8600. **
- ** **
- ****************************************************************
- ****************************************************************/
- /*****************************************************************
- *
- * AppDevice.c
- * AppDevice Commands Handler
- *
- * Author: Govind Kothandapani <govindk@ami.com>
- * : Rama Bisa <ramab@ami.com>
- * : Basavaraj Astekar <basavaraja@ami.com>
- * : Bakka Ravinder Reddy <bakkar@ami.com>
- *
- *****************************************************************/
- #define ENABLE_DEBUG_MACROS 0
- #include "Types.h"
- #include "Debug.h"
- #include "IPMI_Main.h"
- #include "SharedMem.h"
- #include "Support.h"
- #include "Message.h"
- #include "IPMIDefs.h"
- #include "MsgHndlr.h"
- #include "IPMI_IPM.h"
- #include "IPMI_AppDevice.h"
- #include "AppDevice.h"
- #include "RMCP.h"
- #include "MD.h"
- #include "LANIfc.h"
- #include "WDT.h"
- #include "NVRAccess.h"
- #include "Util.h"
- //#include "libipmi_struct.h"
- //#include "nwcfg.h"
- #include "Ethaddr.h"
- //#include "IPMIConf.h"
- #include "IPMBIfc.h"
- #include "IPMI_KCS.h"
- //#include "ipmi_userifc.h"
- //#include "hmac_md5.h"
- //#include "hmac.h"
- //#include "MD5_128.h"
- #include "Badpasswd.h"
- #include "hal_hw.h"
- //#include "iniparser.h"
- #include "Session.h"
- //#include <linux/if.h>
- #include "LANConfig.h"
- #include <netdb.h> /* getaddrinfo(3) et al. */
- #include <netinet/in.h> /* sockaddr_in & sockaddr_in6 definition. */
- //#include "userprivilege.h"
- #include <ctype.h>
- //#include "PDKBridgeMsg.h"
- //#include "featuredef.h"
- //#include "blowfish.h"
- #include "bmc_main.h"
- #include "session.h"
- #include "bmc_type.h"
- #define USER_ID_ENABLED 0x01
- #define USER_ID_DISABLED 0x02
- #define OP_USERID_ONLY_LENGTH 2
- #define OP_ENABLE_USER_ID 1
- #define OP_DISABLE_USER_ID 0
- #define BIT3_BIT0_MASK 0xf
- #define GET_AUTH_TYPE_MASK 0xc0
- #define AUTH_TYPE_V15 0x0
- #define AUTH_TYPE_V20 0x40
- #define AUTH_CODE_V15_MASK 0x0f
- #define AUTH_CODE_V15_1 0x1
- #define AUTH_CODE_V15_2 0x2
- #define AUTH_CODE_V15_3 0x5
- #define AUTH_CODE_V20_MASK 0x3f
- #define MIN_AUTH_CODE_V20 0x04
- #define MAX_AUTH_CODE_V20 0xc0
- #define NULL_USER 1
- #define ZERO_SETSELECTOR 0x00
- #define MAX_TYPE_OF_ENCODING 0x02
- #define MAX_STRING_LENGTH_COPY 14
- #define ASCII_LATIN1 0x00
- #define UTF_8 0x01
- #define UNICODE 0x02
- /* Reserved bit macro definitions */
- #define RESERVED_BITS_SENDMS 0x03 //(BIT1 | BIT0)
- /* Auth code length */
- #define HMAC_SHA1_96_LEN 12
- //#if APP_DEVICE == 1
- #define COUNT_INCREASE 1
- #define COUNT_DECREASE -1
- #define MAX_BT_PKT_LEN 255
- #define RESERVED_USERS_FILE "/etc/reservedusers"
- /*macro definitions for set user password options*/
- #define DISABLE_USER 0
- #define ENABLE_USER 1
- #define SET_PASSWORD 2
- #define TEST_PASSWORD 3
- /*** Global variables ***/
- _FAR_ INT8U g_TmrRunning;
- /*** Module variables ***/
- static _FAR_ MsgPkt_T m_MsgPkt; /**< Message Packet for posting and retrieving messaged to/from queue */
- static INT8U m_Set_ChReserveBit[] ={0xF0,0x0,0x30};
- //extern IfcName_T Ifcnametable[MAX_LAN_CHANNELS];
- /**
- * @fn CheckReservedUsers
- * @brief This function will checks for reserved users.
- * @param Username - Username.
- * @retval availability of reserved users.
- */
- static int CheckForReservedUsers(char *Username)
- {
- //dictionary *dict = NULL;
- //char *sectionname = NULL;
- //int nsec=0 , i=0;
- //TDBG("filename is %s\n",RESERVED_USERS_FILE);
- //dict = iniparser_load(RESERVED_USERS_FILE);
- //if(dict == NULL)
- //{
- // TINFO("Unable to parse dummy users file :%s", RESERVED_USERS_FILE);
- // return -1;
- //}
- //nsec = iniparser_getnsec(dict);
- //for (i=0;i<nsec;i++)
- //{
- // sectionname = iniparser_getsecname (dict, i);
- // if(NULL == sectionname)
- // {
- // TINFO("Unable to get setion name of dummy users file :%s",RESERVED_USERS_FILE);
- // iniparser_freedict(dict);
- // return -1;
- // }
- // if(strcmp(sectionname, Username)==0)
- // {
- // iniparser_freedict(dict);
- // return -1;
- // }
- //}
- //iniparser_freedict(dict);
- return 0;
- }
- static void UpdateCurrentEnabledUserCount(int value, int bmcInstId)
- {
- // if (value == 0) return;
- //
- // _FAR_ ChannelInfo_T* pChannelInfo = NULL;
- // _FAR_ ChannelInfo_T* pNvrChannelInfo = NULL;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[bmcInstId];
- // INT8U maxUserCount = pBMCInfo->IpmiConfig.MaxChUsers;
- // INT8U channelIndex = 0;
- //
- //
- // for (channelIndex = 0; channelIndex < MAX_NUM_CHANNELS; channelIndex++)
- // {
- // if (pBMCInfo->ChConfig[channelIndex].ChType == 0xff) continue;
- //
- // pChannelInfo = (ChannelInfo_T*)&pBMCInfo->ChConfig[channelIndex].ChannelInfo;
- //
- // if (((value > 0) && ((pChannelInfo->NoCurrentUser + value) > maxUserCount)) ||
- // ((value < 0) && ((pChannelInfo->NoCurrentUser + value) < 0)))
- // {
- // continue;
- // }
- //
- // pNvrChannelInfo = GetNVRChConfigs(pChannelInfo, bmcInstId);
- //
- // pChannelInfo->NoCurrentUser+=value;
- // pNvrChannelInfo->NoCurrentUser+=value;
- // FlushChConfigs((INT8U*)pNvrChannelInfo,pNvrChannelInfo->ChannelNumber,bmcInstId);
- //}
- }
- static int IsPrivilegeAvailable(INT8U requestedPrivilege, INT8U channelNumber, int bmcInstId)
- {
- // //_FAR_ PMConfig_T* pPMConfig = (_FAR_ PMConfig_T*) GetNVRAddr(NVRH_PMCONFIG, bmcInstId);
- // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[bmcInstId];
- // INT8U EthIndex = GetEthIndex(channelNumber & 0x0F, bmcInstId);
- // INT8U privilege = 0x00;
- //
- // if(0xff == EthIndex) return -1;
- //
- // //Get requested privilege status (enabled or disabled) from PMConfig by channel
- // switch (requestedPrivilege)
- // {
- // case PRIV_CALLBACK:
- // privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeCallBack;
- // break;
- //
- // case PRIV_USER:
- // privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeUser;
- // break;
- //
- // case PRIV_OPERATOR:
- // privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeOperator;
- // break;
- //
- // case PRIV_ADMIN:
- // privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeAdmin;
- // break;
- //
- // case PRIV_OEM:
- // privilege = pBMCInfo->LANCfs[EthIndex].AuthTypeEnables.AuthTypeOem;
- // break;
- //
- // default:
- // return -1;
- // }
- //
- // //All bits are 0 that means privilege level is disabled
- // return ((privilege != 0x00) ? 0 : -1);
- }
- /*-------------------------------------
- * ValidateIPMBChksum1
- *-------------------------------------*/
- /* Function to validate IPMB Checksum1 for SendMessage Cmd */
- static int ValidateIPMBChksum1(_NEAR_ INT8U* Data)
- {
- int i=0;
- INT8U chksum=0;
- for (i = 0; i < 3; i++)
- {
- chksum += *(Data + i);
- }
- if (chksum != 0)
- {
- return FALSE;
- }
- return TRUE;
- }
- /*-------------------------------------
- * ResetWDT
- *-------------------------------------*/
- int
- ResetWDT (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // INT8U u8ExpirationFlag;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
- //
- //
- // if (pBMCInfo->Msghndlr.TmrSet == FALSE)
- // {
- // *pRes = CC_ATTEMPT_TO_RESET_UNIN_WATCHDOG;
- // return sizeof (*pRes);
- // }
- //
- // // save the WDT expiration flag for later use
- // u8ExpirationFlag = g_WDTTmrMgr.WDTTmr.ExpirationFlag;
- //
- //
- // /* Reset of Watchdog should not happen once
- // once pretimeout interrupt interval is reached*/
- // if(pBMCInfo->WDTPreTmtStat == TRUE)
- // {
- // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (*pRes);
- // }
- //
- // g_WDTTmrMgr.TmrPresent = TRUE;
- // g_WDTTmrMgr.TmrInterval = pBMCInfo->WDTConfig.InitCountDown;
- // g_WDTTmrMgr.PreTimeOutInterval = SEC_TO_MS * pBMCInfo->WDTConfig.PreTimeOutInterval;
- //
- // /* if the pre-timeout interrupt is not configured, adjust the pre-timeout interrupt
- // timeout value beyound the regular WDT timeout value so that it won't get triggered
- // before the WDT timeout. */
- // if ((pBMCInfo->WDTConfig.TmrActions & 0x70) == 0)
- // {
- // g_WDTTmrMgr.PreTimeOutInterval = g_WDTTmrMgr.TmrInterval+ 1;
- // }
- //
- // _fmemcpy (&g_WDTTmrMgr.WDTTmr, &pBMCInfo->WDTConfig, sizeof (WDTConfig_T));
- //
- // // restore the WDT expiration flag, don't use the one from the flash
- // g_WDTTmrMgr.WDTTmr.ExpirationFlag = u8ExpirationFlag;
- //
- // // clear WDT sensor event history
- // if( g_corefeatures.internal_sensor == ENABLED )
- // RestartWD2Sensor(BMCInst);
- //
- // if(g_corefeatures.wdt_flush_support == ENABLED )
- // {
- // FlushIPMI((INT8U*)&pBMCInfo->WDTConfig,(INT8U*)&pBMCInfo->WDTConfig,pBMCInfo->IPMIConfLoc.WDTDATAddr,
- // sizeof(WDTConfig_T),BMCInst);
- // }
- //
- // if(BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent == FALSE)
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning=TRUE;
- // BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent=TRUE;
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // sem_post(&g_BMCInfo;//[BMCInst].WDTSem);
- // }
- // else
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning=TRUE;
- // BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent=TRUE;
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // //Set SetWDTUpdated flag to reload initial countdown value.
- // g_BMCInfo[BMCInst].SetWDTUpdated = TRUE;
- // }
- //
- //
- // *pRes = CC_NORMAL;
- //
- // return sizeof (*pRes);
- }
- /*---------------------------------------
- * SetWDT
- *---------------------------------------*/
- int
- SetWDT (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ SetWDTReq_T* pSetWDTReq = (_NEAR_ SetWDTReq_T*)pReq;
- //#if GET_MSG_FLAGS != UNIMPLEMENTED
- // GetMsgFlagsRes_T GetMsgFlagsRes;
- //#endif
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- //
- //
- // //Check for Reserved bits
- // if((pSetWDTReq->TmrUse & (BIT5 | BIT4 | BIT3)) || !(pSetWDTReq->TmrUse & (BIT2 | BIT1 | BIT0)) || ((pSetWDTReq->TmrUse & (BIT1 | BIT2)) == (BIT1 | BIT2)) ||
- // (pSetWDTReq->TmrActions & (BIT7 |BIT6 | BIT3 | BIT2)) || (pSetWDTReq->ExpirationFlag & (BIT7 | BIT6 | BIT0)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- //
- //#if NO_WDT_PRETIMEOUT_INTERRUPT == 1
- // // do not support pre-timeout interrupt
- // if (pSetWDTReq->TmrActions & 0x70)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- //#endif
- //
- // pSetWDTReq->InitCountDown = htoipmi_u16(pSetWDTReq->InitCountDown);
- //
- // // error out if the pre-timeout interrupt is greater than the initial countdown value
- // if (pSetWDTReq->InitCountDown < 10 * pSetWDTReq->PreTimeOutInterval)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- //
- // // only clear the memory version of the bit(s) when the input bit is set #31175
- // g_WDTTmrMgr.WDTTmr.ExpirationFlag &= ~pSetWDTReq->ExpirationFlag;
- // pSetWDTReq->ExpirationFlag = g_WDTTmrMgr.WDTTmr.ExpirationFlag;
- //
- //
- // /* Copy the Timer configuration in NVRAM */
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemset ((_FAR_ INT8U*)&pBMCInfo->WDTConfig, 0, sizeof (WDTConfig_T));
- // _fmemcpy ((_FAR_ INT8U*)&pBMCInfo->WDTConfig, (_FAR_ INT8U*)pSetWDTReq, sizeof (SetWDTReq_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- //
- // if (TRUE ==BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning)
- // {
- // /* To check wheather Dont stop bit is set or not */
- // if (pSetWDTReq->TmrUse & 0x40)
- // {
- // /* Set the count down value to given value */
- // g_WDTTmrMgr.TmrPresent = TRUE;
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent =TRUE;
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // g_WDTTmrMgr.TmrInterval= pSetWDTReq->InitCountDown;
- // g_WDTTmrMgr.PreTimeOutInterval = (SEC_TO_MS * pSetWDTReq->PreTimeOutInterval);
- //
- // /* If PreTimeOutInt is set, clear it */
- // if (0 != (pSetWDTReq->TmrActions & 0x70))
- // {
- // pSetWDTReq->TmrActions &= ~0x70;
- // }
- // else
- // {
- // // if the pre-timeout interrupt is not configured, adjust the pre-timeout interrupt
- // // timeout value beyound the regular WDT timeout value so that it won't get triggered
- // // before the WDT timeout.
- // g_WDTTmrMgr.PreTimeOutInterval = pSetWDTReq->InitCountDown + 1;
- // }
- // _fmemcpy (&g_WDTTmrMgr.WDTTmr, pSetWDTReq, sizeof (WDTConfig_T ));
- //
- // }
- // else
- // {
- // /* Stop the timer */
- // g_WDTTmrMgr.TmrPresent = FALSE;
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning=FALSE;
- // BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent =FALSE;
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // g_WDTTmrMgr.TmrInterval= pSetWDTReq->InitCountDown;
- // g_WDTTmrMgr.PreTimeOutInterval = SEC_TO_MS * pSetWDTReq->PreTimeOutInterval;
- // // clear WDT sensor event history
- // if( g_corefeatures.internal_sensor == ENABLED)
- // RestartWD2Sensor(BMCInst);
- // }
- //
- // /* Clear the pre-timeout interupt flag */
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // pBMCInfo->WDTConfig.PreTimeoutActionTaken = 0x00;
- // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x08; /* Clear the flag */
- //#if GET_MSG_FLAGS != UNIMPLEMENTED
- // // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
- // GetMsgFlags (NULL, 0, (INT8U *)&GetMsgFlagsRes,BMCInst);
- // TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
- // GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
- // if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
- //#else
- // if((BMC_GET_SHARED_MEM(BMCInst)->MsgFlags & BIT3_BIT0_MASK) == 0)
- //#endif
- // {
- // /* Clear the SMS_ATN bit */
- // if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
- // {
- // CLEAR_SMS_ATN (0, BMCInst);
- // }
- // if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
- // {
- // CLEAR_SMS_ATN (1, BMCInst);
- // }
- // if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
- // {
- // CLEAR_SMS_ATN (2, BMCInst);
- // }
- // }
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- //
- // }
- // else
- // {
- // g_WDTTmrMgr.TmrInterval = pSetWDTReq->InitCountDown;
- // g_WDTTmrMgr.TmrPresent = FALSE;
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent =FALSE;
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // // clear WDT sensor event history
- // if( g_corefeatures.internal_sensor == ENABLED)
- // RestartWD2Sensor(BMCInst);
- // }
- //
- // // Modify ARP status to resume the thread
- // // after receiving set Watchdog Timer command
- // //BMC_GET_SHARED_MEM(BMCInst)->GratArpStatus = RESUME_ARPS;
- //
- // int i = 0;
- //
- // for (i = 0; i < MAX_LAN_CHANNELS; i++)
- // {
- // if((pBMCInfo->LanIfcConfig[i].Enabled == TRUE)
- // && (pBMCInfo->LanIfcConfig[i].Up_Status == LAN_IFC_UP))
- // {
- // BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[i] = RESUME_ARPS;
- // UpdateArpStatus(pBMCInfo->LanIfcConfig[i].Ethindex, BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning, BMCInst);
- // }
- // }
- // if(g_corefeatures.wdt_flush_support == ENABLED )
- // {
- // FlushIPMI((INT8U*)&pBMCInfo->WDTConfig,(INT8U*)&pBMCInfo->WDTConfig,pBMCInfo->IPMIConfLoc.WDTDATAddr,
- // sizeof(WDTConfig_T),BMCInst);
- // }
- // // set the "Don't Log" bit
- // g_WDTTmrMgr.WDTTmr.TmrUse &= 0x7F;
- // g_WDTTmrMgr.WDTTmr.TmrUse |= (pSetWDTReq->TmrUse & 0x80);
- //
- // g_BMCInfo[BMCInst].SetWDTUpdated = TRUE;
- // g_BMCInfo[BMCInst].Msghndlr.TmrSet = TRUE;
- // pBMCInfo->WDTPreTmtStat = FALSE;
- // *pRes = CC_NORMAL;
- //
- // return sizeof (*pRes);
- }
- /*---------------------------------------
- * GetWDT
- *---------------------------------------*/
- int
- GetWDT (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ GetWDTRes_T* pGetWDTRes = (_NEAR_ GetWDTRes_T*)pRes;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
- //
- // /* Copy the current settings from the NVRAM */
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy ((_FAR_ INT8U*)&pGetWDTRes->CurrentSettings,
- // (_FAR_ INT8U*)&pBMCInfo->WDTConfig, sizeof (WDTConfig_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- //
- // // get the WDT expiration from the global veriable in memory, not from the flash
- // pGetWDTRes->CurrentSettings.ExpirationFlag = g_WDTTmrMgr.WDTTmr.ExpirationFlag;
- //
- // // get the current "Don't Log" bit
- // pGetWDTRes->CurrentSettings.TmrUse &= 0x7F;
- // pGetWDTRes->CurrentSettings.TmrUse |= (g_WDTTmrMgr.WDTTmr.TmrUse & 0x80);
- // if (TRUE == BMC_GET_SHARED_MEM(BMCInst)->IsWDTPresent)
- // {
- // // set the WDT running bit #30235/30467
- // pGetWDTRes->CurrentSettings.TmrUse |= 0x40;
- // /* Present count down in 1/100 of second */
- // }
- // else
- // {
- // // clear the WDT running bit #30235/30467 for Timer Use (ie) WatchDog Timer status
- // pGetWDTRes->CurrentSettings.TmrUse &= ~0x40;
- // pGetWDTRes->CurrentSettings.ExpirationFlag = (pGetWDTRes->CurrentSettings.ExpirationFlag) & 0x3E;
- // }
- //
- // pGetWDTRes->PresentCountDown = g_WDTTmrMgr.TmrInterval;
- // pGetWDTRes->CurrentSettings.InitCountDown = htoipmi_u16(pGetWDTRes->CurrentSettings.InitCountDown);
- // pGetWDTRes->CompletionCode = CC_NORMAL;
- //
- // return sizeof (GetWDTRes_T);
- }
- /*---------------------------------------
- * SetBMCGlobalEnables
- *---------------------------------------*/
- int
- SetBMCGlobalEnables (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // INT8U GblEnblByte = *pReq;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
- // MsgPkt_T MsgPkt;
- //
- // _fmemset (&MsgPkt, 0, sizeof (MsgPkt_T));
- //
- // /* Check For the reserved bit 4 */
- // if ( GblEnblByte & BIT4)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
- // if (((BMC_GET_SHARED_MEM (BMCInst)->GlobalEnables ^ GblEnblByte)) & 0x20)
- // {
- // /* OEM 0 puts us in ICTS compatibility mode for IPMIv2,
- // * Send a message to lan process so it can change behavior
- // */
- // MsgPkt.Channel = GetLANChannel(0, BMCInst);
- // MsgPkt.Param = LAN_ICTS_MODE;
- // MsgPkt.Privilege = PRIV_LOCAL;
- // if (GblEnblByte & 0x20)
- // MsgPkt.Cmd = 1;
- // else
- // MsgPkt.Cmd = 0;
- // PostMsg(&MsgPkt,LAN_IFC_Q,BMCInst);
- // }
- //
- // BMC_GET_SHARED_MEM (BMCInst)->GlobalEnables = GblEnblByte;
- // *pRes = CC_NORMAL;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- return sizeof (*pRes);
- }
- /*---------------------------------------
- * GetBMCGlobalEnables
- *---------------------------------------*/
- int
- GetBMCGlobalEnables (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ GetBMCGblEnblRes_T* pGetBMCGblEnblRes = (_NEAR_ GetBMCGblEnblRes_T*)pRes;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
- // pGetBMCGblEnblRes->CompletionCode = CC_NORMAL;
- // pGetBMCGblEnblRes->BMCGblEnblByte = BMC_GET_SHARED_MEM (BMCInst)->GlobalEnables;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // return sizeof (GetBMCGblEnblRes_T);
- }
- /*---------------------------------------
- * ClrMsgFlags
- *---------------------------------------*/
- int
- ClrMsgFlags (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ ClearMsgsFlagReq_T* pClearMsgsFlagReq = (_NEAR_ ClearMsgsFlagReq_T*)pReq;
- // INT8U *kcsifcnum;
- //#if GET_MSG_FLAGS != UNIMPLEMENTED
- // GetMsgFlagsRes_T GetMsgFlagsRes;
- //#endif
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- //
- // //Check for Reserved bits
- // if(pClearMsgsFlagReq->Flag & (BIT4 | BIT2))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- //
- // OS_THREAD_TLS_GET(g_tls.CurKCSIfcNum,kcsifcnum);
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
- // /* Flush Receive Message Queue */
- // if (0 != (pClearMsgsFlagReq->Flag & 0x01))
- // {
- // while (0 == GetMsg (&m_MsgPkt, &g_RcvMsgQ[*kcsifcnum][0], WAIT_NONE,BMCInst))
- // {
- // BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum]--;
- // }
- //
- // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x01; /* Clear the flag */
- // }
- //
- // /* Flush Event Message Buffer */
- // if (0 != (pClearMsgsFlagReq->Flag & 0x02))
- // {
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->EventMutex,WAIT_INFINITE);
- // while (0 == GetMsg (&m_MsgPkt, EVT_MSG_Q, WAIT_NONE,BMCInst))
- // {
- // BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg--;
- // }
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
- // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x02; /* Clear the flag */
- // }
- //
- // /* Clear WatchdogTimer Interrupt*/
- // if (0 != (pClearMsgsFlagReq->Flag & 0x08))
- // {
- // /* Clear the pre-timeout interupt flag */
- // pBMCInfo->WDTConfig.PreTimeoutActionTaken = 0x00;
- // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x08; /* Clear the flag */
- // if(g_corefeatures.wdt_flush_support == ENABLED )
- // {
- // FlushIPMI((INT8U*)&pBMCInfo->WDTConfig,(INT8U*)&pBMCInfo->WDTConfig,pBMCInfo->IPMIConfLoc.WDTDATAddr,
- // sizeof(WDTConfig_T),BMCInst);
- // }
- //
- // }
- //
- //#if GET_MSG_FLAGS != UNIMPLEMENTED
- // // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
- // GetMsgFlags (NULL, 0, (INT8U *)&GetMsgFlagsRes,BMCInst);
- // TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
- // GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
- // if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
- //#else
- // if((BMC_GET_SHARED_MEM(BMCInst)->MsgFlags & BIT3_BIT0_MASK) == 0)
- //#endif
- // {
- // /* Clear the SMS_ATN bit */
- // if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
- // {
- // CLEAR_SMS_ATN (0, BMCInst);
- // }
- // if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
- // {
- // CLEAR_SMS_ATN (1, BMCInst);
- // }
- // if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
- // {
- // CLEAR_SMS_ATN (2, BMCInst);
- // }
- // }
- //
- // *pRes = CC_NORMAL;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- //
- // return sizeof (*pRes);
- }
- /*---------------------------------------
- GetMsgFlags
- ---------------------------------------*/
- int
- GetMsgFlags (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ GetMsgFlagsRes_T* pGetMsgFlagsRes = (_NEAR_ GetMsgFlagsRes_T*)pRes;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
- // INT8U *kcsifcnum;
- //
- // OS_THREAD_TLS_GET(g_tls.CurKCSIfcNum,kcsifcnum);
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
- // /* get the message flags */
- // pGetMsgFlagsRes->MsgFlags = BMC_GET_SHARED_MEM (BMCInst)->MsgFlags;
- //
- // if (BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg >= EVT_MSG_BUF_SIZE)
- // {
- // /* If Event MessageBuffer is Full set the BIT */
- // pGetMsgFlagsRes->MsgFlags |= 0x02;
- // }
- // else
- // {
- // /* else reset the Flag */
- // pGetMsgFlagsRes->MsgFlags &= ~0x02;
- // }
- //
- // if(kcsifcnum != NULL && 0 != BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum])
- // {
- // /* if any Message in ReceiveMsgQ set the Flag */
- // pGetMsgFlagsRes->MsgFlags |= 0x01;
- // }
- // else
- // {
- // /* else reset the Flag */
- // pGetMsgFlagsRes->MsgFlags &= ~0x01;
- // }
- //
- // /* get the Pre-Timeout Bits Value & Set it to Response Data */
- // //PRETIMEOUT BIT is 3rd bit so changed accordingly
- // pGetMsgFlagsRes->MsgFlags |= (pBMCInfo->WDTConfig.PreTimeoutActionTaken & 0x08);
- //
- // /* Update the Message flags in shared Mem */
- // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags |= pGetMsgFlagsRes->MsgFlags;
- // pGetMsgFlagsRes->CompletionCode = CC_NORMAL;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- //
- // return sizeof (GetMsgFlagsRes_T);
- }
- /*---------------------------------------
- * EnblMsgChannelRcv
- *---------------------------------------*/
- int
- EnblMsgChannelRcv (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ EnblMsgChRcvReq_T* pEnblMsgChRcvReq = (_NEAR_ EnblMsgChRcvReq_T*)pReq;
- // _NEAR_ EnblMsgChRcvRes_T* pEnblMsgChRcvRes = (_NEAR_ EnblMsgChRcvRes_T*)pRes;
- // _FAR_ ChannelInfo_T* pChannelInfo;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
- //
- // //Check for Reserved bits
- // if(pEnblMsgChRcvReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4))
- // {
- // pEnblMsgChRcvRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- //
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
- // pChannelInfo = getChannelInfo (pEnblMsgChRcvReq->ChannelNum & 0x0F, BMCInst);
- //
- // TDBG ("ENBL_MSG_CH_RCV: processing..\n");
- //
- // if (NULL == pChannelInfo)
- // {
- // pEnblMsgChRcvRes->CompletionCode = CC_INV_DATA_FIELD;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // return sizeof (*pRes);
- // }
- //
- // switch (pEnblMsgChRcvReq->ChannelState)
- // {
- // case 0:
- // /* disable Receive Message Queue for this Channel */
- // pChannelInfo->ReceiveMsgQ = 0x0;
- // break;
- //
- // case 1:
- // /*enable Recevive Message Queue for this Channel */
- // pChannelInfo->ReceiveMsgQ = 0x1;
- // break;
- //
- // case 2:
- // /*get Channel State */
- // pEnblMsgChRcvRes->ChannelState = pChannelInfo->ReceiveMsgQ;
- // break;
- //
- // default:
- // pEnblMsgChRcvRes->CompletionCode = CC_INV_DATA_FIELD;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // return sizeof (*pRes);
- // }
- //
- // pEnblMsgChRcvRes->CompletionCode = CC_NORMAL;
- //
- // /*get Channel Number */
- // pEnblMsgChRcvRes->ChannelNum = pEnblMsgChRcvReq->ChannelNum & 0x0F;
- //
- // pEnblMsgChRcvRes->ChannelState = pChannelInfo->ReceiveMsgQ;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- //
- // return sizeof (EnblMsgChRcvRes_T);
- }
- /*---------------------------------------
- * GetMessage
- *---------------------------------------*/
- int
- GetMessage (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ GetMsgRes_T* pGetMsgRes = (_NEAR_ GetMsgRes_T*)pRes;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- // INT8U Index = 0,*kcsifcnum;
- //#if GET_MSG_FLAGS != UNIMPLEMENTED
- // GetMsgFlagsRes_T GetMsgFlagsRes;
- //#endif
- //
- // OS_THREAD_TLS_GET(g_tls.CurKCSIfcNum,kcsifcnum);
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
- // if (0 != GetMsg (&m_MsgPkt, &g_RcvMsgQ[*kcsifcnum][0], WAIT_NONE,BMCInst))
- // {
- // /* if Queue is Empty */
- // pGetMsgRes->CompletionCode = CC_GET_MSG_QUEUE_EMPTY;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // return sizeof (*pRes);
- // }
- //
- // BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum]--;
- //
- //#if GET_MSG_FLAGS != UNIMPLEMENTED
- // // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
- // GetMsgFlags (NULL, 0, (INT8U *)&GetMsgFlagsRes,BMCInst);
- // TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
- // GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
- // if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
- //#else
- // if (0 == BMC_GET_SHARED_MEM (BMCInst)->NumRcvMsg[*kcsifcnum])
- //#endif
- // {
- // /* Clear the SMS_ATN bit */
- // CLEAR_SMS_ATN (*kcsifcnum,BMCInst);
- // }
- //
- // /* Completion Code */
- // pGetMsgRes->CompletionCode = CC_NORMAL;
- // /* Channel number and privilege level */
- // pGetMsgRes->ChannelNum = m_MsgPkt.Channel;
- //
- // Index = sizeof (GetMsgRes_T);
- //
- // /* First byte should be session handle */
- // if(pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)
- // {
- // if ((PRIMARY_IPMB_CHANNEL != m_MsgPkt.Channel) && (pBMCInfo->SecondaryIPMBCh != m_MsgPkt.Channel))
- // {
- // pGetMsgRes->ChannelNum |= m_MsgPkt.Privilege << 0x04;
- // pRes [Index++] = m_MsgPkt.Param;
- // }
- // }
- // else
- // {
- // if(PRIMARY_IPMB_CHANNEL != m_MsgPkt.Channel)
- // {
- // pGetMsgRes->ChannelNum |= m_MsgPkt.Privilege << 0x04;
- // pRes [Index++] = m_MsgPkt.Param;
- // }
- // }
- //
- // /* copy the Message data */
- // _fmemcpy ((_FAR_ INT8U*)&pRes[Index], &m_MsgPkt.Data[1], m_MsgPkt.Size-1);
- //
- // IPMI_DBG_PRINT ("GetMsg: Sending the following data through requested channel\n");
- // IPMI_DBG_PRINT_BUF (pRes, m_MsgPkt.Size + Index);
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- //
- // return ((m_MsgPkt.Size-1)+ Index); /*+ 2 for completion code & channel No. */
- }
- /*---------------------------------------
- * SendMessage
- *---------------------------------------*/
- int
- SendMessage (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ SendMsgReq_T* pSendMsgReq = (_NEAR_ SendMsgReq_T*)pReq;
- // _NEAR_ SendMsgRes_T* pSendMsgRes = (_NEAR_ SendMsgRes_T*)pRes;
- // _NEAR_ IPMIMsgHdr_T* pIPMIMsgHdr;
- // char QueueName[MAX_STR_LENGTH];
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- // INT8U Tracking;
- // INT8U Channel=0,resaddr=0;
- // INT8U ResLen = 1;
- // INT8U RetVal = 0;
- // INT8U Offset = 1;
- // INT8U SeqNum = pBMCInfo->SendMsgSeqNum;
- // INT8U PBTbl = PRIMARY_PB_TBL;
- // INT8U SrcSessionHndl = 0;
- // _FAR_ ChannelInfo_T* pChannelInfo;
- // int tmpBMCInst= 0;
- // MsgPkt_T ResPkt;
- // _FAR_ SessionInfo_T* pSessionInfo = NULL;
- // INT32U *CurSesID;
- // INT8U *curprivlevel,*curchannel,*kcsifcnum;
- //
- // if (ReqLen < 1)
- // {
- // *pRes = CC_REQ_INV_LEN;
- // return sizeof (*pRes);
- // }
- //
- // if(pSendMsgReq->ChNoTrackReq == 0xC0)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // /* Get the channel number */
- // Channel = pSendMsgReq->ChNoTrackReq & 0x0F;
- //
- // /* Get Tracking field */
- // Tracking = pSendMsgReq->ChNoTrackReq >> 6;
- //
- // if (Tracking == RESERVED_BITS_SENDMS)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // OS_THREAD_TLS_GET(g_tls.CurSessionID,CurSesID);
- // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
- // OS_THREAD_TLS_GET(g_tls.CurKCSIfcNum,kcsifcnum);
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
- // if(g_corefeatures.mbmc_single_nic == ENABLED
- // && g_corefeatures.ifc_specific_msg_handling != ENABLED)
- // {
- // ResLen = 0;
- // g_MBMCInfo.sbmcinst = BMCInst;
- // memset((char *)&ResPkt,0,sizeof(MsgPkt_T));
- // pIPMIMsgHdr = (IPMIMsgHdr_T*)(&pBMCInfo->LANConfig.MsgReq.Data[sizeof (IPMIMsgHdr_T) + 1]);
- // m_MsgPkt.Param = PARAM_IFC;
- // m_MsgPkt.Channel = *curchannel;
- // m_MsgPkt.NetFnLUN = pIPMIMsgHdr->NetFnLUN;
- // m_MsgPkt.Cmd = pIPMIMsgHdr->Cmd;
- // m_MsgPkt.Privilege = PRIV_ADMIN;
- // m_MsgPkt.Size = pBMCInfo->LANConfig.MsgReq.Size - sizeof (IPMIMsgHdr_T) - 2;
- // _fmemcpy (m_MsgPkt.Data, pIPMIMsgHdr, m_MsgPkt.Size);
- //
- // if(g_PDKHandle[PDK_MBMCSINGLENICSENDMSG] != NULL)
- // {
- // tmpBMCInst = ( (int (*)(INT8U,int) ) g_PDKHandle[PDK_MBMCSINGLENICSENDMSG]) ( m_MsgPkt.Data[0],BMCInst);
- // }
- //
- // if(tmpBMCInst == 0)
- // {
- // resaddr = (m_MsgPkt.Data[0] - pBMCInfo->IpmiConfig.BMCSlaveAddr) >> 1;
- // if(0 <= resaddr && resaddr < BMCInstCount && (m_MsgPkt.Data[0] - pBMCInfo->IpmiConfig.BMCSlaveAddr)%2 == 0)
- // {
- // tmpBMCInst = resaddr + 1;
- // }
- // else
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // return sizeof(*pRes);
- // }
- // }
- //
- // _fmemcpy(ResPkt.Data,pBMCInfo->LANConfig.MsgReq.Data,sizeof(IPMIMsgHdr_T));
- // ResPkt.Param = BRIDGING_REQUEST;
- // ResPkt.Cmd = pIPMIMsgHdr->Cmd;
- // ((IPMIMsgHdr_T *)ResPkt.Data)->NetFnLUN = ((pBMCInfo->LANConfig.MsgReq.NetFnLUN >> 2) +1) << 2;
- // ResPkt.Data [sizeof(IPMIMsgHdr_T)] = CC_NORMAL;
- // ResPkt.Size = sizeof (IPMIMsgHdr_T) + 1 + 1; // IPMI Header + Completion Code + Second Checksum
- // /* Calculate the Second CheckSum */
- // ResPkt.Data[ResPkt.Size - 1] = CalculateCheckSum2 (ResPkt.Data, ResPkt.Size-1);
- // if (0 != PostMsg (&ResPkt,LAN_RES_Q,BMCInst))
- // {
- // TDBG ("SendMsg: Failed to post message to interface queue\n");
- // }
- //
- // pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID,BMCInst);
- // if (NULL != pSessionInfo)
- // {
- // g_MBMCInfo.SrcSessionHndl = pSessionInfo->SessionHandle;
- // }
- // else
- // {
- // *pRes = CC_UNSPECIFIED_ERR;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // return sizeof(*pRes);
- // }
- //
- // memset(QueueName,0,sizeof(QueueName));
- // sprintf(QueueName,"%s%d",LAN_IFC_Q,BMCInst);
- // strcpy ((char *)m_MsgPkt.SrcQ,QueueName);
- //
- // /* Post the message to Message Handler */
- // if (0 != PostMsg (&m_MsgPkt,MSG_HNDLR_Q,tmpBMCInst))
- // {
- // TDBG ("SendMsg: Failed to post message to interface queue\n");
- // }
- // }
- // else
- // {
- // m_MsgPkt.Param = BRIDGING_REQUEST;
- // m_MsgPkt.Channel = Channel;
- // m_MsgPkt.Size = ReqLen - 1; /* -1 to skip channel num */
- //
- // /* Copy the message data */
- // _fmemcpy (m_MsgPkt.Data, &pReq[1], m_MsgPkt.Size);
- // /* Copy the IPMI Message header */
- // pIPMIMsgHdr = (_NEAR_ IPMIMsgHdr_T*)&m_MsgPkt.Data[Offset - 1];
- // if(ValidateIPMBChksum1((_NEAR_ INT8U*)pIPMIMsgHdr) == FALSE)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // return sizeof (*pRes);
- // }
- //
- // if(m_MsgPkt.Data[ReqLen - 2] != CalculateCheckSum2 ((_FAR_ INT8U*)pIPMIMsgHdr, ReqLen - Offset - 1))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // return sizeof (*pRes);
- // }
- //
- //#if 0
- // printf("SendMsg: ReqLen = %d, size = %ld\n",ReqLen,m_MsgPkt.Size);
- //
- // for(i = 0; i < m_MsgPkt.Size;i++)
- // printf("MsgPkt_Data %02X\n",m_MsgPkt.Data[i]);
- // printf("\n");
- //#endif
- //
- // if(pBMCInfo->IpmiConfig.LANIfcSupport == 1)
- // {
- // /* To Check the Wheather LAN Channel */
- // if (IsLANChannel(*curchannel & 0xF, BMCInst))
- // {
- // _FAR_ SessionInfo_T* pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID,BMCInst);
- //
- // if (NULL != pSessionInfo)
- // {
- // SrcSessionHndl = pSessionInfo->SessionHandle;
- // }
- //
- // TDBG ("SendMsg: To LAN Interface for reference\n");
- // // Offset++; : causes bridging issues
- // strcpy ((char *)m_MsgPkt.SrcQ, LAN_IFC_Q);
- // }
- // }
- //
- // if(pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
- // {
- // /* To Check the Wheather Serial Channel */
- // if (pBMCInfo->SERIALch != CH_NOT_USED && (*curchannel & 0xF) == pBMCInfo->SERIALch && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
- // {
- // _FAR_ SessionInfo_T* pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID,BMCInst);
- //
- // if (NULL != pSessionInfo)
- // {
- // SrcSessionHndl = pSessionInfo->SessionHandle;
- // }
- //
- // TDBG ("SendMsg: To Serial Interface for reference\n");
- // // Offset++; : causes bridging issues
- // strcpy ((char *)m_MsgPkt.SrcQ, SERIAL_IFC_Q);
- // }
- // }
- //
- // if((Channel == PRIMARY_IPMB_CHANNEL) && pBMCInfo->IpmiConfig.PrimaryIPMBSupport == 1)
- // {
- // TDBG ("SendMsg: To Primary IPMB Interface\n");
- // strcpy ((char *)m_MsgPkt.SrcQ, IPMB_PRIMARY_IFC_Q);
- // }
- // else if((pBMCInfo->SecondaryIPMBCh != CH_NOT_USED && Channel == pBMCInfo->SecondaryIPMBCh) && pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 1)
- // {
- // TDBG ("SendMsg: To SMLink IPMB Interface\n");
- // strcpy ((char *)m_MsgPkt.SrcQ, IPMB_SECONDARY_IFC_Q);
- // }
- // else if ((pBMCInfo->SERIALch != CH_NOT_USED && Channel == pBMCInfo->SERIALch) && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
- // {
- // TDBG ("SendMsg: To Serial Interface\n");
- // Offset++;
- // strcpy ((char *)m_MsgPkt.SrcQ, SERIAL_IFC_Q);
- // }
- // else if ((pBMCInfo->ICMBCh != CH_NOT_USED && Channel == pBMCInfo->ICMBCh) && pBMCInfo->IpmiConfig.ICMBIfcSupport == 1)
- // {
- // TDBG ("SendMsg: To ICMB Interface\n");
- // strcpy ((char *)m_MsgPkt.SrcQ, ICMB_IFC_Q);
- // }
- // else if(pBMCInfo->SYSCh != CH_NOT_USED && Channel == pBMCInfo->SYSCh)
- // {
- // TDBG ("SendMsg: To System Interface\n");
- // /*
- // * According to IPMI Spec v2.0.
- // * It is recommended to send CC_DEST_UNAVAILABLE
- // * completion code, if the channel is disabled for
- // * receiving messages.
- // * */
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
- // pChannelInfo = getChannelInfo(Channel,BMCInst);
- // if(NULL == pChannelInfo)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // return sizeof (*pRes);
- // }
- // if (0x0 == pChannelInfo->ReceiveMsgQ)
- // {
- // printf ("The Channel(0x%x) has been Disabled "
- // "for Receive message\n", Channel);
- // *pRes = CC_DEST_UNAVAILABLE;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // return sizeof (*pRes);
- // }
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // strcpy ((char *)m_MsgPkt.SrcQ, &g_RcvMsgQ[*kcsifcnum][0]);
- // m_MsgPkt.Param = SrcSessionHndl;
- // }
- // else
- // {
- // printf ("SendMsg: Invalid Channel\n");
- // *pRes = CC_DEST_UNAVAILABLE;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // return sizeof (*pRes);
- // }
- //
- // if( (TRUE == pBMCInfo->NMConfig.NMSupport) && (pBMCInfo->NMConfig.NMDevSlaveAddress == pIPMIMsgHdr->ResAddr) &&
- // (Channel == (NM_PRIMARY_IPMB_BUS == pBMCInfo->NMConfig.NM_IPMBBus) ? pBMCInfo->PrimaryIPMBCh : pBMCInfo->SecondaryIPMBCh) )
- // {
- // if( (pBMCInfo->RMCPLAN1Ch == *curchannel) ||
- // (pBMCInfo->RMCPLAN2Ch == *curchannel) ||
- // (pBMCInfo->RMCPLAN3Ch == *curchannel) ||
- // (pBMCInfo->RMCPLAN4Ch == *curchannel) ||
- // (pBMCInfo->SERIALch == *curchannel) )
- // {
- // OS_THREAD_TLS_GET(g_tls.CurPrivLevel,curprivlevel);
- // if(PRIV_ADMIN != *curprivlevel)
- // {
- // TDBG("Insufficient Privilege\n");
- // *pRes = CC_INSUFFIENT_PRIVILEGE;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // return sizeof(*pRes);
- // }
- // }
- // }
- //
- // if(g_PDKHandle[PDK_BEFORESENDMESSAGE] != NULL)
- // {
- // RetVal = ( (int (*)(INT8U*, INT8U, INT8U*, int) ) g_PDKHandle[PDK_BEFORESENDMESSAGE]) ( pReq, ReqLen, pRes, BMCInst);
- //
- // if(0 < RetVal)
- // {
- // return RetVal;
- // }
- // }
- //
- // if (1 == Tracking)
- // {
- // /* Response length is set to zero to make MsgHndlr skip responding to this request
- // * The Response will be handled by the ipmb interface after verifying NAK.
- // */
- // ResLen = 0;
- //
- // /* Tracking is not required if originator is System ifc */
- // if (SYS_IFC_CHANNEL == (*curchannel & 0xF))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // return sizeof (*pRes);
- // }
- //
- // PBTbl = (Channel == pBMCInfo->SecondaryIPMBCh) ? SECONDARY_PB_TBL : PRIMARY_PB_TBL ;
- //
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->PendBridgeMutex, WAIT_INFINITE);
- //
- // /* Store in the table for response tracking */
- // while(TRUE)
- // {
- // if (FALSE == m_PendingBridgedResTbl[PBTbl][SeqNum].Used)
- // {
- // m_PendingBridgedResTbl[PBTbl][SeqNum].TimeOut = pBMCInfo->IpmiConfig.SendMsgTimeout;
- // m_PendingBridgedResTbl[PBTbl][SeqNum].ChannelNum = (*curchannel & 0xF);
- // m_PendingBridgedResTbl[PBTbl][SeqNum].OriginSrc = ORIGIN_SENDMSG;
- // pBMCInfo->SendMsgSeqNum = SeqNum;
- //
- // if (1 != Offset)
- // {
- // m_PendingBridgedResTbl[PBTbl][SeqNum].DstSessionHandle = pReq[Offset]; /* Session handle */
- // }
- //
- // m_PendingBridgedResTbl[PBTbl][SeqNum].SrcSessionHandle = SrcSessionHndl;
- //
- // _fmemcpy (&m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr, pIPMIMsgHdr, sizeof (IPMIMsgHdr_T));
- //
- // /* Format the IPMI Msg Hdr */
- // if(Channel == pBMCInfo->PrimaryIPMBCh)
- // {
- // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.PrimaryIPMBAddr;
- // }
- // else if(Channel == pBMCInfo->SecondaryIPMBCh)
- // {
- // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.SecondaryIPMBAddr;
- // }
- // else
- // {
- // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
- // }
- //
- // pIPMIMsgHdr->RqSeqLUN = (pBMCInfo->SendMsgSeqNum << 2) & 0xFC; /* Seq Num and LUN =00 */
- //
- // /* Recalculate the checksum */
- // m_MsgPkt.Data[ReqLen - 2] = CalculateCheckSum2 ((_FAR_ INT8U*)pIPMIMsgHdr, ReqLen - Offset - 1);
- // if(IsLANChannel(*curchannel & 0xF, BMCInst))
- // {
- // memset(QueueName,0,sizeof(QueueName));
- // sprintf(QueueName,"%s%d",LAN_IFC_Q,BMCInst);
- // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
- // }
- // else if (pBMCInfo->SERIALch != CH_NOT_USED && (*curchannel & 0xF) == pBMCInfo->SERIALch && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
- // {
- // memset(QueueName,0,sizeof(QueueName));
- // sprintf(QueueName,"%s%d",SERIAL_IFC_Q,BMCInst);
- // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
- // }
- // else
- // {
- // if(( (*curchannel & 0xF) == PRIMARY_IPMB_CHANNEL) && (pBMCInfo->IpmiConfig.PrimaryIPMBSupport == 1 ))
- // {
- // memset(QueueName,0,sizeof(QueueName));
- // sprintf(QueueName,"%s%d",IPMB_PRIMARY_IFC_Q,BMCInst);
- // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
- // }
- // else if((pBMCInfo->SecondaryIPMBCh != CH_NOT_USED && Channel == pBMCInfo->SecondaryIPMBCh) && pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 1)
- // {
- // memset(QueueName,0,sizeof(QueueName));
- // sprintf(QueueName,"%s%d",IPMB_SECONDARY_IFC_Q,BMCInst);
- // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
- // }
- // else if ((pBMCInfo->SERIALch != CH_NOT_USED && Channel == pBMCInfo->SERIALch) && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
- // {
- // memset(QueueName,0,sizeof(QueueName));
- // sprintf(QueueName,"%s%d",SERIAL_IFC_Q,BMCInst);
- // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
- // }
- // else if((pBMCInfo->SMBUSCh != CH_NOT_USED && Channel == pBMCInfo->SMBUSCh) && pBMCInfo->IpmiConfig.SMBUSIfcSupport == 1)
- // {
- // //strcpy ((char *)m_PendingBridgedResTbl[i].DestQ, NULL);
- // }
- // else if ((pBMCInfo->ICMBCh != CH_NOT_USED && Channel == pBMCInfo->ICMBCh) && pBMCInfo->IpmiConfig.ICMBIfcSupport == 1)
- // {
- // memset(QueueName,0,sizeof(QueueName));
- // sprintf(QueueName,"%s%d",ICMB_IFC_Q,BMCInst);
- // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
- // }
- // }
- // m_PendingBridgedResTbl[PBTbl][SeqNum].Used = TRUE;
- // IPMI_DBG_PRINT_1( "SendMessage: Bridged message added index = %d.\n", SeqNum);
- //
- // break;
- // }
- // else
- // {
- // SeqNum = (SeqNum + 1) & 0x3F;
- //
- // if (SeqNum == pBMCInfo->SendMsgSeqNum)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PendBridgeMutex);
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // /* If not been added to the Pending Bridge table, an error should be reported back.
- // If not, for internal channel, the thread calling it may end up waiting! */
- // *pRes = CC_NODE_BUSY;
- // return sizeof (*pRes);
- // }
- // }
- // }
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PendBridgeMutex);
- // }
- //
- // if ((pBMCInfo->SYSCh == (*curchannel & 0xF)) && pBMCInfo->IpmiConfig.SYSIfcSupport == 0x01)
- // {
- //
- // ResLen = 0;
- // /* Format the IPMI Msg Hdr */
- // // Fill the address from Infrastrucure function instead of using PRIMARY_IPMB_ADDR/SECONDARY_IPMB_ADDR
- // if(Channel == pBMCInfo->PrimaryIPMBCh)
- // {
- // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.PrimaryIPMBAddr;
- // }
- // else if(Channel == pBMCInfo->SecondaryIPMBCh)
- // {
- // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.SecondaryIPMBAddr;
- // }
- // else
- // {
- // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
- // }
- //
- // /*Change the encapsulated request's LUN based on originating KCS interface */
- // pIPMIMsgHdr->RqSeqLUN = (pIPMIMsgHdr->RqSeqLUN & 0xFC) | (*kcsifcnum + 0x01);
- // m_MsgPkt.Data[ReqLen - 2] = CalculateCheckSum2 ((_FAR_ INT8U*)pIPMIMsgHdr, ReqLen - Offset - 1);
- // pBMCInfo->BridgeMsgKCSIfc = *kcsifcnum;
- // }
- //
- // IPMI_DBG_PRINT ("SendMsgCmd:Posting to interface");
- // IPMI_DBG_PRINT_BUF (m_MsgPkt.Data, m_MsgPkt.Size);
- //
- // m_MsgPkt.Cmd = PAYLOAD_IPMI_MSG;
- //
- // /* Post the message to interface */
- // if (0 != PostMsg (&m_MsgPkt,(INT8S *)m_MsgPkt.SrcQ, BMCInst))
- // {
- // TDBG ("SendMsg: Failed to post message to interface queue\n");
- // }
- //
- // pSendMsgRes->CompletionCode = CC_NORMAL;
- //
- // if(pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)
- // {
- // if ((PRIMARY_IPMB_CHANNEL== (*curchannel & 0xF) || pBMCInfo->SecondaryIPMBCh == (*curchannel & 0xF)) && 1 == Tracking)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // return 0;
- // }
- // }
- // else
- // {
- // if ( PRIMARY_IPMB_CHANNEL == (*curchannel & 0xF) && (1 == Tracking))
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // return 0;
- // }
- // }
- // }
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // return ResLen;
- }
- /*---------------------------------------
- * ReadEvtMsgBuffer
- *---------------------------------------*/
- int
- ReadEvtMsgBuffer (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ ReadEvtMsgBufRes_T* pReadEvtMsgBufRes = (_NEAR_ ReadEvtMsgBufRes_T*)pRes;
- //#if GET_MSG_FLAGS != UNIMPLEMENTED
- // GetMsgFlagsRes_T GetMsgFlagsRes;
- //#endif
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- //
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->EventMutex,WAIT_INFINITE);
- // if (-2 == GetMsg(&m_MsgPkt, EVT_MSG_Q, WAIT_NONE, BMCInst))
- // {
- // /*If queue is empty */
- // pReadEvtMsgBufRes->CompletionCode = CC_EVT_MSG_QUEUE_EMPTY;/* Queue is empty */
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // return sizeof (*pRes);
- // }
- //
- // if (BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg == 0)
- // {
- // pReadEvtMsgBufRes->CompletionCode = CC_EVT_MSG_QUEUE_EMPTY;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- // return sizeof (*pRes);
- // }
- //
- // BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg--;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
- //
- //#if GET_MSG_FLAGS != UNIMPLEMENTED
- // // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
- // GetMsgFlags (NULL, 0, (INT8U *)&GetMsgFlagsRes,BMCInst);
- // TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
- // GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
- // if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
- //#else
- // if (0 == BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg)
- //#endif
- // {
- // /* if there is no messssage in buffer reset SMS/EVT ATN bit */
- // // CLEAR_SMS_ATN ();
- // if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
- // {
- // CLEAR_SMS_ATN (0, BMCInst);
- // }
- // if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
- // {
- // CLEAR_SMS_ATN (1, BMCInst);
- // }
- // if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
- // {
- // CLEAR_SMS_ATN (2, BMCInst);
- // }
- // }
- //
- // /* clear EventMessageBuffer full flag */
- // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x02;
- //
- // pReadEvtMsgBufRes->CompletionCode = CC_NORMAL; /* Completion Code */
- //
- // /* copy the Message data */
- // _fmemcpy (pReadEvtMsgBufRes->ResData, m_MsgPkt.Data, m_MsgPkt.Size);
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
- //
- // return sizeof (ReadEvtMsgBufRes_T);
- }
- /*---------------------------------------
- * GetBTIfcCap
- *---------------------------------------*/
- int
- GetBTIfcCap (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- _NEAR_ GetBTIfcCapRes_T* pGetBTIfcCapRes = (_NEAR_ GetBTIfcCapRes_T*)pRes;
- pGetBTIfcCapRes->CompletionCode = CC_NORMAL;
- pGetBTIfcCapRes->NumReqSupported = 2;
- pGetBTIfcCapRes->InputBufSize = MAX_BT_PKT_LEN;
- pGetBTIfcCapRes->OutputBufSize = MAX_BT_PKT_LEN;
- pGetBTIfcCapRes->RespTime = 1;
- pGetBTIfcCapRes->Retries = 0;
- return sizeof (GetBTIfcCapRes_T);
- }
- /*---------------------------------------
- * GetSystemGUID
- *---------------------------------------*/
- int
- GetSystemGUID (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- //_NEAR_ GetSysGUIDRes_T* pGetSysGUIDRes = (_NEAR_ GetSysGUIDRes_T*)pRes;
- //pGetSysGUIDRes->CompletionCode = CC_NORMAL;
- //LOCK_BMC_SHARED_MEM (BMCInst);
- //_fmemcpy (&pGetSysGUIDRes->Node, BMC_GET_SHARED_MEM (BMCInst)->SystemGUID, 16);
- //UNLOCK_BMC_SHARED_MEM (BMCInst);
- //return sizeof (GetSysGUIDRes_T);
- }
- #define SUPPORT_IPMI20 0x02
- #define SUPPORT_IPMI15 0x01
- /*---------------------------------------
- * GetChAuthCap
- *---------------------------------------*/
- int
- GetChAuthCap (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // printf("start GetChAuthCap\n");
- _NEAR_ GetChAuthCapReq_T* pGetChAuthCapReq = (_NEAR_ GetChAuthCapReq_T*)pReq;
- _NEAR_ GetChAuthCapRes_T* pGetChAuthCapRes = (_NEAR_ GetChAuthCapRes_T*)pRes;
- memset (pGetChAuthCapRes, 0, sizeof (GetChAuthCapRes_T));
-
- pGetChAuthCapRes->CompletionCode=0x00;
- pGetChAuthCapRes->ChannelNum=0x01;
- pGetChAuthCapRes->AuthType=0x36;
- pGetChAuthCapRes->PerMsgUserAuthLoginStatus=0x04;
- SessionSequenceNumberCount=0;
- return sizeof(GetChAuthCapRes_T);
- }
- /*---------------------------------------
- * GetSessionChallenge
- *---------------------------------------*/
- int
- GetSessionChallenge (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // printf("start GetSessionChallenge\n");
- _NEAR_ GetSesChallengeReq_T* pGetSesChalReq = (_NEAR_ GetSesChallengeReq_T*)pReq;
- _NEAR_ GetSesChallengeRes_T* pGetSesChalRes = (_NEAR_ GetSesChallengeRes_T*)pRes;
- INT32U TemId=0xffb52dfb;//0xfb2db5ff
-
- memset (pGetSesChalRes, 0, sizeof (GetSesChallengeRes_T));
-
- pGetSesChalRes->CompletionCode=0x00;
- pGetSesChalRes->TempSessionID=TemId;
- pGetSesChalRes->ChallengeString[0]=0x54;
- pGetSesChalRes->ChallengeString[1]=0xdf;
- pGetSesChalRes->ChallengeString[2]=0xe1;
- pGetSesChalRes->ChallengeString[3]=0xbf;
- pGetSesChalRes->ChallengeString[4]=0x56;
- pGetSesChalRes->ChallengeString[5]=0x47;
- pGetSesChalRes->ChallengeString[6]=0x87;
- pGetSesChalRes->ChallengeString[7]=0x88;
- pGetSesChalRes->ChallengeString[8]=0xea;
- pGetSesChalRes->ChallengeString[9]=0x7b;
- pGetSesChalRes->ChallengeString[10]=0xa1;
- pGetSesChalRes->ChallengeString[11]=0x54;
- pGetSesChalRes->ChallengeString[12]=0x37;
- pGetSesChalRes->ChallengeString[13]=0x5b;
- pGetSesChalRes->ChallengeString[14]=0x79;
- pGetSesChalRes->ChallengeString[15]=0xe3;
- // SessionSequenceNumberCount=SessionSequenceNumberCount+1;
- return sizeof (GetSesChallengeRes_T);
- }
- /*---------------------------------------
- * ActivateSession
- *---------------------------------------*/
- int
- ActivateSession (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // printf("start ActivateSession:\n");
- _NEAR_ ActivateSesReq_T* pAcvtSesReq = (_NEAR_ ActivateSesReq_T*)pReq;
- _NEAR_ ActivateSesRes_T* pAcvtSesRes = (_NEAR_ ActivateSesRes_T*)pRes;
- INT32U SesId=0xffb52dfb;//0xfb2db5ff;
- INT32U InbSeq=0x2ae8944a;//0x4a94e82a;
-
- memset (pAcvtSesRes, 0, sizeof (ActivateSesRes_T));
-
- pAcvtSesRes->CompletionCode=0x00;
- pAcvtSesRes->AuthType=0x02;
- pAcvtSesRes->SessionID=SesId;
- pAcvtSesRes->InboundSeq=InbSeq;
- pAcvtSesRes->Privilege=0x04;
- SessionSequenceNumberCount=SessionSequenceNumberCount+1;
- return sizeof (ActivateSesRes_T);
-
- }
- /*---------------------------------------
- * SetSessionPrivLevel
- *---------------------------------------*/
- int
- SetSessionPrivLevel (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- _NEAR_ SetSesPrivLevelReq_T* pSetSesPrivLevelReq = (_NEAR_ SetSesPrivLevelReq_T*)pReq;
- _NEAR_ SetSesPrivLevelRes_T* pSetSesPrivLevelRes = (_NEAR_ SetSesPrivLevelRes_T*)pRes;
-
- memset (pSetSesPrivLevelRes, 0, sizeof (SetSesPrivLevelRes_T));
- pSetSesPrivLevelRes->CompletionCode=0x00;
- pSetSesPrivLevelRes->Privilege=0x04;
- SessionSequenceNumberCount=SessionSequenceNumberCount+1;
- return sizeof (SetSesPrivLevelRes_T);
- }
- /*---------------------------------------
- * CloseSession
- *---------------------------------------*/
- int
- CloseSession (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- SessionSequenceNumberCount=SessionSequenceNumberCount+1;
- return sizeof (*pRes);
- }
- //#if GET_SESSION_INFO != UNIMPLEMENTED
- /*---------------------------------------
- * GetSessionInfo
- *---------------------------------------*/
- int
- GetSessionInfo (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ GetSesInfoReq_T* pGetSesInfoReq = (_NEAR_ GetSesInfoReq_T*)pReq;
- // _NEAR_ GetSesInfoRes_T* pGetSesInfoRes = (_NEAR_ GetSesInfoRes_T*)pRes;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- // LANSesInfoRes_T LANSesInfo;
- // LANIPv6SesInfoRes_T LANIPv6SesInfo;
- // _FAR_ SessionInfo_T* pSessInfo;
- // _FAR_ ChannelInfo_T* pChannelInfo;
- // _FAR_ void* SessionArg;
- // INT8U SessionArgAlign[4];
- // INT8U SessionArgType,EthIndex, netindex = 0xFF;
- // char IfcName[IFNAMSIZ];
- // INT32U *CurSesID,*curchannel;
- // int i;
- //
- // *pRes = CC_REQ_INV_LEN;
- //
- // switch (pGetSesInfoReq->SessionIndex)
- // {
- // case 0:
- // /* Get session information for this session */
- // if (1 != ReqLen)
- // {
- // return sizeof (*pRes);
- // }
- // SessionArgType = SESSION_ID_INFO;
- // OS_THREAD_TLS_GET(g_tls.CurSessionID,CurSesID);
- // SessionArg = CurSesID;
- // break;
- //
- // case 0xFF:
- // if (5 != ReqLen)
- // {
- // return sizeof (*pRes);
- // }
- // SessionArgType = SESSION_ID_INFO;
- //
- // SessionArgAlign[0] = pGetSesInfoReq->SessionHandleOrID[0];
- // SessionArgAlign[1] = pGetSesInfoReq->SessionHandleOrID[1];
- // SessionArgAlign[2] = pGetSesInfoReq->SessionHandleOrID[2];
- // SessionArgAlign[3] = pGetSesInfoReq->SessionHandleOrID[3];
- // SessionArg = SessionArgAlign;
- // break;
- //
- // case 0xFE:
- // if (2 != ReqLen)
- // {
- // return sizeof (*pRes);
- // }
- // if (pGetSesInfoReq->SessionHandleOrID[0] == 0)
- // {
- // *pRes=CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // SessionArgType = SESSION_HANDLE_INFO;
- // SessionArgAlign[0] = pGetSesInfoReq->SessionHandleOrID[0];
- // SessionArgAlign[1] = pGetSesInfoReq->SessionHandleOrID[1];
- // SessionArgAlign[2] = pGetSesInfoReq->SessionHandleOrID[2];
- // SessionArgAlign[3] = pGetSesInfoReq->SessionHandleOrID[3];
- // SessionArg = SessionArgAlign;
- // break;
- //
- // default:
- // if (1 != ReqLen)
- // {
- // return sizeof (*pRes);
- // }
- // SessionArgType = SESSION_INDEX_INFO;
- // SessionArg = &pGetSesInfoReq->SessionIndex;
- // break;
- // }
- //
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SessionTblMutex, WAIT_INFINITE);
- // pSessInfo = getSessionInfo (SessionArgType, SessionArg, BMCInst);
- // if (NULL == pSessInfo)
- // {
- // TDBG ("GetSessionInfo: pSessInfo is NULL\n");
- // /* if there is no active channel for the current session Index
- // * return the following bytes
- // */
- //
- // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
- // pChannelInfo = getChannelInfo (*curchannel & 0xF, BMCInst);
- // if(NULL == pChannelInfo)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
- // pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // pGetSesInfoRes->CompletionCode = CC_NORMAL;
- // pGetSesInfoRes->SessionHandle = BMC_GET_SHARED_MEM (BMCInst)->SessionHandle;
- // pGetSesInfoRes->NumPossibleActiveSession= pBMCInfo->IpmiConfig.MaxSession;
- // pGetSesInfoRes->NumActiveSession = GetNumOfActiveSessions (BMCInst);
- //
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
- // return (sizeof (GetSesInfoRes_T) - sizeof (ActiveSesInfo_T) - sizeof (SessionInfoRes_T));
- // }
- //
- // memset (pGetSesInfoRes,0,sizeof(GetSesInfoRes_T));
- // pChannelInfo = getChannelInfo (pSessInfo->Channel, BMCInst);
- // if(NULL == pChannelInfo)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
- // pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // pGetSesInfoRes->CompletionCode = CC_NORMAL;
- // pGetSesInfoRes->SessionHandle = pSessInfo->SessionHandle;
- // pGetSesInfoRes->NumPossibleActiveSession = pBMCInfo->IpmiConfig.MaxSession;
- // pGetSesInfoRes->NumActiveSession = GetNumOfActiveSessions (BMCInst);
- // pGetSesInfoRes->ActiveSesinfo.UserID = pSessInfo->UserId & 0x3F;
- // pGetSesInfoRes->ActiveSesinfo.Privilege = pSessInfo->Privilege & 0x0F;
- // /* Set protocol bit as per Auth Type, bit4 must be 1 for IPMIv2.0 RMCP, 0 for IPMIv1.5 */
- // if( AUTHTYPE_RMCP_PLUS_FORMAT == pSessInfo->AuthType )
- // {
- // pGetSesInfoRes->ActiveSesinfo.ChannelNum = (pSessInfo->Channel & 0x0F) | 0x10;
- // }else
- // {
- // pGetSesInfoRes->ActiveSesinfo.ChannelNum = pSessInfo->Channel & 0x0F;
- // }
- // EthIndex= GetEthIndex(pSessInfo->Channel & 0x0F, BMCInst);
- // if(0xff == EthIndex)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
- // *pRes = CC_INV_DATA_FIELD;
- // DeleteSession (pSessInfo,BMCInst);
- // return sizeof (INT8U);
- // }
- // memset(IfcName,0,sizeof(IfcName));
- // /*Get the EthIndex*/
- // if(GetIfcName(EthIndex,IfcName, BMCInst) == -1)
- // {
- // TCRIT("Error in Getting Ifc name\n");
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (INT8U);
- // }
- //
- // for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
- // {
- // if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
- // {
- // netindex= Ifcnametable[i].Index;
- // break;
- // }
- // }
- //
- // if(netindex == 0xFF)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (INT8U);
- // }
- // if (IsLANChannel( pSessInfo->Channel, BMCInst))
- // {
- // if(g_corefeatures.global_ipv6 == ENABLED)
- // {
- // if(GetIPAdrressType(&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[0])==4)
- // {
- // memset(&LANSesInfo,0,sizeof(LANSesInfo));
- // /* IP Address */
- // _fmemcpy (&(LANSesInfo.IPAddress),
- // &pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[sizeof(struct in6_addr)-sizeof(struct in_addr)],
- // sizeof(struct in_addr));
- // /* MAC Address */
- // if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
- // nwGetSrcCacheMacAddr((INT8U*)&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[12],
- // netindex, pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
- //
- // _fmemcpy(LANSesInfo.MACAddress, pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
- // /* Port number */
- // LANSesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
- //
- // _fmemcpy ((pRes+sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)),&LANSesInfo, sizeof (LANSesInfoRes_T));
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
- // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)+sizeof (LANSesInfoRes_T));
- // }
- // else
- // {
- // /* IP Address */
- // memset(&LANIPv6SesInfo,0,sizeof(LANIPv6SesInfo));
- // _fmemcpy (&(LANIPv6SesInfo.IPv6Address),
- // pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr,
- // sizeof(struct in6_addr));
- // /* MAC Address */
- // if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
- // nwGetSrcMacAddr_IPV6((INT8U*)&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr,
- // pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
- //
- // _fmemcpy(LANIPv6SesInfo.MACAddress, pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
- // /* Port number */
- // LANIPv6SesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
- //
- // _fmemcpy ((pRes+sizeof (GetSesInfoRes_T) - sizeof(SessionInfoRes_T)),&LANIPv6SesInfo, sizeof (LANIPv6SesInfoRes_T));
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
- // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)+sizeof (LANIPv6SesInfoRes_T));
- // }
- // }
- // else
- // {
- //
- // /* IP Address */
- // _fmemcpy (pGetSesInfoRes->SesInfo.LANSesInfo.IPAddress,
- // pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr,
- // sizeof (pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr));
- // /* MAC Address */
- // if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
- // nwGetSrcCacheMacAddr((INT8U*)pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr, netindex,
- // pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
- // _fmemcpy(pGetSesInfoRes->SesInfo.LANSesInfo.MACAddress,
- // pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
- // /* Port number */
- // pGetSesInfoRes->SesInfo.LANSesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
- // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T) + sizeof (LANSesInfoRes_T));
- // }
- // }
- // else if (pBMCInfo->IpmiConfig.SerialIfcSupport == 1 && pBMCInfo->SERIALch== pSessInfo->Channel)
- // {
- //
- // pChannelInfo = getChannelInfo (pBMCInfo->SERIALch, BMCInst);
- // if(NULL == pChannelInfo)
- // {
- // pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
- // return sizeof (*pRes);
- // }
- //
- // pGetSesInfoRes->SesInfo.SerialSesInfo.SessionActivityType = 0;
- // pGetSesInfoRes->SesInfo.SerialSesInfo.DestinationSelector = 0;
- //
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
- // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T) + sizeof (SerialSesInfoRes_T));
- // }
- // else
- // {
- // pChannelInfo = getChannelInfo(pSessInfo->Channel, BMCInst);
- // if(NULL == pChannelInfo)
- // {
- // pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
- // return sizeof (*pRes);
- // }
- //
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
- // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T));
- // }
- }
- //#endif
- /**
- * @fn GetAuthCodeForTypeV15
- * @brief This function will use the encryption technique supported
- * in IPMI V1.5 in order to produce Auth Code.
- * @param[in] pUserInfo - Pointer to User info structure.
- * @param[in] pGetAuthCodeReq - Pointer to the structure of request data
- * @param[out] pGetAuthCodeRes - Pointer to the resultant data.
- * @retval size of the result data.
- */
- static int
- GetAuthCodeForTypeV15 (UserInfo_T* pUserInfo,
- GetAuthCodeReq_T* pGetAuthCodeReq,
- GetAuthCodeRes_T* pGetAuthCodeRes,int BMCInst)
- {
- // INT8U AuthCode;
- // INT8U InBuffer[2*IPMI15_MAX_PASSWORD_LEN + HASH_DATA_LENGTH];
- // char UserPswd[MAX_PASSWD_LEN];
- // INT8U PwdEncKey[MAX_SIZE_KEY + 1] = {0};
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- //
- // memset(&(pGetAuthCodeRes->AuthCode), 0, AUTH_CODE_HASH_LEN);
- // AuthCode = pGetAuthCodeReq->AuthType & AUTH_CODE_V15_MASK;
- // if((pGetAuthCodeReq->AuthType & (BIT5 | BIT4)) ||
- // (AuthCode == AUTHTYPE_RESERVED) || (AuthCode == AUTHTYPE_NONE) ||
- // (AuthCode == AUTHTYPE_STRAIGHT_PASSWORD) ||
- // (AuthCode > AUTHTYPE_OEM_PROPRIETARY))
- // {
- // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
- // return (sizeof (GetAuthCodeRes_T) - 4);
- // }
- //
- // if (g_corefeatures.userpswd_encryption == ENABLED)
- // {
- // /* Get Encryption Key from the MBMCInfo_t structure */
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- //
- // if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[pUserInfo->UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
- // {
- // TCRIT("Error in decrypting the IPMI User password for User ID:%d.\n", pUserInfo->UserId);
- // pGetAuthCodeRes->CompletionCode = CC_UNSPECIFIED_ERR;
- // return sizeof(*pGetAuthCodeRes);
- // }
- // memcpy(&InBuffer[0],UserPswd,IPMI15_MAX_PASSWORD_LEN);
- // }
- // else
- // {
- // memcpy(&InBuffer[0],pUserInfo->UserPassword,IPMI15_MAX_PASSWORD_LEN);
- // }
- //
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // switch (AuthCode)
- // {
- // #if 0 // As per IPMIv2 Markup E4, Straight Password key is Reserved
- // case AUTH_TYPE_PASSWORD: /* Straight password */
- // if (0 == _fmemcmp (pUserInfo->UserPassword,pGetAuthCodeReq->HashData,IPMI15_MAX_PASSWORD_LEN))
- // {
- // _fmemcpy (pGetAuthCodeRes->AuthCode, "OK", 2);
- // }
- // else
- // {
- // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
- // }
- // break;
- // #endif
- //
- // case AUTH_TYPE_MD2: /* MD2 */
- // _fmemcpy (&InBuffer[IPMI15_MAX_PASSWORD_LEN],
- // pGetAuthCodeReq->HashData, HASH_DATA_LENGTH);
- // if (g_corefeatures.userpswd_encryption == ENABLED)
- // {
- // _fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
- // UserPswd, IPMI15_MAX_PASSWORD_LEN);
- // }
- // else
- // {
- // _fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
- // pUserInfo->UserPassword, IPMI15_MAX_PASSWORD_LEN);
- // }
- //
- // AuthCodeCalMD2 (InBuffer, pGetAuthCodeRes->AuthCode, sizeof (InBuffer));
- // break;
- //
- // case AUTH_TYPE_MD5: /* MD5 */
- // _fmemcpy (&InBuffer[IPMI15_MAX_PASSWORD_LEN],
- // pGetAuthCodeReq->HashData, HASH_DATA_LENGTH);
- // if (g_corefeatures.userpswd_encryption == ENABLED)
- // {
- // _fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
- // UserPswd,IPMI15_MAX_PASSWORD_LEN);
- // }
- // else
- // {
- // _fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
- // pUserInfo->UserPassword,IPMI15_MAX_PASSWORD_LEN);
- // }
- // AuthCodeCalMD5 (InBuffer, pGetAuthCodeRes->AuthCode, sizeof (InBuffer));
- // break;
- //
- // default:
- // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
- // }
- //
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // // IPMI V1.5 AuthCode is only 16 byte.
- // return (sizeof (GetAuthCodeRes_T) - 4);
- }
- /**
- * @fn GetAuthCodeForTypeV20
- * @brief This function will use the encryption technique supported
- * in IPMI V2.0 in order to produce Auth Code.
- * @param[in] pUserInfo - Pointer to User info structure.
- * @param[in] pGetAuthCodeReq - Pointer to the structure of request data
- * @param[out] pGetAuthCodeRes - Pointer to the resultant data.
- * @retval size of the result data.
- */
- static int
- GetAuthCodeForTypeV20 (UserInfo_T* pUserInfo,
- GetAuthCodeReq_T* pGetAuthCodeReq,
- GetAuthCodeRes_T* pGetAuthCodeRes,int BMCInst)
- {
- // INT8U AuthCode;
- // INT8U UserPasswdLen=0;
- // INT8U DecVal = 0;
- // _FAR_ INT8U m_SIK [SESSION_INTEGRITY_KEY_SIZE];
- // char UserPswd[MAX_PASSWD_LEN];
- // unsigned char PwdEncKey[MAX_SIZE_KEY + 1] = {0};
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- //
- // if (g_corefeatures.userpswd_encryption == ENABLED)
- // {
- // /* Get Encryption Key from the MBMCInfo_t structure */
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- //
- // if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[pUserInfo->UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
- // {
- // TCRIT("\nError in decrypting the IPMI User password for user with ID:%d.\n", pUserInfo->UserId);
- // pGetAuthCodeRes->CompletionCode = CC_UNSPECIFIED_ERR;
- // return sizeof (*pGetAuthCodeRes);
- // }
- // }
- // else
- // {
- // memcpy(&UserPswd, pUserInfo->UserPassword, MAX_PASSWD_LEN);
- // }
- //
- // /* Calculate password length */
- // UserPasswdLen = _fstrlen ((_FAR_ char*)UserPswd);
- // UserPasswdLen = (UserPasswdLen > MAX_PASSWORD_LEN) ?
- // MAX_PASSWORD_LEN : UserPasswdLen;
- //
- // memset(&(pGetAuthCodeRes->AuthCode), 0, AUTH_CODE_HASH_LEN);
- // AuthCode = pGetAuthCodeReq->AuthType & AUTH_CODE_V20_MASK;
- // /* Validate the Auth Code */
- // if ((AuthCode > MIN_AUTH_CODE_V20) && (AuthCode < MAX_AUTH_CODE_V20))
- // {
- // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(GetAuthCodeRes_T);
- // }
- //
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // switch(AuthCode)
- // {
- // case AUTH_NONE: /* none */
- // TDBG ("\nInside AUTH_NONE in GetAuthCode");
- // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
- // break;
- //
- // case AUTH_HMAC_SHA1_96: /* HMAC-SHA1-96 */
- // TDBG ("\nInside AUTH_HMAC_SHA1_96 in GetAuthCode");
- // hmac_sha1 ((INT8U *)UserPswd, UserPasswdLen,
- // (INT8U *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
- // (INT8U *)m_SIK, SESSION_INTEGRITY_KEY_SIZE);
- //
- // hmac_sha1 ((INT8U *)m_SIK, SESSION_INTEGRITY_KEY_SIZE,
- // (INT8U *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
- // (INT8U *)&(pGetAuthCodeRes->AuthCode), HMAC_SHA1_96_LEN);
- //
- // DecVal = AUTH_CODE_HASH_LEN - HMAC_SHA1_96_LEN;
- // break;
- //
- // case AUTH_HMAC_MD5_128: /* HMAC-MD5-128 */
- // TDBG ("\nInside AUTH_HMAC_MD5_128 in GetAuthCode");
- // hmac_md5 ((unsigned char*)UserPswd, UserPasswdLen,
- // pGetAuthCodeReq->HashData, HASH_DATA_LEN,
- // m_SIK, SESSION_HMAC_MD5_I_KEY_SIZE);
- //
- // hmac_md5 (m_SIK, SESSION_HMAC_MD5_I_KEY_SIZE,
- // pGetAuthCodeReq->HashData, HASH_DATA_LEN,
- // (unsigned char *)&(pGetAuthCodeRes->AuthCode),
- // SESSION_HMAC_MD5_I_KEY_SIZE);
- // DecVal = AUTH_CODE_HASH_LEN - SESSION_HMAC_MD5_I_KEY_SIZE;
- // break;
- //
- // case AUTH_MD5_128: /* MD5-128 */
- // TDBG ("\nInside AUTH_MD5_128 in GetAuthCode");
- // MD5_128 ((char *)UserPswd, UserPasswdLen,
- // (char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
- // (char *)m_SIK, SESSION_MD5_KEY_SIZE);
- //
- // MD5_128 ((char *)m_SIK, SESSION_INTEGRITY_KEY_SIZE,
- // (char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
- // (char *)&(pGetAuthCodeRes->AuthCode), SESSION_MD5_KEY_SIZE);
- // DecVal = AUTH_CODE_HASH_LEN - SESSION_MD5_KEY_SIZE;
- // break;
- //
- // case AUTH_HMAC_SHA256_128: /* HMAC-SHA256-128 */
- // TDBG ("\nInside AUTH_HMAC_SHA256_128 in GetAuthCode");
- // hmac_sha256 ((unsigned char *)UserPswd, UserPasswdLen,
- // (unsigned char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
- // (unsigned char *)m_SIK, SHA2_HASH_KEY_SIZE);
- //
- // hmac_sha256 (m_SIK, SHA2_HASH_KEY_SIZE,
- // (unsigned char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
- // (unsigned char *)&(pGetAuthCodeRes->AuthCode), HMAC_SHA256_128_LEN);
- // DecVal = AUTH_CODE_HASH_LEN - HMAC_SHA256_128_LEN;
- // break;
- //
- // //! TODO: Need support in openssl.
- // default: /* OEM or Reserved */
- // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
- // }
- //
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // if (DecVal > sizeof(GetAuthCodeRes_T))
- // return sizeof(GetAuthCodeRes_T);
- // else
- // return (sizeof(GetAuthCodeRes_T) - DecVal);
- }
- /**
- * @fn GetAuthCode
- * @brief This function will encrypt the given 16 byte data with
- * the algorithm given and return Auth Code.
- * @param[in] pReq - Request data.
- * @param[in] ReqLen - Length of the request data.
- * @param[out] pRes - Result data
- * @retval size of the result data.
- */
- int
- GetAuthCode (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,int BMCInst)
- {
- _NEAR_ GetAuthCodeReq_T* pGetAuthCodeReq = (_NEAR_ GetAuthCodeReq_T*)pReq;
- _NEAR_ GetAuthCodeRes_T* pGetAuthCodeRes = (_NEAR_ GetAuthCodeRes_T*)pRes;
- BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
- _FAR_ UserInfo_T* pUserInfo;
- INT8U AuthType,*curchannel;
- _FAR_ ChannelInfo_T* pChannelInfo;
- int nRetSize = 0;
- // printf("start GetAuthCode\n");
- /* Check for Reserved Bits */
- if((pGetAuthCodeReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4)) ||
- (pGetAuthCodeReq->UserID & (BIT7 | BIT6)))
- {
- pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
- return sizeof(*pRes);
- }
- //OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
- /* Validate the channel number given */
- if (CURRENT_CHANNEL_NUM == pGetAuthCodeReq->ChannelNum)
- {
- OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
- pChannelInfo = getChannelInfo(*curchannel & 0xF,BMCInst);
- }
- else
- pChannelInfo = getChannelInfo(pGetAuthCodeReq->ChannelNum,BMCInst);
- if (NULL == pChannelInfo)
- {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- *pRes = CC_INV_DATA_FIELD;
- return sizeof(*pRes);
- }
- /* Get the user information for the given userID */
- pUserInfo = getUserIdInfo (pGetAuthCodeReq->UserID,BMCInst);
- if (NULL == pUserInfo)
- {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- TDBG ("AppDevice.c : GetAuthCode - Invalid user Id\n");
- pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
- return sizeof (*pRes);
- }
- AuthType = pGetAuthCodeReq->AuthType & GET_AUTH_TYPE_MASK;
- pGetAuthCodeRes->CompletionCode = CC_NORMAL;
- switch(AuthType)
- {
- case AUTH_TYPE_V15: /* IPMI v1.5 AuthCode Algorithms */
- nRetSize = GetAuthCodeForTypeV15(pUserInfo, pGetAuthCodeReq, pGetAuthCodeRes,BMCInst);
- break;
- case AUTH_TYPE_V20: /* IPMI v2.0/RMCP+ Algorithm Number */
- nRetSize = GetAuthCodeForTypeV20(pUserInfo, pGetAuthCodeReq, pGetAuthCodeRes,BMCInst);
- break;
- default:
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
- return sizeof(*pRes);
- }
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- return nRetSize;
- }
- /*---------------------------------------
- * SetChAccess
- *---------------------------------------*/
- int
- SetChAccess (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ SetChAccessReq_T* pSetChAccessReq = (_NEAR_ SetChAccessReq_T*)pReq;
- // INT8U ChannelNum, AccessMode;
- // _FAR_ ChannelInfo_T* pNvrChInfo;
- // _FAR_ ChannelInfo_T* pChannelInfo;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- // INT8U AccessFlags = 0,i=0,*curchannel;
- //// char ChFilename[MAX_CHFILE_NAME];
- //
- // /* Reserve Bit Checking for Set Channel Acces */
- // for(i=0;i<ReqLen;i++)
- // {
- // if( 0 != (pReq[i] & m_Set_ChReserveBit[i]))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // }
- // /* Reserve Value checking */
- //
- // if((pReq[1] & 0xC0)== 0xC0 || (pReq[2] & 0xC0) == 0xC0)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // ChannelNum = pSetChAccessReq->ChannelNum & 0x0F;
- // if (CURRENT_CHANNEL_NUM == ChannelNum)
- // {
- // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
- // ChannelNum = *curchannel & 0xF;
- // }
- //
- // if (((GetBits (pSetChAccessReq->Privilege, 0x0F)) < PRIV_LEVEL_CALLBACK) ||
- // ((GetBits (pSetChAccessReq->Privilege, 0x0F)) > PRIV_LEVEL_PROPRIETARY))
- // {
- // IPMI_DBG_PRINT_1 ("Invalid Channel Privilege = 0x%x\n", pSetChAccessReq->Privilege);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
- // pChannelInfo = getChannelInfo(ChannelNum, BMCInst);
- // if (NULL == pChannelInfo)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // /*point to NVRAM ChannelInfo */
- // pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
- //
- // if (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // /* Channel is sessionless channel this command is not supported */
- // *pRes = CC_SET_CH_COMMAND_NOT_SUPPORTED;
- // return sizeof (*pRes);
- // }
- //
- //
- // AccessMode = pSetChAccessReq->ChannelAccess & 0x07;
- // if(ChannelNum == pBMCInfo->SERIALch)
- // {
- // if( NULL != g_PDKHandle[PDK_SWITCHMUX])
- // {
- // ((void(*)(INT8U, int))(g_PDKHandle[PDK_SWITCHMUX]))(AccessMode ,BMCInst);
- // }
- // }
- //
- // /* if the requested access mode is supported for the given channel */
- // if (0 == (pChannelInfo->AccessModeSupported & (1 << AccessMode)))
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_SET_CH_ACCES_MODE_NOT_SUPPORTED;
- // return sizeof (*pRes);
- // }
- //
- // AccessFlags = GetBits (pSetChAccessReq->ChannelAccess, 0xC0);
- //
- // switch (AccessFlags)
- // {
- // case 0:
- // /* dont set channel access */
- // break;
- //
- // case 1:
- // /*set in Non volatile Memory and in voatile Memory */
- // pNvrChInfo->Alerting = GetBits (pSetChAccessReq->ChannelAccess , 0x20);
- // pNvrChInfo->PerMessageAuth = GetBits (pSetChAccessReq->ChannelAccess , 0x10);
- // pNvrChInfo->UserLevelAuth = GetBits (pSetChAccessReq->ChannelAccess , 0x08);
- // pNvrChInfo->AccessMode = AccessMode;
- // /* write to NVRAM */
- // FlushChConfigs((INT8U*)pNvrChInfo,pNvrChInfo->ChannelNumber,BMCInst);
- // pChannelInfo->Alerting = pNvrChInfo->Alerting;
- // pChannelInfo->PerMessageAuth= pNvrChInfo->PerMessageAuth;
- // pChannelInfo->UserLevelAuth = pNvrChInfo->UserLevelAuth;
- // pChannelInfo->AccessMode = AccessMode;
- // break;
- //
- // case 2:
- // /*set in volatile Memmory only */
- // pChannelInfo->Alerting = GetBits (pSetChAccessReq->ChannelAccess, 0x20);
- // pChannelInfo->PerMessageAuth= GetBits (pSetChAccessReq->ChannelAccess, 0x10);
- // pChannelInfo->UserLevelAuth = GetBits (pSetChAccessReq->ChannelAccess, 0x08);
- // pChannelInfo->AccessMode = AccessMode;
- // }
- //
- // switch (GetBits (pSetChAccessReq->Privilege, 0xC0))
- // {
- // case 0:
- // /* dont set prilivege level */
- // break;
- //
- // case 1:
- // /* set in non volatile mem and volatile memeory*/ /*set privilege*/
- // pNvrChInfo->MaxPrivilege = GetBits (pSetChAccessReq->Privilege, 0x0F);
- // pChannelInfo->MaxPrivilege = pNvrChInfo->MaxPrivilege;
- // break;
- //
- // case 2:
- // /*set privilege*/
- // /* set in volatile memeory only */
- // pChannelInfo->MaxPrivilege = GetBits (pSetChAccessReq->Privilege, 0x0F);
- // }
- //
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_NORMAL;
- //
- // return sizeof (*pRes);
- }
- /*---------------------------------------
- * GetChAccess
- *---------------------------------------*/
- int
- GetChAccess (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ GetChAccessReq_T* pGetChAccessReq = (_NEAR_ GetChAccessReq_T*)pReq;
- // _NEAR_ GetChAccessRes_T* pGetChAccessRes = (_NEAR_ GetChAccessRes_T*)pRes;
- // _FAR_ ChannelInfo_T* pChannelInfo;
- // _FAR_ ChannelInfo_T* pNvrChInfo;
- // INT8U ChannelNum,AccessFlag,*curchannel;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
- //
- // /* Check for reserved bits */
- // if((0 != (pGetChAccessReq->ChannelNum & 0xf0)) ||
- // (0 != (pGetChAccessReq-> AccessFlag & 0x3f)))
- // {
- // pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // ChannelNum = pGetChAccessReq->ChannelNum & 0x0F;
- // if (CURRENT_CHANNEL_NUM == ChannelNum)
- // {
- // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
- // ChannelNum = *curchannel & 0xF;
- // }
- //
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
- // pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
- //
- // if (NULL == pChannelInfo)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // if (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // /* Channel is sessionless channel this command is not supported */
- // pGetChAccessRes->CompletionCode = CC_GET_CH_COMMAND_NOT_SUPPORTED;
- // return sizeof (*pRes);
- // }
- //
- // AccessFlag = GetBits (pGetChAccessReq->AccessFlag, 0xC0);
- //
- // pGetChAccessRes->CompletionCode = CC_NORMAL;
- //
- // switch (AccessFlag)
- // {
- // case 1:
- // /* Get Channel Information from NVRAM */
- // pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
- //
- // pGetChAccessRes->ChannelAccess = SetBits (0x20, pNvrChInfo->Alerting);
- // pGetChAccessRes->ChannelAccess |= SetBits (0x10, pNvrChInfo->PerMessageAuth);
- // pGetChAccessRes->ChannelAccess |= SetBits (0x08, pNvrChInfo->UserLevelAuth);
- // pGetChAccessRes->ChannelAccess |= SetBits (0x07, pNvrChInfo->AccessMode);
- // pGetChAccessRes->Privilege = SetBits (0x0F, pNvrChInfo->MaxPrivilege);
- // break;
- //
- // case 2:
- // /* Get Channel Information from Volatile RAM */
- // pGetChAccessRes->ChannelAccess = SetBits (0x20, pChannelInfo->Alerting);
- // pGetChAccessRes->ChannelAccess |= SetBits (0x10, pChannelInfo->PerMessageAuth);
- // pGetChAccessRes->ChannelAccess |= SetBits (0x08, pChannelInfo->UserLevelAuth);
- // pGetChAccessRes->ChannelAccess |= SetBits (0x07, pChannelInfo->AccessMode);
- // pGetChAccessRes->Privilege = SetBits (0x0F, pChannelInfo->MaxPrivilege);
- // break;
- //
- // default:
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // return sizeof (GetChAccessRes_T);
- }
- /*---------------------------------------
- * GetChInfo
- *---------------------------------------*/
- int
- GetChInfo (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ GetChInfoReq_T* pGetChInfoReq = (_NEAR_ GetChInfoReq_T*)pReq;
- // _NEAR_ GetChInfoRes_T* pGetChInfoRes = (_NEAR_ GetChInfoRes_T*)pRes;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
- // _FAR_ ChannelInfo_T* pChannelInfo;
- // INT8U ChannelNum,*curchannel;
- //
- // if(pGetChInfoReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4)) //Check for Reserved bits
- // {
- // pGetChInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- //
- // ChannelNum = pGetChInfoReq->ChannelNum;
- // if (CURRENT_CHANNEL_NUM == ChannelNum)
- // {
- // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
- // ChannelNum = *curchannel & 0xF;
- //
- // /* UDS, not being a physical channel, will hold LAN properties */
- // if(UDS_CHANNEL == ChannelNum)
- // {
- // ChannelNum = LAN_RMCP_CHANNEL1_TYPE;
- // }
- // }
- //
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
- // pChannelInfo = getChannelInfo(ChannelNum, BMCInst);
- // if (NULL == pChannelInfo)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // pGetChInfoRes->CompletionCode = CC_INV_DATA_FIELD ;
- // return sizeof (*pRes);
- // }
- //
- // pGetChInfoRes->CompletionCode = CC_NORMAL;
- // pGetChInfoRes->ChannelNum = ChannelNum;
- // pGetChInfoRes->ChannelMedium = pChannelInfo->ChannelMedium;
- // pGetChInfoRes->ChannelProtocol = pChannelInfo->ChannelProtocol;
- // pGetChInfoRes->SessionActiveSupport = pChannelInfo->SessionSupport << 6;
- // pGetChInfoRes->SessionActiveSupport |= pChannelInfo->ActiveSession;
- //
- // _fmemcpy (pGetChInfoRes->VendorID, pChannelInfo->ProtocolVendorId,
- // sizeof (pGetChInfoRes->VendorID));
- // _fmemcpy (pGetChInfoRes->AuxiliaryInfo, pChannelInfo->AuxiliaryInfo,
- // sizeof (pGetChInfoRes->AuxiliaryInfo));
- //
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- //
- // return sizeof (GetChInfoRes_T);
- }
- /*---------------------------------------
- * IsChannelSuppGroups
- *---------------------------------------*/
- INT8U IsChannelSuppGroups(INT8U ChannelNum,int BMCInst)
- {
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- // _FAR_ ChannelInfo_T* pChannelInfo;
- // if(IsLANChannel(ChannelNum, BMCInst))
- // {
- //
- // pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
- // if(pChannelInfo==NULL)
- // return 0;
- // if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL1_TYPE)
- // {
- // return pChannelInfo->ChannelType;
- // }
- // else
- // {
- // if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL2_TYPE)
- // {
- // return pChannelInfo->ChannelType;
- // }
- // else
- // {
- // if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL3_TYPE)
- // {
- // return pChannelInfo->ChannelType;
- // }
- // else
- // return 0;
- // }
- // }
- // return 0;
- // }
- // else
- // {
- // if (pBMCInfo->IpmiConfig.SerialIfcSupport == 1 && (pBMCInfo->SERIALch != CH_NOT_USED && ChannelNum == pBMCInfo->SERIALch))
- // {
- // pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
- // if(pChannelInfo==NULL)
- // return 0;
- // return pChannelInfo->ChannelType;
- // }
- // else
- // return 0;
- // }
- }
- /*---------------------------------------
- * ModifyUsrGRP
- *---------------------------------------*/
- int
- ModifyUsrGrp(char * UserName,INT8U ChannelNum,INT8U OldAccessLimit, INT8U NewAccessLimit )
- {
- //
- // char oldgrp[20]="",newgrp[20]="";
- //
- // if(0 == NewAccessLimit)
- // {
- // DeleteUsrFromIPMIGrp(UserName);
- // }
- //
- // if(PRIV_LEVEL_NO_ACCESS == OldAccessLimit)
- // {
- // strcpy(oldgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege].grpname);
- // }
- // else if(IGNORE_ADD_OR_REMOVE != OldAccessLimit)
- // {
- // strcpy(oldgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege+OldAccessLimit].grpname);
- // }
- //
- // if(PRIV_LEVEL_NO_ACCESS == NewAccessLimit)
- // {
- // strcpy(newgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege].grpname);
- // }
- // else if(IGNORE_ADD_OR_REMOVE != NewAccessLimit)
- // {
- // strcpy(newgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege+NewAccessLimit].grpname);
- // }
- //
- // AddIPMIUsrtoChGrp(UserName,(char *)oldgrp,(char *)newgrp);
- return 0;
- }
- /*---------------------------------------
- * SetUserAccess
- *---------------------------------------*/
- int
- SetUserAccess (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ SetUserAccessReq_T* pSetUserAccessReq = (_NEAR_ SetUserAccessReq_T*)pReq;
- // _FAR_ ChannelUserInfo_T* pChUserInfo;
- // _FAR_ UserInfo_T* pUserInfo;
- // _FAR_ ChannelInfo_T* pChannelInfo;
- // _FAR_ ChannelInfo_T* pNvrChInfo;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- // _FAR_ ChannelUserInfo_T * pNVRChUserInfo=NULL;
- //// char ChFilename[MAX_CHFILE_NAME];
- // INT8U Index;
- // INT8U ChannelNum,IPMIMessaging,*curchannel;
- // INT8U OldAccessLimit;
- // int ret=0;
- //
- // if (ReqLen == sizeof(SetUserAccessReq_T) - sizeof(pSetUserAccessReq->SessionLimit) )
- // {
- // pSetUserAccessReq->SessionLimit = 0;
- // }
- // else if(ReqLen == sizeof(SetUserAccessReq_T))
- // {
- // if(0 != pSetUserAccessReq->SessionLimit)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // }
- // else
- // {
- // *pRes = CC_REQ_INV_LEN;
- // return sizeof (*pRes);
- // }
- //
- // // Check for Reserved bits
- // 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))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- //
- // ChannelNum = pSetUserAccessReq->ChannelNoUserAccess & 0x0F;
- // if (CURRENT_CHANNEL_NUM == ChannelNum)
- // {
- // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
- // ChannelNum = *curchannel & 0xF;
- // }
- //
- // /*Removing the Hard coding of admin user
- // if(pSetUserAccessReq->UserID == IPMI_ROOT_USER)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // */
- //
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
- // pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
- // if((NULL == pChannelInfo) || (pSetUserAccessReq->UserID > pBMCInfo->IpmiConfig.MaxUsers) || (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport))
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // pUserInfo = getUserIdInfo(pSetUserAccessReq->UserID, BMCInst);
- // if (NULL == pUserInfo)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // TDBG ("AppDevice.c : SetUserAccess - Invalid user Id\n");
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- //
- // TDBG("pChannle info is %p\n",pChannelInfo);
- // TDBG("UserId id is %d\n",pSetUserAccessReq->UserID);
- // TDBG("pUserInfo->ID is %ld and USERID is %ld\n",pUserInfo->ID,USER_ID);
- //
- // if (pUserInfo->ID != USER_ID)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // TCRIT("Invalid data field\n");
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // /* User 's session limit should be lesser than Channel 's session limit */
- // if(pSetUserAccessReq->SessionLimit > pBMCInfo->IpmiConfig.MaxSession)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- //
- // pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
- // pNVRChUserInfo = GetNVRChUserConfigs(pChannelInfo,BMCInst);
- // pChUserInfo = getChUserIdInfo (pSetUserAccessReq->UserID , &Index, pChannelInfo->ChannelUserInfo, BMCInst);
- //
- // if (NULL == pChUserInfo)
- // {
- // /* Add the user in NVRAM */
- // pChUserInfo = AddChUser (pChannelInfo->ChannelUserInfo, &Index, BMCInst);
- // if(pChUserInfo == NULL)
- // {
- // /*Return proper completion if the user exceeds the max channel users*/
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // pChUserInfo->ID = USER_ID;
- // pChUserInfo->UserId = pSetUserAccessReq->UserID;
- // pNVRChUserInfo[Index].UserId = pSetUserAccessReq->UserID;
- //
- // pChUserInfo->AccessLimit = PRIV_LEVEL_NO_ACCESS;
- // /* Initial depends on the Request Bit */
- // pChUserInfo->IPMIMessaging=FALSE;
- // pChUserInfo->ActivatingSOL=FALSE;
- // pChUserInfo->UserAccessCallback = FALSE;
- // pChUserInfo->LinkAuth = FALSE;
- // pNVRChUserInfo[Index].ID = USER_ID;
- // pNVRChUserInfo[Index].IPMIMessaging=FALSE;
- // pNVRChUserInfo[Index].ActivatingSOL=FALSE;
- // pNVRChUserInfo[Index].UserId = pSetUserAccessReq->UserID;
- // pNVRChUserInfo[Index].LinkAuth = FALSE;
- // pNVRChUserInfo[Index].UserAccessCallback =FALSE;
- // }
- //
- // if (0 != (pSetUserAccessReq->ChannelNoUserAccess & 0x80))
- // {
- // /* set the user access for the channel */
- // IPMIMessaging = GetBits (pSetUserAccessReq->ChannelNoUserAccess, 0x10);
- // if (FALSE == IPMIMessaging)
- // {
- // /* Disable the IPMI Messaging if Its in Enables state */
- // if((TRUE == pChUserInfo->IPMIMessaging)&& (pChannelInfo->NoCurrentUser > 1) )
- // {
- // /* Initialize based on the Request Bit */
- // pChUserInfo->IPMIMessaging=IPMIMessaging;
- // pNVRChUserInfo[Index].IPMIMessaging=IPMIMessaging;
- // }
- // }
- // else
- // {
- // if(TRUE == pChUserInfo->IPMIMessaging)
- // {
- // pChUserInfo->Lock = USER_UNLOCKED;
- // pChUserInfo->LockedTime = 0;
- // pChUserInfo->FailureAttempts = 0;
- // }
- // else if(FALSE == pChUserInfo->IPMIMessaging) /* Enable the IPMI Messaging ,If its in disabled state */
- // {
- // /* Initialize based on the Request Bit */
- // pChUserInfo->IPMIMessaging=IPMIMessaging;
- // pNVRChUserInfo[Index].IPMIMessaging=IPMIMessaging;
- // pChUserInfo->Lock = USER_UNLOCKED;
- // pChUserInfo->LockedTime = 0;
- // pChUserInfo->FailureAttempts = 0;
- // }
- // }
- //
- // /* set in RAM */
- // pChUserInfo->UserAccessCallback = GetBits (pSetUserAccessReq->ChannelNoUserAccess, 0x40);
- // pChUserInfo->LinkAuth = GetBits (pSetUserAccessReq->ChannelNoUserAccess, 0x20);
- //
- // pNVRChUserInfo[Index].UserId = pSetUserAccessReq->UserID;
- // pNVRChUserInfo[Index].LinkAuth =
- // GetBits (pSetUserAccessReq->ChannelNoUserAccess, 0x20);
- // pNVRChUserInfo[Index].UserAccessCallback =
- // GetBits (pSetUserAccessReq->ChannelNoUserAccess, 0x40);
- //
- //
- // }
- // OldAccessLimit=pChUserInfo->AccessLimit;
- // pChUserInfo->AccessLimit = GetBits (pSetUserAccessReq->AccessLimit, 0x0F);
- //
- // ret=ModifyUsrGrp((char *)pUserInfo->UserName,ChannelNum,OldAccessLimit,pChUserInfo->AccessLimit);
- // if(ret < 0)
- // {
- // TCRIT("User Has No LAN or Serial Preivilege!!\n");
- // }
- //
- // pNVRChUserInfo[Index].AccessLimit = pChUserInfo->AccessLimit;
- // /* set in NVRAM */
- // if (0 == (pUserInfo->MaxSession))
- // {
- // /* This is MAX User session Limit */
- // pUserInfo->MaxSession = pBMCInfo->IpmiConfig.MaxSession;
- // }
- //
- //
- // FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0],(INT8U*)&pBMCInfo->UserInfo[0],pBMCInfo->IPMIConfLoc.UserInfoAddr,
- // sizeof(UserInfo_T)*MAX_USER_CFG_MDS,BMCInst);
- // FlushChConfigs((INT8U*)pNvrChInfo,pNvrChInfo->ChannelNumber,BMCInst);
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- //
- // *pRes = CC_NORMAL;
- //
- // return sizeof (*pRes);
- }
- /*---------------------------------------
- * GetUserAccess
- *---------------------------------------*/
- int
- GetUserAccess (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ GetUserAccessReq_T* pGetUserAccessReq = (_NEAR_ GetUserAccessReq_T*)pReq;
- // _NEAR_ GetUserAccessRes_T* pGetUserAccessRes = (_NEAR_ GetUserAccessRes_T*)pRes;
- // _FAR_ ChannelUserInfo_T* pChUserInfo;
- // _FAR_ UserInfo_T* pUserInfo;
- // _FAR_ ChannelInfo_T* pChannelInfo;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- // INT8U Index,*curchannel;
- //
- // // Check for Reserved bits
- // if((pGetUserAccessReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4)) || (pGetUserAccessReq->UserID & (BIT7 | BIT6)) || (pGetUserAccessReq->UserID == 0x00))
- // {
- // pGetUserAccessRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- //
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
- // if (pGetUserAccessReq->ChannelNum == CURRENT_CHANNEL_NUM)
- // {
- // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
- // pChannelInfo = getChannelInfo(*curchannel,BMCInst);
- // }
- // else
- // pChannelInfo = getChannelInfo(pGetUserAccessReq->ChannelNum,BMCInst);
- //
- // //TDBG("UserID is %d\n",pGetUserAccessReq->UserID);
- //
- // if ((NULL == pChannelInfo) ||
- // (pGetUserAccessReq->UserID > pBMCInfo->IpmiConfig.MaxUsers) ||
- // (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport))
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // pGetUserAccessRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // pUserInfo = getUserIdInfo (pGetUserAccessReq->UserID, BMCInst);
- //
- // if (NULL == pUserInfo)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // pGetUserAccessRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // if (TRUE == pUserInfo->UserStatus)
- // {
- // pGetUserAccessRes->CurrentUserID = SetBits (0xC0, USER_ID_ENABLED);
- // }
- // else
- // {
- // pGetUserAccessRes->CurrentUserID = SetBits (0xC0, USER_ID_DISABLED);
- // }
- //
- // pChUserInfo = getChUserIdInfo (pGetUserAccessReq->UserID, &Index, pChannelInfo->ChannelUserInfo ,BMCInst);
- //
- // if (NULL == pChUserInfo)
- // {
- // pGetUserAccessRes->ChannelAccess = SetBits (0x0F, 0x0F);
- // pGetUserAccessRes->ChannelAccess |= SetBits (0x10, FALSE);
- // pGetUserAccessRes->ChannelAccess |= SetBits (0x20, FALSE);
- // pGetUserAccessRes->ChannelAccess |= SetBits (0x40, FALSE);
- // }
- // else
- // {
- // pGetUserAccessRes->ChannelAccess = SetBits (0x0F, pChUserInfo->AccessLimit);
- // pGetUserAccessRes->ChannelAccess |= SetBits (0x10, pChUserInfo->IPMIMessaging);
- // pGetUserAccessRes->ChannelAccess |= SetBits (0x20, pChUserInfo->LinkAuth);
- // pGetUserAccessRes->ChannelAccess |= SetBits (0x40, pChUserInfo->UserAccessCallback);
- // }
- //
- // pGetUserAccessRes->CompletionCode = CC_NORMAL;
- // pGetUserAccessRes->MaxNoUserID = SetBits (0x3F, pChannelInfo->MaxUser);
- // pGetUserAccessRes->CurrentUserID |= SetBits (0x3F, pChannelInfo->NoCurrentUser);
- // pGetUserAccessRes->FixedUserID = SetBits (0x3F, pChannelInfo->NoFixedUser);
- //
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- //
- // return sizeof (GetUserAccessRes_T);
- }
- /*---------------------------------------
- * SetUserName
- *---------------------------------------*/
- int
- SetUserName (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ SetUserNameReq_T* pSetUserNameReq = (_NEAR_ SetUserNameReq_T*)pReq;
- // _FAR_ UserInfo_T* pUserInfo;
- // _FAR_ ChannelInfo_T* pChannelInfo=NULL;
- // _FAR_ ChannelInfo_T* pNvrChInfo;
- // _FAR_ ChannelUserInfo_T* pChUserInfo;
- // _FAR_ ChannelUserInfo_T * pNVRChUserInfo=NULL;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- // INT8U Ch, Index,Chtype;
- // //INT16S Err;
- // INT8U i;
- // INT8U UserName[MAX_USERNAME_LEN + 1]; //plus 1 for null terminator
- // INT8U InvalidChar[]={ ' ' , ',' , '.' , '/' , ':' , ';' , '\\' , '(', ')' , 0x01 ,
- // 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09, 0x0A ,
- // 0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 , 0x11 , 0x12, 0x13 ,
- // 0x14 , 0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1A , 0x1B, 0x1C ,
- // 0x1D , 0x1E , 0x1F , 0x7F} ;
- //
- //// char ChFilename[MAX_CHFILE_NAME];
- // //INT8U Handle = sizeof(ChInfo_T)-sizeof(ChannelInfo_T);
- //
- // // Check for Reserved bits
- // if(pSetUserNameReq->UserID & (BIT7 | BIT6) || (pSetUserNameReq->UserID == 0x00))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- //
- // /*User Id exceeded the limit or Cant set NULL User */
- // if (pSetUserNameReq->UserID > pBMCInfo->IpmiConfig.MaxUsers )
- // {
- // *pRes = CC_INV_DATA_FIELD ;
- // return sizeof (*pRes);
- // }
- //
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
- // pUserInfo = getUserIdInfo(pSetUserNameReq->UserID, BMCInst);
- //
- // /* If the user is fixed user */
- // if (((pUserInfo != NULL) && (pUserInfo->FixedUser == TRUE)))
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_INV_DATA_FIELD ;
- // return sizeof (*pRes);
- // }
- //
- // /* We should not set the NULL user */
- // if(0== pSetUserNameReq->UserName [0] )
- // {
- // printf("\n Setting the NULL user :%x",pSetUserNameReq->UserID);
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_INV_DATA_FIELD ;
- // return sizeof (*pRes);
- // }
- //
- // /* check for numeric first char and special chars */
- // if( 0 != isdigit(pSetUserNameReq->UserName[0] ) )
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- // else
- // {
- // for(i=0;i<sizeof(InvalidChar);i++)
- // {
- // strncpy((char *)UserName,(const char *) pSetUserNameReq->UserName, sizeof(pSetUserNameReq->UserName));
- // UserName[MAX_USERNAME_LEN] = '\0';
- // if( NULL != strchr((const char *)UserName, InvalidChar[i] ))
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- // }
- // }
- //
- // //Don't check duplicated user names for 0xFF, this request is for deleting user
- // if(0xFF != pSetUserNameReq->UserName [0])
- // {
- // //checking for Duplicate user names
- // if(CheckForDuplicateUsers(pSetUserNameReq->UserName,BMCInst)==FALSE)
- // {
- // //setting user's name with same name
- // if(!strncmp((char *)pUserInfo->UserName,(char *)pSetUserNameReq->UserName, MAX_USERNAME_LEN))
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_NORMAL;
- // return sizeof (*pRes);
- // }
- // TINFO("Duplicate ipmi user!!\n");
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // }
- // //checking for reserved user names
- // if(CheckForReservedUsers((char *)pSetUserNameReq->UserName) != 0)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- //
- // /* Add to Linux data base */
- // //Err = 0;
- //
- // /* If User[0] is 0xFF means the user is requested to delete */
- // if ((0xFF == pSetUserNameReq->UserName [0]) ||
- // (0 == pSetUserNameReq->UserName [0] ))
- // {
- // if ((0 == pUserInfo->CurrentSession) && (0 != disableUser (pSetUserNameReq->UserID,BMCInst)))
- // {
- // /* Delete this user form all the channel */
- // for (Ch = 0; Ch < MAX_NUM_CHANNELS; Ch++)
- // {
- // if(pBMCInfo->ChConfig[Ch].ChType != 0xff)
- // {
- // pChannelInfo = (ChannelInfo_T*)&pBMCInfo->ChConfig[Ch].ChannelInfo;
- // }
- // else
- // {
- // continue;
- // }
- //
- // pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
- // pNVRChUserInfo = GetNVRChUserConfigs(pChannelInfo,BMCInst);
- //
- // pChUserInfo = getChUserIdInfo(pSetUserNameReq->UserID, &Index, pChannelInfo->ChannelUserInfo,BMCInst);
- //
- // if (pChUserInfo != NULL)
- // {
- // ModifyUsrGrp((char *)pUserInfo->UserName,pChannelInfo->ChannelNumber,pChUserInfo->AccessLimit,IGNORE_ADD_OR_REMOVE);
- // AddIPMIUsrtoShellGrp((char *)pUserInfo->UserName, pUserInfo->UserShell, IGNORE_ADD_OR_REMOVE_SHELL);
- // AddIPMIUsrtoFlagsGrp((char *)pUserInfo->UserName,pUserInfo->ExtendedPrivilege,IGNORE_ADD_OR_REMOVE);
- // pNVRChUserInfo[Index].UserId = 0;
- // pNVRChUserInfo[Index].IPMIMessaging=FALSE;
- // pNVRChUserInfo[Index].ActivatingSOL=FALSE;
- // pNVRChUserInfo[Index].ID=0;
- // pChUserInfo->ID=0;
- // pChUserInfo->UserId = 0;
- // pChUserInfo->IPMIMessaging=FALSE;
- // pChUserInfo->ActivatingSOL=FALSE;
- // if( pUserInfo->UserStatus == TRUE)
- // {
- // pChannelInfo->NoCurrentUser--;
- // pNvrChInfo->NoCurrentUser--;
- // }
- // FlushChConfigs((INT8U*)pNvrChInfo,pNvrChInfo->ChannelNumber,BMCInst);
- // }
- // else
- // {
- // if(pUserInfo != NULL)
- // DeleteUsrFromIPMIGrp((char *)pUserInfo->UserName);
- // }
- // }
- //
- // /* Checking for valid user, empty users doesnt conatain user directories*/
- // if (USER_ID == pUserInfo->ID)
- // {
- // //removing the user directory created in add user
- // if(RemoveUsrDir((char *)pUserInfo->UserName)!=0)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_UNSPECIFIED_ERR;
- // return sizeof (*pRes);
- // }
- // }
- // /* Delete the user both in Volatile & Non Volatile memory*/
- // pBMCInfo->GenConfig.CurrentNoUser--;
- // _fmemset (pUserInfo, 0, sizeof (UserInfo_T));
- // FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0],(INT8U*)&pBMCInfo->UserInfo[0],pBMCInfo->IPMIConfLoc.UserInfoAddr,
- // sizeof(UserInfo_T)*MAX_USER_CFG_MDS,BMCInst);
- // }
- // else
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_INV_DATA_FIELD ;
- // return sizeof (*pRes);
- // }
- // }
- // else if (USER_ID != pUserInfo->ID)//adding users
- // {
- // for (i = 0; i < MAX_USERNAME_LEN; i++)
- // {
- // if(!(isascii(pSetUserNameReq->UserName[i])))
- // {
- // *pRes = CC_INV_DATA_FIELD ;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // return sizeof (*pRes);
- // }
- // }
- // /* If First time-if user ID does not exist */
- // /* if the user name is set for the first time */
- // pUserInfo->ID = USER_ID;
- // pUserInfo->UserId = pSetUserNameReq->UserID;
- // /* allow for IPMI Mesaging */
- // pUserInfo->UserStatus = FALSE;
- // /* set default max session */
- // pUserInfo->MaxSession = pBMCInfo->IpmiConfig.MaxSession;
- //
- // pBMCInfo->GenConfig.CurrentNoUser++;
- // for (Ch = 0; Ch < MAX_NUM_CHANNELS; Ch++)
- // {
- // if((Chtype = IsChannelSuppGroups(Ch,BMCInst)) == 0)
- // continue;
- // AddUsrtoIPMIGrp((char *)pSetUserNameReq->UserName,Chtype);
- // ModifyUsrGrp((char *)pSetUserNameReq->UserName,Ch,IGNORE_ADD_OR_REMOVE,PRIV_LEVEL_NO_ACCESS);
- // }
- // AddIPMIUsrtoShellGrp((char *)pSetUserNameReq->UserName, IGNORE_ADD_OR_REMOVE_SHELL, pUserInfo->UserShell);
- // AddIPMIUsrtoFlagsGrp((char *)pSetUserNameReq->UserName, IGNORE_ADD_OR_REMOVE, pUserInfo->ExtendedPrivilege);
- // //creating ssh directorys for new user
- // if( CreateSSHUserDir((char *)pSetUserNameReq->UserName) != 0)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_UNSPECIFIED_ERR;
- // return sizeof (*pRes);
- // }
- // //creating authentication key for new user
- // if (CreateSSHAuthKeyFile((char *)pSetUserNameReq->UserName)!= 0)
- // {
- // *pRes = CC_UNSPECIFIED_ERR;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // return sizeof (*pRes);
- // }
- // TINFO("user folders created successfuy----\n");
- //
- // }
- // else if (USER_ID == pUserInfo->ID)//modifying users
- // {
- // for (i = 0; i < MAX_USERNAME_LEN; i++)
- // {
- // if(!(isascii(pSetUserNameReq->UserName[i])))
- // {
- // *pRes = CC_INV_DATA_FIELD ;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // return sizeof (*pRes);
- // }
- // }
- // /* If user name isn't set before we create a folder */
- // if( 0 == pUserInfo->UserName[0] )
- // {
- // CreateSSHUserDir((char *)pSetUserNameReq->UserName);
- // }
- // else
- // {
- // RenameUserDir((char *)pUserInfo->UserName, (char *)pSetUserNameReq->UserName);
- // }
- //
- // for (Ch = 0; Ch < MAX_NUM_CHANNELS; Ch++)
- // {
- // if((Chtype = IsChannelSuppGroups(Ch,BMCInst)) == 0)
- // {
- // continue;
- // }
- // AddUsrtoIPMIGrp((char *)pSetUserNameReq->UserName,Chtype);
- // pChannelInfo = getChannelInfo (Ch, BMCInst);
- // if(NULL == pChannelInfo)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // pChUserInfo = getChUserIdInfo(pSetUserNameReq->UserID, &Index, pChannelInfo->ChannelUserInfo,BMCInst);
- // if (pChUserInfo != NULL)
- // {
- // ModifyUsrGrp((char *)pUserInfo->UserName, pChannelInfo->ChannelNumber, pChUserInfo->AccessLimit, IGNORE_ADD_OR_REMOVE);//Remove User
- // ModifyUsrGrp((char *)pSetUserNameReq->UserName, pChannelInfo->ChannelNumber, IGNORE_ADD_OR_REMOVE, pChUserInfo->AccessLimit);//add user
- // }
- // else
- // {
- // ModifyUsrGrp((char *)pUserInfo->UserName, Ch,PRIV_LEVEL_NO_ACCESS, IGNORE_ADD_OR_REMOVE);//Remove User
- // ModifyUsrGrp((char *)pSetUserNameReq->UserName, Ch, IGNORE_ADD_OR_REMOVE, PRIV_LEVEL_NO_ACCESS);//add user
- // }
- // }
- // AddIPMIUsrtoShellGrp((char *)pUserInfo->UserName, pUserInfo->UserShell, IGNORE_ADD_OR_REMOVE_SHELL);//Remove User from Shell Group
- // AddIPMIUsrtoShellGrp((char *)pSetUserNameReq->UserName, IGNORE_ADD_OR_REMOVE_SHELL, pUserInfo->UserShell);//Add User in Shell Group
- // AddIPMIUsrtoFlagsGrp((char *)pUserInfo->UserName, pUserInfo->ExtendedPrivilege, IGNORE_ADD_OR_REMOVE);//Remove User from Flags Group
- // AddIPMIUsrtoFlagsGrp((char *)pSetUserNameReq->UserName, IGNORE_ADD_OR_REMOVE, pUserInfo->ExtendedPrivilege);//Add User in Flags Group
- // }
- // _fmemcpy (pUserInfo->UserName, pSetUserNameReq->UserName, MAX_USERNAME_LEN);
- //
- // FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0],(INT8U*)&pBMCInfo->UserInfo[0],pBMCInfo->IPMIConfLoc.UserInfoAddr,
- // sizeof(UserInfo_T)*MAX_USER_CFG_MDS,BMCInst);
- // FlushIPMI((INT8U*)&pBMCInfo->GenConfig,(INT8U*)&pBMCInfo->GenConfig,pBMCInfo->IPMIConfLoc.GenConfigAddr,
- // sizeof(GENConfig_T),BMCInst);
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_NORMAL;
- // return sizeof (*pRes);
- }
- /*---------------------------------------
- * GetUserName
- *---------------------------------------*/
- int
- GetUserName (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ GetUserNameReq_T* pGetUserNameReq = (_NEAR_ GetUserNameReq_T*)pReq;
- // _NEAR_ GetUserNameRes_T* pGetUserNameRes = (_NEAR_ GetUserNameRes_T*)pRes;
- // _FAR_ UserInfo_T* pUserInfo;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- // //INT16S Err;
- //
- // // Check for Reserved bits
- // if(pGetUserNameReq->UserID & (BIT7 | BIT6) || (pGetUserNameReq->UserID == 0x00))
- // {
- // pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
- // return sizeof(*pRes);
- // }
- //
- // if (pGetUserNameReq->UserID > pBMCInfo->IpmiConfig.MaxUsers)
- // {
- // /* if user ID exceeded the Max limit */
- // pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
- // return sizeof (*pRes);/* Invalied user id */
- // }
- //
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
- // pUserInfo = getUserIdInfo(pGetUserNameReq->UserID, BMCInst);
- //
- // /* if User is disabled or if User is not created */
- //
- // //if user is disabled we dont have to return invalid data field
- // //instead we return everything possible about the user
- // // if pUserInfo is NULL then nothing in the structure at all
- // // pUserInfo being NULL is probably not possible
- // // If the signature doesnt match then the useris not yet configured
- // // so reasonable to return an error
- // if ((NULL == pUserInfo) || (pUserInfo->ID != USER_ID))
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // /* User with given ID is disabled */
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // //if we are here then the user is just disabled
- // if(FALSE == pUserInfo->UserStatus)
- // {
- // TDBG("user is just dissabled\n");
- // //user is just disabled!!
- // }
- //
- // //Err = 0;
- // pGetUserNameRes->CompletionCode = CC_NORMAL;
- // _fmemcpy (pGetUserNameRes->UserName, pUserInfo->UserName, MAX_USERNAME_LEN);
- //
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- //
- // return sizeof (GetUserNameRes_T);
- }
- /*---------------------------------------
- * SetUserPassword
- *---------------------------------------*/
- int
- SetUserPassword (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ SetUserPswdReq_T* pSetUserPswdReq = (_NEAR_ SetUserPswdReq_T*)pReq;
- // _FAR_ UserInfo_T* pUserInfo;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- // INT8U UserId=0, Operation;
- // INT8U UserPswd[MAX_PASSWD_LEN];
- // INT8S EncryptedUserPswd[MAX_ENCRYPTED_PSWD_LEN] = {0};
- // INT8U PwdEncKey[MAX_SIZE_KEY + 1] = {0};
- // INT8U i;
- // INT8U UserPassword[ MAX_PASSWORD_LEN + 1 ];
- // INT8U InvalidChar[] = { 0x01 , 0x02 , 0x03 , 0x04 ,0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0A,
- // 0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 , 0x11 , 0x12 , 0x13 , 0x14,
- // 0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1A , 0x1B , 0x1C , 0x1D , 0x1E ,
- // 0x1F , 0x7F };
- //
- //
- // Operation = pSetUserPswdReq->Operation & 0x03;
- // UserId = pSetUserPswdReq->UserID & 0x3F;
- //
- // if ((((pSetUserPswdReq->UserID & TWENTY_BYTE_PWD) == 0) && (ReqLen != IPMI_15_PASSWORD_LEN))
- // ||(((pSetUserPswdReq->UserID & TWENTY_BYTE_PWD) == TWENTY_BYTE_PWD) && (ReqLen != IPMI_20_PASSWORD_LEN)))
- // {
- // /* For enable or disable using the password field is optional */
- // if (ReqLen == OP_USERID_ONLY_LENGTH)
- // {
- // if ((Operation != OP_ENABLE_USER_ID) && (Operation != OP_DISABLE_USER_ID))
- // {
- // *pRes = CC_REQ_INV_LEN;
- // return sizeof (*pRes); //Invalid operation.
- // }
- // }
- // else
- // {
- // *pRes = CC_REQ_INV_LEN;
- // return sizeof (*pRes); //password len invalid
- // }
- // }
- //
- // /* Reserved bits checking */
- // if((pSetUserPswdReq->UserID & BIT6) || (UserId == 0) || (pSetUserPswdReq->Operation & (BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // if (ReqLen == IPMI_15_PASSWORD_LEN)
- // {
- // _fmemset (pSetUserPswdReq->Password + 16, 0, 4);
- // }
- // ReqLen -=2;
- //
- // if (UserId > pBMCInfo->IpmiConfig.MaxUsers)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes); /*User Id exceeded the limit*/
- // }
- //
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
- // pUserInfo = getUserIdInfo (UserId, BMCInst);
- //
- // if ( NULL == pUserInfo )
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // IPMI_WARNING ("Invalid User Id \n");
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // TDBG("pUserInfo is %p\n",pUserInfo);
- //
- // *pRes = CC_NORMAL;
- //
- // switch (Operation)
- // {
- //
- // case DISABLE_USER:
- // TDBG("In disable user for user id %d\n",UserId);
- // /*disable user */
- // if(pUserInfo == NULL)
- // {
- // //the user is already disabled!!
- // //no point in disabling him again
- // }
- // else if(disableUser(UserId, BMCInst) == 0)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // //we cannot disable this user because he is the only user in the channel
- // TDBG("not disabling user\n");
- // /* cannot disable user since this user is the only user in the channel*/
- // *pRes = CC_SETPASSWORD_CANNOT_DISABLE_USER;
- // return sizeof (*pRes);
- // }
- // else
- // {
- // //here we can disable the user
- //
- // TDBG("will disable user\n");
- //
- // if (pUserInfo->UserStatus == TRUE)
- // {
- // pBMCInfo->GenConfig.CurrentNoUser--;
- // UpdateCurrentEnabledUserCount(COUNT_DECREASE, BMCInst);
- // }
- //
- // pUserInfo->UserStatus = FALSE;
- //
- // //when user is disabled ".ssh" folder of the user is renamed to restrict user login
- // TDBG("renaming the .ssh folder to _.ssh\n");
- // if(RenameUserSSHDir((char *)pUserInfo->UserName)!=0)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_UNSPECIFIED_ERR;
- // return sizeof (*pRes);
- // }
- // }
- //
- // break;
- //
- // case ENABLE_USER:
- // /*enable user */
- // if (USER_ID == pUserInfo->ID)
- // {
- // /* if for the first time then Increment the Current user No */
- // if ( pUserInfo->UserStatus == FALSE )
- // {
- // pBMCInfo->GenConfig.CurrentNoUser++;
- // UpdateCurrentEnabledUserCount(COUNT_INCREASE, BMCInst);
- // }
- // pUserInfo->UserStatus = TRUE;
- //
- // //when user is enabled the pub key is restored to original name to allow login
- // TDBG("restoring the ._ssh folder to .ssh\n");
- // if( RestoreUsrSSHDir((char *)pUserInfo->UserName)!=0)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_UNSPECIFIED_ERR;
- // return sizeof (*pRes);
- // }
- // if (0 == pUserInfo->UserName [0])
- // {
- // TDBG ("The user Name is Not yet set.. So No synching with the linux \n");
- // *pRes = CC_NORMAL;
- // FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0],(INT8U*)&pBMCInfo->UserInfo[0],pBMCInfo->IPMIConfLoc.UserInfoAddr,
- // sizeof(UserInfo_T)*MAX_USER_CFG_MDS,BMCInst);
- // FlushIPMI((INT8U*)&pBMCInfo->GenConfig,(INT8U*)&pBMCInfo->GenConfig,pBMCInfo->IPMIConfLoc.GenConfigAddr,
- // sizeof(GENConfig_T),BMCInst);
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // return sizeof (*pRes);
- // }
- // TDBG ("Synching with the Linux User dataBase \n");
- // }
- // else
- // {
- // /* Looks like the User info is not there So just enable the user in the IPMI */
- // /* no need to Ssync with the linux databse since there will b No corresponding user in the linux database */
- // TCRIT("Enable user called on a not yet enabled user!!\n");
- // /* If First time-if user ID does not exist */
- // /* if the user is enabled for the first time */
- // pUserInfo->ID = USER_ID;
- // pUserInfo->UserId = UserId;
- // pUserInfo->UserStatus = TRUE;
- // pUserInfo->MaxSession = pBMCInfo->IpmiConfig.MaxSession;
- //
- // pBMCInfo->GenConfig.CurrentNoUser++;
- // UpdateCurrentEnabledUserCount(COUNT_INCREASE, BMCInst);
- //
- // //when user is enabled the pub key is restored to original name to allow login
- // TDBG("restoring the ._ssh folder to .ssh\n");
- // if(RestoreUsrSSHDir((char *)pUserInfo->UserName)!=0)
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_UNSPECIFIED_ERR;
- // return sizeof (*pRes);
- // }
- // memset(pUserInfo->UserName, 0, MAX_USERNAME_LEN);
- // /* If user name isn't set before we save the configuration */
- // FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0], (INT8U*)&pBMCInfo->UserInfo[0], pBMCInfo->IPMIConfLoc.UserInfoAddr,
- // sizeof(UserInfo_T)*MAX_USER_CFG_MDS, BMCInst);
- // FlushIPMI((INT8U*)&pBMCInfo->GenConfig, (INT8U*)&pBMCInfo->GenConfig, pBMCInfo->IPMIConfLoc.GenConfigAddr,
- // sizeof(GENConfig_T), BMCInst);
- // *pRes = CC_NORMAL;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // return sizeof (*pRes);
- // }
- // break;
- //
- // case SET_PASSWORD:
- // /*set password */
- // if (USER_ID == pUserInfo->ID)
- // {
- // /*check for special characters*/
- // for( i = 0 ; i < sizeof(InvalidChar) ; i++ )
- // {
- // strncpy((char *)UserPassword,(const char *) pSetUserPswdReq->Password, sizeof(pSetUserPswdReq->Password));
- // UserPassword[MAX_PASSWORD_LEN] = '\0';
- // if( NULL != strchr((const char *)UserPassword, InvalidChar[i] ))
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- // }
- //
- // pUserInfo->MaxPasswordSize = ReqLen;
- // if (g_corefeatures.userpswd_encryption == ENABLED)
- // {
- // /* Get Encryption Key from the MBMCInfo_t structure */
- // memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
- //
- // if(EncryptPassword((INT8S *)pSetUserPswdReq->Password, MAX_PASSWORD_LEN, EncryptedUserPswd, MAX_PASSWORD_LEN, PwdEncKey))
- // {
- // TCRIT("Error in encrypting the IPMI User Password for user ID:%d\n", pSetUserPswdReq->UserID);
- // *pRes = CC_UNSPECIFIED_ERR;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // return sizeof(INT8U);
- // }
- // memset(&(pBMCInfo->EncryptedUserInfo[UserId - 1].EncryptedPswd), 0, MAX_ENCRYPTED_PSWD_LEN);
- // memcpy(&(pBMCInfo->EncryptedUserInfo[UserId - 1].EncryptedPswd), EncryptedUserPswd, MAX_ENCRYPTED_PSWD_LEN);
- // memcpy(pBMCInfo->UserInfo[UserId - 1].UserPassword, "$ENCRYPTED$", 11);
- // }
- // else
- // {
- // _fmemcpy (pUserInfo->UserPassword, pSetUserPswdReq->Password, MAX_PASSWORD_LEN);
- // }
- // if(ENABLED != g_corefeatures.disable_empty_passwd_login)
- // {
- // TDBG("\nSet User Password .Password is configured succussfully...\n");
- // pUserInfo->UserPasswdConfigured = 1;
- // }
- // }
- // else
- // {
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // break;
- //
- // case TEST_PASSWORD:
- // if (g_corefeatures.userpswd_encryption == ENABLED)
- // {
- // /* Get Encryption Key from the MBMCInfo_t structure */
- // memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
- //
- // if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, (char *)UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
- // {
- // TCRIT("Error in Decrypting IPMI User Password for user with ID:%d\n", UserId);
- // *pRes = CC_UNSPECIFIED_ERR;
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // return sizeof(*pRes);
- // }
- // }
- // else
- // {
- // _fmemcpy (UserPswd, pUserInfo->UserPassword, MAX_PASSWORD_LEN);
- // }
- // /*Test Password */
- // if( ReqLen != pUserInfo->MaxPasswordSize && (pUserInfo->MaxPasswordSize != 0))
- // {
- // *pRes = CC_PASSWORD_TEST_FAILED_WRONG_SIZE;
- // }
- // else if (((FALSE == pUserInfo->UserStatus) && (pUserInfo->ID != USER_ID)) ||
- // (0 != _fmemcmp (UserPswd, pSetUserPswdReq->Password, MAX_PASSWORD_LEN)))
- // {
- // *pRes = CC_PASSWORD_TEST_FAILED;
- // }
- //
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // return sizeof (*pRes);
- // break;
- // }
- //
- // FlushIPMI((INT8U*)&pBMCInfo->UserInfo[0],(INT8U*)&pBMCInfo->UserInfo[0],pBMCInfo->IPMIConfLoc.UserInfoAddr,
- // sizeof(UserInfo_T)*MAX_USER_CFG_MDS,BMCInst);
- // FlushIPMI((INT8U*)&pBMCInfo->GenConfig,(INT8U*)&pBMCInfo->GenConfig,pBMCInfo->IPMIConfLoc.GenConfigAddr,
- // sizeof(GENConfig_T),BMCInst);
- // FlushIPMI((INT8U*)&pBMCInfo->EncryptedUserInfo[0], (INT8U*)&pBMCInfo->EncryptedUserInfo[0], pBMCInfo->IPMIConfLoc.EncUserPasswdAddr,
- // sizeof(EncryptedUserInfo_T) * MAX_USER_CFG_MDS, BMCInst);
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
- // return sizeof (*pRes);
- }
- /*---------------------------------------
- * MasterWriteRead
- *---------------------------------------*/
- int
- MasterWriteRead (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ MasterWriteReadReq_T* pMasterWriteReadReq = (_NEAR_ MasterWriteReadReq_T*)pReq;
- // _NEAR_ MasterWriteReadRes_T* pMasterWriteReadRes = (_NEAR_ MasterWriteReadRes_T*)pRes;
- // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
- // _NEAR_ INT8U* OutBuffer;
- // _NEAR_ INT8U* InBuffer;
- // INT8U ChannelNum, BusID, BusType, SlaveAddr, ReadCount, WriteCount;
- // INT8S BusName[64];
- // int retval = 0;
- // INT8U OrgReadCount;
- // INT8U I2CBusId=0;
- // INT8U DevID = 0; // This will be '0' by Default... /dev/peci0
- // INT8U Target = 0x30; // This is the Client address. 30h = 48 is Default for CPU0
- // INT8U Domain = 0; // Multi-Domain support. Default is '0'
- // INT8U Xmit_Feedback = 0; // If full response is Desired, enable this. Default is '1'
- // INT8U AWFCS = 0; // Enable AWFCS in the Transmitted packet by Hw. Default is '0'
- // INT8U Read_Len = 0; // Number of bytes of read back Data from PECI Client
- // INT8U Write_Len = 0; // Number of bytes of data, host is sending to client
- // INT8U *Write_Data = NULL; // Pointer to the Data sent by User to the PECI Client
- // INT8U *Read_Data = NULL; // Pointer to the Data received from PECI Client to be sent to user
- // int ret_val = 0;
- //
- // if(pMasterWriteReadReq->SlaveAddress & BIT0)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // ReadCount = pMasterWriteReadReq->ReadCount;
- // ChannelNum = GetBits (pMasterWriteReadReq->BusTypeChNo, 0xF0);
- // BusID = GetBits (pMasterWriteReadReq->BusTypeChNo, 0x0E);
- // BusType = GetBits (pMasterWriteReadReq->BusTypeChNo, 0x01);
- // SlaveAddr = (pMasterWriteReadReq->SlaveAddress >> 1);
- //
- // if ((BusType == 0x00 && BusID != 0x00) || ((BusType == 0x01) && (BusID == 0x00)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // // Command order:
- // // ipmitool -H <IP> -I lan -U <Username> -P <Password> bus=7 <Slave_Addr> <Read_Len> <Write_Len> <AWFCS> <Domain> <Data>
- // // <bus=7> : Bus# must be 0x07 for comunicating with PECI over IPMI. Other buses are not for this feature
- // // <Slave_Addr> : This is the PECI Client target address.
- // // <Read_Len> : Number of bytes of data to read from the PECI Response
- // // <Write_Len> : Number of bytes of data being written, as per the PECI Spec. Number of Bytes after Domain.
- // // <AWFCS> : 0x01 or 0x00 indicates enabling or disabling of AWFCS feature respectively
- // // <Domain> : 0x01 or 0x00 indicates domain=1 or domain=0 for multi-domain commands respectively
- // // <Data> : Rest of data like Command, and other params as per the PECI Spec.
- //
- // // If BusType is External (0x01) and BusID is 7, then we consider to communicate with PECI
- //
- // if(g_corefeatures.peci_over_ipmi == ENABLED )
- // {
- // if ((BusType & 0x01) && (BusID == 0x07))
- // {
- // DevID = 0;
- // Xmit_Feedback = 0;
- // Target = pMasterWriteReadReq->SlaveAddress;
- // Read_Len = ReadCount;
- // Write_Len = pMasterWriteReadReq->Data[0];
- // AWFCS = pMasterWriteReadReq->Data[1];
- // Domain = pMasterWriteReadReq->Data[2];
- // Write_Data = &pMasterWriteReadReq->Data[3];
- // Read_Data = &pMasterWriteReadRes->Data[0];
- //
- // memset(&pMasterWriteReadRes->Data[0], 0, sizeof(pMasterWriteReadRes->Data));
- //
- // // Call the PECI Generic Handler for passing the command to the PECI Controller
- // if(g_HALPECIHandle[HAL_PECI_COMMAND] != NULL)
- // {
- // ret_val = ((int(*)(char, char, char, char, char, char *, char, char *, char))g_HALPECIHandle[HAL_PECI_COMMAND]) (DevID, Target,
- // Domain, Xmit_Feedback, AWFCS,
- // (char *)Write_Data, Write_Len,
- // (char *)Read_Data, Read_Len );
- // }
- // else
- // {
- // pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (*pRes);
- // }
- //
- // /* Check if peci issue command operation is success or not */
- // if (ret_val == -1)
- // {
- // pMasterWriteReadRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- //
- // pMasterWriteReadRes->CompletionCode = CC_NORMAL;
- //
- // return (sizeof (*pRes) + ReadCount);
- // }
- // }
- //
- // if(0 ==BusType){
- // if(PRIMARY_IPMB_CHANNEL == ChannelNum)
- // {
- // I2CBusId=pBMCInfo->IpmiConfig.PrimaryIPMBBusNumber;
- // }
- // else if((pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)&&(pBMCInfo->SecondaryIPMBCh == ChannelNum))
- // {
- // I2CBusId=pBMCInfo->IpmiConfig.SecondaryIPMBBusNumber;
- // }else{
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // }
- // else
- // {
- // if(BusID==pBMCInfo->IpmiConfig.PrimaryIPMBBusNumber)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }else if((pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)&&(BusID==pBMCInfo->IpmiConfig.SecondaryIPMBBusNumber))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }else{
- // I2CBusId=BusID;
- // }
- // }
- //
- // if (ReqLen < 3)
- // {
- // *pRes = CC_REQ_INV_LEN;
- // return sizeof (*pRes);
- // }
- //
- // /* number of bytes to write
- // * = pMasterWriteReadReq length - 3 for Request Data byte -
- // * BusTypeChNo,SlaveAddr,Readcount + 1 byte for address
- // */
- // WriteCount = ReqLen - 3;
- //
- // OutBuffer = (pMasterWriteReadReq->Data);
- // InBuffer = pMasterWriteReadRes->Data;
- // sprintf(BusName,"/dev/i2c%d",I2CBusId);
- //
- // // Save original ReadCount in case we need to modify it
- // OrgReadCount = ReadCount;
- //
- // // If both ReadCount and WriteCount are zero, then force a read of 1 byte.
- // // If we do not do this, the write command will fail.
- // // Having both counts 0 is a way of "pinging" the given device to see if it
- // // is responding to its address.
- //
- // if (ReadCount == 0 && WriteCount == 0)
- // {
- // ReadCount = 1;
- // }
- //
- // if (ReadCount > 0 && WriteCount == 0)
- // {
- // if(g_HALI2CHandle[HAL_I2C_MR] != NULL)
- // {
- // retval = ((int(*)(char *,u8,u8 *,size_t))g_HALI2CHandle[HAL_I2C_MR]) (BusName, SlaveAddr, InBuffer, ReadCount);
- // if (retval < 0)
- // {
- // pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
- // return sizeof (*pRes);
- // }
- // }
- // else
- // {
- // pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof(*pRes);
- // }
- //
- // ReadCount = OrgReadCount;
- //
- // /* copy the bytes read to Response Data */
- // _fmemcpy (pMasterWriteReadRes->Data, InBuffer, ReadCount);
- // }
- // else if(ReadCount > 0 && WriteCount > 0 )
- // {
- // if(g_HALI2CHandle[HAL_I2C_RW] != NULL)
- // {
- // retval = ((int(*)(char *,u8,u8 *,u8 *,size_t,size_t))g_HALI2CHandle[HAL_I2C_RW]) (BusName, SlaveAddr, OutBuffer, InBuffer, WriteCount, ReadCount);
- // if (retval < 0)
- // {
- // pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
- // return sizeof (*pRes);
- // }
- // }
- // else
- // {
- // pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof(*pRes);
- // }
- //
- // ReadCount = OrgReadCount;
- //
- // /* copy the bytes read to Response Data */
- // _fmemcpy (pMasterWriteReadRes->Data, InBuffer, ReadCount);
- // }
- // else
- // {
- // /* No data to read so use master write instead,
- // * otherwise some devices (EEPROM) that have not finished writing
- // * will fail on the read transaction and possibly corrupt data
- // */
- // if(g_HALI2CHandle[HAL_I2C_MW] != NULL)
- // {
- // retval= ((ssize_t(*)(char *,u8,u8 *,size_t))g_HALI2CHandle[HAL_I2C_MW]) (BusName, SlaveAddr, OutBuffer, WriteCount);
- // if(retval < 0)
- // {
- // pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
- // return sizeof (*pRes);
- // }
- // }
- // else
- // {
- // pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof(*pRes);
- // }
- // }
- //
- // pMasterWriteReadRes->CompletionCode = CC_NORMAL;
- //
- // return (sizeof (*pRes) + ReadCount);
- }
- //#if 0
- /*-------------------------------------------
- * ComputeAuthCode
- *-------------------------------------------*/
- void
- ComputeAuthCode (_FAR_ INT8U* pPassword, _NEAR_ SessionHdr_T* pSessionHdr,
- _NEAR_ IPMIMsgHdr_T* pIPMIMsg, _NEAR_ INT8U* pAuthCode,
- INT8U ChannelType)
- {
- // if (AUTH_TYPE_PASSWORD == pSessionHdr->AuthType)
- // {
- // _fmemcpy (pAuthCode, pPassword, MAX_PASSWORD_LEN);
- // }
- // else
- // {
- // INT8U AuthBuf [MAX_AUTH_PARAM_SIZE];
- // INT16U AuthBufLen = 0;
- // INT8U IPMIMsgLen = *((_NEAR_ INT8U*) pIPMIMsg - 1);
- //
- // /* Password */
- // _fmemcpy (AuthBuf, pPassword, MAX_PASSWORD_LEN);
- // AuthBufLen += MAX_PASSWORD_LEN;
- // /* Session ID */
- // _fmemcpy (AuthBuf + AuthBufLen, &pSessionHdr->SessionID, sizeof (INT32U));
- // AuthBufLen += sizeof (INT32U);
- // /* IPMI Response Message */
- // _fmemcpy (AuthBuf + AuthBufLen, pIPMIMsg, IPMIMsgLen);
- // AuthBufLen += IPMIMsgLen;
- //
- // if (ChannelType == MULTI_SESSION_CHANNEL)
- // {
- // /* Session Sequence Number */
- // _fmemcpy (AuthBuf + AuthBufLen,
- // &pSessionHdr->SessionSeqNum, sizeof (INT32U));
- // AuthBufLen += sizeof (INT32U);
- // }
- // /* Password */
- // _fmemcpy (AuthBuf + AuthBufLen, pPassword, MAX_PASSWORD_LEN);
- // AuthBufLen += MAX_PASSWORD_LEN;
- //
- // switch (pSessionHdr->AuthType)
- // {
- // case AUTH_TYPE_MD2 :
- // AuthCodeCalMD2 (AuthBuf, pAuthCode, AuthBufLen);
- // break;
- //
- // case AUTH_TYPE_MD5 :
- // AuthCodeCalMD5 (AuthBuf, pAuthCode, AuthBufLen);
- // break;
- //
- // default :
- // TDBG ("RMCP: Invalid Authentication Type \n");
- // }
- // }
- }
- //#endif
- /*---------------------------------------
- * GetSystemInfoParam
- *---------------------------------------*/
- int
- GetSystemInfoParam (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ GetSystemInfoParamReq_T* pGetSysInfoReq = (_NEAR_ GetSystemInfoParamReq_T*)pReq;
- // _NEAR_ GetSystemInfoParamRes_T* pGetSysInfoRes = ( _NEAR_ GetSystemInfoParamRes_T* ) pRes ;
- // _NEAR_ GetSystemInfoParamOEMRes_T* pGetSysInfoOEMRes = ( _NEAR_ GetSystemInfoParamOEMRes_T* ) pRes ;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
- // _FAR_ SystemInfoConfig_T* pSysInfoCfg;
- // INT8U resSize = sizeof(pGetSysInfoRes->CompletionCode) + sizeof(pGetSysInfoRes->ParamRevision);
- // INT8U oem_len;
- // unsigned long oem_addr;
- //
- // // Check for Reserved bits
- // if(pGetSysInfoReq->ParamRev & (BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0))
- // {
- // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pGetSysInfoRes->CompletionCode);
- // }
- //
- // pGetSysInfoRes->CompletionCode = CC_NORMAL;
- //
- // /* Fill the param's older Version and the present version */
- // pGetSysInfoRes->ParamRevision = ((PARAM_OLDER_REVISION << 4) & 0xF0 ) | PARAM_PRESENT_REVISION;
- //
- // /* Check for Revision only parameter */
- // if (pGetSysInfoReq->ParamRev & GET_PARAM_REV_ONLY )
- // {
- // if((MAX_APP_CONF_PARAM >= pGetSysInfoReq->ParamSelector))
- // {
- // return resSize;
- // }
- // else if(( NULL != g_PDKHandle[PDK_GETSYSINFOPARAM]) &&
- // ((MIN_SYSINFO_OEM_CONF_PARAM <= pGetSysInfoReq->ParamSelector) && (MAX_SYSINFO_OEM_CONF_PARAM >= pGetSysInfoReq->ParamSelector)))
- // {
- // oem_len = ((int(*)(INT8U, unsigned long*,int))(g_PDKHandle[PDK_GETSYSINFOPARAM]))(pGetSysInfoReq->ParamSelector, &oem_addr ,BMCInst);
- // if( oem_len == 0)
- // {
- // pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
- // return sizeof(INT8U);
- // }
- // else
- // return resSize;
- // }
- // else
- // {
- // *pRes = CC_PARAM_NOT_SUPPORTED;
- // return sizeof (*pRes);
- // }
- // }
- //
- // /* Get Systen Info parameters from NVRAM */
- // pSysInfoCfg = &pBMCInfo->SystemInfoConfig;
- //
- // switch(pGetSysInfoReq->ParamSelector)
- // {
- // case SET_IN_PROGRESS_PARAM: /*Parameter 0 volatile*/
- // if( (0x00 != pGetSysInfoReq->SetSelector) || (0x00 != pGetSysInfoReq->BlockSelector) )
- // {
- // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pGetSysInfoRes->CompletionCode);
- // }
- //
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // pGetSysInfoRes->SysInfo.SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Sys_SetInProgress;
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // resSize++;
- // break;
- //
- // case SYS_FW_VERSION_PARAM:
- // _fmemset(&pGetSysInfoRes->SysInfo.SysVerInfo,0,sizeof(SysVerInfo_T));
- // if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
- // {
- // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pGetSysInfoRes->CompletionCode);
- // }
- //
- // pGetSysInfoRes->SysInfo.SysVerInfo.SetSelector = pGetSysInfoReq->SetSelector;
- // resSize++;
- // if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
- // {
- // pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[0]=pSysInfoCfg->SysFWVersion.TypeOfEncoding;
- // pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[1]=pSysInfoCfg->SysFWVersion.StringLength;
- // _fmemcpy(&pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[2], pSysInfoCfg->SysFWVersion.SysFWVersionName,MAX_STRING_LENGTH_COPY);
- // resSize += MAX_BLOCK_SIZE;
- // }
- // else
- // {
- // _fmemcpy(&pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[0],
- // &pSysInfoCfg->SysFWVersion.SysFWVersionName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
- // resSize += MAX_BLOCK_SIZE;
- // }
- // break;
- //
- // case SYS_NAME_PARAM:
- // if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
- // {
- // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pGetSysInfoRes->CompletionCode);
- // }
- //
- // pGetSysInfoRes->SysInfo.SysNameInfo.SetSelector = pGetSysInfoReq->SetSelector;
- // resSize++;
- // if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
- // {
- // pGetSysInfoRes->SysInfo.SysNameInfo.SysName[0]=pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name;
- // pGetSysInfoRes->SysInfo.SysNameInfo.SysName[1]=pSysInfoCfg->SysName.StringLength_Sys_Name;
- // _fmemcpy(&pGetSysInfoRes->SysInfo.SysNameInfo.SysName[2],&pSysInfoCfg->SysName.SystemName,MAX_STRING_LENGTH_COPY);
- // resSize += MAX_BLOCK_SIZE;
- // }
- // else
- // {
- // _fmemcpy(&pGetSysInfoRes->SysInfo.SysNameInfo.SysName[0],
- // &pSysInfoCfg->SysName.SystemName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2], MAX_BLOCK_SIZE);
- // resSize += MAX_BLOCK_SIZE;
- // }
- // break;
- //
- // case PRIM_OS_NAME_PARAM:
- // if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
- // {
- // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pGetSysInfoRes->CompletionCode);
- // }
- //
- // pGetSysInfoRes->SysInfo.PrimOSInfo.SetSelector = pGetSysInfoReq->SetSelector;
- // resSize++;
- // if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
- // {
- // pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[0]=pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName;
- // pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[1]=pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName;
- // _fmemcpy(&pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[2], &pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName, MAX_STRING_LENGTH_COPY);
- // resSize += MAX_BLOCK_SIZE;
- // }
- // else
- // {
- // _fmemcpy(&pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[0],
- // &pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
- // resSize += MAX_BLOCK_SIZE;
- // }
- // break;
- //
- // case OS_NAME_PARAM:
- // /*Parameter 4 volatile*/
- // _fmemset(&pGetSysInfoRes->SysInfo.OSInfo,0,sizeof(OSInfo_T));
- // if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)||(0x00 != pGetSysInfoReq->BlockSelector))
- // {
- // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pGetSysInfoRes->CompletionCode);
- // }
- // pGetSysInfoRes->SysInfo.OSInfo.SetSelector = pGetSysInfoReq->SetSelector;
- // resSize++;
- // if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[0]=BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName;
- // pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[1]=BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName;
- // _fmemcpy(&pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[2], BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName, MAX_STRING_LENGTH_COPY);
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // resSize += MAX_BLOCK_SIZE;
- // }
- // else
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy(&pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[0],
- // &BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // resSize += MAX_BLOCK_SIZE;
- // }
- //
- // break;
- //
- // default:
- // if(g_PDKHandle[PDK_GETSYSINFOPARAM] != NULL &&
- // (pGetSysInfoReq->ParamSelector >= 192 && pGetSysInfoReq->ParamSelector <= 255))
- // {
- // oem_len = ((int(*)(INT8U, unsigned long*,int))(g_PDKHandle[PDK_GETSYSINFOPARAM]))(pGetSysInfoReq->ParamSelector, &oem_addr ,BMCInst);
- // if( oem_len == 0)
- // {
- // pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
- // return sizeof(INT8U);
- // }
- // else
- // {
- // //Acquire the OEM parameters
- // if( oem_len < MSG_PAYLOAD_SIZE - sizeof(GetLanCCRev_T))
- // {
- // memcpy((char*)pGetSysInfoOEMRes + sizeof(GetSystemInfoParamOEMRes_T) ,\
- // (unsigned int*)oem_addr , oem_len);
- // }
- // else
- // {
- // pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
- // return sizeof(INT8U);
- // }
- // return sizeof(GetSystemInfoParamOEMRes_T) + oem_len;
- // }
- // }
- // else
- // {
- // pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
- // return sizeof(pGetSysInfoRes->CompletionCode);
- // }
- // }
- // /* return the size of the response */
- // return resSize;
- }
- int validatestring(INT8U* String,int len,INT8U TOE)
- {
- int i,delimit = 0,strlen = 0;
- for(i=0;i<len;i++)
- {
- if(String[i] == 0)
- {
- delimit++;
- }
- else
- {
- if(delimit != 0)
- {
- if(TOE == UNICODE)
- {
- if(delimit == 2)
- {
- strlen = strlen + 2;
- }
- else
- {
- return -1;
- }
- }
- else
- {
- if(delimit == 1)
- {
- strlen = strlen + 1;
- }
- else
- {
- return -1;
- }
- }
- delimit = 0;
- }
- strlen++;
- }
- }
- return strlen;
- }
- /*---------------------------------------
- * SetSystemInfoParam
- *---------------------------------------*/
- int
- SetSystemInfoParam (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
- {
- // _NEAR_ SetSystemInfoParamReq_T* pSetSysInfoReq = (_NEAR_ SetSystemInfoParamReq_T*)pReq;
- // _NEAR_ SetSystemInfoParamOEMReq_T* pSetSysInfoOEMReq = (_NEAR_ SetSystemInfoParamOEMReq_T*)pReq;
- // _NEAR_ SetSystemInfoParamRes_T* pSetSysInfoRes = (_NEAR_ SetSystemInfoParamRes_T*)pRes;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
- // _FAR_ SystemInfoConfig_T* pSysInfoCfg;
- // INT8U *pSetInProgress;
- // unsigned long oem_addr[2]={0}; // use oem_addr[1] as read-only/write-only flag
- // int size,strlen,len;
- // INT8U OSName[MAX_OS_NAME_LENGTH] = {0};
- //
- // //If the OEM parameter is existing, then skip the length check.
- // if(g_PDKHandle[PDK_SETSYSINFOPARAM] == NULL && (pSetSysInfoReq->ParamSelector < 192 )){
- // if( !( (SET_IN_PROGRESS_PARAM == pSetSysInfoReq->ParamSelector && ( ReqLen == ( sizeof(pSetSysInfoReq->ParamSelector) + sizeof(INT8U) /* for Data */ ) )) ||
- // ( pSetSysInfoReq->ParamSelector < MAX_PARAM_SELECTOR && ReqLen == ( sizeof(pSetSysInfoReq->ParamSelector) + sizeof(INT8U) /* for set Selector */ + MAX_BLOCK_SIZE))) )
- // {
- // pSetSysInfoRes->CompletionCode = CC_REQ_INV_LEN;
- // return sizeof(pSetSysInfoRes->CompletionCode);
- // }
- // }
- //
- // pSetInProgress = &BMC_GET_SHARED_MEM(BMCInst)->m_Sys_SetInProgress;
- //
- // pSetSysInfoRes->CompletionCode = CC_NORMAL;
- //
- // /*Get NVRAM System Info Configuration parameters */
- // pSysInfoCfg = &pBMCInfo->SystemInfoConfig;
- //
- // switch (pSetSysInfoReq->ParamSelector)
- // {
- // /*Parameter 0 volatile */
- // case SET_IN_PROGRESS_PARAM:
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // /* If Request for Set In progress */
- // if(( SYS_INFO_SET_IN_PROGRESS == *pSetInProgress ) &&
- // ( SYS_INFO_SET_IN_PROGRESS == pSetSysInfoReq->SysInfo.SetInProgress ))
- // {
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // /* Trying to SetinProgress when already in set*/
- // pSetSysInfoRes->CompletionCode = CC_SYS_INFO_SET_IN_PROGRESS ;
- // return sizeof(pSetSysInfoRes->CompletionCode);
- // } else if( SYS_INFO_COMMIT_WRITE == pSetSysInfoReq->SysInfo.SetInProgress )
- // {
- // /* Write SysInfoConfig to NVR */
- // FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig,
- // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SystemInfoConfig_T),BMCInst);
- // /* Write volatile data to the BMC Shared memory */
- //
- // } else if ( SYS_INFO_SET_COMPLETE == pSetSysInfoReq->SysInfo.SetInProgress )
- // {
- // //PMCONFIG_FILE(BMCInst,PMConfigFile);
- // /* Set it to set Complete */
- // *pSetInProgress = pSetSysInfoReq->SysInfo.SetInProgress;
- // FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig,
- // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SystemInfoConfig_T),BMCInst);
- // } else if ( SYS_INFO_SET_IN_PROGRESS != pSetSysInfoReq->SysInfo.SetInProgress )
- // {
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pSetSysInfoRes->CompletionCode);
- // }
- //
- // *pSetInProgress = pSetSysInfoReq->SysInfo.SetInProgress;
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // break;
- //
- // case SYS_FW_VERSION_PARAM:
- //
- // if(pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector >= MAX_BLOCK_SIZE)
- // {
- // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pSetSysInfoRes->CompletionCode);
- // }
- // if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector==ZERO_SETSELECTOR)
- // {
- // if(pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]> MAX_FW_VER_LENGTH)
- // {
- // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pSetSysInfoRes->CompletionCode);
- // }
- // if(pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0] > MAX_TYPE_OF_ENCODING)
- // {
- // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pSetSysInfoRes->CompletionCode);
- // }
- // memset(&pSysInfoCfg->SysFWVersion,0,sizeof(pSysInfoCfg->SysFWVersion));
- // pSysInfoCfg->SysFWVersion.TypeOfEncoding=pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0];
- // pSysInfoCfg->SysFWVersion.StringLength=pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1];
- // /*First character should not be a delimiter*/
- // 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)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- // strlen = validatestring(&pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0]);
- // if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]) || ((pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- // _fmemcpy(&pSysInfoCfg->SysFWVersion.SysFWVersionName[0],&pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2], MAX_STRING_LENGTH_COPY);
- // FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig.SysFWVersion,
- // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysFWVersion_T),BMCInst);
- // }
- // else
- // {
- // _fmemcpy(&pSysInfoCfg->SysFWVersion.SysFWVersionName[(pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector* MAX_BLOCK_SIZE) - 2],
- // &pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0],MAX_BLOCK_SIZE);
- // len = ((pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
- // strlen = validatestring(&pSysInfoCfg->SysFWVersion.SysFWVersionName[0],len,pSysInfoCfg->SysFWVersion.TypeOfEncoding);
- // if(strlen == -1 || (strlen > pSysInfoCfg->SysFWVersion.StringLength))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- // /*Check the String length*/
- // if(((len < pSysInfoCfg->SysFWVersion.StringLength) && (len != strlen)) || ((len > pSysInfoCfg->SysFWVersion.StringLength) && (pSysInfoCfg->SysFWVersion.StringLength != strlen)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- // if((len == pSysInfoCfg->SysFWVersion.StringLength) && (pSysInfoCfg->SysFWVersion.StringLength != strlen))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- //
- // FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,
- // (INT8U*)&pBMCInfo->SystemInfoConfig.SysFWVersion,pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysFWVersion_T),BMCInst);
- // }
- // break;
- //
- // case SYS_NAME_PARAM:
- // if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector >= MAX_BLOCK_SIZE )
- // {
- // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pSetSysInfoRes->CompletionCode);
- // }
- // if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector==ZERO_SETSELECTOR)
- // {
- // if((pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1] > MAX_SYS_NAME_LENGTH))
- // {
- // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pSetSysInfoRes->CompletionCode);
- // }
- // if(pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0]>MAX_TYPE_OF_ENCODING)
- // {
- // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pSetSysInfoRes->CompletionCode);
- // }
- // memset(&pSysInfoCfg->SysName,0,sizeof(pSysInfoCfg->SysName));
- // pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name=pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0];
- // pSysInfoCfg->SysName.StringLength_Sys_Name=pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1];
- //
- // /*First character should not be a delimiter*/
- // 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)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- //
- // strlen = validatestring(&pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0]);
- // if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]) || ((pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- //
- // _fmemcpy(&pSysInfoCfg->SysName.SystemName[0], &pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2],MAX_STRING_LENGTH_COPY);
- // FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig.SysName,
- // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysName_T),BMCInst);
- // }
- // else
- // {
- // _fmemcpy(&pSysInfoCfg->SysName.SystemName[(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector* MAX_BLOCK_SIZE) - 2],
- // &pSetSysInfoReq->SysInfo.SysNameInfo.SysName,MAX_BLOCK_SIZE);
- // len = ((pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
- // strlen = validatestring(&pSysInfoCfg->SysName.SystemName[0],len,pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name);
- // if(strlen == -1 || (strlen > pSysInfoCfg->SysName.StringLength_Sys_Name))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- // /*Check the String length*/
- // if(((len < pSysInfoCfg->SysName.StringLength_Sys_Name) && (len != strlen)) || ((len > pSysInfoCfg->SysName.StringLength_Sys_Name) && (pSysInfoCfg->SysName.StringLength_Sys_Name != strlen)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- // if((len == pSysInfoCfg->SysName.StringLength_Sys_Name) && (pSysInfoCfg->SysName.StringLength_Sys_Name != strlen))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- //
- // FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig.SysName,
- // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysName_T),BMCInst);
- // }
- // break;
- //
- // case PRIM_OS_NAME_PARAM:
- // if(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector >= MAX_BLOCK_SIZE )
- // {
- // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pSetSysInfoRes->CompletionCode);
- // }
- // if(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector==ZERO_SETSELECTOR)
- // {
- // if((pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1] > MAX_PRIM_OS_NAME_LENGTH))
- // {
- // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pSetSysInfoRes->CompletionCode);
- //
- // }
- // if(pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0]>MAX_TYPE_OF_ENCODING)
- // {
- // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pSetSysInfoRes->CompletionCode);
- // }
- // memset(&pSysInfoCfg->PrimaryOSName,0,sizeof(pSysInfoCfg->PrimaryOSName));
- // pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName=pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0];
- // pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName=pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1];
- //
- // /*First character should not be a delimiter*/
- // 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)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- //
- // strlen = validatestring(&pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0]);
- // if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]) || ((pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- //
- // _fmemcpy(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[0], &pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2], MAX_STRING_LENGTH_COPY);
- // FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,(INT8U*)&pBMCInfo->SystemInfoConfig.PrimaryOSName,
- // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(PrimaryOSName_T),BMCInst);
- // }
- // else
- // {
- // _fmemcpy(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector * MAX_BLOCK_SIZE) - 2],
- // &pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName, MAX_BLOCK_SIZE);
- // len = ((pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
- // strlen = validatestring(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[0],len,pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName);
- // if(strlen == -1 || (strlen > pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- // /*Check the String length*/
- // if(((len < pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (len != strlen)) || ((len > pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName != strlen)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- // if((len == pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName != strlen))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- //
- // FlushIPMI((INT8U*)&pBMCInfo->SystemInfoConfig,
- // (INT8U*)&pBMCInfo->SystemInfoConfig.PrimaryOSName,pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(PrimaryOSName_T),BMCInst);
- // }
- // break;
- //
- // case OS_NAME_PARAM:
- // /*Parameter 4 volatile*/
- // if(pSetSysInfoReq->SysInfo.OSInfo.SetSelector >= MAX_BLOCK_SIZE )
- // {
- // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pSetSysInfoRes->CompletionCode);
- // }
- // if(pSetSysInfoReq->SysInfo.OSInfo.SetSelector==ZERO_SETSELECTOR)
- // {
- // if(pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1] > MAX_OS_NAME_LENGTH)
- // {
- // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pSetSysInfoRes->CompletionCode);
- // }
- // if(pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0] > MAX_TYPE_OF_ENCODING)
- // {
- // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(pSetSysInfoRes->CompletionCode);
- // }
- //
- // /*First character should not be a delimiter*/
- // 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)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- //
- // strlen = validatestring(&pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0]);
- // if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]) || ((pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- //
- // memset(&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName,0,sizeof(OSName_T));
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName=pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0];
- // BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName=pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1];
- // _fmemcpy(&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName, &pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2],
- // MAX_STRING_LENGTH_COPY);
- // UNLOCK_BMC_SHARED_MEM (BMCInst);
- // }
- // else
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy(&OSName[0],&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[0],MAX_OS_NAME_LENGTH);
- // _fmemcpy(&OSName[(pSetSysInfoReq->SysInfo.OSInfo.SetSelector * MAX_BLOCK_SIZE) - 2],&pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName,MAX_BLOCK_SIZE);
- // len = ((pSetSysInfoReq->SysInfo.OSInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
- // strlen = validatestring(&OSName[0],len,BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName);
- // if(strlen == -1 || (strlen > BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // return sizeof(INT8U);
- // }
- // /*Check the String length*/
- // 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)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- // if((len == BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName) && (BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName != strlen))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(INT8U);
- // }
- //
- // _fmemcpy(&(BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[(pSetSysInfoReq->SysInfo.OSInfo.SetSelector * MAX_BLOCK_SIZE) - 2]),
- // &pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName,MAX_BLOCK_SIZE);
- // UNLOCK_BMC_SHARED_MEM (BMCInst);
- // }
- // break;
- //
- // default:
- // if(g_PDKHandle[PDK_SETSYSINFOPARAM] != NULL &&
- // (pSetSysInfoReq->ParamSelector >= 192 && pSetSysInfoReq->ParamSelector <= 255))
- // {
- // oem_addr[0] = (unsigned long)((char*)pSetSysInfoOEMReq + sizeof(SetSystemInfoParamOEMReq_T));
- // size = ((int(*)(INT8U, unsigned long*,int))(g_PDKHandle[PDK_SETSYSINFOPARAM]))(pSetSysInfoReq->ParamSelector, oem_addr ,BMCInst);
- // if(size <= 0)
- // {
- // switch (oem_addr[1]) {
- // case CC_SYS_INFO_READ_ONLY_PARAM:
- // pSetSysInfoRes->CompletionCode = CC_SYS_INFO_READ_ONLY_PARAM;
- // break;
- // default:
- // pSetSysInfoRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
- // }
- // }
- // else
- // {
- // pSetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
- // return sizeof(pSetSysInfoRes->CompletionCode);
- // }
- // }
- // }
- // return sizeof(pSetSysInfoRes->CompletionCode);
- }
- //#endif /* APP_DEVICE */
|