mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-17 06:48:33 +00:00
sync back up again with sofia tree prior to their release
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4177 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
f359f847f7
commit
666bd3bec3
55 files changed
+1807
-2097
No files matched your search
@@ -378,11 +378,9 @@ void nua_dialog_usage_remove_at(nua_owner_t *own,
|
||||
su_free(own, du);
|
||||
}
|
||||
|
||||
/* Zap dialog if there is no more usages */
|
||||
/* Zap dialog if there are no more usages */
|
||||
if (ds->ds_usage == NULL) {
|
||||
nta_leg_destroy(ds->ds_leg), ds->ds_leg = NULL;
|
||||
su_free(own, (void *)ds->ds_remote_tag), ds->ds_remote_tag = NULL;
|
||||
ds->ds_route = 0;
|
||||
nua_dialog_remove(own, ds, NULL);
|
||||
ds->ds_has_events = 0;
|
||||
ds->ds_terminated = 0;
|
||||
return;
|
||||
|
||||
@@ -119,8 +119,11 @@ struct register_usage {
|
||||
nua_registration_t *nr_next, **nr_prev, **nr_list; /* Doubly linked list and its head */
|
||||
sip_from_t *nr_aor; /**< AoR for this registration, NULL if none */
|
||||
sip_contact_t *nr_contact; /**< Our Contact */
|
||||
sip_contact_t nr_dcontact[1]; /**< Contact in dialog */
|
||||
sip_via_t *nr_via; /**< Corresponding Via headers */
|
||||
|
||||
unsigned long nr_min_expires; /**< Value from 423 negotiation */
|
||||
|
||||
/** Status of registration */
|
||||
unsigned nr_ready:1;
|
||||
/** Kind of registration.
|
||||
@@ -222,14 +225,13 @@ static void nua_register_usage_peer_info(nua_dialog_usage_t *du,
|
||||
/* Interface towards outbound_t */
|
||||
sip_contact_t *nua_handle_contact_by_via(nua_handle_t *nh,
|
||||
su_home_t *home,
|
||||
int in_dialog,
|
||||
char const *extra_username,
|
||||
sip_via_t const *v,
|
||||
char const *transport,
|
||||
char const *m_param,
|
||||
...);
|
||||
|
||||
static int nua_stack_outbound_features(nua_handle_t *nh, outbound_t *ob);
|
||||
|
||||
static int nua_stack_outbound_refresh(nua_handle_t *,
|
||||
outbound_t *ob);
|
||||
|
||||
@@ -431,6 +433,11 @@ outbound_owner_vtable nua_stack_outbound_callbacks = {
|
||||
* the desired transport-layer keepalive interval for stream-based
|
||||
* transports like TLS and TCP.
|
||||
*
|
||||
* As alternative to OPTIONS/STUN keepalives, the client can propose
|
||||
* a more frequent registration refresh interval with
|
||||
* NUTAG_M_FEATURES() (e.g. NUTAG_M_FEATURES("expires=120") given as
|
||||
* parameter to nua_register()).
|
||||
*
|
||||
* @sa #nua_r_register, nua_unregister(), #nua_r_unregister,
|
||||
* #nua_i_register,
|
||||
* @RFC3261 section 10,
|
||||
@@ -659,7 +666,6 @@ static int nua_register_client_init(nua_client_request_t *cr,
|
||||
NH_PISSET(nh, keepalive_stream)
|
||||
? NH_PGET(nh, keepalive_stream)
|
||||
: NH_PGET(nh, keepalive));
|
||||
nua_stack_outbound_features(nh, ob);
|
||||
|
||||
if (outbound_set_contact(ob, sip->sip_contact, nr->nr_via, unreg) < 0)
|
||||
return nua_client_return(cr, 900, "Cannot set outbound contact", msg);
|
||||
@@ -676,7 +682,8 @@ int nua_register_client_request(nua_client_request_t *cr,
|
||||
nua_handle_t *nh = cr->cr_owner;
|
||||
nua_dialog_usage_t *du = cr->cr_usage;
|
||||
nua_registration_t *nr;
|
||||
sip_contact_t *m = NULL, *contacts = sip->sip_contact, *previous = NULL;
|
||||
sip_contact_t *m, *contacts = sip->sip_contact;
|
||||
char const *min_expires = NULL;
|
||||
int unreg;
|
||||
|
||||
(void)nh;
|
||||
@@ -698,48 +705,58 @@ int nua_register_client_request(nua_client_request_t *cr,
|
||||
if (m == NULL)
|
||||
nua_client_terminating(cr);
|
||||
}
|
||||
|
||||
if (cr->cr_terminating) {
|
||||
/* Remove the expire parameters from contacts */
|
||||
for (m = sip->sip_contact; m; m = m->m_next) {
|
||||
if (m->m_url->url_type == url_any) {
|
||||
/* If there is a '*' in contact list, remove everything else */
|
||||
while (m != sip->sip_contact)
|
||||
sip_header_remove(msg, sip, (sip_header_t *)sip->sip_contact);
|
||||
while (m->m_next)
|
||||
sip_header_remove(msg, sip, (sip_header_t *)m->m_next);
|
||||
contacts = m;
|
||||
break;
|
||||
}
|
||||
msg_header_remove_param(m->m_common, "expires");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unreg = cr->cr_terminating;
|
||||
|
||||
if (du) {
|
||||
nr = nua_dialog_usage_private(du);
|
||||
nr = nua_dialog_usage_private(du);
|
||||
|
||||
if (nr) {
|
||||
if (nr->nr_ob) {
|
||||
outbound_stop_keepalive(nr->nr_ob);
|
||||
outbound_start_registering(nr->nr_ob);
|
||||
}
|
||||
|
||||
if (nr->nr_by_stack) {
|
||||
m = nr->nr_contact;
|
||||
sip_contact_t *m = nr->nr_contact, *previous = NULL;
|
||||
|
||||
outbound_get_contacts(nr->nr_ob, &m, &previous);
|
||||
|
||||
sip_add_dup(msg, sip, (sip_header_t *)m);
|
||||
/* previous is an outdated contact generated by stack
|
||||
* and it is now unregistered */
|
||||
if (previous)
|
||||
sip_add_dup(msg, sip, (sip_header_t *)previous);
|
||||
}
|
||||
}
|
||||
|
||||
for (m = sip->sip_contact; m; m = m->m_next) {
|
||||
if (m->m_url->url_type == url_any) {
|
||||
/* If there is a '*' in contact list, remove everything else */
|
||||
while (m != sip->sip_contact)
|
||||
sip_header_remove(msg, sip, (sip_header_t *)sip->sip_contact);
|
||||
while (m->m_next)
|
||||
sip_header_remove(msg, sip, (sip_header_t *)m->m_next);
|
||||
contacts = m;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!m->m_expires)
|
||||
continue;
|
||||
if (unreg) {
|
||||
/* Remove the expire parameters from contacts */
|
||||
msg_header_remove_param(m->m_common, "expires");
|
||||
}
|
||||
else if (nr && nr->nr_min_expires &&
|
||||
strtoul(m->m_expires, 0, 10) < nr->nr_min_expires) {
|
||||
if (min_expires == NULL)
|
||||
min_expires = su_sprintf(msg_home(msg), "expires=%lu",
|
||||
nr->nr_min_expires);
|
||||
msg_header_replace_param(msg_home(msg), m->m_common, min_expires);
|
||||
}
|
||||
}
|
||||
|
||||
return nua_base_client_trequest(cr, msg, sip,
|
||||
/* m is stack-generated contact */
|
||||
SIPTAG_CONTACT(m),
|
||||
/*
|
||||
* previous is outdated stack-generated contact
|
||||
* which is now unregistered
|
||||
*/
|
||||
SIPTAG_CONTACT(previous),
|
||||
TAG_IF(unreg, SIPTAG_EXPIRES_STR("0")),
|
||||
#if 0
|
||||
TAG_IF(unreg, NTATAG_SIGCOMP_CLOSE(1)),
|
||||
@@ -772,6 +789,11 @@ static int nua_register_client_check_restart(nua_client_request_t *cr,
|
||||
/* XXX - report an error? */;
|
||||
}
|
||||
|
||||
if (nr && status == 423) {
|
||||
if (sip->sip_min_expires)
|
||||
nr->nr_min_expires = sip->sip_min_expires->me_delta;
|
||||
}
|
||||
|
||||
/* Check for status-specific reasons to retry */
|
||||
if (nua_base_client_check_restart(cr, status, phrase, sip))
|
||||
return 1;
|
||||
@@ -1262,11 +1284,8 @@ int nua_registration_from_via(nua_registration_t **list,
|
||||
|
||||
v2[1].v_next = NULL;
|
||||
|
||||
#if 1
|
||||
contact = nua_handle_contact_by_via(nh, home, NULL, v2, protocol, NULL);
|
||||
#else
|
||||
contact = sip_contact_create_from_via_with_transport(home, v2, NULL, protocol);
|
||||
#endif
|
||||
contact = nua_handle_contact_by_via(nh, home, 0, NULL, v2, protocol, NULL);
|
||||
|
||||
v = sip_via_dup(home, v2);
|
||||
|
||||
if (!contact || !v) {
|
||||
@@ -1277,6 +1296,7 @@ int nua_registration_from_via(nua_registration_t **list,
|
||||
nr->nr_ready = 1, nr->nr_default = 1, nr->nr_public = public;
|
||||
nr->nr_secure = contact->m_url->url_type == url_sips;
|
||||
nr->nr_contact = contact;
|
||||
*nr->nr_dcontact = *contact, nr->nr_dcontact->m_params = NULL;
|
||||
nr->nr_via = v;
|
||||
nr->nr_ip4 = host_is_ip4_address(contact->m_url->url_host);
|
||||
nr->nr_ip6 = !nr->nr_ip4 && host_is_ip6_reference(contact->m_url->url_host);
|
||||
@@ -1446,7 +1466,10 @@ sip_contact_t const *nua_registration_contact(nua_registration_t const *nr)
|
||||
return m;
|
||||
}
|
||||
|
||||
return nr->nr_contact;
|
||||
if (nr->nr_contact)
|
||||
return nr->nr_dcontact;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Return initial route. */
|
||||
@@ -1458,7 +1481,7 @@ sip_route_t const *nua_registration_route(nua_registration_t const *nr)
|
||||
sip_contact_t const *nua_stack_get_contact(nua_registration_t const *nr)
|
||||
{
|
||||
nr = nua_registration_by_aor(nr, NULL, NULL, 1);
|
||||
return nr ? nr->nr_contact : NULL;
|
||||
return nr && nr->nr_contact ? nr->nr_dcontact : NULL;
|
||||
}
|
||||
|
||||
/** Add a Contact (and Route) header to request */
|
||||
@@ -1531,23 +1554,51 @@ int nua_registration_add_contact_and_route(nua_handle_t *nh,
|
||||
return -1;
|
||||
|
||||
if (add_contact) {
|
||||
sip_contact_t const *m = nua_registration_contact(nr);
|
||||
sip_contact_t const *m = NULL;
|
||||
char const *m_display;
|
||||
char const *m_username;
|
||||
char const *m_params;
|
||||
url_t const *u;
|
||||
|
||||
char const *m_display = NH_PGET(nh, m_display);
|
||||
char const *m_username = NH_PGET(nh, m_username);
|
||||
char const *m_params = NH_PGET(nh, m_params);
|
||||
url_t const *u = m->m_url;
|
||||
if (nr->nr_by_stack && nr->nr_ob) {
|
||||
m = outbound_dialog_gruu(nr->nr_ob);
|
||||
|
||||
if (m)
|
||||
return msg_header_add_dup(msg, (msg_pub_t *)sip, (void const *)m);
|
||||
|
||||
m = outbound_dialog_contact(nr->nr_ob);
|
||||
}
|
||||
|
||||
if (m == NULL)
|
||||
m = nr->nr_contact;
|
||||
|
||||
if (!m)
|
||||
return -1;
|
||||
|
||||
if (str0cmp(m_params, u->url_params) == 0)
|
||||
u = m->m_url;
|
||||
|
||||
if (NH_PISSET(nh, m_display))
|
||||
m_display = NH_PGET(nh, m_display);
|
||||
else
|
||||
m_display = m->m_display;
|
||||
|
||||
if (NH_PISSET(nh, m_username))
|
||||
m_username = NH_PGET(nh, m_username);
|
||||
else
|
||||
m_username = m->m_url->url_user;
|
||||
|
||||
if (NH_PISSET(nh, m_params)) {
|
||||
m_params = NH_PGET(nh, m_params);
|
||||
|
||||
if (u->url_params && m_params && strstr(u->url_params, m_params) == 0)
|
||||
m_params = NULL;
|
||||
}
|
||||
else
|
||||
m_params = NULL;
|
||||
|
||||
m = sip_contact_format(msg_home(msg),
|
||||
"%s<%s:%s%s%s%s%s%s%s%s%s>",
|
||||
m_display ? m_display :
|
||||
m->m_display ? m->m_display : "",
|
||||
m_display ? m_display : "",
|
||||
u->url_scheme,
|
||||
m_username ? m_username : "",
|
||||
m_username ? "@" : "",
|
||||
@@ -1648,7 +1699,7 @@ int nua_registration_set_contact(nua_handle_t *nh,
|
||||
|
||||
if (nr0 && nr0->nr_via) {
|
||||
char const *tport = nr0->nr_via->v_next ? NULL : nr0->nr_via->v_protocol;
|
||||
m = nua_handle_contact_by_via(nh, nh->nh_home,
|
||||
m = nua_handle_contact_by_via(nh, nh->nh_home, 0,
|
||||
NULL, nr0->nr_via, tport, NULL);
|
||||
}
|
||||
}
|
||||
@@ -1657,6 +1708,7 @@ int nua_registration_set_contact(nua_handle_t *nh,
|
||||
return -1;
|
||||
|
||||
nr->nr_contact = m;
|
||||
*nr->nr_dcontact = *m, nr->nr_dcontact->m_params = NULL;
|
||||
nr->nr_ip4 = host_is_ip4_address(m->m_url->url_host);
|
||||
nr->nr_ip6 = !nr->nr_ip4 && host_is_ip6_reference(m->m_url->url_host);
|
||||
nr->nr_by_stack = !application_contact;
|
||||
@@ -1785,6 +1837,7 @@ static int nua_stack_outbound_credentials(nua_handle_t *nh,
|
||||
/** @internal Generate a @Contact header. */
|
||||
sip_contact_t *nua_handle_contact_by_via(nua_handle_t *nh,
|
||||
su_home_t *home,
|
||||
int in_dialog,
|
||||
char const *extra_username,
|
||||
sip_via_t const *v,
|
||||
char const *transport,
|
||||
@@ -1868,7 +1921,7 @@ sip_contact_t *nua_handle_contact_by_via(nua_handle_t *nh,
|
||||
su_strlst_append(l, ";comp="), su_strlst_append(l, comp);
|
||||
s = NH_PGET(nh, m_params);
|
||||
if (s)
|
||||
su_strlst_append(l, s[0] == ';' ? "" : ";"), su_strlst_append(l, s);
|
||||
s[0] == ';' ? "" : su_strlst_append(l, ";"), su_strlst_append(l, s);
|
||||
su_strlst_append(l, ">");
|
||||
|
||||
va_start(va, m_param);
|
||||
@@ -1882,81 +1935,42 @@ sip_contact_t *nua_handle_contact_by_via(nua_handle_t *nh,
|
||||
|
||||
va_end(va);
|
||||
|
||||
if (!in_dialog) {
|
||||
s = NH_PGET(nh, m_features);
|
||||
if (s)
|
||||
s[0] == ';' ? "" : su_strlst_append(l, ";"), su_strlst_append(l, s);
|
||||
|
||||
if (NH_PGET(nh, callee_caps)) {
|
||||
sip_allow_t const *allow = NH_PGET(nh, allow);
|
||||
|
||||
if (allow) {
|
||||
su_strlst_append(l, ";methods=\"");
|
||||
if (allow->k_items) {
|
||||
size_t i;
|
||||
for (i = 0; allow->k_items[i]; i++) {
|
||||
su_strlst_append(l, allow->k_items[i]);
|
||||
if (allow->k_items[i + 1])
|
||||
su_strlst_append(l, ",");
|
||||
}
|
||||
}
|
||||
su_strlst_append(l, "\"");
|
||||
}
|
||||
|
||||
if (nh->nh_soa) {
|
||||
char **media = soa_media_features(nh->nh_soa, 0, home);
|
||||
|
||||
while (*media) {
|
||||
if (su_strlst_len(l))
|
||||
su_strlst_append(l, ";");
|
||||
su_strlst_append(l, *media++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m = sip_contact_make(home, su_strlst_join(l, su_strlst_home(l), ""));
|
||||
|
||||
su_strlst_destroy(l);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
/** @internal Return a string describing our features. */
|
||||
static char *nua_handle_features(nua_handle_t *nh)
|
||||
{
|
||||
char *retval = NULL;
|
||||
su_strlst_t *l = su_strlst_create(NULL);
|
||||
su_home_t *home = su_strlst_home(l);
|
||||
|
||||
if (!l)
|
||||
return NULL;
|
||||
|
||||
if (NH_PGET(nh, m_features)) {
|
||||
char const *m_features = NH_PGET(nh, m_features);
|
||||
|
||||
if (m_features[0] != ';')
|
||||
su_strlst_append(l, ";");
|
||||
|
||||
su_strlst_append(l, m_features);
|
||||
}
|
||||
|
||||
if (NH_PGET(nh, callee_caps)) {
|
||||
sip_allow_t const *allow = NH_PGET(nh, allow);
|
||||
|
||||
if (allow) {
|
||||
/* Skip ";" if this is first one */
|
||||
su_strlst_append(l, ";methods=\"" + (su_strlst_len(l) == 0));
|
||||
if (allow->k_items) {
|
||||
size_t i;
|
||||
for (i = 0; allow->k_items[i]; i++) {
|
||||
su_strlst_append(l, allow->k_items[i]);
|
||||
if (allow->k_items[i + 1])
|
||||
su_strlst_append(l, ",");
|
||||
}
|
||||
}
|
||||
su_strlst_append(l, "\"");
|
||||
}
|
||||
|
||||
if (nh->nh_soa) {
|
||||
char **media = soa_media_features(nh->nh_soa, 0, home);
|
||||
|
||||
while (*media) {
|
||||
if (su_strlst_len(l))
|
||||
su_strlst_append(l, ";");
|
||||
su_strlst_append(l, *media++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (su_strlst_len(l))
|
||||
retval = su_strlst_join(l, nh->nh_home, "");
|
||||
|
||||
su_strlst_destroy(l);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int nua_stack_outbound_features(nua_handle_t *nh, outbound_t *ob)
|
||||
{
|
||||
char *features;
|
||||
int retval;
|
||||
|
||||
if (!nh)
|
||||
return -1;
|
||||
if (!ob)
|
||||
return 0;
|
||||
|
||||
features = nua_handle_features(nh);
|
||||
retval = outbound_set_features(ob, features);
|
||||
su_free(nh->nh_home, features);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -299,10 +299,7 @@ int nua_stack_event(nua_t *nua, nua_handle_t *nh, msg_t *msg,
|
||||
|
||||
if (tags) {
|
||||
tagi_t *t = e->e_tags, *t_end = (tagi_t *)((char *)t + len);
|
||||
void *b = t_end;
|
||||
#ifndef NDEBUG
|
||||
void *end = (char *)b + xtra;
|
||||
#endif
|
||||
void *b = t_end, *end = (char *)b + xtra;
|
||||
|
||||
t = tl_dup(t, tags, &b); p = b;
|
||||
assert(t == t_end); assert(b == end); (void)end;
|
||||
|
||||
@@ -117,7 +117,6 @@ struct outbound {
|
||||
|
||||
char const *ob_instance; /**< Our instance ID */
|
||||
int32_t ob_reg_id; /**< Flow-id */
|
||||
char const *ob_features; /**< Feature parameters for rcontact */
|
||||
sip_contact_t *ob_rcontact; /**< Our contact */
|
||||
sip_contact_t *ob_dcontact; /**< Contact for dialogs */
|
||||
sip_contact_t *ob_previous; /**< Stale contact */
|
||||
@@ -327,20 +326,6 @@ int outbound_set_options(outbound_t *ob,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Set the feature string (added to the Contact header when registering). */
|
||||
int outbound_set_features(outbound_t *ob, char *features)
|
||||
{
|
||||
char *old_features = (char *)ob->ob_features;
|
||||
char *new_features = su_strdup(ob->ob_home, features);
|
||||
|
||||
if (features && !new_features)
|
||||
return -1;
|
||||
|
||||
ob->ob_features = new_features;
|
||||
su_free(ob->ob_home, old_features);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/** Obtain contacts for REGISTER */
|
||||
@@ -698,21 +683,32 @@ static int create_keepalive_message(outbound_t *ob, sip_t const *regsip)
|
||||
{
|
||||
msg_t *msg = nta_msg_create(ob->ob_nta, MSG_FLG_COMPACT), *previous;
|
||||
sip_t *osip = sip_object(msg);
|
||||
sip_accept_contact_t *ac;
|
||||
|
||||
char const *p1 = ob->ob_instance;
|
||||
char const *p2 = ob->ob_features;
|
||||
sip_contact_t *m = ob->ob_rcontact;
|
||||
|
||||
unsigned d = ob->ob_keepalive.interval;
|
||||
|
||||
assert(regsip); assert(regsip->sip_request);
|
||||
|
||||
if (p1 || p2) {
|
||||
ac = sip_accept_contact_format(msg_home(msg), "*;require;explicit;%s%s%s",
|
||||
p1 ? p1 : "",
|
||||
p2 && p2 ? ";" : "",
|
||||
p2 ? p2 : "");
|
||||
msg_header_insert(msg, NULL, (void *)ac);
|
||||
if (m && m->m_params) {
|
||||
sip_accept_contact_t *ac;
|
||||
size_t i;
|
||||
int features = 0;
|
||||
|
||||
ac = sip_accept_contact_make(msg_home(msg), "*;require;explicit");
|
||||
|
||||
for (i = 0; m->m_params[i]; i++) {
|
||||
char const *s = m->m_params[i];
|
||||
if (!sip_is_callerpref(s))
|
||||
continue;
|
||||
features++;
|
||||
s = su_strdup(msg_home(msg), s);
|
||||
msg_header_add_param(msg_home(msg), ac->cp_common, s);
|
||||
}
|
||||
|
||||
if (features)
|
||||
msg_header_insert(msg, NULL, (void *)ac);
|
||||
else
|
||||
msg_header_free(msg_home(msg), (void *)ac);
|
||||
}
|
||||
|
||||
if (0 >
|
||||
@@ -1008,46 +1004,16 @@ int outbound_contacts_from_via(outbound_t *ob, sip_via_t const *via)
|
||||
|
||||
v = v0; *v0 = *via; v0->v_next = NULL;
|
||||
|
||||
dcontact = ob->ob_oo->oo_contact(ob->ob_owner, home,
|
||||
dcontact = ob->ob_oo->oo_contact(ob->ob_owner, home, 1,
|
||||
NULL, v, v->v_protocol, NULL);
|
||||
|
||||
if (ob->ob_instance && ob->ob_reg_id != 0)
|
||||
snprintf(reg_id_param, sizeof reg_id_param, ";reg-id=%u", ob->ob_reg_id);
|
||||
|
||||
rcontact = ob->ob_oo->oo_contact(ob->ob_owner, home,
|
||||
rcontact = ob->ob_oo->oo_contact(ob->ob_owner, home, 0,
|
||||
NULL, v, v->v_protocol,
|
||||
ob->ob_features ? ob->ob_features : "",
|
||||
ob->ob_instance, reg_id_param, NULL);
|
||||
|
||||
#if 0
|
||||
char *uri;
|
||||
|
||||
/* uri contains < > */
|
||||
uri = sip_contact_string_from_via(NULL, via, NULL, v->v_protocol);
|
||||
|
||||
dcontact = sip_contact_make(home, uri);
|
||||
|
||||
if (ob->ob_instance) {
|
||||
char reg_id[20];
|
||||
|
||||
if (ob->ob_instance && ob->ob_reg_id)
|
||||
snprintf(reg_id, sizeof reg_id, ";reg-id=%u", ob->ob_reg_id);
|
||||
else
|
||||
strcpy(reg_id, "");
|
||||
|
||||
rcontact = sip_contact_format(home, "%s;%s%s%s%s",
|
||||
uri, ob->ob_instance, reg_id,
|
||||
ob->ob_features ? ";" : "",
|
||||
ob->ob_features ? ob->ob_features : "");
|
||||
}
|
||||
else if (ob->ob_features)
|
||||
rcontact = sip_contact_format(home, "%s;%s", uri, ob->ob_features);
|
||||
else
|
||||
rcontact = dcontact;
|
||||
|
||||
free(uri);
|
||||
#endif
|
||||
|
||||
v = sip_via_dup(home, v);
|
||||
|
||||
if (!rcontact || !dcontact || !v) {
|
||||
@@ -1139,7 +1105,7 @@ int outbound_set_contact(outbound_t *ob,
|
||||
char const *tport = !v->v_next ? v->v_protocol : NULL;
|
||||
char reg_id_param[20];
|
||||
|
||||
dcontact = ob->ob_oo->oo_contact(ob->ob_owner, home,
|
||||
dcontact = ob->ob_oo->oo_contact(ob->ob_owner, home, 1,
|
||||
NULL, v, tport, NULL);
|
||||
if (!dcontact)
|
||||
return -1;
|
||||
@@ -1147,9 +1113,8 @@ int outbound_set_contact(outbound_t *ob,
|
||||
if (ob->ob_instance && ob->ob_reg_id != 0)
|
||||
snprintf(reg_id_param, sizeof reg_id_param, ";reg-id=%u", ob->ob_reg_id);
|
||||
|
||||
rcontact = ob->ob_oo->oo_contact(ob->ob_owner, home,
|
||||
rcontact = ob->ob_oo->oo_contact(ob->ob_owner, home, 0,
|
||||
NULL, v, v->v_protocol,
|
||||
ob->ob_features ? ob->ob_features : "",
|
||||
ob->ob_instance, reg_id_param, NULL);
|
||||
if (!rcontact)
|
||||
return -1;
|
||||
@@ -1195,6 +1160,11 @@ sip_contact_t const *outbound_dialog_contact(outbound_t const *ob)
|
||||
return ob->ob_dcontact;
|
||||
}
|
||||
|
||||
sip_contact_t const *outbound_dialog_gruu(outbound_t const *ob)
|
||||
{
|
||||
return ob ? ob->ob_gruu : NULL;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
|
||||
@@ -70,8 +70,6 @@ int outbound_set_options(outbound_t *ob,
|
||||
unsigned dgram_interval,
|
||||
unsigned stream_interval);
|
||||
|
||||
int outbound_set_features(outbound_t *ob, char *features);
|
||||
|
||||
int outbound_get_contacts(outbound_t *ob,
|
||||
sip_contact_t **return_current_contact,
|
||||
sip_contact_t **return_previous_contact);
|
||||
@@ -98,6 +96,8 @@ int outbound_set_contact(outbound_t *ob,
|
||||
|
||||
sip_contact_t const *outbound_dialog_contact(outbound_t const *ob);
|
||||
|
||||
sip_contact_t const *outbound_dialog_gruu(outbound_t const *ob);
|
||||
|
||||
int outbound_gruuize(outbound_t *ob, sip_t const *sip);
|
||||
|
||||
void outbound_start_keepalive(outbound_t *ob,
|
||||
@@ -118,6 +118,7 @@ struct outbound_owner_vtable
|
||||
int oo_size;
|
||||
sip_contact_t *(*oo_contact)(outbound_owner_t *,
|
||||
su_home_t *home,
|
||||
int used_in_dialog,
|
||||
char const *extra_username,
|
||||
sip_via_t const *v,
|
||||
char const *transport,
|
||||
|
||||
@@ -1074,7 +1074,7 @@ SOFIAPUBVAR tag_typedef_t nutag_registrar_ref;
|
||||
*
|
||||
* The outbound option string can specify how the NAT traversal is handled.
|
||||
* The option tokens are as follows:
|
||||
* - "gruuize": try to generate a GRUU
|
||||
* - "gruuize": try to generate a GRUU contact from REGISTER response
|
||||
* - "outbound": use SIP outbound extension (off by default)
|
||||
* - "validate": validate registration behind a NAT by sending OPTIONS to self
|
||||
* - "natify": try to traverse NAT
|
||||
@@ -1084,6 +1084,10 @@ SOFIAPUBVAR tag_typedef_t nutag_registrar_ref;
|
||||
* An option token with "no-" or "not-" prefix turns the option off. For
|
||||
* example, if you want to try to traverse NATs but not to use OPTIONS
|
||||
* keepalive, use NUTAG_OUTBOUND("natify no-options-keepalive").
|
||||
*
|
||||
* An empty string can be passed to let the stack choose the
|
||||
* default values for outbound usage (in the 1.12.5 release, the
|
||||
* defaults are: "gruuize no-outbound validate use-port options-keepalive").
|
||||
*
|
||||
* @note
|
||||
* Options string is used so that no new tags need to be added when the
|
||||
@@ -1207,7 +1211,7 @@ SOFIAPUBVAR tag_typedef_t nutag_outbound_set4_ref;
|
||||
* nua_create()
|
||||
*
|
||||
* @par Parameter type
|
||||
* msg_mclass_t *
|
||||
* msg_mclass_t const *
|
||||
*
|
||||
* @par Values
|
||||
* Pointer to an extended SIP parser.
|
||||
@@ -1243,6 +1247,9 @@ SOFIAPUBVAR tag_typedef_t nutag_auth;
|
||||
SOFIAPUBVAR tag_typedef_t nutag_auth_ref;
|
||||
|
||||
/** Keepalive interval in milliseconds.
|
||||
*
|
||||
* This setting applies to OPTIONS/STUN keepalives. See documentation
|
||||
* for nua_register() for more detailed information.
|
||||
*
|
||||
* @par Used with
|
||||
* nua_register() \n
|
||||
@@ -1268,6 +1275,8 @@ SOFIAPUBVAR tag_typedef_t nutag_keepalive;
|
||||
SOFIAPUBVAR tag_typedef_t nutag_keepalive_ref;
|
||||
|
||||
/** Transport-level keepalive interval for streams.
|
||||
*
|
||||
* See documentation for nua_register() for more detailed information.
|
||||
*
|
||||
* @par Used with
|
||||
* nua_register() \n
|
||||
|
||||
@@ -478,6 +478,47 @@ int test_basic_call_2(struct context *ctx)
|
||||
TEST_1(nua_handle_has_active_call(b_call->nh));
|
||||
TEST_1(!nua_handle_has_call_on_hold(b_call->nh));
|
||||
|
||||
/* Send a NOTIFY from B to A */
|
||||
if (print_headings)
|
||||
printf("TEST NUA-3.2.2: send a NOTIFY within a dialog\n");
|
||||
|
||||
/* Make A to accept NOTIFY */
|
||||
nua_set_params(a->nua, NUTAG_APPL_METHOD("NOTIFY"), TAG_END());
|
||||
run_a_until(ctx, nua_r_set_params, until_final_response);
|
||||
|
||||
NOTIFY(b, b_call, b_call->nh,
|
||||
NUTAG_NEWSUB(1),
|
||||
SIPTAG_SUBJECT_STR("NUA-3.2.2"),
|
||||
SIPTAG_EVENT_STR("message-summary"),
|
||||
SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"),
|
||||
SIPTAG_PAYLOAD_STR("Messages-Waiting: no"),
|
||||
TAG_END());
|
||||
|
||||
run_ab_until(ctx, -1, accept_notify, -1, save_until_final_response);
|
||||
|
||||
/* Notifier events: nua_r_notify */
|
||||
TEST_1(e = b->events->head); TEST_E(e->data->e_event, nua_r_notify);
|
||||
TEST(e->data->e_status, 200);
|
||||
TEST_1(tl_find(e->data->e_tags, nutag_substate));
|
||||
TEST(tl_find(e->data->e_tags, nutag_substate)->t_value,
|
||||
nua_substate_terminated);
|
||||
|
||||
/* watcher events: nua_i_notify */
|
||||
TEST_1(e = a->events->head); TEST_E(e->data->e_event, nua_i_notify);
|
||||
TEST_1(sip = sip_object(e->data->e_msg));
|
||||
TEST_1(sip->sip_subscription_state);
|
||||
TEST_S(sip->sip_subscription_state->ss_substate, "terminated");
|
||||
TEST_1(tl_find(e->data->e_tags, nutag_substate));
|
||||
TEST(tl_find(e->data->e_tags, nutag_substate)->t_value,
|
||||
nua_substate_terminated);
|
||||
TEST_1(!e->next);
|
||||
|
||||
free_events_in_list(ctx, a->events);
|
||||
free_events_in_list(ctx, b->events);
|
||||
|
||||
if (print_headings)
|
||||
printf("TEST NUA-3.2.2: PASSED\n");
|
||||
|
||||
INFO(b, b_call, b_call->nh, TAG_END());
|
||||
BYE(b, b_call, b_call->nh, TAG_END());
|
||||
INFO(b, b_call, b_call->nh, TAG_END());
|
||||
|
||||
@@ -92,6 +92,9 @@ static char const options_usage[] =
|
||||
" --no-alarm don't ask for guard ALARM\n"
|
||||
" -p uri specify uri of outbound proxy (implies --no-proxy)\n"
|
||||
" --proxy-tests run tests involving proxy, too\n"
|
||||
#if SU_HAVE_OSX_CF_API /* If compiled with CoreFoundation events */
|
||||
" --osx-runloop use OSX CoreFoundation runloop instead of poll() loop\n"
|
||||
#endif
|
||||
" -k do not exit after first error\n"
|
||||
;
|
||||
|
||||
|
||||
@@ -216,6 +216,8 @@ int until_terminated(CONDITION_PARAMS);
|
||||
int until_ready(CONDITION_PARAMS);
|
||||
int accept_call(CONDITION_PARAMS);
|
||||
|
||||
int accept_notify(CONDITION_PARAMS);
|
||||
|
||||
void a_callback(nua_event_t event,
|
||||
int status, char const *phrase,
|
||||
nua_t *nua, struct context *ctx,
|
||||
|
||||
@@ -133,6 +133,8 @@ int test_register_to_proxy(struct context *ctx)
|
||||
NUTAG_KEEPALIVE(1000),
|
||||
NUTAG_M_DISPLAY("A&A"),
|
||||
NUTAG_M_USERNAME("a"),
|
||||
NUTAG_M_PARAMS("foo=bar"),
|
||||
NUTAG_M_FEATURES("q=0.9"),
|
||||
SIPTAG_CSEQ(cseq),
|
||||
TAG_END());
|
||||
run_a_until(ctx, -1, save_until_final_response);
|
||||
@@ -161,6 +163,8 @@ int test_register_to_proxy(struct context *ctx)
|
||||
/* VC does not dig \" with TEST_S() */
|
||||
TEST_S(sip->sip_contact->m_display, expect_m_display); }
|
||||
TEST_S(sip->sip_contact->m_url->url_user, "a");
|
||||
TEST_1(strstr(sip->sip_contact->m_url->url_params, "foo=bar"));
|
||||
TEST_S(sip->sip_contact->m_q, "0.9");
|
||||
TEST(sip->sip_cseq->cs_seq, 14);
|
||||
|
||||
if (ctx->nat) {
|
||||
@@ -222,8 +226,12 @@ int test_register_to_proxy(struct context *ctx)
|
||||
TEST_1(c_reg->nh = nua_handle(c->nua, c_reg, TAG_END()));
|
||||
|
||||
REGISTER(c, c_reg, c_reg->nh, SIPTAG_TO(c->to),
|
||||
NUTAG_OUTBOUND(NULL),
|
||||
NUTAG_M_DISPLAY("C"),
|
||||
NUTAG_M_USERNAME("c"),
|
||||
NUTAG_M_PARAMS("c=1"),
|
||||
NUTAG_M_FEATURES("q=0.987;expires=5"),
|
||||
NUTAG_CALLEE_CAPS(1),
|
||||
SIPTAG_EXPIRES_STR("5"), /* Test 423 negotiation */
|
||||
TAG_END());
|
||||
run_abc_until(ctx, -1, save_events, -1, save_events,
|
||||
@@ -254,6 +262,9 @@ int test_register_to_proxy(struct context *ctx)
|
||||
TEST_1(sip->sip_contact);
|
||||
TEST_S(sip->sip_contact->m_display, "C");
|
||||
TEST_S(sip->sip_contact->m_url->url_user, "c");
|
||||
TEST_1(strstr(sip->sip_contact->m_url->url_params, "c=1"));
|
||||
TEST_S(sip->sip_contact->m_q, "0.987");
|
||||
TEST_1(msg_header_find_param(sip->sip_contact->m_common, "methods="));
|
||||
TEST_1(!e->next);
|
||||
free_events_in_list(ctx, c->events);
|
||||
|
||||
@@ -688,6 +699,7 @@ int test_unregister(struct context *ctx)
|
||||
UNREGISTER(c, c->call, c->call->nh, SIPTAG_TO(c->to),
|
||||
NUTAG_M_DISPLAY("C"),
|
||||
NUTAG_M_USERNAME("c"),
|
||||
NUTAG_M_PARAMS("c=1"),
|
||||
TAG_END());
|
||||
run_c_until(ctx, -1, save_until_final_response);
|
||||
|
||||
|
||||
Reference in new issue
Block a user