📄 mpinterfacelayer.c
字号:
if (( pEventObj = pfwEventObjGet (pLayerState->pluginObj->pfwObj, "PPP_AUTH_UNSUCCESSFUL_EVENT")) != NULL) { if (ERROR == (pfwEventStackSubscribe (pLayerState, pEventObj, mpInterfaceLayerAuthDownEventHandler))) { pfwPrintError (__FILE__, "mpInterfaceLayerStackAdd", __LINE__, \ pfwObj, pLayerState->stackObj, "Failed to subscribe \ for PPP_AUTH_UNSUCCESSFUL_EVENT event"); return ERROR; } } else { pfwPrintError (__FILE__, "mpInterfaceLayerStackAdd", __LINE__, \ pfwObj, pLayerState->stackObj, "Unable to get event obj \ ofthe PPP_AUTH_UNSUCCESSFUL_EVENT event\n"); return ERROR; } if (( pEventObj = pfwEventObjGet (pLayerState->pluginObj->pfwObj, "MP_BUNDLE_CLOSED_EVENT")) != NULL) { if (ERROR == (pfwEventStackSubscribe (pLayerState, pEventObj, mpInterfaceLayerBundleCloseEventHandler))) { pfwPrintError (__FILE__, "mpInterfaceLayerStackAdd", __LINE__, \ pfwObj, pLayerState->stackObj, "Failed to subscribe \ for MP_BUNDLE_CLOSED_EVENT event"); return ERROR; } } else { pfwPrintError (__FILE__, "mpInterfaceLayerStackAdd", __LINE__, pfwObj, \ pLayerState->stackObj, "Unable to get event obj of \ the MP_BUNDLE_CLOSED_EVENT event\n"); return ERROR; } /* call the callback routine */ if (pStackData->callbacks && pStackData->callbacks->stackAddComplete) { (*pStackData->callbacks->stackAddComplete) (pStackData->callbacks, pLayerState); return OK; } else return ERROR; }/******************************************************************************** mpInterfaceLayerStackDelete - called when the stack containing the * plugin is deleted.** The framework calls this function when the stack that contains the Plugin * object is deleted. This function deletes the references to the previously * registered interfaces, frees the memory and calls the callback routine if * provided. ** RETURNS: OK/ERROR*/LOCAL STATUS mpInterfaceLayerStackDelete ( PFW_PLUGIN_OBJ_STATE *pMpInterfaceLayerState /* state for the stack */ ) { MP_INTERFACE_LAYER_STACK_DATA * pStackData = pMpInterfaceLayerState->stackData; PFW_OBJ *pfw = pMpInterfaceLayerState->pluginObj->pfwObj; PFW_STACK_OBJ *pStackObj = pMpInterfaceLayerState->stackObj; /* delete the reference to the interfaces */ if (pStackData->mpBundleManagementInterfaceStatePair.interfaceObj != NULL) { if (pfwInterfaceReferenceDelete ((PFW_INTERFACE_OBJ *) pStackData->mpBundleManagementInterfaceStatePair.interfaceObj) == ERROR) { pfwPrintError (__FILE__, "mpInterfaceLayerStackDelete", __LINE__, \ pfw, pStackObj, "Error in deleting the reference to \ BUNDLE_MANAGEMENT_INTERFACE"); return ERROR; } } if (pStackData->mpPacketRcvInterfaceStatePair.interfaceObj != NULL) { if (pfwInterfaceReferenceDelete ((PFW_INTERFACE_OBJ *) pStackData->mpPacketRcvInterfaceStatePair.interfaceObj) == ERROR) { pfwPrintError (__FILE__, "mpInterfaceLayerStackDelete", __LINE__, \ pfw, pStackObj, "Error in deleting the reference to \ MP_PACKET_RECEIVE_INTERFACE"); return ERROR; } } if (pfwInterfaceReferenceDelete (pStackData->mpControlLayerInterfaceStatePair.interfaceObj) == ERROR) { pfwPrintError (__FILE__, "mpInterfaceLayerStackDelete", __LINE__, \ pfw, pStackObj, "Error in deleting the reference to \ MP_CONTROL_LAYER_INTERFACE"); return ERROR; } if (pfwInterfaceReferenceDelete (pStackData->lcpPacketSendInterfaceStatePair.interfaceObj) == ERROR) { pfwPrintError (__FILE__, "mpInterfaceLayerStackDelete", __LINE__, \ pfw, pStackObj, "Error in deleting the reference to \ LCP_PACKET_SEND_INTERFACE"); return ERROR; } if (pfwInterfaceReferenceDelete (pStackData->lcpNegotiatedAuthProtocolInterfaceStatePair.interfaceObj) == ERROR) { pfwPrintError (__FILE__, "mpInterfaceLayerStackDelete", __LINE__, \ pfw, pStackObj, "Error in deleting the reference to \ LCP_NEGOTIATED_AUTH_PROTOCOL_INTERFACE"); return ERROR; } /* call the callback routine */ if (pStackData->callbacks && pStackData->callbacks->stackDeleteComplete) { (*pStackData->callbacks->stackDeleteComplete) (pStackData->callbacks, pMpInterfaceLayerState); return OK; } else return ERROR; }/******************************************************************************** mpInterfaceLayerReceive - process the received packet ** This function is receives the data packet at the member stack and submits the * packet to its manager stack. It checks if the receive queue is enabled for the * bundle and if it is enabled, it adds the packet to the mpReceiveQueue. If the * receive queue is not enabled, it calls the pluginObj.receive of the * MP_FRAMING_LAYER component with its state.** RETURNS: OK/ERROR*/LOCAL STATUS mpInterfaceLayerReceive ( PFW_PLUGIN_OBJ_STATE * pMpInterfaceLayerState, /* state for member stack */ M_BLK_ID * packet /* packet received */ ) { MP_INTERFACE_LAYER_STACK_DATA *pStackData = (MP_INTERFACE_LAYER_STACK_DATA*) pMpInterfaceLayerState->stackData; PFW_OBJ *pfwObj = pMpInterfaceLayerState->pluginObj->pfwObj; MP_RECEIVE_DATA receiveData; PFW_PLUGIN_OBJ_STATE *pManagerState; /* if packet is NULL, return */ if (packet == NULL || *packet == NULL) { return ERROR; } /* get the manager plugin state */ pManagerState = pStackData->mpPacketRcvInterfaceStatePair.state; /* * fill the receive data structure with the arguments to be passed to * the handler function */ receiveData.pMemberState = pMpInterfaceLayerState; receiveData.pPacket = *packet; /* add to the queue */ if (mpReceiveQueueAdd (pfwObj, (FUNCPTR) _mpReceive, (void*)&receiveData, sizeof (MP_RECEIVE_DATA)) == OK) { return ERROR; } else { netMblkClChainFree (* packet); return ERROR; } }/******************************************************************************** mpInterfaceLayerSend - sends the packet** This function is called to send the PPP packets. It fragments the larger PPP * packets and sends it through the individual member links. It uses the * packetType function to check the type of the packet and calls * mp_send_ppp_packet function to send the packet.** RETURNS: OK/ERROR*/LOCAL STATUS mpInterfaceLayerSend ( PFW_PLUGIN_OBJ_STATE * pLayerState, /* state for this stack */ M_BLK_ID * packet /* packet received */ ) { return OK; }/******************************************************************************** mpInterfaceLayerProfileDataConstruct - called by the framework to initialize* the profile data** The framework calls this function when the first configuration parameter * associated with the Plugin object is added to the profile to initialize the * profile data associated with the Plugin object. This function initializes the * profile data parameters to their default values.** RETURNS: OK/ERROR*/LOCAL STATUS mpInterfaceLayerProfileDataConstruct ( PFW_OBJ * pfw, /* framework object */ void * pData /* pointer to hold profile data */ ) { MP_INTERFACE_LAYER_PROFILE_DATA *pProfileData = (MP_INTERFACE_LAYER_PROFILE_DATA *) pData; pProfileData->mpInterface_memberLinkSpeed = 0; pProfileData->mpInterface_managerStackId = NULL; return OK; } /******************************************************************************* mpInterface_memberLinkSpeed - get/set the member link speed parameter** This routine gets or sets the value of the MP_INTERFACE_LAYER profile data * parameter mpInterface_memberLinkSpeed.** RETURNS: OK/ERROR*/LOCAL STATUS mpInterface_memberLinkSpeed ( PFW_OBJ * pfw, /* framework reference */ PFW_PARAMETER_OPERATION_TYPE operType, /* operation type */ void * pData, /* profile data bucket */ char * value /* value for this parameter */ ) { MP_INTERFACE_LAYER_PROFILE_DATA * pProfileData = (MP_INTERFACE_LAYER_PROFILE_DATA *)pData; UINT configValue = 0; if (operType == PFW_PARAMETER_SET) { if (value == NULL) return ERROR; if ((configValue = atoi (value)) > 0) pProfileData->mpInterface_memberLinkSpeed = configValue; return OK; } else if (operType == PFW_PARAMETER_GET) { sprintf (value, "%ld",\ pProfileData->mpInterface_memberLinkSpeed); return OK; } return ERROR; }/******************************************************************************* mpInterface_managerStackId - get/set the manager stack Id parameter** This routine gets or sets the value of the MP_INTERFACE_LAYER profile data * parameter mpInterface_managerStackId.** RETURNS: OK/ERROR*/LOCAL STATUS mpInterface_managerStackId ( PFW_OBJ * pfw, /* framework reference */ PFW_PARAMETER_OPERATION_TYPE operType, /* operation type */ void * pData, /* profile data bucket */ char * value /* value for this parameter */ ) { MP_INTERFACE_LAYER_PROFILE_DATA * pProfileData = (MP_INTERFACE_LAYER_PROFILE_DATA *)pData; UINT configValue = 0; if (operType == PFW_PARAMETER_SET) { if (value == NULL) return ERROR; if ((configValue = atoi (value)) > 0) pProfileData->mpInterface_managerStackId = (PFW_STACK_OBJ *)configValue; return OK; } else if (operType == PFW_PARAMETER_GET) { sprintf (value, "%d",\ (int)pProfileData->mpInterface_managerStackId); return OK; } return ERROR; }/********************************************************************************* _mpReceive - stub routine for mpReceive* * RETURNS: N/A*/LOCAL void _mpReceive ( void *data ) { MP_RECEIVE_DATA *receiveData = (MP_RECEIVE_DATA *)data; MP_INTERFACE_LAYER_STACK_DATA * pStackData = (MP_INTERFACE_LAYER_STACK_DATA*) receiveData->pMemberState->stackData; MP_PACKET_RECEIVE_INTERFACE *pMpPacketReceiveInterface = NULL; if (receiveData == NULL) { pfwPrintError (__FILE__, "_mpReceive", __LINE__, \ NULL, NULL, "Null argument"); return; } pMpPacketReceiveInterface = (MP_PACKET_RECEIVE_INTERFACE *) pStackData->mpPacketRcvInterfaceStatePair.interfaceObj; if (pMpPacketReceiveInterface != NULL) pMpPacketReceiveInterface->mpFramingLayerReceive (pStackData->mpPacketRcvInterfaceStatePair.state, receiveData->pMemberState->stackObj, receiveData->pPacket); else { netMblkClChainFree (receiveData->pPacket); return; /* added the NULL checking for the pMpPacketReceiveInterface */ } }/******************************************************************************** mpInterfaceLayerLcpUpEventHandler - mpInterface layer LCP_UP event handler* * This function checks whether authentication phase exists in the stack. If * authentication phase is there, this function returns immediately. Otherwise, * it adds the link to the appropriate bundle.* * RETURNS: OK or ERROR*/LOCAL STATUS mpInterfaceLayerLcpUpEventHandler ( PFW_PLUGIN_OBJ_STATE *pMpInterfaceLayerState, void *eventData ) { MP_INTERFACE_LAYER_STACK_DATA *pStackData = NULL; MP_INTERFACE_LAYER_PROFILE_DATA *pProfileData = NULL; PFW_STACK_OBJ *pManagerStackObj = NULL; PFW_PLUGIN_OBJ_STATE *pMemberLcpState = NULL; PFW_PLUGIN_OBJ *pPluginObj = NULL; LCP_NEGOTIATED_AUTH_PROTOCOL_INTERFACE *pLcpNegotiatedAuthProtocolInterface = NULL; MP_CONTROL_LAYER_INTERFACE *pMpControlLayerInterface = NULL; MP_BUNDLE_MANAGEMENT_INTERFACE *pMpBundleManagementInterfaceObj = NULL; PFW_OBJ *pfwObj = NULL; UINT localAuthProtocol = 0; UINT remoteAuthProtocol = 0; UINT interfaceId = 0; STATUS status; pfwObj = pfwStackObjPfwGet (pMpInterfaceLayerState->stackObj); if (pfwObj == NULL) { printf ("NULL Framework Reference\n"); return ERROR; } pStackData = (MP_INTERFACE_LAYER_STACK_DATA *) pMpInterfaceLayerState->stackData; pProfileData = (MP_INTERFACE_LAYER_PROFILE_DATA *) pMpInterfaceLayerState->profileData; /* Get the MPControl Layer Interface Obj */ pMpControlLayerInterface = (MP_CONTROL_LAYER_INTERFACE *) pStackData->mpControlLayerInterfaceStatePair.interfaceObj; /* Set the Control layer in the MP Member link mode */ pMpControlLayerInterface->pppMpMemberSet (pStackData->mpControlLayerInterfaceStatePair.state, TRUE, pProfileData->mpInterface_managerStackId); /* Get the reference to MP up call functions */ pMpControlLayerInterface->mpUpCallsGet (pStackData->mpControlLayerInterfaceStatePair.state, &pStackData->mpUpCalls, &pStackData->userHandler); /* Check whether authentication phase does exist in the stack */ pLcpNegotiatedAuthProtocolInterface = (LCP_NEGOTIATED_AUTH_PROTOCOL_INTERFACE *) pStackData->lcpNegotiatedAuthProtocolInterfaceStatePair.interfaceObj; /* * Retrieve LCP state and LCP negotiated auth. protocol interface state * Pair */ pMemberLcpState = pStackData->lcpNegotiatedAuthProtocolInterfaceStatePair.state; /* Retrieve Local and Remote authentication protocol */ localAuthProtocol = pLcpNegotiatedAuthProtocolInterface->pppLocalAuthenticationProtocolGet (pMemberLcpState); remoteAuthProtocol = pLcpNegotiatedAuthProtocolInterface->pppRemoteAuthenticationProtocolGet (pMemberLcpState); /* * If authentication phase exists in the stack, delay adding the link to the * bundle till authentication phase gets over */ if ((localAuthProtocol != 0) || (remoteAuthProtocol != 0)) { return OK; } /* Add the link to the bundle */ pPluginObj = pfwPluginObjGet (pfwObj, "MP_FRAMING_LAYER"); if (pPluginObj == NULL) { pfwPrintError (__FILE__, "mpInterfaceLayerLcpUpEventHandler", __LINE__, \ pfwObj, pMpInterfaceLayerState->stackObj,\ "mpFraming layer does not exist in the framework"); pMpControlLayerInterface->pppMpMemberSet (pStackData->mpControlLayerInterfaceStatePair.state, FALSE, NULL); return (ERROR); } /* Get reference to the MP bundle Management interface */ interfaceId = pfwInterfaceIdGet (pfwObj, "MP_BUNDLE_MANAGEMENT_INTERFACE"); pMpBundleManagementInterfaceObj = (MP_BUNDLE_MANAGEMENT_INTERFACE *) pfwInterfaceObjGetViaPluginObj (pPluginObj, interfaceId);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -