📄 pppradiuscomponent.c
字号:
*/LOCAL STATUS radiusProfileDataCopy ( PFW_OBJ * pfw, void * srcProfileData, void * dstProfileData ) { RADIUS_PROFILE_DATA * pSrcProfileData; RADIUS_PROFILE_DATA * pDstProfileData; pSrcProfileData = (RADIUS_PROFILE_DATA *) srcProfileData; pDstProfileData = (RADIUS_PROFILE_DATA *) dstProfileData; bzero(dstProfileData, sizeof(RADIUS_PROFILE_DATA)); if (pSrcProfileData->radius_serviceType != NULL) { if (radius_serviceType(pfw, PFW_PARAMETER_SET, dstProfileData, pSrcProfileData->radius_serviceType) == ERROR) { return ERROR; } } if (pSrcProfileData->radius_authenticationServer != NULL) { if (radius_authenticationServer(pfw, PFW_PARAMETER_SET, dstProfileData, pSrcProfileData->radius_authenticationServer) == ERROR) { radiusProfileDataDestruct (pfw,pDstProfileData); return ERROR; } } if (pSrcProfileData->radius_accountingServer != NULL) { if (radius_accountingServer(pfw, PFW_PARAMETER_SET, dstProfileData, pSrcProfileData->radius_accountingServer) == ERROR) { radiusProfileDataDestruct (pfw,pDstProfileData); return ERROR; } } if (pSrcProfileData->radius_nasIPaddress != NULL) { if (radius_nasIPaddress(pfw, PFW_PARAMETER_SET, dstProfileData, pSrcProfileData->radius_nasIPaddress) == ERROR) { radiusProfileDataDestruct (pfw,pDstProfileData); return ERROR; } } if (pSrcProfileData->radius_nasIdentifier != NULL) { if (radius_nasIdentifier(pfw, PFW_PARAMETER_SET, dstProfileData, pSrcProfileData->radius_nasIdentifier) == ERROR) { radiusProfileDataDestruct (pfw,pDstProfileData); return ERROR; } }#ifdef INET6 if (pSrcProfileData->radius_nasIPv6address != NULL) { if (radius_nasIPv6address(pfw, PFW_PARAMETER_SET, dstProfileData, pSrcProfileData->radius_nasIPv6address) == ERROR) { radiusProfileDataDestruct (pfw,pDstProfileData); return ERROR; } }#endif /* INET6 */ pDstProfileData->radius_authenticationServer_retries = pSrcProfileData->radius_authenticationServer_retries; pDstProfileData->radius_accountingServer_retries = pSrcProfileData->radius_accountingServer_retries; return OK; }/******************************************************************************** radiusProfileDataDestruct - clean up profile data***/LOCAL STATUS radiusProfileDataDestruct ( PFW_OBJ * pfw, void * pData ) { RADIUS_PROFILE_DATA * pProfileData = (RADIUS_PROFILE_DATA *) pData; if (pProfileData->radius_serviceType != NULL) pfwFree((void *) pProfileData->radius_serviceType); if (pProfileData->radius_authenticationServer != NULL) pfwFree((void *) pProfileData->radius_authenticationServer); if (pProfileData->radius_accountingServer != NULL) pfwFree((void *) pProfileData->radius_accountingServer); if (pProfileData->radius_nasIPaddress != NULL) pfwFree((void *) pProfileData->radius_nasIPaddress); if (pProfileData->radius_nasIdentifier != NULL) pfwFree((void *) pProfileData->radius_nasIdentifier);#ifdef INET6 if (pProfileData->radius_nasIPv6address != NULL) pfwFree((void *) pProfileData->radius_nasIPv6address);#endif /* INET6 */ return OK; }/******************************************************************************** radiusStackDataConstruct - initialize stack data***/LOCAL STATUS radiusStackDataConstruct ( PFW_OBJ * pfw, void * stackData, void * profileData ) { RADIUS_STACK_DATA * pStackData = (RADIUS_STACK_DATA *) stackData; RADIUS_PROFILE_DATA * pProfileData = (RADIUS_PROFILE_DATA *) profileData; int stringLength; LOCAL int sessionId; extern ULONG inet_addr(char *); bzero(stackData, sizeof(RADIUS_STACK_DATA)); pStackData->numberOfRadiusPendingRequest = 0; /* Set RADIUS attribute values */ pStackData->serviceType = htonl(RADIUS_FRAMED_SERVICE_TYPE); pStackData->framedProtocol = htonl(RADIUS_PPP_PROTOCOL); pStackData->acctStart = htonl(RADIUS_ACCOUNTING_START); pStackData->acctStop = htonl(RADIUS_ACCOUNTING_STOP); /* Set RADIUS Client callbacks */ pStackData->papRequestCallbacks.fptr_radius_normal_callback = radiusClientPapAuthNormalCallback; pStackData->papRequestCallbacks.fptr_radius_error_callback = radiusClientPapAuthErrorCallback; pStackData->chapRequestCallbacks.fptr_radius_normal_callback = radiusClientChapAuthNormalCallback; pStackData->chapRequestCallbacks.fptr_radius_error_callback = radiusClientChapAuthErrorCallback; pStackData->acctRequestCallbacks.fptr_radius_normal_callback = radiusClientAcctNormalCallback; pStackData->acctRequestCallbacks.fptr_radius_error_callback = radiusClientAcctErrorCallback; sprintf(pStackData->sessionId, "radius.%x", sessionId++); if (strcmp(pProfileData->radius_serviceType, "Auth") == 0) { pStackData->radiusFlags |= RADIUS_ALLOW_AUTHENTICATION; } else if (strcmp(pProfileData->radius_serviceType, "Acct") == 0) { pStackData->radiusFlags |= RADIUS_ALLOW_ACCOUNTING; } else { pStackData->radiusFlags |= RADIUS_ALLOW_AUTHENTICATION | RADIUS_ALLOW_ACCOUNTING; } radiusProcessServerConfig(pProfileData->radius_authenticationServer, &pStackData->authServerData, pfw); radiusProcessServerConfig(pProfileData->radius_accountingServer, &pStackData->acctServerData, pfw); if (pProfileData->radius_nasIPaddress != NULL) { pStackData->nasIPaddress = inet_addr(pProfileData->radius_nasIPaddress); } if (pProfileData->radius_nasIdentifier != NULL) { stringLength = strlen (pProfileData->radius_nasIdentifier) + 1; if ((pStackData->nasIdentifier = pfwMalloc(pfw, stringLength)) == NULL) { return ERROR; } bzero(pStackData->nasIdentifier, stringLength); strcpy(pStackData->nasIdentifier, pProfileData->radius_nasIdentifier); }#ifdef INET6 if (pProfileData->radius_nasIPv6address != NULL) { if (inet_pton(AF_INET6, pProfileData->radius_nasIPv6address, (void *)&pStackData->nasIPv6address) <= 0) {#ifdef PPP_DEBUG logMsg ("PPP: radiusStackDataConstruct: Invalid IPv6 address\n", 1,2,3,4,5,6);#endif /* PPP_DEBUG */ return ERROR; } }#endif /* INET6 */ return OK; }/******************************************************************************** RadiusStackDataDestruct - clean up stack data***/LOCAL STATUS radiusStackDataDestruct ( PFW_OBJ * pfw, void * stackData, void * profileData ) { RADIUS_STACK_DATA * pStackData = (RADIUS_STACK_DATA *) stackData; radiusClearServerData(&pStackData->authServerData); radiusClearServerData(&pStackData->acctServerData); return OK; }/******************************************************************************** radiusDestroyStackData - clean up stack data** Clean up the stack data when there are no active references** RETURNS: NONE*/LOCAL void radiusDestroyStackData ( RADIUS_STACK_DATA * pStackData ) { if (pStackData->nasIdentifier != NULL) { pfwFree((void *) pStackData->nasIdentifier); pStackData->nasIdentifier = NULL; } radiusClearPapData(&pStackData->papAuthData); radiusClearChapData(&pStackData->chapAuthData); radiusClearRcvdAttr(&pStackData->rcvdAttributes); radiusClearAcctData(&pStackData->acctData); radiusClearServerData(&pStackData->authServerData); radiusClearServerData(&pStackData->acctServerData); if (pStackData->callbacks && pStackData->callbacks->stackDeleteComplete) { (*pStackData->callbacks->stackDeleteComplete) (pStackData->callbacks, pStackData->state); } }/******************************************************************************** radiusStackAdd - Add RADIUS component to the stack***/LOCAL STATUS radiusStackAdd ( PFW_PLUGIN_OBJ_STATE * pComponentState, PFW_PLUGIN_OBJ_CALLBACKS * callbacks ) { int id; PFW_OBJ * pfwObj; PFW_LAYER_OBJ * layerObj; PFW_EVENT_OBJ * ipcpUpEvent; PFW_EVENT_OBJ * ipcpDownEvent;#ifdef INET6 PFW_EVENT_OBJ * ipv6cpUpEvent; PFW_EVENT_OBJ * ipv6cpDownEvent;#endif /* INET6 */ RADIUS_STACK_DATA * pStackData; pfwObj = pComponentState->pluginObj->pfwObj; layerObj = ((PFW_COMPONENT_OBJ *)pComponentState->pluginObj)->layerObj; pStackData = (RADIUS_STACK_DATA *) pComponentState->stackData; pStackData->callbacks = callbacks; if ((ipcpUpEvent = pfwEventObjGet(pfwObj, "IPCP_UP_EVENT")) == NULL) { logMsg("PPP: no IPCP_UP_EVENT\n",1,2,3,4,5,6); } else pfwEventStackSubscribe (pComponentState, ipcpUpEvent, radiusIpcpUpEventHandler); if ((ipcpDownEvent = pfwEventObjGet(pfwObj, "IPCP_DOWN_EVENT")) == NULL) { logMsg("PPP: no IPCP_DOWN_EVENT\n",1,2,3,4,5,6); } else pfwEventStackSubscribe (pComponentState, ipcpDownEvent, radiusIpcpDownEventHandler);#ifdef INET6 if ((ipv6cpUpEvent = pfwEventObjGet(pfwObj, "IPV6CP_UP_EVENT")) == NULL) { logMsg("PPP: no IPCP_UP_EVENT\n",1,2,3,4,5,6); } else pfwEventStackSubscribe (pComponentState, ipcpUpEvent, radiusIpv6cpUpEventHandler); if ((ipv6cpDownEvent = pfwEventObjGet(pfwObj, "IPV6CP_DOWN_EVENT")) == NULL) { logMsg("PPP: no IPCP_DOWN_EVENT\n",1,2,3,4,5,6); } else pfwEventStackSubscribe (pComponentState, ipv6cpDownEvent, radiusIpv6cpDownEventHandler);#endif /* INET6 */ if ((id = pfwInterfaceIdGet(pComponentState->pluginObj->pfwObj, "PHY_PORT_INTERFACE")) > 0) { if (pfwInterfaceObjAndStateGetViaStackObj(pComponentState->stackObj, id, &pStackData->physicalPortInterface) != OK) pStackData->physicalPortInterface.interfaceObj = NULL; } if ((id = pfwInterfaceIdGet(pComponentState->pluginObj->pfwObj, "ADAPTER_COMPONENT_STATISTICS_INTERFACE")) > 0) { if (pfwInterfaceObjAndStateGetViaStackObj(pComponentState->stackObj, id, &pStackData->adapterStatisticsInterface) != OK) pStackData->adapterStatisticsInterface.interfaceObj = NULL; } if ((id = pfwInterfaceIdGet(pComponentState->pluginObj->pfwObj, "PPP_LINK_STATUS_ENTRY_INTERFACE")) > 0) { if (pfwInterfaceObjAndStateGetViaStackObj(pComponentState->stackObj, id, &pStackData->pppLinkStatusEntryInterface) != OK) pStackData->pppLinkStatusEntryInterface.interfaceObj = NULL;#ifdef PPP_DEBUG logMsg("PPP: radiusStackAdd: PPP_LINK_STATUS_ENTRY_INTERFACE not found\n",1,2,3,4,5,6);#endif /* PPP_DEBUG */ } if (pStackData->callbacks && pStackData->callbacks->stackAddComplete) { (*pStackData->callbacks->stackAddComplete) (pStackData->callbacks, pComponentState); return OK; } else return ERROR; }/******************************************************************************** radiusStackDelete - Delete RADIUS component from the stack***/LOCAL STATUS radiusStackDelete ( PFW_PLUGIN_OBJ_STATE * pComponentState ) { RADIUS_STACK_DATA * pStackData; pStackData = (RADIUS_STACK_DATA *) pComponentState->stackData; if (pStackData->physicalPortInterface.interfaceObj != NULL) pfwInterfaceReferenceDelete(pStackData->physicalPortInterface.interfaceObj); if (pStackData->adapterStatisticsInterface.interfaceObj != NULL) pfwInterfaceReferenceDelete(pStackData->adapterStatisticsInterface.interfaceObj); if (pStackData->pppIpRoutesInterface.interfaceObj != NULL) pfwInterfaceReferenceDelete (pStackData->pppIpRoutesInterface.interfaceObj); if (pStackData->pppLinkStatusEntryInterface.interfaceObj != NULL) pfwInterfaceReferenceDelete (pStackData->pppLinkStatusEntryInterface.interfaceObj); if (pfwPluginObjStateLock (pComponentState) == ERROR) { logMsg("radiusStackDelete - unable to lock state\n", 0, 0, 0, 0, 0, 0 ); return ERROR; } if (!(pStackData->radiusState & RADIUS_ACCT_ERROR) && (pStackData->radiusState & (RADIUS_PAP_AUTH_PENDING | RADIUS_CHAP_AUTH_PENDING | RADIUS_ACCT_START_PENDING | RADIUS_ACCT_STOP_PENDING))) { /* * Some request outstanding. Mark this for deletion. * This will be deleted later by RADIUS client callbacks */ pStackData->radiusState |= RADIUS_STACK_DEL_PENDING; pfwPluginObjStateRelease (pComponentState); return OK; } pfwPluginObjStateRelease (pComponentState); if (pStackData->callbacks && pStackData->callbacks->stackDeleteComplete) { (*pStackData->callbacks->stackDeleteComplete) (pStackData->callbacks ,pComponentState); return OK; } else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -