📄 phb_handler_approve.c
字号:
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 + 2],
(kal_uint16) (tel_number->addr_length - L4_ADDR_BCD_TON_NPI_SIZE - 2));
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 + 2],
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 + 2],
bcd_offset,
&bcd_flag,
&c1);
bcd_n--;
}
bcd_offset = get_next_bcd_digit(
&tel_number->addr_bcd[L4_ADDR_BCD_TEL_NUM_OFFSET + 2],
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*)&phb_ecc_num[i * NUM_OF_BYTE_ECC],
len);
break;
}
}
}
}
return result;
} /* end of phb_approve_err_handler function */
/*****************************************************************************
* FUNCTION
* phb_approve_fdn
* DESCRIPTION
*
* PARAMETERS
* control_block [?]
* tel_number [?]
* l4cphb_approve_req [?]
* ilm_ptr(?) [IN] The primitives
* RETURNS
* void
*****************************************************************************/
static kal_bool phb_approve_fdn(
control_block_type *control_block,
l4_addr_bcd_struct *tel_number,
l4cphb_approve_req_struct *l4cphb_approve_req)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_bool is_more_candidates;
kal_uint8 fdn_proc_stage = APPROVE_NONE;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/*
* FDN enabled.
*
* When FDN is enabled, is_retrieve should be ignored.
* Because, FDN defines just prefix, moreover, could be extended by user,
* searching that phone number either in FDN or PHB_PHONEBOOK is
* meaningless!
*
* Note:
* FDN approved number need not be retrieved!!
*/
if ((phb_ptr->dn_type == TYPE_FDN) || (phb_ptr->dn_type == TYPE_FDN_BDN))
{
l4_addr_bcd_struct *num_pattern;
name_num_index_type *name_num_index;
data_entry_struct *data_entry;
control_block->type = PHB_FDN;
control_block->candidate_name_num_index =
phb_se_compare_tel_number_with_first_character(control_block->type, tel_number, &control_block->candidate, &is_more_candidates);
if ((control_block->candidate != (kal_uint16) PHB_INVALID_VALUE) &&
(control_block->candidate_name_num_index != NULL))
{
/**
* Since match the first character, it is ncessary to search into PHB_PHONEBOOK
* for retrieving the entry that matches this TON.
*/
fdn_proc_stage = APPROVE_FDN_ONE_CHARACTER;
}
else
{
control_block->candidate_name_num_index = phb_se_search_by_tel_num(control_block->type, tel_number, &control_block->candidate, &is_more_candidates);
fdn_proc_stage = APPROVE_FDN;
/* No candidates. Great! */
if ((control_block->candidate == (kal_uint16) PHB_INVALID_VALUE) ||
(control_block->candidate_name_num_index == NULL))
{
control_block->actual_count = 0;
/**
* Since this entry is not approved by FDN under
* FDN enabled condition, it is uncessary to search into PHB_PHONEBOOK
* for retrieving the entry that matches this phone number.
*/
control_block->proc_stage = APPROVE_FDN;
phb_approve_confirm(PHB_ERRNO_FAIL, control_block->type, control_block->src_id, control_block, NULL);
return KAL_TRUE;
}
}
/**
* At least one candidate is found.
* Must verify the attempting phone number with each candidate.
*/
/**
* Now hold local parameter, since we have to verify telephone number
* Don't forget to release it.
*/
num_pattern = (l4_addr_bcd_struct*) get_ctrl_buffer(sizeof(l4_addr_bcd_struct));
kal_mem_cpy(num_pattern, (void const*)&l4cphb_approve_req->tel_number, sizeof(l4_addr_bcd_struct));
phb_control_block_set_param(control_block, fdn_proc_stage, num_pattern, NULL);
phb_control_block_set(
control_block,
phb_approve_continue,
phb_approve_handler,
phb_approve_err_handler,
fdn_proc_stage);
/**
* Read specific record for verification.
*/
phb_control_block_set_IO(control_block, control_block->type, (kal_uint16) PHB_INVALID_VALUE, 1);
/* set storage, record_index, primary_ID, and secondary_ID */
name_num_index = (name_num_index_type*) control_block->candidate_name_num_index;
data_entry =
&name_num_index->data_entry_table.table[name_num_index->num_index.table[control_block->candidate].position];
phb_se_set_control_block(
control_block,
OP_READ,
(phb_storage_enum) data_entry->storage,
data_entry->record_index);
/**
* Since phb_se_set_control_block() modifies control_block->proc_stage,
* it has to be restored.
*/
control_block->proc_stage = fdn_proc_stage;
control_block->data = (kal_uint8*) & control_block->temp_entry;
control_block->length = phb_data_desc_get_record_size(phb_data_desc_get_desc_by_ID(control_block->primary_ID));
phb_approve_continue(NULL, control_block);
return KAL_TRUE;
}
return KAL_FALSE;
} /* end of phb_approve_err_handler function */
/*****************************************************************************
* FUNCTION
* phb_approve_rest_for_PHB_not_ready
* DESCRIPTION
*
* PARAMETERS
* l4cphb_approve_req [?]
* ilm_ptr(?) [IN] The primitives
* RETURNS
* void
*****************************************************************************/
static void phb_approve_rest_for_PHB_not_ready(l4cphb_approve_req_struct *l4cphb_approve_req)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
sim_dn_enum dn_type;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/**
* Since PHB is not ready, dn_type could be un-determined.
* What PHB can do is directly query SMU.
*/
if (phb_ptr->state != PHB_STATE_READY)
{
dn_type = l4csmu_get_dial_mode();
}
else
{
dn_type = phb_ptr->dn_type;
}
/**
* Due to control_block is not allocated, PHB cannot try to
* approve the attempting dialling number.
*/
if ((dn_type == TYPE_FDN) || (dn_type == TYPE_FDN_BDN))
{
phb_approve_confirm(PHB_ERRNO_FAIL, PHB_NONE, l4cphb_approve_req->src_id, NULL, NULL);
return;
}
else if ((dn_type == TYPE_ADN) || (dn_type == TYPE_BDN) || (dn_type == TYPE_ADN_BDN) || (dn_type == TYPE_FDN_BDN) ||
/**
* 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.
*/
(dn_type == TYPE_NONE))
{
phb_approve_confirm(PHB_ERRNO_SUCCESS, PHB_NONE, l4cphb_approve_req->src_id, NULL, NULL);
return;
}
/* Exception case, dn_type is invalid! Make approval failed! */
else
{
phb_approve_confirm(PHB_ERRNO_FAIL, PHB_NONE, l4cphb_approve_req->src_id, NULL, NULL);
return;
}
} /* end of phb_approve_err_handler function */
/*****************************************************************************
* FUNCTION
* phb_approve_err_handler
* DESCRIPTION
* This is phb_approve_err_handler function of PHB module.
* This function should only be called when a request is IN PROECESSING.
* That means error handler is called if error occured while processing the
* request and after controller received the request and returned.
* Ie, if a request is just being handled and it is rejected,
* controller/handler should call confirm to reject it directly.
*
* Hence, unlike handler invokes confirm with EXCEPTION which gives up
* just received request; when this function is called, the in-processing
* request is given up.
*
* So, the difference between invoking confirm with EXCEPTION and
* error handler is: whether control_block_alloc() is invoked; if true,
* call latter, otherwise, call former.
* PARAMETERS
* ilm_ptr [IN] The primitives
* control_block [?]
* RETURNS
* void
*****************************************************************************/
static void phb_approve_err_handler(ilm_struct *ilm_ptr, control_block_type *control_block)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
kal_trace(TRACE_FUNC, FUNC_PHB_APPROVE_ERR);
/**
* Shall we try to recover/continue handling,
* or just reject the request in processing?
* Currently, the latter is adpoted.
*/
control_block->actual_count = 0;
phb_approve_confirm(PHB_ERRNO_FAIL, control_block->type, control_block->src_id, control_block, NULL);
/*
* if (ilm_ptr != NULL)
* (*phb_ptr->control_block.controller)(ilm_ptr);
*/
} /* end of phb_approve_err_handler function */
/*****************************************************************************
* FUNCTION
* phb_approve_continue
* DESCRIPTION
* This is phb_approve_continue function of PHB module.
*
* Note:
* Only searching PHB_PHBONEBOOK and PHB_BYNUMBER can reach this function.
* PARAMETERS
* ilm_ptr [IN] The primitives
* control_block [?]
* RETURNS
* void
*****************************************************************************/
static void phb_approve_continue(ilm_struct *ilm_ptr, control_block_type *control_block)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
kal_trace(TRACE_FUNC, FUNC_PHB_APPROVE_CONT);
if (ilm_ptr == NULL)
{
phb_issue_IO_read(control_block);
}
/* Read confirmed. Now verify the entry! */
else
{
/* Note: only approving FDN can reach here. */
/* Query pattern is stored in local_param_ptr */
l4_addr_bcd_struct *given = (l4_addr_bcd_struct*) control_block->local_param_ptr;
/* The just read back candidate is stored in control_block->data */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -