4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #pragma ident "%Z%%M% %I% %E% SMI"
38 #include <sys/types.h>
41 #include "sip_miscdefs.h"
44 * Dialogs are linked in their own list.
48 /* This is always done within sip_dlg_mutex */
49 #define SIP_DLG_REFCNT_INCR(dialog) \
50 (dialog)->sip_dlg_ref_cnt++;
52 #define SIP_DLG_REFCNT_DECR(dialog) { \
53 (void) pthread_mutex_lock(&((dialog)->sip_dlg_mutex)); \
54 assert((dialog)->sip_dlg_ref_cnt > 0); \
55 (dialog)->sip_dlg_ref_cnt--; \
56 if ((dialog)->sip_dlg_ref_cnt == 0 && \
57 (dialog)->sip_dlg_state == SIP_DLG_DESTROYED) { \
58 (void) pthread_mutex_unlock(&((dialog)->sip_dlg_mutex)); \
59 sip_dialog_delete(dialog); \
61 (void) pthread_mutex_unlock(&((dialog)->sip_dlg_mutex));\
65 /* The dialog structure */
66 typedef struct sip_dialog
68 _sip_header_t
*sip_dlg_remote_uri_tag
;
69 _sip_header_t
*sip_dlg_local_uri_tag
;
70 _sip_header_t
*sip_dlg_remote_target
;
71 _sip_header_t
*sip_dlg_local_contact
;
72 _sip_header_t
*sip_dlg_new_local_contact
; /* for re-INVITE */
73 _sip_header_t
*sip_dlg_route_set
;
74 _sip_header_t
*sip_dlg_event
;
75 sip_str_t sip_dlg_rset
;
76 sip_str_t sip_dlg_req_uri
;
77 _sip_header_t
*sip_dlg_call_id
;
78 uint32_t sip_dlg_local_cseq
;
79 uint32_t sip_dlg_remote_cseq
;
80 uint16_t sip_dlg_id
[8];
81 boolean_t sip_dlg_secure
;
82 dialog_state_t sip_dlg_state
;
83 int sip_dlg_type
; /* CALLEE or CALLER */
84 pthread_mutex_t sip_dlg_mutex
;
85 uint32_t sip_dlg_ref_cnt
;
86 sip_timer_t sip_dlg_timer
; /* to delete partial dialogs */
87 boolean_t sip_dlg_on_fork
;
88 sip_method_t sip_dlg_method
;
89 void *sip_dlg_ctxt
; /* currently unused */
91 sip_log_t sip_dlg_log
[SIP_DLG_DESTROYED
+ 1];
94 void sip_dialog_init(void (*sip_ulp_dlg_del
)(sip_dialog_t
,
96 void (*ulp_dlg_state
)(sip_dialog_t
, sip_msg_t
,
98 sip_dialog_t
sip_dialog_create(_sip_msg_t
*, _sip_msg_t
*, int);
99 sip_dialog_t
sip_dialog_find(_sip_msg_t
*);
100 int sip_dialog_process(_sip_msg_t
*, sip_dialog_t
*);
101 sip_dialog_t
sip_update_dialog(sip_dialog_t
, _sip_msg_t
*);
102 void sip_dialog_add_new_contact(sip_dialog_t
, _sip_msg_t
*);
103 void sip_dialog_terminate(sip_dialog_t
, sip_msg_t
);
104 sip_dialog_t
sip_seed_dialog(sip_conn_object_t
, _sip_msg_t
*,
106 char *sip_dialog_req_uri(sip_dialog_t
);
107 void sip_dialog_delete(_sip_dialog_t
*);
108 extern char *sip_get_dialog_state_str(int);
109 extern boolean_t
sip_incomplete_dialog(sip_dialog_t
);
115 #endif /* _SIP_DIALOG_H */