📄 udp.c
字号:
for (jd = jn->n_dialogs; jd != NULL;) { jdnext = jd->next; eXosip_release_finished_transactions_for_subscription (jd); jd = jdnext; } jn = jnnext; }}#endifstatic inteXosip_pendingosip_transaction_exist (eXosip_call_t * jc, eXosip_dialog_t * jd){ osip_transaction_t *tr; time_t now = time (NULL); tr = eXosip_find_last_inc_transaction (jc, jd, "BYE"); if (tr != NULL && tr->state != NIST_TERMINATED) { /* Don't want to wait forever on broken transaction!! */ if (tr->birth_time + 180 < now) /* Wait a max of 2 minutes */ { /* remove the transaction from oSIP: */ osip_remove_transaction (eXosip.j_osip, tr); eXosip_remove_transaction_from_call (tr, jc); osip_list_add (eXosip.j_transactions, tr, 0); } else return 0; } tr = eXosip_find_last_out_transaction (jc, jd, "BYE"); if (tr != NULL && tr->state != NICT_TERMINATED) { /* Don't want to wait forever on broken transaction!! */ if (tr->birth_time + 180 < now) /* Wait a max of 2 minutes */ { /* remove the transaction from oSIP: */ osip_remove_transaction (eXosip.j_osip, tr); eXosip_remove_transaction_from_call (tr, jc); osip_list_add (eXosip.j_transactions, tr, 0); } else return 0; } tr = eXosip_find_last_inc_invite (jc, jd); if (tr != NULL && tr->state != IST_TERMINATED) { /* Don't want to wait forever on broken transaction!! */ if (tr->birth_time + 180 < now) /* Wait a max of 2 minutes */ { /* remove the transaction from oSIP: */ /* osip_remove_transaction(eXosip.j_osip, tr); eXosip_remove_transaction_from_call(tr, jc); osip_transaction_free(tr); */ } else return 0; } tr = eXosip_find_last_out_invite (jc, jd); if (tr != NULL && tr->state != ICT_TERMINATED) { /* Don't want to wait forever on broken transaction!! */ if (tr->birth_time + 180 < now) /* Wait a max of 2 minutes */ { /* remove the transaction from oSIP: */ /* osip_remove_transaction(eXosip.j_osip, tr); eXosip_remove_transaction_from_call(tr, jc); osip_transaction_free(tr); */ } else return 0; } tr = eXosip_find_last_inc_transaction (jc, jd, "REFER"); if (tr != NULL && tr->state != IST_TERMINATED) { /* Don't want to wait forever on broken transaction!! */ if (tr->birth_time + 180 < now) /* Wait a max of 2 minutes */ { /* remove the transaction from oSIP: */ osip_remove_transaction (eXosip.j_osip, tr); eXosip_remove_transaction_from_call (tr, jc); osip_list_add (eXosip.j_transactions, tr, 0); } else return 0; } tr = eXosip_find_last_out_transaction (jc, jd, "REFER"); if (tr != NULL && tr->state != NICT_TERMINATED) { /* Don't want to wait forever on broken transaction!! */ if (tr->birth_time + 180 < now) /* Wait a max of 2 minutes */ { /* remove the transaction from oSIP: */ osip_remove_transaction (eXosip.j_osip, tr); eXosip_remove_transaction_from_call (tr, jc); osip_list_add (eXosip.j_transactions, tr, 0); } else return 0; } return -1;}#ifndef MINISIZEstatic inteXosip_release_finished_transactions_for_subscription (eXosip_dialog_t *jd){ time_t now = time (NULL); osip_transaction_t *inc_tr; osip_transaction_t *out_tr; int skip_first=0; int pos; int ret; ret = -1; if (jd != NULL) { /* go through all incoming transactions of this dialog */ pos = 0; while (!osip_list_eol (jd->d_inc_trs, pos)) { inc_tr = osip_list_get (jd->d_inc_trs, pos); /* remove, if transaction too old, independent of the state */ if ((skip_first==1) && (inc_tr->state == NIST_TERMINATED) && (inc_tr->birth_time + 30 < now)) /* keep it for 30 seconds */ { /* remove the transaction from oSIP */ OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: releaase non-INVITE server transaction (did=%i)\n", jd->d_id)); osip_remove_transaction (eXosip.j_osip, inc_tr); osip_list_remove (jd->d_inc_trs, pos); osip_list_add (eXosip.j_transactions, inc_tr, 0); ret = 0; break; } if (0 == osip_strcasecmp (inc_tr->cseq->method, "SUBSCRIBE")) skip_first=1; if (0 == osip_strcasecmp (inc_tr->cseq->method, "NOTIFY")) skip_first=1; pos++; } skip_first=0; /* go through all outgoing transactions of this dialog */ pos = 0; while (!osip_list_eol (jd->d_out_trs, pos)) { out_tr = osip_list_get (jd->d_out_trs, pos); /* remove, if transaction too old, independent of the state */ if ((skip_first==1) && (out_tr->state == NICT_TERMINATED) && (out_tr->birth_time + 30 < now)) /* Wait a max of 30 seconds */ { /* remove the transaction from oSIP */ OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: release non INVITE client transaction (did=%i)\n", jd->d_id)); osip_remove_transaction (eXosip.j_osip, out_tr); osip_list_remove (jd->d_out_trs, pos); osip_list_add (eXosip.j_transactions, out_tr, 0); ret = 0; break; } if (0 == osip_strcasecmp (out_tr->cseq->method, "SUBSCRIBE")) skip_first=1; if (0 == osip_strcasecmp (out_tr->cseq->method, "NOTIFY")) skip_first=1; pos++; } } return ret;}#endifstatic inteXosip_release_finished_transactions (eXosip_call_t *jc, eXosip_dialog_t *jd){ time_t now = time (NULL); osip_transaction_t *inc_tr; osip_transaction_t *out_tr; osip_transaction_t *last_invite; int pos; int ret; ret = -1; last_invite = eXosip_find_last_inc_invite (jc, jd); if (jd != NULL) { /* go through all incoming transactions of this dialog */ pos = 1; while (!osip_list_eol (jd->d_inc_trs, pos)) { inc_tr = osip_list_get (jd->d_inc_trs, pos); if (0 != osip_strcasecmp (inc_tr->cseq->method, "INVITE")) { /* remove, if transaction too old, independent of the state */ if ((inc_tr->state == NIST_TERMINATED) && (inc_tr->birth_time + 30 < now)) /* Wait a max of 30 seconds */ { /* remove the transaction from oSIP */ OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: releaase non-INVITE server transaction (did=%i)\n", jd->d_id)); osip_remove_transaction (eXosip.j_osip, inc_tr); osip_list_remove (jd->d_inc_trs, pos); osip_list_add (eXosip.j_transactions, inc_tr, 0); ret = 0; break; } } else { /* remove, if transaction too old, independent of the state */ if (last_invite!=inc_tr && (inc_tr->state == IST_TERMINATED) && (inc_tr->birth_time + 30 < now)) /* Wait a max of 30 seconds */ { /* remove the transaction from oSIP */ OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: release INVITE server transaction (did=%i)\n", jd->d_id)); osip_remove_transaction (eXosip.j_osip, inc_tr); osip_list_remove (jd->d_inc_trs, pos); osip_list_add (eXosip.j_transactions, inc_tr, 0); ret = 0; break; } } pos++; } last_invite = eXosip_find_last_out_invite (jc, jd); /* go through all outgoing transactions of this dialog */ pos = 1; while (!osip_list_eol (jd->d_out_trs, pos)) { out_tr = osip_list_get (jd->d_out_trs, pos); if (0 != osip_strcasecmp (out_tr->cseq->method, "INVITE")) { /* remove, if transaction too old, independent of the state */ if ((out_tr->state == NICT_TERMINATED) && (out_tr->birth_time + 30 < now)) /* Wait a max of 30 seconds */ { /* remove the transaction from oSIP */ OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: release non INVITE client transaction (did=%i)\n", jd->d_id)); osip_remove_transaction (eXosip.j_osip, out_tr); osip_list_remove (jd->d_out_trs, pos); osip_list_add (eXosip.j_transactions, out_tr, 0); ret = 0; break; } } else { /* remove, if transaction too old, independent of the state */ if (last_invite!=out_tr && (out_tr->state == ICT_TERMINATED) && (out_tr->birth_time + 30 < now)) /* Wait a max of 30 seconds */ { /* remove the transaction from oSIP */ OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: release INVITE client transaction (did=%i)\n", jd->d_id)); osip_remove_transaction (eXosip.j_osip, out_tr); osip_list_remove (jd->d_out_trs, pos); osip_list_add (eXosip.j_transactions, out_tr, 0); ret = 0; break; } } pos++; } } return ret;}static inteXosip_release_finished_calls (eXosip_call_t * jc, eXosip_dialog_t * jd){ osip_transaction_t *tr; tr = eXosip_find_last_inc_transaction (jc, jd, "BYE"); if (tr == NULL) tr = eXosip_find_last_out_transaction (jc, jd, "BYE"); if (tr != NULL && (tr->state == NIST_TERMINATED || tr->state == NICT_TERMINATED)) { int did = -2; if (jd != NULL) did = jd->d_id; OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: eXosip_release_finished_calls remove a dialog (cid=%i did=%i)\n", jc->c_id, did)); /* Remove existing reference to the dialog from transactions! */ __eXosip_call_remove_dialog_reference_in_call (jc, jd); REMOVE_ELEMENT (jc->c_dialogs, jd); eXosip_dialog_free (jd); return 0; } return -1;}static void__eXosip_release_call (eXosip_call_t * jc, eXosip_dialog_t * jd){ REMOVE_ELEMENT (eXosip.j_calls, jc); report_call_event (EXOSIP_CALL_RELEASED, jc, jd, NULL); eXosip_call_free (jc); __eXosip_wakeup ();}static inteXosip_release_aborted_calls (eXosip_call_t * jc, eXosip_dialog_t * jd){ time_t now = time (NULL); osip_transaction_t *tr;#if 0 tr = eXosip_find_last_inc_invite (jc, jd); if (tr == NULL) tr = eXosip_find_last_out_invite (jc, jd);#else /* close calls only when the initial INVITE failed */ tr = jc->c_inc_tr; if (tr == NULL) tr = jc->c_out_tr;#endif if (tr == NULL) { if (jd != NULL) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: eXosip_release_aborted_calls remove an empty dialog\n")); __eXosip_call_remove_dialog_reference_in_call (jc, jd); REMOVE_ELEMENT (jc->c_dialogs, jd); eXosip_dialog_free (jd); return 0; } return -1; } if (tr != NULL && tr->state != IST_TERMINATED && tr->state != ICT_TERMINATED && tr->birth_time + 180 < now) /* Wait a max of 2 minutes */ { if (jd != NULL) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: eXosip_release_aborted_calls remove a dialog for an unfinished transaction\n")); __eXosip_call_remove_dialog_reference_in_call (jc, jd); REMOVE_ELEMENT (jc->c_dialogs, jd); report_call_event (EXOSIP_CALL_NOANSWER, jc, jd, NULL); eXosip_dialog_free (jd); __eXosip_wakeup (); return 0; } } if (tr != NULL && (tr->state == IST_TERMINATED || tr->state == ICT_TERMINATED)) { if (tr == jc->c_inc_tr) { if (jc->c_inc_tr->last_response == NULL) { /* OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO2,NULL, "eXosip: eXosip_release_aborted_calls transaction with no answer\n")); */ }#ifndef MINISIZE else if (MSG_IS_STATUS_3XX (jc->c_inc_tr->last_response)) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: eXosip_release_aborted_calls answered with a 3xx\n")); __eXosip_release_call (jc, jd); return 0; } else if (MSG_IS_STATUS_4XX (jc->c_inc_tr->last_response)) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: eXosip_release_aborted_calls answered with a 4xx\n")); __eXosip_release_call (jc, jd); return 0; } else if (MSG_IS_STATUS_5XX (jc->c_inc_tr->last_response)) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: eXosip_release_aborted_calls answered with a 5xx\n")); __eXosip_release_call (jc, jd); return 0; } else if (MSG_IS_STATUS_6XX (jc->c_inc_tr->last_response)) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "eXosip: eXosip_release_aborted_calls answered with a 6xx\n")); __eXosip_release_call (jc, jd); return 0; }#else else if (jc->c_inc_tr->last_respons
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -