nua_params.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /*
  2. * This file is part of the Sofia-SIP package
  3. *
  4. * Copyright (C) 2006 Nokia Corporation.
  5. *
  6. * Contact: Pekka Pessi <pekka.pessi@nokia.com>
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public License
  10. * as published by the Free Software Foundation; either version 2.1 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. *
  23. */
  24. #ifndef NUA_PARAMS_H
  25. /** Defined when <nua_params.h> has been included. */
  26. #define NUA_PARAMS_H
  27. /**@internal @file nua_params.h
  28. * @brief Parameters and their handling
  29. *
  30. * @author Pekka Pessi <Pekka.Pessi@nokia.com>
  31. * @author Kai Vehmanen <Kai.Vehmanen@nokia.com>
  32. *
  33. * @date Created: Wed Mar 8 11:38:18 EET 2006 ppessi
  34. */
  35. #include <nua_types.h>
  36. #ifndef NUA_TAG_H
  37. #include <sofia-sip/nua_tag.h>
  38. #endif
  39. /**@internal @brief NUA preferences.
  40. *
  41. * This structure contains values for various preferences and a separate
  42. * bitmap (nhp_set) for each preference. Preferences are set using
  43. * nua_set_params() or nua_set_hparams() or a handle-specific operation
  44. * setting the preferences, including nua_invite(), nua_respond(),
  45. * nua_ack(), nua_prack(), nua_update(), nua_info(), nua_bye(),
  46. * nua_options(), nua_message(), nua_register(), nua_publish(), nua_refer(),
  47. * nua_subscribe(), nua_notify(), nua_refer(), and nua_notifier().
  48. *
  49. * The stack uses preference value if corresponding bit in bitmap is set,
  50. * otherwise it uses preference value from default handle.
  51. *
  52. * @see NHP_GET(), NH_PGET(), NHP_ISSET(), NH_PISSET()
  53. */
  54. struct nua_handle_preferences
  55. {
  56. unsigned nhp_retry_count; /**< times to retry a request */
  57. unsigned nhp_max_subscriptions;
  58. uint32_t nhp_call_tls_orq_connect_timeout;
  59. /* Session-related preferences */
  60. char const *nhp_soa_name;
  61. unsigned nhp_media_enable:1;
  62. unsigned nhp_invite_enable:1;
  63. unsigned nhp_auto_alert:1;
  64. unsigned nhp_early_answer:1; /**< Include answer in 1XX */
  65. unsigned nhp_early_media:1; /**< Establish early media with 100rel */
  66. unsigned nhp_only183_100rel:1;/**< Only 100rel 183. */
  67. unsigned nhp_auto_answer:1;
  68. unsigned nhp_auto_ack:1; /**< Automatically ACK a final response */
  69. unsigned :0;
  70. /** INVITE timeout.
  71. *
  72. * If no response is received in nhp_invite_timeout seconds,
  73. * INVITE client transaction times out
  74. */
  75. unsigned nhp_invite_timeout;
  76. /** Default session timer (in seconds, 0 disables) */
  77. unsigned nhp_session_timer;
  78. /** Default Min-SE Delta value */
  79. unsigned nhp_min_se;
  80. /** no (preference), local or remote */
  81. enum nua_session_refresher nhp_refresher;
  82. unsigned nhp_update_refresh:1; /**< Use UPDATE to refresh */
  83. /**< Accept refreshes without SDP */
  84. unsigned nhp_refresh_without_sdp:1;
  85. /* Messaging preferences */
  86. unsigned nhp_message_enable : 1;
  87. /** Be bug-compatible with Windows Messenger */
  88. unsigned nhp_win_messenger_enable : 1;
  89. /** PIM-IW hack */
  90. unsigned nhp_message_auto_respond : 1;
  91. /* Preferences for registration (and dialog establishment) */
  92. unsigned nhp_callee_caps:1; /**< Add callee caps to contact */
  93. unsigned nhp_media_features:1;/**< Add media features to caps*/
  94. /** Enable Service-Route */
  95. unsigned nhp_service_route_enable:1;
  96. /** Enable Path */
  97. unsigned nhp_path_enable:1;
  98. /** Authentication cache policy */
  99. unsigned nhp_auth_cache:1;
  100. /** Always include id with Event: refer */
  101. unsigned nhp_refer_with_id:1;
  102. unsigned nhp_timer_autorequire:1;
  103. /** Enable Retry-After */
  104. unsigned nhp_retry_after_enable:1;
  105. /** Enable/Disable automatic 100 Trying when receiving INVITE */
  106. unsigned nhp_auto_invite_100:1;
  107. unsigned:0;
  108. /* Default lifetime for implicit subscriptions created by REFER */
  109. unsigned nhp_refer_expires;
  110. /* Subscriber state, i.e. nua_substate_pending */
  111. unsigned nhp_substate;
  112. unsigned nhp_sub_expires;
  113. /* REGISTER keepalive intervals */
  114. unsigned nhp_keepalive, nhp_keepalive_stream;
  115. char const *nhp_registrar;
  116. sip_allow_t *nhp_allow;
  117. sip_supported_t *nhp_supported;
  118. sip_allow_events_t *nhp_allow_events;
  119. char const *nhp_user_agent;
  120. char const *nhp_organization;
  121. char const *nhp_via;
  122. char const *nhp_m_display;
  123. char const *nhp_m_username;
  124. char const *nhp_m_params;
  125. char const *nhp_m_features;
  126. char const *nhp_instance;
  127. /** Outbound OPTIONS */
  128. char const *nhp_outbound;
  129. sip_allow_t *nhp_appl_method;
  130. /** Initial route set */
  131. sip_route_t *nhp_initial_route;
  132. /** Next hop URI (used instead of route). */
  133. url_string_t *nhp_proxy;
  134. union { struct {
  135. /* A bit for each feature set by application */
  136. /* NOTE:
  137. Some compilers behave weird if there are bitfields
  138. together with width > 32
  139. So there should be a padding field (unsigned:0;)
  140. every 32 bits.
  141. */
  142. unsigned nhb_retry_count:1;
  143. unsigned nhb_max_subscriptions:1;
  144. unsigned nhb_soa_name:1;
  145. unsigned nhb_media_enable:1;
  146. unsigned nhb_invite_enable:1;
  147. unsigned nhb_auto_alert:1;
  148. unsigned nhb_early_answer:1;
  149. unsigned nhb_early_media:1;
  150. unsigned nhb_only183_100rel:1;
  151. unsigned nhb_auto_answer:1;
  152. unsigned nhb_auto_ack:1;
  153. unsigned nhb_invite_timeout:1;
  154. unsigned nhb_session_timer:1;
  155. unsigned nhb_min_se:1;
  156. unsigned nhb_refresher:1;
  157. unsigned nhb_update_refresh:1;
  158. unsigned nhb_refresh_without_sdp:1;
  159. unsigned nhb_message_enable:1;
  160. unsigned nhb_win_messenger_enable:1;
  161. unsigned nhb_message_auto_respond:1;
  162. unsigned nhb_callee_caps:1;
  163. unsigned nhb_media_features:1;
  164. unsigned nhb_service_route_enable:1;
  165. unsigned nhb_path_enable:1;
  166. unsigned nhb_auth_cache:1;
  167. unsigned nhb_refer_with_id:1;
  168. unsigned nhb_refer_expires:1;
  169. unsigned nhb_substate:1;
  170. unsigned nhb_sub_expires:1;
  171. unsigned nhb_keepalive:1;
  172. unsigned nhb_keepalive_stream:1;
  173. unsigned nhb_registrar:1;
  174. unsigned :0; /* at most 32 bits before this point */
  175. unsigned nhb_allow:1;
  176. unsigned nhb_supported:1;
  177. unsigned nhb_allow_events:1;
  178. unsigned nhb_user_agent:1;
  179. unsigned nhb_organization:1;
  180. unsigned nhb_via:1;
  181. unsigned nhb_m_display:1;
  182. unsigned nhb_m_username:1;
  183. unsigned nhb_m_params:1;
  184. unsigned nhb_m_features:1;
  185. unsigned nhb_instance:1;
  186. unsigned nhb_outbound:1;
  187. unsigned nhb_appl_method:1;
  188. unsigned nhb_initial_route:1;
  189. unsigned nhb_proxy:1;
  190. unsigned nhb_timer_autorequire:1;
  191. unsigned nhb_retry_after_enable:1;
  192. unsigned nhb_auto_invite_100:1;
  193. unsigned nhb_call_tls_orq_connect_timeout:1;
  194. unsigned :0;
  195. } set_bits;
  196. unsigned set_unsigned[2];
  197. } nhp_set_;
  198. };
  199. #define nhp_set nhp_set_.set_bits
  200. /** Global preferences for nua. */
  201. struct nua_global_preferences {
  202. /** Network detection: NONE, INFORMAL, TRY_FULL */
  203. signed int ngp_detect_network_updates:3;
  204. /** Pass events during shutdown, too */
  205. int ngp_shutdown_events:1;
  206. unsigned :0; /* pad */
  207. union { struct {
  208. /* A bit for each feature set by application */
  209. unsigned ngp_detect_network_updates:1;
  210. unsigned ngp_shutdown_events:1;
  211. unsigned :0;
  212. } set_bits;
  213. unsigned set_unsigned[2];
  214. } ngp_set_;
  215. };
  216. #define ngp_set ngp_set_.set_bits
  217. #define DNHP_GET(dnhp, pref) ((dnhp)->nhp_##pref)
  218. #define NHP_GET(nhp, dnhp, pref) \
  219. ((nhp)->nhp_set.nhb_##pref \
  220. ? (nhp)->nhp_##pref : (dnhp)->nhp_##pref)
  221. #define NHP_SET(nhp, pref, value) \
  222. ((nhp)->nhp_##pref = (value), \
  223. (nhp)->nhp_set.nhb_##pref = 1)
  224. /* Check if preference is set */
  225. #define NHP_ISSET(nhp, pref) \
  226. ((nhp)->nhp_set.nhb_##pref)
  227. #define NHP_UNSET_ALL(nhp) (memset(&(nhp)->nhp_set, 0, sizeof (nhp)->nhp_set))
  228. #define NHP_SET_ALL(nhp) (memset(&(nhp)->nhp_set, 255, sizeof (nhp)->nhp_set))
  229. /* Get preference from handle, if set, otherwise from default handle */
  230. #define NH_PGET(nh, pref) \
  231. NHP_GET((nh)->nh_prefs, (nh)->nh_dprefs, pref)
  232. /* Get preference from handle, if exists and set,
  233. otherwise from default handle */
  234. #define NUA_PGET(nua, nh, pref) \
  235. NHP_GET((nh) ? (nh)->nh_prefs : (nua)->nua_dhandle->nh_prefs, \
  236. (nua)->nua_dhandle->nh_prefs, \
  237. pref)
  238. /* Get preference from default handle */
  239. #define DNH_PGET(dnh, pref) \
  240. DNHP_GET((dnh)->nh_prefs, pref)
  241. /* Check if preference is set in the handle */
  242. #define NH_PISSET(nh, pref) \
  243. (NHP_ISSET((nh)->nh_prefs, pref) && \
  244. (nh)->nh_nua->nua_dhandle->nh_prefs != (nh)->nh_prefs)
  245. /* Check if preference has been set by application */
  246. #define NUA_PISSET(nua, nh, pref) \
  247. (NHP_ISSET((nua)->nua_dhandle->nh_prefs, pref) || \
  248. ((nh) && NHP_ISSET((nh)->nh_prefs, pref)))
  249. #endif /* NUA_PARAMS_H */