Beispiel #1
0
/**
 * This function will check if wee need to send refresh PUBLISH. 
 * If so, it will send refresh PUBLISH
 *
 * @param[in] none
 *
 * @return none
 */
void publish_handle_periodic_timer_expire (void)
{
    static const char fname[] = "publish_handle_periodic_timer_expire";
    int                 delta = 0;
    ccsip_publish_cb_t *pcb_p;
    pub_req_t           msg;

    config_get_value(CFGID_TIMER_SUBSCRIBE_DELTA, &delta,
                     sizeof(delta));
    pcb_p = (ccsip_publish_cb_t *)sll_next(s_PCB_list, NULL);
    while (pcb_p != NULL) {
        if (pcb_p->outstanding_trxn == FALSE) {
            if (pcb_p->hb.expires >= TMR_PERIODIC_PUBLISH_INTERVAL) {
                pcb_p->hb.expires -= TMR_PERIODIC_PUBLISH_INTERVAL;
            }
            if (pcb_p->hb.expires <= (delta + TMR_PERIODIC_PUBLISH_INTERVAL)) {
                CCSIP_DEBUG_TASK(DEB_F_PREFIX"sending REFRESH PUBLISH", DEB_F_PREFIX_ARGS(SIP_PUB, fname));
                memset (&msg, 0, sizeof(msg));
                /* refresh is triggered by NULL event data and non-zero expires value */
                msg.pub_handle = pcb_p->pub_handle;
                msg.expires = pcb_p->hb.orig_expiration;
                (void)publish_handle_ev_app_publish(&msg);               
            }
        }
        pcb_p = (ccsip_publish_cb_t *)sll_next(s_PCB_list, pcb_p);
    }
}
/**
 * This function will find the matching feature keys.
 *
 * @param[in] presentity - pointer to presentity
 * @param[in] event_body_p - pointer to presense body
 *
 * @return TRUE/FALSE
 *
 * @pre (presentity != NULL)
 */
static
boolean apply_presence_state_to_matching_feature_keys (char *presentity,
                                                       Presence_ext_t *event_body_p)
{
    pres_subscription_req_t *sub_req_p;
    int blf_state;
    boolean match_found = FALSE;

    sub_req_p = (pres_subscription_req_t *)sll_next(s_pres_req_list, NULL);
    while (sub_req_p != NULL) { /* apply the state to all the entries whose presentity matches */
        if ((sub_req_p->app_id > 0) &&
            (strncmp(sub_req_p->presentity, presentity, CC_MAX_DIALSTRING_LEN - 1) == 0)) {
            match_found = TRUE;
            /* derive the BLF state from event data */
            blf_state = extract_blf_state(event_body_p, sub_req_p->feature_mask);
            ui_BLF_notification(sub_req_p->request_id, blf_state, sub_req_p->app_id);
            sub_req_p->blf_state = blf_state;
            /*
             * if blf state is ALERTING,
             * play blf alerting audible tone.
             */
            if (blf_state == CC_SIP_BLF_ALERTING) {
                /*
                 * Post an event to GSM to play alerting tone.
                 */
                cc_feature(CC_SRC_MISC_APP, CC_NO_CALL_ID, 0, CC_FEATURE_BLF_ALERT_TONE, NULL);
            }
        }
        sub_req_p = (pres_subscription_req_t *)sll_next(s_pres_req_list, sub_req_p);
    }
    return match_found;
}
Beispiel #3
0
static cac_data_t *
fsm_cac_get_data_by_call_id (callid_t call_id)
{
    const char fname[] = "fsm_cac_get_data_by_call_id";
    cac_data_t *cac_data;

    cac_data = (cac_data_t *) sll_next(s_cac_list, NULL);

    while (cac_data != NULL) {

        if (cac_data->call_id == call_id) {
            CAC_DEBUG(DEB_F_PREFIX"cac_data found call_id=%x",
              DEB_F_PREFIX_ARGS("CAC", fname),
              cac_data->call_id);
            return(cac_data);
        }

        cac_data = (cac_data_t *) sll_next(s_cac_list, cac_data);

    }

    CAC_DEBUG(DEB_F_PREFIX"cac_data NOT found.",
        DEB_F_PREFIX_ARGS("CAC", fname));
    return(NULL);
}
Beispiel #4
0
void strBuf_joinAllStr(NStrBuf* strBuf)
{
    char* all;
    int len = 0, c = 0;
    NStrBufSeg* seg;
    
    if (strBuf->lst == N_NULL)
        return;
    
    seg = sll_first(strBuf->lst);
    while (seg) {
        len += seg->len;
        c++;
        seg = sll_next(strBuf->lst);
    }
    
    if (len == 0 || c == 1)
        return;
    
    all = (char*)NBK_malloc(len);
    len = 0;
    seg = sll_first(strBuf->lst);
    while (seg) {
        NBK_memcpy(all + len, seg->data, seg->len);
        len += seg->len;
        seg = sll_next(strBuf->lst);
    }
    strBuf_reset(strBuf);
    
    strBuf->lst = sll_create();
    seg = (NStrBufSeg*)NBK_malloc0(sizeof(NStrBufSeg));
    seg->data = all;
    seg->len = len;
    sll_append(strBuf->lst, seg);
}
/**
 * This function will process if there are any pending notifications.
 *
 * @param none.
 *
 * @return none.
 */
static void sub_handler_initialized (void)
{
    static const char fname[] = "sub_handler_initialized";
    pres_pending_notify_t *pending_notify_p;
    char  *presentity_url = NULL;
    char  presentity_user[CC_MAX_DIALSTRING_LEN];
    Presence_ext_t *event_body_p = NULL;

    BLF_DEBUG("MSC: 0/0: %s: invoked", fname);
    s_subs_hndlr_initialized = TRUE;

    if (s_pending_notify_list == NULL) {
        BLF_DEBUG("MSC: 0/0: %s: no pending notfications", fname);
        return;
    }

    /*
     * process the pending NOTIFYs.
     */
    pending_notify_p = (pres_pending_notify_t *)sll_next(s_pending_notify_list, NULL);
    while (pending_notify_p != NULL) {
        /* strip of the "sip:" */
        presentity_url = strchr(pending_notify_p->presentity, ':');
        if (presentity_url == NULL)
        {
            BLF_ERROR("MSC: %s: Error parsing presentity_url", fname);
            return;
        }

        presentity_url = presentity_url + 1;

        /*
         * look for long from (user@host) matches first. if none found, look
         * for short form (user) matches.
         */
        event_body_p = &(pending_notify_p->event_data_p->u.presence_rpid);
        if (apply_presence_state_to_matching_feature_keys(presentity_url, event_body_p)
            != TRUE) {
            ccsip_util_extract_user(pending_notify_p->presentity, presentity_user);
            if (apply_presence_state_to_matching_feature_keys(presentity_user,
                event_body_p) != TRUE) {
                BLF_DEBUG("MSC: 0/0: %s: no matching BLF feature keys found", fname);
            }
        }
        BLF_DEBUG("MSC: 0/0: %s: processed a pending notfication for %s",
                  fname, presentity_url);
        free_event_data(pending_notify_p->event_data_p);
        (void) sll_remove(s_pending_notify_list, (void *)pending_notify_p);
        cpr_free(pending_notify_p);

        pending_notify_p = (pres_pending_notify_t *)sll_next(s_pending_notify_list,
                                                             NULL);
    }
    (void)sll_destroy(s_pending_notify_list);
    s_pending_notify_list = NULL;
}
/**
 * This function will append presence notification to the pending queue.
 *
 * @param[in] event_data_p - pointer to event data.
 *
 * @return none.
 *
 * @pre (event_data_p != NULL)
 */
static void append_notification_to_pending_queue (ccsip_event_data_t *event_data_p)
{
    static const char fname[] = "append_notification_to_pending_queue";
    pres_pending_notify_t *pending_notify_p;
    Presence_ext_t *event_body_p = &(event_data_p->u.presence_rpid);

    /*
     * create pending list if it is not created yet.
     */
    if (s_pending_notify_list == NULL) {
        s_pending_notify_list = sll_create(NULL);
        if (s_pending_notify_list == NULL) {
            CSFLogError("src-common", "MSC: 0/0: %s: out of memory", fname);
            free_event_data(event_data_p);
            return;
        }
    }

    pending_notify_p = (pres_pending_notify_t *)sll_next(s_pending_notify_list, NULL);
    while (pending_notify_p != NULL) {
        if (strncmp(pending_notify_p->presentity, event_body_p->presence_body.entity,
                    CC_MAX_DIALSTRING_LEN - 1) == 0) {
            /* replace the current state with new state */
            free_event_data(pending_notify_p->event_data_p);
            pending_notify_p->event_data_p = event_data_p;
            return;
        }
        pending_notify_p = (pres_pending_notify_t *)sll_next(s_pending_notify_list,
                                                             pending_notify_p);
    }

    /*
     * To protect from DoS attacks, do not allow more than
     * MAX_REG_LINES entries in the list.
     */
    if (sll_count(s_pending_notify_list) == MAX_REG_LINES) {
        CSFLogError("src-common", "MSC: 0/0: %s: ignoring the NOTIFY "
            "to protect from DoS attack", fname);
        free_event_data(event_data_p);
        return;
    }
    pending_notify_p = (pres_pending_notify_t *)
                       cpr_malloc(sizeof(pres_pending_notify_t));
    if (pending_notify_p == NULL) {
        CSFLogError("src-common", "MSC: 0/0: %s: out of memory", fname);
        free_event_data(event_data_p);
        return;
    }
    sstrncpy(pending_notify_p->presentity, event_body_p->presence_body.entity,
             CC_MAX_DIALSTRING_LEN);
    pending_notify_p->event_data_p = event_data_p;
    (void) sll_append(s_pending_notify_list, pending_notify_p);
    return;
}
Beispiel #7
0
/**
 * This function will inform the application that phone is either 
 * 1. restarting or
 * 2. failing over/ falling back 
 *
 * @note detection of CCM reboot will be handled by PUBLISH ETag mechanism.
 *
 * @param[in] none
 *
 * @return none
 */
void publish_reset (void)
{
    ccsip_publish_cb_t *pcb_p;

    pcb_p = (ccsip_publish_cb_t *)sll_next(s_PCB_list, NULL);
    while (pcb_p != NULL) {
        send_resp_to_app(PUBLISH_FAILED_RESET, pcb_p->pub_handle, pcb_p->app_handle,
                         pcb_p->callback_task, pcb_p->resp_msg_id);
        free_pcb(pcb_p);
        pcb_p = (ccsip_publish_cb_t *)sll_next(s_PCB_list, NULL);
    }
}
Beispiel #8
0
/**
 * \brief Delete an element from the association list.
 *
 * \param al          The association list which contains the element to delete.
 * \param key         The key to the element to delete.
 * \param eq          The equals predicate for two keys.
 * \param free_key    The function which is used to free the key data, or
 *			\c NULL if no action should be taken on the key data.
 * \param free_value  The function which is used to free the value data, or
 *			\c NULL if no action should be taken on the value data.
 *
 * \return  The alist, or \c NULL if the key could not be found.
 *
 * \par Errno values:
 * - \b EINVAL if the key could not be found.
 *
 * \sa alist_insert
 */
alist
alist_delete(alist al, gendata key, eq_func eq, free_func free_key,
	     free_func free_value)
{
	sll l, n;
	alist_entry e;

	assert(al != NULL);
	assert(eq != NULL);

	l = al->list;

	if (sll_empty(l)) {
		errno = EINVAL;
		return NULL;
	}

	/*
	 * The first entry is a special case.  Doubly linked lists might
	 *  be easier, but it's not convenience we are after in here.
	 */
	e = sll_get_data(l).ptr;
	if (eq(key, e->key)) {
		if (free_key != NULL)
			free_key(e->key.ptr);
		if (free_value != NULL)
			free_value(e->value.ptr);
		/* We are removing the first entry from the list! */
		al->list = sll_remove_head(l, free);
		return al;
	}

	/* n is always one ahead of l (so, n == l->next) */
	n = sll_next(l);

	while (!sll_empty(n)) {
		e = sll_get_data(n).ptr;
		if (eq(key, e->key)) {
			if (free_key != NULL)
				free_key(e->key.ptr);
			if (free_value != NULL)
				free_value(e->value.ptr);
			sll_remove_next(l, free);
			return al;
		}
		l = sll_next(l);
		n = sll_next(n);
	}

	/* If we got here, we obviously didn't find the entry. */
	errno = EINVAL;
	return NULL;
}
Beispiel #9
0
/**
 * This function will find matching PCB by the SIP Call-ID in the PCB list.
 *
 * @param[in] callID_p - SIP Call-ID
 *
 * @return  NULL if there is no matching PCB
 *          Otherwise, pointer to the found PCB is returned.
 *
 *  @pre    (callID_p != NULL)
 */
static ccsip_publish_cb_t *find_pcb_by_sip_callid (const char *callID_p)
{
    ccsip_publish_cb_t *pcb_p;

    pcb_p = (ccsip_publish_cb_t *)sll_next(s_PCB_list, NULL);
    while (pcb_p != NULL) {
        if (strncmp(callID_p, pcb_p->hb.sipCallID, (sizeof(pcb_p->hb.sipCallID) -1)) == 0) {
            return pcb_p;
        }
        pcb_p = (ccsip_publish_cb_t *)sll_next(s_PCB_list, pcb_p);
    }
    return NULL;
}
Beispiel #10
0
/*
 *  Function: is_info_package_registered
 *
 *  Parameters:
 *      info_index - the index of the Info Package in g_registered_info array
 *
 *  Description:
 *      Checks to see if a handler was registered for the Info Package.
 *
 *  Return:
 *      TRUE - a handler was registered for the Info Package
 *      FALSE - otherwise
 */
static boolean
is_info_package_registered(info_index_t info_index)
{
    handler_record_t *record;

    for (record = (handler_record_t *)sll_next(s_handler_registry, NULL);
         record != NULL;
         record = (handler_record_t *)sll_next(s_handler_registry, record)) {
        if (record->info_index == info_index) {
            return TRUE;
        }
    }

    return FALSE;
}
Beispiel #11
0
/*
 *  Function: is_content_type_registered
 *
 *  Parameters:
 *      type_index - the index of the Content Type in s_registered_type array
 *
 *  Description:
 *      Checks to see if a handler was registered for the Content Type.
 *
 *  Return:
 *      TRUE - a handler was registered for the Content Type
 *      FALSE - otherwise
 */
static boolean
is_content_type_registered(type_index_t type_index)
{
    handler_record_t *record;

    for (record = (handler_record_t *)sll_next(s_handler_registry, NULL);
         record != NULL;
         record = (handler_record_t *)sll_next(s_handler_registry, record)) {
        if (record->type_index == type_index) {
            return TRUE;
        }
    }

    return FALSE;
}
/**
 * This function will post an event - CC_FEATURE_BLF_ALERT_TONE - to GSM task if
 * there is an entry in BLF_ALERTING state.
 *
 * @param[in] none
 *
 * @return none
 */
void pres_play_blf_audible_alert (void)
{
    pres_subscription_req_t *sub_req_p;

    sub_req_p = (pres_subscription_req_t *)sll_next(s_pres_req_list, NULL);
    while (sub_req_p != NULL) {
        if ((sub_req_p->app_id > 0) && (sub_req_p->blf_state == CC_SIP_BLF_ALERTING)) {
            /*
             * Post an event to GSM to play alerting tone.
             */
            cc_feature(CC_SRC_MISC_APP, CC_NO_CALL_ID, 0, CC_FEATURE_BLF_ALERT_TONE, NULL);
            break;
        }
        sub_req_p = (pres_subscription_req_t *)sll_next(s_pres_req_list, sub_req_p);
    }
}
/*
 *  Function: terminate_req_all()
 *
 *  Parameters: none.
 *
 *  Description:  terminates all out standing subscriptions
 *
 *  Returns: void
 */
static void
terminate_req_all (void)
{
    static const char fname[] = "terminate_req_all";
    pres_subscription_req_t *sub_req_p;

    BLF_DEBUG(DEB_F_PREFIX"Entering", DEB_F_PREFIX_ARGS(BLF, fname));
    if (s_pres_req_list == NULL) {
        BLF_DEBUG(DEB_F_PREFIX"Exiting : no outstanding requests", DEB_F_PREFIX_ARGS(BLF, fname));
        return;
    }

    while ((sub_req_p = (pres_subscription_req_t *)
                sll_next(s_pres_req_list, NULL)) != NULL) {
        /*
         * post SIPSPI_EV_CC_SUBSCRIPTION_TERMINATED so that SIP stack cleans up.
         */
        (void) sub_int_subscribe_term(sub_req_p->sub_id, TRUE,
                                      sub_req_p->request_id,
                                      CC_SUBSCRIPTIONS_PRESENCE);

        /*
         * and remove the node from the list of subscriptions.
         */
        free_sub_request(sub_req_p);
    }
    /*
     * this function call indicates the subscription handler is going
     * out of service, set s_subs_hndlr_initialized to FALSE.
     */
    s_subs_hndlr_initialized = FALSE;
    BLF_DEBUG(DEB_F_PREFIX"Exiting", DEB_F_PREFIX_ARGS(BLF, fname));
}
Beispiel #14
0
/**
 * \brief Merge two association lists together uniquely.
 *
 * Add all data elements from an association list to another association list
 * with the given key.  If a duplicate key is encountered, the entry is not
 * inserted into the \p base list.
 *
 * \note
 * This function is \f$ O(n \cdot m) \f$ with \f$ n \f$ the length of
 * \p base and \f$ m \f$ the length of \p rest.
 *
 * \param base	      The association list to insert the data in.
 * \param rest        The association list to be merged into \p base.
 * \param eq          The equals predicate for two keys.
 *
 * \return  The \p base alist, merged with \p rest, or NULL in case of error.
 *           If an error occurred, the \p base list is still valid, but
 *           it is undefined which items from the \p rest list will have been
 *           merged into the list and which haven't.
 *	    The \p rest alist will have been modified so it still contains
 *	     the entries which had matching keys in the \p base alist.
 *	    The \p rest alist will thus still be valid.
 *
 * \par Errno values:
 * - \b ENOMEM if out of memory.
 *
 * \sa alist_insert_uniq alist_delete alist_merge
 */
alist
alist_merge_uniq(alist base, alist rest, eq_func eq)
{
	sll l;
	alist_entry e;
	alist base_tmp;

	assert(base != NULL);
	assert(rest != NULL);

	l = rest->list;

	while (!sll_empty(l)) {
		e = sll_get_data(l).ptr;
		base_tmp = alist_insert_uniq(base, e->key, e->value, eq);

		if (base_tmp == NULL) {
			if (errno == ENOMEM)
				return NULL;
			else
				l = sll_next(l);
		} else {
			base = base_tmp;
			l = sll_remove_head(l, free);
		}
	}

	return base;
}
Beispiel #15
0
/**
 * This function will free up entire list of pending requests
 *
 * @param[in] list -  pending requests list handle
 *
 * @return none 
 *
 */
static void free_pending_reqs (sll_handle_t list)
{
    pub_req_t *msg_p;

    if (list == NULL)  {
        return;
    }

    msg_p = (pub_req_t *)sll_next(list, NULL);
    while (msg_p != NULL) {
        free_event_data(msg_p->event_data_p);
        (void)sll_remove(list, (void *)msg_p);
        cpr_free(msg_p);
        msg_p = (pub_req_t *)sll_next(list, NULL);
    }
    sll_destroy(list);
}
Beispiel #16
0
/*
 * Internal function which alist_insert and alist_insert_uniq call.
 * Argument list is the same as these two functions, except for an extra
 * integer tacked onto the end.  This integer is nonzero if existing
 * key entries are not allowed.  If existing key entries are allowed, the
 * value of that key is overwritten.
 */
static alist
alist_insert_internal(alist al, gendata key, gendata value, eq_func eq,
		      free_func free_key, free_func free_value, int uniq)
{
	sll new_head;
	alist_entry e;
	gendata e_data;
	sll l;

	assert(al != NULL);
	assert(eq != NULL);

	l = al->list;

	/*
	 * We'll have to check if there's already a value with the same key.
	 * If there is, overwrite that value unless uniq.
	 */
	while (!sll_empty(l)) {
		e = sll_get_data(l).ptr;
		if (eq(key, e->key)) {
			/* Duplicates not allowed? */
			if (uniq) {
				errno = EINVAL;
				return NULL;
			}

			/* Free old data */
			if (free_key != NULL)
				free_key(e->key.ptr);
			if (free_value != NULL)
				free_value(e->value.ptr);
			e->value = value;
			e_data.ptr = e;
			sll_set_data(l, e_data);
			return al;
		}
		l = sll_next(l);
	}

	/* If we got here, the key does not occur in the table yet */
	if ((e = malloc(sizeof(alist_entry_t))) == NULL)
		return NULL;

	e->key = key;
	e->value = value;
	e_data.ptr = e;

	new_head = sll_prepend_head(al->list, e_data);
	if (new_head == NULL) {
		free(e);
		return NULL;
	}

	al->list = new_head;
	return al;
}
Beispiel #17
0
void sll_last (sll_s * p_sll)
{
  if (p_sll)
    {
      while (p_sll->list->next != NULL)
	{
	  sll_next (p_sll);
	}
    }
}
Beispiel #18
0
void CResourceManager::ResendRequest()
{
    MResConn* c = (MResConn*) sll_first(iConnList);
    while (c) {
        if (MResConn::EWaiting == c->iConnState) {
            c->RC_Submit();
        }
        c = (MResConn*) sll_next(iConnList);
    }
}
Beispiel #19
0
void CResourceManager::CleanUnusedConn()
{
    MResConn* c = (MResConn*) sll_first(iConnList);
    while (c) {
        if (c->iConnState == MResConn::EFinished /*|| c->IsStop()*/) {
            delete c;
            sll_removeCurr(iConnList);
        }
        c = (MResConn*) sll_next(iConnList);
    }
}
Beispiel #20
0
void CResourceManager::CleanAllConn(nid aPageId)
{
    MResConn* c = (MResConn*) sll_first(iConnList);
    while (c) {
        if (aPageId == KAllPageId || c->PageId() == aPageId) {
            c->RC_Cancel();
            delete c;
            sll_removeCurr(iConnList);
        }
        c = (MResConn*) sll_next(iConnList);
    }
}
Beispiel #21
0
void strBuf_reset(NStrBuf* strBuf)
{
    if (strBuf->lst) {
        NStrBufSeg* seg = sll_first(strBuf->lst);
        while (seg) {
            NBK_free(seg->data);
            NBK_free(seg);
            seg = sll_next(strBuf->lst);
        }
        sll_delete(&strBuf->lst);
    }
}
Beispiel #22
0
/**
 *
 * clears all the entries in the cac list
 *
 * @param void
 *
 * @return  void
 *
 * @pre     (NULL)
 */
void fsm_cac_clear_list (void)
{
    const char fname[] = "fsm_cac_clear_list";
    cac_data_t *cac_data;
    cac_data_t *prev_cac_data;

    DEF_DEBUG(DEB_F_PREFIX"Clear all pending CAC dat.",
                DEB_F_PREFIX_ARGS("CAC", fname));

    cac_data = (cac_data_t *) sll_next(s_cac_list, NULL);

    while (cac_data != NULL) {

        prev_cac_data = cac_data;
        cac_data = (cac_data_t *) sll_next(s_cac_list, cac_data);

        fsm_cac_notify_failure(prev_cac_data);
        fsm_clear_cac_data(prev_cac_data);
    }

}
Beispiel #23
0
/**
 *
 * Check if there are pending CAC requests
 *
 * @param none
 *
 * @return  cac_data returns first pending request.
 *
 * @pre     (NULL)
 */
static cac_data_t *
fsm_cac_check_if_pending_req (void)
{
    cac_data_t *cac_data;

    cac_data = (cac_data_t *) sll_next(s_cac_list, NULL);

    while (cac_data != NULL) {

        if (cac_data->cac_state == FSM_CAC_REQ_PENDING ||
                cac_data->cac_state == FSM_CAC_IDLE) {

            return(cac_data);
        }

        cac_data = (cac_data_t *) sll_next(s_cac_list, cac_data);

    }

    return(NULL);
}
Beispiel #24
0
/*
 *  Function: ccsip_info_package_handler_shutdown
 *
 *  Parameters:
 *      None
 *
 *  Description:
 *      Shuts down the Info Package handler framework.
 *
 *  Return:
 *      None
 */
void
ccsip_info_package_handler_shutdown(void)
{
    static const char *fname = "ccsip_info_package_handler_shutdown";
    info_index_t info_index;
    type_index_t type_index;
    handler_record_t *record;

    if (s_handler_registry == NULL) {
        // Is this considered an error?
        CCSIP_DEBUG_TASK("%s: Info Package handler was not initialized", fname);
        return;
    }

    for (type_index = 0; type_index < MAX_INFO_HANDLER; type_index++) {
        if (s_registered_type[type_index] != NULL) {
            cpr_free(s_registered_type[type_index]);
            s_registered_type[type_index] = NULL;
        }
    }

    for (info_index = 0; info_index < MAX_INFO_HANDLER; info_index++) {
        if (g_registered_info[info_index] != NULL) {
            cpr_free(g_registered_info[info_index]);
            g_registered_info[info_index] = NULL;
        }
    }

    /* Deregister each Info Package handler */
    for (record = (handler_record_t *)sll_next(s_handler_registry, NULL);
         record != NULL;
         record = (handler_record_t *)sll_next(s_handler_registry, record)) {
        cpr_free(record);
    }

    /* Destroy the SLL */
    sll_destroy(s_handler_registry);
    s_handler_registry = NULL;
}
Beispiel #25
0
void
stress_test_sll(int amt)
{
	sll l1;
	sll l2;
	gendata x, y;
	int i;

	l1 = sll_create();
	l2 = sll_create();
	assert(sll_empty(l1));
	assert(sll_empty(l2));
	printf("Filling two slls with 2 * %d items...\n", amt);
	for (i = 0; i < amt; ++i) {
		x.num = i;
		l1 = sll_prepend_head(l1, x);
		l2 = sll_prepend_head(l2, x);
		assert(!sll_empty(l1));
		assert(!sll_empty(l2));
		l1 = sll_append_head(l1, x);
		l2 = sll_append_head(l2, x);
		assert(!sll_empty(l1));
		assert(!sll_empty(l2));
	}
	assert(sll_count(l1) == (unsigned int)(2 * amt));
	assert(sll_count(l2) == (unsigned int)(2 * amt));

	l1 = sll_append(l1, l2);
	assert(sll_count(l1) == (unsigned int)(4 * amt));

	/* From now on, l2 is `invalid' */

	printf("Removing 2 * 2 * %d items from the appended sll...\n", amt);
	for (i = 0; i < (2 * amt); ++i) {
		x = sll_get_data(sll_next(l1));
		assert(!sll_empty(l1));
		l1 = sll_remove_next(l1, NULL);
		y = sll_get_data(l1);
		assert(!sll_empty(l1));
		l1 = sll_remove_head(l1, NULL);

		/*
		 * We have to count backwards in this check, since we're
		 * using the list like a stack, prepending all the time.
		 */
		assert(x.num == amt - (i % amt) - 1);
		assert(x.num == y.num);
	}
	assert(sll_empty(l1));
	sll_destroy(l1, NULL);
}
Beispiel #26
0
void CResourceManager::DumpConnList()
{
    iProbe->OutputChar("==================== Conn List ====================", -1);
    iProbe->OutputReturn();

    MResConn* c = (MResConn*) sll_first(iConnList);
    while (c) {
        DumpConn(c);
        c = (MResConn*) sll_next(iConnList);
    }

    iProbe->OutputChar("---------------------------------------------------", -1);
    iProbe->OutputReturn();
}
Beispiel #27
0
size_t sll_sizeof (sll_s * p_sll)
{
  size_t n = 0;

  if (p_sll)
    {
      sll_first (p_sll);
      while (p_sll->list != NULL)
	{
	  n++;
	  sll_next (p_sll);
	}
    }
  return n;
}
Beispiel #28
0
nbool strBuf_getStr(NStrBuf* strBuf, char** str, int* len, nbool begin)
{
    NStrBufSeg* seg;
    
    if (strBuf->lst == N_NULL)
        return N_FALSE;
    
    seg = (begin) ? sll_first(strBuf->lst) : sll_next(strBuf->lst);
    if (seg) {
        *str = seg->data;
        *len = seg->len;
        return N_TRUE;
    }
    else
        return N_FALSE;
}
Beispiel #29
0
/**
 * \brief Walk through all elements of an alist.
 *
 * Walk an alist, using a user-specified function on the list's pairs.
 *
 * \attention
 * While using this function, it is not allowed to remove entries other than
 * the current entry.  It is allowed to change the contents of the key and
 * value.
 *
 * \param al    The alist to walk.
 * \param walk  The function which will process the pairs.
 * \param data  Any data to pass to the function every time it is called.
 */
void
alist_walk(alist al, assoc_func walk, gendata data)
{
	alist_entry e;
	sll l = al->list;
	sll n = NULL;

	assert(al != NULL);
	assert(walk != NULL);

	while(!sll_empty(l)) {
		/* n is stored in case user deletes the current entry */
		n = sll_next(l);
		e = sll_get_data(l).ptr;
		walk(&e->key, &e->value, data);
		l = n;
	}
}
Beispiel #30
0
void CResourceManager::SetAccessPoint(RConnection& aConnect, RSocketServ& aSocket,
    TUint32 aAccessPoint, const TDesC& aAcessName, const TDesC& aApnName, TBool aReady)
{
    m_bUseOutNetSettting = true;

    if (!aReady) {
        // 将所有等待请求置为失败
        MResConn* c = (MResConn*) sll_first(iConnList);
        while (c) {
            if (MResConn::EWaiting == c->iConnState) {
                CHttpConn* httpConn = static_cast<CHttpConn*> (c);
                if (httpConn)
                    httpConn->OnIapFailed();
            }
            c = (MResConn*) sll_next(iConnList);
        }
        return;
    }

    if (iConnection) {
        if (iConnection == &aConnect)
            return;

        CloseHttpSession();
    }

    iConnection = &aConnect;
    iSocketServ = &aSocket;
    m_iapId = aAccessPoint;

    if (aApnName == KCMCCCmwap || aApnName == KUniCmwap) {
        m_isWap = true;
    }

    if (iConnection && iSocketServ) {
        m_IAPSeted = true;
        if (!m_IAPReady) {
            m_IAPReady = true;
        }
        ResendRequest();
    }
}