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

📄 pppinterfacelayer.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	   break;       }   if (iflProtocolItem == NULL || protocol == 0x0)       {#ifdef PPP_DEBUG       printf  ("PPP: Unknown Protocol 0x%x rejected\n",(int)protocol);#endif /* PPP_DEBUG */       lcpPacketSendInterface->lcpProtocolRejectSend(				   pStackData->lcpPacketSend.state, *packet);       return (ERROR);       }   return (*iflProtocolItem->state->pluginObj->receive) (iflProtocolItem->state,						       packet);   }/********************************************************************************* interfaceLayerStackAdd -*/LOCAL STATUS interfaceLayerStackAdd    (    PFW_PLUGIN_OBJ_STATE *state,    PFW_PLUGIN_OBJ_CALLBACKS * callbacks    )    {    int id;    PFW_STACK_OBJ * stackObj = state->stackObj;    PFW_PLUGIN_OBJ_STATE *componentState;    INTERFACE_LAYER_STACK_DATA *pStackData = 			(INTERFACE_LAYER_STACK_DATA *)state->stackData;    pStackData->callbacks = callbacks;    if ((id = pfwInterfaceIdGet(state->pluginObj->pfwObj,				"LCP_PACKET_SEND_INTERFACE")) > 0)	{	if (pfwInterfaceObjAndStateGetViaStackObj(state->stackObj,				    id, &pStackData->lcpPacketSend) != OK)	    return ERROR;	}    else	return ERROR;    if ((componentState = pfwFirstComponentStateGet (state)) == NULL)	{        pfwPrintError (__FILE__, "interfaceLayerStackAdd", __LINE__,                        0,stackObj, "Null component");        return (ERROR);        }    pStackData->lastAddedComponent = componentState;    return ((*componentState->pluginObj->stackAdd)(componentState,		&pStackData->componentCallbacks));    }/********************************************************************************* componentStackAddDone -*/LOCAL void componentStackAddDone    (    PFW_PLUGIN_OBJ_CALLBACKS * componentCallbacks,    PFW_PLUGIN_OBJ_STATE *componentState    )    {    ACCEPTABLE_PROTOCOLS_ARRAY *recvProtocols;    ACCEPTABLE_PROTOCOLS_ARRAY *sendProtocols;    PFW_PLUGIN_OBJ_STATE *nextComponentState;    unsigned int interfaceId;    IFL_PROTOCOL_ITEM * iflRecvProtocolItem;    IFL_PROTOCOL_ITEM * iflSendProtocolItem;    PFW_PLUGIN_OBJ_STATE *layerState;    PFW_INTERFACE_OBJ *interfaceObj;    COMPONENT_ACCEPTABLE_PROTOCOLS_INTERFACE                *componentAcceptableProtocolsInterface;    INTERFACE_LAYER_STACK_DATA *pStackData;    if ((layerState = pfwLayerStateGet(componentState)) == NULL)	 {	 printf ("NULL interface layer state\n");         return;	 }    pStackData = (INTERFACE_LAYER_STACK_DATA *)layerState->stackData;    interfaceId = pfwInterfaceIdGet (componentState->pluginObj->pfwObj, 				"COMPONENT_ACCEPTABLE_PROTOCOLS_INTERFACE");    if (interfaceId == 0)	{	pfwPrintError (__FILE__, "componentStackAddDone", __LINE__, NULL,	     componentState->stackObj, "interface could not be found");	return;	}    if (componentState != NULL)        {        interfaceObj = pfwInterfaceObjGetViaPluginObj (			componentState->pluginObj, interfaceId);        if (interfaceObj == NULL)            {            pfwPrintError (__FILE__, "componentStackAddDone", __LINE__, NULL,                 componentState->stackObj, "interface could not find");            return;            }	}    else	return;    /* add this component to the appropriate list */    if ((iflRecvProtocolItem = (IFL_PROTOCOL_ITEM *)pfwMalloc        (componentState->pluginObj->pfwObj,sizeof(IFL_PROTOCOL_ITEM))) == NULL)        {        printf ("PPP: could not allocate memory for new protocol Item\n");        return ;        }    if ((iflSendProtocolItem = (IFL_PROTOCOL_ITEM *)pfwMalloc        (componentState->pluginObj->pfwObj,sizeof(IFL_PROTOCOL_ITEM))) == NULL)        {        printf ("PPP: could not allocate memory for new protocol Item\n");        return ;        }    iflRecvProtocolItem->next = NULL;    iflRecvProtocolItem->state = componentState;    iflSendProtocolItem->next = NULL;    iflSendProtocolItem->state = componentState;    componentAcceptableProtocolsInterface = 		(COMPONENT_ACCEPTABLE_PROTOCOLS_INTERFACE *) interfaceObj;    /* Get the protocols from the VJC component */    (*componentAcceptableProtocolsInterface->receivePathAcceptableProtocolsGet)			(componentState, &recvProtocols);    (*componentAcceptableProtocolsInterface->sendPathAcceptableProtocolsGet)			(componentState, &sendProtocols);    iflRecvProtocolItem->acceptableProtocols = recvProtocols;    iflSendProtocolItem->acceptableProtocols = sendProtocols;    sllPutAtTail ((SL_LIST *)&pStackData->recvAcceptableProtocols, 			(SL_NODE *)iflRecvProtocolItem);    sllPutAtTail ((SL_LIST *)&pStackData->sendAcceptableProtocols, 			(SL_NODE *)iflSendProtocolItem);    /* Release the VJC acceptableProtocols Interface */    pfwInterfaceReferenceDelete (interfaceObj);    /*     * 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;        }    /* Call the next component stackAdd routine */    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);    }/******************************************************************************** deleteIflProtocolItem -*/LOCAL STATUS deleteIflProtocolItem    (    SL_LIST * acceptableProtocols,    PFW_PLUGIN_OBJ_STATE *componentState    )    {    IFL_PROTOCOL_ITEM * iflProtocolItem;    IFL_PROTOCOL_ITEM * iflProtocolItemToDelete;    iflProtocolItem = (IFL_PROTOCOL_ITEM *)                SLL_FIRST(acceptableProtocols);    if (iflProtocolItem == NULL)        return ERROR;    /* if protocol item is head of the list */    if (iflProtocolItem->state == componentState)        {        sllRemove(acceptableProtocols,(SL_NODE *)iflProtocolItem,NULL);        iflProtocolItemFree(iflProtocolItem,0);        return OK;        }    while (iflProtocolItem->next != NULL &&           iflProtocolItem->next->state != componentState)        {        iflProtocolItem = (IFL_PROTOCOL_ITEM *)SLL_NEXT(iflProtocolItem);        }    if (iflProtocolItem->next == NULL)        return ERROR;    iflProtocolItemToDelete = iflProtocolItem->next;    sllRemove(acceptableProtocols,(SL_NODE *)iflProtocolItem->next,                            (SL_NODE *)iflProtocolItem);    iflProtocolItemFree(iflProtocolItemToDelete,0);    return OK;    }/********************************************************************************* componentStackDelDone -*/LOCAL void componentStackDelDone    (    PFW_PLUGIN_OBJ_CALLBACKS * componentCallbacks,    PFW_PLUGIN_OBJ_STATE *componentState    )    {    PFW_PLUGIN_OBJ_STATE *nextComponentState;    PFW_PLUGIN_OBJ_STATE *layerState;    INTERFACE_LAYER_STACK_DATA * pStackData;    if ((layerState = pfwLayerStateGet(componentState)) == NULL)	return;    pStackData = (INTERFACE_LAYER_STACK_DATA *)layerState->stackData;    if (pStackData->lastDeletedComponent != componentState)        {        deleteIflProtocolItem (&pStackData->recvAcceptableProtocols,                               componentState);        deleteIflProtocolItem (&pStackData->sendAcceptableProtocols,                               componentState);        if (pStackData->callbacks && pStackData->callbacks->stackDeleteComplete)            (*pStackData->callbacks->stackDeleteComplete)                                    (pStackData->callbacks ,componentState);        return ;        }    /* Call the next component stackDelete routine */    if ((nextComponentState = pfwNextComponentStateGet(componentState)) == NULL)        {	/* Release interfaces */		if (pStackData->lcpPacketSend.interfaceObj != NULL)	    pfwInterfaceReferenceDelete(		(PFW_INTERFACE_OBJ *)pStackData->lcpPacketSend.interfaceObj);	pStackData->lastDeletedComponent = NULL;        if (pStackData->callbacks && pStackData->callbacks->stackDeleteComplete)            (*pStackData->callbacks->stackDeleteComplete)                                    (pStackData->callbacks , layerState);	return;        }      pStackData->lastDeletedComponent = nextComponentState;    (*nextComponentState->pluginObj->stackDelete) (nextComponentState);    }/******************************************************************************** iflProtocolItemFree -*/LOCAL BOOLEAN iflProtocolItemFree    (    IFL_PROTOCOL_ITEM * iflProtocolItem,    int arg    )    {    pfwFree((void *)iflProtocolItem);    return TRUE;    }

⌨️ 快捷键说明

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