123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418 |
- #include <stdio.h>
- #include <stdint.h>
- //#include <linux/if.h>
- #include <linux/ip.h>
- //#include <dlfcn.h>
- #include <sys/prctl.h>
- //#include "nwcfg.h"
- #include "Util.h"
- #include "main.h"
- #include "Api.h"
- #include "Util.h"
- #include "com_IPMI_LANConfig.h"
- #include "com_IPMI_DeviceConfig.h"
- #include <string.h>
- /* Reserved bit macro definitions */
- #define RESERVED_BITS_SUSPENDBMCARPS 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
- #define RESERVED_BITS_GETIPUDPRMCPSTATS_CH 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
- #define RESERVED_BITS_GETIPUDPRMCPSTATS_CLRSTATE 0xFE //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1)
- /*** Local definitions ***/
- #define CHANNEL_ID_MASK 0x0f
- #define SET_IN_PROGRESS_MASK 0x03
- #define PARAMETER_REVISION_MASK 0x0f
- #define DEST_ADDR_DATA2_ADDR_FORMAT_MASK 0xf0
- #define PARAMETER_REVISION_FORMAT 0x11
- #define GET_PARAMETER_REVISION_MASK 0x80
- #define LAN_CALLBACK_AUTH_SUPPORT 0x17 /* MD2 & MD5 supported */
- #define LAN_USER_AUTH_SUPPORT 0x17 /* MD2 & MD5 supported */
- #define LAN_OPERATOR_AUTH_SUPPORT 0x17 /* MD2 & MD5 supported */
- #define LAN_ADMIN_AUTH_SUPPORT 0x17 /* MD2 & MD5 supported */
- #define BRD_CAST_BIT_MASK 0xFF
- #define LOOP_BACK_BIT_MASK 0x7F
- #define SUBNET_MASK_BIT_CHECK 0x80
- #define LAN_CONFIGURATION_SET_IN_PROGRESS 0x01
- #define LAN_CONFIGURATION_SET_COMPLETE 0x00
- #define GRATIUTOUS_ENABLE_MASK 1
- #define ENABLE_ARP_RESPONSES 2
- #define SUSPEND_ARP_RSVD_BIT_MASK 0xFC
- #define ENABLE_ARPS 0x03
- #define SUSPEND_GRAT_ARP 0x01
- #define SUSPEND_ARP 0x02
- #define ARP_IGNORE_ON 8
- #define ARP_IGNORE_OFF 0
- /* Reserved Bits */
- #define RESERVED_VALUE_70 0x70
- #define RESERVED_VALUE_F0 0xF0
- // /**
- // *@fn NwInterfacePresenceCheck
- // *@brief This function is invoked to check network interface presence
- // *@param Interface - Char Pointer to buffer for which interface to check
- // */
- // static int NwInterfacePresenceCheck (char * Interface);
- // /*** Module Variables ***/
- // // uint8_t m_ArpSuspendReq;
- // char **explode(char separator, char *string);
- // int IPAddrCheck(uint8_t *Addr,int params);
- // extern int GetLanAMIParamValue (uint8_t* ParamSelect, uint8_t* ImpType);
- // extern IfcName_T Ifcnametable[MAX_LAN_CHANNELS];
- #define MAX_LAN_PARAMS_DATA 20
- typedef struct
- {
- uint8_t Params;
- uint8_t ReservedBits [MAX_LAN_PARAMS_DATA];
- uint8_t DataLen;
- } LANCfgRsvdBits_T;
- static LANCfgRsvdBits_T m_RsvdBitsCheck [] = {
- /* Param Reserved Bits Data Size */
- { 0, { 0xFC }, 0x1 }, /* Set In progress */
- { 1, { 0xC8 }, 0x1 }, /* Authenication type */
- { 2, { 0xC8,0xC8,0xC8,0xC8,0xC8 }, 0x5}, /* Authenication Support Enable */
- { 4, { 0xF0 }, 0x1 }, /* l */
- { 7, { 0x0,0x1F,0x01 }, 0x3 }, /* l */
- { 0xA, { 0xFC }, 0x1 }, /* l */
- { 0x11, { 0xF0 }, 0x1 }, /* l */
- { 0x12, { 0xF0,0x78,0x0,0xF8 }, 0x4 },
- { 0x13, { 0xF0,0x0F, 0xFE }, 0x3 },
- { 0x14, { 0x0,0x70}, 0x2 },
- { 0x15, { 0xF8 }, 0x1 },
- { 0x16, { 0xE0 }, 0x1 },
- { 0x17, { 0xFF }, 0x1 },
- { 0x18, { 0xFF }, 0x1 },
- { 0x19, { 0xF0,0x0F }, 0x2 },
- { 0x1A, { 0xFE }, 0x1 }
- };
- typedef struct
- {
- uint8_t OEMParam;
- uint8_t Length;
- }OEMParameterLength_T;
- static OEMParameterLength_T m_OEMParamLen [] = {
- // {LAN_PARAMS_AMI_OEM_IPV6_ENABLE, 1 },
- // {LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE, 1 },
- // {LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR, 17 },
- // {LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH, 2},
- // {LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP, 16}
- };
- /**
- * @brief LAN configuration request parameter lengths
- **/
- static const uint8_t LanconfigParameterLength [] = {
- 1, /* Set in progress */
- 1, /* Authentication type support */
- 5, /* Authentication type enables */
- 4, /* IP address */
- 1, /* IP address source */
- 6, /* MAC address */
- 4, /* Subnet mask */
- 3, /* IPv4 header parameters */
- 2, /* Primary RMCP port number */
- 2, /* Secondary RMCP port number */
- 1, /* BMC generated ARP control */
- 1, /* Gratuitous ARP */
- 4, /* Default Gateway address */
- 6, /* Default Gateway MAC address */
- 4, /* Backup Gateway address */
- 6, /* Backup Gateway MAC address */
- 18, /* Community string */
- 1, /* Number of destinations */
- 4, /* Destination type */
- 13, /* Destination address */
- 2, /* VLAN ID */
- 1, /* VLAN Priority */
- 1, /* Cipher suite entry support */
- 17, /* Cipher suite entries */
- 9, /* Cipher suite Privilege levels */
- 4, /* VLAN tags destination address */
- 6, /* Bad Password Threshold */
- (9+16) /* IPv6 Destination address */
- };
- /* A copy of ip_tos2prio with numeric format in "linux/net/ipv4/route.c" */
- static const uint8_t IP_TOS2PRIO[16] = {
- 0, /* TC_PRIO_BESTEFFORT, */
- 1, /* ECN_OR_COST(FILLER), */
- 0, /* TC_PRIO_BESTEFFORT, */
- 0, /* ECN_OR_COST(BESTEFFORT), */
- 2, /* TC_PRIO_BULK, */
- 2, /* ECN_OR_COST(BULK), */
- 2, /* TC_PRIO_BULK, */
- 2, /* ECN_OR_COST(BULK), */
- 6, /* TC_PRIO_INTERACTIVE, */
- 6, /* ECN_OR_COST(INTERACTIVE), */
- 6, /* TC_PRIO_INTERACTIVE, */
- 6, /* ECN_OR_COST(INTERACTIVE), */
- 4, /* TC_PRIO_INTERACTIVE_BULK, */
- 4, /* ECN_OR_COST(INTERACTIVE_BULK),*/
- 4, /* TC_PRIO_INTERACTIVE_BULK, */
- 4 /* ECN_OR_COST(INTERACTIVE_BULK) */
- };
- static uint8_t enableSetMACAddr = TRUE; //jimbo notice
- /*-------------------------------------------------------
- * SetLanConfigParam
- *-------------------------------------------------------*/
- int
- SetLanConfigParam ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes)
- {
- SetLanConfigReq_T* pSetLanReq = ( SetLanConfigReq_T*) pReq;
- SetLanConfigRes_T* pSetLanRes = ( SetLanConfigRes_T*) pRes;
- MsgPkt_T m_MsgPkt;
- int i,j=0;
- uint8_t index;
- int retValue=0,NIC_Count = 0;
- // uint16_t PriorityLevel[MAX_LAN_CHANNELS]= {0};
- uint8_t m_Lan_SetInProgress; /**< Contains setting LAN configuration status */
-
- uint8_t InvalidMac[MAC_ADDR_LEN] = {0,0,0,0,0,0};
- char old_mac[18];
- char macStr[18] = {0};
- char old_ip[16];
- char ipStr[16] = {0};
- char old_netmask[18];
- char netmaskStr[18] = {0};
- if ( ReqLen >= 2 )
- {
- ReqLen -= 2;
- }
- else
- {
- *pRes = CC_REQ_INV_LEN;
- return 1;
- }
-
- //自定义
- // if((pSetLanReq->ParameterSelect >= MIN_LAN_OEM_CONF_PARAM) &&
- // (pSetLanReq->ParameterSelect <= MAX_LAN_OEM_CONF_PARAM) )
- // {
- // /* Converts OEM parameter value to equivalent AMI parameter value */
- // if (0 != GetLanAMIParamValue (&pSetLanReq->ParameterSelect, &IsOemDefined) )
- // {
- // pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
- // return sizeof(uint8_t);
- // }
- // /* Hook for OEM to handle this parameter */
- // if ( (IsOemDefined) && (g_PDKHandle[PDK_SETLANOEMPARAM] != NULL) )
- // {
- // return ((int(*)(uint8_t *, uint8_t, uint8_t *,int))(g_PDKHandle[PDK_SETLANOEMPARAM]))(pReq, ReqLen, pRes, BMCInst);
- // }
-
- // }
- if(0x1b >pSetLanReq->ParameterSelect ) //Max known Lan paramter
- {
- if (ReqLen != LanconfigParameterLength [pSetLanReq->ParameterSelect ])
- {
- *pRes = CC_REQ_INV_LEN;
- return sizeof (uint8_t);
- }
- }
- // /*Check the Request length for OEM parameter*/
- // for(i=0;i<sizeof(m_OEMParamLen)/sizeof(OEMParameterLength_T);i++)
- // {
- // if(m_OEMParamLen[i].OEMParam == pSetLanReq->ParameterSelect)
- // {
- // if(ReqLen != m_OEMParamLen[i].Length)
- // {
- // *pRes = CC_REQ_INV_LEN;
- // return sizeof(uint8_t);
- // }
- // }
- // }
- if(pSetLanReq->ChannelNum & RESERVED_VALUE_F0)
- {
- /* Alarm !!! Somebody is trying to set Reseved Bits */
- *pRes = CC_INV_DATA_FIELD;
- return sizeof (*pRes);
- }
- if(pSetLanReq->ChannelNum == LAN_RMCP_CHANNEL)
- index = 0;
- else
- {
- *pRes = CC_INV_DATA_FIELD;
- return sizeof (*pRes);
- }
-
- /* Check for Reserved Bits */
- for (i = 0; i < sizeof (m_RsvdBitsCheck)/ sizeof (m_RsvdBitsCheck[0]); i++)
- {
- /* Check if this Parameter Selector needs Reserved bit checking !! */
- if (m_RsvdBitsCheck[i].Params == pSetLanReq->ParameterSelect)
- {
- //IPMI_DBG_PRINT_2 ("Param - %x, DataLen - %x\n", pSetLanReq->ParameterSelect, m_RsvdBitsCheck[i].DataLen);
- for (j = 0; j < m_RsvdBitsCheck[i].DataLen; j++)
- {
- // IPMI_DBG_PRINT_2 ("Cmp %x, %x\n", pReq[2+j], m_RsvdBitsCheck[i].ReservedBits[j]);
- if ( 0 != (pReq[2+j] & m_RsvdBitsCheck[i].ReservedBits[j]))
- {
- /* Alarm !!! Somebody is trying to set Reseved Bits */
- *pRes = CC_INV_DATA_FIELD;
- return sizeof (*pRes);
- }
- }
- }
- }
- // ptrChannelInfo = getChannelInfo (pSetLanReq->ChannelNum & 0x0F, BMCInst);
- // if(NULL == ptrChannelInfo)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
-
- printf ("Parameter = %X\n", pSetLanReq->ParameterSelect);
-
- switch (pSetLanReq->ParameterSelect)
- {
- case LAN_PARAM_SET_IN_PROGRESS:
- m_Lan_SetInProgress = g_BMCInfo.m_Lan_SetInProgress;
-
- /* Commit Write is optional and supported
- * only if rollback is supported */
- if ( (GetBits(pSetLanReq->ConfigData.SetInProgress, SET_IN_PROGRESS_MASK) !=
- LAN_CONFIGURATION_SET_COMPLETE) &&
- (GetBits(pSetLanReq->ConfigData.SetInProgress, SET_IN_PROGRESS_MASK) !=
- LAN_CONFIGURATION_SET_IN_PROGRESS) )
- {
- pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
- return sizeof(*pSetLanRes);
- }
- else if ((GetBits(m_Lan_SetInProgress, SET_IN_PROGRESS_MASK) ==
- LAN_CONFIGURATION_SET_IN_PROGRESS) &&
- (GetBits(pSetLanReq->ConfigData.SetInProgress, SET_IN_PROGRESS_MASK) ==
- LAN_CONFIGURATION_SET_IN_PROGRESS))
- {
- pSetLanRes->CompletionCode = CC_SET_IN_PROGRESS;
- return sizeof(*pSetLanRes);
- }
- g_BMCInfo.m_Lan_SetInProgress = pSetLanReq->ConfigData.SetInProgress;
- break;
- case LAN_PARAM_AUTH_TYPE_SUPPORT:
- pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
- return sizeof(*pRes);
- case LAN_PARAM_AUTH_TYPE_ENABLES:
- printf("---> Not implement!\n");
- // for(i=0;i<5;i++)
- // {
- // /* Check for Unsupported AuthType */
- // if (pBMCInfo->LANCfs[EthIndex].AuthTypeSupport != (pBMCInfo->LANCfs[EthIndex].AuthTypeSupport |pReq[2+i]))
- // {
- // IPMI_DBG_PRINT_2("\n Alarm !!! Somebody is trying to Unsupported Bit :%d \t%d\n",pReq[2+i],i);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // }
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (&pBMCInfo->LANCfs[EthIndex].AuthTypeEnables,
- // &(pSetLanReq->ConfigData.AuthTypeEnables), sizeof(AuthTypeEnables_T));
- // _fmemcpy (ptrChannelInfo->AuthType,
- // &(pSetLanReq->ConfigData.AuthTypeEnables), sizeof(AuthTypeEnables_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- break;
- case LAN_PARAM_IP_ADDRESS: //post cmd to chassisTimerTask
- if(IPAddrCheck(pSetLanReq->ConfigData.IPAddr,LAN_PARAM_IP_ADDRESS))
- {
- *pRes = CC_INV_DATA_FIELD;
- return sizeof (uint8_t);
- }
- getip(old_ip);
- sprintf(ipStr, "%d.%d.%d.%d", pSetLanReq->ConfigData.IPAddr[0],
- pSetLanReq->ConfigData.IPAddr[1], pSetLanReq->ConfigData.IPAddr[2],
- pSetLanReq->ConfigData.IPAddr[3]);
- if(strcmp(ipStr, old_ip) == 0)
- {
- printf("The same ip %s, do nothing\n", ipStr );
- *pRes = CC_NORMAL;
- return 1;
- }
- m_MsgPkt.Param = PARAM_LAN;
- m_MsgPkt.NetFnLUN = NETFNLUN_IPMI_TRANSPORT;
- m_MsgPkt.Cmd = CMD_SET_LAN_CONFIGURATION_PARAMETERS;
- m_MsgPkt.Size = sizeof(SetLanConfigReq_T);
- memcpy(m_MsgPkt.Data, pSetLanReq, sizeof(SetLanConfigReq_T));
- PostMsg(gPendActionIfc, &m_MsgPkt);
- //Update
- memcpy(g_BMCInfo.LanInfo[index].IPAddr, pSetLanReq->ConfigData.IPAddr, 4);
- FlushIpmiConfig();
- printf("---> old_ip: %s, new_ip: %s\n", old_ip, ipStr);
- printf("---> send data: %#x %#x %#x %#x %#x\n", m_MsgPkt.Data[0], m_MsgPkt.Data[1]
- , m_MsgPkt.Data[2], m_MsgPkt.Data[3], m_MsgPkt.Data[4]);
- break;
- case LAN_PARAM_IP_ADDRESS_SOURCE:
- printf("---> Not implement!\n");
- //Update
- g_BMCInfo.LanInfo[index].IPAddrSrc = pSetLanReq->ConfigData.IPAddrSrc ;
- FlushIpmiConfig();
- // if ((pSetLanReq->ConfigData.IPAddrSrc > BMC_OTHER_SOURCE)
- // ||(pSetLanReq->ConfigData.IPAddrSrc == UNSPECIFIED_IP_SOURCE))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (uint8_t);
- // }
- // if ( g_BMCInfo.IpmiConfig.IPAddrSrc == pSetLanReq->ConfigData.IPAddrSrc )
- // {
- // printf("LAN or VLAN if current SRC is DHCP/Static and incoming SRC is DHCP/Static, do nothing\n");
- // break;
- // }
- // if(!((pSetLanReq->ConfigData.IPAddrSrc == STATIC_IP_SOURCE ) || (pSetLanReq->ConfigData.IPAddrSrc == DHCP_IP_SOURCE )))
- // g_BMCInfo.IpmiConfig.IPAddrSrc = pSetLanReq->ConfigData.IPAddrSrc ;
- // if ( (pSetLanReq->ConfigData.IPAddrSrc == STATIC_IP_SOURCE ) || (pSetLanReq->ConfigData.IPAddrSrc == DHCP_IP_SOURCE ) )
- // {
- // pendStatus = GetPendStatus(PEND_OP_SET_SOURCE);
- // if(pendStatus == PEND_STATUS_PENDING)
- // {
- // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (uint8_t);
- // }
- // pBMCInfo->LANCfs[EthIndex].IPAddrSrc = pSetLanReq->ConfigData.IPAddrSrc ;
- // NWConfig.CfgMethod = pSetLanReq->ConfigData.IPAddrSrc;
- // SetPendStatus(PEND_OP_SET_SOURCE,PEND_STATUS_PENDING);
- // PostPendTask(PEND_OP_SET_SOURCE,(uint8_t*) &NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
- // }
- // else if(pSetLanReq->ConfigData.IPAddrSrc == BIOS_IP_SOURCE)
- // {
- // /*Perform OEM action*/
- // if(g_PDKHandle[PDK_BIOSIPSOURCE] != NULL)
- // {
- // retValue = ((int(*)(uint8_t))g_PDKHandle[PDK_BIOSIPSOURCE]) (pSetLanReq->ChannelNum & CHANNEL_ID_MASK);
- // if(retValue == 1)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // }
- // else
- // {
- // pendStatus = GetPendStatus(PEND_OP_SET_SOURCE);
- // if(pendStatus == PEND_STATUS_PENDING)
- // {
- // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (uint8_t);
- // }
- // NWConfig.CfgMethod = STATIC_IP_SOURCE;
- // SetPendStatus(PEND_OP_SET_SOURCE,PEND_STATUS_PENDING);
- // PostPendTask(PEND_OP_SET_SOURCE, (uint8_t*) &NWConfig,sizeof(NWConfig), (pSetLanReq->ChannelNum & CHANNEL_ID_MASK), BMCInst );
- // }
- // }
- // else if(pSetLanReq->ConfigData.IPAddrSrc == BMC_OTHER_SOURCE)
- // {
- // /*Perform OEM action*/
- // if(g_PDKHandle[PDK_BMCOTHERSOURCEIP] != NULL)
- // {
- // retValue = ((int(*)(uint8_t))g_PDKHandle[PDK_BMCOTHERSOURCEIP]) (pSetLanReq->ChannelNum & CHANNEL_ID_MASK);
- // if(retValue == 1)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // }
- // else
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // }
- break;
- case LAN_PARAM_MAC_ADDRESS:
- /* According to IPMI 2.0 Specification Revision 3, the MAC address can be read only parameter*/
- //*pRes = CC_ATTEMPT_TO_SET_RO_PARAM;
- //return sizeof (*pRes);
-
- if((pSetLanReq->ConfigData.MACAddr[0]& BIT0)|| (memcmp(&InvalidMac,&pSetLanReq->ConfigData.MACAddr,MAC_ADDR_LEN) == 0))
- {
- pSetLanRes->CompletionCode = CC_INV_DATA_FIELD;
- return 1;
- }
- getmac(old_mac);
- sprintf(macStr, "%02x:%02x:%02x:%02x:%02x:%02x", pSetLanReq->ConfigData.MACAddr[0],
- pSetLanReq->ConfigData.MACAddr[1], pSetLanReq->ConfigData.MACAddr[2],
- pSetLanReq->ConfigData.MACAddr[3], pSetLanReq->ConfigData.MACAddr[4],
- pSetLanReq->ConfigData.MACAddr[5]);
- if(strcmp(macStr, old_mac) == 0)
- {
- printf("The same mac %s, do nothing\n", macStr );
- *pRes = CC_NORMAL;
- return 1;
- }
- if (!enableSetMACAddr)
- pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
- else
- {
- m_MsgPkt.Param = PARAM_LAN;
- m_MsgPkt.NetFnLUN = NETFNLUN_IPMI_TRANSPORT;
- m_MsgPkt.Cmd = CMD_SET_LAN_CONFIGURATION_PARAMETERS;
- m_MsgPkt.Size = sizeof(SetLanConfigReq_T);
- memcpy(m_MsgPkt.Data, pSetLanReq, sizeof(SetLanConfigReq_T));
- PostMsg(gPendActionIfc, &m_MsgPkt);
- //Update
- memcpy(g_BMCInfo.LanInfo[index].MACAddr, pSetLanReq->ConfigData.MACAddr, 6);
- FlushIpmiConfig();
- printf("---> old_mac: %s, new_mac: %s\n", old_mac, macStr);
- pSetLanRes->CompletionCode = CC_NORMAL;
- }
-
- break;
- case LAN_PARAM_SUBNET_MASK:
- /*Returning valid completion code in case of attempt to set netmask in DHCP mode */
- if(g_BMCInfo.LanInfo[index].IPAddrSrc == DHCP_IP_SOURCE)
- {
- *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- return sizeof (uint8_t);
- }
- getnetmask(old_netmask);
- sprintf(netmaskStr, "%d.%d.%d.%d", pSetLanReq->ConfigData.SubNetMask[0],
- pSetLanReq->ConfigData.SubNetMask[1], pSetLanReq->ConfigData.SubNetMask[2],
- pSetLanReq->ConfigData.SubNetMask[3]);
- if(strcmp(netmaskStr, old_netmask) == 0)
- {
- printf("The same netmask %s, do nothing\n", netmaskStr );
- *pRes = CC_NORMAL;
- return 1;
- }
-
- if(IPAddrCheck(pSetLanReq->ConfigData.SubNetMask,LAN_PARAM_SUBNET_MASK))
- {
- *pRes = CC_INV_DATA_FIELD;
- return sizeof (uint8_t);
- }
- m_MsgPkt.Param = PARAM_LAN;
- m_MsgPkt.NetFnLUN = NETFNLUN_IPMI_TRANSPORT;
- m_MsgPkt.Cmd = CMD_SET_LAN_CONFIGURATION_PARAMETERS;
- m_MsgPkt.Size = sizeof(SetLanConfigReq_T);
- memcpy(m_MsgPkt.Data, pSetLanReq, sizeof(SetLanConfigReq_T));
- PostMsg(gPendActionIfc, &m_MsgPkt);
- //Update
- memcpy(g_BMCInfo.LanInfo[index].NetMask, pSetLanReq->ConfigData.SubNetMask, 4);
- FlushIpmiConfig();
- pSetLanRes->CompletionCode = CC_NORMAL;
- break;
- case LAN_PARAM_IPv4_HEADER:
- printf("Not implement\n");
- // pendStatus = GetPendStatus(PEND_OP_SET_IPV4_HEADERS);
- // if(pendStatus == PEND_STATUS_PENDING)
- // {
- // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (uint8_t);
- // }
- // if(!pSetLanReq->ConfigData.Ipv4HdrParam.TimeToLive > 0)
- // {
- // IPMI_DBG_PRINT("The requested IPv4 header(TTL) to set is invalid.\n");
- // *pRes = CC_PARAM_OUT_OF_RANGE;
- // return sizeof(*pRes);
- // }
- // if(pSetLanReq->ConfigData.Ipv4HdrParam.IpHeaderFlags == 0x60) // Flags can be either of the values: DF(0x40) or MF(0x20)
- // {
- // IPMI_DBG_PRINT("The requested IPv4 header(Flags) to set is invalid.\n");
- // *pRes = CC_PARAM_OUT_OF_RANGE;
- // return sizeof(*pRes);
- // }
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (&pBMCInfo->LANCfs[EthIndex].Ipv4HdrParam,
- // &pSetLanReq->ConfigData.Ipv4HdrParam, sizeof(IPv4HdrParams_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // SetPendStatus(PEND_OP_SET_IPV4_HEADERS,PEND_STATUS_PENDING);
- // PostPendTask(PEND_OP_SET_IPV4_HEADERS, (uint8_t*)&(pSetLanReq->ConfigData.Ipv4HdrParam),
- // sizeof(pSetLanReq->ConfigData.Ipv4HdrParam),(pSetLanReq->ChannelNum & 0x0F),BMCInst);
- break;
- case LAN_PARAM_PRI_RMCP_PORT:
- printf("Not implement\n"); //需要重启网络线程
- // pendStatus = GetPendStatus(PEND_RMCP_PORT_CHANGE);
- // if(pendStatus == PEND_STATUS_PENDING)
- // {
- // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (uint8_t);
- // }
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // pBMCInfo->LANCfs[EthIndex].PrimaryRMCPPort = ipmitoh_u16 (pSetLanReq->ConfigData.PrimaryRMCPPort);
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // SetPendStatus(PEND_RMCP_PORT_CHANGE,PEND_STATUS_PENDING);
- // PostPendTask(PEND_RMCP_PORT_CHANGE,(uint8_t*)&(pSetLanReq->ConfigData.PrimaryRMCPPort),
- // sizeof(pSetLanReq->ConfigData.PrimaryRMCPPort),(pSetLanReq->ChannelNum & 0x0F),BMCInst);
- break;
- case LAN_PARAM_SEC_RMCP_PORT:
- /* Returning Invalid error message */
- *pRes = CC_PARAM_NOT_SUPPORTED;
- return sizeof (uint8_t);
- /*pPMConfig->LANConfig[EthIndex].SecondaryPort = ipmitoh_u16 (pSetLanReq->ConfigData.SecondaryPort);*/
- break;
- case LAN_PARAM_BMC_GENERATED_ARP_CONTROL:
- printf("Not implement\n");
- // currBmcGenArpCtrl = pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl;
-
- // if(currBmcGenArpCtrl != pSetLanReq->ConfigData.BMCGeneratedARPControl)
- // pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl = pSetLanReq->ConfigData.BMCGeneratedARPControl;
- // if((ENABLE_ARP_RESPONSES & currBmcGenArpCtrl) !=
- // (ENABLE_ARP_RESPONSES & pSetLanReq->ConfigData.BMCGeneratedARPControl))
- // {
- // UpdateArpStatus(EthIndex, BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning, BMCInst);
- // }
- // if(!(GRATIUTOUS_ENABLE_MASK & currBmcGenArpCtrl) &&
- // (GRATIUTOUS_ENABLE_MASK & pSetLanReq->ConfigData.BMCGeneratedARPControl))
- // {
- // /* Create a thread to Send Gratuitous ARP Packet */
- // pLANArg = malloc(sizeof(BMCArg));
- // pLANArg->BMCInst = BMCInst;
- // pLANArg->Len = strlen((char *)&EthIndex);
- // pLANArg->Argument = malloc(pLANArg->Len);
- // memcpy(pLANArg->Argument,(char *)&EthIndex,pLANArg->Len);
-
- // OS_CREATE_THREAD ((void *)GratuitousARPTask,(void *)pLANArg, NULL);
- // }
- break;
- case LAN_PARAM_GRATITIOUS_ARP_INTERVAL:
- printf("Not implement\n");
- // pBMCInfo->LANCfs[EthIndex].GratitousARPInterval =
- // pSetLanReq->ConfigData.GratitousARPInterval;
- break;
- case LAN_PARAM_DEFAULT_GATEWAY_IP:
- /*Returning valid completion code in case of attempt to set default gateway ip in DHCP mode */
- if(g_BMCInfo.LanInfo[index].IPAddrSrc == DHCP_IP_SOURCE)
- {
- *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- return sizeof (uint8_t);
- }
-
- if(IPAddrCheck(pSetLanReq->ConfigData.DefaultGatewayIPAddr,LAN_PARAM_DEFAULT_GATEWAY_IP))
- {
- *pRes = CC_INV_DATA_FIELD;
- return sizeof (uint8_t);
- }
- m_MsgPkt.Param = PARAM_LAN;
- m_MsgPkt.NetFnLUN = NETFNLUN_IPMI_TRANSPORT;
- m_MsgPkt.Cmd = CMD_SET_LAN_CONFIGURATION_PARAMETERS;
- m_MsgPkt.Size = sizeof(SetLanConfigReq_T);
- memcpy(m_MsgPkt.Data, pSetLanReq, sizeof(SetLanConfigReq_T));
- PostMsg(gPendActionIfc, &m_MsgPkt);
- //Update
- memcpy(g_BMCInfo.LanInfo[index].DefaultGW, pSetLanReq->ConfigData.DefaultGatewayIPAddr, 4);
- FlushIpmiConfig();
- pSetLanRes->CompletionCode = CC_NORMAL;
-
- break;
- case LAN_PARAM_DEFAULT_GATEWAY_MAC:
- pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
- return sizeof(*pRes);
- break;
- case LAN_PARAM_BACKUP_GATEWAY_IP:
- printf("Not implement\n");
- // nwReadNWCfg_v4_v6( &NWConfig,&NWConfig6, netindex,g_corefeatures.global_ipv6);
- // _fmemcpy ((uint8_t*)&GWIp,pSetLanReq->ConfigData.BackupGatewayIPAddr, IP_ADDR_LEN);
- // _fmemcpy ((uint8_t*)&Subnetmask,&NWConfig.Mask[0],IP_ADDR_LEN);
- // _fmemcpy ((uint8_t*)&IPAddr,&NWConfig.IPAddr[0], IP_ADDR_LEN);
- // if(GWIp != 0)
- // {
- // if((IPAddr & Subnetmask ) != (GWIp & Subnetmask))
- // {
- // IPMI_DBG_PRINT("\n Backup GatewayIP to set is not valid \n");
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (uint8_t);
- // }
- // }
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (pBMCInfo->LANCfs[EthIndex].BackupGatewayIPAddr,
- // pSetLanReq->ConfigData.BackupGatewayIPAddr, IP_ADDR_LEN);
- // nwSetBkupGWyAddr(pSetLanReq->ConfigData.BackupGatewayIPAddr,netindex);
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- break;
- case LAN_PARAM_BACKUP_GATEWAY_MAC:
- printf("Not implement\n");
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (pBMCInfo->LANCfs[EthIndex].BackupGatewayMACAddr,
- // pSetLanReq->ConfigData.BackupGatewayMACAddr, MAC_ADDR_LEN);
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- break;
- case LAN_PARAM_COMMUNITY_STRING:
- printf("Not implement\n");
- // if (g_PDKHandle[PDK_SETSNMPCOMMUNITYNAME] != NULL )
- // {
- // if(((int(*)(uint8_t *, uint8_t,int))(g_PDKHandle[PDK_SETSNMPCOMMUNITYNAME]))(pSetLanReq->ConfigData.CommunityStr,MAX_COMM_STRING_SIZE, BMCInst)==0)
- // break;
- // }
- // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->PefConfig.PEFSharedMemMutex, WAIT_INFINITE);
- // _fmemcpy (pBMCInfo->LANCfs[EthIndex].CommunityStr,
- // pSetLanReq->ConfigData.CommunityStr, MAX_COMM_STRING_SIZE);
- // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->PefConfig.PEFSharedMemMutex);
- break;
- case LAN_PARAM_DEST_NUM:
- pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
- return sizeof(uint8_t);
- case LAN_PARAM_SELECT_DEST_TYPE:
- printf("Not implement\n");
- // // if (pSetLanReq->ConfigData.DestType.SetSelect > NUM_LAN_DESTINATION)
- // if (pSetLanReq->ConfigData.DestType.SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
- // {
- // *pRes = CC_PARAM_OUT_OF_RANGE;
- // return sizeof (*pRes);
- // }
- // if (0 == pSetLanReq->ConfigData.DestType.SetSelect)
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (&pSharedMem->VolLANDestType[EthIndex],
- // &pSetLanReq->ConfigData.DestType, sizeof(LANDestType_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // }
- // else
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (&pBMCInfo->LANCfs[EthIndex].DestType [pSetLanReq->ConfigData.DestType.SetSelect - 1],
- // &pSetLanReq->ConfigData.DestType, sizeof(LANDestType_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // }
- break;
- case LAN_PARAM_SELECT_DEST_ADDR:
- printf("Not implement\n");
- // pendStatus = GetPendStatus(PEND_OP_SET_GATEWAY);
- // if(pendStatus == PEND_STATUS_PENDING)
- // {
- // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (uint8_t);
- // }
- // // if (pSetLanReq->ConfigData.DestAddr.SetSelect > NUM_LAN_DESTINATION)
- // if (pSetLanReq->ConfigData.DestType.SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
- // {
- // *pRes = CC_PARAM_OUT_OF_RANGE ;
- // return sizeof (*pRes);
- // }
- // if (0 == pSetLanReq->ConfigData.DestAddr.SetSelect)
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (&pSharedMem->VolLANDest[EthIndex],
- // &pSetLanReq->ConfigData.DestAddr, sizeof(LANDestAddr_T));
- // memset(pSharedMem->VolLANv6Dest,0,sizeof(LANDestv6Addr_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // }
- // else
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (&pBMCInfo->LANCfs[EthIndex].DestAddr [pSetLanReq->ConfigData.DestAddr.SetSelect - 1],
- // &pSetLanReq->ConfigData.DestAddr, sizeof(LANDestAddr_T));
- // memset( &pBMCInfo->LANCfs[EthIndex].Destv6Addr [pSetLanReq->ConfigData.Destv6Addr.SetSelect -1], 0 ,
- // sizeof(LANDestv6Addr_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // }
- // /* Setting BackupGw to DefaultGw as per request to send trap */
- // if(pSetLanReq->ConfigData.DestAddr.GateWayUse == 1)
- // {
- // IPMI_DBG_PRINT("Setting Backupgw to Defaultgwip as per Request \n");
- // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy(NWConfig.Gateway,pBMCInfo->LANCfs[EthIndex].BackupGatewayIPAddr,IP_ADDR_LEN);
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // SetPendStatus(PEND_OP_SET_GATEWAY,PEND_STATUS_PENDING);
- // PostPendTask(PEND_OP_SET_GATEWAY,(uint8_t*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F),BMCInst);
- // }
- break;
- case LAN_PARAM_VLAN_ID:
- printf("Not implement\n");
- // if( pBMCInfo->IpmiConfig.VLANIfcSupport == 1)
- // {
- // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
- // if((pSetLanReq->ConfigData.VLANID & VLAN_MASK_BIT) == VLAN_MASK_BIT) /* checks for VLAN enable bit*/
- // {
- // pendStatus = GetPendStatus(PEND_OP_SET_VLAN_ID);
- // if(pendStatus == PEND_STATUS_PENDING)
- // {
- // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (uint8_t);
- // }
- // vlanID = (pSetLanReq->ConfigData.VLANID & 0xfff); /* get the vlan d from the data */
- // for(i=0;i<sizeof(InvalidVlanID)/sizeof(uint16_t);i++)
- // {
- // if(InvalidVlanID[i] != vlanID)
- // {
- // continue;
- // }
- // else /*invalid vlan id */
- // {
- // *pRes = CC_INV_DATA_FIELD ;
- // return sizeof (*pRes);
- // }
- // }
- // if ( NWConfig.VLANID != 0) /* checks if vlan id already present */
- // {
- // if(NWConfig.VLANID == vlanID)
- // {
- // TCRIT("Currently configured vlan id and incoming set vlan id are same thus, do nothing\n");
- // break;
- // }
- // memset(IfcName,0,sizeof(IfcName));
- // if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
- // {
- // TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
- // *pRes = CC_INV_DATA_FIELD ;
- // return sizeof (*pRes);
- // }
- // sprintf(VLANInterfaceName, "%s.%d", IfcName, (int)(NWConfig.VLANID));
- // if (0 == NwInterfacePresenceCheck (VLANInterfaceName))
- // {
- // pendStatus = GetPendStatus(PEND_OP_SET_VLAN_ID);
- // if(pendStatus == PEND_STATUS_PENDING)
- // {
- // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (uint8_t);
- // }
- // SetPendStatus(PEND_OP_DECONFIG_VLAN_IFC,PEND_STATUS_PENDING);
- // PostPendTask(PEND_OP_DECONFIG_VLAN_IFC,(uint8_t*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
- // pBMCInfo->LANCfs[EthIndex].VLANPriority =0;
- // }
- // }
- // NWConfig.VLANID=vlanID;
- // SetPendStatus(PEND_OP_SET_VLAN_ID,PEND_STATUS_PENDING);
- // PostPendTask(PEND_OP_SET_VLAN_ID,(uint8_t*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
- // pBMCInfo->LANCfs[EthIndex].VLANID = pSetLanReq->ConfigData.VLANID;
- // }
- // else /* Vlan Bit is Disabled */
- // {
- // if(NWConfig.VLANID==0) /* Vlan id is disabled */
- // {
- // if((pSetLanReq->ConfigData.VLANID & 0xfff)!=0)
- // {
- // pBMCInfo->LANCfs[EthIndex].VLANID = pSetLanReq->ConfigData.VLANID;
- // }
- // if((pSetLanReq->ConfigData.VLANID & 0xfff)==0)
- // {
- // if((pBMCInfo->LANCfs[EthIndex].VLANID & 0xfff)!=0)
- // {
- // pBMCInfo->LANCfs[EthIndex].VLANID = pSetLanReq->ConfigData.VLANID;
- // }
- // }
- // }
- // else /* Vlan ID is enable. so deconfigure it */
- // {
- // memset(IfcName,0,sizeof(IfcName));
- // if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
- // {
- // TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
- // *pRes = CC_INV_DATA_FIELD ;
- // return sizeof (*pRes);
- // }
- // sprintf(VLANInterfaceName, "%s.%d", IfcName, (int)(NWConfig.VLANID));
- // if (0 == NwInterfacePresenceCheck (VLANInterfaceName))
- // {
- // pendStatus = GetPendStatus(PEND_OP_SET_VLAN_ID);
- // if(pendStatus == PEND_STATUS_PENDING)
- // {
- // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (uint8_t);
- // }
- // SetPendStatus(PEND_OP_DECONFIG_VLAN_IFC,PEND_STATUS_PENDING);
- // PostPendTask(PEND_OP_DECONFIG_VLAN_IFC,(uint8_t*)&NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
- // pBMCInfo->LANCfs[EthIndex].VLANPriority =0;
- // }
- // pendStatus = GetPendStatus(PEND_OP_SET_SOURCE);
- // if(pendStatus == PEND_STATUS_PENDING)
- // {
- // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (uint8_t);
- // }
- // //NWConfig.VLANID=0;
- // NWConfig.CfgMethod = pBMCInfo->LANCfs[EthIndex].IPAddrSrc;
- // SetPendStatus(PEND_OP_SET_SOURCE,PEND_STATUS_PENDING);
- // PostPendTask(PEND_OP_SET_SOURCE,(uint8_t*) &NWConfig,sizeof(NWConfig),(pSetLanReq->ChannelNum & 0x0F), BMCInst );
- // pBMCInfo->LANCfs[EthIndex].VLANID = pSetLanReq->ConfigData.VLANID;
- // }
- // }
- // }
- // else
- // {
- // pSetLanRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof(uint8_t);
- // }
- break;
- case LAN_PARAM_VLAN_PRIORITY:
- printf("Not implement\n");
- // if( pBMCInfo->IpmiConfig.VLANIfcSupport == 1)
- // {
- // if((pBMCInfo->LANCfs[EthIndex].VLANID & VLAN_MASK_BIT) != VLAN_MASK_BIT) /* checks for VLAN enable bit*/
- // {
- // if(g_corefeatures.vlan_priorityset == ENABLED)
- // {
- // if(pSetLanReq->ConfigData.VLANPriority > 7 )
- // {
- // TCRIT(" VLAN Priority value should be 0-7 \n");
- // *pRes = CC_INV_DATA_FIELD ;
- // return sizeof (*pRes);
- // }
- // if(ReadVLANFile(VLAN_PRIORITY_SETTING_STR, PriorityLevel) == -1)
- // {
- // return -1;
- // }
- // if(WriteVLANFile(VLAN_PRIORITY_SETTING_STR, PriorityLevel, netindex,pSetLanReq->ConfigData.VLANPriority) == -1)
- // {
- // return -1;
- // }
- // pBMCInfo->LANCfs[EthIndex].VLANPriority = pSetLanReq->ConfigData.VLANPriority;
- // }
- // else
- // {
- // TCRIT(" VLAN is not Configured \n");
- // *pRes = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof (*pRes);
- // }
- // }
- // else
- // {
- // if(pSetLanReq->ConfigData.VLANPriority > 7 )
- // {
- // TCRIT(" VLAN Priority value should be 0-7 \n");
- // *pRes = CC_INV_DATA_FIELD ;
- // return sizeof (*pRes);
- // }
- // if(ReadVLANFile(VLAN_PRIORITY_SETTING_STR, PriorityLevel) == -1)
- // {
- // return -1;
- // }
- // if(WriteVLANFile(VLAN_PRIORITY_SETTING_STR, PriorityLevel, netindex,pSetLanReq->ConfigData.VLANPriority) == -1)
- // {
- // return -1;
- // }
- // pBMCInfo->LANCfs[EthIndex].VLANPriority = pSetLanReq->ConfigData.VLANPriority;
- // vlanID = (pBMCInfo->LANCfs[EthIndex].VLANID & 0xfff);
- // memset(IfcName,0,sizeof(IfcName));
- // if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
- // {
- // TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- // /*vconfig set_egress_map <valninterface> <skb_buffer> <vlan-priority>*/
- // sprintf(cmdSetPriority,"vconfig set_egress_map %s.%d 0 %d",IfcName,vlanID,pSetLanReq->ConfigData.VLANPriority);
- // if(((retValue = safe_system(cmdSetPriority)) < 0))
- // {
- // TCRIT("ERROR %d: Set VLAN Priority failed\n",retValue);
- // }
-
- // /*
- // * Set priority of IPMI commands.
- // * The skb->priority value of IPMI command will be modified by TOS option.
- // * So, use the mapping table to get the current value.
- // */
- // memset(&cmdSetPriority,0,sizeof(cmdSetPriority));
- // TOS = pBMCInfo->LANCfs[EthIndex].Ipv4HdrParam.TypeOfService;
- // SkbPriority = IP_TOS2PRIO[IPTOS_TOS(TOS)>>1];
- // sprintf(cmdSetPriority,"vconfig set_egress_map %s.%d %d %d",IfcName,vlanID,SkbPriority,pSetLanReq->ConfigData.VLANPriority);
- // if(((retValue = safe_system(cmdSetPriority)) < 0))
- // {
- // TCRIT("ERROR %d: Set VLAN IPMI Priority failed\n",retValue);
- // }
- // }
- // }
- // else
- // {
- // pSetLanRes->CompletionCode = CC_PARAM_NOT_SUP_IN_CUR_STATE;
- // return sizeof(uint8_t);
- // }
- break;
- case LAN_PARAM_CIPHER_SUITE_ENTRY_SUP:
- pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
- return sizeof(uint8_t);
- case LAN_PARAM_CIPHER_SUITE_ENTRIES:
- pSetLanRes->CompletionCode = CC_ATTEMPT_TO_SET_RO_PARAM;
- return sizeof(uint8_t);
- break;
- case LAN_PARAM_CIPHER_SUITE_PRIV_LEVELS:
- printf("Not implement\n");
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (pBMCInfo->LANCfs[EthIndex].CipherSuitePrivLevels,
- // pSetLanReq->ConfigData.CipherSuitePrivLevels, MAX_NUM_CIPHER_SUITE_PRIV_LEVELS);
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- break;
- case LAN_PARAM_VLAN_TAGS:
- printf("Not implement\n");
- // if (0 == pSetLanReq->ConfigData.DestAddr.SetSelect)
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy(&pSharedMem->VLANDestTag,
- // (( uint8_t*)&pSetLanReq->ConfigData) + 1, sizeof(VLANDestTags_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // }
- // else
- // {
- // if (pSetLanReq->ConfigData.DestAddr.SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest)
- // {
- // pSetLanRes->CompletionCode = CC_PARAM_OUT_OF_RANGE;
- // return sizeof (uint8_t);
- // }
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy(&pBMCInfo->LANCfs[EthIndex].VLANDestTags [pSetLanReq->ConfigData.DestAddr.SetSelect - 1],
- // (( uint8_t*)&pSetLanReq->ConfigData) + 1, sizeof(VLANDestTags_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // }
- break;
- case LAN_PARAMS_BAD_PASSWORD_THRESHOLD:
- printf("Not implement\n");
- // ClearUserLockAttempts(LAN_CHANNEL_BADP,BMCInst);
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy(&pBMCInfo->LANCfs[EthIndex].BadPasswd,
- // &pSetLanReq->ConfigData.BadPasswd,sizeof(BadPassword_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- break;
- default:
- pSetLanRes->CompletionCode = CC_PARAM_NOT_SUPPORTED;
- return sizeof(uint8_t);
- }
-
- pSetLanRes->CompletionCode = CC_NORMAL;
- FlushIpmiConfig();
- return sizeof(*pSetLanRes);
- }
- /*
- *@fn IPAddrCheck function
- *@brief It will validate the IP Address and net Mask
- *@param Addr - IP Address or net Mask
- *@param params - parameter data to validate
- */
- int IPAddrCheck(uint8_t *Addr,int params)
- {
- int i,maskcount=0,bitmask =0,j,bitcheck=0;
- for(i=0;i< IP_ADDR_LEN;i++)
- {
- if(Addr[i] == BRD_CAST_BIT_MASK)
- {
- maskcount++;
- }
- }
- if(maskcount == IP_ADDR_LEN)
- {
- return 1;
- }
- if(params == LAN_PARAM_SUBNET_MASK)
- {
- if(Addr[0] == BRD_CAST_BIT_MASK)
- {
- for(i=1;i< IP_ADDR_LEN;i++)
- {
- if(Addr[i-1] == 0)
- {
- bitmask = 1;
- }
- if(Addr[i] != 0)
- {
- for(j=0;j<8;j++)
- {
- if((Addr[i]<<j) & SUBNET_MASK_BIT_CHECK)
- {
- if(bitcheck == 1)
- {
- return 1;
- }
- continue;
- }
- bitcheck=1;
- }
- if((bitcheck == 1 && Addr[i-1] != BRD_CAST_BIT_MASK) || (Addr[i] > 0 && bitmask == 1))
- {
- return 1;
- }
- }
- }
- return 0;
- }
- return 1;
- }
- if(Addr[0] == LOOP_BACK_BIT_MASK || Addr[0] == BRD_CAST_BIT_MASK)
- {
- return 1;
- }
- return 0;
- }
- // /*----------------------------------------------
- // * GratuitousARPTask
- // *----------------------------------------------*/
- // void* GratuitousARPTask (uint8_t *Addr)
- // {
- // uint8_t IntervalInSec;
- // uint8_t Status;
- // int nRet;
- // NWCFG_STRUCT NWConfig;
- // NWCFG6_STRUCT NWConfig6;
- // uint8_t EthIndex,netindex= 0xFF;
- // int BMCInst,i;
- // char IfcName[16];
- // BMCArg *GratArpArgs = (BMCArg *)Addr;
- // BMCInst = GratArpArgs->BMCInst;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
- // prctl(PR_SET_NAME,__FUNCTION__,0,0,0);
- // memcpy(&EthIndex,GratArpArgs->Argument,GratArpArgs->Len);
- // memset(IfcName,0,sizeof(IfcName));
- // /*Get the EthIndex*/
- // if(GetIfcName(EthIndex,IfcName, BMCInst) == -1)
- // {
- // TCRIT("Error in Getting Ifcname\n");
- // return 0;
- // }
- // for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
- // {
- // if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
- // {
- // netindex= Ifcnametable[i].Index;
- // break;
- // }
- // }
- // if(netindex == 0xFF)
- // {
- // TCRIT("Error in gettting netindex\n");
- // return 0;
- // }
- // if(Addr != NULL)
- // {
- // free(GratArpArgs->Argument);
- // free(Addr);
- // }
- // TDBG ("Gratuitous ARP thread starts for ethindex : %x\n",EthIndex);
- // while (1)
- // {
- // /*Is Gratiutous Arp Enabled */
- // if (0 == (pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl & GRATIUTOUS_ENABLE_MASK))
- // {
- // TDBG("Gratuitous ARP thread exits : Disable BMC-generated Gratuitous ARPs invoked\n");
- // break;
- // }
- // /*Is Gratiutous Arp Suspended */
- // Status = BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex];
- // if ((0 != (Status & GRATIUTOUS_ENABLE_MASK)) &&
- // (BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning == TRUE))
- // {
- // // Gratuitous ARP Suspended.
- // // sleep requested to access Shared memory for two different threads.
- // usleep (20);
- // continue;
- // }
- // nwReadNWCfg_v4_v6( &NWConfig,&NWConfig6, netindex,g_corefeatures.global_ipv6);
- // if(GetIfcName(EthIndex, IfcName,BMCInst) != 0)
- // {
- // TCRIT("Error in getting Interface Name for the Lan Index :%d\n",EthIndex);
-
- // }
- // if (NWConfig.IFName[0] == 0)
- // sprintf((char *)&NWConfig.IFName, "%s",IfcName);
- // TDBG ( "MAC is %2x:%2x:%2x:%2x:%2x:%2x \n", NWConfig.MAC [0], NWConfig.MAC [1],
- // NWConfig.MAC [2], NWConfig.MAC [3], NWConfig.MAC [4], NWConfig.MAC [5] );
- // TDBG ( "IP is %d.%d.%d.%d\n", NWConfig.IPAddr[0], NWConfig.IPAddr[1],
- // NWConfig.IPAddr[2], NWConfig.IPAddr[3]);
- // TDBG ( "Device Name : %s\n", (char *)&NWConfig.IFName);
- // nRet = SendGratuitousARPPacket((char *)&NWConfig.IFName, NWConfig.IPAddr, NWConfig.MAC);
- // if (0 != nRet)
- // {
- // TCRIT("Gratuitous ARP thread exits : Unable to Send Gratuitous ARP packet\n");
- // break;
- // }
- // TDBG ("Send Gratuitous Packet\n");
- // if (0 == pBMCInfo->LANCfs[EthIndex].GratitousARPInterval)
- // {
- // IntervalInSec = 2; //Default 2 secs
- // } else {
- // // Gratuitous ARP interval in 500 millisecond increments.
- // IntervalInSec = (pBMCInfo->LANCfs[EthIndex].GratitousARPInterval * 500)/1000;
- // }
- // usleep( IntervalInSec * 1000 * 1000 );
- // }
- // return 0;
- // }
- // /*---------------------------------------------------
- // * GetLanConfigParam
- // *---------------------------------------------------*/
- // int
- // GetLanConfigParam ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- // {
- // GetLanConfigReq_T* pGetLanReq = ( GetLanConfigReq_T*) pReq;
- // GetLanConfigRes_T* pGetLanRes = ( GetLanConfigRes_T*) pRes;
- // BMCSharedMem_T* pSharedMem = BMC_GET_SHARED_MEM (BMCInst);
- // uint8_t IsOemDefined = FALSE;
- // NWCFG_STRUCT NWConfig;
- // NWCFG6_STRUCT NWConfig6;
- // // V6DNS_CONFIG v6dnsconfig;
- // uint8_t EthIndex,netindex= 0xFF,i;
- // BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
- // int ncsiPortConfigNum = 0;
- // ETHCFG_STRUCT PHYCfg;
- // ChannelInfo_T* pChannelInfo = NULL;
- // char IfcName[16]; /* Eth interface name */
- // uint8_t ComStrLen=MAX_COMM_STRING_SIZE;
- // int retValue = 0,NIC_Count = 0;
- // pGetLanRes->CCParamRev.CompletionCode = CC_NORMAL;
- // pGetLanRes->CCParamRev.ParamRevision = PARAMETER_REVISION_FORMAT;
- // // printf("---> channel: %d, parameter: %#x, setslect: %#x, blockselect: %#x\n", pGetLanReq->ChannelNum, pGetLanReq->ParameterSelect, pGetLanReq->SetSelect, pGetLanReq->BlockSelect);
- // if(pGetLanReq->ChannelNum & RESERVED_VALUE_70)
- // {
- // /* Alarm !!! Somebody is trying to set Reseved Bits */
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // if((pGetLanReq->ParameterSelect >= MIN_LAN_OEM_CONF_PARAM) &&
- // (pGetLanReq->ParameterSelect <= MAX_LAN_OEM_CONF_PARAM) )
- // {
- // /* Converts OEM parameter value to equivalent AMI parameter value */
- // if (0 != GetLanAMIParamValue (&pGetLanReq->ParameterSelect, &IsOemDefined) )
- // {
- // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
- // return sizeof(uint8_t);
- // }
- // /* Hook for OEM to handle this parameter */
- // if ( (IsOemDefined) && (g_PDKHandle[PDK_GETLANOEMPARAM] != NULL) )
- // {
- // return ((int(*)(uint8_t *, uint8_t, uint8_t *,int))(g_PDKHandle[PDK_GETLANOEMPARAM]))(pReq, ReqLen, pRes, BMCInst);
- // }
-
- // }
- // if (g_PDKHandle[PDK_BEFOREGETLANPARM] != NULL)
- // {
- // retValue = ((int(*)(uint8_t *, uint8_t, uint8_t *,int))(g_PDKHandle[PDK_BEFOREGETLANPARM]))(pReq, ReqLen, pRes, BMCInst);
- // if(retValue != 0)
- // {
- // return retValue;
- // }
- // }
- // //! Validate the SetSelector value.
- // if ( (0x00 != pGetLanReq->SetSelect) &&
- // (pGetLanReq->ParameterSelect != LAN_PARAM_SELECT_DEST_TYPE) &&
- // (pGetLanReq->ParameterSelect != LAN_PARAM_SELECT_DEST_ADDR) &&
- // (pGetLanReq->ParameterSelect != LAN_PARAM_VLAN_TAGS) &&
- // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR) &&
- // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR) &&
- // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_EUI64) &&
- // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH))
- // {
- // printf("GetLanConfigParam log1\n");
- // if( g_corefeatures.ncsi_cmd_support == ENABLED )
- // {
- // if ((pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_NCSI_SETTINGS) &&
- // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_NCSI_MODE_CHANGE) &&
- // (pGetLanReq->ParameterSelect != LAN_PARAMS_AMI_OEM_NCSI_EXTENSION))
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // }
- // else
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // }
- // //! Validate the BlockSelector value.
- // if (0x00 != pGetLanReq->BlockSelect)
- // {
- // printf("GetLanConfigParam log2\n");
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // EthIndex= GetEthIndex(pGetLanReq->ChannelNum & 0x0F, BMCInst);
- // if(0xff == EthIndex)
- // {
- // printf("GetLanConfigParam log3\n");
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (uint8_t);
- // }
- // /*Get the EthIndex*/
- // if(GetIfcName(EthIndex,IfcName, BMCInst) != 0)
- // {
- // TCRIT("Error in Getting IfcName\n");
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (uint8_t);
- // }
- // for(i=0;i<sizeof(Ifcnametable)/sizeof(IfcName_T);i++)
- // {
- // if(strcmp(Ifcnametable[i].Ifcname,IfcName) == 0)
- // {
- // netindex= Ifcnametable[i].Index;
- // break;
- // }
- // }
- // if(netindex == 0xFF)
- // {
- // TCRIT("Error in Getting netindex %d %s\n",netindex,IfcName);
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof (uint8_t);
- // }
-
- // if ((pGetLanReq->ChannelNum & GET_PARAMETER_REVISION_MASK) != 0)
- // {
- // if((MAX_LAN_CONF_PARAM >= pGetLanReq->ParameterSelect) ||
- // ((MIN_LAN_OEM_CONF_PARAM <= pGetLanReq->ParameterSelect) && (MAX_LAN_OEM_CONF_PARAM >= pGetLanReq->ParameterSelect)) )
- // {
- // return sizeof(GetLanCCRev_T);
- // }
- // else
- // {
- // *pRes = CC_PARAM_NOT_SUPPORTED;
- // return sizeof (*pRes);
- // }
- // }
- // else
- // {
- // printf("GetLanConfigParam log4\n");
- // switch(pGetLanReq->ParameterSelect)
- // {
- // case LAN_PARAM_SET_IN_PROGRESS:
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // pGetLanRes->ConfigData.SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Lan_SetInProgress;
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // break;
- // case LAN_PARAM_AUTH_TYPE_SUPPORT:
- // pGetLanRes->ConfigData.AuthTypeSupport = pBMCInfo->LANCfs[EthIndex].AuthTypeSupport;
- // break;
- // case LAN_PARAM_AUTH_TYPE_ENABLES:
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (&pGetLanRes->ConfigData.AuthTypeEnables,
- // &(pBMCInfo->LANCfs[EthIndex].AuthTypeEnables), sizeof(AuthTypeEnables_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // break;
- // case LAN_PARAM_IP_ADDRESS:
- // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPAddrSrc == STATIC_IP_SOURCE))
- // {
- // if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
- // {
- // _fmemcpy (NWConfig.IPAddr,pBMCInfo->LANCfs[EthIndex].IPAddr, IP_ADDR_LEN);
- // }
- // else
- // {
- // memset(&NWConfig, 0, sizeof(NWConfig));
- // }
- // }
- // else
- // {
- // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
- // }
- // _fmemcpy (pGetLanRes->ConfigData.IPAddr, NWConfig.IPAddr, IP_ADDR_LEN);
- // break;
- // case LAN_PARAM_IP_ADDRESS_SOURCE:
- // if(g_corefeatures.delayed_lan_restart_support)
- // {
- // if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
- // {
- // NWConfig.CfgMethod = pBMCInfo->LANCfs[EthIndex].IPAddrSrc;
- // }
- // else
- // {
- // memset(&NWConfig, 0, sizeof(NWConfig));
- // }
- // }
- // else
- // {
- // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
- // }
- // pGetLanRes->ConfigData.IPAddrSrc = NWConfig.CfgMethod;
- // break;
- // case LAN_PARAM_MAC_ADDRESS:
- // nwGetNWInformations(&NWConfig,IfcName);
- // _fmemcpy (pGetLanRes->ConfigData.MACAddr, NWConfig.MAC, MAC_ADDR_LEN);
- // break;
- // case LAN_PARAM_SUBNET_MASK:
- // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPAddrSrc == STATIC_IP_SOURCE))
- // {
- // if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
- // {
- // _fmemcpy (NWConfig.Mask,pBMCInfo->LANCfs[EthIndex].SubNetMask, IP_ADDR_LEN);
- // }
- // else
- // {
- // memset(&NWConfig, 0, sizeof(NWConfig));
- // }
- // }
- // else
- // {
- // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
- // }
- // _fmemcpy (pGetLanRes->ConfigData.SubNetMask, NWConfig.Mask, IP_ADDR_LEN);
- // break;
- // case LAN_PARAM_IPv4_HEADER:
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (&pGetLanRes->ConfigData.Ipv4HdrParam,
- // &(pBMCInfo->LANCfs[EthIndex].Ipv4HdrParam), sizeof(IPv4HdrParams_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // break;
- // case LAN_PARAM_PRI_RMCP_PORT:
- // pGetLanRes->ConfigData.PrimaryRMCPPort = htoipmi_u16(pBMCInfo->LANCfs[EthIndex].PrimaryRMCPPort);
- // break;
- // case LAN_PARAM_SEC_RMCP_PORT:
- // /* Returning Invalid error message */
- // *pRes = CC_PARAM_NOT_SUPPORTED;
- // return sizeof (uint8_t);
- // /*pGetLanRes->ConfigData.SecondaryPort = htoipmi_u16(pPMConfig->LANConfig[EthIndex].SecondaryPort);*/
- // break;
- // case LAN_PARAM_BMC_GENERATED_ARP_CONTROL:
- // pGetLanRes->ConfigData.BMCGeneratedARPControl = pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl;
- // break;
- // case LAN_PARAM_GRATITIOUS_ARP_INTERVAL:
- // pGetLanRes->ConfigData.GratitousARPInterval =
- // pBMCInfo->LANCfs[EthIndex].GratitousARPInterval;
- // break;
- // case LAN_PARAM_DEFAULT_GATEWAY_IP:
- // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPAddrSrc == STATIC_IP_SOURCE))
- // {
- // if(pBMCInfo->LANCfs[EthIndex].IPv4_Enable)
- // {
- // _fmemcpy (NWConfig.Gateway, pBMCInfo->LANCfs[EthIndex].DefaultGatewayIPAddr, IP_ADDR_LEN);
- // }
- // else
- // {
- // memset(&NWConfig, 0, sizeof(NWConfig));
- // }
- // }
- // else
- // {
- // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
- // }
- // _fmemcpy (pGetLanRes->ConfigData.DefaultGatewayIPAddr, NWConfig.Gateway, IP_ADDR_LEN);
- // break;
- // case LAN_PARAM_DEFAULT_GATEWAY_MAC:
- // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
- // nwGetSrcMacAddr(&NWConfig.Gateway[0],netindex, &pGetLanRes->ConfigData.DefaultGatewayMACAddr[0]);
- // break;
- // case LAN_PARAM_BACKUP_GATEWAY_IP:
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // nwGetBkupGWyAddr(pGetLanRes->ConfigData.BackupGatewayIPAddr,netindex);
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // break;
- // case LAN_PARAM_BACKUP_GATEWAY_MAC:
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (pGetLanRes->ConfigData.BackupGatewayMACAddr,
- // pBMCInfo->LANCfs[EthIndex].BackupGatewayMACAddr, MAC_ADDR_LEN);
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // break;
- // case LAN_PARAM_COMMUNITY_STRING:
- // if (g_PDKHandle[PDK_GETSNMPCOMMUNITYNAME] != NULL )
- // {
- // if(((int(*)(uint8_t *, uint8_t *,int))(g_PDKHandle[PDK_GETSNMPCOMMUNITYNAME]))(pGetLanRes->ConfigData.CommunityStr,&ComStrLen, BMCInst)==0)
- // break;
- // }
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (pGetLanRes->ConfigData.CommunityStr,
- // pBMCInfo->LANCfs[EthIndex].CommunityStr, MAX_COMM_STRING_SIZE);
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // break;
- // case LAN_PARAM_DEST_NUM:
- // pGetLanRes->ConfigData.NumDest = pBMCInfo->LANCfs[EthIndex].NumDest;
- // break;
- // case LAN_PARAM_SELECT_DEST_TYPE:
- // //if (pGetLanReq->SetSelect > NUM_LAN_DESTINATION)
- // if ( pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
- // {
- // *pRes = CC_PARAM_OUT_OF_RANGE ;
- // return sizeof (*pRes);
- // }
- // if (0 == pGetLanReq->SetSelect)
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (&pGetLanRes->ConfigData.DestType,
- // &pSharedMem->VolLANDestType[EthIndex], sizeof(LANDestType_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // }
- // else
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (&pGetLanRes->ConfigData.DestType,
- // &(pBMCInfo->LANCfs[EthIndex].DestType[pGetLanReq->SetSelect - 1]),
- // sizeof(LANDestType_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // }
- // break;
- // case LAN_PARAM_SELECT_DEST_ADDR:
- // //if (pGetLanReq->SetSelect > NUM_LAN_DESTINATION)
- // if ( pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
- // {
- // *pRes = CC_PARAM_OUT_OF_RANGE ;
- // return sizeof (*pRes);
- // }
- // if (0 == pGetLanReq->SetSelect)
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (&pGetLanRes->ConfigData.DestAddr,
- // &pSharedMem->VolLANDest[EthIndex], sizeof(LANDestAddr_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // }
- // else
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (&pGetLanRes->ConfigData.DestAddr,
- // &(pBMCInfo->LANCfs[EthIndex].DestAddr[pGetLanReq->SetSelect - 1]),
- // sizeof(LANDestAddr_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // }
- // break;
- // case LAN_PARAM_VLAN_ID:
- // if( pBMCInfo->IpmiConfig.VLANIfcSupport == 1)
- // {
- // pGetLanRes->ConfigData.VLANID = pBMCInfo->LANCfs[EthIndex].VLANID;
- // }
- // break;
- // case LAN_PARAM_VLAN_PRIORITY:
- // pGetLanRes->ConfigData.VLANPriority = pBMCInfo->LANCfs[EthIndex].VLANPriority;
- // break;
- // case LAN_PARAM_CIPHER_SUITE_ENTRY_SUP:
- // pGetLanRes->ConfigData.CipherSuiteSup = N0_OF_CIPHER_SUITE_SUPPORTED;
- // break;
- // case LAN_PARAM_CIPHER_SUITE_ENTRIES:
- // {
- // int i;
- // _fmemset (pGetLanRes->ConfigData.CipherSuiteEntries, 0,
- // sizeof (pGetLanRes->ConfigData.CipherSuiteEntries));
- // for (i = 0; i < (N0_OF_CIPHER_SUITE_SUPPORTED); i++)
- // {
- // pGetLanRes->ConfigData.CipherSuiteEntries[i+1] = g_CipherRec[1 + i * 5];
- // }
- // }
- // break;
- // case LAN_PARAM_CIPHER_SUITE_PRIV_LEVELS:
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (pGetLanRes->ConfigData.CipherSuitePrivLevels,
- // pBMCInfo->LANCfs[EthIndex].CipherSuitePrivLevels,
- // MAX_NUM_CIPHER_SUITE_PRIV_LEVELS);
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // break;
- // case LAN_PARAM_VLAN_TAGS:
- // *(( uint8_t*)&pGetLanRes->ConfigData) = pGetLanReq->SetSelect;
- // if (pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest)
- // {
- // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_OUT_OF_RANGE;
- // return sizeof (GetLanCCRev_T);
- // }
- // if (0 == pGetLanReq->SetSelect)
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy ((( uint8_t*) &pGetLanRes->ConfigData) + 1,&pSharedMem->VLANDestTag, sizeof(VLANDestTags_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // }
- // else
- // {
- // if (pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest)
- // {
- // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_OUT_OF_RANGE;
- // return sizeof(GetLanCCRev_T);
- // }
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy ((( uint8_t*)&pGetLanRes->ConfigData) + 1,
- // &pBMCInfo->LANCfs[EthIndex].VLANDestTags[pGetLanReq->SetSelect - 1],
- // sizeof(VLANDestTags_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // }
- // break;
- // case LAN_PARAMS_BAD_PASSWORD_THRESHOLD:
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy(&pGetLanRes->ConfigData.BadPasswd,
- // &pBMCInfo->LANCfs[EthIndex].BadPasswd,sizeof(BadPassword_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // break;
- // case LAN_PARAMS_AMI_OEM_SNMPV6_DEST_ADDR:
- // if ( pGetLanReq->SetSelect > pBMCInfo->LANCfs[EthIndex].NumDest )
- // {
- // *pRes = CC_PARAM_OUT_OF_RANGE ;
- // return sizeof (*pRes);
- // }
- // if (0 == pGetLanReq->SetSelect)
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (&pGetLanRes->ConfigData.Destv6Addr,
- // &pSharedMem->VolLANv6Dest[EthIndex], sizeof(LANDestv6Addr_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // }
- // else
- // {
- // LOCK_BMC_SHARED_MEM(BMCInst);
- // _fmemcpy (&pGetLanRes->ConfigData.Destv6Addr,
- // &(pBMCInfo->LANCfs[EthIndex].Destv6Addr[pGetLanReq->SetSelect - 1]),
- // sizeof(LANDestv6Addr_T));
- // UNLOCK_BMC_SHARED_MEM(BMCInst);
- // }
- // TDBG("\n GetLanconfig: Getting SNMPv6 configuration done..\n");
- // return sizeof(GetLanConfigRes_T);
- // break;
- // case LAN_PARAMS_AMI_OEM_ENABLE_SET_MAC:
- // pGetLanRes->ConfigData.ChangeMACEnabled = enableSetMACAddr;
- // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
- // case LAN_PARAMS_AMI_OEM_IPV6_ENABLE:
- // if(g_corefeatures.delayed_lan_restart_support)
- // {
- // NWConfig6.enable = pBMCInfo->LANCfs[EthIndex].IPv6_Enable;
- // }
- // else
- // {
- // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
- // }
- // pGetLanRes->ConfigData.IPv6_Enable = NWConfig6.enable;
- // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
-
- // break;
- // case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_SOURCE:
- // if(g_corefeatures.delayed_lan_restart_support)
- // {
- // if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
- // {
- // NWConfig6.CfgMethod = pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc;
- // }
- // else
- // {
- // memset(&NWConfig6, 0, sizeof(NWConfig6));
- // }
- // }
- // else
- // {
- // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
- // }
- // pGetLanRes->ConfigData.IPv6_IPAddrSrc = NWConfig6.CfgMethod;
- // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
-
- // break;
- // case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR:
- // case LAN_PARAMS_AMI_OEM_IPV6_IP_ADDR_EUI64:
- // if(pGetLanReq->SetSelect & 0xF0)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(uint8_t);
- // }
-
- // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == STATIC_IP_SOURCE))
- // {
- // if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
- // {
- // _fmemcpy (NWConfig6.GlobalIPAddr,pBMCInfo->LANCfs[EthIndex].IPv6_IPAddr, IP6_ADDR_LEN*MAX_IPV6ADDRS);
- // }
- // else
- // {
- // memset(&NWConfig6, 0, sizeof(NWConfig6));
- // }
- // }
- // else
- // {
- // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
- // }
- // _fmemcpy (pGetLanRes->ConfigData.IPv6_LinkAddr, NWConfig6.GlobalIPAddr[(pGetLanReq->SetSelect & 0x0F)], IP6_ADDR_LEN);
- // return sizeof(GetLanCCRev_T) + IP6_ADDR_LEN;
-
- // break;
- // case LAN_PARAMS_AMI_OEM_IPV6_LINK_ADDR:
- // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
- // _fmemcpy (pGetLanRes->ConfigData.IPv6_LinkAddr, NWConfig6.LinkIPAddr, IP6_ADDR_LEN);
- // return sizeof(GetLanCCRev_T) + IP6_ADDR_LEN;
- // case LAN_PARAMS_AMI_OEM_IPV6_PREFIX_LENGTH:
- // if(pGetLanReq->SetSelect & 0xF0)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(uint8_t);
- // }
- // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == STATIC_IP_SOURCE))
- // {
- // if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
- // {
- // NWConfig6.GlobalPrefix[(pGetLanReq->SetSelect & 0x0F)] = pBMCInfo->LANCfs[EthIndex].IPv6_PrefixLen[(pGetLanReq->SetSelect & 0x0F)];
- // }
- // else
- // {
- // memset(&NWConfig6, 0, sizeof(NWConfig6));
- // }
- // }
- // else
- // {
- // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
- // }
- // pGetLanRes->ConfigData.IPv6_LinkAddrPrefix = NWConfig6.GlobalPrefix[(pGetLanReq->SetSelect & 0x0F)];
- // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
-
- // break;
- // case LAN_PARAMS_AMI_OEM_IPV6_LINK_ADDR_PREFIX:
- // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
- // pGetLanRes->ConfigData.IPv6_LinkAddrPrefix = NWConfig6.LinkPrefix;
- // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
-
- // break;
- // case LAN_PARAMS_AMI_OEM_IPV6_GATEWAY_IP:
- // if((g_corefeatures.delayed_lan_restart_support) && (pBMCInfo->LANCfs[EthIndex].IPv6_IPAddrSrc == STATIC_IP_SOURCE))
- // {
- // if((pBMCInfo->LANCfs[EthIndex].IPv6_Enable))
- // {
- // _fmemcpy (NWConfig6.Gateway,pBMCInfo->LANCfs[EthIndex].IPv6_GatewayIPAddr, IP6_ADDR_LEN);
- // }
- // else
- // {
- // memset(&NWConfig6, 0, sizeof(NWConfig6));
- // }
- // }
- // else
- // {
- // nwReadNWCfg_v4_v6( &NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
- // }
- // _fmemcpy (pGetLanRes->ConfigData.IPv6_GatewayIPAddr, NWConfig6.Gateway, IP6_ADDR_LEN);
- // return sizeof(GetLanCCRev_T) + IP6_ADDR_LEN;
-
- // break;
- // case LAN_PARAMS_AMI_OEM_PHY_SETTINGS:
- // memset(IfcName, 0, sizeof(IfcName));
- // if(GetIfcNameByIndex(EthIndex, IfcName) != 0)
- // {
- // TCRIT("Error in Getting Interface Name for the lan Index:%d\n",EthIndex);
- // }
- // if(nwGetEthInformation(&PHYCfg, IfcName) !=0)
- // {
- // pGetLanRes->CCParamRev.CompletionCode = CC_UNSPECIFIED_ERR;
- // return sizeof(GetLanCCRev_T);
- // }
- // pGetLanRes->ConfigData.PHYConfig.Interface = EthIndex;
- // pGetLanRes->ConfigData.PHYConfig.AutoNegotiationEnable = PHYCfg.autoneg;
- // pGetLanRes->ConfigData.PHYConfig.Speed = PHYCfg.speed;
- // pGetLanRes->ConfigData.PHYConfig.Duplex = PHYCfg.duplex;
- // pGetLanRes->ConfigData.PHYConfig.CapabilitiesSupported = PHYCfg.supported;
- // return sizeof(GetLanCCRev_T) + sizeof(PHYConfig_T);
- // case LAN_PARAMS_AMI_OEM_MTU_SETTINGS:
- // memset(IfcName,0,sizeof(IfcName));
- // if(GetIfcNameByIndex(EthIndex, IfcName) != 0)
- // {
- // TCRIT("Error in Getting Interface Name for the lan Index:%d\n",EthIndex);
- // pGetLanRes->CCParamRev.CompletionCode = CC_UNSPECIFIED_ERR;
- // return sizeof(GetLanCCRev_T);
- // }
- // if(nwGetEthInformation(&PHYCfg, IfcName) !=0)
- // {
- // pGetLanRes->CCParamRev.CompletionCode = CC_UNSPECIFIED_ERR;
- // return sizeof(GetLanCCRev_T);
- // }
-
- // pGetLanRes->ConfigData.MTU_size = PHYCfg.maxtxpkt;
- // return sizeof(GetLanCCRev_T) + sizeof(uint16_t);
-
- // case LAN_PARAMS_SSI_OEM_2ND_PRI_ETH_MAC_ADDR:
- // if(g_corefeatures.ssi_support == ENABLED)
- // {
- // netindex = 0x1; /* Specify the 2nd interface */
- // nwReadNWCfg_v4_v6(&NWConfig, &NWConfig6, netindex,g_corefeatures.global_ipv6);
- // _fmemcpy(pGetLanRes->ConfigData.SSI2ndPriEthMACAddr, NWConfig.MAC, MAC_ADDR_LEN);
- // return sizeof(GetLanCCRev_T) + sizeof(pGetLanRes->ConfigData.SSI2ndPriEthMACAddr);
- // }
- // else
- // {
- // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
- // return sizeof(uint8_t);
- // }
- // break;
- // case LAN_PARAMS_SSI_OEM_LINK_CTRL:
- // if(g_corefeatures.ssi_support == ENABLED)
- // {
- // pGetLanRes->ConfigData.SSILinkControl = 0;
- // pChannelInfo = getChannelInfo(pBMCInfo->RMCPLAN1Ch, BMCInst);
- // if(NULL == pChannelInfo)
- // {
- // *pRes = CC_UNSPECIFIED_ERR;
- // return sizeof (*pRes);
- // }
- // if (pChannelInfo->AccessMode == 0x02) /* If 1st channal is available */
- // pGetLanRes->ConfigData.SSILinkControl |= BIT0;
- // NIC_Count = g_coremacros.global_nic_count;
- // if (NIC_Count == 2)
- // {
- // pChannelInfo = getChannelInfo(pBMCInfo->RMCPLAN2Ch, BMCInst);
- // if(NULL == pChannelInfo)
- // {
- // *pRes = CC_UNSPECIFIED_ERR;
- // return sizeof (*pRes);
- // }
- // if (pChannelInfo->AccessMode == 0x02) /* If 2nd channal is available */
- // pGetLanRes->ConfigData.SSILinkControl |= BIT1;
- // }
- // return sizeof(GetLanCCRev_T) + sizeof(pGetLanRes->ConfigData.SSILinkControl);
- // }
- // else
- // {
- // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
- // return sizeof(uint8_t);
- // }
- // break;
- // case LAN_PARAMS_SSI_OEM_CMM_IP_ADDR:
- // if(g_corefeatures.ssi_support == ENABLED)
- // {
- // _fmemcpy (pGetLanRes->ConfigData.CMMIPAddr, pBMCInfo->SSIConfig.CMMIPAddr, IP_ADDR_LEN);
- // return sizeof(GetLanCCRev_T) + sizeof(pGetLanRes->ConfigData.CMMIPAddr);
- // }
- // else
- // {
- // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
- // return sizeof(uint8_t);
- // }
- // break;
- // default:
- // if(g_corefeatures.ncsi_cmd_support == ENABLED)
- // {
- // switch(pGetLanReq->ParameterSelect)
- // {
- // case LAN_PARAMS_AMI_OEM_NCSI_CONFIG_NUM:
- // NCSIGetTotalPorts(&ncsiPortConfigNum);
-
- // if (ncsiPortConfigNum >= 0xFF)
- // {
- // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(GetLanCCRev_T);
- // }
- // else
- // {
- // pGetLanRes->ConfigData.NumNCSIPortConfigs = ncsiPortConfigNum;
- // return sizeof(GetLanCCRev_T) + sizeof(uint8_t);
- // }
- // break;
-
- // case LAN_PARAMS_AMI_OEM_NCSI_SETTINGS:
- // {
- // NIC_Count=g_coremacros.global_nic_count;
- // if (pGetLanReq->SetSelect >= NIC_Count)
- // {
- // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(GetLanCCRev_T);
- // }
- // NCSIConfig_T configData;
- // char interfaceName[8];
- // memset(&configData, 0, sizeof(NCSIConfig_T));
- // memset(interfaceName, 0, sizeof(interfaceName));
- // snprintf(interfaceName, sizeof(interfaceName), "%s%d", "eth", pGetLanReq->SetSelect);
-
- // if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
- // {
- // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(GetLanCCRev_T);
- // }
- // if (configData.PackageId >= 0xFF || configData.ChannelId >= 0xFF)
- // {
- // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(GetLanCCRev_T);
- // }
- // pGetLanRes->ConfigData.NCSIPortConfig.Interface = pGetLanReq->SetSelect;
- // pGetLanRes->ConfigData.NCSIPortConfig.PackageId = configData.PackageId;
- // pGetLanRes->ConfigData.NCSIPortConfig.ChannelId = configData.ChannelId;
- // return sizeof(GetLanCCRev_T) + sizeof(NCSIPortConfig_T);
- // }
- // break;
- // case LAN_PARAMS_AMI_OEM_NCSI_MODE_CHANGE:
- // {
- // NIC_Count=g_coremacros.global_nic_count;
- // if (pGetLanReq->SetSelect >= NIC_Count)
- // {
- // printf("---> log5, SetSelect = %d, NIC_Count = %d\n",pGetLanReq->SetSelect, NIC_Count);
- // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(GetLanCCRev_T);
- // }
-
- // NCSIConfig_T configData;
- // char interfaceName[8];
- // memset(&configData, 0, sizeof(NCSIConfig_T));
- // memset(interfaceName, 0, sizeof(interfaceName));
-
- // snprintf(interfaceName, sizeof(interfaceName), "%s%d", "eth", pGetLanReq->SetSelect);
-
- // if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
- // {
- // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(GetLanCCRev_T);
- // }
-
- // if (configData.AutoSelect>= 0xFF)
- // {
- // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(GetLanCCRev_T);
- // }
- // pGetLanRes->ConfigData.NCSIModeConfig.Interface = pGetLanReq->SetSelect;
- // pGetLanRes->ConfigData.NCSIModeConfig.NCSIMode = configData.AutoSelect;
- // return sizeof(GetLanCCRev_T) + sizeof(NCSIModeConfig_T);
- // }
- // break;
- // case LAN_PARAMS_AMI_OEM_NCSI_EXTENSION:
- // {
- // char ncsi_default_ifc[IFNAMSIZ + 1] = "eth1";
-
- // if ((pGetLanReq->SetSelect == 0x20) &&
- // (g_corefeatures.ncsi_keep_phy_linkup_support == ENABLED))
- // {
- // NIC_Count=g_coremacros.global_nic_count;
- // NCSIConfig_T configData;
- // char interfaceName[8];
- // memset(&configData, 0, sizeof(NCSIConfig_T));
- // memset(interfaceName, 0, sizeof(interfaceName));
- // GetMacrodefine_string("CONFIG_SPX_FEATURE_NCSI_DEFAULT_INTERFACE", ncsi_default_ifc);
- // snprintf(interfaceName, sizeof(interfaceName), "%s", ncsi_default_ifc);
- // if (NCSIGetPortConfigByName(interfaceName, &configData) != 0)
- // {
- // pGetLanRes->CCParamRev.CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof(GetLanCCRev_T);
- // }
- // char Interface[2];
- // snprintf(Interface, sizeof(Interface), "%c", interfaceName[3]);
- // pGetLanRes->ConfigData.NCSIPHYConfigGet.Interface = atoi(Interface);
- // pGetLanRes->ConfigData.NCSIPHYConfigGet.VetoBit = configData.VetoBit;
- // return sizeof(GetLanCCRev_T) + sizeof(NCSIPHYConfigGet_T);
- // }
- // else
- // {
- // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
- // return sizeof(GetLanCCRev_T);
- // }
- // }
- // break;
-
- // default:
- // TDBG("In Valid Option\n");
-
- // }
- // }
- // pGetLanRes->CCParamRev.CompletionCode = CC_PARAM_NOT_SUPPORTED;
- // return sizeof(uint8_t);
- // }
- // }
-
- // return sizeof(GetLanCCRev_T) + LanconfigParameterLength[pGetLanReq->ParameterSelect];
- // }
- // /*---------------------------------------------------
- // * SuspendBMCArps
- // *---------------------------------------------------*/
- // int
- // SuspendBMCArps ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- // {
- // SuspendBMCArpsReq_T* pArpReq = ( SuspendBMCArpsReq_T*) pReq;
- // SuspendBMCArpsRes_T* pArpRes = ( SuspendBMCArpsRes_T*) pRes;
- // uint8_t EthIndex;
- // /* Verify Channel ID */
- // pArpRes->CompletionCode = CC_INV_DATA_FIELD;
- // if(pArpReq->ChannelNo & RESERVED_BITS_SUSPENDBMCARPS) return sizeof(*pRes);
- // if (!IsLANChannel(pArpReq->ChannelNo & CHANNEL_ID_MASK, BMCInst) )
- // {
- // return sizeof (*pRes);
- // }
- // EthIndex= GetEthIndex(pArpReq->ChannelNo & 0x0F,BMCInst);
- // if(0xff == EthIndex)
- // {
- // return sizeof (*pRes);
- // }
- // /* Reserved Bits Validation */
- // if (0 != (SUSPEND_ARP_RSVD_BIT_MASK & pArpReq->ArpSuspend))
- // {
- // return sizeof (*pRes);
- // }
- // if (BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning == TRUE)
- // BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex] = pArpReq->ArpSuspend;
- // /* Update Response */
- // pArpRes->CompletionCode = CC_NORMAL;
- // pArpRes->ArpSuspendStatus = UpdateArpStatus(EthIndex, BMC_GET_SHARED_MEM(BMCInst)->IsWDTRunning, BMCInst);
- // return sizeof (SuspendBMCArpsRes_T);
- // }
- // /*---------------------------------------------------
- // * GetIPUDPRMCPStats
- // *---------------------------------------------------*/
- // int
- // GetIPUDPRMCPStats ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes, int BMCInst)
- // {
- // GetIPUDPRMCPStatsReq_T* pGetIPUDPRMCPStatsReq = ( GetIPUDPRMCPStatsReq_T*) pReq;
- // GetIPUDPRMCPStatsRes_T* pGetIPUDPRMCPStatsRes = ( GetIPUDPRMCPStatsRes_T*) pRes;
- // BMCSharedMem_T* pSharedMem = BMC_GET_SHARED_MEM (BMCInst);
- // FILE *fptr;
- // char FDRead[512], FSRead[512];
- // char *result = NULL;
- // char **StrArray;
- // int count = 0;
- // int cStrings =0;
- // if(pGetIPUDPRMCPStatsReq->ChannelNo & RESERVED_BITS_GETIPUDPRMCPSTATS_CH)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- // if(pGetIPUDPRMCPStatsReq->ClearStatus & RESERVED_BITS_GETIPUDPRMCPSTATS_CLRSTATE)
- // {
- // *pRes = CC_INV_DATA_FIELD;
- // return sizeof(*pRes);
- // }
- // //Channel number [3:0] is valid.
- // if ( !IsLANChannel(pGetIPUDPRMCPStatsReq->ChannelNo & CHANNEL_ID_MASK, BMCInst) )
- // {
- // pGetIPUDPRMCPStatsRes->CompletionCode = CC_INV_DATA_FIELD;
- // return sizeof (*pRes);
- // }
- // //Clear the statistics if 1 is given in request.
- // if ( pGetIPUDPRMCPStatsReq->ClearStatus & 0x01 )
- // {
- // /* <TBD BalaT>
- // * Have to clear the already stored statistics when clear req is 1.
- // */
- // pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
- // return sizeof (uint8_t);
- // }
- // //All Statistics values are initialised to 0.
- // memset (pGetIPUDPRMCPStatsRes, 0, sizeof(GetIPUDPRMCPStatsRes_T) );
- // //All the datas are taken from /proc/net/snmp file
- // fptr = fopen ("/proc/net/snmp","r+");
- // if (fptr == NULL)
- // {
- // pGetIPUDPRMCPStatsRes->CompletionCode = CC_COULD_NOT_PROVIDE_RESP;
- // return sizeof (uint8_t);
- // }
- // while( NULL != fgets(FDRead,512,fptr) )
- // {
- // if ( NULL != strstr (FDRead, "Ip: ") )
- // {
- // count++;
- // if (count == 2)
- // {
- // //To find the no. of valid strings in a line.
- // strcpy (FSRead, FDRead);
- // result = strtok( FSRead, " " );
- // while( result != NULL )
- // {
- // cStrings++;
- // result = strtok( NULL, " " );
- // }
- // //Condition to check so that explode doesnt try to read the strings from unknown location.
- // if ( cStrings == 20)
- // {
- // StrArray = explode (' ', FDRead);
- // }
- // else
- // {
- // pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
- // return sizeof (uint8_t);
- // }
- // //All Statistics stops acumulating at FFFFh unless otherwise noted.
- // //IP packets received.
- // if ( atol((char *)StrArray[3]) > 0xffff)
- // pGetIPUDPRMCPStatsRes->IPPacketsRecv = ( ( atol((char *)StrArray[3]) ) % 65535);
- // else
- // pGetIPUDPRMCPStatsRes->IPPacketsRecv = atoi((char *)StrArray[3]);
- // //IP Header Error.
- // pGetIPUDPRMCPStatsRes->IPHeaderErr = atoi((char *)StrArray[4]);
- // //IP Address Error.
- // if ( atol((char *)StrArray[5]) > 0xffff)
- // pGetIPUDPRMCPStatsRes->IPAddrErr = ( ( atol((char *)StrArray[5]) ) % 65535);
- // else
- // pGetIPUDPRMCPStatsRes->IPAddrErr = atoi((char *)StrArray[5]);
- // //Fragmented IP Packets received.
- // if ( atol((char *)StrArray[17]) > 0xffff)
- // pGetIPUDPRMCPStatsRes->FragIPPacketsRecv = ( ( atol((char *)StrArray[17]) ) % 65535);
- // else
- // pGetIPUDPRMCPStatsRes->FragIPPacketsRecv = atoi((char *)StrArray[17]);
- // //IP packets Transmitted.
- // if ( atol((char *)StrArray[10]) > 0xffff)
- // pGetIPUDPRMCPStatsRes->IPPacketsTrans = ( ( atol((char *)StrArray[10]) ) % 65535);
- // else
- // pGetIPUDPRMCPStatsRes->IPPacketsTrans = atoi((char *)StrArray[10]);
- // count = 0;
- // }
- // }
-
- // if ( NULL != strstr (FDRead, "Udp: ") )
- // {
- // count++;
- // if (count == 2)
- // {
- // //To find the no. of valid strings in a line.
- // cStrings = 0;
- // strcpy (FSRead, FDRead);
- // result = strtok( FSRead, " " );
- // while( result != NULL )
- // {
- // cStrings++;
- // result = strtok( NULL, " " );
- // }
- // //Condition to check so that explode doesnt try to read the strings beyond the valid location.
- // if ( cStrings == 5)
- // {
- // StrArray = explode (' ', FDRead);
- // }
- // else
- // {
- // pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
- // return sizeof (uint8_t);
- // }
- // //UDP packets received.
- // if ( atol((char *)StrArray[1]) > 0xffff)
- // pGetIPUDPRMCPStatsRes->UDPPacketsRecv = ( ( atol((char *)StrArray[1]) ) % 65535);
- // else
- // pGetIPUDPRMCPStatsRes->UDPPacketsRecv = atoi((char *)StrArray[1]);
- // count = 0;
- // }
- // }
- // }
- // fclose(fptr);
- // //Valid RMCP packets received.
- // pGetIPUDPRMCPStatsRes->ValidRMCPPackets = pSharedMem->gIPUDPRMCPStats;
- // //<TBD BalaT>To store the statistics across the system reset and power cycles
- // pGetIPUDPRMCPStatsRes->CompletionCode = CC_NORMAL;
- // return sizeof (GetIPUDPRMCPStatsRes_T);
- // }
- // /*-----------------------------------------------------
- // * explode
- // * Funntion to split the strings and store in an array
- // *-----------------------------------------------------*/
- // char **explode(char separator, char *string)
- // {
- // int start = 0, i, k = 1, count = 2;
- // char **strarr;
- // for (i = 0; string[i] != '\0'; i++)
- // /* how many rows do we need for our array? */
- // if (string[i] == separator)
- // count++;
- // /* count is at least 2 to make room for the entire string
- // * * and the ending NULL */
- // strarr = malloc(count * sizeof(char*));
- // i = 0;
- // while (*string++ != '\0')
- // {
- // if (*string == separator)
- // {
- // strarr[i] = malloc(k - start + 2);
- // strncpy(strarr[i], string - k + start, k - start + 1);
- // strarr[i][k - start + 1] = '\0'; /* guarantee null termination */
- // start = k;
- // i++;
- // }
- // k++;
- // }
- // /* copy the last part of the string after the last separator */
- // strarr[i] = malloc(k - start);
- // strncpy(strarr[i], string - k + start, k - start - 1);
- // strarr[i][k - start - 1] = '\0'; /* guarantee null termination */
- // strarr[++i] = NULL;
- // return strarr;
- // }
- // /*----------------------------------------------
- // * UpdateArpStatus
- // *----------------------------------------------*/
- // uint8_t
- // UpdateArpStatus (uint8_t EthIndex,BOOL IsTimerRunning, int BMCInst)
- // {
- // uint8_t GratArpSuspend;
- // uint8_t ArpSuspend;
- // uint8_t Status;
- // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
- // char Cmds[50]={0}; // command string to perform BMC-generated ARP
- // char IfcName[16];
- // IPMI_DBG_PRINT_1 ("Timer - %x", IsTimerRunning);
- // GratArpSuspend = ArpSuspend = 1;
- // // Check Gratuitous ARP is Enabled
- // if (0 == (pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl & GRATIUTOUS_ENABLE_MASK))
- // {
- // GratArpSuspend = 0;
- // }
- // // Check ARP Response is Enabled
- // if (0 == (pBMCInfo->LANCfs[EthIndex].BMCGeneratedARPControl & ENABLE_ARP_RESPONSES))
- // {
- // ArpSuspend = 0;
- // }
- // /*Disable ARP */
- // if (TRUE == IsTimerRunning)
- // {
- // /* WDT is running, check and suspend ARP if necessary */
- // if( (0 != (BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex] & SUSPEND_GRAT_ARP)) &&
- // (0 < GratArpSuspend) )
- // {
- // GratArpSuspend--;
- // }
- // if( (0 != (BMC_GET_SHARED_MEM(BMCInst)->ArpSuspendStatus[EthIndex] & SUSPEND_ARP)) &&
- // (0 < ArpSuspend) )
- // {
- // ArpSuspend--;
- // }
- // }
-
- // memset(IfcName,0,sizeof(IfcName));
- // if(GetIfcName(EthIndex, IfcName, BMCInst) != 0)
- // {
- // TCRIT("Error in getting Interface Name for the Lan Index :%d\n", EthIndex);
- // }
- // else
- // {
- // /* Perform commands for BMC-generated Arp */
- // memset(Cmds, 0, sizeof(Cmds));
- // sprintf(Cmds, "/usr/local/bin/ArpSwitch.sh %s %d", IfcName, (!ArpSuspend) ? ARP_IGNORE_ON : ARP_IGNORE_OFF);
- // safe_system (Cmds);
- // /* Perform commands for BMC-generated Arp ends */
- // }
-
- // /* Update Status */
- // Status = ArpSuspend << 1;
- // Status = Status | GratArpSuspend;
- // return Status;
- // }
- // /**
- // *@fn NwInterfacePresenceCheck
- // *@brief This function is invoked to check network interface presence
- // *@param Interface - Char Pointer to Interface for which interface to check
- // *@return Returns 0 on success
- // */
- // static int
- // NwInterfacePresenceCheck (char * Interface)
- // {
- // int r;
- // int sockdes;
- // struct ifreq Ifreq;
- // unsigned char MAC[MAC_ADDR_LEN];
- // IPMI_DBG_PRINT_1 ("Checking the presence of %s\n", Interface);
- // sockdes = socket(PF_INET, SOCK_DGRAM, 0 );
- // if ( sockdes < 0 )
- // {
- // IPMI_ERROR("can't open socket: %s\n",strerror(errno));
- // return -1;
- // }
- // /* Get MAC address */
- // memset(&Ifreq,0,sizeof(struct ifreq));
- // memset(MAC, 0, MAC_ADDR_LEN);
- // strcpy(Ifreq.ifr_name, Interface);
- // Ifreq.ifr_hwaddr.sa_family = AF_INET;
- // r = ioctl(sockdes, SIOCGIFHWADDR, &Ifreq);
- // close (sockdes);
- // if ( r < 0 )
- // {
- // //IPMI_ERROR("IOCTL to get MAC failed: %d\n",r);
- // return -1;
- // }
- // IPMI_DBG_PRINT_1 (" %s Interface is present\n", Interface);
- // return 0;
- // }
|