2006-12-21 06:30:28 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**@CFILE nua_publish.c
|
|
|
|
* @brief PUBLISH and publications
|
|
|
|
*
|
|
|
|
* @sa @RFC3903
|
|
|
|
*
|
|
|
|
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
|
|
|
*
|
|
|
|
* @date Created: Wed Mar 8 17:01:32 EET 2006 ppessi
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
2009-02-11 16:49:25 +00:00
|
|
|
#include <sofia-sip/su_string.h>
|
2006-12-21 06:30:28 +00:00
|
|
|
#include <sofia-sip/sip_protos.h>
|
|
|
|
#include <sofia-sip/sip_status.h>
|
|
|
|
|
|
|
|
#include "nua_stack.h"
|
|
|
|
|
|
|
|
/* ====================================================================== */
|
|
|
|
/* Publish usage */
|
|
|
|
|
|
|
|
struct publish_usage {
|
|
|
|
sip_etag_t *pu_etag;
|
2007-04-15 02:03:41 +00:00
|
|
|
int pu_published;
|
2006-12-21 06:30:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static char const *nua_publish_usage_name(nua_dialog_usage_t const *du);
|
|
|
|
static int nua_publish_usage_add(nua_handle_t *nh,
|
|
|
|
nua_dialog_state_t *ds,
|
|
|
|
nua_dialog_usage_t *du);
|
|
|
|
static void nua_publish_usage_remove(nua_handle_t *nh,
|
2008-03-07 17:41:29 +00:00
|
|
|
nua_dialog_state_t *ds,
|
|
|
|
nua_dialog_usage_t *du,
|
|
|
|
nua_client_request_t *cr,
|
|
|
|
nua_server_request_t *sr);
|
2006-12-21 06:30:28 +00:00
|
|
|
static void nua_publish_usage_refresh(nua_handle_t *nh,
|
|
|
|
nua_dialog_state_t *ds,
|
|
|
|
nua_dialog_usage_t *du,
|
|
|
|
sip_time_t now);
|
|
|
|
static int nua_publish_usage_shutdown(nua_handle_t *nh,
|
|
|
|
nua_dialog_state_t *ds,
|
|
|
|
nua_dialog_usage_t *du);
|
|
|
|
|
|
|
|
static nua_usage_class const nua_publish_usage[1] = {
|
|
|
|
{
|
|
|
|
sizeof (struct publish_usage),
|
|
|
|
sizeof nua_publish_usage,
|
|
|
|
nua_publish_usage_add,
|
|
|
|
nua_publish_usage_remove,
|
|
|
|
nua_publish_usage_name,
|
2008-05-13 19:10:47 +00:00
|
|
|
nua_base_usage_update_params,
|
2006-12-21 06:30:28 +00:00
|
|
|
NULL,
|
|
|
|
nua_publish_usage_refresh,
|
|
|
|
nua_publish_usage_shutdown,
|
|
|
|
}};
|
|
|
|
|
|
|
|
static
|
|
|
|
char const *nua_publish_usage_name(nua_dialog_usage_t const *du)
|
|
|
|
{
|
|
|
|
return "publish";
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
int nua_publish_usage_add(nua_handle_t *nh,
|
|
|
|
nua_dialog_state_t *ds,
|
|
|
|
nua_dialog_usage_t *du)
|
|
|
|
{
|
|
|
|
if (ds->ds_has_publish)
|
|
|
|
return -1; /* There can be only one */
|
|
|
|
ds->ds_has_publish = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
void nua_publish_usage_remove(nua_handle_t *nh,
|
2008-03-07 17:41:29 +00:00
|
|
|
nua_dialog_state_t *ds,
|
|
|
|
nua_dialog_usage_t *du,
|
|
|
|
nua_client_request_t *cr,
|
|
|
|
nua_server_request_t *sr
|
|
|
|
)
|
2006-12-21 06:30:28 +00:00
|
|
|
{
|
2008-05-25 13:52:27 +00:00
|
|
|
struct publish_usage *pu = NUA_DIALOG_USAGE_PRIVATE(du);
|
2006-12-21 06:30:28 +00:00
|
|
|
|
|
|
|
su_free(nh->nh_home, pu->pu_etag);
|
|
|
|
|
|
|
|
ds->ds_has_publish = 0; /* There can be only one */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ======================================================================== */
|
|
|
|
/* PUBLISH */
|
|
|
|
|
|
|
|
/**@fn \
|
|
|
|
* void nua_publish(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
|
|
|
|
*
|
|
|
|
* Send PUBLISH request to publication server.
|
|
|
|
*
|
|
|
|
* Request status will be delivered to the application using #nua_r_publish
|
|
|
|
* event. When successful the publication will be updated periodically until
|
|
|
|
* nua_unpublish() is called or handle is destroyed. Note that the periodic
|
|
|
|
* updates and unpublish do not include the original message body nor the @b
|
|
|
|
* Content-Type header. Instead, the periodic update will include the
|
|
|
|
* @SIPIfMatch header, which was generated from the latest @SIPETag
|
|
|
|
* header received in response to @b PUBLISH request.
|
|
|
|
*
|
|
|
|
* The handle used for publication cannot be used for any other purposes.
|
|
|
|
*
|
|
|
|
* @param nh Pointer to operation handle
|
|
|
|
* @param tag, value, ... List of tagged parameters
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* nothing
|
|
|
|
*
|
|
|
|
* @par Related Tags:
|
|
|
|
* NUTAG_URL() \n
|
|
|
|
* Tags of nua_set_hparams() \n
|
2007-08-06 19:24:10 +00:00
|
|
|
* Header tags defined in <sofia-sip/sip_tag.h>
|
2006-12-21 06:30:28 +00:00
|
|
|
*
|
|
|
|
* @par Events:
|
|
|
|
* #nua_r_publish
|
|
|
|
*
|
|
|
|
* @sa #nua_r_publish, @RFC3903, @SIPIfMatch,
|
|
|
|
* nua_unpublish(), #nua_r_unpublish, #nua_i_publish
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @NUA_EVENT nua_r_publish
|
|
|
|
*
|
|
|
|
* Response to an outgoing PUBLISH.
|
|
|
|
*
|
|
|
|
* The PUBLISH request may be sent explicitly by nua_publish() or implicitly
|
|
|
|
* by NUA state machine.
|
|
|
|
*
|
|
|
|
* @param status status code of PUBLISH request
|
|
|
|
* (if the request is retried, @a status is 100, the @a
|
|
|
|
* sip->sip_status->st_status contain the real status code
|
|
|
|
* from the response message, e.g., 302, 401, or 407)
|
|
|
|
* @param phrase a short textual description of @a status code
|
|
|
|
* @param nh operation handle associated with the publication
|
|
|
|
* @param hmagic application context associated with the handle
|
|
|
|
* @param sip response to PUBLISH request or NULL upon an error
|
2008-12-16 18:05:22 +00:00
|
|
|
* (status code is in @a status and
|
2006-12-21 06:30:28 +00:00
|
|
|
* descriptive message in @a phrase parameters)
|
|
|
|
* @param tags empty
|
|
|
|
*
|
|
|
|
* @sa nua_publish(), @RFC3903, @SIPETag, @Expires,
|
|
|
|
* nua_unpublish(), #nua_r_unpublish, #nua_i_publish
|
|
|
|
*
|
|
|
|
* @END_NUA_EVENT
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**@fn \
|
|
|
|
void nua_unpublish(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...);
|
|
|
|
*
|
|
|
|
* Send un-PUBLISH request to publication server. Un-PUBLISH request is just
|
|
|
|
* a PUBLISH request with @Expires set to 0. It is possible to un-publish a
|
|
|
|
* publication not associated with the handle by providing correct ETag in
|
|
|
|
* SIPTAG_IF_MATCH() or SIPTAG_IF_MATCH_STR() tags.
|
|
|
|
*
|
|
|
|
* Response to the un-PUBLISH request will be delivered to the application
|
|
|
|
* using #nua_r_unpublish event.
|
|
|
|
*
|
|
|
|
* The handle used for publication cannot be used for any other purposes.
|
|
|
|
*
|
|
|
|
* @param nh Pointer to operation handle
|
|
|
|
* @param tag, value, ... List of tagged parameters
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* nothing
|
|
|
|
*
|
|
|
|
* @par Related Tags:
|
|
|
|
* NUTAG_URL() \n
|
|
|
|
* SIPTAG_IF_MATCH(), SIPTAG_IF_MATCH_STR() \n
|
|
|
|
* SIPTAG_EVENT(), SIPTAG_EVENT_STR() \n
|
|
|
|
* Tags of nua_set_hparams() \n
|
2007-08-06 19:24:10 +00:00
|
|
|
* Other header tags defined in <sofia-sip/sip_tag.h> except SIPTAG_EXPIRES() or SIPTAG_EXPIRES_STR()
|
2006-12-21 06:30:28 +00:00
|
|
|
*
|
|
|
|
* @par Events:
|
|
|
|
* #nua_r_unpublish
|
2008-12-16 18:05:22 +00:00
|
|
|
*
|
|
|
|
* @sa #nua_r_unpublish, @RFC3903, @SIPIfMatch,
|
2006-12-21 06:30:28 +00:00
|
|
|
* #nua_i_publish, nua_publish(), #nua_r_publish
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @NUA_EVENT nua_r_unpublish
|
|
|
|
*
|
|
|
|
* Response to an outgoing un-PUBLISH.
|
|
|
|
*
|
|
|
|
* @param status response status code
|
|
|
|
* (if the request is retried, @a status is 100, the @a
|
|
|
|
* sip->sip_status->st_status contain the real status code
|
|
|
|
* from the response message, e.g., 302, 401, or 407)
|
|
|
|
* @param phrase a short textual description of @a status code
|
|
|
|
* @param nh operation handle associated with the publication
|
|
|
|
* @param hmagic application context associated with the handle
|
|
|
|
* @param sip response to PUBLISH request or NULL upon an error
|
2008-12-16 18:05:22 +00:00
|
|
|
* (status code is in @a status and
|
2006-12-21 06:30:28 +00:00
|
|
|
* descriptive message in @a phrase parameters)
|
|
|
|
* @param tags empty
|
|
|
|
*
|
|
|
|
* @sa nua_unpublish(), @RFC3903, @SIPETag, @Expires,
|
|
|
|
* nua_publish(), #nua_r_publish, #nua_i_publish
|
|
|
|
*
|
|
|
|
* @END_NUA_EVENT
|
|
|
|
*/
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
static int nua_publish_client_template(nua_client_request_t *cr,
|
|
|
|
msg_t **return_msg,
|
|
|
|
tagi_t const *tags);
|
|
|
|
static int nua_publish_client_init(nua_client_request_t *cr,
|
|
|
|
msg_t *, sip_t *,
|
|
|
|
tagi_t const *tags);
|
|
|
|
static int nua_publish_client_request(nua_client_request_t *cr,
|
|
|
|
msg_t *, sip_t *,
|
|
|
|
tagi_t const *tags);
|
2007-04-19 19:17:12 +00:00
|
|
|
static int nua_publish_client_check_restart(nua_client_request_t *cr,
|
|
|
|
int status, char const *phrase,
|
|
|
|
sip_t const *sip);
|
2007-04-15 02:03:41 +00:00
|
|
|
static int nua_publish_client_response(nua_client_request_t *cr,
|
|
|
|
int status, char const *phrase,
|
|
|
|
sip_t const *sip);
|
|
|
|
|
|
|
|
static nua_client_methods_t const nua_publish_client_methods = {
|
2008-03-07 17:34:46 +00:00
|
|
|
SIP_METHOD_PUBLISH, /* crm_method, crm_method_name */
|
|
|
|
0, /* crm_extra */
|
|
|
|
{ /* crm_flags */
|
2007-04-15 02:03:41 +00:00
|
|
|
/* create_dialog */ 0,
|
|
|
|
/* in_dialog */ 0,
|
|
|
|
/* target refresh */ 0
|
|
|
|
},
|
2008-03-07 17:34:46 +00:00
|
|
|
nua_publish_client_template, /* crm_template */
|
|
|
|
nua_publish_client_init, /* crm_init */
|
|
|
|
nua_publish_client_request, /* crm_send */
|
|
|
|
nua_publish_client_check_restart, /* crm_check_restart */
|
|
|
|
nua_publish_client_response, /* crm_recv */
|
|
|
|
NULL, /* crm_preliminary */
|
|
|
|
NULL, /* crm_report */
|
|
|
|
NULL, /* crm_complete */
|
2007-04-15 02:03:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**@internal Send PUBLISH. */
|
|
|
|
int nua_stack_publish(nua_t *nua,
|
|
|
|
nua_handle_t *nh,
|
|
|
|
nua_event_t e,
|
|
|
|
tagi_t const *tags)
|
2006-12-21 06:30:28 +00:00
|
|
|
{
|
2007-04-15 02:03:41 +00:00
|
|
|
return nua_client_create(nh, e, &nua_publish_client_methods, tags);
|
2006-12-21 06:30:28 +00:00
|
|
|
}
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
static int nua_publish_client_template(nua_client_request_t *cr,
|
|
|
|
msg_t **return_msg,
|
|
|
|
tagi_t const *tags)
|
2006-12-21 06:30:28 +00:00
|
|
|
{
|
|
|
|
nua_dialog_usage_t *du;
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
if (cr->cr_event == nua_r_publish)
|
|
|
|
return 0;
|
2006-12-21 06:30:28 +00:00
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
du = nua_dialog_usage_get(cr->cr_owner->nh_ds, nua_publish_usage, NULL);
|
|
|
|
if (du && du->du_cr) {
|
|
|
|
if (nua_client_set_target(cr, du->du_cr->cr_target) < 0)
|
|
|
|
return -1;
|
|
|
|
*return_msg = msg_copy(du->du_cr->cr_msg);
|
|
|
|
return 1;
|
2006-12-21 06:30:28 +00:00
|
|
|
}
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2007-02-07 21:59:38 +00:00
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
static int nua_publish_client_init(nua_client_request_t *cr,
|
|
|
|
msg_t *msg, sip_t *sip,
|
|
|
|
tagi_t const *tags)
|
|
|
|
{
|
|
|
|
nua_handle_t *nh = cr->cr_owner;
|
|
|
|
nua_dialog_usage_t *du;
|
|
|
|
struct publish_usage *pu;
|
|
|
|
|
|
|
|
if (cr->cr_event == nua_r_publish) {
|
2007-02-17 06:25:21 +00:00
|
|
|
du = nua_dialog_usage_add(nh, nh->nh_ds, nua_publish_usage, NULL);
|
2007-04-15 02:03:41 +00:00
|
|
|
if (!du)
|
|
|
|
return -1;
|
|
|
|
pu = nua_dialog_usage_private(du);
|
|
|
|
pu->pu_published = 0;
|
|
|
|
if (sip->sip_if_match) {
|
|
|
|
pu->pu_etag = sip_etag_dup(nh->nh_home, sip->sip_if_match);
|
|
|
|
if (!pu->pu_etag)
|
|
|
|
return -1;
|
|
|
|
sip_header_remove(msg, sip, (sip_header_t *)sip->sip_if_match);
|
|
|
|
}
|
|
|
|
}
|
2006-12-21 06:30:28 +00:00
|
|
|
else
|
|
|
|
du = nua_dialog_usage_get(nh->nh_ds, nua_publish_usage, NULL);
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
cr->cr_usage = du;
|
2006-12-21 06:30:28 +00:00
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2007-02-17 06:25:21 +00:00
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
static
|
|
|
|
int nua_publish_client_request(nua_client_request_t *cr,
|
|
|
|
msg_t *msg, sip_t *sip,
|
|
|
|
tagi_t const *tags)
|
|
|
|
{
|
|
|
|
nua_dialog_usage_t *du = cr->cr_usage;
|
|
|
|
int un, done;
|
|
|
|
sip_etag_t const *etag = NULL;
|
2006-12-21 06:30:28 +00:00
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
un = cr->cr_terminating ||
|
|
|
|
cr->cr_event != nua_r_publish ||
|
|
|
|
(du && du->du_shutdown) ||
|
2007-02-17 06:25:21 +00:00
|
|
|
(sip->sip_expires && sip->sip_expires->ex_delta == 0);
|
2008-09-03 18:32:12 +00:00
|
|
|
nua_client_set_terminating(cr, un);
|
2007-04-15 02:03:41 +00:00
|
|
|
done = un;
|
2006-12-21 06:30:28 +00:00
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
if (du) {
|
|
|
|
struct publish_usage *pu = nua_dialog_usage_private(du);
|
2007-02-17 06:25:21 +00:00
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
if (nua_client_bind(cr, du) < 0)
|
|
|
|
return -1;
|
|
|
|
if (pu->pu_published)
|
|
|
|
done = 1;
|
|
|
|
etag = pu->pu_etag;
|
|
|
|
}
|
2007-02-17 06:25:21 +00:00
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
return nua_base_client_trequest(cr, msg, sip,
|
|
|
|
SIPTAG_IF_MATCH(etag),
|
|
|
|
TAG_IF(done, SIPTAG_PAYLOAD(NONE)),
|
|
|
|
TAG_IF(done, SIPTAG_CONTENT_TYPE(NONE)),
|
|
|
|
TAG_IF(un, SIPTAG_EXPIRES_STR("0")),
|
|
|
|
TAG_NEXT(tags));
|
2007-02-17 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2007-04-19 19:17:12 +00:00
|
|
|
static int nua_publish_client_check_restart(nua_client_request_t *cr,
|
|
|
|
int status, char const *phrase,
|
|
|
|
sip_t const *sip)
|
|
|
|
{
|
|
|
|
char const *restarting = NULL;
|
|
|
|
|
|
|
|
if (cr->cr_terminating || !cr->cr_usage)
|
|
|
|
;
|
|
|
|
else if (status == 412)
|
|
|
|
restarting = phrase;
|
2008-12-16 18:05:22 +00:00
|
|
|
else if (200 <= status && status < 300 &&
|
2007-04-19 19:17:12 +00:00
|
|
|
sip->sip_expires && sip->sip_expires->ex_delta == 0)
|
|
|
|
restarting = "Immediate re-PUBLISH";
|
|
|
|
|
|
|
|
if (restarting) {
|
|
|
|
struct publish_usage *pu = nua_dialog_usage_private(cr->cr_usage);
|
|
|
|
|
|
|
|
if (pu) {
|
|
|
|
pu->pu_published = 0;
|
|
|
|
su_free(cr->cr_owner->nh_home, pu->pu_etag), pu->pu_etag = NULL;
|
|
|
|
if (nua_client_restart(cr, 100, restarting))
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nua_base_client_check_restart(cr, status, phrase, sip);
|
|
|
|
}
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
static int nua_publish_client_response(nua_client_request_t *cr,
|
|
|
|
int status, char const *phrase,
|
|
|
|
sip_t const *sip)
|
2007-02-17 06:25:21 +00:00
|
|
|
{
|
2007-04-15 02:03:41 +00:00
|
|
|
nua_handle_t *nh = cr->cr_owner;
|
2006-12-21 06:30:28 +00:00
|
|
|
nua_dialog_usage_t *du = cr->cr_usage;
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
if (!cr->cr_terminated && du && sip) {
|
|
|
|
struct publish_usage *pu = nua_dialog_usage_private(du);
|
|
|
|
sip_expires_t const *ex = sip->sip_expires;
|
2006-12-21 06:30:28 +00:00
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
/* Reset state */
|
|
|
|
pu->pu_published = 0;
|
|
|
|
if (pu->pu_etag)
|
|
|
|
su_free(nh->nh_home, pu->pu_etag), pu->pu_etag = NULL;
|
2006-12-21 06:30:28 +00:00
|
|
|
|
2007-04-19 19:17:12 +00:00
|
|
|
if (status < 300) {
|
2007-04-15 02:03:41 +00:00
|
|
|
pu->pu_published = 1;
|
2006-12-21 06:30:28 +00:00
|
|
|
pu->pu_etag = sip_etag_dup(nh->nh_home, sip->sip_etag);
|
2007-04-15 02:03:41 +00:00
|
|
|
|
|
|
|
if (!ex || ex->ex_delta == 0 || !pu->pu_etag) {
|
|
|
|
cr->cr_terminated = 1;
|
|
|
|
|
|
|
|
if (!ex || ex->ex_delta == 0)
|
|
|
|
SET_STATUS(900, "Received Invalid Expiration Time");
|
|
|
|
else
|
2012-06-25 06:20:16 +00:00
|
|
|
SET_STATUS(900, _NUA_INTERNAL_ERROR_AT(__FILE__, __LINE__));
|
2007-04-15 02:03:41 +00:00
|
|
|
}
|
2007-04-19 19:17:12 +00:00
|
|
|
else
|
|
|
|
nua_dialog_usage_set_refresh(du, ex->ex_delta);
|
2006-12-21 06:30:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
return nua_base_client_response(cr, status, phrase, sip, NULL);
|
2006-12-21 06:30:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void nua_publish_usage_refresh(nua_handle_t *nh,
|
2007-04-15 02:03:41 +00:00
|
|
|
nua_dialog_state_t *ds,
|
|
|
|
nua_dialog_usage_t *du,
|
|
|
|
sip_time_t now)
|
2006-12-21 06:30:28 +00:00
|
|
|
{
|
2007-04-15 02:03:41 +00:00
|
|
|
nua_client_request_t *cr = du->du_cr;
|
|
|
|
|
|
|
|
if (cr) {
|
|
|
|
if (nua_client_resend_request(cr, 0) >= 0)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nua_stack_event(nh->nh_nua, nh, NULL,
|
merge to sofia sip darcs tree. Includes multiple fixes and several merges of changes from the freeswitch tree back to darcs as follows:
Mon Nov 19 22:05:07 EST 2007 Pekka Pessi <first.lastname@nokia.com>
* test_htable2.c: define struct before using it in prototypes
Fri Jan 11 09:12:01 EST 2008 Bernhard Suttner <suttner at comdasys.com>
* Using # in SOATAG_HOLD to set media as inactive instead of sendonly
Fri Jan 11 09:15:18 EST 2008 Pekka.Pessi@nokia.com
* soa_tag.c: documented SOATAG_HOLD() inactive mode
Fri Jan 11 09:28:46 EST 2008 Pekka.Pessi@nokia.com
* su_addrinfo.c: if su_getaddrinfo() service is NULL, try both with "0" and NULL
Fri Jan 11 09:30:23 EST 2008 Pekka.Pessi@nokia.com
* Makefile.am: added tests to DIST_SUBDIRS
Fri Jan 11 12:11:12 EST 2008 Pekka.Pessi@nokia.com
* nta.c: NetModule hack re-prioritizing SRV records
Original hack by Stefan Leuenberger <Stefan.Leuenberger@netmodule.com>.
The hack reprioritizes the SRV records used with transaction in case a
server refuses connection or it does not answer.
Fri Jan 11 12:12:23 EST 2008 Pekka.Pessi@nokia.com
* sres.c, sres_cache.c: NetModule hack for re-prioritizing SRV records
Original hack by Stefan Leuenberger <Stefan.Leuenberger@netmodule.com>.
The hack reprioritizes the SRV records used with transaction in case a
server refuses connection or it does not answer.
New functions sres_cache_set_srv_priority() and
sres_set_cached_srv_priority().
Fri Jan 11 12:15:19 EST 2008 Pekka.Pessi@nokia.com
* Makefile.am: fixed dist target
Fri Jan 11 12:19:33 EST 2008 Pekka.Pessi@nokia.com
* tport_internal.h: grammar in doc
Mon Jan 14 06:59:17 EST 2008 Pekka.Pessi@nokia.com
* su.h: IPv6 fix for Vista SDK
Patch by Michael Jerris
Wed Jan 16 13:20:47 EST 2008 Pekka.Pessi@nokia.com
* nua: fix sf.net bug #1867753 (avoid duplicating initial route set)
Thu Jan 17 07:48:10 EST 2008 Pekka.Pessi@nokia.com
* sres.c, sres_cache.c: documented sres_set_cached_srv_priority(), sres_cache_set_srv_priority()
Thu Jan 17 07:51:32 EST 2008 Pekka.Pessi@nokia.com
* sofia-sip/su_wait.h, su_port.h, su_root.c: documented new functions and types for 1.12.8
Thu Jan 17 07:52:03 EST 2008 Pekka.Pessi@nokia.com
* sofia-sip/htable2.h: marked new features for release 1.12.8
Thu Jan 17 07:52:33 EST 2008 Pekka.Pessi@nokia.com
* su_alloc.c: marked new features for release 1.12.8.
Thu Jan 17 07:53:01 EST 2008 Pekka.Pessi@nokia.com
* AUTHORS: updated
Thu Jan 17 07:53:21 EST 2008 Pekka.Pessi@nokia.com
* RELEASE: added new features and bug fixes since 1.12.7
Thu Jan 17 07:55:18 EST 2008 Pekka.Pessi@nokia.com
* libsofia-sip-ua/docs/Doxyfile.aliases: added @NEW_1_12_8 and @VERSION_1_12_8
Thu Jan 17 09:48:48 EST 2008 Pekka Pessi <Pekka.Pessi@nokia.com>
* autogen.sh: use automake 1.9 unless otherwise specified
Thu Jan 17 11:40:46 EST 2008 Pekka Pessi <Pekka.Pessi@nokia.com>
* soa_static.c: cleaned inactive hold, added tests
Thu Jan 17 11:41:54 EST 2008 Pekka Pessi <Pekka.Pessi@nokia.com>
* Makefile.am: added hide_emails.sh to dist
Thu Jan 17 11:42:35 EST 2008 Pekka Pessi <Pekka.Pessi@nokia.com>
* nua_stack.c: removed noisy debug message from nua_client_request_sendmsg()
Fri Jan 18 11:06:10 EST 2008 Pekka.Pessi@nokia.com
* nua: Added NUA_ERROR_AT() macro
Made internally generated 900 (and 904) response phrases unique as suggested
by Jerry Richards.
Mon Jan 21 10:39:50 EST 2008 Stefan Knoblich
* TLS debug cleanup
Mon Jan 21 12:05:38 EST 2008 Pekka.Pessi@nokia.com
* tport: build fixes from Freeswitch
Mon Jan 21 12:14:25 EST 2008 Pekka.Pessi@nokia.com
* su_global_log.c: disable warning on SU_DEBUG[] (Doxygen-only variable)
Patch from Michael Jerris.
Mon Jan 21 12:15:19 EST 2008 Pekka.Pessi@nokia.com
* sres.c: default log level to the same as SU_DEBUG define
Patch by Michael Jerris
Mon Jan 21 12:16:39 EST 2008 Pekka.Pessi@nokia.com
* stun.c: default log level to the same as SU_DEBUG define
Patch by Michael Jerris
Mon Jan 21 12:45:04 EST 2008 Stefan Knoblich
* TLS debug cleanup, 2/2.
Silence openssl messages, part 2 of 2. Changed to TPORT_DEBUG=1 (thanks
MikeJ). This one converts all ERR_print_errors() calls
Mon Jan 21 13:00:49 EST 2008 Pekka.Pessi@nokia.com
* nua: removed asserts() on hairy dialog/request handling cases
Mon Jan 21 14:06:35 EST 2008 Pekka.Pessi@nokia.com
* soa.c: using session state in soa_set_activity()
The media mode bits are set using (local) session description instead of
remote offer/answer when O/A has been completed.
Mon Jan 21 14:08:08 EST 2008 Pekka.Pessi@nokia.com
* soa_static.c: soa_sdp_mode_set() now includes wanted media state in offer
The wanted media state is based on original user SDP and SOATAG_HOLD()
content. Removed soa_sdp_mode_set_is_needed(), using dry-run parameter
instead.
Mon Jan 21 14:09:11 EST 2008 Pekka.Pessi@nokia.com
* nua_subnotref.c: fixed REFER re-try case
REFER trashed its dialog when it got retried if there was no other dialog
usages.
Mon Jan 21 14:20:31 EST 2008 Pekka.Pessi@nokia.com
* nua_stack.c: return specific error phrases from nua_client_init_request()
As suggested by Jerry Richards.
Tue Jan 22 11:15:04 EST 2008 Pekka.Pessi@nokia.com
* sip_util.c: updated sip_response_terminates_dialog() as per RFC 5057.
Changes handling of 423 in case of SUBSCRIBE.
Tue Jan 22 11:34:01 EST 2008 Pekka.Pessi@nokia.com
* conformance.docs: added RFC 5057 (sipping-dialogusage)
Tue Jan 22 11:34:16 EST 2008 Pekka.Pessi@nokia.com
* test_auth_digest.c: testing empty realm
Tue Jan 22 11:35:44 EST 2008 Pekka.Pessi@nokia.com
* test_soa.c: testing hold with inactive, offered mode and setting remote activity flags while in hold
Tue Jan 22 12:27:41 EST 2008 Pekka.Pessi@nokia.com
* nta.c: fixed memory corruption in case sending ACK failed
Thanks for Fabio Margarido for reporting this problem.
Tue Jan 22 12:49:02 EST 2008 Pekka.Pessi@nokia.com
* nua/test_refer.c: run test_challenge_refer() only if we use proxy
Test case is now more deterministic, too.
Tue Jan 22 12:51:59 EST 2008 Pekka.Pessi@nokia.com
* docs/Makefile.am, docs/conformance.docs: fixed links to RFC 5057.
Tue Jan 22 13:57:38 EST 2008 Pekka.Pessi@nokia.com
* sres: added ttl parameter to sres_set_cached_srv_priority() and sres_cache_set_srv_priority().
Tue Jan 22 13:59:44 EST 2008 Pekka.Pessi@nokia.com
* nta.c: added NTATAG_GRAYLIST().
Use NTATAG_GRAYLIST() as ttl value for sres_set_cached_srv_priority().
Tue Jan 22 14:04:29 EST 2008 Pekka.Pessi@nokia.com
* RELEASE: updated.
Tue Jan 22 14:04:29 EST 2008 Pekka.Pessi@nokia.com
* RELEASE: updated.
Wed Jan 23 06:56:11 EST 2008 Pekka.Pessi@nokia.com
* sip_extra.c, sip_parser.c: updated documentation
Wed Jan 23 09:47:50 EST 2008 Pekka.Pessi@nokia.com
* test_nta.c: fixed receiving with sink socket
Wed Jan 23 10:07:30 EST 2008 Pekka Pessi <Pekka.Pessi@nokia.com>
* soa_static.c: fixed signedness error
Wed Jan 23 10:11:14 EST 2008 Pekka Pessi <Pekka.Pessi@nokia.com>
* win32 project files: fixed slash direction
Wed Jan 23 10:13:00 EST 2008 Pekka Pessi <Pekka.Pessi@nokia.com>
* torture_su.c: set blocking on
Wed Jan 23 10:13:36 EST 2008 Pekka Pessi <Pekka.Pessi@nokia.com>
* test_tport.c: using blocking sockets in test_incomplete()
Wed Jan 23 11:01:11 EST 2008 Pekka.Pessi@nokia.com
* nta.c: now using RFC3261-compliant dialog-matching
Wed Jan 23 11:05:23 EST 2008 Pekka.Pessi@nokia.com
* nta.c: ignore tags in nta_leg_by_dialog() if they are empty strings
Wed Jan 23 11:05:58 EST 2008 Pekka.Pessi@nokia.com
* nta.c: asserting in proper place when handling queue tail
Wed Jan 23 12:11:09 EST 2008 Pekka.Pessi@nokia.com
* torture_sip.c: added tests for accessing other extra headers beside P-Asserted-Identity/P-Preferred-Identity
Wed Jan 23 13:08:55 EST 2008 Pekka.Pessi@nokia.com
* nua: terminate dialog when redirected and re-establish it with new request
Wed Jan 23 13:18:16 EST 2008 Pekka.Pessi@nokia.com
* test_100rel.c: added test for redirect after 100rel response.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7328 d0543943-73ff-0310-b7d9-9358b9ac24b2
2008-01-23 18:37:33 +00:00
|
|
|
nua_r_publish, NUA_ERROR_AT(__FILE__, __LINE__),
|
2007-04-15 02:03:41 +00:00
|
|
|
NULL);
|
|
|
|
|
2008-03-07 17:41:29 +00:00
|
|
|
nua_dialog_usage_remove(nh, ds, du, NULL, NULL);
|
2006-12-21 06:30:28 +00:00
|
|
|
}
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
/** @interal Shut down PUBLISH usage.
|
2006-12-21 06:30:28 +00:00
|
|
|
*
|
|
|
|
* @retval >0 shutdown done
|
|
|
|
* @retval 0 shutdown in progress
|
|
|
|
* @retval <0 try again later
|
|
|
|
*/
|
|
|
|
static int nua_publish_usage_shutdown(nua_handle_t *nh,
|
2007-04-15 02:03:41 +00:00
|
|
|
nua_dialog_state_t *ds,
|
|
|
|
nua_dialog_usage_t *du)
|
2006-12-21 06:30:28 +00:00
|
|
|
{
|
2007-04-15 02:03:41 +00:00
|
|
|
nua_client_request_t *cr = du->du_cr;
|
2006-12-21 06:30:28 +00:00
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
if (cr) {
|
|
|
|
if (nua_client_resend_request(cr, 1) >= 0)
|
|
|
|
return 0;
|
2007-02-07 21:59:38 +00:00
|
|
|
}
|
2006-12-21 06:30:28 +00:00
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
/* XXX - report to user */
|
2008-03-07 17:41:29 +00:00
|
|
|
nua_dialog_usage_remove(nh, ds, du, NULL, NULL);
|
2007-04-15 02:03:41 +00:00
|
|
|
return 200;
|
2006-12-21 06:30:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
/* Server side */
|
|
|
|
|
|
|
|
/** @NUA_EVENT nua_i_publish
|
|
|
|
*
|
|
|
|
* Incoming PUBLISH request.
|
|
|
|
*
|
|
|
|
* In order to receive #nua_i_publish events, the application must enable
|
|
|
|
* both the PUBLISH method with NUTAG_ALLOW() tag and the acceptable SIP
|
2008-12-16 18:05:22 +00:00
|
|
|
* events with nua_set_params() tag NUTAG_ALLOW_EVENTS().
|
2006-12-21 06:30:28 +00:00
|
|
|
*
|
|
|
|
* The nua_response() call responding to a PUBLISH request must have
|
2007-04-15 02:03:41 +00:00
|
|
|
* NUTAG_WITH() (or NUTAG_WITH_THIS()/NUTAG_WITH_SAVED()) tag. Note that
|
2006-12-21 06:30:28 +00:00
|
|
|
* a successful response to PUBLISH @b MUST include @Expires and @SIPETag
|
|
|
|
* headers.
|
|
|
|
*
|
|
|
|
* The PUBLISH request does not create a dialog. Currently the processing
|
|
|
|
* of incoming PUBLISH creates a new handle for each incoming request which
|
|
|
|
* is not assiciated with an existing dialog. If the handle @a nh is not
|
|
|
|
* bound, you should probably destroy it after responding to the PUBLISH
|
|
|
|
* request.
|
|
|
|
*
|
|
|
|
* @param status status code of response sent automatically by stack
|
|
|
|
* @param phrase a short textual description of @a status code
|
|
|
|
* @param nh operation handle associated with the incoming request
|
|
|
|
* @param hmagic application context associated with the call
|
|
|
|
* (usually NULL)
|
|
|
|
* @param sip incoming PUBLISH request
|
|
|
|
* @param tags empty
|
|
|
|
*
|
|
|
|
* @sa @RFC3903, nua_respond(),
|
2008-12-16 18:05:22 +00:00
|
|
|
* @Expires, @SIPETag, @SIPIfMatch, @Event,
|
|
|
|
* nua_subscribe(), #nua_i_subscribe,
|
2006-12-21 06:30:28 +00:00
|
|
|
* nua_notifier(), #nua_i_subscription,
|
|
|
|
*
|
|
|
|
* @since First used in @VERSION_1_12_4
|
|
|
|
*
|
|
|
|
* @END_NUA_EVENT
|
|
|
|
*/
|
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
int nua_publish_server_init(nua_server_request_t *sr);
|
|
|
|
|
2008-12-16 18:05:22 +00:00
|
|
|
nua_server_methods_t const nua_publish_server_methods =
|
2007-04-15 02:03:41 +00:00
|
|
|
{
|
|
|
|
SIP_METHOD_PUBLISH,
|
|
|
|
nua_i_publish, /* Event */
|
2008-12-16 18:05:22 +00:00
|
|
|
{
|
2007-04-15 02:03:41 +00:00
|
|
|
0, /* Do not create dialog */
|
|
|
|
0, /* Initial request */
|
|
|
|
0, /* Not a target refresh request */
|
|
|
|
1, /* Add Contact */
|
|
|
|
},
|
|
|
|
nua_publish_server_init,
|
|
|
|
nua_base_server_preprocess,
|
|
|
|
nua_base_server_params,
|
|
|
|
nua_base_server_respond,
|
|
|
|
nua_base_server_report,
|
|
|
|
};
|
|
|
|
|
|
|
|
int nua_publish_server_init(nua_server_request_t *sr)
|
2006-12-21 06:30:28 +00:00
|
|
|
{
|
2007-04-15 02:03:41 +00:00
|
|
|
sip_allow_events_t *allow_events = NH_PGET(sr->sr_owner, allow_events);
|
|
|
|
sip_event_t *o = sr->sr_request.sip->sip_event;
|
2006-12-21 06:30:28 +00:00
|
|
|
char const *event = o ? o->o_type : NULL;
|
2008-12-16 18:05:22 +00:00
|
|
|
|
2006-12-21 06:30:28 +00:00
|
|
|
if (!allow_events)
|
2007-04-15 02:03:41 +00:00
|
|
|
return SR_STATUS1(sr, SIP_501_NOT_IMPLEMENTED);
|
2006-12-21 06:30:28 +00:00
|
|
|
else if (!event || !msg_header_find_param(allow_events->k_common, event))
|
2007-04-15 02:03:41 +00:00
|
|
|
return SR_STATUS1(sr, SIP_489_BAD_EVENT);
|
2006-12-21 06:30:28 +00:00
|
|
|
|
2007-04-15 02:03:41 +00:00
|
|
|
return 0;
|
2006-12-21 06:30:28 +00:00
|
|
|
}
|