xref: /titanic_51/usr/src/lib/libsip/common/sip_msg.h (revision 2c2c41837e330b002c4220a39638150db504fe0e)
140cb5e5dSvi117747 /*
240cb5e5dSvi117747  * CDDL HEADER START
340cb5e5dSvi117747  *
440cb5e5dSvi117747  * The contents of this file are subject to the terms of the
540cb5e5dSvi117747  * Common Development and Distribution License (the "License").
640cb5e5dSvi117747  * You may not use this file except in compliance with the License.
740cb5e5dSvi117747  *
840cb5e5dSvi117747  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
940cb5e5dSvi117747  * or http://www.opensolaris.org/os/licensing.
1040cb5e5dSvi117747  * See the License for the specific language governing permissions
1140cb5e5dSvi117747  * and limitations under the License.
1240cb5e5dSvi117747  *
1340cb5e5dSvi117747  * When distributing Covered Code, include this CDDL HEADER in each
1440cb5e5dSvi117747  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1540cb5e5dSvi117747  * If applicable, add the following below this CDDL HEADER, with the
1640cb5e5dSvi117747  * fields enclosed by brackets "[]" replaced with your own identifying
1740cb5e5dSvi117747  * information: Portions Copyright [yyyy] [name of copyright owner]
1840cb5e5dSvi117747  *
1940cb5e5dSvi117747  * CDDL HEADER END
2040cb5e5dSvi117747  */
2140cb5e5dSvi117747 
2240cb5e5dSvi117747 /*
23*2c2c4183Svi117747  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
2440cb5e5dSvi117747  * Use is subject to license terms.
2540cb5e5dSvi117747  */
2640cb5e5dSvi117747 
2740cb5e5dSvi117747 #ifndef	_SIP_MSG_H
2840cb5e5dSvi117747 #define	_SIP_MSG_H
2940cb5e5dSvi117747 
3040cb5e5dSvi117747 #pragma ident	"%Z%%M%	%I%	%E% SMI"
3140cb5e5dSvi117747 
3240cb5e5dSvi117747 #ifdef	__cplusplus
3340cb5e5dSvi117747 extern "C" {
3440cb5e5dSvi117747 #endif
3540cb5e5dSvi117747 
36*2c2c4183Svi117747 #include <pthread.h>
3740cb5e5dSvi117747 #include <sip.h>
38*2c2c4183Svi117747 #include <sys/types.h>
3940cb5e5dSvi117747 
4040cb5e5dSvi117747 #ifdef	__solaris__
4140cb5e5dSvi117747 extern int mutex_held();
4240cb5e5dSvi117747 #endif
4340cb5e5dSvi117747 
4440cb5e5dSvi117747 extern sip_header_function_t *sip_header_function_table_external;
4540cb5e5dSvi117747 
4640cb5e5dSvi117747 /* Compare Cseq numbers */
4740cb5e5dSvi117747 #define	SIP_CSEQ_LT(a, b)	((int32_t)((a)-(b)) < 0)
4840cb5e5dSvi117747 #define	SIP_CSEQ_GT(a, b)	((int32_t)((a)-(b)) > 0)
4940cb5e5dSvi117747 #define	SIP_CSEQ_GEQ(a, b)	((int32_t)((a)-(b)) >= 0)
5040cb5e5dSvi117747 
5140cb5e5dSvi117747 #define	SIP_HEADER_ACTIVE	0x0
5240cb5e5dSvi117747 #define	SIP_HEADER_DELETED	0x1
5340cb5e5dSvi117747 #define	SIP_HEADER_DELETED_VAL	0x2
5440cb5e5dSvi117747 
5540cb5e5dSvi117747 /* List of registered sent-by values */
5640cb5e5dSvi117747 typedef struct sent_by_list_s {
5740cb5e5dSvi117747 	struct sent_by_list_s	*sb_next;
5840cb5e5dSvi117747 	struct sent_by_list_s	*sb_prev;
5940cb5e5dSvi117747 	char			*sb_val;
6040cb5e5dSvi117747 } sent_by_list_t;
6140cb5e5dSvi117747 
6240cb5e5dSvi117747 extern sent_by_list_t	*sip_sent_by;
6340cb5e5dSvi117747 extern int		sip_sent_by_count;
6440cb5e5dSvi117747 extern pthread_mutex_t	sip_sent_by_lock;
6540cb5e5dSvi117747 
6640cb5e5dSvi117747 typedef struct sip_header {
6740cb5e5dSvi117747 	sip_hdr_general_t	sip_hdr_general;
6840cb5e5dSvi117747 	/* active/deleted or has deleted val */
6940cb5e5dSvi117747 	int			sip_header_state;
7040cb5e5dSvi117747 	struct sip_header	*sip_hdr_next;
7140cb5e5dSvi117747 	struct sip_header	*sip_hdr_prev;
7240cb5e5dSvi117747 	struct sip_message	*sip_hdr_sipmsg;
7340cb5e5dSvi117747 	/* True if header was allocated */
7440cb5e5dSvi117747 	boolean_t		sip_hdr_allocated;
7540cb5e5dSvi117747 	sip_header_function_t	*sip_header_functions;
7640cb5e5dSvi117747 }_sip_header_t;
7740cb5e5dSvi117747 
7840cb5e5dSvi117747 /* Structure for the SIP message body */
7940cb5e5dSvi117747 typedef struct sip_content {
8040cb5e5dSvi117747 	char			*sip_content_start;
8140cb5e5dSvi117747 	char			*sip_content_end;
8240cb5e5dSvi117747 	char			*sip_content_current;
8340cb5e5dSvi117747 	struct sip_content	*sip_content_next;
8440cb5e5dSvi117747 	boolean_t		sip_content_allocated;
8540cb5e5dSvi117747 }sip_content_t;
8640cb5e5dSvi117747 
8740cb5e5dSvi117747 
8840cb5e5dSvi117747 /* General definitions */
8940cb5e5dSvi117747 
9040cb5e5dSvi117747 /* Two string values */
9140cb5e5dSvi117747 typedef struct sip_2strs {
9240cb5e5dSvi117747 	sip_str_t	s1;
9340cb5e5dSvi117747 	sip_str_t	s2;
9440cb5e5dSvi117747 }sip_2strs_t;
9540cb5e5dSvi117747 
9640cb5e5dSvi117747 /* An integer and a string value */
9740cb5e5dSvi117747 typedef struct sip_intstr {
9840cb5e5dSvi117747 	int		i;
9940cb5e5dSvi117747 	sip_str_t	s;
10040cb5e5dSvi117747 } sip_intstr_t;
10140cb5e5dSvi117747 
10240cb5e5dSvi117747 /* Warn value */
10340cb5e5dSvi117747 typedef struct sip_warn {
10440cb5e5dSvi117747 	int		code;
10540cb5e5dSvi117747 	sip_str_t	agt;
10640cb5e5dSvi117747 	sip_str_t	text;
10740cb5e5dSvi117747 } sip_warn_t;
10840cb5e5dSvi117747 
10940cb5e5dSvi117747 /* Date value */
11040cb5e5dSvi117747 typedef struct sip_date {
11140cb5e5dSvi117747 	sip_str_t	t;
11240cb5e5dSvi117747 	int		d;
11340cb5e5dSvi117747 	sip_str_t	m;
11440cb5e5dSvi117747 	int		y;
11540cb5e5dSvi117747 	sip_str_t	tz;
11640cb5e5dSvi117747 	sip_str_t	wd;
11740cb5e5dSvi117747 } sip_date_t;
11840cb5e5dSvi117747 
11940cb5e5dSvi117747 /* Authorization and authentication value */
12040cb5e5dSvi117747 typedef struct sip_auth {
12140cb5e5dSvi117747 	sip_str_t	scheme;
12240cb5e5dSvi117747 	sip_param_t	*param;
12340cb5e5dSvi117747 } sip_auth_t;
12440cb5e5dSvi117747 
12540cb5e5dSvi117747 /* RACK value */
12640cb5e5dSvi117747 typedef struct sip_rack {
12740cb5e5dSvi117747 	int		rack_resp_num;
12840cb5e5dSvi117747 	int		rack_cseq_num;
12940cb5e5dSvi117747 	sip_method_t	rack_method;
13040cb5e5dSvi117747 }sip_rack_t;
13140cb5e5dSvi117747 
13240cb5e5dSvi117747 /* Cseq value */
13340cb5e5dSvi117747 typedef struct sip_cseq {
13440cb5e5dSvi117747 	int		num;
13540cb5e5dSvi117747 	sip_method_t	method;
13640cb5e5dSvi117747 } sip_cseq_value_t;
13740cb5e5dSvi117747 
13840cb5e5dSvi117747 /* Value for Contact, From and To header */
13940cb5e5dSvi117747 typedef struct cftr_value {
14040cb5e5dSvi117747 	sip_str_t	*display_name;
14140cb5e5dSvi117747 	sip_str_t	uri;
14240cb5e5dSvi117747 } sip_cftr_value_t;
14340cb5e5dSvi117747 
14440cb5e5dSvi117747 /* SIP name/version/transport value in Via */
14540cb5e5dSvi117747 typedef struct sip_proto_version_s {
14640cb5e5dSvi117747 	sip_str_t	name;
14740cb5e5dSvi117747 	sip_str_t	version;
14840cb5e5dSvi117747 	sip_str_t	transport;
14940cb5e5dSvi117747 }sip_proto_version_t;
15040cb5e5dSvi117747 
15140cb5e5dSvi117747 /* Via value */
15240cb5e5dSvi117747 typedef struct via_value {
15340cb5e5dSvi117747 	sip_proto_version_t 	sent_protocol;
15440cb5e5dSvi117747 	sip_str_t		sent_by_host;
15540cb5e5dSvi117747 	int			sent_by_port;
15640cb5e5dSvi117747 }sip_via_value_t;
15740cb5e5dSvi117747 
15840cb5e5dSvi117747 typedef struct sip_hdr_value {
15940cb5e5dSvi117747 	sip_value_t	sip_value;
16040cb5e5dSvi117747 	union {
16140cb5e5dSvi117747 		int			i;
16240cb5e5dSvi117747 		sip_str_t		str;
16340cb5e5dSvi117747 		sip_2strs_t		strs;
16440cb5e5dSvi117747 		sip_intstr_t		intstr;
16540cb5e5dSvi117747 		sip_warn_t		warn;
16640cb5e5dSvi117747 		sip_date_t		date;
16740cb5e5dSvi117747 		sip_auth_t		auth;
16840cb5e5dSvi117747 		sip_rack_t		rack;
16940cb5e5dSvi117747 		sip_cseq_value_t	cseq;
17040cb5e5dSvi117747 		sip_cftr_value_t	cftr;
17140cb5e5dSvi117747 		sip_via_value_t		via;
17240cb5e5dSvi117747 	} hdr_value;
17340cb5e5dSvi117747 } sip_hdr_value_t;
17440cb5e5dSvi117747 
17540cb5e5dSvi117747 /*
17640cb5e5dSvi117747  * NOTE: ALL value structs MUST have sip_value_t as the first field.
17740cb5e5dSvi117747  */
17840cb5e5dSvi117747 #define	sip_value_version	sip_value.sip_value_version
17940cb5e5dSvi117747 #define	sip_next_value		sip_value.next
18040cb5e5dSvi117747 #define	sip_param_list		sip_value.param_list
18140cb5e5dSvi117747 #define	sip_value_state 	sip_value.value_state
18240cb5e5dSvi117747 #define	sip_value_header 	sip_value.parsed_header
18340cb5e5dSvi117747 #define	sip_value_start		sip_value.value_start
18440cb5e5dSvi117747 #define	sip_value_end		sip_value.value_end
18540cb5e5dSvi117747 #define	sip_value_parsed_uri 	sip_value.sip_value_parse_uri
18640cb5e5dSvi117747 
18740cb5e5dSvi117747 #define	auth_val		hdr_value.auth
18840cb5e5dSvi117747 #define	auth_scheme_ptr		hdr_value.auth.scheme.sip_str_ptr
18940cb5e5dSvi117747 #define	auth_scheme_len		hdr_value.auth.scheme.sip_str_len
19040cb5e5dSvi117747 #define	auth_param		hdr_value.auth.param
19140cb5e5dSvi117747 #define	int_val			hdr_value.i
19240cb5e5dSvi117747 #define	str_val			hdr_value.str
19340cb5e5dSvi117747 #define	str_val_ptr		hdr_value.str.sip_str_ptr
19440cb5e5dSvi117747 #define	str_val_len		hdr_value.str.sip_str_len
19540cb5e5dSvi117747 #define	strs_val		hdr_value.strs
19640cb5e5dSvi117747 #define	strs_s1			hdr_value.strs.s1
19740cb5e5dSvi117747 #define	strs_s2			hdr_value.strs.s2
19840cb5e5dSvi117747 #define	strs1_val_ptr		hdr_value.strs.s1.sip_str_ptr
19940cb5e5dSvi117747 #define	strs1_val_len		hdr_value.strs.s1.sip_str_len
20040cb5e5dSvi117747 #define	strs2_val_ptr		hdr_value.strs.s2.sip_str_ptr
20140cb5e5dSvi117747 #define	strs2_val_len		hdr_value.strs.s2.sip_str_len
20240cb5e5dSvi117747 #define	intstr_val		hdr_value.intstr
20340cb5e5dSvi117747 #define	intstr_int		hdr_value.intstr.i
20440cb5e5dSvi117747 #define	intstr_str		hdr_value.intstr.s
20540cb5e5dSvi117747 #define	intstr_str_ptr		hdr_value.intstr.s.sip_str_ptr
20640cb5e5dSvi117747 #define	intstr_str_len		hdr_value.intstr.s.sip_str_len
20740cb5e5dSvi117747 #define	warn_code		hdr_value.warn.code
20840cb5e5dSvi117747 #define	warn_agt		hdr_value.warn.agt
20940cb5e5dSvi117747 #define	warn_text		hdr_value.warn.text
21040cb5e5dSvi117747 #define	warn_agt_ptr		warn_agt.sip_str_ptr
21140cb5e5dSvi117747 #define	warn_agt_len		warn_agt.sip_str_len
21240cb5e5dSvi117747 #define	warn_text_ptr		warn_text.sip_str_ptr
21340cb5e5dSvi117747 #define	warn_text_len		warn_text.sip_str_len
21440cb5e5dSvi117747 #define	date_t			hdr_value.date.t
21540cb5e5dSvi117747 #define	date_d			hdr_value.date.d
21640cb5e5dSvi117747 #define	date_m			hdr_value.date.m
21740cb5e5dSvi117747 #define	date_y			hdr_value.date.y
21840cb5e5dSvi117747 #define	date_tz			hdr_value.date.tz
21940cb5e5dSvi117747 #define	date_wd			hdr_value.date.wd
22040cb5e5dSvi117747 #define	date_t_ptr		date_t.sip_str_ptr
22140cb5e5dSvi117747 #define	date_t_len		date_t.sip_str_len
22240cb5e5dSvi117747 #define	date_m_ptr		date_m.sip_str_ptr
22340cb5e5dSvi117747 #define	date_m_len		date_m.sip_str_len
22440cb5e5dSvi117747 #define	date_tz_ptr		date_tz.sip_str_ptr
22540cb5e5dSvi117747 #define	date_tz_len		date_tz.sip_str_len
22640cb5e5dSvi117747 #define	date_wd_ptr		date_wd.sip_str_ptr
22740cb5e5dSvi117747 #define	date_wd_len		date_wd.sip_str_len
22840cb5e5dSvi117747 #define	rack_resp		hdr_value.rack.rack_resp_num
22940cb5e5dSvi117747 #define	rack_cseq		hdr_value.rack.rack_cseq_num
23040cb5e5dSvi117747 #define	rack_method		hdr_value.rack.rack_method
23140cb5e5dSvi117747 #define	cftr_name		hdr_value.cftr.display_name
23240cb5e5dSvi117747 #define	cftr_uri		hdr_value.cftr.uri
23340cb5e5dSvi117747 #define	cseq_num		hdr_value.cseq.num
23440cb5e5dSvi117747 #define	cseq_method		hdr_value.cseq.method
23540cb5e5dSvi117747 #define	via_protocol		hdr_value.via.sent_protocol
23640cb5e5dSvi117747 #define	via_protocol_name	hdr_value.via.sent_protocol.name
23740cb5e5dSvi117747 #define	via_protocol_vers	hdr_value.via.sent_protocol.version
23840cb5e5dSvi117747 #define	via_protocol_transport	hdr_value.via.sent_protocol.transport
23940cb5e5dSvi117747 #define	via_sent_by_host	hdr_value.via.sent_by_host
24040cb5e5dSvi117747 #define	via_sent_by_port	hdr_value.via.sent_by_port
24140cb5e5dSvi117747 
24240cb5e5dSvi117747 #define	SIP_INT_VAL		0x01
24340cb5e5dSvi117747 #define	SIP_STR_VAL		0x02
24440cb5e5dSvi117747 #define	SIP_STRS_VAL		0x03
24540cb5e5dSvi117747 #define	SIP_INTSTR_VAL		0x04
24640cb5e5dSvi117747 #define	SIP_AUTH_VAL		0x05
24740cb5e5dSvi117747 
24840cb5e5dSvi117747 /* hdr value contains two string */
24940cb5e5dSvi117747 typedef sip_hdr_value_t sip_acpt_value_t;
25040cb5e5dSvi117747 typedef sip_hdr_value_t sip_content_type_value_t;
25140cb5e5dSvi117747 
25240cb5e5dSvi117747 /* hdr value contains one string only */
25340cb5e5dSvi117747 typedef sip_hdr_value_t sip_acpt_lang_value_t;
25440cb5e5dSvi117747 typedef sip_hdr_value_t sip_acpt_encode_value_t;
25540cb5e5dSvi117747 typedef sip_hdr_value_t sip_alert_value_t;
25640cb5e5dSvi117747 typedef sip_hdr_value_t sip_cl_info_value_t;
25740cb5e5dSvi117747 typedef sip_hdr_value_t sip_ct_disp_value_t;
25840cb5e5dSvi117747 typedef sip_hdr_value_t sip_ct_encode_value_t;
25940cb5e5dSvi117747 typedef sip_hdr_value_t sip_ct_lang_value_t;
26040cb5e5dSvi117747 typedef sip_hdr_value_t sip_irt_value_t;
26140cb5e5dSvi117747 typedef sip_hdr_value_t sip_mime_ver_value_t;
26240cb5e5dSvi117747 typedef sip_hdr_value_t sip_org_value_t;
26340cb5e5dSvi117747 typedef sip_hdr_value_t sip_prio_value_t;
26440cb5e5dSvi117747 typedef sip_hdr_value_t sip_reply_value_t;
26540cb5e5dSvi117747 typedef sip_hdr_value_t sip_privacy_value_t;
26640cb5e5dSvi117747 typedef sip_hdr_value_t sip_ppassertedid_value_t;
26740cb5e5dSvi117747 typedef sip_hdr_value_t sip_ppreferredid_value_t;
26840cb5e5dSvi117747 typedef sip_hdr_value_t sip_pxy_req_value_t;
26940cb5e5dSvi117747 typedef sip_hdr_value_t sip_req_value_t;
27040cb5e5dSvi117747 typedef sip_hdr_value_t sip_subject_value_t;
27140cb5e5dSvi117747 typedef sip_hdr_value_t sip_svr_value_t;
27240cb5e5dSvi117747 typedef sip_hdr_value_t sip_support_value_t;
27340cb5e5dSvi117747 typedef sip_hdr_value_t sip_unsupport_value_t;
27440cb5e5dSvi117747 typedef sip_hdr_value_t sip_usr_agt_value_t;
27540cb5e5dSvi117747 typedef sip_hdr_value_t sip_err_info_value_t;
27640cb5e5dSvi117747 typedef sip_hdr_value_t sip_date_value_t;
27740cb5e5dSvi117747 typedef sip_hdr_value_t sip_allert_value_t;
27840cb5e5dSvi117747 typedef sip_hdr_value_t	sip_callid_value_t;
27940cb5e5dSvi117747 
28040cb5e5dSvi117747 /* hdr value contain one int only */
28140cb5e5dSvi117747 typedef sip_hdr_value_t sip_expr_value_t;
28240cb5e5dSvi117747 typedef sip_hdr_value_t sip_min_expr_value_t;
28340cb5e5dSvi117747 typedef sip_hdr_value_t sip_retry_value_t;
28440cb5e5dSvi117747 typedef sip_hdr_value_t sip_timestamp_value_t;
28540cb5e5dSvi117747 typedef sip_hdr_value_t sip_rseq_value_t;
28640cb5e5dSvi117747 typedef sip_hdr_value_t sip_content_len_value_t;
28740cb5e5dSvi117747 typedef sip_hdr_value_t sip_max_forwards_value_t;
28840cb5e5dSvi117747 typedef sip_hdr_value_t sip_allow_value_t;
28940cb5e5dSvi117747 
29040cb5e5dSvi117747 /* hdr value contain one int, two strings */
29140cb5e5dSvi117747 typedef sip_hdr_value_t sip_warn_value_t;
29240cb5e5dSvi117747 
29340cb5e5dSvi117747 /* hdr field value is a list of param=param_val */
29440cb5e5dSvi117747 typedef sip_hdr_value_t	sip_authen_value_t;
29540cb5e5dSvi117747 typedef sip_hdr_value_t	sip_authen_info_value_t;
29640cb5e5dSvi117747 typedef sip_hdr_value_t	sip_pxy_authen_value_t;
29740cb5e5dSvi117747 typedef sip_hdr_value_t	sip_pxy_author_value_t;
29840cb5e5dSvi117747 typedef sip_hdr_value_t	sip_3w_authen_value_t;
29940cb5e5dSvi117747 
30040cb5e5dSvi117747 /* SIP request line structure */
30140cb5e5dSvi117747 typedef struct sip_request {
30240cb5e5dSvi117747 	sip_method_t	sip_request_method;
30340cb5e5dSvi117747 	sip_str_t	sip_request_uri;
30440cb5e5dSvi117747 	sip_uri_t	sip_parse_uri;
30540cb5e5dSvi117747 } sip_request_t;
30640cb5e5dSvi117747 
30740cb5e5dSvi117747 /* SIP response line structure */
30840cb5e5dSvi117747 typedef struct sip_response {
30940cb5e5dSvi117747 	int		sip_response_code;
31040cb5e5dSvi117747 	sip_str_t	sip_response_phrase;
31140cb5e5dSvi117747 } sip_response_t;
31240cb5e5dSvi117747 
31340cb5e5dSvi117747 /* SIP message type - request or response */
31440cb5e5dSvi117747 typedef struct sip_message_type {
31540cb5e5dSvi117747 	boolean_t		is_request;
31640cb5e5dSvi117747 	sip_proto_version_t	sip_proto_version;
31740cb5e5dSvi117747 	union {
31840cb5e5dSvi117747 	sip_request_t		sip_request;
31940cb5e5dSvi117747 	sip_response_t		sip_response;
32040cb5e5dSvi117747 	} U;
32140cb5e5dSvi117747 	/* This is to save old value when we use a recvd message. */
32240cb5e5dSvi117747 	struct sip_message_type	*sip_next;
32340cb5e5dSvi117747 } sip_message_type_t;
32440cb5e5dSvi117747 
32540cb5e5dSvi117747 /* Increment reference count on SIP message */
32640cb5e5dSvi117747 #define	SIP_MSG_REFCNT_INCR(sip_msg) {				\
32740cb5e5dSvi117747 	(void) pthread_mutex_lock(&(sip_msg)->sip_msg_mutex);	\
32840cb5e5dSvi117747 	(sip_msg)->sip_msg_ref_cnt++;				\
32940cb5e5dSvi117747 	(void) pthread_mutex_unlock(&(sip_msg)->sip_msg_mutex);	\
33040cb5e5dSvi117747 }
33140cb5e5dSvi117747 
33240cb5e5dSvi117747 /* Decrement reference count on SIP message */
33340cb5e5dSvi117747 #define	SIP_MSG_REFCNT_DECR(sip_msg) {					\
33440cb5e5dSvi117747 	(void) pthread_mutex_lock(&(sip_msg)->sip_msg_mutex);		\
33540cb5e5dSvi117747 	assert((sip_msg)->sip_msg_ref_cnt > 0);				\
33640cb5e5dSvi117747 	if (--(sip_msg)->sip_msg_ref_cnt == 0) {			\
33740cb5e5dSvi117747 		sip_destroy_msg(sip_msg);				\
33840cb5e5dSvi117747 	} else {							\
33940cb5e5dSvi117747 		(void) pthread_mutex_unlock(&(sip_msg)->sip_msg_mutex);	\
34040cb5e5dSvi117747 	}								\
34140cb5e5dSvi117747 }
34240cb5e5dSvi117747 
34340cb5e5dSvi117747 /* SIP message structure */
34440cb5e5dSvi117747 typedef struct sip_message {
34540cb5e5dSvi117747 	char			*sip_msg_buf;	/* Message */
34640cb5e5dSvi117747 	char			*sip_msg_old_buf;
34740cb5e5dSvi117747 	boolean_t		sip_msg_modified;
34840cb5e5dSvi117747 	boolean_t		sip_msg_cannot_be_modified;
34940cb5e5dSvi117747 	int			sip_msg_len;
35040cb5e5dSvi117747 	size_t			sip_msg_content_len;	/* content length */
35140cb5e5dSvi117747 	sip_content_t		*sip_msg_content;
35240cb5e5dSvi117747 	/* All fields synchronizes on this */
35340cb5e5dSvi117747 	pthread_mutex_t		sip_msg_mutex;
35440cb5e5dSvi117747 	/* doubly linked list of headers */
35540cb5e5dSvi117747 	_sip_header_t		*sip_msg_headers_start;
35640cb5e5dSvi117747 	_sip_header_t		*sip_msg_headers_end;
35740cb5e5dSvi117747 	_sip_header_t		*sip_msg_start_line;
35840cb5e5dSvi117747 	sip_message_type_t	*sip_msg_req_res;
35940cb5e5dSvi117747 	int			sip_msg_ref_cnt;
36040cb5e5dSvi117747 }_sip_msg_t;
36140cb5e5dSvi117747 
36240cb5e5dSvi117747 extern char		*sip_get_tcp_msg(sip_conn_object_t, char *, size_t *);
36340cb5e5dSvi117747 extern char		*sip_msg_to_msgbuf(_sip_msg_t *msg, int *error);
36440cb5e5dSvi117747 extern char		*_sip_startline_to_str(_sip_msg_t *sip_msg, int *error);
36540cb5e5dSvi117747 extern int		sip_adjust_msgbuf(_sip_msg_t *msg);
36640cb5e5dSvi117747 extern void		sip_delete_all_headers(_sip_msg_t *sip_msg);
36740cb5e5dSvi117747 extern _sip_header_t	*sip_dup_header(_sip_header_t *from);
36840cb5e5dSvi117747 extern int		_sip_copy_header(_sip_msg_t *, _sip_header_t *, char *,
36940cb5e5dSvi117747 			    boolean_t);
37040cb5e5dSvi117747 extern int		_sip_find_and_copy_header(_sip_msg_t *, _sip_msg_t *,
37140cb5e5dSvi117747 			    char *, char *, boolean_t);
37240cb5e5dSvi117747 extern int		_sip_find_and_copy_all_header(_sip_msg_t *,
37340cb5e5dSvi117747 			    _sip_msg_t *, char *header_name);
37440cb5e5dSvi117747 extern _sip_header_t	*sip_search_for_header(_sip_msg_t *, char *,
37540cb5e5dSvi117747 			    _sip_header_t *);
37640cb5e5dSvi117747 extern void		_sip_add_header(_sip_msg_t *, _sip_header_t *,
37740cb5e5dSvi117747 			    boolean_t, boolean_t, char *);
37840cb5e5dSvi117747 extern _sip_header_t	*sip_new_header(int);
37940cb5e5dSvi117747 extern int		sip_create_nonOKack(sip_msg_t, sip_msg_t, sip_msg_t);
38040cb5e5dSvi117747 extern void		sip_destroy_msg(_sip_msg_t *);
38140cb5e5dSvi117747 extern void		sip_free_header(_sip_header_t *sip_header);
38240cb5e5dSvi117747 extern void		sip_free_phdr(sip_parsed_header_t *);
38340cb5e5dSvi117747 extern void		sip_free_cftr_header(sip_parsed_header_t *);
38440cb5e5dSvi117747 
38540cb5e5dSvi117747 extern int		sip_parse_allow_events_header(_sip_header_t *,
38640cb5e5dSvi117747 			    sip_parsed_header_t **);
38740cb5e5dSvi117747 extern int		sip_parse_event_header(_sip_header_t *,
38840cb5e5dSvi117747 			    sip_parsed_header_t **);
38940cb5e5dSvi117747 extern int		sip_parse_substate_header(_sip_header_t *,
39040cb5e5dSvi117747 			    sip_parsed_header_t **);
39140cb5e5dSvi117747 extern int		sip_parse_acpt_header(_sip_header_t *,
39240cb5e5dSvi117747 			    sip_parsed_header_t **);
39340cb5e5dSvi117747 extern int		sip_parse_acpt_encode_header(_sip_header_t *,
39440cb5e5dSvi117747 			    sip_parsed_header_t **);
39540cb5e5dSvi117747 extern int		sip_parse_acpt_lang_header(_sip_header_t *,
39640cb5e5dSvi117747 			    sip_parsed_header_t **);
39740cb5e5dSvi117747 extern int		sip_parse_alert_header(_sip_header_t *,
39840cb5e5dSvi117747 			    sip_parsed_header_t **);
39940cb5e5dSvi117747 extern int		sip_parse_allow_header(_sip_header_t *,
40040cb5e5dSvi117747 			    sip_parsed_header_t **);
40140cb5e5dSvi117747 extern int		sip_parse_useragt_header(_sip_header_t *,
40240cb5e5dSvi117747 			    sip_parsed_header_t **);
40340cb5e5dSvi117747 extern int		sip_parse_usupport_header(_sip_header_t *,
40440cb5e5dSvi117747 			    sip_parsed_header_t **);
40540cb5e5dSvi117747 extern int		sip_parse_timestamp_header(_sip_header_t *,
40640cb5e5dSvi117747 			    sip_parsed_header_t **);
40740cb5e5dSvi117747 extern int		sip_parse_support_header(_sip_header_t *,
40840cb5e5dSvi117747 			    sip_parsed_header_t **);
40940cb5e5dSvi117747 extern int		sip_parse_subject_header(_sip_header_t *,
41040cb5e5dSvi117747 			    sip_parsed_header_t **);
41140cb5e5dSvi117747 extern int		sip_parse_server_header(_sip_header_t *,
41240cb5e5dSvi117747 			    sip_parsed_header_t **);
41340cb5e5dSvi117747 extern int		sip_parse_retryaft_header(_sip_header_t *,
41440cb5e5dSvi117747 			    sip_parsed_header_t **);
41540cb5e5dSvi117747 extern int		sip_parse_require_header(_sip_header_t *,
41640cb5e5dSvi117747 			    sip_parsed_header_t **);
41740cb5e5dSvi117747 extern int		sip_parse_replyto_header(_sip_header_t *,
41840cb5e5dSvi117747 			    sip_parsed_header_t **);
41940cb5e5dSvi117747 extern int		sip_parse_passertedid_header(_sip_header_t *,
42040cb5e5dSvi117747 			    sip_parsed_header_t **);
42140cb5e5dSvi117747 extern int		sip_parse_ppreferredid_header(_sip_header_t *,
42240cb5e5dSvi117747 			    sip_parsed_header_t **);
42340cb5e5dSvi117747 extern int		sip_parse_priority_header(_sip_header_t *,
42440cb5e5dSvi117747 			    sip_parsed_header_t **);
42540cb5e5dSvi117747 extern int		sip_parse_org_header(_sip_header_t *,
42640cb5e5dSvi117747 			    sip_parsed_header_t **);
42740cb5e5dSvi117747 extern int		sip_parse_mimeversion_header(_sip_header_t *,
42840cb5e5dSvi117747 			    sip_parsed_header_t **);
42940cb5e5dSvi117747 extern int		sip_parse_minexpire_header(_sip_header_t *,
43040cb5e5dSvi117747 			    sip_parsed_header_t **);
43140cb5e5dSvi117747 extern int		sip_parse_rseq_header(_sip_header_t *,
43240cb5e5dSvi117747 			    sip_parsed_header_t **);
43340cb5e5dSvi117747 extern int		sip_parse_inreplyto_header(_sip_header_t *,
43440cb5e5dSvi117747 			    sip_parsed_header_t **);
43540cb5e5dSvi117747 extern int		sip_parse_privacy_header(_sip_header_t *,
43640cb5e5dSvi117747 			    sip_parsed_header_t **);
43740cb5e5dSvi117747 extern int		sip_parse_expire_header(_sip_header_t *,
43840cb5e5dSvi117747 			    sip_parsed_header_t **);
43940cb5e5dSvi117747 extern int		sip_parse_errorinfo_header(_sip_header_t *,
44040cb5e5dSvi117747 			    sip_parsed_header_t **);
44140cb5e5dSvi117747 extern int		sip_parse_contentlang_header(_sip_header_t *,
44240cb5e5dSvi117747 			    sip_parsed_header_t **);
44340cb5e5dSvi117747 extern int		sip_parse_contentencode_header(_sip_header_t *,
44440cb5e5dSvi117747 			    sip_parsed_header_t **);
44540cb5e5dSvi117747 extern int		sip_parse_contentdis_header(_sip_header_t *,
44640cb5e5dSvi117747 			    sip_parsed_header_t **);
44740cb5e5dSvi117747 extern int		sip_parse_callinfo_header(_sip_header_t *,
44840cb5e5dSvi117747 			    sip_parsed_header_t **);
44940cb5e5dSvi117747 extern int		sip_parse_date_header(_sip_header_t *,
45040cb5e5dSvi117747 			    sip_parsed_header_t **);
45140cb5e5dSvi117747 extern int		sip_parse_warn_header(_sip_header_t *,
45240cb5e5dSvi117747 			    sip_parsed_header_t **);
45340cb5e5dSvi117747 extern int		sip_parse_cftr_header(_sip_header_t *,
45440cb5e5dSvi117747 			    sip_parsed_header_t **);
45540cb5e5dSvi117747 extern int		sip_parse_cseq_header(_sip_header_t *,
45640cb5e5dSvi117747 			    sip_parsed_header_t **);
45740cb5e5dSvi117747 extern int		sip_parse_cid_header(_sip_header_t *,
45840cb5e5dSvi117747 			    sip_parsed_header_t **);
45940cb5e5dSvi117747 extern int		sip_parse_via_header(_sip_header_t *,
46040cb5e5dSvi117747 			    sip_parsed_header_t **);
46140cb5e5dSvi117747 extern int		sip_parse_clen_header(_sip_header_t *,
46240cb5e5dSvi117747 			    sip_parsed_header_t **);
46340cb5e5dSvi117747 extern int		sip_parse_maxf_header(_sip_header_t *,
46440cb5e5dSvi117747 			    sip_parsed_header_t **);
46540cb5e5dSvi117747 extern int		sip_parse_ctype_header(_sip_header_t *,
46640cb5e5dSvi117747 			    sip_parsed_header_t **);
46740cb5e5dSvi117747 extern int		sip_parse_unknown_header(_sip_header_t *,
46840cb5e5dSvi117747 			    sip_parsed_header_t **);
46940cb5e5dSvi117747 extern int		sip_parse_ainfo_header(_sip_header_t *,
47040cb5e5dSvi117747 			    sip_parsed_header_t **);
47140cb5e5dSvi117747 extern int		sip_parse_preq_header(_sip_header_t *,
47240cb5e5dSvi117747 			    sip_parsed_header_t **);
47340cb5e5dSvi117747 extern int		sip_parse_author_header(_sip_header_t *,
47440cb5e5dSvi117747 			    sip_parsed_header_t **);
47540cb5e5dSvi117747 extern int		sip_parse_pauthor_header(_sip_header_t *,
47640cb5e5dSvi117747 			    sip_parsed_header_t **);
47740cb5e5dSvi117747 extern int		sip_parse_pauthen_header(_sip_header_t *,
47840cb5e5dSvi117747 			    sip_parsed_header_t **);
47940cb5e5dSvi117747 extern int		sip_parse_wauthen_header(_sip_header_t *,
48040cb5e5dSvi117747 			    sip_parsed_header_t **);
48140cb5e5dSvi117747 extern int		sip_parse_rseq(_sip_header_t *, sip_parsed_header_t **);
48240cb5e5dSvi117747 extern int		sip_parse_rack(_sip_header_t *, sip_parsed_header_t **);
48340cb5e5dSvi117747 extern int		sip_parse_passertedid(_sip_header_t *,
48440cb5e5dSvi117747 			    sip_parsed_header_t **);
48540cb5e5dSvi117747 extern int		sip_parse_ppreferredid(_sip_header_t *,
48640cb5e5dSvi117747 			    sip_parsed_header_t **);
48740cb5e5dSvi117747 extern int		sip_parse_privacy_header(_sip_header_t *,
48840cb5e5dSvi117747 			    sip_parsed_header_t **);
48940cb5e5dSvi117747 
49040cb5e5dSvi117747 extern sip_param_t	*sip_get_param_from_list(sip_param_t *, char *);
49140cb5e5dSvi117747 extern int		sip_copy_values(char *, _sip_header_t *);
49240cb5e5dSvi117747 extern int		sip_add_content_length(_sip_msg_t *, int);
49340cb5e5dSvi117747 extern int		sip_delete_start_line_locked(_sip_msg_t *);
49440cb5e5dSvi117747 
49540cb5e5dSvi117747 /* Useful access macros */
49640cb5e5dSvi117747 #define	sip_resp_phrase_len	U.sip_response.sip_response_phrase.sip_str_len
49740cb5e5dSvi117747 #define	sip_resp_phrase_ptr	U.sip_response.sip_response_phrase.sip_str_ptr
49840cb5e5dSvi117747 
49940cb5e5dSvi117747 #define	sip_resp_code		U.sip_response.sip_response_code
50040cb5e5dSvi117747 #define	sip_resp_phrase		U.sip_response.sip_response_phrase
50140cb5e5dSvi117747 
50240cb5e5dSvi117747 #define	sip_req_method		U.sip_request.sip_request_method
50340cb5e5dSvi117747 #define	sip_req_uri		U.sip_request.sip_request_uri
50440cb5e5dSvi117747 #define	sip_req_uri_ptr		U.sip_request.sip_request_uri.sip_str_ptr
50540cb5e5dSvi117747 #define	sip_req_uri_len		U.sip_request.sip_request_uri.sip_str_ptr
50640cb5e5dSvi117747 #define	sip_req_parse_uri	U.sip_request.sip_parse_uri
50740cb5e5dSvi117747 
50840cb5e5dSvi117747 #define	sip_header_parse	sip_header_functions->header_parse_func
50940cb5e5dSvi117747 #define	sip_header_name		sip_header_functions->header_name
51040cb5e5dSvi117747 
51140cb5e5dSvi117747 #define	sip_hdr_start		sip_hdr_general.sip_hdr_start
51240cb5e5dSvi117747 #define	sip_hdr_end		sip_hdr_general.sip_hdr_end
51340cb5e5dSvi117747 #define	sip_hdr_current		sip_hdr_general.sip_hdr_current
51440cb5e5dSvi117747 #define	sip_hdr_parsed		sip_hdr_general.sip_hdr_parsed
51540cb5e5dSvi117747 
51640cb5e5dSvi117747 #ifdef	__cplusplus
51740cb5e5dSvi117747 }
51840cb5e5dSvi117747 #endif
51940cb5e5dSvi117747 
52040cb5e5dSvi117747 #endif	/* _SIP_MSG_H */
521