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

📄 portmanagermodem.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
* 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;				/* delete the stack added for the link */				if (pPortUnreserve->linkStackObj != NULL)					{					printf ("\n Stack 0x%x populated  is deleted \n",pPortUnreserve->linkStackObj);					pfwStackDelete (pPortUnreserve->linkStackObj);					}				printf ("Port Unreserved %d and Bandwidth %d \n", \		             pPortUnreserve->port_number, pPortUnreserve->port_speed);					return OK;			}				pLinkInfo = (LINK_INFO *)SLL_NEXT (pLinkInfo);		}	printf ("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);			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;/* Modem Functionalities */				modemDisconnectTest (pfwStackObj);/* Modem Functionalities */				pfwStackDelete (pfwStackObj); 				printf ("Port Unreserved %d and Bandwidth %d\n", \		             pLinkInfo->port_number, pLinkInfo->bandwidth);					return OK;			}				pLinkInfo = (LINK_INFO *)SLL_NEXT (pLinkInfo);		}	printf ("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);		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			{			printf ("Port Number [%u] already exists in the Port Manager \n",pLinkInfo->port_number);			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/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);    }/********************************************************************************* 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)		{		printf ("\n There are no ports in the port list\n");		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 + -