From 9b0b811739b5fd9f329b14dd21f1e48842070040 Mon Sep 17 00:00:00 2001 From: Vijaya Kumar Abbaraju Date: Wed, 10 Apr 2024 02:21:31 -0700 Subject: [PATCH 1/2] MAB common header files for genereic files --- src/sonic-pac/mab/mapping/include/mab_cfg.h | 64 +++ .../mab/mapping/include/mab_client.h | 92 ++++ .../mab/mapping/include/mab_control.h | 397 ++++++++++++++++++ src/sonic-pac/mab/mapping/include/mab_debug.h | 48 +++ src/sonic-pac/mab/mapping/include/mab_ih.h | 41 ++ .../mab/mapping/include/mab_include.h | 66 +++ .../mab/mapping/include/mab_socket.h | 31 ++ .../mab/mapping/include/mab_struct.h | 95 +++++ 8 files changed, 834 insertions(+) create mode 100755 src/sonic-pac/mab/mapping/include/mab_cfg.h create mode 100755 src/sonic-pac/mab/mapping/include/mab_client.h create mode 100755 src/sonic-pac/mab/mapping/include/mab_control.h create mode 100755 src/sonic-pac/mab/mapping/include/mab_debug.h create mode 100755 src/sonic-pac/mab/mapping/include/mab_ih.h create mode 100755 src/sonic-pac/mab/mapping/include/mab_include.h create mode 100644 src/sonic-pac/mab/mapping/include/mab_socket.h create mode 100755 src/sonic-pac/mab/mapping/include/mab_struct.h diff --git a/src/sonic-pac/mab/mapping/include/mab_cfg.h b/src/sonic-pac/mab/mapping/include/mab_cfg.h new file mode 100755 index 000000000000..104462e6423c --- /dev/null +++ b/src/sonic-pac/mab/mapping/include/mab_cfg.h @@ -0,0 +1,64 @@ +/* + * 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_MAB_CFG_H +#define INCLUDE_MAB_CFG_H + +#include "nim_data.h" +/* USE C Declarations */ +#ifdef __cplusplus + extern "C" { +#endif +#define PASSWORD_SIZE MAB_USER_NAME_LEN + +extern BOOL mabInitializationState; +#define MAB_IS_READY (mabInitializationState) + +typedef struct mabPortCfg_s +{ + nimConfigID_t configId; /* NIM config ID for this interface*/ + uint32 maxUsers; /*Maximum no. users in Mac-Based Authentication */ + uint32 mabEnabled; /*enabled if MAB is enabled for the port*/ + AUTHMGR_PORT_MAB_AUTH_TYPE_t mabAuthType; /* Authentication type to be used by MAB */ +} mabPortCfg_t; + +typedef struct mabCfg_s +{ + mabPortCfg_t mabPortCfg[ MAB_INTF_MAX_COUNT]; /* Per-port config info */ +} mabCfg_t; + +extern mabCfg_t *mabCfg; + +extern uint32 mabPhysPortGet(uint32 lIntIfNum); +extern void mabBuildDefaultConfigData(); +extern void mabBuildDefaultIntfConfigData(nimConfigID_t *configId, mabPortCfg_t *pCfg); + +extern RC_t mabApplyConfigData(void); +extern RC_t mabPortInfoInitialize(uint32 intIfNum, BOOL flag); +extern RC_t mabPortReset(uint32 intIfNum); + +extern BOOL mabIsRestartTypeWarm(); +extern RC_t mabInit(void); +extern void mabInitUndo(); +extern RC_t mabInitPhase1Process(void); +extern RC_t mabInitPhase2Process(void); +extern RC_t mabInitPhase3Process( BOOL warmRestart); + +/* USE C Declarations */ +#ifdef __cplusplus +} +#endif +#endif /* INCLUDE_MAB_CFG_H */ diff --git a/src/sonic-pac/mab/mapping/include/mab_client.h b/src/sonic-pac/mab/mapping/include/mab_client.h new file mode 100755 index 000000000000..a331c5e62c61 --- /dev/null +++ b/src/sonic-pac/mab/mapping/include/mab_client.h @@ -0,0 +1,92 @@ +/* + * 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_MAB_CLIENT_H +#define INCLUDE_MAB_CLIENT_H + +/* USE C Declarations */ +#ifdef __cplusplus + extern "C" { +#endif + +#define MAC_STR_LEN 17 + +#include "comm_mask.h" + +/********************************************************************* + * @purpose Set the mab 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 mabClientStatusSet(mabLogicalPortInfo_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 mabClientInfoCleanup(mabLogicalPortInfo_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 mabClientSwInfoCleanup(mabLogicalPortInfo_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 mabClientDisconnectAction(mabLogicalPortInfo_t *logicalPortInfo); + +/* USE C Declarations */ +#ifdef __cplusplus +} +#endif + +#endif /* INCLUDE_MAB_CLIENT_H */ diff --git a/src/sonic-pac/mab/mapping/include/mab_control.h b/src/sonic-pac/mab/mapping/include/mab_control.h new file mode 100755 index 000000000000..251d44934fe0 --- /dev/null +++ b/src/sonic-pac/mab/mapping/include/mab_control.h @@ -0,0 +1,397 @@ +/* + * 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_MAB_CONTROL_H +#define INCLUDE_MAB_CONTROL_H + +/* USE C Declarations */ +#ifdef __cplusplus + extern "C" { +#endif + +#include +#include "auth_mgr_common.h" + +typedef enum mabControlEvents_s +{ + /***************************************************************/ + /* Events shared with all */ + /***************************************************************/ + /*100*/mabControlBegin = 100, + + /***************************************************************/ + /* Events from Management commands */ + /***************************************************************/ + /*101*/mabMgmtPortInitializeSet, + /*102*/mabMgmtPortControlModeSet, + /*103*/mabMgmtPortHostModeSet, + /*104*/mabMgmtPortStatsClear, + /*105*/mabMgmtApplyConfigData, // No calls to API + /*106*/mabMgmtPortMABEnableSet, + /*107*/mabMgmtPortMABDisableSet, + + /*120*/mabMgmtEvents = 120, /*keep this last in sub group*/ + + /***************************************************************/ + /* Events from AAA client */ + /***************************************************************/ + /*121*/mabAaaInfoReceived, + /*122*/mabRadiusConfigUpdate, + + /***************************************************************/ + /* Events from interface state changes */ + /***************************************************************/ + /*123*/mabIntfChange, + /*124*/mabIntfStartup, + + /***************************************************************/ + /* Events from Vlan state changes */ + /***************************************************************/ + /*131*/mabVlanDeleteEvent = 131, + /*132*/mabVlanAddEvent, + /*133*/mabVlanAddPortEvent, + /*134*/mabVlanDeletePortEvent, + /*135*/mabVlanPvidChangeEvent, + + /***************************************************************/ + /* Events from authentication manager. */ + /***************************************************************/ + /*136*/mabAuthMgrEvent, + + /*137*/mabAddMacInMacDB, + + /***************************************************************/ + /* App timer events. */ + /***************************************************************/ + /*138*/ mabTimeTick, + + +}mabControlEvents_t; + +/* Message structure to Global RADIUS config updates */ +typedef struct mabRadiusGlobal_s +{ + unsigned char nas_ip[64]; + unsigned char nas_id[64]; +}mabRadiusGlobal_t; + +/* Message structure to RADIUS config updates */ +typedef struct mabRadiusServer_s +{ + unsigned int cmd; + union { + mab_radius_server_t server; + mabRadiusGlobal_t globalCfg; + }cmd_data; +}mabRadiusServer_t; + +typedef struct mabIpAaddr { + unsigned char af; /* AF_INET / AF_INET6 */ + union { + struct in_addr v4; + struct in6_addr v6; + } u; +}mabIpAaddr_t; + +/* Message structure to hold responses from AAA client (i.e. RADIUS) */ +typedef struct mabAaaMsg_s +{ + void *resp; + unsigned int len; +} mabAaaMsg_t; + +typedef struct mabIntfChangeParms_s +{ + uint32 intfEvent; + NIM_CORRELATOR_t nimCorrelator; +} mabIntfChangeParms_t; + +/* Message structure to hold responses from authentication manager */ +typedef struct mabAuthmgrMsg_s +{ + uint32 event; /* event */ + enetMacAddr_t clientMacAddr; /* client mac addr*/ +} mabAuthmgrMsg_t; + +typedef struct mabMsg_s +{ + uint32 event; + uint32 intf; + union + { + uint32 msgParm; + mabAaaMsg_t mabAaaMsg; + mabIntfChangeParms_t mabIntfChangeParms; + dot1qNotifyData_t vlanData; + NIM_STARTUP_PHASE_t startupPhase; + mabAuthmgrMsg_t mabAuthmgrMsg; + mabRadiusServer_t mabRadiusCfgMsg; + }data; +} mabMsg_t; + + +#define MAB_MSG_COUNT FD_MAB_MSG_COUNT +#define MAB_TIMER_TICK 1000 /*in milliseconds*/ + +extern RC_t mabStartTasks(); +extern void mabTask(); +extern void mabSrvrTask (); +extern void mabEloopTask (); +extern RC_t mabFillMsg(void *data, mabMsg_t *msg); +extern RC_t mabIssueCmd(uint32 event, uint32 intIfNum, void *data); +extern RC_t mabDispatchCmd(mabMsg_t *msg); +extern RC_t mabTimerAction(); +extern RC_t mabAuthmgrEventMapFnGet(uint32 event, mabAuthmgrEventFnMap_t *elem); +extern RC_t mabCtlPortInitializeSet(uint32 intIfNum, BOOL initialize); +extern RC_t mabCtlPortControlModeSet(uint32 intIfNum, AUTHMGR_PORT_CONTROL_t portControl); +extern RC_t mabPortCtrlModeSet(uint32 intIfNum, AUTHMGR_PORT_CONTROL_t portControl); +extern RC_t mabCtlPortStatsClear(uint32 intIfNum); +extern RC_t mabCtlApplyConfigData(void); +extern RC_t mabCtlApplyPortConfigData(uint32 intIfNum); +extern RC_t mabRadiusServerVlanConversionHandle(const char8 *vlanName, uint32 *vlanId); +extern RC_t mabVlanChangeCallback(dot1qNotifyData_t *vlanData, uint32 intIfNum, uint32 event); +extern void mabVlanChangeProcess(uint32 event, uint32 intIfNum, dot1qNotifyData_t *vlanData); +extern RC_t mabCheckMapPdu(uint32 intIfNum, char8 *srcMac, uint32 *logicalPort, BOOL *existing_node); +extern RC_t mabVlanPVIDChangeEventProcess(uint32 intIfNum,uint32 vlanId); + +extern RC_t mabCtlPortMABEnableSet(uint32 intIfNum); +extern RC_t mabCtlPortMABDisableSet(uint32 intIfNum); +extern RC_t mabCtlLogicalPortMABGenResp(uint32 lIntIfNum, BOOL generateNak); + +extern RC_t mabPortControlForceUnAuthActionSet(uint32 intIfNum); + +int mab_socket_server_handle(int *listen_sock); +int mabPortClientAuthStatusUpdate(int intIfNum, unsigned char *addr, char *status, void *param); + +/********************************************************************* + * @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 mabPortControlAutoActionSet(uint32 intIfNum); + +/********************************************************************* + * @purpose control function to set the host mode to multi-domain-auth + * + * @param intIfNum @b{(input)) internal interface number + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t mabControlMultiDomainHostAuthActionSet(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 mabControlMultiHostActionSet(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 mabControlSingleAuthActionSet(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 mabControlMultAuthActionSet(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 mabPortControlForceAuthActionSet(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 mabPortControlForceUnAuthActionSet(uint32 intIfNum); + +/********************************************************************* + * @purpose function to clean up mab port oper info + * + * @param intIfNum @b{(input)) internal interface number + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t mabPortInfoCleanup(uint32 intIfNum); + +RC_t mabHostModeMapInfoGet( AUTHMGR_HOST_CONTROL_t type, mabHostModeMap_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 mabPortCtrlHostModeSet(uint32 intIfNum, AUTHMGR_HOST_CONTROL_t hostMode); + +/********************************************************************* + * @purpose Actions to be performed in the APM state DISCONNECTED + * + * @param logicalPortInfo @b{(input)) Logical Port Info node + * + * @returns SUCCESS + * + * @comments + * + * @end + *********************************************************************/ +RC_t mabUnAuthenticatedAction(mabLogicalPortInfo_t *logicalPortInfo); + +/********************************************************************* + * @purpose Actions to be performed in the APM state AUTHENTICATED + * + * @param logicalPortInfo @b{(input)) Logical Port Info node + * + * @returns SUCCESS + * + * @comments + * + * @end + *********************************************************************/ +RC_t mabAuthenticatedAction(mabLogicalPortInfo_t *logicalPortInfo); + +/********************************************************************* + * @purpose Actions to be performed in the APM state AUTHENTICATING + * + * @param logicalPortInfo @b{(input)) Logical Port Info node + * + * @returns SUCCESS + * + * @comments + * + * @end + *********************************************************************/ +RC_t mabAuthenticatingAction(mabLogicalPortInfo_t *logicalPortInfo); + +/********************************************************************* + * @purpose Add supplicant MAC in MAC database + * + * @param lIntIfNum @b{(input)} logical interface number that this PDU was received on + * + * @returns SUCCESS or FAILURE + * + * @end + *********************************************************************/ +RC_t mabAddMac(uint32 lIntIfNum); + +RC_t mabAuthenticationInitiate(uint32 intIfNum, enetMacAddr_t suppMacAddr); + +RC_t mabAuthmgrEventProcess(uint32 intIfNum, mabAuthmgrMsg_t *authmgrParams); + +/********************************************************************* +* @purpose Set values of the Logical Dot1x 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 mabLogicalPortInfoInit(uint32 lIntIfNum); + +/********************************************************************* + * @purpose API to check and clear appTimer Deinit + * + * @param none + * + * @returns SUCCESS + * @returns FAILURE + * + * @comments + * + * @end + *********************************************************************/ +RC_t mabAppTimerDeInitCheck(void); + +RC_t mabRadiusChangeHandle(mabRadiusServer_t *info); + +/* USE C Declarations */ +#ifdef __cplusplus +} +#endif + +#endif /* INCLUDE_MAB_CONTROL_H */ diff --git a/src/sonic-pac/mab/mapping/include/mab_debug.h b/src/sonic-pac/mab/mapping/include/mab_debug.h new file mode 100755 index 000000000000..cf8a098619a7 --- /dev/null +++ b/src/sonic-pac/mab/mapping/include/mab_debug.h @@ -0,0 +1,48 @@ +/* + * 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_MAB_DEBUG_H +#define INCLUDE_MAB_DEBUG_H + + /* USE C Declarations */ +#ifdef __cplusplus + extern "C" { +#endif + +#define MAB_ERROR_SEVERE(format,args...) \ +{ \ + LOGF(LOG_SEVERITY_ERROR,format,##args); \ +} + +#define MAB_EVENT_TRACE(__fmt__, __args__...) \ + { \ + char8 __buf1__[256] = {0}; \ + (void)osapiSnprintf(__buf1__, 256, __fmt__, ## __args__); \ + LOGF(LOG_SEVERITY_DEBUG, \ + "[%s:%d]%s",__FUNCTION__, __LINE__, (char *)__buf1__); \ + } + +char *mabHostModeStringGet( AUTHMGR_HOST_CONTROL_t hostMode); +char *mabNodeTypeStringGet(authmgrNodeType_t type); +char *mabTimerTypeStringGet(mabTimerType_t type); +char *mabVlanTypeStringGet(authmgrVlanType_t type); + +/* USE C Declarations */ +#ifdef __cplusplus +} +#endif + +#endif /* INCLUDE_MAB_DEBUG_H*/ diff --git a/src/sonic-pac/mab/mapping/include/mab_ih.h b/src/sonic-pac/mab/mapping/include/mab_ih.h new file mode 100755 index 000000000000..66f6816a8765 --- /dev/null +++ b/src/sonic-pac/mab/mapping/include/mab_ih.h @@ -0,0 +1,41 @@ +/* + * 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_MAB_IH_H +#define INCLUDE_MAB_IH_H + + /* USE C Declarations */ +#ifdef __cplusplus + extern "C" { +#endif + +extern RC_t mabIntfChangeCallback(uint32 intIfNum, uint32 intfEvent,NIM_CORRELATOR_t correlator, + NIM_EVENT_SPECIFIC_DATA_t eventData); +extern RC_t mabIhProcessIntfChange(uint32 intIfNum, uint32 intfEvent, NIM_CORRELATOR_t correlator); +extern RC_t mabIhProcessIntfStartup(NIM_STARTUP_PHASE_t startupPhase); +extern RC_t mabIntfActivateStartup(); +extern void mabIntfStartupCallback(NIM_STARTUP_PHASE_t startupPhase); +extern BOOL mabIntfIsConfigurable(uint32 intIfNum, mabPortCfg_t **pCfg); +extern RC_t mabIntfCreate(uint32 intIfNum); +extern RC_t mabIntfDetach(uint32 intIfNum); +extern RC_t mabIntfDelete(uint32 intIfNum); + +/* USE C Declarations */ +#ifdef __cplusplus +} +#endif + +#endif /*INCLUDE_MAB_IH_H*/ diff --git a/src/sonic-pac/mab/mapping/include/mab_include.h b/src/sonic-pac/mab/mapping/include/mab_include.h new file mode 100755 index 000000000000..6b3808bd98f2 --- /dev/null +++ b/src/sonic-pac/mab/mapping/include/mab_include.h @@ -0,0 +1,66 @@ +/* + * 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_MAB_INCLUDE_H +#define INCLUDE_MAB_INCLUDE_H + +/* +*********************************************************************** +* COMMON INCLUDES +*********************************************************************** +*/ + /* USE C Declarations */ +#ifdef __cplusplus + extern "C" { +#endif + +/* +********************************************************************** +* STANDARD LIBRARIES +********************************************************************** +*/ + +#include +#include +#include + +/* +********************************************************************** +* MAB HEADER FILES +********************************************************************** +*/ +#include "pacinfra_common.h" +#include "osapi.h" +#include "nimapi.h" + +#include "mab_api.h" +#include "mab_common.h" +#include "mab_db.h" +#include "mab_cfg.h" +#include "mab_control.h" +#include "mab_ih.h" +#include "mab_local.h" +#include "mab_debug.h" +#include "mab_sid.h" +#include "mab_mac_db.h" + +/* USE C Declarations */ +#ifdef __cplusplus +} +#endif +#endif /* INCLUDE_MAB_INCLUDE_H */ diff --git a/src/sonic-pac/mab/mapping/include/mab_socket.h b/src/sonic-pac/mab/mapping/include/mab_socket.h new file mode 100644 index 000000000000..94906058dfaa --- /dev/null +++ b/src/sonic-pac/mab/mapping/include/mab_socket.h @@ -0,0 +1,31 @@ +/* + * 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 MAB_SOCKET_H +#define MAB_SOCKET_H + +typedef struct mab_pac_cmd_s +{ + char intf[128]; + char cmd[128]; + unsigned char mac_addr[6]; + unsigned int notif_event; +}mab_pac_cmd_t; + +int mab_radius_init_send_socket(int *sock); +int mab_radius_init_recv_socket(int *sock); +#endif diff --git a/src/sonic-pac/mab/mapping/include/mab_struct.h b/src/sonic-pac/mab/mapping/include/mab_struct.h new file mode 100755 index 000000000000..d111cfbbf18b --- /dev/null +++ b/src/sonic-pac/mab/mapping/include/mab_struct.h @@ -0,0 +1,95 @@ +/* + * 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_MAB_STRUCT_H +#define INCLUDE_MAB_STRUCT_H + +/* USE C Declarations */ +#ifdef __cplusplus +extern "C" { +#endif + +#include "pacinfra_common.h" +#include "osapi.h" +#include "avl_api.h" +#include "apptimer_api.h" +#include "mab_db.h" +#include "mab_cfg.h" +#include "mab_api.h" +#include "mab_debug.h" +#include "mab_include.h" +#include "portevent_mask.h" +#include "tree_api.h" + +typedef struct connection_list_e +{ + int socket; + pthread_t tid; +}connection_list_t; + + +typedef struct mabBlock_s +{ + void * mabTaskId; + void * mabSrvrTaskId; + void * mabEloopTaskId; + int mabServerSock; + int send_fd; + int recv_fd; + connection_list_t *conn_list; + void *rad_cxt; + + mabCfg_t *mabCfg; + mabInfo_t mabInfo; + mabPortInfo_t *mabPortInfo; + mabPortStats_t *mabPortStats; + uint32 *mabMapTbl; + + /* App timer related data */ + APP_TMR_CTRL_BLK_t mabTimerCB; + uint32 mabAppTimerBufferPoolId; + + BOOL warmRestart; + BOOL mabSwitchoverInProgress; + + void *mabQueue; /* reference to the mab message queue */ + void *mabTaskSyncSema; + + void *mabRadiusSrvrTaskSyncSema; + + /* Global parameters */ + avlTree_t mabLogicalPortTreeDb; + avlTreeTables_t *mabLogicalPortTreeHeap; + mabLogicalPortInfo_t *mabLogicalPortDataHeap; + + uint32 mabMacAddrBufferPoolId; + sll_t mabMacAddrSLL; + osapiRWLock_t mabMacAddrDBRWLock; + + osapiRWLock_t mabRWLock; + + mabIpAaddr_t nas_ip; + unsigned char nas_id[64]; + +}mabBlock_t; + +/* USE C Declarations */ +#ifdef __cplusplus +} +#endif + + +#endif /* INCLUDE_MAB_STRUCT_H */ From 600c2983c1fdc792497031282477f4668e2f5f2f Mon Sep 17 00:00:00 2001 From: Vijaya Kumar Abbaraju Date: Thu, 24 Oct 2024 00:03:08 -0700 Subject: [PATCH 2/2] Addressed review comments --- src/sonic-pac/mab/mapping/include/mab_socket.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sonic-pac/mab/mapping/include/mab_socket.h b/src/sonic-pac/mab/mapping/include/mab_socket.h index 94906058dfaa..8518632a5627 100644 --- a/src/sonic-pac/mab/mapping/include/mab_socket.h +++ b/src/sonic-pac/mab/mapping/include/mab_socket.h @@ -18,10 +18,13 @@ #ifndef MAB_SOCKET_H #define MAB_SOCKET_H +#define MAB_INTF_STR_LEN 128 +#define MAB_CMD_STR_LEN 128 + typedef struct mab_pac_cmd_s { - char intf[128]; - char cmd[128]; + char intf[MAB_INTF_STR_LEN]; + char cmd[MAB_CMD_STR_LEN]; unsigned char mac_addr[6]; unsigned int notif_event; }mab_pac_cmd_t;