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.
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.
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]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
39 * Generic function to get int or string value from a header
42 sip_get_val_from_hdr(sip_hdr_value_t
*val
, int val_type
, boolean_t stype
,
48 if (val
== NULL
|| val
->sip_value_state
== SIP_VALUE_DELETED
) {
54 if (val
->sip_value_state
== SIP_VALUE_BAD
)
59 return (&(val
->int_val
));
61 return (&(val
->str_val
));
63 if (stype
== B_TRUE
) {
64 if (val
->strs_val
.s1
.sip_str_ptr
!= NULL
)
65 return (&(val
->strs_val
.s1
));
68 if (val
->strs_val
.s2
.sip_str_ptr
!= NULL
)
69 return (&(val
->strs_val
.s2
));
71 case (SIP_INTSTR_VAL
):
72 if (stype
== B_TRUE
) {
73 if (val
->intstr_str
.sip_str_ptr
!= NULL
)
74 return (&(val
->intstr_str
));
78 return (&(val
->intstr_int
));
80 return (&(val
->auth_val
));
82 if (error
!= NULL
&& *error
== 0)
88 * Generic function to get value from a header given the value type and
89 * the string info (for multi-string values).
92 sip_get_val_from_msg(sip_msg_t msg
, char *hdr_name
, int val_type
,
93 boolean_t stype
, boolean_t empty_val
, int *error
)
95 const _sip_header_t
*header
;
96 sip_hdr_value_t
*value
;
106 header
= sip_get_header(msg
, hdr_name
, NULL
, error
);
107 if (header
== NULL
) {
113 value
= (sip_hdr_value_t
*)sip_get_header_value(header
, error
);
115 if (error
!= NULL
&& empty_val
== B_FALSE
)
119 return (sip_get_val_from_hdr(value
, val_type
, stype
, error
));
123 * Get the URI from the value
126 sip_get_cftruri_from_val(sip_header_value_t value
, int *error
)
128 sip_hdr_value_t
*cftrvalue
;
133 if (value
== NULL
|| value
->value_state
== SIP_VALUE_DELETED
) {
138 cftrvalue
= (sip_hdr_value_t
*)value
;
140 * If the value is BAD, update error to reflect it.
142 if (error
!= NULL
&& value
->value_state
== SIP_VALUE_BAD
)
144 return (&cftrvalue
->cftr_uri
);
148 * Get display name from the value
151 sip_get_cftrname_from_val(sip_header_value_t value
, int *error
)
153 sip_hdr_value_t
*cftrvalue
;
157 if (value
== NULL
|| value
->value_state
== SIP_VALUE_DELETED
) {
162 cftrvalue
= (sip_hdr_value_t
*)value
;
164 * If the value is BAD, update error to reflect it.
166 if (error
!= NULL
&& value
->value_state
== SIP_VALUE_BAD
)
168 return (cftrvalue
->cftr_name
);
172 * Contact header can have more than one value
173 * so we require a value to be passed in to get a value.
176 sip_get_contact_uri_str(sip_header_value_t value
, int *error
)
178 return (sip_get_cftruri_from_val(value
, error
));
182 * Contact header can have more than one value
183 * so we require a value to be passed in to get a value.
186 sip_get_contact_display_name(sip_header_value_t value
, int *error
)
188 return (sip_get_cftrname_from_val(value
, error
));
192 * Route header can have more than one value
193 * so we require a value to be passed in to get a value.
196 sip_get_route_uri_str(sip_header_value_t value
, int *error
)
198 return (sip_get_cftruri_from_val(value
, error
));
202 * Route header can have more than one value
203 * so we require a value to be passed in to get a value.
206 sip_get_route_display_name(sip_header_value_t value
, int *error
)
208 return (sip_get_cftrname_from_val(value
, error
));
212 * Get URI from the SIP message
215 sip_get_cftruri_from_msg(sip_msg_t sip_msg
, int *error
, char *hdrname
)
217 const sip_hdr_value_t
*value
;
218 const struct sip_header
*header
;
222 if (sip_msg
== NULL
) {
228 header
= sip_get_header(sip_msg
, hdrname
, NULL
, error
);
229 if (header
== NULL
) {
235 value
= (sip_hdr_value_t
*)sip_get_header_value(header
, error
);
242 * If the value is BAD, update error to reflect it.
244 if (error
!= NULL
&& value
->sip_value_state
== SIP_VALUE_BAD
)
246 return (&value
->cftr_uri
);
250 * Get display name from the SIP message
253 sip_get_cftrname_from_msg(sip_msg_t sip_msg
, int *error
, char *hdrname
)
255 const sip_hdr_value_t
*value
;
256 const struct sip_header
*header
;
260 if (sip_msg
== NULL
) {
265 header
= sip_get_header(sip_msg
, hdrname
, NULL
, error
);
266 if (header
== NULL
) {
272 value
= (sip_hdr_value_t
*)sip_get_header_value(header
, error
);
279 * If the value is BAD, update error to reflect it.
281 if (error
!= NULL
&& value
->sip_value_state
== SIP_VALUE_BAD
)
283 return (value
->cftr_name
);
290 sip_get_from_uri_str(sip_msg_t sip_msg
, int *error
)
292 return (sip_get_cftruri_from_msg(sip_msg
, error
, SIP_FROM
));
296 * Get FROM display name
299 sip_get_from_display_name(sip_msg_t sip_msg
, int *error
)
301 return (sip_get_cftrname_from_msg(sip_msg
, error
, SIP_FROM
));
305 * Return the FROM tag
308 sip_get_from_tag(sip_msg_t sip_msg
, int *error
)
310 const sip_hdr_value_t
*value
;
311 const struct sip_header
*header
;
315 if (sip_msg
== NULL
) {
320 header
= sip_get_header(sip_msg
, SIP_FROM
, NULL
, error
);
321 if (header
== NULL
) {
327 value
= (sip_hdr_value_t
*)sip_get_header_value(header
, error
);
334 * If the value is BAD, update error to reflect it.
336 if (error
!= NULL
&& value
->sip_value_state
== SIP_VALUE_BAD
)
338 return (sip_get_param_value((sip_header_value_t
)value
, "tag", error
));
345 sip_get_to_uri_str(sip_msg_t sip_msg
, int *error
)
347 return (sip_get_cftruri_from_msg(sip_msg
, error
, SIP_TO
));
351 * Get TO display name
354 sip_get_to_display_name(sip_msg_t sip_msg
, int *error
)
356 return (sip_get_cftrname_from_msg(sip_msg
, error
, SIP_TO
));
363 sip_get_to_tag(sip_msg_t sip_msg
, int *error
)
365 const sip_hdr_value_t
*value
;
366 const struct sip_header
*header
;
370 if (sip_msg
== NULL
) {
375 header
= sip_get_header(sip_msg
, SIP_TO
, NULL
, error
);
376 if (header
== NULL
) {
382 value
= (sip_hdr_value_t
*)sip_get_header_value(header
, error
);
389 * If the value is BAD, update error to reflect it.
391 if (error
!= NULL
&& value
->sip_value_state
== SIP_VALUE_BAD
)
393 return (sip_get_param_value((sip_header_value_t
)value
, "tag", error
));
400 sip_get_callid(sip_msg_t sip_msg
, int *error
)
404 r
= (sip_str_t
*)sip_get_val_from_msg(sip_msg
, SIP_CALL_ID
, SIP_STR_VAL
,
405 B_FALSE
, B_TRUE
, error
);
409 #define SIP_CSEQ_NUM 1
410 #define SIP_CSEQ_METHOD 2
413 * Get number/method from the CSEQ header
416 sip_get_cseq_val(sip_msg_t msg
, int type
, int *error
)
418 const _sip_header_t
*header
;
419 sip_hdr_value_t
*val
;
429 header
= sip_get_header(msg
, SIP_CSEQ
, NULL
, error
);
430 if (header
== NULL
) {
435 val
= (sip_hdr_value_t
*)sip_get_header_value(header
, error
);
441 if (error
!= NULL
&& val
->sip_value
.value_state
== SIP_VALUE_BAD
)
446 return (&(val
->cseq_num
));
447 case SIP_CSEQ_METHOD
:
448 return (&(val
->cseq_method
));
459 sip_get_callseq_num(sip_msg_t sip_msg
, int *error
)
463 r
= (int *)sip_get_cseq_val(sip_msg
, SIP_CSEQ_NUM
, error
);
464 return (r
== NULL
? -1 : *r
);
471 sip_get_callseq_method(sip_msg_t sip_msg
, int *error
)
475 r
= (sip_method_t
*)sip_get_cseq_val(sip_msg
, SIP_CSEQ_METHOD
, error
);
476 return (r
== NULL
? -1 : *r
);
480 * Via header can have more than one value
481 * so we require a value to be passed in.
484 sip_get_via_sent_by_host(sip_header_value_t value
, int *error
)
486 sip_hdr_value_t
*via_value
;
490 if (value
== NULL
|| value
->value_state
== SIP_VALUE_DELETED
) {
495 via_value
= (sip_hdr_value_t
*)value
;
496 if (via_value
->sip_value_state
== SIP_VALUE_BAD
&& error
!= NULL
)
498 return (&via_value
->via_sent_by_host
);
502 * Via header can have more than one value
503 * so we require a value to be passed in.
506 sip_get_via_sent_by_port(sip_header_value_t value
, int *error
)
508 sip_hdr_value_t
*via_value
;
512 if (value
== NULL
|| value
->value_state
== SIP_VALUE_DELETED
) {
517 via_value
= (sip_hdr_value_t
*)value
;
518 if (via_value
->sip_value_state
== SIP_VALUE_BAD
&& error
!= NULL
)
520 return (via_value
->via_sent_by_port
);
524 * Return the protocol version from the VIA value
527 sip_get_via_sent_protocol_version(sip_header_value_t value
, int *error
)
529 sip_hdr_value_t
*via_value
;
531 if (value
== NULL
|| value
->value_state
== SIP_VALUE_DELETED
) {
536 via_value
= (sip_hdr_value_t
*)value
;
537 if (via_value
->sip_value_state
== SIP_VALUE_BAD
&& error
!= NULL
)
539 return (&via_value
->via_protocol_vers
);
543 * Return the protocol name
546 sip_get_via_sent_protocol_name(sip_header_value_t value
, int *error
)
548 sip_hdr_value_t
*via_value
;
552 if (value
== NULL
|| value
->value_state
== SIP_VALUE_DELETED
) {
557 via_value
= (sip_hdr_value_t
*)value
;
558 if (via_value
->sip_value_state
== SIP_VALUE_BAD
&& error
!= NULL
)
560 return (&via_value
->via_protocol_name
);
564 * Return the transport from the VIA value
567 sip_get_via_sent_transport(sip_header_value_t value
, int *error
)
569 sip_hdr_value_t
*via_value
;
573 if (value
== NULL
|| value
->value_state
== SIP_VALUE_DELETED
) {
578 via_value
= (sip_hdr_value_t
*)value
;
579 if (via_value
->sip_value_state
== SIP_VALUE_BAD
&& error
!= NULL
)
581 return (&via_value
->via_protocol_transport
);
585 * get the branch id from the topmost VIA header
588 sip_get_branchid(sip_msg_t sip_msg
, int *error
)
590 _sip_header_t
*header
;
591 sip_parsed_header_t
*parsed_header
;
592 sip_hdr_value_t
*via_value
;
593 const sip_str_t
*param_value
;
595 _sip_msg_t
*_sip_msg
;
600 if (sip_msg
== NULL
) {
606 _sip_msg
= (_sip_msg_t
*)sip_msg
;
608 (void) pthread_mutex_lock(&_sip_msg
->sip_msg_mutex
);
609 header
= sip_search_for_header(_sip_msg
, SIP_VIA
, NULL
);
610 if (header
== NULL
) {
613 (void) pthread_mutex_unlock(&_sip_msg
->sip_msg_mutex
);
616 if (sip_parse_via_header(header
, &parsed_header
) != 0) {
619 (void) pthread_mutex_unlock(&_sip_msg
->sip_msg_mutex
);
622 if (parsed_header
== NULL
) {
625 (void) pthread_mutex_unlock(&_sip_msg
->sip_msg_mutex
);
628 via_value
= (sip_hdr_value_t
*)parsed_header
->value
;
629 if (via_value
== NULL
|| via_value
->sip_value_state
== SIP_VALUE_BAD
) {
632 (void) pthread_mutex_unlock(&_sip_msg
->sip_msg_mutex
);
635 param_value
= sip_get_param_value((sip_header_value_t
)via_value
,
638 if (param_value
== NULL
) {
641 (void) pthread_mutex_unlock(&_sip_msg
->sip_msg_mutex
);
645 bid
= (char *)malloc(param_value
->sip_str_len
+ 1);
649 (void) pthread_mutex_unlock(&_sip_msg
->sip_msg_mutex
);
652 (void) strncpy(bid
, param_value
->sip_str_ptr
,
653 param_value
->sip_str_len
);
654 bid
[param_value
->sip_str_len
] = '\0';
655 (void) pthread_mutex_unlock(&_sip_msg
->sip_msg_mutex
);
660 * adds branchid to the topmost VIA header, if a branchid already exists,
664 sip_add_branchid_to_via(sip_msg_t sip_msg
, char *branchid
)
669 sip_header_t via_hdr
;
670 _sip_msg_t
*_sip_msg
;
675 * If there is already a branchid param, error?
677 if (sip_get_branchid(sip_msg
, NULL
) != NULL
)
679 _sip_msg
= (_sip_msg_t
*)sip_msg
;
680 (void) pthread_mutex_lock(&_sip_msg
->sip_msg_mutex
);
681 via_hdr
= (sip_header_t
)sip_search_for_header(_sip_msg
, SIP_VIA
, NULL
);
682 (void) pthread_mutex_unlock(&_sip_msg
->sip_msg_mutex
);
685 plen
= strlen(branchid
) + strlen("branch=") + 1;
686 param
= malloc(plen
);
689 (void) snprintf(param
, plen
, "branch=%s", branchid
);
691 (void) sip_add_param(via_hdr
, param
, &err
);
698 * returns the number of VIA headers in the SIP message
701 sip_get_num_via(sip_msg_t sip_msg
, int *error
)
703 _sip_msg_t
*_sip_msg
;
709 if (sip_msg
== NULL
) {
714 _sip_msg
= (_sip_msg_t
*)sip_msg
;
715 (void) pthread_mutex_lock(&_sip_msg
->sip_msg_mutex
);
716 hdr
= (sip_header_t
)sip_search_for_header(_sip_msg
, SIP_VIA
, NULL
);
717 while (hdr
!= NULL
) {
719 hdr
= (sip_header_t
)sip_search_for_header(_sip_msg
, SIP_VIA
,
722 (void) pthread_mutex_unlock(&_sip_msg
->sip_msg_mutex
);
727 * Return Max-Forward value
730 sip_get_maxforward(sip_msg_t sip_msg
, int *error
)
734 r
= (int *)sip_get_val_from_msg(sip_msg
, SIP_MAX_FORWARDS
, SIP_INT_VAL
,
735 B_FALSE
, B_FALSE
, error
);
742 * Get the content type
745 sip_get_content_type(sip_msg_t sip_msg
, int *error
)
749 r
= (sip_str_t
*)sip_get_val_from_msg(sip_msg
, SIP_CONTENT_TYPE
,
750 SIP_STRS_VAL
, B_TRUE
, B_FALSE
, error
);
755 * Get the content sub-type
758 sip_get_content_sub_type(sip_msg_t sip_msg
, int *error
)
762 r
= (sip_str_t
*)sip_get_val_from_msg(sip_msg
, SIP_CONTENT_TYPE
,
763 SIP_STRS_VAL
, B_FALSE
, B_FALSE
, error
);
768 * Return the content-length value
771 sip_get_content_length(sip_msg_t sip_msg
, int *error
)
775 r
= (int *)sip_get_val_from_msg(sip_msg
, SIP_CONTENT_LENGTH
,
776 SIP_INT_VAL
, B_FALSE
, B_FALSE
, error
);
786 sip_get_allow_events(sip_header_value_t value
, int *error
)
789 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
791 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STR_VAL
, B_TRUE
, error
);
799 sip_get_event(sip_msg_t sip_msg
, int *error
)
803 r
= (sip_str_t
*)sip_get_val_from_msg(sip_msg
, SIP_EVENT
, SIP_STR_VAL
,
804 B_FALSE
, B_FALSE
, error
);
809 * get subscription state
812 sip_get_substate(sip_msg_t sip_msg
, int *error
)
816 r
= (sip_str_t
*)sip_get_val_from_msg(sip_msg
, SIP_SUBSCRIPTION_STATE
,
817 SIP_STR_VAL
, B_FALSE
, B_FALSE
, error
);
825 sip_get_accept_type(sip_header_value_t value
, int *error
)
828 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
830 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STRS_VAL
, B_TRUE
, error
);
838 sip_get_accept_sub_type(sip_header_value_t value
, int *error
)
841 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
843 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STRS_VAL
, B_FALSE
,
849 * accept-encode can have more than one value
852 sip_get_accept_enc(sip_header_value_t value
, int *error
)
855 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
857 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STR_VAL
, B_FALSE
, error
);
862 * accept-language can have more than one value
865 sip_get_accept_lang(sip_header_value_t value
, int *error
)
868 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
870 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STR_VAL
, B_FALSE
, error
);
875 * get URI from the alert-info header
878 sip_get_alert_info_uri(sip_header_value_t value
, int *error
)
881 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
883 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STR_VAL
, B_FALSE
, error
);
888 * get method from allow header
891 sip_get_allow_method(sip_header_value_t value
, int *error
)
894 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
896 r
= (int *)sip_get_val_from_hdr(val
, SIP_INT_VAL
, B_FALSE
, error
);
897 return (r
== NULL
? -1 : (sip_method_t
)*r
);
901 * get URI from call-info header
904 sip_get_call_info_uri(sip_header_value_t value
, int *error
)
907 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
909 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STR_VAL
, B_FALSE
, error
);
914 * get content-disposition value
917 sip_get_content_disp(sip_msg_t sip_msg
, int *error
)
921 r
= (sip_str_t
*)sip_get_val_from_msg(sip_msg
, SIP_CONTENT_DIS
,
922 SIP_STR_VAL
, B_FALSE
, B_FALSE
, error
);
927 * get content-encoding value
930 sip_get_content_enc(sip_header_value_t value
, int *error
)
933 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
935 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STR_VAL
, B_FALSE
, error
);
940 * get content-language value
943 sip_get_content_lang(sip_header_value_t value
, int *error
)
946 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
948 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STR_VAL
, B_FALSE
, error
);
953 * sip_get_date_time, day, wkday, month, year
960 #define D_TIMEZONE 0x06
963 * get date information
966 sip_get_date_val(sip_msg_t msg
, int type
, int *error
)
968 const _sip_header_t
*header
;
969 sip_hdr_value_t
*val
;
978 header
= sip_get_header(msg
, SIP_DATE
, NULL
, error
);
979 if (header
== NULL
) {
985 val
= (sip_hdr_value_t
*)sip_get_header_value(header
, error
);
991 if (error
!= NULL
&& val
->sip_value
.value_state
== SIP_VALUE_BAD
)
995 return (&(val
->date_t
));
997 return (&(val
->date_d
));
999 return (&(val
->date_m
));
1001 return (&(val
->date_y
));
1003 return (&(val
->date_wd
));
1005 return (&(val
->date_tz
));
1016 sip_get_date_time(sip_msg_t sip_msg
, int *error
)
1020 r
= (sip_str_t
*)sip_get_date_val(sip_msg
, D_TIME
, error
);
1028 sip_get_date_day(sip_msg_t sip_msg
, int *error
)
1032 r
= sip_get_date_val(sip_msg
, D_DAY
, error
);
1033 return (r
== NULL
? -1 : *(int *)r
);
1040 sip_get_date_month(sip_msg_t sip_msg
, int *error
)
1044 r
= (sip_str_t
*)sip_get_date_val(sip_msg
, D_MONTH
, error
);
1052 sip_get_date_year(sip_msg_t sip_msg
, int *error
)
1056 r
= (int *)sip_get_date_val(sip_msg
, D_YEAR
, error
);
1057 return (r
== NULL
? -1 : *r
);
1061 * get day of the week
1064 sip_get_date_wkday(sip_msg_t sip_msg
, int *error
)
1068 r
= (sip_str_t
*)sip_get_date_val(sip_msg
, D_WKDAY
, error
);
1076 sip_get_date_timezone(sip_msg_t sip_msg
, int *error
)
1080 r
= (sip_str_t
*)sip_get_date_val(sip_msg
, D_TIMEZONE
, error
);
1085 * get error-info URI
1088 sip_get_error_info_uri(sip_header_value_t value
, int *error
)
1091 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
1093 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STR_VAL
, B_FALSE
, error
);
1098 * get priv-value from privacy
1101 sip_get_priv_value(sip_header_value_t value
, int *error
)
1104 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
1106 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STR_VAL
, B_FALSE
, error
);
1111 * return expires value
1114 sip_get_expires(sip_msg_t sip_msg
, int *error
)
1118 r
= (int *)sip_get_val_from_msg(sip_msg
, SIP_EXPIRE
, SIP_INT_VAL
,
1119 B_FALSE
, B_FALSE
, error
);
1126 * get reply-to value
1129 sip_get_in_reply_to(sip_header_value_t value
, int *error
)
1132 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
1134 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STR_VAL
, B_FALSE
, error
);
1139 * get min-expires value
1142 sip_get_min_expires(sip_msg_t sip_msg
, int *error
)
1146 r
= (int *)sip_get_val_from_msg(sip_msg
, SIP_MIN_EXPIRE
, SIP_INT_VAL
,
1147 B_FALSE
, B_FALSE
, error
);
1157 sip_get_mime_version(sip_msg_t sip_msg
, int *error
)
1161 r
= (sip_str_t
*)sip_get_val_from_msg(sip_msg
, SIP_MIME_VERSION
,
1162 SIP_STR_VAL
, B_FALSE
, B_FALSE
, error
);
1167 * get organization value
1170 sip_get_org(sip_msg_t sip_msg
, int *error
)
1174 r
= (sip_str_t
*)sip_get_val_from_msg(sip_msg
, SIP_ORGANIZATION
,
1175 SIP_STR_VAL
, B_FALSE
, B_TRUE
, error
);
1180 * get priority value
1183 sip_get_priority(sip_msg_t sip_msg
, int *error
)
1187 r
= (sip_str_t
*)sip_get_val_from_msg(sip_msg
, SIP_PRIORITY
,
1188 SIP_STR_VAL
, B_FALSE
, B_FALSE
, error
);
1196 sip_get_pidentity_display_name(sip_header_value_t value
, int *error
)
1199 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
1201 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STRS_VAL
, B_TRUE
, error
);
1210 sip_get_pidenty_uri_str(sip_header_value_t value
, int *error
)
1213 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
1215 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STRS_VAL
, B_FALSE
,
1222 * get display name from passerted-identity header
1225 sip_get_passertedid_display_name(sip_header_value_t value
, int *error
)
1227 return (sip_get_pidentity_display_name(value
, error
));
1231 * get URI from passerted-identity header
1234 sip_get_passertedid_uri_str(sip_header_value_t value
, int *error
)
1236 return (sip_get_pidenty_uri_str(value
, error
));
1240 * get display name from ppreferred-identity header
1243 sip_get_ppreferredid_display_name(sip_header_value_t value
, int *error
)
1245 return (sip_get_pidentity_display_name(value
, error
));
1249 * get URI from ppreferred-identity header
1252 sip_get_ppreferredid_uri_str(sip_header_value_t value
, int *error
)
1254 return (sip_get_pidenty_uri_str(value
, error
));
1257 #define SIP_RACK_RESP_NUM 1
1258 #define SIP_RACK_CSEQ_NUM 2
1259 #define SIP_RACK_METHOD 3
1262 * Get rack information
1265 sip_get_rack_val(sip_msg_t msg
, int type
, int *error
)
1267 const _sip_header_t
*header
;
1268 sip_hdr_value_t
*val
;
1278 header
= sip_get_header(msg
, SIP_RACK
, NULL
, error
);
1279 if (header
== NULL
) {
1284 val
= (sip_hdr_value_t
*)sip_get_header_value(header
, error
);
1290 if (error
!= NULL
&& val
->sip_value
.value_state
== SIP_VALUE_BAD
)
1294 case SIP_RACK_RESP_NUM
:
1295 return (&(val
->rack_resp
));
1296 case SIP_RACK_CSEQ_NUM
:
1297 return (&(val
->rack_cseq
));
1298 case SIP_RACK_METHOD
:
1299 return (&(val
->rack_method
));
1307 * get response number for rack
1310 sip_get_rack_resp_num(sip_msg_t sip_msg
, int *error
)
1314 r
= (int *)sip_get_rack_val(sip_msg
, SIP_RACK_RESP_NUM
, error
);
1316 return (r
== NULL
? -1 : *r
);
1320 * get sequence number for rack
1323 sip_get_rack_cseq_num(sip_msg_t sip_msg
, int *error
)
1327 r
= (int *)sip_get_rack_val(sip_msg
, SIP_RACK_CSEQ_NUM
, error
);
1329 return (r
== NULL
? -1 : *r
);
1333 * get method for rack
1336 sip_get_rack_method(sip_msg_t sip_msg
, int *error
)
1340 r
= (sip_method_t
*)sip_get_rack_val(sip_msg
, SIP_RACK_METHOD
, error
);
1342 return (r
== NULL
? -1 : *r
);
1346 * get response number from rseq
1349 sip_get_rseq_resp_num(sip_msg_t sip_msg
, int *error
)
1353 r
= (int *)sip_get_val_from_msg(sip_msg
, SIP_RSEQ
, SIP_INT_VAL
,
1354 B_FALSE
, B_FALSE
, error
);
1356 return (r
== NULL
? -1 : *r
);
1360 * get reply-to display name
1363 sip_get_replyto_display_name(sip_msg_t sip_msg
, int *error
)
1367 r
= (sip_str_t
*)sip_get_val_from_msg(sip_msg
, SIP_REPLYTO
,
1368 SIP_STRS_VAL
, B_TRUE
, B_FALSE
, error
);
1376 sip_get_replyto_uri_str(sip_msg_t sip_msg
, int *error
)
1380 r
= (sip_str_t
*)sip_get_val_from_msg(sip_msg
, SIP_REPLYTO
,
1381 SIP_STRS_VAL
, B_FALSE
, B_FALSE
, error
);
1390 sip_get_require(sip_header_value_t value
, int *error
)
1393 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
1395 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STR_VAL
, B_FALSE
, error
);
1400 * get retry-after time
1403 sip_get_retry_after_time(sip_msg_t sip_msg
, int *error
)
1407 t
= (int *)sip_get_val_from_msg(sip_msg
, SIP_RETRY_AFTER
,
1408 SIP_INTSTR_VAL
, B_FALSE
, B_FALSE
, error
);
1415 * get retry-after comments
1418 sip_get_retry_after_cmts(sip_msg_t sip_msg
, int *error
)
1422 r
= (sip_str_t
*)sip_get_val_from_msg(sip_msg
, SIP_RETRY_AFTER
,
1423 SIP_INTSTR_VAL
, B_TRUE
, B_FALSE
, error
);
1431 sip_get_subject(sip_msg_t sip_msg
, int *error
)
1435 r
= (sip_str_t
*)sip_get_val_from_msg(sip_msg
, SIP_SUBJECT
, SIP_STR_VAL
,
1436 B_FALSE
, B_TRUE
, error
);
1444 sip_get_supported(sip_header_value_t value
, int *error
)
1447 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
1449 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STR_VAL
, B_FALSE
, error
);
1454 * get timestamp delay
1457 sip_get_tstamp_delay(sip_msg_t sip_msg
, int *error
)
1461 t
= sip_get_val_from_msg(sip_msg
, SIP_TIMESTAMP
, SIP_STRS_VAL
, B_FALSE
,
1470 sip_get_tstamp_value(sip_msg_t sip_msg
, int *error
)
1474 t
= sip_get_val_from_msg(sip_msg
, SIP_TIMESTAMP
, SIP_STRS_VAL
, B_TRUE
,
1480 * get unsupported value
1483 sip_get_unsupported(sip_header_value_t value
, int *error
)
1486 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
1488 r
= (sip_str_t
*)sip_get_val_from_hdr(val
, SIP_STR_VAL
, B_FALSE
, error
);
1493 * get server value from message
1496 sip_get_server(sip_msg_t sip_msg
, int *error
)
1500 r
= (sip_str_t
*)sip_get_val_from_msg(sip_msg
, SIP_SERVER
, SIP_STR_VAL
,
1501 B_FALSE
, B_FALSE
, error
);
1506 * get user-agent value
1509 sip_get_user_agent(sip_msg_t sip_msg
, int *error
)
1513 r
= sip_get_val_from_msg(sip_msg
, SIP_USER_AGENT
, SIP_STR_VAL
, B_FALSE
,
1519 #define W_AGENT 0x06
1526 sip_get_warninfo(sip_header_value_t value
, int info
, int *error
)
1528 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
1539 if (val
->sip_value_state
== SIP_VALUE_BAD
) {
1546 return (&(val
->warn_code
));
1548 return (&(val
->warn_agt
));
1550 return (&(val
->warn_text
));
1561 sip_get_warning_code(sip_header_value_t value
, int *error
)
1568 if (value
== NULL
|| value
->value_state
== SIP_VALUE_DELETED
) {
1573 c
= (int *)sip_get_warninfo(value
, W_CODE
, error
);
1583 sip_get_warning_agent(sip_header_value_t value
, int *error
)
1587 if (value
== NULL
|| value
->value_state
== SIP_VALUE_DELETED
) {
1592 r
= (sip_str_t
*)sip_get_warninfo(value
, W_AGENT
, error
);
1600 sip_get_warning_text(sip_header_value_t value
, int *error
)
1604 if (value
== NULL
|| value
->value_state
== SIP_VALUE_DELETED
) {
1609 r
= (sip_str_t
*)sip_get_warninfo(value
, W_TEXT
, error
);
1614 * get authorization scheme
1617 sip_get_author_scheme(sip_msg_t sip_msg
, int *error
)
1621 r
= sip_get_val_from_msg(sip_msg
, SIP_AUTHOR
, SIP_AUTH_VAL
, B_FALSE
,
1627 * get authentication parameter
1629 static const sip_str_t
*
1630 sip_get_auth_param(sip_msg_t msg
, char *hdr_name
, char *pname
, int *error
)
1632 const _sip_header_t
*header
;
1633 sip_hdr_value_t
*value
;
1639 if (msg
== NULL
|| pname
== NULL
|| hdr_name
== NULL
) {
1645 header
= sip_get_header(msg
, hdr_name
, NULL
, error
);
1646 if (header
== NULL
) {
1652 value
= (sip_hdr_value_t
*)sip_get_header_value(header
, error
);
1653 if (value
== NULL
) {
1659 param
= sip_get_param_from_list(value
->auth_param
, pname
);
1661 return (¶m
->param_value
);
1666 * get authentication parameter
1669 sip_get_author_param(sip_msg_t sip_msg
, char *name
, int *error
)
1673 r
= sip_get_auth_param(sip_msg
, SIP_AUTHOR
, name
, error
);
1678 * get authentication info
1681 sip_get_authen_info(sip_header_value_t value
, int *error
)
1684 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
1688 if (value
== NULL
|| value
->value_state
== SIP_VALUE_DELETED
) {
1693 r
= sip_get_val_from_hdr(val
, SIP_STR_VAL
, B_FALSE
, error
);
1698 * get proxy-authentication scheme
1701 sip_get_proxy_authen_scheme(sip_msg_t msg
, int *error
)
1705 r
= sip_get_val_from_msg(msg
, SIP_PROXY_AUTHEN
, SIP_AUTH_VAL
, B_FALSE
,
1711 * get proxy authentication parameter
1714 sip_get_proxy_authen_param(sip_msg_t sip_msg
, char *name
, int *error
)
1718 r
= sip_get_auth_param(sip_msg
, SIP_PROXY_AUTHEN
, name
, error
);
1723 * get proxy-authorization scheme
1726 sip_get_proxy_author_scheme(sip_msg_t msg
, int *error
)
1730 r
= sip_get_val_from_msg(msg
, SIP_PROXY_AUTHOR
, SIP_AUTH_VAL
, B_FALSE
,
1736 * get proxy-authorization parameter
1739 sip_get_proxy_author_param(sip_msg_t sip_msg
, char *name
, int *error
)
1743 r
= sip_get_auth_param(sip_msg
, SIP_PROXY_AUTHOR
, name
, error
);
1751 sip_get_proxy_require(sip_header_value_t value
, int *error
)
1754 sip_hdr_value_t
*val
= (sip_hdr_value_t
*)value
;
1758 if (value
== NULL
|| value
->value_state
== SIP_VALUE_DELETED
) {
1763 r
= sip_get_val_from_hdr(val
, SIP_STR_VAL
, B_FALSE
, error
);
1768 * get www-authentication scheme
1771 sip_get_www_authen_scheme(sip_msg_t msg
, int *error
)
1775 r
= sip_get_val_from_msg(msg
, SIP_WWW_AUTHEN
, SIP_AUTH_VAL
, B_FALSE
,
1781 * get www-authentication parameter
1784 sip_get_www_authen_param(sip_msg_t sip_msg
, char *name
, int *error
)
1788 r
= sip_get_auth_param(sip_msg
, SIP_WWW_AUTHEN
, name
, error
);