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 /* 23*5842Sgm209912 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 242882Svi117747 * Use is subject to license terms. 252882Svi117747 */ 262882Svi117747 272882Svi117747 #ifndef _SIP_DIALOG_H 282882Svi117747 #define _SIP_DIALOG_H 292882Svi117747 302882Svi117747 #pragma ident "%Z%%M% %I% %E% SMI" 312882Svi117747 322882Svi117747 #ifdef __cplusplus 332882Svi117747 extern "C" { 342882Svi117747 #endif 352882Svi117747 363439Svi117747 #include <pthread.h> 373439Svi117747 #include <sip.h> 383439Svi117747 #include <sys/types.h> 393439Svi117747 403439Svi117747 #include "sip_msg.h" 413439Svi117747 #include "sip_miscdefs.h" 423439Svi117747 432882Svi117747 /* 442882Svi117747 * Dialogs are linked in their own list. 452882Svi117747 */ 462882Svi117747 472882Svi117747 482882Svi117747 /* This is always done within sip_dlg_mutex */ 492882Svi117747 #define SIP_DLG_REFCNT_INCR(dialog) \ 502882Svi117747 (dialog)->sip_dlg_ref_cnt++; 512882Svi117747 522882Svi117747 #define SIP_DLG_REFCNT_DECR(dialog) { \ 532882Svi117747 (void) pthread_mutex_lock(&((dialog)->sip_dlg_mutex)); \ 542882Svi117747 assert((dialog)->sip_dlg_ref_cnt > 0); \ 552882Svi117747 (dialog)->sip_dlg_ref_cnt--; \ 562882Svi117747 if ((dialog)->sip_dlg_ref_cnt == 0 && \ 572882Svi117747 (dialog)->sip_dlg_state == SIP_DLG_DESTROYED) { \ 582882Svi117747 (void) pthread_mutex_unlock(&((dialog)->sip_dlg_mutex)); \ 592882Svi117747 sip_dialog_delete(dialog); \ 602882Svi117747 } else { \ 612882Svi117747 (void) pthread_mutex_unlock(&((dialog)->sip_dlg_mutex));\ 622882Svi117747 } \ 632882Svi117747 } 642882Svi117747 652882Svi117747 /* The dialog structure */ 662882Svi117747 typedef struct sip_dialog 672882Svi117747 { 682882Svi117747 _sip_header_t *sip_dlg_remote_uri_tag; 692882Svi117747 _sip_header_t *sip_dlg_local_uri_tag; 702882Svi117747 _sip_header_t *sip_dlg_remote_target; 714702Sgm209912 _sip_header_t *sip_dlg_local_contact; 724702Sgm209912 _sip_header_t *sip_dlg_new_local_contact; /* for re-INVITE */ 732882Svi117747 _sip_header_t *sip_dlg_route_set; 742882Svi117747 _sip_header_t *sip_dlg_event; 752882Svi117747 sip_str_t sip_dlg_rset; 762882Svi117747 sip_str_t sip_dlg_req_uri; 772882Svi117747 _sip_header_t *sip_dlg_call_id; 782882Svi117747 uint32_t sip_dlg_local_cseq; 792882Svi117747 uint32_t sip_dlg_remote_cseq; 802882Svi117747 uint16_t sip_dlg_id[8]; 812882Svi117747 boolean_t sip_dlg_secure; 822882Svi117747 dialog_state_t sip_dlg_state; 832882Svi117747 int sip_dlg_type; /* CALLEE or CALLER */ 842882Svi117747 pthread_mutex_t sip_dlg_mutex; 852882Svi117747 uint32_t sip_dlg_ref_cnt; 862882Svi117747 sip_timer_t sip_dlg_timer; /* to delete partial dialogs */ 872882Svi117747 boolean_t sip_dlg_on_fork; 882882Svi117747 sip_method_t sip_dlg_method; 892882Svi117747 void *sip_dlg_ctxt; /* currently unused */ 90*5842Sgm209912 int sip_dlg_msgcnt; 91*5842Sgm209912 sip_log_t sip_dlg_log[SIP_DLG_DESTROYED + 1]; 922882Svi117747 } _sip_dialog_t; 932882Svi117747 942882Svi117747 void sip_dialog_init(void (*sip_ulp_dlg_del)(sip_dialog_t, 952882Svi117747 sip_msg_t, void *), 962882Svi117747 void (*ulp_dlg_state)(sip_dialog_t, sip_msg_t, 972882Svi117747 int, int)); 982882Svi117747 sip_dialog_t sip_dialog_create(_sip_msg_t *, _sip_msg_t *, int); 992882Svi117747 sip_dialog_t sip_dialog_find(_sip_msg_t *); 1002882Svi117747 int sip_dialog_process(_sip_msg_t *, sip_dialog_t *); 1012882Svi117747 sip_dialog_t sip_update_dialog(sip_dialog_t, _sip_msg_t *); 1024702Sgm209912 void sip_dialog_add_new_contact(sip_dialog_t, _sip_msg_t *); 1032882Svi117747 void sip_dialog_terminate(sip_dialog_t, sip_msg_t); 1042882Svi117747 sip_dialog_t sip_seed_dialog(sip_conn_object_t, _sip_msg_t *, 1052882Svi117747 boolean_t, int); 1062882Svi117747 char *sip_dialog_req_uri(sip_dialog_t); 1072882Svi117747 void sip_dialog_delete(_sip_dialog_t *); 108*5842Sgm209912 extern char *sip_get_dialog_state_str(int); 1092882Svi117747 extern boolean_t sip_incomplete_dialog(sip_dialog_t); 1102882Svi117747 1112882Svi117747 #ifdef __cplusplus 1122882Svi117747 } 1132882Svi117747 #endif 1142882Svi117747 1152882Svi117747 #endif /* _SIP_DIALOG_H */ 116