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
This commit is contained in:
Michael Jerris committed 2008-01-23 18:37:33 +00:00
1 parent c7b311fdcd
commit da29143b60
75 files changed
+1976 -727

No files matched your search

+109 -43
View File
@@ -176,9 +176,7 @@ static nta_leg_t *leg_find(nta_agent_t const *sa,
url_t const *request_uri,
sip_call_id_t const *i,
char const *from_tag,
url_t const *from_uri,
char const *to_tag,
url_t const *to_uri);
char const *to_tag);
static nta_leg_t *dst_find(nta_agent_t const *sa, url_t const *u0,
char const *method);
static void leg_recv(nta_leg_t *, msg_t *, sip_t *, tport_t *);
@@ -340,7 +338,7 @@ su_log_t nta_log[] = { SU_LOG_INIT("nta", "NTA_DEBUG", SU_DEBUG) };
* NTATAG_BAD_REQ_MASK(), NTATAG_BAD_RESP_MASK(), NTATAG_BLACKLIST(),
* NTATAG_CANCEL_2543(), NTATAG_CANCEL_487(), NTATAG_CLIENT_RPORT(),
* NTATAG_DEBUG_DROP_PROB(), NTATAG_DEFAULT_PROXY(),
* NTATAG_EXTRA_100(),
* NTATAG_EXTRA_100(), NTATAG_GRAYLIST(),
* NTATAG_MAXSIZE(), NTATAG_MAX_FORWARDS(), NTATAG_MERGE_482(), NTATAG_MCLASS()
* NTATAG_PASS_100(), NTATAG_PASS_408(), NTATAG_PRELOAD(), NTATAG_PROGRESS(),
* NTATAG_REL100(),
@@ -402,6 +400,7 @@ nta_agent_t *nta_agent_create(su_root_t *root,
agent->sa_t4 = NTA_SIP_T4;
agent->sa_t1x64 = 64 * NTA_SIP_T1;
agent->sa_timer_c = 185 * 1000;
agent->sa_graylist = 600;
agent->sa_drop_prob = 0;
agent->sa_is_a_uas = 0;
agent->sa_progress = 60 * 1000;
@@ -896,7 +895,7 @@ void agent_kill_terminator(nta_agent_t *agent)
* NTATAG_BAD_REQ_MASK(), NTATAG_BAD_RESP_MASK(), NTATAG_BLACKLIST(),
* NTATAG_CANCEL_2543(), NTATAG_CANCEL_487(), NTATAG_CLIENT_RPORT(),
* NTATAG_DEBUG_DROP_PROB(), NTATAG_DEFAULT_PROXY(),
* NTATAG_EXTRA_100(),
* NTATAG_EXTRA_100(), NTATAG_GRAYLIST(),
* NTATAG_MAXSIZE(), NTATAG_MAX_FORWARDS(), NTATAG_MERGE_482(), NTATAG_MCLASS()
* NTATAG_PASS_100(), NTATAG_PASS_408(), NTATAG_PRELOAD(), NTATAG_PROGRESS(),
* NTATAG_REL100(),
@@ -946,6 +945,7 @@ int agent_set_params(nta_agent_t *agent, tagi_t *tags)
unsigned sip_t4 = agent->sa_t4;
unsigned sip_t1x64 = agent->sa_t1x64;
unsigned timer_c = agent->sa_timer_c;
unsigned graylist = agent->sa_graylist;
unsigned blacklist = agent->sa_blacklist;
int ua = agent->sa_is_a_uas;
unsigned progress = agent->sa_progress;
@@ -989,6 +989,7 @@ int agent_set_params(nta_agent_t *agent, tagi_t *tags)
NTATAG_DEBUG_DROP_PROB_REF(drop_prob),
NTATAG_DEFAULT_PROXY_REF(proxy),
NTATAG_EXTRA_100_REF(extra_100),
NTATAG_GRAYLIST_REF(graylist),
NTATAG_MAXSIZE_REF(maxsize),
NTATAG_MAX_PROCEEDING_REF(max_proceeding),
NTATAG_MAX_FORWARDS_REF(max_forwards),
@@ -1142,6 +1143,12 @@ int agent_set_params(nta_agent_t *agent, tagi_t *tags)
outgoing_queue_adjust(agent, agent->sa_out.inv_proceeding, timer_c);
}
if (graylist > 24 * 60 * 60)
graylist = 24 * 60 * 60;
agent->sa_graylist = graylist;
if (blacklist > 24 * 60 * 60)
blacklist = 24 * 60 * 60;
agent->sa_blacklist = blacklist;
if (progress == 0)
@@ -1204,7 +1211,7 @@ void agent_set_udp_params(nta_agent_t *self, usize_t udp_mtu)
* NTATAG_CANCEL_2543_REF(), NTATAG_CANCEL_487_REF(),
* NTATAG_CLIENT_RPORT_REF(), NTATAG_CONTACT_REF(),
* NTATAG_DEBUG_DROP_PROB_REF(), NTATAG_DEFAULT_PROXY_REF(),
* NTATAG_EXTRA_100_REF(),
* NTATAG_EXTRA_100_REF(), NTATAG_GRAYLIST_REF(),
* NTATAG_MAXSIZE_REF(), NTATAG_MAX_FORWARDS_REF(), NTATAG_MCLASS_REF(),
* NTATAG_MERGE_482_REF(), NTATAG_MAX_PROCEEDING_REF(),
* NTATAG_PASS_100_REF(), NTATAG_PASS_408_REF(), NTATAG_PRELOAD_REF(),
@@ -1253,6 +1260,7 @@ int agent_get_params(nta_agent_t *agent, tagi_t *tags)
NTATAG_DEBUG_DROP_PROB(agent->sa_drop_prob),
NTATAG_DEFAULT_PROXY(agent->sa_default_proxy),
NTATAG_EXTRA_100(agent->sa_extra_100),
NTATAG_GRAYLIST(agent->sa_graylist),
NTATAG_MAXSIZE(agent->sa_maxsize),
NTATAG_MAX_PROCEEDING(agent->sa_max_proceeding),
NTATAG_MAX_FORWARDS(agent->sa_max_forwards->mf_count),
@@ -2416,8 +2424,8 @@ void agent_recv_request(nta_agent_t *agent,
if ((leg = leg_find(agent,
method_name, url,
sip->sip_call_id,
sip->sip_from->a_tag, sip->sip_from->a_url,
sip->sip_to->a_tag, sip->sip_to->a_url))) {
sip->sip_from->a_tag,
sip->sip_to->a_tag))) {
/* Try existing dialog */
SU_DEBUG_5(("nta: %s (%u) %s\n",
method_name, cseq, "going to existing leg"));
@@ -3991,12 +3999,12 @@ nta_leg_t *nta_leg_by_replaces(nta_agent_t *sa, sip_replaces_t const *rp)
id->i_hash = msg_hash_string(id->i_id = rp->rp_call_id);
leg = leg_find(sa, NULL, NULL, id, from_tag, NULL, to_tag, NULL);
leg = leg_find(sa, NULL, NULL, id, from_tag, to_tag);
if (leg == NULL && strcmp(from_tag, "0") == 0)
leg = leg_find(sa, NULL, NULL, id, NULL, NULL, to_tag, NULL);
leg = leg_find(sa, NULL, NULL, id, NULL, to_tag);
if (leg == NULL && strcmp(to_tag, "0") == 0)
leg = leg_find(sa, NULL, NULL, id, from_tag, NULL, NULL, NULL);
leg = leg_find(sa, NULL, NULL, id, from_tag, NULL);
}
return leg;
@@ -4120,11 +4128,14 @@ int addr_cmp(url_t const *a, url_t const *b)
* @param call_id if non-NULL, must match with @CallID header contents
* @param remote_tag if there is remote tag
* associated with dialog, @a remote_tag must match
* @param remote_uri if there is no remote tag, the remote URI must match
* @param remote_uri ignored
* @param local_tag if non-NULL and there is local tag associated with leg,
* it must math
* @param local_uri if there is no local tag, the local URI must match
* @param local_uri ignored
*
* @note
* If @a remote_tag or @a local_tag is an empty string (""), the tag is
* ignored when matching legs.
*/
nta_leg_t *nta_leg_by_dialog(nta_agent_t const *agent,
url_t const *request_uri,
@@ -4134,7 +4145,7 @@ nta_leg_t *nta_leg_by_dialog(nta_agent_t const *agent,
char const *local_tag,
url_t const *local_uri)
{
void *to_be_freed = NULL, *tbf2 = NULL, *tbf3 = NULL;
void *to_be_freed = NULL;
url_t *url;
url_t url0[1];
nta_leg_t *leg;
@@ -4158,21 +4169,18 @@ nta_leg_t *nta_leg_by_dialog(nta_agent_t const *agent,
agent_aliases(agent, url, NULL); /* canonize url */
}
if (remote_uri && URL_IS_STRING(remote_uri))
request_uri = tbf2 = url_hdup(NULL, remote_uri);
if (remote_tag && remote_tag[0] == '\0')
remote_tag = NULL;
if (local_tag && local_tag[0] == '\0')
local_tag = NULL;
if (local_uri && URL_IS_STRING(local_uri))
local_uri = tbf3 = url_hdup(NULL, local_uri);
leg = leg_find(agent,
NULL, url,
call_id,
remote_tag, remote_uri,
local_tag, local_uri);
remote_tag,
local_tag);
if (to_be_freed) su_free(NULL, to_be_freed);
if (tbf2) su_free(NULL, tbf2);
if (tbf3) su_free(NULL, tbf3);
return leg;
}
@@ -4181,7 +4189,7 @@ nta_leg_t *nta_leg_by_dialog(nta_agent_t const *agent,
* Find a leg corresponding to the request message.
*
* A leg matches to message if leg_match_request() returns true ("Call-ID",
* "To", and "From" match).
* "To"-tag, and "From"-tag match).
*/
static
nta_leg_t *leg_find(nta_agent_t const *sa,
@@ -4189,9 +4197,7 @@ nta_leg_t *leg_find(nta_agent_t const *sa,
url_t const *request_uri,
sip_call_id_t const *i,
char const *from_tag,
url_t const *from_uri,
char const *to_tag,
url_t const *to_uri)
char const *to_tag)
{
hash_value_t hash = i->i_hash;
leg_htable_t const *lht = sa->sa_dialogs;
@@ -4201,10 +4207,9 @@ nta_leg_t *leg_find(nta_agent_t const *sa,
(leg = *ll);
ll = leg_htable_next(lht, ll)) {
sip_call_id_t const *leg_i = leg->leg_id;
url_t const *remote_uri = leg->leg_remote->a_url;
char const *remote_tag = leg->leg_remote->a_tag;
url_t const *local_uri = leg->leg_local->a_url;
char const *local_tag = leg->leg_local->a_tag;
url_t const *leg_url = leg->leg_url;
char const *leg_method = leg->leg_method;
@@ -4212,6 +4217,7 @@ nta_leg_t *leg_find(nta_agent_t const *sa,
continue;
if (strcmp(leg_i->i_id, i->i_id) != 0)
continue;
/* Do not match if the incoming To has tag, but the local does not */
if (!local_tag && to_tag)
continue;
@@ -4226,15 +4232,14 @@ nta_leg_t *leg_find(nta_agent_t const *sa,
/* Do not match if incoming From has no tag but remote has a tag */
if (remote_tag && !from_tag)
continue;
/* Avoid matching with itself */
if (!remote_tag != !from_tag && !local_tag != !to_tag)
continue;
if (local_tag && to_tag ?
strcasecmp(local_tag, to_tag) : addr_cmp(local_uri, to_uri))
if (local_tag && to_tag && strcasecmp(local_tag, to_tag) && to_tag[0])
continue;
if (remote_tag && from_tag ?
strcasecmp(remote_tag, from_tag) : addr_cmp(remote_uri, from_uri))
if (remote_tag && from_tag && strcasecmp(remote_tag, from_tag) && from_tag[0])
continue;
if (leg_url && request_uri && url_cmp(leg_url, request_uri))
@@ -6390,7 +6395,7 @@ static size_t outgoing_timer_c(outgoing_queue_t *q,
char const *timer,
su_duration_t now);
static void outgoing_ack(nta_outgoing_t *orq, msg_t *msg, sip_t *sip);
static void outgoing_ack(nta_outgoing_t *orq, sip_t *sip);
static msg_t *outgoing_ackmsg(nta_outgoing_t *, sip_method_t, char const *,
tagi_t const *tags);
static void outgoing_retransmit(nta_outgoing_t *orq);
@@ -7657,6 +7662,7 @@ void outgoing_queue(outgoing_queue_t *queue,
if (outgoing_is_queued(orq))
outgoing_remove(orq);
assert(orq->orq_next == NULL);
assert(*queue->q_tail == NULL);
orq->orq_timeout = set_timeout(orq->orq_agent, queue->q_timeout);
@@ -7680,7 +7686,7 @@ void outgoing_remove(nta_outgoing_t *orq)
if ((*orq->orq_prev = orq->orq_next))
orq->orq_next->orq_prev = orq->orq_prev;
else
orq->orq_queue->q_tail = orq->orq_prev, assert(!*orq->orq_queue->q_tail);
orq->orq_queue->q_tail = orq->orq_prev;
orq->orq_queue->q_length--;
orq->orq_next = NULL;
@@ -8334,7 +8340,7 @@ int outgoing_recv(nta_outgoing_t *orq,
else {
/* Final response */
if (status >= 300 && !internal)
outgoing_ack(orq, msg, sip);
outgoing_ack(orq, sip);
if (!orq->orq_completed) {
if (outgoing_complete(orq))
@@ -8532,7 +8538,7 @@ static int outgoing_duplicate(nta_outgoing_t *orq,
/** @internal ACK to a final response (300..699).
* These messages are ACK'ed via the original URL (and tport)
*/
void outgoing_ack(nta_outgoing_t *orq, msg_t *msg, sip_t *sip)
void outgoing_ack(nta_outgoing_t *orq, sip_t *sip)
{
nta_outgoing_t *ack;
msg_t *ackmsg;
@@ -8563,7 +8569,7 @@ void outgoing_ack(nta_outgoing_t *orq, msg_t *msg, sip_t *sip)
TAG_END())))
;
else
msg_destroy(msg);
msg_destroy(ackmsg);
}
}
@@ -8836,8 +8842,8 @@ struct sipdns_query
char const *sq_proto;
char const *sq_domain;
char sq_port[6]; /* port number */
uint16_t sq_type;
uint16_t sq_otype; /* origin type of query data (0 means request) */
uint16_t sq_type; /* query type */
uint16_t sq_priority; /* priority or preference */
uint16_t sq_weight; /* preference or weight */
};
@@ -9068,6 +9074,65 @@ outgoing_try_another(nta_outgoing_t *orq)
outgoing_reset_timer(orq);
outgoing_queue(orq->orq_agent->sa_out.resolving, orq);
if (orq->orq_status > 0)
/* PP: don't hack priority if a preliminary response has been received */
;
else if (orq->orq_agent->sa_graylist == 0)
/* PP: priority hacking disabled */
;
/* NetModule hack:
* Move server that did not work to end of queue in sres cache
*
* the next request does not try to use the server that is currently down
*
* @TODO: fix cases with only A or AAAA answering, or all servers down.
*/
else if (sr && sr->sr_target) {
struct sipdns_query *sq;
/* find latest A/AAAA record */
sq = sr->sr_head;
if (!sq || (sr->sr_a_aaaa1 != sr->sr_a_aaaa2 && sq->sq_type == sr->sr_a_aaaa1))
sq = sr->sr_done;
if (sq && sq->sq_otype == sres_type_srv) {
char const *target = sq->sq_domain, *proto = sq->sq_proto;
unsigned prio = sq->sq_priority, maxprio = prio;
SU_DEBUG_5(("nta: no response from %s:%s;transport=%s\n", target, sq->sq_port, proto));
for (sq = sr->sr_head; sq; sq = sq->sq_next)
if (sq->sq_otype == sres_type_srv && sq->sq_priority > maxprio)
maxprio = sq->sq_priority;
for (sq = sr->sr_done; sq; sq = sq->sq_next)
if (sq->sq_otype == sres_type_srv && sq->sq_priority > maxprio)
maxprio = sq->sq_priority;
for (sq = sr->sr_done; sq; sq = sq->sq_next) {
int modified;
if (sq->sq_type != sres_type_srv || strcmp(proto, sq->sq_proto))
continue;
/* modify the SRV record(s) corresponding to the latest A/AAAA record */
modified = sres_set_cached_srv_priority(
orq->orq_agent->sa_resolver,
sq->sq_domain,
target,
sq->sq_port[0] ? (uint16_t)strtoul(sq->sq_port, NULL, 10) : 0,
orq->orq_agent->sa_graylist,
maxprio + 1);
if (modified >= 0)
SU_DEBUG_3(("nta: reduced priority of %d %s SRV records (increase value to %u)\n",
modified, sq->sq_domain, maxprio + 1));
else
SU_DEBUG_3(("nta: failed to reduce %s SRV priority\n", sq->sq_domain));
}
}
}
return outgoing_resolve_next(orq);
}
@@ -9346,6 +9411,7 @@ void outgoing_answer_naptr(sres_context_t *orq,
sq = su_zalloc(home, (sizeof *sq) + rlen);
*tail = sq, tail = &sq->sq_next;
sq->sq_otype = sres_type_naptr;
sq->sq_priority = na->na_prefer;
sq->sq_weight = j;
sq->sq_type = type;
@@ -9446,11 +9512,11 @@ outgoing_answer_srv(sres_context_t *orq, sres_query_t *q,
if (sq) {
*tail = sq, tail = &sq->sq_next;
sq->sq_otype = sres_type_srv;
sq->sq_type = sr->sr_a_aaaa1;
sq->sq_proto = sq0->sq_proto;
sq->sq_domain = memcpy(sq + 1, srv->srv_target, tlen);
snprintf(sq->sq_port, sizeof(sq->sq_port), "%u", srv->srv_port);
sq->sq_priority = srv->srv_priority;
sq->sq_weight = srv->srv_weight;
}
@@ -10143,8 +10209,8 @@ int nta_reliable_leg_prack(nta_reliable_magic_t *magic,
if ((leg = leg_find(irq->irq_agent,
method_name, url,
sip->sip_call_id,
sip->sip_from->a_tag, sip->sip_from->a_url,
sip->sip_to->a_tag, sip->sip_to->a_url))) {
sip->sip_from->a_tag,
sip->sip_to->a_tag))) {
/* Use existing dialog */
SU_DEBUG_5(("nta: %s (%u) %s\n",
method_name, sip->sip_cseq->cs_seq,
@@ -167,6 +167,8 @@ struct nta_agent_s
/** SIP timer C - interval between provisional responses receivedxs */
unsigned sa_timer_c;
/** Graylisting period */
unsigned sa_graylist;
/** Blacklisting period */
unsigned sa_blacklist;
+26 -1
View File
@@ -643,6 +643,31 @@ tag_typedef_t ntatag_progress = UINTTAG_TYPEDEF(progress);
*/
tag_typedef_t ntatag_timer_c = UINTTAG_TYPEDEF(timer_c);
/**@def NTATAG_GRAYLIST(x)
*
* Avoid failed servers.
*
* The NTATAG_GRAYLIST() provides the time that the servers are avoided
* after a request sent to them has been failed. Avoiding means that if a
* domain provides multiple servers, the failed servers are tried last.
*
* @par Used with
* nua_create(), nua_set_params(),
* nta_agent_create(), nta_agent_set_params()
*
* @par Parameter type
* unsigned int
*
* @par Values
* - Number of seconds that server is kept in graylist, from 0 to 86400.
*
* @par Default Value
* - 600 (graylist server for 10 minutes)
*
* @sa NTATAG_BLACKLIST(), NTATAG_TIMEOUT_408()
*/
tag_typedef_t ntatag_graylist = UINTTAG_TYPEDEF(graylist);
/**@def NTATAG_BLACKLIST(x)
*
* Add Retry-After header to error responses returned to application.
@@ -660,7 +685,7 @@ tag_typedef_t ntatag_timer_c = UINTTAG_TYPEDEF(timer_c);
* unsigned int
*
* @par Values
* - Value of delta-seconds in @RetryAfter header
* - Value of @i delta-seconds in @RetryAfter header, from 0 to 86400
*
* @par Default Value
* - 0 (no Retry-After is included)
@@ -203,6 +203,12 @@ NTA_DLL extern tag_typedef_t ntatag_timer_c;
NTA_DLL extern tag_typedef_t ntatag_timer_c_ref;
#define NTATAG_TIMER_C_REF(x) ntatag_timer_c_ref, tag_uint_vr(&(x))
NTA_DLL extern tag_typedef_t ntatag_graylist;
#define NTATAG_GRAYLIST(x) ntatag_graylist, tag_uint_v((x))
NTA_DLL extern tag_typedef_t ntatag_graylist_ref;
#define NTATAG_GRAYLIST_REF(x) ntatag_graylist_ref, tag_uint_vr(&(x))
NTA_DLL extern tag_typedef_t ntatag_blacklist;
#define NTATAG_BLACKLIST(x) ntatag_blacklist, tag_uint_v((x))
+60 -63
View File
@@ -363,8 +363,16 @@ int new_leg_callback_200(agent_t *ag,
return 200;
}
static client_check_f client_check_to_tag;
static client_check_f * const default_checks[];
static client_check_f * const default_checks[] = {
client_check_to_tag,
NULL
};
static client_check_f * const no_default_checks[] = {
NULL
};
int outgoing_callback(client_t *ctx,
nta_outgoing_t *orq,
@@ -1014,14 +1022,6 @@ int save_and_check_tcp(client_t *ctx, nta_outgoing_t *orq, sip_t const *sip)
}
static client_check_f * const default_checks[] = {
client_check_to_tag,
NULL
};
static client_check_f * const no_default_checks[] = {
NULL
};
/* Test transports */
@@ -2256,8 +2256,23 @@ int test_dialog(agent_t *ag)
END();
}
/* Test merging */
static ssize_t recv_udp(agent_t *ag, void *b, size_t size)
{
ssize_t n;
memset(b, size, 0);
for (;;) {
su_root_step(ag->ag_root, 10L);
if (su_wait(ag->ag_sink_wait, 1, 0) == 0) {
n = su_recv(ag->ag_sink_socket, b, size, MSG_TRUNC);
if (n > 0)
return n;
}
}
}
/* Test merging */
int test_merging(agent_t *ag)
{
BEGIN();
@@ -2289,11 +2304,17 @@ int test_merging(agent_t *ag)
size_t len, l1, l2;
su_sockaddr_t *su = ag->ag_su_nta;
socklen_t sulen = ag->ag_su_nta_len;
int n;
#ifndef MSG_TRUNC
#define MSG_TRUNC 0
#endif
/* Empty sink socket */
while (su_wait(ag->ag_sink_wait, 1, 0) == 0)
su_recv(ag->ag_sink_socket, m1, sizeof m1, MSG_TRUNC);
su_setblocking(ag->ag_sink_socket, 0);
while (su_recv(ag->ag_sink_socket, m1, sizeof m1, MSG_TRUNC) >= 0)
;
su_wait(ag->ag_sink_wait, 1, 0);
su_wait(ag->ag_sink_wait, 1, 0);
{
/* RFC 3261 8.2.2.2 Merged Requests:
@@ -2338,16 +2359,9 @@ int test_merging(agent_t *ag)
TEST_1((size_t)su_sendto(ag->ag_sink_socket, m1, l1, 0, su, sulen) == l1);
TEST_1((size_t)su_sendto(ag->ag_sink_socket, m2, l2, 0, su, sulen) == l2);
for (n = 0; n < 2; ) {
su_root_step(ag->ag_root, 10L);
if (su_wait(ag->ag_sink_wait, 1, 0) == 0) {
if (n == 0)
su_recv(ag->ag_sink_socket, r1, sizeof r1, MSG_TRUNC);
else
su_recv(ag->ag_sink_socket, r2, sizeof r2, MSG_TRUNC);
n++;
}
}
recv_udp(ag, r1, sizeof r1);
recv_udp(ag, r2, sizeof r2);
len = strlen("SIP/2.0 200 ");
TEST_1(memcmp(r1, "SIP/2.0 200 ", len) == 0);
TEST_1(memcmp(r2, "SIP/2.0 482 ", len) == 0);
@@ -2355,6 +2369,9 @@ int test_merging(agent_t *ag)
TEST_P(ag->ag_latest_leg, ag->ag_server_leg);
}
while (su_recv(ag->ag_sink_socket, m1, sizeof m1, MSG_TRUNC) >= 0)
;
{
/*
* Check that request with same call-id, cseq and from-tag
@@ -2392,16 +2409,8 @@ int test_merging(agent_t *ag)
TEST_1((size_t)su_sendto(ag->ag_sink_socket, m1, l1, 0, su, sulen) == l1);
TEST_1((size_t)su_sendto(ag->ag_sink_socket, m2, l2, 0, su, sulen) == l2);
for (n = 0; n < 2; ) {
su_root_step(ag->ag_root, 10L);
if (su_wait(ag->ag_sink_wait, 1, 0) == 0) {
if (n == 0)
su_recv(ag->ag_sink_socket, r1, sizeof r1, MSG_TRUNC);
else
su_recv(ag->ag_sink_socket, r2, sizeof r2, MSG_TRUNC);
n++;
}
}
recv_udp(ag, r1, sizeof r1);
recv_udp(ag, r2, sizeof r2);
len = strlen("SIP/2.0 200 ");
TEST_1(memcmp(r1, "SIP/2.0 200 ", len) == 0);
@@ -2410,6 +2419,9 @@ int test_merging(agent_t *ag)
TEST_P(ag->ag_latest_leg, ag->ag_server_leg);
}
while (su_recv(ag->ag_sink_socket, m1, sizeof m1, MSG_TRUNC) >= 0)
;
{
/* test with rfc2543 */
@@ -2440,16 +2452,9 @@ int test_merging(agent_t *ag)
TEST_1((size_t)su_sendto(ag->ag_sink_socket, m1, l1, 0, su, sulen) == l1);
TEST_1((size_t)su_sendto(ag->ag_sink_socket, m2, l2, 0, su, sulen) == l2);
for (n = 0; n < 2; ) {
su_root_step(ag->ag_root, 10L);
if (su_wait(ag->ag_sink_wait, 1, 0) == 0) {
if (n == 0)
su_recv(ag->ag_sink_socket, r1, sizeof r1, MSG_TRUNC);
else
su_recv(ag->ag_sink_socket, r2, sizeof r2, MSG_TRUNC);
n++;
}
}
recv_udp(ag, r1, sizeof r1);
recv_udp(ag, r2, sizeof r2);
l1 = strlen("SIP/2.0 200 ");
TEST_1(memcmp(r1, "SIP/2.0 200 ", l1) == 0);
TEST_1(memcmp(r2, "SIP/2.0 482 ", l1) == 0);
@@ -2457,6 +2462,9 @@ int test_merging(agent_t *ag)
TEST_P(ag->ag_latest_leg, ag->ag_server_leg);
}
while (su_recv(ag->ag_sink_socket, m1, sizeof m1, MSG_TRUNC) >= 0)
;
{
/* test with to-tag */
@@ -2487,16 +2495,9 @@ int test_merging(agent_t *ag)
TEST_1((size_t)su_sendto(ag->ag_sink_socket, m1, l1, 0, su, sulen) == l1);
TEST_1((size_t)su_sendto(ag->ag_sink_socket, m2, l2, 0, su, sulen) == l2);
for (n = 0; n < 2; ) {
su_root_step(ag->ag_root, 10L);
if (su_wait(ag->ag_sink_wait, 1, 0) == 0) {
if (n == 0)
su_recv(ag->ag_sink_socket, r1, sizeof r1, MSG_TRUNC);
else
su_recv(ag->ag_sink_socket, r2, sizeof r2, MSG_TRUNC);
n++;
}
}
recv_udp(ag, r1, sizeof r1);
recv_udp(ag, r2, sizeof r2);
l1 = strlen("SIP/2.0 200 ");
TEST_1(memcmp(r1, "SIP/2.0 200 ", l1) == 0);
TEST_1(memcmp(r2, "SIP/2.0 482 ", l1) != 0);
@@ -2504,6 +2505,9 @@ int test_merging(agent_t *ag)
TEST_P(ag->ag_latest_leg, ag->ag_server_leg);
}
while (su_recv(ag->ag_sink_socket, m1, sizeof m1, MSG_TRUNC) >= 0)
;
{
/* test with rfc2543 and to-tag */
@@ -2532,16 +2536,9 @@ int test_merging(agent_t *ag)
TEST_1((size_t)su_sendto(ag->ag_sink_socket, m1, l1, 0, su, sulen) == l1);
TEST_1((size_t)su_sendto(ag->ag_sink_socket, m2, l2, 0, su, sulen) == l2);
for (n = 0; n < 2; ) {
su_root_step(ag->ag_root, 10L);
if (su_wait(ag->ag_sink_wait, 1, 0) == 0) {
if (n == 0)
su_recv(ag->ag_sink_socket, r1, sizeof r1, MSG_TRUNC);
else
su_recv(ag->ag_sink_socket, r2, sizeof r2, MSG_TRUNC);
n++;
}
}
recv_udp(ag, r1, sizeof r1);
recv_udp(ag, r2, sizeof r2);
l1 = strlen("SIP/2.0 200 ");
TEST_1(memcmp(r1, "SIP/2.0 200 ", l1) == 0);
TEST_1(memcmp(r2, "SIP/2.0 482 ", l1) != 0);
@@ -1268,15 +1268,17 @@ static int api_test_dialog_matching(agent_t *ag)
TEST_P(leg = nta_leg_by_dialog(nta, (url_t *)"sip:pc.al.us", i,
"xyzzy", a2->a_url, a1->a_tag, a1->a_url),
dialog1);
#if nomore
/* remote url is required */
TEST_P(leg = nta_leg_by_dialog(nta, (url_t *)"sip:pc.al.us", i,
a2->a_tag, a1->a_url, a1->a_tag, a1->a_url),
NULL);
#endif
TEST_P(leg = nta_leg_by_dialog(nta, (url_t *)"sip:pc.al.us", i,
a2->a_tag, NULL, a1->a_tag, a1->a_url),
dialog1);
/* local url is used if there is no local tag */
/* local url is used if there is no local tag */ /* XXX - not really */
TEST_P(leg = nta_leg_by_dialog(nta, (url_t *)"sip:pc.al.us", i,
a2->a_tag, a2->a_url, NULL, NULL),
NULL);