Commit f724a042 authored by Martti Mela's avatar Martti Mela

network detection now closes tports and creates new ones

darcs-hash:20060816162258-1b897-066d0544bed8e9adf16581eec483c9a2efb1752f.gz
parent 8f346d54
......@@ -21,6 +21,10 @@ API/ABI changes and versioning
- and should be updated _continuously_! />
libsofia-sip-ua:
- Added network change detection logic. This extends current su API
with two functions defined in su_os_nw.h. Also a new event
nua_i_network_changed and tag NUTAG_DETECT_NETWORK_UPDATES are
introduced.
- template: Added foobar() function (sofia-sip/foobar.h).
- The install location of awk scripts (msg_parser.awk and
tag_dll.awk) from libexec to share/sofia-sip/. Also added
......
......@@ -6655,6 +6655,12 @@ outgoing_send(nta_outgoing_t *orq, int retransmit)
tag_value_t value = 0;
struct sigcomp_compartment *cc; cc = NULL;
/* tport can be NULL if we are just switching network */
if (orq->orq_tport == NULL) {
outgoing_tport_error(agent, orq, NULL, orq->orq_request, ENETRESET);
return;
}
if (!retransmit)
orq->orq_sent = now;
......@@ -9915,3 +9921,33 @@ int nta_tport_keepalive(nta_outgoing_t *orq)
return tport_keepalive(orq->orq_tport, msg_addrinfo(orq->orq_request),
TAG_END());
}
int nta_agent_close_tports(nta_agent_t *agent)
{
int i;
outgoing_htable_t *oht = agent->sa_outgoing;
incoming_htable_t *iht = agent->sa_incoming;
for (i = oht->oht_size; i-- > 0;)
/* while */ if (oht->oht_table[i]) {
nta_outgoing_t *orq = oht->oht_table[i];
if (orq->orq_pending && orq->orq_tport)
tport_release(orq->orq_tport, orq->orq_pending, orq->orq_request,
NULL, orq, 0);
orq->orq_pending = 0;
tport_unref(orq->orq_tport), orq->orq_tport = NULL;
}
for (i = iht->iht_size; i-- > 0;)
/* while */ if (iht->iht_table[i]) {
nta_incoming_t *irq = iht->iht_table[i];
tport_unref(irq->irq_tport), irq->irq_tport = NULL;
}
tport_destroy(agent->sa_tports), agent->sa_tports = NULL;
return 0;
}
......@@ -139,6 +139,8 @@ int nta_agent_add_tport(nta_agent_t *agent,
url_string_t const *url,
tag_type_t tag, tag_value_t value, ...);
SOFIAPUBFUN int nta_agent_close_tports(nta_agent_t *agent);
SOFIAPUBFUN sip_contact_t *nta_agent_contact(nta_agent_t const *a);
SOFIAPUBFUN sip_via_t *nta_agent_via(nta_agent_t const *a);
SOFIAPUBFUN sip_via_t *nta_agent_public_via(nta_agent_t const *a);
......
......@@ -32,6 +32,9 @@
#include "config.h"
/** @internal SU network changed detector argument pointer type */
#define SU_NETWORK_CHANGED_MAGIC_T struct nua_s
#include <sofia-sip/string0.h>
#include <sofia-sip/su_strlst.h>
#include <sofia-sip/su_uniqueid.h>
......@@ -904,6 +907,70 @@ nua_stack_init_transport(nua_t *nua, tagi_t const *tags)
return 0;
}
#if 0
/* Store network detector param value */
if (agent->sa_nw_updates == 0)
agent->sa_nw_updates = nw_updates;
NTATAG_DETECT_NETWORK_UPDATES_REF(nw_updates),
unsigned nw_updates = 0;
unsigned nw_updates = 0;
su_network_changed_t *sa_nw_changed;
#endif
static
void nua_network_changed_cb(nua_t *nua, su_root_t *root)
{
uint32_t nw_updates = NUA_NW_DETECT_TRY_FULL;
switch (nw_updates) {
case NUA_NW_DETECT_ONLY_INFO:
nua_stack_event(nua, NULL, NULL, nua_i_network_changed,
SIP_200_OK, TAG_END());
break;
case NUA_NW_DETECT_TRY_FULL:
/* 1) Shutdown all tports */
nta_agent_close_tports(nua->nua_nta);
/* 2) */
if (nua_stack_init_transport(nua, nua->nua_args) < 0);
nua_stack_event(nua, NULL, NULL, nua_i_network_changed,
SIP_200_OK, TAG_END());
break;
default:
break;
}
return;
}
int nua_stack_launch_network_change_detector(nua_t *nua)
{
su_network_changed_t *snc = NULL;
snc = su_root_add_network_changed(nua->nua_home,
nua->nua_api_root,
nua_network_changed_cb,
nua);
if (!snc)
return -1;
nua->nua_nw_changed = snc;
return 0;
}
int
nua_stack_init_registrations(nua_t *nua)
{
......
......@@ -47,9 +47,6 @@
#define SU_ROOT_MAGIC_T struct nua_s
#define SU_MSG_ARG_T struct event_s
/** @internal SU network changed detector argument pointer type */
#define SU_NETWORK_CHANGED_MAGIC_T struct nua_s
#define NUA_SAVED_EVENT_T su_msg_t *
#define NTA_AGENT_MAGIC_T struct nua_s
......@@ -1688,66 +1685,3 @@ nua_stack_respond(nua_t *nua, nua_handle_t *nh,
500, "Responding to a Non-Existing Request", TAG_END());
}
}
#if 0
/* Store network detector param value */
if (agent->sa_nw_updates == 0)
agent->sa_nw_updates = nw_updates;
NTATAG_DETECT_NETWORK_UPDATES_REF(nw_updates),
unsigned nw_updates = 0;
unsigned nw_updates = 0;
su_network_changed_t *sa_nw_changed;
#endif
static
void nua_network_changed_cb(nua_t *nua, su_root_t *root)
{
uint32_t nw_updates = NUA_NW_DETECT_ONLY_INFO;
switch (nw_updates) {
case NUA_NW_DETECT_ONLY_INFO:
nua_stack_event(nua, NULL, NULL, nua_i_network_changed,
SIP_200_OK, TAG_END());
break;
case NUA_NW_DETECT_TRY_FULL:
/* XXX - loop through transactions and remove tport_primaries */
/* XXX - tport_shutdown() */
/* XXX - tport_tcreate() */
/* XXX - tport_tbind() */
//if (agent->sa_callback)
//(void)agent->sa_callback(agent->sa_magic, agent, NULL, NULL);
break;
default:
break;
}
return;
}
int nua_stack_launch_network_change_detector(nua_t *nua)
{
su_network_changed_t *snc = NULL;
snc = su_root_add_network_changed(nua->nua_home,
nua->nua_api_root,
nua_network_changed_cb,
nua);
if (!snc)
return -1;
nua->nua_nw_changed = snc;
return 0;
}
......@@ -33,7 +33,6 @@
*/
#include "config.h"
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
......@@ -43,6 +42,7 @@
#include "sofia-sip/su.h"
#include "sofia-sip/su_alloc.h"
#include "sofia-sip/su_wait.h"
#include "sofia-sip/su_debug.h"
#include "sofia-sip/su_os_nw.h"
#include "sofia-sip/su_debug.h"
......@@ -83,7 +83,7 @@ static void su_nw_changed_msg_recv(su_root_magic_t *rm,
assert(magic);
SU_DEBUG_5(("su_nw_changed_msg_recv: entering.\n"));
/* SU_DEBUG_5(("su_nw_changed_msg_recv: entering.\n")); */
snc->su_network_changed_cb(magic, snc->su_root);
......@@ -99,7 +99,7 @@ void nw_changed_cb(SCDynamicStoreRef store,
su_network_changed_t *snc2;
su_msg_r rmsg = SU_MSG_R_INIT;
SU_DEBUG_5(("nw_changed_cb: entering.\n"));
SU_DEBUG_7(("nw_changed_cb: entering.\n"));
if (su_msg_create(rmsg,
su_root_task(snc->su_root),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment