Lines Matching defs:dialog

60  * Complete dialog hash table
65 * Partial dialog hash table
101 _sip_dialog_t *dialog;
109 sip_release_dialog_res(_sip_dialog_t *dialog)
115 if (dialog->sip_dlg_ref_cnt != 0) {
116 sip_write_to_log((void *)dialog, SIP_DIALOG_LOG |
119 assert(dialog->sip_dlg_ref_cnt == 0);
120 if (SIP_IS_TIMER_RUNNING(dialog->sip_dlg_timer))
121 SIP_CANCEL_TIMER(dialog->sip_dlg_timer);
122 if (dialog->sip_dlg_call_id != NULL)
123 sip_free_header(dialog->sip_dlg_call_id);
124 if (dialog->sip_dlg_local_uri_tag != NULL)
125 sip_free_header(dialog->sip_dlg_local_uri_tag);
126 if (dialog->sip_dlg_remote_uri_tag != NULL)
127 sip_free_header(dialog->sip_dlg_remote_uri_tag);
128 if (dialog->sip_dlg_remote_target != NULL)
129 sip_free_header(dialog->sip_dlg_remote_target);
130 if (dialog->sip_dlg_local_contact != NULL)
131 sip_free_header(dialog->sip_dlg_local_contact);
132 if (dialog->sip_dlg_new_local_contact != NULL)
133 sip_free_header(dialog->sip_dlg_new_local_contact);
134 if (dialog->sip_dlg_route_set != NULL)
135 sip_free_header(dialog->sip_dlg_route_set);
136 if (dialog->sip_dlg_event != NULL)
137 sip_free_header(dialog->sip_dlg_event);
138 if (dialog->sip_dlg_req_uri.sip_str_ptr != NULL) {
139 free(dialog->sip_dlg_req_uri.sip_str_ptr);
140 dialog->sip_dlg_req_uri.sip_str_ptr = NULL;
141 dialog->sip_dlg_req_uri.sip_str_len = 0;
143 if (dialog->sip_dlg_rset.sip_str_ptr != NULL) {
144 free(dialog->sip_dlg_rset.sip_str_ptr);
145 dialog->sip_dlg_rset.sip_str_len = 0;
146 dialog->sip_dlg_rset.sip_str_ptr = NULL;
149 msg_chain = dialog->sip_dlg_log[count].sip_msgs;
158 (void) pthread_mutex_destroy(&dialog->sip_dlg_mutex);
159 free(dialog);
225 sip_dialog_req_uri(sip_dialog_t dialog)
231 _dialog = (_sip_dialog_t *)dialog;
274 sip_dlg_recompute_rset(_sip_dialog_t *dialog, _sip_msg_t *sip_msg, int what)
278 if (dialog->sip_dlg_route_set != NULL) {
279 sip_free_header(dialog->sip_dlg_route_set);
280 dialog->sip_dlg_route_set = NULL;
282 if (dialog->sip_dlg_req_uri.sip_str_ptr != NULL) {
283 free(dialog->sip_dlg_req_uri.sip_str_ptr);
284 dialog->sip_dlg_req_uri.sip_str_ptr = NULL;
285 dialog->sip_dlg_req_uri.sip_str_len = 0;
287 if (dialog->sip_dlg_rset.sip_str_ptr != NULL) {
288 free(dialog->sip_dlg_rset.sip_str_ptr);
289 dialog->sip_dlg_rset.sip_str_ptr = NULL;
290 dialog->sip_dlg_rset.sip_str_len = 0;
292 ret = sip_dialog_get_route_set(dialog, sip_msg, what);
316 sip_dialog_set_route_hdr(_sip_dialog_t *dialog, sip_dlg_route_set_t *rset_head,
333 sip_write_to_log((void *)dialog, SIP_DIALOG_LOG |
338 dialog->sip_dlg_rset.sip_str_len = rlen + rcnt - 1;
339 dialog->sip_dlg_rset.sip_str_ptr = malloc(rlen + rcnt);
340 if (dialog->sip_dlg_rset.sip_str_ptr == NULL)
342 rsp = dialog->sip_dlg_rset.sip_str_ptr;
349 val = sip_get_header_value(dialog->sip_dlg_remote_target, NULL);
353 free(dialog->sip_dlg_rset.sip_str_ptr);
354 dialog->sip_dlg_rset.sip_str_len = 0;
355 dialog->sip_dlg_rset.sip_str_ptr = NULL;
364 dialog->sip_dlg_req_uri.sip_str_ptr = malloc(
366 if (dialog->sip_dlg_req_uri.sip_str_ptr == NULL) {
368 free(dialog->sip_dlg_rset.sip_str_ptr);
369 dialog->sip_dlg_rset.sip_str_len = 0;
370 dialog->sip_dlg_rset.sip_str_ptr = NULL;
373 (void) strncpy(dialog->sip_dlg_req_uri.sip_str_ptr, rsp +
376 dialog->sip_dlg_req_uri.sip_str_ptr[
378 dialog->sip_dlg_req_uri.sip_str_len =
393 free(dialog->sip_dlg_rset.sip_str_ptr);
394 dialog->sip_dlg_rset.sip_str_len = 0;
395 dialog->sip_dlg_rset.sip_str_ptr = NULL;
401 free(dialog->sip_dlg_rset.sip_str_ptr);
402 dialog->sip_dlg_rset.sip_str_len = 0;
403 dialog->sip_dlg_rset.sip_str_ptr = NULL;
440 if (rsp > dialog->sip_dlg_rset.sip_str_ptr +
441 dialog->sip_dlg_rset.sip_str_len) {
442 sip_write_to_log((void *)dialog, SIP_DIALOG_LOG |
445 assert(rsp <= dialog->sip_dlg_rset.sip_str_ptr +
446 dialog->sip_dlg_rset.sip_str_len);
447 dialog->sip_dlg_rset.sip_str_ptr[dialog->sip_dlg_rset.sip_str_len] =
462 sip_write_to_log((void *)dialog, SIP_DIALOG_LOG |
469 dialog->sip_dlg_route_set = (sip_header_t)rhdr;
486 sip_dialog_get_route_set(_sip_dialog_t *dialog, _sip_msg_t *sip_msg, int what)
530 sip_write_to_log((void *)dialog,
543 sip_write_to_log((void *)dialog,
557 if (sip_dialog_set_route_hdr(dialog, rset_head, rset_cnt,
571 * number MUST be empty. The call identifier component of the dialog ID
573 * tag component of the dialog ID MUST be set to the tag in the To field
575 * remote tag component of the dialog ID MUST be set to the tag from the
588 * request within the dialog). The call identifier component of the
589 * dialog ID MUST be set to the value of the Call-ID in the request.
590 * The local tag component of the dialog ID MUST be set to the tag in
592 * dialog ID MUST be set to the tag in the To field of the response. A
603 * This is the routine that seeds a dialog.
609 _sip_dialog_t *dialog;
634 * A request outside of a dialog MUST NOT contain a To tag
660 * Sanity check since we just store the headers in the dialog
680 dialog = calloc(1, sizeof (_sip_dialog_t));
681 if (dialog == NULL) {
688 * dialog
691 dialog->sip_dlg_remote_uri_tag = thdr;
696 if ((dialog->sip_dlg_remote_target = sip_dup_header(chdr)) ==
701 if ((dialog->sip_dlg_local_uri_tag = sip_dup_header(fhdr)) ==
709 if ((dialog->sip_dlg_local_contact = sip_dup_header(chdr)) ==
713 dialog->sip_dlg_new_local_contact = NULL;
716 if ((dialog->sip_dlg_call_id = sip_dup_header(cihdr)) == NULL)
719 dialog->sip_dlg_event = sip_dup_header(evhdr);
720 if (dialog->sip_dlg_event == NULL) {
724 dialog->sip_dlg_rset.sip_str_ptr = NULL;
725 dialog->sip_dlg_rset.sip_str_len = 0;
726 dialog->sip_dlg_req_uri.sip_str_ptr = NULL;
727 dialog->sip_dlg_req_uri.sip_str_len = 0;
732 sip_dialog_get_route_set(dialog, sip_msg, dlg_type) != 0) {
736 dialog->sip_dlg_local_cseq = cseq;
738 dialog->sip_dlg_remote_cseq = cseq;
739 dialog->sip_dlg_type = dlg_type;
740 dialog->sip_dlg_on_fork = dlg_on_fork;
741 dialog->sip_dlg_method = method;
743 * Set the partial dialog timer with the INVITE timeout val
747 SIP_INIT_TIMER(dialog->sip_dlg_timer, 64 * timer1);
748 tim_obj->dialog = dialog;
750 * Since at the client we never pass the partial dialog, we need not
751 * invoke the callback when the partial dialog self-destructs.
755 SIP_SCHED_TIMER(dialog->sip_dlg_timer, (void *)tim_obj,
757 if (!SIP_IS_TIMER_RUNNING(dialog->sip_dlg_timer))
759 (void) pthread_mutex_init(&dialog->sip_dlg_mutex, NULL);
766 sip_write_to_log((void *)dialog, SIP_DIALOG_LOG |
773 (uchar_t *)dialog->sip_dlg_id);
779 if (sip_hash_add(sip_dialog_phash, (void *)dialog,
780 SIP_DIGEST_TO_HASH(dialog->sip_dlg_id)) != 0) {
785 dialog->sip_dlg_msgcnt = 1;
786 sip_add_log(&dialog->sip_dlg_log[dialog->sip_dlg_state],
787 (sip_msg_t)sip_msg, dialog->sip_dlg_msgcnt, SIP_DIALOG_LOG);
789 SIP_DLG_REFCNT_INCR(dialog);
790 return ((sip_dialog_t)dialog);
792 sip_release_dialog_res(dialog);
793 if (SIP_IS_TIMER_RUNNING(dialog->sip_dlg_timer))
794 SIP_CANCEL_TIMER(dialog->sip_dlg_timer);
801 * When creating a dialog from a NOTIFY request, we need to get the FROM
802 * header for the dialog from the TO header of the NOTIFY.
854 * This is the response that completes the dialog that was created
858 sip_complete_dialog(_sip_msg_t *sip_msg, _sip_dialog_t *dialog)
878 if (error != 0 || dialog == NULL ||
880 (dialog->sip_dlg_method == INVITE || method != NOTIFY))) {
883 if ((dialog->sip_dlg_type == SIP_UAC_DIALOG && method != NOTIFY &&
885 dialog->sip_dlg_local_cseq) ||
886 (dialog->sip_dlg_type == SIP_UAS_DIALOG && method != NOTIFY &&
888 dialog->sip_dlg_remote_cseq)) {
938 if (dialog->sip_dlg_type == SIP_UAS_DIALOG) {
945 if (dialog->sip_dlg_remote_target == NULL) {
962 prev_state = dialog->sip_dlg_state;
983 dialog->sip_dlg_event, &error);
1011 if (dialog->sip_dlg_type == SIP_UAC_DIALOG) {
1012 dialog->sip_dlg_remote_uri_tag = thdr;
1013 if ((dialog->sip_dlg_remote_target =
1019 dialog->sip_dlg_local_uri_tag = thdr;
1021 dialog->sip_dlg_state = SIP_DLG_CONFIRMED;
1024 (void) pthread_mutex_lock(&dialog->sip_dlg_mutex);
1025 if (dialog->sip_dlg_state != SIP_DLG_NEW) {
1026 sip_write_to_log((void *)dialog, SIP_DIALOG_LOG |
1029 assert(dialog->sip_dlg_state == SIP_DLG_NEW);
1030 if (dialog->sip_dlg_remote_target == NULL && chdr != NULL) {
1031 if (dialog->sip_dlg_type != SIP_UAC_DIALOG) {
1032 sip_write_to_log((void *)dialog,
1036 assert(dialog->sip_dlg_type == SIP_UAC_DIALOG);
1037 if ((dialog->sip_dlg_remote_target =
1040 &dialog->sip_dlg_mutex);
1045 if (sip_dialog_get_route_set(dialog, sip_msg,
1046 dialog->sip_dlg_type) != 0) {
1048 &dialog->sip_dlg_mutex);
1055 dialog->sip_dlg_state = SIP_DLG_EARLY;
1059 * for a dialog establishing response, so if we
1062 if (dialog->sip_dlg_remote_target == NULL) {
1064 &dialog->sip_dlg_mutex);
1066 sip_ulp_dlg_del_cb(dialog,
1073 dialog->sip_dlg_state = SIP_DLG_CONFIRMED;
1075 (void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);
1077 sip_ulp_dlg_del_cb(dialog, (sip_msg_t)sip_msg,
1084 if (dialog->sip_dlg_type == SIP_UAS_DIALOG) {
1085 dialog->sip_dlg_local_uri_tag = thdr;
1087 if ((dialog->sip_dlg_remote_uri_tag =
1090 &dialog->sip_dlg_mutex);
1101 if ((dialog->sip_dlg_type == SIP_UAS_DIALOG) && (dialog->sip_dlg_state
1109 if ((chdr == NULL) || ((dialog->sip_dlg_local_contact =
1111 (void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);
1119 * Cancel the partial dialog timer
1121 if (SIP_IS_TIMER_RUNNING(dialog->sip_dlg_timer))
1122 SIP_CANCEL_TIMER(dialog->sip_dlg_timer);
1124 if (dialog->sip_dlg_type == SIP_UAC_DIALOG) {
1125 val = sip_get_header_value(dialog->sip_dlg_local_uri_tag,
1128 val = sip_get_header_value(dialog->sip_dlg_remote_uri_tag,
1132 sip_write_to_log((void *)dialog, SIP_DIALOG_LOG |
1138 val = sip_get_header_value(dialog->sip_dlg_call_id, &error);
1142 * Get an ID for this dialog
1144 if (dialog->sip_dlg_type == SIP_UAC_DIALOG) {
1148 NULL, 0, NULL, 0, NULL, 0, (uchar_t *)dialog->sip_dlg_id);
1153 NULL, 0, NULL, 0, NULL, 0, (uchar_t *)dialog->sip_dlg_id);
1156 SIP_DLG_REFCNT_INCR(dialog);
1157 (void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);
1162 if (sip_hash_add(sip_dialog_hash, (void *)dialog,
1163 SIP_DIGEST_TO_HASH(dialog->sip_dlg_id)) != 0) {
1169 (void) pthread_mutex_lock(&dialog->sip_dlg_mutex);
1170 if (dialog->sip_dlg_type == SIP_UAS_DIALOG) {
1171 if (dialog->sip_dlg_local_uri_tag != NULL) {
1172 sip_free_header(dialog->sip_dlg_local_uri_tag);
1173 dialog->sip_dlg_local_uri_tag = NULL;
1176 if (dialog->sip_dlg_remote_uri_tag != NULL) {
1177 sip_free_header(dialog->sip_dlg_remote_uri_tag);
1178 dialog->sip_dlg_remote_uri_tag = NULL;
1181 (void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);
1182 sip_dialog_terminate(dialog, (sip_msg_t)sip_msg);
1186 sip_dlg_ulp_state_cb((sip_dialog_t)dialog,
1187 (sip_msg_t)sip_msg, prev_state, dialog->sip_dlg_state);
1189 return ((sip_dialog_t)dialog);
1193 * Check if this dialog is a match.
1198 _sip_dialog_t *dialog = (_sip_dialog_t *)obj;
1200 (void) pthread_mutex_lock(&dialog->sip_dlg_mutex);
1201 if (dialog->sip_dlg_state == SIP_DLG_DESTROYED) {
1202 (void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);
1205 if (bcmp(dialog->sip_dlg_id, hindex,
1206 sizeof (dialog->sip_dlg_id)) == 0) {
1207 SIP_DLG_REFCNT_INCR(dialog);
1208 (void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);
1211 (void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);
1221 _sip_dialog_t *dialog = (_sip_dialog_t *)obj;
1224 (void) pthread_mutex_lock(&dialog->sip_dlg_mutex);
1225 if (bcmp(dialog->sip_dlg_id, hindex, sizeof (dialog->sip_dlg_id))
1228 (void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);
1231 (void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);
1236 * Free resources associated with the dialog, the object will be removed
1242 _sip_dialog_t *dialog = (_sip_dialog_t *)obj;
1245 (void) pthread_mutex_lock(&dialog->sip_dlg_mutex);
1246 if (bcmp(dialog->sip_dlg_id, hindex, sizeof (dialog->sip_dlg_id))
1249 if (dialog->sip_dlg_state != SIP_DLG_DESTROYED) {
1250 sip_write_to_log((void *)dialog, SIP_DIALOG_LOG |
1253 assert(dialog->sip_dlg_state == SIP_DLG_DESTROYED);
1254 if (dialog->sip_dlg_ref_cnt != 0) {
1255 (void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);
1258 sip_write_to_log((void *)dialog, SIP_DIALOG_LOG, NULL, 0);
1259 sip_release_dialog_res(dialog);
1262 (void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);
1269 * dialog identifier corresponding to the request and compares it with
1270 * existing dialogs. If there is a match, this is a mid-dialog request.
1279 _sip_dialog_t *dialog;
1307 dialog = (_sip_dialog_t *)sip_hash_find(sip_dialog_hash,
1309 if (dialog == NULL) {
1313 dialog = (_sip_dialog_t *)sip_hash_find(sip_dialog_phash,
1317 return ((sip_dialog_t)dialog);
1321 * We keep this partial dialog for the duration of the INVITE
1328 _sip_dialog_t *dialog = (_sip_dialog_t *)tim_obj->dialog;
1331 (void) pthread_mutex_lock(&dialog->sip_dlg_mutex);
1332 if (dialog->sip_dlg_state != SIP_DLG_NEW) {
1333 sip_write_to_log((void *)dialog, SIP_DIALOG_LOG |
1336 assert(dialog->sip_dlg_state == SIP_DLG_NEW);
1337 dialog->sip_dlg_state = SIP_DLG_DESTROYED;
1338 if (dialog->sip_dlg_type == SIP_UAC_DIALOG) {
1339 index = SIP_DIGEST_TO_HASH(dialog->sip_dlg_id);
1340 (void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);
1341 sip_hash_delete(sip_dialog_phash, (void *)dialog->sip_dlg_id,
1344 (void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);
1347 tim_obj->func(dialog, NULL, NULL);
1349 SIP_DLG_REFCNT_DECR(dialog);
1353 * Terminate a dialog
1356 sip_dialog_terminate(_sip_dialog_t *dialog, sip_msg_t sip_msg)
1360 (void) pthread_mutex_lock(&dialog->sip_dlg_mutex);
1361 prev_state = dialog->sip_dlg_state;
1362 dialog->sip_dlg_state = SIP_DLG_DESTROYED;
1363 (void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);
1365 sip_dlg_ulp_state_cb((sip_dialog_t)dialog, sip_msg, prev_state,
1366 dialog->sip_dlg_state);
1368 SIP_DLG_REFCNT_DECR(dialog);
1372 * Delete a dialog
1375 sip_dialog_delete(_sip_dialog_t *dialog)
1380 * partial dialog, not in the hash table
1382 if (dialog->sip_dlg_local_uri_tag == NULL ||
1383 dialog->sip_dlg_remote_uri_tag == NULL) {
1385 * Cancel the partial dialog timer
1387 if (SIP_IS_TIMER_RUNNING(dialog->sip_dlg_timer))
1388 SIP_CANCEL_TIMER(dialog->sip_dlg_timer);
1389 sip_write_to_log((void *)dialog, SIP_DIALOG_LOG, NULL, 0);
1390 sip_release_dialog_res(dialog);
1393 index = SIP_DIGEST_TO_HASH(dialog->sip_dlg_id);
1394 sip_hash_delete(sip_dialog_hash, (void *)dialog->sip_dlg_id, index,
1402 sip_get_rtarg(_sip_dialog_t *dialog, _sip_msg_t *sip_msg)
1406 if (dialog->sip_dlg_remote_target != NULL)
1414 if ((dialog->sip_dlg_remote_target = sip_dup_header(chdr)) == NULL)
1459 * of a dialog may be received within a dialog.
1461 * outside the dialog.
1520 * Let the user delete the dialog if it is not a 1XX/2XX resp
1521 * for an early INVITE dialog.
1577 * Copy partial dialog to create a complete dialog
1580 sip_copy_partial_dialog(_sip_dialog_t *dialog)
1587 if (dialog->sip_dlg_req_uri.sip_str_ptr != NULL) {
1589 malloc(dialog->sip_dlg_req_uri.sip_str_len + 1);
1595 dialog->sip_dlg_req_uri.sip_str_ptr,
1596 dialog->sip_dlg_req_uri.sip_str_len);
1598 dialog->sip_dlg_req_uri.sip_str_len] = '\0';
1600 dialog->sip_dlg_req_uri.sip_str_len;
1602 if (dialog->sip_dlg_route_set != NULL) {
1603 if (dialog->sip_dlg_rset.sip_str_ptr == NULL) {
1604 sip_write_to_log((void *)dialog, SIP_DIALOG_LOG |
1607 assert(dialog->sip_dlg_rset.sip_str_ptr != NULL);
1609 malloc(dialog->sip_dlg_rset.sip_str_len + 1);
1617 dialog->sip_dlg_rset.sip_str_ptr,
1618 dialog->sip_dlg_rset.sip_str_len);
1620 dialog->sip_dlg_rset.sip_str_len] = '\0';
1622 dialog->sip_dlg_rset.sip_str_len;
1625 sip_dup_header(dialog->sip_dlg_route_set);
1635 sip_dup_header(dialog->sip_dlg_local_uri_tag)) == NULL ||
1637 sip_dup_header(dialog->sip_dlg_remote_target)) == NULL ||
1639 sip_dup_header(dialog->sip_dlg_local_contact)) == NULL ||
1641 sip_dup_header(dialog->sip_dlg_call_id)) == NULL) {
1645 if (dialog->sip_dlg_event != NULL) {
1646 new_dlg->sip_dlg_event = sip_dup_header(dialog->sip_dlg_event);
1652 new_dlg->sip_dlg_local_cseq = dialog->sip_dlg_local_cseq;
1653 new_dlg->sip_dlg_type = dialog->sip_dlg_type;
1661 * Update the dialog using the response
1664 sip_update_dialog(sip_dialog_t dialog, _sip_msg_t *sip_msg)
1674 _dialog = (_sip_dialog_t *)dialog;
1683 return (dialog);
1690 return (dialog);
1696 return (dialog);
1701 return (dialog);
1709 * Let the user delete the dialog if it is not a 1XX/2XX resp
1710 * for an early dialog.
1743 sip_dlg_ulp_state_cb(dialog, (sip_msg_t)sip_msg,
1744 prev_state, dialog->sip_dlg_state);
1753 return (dialog);
1763 return (dialog);
1768 * dialog, we release it here and incr the
1769 * ref on the new dialog which will be
1784 * responses will not result in a dialog.
1787 * one when the partial dialog was created -
1800 index = SIP_DIGEST_TO_HASH(dialog->sip_dlg_id);
1814 if ((dialog = sip_complete_dialog(sip_msg, _dialog)) ==
1825 return (dialog);
1860 sip_dialog_add_new_contact(sip_dialog_t dialog, _sip_msg_t *sip_msg)
1872 (void) pthread_mutex_lock(&dialog->sip_dlg_mutex);
1873 if (dialog->sip_dlg_method != INVITE || dialog->sip_dlg_state
1875 (void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);
1880 if (dialog->sip_dlg_new_local_contact != NULL)
1881 sip_free_header(dialog->sip_dlg_new_local_contact);
1882 dialog->sip_dlg_new_local_contact = nhdr;
1884 (void) pthread_mutex_unlock(&dialog->sip_dlg_mutex);