📄 mpapi.c
字号:
{ magicNumber = 0;#if (_BYTE_ORDER == _BIG_ENDIAN) /* big endian support */ magicNumber = (magicNumber |((ULONG)mpDiscriminator.address [loopIndex +3])) | ((ULONG)mpDiscriminator.address [loopIndex+2] << 8) | ((ULONG)mpDiscriminator.address [loopIndex+1] << 16) | (mpDiscriminator.address [loopIndex] << 24);#else magicNumber = (magicNumber |((ULONG)mpDiscriminator.address [loopIndex +3] << 24)) | ((ULONG)mpDiscriminator.address [loopIndex+2] << 16) | ((ULONG)mpDiscriminator.address [loopIndex+1] << 8) | (mpDiscriminator.address [loopIndex]);#endif if ((loopIndex + 4) < mpDiscriminator.length) printf ("%ld:",ntohl(magicNumber)); else printf ("%ld\n",ntohl(magicNumber)); } } break; case 5: if (local == TRUE) printf ("Local Discriminator Addres : %s\n",mpDiscriminator.address); else printf ("Remote Discriminator Addres : %s\n",mpDiscriminator.address); break; default : printf ("Invalid EID to print\n"); break; } }/******************************************************************************** mpMemberList - Lists the details of the links in the bundle* * This function lists stack objs of the links in the bundle and specifies * whether the link is in sending end and receiving end of the bundle.** RETURNS: OK/ERROR*/STATUS mpMemberList ( PFW_STACK_OBJ *pManagerStackObj /* member stack object */ ) { PFW_OBJ * pfwFrameworkObj = NULL; PFW_PLUGIN_OBJ * pluginObj = NULL; PFW_PLUGIN_OBJ_STATE * mpFramingLayerPluginObjState = NULL; MP_FRAMING_LAYER_STACK_DATA * pFramingLayerStackData = NULL; USHORT linkIndex = 0; USHORT numberOfLinks = 0; MP_PORT_CLASS memberLinkInfo; if (pManagerStackObj == NULL) { printf ("mpAPI:Invalid Paramters\n"); return ERROR; } pfwFrameworkObj = pfwStackObjPfwGet (pManagerStackObj); pluginObj = pfwPluginObjGet (pfwFrameworkObj, "MP_FRAMING_LAYER"); if ((mpFramingLayerPluginObjState = pfwPluginObjStateGet (pManagerStackObj, pluginObj)) == NULL) { printf (" MP Framing Layer Plugin Object State is NULL \n"); return ERROR; } if (pfwPluginObjStateLock (mpFramingLayerPluginObjState) == ERROR) return ERROR; pFramingLayerStackData = mpFramingLayerPluginObjState->stackData; /* Printing the Bundle details */ printf ("\n\n"); printf ("Bundle Details :\n"); printf ("--------------- \n"); printf ("Bundle Stack Object : 0x%x\n",(int)pManagerStackObj); if (pFramingLayerStackData->bundle_state == 0) printf ("Bundle State is : BUNDLE_CLOSED_STATE\n"); else printf ("Bundle State is : BUNDLE_OPENED_STATE\n"); numberOfLinks = pFramingLayerStackData->bundle.no_of_links; printf ("Number of links in Bundle : %u\n",numberOfLinks); /* Printing the link details within this manager stack or bundle */ printf ("\n"); printf ("Bundle Link Details :\n"); printf ("-------------------- \n"); for (linkIndex = 0; linkIndex < numberOfLinks; linkIndex++) { memberLinkInfo = pFramingLayerStackData->bundle.memberLinks[linkIndex]; printf ("Link Number is : %d\n",linkIndex); printf ("Link Member Stack Object is : 0x%x\n", (int) memberLinkInfo.pMemberStackObj); if (memberLinkInfo.pLcpBundleOptions->is_link_in_sending_end == TRUE) { if (memberLinkInfo.pLcpBundleOptions->is_link_in_receiving_end == TRUE) { printf ("Link is used for both Sending and Receving\n"); } else { printf ("Link is used for Sending only\n"); } } else { if (memberLinkInfo.pLcpBundleOptions->is_link_in_receiving_end == TRUE) { printf ("Link is used for receving only\n"); } else { printf ("Link is neither used for Sending nor Receving\n"); } } } if (pfwPluginObjStateRelease (mpFramingLayerPluginObjState) == ERROR) return ERROR; return OK; }/******************************************************************************** mpFindAPortToBundleMapping - Gets port to bundle assignment* * Checks whether the given link is there in any of the bundle. If so, it gets * the bundle number and returns PASS. Otherwise, it returns FAIL.** RETURNS: PASS/FAIL*/TEST mpFindAPortToBundleMapping ( PFW_STACK_OBJ *pMemberStackObj, /* member stack object */ PFW_STACK_OBJ **pManagerStackObj /* manager stack object */ ) { PFW_OBJ * pfwFrameworkObj = NULL; PFW_PLUGIN_OBJ * pluginObj = NULL; MP_FRAMING_LAYER * mpFramingComponent = NULL; int found = 0; USHORT bundleIndex = 0; MP_BUNDLE_ASSIGNMENT_CLASS *pPortToBundleAssignment = NULL; if ((pMemberStackObj == NULL) || (pManagerStackObj == NULL)) return FAIL; pfwFrameworkObj = pfwStackObjPfwGet (pMemberStackObj); pluginObj = pfwPluginObjGet (pfwFrameworkObj, "MP_FRAMING_LAYER"); /* Get MP FRAMING LAYER COMPONENT structure address */ mpFramingComponent = (MP_FRAMING_LAYER *) pluginObj; if (semTake (mpFramingComponent->componentSem, WAIT_FOREVER) == ERROR) return FAIL; for (bundleIndex = 0; bundleIndex <mpFramingComponent->no_of_ports; bundleIndex ++) { pPortToBundleAssignment = &mpFramingComponent->port_to_bundle_assignment[bundleIndex]; if (pPortToBundleAssignment->pMemberStackObj == pMemberStackObj) { found = 1; break; } } if (found == 0) { printf ("Cannot find a link in the BUNDLE \n"); if (semGive (mpFramingComponent->componentSem) == ERROR) return FAIL; return FAIL; } if (pPortToBundleAssignment->is_port_assigned_to_a_bundle == TRUE) { *pManagerStackObj = pPortToBundleAssignment->pManagerStackObj; if (semGive (mpFramingComponent->componentSem) == ERROR) return FAIL; return PASS; } if (semGive (mpFramingComponent->componentSem) == ERROR) return FAIL; return FAIL; }/******************************************************************************** mpSetPortToBundleMapping - set port to bundle assignment* * Checks if the Member Stack has an entry in the port_to_bundle_assignment * array. If entry exists, it replaces the entry with the new port-to-bundle * assignment. Otherwise, it creates a new entryand set the assignment. If * existing number of entries are equal to MAN_NO_OF_PPP_PORTS, this function * will return an ERROR.** RETURNS: PASS/FAIL*/TEST mpSetPortToBundleMapping ( PFW_STACK_OBJ *pMemberStackObj, /* member stack object */ PFW_STACK_OBJ *pManagerStackObj /* manager stack object */ ) { PFW_OBJ * pfwFrameworkObj = NULL; PFW_PLUGIN_OBJ * pluginObj = NULL; MP_FRAMING_LAYER * mpFramingComponent = NULL; int found = 0; USHORT loopIndex = 0; char profileString [MAX_VALUE_STRING_LENGTH]; UINT paramId = 0; if ((pMemberStackObj == NULL) || (pManagerStackObj == NULL)) { printf ("mpAPI: Invalid Parameters\n"); return ERROR; } bzero (profileString, sizeof (profileString)); pfwFrameworkObj = pfwStackObjPfwGet (pMemberStackObj); pluginObj = pfwPluginObjGet (pfwFrameworkObj, "MP_FRAMING_LAYER"); /* Get MP FRAMING LAYER COMPONENT structure address */ mpFramingComponent = (MP_FRAMING_LAYER *) pluginObj; if (semTake (mpFramingComponent->componentSem, WAIT_FOREVER) == ERROR) return FAIL; for (loopIndex = 0; loopIndex < mpFramingComponent->no_of_ports; loopIndex ++) { if (mpFramingComponent->port_to_bundle_assignment[loopIndex]. pMemberStackObj == pMemberStackObj) { found = 1; break; } } /* If member found, update portToBundleAssignment structure */ if (found) { mpFramingComponent->port_to_bundle_assignment[loopIndex]. is_port_assigned_to_a_bundle = TRUE; mpFramingComponent->port_to_bundle_assignment[loopIndex]. pManagerStackObj = pManagerStackObj; sprintf (profileString, "%d", (int) pManagerStackObj); paramId = pfwParameterIdGet (pfwFrameworkObj, "mpInterface_managerStackId"); pfwStackParamSet (pMemberStackObj, paramId, profileString); if (semGive (mpFramingComponent->componentSem) == ERROR) return FAIL; return PASS; } /* If no member found, add new entry to portToBundleAssignment structure */ if (mpFramingComponent->no_of_ports < MAX_NO_OF_PPP_PORTS ) { mpFramingComponent-> port_to_bundle_assignment[mpFramingComponent->no_of_ports]. pMemberStackObj = pMemberStackObj; mpFramingComponent-> port_to_bundle_assignment[mpFramingComponent->no_of_ports]. pManagerStackObj = pManagerStackObj; mpFramingComponent-> port_to_bundle_assignment[mpFramingComponent->no_of_ports]. is_port_assigned_to_a_bundle = TRUE; mpFramingComponent->no_of_ports++; /* Also update no of ports */ sprintf (profileString, "%d", (int) pManagerStackObj); paramId = pfwParameterIdGet (pfwFrameworkObj, "mpInterface_managerStackId"); pfwStackParamSet (pMemberStackObj, paramId, profileString); if (semGive (mpFramingComponent->componentSem) == ERROR) return FAIL; return PASS; } printf("Number of Port has exceeded MAX_NO_OF_PPP_PORTS limit \n"); if (semGive (mpFramingComponent->componentSem) == ERROR) return FAIL; return FAIL; }/******************************************************************************** mpRemovePortToBundleMapping - Remove the entry of the given Member Stack * from the Bundle Assignment array** This function has to be called by the application before a Member Stack is * deleted. MP implementation will not remove the entry of a member Stack when * the link is removed from its bundle.** RETURNS: OK/ERROR*/STATUS mpRemovePortToBundleMapping ( PFW_STACK_OBJ *pMemberStackObj /* member stack object */ ) { PFW_OBJ * pfwFrameworkObj = NULL; PFW_PLUGIN_OBJ * pluginObj = NULL; MP_FRAMING_LAYER * mpFramingComponent = NULL; USHORT loopIndex = 0; if (pMemberStackObj == NULL) return ERROR; pfwFrameworkObj = pfwStackObjPfwGet (pMemberStackObj); pluginObj = pfwPluginObjGet (pfwFrameworkObj, "MP_FRAMING_LAYER"); /* Get MP FRAMING LAYER COMPONENT structure address */ mpFramingComponent = (MP_FRAMING_LAYER *) pluginObj; if (semTake (mpFramingComponent->componentSem, WAIT_FOREVER) == ERROR) return ERROR; /* Remove the entry corresponding to pMemberStackObj */ for (loopIndex = 0; loopIndex < mpFramingComponent->no_of_ports; loopIndex ++) { if (mpFramingComponent->port_to_bundle_assignment[loopIndex]. pMemberStackObj == pMemberStackObj) { while (loopIndex < (mpFramingComponent->no_of_ports - 1)) { mpFramingComponent->port_to_bundle_assignment[loopIndex] = mpFramingComponent->port_to_bundle_assignment[loopIndex + 1]; loopIndex++; } mpFramingComponent->no_of_ports--; break; } } if (semGive (mpFramingComponent->componentSem) == ERROR) return ERROR; return OK; }/******************************************************************************** mpGetBundleState - returns the state of the bundle* * This function gets the state of the given bundle and returns the same.** RETURNS: MP_BUNDLE_STATE whether its Open or Closed
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -