AppDevice.c 151 KB

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