Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions source/TR-181/middle_layer_src/ethernet_apis.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,7 @@ static ANSC_STATUS EthLink_CreateUnTaggedInterface(PDML_ETHERNET pEntry)

CcspTraceInfo(("%s-%d: Successfully created MACVLAN untagged interface %s\n",
__FUNCTION__, __LINE__, pEntry->Name));

#endif
//Free VlanCfg skb_config memory
if (VlanCfg.skb_config != NULL)
Expand Down Expand Up @@ -1245,7 +1246,7 @@ ANSC_STATUS EthLink_GetMacAddr( PDML_ETHERNET pEntry )
char macStr[32];
int i, j = 0;

if (pEntry->InstanceNumber <= 0)
if (!pEntry || pEntry->InstanceNumber <= 0)
{
CcspTraceError(("%s-%d: Failed to get Mac Address, EthLinkInstance=%ld ", __FUNCTION__, __LINE__, pEntry->InstanceNumber));
return ANSC_STATUS_FAILURE;
Expand All @@ -1266,17 +1267,34 @@ ANSC_STATUS EthLink_GetMacAddr( PDML_ETHERNET pEntry )
}

acTmpReturnValue[j] = '\0';
sscanf(acTmpReturnValue, "%64llx", &number);

new_mac = number + pEntry->MACAddrOffSet;
snprintf(hex, sizeof(hex), "%08llx", new_mac);
if (sscanf(acTmpReturnValue, "%llx", &number) != 1)
{
CcspTraceError(("[%s][%d] Failed to parse MAC address %s\n",
__FUNCTION__, __LINE__, acTmpReturnValue));
return ANSC_STATUS_FAILURE;
}
Comment on lines +1271 to +1276

new_mac = number + pEntry->MACAddrOffSet;

/* Always preserve leading zeros of a 48-bit MAC */
snprintf(hex, sizeof(hex), "%012llx", new_mac);
Comment on lines +1278 to +1281

snprintf(macStr, sizeof(macStr), "%c%c:%c%c:%c%c:%c%c:%c%c:%c%c",
hex[0], hex[1], hex[2], hex[3], hex[4], hex[5], hex[6], hex[7], hex[8], hex[9], hex[10], hex[11]);
snprintf(macStr, sizeof(macStr),
"%c%c:%c%c:%c%c:%c%c:%c%c:%c%c",
hex[0], hex[1],
hex[2], hex[3],
hex[4], hex[5],
hex[6], hex[7],
hex[8], hex[9],
hex[10], hex[11]);

strncpy(pEntry->MACAddress, macStr, sizeof(pEntry->MACAddress) - 1);
strncpy(pEntry->MACAddress, macStr,
sizeof(pEntry->MACAddress) - 1);
pEntry->MACAddress[sizeof(pEntry->MACAddress) - 1] = '\0';

return ANSC_STATUS_SUCCESS;

}

#if defined(COMCAST_VLAN_HAL_ENABLED)
Expand Down