Example #1
0
static void
dp_int_message (line_t line, callid_t call_id, char digit,
                char *digit_str, boolean collect_more, void *tmr_data,
                int msg_id, char *g_call_id, monitor_mode_t monitor_mode)
{
    char fname[] = "dp_int_message";
    dp_int_t *pmsg;

    pmsg = (dp_int_t *) cc_get_msg_buf(sizeof(dp_int_t));

    if (!pmsg) {
        err_msg(get_debug_string(CC_NO_MSG_BUFFER), fname);
        return;
    }

    pmsg->line = line;
    pmsg->call_id = call_id;
    pmsg->digit = digit;
    if (digit_str) {
        sstrncpy(pmsg->digit_str, digit_str, MAX_DIALSTRING);
    }
    pmsg->collect_more = collect_more;
    pmsg->tmr_ptr = tmr_data;
    if (digit_str) {
        sstrncpy(pmsg->global_call_id, g_call_id, CC_GCID_LEN);
    }

    pmsg->monitor_mode = monitor_mode;
    if (gsm_send_msg(msg_id, (cprBuffer_t) pmsg, sizeof(dp_int_t)) !=
        CPR_SUCCESS) {
        err_msg(get_debug_string(CC_SEND_FAILURE), fname);
    }
}
int
sip_platform_udp_channel_send (cpr_socket_t s, char *buf, uint16_t len)
{
    static const char *fname = "sip_platform_udp_channel_send";
    ssize_t bytesSent;

    /*
     * Check not exceeding max allowed payload size
     */
    if (len >= PKTBUF_SIZ) {
        CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_UDP_PAYLOAD_TOO_LARGE),
                          fname, len, PKTBUF_SIZ);
        return SIP_ERROR;
    }

    while (len > 0) {
        bytesSent = sipSocketSend(s, (void *)buf, (size_t)len, 0, FALSE);
        if (bytesSent == SOCKET_ERROR) {
            CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_GENERAL_SYSTEMCALL_FAILED),
                              fname, "cprSend", cpr_errno);
            return SIP_ERROR;
        }

        len -= bytesSent;
        buf += bytesSent;
    }

    return SIP_OK;
}
int
sip_platform_udp_channel_sendto (cpr_socket_t s, char *buf, uint32_t len,
                                 cpr_ip_addr_t *dst_ipaddr, uint16_t dst_port)
{
    static const char *fname = "sip_platform_udp_channel_sendto";
    ssize_t bytesSent;
    cpr_sockaddr_storage sock_addr;
    uint16_t       addr_len;
    cpr_ip_addr_t  dest_ip_addr;

    /*
     * Connect to remote address
     */
    dest_ip_addr = *dst_ipaddr;
    (void) sip_set_sockaddr(&sock_addr, af_family_connect, dest_ip_addr,
                            dst_port, &addr_len);


    /*
     * Check not exceeding max allowed payload size
     */
    if (len >= PKTBUF_SIZ) {
        CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_UDP_PAYLOAD_TOO_LARGE),
                          fname, len, PKTBUF_SIZ);
        return SIP_ERROR;
    }

    while (len > 0) {
        bytesSent = cprSendTo(s, (void *)buf, (size_t)len, 0,
                              (cpr_sockaddr_t *)&sock_addr, addr_len);

        if ((bytesSent == SOCKET_ERROR) && (cpr_errno == CPR_ECONNREFUSED)) {
            /*
             * Will get socket error ECONNREFUSED after an ICMP message
             * resend the message
             */
            CCSIP_DEBUG_TASK(DEB_F_PREFIX"UDP send to error %d\n", DEB_F_PREFIX_ARGS(SIP_SOCK, fname), cpr_errno);
            bytesSent = cprSendTo(s, (void *)buf, (size_t)len, 0,
                                  (cpr_sockaddr_t *)&sock_addr, addr_len);
        }
        if (bytesSent == SOCKET_ERROR) {
            CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_GENERAL_SYSTEMCALL_FAILED),
                              fname, "cprSendTo", cpr_errno);
            return SIP_ERROR;
        }

        len -= bytesSent;
        buf += bytesSent;
    }

    return SIP_OK;
}
Example #4
0
void
fsm_sm_ignore_ftr (fsm_fcb_t *fcb, int fname, cc_features_t ftr_id)
{
    FSM_DEBUG_SM(get_debug_string(FSM_DBG_IGNORE_FTR),
                 fsm_type_name(fcb->fsm_type), fcb->call_id, fname,
                 cc_feature_name(ftr_id));
}
Example #5
0
void
fsm_sm_ignore_src (fsm_fcb_t *fcb, int fname, cc_srcs_t src_id)
{
    FSM_DEBUG_SM(get_debug_string(FSM_DBG_IGNORE_SRC),
                 fsm_type_name(fcb->fsm_type), fcb->call_id, fname,
                 cc_src_name(src_id));
}
Example #6
0
/*
 *  DESCRIPTION: return the fcb referenced by the given call_id and type
 *
 *  PARAMETERS:  fsm_id
 *
 *  @return void
 *      !NULL: fcb found
 *      NULL:  fcb not found
 *
 */
void
fsm_get_fcb_by_selected_or_connected_call_fcb (callid_t call_id, fsm_fcb_t **con_fcb_found,
                                               fsm_fcb_t **sel_fcb_found)
{
    static const char fname[] = "fsm_get_fcb_by_selected_or_connected_call_fcb";
    fsm_fcb_t      *fcb;

    *con_fcb_found = NULL;
    *sel_fcb_found = NULL;

    FSM_FOR_ALL_CBS(fcb, fsm_fcbs, FSM_MAX_FCBS) {

        if (fcb->call_id == call_id) {
            /* Do not count current call_id */
            continue;
        }
        if (fcb->fsm_type == FSM_TYPE_DEF &&
            (fcb->state == FSMDEF_S_CONNECTED ||
             fcb->state == FSMDEF_S_CONNECTED_MEDIA_PEND ||
             fcb->state == FSMDEF_S_OUTGOING_ALERTING)) {
            *con_fcb_found = fcb;
        } else if (fcb->fsm_type == FSM_TYPE_DEF && fcb->dcb->selected) {
            *sel_fcb_found = fcb;
            break;
        }
    }

    FSM_DEBUG_SM(get_debug_string(GSM_DBG_PTR), "FSM", call_id,
                 fname, "fcb", con_fcb_found);

}
/********************************************************
 *
 * Local Expires timer support functions for SIP SM
 *
 ********************************************************/
int
sip_platform_localexpires_timer_start (uint32_t msec,
                                       int idx,
                                       cpr_ip_addr_t *ipaddr,
                                       uint16_t port)
{
    static const char fname[] = "sip_platform_localexpires_timer_start";

    if (sip_platform_localexpires_timer_stop(idx) == SIP_ERROR) {
        return SIP_ERROR;
    }

    sipPlatformUISMLocalExpiresTimers[idx].ipaddr = *ipaddr;
    sipPlatformUISMLocalExpiresTimers[idx].port = port;

    //sip_platform_localexpires_timer_callback
    if (cprStartTimer(sipPlatformUISMLocalExpiresTimers[idx].timer, msec,
                      (void *)(long) idx) == CPR_FAILURE) {
        CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED),
                          idx, 0, fname, "cprStartTimer");
        return SIP_ERROR;
    }

    return SIP_OK;
}
/********************************************************
 *
 * Message timer support functions for SIP SM
 *
 ********************************************************/
void
sip_platform_msg_timers_init (void)
{
    static const char fname[] = "sip_platform_msg_timers_init";
    static long timer_init_complete = 0;
    int i;
    cprTimer_t timer, reg_timer;

    for (i = 0; i < MAX_CCBS; i++) {
        if (timer_init_complete) {
            if ((cprCancelTimer(sipPlatformUISMTimers[i].timer)
                    == CPR_FAILURE) ||
                (cprCancelTimer(sipPlatformUISMTimers[i].reg_timer)
                    == CPR_FAILURE)) {
                CCSIP_DEBUG_STATE(get_debug_string(DEBUG_GENERAL_FUNCTIONCALL_FAILED),
                                  fname, "cprCancelTimer");
            }
        }
        timer = sipPlatformUISMTimers[i].timer;
        reg_timer = sipPlatformUISMTimers[i].reg_timer;

        if (sipPlatformUISMTimers[i].message_buffer != NULL) {
            cpr_free(sipPlatformUISMTimers[i].message_buffer);
            sipPlatformUISMTimers[i].message_buffer = NULL;
            sipPlatformUISMTimers[i].message_buffer_len = 0;
        }

        memset(&sipPlatformUISMTimers[i], 0, sizeof(sipPlatformUITimer_t));
        sipPlatformUISMTimers[i].timer = timer;
        sipPlatformUISMTimers[i].reg_timer = reg_timer;
    }
    timer_init_complete = 1;
    return;
}
Example #9
0
const char *
fsm_type_name (fsm_types_t type)
{
    if ((type <= FSM_TYPE_MIN) || (type >= FSM_TYPE_MAX)) {
        return (get_debug_string(GSM_UNDEFINED));
    }

    return (fsm_type_names[type]);
}
Example #10
0
const char *
fsmb2bcnf_state_name (int state)
{
    if ((state <= FSMB2BCNF_S_MIN) || (state >= FSMB2BCNF_S_MAX)) {
        return (get_debug_string(GSM_UNDEFINED));
    }

    return (fsmb2bcnf_state_names[state]);
}
void
sip_platform_msg_timer_stop (int idx)
{
    static const char fname[] = "sip_platform_msg_timer_stop";

    if ((idx < MIN_TEL_LINES) || (idx >= MAX_CCBS)) {
        CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_LINE_NUMBER_INVALID),
                          fname, idx);
        return;
    }

    if ((cprCancelTimer(sipPlatformUISMTimers[idx].timer) == CPR_FAILURE) ||
        (cprCancelTimer(sipPlatformUISMTimers[idx].reg_timer) == CPR_FAILURE)) {
        CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED),
                          idx, 0, fname, "cprCancelTimer");
        return;
    }
    sipPlatformUISMTimers[idx].outstanding = FALSE;
}
int
sip_platform_supervision_disconnect_timer_stop (int idx)
{
    static const char fname[] = "sip_platform_supervision_disconnect_timer_stop";

    if ((idx < TEL_CCB_START) || (idx > TEL_CCB_END)) {
        CCSIP_DEBUG_STATE(get_debug_string(DEBUG_LINE_NUMBER_INVALID), fname, idx);
        return SIP_ERROR;
    }

    if (cprCancelTimer(sipPlatformSupervisionTimers[idx].timer)
            == CPR_FAILURE) {
        CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED),
                          idx, 0, fname, "cprCancelTimer");
        return SIP_ERROR;
    }

    return SIP_OK;
}
int
sip_platform_localexpires_timer_stop (int idx)
{
    static const char fname[] = "sip_platform_localexpires_timer_stop";

    if ((idx < MIN_TEL_LINES) || (idx >= MAX_CCBS)) {
        CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_LINE_NUMBER_INVALID),
                          fname, idx);
        return SIP_ERROR;
    }

    if (cprCancelTimer(sipPlatformUISMLocalExpiresTimers[idx].timer)
            == CPR_FAILURE) {
        CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED),
                          idx, 0, fname, "cprCancelTimer");
        return SIP_ERROR;
    }

    return SIP_OK;
}
/**
 ** sip_platform_reg_all_fail_timer_stop
 *  Stops the Reg-All Fail timer  
 *  
 *  @param  none
 *
 *  @return SIP_OK if timer could be stopped; else  SIP_ERROR
 *
 */
int
sip_platform_reg_all_fail_timer_stop (void)
{
    static const char fname[] = "sip_platform_reg_all_fail_timer_stop";

    if (cprCancelTimer(sipPlatformRegAllFailedTimer) == CPR_FAILURE) {
        CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED),
                          0, 0, fname, "cprCancelTimer");
        return SIP_ERROR;
    }
    return SIP_OK;
}
int
sip_platform_notify_timer_stop ()
{
    static const char fname[] = "sip_platform_notify_timer_stop";

    if (cprCancelTimer(sipPlatformNotifyTimer) == CPR_FAILURE) {
        CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED),
                          0, 0, fname, "cprCancelTimer");
        return SIP_ERROR;
    }
    return SIP_OK;
}
 /**
  ** sip_platform_pass_through_timer_stop
  *  Stops the Pass Through timer
  *
  *  @param  none
  *
  *  @return SIP_OK if timer could be stopped; else  SIP_ERROR
  *
  */
int
sip_platform_pass_through_timer_stop (void)
{
	static const char fname[] = "sip_platform_pass_through_timer_stop";
	
	if (cprCancelTimer(sipPassThroughTimer) == CPR_FAILURE) {
		CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED),
						  0, 0, fname, "cprCancelTimer");
		return SIP_ERROR;
	}
	return SIP_OK;
}
int
sip_platform_msg_timer_subnot_start (uint32_t msec,
                                     sipPlatformUITimer_t *timer_p,
                                     uint32_t id,
                                     char *message_buffer,
                                     int message_buffer_len,
                                     int message_type,
                                     cpr_ip_addr_t *ipaddr,
                                     uint16_t port)
{
    static const char fname[] = "sip_platform_msg_timer_start_subnot";

    sip_platform_msg_timer_subnot_stop(timer_p);

    if (message_buffer_len > SIP_UDP_MESSAGE_SIZE) {
        CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_MSG_BUFFER_TOO_BIG),
                          fname, message_buffer_len);
        return SIP_ERROR;
    }

    if (timer_p->message_buffer == NULL) {
        timer_p->message_buffer = (char *)cpr_malloc(message_buffer_len+1);
        if (timer_p->message_buffer == NULL) return SIP_ERROR;
    }
    else if (timer_p->message_buffer != message_buffer) {
        cpr_free(timer_p->message_buffer);
        timer_p->message_buffer = (char *)cpr_malloc(message_buffer_len+1);
        if (timer_p->message_buffer == NULL) return SIP_ERROR;
    }

    timer_p->message_buffer_len = message_buffer_len;
    timer_p->message_buffer[message_buffer_len] = '\0';
    memcpy(timer_p->message_buffer, message_buffer,
           message_buffer_len);
    timer_p->message_type =
        (sipMethod_t) message_type;
    timer_p->ipaddr = *ipaddr;
    timer_p->port = port;

    if (cprStartTimer(timer_p->timer, msec, (void *)(long)id) == CPR_FAILURE) {
        CCSIP_DEBUG_ERROR(SIP_F_PREFIX "%s failed\n",
                          fname, "cprStartTimer");
        cpr_free(timer_p->message_buffer);
        timer_p->message_buffer = NULL;
        timer_p->message_buffer_len = 0;
        return SIP_ERROR;
    }

    return SIP_OK;

}
int
sip_platform_udp_channel_read (cpr_socket_t s,
                               cprBuffer_t buf,
                               uint16_t *len,
                               cpr_sockaddr_t *soc_addr,
                               cpr_socklen_t *soc_addr_len)
{
    static const char *fname = "sip_platform_udp_channel_read";
    int bytes_read;
    // NOT USED: cpr_sockaddr_in_t *addr = (cpr_sockaddr_in_t *)soc_addr;

    bytes_read = cprRecvFrom(s, buf, CPR_MAX_MSG_SIZE, 0, soc_addr,
                             soc_addr_len);

    switch (bytes_read) {
    case SOCKET_ERROR:
        /*
         * If no data is available to read (CPR_EWOULDBLOCK),
         * for non-blocking socket, it is not an error.
         */
        cpr_free(buf);
        *len = 0;
        if (cpr_errno != CPR_EWOULDBLOCK) {
            CCSIP_DEBUG_ERROR(SIP_F_PREFIX"fd[%d]\n", fname, s);
            CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_GENERAL_SYSTEMCALL_FAILED),
                              fname, "cprRecvFrom", cpr_errno);
            return SIP_ERROR;
        }
        /*
         * Will continue reading when data arrives at socket
         */
        break;
    case 0:
        /*
         * Return value 0 is OK.  This does NOT mean the connection
         * has closed by the peer, as with TCP sockets.  With UDP
         * sockets, there is no such thing as closing a connection.
         */
        CCSIP_DEBUG_MESSAGE(DEB_F_PREFIX"No data on fd %d\n", DEB_F_PREFIX_ARGS(SIP_SDP, fname), s);
        cpr_free(buf);
        *len = 0;
        break;
    default:
        /* PKT has been read */
        CCSIP_DEBUG_MESSAGE(DEB_F_PREFIX"Recvd on fd %d\n", DEB_F_PREFIX_ARGS(SIP_SDP, fname), s);
        *len = (uint16_t) bytes_read;
        break;
    }

    return SIP_OK;
}
int
sip_platform_udp_channel_destroy (cpr_socket_t s)
{
    static const char fname[] = "sip_platform_udp_channel_destroy";

    if (s != INVALID_SOCKET) {
        if (sipSocketClose(s, FALSE) == CPR_FAILURE) {
            CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_GENERAL_SYSTEMCALL_FAILED),
                              fname, "sipSocketClose", cpr_errno);
            return SIP_ERROR;
        }
    }
    return SIP_OK;
}
int
sip_platform_subnot_periodic_timer_stop (void)
{
    static const char fname[] = "sip_platform_subnot_periodic_timer_stop";

    if (sipPlatformSubNotPeriodicTimer.started == TRUE) {
        if (cprCancelTimer(sipPlatformSubNotPeriodicTimer.timer)
                == CPR_FAILURE) {
            CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED),
                              -1, 0, fname, "cprCancelTimer");
            return SIP_ERROR;
        }
    }
    sipPlatformSubNotPeriodicTimer.started = FALSE;
    return SIP_OK;
}
/***********************************************
  *         PassThrough Timer
 ***********************************************
  ** sip_platform_pass_through_timer_start
  *  Starts a timer when all registrations fail.
  *
  *  @param  sec Value of the timer to be started
  *
  *  @return SIP_OK if timer could be started; else  SIP_ERROR
  *
  */
int
sip_platform_pass_through_timer_start (uint32_t sec)
{
	static const char fname[] = "sip_platform_pass_through_timer_start";
	
	if (sip_platform_pass_through_timer_stop() == SIP_ERROR) {
		return SIP_ERROR;
	}	
	if (cprStartTimer(sipPassThroughTimer, sec*1000, NULL) == CPR_FAILURE) {
		CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED),
				 		  0, 0, fname, "cprStartTimer");
		return SIP_ERROR;
	}
	
	CCSIP_DEBUG_REG_STATE("%s: Regmgr Pass Through Timer started for %lu secs\n", fname, sec);
	return SIP_OK;
}
/*
 * Call disconnect timer
 */
int
sip_platform_supervision_disconnect_timer_start (uint32_t msec, int idx)
{
    static const char fname[] = "sip_platform_supervision_disconnect_timer_start";

    if (sip_platform_supervision_disconnect_timer_stop(idx) == SIP_ERROR) {
        return SIP_ERROR;
    }

    if (cprStartTimer(sipPlatformSupervisionTimers[idx].timer, msec,
                      (void *)(long) idx) == CPR_FAILURE) {
        CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED),
                          idx, 0, fname, "cprStartTimer");
        return SIP_ERROR;
    }

    return SIP_OK;
}
int
sip_platform_notify_timer_start (uint32_t msec)
{
    static const char fname[] = "sip_platform_notify_timer_start";

    if (sip_platform_notify_timer_stop() == SIP_ERROR) {
        return SIP_ERROR;
    }

    if (cprStartTimer(sipPlatformNotifyTimer, msec, NULL) == CPR_FAILURE) {
        CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED),
                          0, 0, fname, "cprStartTimer");
        return SIP_ERROR;
    }
    CCSIP_DEBUG_STATE(DEB_F_PREFIX
        "Timer started for %lu msecs\n", DEB_F_PREFIX_ARGS(SIP_TIMER, fname), msec);
    return SIP_OK;
}
int
sip_platform_register_expires_timer_start (uint32_t msec, int idx)
{
    static const char fname[] = "sip_platform_register_expires_timer_start";

    if (sip_platform_register_expires_timer_stop(idx) == SIP_ERROR) {
        return SIP_ERROR;
    }

    if (cprStartTimer(sipPlatformUISMRegExpiresTimers[idx].timer, msec,
                      (void *)(long) idx) == CPR_FAILURE) {
        CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED),
                          idx, 0, fname, "cprStartTimer");
        return SIP_ERROR;
    }

    return SIP_OK;
}
int
sip_platform_subnot_periodic_timer_start (uint32_t msec)
{
    static const char fname[] = "sip_platform_subnot_periodic_timer_start";

    if (sip_platform_subnot_periodic_timer_stop() == SIP_ERROR) {
        return SIP_ERROR;
    }

    if (cprStartTimer(sipPlatformSubNotPeriodicTimer.timer, msec, (void *) 0)
            == CPR_FAILURE) {
        CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED),
                          -1, 0, fname, "cprStartTimer");
        return SIP_ERROR;
    }
    sipPlatformSubNotPeriodicTimer.started = TRUE;
    return SIP_OK;
}
int
sip_platform_unregistration_timer_start (uint32_t msec, boolean external)
{
    static const char fname[] = "sip_platform_unregistration_timer_start";

    if (sip_platform_unregistration_timer_stop() == SIP_ERROR) {
        return SIP_ERROR;
    }

    if (cprStartTimer(sipPlatformUnRegistrationTimer, msec, (void *)(long)external)
            == CPR_FAILURE) {
        CCSIP_DEBUG_STATE(get_debug_string(DEBUG_SIP_FUNCTIONCALL_FAILED),
                          0, 0, fname, "cprStartTimer");
        return SIP_ERROR;
    }
    CCSIP_DEBUG_STATE(DEB_F_PREFIX
        "Timer started for %lu msecs\n", DEB_F_PREFIX_ARGS(SIP_TIMER, fname), msec);
    return SIP_OK;
}
Example #27
0
/*
 *  ROUTINE:     fsm_get_fcb_by_call_id
 *
 *  DESCRIPTION: return the fcb referenced by the given call_id
 *
 *  PARAMETERS:  fsm_id
 *
 *  RETURNS:     fcb
 *      !NULL: fcb found
 *      NULL:  fcb not found
 *
 *  NOTES:
 */
fsm_fcb_t *
fsm_get_fcb_by_call_id (callid_t call_id)
{
    static const char fname[] = "fsm_get_fcb_by_call_id";
    fsm_fcb_t      *fcb;
    fsm_fcb_t      *fcb_found = NULL;

    FSM_FOR_ALL_CBS(fcb, fsm_fcbs, FSM_MAX_FCBS) {
        if (fcb->call_id == call_id) {
            fcb_found = fcb;
            break;
        }
    }

    FSM_DEBUG_SM(get_debug_string(GSM_DBG_PTR), "FSM", call_id,
                 fname, "fcb", fcb_found);

    return (fcb_found);
}
Example #28
0
/*
 *  ROUTINE:     fsm_get_new_fcb
 *
 *  DESCRIPTION: return a new fcb initialized with the given data
 *
 *  PARAMETERS:
 *      call_id:    call_id
 *      type:       feature type
 *
 *  RETURNS:
 *      fcb: the new fcb
 */
fsm_fcb_t *
fsm_get_new_fcb (callid_t call_id, fsm_types_t fsm_type)
{
    static const char fname[] = "fsm_get_new_fcb";
    fsm_fcb_t *fcb;

    /*
     * Get free fcb by using CC_NO_CALL_ID as the call_id because a free fcb
     * will have a call_id of CC_NO_CALL_ID.
     */
    fcb = fsm_get_fcb_by_call_id(CC_NO_CALL_ID);
    if (fcb != NULL) {
        fsm_init_fcb(fcb, call_id, FSMDEF_NO_DCB, fsm_type);
    }

    FSM_DEBUG_SM(get_debug_string(GSM_DBG_PTR), "FSM", call_id,
                 fname, "fcb", fcb);

    return (fcb);
}
void
sip_platform_post_timer (uint32_t cmd, void *data)
{
    static const char fname[] = "sip_platform_post_timer";
    uint32_t *timer_msg = NULL;

    /* grab msg buffer */
    timer_msg = (uint32_t *) SIPTaskGetBuffer(sizeof(uint32_t));
    if (!timer_msg) {
        CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_SYSBUF_UNAVAILABLE), fname);
        return;
    }
    *timer_msg = (long) data;

    /* Put it on the SIP message queue */
    if (SIPTaskSendMsg(cmd, (cprBuffer_t) timer_msg, sizeof(uint32_t), NULL)
            == CPR_FAILURE) {
        cpr_free(timer_msg);
        CCSIP_DEBUG_ERROR(SIP_F_PREFIX "Send msg failed.\n", fname);
    }
    return;
}
int
sip_platform_msg_timer_update_destination (int idx,
                                           cpr_ip_addr_t *ipaddr,
                                           uint16_t port)
{
    static const char fname[] = "sip_platform_msg_timer_update_destination";

    if ((idx < TEL_CCB_START) || (idx > REG_BACKUP_CCB)) {
        CCSIP_DEBUG_ERROR(get_debug_string(DEBUG_LINE_NUMBER_INVALID),
                          fname, idx);
        return SIP_ERROR;
    }

    if (ipaddr == NULL) {
        sipPlatformUISMExpiresTimers[idx].ipaddr = ip_addr_invalid;
    } else {
        sipPlatformUISMTimers[idx].ipaddr = *ipaddr;
    }

    sipPlatformUISMTimers[idx].port = port;

    return SIP_OK;
}