xref: /titanic_51/usr/src/lib/libsip/common/sip.h (revision 2401904da3a3a741ce3aa7e27493641b2257523f)
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_H
28 #define	_SIP_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #define	_XPG4_2
37 #define	__EXTENSIONS__
38 
39 #ifndef	DEBUG
40 #define	NDEBUG	1
41 #endif
42 
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <ctype.h>
46 #include <string.h>
47 #include <strings.h>
48 #include <assert.h>
49 #include <sys/types.h>
50 #include <sys/socket.h>
51 #include <netinet/in.h>
52 #include <arpa/inet.h>
53 #include <pthread.h>
54 #include <errno.h>
55 #include <unistd.h>
56 #include <signal.h>
57 
58 /* Send a SIP message statefully */
59 #define	SIP_SEND_STATEFUL	0x0001
60 
61 /* Enable multiple dialogs if a request is forked */
62 #define	SIP_DIALOG_ON_FORK	0x0010
63 
64 #define	SIP_CRLF 		"\r\n"
65 #define	SKIP_CRLF(msg_ptr)	(msg_ptr = msg_ptr + 2)
66 #define	SIP_VERSION		"SIP/2.0"
67 #define	SIP			"SIP"
68 
69 /* SIP headers */
70 #define	SIP_TO				"TO"
71 #define	SIP_FROM			"FROM"
72 #define	SIP_TAG				"TAG="
73 #define	SIP_CONTENT_LENGTH		"CONTENT-LENGTH"
74 #define	SIP_CONTENT_TYPE		"CONTENT-TYPE"
75 #define	SIP_CALL_ID			"CALL-ID"
76 #define	SIP_CSEQ			"CSEQ"
77 #define	SIP_MAX_FORWARDS		"MAX-FORWARDS"
78 #define	SIP_CONTACT			"CONTACT"
79 #define	SIP_VIA				"Via"
80 #define	SIP_RECORD_ROUTE		"RECORD-ROUTE"
81 #define	SIP_ROUTE			"ROUTE"
82 #define	SIP_ACCEPT			"ACCEPT"
83 #define	SIP_ACCEPT_ENCODE		"ACCEPT-ENCODING"
84 #define	SIP_ACCEPT_LANG			"ACCEPT-LANGUAGE"
85 #define	SIP_ALERT_INFO			"ALERT-INFO"
86 #define	SIP_ALLOW			"ALLOW"
87 #define	SIP_CALL_INFO			"CALL-INFO"
88 #define	SIP_CONTENT_DIS			"CONTENT-DISPOSITION"
89 #define	SIP_CONTENT_ENCODE		"CONTENT-ENCODING"
90 #define	SIP_CONTENT_LANG		"CONTENT-LANGUAGE"
91 #define	SIP_DATE			"DATE"
92 #define	SIP_ERROR_INFO			"ERROR-INFO"
93 #define	SIP_EXPIRE			"EXPIRES"
94 #define	SIP_IN_REPLY_TO			"IN-REPLY-TO"
95 #define	SIP_MIN_EXPIRE			"MIN-EXPIRES"
96 #define	SIP_MIME_VERSION		"MIME-VERSION"
97 #define	SIP_ORGANIZATION		"ORGANIZATION"
98 #define	SIP_PRIORITY			"PRIORITY"
99 #define	SIP_REQUIRE			"REQUIRE"
100 #define	SIP_REPLYTO			"REPLY-TO"
101 #define	SIP_RETRY_AFTER			"RETRY-AFTER"
102 #define	SIP_SERVER			"SERVER"
103 #define	SIP_SUBJECT			"SUBJECT"
104 #define	SIP_SUPPORT			"SUPPORTED"
105 #define	SIP_TIMESTAMP			"TIMESTAMP"
106 #define	SIP_UNSUPPORT			"UNSUPPORTED"
107 #define	SIP_USER_AGENT			"USER-AGENT"
108 #define	SIP_WARNING			"WARNING"
109 #define	SIP_ALLOW_EVENTS		"ALLOW-EVENTS"
110 #define	SIP_EVENT			"EVENT"
111 #define	SIP_SUBSCRIPTION_STATE		"SUBSCRIPTION-STATE"
112 #define	SIP_WWW_AUTHEN			"WWW-AUTHENTICATE"
113 #define	SIP_AUTHOR			"AUTHORIZATION"
114 #define	SIP_AUTHEN_INFO			"AUTHENTICATION-INFO"
115 #define	SIP_PROXY_AUTHOR		"PROXY-AUTHORIZATION"
116 #define	SIP_PROXY_AUTHEN		"PROXY-AUTHENTICATE"
117 #define	SIP_PROXY_REQ			"PROXY-REQUIRE"
118 #define	SIP_PASSERTEDID			"P-ASSERTED-IDENTITY"
119 #define	SIP_PPREFERREDID		"P-PREFERRED-IDENTITY"
120 #define	SIP_PRIVACY			"PRIVACY"
121 #define	SIP_RACK			"RACK"
122 #define	SIP_RSEQ			"RSEQ"
123 
124 /* SIP Response Codes */
125 
126 /* 1XX - Provisional */
127 #define	SIP_TRYING			100
128 #define	SIP_RINGING			180
129 #define	SIP_CALL_IS_BEING_FORWARDED 	181
130 #define	SIP_QUEUED			182
131 #define	SIP_SESSION_PROGRESS		183
132 
133 /* 2XX - Success */
134 #define	SIP_OK				200
135 #define	SIP_ACCEPTED			202
136 
137 /* 3XX - Redirection */
138 #define	SIP_MULTIPLE_CHOICES		300
139 #define	SIP_MOVED_PERMANENTLY		301
140 #define	SIP_MOVED_TEMPORARILY		302
141 #define	SIP_USE_PROXY			303
142 #define	SIP_ALTERNATIVE_SERVICE		304
143 
144 /* 4XX - Request Failed */
145 #define	SIP_BAD_REQUEST			400
146 #define	SIP_UNAUTHORIZED		401
147 #define	SIP_PAYMENT_REQUIRED		402
148 #define	SIP_FORBIDDEN			403
149 #define	SIP_NOT_FOUND			404
150 #define	SIP_METHOD_NOT_ALLOWED		405
151 #define	SIP_NOT_ACCEPTABLE		406
152 #define	SIP_PROXY_AUTH_REQUIRED		407
153 #define	SIP_REQUEST_TIMEOUT		408
154 #define	SIP_GONE			410
155 #define	SIP_REQUEST_ENTITY_2_LARGE	413
156 #define	SIP_REQUEST_URI_2_LONG		414
157 #define	SIP_UNSUPPORTED_MEDIA_TYPE	415
158 #define	SIP_UNSUPPORTED_URI_SCHEME	416
159 #define	SIP_BAD_EXTENSION		420
160 #define	SIP_EXTENSION_REQUIRED		421
161 #define	SIP_INTERVAL_2_BRIEF		423
162 #define	SIP_TEMPORARILY_UNAVAIL		480
163 #define	SIP_CALL_NON_EXISTANT		481
164 #define	SIP_LOOP_DETECTED		482
165 #define	SIP_TOO_MANY_HOOPS		483
166 #define	SIP_ADDRESS_INCOMPLETE		484
167 #define	SIP_AMBIGUOUS			485
168 #define	SIP_BUSY_HERE			486
169 #define	SIP_REQUEST_TERMINATED		487
170 #define	SIP_NOT_ACCEPTABLE_HERE		488
171 #define	SIP_BAD_EVENT			489
172 #define	SIP_REQUEST_PENDING		491
173 #define	SIP_UNDECIPHERABLE		493
174 
175 /* 5XX - Server Failure */
176 #define	SIP_SERVER_INTERNAL_ERROR	500
177 #define	SIP_NOT_IMPLEMENTED		501
178 #define	SIP_BAD_GATEWAY			502
179 #define	SIP_SERVICE_UNAVAILABLE		503
180 #define	SIP_SERVER_TIMEOUT		504
181 #define	SIP_VERSION_NOT_SUPPORTED	505
182 #define	SIP_MESSAGE_2_LARGE		513
183 
184 /* 6XX - Global Failures */
185 #define	SIP_BUSY_EVERYWHERE		600
186 #define	SIP_DECLINE			601
187 #define	SIP_DOES_NOT_EXIST_ANYWHERE 	604
188 #define	SIP_NOT_ACCEPTABLE_ANYWHERE	606
189 
190 /* Response error types */
191 #define	SIP_PROVISIONAL_RESP(resp)	((resp) >= 100 && (resp) < 200)
192 #define	SIP_FINAL_RESP(resp)		((resp) >= 200 && (resp) < 700)
193 #define	SIP_OK_RESP(resp)		((resp) >= 200 && (resp) < 300)
194 #define	SIP_NONOK_FINAL_RESP(resp)	((resp) >= 300 && (resp) < 700)
195 #define	SIP_REDIRECT_RESP(resp)		((resp) >= 300 && (resp) < 400)
196 #define	SIP_REQFAIL_RESP(resp)		((resp) >= 400 && (resp) < 500)
197 #define	SIP_SRVFAIL_RESP(resp)		((resp) >= 500 && (resp) < 600)
198 #define	SIP_GLOBFAIL_RESP(resp)		((resp) >= 600 && (resp) < 700)
199 
200 /* Types of transactions */
201 #define	SIP_CLIENT_TRANSACTION		1
202 #define	SIP_SERVER_TRANSACTION		2
203 
204 /* Transaction states */
205 #define	SIP_NEW_TRANSACTION		0
206 
207 /* Client Transaction States */
208 #define	SIP_CLNT_CALLING		1
209 #define	SIP_CLNT_INV_PROCEEDING 	2
210 #define	SIP_CLNT_INV_TERMINATED 	3
211 #define	SIP_CLNT_INV_COMPLETED		4
212 #define	SIP_CLNT_TRYING		5
213 #define	SIP_CLNT_NONINV_PROCEEDING 	6
214 #define	SIP_CLNT_NONINV_TERMINATED 	7
215 #define	SIP_CLNT_NONINV_COMPLETED	8
216 
217 /* Server Transaction States */
218 #define	SIP_SRV_INV_PROCEEDING		9
219 #define	SIP_SRV_INV_COMPLETED		10
220 #define	SIP_SRV_CONFIRMED		11
221 #define	SIP_SRV_INV_TERMINATED		12
222 #define	SIP_SRV_TRYING			13
223 #define	SIP_SRV_NONINV_PROCEEDING	14
224 #define	SIP_SRV_NONINV_COMPLETED	15
225 #define	SIP_SRV_NONINV_TERMINATED	16
226 
227 /* Dialog types */
228 #define	SIP_UAC_DIALOG			1
229 #define	SIP_UAS_DIALOG			2
230 
231 /* Dialog state */
232 typedef enum dialog_state {
233 	SIP_DLG_NEW = 0,	/* New dialog, no reply received yet */
234 	SIP_DLG_EARLY,		/* Early dialog, provisional reply received */
235 	SIP_DLG_CONFIRMED,	/* Confirmed dialog, 2xx reply received */
236 	SIP_DLG_DESTROYED	/* Destroyed dialog */
237 } dialog_state_t;
238 
239 /* SIP URI parse errors */
240 #define	SIP_URIERR_SCHEME	0x00000001 /* invalid URL SCHEME name */
241 #define	SIP_URIERR_USER		0x00000002 /* invalid user name */
242 #define	SIP_URIERR_PASS		0x00000004 /* invalid password  */
243 #define	SIP_URIERR_HOST		0x00000008 /* invalid domain name */
244 #define	SIP_URIERR_PORT		0x00000010 /* invalid port number */
245 #define	SIP_URIERR_PARAM	0x00000020 /* parameter specific error */
246 #define	SIP_URIERR_HEADER	0x00000040 /* headers specific error */
247 #define	SIP_URIERR_OPAQUE	0x00000080 /* opaque specific error */
248 #define	SIP_URIERR_QUERY	0x00000100 /* query specific error */
249 #define	SIP_URIERR_PATH		0x00000200 /* path specific error */
250 #define	SIP_URIERR_REGNAME	0x00000400 /* reg-name specific error */
251 #define	SIP_URIERR_NOURI	0x00000800 /* No URI */
252 #define	SIP_URIERR_MEMORY	0x00001000 /* out of memory */
253 
254 #ifdef		__linux__
255 #define		B_FALSE		0
256 #define		B_TRUE		1
257 
258 typedef int		boolean_t;
259 typedef unsigned char	uchar_t;
260 typedef unsigned int	uint_t;
261 typedef unsigned int	uint32_t;
262 #endif
263 
264 typedef struct sip_message	*sip_msg_t;
265 typedef struct sip_header	*sip_header_t;
266 typedef struct sip_value	*sip_header_value_t;
267 typedef struct sip_dialog	*sip_dialog_t;
268 typedef struct sip_uri		*sip_uri_t;
269 typedef struct sip_conn_object	*sip_conn_object_t;
270 typedef	struct sip_xaction	*sip_transaction_t;
271 
272 typedef struct sip_str {
273 	char	*sip_str_ptr;
274 	int	sip_str_len;
275 }sip_str_t;
276 
277 
278 /* SIP parameter */
279 typedef struct sip_param {
280 	sip_str_t	param_name;
281 	sip_str_t	param_value;
282 	struct sip_param *param_next;
283 }sip_param_t;
284 
285 
286 /* Parsed header structure */
287 typedef struct sip_parsed_header {
288 	int		 sip_parsed_header_version;
289 	struct sip_value *value;
290 	sip_header_t	sip_header;
291 }sip_parsed_header_t;
292 
293 #define	SIP_PARSED_HEADER_VERSION_1	1
294 
295 /* Value states */
296 typedef enum {
297 	SIP_VALUE_ACTIVE = 0,
298 	SIP_VALUE_BAD,
299 	SIP_VALUE_DELETED
300 }sip_value_state_t;
301 
302 /* SIP header value */
303 typedef struct sip_value {
304 	int			sip_value_version;
305 	void			*next;
306 	sip_param_t		*param_list;
307 	sip_value_state_t	value_state; /* Active/Deleted */
308 	sip_parsed_header_t	*parsed_header;
309 	char			*value_start;
310 	char			*value_end;
311 	sip_str_t		*sip_value_uri_str;
312 	sip_uri_t		sip_value_parse_uri;
313 }sip_value_t;
314 
315 #define	SIP_VALUE_VERSION_1	1
316 
317 typedef struct sip_header_general {
318 	char			*sip_hdr_start;
319 	char			*sip_hdr_end;
320 	char			*sip_hdr_current;
321 	sip_parsed_header_t	*sip_hdr_parsed;
322 }sip_hdr_general_t;
323 
324 /* SIP methods */
325 typedef enum {
326 	UNKNOWN = 0,
327 	INVITE,
328 	ACK,
329 	OPTIONS,
330 	BYE,
331 	CANCEL,
332 	REGISTER,
333 	REFER,
334 	INFO,
335 	SUBSCRIBE,
336 	NOTIFY,
337 	PRACK
338 }sip_method_t;
339 
340 #define	MAX_SIP_METHODS	12
341 
342 typedef struct sip_methods {
343 	char *name;	/* Name of the method */
344 	int  len;	/* Length for comparison */
345 }sip_methods_t;
346 
347 extern sip_methods_t sip_methods[];
348 
349 /* SIP header function table */
350 typedef struct header_function_table {
351 	char		*header_name;
352 	char		*header_short_name;
353 	int		(*header_parse_func)(struct sip_header *,
354 			    struct sip_parsed_header **);
355 	boolean_t	(*header_check_compliance)(struct sip_parsed_header *);
356 	boolean_t	(*header_is_equal)(struct sip_parsed_header *,
357 			    struct sip_parsed_header *);
358 	void		(*header_free)(struct sip_parsed_header *);
359 }sip_header_function_t;
360 
361 /* Connection Manager interface */
362 typedef struct sip_io_pointers_s {
363 	int	(*sip_conn_send)(const sip_conn_object_t, char *, int);
364 	void	(*sip_hold_conn_object)(sip_conn_object_t);
365 	void	(*sip_rel_conn_object)(sip_conn_object_t);
366 	boolean_t	(*sip_conn_is_stream)(sip_conn_object_t);
367 	boolean_t	(*sip_conn_is_reliable)(sip_conn_object_t);
368 	int 	(*sip_conn_remote_address)(sip_conn_object_t, struct sockaddr *,
369 		    socklen_t *);
370 	int 	(*sip_conn_local_address)(sip_conn_object_t, struct sockaddr *,
371 		    socklen_t *);
372 	int	(*sip_conn_transport)(sip_conn_object_t);
373 	int	(*sip_conn_timer1)(sip_conn_object_t);
374 	int	(*sip_conn_timer2)(sip_conn_object_t);
375 	int	(*sip_conn_timer4)(sip_conn_object_t);
376 	int	(*sip_conn_timerd)(sip_conn_object_t);
377 }sip_io_pointers_t;
378 
379 /* Upper layer registerations */
380 typedef struct sip_ulp_pointers_s {
381 	void		(*sip_ulp_recv)(const sip_conn_object_t,
382 			    sip_msg_t, const sip_dialog_t);
383 	uint_t		(*sip_ulp_timeout)(void *, void (*func)(void *),
384 			    struct timeval *);
385 	boolean_t	(*sip_ulp_untimeout)(uint_t);
386 	int		(*sip_ulp_trans_error)(sip_transaction_t, int, void *);
387 	void		(*sip_ulp_dlg_del)(sip_dialog_t, sip_msg_t, void *);
388 	void		(*sip_ulp_trans_state_cb)(sip_transaction_t,
389 			    sip_msg_t, int, int);
390 	void		(*sip_ulp_dlg_state_cb)(sip_dialog_t, sip_msg_t, int,
391 			    int);
392 }sip_ulp_pointers_t;
393 
394 /* SIP stack initialization structure */
395 typedef struct sip_stack_init_s {
396 	int			sip_version;
397 	int			sip_stack_flags;
398 	sip_io_pointers_t	*sip_io_pointers;
399 	sip_ulp_pointers_t	*sip_ulp_pointers;
400 	sip_header_function_t	*sip_function_table;
401 }sip_stack_init_t;
402 
403 /* SIP stack version */
404 #define	SIP_STACK_VERSION		1
405 
406 /* Flags for sip_stack_flags */
407 #define	SIP_STACK_DIALOGS		0x0001
408 
409 extern int		sip_init_conn_object(sip_conn_object_t);
410 extern void		sip_clear_stale_data(sip_conn_object_t);
411 extern void		sip_conn_destroyed(sip_conn_object_t);
412 
413 extern int		(*sip_stack_send)(const sip_conn_object_t, char *, int);
414 extern void		(*sip_refhold_conn)(sip_conn_object_t);
415 extern void		(*sip_refrele_conn)(sip_conn_object_t);
416 extern boolean_t	(*sip_is_conn_stream)(sip_conn_object_t);
417 extern boolean_t	(*sip_is_conn_reliable)(sip_conn_object_t);
418 extern int 		(*sip_conn_rem_addr)(sip_conn_object_t,
419 			    struct sockaddr *, socklen_t *);
420 extern int		(*sip_conn_local_addr)(sip_conn_object_t,
421 			    struct sockaddr *, socklen_t *);
422 extern int		(*sip_conn_transport)(sip_conn_object_t);
423 extern int		(*sip_conn_timer1)(sip_conn_object_t);
424 extern int		(*sip_conn_timer2)(sip_conn_object_t);
425 extern int		(*sip_conn_timer4)(sip_conn_object_t);
426 extern int		(*sip_conn_timerd)(sip_conn_object_t);
427 
428 extern uint_t		(*sip_stack_timeout)(void *, void (*func)(void *),
429 			    struct timeval *);
430 extern boolean_t	(*sip_stack_untimeout)(uint_t);
431 
432 extern sip_msg_t	sip_new_msg();
433 extern void		sip_free_msg(sip_msg_t);
434 extern void		sip_hold_msg(sip_msg_t);
435 extern int		sip_stack_init(sip_stack_init_t *);
436 extern int		sip_sendmsg(sip_conn_object_t, sip_msg_t, sip_dialog_t,
437 			    uint32_t);
438 extern void		sip_process_new_packet(sip_conn_object_t, void *,
439 			    size_t);
440 extern char 		*sip_guid();
441 extern char		*sip_sent_by_to_str(int *);
442 extern int		sip_register_sent_by(char *);
443 extern void		sip_unregister_sent_by(char *);
444 extern void		sip_unregister_all_sent_by();
445 extern char 		*sip_branchid(sip_msg_t);
446 extern uint32_t		sip_get_cseq();
447 extern uint32_t		sip_get_rseq();
448 extern int		sip_get_num_via(sip_msg_t, int *);
449 
450 extern int 		sip_add_from(sip_msg_t, char *, char *, char *,
451 			    boolean_t, char *);
452 extern int 		sip_add_to(sip_msg_t, char *, char *, char *,
453 			    boolean_t, char *);
454 extern int 		sip_add_response_line(sip_msg_t, int, char *);
455 extern int 		sip_add_request_line(sip_msg_t, sip_method_t, char *);
456 extern int 		sip_add_via(sip_msg_t, char *, char *, int, char *);
457 extern int 		sip_add_maxforward(sip_msg_t, uint_t);
458 extern int 		sip_add_callid(sip_msg_t, char *);
459 extern int 		sip_add_cseq(sip_msg_t, sip_method_t, uint32_t);
460 extern int 		sip_add_content_type(sip_msg_t, char *, char *);
461 extern int 		sip_add_content(sip_msg_t, char *);
462 extern int 		sip_add_contact(sip_msg_t, char *, char *, boolean_t,
463 			    char *);
464 extern int 		sip_add_route(sip_msg_t, char *, char *, char *);
465 extern int 		sip_add_record_route(sip_msg_t, char *, char *, char *);
466 extern int 		sip_add_branchid_to_via(sip_msg_t, char *);
467 extern int 		sip_add_accept(sip_msg_t, char *, char *, char *,
468 			    char *);
469 extern int		sip_add_author(sip_msg_t, char *,  char *);
470 extern int		sip_add_authen_info(sip_msg_t, char *);
471 extern int		sip_add_proxy_authen(sip_msg_t, char *,  char *);
472 extern int		sip_add_proxy_author(sip_msg_t, char *, char *);
473 extern int		sip_add_proxy_require(sip_msg_t, char *);
474 extern int		sip_add_www_authen(sip_msg_t, char *, char *);
475 extern int		sip_add_accept_enc(sip_msg_t, char *, char *);
476 extern int		sip_add_accept_lang(sip_msg_t, char *, char *);
477 extern int		sip_add_alert_info(sip_msg_t, char *, char *);
478 extern int		sip_add_allow(sip_msg_t, sip_method_t);
479 extern int		sip_add_call_info(sip_msg_t, char *, char *);
480 extern int		sip_add_content_disp(sip_msg_t, char *, char *);
481 extern int		sip_add_content_enc(sip_msg_t, char *);
482 extern int		sip_add_content_lang(sip_msg_t, char *);
483 extern int		sip_add_date(sip_msg_t, char *);
484 extern int		sip_add_error_info(sip_msg_t, char *, char *);
485 extern int		sip_add_expires(sip_msg_t, int);
486 extern int		sip_add_in_reply_to(sip_msg_t, char *);
487 extern int		sip_add_mime_version(sip_msg_t, char *);
488 extern int		sip_add_min_expires(sip_msg_t, int);
489 extern int		sip_add_org(sip_msg_t, char *);
490 extern int		sip_add_priority(sip_msg_t, char *);
491 extern int		sip_add_reply_to(sip_msg_t, char *, char *, char *,
492 			    boolean_t);
493 extern int		sip_add_require(sip_msg_t, char *);
494 extern int		sip_add_retry_after(sip_msg_t, int, char *, char *);
495 extern int		sip_add_server(sip_msg_t, char *);
496 extern int		sip_add_subject(sip_msg_t, char *);
497 extern int		sip_add_supported(sip_msg_t, char *);
498 extern int		sip_add_tstamp(sip_msg_t, char *, char *);
499 extern int		sip_add_unsupported(sip_msg_t, char *);
500 extern int		sip_add_user_agent(sip_msg_t, char *);
501 extern int		sip_add_warning(sip_msg_t, int, char *, char *);
502 extern int		sip_add_allow_events(sip_msg_t, char *);
503 extern int		sip_add_event(sip_msg_t, char *, char *);
504 extern int		sip_add_substate(sip_msg_t, char *, char *);
505 extern int		sip_add_privacy(sip_msg_t, char *);
506 extern int		sip_add_passertedid(sip_msg_t, char *, char *,
507 			    boolean_t);
508 extern int		sip_add_ppreferredid(sip_msg_t, char *, char *,
509 			    boolean_t);
510 extern int		sip_add_rack(sip_msg_t, int, int, sip_method_t);
511 extern int		sip_add_rseq(sip_msg_t, int);
512 extern const sip_str_t *sip_get_author_scheme(sip_msg_t, int *);
513 extern const sip_str_t *sip_get_author_param(sip_msg_t, char *, int *);
514 extern const sip_str_t *sip_get_authen_info(sip_header_value_t, int *);
515 extern const sip_str_t *sip_get_proxy_authen_scheme(sip_msg_t, int *);
516 extern const sip_str_t *sip_get_proxy_authen_param(sip_msg_t, char *, int *);
517 extern const sip_str_t *sip_get_proxy_author_scheme(sip_msg_t, int *);
518 extern const sip_str_t *sip_get_proxy_author_param(sip_msg_t, char *, int *);
519 extern const sip_str_t *sip_get_proxy_require(sip_header_value_t, int *);
520 extern const sip_str_t *sip_get_www_authen_scheme(sip_msg_t, int *);
521 extern const sip_str_t *sip_get_www_authen_param(sip_msg_t, char *, int *);
522 extern const sip_str_t	*sip_get_allow_events(sip_header_value_t, int *);
523 extern const sip_str_t	*sip_get_event(sip_msg_t, int *);
524 extern const sip_str_t	*sip_get_substate(sip_msg_t, int *);
525 extern const sip_str_t	*sip_get_accept_type(sip_header_value_t, int *);
526 extern const sip_str_t	*sip_get_accept_sub_type(sip_header_value_t, int *);
527 extern const sip_str_t	*sip_get_accept_enc(sip_header_value_t, int *);
528 extern const sip_str_t	*sip_get_accept_lang(sip_header_value_t, int *);
529 extern const sip_str_t	*sip_get_alert_info_uri(sip_header_value_t, int *);
530 extern sip_method_t	sip_get_allow_method(sip_header_value_t, int *);
531 extern int		sip_get_min_expires(sip_msg_t, int *);
532 extern const sip_str_t	*sip_get_mime_version(sip_msg_t, int *);
533 extern const sip_str_t	*sip_get_org(sip_msg_t, int *);
534 extern const sip_str_t	*sip_get_priority(sip_msg_t, int *);
535 extern const sip_str_t	*sip_get_replyto_display_name(sip_msg_t, int *);
536 extern const sip_str_t	*sip_get_replyto_uri_str(sip_msg_t, int *);
537 extern const sip_str_t	*sip_get_date_time(sip_msg_t, int *);
538 extern int		sip_get_date_day(sip_msg_t, int *);
539 extern const sip_str_t	*sip_get_date_month(sip_msg_t, int *);
540 extern const sip_str_t	*sip_get_date_wkday(sip_msg_t, int *);
541 extern int		sip_get_date_year(sip_msg_t, int *);
542 extern const sip_str_t	*sip_get_date_timezone(sip_msg_t, int *);
543 extern const sip_str_t	*sip_get_content_disp(sip_msg_t, int *);
544 extern const sip_str_t	*sip_get_content_lang(sip_header_value_t, int *);
545 extern const sip_str_t	*sip_get_content_enc(sip_header_value_t, int *);
546 extern const sip_str_t	*sip_get_error_info_uri(sip_header_value_t, int *);
547 extern int		sip_get_expires(sip_msg_t, int *);
548 extern const sip_str_t	*sip_get_require(sip_header_value_t, int *);
549 extern const sip_str_t	*sip_get_subject(sip_msg_t, int *);
550 extern const sip_str_t	*sip_get_supported(sip_header_value_t, int *);
551 extern const sip_str_t	*sip_get_tstamp_delay(sip_msg_t, int *);
552 extern const sip_str_t	*sip_get_tstamp_value(sip_msg_t, int *);
553 extern const sip_str_t	*sip_get_unsupported(sip_header_value_t, int *);
554 extern const sip_str_t	*sip_get_server(sip_msg_t, int *);
555 extern const sip_str_t	*sip_get_user_agent(sip_msg_t, int *);
556 extern int		sip_get_warning_code(sip_header_value_t, int *);
557 extern const sip_str_t	*sip_get_warning_agent(sip_header_value_t, int *);
558 extern const sip_str_t	*sip_get_warning_text(sip_header_value_t, int *);
559 extern const sip_str_t	*sip_get_call_info_uri(sip_header_value_t, int *);
560 extern const sip_str_t	*sip_get_in_reply_to(sip_header_value_t, int *);
561 extern int		sip_get_retry_after_time(sip_msg_t, int *);
562 extern const sip_str_t	*sip_get_retry_after_cmts(sip_msg_t, int *);
563 extern const sip_str_t	*sip_get_passertedid_display_name(sip_header_value_t,
564 			    int *);
565 extern const sip_str_t	*sip_get_passertedid_uri_str(sip_header_value_t,
566 			    int *);
567 extern const sip_str_t	*sip_get_ppreferredid_display_name(sip_header_value_t,
568 			    int *);
569 extern const sip_str_t	*sip_get_ppreferredid_uri_str(sip_header_value_t,
570 			    int *);
571 extern const sip_str_t	*sip_get_priv_value(sip_header_value_t, int *);
572 extern int		sip_get_rack_resp_num(sip_msg_t, int *);
573 extern int		sip_get_rack_cseq_num(sip_msg_t, int *);
574 extern sip_method_t	sip_get_rack_method(sip_msg_t, int *);
575 extern int		sip_get_rseq_resp_num(sip_msg_t, int *);
576 
577 extern int		sip_copy_start_line(sip_msg_t, sip_msg_t);
578 extern int		sip_delete_start_line(sip_msg_t sip_msg);
579 extern int		sip_copy_header(sip_msg_t, sip_header_t, char *);
580 extern int		sip_copy_header_by_name(sip_msg_t, sip_msg_t, char *,
581 			    char *);
582 extern int		sip_copy_all_headers(sip_msg_t, sip_msg_t);
583 extern int		sip_delete_header_by_name(sip_msg_t, char *);
584 extern int		sip_add_header(sip_msg_t, char *);
585 extern sip_header_t	sip_add_param(sip_header_t, char *, int *);
586 extern int		sip_delete_header(sip_header_t);
587 extern int		sip_delete_value(sip_header_t, sip_header_value_t);
588 extern sip_msg_t	sip_clone_msg(const sip_msg_t);
589 extern sip_msg_t	sip_create_response(const sip_msg_t, int, char *,
590 			    char *, char *);
591 extern int		sip_create_OKack(const sip_msg_t, sip_msg_t, char *,
592 			    char *, int, char *);
593 extern char 		*sip_get_resp_desc(int);
594 extern char		*sip_get_branchid(const sip_msg_t, int *);
595 
596 extern const struct sip_header	*sip_get_header(sip_msg_t, char *, sip_header_t,
597 				    int *);
598 extern const struct sip_value	*sip_get_header_value(
599 				    const struct sip_header *, int *);
600 extern const struct sip_value	*sip_get_next_value(sip_header_value_t, int *);
601 extern const sip_str_t		*sip_get_param_value(sip_header_value_t,
602 				    char *, int *);
603 extern const sip_param_t	*sip_get_params(sip_header_value_t, int *);
604 extern boolean_t		sip_is_param_present(const sip_param_t *,
605 				    char *, int);
606 
607 extern char		*sip_msg_to_str(sip_msg_t, int *);
608 extern char		*sip_hdr_to_str(sip_header_t, int *);
609 extern char		*sip_reqline_to_str(sip_msg_t, int *);
610 extern char		*sip_respline_to_str(sip_msg_t, int *);
611 extern boolean_t	sip_msg_is_request(const sip_msg_t, int *);
612 extern boolean_t	sip_msg_is_response(const sip_msg_t, int *);
613 extern sip_method_t	sip_get_request_method(const sip_msg_t, int *);
614 extern const sip_str_t	*sip_get_request_uri_str(sip_msg_t, int *);
615 extern int		sip_get_response_code(sip_msg_t, int *);
616 extern const sip_str_t	*sip_get_response_phrase(sip_msg_t, int *);
617 extern const sip_str_t	*sip_get_sip_version(sip_msg_t, int *);
618 extern int		sip_get_msg_len(sip_msg_t, int *);
619 extern const sip_str_t	*sip_get_route_uri_str(sip_header_value_t, int *);
620 extern const sip_str_t	*sip_get_route_display_name(sip_header_value_t, int *);
621 extern const sip_str_t	*sip_get_contact_uri_str(sip_header_value_t, int *);
622 extern const sip_str_t	*sip_get_contact_display_name(sip_header_value_t,
623 			    int *);
624 extern const sip_str_t	*sip_get_from_uri_str(sip_msg_t, int *);
625 extern const sip_str_t	*sip_get_from_display_name(sip_msg_t, int *);
626 extern const sip_str_t	*sip_get_from_tag(sip_msg_t, int *);
627 extern const sip_str_t	*sip_get_to_uri_str(sip_msg_t, int *);
628 extern const sip_str_t	*sip_get_to_display_name(sip_msg_t, int *);
629 extern const sip_str_t	*sip_get_to_tag(sip_msg_t, int *);
630 extern const sip_str_t	*sip_get_callid(sip_msg_t, int *);
631 extern int		sip_get_callseq_num(sip_msg_t, int *);
632 extern sip_method_t	sip_get_callseq_method(sip_msg_t, int *);
633 extern const sip_str_t	*sip_get_via_sent_by_host(sip_header_value_t, int *);
634 extern int		sip_get_via_sent_by_port(sip_header_value_t, int *);
635 extern const sip_str_t	*sip_get_via_sent_protocol_version(sip_header_value_t,
636 			    int *);
637 extern const sip_str_t	*sip_get_via_sent_protocol_name(sip_header_value_t,
638 			    int *);
639 extern const sip_str_t	*sip_get_via_sent_transport(sip_header_value_t,
640 			    int *);
641 extern int 		sip_get_maxforward(sip_msg_t, int *);
642 extern int 		sip_get_content_length(sip_msg_t, int *);
643 extern const sip_str_t	*sip_get_content_type(sip_msg_t, int *);
644 extern const sip_str_t	*sip_get_content_sub_type(sip_msg_t, int *);
645 extern char		*sip_get_content(sip_msg_t, int *);
646 extern sip_msg_t	sip_create_dialog_req(sip_method_t, sip_dialog_t,
647 			    char *, char *, int, char *, uint32_t, int);
648 
649 extern int			sip_get_dialog_state(sip_dialog_t, int *);
650 extern int			sip_get_dialog_method(sip_dialog_t, int *);
651 extern const sip_str_t		*sip_get_dialog_callid(sip_dialog_t, int *);
652 extern const sip_str_t		*sip_get_dialog_local_tag(sip_dialog_t, int *);
653 extern const sip_str_t		*sip_get_dialog_remote_tag(sip_dialog_t, int *);
654 extern const struct sip_uri	*sip_get_dialog_local_uri(sip_dialog_t, int *);
655 extern const struct sip_uri	*sip_get_dialog_remote_uri(sip_dialog_t, int *);
656 extern const struct sip_uri	*sip_get_dialog_remote_target_uri(sip_dialog_t,
657 				    int *);
658 extern const sip_str_t		*sip_get_dialog_route_set(sip_dialog_t, int *);
659 extern boolean_t		sip_is_dialog_secure(sip_dialog_t, int *);
660 extern uint32_t			sip_get_dialog_local_cseq(sip_dialog_t, int *);
661 extern uint32_t			sip_get_dialog_remote_cseq(sip_dialog_t, int *);
662 extern int			sip_get_dialog_type(sip_dialog_t dialog, int *);
663 
664 extern void			sip_hold_dialog(sip_dialog_t);
665 extern void			sip_release_dialog(sip_dialog_t);
666 extern void			sip_delete_dialog(sip_dialog_t);
667 
668 extern sip_uri_t		sip_parse_uri(sip_str_t *, int *);
669 extern void			sip_free_parsed_uri(sip_uri_t);
670 extern boolean_t		sip_is_sipuri(const struct sip_uri *);
671 extern const sip_str_t		*sip_get_uri_scheme(const struct sip_uri *,
672 				    int *);
673 extern const sip_str_t		*sip_get_uri_user(const struct sip_uri *,
674 				    int *);
675 extern const sip_str_t		*sip_get_uri_password(const struct sip_uri *,
676 				    int *);
677 extern const sip_str_t		*sip_get_uri_host(const struct sip_uri *,
678 				    int *);
679 extern int			sip_get_uri_port(const struct sip_uri *,
680 				    int *error);
681 extern const sip_param_t	*sip_get_uri_params(const struct sip_uri *,
682 				    int *);
683 extern const sip_str_t		*sip_get_uri_headers(const struct sip_uri *,
684 				    int *);
685 extern const sip_str_t		*sip_get_uri_opaque(const struct sip_uri *,
686 				    int *);
687 extern const sip_str_t		*sip_get_uri_query(const struct sip_uri *,
688 				    int *);
689 extern const sip_str_t		*sip_get_uri_path(const struct sip_uri *,
690 				    int *);
691 extern const sip_str_t		*sip_get_uri_regname(const struct sip_uri *,
692 				    int *);
693 extern boolean_t		sip_is_uri_teluser(const struct sip_uri *);
694 extern int			sip_get_uri_errflags(const struct sip_uri *,
695 				    int *);
696 extern char			*sip_uri_errflags_to_str(int);
697 
698 extern const struct sip_uri	*sip_get_request_uri(sip_msg_t, int *);
699 extern const struct sip_uri	*sip_get_uri_parsed(sip_header_value_t, int *);
700 
701 /* Transaction functions */
702 extern const struct sip_xaction	*sip_get_trans(sip_msg_t, int, int *);
703 extern char 			*sip_get_trans_branchid(sip_transaction_t,
704 				    int *);
705 extern sip_method_t		sip_get_trans_method(sip_transaction_t,
706 				    int *);
707 extern int			sip_get_trans_state(sip_transaction_t, int *);
708 extern const struct sip_message	*sip_get_trans_resp_msg(sip_transaction_t,
709 				    int *);
710 extern const struct sip_message	*sip_get_trans_orig_msg(sip_transaction_t,
711 				    int *);
712 extern void			sip_hold_trans(sip_transaction_t);
713 extern void			sip_release_trans(sip_transaction_t);
714 extern const struct sip_conn_object	*sip_get_trans_conn_obj(
715 					    sip_transaction_t, int *);
716 #ifdef	__cplusplus
717 }
718 #endif
719 
720 #endif	/* _SIP_H */
721