sip 1.12.11devel
|
00001 /* 00002 * This file is part of the Sofia-SIP package 00003 * 00004 * Copyright (C) 2005 Nokia Corporation. 00005 * 00006 * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden> 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public License 00010 * as published by the Free Software Foundation; either version 2.1 of 00011 * the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 00021 * 02110-1301 USA 00022 * 00023 */ 00024 00025 #ifndef SIP_UTIL_H 00026 00027 #define SIP_UTIL_H 00028 00037 #ifndef SIP_H 00038 #include <sofia-sip/sip.h> 00039 #endif 00040 00041 #ifndef STRING0_H 00042 #include <sofia-sip/string0.h> 00043 #endif 00044 00045 #ifndef MSG_HEADER_H 00046 #include <sofia-sip/msg_header.h> 00047 #endif 00048 00049 SOFIA_BEGIN_DECLS 00050 00051 SOFIAPUBFUN 00052 sip_contact_t * 00053 sip_contact_create_from_via_with_transport(su_home_t *home, 00054 sip_via_t const *v, 00055 char const *user, 00056 char const *transport); 00057 00058 SOFIAPUBFUN 00059 sip_contact_t *sip_contact_create_from_via(su_home_t *, sip_via_t const *, 00060 char const *user); 00061 00062 SOFIAPUBFUN 00063 char * 00064 sip_contact_string_from_via(su_home_t *home, 00065 sip_via_t const *v, 00066 char const *user, 00067 char const *transport); 00068 00069 SOFIAPUBFUN int sip_transport_has_tls(char const *transport_name); 00070 00071 SOFIAPUBFUN int sip_response_terminates_dialog(int response_code, 00072 sip_method_t method, 00073 int *return_graceful_terminate); 00074 00075 SOFIAPUBFUN int sip_sanity_check(sip_t const *sip); 00076 00077 SOFIAPUBFUN unsigned sip_q_value(char const * q); 00078 00079 SOFIAPUBFUN url_t *sip_url_dup(su_home_t *sh, url_t const *o); 00080 00084 #define SIP_STRLOG(prefix, s) ((s) ? (prefix) : ""), ((s) ? (s) : "") 00085 00086 SOFIAPUBFUN int sip_addr_match(sip_addr_t const *a, sip_addr_t const *b); 00087 00088 /* ---------------------------------------------------------------------- 00089 * Header-specific functions below 00090 */ 00091 00092 SOFIAPUBFUN int sip_route_is_loose(sip_route_t const *r); 00093 SOFIAPUBFUN sip_route_t *sip_route_remove(msg_t *msg, sip_t *sip); 00094 SOFIAPUBFUN sip_route_t *sip_route_pop(msg_t *msg, sip_t *sip); 00095 SOFIAPUBFUN sip_route_t *sip_route_follow(msg_t *msg, sip_t *sip); 00096 SOFIAPUBFUN sip_route_t *sip_route_reverse(su_home_t *, sip_route_t const *); 00097 SOFIAPUBFUN sip_route_t *sip_route_fixdup(su_home_t *, sip_route_t const *); 00098 SOFIAPUBFUN sip_route_t *sip_route_fix(sip_route_t *route); 00099 00100 SOFIAPUBFUN sip_route_t *sip_route_fixdup_as(su_home_t *, 00101 msg_hclass_t *, 00102 sip_route_t const *); 00103 SOFIAPUBFUN sip_route_t *sip_route_reverse_as(su_home_t *, 00104 msg_hclass_t *, 00105 sip_route_t const *); 00106 00107 SOFIAPUBFUN sip_via_t *sip_via_remove(msg_t *msg, sip_t *sip); 00108 00109 /* ---------------------------------------------------------------------- */ 00110 /* Caller preferences */ 00111 00113 SOFIAPUBFUN int sip_prefs_matching(char const *pvalue, 00114 char const *nvalue, 00115 int *return_parse_error); 00116 SOFIAPUBFUN int sip_is_callerpref(char const *param); 00117 00119 enum sp_type { 00120 sp_error = -1, 00121 sp_init, 00122 sp_literal, 00123 sp_string, 00124 sp_range, 00125 }; 00126 00127 00129 union sip_pref 00130 { 00132 enum sp_type sp_type; 00133 00135 struct sp_literal { 00136 enum sp_type spl_type; 00137 char const *spl_value; 00138 usize_t spl_length; 00139 } sp_literal; 00140 /* (tag="<foo>") */ 00142 struct sp_string { 00143 enum sp_type sps_type; 00144 char const *sps_value; 00145 usize_t sps_length; 00146 } sp_string; 00147 00150 struct sp_range { 00151 enum sp_type spr_type; 00152 double spr_lower; 00153 double spr_upper; 00154 } sp_range; 00155 }; 00156 00158 SOFIAPUBFUN int sip_prefs_parse(union sip_pref *sp, 00159 char const **in_out_s, 00160 int *return_negation); 00161 00163 SOFIAPUBFUN int sip_prefs_match(union sip_pref const *, union sip_pref const *); 00164 00165 SOFIAPUBFUN int sip_contact_is_immune(sip_contact_t const *m); 00166 00171 #define sip_contact_immune(m) sip_contact_is_immune(m) 00172 00173 SOFIAPUBFUN sip_contact_t *sip_contact_immunize(su_home_t *home, 00174 sip_contact_t const *m); 00175 00176 SOFIAPUBFUN int sip_contact_reject(sip_contact_t const *m, 00177 sip_reject_contact_t const *rc); 00178 00179 SOFIAPUBFUN int sip_contact_accept(sip_contact_t const *m, 00180 sip_accept_contact_t const *cp, 00181 unsigned *return_S, 00182 unsigned *return_N, 00183 int *return_error); 00184 00185 SOFIAPUBFUN int sip_contact_score(sip_contact_t const *m, 00186 sip_accept_contact_t const *ac, 00187 sip_reject_contact_t const *rc); 00188 00189 00190 SOFIAPUBFUN int sip_aor_strip(url_t *url); 00191 00192 /* sec-agree utility functions. */ 00193 00194 SOFIAPUBFUN int sip_security_verify_compare(sip_security_server_t const *s, 00195 sip_security_verify_t const *v, 00196 char const **return_d_ver); 00197 00198 SOFIAPUBFUN 00199 sip_security_client_t const * 00200 sip_security_client_select(sip_security_client_t const *client, 00201 sip_security_server_t const *server); 00202 00203 /* Compatibility stuff */ 00204 00205 #define sip_params_add msg_params_add 00206 #define sip_params_cmp msg_params_cmp 00207 #define sip_params_replace msg_params_replace 00208 #define sip_params_find msg_params_find 00209 00210 SOFIA_END_DECLS 00211 00212 #endif