1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631 |
- /****************************************************************
- ****************************************************************
- ** **
- ** (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>
- *
- *****************************************************************/
- #include "com_BmcType.h"
- #include "Support.h"
- #include "com_IPMIDefs.h"
- #include "com_IPMI_IPM.h"
- #include "com_IPMI_AppDevice.h"
- #include "AppDevice.h"
- #include "RMCP.h"
- #include "Session.h"
- #include "PMConfig.h"
- #include "main.h"
- #include <string.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
- /*macro definitions for set user password options*/
- #define DISABLE_USER 0
- #define ENABLE_USER 1
- #define SET_PASSWORD 2
- #define TEST_PASSWORD 3
- #define MAX_LAN_CHANNELS 1
- #define LAN_RMCP_CHANNEL1_TYPE 0x01
- #define LAN_RMCP_CHANNEL2_TYPE 0x02
- #define LAN_RMCP_CHANNEL3_TYPE 0x03
- /*** Global variables ***/
- uint8_t g_TmrRunning;
- /*** Module variables ***/
- static MsgPkt_T m_MsgPkt; /**< Message Packet for posting and retrieving messaged to/from queue */
- static uint8_t m_Set_ChReserveBit[] ={0xF0,0x0,0x30};
- //extern IfcName_T Ifcnametable[MAX_LAN_CHANNELS];
- //static void UpdateCurrentEnabledUserCount(int value, int bmcInstId)
- //{
- // if (value == 0) return;
- // ChannelInfo_T* pChannelInfo = NULL;
- // ChannelInfo_T* pNvrChannelInfo = NULL;
- // BMCInfo_t* pBMCInfo = &g_BMCInfo[bmcInstId];
- // uint8_t maxUserCount = pBMCInfo->IpmiConfig.MaxChUsers;
- // uint8_t 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((uint8_t*)pNvrChannelInfo,pNvrChannelInfo->ChannelNumber,bmcInstId);
- //}
- //}
- //static int IsPrivilegeAvailable(uint8_t requestedPrivilege, uint8_t channelNumber, int bmcInstId)
- //{
- // // PMConfig_T* pPMConfig = ( PMConfig_T*) GetNVRAddr(NVRH_PMCONFIG, bmcInstId);
- // BMCInfo_t *pBMCInfo = &g_BMCInfo[bmcInstId];
- // uint8_t EthIndex = GetEthIndex(channelNumber & 0x0F, bmcInstId);
- // uint8_t 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( uint8_t* Data)
- {
- int i=0;
- uint8_t chksum=0;
- for (i = 0; i < 3; i++)
- {
- chksum += *(Data + i);
- }
- if (chksum != 0)
- {
- return FALSE;
- }
- return TRUE;
- }
- ///*-------------------------------------
- //* ResetWDT
- //*-------------------------------------*/
- //int
- //ResetWDT ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- //{
- // uint8_t 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((uint8_t*)&pBMCInfo->WDTConfig,(uint8_t*)&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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- //{
- // SetWDTReq_T* pSetWDTReq = ( SetWDTReq_T*)pReq;
- //#if GET_MSG_FLAGS != UNIMPLEMENTED
- // GetMsgFlagsRes_T GetMsgFlagsRes;
- //#endif
- // 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 (( uint8_t*)&pBMCInfo->WDTConfig, 0, sizeof (WDTConfig_T));
- // _fmemcpy (( uint8_t*)&pBMCInfo->WDTConfig, ( uint8_t*)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, (uint8_t *)&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((uint8_t*)&pBMCInfo->WDTConfig,(uint8_t*)&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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- //{
- // GetWDTRes_T* pGetWDTRes = ( GetWDTRes_T*)pRes;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
- // /* Copy the current settings from the NVRAM */
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (( uint8_t*)&pGetWDTRes->CurrentSettings,
- // ( uint8_t*)&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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- //{
- // uint8_t 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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- //{
- // GetBMCGblEnblRes_T* pGetBMCGblEnblRes = ( 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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- //{
- // ClearMsgsFlagReq_T* pClearMsgsFlagReq = ( ClearMsgsFlagReq_T*)pReq;
- // uint8_t *kcsifcnum;
- //#if GET_MSG_FLAGS != UNIMPLEMENTED
- // GetMsgFlagsRes_T GetMsgFlagsRes;
- //#endif
- // 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((uint8_t*)&pBMCInfo->WDTConfig,(uint8_t*)&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, (uint8_t *)&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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- // {
- // GetMsgFlagsRes_T* pGetMsgFlagsRes = ( GetMsgFlagsRes_T*)pRes;
- // uint8_t *kcsifcnum;
- // /* 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;
- // return sizeof (GetMsgFlagsRes_T);
- // }
- ///*---------------------------------------
- //* EnblMsgChannelRcv
- //*---------------------------------------*/
- //int
- //EnblMsgChannelRcv ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- //{
- // EnblMsgChRcvReq_T* pEnblMsgChRcvReq = ( EnblMsgChRcvReq_T*)pReq;
- // EnblMsgChRcvRes_T* pEnblMsgChRcvRes = ( EnblMsgChRcvRes_T*)pRes;
- // 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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- GetMsgRes_T* pGetMsgRes = ( GetMsgRes_T*)pRes;
- uint8_t Index = 0,*kcsifcnum;
- #if GET_MSG_FLAGS != UNIMPLEMENTED
- GetMsgFlagsRes_T GetMsgFlagsRes;
- #endif
- printf("GetMessage!\n");
- // if (0 != GetMsg (&m_MsgPkt, &g_RcvMsgQ[*kcsifcnum][0], WAIT_NONE))
- // {
- // /* if Queue is Empty */
- // pGetMsgRes->CompletionCode = CC_GET_MSG_QUEUE_EMPTY;
- // return sizeof (*pRes);
- // }
- // #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, (uint8_t *)&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 (( uint8_t*)&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. */
- return 1;
- }
- /*---------------------------------------
- * SendMessage
- *---------------------------------------*/
- int
- SendMessage ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- SendMsgReq_T* pSendMsgReq = ( SendMsgReq_T*)pReq;
- SendMsgRes_T* pSendMsgRes = ( SendMsgRes_T*)pRes;
- IPMIMsgHdr_T* pIPMIMsgHdr;
- int Queuefd = 0;
- uint8_t Tracking;
- uint8_t Channel=0,resaddr=0;
- uint8_t ResLen = 1;
- uint8_t RetVal = 0;
- uint8_t Offset = 1;
- uint8_t SeqNum = g_BMCInfo.SendMsgSeqNum;
- uint8_t PBTbl = PRIMARY_PB_TBL;
- uint8_t SrcSessionHndl = 0;
- ChannelInfo_T* pChannelInfo;
- MsgPkt_T ResPkt;
- SessionInfo_T* pSessionInfo = NULL;
- uint32_t *CurSesID;
- uint8_t *curprivlevel,*curchannel,*kcsifcnum;
- *pRes = CC_NORMAL;
- 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);
- }
- CurSesID = pthread_getspecific(g_tls.CurSessionID);
- curchannel = pthread_getspecific(g_tls.CurChannel);
- kcsifcnum = pthread_getspecific(g_tls.CurKCSIfcNum);
-
- m_MsgPkt.Param = BRIDGING_REQUEST;
- m_MsgPkt.Channel = Channel;
- m_MsgPkt.Size = ReqLen - 1; /* -1 to skip channel num */
- /* Copy the message data */
- memcpy (m_MsgPkt.Data, &pReq[1], m_MsgPkt.Size);
- /* Copy the IPMI Message header */
- pIPMIMsgHdr = ( IPMIMsgHdr_T*)&m_MsgPkt.Data[Offset - 1];
- if(ValidateIPMBChksum1(( uint8_t*)pIPMIMsgHdr) == FALSE)
- {
- *pRes = CC_INV_DATA_FIELD;
- printf("Invalid checksum1\n");
- return sizeof (*pRes);
- }
- if(m_MsgPkt.Data[ReqLen - 2] != CalculateCheckSum2 (( uint8_t*)pIPMIMsgHdr, ReqLen - Offset - 1))
- {
- *pRes = CC_INV_DATA_FIELD;
- return sizeof (*pRes);
- }
- #if 0
- int z;
- printf("m_MsgPkt: ");
- for(z = 0; z < m_MsgPkt.Size;z++)
- printf("%02x ", m_MsgPkt.Data[z]);
- printf("\n");
- #endif
- // printf("---> curchannel: %d, Channel: %d\n", *curchannel, Channel);
- if((Channel == PRIMARY_IPMB_CHANNEL) && g_BMCInfo.IpmiConfig.PrimaryIPMBSupport == 1)
- {
- //printf ("SendMsg: To Primary IPMB Interface\n");
- m_MsgPkt.SrcQ = gFd_PrimaryIpmbIfcQ;
- }
- else if(( Channel == SECONDARY_IPMB_CHANNEL) && (g_BMCInfo.IpmiConfig.SecondaryIPMBSupport == 1))
- {
- //printf ("SendMsg: To Secondary IPMB Interface\n");
- m_MsgPkt.SrcQ = gFd_SecondaryIpmbIfcQ;
- }
- else
- {
- printf ("SendMsg: Invalid Channel\n");
- *pRes = CC_DEST_UNAVAILABLE;
- return sizeof (*pRes);
- }
- if (1 == Tracking)
- {
- ResLen = 0;
- //printf("---> Tracking, curchannel %d, ", *curchannel);
- /* Tracking is not required if originator is System ifc */
- if (SYS_IFC_CHANNEL == (*curchannel & 0xF))
- {
- *pRes = CC_INV_DATA_FIELD;
- return sizeof (*pRes);
- }
- if(*curchannel == LAN_RMCP_CHANNEL)
- {
- pSessionInfo = getSessionInfo (SESSION_ID_INFO, CurSesID);
- //printf("SendMEssage/CurSesID %#x, SessionHandle %#x\n", *CurSesID, pSessionInfo->SessionHandle);
- if (NULL != pSessionInfo)
- {
- g_BMCInfo.SessionHandle = pSessionInfo->SessionHandle;
- }
- else
- {
- printf("Error: Not get valid session!\n");
- *pRes = CC_UNSPECIFIED_ERR;
- return sizeof(*pRes);
- }
- }
-
- PBTbl = (Channel == SECONDARY_IPMB_CHANNEL) ? SECONDARY_PB_TBL : PRIMARY_PB_TBL ;
- //printf("PBTbl %d, g_BMCInfo.SendMsgSeqNum %d, ", PBTbl, g_BMCInfo.SendMsgSeqNum);
- /* Store in the table for response tracking */
- while(TRUE)
- {
- if (FALSE == m_PendingBridgedResTbl[PBTbl][SeqNum].Used)
- {
- m_PendingBridgedResTbl[PBTbl][SeqNum].TimeOut = g_BMCInfo.IpmiConfig.SendMsgTimeout;
- m_PendingBridgedResTbl[PBTbl][SeqNum].ChannelNum = (*curchannel & 0xF);
- m_PendingBridgedResTbl[PBTbl][SeqNum].OriginSrc = ORIGIN_SENDMSG;
- g_BMCInfo.SendMsgSeqNum = SeqNum;
-
- if (1 != Offset)
- {
- //TODO:这个貌似没用到?
- m_PendingBridgedResTbl[PBTbl][SeqNum].DstSessionHandle = pReq[Offset]; /* Session handle */
- }
- m_PendingBridgedResTbl[PBTbl][SeqNum].SrcSessionHandle = pSessionInfo->SessionHandle;// SrcSessionHndl;
-
- memcpy (&m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr, pIPMIMsgHdr, sizeof (IPMIMsgHdr_T));
- /* Format the IPMI Msg Hdr */
- if(Channel == PRIMARY_IPMB_CHANNEL)
- {
- pIPMIMsgHdr->ReqAddr = g_BMCInfo.PrimaryIPMBAddr;
- }
- else if(Channel == SECONDARY_IPMB_CHANNEL)
- {
- pIPMIMsgHdr->ReqAddr = g_BMCInfo.SecondaryIPMBAddr;
- }
- else
- {
- printf("Invalid channel %d\n", Channel);//pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
- }
- pIPMIMsgHdr->RqSeqLUN = (g_BMCInfo.SendMsgSeqNum << 2) & 0xFC; /* Seq Num and LUN =00 */
- /* Recalculate the checksum */
- m_MsgPkt.Data[ReqLen - 2] = CalculateCheckSum2 (( uint8_t*)pIPMIMsgHdr, ReqLen - Offset - 1);
- if((*curchannel & 0xF) == LAN_RMCP_CHANNEL)
- {
- m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ = gFd_LanIfcQ;
-
- }
- else if((*curchannel & 0xF) == UDS_CHANNEL)
- {
- m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ = gFdUdsIfc;
- }
- else
- {
- printf("Not support channel! %d\n", *curchannel);
- *pRes = CC_PARAM_OUT_OF_RANGE;
- return 1;
- }
- m_PendingBridgedResTbl[PBTbl][SeqNum].Used = TRUE;
- m_PendingBridgedResTbl[PBTbl][SeqNum].SeqNum = SeqNum;
- m_PendingBridgedResTbl[PBTbl][SeqNum].ResDataOk = 0;
- //printf( "SendMessage SeqNum %d, ", SeqNum);
- //memcpy (&m_PendingBridgedResTbl[PBTbl][SeqNum].ResMsgHdr, pRes->Data, sizeof (IPMIMsgHdr_T));
- break;
- }
- else
- {
- SeqNum = (SeqNum + 1) & 0x3F;
- if (SeqNum == g_BMCInfo.SendMsgSeqNum) //转了一圈,没有空闲的SeqNum可用。
- {
- /* 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);
- }
- }
- }
- }
- else
- {
- pSendMsgRes->CompletionCode = 0xff;
- return 1;
- }
- // printf ("SendMsgCmd:Posting to interface ");
- // int y;
- // for(y=0;y<m_MsgPkt.Size;y++)
- // printf("%#x ", m_MsgPkt.Data[y]);
- // printf("\n");
- m_MsgPkt.Cmd = PAYLOAD_IPMI_MSG;
- /* Post the message to interface */
- if (0 != PostMsg (m_MsgPkt.SrcQ, &m_MsgPkt))
- {
- printf ("Warning: SendMsg Failed to post message to interface queue\n");
- }
- pSendMsgRes->CompletionCode = CC_NORMAL;
-
- return ResLen;
- }
- ///*---------------------------------------
- //* ReadEvtMsgBuffer
- //*---------------------------------------*/
- //int
- //ReadEvtMsgBuffer ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- //{
- // ReadEvtMsgBufRes_T* pReadEvtMsgBufRes = ( ReadEvtMsgBufRes_T*)pRes;
- //#if GET_MSG_FLAGS != UNIMPLEMENTED
- // GetMsgFlagsRes_T GetMsgFlagsRes;
- //#endif
- // 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, (uint8_t *)&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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- //{
- // GetBTIfcCapRes_T* pGetBTIfcCapRes = ( 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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- //{
- // GetSysGUIDRes_T* pGetSysGUIDRes = ( 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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- //TODO: dummy data
- // GetChAuthCapReq_T* pGetChAuthCapReq = ( GetChAuthCapReq_T*)pReq;
- GetChAuthCapRes_T* pGetChAuthCapRes = ( GetChAuthCapRes_T*)pRes;
- pGetChAuthCapRes->CompletionCode = CC_NORMAL;
- pGetChAuthCapRes->ChannelNum = LAN_RMCP_CHANNEL;
- pGetChAuthCapRes->AuthType = 0x36;
- pGetChAuthCapRes->PerMsgUserAuthLoginStatus = 0x04;
- pGetChAuthCapRes->ExtCap = 0;
- pGetChAuthCapRes->OEMID[0] = 0;
- pGetChAuthCapRes->OEMID[1] = 0;
- pGetChAuthCapRes->OEMID[2] = 0;
- pGetChAuthCapRes->OEMAuxData = 0;
-
- return sizeof (GetChAuthCapRes_T);
- }
- /*---------------------------------------
- * GetSessionChallenge
- * Create session in this function
- *---------------------------------------*/
- int
- GetSessionChallenge ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- GetSesChallengeReq_T* pGetSesChalReq = ( GetSesChallengeReq_T*)pReq;
- GetSesChallengeRes_T* pGetSesChalRes = ( GetSesChallengeRes_T*)pRes;
- uint8_t Index;
- uint8_t ChallengeString[CHALLENGE_STR_LEN];
- UserInfo_T *pUserInfo;
- uint32_t TempSessId;
- SessionInfo_T SessionInfo;
- uint8_t *curchannel;
- uint32_t TempRandom;
- if(pGetSesChalReq->UserName[0] == 0)
- {
- pGetSesChalRes->CompletionCode = 0x82;
- return sizeof (*pRes);
- }
-
- g_BMCInfo.pUserInfo = NULL;
- pUserInfo = getUserNameInfo(pGetSesChalReq->UserName);
- if((pUserInfo == NULL) || (TRUE != pUserInfo->UserStatus))
- {
- pGetSesChalRes->CompletionCode = 0x81;
- return sizeof (*pRes);
- }
- curchannel = pthread_getspecific(g_tls.CurChannel);
- do
- {
- /*generate 32 bit temp session Id*/
- TempSessId = stm32_generate_random32bit();
- } while ((NULL != getSessionInfo (SESSION_ID_INFO, &TempSessId)) || (0 == TempSessId));
- SessionInfo.UserId = (uint8_t)pUserInfo->UserId;
- /*Activated in ActivateSession Command*/
- SessionInfo.Activated = FALSE;
- SessionInfo.AuthType = pGetSesChalReq->AuthType;
- SessionInfo.Channel = *curchannel & 0xF;
- SessionInfo.SessionID = TempSessId;
- SessionInfo.TimeOutValue = g_BMCInfo.IpmiConfig.SessionTimeOut;
- if(GetNumOfUsedSessions() >= g_BMCInfo.IpmiConfig.MaxSession)
- {
- CleanSession();
- }
- /* Add Session information in Table */
- AddSession (&SessionInfo);
- g_BMCInfo.pUserInfo = pUserInfo;
-
- pGetSesChalRes->CompletionCode = CC_NORMAL;
- pGetSesChalRes->TempSessionID = TempSessId;
- /* generate Randam Challenge String */
- for(Index=0;Index < CHALLENGE_STR_LEN;Index+=4)
- {
- TempRandom = stm32_generate_random32bit();
- // printf("TempRandom: %#lx\n", TempRandom);
- ChallengeString[Index] = TempRandom&0xff;
- ChallengeString[Index+1] = TempRandom>>8;
- ChallengeString[Index+2] = TempRandom>>16;
- ChallengeString[Index+3] = TempRandom>>24;
- }
- memcpy(pGetSesChalRes->ChallengeString, ChallengeString, CHALLENGE_STR_LEN);
- return sizeof (GetSesChallengeRes_T);
- }
- /*---------------------------------------
- * ActivateSession
- *---------------------------------------*/
- int
- ActivateSession ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- //TODO: dummy data
- ActivateSesReq_T* pAcvtSesReq = ( ActivateSesReq_T*)pReq;
- ActivateSesRes_T* pAcvtSesRes = ( ActivateSesRes_T*)pRes;
- uint32_t *CurSesID,*curchannel;
- SessionInfo_T* pSessInfo;
- /* Initial Outbound Sequence Number cannot be null */
- if (pAcvtSesReq->OutboundSeq == 0)
- {
- pAcvtSesRes->CompletionCode = CC_ACTIVATE_SESS_SEQ_OUT_OF_RANGE;
- return sizeof(*pRes);
- }
- CurSesID = pthread_getspecific(g_tls.CurSessionID);
- curchannel = pthread_getspecific(g_tls.CurChannel);
-
- pSessInfo = getSessionInfo (SESSION_ID_INFO, CurSesID);
- if(pSessInfo == NULL)
- {
- pAcvtSesRes->CompletionCode = CC_ACTIVATE_SESS_INVALID_SESSION_ID;
- return sizeof (*pRes);
- }
- pSessInfo->Activated = TRUE;
- pSessInfo->Channel = (*curchannel & 0xF);
- /* set the Max Privilege allowed for the Session*/
- pSessInfo->MaxPrivilege = pAcvtSesReq->Privilege;
- /* set the Out bound sequensce Number */
- pSessInfo->OutboundSeq = (pAcvtSesReq->OutboundSeq);
- g_BMCInfo.SessionHandle += 1;
- pSessInfo->SessionHandle = g_BMCInfo.SessionHandle;
- pAcvtSesRes->CompletionCode = CC_NORMAL;
- pAcvtSesRes->AuthType = (pSessInfo->AuthType & 0x0F);
- pAcvtSesRes->SessionID = pSessInfo->SessionID;
- pAcvtSesRes->InboundSeq = stm32_generate_random32bit();
- pAcvtSesRes->Privilege = 0x04;
- pSessInfo->InboundRecv = 0xFF;
- pSessInfo->InboundSeq = (pAcvtSesRes->InboundSeq -1);
- return sizeof (ActivateSesRes_T);
- }
- /*---------------------------------------
- * SetSessionPrivLevel
- *---------------------------------------*/
- int
- SetSessionPrivLevel ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- SetSesPrivLevelReq_T* pSetSesPrivLevelReq = ( SetSesPrivLevelReq_T*)pReq;
- SetSesPrivLevelRes_T* pSetSesPrivLevelRes = ( SetSesPrivLevelRes_T*)pRes;
- //Check for Reserved bits
- if((pSetSesPrivLevelReq->Privilege == PRIV_LEVEL_CALLBACK) || (pSetSesPrivLevelReq->Privilege > PRIV_LEVEL_PROPRIETARY))
- {
- pSetSesPrivLevelRes->CompletionCode = CC_INV_DATA_FIELD;
- return sizeof(SetSesPrivLevelRes_T);
- }
-
- /* According to the IPMI 2.0 Priv Level =1 is reserved */
- if((PRIV_USER != pSetSesPrivLevelReq->Privilege) &&
- (PRIV_OPERATOR != pSetSesPrivLevelReq->Privilege) &&
- (PRIV_ADMIN != pSetSesPrivLevelReq->Privilege) &&
- (PRIV_OEM != pSetSesPrivLevelReq->Privilege))
- {
- /*Requested Privilege exceeds ChannelPrivilege Limit */
- pSetSesPrivLevelRes->CompletionCode = CC_INV_DATA_FIELD;
- return sizeof (*pRes);
- }
- pSetSesPrivLevelRes->CompletionCode = CC_NORMAL;
- pSetSesPrivLevelRes->Privilege = pSetSesPrivLevelReq->Privilege;
- return sizeof (SetSesPrivLevelRes_T);
- }
- /*---------------------------------------
- * CloseSession
- *---------------------------------------*/
- int
- CloseSession ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- CloseSesReq_T* pCloseSesReq = (CloseSesReq_T*)pReq;
- SessionInfo_T* pSessInfo;
- uint32_t SessionID;
- *pRes = CC_REQ_INV_LEN;
- if ((4 != ReqLen) && (5 != ReqLen))
- {
- return sizeof (*pRes);
- }
- if (0 == pCloseSesReq->SessionID)
- {
- if (5 != ReqLen)
- {
- return sizeof (*pRes);
- }
- SessionID = (uint32_t)pCloseSesReq->SessionHandle;
- *pRes = CC_CLOSE_INVALID_SESSION_ID_HANDLE;
- pSessInfo = getSessionInfo (SESSION_HANDLE_INFO, &SessionID);
- }
- else
- {
- if (4 != ReqLen)
- {
- return sizeof (*pRes);
- }
- SessionID = pCloseSesReq->SessionID;
- *pRes = CC_CLOSE_INVALID_SESSION_ID;
- pSessInfo = getSessionInfo (SESSION_ID_INFO, &SessionID);
- }
- if ((NULL == pSessInfo) || (0 == pSessInfo->Activated))
- {
- return sizeof (*pRes);
- }
- /* The SessionInfo is deleted form session table from interface */
- DeleteSession(pSessInfo);
- *pRes = CC_NORMAL;
- return sizeof (*pRes);
- }
- //#if GET_SESSION_INFO != UNIMPLEMENTED
- ///*---------------------------------------
- //* GetSessionInfo
- //*---------------------------------------*/
- //int
- //GetSessionInfo ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- //{
- // GetSesInfoReq_T* pGetSesInfoReq = ( GetSesInfoReq_T*)pReq;
- // GetSesInfoRes_T* pGetSesInfoRes = ( GetSesInfoRes_T*)pRes;
- // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // LANSesInfoRes_T LANSesInfo;
- // LANIPv6SesInfoRes_T LANIPv6SesInfo;
- // SessionInfo_T* pSessInfo;
- // ChannelInfo_T* pChannelInfo;
- // void* SessionArg;
- // uint8_t SessionArgAlign[4];
- // uint8_t SessionArgType,EthIndex, netindex = 0xFF;
- // char IfcName[IFNAMSIZ];
- // uint32_t *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 (uint8_t);
- // }
- // 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 (uint8_t);
- // }
- // 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 (uint8_t);
- // }
- // 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((uint8_t*)&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((uint8_t*)&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((uint8_t*)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 )
- //{
- // uint8_t AuthCode;
- // uint8_t InBuffer[2*IPMI15_MAX_PASSWORD_LEN + HASH_DATA_LENGTH];
- // char UserPswd[MAX_PASSWD_LEN];
- // uint8_t PwdEncKey[MAX_SIZE_KEY + 1] = {0};
- // 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 )
- //{
- // uint8_t AuthCode;
- // uint8_t UserPasswdLen=0;
- // uint8_t DecVal = 0;
- // uint8_t m_SIK [SESSION_INTEGRITY_KEY_SIZE];
- // char UserPswd[MAX_PASSWD_LEN];
- // unsigned char PwdEncKey[MAX_SIZE_KEY + 1] = {0};
- // 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 (( 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 ((uint8_t *)UserPswd, UserPasswdLen,
- // (uint8_t *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
- // (uint8_t *)m_SIK, SESSION_INTEGRITY_KEY_SIZE);
- // hmac_sha1 ((uint8_t *)m_SIK, SESSION_INTEGRITY_KEY_SIZE,
- // (uint8_t *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
- // (uint8_t *)&(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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes )
- //{
- // GetAuthCodeReq_T* pGetAuthCodeReq = ( GetAuthCodeReq_T*)pReq;
- // GetAuthCodeRes_T* pGetAuthCodeRes = ( GetAuthCodeRes_T*)pRes;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
- // UserInfo_T* pUserInfo;
- // uint8_t AuthType,*curchannel;
- // ChannelInfo_T* pChannelInfo;
- // int nRetSize = 0;
- // /* 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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- //{
- // SetChAccessReq_T* pSetChAccessReq = ( SetChAccessReq_T*)pReq;
- // uint8_t ChannelNum, AccessMode;
- // ChannelInfo_T* pNvrChInfo;
- // ChannelInfo_T* pChannelInfo;
- // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // uint8_t 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(*)(uint8_t, 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((uint8_t*)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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- //{
- // GetChAccessReq_T* pGetChAccessReq = ( GetChAccessReq_T*)pReq;
- // GetChAccessRes_T* pGetChAccessRes = ( GetChAccessRes_T*)pRes;
- // ChannelInfo_T* pChannelInfo;
- // ChannelInfo_T* pNvrChInfo;
- // uint8_t 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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- GetChInfoReq_T* pGetChInfoReq = ( GetChInfoReq_T*)pReq;
- GetChInfoRes_T* pGetChInfoRes = ( GetChInfoRes_T*)pRes;
- ChannelInfo_T* pChannelInfo;
- uint8_t 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)
- {
- curchannel = pthread_getspecific(g_tls.CurChannel);
- ChannelNum = *curchannel & 0xF;
-
- /* UDS, not being a physical channel, will hold LAN properties */
- if(UDS_CHANNEL == ChannelNum)
- {
- ChannelNum = LAN_RMCP_CHANNEL1_TYPE;
- }
- }
- pChannelInfo = getChannelInfo(ChannelNum);
- if (NULL == pChannelInfo)
- {
- 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;
- memcpy (pGetChInfoRes->VendorID, pChannelInfo->ProtocolVendorId,
- sizeof (pGetChInfoRes->VendorID));
- memcpy (pGetChInfoRes->AuxiliaryInfo, pChannelInfo->AuxiliaryInfo,
- sizeof (pGetChInfoRes->AuxiliaryInfo));
- return sizeof (GetChInfoRes_T);
- }
- ///*---------------------------------------
- //* IsChannelSuppGroups
- //*---------------------------------------*/
- //uint8_t IsChannelSuppGroups(uint8_t ChannelNum )
- //{
- // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // 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,uint8_t ChannelNum,uint8_t OldAccessLimit, uint8_t 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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- SetUserAccessReq_T* pSetUserAccessReq = ( SetUserAccessReq_T*)pReq;
- UserInfo_T* pUserInfo;
-
- 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);
- }
- pUserInfo = getUserIdInfo(pSetUserAccessReq->UserID);
- if (NULL == pUserInfo)
- {
- printf ("AppDevice.c : SetUserAccess - Invalid user Id\n");
- *pRes = CC_INV_DATA_FIELD;
- return sizeof (*pRes);
- }
- // if (pUserInfo->ID != USER_ID)
- // {
- // printf("Invalid data field\n");
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
-
- // pUserInfo->ChannelAccess = (pSetUserAccessReq->ChannelNoUserAccess&0x70) | (pSetUserAccessReq->AccessLimit&0x0f);
- *pRes = CC_NORMAL;
- return sizeof (*pRes);
- }
- /*---------------------------------------
- * GetUserAccess
- *---------------------------------------*/
- int
- GetUserAccess ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- GetUserAccessReq_T* pGetUserAccessReq = ( GetUserAccessReq_T*)pReq;
- GetUserAccessRes_T* pGetUserAccessRes = ( GetUserAccessRes_T*)pRes;
- UserInfo_T* pUserInfo;
- pUserInfo = getUserIdInfo (pGetUserAccessReq->UserID);
- if (NULL == pUserInfo)
- {
- pGetUserAccessRes->CompletionCode = CC_INV_DATA_FIELD;
- return sizeof (*pRes);
- }
- if(FALSE == pUserInfo->UserStatus)
- pGetUserAccessRes->ChannelAccess = 0x0F;
- else
- pGetUserAccessRes->ChannelAccess = 0x34;
- pGetUserAccessRes->CompletionCode = CC_NORMAL;
- pGetUserAccessRes->MaxNoUserID = MAX_USER_NUM;
- pGetUserAccessRes->CurrentUserID = g_BMCInfo.CurrentNoUser;
- pGetUserAccessRes->FixedUserID = 0;
-
- return sizeof (GetUserAccessRes_T);
- }
- /*---------------------------------------
- * SetUserName
- *---------------------------------------*/
- int
- SetUserName ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes) //default password 123456
- {
- SetUserNameReq_T* pSetUserNameReq = ( SetUserNameReq_T*)pReq;
- UserInfo_T* pUserInfo;
- uint8_t i;
- uint8_t UserName[MAX_USERNAME_LEN + 1]; //plus 1 for null terminator
- uint8_t 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} ;
- // 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 > MAX_USER_NUM )
- {
- *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);
- *pRes = CC_INV_DATA_FIELD ;
- return sizeof (*pRes);
- }
- if((strlen(pSetUserNameReq->UserName) > MAX_USERNAME_LEN) || (strlen(pSetUserNameReq->UserName) == 0))
- {
- printf("Invalid username length: %d\n", strlen(pSetUserNameReq->UserName));
- *pRes = CC_INV_DATA_FIELD;
- return 1;
- }
- pUserInfo = getUserIdInfo(pSetUserNameReq->UserID);
- /* check for numeric first char and special chars */
- if( (pSetUserNameReq->UserName[0] >= '0') && (pSetUserNameReq->UserName[0] <= '9') )
- {
- *pRes = CC_INV_DATA_FIELD;
- return sizeof(*pRes);
- }
- else
- {
- strncpy((char *)UserName,(const char *) pSetUserNameReq->UserName, sizeof(pSetUserNameReq->UserName));
- UserName[MAX_USERNAME_LEN] = '\0';
- for(i=0;i<sizeof(InvalidChar);i++)
- {
- if( NULL != strchr((const char *)UserName, InvalidChar[i] ))
- {
- *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)==FALSE)
- {
- printf("Duplicate ipmi user!!\n");
- *pRes = CC_INV_DATA_FIELD;
- return sizeof (*pRes);
- }
- }
- /* If User[0] is 0xFF means the user is requested to delete */
- if (0xFF == pSetUserNameReq->UserName [0]) //delete user
- {
- if( (g_BMCInfo.CurrentNoUser > 1) && (0 != pUserInfo->UserId))
- {
- if(pUserInfo->UserStatus == TRUE)
- {
- g_BMCInfo.CurrentNoUser--;
- }
- /* Delete the user both in Volatile & Non Volatile memory*/
- memset (pUserInfo, 0, sizeof (UserInfo_T));
- }
- else
- {
- *pRes = CC_INV_DATA_FIELD ;
- return sizeof (*pRes);
- }
- }
- else if(0 == pUserInfo->UserId) //add user
- {
- /* If First time-if user ID does not exist */
- /* if the user name is set for the first time */
- pUserInfo->UserId = pSetUserNameReq->UserID;
- pUserInfo->UserStatus = TRUE;
- memcpy(pUserInfo->UserName, pSetUserNameReq->UserName, MAX_USERNAME_LEN);
- strcpy(pUserInfo->UserPassword, "123456");
- g_BMCInfo.CurrentNoUser++;
- }
- else if (0 != pUserInfo->UserId)//modifying users
- {
- memcpy (pUserInfo->UserName, pSetUserNameReq->UserName, MAX_USERNAME_LEN);
- }
- FlushUserInfoTbl();
- *pRes = CC_NORMAL;
- return sizeof (*pRes);
- }
- /*---------------------------------------
- * GetUserName
- *---------------------------------------*/
- int
- GetUserName ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- GetUserNameReq_T* pGetUserNameReq = ( GetUserNameReq_T*)pReq;
- GetUserNameRes_T* pGetUserNameRes = ( GetUserNameRes_T*)pRes;
- UserInfo_T* pUserInfo;
- // Check for Reserved bits
- if(pGetUserNameReq->UserID & (BIT7 | BIT6) || (pGetUserNameReq->UserID == 0x00))
- {
- pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
- return sizeof(*pRes);
- }
- if (pGetUserNameReq->UserID > MAX_USER_NUM)
- {
- /* if user ID exceeded the Max limit */
- pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
- return sizeof (*pRes);/* Invalied user id */
- }
- pUserInfo = getUserIdInfo(pGetUserNameReq->UserID);
- /* 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)*/)
- {
- /* 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)
- {
- *pRes = CC_INV_DATA_FIELD;
- return sizeof (*pRes);
- }
- //Err = 0;
- pGetUserNameRes->CompletionCode = CC_NORMAL;
- memcpy (pGetUserNameRes->UserName, pUserInfo->UserName, MAX_USERNAME_LEN);
- return sizeof (GetUserNameRes_T);
- }
- /*---------------------------------------
- * SetUserPassword
- *---------------------------------------*/
- int
- SetUserPassword ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- SetUserPswdReq_T* pSetUserPswdReq = ( SetUserPswdReq_T*)pReq;
- UserInfo_T* pUserInfo;
- uint8_t UserId=0, Operation;
- uint8_t i;
- uint8_t UserPassword[ MAX_PASSWORD_LEN + 1 ] = {0};
- uint8_t 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;
- /* 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)
- {
- memset (pSetUserPswdReq->Password + 16, 0, 4);
- }
- ReqLen -=2;
- if (UserId > MAX_USER_NUM)
- {
- *pRes = CC_INV_DATA_FIELD;
- return sizeof (*pRes); /*User Id exceeded the limit*/
- }
- pUserInfo = getUserIdInfo (UserId);
- if ( NULL == pUserInfo )
- {
- printf ("Invalid User Id \n");
- *pRes = CC_INV_DATA_FIELD;
- return sizeof (*pRes);
- }
- *pRes = CC_NORMAL;
- switch (Operation)
- {
- case DISABLE_USER:
- //here we can disable the user
- if ((pUserInfo->UserStatus == TRUE) && (g_BMCInfo.CurrentNoUser > 1))
- {
- pUserInfo->UserStatus = FALSE;
- g_BMCInfo.CurrentNoUser--;
- FlushUserInfoTbl();
- }
- break;
- case ENABLE_USER:
- /*enable user */
- if ((0 != pUserInfo->UserId) && (0 != pUserInfo->UserName[0]))
- {
- /* if for the first time then Increment the Current user No */
- if ( pUserInfo->UserStatus == FALSE )
- {
- pUserInfo->UserStatus = TRUE;
- g_BMCInfo.CurrentNoUser++;
- FlushUserInfoTbl();
- }
- }
- else
- {
- *pRes = CC_UNSPECIFIED_ERR;
- return sizeof (*pRes);
- }
- break;
- case SET_PASSWORD:
- /*set password */
- if ((0 != pUserInfo->UserId) && (0 != pUserInfo->UserName[0]))
- {
- /*check for special characters*/
- strncpy((char *)UserPassword,(const char *) pSetUserPswdReq->Password, sizeof(pSetUserPswdReq->Password));
- for( i = 0 ; i < sizeof(InvalidChar) ; i++ )
- {
- if( NULL != strchr((const char *)UserPassword, InvalidChar[i] ))
- {
- *pRes = CC_INV_DATA_FIELD;
- return sizeof(*pRes);
- }
- }
- strcpy(pUserInfo->UserPassword, pSetUserPswdReq->Password);
- FlushUserInfoTbl();
- }
- else
- {
- *pRes = CC_INV_DATA_FIELD;
- return sizeof (*pRes);
- }
- break;
- case TEST_PASSWORD:
- memcpy (UserPassword, pUserInfo->UserPassword, MAX_PASSWORD_LEN);
-
- /*Test Password */
- if ((FALSE == pUserInfo->UserStatus) ||
- (0 != memcmp (UserPassword, pSetUserPswdReq->Password, MAX_PASSWORD_LEN)))
- {
- *pRes = CC_PASSWORD_TEST_FAILED;
- }
- break;
- }
- return sizeof (*pRes);
- }
- ///*---------------------------------------
- //* MasterWriteRead
- //*---------------------------------------*/
- //int
- //MasterWriteRead ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- //{
- // MasterWriteReadReq_T* pMasterWriteReadReq = ( MasterWriteReadReq_T*)pReq;
- // MasterWriteReadRes_T* pMasterWriteReadRes = ( MasterWriteReadRes_T*)pRes;
- // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // uint8_t* OutBuffer;
- // uint8_t* InBuffer;
- // uint8_t ChannelNum, BusID, BusType, SlaveAddr, ReadCount, WriteCount;
- // INT8S BusName[64];
- // int retval = 0;
- // uint8_t OrgReadCount;
- // uint8_t I2CBusId=0;
- // uint8_t DevID = 0; // This will be '0' by Default... /dev/peci0
- // uint8_t Target = 0x30; // This is the Client address. 30h = 48 is Default for CPU0
- // uint8_t Domain = 0; // Multi-Domain support. Default is '0'
- // uint8_t Xmit_Feedback = 0; // If full response is Desired, enable this. Default is '1'
- // uint8_t AWFCS = 0; // Enable AWFCS in the Transmitted packet by Hw. Default is '0'
- // uint8_t Read_Len = 0; // Number of bytes of read back Data from PECI Client
- // uint8_t Write_Len = 0; // Number of bytes of data, host is sending to client
- // uint8_t *Write_Data = NULL; // Pointer to the Data sent by User to the PECI Client
- // uint8_t *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 ( uint8_t* pPassword, SessionHdr_T* pSessionHdr,
- // IPMIMsgHdr_T* pIPMIMsg, uint8_t* pAuthCode,
- // uint8_t ChannelType)
- //{
- // if (AUTH_TYPE_PASSWORD == pSessionHdr->AuthType)
- // {
- // _fmemcpy (pAuthCode, pPassword, MAX_PASSWORD_LEN);
- // }
- // else
- // {
- // uint8_t AuthBuf [MAX_AUTH_PARAM_SIZE];
- // uint16_t AuthBufLen = 0;
- // uint8_t IPMIMsgLen = *(( uint8_t*) pIPMIMsg - 1);
- // /* Password */
- // _fmemcpy (AuthBuf, pPassword, MAX_PASSWORD_LEN);
- // AuthBufLen += MAX_PASSWORD_LEN;
- // /* Session ID */
- // _fmemcpy (AuthBuf + AuthBufLen, &pSessionHdr->SessionID, sizeof (uint32_t));
- // AuthBufLen += sizeof (uint32_t);
- // /* IPMI Response Message */
- // _fmemcpy (AuthBuf + AuthBufLen, pIPMIMsg, IPMIMsgLen);
- // AuthBufLen += IPMIMsgLen;
- // if (ChannelType == MULTI_SESSION_CHANNEL)
- // {
- // /* Session Sequence Number */
- // _fmemcpy (AuthBuf + AuthBufLen,
- // &pSessionHdr->SessionSeqNum, sizeof (uint32_t));
- // AuthBufLen += sizeof (uint32_t);
- // }
- // /* 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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- //{
- // GetSystemInfoParamReq_T* pGetSysInfoReq = ( GetSystemInfoParamReq_T*)pReq;
- // GetSystemInfoParamRes_T* pGetSysInfoRes = ( GetSystemInfoParamRes_T* ) pRes ;
- // GetSystemInfoParamOEMRes_T* pGetSysInfoOEMRes = ( GetSystemInfoParamOEMRes_T* ) pRes ;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
- // SystemInfoConfig_T* pSysInfoCfg;
- // uint8_t resSize = sizeof(pGetSysInfoRes->CompletionCode) + sizeof(pGetSysInfoRes->ParamRevision);
- // uint8_t 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(*)(uint8_t, 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(uint8_t);
- // }
- // 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(*)(uint8_t, 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(uint8_t);
- // }
- // 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(uint8_t);
- // }
- // 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(uint8_t* String,int len,uint8_t 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 ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- //{
- // SetSystemInfoParamReq_T* pSetSysInfoReq = ( SetSystemInfoParamReq_T*)pReq;
- // SetSystemInfoParamOEMReq_T* pSetSysInfoOEMReq = ( SetSystemInfoParamOEMReq_T*)pReq;
- // SetSystemInfoParamRes_T* pSetSysInfoRes = ( SetSystemInfoParamRes_T*)pRes;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
- // SystemInfoConfig_T* pSysInfoCfg;
- // uint8_t *pSetInProgress;
- // unsigned long oem_addr[2]={0}; // use oem_addr[1] as read-only/write-only flag
- // int size,strlen,len;
- // uint8_t 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(uint8_t) /* for Data */ ) )) ||
- // ( pSetSysInfoReq->ParamSelector < MAX_PARAM_SELECTOR && ReqLen == ( sizeof(pSetSysInfoReq->ParamSelector) + sizeof(uint8_t) /* 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((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&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((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&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(uint8_t);
- // }
- // 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(uint8_t);
- // }
- // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(uint8_t);
- // }
- // _fmemcpy(&pSysInfoCfg->SysFWVersion.SysFWVersionName[0],&pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2], MAX_STRING_LENGTH_COPY);
- // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&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(uint8_t);
- // }
- // /*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(uint8_t);
- // }
- // if((len == pSysInfoCfg->SysFWVersion.StringLength) && (pSysInfoCfg->SysFWVersion.StringLength != strlen))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(uint8_t);
- // }
- // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,
- // (uint8_t*)&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(uint8_t);
- // }
- // 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(uint8_t);
- // }
- // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(uint8_t);
- // }
- // _fmemcpy(&pSysInfoCfg->SysName.SystemName[0], &pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2],MAX_STRING_LENGTH_COPY);
- // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&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(uint8_t);
- // }
- // /*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(uint8_t);
- // }
- // if((len == pSysInfoCfg->SysName.StringLength_Sys_Name) && (pSysInfoCfg->SysName.StringLength_Sys_Name != strlen))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(uint8_t);
- // }
- // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&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(uint8_t);
- // }
- // 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(uint8_t);
- // }
- // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(uint8_t);
- // }
- // _fmemcpy(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[0], &pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2], MAX_STRING_LENGTH_COPY);
- // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&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(uint8_t);
- // }
- // /*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(uint8_t);
- // }
- // if((len == pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName != strlen))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(uint8_t);
- // }
- // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,
- // (uint8_t*)&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(uint8_t);
- // }
- // 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(uint8_t);
- // }
- // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(uint8_t);
- // }
- // 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(uint8_t);
- // }
- // /*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(uint8_t);
- // }
- // 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(uint8_t);
- // }
- // _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(*)(uint8_t, 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 */
|