📄 pppcontrollayer.c
字号:
) { unsigned int i; CL_PROTOCOL_ITEM * clProtocolItem; CONTROL_LAYER_STACK_DATA * pStackData = (CONTROL_LAYER_STACK_DATA *)layerState->stackData; if (protocolPhase >= DEAD_PHASE && protocolPhase < TOTAL_PPP_CONTROL_PHASES) { clProtocolItem = (CL_PROTOCOL_ITEM *) SLL_FIRST(&pStackData->protocols[protocolPhase]); while (clProtocolItem != NULL) { if ( ((PFW_COMPONENT_OBJ *)clProtocolItem->state->pluginObj)-> protocol == protocol) { return (clProtocolItem); } clProtocolItem = (CL_PROTOCOL_ITEM *)SLL_NEXT(clProtocolItem); } return NULL; } for (i = DEAD_PHASE; i < TOTAL_PPP_CONTROL_PHASES; i++) { clProtocolItem = (CL_PROTOCOL_ITEM *) SLL_FIRST(&pStackData->protocols[i]); while (clProtocolItem != NULL) { if ( ((PFW_COMPONENT_OBJ *)clProtocolItem->state->pluginObj)-> protocol == protocol) { return (clProtocolItem); } clProtocolItem = (CL_PROTOCOL_ITEM *)SLL_NEXT(clProtocolItem); } } return NULL; }/******************************************************************************** deleteProtocolItem -*/LOCAL STATUS deleteProtocolItem ( PFW_PLUGIN_OBJ_STATE * layerState, PPP_CONTROL_PHASE protocolPhase, UINT16 protocol ) { unsigned int i; CL_PROTOCOL_ITEM * clProtocolItem; CL_PROTOCOL_ITEM * clProtocolItemToDelete; CONTROL_LAYER_STACK_DATA * pStackData = (CONTROL_LAYER_STACK_DATA *)layerState->stackData; PPP_CONTROL_PHASE startPhase; PPP_CONTROL_PHASE endPhase; if (protocolPhase >= DEAD_PHASE && protocolPhase < TOTAL_PPP_CONTROL_PHASES) { startPhase = protocolPhase; endPhase = (PPP_CONTROL_PHASE) (protocolPhase + 1); } else { startPhase = DEAD_PHASE; endPhase = TOTAL_PPP_CONTROL_PHASES; } for (i = startPhase; i < endPhase; i++) { clProtocolItem = (CL_PROTOCOL_ITEM *) SLL_FIRST(&pStackData->protocols[i]); if (clProtocolItem == NULL) continue; if (((PFW_COMPONENT_OBJ *)clProtocolItem->state->pluginObj)->protocol == protocol) { sllRemove(&pStackData->protocols[i],(SL_NODE *)clProtocolItem,NULL); clProtocolItemFree(clProtocolItem,0); return OK; } while (clProtocolItem->next != NULL && ((PFW_COMPONENT_OBJ *)clProtocolItem->next->state->pluginObj)->protocol != protocol) { clProtocolItem = (CL_PROTOCOL_ITEM *)SLL_NEXT(clProtocolItem); } if (clProtocolItem->next == NULL) continue; clProtocolItemToDelete = clProtocolItem->next; sllRemove(&pStackData->protocols[i],(SL_NODE *)clProtocolItem->next, (SL_NODE *)clProtocolItem); clProtocolItemFree(clProtocolItemToDelete,0); return OK; } return ERROR; }/******************************************************************************** controlLayerComponentAddComplete -*/LOCAL STATUS controlLayerComponentAddComplete ( PFW_COMPONENT_OBJ *co ) { int id; char s[80]; CONTROL_PROTOCOL_INTERFACE * controlProtocolInterface; PPP_CONTROL_PHASE phase; int sequence; if ((id = pfwInterfaceIdGet(co->pluginObj.pfwObj, "CONTROL_PROTOCOL_INTERFACE")) == 0) { pfwPrintError (__FILE__, "controlLayerComponentAddComplete", __LINE__, co->pluginObj.pfwObj,0,"No CONTROL_PROTOCOL_INTERFACE published"); return (ERROR); } if ((controlProtocolInterface = (CONTROL_PROTOCOL_INTERFACE *) pfwInterfaceObjGetViaPluginObj(&co->pluginObj,id)) == NULL) { printf ("Control Layer:No CONTROL_PROTOCOL_INTERFACE for protocol 0x%x\n" ,co->protocol); return ERROR; } if ((phase = (controlProtocolInterface->pppPhaseGet)()) >= TOTAL_PPP_CONTROL_PHASES) { sprintf (s, "protocol: %x has bad phase %d\n", co->protocol,phase); pfwPrintError (__FILE__, "controlLayerComponentAddComplete", __LINE__, co->pluginObj.pfwObj,0,s); return (ERROR); } sequence = PPP_PHASE_STARTING_PROTOCOL_SEQUENCE(phase); if (co->protocol == _LCP_PROTOCOL_ || co->protocol == _ECP_PROTOCOL_ || co->protocol == _ML_ECP_PROTOCOL_) { co->sequence = sequence + 1; } else co->sequence = sequence; pfwInterfaceReferenceDelete((PFW_INTERFACE_OBJ *)controlProtocolInterface); return OK; } /******************************************************************************** controlLayerSend -*/LOCAL STATUS controlLayerSend ( PFW_PLUGIN_OBJ_STATE *state, M_BLK_ID *packet ) { pfwPrintError (__FILE__, "sendIf", __LINE__, 0,state->stackObj, "Control Layer sendIf routine is not supposed to be called"); return (ERROR); }/******************************************************************************** controlLayerReceive -*/LOCAL STATUS controlLayerReceive ( PFW_PLUGIN_OBJ_STATE *state, M_BLK_ID *packet ) { CL_PROTOCOL_ITEM * clProtocolItem = NULL; PFW_COMPONENT_OBJ * componentObj; CONTROL_LAYER_STACK_DATA * pStackData = (CONTROL_LAYER_STACK_DATA *)state->stackData; unsigned int protocol = 0; M_BLK_ID m = NULL; unsigned int i; BOOLEAN found = FALSE;/* WindNet Multilink */ unsigned int j = 0; PFW_PLUGIN_OBJ *mpFramingLayerObj = NULL; PFW_PLUGIN_OBJ_STATE *mpFramingLayerState = NULL; M_BLK_ID saveMblkPtr = NULL; BOOL bFirstProtocolIdByteDone = FALSE;/* WindNet Multilink */ if ((packet == NULL) || ((m = *packet) == NULL)) return ERROR; /* get the protocol id from the packet *//* WindNet Multilink - Added to support single byte fragments */ if (m->mBlkHdr.mLen < 2) { saveMblkPtr = m; while (m != NULL) { if (m->mBlkHdr.mLen == 0) { m = m->mBlkHdr.mNext; continue; } else if (m->mBlkHdr.mLen > 1) { if (bFirstProtocolIdByteDone == FALSE) { protocol = ((m->m_data[0]&0xff) << 8) + (m->m_data[1] & 0xff); } else { protocol += m->m_data[0]&0xff; } break; } else { if (bFirstProtocolIdByteDone == FALSE) { protocol = ((m->m_data[0]&0xff) << 8); bFirstProtocolIdByteDone = TRUE; } else { protocol += m->m_data[0]&0xff; break; } } m = m->mBlkHdr.mNext; } if (m == NULL) { netMblkClChainFree (saveMblkPtr); return ERROR; } m = saveMblkPtr; } else protocol = ((m->m_data[0]&0xff) << 8) + (m->m_data[1] & 0xff); /* WindNet Multilink - Added to support single byte fragments */ /* find protocol for which this packet is intended */ /*for (i = pStackData->phase; i > DEAD_PHASE; i--) */ /* WindNet Multilink */ /* start : component acceptable protcol interface */ for (i = NETWORK_PHASE; i > DEAD_PHASE; i--) { clProtocolItem = (CL_PROTOCOL_ITEM *) SLL_FIRST(&pStackData->protocols[i]); while (clProtocolItem != NULL) { componentObj = (PFW_COMPONENT_OBJ *)clProtocolItem->state->pluginObj; if (componentObj->protocol == protocol) { found = TRUE; break; } else if (clProtocolItem->acceptableProtocols != NULL) { for (j = 0; j < clProtocolItem->acceptableProtocols->numberOfProtocols;j++) { #ifdef PPP_DEBUG printf("controlLayerReceive: accepted protos in receive = %d\n", clProtocolItem->acceptableProtocols->protocols[j]); #endif if (clProtocolItem->acceptableProtocols->protocols[j] == protocol) { found = TRUE; break; } if (found == TRUE) break; } /* end of for(2) */ } if (!found) clProtocolItem = (CL_PROTOCOL_ITEM *)SLL_NEXT(clProtocolItem); else break; } /* End of While */ if (found) break; } /* End of for(1) */ /* end : component acceptable protocol interface */ /* WindNet Multilink */ /* WindNet Multilink - start :*/ if (clProtocolItem == NULL) { /* * find if you are a part of the MANAGER or MEMBER if you are in * the MEMBER, then submit the packet to the MANAGER stack by calling * pfwReceive with MP_FRAMING_LAYER context */ if (pStackData->isMember == TRUE) { if (pStackData->mpStackObj != NULL) { mpFramingLayerObj = pfwPluginObjGet (state->pluginObj->pfwObj, "MP_FRAMING_LAYER"); mpFramingLayerState = pfwPluginObjStateGet (pStackData->mpStackObj, mpFramingLayerObj); if (pfwReceive (mpFramingLayerState, *packet) != OK) netMblkClChainFree (*packet); } return ERROR; } else { /* if you are part of the MEMBER, then */ /* we give this to LCP which sends a protocol reject packet */ (*pStackData->lcpProtocolItem->state->pluginObj->receive) (pStackData->lcpProtocolItem->state, packet);#ifdef PPP_DEBUG printf ("PPP: Protocol 0x%x rejected\n",(int)protocol);#endif /* PPP_DEBUG */ return (ERROR); } } /* WindNet Multilink - end :*/ /* drop packet if we are not ready to receive packets from this protocol */ if (clProtocolItem->interface->pppPhaseGet() > pStackData->phase) {#ifdef PPP_DEBUG printf ("PPP: Protocol 0x%x received in bad phase %d\n",(int)protocol, pStackData->phase);#endif /* PPP_DEBUG */ netMblkClChainFree(*packet); return ERROR; } return (*clProtocolItem->state->pluginObj->receive) (clProtocolItem->state, packet); } /******************************************************************************** controlLayerStackDelete -*/LOCAL STATUS controlLayerStackDelete ( PFW_PLUGIN_OBJ_STATE *state ) { PFW_PLUGIN_OBJ_STATE * componentState; CONTROL_LAYER_STACK_DATA * pStackData; pStackData = (CONTROL_LAYER_STACK_DATA *)state->stackData; if ((componentState = pfwFirstComponentStateGet (state)) == NULL) { pfwPrintError (__FILE__, "stackDelete", __LINE__,0,state->stackObj, "Null component"); return (ERROR); } pStackData->lastDeletedComponent = componentState; return ((*componentState->pluginObj->stackDelete)(componentState)); }/******************************************************************************** controlLayerProfileDataConstruct -*/LOCAL STATUS controlLayerProfileDataConstruct ( PFW_OBJ * pfw, void * pData ) { CONTROL_LAYER_PROFILE_DATA * pProfileData = (CONTROL_LAYER_PROFILE_DATA * )pData;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -