Skip to content

Commit f256f3a

Browse files
vijaya-opssaksarav-nokia
authored andcommitted
PAC infra system related APIs (sonic-net#18642)
1 parent 992800d commit f256f3a

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

src/sonic-pac/fpinfra/sim/sim.cpp

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
* Copyright 2024 Broadcom Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include <time.h>
18+
#include "fpnim.h"
19+
20+
extern "C" {
21+
#include "datatypes.h"
22+
#include "system_exports.h"
23+
#include "simapi.h"
24+
#include "osapi.h"
25+
}
26+
27+
/*********************************************************************
28+
* @purpose Get the Unit's System Mac Address Type
29+
*
30+
* @param none
31+
*
32+
* @returns sysMacType System Mac Address Type
33+
*
34+
* @comments
35+
*
36+
* @end
37+
*********************************************************************/
38+
uint32 simGetSystemIPMacType(void)
39+
{
40+
return( SYSMAC_BIA);
41+
}
42+
43+
/*********************************************************************
44+
* @purpose Get the Unit's System Burned in Mac Address
45+
*
46+
* @param *sysBIA @b{(output)} pointer to system burned in mac address
47+
* Length MAC_ADDR_LEN
48+
*
49+
* @returns none
50+
*
51+
* @comments
52+
*
53+
* @end
54+
*********************************************************************/
55+
void simGetSystemIPBurnedInMac( uchar8 *sysBIA)
56+
{
57+
FpNim * nim = FpNim::getInstance();
58+
if(nim)
59+
{
60+
nim->getSystemMac(sysBIA);
61+
}
62+
}
63+
64+
65+
/*********************************************************************
66+
* @purpose Get the Unit's System Locally Administered Mac Address
67+
*
68+
* @param *sysLAA @b{(output)} pointer to system local admin mac address
69+
*
70+
* @returns none
71+
*
72+
* @comments
73+
*
74+
* @end
75+
*********************************************************************/
76+
void simGetSystemIPLocalAdminMac( uchar8 *sysLAA)
77+
{
78+
simGetSystemIPBurnedInMac(sysLAA);
79+
}
80+
81+
/*********************************************************************
82+
*
83+
* @purpose Get the stack up time
84+
*
85+
* @param none
86+
*
87+
* @returns stack up time in seconds
88+
*
89+
* @comments Stack up time is the time since the stack performed a cold
90+
* restart. Stack up time does not reset on a warm restart.
91+
*
92+
* @end
93+
*
94+
*********************************************************************/
95+
uint32 simSystemUpTimeGet(void)
96+
{
97+
return osapiUpTimeRaw();
98+
}
99+
100+
/**********************************************************************
101+
* @purpose Adjusts current time for timezone and summer time
102+
*
103+
* @returns Adjusted time
104+
*
105+
*
106+
* @end
107+
*********************************************************************/
108+
uint32 simAdjustedTimeGet()
109+
{
110+
struct timespec tp;
111+
int rc;
112+
113+
rc = clock_gettime(CLOCK_REALTIME, &tp);
114+
if (rc < 0)
115+
{
116+
return 0;
117+
}
118+
return(tp.tv_sec);
119+
}
120+
121+
122+

0 commit comments

Comments
 (0)