sip_dialog.h revision 2882:5f4abbf1f03e
1/*
2 * CDDL HEADER START
3 *
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.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#ifndef	_SIP_DIALOG_H
28#define	_SIP_DIALOG_H
29
30#pragma ident	"%Z%%M%	%I%	%E% SMI"
31
32#ifdef	__cplusplus
33extern "C" {
34#endif
35
36/*
37 * Dialogs are linked in their own list.
38 */
39
40
41/* This is always done within sip_dlg_mutex */
42#define	SIP_DLG_REFCNT_INCR(dialog)					\
43	(dialog)->sip_dlg_ref_cnt++;
44
45#define	SIP_DLG_REFCNT_DECR(dialog)	 {				\
46	(void) pthread_mutex_lock(&((dialog)->sip_dlg_mutex));		\
47	assert((dialog)->sip_dlg_ref_cnt > 0);				\
48	(dialog)->sip_dlg_ref_cnt--;					\
49	if ((dialog)->sip_dlg_ref_cnt == 0 &&				\
50	    (dialog)->sip_dlg_state == SIP_DLG_DESTROYED) {		\
51		(void) pthread_mutex_unlock(&((dialog)->sip_dlg_mutex)); \
52		sip_dialog_delete(dialog);				\
53	} else {							\
54		(void) pthread_mutex_unlock(&((dialog)->sip_dlg_mutex));\
55	}								\
56}
57
58/* The dialog structure */
59typedef struct sip_dialog
60{
61	_sip_header_t		*sip_dlg_remote_uri_tag;
62	_sip_header_t		*sip_dlg_local_uri_tag;
63	_sip_header_t		*sip_dlg_remote_target;
64	_sip_header_t		*sip_dlg_route_set;
65	_sip_header_t		*sip_dlg_event;
66	sip_str_t		sip_dlg_rset;
67	sip_str_t		sip_dlg_req_uri;
68	_sip_header_t		*sip_dlg_call_id;
69	uint32_t		sip_dlg_local_cseq;
70	uint32_t		sip_dlg_remote_cseq;
71	uint16_t		sip_dlg_id[8];
72	boolean_t		sip_dlg_secure;
73	dialog_state_t		sip_dlg_state;
74	int			sip_dlg_type;	/* CALLEE or CALLER */
75	pthread_mutex_t		sip_dlg_mutex;
76	uint32_t		sip_dlg_ref_cnt;
77	sip_timer_t		sip_dlg_timer;	/* to delete partial dialogs */
78	boolean_t		sip_dlg_on_fork;
79	sip_method_t		sip_dlg_method;
80	void			*sip_dlg_ctxt;	/* currently unused */
81} _sip_dialog_t;
82
83void			sip_dialog_init(void (*sip_ulp_dlg_del)(sip_dialog_t,
84			    sip_msg_t, void *),
85			    void (*ulp_dlg_state)(sip_dialog_t, sip_msg_t,
86			    int, int));
87sip_dialog_t		sip_dialog_create(_sip_msg_t *, _sip_msg_t *, int);
88sip_dialog_t		sip_dialog_find(_sip_msg_t *);
89int			sip_dialog_process(_sip_msg_t *, sip_dialog_t *);
90sip_dialog_t		sip_update_dialog(sip_dialog_t, _sip_msg_t *);
91void			sip_dialog_terminate(sip_dialog_t, sip_msg_t);
92sip_dialog_t		sip_seed_dialog(sip_conn_object_t, _sip_msg_t *,
93			    boolean_t, int);
94char			*sip_dialog_req_uri(sip_dialog_t);
95void			sip_dialog_delete(_sip_dialog_t *);
96extern boolean_t	sip_incomplete_dialog(sip_dialog_t);
97
98#ifdef	__cplusplus
99}
100#endif
101
102#endif	/* _SIP_DIALOG_H */
103