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