LANConfig.c 99 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. //#include <linux/if.h>
  4. #include <linux/ip.h>
  5. //#include <dlfcn.h>
  6. #include <sys/prctl.h>
  7. //#include "nwcfg.h"
  8. #include "Util.h"
  9. #include "main.h"
  10. #include "Api.h"
  11. #include "Util.h"
  12. #include "com_IPMI_LANConfig.h"
  13. #include "com_IPMI_DeviceConfig.h"
  14. #include <string.h>
  15. /* Reserved bit macro definitions */
  16. #define RESERVED_BITS_SUSPENDBMCARPS 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  17. #define RESERVED_BITS_GETIPUDPRMCPSTATS_CH 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  18. #define RESERVED_BITS_GETIPUDPRMCPSTATS_CLRSTATE 0xFE //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1)
  19. /*** Local definitions ***/
  20. #define CHANNEL_ID_MASK 0x0f
  21. #define SET_IN_PROGRESS_MASK 0x03
  22. #define PARAMETER_REVISION_MASK 0x0f
  23. #define DEST_ADDR_DATA2_ADDR_FORMAT_MASK 0xf0
  24. #define PARAMETER_REVISION_FORMAT 0x11
  25. #define GET_PARAMETER_REVISION_MASK 0x80
  26. #define LAN_CALLBACK_AUTH_SUPPORT 0x17 /* MD2 & MD5 supported */
  27. #define LAN_USER_AUTH_SUPPORT 0x17 /* MD2 & MD5 supported */
  28. #define LAN_OPERATOR_AUTH_SUPPORT 0x17 /* MD2 & MD5 supported */
  29. #define LAN_ADMIN_AUTH_SUPPORT 0x17 /* MD2 & MD5 supported */
  30. #define BRD_CAST_BIT_MASK 0xFF
  31. #define LOOP_BACK_BIT_MASK 0x7F
  32. #define SUBNET_MASK_BIT_CHECK 0x80
  33. #define LAN_CONFIGURATION_SET_IN_PROGRESS 0x01
  34. #define LAN_CONFIGURATION_SET_COMPLETE 0x00
  35. #define GRATIUTOUS_ENABLE_MASK 1
  36. #define ENABLE_ARP_RESPONSES 2
  37. #define SUSPEND_ARP_RSVD_BIT_MASK 0xFC
  38. #define ENABLE_ARPS 0x03
  39. #define SUSPEND_GRAT_ARP 0x01
  40. #define SUSPEND_ARP 0x02
  41. #define ARP_IGNORE_ON 8
  42. #define ARP_IGNORE_OFF 0
  43. /* Reserved Bits */
  44. #define RESERVED_VALUE_70 0x70
  45. #define RESERVED_VALUE_F0 0xF0
  46. // /**
  47. // *@fn NwInterfacePresenceCheck
  48. // *@brief This function is invoked to check network interface presence
  49. // *@param Interface - Char Pointer to buffer for which interface to check
  50. // */
  51. // static int NwInterfacePresenceCheck (char * Interface);
  52. // /*** Module Variables ***/
  53. // // uint8_t m_ArpSuspendReq;
  54. // char **explode(char separator, char *string);
  55. // int IPAddrCheck(uint8_t *Addr,int params);
  56. // extern int GetLanAMIParamValue (uint8_t* ParamSelect, uint8_t* ImpType);
  57. // extern IfcName_T Ifcnametable[MAX_LAN_CHANNELS];
  58. #define MAX_LAN_PARAMS_DATA 20
  59. typedef struct
  60. {
  61. uint8_t Params;
  62. uint8_t ReservedBits [MAX_LAN_PARAMS_DATA];
  63. uint8_t DataLen;
  64. } LANCfgRsvdBits_T;
  65. static LANCfgRsvdBits_T m_RsvdBitsCheck [] = {
  66. /* Param Reserved Bits Data Size */
  67. { 0, { 0xFC }, 0x1 }, /* Set In progress */
  68. { 1, { 0xC8 }, 0x1 }, /* Authenication type */
  69. { 2, { 0xC8,0xC8,0xC8,0xC8,0xC8 }, 0x5}, /* Authenication Support Enable */
  70. { 4, { 0xF0 }, 0x1 }, /* l */
  71. { 7, { 0x0,0x1F,0x01 }, 0x3 }, /* l */
  72. { 0xA, { 0xFC }, 0x1 }, /* l */
  73. { 0x11, { 0xF0 }, 0x1 }, /* l */
  74. { 0x12, { 0xF0,0x78,0x0,0xF8 }, 0x4 },
  75. { 0x13, { 0xF0,0x0F, 0xFE }, 0x3 },
  76. { 0x14, { 0x0,0x70}, 0x2 },
  77. { 0x15, { 0xF8 }, 0x1 },
  78. { 0x16, { 0xE0 }, 0x1 },
  79. { 0x17, { 0xFF }, 0x1 },
  80. { 0x18, { 0xFF }, 0x1 },
  81. { 0x19, { 0xF0,0x0F }, 0x2 },
  82. { 0x1A, { 0xFE }, 0x1 }
  83. };
  84. typedef struct
  85. {
  86. uint8_t OEMParam;
  87. uint8_t Length;
  88. }OEMParameterLength_T;
  89. static OEMParameterLength_T m_OEMParamLen [] = {
  90. // {LAN_PARAMS_AMI_OEM_IPV6_ENABLE, 1 },
  91. // {LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE, 1 },
  92. // {LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR, 17 },
  93. // {LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH, 2},
  94. // {LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP, 16}
  95. };
  96. /**
  97. * @brief LAN configuration request parameter lengths
  98. **/
  99. static const uint8_t LanconfigParameterLength [] = {
  100. 1, /* Set in progress */
  101. 1, /* Authentication type support */
  102. 5, /* Authentication type enables */
  103. 4, /* IP address */
  104. 1, /* IP address source */
  105. 6, /* MAC address */
  106. 4, /* Subnet mask */
  107. 3, /* IPv4 header parameters */
  108. 2, /* Primary RMCP port number */
  109. 2, /* Secondary RMCP port number */
  110. 1, /* BMC generated ARP control */
  111. 1, /* Gratuitous ARP */
  112. 4, /* Default Gateway address */
  113. 6, /* Default Gateway MAC address */
  114. 4, /* Backup Gateway address */
  115. 6, /* Backup Gateway MAC address */
  116. 18, /* Community string */
  117. 1, /* Number of destinations */
  118. 4, /* Destination type */
  119. 13, /* Destination address */
  120. 2, /* VLAN ID */
  121. 1, /* VLAN Priority */
  122. 1, /* Cipher suite entry support */
  123. 17, /* Cipher suite entries */
  124. 9, /* Cipher suite Privilege levels */
  125. 4, /* VLAN tags destination address */
  126. 6, /* Bad Password Threshold */
  127. (9+16) /* IPv6 Destination address */
  128. };
  129. /* A copy of ip_tos2prio with numeric format in "linux/net/ipv4/route.c" */
  130. static const uint8_t IP_TOS2PRIO[16] = {
  131. 0, /* TC_PRIO_BESTEFFORT, */
  132. 1, /* ECN_OR_COST(FILLER), */
  133. 0, /* TC_PRIO_BESTEFFORT, */
  134. 0, /* ECN_OR_COST(BESTEFFORT), */
  135. 2, /* TC_PRIO_BULK, */
  136. 2, /* ECN_OR_COST(BULK), */
  137. 2, /* TC_PRIO_BULK, */
  138. 2, /* ECN_OR_COST(BULK), */
  139. 6, /* TC_PRIO_INTERACTIVE, */
  140. 6, /* ECN_OR_COST(INTERACTIVE), */
  141. 6, /* TC_PRIO_INTERACTIVE, */
  142. 6, /* ECN_OR_COST(INTERACTIVE), */
  143. 4, /* TC_PRIO_INTERACTIVE_BULK, */
  144. 4, /* ECN_OR_COST(INTERACTIVE_BULK),*/
  145. 4, /* TC_PRIO_INTERACTIVE_BULK, */
  146. 4 /* ECN_OR_COST(INTERACTIVE_BULK) */
  147. };
  148. static uint8_t enableSetMACAddr = TRUE; //jimbo notice
  149. /*-------------------------------------------------------
  150. * SetLanConfigParam
  151. *-------------------------------------------------------*/
  152. int
  153. SetLanConfigParam ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
  154. {
  155. SetLanConfigReq_T* pSetLanReq = ( SetLanConfigReq_T*) pReq;
  156. SetLanConfigRes_T* pSetLanRes = ( SetLanConfigRes_T*) pRes;
  157. MsgPkt_T m_MsgPkt;
  158. int i,j=0;
  159. uint8_t index;
  160. int retValue=0,NIC_Count = 0;
  161. // uint16_t PriorityLevel[MAX_LAN_CHANNELS]= {0};
  162. uint8_t m_Lan_SetInProgress; /**< Contains setting LAN configuration status */
  163. uint8_t InvalidMac[MAC_ADDR_LEN] = {0,0,0,0,0,0};
  164. char old_mac[18];
  165. char macStr[18] = {0};
  166. char old_ip[16];
  167. char ipStr[16] = {0};
  168. char old_netmask[18];
  169. char netmaskStr[18] = {0};
  170. if ( ReqLen >= 2 )
  171. {
  172. ReqLen -= 2;
  173. }
  174. else
  175. {
  176. *pRes = CC_REQ_INV_LEN;
  177. return 1;
  178. }
  179. //自定义
  180. // if((pSetLanReq->ParameterSelect >= MIN_LAN_OEM_CONF_PARAM) &&
  181. // (pSetLanReq->ParameterSelect <= MAX_LAN_OEM_CONF_PARAM) )
  182. // {
  183. // /* Converts OEM parameter value to equivalent AMI parameter value */
  184. // if (0 != GetLanAMIParamValue (&pSetLanReq->ParameterSelect, &IsOemDefined) )
  185. // {
  186. // pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
  187. // return sizeof(uint8_t);
  188. // }
  189. // /* Hook for OEM to handle this parameter */
  190. // if ( (IsOemDefined) && (g_PDKHandle[PDK_SETLANOEMPARAM] != NULL) )
  191. // {
  192. // return ((int(*)(uint8_t *, uint8_t, uint8_t *,int))(g_PDKHandle[PDK_SETLANOEMPARAM]))(pReq, ReqLen, pRes, BMCInst);
  193. // }
  194. // }
  195. if(0x1b >pSetLanReq->ParameterSelect ) //Max known Lan paramter
  196. {
  197. if (ReqLen != LanconfigParameterLength [pSetLanReq->ParameterSelect ])
  198. {
  199. *pRes = CC_REQ_INV_LEN;
  200. return sizeof (uint8_t);
  201. }
  202. }
  203. // /*Check the Request length for OEM parameter*/
  204. // for(i=0;i<sizeof(m_OEMParamLen)/sizeof(OEMParameterLength_T);i++)
  205. // {
  206. // if(m_OEMParamLen[i].OEMParam == pSetLanReq->ParameterSelect)
  207. // {
  208. // if(ReqLen != m_OEMParamLen[i].Length)
  209. // {
  210. // *pRes = CC_REQ_INV_LEN;
  211. // return sizeof(uint8_t);
  212. // }
  213. // }
  214. // }
  215. if(pSetLanReq->ChannelNum & RESERVED_VALUE_F0)
  216. {
  217. /* Alarm !!! Somebody is trying to set Reseved Bits */
  218. *pRes = CC_INV_DATA_FIELD;
  219. return sizeof (*pRes);
  220. }
  221. if(pSetLanReq->ChannelNum == LAN_RMCP_CHANNEL)
  222. index = 0;
  223. else
  224. {
  225. *pRes = CC_INV_DATA_FIELD;
  226. return sizeof (*pRes);
  227. }
  228. /* Check for Reserved Bits */
  229. for (i = 0; i < sizeof (m_RsvdBitsCheck)/ sizeof (m_RsvdBitsCheck[0]); i++)
  230. {
  231. /* Check if this Parameter Selector needs Reserved bit checking !! */
  232. if (m_RsvdBitsCheck[i].Params == pSetLanReq->ParameterSelect)
  233. {
  234. //IPMI_DBG_PRINT_2 ("Param - %x, DataLen - %x\n", pSetLanReq->ParameterSelect, m_RsvdBitsCheck[i].DataLen);
  235. for (j = 0; j < m_RsvdBitsCheck[i].DataLen; j++)
  236. {
  237. // IPMI_DBG_PRINT_2 ("Cmp %x, %x\n", pReq[2+j], m_RsvdBitsCheck[i].ReservedBits[j]);
  238. if ( 0 != (pReq[2+j] & m_RsvdBitsCheck[i].ReservedBits[j]))
  239. {
  240. /* Alarm !!! Somebody is trying to set Reseved Bits */
  241. *pRes = CC_INV_DATA_FIELD;
  242. return sizeof (*pRes);
  243. }
  244. }
  245. }
  246. }
  247. // ptrChannelInfo = getChannelInfo (pSetLanReq->ChannelNum & 0x0F, BMCInst);
  248. // if(NULL == ptrChannelInfo)
  249. // {
  250. // *pRes = CC_INV_DATA_FIELD;
  251. // return sizeof(*pRes);
  252. // }
  253. printf ("Parameter = %X\n", pSetLanReq->ParameterSelect);
  254. switch (pSetLanReq->ParameterSelect)
  255. {
  256. case LAN_PARAM_SET_IN_PROGRESS:
  257. m_Lan_SetInProgress = g_BMCInfo.m_Lan_SetInProgress;
  258. /* Commit Write is optional and supported
  259. * only if rollback is supported */
  260. if ( (GetBits(pSetLanReq->ConfigData.SetInProgress, SET_IN_PROGRESS_MASK) !=
  261. LAN_CONFIGURATION_SET_COMPLETE) &&
  262. (GetBits(pSetLanReq->ConfigData.SetInProgress, SET_IN_PROGRESS_MASK) !=
  263. LAN_CONFIGURATION_SET_IN_PROGRESS) )
  264. {
  265. pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
  266. return sizeof(*pSetLanRes);
  267. }
  268. else if ((GetBits(m_Lan_SetInProgress, SET_IN_PROGRESS_MASK) ==
  269. LAN_CONFIGURATION_SET_IN_PROGRESS) &&
  270. (GetBits(pSetLanReq->ConfigData.SetInProgress, SET_IN_PROGRESS_MASK) ==
  271. LAN_CONFIGURATION_SET_IN_PROGRESS))
  272. {
  273. pSetLanRes->CompletionCode = CC_SET_IN_PROGRESS;
  274. return sizeof(*pSetLanRes);
  275. }
  276. g_BMCInfo.m_Lan_SetInProgress = pSetLanReq->ConfigData.SetInProgress;
  277. break;
  278. case LAN_PARAM_AUTH_TYPE_SUPPORT:
  279. pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  280. return sizeof(*pRes);
  281. case LAN_PARAM_AUTH_TYPE_ENABLES:
  282. printf("---> Not implement!\n");
  283. // for(i=0;i<5;i++)
  284. // {
  285. // /* Check for Unsupported AuthType */
  286. // if (pBMCInfo->LANCfs[EthIndex].AuthTypeSupport != (pBMCInfo->LANCfs[EthIndex].AuthTypeSupport |pReq[2+i]))
  287. // {
  288. // IPMI_DBG_PRINT_2("\n Alarm !!! Somebody is trying to Unsupported Bit :%d \t%d\n",pReq[2+i],i);
  289. // *pRes = CC_INV_DATA_FIELD;
  290. // return sizeof (*pRes);
  291. // }
  292. // }
  293. // LOCK_BMC_SHARED_MEM(BMCInst);
  294. // _fmemcpy (&pBMCInfo->LANCfs[EthIndex].AuthTypeEnables,
  295. // &(pSetLanReq->ConfigData.AuthTypeEnables), sizeof(AuthTypeEnables_T));
  296. // _fmemcpy (ptrChannelInfo->AuthType,
  297. // &(pSetLanReq->ConfigData.AuthTypeEnables), sizeof(AuthTypeEnables_T));
  298. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  299. break;
  300. case LAN_PARAM_IP_ADDRESS: //post cmd to chassisTimerTask
  301. if(IPAddrCheck(pSetLanReq->ConfigData.IPAddr,LAN_PARAM_IP_ADDRESS))
  302. {
  303. *pRes = CC_INV_DATA_FIELD;
  304. return sizeof (uint8_t);
  305. }
  306. getip(old_ip);
  307. sprintf(ipStr, "%d.%d.%d.%d", pSetLanReq->ConfigData.IPAddr[0],
  308. pSetLanReq->ConfigData.IPAddr[1], pSetLanReq->ConfigData.IPAddr[2],
  309. pSetLanReq->ConfigData.IPAddr[3]);
  310. if(strcmp(ipStr, old_ip) == 0)
  311. {
  312. printf("The same ip %s, do nothing\n", ipStr );
  313. *pRes = CC_NORMAL;
  314. return 1;
  315. }
  316. m_MsgPkt.Param = PARAM_LAN;
  317. m_MsgPkt.NetFnLUN = NETFNLUN_IPMI_TRANSPORT;
  318. m_MsgPkt.Cmd = CMD_SET_LAN_CONFIGURATION_PARAMETERS;
  319. m_MsgPkt.Size = sizeof(SetLanConfigReq_T);
  320. memcpy(m_MsgPkt.Data, pSetLanReq, sizeof(SetLanConfigReq_T));
  321. PostMsg(gPendActionIfc, &m_MsgPkt);
  322. //Update
  323. memcpy(g_BMCInfo.LanInfo[index].IPAddr, pSetLanReq->ConfigData.IPAddr, 4);
  324. FlushIpmiConfig();
  325. printf("---> old_ip: %s, new_ip: %s\n", old_ip, ipStr);
  326. printf("---> send data: %#x %#x %#x %#x %#x\n", m_MsgPkt.Data[0], m_MsgPkt.Data[1]
  327. , m_MsgPkt.Data[2], m_MsgPkt.Data[3], m_MsgPkt.Data[4]);
  328. break;
  329. case LAN_PARAM_IP_ADDRESS_SOURCE:
  330. printf("---> Not implement!\n");
  331. //Update
  332. g_BMCInfo.LanInfo[index].IPAddrSrc = pSetLanReq->ConfigData.IPAddrSrc ;
  333. FlushIpmiConfig();
  334. // if ((pSetLanReq->ConfigData.IPAddrSrc > BMC_OTHER_SOURCE)
  335. // ||(pSetLanReq->ConfigData.IPAddrSrc == UNSPECIFIED_IP_SOURCE))
  336. // {
  337. // *pRes = CC_INV_DATA_FIELD;
  338. // return sizeof (uint8_t);
  339. // }
  340. // if ( g_BMCInfo.IpmiConfig.IPAddrSrc == pSetLanReq->ConfigData.IPAddrSrc )
  341. // {
  342. // printf("LAN or VLAN if current SRC is DHCP/Static and incoming SRC is DHCP/Static, do nothing\n");
  343. // break;
  344. // }
  345. // if(!((pSetLanReq->ConfigData.IPAddrSrc == STATIC_IP_SOURCE ) || (pSetLanReq->ConfigData.IPAddrSrc == DHCP_IP_SOURCE )))
  346. // g_BMCInfo.IpmiConfig.IPAddrSrc = pSetLanReq->ConfigData.IPAddrSrc ;
  347. // if ( (pSetLanReq->ConfigData.IPAddrSrc == STATIC_IP_SOURCE ) || (pSetLanReq->ConfigData.IPAddrSrc == DHCP_IP_SOURCE ) )
  348. // {
  349. // pendStatus = GetPendStatus(PEND_OP_SET_SOURCE);
  350. // if(pendStatus == PEND_STATUS_PENDING)
  351. // {
  352. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  353. // return sizeof (uint8_t);
  354. // }
  355. // pBMCInfo->LANCfs[EthIndex].IPAddrSrc = pSetLanReq->ConfigData.IPAddrSrc ;
  356. // NWConfig.CfgMethod = pSetLanReq->ConfigData.IPAddrSrc;
  357. // SetPendStatus(PEND_OP_SET_SOURCE,PEND_STATUS_PENDING);
  358. // PostPendTask(PEND_OP_SET_SOURCE,(uint8_t*) &NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  359. // }
  360. // else if(pSetLanReq->ConfigData.IPAddrSrc == BIOS_IP_SOURCE)
  361. // {
  362. // /*Perform OEM action*/
  363. // if(g_PDKHandle[PDK_BIOSIPSOURCE] != NULL)
  364. // {
  365. // retValue = ((int(*)(uint8_t))g_PDKHandle[PDK_BIOSIPSOURCE]) (pSetLanReq->ChannelNum & CHANNEL_ID_MASK);
  366. // if(retValue == 1)
  367. // {
  368. // *pRes = CC_INV_DATA_FIELD;
  369. // return sizeof (*pRes);
  370. // }
  371. // }
  372. // else
  373. // {
  374. // pendStatus = GetPendStatus(PEND_OP_SET_SOURCE);
  375. // if(pendStatus == PEND_STATUS_PENDING)
  376. // {
  377. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  378. // return sizeof (uint8_t);
  379. // }
  380. // NWConfig.CfgMethod = STATIC_IP_SOURCE;
  381. // SetPendStatus(PEND_OP_SET_SOURCE,PEND_STATUS_PENDING);
  382. // PostPendTask(PEND_OP_SET_SOURCE, (uint8_t*) &NWConfig,sizeof(NWConfig), (pSetLanReq->ChannelNum & CHANNEL_ID_MASK), BMCInst );
  383. // }
  384. // }
  385. // else if(pSetLanReq->ConfigData.IPAddrSrc == BMC_OTHER_SOURCE)
  386. // {
  387. // /*Perform OEM action*/
  388. // if(g_PDKHandle[PDK_BMCOTHERSOURCEIP] != NULL)
  389. // {
  390. // retValue = ((int(*)(uint8_t))g_PDKHandle[PDK_BMCOTHERSOURCEIP]) (pSetLanReq->ChannelNum & CHANNEL_ID_MASK);
  391. // if(retValue == 1)
  392. // {
  393. // *pRes = CC_INV_DATA_FIELD;
  394. // return sizeof (*pRes);
  395. // }
  396. // }
  397. // else
  398. // {
  399. // *pRes = CC_INV_DATA_FIELD;
  400. // return sizeof (*pRes);
  401. // }
  402. // }
  403. break;
  404. case LAN_PARAM_MAC_ADDRESS:
  405. /* According to IPMI 2.0 Specification Revision 3, the MAC address can be read only parameter*/
  406. //*pRes = CC_ATTEMPT_TO_SET_RO_PARAM;
  407. //return sizeof (*pRes);
  408. if((pSetLanReq->ConfigData.MACAddr[0]& BIT0)|| (memcmp(&InvalidMac,&pSetLanReq->ConfigData.MACAddr,MAC_ADDR_LEN) == 0))
  409. {
  410. pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
  411. return 1;
  412. }
  413. getmac(old_mac);
  414. sprintf(macStr, "%02x:%02x:%02x:%02x:%02x:%02x", pSetLanReq->ConfigData.MACAddr[0],
  415. pSetLanReq->ConfigData.MACAddr[1], pSetLanReq->ConfigData.MACAddr[2],
  416. pSetLanReq->ConfigData.MACAddr[3], pSetLanReq->ConfigData.MACAddr[4],
  417. pSetLanReq->ConfigData.MACAddr[5]);
  418. if(strcmp(macStr, old_mac) == 0)
  419. {
  420. printf("The same mac %s, do nothing\n", macStr );
  421. *pRes = CC_NORMAL;
  422. return 1;
  423. }
  424. if (!enableSetMACAddr)
  425. pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  426. else
  427. {
  428. m_MsgPkt.Param = PARAM_LAN;
  429. m_MsgPkt.NetFnLUN = NETFNLUN_IPMI_TRANSPORT;
  430. m_MsgPkt.Cmd = CMD_SET_LAN_CONFIGURATION_PARAMETERS;
  431. m_MsgPkt.Size = sizeof(SetLanConfigReq_T);
  432. memcpy(m_MsgPkt.Data, pSetLanReq, sizeof(SetLanConfigReq_T));
  433. PostMsg(gPendActionIfc, &m_MsgPkt);
  434. //Update
  435. memcpy(g_BMCInfo.LanInfo[index].MACAddr, pSetLanReq->ConfigData.MACAddr, 6);
  436. FlushIpmiConfig();
  437. printf("---> old_mac: %s, new_mac: %s\n", old_mac, macStr);
  438. pSetLanRes->CompletionCode = CC_NORMAL;
  439. }
  440. break;
  441. case LAN_PARAM_SUBNET_MASK:
  442. /*Returning valid completion code in case of attempt to set netmask in DHCP mode */
  443. if(g_BMCInfo.LanInfo[index].IPAddrSrc == DHCP_IP_SOURCE)
  444. {
  445. *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  446. return sizeof (uint8_t);
  447. }
  448. getnetmask(old_netmask);
  449. sprintf(netmaskStr, "%d.%d.%d.%d", pSetLanReq->ConfigData.SubNetMask[0],
  450. pSetLanReq->ConfigData.SubNetMask[1], pSetLanReq->ConfigData.SubNetMask[2],
  451. pSetLanReq->ConfigData.SubNetMask[3]);
  452. if(strcmp(netmaskStr, old_netmask) == 0)
  453. {
  454. printf("The same netmask %s, do nothing\n", netmaskStr );
  455. *pRes = CC_NORMAL;
  456. return 1;
  457. }
  458. if(IPAddrCheck(pSetLanReq->ConfigData.SubNetMask,LAN_PARAM_SUBNET_MASK))
  459. {
  460. *pRes = CC_INV_DATA_FIELD;
  461. return sizeof (uint8_t);
  462. }
  463. m_MsgPkt.Param = PARAM_LAN;
  464. m_MsgPkt.NetFnLUN = NETFNLUN_IPMI_TRANSPORT;
  465. m_MsgPkt.Cmd = CMD_SET_LAN_CONFIGURATION_PARAMETERS;
  466. m_MsgPkt.Size = sizeof(SetLanConfigReq_T);
  467. memcpy(m_MsgPkt.Data, pSetLanReq, sizeof(SetLanConfigReq_T));
  468. PostMsg(gPendActionIfc, &m_MsgPkt);
  469. //Update
  470. memcpy(g_BMCInfo.LanInfo[index].NetMask, pSetLanReq->ConfigData.SubNetMask, 4);
  471. FlushIpmiConfig();
  472. pSetLanRes->CompletionCode = CC_NORMAL;
  473. break;
  474. case LAN_PARAM_IPv4_HEADER:
  475. printf("Not implement\n");
  476. // pendStatus = GetPendStatus(PEND_OP_SET_IPV4_HEADERS);
  477. // if(pendStatus == PEND_STATUS_PENDING)
  478. // {
  479. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  480. // return sizeof (uint8_t);
  481. // }
  482. // if(!pSetLanReq->ConfigData.Ipv4HdrParam.TimeToLive > 0)
  483. // {
  484. // IPMI_DBG_PRINT("The requested IPv4 header(TTL) to set is invalid.\n");
  485. // *pRes = CC_PARAM_OUT_OF_RANGE;
  486. // return sizeof(*pRes);
  487. // }
  488. // if(pSetLanReq->ConfigData.Ipv4HdrParam.IpHeaderFlags == 0x60) // Flags can be either of the values: DF(0x40) or MF(0x20)
  489. // {
  490. // IPMI_DBG_PRINT("The requested IPv4 header(Flags) to set is invalid.\n");
  491. // *pRes = CC_PARAM_OUT_OF_RANGE;
  492. // return sizeof(*pRes);
  493. // }
  494. // LOCK_BMC_SHARED_MEM(BMCInst);
  495. // _fmemcpy (&pBMCInfo->LANCfs[EthIndex].Ipv4HdrParam,
  496. // &pSetLanReq->ConfigData.Ipv4HdrParam, sizeof(IPv4HdrParams_T));
  497. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  498. // SetPendStatus(PEND_OP_SET_IPV4_HEADERS,PEND_STATUS_PENDING);
  499. // PostPendTask(PEND_OP_SET_IPV4_HEADERS, (uint8_t*)&(pSetLanReq->ConfigData.Ipv4HdrParam),
  500. // sizeof(pSetLanReq->ConfigData.Ipv4HdrParam),(pSetLanReq->ChannelNum & 0x0F),BMCInst);
  501. break;
  502. case LAN_PARAM_PRI_RMCP_PORT:
  503. printf("Not implement\n"); //需要重启网络线程
  504. // pendStatus = GetPendStatus(PEND_RMCP_PORT_CHANGE);
  505. // if(pendStatus == PEND_STATUS_PENDING)
  506. // {
  507. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  508. // return sizeof (uint8_t);
  509. // }
  510. // LOCK_BMC_SHARED_MEM(BMCInst);
  511. // pBMCInfo->LANCfs[EthIndex].PrimaryRMCPPort = ipmitoh_u16 (pSetLanReq->ConfigData.PrimaryRMCPPort);
  512. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  513. // SetPendStatus(PEND_RMCP_PORT_CHANGE,PEND_STATUS_PENDING);
  514. // PostPendTask(PEND_RMCP_PORT_CHANGE,(uint8_t*)&(pSetLanReq->ConfigData.PrimaryRMCPPort),
  515. // sizeof(pSetLanReq->ConfigData.PrimaryRMCPPort),(pSetLanReq->ChannelNum & 0x0F),BMCInst);
  516. break;
  517. case LAN_PARAM_SEC_RMCP_PORT:
  518. /* Returning Invalid error message */
  519. *pRes = CC_PARAM_NOT_SUPPORTED;
  520. return sizeof (uint8_t);
  521. /*pPMConfig->LANConfig[EthIndex].SecondaryPort = ipmitoh_u16 (pSetLanReq->ConfigData.SecondaryPort);*/
  522. break;
  523. case LAN_PARAM_BMC_GENERATED_ARP_CONTROL:
  524. printf("Not implement\n");
  525. // currBmcGenArpCtrl = pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl;
  526. // if(currBmcGenArpCtrl != pSetLanReq->ConfigData.BMCGeneratedARPControl)
  527. // pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl = pSetLanReq->ConfigData.BMCGeneratedARPControl;
  528. // if((ENABLE_ARP_RESPONSES & currBmcGenArpCtrl) !=
  529. // (ENABLE_ARP_RESPONSES & pSetLanReq->ConfigData.BMCGeneratedARPControl))
  530. // {
  531. // UpdateArpStatus(EthIndex, BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning, BMCInst);
  532. // }
  533. // if(!(GRATIUTOUS_ENABLE_MASK & currBmcGenArpCtrl) &&
  534. // (GRATIUTOUS_ENABLE_MASK & pSetLanReq->ConfigData.BMCGeneratedARPControl))
  535. // {
  536. // /* Create a thread to Send Gratuitous ARP Packet */
  537. // pLANArg = malloc(sizeof(BMCArg));
  538. // pLANArg->BMCInst = BMCInst;
  539. // pLANArg->Len = strlen((char *)&EthIndex);
  540. // pLANArg->Argument = malloc(pLANArg->Len);
  541. // memcpy(pLANArg->Argument,(char *)&EthIndex,pLANArg->Len);
  542. // OS_CREATE_THREAD ((void *)GratuitousARPTask,(void *)pLANArg, NULL);
  543. // }
  544. break;
  545. case LAN_PARAM_GRATITIOUS_ARP_INTERVAL:
  546. printf("Not implement\n");
  547. // pBMCInfo->LANCfs[EthIndex].GratitousARPInterval =
  548. // pSetLanReq->ConfigData.GratitousARPInterval;
  549. break;
  550. case LAN_PARAM_DEFAULT_GATEWAY_IP:
  551. /*Returning valid completion code in case of attempt to set default gateway ip in DHCP mode */
  552. if(g_BMCInfo.LanInfo[index].IPAddrSrc == DHCP_IP_SOURCE)
  553. {
  554. *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  555. return sizeof (uint8_t);
  556. }
  557. if(IPAddrCheck(pSetLanReq->ConfigData.DefaultGatewayIPAddr,LAN_PARAM_DEFAULT_GATEWAY_IP))
  558. {
  559. *pRes = CC_INV_DATA_FIELD;
  560. return sizeof (uint8_t);
  561. }
  562. m_MsgPkt.Param = PARAM_LAN;
  563. m_MsgPkt.NetFnLUN = NETFNLUN_IPMI_TRANSPORT;
  564. m_MsgPkt.Cmd = CMD_SET_LAN_CONFIGURATION_PARAMETERS;
  565. m_MsgPkt.Size = sizeof(SetLanConfigReq_T);
  566. memcpy(m_MsgPkt.Data, pSetLanReq, sizeof(SetLanConfigReq_T));
  567. PostMsg(gPendActionIfc, &m_MsgPkt);
  568. //Update
  569. memcpy(g_BMCInfo.LanInfo[index].DefaultGW, pSetLanReq->ConfigData.DefaultGatewayIPAddr, 4);
  570. FlushIpmiConfig();
  571. pSetLanRes->CompletionCode = CC_NORMAL;
  572. break;
  573. case LAN_PARAM_DEFAULT_GATEWAY_MAC:
  574. pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  575. return sizeof(*pRes);
  576. break;
  577. case LAN_PARAM_BACKUP_GATEWAY_IP:
  578. printf("Not implement\n");
  579. // nwReadNWCfg_v4_v6( &NWConfig,&NWConfig6, netindex,g_corefeatures.global_ipv6);
  580. // _fmemcpy ((uint8_t*)&GWIp,pSetLanReq->ConfigData.BackupGatewayIPAddr, IP_ADDR_LEN);
  581. // _fmemcpy ((uint8_t*)&Subnetmask,&NWConfig.Mask[0],IP_ADDR_LEN);
  582. // _fmemcpy ((uint8_t*)&IPAddr,&NWConfig.IPAddr[0], IP_ADDR_LEN);
  583. // if(GWIp != 0)
  584. // {
  585. // if((IPAddr & Subnetmask ) != (GWIp & Subnetmask))
  586. // {
  587. // IPMI_DBG_PRINT("\n Backup GatewayIP to set is not valid \n");
  588. // *pRes = CC_INV_DATA_FIELD;
  589. // return sizeof (uint8_t);
  590. // }
  591. // }
  592. // LOCK_BMC_SHARED_MEM(BMCInst);
  593. // _fmemcpy (pBMCInfo->LANCfs[EthIndex].BackupGatewayIPAddr,
  594. // pSetLanReq->ConfigData.BackupGatewayIPAddr, IP_ADDR_LEN);
  595. // nwSetBkupGWyAddr(pSetLanReq->ConfigData.BackupGatewayIPAddr,netindex);
  596. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  597. break;
  598. case LAN_PARAM_BACKUP_GATEWAY_MAC:
  599. printf("Not implement\n");
  600. // LOCK_BMC_SHARED_MEM(BMCInst);
  601. // _fmemcpy (pBMCInfo->LANCfs[EthIndex].BackupGatewayMACAddr,
  602. // pSetLanReq->ConfigData.BackupGatewayMACAddr, MAC_ADDR_LEN);
  603. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  604. break;
  605. case LAN_PARAM_COMMUNITY_STRING:
  606. printf("Not implement\n");
  607. // if (g_PDKHandle[PDK_SETSNMPCOMMUNITYNAME] != NULL )
  608. // {
  609. // if(((int(*)(uint8_t *, uint8_t,int))(g_PDKHandle[PDK_SETSNMPCOMMUNITYNAME]))(pSetLanReq->ConfigData.CommunityStr,MAX_COMM_STRING_SIZE, BMCInst)==0)
  610. // break;
  611. // }
  612. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->PefConfig.PEFSharedMemMutex, WAIT_INFINITE);
  613. // _fmemcpy (pBMCInfo->LANCfs[EthIndex].CommunityStr,
  614. // pSetLanReq->ConfigData.CommunityStr, MAX_COMM_STRING_SIZE);
  615. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  616. break;
  617. case LAN_PARAM_DEST_NUM:
  618. pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  619. return sizeof(uint8_t);
  620. case LAN_PARAM_SELECT_DEST_TYPE:
  621. printf("Not implement\n");
  622. // // if (pSetLanReq->ConfigData.DestType.SetSelect > NUM_LAN_DESTINATION)
  623. // if (pSetLanReq->ConfigData.DestType.SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
  624. // {
  625. // *pRes = CC_PARAM_OUT_OF_RANGE;
  626. // return sizeof (*pRes);
  627. // }
  628. // if (0 == pSetLanReq->ConfigData.DestType.SetSelect)
  629. // {
  630. // LOCK_BMC_SHARED_MEM(BMCInst);
  631. // _fmemcpy (&pSharedMem->VolLANDestType[EthIndex],
  632. // &pSetLanReq->ConfigData.DestType, sizeof(LANDestType_T));
  633. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  634. // }
  635. // else
  636. // {
  637. // LOCK_BMC_SHARED_MEM(BMCInst);
  638. // _fmemcpy (&pBMCInfo->LANCfs[EthIndex].DestType [pSetLanReq->ConfigData.DestType.SetSelect - 1],
  639. // &pSetLanReq->ConfigData.DestType, sizeof(LANDestType_T));
  640. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  641. // }
  642. break;
  643. case LAN_PARAM_SELECT_DEST_ADDR:
  644. printf("Not implement\n");
  645. // pendStatus = GetPendStatus(PEND_OP_SET_GATEWAY);
  646. // if(pendStatus == PEND_STATUS_PENDING)
  647. // {
  648. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  649. // return sizeof (uint8_t);
  650. // }
  651. // // if (pSetLanReq->ConfigData.DestAddr.SetSelect > NUM_LAN_DESTINATION)
  652. // if (pSetLanReq->ConfigData.DestType.SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
  653. // {
  654. // *pRes = CC_PARAM_OUT_OF_RANGE ;
  655. // return sizeof (*pRes);
  656. // }
  657. // if (0 == pSetLanReq->ConfigData.DestAddr.SetSelect)
  658. // {
  659. // LOCK_BMC_SHARED_MEM(BMCInst);
  660. // _fmemcpy (&pSharedMem->VolLANDest[EthIndex],
  661. // &pSetLanReq->ConfigData.DestAddr, sizeof(LANDestAddr_T));
  662. // memset(pSharedMem->VolLANv6Dest,0,sizeof(LANDestv6Addr_T));
  663. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  664. // }
  665. // else
  666. // {
  667. // LOCK_BMC_SHARED_MEM(BMCInst);
  668. // _fmemcpy (&pBMCInfo->LANCfs[EthIndex].DestAddr [pSetLanReq->ConfigData.DestAddr.SetSelect - 1],
  669. // &pSetLanReq->ConfigData.DestAddr, sizeof(LANDestAddr_T));
  670. // memset( &pBMCInfo->LANCfs[EthIndex].Destv6Addr [pSetLanReq->ConfigData.Destv6Addr.SetSelect -1], 0 ,
  671. // sizeof(LANDestv6Addr_T));
  672. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  673. // }
  674. // /* Setting BackupGw to DefaultGw as per request to send trap */
  675. // if(pSetLanReq->ConfigData.DestAddr.GateWayUse == 1)
  676. // {
  677. // IPMI_DBG_PRINT("Setting Backupgw to Defaultgwip as per Request \n");
  678. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  679. // LOCK_BMC_SHARED_MEM(BMCInst);
  680. // _fmemcpy(NWConfig.Gateway,pBMCInfo->LANCfs[EthIndex].BackupGatewayIPAddr,IP_ADDR_LEN);
  681. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  682. // SetPendStatus(PEND_OP_SET_GATEWAY,PEND_STATUS_PENDING);
  683. // PostPendTask(PEND_OP_SET_GATEWAY,(uint8_t*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F),BMCInst);
  684. // }
  685. break;
  686. case LAN_PARAM_VLAN_ID:
  687. printf("Not implement\n");
  688. // if( pBMCInfo->IpmiConfig.VLANIfcSupport == 1)
  689. // {
  690. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  691. // if((pSetLanReq->ConfigData.VLANID & VLAN_MASK_BIT) == VLAN_MASK_BIT) /* checks for VLAN enable bit*/
  692. // {
  693. // pendStatus = GetPendStatus(PEND_OP_SET_VLAN_ID);
  694. // if(pendStatus == PEND_STATUS_PENDING)
  695. // {
  696. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  697. // return sizeof (uint8_t);
  698. // }
  699. // vlanID = (pSetLanReq->ConfigData.VLANID & 0xfff); /* get the vlan d from the data */
  700. // for(i=0;i<sizeof(InvalidVlanID)/sizeof(uint16_t);i++)
  701. // {
  702. // if(InvalidVlanID[i] != vlanID)
  703. // {
  704. // continue;
  705. // }
  706. // else /*invalid vlan id */
  707. // {
  708. // *pRes = CC_INV_DATA_FIELD ;
  709. // return sizeof (*pRes);
  710. // }
  711. // }
  712. // if ( NWConfig.VLANID != 0) /* checks if vlan id already present */
  713. // {
  714. // if(NWConfig.VLANID == vlanID)
  715. // {
  716. // TCRIT("Currently configured vlan id and incoming set vlan id are same thus, do nothing\n");
  717. // break;
  718. // }
  719. // memset(IfcName,0,sizeof(IfcName));
  720. // if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
  721. // {
  722. // TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
  723. // *pRes = CC_INV_DATA_FIELD ;
  724. // return sizeof (*pRes);
  725. // }
  726. // sprintf(VLANInterfaceName, "%s.%d", IfcName, (int)(NWConfig.VLANID));
  727. // if (0 == NwInterfacePresenceCheck (VLANInterfaceName))
  728. // {
  729. // pendStatus = GetPendStatus(PEND_OP_SET_VLAN_ID);
  730. // if(pendStatus == PEND_STATUS_PENDING)
  731. // {
  732. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  733. // return sizeof (uint8_t);
  734. // }
  735. // SetPendStatus(PEND_OP_DECONFIG_VLAN_IFC,PEND_STATUS_PENDING);
  736. // PostPendTask(PEND_OP_DECONFIG_VLAN_IFC,(uint8_t*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  737. // pBMCInfo->LANCfs[EthIndex].VLANPriority =0;
  738. // }
  739. // }
  740. // NWConfig.VLANID=vlanID;
  741. // SetPendStatus(PEND_OP_SET_VLAN_ID,PEND_STATUS_PENDING);
  742. // PostPendTask(PEND_OP_SET_VLAN_ID,(uint8_t*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  743. // pBMCInfo->LANCfs[EthIndex].VLANID = pSetLanReq->ConfigData.VLANID;
  744. // }
  745. // else /* Vlan Bit is Disabled */
  746. // {
  747. // if(NWConfig.VLANID==0) /* Vlan id is disabled */
  748. // {
  749. // if((pSetLanReq->ConfigData.VLANID & 0xfff)!=0)
  750. // {
  751. // pBMCInfo->LANCfs[EthIndex].VLANID = pSetLanReq->ConfigData.VLANID;
  752. // }
  753. // if((pSetLanReq->ConfigData.VLANID & 0xfff)==0)
  754. // {
  755. // if((pBMCInfo->LANCfs[EthIndex].VLANID & 0xfff)!=0)
  756. // {
  757. // pBMCInfo->LANCfs[EthIndex].VLANID = pSetLanReq->ConfigData.VLANID;
  758. // }
  759. // }
  760. // }
  761. // else /* Vlan ID is enable. so deconfigure it */
  762. // {
  763. // memset(IfcName,0,sizeof(IfcName));
  764. // if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
  765. // {
  766. // TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
  767. // *pRes = CC_INV_DATA_FIELD ;
  768. // return sizeof (*pRes);
  769. // }
  770. // sprintf(VLANInterfaceName, "%s.%d", IfcName, (int)(NWConfig.VLANID));
  771. // if (0 == NwInterfacePresenceCheck (VLANInterfaceName))
  772. // {
  773. // pendStatus = GetPendStatus(PEND_OP_SET_VLAN_ID);
  774. // if(pendStatus == PEND_STATUS_PENDING)
  775. // {
  776. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  777. // return sizeof (uint8_t);
  778. // }
  779. // SetPendStatus(PEND_OP_DECONFIG_VLAN_IFC,PEND_STATUS_PENDING);
  780. // PostPendTask(PEND_OP_DECONFIG_VLAN_IFC,(uint8_t*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  781. // pBMCInfo->LANCfs[EthIndex].VLANPriority =0;
  782. // }
  783. // pendStatus = GetPendStatus(PEND_OP_SET_SOURCE);
  784. // if(pendStatus == PEND_STATUS_PENDING)
  785. // {
  786. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  787. // return sizeof (uint8_t);
  788. // }
  789. // //NWConfig.VLANID=0;
  790. // NWConfig.CfgMethod = pBMCInfo->LANCfs[EthIndex].IPAddrSrc;
  791. // SetPendStatus(PEND_OP_SET_SOURCE,PEND_STATUS_PENDING);
  792. // PostPendTask(PEND_OP_SET_SOURCE,(uint8_t*) &NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  793. // pBMCInfo->LANCfs[EthIndex].VLANID = pSetLanReq->ConfigData.VLANID;
  794. // }
  795. // }
  796. // }
  797. // else
  798. // {
  799. // pSetLanRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  800. // return sizeof(uint8_t);
  801. // }
  802. break;
  803. case LAN_PARAM_VLAN_PRIORITY:
  804. printf("Not implement\n");
  805. // if( pBMCInfo->IpmiConfig.VLANIfcSupport == 1)
  806. // {
  807. // if((pBMCInfo->LANCfs[EthIndex].VLANID & VLAN_MASK_BIT) != VLAN_MASK_BIT) /* checks for VLAN enable bit*/
  808. // {
  809. // if(g_corefeatures.vlan_priorityset == ENABLED)
  810. // {
  811. // if(pSetLanReq->ConfigData.VLANPriority > 7 )
  812. // {
  813. // TCRIT(" VLAN Priority value should be 0-7 \n");
  814. // *pRes = CC_INV_DATA_FIELD ;
  815. // return sizeof (*pRes);
  816. // }
  817. // if(ReadVLANFile(VLAN_PRIORITY_SETTING_STR, PriorityLevel) == -1)
  818. // {
  819. // return -1;
  820. // }
  821. // if(WriteVLANFile(VLAN_PRIORITY_SETTING_STR, PriorityLevel, netindex,pSetLanReq->ConfigData.VLANPriority) == -1)
  822. // {
  823. // return -1;
  824. // }
  825. // pBMCInfo->LANCfs[EthIndex].VLANPriority = pSetLanReq->ConfigData.VLANPriority;
  826. // }
  827. // else
  828. // {
  829. // TCRIT(" VLAN is not Configured \n");
  830. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  831. // return sizeof (*pRes);
  832. // }
  833. // }
  834. // else
  835. // {
  836. // if(pSetLanReq->ConfigData.VLANPriority > 7 )
  837. // {
  838. // TCRIT(" VLAN Priority value should be 0-7 \n");
  839. // *pRes = CC_INV_DATA_FIELD ;
  840. // return sizeof (*pRes);
  841. // }
  842. // if(ReadVLANFile(VLAN_PRIORITY_SETTING_STR, PriorityLevel) == -1)
  843. // {
  844. // return -1;
  845. // }
  846. // if(WriteVLANFile(VLAN_PRIORITY_SETTING_STR, PriorityLevel, netindex,pSetLanReq->ConfigData.VLANPriority) == -1)
  847. // {
  848. // return -1;
  849. // }
  850. // pBMCInfo->LANCfs[EthIndex].VLANPriority = pSetLanReq->ConfigData.VLANPriority;
  851. // vlanID = (pBMCInfo->LANCfs[EthIndex].VLANID & 0xfff);
  852. // memset(IfcName,0,sizeof(IfcName));
  853. // if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
  854. // {
  855. // TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
  856. // *pRes = CC_INV_DATA_FIELD;
  857. // return sizeof(*pRes);
  858. // }
  859. // /*vconfig set_egress_map <valninterface> <skb_buffer> <vlan-priority>*/
  860. // sprintf(cmdSetPriority,"vconfig set_egress_map %s.%d 0 %d",IfcName,vlanID,pSetLanReq->ConfigData.VLANPriority);
  861. // if(((retValue = safe_system(cmdSetPriority)) < 0))
  862. // {
  863. // TCRIT("ERROR %d: Set VLAN Priority failed\n",retValue);
  864. // }
  865. // /*
  866. // * Set priority of IPMI commands.
  867. // * The skb->priority value of IPMI command will be modified by TOS option.
  868. // * So, use the mapping table to get the current value.
  869. // */
  870. // memset(&cmdSetPriority,0,sizeof(cmdSetPriority));
  871. // TOS = pBMCInfo->LANCfs[EthIndex].Ipv4HdrParam.TypeOfService;
  872. // SkbPriority = IP_TOS2PRIO[IPTOS_TOS(TOS)>>1];
  873. // sprintf(cmdSetPriority,"vconfig set_egress_map %s.%d %d %d",IfcName,vlanID,SkbPriority,pSetLanReq->ConfigData.VLANPriority);
  874. // if(((retValue = safe_system(cmdSetPriority)) < 0))
  875. // {
  876. // TCRIT("ERROR %d: Set VLAN IPMI Priority failed\n",retValue);
  877. // }
  878. // }
  879. // }
  880. // else
  881. // {
  882. // pSetLanRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  883. // return sizeof(uint8_t);
  884. // }
  885. break;
  886. case LAN_PARAM_CIPHER_SUITE_ENTRY_SUP:
  887. pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  888. return sizeof(uint8_t);
  889. case LAN_PARAM_CIPHER_SUITE_ENTRIES:
  890. pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  891. return sizeof(uint8_t);
  892. break;
  893. case LAN_PARAM_CIPHER_SUITE_PRIV_LEVELS:
  894. printf("Not implement\n");
  895. // LOCK_BMC_SHARED_MEM(BMCInst);
  896. // _fmemcpy (pBMCInfo->LANCfs[EthIndex].CipherSuitePrivLevels,
  897. // pSetLanReq->ConfigData.CipherSuitePrivLevels, MAX_NUM_CIPHER_SUITE_PRIV_LEVELS);
  898. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  899. break;
  900. case LAN_PARAM_VLAN_TAGS:
  901. printf("Not implement\n");
  902. // if (0 == pSetLanReq->ConfigData.DestAddr.SetSelect)
  903. // {
  904. // LOCK_BMC_SHARED_MEM(BMCInst);
  905. // _fmemcpy(&pSharedMem->VLANDestTag,
  906. // (( uint8_t*)&pSetLanReq->ConfigData) + 1, sizeof(VLANDestTags_T));
  907. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  908. // }
  909. // else
  910. // {
  911. // if (pSetLanReq->ConfigData.DestAddr.SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest)
  912. // {
  913. // pSetLanRes->CompletionCode = CC_PARAM_OUT_OF_RANGE;
  914. // return sizeof (uint8_t);
  915. // }
  916. // LOCK_BMC_SHARED_MEM(BMCInst);
  917. // _fmemcpy(&pBMCInfo->LANCfs[EthIndex].VLANDestTags [pSetLanReq->ConfigData.DestAddr.SetSelect - 1],
  918. // (( uint8_t*)&pSetLanReq->ConfigData) + 1, sizeof(VLANDestTags_T));
  919. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  920. // }
  921. break;
  922. case LAN_PARAMS_BAD_PASSWORD_THRESHOLD:
  923. printf("Not implement\n");
  924. // ClearUserLockAttempts(LAN_CHANNEL_BADP,BMCInst);
  925. // LOCK_BMC_SHARED_MEM(BMCInst);
  926. // _fmemcpy(&pBMCInfo->LANCfs[EthIndex].BadPasswd,
  927. // &pSetLanReq->ConfigData.BadPasswd,sizeof(BadPassword_T));
  928. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  929. break;
  930. default:
  931. pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
  932. return sizeof(uint8_t);
  933. }
  934. pSetLanRes->CompletionCode = CC_NORMAL;
  935. FlushIpmiConfig();
  936. return sizeof(*pSetLanRes);
  937. }
  938. /*
  939. *@fn IPAddrCheck function
  940. *@brief It will validate the IP Address and net Mask
  941. *@param Addr - IP Address or net Mask
  942. *@param params - parameter data to validate
  943. */
  944. int IPAddrCheck(uint8_t *Addr,int params)
  945. {
  946. int i,maskcount=0,bitmask =0,j,bitcheck=0;
  947. for(i=0;i< IP_ADDR_LEN;i++)
  948. {
  949. if(Addr[i] == BRD_CAST_BIT_MASK)
  950. {
  951. maskcount++;
  952. }
  953. }
  954. if(maskcount == IP_ADDR_LEN)
  955. {
  956. return 1;
  957. }
  958. if(params == LAN_PARAM_SUBNET_MASK)
  959. {
  960. if(Addr[0] == BRD_CAST_BIT_MASK)
  961. {
  962. for(i=1;i< IP_ADDR_LEN;i++)
  963. {
  964. if(Addr[i-1] == 0)
  965. {
  966. bitmask = 1;
  967. }
  968. if(Addr[i] != 0)
  969. {
  970. for(j=0;j<8;j++)
  971. {
  972. if((Addr[i]<<j) & SUBNET_MASK_BIT_CHECK)
  973. {
  974. if(bitcheck == 1)
  975. {
  976. return 1;
  977. }
  978. continue;
  979. }
  980. bitcheck=1;
  981. }
  982. if((bitcheck == 1 && Addr[i-1] != BRD_CAST_BIT_MASK) || (Addr[i] > 0 && bitmask == 1))
  983. {
  984. return 1;
  985. }
  986. }
  987. }
  988. return 0;
  989. }
  990. return 1;
  991. }
  992. if(Addr[0] == LOOP_BACK_BIT_MASK || Addr[0] == BRD_CAST_BIT_MASK)
  993. {
  994. return 1;
  995. }
  996. return 0;
  997. }
  998. // /*----------------------------------------------
  999. // * GratuitousARPTask
  1000. // *----------------------------------------------*/
  1001. // void* GratuitousARPTask (uint8_t *Addr)
  1002. // {
  1003. // uint8_t IntervalInSec;
  1004. // uint8_t Status;
  1005. // int nRet;
  1006. // NWCFG_STRUCT NWConfig;
  1007. // NWCFG6_STRUCT NWConfig6;
  1008. // uint8_t EthIndex,netindex= 0xFF;
  1009. // int BMCInst,i;
  1010. // char IfcName[16];
  1011. // BMCArg *GratArpArgs = (BMCArg *)Addr;
  1012. // BMCInst = GratArpArgs->BMCInst;
  1013. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  1014. // prctl(PR_SET_NAME,__FUNCTION__,0,0,0);
  1015. // memcpy(&EthIndex,GratArpArgs->Argument,GratArpArgs->Len);
  1016. // memset(IfcName,0,sizeof(IfcName));
  1017. // /*Get the EthIndex*/
  1018. // if(GetIfcName(EthIndex,IfcName, BMCInst) == -1)
  1019. // {
  1020. // TCRIT("Error in Getting Ifcname\n");
  1021. // return 0;
  1022. // }
  1023. // for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
  1024. // {
  1025. // if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
  1026. // {
  1027. // netindex= Ifcnametable[i].Index;
  1028. // break;
  1029. // }
  1030. // }
  1031. // if(netindex == 0xFF)
  1032. // {
  1033. // TCRIT("Error in gettting netindex\n");
  1034. // return 0;
  1035. // }
  1036. // if(Addr != NULL)
  1037. // {
  1038. // free(GratArpArgs->Argument);
  1039. // free(Addr);
  1040. // }
  1041. // TDBG ("Gratuitous ARP thread starts for ethindex : %x\n",EthIndex);
  1042. // while (1)
  1043. // {
  1044. // /*Is Gratiutous Arp Enabled */
  1045. // if (0 == (pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl & GRATIUTOUS_ENABLE_MASK))
  1046. // {
  1047. // TDBG("Gratuitous ARP thread exits : Disable BMC-generated Gratuitous ARPs invoked\n");
  1048. // break;
  1049. // }
  1050. // /*Is Gratiutous Arp Suspended */
  1051. // Status = BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex];
  1052. // if ((0 != (Status & GRATIUTOUS_ENABLE_MASK)) &&
  1053. // (BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning == TRUE))
  1054. // {
  1055. // // Gratuitous ARP Suspended.
  1056. // // sleep requested to access Shared memory for two different threads.
  1057. // usleep (20);
  1058. // continue;
  1059. // }
  1060. // nwReadNWCfg_v4_v6( &NWConfig,&NWConfig6, netindex,g_corefeatures.global_ipv6);
  1061. // if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
  1062. // {
  1063. // TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
  1064. // }
  1065. // if (NWConfig.IFName[0] == 0)
  1066. // sprintf((char *)&NWConfig.IFName, "%s",IfcName);
  1067. // TDBG ( "MAC is %2x:%2x:%2x:%2x:%2x:%2x \n", NWConfig.MAC [0], NWConfig.MAC [1],
  1068. // NWConfig.MAC [2], NWConfig.MAC [3], NWConfig.MAC [4], NWConfig.MAC [5] );
  1069. // TDBG ( "IP is %d.%d.%d.%d\n", NWConfig.IPAddr[0], NWConfig.IPAddr[1],
  1070. // NWConfig.IPAddr[2], NWConfig.IPAddr[3]);
  1071. // TDBG ( "Device Name : %s\n", (char *)&NWConfig.IFName);
  1072. // nRet = SendGratuitousARPPacket((char *)&NWConfig.IFName, NWConfig.IPAddr, NWConfig.MAC);
  1073. // if (0 != nRet)
  1074. // {
  1075. // TCRIT("Gratuitous ARP thread exits : Unable to Send Gratuitous ARP packet\n");
  1076. // break;
  1077. // }
  1078. // TDBG ("Send Gratuitous Packet\n");
  1079. // if (0 == pBMCInfo->LANCfs[EthIndex].GratitousARPInterval)
  1080. // {
  1081. // IntervalInSec = 2; //Default 2 secs
  1082. // } else {
  1083. // // Gratuitous ARP interval in 500 millisecond increments.
  1084. // IntervalInSec = (pBMCInfo->LANCfs[EthIndex].GratitousARPInterval * 500)/1000;
  1085. // }
  1086. // usleep( IntervalInSec * 1000 * 1000 );
  1087. // }
  1088. // return 0;
  1089. // }
  1090. // /*---------------------------------------------------
  1091. // * GetLanConfigParam
  1092. // *---------------------------------------------------*/
  1093. // int
  1094. // GetLanConfigParam ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1095. // {
  1096. // GetLanConfigReq_T* pGetLanReq = ( GetLanConfigReq_T*) pReq;
  1097. // GetLanConfigRes_T* pGetLanRes = ( GetLanConfigRes_T*) pRes;
  1098. // BMCSharedMem_T* pSharedMem = BMC_GET_SHARED_MEM (BMCInst);
  1099. // uint8_t IsOemDefined = FALSE;
  1100. // NWCFG_STRUCT NWConfig;
  1101. // NWCFG6_STRUCT NWConfig6;
  1102. // // V6DNS_CONFIG v6dnsconfig;
  1103. // uint8_t EthIndex,netindex= 0xFF,i;
  1104. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1105. // int ncsiPortConfigNum = 0;
  1106. // ETHCFG_STRUCT PHYCfg;
  1107. // ChannelInfo_T* pChannelInfo = NULL;
  1108. // char IfcName[16]; /* Eth interface name */
  1109. // uint8_t ComStrLen=MAX_COMM_STRING_SIZE;
  1110. // int retValue = 0,NIC_Count = 0;
  1111. // pGetLanRes->CCParamRev.CompletionCode = CC_NORMAL;
  1112. // pGetLanRes->CCParamRev.ParamRevision = PARAMETER_REVISION_FORMAT;
  1113. // // printf("---> channel: %d, parameter: %#x, setslect: %#x, blockselect: %#x\n", pGetLanReq->ChannelNum, pGetLanReq->ParameterSelect, pGetLanReq->SetSelect, pGetLanReq->BlockSelect);
  1114. // if(pGetLanReq->ChannelNum & RESERVED_VALUE_70)
  1115. // {
  1116. // /* Alarm !!! Somebody is trying to set Reseved Bits */
  1117. // *pRes = CC_INV_DATA_FIELD;
  1118. // return sizeof (*pRes);
  1119. // }
  1120. // if((pGetLanReq->ParameterSelect >= MIN_LAN_OEM_CONF_PARAM) &&
  1121. // (pGetLanReq->ParameterSelect <= MAX_LAN_OEM_CONF_PARAM) )
  1122. // {
  1123. // /* Converts OEM parameter value to equivalent AMI parameter value */
  1124. // if (0 != GetLanAMIParamValue (&pGetLanReq->ParameterSelect, &IsOemDefined) )
  1125. // {
  1126. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1127. // return sizeof(uint8_t);
  1128. // }
  1129. // /* Hook for OEM to handle this parameter */
  1130. // if ( (IsOemDefined) && (g_PDKHandle[PDK_GETLANOEMPARAM] != NULL) )
  1131. // {
  1132. // return ((int(*)(uint8_t *, uint8_t, uint8_t *,int))(g_PDKHandle[PDK_GETLANOEMPARAM]))(pReq, ReqLen, pRes, BMCInst);
  1133. // }
  1134. // }
  1135. // if (g_PDKHandle[PDK_BEFOREGETLANPARM] != NULL)
  1136. // {
  1137. // retValue = ((int(*)(uint8_t *, uint8_t, uint8_t *,int))(g_PDKHandle[PDK_BEFOREGETLANPARM]))(pReq, ReqLen, pRes, BMCInst);
  1138. // if(retValue != 0)
  1139. // {
  1140. // return retValue;
  1141. // }
  1142. // }
  1143. // //! Validate the SetSelector value.
  1144. // if ( (0x00 != pGetLanReq->SetSelect) &&
  1145. // (pGetLanReq->ParameterSelect != LAN_PARAM_SELECT_DEST_TYPE) &&
  1146. // (pGetLanReq->ParameterSelect != LAN_PARAM_SELECT_DEST_ADDR) &&
  1147. // (pGetLanReq->ParameterSelect != LAN_PARAM_VLAN_TAGS) &&
  1148. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR) &&
  1149. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR) &&
  1150. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_EUI64) &&
  1151. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH))
  1152. // {
  1153. // printf("GetLanConfigParam log1\n");
  1154. // if( g_corefeatures.ncsi_cmd_support == ENABLED )
  1155. // {
  1156. // if ((pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_NCSI_SETTINGS) &&
  1157. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_NCSI_MODE_CHANGE) &&
  1158. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_NCSI_EXTENSION))
  1159. // {
  1160. // *pRes = CC_INV_DATA_FIELD;
  1161. // return sizeof (*pRes);
  1162. // }
  1163. // }
  1164. // else
  1165. // {
  1166. // *pRes = CC_INV_DATA_FIELD;
  1167. // return sizeof (*pRes);
  1168. // }
  1169. // }
  1170. // //! Validate the BlockSelector value.
  1171. // if (0x00 != pGetLanReq->BlockSelect)
  1172. // {
  1173. // printf("GetLanConfigParam log2\n");
  1174. // *pRes = CC_INV_DATA_FIELD;
  1175. // return sizeof (*pRes);
  1176. // }
  1177. // EthIndex= GetEthIndex(pGetLanReq->ChannelNum & 0x0F, BMCInst);
  1178. // if(0xff == EthIndex)
  1179. // {
  1180. // printf("GetLanConfigParam log3\n");
  1181. // *pRes = CC_INV_DATA_FIELD;
  1182. // return sizeof (uint8_t);
  1183. // }
  1184. // /*Get the EthIndex*/
  1185. // if(GetIfcName(EthIndex,IfcName, BMCInst) != 0)
  1186. // {
  1187. // TCRIT("Error in Getting IfcName\n");
  1188. // *pRes = CC_INV_DATA_FIELD;
  1189. // return sizeof (uint8_t);
  1190. // }
  1191. // for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
  1192. // {
  1193. // if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
  1194. // {
  1195. // netindex= Ifcnametable[i].Index;
  1196. // break;
  1197. // }
  1198. // }
  1199. // if(netindex == 0xFF)
  1200. // {
  1201. // TCRIT("Error in Getting netindex %d %s\n",netindex,IfcName);
  1202. // *pRes = CC_INV_DATA_FIELD;
  1203. // return sizeof (uint8_t);
  1204. // }
  1205. // if ((pGetLanReq->ChannelNum & GET_PARAMETER_REVISION_MASK) != 0)
  1206. // {
  1207. // if((MAX_LAN_CONF_PARAM >= pGetLanReq->ParameterSelect) ||
  1208. // ((MIN_LAN_OEM_CONF_PARAM <= pGetLanReq->ParameterSelect) && (MAX_LAN_OEM_CONF_PARAM >= pGetLanReq->ParameterSelect)) )
  1209. // {
  1210. // return sizeof(GetLanCCRev_T);
  1211. // }
  1212. // else
  1213. // {
  1214. // *pRes = CC_PARAM_NOT_SUPPORTED;
  1215. // return sizeof (*pRes);
  1216. // }
  1217. // }
  1218. // else
  1219. // {
  1220. // printf("GetLanConfigParam log4\n");
  1221. // switch(pGetLanReq->ParameterSelect)
  1222. // {
  1223. // case LAN_PARAM_SET_IN_PROGRESS:
  1224. // LOCK_BMC_SHARED_MEM(BMCInst);
  1225. // pGetLanRes->ConfigData.SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Lan_SetInProgress;
  1226. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1227. // break;
  1228. // case LAN_PARAM_AUTH_TYPE_SUPPORT:
  1229. // pGetLanRes->ConfigData.AuthTypeSupport = pBMCInfo->LANCfs[EthIndex].AuthTypeSupport;
  1230. // break;
  1231. // case LAN_PARAM_AUTH_TYPE_ENABLES:
  1232. // LOCK_BMC_SHARED_MEM(BMCInst);
  1233. // _fmemcpy (&pGetLanRes->ConfigData.AuthTypeEnables,
  1234. // &(pBMCInfo->LANCfs[EthIndex].AuthTypeEnables), sizeof(AuthTypeEnables_T));
  1235. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1236. // break;
  1237. // case LAN_PARAM_IP_ADDRESS:
  1238. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPAddrSrc == STATIC_IP_SOURCE))
  1239. // {
  1240. // if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
  1241. // {
  1242. // _fmemcpy (NWConfig.IPAddr,pBMCInfo->LANCfs[EthIndex].IPAddr, IP_ADDR_LEN);
  1243. // }
  1244. // else
  1245. // {
  1246. // memset(&NWConfig, 0, sizeof(NWConfig));
  1247. // }
  1248. // }
  1249. // else
  1250. // {
  1251. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1252. // }
  1253. // _fmemcpy (pGetLanRes->ConfigData.IPAddr, NWConfig.IPAddr, IP_ADDR_LEN);
  1254. // break;
  1255. // case LAN_PARAM_IP_ADDRESS_SOURCE:
  1256. // if(g_corefeatures.delayed_lan_restart_support)
  1257. // {
  1258. // if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
  1259. // {
  1260. // NWConfig.CfgMethod = pBMCInfo->LANCfs[EthIndex].IPAddrSrc;
  1261. // }
  1262. // else
  1263. // {
  1264. // memset(&NWConfig, 0, sizeof(NWConfig));
  1265. // }
  1266. // }
  1267. // else
  1268. // {
  1269. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1270. // }
  1271. // pGetLanRes->ConfigData.IPAddrSrc = NWConfig.CfgMethod;
  1272. // break;
  1273. // case LAN_PARAM_MAC_ADDRESS:
  1274. // nwGetNWInformations(&NWConfig,IfcName);
  1275. // _fmemcpy (pGetLanRes->ConfigData.MACAddr, NWConfig.MAC, MAC_ADDR_LEN);
  1276. // break;
  1277. // case LAN_PARAM_SUBNET_MASK:
  1278. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPAddrSrc == STATIC_IP_SOURCE))
  1279. // {
  1280. // if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
  1281. // {
  1282. // _fmemcpy (NWConfig.Mask,pBMCInfo->LANCfs[EthIndex].SubNetMask, IP_ADDR_LEN);
  1283. // }
  1284. // else
  1285. // {
  1286. // memset(&NWConfig, 0, sizeof(NWConfig));
  1287. // }
  1288. // }
  1289. // else
  1290. // {
  1291. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1292. // }
  1293. // _fmemcpy (pGetLanRes->ConfigData.SubNetMask, NWConfig.Mask, IP_ADDR_LEN);
  1294. // break;
  1295. // case LAN_PARAM_IPv4_HEADER:
  1296. // LOCK_BMC_SHARED_MEM(BMCInst);
  1297. // _fmemcpy (&pGetLanRes->ConfigData.Ipv4HdrParam,
  1298. // &(pBMCInfo->LANCfs[EthIndex].Ipv4HdrParam), sizeof(IPv4HdrParams_T));
  1299. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1300. // break;
  1301. // case LAN_PARAM_PRI_RMCP_PORT:
  1302. // pGetLanRes->ConfigData.PrimaryRMCPPort = htoipmi_u16(pBMCInfo->LANCfs[EthIndex].PrimaryRMCPPort);
  1303. // break;
  1304. // case LAN_PARAM_SEC_RMCP_PORT:
  1305. // /* Returning Invalid error message */
  1306. // *pRes = CC_PARAM_NOT_SUPPORTED;
  1307. // return sizeof (uint8_t);
  1308. // /*pGetLanRes->ConfigData.SecondaryPort = htoipmi_u16(pPMConfig->LANConfig[EthIndex].SecondaryPort);*/
  1309. // break;
  1310. // case LAN_PARAM_BMC_GENERATED_ARP_CONTROL:
  1311. // pGetLanRes->ConfigData.BMCGeneratedARPControl = pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl;
  1312. // break;
  1313. // case LAN_PARAM_GRATITIOUS_ARP_INTERVAL:
  1314. // pGetLanRes->ConfigData.GratitousARPInterval =
  1315. // pBMCInfo->LANCfs[EthIndex].GratitousARPInterval;
  1316. // break;
  1317. // case LAN_PARAM_DEFAULT_GATEWAY_IP:
  1318. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPAddrSrc == STATIC_IP_SOURCE))
  1319. // {
  1320. // if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
  1321. // {
  1322. // _fmemcpy (NWConfig.Gateway, pBMCInfo->LANCfs[EthIndex].DefaultGatewayIPAddr, IP_ADDR_LEN);
  1323. // }
  1324. // else
  1325. // {
  1326. // memset(&NWConfig, 0, sizeof(NWConfig));
  1327. // }
  1328. // }
  1329. // else
  1330. // {
  1331. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1332. // }
  1333. // _fmemcpy (pGetLanRes->ConfigData.DefaultGatewayIPAddr, NWConfig.Gateway, IP_ADDR_LEN);
  1334. // break;
  1335. // case LAN_PARAM_DEFAULT_GATEWAY_MAC:
  1336. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1337. // nwGetSrcMacAddr(&NWConfig.Gateway[0],netindex, &pGetLanRes->ConfigData.DefaultGatewayMACAddr[0]);
  1338. // break;
  1339. // case LAN_PARAM_BACKUP_GATEWAY_IP:
  1340. // LOCK_BMC_SHARED_MEM(BMCInst);
  1341. // nwGetBkupGWyAddr(pGetLanRes->ConfigData.BackupGatewayIPAddr,netindex);
  1342. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1343. // break;
  1344. // case LAN_PARAM_BACKUP_GATEWAY_MAC:
  1345. // LOCK_BMC_SHARED_MEM(BMCInst);
  1346. // _fmemcpy (pGetLanRes->ConfigData.BackupGatewayMACAddr,
  1347. // pBMCInfo->LANCfs[EthIndex].BackupGatewayMACAddr, MAC_ADDR_LEN);
  1348. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1349. // break;
  1350. // case LAN_PARAM_COMMUNITY_STRING:
  1351. // if (g_PDKHandle[PDK_GETSNMPCOMMUNITYNAME] != NULL )
  1352. // {
  1353. // if(((int(*)(uint8_t *, uint8_t *,int))(g_PDKHandle[PDK_GETSNMPCOMMUNITYNAME]))(pGetLanRes->ConfigData.CommunityStr,&ComStrLen, BMCInst)==0)
  1354. // break;
  1355. // }
  1356. // LOCK_BMC_SHARED_MEM(BMCInst);
  1357. // _fmemcpy (pGetLanRes->ConfigData.CommunityStr,
  1358. // pBMCInfo->LANCfs[EthIndex].CommunityStr, MAX_COMM_STRING_SIZE);
  1359. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1360. // break;
  1361. // case LAN_PARAM_DEST_NUM:
  1362. // pGetLanRes->ConfigData.NumDest = pBMCInfo->LANCfs[EthIndex].NumDest;
  1363. // break;
  1364. // case LAN_PARAM_SELECT_DEST_TYPE:
  1365. // //if (pGetLanReq->SetSelect > NUM_LAN_DESTINATION)
  1366. // if ( pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
  1367. // {
  1368. // *pRes = CC_PARAM_OUT_OF_RANGE ;
  1369. // return sizeof (*pRes);
  1370. // }
  1371. // if (0 == pGetLanReq->SetSelect)
  1372. // {
  1373. // LOCK_BMC_SHARED_MEM(BMCInst);
  1374. // _fmemcpy (&pGetLanRes->ConfigData.DestType,
  1375. // &pSharedMem->VolLANDestType[EthIndex], sizeof(LANDestType_T));
  1376. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1377. // }
  1378. // else
  1379. // {
  1380. // LOCK_BMC_SHARED_MEM(BMCInst);
  1381. // _fmemcpy (&pGetLanRes->ConfigData.DestType,
  1382. // &(pBMCInfo->LANCfs[EthIndex].DestType[pGetLanReq->SetSelect - 1]),
  1383. // sizeof(LANDestType_T));
  1384. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1385. // }
  1386. // break;
  1387. // case LAN_PARAM_SELECT_DEST_ADDR:
  1388. // //if (pGetLanReq->SetSelect > NUM_LAN_DESTINATION)
  1389. // if ( pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
  1390. // {
  1391. // *pRes = CC_PARAM_OUT_OF_RANGE ;
  1392. // return sizeof (*pRes);
  1393. // }
  1394. // if (0 == pGetLanReq->SetSelect)
  1395. // {
  1396. // LOCK_BMC_SHARED_MEM(BMCInst);
  1397. // _fmemcpy (&pGetLanRes->ConfigData.DestAddr,
  1398. // &pSharedMem->VolLANDest[EthIndex], sizeof(LANDestAddr_T));
  1399. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1400. // }
  1401. // else
  1402. // {
  1403. // LOCK_BMC_SHARED_MEM(BMCInst);
  1404. // _fmemcpy (&pGetLanRes->ConfigData.DestAddr,
  1405. // &(pBMCInfo->LANCfs[EthIndex].DestAddr[pGetLanReq->SetSelect - 1]),
  1406. // sizeof(LANDestAddr_T));
  1407. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1408. // }
  1409. // break;
  1410. // case LAN_PARAM_VLAN_ID:
  1411. // if( pBMCInfo->IpmiConfig.VLANIfcSupport == 1)
  1412. // {
  1413. // pGetLanRes->ConfigData.VLANID = pBMCInfo->LANCfs[EthIndex].VLANID;
  1414. // }
  1415. // break;
  1416. // case LAN_PARAM_VLAN_PRIORITY:
  1417. // pGetLanRes->ConfigData.VLANPriority = pBMCInfo->LANCfs[EthIndex].VLANPriority;
  1418. // break;
  1419. // case LAN_PARAM_CIPHER_SUITE_ENTRY_SUP:
  1420. // pGetLanRes->ConfigData.CipherSuiteSup = N0_OF_CIPHER_SUITE_SUPPORTED;
  1421. // break;
  1422. // case LAN_PARAM_CIPHER_SUITE_ENTRIES:
  1423. // {
  1424. // int i;
  1425. // _fmemset (pGetLanRes->ConfigData.CipherSuiteEntries, 0,
  1426. // sizeof (pGetLanRes->ConfigData.CipherSuiteEntries));
  1427. // for (i = 0; i < (N0_OF_CIPHER_SUITE_SUPPORTED); i++)
  1428. // {
  1429. // pGetLanRes->ConfigData.CipherSuiteEntries[i+1] = g_CipherRec[1 + i * 5];
  1430. // }
  1431. // }
  1432. // break;
  1433. // case LAN_PARAM_CIPHER_SUITE_PRIV_LEVELS:
  1434. // LOCK_BMC_SHARED_MEM(BMCInst);
  1435. // _fmemcpy (pGetLanRes->ConfigData.CipherSuitePrivLevels,
  1436. // pBMCInfo->LANCfs[EthIndex].CipherSuitePrivLevels,
  1437. // MAX_NUM_CIPHER_SUITE_PRIV_LEVELS);
  1438. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1439. // break;
  1440. // case LAN_PARAM_VLAN_TAGS:
  1441. // *(( uint8_t*)&pGetLanRes->ConfigData) = pGetLanReq->SetSelect;
  1442. // if (pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest)
  1443. // {
  1444. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_OUT_OF_RANGE;
  1445. // return sizeof (GetLanCCRev_T);
  1446. // }
  1447. // if (0 == pGetLanReq->SetSelect)
  1448. // {
  1449. // LOCK_BMC_SHARED_MEM(BMCInst);
  1450. // _fmemcpy ((( uint8_t*) &pGetLanRes->ConfigData) + 1,&pSharedMem->VLANDestTag, sizeof(VLANDestTags_T));
  1451. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1452. // }
  1453. // else
  1454. // {
  1455. // if (pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest)
  1456. // {
  1457. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_OUT_OF_RANGE;
  1458. // return sizeof(GetLanCCRev_T);
  1459. // }
  1460. // LOCK_BMC_SHARED_MEM(BMCInst);
  1461. // _fmemcpy ((( uint8_t*)&pGetLanRes->ConfigData) + 1,
  1462. // &pBMCInfo->LANCfs[EthIndex].VLANDestTags[pGetLanReq->SetSelect - 1],
  1463. // sizeof(VLANDestTags_T));
  1464. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1465. // }
  1466. // break;
  1467. // case LAN_PARAMS_BAD_PASSWORD_THRESHOLD:
  1468. // LOCK_BMC_SHARED_MEM(BMCInst);
  1469. // _fmemcpy(&pGetLanRes->ConfigData.BadPasswd,
  1470. // &pBMCInfo->LANCfs[EthIndex].BadPasswd,sizeof(BadPassword_T));
  1471. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1472. // break;
  1473. // case LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR:
  1474. // if ( pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
  1475. // {
  1476. // *pRes = CC_PARAM_OUT_OF_RANGE ;
  1477. // return sizeof (*pRes);
  1478. // }
  1479. // if (0 == pGetLanReq->SetSelect)
  1480. // {
  1481. // LOCK_BMC_SHARED_MEM(BMCInst);
  1482. // _fmemcpy (&pGetLanRes->ConfigData.Destv6Addr,
  1483. // &pSharedMem->VolLANv6Dest[EthIndex], sizeof(LANDestv6Addr_T));
  1484. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1485. // }
  1486. // else
  1487. // {
  1488. // LOCK_BMC_SHARED_MEM(BMCInst);
  1489. // _fmemcpy (&pGetLanRes->ConfigData.Destv6Addr,
  1490. // &(pBMCInfo->LANCfs[EthIndex].Destv6Addr[pGetLanReq->SetSelect - 1]),
  1491. // sizeof(LANDestv6Addr_T));
  1492. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1493. // }
  1494. // TDBG("\n GetLanconfig: Getting SNMPv6 configuration done..\n");
  1495. // return sizeof(GetLanConfigRes_T);
  1496. // break;
  1497. // case LAN_PARAMS_AMI_OEM_ENABLE_SET_MAC:
  1498. // pGetLanRes->ConfigData.ChangeMACEnabled = enableSetMACAddr;
  1499. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  1500. // case LAN_PARAMS_AMI_OEM_IPV6_ENABLE:
  1501. // if(g_corefeatures.delayed_lan_restart_support)
  1502. // {
  1503. // NWConfig6.enable = pBMCInfo->LANCfs[EthIndex].IPv6_Enable;
  1504. // }
  1505. // else
  1506. // {
  1507. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1508. // }
  1509. // pGetLanRes->ConfigData.IPv6_Enable = NWConfig6.enable;
  1510. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  1511. // break;
  1512. // case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE:
  1513. // if(g_corefeatures.delayed_lan_restart_support)
  1514. // {
  1515. // if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
  1516. // {
  1517. // NWConfig6.CfgMethod = pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc;
  1518. // }
  1519. // else
  1520. // {
  1521. // memset(&NWConfig6, 0, sizeof(NWConfig6));
  1522. // }
  1523. // }
  1524. // else
  1525. // {
  1526. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1527. // }
  1528. // pGetLanRes->ConfigData.IPv6_IPAddrSrc = NWConfig6.CfgMethod;
  1529. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  1530. // break;
  1531. // case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR:
  1532. // case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_EUI64:
  1533. // if(pGetLanReq->SetSelect & 0xF0)
  1534. // {
  1535. // *pRes = CC_INV_DATA_FIELD;
  1536. // return sizeof(uint8_t);
  1537. // }
  1538. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == STATIC_IP_SOURCE))
  1539. // {
  1540. // if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
  1541. // {
  1542. // _fmemcpy (NWConfig6.GlobalIPAddr,pBMCInfo->LANCfs[EthIndex].IPv6_IPAddr, IP6_ADDR_LEN*MAX_IPV6ADDRS);
  1543. // }
  1544. // else
  1545. // {
  1546. // memset(&NWConfig6, 0, sizeof(NWConfig6));
  1547. // }
  1548. // }
  1549. // else
  1550. // {
  1551. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1552. // }
  1553. // _fmemcpy (pGetLanRes->ConfigData.IPv6_LinkAddr, NWConfig6.GlobalIPAddr[(pGetLanReq->SetSelect & 0x0F)], IP6_ADDR_LEN);
  1554. // return sizeof(GetLanCCRev_T) + IP6_ADDR_LEN;
  1555. // break;
  1556. // case LAN_PARAMS_AMI_OEM_IPV6_LINK_ADDR:
  1557. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1558. // _fmemcpy (pGetLanRes->ConfigData.IPv6_LinkAddr, NWConfig6.LinkIPAddr, IP6_ADDR_LEN);
  1559. // return sizeof(GetLanCCRev_T) + IP6_ADDR_LEN;
  1560. // case LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH:
  1561. // if(pGetLanReq->SetSelect & 0xF0)
  1562. // {
  1563. // *pRes = CC_INV_DATA_FIELD;
  1564. // return sizeof(uint8_t);
  1565. // }
  1566. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == STATIC_IP_SOURCE))
  1567. // {
  1568. // if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
  1569. // {
  1570. // NWConfig6.GlobalPrefix[(pGetLanReq->SetSelect & 0x0F)] = pBMCInfo->LANCfs[EthIndex].IPv6_PrefixLen[(pGetLanReq->SetSelect & 0x0F)];
  1571. // }
  1572. // else
  1573. // {
  1574. // memset(&NWConfig6, 0, sizeof(NWConfig6));
  1575. // }
  1576. // }
  1577. // else
  1578. // {
  1579. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1580. // }
  1581. // pGetLanRes->ConfigData.IPv6_LinkAddrPrefix = NWConfig6.GlobalPrefix[(pGetLanReq->SetSelect & 0x0F)];
  1582. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  1583. // break;
  1584. // case LAN_PARAMS_AMI_OEM_IPV6_LINK_ADDR_PREFIX:
  1585. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1586. // pGetLanRes->ConfigData.IPv6_LinkAddrPrefix = NWConfig6.LinkPrefix;
  1587. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  1588. // break;
  1589. // case LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP:
  1590. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == STATIC_IP_SOURCE))
  1591. // {
  1592. // if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
  1593. // {
  1594. // _fmemcpy (NWConfig6.Gateway,pBMCInfo->LANCfs[EthIndex].IPv6_GatewayIPAddr, IP6_ADDR_LEN);
  1595. // }
  1596. // else
  1597. // {
  1598. // memset(&NWConfig6, 0, sizeof(NWConfig6));
  1599. // }
  1600. // }
  1601. // else
  1602. // {
  1603. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1604. // }
  1605. // _fmemcpy (pGetLanRes->ConfigData.IPv6_GatewayIPAddr, NWConfig6.Gateway, IP6_ADDR_LEN);
  1606. // return sizeof(GetLanCCRev_T) + IP6_ADDR_LEN;
  1607. // break;
  1608. // case LAN_PARAMS_AMI_OEM_PHY_SETTINGS:
  1609. // memset(IfcName, 0, sizeof(IfcName));
  1610. // if(GetIfcNameByIndex(EthIndex, IfcName) != 0)
  1611. // {
  1612. // TCRIT("Error in Getting Interface Name for the lan Index:%d\n",EthIndex);
  1613. // }
  1614. // if(nwGetEthInformation(&PHYCfg, IfcName) !=0)
  1615. // {
  1616. // pGetLanRes->CCParamRev.CompletionCode = CC_UNSPECIFIED_ERR;
  1617. // return sizeof(GetLanCCRev_T);
  1618. // }
  1619. // pGetLanRes->ConfigData.PHYConfig.Interface = EthIndex;
  1620. // pGetLanRes->ConfigData.PHYConfig.AutoNegotiationEnable = PHYCfg.autoneg;
  1621. // pGetLanRes->ConfigData.PHYConfig.Speed = PHYCfg.speed;
  1622. // pGetLanRes->ConfigData.PHYConfig.Duplex = PHYCfg.duplex;
  1623. // pGetLanRes->ConfigData.PHYConfig.CapabilitiesSupported = PHYCfg.supported;
  1624. // return sizeof(GetLanCCRev_T) + sizeof(PHYConfig_T);
  1625. // case LAN_PARAMS_AMI_OEM_MTU_SETTINGS:
  1626. // memset(IfcName,0,sizeof(IfcName));
  1627. // if(GetIfcNameByIndex(EthIndex, IfcName) != 0)
  1628. // {
  1629. // TCRIT("Error in Getting Interface Name for the lan Index:%d\n",EthIndex);
  1630. // pGetLanRes->CCParamRev.CompletionCode = CC_UNSPECIFIED_ERR;
  1631. // return sizeof(GetLanCCRev_T);
  1632. // }
  1633. // if(nwGetEthInformation(&PHYCfg, IfcName) !=0)
  1634. // {
  1635. // pGetLanRes->CCParamRev.CompletionCode = CC_UNSPECIFIED_ERR;
  1636. // return sizeof(GetLanCCRev_T);
  1637. // }
  1638. // pGetLanRes->ConfigData.MTU_size = PHYCfg.maxtxpkt;
  1639. // return sizeof(GetLanCCRev_T) + sizeof(uint16_t);
  1640. // case LAN_PARAMS_SSI_OEM_2ND_PRI_ETH_MAC_ADDR:
  1641. // if(g_corefeatures.ssi_support == ENABLED)
  1642. // {
  1643. // netindex = 0x1; /* Specify the 2nd interface */
  1644. // nwReadNWCfg_v4_v6(&NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1645. // _fmemcpy(pGetLanRes->ConfigData.SSI2ndPriEthMACAddr, NWConfig.MAC, MAC_ADDR_LEN);
  1646. // return sizeof(GetLanCCRev_T) + sizeof(pGetLanRes->ConfigData.SSI2ndPriEthMACAddr);
  1647. // }
  1648. // else
  1649. // {
  1650. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1651. // return sizeof(uint8_t);
  1652. // }
  1653. // break;
  1654. // case LAN_PARAMS_SSI_OEM_LINK_CTRL:
  1655. // if(g_corefeatures.ssi_support == ENABLED)
  1656. // {
  1657. // pGetLanRes->ConfigData.SSILinkControl = 0;
  1658. // pChannelInfo = getChannelInfo(pBMCInfo->RMCPLAN1Ch, BMCInst);
  1659. // if(NULL == pChannelInfo)
  1660. // {
  1661. // *pRes = CC_UNSPECIFIED_ERR;
  1662. // return sizeof (*pRes);
  1663. // }
  1664. // if (pChannelInfo->AccessMode == 0x02) /* If 1st channal is available */
  1665. // pGetLanRes->ConfigData.SSILinkControl |= BIT0;
  1666. // NIC_Count = g_coremacros.global_nic_count;
  1667. // if (NIC_Count == 2)
  1668. // {
  1669. // pChannelInfo = getChannelInfo(pBMCInfo->RMCPLAN2Ch, BMCInst);
  1670. // if(NULL == pChannelInfo)
  1671. // {
  1672. // *pRes = CC_UNSPECIFIED_ERR;
  1673. // return sizeof (*pRes);
  1674. // }
  1675. // if (pChannelInfo->AccessMode == 0x02) /* If 2nd channal is available */
  1676. // pGetLanRes->ConfigData.SSILinkControl |= BIT1;
  1677. // }
  1678. // return sizeof(GetLanCCRev_T) + sizeof(pGetLanRes->ConfigData.SSILinkControl);
  1679. // }
  1680. // else
  1681. // {
  1682. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1683. // return sizeof(uint8_t);
  1684. // }
  1685. // break;
  1686. // case LAN_PARAMS_SSI_OEM_CMM_IP_ADDR:
  1687. // if(g_corefeatures.ssi_support == ENABLED)
  1688. // {
  1689. // _fmemcpy (pGetLanRes->ConfigData.CMMIPAddr, pBMCInfo->SSIConfig.CMMIPAddr, IP_ADDR_LEN);
  1690. // return sizeof(GetLanCCRev_T) + sizeof(pGetLanRes->ConfigData.CMMIPAddr);
  1691. // }
  1692. // else
  1693. // {
  1694. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1695. // return sizeof(uint8_t);
  1696. // }
  1697. // break;
  1698. // default:
  1699. // if(g_corefeatures.ncsi_cmd_support == ENABLED)
  1700. // {
  1701. // switch(pGetLanReq->ParameterSelect)
  1702. // {
  1703. // case LAN_PARAMS_AMI_OEM_NCSI_CONFIG_NUM:
  1704. // NCSIGetTotalPorts(&ncsiPortConfigNum);
  1705. // if (ncsiPortConfigNum >= 0xFF)
  1706. // {
  1707. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  1708. // return sizeof(GetLanCCRev_T);
  1709. // }
  1710. // else
  1711. // {
  1712. // pGetLanRes->ConfigData.NumNCSIPortConfigs = ncsiPortConfigNum;
  1713. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  1714. // }
  1715. // break;
  1716. // case LAN_PARAMS_AMI_OEM_NCSI_SETTINGS:
  1717. // {
  1718. // NIC_Count=g_coremacros.global_nic_count;
  1719. // if (pGetLanReq->SetSelect >= NIC_Count)
  1720. // {
  1721. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  1722. // return sizeof(GetLanCCRev_T);
  1723. // }
  1724. // NCSIConfig_T configData;
  1725. // char interfaceName[8];
  1726. // memset(&configData, 0, sizeof(NCSIConfig_T));
  1727. // memset(interfaceName, 0, sizeof(interfaceName));
  1728. // snprintf(interfaceName, sizeof(interfaceName), "%s%d", "eth", pGetLanReq->SetSelect);
  1729. // if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
  1730. // {
  1731. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  1732. // return sizeof(GetLanCCRev_T);
  1733. // }
  1734. // if (configData.PackageId >= 0xFF || configData.ChannelId >= 0xFF)
  1735. // {
  1736. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  1737. // return sizeof(GetLanCCRev_T);
  1738. // }
  1739. // pGetLanRes->ConfigData.NCSIPortConfig.Interface = pGetLanReq->SetSelect;
  1740. // pGetLanRes->ConfigData.NCSIPortConfig.PackageId = configData.PackageId;
  1741. // pGetLanRes->ConfigData.NCSIPortConfig.ChannelId = configData.ChannelId;
  1742. // return sizeof(GetLanCCRev_T) + sizeof(NCSIPortConfig_T);
  1743. // }
  1744. // break;
  1745. // case LAN_PARAMS_AMI_OEM_NCSI_MODE_CHANGE:
  1746. // {
  1747. // NIC_Count=g_coremacros.global_nic_count;
  1748. // if (pGetLanReq->SetSelect >= NIC_Count)
  1749. // {
  1750. // printf("---> log5, SetSelect = %d, NIC_Count = %d\n",pGetLanReq->SetSelect, NIC_Count);
  1751. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  1752. // return sizeof(GetLanCCRev_T);
  1753. // }
  1754. // NCSIConfig_T configData;
  1755. // char interfaceName[8];
  1756. // memset(&configData, 0, sizeof(NCSIConfig_T));
  1757. // memset(interfaceName, 0, sizeof(interfaceName));
  1758. // snprintf(interfaceName, sizeof(interfaceName), "%s%d", "eth", pGetLanReq->SetSelect);
  1759. // if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
  1760. // {
  1761. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  1762. // return sizeof(GetLanCCRev_T);
  1763. // }
  1764. // if (configData.AutoSelect>= 0xFF)
  1765. // {
  1766. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  1767. // return sizeof(GetLanCCRev_T);
  1768. // }
  1769. // pGetLanRes->ConfigData.NCSIModeConfig.Interface = pGetLanReq->SetSelect;
  1770. // pGetLanRes->ConfigData.NCSIModeConfig.NCSIMode = configData.AutoSelect;
  1771. // return sizeof(GetLanCCRev_T) + sizeof(NCSIModeConfig_T);
  1772. // }
  1773. // break;
  1774. // case LAN_PARAMS_AMI_OEM_NCSI_EXTENSION:
  1775. // {
  1776. // char ncsi_default_ifc[IFNAMSIZ + 1] = "eth1";
  1777. // if ((pGetLanReq->SetSelect == 0x20) &&
  1778. // (g_corefeatures.ncsi_keep_phy_linkup_support == ENABLED))
  1779. // {
  1780. // NIC_Count=g_coremacros.global_nic_count;
  1781. // NCSIConfig_T configData;
  1782. // char interfaceName[8];
  1783. // memset(&configData, 0, sizeof(NCSIConfig_T));
  1784. // memset(interfaceName, 0, sizeof(interfaceName));
  1785. // GetMacrodefine_string("CONFIG_SPX_FEATURE_NCSI_DEFAULT_INTERFACE", ncsi_default_ifc);
  1786. // snprintf(interfaceName, sizeof(interfaceName), "%s", ncsi_default_ifc);
  1787. // if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
  1788. // {
  1789. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  1790. // return sizeof(GetLanCCRev_T);
  1791. // }
  1792. // char Interface[2];
  1793. // snprintf(Interface, sizeof(Interface), "%c", interfaceName[3]);
  1794. // pGetLanRes->ConfigData.NCSIPHYConfigGet.Interface = atoi(Interface);
  1795. // pGetLanRes->ConfigData.NCSIPHYConfigGet.VetoBit = configData.VetoBit;
  1796. // return sizeof(GetLanCCRev_T) + sizeof(NCSIPHYConfigGet_T);
  1797. // }
  1798. // else
  1799. // {
  1800. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1801. // return sizeof(GetLanCCRev_T);
  1802. // }
  1803. // }
  1804. // break;
  1805. // default:
  1806. // TDBG("In Valid Option\n");
  1807. // }
  1808. // }
  1809. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1810. // return sizeof(uint8_t);
  1811. // }
  1812. // }
  1813. // return sizeof(GetLanCCRev_T) + LanconfigParameterLength[pGetLanReq->ParameterSelect];
  1814. // }
  1815. // /*---------------------------------------------------
  1816. // * SuspendBMCArps
  1817. // *---------------------------------------------------*/
  1818. // int
  1819. // SuspendBMCArps ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1820. // {
  1821. // SuspendBMCArpsReq_T* pArpReq = ( SuspendBMCArpsReq_T*) pReq;
  1822. // SuspendBMCArpsRes_T* pArpRes = ( SuspendBMCArpsRes_T*) pRes;
  1823. // uint8_t EthIndex;
  1824. // /* Verify Channel ID */
  1825. // pArpRes->CompletionCode = CC_INV_DATA_FIELD;
  1826. // if(pArpReq->ChannelNo & RESERVED_BITS_SUSPENDBMCARPS) return sizeof(*pRes);
  1827. // if (!IsLANChannel(pArpReq->ChannelNo & CHANNEL_ID_MASK, BMCInst) )
  1828. // {
  1829. // return sizeof (*pRes);
  1830. // }
  1831. // EthIndex= GetEthIndex(pArpReq->ChannelNo & 0x0F,BMCInst);
  1832. // if(0xff == EthIndex)
  1833. // {
  1834. // return sizeof (*pRes);
  1835. // }
  1836. // /* Reserved Bits Validation */
  1837. // if (0 != (SUSPEND_ARP_RSVD_BIT_MASK & pArpReq->ArpSuspend))
  1838. // {
  1839. // return sizeof (*pRes);
  1840. // }
  1841. // if (BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning == TRUE)
  1842. // BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex] = pArpReq->ArpSuspend;
  1843. // /* Update Response */
  1844. // pArpRes->CompletionCode = CC_NORMAL;
  1845. // pArpRes->ArpSuspendStatus = UpdateArpStatus(EthIndex, BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning, BMCInst);
  1846. // return sizeof (SuspendBMCArpsRes_T);
  1847. // }
  1848. // /*---------------------------------------------------
  1849. // * GetIPUDPRMCPStats
  1850. // *---------------------------------------------------*/
  1851. // int
  1852. // GetIPUDPRMCPStats ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1853. // {
  1854. // GetIPUDPRMCPStatsReq_T* pGetIPUDPRMCPStatsReq = ( GetIPUDPRMCPStatsReq_T*) pReq;
  1855. // GetIPUDPRMCPStatsRes_T* pGetIPUDPRMCPStatsRes = ( GetIPUDPRMCPStatsRes_T*) pRes;
  1856. // BMCSharedMem_T* pSharedMem = BMC_GET_SHARED_MEM (BMCInst);
  1857. // FILE *fptr;
  1858. // char FDRead[512], FSRead[512];
  1859. // char *result = NULL;
  1860. // char **StrArray;
  1861. // int count = 0;
  1862. // int cStrings =0;
  1863. // if(pGetIPUDPRMCPStatsReq->ChannelNo & RESERVED_BITS_GETIPUDPRMCPSTATS_CH)
  1864. // {
  1865. // *pRes = CC_INV_DATA_FIELD;
  1866. // return sizeof(*pRes);
  1867. // }
  1868. // if(pGetIPUDPRMCPStatsReq->ClearStatus & RESERVED_BITS_GETIPUDPRMCPSTATS_CLRSTATE)
  1869. // {
  1870. // *pRes = CC_INV_DATA_FIELD;
  1871. // return sizeof(*pRes);
  1872. // }
  1873. // //Channel number [3:0] is valid.
  1874. // if ( !IsLANChannel(pGetIPUDPRMCPStatsReq->ChannelNo & CHANNEL_ID_MASK, BMCInst) )
  1875. // {
  1876. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_INV_DATA_FIELD;
  1877. // return sizeof (*pRes);
  1878. // }
  1879. // //Clear the statistics if 1 is given in request.
  1880. // if ( pGetIPUDPRMCPStatsReq->ClearStatus & 0x01 )
  1881. // {
  1882. // /* <TBD BalaT>
  1883. // * Have to clear the already stored statistics when clear req is 1.
  1884. // */
  1885. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
  1886. // return sizeof (uint8_t);
  1887. // }
  1888. // //All Statistics values are initialised to 0.
  1889. // memset (pGetIPUDPRMCPStatsRes, 0, sizeof(GetIPUDPRMCPStatsRes_T) );
  1890. // //All the datas are taken from /proc/net/snmp file
  1891. // fptr = fopen ("/proc/net/snmp","r+");
  1892. // if (fptr == NULL)
  1893. // {
  1894. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_COULD_NOT_PROVIDE_RESP;
  1895. // return sizeof (uint8_t);
  1896. // }
  1897. // while( NULL != fgets(FDRead,512,fptr) )
  1898. // {
  1899. // if ( NULL != strstr (FDRead, "Ip: ") )
  1900. // {
  1901. // count++;
  1902. // if (count == 2)
  1903. // {
  1904. // //To find the no. of valid strings in a line.
  1905. // strcpy (FSRead, FDRead);
  1906. // result = strtok( FSRead, " " );
  1907. // while( result != NULL )
  1908. // {
  1909. // cStrings++;
  1910. // result = strtok( NULL, " " );
  1911. // }
  1912. // //Condition to check so that explode doesnt try to read the strings from unknown location.
  1913. // if ( cStrings == 20)
  1914. // {
  1915. // StrArray = explode (' ', FDRead);
  1916. // }
  1917. // else
  1918. // {
  1919. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
  1920. // return sizeof (uint8_t);
  1921. // }
  1922. // //All Statistics stops acumulating at FFFFh unless otherwise noted.
  1923. // //IP packets received.
  1924. // if ( atol((char *)StrArray[3]) > 0xffff)
  1925. // pGetIPUDPRMCPStatsRes->IPPacketsRecv = ( ( atol((char *)StrArray[3]) ) % 65535);
  1926. // else
  1927. // pGetIPUDPRMCPStatsRes->IPPacketsRecv = atoi((char *)StrArray[3]);
  1928. // //IP Header Error.
  1929. // pGetIPUDPRMCPStatsRes->IPHeaderErr = atoi((char *)StrArray[4]);
  1930. // //IP Address Error.
  1931. // if ( atol((char *)StrArray[5]) > 0xffff)
  1932. // pGetIPUDPRMCPStatsRes->IPAddrErr = ( ( atol((char *)StrArray[5]) ) % 65535);
  1933. // else
  1934. // pGetIPUDPRMCPStatsRes->IPAddrErr = atoi((char *)StrArray[5]);
  1935. // //Fragmented IP Packets received.
  1936. // if ( atol((char *)StrArray[17]) > 0xffff)
  1937. // pGetIPUDPRMCPStatsRes->FragIPPacketsRecv = ( ( atol((char *)StrArray[17]) ) % 65535);
  1938. // else
  1939. // pGetIPUDPRMCPStatsRes->FragIPPacketsRecv = atoi((char *)StrArray[17]);
  1940. // //IP packets Transmitted.
  1941. // if ( atol((char *)StrArray[10]) > 0xffff)
  1942. // pGetIPUDPRMCPStatsRes->IPPacketsTrans = ( ( atol((char *)StrArray[10]) ) % 65535);
  1943. // else
  1944. // pGetIPUDPRMCPStatsRes->IPPacketsTrans = atoi((char *)StrArray[10]);
  1945. // count = 0;
  1946. // }
  1947. // }
  1948. // if ( NULL != strstr (FDRead, "Udp: ") )
  1949. // {
  1950. // count++;
  1951. // if (count == 2)
  1952. // {
  1953. // //To find the no. of valid strings in a line.
  1954. // cStrings = 0;
  1955. // strcpy (FSRead, FDRead);
  1956. // result = strtok( FSRead, " " );
  1957. // while( result != NULL )
  1958. // {
  1959. // cStrings++;
  1960. // result = strtok( NULL, " " );
  1961. // }
  1962. // //Condition to check so that explode doesnt try to read the strings beyond the valid location.
  1963. // if ( cStrings == 5)
  1964. // {
  1965. // StrArray = explode (' ', FDRead);
  1966. // }
  1967. // else
  1968. // {
  1969. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
  1970. // return sizeof (uint8_t);
  1971. // }
  1972. // //UDP packets received.
  1973. // if ( atol((char *)StrArray[1]) > 0xffff)
  1974. // pGetIPUDPRMCPStatsRes->UDPPacketsRecv = ( ( atol((char *)StrArray[1]) ) % 65535);
  1975. // else
  1976. // pGetIPUDPRMCPStatsRes->UDPPacketsRecv = atoi((char *)StrArray[1]);
  1977. // count = 0;
  1978. // }
  1979. // }
  1980. // }
  1981. // fclose(fptr);
  1982. // //Valid RMCP packets received.
  1983. // pGetIPUDPRMCPStatsRes->ValidRMCPPackets = pSharedMem->gIPUDPRMCPStats;
  1984. // //<TBD BalaT>To store the statistics across the system reset and power cycles
  1985. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
  1986. // return sizeof (GetIPUDPRMCPStatsRes_T);
  1987. // }
  1988. // /*-----------------------------------------------------
  1989. // * explode
  1990. // * Funntion to split the strings and store in an array
  1991. // *-----------------------------------------------------*/
  1992. // char **explode(char separator, char *string)
  1993. // {
  1994. // int start = 0, i, k = 1, count = 2;
  1995. // char **strarr;
  1996. // for (i = 0; string[i] != '\0'; i++)
  1997. // /* how many rows do we need for our array? */
  1998. // if (string[i] == separator)
  1999. // count++;
  2000. // /* count is at least 2 to make room for the entire string
  2001. // * * and the ending NULL */
  2002. // strarr = malloc(count * sizeof(char*));
  2003. // i = 0;
  2004. // while (*string++ != '\0')
  2005. // {
  2006. // if (*string == separator)
  2007. // {
  2008. // strarr[i] = malloc(k - start + 2);
  2009. // strncpy(strarr[i], string - k + start, k - start + 1);
  2010. // strarr[i][k - start + 1] = '\0'; /* guarantee null termination */
  2011. // start = k;
  2012. // i++;
  2013. // }
  2014. // k++;
  2015. // }
  2016. // /* copy the last part of the string after the last separator */
  2017. // strarr[i] = malloc(k - start);
  2018. // strncpy(strarr[i], string - k + start, k - start - 1);
  2019. // strarr[i][k - start - 1] = '\0'; /* guarantee null termination */
  2020. // strarr[++i] = NULL;
  2021. // return strarr;
  2022. // }
  2023. // /*----------------------------------------------
  2024. // * UpdateArpStatus
  2025. // *----------------------------------------------*/
  2026. // uint8_t
  2027. // UpdateArpStatus (uint8_t EthIndex,BOOL IsTimerRunning, int BMCInst)
  2028. // {
  2029. // uint8_t GratArpSuspend;
  2030. // uint8_t ArpSuspend;
  2031. // uint8_t Status;
  2032. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  2033. // char Cmds[50]={0}; // command string to perform BMC-generated ARP
  2034. // char IfcName[16];
  2035. // IPMI_DBG_PRINT_1 ("Timer - %x", IsTimerRunning);
  2036. // GratArpSuspend = ArpSuspend = 1;
  2037. // // Check Gratuitous ARP is Enabled
  2038. // if (0 == (pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl & GRATIUTOUS_ENABLE_MASK))
  2039. // {
  2040. // GratArpSuspend = 0;
  2041. // }
  2042. // // Check ARP Response is Enabled
  2043. // if (0 == (pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl & ENABLE_ARP_RESPONSES))
  2044. // {
  2045. // ArpSuspend = 0;
  2046. // }
  2047. // /*Disable ARP */
  2048. // if (TRUE == IsTimerRunning)
  2049. // {
  2050. // /* WDT is running, check and suspend ARP if necessary */
  2051. // if( (0 != (BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex] & SUSPEND_GRAT_ARP)) &&
  2052. // (0 < GratArpSuspend) )
  2053. // {
  2054. // GratArpSuspend--;
  2055. // }
  2056. // if( (0 != (BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex] & SUSPEND_ARP)) &&
  2057. // (0 < ArpSuspend) )
  2058. // {
  2059. // ArpSuspend--;
  2060. // }
  2061. // }
  2062. // memset(IfcName,0,sizeof(IfcName));
  2063. // if(GetIfcName(EthIndex, IfcName, BMCInst) != 0)
  2064. // {
  2065. // TCRIT("Error in getting Interface Name for the Lan Index :%d\n", EthIndex);
  2066. // }
  2067. // else
  2068. // {
  2069. // /* Perform commands for BMC-generated Arp */
  2070. // memset(Cmds, 0, sizeof(Cmds));
  2071. // sprintf(Cmds, "/usr/local/bin/ArpSwitch.sh %s %d", IfcName, (!ArpSuspend) ? ARP_IGNORE_ON : ARP_IGNORE_OFF);
  2072. // safe_system (Cmds);
  2073. // /* Perform commands for BMC-generated Arp ends */
  2074. // }
  2075. // /* Update Status */
  2076. // Status = ArpSuspend << 1;
  2077. // Status = Status | GratArpSuspend;
  2078. // return Status;
  2079. // }
  2080. // /**
  2081. // *@fn NwInterfacePresenceCheck
  2082. // *@brief This function is invoked to check network interface presence
  2083. // *@param Interface - Char Pointer to Interface for which interface to check
  2084. // *@return Returns 0 on success
  2085. // */
  2086. // static int
  2087. // NwInterfacePresenceCheck (char * Interface)
  2088. // {
  2089. // int r;
  2090. // int sockdes;
  2091. // struct ifreq Ifreq;
  2092. // unsigned char MAC[MAC_ADDR_LEN];
  2093. // IPMI_DBG_PRINT_1 ("Checking the presence of %s\n", Interface);
  2094. // sockdes = socket(PF_INET, SOCK_DGRAM, 0 );
  2095. // if ( sockdes < 0 )
  2096. // {
  2097. // IPMI_ERROR("can't open socket: %s\n",strerror(errno));
  2098. // return -1;
  2099. // }
  2100. // /* Get MAC address */
  2101. // memset(&Ifreq,0,sizeof(struct ifreq));
  2102. // memset(MAC, 0, MAC_ADDR_LEN);
  2103. // strcpy(Ifreq.ifr_name, Interface);
  2104. // Ifreq.ifr_hwaddr.sa_family = AF_INET;
  2105. // r = ioctl(sockdes, SIOCGIFHWADDR, &Ifreq);
  2106. // close (sockdes);
  2107. // if ( r < 0 )
  2108. // {
  2109. // //IPMI_ERROR("IOCTL to get MAC failed: %d\n",r);
  2110. // return -1;
  2111. // }
  2112. // IPMI_DBG_PRINT_1 (" %s Interface is present\n", Interface);
  2113. // return 0;
  2114. // }