void _eXosip_call_remove_dialog_reference_in_call (eXosip_call_t * jc, eXosip_dialog_t * jd) { eXosip_dialog_t *_jd; if (jc == NULL) return; if (jd == NULL) return; for (_jd = jc->c_dialogs; _jd != NULL; _jd = _jd->next) { if (jd == _jd) break; } if (_jd == NULL) { /* dialog not found??? */ } _jd = (eXosip_dialog_t *) osip_transaction_get_reserved3 (jc->c_inc_tr); if (_jd != NULL && _jd == jd) osip_transaction_set_reserved3 (jc->c_inc_tr, NULL); _jd = (eXosip_dialog_t *) osip_transaction_get_reserved3 (jc->c_out_tr); if (_jd != NULL && _jd == jd) osip_transaction_set_reserved3 (jc->c_out_tr, NULL); }
int eXosip_subscribe_send_refresh_request (struct eXosip_t *excontext, int did, osip_message_t * sub) { eXosip_dialog_t *jd = NULL; eXosip_subscribe_t *js = NULL; osip_transaction_t *transaction; osip_event_t *sipevent; int i; if (did <= 0) return OSIP_BADPARAMETER; if (did > 0) { _eXosip_subscribe_dialog_find (excontext, did, &js, &jd); } if (jd == NULL) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: No subscribe here?\n")); osip_message_free (sub); return OSIP_NOTFOUND; } transaction = NULL; transaction = _eXosip_find_last_out_subscribe (js, jd); if (transaction != NULL) { if (transaction->state != NICT_TERMINATED && transaction->state != NIST_TERMINATED && transaction->state != NICT_COMPLETED && transaction->state != NIST_COMPLETED) { osip_message_free (sub); return OSIP_WRONG_STATE; } transaction = NULL; } transaction = NULL; i = _eXosip_transaction_init (excontext, &transaction, NICT, excontext->j_osip, sub); if (i != 0) { osip_message_free (sub); return i; } js->s_reg_period = 3600; _eXosip_subscribe_set_refresh_interval (js, sub); osip_list_add (jd->d_out_trs, transaction, 0); sipevent = osip_new_outgoing_sipmessage (sub); sipevent->transactionid = transaction->transactionid; osip_transaction_set_reserved5 (transaction, js); osip_transaction_set_reserved3 (transaction, jd); osip_transaction_add_event (transaction, sipevent); _eXosip_wakeup (excontext); return OSIP_SUCCESS; }
int _eXosip_subscribe_send_request_with_credential (struct eXosip_t *excontext, eXosip_subscribe_t * js, eXosip_dialog_t * jd, osip_transaction_t * out_tr) { osip_transaction_t *tr = NULL; osip_message_t *msg = NULL; osip_event_t *sipevent; int cseq; osip_via_t *via; int i; if (js == NULL) return OSIP_BADPARAMETER; if (jd != NULL) { if (jd->d_out_trs == NULL) return OSIP_BADPARAMETER; } if (out_tr == NULL) { out_tr = _eXosip_find_last_out_subscribe (js, jd); } if (out_tr == NULL || out_tr->orig_request == NULL || out_tr->last_response == NULL) return OSIP_NOTFOUND; i = osip_message_clone (out_tr->orig_request, &msg); if (i != 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: could not clone msg for authentication\n")); return i; } { osip_generic_param_t *tag = NULL; osip_to_get_tag (msg->to, &tag); if (NULL == tag && jd != NULL && jd->d_dialog != NULL && jd->d_dialog->remote_tag != NULL) { osip_to_set_tag (msg->to, osip_strdup (jd->d_dialog->remote_tag)); } } via = (osip_via_t *) osip_list_get (&msg->vias, 0); if (via == NULL || msg->cseq == NULL || msg->cseq->number == NULL) { osip_message_free (msg); OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: missing via or cseq header\n")); return OSIP_SYNTAXERROR; } /* increment cseq */ cseq = atoi (msg->cseq->number); osip_free (msg->cseq->number); msg->cseq->number = _eXosip_strdup_printf ("%i", cseq + 1); if (msg->cseq->number == NULL) { osip_message_free (msg); return OSIP_NOMEM; } if (jd != NULL && jd->d_dialog != NULL) { jd->d_dialog->local_cseq++; } i = _eXosip_update_top_via (msg); if (i != 0) { osip_message_free (msg); return i; } osip_list_special_free (&msg->authorizations, (void (*)(void *)) &osip_authorization_free); osip_list_special_free (&msg->proxy_authorizations, (void (*)(void *)) &osip_proxy_authorization_free); if (out_tr->last_response->status_code == 401 || out_tr->last_response->status_code == 407) { _eXosip_add_authentication_information (excontext, msg, out_tr->last_response); } else _eXosip_add_authentication_information (excontext, msg, NULL); if (out_tr != NULL && out_tr->last_response != NULL && out_tr->last_response->status_code == 423) { /* increase expires value to "min-expires" value */ osip_header_t *exp; osip_header_t *min_exp; osip_message_header_get_byname (msg, "expires", 0, &exp); osip_message_header_get_byname (out_tr->last_response, "min-expires", 0, &min_exp); if (exp != NULL && exp->hvalue != NULL && min_exp != NULL && min_exp->hvalue != NULL) { osip_free (exp->hvalue); exp->hvalue = osip_strdup (min_exp->hvalue); } else { osip_message_free (msg); OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: missing Min-Expires or Expires in PUBLISH\n")); return OSIP_SYNTAXERROR; } } osip_message_force_update (msg); i = _eXosip_transaction_init (excontext, &tr, NICT, excontext->j_osip, msg); if (i != 0) { osip_message_free (msg); return i; } if (out_tr == js->s_out_tr) { /* replace with the new tr */ osip_list_add (&excontext->j_transactions, js->s_out_tr, 0); js->s_out_tr = tr; } else { /* add the new tr for the current dialog */ osip_list_add (jd->d_out_trs, tr, 0); } sipevent = osip_new_outgoing_sipmessage (msg); osip_transaction_set_reserved5 (tr, js); osip_transaction_set_reserved3 (tr, jd); osip_transaction_add_event (tr, sipevent); _eXosip_update (excontext); /* fixed? */ _eXosip_wakeup (excontext); return OSIP_SUCCESS; }