AppDevice.c 155 KB

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