From c75dc62b333d456bc2ecb3182db71b7040e8fe1a Mon Sep 17 00:00:00 2001 From: Vijaya Kumar Abbaraju Date: Sat, 26 Oct 2024 00:37:37 +0530 Subject: [PATCH] Auth mgr generic header files (#18632) --- .../authmgr/mapping/include/auth_mgr.h | 98 ++ .../mapping/include/auth_mgr_auth_method.h | 55 ++ .../authmgr/mapping/include/auth_mgr_cfg.h | 130 +++ .../authmgr/mapping/include/auth_mgr_client.h | 225 +++++ .../mapping/include/auth_mgr_control.h | 858 ++++++++++++++++++ .../authmgr/mapping/include/auth_mgr_debug.h | 146 +++ .../authmgr/mapping/include/auth_mgr_ih.h | 45 + .../mapping/include/auth_mgr_include.h | 69 ++ .../authmgr/mapping/include/auth_mgr_struct.h | 89 ++ 9 files changed, 1715 insertions(+) create mode 100755 src/sonic-pac/authmgr/mapping/include/auth_mgr.h create mode 100755 src/sonic-pac/authmgr/mapping/include/auth_mgr_auth_method.h create mode 100755 src/sonic-pac/authmgr/mapping/include/auth_mgr_cfg.h create mode 100755 src/sonic-pac/authmgr/mapping/include/auth_mgr_client.h create mode 100755 src/sonic-pac/authmgr/mapping/include/auth_mgr_control.h create mode 100755 src/sonic-pac/authmgr/mapping/include/auth_mgr_debug.h create mode 100755 src/sonic-pac/authmgr/mapping/include/auth_mgr_ih.h create mode 100755 src/sonic-pac/authmgr/mapping/include/auth_mgr_include.h create mode 100755 src/sonic-pac/authmgr/mapping/include/auth_mgr_struct.h diff --git a/src/sonic-pac/authmgr/mapping/include/auth_mgr.h b/src/sonic-pac/authmgr/mapping/include/auth_mgr.h new file mode 100755 index 000000000000..2c20957c1b5b --- /dev/null +++ b/src/sonic-pac/authmgr/mapping/include/auth_mgr.h @@ -0,0 +1,98 @@ +/* + * 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. + */ + +#ifndef AUTHMGR_H +#define AUTHMGR_H + +/* USE C Declarations */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Authentication Manager Timers */ +typedef enum +{ + AUTH_MGR_RESTART = 0, +} auth_mgr_timer_t; + +/* Authentication Manager Event Message IDs */ +typedef enum +{ + authMgrMethodSet = 1, + authMgrPrioritySet, + authMgrOpenAccess, + authMgrRestartTimerSet, + authMgrRestartTimerExpiry, + authMgrNimStartup, + authMgrCnfgr, + authMgrActivateStartupDone, + authMgrHandleNewBackupManager +}authMgrMessages_t; + +typedef enum +{ + AUTH_MGR_UNAUTHENTICATED = 0, + AUTH_MGR_AUTHENTICATED +} authMgrAuthStatus_t; + + +typedef struct authMgrIntfChangeParms_s +{ + uint32 event; + NIM_CORRELATOR_t correlator; +} authMgrIntfChangeParms_t; + +typedef struct authMgrNimStartup_s +{ + NIM_STARTUP_PHASE_t startupPhase; +} authMgrNimStartup_t; + +typedef struct authMgrTimerParams_s +{ + uint32 timerCBHandle; +} authMgrTimerParams_t; +#define AUTHMGR_TIMER_MSG_SIZE sizeof(authMgrTimerParams_t) + +/* authentication manager Event Message format */ +typedef struct authMgrMgmtMsg_s +{ + uint32 msgId; /* Of type snoopMgmtMessages_t */ + uint32 intIfNum; + union + { + CNFGR_CMD_DATA_t CmdData; + authMgrIntfChangeParms_t authMgrIntfChangeParms; + authMgrNimStartup_t authMgrNimStartup; + uint32 mode; + authMgrTimerParams_t authMgrParams; + uint32 timerValue; + } u; +} authMgrMgmtMsg_t; +#define AUTHMGR_MSG_SIZE sizeof(authMgrMgmtMsg_t) + + +/* Start of Function Prototype */ +void authMgrNotifyRegisteredUsers(uint32 intIfNum, + uint32 event); +/* End of function prototypes */ + +/* USE C Declarations */ +#ifdef __cplusplus +} +#endif + +#endif /* AUTHMGR_H */ + diff --git a/src/sonic-pac/authmgr/mapping/include/auth_mgr_auth_method.h b/src/sonic-pac/authmgr/mapping/include/auth_mgr_auth_method.h new file mode 100755 index 000000000000..84dcdddaa8de --- /dev/null +++ b/src/sonic-pac/authmgr/mapping/include/auth_mgr_auth_method.h @@ -0,0 +1,55 @@ +/* + * 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. + */ + +#ifndef AUTHMGR_AUTHMETHOD_H +#define AUTHMGR_AUTHMETHOD_H + +#include +#include "mab_socket.h" + +/* USE C Declarations */ +#ifdef __cplusplus +extern "C" { +#endif + +#define ETHERNET_PREFIX "Ethernet" + +typedef struct authmgrMethodEvent_s +{ + authmgrNotifyEvent_t event; + char8 eventStr[16]; +}authmgrMethodEvent_t; + +RC_t authmgrDot1xEventSend (uint32 intIfNum, uint32 event, enetMacAddr_t *macAddr); +RC_t authmgrDot1xIntfAdminModeGet (uint32 intIfNum, BOOL *enabled); +RC_t authmgrDot1xIntfPortControlModeSet (uint32 intIfNum, AUTHMGR_PORT_CONTROL_t portControl); +RC_t authmgrDot1xPortPaeCapabilitiesGet (uint32 intIfNum, uchar8 * capabilities); +int wpa_sync_send(char * ctrl_ifname, char * cmd, char *buf, size_t *len); +int authmgrMabDataSend(mab_pac_cmd_t *req, char *resp, unsigned int *len); +RC_t authmgrMabEventSend (uint32 intIfNum, uint32 event, enetMacAddr_t *macAddr); +RC_t authmgrMabIntfAdminModeGet (uint32 intIfNum, BOOL *enabled); + +int handle_async_resp_data(int *listen_sock); + +/* End of function prototypes */ + +/* USE C Declarations */ +#ifdef __cplusplus +} +#endif + +#endif /* AUTHMGR_AUTHMETHOD_H */ + diff --git a/src/sonic-pac/authmgr/mapping/include/auth_mgr_cfg.h b/src/sonic-pac/authmgr/mapping/include/auth_mgr_cfg.h new file mode 100755 index 000000000000..1026c6e98529 --- /dev/null +++ b/src/sonic-pac/authmgr/mapping/include/auth_mgr_cfg.h @@ -0,0 +1,130 @@ +/* + * 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. + */ + +#ifndef INCLUDE_AUTHMGR_CFG_H +#define INCLUDE_AUTHMGR_CFG_H + +/* USE C Declarations */ +#ifdef __cplusplus +extern "C" { +#endif + +#include "nim_data.h" + +#define AUTHMGR_IS_READY (((authmgrCnfgrState == AUTHMGR_PHASE_INIT_3) || \ + (authmgrCnfgrState == AUTHMGR_PHASE_EXECUTE) || \ + (authmgrCnfgrState == AUTHMGR_PHASE_UNCONFIG_1)) ? ( TRUE) : ( FALSE)) + +typedef enum { + AUTHMGR_PHASE_INIT_0 = 0, + AUTHMGR_PHASE_INIT_1, + AUTHMGR_PHASE_INIT_2, + AUTHMGR_PHASE_WMU, + AUTHMGR_PHASE_INIT_3, + AUTHMGR_PHASE_EXECUTE, + AUTHMGR_PHASE_UNCONFIG_1, + AUTHMGR_PHASE_UNCONFIG_2, +} authmgrCnfgrState_t; + +#define AUTHMGR_LLDP_PROFILES_MAX 128 + +typedef struct authmgrPortCfg_s +{ + nimConfigID_t configId; /* NIM config ID for this interface*/ + /* if port is operating as supplicnat, + the functionality is redundant */ + /* Authentication methods */ + AUTHMGR_METHOD_t methodList[ AUTHMGR_METHOD_LAST]; + AUTHMGR_METHOD_t priorityList[ AUTHMGR_METHOD_LAST]; + AUTHMGR_PORT_CONTROL_t portControlMode; /* Current control mode setting by mgmt */ + AUTHMGR_HOST_CONTROL_t hostMode; /* Current host mode setting by mgmt */ + uint32 quietPeriod; /* Initialization value for txWhen timer */ + uint32 reAuthPeriod; /* Number of seconds between periodic reauthentication */ + BOOL reAuthEnabled; /* TRUE if reauthentication is enabled */ + uint32 maxUsers; /*Maximum no. users in Mac-Based Authentication */ + uint32 maxAuthAttempts; /* Maximum number of times authentication may be reattempted by the user radius */ + /* variable to hold config related to session time out is to be used + from radius server */ + BOOL reAuthPeriodServer; + uint32 inActivityPeriod; /* Number of seconds to wait after which clients can be cleaned up due to inactivity */ + uint32 intfConfigMask; + uchar8 paeCapabilities; +} authmgrPortCfg_t; + +typedef struct authmgrCfg_s +{ + fileHdr_t cfgHdr; + uint32 adminMode; + uint32 authmgrLogTraceMode; /* Enable/disable log file tracing */ + uint32 vlanAssignmentMode;/* Global mode to enable vlan assignment */ + authmgrPortCfg_t authmgrPortCfg[ AUTHMGR_INTF_MAX_COUNT]; /* Per-port config info */ + AUTHMGR_PORT_CONTROL_t portControlMode; /* Current control mode setting by mgmt */ + AUTHMGR_HOST_CONTROL_t hostMode; /* Current host mode setting by mgmt */ +} authmgrCfg_t; + +extern authmgrCfg_t *authmgrCfg; + +typedef struct authmgrDebugCfgData_s +{ + BOOL authmgrDebugPacketTraceTxFlag; + BOOL authmgrDebugPacketTraceRxFlag; +} authmgrDebugCfgData_t; + +typedef struct authmgrDebugCfg_s +{ + fileHdr_t hdr; + authmgrDebugCfgData_t cfg; + uint32 checkSum; +} authmgrDebugCfg_t; + +extern RC_t authmgrSave(void); +extern BOOL authmgrHasDataChanged(void); +extern void authmgrResetDataChanged(void); + +extern RC_t authmgrCfgDump(void); +extern void authmgrBuildDefaultConfigData(void); +extern void authmgrBuildDefaultIntfConfigData(nimConfigID_t *configId, authmgrPortCfg_t *pCfg); + +extern RC_t authmgrApplyConfigData(void); +extern RC_t authmgrApplyPortConfigData(uint32 intIfNum); +extern RC_t authmgrPortReset(uint32 intIfNum); + +extern void authmgrApiCnfgrCommand( CNFGR_CMD_DATA_t *pCmdData); +extern RC_t authmgrInit(void); +extern void authmgrInitUndo(); +extern RC_t authmgrCnfgrInitPhase1Process(void); +extern RC_t authmgrCnfgrInitPhase2Process(void); +extern RC_t authmgrCnfgrInitPhase3Process( BOOL warmRestart); +extern void authmgrCnfgrFiniPhase1Process(); +extern void authmgrCnfgrFiniPhase2Process(); +extern void authmgrCnfgrFiniPhase3Process(); +extern RC_t authmgrCnfgrNoopProccess( CNFGR_RESPONSE_t *pResponse, + CNFGR_ERR_RC_t *pReason ); +extern RC_t authmgrCnfgrUconfigPhase2( CNFGR_RESPONSE_t *pResponse, + CNFGR_ERR_RC_t *pReason ); +extern void authmgrCnfgrParse( CNFGR_CMD_DATA_t *pCmdData); + +extern RC_t authmgrLogicalPortInfoSetPortInfo(authmgrLogicalPortInfo_t *logicalPortInfo); +extern RC_t authmgrLogicalPortInfoInitialize(authmgrLogicalPortInfo_t *logicalPortInfo); +extern RC_t authmgrLogicalPortReset(authmgrLogicalPortInfo_t *logicalPortInfo); +extern void authmgrCnfgrTerminateProcess( CNFGR_CMD_DATA_t *pCmdData); + +/* USE C Declarations */ +#ifdef __cplusplus +} +#endif + +#endif /* INCLUDE_AUTHMGR_CFG_H */ diff --git a/src/sonic-pac/authmgr/mapping/include/auth_mgr_client.h b/src/sonic-pac/authmgr/mapping/include/auth_mgr_client.h new file mode 100755 index 000000000000..07ebde81ef15 --- /dev/null +++ b/src/sonic-pac/authmgr/mapping/include/auth_mgr_client.h @@ -0,0 +1,225 @@ +/* + * 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. + */ + +#ifndef INCLUDE_AUTHMGR_CLIENT_H +#define INCLUDE_AUTHMGR_CLIENT_H + +/* USE C Declarations */ +#ifdef __cplusplus +extern "C" { +#endif + +#include "comm_mask.h" + +/********************************************************************* + * @purpose Set the authmgr physical port authorization status + * + * @param intIfNum @b{(input)) internal interface number + * @param portStatus @b{(input)) port authorization status setting + * + * @returns SUCCESS + * @returns FAILURE + * @returns ERROR + * + * @comments none + * + * @end + *********************************************************************/ +RC_t authmgrIhPhysicalPortStatusSet(uint32 intIfNum, + AUTHMGR_PORT_STATUS_t portStatus); + +/********************************************************************* + * @purpose Set the authmgr physical port authorization status + * +* @param intIfNum @b{(input)} internal interface number +* @param macAddr @b{(input)} MAC address of authorized client +* @param vlanId @b{(input)} set to non-zero value to assign this client to a VLAN + * + * @returns SUCCESS + * @returns FAILURE + * @returns ERROR + * + * @comments none + * + * @end + *********************************************************************/ +RC_t authmgrAuthenticatedClientAdd(uint32 physPort, + enetMacAddr_t macAddr, + ushort16 vlanId, + ushort16 blockVlanId); + +/********************************************************************* + * @purpose Set the authmgr physical port authorization status + * +* @param intIfNum @b{(input)} internal interface number +* @param macAddr @b{(input)} MAC address of authorized client +* @param vlanId @b{(input)} set to non-zero value to assign this client to a VLAN + * + * @returns SUCCESS + * @returns FAILURE + * @returns ERROR + * + * @comments none + * + * @end + *********************************************************************/ +RC_t authmgrAuthenticatedClientDelete(uint32 physPort, + enetMacAddr_t macAddr, + ushort16 vlanId); + +/********************************************************************* +* @purpose Cleanup the client Secure Downloadable ACL info from DB +* +* @param logicalPortInfo @b{(input)) client logical port info structure +* +* @returns SUCCESS +* @returns FAILURE +* +* @comments +* +* @end +*********************************************************************/ +RC_t authmgrRadiusSecDAclCleanupFromDb (authmgrLogicalPortInfo_t * logicalPortInfo); + +/********************************************************************* + * @purpose function to cleanup the vlan and other settings + * + * @param intIfNum @b{(input)) internal interface number + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrClientHwInfoCleanup(authmgrLogicalPortInfo_t *logicalPortInfo); + +/********************************************************************* + * @purpose function to cleanup the vlan and other settings + * + * @param intIfNum @b{(input)) internal interface number + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrClientHwInfoAdd(authmgrLogicalPortInfo_t *logicalPortInfo, + enetMacAddr_t macAddr, + ushort16 vlanId, + ushort16 blockVlanId); + +/********************************************************************* + * @purpose Set the authmgr client authorization status + * + * @param lIntIfNum @b{(input)) internal interface number + * @param portStatus @b{(input)) port authorization status setting + * + * @returns SUCCESS + * @returns FAILURE + * @returns ERROR + * + * @comments none + * + * @end + *********************************************************************/ +RC_t authmgrClientStatusSet(authmgrLogicalPortInfo_t *logicalPortInfo, AUTHMGR_PORT_STATUS_t portStatus); + +/********************************************************************* + * @purpose function to cleanup the client + * + * @param intIfNum @b{(input)) internal interface number + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrClientInfoCleanup(authmgrLogicalPortInfo_t *logicalPortInfo); + +/********************************************************************* + * @purpose function to cleanup the client sw info + * + * @param intIfNum @b{(input)) internal interface number + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrClientSwInfoCleanup(authmgrLogicalPortInfo_t *logicalPortInfo); + +/********************************************************************* + * @purpose function to check and deAllocate the client + * + * @param intIfNum @b{(input)) internal interface number + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrClientDisconnectAction(authmgrLogicalPortInfo_t *logicalPortInfo); + + +RC_t authmgrClientInfoCleanupCheck (authmgrClientInfo_t *src, + authmgrClientInfo_t *dst); +RC_t authmgrClientFailTimeoutAction(authmgrLogicalPortInfo_t *logicalPortInfo); + +/********************************************************************* +* @purpose utility function to check if the client ckpt params modified +* @param src +* @param dst +* @return SUCCESS/ FAILURE +* +* @comments +* +* @end +*********************************************************************/ +RC_t authmgrClientHwAddFailPostHwCleanup (authmgrLogicalPortInfo_t *logicalPortInfo, + uint32 mask); + + +/********************************************************************* +* @purpose function to check and cleanup authenticated client's params +* +* @param logicalPortInfo @b{(input)) logical interface structure +* +* @returns SUCCESS +* @returns FAILURE +* +* @comments +* +* @end +*********************************************************************/ +RC_t authmgrAuthenticatedClientCleanupAction (authmgrLogicalPortInfo_t * + logicalPortInfo); + +/* USE C Declarations */ +#ifdef __cplusplus +} +#endif + +#endif /* INCLUDE_AUTHMGR_CLIENT_H */ diff --git a/src/sonic-pac/authmgr/mapping/include/auth_mgr_control.h b/src/sonic-pac/authmgr/mapping/include/auth_mgr_control.h new file mode 100755 index 000000000000..56a53f886b98 --- /dev/null +++ b/src/sonic-pac/authmgr/mapping/include/auth_mgr_control.h @@ -0,0 +1,858 @@ +/* + * 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. + */ + + +#ifndef INCLUDE_AUTHMGR_CONTROL_H +#define INCLUDE_AUTHMGR_CONTROL_H + +/* USE C Declarations */ +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef AUTHMGR_MAC_MOVE_ON +#define AUTHMGR_MAC_MOVE_ON +#endif + +typedef enum authmgrControlEvents_s +{ + /***************************************************************/ + /* Events shared with all */ + /***************************************************************/ + /*100*/authmgrControlBegin = 100, + + /***************************************************************/ + /* Events from Management commands */ + /***************************************************************/ + + /*101*/authmgrMgmtPortInitializeSet, + /*102*/authmgrMgmtLogicalPortInitializeSet, + /*103*/authmgrMgmtPortReauthenticateSet, + /*105*/authmgrMgmtPortControlModeSet, + /*106*/authmgrMgmtHostControlModeSet, + /*110*/authmgrMgmtPortQuietPeriodSet, + /*111*/authmgrMgmtPortReAuthPeriodSet, + /*112*/authmgrMgmtPortReAuthEnabledSet, + /*113*/authmgrMgmtPortStatsClear, + /*114*/authmgrMgmtApplyConfigData, + /*115*/authmgrMgmtApplyPortConfigData, + /*116*/authmgrMgmtPortMaxUsersSet, + /*118*/authmgrMgmtLogicalPortReauthenticateSet, + /*119*/authmgrMethodOrderModify, + /*120*/authmgrMethodPriorityModify, + /*123*/authmgrPaeCapabilitiesEvent, + /*124*/authmgrViolationModeSet, + /*125*/authmgrMaxAuthAttemptsSet, + + /*129*/authmgrMgmtEvents, /*keep this last in sub group*/ + + /***************************************************************/ + /* Events from network pdu received */ + /***************************************************************/ + /*130*/authmgrNetworkEvents, + + /***************************************************************/ + /* Events from AAA client */ + /***************************************************************/ + /*131*/authmgrAaaInfoReceived, + + /*132*/authmgrAaaEvents, + + /***************************************************************/ + /* Events from interface state changes */ + /***************************************************************/ + /*133*/authmgrIntfChange, + /*134*/authmgrIntfStartup, + + /*135*/authmgrIntfChangeEvents, + + /***************************************************************/ + /* Events from Vlan state changes */ + /***************************************************************/ + + /*136*/authmgrVlanDeleteEvent, + /*137*/authmgrVlanAddEvent, + /*138*/authmgrVlanAddPortEvent, + /*139*/authmgrVlanDeletePortEvent, + /*140*/authmgrVlanPvidChangeEvent, + /*140*/authmgrVlanConfDeleteEvent, + /*140*/authmgrVlanConfPortDeleteEvent, + /***************************************************************/ + /* Events from configurator */ + /***************************************************************/ + /*141*/authmgrCnfgr, + + /*142*/authmgrCnfgrEvents, + + /*143*/authmgrUnauthAddrCallBackEvent, + /*145*/authmgrClientTimeout, + /***************************************************************/ + /*147*/authmgrDelDuplicateEntry, + /*148*/authmgrAddMacInMacDB, + /*149*/authmgrClientCleanup, + /***************************************************************/ + /* Events from Radius. */ + /***************************************************************/ + /* authmgr app timer events */ + /* 154*/ authmgrTimeTick, + /* 155*/ authmgrAuthenticationStart, + /* 156*/ authMgr8021xEnableDisable, + /* 157*/ authmgrMabEnableDisable, + /* 159*/ authmgrAuthMethodCallbackEvent, + /* 164*/ authmgrMgmtAdminModeEnable, + /* 165*/ authmgrMgmtAdminModeDisable, + /* 167*/ authmgrDynamicVlanModeEnable, + /* 168*/ authmgrDynamicVlanModeDisable, + /* 169*/ authmgrMgmtPortInactivePeriodSet, + + /* 179*/ authmgrCtlPortInfoReset, +}authmgrControlEvents_t; + +/* Message structure to hold responses from AAA client (i.e. RADIUS) */ +typedef struct authmgrAaaMsg_s +{ + uint32 status; /* status of response (i.e. RADIUS_STATUS_SUCCESS, etc.) */ + uint32 respLen; /* length of data (response) being passed */ + uchar8 *pResponse; /* pointer to response from AAA server */ +} authmgrAaaMsg_t; + +typedef struct authmgrIntfChangeParms_s +{ + uint32 intfEvent; + NIM_CORRELATOR_t nimCorrelator; +} authmgrIntfChangeParms_t; + +typedef struct authmgrUnauthCallbackParms_s +{ + enetMacAddr_t macAddr; + ushort16 vlanId; +} authmgrUnauthCallbackParms_t; + +typedef struct authmgrMgmtTimePeriod_s +{ + BOOL reAuthPeriodServer; + uint32 val; +} authmgrMgmtTimePeriod_t; + +typedef struct authmgrMsg_s +{ + uint32 event; + uint32 intf; + union + { + uint32 msgParm; + netBufHandle bufHandle; + authmgrAaaMsg_t authmgrAaaMsg; + authmgrIntfChangeParms_t authmgrIntfChangeParms; + NIM_STARTUP_PHASE_t startupPhase; + authmgrAuthRespParams_t authParams; + authmgrMgmtTimePeriod_t timePeriod; + }data; +} authmgrMsg_t; + +typedef struct authmgrBulkMsg_s +{ + uint32 event; + uint32 intf; + union + { + authmgrUnauthCallbackParms_t unauthParms; + }data; +} authmgrBulkMsg_t; + +typedef struct authmgrVlanMsg_s +{ + uint32 event; + uint32 intf; + union + { + dot1qNotifyData_t vlanData; + }data; +} authmgrVlanMsg_t; + +#define AUTHMGR_MSG_COUNT FD_AUTHMGR_MSG_COUNT +#define AUTHMGR_VLAN_MSG_COUNT (16 * 1024) +#define AUTHMGR_TIMER_TICK 1000 /*in milliseconds*/ + +typedef RC_t(*authmgrStatusMapFn_t) (uint32 lIntIfNum, authmgrAuthRespParams_t *params); + +typedef struct authmgrStatusMap_s +{ + AUTHMGR_STATUS_t type; + authmgrStatusMapFn_t statusFn; +}authmgrStatusMap_t; + +typedef RC_t(*authmgrPortControlChangeNotifyFn_t) (uint32 intIfNum, AUTHMGR_PORT_CONTROL_t portControl); +typedef RC_t(*authmgrHostControlChangeNotifyFn_t) (uint32 intIfNum, AUTHMGR_HOST_CONTROL_t hostMode); +typedef RC_t(*authmgrClientEventNotifyFn_t) (uint32 intIfNum, uint32 event, enetMacAddr_t *macAddr); +typedef RC_t(*authmgrMethodOperEnableGetFn_t) (uint32 intIfNum, uint32 *enable); + +typedef struct authmgrMethodCallbackNotifyMap_s +{ + AUTHMGR_METHOD_t method; + authmgrPortControlChangeNotifyFn_t portCtrlFn; + authmgrHostControlChangeNotifyFn_t hostCtrlFn; + authmgrClientEventNotifyFn_t eventNotifyFn; + authmgrMethodOperEnableGetFn_t enableGetFn; + authmgrMethodOperEnableGetFn_t radiusEnabledGetFn; +}authmgrMethodCallbackNotifyMap_t; + +extern RC_t authmgrStartTasks(); +extern RC_t authmgrFillMsg(void *data, authmgrMsg_t *msg); +extern RC_t authmgrBulkFillMsg(void *data, authmgrBulkMsg_t *msg); +extern RC_t authmgrVlanFillMsg (void *data, authmgrVlanMsg_t * msg); +extern RC_t authmgrIssueCmd(uint32 event, uint32 intIfNum, void *data); +extern RC_t authmgrDispatchCmd(authmgrMsg_t *msg); +extern RC_t authmgrBulkDispatchCmd(authmgrBulkMsg_t *msg); +extern RC_t authmgrVlanDispatchCmd (authmgrVlanMsg_t * msg); +extern RC_t authmgrTimerAction(); + +extern RC_t authmgrCtlPortInitializeSet(uint32 intIfNum, BOOL initialize); +extern RC_t authmgrCtlLogicalPortInitializeSet(uint32 lIntIfNum); +extern RC_t authmgrCtlPortReauthenticateSet(uint32 intIfNum, BOOL reauthenticate); +extern RC_t authmgrCtlLogicalPortReauthenticateSet(uint32 lIntIfNum, BOOL reauthenticate); +extern RC_t authmgrCtlPortControlModeSet(uint32 intIfNum, AUTHMGR_PORT_CONTROL_t portControl); +extern RC_t authmgrCtlPortPaeCapabilitiesSet(uint32 intIfNum, uint32 capabilities); +extern RC_t authmgrCtlPortPaeCapabilitiesInGlobalDisableSet(uint32 intIfNum, uint32 paeCapabilities); +extern RC_t authmgrCtlPortQuietPeriodSet(uint32 intIfNum, uint32 quietPeriod); +extern RC_t authmgrCtlPortTxPeriodSet(uint32 intIfNum, uint32 txPeriod); +extern RC_t authmgrCtlPortReAuthPeriodSet(uint32 intIfNum, authmgrMgmtTimePeriod_t *params); +extern RC_t authmgrCtlPortReAuthEnabledSet(uint32 intIfNum, BOOL reAuthEnabled); +extern RC_t authmgrCtlPortStatsClear(uint32 intIfNum); +extern RC_t authmgrCtlApplyConfigData(void); +extern RC_t authmgrCtlApplyPortConfigData(uint32 intIfNum); +extern RC_t authmgrRadiusServerVlanAssignmentHandle(uint32 intIfNum,uint32 vlanId); +extern RC_t authmgrRadiusServerVlanConversionHandle(const char8 *vlanName, uint32 *vlanId); +extern RC_t authmgrVlanAssignmentEnable(authmgrLogicalPortInfo_t *logicalPortInfo,uint32 vlanId); +extern RC_t authmgrVlanAssignmentDisable(uint32 intIfNum,uint32 vlanId); +extern RC_t authmgrPortVlanAssignmentDisable(uint32 intIfNum); +extern RC_t authmgrApplyConfigCompleteCb(uint32 event); +extern void authmgrVlanChangeProcess(uint32 event, uint32 intIfNum, dot1qNotifyData_t *vlanData); +extern RC_t authmgrCheckMapPdu(uint32 intIfNum, char8 *srcMac, uint32 *logicalPort, BOOL *existing_node); +extern RC_t authmgrCtlPortMaxUsersSet(uint32 intIfNum, uint32 maxUsers); +extern RC_t authmgrCtlApplyLogicalPortConfigData(uint32 lIntIfNum); +extern RC_t authmgrCtlResetLogicalPortSessionData(authmgrLogicalPortInfo_t *logicalPortInfo); +extern RC_t authmgrCtlStopLogicalPortSessionData(authmgrLogicalPortInfo_t *logicalPortInfo); +extern RC_t authmgrPortVlanMembershipSet(uint32 intIfNum, uint32 vlanId, BOOL flag); +extern RC_t authmgrVlanAddPortEventProcess(uint32 intIfNum,uint32 VlanId); +extern RC_t authmgrVlanAddEventProcess(uint32 intIfNum,uint32 VlanId); +extern RC_t authmgrVlanDeletePortEventProcess(uint32 intIfNum,uint32 VlanId); +extern RC_t authmgrVlanPVIDChangeEventProcess(uint32 intIfNum,uint32 vlanId); + +extern RC_t authmgrCtlLogicalPortVlanAssignedReset(uint32 lIntIfNum); +extern RC_t authmgrCtlLogicalPortVlanAssignmentDisable(authmgrLogicalPortInfo_t *logicalPortInfo); +extern RC_t authmgrCtlPortUnauthAddrCallbackProcess(uint32 intIfNum, enetMacAddr_t macAddr, ushort16 vlanId); + +/*MAB*/ +extern RC_t authmgrCtlLogicalPortMABTimerStart(uint32 lIntIfNum); +extern RC_t authmgrCtlPortMABEnableSet(uint32 intIfNum); +extern RC_t authmgrCtlPortMABDisableSet(uint32 intIfNum); +extern RC_t authmgrCtlLogicalPortMABRemove(uint32 llIntIfNum); +extern RC_t authmgrCtlLogicalPortMABOperational(uint32 llIntIfNum); +extern RC_t authmgrCtlLogicalPortMABAuthFailGuestVlanSet(authmgrLogicalPortInfo_t *logicalPortInfo); +extern RC_t authmgrCtlLogicalPortMABGuestVlanReset(uint32 lIntIfNum); +extern RC_t authmgrCtlLogicalPortMABGenResp(uint32 lIntIfNum, BOOL generateNak); + +extern RC_t authmgrCtlPortReset(uint32 intIfNum, BOOL initialize); + +/* Authmgr Client Timeout API */ +RC_t authmgrCtlLogicalPortClientTimeout(uint32 lIntIfNum); + +/********************************************************************* +* @purpose Disconnect the client +* +* @param intIfNum @b{(input)) internal interface number +* +* @returns SUCCESS +* @returns FAILURE +* +* @comments +* +* @end +*********************************************************************/ +RC_t authmgrCtlClientCleanup (uint32 lIntIfNum); + +/********************************************************************* + * @purpose Used to change port admin mode. + * + * @param intIfNum @b{(input)) internal interface number + * @param adminMode @b{(input)) administrative mode + * + * @returns SUCCESS + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrCtlPortAdminMode(uint32 intIfNum, uint32 adminMode); + +/********************************************************************* + * @purpose control mode function to set the port control mode to auto + * + * @param intIfNum @b{(input)) internal interface number + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrPortControlAutoActionSet(uint32 intIfNum); + +/********************************************************************* + * @purpose control function to set the host mode to multi host + * + * @param intIfNum @b{(input)) internal interface number + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrControlMultiHostActionSet(uint32 intIfNum); + +/********************************************************************* + * @purpose control function to set the host mode to single host mode + * + * @param intIfNum @b{(input)) internal interface number + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrControlSingleAuthActionSet(uint32 intIfNum); + +/********************************************************************* + * @purpose control function to set the host mode to multi auth + * + * @param intIfNum @b{(input)) internal interface number + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrControlMultAuthActionSet(uint32 intIfNum); + +/********************************************************************* + * @purpose control function to set the to force authorized + * + * @param intIfNum @b{(input)) internal interface number + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrPortControlForceAuthActionSet(uint32 intIfNum); + +/********************************************************************* + * @purpose control function to set the to force un-authorized + * + * @param intIfNum @b{(input)) internal interface number + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrPortControlForceUnAuthActionSet(uint32 intIfNum); + +/********************************************************************* + * @purpose function to clean up authmgr port oper info + * + * @param intIfNum @b{(input)) internal interface number + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrPortInfoCleanup(uint32 intIfNum); + +/********************************************************************* + * @purpose function to check policy validation based on host mode + * + * @param hostMode @b{(input)) hostmode + * @param *appyPolicy @b{(input)) bool value + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrHostModeHwPolicyApply( AUTHMGR_HOST_CONTROL_t hostMode, uint32 intIfNum, BOOL install); + + +/********************************************************************* + * @purpose Set authmgr authenticated client in specified VLAN + * + * @param logicalPortInfo @b{(input)) Logical Port Info node + * @param reason @b{(input)) Reason for the assignment + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrClientVlanInfoSet(authmgrLogicalPortInfo_t *logicalPortInfo, + uint32 vlanId); + +/********************************************************************* + * @purpose Set authmgr authenticated client in specified VLAN + * + * @param logicalPortInfo @b{(input)) Logical Port Info node + * @param reason @b{(input)) Reason for the assignment + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrClientVlanInfoReset(uint32 physPort, + uint32 vlanId); + + +void authmgrTimerExpiryHdlr( APP_TMR_CTRL_BLK_t timerCtrlBlk, void* ptrData); + +/************************************************************************* + * @purpose Starts the specified timer + * + * @param intIfNum @b{(input)} Interface for starting the timer + * @param timerType @b{(input)} Interface/Timer type + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments none + * + * @end + *************************************************************************/ +RC_t authmgrTimerStart(authmgrLogicalPortInfo_t *logicalPortInfo, authmgrTimerType_t type); + +RC_t authmgrTxPeriodGet(uint32 intIfNum, uint32 *val); + +RC_t authmgrQuietPeriodGet(uint32 intIfNum, uint32 *val); + +RC_t authmgrReAuthPeriodGet(uint32 intIfNum, uint32 *val); + +RC_t authmgrServerTimeoutPeriodGet(uint32 intIfNum, uint32 *val); + +RC_t authmgrHostModeMapInfoGet( AUTHMGR_HOST_CONTROL_t type, authmgrHostModeMap_t *elem); +/********************************************************************* + * @purpose control mode function to set the port host mode + * + * @param intIfNum @b{(input)) internal interface number + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrPortCtrlHostModeSet(uint32 intIfNum, AUTHMGR_HOST_CONTROL_t hostMode); + +/********************************************************************* + * @purpose Control function to handle the authentication method order changes + * + * @param intIfNum @b{(input)) internal interface number + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrMethodOrderChangeProcess(uint32 intIfNum); +/********************************************************************* + * @purpose authmgr task which serves the request queue + * + * @param none + * + * @returns void + * + * @comments User-interface writes and all are serviced off + * of the authmgrQueue + * + * @end + *********************************************************************/ +void authmgrTask(); +/********************************************************************* +* @purpose authmgr srvr task which serves the request queue +* +* @param none +* +* @returns void +* +* @comments external applications are serviced off +* of the authmgrQueue +* +* @end +*********************************************************************/ +void authmgrSrvrTask (); + +/********************************************************************* + * @purpose Control function to handle the events received from methods + * + * @param intIfNum @b{(input)) internal interface number + * @param status @b{(input)) status from the calling applications like + 802.1X/MAB/CP + * @param macAddr @b{(input)) mac addr of the client + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrClientCallbackEventProcess(uint32 intIfNum, + authmgrAuthRespParams_t *callbackParams); + +/********************************************************************* + * @purpose Function to Update the statistics + * + * @param intIfNum @b{(input)) internal interface number + * @param method @b{(input)) 802.1x/mab/cp + * @param mode @b{(input)) TRUE/ FALSE + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments TRUE will update the attempts, and FALSE will update the + failed attempts + * + * @end + *********************************************************************/ +RC_t authmgrStatsUpdate(uint32 intIfNum, + AUTHMGR_METHOD_t method, + authmgrStatsUpdate_t status); + +/********************************************************************* + * @purpose Get the next operationally enabled method on a interface + * + * @param intIfNum @b{(input)) internal interface number + * @param method @b{(input)) input method for which next method is needed. + * @param nextMethod @b{(output)) pointer to the next method + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ + +RC_t authmgrNextMethodGet(uint32 intIfNum, + AUTHMGR_METHOD_t *nextMethod); + +RC_t authmgrRegisteredEntryFnMapGet( AUTHMGR_METHOD_t method, authmgrMethodCallbackNotifyMap_t *entry); + +RC_t authmgrAuthenticationTrigger(authmgrLogicalPortInfo_t *logicalPortInfo); +RC_t authmgrPortEnabledMethodCountGet(uint32 physPort, uint32 *count); +/********************************************************************* + * @purpose Get the next operationally enabled method on a interface + * + * @param intIfNum @b{(input)) internal interface number + * @param method @b{(input)) input method for which next method is needed. + * @param nextMethod @b{(output)) pointer to the next method + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ + +RC_t authmgrEnabledMethodNextGet(uint32 intIfNum, + AUTHMGR_METHOD_t *nextMethod); + +/********************************************************************* + * @purpose updates the port pae capabilities + * + * @param intIfNum + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrPaeCapabilitiesEventProcess(uint32 intIfNum, uint32 mode); + +/********************************************************************* + * @purpose updates the port violation mode + * + * @param intIfNum + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrViolationModeSetAction(uint32 intIfNum, AUTHMGR_PORT_AUTH_VIOLATION_MODE_t mode); + +/********************************************************************* + * @purpose updates the port max auth retry attempts + * + * @param intIfNum + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrAuthFailMaxRetryCountSetAction(uint32 intIfNum, uint32 count); + +RC_t authmgrTimerReset(authmgrTimerType_t type); + +RC_t authmgrMethodModifyAction(uint32 intIfNum); +RC_t authmgrLogicalPortReAuthPeriodGet(uint32 lIntfNum, uint32 *val); + + void authmgrAllTimersStart(authmgrTimerType_t type, BOOL flag); + void authmgrAuthClientsTimersRestart(); + +/********************************************************************* + * @purpose updates the port max auth retry attempts + * + * @param intIfNum + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrAuthFailMaxRetryCountSetAction(uint32 intIfNum, uint32 count); + +/********************************************************************* + * @purpose Set port control mode + * + * @param intIfNum @b{(input)) internal interface number + * @param portControl @b{(input)) port control mode + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrPortCtrlModeSet(uint32 intIfNum, AUTHMGR_PORT_CONTROL_t portControl); + +/********************************************************************* + * @purpose Enable administrative mode setting for authmgr + * + * @param none + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrCtlAdminModeEnable(); + +/********************************************************************* + * @purpose Disable administrative mode setting for authmgr + * + * @param none + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrCtlAdminModeDisable(); + +/********************************************************************* +* @purpose Initialize the Authmgr Port Structure with Default Values +* +* @param intIfNum @b{(input)) internal interface number +* +* @returns SUCCESS +* @returns FAILURE +* +* @comments +* +* @end +*********************************************************************/ +RC_t authmgrPortInfoInitialize(uint32 intIfNum, BOOL flag); + +/********************************************************************* +* @purpose Set values of the Logical Authmgr Port Structure +* with Default Values of port it belongs to +* +* @param logicalPortInfo @b{(input)) Logical port Info +* +* @returns SUCCESS +* @returns FAILURE +* +* @comments +* +* @end +*********************************************************************/ +RC_t authmgrLogicalPortInfoInit(uint32 lIntIfNum); + +/********************************************************************* +* @purpose Populate Auth Manager Global Info structure +* +* @param none +* +* @returns none +* +* @comments +* +* @end +*********************************************************************/ +void authmgrGlobalInfoPopulate(); + +/********************************************************************* + * @purpose Handle dynamic vlan enable event + * + * @param none + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrCtlDynamicVlanEnableProcess(); + +/********************************************************************* + * @purpose Disable administrative mode setting for authmgr + * + * @param none + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t authmgrCtlDynamicVlanDisableProcess(); + +/********************************************************************* +* @purpose function to start timers on an interface +* +* @param phyIntf interface number +* @param type timer type +* @param flag start or stop +* +* @comments +* +* @end +*********************************************************************/ +void authmgrIntfClientsTimerStart (uint32 phyIntf, authmgrTimerType_t type, + BOOL flag); + +/********************************************************************* +* @purpose Used to get client inactivity timeout +* +* @param val @b{(input)) periodic timeout in seconds +* +* @returns SUCCESS +* +* @comments +* +* @end +*********************************************************************/ +RC_t authmgrCtlPortInactivityPeriodGet (uint32 intIfNum, + uint32 * val); + +/********************************************************************* +* @purpose function to start timers on an interface +* +* @param phyIntf interface number +* @param type timer type +* @param flag start or stop +* +* @comments +* +* @end +*********************************************************************/ +void authmgrIntfClientsTimerStart (uint32 phyIntf, authmgrTimerType_t type, + BOOL flag); + +/********************************************************************* +* @purpose Used to get client inactivity timeout +* +* @param val @b{(input)) periodic timeout in seconds +* +* @returns SUCCESS +* +* @comments +* +* @end +*********************************************************************/ +RC_t authmgrCtlPortInactivityPeriodGet (uint32 intIfNum, + uint32 * val); + +RC_t authmgrCtlPortMethodNoRespPeriodGet (uint32 intIfNum, + uint32 * val); + +/********************************************************************* +* @purpose To close the authenticated sessions gracefully. +* +* @returns SUCCESS +* @returns FAILURE +* +* @comments +* +* @end +*********************************************************************/ +RC_t authmgrTerminateAuthSessions(); + +/* USE C Declarations */ +#ifdef __cplusplus +} +#endif +#endif /* INCLUDE_AUTHMGR_CONTROL_H */ diff --git a/src/sonic-pac/authmgr/mapping/include/auth_mgr_debug.h b/src/sonic-pac/authmgr/mapping/include/auth_mgr_debug.h new file mode 100755 index 000000000000..80ea003926f1 --- /dev/null +++ b/src/sonic-pac/authmgr/mapping/include/auth_mgr_debug.h @@ -0,0 +1,146 @@ +/* + * 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. + */ + +#ifndef INCLUDE_AUTHMGR_DEBUG_H +#define INCLUDE_AUTHMGR_DEBUG_H + +/* USE C Declarations */ +#ifdef __cplusplus +extern "C" { +#endif + +#define AUTHMGR_TRACE(format,args...) \ +{ \ + if ( authmgrDebugLogTraceModeGet() == ENABLE) \ + { \ + LOGF( LOG_SEVERITY_INFO,format,##args); \ + } \ +} + +#define AUTHMGR_ERROR_SEVERE(format,args...) \ +{ \ + LOGF( LOG_SEVERITY_ERROR,format,##args); \ +} + +/* logical port debug info */ +typedef struct authmgrLogicalPortDebugInfo_s +{ + /* unique node identifier*/ + authmgrLogicalNodeKey_t key; + char8 timers[200]; + + /* protocol related info */ + authmgrProtocolInfo_t protocol; + + /* client specific non protocol data */ + authmgrClientInfo_t client; + +} authmgrLogicalPortDebugInfo_t; + +extern void authmgrDebugMsgQueue(); +extern void authmgrDebugTraceIdGet(); +extern void authmgrDebugSizesShow(); +extern void authmgrDebugPortCfgShow(uint32 intIfNum); +extern void authmgrDebugPortInfoShow(uint32 intIfNum); +extern void authmgrDebugPortStatsShow(uint32 intIfNum); +extern RC_t authmgrDebugLogTraceModeSet(uint32 mode); +extern uint32 authmgrDebugLogTraceModeGet(); +extern BOOL authmgrDebugPacketTraceTxFlag; +extern BOOL authmgrDebugPacketTraceRxFlag; + +extern void authmgrBuildTestConfigData(void); +extern RC_t authmgrDebugSave(void); +extern void authmgrDebugBuildDefaultConfigData(uint32 ver); +extern BOOL authmgrDebugHasDataChanged(void); +extern void authmgrDebugPacketTraceFlagGet( BOOL *transmitFlag, BOOL *receiveFlag); +extern RC_t authmgrDebugPacketTraceFlagSet( BOOL transmitFlag, BOOL receiveFlag); +extern void authmgrDebugPacketRxTrace(uint32 intIfNum, netBufHandle bufHandle); +extern void authmgrDebugPacketTxTrace(uint32 intIfNum, netBufHandle bufHandle); +extern void authmgrDebugPacketTrace(uint32 intIfNum, netBufHandle bufHandle, BOOL rxFlag, BOOL txFlag); +extern void authmgrDebugPacketDump(uint32 flag,uint32 physPort,uint32 intIfNum, netBufHandle bufHandle); +extern void authmgrDebugDataDump(uint32 flag, uint32 physPort, uchar8 *data,uint32 len); + +extern void authmgrDebugLogicalPortInfoShow(uint32 intIfNum, uint32 lIntIfNum); + +#define AUTHMGR_USER_TRACE_TX(__fmt__, __args__... ) \ + if (authmgrDebugPacketTraceTxFlag == TRUE) \ + { \ + LOG_USER_TRACE( AUTHMGR_COMPONENT_ID, __fmt__,##__args__); \ + } + +#define AUTHMGR_USER_TRACE_RX(__fmt__, __args__... ) \ + if (authmgrDebugPacketTraceRxFlag == TRUE) \ + { \ + LOG_USER_TRACE( AUTHMGR_COMPONENT_ID, __fmt__,##__args__); \ + } + + + +#define AUTHMGR_TRACE_PORT_STATUS 0x0001 +#define AUTHMGR_TRACE_EVENTS 0x0002 +#define AUTHMGR_TRACE_API_CALLS 0x0004 +#define AUTHMGR_TRACE_FSM_EVENTS 0x0008 +#define AUTHMGR_TRACE_FAILURE 0x0010 +#define AUTHMGR_TRACE_RADIUS 0x0020 +#define AUTHMGR_TRACE_TIMER 0x0040 +#define AUTHMGR_TRACE_MAC_ADDR_DB 0x0080 +#define AUTHMGR_TRACE_CLIENT 0x0800 + +extern uint32 authmgrDebugTraceFlag; +extern uint32 authmgrDebugTraceIntf; + +#define AUTHMGR_EVENT_TRACE(flag,intf,__fmt__, __args__...) \ + /*if ((authmgrDebugTraceFlag&flag) != 0 && (intf==0 || authmgrDebugTraceIntf ==0 || intf == authmgrDebugTraceIntf))*/ \ + { \ + char8 __buf1__[256]; \ + (void)osapiSnprintf (__buf1__, 256, __fmt__, ## __args__); \ + LOGF( LOG_SEVERITY_DEBUG, \ + "[%s:%d]%s",__FUNCTION__, __LINE__, __buf1__); \ + } + +void authmgrDevshellHelpPrint(); + +char *authmgrHostModeStringGet( AUTHMGR_HOST_CONTROL_t hostMode); +char *authmgrNodeTypeStringGet(authmgrNodeType_t type); +char *authmgrTimerTypeStringGet(authmgrTimerType_t type); +char *authmgrVlanTypeStringGet(authmgrVlanType_t type); +char *authmgrAuthStateStringGet(AUTHMGR_STATES_t state); +char *authmgrMethodStringGet( AUTHMGR_METHOD_t method); +char *authmgrMethodStatusStringGet( AUTHMGR_STATUS_t status); +char *authmgrSmEventStringGet(authmgrSmEvents_t event); +char *authmgrListTypeStringGet( AUTHMGR_METHOD_TYPE_t status); +char *authmgrClientTypeStringGet(authmgrClientType_t type); +char *authmgrAuthStatusStringGet( AUTHMGR_PORT_STATUS_t status); +void authmgrSuppMacStringGet( enetMacAddr_t *suppMacAddr); +char *authmgrAuthMethodStringGet(uint32 authMethod); +void authmgrDebugTraceEvent(uint32 debug,uint32 intfNum); +RC_t authmgrDebugTraceEventGet(uint32 *pDebug, uint32 *pIntfNum); + +void authmgrBuildTestConfigData(void); +void authmgrDebugBuildDefaultConfigData(uint32 ver); +BOOL authmgrDebugHasDataChanged(void); + +void authmgrDebugLogicalPortInfoShow(uint32 intIfNum, uint32 lIntIfNum); + +RC_t authmgrLportPortGet(uint32 *intIfNum, uint32 *lIntIfNum); +void authmgrUserCountDump(uint32 intIfNum); +RC_t authmgrDebugLogicalPortInfoNextGet (uint32 intIfNum, uint32 *lIntIfNum, + authmgrLogicalPortDebugInfo_t *debugInfo); + /* USE C Declarations */ +#ifdef __cplusplus +} +#endif +#endif /* INCLUDE_AUTHMGR_DEBUG_H*/ diff --git a/src/sonic-pac/authmgr/mapping/include/auth_mgr_ih.h b/src/sonic-pac/authmgr/mapping/include/auth_mgr_ih.h new file mode 100755 index 000000000000..ac623f7dea20 --- /dev/null +++ b/src/sonic-pac/authmgr/mapping/include/auth_mgr_ih.h @@ -0,0 +1,45 @@ +/* + * 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. + */ + +#ifndef INCLUDE_AUTHMGR_IH_H +#define INCLUDE_AUTHMGR_IH_H + +/* USE C Declarations */ +#ifdef __cplusplus +extern "C" { +#endif + +extern RC_t authmgrIntfChangeCallback(uint32 intIfNum, uint32 intfEvent,NIM_CORRELATOR_t correlator, + NIM_EVENT_SPECIFIC_DATA_t eventData); + +extern RC_t authmgrIhProcessIntfChange(uint32 intIfNum, uint32 intfEvent, NIM_CORRELATOR_t correlator); +extern RC_t authmgrIhProcessIntfStartup(NIM_STARTUP_PHASE_t startupPhase); +extern RC_t authmgrIntfActivateStartup(); +extern void authmgrIntfStartupCallback(NIM_STARTUP_PHASE_t startupPhase); +extern RC_t authmgrIhIntfValidate(uint32 intIfNum); +extern BOOL authmgrIntfIsConfigurable(uint32 intIfNum, authmgrPortCfg_t **pCfg); +extern BOOL authmgrIntfConfigEntryGet(uint32 intIfNum, authmgrPortCfg_t **pCfg); +extern RC_t authmgrIntfCreate(uint32 intIfNum); +extern RC_t authmgrIntfDetach(uint32 intIfNum); +extern RC_t authmgrIntfDelete(uint32 intIfNum); +extern RC_t authmgrIhPhyPortViolationCallbackSet(uint32 intIfNum, AUTHMGR_PORT_VIOLATION_CALLBACK_t flag); +extern RC_t authmgrAuthViolationDiagDisablePort(uint32 IntIfNum); +/* USE C Declarations */ +#ifdef __cplusplus +} +#endif + +#endif /*INCLUDE_AUTHMGR_IH_H*/ diff --git a/src/sonic-pac/authmgr/mapping/include/auth_mgr_include.h b/src/sonic-pac/authmgr/mapping/include/auth_mgr_include.h new file mode 100755 index 000000000000..2008eeb4fce4 --- /dev/null +++ b/src/sonic-pac/authmgr/mapping/include/auth_mgr_include.h @@ -0,0 +1,69 @@ +/* + * 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. + */ + +#ifndef INCLUDE_AUTHMGR_INCLUDE_H +#define INCLUDE_AUTHMGR_INCLUDE_H + +/* USE C Declarations */ +#ifdef __cplusplus +extern "C" { +#endif +/* +*********************************************************************** +* COMMON INCLUDES +*********************************************************************** +*/ +#include "pacinfra_common.h" +#include "osapi.h" +#include "nimapi.h" +#include "log.h" +#include +#include "datatypes.h" +#include "auth_mgr_api.h" + +/* +********************************************************************** +* STANDARD LIBRARIES +********************************************************************** +*/ +#include +#include +#include + +/* +********************************************************************** +* AUTHMGR HEADER FILES +********************************************************************** +*/ +#include "auth_mgr_exports.h" +#include "auth_mgr_sid.h" +#include "auth_mgr_sm.h" +#include "auth_mgr_db.h" +#include "auth_mgr_cfg.h" +#include "auth_mgr_control.h" +#include "auth_mgr_ih.h" +#include "auth_mgr_txrx.h" +#include "auth_mgr_debug.h" +#include "auth_mgr_mac_db.h" +#include "auth_mgr_client.h" +#include "auth_mgr_radius.h" +#include "auth_mgr_vlan.h" +#include "auth_mgr_util.h" + +#ifdef __cplusplus +} +#endif +#endif /* INCLUDE_AUTHMGR_INCLUDE_H */ diff --git a/src/sonic-pac/authmgr/mapping/include/auth_mgr_struct.h b/src/sonic-pac/authmgr/mapping/include/auth_mgr_struct.h new file mode 100755 index 000000000000..4d2770fa4f30 --- /dev/null +++ b/src/sonic-pac/authmgr/mapping/include/auth_mgr_struct.h @@ -0,0 +1,89 @@ +/* + * 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. + */ + +#ifndef INCLUDE_AUTHMGR_STRUCT_H +#define INCLUDE_AUTHMGR_STRUCT_H + +/* USE C Declarations */ +#ifdef __cplusplus +extern "C" { +#endif + +#include "pacinfra_common.h" +#include "osapi.h" +#include "portevent_mask.h" +#include "avl_api.h" +#include "tree_api.h" +#include "apptimer_api.h" +#include "auth_mgr_db.h" +#include "auth_mgr_cfg.h" +#include "auth_mgr_api.h" +#include "auth_mgr_debug.h" +#include "auth_mgr_include.h" + +typedef struct authmgrGlobalInfo_s +{ + authmgrCfg_t *authmgrCfg; + authmgrInfo_t authmgrInfo; + authmgrPortInfo_t *authmgrPortInfo; + authmgrPortStats_t *authmgrPortStats; + uint32 *authmgrMapTbl; + authmgrPortSessionStats_t *authmgrPortSessionStats; + authmgrDebugCfg_t authmgrDebugCfg; + + authmgrMethodCallbackNotifyMap_t authmgrCallbacks[ AUTHMGR_METHOD_LAST]; + /* App timer related data */ + APP_TMR_CTRL_BLK_t authmgrTimerCB; + uint32 authmgrAppTimerBufferPoolId; + + /* avl tree parameters */ + avlTree_t authmgrLogicalPortTreeDb; + avlTreeTables_t *authmgrLogicalPortTreeHeap; + authmgrLogicalPortInfo_t *authmgrLogicalPortDataHeap; + + uint32 authmgrMacAddrBufferPoolId; + sll_t authmgrMacAddrSLL; + osapiRWLock_t authmgrMacAddrDBRWLock; + + VLAN_MASK_t authmgrVlanMask; + int32 eap_socket; + uint32 reservedVlan; +}authmgrGlobalInfo_t; + +typedef struct authmgrCB_s +{ + void *authmgrTaskSyncSema; + void * authmgrTaskId; + void *authmgrSrvrTaskSyncSema; + void * authmgrSrvrTaskId; + int listen_sock; + osapiRWLock_t authmgrRWLock; + osapiRWLock_t authmgrCfgRWLock; + void *authmgrQueue; /* reference to the authmgr message queue */ + void *authmgrBulkQueue; /* reference to the authmgr bulk message queue */ + void *authmgrVlanEventQueue; /* reference to the authmgr vlan message queue */ + authmgrGlobalInfo_t *globalInfo; + authmgrClientInfo_t processInfo; + authmgrClientInfo_t oldInfo; + authmgrAuthAttributeInfo_t attrInfo; +}authmgrCB_t; + +/* USE C Declarations */ +#ifdef __cplusplus +} +#endif + +#endif /* INCLUDE_AUTHMGR_STRUCT_H */