LANConfig.c 132 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115
  1. #include <linux/if.h>
  2. #include <linux/ip.h>
  3. #include <dlfcn.h>
  4. #include <sys/prctl.h>
  5. /* Reserved bit macro definitions */
  6. #define RESERVED_BITS_SUSPENDBMCARPS 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  7. #define RESERVED_BITS_GETIPUDPRMCPSTATS_CH 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  8. #define RESERVED_BITS_GETIPUDPRMCPSTATS_CLRSTATE 0xFE //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1)
  9. /*** Local definitions ***/
  10. #define CHANNEL_ID_MASK 0x0f
  11. #define SET_IN_PROGRESS_MASK 0x03
  12. #define PARAMETER_REVISION_MASK 0x0f
  13. #define DEST_ADDR_DATA2_ADDR_FORMAT_MASK 0xf0
  14. #define PARAMETER_REVISION_FORMAT 0x11
  15. #define GET_PARAMETER_REVISION_MASK 0x80
  16. #define LAN_CALLBACK_AUTH_SUPPORT 0x17 /* MD2 & MD5 supported */
  17. #define LAN_USER_AUTH_SUPPORT 0x17 /* MD2 & MD5 supported */
  18. #define LAN_OPERATOR_AUTH_SUPPORT 0x17 /* MD2 & MD5 supported */
  19. #define LAN_ADMIN_AUTH_SUPPORT 0x17 /* MD2 & MD5 supported */
  20. #define BRD_CAST_BIT_MASK 0xFF
  21. #define LOOP_BACK_BIT_MASK 0x7F
  22. #define SUBNET_MASK_BIT_CHECK 0x80
  23. #define LAN_CONFIGURATION_SET_IN_PROGRESS 0x01
  24. #define LAN_CONFIGURATION_SET_COMPLETE 0x00
  25. #define GRATIUTOUS_ENABLE_MASK 1
  26. #define ENABLE_ARP_RESPONSES 2
  27. #define SUSPEND_ARP_RSVD_BIT_MASK 0xFC
  28. #define ENABLE_ARPS 0x03
  29. #define SUSPEND_GRAT_ARP 0x01
  30. #define SUSPEND_ARP 0x02
  31. #define ARP_IGNORE_ON 8
  32. #define ARP_IGNORE_OFF 0
  33. /* Reserved Bits */
  34. #define RESERVED_VALUE_70 0x70
  35. #define RESERVED_VALUE_F0 0xF0
  36. // /**
  37. // *@fn NwInterfacePresenceCheck
  38. // *@brief This function is invoked to check network interface presence
  39. // *@param Interface - Char Pointer to buffer for which interface to check
  40. // */
  41. // static int NwInterfacePresenceCheck (char * Interface);
  42. // /*** Module Variables ***/
  43. // //_FAR_ uint8_t m_ArpSuspendReq;
  44. // char **explode(char separator, char *string);
  45. // int IPAddrCheck(uint8_t *Addr,int params);
  46. // extern int GetLanAMIParamValue (uint8_t* ParamSelect, uint8_t* ImpType);
  47. // extern IfcName_T Ifcnametable[MAX_LAN_CHANNELS];
  48. #define MAX_LAN_PARAMS_DATA 20
  49. typedef struct
  50. {
  51. uint8_t Params;
  52. uint8_t ReservedBits [MAX_LAN_PARAMS_DATA];
  53. uint8_t DataLen;
  54. } LANCfgRsvdBits_T;
  55. static LANCfgRsvdBits_T m_RsvdBitsCheck [] = {
  56. /* Param Reserved Bits Data Size */
  57. { 0, { 0xFC }, 0x1 }, /* Set In progress */
  58. { 1, { 0xC8 }, 0x1 }, /* Authenication type */
  59. { 2, { 0xC8,0xC8,0xC8,0xC8,0xC8 }, 0x5}, /* Authenication Support Enable */
  60. { 4, { 0xF0 }, 0x1 }, /* l */
  61. { 7, { 0x0,0x1F,0x01 }, 0x3 }, /* l */
  62. { 0xA, { 0xFC }, 0x1 }, /* l */
  63. { 0x11, { 0xF0 }, 0x1 }, /* l */
  64. { 0x12, { 0xF0,0x78,0x0,0xF8 }, 0x4 },
  65. { 0x13, { 0xF0,0x0F, 0xFE }, 0x3 },
  66. { 0x14, { 0x0,0x70}, 0x2 },
  67. { 0x15, { 0xF8 }, 0x1 },
  68. { 0x16, { 0xE0 }, 0x1 },
  69. { 0x17, { 0xFF }, 0x1 },
  70. { 0x18, { 0xFF }, 0x1 },
  71. { 0x19, { 0xF0,0x0F }, 0x2 },
  72. { 0x1A, { 0xFE }, 0x1 }
  73. };
  74. typedef struct
  75. {
  76. uint8_t OEMParam;
  77. uint8_t Length;
  78. }OEMParameterLength_T;
  79. static OEMParameterLength_T m_OEMParamLen [] = {
  80. {LAN_PARAMS_AMI_OEM_IPV6_ENABLE, 1 },
  81. {LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE, 1 },
  82. {LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR, 17 },
  83. {LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH, 2},
  84. {LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP, 16}
  85. };
  86. // /**
  87. // * @brief LAN configuration request parameter lengths
  88. // **/
  89. // static const uint8_t LanconfigParameterLength [] = {
  90. // 1, /* Set in progress */
  91. // 1, /* Authentication type support */
  92. // 5, /* Authentication type enables */
  93. // 4, /* IP address */
  94. // 1, /* IP address source */
  95. // 6, /* MAC address */
  96. // 4, /* Subnet mask */
  97. // 3, /* IPv4 header parameters */
  98. // 2, /* Primary RMCP port number */
  99. // 2, /* Secondary RMCP port number */
  100. // 1, /* BMC generated ARP control */
  101. // 1, /* Gratuitous ARP */
  102. // 4, /* Default Gateway address */
  103. // 6, /* Default Gateway MAC address */
  104. // 4, /* Backup Gateway address */
  105. // 6, /* Backup Gateway MAC address */
  106. // 18, /* Community string */
  107. // 1, /* Number of destinations */
  108. // 4, /* Destination type */
  109. // 13, /* Destination address */
  110. // 2, /* VLAN ID */
  111. // 1, /* VLAN Priority */
  112. // 1, /* Cipher suite entry support */
  113. // 17, /* Cipher suite entries */
  114. // 9, /* Cipher suite Privilege levels */
  115. // 4, /* VLAN tags destination address */
  116. // 6, /* Bad Password Threshold */
  117. // (9+16) /* IPv6 Destination address */
  118. // };
  119. // /* A copy of ip_tos2prio with numeric format in "linux/net/ipv4/route.c" */
  120. // static const uint8_t IP_TOS2PRIO[16] = {
  121. // 0, /* TC_PRIO_BESTEFFORT, */
  122. // 1, /* ECN_OR_COST(FILLER), */
  123. // 0, /* TC_PRIO_BESTEFFORT, */
  124. // 0, /* ECN_OR_COST(BESTEFFORT), */
  125. // 2, /* TC_PRIO_BULK, */
  126. // 2, /* ECN_OR_COST(BULK), */
  127. // 2, /* TC_PRIO_BULK, */
  128. // 2, /* ECN_OR_COST(BULK), */
  129. // 6, /* TC_PRIO_INTERACTIVE, */
  130. // 6, /* ECN_OR_COST(INTERACTIVE), */
  131. // 6, /* TC_PRIO_INTERACTIVE, */
  132. // 6, /* ECN_OR_COST(INTERACTIVE), */
  133. // 4, /* TC_PRIO_INTERACTIVE_BULK, */
  134. // 4, /* ECN_OR_COST(INTERACTIVE_BULK),*/
  135. // 4, /* TC_PRIO_INTERACTIVE_BULK, */
  136. // 4 /* ECN_OR_COST(INTERACTIVE_BULK) */
  137. // };
  138. // static BOOL enableSetMACAddr = FALSE; //jimbo notice
  139. // /*-------------------------------------------------------
  140. // * SetLanConfigParam
  141. // *-------------------------------------------------------*/
  142. // int
  143. // SetLanConfigParam (_NEAR_ uint8_t* pReq, uint8_t ReqLen, _NEAR_ uint8_t* pRes,_NEAR_ int BMCInst)
  144. // {
  145. // _NEAR_ SetLanConfigReq_T* pSetLanReq = (_NEAR_ SetLanConfigReq_T*) pReq;
  146. // _NEAR_ SetLanConfigRes_T* pSetLanRes = (_NEAR_ SetLanConfigRes_T*) pRes;
  147. // _FAR_ BMCSharedMem_T* pSharedMem = BMC_GET_SHARED_MEM (BMCInst);
  148. // _FAR_ ChannelInfo_T* ptrChannelInfo;
  149. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  150. // NWCFG_STRUCT NWConfig;
  151. // NWCFG6_STRUCT NWConfig6;
  152. // INT32U GWIp,IPAddr;
  153. // INT32U Subnetmask;
  154. // int i,j=0;
  155. // uint8_t IsOemDefined = FALSE;
  156. // uint8_t EthIndex,netindex= 0xFF, currBmcGenArpCtrl;
  157. // BMCArg *pLANArg=NULL;
  158. // char VLANInterfaceName [32];
  159. // INT16U vlanID=0;
  160. // INT16U InvalidVlanID[3]={0,1,4095};
  161. // char cmdSetPriority[32];
  162. // int retValue=0,NIC_Count = 0;
  163. // INT16U PriorityLevel[MAX_LAN_CHANNELS]= {0};
  164. // uint8_t m_Lan_SetInProgress; /**< Contains setting LAN configuration status */
  165. // ETHCFG_STRUCT PHYCfg;
  166. // static uint8_t macEthIndex = 0xFF;
  167. // uint8_t TOS = 0, SkbPriority = 0; /* For VLAN priority parameter */
  168. // int pendStatus = PEND_STATUS_COMPLETED;
  169. // char IfcName[16]; /* Eth interface name */
  170. // if ( ReqLen >= 2 )
  171. // {
  172. // ReqLen -= 2;
  173. // }
  174. // else
  175. // {
  176. // *pRes = CC_REQ_INV_LEN;
  177. // return sizeof (uint8_t);
  178. // }
  179. // if(g_corefeatures.dual_image_support == ENABLED)
  180. // {
  181. // if(IsCardInFlashMode())
  182. // {
  183. // IPMI_WARNING("Card in Active flash mode, Not safe to set any of LAN configurations...\n");
  184. // *pRes = CC_DEV_IN_FIRMWARE_UPDATE_MODE;
  185. // return sizeof (*pRes);
  186. // }
  187. // }
  188. // EthIndex= GetEthIndex(pSetLanReq->ChannelNum & 0x0F, BMCInst);
  189. // if(0xff == EthIndex)
  190. // {
  191. // *pRes = CC_INV_DATA_FIELD;
  192. // return sizeof (uint8_t);
  193. // }
  194. // memset(IfcName,0,sizeof(IfcName));
  195. // /*Get the EthIndex*/
  196. // if(GetIfcName(EthIndex,IfcName, BMCInst) == -1)
  197. // {
  198. // TCRIT("Error in Getting Ifc name\n");
  199. // *pRes = CC_INV_DATA_FIELD;
  200. // return sizeof (uint8_t);
  201. // }
  202. // for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
  203. // {
  204. // if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
  205. // {
  206. // netindex= Ifcnametable[i].Index;
  207. // break;
  208. // }
  209. // }
  210. // if(netindex == 0xFF)
  211. // {
  212. // *pRes = CC_INV_DATA_FIELD;
  213. // return sizeof (uint8_t);
  214. // }
  215. // if((pSetLanReq->ParameterSelect >= MIN_LAN_OEM_CONF_PARAM) &&
  216. // (pSetLanReq->ParameterSelect <= MAX_LAN_OEM_CONF_PARAM) )
  217. // {
  218. // /* Converts OEM parameter value to equivalent AMI parameter value */
  219. // if (0 != GetLanAMIParamValue (&pSetLanReq->ParameterSelect, &IsOemDefined) )
  220. // {
  221. // pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
  222. // return sizeof(uint8_t);
  223. // }
  224. // /* Hook for OEM to handle this parameter */
  225. // if ( (IsOemDefined) && (g_PDKHandle[PDK_SETLANOEMPARAM] != NULL) )
  226. // {
  227. // return ((int(*)(uint8_t *, uint8_t, uint8_t *,int))(g_PDKHandle[PDK_SETLANOEMPARAM]))(pReq, ReqLen, pRes, BMCInst);
  228. // }
  229. // }
  230. // if(0x1b >pSetLanReq->ParameterSelect ) //Max known Lan paramter
  231. // {
  232. // if (ReqLen != LanconfigParameterLength [pSetLanReq->ParameterSelect ])
  233. // {
  234. // *pRes = CC_REQ_INV_LEN;
  235. // return sizeof (uint8_t);
  236. // }
  237. // }
  238. // /*Check the Request length for OEM parameter*/
  239. // for(i=0;i<sizeof(m_OEMParamLen)/sizeof(OEMParameterLength_T);i++)
  240. // {
  241. // if(m_OEMParamLen[i].OEMParam == pSetLanReq->ParameterSelect)
  242. // {
  243. // if(ReqLen != m_OEMParamLen[i].Length)
  244. // {
  245. // *pRes = CC_REQ_INV_LEN;
  246. // return sizeof(uint8_t);
  247. // }
  248. // }
  249. // }
  250. // if(pSetLanReq->ChannelNum & RESERVED_VALUE_F0)
  251. // {
  252. // /* Alarm !!! Somebody is trying to set Reseved Bits */
  253. // *pRes = CC_INV_DATA_FIELD;
  254. // return sizeof (*pRes);
  255. // }
  256. // /* Check for Reserved Bits */
  257. // for (i = 0; i < sizeof (m_RsvdBitsCheck)/ sizeof (m_RsvdBitsCheck[0]); i++)
  258. // {
  259. // /* Check if this Parameter Selector needs Reserved bit checking !! */
  260. // if (m_RsvdBitsCheck[i].Params == pSetLanReq->ParameterSelect)
  261. // {
  262. // //IPMI_DBG_PRINT_2 ("Param - %x, DataLen - %x\n", pSetLanReq->ParameterSelect, m_RsvdBitsCheck[i].DataLen);
  263. // for (j = 0; j < m_RsvdBitsCheck[i].DataLen; j++)
  264. // {
  265. // // IPMI_DBG_PRINT_2 ("Cmp %x, %x\n", pReq[2+j], m_RsvdBitsCheck[i].ReservedBits[j]);
  266. // if ( 0 != (pReq[2+j] & m_RsvdBitsCheck[i].ReservedBits[j]))
  267. // {
  268. // /* Alarm !!! Somebody is trying to set Reseved Bits */
  269. // *pRes = CC_INV_DATA_FIELD;
  270. // return sizeof (*pRes);
  271. // }
  272. // }
  273. // }
  274. // }
  275. // ptrChannelInfo = getChannelInfo (pSetLanReq->ChannelNum & 0x0F, BMCInst);
  276. // if(NULL == ptrChannelInfo)
  277. // {
  278. // *pRes = CC_INV_DATA_FIELD;
  279. // return sizeof(*pRes);
  280. // }
  281. // IPMI_DBG_PRINT_1 ("Parameter = %X\n", pSetLanReq->ParameterSelect);
  282. // if (g_PDKHandle[PDK_BEFORESETLANPARM] != NULL )
  283. // {
  284. // retValue = ((int(*)(uint8_t *, uint8_t, uint8_t *,int))(g_PDKHandle[PDK_BEFORESETLANPARM]))(pReq, ReqLen, pRes, BMCInst);
  285. // if(retValue != 0)
  286. // {
  287. // return retValue;
  288. // }
  289. // }
  290. // if((pSetLanReq->ParameterSelect == LAN_PARAM_SELECT_DEST_ADDR) ||
  291. // (pSetLanReq->ParameterSelect == LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR))
  292. // {
  293. // /*Destination Address is allowed to configure only if DestType is LAN_PET_TRAP(SNMP alerts types)*/
  294. // if(pBMCInfo->LANCfs[EthIndex].DestType [pSetLanReq->ConfigData.DestAddr.SetSelect - 1].DestType == LAN_OEM1_ALERT)
  295. // {
  296. // *pRes = CC_INV_DATA_FIELD;
  297. // return sizeof (uint8_t);
  298. // }
  299. // }
  300. // switch (pSetLanReq->ParameterSelect)
  301. // {
  302. // case LAN_PARAM_SET_IN_PROGRESS:
  303. // LOCK_BMC_SHARED_MEM(BMCInst);
  304. // m_Lan_SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Lan_SetInProgress;
  305. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  306. // /* Commit Write is optional and supported
  307. // * only if rollback is supported */
  308. // if ( (GetBits(pSetLanReq->ConfigData.SetInProgress, SET_IN_PROGRESS_MASK) !=
  309. // LAN_CONFIGURATION_SET_COMPLETE) &&
  310. // (GetBits(pSetLanReq->ConfigData.SetInProgress, SET_IN_PROGRESS_MASK) !=
  311. // LAN_CONFIGURATION_SET_IN_PROGRESS) )
  312. // {
  313. // pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
  314. // return sizeof(*pSetLanRes);
  315. // }
  316. // else if ((GetBits(m_Lan_SetInProgress, SET_IN_PROGRESS_MASK) ==
  317. // LAN_CONFIGURATION_SET_IN_PROGRESS) &&
  318. // (GetBits(pSetLanReq->ConfigData.SetInProgress, SET_IN_PROGRESS_MASK) ==
  319. // LAN_CONFIGURATION_SET_IN_PROGRESS))
  320. // {
  321. // pSetLanRes->CompletionCode = CC_SET_IN_PROGRESS;
  322. // return sizeof(*pSetLanRes);
  323. // }
  324. // LOCK_BMC_SHARED_MEM(BMCInst);
  325. // BMC_GET_SHARED_MEM(BMCInst)->m_Lan_SetInProgress = pSetLanReq->ConfigData.SetInProgress;
  326. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  327. // break;
  328. // case LAN_PARAM_AUTH_TYPE_SUPPORT:
  329. // pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  330. // return sizeof(*pRes);
  331. // case LAN_PARAM_AUTH_TYPE_ENABLES:
  332. // for(i=0;i<5;i++)
  333. // {
  334. // /* Check for Unsupported AuthType */
  335. // if (pBMCInfo->LANCfs[EthIndex].AuthTypeSupport != (pBMCInfo->LANCfs[EthIndex].AuthTypeSupport |pReq[2+i]))
  336. // {
  337. // IPMI_DBG_PRINT_2("\n Alarm !!! Somebody is trying to Unsupported Bit :%d \t%d\n",pReq[2+i],i);
  338. // *pRes = CC_INV_DATA_FIELD;
  339. // return sizeof (*pRes);
  340. // }
  341. // }
  342. // LOCK_BMC_SHARED_MEM(BMCInst);
  343. // _fmemcpy (&pBMCInfo->LANCfs[EthIndex].AuthTypeEnables,
  344. // &(pSetLanReq->ConfigData.AuthTypeEnables), sizeof(AuthTypeEnables_T));
  345. // _fmemcpy (ptrChannelInfo->AuthType,
  346. // &(pSetLanReq->ConfigData.AuthTypeEnables), sizeof(AuthTypeEnables_T));
  347. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  348. // break;
  349. // case LAN_PARAM_IP_ADDRESS:
  350. // pendStatus = GetPendStatus(PEND_OP_SET_IP);
  351. // if(pendStatus == PEND_STATUS_PENDING)
  352. // {
  353. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  354. // return sizeof (uint8_t);
  355. // }
  356. // //we need to do a read in hte pend task and not here
  357. // // because if pend task is still working on setting the source for example t- by then we would have got the
  358. // // next command which is ip address and then we would read back DHCP since nwcfg hasnt done its work yet etc. and all hell will breakloose.
  359. // //nwReadNWCfg (&NWConfig);
  360. // if(pBMCInfo->LANCfs[EthIndex].IPAddrSrc == DHCP_IP_SOURCE)
  361. // {
  362. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  363. // return sizeof (uint8_t);
  364. // }
  365. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  366. // if(memcmp ( NWConfig.IPAddr, pSetLanReq->ConfigData.IPAddr, IP_ADDR_LEN ) == 0)
  367. // {
  368. // TCRIT("Same IP address, do nothing\n");
  369. // _fmemcpy (pBMCInfo->LANCfs[EthIndex].IPAddr, pSetLanReq->ConfigData.IPAddr, IP_ADDR_LEN);
  370. // break;
  371. // }
  372. // if(IPAddrCheck(pSetLanReq->ConfigData.IPAddr,LAN_PARAM_IP_ADDRESS))
  373. // {
  374. // *pRes = CC_INV_DATA_FIELD;
  375. // return sizeof (uint8_t);
  376. // }
  377. // pendStatus = GetPendStatus(PEND_OP_SET_IP);
  378. // if(pendStatus == PEND_STATUS_PENDING)
  379. // {
  380. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  381. // return sizeof (uint8_t);
  382. // }
  383. // _fmemcpy (NWConfig.IPAddr, pSetLanReq->ConfigData.IPAddr, IP_ADDR_LEN);
  384. // SetPendStatus(PEND_OP_SET_IP,PEND_STATUS_PENDING);
  385. // PostPendTask(PEND_OP_SET_IP,(uint8_t*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F),BMCInst);
  386. // _fmemcpy (pBMCInfo->LANCfs[EthIndex].IPAddr, pSetLanReq->ConfigData.IPAddr, IP_ADDR_LEN);
  387. // //nwWriteNWCfg (&NWConfig);
  388. // break;
  389. // case LAN_PARAM_IP_ADDRESS_SOURCE:
  390. // if ((pSetLanReq->ConfigData.IPAddrSrc > BMC_OTHER_SOURCE)
  391. // ||(pSetLanReq->ConfigData.IPAddrSrc == UNSPECIFIED_IP_SOURCE))
  392. // {
  393. // *pRes = CC_INV_DATA_FIELD;
  394. // return sizeof (uint8_t);
  395. // }
  396. // if ( pBMCInfo->LANCfs[EthIndex].IPAddrSrc == pSetLanReq->ConfigData.IPAddrSrc )
  397. // {
  398. // TCRIT("LAN or VLAN if current SRC is DHCP/Static and incoming SRC is DHCP/Static, do nothing\n");
  399. // break;
  400. // }
  401. // if(!((pSetLanReq->ConfigData.IPAddrSrc == STATIC_IP_SOURCE ) || (pSetLanReq->ConfigData.IPAddrSrc == DHCP_IP_SOURCE )))
  402. // pBMCInfo->LANCfs[EthIndex].IPAddrSrc = pSetLanReq->ConfigData.IPAddrSrc ;
  403. // if ( (pSetLanReq->ConfigData.IPAddrSrc == STATIC_IP_SOURCE ) || (pSetLanReq->ConfigData.IPAddrSrc == DHCP_IP_SOURCE ) )
  404. // {
  405. // pendStatus = GetPendStatus(PEND_OP_SET_SOURCE);
  406. // if(pendStatus == PEND_STATUS_PENDING)
  407. // {
  408. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  409. // return sizeof (uint8_t);
  410. // }
  411. // pBMCInfo->LANCfs[EthIndex].IPAddrSrc = pSetLanReq->ConfigData.IPAddrSrc ;
  412. // NWConfig.CfgMethod = pSetLanReq->ConfigData.IPAddrSrc;
  413. // SetPendStatus(PEND_OP_SET_SOURCE,PEND_STATUS_PENDING);
  414. // PostPendTask(PEND_OP_SET_SOURCE,(uint8_t*) &NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  415. // }
  416. // else if(pSetLanReq->ConfigData.IPAddrSrc == BIOS_IP_SOURCE)
  417. // {
  418. // /*Perform OEM action*/
  419. // if(g_PDKHandle[PDK_BIOSIPSOURCE] != NULL)
  420. // {
  421. // retValue = ((int(*)(uint8_t))g_PDKHandle[PDK_BIOSIPSOURCE]) (pSetLanReq->ChannelNum & CHANNEL_ID_MASK);
  422. // if(retValue == 1)
  423. // {
  424. // *pRes = CC_INV_DATA_FIELD;
  425. // return sizeof (*pRes);
  426. // }
  427. // }
  428. // else
  429. // {
  430. // pendStatus = GetPendStatus(PEND_OP_SET_SOURCE);
  431. // if(pendStatus == PEND_STATUS_PENDING)
  432. // {
  433. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  434. // return sizeof (uint8_t);
  435. // }
  436. // NWConfig.CfgMethod = STATIC_IP_SOURCE;
  437. // SetPendStatus(PEND_OP_SET_SOURCE,PEND_STATUS_PENDING);
  438. // PostPendTask(PEND_OP_SET_SOURCE, (uint8_t*) &NWConfig,sizeof(NWConfig), (pSetLanReq->ChannelNum & CHANNEL_ID_MASK), BMCInst );
  439. // }
  440. // }
  441. // else if(pSetLanReq->ConfigData.IPAddrSrc == BMC_OTHER_SOURCE)
  442. // {
  443. // /*Perform OEM action*/
  444. // if(g_PDKHandle[PDK_BMCOTHERSOURCEIP] != NULL)
  445. // {
  446. // retValue = ((int(*)(uint8_t))g_PDKHandle[PDK_BMCOTHERSOURCEIP]) (pSetLanReq->ChannelNum & CHANNEL_ID_MASK);
  447. // if(retValue == 1)
  448. // {
  449. // *pRes = CC_INV_DATA_FIELD;
  450. // return sizeof (*pRes);
  451. // }
  452. // }
  453. // else
  454. // {
  455. // *pRes = CC_INV_DATA_FIELD;
  456. // return sizeof (*pRes);
  457. // }
  458. // }
  459. // break;
  460. // case LAN_PARAM_MAC_ADDRESS:
  461. // #if 0
  462. // nwReadNWCfg (&NWConfig);
  463. // printf ( "The MAC is %x %x %x %x %x %x \n", NWConfig.MAC [0],NWConfig.MAC [1],NWConfig.MAC [2],NWConfig.MAC [3],NWConfig.MAC [4],NWConfig.MAC [5] );
  464. // _fmemcpy (NWConfig.MAC, pSetLanReq->ConfigData.MACAddr, MAC_ADDR_LEN);
  465. // printf ( "The MAC is %x %x %x %x %x %x \n", NWConfig.MAC [0],NWConfig.MAC [1],NWConfig.MAC [2],NWConfig.MAC [3],NWConfig.MAC [4],NWConfig.MAC [5] );
  466. // nwWriteNWCfg (&NWConfig);
  467. // #else
  468. // /* According to IPMI 2.0 Specification Revision 3, the MAC address can be read only parameter*/
  469. // //*pRes = CC_ATTEMPT_TO_SET_RO_PARAM;
  470. // //return sizeof (*pRes);
  471. // if (!enableSetMACAddr)
  472. // pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  473. // else
  474. // {
  475. // EnableSetMACAddress_T macAddrEnabled;
  476. // uint8_t InvalidMac[MAC_ADDR_LEN] = {0};
  477. // if((pSetLanReq->ConfigData.MACAddr[0]& BIT0)|| (memcmp(&InvalidMac,&pSetLanReq->ConfigData.MACAddr,MAC_ADDR_LEN) == 0))
  478. // {
  479. // pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
  480. // return sizeof(uint8_t);
  481. // }
  482. // memset(&macAddrEnabled, 0, sizeof(EnableSetMACAddress_T));
  483. // macAddrEnabled.EthIndex = macEthIndex;
  484. // memcpy(&macAddrEnabled.MACAddress, &pSetLanReq->ConfigData.MACAddr, MAC_ADDR_LEN);
  485. // pendStatus = GetPendStatus(PEND_OP_SET_MAC_ADDRESS);
  486. // if(pendStatus == PEND_STATUS_PENDING)
  487. // {
  488. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  489. // return sizeof (uint8_t);
  490. // }
  491. // SetPendStatus(PEND_OP_SET_MAC_ADDRESS, PEND_STATUS_PENDING);
  492. // PostPendTask(PEND_OP_SET_MAC_ADDRESS, (uint8_t*)&macAddrEnabled, sizeof(EnableSetMACAddress_T), (pSetLanReq->ChannelNum & 0x0F), BMCInst);
  493. // enableSetMACAddr = FALSE;
  494. // macEthIndex = 0xFF;
  495. // pSetLanRes->CompletionCode = CC_NORMAL;
  496. // }
  497. // return sizeof(*pSetLanRes);
  498. // #endif
  499. // case LAN_PARAM_SUBNET_MASK:
  500. // pendStatus = GetPendStatus(PEND_OP_SET_SUBNET);
  501. // if(pendStatus == PEND_STATUS_PENDING)
  502. // {
  503. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  504. // return sizeof (uint8_t);
  505. // }
  506. // /*Returning valid completion code in case of attempt to set netmask in DHCP mode */
  507. // if(pBMCInfo->LANCfs[EthIndex].IPAddrSrc == DHCP_IP_SOURCE)
  508. // {
  509. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  510. // return sizeof (uint8_t);
  511. // }
  512. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  513. // if(memcmp ( NWConfig.Mask, pSetLanReq->ConfigData.SubNetMask, IP_ADDR_LEN ) == 0)
  514. // {
  515. // TCRIT("Same Mask, do nothing\n");
  516. // _fmemcpy (pBMCInfo->LANCfs[EthIndex].SubNetMask, pSetLanReq->ConfigData.SubNetMask, IP_ADDR_LEN);
  517. // break;
  518. // }
  519. // if(IPAddrCheck(pSetLanReq->ConfigData.SubNetMask,LAN_PARAM_SUBNET_MASK))
  520. // {
  521. // *pRes = CC_INV_DATA_FIELD;
  522. // return sizeof (uint8_t);
  523. // }
  524. // _fmemcpy (NWConfig.Mask, pSetLanReq->ConfigData.SubNetMask, IP_ADDR_LEN);
  525. // SetPendStatus(PEND_OP_SET_SUBNET,PEND_STATUS_PENDING);
  526. // PostPendTask(PEND_OP_SET_SUBNET,(uint8_t*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F) , BMCInst);
  527. // _fmemcpy (pBMCInfo->LANCfs[EthIndex].SubNetMask, pSetLanReq->ConfigData.SubNetMask, IP_ADDR_LEN);
  528. // break;
  529. // case LAN_PARAM_IPv4_HEADER:
  530. // pendStatus = GetPendStatus(PEND_OP_SET_IPV4_HEADERS);
  531. // if(pendStatus == PEND_STATUS_PENDING)
  532. // {
  533. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  534. // return sizeof (uint8_t);
  535. // }
  536. // if(!pSetLanReq->ConfigData.Ipv4HdrParam.TimeToLive > 0)
  537. // {
  538. // IPMI_DBG_PRINT("The requested IPv4 header(TTL) to set is invalid.\n");
  539. // *pRes = CC_PARAM_OUT_OF_RANGE;
  540. // return sizeof(*pRes);
  541. // }
  542. // if(pSetLanReq->ConfigData.Ipv4HdrParam.IpHeaderFlags == 0x60) // Flags can be either of the values: DF(0x40) or MF(0x20)
  543. // {
  544. // IPMI_DBG_PRINT("The requested IPv4 header(Flags) to set is invalid.\n");
  545. // *pRes = CC_PARAM_OUT_OF_RANGE;
  546. // return sizeof(*pRes);
  547. // }
  548. // LOCK_BMC_SHARED_MEM(BMCInst);
  549. // _fmemcpy (&pBMCInfo->LANCfs[EthIndex].Ipv4HdrParam,
  550. // &pSetLanReq->ConfigData.Ipv4HdrParam, sizeof(IPv4HdrParams_T));
  551. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  552. // SetPendStatus(PEND_OP_SET_IPV4_HEADERS,PEND_STATUS_PENDING);
  553. // PostPendTask(PEND_OP_SET_IPV4_HEADERS, (uint8_t*)&(pSetLanReq->ConfigData.Ipv4HdrParam),
  554. // sizeof(pSetLanReq->ConfigData.Ipv4HdrParam),(pSetLanReq->ChannelNum & 0x0F),BMCInst);
  555. // break;
  556. // case LAN_PARAM_PRI_RMCP_PORT:
  557. // pendStatus = GetPendStatus(PEND_RMCP_PORT_CHANGE);
  558. // if(pendStatus == PEND_STATUS_PENDING)
  559. // {
  560. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  561. // return sizeof (uint8_t);
  562. // }
  563. // LOCK_BMC_SHARED_MEM(BMCInst);
  564. // pBMCInfo->LANCfs[EthIndex].PrimaryRMCPPort = ipmitoh_u16 (pSetLanReq->ConfigData.PrimaryRMCPPort);
  565. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  566. // SetPendStatus(PEND_RMCP_PORT_CHANGE,PEND_STATUS_PENDING);
  567. // PostPendTask(PEND_RMCP_PORT_CHANGE,(uint8_t*)&(pSetLanReq->ConfigData.PrimaryRMCPPort),
  568. // sizeof(pSetLanReq->ConfigData.PrimaryRMCPPort),(pSetLanReq->ChannelNum & 0x0F),BMCInst);
  569. // break;
  570. // case LAN_PARAM_SEC_RMCP_PORT:
  571. // /* Returning Invalid error message */
  572. // *pRes = CC_PARAM_NOT_SUPPORTED;
  573. // return sizeof (uint8_t);
  574. // /*pPMConfig->LANConfig[EthIndex].SecondaryPort = ipmitoh_u16 (pSetLanReq->ConfigData.SecondaryPort);*/
  575. // break;
  576. // case LAN_PARAM_BMC_GENERATED_ARP_CONTROL:
  577. // currBmcGenArpCtrl = pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl;
  578. // if(currBmcGenArpCtrl != pSetLanReq->ConfigData.BMCGeneratedARPControl)
  579. // pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl = pSetLanReq->ConfigData.BMCGeneratedARPControl;
  580. // if((ENABLE_ARP_RESPONSES & currBmcGenArpCtrl) !=
  581. // (ENABLE_ARP_RESPONSES & pSetLanReq->ConfigData.BMCGeneratedARPControl))
  582. // {
  583. // UpdateArpStatus(EthIndex, BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning, BMCInst);
  584. // }
  585. // if(!(GRATIUTOUS_ENABLE_MASK & currBmcGenArpCtrl) &&
  586. // (GRATIUTOUS_ENABLE_MASK & pSetLanReq->ConfigData.BMCGeneratedARPControl))
  587. // {
  588. // /* Create a thread to Send Gratuitous ARP Packet */
  589. // pLANArg = malloc(sizeof(BMCArg));
  590. // pLANArg->BMCInst = BMCInst;
  591. // pLANArg->Len = strlen((char *)&EthIndex);
  592. // pLANArg->Argument = malloc(pLANArg->Len);
  593. // memcpy(pLANArg->Argument,(char *)&EthIndex,pLANArg->Len);
  594. // OS_CREATE_THREAD ((void *)GratuitousARPTask,(void *)pLANArg, NULL);
  595. // }
  596. // break;
  597. // case LAN_PARAM_GRATITIOUS_ARP_INTERVAL:
  598. // pBMCInfo->LANCfs[EthIndex].GratitousARPInterval =
  599. // pSetLanReq->ConfigData.GratitousARPInterval;
  600. // break;
  601. // case LAN_PARAM_DEFAULT_GATEWAY_IP:
  602. // pendStatus = GetPendStatus(PEND_OP_SET_GATEWAY);
  603. // if(pendStatus == PEND_STATUS_PENDING)
  604. // {
  605. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  606. // return sizeof (uint8_t);
  607. // }
  608. // /*Returning valid completion code in case of attempt to set default gateway ip in DHCP mode */
  609. // if(pBMCInfo->LANCfs[EthIndex].IPAddrSrc == DHCP_IP_SOURCE)
  610. // {
  611. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  612. // return sizeof (uint8_t);
  613. // }
  614. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  615. // if(memcmp ( NWConfig.Gateway, pSetLanReq->ConfigData.DefaultGatewayIPAddr, IP_ADDR_LEN ) == 0)
  616. // {
  617. // TCRIT("Same Gateway, do nothing\n");
  618. // _fmemcpy(pBMCInfo->LANCfs[EthIndex].DefaultGatewayIPAddr, pSetLanReq->ConfigData.DefaultGatewayIPAddr,IP_ADDR_LEN);
  619. // break;
  620. // }
  621. // if(IPAddrCheck(pSetLanReq->ConfigData.DefaultGatewayIPAddr,LAN_PARAM_DEFAULT_GATEWAY_IP))
  622. // {
  623. // *pRes = CC_INV_DATA_FIELD;
  624. // return sizeof (uint8_t);
  625. // }
  626. // _fmemcpy ((uint8_t*)&GWIp,pSetLanReq->ConfigData.DefaultGatewayIPAddr, IP_ADDR_LEN);
  627. // _fmemcpy ((uint8_t*)&Subnetmask,&NWConfig.Mask[0],IP_ADDR_LEN);
  628. // _fmemcpy ((uint8_t*)&IPAddr,&NWConfig.IPAddr[0], IP_ADDR_LEN);
  629. // /* Allowing When the Default Gateway is Zero without validation to clear the Default Gateway */
  630. // if(GWIp != 0)
  631. // {
  632. // _fmemcpy ((uint8_t*)&Subnetmask,pBMCInfo->LANCfs[EthIndex].SubNetMask,IP_ADDR_LEN);
  633. // _fmemcpy ((uint8_t*)&IPAddr,pBMCInfo->LANCfs[EthIndex].IPAddr, IP_ADDR_LEN);
  634. // if((IPAddr & Subnetmask ) != (GWIp & Subnetmask))
  635. // {
  636. // IPMI_DBG_PRINT("\n Default GatewayIP to set is not valid \n");
  637. // *pRes = CC_INV_DATA_FIELD;
  638. // return sizeof (uint8_t);
  639. // }
  640. // }
  641. // _fmemcpy (NWConfig.Gateway,pSetLanReq->ConfigData.DefaultGatewayIPAddr, IP_ADDR_LEN);
  642. // LOCK_BMC_SHARED_MEM(BMCInst);
  643. // _fmemcpy(pBMCInfo->LANCfs[EthIndex].DefaultGatewayIPAddr,
  644. // pSetLanReq->ConfigData.DefaultGatewayIPAddr,IP_ADDR_LEN);
  645. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  646. // SetPendStatus(PEND_OP_SET_GATEWAY,PEND_STATUS_PENDING);
  647. // PostPendTask(PEND_OP_SET_GATEWAY,(uint8_t*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  648. // break;
  649. // case LAN_PARAM_DEFAULT_GATEWAY_MAC:
  650. // pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  651. // return sizeof(*pRes);
  652. // break;
  653. // case LAN_PARAM_BACKUP_GATEWAY_IP:
  654. // nwReadNWCfg_v4_v6( &NWConfig,&NWConfig6, netindex,g_corefeatures.global_ipv6);
  655. // _fmemcpy ((uint8_t*)&GWIp,pSetLanReq->ConfigData.BackupGatewayIPAddr, IP_ADDR_LEN);
  656. // _fmemcpy ((uint8_t*)&Subnetmask,&NWConfig.Mask[0],IP_ADDR_LEN);
  657. // _fmemcpy ((uint8_t*)&IPAddr,&NWConfig.IPAddr[0], IP_ADDR_LEN);
  658. // if(GWIp != 0)
  659. // {
  660. // if((IPAddr & Subnetmask ) != (GWIp & Subnetmask))
  661. // {
  662. // IPMI_DBG_PRINT("\n Backup GatewayIP to set is not valid \n");
  663. // *pRes = CC_INV_DATA_FIELD;
  664. // return sizeof (uint8_t);
  665. // }
  666. // }
  667. // LOCK_BMC_SHARED_MEM(BMCInst);
  668. // _fmemcpy (pBMCInfo->LANCfs[EthIndex].BackupGatewayIPAddr,
  669. // pSetLanReq->ConfigData.BackupGatewayIPAddr, IP_ADDR_LEN);
  670. // nwSetBkupGWyAddr(pSetLanReq->ConfigData.BackupGatewayIPAddr,netindex);
  671. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  672. // break;
  673. // case LAN_PARAM_BACKUP_GATEWAY_MAC:
  674. // LOCK_BMC_SHARED_MEM(BMCInst);
  675. // _fmemcpy (pBMCInfo->LANCfs[EthIndex].BackupGatewayMACAddr,
  676. // pSetLanReq->ConfigData.BackupGatewayMACAddr, MAC_ADDR_LEN);
  677. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  678. // break;
  679. // case LAN_PARAM_COMMUNITY_STRING:
  680. // if (g_PDKHandle[PDK_SETSNMPCOMMUNITYNAME] != NULL )
  681. // {
  682. // if(((int(*)(uint8_t *, uint8_t,int))(g_PDKHandle[PDK_SETSNMPCOMMUNITYNAME]))(pSetLanReq->ConfigData.CommunityStr,MAX_COMM_STRING_SIZE, BMCInst)==0)
  683. // break;
  684. // }
  685. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->PefConfig.PEFSharedMemMutex, WAIT_INFINITE);
  686. // _fmemcpy (pBMCInfo->LANCfs[EthIndex].CommunityStr,
  687. // pSetLanReq->ConfigData.CommunityStr, MAX_COMM_STRING_SIZE);
  688. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
  689. // break;
  690. // case LAN_PARAM_DEST_NUM:
  691. // pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  692. // return sizeof(uint8_t);
  693. // case LAN_PARAM_SELECT_DEST_TYPE:
  694. // // if (pSetLanReq->ConfigData.DestType.SetSelect > NUM_LAN_DESTINATION)
  695. // if (pSetLanReq->ConfigData.DestType.SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
  696. // {
  697. // *pRes = CC_PARAM_OUT_OF_RANGE;
  698. // return sizeof (*pRes);
  699. // }
  700. // if (0 == pSetLanReq->ConfigData.DestType.SetSelect)
  701. // {
  702. // LOCK_BMC_SHARED_MEM(BMCInst);
  703. // _fmemcpy (&pSharedMem->VolLANDestType[EthIndex],
  704. // &pSetLanReq->ConfigData.DestType, sizeof(LANDestType_T));
  705. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  706. // }
  707. // else
  708. // {
  709. // LOCK_BMC_SHARED_MEM(BMCInst);
  710. // _fmemcpy (&pBMCInfo->LANCfs[EthIndex].DestType [pSetLanReq->ConfigData.DestType.SetSelect - 1],
  711. // &pSetLanReq->ConfigData.DestType, sizeof(LANDestType_T));
  712. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  713. // }
  714. // break;
  715. // case LAN_PARAM_SELECT_DEST_ADDR:
  716. // pendStatus = GetPendStatus(PEND_OP_SET_GATEWAY);
  717. // if(pendStatus == PEND_STATUS_PENDING)
  718. // {
  719. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  720. // return sizeof (uint8_t);
  721. // }
  722. // // if (pSetLanReq->ConfigData.DestAddr.SetSelect > NUM_LAN_DESTINATION)
  723. // if (pSetLanReq->ConfigData.DestType.SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
  724. // {
  725. // *pRes = CC_PARAM_OUT_OF_RANGE ;
  726. // return sizeof (*pRes);
  727. // }
  728. // if (0 == pSetLanReq->ConfigData.DestAddr.SetSelect)
  729. // {
  730. // LOCK_BMC_SHARED_MEM(BMCInst);
  731. // _fmemcpy (&pSharedMem->VolLANDest[EthIndex],
  732. // &pSetLanReq->ConfigData.DestAddr, sizeof(LANDestAddr_T));
  733. // memset(pSharedMem->VolLANv6Dest,0,sizeof(LANDestv6Addr_T));
  734. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  735. // }
  736. // else
  737. // {
  738. // LOCK_BMC_SHARED_MEM(BMCInst);
  739. // _fmemcpy (&pBMCInfo->LANCfs[EthIndex].DestAddr [pSetLanReq->ConfigData.DestAddr.SetSelect - 1],
  740. // &pSetLanReq->ConfigData.DestAddr, sizeof(LANDestAddr_T));
  741. // memset( &pBMCInfo->LANCfs[EthIndex].Destv6Addr [pSetLanReq->ConfigData.Destv6Addr.SetSelect -1], 0 ,
  742. // sizeof(LANDestv6Addr_T));
  743. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  744. // }
  745. // /* Setting BackupGw to DefaultGw as per request to send trap */
  746. // if(pSetLanReq->ConfigData.DestAddr.GateWayUse == 1)
  747. // {
  748. // IPMI_DBG_PRINT("Setting Backupgw to Defaultgwip as per Request \n");
  749. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  750. // LOCK_BMC_SHARED_MEM(BMCInst);
  751. // _fmemcpy(NWConfig.Gateway,pBMCInfo->LANCfs[EthIndex].BackupGatewayIPAddr,IP_ADDR_LEN);
  752. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  753. // SetPendStatus(PEND_OP_SET_GATEWAY,PEND_STATUS_PENDING);
  754. // PostPendTask(PEND_OP_SET_GATEWAY,(uint8_t*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F),BMCInst);
  755. // }
  756. // break;
  757. // case LAN_PARAM_VLAN_ID:
  758. // if( pBMCInfo->IpmiConfig.VLANIfcSupport == 1)
  759. // {
  760. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  761. // if((pSetLanReq->ConfigData.VLANID & VLAN_MASK_BIT) == VLAN_MASK_BIT) /* checks for VLAN enable bit*/
  762. // {
  763. // pendStatus = GetPendStatus(PEND_OP_SET_VLAN_ID);
  764. // if(pendStatus == PEND_STATUS_PENDING)
  765. // {
  766. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  767. // return sizeof (uint8_t);
  768. // }
  769. // vlanID = (pSetLanReq->ConfigData.VLANID & 0xfff); /* get the vlan d from the data */
  770. // for(i=0;i<sizeof(InvalidVlanID)/sizeof(INT16U);i++)
  771. // {
  772. // if(InvalidVlanID[i] != vlanID)
  773. // {
  774. // continue;
  775. // }
  776. // else /*invalid vlan id */
  777. // {
  778. // *pRes = CC_INV_DATA_FIELD ;
  779. // return sizeof (*pRes);
  780. // }
  781. // }
  782. // if ( NWConfig.VLANID != 0) /* checks if vlan id already present */
  783. // {
  784. // if(NWConfig.VLANID == vlanID)
  785. // {
  786. // TCRIT("Currently configured vlan id and incoming set vlan id are same thus, do nothing\n");
  787. // break;
  788. // }
  789. // memset(IfcName,0,sizeof(IfcName));
  790. // if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
  791. // {
  792. // TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
  793. // *pRes = CC_INV_DATA_FIELD ;
  794. // return sizeof (*pRes);
  795. // }
  796. // sprintf(VLANInterfaceName, "%s.%d", IfcName, (int)(NWConfig.VLANID));
  797. // if (0 == NwInterfacePresenceCheck (VLANInterfaceName))
  798. // {
  799. // pendStatus = GetPendStatus(PEND_OP_SET_VLAN_ID);
  800. // if(pendStatus == PEND_STATUS_PENDING)
  801. // {
  802. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  803. // return sizeof (uint8_t);
  804. // }
  805. // SetPendStatus(PEND_OP_DECONFIG_VLAN_IFC,PEND_STATUS_PENDING);
  806. // PostPendTask(PEND_OP_DECONFIG_VLAN_IFC,(uint8_t*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  807. // pBMCInfo->LANCfs[EthIndex].VLANPriority =0;
  808. // }
  809. // }
  810. // NWConfig.VLANID=vlanID;
  811. // SetPendStatus(PEND_OP_SET_VLAN_ID,PEND_STATUS_PENDING);
  812. // PostPendTask(PEND_OP_SET_VLAN_ID,(uint8_t*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  813. // pBMCInfo->LANCfs[EthIndex].VLANID = pSetLanReq->ConfigData.VLANID;
  814. // }
  815. // else /* Vlan Bit is Disabled */
  816. // {
  817. // if(NWConfig.VLANID==0) /* Vlan id is disabled */
  818. // {
  819. // if((pSetLanReq->ConfigData.VLANID & 0xfff)!=0)
  820. // {
  821. // pBMCInfo->LANCfs[EthIndex].VLANID = pSetLanReq->ConfigData.VLANID;
  822. // }
  823. // if((pSetLanReq->ConfigData.VLANID & 0xfff)==0)
  824. // {
  825. // if((pBMCInfo->LANCfs[EthIndex].VLANID & 0xfff)!=0)
  826. // {
  827. // pBMCInfo->LANCfs[EthIndex].VLANID = pSetLanReq->ConfigData.VLANID;
  828. // }
  829. // }
  830. // }
  831. // else /* Vlan ID is enable. so deconfigure it */
  832. // {
  833. // memset(IfcName,0,sizeof(IfcName));
  834. // if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
  835. // {
  836. // TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
  837. // *pRes = CC_INV_DATA_FIELD ;
  838. // return sizeof (*pRes);
  839. // }
  840. // sprintf(VLANInterfaceName, "%s.%d", IfcName, (int)(NWConfig.VLANID));
  841. // if (0 == NwInterfacePresenceCheck (VLANInterfaceName))
  842. // {
  843. // pendStatus = GetPendStatus(PEND_OP_SET_VLAN_ID);
  844. // if(pendStatus == PEND_STATUS_PENDING)
  845. // {
  846. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  847. // return sizeof (uint8_t);
  848. // }
  849. // SetPendStatus(PEND_OP_DECONFIG_VLAN_IFC,PEND_STATUS_PENDING);
  850. // PostPendTask(PEND_OP_DECONFIG_VLAN_IFC,(uint8_t*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  851. // pBMCInfo->LANCfs[EthIndex].VLANPriority =0;
  852. // }
  853. // pendStatus = GetPendStatus(PEND_OP_SET_SOURCE);
  854. // if(pendStatus == PEND_STATUS_PENDING)
  855. // {
  856. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  857. // return sizeof (uint8_t);
  858. // }
  859. // //NWConfig.VLANID=0;
  860. // NWConfig.CfgMethod = pBMCInfo->LANCfs[EthIndex].IPAddrSrc;
  861. // SetPendStatus(PEND_OP_SET_SOURCE,PEND_STATUS_PENDING);
  862. // PostPendTask(PEND_OP_SET_SOURCE,(uint8_t*) &NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  863. // pBMCInfo->LANCfs[EthIndex].VLANID = pSetLanReq->ConfigData.VLANID;
  864. // }
  865. // }
  866. // }
  867. // else
  868. // {
  869. // pSetLanRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  870. // return sizeof(uint8_t);
  871. // }
  872. // break;
  873. // case LAN_PARAM_VLAN_PRIORITY:
  874. // if( pBMCInfo->IpmiConfig.VLANIfcSupport == 1)
  875. // {
  876. // if((pBMCInfo->LANCfs[EthIndex].VLANID & VLAN_MASK_BIT) != VLAN_MASK_BIT) /* checks for VLAN enable bit*/
  877. // {
  878. // if(g_corefeatures.vlan_priorityset == ENABLED)
  879. // {
  880. // if(pSetLanReq->ConfigData.VLANPriority > 7 )
  881. // {
  882. // TCRIT(" VLAN Priority value should be 0-7 \n");
  883. // *pRes = CC_INV_DATA_FIELD ;
  884. // return sizeof (*pRes);
  885. // }
  886. // if(ReadVLANFile(VLAN_PRIORITY_SETTING_STR, PriorityLevel) == -1)
  887. // {
  888. // return -1;
  889. // }
  890. // if(WriteVLANFile(VLAN_PRIORITY_SETTING_STR, PriorityLevel, netindex,pSetLanReq->ConfigData.VLANPriority) == -1)
  891. // {
  892. // return -1;
  893. // }
  894. // pBMCInfo->LANCfs[EthIndex].VLANPriority = pSetLanReq->ConfigData.VLANPriority;
  895. // }
  896. // else
  897. // {
  898. // TCRIT(" VLAN is not Configured \n");
  899. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  900. // return sizeof (*pRes);
  901. // }
  902. // }
  903. // else
  904. // {
  905. // if(pSetLanReq->ConfigData.VLANPriority > 7 )
  906. // {
  907. // TCRIT(" VLAN Priority value should be 0-7 \n");
  908. // *pRes = CC_INV_DATA_FIELD ;
  909. // return sizeof (*pRes);
  910. // }
  911. // if(ReadVLANFile(VLAN_PRIORITY_SETTING_STR, PriorityLevel) == -1)
  912. // {
  913. // return -1;
  914. // }
  915. // if(WriteVLANFile(VLAN_PRIORITY_SETTING_STR, PriorityLevel, netindex,pSetLanReq->ConfigData.VLANPriority) == -1)
  916. // {
  917. // return -1;
  918. // }
  919. // pBMCInfo->LANCfs[EthIndex].VLANPriority = pSetLanReq->ConfigData.VLANPriority;
  920. // vlanID = (pBMCInfo->LANCfs[EthIndex].VLANID & 0xfff);
  921. // memset(IfcName,0,sizeof(IfcName));
  922. // if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
  923. // {
  924. // TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
  925. // *pRes = CC_INV_DATA_FIELD;
  926. // return sizeof(*pRes);
  927. // }
  928. // /*vconfig set_egress_map <valninterface> <skb_buffer> <vlan-priority>*/
  929. // sprintf(cmdSetPriority,"vconfig set_egress_map %s.%d 0 %d",IfcName,vlanID,pSetLanReq->ConfigData.VLANPriority);
  930. // if(((retValue = safe_system(cmdSetPriority)) < 0))
  931. // {
  932. // TCRIT("ERROR %d: Set VLAN Priority failed\n",retValue);
  933. // }
  934. // /*
  935. // * Set priority of IPMI commands.
  936. // * The skb->priority value of IPMI command will be modified by TOS option.
  937. // * So, use the mapping table to get the current value.
  938. // */
  939. // memset(&cmdSetPriority,0,sizeof(cmdSetPriority));
  940. // TOS = pBMCInfo->LANCfs[EthIndex].Ipv4HdrParam.TypeOfService;
  941. // SkbPriority = IP_TOS2PRIO[IPTOS_TOS(TOS)>>1];
  942. // sprintf(cmdSetPriority,"vconfig set_egress_map %s.%d %d %d",IfcName,vlanID,SkbPriority,pSetLanReq->ConfigData.VLANPriority);
  943. // if(((retValue = safe_system(cmdSetPriority)) < 0))
  944. // {
  945. // TCRIT("ERROR %d: Set VLAN IPMI Priority failed\n",retValue);
  946. // }
  947. // }
  948. // }
  949. // else
  950. // {
  951. // pSetLanRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  952. // return sizeof(uint8_t);
  953. // }
  954. // break;
  955. // case LAN_PARAM_CIPHER_SUITE_ENTRY_SUP:
  956. // pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  957. // return sizeof(uint8_t);
  958. // case LAN_PARAM_CIPHER_SUITE_ENTRIES:
  959. // pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  960. // return sizeof(uint8_t);
  961. // break;
  962. // case LAN_PARAM_CIPHER_SUITE_PRIV_LEVELS:
  963. // LOCK_BMC_SHARED_MEM(BMCInst);
  964. // _fmemcpy (pBMCInfo->LANCfs[EthIndex].CipherSuitePrivLevels,
  965. // pSetLanReq->ConfigData.CipherSuitePrivLevels, MAX_NUM_CIPHER_SUITE_PRIV_LEVELS);
  966. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  967. // break;
  968. // case LAN_PARAM_VLAN_TAGS:
  969. // if (0 == pSetLanReq->ConfigData.DestAddr.SetSelect)
  970. // {
  971. // LOCK_BMC_SHARED_MEM(BMCInst);
  972. // _fmemcpy(&pSharedMem->VLANDestTag,
  973. // ((_NEAR_ uint8_t*)&pSetLanReq->ConfigData) + 1, sizeof(VLANDestTags_T));
  974. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  975. // }
  976. // else
  977. // {
  978. // if (pSetLanReq->ConfigData.DestAddr.SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest)
  979. // {
  980. // pSetLanRes->CompletionCode = CC_PARAM_OUT_OF_RANGE;
  981. // return sizeof (uint8_t);
  982. // }
  983. // LOCK_BMC_SHARED_MEM(BMCInst);
  984. // _fmemcpy(&pBMCInfo->LANCfs[EthIndex].VLANDestTags [pSetLanReq->ConfigData.DestAddr.SetSelect - 1],
  985. // ((_NEAR_ uint8_t*)&pSetLanReq->ConfigData) + 1, sizeof(VLANDestTags_T));
  986. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  987. // }
  988. // break;
  989. // case LAN_PARAMS_BAD_PASSWORD_THRESHOLD:
  990. // ClearUserLockAttempts(LAN_CHANNEL_BADP,BMCInst);
  991. // LOCK_BMC_SHARED_MEM(BMCInst);
  992. // _fmemcpy(&pBMCInfo->LANCfs[EthIndex].BadPasswd,
  993. // &pSetLanReq->ConfigData.BadPasswd,sizeof(BadPassword_T));
  994. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  995. // break;
  996. // case LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR:
  997. // if (pSetLanReq->ConfigData.DestType.SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
  998. // {
  999. // TCRIT("Invalid data for SetSelect");
  1000. // *pRes = CC_INV_DATA_FIELD ;
  1001. // return sizeof (*pRes);
  1002. // }
  1003. // /*Validate the IPv6 address*/
  1004. // if(0 != IsValidGlobalIPv6Addr((struct in6_addr*)&pSetLanReq->ConfigData.Destv6Addr.IPAddr))
  1005. // {
  1006. // TCRIT("Invalid Global IPv6 Address\n");
  1007. // *pRes = CC_INV_DATA_FIELD;
  1008. // return sizeof(uint8_t);
  1009. // }
  1010. // if (0 == pSetLanReq->ConfigData.Destv6Addr.SetSelect)
  1011. // {
  1012. // LOCK_BMC_SHARED_MEM(BMCInst);
  1013. // _fmemcpy (&pSharedMem->VolLANv6Dest,
  1014. // &pSetLanReq->ConfigData.Destv6Addr, sizeof(LANDestv6Addr_T));
  1015. // memset(pSharedMem->VolLANDest,0,sizeof(LANDestAddr_T));
  1016. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1017. // }
  1018. // else
  1019. // {
  1020. // LOCK_BMC_SHARED_MEM(BMCInst);
  1021. // _fmemcpy (&pBMCInfo->LANCfs[EthIndex].Destv6Addr[pSetLanReq->ConfigData.Destv6Addr.SetSelect - 1],
  1022. // &pSetLanReq->ConfigData.Destv6Addr, sizeof(LANDestv6Addr_T));
  1023. // memset(&pBMCInfo->LANCfs[EthIndex].DestAddr[pSetLanReq->ConfigData.DestAddr.SetSelect - 1],0,sizeof(LANDestAddr_T));
  1024. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1025. // }
  1026. // TDBG("\n SetLanconfig: Setting SNMPv6 configuration done..\n");
  1027. // break;
  1028. // case LAN_PARAMS_AMI_OEM_ENABLE_SET_MAC: //194
  1029. // NIC_Count = g_coremacros.global_nic_count;
  1030. // if (ReqLen != 1)
  1031. // pSetLanRes->CompletionCode = CC_REQ_INV_LEN;
  1032. // else if (pSetLanReq->ConfigData.EthIndex > ( NIC_Count- 1))
  1033. // pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
  1034. // else
  1035. // {
  1036. // enableSetMACAddr = TRUE;
  1037. // macEthIndex = pSetLanReq->ConfigData.EthIndex;
  1038. // pSetLanRes->CompletionCode = CC_NORMAL;
  1039. // }
  1040. // return sizeof(*pSetLanRes);
  1041. // case LAN_PARAMS_AMI_OEM_IPV6_ENABLE:
  1042. // pendStatus = GetPendStatus(PEND_OP_SET_IPV6_ENABLE);
  1043. // if (pendStatus == PEND_STATUS_PENDING)
  1044. // {
  1045. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1046. // return sizeof (uint8_t);
  1047. // }
  1048. // TDBG("\n Entered in LAN_PARAMS_AMI_OEM_IPV6_ENABLE \n");
  1049. // if ( pBMCInfo->LANCfs[EthIndex].IPv6_Enable == pSetLanReq->ConfigData.IPv6_Enable)
  1050. // {
  1051. // TCRIT("LAN or VLAN - the current state is the same \n");
  1052. // break;
  1053. // }
  1054. // pBMCInfo->LANCfs[EthIndex].IPv6_Enable= pSetLanReq->ConfigData.IPv6_Enable;
  1055. // NWConfig6.enable= pSetLanReq->ConfigData.IPv6_Enable;
  1056. // SetPendStatus(PEND_OP_SET_IPV6_ENABLE,PEND_STATUS_PENDING);
  1057. // PostPendTask(PEND_OP_SET_IPV6_ENABLE,(uint8_t*) &NWConfig6,sizeof(NWConfig6),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  1058. // break;
  1059. // case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE:
  1060. // pendStatus = GetPendStatus(PEND_OP_SET_IPV6_IP_ADDR_SOURCE);
  1061. // if (pendStatus == PEND_STATUS_PENDING)
  1062. // {
  1063. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1064. // return sizeof (uint8_t);
  1065. // }
  1066. // TDBG("\n Entered in LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE \n");
  1067. // /* check for IPv6 enable state */
  1068. // if ( pBMCInfo->LANCfs[EthIndex].IPv6_Enable != 1)
  1069. // {
  1070. // TCRIT("IPv6 is not enabled yet... \n");
  1071. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1072. // return sizeof (uint8_t);
  1073. // }
  1074. // if ((pSetLanReq->ConfigData.IPv6_IPAddrSrc > BMC_OTHER_SOURCE)
  1075. // ||(pSetLanReq->ConfigData.IPv6_IPAddrSrc == UNSPECIFIED_IP_SOURCE))
  1076. // {
  1077. // *pRes = CC_INV_DATA_FIELD;
  1078. // return sizeof (uint8_t);
  1079. // }
  1080. // else if((pSetLanReq->ConfigData.IPv6_IPAddrSrc == BIOS_IP_SOURCE)
  1081. // || (pSetLanReq->ConfigData.IPv6_IPAddrSrc == BMC_OTHER_SOURCE))
  1082. // {
  1083. // /* we only support DHCP and Static IP source */
  1084. // *pRes = CC_INV_DATA_FIELD;
  1085. // return sizeof (uint8_t);
  1086. // }
  1087. // if (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == pSetLanReq->ConfigData.IPv6_IPAddrSrc )
  1088. // {
  1089. // TCRIT("LAN or VLAN if current SRC is DHCP/Static and incoming SRC is DHCP/Static, do nothing\n");
  1090. // break;
  1091. // }
  1092. // pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc = pSetLanReq->ConfigData.IPv6_IPAddrSrc ;
  1093. // if ( (pSetLanReq->ConfigData.IPv6_IPAddrSrc == STATIC_IP_SOURCE ) || (pSetLanReq->ConfigData.IPv6_IPAddrSrc == DHCP_IP_SOURCE ) )
  1094. // {
  1095. // NWConfig6.CfgMethod = pSetLanReq->ConfigData.IPv6_IPAddrSrc;
  1096. // SetPendStatus(PEND_OP_SET_IPV6_IP_ADDR_SOURCE,PEND_STATUS_PENDING);
  1097. // PostPendTask(PEND_OP_SET_IPV6_IP_ADDR_SOURCE,(uint8_t*) &NWConfig6,sizeof(NWConfig6),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  1098. // }
  1099. // break;
  1100. // case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR:
  1101. // pendStatus = GetPendStatus(PEND_OP_SET_IPV6_IP_ADDR);
  1102. // if (pendStatus == PEND_STATUS_PENDING)
  1103. // {
  1104. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1105. // return sizeof (uint8_t);
  1106. // }
  1107. // TDBG("\n Entered in LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR \n");
  1108. // /* check for IPv6 enable state */
  1109. // if ( pBMCInfo->LANCfs[EthIndex].IPv6_Enable != 1)
  1110. // {
  1111. // TCRIT("IPv6 is not enabled yet... \n");
  1112. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1113. // return sizeof (uint8_t);
  1114. // }
  1115. // /* Do IP address source check */
  1116. // if( pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == DHCP_IP_SOURCE)
  1117. // {
  1118. // TCRIT("IPv6 Address source is currently in DHCP \n");
  1119. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1120. // return sizeof (uint8_t);
  1121. // }
  1122. // /*Validate the Index value*/
  1123. // if(pSetLanReq->ConfigData.IPv6Addr.IPv6_Cntr & 0xF0)
  1124. // {
  1125. // *pRes = CC_INV_DATA_FIELD;
  1126. // return sizeof(uint8_t);
  1127. // }
  1128. // /*Validate the IPv6 address*/
  1129. // if(0 != IsValidGlobalIPv6Addr((struct in6_addr*)&pSetLanReq->ConfigData.IPv6Addr.IPv6_IPAddr))
  1130. // {
  1131. // TCRIT("Invalid Global IPv6 Address\n");
  1132. // *pRes = CC_INV_DATA_FIELD;
  1133. // return sizeof(uint8_t);
  1134. // }
  1135. // /*Validate the duplicate IPv6 Address*/
  1136. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1137. // for(i=0;i<MAX_IPV6ADDRS;i++)
  1138. // {
  1139. // /*Use can set the same IPv6 address for same index. To satisfy the WebServer*/
  1140. // if((memcmp(NWConfig6.GlobalIPAddr[i],pSetLanReq->ConfigData.IPv6Addr.IPv6_IPAddr,IP6_ADDR_LEN) == 0) && pSetLanReq->ConfigData.IPv6Addr.IPv6_Cntr != i)
  1141. // {
  1142. // *pRes = CC_INV_DATA_FIELD;
  1143. // return sizeof(uint8_t);
  1144. // }
  1145. // }
  1146. // _fmemcpy(pBMCInfo->LANCfs[EthIndex].IPv6_IPAddr[pSetLanReq->ConfigData.IPv6Addr.IPv6_Cntr], pSetLanReq->ConfigData.IPv6Addr.IPv6_IPAddr, IP6_ADDR_LEN );
  1147. // SetPendStatus(PEND_OP_SET_IPV6_IP_ADDR,PEND_STATUS_PENDING);
  1148. // PostPendTask(PEND_OP_SET_IPV6_IP_ADDR, (uint8_t*) &pSetLanReq->ConfigData.IPv6Addr,\
  1149. // sizeof (IPv6Addr_T),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  1150. // break;
  1151. // case LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH:
  1152. // pendStatus = GetPendStatus(PEND_OP_SET_IPV6_PREFIX_LENGTH);
  1153. // if (pendStatus == PEND_STATUS_PENDING)
  1154. // {
  1155. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1156. // return sizeof (uint8_t);
  1157. // }
  1158. // TDBG("\n Entered in LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH \n");
  1159. // /* check for IPv6 enable state */
  1160. // if ( pBMCInfo->LANCfs[EthIndex].IPv6_Enable != 1)
  1161. // {
  1162. // TCRIT("IPv6 is not enabled yet... \n");
  1163. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1164. // return sizeof (uint8_t);
  1165. // }
  1166. // /* Do IP address source check */
  1167. // if( pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == DHCP_IP_SOURCE)
  1168. // {
  1169. // TCRIT("IPv6 Address source is currently in DHCP \n");
  1170. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1171. // return sizeof (uint8_t);
  1172. // }
  1173. // /*Validate the Index value*/
  1174. // if(pSetLanReq->ConfigData.IPv6Prefix.IPv6_Prepos & 0xF0)
  1175. // {
  1176. // *pRes = CC_INV_DATA_FIELD;
  1177. // return sizeof(uint8_t);
  1178. // }
  1179. // pBMCInfo->LANCfs[EthIndex].IPv6_PrefixLen[pSetLanReq->ConfigData.IPv6Prefix.IPv6_Prepos] = pSetLanReq->ConfigData.IPv6Prefix.IPv6_PrefixLen;
  1180. // SetPendStatus(PEND_OP_SET_IPV6_PREFIX_LENGTH,PEND_STATUS_PENDING);
  1181. // PostPendTask(PEND_OP_SET_IPV6_PREFIX_LENGTH,(uint8_t*) &pSetLanReq->ConfigData.IPv6Prefix, sizeof(IPv6Prefix_T),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  1182. // break;
  1183. // case LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP:
  1184. // pendStatus = GetPendStatus(PEND_OP_SET_IPV6_GATEWAY);
  1185. // if (pendStatus == PEND_STATUS_PENDING)
  1186. // {
  1187. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1188. // return sizeof (uint8_t);
  1189. // }
  1190. // TDBG("\n Entered in LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP \n");
  1191. // /* check for IPv6 enable state */
  1192. // if ( pBMCInfo->LANCfs[EthIndex].IPv6_Enable != 1)
  1193. // {
  1194. // TCRIT("IPv6 is not enabled yet... \n");
  1195. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1196. // return sizeof (uint8_t);
  1197. // }
  1198. // /* Do IP address source check */
  1199. // if( pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == DHCP_IP_SOURCE)
  1200. // {
  1201. // TCRIT("IPv6 Address source is currently in DHCP \n");
  1202. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1203. // return sizeof (uint8_t);
  1204. // }
  1205. // /*Validate the IPv6 address*/
  1206. // if(0 != IsValidGlobalIPv6Addr((struct in6_addr*)&pSetLanReq->ConfigData.IPv6_GatewayIPAddr))
  1207. // {
  1208. // TCRIT("Invalid Global IPv6 Address\n");
  1209. // *pRes = CC_INV_DATA_FIELD;
  1210. // return sizeof(uint8_t);
  1211. // }
  1212. // _fmemcpy( pBMCInfo->LANCfs[EthIndex].IPv6_GatewayIPAddr, pSetLanReq->ConfigData.IPv6_GatewayIPAddr, IP6_ADDR_LEN );
  1213. // _fmemcpy( NWConfig6.Gateway, pSetLanReq->ConfigData.IPv6_GatewayIPAddr, IP6_ADDR_LEN );
  1214. // SetPendStatus(PEND_OP_SET_IPV6_GATEWAY,PEND_STATUS_PENDING);
  1215. // PostPendTask(PEND_OP_SET_IPV6_GATEWAY,(uint8_t*) &NWConfig6,sizeof(NWConfig6),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  1216. // break;
  1217. // case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_EUI64:
  1218. // /* The first byte is the index and it should contain atleast one byte of IPv6 address and it cannot exceed 8 bytes incase of EUI-64 algo */
  1219. // if((ReqLen < 2) || (ReqLen > 9))
  1220. // {
  1221. // *pRes = CC_REQ_INV_LEN;
  1222. // return sizeof(uint8_t);
  1223. // }
  1224. // pendStatus = GetPendStatus(PEND_OP_SET_IPV6_IP_ADDR);
  1225. // if (pendStatus == PEND_STATUS_PENDING)
  1226. // {
  1227. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1228. // return sizeof (uint8_t);
  1229. // }
  1230. // TDBG("\n Entered in LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_EUI64 \n");
  1231. // /* Check for IPv6 enabled state */
  1232. // if(pBMCInfo->LANCfs[EthIndex].IPv6_Enable != 1)
  1233. // {
  1234. // TCRIT("IPv6 is not enabled yet... \n");
  1235. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1236. // return sizeof(uint8_t);
  1237. // }
  1238. // /* Do IP address source check */
  1239. // if(pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == DHCP_IP_SOURCE)
  1240. // {
  1241. // TCRIT("IPv6 Address source is currently in DHCP \n");
  1242. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1243. // return sizeof (uint8_t);
  1244. // }
  1245. // /*Validate the Index value*/
  1246. // if(pSetLanReq->ConfigData.IPv6Addr.IPv6_Cntr & 0xF0)
  1247. // {
  1248. // TCRIT("Index of the given IPv6 Address is invalid. \n");
  1249. // *pRes = CC_INV_DATA_FIELD;
  1250. // return sizeof(uint8_t);
  1251. // }
  1252. // /* The request may be of variable length, so fill the network prefix by appending zeros. This is to avoid garbage values */
  1253. // for(i = ReqLen-1; i<8; i++)
  1254. // {
  1255. // pSetLanReq->ConfigData.IPv6Addr.IPv6_IPAddr[i] = 0;
  1256. // }
  1257. // /* Generate the IPv6 address using EUI-64 algo */
  1258. // if(nwFormIPv6Addr_EUI64((uint8_t*) &pSetLanReq->ConfigData.IPv6Addr.IPv6_IPAddr, netindex, g_corefeatures.global_ipv6) != 0)
  1259. // {
  1260. // *pRes = CC_INV_DATA_FIELD;
  1261. // return sizeof(uint8_t);
  1262. // }
  1263. // /* Get the current network configuration settings */
  1264. // nwReadNWCfg_v4_v6(&NWConfig, &NWConfig6, netindex, g_corefeatures.global_ipv6);
  1265. // /*Validate the duplicate IPv6 Address*/
  1266. // for(i=0; i<MAX_IPV6ADDRS; i++)
  1267. // {
  1268. // /* User can set the same IPv6 address for same index to satisfy the WebServer */
  1269. // if((memcmp(NWConfig6.GlobalIPAddr[i], pSetLanReq->ConfigData.IPv6Addr.IPv6_IPAddr, IP6_ADDR_LEN) == 0) && pSetLanReq->ConfigData.IPv6Addr.IPv6_Cntr != i)
  1270. // {
  1271. // TCRIT("\n Error in setting the IPv6 address - Duplicate :( \n");
  1272. // *pRes = CC_INV_DATA_FIELD;
  1273. // return sizeof(uint8_t);
  1274. // }
  1275. // }
  1276. // _fmemcpy(pBMCInfo->LANCfs[EthIndex].IPv6_IPAddr[pSetLanReq->ConfigData.IPv6Addr.IPv6_Cntr], pSetLanReq->ConfigData.IPv6Addr.IPv6_IPAddr, IP6_ADDR_LEN);
  1277. // SetPendStatus(PEND_OP_SET_IPV6_IP_ADDR,PEND_STATUS_PENDING);
  1278. // PostPendTask(PEND_OP_SET_IPV6_IP_ADDR, (uint8_t*) &pSetLanReq->ConfigData.IPv6Addr, sizeof(IPv6Addr_T), (pSetLanReq->ChannelNum & 0x0F), BMCInst);
  1279. // break;
  1280. // case LAN_PARAMS_AMI_OEM_PHY_SETTINGS:
  1281. // if(ReqLen != 4)
  1282. // {
  1283. // pSetLanRes->CompletionCode = CC_REQ_INV_LEN;
  1284. // return sizeof(*pSetLanRes);
  1285. // }
  1286. // memset(IfcName, 0, sizeof(IfcName));
  1287. // if(GetIfcNameByIndex(EthIndex, IfcName) != 0)
  1288. // {
  1289. // TCRIT("Error in Getting Interface Name for the lan Index:%d\n",EthIndex);
  1290. // pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
  1291. // return sizeof(*pSetLanRes);
  1292. // }
  1293. // if(nwGetEthInformation(&PHYCfg, IfcName) == 0)
  1294. // {
  1295. // if(((PHYCfg.autoneg == pSetLanReq->ConfigData.PHYConfig.AutoNegotiationEnable) && (PHYCfg.speed == pSetLanReq->ConfigData.PHYConfig.Speed)
  1296. // && (PHYCfg.duplex == pSetLanReq->ConfigData.PHYConfig.Duplex)))
  1297. // {
  1298. // TDBG("There is no change in the link mode, ignoring the request for setting the speed/duplex.\n");
  1299. // break;
  1300. // }
  1301. // }
  1302. // else
  1303. // {
  1304. // pSetLanRes->CompletionCode = CC_UNSPECIFIED_ERR;
  1305. // return sizeof(*pSetLanRes);
  1306. // }
  1307. // if(pSetLanReq->ConfigData.PHYConfig.Speed != 0xFFFF && pSetLanReq->ConfigData.PHYConfig.Duplex != 0xFF)
  1308. // {
  1309. // if(IsLinkModeSupported(&PHYCfg,pSetLanReq->ConfigData.PHYConfig.Speed,pSetLanReq->ConfigData.PHYConfig.Duplex) <= 0)
  1310. // {
  1311. // TCRIT("Unsupported link mode \n");
  1312. // pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
  1313. // return sizeof(*pSetLanRes);
  1314. // }
  1315. // }
  1316. // SetPendStatus(PEND_OP_SET_SPEED, PEND_STATUS_PENDING);
  1317. // PostPendTask(PEND_OP_SET_SPEED, (uint8_t*) &(pSetLanReq->ConfigData.PHYConfig), sizeof(PHYConfig_T),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  1318. // break;
  1319. // case LAN_PARAMS_AMI_OEM_MTU_SETTINGS:
  1320. // if(ReqLen != 2)
  1321. // {
  1322. // pSetLanRes->CompletionCode = CC_REQ_INV_LEN;
  1323. // return sizeof(*pSetLanRes);
  1324. // }
  1325. // /* Setting MTU values less than 1280 disables IPv6,
  1326. // RFC 1280 recommends MTU value should be greater than 1200 for IPV6.
  1327. // so restricting MTU value b/w 1280 to 1500.*/
  1328. // if( (pSetLanReq->ConfigData.MTU_size < 1280) || (pSetLanReq->ConfigData.MTU_size > 1500) )
  1329. // {
  1330. // pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
  1331. // return sizeof(*pSetLanRes);
  1332. // }
  1333. // SetPendStatus(PEND_OP_SET_MTU_SIZE, PEND_STATUS_PENDING);
  1334. // PostPendTask(PEND_OP_SET_MTU_SIZE, (uint8_t*) &(pSetLanReq->ConfigData.MTU_size), sizeof(INT16U),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
  1335. // break;
  1336. // case LAN_PARAMS_SSI_OEM_2ND_PRI_ETH_MAC_ADDR:
  1337. // if(g_corefeatures.ssi_support == ENABLED)
  1338. // {
  1339. // pendStatus = GetPendStatus(PEND_OP_SET_MAC_ADDRESS);
  1340. // if(pendStatus == PEND_STATUS_PENDING)
  1341. // {
  1342. // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
  1343. // return sizeof (uint8_t);
  1344. // }
  1345. // if (!enableSetMACAddr)
  1346. // {
  1347. // pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  1348. // return sizeof(uint8_t);
  1349. // }
  1350. // else
  1351. // {
  1352. // EnableSetMACAddress_T macAddrEnabled;
  1353. // memset(&macAddrEnabled, 0, sizeof(EnableSetMACAddress_T));
  1354. // macAddrEnabled.EthIndex = 0x1; /* Specify the 2nd interface */
  1355. // memcpy(&macAddrEnabled.MACAddress, pSetLanReq->ConfigData.SSI2ndPriEthMACAddr, MAC_ADDR_LEN);
  1356. // SetPendStatus(PEND_OP_SET_MAC_ADDRESS, PEND_STATUS_PENDING);
  1357. // PostPendTask(PEND_OP_SET_MAC_ADDRESS, (uint8_t*)&macAddrEnabled, sizeof(EnableSetMACAddress_T), 0x1, BMCInst);
  1358. // }
  1359. // break;
  1360. // }
  1361. // else
  1362. // {
  1363. // pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1364. // return sizeof(uint8_t);
  1365. // }
  1366. // case LAN_PARAMS_SSI_OEM_LINK_CTRL:
  1367. // if(g_corefeatures.ssi_support == ENABLED)
  1368. // {
  1369. // pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM; /* Read Only */
  1370. // }
  1371. // else
  1372. // {
  1373. // pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1374. // }
  1375. // return sizeof(uint8_t);
  1376. // case LAN_PARAMS_SSI_OEM_CMM_IP_ADDR:
  1377. // if(g_corefeatures.ssi_support == ENABLED)
  1378. // {
  1379. // _fmemcpy(pBMCInfo->SSIConfig.CMMIPAddr, pSetLanReq->ConfigData.CMMIPAddr, IP_ADDR_LEN);
  1380. // FlushIPMI((uint8_t*)&pBMCInfo->SSIConfig, (uint8_t*)&pBMCInfo->SSIConfig, pBMCInfo->IPMIConfLoc.SSIConfigAddr,
  1381. // sizeof(SSIConfig_T), BMCInst);
  1382. // break;
  1383. // }
  1384. // else
  1385. // {
  1386. // pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1387. // return sizeof(uint8_t);
  1388. // }
  1389. // default:
  1390. // if(g_corefeatures.ncsi_cmd_support == ENABLED)
  1391. // {
  1392. // switch (pSetLanReq->ParameterSelect)
  1393. // {
  1394. // case LAN_PARAMS_AMI_OEM_NCSI_CONFIG_NUM:
  1395. // pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
  1396. // return sizeof(*pSetLanRes);
  1397. // case LAN_PARAMS_AMI_OEM_NCSI_SETTINGS:
  1398. // NIC_Count=g_coremacros.global_nic_count;
  1399. // if (ReqLen != 3)
  1400. // pSetLanRes->CompletionCode = CC_REQ_INV_LEN;
  1401. // else if (pSetLanReq->ConfigData.NCSIPortConfig.Interface >= NIC_Count)
  1402. // pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
  1403. // else
  1404. // {
  1405. // pendStatus = GetPendStatus(PEND_OP_SET_NCSI_CHANNEL_ID);
  1406. // if(pendStatus == PEND_STATUS_PENDING)
  1407. // {
  1408. // *pRes = CC_NODE_BUSY;
  1409. // return sizeof (uint8_t);
  1410. // }
  1411. // NCSIConfig_T configData;
  1412. // char interfaceName[8];
  1413. // memset(&configData, 0, sizeof(NCSIConfig_T));
  1414. // memset(interfaceName, 0, sizeof(interfaceName));
  1415. // snprintf(interfaceName, sizeof(interfaceName), "%s%d", "eth", pSetLanReq->ConfigData.NCSIPortConfig.Interface);
  1416. // if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
  1417. // pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
  1418. // else
  1419. // {
  1420. // configData.PackageId = pSetLanReq->ConfigData.NCSIPortConfig.PackageId;
  1421. // configData.ChannelId = pSetLanReq->ConfigData.NCSIPortConfig.ChannelId;
  1422. // if (NCSISetPortConfigByName(interfaceName, configData) != 0)
  1423. // pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
  1424. // else
  1425. // {
  1426. // SetPendStatus(PEND_OP_SET_NCSI_CHANNEL_ID, PEND_STATUS_PENDING);
  1427. // PostPendTask(PEND_OP_SET_NCSI_CHANNEL_ID, NULL, 0, 0, BMCInst);
  1428. // pSetLanRes->CompletionCode = CC_NORMAL;
  1429. // }
  1430. // }
  1431. // }
  1432. // return sizeof(*pSetLanRes);
  1433. // case LAN_PARAMS_AMI_OEM_NCSI_MODE_CHANGE:
  1434. // NIC_Count=g_coremacros.global_nic_count;
  1435. // if (ReqLen != 2)
  1436. // pSetLanRes->CompletionCode = CC_REQ_INV_LEN;
  1437. // else if (pSetLanReq->ConfigData.NCSIModeConfig.Interface >= NIC_Count)
  1438. // pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
  1439. // else
  1440. // {
  1441. // pendStatus = GetPendStatus(PEND_OP_SET_NCSI_MODE_CHANGE);
  1442. // if(pendStatus == PEND_STATUS_PENDING)
  1443. // {
  1444. // *pRes = CC_NODE_BUSY;
  1445. // return sizeof (uint8_t);
  1446. // }
  1447. // NCSIConfig_T configData;
  1448. // char interfaceName[8];
  1449. // memset(&configData, 0, sizeof(NCSIConfig_T));
  1450. // memset(interfaceName, 0, sizeof(interfaceName));
  1451. // snprintf(interfaceName, sizeof(interfaceName), "%s%d", "eth", pSetLanReq->ConfigData.NCSIModeConfig.Interface);
  1452. // if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
  1453. // pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
  1454. // else
  1455. // {
  1456. // configData.AutoSelect = pSetLanReq->ConfigData.NCSIModeConfig.NCSIMode;
  1457. // if (NCSISetPortConfigByName(interfaceName, configData) != 0)
  1458. // pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
  1459. // else
  1460. // {
  1461. // SetPendStatus(PEND_OP_SET_NCSI_MODE_CHANGE, PEND_STATUS_PENDING);
  1462. // PostPendTask(PEND_OP_SET_NCSI_MODE_CHANGE, NULL, 0, 0, BMCInst);
  1463. // pSetLanRes->CompletionCode = CC_NORMAL;
  1464. // }
  1465. // }
  1466. // }
  1467. // return sizeof(*pSetLanRes);
  1468. // case LAN_PARAMS_AMI_OEM_NCSI_EXTENSION:
  1469. // if ((0x20 == pSetLanReq->ConfigData.NCSIPHYConfigSet.Command) &&
  1470. // (g_corefeatures.ncsi_keep_phy_linkup_support == ENABLED))
  1471. // {
  1472. // NIC_Count=g_coremacros.global_nic_count;
  1473. // if (ReqLen != 3)
  1474. // pSetLanRes->CompletionCode = CC_REQ_INV_LEN;
  1475. // else if (pSetLanReq->ConfigData.NCSIPHYConfigSet.Interface >= NIC_Count)
  1476. // pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
  1477. // else
  1478. // {
  1479. // pendStatus = GetPendStatus(PEND_OP_SET_NCSI_VETOBIT);
  1480. // if(pendStatus == PEND_STATUS_PENDING)
  1481. // {
  1482. // *pRes = CC_NODE_BUSY;
  1483. // return sizeof (uint8_t);
  1484. // }
  1485. // NCSIConfig_T configData;
  1486. // char interfaceName[8];
  1487. // memset(&configData, 0, sizeof(NCSIConfig_T));
  1488. // memset(interfaceName, 0, sizeof(interfaceName));
  1489. // snprintf(interfaceName, sizeof(interfaceName), "%s%d", "eth", pSetLanReq->ConfigData.NCSIPHYConfigSet.Interface);
  1490. // if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
  1491. // pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
  1492. // else
  1493. // {
  1494. // configData.VetoBit= pSetLanReq->ConfigData.NCSIPHYConfigSet.VetoBit;
  1495. // if (NCSISetPortConfigByName(interfaceName, configData) != 0)
  1496. // pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
  1497. // else
  1498. // {
  1499. // SetPendStatus(PEND_OP_SET_NCSI_VETOBIT, PEND_STATUS_PENDING);
  1500. // PostPendTask(PEND_OP_SET_NCSI_VETOBIT, NULL, 0, 0, BMCInst);
  1501. // pSetLanRes->CompletionCode = CC_NORMAL;
  1502. // }
  1503. // }
  1504. // }
  1505. // }
  1506. // else
  1507. // {
  1508. // pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1509. // }
  1510. // return sizeof(*pSetLanRes);
  1511. // default:
  1512. // TDBG("In Valid Option\n");
  1513. // }
  1514. // }
  1515. // pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1516. // return sizeof(uint8_t);
  1517. // }
  1518. // pSetLanRes->CompletionCode = CC_NORMAL;
  1519. // if(g_PDKHandle[PDK_POSTSETLANPARAM] != NULL)
  1520. // {
  1521. // ((int(*)(uint8_t*, uint8_t, int))(g_PDKHandle[PDK_POSTSETLANPARAM]))(pReq, ReqLen, BMCInst);
  1522. // }
  1523. // FlushIPMI((uint8_t*)&pBMCInfo->LANCfs[0],(uint8_t*)&pBMCInfo->LANCfs[EthIndex],pBMCInfo->IPMIConfLoc.LANCfsAddr,
  1524. // sizeof(LANConfig_T),BMCInst);
  1525. // return sizeof(*pSetLanRes);
  1526. // }
  1527. // /*
  1528. // *@fn IPAddrCheck function
  1529. // *@brief It will validate the IP Address and net Mask
  1530. // *@param Addr - IP Address or net Mask
  1531. // *@param params - parameter data to validate
  1532. // */
  1533. // int IPAddrCheck(uint8_t *Addr,int params)
  1534. // {
  1535. // int i,maskcount=0,bitmask =0,j,bitcheck=0;
  1536. // for(i=0;i< IP_ADDR_LEN;i++)
  1537. // {
  1538. // if(Addr[i] == BRD_CAST_BIT_MASK)
  1539. // {
  1540. // maskcount++;
  1541. // }
  1542. // }
  1543. // if(maskcount == IP_ADDR_LEN)
  1544. // {
  1545. // return 1;
  1546. // }
  1547. // if(params == LAN_PARAM_SUBNET_MASK)
  1548. // {
  1549. // if(Addr[0] == BRD_CAST_BIT_MASK)
  1550. // {
  1551. // for(i=1;i< IP_ADDR_LEN;i++)
  1552. // {
  1553. // if(Addr[i-1] == 0)
  1554. // {
  1555. // bitmask = 1;
  1556. // }
  1557. // if(Addr[i] != 0)
  1558. // {
  1559. // for(j=0;j<8;j++)
  1560. // {
  1561. // if((Addr[i]<<j) & SUBNET_MASK_BIT_CHECK)
  1562. // {
  1563. // if(bitcheck == 1)
  1564. // {
  1565. // return 1;
  1566. // }
  1567. // continue;
  1568. // }
  1569. // bitcheck=1;
  1570. // }
  1571. // if((bitcheck == 1 && Addr[i-1] != BRD_CAST_BIT_MASK) || (Addr[i] > 0 && bitmask == 1))
  1572. // {
  1573. // return 1;
  1574. // }
  1575. // }
  1576. // }
  1577. // return 0;
  1578. // }
  1579. // return 1;
  1580. // }
  1581. // if(Addr[0] == LOOP_BACK_BIT_MASK || Addr[0] == BRD_CAST_BIT_MASK)
  1582. // {
  1583. // return 1;
  1584. // }
  1585. // return 0;
  1586. // }
  1587. // /*----------------------------------------------
  1588. // * GratuitousARPTask
  1589. // *----------------------------------------------*/
  1590. // void* GratuitousARPTask (uint8_t *Addr)
  1591. // {
  1592. // uint8_t IntervalInSec;
  1593. // uint8_t Status;
  1594. // int nRet;
  1595. // NWCFG_STRUCT NWConfig;
  1596. // NWCFG6_STRUCT NWConfig6;
  1597. // uint8_t EthIndex,netindex= 0xFF;
  1598. // int BMCInst,i;
  1599. // char IfcName[16];
  1600. // BMCArg *GratArpArgs = (BMCArg *)Addr;
  1601. // BMCInst = GratArpArgs->BMCInst;
  1602. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  1603. // prctl(PR_SET_NAME,__FUNCTION__,0,0,0);
  1604. // memcpy(&EthIndex,GratArpArgs->Argument,GratArpArgs->Len);
  1605. // memset(IfcName,0,sizeof(IfcName));
  1606. // /*Get the EthIndex*/
  1607. // if(GetIfcName(EthIndex,IfcName, BMCInst) == -1)
  1608. // {
  1609. // TCRIT("Error in Getting Ifcname\n");
  1610. // return 0;
  1611. // }
  1612. // for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
  1613. // {
  1614. // if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
  1615. // {
  1616. // netindex= Ifcnametable[i].Index;
  1617. // break;
  1618. // }
  1619. // }
  1620. // if(netindex == 0xFF)
  1621. // {
  1622. // TCRIT("Error in gettting netindex\n");
  1623. // return 0;
  1624. // }
  1625. // if(Addr != NULL)
  1626. // {
  1627. // free(GratArpArgs->Argument);
  1628. // free(Addr);
  1629. // }
  1630. // TDBG ("Gratuitous ARP thread starts for ethindex : %x\n",EthIndex);
  1631. // while (1)
  1632. // {
  1633. // /*Is Gratiutous Arp Enabled */
  1634. // if (0 == (pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl & GRATIUTOUS_ENABLE_MASK))
  1635. // {
  1636. // TDBG("Gratuitous ARP thread exits : Disable BMC-generated Gratuitous ARPs invoked\n");
  1637. // break;
  1638. // }
  1639. // /*Is Gratiutous Arp Suspended */
  1640. // Status = BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex];
  1641. // if ((0 != (Status & GRATIUTOUS_ENABLE_MASK)) &&
  1642. // (BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning == TRUE))
  1643. // {
  1644. // // Gratuitous ARP Suspended.
  1645. // // sleep requested to access Shared memory for two different threads.
  1646. // usleep (20);
  1647. // continue;
  1648. // }
  1649. // nwReadNWCfg_v4_v6( &NWConfig,&NWConfig6, netindex,g_corefeatures.global_ipv6);
  1650. // if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
  1651. // {
  1652. // TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
  1653. // }
  1654. // if (NWConfig.IFName[0] == 0)
  1655. // sprintf((char *)&NWConfig.IFName, "%s",IfcName);
  1656. // TDBG ( "MAC is %2x:%2x:%2x:%2x:%2x:%2x \n", NWConfig.MAC [0], NWConfig.MAC [1],
  1657. // NWConfig.MAC [2], NWConfig.MAC [3], NWConfig.MAC [4], NWConfig.MAC [5] );
  1658. // TDBG ( "IP is %d.%d.%d.%d\n", NWConfig.IPAddr[0], NWConfig.IPAddr[1],
  1659. // NWConfig.IPAddr[2], NWConfig.IPAddr[3]);
  1660. // TDBG ( "Device Name : %s\n", (char *)&NWConfig.IFName);
  1661. // nRet = SendGratuitousARPPacket((char *)&NWConfig.IFName, NWConfig.IPAddr, NWConfig.MAC);
  1662. // if (0 != nRet)
  1663. // {
  1664. // TCRIT("Gratuitous ARP thread exits : Unable to Send Gratuitous ARP packet\n");
  1665. // break;
  1666. // }
  1667. // TDBG ("Send Gratuitous Packet\n");
  1668. // if (0 == pBMCInfo->LANCfs[EthIndex].GratitousARPInterval)
  1669. // {
  1670. // IntervalInSec = 2; //Default 2 secs
  1671. // } else {
  1672. // // Gratuitous ARP interval in 500 millisecond increments.
  1673. // IntervalInSec = (pBMCInfo->LANCfs[EthIndex].GratitousARPInterval * 500)/1000;
  1674. // }
  1675. // usleep( IntervalInSec * 1000 * 1000 );
  1676. // }
  1677. // return 0;
  1678. // }
  1679. // /*---------------------------------------------------
  1680. // * GetLanConfigParam
  1681. // *---------------------------------------------------*/
  1682. // int
  1683. // GetLanConfigParam (_NEAR_ uint8_t* pReq, uint8_t ReqLen, _NEAR_ uint8_t* pRes,_NEAR_ int BMCInst)
  1684. // {
  1685. // _NEAR_ GetLanConfigReq_T* pGetLanReq = (_NEAR_ GetLanConfigReq_T*) pReq;
  1686. // _NEAR_ GetLanConfigRes_T* pGetLanRes = (_NEAR_ GetLanConfigRes_T*) pRes;
  1687. // _FAR_ BMCSharedMem_T* pSharedMem = BMC_GET_SHARED_MEM (BMCInst);
  1688. // uint8_t IsOemDefined = FALSE;
  1689. // NWCFG_STRUCT NWConfig;
  1690. // NWCFG6_STRUCT NWConfig6;
  1691. // // V6DNS_CONFIG v6dnsconfig;
  1692. // uint8_t EthIndex,netindex= 0xFF,i;
  1693. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1694. // int ncsiPortConfigNum = 0;
  1695. // ETHCFG_STRUCT PHYCfg;
  1696. // ChannelInfo_T* pChannelInfo = NULL;
  1697. // char IfcName[16]; /* Eth interface name */
  1698. // uint8_t ComStrLen=MAX_COMM_STRING_SIZE;
  1699. // int retValue = 0,NIC_Count = 0;
  1700. // pGetLanRes->CCParamRev.CompletionCode = CC_NORMAL;
  1701. // pGetLanRes->CCParamRev.ParamRevision = PARAMETER_REVISION_FORMAT;
  1702. // // printf("---> channel: %d, parameter: %#x, setslect: %#x, blockselect: %#x\n", pGetLanReq->ChannelNum, pGetLanReq->ParameterSelect, pGetLanReq->SetSelect, pGetLanReq->BlockSelect);
  1703. // if(pGetLanReq->ChannelNum & RESERVED_VALUE_70)
  1704. // {
  1705. // /* Alarm !!! Somebody is trying to set Reseved Bits */
  1706. // *pRes = CC_INV_DATA_FIELD;
  1707. // return sizeof (*pRes);
  1708. // }
  1709. // if((pGetLanReq->ParameterSelect >= MIN_LAN_OEM_CONF_PARAM) &&
  1710. // (pGetLanReq->ParameterSelect <= MAX_LAN_OEM_CONF_PARAM) )
  1711. // {
  1712. // /* Converts OEM parameter value to equivalent AMI parameter value */
  1713. // if (0 != GetLanAMIParamValue (&pGetLanReq->ParameterSelect, &IsOemDefined) )
  1714. // {
  1715. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  1716. // return sizeof(uint8_t);
  1717. // }
  1718. // /* Hook for OEM to handle this parameter */
  1719. // if ( (IsOemDefined) && (g_PDKHandle[PDK_GETLANOEMPARAM] != NULL) )
  1720. // {
  1721. // return ((int(*)(uint8_t *, uint8_t, uint8_t *,int))(g_PDKHandle[PDK_GETLANOEMPARAM]))(pReq, ReqLen, pRes, BMCInst);
  1722. // }
  1723. // }
  1724. // if (g_PDKHandle[PDK_BEFOREGETLANPARM] != NULL)
  1725. // {
  1726. // retValue = ((int(*)(uint8_t *, uint8_t, uint8_t *,int))(g_PDKHandle[PDK_BEFOREGETLANPARM]))(pReq, ReqLen, pRes, BMCInst);
  1727. // if(retValue != 0)
  1728. // {
  1729. // return retValue;
  1730. // }
  1731. // }
  1732. // //! Validate the SetSelector value.
  1733. // if ( (0x00 != pGetLanReq->SetSelect) &&
  1734. // (pGetLanReq->ParameterSelect != LAN_PARAM_SELECT_DEST_TYPE) &&
  1735. // (pGetLanReq->ParameterSelect != LAN_PARAM_SELECT_DEST_ADDR) &&
  1736. // (pGetLanReq->ParameterSelect != LAN_PARAM_VLAN_TAGS) &&
  1737. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR) &&
  1738. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR) &&
  1739. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_EUI64) &&
  1740. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH))
  1741. // {
  1742. // printf("GetLanConfigParam log1\n");
  1743. // if( g_corefeatures.ncsi_cmd_support == ENABLED )
  1744. // {
  1745. // if ((pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_NCSI_SETTINGS) &&
  1746. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_NCSI_MODE_CHANGE) &&
  1747. // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_NCSI_EXTENSION))
  1748. // {
  1749. // *pRes = CC_INV_DATA_FIELD;
  1750. // return sizeof (*pRes);
  1751. // }
  1752. // }
  1753. // else
  1754. // {
  1755. // *pRes = CC_INV_DATA_FIELD;
  1756. // return sizeof (*pRes);
  1757. // }
  1758. // }
  1759. // //! Validate the BlockSelector value.
  1760. // if (0x00 != pGetLanReq->BlockSelect)
  1761. // {
  1762. // printf("GetLanConfigParam log2\n");
  1763. // *pRes = CC_INV_DATA_FIELD;
  1764. // return sizeof (*pRes);
  1765. // }
  1766. // EthIndex= GetEthIndex(pGetLanReq->ChannelNum & 0x0F, BMCInst);
  1767. // if(0xff == EthIndex)
  1768. // {
  1769. // printf("GetLanConfigParam log3\n");
  1770. // *pRes = CC_INV_DATA_FIELD;
  1771. // return sizeof (uint8_t);
  1772. // }
  1773. // /*Get the EthIndex*/
  1774. // if(GetIfcName(EthIndex,IfcName, BMCInst) != 0)
  1775. // {
  1776. // TCRIT("Error in Getting IfcName\n");
  1777. // *pRes = CC_INV_DATA_FIELD;
  1778. // return sizeof (uint8_t);
  1779. // }
  1780. // for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
  1781. // {
  1782. // if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
  1783. // {
  1784. // netindex= Ifcnametable[i].Index;
  1785. // break;
  1786. // }
  1787. // }
  1788. // if(netindex == 0xFF)
  1789. // {
  1790. // TCRIT("Error in Getting netindex %d %s\n",netindex,IfcName);
  1791. // *pRes = CC_INV_DATA_FIELD;
  1792. // return sizeof (uint8_t);
  1793. // }
  1794. // if ((pGetLanReq->ChannelNum & GET_PARAMETER_REVISION_MASK) != 0)
  1795. // {
  1796. // if((MAX_LAN_CONF_PARAM >= pGetLanReq->ParameterSelect) ||
  1797. // ((MIN_LAN_OEM_CONF_PARAM <= pGetLanReq->ParameterSelect) && (MAX_LAN_OEM_CONF_PARAM >= pGetLanReq->ParameterSelect)) )
  1798. // {
  1799. // return sizeof(GetLanCCRev_T);
  1800. // }
  1801. // else
  1802. // {
  1803. // *pRes = CC_PARAM_NOT_SUPPORTED;
  1804. // return sizeof (*pRes);
  1805. // }
  1806. // }
  1807. // else
  1808. // {
  1809. // printf("GetLanConfigParam log4\n");
  1810. // switch(pGetLanReq->ParameterSelect)
  1811. // {
  1812. // case LAN_PARAM_SET_IN_PROGRESS:
  1813. // LOCK_BMC_SHARED_MEM(BMCInst);
  1814. // pGetLanRes->ConfigData.SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Lan_SetInProgress;
  1815. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1816. // break;
  1817. // case LAN_PARAM_AUTH_TYPE_SUPPORT:
  1818. // pGetLanRes->ConfigData.AuthTypeSupport = pBMCInfo->LANCfs[EthIndex].AuthTypeSupport;
  1819. // break;
  1820. // case LAN_PARAM_AUTH_TYPE_ENABLES:
  1821. // LOCK_BMC_SHARED_MEM(BMCInst);
  1822. // _fmemcpy (&pGetLanRes->ConfigData.AuthTypeEnables,
  1823. // &(pBMCInfo->LANCfs[EthIndex].AuthTypeEnables), sizeof(AuthTypeEnables_T));
  1824. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1825. // break;
  1826. // case LAN_PARAM_IP_ADDRESS:
  1827. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPAddrSrc == STATIC_IP_SOURCE))
  1828. // {
  1829. // if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
  1830. // {
  1831. // _fmemcpy (NWConfig.IPAddr,pBMCInfo->LANCfs[EthIndex].IPAddr, IP_ADDR_LEN);
  1832. // }
  1833. // else
  1834. // {
  1835. // memset(&NWConfig, 0, sizeof(NWConfig));
  1836. // }
  1837. // }
  1838. // else
  1839. // {
  1840. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1841. // }
  1842. // _fmemcpy (pGetLanRes->ConfigData.IPAddr, NWConfig.IPAddr, IP_ADDR_LEN);
  1843. // break;
  1844. // case LAN_PARAM_IP_ADDRESS_SOURCE:
  1845. // if(g_corefeatures.delayed_lan_restart_support)
  1846. // {
  1847. // if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
  1848. // {
  1849. // NWConfig.CfgMethod = pBMCInfo->LANCfs[EthIndex].IPAddrSrc;
  1850. // }
  1851. // else
  1852. // {
  1853. // memset(&NWConfig, 0, sizeof(NWConfig));
  1854. // }
  1855. // }
  1856. // else
  1857. // {
  1858. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1859. // }
  1860. // pGetLanRes->ConfigData.IPAddrSrc = NWConfig.CfgMethod;
  1861. // break;
  1862. // case LAN_PARAM_MAC_ADDRESS:
  1863. // nwGetNWInformations(&NWConfig,IfcName);
  1864. // _fmemcpy (pGetLanRes->ConfigData.MACAddr, NWConfig.MAC, MAC_ADDR_LEN);
  1865. // break;
  1866. // case LAN_PARAM_SUBNET_MASK:
  1867. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPAddrSrc == STATIC_IP_SOURCE))
  1868. // {
  1869. // if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
  1870. // {
  1871. // _fmemcpy (NWConfig.Mask,pBMCInfo->LANCfs[EthIndex].SubNetMask, IP_ADDR_LEN);
  1872. // }
  1873. // else
  1874. // {
  1875. // memset(&NWConfig, 0, sizeof(NWConfig));
  1876. // }
  1877. // }
  1878. // else
  1879. // {
  1880. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1881. // }
  1882. // _fmemcpy (pGetLanRes->ConfigData.SubNetMask, NWConfig.Mask, IP_ADDR_LEN);
  1883. // break;
  1884. // case LAN_PARAM_IPv4_HEADER:
  1885. // LOCK_BMC_SHARED_MEM(BMCInst);
  1886. // _fmemcpy (&pGetLanRes->ConfigData.Ipv4HdrParam,
  1887. // &(pBMCInfo->LANCfs[EthIndex].Ipv4HdrParam), sizeof(IPv4HdrParams_T));
  1888. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1889. // break;
  1890. // case LAN_PARAM_PRI_RMCP_PORT:
  1891. // pGetLanRes->ConfigData.PrimaryRMCPPort = htoipmi_u16(pBMCInfo->LANCfs[EthIndex].PrimaryRMCPPort);
  1892. // break;
  1893. // case LAN_PARAM_SEC_RMCP_PORT:
  1894. // /* Returning Invalid error message */
  1895. // *pRes = CC_PARAM_NOT_SUPPORTED;
  1896. // return sizeof (uint8_t);
  1897. // /*pGetLanRes->ConfigData.SecondaryPort = htoipmi_u16(pPMConfig->LANConfig[EthIndex].SecondaryPort);*/
  1898. // break;
  1899. // case LAN_PARAM_BMC_GENERATED_ARP_CONTROL:
  1900. // pGetLanRes->ConfigData.BMCGeneratedARPControl = pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl;
  1901. // break;
  1902. // case LAN_PARAM_GRATITIOUS_ARP_INTERVAL:
  1903. // pGetLanRes->ConfigData.GratitousARPInterval =
  1904. // pBMCInfo->LANCfs[EthIndex].GratitousARPInterval;
  1905. // break;
  1906. // case LAN_PARAM_DEFAULT_GATEWAY_IP:
  1907. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPAddrSrc == STATIC_IP_SOURCE))
  1908. // {
  1909. // if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
  1910. // {
  1911. // _fmemcpy (NWConfig.Gateway, pBMCInfo->LANCfs[EthIndex].DefaultGatewayIPAddr, IP_ADDR_LEN);
  1912. // }
  1913. // else
  1914. // {
  1915. // memset(&NWConfig, 0, sizeof(NWConfig));
  1916. // }
  1917. // }
  1918. // else
  1919. // {
  1920. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1921. // }
  1922. // _fmemcpy (pGetLanRes->ConfigData.DefaultGatewayIPAddr, NWConfig.Gateway, IP_ADDR_LEN);
  1923. // break;
  1924. // case LAN_PARAM_DEFAULT_GATEWAY_MAC:
  1925. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  1926. // nwGetSrcMacAddr(&NWConfig.Gateway[0],netindex, &pGetLanRes->ConfigData.DefaultGatewayMACAddr[0]);
  1927. // break;
  1928. // case LAN_PARAM_BACKUP_GATEWAY_IP:
  1929. // LOCK_BMC_SHARED_MEM(BMCInst);
  1930. // nwGetBkupGWyAddr(pGetLanRes->ConfigData.BackupGatewayIPAddr,netindex);
  1931. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1932. // break;
  1933. // case LAN_PARAM_BACKUP_GATEWAY_MAC:
  1934. // LOCK_BMC_SHARED_MEM(BMCInst);
  1935. // _fmemcpy (pGetLanRes->ConfigData.BackupGatewayMACAddr,
  1936. // pBMCInfo->LANCfs[EthIndex].BackupGatewayMACAddr, MAC_ADDR_LEN);
  1937. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1938. // break;
  1939. // case LAN_PARAM_COMMUNITY_STRING:
  1940. // if (g_PDKHandle[PDK_GETSNMPCOMMUNITYNAME] != NULL )
  1941. // {
  1942. // if(((int(*)(uint8_t *, uint8_t *,int))(g_PDKHandle[PDK_GETSNMPCOMMUNITYNAME]))(pGetLanRes->ConfigData.CommunityStr,&ComStrLen, BMCInst)==0)
  1943. // break;
  1944. // }
  1945. // LOCK_BMC_SHARED_MEM(BMCInst);
  1946. // _fmemcpy (pGetLanRes->ConfigData.CommunityStr,
  1947. // pBMCInfo->LANCfs[EthIndex].CommunityStr, MAX_COMM_STRING_SIZE);
  1948. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1949. // break;
  1950. // case LAN_PARAM_DEST_NUM:
  1951. // pGetLanRes->ConfigData.NumDest = pBMCInfo->LANCfs[EthIndex].NumDest;
  1952. // break;
  1953. // case LAN_PARAM_SELECT_DEST_TYPE:
  1954. // //if (pGetLanReq->SetSelect > NUM_LAN_DESTINATION)
  1955. // if ( pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
  1956. // {
  1957. // *pRes = CC_PARAM_OUT_OF_RANGE ;
  1958. // return sizeof (*pRes);
  1959. // }
  1960. // if (0 == pGetLanReq->SetSelect)
  1961. // {
  1962. // LOCK_BMC_SHARED_MEM(BMCInst);
  1963. // _fmemcpy (&pGetLanRes->ConfigData.DestType,
  1964. // &pSharedMem->VolLANDestType[EthIndex], sizeof(LANDestType_T));
  1965. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1966. // }
  1967. // else
  1968. // {
  1969. // LOCK_BMC_SHARED_MEM(BMCInst);
  1970. // _fmemcpy (&pGetLanRes->ConfigData.DestType,
  1971. // &(pBMCInfo->LANCfs[EthIndex].DestType[pGetLanReq->SetSelect - 1]),
  1972. // sizeof(LANDestType_T));
  1973. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1974. // }
  1975. // break;
  1976. // case LAN_PARAM_SELECT_DEST_ADDR:
  1977. // //if (pGetLanReq->SetSelect > NUM_LAN_DESTINATION)
  1978. // if ( pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
  1979. // {
  1980. // *pRes = CC_PARAM_OUT_OF_RANGE ;
  1981. // return sizeof (*pRes);
  1982. // }
  1983. // if (0 == pGetLanReq->SetSelect)
  1984. // {
  1985. // LOCK_BMC_SHARED_MEM(BMCInst);
  1986. // _fmemcpy (&pGetLanRes->ConfigData.DestAddr,
  1987. // &pSharedMem->VolLANDest[EthIndex], sizeof(LANDestAddr_T));
  1988. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1989. // }
  1990. // else
  1991. // {
  1992. // LOCK_BMC_SHARED_MEM(BMCInst);
  1993. // _fmemcpy (&pGetLanRes->ConfigData.DestAddr,
  1994. // &(pBMCInfo->LANCfs[EthIndex].DestAddr[pGetLanReq->SetSelect - 1]),
  1995. // sizeof(LANDestAddr_T));
  1996. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1997. // }
  1998. // break;
  1999. // case LAN_PARAM_VLAN_ID:
  2000. // if( pBMCInfo->IpmiConfig.VLANIfcSupport == 1)
  2001. // {
  2002. // pGetLanRes->ConfigData.VLANID = pBMCInfo->LANCfs[EthIndex].VLANID;
  2003. // }
  2004. // break;
  2005. // case LAN_PARAM_VLAN_PRIORITY:
  2006. // pGetLanRes->ConfigData.VLANPriority = pBMCInfo->LANCfs[EthIndex].VLANPriority;
  2007. // break;
  2008. // case LAN_PARAM_CIPHER_SUITE_ENTRY_SUP:
  2009. // pGetLanRes->ConfigData.CipherSuiteSup = N0_OF_CIPHER_SUITE_SUPPORTED;
  2010. // break;
  2011. // case LAN_PARAM_CIPHER_SUITE_ENTRIES:
  2012. // {
  2013. // int i;
  2014. // _fmemset (pGetLanRes->ConfigData.CipherSuiteEntries, 0,
  2015. // sizeof (pGetLanRes->ConfigData.CipherSuiteEntries));
  2016. // for (i = 0; i < (N0_OF_CIPHER_SUITE_SUPPORTED); i++)
  2017. // {
  2018. // pGetLanRes->ConfigData.CipherSuiteEntries[i+1] = g_CipherRec[1 + i * 5];
  2019. // }
  2020. // }
  2021. // break;
  2022. // case LAN_PARAM_CIPHER_SUITE_PRIV_LEVELS:
  2023. // LOCK_BMC_SHARED_MEM(BMCInst);
  2024. // _fmemcpy (pGetLanRes->ConfigData.CipherSuitePrivLevels,
  2025. // pBMCInfo->LANCfs[EthIndex].CipherSuitePrivLevels,
  2026. // MAX_NUM_CIPHER_SUITE_PRIV_LEVELS);
  2027. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  2028. // break;
  2029. // case LAN_PARAM_VLAN_TAGS:
  2030. // *((_NEAR_ uint8_t*)&pGetLanRes->ConfigData) = pGetLanReq->SetSelect;
  2031. // if (pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest)
  2032. // {
  2033. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_OUT_OF_RANGE;
  2034. // return sizeof (GetLanCCRev_T);
  2035. // }
  2036. // if (0 == pGetLanReq->SetSelect)
  2037. // {
  2038. // LOCK_BMC_SHARED_MEM(BMCInst);
  2039. // _fmemcpy (((_NEAR_ uint8_t*) &pGetLanRes->ConfigData) + 1,&pSharedMem->VLANDestTag, sizeof(VLANDestTags_T));
  2040. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  2041. // }
  2042. // else
  2043. // {
  2044. // if (pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest)
  2045. // {
  2046. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_OUT_OF_RANGE;
  2047. // return sizeof(GetLanCCRev_T);
  2048. // }
  2049. // LOCK_BMC_SHARED_MEM(BMCInst);
  2050. // _fmemcpy (((_NEAR_ uint8_t*)&pGetLanRes->ConfigData) + 1,
  2051. // &pBMCInfo->LANCfs[EthIndex].VLANDestTags[pGetLanReq->SetSelect - 1],
  2052. // sizeof(VLANDestTags_T));
  2053. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  2054. // }
  2055. // break;
  2056. // case LAN_PARAMS_BAD_PASSWORD_THRESHOLD:
  2057. // LOCK_BMC_SHARED_MEM(BMCInst);
  2058. // _fmemcpy(&pGetLanRes->ConfigData.BadPasswd,
  2059. // &pBMCInfo->LANCfs[EthIndex].BadPasswd,sizeof(BadPassword_T));
  2060. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  2061. // break;
  2062. // case LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR:
  2063. // if ( pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
  2064. // {
  2065. // *pRes = CC_PARAM_OUT_OF_RANGE ;
  2066. // return sizeof (*pRes);
  2067. // }
  2068. // if (0 == pGetLanReq->SetSelect)
  2069. // {
  2070. // LOCK_BMC_SHARED_MEM(BMCInst);
  2071. // _fmemcpy (&pGetLanRes->ConfigData.Destv6Addr,
  2072. // &pSharedMem->VolLANv6Dest[EthIndex], sizeof(LANDestv6Addr_T));
  2073. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  2074. // }
  2075. // else
  2076. // {
  2077. // LOCK_BMC_SHARED_MEM(BMCInst);
  2078. // _fmemcpy (&pGetLanRes->ConfigData.Destv6Addr,
  2079. // &(pBMCInfo->LANCfs[EthIndex].Destv6Addr[pGetLanReq->SetSelect - 1]),
  2080. // sizeof(LANDestv6Addr_T));
  2081. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  2082. // }
  2083. // TDBG("\n GetLanconfig: Getting SNMPv6 configuration done..\n");
  2084. // return sizeof(GetLanConfigRes_T);
  2085. // break;
  2086. // case LAN_PARAMS_AMI_OEM_ENABLE_SET_MAC:
  2087. // pGetLanRes->ConfigData.ChangeMACEnabled = enableSetMACAddr;
  2088. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  2089. // case LAN_PARAMS_AMI_OEM_IPV6_ENABLE:
  2090. // if(g_corefeatures.delayed_lan_restart_support)
  2091. // {
  2092. // NWConfig6.enable = pBMCInfo->LANCfs[EthIndex].IPv6_Enable;
  2093. // }
  2094. // else
  2095. // {
  2096. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  2097. // }
  2098. // pGetLanRes->ConfigData.IPv6_Enable = NWConfig6.enable;
  2099. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  2100. // break;
  2101. // case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE:
  2102. // if(g_corefeatures.delayed_lan_restart_support)
  2103. // {
  2104. // if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
  2105. // {
  2106. // NWConfig6.CfgMethod = pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc;
  2107. // }
  2108. // else
  2109. // {
  2110. // memset(&NWConfig6, 0, sizeof(NWConfig6));
  2111. // }
  2112. // }
  2113. // else
  2114. // {
  2115. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  2116. // }
  2117. // pGetLanRes->ConfigData.IPv6_IPAddrSrc = NWConfig6.CfgMethod;
  2118. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  2119. // break;
  2120. // case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR:
  2121. // case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_EUI64:
  2122. // if(pGetLanReq->SetSelect & 0xF0)
  2123. // {
  2124. // *pRes = CC_INV_DATA_FIELD;
  2125. // return sizeof(uint8_t);
  2126. // }
  2127. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == STATIC_IP_SOURCE))
  2128. // {
  2129. // if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
  2130. // {
  2131. // _fmemcpy (NWConfig6.GlobalIPAddr,pBMCInfo->LANCfs[EthIndex].IPv6_IPAddr, IP6_ADDR_LEN*MAX_IPV6ADDRS);
  2132. // }
  2133. // else
  2134. // {
  2135. // memset(&NWConfig6, 0, sizeof(NWConfig6));
  2136. // }
  2137. // }
  2138. // else
  2139. // {
  2140. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  2141. // }
  2142. // _fmemcpy (pGetLanRes->ConfigData.IPv6_LinkAddr, NWConfig6.GlobalIPAddr[(pGetLanReq->SetSelect & 0x0F)], IP6_ADDR_LEN);
  2143. // return sizeof(GetLanCCRev_T) + IP6_ADDR_LEN;
  2144. // break;
  2145. // case LAN_PARAMS_AMI_OEM_IPV6_LINK_ADDR:
  2146. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  2147. // _fmemcpy (pGetLanRes->ConfigData.IPv6_LinkAddr, NWConfig6.LinkIPAddr, IP6_ADDR_LEN);
  2148. // return sizeof(GetLanCCRev_T) + IP6_ADDR_LEN;
  2149. // case LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH:
  2150. // if(pGetLanReq->SetSelect & 0xF0)
  2151. // {
  2152. // *pRes = CC_INV_DATA_FIELD;
  2153. // return sizeof(uint8_t);
  2154. // }
  2155. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == STATIC_IP_SOURCE))
  2156. // {
  2157. // if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
  2158. // {
  2159. // NWConfig6.GlobalPrefix[(pGetLanReq->SetSelect & 0x0F)] = pBMCInfo->LANCfs[EthIndex].IPv6_PrefixLen[(pGetLanReq->SetSelect & 0x0F)];
  2160. // }
  2161. // else
  2162. // {
  2163. // memset(&NWConfig6, 0, sizeof(NWConfig6));
  2164. // }
  2165. // }
  2166. // else
  2167. // {
  2168. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  2169. // }
  2170. // pGetLanRes->ConfigData.IPv6_LinkAddrPrefix = NWConfig6.GlobalPrefix[(pGetLanReq->SetSelect & 0x0F)];
  2171. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  2172. // break;
  2173. // case LAN_PARAMS_AMI_OEM_IPV6_LINK_ADDR_PREFIX:
  2174. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  2175. // pGetLanRes->ConfigData.IPv6_LinkAddrPrefix = NWConfig6.LinkPrefix;
  2176. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  2177. // break;
  2178. // case LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP:
  2179. // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == STATIC_IP_SOURCE))
  2180. // {
  2181. // if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
  2182. // {
  2183. // _fmemcpy (NWConfig6.Gateway,pBMCInfo->LANCfs[EthIndex].IPv6_GatewayIPAddr, IP6_ADDR_LEN);
  2184. // }
  2185. // else
  2186. // {
  2187. // memset(&NWConfig6, 0, sizeof(NWConfig6));
  2188. // }
  2189. // }
  2190. // else
  2191. // {
  2192. // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  2193. // }
  2194. // _fmemcpy (pGetLanRes->ConfigData.IPv6_GatewayIPAddr, NWConfig6.Gateway, IP6_ADDR_LEN);
  2195. // return sizeof(GetLanCCRev_T) + IP6_ADDR_LEN;
  2196. // break;
  2197. // case LAN_PARAMS_AMI_OEM_PHY_SETTINGS:
  2198. // memset(IfcName, 0, sizeof(IfcName));
  2199. // if(GetIfcNameByIndex(EthIndex, IfcName) != 0)
  2200. // {
  2201. // TCRIT("Error in Getting Interface Name for the lan Index:%d\n",EthIndex);
  2202. // }
  2203. // if(nwGetEthInformation(&PHYCfg, IfcName) !=0)
  2204. // {
  2205. // pGetLanRes->CCParamRev.CompletionCode = CC_UNSPECIFIED_ERR;
  2206. // return sizeof(GetLanCCRev_T);
  2207. // }
  2208. // pGetLanRes->ConfigData.PHYConfig.Interface = EthIndex;
  2209. // pGetLanRes->ConfigData.PHYConfig.AutoNegotiationEnable = PHYCfg.autoneg;
  2210. // pGetLanRes->ConfigData.PHYConfig.Speed = PHYCfg.speed;
  2211. // pGetLanRes->ConfigData.PHYConfig.Duplex = PHYCfg.duplex;
  2212. // pGetLanRes->ConfigData.PHYConfig.CapabilitiesSupported = PHYCfg.supported;
  2213. // return sizeof(GetLanCCRev_T) + sizeof(PHYConfig_T);
  2214. // case LAN_PARAMS_AMI_OEM_MTU_SETTINGS:
  2215. // memset(IfcName,0,sizeof(IfcName));
  2216. // if(GetIfcNameByIndex(EthIndex, IfcName) != 0)
  2217. // {
  2218. // TCRIT("Error in Getting Interface Name for the lan Index:%d\n",EthIndex);
  2219. // pGetLanRes->CCParamRev.CompletionCode = CC_UNSPECIFIED_ERR;
  2220. // return sizeof(GetLanCCRev_T);
  2221. // }
  2222. // if(nwGetEthInformation(&PHYCfg, IfcName) !=0)
  2223. // {
  2224. // pGetLanRes->CCParamRev.CompletionCode = CC_UNSPECIFIED_ERR;
  2225. // return sizeof(GetLanCCRev_T);
  2226. // }
  2227. // pGetLanRes->ConfigData.MTU_size = PHYCfg.maxtxpkt;
  2228. // return sizeof(GetLanCCRev_T) + sizeof(INT16U);
  2229. // case LAN_PARAMS_SSI_OEM_2ND_PRI_ETH_MAC_ADDR:
  2230. // if(g_corefeatures.ssi_support == ENABLED)
  2231. // {
  2232. // netindex = 0x1; /* Specify the 2nd interface */
  2233. // nwReadNWCfg_v4_v6(&NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
  2234. // _fmemcpy(pGetLanRes->ConfigData.SSI2ndPriEthMACAddr, NWConfig.MAC, MAC_ADDR_LEN);
  2235. // return sizeof(GetLanCCRev_T) + sizeof(pGetLanRes->ConfigData.SSI2ndPriEthMACAddr);
  2236. // }
  2237. // else
  2238. // {
  2239. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  2240. // return sizeof(uint8_t);
  2241. // }
  2242. // break;
  2243. // case LAN_PARAMS_SSI_OEM_LINK_CTRL:
  2244. // if(g_corefeatures.ssi_support == ENABLED)
  2245. // {
  2246. // pGetLanRes->ConfigData.SSILinkControl = 0;
  2247. // pChannelInfo = getChannelInfo(pBMCInfo->RMCPLAN1Ch, BMCInst);
  2248. // if(NULL == pChannelInfo)
  2249. // {
  2250. // *pRes = CC_UNSPECIFIED_ERR;
  2251. // return sizeof (*pRes);
  2252. // }
  2253. // if (pChannelInfo->AccessMode == 0x02) /* If 1st channal is available */
  2254. // pGetLanRes->ConfigData.SSILinkControl |= BIT0;
  2255. // NIC_Count = g_coremacros.global_nic_count;
  2256. // if (NIC_Count == 2)
  2257. // {
  2258. // pChannelInfo = getChannelInfo(pBMCInfo->RMCPLAN2Ch, BMCInst);
  2259. // if(NULL == pChannelInfo)
  2260. // {
  2261. // *pRes = CC_UNSPECIFIED_ERR;
  2262. // return sizeof (*pRes);
  2263. // }
  2264. // if (pChannelInfo->AccessMode == 0x02) /* If 2nd channal is available */
  2265. // pGetLanRes->ConfigData.SSILinkControl |= BIT1;
  2266. // }
  2267. // return sizeof(GetLanCCRev_T) + sizeof(pGetLanRes->ConfigData.SSILinkControl);
  2268. // }
  2269. // else
  2270. // {
  2271. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  2272. // return sizeof(uint8_t);
  2273. // }
  2274. // break;
  2275. // case LAN_PARAMS_SSI_OEM_CMM_IP_ADDR:
  2276. // if(g_corefeatures.ssi_support == ENABLED)
  2277. // {
  2278. // _fmemcpy (pGetLanRes->ConfigData.CMMIPAddr, pBMCInfo->SSIConfig.CMMIPAddr, IP_ADDR_LEN);
  2279. // return sizeof(GetLanCCRev_T) + sizeof(pGetLanRes->ConfigData.CMMIPAddr);
  2280. // }
  2281. // else
  2282. // {
  2283. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  2284. // return sizeof(uint8_t);
  2285. // }
  2286. // break;
  2287. // default:
  2288. // if(g_corefeatures.ncsi_cmd_support == ENABLED)
  2289. // {
  2290. // switch(pGetLanReq->ParameterSelect)
  2291. // {
  2292. // case LAN_PARAMS_AMI_OEM_NCSI_CONFIG_NUM:
  2293. // NCSIGetTotalPorts(&ncsiPortConfigNum);
  2294. // if (ncsiPortConfigNum >= 0xFF)
  2295. // {
  2296. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  2297. // return sizeof(GetLanCCRev_T);
  2298. // }
  2299. // else
  2300. // {
  2301. // pGetLanRes->ConfigData.NumNCSIPortConfigs = ncsiPortConfigNum;
  2302. // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
  2303. // }
  2304. // break;
  2305. // case LAN_PARAMS_AMI_OEM_NCSI_SETTINGS:
  2306. // {
  2307. // NIC_Count=g_coremacros.global_nic_count;
  2308. // if (pGetLanReq->SetSelect >= NIC_Count)
  2309. // {
  2310. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  2311. // return sizeof(GetLanCCRev_T);
  2312. // }
  2313. // NCSIConfig_T configData;
  2314. // char interfaceName[8];
  2315. // memset(&configData, 0, sizeof(NCSIConfig_T));
  2316. // memset(interfaceName, 0, sizeof(interfaceName));
  2317. // snprintf(interfaceName, sizeof(interfaceName), "%s%d", "eth", pGetLanReq->SetSelect);
  2318. // if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
  2319. // {
  2320. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  2321. // return sizeof(GetLanCCRev_T);
  2322. // }
  2323. // if (configData.PackageId >= 0xFF || configData.ChannelId >= 0xFF)
  2324. // {
  2325. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  2326. // return sizeof(GetLanCCRev_T);
  2327. // }
  2328. // pGetLanRes->ConfigData.NCSIPortConfig.Interface = pGetLanReq->SetSelect;
  2329. // pGetLanRes->ConfigData.NCSIPortConfig.PackageId = configData.PackageId;
  2330. // pGetLanRes->ConfigData.NCSIPortConfig.ChannelId = configData.ChannelId;
  2331. // return sizeof(GetLanCCRev_T) + sizeof(NCSIPortConfig_T);
  2332. // }
  2333. // break;
  2334. // case LAN_PARAMS_AMI_OEM_NCSI_MODE_CHANGE:
  2335. // {
  2336. // NIC_Count=g_coremacros.global_nic_count;
  2337. // if (pGetLanReq->SetSelect >= NIC_Count)
  2338. // {
  2339. // printf("---> log5, SetSelect = %d, NIC_Count = %d\n",pGetLanReq->SetSelect, NIC_Count);
  2340. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  2341. // return sizeof(GetLanCCRev_T);
  2342. // }
  2343. // NCSIConfig_T configData;
  2344. // char interfaceName[8];
  2345. // memset(&configData, 0, sizeof(NCSIConfig_T));
  2346. // memset(interfaceName, 0, sizeof(interfaceName));
  2347. // snprintf(interfaceName, sizeof(interfaceName), "%s%d", "eth", pGetLanReq->SetSelect);
  2348. // if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
  2349. // {
  2350. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  2351. // return sizeof(GetLanCCRev_T);
  2352. // }
  2353. // if (configData.AutoSelect>= 0xFF)
  2354. // {
  2355. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  2356. // return sizeof(GetLanCCRev_T);
  2357. // }
  2358. // pGetLanRes->ConfigData.NCSIModeConfig.Interface = pGetLanReq->SetSelect;
  2359. // pGetLanRes->ConfigData.NCSIModeConfig.NCSIMode = configData.AutoSelect;
  2360. // return sizeof(GetLanCCRev_T) + sizeof(NCSIModeConfig_T);
  2361. // }
  2362. // break;
  2363. // case LAN_PARAMS_AMI_OEM_NCSI_EXTENSION:
  2364. // {
  2365. // char ncsi_default_ifc[IFNAMSIZ + 1] = "eth1";
  2366. // if ((pGetLanReq->SetSelect == 0x20) &&
  2367. // (g_corefeatures.ncsi_keep_phy_linkup_support == ENABLED))
  2368. // {
  2369. // NIC_Count=g_coremacros.global_nic_count;
  2370. // NCSIConfig_T configData;
  2371. // char interfaceName[8];
  2372. // memset(&configData, 0, sizeof(NCSIConfig_T));
  2373. // memset(interfaceName, 0, sizeof(interfaceName));
  2374. // GetMacrodefine_string("CONFIG_SPX_FEATURE_NCSI_DEFAULT_INTERFACE", ncsi_default_ifc);
  2375. // snprintf(interfaceName, sizeof(interfaceName), "%s", ncsi_default_ifc);
  2376. // if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
  2377. // {
  2378. // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
  2379. // return sizeof(GetLanCCRev_T);
  2380. // }
  2381. // char Interface[2];
  2382. // snprintf(Interface, sizeof(Interface), "%c", interfaceName[3]);
  2383. // pGetLanRes->ConfigData.NCSIPHYConfigGet.Interface = atoi(Interface);
  2384. // pGetLanRes->ConfigData.NCSIPHYConfigGet.VetoBit = configData.VetoBit;
  2385. // return sizeof(GetLanCCRev_T) + sizeof(NCSIPHYConfigGet_T);
  2386. // }
  2387. // else
  2388. // {
  2389. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  2390. // return sizeof(GetLanCCRev_T);
  2391. // }
  2392. // }
  2393. // break;
  2394. // default:
  2395. // TDBG("In Valid Option\n");
  2396. // }
  2397. // }
  2398. // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
  2399. // return sizeof(uint8_t);
  2400. // }
  2401. // }
  2402. // return sizeof(GetLanCCRev_T) + LanconfigParameterLength[pGetLanReq->ParameterSelect];
  2403. // }
  2404. // /*---------------------------------------------------
  2405. // * SuspendBMCArps
  2406. // *---------------------------------------------------*/
  2407. // int
  2408. // SuspendBMCArps (_NEAR_ uint8_t* pReq, uint8_t ReqLen, _NEAR_ uint8_t* pRes,_NEAR_ int BMCInst)
  2409. // {
  2410. // _NEAR_ SuspendBMCArpsReq_T* pArpReq = (_NEAR_ SuspendBMCArpsReq_T*) pReq;
  2411. // _NEAR_ SuspendBMCArpsRes_T* pArpRes = (_NEAR_ SuspendBMCArpsRes_T*) pRes;
  2412. // uint8_t EthIndex;
  2413. // /* Verify Channel ID */
  2414. // pArpRes->CompletionCode = CC_INV_DATA_FIELD;
  2415. // if(pArpReq->ChannelNo & RESERVED_BITS_SUSPENDBMCARPS) return sizeof(*pRes);
  2416. // if (!IsLANChannel(pArpReq->ChannelNo & CHANNEL_ID_MASK, BMCInst) )
  2417. // {
  2418. // return sizeof (*pRes);
  2419. // }
  2420. // EthIndex= GetEthIndex(pArpReq->ChannelNo & 0x0F,BMCInst);
  2421. // if(0xff == EthIndex)
  2422. // {
  2423. // return sizeof (*pRes);
  2424. // }
  2425. // /* Reserved Bits Validation */
  2426. // if (0 != (SUSPEND_ARP_RSVD_BIT_MASK & pArpReq->ArpSuspend))
  2427. // {
  2428. // return sizeof (*pRes);
  2429. // }
  2430. // if (BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning == TRUE)
  2431. // BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex] = pArpReq->ArpSuspend;
  2432. // /* Update Response */
  2433. // pArpRes->CompletionCode = CC_NORMAL;
  2434. // pArpRes->ArpSuspendStatus = UpdateArpStatus(EthIndex, BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning, BMCInst);
  2435. // return sizeof (SuspendBMCArpsRes_T);
  2436. // }
  2437. // /*---------------------------------------------------
  2438. // * GetIPUDPRMCPStats
  2439. // *---------------------------------------------------*/
  2440. // int
  2441. // GetIPUDPRMCPStats (_NEAR_ uint8_t* pReq, uint8_t ReqLen, _NEAR_ uint8_t* pRes,_NEAR_ int BMCInst)
  2442. // {
  2443. // _NEAR_ GetIPUDPRMCPStatsReq_T* pGetIPUDPRMCPStatsReq = (_NEAR_ GetIPUDPRMCPStatsReq_T*) pReq;
  2444. // _NEAR_ GetIPUDPRMCPStatsRes_T* pGetIPUDPRMCPStatsRes = (_NEAR_ GetIPUDPRMCPStatsRes_T*) pRes;
  2445. // _FAR_ BMCSharedMem_T* pSharedMem = BMC_GET_SHARED_MEM (BMCInst);
  2446. // FILE *fptr;
  2447. // char FDRead[512], FSRead[512];
  2448. // char *result = NULL;
  2449. // char **StrArray;
  2450. // int count = 0;
  2451. // int cStrings =0;
  2452. // if(pGetIPUDPRMCPStatsReq->ChannelNo & RESERVED_BITS_GETIPUDPRMCPSTATS_CH)
  2453. // {
  2454. // *pRes = CC_INV_DATA_FIELD;
  2455. // return sizeof(*pRes);
  2456. // }
  2457. // if(pGetIPUDPRMCPStatsReq->ClearStatus & RESERVED_BITS_GETIPUDPRMCPSTATS_CLRSTATE)
  2458. // {
  2459. // *pRes = CC_INV_DATA_FIELD;
  2460. // return sizeof(*pRes);
  2461. // }
  2462. // //Channel number [3:0] is valid.
  2463. // if ( !IsLANChannel(pGetIPUDPRMCPStatsReq->ChannelNo & CHANNEL_ID_MASK, BMCInst) )
  2464. // {
  2465. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_INV_DATA_FIELD;
  2466. // return sizeof (*pRes);
  2467. // }
  2468. // //Clear the statistics if 1 is given in request.
  2469. // if ( pGetIPUDPRMCPStatsReq->ClearStatus & 0x01 )
  2470. // {
  2471. // /* <TBD BalaT>
  2472. // * Have to clear the already stored statistics when clear req is 1.
  2473. // */
  2474. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
  2475. // return sizeof (uint8_t);
  2476. // }
  2477. // //All Statistics values are initialised to 0.
  2478. // memset (pGetIPUDPRMCPStatsRes, 0, sizeof(GetIPUDPRMCPStatsRes_T) );
  2479. // //All the datas are taken from /proc/net/snmp file
  2480. // fptr = fopen ("/proc/net/snmp","r+");
  2481. // if (fptr == NULL)
  2482. // {
  2483. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_COULD_NOT_PROVIDE_RESP;
  2484. // return sizeof (uint8_t);
  2485. // }
  2486. // while( NULL != fgets(FDRead,512,fptr) )
  2487. // {
  2488. // if ( NULL != strstr (FDRead, "Ip: ") )
  2489. // {
  2490. // count++;
  2491. // if (count == 2)
  2492. // {
  2493. // //To find the no. of valid strings in a line.
  2494. // strcpy (FSRead, FDRead);
  2495. // result = strtok( FSRead, " " );
  2496. // while( result != NULL )
  2497. // {
  2498. // cStrings++;
  2499. // result = strtok( NULL, " " );
  2500. // }
  2501. // //Condition to check so that explode doesnt try to read the strings from unknown location.
  2502. // if ( cStrings == 20)
  2503. // {
  2504. // StrArray = explode (' ', FDRead);
  2505. // }
  2506. // else
  2507. // {
  2508. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
  2509. // return sizeof (uint8_t);
  2510. // }
  2511. // //All Statistics stops acumulating at FFFFh unless otherwise noted.
  2512. // //IP packets received.
  2513. // if ( atol((char *)StrArray[3]) > 0xffff)
  2514. // pGetIPUDPRMCPStatsRes->IPPacketsRecv = ( ( atol((char *)StrArray[3]) ) % 65535);
  2515. // else
  2516. // pGetIPUDPRMCPStatsRes->IPPacketsRecv = atoi((char *)StrArray[3]);
  2517. // //IP Header Error.
  2518. // pGetIPUDPRMCPStatsRes->IPHeaderErr = atoi((char *)StrArray[4]);
  2519. // //IP Address Error.
  2520. // if ( atol((char *)StrArray[5]) > 0xffff)
  2521. // pGetIPUDPRMCPStatsRes->IPAddrErr = ( ( atol((char *)StrArray[5]) ) % 65535);
  2522. // else
  2523. // pGetIPUDPRMCPStatsRes->IPAddrErr = atoi((char *)StrArray[5]);
  2524. // //Fragmented IP Packets received.
  2525. // if ( atol((char *)StrArray[17]) > 0xffff)
  2526. // pGetIPUDPRMCPStatsRes->FragIPPacketsRecv = ( ( atol((char *)StrArray[17]) ) % 65535);
  2527. // else
  2528. // pGetIPUDPRMCPStatsRes->FragIPPacketsRecv = atoi((char *)StrArray[17]);
  2529. // //IP packets Transmitted.
  2530. // if ( atol((char *)StrArray[10]) > 0xffff)
  2531. // pGetIPUDPRMCPStatsRes->IPPacketsTrans = ( ( atol((char *)StrArray[10]) ) % 65535);
  2532. // else
  2533. // pGetIPUDPRMCPStatsRes->IPPacketsTrans = atoi((char *)StrArray[10]);
  2534. // count = 0;
  2535. // }
  2536. // }
  2537. // if ( NULL != strstr (FDRead, "Udp: ") )
  2538. // {
  2539. // count++;
  2540. // if (count == 2)
  2541. // {
  2542. // //To find the no. of valid strings in a line.
  2543. // cStrings = 0;
  2544. // strcpy (FSRead, FDRead);
  2545. // result = strtok( FSRead, " " );
  2546. // while( result != NULL )
  2547. // {
  2548. // cStrings++;
  2549. // result = strtok( NULL, " " );
  2550. // }
  2551. // //Condition to check so that explode doesnt try to read the strings beyond the valid location.
  2552. // if ( cStrings == 5)
  2553. // {
  2554. // StrArray = explode (' ', FDRead);
  2555. // }
  2556. // else
  2557. // {
  2558. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
  2559. // return sizeof (uint8_t);
  2560. // }
  2561. // //UDP packets received.
  2562. // if ( atol((char *)StrArray[1]) > 0xffff)
  2563. // pGetIPUDPRMCPStatsRes->UDPPacketsRecv = ( ( atol((char *)StrArray[1]) ) % 65535);
  2564. // else
  2565. // pGetIPUDPRMCPStatsRes->UDPPacketsRecv = atoi((char *)StrArray[1]);
  2566. // count = 0;
  2567. // }
  2568. // }
  2569. // }
  2570. // fclose(fptr);
  2571. // //Valid RMCP packets received.
  2572. // pGetIPUDPRMCPStatsRes->ValidRMCPPackets = pSharedMem->gIPUDPRMCPStats;
  2573. // //<TBD BalaT>To store the statistics across the system reset and power cycles
  2574. // pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
  2575. // return sizeof (GetIPUDPRMCPStatsRes_T);
  2576. // }
  2577. // /*-----------------------------------------------------
  2578. // * explode
  2579. // * Funntion to split the strings and store in an array
  2580. // *-----------------------------------------------------*/
  2581. // char **explode(char separator, char *string)
  2582. // {
  2583. // int start = 0, i, k = 1, count = 2;
  2584. // char **strarr;
  2585. // for (i = 0; string[i] != '\0'; i++)
  2586. // /* how many rows do we need for our array? */
  2587. // if (string[i] == separator)
  2588. // count++;
  2589. // /* count is at least 2 to make room for the entire string
  2590. // * * and the ending NULL */
  2591. // strarr = malloc(count * sizeof(char*));
  2592. // i = 0;
  2593. // while (*string++ != '\0')
  2594. // {
  2595. // if (*string == separator)
  2596. // {
  2597. // strarr[i] = malloc(k - start + 2);
  2598. // strncpy(strarr[i], string - k + start, k - start + 1);
  2599. // strarr[i][k - start + 1] = '\0'; /* guarantee null termination */
  2600. // start = k;
  2601. // i++;
  2602. // }
  2603. // k++;
  2604. // }
  2605. // /* copy the last part of the string after the last separator */
  2606. // strarr[i] = malloc(k - start);
  2607. // strncpy(strarr[i], string - k + start, k - start - 1);
  2608. // strarr[i][k - start - 1] = '\0'; /* guarantee null termination */
  2609. // strarr[++i] = NULL;
  2610. // return strarr;
  2611. // }
  2612. // /*----------------------------------------------
  2613. // * UpdateArpStatus
  2614. // *----------------------------------------------*/
  2615. // uint8_t
  2616. // UpdateArpStatus (uint8_t EthIndex,BOOL IsTimerRunning, int BMCInst)
  2617. // {
  2618. // uint8_t GratArpSuspend;
  2619. // uint8_t ArpSuspend;
  2620. // uint8_t Status;
  2621. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  2622. // char Cmds[50]={0}; // command string to perform BMC-generated ARP
  2623. // char IfcName[16];
  2624. // IPMI_DBG_PRINT_1 ("Timer - %x", IsTimerRunning);
  2625. // GratArpSuspend = ArpSuspend = 1;
  2626. // // Check Gratuitous ARP is Enabled
  2627. // if (0 == (pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl & GRATIUTOUS_ENABLE_MASK))
  2628. // {
  2629. // GratArpSuspend = 0;
  2630. // }
  2631. // // Check ARP Response is Enabled
  2632. // if (0 == (pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl & ENABLE_ARP_RESPONSES))
  2633. // {
  2634. // ArpSuspend = 0;
  2635. // }
  2636. // /*Disable ARP */
  2637. // if (TRUE == IsTimerRunning)
  2638. // {
  2639. // /* WDT is running, check and suspend ARP if necessary */
  2640. // if( (0 != (BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex] & SUSPEND_GRAT_ARP)) &&
  2641. // (0 < GratArpSuspend) )
  2642. // {
  2643. // GratArpSuspend--;
  2644. // }
  2645. // if( (0 != (BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex] & SUSPEND_ARP)) &&
  2646. // (0 < ArpSuspend) )
  2647. // {
  2648. // ArpSuspend--;
  2649. // }
  2650. // }
  2651. // memset(IfcName,0,sizeof(IfcName));
  2652. // if(GetIfcName(EthIndex, IfcName, BMCInst) != 0)
  2653. // {
  2654. // TCRIT("Error in getting Interface Name for the Lan Index :%d\n", EthIndex);
  2655. // }
  2656. // else
  2657. // {
  2658. // /* Perform commands for BMC-generated Arp */
  2659. // memset(Cmds, 0, sizeof(Cmds));
  2660. // sprintf(Cmds, "/usr/local/bin/ArpSwitch.sh %s %d", IfcName, (!ArpSuspend) ? ARP_IGNORE_ON : ARP_IGNORE_OFF);
  2661. // safe_system (Cmds);
  2662. // /* Perform commands for BMC-generated Arp ends */
  2663. // }
  2664. // /* Update Status */
  2665. // Status = ArpSuspend << 1;
  2666. // Status = Status | GratArpSuspend;
  2667. // return Status;
  2668. // }
  2669. // /**
  2670. // *@fn NwInterfacePresenceCheck
  2671. // *@brief This function is invoked to check network interface presence
  2672. // *@param Interface - Char Pointer to Interface for which interface to check
  2673. // *@return Returns 0 on success
  2674. // */
  2675. // static int
  2676. // NwInterfacePresenceCheck (char * Interface)
  2677. // {
  2678. // int r;
  2679. // int sockdes;
  2680. // struct ifreq Ifreq;
  2681. // unsigned char MAC[MAC_ADDR_LEN];
  2682. // IPMI_DBG_PRINT_1 ("Checking the presence of %s\n", Interface);
  2683. // sockdes = socket(PF_INET, SOCK_DGRAM, 0 );
  2684. // if ( sockdes < 0 )
  2685. // {
  2686. // IPMI_ERROR("can't open socket: %s\n",strerror(errno));
  2687. // return -1;
  2688. // }
  2689. // /* Get MAC address */
  2690. // memset(&Ifreq,0,sizeof(struct ifreq));
  2691. // memset(MAC, 0, MAC_ADDR_LEN);
  2692. // strcpy(Ifreq.ifr_name, Interface);
  2693. // Ifreq.ifr_hwaddr.sa_family = AF_INET;
  2694. // r = ioctl(sockdes, SIOCGIFHWADDR, &Ifreq);
  2695. // close (sockdes);
  2696. // if ( r < 0 )
  2697. // {
  2698. // //IPMI_ERROR("IOCTL to get MAC failed: %d\n",r);
  2699. // return -1;
  2700. // }
  2701. // IPMI_DBG_PRINT_1 (" %s Interface is present\n", Interface);
  2702. // return 0;
  2703. // }