xref: /titanic_41/usr/src/lib/libsip/common/sip_parse_uri.h (revision 989f28072d20c73ae0955d6a1e3e2fc74831cb39)
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_PARSE_URI_H
28 #define	_SIP_PARSE_URI_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/types.h>
37 #include <sip.h>
38 
39 #define	SIP_URI_BUF_SIZE	128
40 
41 #define	SIP_SCHEME		"sip"
42 #define	SIPS_SCHEME		"sips"
43 
44 #define	SIP_SCHEME_LEN		3
45 #define	SIPS_SCHEME_LEN		4
46 
47 /*
48  * SIP-URI = "sip:" [ userinfo ] hostport
49  *           uri-parameters [ headers ]
50  * SIPS-URI =  "sips:" [ userinfo ] hostport
51  *           uri-parameters [ headers ]
52  * uri-parameters = *( ";" uri-parameter)
53  * uri-parameter = transport-param / user-param / method-param
54  *                 / ttl-param / maddr-param / lr-param / other-param
55  * transport-param   =  "transport="
56  *                      "udp" / "tcp" / "sctp" / "tls"/ other-transport)
57  * other-transport   =  token
58  * headers  =  "?" header *( "&" header )
59  */
60 typedef struct sip_uri_sip_s {
61 	sip_param_t 	*sip_params;
62 	sip_str_t 	sip_headers;
63 } sip_uri_sip_t;
64 
65 /*
66  * opaque	uri opaque part
67  * query	uri query
68  * path		uri path
69  * regname	uri reg-name
70  */
71 typedef struct sip_uri_abs_s {
72 	sip_str_t	sip_uri_opaque;
73 	sip_str_t 	sip_uri_query;
74 	sip_str_t 	sip_uri_path;
75 	sip_str_t 	sip_uri_regname;
76 } sip_uri_abs_t;
77 
78 /*
79  * structure for a parsed URI
80  *   sip_uri_scheme		URI scheme
81  *   sip_uri_user		user name
82  *   sip_uri_password		password for the user
83  *   sip_uri_host		host name
84  *   sip_uri_port		port number for the host (0 = none specified)
85  *   sip_uri_errflags		error flags
86  *   sip_uri_issip		is this a SIP  URI.
87  *   sip_uri_isteluser		user is a telephone-subscriber
88  */
89 typedef struct sip_uri {
90 	sip_str_t	sip_uri_scheme;
91 	sip_str_t 	sip_uri_user;
92 	sip_str_t	sip_uri_password;
93 	sip_str_t	sip_uri_host;
94 	uint_t		sip_uri_port;
95 	uint_t		sip_uri_errflags;
96 	boolean_t	sip_uri_issip;
97 	boolean_t	sip_uri_isteluser;
98 	union {
99 		sip_uri_sip_t	sip_sipuri;	/* SIP URI */
100 		sip_uri_abs_t	sip_absuri;	/* Absolute URI */
101 	} specific;
102 }_sip_uri_t;
103 
104 #define	sip_uri_params		specific.sip_sipuri.sip_params
105 #define	sip_uri_headers		specific.sip_sipuri.sip_headers
106 #define	sip_uri_opaque		specific.sip_absuri.sip_uri_opaque
107 #define	sip_uri_query		specific.sip_absuri.sip_uri_query
108 #define	sip_uri_path		specific.sip_absuri.sip_uri_path
109 #define	sip_uri_regname		specific.sip_absuri.sip_uri_regname
110 
111 extern void	sip_uri_parse_it(_sip_uri_t *, sip_str_t *);
112 
113 #ifdef	__cplusplus
114 }
115 #endif
116 
117 #endif	/* _SIP_PARSE_URI_H */
118