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

📄 pppcontrollayer.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
    memset(pData,0,sizeof(CONTROL_LAYER_PROFILE_DATA));    pProfileData->secretsDatabase = LOCAL_SECRETS_DATABASE;    return OK;    }/******************************************************************************** controlLayerStackDataConstruct -*/LOCAL STATUS controlLayerStackDataConstruct    (    PFW_OBJ * pfw,    void * stackData,    void * profileData    )    {    unsigned int i;    CONTROL_LAYER_STACK_DATA * pStackData = 			    (CONTROL_LAYER_STACK_DATA * )stackData;    memset(stackData,0,sizeof(CONTROL_LAYER_STACK_DATA));        pStackData->proxyAuthenAttributes = NULL;	pStackData->networkPhaseUpEvent = NULL;    pStackData->phase = DEAD_PHASE;    pStackData->adminState = CLOSED;    pStackData->numberOfAuthenticationsRequired = 0;    pStackData->numberOfNetworkPhaseProtocols = 0;    pStackData->componentCallbacks.stackAddComplete = componentStackAddDone;    pStackData->componentCallbacks.stackDeleteComplete = componentStackDelDone;    for (i = DEAD_PHASE; i < TOTAL_PPP_CONTROL_PHASES; i++)	{	sllInit (&pStackData->protocols[i]);	}    if ((pStackData->lcpOpenEvent = pfwEventObjGet(pfw,"LCP_OPEN_EVENT"))==NULL)	{	return ERROR;	}    if ((pStackData->lcpDownEvent = pfwEventObjGet(pfw,"LCP_DOWN_EVENT"))==NULL)	{	return ERROR;	}    if ((pStackData->lcpCloseEvent = pfwEventObjGet(pfw,"LCP_CLOSE_EVENT"))==NULL)        {        return ERROR;        }/* WindNet Multilink */    if ((pStackData->pAuthUpEventObj = pfwEventObjGet(pfw,											"PPP_AUTH_SUCCESSFUL_EVENT"))==NULL)	{	pfwPrintError (__FILE__, "controlLayerStackDataConstruct", __LINE__,			pfw,0, "NO PPP_AUTH_SUCCESSFUL_EVENT");	return ERROR;	}    if ((pStackData->pAuthDownEventObj = pfwEventObjGet(pfw,											"PPP_AUTH_UNSUCCESSFUL_EVENT"))==NULL)        {												pfwPrintError (__FILE__, "controlLayerStackDataConstruct", __LINE__,			pfw,0, "NO PPP_AUTH_UNSUCCESSFUL_EVENT");	return ERROR;	}	    if ((pStackData->pppLinkResetEvent = pfwEventObjGet(pfw,											"PPP_LINK_RESET_EVENT"))==NULL)	{	pfwPrintError (__FILE__, "controlLayerStackDataConstruct", __LINE__,			pfw,0, "NO PPP_LINK_RESET_EVENT");	return ERROR;	}/* WindNet Multilink */    return OK;    }/******************************************************************************** controlLayerStackDataDestruct -*/LOCAL STATUS controlLayerStackDataDestruct    (    PFW_OBJ * pfw,    void * stackData,    void * profileData    )    {    unsigned int i;    CONTROL_LAYER_STACK_DATA * pStackData = 			    (CONTROL_LAYER_STACK_DATA * )stackData;    if (pStackData->proxyAuthenAttributes != NULL)        {        pfwFree (pStackData->proxyAuthenAttributes);        pStackData->proxyAuthenAttributes = NULL;        }	    for (i = DEAD_PHASE; i < TOTAL_PPP_CONTROL_PHASES; i++)	{	sllEach (&pStackData->protocols[i],clProtocolItemFree,0);	}    return OK;    }/******************************************************************************** controlLayerStackAdd -*/LOCAL STATUS controlLayerStackAdd         (    PFW_PLUGIN_OBJ_STATE *state,    PFW_PLUGIN_OBJ_CALLBACKS * callbacks    )    {    PFW_PLUGIN_OBJ_STATE *firstComponentState = NULL;    PFW_STACK_OBJ * stackObj = state->stackObj;    CONTROL_LAYER_STACK_DATA *pStackData =				(CONTROL_LAYER_STACK_DATA *)state->stackData;    pStackData->callbacks = callbacks;    if ((pStackData->interfaceUpEvent = pfwEventObjGet(state->pluginObj->pfwObj,					    "PPP_INTERFACE_UP_EVENT")) == NULL)	{	printf ("PPP: no PPP_INTERFACE_UP_EVENT\n");	}    else	pfwEventStackSubscribe (state,pStackData->interfaceUpEvent,					      interfaceUpEventHandler);    if ((pStackData->interfaceDownEvent=pfwEventObjGet(state->pluginObj->pfwObj,					    "PPP_INTERFACE_DOWN_EVENT")) ==NULL)	{	printf ("PPP: no PPP_INTERFACE_DOWN_EVENT\n");	}    else	pfwEventStackSubscribe (state,pStackData->interfaceDownEvent, 					      interfaceDownEventHandler);    if ((firstComponentState = pfwFirstComponentStateGet (state)) == NULL)	{	pfwPrintError (__FILE__, "controlLayerStackAdd", __LINE__,			0,stackObj, "Null component");	return (ERROR);	}    /* start first component */    pStackData->lastAddedComponent = firstComponentState;    return ((*firstComponentState->pluginObj->stackAdd)(firstComponentState,					    &pStackData->componentCallbacks));    }/******************************************************************************** componentStackAddDone -*/LOCAL void componentStackAddDone     (    PFW_PLUGIN_OBJ_CALLBACKS * componentCallbacks,    PFW_PLUGIN_OBJ_STATE *componentState    )    {    char s[80];    PFW_PLUGIN_OBJ_STATE *nextComponentState;    PFW_PLUGIN_OBJ_STATE *layerState;    CONTROL_LAYER_STACK_DATA * pStackData;    CL_PROTOCOL_ITEM * clProtocolItem;    REMOTE_AUTHENTICATION_CALLBACKS *authCallback;    PPP_CONTROL_PHASE phase;    int id;	/* WindNet Multilink - start : component acceptable protocol interface */	PFW_INTERFACE_OBJ 			*interfaceObj = NULL; 	    COMPONENT_ACCEPTABLE_PROTOCOLS_INTERFACE 								*componentAcceptableProtocolsInterface = NULL;    ACCEPTABLE_PROTOCOLS_ARRAY 	*recvProtocols;	/* WindNet Multilink - end : component acceptable protocol interface */    if ((layerState = pfwLayerStateGet(componentState)) == NULL)	    return ;    pStackData = (CONTROL_LAYER_STACK_DATA *)layerState->stackData;    /* add this component to the appropriate phase list */    if ((clProtocolItem = (CL_PROTOCOL_ITEM *)pfwMalloc	(componentState->pluginObj->pfwObj,sizeof(CL_PROTOCOL_ITEM))) == NULL)	{	printf("PPP: could not allocate memory for new protocol Item\n");	return ;	}    clProtocolItem->next = NULL;    clProtocolItem->state = componentState;    if ((id = pfwInterfaceIdGet(componentState->pluginObj->pfwObj,					"CONTROL_PROTOCOL_INTERFACE")) == 0)	{	pfwPrintError (__FILE__, "componentStackAddDone", __LINE__, 0,	componentState->stackObj,"No CONTROL_PROTOCOL_INTERFACE published");	return;	}    if ((clProtocolItem->interface = (CONTROL_PROTOCOL_INTERFACE *)	 pfwInterfaceObjGetViaPluginObj(componentState->pluginObj,id)) == NULL)	{	printf ("Control Layer:No CONTROL_PROTOCOL_INTERFACE for protocol 0x%x\n"	 ,((PFW_COMPONENT_OBJ *)componentState->pluginObj)->protocol);	return ;	}	/* WindNet Multilink start : for COMPONENT_ACCEPTABLE_PROTOCOLS_INTERFACE */	/*	 * no validation of interfaceId done here, to facilitate	 * backward compatibility with PPP - WindNet Multilink     */	id = pfwInterfaceIdGet(componentState->pluginObj->pfwObj,					"COMPONENT_ACCEPTABLE_PROTOCOLS_INTERFACE");     if (componentState != NULL)    {        interfaceObj = pfwInterfaceObjGetViaPluginObj (componentState->pluginObj, id);        if (interfaceObj == NULL)        {		    clProtocolItem->acceptableProtocols = NULL;        }		else		{ 				componentAcceptableProtocolsInterface = (COMPONENT_ACCEPTABLE_PROTOCOLS_INTERFACE *) interfaceObj;    		/* Get the protocols from the control components */    		(*componentAcceptableProtocolsInterface->receivePathAcceptableProtocolsGet)				(componentState, &recvProtocols);	    	clProtocolItem->acceptableProtocols = recvProtocols;		    /* release the acceptableProtocols Interface */	    	pfwInterfaceReferenceDelete (interfaceObj);		}	}    else		return;	/* WindNet Multilink end : for COMPONENT_ACCEPTABLE_PROTOCOLS_INTERFACE */    if (((PFW_COMPONENT_OBJ *)componentState->pluginObj)->protocol ==	_LCP_PROTOCOL_)	{	pStackData->lcpProtocolItem = clProtocolItem;	if ((id = pfwInterfaceIdGet(componentState->pluginObj->pfwObj,				    "PPP_LINK_STATUS_ENTRY_INTERFACE")) == 0)	     {	     printf ("Control Layer: Could not get linkStatus interface ID\n");	     return ;	     }	if ((pStackData->pppLinkStatusInterface = 	    (PPP_LINK_STATUS_ENTRY_INTERFACE *) 		pfwInterfaceObjGetViaPluginObj(componentState->pluginObj,id))	    == NULL)	    {	    pfwPrintError (__FILE__, "componentStackAddDone", __LINE__, 0,		componentState->stackObj,"No PPP_LINK_STATUS_ENTRY_INTERFACE!");	    return;	    }	if ((id = pfwInterfaceIdGet(componentState->pluginObj->pfwObj,				    "LCP_EXTENDED_OPTIONS_INTERFACE")) == 0)	     {	     printf ("Control Layer:Could not get extendedOptions interface ID\n");	     return ;	     }	if ((pStackData->lcpExtendedOptions = 	    (LCP_EXTENDED_OPTIONS_INTERFACE *) 		pfwInterfaceObjGetViaPluginObj(componentState->pluginObj,id))	    == NULL)	    {	    pfwPrintError (__FILE__, "componentStackAddDone", __LINE__, 0,		componentState->stackObj,"No LCP_EXTENDED_OPTIONS_INTERFACE!");	    return;	    }	if ((id = pfwInterfaceIdGet(componentState->pluginObj->pfwObj,				"LCP_NEGOTIATED_AUTH_PROTOCOL_INTERFACE")) == 0)	     {	     printf ("Control Layer: Could not get Auth Protocol interface ID\n");	     return ;	     }	if ((pStackData->lcpNegotiatedAuthProtocolInterface = 	    (LCP_NEGOTIATED_AUTH_PROTOCOL_INTERFACE *) 		pfwInterfaceObjGetViaPluginObj(componentState->pluginObj,id))	    == NULL)	    {	    pfwPrintError (__FILE__, "componentStackAddDone", __LINE__, 0,		componentState->stackObj,				"No LCP_NEGOTIATED_AUTH_PROTOCOL_INTERFACE!");	    return;	    }	pStackData->phase = ESTABLISH_PHASE;	}    if (strcmp(componentState->pluginObj->name, "PPP_RADIUS") == 0)	{	pStackData->radiusComponent = componentState;        if ((id = pfwInterfaceIdGet(componentState->pluginObj->pfwObj,				"REMOTE_AUTHENTICATION_INTERFACE")) == 0)	    {	    pfwPrintError (__FILE__, "componentStackAddDone",	          __LINE__, 0, componentState->stackObj,	          "No REMOTE_AUTHENTICATION_INTERFACE published");	    return;	    }	if ((pStackData->remoteAuthInterface = 	        (REMOTE_AUTHENTICATION_INTERFACE *) 		pfwInterfaceObjGetViaPluginObj(componentState->pluginObj,id))	    == NULL)	    {	    pfwPrintError (__FILE__, "componentStackAddDone",	        __LINE__, 0, componentState->stackObj,		"No REMOTE_AUTHENTICATION_INTERFACE!");	    return;	    }        if ((id = pfwInterfaceIdGet(componentState->pluginObj->pfwObj,				"REMOTE_ACCOUNTING_INTERFACE")) == 0)	    {	    pfwPrintError (__FILE__, "componentStackAddDone",	          __LINE__, 0, componentState->stackObj,	          "No REMOTE_ACCOUNTING_INTERFACE published");	    return;	    }	if ((pStackData->remoteAcctInterface = 	        (REMOTE_ACCOUNTING_INTERFACE *) 		pfwInterfaceObjGetViaPluginObj(componentState->pluginObj,id))	    == NULL)	    {	    pfwPrintError (__FILE__, "componentStackAddDone",	        __LINE__, 0, componentState->stackObj,		"No REMOTE_ACCOUNTING_INTERFACE!");	    return;	    }        authCallback = &pStackData->remoteChapCallbacks;        authCallback->authRequestAccepted = remoteChapAcceptedWrapper;        authCallback->authRequestRejected = remoteChapRejectedWrapper;        authCallback->authErrorCallback   = remoteChapErrorWrapper;        authCallback = &pStackData->remotePapCallbacks;        authCallback->authRequestAccepted = remotePapAcceptedWrapper;        authCallback->authRequestRejected = remotePapRejectedWrapper;        authCallback->authErrorCallback   = remotePapErrorWrapper;	}    if ((phase = (*clProtocolItem->interface->pppPhaseGet)()) >= 						    TOTAL_PPP_CONTROL_PHASES)	{        sprintf (s, "protocol: %x has bad phase %d\n",	    ((PFW_COMPONENT_OBJ *)componentState->pluginObj)->protocol,phase);        pfwPrintError (__FILE__, "componentStackAddDone", __LINE__,					componentState->pluginObj->pfwObj,0,s);        return;	}        sllPutAtTail(&pStackData->protocols[phase],(SL_NODE *)clProtocolItem);    /*     * Call the next component stackAdd routine only if we added the last one     * else tell framework via installed callbacks that component add is done     */    if (pStackData->lastAddedComponent != componentState)	{	if(pStackData->callbacks &&pStackData->callbacks->stackAddComplete)	    (*pStackData->callbacks->stackAddComplete)				    (pStackData->callbacks, componentState);	return;	}    if ((nextComponentState = pfwNextComponentStateGet(componentState)) == NULL)	{	pStackData->lastAddedComponent = NULL;	if(pStackData->callbacks &&pStackData->callbacks->stackAddComplete)	    {	    (*pStackData->callbacks->stackAddComplete)				    (pStackData->callbacks, layerState);	    return;	    }	}        pStackData->lastAddedComponent = nextComponentState;    (*nextComponentState->pluginObj->stackAdd)(nextComponentState,					    &pStackData->componentCallbacks);    }/**************

⌨️ 快捷键说明

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