mpframinglayerinterface.c
来自「这是全套的PPP协议的源码」· C语言 代码 · 共 2,047 行 · 第 1/4 页
C
2,047 行
pLcpBundleOptions = NULL; } return NULL; } } /* end of else - Trying mapping for the link in the bundle assignment array */ if (pfwPluginObjStateLock (pBundleId) == ERROR) return NULL; pStackData = (MP_FRAMING_LAYER_STACK_DATA *)pBundleId->stackData; /* Add the link to the bundle identified by pBundleId */ /* * Assign the bundle identifier of the member link to the newly opened * bundle */ memcpy ((void *) &pStackData->bundle.id, (const void *) &pLcpBundleOptions->bundle_identifier, (size_t) sizeof (MP_BUNDLE_IDENTIFIER)); if (pfwPluginObjStateRelease (pBundleId) == ERROR) return NULL; status = linkToTheBundleAdd (pBundleId, pMemberStackObj, pLcpBundleOptions); if (status == ERROR) { printf ("MP:mp_open_bundle_or_add_to_the_existing_bundle(): Addition of \ member stack 0x%x to the bundle 0x%x failed\n", \ (int) pMemberStackObj, (int) pManagerStackObj); if (pLcpBundleOptions != NULL) { pfwFree (pLcpBundleOptions); pLcpBundleOptions = NULL; } return NULL; } /* do proxy LCP for the manager stack */ pProxyLcpInterfaceObj = (LCP_PROXYLCP_INTERFACE *) pStackData->proxyLcpInterfaceStatePair.interfaceObj; pManagerLcpState = pfwPluginObjStateGet (pBundleId->stackObj, pMemberLcpState->pluginObj); if (pManagerLcpState == NULL) { printf ("MP:mp_open_bundle_or_add_to_the_existing_bundle(): \ LCP Component does not exist in the stack 0x%x\n", \ (int)pBundleId->stackObj); if (pLcpBundleOptions != NULL) { pfwFree (pLcpBundleOptions); pLcpBundleOptions = NULL; } return NULL; } status = pProxyLcpInterfaceObj->lcpProxyLcpDo (pManagerLcpState, pMemberLcpState); if (status == ERROR) { printf ("MP:mp_open_bundle_or_add_to_the_existing_bundle(): Addition of \ member stack 0x%x to the bundle 0x%x failed\n", \ (int)pMemberStackObj, (int)pManagerStackObj); if (pLcpBundleOptions != NULL) { pfwFree (pLcpBundleOptions); pLcpBundleOptions = NULL; } return NULL; } /* Initialize the profile for the bundle */ bundleProfileInit (pBundleId, pLcpBundleOptions); /* Raise MP_BUNDLE_OPENED event */ if (pfwPluginObjStateLock (pBundleId) == ERROR) return NULL; status = bundleOpenedEventRaise (pBundleId, pLcpBundleOptions); if (status == ERROR) { printf ("MP:mp_open_bundle_or_add_to_the_existing_bundle(): \ Addition of member stack 0x%x to the bundle 0x%x failed\n", \ (int) pMemberStackObj, (int) pManagerStackObj); if (pfwPluginObjStateRelease (pBundleId) == ERROR) return NULL; if (pLcpBundleOptions != NULL) { pfwFree (pLcpBundleOptions); pLcpBundleOptions = NULL; } return NULL; } /* Raise MP_MEMBER_ADDED event */ status = mpMemberAddedEventRaise (pBundleId, pMemberStackObj, pLcpBundleOptions); if (status == ERROR) { printf ("MP:mp_open_bundle_or_add_to_the_existing_bundle(): Addition of \ member stack 0x%x to the bundle 0x%x failed\n", \ (int) pMemberStackObj, (int) pManagerStackObj); if (pfwPluginObjStateRelease (pBundleId) == ERROR) return NULL; if (pLcpBundleOptions != NULL) { pfwFree (pLcpBundleOptions); pLcpBundleOptions = NULL; } return NULL; } if (pfwPluginObjStateRelease (pBundleId) == ERROR) return NULL; /* updating the compone data structures */ pComponentData = (MP_FRAMING_LAYER *) pBundleId->pluginObj; if (semTake (pComponentData->componentSem, WAIT_FOREVER) == ERROR) return NULL; if (pComponentData->no_of_bundles >= MAX_NO_OF_PPP_PORTS) { pfwStackDelete (pBundleId->stackObj); return NULL; } pComponentData->pMpFramingLayerState [pComponentData->no_of_bundles] = pBundleId; pComponentData->bundle_count_to_manager_stackObj_lookup [pComponentData->no_of_bundles].pManagerStackObj = pBundleId->stackObj; pComponentData->no_of_bundles++; if (semGive (pComponentData->componentSem) == ERROR) return NULL; return pBundleId->stackObj; }/******************************************************************************** mp_remove_port_from_bundle - Drops a link from the bundle* * * This function can be called in the PPP_LINK_RESET event handler function of the * mpInterface layer in the Member Stacks to drop the link from the bundle. This * function removes the entry of the member link from the corresponding Manager * Stack's bundle management structure. If the member link is in the sending end* of the bundle, it updates bandwidth share information and if the link is in * receiving end of the bundle, it re-estimates the buffer requirement.* * RETURNS: OK or ERROR*/STATUS mp_remove_port_from_bundle ( PFW_PLUGIN_OBJ_STATE *pMpFramingLayerState, /* mpFraming layer state representing the bundle */ PFW_STACK_OBJ *pMemberStackObj /*stack obj representing the link*/ ) { MP_FRAMING_LAYER_STACK_DATA *pStackData = NULL; LCP_BUNDLE_OPTIONS *pLcpBundleOptions = NULL; STATUS status; UINT loopIndex = 0; MP_FRAMING_LAYER *pComponentData = NULL; PFW_OBJ *pfwObj = NULL; if ((pMpFramingLayerState == NULL) || (pMemberStackObj == NULL)) return ERROR; pfwObj = pMpFramingLayerState->pluginObj->pfwObj; pStackData = (MP_FRAMING_LAYER_STACK_DATA *)pMpFramingLayerState->stackData; pComponentData = (MP_FRAMING_LAYER *) pMpFramingLayerState->pluginObj; /* Search the matching entry for the link in port array */ if (pfwPluginObjStateLock (pMpFramingLayerState) == ERROR) return ERROR; for (loopIndex = 0; loopIndex < pStackData->bundle.no_of_links; loopIndex++) { if (pStackData->bundle.memberLinks[loopIndex].pMemberStackObj == pMemberStackObj) break; } if (loopIndex == pStackData->bundle.no_of_links) { if (pfwPluginObjStateRelease (pMpFramingLayerState) == ERROR) return ERROR; return OK; } pLcpBundleOptions = pStackData->bundle.memberLinks[loopIndex].pLcpBundleOptions; /* Remove the link from the receiving end of the bundle */ if (pLcpBundleOptions->is_link_in_receiving_end) { status = mp_remove_port_from_receiving_end_of_the_bundle (pMpFramingLayerState, pMemberStackObj); if (status == ERROR) { printf ("MP:mp_remove_port_from_bundle(): Failed to remove the link \ 0x%x from the receiving end of the bundle 0x%x\n", \ (int) pMemberStackObj, (int) pMpFramingLayerState->stackObj); if (pfwPluginObjStateRelease (pMpFramingLayerState) == ERROR) return ERROR; return ERROR; } } /* Remove the link from the sending end of the bundle */ if (pLcpBundleOptions->is_link_in_sending_end) { status = mp_remove_port_from_sending_end_of_the_bundle (pMpFramingLayerState, pMemberStackObj); if (status == ERROR) { printf ("MP:mp_remove_port_from_bundle(): Failed to remove the link \ 0x%x from the receiving end of the bundle 0x%x\n", \ (int) pMemberStackObj, (int) pMpFramingLayerState->stackObj); if (pfwPluginObjStateRelease (pMpFramingLayerState) == ERROR) return ERROR; return ERROR; } } /* Raise Member Dropped event */ status = pfwEventRaise ( pMpFramingLayerState->stackObj, pStackData->pMpMemberDroppedEventObj, pMemberStackObj); if (status == ERROR) { printf ("MP:mp_remove_port_from_bundle(): Removal of member stack 0x%x \ from the bundle 0x%x failed", (int) pMemberStackObj, \ (int) pMpFramingLayerState->stackObj); if (pfwPluginObjStateRelease (pMpFramingLayerState) == ERROR) return ERROR; return ERROR; } /* remove the enty of the link from the port class array */ if (pLcpBundleOptions != NULL) { pfwFree (pLcpBundleOptions); pLcpBundleOptions = NULL; } while (loopIndex < (pStackData->bundle.no_of_links - 1)) { pStackData->bundle.memberLinks[loopIndex] = pStackData->bundle.memberLinks[loopIndex + 1]; loopIndex++; } /* If there are no links in the bundle, close the bundle */ if (--(pStackData->bundle.no_of_links) == 0) { if (pfwPluginObjStateRelease (pMpFramingLayerState) == ERROR) return ERROR; status = mpBundleDown (pMpFramingLayerState->stackObj, FALSE); if (status == ERROR) { printf ("MP:mp_remove_port_from_bundle(): Removal of member stack \ 0x%x from the bundle 0x%x failed", (int) pMemberStackObj, \ (int) pMpFramingLayerState->stackObj); return ERROR; } else return OK; } if (pfwPluginObjStateRelease (pMpFramingLayerState) == ERROR) return ERROR; return OK; }/******************************************************************************** mpLinkAssign - Assigns the given bundle to the given Member Stack* * * This function can be used to assign an already existing Member Stack to a * particular bundle. This function takes stack obj of the Member Stack that need * to be assigned to the bundle and the Manager Stack obj of the bundle to which * the link has to be assigned. This function removes known conflicting * components from the Member Stack, retrieves Bundle LCP profiles from the * Manager Stack through MP_BUNDLE_MANAGEMENT_INTERFACE and reconfigures the LCP* in the Member Stack with the retrieved values. * * RETURNS: OK or ERROR*/STATUS mpLinkAssign ( PFW_STACK_OBJ *pMemberStackObj, /*stack obj representing the link*/ PFW_STACK_OBJ *pManagerStackObj /*stack obj representing the bundle*/ ) { PFW_PLUGIN_OBJ *pPluginObj = NULL; LCP_BUNDLE_PROFILE lcpBundleProfile; PFW_OBJ *pfwObj = NULL; PFW_PLUGIN_OBJ_STATE *pMpFramingLayerState = NULL; MP_FRAMING_LAYER_STACK_DATA *pMpFramingLayerStackData = NULL; char profileString [MAX_PROFILE_PARAM_LENGTH]; char temp[MAX_PROFILE_PARAM_LENGTH]; unsigned int paramId = 0; BYTE eidClass; char * cptr_parameter = NULL; if ((pMemberStackObj == NULL) || (pManagerStackObj == NULL)) return ERROR; bzero (profileString, sizeof (profileString)); bzero (temp, sizeof (temp)); bzero ((char *)&lcpBundleProfile, sizeof (lcpBundleProfile)); /* Get the reference to the framework */ pfwObj = pfwStackObjPfwGet (pMemberStackObj); if (pfwObj == NULL) { pfwPrintError (__FILE__, "mpLinkAssign",__LINE__, 0, 0, \ "NULL Framework reference"); return ERROR; } if (mpStackConvert (pMemberStackObj) == ERROR) { pfwPrintError (__FILE__, "mpLinkAssign",__LINE__, 0, 0, \ "MP stack convertion failed"); return ERROR; } /* Get pluginObj state of the mpFraming layer in the manager stack */ pPluginObj = pfwPluginObjGet (pfwObj, "MP_FRAMING_LAYER"); pMpFramingLayerState = pfwPluginObjStateGet (pManagerStackObj, pPluginObj); if (pMpFramingLayerState == NULL) { printf ("MP:mpLinkAssign(): mpFraming layer does not exist in the stack \ %x\n", (int) pManagerStackObj); return ERROR; } pMpFramingLayerStackData = (MP_FRAMING_LAYER_STACK_DATA *) pMpFramingLayerState->stackData; /* Retrieve the bundle profile */ /* * If the bundle is closed, bundle profile is not available. Get the * profile by reading the existing profile configurations in the manager * Stack */ if (pMpFramingLayerStackData->bundle_state == MP_BUNDLE_CLOSED_STATE) { bzero (profileString, sizeof (profileString)); paramId = pfwParameterIdGet (pfwObj, "lcp_ML_maxRcvdReconstructedUnit"); pfwStackParamGet (pManagerStackObj, paramId, profileString); mpStackOptionSet (pMemberStackObj, profileString, paramId); bzero (profileString, sizeof (profileString)); paramId = pfwParameterIdGet (pfwObj, "lcp_ML_shortSeqNumberHdrFormat"); pfwStackParamGet (pManagerStackObj, paramId, profileString); mpStackOptionSet (pMemberStackObj, profileString, paramId); bzero (profileString, sizeof (profileString)); paramId = pfwParameterIdGet (pfwObj, "lcp_endpointDiscriminator"); pfwStackParamGet (pManagerStackObj, paramId, profileString); mpStackOptionSet (pMemberStackObj, profileString, paramId); bzero (profileString, sizeof (profileString)); paramId = pfwParameterIdGet (pfwObj, "lcp_authProtocol"); pfwStackParamGet (pManagerStackObj, paramId, profileString); mpStackOptionSet (pMemberStackObj, profileString, paramId); if (mpSetPortToBundleMapping (pMemberStackObj, pManagerStackObj) == FAIL) return ERROR; return OK; } /* * Get the bundle profiles from the manager stack with the interface * provided */ mpBundleProfileGet (pMpFramingLayerState, &lcpBundleProfile); /* Configure the Member Stack with the Manager Stack Profile */ /* Configure MRRU */ /* * All member links should have the same Local End MRRU and same * Remote End MRRU */ /* Local MRRU */ bzero (temp, sizeof (temp)); bzero (profileString, sizeof (profileString)); strcpy (profileString, "Local:Negotiation Required, Not Negotiable:"); sprintf (temp, "%ld", lcpBundleProfile.localMRRU); strcat (profileString, temp); paramId = pfwParameterIdGet (pfwObj, "lcp_ML_maxRcvdReconstructedUnit"); pfwStackParamSet (pMemberStackObj, paramId, "Local:"); pfwStackParamSet (pMemberStackObj, paramId, profileString); /* Remote MRRU */ bzero (temp, sizeof (temp)); bzero (profileString, sizeof (profileString)); strcpy (profileString, "Remote:Negotiation Required, Not Negotiable:"); sprintf (temp, "%ld", lcpBundleProfile.remoteMRRU); strcat (profileString, temp); paramId = pfwParameterIdGet (pfwObj, "lcp_ML_maxRcvdReconstructedUnit"); pfwStackParamSet (pMemberStackObj, paramId, "Remote:"); pfwStackParamSet (pMemberStackObj, paramId, profileString); /* SSNHF */ /* * All member links should use the same local end packet format and same * remote end packet format */ /* Local End SSNHF */ bzero (profileString, sizeof (profileString)); if (lcpBundleProfile.use_short_sequence_number_in_local_end == TRUE) strcpy (profileString, "Local:Negotiation Required, Not Negotiable:1"); else strcpy (profileString, "Local:"); paramId = pfwParameterIdGet (pfwObj, "lcp_ML_shortSeqNumberHdrFormat"); pfwStackParamSet (pMemberStackObj, paramId, "Local:"); pfwStackParamSet (pMemberStackObj, paramId, profileString); /* Remote End SSNHF */ bzero (profileString, sizeof (profileString)); if (lcpBundleProfile.use_short_sequence_number_in_remote_end == TRUE) strcpy (profileString, "Remote:Negotiation Required, Not Negotiable:1"); else strcpy (profileString, "Remote:"); paramId = pfwParameterIdGet (pfwObj, "lcp_ML_shortSeqNumberHdrFormat"); pfwStackParamSet (pMemberStackObj, paramId, "Remote:"); pfwStackParamSet (pMemberStackObj, paramId, profileString); /* EID */ paramId = pfwParameterIdGet (pfwObj, "lcp_endpointDiscriminator");
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?