📄 mpapi.c
字号:
mpBundleClose (pManagerStackObj); } /* Get MP FRAMING LAYER COMPONENT structure address */ mpFramingComponent = (MP_FRAMING_LAYER *) mpFramingLayerPluginObjState->pluginObj; if (semTake (mpFramingComponent->componentSem, WAIT_FOREVER) == ERROR) return ERROR; /* remove the entry from the port_to_bundle_assignment array */ for (bundleIndex = 0; bundleIndex < MAX_NO_OF_PPP_PORTS; bundleIndex ++) { if (mpFramingComponent->port_to_bundle_assignment [bundleIndex]. pManagerStackObj == pManagerStackObj) { mpFramingComponent->port_to_bundle_assignment[bundleIndex]. port_used_in_sending_end = FALSE; mpFramingComponent->port_to_bundle_assignment[bundleIndex]. port_used_in_receiving_end = FALSE; mpFramingComponent->port_to_bundle_assignment[bundleIndex]. is_port_assigned_to_a_bundle = FALSE; } } if (semGive (mpFramingComponent->componentSem) == ERROR) return ERROR; /* Delete the manager stack */ if (pfwStackDelete (pManagerStackObj) == ERROR) { return ERROR; } return OK; }/******************************************************************************** apiMpLinkAssign - 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 calls mpLinkAssign () of the * MP_BUNDLE_MANAGEMENT interface to assign the link to the bundle.** RETURNS: OK/ERROR*/STATUS apiMpLinkAssign ( PFW_STACK_OBJ *pMemberStackObj, /* member stack object */ PFW_STACK_OBJ *pManagerStackObj /* manger stack object */ ) { if ((pMemberStackObj == NULL) || (pManagerStackObj == NULL)) return ERROR; /* Assign the given link to the given bundle */ if (mpLinkAssign (pMemberStackObj, pManagerStackObj) == OK) return OK; return ERROR; }/******************************************************************************** mpLinkAdd - Adds the link to the given bundle * * 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 calls mpLinkAssign () of the * MP_BUNDLE_MANAGEMENT interface to assign the link to the bundle.** RETURNS: PFW_STACK_OBJ * or NULL*/PFW_STACK_OBJ * mpLinkAdd ( PFW_PROFILE_OBJ *pProfileObj, /* profile for Member Stack */ PFW_STACK_OBJ_CALLBACKS * callbacks, /* Callback functions */ void *userHandle ) { PFW_OBJ * pfwFrameworkObj = NULL; PFW_STACK_OBJ * pMemberStackObj = NULL; unsigned int paramId = 0; char paramBuffer[MAX_PROFILE_PARAM_LENGTH]; PFW_STACK_OBJ * pManagerStackObj = NULL; if (pProfileObj == NULL) return NULL; bzero (paramBuffer, sizeof (paramBuffer)); pfwFrameworkObj = pfwProfilePfwObjGet (pProfileObj); if (pfwFrameworkObj == NULL) return NULL; pMemberStackObj = pfwStackAdd (pProfileObj, callbacks, userHandle); if (pMemberStackObj == NULL) return NULL; paramId = pfwParameterIdGet (pfwFrameworkObj, "mpInterface_managerStackId"); if (paramId == 0) return NULL; if (pfwStackParamGet (pMemberStackObj, paramId, paramBuffer) == ERROR) return NULL; pManagerStackObj = (PFW_STACK_OBJ *) atoi (paramBuffer); /* Assign the given link to the given bundle */ if (mpLinkAssign (pMemberStackObj, pManagerStackObj) == OK) { if (pppConnectionOpen (pMemberStackObj, NULL, NULL) == OK) { return pMemberStackObj; } } return NULL; }/******************************************************************************** mpBundleListShow - List information about all the bundle in the framework * * This function prints the Manager Stack Obj, no of links in the bundle, * sending_end details and receiving end details of all the links in the bundle.** RETURNS: OK/ERROR*/STATUS mpBundleListShow ( PFW_OBJ * pfwObj /* framework object */ ) { PFW_PLUGIN_OBJ * pluginObj = NULL; PFW_PLUGIN_OBJ_STATE * mpFramingLayerPluginObjState = NULL; MP_FRAMING_LAYER_STACK_DATA * pFramingLayerStackData = NULL; MP_FRAMING_LAYER * mpFramingComponent = NULL; MP_DISCRIMINATOR_CLASS bundleLocalDiscriminator; MP_DISCRIMINATOR_CLASS bundleRemoteDiscriminator; MP_BUNDLE_RECEIVING_END_CLASS recvEndClass; MP_BUNDLE_SENDING_END_CLASS sendEndClass; USHORT numberOfBundles = 0; USHORT bundleIndex = 0; if (pfwObj == NULL) { printf ("Invalid argument : NULL framework object\nUsage: mpBundleListShow <Framework Object>\n"); return ERROR; } pluginObj = pfwPluginObjGet (pfwObj, "MP_FRAMING_LAYER"); mpFramingComponent = (MP_FRAMING_LAYER *) pluginObj; if (semTake (mpFramingComponent->componentSem, WAIT_FOREVER) == ERROR) return ERROR; numberOfBundles = mpFramingComponent->no_of_bundles; printf ("Total number of bundles are %d\n",numberOfBundles); for (bundleIndex = 0; bundleIndex < numberOfBundles; bundleIndex ++) { mpFramingLayerPluginObjState = mpFramingComponent-> pMpFramingLayerState[bundleIndex]; if (pfwPluginObjStateLock (mpFramingLayerPluginObjState) == ERROR) { if (semGive (mpFramingComponent->componentSem) == ERROR) return ERROR; return ERROR; } pFramingLayerStackData = mpFramingLayerPluginObjState->stackData; printf ("\n\n"); printf ("Bundle Details :\n"); printf ("--------------- \n"); printf ("Bundle Number is : %d\n",bundleIndex); printf ("Bundle Stack Object : 0x%x\n",\ (int)mpFramingLayerPluginObjState->stackObj); if (pFramingLayerStackData->bundle_state == 0) printf ("Bundle State is : BUNDLE_CLOSED_STATE\n"); else printf ("Bundle State is : BUNDLE_OPENED_STATE\n"); printf ("Number of links in Bundle : %d\n",\ pFramingLayerStackData->bundle.no_of_links); printf ("Bundle Identifier Details :\n"); printf ("-------------------------- \n"); bundleLocalDiscriminator = pFramingLayerStackData->bundle.id.local_station_discriminator; bundleRemoteDiscriminator = pFramingLayerStackData->bundle.id.remote_station_discriminator; printDiscriminator (pfwObj, bundleLocalDiscriminator, TRUE); printf ("Local User Name : %s\n", pFramingLayerStackData->bundle.id.local_user_name); printDiscriminator (pfwObj, bundleRemoteDiscriminator, FALSE); printf ("Remote User Name : %s\n", pFramingLayerStackData->bundle.id.remote_user_name); printf ("Bundle Receiving End Details :\n"); printf ("----------------------------- \n"); recvEndClass = pFramingLayerStackData->bundle.receiving_end; printf ("Number of links : %u\n",recvEndClass.no_of_links); printf ("Local MRRU : %lu\n",recvEndClass.localMRRU); if (recvEndClass.use_short_sequence_number == TRUE) printf ("Receiving End Uses Short Sequence Number Header Format\n"); else printf ("Receiving End Uses Long Sequence Number Header Format\n"); printf ("Bundle Sending End Details :\n"); printf ("----------------------------- \n"); sendEndClass = pFramingLayerStackData->bundle.sending_end; printf ("Number of links : %u\n",sendEndClass.no_of_links); printf ("Remote MRRU : %lu\n",sendEndClass.remoteMRRU); if (sendEndClass.use_short_sequence_number == TRUE) printf ("Sending End Uses Short Sequence Number Header Format\n"); else printf ("Sending End Uses Long Sequence Number Header Format\n"); if (pfwPluginObjStateRelease (mpFramingLayerPluginObjState) == ERROR) { if (semGive (mpFramingComponent->componentSem) == ERROR) return ERROR; return ERROR; } } if (semGive (mpFramingComponent->componentSem) == ERROR) return ERROR; return OK; }/******************************************************************************** printDiscriminator - 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** RETURNS N/A*/LOCAL void printDiscriminator ( PFW_OBJ * pfwObj, MP_DISCRIMINATOR_CLASS mpDiscriminator, BOOL local ) { int loopIndex = 0; ULONG magicNumber = 0; struct in_addr iaddr; char *str, addr[20]; char *dot="."; int i; if (local == TRUE) printf ("Local Discriminator Class : %d\n", mpDiscriminator.discriminatorClass); else printf ("Remote Discriminator Class : %d\n", mpDiscriminator.discriminatorClass); switch (mpDiscriminator.discriminatorClass) { case 0: printf ("Local Discriminator Address : 0\n"); break; case 1: if (local == TRUE) printf ("Local Discriminator Address :"); else printf ("Remote Discriminator Address :"); for (i = 0; i<mpDiscriminator.length; i++) { printf ("%02x",mpDiscriminator.address[i]); } printf ("\n"); break; case 2: str = (char *) pfwMalloc (pfwObj, 20); bzero (addr,sizeof(addr)); for (loopIndex = 0; loopIndex <= 3; loopIndex++) { sprintf (str, "%d",mpDiscriminator.address[loopIndex]); strcat (addr, str); if (loopIndex != 3) strcat (addr,dot); } iaddr.s_addr = ntohl((inet_network (addr))); if (local == TRUE) printf ("Local Discriminator Address : %s\n",inet_ntoa (iaddr)); else printf ("Remote Discriminator Address : %s\n",inet_ntoa (iaddr)); if (str != NULL) { pfwFree (str); str = NULL; } break; case 3: if (local == TRUE) { printf ("Local Discriminator Address : "); for (loopIndex = 0; loopIndex <= 5; loopIndex++) { if (loopIndex != 5) printf ("%x:",mpDiscriminator.address[loopIndex]); else printf ("%x\n",mpDiscriminator.address[loopIndex]); } } else { printf ("Remote Discriminator Address : "); for (loopIndex = 0; loopIndex <= 5; loopIndex++) { if (loopIndex != 5) printf ("%x:",mpDiscriminator.address[loopIndex]); else printf ("%x\n",mpDiscriminator.address[loopIndex]); } } break; case 4: if (local == TRUE) { printf ("Local Discriminator Address : "); for (loopIndex = 0; loopIndex < mpDiscriminator.length; loopIndex = loopIndex + 4) { 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)); } } else { printf ("Remote Discriminator Address : "); for (loopIndex = 0; loopIndex < mpDiscriminator.length; loopIndex = loopIndex + 4)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -