xref: /onnv-gate/usr/src/lib/libsip/common/sip_dialog.h (revision 2882:5f4abbf1f03e)
1*2882Svi117747 /*
2*2882Svi117747  * CDDL HEADER START
3*2882Svi117747  *
4*2882Svi117747  * The contents of this file are subject to the terms of the
5*2882Svi117747  * Common Development and Distribution License (the "License").
6*2882Svi117747  * You may not use this file except in compliance with the License.
7*2882Svi117747  *
8*2882Svi117747  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*2882Svi117747  * or http://www.opensolaris.org/os/licensing.
10*2882Svi117747  * See the License for the specific language governing permissions
11*2882Svi117747  * and limitations under the License.
12*2882Svi117747  *
13*2882Svi117747  * When distributing Covered Code, include this CDDL HEADER in each
14*2882Svi117747  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*2882Svi117747  * If applicable, add the following below this CDDL HEADER, with the
16*2882Svi117747  * fields enclosed by brackets "[]" replaced with your own identifying
17*2882Svi117747  * information: Portions Copyright [yyyy] [name of copyright owner]
18*2882Svi117747  *
19*2882Svi117747  * CDDL HEADER END
20*2882Svi117747  */
21*2882Svi117747 
22*2882Svi117747 /*
23*2882Svi117747  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24*2882Svi117747  * Use is subject to license terms.
25*2882Svi117747  */
26*2882Svi117747 
27*2882Svi117747 #ifndef	_SIP_DIALOG_H
28*2882Svi117747 #define	_SIP_DIALOG_H
29*2882Svi117747 
30*2882Svi117747 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*2882Svi117747 
32*2882Svi117747 #ifdef	__cplusplus
33*2882Svi117747 extern "C" {
34*2882Svi117747 #endif
35*2882Svi117747 
36*2882Svi117747 /*
37*2882Svi117747  * Dialogs are linked in their own list.
38*2882Svi117747  */
39*2882Svi117747 
40*2882Svi117747 
41*2882Svi117747 /* This is always done within sip_dlg_mutex */
42*2882Svi117747 #define	SIP_DLG_REFCNT_INCR(dialog)					\
43*2882Svi117747 	(dialog)->sip_dlg_ref_cnt++;
44*2882Svi117747 
45*2882Svi117747 #define	SIP_DLG_REFCNT_DECR(dialog)	 {				\
46*2882Svi117747 	(void) pthread_mutex_lock(&((dialog)->sip_dlg_mutex));		\
47*2882Svi117747 	assert((dialog)->sip_dlg_ref_cnt > 0);				\
48*2882Svi117747 	(dialog)->sip_dlg_ref_cnt--;					\
49*2882Svi117747 	if ((dialog)->sip_dlg_ref_cnt == 0 &&				\
50*2882Svi117747 	    (dialog)->sip_dlg_state == SIP_DLG_DESTROYED) {		\
51*2882Svi117747 		(void) pthread_mutex_unlock(&((dialog)->sip_dlg_mutex)); \
52*2882Svi117747 		sip_dialog_delete(dialog);				\
53*2882Svi117747 	} else {							\
54*2882Svi117747 		(void) pthread_mutex_unlock(&((dialog)->sip_dlg_mutex));\
55*2882Svi117747 	}								\
56*2882Svi117747 }
57*2882Svi117747 
58*2882Svi117747 /* The dialog structure */
59*2882Svi117747 typedef struct sip_dialog
60*2882Svi117747 {
61*2882Svi117747 	_sip_header_t		*sip_dlg_remote_uri_tag;
62*2882Svi117747 	_sip_header_t		*sip_dlg_local_uri_tag;
63*2882Svi117747 	_sip_header_t		*sip_dlg_remote_target;
64*2882Svi117747 	_sip_header_t		*sip_dlg_route_set;
65*2882Svi117747 	_sip_header_t		*sip_dlg_event;
66*2882Svi117747 	sip_str_t		sip_dlg_rset;
67*2882Svi117747 	sip_str_t		sip_dlg_req_uri;
68*2882Svi117747 	_sip_header_t		*sip_dlg_call_id;
69*2882Svi117747 	uint32_t		sip_dlg_local_cseq;
70*2882Svi117747 	uint32_t		sip_dlg_remote_cseq;
71*2882Svi117747 	uint16_t		sip_dlg_id[8];
72*2882Svi117747 	boolean_t		sip_dlg_secure;
73*2882Svi117747 	dialog_state_t		sip_dlg_state;
74*2882Svi117747 	int			sip_dlg_type;	/* CALLEE or CALLER */
75*2882Svi117747 	pthread_mutex_t		sip_dlg_mutex;
76*2882Svi117747 	uint32_t		sip_dlg_ref_cnt;
77*2882Svi117747 	sip_timer_t		sip_dlg_timer;	/* to delete partial dialogs */
78*2882Svi117747 	boolean_t		sip_dlg_on_fork;
79*2882Svi117747 	sip_method_t		sip_dlg_method;
80*2882Svi117747 	void			*sip_dlg_ctxt;	/* currently unused */
81*2882Svi117747 } _sip_dialog_t;
82*2882Svi117747 
83*2882Svi117747 void			sip_dialog_init(void (*sip_ulp_dlg_del)(sip_dialog_t,
84*2882Svi117747 			    sip_msg_t, void *),
85*2882Svi117747 			    void (*ulp_dlg_state)(sip_dialog_t, sip_msg_t,
86*2882Svi117747 			    int, int));
87*2882Svi117747 sip_dialog_t		sip_dialog_create(_sip_msg_t *, _sip_msg_t *, int);
88*2882Svi117747 sip_dialog_t		sip_dialog_find(_sip_msg_t *);
89*2882Svi117747 int			sip_dialog_process(_sip_msg_t *, sip_dialog_t *);
90*2882Svi117747 sip_dialog_t		sip_update_dialog(sip_dialog_t, _sip_msg_t *);
91*2882Svi117747 void			sip_dialog_terminate(sip_dialog_t, sip_msg_t);
92*2882Svi117747 sip_dialog_t		sip_seed_dialog(sip_conn_object_t, _sip_msg_t *,
93*2882Svi117747 			    boolean_t, int);
94*2882Svi117747 char			*sip_dialog_req_uri(sip_dialog_t);
95*2882Svi117747 void			sip_dialog_delete(_sip_dialog_t *);
96*2882Svi117747 extern boolean_t	sip_incomplete_dialog(sip_dialog_t);
97*2882Svi117747 
98*2882Svi117747 #ifdef	__cplusplus
99*2882Svi117747 }
100*2882Svi117747 #endif
101*2882Svi117747 
102*2882Svi117747 #endif	/* _SIP_DIALOG_H */
103