⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pppradiuscomponent.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* pppRadiusComponent.c - RADIUS Component *//* Copyright 1999 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01h,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 FILES: pppRadiusComponentP.h */#include "ppp/pppRadiusComponent.h"#include "private/ppp/pppRadiusComponentP.h"/* defines *//* typedefs *//* externs *//* locals and forwards */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 *);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);LOCAL 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 *);    /* 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);    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***/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)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -