Esempio n. 1
0
/*!
 * \brief Create and insert a new impurecord assumes domain is locked
 * @param _d domain to insert the new record
 * @param public_identity IMPU of new record
 * @param private_identity IMPI of new record
 * @param reg_state state to insert in
 * @param barring is impu barred or not
 * @param s associated subscription data
 * @param ccf1  
 * @param ccf2
 * @param ecf1
 * @param ecf2
 * @param _r pointer to returned IMPU record
 * @return 0 on success with _r populated
 */
int insert_impurecord(struct udomain* _d, str* public_identity, str* private_identity, int reg_state, int barring,
        ims_subscription** s, str* ccf1, str* ccf2, str* ecf1, str* ecf2,
        struct impurecord** _r) {

    if (s == 0 || (*s) == 0) {
        LM_WARN("Can't insert an impurecord without it being associated to a subscription\n");
        goto error;
    }

    if (!private_identity || !private_identity->len || !private_identity->s) {
        LM_WARN("Can't insert an impurecord without it being associated to a subscription (private_identity\n");
        goto error;
    }

    /* check to see if we already have this subscription information in memory*/
    if (mem_insert_impurecord(_d, public_identity, private_identity, reg_state, barring, s, ccf1, ccf2, ecf1, ecf2, _r) < 0) {
        LM_ERR("inserting record failed\n");
        goto error;
    }

    /*DB?*/
    if (db_mode == WRITE_THROUGH && db_insert_impurecord(_d, public_identity, reg_state, barring, s, ccf1, ccf2, ecf1, ecf2, _r) != 0) {
        LM_ERR("error inserting contact into db");
        goto error;
    }

    return 0;

error:
    return -1;
}
Esempio n. 2
0
/*!
 * \brief Create and insert a new record
 * \param _d domain to insert the new record
 * \param _aor address of the record
 * \param _r new created record
 * \return return 0 on success, -1 on failure
 */
int insert_impurecord(struct udomain* _d, str* public_identity, int reg_state, int barring,
	ims_subscription** s, str* ccf1, str* ccf2, str* ecf1, str* ecf2,
	struct impurecord** _r) {

    /* check to see if we already have this subscription information in memory*/
    if (mem_insert_impurecord(_d, public_identity, reg_state, barring, s, ccf1, ccf2, ecf1, ecf2, _r) < 0) {
	LM_ERR("inserting record failed\n");
	goto error;
    }

    /*DB?*/
    if (db_mode == WRITE_THROUGH && db_insert_impurecord(_d, public_identity, reg_state, barring, s, ccf1, ccf2, ecf1, ecf2, _r) != 0) {
	LM_ERR("error inserting contact into db");
	goto error;
    }

    return 0;

error:
    //    if (s) {
    //    	free_ims_subscription_data(s);
    //    }
    return -1;
}