int
eXosip_register_build_initial_register_withqvalue(const char *from, const char *proxy,
									   const char *contact, int expires,
									   const char *qvalue,
									   osip_message_t ** reg)
{
	eXosip_reg_t *jr = NULL;
	int i;

	*reg = NULL;

	if (from == NULL || proxy == NULL)
		return OSIP_BADPARAMETER;

#ifdef REJECT_DOUBLE_REGISTRATION
	/* Avoid adding the same registration info twice to prevent mem leaks */
	for (jr = eXosip.j_reg; jr != NULL; jr = jr->next) {
		if (strcmp(jr->r_aor, from) == 0 && strcmp(jr->r_registrar, proxy) == 0) {
			REMOVE_ELEMENT(eXosip.j_reg, jr);
			eXosip_reg_free(jr);
			jr = NULL;
			break;
		}
	}
#endif

	if (jr == NULL) {
		/* Add new registration info */
		i = eXosip_reg_init(&jr, from, proxy, contact);
		if (i != 0) {
			OSIP_TRACE(osip_trace
					   (__FILE__, __LINE__, OSIP_ERROR, NULL,
						"eXosip: cannot register! "));
			return i;
		}
		ADD_ELEMENT(eXosip.j_reg, jr);
	}

	/* build register */
	jr->r_reg_period = expires;
	if (jr->r_reg_period <= 0)	/* too low */
		jr->r_reg_period = 0;
	else if (jr->r_reg_period < 30)	/* too low */
		jr->r_reg_period = 30;

	if(qvalue)
		osip_strncpy(jr->r_qvalue, qvalue, sizeof(jr->r_qvalue));

	i = _eXosip_register_build_register(jr, reg);
	if (i != 0) {
		OSIP_TRACE(osip_trace
				   (__FILE__, __LINE__, OSIP_ERROR, NULL,
					"eXosip: cannot build REGISTER!\n"));
		*reg = NULL;
		return i;
	}

	return jr->r_id;
}
Beispiel #2
0
int
eXosip_register_build_initial_register (const char *from, const char *proxy,
                                        const char *contact, int expires,
                                        osip_message_t ** reg)
{
    eXosip_reg_t *jr = NULL;
    int i;

    *reg = NULL;

    /* Avoid adding the same registration info twice to prevent mem leaks */
    for (jr = eXosip.j_reg; jr != NULL; jr = jr->next)
    {
        if (strcmp (jr->r_aor, from) == 0 && strcmp (jr->r_registrar, proxy) == 0)
        {
            REMOVE_ELEMENT (eXosip.j_reg, jr);
            eXosip_reg_free (jr);
            jr=NULL;
            break;
        }
    }
    if (jr == NULL)
    {
        /* Add new registration info */
        i = eXosip_reg_init (&jr, from, proxy, contact);
        if (i != 0)
        {
            OSIP_TRACE (osip_trace
                        (__FILE__, __LINE__, OSIP_ERROR, NULL,
                         "eXosip: cannot register! "));
            return i;
        }
        ADD_ELEMENT (eXosip.j_reg, jr);
    }

    /* build register */
    jr->r_reg_period = expires;
    if (jr->r_reg_period <= 0)      /* too low */
        jr->r_reg_period = 0;
    else if (jr->r_reg_period < 100)      /* too low */
        jr->r_reg_period = 100;

    i = _eXosip_register_build_register (jr, reg);
    if (i != 0)
    {
        OSIP_TRACE (osip_trace
                    (__FILE__, __LINE__, OSIP_ERROR, NULL,
                     "eXosip: cannot build REGISTER!\n"));
        *reg = NULL;
        return i;
    }

    return jr->r_id;
}