diff --git a/config/RdkVlanManager.xml b/config/RdkVlanManager.xml index 1cfda42..97f3010 100644 --- a/config/RdkVlanManager.xml +++ b/config/RdkVlanManager.xml @@ -202,7 +202,13 @@ unsignedInt uint32 true - + + + MACVLAN + unsignedInt + uint32 + true + X_RDK_BaseInterface string(64) diff --git a/source/TR-181/include/vlan_apis.h b/source/TR-181/include/vlan_apis.h index 9753c1b..c06638a 100644 --- a/source/TR-181/include/vlan_apis.h +++ b/source/TR-181/include/vlan_apis.h @@ -50,6 +50,7 @@ #define PSM_VLANMANAGER_LOWERLAYERS "dmsb.vlanmanager.%d.lowerlayers" #define PSM_VLANMANAGER_VLANID "dmsb.vlanmanager.%d.vlanid" #define PSM_VLANMANAGER_TPID "dmsb.vlanmanager.%d.tpid" +#define PSM_VLANMANAGER_MACVLAN "dmsb.vlanmanager.%d.macvlan" #define PSM_VLANMANAGER_BASEINTERFACE "dmsb.vlanmanager.%d.baseinterface" #define PSM_VLANMANAGER_PATH "dmsb.vlanmanager.%d.path" @@ -88,6 +89,7 @@ _DML_VLAN CHAR BaseInterface[64]; INT VLANId; UINT TPId; + UINT macvlan; CHAR Path[1024]; } DML_VLAN, *PDML_VLAN; diff --git a/source/TR-181/middle_layer_src/ethernet_apis.c b/source/TR-181/middle_layer_src/ethernet_apis.c index af2ee48..31478ec 100644 --- a/source/TR-181/middle_layer_src/ethernet_apis.c +++ b/source/TR-181/middle_layer_src/ethernet_apis.c @@ -927,6 +927,7 @@ static ANSC_STATUS EthLink_CreateUnTaggedInterface(PDML_ETHERNET pEntry) #if !defined(VLAN_MANAGER_HAL_ENABLED) static ANSC_STATUS EthLink_DeleteUnTaggedInterface(PDML_ETHERNET pEntry) { + ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; if (pEntry == NULL) @@ -943,7 +944,6 @@ static ANSC_STATUS EthLink_DeleteUnTaggedInterface(PDML_ETHERNET pEntry) CcspTraceInfo(("%s-%d: Successfully deleted untagged VLAN interface %s\n", __FUNCTION__, __LINE__, pEntry->Name)); - return returnStatus; } #endif /* !VLAN_MANAGER_HAL_ENABLED */ diff --git a/source/TR-181/middle_layer_src/vlan_apis.c b/source/TR-181/middle_layer_src/vlan_apis.c index 395de97..679e416 100644 --- a/source/TR-181/middle_layer_src/vlan_apis.c +++ b/source/TR-181/middle_layer_src/vlan_apis.c @@ -402,6 +402,12 @@ void * Vlan_Disable(void *Arg) Vlan_DeleteInterface(pEntry); #endif } +#if !defined(VLAN_MANAGER_HAL_ENABLED) + else if(pEntry->VLANId == -1 && pEntry->macvlan == 0) + { + Vlan_DeleteInterface(pEntry); + } +#endif pEntry->Status = VLAN_IF_DOWN; EthLink_SendVirtualIfaceVlanStatus(pEntry->Path, "Down"); CcspTraceInfo(("%s - %s:Successfully deleted VLAN interface %s\n", __FUNCTION__, VLAN_MARKER_VLAN_IF_CREATE, pEntry->Name)); @@ -590,6 +596,32 @@ static ANSC_STATUS Vlan_CreateTaggedInterface(PDML_VLAN pEntry) } #endif +#if !defined(VLAN_MANAGER_HAL_ENABLED) +static ANSC_STATUS Vlan_CreateUnTaggedInterface(PDML_VLAN pEntry) +{ + ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; + + if (pEntry == NULL) + { + CcspTraceError(("%s-%d: Failed to Create UnTagged Vlan Interface\n", __FUNCTION__, __LINE__)); + return ANSC_STATUS_FAILURE; + } + + v_secure_system("ip link add link %s name %s type vlan id 0", pEntry->Alias , pEntry->Name); + + v_secure_system("ip link set %s up", pEntry->Name); + + if (Vlan_SetMacAddr(pEntry) == ANSC_STATUS_FAILURE) + { + CcspTraceError(("%s Failed to Set MacAddress \n", __FUNCTION__)); + return ANSC_STATUS_FAILURE; + } + + return returnStatus; +} +#endif + + void * Vlan_Enable(void *Arg) { ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; @@ -603,11 +635,17 @@ void * Vlan_Enable(void *Arg) pthread_exit(NULL); } + CcspTraceError(("%s-%d: PALAKSHA MAIN VLAN_ENABLE VLAN ID CASE %d %d %s %s\n", __FUNCTION__, __LINE__, pEntry->VLANId,pEntry->macvlan, pEntry->BaseInterface, pEntry->Name)); pthread_detach(pthread_self()); pthread_mutex_lock(&vlan_access_mutex); //Create Vlan Tagged Interface - if(pEntry->VLANId > 0) { +#if defined(VLAN_MANAGER_HAL_ENABLED) + if(pEntry->VLANId > 0 ) { +#else + if(pEntry->VLANId > 0 || (pEntry->VLANId == -1 && pEntry->macvlan == 0)) { +#endif + CcspTraceError(("%s-%d: PALAKSHA MAIN VLAN_ENABLE VLAN ID GREATER CASE %d %d %s %s\n", __FUNCTION__, __LINE__, pEntry->VLANId,pEntry->macvlan, pEntry->BaseInterface, pEntry->Name)); if (Vlan_SetEthLink(pEntry, TRUE, TRUE) == ANSC_STATUS_FAILURE) { CcspTraceError(("%s-%d: Failed to Enable EthLink\n", __FUNCTION__, __LINE__)); @@ -617,25 +655,48 @@ void * Vlan_Enable(void *Arg) { CcspTraceError(("[%s][%d]Failed to get vlan interface status \n", __FUNCTION__, __LINE__)); } -#if defined(VLAN_MANAGER_HAL_ENABLED) if ( ( status != VLAN_IF_NOTPRESENT ) && ( status != VLAN_IF_ERROR ) ) { CcspTraceInfo(("%s %s:VLAN interface(%s) already exists, delete it first\n", __FUNCTION__, VLAN_MARKER_VLAN_IF_CREATE, pEntry->Name)); +#if defined(VLAN_MANAGER_HAL_ENABLED) returnStatus = vlan_eth_hal_deleteInterface(pEntry->Name, pEntry->InstanceNumber); if (ANSC_STATUS_SUCCESS != returnStatus) { CcspTraceError(("%s - Failed to delete the existing VLAN interface %s\n", __FUNCTION__, pEntry->Name)); } - CcspTraceInfo(("%s - %s:Successfully deleted VLAN interface %s\n", __FUNCTION__, VLAN_MARKER_VLAN_IF_DELETE, pEntry->Name)); + else +#else + v_secure_system("ip link set %s down", pEntry->Name); + v_secure_system("ip link delete %s",pEntry->Name); +#endif + { + CcspTraceInfo(("%s - %s:Successfully deleted VLAN interface %s\n", __FUNCTION__, VLAN_MARKER_VLAN_IF_DELETE, pEntry->Name)); + } } + +#if !defined(VLAN_MANAGER_HAL_ENABLED) + if(pEntry->VLANId > 0) + { #endif - returnStatus = Vlan_CreateTaggedInterface(pEntry); - if (ANSC_STATUS_SUCCESS != returnStatus) + returnStatus = Vlan_CreateTaggedInterface(pEntry); + if (ANSC_STATUS_SUCCESS != returnStatus) + { + pEntry->Status = VLAN_IF_ERROR; + CcspTraceError(("[%s][%d]Failed to create VLAN Tagged interface \n", __FUNCTION__, __LINE__)); + } +#if !defined(VLAN_MANAGER_HAL_ENABLED) + } + else { - pEntry->Status = VLAN_IF_ERROR; - CcspTraceError(("[%s][%d]Failed to create VLAN Tagged interface \n", __FUNCTION__, __LINE__)); + CcspTraceError(("[%s][%d]PALAKSHA CREATING UNTAGGED VLAN WITH VLAN ID 0\n", __FUNCTION__, __LINE__)); + returnStatus = Vlan_CreateUnTaggedInterface(pEntry); + if (ANSC_STATUS_SUCCESS != returnStatus) + { + pEntry->Status = VLAN_IF_ERROR; + CcspTraceError(("[%s][%d]Failed to create VLAN UnTagged interface \n", __FUNCTION__, __LINE__)); + } } - +#endif //Get status of VLAN link while(iIterator < 10) { @@ -661,6 +722,7 @@ void * Vlan_Enable(void *Arg) } else { + CcspTraceError(("%s-%d: PALAKSHA INSIDE FULL ELSE CASE calling Vlan_SetEthLink\n", __FUNCTION__, __LINE__)); //Enable EthLink and it will take care Creation of UnTagged Vlan Interface. if (Vlan_SetEthLink(pEntry, TRUE, FALSE) == ANSC_STATUS_FAILURE) { diff --git a/source/TR-181/middle_layer_src/vlan_dml.c b/source/TR-181/middle_layer_src/vlan_dml.c index 49c422d..64a1de2 100644 --- a/source/TR-181/middle_layer_src/vlan_dml.c +++ b/source/TR-181/middle_layer_src/vlan_dml.c @@ -360,6 +360,11 @@ Vlan_GetParamUlongValue *puLong = p_Vlan->TPId; return TRUE; } + if (strcmp(ParamName, "MACVLAN") == 0) + { + *puLong = p_Vlan->macvlan; + return TRUE; + } /* CcspTraceWarning(("Unsupported parameter '%s'\n", ParamName)); */ return FALSE; } @@ -627,6 +632,12 @@ Vlan_SetParamUlongValue p_Vlan->TPId = uValue; return TRUE; } + if (strcmp(ParamName, "MACVLAN") == 0) + { + p_Vlan->macvlan = uValue; + return TRUE; + } + /* CcspTraceWarning(("Unsupported parameter '%s'\n", ParamName)); */ return FALSE; diff --git a/source/TR-181/middle_layer_src/vlan_internal.c b/source/TR-181/middle_layer_src/vlan_internal.c index 9d9abb9..5faf730 100644 --- a/source/TR-181/middle_layer_src/vlan_internal.c +++ b/source/TR-181/middle_layer_src/vlan_internal.c @@ -48,6 +48,7 @@ #define PSM_VLANMANAGER_CFG_REGION "dmsb.vlanmanager.cfg.%d.region" #define PSM_VLANMANAGER_CFG_VLANID "dmsb.vlanmanager.cfg.%d.vlanid" #define PSM_VLANMANAGER_CFG_TPID "dmsb.vlanmanager.cfg.%d.tpid" +#define PSM_VLANMANAGER_CFG_MACVLAN "dmsb.vlanmanager.cfg.%d.macvlan" extern char g_Subsystem[32]; extern ANSC_HANDLE bus_handle; @@ -278,6 +279,15 @@ static ANSC_STATUS VlanTerminationInitialize( ANSC_HANDLE hThisObject) pVlan[nIndex].TPId = atoi(acPSMValue) ; } + /* get macvlan from psm */ + memset(acPSMQuery, 0, sizeof(acPSMQuery)); + memset(acPSMValue, 0, sizeof(acPSMValue)); + snprintf( acPSMQuery, sizeof( acPSMQuery ), PSM_VLANMANAGER_CFG_MACVLAN, (vlanCfgIndexes[nIndex] + 1) ); + if ( CCSP_SUCCESS == DmlVlanGetPSMRecordValue( acPSMQuery, acPSMValue ) ) + { + pVlan[nIndex].macvlan = atoi(acPSMValue) ; + } + /*TODO: *Need to be Removed Path From PSM Once RBUS Support Available in VlanManager and WanManager. */ @@ -377,6 +387,13 @@ static ANSC_STATUS VlanTerminationInitialize( ANSC_HANDLE hThisObject) pVlan[nIndex].TPId = atoi(acPSMValue) ; } + /* get cfg macvlan from psm */ + snprintf( acPSMQuery, sizeof( acPSMQuery ), PSM_VLANMANAGER_MACVLAN, nIndex + 1 ); + if ( CCSP_SUCCESS == DmlVlanGetPSMRecordValue( acPSMQuery, acPSMValue ) ) + { + pVlan[nIndex].macvlan = atoi(acPSMValue) ; + } + /* get base interface from psm */ snprintf( acPSMQuery, sizeof( acPSMQuery ), PSM_VLANMANAGER_BASEINTERFACE, nIndex + 1 ); if ( CCSP_SUCCESS == DmlVlanGetPSMRecordValue( acPSMQuery, acPSMValue ) )