AppDevice.c 152 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767
  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. printf("SendMsg: ReqLen = %d, size = %ld\n",ReqLen,m_MsgPkt.Size);
  816. int z;
  817. printf("m_MsgPkt: \n");
  818. for(z = 0; z < m_MsgPkt.Size;z++)
  819. printf("%02x ", m_MsgPkt.Data[z]);
  820. printf("\n");
  821. #endif
  822. // if(pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
  823. // {
  824. // /* To Check the Wheather Serial Channel */
  825. // if (pBMCInfo->SERIALch != CH_NOT_USED && (*curchannel & 0xF) == pBMCInfo->SERIALch && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
  826. // {
  827. // SessionInfo_T* pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID,BMCInst);
  828. // if (NULL != pSessionInfo)
  829. // {
  830. // SrcSessionHndl = pSessionInfo->SessionHandle;
  831. // }
  832. // TDBG ("SendMsg: To Serial Interface for reference\n");
  833. // // Offset++; : causes bridging issues
  834. // strcpy ((char *)m_MsgPkt.SrcQ, SERIAL_IFC_Q);
  835. // }
  836. // }
  837. printf("curchannel: %d, Channel: %d\n", *curchannel, Channel);
  838. if(g_BMCInfo.IpmiConfig.LANIfcSupport == 1)
  839. {
  840. /* To Check the Wheather LAN Channel */
  841. //if (IsLANChannel(*curchannel & 0xF, BMCInst))
  842. if(*curchannel&0xf == LAN_RMCP_CHANNEL) //jimbo
  843. {
  844. SessionInfo_T* pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID);
  845. if (NULL != pSessionInfo)
  846. {
  847. SrcSessionHndl = pSessionInfo->SessionHandle;
  848. }
  849. printf ("SendMsg: To LAN Interface for reference\n");
  850. // Offset++; : causes bridging issues
  851. strcpy ((char *)m_MsgPkt.SrcQ, LAN_IFC_Q);
  852. }
  853. }
  854. if((Channel == PRIMARY_IPMB_CHANNEL) && g_BMCInfo.IpmiConfig.PrimaryIPMBSupport == 1)
  855. {
  856. printf ("SendMsg: To Primary IPMB Interface\n");
  857. m_MsgPkt.SrcQ = gFd_PrimaryIpmbIfcQ;
  858. }
  859. else if(( Channel == SECONDARY_IPMB_CHANNEL) && (g_BMCInfo.IpmiConfig.SecondaryIPMBSupport == 1))
  860. {
  861. printf ("SendMsg: To SMLink IPMB Interface\n");
  862. m_MsgPkt.SrcQ = gFd_SecondaryIpmbIfcQ;
  863. }
  864. // else if ((pBMCInfo->SERIALch != CH_NOT_USED && Channel == pBMCInfo->SERIALch) && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
  865. // {
  866. // TDBG ("SendMsg: To Serial Interface\n");
  867. // Offset++;
  868. // strcpy ((char *)m_MsgPkt.SrcQ, SERIAL_IFC_Q);
  869. // }
  870. // else if ((pBMCInfo->ICMBCh != CH_NOT_USED && Channel == pBMCInfo->ICMBCh) && pBMCInfo->IpmiConfig.ICMBIfcSupport == 1)
  871. // {
  872. // TDBG ("SendMsg: To ICMB Interface\n");
  873. // strcpy ((char *)m_MsgPkt.SrcQ, ICMB_IFC_Q);
  874. // }
  875. // else if(pBMCInfo->SYSCh != CH_NOT_USED && Channel == pBMCInfo->SYSCh)
  876. // {
  877. // TDBG ("SendMsg: To System Interface\n");
  878. // /*
  879. // * According to IPMI Spec v2.0.
  880. // * It is recommended to send CC_DEST_UNAVAILABLE
  881. // * completion code, if the channel is disabled for
  882. // * receiving messages.
  883. // * */
  884. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  885. // pChannelInfo = getChannelInfo(Channel,BMCInst);
  886. // if(NULL == pChannelInfo)
  887. // {
  888. // *pRes = CC_INV_DATA_FIELD;
  889. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  890. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  891. // return sizeof (*pRes);
  892. // }
  893. // if (0x0 == pChannelInfo->ReceiveMsgQ)
  894. // {
  895. // printf ("The Channel(0x%x) has been Disabled "
  896. // "for Receive message\n", Channel);
  897. // *pRes = CC_DEST_UNAVAILABLE;
  898. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  899. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  900. // return sizeof (*pRes);
  901. // }
  902. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  903. // strcpy ((char *)m_MsgPkt.SrcQ, &g_RcvMsgQ[*kcsifcnum][0]);
  904. // m_MsgPkt.Param = SrcSessionHndl;
  905. // }
  906. else
  907. {
  908. printf ("SendMsg: Invalid Channel\n");
  909. *pRes = CC_DEST_UNAVAILABLE;
  910. return sizeof (*pRes);
  911. }
  912. // if( (TRUE == pBMCInfo->NMConfig.NMSupport) && (pBMCInfo->NMConfig.NMDevSlaveAddress == pIPMIMsgHdr->ResAddr) &&
  913. // (Channel == (NM_PRIMARY_IPMB_BUS == pBMCInfo->NMConfig.NM_IPMBBus) ? pBMCInfo->PrimaryIPMBCh : pBMCInfo->SecondaryIPMBCh) )
  914. // {
  915. // if( (pBMCInfo->RMCPLAN1Ch == *curchannel) ||
  916. // (pBMCInfo->RMCPLAN2Ch == *curchannel) ||
  917. // (pBMCInfo->RMCPLAN3Ch == *curchannel) ||
  918. // (pBMCInfo->RMCPLAN4Ch == *curchannel) ||
  919. // (pBMCInfo->SERIALch == *curchannel) )
  920. // {
  921. // OS_THREAD_TLS_GET(g_tls.CurPrivLevel,curprivlevel);
  922. // if(PRIV_ADMIN != *curprivlevel)
  923. // {
  924. // TDBG("Insufficient Privilege\n");
  925. // *pRes = CC_INSUFFIENT_PRIVILEGE;
  926. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  927. // return sizeof(*pRes);
  928. // }
  929. // }
  930. // }
  931. if (1 == Tracking)
  932. {
  933. /* Response length is set to zero to make MsgHndlr skip responding to this request
  934. * The Response will be handled by the ipmb interface after verifying NAK.
  935. */
  936. ResLen = 0;
  937. /* Tracking is not required if originator is System ifc */
  938. if (SYS_IFC_CHANNEL == (*curchannel & 0xF))
  939. {
  940. *pRes = CC_INV_DATA_FIELD;
  941. return sizeof (*pRes);
  942. }
  943. PBTbl = (Channel == SECONDARY_IPMB_CHANNEL) ? SECONDARY_PB_TBL : PRIMARY_PB_TBL ;
  944. /* Store in the table for response tracking */
  945. while(TRUE)
  946. {
  947. if (FALSE == m_PendingBridgedResTbl[PBTbl][SeqNum].Used)
  948. {
  949. m_PendingBridgedResTbl[PBTbl][SeqNum].TimeOut = g_BMCInfo.IpmiConfig.SendMsgTimeout;
  950. m_PendingBridgedResTbl[PBTbl][SeqNum].ChannelNum = (*curchannel & 0xF);
  951. m_PendingBridgedResTbl[PBTbl][SeqNum].OriginSrc = ORIGIN_SENDMSG;
  952. g_BMCInfo.SendMsgSeqNum = SeqNum;
  953. if (1 != Offset)
  954. {
  955. m_PendingBridgedResTbl[PBTbl][SeqNum].DstSessionHandle = pReq[Offset]; /* Session handle */
  956. }
  957. m_PendingBridgedResTbl[PBTbl][SeqNum].SrcSessionHandle = SrcSessionHndl;
  958. memcpy (&m_PendingBridgedResTbl[PBTbl][SeqNum].ReqMsgHdr, pIPMIMsgHdr, sizeof (IPMIMsgHdr_T));
  959. /* Format the IPMI Msg Hdr */
  960. if(Channel == PRIMARY_IPMB_CHANNEL)
  961. {
  962. pIPMIMsgHdr->ReqAddr = g_BMCInfo.IpmiConfig.PrimaryIPMBAddr;
  963. }
  964. else if(Channel == SECONDARY_IPMB_CHANNEL)
  965. {
  966. pIPMIMsgHdr->ReqAddr = g_BMCInfo.IpmiConfig.SecondaryIPMBAddr;
  967. }
  968. else
  969. {
  970. printf("Invalid channel %d\n", Channel);//pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
  971. }
  972. pIPMIMsgHdr->RqSeqLUN = (g_BMCInfo.SendMsgSeqNum << 2) & 0xFC; /* Seq Num and LUN =00 */
  973. /* Recalculate the checksum */
  974. m_MsgPkt.Data[ReqLen - 2] = CalculateCheckSum2 (( uint8_t*)pIPMIMsgHdr, ReqLen - Offset - 1);
  975. if((*curchannel & 0xF) == LAN_RMCP_CHANNEL)
  976. {
  977. m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ = gFd_LanIfcQ;
  978. }
  979. // else if (pBMCInfo->SERIALch != CH_NOT_USED && (*curchannel & 0xF) == pBMCInfo->SERIALch && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
  980. // {
  981. // memset(QueueName,0,sizeof(QueueName));
  982. // sprintf(QueueName,"%s%d",SERIAL_IFC_Q,BMCInst);
  983. // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
  984. // }
  985. else
  986. {
  987. if(( (*curchannel & 0xF) == PRIMARY_IPMB_CHANNEL) && (g_BMCInfo.IpmiConfig.PrimaryIPMBSupport == 1 ))
  988. {
  989. m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ = gFd_PrimaryIpmbIfcQ;
  990. }
  991. else if(((*curchannel & 0xF) == SECONDARY_IPMB_CHANNEL) && g_BMCInfo.IpmiConfig.SecondaryIPMBSupport == 1)
  992. {
  993. m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ = gFd_SecondaryIpmbIfcQ;
  994. }
  995. // else if ((pBMCInfo->SERIALch != CH_NOT_USED && Channel == pBMCInfo->SERIALch) && pBMCInfo->IpmiConfig.SerialIfcSupport == 1)
  996. // {
  997. // memset(QueueName,0,sizeof(QueueName));
  998. // sprintf(QueueName,"%s%d",SERIAL_IFC_Q,BMCInst);
  999. // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
  1000. // }
  1001. // else if((pBMCInfo->SMBUSCh != CH_NOT_USED && Channel == pBMCInfo->SMBUSCh) && pBMCInfo->IpmiConfig.SMBUSIfcSupport == 1)
  1002. // {
  1003. // //strcpy ((char *)m_PendingBridgedResTbl[i].DestQ, NULL);
  1004. // }
  1005. // else if ((pBMCInfo->ICMBCh != CH_NOT_USED && Channel == pBMCInfo->ICMBCh) && pBMCInfo->IpmiConfig.ICMBIfcSupport == 1)
  1006. // {
  1007. // memset(QueueName,0,sizeof(QueueName));
  1008. // sprintf(QueueName,"%s%d",ICMB_IFC_Q,BMCInst);
  1009. // strcpy ((char *)m_PendingBridgedResTbl[PBTbl][SeqNum].DestQ,QueueName);
  1010. // }
  1011. }
  1012. m_PendingBridgedResTbl[PBTbl][SeqNum].Used = TRUE;
  1013. printf( "SendMessage: Bridged message added index = %d.\n", SeqNum);
  1014. break;
  1015. }
  1016. else
  1017. {
  1018. SeqNum = (SeqNum + 1) & 0x3F;
  1019. if (SeqNum == g_BMCInfo.SendMsgSeqNum)
  1020. {
  1021. /* If not been added to the Pending Bridge table, an error should be reported back.
  1022. If not, for internal channel, the thread calling it may end up waiting! */
  1023. *pRes = CC_NODE_BUSY;
  1024. return sizeof (*pRes);
  1025. }
  1026. }
  1027. }
  1028. }
  1029. // if ((pBMCInfo->SYSCh == (*curchannel & 0xF)) && pBMCInfo->IpmiConfig.SYSIfcSupport == 0x01)
  1030. // {
  1031. // ResLen = 0;
  1032. // /* Format the IPMI Msg Hdr */
  1033. // // Fill the address from Infrastrucure function instead of using PRIMARY_IPMB_ADDR/SECONDARY_IPMB_ADDR
  1034. // if(Channel == pBMCInfo->PrimaryIPMBCh)
  1035. // {
  1036. // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.PrimaryIPMBAddr;
  1037. // }
  1038. // else if(Channel == pBMCInfo->SecondaryIPMBCh)
  1039. // {
  1040. // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.SecondaryIPMBAddr;
  1041. // }
  1042. // else
  1043. // {
  1044. // pIPMIMsgHdr->ReqAddr = pBMCInfo->IpmiConfig.BMCSlaveAddr;
  1045. // }
  1046. // /*Change the encapsulated request's LUN based on originating KCS interface */
  1047. // pIPMIMsgHdr->RqSeqLUN = (pIPMIMsgHdr->RqSeqLUN & 0xFC) | (*kcsifcnum + 0x01);
  1048. // m_MsgPkt.Data[ReqLen - 2] = CalculateCheckSum2 (( uint8_t*)pIPMIMsgHdr, ReqLen - Offset - 1);
  1049. // pBMCInfo->BridgeMsgKCSIfc = *kcsifcnum;
  1050. // }
  1051. printf ("SendMsgCmd:Posting to interface ");
  1052. int y;
  1053. for(y=0;y<m_MsgPkt.Size;y++)
  1054. printf("%#x ", m_MsgPkt.Data[y]);
  1055. printf("\n");
  1056. m_MsgPkt.Cmd = PAYLOAD_IPMI_MSG;
  1057. /* Post the message to interface */
  1058. if (0 != PostMsg (m_MsgPkt.SrcQ, &m_MsgPkt))
  1059. {
  1060. printf ("SendMsg: Failed to post message to interface queue\n");
  1061. }
  1062. pSendMsgRes->CompletionCode = CC_NORMAL;
  1063. }
  1064. return ResLen;
  1065. }
  1066. ///*---------------------------------------
  1067. //* ReadEvtMsgBuffer
  1068. //*---------------------------------------*/
  1069. //int
  1070. //ReadEvtMsgBuffer ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1071. //{
  1072. // ReadEvtMsgBufRes_T* pReadEvtMsgBufRes = ( ReadEvtMsgBufRes_T*)pRes;
  1073. //#if GET_MSG_FLAGS != UNIMPLEMENTED
  1074. // GetMsgFlagsRes_T GetMsgFlagsRes;
  1075. //#endif
  1076. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1077. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->BMCMsgMutex,WAIT_INFINITE);
  1078. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->EventMutex,WAIT_INFINITE);
  1079. // if (-2 == GetMsg(&m_MsgPkt, EVT_MSG_Q, WAIT_NONE, BMCInst))
  1080. // {
  1081. // /*If queue is empty */
  1082. // pReadEvtMsgBufRes->CompletionCode = CC_EVT_MSG_QUEUE_EMPTY;/* Queue is empty */
  1083. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
  1084. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1085. // return sizeof (*pRes);
  1086. // }
  1087. // if (BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg == 0)
  1088. // {
  1089. // pReadEvtMsgBufRes->CompletionCode = CC_EVT_MSG_QUEUE_EMPTY;
  1090. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
  1091. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1092. // return sizeof (*pRes);
  1093. // }
  1094. // BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg--;
  1095. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->EventMutex);
  1096. //#if GET_MSG_FLAGS != UNIMPLEMENTED
  1097. // // Clear SMS_ATN bit if and only if the Get Message Flag return 0 in byte 2.
  1098. // GetMsgFlags (NULL, 0, (uint8_t *)&GetMsgFlagsRes,BMCInst);
  1099. // TDBG("GetMsgFlagsRes.CompletionCode : %X, GetMsgFlagsRes.MsgFlags : %X\n",
  1100. // GetMsgFlagsRes.CompletionCode, GetMsgFlagsRes.MsgFlags);
  1101. // if (GetMsgFlagsRes.CompletionCode == CC_NORMAL && GetMsgFlagsRes.MsgFlags == 0)
  1102. //#else
  1103. // if (0 == BMC_GET_SHARED_MEM (BMCInst)->NumEvtMsg)
  1104. //#endif
  1105. // {
  1106. // /* if there is no messssage in buffer reset SMS/EVT ATN bit */
  1107. // // CLEAR_SMS_ATN ();
  1108. // if (pBMCInfo->IpmiConfig.KCS1IfcSupport == 1)
  1109. // {
  1110. // CLEAR_SMS_ATN (0, BMCInst);
  1111. // }
  1112. // if (pBMCInfo->IpmiConfig.KCS2IfcSupport == 1)
  1113. // {
  1114. // CLEAR_SMS_ATN (1, BMCInst);
  1115. // }
  1116. // if (pBMCInfo->IpmiConfig.KCS3IfcSuppport == 1)
  1117. // {
  1118. // CLEAR_SMS_ATN (2, BMCInst);
  1119. // }
  1120. // }
  1121. // /* clear EventMessageBuffer full flag */
  1122. // BMC_GET_SHARED_MEM (BMCInst)->MsgFlags &= ~0x02;
  1123. // pReadEvtMsgBufRes->CompletionCode = CC_NORMAL; /* Completion Code */
  1124. // /* copy the Message data */
  1125. // _fmemcpy (pReadEvtMsgBufRes->ResData, m_MsgPkt.Data, m_MsgPkt.Size);
  1126. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->BMCMsgMutex);
  1127. // return sizeof (ReadEvtMsgBufRes_T);
  1128. //}
  1129. ///*---------------------------------------
  1130. //* GetBTIfcCap
  1131. //*---------------------------------------*/
  1132. //int
  1133. //GetBTIfcCap ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1134. //{
  1135. // GetBTIfcCapRes_T* pGetBTIfcCapRes = ( GetBTIfcCapRes_T*)pRes;
  1136. // pGetBTIfcCapRes->CompletionCode = CC_NORMAL;
  1137. // pGetBTIfcCapRes->NumReqSupported = 2;
  1138. // pGetBTIfcCapRes->InputBufSize = MAX_BT_PKT_LEN;
  1139. // pGetBTIfcCapRes->OutputBufSize = MAX_BT_PKT_LEN;
  1140. // pGetBTIfcCapRes->RespTime = 1;
  1141. // pGetBTIfcCapRes->Retries = 0;
  1142. // return sizeof (GetBTIfcCapRes_T);
  1143. //}
  1144. ///*---------------------------------------
  1145. //* GetSystemGUID
  1146. //*---------------------------------------*/
  1147. //int
  1148. //GetSystemGUID ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1149. //{
  1150. // GetSysGUIDRes_T* pGetSysGUIDRes = ( GetSysGUIDRes_T*)pRes;
  1151. // pGetSysGUIDRes->CompletionCode = CC_NORMAL;
  1152. // LOCK_BMC_SHARED_MEM (BMCInst);
  1153. // _fmemcpy (&pGetSysGUIDRes->Node, BMC_GET_SHARED_MEM (BMCInst)->SystemGUID, 16);
  1154. // UNLOCK_BMC_SHARED_MEM (BMCInst);
  1155. // return sizeof (GetSysGUIDRes_T);
  1156. //}
  1157. #define SUPPORT_IPMI20 0x02
  1158. #define SUPPORT_IPMI15 0x01
  1159. /*---------------------------------------
  1160. * GetChAuthCap
  1161. *---------------------------------------*/
  1162. int
  1163. GetChAuthCap ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  1164. {
  1165. //TODO: dummy data
  1166. // GetChAuthCapReq_T* pGetChAuthCapReq = ( GetChAuthCapReq_T*)pReq;
  1167. GetChAuthCapRes_T* pGetChAuthCapRes = ( GetChAuthCapRes_T*)pRes;
  1168. pGetChAuthCapRes->CompletionCode = CC_NORMAL;
  1169. pGetChAuthCapRes->ChannelNum = LAN_RMCP_CHANNEL;
  1170. pGetChAuthCapRes->AuthType = 0x36;
  1171. pGetChAuthCapRes->PerMsgUserAuthLoginStatus = 0x04;
  1172. pGetChAuthCapRes->ExtCap = 0;
  1173. pGetChAuthCapRes->OEMID[0] = 0;
  1174. pGetChAuthCapRes->OEMID[1] = 0;
  1175. pGetChAuthCapRes->OEMID[2] = 0;
  1176. pGetChAuthCapRes->OEMAuxData = 0;
  1177. return sizeof (GetChAuthCapRes_T);
  1178. }
  1179. /*---------------------------------------
  1180. * GetSessionChallenge
  1181. * Create session in this function
  1182. *---------------------------------------*/
  1183. int
  1184. GetSessionChallenge ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  1185. {
  1186. GetSesChallengeReq_T* pGetSesChalReq = ( GetSesChallengeReq_T*)pReq;
  1187. GetSesChallengeRes_T* pGetSesChalRes = ( GetSesChallengeRes_T*)pRes;
  1188. uint8_t Index;
  1189. uint8_t ChallengeString[CHALLENGE_STR_LEN];
  1190. UserInfo_T *pUserInfo;
  1191. // // Check for Reserved bits
  1192. // if((pGetSesChalReq->AuthType == AUTHTYPE_RESERVED) || (pGetSesChalReq->AuthType > AUTHTYPE_OEM_PROPRIETARY))
  1193. // {
  1194. // pGetSesChalRes->CompletionCode = CC_INV_DATA_FIELD;
  1195. // return sizeof (*pRes);
  1196. // }
  1197. if(pGetSesChalReq->UserName[0] == 0)
  1198. {
  1199. pGetSesChalRes->CompletionCode = 0x82;
  1200. return sizeof (*pRes);
  1201. }
  1202. g_BMCInfo.pUserInfo = NULL;
  1203. pUserInfo = getUserNameInfo(pGetSesChalReq->UserName);
  1204. if(pUserInfo == NULL)
  1205. {
  1206. pGetSesChalRes->CompletionCode = 0x81;
  1207. return sizeof (*pRes);
  1208. }
  1209. // if((pUserInfo->ID != USER_ID) || (pUserInfo->UserStatus == FALSE))
  1210. // {
  1211. // pGetSesChalRes->CompletionCode = 0x81;
  1212. // return sizeof (*pRes);
  1213. // }
  1214. g_BMCInfo.pUserInfo = pUserInfo;
  1215. g_BMCInfo.LanSession.AuthType = pGetSesChalReq->AuthType;
  1216. g_BMCInfo.LanSession.SessionID = 0x1234;//trng_get_true_random_data();
  1217. pGetSesChalRes->CompletionCode = CC_NORMAL;
  1218. pGetSesChalRes->TempSessionID = g_BMCInfo.LanSession.SessionID;
  1219. /* generate Randam Challenge String */
  1220. for(Index=0;Index < CHALLENGE_STR_LEN;Index++)
  1221. {
  1222. ChallengeString[Index] = 0x56;//trng_get_true_random_data()&0xff;
  1223. }
  1224. memcpy(pGetSesChalRes->ChallengeString, ChallengeString, CHALLENGE_STR_LEN);
  1225. return sizeof (GetSesChallengeRes_T);
  1226. }
  1227. /*---------------------------------------
  1228. * ActivateSession
  1229. *---------------------------------------*/
  1230. int
  1231. ActivateSession ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  1232. {
  1233. //TODO: dummy data
  1234. ActivateSesReq_T* pAcvtSesReq = ( ActivateSesReq_T*)pReq;
  1235. ActivateSesRes_T* pAcvtSesRes = ( ActivateSesRes_T*)pRes;
  1236. // /* Initial Outbound Sequence Number cannot be null */
  1237. // if (pAcvtSesReq->OutboundSeq == 0)
  1238. // {
  1239. // pAcvtSesRes->CompletionCode = CC_ACTIVATE_SESS_SEQ_OUT_OF_RANGE;
  1240. // return sizeof(*pRes);
  1241. // }
  1242. // // Check for Reserved bitss
  1243. // if((pAcvtSesReq->AuthType == AUTHTYPE_RESERVED) || (pAcvtSesReq->AuthType > AUTHTYPE_OEM_PROPRIETARY))
  1244. // {
  1245. // pAcvtSesRes->CompletionCode = CC_INV_DATA_FIELD;
  1246. // return sizeof (*pRes);
  1247. // }
  1248. // if ((pAcvtSesReq->Privilege == PRIV_LEVEL_RESERVED) || (pAcvtSesReq->Privilege > PRIV_LEVEL_PROPRIETARY))
  1249. // {
  1250. // pAcvtSesRes->CompletionCode = CC_INV_DATA_FIELD;/* Privilege is Reserved */
  1251. // return sizeof (*pRes);
  1252. // }
  1253. pAcvtSesRes->CompletionCode = CC_NORMAL;
  1254. pAcvtSesRes->AuthType = g_BMCInfo.LanSession.AuthType;
  1255. pAcvtSesRes->SessionID = g_BMCInfo.LanSession.SessionID;
  1256. pAcvtSesRes->InboundSeq = 0x78;//trng_get_true_random_data();
  1257. pAcvtSesRes->Privilege = 0x04;
  1258. return sizeof (ActivateSesRes_T);
  1259. }
  1260. /*---------------------------------------
  1261. * SetSessionPrivLevel
  1262. *---------------------------------------*/
  1263. int
  1264. SetSessionPrivLevel ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  1265. {
  1266. SetSesPrivLevelReq_T* pSetSesPrivLevelReq = ( SetSesPrivLevelReq_T*)pReq;
  1267. SetSesPrivLevelRes_T* pSetSesPrivLevelRes = ( SetSesPrivLevelRes_T*)pRes;
  1268. //Check for Reserved bits
  1269. if((pSetSesPrivLevelReq->Privilege == PRIV_LEVEL_CALLBACK) || (pSetSesPrivLevelReq->Privilege > PRIV_LEVEL_PROPRIETARY))
  1270. {
  1271. pSetSesPrivLevelRes->CompletionCode = CC_INV_DATA_FIELD;
  1272. return sizeof(SetSesPrivLevelRes_T);
  1273. }
  1274. /* According to the IPMI 2.0 Priv Level =1 is reserved */
  1275. if((PRIV_USER != pSetSesPrivLevelReq->Privilege) &&
  1276. (PRIV_OPERATOR != pSetSesPrivLevelReq->Privilege) &&
  1277. (PRIV_ADMIN != pSetSesPrivLevelReq->Privilege) &&
  1278. (PRIV_OEM != pSetSesPrivLevelReq->Privilege))
  1279. {
  1280. /*Requested Privilege exceeds ChannelPrivilege Limit */
  1281. pSetSesPrivLevelRes->CompletionCode = CC_INV_DATA_FIELD;
  1282. return sizeof (*pRes);
  1283. }
  1284. pSetSesPrivLevelRes->CompletionCode = CC_NORMAL;
  1285. pSetSesPrivLevelRes->Privilege = pSetSesPrivLevelReq->Privilege;
  1286. return sizeof (SetSesPrivLevelRes_T);
  1287. }
  1288. /*---------------------------------------
  1289. * CloseSession
  1290. *---------------------------------------*/
  1291. int
  1292. CloseSession ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  1293. {
  1294. //TODO: dymmy data
  1295. *pRes = CC_NORMAL;
  1296. return sizeof (*pRes);
  1297. }
  1298. //#if GET_SESSION_INFO != UNIMPLEMENTED
  1299. ///*---------------------------------------
  1300. //* GetSessionInfo
  1301. //*---------------------------------------*/
  1302. //int
  1303. //GetSessionInfo ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1304. //{
  1305. // GetSesInfoReq_T* pGetSesInfoReq = ( GetSesInfoReq_T*)pReq;
  1306. // GetSesInfoRes_T* pGetSesInfoRes = ( GetSesInfoRes_T*)pRes;
  1307. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1308. // LANSesInfoRes_T LANSesInfo;
  1309. // LANIPv6SesInfoRes_T LANIPv6SesInfo;
  1310. // SessionInfo_T* pSessInfo;
  1311. // ChannelInfo_T* pChannelInfo;
  1312. // void* SessionArg;
  1313. // uint8_t SessionArgAlign[4];
  1314. // uint8_t SessionArgType,EthIndex, netindex = 0xFF;
  1315. // char IfcName[IFNAMSIZ];
  1316. // uint32_t *CurSesID,*curchannel;
  1317. // int i;
  1318. // *pRes = CC_REQ_INV_LEN;
  1319. // switch (pGetSesInfoReq->SessionIndex)
  1320. // {
  1321. // case 0:
  1322. // /* Get session information for this session */
  1323. // if (1 != ReqLen)
  1324. // {
  1325. // return sizeof (*pRes);
  1326. // }
  1327. // SessionArgType = SESSION_ID_INFO;
  1328. // OS_THREAD_TLS_GET(g_tls.CurSessionID,CurSesID);
  1329. // SessionArg = CurSesID;
  1330. // break;
  1331. // case 0xFF:
  1332. // if (5 != ReqLen)
  1333. // {
  1334. // return sizeof (*pRes);
  1335. // }
  1336. // SessionArgType = SESSION_ID_INFO;
  1337. // SessionArgAlign[0] = pGetSesInfoReq->SessionHandleOrID[0];
  1338. // SessionArgAlign[1] = pGetSesInfoReq->SessionHandleOrID[1];
  1339. // SessionArgAlign[2] = pGetSesInfoReq->SessionHandleOrID[2];
  1340. // SessionArgAlign[3] = pGetSesInfoReq->SessionHandleOrID[3];
  1341. // SessionArg = SessionArgAlign;
  1342. // break;
  1343. // case 0xFE:
  1344. // if (2 != ReqLen)
  1345. // {
  1346. // return sizeof (*pRes);
  1347. // }
  1348. // if (pGetSesInfoReq->SessionHandleOrID[0] == 0)
  1349. // {
  1350. // *pRes=CC_INV_DATA_FIELD;
  1351. // return sizeof (*pRes);
  1352. // }
  1353. // SessionArgType = SESSION_HANDLE_INFO;
  1354. // SessionArgAlign[0] = pGetSesInfoReq->SessionHandleOrID[0];
  1355. // SessionArgAlign[1] = pGetSesInfoReq->SessionHandleOrID[1];
  1356. // SessionArgAlign[2] = pGetSesInfoReq->SessionHandleOrID[2];
  1357. // SessionArgAlign[3] = pGetSesInfoReq->SessionHandleOrID[3];
  1358. // SessionArg = SessionArgAlign;
  1359. // break;
  1360. // default:
  1361. // if (1 != ReqLen)
  1362. // {
  1363. // return sizeof (*pRes);
  1364. // }
  1365. // SessionArgType = SESSION_INDEX_INFO;
  1366. // SessionArg = &pGetSesInfoReq->SessionIndex;
  1367. // break;
  1368. // }
  1369. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SessionTblMutex, WAIT_INFINITE);
  1370. // pSessInfo = getSessionInfo (SessionArgType, SessionArg, BMCInst);
  1371. // if (NULL == pSessInfo)
  1372. // {
  1373. // TDBG ("GetSessionInfo: pSessInfo is NULL\n");
  1374. // /* if there is no active channel for the current session Index
  1375. // * return the following bytes
  1376. // */
  1377. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  1378. // pChannelInfo = getChannelInfo (*curchannel & 0xF, BMCInst);
  1379. // if(NULL == pChannelInfo)
  1380. // {
  1381. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1382. // pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  1383. // return sizeof (*pRes);
  1384. // }
  1385. // pGetSesInfoRes->CompletionCode = CC_NORMAL;
  1386. // pGetSesInfoRes->SessionHandle = BMC_GET_SHARED_MEM (BMCInst)->SessionHandle;
  1387. // pGetSesInfoRes->NumPossibleActiveSession= pBMCInfo->IpmiConfig.MaxSession;
  1388. // pGetSesInfoRes->NumActiveSession = GetNumOfActiveSessions (BMCInst);
  1389. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1390. // return (sizeof (GetSesInfoRes_T) - sizeof (ActiveSesInfo_T) - sizeof (SessionInfoRes_T));
  1391. // }
  1392. // memset (pGetSesInfoRes,0,sizeof(GetSesInfoRes_T));
  1393. // pChannelInfo = getChannelInfo (pSessInfo->Channel, BMCInst);
  1394. // if(NULL == pChannelInfo)
  1395. // {
  1396. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1397. // pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  1398. // return sizeof (*pRes);
  1399. // }
  1400. // pGetSesInfoRes->CompletionCode = CC_NORMAL;
  1401. // pGetSesInfoRes->SessionHandle = pSessInfo->SessionHandle;
  1402. // pGetSesInfoRes->NumPossibleActiveSession = pBMCInfo->IpmiConfig.MaxSession;
  1403. // pGetSesInfoRes->NumActiveSession = GetNumOfActiveSessions (BMCInst);
  1404. // pGetSesInfoRes->ActiveSesinfo.UserID = pSessInfo->UserId & 0x3F;
  1405. // pGetSesInfoRes->ActiveSesinfo.Privilege = pSessInfo->Privilege & 0x0F;
  1406. // /* Set protocol bit as per Auth Type, bit4 must be 1 for IPMIv2.0 RMCP, 0 for IPMIv1.5 */
  1407. // if( AUTHTYPE_RMCP_PLUS_FORMAT == pSessInfo->AuthType )
  1408. // {
  1409. // pGetSesInfoRes->ActiveSesinfo.ChannelNum = (pSessInfo->Channel & 0x0F) | 0x10;
  1410. // }else
  1411. // {
  1412. // pGetSesInfoRes->ActiveSesinfo.ChannelNum = pSessInfo->Channel & 0x0F;
  1413. // }
  1414. // EthIndex= GetEthIndex(pSessInfo->Channel & 0x0F, BMCInst);
  1415. // if(0xff == EthIndex)
  1416. // {
  1417. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1418. // *pRes = CC_INV_DATA_FIELD;
  1419. // DeleteSession (pSessInfo,BMCInst);
  1420. // return sizeof (uint8_t);
  1421. // }
  1422. // memset(IfcName,0,sizeof(IfcName));
  1423. // /*Get the EthIndex*/
  1424. // if(GetIfcName(EthIndex,IfcName, BMCInst) == -1)
  1425. // {
  1426. // TCRIT("Error in Getting Ifc name\n");
  1427. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1428. // *pRes = CC_INV_DATA_FIELD;
  1429. // return sizeof (uint8_t);
  1430. // }
  1431. // for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
  1432. // {
  1433. // if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
  1434. // {
  1435. // netindex= Ifcnametable[i].Index;
  1436. // break;
  1437. // }
  1438. // }
  1439. // if(netindex == 0xFF)
  1440. // {
  1441. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1442. // *pRes = CC_INV_DATA_FIELD;
  1443. // return sizeof (uint8_t);
  1444. // }
  1445. // if (IsLANChannel( pSessInfo->Channel, BMCInst))
  1446. // {
  1447. // if(g_corefeatures.global_ipv6 == ENABLED)
  1448. // {
  1449. // if(GetIPAdrressType(&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[0])==4)
  1450. // {
  1451. // memset(&LANSesInfo,0,sizeof(LANSesInfo));
  1452. // /* IP Address */
  1453. // _fmemcpy (&(LANSesInfo.IPAddress),
  1454. // &pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[sizeof(struct in6_addr)-sizeof(struct in_addr)],
  1455. // sizeof(struct in_addr));
  1456. // /* MAC Address */
  1457. // if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
  1458. // nwGetSrcCacheMacAddr((uint8_t*)&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr[12],
  1459. // netindex, pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
  1460. // _fmemcpy(LANSesInfo.MACAddress, pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
  1461. // /* Port number */
  1462. // LANSesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
  1463. // _fmemcpy ((pRes+sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)),&LANSesInfo, sizeof (LANSesInfoRes_T));
  1464. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1465. // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)+sizeof (LANSesInfoRes_T));
  1466. // }
  1467. // else
  1468. // {
  1469. // /* IP Address */
  1470. // memset(&LANIPv6SesInfo,0,sizeof(LANIPv6SesInfo));
  1471. // _fmemcpy (&(LANIPv6SesInfo.IPv6Address),
  1472. // pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr,
  1473. // sizeof(struct in6_addr));
  1474. // /* MAC Address */
  1475. // if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
  1476. // nwGetSrcMacAddr_IPV6((uint8_t*)&pSessInfo->LANRMCPPkt.IPHdr.Srcv6Addr,
  1477. // pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
  1478. // _fmemcpy(LANIPv6SesInfo.MACAddress, pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
  1479. // /* Port number */
  1480. // LANIPv6SesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
  1481. // _fmemcpy ((pRes+sizeof (GetSesInfoRes_T) - sizeof(SessionInfoRes_T)),&LANIPv6SesInfo, sizeof (LANIPv6SesInfoRes_T));
  1482. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1483. // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T)+sizeof (LANIPv6SesInfoRes_T));
  1484. // }
  1485. // }
  1486. // else
  1487. // {
  1488. // /* IP Address */
  1489. // _fmemcpy (pGetSesInfoRes->SesInfo.LANSesInfo.IPAddress,
  1490. // pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr,
  1491. // sizeof (pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr));
  1492. // /* MAC Address */
  1493. // if(pSessInfo->LANRMCPPkt.MACHdr.DestAddr[0] == 0)
  1494. // nwGetSrcCacheMacAddr((uint8_t*)pSessInfo->LANRMCPPkt.IPHdr.Srcv4Addr, netindex,
  1495. // pSessInfo->LANRMCPPkt.MACHdr.DestAddr);
  1496. // _fmemcpy(pGetSesInfoRes->SesInfo.LANSesInfo.MACAddress,
  1497. // pSessInfo->LANRMCPPkt.MACHdr.DestAddr, MAC_ADDR_LEN);
  1498. // /* Port number */
  1499. // pGetSesInfoRes->SesInfo.LANSesInfo.PortNumber = pSessInfo->LANRMCPPkt.UDPHdr.SrcPort;
  1500. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1501. // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T) + sizeof (LANSesInfoRes_T));
  1502. // }
  1503. // }
  1504. // else if (pBMCInfo->IpmiConfig.SerialIfcSupport == 1 && pBMCInfo->SERIALch== pSessInfo->Channel)
  1505. // {
  1506. // pChannelInfo = getChannelInfo (pBMCInfo->SERIALch, BMCInst);
  1507. // if(NULL == pChannelInfo)
  1508. // {
  1509. // pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  1510. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1511. // return sizeof (*pRes);
  1512. // }
  1513. // pGetSesInfoRes->SesInfo.SerialSesInfo.SessionActivityType = 0;
  1514. // pGetSesInfoRes->SesInfo.SerialSesInfo.DestinationSelector = 0;
  1515. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1516. // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T) + sizeof (SerialSesInfoRes_T));
  1517. // }
  1518. // else
  1519. // {
  1520. // pChannelInfo = getChannelInfo(pSessInfo->Channel, BMCInst);
  1521. // if(NULL == pChannelInfo)
  1522. // {
  1523. // pGetSesInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  1524. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1525. // return sizeof (*pRes);
  1526. // }
  1527. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->SessionTblMutex);
  1528. // return (sizeof (GetSesInfoRes_T) - sizeof (SessionInfoRes_T));
  1529. // }
  1530. //}
  1531. //#endif
  1532. ///**
  1533. // * @fn GetAuthCodeForTypeV15
  1534. // * @brief This function will use the encryption technique supported
  1535. // * in IPMI V1.5 in order to produce Auth Code.
  1536. // * @param[in] pUserInfo - Pointer to User info structure.
  1537. // * @param[in] pGetAuthCodeReq - Pointer to the structure of request data
  1538. // * @param[out] pGetAuthCodeRes - Pointer to the resultant data.
  1539. // * @retval size of the result data.
  1540. // */
  1541. //static int
  1542. //GetAuthCodeForTypeV15 (UserInfo_T* pUserInfo,
  1543. // GetAuthCodeReq_T* pGetAuthCodeReq,
  1544. // GetAuthCodeRes_T* pGetAuthCodeRes )
  1545. //{
  1546. // uint8_t AuthCode;
  1547. // uint8_t InBuffer[2*IPMI15_MAX_PASSWORD_LEN + HASH_DATA_LENGTH];
  1548. // char UserPswd[MAX_PASSWD_LEN];
  1549. // uint8_t PwdEncKey[MAX_SIZE_KEY + 1] = {0};
  1550. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1551. // memset(&(pGetAuthCodeRes->AuthCode), 0, AUTH_CODE_HASH_LEN);
  1552. // AuthCode = pGetAuthCodeReq->AuthType & AUTH_CODE_V15_MASK;
  1553. // if((pGetAuthCodeReq->AuthType & (BIT5 | BIT4)) ||
  1554. // (AuthCode == AUTHTYPE_RESERVED) || (AuthCode == AUTHTYPE_NONE) ||
  1555. // (AuthCode == AUTHTYPE_STRAIGHT_PASSWORD) ||
  1556. // (AuthCode > AUTHTYPE_OEM_PROPRIETARY))
  1557. // {
  1558. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1559. // return (sizeof (GetAuthCodeRes_T) - 4);
  1560. // }
  1561. // if (g_corefeatures.userpswd_encryption == ENABLED)
  1562. // {
  1563. // /* Get Encryption Key from the MBMCInfo_t structure */
  1564. // LOCK_BMC_SHARED_MEM(BMCInst);
  1565. // memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
  1566. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1567. // if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[pUserInfo->UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
  1568. // {
  1569. // TCRIT("Error in decrypting the IPMI User password for User ID:%d.\n", pUserInfo->UserId);
  1570. // pGetAuthCodeRes->CompletionCode = CC_UNSPECIFIED_ERR;
  1571. // return sizeof(*pGetAuthCodeRes);
  1572. // }
  1573. // memcpy(&InBuffer[0],UserPswd,IPMI15_MAX_PASSWORD_LEN);
  1574. // }
  1575. // else
  1576. // {
  1577. // memcpy(&InBuffer[0],pUserInfo->UserPassword,IPMI15_MAX_PASSWORD_LEN);
  1578. // }
  1579. // LOCK_BMC_SHARED_MEM(BMCInst);
  1580. // switch (AuthCode)
  1581. // {
  1582. // #if 0 // As per IPMIv2 Markup E4, Straight Password key is Reserved
  1583. // case AUTH_TYPE_PASSWORD: /* Straight password */
  1584. // if (0 == _fmemcmp (pUserInfo->UserPassword,pGetAuthCodeReq->HashData,IPMI15_MAX_PASSWORD_LEN))
  1585. // {
  1586. // _fmemcpy (pGetAuthCodeRes->AuthCode, "OK", 2);
  1587. // }
  1588. // else
  1589. // {
  1590. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1591. // }
  1592. // break;
  1593. // #endif
  1594. // case AUTH_TYPE_MD2: /* MD2 */
  1595. // _fmemcpy (&InBuffer[IPMI15_MAX_PASSWORD_LEN],
  1596. // pGetAuthCodeReq->HashData, HASH_DATA_LENGTH);
  1597. // if (g_corefeatures.userpswd_encryption == ENABLED)
  1598. // {
  1599. // _fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
  1600. // UserPswd, IPMI15_MAX_PASSWORD_LEN);
  1601. // }
  1602. // else
  1603. // {
  1604. // _fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
  1605. // pUserInfo->UserPassword, IPMI15_MAX_PASSWORD_LEN);
  1606. // }
  1607. // AuthCodeCalMD2 (InBuffer, pGetAuthCodeRes->AuthCode, sizeof (InBuffer));
  1608. // break;
  1609. // case AUTH_TYPE_MD5: /* MD5 */
  1610. // _fmemcpy (&InBuffer[IPMI15_MAX_PASSWORD_LEN],
  1611. // pGetAuthCodeReq->HashData, HASH_DATA_LENGTH);
  1612. // if (g_corefeatures.userpswd_encryption == ENABLED)
  1613. // {
  1614. // _fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
  1615. // UserPswd,IPMI15_MAX_PASSWORD_LEN);
  1616. // }
  1617. // else
  1618. // {
  1619. // _fmemcpy(&InBuffer[IPMI15_MAX_PASSWORD_LEN+HASH_DATA_LENGTH],
  1620. // pUserInfo->UserPassword,IPMI15_MAX_PASSWORD_LEN);
  1621. // }
  1622. // AuthCodeCalMD5 (InBuffer, pGetAuthCodeRes->AuthCode, sizeof (InBuffer));
  1623. // break;
  1624. // default:
  1625. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1626. // }
  1627. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1628. // // IPMI V1.5 AuthCode is only 16 byte.
  1629. // return (sizeof (GetAuthCodeRes_T) - 4);
  1630. //}
  1631. ///**
  1632. // * @fn GetAuthCodeForTypeV20
  1633. // * @brief This function will use the encryption technique supported
  1634. // * in IPMI V2.0 in order to produce Auth Code.
  1635. // * @param[in] pUserInfo - Pointer to User info structure.
  1636. // * @param[in] pGetAuthCodeReq - Pointer to the structure of request data
  1637. // * @param[out] pGetAuthCodeRes - Pointer to the resultant data.
  1638. // * @retval size of the result data.
  1639. // */
  1640. //static int
  1641. //GetAuthCodeForTypeV20 (UserInfo_T* pUserInfo,
  1642. // GetAuthCodeReq_T* pGetAuthCodeReq,
  1643. // GetAuthCodeRes_T* pGetAuthCodeRes )
  1644. //{
  1645. // uint8_t AuthCode;
  1646. // uint8_t UserPasswdLen=0;
  1647. // uint8_t DecVal = 0;
  1648. // uint8_t m_SIK [SESSION_INTEGRITY_KEY_SIZE];
  1649. // char UserPswd[MAX_PASSWD_LEN];
  1650. // unsigned char PwdEncKey[MAX_SIZE_KEY + 1] = {0};
  1651. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1652. // if (g_corefeatures.userpswd_encryption == ENABLED)
  1653. // {
  1654. // /* Get Encryption Key from the MBMCInfo_t structure */
  1655. // LOCK_BMC_SHARED_MEM(BMCInst);
  1656. // memcpy(PwdEncKey, &(g_MBMCInfo.PwdEncKey), MAX_SIZE_KEY);
  1657. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1658. // if(DecryptPassword((INT8S *)(pBMCInfo->EncryptedUserInfo[pUserInfo->UserId - 1].EncryptedPswd), MAX_PASSWORD_LEN, UserPswd, MAX_PASSWORD_LEN, PwdEncKey))
  1659. // {
  1660. // TCRIT("\nError in decrypting the IPMI User password for user with ID:%d.\n", pUserInfo->UserId);
  1661. // pGetAuthCodeRes->CompletionCode = CC_UNSPECIFIED_ERR;
  1662. // return sizeof (*pGetAuthCodeRes);
  1663. // }
  1664. // }
  1665. // else
  1666. // {
  1667. // memcpy(&UserPswd, pUserInfo->UserPassword, MAX_PASSWD_LEN);
  1668. // }
  1669. // /* Calculate password length */
  1670. // UserPasswdLen = _fstrlen (( char*)UserPswd);
  1671. // UserPasswdLen = (UserPasswdLen > MAX_PASSWORD_LEN) ?
  1672. // MAX_PASSWORD_LEN : UserPasswdLen;
  1673. // memset(&(pGetAuthCodeRes->AuthCode), 0, AUTH_CODE_HASH_LEN);
  1674. // AuthCode = pGetAuthCodeReq->AuthType & AUTH_CODE_V20_MASK;
  1675. // /* Validate the Auth Code */
  1676. // if ((AuthCode > MIN_AUTH_CODE_V20) && (AuthCode < MAX_AUTH_CODE_V20))
  1677. // {
  1678. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1679. // return sizeof(GetAuthCodeRes_T);
  1680. // }
  1681. // LOCK_BMC_SHARED_MEM(BMCInst);
  1682. // switch(AuthCode)
  1683. // {
  1684. // case AUTH_NONE: /* none */
  1685. // TDBG ("\nInside AUTH_NONE in GetAuthCode");
  1686. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1687. // break;
  1688. // case AUTH_HMAC_SHA1_96: /* HMAC-SHA1-96 */
  1689. // TDBG ("\nInside AUTH_HMAC_SHA1_96 in GetAuthCode");
  1690. // hmac_sha1 ((uint8_t *)UserPswd, UserPasswdLen,
  1691. // (uint8_t *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1692. // (uint8_t *)m_SIK, SESSION_INTEGRITY_KEY_SIZE);
  1693. // hmac_sha1 ((uint8_t *)m_SIK, SESSION_INTEGRITY_KEY_SIZE,
  1694. // (uint8_t *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1695. // (uint8_t *)&(pGetAuthCodeRes->AuthCode), HMAC_SHA1_96_LEN);
  1696. // DecVal = AUTH_CODE_HASH_LEN - HMAC_SHA1_96_LEN;
  1697. // break;
  1698. // case AUTH_HMAC_MD5_128: /* HMAC-MD5-128 */
  1699. // TDBG ("\nInside AUTH_HMAC_MD5_128 in GetAuthCode");
  1700. // hmac_md5 ((unsigned char*)UserPswd, UserPasswdLen,
  1701. // pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1702. // m_SIK, SESSION_HMAC_MD5_I_KEY_SIZE);
  1703. // hmac_md5 (m_SIK, SESSION_HMAC_MD5_I_KEY_SIZE,
  1704. // pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1705. // (unsigned char *)&(pGetAuthCodeRes->AuthCode),
  1706. // SESSION_HMAC_MD5_I_KEY_SIZE);
  1707. // DecVal = AUTH_CODE_HASH_LEN - SESSION_HMAC_MD5_I_KEY_SIZE;
  1708. // break;
  1709. // case AUTH_MD5_128: /* MD5-128 */
  1710. // TDBG ("\nInside AUTH_MD5_128 in GetAuthCode");
  1711. // MD5_128 ((char *)UserPswd, UserPasswdLen,
  1712. // (char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1713. // (char *)m_SIK, SESSION_MD5_KEY_SIZE);
  1714. // MD5_128 ((char *)m_SIK, SESSION_INTEGRITY_KEY_SIZE,
  1715. // (char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1716. // (char *)&(pGetAuthCodeRes->AuthCode), SESSION_MD5_KEY_SIZE);
  1717. // DecVal = AUTH_CODE_HASH_LEN - SESSION_MD5_KEY_SIZE;
  1718. // break;
  1719. // case AUTH_HMAC_SHA256_128: /* HMAC-SHA256-128 */
  1720. // TDBG ("\nInside AUTH_HMAC_SHA256_128 in GetAuthCode");
  1721. // hmac_sha256 ((unsigned char *)UserPswd, UserPasswdLen,
  1722. // (unsigned char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1723. // (unsigned char *)m_SIK, SHA2_HASH_KEY_SIZE);
  1724. // hmac_sha256 (m_SIK, SHA2_HASH_KEY_SIZE,
  1725. // (unsigned char *)pGetAuthCodeReq->HashData, HASH_DATA_LEN,
  1726. // (unsigned char *)&(pGetAuthCodeRes->AuthCode), HMAC_SHA256_128_LEN);
  1727. // DecVal = AUTH_CODE_HASH_LEN - HMAC_SHA256_128_LEN;
  1728. // break;
  1729. // //! TODO: Need support in openssl.
  1730. // default: /* OEM or Reserved */
  1731. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1732. // }
  1733. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1734. // if (DecVal > sizeof(GetAuthCodeRes_T))
  1735. // return sizeof(GetAuthCodeRes_T);
  1736. // else
  1737. // return (sizeof(GetAuthCodeRes_T) - DecVal);
  1738. //}
  1739. ///**
  1740. // * @fn GetAuthCode
  1741. // * @brief This function will encrypt the given 16 byte data with
  1742. // * the algorithm given and return Auth Code.
  1743. // * @param[in] pReq - Request data.
  1744. // * @param[in] ReqLen - Length of the request data.
  1745. // * @param[out] pRes - Result data
  1746. // * @retval size of the result data.
  1747. // */
  1748. //int
  1749. //GetAuthCode ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes )
  1750. //{
  1751. // GetAuthCodeReq_T* pGetAuthCodeReq = ( GetAuthCodeReq_T*)pReq;
  1752. // GetAuthCodeRes_T* pGetAuthCodeRes = ( GetAuthCodeRes_T*)pRes;
  1753. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  1754. // UserInfo_T* pUserInfo;
  1755. // uint8_t AuthType,*curchannel;
  1756. // ChannelInfo_T* pChannelInfo;
  1757. // int nRetSize = 0;
  1758. // /* Check for Reserved Bits */
  1759. // if((pGetAuthCodeReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4)) ||
  1760. // (pGetAuthCodeReq->UserID & (BIT7 | BIT6)))
  1761. // {
  1762. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1763. // return sizeof(*pRes);
  1764. // }
  1765. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  1766. // /* Validate the channel number given */
  1767. // if (CURRENT_CHANNEL_NUM == pGetAuthCodeReq->ChannelNum)
  1768. // {
  1769. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  1770. // pChannelInfo = getChannelInfo(*curchannel & 0xF,BMCInst);
  1771. // }
  1772. // else
  1773. // pChannelInfo = getChannelInfo(pGetAuthCodeReq->ChannelNum,BMCInst);
  1774. // if (NULL == pChannelInfo)
  1775. // {
  1776. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1777. // *pRes = CC_INV_DATA_FIELD;
  1778. // return sizeof(*pRes);
  1779. // }
  1780. // /* Get the user information for the given userID */
  1781. // pUserInfo = getUserIdInfo (pGetAuthCodeReq->UserID,BMCInst);
  1782. // if (NULL == pUserInfo)
  1783. // {
  1784. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1785. // TDBG ("AppDevice.c : GetAuthCode - Invalid user Id\n");
  1786. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1787. // return sizeof (*pRes);
  1788. // }
  1789. // AuthType = pGetAuthCodeReq->AuthType & GET_AUTH_TYPE_MASK;
  1790. // pGetAuthCodeRes->CompletionCode = CC_NORMAL;
  1791. // switch(AuthType)
  1792. // {
  1793. // case AUTH_TYPE_V15: /* IPMI v1.5 AuthCode Algorithms */
  1794. // nRetSize = GetAuthCodeForTypeV15(pUserInfo, pGetAuthCodeReq, pGetAuthCodeRes,BMCInst);
  1795. // break;
  1796. // case AUTH_TYPE_V20: /* IPMI v2.0/RMCP+ Algorithm Number */
  1797. // nRetSize = GetAuthCodeForTypeV20(pUserInfo, pGetAuthCodeReq, pGetAuthCodeRes,BMCInst);
  1798. // break;
  1799. // default:
  1800. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1801. // pGetAuthCodeRes->CompletionCode = CC_INV_DATA_FIELD;
  1802. // return sizeof(*pRes);
  1803. // }
  1804. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1805. // return nRetSize;
  1806. //}
  1807. ///*---------------------------------------
  1808. //* SetChAccess
  1809. //*---------------------------------------*/
  1810. //int
  1811. //SetChAccess ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1812. //{
  1813. // SetChAccessReq_T* pSetChAccessReq = ( SetChAccessReq_T*)pReq;
  1814. // uint8_t ChannelNum, AccessMode;
  1815. // ChannelInfo_T* pNvrChInfo;
  1816. // ChannelInfo_T* pChannelInfo;
  1817. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1818. // uint8_t AccessFlags = 0,i=0,*curchannel;
  1819. //// char ChFilename[MAX_CHFILE_NAME];
  1820. // /* Reserve Bit Checking for Set Channel Acces */
  1821. // for(i=0;i<ReqLen;i++)
  1822. // {
  1823. // if( 0 != (pReq[i] & m_Set_ChReserveBit[i]))
  1824. // {
  1825. // *pRes = CC_INV_DATA_FIELD;
  1826. // return sizeof (*pRes);
  1827. // }
  1828. // }
  1829. // /* Reserve Value checking */
  1830. // if((pReq[1] & 0xC0)== 0xC0 || (pReq[2] & 0xC0) == 0xC0)
  1831. // {
  1832. // *pRes = CC_INV_DATA_FIELD;
  1833. // return sizeof (*pRes);
  1834. // }
  1835. // ChannelNum = pSetChAccessReq->ChannelNum & 0x0F;
  1836. // if (CURRENT_CHANNEL_NUM == ChannelNum)
  1837. // {
  1838. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  1839. // ChannelNum = *curchannel & 0xF;
  1840. // }
  1841. // if (((GetBits (pSetChAccessReq->Privilege, 0x0F)) < PRIV_LEVEL_CALLBACK) ||
  1842. // ((GetBits (pSetChAccessReq->Privilege, 0x0F)) > PRIV_LEVEL_PROPRIETARY))
  1843. // {
  1844. // IPMI_DBG_PRINT_1 ("Invalid Channel Privilege = 0x%x\n", pSetChAccessReq->Privilege);
  1845. // *pRes = CC_INV_DATA_FIELD;
  1846. // return sizeof (*pRes);
  1847. // }
  1848. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  1849. // pChannelInfo = getChannelInfo(ChannelNum, BMCInst);
  1850. // if (NULL == pChannelInfo)
  1851. // {
  1852. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1853. // *pRes = CC_INV_DATA_FIELD;
  1854. // return sizeof (*pRes);
  1855. // }
  1856. // /*point to NVRAM ChannelInfo */
  1857. // pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
  1858. // if (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport)
  1859. // {
  1860. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1861. // /* Channel is sessionless channel this command is not supported */
  1862. // *pRes = CC_SET_CH_COMMAND_NOT_SUPPORTED;
  1863. // return sizeof (*pRes);
  1864. // }
  1865. // AccessMode = pSetChAccessReq->ChannelAccess & 0x07;
  1866. // if(ChannelNum == pBMCInfo->SERIALch)
  1867. // {
  1868. // if( NULL != g_PDKHandle[PDK_SWITCHMUX])
  1869. // {
  1870. // ((void(*)(uint8_t, int))(g_PDKHandle[PDK_SWITCHMUX]))(AccessMode ,BMCInst);
  1871. // }
  1872. // }
  1873. // /* if the requested access mode is supported for the given channel */
  1874. // if (0 == (pChannelInfo->AccessModeSupported & (1 << AccessMode)))
  1875. // {
  1876. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1877. // *pRes = CC_SET_CH_ACCES_MODE_NOT_SUPPORTED;
  1878. // return sizeof (*pRes);
  1879. // }
  1880. // AccessFlags = GetBits (pSetChAccessReq->ChannelAccess, 0xC0);
  1881. // switch (AccessFlags)
  1882. // {
  1883. // case 0:
  1884. // /* dont set channel access */
  1885. // break;
  1886. // case 1:
  1887. // /*set in Non volatile Memory and in voatile Memory */
  1888. // pNvrChInfo->Alerting = GetBits (pSetChAccessReq->ChannelAccess , 0x20);
  1889. // pNvrChInfo->PerMessageAuth = GetBits (pSetChAccessReq->ChannelAccess , 0x10);
  1890. // pNvrChInfo->UserLevelAuth = GetBits (pSetChAccessReq->ChannelAccess , 0x08);
  1891. // pNvrChInfo->AccessMode = AccessMode;
  1892. // /* write to NVRAM */
  1893. // FlushChConfigs((uint8_t*)pNvrChInfo,pNvrChInfo->ChannelNumber,BMCInst);
  1894. // pChannelInfo->Alerting = pNvrChInfo->Alerting;
  1895. // pChannelInfo->PerMessageAuth= pNvrChInfo->PerMessageAuth;
  1896. // pChannelInfo->UserLevelAuth = pNvrChInfo->UserLevelAuth;
  1897. // pChannelInfo->AccessMode = AccessMode;
  1898. // break;
  1899. // case 2:
  1900. // /*set in volatile Memmory only */
  1901. // pChannelInfo->Alerting = GetBits (pSetChAccessReq->ChannelAccess, 0x20);
  1902. // pChannelInfo->PerMessageAuth= GetBits (pSetChAccessReq->ChannelAccess, 0x10);
  1903. // pChannelInfo->UserLevelAuth = GetBits (pSetChAccessReq->ChannelAccess, 0x08);
  1904. // pChannelInfo->AccessMode = AccessMode;
  1905. // }
  1906. // switch (GetBits (pSetChAccessReq->Privilege, 0xC0))
  1907. // {
  1908. // case 0:
  1909. // /* dont set prilivege level */
  1910. // break;
  1911. // case 1:
  1912. // /* set in non volatile mem and volatile memeory*/ /*set privilege*/
  1913. // pNvrChInfo->MaxPrivilege = GetBits (pSetChAccessReq->Privilege, 0x0F);
  1914. // pChannelInfo->MaxPrivilege = pNvrChInfo->MaxPrivilege;
  1915. // break;
  1916. // case 2:
  1917. // /*set privilege*/
  1918. // /* set in volatile memeory only */
  1919. // pChannelInfo->MaxPrivilege = GetBits (pSetChAccessReq->Privilege, 0x0F);
  1920. // }
  1921. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1922. // *pRes = CC_NORMAL;
  1923. // return sizeof (*pRes);
  1924. //}
  1925. ///*---------------------------------------
  1926. //* GetChAccess
  1927. //*---------------------------------------*/
  1928. //int
  1929. //GetChAccess ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1930. //{
  1931. // GetChAccessReq_T* pGetChAccessReq = ( GetChAccessReq_T*)pReq;
  1932. // GetChAccessRes_T* pGetChAccessRes = ( GetChAccessRes_T*)pRes;
  1933. // ChannelInfo_T* pChannelInfo;
  1934. // ChannelInfo_T* pNvrChInfo;
  1935. // uint8_t ChannelNum,AccessFlag,*curchannel;
  1936. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  1937. // /* Check for reserved bits */
  1938. // if((0 != (pGetChAccessReq->ChannelNum & 0xf0)) ||
  1939. // (0 != (pGetChAccessReq-> AccessFlag & 0x3f)))
  1940. // {
  1941. // pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
  1942. // return sizeof (*pRes);
  1943. // }
  1944. // ChannelNum = pGetChAccessReq->ChannelNum & 0x0F;
  1945. // if (CURRENT_CHANNEL_NUM == ChannelNum)
  1946. // {
  1947. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  1948. // ChannelNum = *curchannel & 0xF;
  1949. // }
  1950. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  1951. // pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
  1952. // if (NULL == pChannelInfo)
  1953. // {
  1954. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1955. // pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
  1956. // return sizeof (*pRes);
  1957. // }
  1958. // if (SESSIONLESS_CHANNEL == pChannelInfo->SessionSupport)
  1959. // {
  1960. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1961. // /* Channel is sessionless channel this command is not supported */
  1962. // pGetChAccessRes->CompletionCode = CC_GET_CH_COMMAND_NOT_SUPPORTED;
  1963. // return sizeof (*pRes);
  1964. // }
  1965. // AccessFlag = GetBits (pGetChAccessReq->AccessFlag, 0xC0);
  1966. // pGetChAccessRes->CompletionCode = CC_NORMAL;
  1967. // switch (AccessFlag)
  1968. // {
  1969. // case 1:
  1970. // /* Get Channel Information from NVRAM */
  1971. // pNvrChInfo = GetNVRChConfigs(pChannelInfo,BMCInst);
  1972. // pGetChAccessRes->ChannelAccess = SetBits (0x20, pNvrChInfo->Alerting);
  1973. // pGetChAccessRes->ChannelAccess |= SetBits (0x10, pNvrChInfo->PerMessageAuth);
  1974. // pGetChAccessRes->ChannelAccess |= SetBits (0x08, pNvrChInfo->UserLevelAuth);
  1975. // pGetChAccessRes->ChannelAccess |= SetBits (0x07, pNvrChInfo->AccessMode);
  1976. // pGetChAccessRes->Privilege = SetBits (0x0F, pNvrChInfo->MaxPrivilege);
  1977. // break;
  1978. // case 2:
  1979. // /* Get Channel Information from Volatile RAM */
  1980. // pGetChAccessRes->ChannelAccess = SetBits (0x20, pChannelInfo->Alerting);
  1981. // pGetChAccessRes->ChannelAccess |= SetBits (0x10, pChannelInfo->PerMessageAuth);
  1982. // pGetChAccessRes->ChannelAccess |= SetBits (0x08, pChannelInfo->UserLevelAuth);
  1983. // pGetChAccessRes->ChannelAccess |= SetBits (0x07, pChannelInfo->AccessMode);
  1984. // pGetChAccessRes->Privilege = SetBits (0x0F, pChannelInfo->MaxPrivilege);
  1985. // break;
  1986. // default:
  1987. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1988. // pGetChAccessRes->CompletionCode = CC_INV_DATA_FIELD;
  1989. // return sizeof (*pRes);
  1990. // }
  1991. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  1992. // return sizeof (GetChAccessRes_T);
  1993. //}
  1994. ///*---------------------------------------
  1995. //* GetChInfo
  1996. //*---------------------------------------*/
  1997. //int
  1998. //GetChInfo ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1999. //{
  2000. // GetChInfoReq_T* pGetChInfoReq = ( GetChInfoReq_T*)pReq;
  2001. // GetChInfoRes_T* pGetChInfoRes = ( GetChInfoRes_T*)pRes;
  2002. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  2003. // ChannelInfo_T* pChannelInfo;
  2004. // uint8_t ChannelNum,*curchannel;
  2005. // if(pGetChInfoReq->ChannelNum & (BIT7 | BIT6 | BIT5 | BIT4)) //Check for Reserved bits
  2006. // {
  2007. // pGetChInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  2008. // return sizeof(*pRes);
  2009. // }
  2010. // ChannelNum = pGetChInfoReq->ChannelNum;
  2011. // if (CURRENT_CHANNEL_NUM == ChannelNum)
  2012. // {
  2013. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  2014. // ChannelNum = *curchannel & 0xF;
  2015. //
  2016. // /* UDS, not being a physical channel, will hold LAN properties */
  2017. // if(UDS_CHANNEL == ChannelNum)
  2018. // {
  2019. // ChannelNum = LAN_RMCP_CHANNEL1_TYPE;
  2020. // }
  2021. // }
  2022. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  2023. // pChannelInfo = getChannelInfo(ChannelNum, BMCInst);
  2024. // if (NULL == pChannelInfo)
  2025. // {
  2026. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2027. // pGetChInfoRes->CompletionCode = CC_INV_DATA_FIELD ;
  2028. // return sizeof (*pRes);
  2029. // }
  2030. // pGetChInfoRes->CompletionCode = CC_NORMAL;
  2031. // pGetChInfoRes->ChannelNum = ChannelNum;
  2032. // pGetChInfoRes->ChannelMedium = pChannelInfo->ChannelMedium;
  2033. // pGetChInfoRes->ChannelProtocol = pChannelInfo->ChannelProtocol;
  2034. // pGetChInfoRes->SessionActiveSupport = pChannelInfo->SessionSupport << 6;
  2035. // pGetChInfoRes->SessionActiveSupport |= pChannelInfo->ActiveSession;
  2036. // _fmemcpy (pGetChInfoRes->VendorID, pChannelInfo->ProtocolVendorId,
  2037. // sizeof (pGetChInfoRes->VendorID));
  2038. // _fmemcpy (pGetChInfoRes->AuxiliaryInfo, pChannelInfo->AuxiliaryInfo,
  2039. // sizeof (pGetChInfoRes->AuxiliaryInfo));
  2040. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  2041. // return sizeof (GetChInfoRes_T);
  2042. //}
  2043. ///*---------------------------------------
  2044. //* IsChannelSuppGroups
  2045. //*---------------------------------------*/
  2046. //uint8_t IsChannelSuppGroups(uint8_t ChannelNum )
  2047. //{
  2048. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  2049. // ChannelInfo_T* pChannelInfo;
  2050. // if(IsLANChannel(ChannelNum, BMCInst))
  2051. // {
  2052. //
  2053. // pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
  2054. // if(pChannelInfo==NULL)
  2055. // return 0;
  2056. // if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL1_TYPE)
  2057. // {
  2058. // return pChannelInfo->ChannelType;
  2059. // }
  2060. // else
  2061. // {
  2062. // if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL2_TYPE)
  2063. // {
  2064. // return pChannelInfo->ChannelType;
  2065. // }
  2066. // else
  2067. // {
  2068. // if(pChannelInfo->ChannelType==LAN_RMCP_CHANNEL3_TYPE)
  2069. // {
  2070. // return pChannelInfo->ChannelType;
  2071. // }
  2072. // else
  2073. // return 0;
  2074. // }
  2075. // }
  2076. // return 0;
  2077. // }
  2078. // else
  2079. // {
  2080. // if (pBMCInfo->IpmiConfig.SerialIfcSupport == 1 && (pBMCInfo->SERIALch != CH_NOT_USED && ChannelNum == pBMCInfo->SERIALch))
  2081. // {
  2082. // pChannelInfo = getChannelInfo (ChannelNum, BMCInst);
  2083. // if(pChannelInfo==NULL)
  2084. // return 0;
  2085. // return pChannelInfo->ChannelType;
  2086. // }
  2087. // else
  2088. // return 0;
  2089. // }
  2090. //}
  2091. ///*---------------------------------------
  2092. //* ModifyUsrGRP
  2093. //*---------------------------------------*/
  2094. //int
  2095. //ModifyUsrGrp(char * UserName,uint8_t ChannelNum,uint8_t OldAccessLimit, uint8_t NewAccessLimit )
  2096. //{
  2097. // char oldgrp[20]="",newgrp[20]="";
  2098. // if(0 == NewAccessLimit)
  2099. // {
  2100. // DeleteUsrFromIPMIGrp(UserName);
  2101. // }
  2102. // if(PRIV_LEVEL_NO_ACCESS == OldAccessLimit)
  2103. // {
  2104. // strcpy(oldgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege].grpname);
  2105. // }
  2106. // else if(IGNORE_ADD_OR_REMOVE != OldAccessLimit)
  2107. // {
  2108. // strcpy(oldgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege+OldAccessLimit].grpname);
  2109. // }
  2110. // if(PRIV_LEVEL_NO_ACCESS == NewAccessLimit)
  2111. // {
  2112. // strcpy(newgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege].grpname);
  2113. // }
  2114. // else if(IGNORE_ADD_OR_REMOVE != NewAccessLimit)
  2115. // {
  2116. // strcpy(newgrp,g_GrpPriv[g_ChannelPrivtbl[ChannelNum].Privilege+NewAccessLimit].grpname);
  2117. // }
  2118. // AddIPMIUsrtoChGrp(UserName,(char *)oldgrp,(char *)newgrp);
  2119. // return 0;
  2120. //}
  2121. /*---------------------------------------
  2122. * SetUserAccess
  2123. *---------------------------------------*/
  2124. int
  2125. SetUserAccess ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  2126. {
  2127. SetUserAccessReq_T* pSetUserAccessReq = ( SetUserAccessReq_T*)pReq;
  2128. UserInfo_T* pUserInfo;
  2129. if (ReqLen == sizeof(SetUserAccessReq_T) - sizeof(pSetUserAccessReq->SessionLimit) )
  2130. {
  2131. pSetUserAccessReq->SessionLimit = 0;
  2132. }
  2133. else if(ReqLen == sizeof(SetUserAccessReq_T))
  2134. {
  2135. if(0 != pSetUserAccessReq->SessionLimit)
  2136. {
  2137. *pRes = CC_INV_DATA_FIELD;
  2138. return sizeof (*pRes);
  2139. }
  2140. }
  2141. else
  2142. {
  2143. *pRes = CC_REQ_INV_LEN;
  2144. return sizeof (*pRes);
  2145. }
  2146. pUserInfo = getUserIdInfo(pSetUserAccessReq->UserID);
  2147. if (NULL == pUserInfo)
  2148. {
  2149. printf ("AppDevice.c : SetUserAccess - Invalid user Id\n");
  2150. *pRes = CC_INV_DATA_FIELD;
  2151. return sizeof (*pRes);
  2152. }
  2153. // if (pUserInfo->ID != USER_ID)
  2154. // {
  2155. // printf("Invalid data field\n");
  2156. // *pRes = CC_INV_DATA_FIELD;
  2157. // return sizeof (*pRes);
  2158. // }
  2159. // pUserInfo->ChannelAccess = (pSetUserAccessReq->ChannelNoUserAccess&0x70) | (pSetUserAccessReq->AccessLimit&0x0f);
  2160. *pRes = CC_NORMAL;
  2161. return sizeof (*pRes);
  2162. }
  2163. /*---------------------------------------
  2164. * GetUserAccess
  2165. *---------------------------------------*/
  2166. int
  2167. GetUserAccess ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  2168. {
  2169. GetUserAccessReq_T* pGetUserAccessReq = ( GetUserAccessReq_T*)pReq;
  2170. GetUserAccessRes_T* pGetUserAccessRes = ( GetUserAccessRes_T*)pRes;
  2171. UserInfo_T* pUserInfo;
  2172. pUserInfo = getUserIdInfo (pGetUserAccessReq->UserID);
  2173. if (NULL == pUserInfo)
  2174. {
  2175. pGetUserAccessRes->CompletionCode = CC_INV_DATA_FIELD;
  2176. return sizeof (*pRes);
  2177. }
  2178. pGetUserAccessRes->CompletionCode = CC_NORMAL;
  2179. pGetUserAccessRes->MaxNoUserID = MAX_USER_NUM;
  2180. pGetUserAccessRes->CurrentUserID = g_BMCInfo.CurrentNoUser;
  2181. pGetUserAccessRes->FixedUserID = 0;
  2182. //pGetUserAccessRes->ChannelAccess = pUserInfo->ChannelAccess;
  2183. return sizeof (GetUserAccessRes_T);
  2184. }
  2185. /*---------------------------------------
  2186. * SetUserName
  2187. *---------------------------------------*/
  2188. int
  2189. SetUserName ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  2190. {
  2191. // SetUserNameReq_T* pSetUserNameReq = ( SetUserNameReq_T*)pReq;
  2192. // UserInfo_T* pUserInfo;
  2193. // uint8_t i;
  2194. // uint8_t UserName[MAX_USERNAME_LEN + 1]; //plus 1 for null terminator
  2195. // uint8_t InvalidChar[]={ ' ' , ',' , '.' , '/' , ':' , ';' , '\\' , '(', ')' , 0x01 ,
  2196. // 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09, 0x0A ,
  2197. // 0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 , 0x11 , 0x12, 0x13 ,
  2198. // 0x14 , 0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1A , 0x1B, 0x1C ,
  2199. // 0x1D , 0x1E , 0x1F , 0x7F} ;
  2200. // // Check for Reserved bits
  2201. // if(pSetUserNameReq->UserID & (BIT7 | BIT6) || (pSetUserNameReq->UserID == 0x00))
  2202. // {
  2203. // *pRes = CC_INV_DATA_FIELD;
  2204. // return sizeof(*pRes);
  2205. // }
  2206. // /*User Id exceeded the limit or Cant set NULL User */
  2207. // if (pSetUserNameReq->UserID > MAX_USER_NUM )
  2208. // {
  2209. // *pRes = CC_INV_DATA_FIELD ;
  2210. // return sizeof (*pRes);
  2211. // }
  2212. // pUserInfo = getUserIdInfo(pSetUserNameReq->UserID);
  2213. // /* We should not set the NULL user */
  2214. // if(0== pSetUserNameReq->UserName [0] )
  2215. // {
  2216. // printf("\n Setting the NULL user :%x",pSetUserNameReq->UserID);
  2217. // *pRes = CC_INV_DATA_FIELD ;
  2218. // return sizeof (*pRes);
  2219. // }
  2220. // /* check for numeric first char and special chars */
  2221. // if( (pSetUserNameReq->UserName[0] >= '0') && (pSetUserNameReq->UserName[0] <= '9') )
  2222. // {
  2223. // *pRes = CC_INV_DATA_FIELD;
  2224. // return sizeof(*pRes);
  2225. // }
  2226. // else
  2227. // {
  2228. // strncpy((char *)UserName,(const char *) pSetUserNameReq->UserName, sizeof(pSetUserNameReq->UserName));
  2229. // UserName[MAX_USERNAME_LEN] = '\0';
  2230. // for(i=0;i<sizeof(InvalidChar);i++)
  2231. // {
  2232. // if( NULL != strchr((const char *)UserName, InvalidChar[i] ))
  2233. // {
  2234. // *pRes = CC_INV_DATA_FIELD;
  2235. // return sizeof(*pRes);
  2236. // }
  2237. // }
  2238. // }
  2239. // //Don't check duplicated user names for 0xFF, this request is for deleting user
  2240. // if(0xFF != pSetUserNameReq->UserName [0])
  2241. // {
  2242. // //checking for Duplicate user names
  2243. // if(CheckForDuplicateUsers(pSetUserNameReq->UserName)==FALSE)
  2244. // {
  2245. // //setting user's name with same name
  2246. // if(!strncmp((char *)pUserInfo->UserName,(char *)pSetUserNameReq->UserName, MAX_USERNAME_LEN))
  2247. // {
  2248. // *pRes = CC_NORMAL;
  2249. // return sizeof (*pRes);
  2250. // }
  2251. // printf("Duplicate ipmi user!!\n");
  2252. // *pRes = CC_INV_DATA_FIELD;
  2253. // return sizeof (*pRes);
  2254. // }
  2255. // }
  2256. // /* If User[0] is 0xFF means the user is requested to delete */
  2257. // if (0xFF == pSetUserNameReq->UserName [0]) //delete user
  2258. // {
  2259. // if( (g_BMCInfo.IpmiConfig.CurrentNoUser > 1) && (USER_ID == pUserInfo->ID))
  2260. // {
  2261. // if(pUserInfo->UserStatus == TRUE)
  2262. // {
  2263. // g_BMCInfo.IpmiConfig.CurrentNoUser--;
  2264. // }
  2265. // /* Delete the user both in Volatile & Non Volatile memory*/
  2266. // memset (pUserInfo, 0, sizeof (UserInfo_T));
  2267. // }
  2268. // else
  2269. // {
  2270. // *pRes = CC_INV_DATA_FIELD ;
  2271. // return sizeof (*pRes);
  2272. // }
  2273. // }
  2274. // else if(USER_ID != pUserInfo->ID) //add user
  2275. // {
  2276. // /* If First time-if user ID does not exist */
  2277. // /* if the user name is set for the first time */
  2278. // pUserInfo->ID = USER_ID;
  2279. // pUserInfo->UserId = pSetUserNameReq->UserID;
  2280. // pUserInfo->UserStatus = FALSE;
  2281. // memcpy(pUserInfo->UserName, pSetUserNameReq->UserName, MAX_USERNAME_LEN);
  2282. // //g_BMCInfo.IpmiConfig.CurrentNoUser++;
  2283. // }
  2284. // else if (USER_ID == pUserInfo->ID)//modifying users
  2285. // {
  2286. // memcpy (pUserInfo->UserName, pSetUserNameReq->UserName, MAX_USERNAME_LEN);
  2287. // }
  2288. // UpdateFlash();
  2289. *pRes = CC_NORMAL;
  2290. return sizeof (*pRes);
  2291. }
  2292. /*---------------------------------------
  2293. * GetUserName
  2294. *---------------------------------------*/
  2295. int
  2296. GetUserName ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  2297. {
  2298. GetUserNameReq_T* pGetUserNameReq = ( GetUserNameReq_T*)pReq;
  2299. GetUserNameRes_T* pGetUserNameRes = ( GetUserNameRes_T*)pRes;
  2300. UserInfo_T* pUserInfo;
  2301. // // Check for Reserved bits
  2302. // if(pGetUserNameReq->UserID & (BIT7 | BIT6) || (pGetUserNameReq->UserID == 0x00))
  2303. // {
  2304. // pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
  2305. // return sizeof(*pRes);
  2306. // }
  2307. if (pGetUserNameReq->UserID >= MAX_USER_NUM)
  2308. {
  2309. /* if user ID exceeded the Max limit */
  2310. pGetUserNameRes->CompletionCode = CC_INV_DATA_FIELD ;
  2311. return sizeof (*pRes);/* Invalied user id */
  2312. }
  2313. pUserInfo = getUserIdInfo(pGetUserNameReq->UserID);
  2314. /* if User is disabled or if User is not created */
  2315. //if user is disabled we dont have to return invalid data field
  2316. //instead we return everything possible about the user
  2317. // if pUserInfo is NULL then nothing in the structure at all
  2318. // pUserInfo being NULL is probably not possible
  2319. // If the signature doesnt match then the useris not yet configured
  2320. // so reasonable to return an error
  2321. // if ((NULL == pUserInfo) || (pUserInfo->ID != USER_ID))
  2322. // {
  2323. // /* User with given ID is disabled */
  2324. // *pRes = CC_INV_DATA_FIELD;
  2325. // return sizeof (*pRes);
  2326. // }
  2327. // //if we are here then the user is just disabled
  2328. // if(FALSE == pUserInfo->UserStatus)
  2329. // {
  2330. // printf("user is just dissabled\n");
  2331. // //user is just disabled!!
  2332. // }
  2333. //Err = 0;
  2334. pGetUserNameRes->CompletionCode = CC_NORMAL;
  2335. memcpy (pGetUserNameRes->UserName, pUserInfo->UserName, MAX_USERNAME_LEN);
  2336. return sizeof (GetUserNameRes_T);
  2337. }
  2338. /*---------------------------------------
  2339. * SetUserPassword
  2340. *---------------------------------------*/
  2341. int
  2342. SetUserPassword ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  2343. {
  2344. // SetUserPswdReq_T* pSetUserPswdReq = ( SetUserPswdReq_T*)pReq;
  2345. // UserInfo_T* pUserInfo;
  2346. // uint8_t UserId=0, Operation;
  2347. // uint8_t i;
  2348. // uint8_t UserPassword[ MAX_PASSWORD_LEN + 1 ];
  2349. // uint8_t InvalidChar[] = { 0x01 , 0x02 , 0x03 , 0x04 ,0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x0A,
  2350. // 0x0B , 0x0C , 0x0D , 0x0E , 0x0F , 0x10 , 0x11 , 0x12 , 0x13 , 0x14,
  2351. // 0x15 , 0x16 , 0x17 , 0x18 , 0x19 , 0x1A , 0x1B , 0x1C , 0x1D , 0x1E ,
  2352. // 0x1F , 0x7F };
  2353. // Operation = pSetUserPswdReq->Operation & 0x03;
  2354. // UserId = pSetUserPswdReq->UserID & 0x3F;
  2355. // /* Reserved bits checking */
  2356. // if((pSetUserPswdReq->UserID & BIT6) || (UserId == 0) || (pSetUserPswdReq->Operation & (BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)))
  2357. // {
  2358. // *pRes = CC_INV_DATA_FIELD;
  2359. // return sizeof (*pRes);
  2360. // }
  2361. // if (ReqLen == IPMI_15_PASSWORD_LEN)
  2362. // {
  2363. // memset (pSetUserPswdReq->Password + 16, 0, 4);
  2364. // }
  2365. // ReqLen -=2;
  2366. // if (UserId > MAX_USER_NUM)
  2367. // {
  2368. // *pRes = CC_INV_DATA_FIELD;
  2369. // return sizeof (*pRes); /*User Id exceeded the limit*/
  2370. // }
  2371. // pUserInfo = getUserIdInfo (UserId);
  2372. // if ( NULL == pUserInfo )
  2373. // {
  2374. // printf ("Invalid User Id \n");
  2375. // *pRes = CC_INV_DATA_FIELD;
  2376. // return sizeof (*pRes);
  2377. // }
  2378. // *pRes = CC_NORMAL;
  2379. // switch (Operation)
  2380. // {
  2381. // case DISABLE_USER:
  2382. // /*disable user */
  2383. // if(pUserInfo == NULL)
  2384. // {
  2385. // //the user is already disabled!!
  2386. // //no point in disabling him again
  2387. // }
  2388. // else
  2389. // {
  2390. // //here we can disable the user
  2391. // if ((pUserInfo->UserStatus == TRUE) && (USER_ID == pUserInfo->ID) && (g_BMCInfo.IpmiConfig.CurrentNoUser > 1))
  2392. // {
  2393. // pUserInfo->UserStatus = FALSE;
  2394. // pUserInfo->ChannelAccess &= 0x0f;
  2395. // g_BMCInfo.IpmiConfig.CurrentNoUser--;
  2396. // UpdateFlash();
  2397. // }
  2398. // }
  2399. // break;
  2400. // case ENABLE_USER:
  2401. // /*enable user */
  2402. // if (USER_ID == pUserInfo->ID)
  2403. // {
  2404. // /* if for the first time then Increment the Current user No */
  2405. // if ( pUserInfo->UserStatus == FALSE )
  2406. // {
  2407. // pUserInfo->UserStatus = TRUE;
  2408. // pUserInfo->ChannelAccess |= 0x70;
  2409. // g_BMCInfo.IpmiConfig.CurrentNoUser++;
  2410. // UpdateFlash();
  2411. // }
  2412. // }
  2413. // else
  2414. // {
  2415. // *pRes = CC_UNSPECIFIED_ERR;
  2416. // return sizeof (*pRes);
  2417. // }
  2418. // break;
  2419. // case SET_PASSWORD:
  2420. // /*set password */
  2421. // if (USER_ID == pUserInfo->ID)
  2422. // {
  2423. // /*check for special characters*/
  2424. // strncpy((char *)UserPassword,(const char *) pSetUserPswdReq->Password, sizeof(pSetUserPswdReq->Password));
  2425. // UserPassword[MAX_PASSWORD_LEN] = '\0';
  2426. // for( i = 0 ; i < sizeof(InvalidChar) ; i++ )
  2427. // {
  2428. // if( NULL != strchr((const char *)UserPassword, InvalidChar[i] ))
  2429. // {
  2430. // *pRes = CC_INV_DATA_FIELD;
  2431. // return sizeof(*pRes);
  2432. // }
  2433. // }
  2434. // pUserInfo->MaxPasswordSize = ReqLen;
  2435. // memcpy (pUserInfo->UserPassword, pSetUserPswdReq->Password, MAX_PASSWORD_LEN);
  2436. // UpdateFlash();
  2437. // }
  2438. // else
  2439. // {
  2440. // *pRes = CC_INV_DATA_FIELD;
  2441. // return sizeof (*pRes);
  2442. // }
  2443. // break;
  2444. // case TEST_PASSWORD:
  2445. // memcpy (UserPassword, pUserInfo->UserPassword, MAX_PASSWORD_LEN);
  2446. // /*Test Password */
  2447. // if( ReqLen != pUserInfo->MaxPasswordSize && (pUserInfo->MaxPasswordSize != 0))
  2448. // {
  2449. // *pRes = CC_PASSWORD_TEST_FAILED_WRONG_SIZE;
  2450. // }
  2451. // else if (((FALSE == pUserInfo->UserStatus) && (pUserInfo->ID != USER_ID)) ||
  2452. // (0 != memcmp (UserPassword, pSetUserPswdReq->Password, MAX_PASSWORD_LEN)))
  2453. // {
  2454. // *pRes = CC_PASSWORD_TEST_FAILED;
  2455. // }
  2456. // break;
  2457. // }
  2458. return sizeof (*pRes);
  2459. }
  2460. ///*---------------------------------------
  2461. //* MasterWriteRead
  2462. //*---------------------------------------*/
  2463. //int
  2464. //MasterWriteRead ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  2465. //{
  2466. // MasterWriteReadReq_T* pMasterWriteReadReq = ( MasterWriteReadReq_T*)pReq;
  2467. // MasterWriteReadRes_T* pMasterWriteReadRes = ( MasterWriteReadRes_T*)pRes;
  2468. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  2469. // uint8_t* OutBuffer;
  2470. // uint8_t* InBuffer;
  2471. // uint8_t ChannelNum, BusID, BusType, SlaveAddr, ReadCount, WriteCount;
  2472. // INT8S BusName[64];
  2473. // int retval = 0;
  2474. // uint8_t OrgReadCount;
  2475. // uint8_t I2CBusId=0;
  2476. // uint8_t DevID = 0; // This will be '0' by Default... /dev/peci0
  2477. // uint8_t Target = 0x30; // This is the Client address. 30h = 48 is Default for CPU0
  2478. // uint8_t Domain = 0; // Multi-Domain support. Default is '0'
  2479. // uint8_t Xmit_Feedback = 0; // If full response is Desired, enable this. Default is '1'
  2480. // uint8_t AWFCS = 0; // Enable AWFCS in the Transmitted packet by Hw. Default is '0'
  2481. // uint8_t Read_Len = 0; // Number of bytes of read back Data from PECI Client
  2482. // uint8_t Write_Len = 0; // Number of bytes of data, host is sending to client
  2483. // uint8_t *Write_Data = NULL; // Pointer to the Data sent by User to the PECI Client
  2484. // uint8_t *Read_Data = NULL; // Pointer to the Data received from PECI Client to be sent to user
  2485. // int ret_val = 0;
  2486. // if(pMasterWriteReadReq->SlaveAddress & BIT0)
  2487. // {
  2488. // *pRes = CC_INV_DATA_FIELD;
  2489. // return sizeof (*pRes);
  2490. // }
  2491. // ReadCount = pMasterWriteReadReq->ReadCount;
  2492. // ChannelNum = GetBits (pMasterWriteReadReq->BusTypeChNo, 0xF0);
  2493. // BusID = GetBits (pMasterWriteReadReq->BusTypeChNo, 0x0E);
  2494. // BusType = GetBits (pMasterWriteReadReq->BusTypeChNo, 0x01);
  2495. // SlaveAddr = (pMasterWriteReadReq->SlaveAddress >> 1);
  2496. // if ((BusType == 0x00 && BusID != 0x00) || ((BusType == 0x01) && (BusID == 0x00)))
  2497. // {
  2498. // *pRes = CC_INV_DATA_FIELD;
  2499. // return sizeof (*pRes);
  2500. // }
  2501. // // Command order:
  2502. // // ipmitool -H <IP> -I lan -U <Username> -P <Password> bus=7 <Slave_Addr> <Read_Len> <Write_Len> <AWFCS> <Domain> <Data>
  2503. // // <bus=7> : Bus# must be 0x07 for comunicating with PECI over IPMI. Other buses are not for this feature
  2504. // // <Slave_Addr> : This is the PECI Client target address.
  2505. // // <Read_Len> : Number of bytes of data to read from the PECI Response
  2506. // // <Write_Len> : Number of bytes of data being written, as per the PECI Spec. Number of Bytes after Domain.
  2507. // // <AWFCS> : 0x01 or 0x00 indicates enabling or disabling of AWFCS feature respectively
  2508. // // <Domain> : 0x01 or 0x00 indicates domain=1 or domain=0 for multi-domain commands respectively
  2509. // // <Data> : Rest of data like Command, and other params as per the PECI Spec.
  2510. // // If BusType is External (0x01) and BusID is 7, then we consider to communicate with PECI
  2511. //
  2512. // if(g_corefeatures.peci_over_ipmi == ENABLED )
  2513. // {
  2514. // if ((BusType & 0x01) && (BusID == 0x07))
  2515. // {
  2516. // DevID = 0;
  2517. // Xmit_Feedback = 0;
  2518. // Target = pMasterWriteReadReq->SlaveAddress;
  2519. // Read_Len = ReadCount;
  2520. // Write_Len = pMasterWriteReadReq->Data[0];
  2521. // AWFCS = pMasterWriteReadReq->Data[1];
  2522. // Domain = pMasterWriteReadReq->Data[2];
  2523. // Write_Data = &pMasterWriteReadReq->Data[3];
  2524. // Read_Data = &pMasterWriteReadRes->Data[0];
  2525. // memset(&pMasterWriteReadRes->Data[0], 0, sizeof(pMasterWriteReadRes->Data));
  2526. //
  2527. // // Call the PECI Generic Handler for passing the command to the PECI Controller
  2528. // if(g_HALPECIHandle[HAL_PECI_COMMAND] != NULL)
  2529. // {
  2530. // ret_val = ((int(*)(char, char, char, char, char, char *, char, char *, char))g_HALPECIHandle[HAL_PECI_COMMAND]) (DevID, Target,
  2531. // Domain, Xmit_Feedback, AWFCS,
  2532. // (char *)Write_Data, Write_Len,
  2533. // (char *)Read_Data, Read_Len );
  2534. // }
  2535. // else
  2536. // {
  2537. // pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  2538. // return sizeof (*pRes);
  2539. // }
  2540. // /* Check if peci issue command operation is success or not */
  2541. // if (ret_val == -1)
  2542. // {
  2543. // pMasterWriteReadRes->CompletionCode = CC_INV_DATA_FIELD;
  2544. // return sizeof (*pRes);
  2545. // }
  2546. // pMasterWriteReadRes->CompletionCode = CC_NORMAL;
  2547. // return (sizeof (*pRes) + ReadCount);
  2548. // }
  2549. // }
  2550. // if(0 ==BusType){
  2551. // if(PRIMARY_IPMB_CHANNEL == ChannelNum)
  2552. // {
  2553. // I2CBusId=pBMCInfo->IpmiConfig.PrimaryIPMBBusNumber;
  2554. // }
  2555. // else if((pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)&&(pBMCInfo->SecondaryIPMBCh == ChannelNum))
  2556. // {
  2557. // I2CBusId=pBMCInfo->IpmiConfig.SecondaryIPMBBusNumber;
  2558. // }else{
  2559. // *pRes = CC_INV_DATA_FIELD;
  2560. // return sizeof (*pRes);
  2561. // }
  2562. // }
  2563. // else
  2564. // {
  2565. // if(BusID==pBMCInfo->IpmiConfig.PrimaryIPMBBusNumber)
  2566. // {
  2567. // *pRes = CC_INV_DATA_FIELD;
  2568. // return sizeof (*pRes);
  2569. // }else if((pBMCInfo->IpmiConfig.SecondaryIPMBSupport == 0x01)&&(BusID==pBMCInfo->IpmiConfig.SecondaryIPMBBusNumber))
  2570. // {
  2571. // *pRes = CC_INV_DATA_FIELD;
  2572. // return sizeof (*pRes);
  2573. // }else{
  2574. // I2CBusId=BusID;
  2575. // }
  2576. // }
  2577. // if (ReqLen < 3)
  2578. // {
  2579. // *pRes = CC_REQ_INV_LEN;
  2580. // return sizeof (*pRes);
  2581. // }
  2582. // /* number of bytes to write
  2583. // * = pMasterWriteReadReq length - 3 for Request Data byte -
  2584. // * BusTypeChNo,SlaveAddr,Readcount + 1 byte for address
  2585. // */
  2586. // WriteCount = ReqLen - 3;
  2587. // OutBuffer = (pMasterWriteReadReq->Data);
  2588. // InBuffer = pMasterWriteReadRes->Data;
  2589. // sprintf(BusName,"/dev/i2c%d",I2CBusId);
  2590. // // Save original ReadCount in case we need to modify it
  2591. // OrgReadCount = ReadCount;
  2592. // // If both ReadCount and WriteCount are zero, then force a read of 1 byte.
  2593. // // If we do not do this, the write command will fail.
  2594. // // Having both counts 0 is a way of "pinging" the given device to see if it
  2595. // // is responding to its address.
  2596. //
  2597. // if (ReadCount == 0 && WriteCount == 0)
  2598. // {
  2599. // ReadCount = 1;
  2600. // }
  2601. // if (ReadCount > 0 && WriteCount == 0)
  2602. // {
  2603. // if(g_HALI2CHandle[HAL_I2C_MR] != NULL)
  2604. // {
  2605. // retval = ((int(*)(char *,u8,u8 *,size_t))g_HALI2CHandle[HAL_I2C_MR]) (BusName, SlaveAddr, InBuffer, ReadCount);
  2606. // if (retval < 0)
  2607. // {
  2608. // pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
  2609. // return sizeof (*pRes);
  2610. // }
  2611. // }
  2612. // else
  2613. // {
  2614. // pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  2615. // return sizeof(*pRes);
  2616. // }
  2617. // ReadCount = OrgReadCount;
  2618. // /* copy the bytes read to Response Data */
  2619. // _fmemcpy (pMasterWriteReadRes->Data, InBuffer, ReadCount);
  2620. // }
  2621. // else if(ReadCount > 0 && WriteCount > 0 )
  2622. // {
  2623. // if(g_HALI2CHandle[HAL_I2C_RW] != NULL)
  2624. // {
  2625. // retval = ((int(*)(char *,u8,u8 *,u8 *,size_t,size_t))g_HALI2CHandle[HAL_I2C_RW]) (BusName, SlaveAddr, OutBuffer, InBuffer, WriteCount, ReadCount);
  2626. // if (retval < 0)
  2627. // {
  2628. // pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
  2629. // return sizeof (*pRes);
  2630. // }
  2631. // }
  2632. // else
  2633. // {
  2634. // pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  2635. // return sizeof(*pRes);
  2636. // }
  2637. // ReadCount = OrgReadCount;
  2638. // /* copy the bytes read to Response Data */
  2639. // _fmemcpy (pMasterWriteReadRes->Data, InBuffer, ReadCount);
  2640. // }
  2641. // else
  2642. // {
  2643. // /* No data to read so use master write instead,
  2644. // * otherwise some devices (EEPROM) that have not finished writing
  2645. // * will fail on the read transaction and possibly corrupt data
  2646. // */
  2647. // if(g_HALI2CHandle[HAL_I2C_MW] != NULL)
  2648. // {
  2649. // retval= ((ssize_t(*)(char *,u8,u8 *,size_t))g_HALI2CHandle[HAL_I2C_MW]) (BusName, SlaveAddr, OutBuffer, WriteCount);
  2650. // if(retval < 0)
  2651. // {
  2652. // pMasterWriteReadRes->CompletionCode = (retval & MASTER_RW_ERRCODE);
  2653. // return sizeof (*pRes);
  2654. // }
  2655. // }
  2656. // else
  2657. // {
  2658. // pMasterWriteReadRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  2659. // return sizeof(*pRes);
  2660. // }
  2661. // }
  2662. // pMasterWriteReadRes->CompletionCode = CC_NORMAL;
  2663. // return (sizeof (*pRes) + ReadCount);
  2664. //}
  2665. //#if 0
  2666. ///*-------------------------------------------
  2667. //* ComputeAuthCode
  2668. //*-------------------------------------------*/
  2669. //void
  2670. //ComputeAuthCode ( uint8_t* pPassword, SessionHdr_T* pSessionHdr,
  2671. // IPMIMsgHdr_T* pIPMIMsg, uint8_t* pAuthCode,
  2672. // uint8_t ChannelType)
  2673. //{
  2674. // if (AUTH_TYPE_PASSWORD == pSessionHdr->AuthType)
  2675. // {
  2676. // _fmemcpy (pAuthCode, pPassword, MAX_PASSWORD_LEN);
  2677. // }
  2678. // else
  2679. // {
  2680. // uint8_t AuthBuf [MAX_AUTH_PARAM_SIZE];
  2681. // uint16_t AuthBufLen = 0;
  2682. // uint8_t IPMIMsgLen = *(( uint8_t*) pIPMIMsg - 1);
  2683. // /* Password */
  2684. // _fmemcpy (AuthBuf, pPassword, MAX_PASSWORD_LEN);
  2685. // AuthBufLen += MAX_PASSWORD_LEN;
  2686. // /* Session ID */
  2687. // _fmemcpy (AuthBuf + AuthBufLen, &pSessionHdr->SessionID, sizeof (uint32_t));
  2688. // AuthBufLen += sizeof (uint32_t);
  2689. // /* IPMI Response Message */
  2690. // _fmemcpy (AuthBuf + AuthBufLen, pIPMIMsg, IPMIMsgLen);
  2691. // AuthBufLen += IPMIMsgLen;
  2692. // if (ChannelType == MULTI_SESSION_CHANNEL)
  2693. // {
  2694. // /* Session Sequence Number */
  2695. // _fmemcpy (AuthBuf + AuthBufLen,
  2696. // &pSessionHdr->SessionSeqNum, sizeof (uint32_t));
  2697. // AuthBufLen += sizeof (uint32_t);
  2698. // }
  2699. // /* Password */
  2700. // _fmemcpy (AuthBuf + AuthBufLen, pPassword, MAX_PASSWORD_LEN);
  2701. // AuthBufLen += MAX_PASSWORD_LEN;
  2702. // switch (pSessionHdr->AuthType)
  2703. // {
  2704. // case AUTH_TYPE_MD2 :
  2705. // AuthCodeCalMD2 (AuthBuf, pAuthCode, AuthBufLen);
  2706. // break;
  2707. // case AUTH_TYPE_MD5 :
  2708. // AuthCodeCalMD5 (AuthBuf, pAuthCode, AuthBufLen);
  2709. // break;
  2710. // default :
  2711. // TDBG ("RMCP: Invalid Authentication Type \n");
  2712. // }
  2713. // }
  2714. //}
  2715. //#endif
  2716. ///*---------------------------------------
  2717. //* GetSystemInfoParam
  2718. //*---------------------------------------*/
  2719. //int
  2720. //GetSystemInfoParam ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  2721. //{
  2722. // GetSystemInfoParamReq_T* pGetSysInfoReq = ( GetSystemInfoParamReq_T*)pReq;
  2723. // GetSystemInfoParamRes_T* pGetSysInfoRes = ( GetSystemInfoParamRes_T* ) pRes ;
  2724. // GetSystemInfoParamOEMRes_T* pGetSysInfoOEMRes = ( GetSystemInfoParamOEMRes_T* ) pRes ;
  2725. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  2726. // SystemInfoConfig_T* pSysInfoCfg;
  2727. // uint8_t resSize = sizeof(pGetSysInfoRes->CompletionCode) + sizeof(pGetSysInfoRes->ParamRevision);
  2728. // uint8_t oem_len;
  2729. // unsigned long oem_addr;
  2730. // // Check for Reserved bits
  2731. // if(pGetSysInfoReq->ParamRev & (BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0))
  2732. // {
  2733. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  2734. // return sizeof(pGetSysInfoRes->CompletionCode);
  2735. // }
  2736. // pGetSysInfoRes->CompletionCode = CC_NORMAL;
  2737. // /* Fill the param's older Version and the present version */
  2738. // pGetSysInfoRes->ParamRevision = ((PARAM_OLDER_REVISION << 4) & 0xF0 ) | PARAM_PRESENT_REVISION;
  2739. // /* Check for Revision only parameter */
  2740. // if (pGetSysInfoReq->ParamRev & GET_PARAM_REV_ONLY )
  2741. // {
  2742. // if((MAX_APP_CONF_PARAM >= pGetSysInfoReq->ParamSelector))
  2743. // {
  2744. // return resSize;
  2745. // }
  2746. // else if(( NULL != g_PDKHandle[PDK_GETSYSINFOPARAM]) &&
  2747. // ((MIN_SYSINFO_OEM_CONF_PARAM <= pGetSysInfoReq->ParamSelector) && (MAX_SYSINFO_OEM_CONF_PARAM >= pGetSysInfoReq->ParamSelector)))
  2748. // {
  2749. // oem_len = ((int(*)(uint8_t, unsigned long*,int))(g_PDKHandle[PDK_GETSYSINFOPARAM]))(pGetSysInfoReq->ParamSelector, &oem_addr ,BMCInst);
  2750. // if( oem_len == 0)
  2751. // {
  2752. // pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
  2753. // return sizeof(uint8_t);
  2754. // }
  2755. // else
  2756. // return resSize;
  2757. // }
  2758. // else
  2759. // {
  2760. // *pRes = CC_PARAM_NOT_SUPPORTED;
  2761. // return sizeof (*pRes);
  2762. // }
  2763. // }
  2764. // /* Get Systen Info parameters from NVRAM */
  2765. // pSysInfoCfg = &pBMCInfo->SystemInfoConfig;
  2766. // switch(pGetSysInfoReq->ParamSelector)
  2767. // {
  2768. // case SET_IN_PROGRESS_PARAM: /*Parameter 0 volatile*/
  2769. // if( (0x00 != pGetSysInfoReq->SetSelector) || (0x00 != pGetSysInfoReq->BlockSelector) )
  2770. // {
  2771. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  2772. // return sizeof(pGetSysInfoRes->CompletionCode);
  2773. // }
  2774. // LOCK_BMC_SHARED_MEM(BMCInst);
  2775. // pGetSysInfoRes->SysInfo.SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Sys_SetInProgress;
  2776. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  2777. // resSize++;
  2778. // break;
  2779. // case SYS_FW_VERSION_PARAM:
  2780. // _fmemset(&pGetSysInfoRes->SysInfo.SysVerInfo,0,sizeof(SysVerInfo_T));
  2781. // if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
  2782. // {
  2783. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  2784. // return sizeof(pGetSysInfoRes->CompletionCode);
  2785. // }
  2786. // pGetSysInfoRes->SysInfo.SysVerInfo.SetSelector = pGetSysInfoReq->SetSelector;
  2787. // resSize++;
  2788. // if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
  2789. // {
  2790. // pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[0]=pSysInfoCfg->SysFWVersion.TypeOfEncoding;
  2791. // pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[1]=pSysInfoCfg->SysFWVersion.StringLength;
  2792. // _fmemcpy(&pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[2], pSysInfoCfg->SysFWVersion.SysFWVersionName,MAX_STRING_LENGTH_COPY);
  2793. // resSize += MAX_BLOCK_SIZE;
  2794. // }
  2795. // else
  2796. // {
  2797. // _fmemcpy(&pGetSysInfoRes->SysInfo.SysVerInfo.SysFWVersion[0],
  2798. // &pSysInfoCfg->SysFWVersion.SysFWVersionName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
  2799. // resSize += MAX_BLOCK_SIZE;
  2800. // }
  2801. // break;
  2802. // case SYS_NAME_PARAM:
  2803. // if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
  2804. // {
  2805. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  2806. // return sizeof(pGetSysInfoRes->CompletionCode);
  2807. // }
  2808. // pGetSysInfoRes->SysInfo.SysNameInfo.SetSelector = pGetSysInfoReq->SetSelector;
  2809. // resSize++;
  2810. // if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
  2811. // {
  2812. // pGetSysInfoRes->SysInfo.SysNameInfo.SysName[0]=pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name;
  2813. // pGetSysInfoRes->SysInfo.SysNameInfo.SysName[1]=pSysInfoCfg->SysName.StringLength_Sys_Name;
  2814. // _fmemcpy(&pGetSysInfoRes->SysInfo.SysNameInfo.SysName[2],&pSysInfoCfg->SysName.SystemName,MAX_STRING_LENGTH_COPY);
  2815. // resSize += MAX_BLOCK_SIZE;
  2816. // }
  2817. // else
  2818. // {
  2819. // _fmemcpy(&pGetSysInfoRes->SysInfo.SysNameInfo.SysName[0],
  2820. // &pSysInfoCfg->SysName.SystemName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2], MAX_BLOCK_SIZE);
  2821. // resSize += MAX_BLOCK_SIZE;
  2822. // }
  2823. // break;
  2824. // case PRIM_OS_NAME_PARAM:
  2825. // if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)|| (0x00 != pGetSysInfoReq->BlockSelector))
  2826. // {
  2827. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  2828. // return sizeof(pGetSysInfoRes->CompletionCode);
  2829. // }
  2830. // pGetSysInfoRes->SysInfo.PrimOSInfo.SetSelector = pGetSysInfoReq->SetSelector;
  2831. // resSize++;
  2832. // if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
  2833. // {
  2834. // pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[0]=pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName;
  2835. // pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[1]=pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName;
  2836. // _fmemcpy(&pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[2], &pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName, MAX_STRING_LENGTH_COPY);
  2837. // resSize += MAX_BLOCK_SIZE;
  2838. // }
  2839. // else
  2840. // {
  2841. // _fmemcpy(&pGetSysInfoRes->SysInfo.PrimOSInfo.PrimaryOSName[0],
  2842. // &pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
  2843. // resSize += MAX_BLOCK_SIZE;
  2844. // }
  2845. // break;
  2846. // case OS_NAME_PARAM:
  2847. // /*Parameter 4 volatile*/
  2848. // _fmemset(&pGetSysInfoRes->SysInfo.OSInfo,0,sizeof(OSInfo_T));
  2849. // if((pGetSysInfoReq->SetSelector >= MAX_BLOCK_SIZE)||(0x00 != pGetSysInfoReq->BlockSelector))
  2850. // {
  2851. // pGetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  2852. // return sizeof(pGetSysInfoRes->CompletionCode);
  2853. // }
  2854. // pGetSysInfoRes->SysInfo.OSInfo.SetSelector = pGetSysInfoReq->SetSelector;
  2855. // resSize++;
  2856. // if(pGetSysInfoReq->SetSelector==ZERO_SETSELECTOR)
  2857. // {
  2858. // LOCK_BMC_SHARED_MEM(BMCInst);
  2859. // pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[0]=BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName;
  2860. // pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[1]=BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName;
  2861. // _fmemcpy(&pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[2], BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName, MAX_STRING_LENGTH_COPY);
  2862. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  2863. // resSize += MAX_BLOCK_SIZE;
  2864. // }
  2865. // else
  2866. // {
  2867. // LOCK_BMC_SHARED_MEM(BMCInst);
  2868. // _fmemcpy(&pGetSysInfoRes->SysInfo.OSInfo.OperatingSystemName[0],
  2869. // &BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[(pGetSysInfoReq->SetSelector * MAX_BLOCK_SIZE) - 2],MAX_BLOCK_SIZE);
  2870. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  2871. // resSize += MAX_BLOCK_SIZE;
  2872. // }
  2873. //
  2874. // break;
  2875. // default:
  2876. // if(g_PDKHandle[PDK_GETSYSINFOPARAM] != NULL &&
  2877. // (pGetSysInfoReq->ParamSelector >= 192 && pGetSysInfoReq->ParamSelector <= 255))
  2878. // {
  2879. // oem_len = ((int(*)(uint8_t, unsigned long*,int))(g_PDKHandle[PDK_GETSYSINFOPARAM]))(pGetSysInfoReq->ParamSelector, &oem_addr ,BMCInst);
  2880. // if( oem_len == 0)
  2881. // {
  2882. // pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
  2883. // return sizeof(uint8_t);
  2884. // }
  2885. // else
  2886. // {
  2887. // //Acquire the OEM parameters
  2888. // if( oem_len < MSG_PAYLOAD_SIZE - sizeof(GetLanCCRev_T))
  2889. // {
  2890. // memcpy((char*)pGetSysInfoOEMRes + sizeof(GetSystemInfoParamOEMRes_T) ,\
  2891. // (unsigned int*)oem_addr , oem_len);
  2892. // }
  2893. // else
  2894. // {
  2895. // pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
  2896. // return sizeof(uint8_t);
  2897. // }
  2898. // return sizeof(GetSystemInfoParamOEMRes_T) + oem_len;
  2899. // }
  2900. // }
  2901. // else
  2902. // {
  2903. // pGetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
  2904. // return sizeof(pGetSysInfoRes->CompletionCode);
  2905. // }
  2906. // }
  2907. // /* return the size of the response */
  2908. // return resSize;
  2909. //}
  2910. //int validatestring(uint8_t* String,int len,uint8_t TOE)
  2911. //{
  2912. // int i,delimit = 0,strlen = 0;
  2913. // for(i=0;i<len;i++)
  2914. // {
  2915. // if(String[i] == 0)
  2916. // {
  2917. // delimit++;
  2918. // }
  2919. // else
  2920. // {
  2921. // if(delimit != 0)
  2922. // {
  2923. // if(TOE == UNICODE)
  2924. // {
  2925. // if(delimit == 2)
  2926. // {
  2927. // strlen = strlen + 2;
  2928. // }
  2929. // else
  2930. // {
  2931. // return -1;
  2932. // }
  2933. // }
  2934. // else
  2935. // {
  2936. // if(delimit == 1)
  2937. // {
  2938. // strlen = strlen + 1;
  2939. // }
  2940. // else
  2941. // {
  2942. // return -1;
  2943. // }
  2944. // }
  2945. // delimit = 0;
  2946. // }
  2947. // strlen++;
  2948. // }
  2949. // }
  2950. // return strlen;
  2951. //}
  2952. ///*---------------------------------------
  2953. //* SetSystemInfoParam
  2954. //*---------------------------------------*/
  2955. //int
  2956. //SetSystemInfoParam ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  2957. //{
  2958. // SetSystemInfoParamReq_T* pSetSysInfoReq = ( SetSystemInfoParamReq_T*)pReq;
  2959. // SetSystemInfoParamOEMReq_T* pSetSysInfoOEMReq = ( SetSystemInfoParamOEMReq_T*)pReq;
  2960. // SetSystemInfoParamRes_T* pSetSysInfoRes = ( SetSystemInfoParamRes_T*)pRes;
  2961. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  2962. // SystemInfoConfig_T* pSysInfoCfg;
  2963. // uint8_t *pSetInProgress;
  2964. // unsigned long oem_addr[2]={0}; // use oem_addr[1] as read-only/write-only flag
  2965. // int size,strlen,len;
  2966. // uint8_t OSName[MAX_OS_NAME_LENGTH] = {0};
  2967. // //If the OEM parameter is existing, then skip the length check.
  2968. // if(g_PDKHandle[PDK_SETSYSINFOPARAM] == NULL && (pSetSysInfoReq->ParamSelector < 192 )){
  2969. // if( !( (SET_IN_PROGRESS_PARAM == pSetSysInfoReq->ParamSelector && ( ReqLen == ( sizeof(pSetSysInfoReq->ParamSelector) + sizeof(uint8_t) /* for Data */ ) )) ||
  2970. // ( pSetSysInfoReq->ParamSelector < MAX_PARAM_SELECTOR && ReqLen == ( sizeof(pSetSysInfoReq->ParamSelector) + sizeof(uint8_t) /* for set Selector */ + MAX_BLOCK_SIZE))) )
  2971. // {
  2972. // pSetSysInfoRes->CompletionCode = CC_REQ_INV_LEN;
  2973. // return sizeof(pSetSysInfoRes->CompletionCode);
  2974. // }
  2975. // }
  2976. // pSetInProgress = &BMC_GET_SHARED_MEM(BMCInst)->m_Sys_SetInProgress;
  2977. // pSetSysInfoRes->CompletionCode = CC_NORMAL;
  2978. // /*Get NVRAM System Info Configuration parameters */
  2979. // pSysInfoCfg = &pBMCInfo->SystemInfoConfig;
  2980. // switch (pSetSysInfoReq->ParamSelector)
  2981. // {
  2982. // /*Parameter 0 volatile */
  2983. // case SET_IN_PROGRESS_PARAM:
  2984. // LOCK_BMC_SHARED_MEM(BMCInst);
  2985. // /* If Request for Set In progress */
  2986. // if(( SYS_INFO_SET_IN_PROGRESS == *pSetInProgress ) &&
  2987. // ( SYS_INFO_SET_IN_PROGRESS == pSetSysInfoReq->SysInfo.SetInProgress ))
  2988. // {
  2989. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  2990. // /* Trying to SetinProgress when already in set*/
  2991. // pSetSysInfoRes->CompletionCode = CC_SYS_INFO_SET_IN_PROGRESS ;
  2992. // return sizeof(pSetSysInfoRes->CompletionCode);
  2993. // } else if( SYS_INFO_COMMIT_WRITE == pSetSysInfoReq->SysInfo.SetInProgress )
  2994. // {
  2995. // /* Write SysInfoConfig to NVR */
  2996. // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig,
  2997. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SystemInfoConfig_T),BMCInst);
  2998. // /* Write volatile data to the BMC Shared memory */
  2999. //
  3000. // } else if ( SYS_INFO_SET_COMPLETE == pSetSysInfoReq->SysInfo.SetInProgress )
  3001. // {
  3002. // //PMCONFIG_FILE(BMCInst,PMConfigFile);
  3003. // /* Set it to set Complete */
  3004. // *pSetInProgress = pSetSysInfoReq->SysInfo.SetInProgress;
  3005. // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig,
  3006. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SystemInfoConfig_T),BMCInst);
  3007. // } else if ( SYS_INFO_SET_IN_PROGRESS != pSetSysInfoReq->SysInfo.SetInProgress )
  3008. // {
  3009. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  3010. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3011. // return sizeof(pSetSysInfoRes->CompletionCode);
  3012. // }
  3013. // *pSetInProgress = pSetSysInfoReq->SysInfo.SetInProgress;
  3014. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  3015. // break;
  3016. // case SYS_FW_VERSION_PARAM:
  3017. //
  3018. // if(pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector >= MAX_BLOCK_SIZE)
  3019. // {
  3020. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3021. // return sizeof(pSetSysInfoRes->CompletionCode);
  3022. // }
  3023. // if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector==ZERO_SETSELECTOR)
  3024. // {
  3025. // if(pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]> MAX_FW_VER_LENGTH)
  3026. // {
  3027. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3028. // return sizeof(pSetSysInfoRes->CompletionCode);
  3029. // }
  3030. // if(pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0] > MAX_TYPE_OF_ENCODING)
  3031. // {
  3032. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3033. // return sizeof(pSetSysInfoRes->CompletionCode);
  3034. // }
  3035. // memset(&pSysInfoCfg->SysFWVersion,0,sizeof(pSysInfoCfg->SysFWVersion));
  3036. // pSysInfoCfg->SysFWVersion.TypeOfEncoding=pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0];
  3037. // pSysInfoCfg->SysFWVersion.StringLength=pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1];
  3038. // /*First character should not be a delimiter*/
  3039. // 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)))
  3040. // {
  3041. // *pRes = CC_INV_DATA_FIELD;
  3042. // return sizeof(uint8_t);
  3043. // }
  3044. // strlen = validatestring(&pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0]);
  3045. // if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]) || ((pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]))
  3046. // {
  3047. // *pRes = CC_INV_DATA_FIELD;
  3048. // return sizeof(uint8_t);
  3049. // }
  3050. // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
  3051. // {
  3052. // *pRes = CC_INV_DATA_FIELD;
  3053. // return sizeof(uint8_t);
  3054. // }
  3055. // _fmemcpy(&pSysInfoCfg->SysFWVersion.SysFWVersionName[0],&pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[2], MAX_STRING_LENGTH_COPY);
  3056. // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig.SysFWVersion,
  3057. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysFWVersion_T),BMCInst);
  3058. // }
  3059. // else
  3060. // {
  3061. // _fmemcpy(&pSysInfoCfg->SysFWVersion.SysFWVersionName[(pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector* MAX_BLOCK_SIZE) - 2],
  3062. // &pSetSysInfoReq->SysInfo.SysVerInfo.SysFWVersion[0],MAX_BLOCK_SIZE);
  3063. // len = ((pSetSysInfoReq->SysInfo.SysVerInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
  3064. // strlen = validatestring(&pSysInfoCfg->SysFWVersion.SysFWVersionName[0],len,pSysInfoCfg->SysFWVersion.TypeOfEncoding);
  3065. // if(strlen == -1 || (strlen > pSysInfoCfg->SysFWVersion.StringLength))
  3066. // {
  3067. // *pRes = CC_INV_DATA_FIELD;
  3068. // return sizeof(uint8_t);
  3069. // }
  3070. // /*Check the String length*/
  3071. // if(((len < pSysInfoCfg->SysFWVersion.StringLength) && (len != strlen)) || ((len > pSysInfoCfg->SysFWVersion.StringLength) && (pSysInfoCfg->SysFWVersion.StringLength != strlen)))
  3072. // {
  3073. // *pRes = CC_INV_DATA_FIELD;
  3074. // return sizeof(uint8_t);
  3075. // }
  3076. // if((len == pSysInfoCfg->SysFWVersion.StringLength) && (pSysInfoCfg->SysFWVersion.StringLength != strlen))
  3077. // {
  3078. // *pRes = CC_INV_DATA_FIELD;
  3079. // return sizeof(uint8_t);
  3080. // }
  3081. // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,
  3082. // (uint8_t*)&pBMCInfo->SystemInfoConfig.SysFWVersion,pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysFWVersion_T),BMCInst);
  3083. // }
  3084. // break;
  3085. // case SYS_NAME_PARAM:
  3086. // if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector >= MAX_BLOCK_SIZE )
  3087. // {
  3088. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3089. // return sizeof(pSetSysInfoRes->CompletionCode);
  3090. // }
  3091. // if(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector==ZERO_SETSELECTOR)
  3092. // {
  3093. // if((pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1] > MAX_SYS_NAME_LENGTH))
  3094. // {
  3095. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3096. // return sizeof(pSetSysInfoRes->CompletionCode);
  3097. // }
  3098. // if(pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0]>MAX_TYPE_OF_ENCODING)
  3099. // {
  3100. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3101. // return sizeof(pSetSysInfoRes->CompletionCode);
  3102. // }
  3103. // memset(&pSysInfoCfg->SysName,0,sizeof(pSysInfoCfg->SysName));
  3104. // pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name=pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0];
  3105. // pSysInfoCfg->SysName.StringLength_Sys_Name=pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1];
  3106. // /*First character should not be a delimiter*/
  3107. // 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)))
  3108. // {
  3109. // *pRes = CC_INV_DATA_FIELD;
  3110. // return sizeof(uint8_t);
  3111. // }
  3112. // strlen = validatestring(&pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.SysNameInfo.SysName[0]);
  3113. // if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]) || ((pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]))
  3114. // {
  3115. // *pRes = CC_INV_DATA_FIELD;
  3116. // return sizeof(uint8_t);
  3117. // }
  3118. // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.SysNameInfo.SysName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
  3119. // {
  3120. // *pRes = CC_INV_DATA_FIELD;
  3121. // return sizeof(uint8_t);
  3122. // }
  3123. // _fmemcpy(&pSysInfoCfg->SysName.SystemName[0], &pSetSysInfoReq->SysInfo.SysNameInfo.SysName[2],MAX_STRING_LENGTH_COPY);
  3124. // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig.SysName,
  3125. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysName_T),BMCInst);
  3126. // }
  3127. // else
  3128. // {
  3129. // _fmemcpy(&pSysInfoCfg->SysName.SystemName[(pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector* MAX_BLOCK_SIZE) - 2],
  3130. // &pSetSysInfoReq->SysInfo.SysNameInfo.SysName,MAX_BLOCK_SIZE);
  3131. // len = ((pSetSysInfoReq->SysInfo.SysNameInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
  3132. // strlen = validatestring(&pSysInfoCfg->SysName.SystemName[0],len,pSysInfoCfg->SysName.TypeOfEncoding_Sys_Name);
  3133. // if(strlen == -1 || (strlen > pSysInfoCfg->SysName.StringLength_Sys_Name))
  3134. // {
  3135. // *pRes = CC_INV_DATA_FIELD;
  3136. // return sizeof(uint8_t);
  3137. // }
  3138. // /*Check the String length*/
  3139. // if(((len < pSysInfoCfg->SysName.StringLength_Sys_Name) && (len != strlen)) || ((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. // if((len == pSysInfoCfg->SysName.StringLength_Sys_Name) && (pSysInfoCfg->SysName.StringLength_Sys_Name != strlen))
  3145. // {
  3146. // *pRes = CC_INV_DATA_FIELD;
  3147. // return sizeof(uint8_t);
  3148. // }
  3149. // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig.SysName,
  3150. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(SysName_T),BMCInst);
  3151. // }
  3152. // break;
  3153. // case PRIM_OS_NAME_PARAM:
  3154. // if(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector >= MAX_BLOCK_SIZE )
  3155. // {
  3156. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3157. // return sizeof(pSetSysInfoRes->CompletionCode);
  3158. // }
  3159. // if(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector==ZERO_SETSELECTOR)
  3160. // {
  3161. // if((pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1] > MAX_PRIM_OS_NAME_LENGTH))
  3162. // {
  3163. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3164. // return sizeof(pSetSysInfoRes->CompletionCode);
  3165. //
  3166. // }
  3167. // if(pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0]>MAX_TYPE_OF_ENCODING)
  3168. // {
  3169. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3170. // return sizeof(pSetSysInfoRes->CompletionCode);
  3171. // }
  3172. // memset(&pSysInfoCfg->PrimaryOSName,0,sizeof(pSysInfoCfg->PrimaryOSName));
  3173. // pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName=pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0];
  3174. // pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName=pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1];
  3175. // /*First character should not be a delimiter*/
  3176. // 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)))
  3177. // {
  3178. // *pRes = CC_INV_DATA_FIELD;
  3179. // return sizeof(uint8_t);
  3180. // }
  3181. // strlen = validatestring(&pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[0]);
  3182. // if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]) || ((pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]))
  3183. // {
  3184. // *pRes = CC_INV_DATA_FIELD;
  3185. // return sizeof(uint8_t);
  3186. // }
  3187. // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
  3188. // {
  3189. // *pRes = CC_INV_DATA_FIELD;
  3190. // return sizeof(uint8_t);
  3191. // }
  3192. // _fmemcpy(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[0], &pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName[2], MAX_STRING_LENGTH_COPY);
  3193. // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,(uint8_t*)&pBMCInfo->SystemInfoConfig.PrimaryOSName,
  3194. // pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(PrimaryOSName_T),BMCInst);
  3195. // }
  3196. // else
  3197. // {
  3198. // _fmemcpy(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[(pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector * MAX_BLOCK_SIZE) - 2],
  3199. // &pSetSysInfoReq->SysInfo.PrimOSInfo.PrimaryOSName, MAX_BLOCK_SIZE);
  3200. // len = ((pSetSysInfoReq->SysInfo.PrimOSInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
  3201. // strlen = validatestring(&pSysInfoCfg->PrimaryOSName.PrimaryOperatingSystemName[0],len,pSysInfoCfg->PrimaryOSName.TypeOfEncoding_PrimaryOSName);
  3202. // if(strlen == -1 || (strlen > pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName))
  3203. // {
  3204. // *pRes = CC_INV_DATA_FIELD;
  3205. // return sizeof(uint8_t);
  3206. // }
  3207. // /*Check the String length*/
  3208. // if(((len < pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (len != strlen)) || ((len > pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName != strlen)))
  3209. // {
  3210. // *pRes = CC_INV_DATA_FIELD;
  3211. // return sizeof(uint8_t);
  3212. // }
  3213. // if((len == pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName) && (pSysInfoCfg->PrimaryOSName.StringLength_PrimaryOSName != strlen))
  3214. // {
  3215. // *pRes = CC_INV_DATA_FIELD;
  3216. // return sizeof(uint8_t);
  3217. // }
  3218. // FlushIPMI((uint8_t*)&pBMCInfo->SystemInfoConfig,
  3219. // (uint8_t*)&pBMCInfo->SystemInfoConfig.PrimaryOSName,pBMCInfo->IPMIConfLoc.SystemInfoConfigAddr,sizeof(PrimaryOSName_T),BMCInst);
  3220. // }
  3221. // break;
  3222. // case OS_NAME_PARAM:
  3223. // /*Parameter 4 volatile*/
  3224. // if(pSetSysInfoReq->SysInfo.OSInfo.SetSelector >= MAX_BLOCK_SIZE )
  3225. // {
  3226. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3227. // return sizeof(pSetSysInfoRes->CompletionCode);
  3228. // }
  3229. // if(pSetSysInfoReq->SysInfo.OSInfo.SetSelector==ZERO_SETSELECTOR)
  3230. // {
  3231. // if(pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1] > MAX_OS_NAME_LENGTH)
  3232. // {
  3233. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3234. // return sizeof(pSetSysInfoRes->CompletionCode);
  3235. // }
  3236. // if(pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0] > MAX_TYPE_OF_ENCODING)
  3237. // {
  3238. // pSetSysInfoRes->CompletionCode = CC_INV_DATA_FIELD;
  3239. // return sizeof(pSetSysInfoRes->CompletionCode);
  3240. // }
  3241. // /*First character should not be a delimiter*/
  3242. // 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)))
  3243. // {
  3244. // *pRes = CC_INV_DATA_FIELD;
  3245. // return sizeof(uint8_t);
  3246. // }
  3247. // strlen = validatestring(&pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2],MAX_BLOCK_SIZE-2,pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0]);
  3248. // if(strlen == -1 || (strlen > pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]) || ((pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1] <= (MAX_BLOCK_SIZE - 2)) && strlen != pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]))
  3249. // {
  3250. // *pRes = CC_INV_DATA_FIELD;
  3251. // return sizeof(uint8_t);
  3252. // }
  3253. // if(((MAX_BLOCK_SIZE -2) < pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1]) && (strlen != (MAX_BLOCK_SIZE - 2)))
  3254. // {
  3255. // *pRes = CC_INV_DATA_FIELD;
  3256. // return sizeof(uint8_t);
  3257. // }
  3258. // memset(&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName,0,sizeof(OSName_T));
  3259. // LOCK_BMC_SHARED_MEM(BMCInst);
  3260. // BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName=pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[0];
  3261. // BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName=pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[1];
  3262. // _fmemcpy(&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName, &pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName[2],
  3263. // MAX_STRING_LENGTH_COPY);
  3264. // UNLOCK_BMC_SHARED_MEM (BMCInst);
  3265. // }
  3266. // else
  3267. // {
  3268. // LOCK_BMC_SHARED_MEM(BMCInst);
  3269. // _fmemcpy(&OSName[0],&BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[0],MAX_OS_NAME_LENGTH);
  3270. // _fmemcpy(&OSName[(pSetSysInfoReq->SysInfo.OSInfo.SetSelector * MAX_BLOCK_SIZE) - 2],&pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName,MAX_BLOCK_SIZE);
  3271. // len = ((pSetSysInfoReq->SysInfo.OSInfo.SetSelector* MAX_BLOCK_SIZE) + MAX_BLOCK_SIZE) - 2;
  3272. // strlen = validatestring(&OSName[0],len,BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.TypeOfEncoding_OSName);
  3273. // if(strlen == -1 || (strlen > BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName))
  3274. // {
  3275. // *pRes = CC_INV_DATA_FIELD;
  3276. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  3277. // return sizeof(uint8_t);
  3278. // }
  3279. // /*Check the String length*/
  3280. // 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)))
  3281. // {
  3282. // *pRes = CC_INV_DATA_FIELD;
  3283. // return sizeof(uint8_t);
  3284. // }
  3285. // if((len == BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName) && (BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.StringLength_OSName != strlen))
  3286. // {
  3287. // *pRes = CC_INV_DATA_FIELD;
  3288. // return sizeof(uint8_t);
  3289. // }
  3290. // _fmemcpy(&(BMC_GET_SHARED_MEM(BMCInst)->OperatingSystemName.OSName[(pSetSysInfoReq->SysInfo.OSInfo.SetSelector * MAX_BLOCK_SIZE) - 2]),
  3291. // &pSetSysInfoReq->SysInfo.OSInfo.OperatingSystemName,MAX_BLOCK_SIZE);
  3292. // UNLOCK_BMC_SHARED_MEM (BMCInst);
  3293. // }
  3294. // break;
  3295. // default:
  3296. // if(g_PDKHandle[PDK_SETSYSINFOPARAM] != NULL &&
  3297. // (pSetSysInfoReq->ParamSelector >= 192 && pSetSysInfoReq->ParamSelector <= 255))
  3298. // {
  3299. // oem_addr[0] = (unsigned long)((char*)pSetSysInfoOEMReq + sizeof(SetSystemInfoParamOEMReq_T));
  3300. // size = ((int(*)(uint8_t, unsigned long*,int))(g_PDKHandle[PDK_SETSYSINFOPARAM]))(pSetSysInfoReq->ParamSelector, oem_addr ,BMCInst);
  3301. // if(size <= 0)
  3302. // {
  3303. // switch (oem_addr[1]) {
  3304. // case CC_SYS_INFO_READ_ONLY_PARAM:
  3305. // pSetSysInfoRes->CompletionCode = CC_SYS_INFO_READ_ONLY_PARAM;
  3306. // break;
  3307. // default:
  3308. // pSetSysInfoRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
  3309. // }
  3310. // }
  3311. // else
  3312. // {
  3313. // pSetSysInfoRes->CompletionCode = CC_SYS_INFO_PARAM_NOT_SUPPORTED;
  3314. // return sizeof(pSetSysInfoRes->CompletionCode);
  3315. // }
  3316. // }
  3317. // }
  3318. // return sizeof(pSetSysInfoRes->CompletionCode);
  3319. //}
  3320. #endif /* APP_DEVICE */