12882Svi117747 /* 22882Svi117747 * CDDL HEADER START 32882Svi117747 * 42882Svi117747 * The contents of this file are subject to the terms of the 52882Svi117747 * Common Development and Distribution License (the "License"). 62882Svi117747 * You may not use this file except in compliance with the License. 72882Svi117747 * 82882Svi117747 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 92882Svi117747 * or http://www.opensolaris.org/os/licensing. 102882Svi117747 * See the License for the specific language governing permissions 112882Svi117747 * and limitations under the License. 122882Svi117747 * 132882Svi117747 * When distributing Covered Code, include this CDDL HEADER in each 142882Svi117747 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 152882Svi117747 * If applicable, add the following below this CDDL HEADER, with the 162882Svi117747 * fields enclosed by brackets "[]" replaced with your own identifying 172882Svi117747 * information: Portions Copyright [yyyy] [name of copyright owner] 182882Svi117747 * 192882Svi117747 * CDDL HEADER END 202882Svi117747 */ 212882Svi117747 222882Svi117747 /* 233439Svi117747 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 242882Svi117747 * Use is subject to license terms. 252882Svi117747 */ 262882Svi117747 272882Svi117747 #pragma ident "%Z%%M% %I% %E% SMI" 282882Svi117747 293439Svi117747 #include <stdlib.h> 303439Svi117747 #include <assert.h> 313439Svi117747 #include <errno.h> 323439Svi117747 #include <pthread.h> 333439Svi117747 #include <sip.h> 343439Svi117747 352882Svi117747 #include "sip_msg.h" 362882Svi117747 #include "sip_miscdefs.h" 373439Svi117747 #include "sip_parse_uri.h" 382882Svi117747 #include "sip_dialog.h" 392882Svi117747 402882Svi117747 /* 412882Svi117747 * Create a request using the state maintained in the dialog. 422882Svi117747 */ 432882Svi117747 sip_msg_t 442882Svi117747 sip_create_dialog_req(sip_method_t method, sip_dialog_t dialog, 452882Svi117747 char *transport, char *sent_by, int sent_by_port, char *via_param, 462882Svi117747 uint32_t maxforward, int cseq) 472882Svi117747 { 482882Svi117747 _sip_dialog_t *_dialog; 492882Svi117747 sip_msg_t sip_msg; 502882Svi117747 char *uri; 512882Svi117747 int oldseq = 0; 522882Svi117747 532882Svi117747 if (!sip_manage_dialog || dialog == NULL || transport == NULL || 542882Svi117747 sent_by == NULL) { 552882Svi117747 return (NULL); 562882Svi117747 } 572882Svi117747 if ((sip_msg = sip_new_msg()) == NULL) 582882Svi117747 return (NULL); 592882Svi117747 _dialog = (_sip_dialog_t *)dialog; 602882Svi117747 (void) pthread_mutex_lock(&_dialog->sip_dlg_mutex); 612882Svi117747 /* 622882Svi117747 * Depending on the route set, if any, the request URI could either 632882Svi117747 * be the contact URI or the 1st URI from the route set. 642882Svi117747 */ 652882Svi117747 uri = (char *)sip_dialog_req_uri(_dialog); 662882Svi117747 if (uri == NULL) 672882Svi117747 goto err_ret; 682882Svi117747 if (sip_add_request_line(sip_msg, method, uri) != 0) { 692882Svi117747 free(uri); 702882Svi117747 goto err_ret; 712882Svi117747 } 722882Svi117747 free(uri); 732882Svi117747 if (sip_copy_header(sip_msg, _dialog->sip_dlg_local_uri_tag, NULL) != 0) 742882Svi117747 goto err_ret; 752882Svi117747 if (sip_copy_header(sip_msg, _dialog->sip_dlg_remote_uri_tag, NULL) != 762882Svi117747 0) { 772882Svi117747 goto err_ret; 782882Svi117747 } 794702Sgm209912 if (sip_copy_header(sip_msg, _dialog->sip_dlg_local_contact, NULL) != 0) 804702Sgm209912 goto err_ret; 812882Svi117747 if (sip_add_via(sip_msg, transport, sent_by, sent_by_port, via_param) != 822882Svi117747 0) { 832882Svi117747 goto err_ret; 842882Svi117747 } 852882Svi117747 if (sip_add_maxforward(sip_msg, maxforward) != 0) 862882Svi117747 goto err_ret; 872882Svi117747 if (sip_copy_header(sip_msg, _dialog->sip_dlg_call_id, NULL) != 0) 882882Svi117747 goto err_ret; 892882Svi117747 if (cseq < 0) { 902882Svi117747 if (_dialog->sip_dlg_local_cseq == 0) 912882Svi117747 _dialog->sip_dlg_local_cseq = 1; 922882Svi117747 oldseq = _dialog->sip_dlg_local_cseq; 932882Svi117747 cseq = ++_dialog->sip_dlg_local_cseq; 942882Svi117747 } 952882Svi117747 if (sip_add_cseq(sip_msg, method, cseq) != 0) { 962882Svi117747 _dialog->sip_dlg_local_cseq = oldseq; 972882Svi117747 goto err_ret; 982882Svi117747 } 992882Svi117747 /* 1002882Svi117747 * The route set, even if empty, overrides any pre-existing route set. 1012882Svi117747 * If the route set is empty, the UAC MUST NOT add a Route header 1022882Svi117747 * field to the request. 1032882Svi117747 */ 1042882Svi117747 (void) sip_delete_header_by_name(sip_msg, SIP_ROUTE); 1052882Svi117747 1062882Svi117747 if (_dialog->sip_dlg_route_set != NULL) { 1072882Svi117747 if (sip_copy_header(sip_msg, _dialog->sip_dlg_route_set, 1082882Svi117747 NULL) != 0) { 1092882Svi117747 _dialog->sip_dlg_local_cseq = oldseq; 1102882Svi117747 goto err_ret; 1112882Svi117747 } 1122882Svi117747 } 1132882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 1142882Svi117747 return (sip_msg); 1152882Svi117747 err_ret: 1162882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 1172882Svi117747 sip_free_msg(sip_msg); 1182882Svi117747 return (NULL); 1192882Svi117747 } 1202882Svi117747 1212882Svi117747 /* 122*5092Sgm209912 * Create a request using the state maintained in the dialog. The request will 123*5092Sgm209912 * not have Contact header. 124*5092Sgm209912 */ 125*5092Sgm209912 sip_msg_t 126*5092Sgm209912 sip_create_dialog_req_nocontact(sip_method_t method, sip_dialog_t dialog, 127*5092Sgm209912 char *transport, char *sent_by, int sent_by_port, char *via_param, 128*5092Sgm209912 uint32_t maxforward, int cseq) 129*5092Sgm209912 { 130*5092Sgm209912 sip_msg_t sip_msg; 131*5092Sgm209912 132*5092Sgm209912 sip_msg = sip_create_dialog_req(method, dialog, transport, sent_by, 133*5092Sgm209912 sent_by_port, via_param, maxforward, cseq); 134*5092Sgm209912 if (sip_msg != NULL) { 135*5092Sgm209912 if (sip_delete_header_by_name(sip_msg, SIP_CONTACT) != 0) { 136*5092Sgm209912 sip_free_msg(sip_msg); 137*5092Sgm209912 return (NULL); 138*5092Sgm209912 } 139*5092Sgm209912 } 140*5092Sgm209912 141*5092Sgm209912 return (sip_msg); 142*5092Sgm209912 } 143*5092Sgm209912 144*5092Sgm209912 /* 1452882Svi117747 * Get the Dialog method 1462882Svi117747 */ 1472882Svi117747 int 1482882Svi117747 sip_get_dialog_method(sip_dialog_t dialog, int *error) 1492882Svi117747 { 1502882Svi117747 _sip_dialog_t *_dialog; 1512882Svi117747 1522882Svi117747 if (error != NULL) 1532882Svi117747 *error = 0; 1542882Svi117747 if (!sip_manage_dialog) { 1552882Svi117747 if (error != NULL) 1562882Svi117747 *error = EINVAL; 1572882Svi117747 return (0); 1582882Svi117747 } 1592882Svi117747 if (dialog == NULL) { 1602882Svi117747 if (error != NULL) 1612882Svi117747 *error = EINVAL; 1622882Svi117747 return (0); 1632882Svi117747 } 1642882Svi117747 _dialog = (_sip_dialog_t *)dialog; 1652882Svi117747 return (_dialog->sip_dlg_method); 1662882Svi117747 } 1672882Svi117747 1682882Svi117747 /* 1692882Svi117747 * Get the Dialog state 1702882Svi117747 */ 1712882Svi117747 int 1722882Svi117747 sip_get_dialog_state(sip_dialog_t dialog, int *error) 1732882Svi117747 { 1742882Svi117747 _sip_dialog_t *_dialog; 1752882Svi117747 1762882Svi117747 if (error != NULL) 1772882Svi117747 *error = 0; 1782882Svi117747 if (!sip_manage_dialog) { 1792882Svi117747 if (error != NULL) 1802882Svi117747 *error = EINVAL; 1812882Svi117747 return (0); 1822882Svi117747 } 1832882Svi117747 if (dialog == NULL) { 1842882Svi117747 if (error != NULL) 1852882Svi117747 *error = EINVAL; 1862882Svi117747 return (0); 1872882Svi117747 } 1882882Svi117747 _dialog = (_sip_dialog_t *)dialog; 1892882Svi117747 return (_dialog->sip_dlg_state); 1902882Svi117747 } 1912882Svi117747 1922882Svi117747 /* 1932882Svi117747 * Return the dialog callid 1942882Svi117747 */ 1952882Svi117747 const sip_str_t * 1962882Svi117747 sip_get_dialog_callid(sip_dialog_t dialog, int *error) 1972882Svi117747 { 1982882Svi117747 _sip_dialog_t *_dialog; 1992882Svi117747 const struct sip_value *val; 2002882Svi117747 const sip_str_t *callid = NULL; 2012882Svi117747 2022882Svi117747 if (error != NULL) 2032882Svi117747 *error = 0; 2042882Svi117747 if (!sip_manage_dialog || dialog == NULL) { 2052882Svi117747 if (error != NULL) 2062882Svi117747 *error = EINVAL; 2072882Svi117747 return (NULL); 2082882Svi117747 } 2092882Svi117747 _dialog = (_sip_dialog_t *)dialog; 2102882Svi117747 (void) pthread_mutex_lock(&_dialog->sip_dlg_mutex); 2112882Svi117747 if (dialog->sip_dlg_call_id != NULL) { 2122882Svi117747 val = sip_get_header_value(_dialog->sip_dlg_call_id, error); 2132882Svi117747 if (val == NULL) { 2142882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 2152882Svi117747 return (NULL); 2162882Svi117747 } 2172882Svi117747 callid = &((sip_hdr_value_t *)val)->str_val; 2182882Svi117747 } 2192882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 2202882Svi117747 return (callid); 2212882Svi117747 } 2222882Svi117747 2232882Svi117747 /* 2242882Svi117747 * Return the dialog localtag. 2252882Svi117747 */ 2262882Svi117747 const sip_str_t * 2272882Svi117747 sip_get_dialog_local_tag(sip_dialog_t dialog, int *error) 2282882Svi117747 { 2292882Svi117747 _sip_dialog_t *_dialog; 2302882Svi117747 const sip_str_t *ltag = NULL; 2312882Svi117747 const struct sip_value *val; 2322882Svi117747 2332882Svi117747 if (error != NULL) 2342882Svi117747 *error = 0; 2352882Svi117747 if (!sip_manage_dialog || dialog == NULL) { 2362882Svi117747 if (error != NULL) 2372882Svi117747 *error = EINVAL; 2382882Svi117747 return (NULL); 2392882Svi117747 } 2402882Svi117747 _dialog = (_sip_dialog_t *)dialog; 2412882Svi117747 (void) pthread_mutex_lock(&_dialog->sip_dlg_mutex); 2422882Svi117747 if (dialog->sip_dlg_local_uri_tag != NULL) { 2432882Svi117747 val = sip_get_header_value(_dialog->sip_dlg_local_uri_tag, 2442882Svi117747 error); 2452882Svi117747 if (val == NULL) { 2462882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 2472882Svi117747 return (NULL); 2482882Svi117747 } 2492882Svi117747 ltag = sip_get_param_value((sip_header_value_t)val, "tag", 2502882Svi117747 error); 2512882Svi117747 } 2522882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 2532882Svi117747 return (ltag); 2542882Svi117747 } 2552882Svi117747 2562882Svi117747 /* 2572882Svi117747 * Return the dialog remotetag 2582882Svi117747 */ 2592882Svi117747 const sip_str_t * 2602882Svi117747 sip_get_dialog_remote_tag(sip_dialog_t dialog, int *error) 2612882Svi117747 { 2622882Svi117747 _sip_dialog_t *_dialog; 2632882Svi117747 const sip_str_t *ttag = NULL; 2642882Svi117747 const struct sip_value *val; 2652882Svi117747 2662882Svi117747 if (error != NULL) 2672882Svi117747 *error = 0; 2682882Svi117747 if (!sip_manage_dialog || dialog == NULL) { 2692882Svi117747 if (error != NULL) 2702882Svi117747 *error = EINVAL; 2712882Svi117747 return (NULL); 2722882Svi117747 } 2732882Svi117747 _dialog = (_sip_dialog_t *)dialog; 2742882Svi117747 (void) pthread_mutex_lock(&_dialog->sip_dlg_mutex); 2752882Svi117747 if (dialog->sip_dlg_remote_uri_tag != NULL) { 2762882Svi117747 val = sip_get_header_value(_dialog->sip_dlg_remote_uri_tag, 2772882Svi117747 error); 2782882Svi117747 if (val == NULL) { 2792882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 2802882Svi117747 return (NULL); 2812882Svi117747 } 2822882Svi117747 ttag = sip_get_param_value((sip_header_value_t)val, "tag", 2832882Svi117747 error); 2842882Svi117747 } 2852882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 2862882Svi117747 2872882Svi117747 return (ttag); 2882882Svi117747 } 2892882Svi117747 2902882Svi117747 /* 2912882Svi117747 * Return the dialog localuri. 2922882Svi117747 */ 2932882Svi117747 const struct sip_uri * 2942882Svi117747 sip_get_dialog_local_uri(sip_dialog_t dialog, int *error) 2952882Svi117747 { 2962882Svi117747 _sip_dialog_t *_dialog; 2972882Svi117747 const _sip_uri_t *luri = NULL; 2982882Svi117747 const struct sip_value *val; 2992882Svi117747 3002882Svi117747 if (error != NULL) 3012882Svi117747 *error = 0; 3022882Svi117747 if (!sip_manage_dialog || dialog == NULL) { 3032882Svi117747 if (error != NULL) 3042882Svi117747 *error = EINVAL; 3052882Svi117747 return (NULL); 3062882Svi117747 } 3072882Svi117747 _dialog = (_sip_dialog_t *)dialog; 3082882Svi117747 (void) pthread_mutex_lock(&_dialog->sip_dlg_mutex); 3092882Svi117747 if (dialog->sip_dlg_local_uri_tag != NULL) { 3102882Svi117747 val = sip_get_header_value(_dialog->sip_dlg_local_uri_tag, 3112882Svi117747 error); 3122882Svi117747 if (val == NULL) { 3132882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 3142882Svi117747 return (NULL); 3152882Svi117747 } 3162882Svi117747 luri = val->sip_value_parse_uri; 3172882Svi117747 } 3182882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 3192882Svi117747 3202882Svi117747 return ((sip_uri_t)luri); 3212882Svi117747 } 3222882Svi117747 3232882Svi117747 /* 3242882Svi117747 * Return the dialog remoteuri. 3252882Svi117747 */ 3262882Svi117747 const struct sip_uri * 3272882Svi117747 sip_get_dialog_remote_uri(sip_dialog_t dialog, int *error) 3282882Svi117747 { 3292882Svi117747 _sip_dialog_t *_dialog; 3302882Svi117747 const _sip_uri_t *ruri = NULL; 3312882Svi117747 const struct sip_value *val; 3322882Svi117747 3332882Svi117747 if (error != NULL) 3342882Svi117747 *error = 0; 3352882Svi117747 if (!sip_manage_dialog || dialog == NULL) { 3362882Svi117747 if (error != NULL) 3372882Svi117747 *error = EINVAL; 3382882Svi117747 return (NULL); 3392882Svi117747 } 3402882Svi117747 _dialog = (_sip_dialog_t *)dialog; 3412882Svi117747 (void) pthread_mutex_lock(&_dialog->sip_dlg_mutex); 3422882Svi117747 if (dialog->sip_dlg_remote_uri_tag != NULL) { 3432882Svi117747 val = sip_get_header_value(dialog->sip_dlg_remote_uri_tag, 3442882Svi117747 error); 3452882Svi117747 if (val == NULL) { 3462882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 3472882Svi117747 return (NULL); 3482882Svi117747 } 3492882Svi117747 ruri = val->sip_value_parse_uri; 3502882Svi117747 } 3512882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 3522882Svi117747 return ((sip_uri_t)ruri); 3532882Svi117747 } 3542882Svi117747 3552882Svi117747 /* 3562882Svi117747 * Return the dialog remotetarg. 3572882Svi117747 */ 3582882Svi117747 const struct sip_uri * 3592882Svi117747 sip_get_dialog_remote_target_uri(sip_dialog_t dialog, int *error) 3602882Svi117747 { 3612882Svi117747 _sip_dialog_t *_dialog; 3622882Svi117747 const struct sip_uri *rtarg = NULL; 3632882Svi117747 const struct sip_value *val; 3642882Svi117747 3652882Svi117747 if (error != NULL) 3662882Svi117747 *error = 0; 3672882Svi117747 if (!sip_manage_dialog || dialog == NULL) { 3682882Svi117747 if (error != NULL) 3692882Svi117747 *error = EINVAL; 3702882Svi117747 return (NULL); 3712882Svi117747 } 3722882Svi117747 _dialog = (_sip_dialog_t *)dialog; 3732882Svi117747 (void) pthread_mutex_lock(&_dialog->sip_dlg_mutex); 3742882Svi117747 if (dialog->sip_dlg_remote_target != NULL) { 3752882Svi117747 val = sip_get_header_value(_dialog->sip_dlg_remote_target, 3762882Svi117747 error); 3772882Svi117747 if (val == NULL) { 3782882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 3792882Svi117747 return (NULL); 3802882Svi117747 } 3812882Svi117747 rtarg = val->sip_value_parse_uri; 3822882Svi117747 } 3832882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 3842882Svi117747 3852882Svi117747 return ((sip_uri_t)rtarg); 3862882Svi117747 } 3872882Svi117747 3882882Svi117747 /* 389*5092Sgm209912 * Return the dialog local contact uri. 390*5092Sgm209912 */ 391*5092Sgm209912 const struct sip_uri * 392*5092Sgm209912 sip_get_dialog_local_contact_uri(sip_dialog_t dialog, int *error) 393*5092Sgm209912 { 394*5092Sgm209912 _sip_dialog_t *_dialog; 395*5092Sgm209912 const struct sip_uri *lcuri = NULL; 396*5092Sgm209912 const struct sip_value *val; 397*5092Sgm209912 398*5092Sgm209912 if (error != NULL) 399*5092Sgm209912 *error = 0; 400*5092Sgm209912 if (!sip_manage_dialog || dialog == NULL) { 401*5092Sgm209912 if (error != NULL) 402*5092Sgm209912 *error = EINVAL; 403*5092Sgm209912 return (NULL); 404*5092Sgm209912 } 405*5092Sgm209912 _dialog = (_sip_dialog_t *)dialog; 406*5092Sgm209912 (void) pthread_mutex_lock(&_dialog->sip_dlg_mutex); 407*5092Sgm209912 if (dialog->sip_dlg_local_contact != NULL) { 408*5092Sgm209912 val = sip_get_header_value(_dialog->sip_dlg_local_contact, 409*5092Sgm209912 error); 410*5092Sgm209912 if (val == NULL) { 411*5092Sgm209912 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 412*5092Sgm209912 return (NULL); 413*5092Sgm209912 } 414*5092Sgm209912 lcuri = val->sip_value_parse_uri; 415*5092Sgm209912 } 416*5092Sgm209912 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 417*5092Sgm209912 418*5092Sgm209912 return ((sip_uri_t)lcuri); 419*5092Sgm209912 } 420*5092Sgm209912 421*5092Sgm209912 /* 4222882Svi117747 * Return the dialog route set 4232882Svi117747 */ 4242882Svi117747 const sip_str_t * 4252882Svi117747 sip_get_dialog_route_set(sip_dialog_t dialog, int *error) 4262882Svi117747 { 4272882Svi117747 _sip_dialog_t *_dialog; 4282882Svi117747 4292882Svi117747 if (error != NULL) 4302882Svi117747 *error = 0; 4312882Svi117747 if (!sip_manage_dialog || dialog == NULL) { 4322882Svi117747 if (error != NULL) 4332882Svi117747 *error = EINVAL; 4342882Svi117747 return (NULL); 4352882Svi117747 } 4362882Svi117747 _dialog = (_sip_dialog_t *)dialog; 4372882Svi117747 if (_dialog->sip_dlg_rset.sip_str_len > 0) 4382882Svi117747 return (&_dialog->sip_dlg_rset); 4392882Svi117747 return (NULL); 4402882Svi117747 } 4412882Svi117747 4422882Svi117747 /* 4432882Svi117747 * Return the dialog secure 4442882Svi117747 */ 4452882Svi117747 boolean_t 4462882Svi117747 sip_is_dialog_secure(sip_dialog_t dialog, int *error) 4472882Svi117747 { 4482882Svi117747 _sip_dialog_t *_dialog; 4492882Svi117747 boolean_t issecure; 4502882Svi117747 4512882Svi117747 if (error != NULL) 4522882Svi117747 *error = 0; 4532882Svi117747 if (!sip_manage_dialog || dialog == NULL) { 4542882Svi117747 if (error != NULL) 4552882Svi117747 *error = EINVAL; 4562882Svi117747 return (B_FALSE); 4572882Svi117747 } 4582882Svi117747 _dialog = (_sip_dialog_t *)dialog; 4592882Svi117747 (void) pthread_mutex_lock(&_dialog->sip_dlg_mutex); 4602882Svi117747 issecure = _dialog->sip_dlg_secure; 4612882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 4622882Svi117747 return (issecure); 4632882Svi117747 } 4642882Svi117747 4652882Svi117747 /* 4662882Svi117747 * Return the dialog local cseq 4672882Svi117747 */ 4682882Svi117747 uint32_t 4692882Svi117747 sip_get_dialog_local_cseq(sip_dialog_t dialog, int *error) 4702882Svi117747 { 4712882Svi117747 _sip_dialog_t *_dialog; 4722882Svi117747 uint32_t cseq; 4732882Svi117747 4742882Svi117747 if (error != NULL) 4752882Svi117747 *error = 0; 4762882Svi117747 if (!sip_manage_dialog || dialog == NULL) { 4772882Svi117747 if (error != NULL) 4782882Svi117747 *error = EINVAL; 4792882Svi117747 return (0); 4802882Svi117747 } 4812882Svi117747 _dialog = (_sip_dialog_t *)dialog; 4822882Svi117747 (void) pthread_mutex_lock(&_dialog->sip_dlg_mutex); 4832882Svi117747 cseq = _dialog->sip_dlg_local_cseq; 4842882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 4852882Svi117747 return (cseq); 4862882Svi117747 } 4872882Svi117747 4882882Svi117747 /* 4892882Svi117747 * Return the dialog remote cseq 4902882Svi117747 */ 4912882Svi117747 uint32_t 4922882Svi117747 sip_get_dialog_remote_cseq(sip_dialog_t dialog, int *error) 4932882Svi117747 { 4942882Svi117747 _sip_dialog_t *_dialog; 4952882Svi117747 uint32_t cseq; 4962882Svi117747 4972882Svi117747 if (error != NULL) 4982882Svi117747 *error = 0; 4992882Svi117747 if (!sip_manage_dialog || dialog == NULL) { 5002882Svi117747 if (error != NULL) 5012882Svi117747 *error = EINVAL; 5022882Svi117747 return (0); 5032882Svi117747 } 5042882Svi117747 _dialog = (_sip_dialog_t *)dialog; 5052882Svi117747 (void) pthread_mutex_lock(&_dialog->sip_dlg_mutex); 5062882Svi117747 cseq = _dialog->sip_dlg_remote_cseq; 5072882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 5082882Svi117747 return (cseq); 5092882Svi117747 } 5102882Svi117747 5112882Svi117747 /* 5122882Svi117747 * Return the dialog type 5132882Svi117747 */ 5142882Svi117747 int 5152882Svi117747 sip_get_dialog_type(sip_dialog_t dialog, int *error) 5162882Svi117747 { 5172882Svi117747 _sip_dialog_t *_dialog; 5182882Svi117747 int type; 5192882Svi117747 5202882Svi117747 if (error != NULL) 5212882Svi117747 *error = 0; 5222882Svi117747 if (!sip_manage_dialog || dialog == NULL) { 5232882Svi117747 if (error != NULL) 5242882Svi117747 *error = EINVAL; 5252882Svi117747 return (-1); 5262882Svi117747 } 5272882Svi117747 _dialog = (_sip_dialog_t *)dialog; 5282882Svi117747 (void) pthread_mutex_lock(&_dialog->sip_dlg_mutex); 5292882Svi117747 type = _dialog->sip_dlg_type; 5302882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 5312882Svi117747 return (type); 5322882Svi117747 } 5332882Svi117747 5342882Svi117747 5352882Svi117747 /* 5362882Svi117747 * Partial dialog ? 5372882Svi117747 */ 5382882Svi117747 boolean_t 5392882Svi117747 sip_incomplete_dialog(sip_dialog_t dialog) 5402882Svi117747 { 5412882Svi117747 _sip_dialog_t *_dialog; 5422882Svi117747 boolean_t isnew; 5432882Svi117747 5442882Svi117747 if (!sip_manage_dialog || dialog == NULL) 5452882Svi117747 return (B_FALSE); 5462882Svi117747 _dialog = (_sip_dialog_t *)dialog; 5472882Svi117747 (void) pthread_mutex_lock(&_dialog->sip_dlg_mutex); 5482882Svi117747 isnew = _dialog->sip_dlg_state == SIP_DLG_NEW; 5492882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 5502882Svi117747 return (isnew); 5512882Svi117747 } 5522882Svi117747 5532882Svi117747 /* 5542882Svi117747 * Hold dialog 5552882Svi117747 */ 5562882Svi117747 void 5572882Svi117747 sip_hold_dialog(sip_dialog_t dialog) 5582882Svi117747 { 5592882Svi117747 _sip_dialog_t *_dialog; 5602882Svi117747 5612882Svi117747 if (!sip_manage_dialog || dialog == NULL) 5622882Svi117747 return; 5632882Svi117747 _dialog = (_sip_dialog_t *)dialog; 5642882Svi117747 (void) pthread_mutex_lock(&_dialog->sip_dlg_mutex); 5652882Svi117747 SIP_DLG_REFCNT_INCR(_dialog); 5662882Svi117747 (void) pthread_mutex_unlock(&_dialog->sip_dlg_mutex); 5672882Svi117747 } 5682882Svi117747 5692882Svi117747 /* 5702882Svi117747 * Release dialog 5712882Svi117747 */ 5722882Svi117747 void 5732882Svi117747 sip_release_dialog(sip_dialog_t dialog) 5742882Svi117747 { 5752882Svi117747 _sip_dialog_t *_dialog; 5762882Svi117747 5772882Svi117747 if (!sip_manage_dialog || dialog == NULL) 5782882Svi117747 return; 5792882Svi117747 _dialog = (_sip_dialog_t *)dialog; 5802882Svi117747 SIP_DLG_REFCNT_DECR(_dialog); 5812882Svi117747 } 5822882Svi117747 5832882Svi117747 /* 5842882Svi117747 * Delete a dialog 5852882Svi117747 */ 5862882Svi117747 void 5872882Svi117747 sip_delete_dialog(sip_dialog_t dialog) 5882882Svi117747 { 5892882Svi117747 if (!sip_manage_dialog || dialog == NULL) 5902882Svi117747 return; 5912882Svi117747 sip_dialog_terminate(dialog, NULL); 5922882Svi117747 } 593