📄 pppbaprx.c
字号:
} pPortInfo = (PORT_CONNECTION_INFO *) SLL_NEXT (pPortInfo); } }/******************************************************************************* bap_link_drop_query_request_received - * processes the received BAP link drop query request packet* * This routine is called to process the BAP link drop query request packet * received. The active_port_queue is checked for the presence of the port * corresponding to the link_discriminator received. The received BAP link * drop query request packet is positively acknowledged. ** RETURNS: PASS or FAIL */LOCAL TEST bap_link_drop_query_request_received ( PFW_PLUGIN_OBJ_STATE * pluginState, /* plugin object state in manager stack */ M_BLK_ID packet /* packet received */ ) { BAP_LINK_DROP_QUERY_REQUEST_PACKET * bap_rx_packet = NULL; BACP_STACK_DATA * pStackData = (BACP_STACK_DATA *)pluginState->stackData; PFW_STACK_OBJ * pManagerStackObj = pluginState->stackObj; BAP_ACTIVE_PORT * ptr_active_port = NULL; BAP_BUFFER * sptr_bap_buffer = NULL; PORT_CONNECTION_INFO *port_info = NULL; char * reason_string = NULL; enum BAP_RESPONSE_CODE response_code = BAP_RESPONSE_ACK; USHORT numberOfEntries = 0; bap_rx_packet = mtod (packet, BAP_LINK_DROP_QUERY_REQUEST_PACKET *);#ifdef PPP_DEBUG logMsg ("BAP Rx: Link-Drop Query Request of: ID %d\n",\ bap_rx_packet->bap_id, 2, 3, 4, 5, 6);#endif /* PPP_DEBUG */ /* * if the discriminator matches the entry in the active port queue then * port is in existence, Else particular port is already inactive */ ptr_active_port = bap_match_discriminator_and_active_port ((LINK *) &pStackData->active_port_queue, ntohs (bap_rx_packet->link_discriminator_option.link_discriminator)); if (ptr_active_port == NULL) {#ifdef PPP_DEBUG logMsg ("BAP Rx: Local Link Discriminator doesn't match with recived \ Link-Drop Query Request of ID %d\n",\ bap_rx_packet->bap_id, 2, 3, 4, 5, 6);#endif /* PPP_DEBUG */ bap_send_link_drop_query_response (pluginState, bap_rx_packet->bap_id, "Link Discriminator dosent match", BAP_RESPONSE_NAK); return (PASS); } /* * we have the port now, check if we have link drop active for the port * if so and we are the favored peer then drop it. Send response anyway * else if we are not favored peer, reply and drop our request */ sptr_bap_buffer = bap_find_outstanding_request_for_port ((LINK *) &pStackData->link_drop_request_send_queue, ptr_active_port->port_number); if (sptr_bap_buffer != NULL) { port_info = (PORT_CONNECTION_INFO *) SLL_FIRST (&sptr_bap_buffer->port_list); if (port_info == NULL) return FAIL; /* * if we r the favoured peer then drop the req. send from the other * peer ie by sending NACK */ if (pStackData->favored_peer_is_me == TRUE) {#ifdef PPP_DEBUG logMsg ("BAP Rx: Dropping Link-Drop Request Packet of ID %d as I am the Favored-Peer \n",\ bap_rx_packet->bap_id, 2, 3, 4, 5, 6);#endif /* PPP_DEBUG */ bap_send_link_drop_query_response (pluginState, bap_rx_packet->bap_id, "Favored Peer dropped the request", BAP_RESPONSE_NAK); return (PASS); } else /* drop ours */ { #ifdef PPP_DEBUG logMsg ("BAP Rx: Dropping our Link-Drop Request Packet as peer is the \ Favored-Peer \n",1, 2, 3, 4, 5, 6);#endif /* PPP_DEBUG */ pfwTimerCancel (pStackData->dropRequestRetryTimer); pStackData->number_of_bap_linkdrop_requests = 0; free_bap_buffer ((LINK *) &pStackData->link_drop_request_send_queue, sptr_bap_buffer); } } numberOfEntries = bap_number_of_active_port_entries ( (LINK *) &pStackData->active_port_queue); if (numberOfEntries == 1) { /* * If its the last port to be deleted let BODA take the decisison to * send FULL NACK or just ACK */ if (pStackData->bacpUpcall != NULL) { response_code = (*pStackData->bacpUpcall->bacpUpCallFunction) (pManagerStackObj, BAP_EVENT_REQUEST_FULL_NAK, ptr_active_port->port_number, ptr_active_port->linkStackObj, BAP_LINK_DROP_QUERY_REQUEST, &reason_string); } } else { /* just check in UP call function if u can drop that particular link */ if (pStackData->bacpUpcall != NULL) { response_code = (*pStackData->bacpUpcall->bacpUpCallFunction) (pManagerStackObj, BAP_EVENT_DROP_QUERY_REQUEST, ptr_active_port->port_number, ptr_active_port->linkStackObj, 0, &reason_string); } } bap_send_link_drop_query_response (pluginState, bap_rx_packet->bap_id, reason_string, (BYTE) response_code); return (PASS); }/******************************************************************************* bap_link_drop_query_response_received - * processes the received BAP link drop query response packet.** This routine is called to process the BAP link drop query response packet * received. The received BAP link drop query response is positively acknowledged * then terminate request packet is sent to close the link.** RETURNS: PASS, or FAIL */LOCAL TEST bap_link_drop_query_response_received ( PFW_PLUGIN_OBJ_STATE * pluginState, /* plugin object state in manager stack */ M_BLK_ID packet /* packet received */ ) { BAP_LINK_DROP_QUERY_RESPONSE_PACKET * bap_rx_packet = NULL; BACP_STACK_DATA * pStackData = (BACP_STACK_DATA *)pluginState->stackData; PFW_STACK_OBJ *pLinkStackObj; PFW_STACK_OBJ * pManagerStackObj = pluginState->stackObj; PORT_CONNECTION_INFO *port_info = NULL; BAP_BUFFER * sptr_bap_buffer = NULL; char * reason_string = NULL; bap_rx_packet = mtod (packet, BAP_LINK_DROP_QUERY_RESPONSE_PACKET *); sptr_bap_buffer = bap_match_received_response_to_outstanding_request ((LINK *) &pStackData->link_drop_request_send_queue, bap_rx_packet->bap_id);#ifdef PPP_DEBUG logMsg ("BAP Rx: Link-Drop Query 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 */ /* matching LINK DROP REQUEST for response NOT found */ if (sptr_bap_buffer == NULL) {#ifdef PPP_DEBUG logMsg ("BAP Rx: Illegal Link-Drop Query Response or Request might have 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 (&sptr_bap_buffer->port_list); if (port_info == NULL) { return (FAIL); } /* If already responded for the request then need not reply, return */ if (sptr_bap_buffer->status == BAP_LINK_DROP_ACCEPTED) {#ifdef PPP_DEBUG logMsg ("BAP Rx: Duplicate Link-Drop Query Response of ID %d\n",\ bap_rx_packet->bap_id, 2, 3, 4, 5, 6);#endif /* PPP_DEBUG */ return (PASS); } /* Cancel the timer and reset number_of_bap_linkdrop_requests to zero */ pfwTimerCancel (pStackData->dropRequestRetryTimer); pStackData->number_of_bap_linkdrop_requests = 0; /* if negatively acknowleged then */ if (bap_rx_packet->bap_response_code == BAP_RESPONSE_NAK) { if (pStackData->bacpUpcall != NULL) { (*pStackData->bacpUpcall->bacpUpCallFunction) (pManagerStackObj, BAP_EVENT_DROP_QUERY_REQUEST, port_info->port_number, port_info->linkStackObj, bap_rx_packet->bap_response_code, &reason_string); } free_bap_buffer ((LINK *) &pStackData->link_drop_request_send_queue, sptr_bap_buffer); return (PASS); } /* * if response is FULL NAK inform BODA and it has take decision on when * to drop place the request again */ else if (bap_rx_packet->bap_response_code == BAP_RESPONSE_FULL_NAK) { if (pStackData->bacpUpcall != NULL) { (*pStackData->bacpUpcall->bacpUpCallFunction) (pManagerStackObj, BAP_EVENT_REQUEST_FULL_NAK, port_info->port_number, port_info->linkStackObj, bap_rx_packet->bap_response_code, &reason_string); } free_bap_buffer ((LINK *) &pStackData->link_drop_request_send_queue, sptr_bap_buffer); return (PASS); } /* if +vely acknowleged then get linkstackObject and send terminate request */ else if (bap_rx_packet->bap_response_code == BAP_RESPONSE_ACK) { pLinkStackObj = bap_find_stackobj_with_this_discriminators ((LINK *) &pStackData->active_port_queue, port_info->port_lcp_local_link_discriminator, port_info->port_lcp_remote_link_discriminator); /* update the status */ sptr_bap_buffer->status = BAP_LINK_DROP_ACCEPTED; pppConnectionClose (pLinkStackObj); } else {#ifdef PPP_DEBUG logMsg ("BAP Rx: ILLEGAL Link-Drop Query Response Received: ID %d \t \ Response CODE %d\n", bap_rx_packet->bap_id, bap_rx_packet->bap_response_code, 3, 4, 5, 6);#endif /* PPP_DEBUG */ return (FAIL); } return (PASS); }/******************************************************************************* bap_call_status_indication_received - * processes the received BAP call status indication packet** Whenever a call status indication packet is received a call status response * packet is sent with the response code of ACK for all the received indication packets.** RETURNS: PASS, or FAIL */LOCAL TEST bap_call_status_indication_received ( PFW_PLUGIN_OBJ_STATE * pluginState, /* plugin object state in manager stack */ M_BLK_ID packet /* packet received */ ) { BAP_CALL_STATUS_INDICATION_PACKET * bap_rx_packet = NULL; BAP_BUFFER * ptr_matching_request = NULL; PORT_CONNECTION_INFO * port_info = NULL; BOOL request_is_in_callback_queue = FALSE; BAP_ACTIVE_PORT * ptr_active_port = NULL; BACP_STACK_DATA *pStackData = (BACP_STACK_DATA *)pluginState->stackData; PFW_STACK_OBJ * pManagerStackObj = pluginState->stackObj; /* get the id of received call status inidication packet and send the call status response packet */ bap_rx_packet = mtod (packet, BAP_CALL_STATUS_INDICATION_PACKET *);#ifdef PPP_DEBUG logMsg ("BAP Rx: Call-Status Indication of ID %d\n",bap_rx_packet->bap_id,\ 2, 3, 4, 5, 6);#endif /* PPP_DEBUG */ if (bap_rx_packet->bap_call_status_option.status != CALL_STATUS_OK) { if (bap_rx_packet->bap_call_status_option.action == CALL_ACTION_NO_RETRY) { ptr_matching_request = bap_match_received_response_to_outstanding_request ((LINK *) &pStackData->call_request_send_queue, bap_rx_packet->bap_id); if (ptr_matching_request == NULL) { ptr_matching_request = bap_match_received_response_to_outstanding_request ((LINK *) &pStackData->callback_request_send_queue, bap_rx_packet->bap_id); request_is_in_callback_queue = TRUE; } if (ptr_matching_request != NULL) { /* Get the port information and unreserve the port */ port_info = (PORT_CONNECTION_INFO *) SLL_FIRST (&ptr_matching_request->port_list); if (pStackData->bacpUpcall != NULL) (*pStackData->bacpUpcall->bacpUpCallFunction) (pManagerStackObj, BAP_EVENT_CALL_REQUEST_STATUS, port_info->port_number, port_info->linkStackObj, BAP_EVENT_BODA_REQUEST_NOT_PROCESSED, NULL); pmPortUnreserve (port_info); /* Find the entry in active port list entry */ ptr_active_port = bap_find_active_port_with_this_portnumber ((LINK *) &pStackData->active_port_queue, port_info->port_number); /* Remove the entry from the BAP BUFFER list entry */ if (request_is_in_callback_queue == TRUE) free_bap_buffer ((LINK *) &pStackData->callback_request_send_queue, ptr_matching_request); else free_bap_buffer ((LINK *) &pStackData->call_request_send_queue, ptr_matching_request); /* Remove the entry from active port list entry */ if (ptr_active_port != NULL) free_active_port ((LINK *)&pStackData->active_port_queue, ptr_active_port); } } } /* any BAP Call Status Indication packet received send a Call Status response */ bap_send_call_status_response (pluginState, bap_rx_packet->bap_id, "Received Request"); return (PASS); }/******************************************************************************* bap_call_status_response_received - * processes the received BAP call status response packet** Whenever a call status response packet is received * call_status_indication_send_queue is searched for the sequence identifier * received and that packet is deleted and return PASS.** RETURNS: PASS, or FAIL */LOCAL TEST bap_call_status_response_received ( PFW_PLUGIN_OBJ_STATE * pluginState, /* plugin object state in manager stack */ M_BLK_ID packet /* packet received */ ) { BAP_BUFFER * sp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -