nua_params.h 8.98 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2006 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

25 26
#ifndef NUA_PARAMS_H
/** Defined when <nua_params.h> has been included. */
27 28
#define NUA_PARAMS_H

29
/**@internal @file nua_params.h
30 31 32 33 34 35 36 37
 * @brief Parameters and their handling
 *
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>
 * @author Kai Vehmanen <Kai.Vehmanen@nokia.com>
 *
 * @date Created: Wed Mar  8 11:38:18 EET 2006  ppessi
 */

38 39
#include <nua_types.h>

40 41 42 43
#ifndef NUA_TAG_H
#include <sofia-sip/nua_tag.h>
#endif

44
/**@internal @brief NUA preferences.
45 46 47 48 49 50 51 52 53 54 55 56 57 58
 *
 * This structure contains values for various preferences and a separate
 * bitmap (nhp_set) for each preference. Preferences are set using
 * nua_set_params() or nua_set_hparams() or a handle-specific operation
 * setting the preferences, including nua_invite(), nua_respond(),
 * nua_ack(), nua_prack(), nua_update(), nua_info(), nua_bye(),
 * nua_options(), nua_message(), nua_register(), nua_publish(), nua_refer(),
 * nua_subscribe(), nua_notify(), nua_refer(), and nua_notifier().
 *
 * The stack uses preference value if corresponding bit in bitmap is set,
 * otherwise it uses preference value from default handle.
 *
 * @see NHP_GET(), NH_PGET(), NHP_ISSET(), NH_PISSET()
 */
59
struct nua_handle_preferences
60 61 62 63 64
{
  unsigned         nhp_retry_count;	/**< times to retry a request */
  unsigned         nhp_max_subscriptions;

  /* Session-related preferences */
65 66
  char const      *nhp_soa_name;
  unsigned         nhp_media_enable:1;
67 68
  unsigned     	   nhp_invite_enable:1;
  unsigned     	   nhp_auto_alert:1;
69 70
  unsigned         nhp_early_answer:1; /**< Include answer in 1XX */
  unsigned         nhp_early_media:1; /**< Establish early media with 100rel */
71
  unsigned         nhp_only183_100rel:1;/**< Only 100rel 183. */
72 73 74 75
  unsigned         nhp_auto_answer:1;
  unsigned         nhp_auto_ack:1; /**< Automatically ACK a final response */
  unsigned         :0;

76
  /** INVITE timeout.
77 78 79 80 81 82 83 84 85 86
   *
   * If no response is received in nhp_invite_timeout seconds,
   * INVITE client transaction times out
   */
  unsigned         nhp_invite_timeout;
  /** Default session timer (in seconds, 0 disables) */
  unsigned         nhp_session_timer;
  /** Default Min-SE Delta value */
  unsigned         nhp_min_se;
  /** no (preference), local or remote */
87
  enum nua_session_refresher nhp_refresher;
88
  unsigned         nhp_update_refresh:1; /**< Use UPDATE to refresh */
89 90 91

  /**< Accept refreshes without SDP */
  unsigned         nhp_refresh_without_sdp:1;
92

93 94 95 96
  /* Messaging preferences */
  unsigned     	   nhp_message_enable : 1;
  /** Be bug-compatible with Windows Messenger */
  unsigned     	   nhp_win_messenger_enable : 1;
97 98
  /** PIM-IW hack */
  unsigned         nhp_message_auto_respond : 1;
99 100 101 102 103 104 105 106

  /* Preferences for registration (and dialog establishment) */
  unsigned         nhp_callee_caps:1; /**< Add callee caps to contact */
  unsigned         nhp_media_features:1;/**< Add media features to caps*/
  /** Enable Service-Route */
  unsigned         nhp_service_route_enable:1;
  /** Enable Path */
  unsigned         nhp_path_enable:1;
107 108 109
  /** Authentication cache policy */
  unsigned         nhp_auth_cache:1;

110 111
  /** Always include id with Event: refer */
  unsigned         nhp_refer_with_id:1;
112 113 114 115
  /** Redirect automatically with 302 responses */
  unsigned         nhp_auto302:1;
  /** Redirect automatically with 305 responses */
  unsigned         nhp_auto305:1;
116 117 118 119 120 121 122
  unsigned:0;

  /* Default lifetime for implicit subscriptions created by REFER */
  unsigned         nhp_refer_expires;

  /* Subscriber state, i.e. nua_substate_pending */
  unsigned         nhp_substate;
123
  unsigned         nhp_sub_expires;
124

125
  /* REGISTER keepalive intervals */
126 127 128
  unsigned         nhp_keepalive, nhp_keepalive_stream;
  char const      *nhp_registrar;

129 130
  sip_allow_t        *nhp_allow;
  sip_supported_t    *nhp_supported;
131
  sip_allow_events_t *nhp_allow_events;
132 133
  char const         *nhp_user_agent;
  char const         *nhp_organization;
134

135 136 137 138
  char const         *nhp_m_display;
  char const         *nhp_m_username;
  char const         *nhp_m_params;
  char const         *nhp_m_features;
139
  char const         *nhp_instance;
140

141
  /** Outbound OPTIONS */
142 143
  char const         *nhp_outbound;

144
  sip_allow_t        *nhp_appl_method;
145

146 147 148
  /** Initial route set */
  sip_route_t        *nhp_initial_route;

149 150 151
  /** Next hop URI (used instead of route). */
  url_string_t       *nhp_proxy;

152 153
  union { struct {
    /* A bit for each feature set by application */
154
    /* NOTE:
155
       Some compilers behave weird if there are bitfields
156 157 158
       together with width > 32
       So there should be a padding field (unsigned:0;)
       every 32 bits.
159
    */
160 161
    unsigned nhb_retry_count:1;
    unsigned nhb_max_subscriptions:1;
162 163 164

    unsigned nhb_soa_name:1;
    unsigned nhb_media_enable:1;
165 166
    unsigned nhb_invite_enable:1;
    unsigned nhb_auto_alert:1;
167
    unsigned nhb_early_answer:1;
168 169 170 171 172
    unsigned nhb_early_media:1;
    unsigned nhb_only183_100rel:1;
    unsigned nhb_auto_answer:1;
    unsigned nhb_auto_ack:1;
    unsigned nhb_invite_timeout:1;
173

174 175
    unsigned nhb_session_timer:1;
    unsigned nhb_min_se:1;
176
    unsigned nhb_refresher:1;
177
    unsigned nhb_update_refresh:1;
178
    unsigned nhb_refresh_without_sdp:1;
179 180
    unsigned nhb_message_enable:1;
    unsigned nhb_win_messenger_enable:1;
181
    unsigned nhb_message_auto_respond:1;
182 183 184 185
    unsigned nhb_callee_caps:1;
    unsigned nhb_media_features:1;
    unsigned nhb_service_route_enable:1;
    unsigned nhb_path_enable:1;
186
    unsigned nhb_auth_cache:1;
187
    unsigned nhb_refer_with_id:1;
188 189
    unsigned nhb_auto302:1;
    unsigned nhb_auto305:1;
190 191
    unsigned nhb_refer_expires:1;
    unsigned nhb_substate:1;
192
    unsigned nhb_sub_expires:1;
193
    unsigned nhb_keepalive:1;
194 195
    unsigned :0;		/* at most 32 bits before this point */

196 197 198
    unsigned nhb_keepalive_stream:1;
    unsigned nhb_registrar:1;

199
    unsigned nhb_allow:1;
200
    unsigned nhb_supported:1;
201

202
    unsigned nhb_allow_events:1;
203
    unsigned nhb_user_agent:1;
204
    unsigned nhb_organization:1;
205

206 207 208 209 210 211
    unsigned nhb_m_display:1;
    unsigned nhb_m_username:1;
    unsigned nhb_m_params:1;
    unsigned nhb_m_features:1;
    unsigned nhb_instance:1;
    unsigned nhb_outbound:1;
212
    unsigned nhb_appl_method:1;
213
    unsigned nhb_initial_route:1;
214
    unsigned nhb_proxy:1;
215
    unsigned :0;
216
  } set_bits;
217 218
    unsigned set_unsigned[2];
  } nhp_set_;
219
};
220

221 222
#define nhp_set nhp_set_.set_bits

Pekka Pessi's avatar
Pekka Pessi committed
223
/** @internal Global preferences for nua. */
224
struct nua_global_preferences {
225 226 227 228 229 230 231 232 233 234 235
  /** Network detection: NONE, INFORMAL, TRY_FULL */
  signed int ngp_detect_network_updates:3;
  /** Pass events during shutdown, too */
  int ngp_shutdown_events:1;

  unsigned :0;			/* pad */
  union { struct {
    /* A bit for each feature set by application */
    unsigned ngp_detect_network_updates:1;
    unsigned ngp_shutdown_events:1;
    unsigned :0;
236
  } set_bits;
237 238
    unsigned set_unsigned[2];
  } ngp_set_;
239
};
240 241 242

#define ngp_set ngp_set_.set_bits

243 244 245
#define DNHP_GET(dnhp, pref) ((dnhp)->nhp_##pref)

#define NHP_GET(nhp, dnhp, pref)					\
246
  ((nhp)->nhp_set.nhb_##pref					\
247 248 249 250
   ? (nhp)->nhp_##pref : (dnhp)->nhp_##pref)

#define NHP_SET(nhp, pref, value)					\
  ((nhp)->nhp_##pref = (value),						\
251
   (nhp)->nhp_set.nhb_##pref = 1)
252 253 254

/* Check if preference is set */
#define NHP_ISSET(nhp, pref)						\
255
  ((nhp)->nhp_set.nhb_##pref)
256

257 258
#define NHP_UNSET_ALL(nhp) (memset(&(nhp)->nhp_set, 0, sizeof (nhp)->nhp_set))
#define NHP_SET_ALL(nhp) (memset(&(nhp)->nhp_set, 255, sizeof (nhp)->nhp_set))
259 260 261

/* Get preference from handle, if set, otherwise from default handle */
#define NH_PGET(nh, pref)						\
262
  NHP_GET((nh)->nh_prefs, (nh)->nh_dprefs, pref)
263

264
/* Get preference from handle, if exists and set,
265 266 267 268 269 270
   otherwise from default handle */
#define NUA_PGET(nua, nh, pref)						\
  NHP_GET((nh) ? (nh)->nh_prefs : (nua)->nua_dhandle->nh_prefs,		\
	  (nua)->nua_dhandle->nh_prefs,					\
	  pref)

271 272 273 274 275 276 277 278
/* Get preference from default handle */
#define DNH_PGET(dnh, pref)						\
  DNHP_GET((dnh)->nh_prefs, pref)
/* Check if preference is set in the handle */
#define NH_PISSET(nh, pref)						\
  (NHP_ISSET((nh)->nh_prefs, pref) &&					\
   (nh)->nh_nua->nua_dhandle->nh_prefs != (nh)->nh_prefs)

279
/* Check if preference has been set by application */
280 281 282 283
#define NUA_PISSET(nua, nh, pref)					\
  (NHP_ISSET((nua)->nua_dhandle->nh_prefs, pref) ||			\
   ((nh) && NHP_ISSET((nh)->nh_prefs, pref)))

284
#endif /* NUA_PARAMS_H */