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