void _eXosip_call_renew_expire_time (eXosip_call_t * jc) { time_t now = osip_getsystemtime (NULL); jc->expire_time = now + 180; }
int _eXosip_dialog_init_as_uac (eXosip_dialog_t ** _jd, osip_message_t * _200Ok) { int i; eXosip_dialog_t *jd; *_jd = NULL; jd = (eXosip_dialog_t *) osip_malloc (sizeof (eXosip_dialog_t)); if (jd == NULL) return OSIP_NOMEM; memset (jd, 0, sizeof (eXosip_dialog_t)); jd->d_id = -1; /* not yet available to user */ if (MSG_IS_REQUEST (_200Ok)) { i = osip_dialog_init_as_uac_with_remote_request (&(jd->d_dialog), _200Ok, -1); } else { /* normal usage with response */ i = osip_dialog_init_as_uac (&(jd->d_dialog), _200Ok); } if (i != 0) { osip_free (jd); return i; } jd->d_count = 0; jd->d_session_timer_start = 0; jd->d_session_timer_length = 0; jd->d_refresher = -1; /* 0 -> me / 1 -> remote */ jd->d_timer = osip_getsystemtime (NULL); jd->d_200Ok = NULL; jd->d_ack = NULL; jd->next = NULL; jd->parent = NULL; jd->d_out_trs = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if (jd->d_out_trs == NULL) { osip_dialog_free (jd->d_dialog); osip_free (jd); return OSIP_NOMEM; } osip_list_init (jd->d_out_trs); jd->d_inc_trs = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if (jd->d_inc_trs == NULL) { osip_dialog_free (jd->d_dialog); osip_free (jd->d_out_trs); osip_free (jd); return OSIP_NOMEM; } osip_list_init (jd->d_inc_trs); *_jd = jd; return OSIP_SUCCESS; }
int _eXosip_dialog_init_as_uas (eXosip_dialog_t ** _jd, osip_message_t * _invite, osip_message_t * _200Ok) { int i; eXosip_dialog_t *jd; *_jd = NULL; jd = (eXosip_dialog_t *) osip_malloc (sizeof (eXosip_dialog_t)); if (jd == NULL) return OSIP_NOMEM; memset (jd, 0, sizeof (eXosip_dialog_t)); jd->d_id = -1; /* not yet available to user */ i = osip_dialog_init_as_uas (&(jd->d_dialog), _invite, _200Ok); if (i != 0) { osip_free (jd); return i; } jd->d_count = 0; jd->d_session_timer_start = 0; jd->d_session_timer_length = 0; jd->d_session_timer_use_update = -1; jd->d_refresher = -1; /* 0 -> me / 1 -> remote */ jd->d_timer = osip_getsystemtime (NULL); jd->d_200Ok = NULL; jd->d_ack = NULL; jd->next = NULL; jd->parent = NULL; jd->d_out_trs = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if (jd->d_out_trs == NULL) { osip_dialog_free (jd->d_dialog); osip_free (jd); return OSIP_NOMEM; } osip_list_init (jd->d_out_trs); jd->d_inc_trs = (osip_list_t *) osip_malloc (sizeof (osip_list_t)); if (jd->d_inc_trs == NULL) { osip_dialog_free (jd->d_dialog); osip_free (jd->d_out_trs); osip_free (jd); return OSIP_NOMEM; } osip_list_init (jd->d_inc_trs); jd->d_dialog->local_cseq = 1; *_jd = jd; return OSIP_SUCCESS; }
int _eXosip_dialog_set_200ok (eXosip_dialog_t * jd, osip_message_t * _200Ok) { int i; if (jd == NULL) return OSIP_BADPARAMETER; if (jd->d_200Ok != NULL) osip_message_free (jd->d_200Ok); jd->d_timer = osip_getsystemtime (NULL) + 1; jd->d_count = 0; i = osip_message_clone (_200Ok, &(jd->d_200Ok)); if (i != 0) return i; return OSIP_SUCCESS; }
void _eXosip_notify_add_expires_in_2XX_for_subscribe(eXosip_notify_t * jn, osip_message_t * answer) { char tmp[20]; time_t now; now = osip_getsystemtime(NULL); if (jn->n_ss_expires - now < 0) { tmp[0] = '0'; tmp[1] = '\0'; } else { snprintf(tmp, 20, "%li", jn->n_ss_expires - now); } osip_message_set_expires(answer, tmp); }
int _eXosip_notify_set_refresh_interval(eXosip_notify_t * jn, osip_message_t * inc_subscribe) { osip_header_t *exp; time_t now; now = osip_getsystemtime(NULL); if (jn == NULL || inc_subscribe == NULL) return -1; osip_message_get_expires(inc_subscribe, 0, &exp); if (exp == NULL || exp->hvalue == NULL) jn->n_ss_expires = now + 600; else { jn->n_ss_expires = osip_atoi(exp->hvalue); if (jn->n_ss_expires != -1) jn->n_ss_expires = now + jn->n_ss_expires; else /* on error, set it to default */ jn->n_ss_expires = now + 600; } return OSIP_SUCCESS; }