⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 portmanagerserial.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
* the link to a particular bundle in the MP system. This function also * activate the reserved port and wait for the peer to call for making the * physical link up on the reserved port. * In case of multiple ports in the list portListToCall, implementation should * give provision for waiting in the multiple ports for peer to call. The port* in which the peer calls succesfully the stackObj of that particular port* should be set in the port information of the port list.** RETURNS: Pointer to the PFW_STACK_OBJ structre or NULL** SEE ALSO: pmPortReserve, pmPortUnreserve*/PFW_STACK_OBJ *pmPortActivateAndWait    (	SL_LIST			   *portListToCall,	PFW_STACK_OBJ			*pBundleId    )    {	PFW_STACK_OBJ	*pPortStack;	PORT_CONNECTION_INFO *pPortConnectionInfo;	pPortConnectionInfo = (PORT_CONNECTION_INFO *) SLL_FIRST (portListToCall);	pPortStack = pfwStackAdd (pPortConnectionInfo->linkProfileObj, NULL, NULL);	if (pPortStack == NULL)		{		logMsg ("\n PM pmPortActivateAndWait : stack Add returned NULL \n",1,2,3,4,5,6);		return (NULL);		}	if (apiMpLinkAssign (pPortStack, pBundleId) != OK)		{		logMsg ("Assign link to bundle failed \n",1,2,3,4,5,6);		return (NULL);		}	/* save the stack object in the port connection info */	pPortConnectionInfo->linkStackObj = pPortStack; 	/* open the connection */ 	taskDelay (300); #ifdef PPP_DEBUG	logMsg ("\n PM pmPortActivateAndWait : Calling PPP Connection open \n",1,2,3,4,5,6);#endif 	pppConnectionOpen (pPortStack, NULL, NULL);	return pPortStack;    }/********************************************************************************* pmPortUnreserve - unreserve the port** This function is used to unreserve a previously reserved port. It takes the * PORT_CONNECTION_INFO as the input parameter and it searches through the list* of ports available in the system. It marks the PORT as unreserved once it * finds the matching port type, bandwidth and number and returns OK. If the * port is not found in the list, it returns ERROR.** RETURNS: OK or ERROR** SEE ALSO: pmPortReserve*/STATUS pmPortUnreserve    (	PORT_CONNECTION_INFO	*pPortUnreserve    )    {	LINK_INFO *pLinkInfo;			pLinkInfo = (LINK_INFO *)SLL_FIRST (&portList);	while (pLinkInfo != NULL)		{		if ((pLinkInfo->bandwidth == pPortUnreserve->port_speed) &&			(pLinkInfo->port_number == pPortUnreserve->port_number) &&			(pLinkInfo->port_type == pPortUnreserve->port_type) &&			(pLinkInfo->isPortUsed == TRUE))			{			pLinkInfo->isPortUsed = FALSE;#ifdef PPP_DEBUG			logMsg ("Port Unreserved %d and Bandwidth %d \n", \	             pPortUnreserve->port_number, pPortUnreserve->port_speed,3,4,5,6);	#endif			return OK;			}				pLinkInfo = (LINK_INFO *)SLL_NEXT (pLinkInfo);		}#ifdef PPP_DEBUG	logMsg ("Port with Port Number %d Port Type %d and Bandwidth %d is not \	present/free in the system \n",pPortUnreserve->port_number, pPortUnreserve->port_type, \	pPortUnreserve->port_speed,4,5,6);	#endif		return ERROR;    }/********************************************************************************* pmPortUnreserveByPort - unreserve the port** This function is used to unreserve a previously reserved port. It takes the * portNumber as the input parameter and it searches through the list of ports * available in the system. It marks the PORT as unreserved once it finds the * matching port type, bandwidth and number and returns OK. If the port is not * found in the list, it returns ERROR.** RETURNS: OK or ERROR** SEE ALSO: pmPortUnreserveByPort*/STATUS pmPortUnreserveByPort    (	USHORT portNumber,	PFW_STACK_OBJ * pfwStackObj    )    {	LINK_INFO *pLinkInfo;			pLinkInfo = (LINK_INFO *)SLL_FIRST (&portList);	while (pLinkInfo != NULL)		{		if ((pLinkInfo->port_number == portNumber) &&			(pLinkInfo->isPortUsed == TRUE))			{			pLinkInfo->isPortUsed = FALSE;#ifdef PPP_DEBUG			logMsg ("Port Unreserved %d and Bandwidth %d\n", \	             pLinkInfo->port_number, pLinkInfo->bandwidth,3,4,5,6);	#endif			return OK;			}				pLinkInfo = (LINK_INFO *)SLL_NEXT (pLinkInfo);		}#ifdef PPP_DEBUG	logMsg ("Port with Port Number %d, Port Type %d and Bandwidth %d \             is not present/free in the system\n", \             pLinkInfo->port_number, pLinkInfo->port_type, \			 pLinkInfo->bandwidth,4,5,6);	#endif	return ERROR;    }/********************************************************************************* pmPortToListAdd - add a port to the port list** This function is used to add ports to the port list in the Port Manager. It * checks if the list is empty, if it is empty, it initializes the list and then* adds the port to the list, else it adds the port at the end of the list.* RETURNS: OK or ERROR** SEE ALSO: pmPortListPrint*/STATUS pmPortToListAdd    (	LINK_INFO	*pLinkInfo    )    {	if (SLL_EMPTY(&portList) == TRUE)		{		sllInit (&portList);		sllPutAtTail (&portList, (SL_NODE *) pLinkInfo);		}	else		{		if (pmPortListSearch (pLinkInfo->port_number) == OK)			sllPutAtTail (&portList, (SL_NODE *) pLinkInfo);		else			{			/* if the port already exists in the list */#ifdef PPP_DEBUG			logMsg ("Port Number [%u] already exists in the \							Port Manager \n",pLinkInfo->port_number,2,3,4,5,6);#endif			if (pfwProfileDelete (pLinkInfo->pLinkProfileObj) == ERROR) 				logMsg ("pmPortListDelete: Error in deleting the profile\n",1,2,3,4,5,6);             if (pLinkInfo != NULL)                {                pfwFree (pLinkInfo);                pLinkInfo = NULL;                }            return (ERROR);			}		}			return (OK);    }/********************************************************************************* pmPortListSearch - search port in the port list for the given port number** This function is used to search the port list in the Port Manager for the given* port number. ** RETURNS: OK or ERROR*/LOCAL STATUS pmPortListSearch    (	USHORT portNumberToSearch	    )    {	LINK_INFO	*pLinkInfo;	pLinkInfo = (LINK_INFO *)SLL_FIRST (&portList);	while (pLinkInfo != NULL)		{		if (pLinkInfo->port_number == portNumberToSearch)			return ERROR;		pLinkInfo = (LINK_INFO *)SLL_NEXT (pLinkInfo);						}	return (OK);    }/********************************************************************************* pmPortListDelete - delete the port in the port list for the given port number** This function is used to delete a port in the Port Manager for the given* port number. ** RETURNS: OK or ERROR*/STATUS pmPortListDelete    (	USHORT portNumberToDelete	    )    {	LINK_INFO	*pLinkInfo;	pLinkInfo = (LINK_INFO *)SLL_FIRST (&portList);	while (pLinkInfo != NULL)		{		if (pLinkInfo->port_number == portNumberToDelete)			{#ifdef PPP_DEBUG			logMsg ("pmPortListDelete: Deleting the port %d from the \										port list\n", pLinkInfo->port_number,2,3,4,5,6);#endif			sllRemove (&portList, (SL_NODE *)pLinkInfo, NULL);			if (pfwProfileDelete (pLinkInfo->pLinkProfileObj) == ERROR) 				logMsg ("pmPortListDelete: Error in deleting the profile\n",1,2,3,4,5,6);             if (pLinkInfo != NULL)               {               pfwFree (pLinkInfo);               pLinkInfo = NULL;               }            return OK;			}		pLinkInfo = (LINK_INFO *)SLL_NEXT (pLinkInfo);						}	return (ERROR);    }/********************************************************************************* pmPortListPrint - display the details of the port list** This function is used to display the details of all the ports in the Port * Manager.** RETURNS: N/A** SEE ALSO: */void pmPortListPrint ( )    {	LINK_INFO * pLinkInfo;	pLinkInfo = (LINK_INFO *) SLL_FIRST (&portList);		if (pLinkInfo == NULL)		{		logMsg ("\n There are no ports in the port list\n",1,2,3,4,5,6);		return;		}	while (pLinkInfo != NULL)		{		printf ("\n\n");		printf ("********************Port Manager Details********************");		printf ("\nPort Number is : %d\n", pLinkInfo->port_number);		if (pLinkInfo->isPortUsed == TRUE)			printf ("Port usage is  : RESERVED \n");		else			printf ("Port usage is  : UNRESERVED \n");		switch (pLinkInfo->port_type)			{			case 0x01:					printf ("Port Type is   : %s\n", "ISDN");				break;			case 0x02:				printf ("Port Type is   : %s\n", "X.25");				break;			case 0x04:				printf ("Port Type is   : %s\n", "ANALOG");				break;			case 0x08:				printf ("Port Type is   : %s\n", "SWITCHED DIGITAL");				break;			case 0x10:				printf ("Port Type is   : %s\n", "ISDN DOV");				break;			case 0xFF:				printf ("Port Type is   : %s\n", "DEDICATED");				break;			default:				printf ("Port Type is   : %s\n", "RESERVED");				break;			}		switch (pLinkInfo->port_dial_type)			{			case 0x0:					printf ("Dial Type is   : %s\n", "PORT_DEDICATED");				break;			case 0x1:				printf ("Dial Type is   : %s\n", "PORT_DIAL_IN");				break;			case 0x2:				printf ("Dial Type is   : %s\n", "PORT_DIAL_OUT");				break;			case 0x3:				printf ("Dial Type is   : %s\n", "PORT_DIAL_IN_AND_OUT");				break;			default:				printf ("Dial Type is   : %s\n", "INVALID");				break;			}				switch (pLinkInfo->port_dial_status)			{			case 0x0:					printf ("Port Dial Status is : %s\n", "PORT_DIAL_DISCONNECTED");				break;			case 0x1:				printf ("Port Dial Status is : %s\n", \                        "PORT_DIAL_WAITING_CONNECT_CMD");				break;			case 0x2:				printf ("Port Dial Status is : %s\n", "PORT_DIAL_CONNECTING");				break;			case 0x3:				printf ("Port Dial Status is : %s\n", "PORT_DIAL_CONNECTED");				break;			case 0x4:				printf ("Port Dial Status is : %s\n", \                        "PORT_DIAL_DISCONNECTING");				break;			default:				printf ("Dial Type is   : %s\n", "INVALID");				break;			}						printf ("Bandwidth supported is : %d\n", pLinkInfo->bandwidth);				printf ("Port LOCAL phone number is : %s\n", \								pLinkInfo->port_local_phone_number);				printf ("Port REMOTE phone number is : %s\n", \								pLinkInfo->port_remote_phone_number);				printf ("Port sub address phone number is : %s\n", \								pLinkInfo->port_subaddress_phone_number);				printf ("Port unique digit phone number length is : %d\n", \							pLinkInfo->port_unique_digits_phone_number_length);				printf ("Port unique digit phone number is : %s\n", \								pLinkInfo->port_unique_digits_phone_number);				printf ("********************Port Manager Details********************");		printf ("\n\n");		pLinkInfo = (LINK_INFO *)SLL_NEXT (pLinkInfo);		}    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -