📄 pppbacpcomponent.c
字号:
/******************************************************************************** bacpInterfaceBind - bind to the interfaces** The framework calls this function to bind the BACP Plugin object to the * interfaces it implements. This function binds the interfaces * CONTROL_PROTOCOL_INTERFACE and COMPONENT_ACCEPTABLE_PROTOCOLS_INTERFACE * that it implements, with the framework by calling pfwInterfaceBind ().* * RETURNS: OK or ERROR*/LOCAL STATUS bacpInterfaceBind ( PFW_PLUGIN_OBJ * pluginObj /* BACP component object */ ) { PPP_BACP_COMPONENT * pComponent = (PPP_BACP_COMPONENT *)pluginObj; CONTROL_PROTOCOL_INTERFACE * pBacpControlInterface = NULL; COMPONENT_ACCEPTABLE_PROTOCOLS_INTERFACE * pBacpAcceptableProtocolsInterface =NULL; PFW_OBJ * pfw = pluginObj->pfwObj; UINT id = 0; /* get CONTROL_PROTOCOL_INTERFACE ID and bind to it */ if ((id = pfwInterfaceIdGet (pfw, "CONTROL_PROTOCOL_INTERFACE")) > 0) { pBacpControlInterface = &pComponent->bacpControlInterface; pBacpControlInterface->interfaceObj.id = id; pBacpControlInterface->interfaceObj.pluginObj = (PFW_PLUGIN_OBJ *)pComponent; pBacpControlInterface->pppPhaseGet = bacpPhaseGet; pBacpControlInterface->pppStateGet = bacpStateGet; pBacpControlInterface->executeStateMachine = execute_bacp_state_machine; pfwInterfaceBind (&pBacpControlInterface->interfaceObj); } else {#ifdef PPP_DEBUG logMsg ("BACP component Interface Bind: \ ERROR in binding to CONTROL_PROTOCOL_INTERFACE\n",1,2,3,4,5,6);#endif /* PPP_DEBUG */ return ERROR; } /* get COMPONENT_ACCEPTABLE_PROTOCOLS_INTERFACE ID and bind to it */ if ((id = pfwInterfaceIdGet (pfw, "COMPONENT_ACCEPTABLE_PROTOCOLS_INTERFACE")) > 0) { pBacpAcceptableProtocolsInterface = &pComponent->bacpComponentAcceptableProtocolsInterface; pBacpAcceptableProtocolsInterface->interfaceObj.id = id; pBacpAcceptableProtocolsInterface->interfaceObj.pluginObj = (PFW_PLUGIN_OBJ *)pComponent; pBacpAcceptableProtocolsInterface->receivePathAcceptableProtocolsGet = bacpReceivePathAcceptableProtocolsGet; pBacpAcceptableProtocolsInterface->sendPathAcceptableProtocolsGet = NULL; pfwInterfaceBind (&pBacpAcceptableProtocolsInterface->interfaceObj); } else {#ifdef PPP_DEBUG logMsg ("BACP component Interface Bind: \ ERROR in binding to COMPONENT_ACCEPTABLE_PROTOCOLS_INTERFACE\n",1,2,3,4,5,6);#endif /* PPP_DEBUG */ return ERROR; } return OK; }/******************************************************************************** bacpStackAdd - add BACP to stack ** This function is called when the BACP plug-in object is added to a stack that * is being built to support a connection. This function initializes the * bacpStatistics and bapStatistics structures, timers for use by BACP, * subscribes for the events and registers the interfaces implemented by the * other components and calls stackAddComplete () callback routine. ** RETURNS:OK or ERROR*/LOCAL STATUS bacpStackAdd ( PFW_PLUGIN_OBJ_STATE * pComponentState, /* state for the stack */ PFW_PLUGIN_OBJ_CALLBACKS * callbacks /* callback routines */ ) { UINT id = 0; PFW_LAYER_OBJ * pLayerObj = ((PFW_COMPONENT_OBJ *)pComponentState->pluginObj)->layerObj; BACP_STACK_DATA * pStackData = (BACP_STACK_DATA *) pComponentState->stackData; /* initialize the statistics counters */ initialize_bacp_statistics_counters (pComponentState); initialize_bap_statistics_counters (pComponentState); /* initialize the timers */ if ((pStackData->retryTimer = pfwTimerCreate (pComponentState)) == NULL) { logMsg("Timer create error for retryTimer \n", 1, 2, 3, 4, 5, 6); return ERROR; } if ((pStackData->callRequestRetryTimer = pfwTimerCreate (pComponentState)) == NULL) { logMsg("Timer create error for Call Request retryTimer \n", \ 1, 2, 3, 4, 5, 6); return ERROR; } if ((pStackData->callbackRequestRetryTimer = pfwTimerCreate (pComponentState)) == NULL) { logMsg("Timer create error for Callback Request retryTimer \n", \ 1, 2, 3, 4, 5, 6); return ERROR; } if ((pStackData->indicationRetryTimer = pfwTimerCreate (pComponentState)) == NULL) { logMsg("Timer create error for Indication Request retryTimer \n",\ 1, 2, 3, 4, 5, 6); return ERROR; } if ((pStackData->dropRequestRetryTimer = pfwTimerCreate (pComponentState)) == NULL) { logMsg("Timer create error for Link drop Request retryTimer \n",\ 1, 2, 3, 4, 5, 6); return ERROR; } /* initialize the callback routines */ pStackData->callbacks = callbacks; /* get controlLayer interface */ if ((id = pfwInterfaceIdGet (pComponentState->pluginObj->pfwObj, "PPP_CONTROL_LAYER_INTERFACE")) > 0) { if (NULL == (pStackData->controlLayerInterface = (PPP_CONTROL_LAYER_INTERFACE *) pfwInterfaceObjGetViaPluginObj (&pLayerObj->pluginObj, id))) { logMsg("Interface Object get failed for \ PPP_CONTROL_LAYER_INTERFACE \n", 1, 2, 3, 4, 5, 6); return ERROR; } } else { logMsg("Interface ID get for \ PPP_CONTROL_LAYER_INTERFACE \n", 1, 2, 3, 4, 5, 6); return ERROR; } if ((pStackData->mpLinkUpEventObj = pfwEventObjGet (pComponentState->pluginObj->pfwObj, "MP_MEMBER_ADDED_EVENT")) != NULL) { if (ERROR == (pfwEventStackSubscribe (pComponentState, pStackData->mpLinkUpEventObj, bacpLinkAdded))) {#ifdef PPP_DEBUG printf ("BACP Component Stack Add: \ ERROR in subscribing MP_MEMBER_ADDED_EVENT\n");#endif /* PPP_DEBUG */ return ERROR; } } else { logMsg("Event Obj get error for \ MP_MEMBER_ADDED_EVENT \n", 1, 2, 3, 4, 5, 6); return ERROR; } if ((pStackData->mpLinkDownEventObj = pfwEventObjGet (pComponentState->pluginObj->pfwObj, "MP_MEMBER_DROPPED_EVENT")) != NULL) { if (ERROR == (pfwEventStackSubscribe (pComponentState, pStackData->mpLinkDownEventObj, bacpLinkRemoved))) {#ifdef PPP_DEBUG printf ("BACP Component Stack Add: \ ERROR in subscribing MP_MEMBER_DROPPED_EVENT\n");#endif /* PPP_DEBUG */ return ERROR; } } else { logMsg("Event Obj get error for \ MP_MEMBER_DROPPED_EVENT \n", 1, 2, 3, 4, 5, 6); return ERROR; } if ((pStackData->mpBundleCloseEventObj = pfwEventObjGet (pComponentState->pluginObj->pfwObj, "MP_BUNDLE_CLOSED_EVENT")) != NULL) { if (ERROR == (pfwEventStackSubscribe (pComponentState, pStackData->mpBundleCloseEventObj, mpBundleClose))) {#ifdef PPP_DEBUG printf ("BACP Component Stack Add: \ ERROR in subscribing MP_BUNDLE_CLOSED_EVENT\n");#endif /* PPP_DEBUG */ return ERROR; } } else { logMsg("Event Obj get error for \ MP_BUNDLE_CLOSED_EVENT \n", 1, 2, 3, 4, 5, 6); return ERROR; } if ((pStackData->mpBundleOpenEventObj = pfwEventObjGet (pComponentState->pluginObj->pfwObj, "MP_BUNDLE_OPENED_EVENT")) != NULL) { if (ERROR == (pfwEventStackSubscribe (pComponentState, pStackData->mpBundleOpenEventObj, mpBundleOpen))) {#ifdef PPP_DEBUG printf ("BACP Component Stack Add: \ ERROR in subscribing MP_BUNDLE_OPENED_EVENT\n");#endif /* PPP_DEBUG */ return ERROR; } } else { logMsg("Event Obj get error for \ MP_BUNDLE_OPENED_EVENT \n", 1, 2, 3, 4, 5, 6); return ERROR; } /* call the callback routine */ if (pStackData->callbacks && pStackData->callbacks->stackAddComplete) { (*pStackData->callbacks->stackAddComplete) (pStackData->callbacks, pComponentState); return OK; } else return ERROR; }/******************************************************************************** bacpStackDelete - delete BACP from Stack** The framework calls this function when the stack that contains the Plugin * object is deleted. This function deletes the references to the registered * interfaces, deletes the timers created, frees the memory and calls * the callback routine if provided. ** RETURNS: OK/ERROR*/LOCAL STATUS bacpStackDelete ( PFW_PLUGIN_OBJ_STATE * pComponentState /* state for the stack */ ) { BACP_STACK_DATA * pStackData = (BACP_STACK_DATA *)pComponentState->stackData; /* delete the timers */ pfwTimerDelete (pStackData->retryTimer); pfwTimerDelete (pStackData->indicationRetryTimer); pfwTimerDelete (pStackData->dropRequestRetryTimer); pfwTimerDelete (pStackData->callRequestRetryTimer); pfwTimerDelete (pStackData->callbackRequestRetryTimer); /* free the memory of request packets */ if (pStackData->last_txed_bacp_configuration_request_packet != NULL) netMblkClChainFree (pStackData->last_txed_bacp_configuration_request_packet); if (pStackData->last_rxed_bacp_configuration_request_packet != NULL) netMblkClChainFree (pStackData->last_rxed_bacp_configuration_request_packet); /* delete the reference to the interfaces */ pfwInterfaceReferenceDelete ((PFW_INTERFACE_OBJ *)pStackData->controlLayerInterface); if (pStackData->mpBundleManagementInterface.interfaceObj != NULL) pfwInterfaceReferenceDelete ((PFW_INTERFACE_OBJ *) pStackData->mpBundleManagementInterface.interfaceObj); /* call the callback routine */ if (pStackData->callbacks && pStackData->callbacks->stackDeleteComplete) { (*pStackData->callbacks->stackDeleteComplete) (pStackData->callbacks, pComponentState); return OK; } else return ERROR; }/******************************************************************************* bacpReceive - BACP receive interface ** This function is called with the packet received from the network that is * being passed up through the stack. This routine processes the BACP and BAP* packets. The function checks the protocol id of the received packet, if the * protocol id is BACP_PROTOCOL, then bacp_packet_received is called to process * the packet and if the protocol id is BAP_PROTOCOL, then bap_packet_received * is called to process the packet further.** RETURNS: OK/ERROR*/LOCAL STATUS bacpReceive ( PFW_PLUGIN_OBJ_STATE * pComponentState, /* state for this stack */ M_BLK_ID * pMblkId /* packet received */ ) { UINT protocol = 0; M_BLK_ID m = *pMblkId; if (pMblkId != NULL && *pMblkId != NULL) { /* get the protocol id from the packet */ protocol = ((m->m_data[0] & 0xff) << 8) + (m->m_data[1] & 0xff); if (protocol == BACP_PROTOCOL) bacp_packet_received (pComponentState, *pMblkId); else { if (protocol == BAP_PROTOCOL) bap_packet_received (pComponentState, *pMblkId); else return ERROR; } } return OK; }/******************************************************************************** removeAlternateValues - removes alternate and range values for the option** This routine frees the memory held by either the localAlternateConfigString or * remoteAlternateConfigString.** RETURNS: N/A*/LOCAL void removeAlternateValues ( BACP_CONFIG_STRINGS * pBacpOption, /* option string */ char * remoteOrLocal /* remote/local */ ) { ALTERNATE_OPTION_STRING * nextString = NULL; ALTERNATE_OPTION_STRING * alternateString = NULL; /* if local free the local alternate string, if remote free the remote alternate string */ if ((strstr (remoteOrLocal, "Local") != NULL) && (strlen (remoteOrLocal) <= 6)) { alternateString = pBacpOption->localAlternateConfigString; pBacpOption->localAlternateConfigString = NULL; } else if ((strstr (remoteOrLocal, "Remote") != NULL) && (strlen (remoteOrLocal) <= 7)) { alternateString = pBacpOption->remoteAlternateConfigString; pBacpOption->remoteAlternateConfigString = NULL; } else return; while (alternateString != NULL) { nextString = alternateString->next; if (alternateString != NULL) { pfwFree (alternateString); alternateString = NULL; } alternateString = nextString; } }/******************************************************************************** bacp_optionsHandler - generic handler for all BACP options** If operation type is PFW_PARAMETER_SET, the options given in value are copied * into options structure of BACP_PROFILE_DATA, if operation type is * PFW_PARAMETER_GET the options data is copied into the passed value. ** RETURNS: OK/ERROR*/LOCAL STATUS bacp_optionsHandler ( PFW_OBJ * pfw, /* framework reference */ BACP_OPTION_TYPE optionType, /* option number 0x1 */ PFW_PARAMETER_OPERATION_TYPE operType, /* operation type */ void * pData, /* profile data bucket */ char * value /* value for this parameter */ ) { UINT stringLength= 0; char **ppConfigString = NULL; char *pAlternateStringPtr = NULL; BACP_PROFILE_DATA *pProfileData = (BACP_PROFILE_DATA *)pData; BACP_CONFIG_OPTION *pBacpOption = NULL; UINT alternateLength = 0; ALTERNATE_OPTION_STRING *pPrevious = NULL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -