?? pppradiuscomponent.c
字號:
/* pppRadiusComponent.c - RADIUS Component *//* Copyright 1999 - 2006 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01s,22mar06,rpb Coverity bugs fix, SPR 119177, Pointer "str" dereferenced before NULL check01r,22feb06,rb Fix for SPR 117974: Build error when IPv6 not defined01q,10feb06,snd Fixed bug during Spring 06 testing01p,12dec05,snd Added changes for RFC update to 2865/286601o,30aug05,snd Added Changes for IPv6 support01n,25feb05,ijm Moved to radius directory; changed path for header files01m,17feb05,snd Changed radiusProcessAttributes() to check for return value radius_util_deserialize_ulong() and return error. This is to fix coverity bug 44 for SPR 102988. Changed radiusChapAuthAcceptCallback to use chap data structure only after chap == NULL check is done. This is to fix coverity bug 67 for SPR 102988. Changed radiusPapAuthAcceptCallback to use pap data structure only after pap == NULL check is done. This is to fix coverity bug 70 for SPR 102988.01l,03feb05,snd Change copyright to 200501k,26nov04,snd Base6 porting effort, fixed errors due to type mismatches01j,18oct04,ijm fixed compilation warnings01i,20jun04,snd Bug fix for SPR 97527. Memory leak in radiusStackDataDestruct01h,26feb02,md Bug fix - changes to radiusState to wait for outstanding request to clear before destroying PPP stack.01g,26feb02,md Fix TSR#267405 - rfc2138 said that it's ok to have no attributes returned from the RADIUS server on access accept01f,02oct01,md initial version of T3 and remove warnings01e,28aug01,md change radiusState before processing RADIUS packets in radiusPapAuthAcceptCallback and radiusChapAuthAcceptCallback01d,05jan01,sj wrap debug logMsgs with PPP_DEBUG01c,03aug00,adb exec radiusSendRequest in netTask context"01b,27jul00,sj use PPP_IP_ROUTES_INTERFACE also no htonl() as inet_addr does it01a,18jul00,bsn fixes from the openstack branch*//*DESCRIPTIONThis module implements the RADIUS support for PPP.INCLUDE FILES: pppRadiusComponent.h*/#include "pppRadiusComponent.h"#include "private/pppRadiusComponentP.h"#include "vpn_interface.h"#include "pppRadiusSessionMgrIf.h"#include "pppLacLayerInterface.h"#ifdef INET6#include <sockLib.h>#endif /* INET6 *//* defines *//* typedefs *//* externs *//* locals and forwards */int routec ( char * paramString);LOCAL void radiusClearPapData(PAP_AUTHENTICATION_DATA *);LOCAL void radiusClearChapData(CHAP_AUTHENTICATION_DATA *);LOCAL void radiusClearRcvdAttr(RADIUS_RECEIVED_ATTRIBUTES *);LOCAL void radiusClearAcctData(ACCOUNTING_DATA *);LOCAL void radiusClearServerData(RADIUS_SERVER_DATA *);LOCAL void radiusDestroyStackData(RADIUS_STACK_DATA *);LOCAL void radiusProcessServerConfig(char *, RADIUS_SERVER_DATA *, PFW_OBJ *);LOCAL void radiusProcessFramedRoute(char *, RADIUS_RECEIVED_ATTRIBUTES *, PFW_OBJ *);#ifdef INET6LOCAL void radiusProcessFramedIPv6Route(char *, RADIUS_RECEIVED_ATTRIBUTES *, PFW_OBJ *);#endif /* INET6 */LOCAL STATUS radiusProcessAttributes(RADIUS_ATTRIBUTE_LIST_HANDLE , RADIUS_STACK_DATA *, PFW_PLUGIN_OBJ_STATE *, BOOLEAN *);LOCAL RADIUS_SERVER_HANDLE get_radius_server(RADIUS_SERVER_DATA *, enum RADIUS_SERVER_TYPE);LOCAL void radiusAcctErrorCallback (int ,int ,int ,int ,int);LOCAL void radiusSendRequest (int ,int ,int ,int ,int); /* component interface */LOCAL STATUS radiusProfileDataConstruct (PFW_OBJ *, void * profileData);LOCAL STATUS radiusProfileDataCopy (PFW_OBJ *,void * srcProfile, void * dstProfile);LOCAL STATUS radiusProfileDataDestruct (PFW_OBJ *, void * profileData);LOCAL STATUS radiusStackDataConstruct (PFW_OBJ *, void * stackData, void * profileData);LOCAL STATUS radiusStackDataDestruct (PFW_OBJ *,void * stackData, void * profileData);LOCAL STATUS radiusInterfaceBind ( PFW_PLUGIN_OBJ * pluginObj);LOCAL STATUS radiusStackAdd (PFW_PLUGIN_OBJ_STATE *,PFW_PLUGIN_OBJ_CALLBACKS *);LOCAL STATUS radiusStackDelete (PFW_PLUGIN_OBJ_STATE *);LOCAL STATUS radiusStackDataShow (PFW_PLUGIN_OBJ_STATE *); /* parameter handlers */LOCAL STATUS radius_serviceType (PFW_OBJ *pfw, PFW_PARAMETER_OPERATION_TYPE opertype, void *pData, char *value);LOCAL STATUS radius_authenticationServer ( PFW_OBJ *pfw, PFW_PARAMETER_OPERATION_TYPE opertype, void *pData, char *value);LOCAL STATUS radius_accountingServer ( PFW_OBJ *pfw, PFW_PARAMETER_OPERATION_TYPE opertype, void *pData, char *value);LOCAL STATUS radius_nasIPaddress ( PFW_OBJ *pfw, PFW_PARAMETER_OPERATION_TYPE opertype, void *pData, char *value);LOCAL STATUS radius_nasIdentifier ( PFW_OBJ *pfw, PFW_PARAMETER_OPERATION_TYPE opertype, void *pData, char *value);#ifdef INET6LOCAL STATUS radius_nasIPv6address ( PFW_OBJ *pfw, PFW_PARAMETER_OPERATION_TYPE opertype, void *pData, char *value);#endifLOCAL STATUS radius_authenticationServer_retries ( PFW_OBJ *pfw, PFW_PARAMETER_OPERATION_TYPE opertype, void *pData, char *value);LOCAL STATUS radius_accountingServer_retries ( PFW_OBJ *pfw, PFW_PARAMETER_OPERATION_TYPE opertype, void *pData, char *value);LOCAL STATUS radius_stringProfileHandler ( PFW_OBJ * pfw, PFW_PARAMETER_OPERATION_TYPE opertype, char **pConfigString, char *value);LOCAL STATUS radius_longProfileHandler ( PFW_OBJ * pfw, PFW_PARAMETER_OPERATION_TYPE opertype, ULONG *pConfigData, char *value); /* published interface */LOCAL void challengeAuthVerify ( PFW_PLUGIN_OBJ_STATE * state, char * userName, char * response, unsigned int responseLen, char * challenge, unsigned int challengeLen, BYTE id, CHALLENGE_AUTH_METHOD method, REMOTE_AUTHENTICATION_CALLBACKS * radiusCallbacks);LOCAL void passwordAuthVerify ( PFW_PLUGIN_OBJ_STATE * state, char * userName, char * password, BYTE id, REMOTE_AUTHENTICATION_CALLBACKS * radiusCallbacks);LOCAL void accountingStart ( PFW_PLUGIN_OBJ_STATE * state);LOCAL void accountingStop ( PFW_PLUGIN_OBJ_STATE * state);LOCAL PPP_CONTROL_PHASE radius_pppPhaseGet ();LOCAL PPP_STATE radius_pppStateGet (PFW_PLUGIN_OBJ_STATE *);LOCAL void radius_pppStateMachine (PFW_PLUGIN_OBJ_STATE * pluginState, PPP_EVENT ppp_event, M_BLK_ID pMblk); /* Radius Client Callbacks */LOCAL void radiusClientPapAuthNormalCallback(RADIUS_REQUEST_HANDLE, enum RADIUS_CODE, RADIUS_ATTRIBUTE_LIST_HANDLE);LOCAL void radiusClientPapAuthErrorCallback(RADIUS_REQUEST_HANDLE, enum RADIUS_ERROR_CALLBACK_CODE);LOCAL void radiusClientChapAuthNormalCallback(RADIUS_REQUEST_HANDLE, enum RADIUS_CODE, RADIUS_ATTRIBUTE_LIST_HANDLE);LOCAL void radiusClientChapAuthErrorCallback(RADIUS_REQUEST_HANDLE, enum RADIUS_ERROR_CALLBACK_CODE);LOCAL void radiusClientAcctNormalCallback(RADIUS_REQUEST_HANDLE, enum RADIUS_CODE, RADIUS_ATTRIBUTE_LIST_HANDLE);LOCAL void radiusClientAcctErrorCallback(RADIUS_REQUEST_HANDLE, enum RADIUS_ERROR_CALLBACK_CODE);LOCAL void radiusPapAuthAcceptCallback(void *);LOCAL void radiusPapAuthFailureCallback(void *);LOCAL void radiusPapAuthErrorCallback(void *);LOCAL void radiusChapAuthAcceptCallback(void *);LOCAL void radiusChapAuthFailureCallback(void *);LOCAL void radiusChapAuthErrorCallback(void *);LOCAL void radiusAcctNormalCallback(void *); /* IPCP Event handlers */LOCAL STATUS radiusIpcpUpEventHandler(PFW_PLUGIN_OBJ_STATE *, void *);LOCAL STATUS radiusIpcpDownEventHandler(PFW_PLUGIN_OBJ_STATE *, void *);#ifdef INET6LOCAL STATUS radiusIpv6cpUpEventHandler(PFW_PLUGIN_OBJ_STATE *, void *);LOCAL STATUS radiusIpv6cpDownEventHandler(PFW_PLUGIN_OBJ_STATE *, void *);#endif /* INET6 */ /* IPCP configuration profiles */LOCAL char enableLocalVJ[] = "Local:Negotiation Required,Not Negotiable:002D0F01";LOCAL char enableRemoteVJ[] = "Remote:Negotiation Required,Not Negotiable:002D0F01";LOCAL char disableLocalVJ[] = "Local:";LOCAL char disableRemoteVJ[] = "Remote:";LOCAL char allowUserIPAddress[] = "Remote:Negotiation Required,Negotiable:0";LOCAL char useUserIPAddress[] = "Remote:Negotiation Required,Not Negotiable:";/* globals *//******************************************************************************** radiusComponentCreate - initialize and add RADIUS component to framework** This component implements the RADIUS support for PPP.** RETURNS: OK or ERROR*/STATUS radiusComponentCreate ( PFW_OBJ * pfw /* framework reference */ ) { PPP_RADIUS_COMPONENT * pComponent; PFW_PLUGIN_OBJ * radiusPluginObj; if (pfw == NULL) { return ERROR; } /* allocate the component object */ if ((pComponent = pfwMalloc(pfw,sizeof(PPP_RADIUS_COMPONENT))) == NULL) return ERROR; bzero((void *)pComponent,sizeof(PPP_RADIUS_COMPONENT)); radiusPluginObj = (PFW_PLUGIN_OBJ *)&(pComponent->component); /* initialize our component object */ strcpy (radiusPluginObj->name, "PPP_RADIUS"); radiusPluginObj->pfwObj = pfw; radiusPluginObj->profileDataSize = sizeof (RADIUS_PROFILE_DATA); radiusPluginObj->stackDataSize = sizeof (RADIUS_STACK_DATA); radiusPluginObj->profileDataConstruct = radiusProfileDataConstruct; radiusPluginObj->profileDataCopy = radiusProfileDataCopy; radiusPluginObj->profileDataDestruct = radiusProfileDataDestruct; radiusPluginObj->receive = NULL; radiusPluginObj->send = NULL; radiusPluginObj->stackAdd = radiusStackAdd; radiusPluginObj->stackDelete = radiusStackDelete; radiusPluginObj->stackDataShow = radiusStackDataShow; radiusPluginObj->stackDataConstruct = radiusStackDataConstruct; radiusPluginObj->stackDataDestruct = radiusStackDataDestruct; radiusPluginObj->interfaceBind = radiusInterfaceBind; pComponent->component.protocol = 0xffff; pComponent->component.layerObj = (struct pfwLayerObj *) pfwLayerObjGet (pfw, "CONTROL_LAYER"); if (pfwComponentAdd (&pComponent->component) == ERROR) { logMsg ("radiusComponentCreate - Couldn't add RADIUS to pfw\n", 0, 0, 0, 0, 0, 0); return (ERROR); } /* Add configuration parameters to the framework */ pfwParameterAdd (radiusPluginObj, "radius_serviceType", radius_serviceType); pfwParameterAdd (radiusPluginObj, "radius_authenticationServer", radius_authenticationServer); pfwParameterAdd (radiusPluginObj, "radius_accountingServer", radius_accountingServer); pfwParameterAdd (radiusPluginObj, "radius_nasIPaddress", radius_nasIPaddress); pfwParameterAdd (radiusPluginObj, "radius_nasIdentifier", radius_nasIdentifier);#ifdef INET6 pfwParameterAdd (radiusPluginObj, "radius_nasIPv6address", radius_nasIPv6address);#endif /* INET6 */ pfwParameterAdd (radiusPluginObj, "radius_authenticationServer_retries", radius_authenticationServer_retries); pfwParameterAdd (radiusPluginObj, "radius_accountingServer_retries", radius_accountingServer_retries); return (OK); }/******************************************************************************** radiusComponentDelete - delete the RADIUS component from the framework** The RADIUS plugin object which is allocated by the radiusComponentCreate* is freed if there is no active reference to this object from a stack or* profile object in the framework.** RETURNS: OK or ERROR*/STATUS radiusComponentDelete ( PFW_OBJ *pfw ) { PFW_COMPONENT_OBJ *pComponent; pComponent = pfwComponentObjGetByName (pfw, "PPP_RADIUS"); if (pComponent == NULL) return ERROR; if (pfwComponentDelete (pComponent) == OK) { pfwFree (pComponent); return OK; } return (ERROR); }/******************************************************************************** radiusInterfaceBind -*/LOCAL STATUS radiusInterfaceBind ( PFW_PLUGIN_OBJ * pluginObj ) { PPP_RADIUS_COMPONENT * pComponent = (PPP_RADIUS_COMPONENT *)pluginObj; REMOTE_AUTHENTICATION_INTERFACE * remoteAuthInterface; REMOTE_ACCOUNTING_INTERFACE * remoteAcctInterface; CONTROL_PROTOCOL_INTERFACE * radiusControlInterface; PFW_OBJ * pfw = pluginObj->pfwObj; int i; /* get CONTROL_PROTOCOL_INTERFACE ID and bind to it */ if ((i = pfwInterfaceIdGet(pfw, "CONTROL_PROTOCOL_INTERFACE")) > 0) { radiusControlInterface = &pComponent->radiusControlInterface; radiusControlInterface->interfaceObj.id = i; radiusControlInterface->interfaceObj.pluginObj = pluginObj; radiusControlInterface->pppPhaseGet = radius_pppPhaseGet; radiusControlInterface->pppStateGet = radius_pppStateGet; radiusControlInterface->executeStateMachine = radius_pppStateMachine; pfwInterfaceBind (&radiusControlInterface->interfaceObj); } /* publish and bind our remote authentication interface */ if ((i = pfwInterfaceRegister(pfw, "REMOTE_AUTHENTICATION_INTERFACE")) > 0) { remoteAuthInterface = &pComponent->remoteAuthInterface; remoteAuthInterface->interfaceObj.id = i; remoteAuthInterface->interfaceObj.pluginObj = pluginObj; remoteAuthInterface->challengeAuthVerify = challengeAuthVerify; remoteAuthInterface->passwordAuthVerify = passwordAuthVerify; pfwInterfaceBind (&remoteAuthInterface->interfaceObj); } /* publish and bind our remote accounting interface */ if ((i = pfwInterfaceRegister(pfw, "REMOTE_ACCOUNTING_INTERFACE")) > 0) { remoteAcctInterface = &pComponent->remoteAcctInterface; remoteAcctInterface->interfaceObj.id = i; remoteAcctInterface->interfaceObj.pluginObj = pluginObj; remoteAcctInterface->accountingStart = accountingStart; remoteAcctInterface->accountingStop = accountingStop; pfwInterfaceBind (&remoteAcctInterface->interfaceObj); } return (OK); }/******************************************************************************** radiusProfileDataConstruct - initialize RADIUS profile data***/LOCAL STATUS radiusProfileDataConstruct ( PFW_OBJ * pfw, void * pData ) { RADIUS_PROFILE_DATA * pProfileData = (RADIUS_PROFILE_DATA *) pData; bzero(pData, sizeof(RADIUS_PROFILE_DATA)); /* Set default values */ radius_serviceType(pfw, PFW_PARAMETER_SET, pProfileData, "Auth"); radius_authenticationServer(pfw, PFW_PARAMETER_SET, pProfileData, "ALL"); radius_accountingServer(pfw, PFW_PARAMETER_SET, pProfileData, "ALL"); radius_authenticationServer_retries(pfw, PFW_PARAMETER_SET, pProfileData, "5"); radius_accountingServer_retries(pfw, PFW_PARAMETER_SET, pProfileData, "5"); return OK; }/******************************************************************************** radiusProfileDataCopy - profileData object copy constructor**
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -