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