unpull a number of patches from the previous darcs merge to try to eliminate some causes of new segfaults in sofia-sip

Wed Jan 23 11:05:58 EST 2008  Pekka.Pessi@nokia.com
  * nta.c: asserting in proper place when handling queue tail
Shall I unpull this patch? (4/553)  [ynWvpxqadjk], or ? for help: y

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
Shall I unpull this patch? (5/553)  [ynWvpxqadjk], or ? for help: y

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().
Shall I unpull this patch? (14/553)  [ynWvpxqadjk], or ? for help: y

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().
Shall I unpull this patch? (15/553)  [ynWvpxqadjk], or ? for help: y

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.
Shall I unpull this patch? (22/553)  [ynWvpxqadjk], or ? for help: y

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.
Shall I unpull this patch? (26/553)  [ynWvpxqadjk], or ? for help: y

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.
Shall I unpull this patch? (51/553)  [ynWvpxqadjk], or ? for help: y

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
Shall I unpull this patch? (53/553)  [ynWvpxqadjk], or ? for help: y




git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7354 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2008-01-25 17:42:24 +00:00
parent 82ac8dceb1
commit 1103bf8b19
14 changed files with 81 additions and 206 deletions

View File

@ -338,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_BAD_REQ_MASK(), NTATAG_BAD_RESP_MASK(), NTATAG_BLACKLIST(),
* NTATAG_CANCEL_2543(), NTATAG_CANCEL_487(), NTATAG_CLIENT_RPORT(), * NTATAG_CANCEL_2543(), NTATAG_CANCEL_487(), NTATAG_CLIENT_RPORT(),
* NTATAG_DEBUG_DROP_PROB(), NTATAG_DEFAULT_PROXY(), * NTATAG_DEBUG_DROP_PROB(), NTATAG_DEFAULT_PROXY(),
* NTATAG_EXTRA_100(), NTATAG_GRAYLIST(), * NTATAG_EXTRA_100(),
* NTATAG_MAXSIZE(), NTATAG_MAX_FORWARDS(), NTATAG_MERGE_482(), NTATAG_MCLASS() * NTATAG_MAXSIZE(), NTATAG_MAX_FORWARDS(), NTATAG_MERGE_482(), NTATAG_MCLASS()
* NTATAG_PASS_100(), NTATAG_PASS_408(), NTATAG_PRELOAD(), NTATAG_PROGRESS(), * NTATAG_PASS_100(), NTATAG_PASS_408(), NTATAG_PRELOAD(), NTATAG_PROGRESS(),
* NTATAG_REL100(), * NTATAG_REL100(),
@ -400,7 +400,6 @@ nta_agent_t *nta_agent_create(su_root_t *root,
agent->sa_t4 = NTA_SIP_T4; agent->sa_t4 = NTA_SIP_T4;
agent->sa_t1x64 = 64 * NTA_SIP_T1; agent->sa_t1x64 = 64 * NTA_SIP_T1;
agent->sa_timer_c = 185 * 1000; agent->sa_timer_c = 185 * 1000;
agent->sa_graylist = 600;
agent->sa_drop_prob = 0; agent->sa_drop_prob = 0;
agent->sa_is_a_uas = 0; agent->sa_is_a_uas = 0;
agent->sa_progress = 60 * 1000; agent->sa_progress = 60 * 1000;
@ -895,7 +894,7 @@ void agent_kill_terminator(nta_agent_t *agent)
* NTATAG_BAD_REQ_MASK(), NTATAG_BAD_RESP_MASK(), NTATAG_BLACKLIST(), * NTATAG_BAD_REQ_MASK(), NTATAG_BAD_RESP_MASK(), NTATAG_BLACKLIST(),
* NTATAG_CANCEL_2543(), NTATAG_CANCEL_487(), NTATAG_CLIENT_RPORT(), * NTATAG_CANCEL_2543(), NTATAG_CANCEL_487(), NTATAG_CLIENT_RPORT(),
* NTATAG_DEBUG_DROP_PROB(), NTATAG_DEFAULT_PROXY(), * NTATAG_DEBUG_DROP_PROB(), NTATAG_DEFAULT_PROXY(),
* NTATAG_EXTRA_100(), NTATAG_GRAYLIST(), * NTATAG_EXTRA_100(),
* NTATAG_MAXSIZE(), NTATAG_MAX_FORWARDS(), NTATAG_MERGE_482(), NTATAG_MCLASS() * NTATAG_MAXSIZE(), NTATAG_MAX_FORWARDS(), NTATAG_MERGE_482(), NTATAG_MCLASS()
* NTATAG_PASS_100(), NTATAG_PASS_408(), NTATAG_PRELOAD(), NTATAG_PROGRESS(), * NTATAG_PASS_100(), NTATAG_PASS_408(), NTATAG_PRELOAD(), NTATAG_PROGRESS(),
* NTATAG_REL100(), * NTATAG_REL100(),
@ -945,7 +944,6 @@ int agent_set_params(nta_agent_t *agent, tagi_t *tags)
unsigned sip_t4 = agent->sa_t4; unsigned sip_t4 = agent->sa_t4;
unsigned sip_t1x64 = agent->sa_t1x64; unsigned sip_t1x64 = agent->sa_t1x64;
unsigned timer_c = agent->sa_timer_c; unsigned timer_c = agent->sa_timer_c;
unsigned graylist = agent->sa_graylist;
unsigned blacklist = agent->sa_blacklist; unsigned blacklist = agent->sa_blacklist;
int ua = agent->sa_is_a_uas; int ua = agent->sa_is_a_uas;
unsigned progress = agent->sa_progress; unsigned progress = agent->sa_progress;
@ -989,7 +987,6 @@ int agent_set_params(nta_agent_t *agent, tagi_t *tags)
NTATAG_DEBUG_DROP_PROB_REF(drop_prob), NTATAG_DEBUG_DROP_PROB_REF(drop_prob),
NTATAG_DEFAULT_PROXY_REF(proxy), NTATAG_DEFAULT_PROXY_REF(proxy),
NTATAG_EXTRA_100_REF(extra_100), NTATAG_EXTRA_100_REF(extra_100),
NTATAG_GRAYLIST_REF(graylist),
NTATAG_MAXSIZE_REF(maxsize), NTATAG_MAXSIZE_REF(maxsize),
NTATAG_MAX_PROCEEDING_REF(max_proceeding), NTATAG_MAX_PROCEEDING_REF(max_proceeding),
NTATAG_MAX_FORWARDS_REF(max_forwards), NTATAG_MAX_FORWARDS_REF(max_forwards),
@ -1143,12 +1140,6 @@ int agent_set_params(nta_agent_t *agent, tagi_t *tags)
outgoing_queue_adjust(agent, agent->sa_out.inv_proceeding, timer_c); 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; agent->sa_blacklist = blacklist;
if (progress == 0) if (progress == 0)
@ -1211,7 +1202,7 @@ void agent_set_udp_params(nta_agent_t *self, usize_t udp_mtu)
* NTATAG_CANCEL_2543_REF(), NTATAG_CANCEL_487_REF(), * NTATAG_CANCEL_2543_REF(), NTATAG_CANCEL_487_REF(),
* NTATAG_CLIENT_RPORT_REF(), NTATAG_CONTACT_REF(), * NTATAG_CLIENT_RPORT_REF(), NTATAG_CONTACT_REF(),
* NTATAG_DEBUG_DROP_PROB_REF(), NTATAG_DEFAULT_PROXY_REF(), * NTATAG_DEBUG_DROP_PROB_REF(), NTATAG_DEFAULT_PROXY_REF(),
* NTATAG_EXTRA_100_REF(), NTATAG_GRAYLIST_REF(), * NTATAG_EXTRA_100_REF(),
* NTATAG_MAXSIZE_REF(), NTATAG_MAX_FORWARDS_REF(), NTATAG_MCLASS_REF(), * NTATAG_MAXSIZE_REF(), NTATAG_MAX_FORWARDS_REF(), NTATAG_MCLASS_REF(),
* NTATAG_MERGE_482_REF(), NTATAG_MAX_PROCEEDING_REF(), * NTATAG_MERGE_482_REF(), NTATAG_MAX_PROCEEDING_REF(),
* NTATAG_PASS_100_REF(), NTATAG_PASS_408_REF(), NTATAG_PRELOAD_REF(), * NTATAG_PASS_100_REF(), NTATAG_PASS_408_REF(), NTATAG_PRELOAD_REF(),
@ -1260,7 +1251,6 @@ int agent_get_params(nta_agent_t *agent, tagi_t *tags)
NTATAG_DEBUG_DROP_PROB(agent->sa_drop_prob), NTATAG_DEBUG_DROP_PROB(agent->sa_drop_prob),
NTATAG_DEFAULT_PROXY(agent->sa_default_proxy), NTATAG_DEFAULT_PROXY(agent->sa_default_proxy),
NTATAG_EXTRA_100(agent->sa_extra_100), NTATAG_EXTRA_100(agent->sa_extra_100),
NTATAG_GRAYLIST(agent->sa_graylist),
NTATAG_MAXSIZE(agent->sa_maxsize), NTATAG_MAXSIZE(agent->sa_maxsize),
NTATAG_MAX_PROCEEDING(agent->sa_max_proceeding), NTATAG_MAX_PROCEEDING(agent->sa_max_proceeding),
NTATAG_MAX_FORWARDS(agent->sa_max_forwards->mf_count), NTATAG_MAX_FORWARDS(agent->sa_max_forwards->mf_count),
@ -4133,9 +4123,6 @@ int addr_cmp(url_t const *a, url_t const *b)
* it must math * it must math
* @param local_uri ignored * @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, nta_leg_t *nta_leg_by_dialog(nta_agent_t const *agent,
url_t const *request_uri, url_t const *request_uri,
@ -4237,9 +4224,9 @@ nta_leg_t *leg_find(nta_agent_t const *sa,
if (!remote_tag != !from_tag && !local_tag != !to_tag) if (!remote_tag != !from_tag && !local_tag != !to_tag)
continue; continue;
if (local_tag && to_tag && strcasecmp(local_tag, to_tag) && to_tag[0]) if (local_tag && to_tag && strcasecmp(local_tag, to_tag))
continue; continue;
if (remote_tag && from_tag && strcasecmp(remote_tag, from_tag) && from_tag[0]) if (remote_tag && from_tag && strcasecmp(remote_tag, from_tag))
continue; continue;
if (leg_url && request_uri && url_cmp(leg_url, request_uri)) if (leg_url && request_uri && url_cmp(leg_url, request_uri))
@ -7662,7 +7649,6 @@ void outgoing_queue(outgoing_queue_t *queue,
if (outgoing_is_queued(orq)) if (outgoing_is_queued(orq))
outgoing_remove(orq); outgoing_remove(orq);
assert(orq->orq_next == NULL);
assert(*queue->q_tail == NULL); assert(*queue->q_tail == NULL);
orq->orq_timeout = set_timeout(orq->orq_agent, queue->q_timeout); orq->orq_timeout = set_timeout(orq->orq_agent, queue->q_timeout);
@ -7686,7 +7672,7 @@ void outgoing_remove(nta_outgoing_t *orq)
if ((*orq->orq_prev = orq->orq_next)) if ((*orq->orq_prev = orq->orq_next))
orq->orq_next->orq_prev = orq->orq_prev; orq->orq_next->orq_prev = orq->orq_prev;
else else
orq->orq_queue->q_tail = orq->orq_prev; orq->orq_queue->q_tail = orq->orq_prev, assert(!*orq->orq_queue->q_tail);
orq->orq_queue->q_length--; orq->orq_queue->q_length--;
orq->orq_next = NULL; orq->orq_next = NULL;
@ -8842,8 +8828,8 @@ struct sipdns_query
char const *sq_proto; char const *sq_proto;
char const *sq_domain; char const *sq_domain;
char sq_port[6]; /* port number */ char sq_port[6]; /* port number */
uint16_t sq_otype; /* origin type of query data (0 means request) */
uint16_t sq_type; /* query type */ uint16_t sq_type;
uint16_t sq_priority; /* priority or preference */ uint16_t sq_priority; /* priority or preference */
uint16_t sq_weight; /* preference or weight */ uint16_t sq_weight; /* preference or weight */
}; };
@ -9074,65 +9060,6 @@ outgoing_try_another(nta_outgoing_t *orq)
outgoing_reset_timer(orq); outgoing_reset_timer(orq);
outgoing_queue(orq->orq_agent->sa_out.resolving, 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); return outgoing_resolve_next(orq);
} }
@ -9411,7 +9338,6 @@ void outgoing_answer_naptr(sres_context_t *orq,
sq = su_zalloc(home, (sizeof *sq) + rlen); sq = su_zalloc(home, (sizeof *sq) + rlen);
*tail = sq, tail = &sq->sq_next; *tail = sq, tail = &sq->sq_next;
sq->sq_otype = sres_type_naptr;
sq->sq_priority = na->na_prefer; sq->sq_priority = na->na_prefer;
sq->sq_weight = j; sq->sq_weight = j;
sq->sq_type = type; sq->sq_type = type;
@ -9512,11 +9438,11 @@ outgoing_answer_srv(sres_context_t *orq, sres_query_t *q,
if (sq) { if (sq) {
*tail = sq, tail = &sq->sq_next; *tail = sq, tail = &sq->sq_next;
sq->sq_otype = sres_type_srv;
sq->sq_type = sr->sr_a_aaaa1; sq->sq_type = sr->sr_a_aaaa1;
sq->sq_proto = sq0->sq_proto; sq->sq_proto = sq0->sq_proto;
sq->sq_domain = memcpy(sq + 1, srv->srv_target, tlen); sq->sq_domain = memcpy(sq + 1, srv->srv_target, tlen);
snprintf(sq->sq_port, sizeof(sq->sq_port), "%u", srv->srv_port); snprintf(sq->sq_port, sizeof(sq->sq_port), "%u", srv->srv_port);
sq->sq_priority = srv->srv_priority; sq->sq_priority = srv->srv_priority;
sq->sq_weight = srv->srv_weight; sq->sq_weight = srv->srv_weight;
} }

View File

@ -167,8 +167,6 @@ struct nta_agent_s
/** SIP timer C - interval between provisional responses receivedxs */ /** SIP timer C - interval between provisional responses receivedxs */
unsigned sa_timer_c; unsigned sa_timer_c;
/** Graylisting period */
unsigned sa_graylist;
/** Blacklisting period */ /** Blacklisting period */
unsigned sa_blacklist; unsigned sa_blacklist;

View File

@ -643,31 +643,6 @@ tag_typedef_t ntatag_progress = UINTTAG_TYPEDEF(progress);
*/ */
tag_typedef_t ntatag_timer_c = UINTTAG_TYPEDEF(timer_c); 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) /**@def NTATAG_BLACKLIST(x)
* *
* Add Retry-After header to error responses returned to application. * Add Retry-After header to error responses returned to application.
@ -685,7 +660,7 @@ tag_typedef_t ntatag_graylist = UINTTAG_TYPEDEF(graylist);
* unsigned int * unsigned int
* *
* @par Values * @par Values
* - Value of @i delta-seconds in @RetryAfter header, from 0 to 86400 * - Value of delta-seconds in @RetryAfter header
* *
* @par Default Value * @par Default Value
* - 0 (no Retry-After is included) * - 0 (no Retry-After is included)

View File

@ -203,12 +203,6 @@ NTA_DLL extern tag_typedef_t ntatag_timer_c;
NTA_DLL extern tag_typedef_t ntatag_timer_c_ref; NTA_DLL extern tag_typedef_t ntatag_timer_c_ref;
#define NTATAG_TIMER_C_REF(x) ntatag_timer_c_ref, tag_uint_vr(&(x)) #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; NTA_DLL extern tag_typedef_t ntatag_blacklist;
#define NTATAG_BLACKLIST(x) ntatag_blacklist, tag_uint_v((x)) #define NTATAG_BLACKLIST(x) ntatag_blacklist, tag_uint_v((x))

View File

@ -883,7 +883,8 @@ sip_security_client_select(sip_security_client_t const *client,
* decide whether to gracefully terminate or not, the * decide whether to gracefully terminate or not, the
* @a *return_graceful_terminate_usage is left unmodified. * @a *return_graceful_terminate_usage is left unmodified.
* *
* @RFC 5057 * @sa
* http://www.ietf.org/internet-drafts/draft-ietf-sipping-dialogusage-02.txt
*/ */
int sip_response_terminates_dialog(int response_code, int sip_response_terminates_dialog(int response_code,
sip_method_t method, sip_method_t method,
@ -1059,6 +1060,8 @@ int sip_response_terminates_dialog(int response_code,
usage in an existing dialog, no new usage is created and existing usage in an existing dialog, no new usage is created and existing
usages are unaffected. usages are unaffected.
*/ */
*return_graceful_terminate_usage = 0;
return 0;
case 423: /** @par 423 Interval Too Brief case 423: /** @par 423 Interval Too Brief
@ -1067,6 +1070,8 @@ int sip_response_terminates_dialog(int response_code,
subscribe usage is not destroyed (or otherwise affected). No subscribe usage is not destroyed (or otherwise affected). No
other usages of the dialog are affected. other usages of the dialog are affected.
*/ */
*return_graceful_terminate_usage = 0;
return sip_method_subscribe == method ? terminate_usage : no_effect;
case 428: /** @par 428 Use Identity Header case 428: /** @par 428 Use Identity Header
@ -1074,6 +1079,8 @@ int sip_response_terminates_dialog(int response_code,
the usage. The usage is not affected. The dialog is only the usage. The usage is not affected. The dialog is only
affected by a change in its local @CSeq. No other usages of the affected by a change in its local @CSeq. No other usages of the
dialog are affected. */ dialog are affected. */
*return_graceful_terminate_usage = 0;
return 0;
case 429: /** @par 429 Provide Referrer Identity case 429: /** @par 429 Provide Referrer Identity

View File

@ -70,6 +70,10 @@ static char const __func__[] = "soa";
/* ======================================================================== */ /* ======================================================================== */
/* Internal prototypes */ /* Internal prototypes */
void soa_set_activity(soa_session_t *ss,
sdp_media_t const *,
int remote);
su_inline int soa_media_is_ready(soa_session_t const *ss); su_inline int soa_media_is_ready(soa_session_t const *ss);
enum soa_sdp_kind { enum soa_sdp_kind {
@ -1167,7 +1171,7 @@ int soa_base_set_remote_sdp(soa_session_t *ss,
if (!new_version) if (!new_version)
return 0; return 0;
soa_set_activity(ss, sdp->sdp_media, soa_activity_remote); soa_set_activity(ss, sdp->sdp_media, 1);
ss->ss_remote_version++; ss->ss_remote_version++;
@ -1450,7 +1454,7 @@ int soa_base_generate_offer(soa_session_t *ss,
if (!sdp) if (!sdp)
return -1; return -1;
soa_set_activity(ss, sdp->sdp_media, soa_activity_local); /* Wanted activity */ soa_set_activity(ss, sdp->sdp_media, 0);
ss->ss_offer_sent = 1; ss->ss_offer_sent = 1;
ss->ss_answer_recv = 0; ss->ss_answer_recv = 0;
@ -1538,7 +1542,8 @@ int soa_base_generate_answer(soa_session_t *ss,
su_free(ss->ss_home, ss->ss_rsession); su_free(ss->ss_home, ss->ss_rsession);
ss->ss_rsession = rsession; ss->ss_rsession = rsession;
soa_set_activity(ss, l_sdp->sdp_media, soa_activity_session); soa_set_activity(ss, l_sdp->sdp_media, 0);
soa_set_activity(ss, r_sdp->sdp_media, 1);
ss->ss_offer_recv = 1; ss->ss_offer_recv = 1;
ss->ss_answer_sent = 1; ss->ss_answer_sent = 1;
@ -1619,7 +1624,8 @@ int soa_base_process_answer(soa_session_t *ss,
su_free(ss->ss_home, ss->ss_rsession); su_free(ss->ss_home, ss->ss_rsession);
ss->ss_rsession = rsession; ss->ss_rsession = rsession;
soa_set_activity(ss, l_sdp->sdp_media, soa_activity_session); soa_set_activity(ss, l_sdp->sdp_media, 0);
soa_set_activity(ss, r_sdp->sdp_media, 1);
ss->ss_answer_recv = 1; ss->ss_answer_recv = 1;
ss->ss_complete = 1; ss->ss_complete = 1;
@ -1686,7 +1692,7 @@ int soa_base_process_reject(soa_session_t *ss,
if (!l_sdp) if (!l_sdp)
return -1; return -1;
soa_set_activity(ss, l_sdp->sdp_media, soa_activity_session); soa_set_activity(ss, l_sdp->sdp_media, 0);
ss->ss_offer_sent = 0; ss->ss_offer_sent = 0;
@ -1777,7 +1783,8 @@ void soa_base_terminate(soa_session_t *ss, char const *option)
ss->ss_oa_rounds = 0; ss->ss_oa_rounds = 0;
soa_description_free(ss, ss->ss_remote); soa_description_free(ss, ss->ss_remote);
soa_set_activity(ss, NULL, soa_activity_session); soa_set_activity(ss, NULL, 0);
soa_set_activity(ss, NULL, 1);
} }
/** Return true if the SDP Offer/Answer negotation is complete. /** Return true if the SDP Offer/Answer negotation is complete.
@ -1882,75 +1889,56 @@ int soa_media_is_ready(soa_session_t const *ss)
void soa_set_activity(soa_session_t *ss, void soa_set_activity(soa_session_t *ss,
sdp_media_t const *m, sdp_media_t const *m,
enum soa_activity activity) int remote)
{ {
struct soa_media_activity *ma; struct soa_media_activity *ma;
sdp_connection_t const *c; sdp_connection_t const *c;
int mode, swap; int mode;
int l_audio = SOA_ACTIVE_DISABLED, r_audio = SOA_ACTIVE_DISABLED; int ma_audio = SOA_ACTIVE_DISABLED;
int l_video = SOA_ACTIVE_DISABLED, r_video = SOA_ACTIVE_DISABLED; int ma_video = SOA_ACTIVE_DISABLED;
int l_chat = SOA_ACTIVE_DISABLED, r_chat = SOA_ACTIVE_DISABLED; int ma_chat = SOA_ACTIVE_DISABLED;
int l_image = SOA_ACTIVE_DISABLED, r_image = SOA_ACTIVE_DISABLED; int ma_image = SOA_ACTIVE_DISABLED;
int *p;
int *l, *r; remote = !!remote;
ma = remote ? ss->ss_remote_activity : ss->ss_local_activity;
for (; m; m = m->m_next) { for (; m; m = m->m_next) {
if (m->m_type == sdp_media_audio) if (m->m_type == sdp_media_audio)
l = &l_audio, r = &r_audio; p = &ma_audio;
else if (m->m_type == sdp_media_video) else if (m->m_type == sdp_media_video)
l = &l_video, r = &r_video; p = &ma_video;
else if (m->m_type == sdp_media_image) else if (m->m_type == sdp_media_image)
l = &l_image, r = &r_image; p = &ma_image;
else if (strcasecmp(m->m_type_name, "message") == 0) else if (strcasecmp(m->m_type_name, "message") == 0)
l = &l_chat, r = &r_chat; p = &ma_chat;
else else
continue; continue;
if (m->m_rejected) { if (m->m_rejected) {
if (*l < 0) *l = SOA_ACTIVE_REJECTED; if (*p < 0)
if (*r < 0) *r = SOA_ACTIVE_REJECTED; *p = SOA_ACTIVE_REJECTED;
continue; continue;
} }
mode = m->m_mode, swap = ((mode << 1) & 2) | ((mode >> 1) & 1); mode = m->m_mode;
c = sdp_media_connections((sdp_media_t *)m); c = sdp_media_connections((sdp_media_t *)m);
switch (activity) { if (remote != (c && c->c_mcast))
case soa_activity_local: mode = ((mode << 1) & 2) | ((mode >> 1) & 1);
*l &= SOA_ACTIVE_SENDRECV;
*l |= c && c->c_mcast ? swap : mode; if (*p < 0)
break; *p = mode;
case soa_activity_remote: else
*r &= SOA_ACTIVE_SENDRECV; *p |= mode;
*r = c && c->c_mcast ? mode : swap;
break;
case soa_activity_session:
*l &= SOA_ACTIVE_SENDRECV;
*l |= c && c->c_mcast ? swap : mode;
*r &= SOA_ACTIVE_SENDRECV;
*r = c && c->c_mcast ? swap : mode;
break;
}
} }
if (activity == soa_activity_local || ma->ma_audio = ma_audio;
activity == soa_activity_session) { ma->ma_video = ma_video;
ma = ss->ss_local_activity; ma->ma_image = ma_image;
ma->ma_audio = l_audio; ma->ma_chat = ma_chat;
ma->ma_video = l_video;
ma->ma_image = l_image;
ma->ma_chat = l_chat;
}
if (activity == soa_activity_remote ||
activity == soa_activity_session) {
ma = ss->ss_remote_activity;
ma->ma_audio = r_audio;
ma->ma_video = r_video;
ma->ma_image = r_image;
ma->ma_chat = r_chat;
}
} }
/* ----------------------------------------------------------------------*/ /* ----------------------------------------------------------------------*/

View File

@ -238,11 +238,8 @@ SOFIAPUBFUN int soa_has_received_sdp(soa_session_t const *ss);
SOFIAPUBFUN int soa_set_status(soa_session_t *ss, SOFIAPUBFUN int soa_set_status(soa_session_t *ss,
int status, char const *phrase); int status, char const *phrase);
enum soa_activity { soa_activity_local, soa_activity_remote, soa_activity_session };
SOFIAPUBFUN void soa_set_activity(soa_session_t *ss, SOFIAPUBFUN void soa_set_activity(soa_session_t *ss,
sdp_media_t const *m, sdp_media_t const *m, int remote);
enum soa_activity activity);
SOFIAPUBFUN int soa_description_set(soa_session_t *ss, SOFIAPUBFUN int soa_description_set(soa_session_t *ss,
struct soa_description *ssd, struct soa_description *ssd,

View File

@ -1376,7 +1376,7 @@ int test_asynch_offer_answer(struct context *ctx)
{ {
BEGIN(); BEGIN();
#if 0 /* This has never been implemented */ #if 0
int n; int n;
char const *caps = NONE, *offer = NONE, *answer = NONE; char const *caps = NONE, *offer = NONE, *answer = NONE;

View File

@ -218,13 +218,21 @@ sres_record_t **sres_cached_answers_sockaddr(sres_resolver_t *res,
uint16_t type, uint16_t type,
struct sockaddr const *addr); struct sockaddr const *addr);
/**Modify the priority of the specified SRV records. */ /**Modify the priority of the specified SRV records.
*
* @param res pointer to resolver object
* @param service domain name of the SRV records to search in cache
* @param target target to lower the prio
* @param port port number to lower the prio
* @param newprio new priority value
*
* @return Number of modified records on success, -1 otherwise
*/
SRESPUBFUN SRESPUBFUN
int sres_set_cached_srv_priority(sres_resolver_t *res, int sres_set_cached_srv_priority(sres_resolver_t *res,
char const *domain, char const *domain,
char const *target, char const *target,
uint16_t port, uint16_t port,
uint32_t newttl,
uint16_t newprio); uint16_t newprio);

View File

@ -107,8 +107,7 @@ SRESPUBFUN int sres_cache_set_srv_priority(sres_cache_t *,
char const *domain, char const *domain,
char const *target, char const *target,
uint16_t port, uint16_t port,
uint32_t newttl, uint16_t prio);
uint16_t newprio);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1358,7 +1358,6 @@ sres_cached_answers_sockaddr(sres_resolver_t *res,
* @param target SRV target of the SRV record(s) to modify * @param target SRV target of the SRV record(s) to modify
* @param port port number of SRV record(s) to modify * @param port port number of SRV record(s) to modify
* (in host byte order) * (in host byte order)
* @param ttl new ttl for SRV records of the domain
* @param priority new priority value (0=highest, 65535=lowest) * @param priority new priority value (0=highest, 65535=lowest)
* *
* @sa sres_cache_set_srv_priority() * @sa sres_cache_set_srv_priority()
@ -1369,7 +1368,6 @@ int sres_set_cached_srv_priority(sres_resolver_t *res,
char const *domain, char const *domain,
char const *target, char const *target,
uint16_t port, uint16_t port,
uint32_t ttl,
uint16_t priority) uint16_t priority)
{ {
char rooted_domain[SRES_MAXDNAME]; char rooted_domain[SRES_MAXDNAME];
@ -1383,8 +1381,7 @@ int sres_set_cached_srv_priority(sres_resolver_t *res,
return -1; return -1;
return sres_cache_set_srv_priority(res->res_cache, return sres_cache_set_srv_priority(res->res_cache,
domain, target, port, domain, target, port, priority);
ttl, priority);
} }

View File

@ -483,7 +483,6 @@ void sres_cache_clean(sres_cache_t *cache, time_t now)
* @param target SRV target of the SRV record(s) to modify * @param target SRV target of the SRV record(s) to modify
* @param port port number of SRV record(s) to modify * @param port port number of SRV record(s) to modify
* (in host byte order) * (in host byte order)
* @param ttl new ttl
* @param priority new priority value (0=highest, 65535=lowest) * @param priority new priority value (0=highest, 65535=lowest)
* *
* @sa sres_set_cached_srv_priority() * @sa sres_set_cached_srv_priority()
@ -494,14 +493,12 @@ int sres_cache_set_srv_priority(sres_cache_t *cache,
char const *domain, char const *domain,
char const *target, char const *target,
uint16_t port, uint16_t port,
uint32_t ttl,
uint16_t priority) uint16_t priority)
{ {
int ret = 0; int ret = 0;
unsigned hash; unsigned hash;
sres_rr_hash_entry_t **iter; sres_rr_hash_entry_t **iter;
time_t expires;
if (cache == NULL || domain == NULL || target == NULL) if (cache == NULL || domain == NULL || target == NULL)
return -1; return -1;
@ -510,9 +507,6 @@ int sres_cache_set_srv_priority(sres_cache_t *cache,
if (!LOCK(cache)) if (!LOCK(cache))
return -1; return -1;
time(&expires);
expires += ttl;
for (iter = sres_htable_hash(cache->cache_hash, hash); for (iter = sres_htable_hash(cache->cache_hash, hash);
iter && *iter; iter && *iter;
iter = sres_htable_next(cache->cache_hash, iter)) { iter = sres_htable_next(cache->cache_hash, iter)) {
@ -520,17 +514,13 @@ int sres_cache_set_srv_priority(sres_cache_t *cache,
if (rr && rr->sr_name && if (rr && rr->sr_name &&
sres_type_srv == rr->sr_type && sres_type_srv == rr->sr_type &&
(port == 0 || rr->sr_srv->srv_port == port) &&
rr->sr_srv->srv_target &&
strcasecmp(rr->sr_srv->srv_target, target) == 0 &&
strcasecmp(rr->sr_name, domain) == 0) { strcasecmp(rr->sr_name, domain) == 0) {
/* record found --> change priority of server */
(*iter)->rr_expires = expires; rr->sr_srv->srv_priority = priority;
ret++;
if ((port == 0 || rr->sr_srv->srv_port == port) &&
rr->sr_srv->srv_target &&
strcasecmp(rr->sr_srv->srv_target, target) == 0) {
/* record found --> change priority of server */
rr->sr_srv->srv_priority = priority;
ret++;
}
} }
} }

View File

@ -126,7 +126,7 @@ struct addrinfo {
#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST) #define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
#endif #endif
/** @RFC1576 address info structure. */ /** RFC 1576 address info structure. */
typedef struct addrinfo su_addrinfo_t; typedef struct addrinfo su_addrinfo_t;
/** Translate address and service. */ /** Translate address and service. */

View File

@ -893,7 +893,6 @@ int su_getaddrinfo(char const *node, char const *service,
{ {
int retval; int retval;
su_addrinfo_t *ai; su_addrinfo_t *ai;
char const *realservice = service;
if (!service || service[0] == '\0') if (!service || service[0] == '\0')
service = "0"; service = "0";
@ -933,9 +932,6 @@ int su_getaddrinfo(char const *node, char const *service,
retval = getaddrinfo(node, service, hints, res); retval = getaddrinfo(node, service, hints, res);
if (service != realservice && retval == EAI_SERVICE)
retval = getaddrinfo(node, realservice, hints, res);
if (retval == 0) { if (retval == 0) {
for (ai = *res; ai; ai = ai->ai_next) { for (ai = *res; ai; ai = ai->ai_next) {
if (ai->ai_protocol) if (ai->ai_protocol)