Skip to content

Commit 2e55c75

Browse files
authored
MAB protocol related header files (#18629)
1 parent c75dc62 commit 2e55c75

File tree

8 files changed

+739
-0
lines changed

8 files changed

+739
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
#ifndef INCLUDE_MAB_AUTH_H
18+
#define INCLUDE_MAB_AUTH_H
19+
20+
/* USE C Declarations */
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
#include "comm_mask.h"
25+
26+
/*********************************************************************
27+
* @purpose Actions to be performed when sending request to a client
28+
*
29+
* @param logicalPortInfo @b{(input)) Logical Port Info node
30+
* @param bufHandle @b{(input)) buff handle
31+
*
32+
* @returns SUCCESS
33+
*
34+
* @comments
35+
*
36+
* @end
37+
*********************************************************************/
38+
RC_t mabClientRequestAction(mabLogicalPortInfo_t *logicalPortInfo, netBufHandle bufHandle);
39+
40+
/*********************************************************************
41+
* @purpose Actions to be performed when sending response to AAA
42+
*
43+
* @param logicalPortInfo @b{(input)) Logical Port Info node
44+
* @param bufHandle @b{(input)) buff handle
45+
*
46+
* @returns SUCCESS
47+
*
48+
* @comments
49+
*
50+
* @end
51+
*********************************************************************/
52+
RC_t mabClientResponseAction(mabLogicalPortInfo_t *logicalPortInfo, netBufHandle bufHandle);
53+
54+
/* USE C Declarations */
55+
#ifdef __cplusplus
56+
}
57+
#endif
58+
59+
#endif /* INCLUDE_MAB_AUTH_H */
Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
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+
18+
#ifndef INCLUDE_MAB_DB_H
19+
#define INCLUDE_MAB_DB_H
20+
21+
/* USE C Declarations */
22+
#ifdef __cplusplus
23+
extern "C" {
24+
#endif
25+
26+
#include "comm_mask.h"
27+
#include "apptimer_api.h"
28+
#include "mab_vlan.h"
29+
#include "auth_mgr_exports.h"
30+
#include "mab_radius.h"
31+
#include "mab_exports.h"
32+
#include "mab_util.h"
33+
#include "avl_api.h"
34+
#include "radius_attr_parse.h"
35+
36+
#define MAB_USER_INDEX_INVALID -1
37+
38+
#define MAB_MD5_LEN 16
39+
40+
#define MAB_SERVER_STATE_LEN 253
41+
#define MAB_SERVER_CLASS_LEN 253
42+
43+
#define MAB_FILTER_NAME_LEN 256
44+
45+
#define MAB_LOGICAL_PORT_START 0
46+
#define MAB_LOGICAL_PORT_END MAB_MAX_USERS_PER_PORT
47+
48+
#define MAB_LOGICAL_PORT_ITERATE 0xFFFFFFFF
49+
#define MAB_RADIUS_VLAN_ASSIGNED_LEN 32 /* Radius Assigned vlan length */
50+
51+
/* switch info */
52+
typedef struct mabInfo_s
53+
{
54+
uint32 traceId;
55+
} mabInfo_t;
56+
57+
typedef enum mabTimerType_s
58+
{
59+
MAB_TIMER_UNASSIGNED = 0,
60+
MAB_SERVER_AWHILE,
61+
}mabTimerType_t;
62+
63+
typedef enum
64+
{
65+
MAB_UNAUTHENTICATED = 0,
66+
MAB_AUTHENTICATING,
67+
MAB_AUTHENTICATED
68+
} MAB_AUTH_STATES_t;
69+
70+
typedef struct mabProtocolInfo_s
71+
{
72+
MAB_AUTH_STATES_t mabAuthState;
73+
BOOL authSuccess;
74+
BOOL authFail;
75+
}mabProtocolInfo_t;
76+
77+
typedef struct mabClientInfo_s
78+
{
79+
/* mab Client category */
80+
authmgrClientType_t clientType;
81+
82+
/* Re-auth and session related info */
83+
uchar8 currentIdL; /* ID of current auth session (0-255) */
84+
BOOL reAuthenticate; /* Set to TRUE when reAuthWhen timer expires */
85+
86+
/* client authentication status */
87+
AUTHMGR_PORT_STATUS_t logicalPortStatus; /* Current authorization state of the port */
88+
89+
/* user Details */
90+
uchar8 mabUserName[MAB_USER_NAME_LEN];
91+
uint32 mabUserNameLength;
92+
int32 mabUserIndex;
93+
94+
uchar8 mabChallenge[MAB_CHALLENGE_LEN];
95+
uint32 mabChallengelen;
96+
97+
netBufHandle suppBufHandle; /* Hold onto buf handle for re-transmit */
98+
enetMacAddr_t suppMacAddr; /* MAC address of Supplicant */
99+
100+
/* vlan related info */
101+
authmgrVlanType_t vlanType; /* assigned vlan category */
102+
uint32 vlanId; /* Vlan Id of Supplicant */
103+
104+
attrInfo_t attrInfo;
105+
uchar8 filterName[MAB_FILTER_NAME_LEN];
106+
107+
USER_MGR_AUTH_METHOD_t authMethod; /* Auth method for the user of this port */
108+
109+
AUTHMGR_PORT_MAB_AUTH_TYPE_t mabAuthType; /* Authentication type used by MAB. To be filled in only if isMABClient is TRUE */
110+
111+
}mabClientInfo_t;
112+
113+
typedef struct mabLogicalNodeKey_s
114+
{
115+
/* first 16 bits represent physical port
116+
next 12 bits represent logical port
117+
and remaining 3 bits represent client type.
118+
last bit is always 0 */
119+
uint32 keyNum;
120+
}mabLogicalNodeKey_t;
121+
122+
123+
typedef struct mabTimerContext_s
124+
{
125+
mabTimerType_t type;
126+
uint32 keyNum;
127+
}mabTimerContext_t;
128+
129+
130+
typedef struct mabTimerHandle_s
131+
{
132+
APP_TMR_HNDL_t timer;
133+
/* void *timerHandle; */
134+
}mabTimerHandle_t;
135+
136+
137+
typedef struct mabTimer_s
138+
{
139+
mabTimerContext_t cxt;
140+
mabTimerHandle_t handle;
141+
}mabTimer_t;
142+
143+
144+
/* logical port info */
145+
typedef struct mabLogicalPortInfo_s
146+
{
147+
/* unique node identifier*/
148+
mabLogicalNodeKey_t key;
149+
150+
mabTimer_t mabTimer;
151+
152+
/* protocol related info */
153+
mabProtocolInfo_t protocol;
154+
155+
/* client specific non protocol data */
156+
mabClientInfo_t client;
157+
158+
void *next; /* This field must be the last one in this structure */
159+
} mabLogicalPortInfo_t;
160+
161+
162+
/* Per-port info */
163+
typedef struct mabPortInfo_s
164+
{
165+
uint32 maxUsers;
166+
uint32 numUsers;
167+
168+
/* Inter-state machine communication and initialization */
169+
uchar8 currentId; /* ID of current auth session (0-255) */
170+
BOOL initialize; /* Set to TRUE by mgmt to cause port initialization */
171+
AUTHMGR_PORT_CONTROL_t portControlMode; /* Current control mode setting by mgmt */
172+
AUTHMGR_HOST_CONTROL_t hostMode; /* host mode setting by mgmt */
173+
BOOL portEnabled; /* TRUE if port is active */
174+
uint32 authCount; /* number of authorized clients */
175+
uint32 serverTimeout; /* Initialization value for aWhile timer when timing out Auth. Server */
176+
USER_MGR_AUTH_METHOD_t authMethod; /* Authentication method for the user of this port */
177+
AcquiredMask acquiredList; /* Mask of components "acquiring" an interface */
178+
uint32 mabEnabled; /* ENABLE if MAB has been enabled on the port and port control mode is mac-based*/
179+
180+
} mabPortInfo_t;
181+
182+
typedef RC_t(*mabCtrlTimerExpiryFn_t) (mabLogicalPortInfo_t *logicalPortInfo);
183+
typedef RC_t(*mabCtrlTimerNodeSetFn_t) (uint32 intIfNum, uint32 val);
184+
typedef RC_t(*mabCtrlTimerNodeGetFn_t) (uint32 intIfNum, uint32 *val);
185+
186+
typedef struct mabTimerMap_s
187+
{
188+
mabTimerType_t type;
189+
mabCtrlTimerExpiryFn_t expiryFn;
190+
}mabTimerMap_t;
191+
192+
193+
typedef RC_t(*mabCtrlHostModeSetFn_t) (uint32 intIfNum);
194+
195+
typedef struct mabHostModeMap_s
196+
{
197+
AUTHMGR_HOST_CONTROL_t hostMode;
198+
mabCtrlHostModeSetFn_t hostModeFn;
199+
}mabHostModeMap_t;
200+
201+
202+
typedef RC_t(*mabPortCtrlLearnFn_t) (uint32 intIfNum);
203+
204+
typedef struct mabPortCtrlLearnMap_s
205+
{
206+
AUTHMGR_PORT_CONTROL_t portControlMode;
207+
mabPortCtrlLearnFn_t learnFn;
208+
}mabPortCtrlLearnMap_t;
209+
210+
211+
typedef RC_t(*mabHostCtrlLearnFn_t) (uint32 intIfNum);
212+
213+
typedef struct mabHostCtrlLearnMap_s
214+
{
215+
AUTHMGR_HOST_CONTROL_t hostMode;
216+
mabHostCtrlLearnFn_t learnFn;
217+
}mabHostCtrlLearnMap_t;
218+
219+
typedef RC_t(*mabAuthmgrEventMapFn_t) (uint32 intIfNum, enetMacAddr_t suppMacAddr);
220+
221+
typedef struct mabAuthmgrEventFnMap_s
222+
{
223+
uint32 event;
224+
mabAuthmgrEventMapFn_t eventMapFn;
225+
}mabAuthmgrEventFnMap_t;
226+
227+
/* This structure is used to keep track of vlan addport/delport evetnts */
228+
typedef struct mabMacBasedVlanParticipation_s
229+
{
230+
INTF_MASK_t intfBitMask;
231+
INTF_MASK_t adminBitMask; /* Dot1q admin mode */
232+
}mabMacBasedVlanParticipation_t;
233+
234+
235+
typedef struct mabPortStats_s
236+
{
237+
/* Authenticator Diagnostics */
238+
uint32 authEntersAuthenticating;
239+
uint32 authAuthSuccessWhileAuthenticating;
240+
} mabPortStats_t;
241+
242+
extern mabInfo_t mabInfo;
243+
extern mabPortInfo_t *mabPortInfo;
244+
extern mabPortStats_t *mabPortStats;
245+
extern uint32 *mabMapTbl;
246+
247+
/*********************************************************************************************/
248+
249+
250+
/* Prototypes for the mab_db.c file */
251+
RC_t mabLogicalPortInfoDBInit(uint32 nodeCount);
252+
RC_t mabLogicalPortInfoDBDeInit(void);
253+
254+
RC_t mabLogicalPortInfoTakeLock(void);
255+
RC_t mabLogicalPortInfoGiveLock(void);
256+
257+
mabLogicalPortInfo_t *mabLogicalPortInfoAlloc(uint32 intIfNum);
258+
RC_t mabLogicalPortInfoDeAlloc(mabLogicalPortInfo_t *node);
259+
260+
mabLogicalPortInfo_t *mabLogicalPortInfoGet(uint32 lIntIfNum);
261+
mabLogicalPortInfo_t *mabLogicalPortInfoGetNext(uint32 lIntIfNum);
262+
263+
mabLogicalPortInfo_t *mabLogicalPortInfoFirstGet(uint32 intIfNum,
264+
uint32 *lIntIfNum);
265+
mabLogicalPortInfo_t *mabLogicalPortInfoGetNextNode(uint32 intIfNum,
266+
uint32 *lIntIfNum);
267+
/* USE C Declarations */
268+
#ifdef __cplusplus
269+
}
270+
#endif
271+
272+
#endif /* INCLUDE_MAB_DB_H */
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
#ifndef INCLUDE_MAB_LOCAL_H
18+
#define INCLUDE_MAB_LOCAL_H
19+
20+
/* USE C Declarations */
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
25+
extern RC_t mabLocalAuthResponseProcess(mabLogicalPortInfo_t *logicalPortInfo, netBufHandle bufHandle);
26+
extern RC_t mabLocalAuthMd5ResponseValidate(mabLogicalPortInfo_t *logicalPortInfo, uchar8 *response);
27+
extern void mabLocalAuthChallengeGenerate( uchar8 *challenge, uint32 challengeLen);
28+
extern void mabLocalMd5Calc( uchar8 *inBuf, uint32 inLen, uchar8 *outBuf);
29+
30+
/* USE C Declarations */
31+
#ifdef __cplusplus
32+
}
33+
#endif
34+
35+
#endif /* INCLUDE_MAB_LOCAL_H */

0 commit comments

Comments
 (0)