LANConfig.c 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946
  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)+2;
  320. m_MsgPkt.Data[0] = 0;//eth0
  321. m_MsgPkt.Data[1] = 0;//掉电不保存
  322. memcpy(&m_MsgPkt.Data[2], pSetLanReq, sizeof(SetLanConfigReq_T));
  323. PostMsg(gPendActionIfc, &m_MsgPkt);
  324. //Update
  325. memcpy(g_BMCInfo.IpmiConfig.LanInfo[index].IPAddr, pSetLanReq->ConfigData.IPAddr, 4);
  326. FlushIpmiConfig();
  327. printf("---> old_ip: %s, new_ip: %s\n", old_ip, ipStr);
  328. printf("---> send data: %#x %#x %#x %#x %#x\n", m_MsgPkt.Data[0], m_MsgPkt.Data[1]
  329. , m_MsgPkt.Data[2], m_MsgPkt.Data[3], m_MsgPkt.Data[4]);
  330. break;
  331. case LAN_PARAM_IP_ADDRESS_SOURCE:
  332. printf("---> Not implement!\n");
  333. break;
  334. case LAN_PARAM_MAC_ADDRESS:
  335. /* According to IPMI 2.0 Specification Revision 3, the MAC address can be read only parameter*/
  336. //*pRes = CC_ATTEMPT_TO_SET_RO_PARAM;
  337. //return sizeof (*pRes);
  338. if((pSetLanReq->ConfigData.MACAddr[0]& BIT0)|| (memcmp(&InvalidMac,&pSetLanReq->ConfigData.MACAddr,MAC_ADDR_LEN) == 0))
  339. {
  340. pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
  341. return 1;
  342. }
  343. getmac(old_mac);
  344. sprintf(macStr, "%02x:%02x:%02x:%02x:%02x:%02x", pSetLanReq->ConfigData.MACAddr[0],
  345. pSetLanReq->ConfigData.MACAddr[1], pSetLanReq->ConfigData.MACAddr[2],
  346. pSetLanReq->ConfigData.MACAddr[3], pSetLanReq->ConfigData.MACAddr[4],
  347. pSetLanReq->ConfigData.MACAddr[5]);
  348. if(strcmp(macStr, old_mac) == 0)
  349. {
  350. printf("The same mac %s, do nothing\n", macStr );
  351. *pRes = CC_NORMAL;
  352. return 1;
  353. }
  354. if (!enableSetMACAddr)
  355. pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  356. else
  357. {
  358. m_MsgPkt.Param = PARAM_LAN;
  359. m_MsgPkt.NetFnLUN = NETFNLUN_IPMI_TRANSPORT;
  360. m_MsgPkt.Cmd = CMD_SET_LAN_CONFIGURATION_PARAMETERS;
  361. m_MsgPkt.Size = sizeof(SetLanConfigReq_T)+2;
  362. m_MsgPkt.Data[0] = 0;//eth0
  363. m_MsgPkt.Data[1] = 0;//掉电不保存
  364. memcpy(&m_MsgPkt.Data[2], pSetLanReq, sizeof(SetLanConfigReq_T));
  365. PostMsg(gPendActionIfc, &m_MsgPkt);
  366. //Update
  367. memcpy(g_BMCInfo.IpmiConfig.LanInfo[index].MACAddr, pSetLanReq->ConfigData.MACAddr, 6);
  368. printf("---> old_mac: %s, new_mac: %s\n", old_mac, macStr);
  369. pSetLanRes->CompletionCode = CC_NORMAL;
  370. }
  371. break;
  372. case LAN_PARAM_SUBNET_MASK:
  373. getnetmask(old_netmask);
  374. sprintf(netmaskStr, "%d.%d.%d.%d", pSetLanReq->ConfigData.SubNetMask[0],
  375. pSetLanReq->ConfigData.SubNetMask[1], pSetLanReq->ConfigData.SubNetMask[2],
  376. pSetLanReq->ConfigData.SubNetMask[3]);
  377. if(strcmp(netmaskStr, old_netmask) == 0)
  378. {
  379. printf("The same netmask %s, do nothing\n", netmaskStr );
  380. *pRes = CC_NORMAL;
  381. return 1;
  382. }
  383. if(IPAddrCheck(pSetLanReq->ConfigData.SubNetMask,LAN_PARAM_SUBNET_MASK))
  384. {
  385. *pRes = CC_INV_DATA_FIELD;
  386. return sizeof (uint8_t);
  387. }
  388. m_MsgPkt.Param = PARAM_LAN;
  389. m_MsgPkt.NetFnLUN = NETFNLUN_IPMI_TRANSPORT;
  390. m_MsgPkt.Cmd = CMD_SET_LAN_CONFIGURATION_PARAMETERS;
  391. m_MsgPkt.Size = sizeof(SetLanConfigReq_T)+2;
  392. m_MsgPkt.Data[0] = 0;//eth0
  393. m_MsgPkt.Data[1] = 0;//掉电不保存
  394. memcpy(&m_MsgPkt.Data[2], pSetLanReq, sizeof(SetLanConfigReq_T));
  395. PostMsg(gPendActionIfc, &m_MsgPkt);
  396. //Update
  397. memcpy(g_BMCInfo.IpmiConfig.LanInfo[index].NetMask, pSetLanReq->ConfigData.SubNetMask, 4);
  398. pSetLanRes->CompletionCode = CC_NORMAL;
  399. break;
  400. case LAN_PARAM_IPv4_HEADER:
  401. printf("Not implement\n");
  402. break;
  403. case LAN_PARAM_PRI_RMCP_PORT:
  404. printf("Not implement\n"); //需要重启网络线程
  405. break;
  406. case LAN_PARAM_SEC_RMCP_PORT:
  407. /* Returning Invalid error message */
  408. *pRes = CC_PARAM_NOT_SUPPORTED;
  409. return sizeof (uint8_t);
  410. /*pPMConfig->LANConfig[EthIndex].SecondaryPort = ipmitoh_u16 (pSetLanReq->ConfigData.SecondaryPort);*/
  411. break;
  412. case LAN_PARAM_BMC_GENERATED_ARP_CONTROL:
  413. printf("Not implement\n");
  414. break;
  415. case LAN_PARAM_GRATITIOUS_ARP_INTERVAL:
  416. printf("Not implement\n");
  417. break;
  418. case LAN_PARAM_DEFAULT_GATEWAY_IP:
  419. if(IPAddrCheck(pSetLanReq->ConfigData.DefaultGatewayIPAddr,LAN_PARAM_DEFAULT_GATEWAY_IP))
  420. {
  421. *pRes = CC_INV_DATA_FIELD;
  422. return sizeof (uint8_t);
  423. }
  424. m_MsgPkt.Param = PARAM_LAN;
  425. m_MsgPkt.NetFnLUN = NETFNLUN_IPMI_TRANSPORT;
  426. m_MsgPkt.Cmd = CMD_SET_LAN_CONFIGURATION_PARAMETERS;
  427. m_MsgPkt.Size = sizeof(SetLanConfigReq_T)+2;
  428. m_MsgPkt.Data[0] = 0;//eth0
  429. m_MsgPkt.Data[1] = 0;//掉电不保存
  430. memcpy(&m_MsgPkt.Data[2], pSetLanReq, sizeof(SetLanConfigReq_T));
  431. PostMsg(gPendActionIfc, &m_MsgPkt);
  432. //Update
  433. memcpy(g_BMCInfo.IpmiConfig.LanInfo[index].DefaultGW, pSetLanReq->ConfigData.DefaultGatewayIPAddr, 4);
  434. pSetLanRes->CompletionCode = CC_NORMAL;
  435. break;
  436. case LAN_PARAM_DEFAULT_GATEWAY_MAC:
  437. pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  438. return sizeof(*pRes);
  439. break;
  440. case LAN_PARAM_BACKUP_GATEWAY_IP:
  441. printf("Not implement\n");
  442. break;
  443. case LAN_PARAM_BACKUP_GATEWAY_MAC:
  444. printf("Not implement\n");
  445. break;
  446. case LAN_PARAM_COMMUNITY_STRING:
  447. printf("Not implement\n");
  448. break;
  449. case LAN_PARAM_DEST_NUM:
  450. pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  451. return sizeof(uint8_t);
  452. case LAN_PARAM_SELECT_DEST_TYPE:
  453. printf("Not implement\n");
  454. break;
  455. case LAN_PARAM_SELECT_DEST_ADDR:
  456. printf("Not implement\n");
  457. break;
  458. case LAN_PARAM_VLAN_ID:
  459. printf("Not implement\n");
  460. break;
  461. case LAN_PARAM_VLAN_PRIORITY:
  462. printf("Not implement\n");
  463. break;
  464. case LAN_PARAM_CIPHER_SUITE_ENTRY_SUP:
  465. pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  466. return sizeof(uint8_t);
  467. case LAN_PARAM_CIPHER_SUITE_ENTRIES:
  468. pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  469. return sizeof(uint8_t);
  470. break;
  471. case LAN_PARAM_CIPHER_SUITE_PRIV_LEVELS:
  472. printf("Not implement\n");
  473. break;
  474. case LAN_PARAM_VLAN_TAGS:
  475. printf("Not implement\n");
  476. break;
  477. case LAN_PARAMS_BAD_PASSWORD_THRESHOLD:
  478. printf("Not implement\n");
  479. break;
  480. default:
  481. pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
  482. return sizeof(uint8_t);
  483. }
  484. pSetLanRes->CompletionCode = CC_NORMAL;
  485. FlushIpmiConfig();
  486. return sizeof(*pSetLanRes);
  487. }
  488. /*
  489. *@fn IPAddrCheck function
  490. *@brief It will validate the IP Address and net Mask
  491. *@param Addr - IP Address or net Mask
  492. *@param params - parameter data to validate
  493. */
  494. int IPAddrCheck(uint8_t *Addr,int params)
  495. {
  496. int i,maskcount=0,bitmask =0,j,bitcheck=0;
  497. for(i=0;i< IP_ADDR_LEN;i++)
  498. {
  499. if(Addr[i] == BRD_CAST_BIT_MASK)
  500. {
  501. maskcount++;
  502. }
  503. }
  504. if(maskcount == IP_ADDR_LEN)
  505. {
  506. return 1;
  507. }
  508. if(params == LAN_PARAM_SUBNET_MASK)
  509. {
  510. if(Addr[0] == BRD_CAST_BIT_MASK)
  511. {
  512. for(i=1;i< IP_ADDR_LEN;i++)
  513. {
  514. if(Addr[i-1] == 0)
  515. {
  516. bitmask = 1;
  517. }
  518. if(Addr[i] != 0)
  519. {
  520. for(j=0;j<8;j++)
  521. {
  522. if((Addr[i]<<j) & SUBNET_MASK_BIT_CHECK)
  523. {
  524. if(bitcheck == 1)
  525. {
  526. return 1;
  527. }
  528. continue;
  529. }
  530. bitcheck=1;
  531. }
  532. if((bitcheck == 1 && Addr[i-1] != BRD_CAST_BIT_MASK) || (Addr[i] > 0 && bitmask == 1))
  533. {
  534. return 1;
  535. }
  536. }
  537. }
  538. return 0;
  539. }
  540. return 1;
  541. }
  542. if(Addr[0] == LOOP_BACK_BIT_MASK || Addr[0] == BRD_CAST_BIT_MASK)
  543. {
  544. return 1;
  545. }
  546. return 0;
  547. }
  548. // /*----------------------------------------------
  549. // * GratuitousARPTask
  550. // *----------------------------------------------*/
  551. // void* GratuitousARPTask (uint8_t *Addr)
  552. // {
  553. // uint8_t IntervalInSec;
  554. // uint8_t Status;
  555. // int nRet;
  556. // NWCFG_STRUCT NWConfig;
  557. // NWCFG6_STRUCT NWConfig6;
  558. // uint8_t EthIndex,netindex= 0xFF;
  559. // int BMCInst,i;
  560. // char IfcName[16];
  561. // BMCArg *GratArpArgs = (BMCArg *)Addr;
  562. // BMCInst = GratArpArgs->BMCInst;
  563. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  564. // prctl(PR_SET_NAME,__FUNCTION__,0,0,0);
  565. // memcpy(&EthIndex,GratArpArgs->Argument,GratArpArgs->Len);
  566. // memset(IfcName,0,sizeof(IfcName));
  567. // /*Get the EthIndex*/
  568. // if(GetIfcName(EthIndex,IfcName, BMCInst) == -1)
  569. // {
  570. // TCRIT("Error in Getting Ifcname\n");
  571. // return 0;
  572. // }
  573. // for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
  574. // {
  575. // if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
  576. // {
  577. // netindex= Ifcnametable[i].Index;
  578. // break;
  579. // }
  580. // }
  581. // if(netindex == 0xFF)
  582. // {
  583. // TCRIT("Error in gettting netindex\n");
  584. // return 0;
  585. // }
  586. // if(Addr != NULL)
  587. // {
  588. // free(GratArpArgs->Argument);
  589. // free(Addr);
  590. // }
  591. // TDBG ("Gratuitous ARP thread starts for ethindex : %x\n",EthIndex);
  592. // while (1)
  593. // {
  594. // /*Is Gratiutous Arp Enabled */
  595. // if (0 == (pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl & GRATIUTOUS_ENABLE_MASK))
  596. // {
  597. // TDBG("Gratuitous ARP thread exits : Disable BMC-generated Gratuitous ARPs invoked\n");
  598. // break;
  599. // }
  600. // /*Is Gratiutous Arp Suspended */
  601. // Status = BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex];
  602. // if ((0 != (Status & GRATIUTOUS_ENABLE_MASK)) &&
  603. // (BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning == TRUE))
  604. // {
  605. // // Gratuitous ARP Suspended.
  606. // // sleep requested to access Shared memory for two different threads.
  607. // usleep (20);
  608. // continue;
  609. // }
  610. // nwReadNWCfg_v4_v6( &NWConfig,&NWConfig6, netindex,g_corefeatures.global_ipv6);
  611. // if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
  612. // {
  613. // TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
  614. // }
  615. // if (NWConfig.IFName[0] == 0)
  616. // sprintf((char *)&NWConfig.IFName, "%s",IfcName);
  617. // TDBG ( "MAC is %2x:%2x:%2x:%2x:%2x:%2x \n", NWConfig.MAC [0], NWConfig.MAC [1],
  618. // NWConfig.MAC [2], NWConfig.MAC [3], NWConfig.MAC [4], NWConfig.MAC [5] );
  619. // TDBG ( "IP is %d.%d.%d.%d\n", NWConfig.IPAddr[0], NWConfig.IPAddr[1],
  620. // NWConfig.IPAddr[2], NWConfig.IPAddr[3]);
  621. // TDBG ( "Device Name : %s\n", (char *)&NWConfig.IFName);
  622. // nRet = SendGratuitousARPPacket((char *)&NWConfig.IFName, NWConfig.IPAddr, NWConfig.MAC);
  623. // if (0 != nRet)
  624. // {
  625. // TCRIT("Gratuitous ARP thread exits : Unable to Send Gratuitous ARP packet\n");
  626. // break;
  627. // }
  628. // TDBG ("Send Gratuitous Packet\n");
  629. // if (0 == pBMCInfo->LANCfs[EthIndex].GratitousARPInterval)
  630. // {
  631. // IntervalInSec = 2; //Default 2 secs
  632. // } else {
  633. // // Gratuitous ARP interval in 500 millisecond increments.
  634. // IntervalInSec = (pBMCInfo->LANCfs[EthIndex].GratitousARPInterval * 500)/1000;
  635. // }
  636. // usleep( IntervalInSec * 1000 * 1000 );
  637. // }
  638. // return 0;
  639. // }
  640. // /*---------------------------------------------------
  641. // * GetLanConfigParam
  642. // *---------------------------------------------------*/
  643. // int
  644. // GetLanConfigParam ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  645. // {
  646. // GetLanConfigReq_T* pGetLanReq = ( GetLanConfigReq_T*) pReq;
  647. // GetLanConfigRes_T* pGetLanRes = ( GetLanConfigRes_T*) pRes;
  648. // BMCSharedMem_T* pSharedMem = BMC_GET_SHARED_MEM (BMCInst);
  649. // uint8_t IsOemDefined = FALSE;
  650. // NWCFG_STRUCT NWConfig;
  651. // NWCFG6_STRUCT NWConfig6;
  652. // // V6DNS_CONFIG v6dnsconfig;
  653. // uint8_t EthIndex,netindex= 0xFF,i;
  654. // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  655. // int ncsiPortConfigNum = 0;
  656. // ETHCFG_STRUCT PHYCfg;
  657. // ChannelInfo_T* pChannelInfo = NULL;
  658. // char IfcName[16]; /* Eth interface name */
  659. // uint8_t ComStrLen=MAX_COMM_STRING_SIZE;
  660. // int retValue = 0,NIC_Count = 0;
  661. // pGetLanRes->CCParamRev.CompletionCode = CC_NORMAL;
  662. // pGetLanRes->CCParamRev.ParamRevision = PARAMETER_REVISION_FORMAT;
  663. // // printf("---> channel: %d, parameter: %#x, setslect: %#x, blockselect: %#x\n", pGetLanReq->ChannelNum, pGetLanReq->ParameterSelect, pGetLanReq->SetSelect, pGetLanReq->BlockSelect);
  664. // if(pGetLanReq->ChannelNum & RESERVED_VALUE_70)
  665. // {
  666. // /* Alarm !!! Somebody is trying to set Reseved Bits */
  667. // *pRes = CC_INV_DATA_FIELD;
  668. // return sizeof (*pRes);
  669. // }
  670. // if((pGetLanReq->ParameterSelect >= MIN_LAN_OEM_CONF_PARAM) &&
  671. // (pGetLanReq->ParameterSelect <= MAX_LAN_OEM_CONF_PARAM) )
  672. // {
  673. // /* Converts OEM parameter value to equivalent AMI parameter value */
  674. // if (0 != GetLanAMIParamValue (&pGetLanReq->ParameterSelect, &IsOemDefined) )
  675. // {
  676. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  677. // return sizeof(uint8_t);
  678. // }
  679. // /* Hook for OEM to handle this parameter */
  680. // if ( (IsOemDefined) && (g_PDKHandle[PDK_GETLANOEMPARAM] != NULL) )
  681. // {
  682. // return ((int(*)(uint8_t *, uint8_t, uint8_t *,int))(g_PDKHandle[PDK_GETLANOEMPARAM]))(pReq, ReqLen, pRes, BMCInst);
  683. // }
  684. // }
  685. // if (g_PDKHandle[PDK_BEFOREGETLANPARM] != NULL)
  686. // {
  687. // retValue = ((int(*)(uint8_t *, uint8_t, uint8_t *,int))(g_PDKHandle[PDK_BEFOREGETLANPARM]))(pReq, ReqLen, pRes, BMCInst);
  688. // if(retValue != 0)
  689. // {
  690. // return retValue;
  691. // }
  692. // }
  693. // //! Validate the SetSelector value.
  694. // if ( (0x00 != pGetLanReq->SetSelect) &&
  695. // (pGetLanReq->ParameterSelect != LAN_PARAM_SELECT_DEST_TYPE) &&
  696. // (pGetLanReq->ParameterSelect != LAN_PARAM_SELECT_DEST_ADDR) &&
  697. // (pGetLanReq->ParameterSelect != LAN_PARAM_VLAN_TAGS) &&
  698. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR) &&
  699. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR) &&
  700. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_EUI64) &&
  701. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH))
  702. // {
  703. // printf("GetLanConfigParam log1\n");
  704. // if( g_corefeatures.ncsi_cmd_support == ENABLED )
  705. // {
  706. // if ((pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_NCSI_SETTINGS) &&
  707. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_NCSI_MODE_CHANGE) &&
  708. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_NCSI_EXTENSION))
  709. // {
  710. // *pRes = CC_INV_DATA_FIELD;
  711. // return sizeof (*pRes);
  712. // }
  713. // }
  714. // else
  715. // {
  716. // *pRes = CC_INV_DATA_FIELD;
  717. // return sizeof (*pRes);
  718. // }
  719. // }
  720. // //! Validate the BlockSelector value.
  721. // if (0x00 != pGetLanReq->BlockSelect)
  722. // {
  723. // printf("GetLanConfigParam log2\n");
  724. // *pRes = CC_INV_DATA_FIELD;
  725. // return sizeof (*pRes);
  726. // }
  727. // EthIndex= GetEthIndex(pGetLanReq->ChannelNum & 0x0F, BMCInst);
  728. // if(0xff == EthIndex)
  729. // {
  730. // printf("GetLanConfigParam log3\n");
  731. // *pRes = CC_INV_DATA_FIELD;
  732. // return sizeof (uint8_t);
  733. // }
  734. // /*Get the EthIndex*/
  735. // if(GetIfcName(EthIndex,IfcName, BMCInst) != 0)
  736. // {
  737. // TCRIT("Error in Getting IfcName\n");
  738. // *pRes = CC_INV_DATA_FIELD;
  739. // return sizeof (uint8_t);
  740. // }
  741. // for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
  742. // {
  743. // if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
  744. // {
  745. // netindex= Ifcnametable[i].Index;
  746. // break;
  747. // }
  748. // }
  749. // if(netindex == 0xFF)
  750. // {
  751. // TCRIT("Error in Getting netindex %d %s\n",netindex,IfcName);
  752. // *pRes = CC_INV_DATA_FIELD;
  753. // return sizeof (uint8_t);
  754. // }
  755. // if ((pGetLanReq->ChannelNum & GET_PARAMETER_REVISION_MASK) != 0)
  756. // {
  757. // if((MAX_LAN_CONF_PARAM >= pGetLanReq->ParameterSelect) ||
  758. // ((MIN_LAN_OEM_CONF_PARAM <= pGetLanReq->ParameterSelect) && (MAX_LAN_OEM_CONF_PARAM >= pGetLanReq->ParameterSelect)) )
  759. // {
  760. // return sizeof(GetLanCCRev_T);
  761. // }
  762. // else
  763. // {
  764. // *pRes = CC_PARAM_NOT_SUPPORTED;
  765. // return sizeof (*pRes);
  766. // }
  767. // }
  768. // else
  769. // {
  770. // printf("GetLanConfigParam log4\n");
  771. // switch(pGetLanReq->ParameterSelect)
  772. // {
  773. // case LAN_PARAM_SET_IN_PROGRESS:
  774. // LOCK_BMC_SHARED_MEM(BMCInst);
  775. // pGetLanRes->ConfigData.SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Lan_SetInProgress;
  776. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  777. // break;
  778. // case LAN_PARAM_AUTH_TYPE_SUPPORT:
  779. // pGetLanRes->ConfigData.AuthTypeSupport = pBMCInfo->LANCfs[EthIndex].AuthTypeSupport;
  780. // break;
  781. // case LAN_PARAM_AUTH_TYPE_ENABLES:
  782. // LOCK_BMC_SHARED_MEM(BMCInst);
  783. // _fmemcpy (&pGetLanRes->ConfigData.AuthTypeEnables,
  784. // &(pBMCInfo->LANCfs[EthIndex].AuthTypeEnables), sizeof(AuthTypeEnables_T));
  785. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  786. // break;
  787. // case LAN_PARAM_IP_ADDRESS:
  788. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPAddrSrc == STATIC_IP_SOURCE))
  789. // {
  790. // if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
  791. // {
  792. // _fmemcpy (NWConfig.IPAddr,pBMCInfo->LANCfs[EthIndex].IPAddr, IP_ADDR_LEN);
  793. // }
  794. // else
  795. // {
  796. // memset(&NWConfig, 0, sizeof(NWConfig));
  797. // }
  798. // }
  799. // else
  800. // {
  801. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  802. // }
  803. // _fmemcpy (pGetLanRes->ConfigData.IPAddr, NWConfig.IPAddr, IP_ADDR_LEN);
  804. // break;
  805. // case LAN_PARAM_IP_ADDRESS_SOURCE:
  806. // if(g_corefeatures.delayed_lan_restart_support)
  807. // {
  808. // if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
  809. // {
  810. // NWConfig.CfgMethod = pBMCInfo->LANCfs[EthIndex].IPAddrSrc;
  811. // }
  812. // else
  813. // {
  814. // memset(&NWConfig, 0, sizeof(NWConfig));
  815. // }
  816. // }
  817. // else
  818. // {
  819. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  820. // }
  821. // pGetLanRes->ConfigData.IPAddrSrc = NWConfig.CfgMethod;
  822. // break;
  823. // case LAN_PARAM_MAC_ADDRESS:
  824. // nwGetNWInformations(&NWConfig,IfcName);
  825. // _fmemcpy (pGetLanRes->ConfigData.MACAddr, NWConfig.MAC, MAC_ADDR_LEN);
  826. // break;
  827. // case LAN_PARAM_SUBNET_MASK:
  828. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPAddrSrc == STATIC_IP_SOURCE))
  829. // {
  830. // if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
  831. // {
  832. // _fmemcpy (NWConfig.Mask,pBMCInfo->LANCfs[EthIndex].SubNetMask, IP_ADDR_LEN);
  833. // }
  834. // else
  835. // {
  836. // memset(&NWConfig, 0, sizeof(NWConfig));
  837. // }
  838. // }
  839. // else
  840. // {
  841. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  842. // }
  843. // _fmemcpy (pGetLanRes->ConfigData.SubNetMask, NWConfig.Mask, IP_ADDR_LEN);
  844. // break;
  845. // case LAN_PARAM_IPv4_HEADER:
  846. // LOCK_BMC_SHARED_MEM(BMCInst);
  847. // _fmemcpy (&pGetLanRes->ConfigData.Ipv4HdrParam,
  848. // &(pBMCInfo->LANCfs[EthIndex].Ipv4HdrParam), sizeof(IPv4HdrParams_T));
  849. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  850. // break;
  851. // case LAN_PARAM_PRI_RMCP_PORT:
  852. // pGetLanRes->ConfigData.PrimaryRMCPPort = htoipmi_u16(pBMCInfo->LANCfs[EthIndex].PrimaryRMCPPort);
  853. // break;
  854. // case LAN_PARAM_SEC_RMCP_PORT:
  855. // /* Returning Invalid error message */
  856. // *pRes = CC_PARAM_NOT_SUPPORTED;
  857. // return sizeof (uint8_t);
  858. // /*pGetLanRes->ConfigData.SecondaryPort = htoipmi_u16(pPMConfig->LANConfig[EthIndex].SecondaryPort);*/
  859. // break;
  860. // case LAN_PARAM_BMC_GENERATED_ARP_CONTROL:
  861. // pGetLanRes->ConfigData.BMCGeneratedARPControl = pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl;
  862. // break;
  863. // case LAN_PARAM_GRATITIOUS_ARP_INTERVAL:
  864. // pGetLanRes->ConfigData.GratitousARPInterval =
  865. // pBMCInfo->LANCfs[EthIndex].GratitousARPInterval;
  866. // break;
  867. // case LAN_PARAM_DEFAULT_GATEWAY_IP:
  868. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPAddrSrc == STATIC_IP_SOURCE))
  869. // {
  870. // if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
  871. // {
  872. // _fmemcpy (NWConfig.Gateway, pBMCInfo->LANCfs[EthIndex].DefaultGatewayIPAddr, IP_ADDR_LEN);
  873. // }
  874. // else
  875. // {
  876. // memset(&NWConfig, 0, sizeof(NWConfig));
  877. // }
  878. // }
  879. // else
  880. // {
  881. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  882. // }
  883. // _fmemcpy (pGetLanRes->ConfigData.DefaultGatewayIPAddr, NWConfig.Gateway, IP_ADDR_LEN);
  884. // break;
  885. // case LAN_PARAM_DEFAULT_GATEWAY_MAC:
  886. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  887. // nwGetSrcMacAddr(&NWConfig.Gateway[0],netindex, &pGetLanRes->ConfigData.DefaultGatewayMACAddr[0]);
  888. // break;
  889. // case LAN_PARAM_BACKUP_GATEWAY_IP:
  890. // LOCK_BMC_SHARED_MEM(BMCInst);
  891. // nwGetBkupGWyAddr(pGetLanRes->ConfigData.BackupGatewayIPAddr,netindex);
  892. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  893. // break;
  894. // case LAN_PARAM_BACKUP_GATEWAY_MAC:
  895. // LOCK_BMC_SHARED_MEM(BMCInst);
  896. // _fmemcpy (pGetLanRes->ConfigData.BackupGatewayMACAddr,
  897. // pBMCInfo->LANCfs[EthIndex].BackupGatewayMACAddr, MAC_ADDR_LEN);
  898. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  899. // break;
  900. // case LAN_PARAM_COMMUNITY_STRING:
  901. // if (g_PDKHandle[PDK_GETSNMPCOMMUNITYNAME] != NULL )
  902. // {
  903. // if(((int(*)(uint8_t *, uint8_t *,int))(g_PDKHandle[PDK_GETSNMPCOMMUNITYNAME]))(pGetLanRes->ConfigData.CommunityStr,&ComStrLen, BMCInst)==0)
  904. // break;
  905. // }
  906. // LOCK_BMC_SHARED_MEM(BMCInst);
  907. // _fmemcpy (pGetLanRes->ConfigData.CommunityStr,
  908. // pBMCInfo->LANCfs[EthIndex].CommunityStr, MAX_COMM_STRING_SIZE);
  909. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  910. // break;
  911. // case LAN_PARAM_DEST_NUM:
  912. // pGetLanRes->ConfigData.NumDest = pBMCInfo->LANCfs[EthIndex].NumDest;
  913. // break;
  914. // case LAN_PARAM_SELECT_DEST_TYPE:
  915. // //if (pGetLanReq->SetSelect > NUM_LAN_DESTINATION)
  916. // if ( pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
  917. // {
  918. // *pRes = CC_PARAM_OUT_OF_RANGE ;
  919. // return sizeof (*pRes);
  920. // }
  921. // if (0 == pGetLanReq->SetSelect)
  922. // {
  923. // LOCK_BMC_SHARED_MEM(BMCInst);
  924. // _fmemcpy (&pGetLanRes->ConfigData.DestType,
  925. // &pSharedMem->VolLANDestType[EthIndex], sizeof(LANDestType_T));
  926. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  927. // }
  928. // else
  929. // {
  930. // LOCK_BMC_SHARED_MEM(BMCInst);
  931. // _fmemcpy (&pGetLanRes->ConfigData.DestType,
  932. // &(pBMCInfo->LANCfs[EthIndex].DestType[pGetLanReq->SetSelect - 1]),
  933. // sizeof(LANDestType_T));
  934. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  935. // }
  936. // break;
  937. // case LAN_PARAM_SELECT_DEST_ADDR:
  938. // //if (pGetLanReq->SetSelect > NUM_LAN_DESTINATION)
  939. // if ( pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
  940. // {
  941. // *pRes = CC_PARAM_OUT_OF_RANGE ;
  942. // return sizeof (*pRes);
  943. // }
  944. // if (0 == pGetLanReq->SetSelect)
  945. // {
  946. // LOCK_BMC_SHARED_MEM(BMCInst);
  947. // _fmemcpy (&pGetLanRes->ConfigData.DestAddr,
  948. // &pSharedMem->VolLANDest[EthIndex], sizeof(LANDestAddr_T));
  949. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  950. // }
  951. // else
  952. // {
  953. // LOCK_BMC_SHARED_MEM(BMCInst);
  954. // _fmemcpy (&pGetLanRes->ConfigData.DestAddr,
  955. // &(pBMCInfo->LANCfs[EthIndex].DestAddr[pGetLanReq->SetSelect - 1]),
  956. // sizeof(LANDestAddr_T));
  957. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  958. // }
  959. // break;
  960. // case LAN_PARAM_VLAN_ID:
  961. // if( pBMCInfo->IpmiConfig.VLANIfcSupport == 1)
  962. // {
  963. // pGetLanRes->ConfigData.VLANID = pBMCInfo->LANCfs[EthIndex].VLANID;
  964. // }
  965. // break;
  966. // case LAN_PARAM_VLAN_PRIORITY:
  967. // pGetLanRes->ConfigData.VLANPriority = pBMCInfo->LANCfs[EthIndex].VLANPriority;
  968. // break;
  969. // case LAN_PARAM_CIPHER_SUITE_ENTRY_SUP:
  970. // pGetLanRes->ConfigData.CipherSuiteSup = N0_OF_CIPHER_SUITE_SUPPORTED;
  971. // break;
  972. // case LAN_PARAM_CIPHER_SUITE_ENTRIES:
  973. // {
  974. // int i;
  975. // _fmemset (pGetLanRes->ConfigData.CipherSuiteEntries, 0,
  976. // sizeof (pGetLanRes->ConfigData.CipherSuiteEntries));
  977. // for (i = 0; i < (N0_OF_CIPHER_SUITE_SUPPORTED); i++)
  978. // {
  979. // pGetLanRes->ConfigData.CipherSuiteEntries[i+1] = g_CipherRec[1 + i * 5];
  980. // }
  981. // }
  982. // break;
  983. // case LAN_PARAM_CIPHER_SUITE_PRIV_LEVELS:
  984. // LOCK_BMC_SHARED_MEM(BMCInst);
  985. // _fmemcpy (pGetLanRes->ConfigData.CipherSuitePrivLevels,
  986. // pBMCInfo->LANCfs[EthIndex].CipherSuitePrivLevels,
  987. // MAX_NUM_CIPHER_SUITE_PRIV_LEVELS);
  988. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  989. // break;
  990. // case LAN_PARAM_VLAN_TAGS:
  991. // *(( uint8_t*)&pGetLanRes->ConfigData) = pGetLanReq->SetSelect;
  992. // if (pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest)
  993. // {
  994. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_OUT_OF_RANGE;
  995. // return sizeof (GetLanCCRev_T);
  996. // }
  997. // if (0 == pGetLanReq->SetSelect)
  998. // {
  999. // LOCK_BMC_SHARED_MEM(BMCInst);
  1000. // _fmemcpy ((( uint8_t*) &pGetLanRes->ConfigData) + 1,&pSharedMem->VLANDestTag, sizeof(VLANDestTags_T));
  1001. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1002. // }
  1003. // else
  1004. // {
  1005. // if (pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest)
  1006. // {
  1007. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_OUT_OF_RANGE;
  1008. // return sizeof(GetLanCCRev_T);
  1009. // }
  1010. // LOCK_BMC_SHARED_MEM(BMCInst);
  1011. // _fmemcpy ((( uint8_t*)&pGetLanRes->ConfigData) + 1,
  1012. // &pBMCInfo->LANCfs[EthIndex].VLANDestTags[pGetLanReq->SetSelect - 1],
  1013. // sizeof(VLANDestTags_T));
  1014. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1015. // }
  1016. // break;
  1017. // case LAN_PARAMS_BAD_PASSWORD_THRESHOLD:
  1018. // LOCK_BMC_SHARED_MEM(BMCInst);
  1019. // _fmemcpy(&pGetLanRes->ConfigData.BadPasswd,
  1020. // &pBMCInfo->LANCfs[EthIndex].BadPasswd,sizeof(BadPassword_T));
  1021. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1022. // break;
  1023. // case LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR:
  1024. // if ( pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
  1025. // {
  1026. // *pRes = CC_PARAM_OUT_OF_RANGE ;
  1027. // return sizeof (*pRes);
  1028. // }
  1029. // if (0 == pGetLanReq->SetSelect)
  1030. // {
  1031. // LOCK_BMC_SHARED_MEM(BMCInst);
  1032. // _fmemcpy (&pGetLanRes->ConfigData.Destv6Addr,
  1033. // &pSharedMem->VolLANv6Dest[EthIndex], sizeof(LANDestv6Addr_T));
  1034. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1035. // }
  1036. // else
  1037. // {
  1038. // LOCK_BMC_SHARED_MEM(BMCInst);
  1039. // _fmemcpy (&pGetLanRes->ConfigData.Destv6Addr,
  1040. // &(pBMCInfo->LANCfs[EthIndex].Destv6Addr[pGetLanReq->SetSelect - 1]),
  1041. // sizeof(LANDestv6Addr_T));
  1042. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1043. // }
  1044. // TDBG("\n GetLanconfig: Getting SNMPv6 configuration done..\n");
  1045. // return sizeof(GetLanConfigRes_T);
  1046. // break;
  1047. // case LAN_PARAMS_AMI_OEM_ENABLE_SET_MAC:
  1048. // pGetLanRes->ConfigData.ChangeMACEnabled = enableSetMACAddr;
  1049. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  1050. // case LAN_PARAMS_AMI_OEM_IPV6_ENABLE:
  1051. // if(g_corefeatures.delayed_lan_restart_support)
  1052. // {
  1053. // NWConfig6.enable = pBMCInfo->LANCfs[EthIndex].IPv6_Enable;
  1054. // }
  1055. // else
  1056. // {
  1057. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1058. // }
  1059. // pGetLanRes->ConfigData.IPv6_Enable = NWConfig6.enable;
  1060. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  1061. // break;
  1062. // case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE:
  1063. // if(g_corefeatures.delayed_lan_restart_support)
  1064. // {
  1065. // if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
  1066. // {
  1067. // NWConfig6.CfgMethod = pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc;
  1068. // }
  1069. // else
  1070. // {
  1071. // memset(&NWConfig6, 0, sizeof(NWConfig6));
  1072. // }
  1073. // }
  1074. // else
  1075. // {
  1076. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1077. // }
  1078. // pGetLanRes->ConfigData.IPv6_IPAddrSrc = NWConfig6.CfgMethod;
  1079. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  1080. // break;
  1081. // case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR:
  1082. // case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_EUI64:
  1083. // if(pGetLanReq->SetSelect & 0xF0)
  1084. // {
  1085. // *pRes = CC_INV_DATA_FIELD;
  1086. // return sizeof(uint8_t);
  1087. // }
  1088. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == STATIC_IP_SOURCE))
  1089. // {
  1090. // if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
  1091. // {
  1092. // _fmemcpy (NWConfig6.GlobalIPAddr,pBMCInfo->LANCfs[EthIndex].IPv6_IPAddr, IP6_ADDR_LEN*MAX_IPV6ADDRS);
  1093. // }
  1094. // else
  1095. // {
  1096. // memset(&NWConfig6, 0, sizeof(NWConfig6));
  1097. // }
  1098. // }
  1099. // else
  1100. // {
  1101. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1102. // }
  1103. // _fmemcpy (pGetLanRes->ConfigData.IPv6_LinkAddr, NWConfig6.GlobalIPAddr[(pGetLanReq->SetSelect & 0x0F)], IP6_ADDR_LEN);
  1104. // return sizeof(GetLanCCRev_T) + IP6_ADDR_LEN;
  1105. // break;
  1106. // case LAN_PARAMS_AMI_OEM_IPV6_LINK_ADDR:
  1107. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1108. // _fmemcpy (pGetLanRes->ConfigData.IPv6_LinkAddr, NWConfig6.LinkIPAddr, IP6_ADDR_LEN);
  1109. // return sizeof(GetLanCCRev_T) + IP6_ADDR_LEN;
  1110. // case LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH:
  1111. // if(pGetLanReq->SetSelect & 0xF0)
  1112. // {
  1113. // *pRes = CC_INV_DATA_FIELD;
  1114. // return sizeof(uint8_t);
  1115. // }
  1116. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == STATIC_IP_SOURCE))
  1117. // {
  1118. // if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
  1119. // {
  1120. // NWConfig6.GlobalPrefix[(pGetLanReq->SetSelect & 0x0F)] = pBMCInfo->LANCfs[EthIndex].IPv6_PrefixLen[(pGetLanReq->SetSelect & 0x0F)];
  1121. // }
  1122. // else
  1123. // {
  1124. // memset(&NWConfig6, 0, sizeof(NWConfig6));
  1125. // }
  1126. // }
  1127. // else
  1128. // {
  1129. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1130. // }
  1131. // pGetLanRes->ConfigData.IPv6_LinkAddrPrefix = NWConfig6.GlobalPrefix[(pGetLanReq->SetSelect & 0x0F)];
  1132. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  1133. // break;
  1134. // case LAN_PARAMS_AMI_OEM_IPV6_LINK_ADDR_PREFIX:
  1135. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1136. // pGetLanRes->ConfigData.IPv6_LinkAddrPrefix = NWConfig6.LinkPrefix;
  1137. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  1138. // break;
  1139. // case LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP:
  1140. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == STATIC_IP_SOURCE))
  1141. // {
  1142. // if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
  1143. // {
  1144. // _fmemcpy (NWConfig6.Gateway,pBMCInfo->LANCfs[EthIndex].IPv6_GatewayIPAddr, IP6_ADDR_LEN);
  1145. // }
  1146. // else
  1147. // {
  1148. // memset(&NWConfig6, 0, sizeof(NWConfig6));
  1149. // }
  1150. // }
  1151. // else
  1152. // {
  1153. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1154. // }
  1155. // _fmemcpy (pGetLanRes->ConfigData.IPv6_GatewayIPAddr, NWConfig6.Gateway, IP6_ADDR_LEN);
  1156. // return sizeof(GetLanCCRev_T) + IP6_ADDR_LEN;
  1157. // break;
  1158. // case LAN_PARAMS_AMI_OEM_PHY_SETTINGS:
  1159. // memset(IfcName, 0, sizeof(IfcName));
  1160. // if(GetIfcNameByIndex(EthIndex, IfcName) != 0)
  1161. // {
  1162. // TCRIT("Error in Getting Interface Name for the lan Index:%d\n",EthIndex);
  1163. // }
  1164. // if(nwGetEthInformation(&PHYCfg, IfcName) !=0)
  1165. // {
  1166. // pGetLanRes->CCParamRev.CompletionCode = CC_UNSPECIFIED_ERR;
  1167. // return sizeof(GetLanCCRev_T);
  1168. // }
  1169. // pGetLanRes->ConfigData.PHYConfig.Interface = EthIndex;
  1170. // pGetLanRes->ConfigData.PHYConfig.AutoNegotiationEnable = PHYCfg.autoneg;
  1171. // pGetLanRes->ConfigData.PHYConfig.Speed = PHYCfg.speed;
  1172. // pGetLanRes->ConfigData.PHYConfig.Duplex = PHYCfg.duplex;
  1173. // pGetLanRes->ConfigData.PHYConfig.CapabilitiesSupported = PHYCfg.supported;
  1174. // return sizeof(GetLanCCRev_T) + sizeof(PHYConfig_T);
  1175. // case LAN_PARAMS_AMI_OEM_MTU_SETTINGS:
  1176. // memset(IfcName,0,sizeof(IfcName));
  1177. // if(GetIfcNameByIndex(EthIndex, IfcName) != 0)
  1178. // {
  1179. // TCRIT("Error in Getting Interface Name for the lan Index:%d\n",EthIndex);
  1180. // pGetLanRes->CCParamRev.CompletionCode = CC_UNSPECIFIED_ERR;
  1181. // return sizeof(GetLanCCRev_T);
  1182. // }
  1183. // if(nwGetEthInformation(&PHYCfg, IfcName) !=0)
  1184. // {
  1185. // pGetLanRes->CCParamRev.CompletionCode = CC_UNSPECIFIED_ERR;
  1186. // return sizeof(GetLanCCRev_T);
  1187. // }
  1188. // pGetLanRes->ConfigData.MTU_size = PHYCfg.maxtxpkt;
  1189. // return sizeof(GetLanCCRev_T) + sizeof(uint16_t);
  1190. // case LAN_PARAMS_SSI_OEM_2ND_PRI_ETH_MAC_ADDR:
  1191. // if(g_corefeatures.ssi_support == ENABLED)
  1192. // {
  1193. // netindex = 0x1; /* Specify the 2nd interface */
  1194. // nwReadNWCfg_v4_v6(&NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1195. // _fmemcpy(pGetLanRes->ConfigData.SSI2ndPriEthMACAddr, NWConfig.MAC, MAC_ADDR_LEN);
  1196. // return sizeof(GetLanCCRev_T) + sizeof(pGetLanRes->ConfigData.SSI2ndPriEthMACAddr);
  1197. // }
  1198. // else
  1199. // {
  1200. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1201. // return sizeof(uint8_t);
  1202. // }
  1203. // break;
  1204. // case LAN_PARAMS_SSI_OEM_LINK_CTRL:
  1205. // if(g_corefeatures.ssi_support == ENABLED)
  1206. // {
  1207. // pGetLanRes->ConfigData.SSILinkControl = 0;
  1208. // pChannelInfo = getChannelInfo(pBMCInfo->RMCPLAN1Ch, BMCInst);
  1209. // if(NULL == pChannelInfo)
  1210. // {
  1211. // *pRes = CC_UNSPECIFIED_ERR;
  1212. // return sizeof (*pRes);
  1213. // }
  1214. // if (pChannelInfo->AccessMode == 0x02) /* If 1st channal is available */
  1215. // pGetLanRes->ConfigData.SSILinkControl |= BIT0;
  1216. // NIC_Count = g_coremacros.global_nic_count;
  1217. // if (NIC_Count == 2)
  1218. // {
  1219. // pChannelInfo = getChannelInfo(pBMCInfo->RMCPLAN2Ch, BMCInst);
  1220. // if(NULL == pChannelInfo)
  1221. // {
  1222. // *pRes = CC_UNSPECIFIED_ERR;
  1223. // return sizeof (*pRes);
  1224. // }
  1225. // if (pChannelInfo->AccessMode == 0x02) /* If 2nd channal is available */
  1226. // pGetLanRes->ConfigData.SSILinkControl |= BIT1;
  1227. // }
  1228. // return sizeof(GetLanCCRev_T) + sizeof(pGetLanRes->ConfigData.SSILinkControl);
  1229. // }
  1230. // else
  1231. // {
  1232. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1233. // return sizeof(uint8_t);
  1234. // }
  1235. // break;
  1236. // case LAN_PARAMS_SSI_OEM_CMM_IP_ADDR:
  1237. // if(g_corefeatures.ssi_support == ENABLED)
  1238. // {
  1239. // _fmemcpy (pGetLanRes->ConfigData.CMMIPAddr, pBMCInfo->SSIConfig.CMMIPAddr, IP_ADDR_LEN);
  1240. // return sizeof(GetLanCCRev_T) + sizeof(pGetLanRes->ConfigData.CMMIPAddr);
  1241. // }
  1242. // else
  1243. // {
  1244. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1245. // return sizeof(uint8_t);
  1246. // }
  1247. // break;
  1248. // default:
  1249. // if(g_corefeatures.ncsi_cmd_support == ENABLED)
  1250. // {
  1251. // switch(pGetLanReq->ParameterSelect)
  1252. // {
  1253. // case LAN_PARAMS_AMI_OEM_NCSI_CONFIG_NUM:
  1254. // NCSIGetTotalPorts(&ncsiPortConfigNum);
  1255. // if (ncsiPortConfigNum >= 0xFF)
  1256. // {
  1257. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  1258. // return sizeof(GetLanCCRev_T);
  1259. // }
  1260. // else
  1261. // {
  1262. // pGetLanRes->ConfigData.NumNCSIPortConfigs = ncsiPortConfigNum;
  1263. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  1264. // }
  1265. // break;
  1266. // case LAN_PARAMS_AMI_OEM_NCSI_SETTINGS:
  1267. // {
  1268. // NIC_Count=g_coremacros.global_nic_count;
  1269. // if (pGetLanReq->SetSelect >= NIC_Count)
  1270. // {
  1271. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  1272. // return sizeof(GetLanCCRev_T);
  1273. // }
  1274. // NCSIConfig_T configData;
  1275. // char interfaceName[8];
  1276. // memset(&configData, 0, sizeof(NCSIConfig_T));
  1277. // memset(interfaceName, 0, sizeof(interfaceName));
  1278. // snprintf(interfaceName, sizeof(interfaceName), "%s%d", "eth", pGetLanReq->SetSelect);
  1279. // if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
  1280. // {
  1281. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  1282. // return sizeof(GetLanCCRev_T);
  1283. // }
  1284. // if (configData.PackageId >= 0xFF || configData.ChannelId >= 0xFF)
  1285. // {
  1286. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  1287. // return sizeof(GetLanCCRev_T);
  1288. // }
  1289. // pGetLanRes->ConfigData.NCSIPortConfig.Interface = pGetLanReq->SetSelect;
  1290. // pGetLanRes->ConfigData.NCSIPortConfig.PackageId = configData.PackageId;
  1291. // pGetLanRes->ConfigData.NCSIPortConfig.ChannelId = configData.ChannelId;
  1292. // return sizeof(GetLanCCRev_T) + sizeof(NCSIPortConfig_T);
  1293. // }
  1294. // break;
  1295. // case LAN_PARAMS_AMI_OEM_NCSI_MODE_CHANGE:
  1296. // {
  1297. // NIC_Count=g_coremacros.global_nic_count;
  1298. // if (pGetLanReq->SetSelect >= NIC_Count)
  1299. // {
  1300. // printf("---> log5, SetSelect = %d, NIC_Count = %d\n",pGetLanReq->SetSelect, NIC_Count);
  1301. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  1302. // return sizeof(GetLanCCRev_T);
  1303. // }
  1304. // NCSIConfig_T configData;
  1305. // char interfaceName[8];
  1306. // memset(&configData, 0, sizeof(NCSIConfig_T));
  1307. // memset(interfaceName, 0, sizeof(interfaceName));
  1308. // snprintf(interfaceName, sizeof(interfaceName), "%s%d", "eth", pGetLanReq->SetSelect);
  1309. // if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
  1310. // {
  1311. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  1312. // return sizeof(GetLanCCRev_T);
  1313. // }
  1314. // if (configData.AutoSelect>= 0xFF)
  1315. // {
  1316. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  1317. // return sizeof(GetLanCCRev_T);
  1318. // }
  1319. // pGetLanRes->ConfigData.NCSIModeConfig.Interface = pGetLanReq->SetSelect;
  1320. // pGetLanRes->ConfigData.NCSIModeConfig.NCSIMode = configData.AutoSelect;
  1321. // return sizeof(GetLanCCRev_T) + sizeof(NCSIModeConfig_T);
  1322. // }
  1323. // break;
  1324. // case LAN_PARAMS_AMI_OEM_NCSI_EXTENSION:
  1325. // {
  1326. // char ncsi_default_ifc[IFNAMSIZ + 1] = "eth1";
  1327. // if ((pGetLanReq->SetSelect == 0x20) &&
  1328. // (g_corefeatures.ncsi_keep_phy_linkup_support == ENABLED))
  1329. // {
  1330. // NIC_Count=g_coremacros.global_nic_count;
  1331. // NCSIConfig_T configData;
  1332. // char interfaceName[8];
  1333. // memset(&configData, 0, sizeof(NCSIConfig_T));
  1334. // memset(interfaceName, 0, sizeof(interfaceName));
  1335. // GetMacrodefine_string("CONFIG_SPX_FEATURE_NCSI_DEFAULT_INTERFACE", ncsi_default_ifc);
  1336. // snprintf(interfaceName, sizeof(interfaceName), "%s", ncsi_default_ifc);
  1337. // if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
  1338. // {
  1339. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  1340. // return sizeof(GetLanCCRev_T);
  1341. // }
  1342. // char Interface[2];
  1343. // snprintf(Interface, sizeof(Interface), "%c", interfaceName[3]);
  1344. // pGetLanRes->ConfigData.NCSIPHYConfigGet.Interface = atoi(Interface);
  1345. // pGetLanRes->ConfigData.NCSIPHYConfigGet.VetoBit = configData.VetoBit;
  1346. // return sizeof(GetLanCCRev_T) + sizeof(NCSIPHYConfigGet_T);
  1347. // }
  1348. // else
  1349. // {
  1350. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1351. // return sizeof(GetLanCCRev_T);
  1352. // }
  1353. // }
  1354. // break;
  1355. // default:
  1356. // TDBG("In Valid Option\n");
  1357. // }
  1358. // }
  1359. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1360. // return sizeof(uint8_t);
  1361. // }
  1362. // }
  1363. // return sizeof(GetLanCCRev_T) + LanconfigParameterLength[pGetLanReq->ParameterSelect];
  1364. // }
  1365. // /*---------------------------------------------------
  1366. // * SuspendBMCArps
  1367. // *---------------------------------------------------*/
  1368. // int
  1369. // SuspendBMCArps ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1370. // {
  1371. // SuspendBMCArpsReq_T* pArpReq = ( SuspendBMCArpsReq_T*) pReq;
  1372. // SuspendBMCArpsRes_T* pArpRes = ( SuspendBMCArpsRes_T*) pRes;
  1373. // uint8_t EthIndex;
  1374. // /* Verify Channel ID */
  1375. // pArpRes->CompletionCode = CC_INV_DATA_FIELD;
  1376. // if(pArpReq->ChannelNo & RESERVED_BITS_SUSPENDBMCARPS) return sizeof(*pRes);
  1377. // if (!IsLANChannel(pArpReq->ChannelNo & CHANNEL_ID_MASK, BMCInst) )
  1378. // {
  1379. // return sizeof (*pRes);
  1380. // }
  1381. // EthIndex= GetEthIndex(pArpReq->ChannelNo & 0x0F,BMCInst);
  1382. // if(0xff == EthIndex)
  1383. // {
  1384. // return sizeof (*pRes);
  1385. // }
  1386. // /* Reserved Bits Validation */
  1387. // if (0 != (SUSPEND_ARP_RSVD_BIT_MASK & pArpReq->ArpSuspend))
  1388. // {
  1389. // return sizeof (*pRes);
  1390. // }
  1391. // if (BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning == TRUE)
  1392. // BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex] = pArpReq->ArpSuspend;
  1393. // /* Update Response */
  1394. // pArpRes->CompletionCode = CC_NORMAL;
  1395. // pArpRes->ArpSuspendStatus = UpdateArpStatus(EthIndex, BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning, BMCInst);
  1396. // return sizeof (SuspendBMCArpsRes_T);
  1397. // }
  1398. // /*---------------------------------------------------
  1399. // * GetIPUDPRMCPStats
  1400. // *---------------------------------------------------*/
  1401. // int
  1402. // GetIPUDPRMCPStats ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
  1403. // {
  1404. // GetIPUDPRMCPStatsReq_T* pGetIPUDPRMCPStatsReq = ( GetIPUDPRMCPStatsReq_T*) pReq;
  1405. // GetIPUDPRMCPStatsRes_T* pGetIPUDPRMCPStatsRes = ( GetIPUDPRMCPStatsRes_T*) pRes;
  1406. // BMCSharedMem_T* pSharedMem = BMC_GET_SHARED_MEM (BMCInst);
  1407. // FILE *fptr;
  1408. // char FDRead[512], FSRead[512];
  1409. // char *result = NULL;
  1410. // char **StrArray;
  1411. // int count = 0;
  1412. // int cStrings =0;
  1413. // if(pGetIPUDPRMCPStatsReq->ChannelNo & RESERVED_BITS_GETIPUDPRMCPSTATS_CH)
  1414. // {
  1415. // *pRes = CC_INV_DATA_FIELD;
  1416. // return sizeof(*pRes);
  1417. // }
  1418. // if(pGetIPUDPRMCPStatsReq->ClearStatus & RESERVED_BITS_GETIPUDPRMCPSTATS_CLRSTATE)
  1419. // {
  1420. // *pRes = CC_INV_DATA_FIELD;
  1421. // return sizeof(*pRes);
  1422. // }
  1423. // //Channel number [3:0] is valid.
  1424. // if ( !IsLANChannel(pGetIPUDPRMCPStatsReq->ChannelNo & CHANNEL_ID_MASK, BMCInst) )
  1425. // {
  1426. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_INV_DATA_FIELD;
  1427. // return sizeof (*pRes);
  1428. // }
  1429. // //Clear the statistics if 1 is given in request.
  1430. // if ( pGetIPUDPRMCPStatsReq->ClearStatus & 0x01 )
  1431. // {
  1432. // /* <TBD BalaT>
  1433. // * Have to clear the already stored statistics when clear req is 1.
  1434. // */
  1435. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
  1436. // return sizeof (uint8_t);
  1437. // }
  1438. // //All Statistics values are initialised to 0.
  1439. // memset (pGetIPUDPRMCPStatsRes, 0, sizeof(GetIPUDPRMCPStatsRes_T) );
  1440. // //All the datas are taken from /proc/net/snmp file
  1441. // fptr = fopen ("/proc/net/snmp","r+");
  1442. // if (fptr == NULL)
  1443. // {
  1444. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_COULD_NOT_PROVIDE_RESP;
  1445. // return sizeof (uint8_t);
  1446. // }
  1447. // while( NULL != fgets(FDRead,512,fptr) )
  1448. // {
  1449. // if ( NULL != strstr (FDRead, "Ip: ") )
  1450. // {
  1451. // count++;
  1452. // if (count == 2)
  1453. // {
  1454. // //To find the no. of valid strings in a line.
  1455. // strcpy (FSRead, FDRead);
  1456. // result = strtok( FSRead, " " );
  1457. // while( result != NULL )
  1458. // {
  1459. // cStrings++;
  1460. // result = strtok( NULL, " " );
  1461. // }
  1462. // //Condition to check so that explode doesnt try to read the strings from unknown location.
  1463. // if ( cStrings == 20)
  1464. // {
  1465. // StrArray = explode (' ', FDRead);
  1466. // }
  1467. // else
  1468. // {
  1469. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
  1470. // return sizeof (uint8_t);
  1471. // }
  1472. // //All Statistics stops acumulating at FFFFh unless otherwise noted.
  1473. // //IP packets received.
  1474. // if ( atol((char *)StrArray[3]) > 0xffff)
  1475. // pGetIPUDPRMCPStatsRes->IPPacketsRecv = ( ( atol((char *)StrArray[3]) ) % 65535);
  1476. // else
  1477. // pGetIPUDPRMCPStatsRes->IPPacketsRecv = atoi((char *)StrArray[3]);
  1478. // //IP Header Error.
  1479. // pGetIPUDPRMCPStatsRes->IPHeaderErr = atoi((char *)StrArray[4]);
  1480. // //IP Address Error.
  1481. // if ( atol((char *)StrArray[5]) > 0xffff)
  1482. // pGetIPUDPRMCPStatsRes->IPAddrErr = ( ( atol((char *)StrArray[5]) ) % 65535);
  1483. // else
  1484. // pGetIPUDPRMCPStatsRes->IPAddrErr = atoi((char *)StrArray[5]);
  1485. // //Fragmented IP Packets received.
  1486. // if ( atol((char *)StrArray[17]) > 0xffff)
  1487. // pGetIPUDPRMCPStatsRes->FragIPPacketsRecv = ( ( atol((char *)StrArray[17]) ) % 65535);
  1488. // else
  1489. // pGetIPUDPRMCPStatsRes->FragIPPacketsRecv = atoi((char *)StrArray[17]);
  1490. // //IP packets Transmitted.
  1491. // if ( atol((char *)StrArray[10]) > 0xffff)
  1492. // pGetIPUDPRMCPStatsRes->IPPacketsTrans = ( ( atol((char *)StrArray[10]) ) % 65535);
  1493. // else
  1494. // pGetIPUDPRMCPStatsRes->IPPacketsTrans = atoi((char *)StrArray[10]);
  1495. // count = 0;
  1496. // }
  1497. // }
  1498. // if ( NULL != strstr (FDRead, "Udp: ") )
  1499. // {
  1500. // count++;
  1501. // if (count == 2)
  1502. // {
  1503. // //To find the no. of valid strings in a line.
  1504. // cStrings = 0;
  1505. // strcpy (FSRead, FDRead);
  1506. // result = strtok( FSRead, " " );
  1507. // while( result != NULL )
  1508. // {
  1509. // cStrings++;
  1510. // result = strtok( NULL, " " );
  1511. // }
  1512. // //Condition to check so that explode doesnt try to read the strings beyond the valid location.
  1513. // if ( cStrings == 5)
  1514. // {
  1515. // StrArray = explode (' ', FDRead);
  1516. // }
  1517. // else
  1518. // {
  1519. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
  1520. // return sizeof (uint8_t);
  1521. // }
  1522. // //UDP packets received.
  1523. // if ( atol((char *)StrArray[1]) > 0xffff)
  1524. // pGetIPUDPRMCPStatsRes->UDPPacketsRecv = ( ( atol((char *)StrArray[1]) ) % 65535);
  1525. // else
  1526. // pGetIPUDPRMCPStatsRes->UDPPacketsRecv = atoi((char *)StrArray[1]);
  1527. // count = 0;
  1528. // }
  1529. // }
  1530. // }
  1531. // fclose(fptr);
  1532. // //Valid RMCP packets received.
  1533. // pGetIPUDPRMCPStatsRes->ValidRMCPPackets = pSharedMem->gIPUDPRMCPStats;
  1534. // //<TBD BalaT>To store the statistics across the system reset and power cycles
  1535. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
  1536. // return sizeof (GetIPUDPRMCPStatsRes_T);
  1537. // }
  1538. // /*-----------------------------------------------------
  1539. // * explode
  1540. // * Funntion to split the strings and store in an array
  1541. // *-----------------------------------------------------*/
  1542. // char **explode(char separator, char *string)
  1543. // {
  1544. // int start = 0, i, k = 1, count = 2;
  1545. // char **strarr;
  1546. // for (i = 0; string[i] != '\0'; i++)
  1547. // /* how many rows do we need for our array? */
  1548. // if (string[i] == separator)
  1549. // count++;
  1550. // /* count is at least 2 to make room for the entire string
  1551. // * * and the ending NULL */
  1552. // strarr = malloc(count * sizeof(char*));
  1553. // i = 0;
  1554. // while (*string++ != '\0')
  1555. // {
  1556. // if (*string == separator)
  1557. // {
  1558. // strarr[i] = malloc(k - start + 2);
  1559. // strncpy(strarr[i], string - k + start, k - start + 1);
  1560. // strarr[i][k - start + 1] = '\0'; /* guarantee null termination */
  1561. // start = k;
  1562. // i++;
  1563. // }
  1564. // k++;
  1565. // }
  1566. // /* copy the last part of the string after the last separator */
  1567. // strarr[i] = malloc(k - start);
  1568. // strncpy(strarr[i], string - k + start, k - start - 1);
  1569. // strarr[i][k - start - 1] = '\0'; /* guarantee null termination */
  1570. // strarr[++i] = NULL;
  1571. // return strarr;
  1572. // }
  1573. // /*----------------------------------------------
  1574. // * UpdateArpStatus
  1575. // *----------------------------------------------*/
  1576. // uint8_t
  1577. // UpdateArpStatus (uint8_t EthIndex,BOOL IsTimerRunning, int BMCInst)
  1578. // {
  1579. // uint8_t GratArpSuspend;
  1580. // uint8_t ArpSuspend;
  1581. // uint8_t Status;
  1582. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  1583. // char Cmds[50]={0}; // command string to perform BMC-generated ARP
  1584. // char IfcName[16];
  1585. // IPMI_DBG_PRINT_1 ("Timer - %x", IsTimerRunning);
  1586. // GratArpSuspend = ArpSuspend = 1;
  1587. // // Check Gratuitous ARP is Enabled
  1588. // if (0 == (pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl & GRATIUTOUS_ENABLE_MASK))
  1589. // {
  1590. // GratArpSuspend = 0;
  1591. // }
  1592. // // Check ARP Response is Enabled
  1593. // if (0 == (pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl & ENABLE_ARP_RESPONSES))
  1594. // {
  1595. // ArpSuspend = 0;
  1596. // }
  1597. // /*Disable ARP */
  1598. // if (TRUE == IsTimerRunning)
  1599. // {
  1600. // /* WDT is running, check and suspend ARP if necessary */
  1601. // if( (0 != (BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex] & SUSPEND_GRAT_ARP)) &&
  1602. // (0 < GratArpSuspend) )
  1603. // {
  1604. // GratArpSuspend--;
  1605. // }
  1606. // if( (0 != (BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex] & SUSPEND_ARP)) &&
  1607. // (0 < ArpSuspend) )
  1608. // {
  1609. // ArpSuspend--;
  1610. // }
  1611. // }
  1612. // memset(IfcName,0,sizeof(IfcName));
  1613. // if(GetIfcName(EthIndex, IfcName, BMCInst) != 0)
  1614. // {
  1615. // TCRIT("Error in getting Interface Name for the Lan Index :%d\n", EthIndex);
  1616. // }
  1617. // else
  1618. // {
  1619. // /* Perform commands for BMC-generated Arp */
  1620. // memset(Cmds, 0, sizeof(Cmds));
  1621. // sprintf(Cmds, "/usr/local/bin/ArpSwitch.sh %s %d", IfcName, (!ArpSuspend) ? ARP_IGNORE_ON : ARP_IGNORE_OFF);
  1622. // safe_system (Cmds);
  1623. // /* Perform commands for BMC-generated Arp ends */
  1624. // }
  1625. // /* Update Status */
  1626. // Status = ArpSuspend << 1;
  1627. // Status = Status | GratArpSuspend;
  1628. // return Status;
  1629. // }
  1630. // /**
  1631. // *@fn NwInterfacePresenceCheck
  1632. // *@brief This function is invoked to check network interface presence
  1633. // *@param Interface - Char Pointer to Interface for which interface to check
  1634. // *@return Returns 0 on success
  1635. // */
  1636. // static int
  1637. // NwInterfacePresenceCheck (char * Interface)
  1638. // {
  1639. // int r;
  1640. // int sockdes;
  1641. // struct ifreq Ifreq;
  1642. // unsigned char MAC[MAC_ADDR_LEN];
  1643. // IPMI_DBG_PRINT_1 ("Checking the presence of %s\n", Interface);
  1644. // sockdes = socket(PF_INET, SOCK_DGRAM, 0 );
  1645. // if ( sockdes < 0 )
  1646. // {
  1647. // IPMI_ERROR("can't open socket: %s\n",strerror(errno));
  1648. // return -1;
  1649. // }
  1650. // /* Get MAC address */
  1651. // memset(&Ifreq,0,sizeof(struct ifreq));
  1652. // memset(MAC, 0, MAC_ADDR_LEN);
  1653. // strcpy(Ifreq.ifr_name, Interface);
  1654. // Ifreq.ifr_hwaddr.sa_family = AF_INET;
  1655. // r = ioctl(sockdes, SIOCGIFHWADDR, &Ifreq);
  1656. // close (sockdes);
  1657. // if ( r < 0 )
  1658. // {
  1659. // //IPMI_ERROR("IOCTL to get MAC failed: %d\n",r);
  1660. // return -1;
  1661. // }
  1662. // IPMI_DBG_PRINT_1 (" %s Interface is present\n", Interface);
  1663. // return 0;
  1664. // }