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