📄 pppnetworklayer.c
字号:
nlProtocolItem = (NL_PROTOCOL_ITEM *) SLL_FIRST(&pStackData->sendAcceptableProtocols); while (nlProtocolItem != NULL) { componentObj = (PFW_COMPONENT_OBJ *)nlProtocolItem->state->pluginObj; for (i = 0; i < nlProtocolItem->acceptableProtocols->numberOfProtocols; i++) { if (nlProtocolItem->acceptableProtocols->protocols[i] == protocol) { found = TRUE;#ifdef PPP_DEBUG printf ("Tx proto = 0x%x ", nlProtocolItem->acceptableProtocols->protocols[i]);#endif /* PPP_DEBUG */ break; } } if (found == TRUE) break; else nlProtocolItem = (NL_PROTOCOL_ITEM *)SLL_NEXT(nlProtocolItem); } if (nlProtocolItem == NULL) { if (protocolIsInDefaultList (protocol) == TRUE) {#ifdef PPP_DEBUG printf ("Tx proto = 0x%x ", protocol);#endif /* PPP_DEBUG */ return (OK); } printf ("PPP: Unknown Protocol 0x%x rejected\n",(int)protocol); netMblkClChainFree(*packet); return (ERROR); } return (*nlProtocolItem->state->pluginObj->send) (nlProtocolItem->state, packet); }/********************************************************************************* networkLayerStackAdd -*/LOCAL STATUS networkLayerStackAdd ( PFW_PLUGIN_OBJ_STATE *state, PFW_PLUGIN_OBJ_CALLBACKS * callbacks ) { int id; PFW_STACK_OBJ * stackObj = state->stackObj; PFW_PLUGIN_OBJ_STATE *componentState; NETWORK_LAYER_STACK_DATA *pStackData = (NETWORK_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__, "networkLayerStackAdd", __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; NL_PROTOCOL_ITEM * nlRecvProtocolItem; NL_PROTOCOL_ITEM * nlSendProtocolItem; PFW_PLUGIN_OBJ_STATE *layerState; PFW_INTERFACE_OBJ *interfaceObj; COMPONENT_ACCEPTABLE_PROTOCOLS_INTERFACE *componentAcceptableProtocolsInterface; NETWORK_LAYER_STACK_DATA *pStackData; if ((layerState = pfwLayerStateGet(componentState)) == NULL) { printf ("NULL network layer state\n"); return; } pStackData = (NETWORK_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 ((nlRecvProtocolItem = (NL_PROTOCOL_ITEM *)pfwMalloc (componentState->pluginObj->pfwObj,sizeof(NL_PROTOCOL_ITEM))) == NULL) { printf ("PPP: could not allocate memory for new protocol Item\n"); return ; } if ((nlSendProtocolItem = (NL_PROTOCOL_ITEM *)pfwMalloc (componentState->pluginObj->pfwObj,sizeof(NL_PROTOCOL_ITEM))) == NULL) { printf ("PPP: could not allocate memory for new protocol Item\n"); return ; } nlRecvProtocolItem->next = NULL; nlRecvProtocolItem->state = componentState; nlSendProtocolItem->next = NULL; nlSendProtocolItem->state = componentState; componentAcceptableProtocolsInterface = (COMPONENT_ACCEPTABLE_PROTOCOLS_INTERFACE *) interfaceObj; /* Get the protocols from the VJC component */ (*componentAcceptableProtocolsInterface->receivePathAcceptableProtocolsGet) (componentState, &recvProtocols); (*componentAcceptableProtocolsInterface->sendPathAcceptableProtocolsGet) (componentState, &sendProtocols); nlRecvProtocolItem->acceptableProtocols = recvProtocols; nlSendProtocolItem->acceptableProtocols = sendProtocols; sllPutAtTail ((SL_LIST *)&pStackData->recvAcceptableProtocols, (SL_NODE *)nlRecvProtocolItem); sllPutAtTail ((SL_LIST *)&pStackData->sendAcceptableProtocols, (SL_NODE *)nlSendProtocolItem); /* 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) { if (pStackData->callbacks &&pStackData->callbacks->stackAddComplete) { (*pStackData->callbacks->stackAddComplete) (pStackData->callbacks, layerState); return; } } pStackData->lastAddedComponent = nextComponentState; (*nextComponentState->pluginObj->stackAdd)(nextComponentState, &pStackData->componentCallbacks); }/******************************************************************************** deleteNlProtocolItem -*/LOCAL STATUS deleteNlProtocolItem ( SL_LIST * acceptableProtocols, PFW_PLUGIN_OBJ_STATE *componentState ) { NL_PROTOCOL_ITEM * nlProtocolItem; NL_PROTOCOL_ITEM * nlProtocolItemToDelete; nlProtocolItem = (NL_PROTOCOL_ITEM *) SLL_FIRST(acceptableProtocols); if (nlProtocolItem == NULL) return ERROR; /* if protocol item is head of the list */ if (nlProtocolItem->state == componentState) { sllRemove(acceptableProtocols,(SL_NODE *)nlProtocolItem,NULL); nlProtocolItemFree(nlProtocolItem,0); return OK; } while (nlProtocolItem->next != NULL && nlProtocolItem->next->state != componentState) { nlProtocolItem = (NL_PROTOCOL_ITEM *)SLL_NEXT(nlProtocolItem); } if (nlProtocolItem->next == NULL) return ERROR; nlProtocolItemToDelete = nlProtocolItem->next; sllRemove(acceptableProtocols,(SL_NODE *)nlProtocolItem->next, (SL_NODE *)nlProtocolItem); nlProtocolItemFree(nlProtocolItemToDelete,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; NETWORK_LAYER_STACK_DATA * pStackData; if ((layerState = pfwLayerStateGet(componentState)) == NULL) return; pStackData = (NETWORK_LAYER_STACK_DATA *)layerState->stackData; if (pStackData->lastDeletedComponent != componentState) { deleteNlProtocolItem (&pStackData->recvAcceptableProtocols, componentState); deleteNlProtocolItem (&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) { pStackData->lastDeletedComponent = NULL; if (pStackData->callbacks && pStackData->callbacks->stackDeleteComplete) (*pStackData->callbacks->stackDeleteComplete) (pStackData->callbacks , layerState); return; } pStackData->lastDeletedComponent = nextComponentState; (*nextComponentState->pluginObj->stackDelete) (nextComponentState); }/******************************************************************************** componentStackDynamicAdd -*/LOCAL STATUS componentStackDynamicAdd ( PFW_PLUGIN_OBJ_STATE *layerState, PFW_PLUGIN_OBJ_STATE *componentState ) { NETWORK_LAYER_STACK_DATA * pStackData; pStackData = (NETWORK_LAYER_STACK_DATA *)layerState->stackData; /* start the protocol */ return((*componentState->pluginObj->stackAdd)(componentState, &pStackData->componentCallbacks)); }/******************************************************************************** componentStackDynamicDel -*/LOCAL STATUS componentStackDynamicDel ( PFW_PLUGIN_OBJ_STATE *layerState, PFW_PLUGIN_OBJ_STATE *componentState ) { NETWORK_LAYER_STACK_DATA * pStackData; pStackData = (NETWORK_LAYER_STACK_DATA *)layerState->stackData; /* delete the protocol */ return((*componentState->pluginObj->stackDelete)(componentState)); }/******************************************************************************** nlProtocolItemFree -*/LOCAL BOOLEAN nlProtocolItemFree ( NL_PROTOCOL_ITEM * nlProtocolItem, int arg ) { pfwFree((void *)nlProtocolItem); return TRUE; }/***************************************************************************** protocolIsInDefaultList - check if protocol is in default acceptable protocols* list**/LOCAL BOOL protocolIsInDefaultList ( USHORT protocol ) { int i; for (i = 0; i < nlDefaultRecvAcceptableProtocols.numberOfProtocols; ++i) { if (nlDefaultRecvAcceptableProtocols.protocols[i] == protocol) return TRUE; } return FALSE; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -