📄 phb_handler_approve.c
字号:
tel_number = &l4cphb_approve_req->tel_number;
control_block->candidate_name_num_index = phb_se_search_by_tel_num(
control_block->type,
tel_number,
&control_block->candidate,
&is_more_candidates);
/* No candidates. Great! */
if ((control_block->candidate == (kal_uint16) PHB_INVALID_VALUE) ||
(control_block->candidate_name_num_index == NULL))
{
control_block->actual_count = 0;
phb_approve_confirm(
PHB_ERRNO_SUCCESS,
control_block->type,
control_block->src_id,
control_block,
NULL);
return;
}
/* So, let's search... */
control_block->match_result = MATCH_FAIL;
/* One entry of l4cphb_phb_entry_array_struct will be allocated */
phb_search_fake(control_block, ilm_ptr, control_block->type, tel_number);
phb_search_continue(NULL, control_block);
return;
}
}
/**
* What the hell is this type!?
* Currently, treat it as FDN disabled.
* Hence, it is ALWAYS approved, but searching is unnecessary,
* since neither ADN nor FDN is enabled.
*/
else if (phb_ptr->dn_type == TYPE_NONE)
{
control_block->type = PHB_NONE;
control_block->actual_count = 0;
phb_approve_confirm(
PHB_ERRNO_SUCCESS,
control_block->type,
control_block->src_id,
control_block,
NULL);
return;
}
/* Exception case, dn_type is invalid! Make approval failed! */
else
{
control_block->type = PHB_NONE;
control_block->actual_count = 0;
phb_approve_confirm(
PHB_ERRNO_FAIL,
control_block->type,
control_block->src_id,
control_block,
NULL);
return;
}
}
/* error */
else
{
phb_approve_err_handler(NULL, control_block);
return;
}
}
/**
* If PHB is not ready, this control path will be reached,
* whether a control_block is allocated or not.
*
* Under such condition, ECC still need to be approved,
* so does other dialling numbers accoding to dialing mode;
* because, even maximum concurrency degree is reached,
* user attempted dialling CANNOT be rejected.
*
* Sigh, so lousy...
*/
else
{
/* Since control_block is not allocated, MUST NOT use it!! */
l4_addr_bcd_struct *tel_number = &l4cphb_approve_req->tel_number;
phb_entry_struct phb_entry;
kal_trace(TRACE_STATE, ERROR_PHB_STATE);
if (phb_approve_ecc(NULL, tel_number, &phb_entry) == KAL_TRUE)
{
/**
* This statement is due to PHB is not ready,
* but control_block is successfully allocated.
*/
if (control_block != NULL)
{
phb_free_control_block(control_block);
}
phb_approve_confirm(PHB_ERRNO_SUCCESS, PHB_ECC, l4cphb_approve_req->src_id, NULL, &phb_entry);
return;
}
if (control_block != NULL)
{
control_block->src_id = l4cphb_approve_req->src_id;
/* Retain msg_id */
control_block->cnf_msg_id = ilm_ptr->msg_id;
/* FDN can be approved only if control_block is allocated */
if ((phb_ptr->state == PHB_STATE_NOT_READY_FDN_READY) &&
(phb_approve_fdn(control_block, tel_number, l4cphb_approve_req) == KAL_TRUE))
{
return;
}
/**
* This statement is due to PHB is not ready,
* but control_block is successfully allocated.
*/
phb_free_control_block(control_block);
}
phb_approve_rest_for_PHB_not_ready(l4cphb_approve_req);
return;
}
}
else
{
/* Verification over. */
if (control_block->proc_stage == APPROVE_FDN || control_block->proc_stage == APPROVE_FDN_ONE_CHARACTER)
{
/* The attempting phone number matches no candidate, NOT APPROVED! */
if (control_block->actual_count == 0)
{
/**
* Since this entry is not approved by FDN (that implicitly means
* FDN is enabled), it is uncessary to search into PHB_PHONEBOOK
* for retrieving the entry that matches this phone number.
*/
control_block->proc_stage = APPROVE_FDN;
control_block->cause = PHB_CAUSE_FDN_BLOCKED;
phb_approve_confirm(PHB_ERRNO_FAIL, control_block->type, control_block->src_id, control_block, NULL);
return;
}
/* The attempting phone number matches some candidate, APPROVED! */
/**
* Should consider whether searching into PHB_PHONEBOOK is meaningful,
* when FDN is enabled, and the attempting phone number is approved by
* FDN ?!
*/
/**
* Currently, it is supposed searching into PHONEBOOK is meaningless.
* Meanwhile, this is also the behavior that most ME providers adpoted.
*/
control_block->proc_stage = APPROVE_FDN;
phb_approve_confirm(PHB_ERRNO_SUCCESS, control_block->type, control_block->src_id, control_block, NULL);
return;
}
/* error */
else
{
phb_approve_err_handler(NULL, control_block);
return;
}
}
} /* end of phb_approve_handler */
/*****************************************************************************
* FUNCTION
* phb_approve_ecc
* DESCRIPTION
* Standard ECC number is 112.
* This code is used to approve telephone number from
* statndard ECC and EFecc; even when PHB is not ready or SIM not ready yet.
* Note that CPHS defines 999 ECC number.
* PARAMETERS
* control_block [?]
* tel_number [?]
* phb_entry [?]
* RETURNS
* void
*****************************************************************************/
static kal_bool phb_approve_ecc(
control_block_type *control_block,
l4_addr_bcd_struct *tel_number,
phb_entry_struct *phb_entry)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_bool result = KAL_FALSE;
kal_uint8 i;
kal_uint16 len;
kal_uint16 len2;
kal_uint8 c1 = 0;
kal_bool bcd_flag = KAL_TRUE;
kal_uint16 bcd_offset = 0;
kal_uint16 bcd_n;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* First, examine if the attempting phone number is ECC */
sim_ecc_struct *eccs = &phb_ptr->ecc;
/* Clean phb_entry */
kal_mem_set(phb_entry, (kal_uint8) PHB_INVALID_VALUE, sizeof(phb_entry_struct));
for (i = 0; i < eccs->num_ecc; ++i)
{
/* Try exact matching ECC */
len = bcd_len(&eccs->ecc[i * NUM_OF_BYTE_ECC], NUM_OF_BYTE_ECC);
len2 = bcd_len(
&tel_number->addr_bcd[L4_ADDR_BCD_TEL_NUM_OFFSET],
(kal_uint16) (tel_number->addr_length - L4_ADDR_BCD_TON_NPI_SIZE));
if (len > len2)
{
continue;
}
if (len > 0 && compare_n_bcd(
&eccs->ecc[i * NUM_OF_BYTE_ECC],
&tel_number->addr_bcd[L4_ADDR_BCD_TEL_NUM_OFFSET],
len) == 0)
{
if (len == len2) /* same len */
{
result = KAL_TRUE;
}
else /* len2 > len */
{
bcd_n = len;
bcd_flag = KAL_TRUE;
bcd_offset = 0;
while (bcd_n > 0)
{
bcd_offset = get_next_bcd_digit(
&tel_number->addr_bcd[L4_ADDR_BCD_TEL_NUM_OFFSET],
bcd_offset,
&bcd_flag,
&c1);
bcd_n--;
}
bcd_offset = get_next_bcd_digit(
&tel_number->addr_bcd[L4_ADDR_BCD_TEL_NUM_OFFSET],
bcd_offset,
&bcd_flag,
&c1);
if (c1 == 0x0C || c1 == 0x0D) /* with p or w */
{
result = KAL_TRUE;
}
}
if (result == KAL_TRUE)
{
len = (len + 1) >> 1;
phb_entry->tel_number.addr_length = len + L4_ADDR_BCD_TON_NPI_SIZE;
phb_entry->tel_number.addr_bcd[L4_ADDR_BCD_TON_NPI_OFFSET] = TON_NPI_DEFAULT;
kal_mem_cpy(
&phb_entry->tel_number.addr_bcd[L4_ADDR_BCD_TEL_NUM_OFFSET],
(void const*)&eccs->ecc[i * NUM_OF_BYTE_ECC],
len);
phb_entry->storage = PHB_SIM;
break;
}
}
}
/* Try to approve hardcoded ECC's */
if (result == KAL_FALSE)
{
phb_entry->storage = PHB_STORAGE_NONE;
for (i = 0; i < phb_ecc_num_total; ++i)
{
/* Try exact matching ECC */
len = bcd_len(&phb_ecc_num[i * NUM_OF_BYTE_ECC], NUM_OF_BYTE_ECC);
len2 = bcd_len(
&tel_number->addr_bcd[L4_ADDR_BCD_TEL_NUM_OFFSET],
(kal_uint16) (tel_number->addr_length - L4_ADDR_BCD_TON_NPI_SIZE));
if (len > len2)
{
continue;
}
if (compare_n_bcd(
&phb_ecc_num[i * NUM_OF_BYTE_ECC],
&tel_number->addr_bcd[L4_ADDR_BCD_TEL_NUM_OFFSET],
len) == 0)
{
if (len == len2) /* same len */
{
result = KAL_TRUE;
}
else /* len2 > len */
{
bcd_n = len;
bcd_flag = KAL_TRUE;
bcd_offset = 0;
while (bcd_n > 0)
{
bcd_offset = get_next_bcd_digit(
&tel_number->addr_bcd[L4_ADDR_BCD_TEL_NUM_OFFSET],
bcd_offset,
&bcd_flag,
&c1);
bcd_n--;
}
bcd_offset = get_next_bcd_digit(
&tel_number->addr_bcd[L4_ADDR_BCD_TEL_NUM_OFFSET],
bcd_offset,
&bcd_flag,
&c1);
if (c1 == 0x0C || c1 == 0x0D || c1 == 0x0E) /* with p or w or + */
{
result = KAL_TRUE;
}
}
if (result == KAL_TRUE)
{
len = (len + 1) >> 1;
phb_entry->tel_number.addr_length = len + L4_ADDR_BCD_TON_NPI_SIZE;
phb_entry->tel_number.addr_bcd[L4_ADDR_BCD_TON_NPI_OFFSET] = TON_NPI_DEFAULT;
kal_mem_cpy(
&phb_entry->tel_number.addr_bcd[L4_ADDR_BCD_TEL_NUM_OFFSET],
(void const*)&eccs->ecc[i * NUM_OF_BYTE_ECC],
len);
break;
}
}
i++; /* skip the first digit is + */
}
}
/* Consider *31# or #31# case */
if (((tel_number->addr_bcd[L4_ADDR_BCD_TEL_NUM_OFFSET] == 0x3a ||
tel_number->addr_bcd[L4_ADDR_BCD_TEL_NUM_OFFSET] == 0x3b) &&
tel_number->addr_bcd[L4_ADDR_BCD_TEL_NUM_OFFSET + 1] == 0xb1))
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -