📄 baputil.c
字号:
}/******************************************************************************** bap_find_stackobj_with_this_discriminators - * to find link stack obj with the matching discriminators** This routine finds the stackObj in the active_port_queue with the matching * local and remote discriminator. If found returns stackObj** RETURNS linkStackObj on success and NULL otherwise*/PFW_STACK_OBJ * bap_find_stackobj_with_this_discriminators ( LINK * ptr_linked_list, /* list to be searched */ USHORT localDiscriminator, /* local link discriminator */ USHORT remoteDiscriminator /* remote link discriminator */ ) { BAP_ACTIVE_PORT *sptr_active_port; sptr_active_port = (BAP_ACTIVE_PORT *) get_pointer_to_first_entry_in_list (ptr_linked_list); while (sptr_active_port != NULL) { if ((localDiscriminator == sptr_active_port->port_bacp_local_discr) && (remoteDiscriminator == sptr_active_port->port_bacp_remote_discr)) break; sptr_active_port = (BAP_ACTIVE_PORT *) get_pointer_to_next_entry_in_list ((LINK *) sptr_active_port); } if (sptr_active_port == NULL) return NULL; return (sptr_active_port->linkStackObj); }/******************************************************************************** bap_find_stackobj_for_the_remote_discriminator - * to find link stack obj with the matching discriminators** This routine finds the stackObj in the active_port_queue with the matching * discriminator. If found returns stackObj** RETURNS linkStackObj on success and NULL otherwise*/PFW_STACK_OBJ * bap_find_stackobj_for_the_remote_discriminator ( LINK * ptr_linked_list, /* list to be searched */ USHORT remoteDiscriminator /* remote link discriminator */ ) { BAP_ACTIVE_PORT *sptr_active_port; sptr_active_port = (BAP_ACTIVE_PORT *) get_pointer_to_first_entry_in_list (ptr_linked_list); while (sptr_active_port != NULL) { if (remoteDiscriminator == sptr_active_port->port_bacp_remote_discr) break; sptr_active_port = (BAP_ACTIVE_PORT *) get_pointer_to_next_entry_in_list ((LINK *) sptr_active_port); } if (sptr_active_port == NULL) return NULL; return (sptr_active_port->linkStackObj); }/******************************************************************************** bap_number_of_active_port_entries - * to find number of active port entries in the list** RETURNS Number of entries in list else zero*/USHORT bap_number_of_active_port_entries ( LINK * ptr_linked_list ) { BAP_ACTIVE_PORT *sptr_active_port; USHORT numberOfEntries = 0; sptr_active_port = (BAP_ACTIVE_PORT *) get_pointer_to_first_entry_in_list (ptr_linked_list); while (sptr_active_port != NULL) { numberOfEntries ++; sptr_active_port = (BAP_ACTIVE_PORT *) get_pointer_to_next_entry_in_list ((LINK *) sptr_active_port); } return (numberOfEntries); }/******************************************************************************** copyPortInfoToBapBuffer - To copy port information in the port list** This routine is used to copy the port information from the source port list * to a destination port list. It also allocates memory for the port information * before copying the contents to the destination port list. It also frees the * memory related to the source port list port information. ** RETURNS: OK/ERROR*/STATUS copyPortInfoToBapBuffer ( PFW_OBJ * pfwObj, SL_LIST *destinationPortList, SL_LIST *sourcePortList ) { PORT_CONNECTION_INFO *port_info, *temp_port_info; /* save all port information to destination port list from source */ sllInit (destinationPortList); port_info = (PORT_CONNECTION_INFO *) SLL_FIRST (sourcePortList); if ((temp_port_info = (PORT_CONNECTION_INFO *)pfwMalloc (pfwObj, sizeof (PORT_CONNECTION_INFO))) == NULL) return ERROR; memcpy (temp_port_info, port_info, sizeof (PORT_CONNECTION_INFO)); while (port_info != NULL) { sllPutAtTail ((SL_LIST *)destinationPortList, (SL_NODE *) temp_port_info); port_info = (PORT_CONNECTION_INFO *) SLL_NEXT (port_info); if (port_info != NULL) { if ((temp_port_info = (PORT_CONNECTION_INFO *)pfwMalloc (pfwObj, sizeof (PORT_CONNECTION_INFO))) == NULL) return ERROR; memcpy (temp_port_info, port_info, sizeof(PORT_CONNECTION_INFO)); } } /* free the memory associated with source port list */ port_info = (PORT_CONNECTION_INFO *) SLL_FIRST (sourcePortList); while (port_info != NULL) { temp_port_info = (PORT_CONNECTION_INFO *) SLL_NEXT (port_info); if (port_info != NULL) { pfwFree (port_info); port_info = NULL; } port_info = temp_port_info; } return OK; }/******************************************************************************* bapPrintOptions - print options in BAP packet** RETURNS: N/A*/void bapPrintOptionsInPacket ( M_BLK_ID packet /* BAP packet */ ) { BAP_TLV_OPTION * ptr_option, *old_ptr_option; USHORT length_of_options = 0, old_legth = 0; USHORT length_of_phone_delta_option = 0; char phoneString [24]; char reasonString [100]; BYTE_ENUM(BAP_PACKET_TYPE) bap_type; BAP_REQUEST_PACKET * sptr_bap_request_packet; BAP_RESPONSE_PACKET * sptr_bap_response_packet; BAP_PHONE_DELTA_UNIQUE_DIGITS *sptr_unique_digits_option; BAP_PHONE_DELTA_SUBSCRIBER_NUMBER *sptr_subscriber_option; BAP_PHONE_DELTA_PHONE_NUMBER_SUB_ADDRESS *sptr_subaddress_option; BAP_NO_PHONE_NUMBER_NEEDED_OPTION *sptr_no_phone_option; BAP_LINK_TYPE_OPTION *sptr_link_type_option; BAP_REASON_OPTION *sptr_reason_option; BAP_LINK_DISCRIMINATOR_OPTION *sptr_link_discriminator_option; BAP_CALL_STATUS_OPTION *sptr_call_status_option = NULL; sptr_bap_request_packet = mtod (packet, BAP_REQUEST_PACKET *); ptr_option = (BAP_TLV_OPTION*)sptr_bap_request_packet->bap_data;/* testing */ bap_type = sptr_bap_request_packet->bap_type; printf ("\n BAP PRINT OPTIONS IN PACKET: "); printf ("\n ----------------------------\n"); length_of_options = ntohs (sptr_bap_request_packet->bap_length); /* If the packet type is of response packet */ if (bap_type == BAP_CALL_RESPONSE || bap_type == BAP_CALLBACK_RESPONSE || bap_type == BAP_LINK_DROP_QUERY_RESPONSE || bap_type == BAP_CALL_STATUS_RESPONSE) { sptr_bap_response_packet = mtod (packet, BAP_RESPONSE_PACKET *); /* Position pointer to begining of TLV address */ ptr_option = (BAP_TLV_OPTION*) sptr_bap_response_packet->bap_data;/* testing */ /* Getting the length of TLV option alone from the actual length */ length_of_options -= sizeof (BAP_RESPONSE_HEADER); } else { /* If the packet type is of request packet */ length_of_options -= sizeof (BAP_REQUEST_HEADER); } printf ("Total Length of the options to be printed is %d \n",length_of_options); while (length_of_options > 0) { switch (ptr_option->type) { case BAP_NO_PHONE_NUMBER_NEEDED: printf ("BAP_NO_PHONE_NUMBER_NEEDED \n"); sptr_no_phone_option = (BAP_NO_PHONE_NUMBER_NEEDED_OPTION *)ptr_option; /* Added */ printf ("Length = %u \n\n", sptr_no_phone_option->length); length_of_options = length_of_options - (sptr_no_phone_option->length); ptr_option = (BAP_TLV_OPTION *) (((char *) ptr_option) + sptr_no_phone_option->length); break; case BAP_LINK_TYPE: sptr_link_type_option = (BAP_LINK_TYPE_OPTION *)ptr_option; printf ("BAP_LINK_TYPE \n"); printf ("Length = %u\n", sptr_link_type_option->length); printf ("Link Speed = %u\n", ntohs(sptr_link_type_option->link_speed)); /* testing */ printf ("Link Type = %u\n\n", sptr_link_type_option->link_type); length_of_options = length_of_options - (sptr_link_type_option->length); ptr_option = (BAP_TLV_OPTION *) (((char *) ptr_option) + sptr_link_type_option->length); break; case BAP_REASON: bzero(reasonString, sizeof(reasonString)); sptr_reason_option = (BAP_REASON_OPTION *) ptr_option; printf ("BAP_REASON \n"); printf ("Length = %u\n", sptr_reason_option->length); printf ("length to copy = %u \n", sptr_reason_option->length-2); memcpy (reasonString, &sptr_reason_option->reason[0],sptr_reason_option->length-2); printf ("Reason String is = %s\n\n", reasonString); length_of_options = length_of_options - sptr_reason_option->length; ptr_option = (BAP_TLV_OPTION *) (((char *) ptr_option) + sptr_reason_option->length); printf ("Next Option Type is 0x%x \n",ptr_option->type); break; case BAP_LINK_DISCRIMINATOR: sptr_link_discriminator_option = (BAP_LINK_DISCRIMINATOR_OPTION *) ptr_option; printf ("BAP_LINK_DISCRIMINATOR \n"); printf ("Length = %u\n", sptr_link_discriminator_option->length); printf ("Link Discriminator = %u\n\n", ntohs(sptr_link_discriminator_option->link_discriminator)); length_of_options = length_of_options - (sptr_link_discriminator_option->length); ptr_option = (BAP_TLV_OPTION *) (((char *) ptr_option) + sptr_link_discriminator_option->length); break; case BAP_CALL_STATUS: printf ("BAP_CALL_STATUS \n"); sptr_call_status_option = (BAP_CALL_STATUS_OPTION *) ptr_option; printf ("Length = %u\n", sptr_call_status_option->length); printf ("Status = 0x%x\n", sptr_call_status_option->status); printf ("Action = 0x%x\n\n", sptr_call_status_option->action); length_of_options = length_of_options - (sptr_call_status_option->length); ptr_option = (BAP_TLV_OPTION *) (((char *) ptr_option) + sptr_call_status_option->length); break; /* * Save the phone delta option length and also subtract that length * from the total lenth of options */ case BAP_PHONE_DELTA : length_of_phone_delta_option = ptr_option->length; length_of_options -= length_of_phone_delta_option; old_ptr_option = ptr_option; old_legth = length_of_phone_delta_option; /* skip over */ ptr_option = (BAP_TLV_OPTION *) (((char *) ptr_option) + 2); length_of_phone_delta_option -= 2; while ((length_of_phone_delta_option > 0) && ((ptr_option->type == UNIQUE_DIGITS_TYPE) || (ptr_option->type == SUBSCRIBER_NUMBER_TYPE) || (ptr_option->type == PHONE_NUMBER_SUBADDRESS_TYPE))) { bzero (phoneString, sizeof (phoneString)); switch (ptr_option->type) { case SUBSCRIBER_NUMBER_TYPE: sptr_subscriber_option = (BAP_PHONE_DELTA_SUBSCRIBER_NUMBER *)ptr_option; printf ("SUBSCRIBER_NUMBER_TYPE \n"); printf ("Length %u \n", sptr_subscriber_option->length); strncpy (phoneString, (char *) sptr_subscriber_option->digits, sptr_subscriber_option->length-2); printf ("Subscriber Number Phone Digits : %s \n\n", phoneString); /* skip over */ length_of_phone_delta_option -= sptr_subscriber_option->length; ptr_option = (BAP_TLV_OPTION *) (((char *) ptr_option) + sptr_subscriber_option->length); break; case PHONE_NUMBER_SUBADDRESS_TYPE: sptr_subaddress_option = (BAP_PHONE_DELTA_PHONE_NUMBER_SUB_ADDRESS *) ptr_option; printf ("PHONE_NUMBER_SUBADDRESS_TYPE \n"); printf ("Length %u \n",sptr_subaddress_option->length); strncpy (phoneString, (char *) sptr_subaddress_option->digits, sptr_subaddress_option->length-2); printf ("Sub Address Phone Digits : %s \n\n", phoneString); /* skip over */ length_of_phone_delta_option -= sptr_subaddress_option->length; ptr_option = (BAP_TLV_OPTION *) (((char *) ptr_option) + sptr_subaddress_option->length); break; case UNIQUE_DIGITS_TYPE: sptr_unique_digits_option = (BAP_PHONE_DELTA_UNIQUE_DIGITS *) ptr_option; printf ("UNIQUE_DIGITS_TYPE \n"); printf ("Length %u \n",sptr_unique_digits_option->length); strncpy (phoneString, (char *) &sptr_unique_digits_option->digits[0], sptr_unique_digits_option->length-3); printf ("Unique Phone Digits : %s \n", phoneString); printf ("Unique Digit %u\n\n", sptr_unique_digits_option->number_of_digits); /* skip over */ length_of_phone_delta_option -= sptr_unique_digits_option->length; ptr_option = (BAP_TLV_OPTION *) (((char *) ptr_option) + sptr_unique_digits_option->length); break; } /* end of switch */ if (length_of_phone_delta_option == 0) { printf (" Length of phone delta is NULL \n"); ptr_option = (BAP_TLV_OPTION *) (((char *) old_ptr_option) + old_legth); break; } } /* before while */ break; default: printf ("Invalid BAP option Type %u Length is %d \n",ptr_option->type, ptr_option->length); length_of_options = length_of_options - (ptr_option->length); ptr_option = (BAP_TLV_OPTION *) (((char *) ptr_option) + ptr_option->length); break; } /* end of switch */ } /* end of outer while */ }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -