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

📄 pppbaptx.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
							1, 2, 3, 4, 5, 6);#endif /* PPP_DEBUG */			pmPortUnreserve (port_info);			free_bap_buffer ((LINK *) &pStackData->call_request_send_queue,							bap_buffer);			if (pfwPluginObjStateRelease (pluginState) == ERROR) 				return ERROR;			return ERROR;			}		pfwSend (pluginState, packet);							pfwTimerCancel (pStackData->callRequestRetryTimer);		if (pfwTimerStart (pStackData->callRequestRetryTimer, PFW_100_MILLISECOND,			pProfileData->maximum_bap_call_request_send_interval * 10,			retry_bap_call_request, txIdentifier) == ERROR)			{			logMsg ("Call Request Timer start failed: \n",\					1, 2, 3, 4, 5, 6);			}		if (pfwPluginObjStateRelease (pluginState) == ERROR) 			return ERROR;		return OK;		}	else if (call_or_callback == BAP_CALLBACK_REQUEST)		{		port_info->port_speed = bandwidth;		port_info->port_dial_type = PORT_DIAL_IN;		/* save the port information to the temperory port list */				sllInit (&tempPortList);     	sllPutAtTail ((SL_LIST *)&tempPortList, (SL_NODE *) port_info);		/* For the request bandwidth reserve a port. If fail return */		if (pmFindAndReserveMultiplePort (pfwObj, &tempPortList) == ERROR) 			{#ifdef PPP_DEBUG    printf("BAP: In function BundleBandwidthAdd: Find and Reserve a port failed \n");#endif /* PPP_DEBUG */            if (port_info != NULL)                {                pfwFree (port_info);                port_info = NULL;                }			if (pfwPluginObjStateRelease (pluginState) == ERROR) 				return ERROR;			return ERROR;			}		txIdentifier = pStackData->last_bap_id++;		bap_buffer = bap_create_callback_request (pluginState,												  txIdentifier, 												  &tempPortList, reason_string, TRUE);		if (bap_buffer == NULL)			{#ifdef PPP_DEBUG    printf("BACP: In function BundleBandwidthAdd:Create CALLBACK REQ Packet failed \n");#endif /* PPP_DEBUG */			if (pfwPluginObjStateRelease (pluginState) == ERROR) 				return ERROR;			return ERROR;			}		/* Copy the port info from the tempPortList to bafbuffer's port list */						if (copyPortInfoToBapBuffer (pfwObj, 					&bap_buffer->port_list, &tempPortList) == ERROR) 			{			unreservePortInPortList (&tempPortList);			freeMemoryInPortList (&tempPortList);			if (pfwPluginObjStateRelease (pluginState) == ERROR) 				return ERROR;			return ERROR;			}		/* update the status */		bap_buffer->status  = BAP_CALLBACK_REQUEST_ALREADY_IN_PROGRESS;		/* add to call back request send queue */		add_entry_to_list ((LINK *) &pStackData->callback_request_send_queue, 												(LINK *) bap_buffer);		/* Updating BAP statistics */		pStackData->bap_statistics.number_of_tx_bytes += bap_buffer->bap->mBlkHdr.mLen;    	++pStackData->bap_statistics.number_of_tx_packets;    	++pStackData->bap_statistics.					number_of_control_tx_packets [BAP_CALLBACK_REQUEST];#ifdef PPP_DEBUG	    printf("BAP: Sending CALL BACK REQ Packet ID %d Length %u\n", \				txIdentifier, bap_buffer->bap->mBlkHdr.mLen);#endif /* PPP_DEBUG */		/* 		 * save the packet information after making a duplicate packet to 		 * callback_request_send_queue 		 */	 			packet = bap_buffer->bap;		bap_buffer->bap = bacpDupPkt (packet);		if (bap_buffer->bap == NULL)			{#ifdef PPP_DEBUG		logMsg ("bap_create_callback_request Packet duplication Error: \n",\				1, 2, 3, 4, 5, 6);#endif /* PPP_DEBUG */			unreservePortInPortList (&bap_buffer->port_list);			free_bap_buffer ((LINK *) &pStackData->callback_request_send_queue,							bap_buffer);			if (pfwPluginObjStateRelease (pluginState) == ERROR) 				return ERROR;			return ERROR;			}		pfwSend (pluginState, packet);		pfwTimerCancel (pStackData->callbackRequestRetryTimer);   		if (pfwTimerStart (pStackData->callbackRequestRetryTimer, 				PFW_100_MILLISECOND,				pProfileData->maximum_bap_callback_request_send_interval * 10, 				retry_bap_callback_request, txIdentifier) == ERROR )			{			logMsg ("Call Back Request Timer start failed: \n",\					1, 2, 3, 4, 5, 6);			}		if (pfwPluginObjStateRelease (pluginState) == ERROR) 			return ERROR;		return OK;		}	if (pfwPluginObjStateRelease (pluginState) == ERROR) 		return ERROR;	return ERROR;	}/******************************************************************************** bapBundleBandwidthDelete - delete the link with the specified bandwidth *																from the bundle** This routine is called to gracefully remove requested bandwidth from the * bundle.  It also finds the active port with the corresponding bandwidth, * creates link drop query request and sends the packet.The timer is started to * keep track number of request sent.   ** RETURNS: OK/ERROR*/STATUS bapBundleBandwidthDelete    	(	PFW_STACK_OBJ *managerStackObj,		/* manager stack object */	ULONG bandwidth,					/* bandwidth to be deleted */	char * reason_string				/* reason string */	)	{    PFW_PLUGIN_OBJ * pluginObj = NULL;    PFW_PLUGIN_OBJ_STATE * pluginState = NULL;    BACP_STACK_DATA *pStackData = NULL;    BACP_PROFILE_DATA * pProfileData = NULL;	PORT_CONNECTION_INFO *port_info = NULL;	BAP_BUFFER	* bap_buffer = NULL;	BAP_ACTIVE_PORT * ptr_port_to_drop = NULL;	M_BLK_ID packet = NULL;	BYTE txIdentifier;	    if ((pluginObj = pfwPluginObjGet (pfwStackObjPfwGet (managerStackObj), 										"PPP_BACP")) == NULL)		return ERROR;    if ((pluginState = pfwPluginObjStateGet (managerStackObj, 										pluginObj)) == NULL)		return ERROR;	if (pfwPluginObjStateLock (pluginState) == ERROR) 		return ERROR;    pStackData = (BACP_STACK_DATA *) pluginState->stackData;    pProfileData = (BACP_PROFILE_DATA *) pluginState->profileData;    if (pStackData->stateData.state != PPP_OPENED_STATE)		{		if (pfwPluginObjStateRelease (pluginState) == ERROR) 			return ERROR;		return ERROR;		}	ptr_port_to_drop = bap_find_active_port_with_this_bandwidth (										(LINK *) &pStackData->active_port_queue, 										(USHORT) bandwidth);	if(ptr_port_to_drop == NULL)		{		if (pStackData->bacpUpcall != NULL)			(*pStackData->bacpUpcall->bacpUpCallFunction) 					(managerStackObj, BAP_EVENT_BODA_REQUEST_NOT_PROCESSED,					bandwidth, NULL, 					0, &reason_string);		if (pfwPluginObjStateRelease (pluginState) == ERROR) 			return ERROR;		return ERROR;		}	/* populate port_info structure */   	if ((port_info =(PORT_CONNECTION_INFO *)pfwMalloc	       		(pluginState->pluginObj->pfwObj, sizeof(PORT_CONNECTION_INFO))) == NULL)   		{   		printf("PPP: could not allocate memory for new port connection info \n");			if (pfwPluginObjStateRelease (pluginState) == ERROR) 			return ERROR;   		return ERROR;   		}	port_info->next = NULL;	port_info->port_number = ptr_port_to_drop->port_number;	port_info->port_dial_status = PORT_DIAL_CONNECTED;	port_info->port_type = ptr_port_to_drop->port_bap_type;	port_info->port_lcp_local_link_discriminator = ptr_port_to_drop->port_bacp_local_discr;	port_info->port_lcp_remote_link_discriminator = ptr_port_to_drop->port_bacp_remote_discr;	txIdentifier = pStackData->last_bap_id++;	bap_buffer = bap_create_link_drop_request (pluginState, 												txIdentifier,												port_info, reason_string);	if (bap_buffer == NULL)		{#ifdef PPP_DEBUG    printf("BACP: In function BundleBandwidthDelete:Create LINK DROP REQ Packet failed \n");#endif /* PPP_DEBUG */		if (pfwPluginObjStateRelease (pluginState) == ERROR) 			return ERROR;		return (ERROR);		}	/* save all port information */		sllInit (&bap_buffer->port_list);     sllPutAtTail ((SL_LIST *)&bap_buffer->port_list, 			(SL_NODE *)port_info);	/* update the status */	bap_buffer->status = BAP_LINK_DROP_ALREADY_IN_PROGRESS;	/* add to link drop request send queue */	add_entry_to_list ((LINK *) &pStackData->link_drop_request_send_queue, 											(LINK *) bap_buffer);	/* Updating BAP statistics */	pStackData->bap_statistics.number_of_tx_bytes += bap_buffer->bap->mBlkHdr.mLen;    ++pStackData->bap_statistics.number_of_tx_packets;    ++pStackData->bap_statistics.					number_of_control_tx_packets [BAP_LINK_DROP_QUERY_REQUEST];	/* save the packet information after making a duplicate packet to 	link_drop_request_send_queue */	 		packet = bap_buffer->bap;	bap_buffer->bap = bacpDupPkt (packet);	if (bap_buffer->bap == NULL)		{		logMsg ("link_drop_request_send_queue Packet duplication Error: \n",\							1, 2, 3, 4, 5, 6);		if (pfwPluginObjStateRelease (pluginState) == ERROR) 			return ERROR;				return ERROR;		}#ifdef PPP_DEBUG    printf("BAP: Sending LINK DROP REQ Packet ID %d Length %u\n", \			txIdentifier, bap_buffer->bap->mBlkHdr.mLen);#endif /* PPP_DEBUG */	pfwSend (pluginState, packet);	pfwTimerCancel (pStackData->dropRequestRetryTimer);	if (pfwTimerStart (pStackData->dropRequestRetryTimer, 			PFW_100_MILLISECOND,			pProfileData->maximum_bap_linkdrop_request_send_interval * 10, 			retry_bap_link_drop_request, txIdentifier) == ERROR )		{		logMsg ("BAP Link Drop Request Timer start failed: \n",\					1, 2, 3, 4, 5, 6);		}	if (pfwPluginObjStateRelease (pluginState) == ERROR) 		return ERROR;	return OK;		}	/******************************************************************************** bapBundleBandwidthDrop - drop the link with the specified bandwidth  *																from the bundle** This routine is called to gracefully remove requested bandwidth from the * bundle. It also finds finds the active port corresponding to the bandwidth * to be dropped. The port is then removed from the active_port_queue and * pmPortUnreserve () is called to remove the port to the pool of free ports* in MP_LINK_DOWN_EVENT. Terminate request packet is sent to close the link.** RETURNS: OK/ERROR*/STATUS bapBundleBandwidthDrop    	(	PFW_STACK_OBJ *managerStackObj,		/* manager stack object */	ULONG bandwidth,					/* bandwidth to be dropped */	char * reason_string				/* reason string */	)	{    PFW_PLUGIN_OBJ * pluginObj = NULL;    PFW_PLUGIN_OBJ_STATE * pluginState = NULL;	BACP_STACK_DATA *pStackData = NULL;	BAP_ACTIVE_PORT * ptr_port_to_drop = NULL;	    if ((pluginObj = pfwPluginObjGet (pfwStackObjPfwGet (managerStackObj), 										"PPP_BACP") ) == NULL)		return ERROR;    if ((pluginState = pfwPluginObjStateGet (managerStackObj, 										pluginObj)) == NULL)		return ERROR;	if (pfwPluginObjStateLock (pluginState) == ERROR) 		return ERROR;    pStackData = (BACP_STACK_DATA *)pluginState->stackData;    if (pStackData->stateData.state != PPP_OPENED_STATE)		{		if (pfwPluginObjStateRelease (pluginState) == ERROR) 			return ERROR;		return ERROR;		}	ptr_port_to_drop = bap_find_active_port_with_this_bandwidth (										(LINK *) &pStackData->active_port_queue, 										(USHORT) bandwidth);	if(ptr_port_to_drop == NULL)		{		if (pStackData->bacpUpcall != NULL)			(*pStackData->bacpUpcall->bacpUpCallFunction) 					(managerStackObj, BAP_EVENT_BODA_REQUEST_NOT_PROCESSED,					bandwidth, NULL,					0, &reason_string);		if (pfwPluginObjStateRelease (pluginState) == ERROR) 			return ERROR;		return ERROR;		}#ifdef PPP_DEBUG    printf("BAP: Calling PPP Connection close \n");#endif /* PPP_DEBUG */	/* Send the terminate request packet */	pppConnectionClose (ptr_port_to_drop->linkStackObj);	if (pfwPluginObjStateRelease (pluginState) == ERROR) 		return ERROR;	return OK;	}/******************************************************************************* free_active_port - frees the active port** This routine clears an entry in BAP_ACTIVE_PORT list. Delete current entry * from BAP_ACTIVE_PORT list and also free the memory allocated for * this BAP_ACTIVE_PORT.** RETURNS: N/A** NOMANUAL*/void free_active_port 	(	LINK * ptr_linked_list,			/* active port list */ 	BAP_ACTIVE_PORT *active_port	/* active port */	)	{	delete_entry_from_l

⌨️ 快捷键说明

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