nua_dialog.h 21.7 KB
Newer Older
1 2 3
/*
 * This file is part of the Sofia-SIP package
 *
4
 * Copyright (C) 2006 Nokia Corporation.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 *
 * 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_DIALOG_H
/** Defined when <nua_dialog.h> has been included. */
27 28
#define NUA_DIALOG_H

29
/**@IFILE nua_dialog.h
30 31 32 33 34 35 36 37
 * @brief Dialog and dialog usage 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
#include <nua_types.h>
39

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

44
typedef struct {
45
  sip_method_t sm_method;
46
  char const *sm_method_name;
47

48
  int sm_event;
49

50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
  struct {
    unsigned create_dialog:1, in_dialog:1, target_refresh:1, add_contact:1;
    unsigned :0;
  } sm_flags;

  /** Initialize server-side request. */
  int (*sm_init)(nua_server_request_t *sr);

  /** Preprocess server-side request (after handle has been created). */
  int (*sm_preprocess)(nua_server_request_t *sr);

  /** Update server-side request parameters */
  int (*sm_params)(nua_server_request_t *sr, tagi_t const *tags);

  /** Respond to server-side request. */
  int (*sm_respond)(nua_server_request_t *sr, tagi_t const *tags);
Pekka Pessi's avatar
Pekka Pessi committed
66

67 68 69 70
  /** Report server-side request to application. */
  int (*sm_report)(nua_server_request_t *sr, tagi_t const *tags);

} nua_server_methods_t;
Pekka Pessi's avatar
Pekka Pessi committed
71

72

Pekka Pessi's avatar
Pekka Pessi committed
73
/* Server side transaction */
74 75 76
struct nua_server_request {
  struct nua_server_request *sr_next, **sr_prev;

77 78
  nua_server_methods_t const *sr_methods;

79 80 81 82
  nua_owner_t *sr_owner;	/**< Backpointer to handle */
  nua_dialog_usage_t *sr_usage;	/**< Backpointer to usage */

  nta_incoming_t *sr_irq;	/**< Server transaction object */
83

84 85 86 87 88 89 90 91 92
  struct {
    msg_t *msg;			/**< Request message */
    sip_t const *sip;		/**< Headers in request message */
  } sr_request;

  struct {
    msg_t *msg;			/**< Response message */
    sip_t *sip;			/**< Headers in response message */
  } sr_response;
93 94

  sip_method_t sr_method;	/**< Request method */
95 96 97

  int sr_application;		/**< Status by application */

98 99 100
  int sr_status;		/**< Status code */
  char const *sr_phrase;	/**< Status phrase */

101
  unsigned sr_event:1;		/**< Reported to application */
102
  unsigned sr_initial:1;	/**< Handle was created by this request */
103
  unsigned sr_add_contact:1;	/**< Add Contact header to the response */
104
  unsigned sr_target_refresh:1;	/**< Refresh target */
105 106
  unsigned sr_terminating:1;	/**< Terminate usage after final response */
  unsigned sr_gracefully:1;	/**< Terminate usage gracefully */
107

108 109
  unsigned sr_neutral:1;	/**< No effect on session or other usage */

110 111 112
  /* Flags used with 100rel */
  unsigned sr_100rel:1, sr_pracked:1;

113 114 115 116
  /* Flags used with offer-answer */
  unsigned sr_offer_recv:1;	/**< We have received an offer */
  unsigned sr_answer_sent:2;	/**< We have answered (reliably, if >1) */

117
  unsigned sr_offer_sent:2;	/**< We have offered SDP (reliably, if >1) */
118
  unsigned sr_answer_recv:1;	/**< We have received SDP answer */
119

120
  unsigned :0;
121

122
  char const *sr_sdp;		/**< SDP received from client */
123 124 125
  size_t sr_sdp_len;		/**< SDP length */

  /**< Save 200 OK nua_respond() signal until PRACK has been received */
126
  nua_saved_signal_t sr_signal[1];
127
};
128 129 130 131 132 133 134

#define SR_STATUS(sr, status, phrase) \
  ((sr)->sr_phrase = (phrase), (sr)->sr_status = (status))

#define SR_STATUS1(sr, statusphrase)					\
  sr_status(sr, statusphrase)

135 136
#define SR_HAS_SAVED_SIGNAL(sr) ((sr)->sr_signal[0] != NULL)

137
su_inline
138 139 140 141 142
int sr_status(nua_server_request_t *sr, int status, char const *phrase)
{
  return (void)(sr->sr_phrase = phrase), (sr->sr_status = status);
}

Pekka Pessi's avatar
Pekka Pessi committed
143
/* Methods for client request. @internal */
Pekka Pessi's avatar
Pekka Pessi committed
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
typedef struct {
  sip_method_t crm_method;
  char const *crm_method_name;
  size_t crm_extra;		/**< Size of private data */

  struct {
    unsigned create_dialog:1, in_dialog:1, target_refresh:1;
    unsigned:0;
  } crm_flags;

  /** Generate a request message.
   *
   * @retval 1 when request message has been created
   * @retval 0 when request message should be created in normal fashion
   * @retval -1 upon an error
   */
  int (*crm_template)(nua_client_request_t *cr,
		      msg_t **return_msg,
		      tagi_t const *tags);

164
  /**@a crm_init is called when a client request is sent first time.
Pekka Pessi's avatar
Pekka Pessi committed
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
   *
   * @retval 1 when request has been responded
   * @retval 0 when request should be sent in normal fashion
   * @retval -1 upon an error
   */
  int (*crm_init)(nua_client_request_t *, msg_t *msg, sip_t *sip,
		  tagi_t const *tags);

  /** @a crm_send is called each time when a client request is sent.
   *
   * @retval 1 when request has been responded
   * @retval 0 when request has been sent
   * @retval -1 upon an error (request message has not been destroyed)
   * @retval -2 upon an error (request message has been destroyed)
   */
  int (*crm_send)(nua_client_request_t *,
		  msg_t *msg, sip_t *sip,
		  tagi_t const *tags);

  /** @a crm_check_restart is called each time when a response is received.
   *
   * It is used to restart reqquest after responses with method-specific
   * status code or method-specific way of restarting the request.
   *
   * @retval 1 when request has been restarted
   * @retval 0 when response should be processed normally
   */
  int (*crm_check_restart)(nua_client_request_t *,
			   int status, char const *phrase,
			   sip_t const *sip);

  /** @a crm_recv is called each time a final response is received.
   *
   * A final response is in range 200 .. 699 (or internal response) and it
   * cannot be restarted.
   *
   * crm_recv() should call nua_base_client_response() or
   * nua_base_client_tresponse(). The return values below are documented with
   * nua_base_client_response(), too.
   *
   * @retval 0 if response was preliminary
   * @retval 1 if response was final
   * @retval 2 if response destroyed the handle, too.
   */
  int (*crm_recv)(nua_client_request_t *,
		  int status, char const *phrase,
		  sip_t const *sip);

  /** @a crm_preliminary is called each time a preliminary response is received.
   *
   * A preliminary response is in range 101 .. 199.
   *
   * crm_preliminary() should call nua_base_client_response() or
   * nua_base_client_tresponse().
   *
   * @retval 0 if response was preliminary
   * @retval 1 if response was final
   * @retval 2 if response destroyed the handle, too.
   */
  int (*crm_preliminary)(nua_client_request_t *,
			 int status, char const *phrase,
			 sip_t const *sip);

  /** @a crm_report is called each time a response is received and it is
   * reported to the application.
   *
   * The status and phrase may be different from the status and phrase
   * received from the network, e.g., when the request is restarted.
   *
   * @return The return value should be 0. It is currently ignored.
   */
  int (*crm_report)(nua_client_request_t *,
		    int status, char const *phrase,
		    sip_t const *sip,
		    nta_outgoing_t *orq,
		    tagi_t const *tags);

242
  /** @a crm_complete is called when a client-side request is destroyed.
243 244 245
   *
   * @return The return value should be 0. It is currently ignored.
   */
246
  int (*crm_complete)(nua_client_request_t *);
247

Pekka Pessi's avatar
Pekka Pessi committed
248 249 250
} nua_client_methods_t;

/* Client-side request. Documented by nua_client_create() */
251 252
struct nua_client_request
{
Pekka Pessi's avatar
Pekka Pessi committed
253 254
  nua_client_request_t *cr_next, **cr_prev; /**< Linked list of requests */
  nua_owner_t        *cr_owner;
255
  nua_dialog_usage_t *cr_usage;
Pekka Pessi's avatar
Pekka Pessi committed
256

257
  nua_saved_signal_t cr_signal[1];
Pekka Pessi's avatar
Pekka Pessi committed
258 259 260 261 262 263 264 265 266
  tagi_t const      *cr_tags;

  nua_client_methods_t const *cr_methods;

  msg_t              *cr_msg;
  sip_t              *cr_sip;

  nta_outgoing_t     *cr_orq;

267 268
  su_timer_t         *cr_timer;	        /**< Expires or retry timer */

Pekka Pessi's avatar
Pekka Pessi committed
269 270 271 272 273 274
  /*nua_event_t*/ int cr_event;		/**< Request event */
  sip_method_t        cr_method;
  char const         *cr_method_name;

  url_t              *cr_target;

275
  char const         *cr_phrase;        /**< Latest status phrase */
Pekka Pessi's avatar
Pekka Pessi committed
276
  unsigned short      cr_status;        /**< Latest status */
277 278
  unsigned short      cr_retry_count;   /**< Retry count for this request */

279
  uint32_t            cr_seq;
280 281

  unsigned            cr_refs;	 /**< References to client request */
282

283
  /* Flags used with offer-answer */
284
  unsigned short      cr_answer_recv;   /**< Recv answer in response
285 286
					 *  with this status.
					 */
Pekka Pessi's avatar
Pekka Pessi committed
287 288 289 290 291
  unsigned cr_offer_sent:1;	/**< Sent offer in this request */

  unsigned cr_offer_recv:1;	/**< Recv offer in a response */
  unsigned cr_answer_sent:1;	/**< Sent answer in (PR)ACK */

292 293 294
  /* Flags with usage */
  unsigned cr_neutral:1;	/**< No effect on session or other usage */

Pekka Pessi's avatar
Pekka Pessi committed
295 296 297 298
  /* Lifelong flags? */
  unsigned cr_auto:1;		/**< Request was generated by stack */
  unsigned cr_has_contact:1;	/**< Request has user Contact */
  unsigned cr_contactize:1;	/**< Request needs Contact */
299
  unsigned cr_dialog:1;		/**< Request can initiate dialog */
Pekka Pessi's avatar
Pekka Pessi committed
300 301

  /* Current state */
302
  unsigned cr_acked:1;		/**< Final response to the request has been ACKed */
303
  unsigned cr_waiting:1;	/**< Request is waiting */
304 305
  unsigned cr_challenged:1;	/**< Request was challenged */
  unsigned cr_wait_for_cred:1;	/**< Request is pending authentication */
Pekka Pessi's avatar
Pekka Pessi committed
306 307 308
  unsigned cr_restarting:1;	/**< Request is being restarted */
  unsigned cr_reporting:1;	/**< Reporting in progress */
  unsigned cr_terminating:1;	/**< Request terminates the usage */
309
  signed int cr_terminated:2;	/**< Response terminated usage (1) or
Pekka Pessi's avatar
Pekka Pessi committed
310 311
				    whole dialog (-1) */
  unsigned cr_graceful:1;	/**< Graceful termination required */
312 313 314
};


315 316
struct nua_dialog_state
{
317 318 319
  /** Dialog owner */
  nua_owner_t            *ds_owner;

320 321 322
  /** Dialog usages. */
  nua_dialog_usage_t     *ds_usage;

Pekka Pessi's avatar
Pekka Pessi committed
323 324 325 326 327
  /** Client requests */
  nua_client_request_t   *ds_cr;
  /** Server requests */
  nua_server_request_t *ds_sr;

328
  /* Dialog and subscription state */
329 330
  unsigned ds_reporting:1;	/**< We are reporting */

331
  unsigned ds_route:1;		/**< We have route */
332
  unsigned ds_terminating:1;	/**< Being terminated */
333 334 335 336

  unsigned ds_has_session:1;	/**< We have session */
  unsigned ds_has_register:1;	/**< We have registration */
  unsigned ds_has_publish:1;	/**< We have publish */
337

338
  unsigned ds_got_session:1;	/**< We have (or have had) session */
Pekka Pessi's avatar
Pekka Pessi committed
339
  unsigned ds_got_referrals:1;	/**< We have (or have had) referrals */
340

341 342 343 344 345 346 347 348 349
  unsigned :0;

  unsigned ds_has_events;	/**< We have events */
  unsigned ds_has_subscribes;   /**< We have subscriptions */
  unsigned ds_has_notifys;	/**< We have notifiers */

  sip_from_t const *ds_local;		/**< Local address */
  sip_to_t const *ds_remote;		/**< Remote address */
  nta_leg_t      *ds_leg;
350
  sip_contact_t  *ds_ltarget;	        /**< Local target */
351 352
  char const     *ds_remote_tag;	/**< Remote tag (if any).
					 * Should be non-NULL
353 354
					 * if dialog is established.
					 */
355

356
  struct nua_dialog_peer_info {
357 358 359 360 361 362 363 364
    sip_allow_t      *nr_allow;
    sip_accept_t     *nr_accept;
    sip_require_t    *nr_require;
    sip_supported_t  *nr_supported;
    sip_user_agent_t *nr_user_agent;
  } ds_remote_ua[1];
};

Pekka Pessi's avatar
Pekka Pessi committed
365
/* Virtual function pointer table for dialog usage. */
366 367
typedef struct {
  unsigned usage_size, usage_class_size;
368
  int (*usage_add)(nua_owner_t *,
369 370
		   nua_dialog_state_t *ds,
		   nua_dialog_usage_t *du);
371
  void (*usage_remove)(nua_owner_t *,
372
		       nua_dialog_state_t *ds,
373 374 375
		       nua_dialog_usage_t *du,
		       nua_client_request_t *cr,
		       nua_server_request_t *sr);
376
  char const *(*usage_name)(nua_dialog_usage_t const *du);
377 378 379 380
  void (*usage_update_params)(nua_dialog_usage_t const *du,
			      nua_handle_preferences_t const *changed,
			      nua_handle_preferences_t const *params,
			      nua_handle_preferences_t const *defaults);
381 382 383
  void (*usage_peer_info)(nua_dialog_usage_t *du,
			  nua_dialog_state_t const *ds,
			  sip_t const *sip);
384 385
  void (*usage_refresh)(nua_owner_t *, nua_dialog_state_t *ds,
			nua_dialog_usage_t *, sip_time_t now);
386
  int (*usage_shutdown)(nua_owner_t *, nua_dialog_state_t *ds,
387
			nua_dialog_usage_t *);
388 389
} nua_usage_class;

390

Pekka Pessi's avatar
Pekka Pessi committed
391
/* Base structure for dialog usage. */
392 393 394
struct nua_dialog_usage {
  nua_dialog_usage_t *du_next;
  nua_usage_class const *du_class;
395
  nua_dialog_state_t *du_dialog;
Pekka Pessi's avatar
Pekka Pessi committed
396
  nua_client_request_t *du_cr;	        /**< Client request bound with usage */
397 398
  sip_time_t   du_refquested;	        /**< When refreshed was requested */
  sip_time_t   du_refresh;		/**< When to refresh */
399 400

  unsigned     du_ready:1;	        /**< Established usage */
Pekka Pessi's avatar
Pekka Pessi committed
401
  unsigned     du_shutdown:1;	        /**< Shutdown in progress */
402 403
  unsigned:0;

404 405 406 407 408
  /** When usage expires.
   * Non-zero if the usage is established, SIP_TIME_MAX if there no
   * expiration time.
   */

409
  sip_event_t const *du_event;		/**< Event of usage */
410

411 412
};

413 414 415 416 417 418
void nua_dialog_uac_route(nua_owner_t *, nua_dialog_state_t *ds,
			  sip_t const *sip, int rtag);
void nua_dialog_uas_route(nua_owner_t *, nua_dialog_state_t *ds,
			  sip_t const *sip, int rtag);
void nua_dialog_store_peer_info(nua_owner_t *, nua_dialog_state_t *ds,
				sip_t const *sip);
419 420
int nua_dialog_zap(nua_owner_t *own,
		   nua_dialog_state_t *ds);
421 422 423
int nua_dialog_remove(nua_owner_t *own,
		      nua_dialog_state_t *ds,
		      nua_dialog_usage_t *usage);
424

425
su_inline int nua_dialog_is_reporting(nua_dialog_state_t const *ds)
426 427 428 429
{
  return ds && ds->ds_reporting;
}

430 431
char const *nua_dialog_usage_name(nua_dialog_usage_t const *du);

432
nua_dialog_usage_t *nua_dialog_usage_add(nua_owner_t *,
433 434 435 436
					 struct nua_dialog_state *ds,
					 nua_usage_class const *uclass,
					 sip_event_t const *event);

437
nua_dialog_usage_t *nua_dialog_usage_get(nua_dialog_state_t const *ds,
438 439 440
					 nua_usage_class const *uclass,
					 sip_event_t const *event);

441
void nua_dialog_usage_remove(nua_owner_t *,
442
			     nua_dialog_state_t *ds,
443 444 445
			     nua_dialog_usage_t *du,
			     nua_client_request_t *cr,
			     nua_server_request_t *sr);
446

447 448 449 450 451 452 453 454 455 456
void nua_dialog_update_params(nua_dialog_state_t *ds,
			      nua_handle_preferences_t const *changed,
			      nua_handle_preferences_t const *params,
			      nua_handle_preferences_t const *defaults);

void nua_base_usage_update_params(nua_dialog_usage_t const *du,
				  nua_handle_preferences_t const *changed,
				  nua_handle_preferences_t const *params,
				  nua_handle_preferences_t const *defaults);

457 458 459
void nua_dialog_deinit(nua_owner_t *own,
		       nua_dialog_state_t *ds);

460 461
int nua_dialog_shutdown(nua_owner_t *owner, nua_dialog_state_t *ds);

462 463 464
int nua_dialog_repeat_shutdown(nua_owner_t *owner,
			       nua_dialog_state_t *ds);

465 466
void nua_dialog_usage_set_refresh(nua_dialog_usage_t *du, unsigned delta);

467
void nua_dialog_usage_set_refresh_range(nua_dialog_usage_t *du,
468
					unsigned min, unsigned max);
469

470
void nua_dialog_usage_set_refresh_at(nua_dialog_usage_t *du,
471
				     sip_time_t target);
472

473 474
void nua_dialog_usage_reset_refresh(nua_dialog_usage_t *du);

475
void nua_dialog_usage_refresh(nua_owner_t *owner,
476
			      nua_dialog_state_t *ds,
477
			      nua_dialog_usage_t *du,
478 479
			      sip_time_t now);

480 481 482
int nua_dialog_usage_shutdown(nua_owner_t *owner,
			      nua_dialog_state_t *ds,
			      nua_dialog_usage_t *du);
Pekka Pessi's avatar
Pekka Pessi committed
483

484
su_inline
485 486 487 488 489 490
int nua_dialog_is_established(nua_dialog_state_t const *ds)
{
  return ds->ds_remote_tag != NULL;
}

#if 0
491
su_inline
492 493
void *nua_dialog_usage_private(nua_dialog_usage_t const *du)
{
494 495 496
  return du ? (void *)(du + 1) : NULL;
}

497
su_inline
498 499 500
nua_dialog_usage_t *nua_dialog_usage_public(void const *p)
{
  return p ? (nua_dialog_usage_t *)p - 1 : NULL;
501 502
}
#else
503 504
#define nua_dialog_usage_private(du) ((du) ? (void*)((du) + 1) : NULL)
#define nua_dialog_usage_public(p) ((p) ? (nua_dialog_usage_t*)(p) - 1 : NULL)
505 506
#endif

507 508 509
#define NUA_DIALOG_USAGE_PRIVATE(du) ((void *)((du) + 1))
#define NUA_DIALOG_USAGE_PUBLIC(pu) ((void *)((nua_dialog_usage_t *)(pu) - 1))

510 511
/* ---------------------------------------------------------------------- */

Pekka Pessi's avatar
Pekka Pessi committed
512 513 514 515 516
int nua_client_create(nua_owner_t *owner,
		      int event,
		      nua_client_methods_t const *methods,
		      tagi_t const *tags);

517
int nua_client_tcreate(nua_owner_t *nh,
Pekka Pessi's avatar
Pekka Pessi committed
518 519 520 521
		       int event,
		       nua_client_methods_t const *methods,
		       tag_type_t tag, tag_value_t value, ...);

522
su_inline
Pekka Pessi's avatar
Pekka Pessi committed
523 524 525 526 527
void *nua_private_client_request(nua_client_request_t const *cr)
{
  return (void *)(cr + 1);
}

528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
nua_client_request_t *nua_client_request_ref(nua_client_request_t *);
int nua_client_request_unref(nua_client_request_t *);

#if HAVE_MEMLEAK_LOG

#define nua_client_request_ref(cr) \
  nua_client_request_ref_by((cr), __FILE__, __LINE__, __func__)
#define nua_client_request_unref(cr) \
  nua_client_request_unref_by((cr), __FILE__, __LINE__, __func__)

nua_client_request_t *nua_client_request_ref_by(nua_client_request_t *,
						char const *file, unsigned line,
						char const *who);
int nua_client_request_unref_by(nua_client_request_t *,
				char const *file, unsigned line, char const *who);

#endif
Pekka Pessi's avatar
Pekka Pessi committed
545 546 547

int nua_client_request_queue(nua_client_request_t *cr);

548
su_inline int nua_client_is_queued(nua_client_request_t const *cr)
Pekka Pessi's avatar
Pekka Pessi committed
549 550 551 552
{
  return cr && cr->cr_prev;
}

553 554
int nua_client_request_remove(nua_client_request_t *cr);
int nua_client_request_clean(nua_client_request_t *cr);
Pekka Pessi's avatar
Pekka Pessi committed
555 556
int nua_client_bind(nua_client_request_t *cr, nua_dialog_usage_t *du);

557
su_inline int nua_client_is_bound(nua_client_request_t const *cr)
Pekka Pessi's avatar
Pekka Pessi committed
558 559 560 561
{
  return cr && cr->cr_usage && cr->cr_usage->du_cr == cr;
}

562
su_inline int nua_client_is_reporting(nua_client_request_t const *cr)
Pekka Pessi's avatar
Pekka Pessi committed
563 564 565 566 567
{
  return cr && cr->cr_reporting;
}

/** Mark client request as a terminating one */
568
su_inline void nua_client_set_terminating(nua_client_request_t *cr, int value)
Pekka Pessi's avatar
Pekka Pessi committed
569
{
570
  cr->cr_terminating = value != 0;
Pekka Pessi's avatar
Pekka Pessi committed
571 572 573 574
}

int nua_client_init_request(nua_client_request_t *cr);

575 576
msg_t *nua_client_request_template(nua_client_request_t *cr);

577 578 579 580
int nua_client_restart_request(nua_client_request_t *cr,
			       int terminating,
			       tagi_t const *tags);

Pekka Pessi's avatar
Pekka Pessi committed
581
int nua_client_resend_request(nua_client_request_t *cr,
582
			      int terminating);
Pekka Pessi's avatar
Pekka Pessi committed
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638

int nua_base_client_request(nua_client_request_t *cr,
			    msg_t *msg,
			    sip_t *sip,
			    tagi_t const *tags);

int nua_base_client_trequest(nua_client_request_t *cr,
			     msg_t *msg,
			     sip_t *sip,
			     tag_type_t tag, tag_value_t value, ...);

extern nta_response_f nua_client_orq_response;

int nua_client_return(nua_client_request_t *cr,
		      int status,
		      char const *phrase,
		      msg_t *to_be_destroyed);

int nua_client_response(nua_client_request_t *cr,
			int status,
			char const *phrase,
			sip_t const *sip);

int nua_client_check_restart(nua_client_request_t *cr,
			     int status,
			     char const *phrase,
			     sip_t const *sip);

int nua_base_client_check_restart(nua_client_request_t *cr,
				  int status,
				  char const *phrase,
				  sip_t const *sip);

int nua_client_restart(nua_client_request_t *cr,
		       int status, char const *phrase);

int nua_base_client_response(nua_client_request_t *cr,
			     int status, char const *phrase,
			     sip_t const *sip,
			     tagi_t const *tags);

int nua_base_client_tresponse(nua_client_request_t *cr,
			      int status, char const *phrase,
			      sip_t const *sip,
			      tag_type_t tag, tag_value_t value, ...);

int nua_client_set_target(nua_client_request_t *cr, url_t const *target);

int nua_client_report(nua_client_request_t *cr,
		      int status, char const *phrase,
		      sip_t const *sip,
		      nta_outgoing_t *orq,
		      tagi_t const *tags);

nua_client_request_t *nua_client_request_pending(nua_client_request_t const *);

639
int nua_client_next_request(nua_client_request_t *cr, int invite);
640

Pekka Pessi's avatar
Pekka Pessi committed
641 642
/* ---------------------------------------------------------------------- */

643 644 645 646 647 648 649 650 651 652 653 654 655 656 657
extern nua_server_methods_t const
  nua_extension_server_methods,
  nua_invite_server_methods,	/**< INVITE */
  nua_bye_server_methods,	/**< BYE */
  nua_options_server_methods,	/**< OPTIONS */
  nua_register_server_methods,	/**< REGISTER */
  nua_info_server_methods,	/**< INFO */
  nua_prack_server_methods,	/**< PRACK */
  nua_update_server_methods,	/**< UPDATE */
  nua_message_server_methods,	/**< MESSAGE */
  nua_subscribe_server_methods, /**< SUBSCRIBE */
  nua_notify_server_methods,	/**< NOTIFY */
  nua_refer_server_methods,	/**< REFER */
  nua_publish_server_methods;	/**< PUBLISH */

658 659
/** Return true if we have not sent final response to request */
su_inline
660 661 662 663 664
int nua_server_request_is_pending(nua_server_request_t const *sr)
{
  return sr && sr->sr_response.msg;
}

665
su_inline
666 667 668 669 670
int nua_server_request_status(nua_server_request_t const *sr)
{
  return sr ? nta_incoming_status(sr->sr_irq) : 500;
}

671 672
void nua_server_request_destroy(nua_server_request_t *sr);

673
int nua_base_server_init(nua_server_request_t *sr);
674

675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694
#define nua_base_server_init NULL

int nua_base_server_preprocess(nua_server_request_t *sr);

#define nua_base_server_preprocess NULL

int nua_server_params(nua_server_request_t *sr, tagi_t const *tags);

int nua_base_server_params(nua_server_request_t *sr, tagi_t const *tags);

#define nua_base_server_params NULL

int nua_server_trespond(nua_server_request_t *sr,
			tag_type_t tag, tag_value_t value, ...);
int nua_server_respond(nua_server_request_t *sr, tagi_t const *tags);

int nua_base_server_trespond(nua_server_request_t *sr,
			     tag_type_t tag, tag_value_t value, ...);
int nua_base_server_respond(nua_server_request_t *sr,
			    tagi_t const *tags);
695

696
int nua_server_report(nua_server_request_t *sr);
697

698
int nua_base_server_treport(nua_server_request_t *sr,
699 700
			    tag_type_t tag, tag_value_t value, ...);
int nua_base_server_report(nua_server_request_t *sr, tagi_t const *tags);
701

Pekka Pessi's avatar
Pekka Pessi committed
702 703
/* ---------------------------------------------------------------------- */

704
#endif /* NUA_DIALOG_H */