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

📄 pppbaprx.c

📁 这是全套的PPP协议的源码
💻 C
📖 第 1 页 / 共 5 页
字号:
		free_bap_buffer ((LINK *) &pStackData->call_request_send_queue,							ptr_matching_request);		return (PASS);		}	/* If response is ACK then find various option that arrived in req packet */  	ptr_reason_option = (BAP_REASON_OPTION *) bap_find_option_in_packet (							packet, BAP_REASON, SUBOPTION_TYPE_NONE);	if (ptr_reason_option != NULL)		{		ptr_reason_string = (char *) &ptr_reason_option->reason[0];		memcpy((void *) &reason_string, 				(void *) ptr_reason_string, 				ptr_reason_option->length - 2);		reason_string[ptr_reason_option->length - 2] = 0x00; 		ptr_reason_string = &reason_string[0];		}	ptr_phone_delta_option = (BAP_PHONE_DELTA_OPTION *) 				bap_find_option_in_packet (packet, BAP_PHONE_DELTA, 											SUBOPTION_TYPE_NONE);	/* if no_phone_number_selected == TRUE then phone_delta_option will be NULL */	if (strlen (port_info->port_remote_phone_number) != 0) 		{		if (ptr_phone_delta_option == NULL)			{			/* activation of port */			if (callRequestPortActivate (pluginState, ptr_matching_request) == ERROR)				return FAIL;			}		else			{			pmPortUnreserve (port_info);			port_info->port_status = CALL_STATUS_SECURITY_VIOLATION;			port_info->port_action = CALL_ACTION_NO_RETRY;				/* To get id of request packet in call request queue */			call_rq_packet = mtod(ptr_matching_request->bap, 									BAP_CALL_REQUEST_PACKET *);			bap_send_call_status_indication (pluginState, 							call_rq_packet->bap_id, ptr_reason_string,							port_info);			if (pStackData->bacpUpcall != NULL)				(*pStackData->bacpUpcall->bacpUpCallFunction) 						(pManagerStackObj, BAP_EVENT_CALL_REQUEST_STATUS,						port_info->port_number, NULL,						response_code, &ptr_reason_string);			free_bap_buffer ((LINK *) &pStackData->call_request_send_queue,							ptr_matching_request);			return (PASS);			}		}	else		{		/* if no_phone_number_selected = FALSE, phone_delta_option will not be NULL */		if(ptr_phone_delta_option == NULL)			{#ifdef PPP_DEBUG            logMsg ("BAP Rx: Illegal Call Response with No-Phone-Number Option of ID %d\n",\                        (int) bap_rx_packet->bap_id, 2, 3, 4, 5, 6);#endif /* PPP_DEBUG */			/* If phone delta option is NULL then send call status indication */        	/* packet. Since we require a phone delta option as requested.    */						pmPortUnreserve (port_info);			port_info->port_status = CALL_STATUS_SECURITY_VIOLATION;			port_info->port_action = CALL_ACTION_NO_RETRY;			/* To get id of request packet in call request queue */			call_rq_packet = mtod (ptr_matching_request->bap, 				                   BAP_CALL_REQUEST_PACKET *);			bap_send_call_status_indication (pluginState, 							call_rq_packet->bap_id, ptr_reason_string,							port_info);			free_bap_buffer ((LINK *) &pStackData->call_request_send_queue,						ptr_matching_request);			return (FAIL);			}		else			{				/* From the phone delta option get the phone-number and make a dial */	 		bap_store_and_select_phone_number (pluginState, packet, ptr_matching_request);						/* activation of port */			if (callRequestPortActivate (pluginState, ptr_matching_request) == ERROR)				return FAIL;			}		}	ptr_matching_request->status = BAP_CALL_REQUEST_ACCEPTED;	if (pStackData->bacpUpcall != NULL)		{		(*pStackData->bacpUpcall->bacpUpCallFunction) 					(pManagerStackObj, BAP_EVENT_CALL_REQUEST_STATUS,					port_info->port_number, NULL,					response_code, &ptr_reason_string);		}	return (PASS);	}	/******************************************************************************* bap_callback_response_received - *						processes the received BAP call back response packet** This routine is called to process the BAP call back response packet. The * received BAP call back response packet is matched with the call back request * packet sent and pmPortActivate () is called to wait for the peer to call us.** RETURNS: PASS, or FAIL */LOCAL TEST bap_callback_response_received 	(    PFW_PLUGIN_OBJ_STATE * pluginState,	/* plugin object state in manager stack */    M_BLK_ID packet						/* packet received */	)	{	BAP_BUFFER * ptr_matching_request = NULL;	BAP_LINK_TYPE_OPTION * ptr_link_option = NULL;	BAP_REASON_OPTION * ptr_reason_option = NULL;	BAP_ACTIVE_PORT * ptr_active_port = NULL; 	PORT_CONNECTION_INFO * port_info = NULL;    BAP_CALLBACK_RESPONSE_PACKET * bap_rx_packet = NULL;	char * ptr_reason_string = NULL;	char   reason_string[256];	BYTE response_code;	PFW_STACK_OBJ * pLinkStackObj;	PFW_STACK_OBJ * pManagerStackObj = pluginState->stackObj;    BACP_STACK_DATA * pStackData = (BACP_STACK_DATA *)pluginState->stackData;    bap_rx_packet = mtod (packet, BAP_CALLBACK_RESPONSE_PACKET *);	/* Whenver a call back request is placed an entry is added to the        */    /* callback_request_send_queue. Incoming packet's ID is checked for any  */	/* matching entry existence in callback_request_send_queue.              */		ptr_matching_request = bap_match_received_response_to_outstanding_request 							((LINK *) &pStackData->callback_request_send_queue, 							bap_rx_packet->bap_id);#ifdef PPP_DEBUG    logMsg ("BAP Rx: Call-Back Response Packet: ID %d  Length %d  Code %d\n",\				bap_rx_packet->bap_id, ntohs(bap_rx_packet->bap_length), \				bap_rx_packet->bap_response_code, 4, 5, 6);#endif /* PPP_DEBUG */	/* If response is not matching any of our request placed then return fail */	if (ptr_matching_request == NULL)		{#ifdef PPP_DEBUG        logMsg ("BAP Rx: Illegal Call-Back Response or request might been dropped \                due to Favored Peer: ID %d\n",bap_rx_packet->bap_id, 2, 3, 4, 5, 6);#endif /* PPP_DEBUG */		return (PASS);		}	port_info = (PORT_CONNECTION_INFO *)						SLL_FIRST (&ptr_matching_request->port_list); 	if (port_info == NULL)		{		return (FAIL);		}	/* If already responded for the request then need not reply, return       */	if (ptr_matching_request->status == BAP_CALL_REQUEST_ACCEPTED)		{#ifdef PPP_DEBUG        logMsg ("BAP Rx: Duplicate BAP Call-Back Response Received: ID %d\n",\                bap_rx_packet->bap_id, 2, 3, 4, 5, 6);#endif /* PPP_DEBUG */		return (PASS);		}	response_code = bap_rx_packet->bap_response_code;	/* Cancel the timer and reset number_of_bap_callback_requests to zero 	  */	pfwTimerCancel (pStackData->callbackRequestRetryTimer);	pStackData->number_of_bap_callback_requests = 0;	/* If response is negative ACK then delete request addedd in the 		  */	/* callback_request_send_queue 			 								  */	if (response_code != BAP_RESPONSE_ACK)		{		if (pStackData->bacpUpcall != NULL)			{			(*pStackData->bacpUpcall->bacpUpCallFunction) 						(pManagerStackObj, BAP_EVENT_CALL_REQUEST_STATUS,						port_info->port_number, NULL,						response_code, &ptr_reason_string);			}		/* unreserve the previously reserved port in the ptr_matching_request */		while (port_info != NULL)			{			pmPortUnreserve (port_info);			port_info = (PORT_CONNECTION_INFO *) SLL_NEXT (port_info);						}		free_bap_buffer ((LINK *) &pStackData->callback_request_send_queue,							ptr_matching_request);		return (PASS);		}	/* If response is ACK then find various option that arrived in req packet */  	ptr_reason_option = (BAP_REASON_OPTION *) bap_find_option_in_packet (							packet, BAP_REASON, SUBOPTION_TYPE_NONE);	if (ptr_reason_option)		{		ptr_reason_string = (char *) &ptr_reason_option->reason[0];		memcpy((void *) &reason_string, 				(void *) ptr_reason_string, 				ptr_reason_option->length - 2);		reason_string[ptr_reason_option->length - 2]  = 0x00;		ptr_reason_string = &reason_string[0];		}	ptr_link_option = (BAP_LINK_TYPE_OPTION *) bap_find_option_in_packet 							(packet, BAP_LINK_TYPE, SUBOPTION_TYPE_NONE);		/*	 * if the Linktype option received in response packet doesn't match the	 * Linktype in Callback-req already placed,then remove the request from	 * callback_request_send_queue and return 								  	 */	if (ptr_link_option != NULL && (ptr_link_option->link_type != 									port_info->port_type))		{		if (pStackData->bacpUpcall != NULL)			{			(*pStackData->bacpUpcall->bacpUpCallFunction) 						(pManagerStackObj, BAP_EVENT_CALL_REQUEST_STATUS,						port_info->port_number, NULL,						BAP_RESPONSE_NAK, &ptr_reason_string);			}		port_info->port_status = CALL_STATUS_SECURITY_VIOLATION;		port_info->port_action = CALL_ACTION_NO_RETRY;		bap_send_call_status_indication (pluginState, 		bap_rx_packet->bap_id, "non existant or non matching link type", port_info);		/* unreserve the previously reserved port in the ptr_matching_request */		port_info = (PORT_CONNECTION_INFO *)						SLL_FIRST (&ptr_matching_request->port_list); 		while (port_info != NULL)			{			pmPortUnreserve (port_info);			port_info = (PORT_CONNECTION_INFO *) SLL_NEXT (port_info);			}		free_bap_buffer ((LINK *) &pStackData->callback_request_send_queue,							ptr_matching_request);		return (FAIL);		}	/* activation of port */	if ((pLinkStackObj = pmPortActivateAndWait (&ptr_matching_request->port_list,													pManagerStackObj)) == NULL)		{		if (pStackData->bacpUpcall != NULL)			{			(*pStackData->bacpUpcall->bacpUpCallFunction) 						(pManagerStackObj, BAP_EVENT_CALL_REQUEST_STATUS,						port_info->port_number, NULL,						BAP_RESPONSE_NAK, &ptr_reason_string);			}		port_info->port_status = CALL_STATUS_SECURITY_VIOLATION;		port_info->port_action = CALL_ACTION_NO_RETRY;		bap_send_call_status_indication (pluginState,				bap_rx_packet->bap_id, "Activate Port Failed", port_info);		/* unreserve the previously reserved port in the ptr_matching_request */		port_info = (PORT_CONNECTION_INFO *)						SLL_FIRST (&ptr_matching_request->port_list); 		while (port_info != NULL)			{			pmPortUnreserve (port_info);			port_info = (PORT_CONNECTION_INFO *) SLL_NEXT (port_info);			}		free_bap_buffer ((LINK *) &pStackData->callback_request_send_queue,							ptr_matching_request);		return (FAIL);		}	/* remove in active port info from the port list form ptr_matching_request */	removePortInfoFromBapBuffer (&ptr_matching_request->port_list, pLinkStackObj);	/* assign the port info of the active member in the port list */	port_info = (PORT_CONNECTION_INFO *) SLL_FIRST (&ptr_matching_request->port_list);	ptr_active_port = (BAP_ACTIVE_PORT *) pfwMalloc 				(pluginState->pluginObj->pfwObj, sizeof (BAP_ACTIVE_PORT));	if (ptr_active_port == NULL)		return FAIL;	ptr_active_port->port_number   = port_info->port_number;	ptr_active_port->port_bap_type = port_info->port_type;	ptr_active_port->port_speed    = port_info->port_speed;	ptr_active_port->bacpAdded     = TRUE;	ptr_active_port->linkStackObj  = pLinkStackObj;	/* add to active port queue */	add_entry_to_list ((LINK *) &pStackData->active_port_queue, 									(LINK *) ptr_active_port);	ptr_matching_request->status = BAP_CALL_REQUEST_ACCEPTED;	if (pStackData->bacpUpcall != NULL)		{		(*pStackData->bacpUpcall->bacpUpCallFunction) 					(pManagerStackObj, BAP_EVENT_CALL_REQUEST_STATUS,					port_info->port_number, NULL,					response_code, &ptr_reason_string);		}	return (PASS);	}/******************************************************************************* removePortInfoFromBapBuffer - To remove the unused port information from *													   port list of bap buffer.*					 * This routine is called to retain the active port information and remove all * other unused port information from the bap buffer port list. ** RETURNS: N/A*/LOCAL void removePortInfoFromBapBuffer 	(	SL_LIST	* portList,					/* Port list containing port info */		PFW_STACK_OBJ * activeLinkStackObj  /* Active port stack object */	)	{	PORT_CONNECTION_INFO *pPortInfo = NULL;    PORT_CONNECTION_INFO *pPortInfoLast = NULL;	pPortInfo = (PORT_CONNECTION_INFO *) SLL_FIRST (portList);	pPortInfoLast = (PORT_CONNECTION_INFO *) SLL_LAST (portList); 	if (pPortInfo == pPortInfoLast)		{		return;		}	while (pPortInfo != NULL)		{		if (pPortInfo->linkStackObj != activeLinkStackObj)			{			/* if the node to be deleted is the last node */			if (SLL_NEXT (pPortInfo) == NULL)				{				sllRemove (portList, 							(SL_NODE *)pPortInfo, 							sllPrevious (portList, (SL_NODE *)pPortInfo));				}			else				{				if (sllPrevious (portList, (SL_NODE *)pPortInfo) == NULL)					{					sllRemove (portList, (SL_NODE *)pPortInfo, NULL);						}				else 					{					sllRemove (portList, 						(SL_NODE *)pPortInfo, 						sllPrevious (portList, (SL_NODE *)pPortInfo));					}				}			/* unreserve the previously reserved port */			pmPortUnreserve (pPortInfo);  				/* free the port_info */            if (pPortInfo != NULL)               {               pfwFree(pPortInfo);	 		 /* free the port_info */               pPortInfo = NULL;               }

⌨️ 快捷键说明

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