/*****************************************************************************
 * FUNCTION
 *  phb_sat_file_change_confirm
 * DESCRIPTION
 *  This is phb_sat_file_change_confirm function of PHB module.
 * PARAMETERS
 *  result              [IN]        
 *  src_id              [IN]        
 *  control_block       [?]         
 *  ilm_ptr(?)          [IN]        The primitives
 * RETURNS
 *  void
 *****************************************************************************/
void phb_sat_file_change_confirm(phb_errno_enum result, kal_uint8 src_id, control_block_type *control_block)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    local_para_struct *local_param_ptr = NULL;
    sat_file_change_res_struct *sat_file_change_res;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_PHB_SAT_FILE_CHANGE_CNF, result, src_id);

    sat_file_change_res = (sat_file_change_res_struct*) construct_local_para(
                                                            sizeof(sat_file_change_res_struct),
                                                            TD_CTRL);
    sat_file_change_res->src_id = src_id;

    local_param_ptr = (local_para_struct*) sat_file_change_res;

    /* Reject newly received request */
    if (result == PHB_ERRNO_BUSY)
    {
        sat_file_change_res->is_successful = KAL_FALSE;
    }

    else
    {
        sat_file_change_res->is_successful = (result == PHB_ERRNO_SUCCESS) ? KAL_TRUE : KAL_FALSE;

        if (control_block)
        {
            phb_free_control_block(control_block);
        }
    }

    phb_send_ilm(MOD_SIM, MSG_ID_SAT_FILE_CHANGE_RES, local_param_ptr, NULL);
}   /* end of phb_sat_file_change_confirm */
예제 #2
0
/*****************************************************************************
 * FUNCTION
 *  phb_search_confirm
 * DESCRIPTION
 *  This is phb_search_confirm function of PHB module.
 * PARAMETERS
 *  result              [IN]        
 *  actual_count        [IN]        
 *  src_id              [IN]        
 *  cnf_msg_id          [IN]        
 *  control_block       [?]         
 *  ilm_ptr(?)          [IN]        The primitives
 * RETURNS
 *  void
 *****************************************************************************/
static void phb_search_confirm(
                phb_errno_enum result,
                kal_uint16 actual_count,
                kal_uint8 src_id,
                msg_type cnf_msg_id,
                control_block_type *control_block)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    local_para_struct *local_param_ptr = NULL;
    peer_buff_struct *peer_buf_ptr = NULL;

    kal_uint16 msg_id = 0;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_FUNC, FUNC_PHB_SEARCH_CNF, result, actual_count, src_id, cnf_msg_id);

    /* First we release local parameter. */
    if ((result != PHB_ERRNO_BUSY) && (control_block->local_param_ptr != NULL))
    {
        free_ctrl_buffer(control_block->local_param_ptr);
    }

    if ((result == PHB_ERRNO_BUSY) || (control_block->cnf_msg_id == MSG_ID_L4CPHB_SEARCH_REQ))
    {
        l4cphb_search_cnf_struct *l4cphb_search_cnf;

        l4cphb_search_cnf = (l4cphb_search_cnf_struct*) construct_local_para(
                                                            sizeof(l4cphb_search_cnf_struct),
                                                            TD_CTRL);
        l4cphb_search_cnf->total = actual_count;
        l4cphb_search_cnf->src_id = src_id;
        l4cphb_search_cnf->result = result;

        /* Field `cause' is meaningful when I/O occured by using control blocks */
        l4cphb_search_cnf->cause = control_block->cause;

        if (result == PHB_ERRNO_BUSY)
        {

            phb_send_ilm(MOD_L4C, MSG_ID_L4CPHB_SEARCH_CNF, (local_para_struct*) l4cphb_search_cnf, NULL);
            return;
        }

        local_param_ptr = (local_para_struct*) l4cphb_search_cnf;

        msg_id = MSG_ID_L4CPHB_SEARCH_CNF;
    }

   /**
    * Under ADN mode, only when is_retrieve is true and searching into
    * physical storage device is required will call search_continue(), which
    * in consequence results in this search_confirm() is invoked.
    *
    * Since it is ADN mode, no matter the search result is,
    * the approval result is ALWAYS success!!
    */
    else if (control_block->cnf_msg_id == MSG_ID_L4CPHB_APPROVE_REQ)
    {
        l4cphb_approve_cnf_struct *l4cphb_approve_cnf;

        l4cphb_approve_cnf = (l4cphb_approve_cnf_struct*) construct_local_para(
                                                            sizeof(l4cphb_approve_cnf_struct),
                                                            TD_CTRL);
        l4cphb_approve_cnf->result = PHB_ERRNO_SUCCESS;

        /* Field `cause' is meaningful when I/O occured by using control blocks */
        l4cphb_approve_cnf->cause = control_block->cause;

        l4cphb_approve_cnf->type = control_block->type;
        l4cphb_approve_cnf->src_id = control_block->src_id;

        local_param_ptr = (local_para_struct*) l4cphb_approve_cnf;

        msg_id = MSG_ID_L4CPHB_APPROVE_CNF;
    }

    /* EXCEPTION cannot reach here */
    if (control_block->peer_buf_ptr != NULL)
    {
        if (control_block->actual_count > 0)
        {
            peer_buf_ptr = (peer_buff_struct*) control_block->peer_buf_ptr;
            control_block->peer_buf_ptr = NULL;
        }
        else
        {
            free_ctrl_buffer(control_block->peer_buf_ptr);
            peer_buf_ptr = NULL;
        }
        control_block->need_free_peer = KAL_FALSE;
    }

    phb_free_control_block(control_block);

    phb_send_ilm(MOD_L4C, msg_id, local_param_ptr, peer_buf_ptr);
}   /* end of phb_search_confirm */