Skip to content

Commit

Permalink
PAC infra system related APIs (sonic-net#18642)
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaya-ops authored and saksarav-nokia committed Oct 9, 2024
1 parent 992800d commit f256f3a
Showing 1 changed file with 122 additions and 0 deletions.
122 changes: 122 additions & 0 deletions src/sonic-pac/fpinfra/sim/sim.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* Copyright 2024 Broadcom Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <time.h>
#include "fpnim.h"

extern "C" {
#include "datatypes.h"
#include "system_exports.h"
#include "simapi.h"
#include "osapi.h"
}

/*********************************************************************
* @purpose Get the Unit's System Mac Address Type
*
* @param none
*
* @returns sysMacType System Mac Address Type
*
* @comments
*
* @end
*********************************************************************/
uint32 simGetSystemIPMacType(void)
{
return( SYSMAC_BIA);
}

/*********************************************************************
* @purpose Get the Unit's System Burned in Mac Address
*
* @param *sysBIA @b{(output)} pointer to system burned in mac address
* Length MAC_ADDR_LEN
*
* @returns none
*
* @comments
*
* @end
*********************************************************************/
void simGetSystemIPBurnedInMac( uchar8 *sysBIA)
{
FpNim * nim = FpNim::getInstance();
if(nim)
{
nim->getSystemMac(sysBIA);
}
}


/*********************************************************************
* @purpose Get the Unit's System Locally Administered Mac Address
*
* @param *sysLAA @b{(output)} pointer to system local admin mac address
*
* @returns none
*
* @comments
*
* @end
*********************************************************************/
void simGetSystemIPLocalAdminMac( uchar8 *sysLAA)
{
simGetSystemIPBurnedInMac(sysLAA);
}

/*********************************************************************
*
* @purpose Get the stack up time
*
* @param none
*
* @returns stack up time in seconds
*
* @comments Stack up time is the time since the stack performed a cold
* restart. Stack up time does not reset on a warm restart.
*
* @end
*
*********************************************************************/
uint32 simSystemUpTimeGet(void)
{
return osapiUpTimeRaw();
}

/**********************************************************************
* @purpose Adjusts current time for timezone and summer time
*
* @returns Adjusted time
*
*
* @end
*********************************************************************/
uint32 simAdjustedTimeGet()
{
struct timespec tp;
int rc;

rc = clock_gettime(CLOCK_REALTIME, &tp);
if (rc < 0)
{
return 0;
}
return(tp.tv_sec);
}



0 comments on commit f256f3a

Please sign in to comment.