Commit 803c119b authored by Pekka Pessi's avatar Pekka Pessi

Removed RFC2543-compatible tag code.

darcs-hash:20051125132841-65a35-17e4ed41a7b686d4ea7f709943a39b5af4a8245b.gz
parent ecfb0ab0
......@@ -640,11 +640,6 @@ static int agent_tag_init(nta_agent_t *self)
self->sa_tags = NTA_TAG_PRIME * self->sa_branch;
if (!self->sa_tag_3261) {
if (!(self->sa_2543_tag = nta_agent_newtag(self->sa_home, "tag=%s", self)))
return -1;
}
return 0;
}
......@@ -801,7 +796,6 @@ int agent_set_params(nta_agent_t *agent, tagi_t *tags)
int merge_482 = agent->sa_merge_482;
int cancel_2543 = agent->sa_cancel_2543;
int cancel_487 = agent->sa_cancel_487;
int tag_3261 = agent->sa_tag_3261;
int invite_100rel = agent->sa_invite_100rel;
int use_timestamp = agent->sa_timestamp;
int use_naptr = agent->sa_use_naptr;
......@@ -848,7 +842,6 @@ int agent_set_params(nta_agent_t *agent, tagi_t *tags)
NTATAG_DEFAULT_PROXY_REF(proxy),
NTATAG_CANCEL_2543_REF(cancel_2543),
NTATAG_CANCEL_487_REF(cancel_487),
NTATAG_TAG_3261_REF(tag_3261),
NTATAG_REL100_REF(invite_100rel),
NTATAG_USE_TIMESTAMP_REF(use_timestamp),
NTATAG_USE_NAPTR_REF(use_naptr),
......@@ -1000,11 +993,6 @@ int agent_set_params(nta_agent_t *agent, tagi_t *tags)
agent->sa_preload = preload;
agent->sa_tport_threadpool = threadpool;
agent->sa_tag_3261 = tag_3261;
if (!tag_3261 && !agent->sa_2543_tag)
agent->sa_2543_tag = nta_agent_newtag(home, "tag=%s", agent);
return n;
}
......@@ -1090,7 +1078,7 @@ int agent_get_params(nta_agent_t *agent, tagi_t *tags)
NTATAG_DEFAULT_PROXY(agent->sa_default_proxy),
NTATAG_CANCEL_2543(agent->sa_cancel_2543),
NTATAG_CANCEL_487(agent->sa_cancel_487),
NTATAG_TAG_3261(agent->sa_tag_3261),
NTATAG_TAG_3261(1),
NTATAG_REL100(agent->sa_invite_100rel),
NTATAG_USE_TIMESTAMP(agent->sa_timestamp),
NTATAG_USE_NAPTR(agent->sa_use_naptr),
......@@ -2983,7 +2971,7 @@ int nta_msg_response_complete(msg_t *msg,
(status != 0 && (status < 100 || status > 699)))
return su_seterrno(EINVAL), -1;
if (status >= 200 && !irq->irq_tag)
if (status > 100 && !irq->irq_tag)
nta_incoming_tag(irq, NULL);
if (!sip->sip_status)
......@@ -3411,41 +3399,38 @@ void nta_leg_bind(nta_leg_t *leg,
* @param leg leg to be tagged
* @param tag tag to be added (if NULL, a tag generated by @b NTA is added)
*
* @return The function nta_leg_tag() returns 0 if successful,
* -1 otherwise.
* @return
* Pointer to tag if successful, NULL otherwise.
*/
int nta_leg_tag(nta_leg_t *leg, char const *tag)
char const *nta_leg_tag(nta_leg_t *leg, char const *tag)
{
nta_agent_t *sa;
if (!leg || !leg->leg_local)
return su_seterrno(EINVAL), -1;
return su_seterrno(EINVAL), NULL;
if (tag && strchr(tag, '='))
tag = strchr(tag, '=') + 1;
/* If there already is a tag, return -1 if it does not match with new one */
/* If there already is a tag,
return NULL if it does not match with new one */
if (leg->leg_local->a_tag) {
if (tag && str0casecmp(tag, leg->leg_local->a_tag))
return -1;
if (!tag && str0casecmp(tag, leg->leg_local->a_tag))
return NULL;
else
return 0;
return leg->leg_local->a_tag;
}
if (tag)
return sip_to_tag(leg->leg_home, leg->leg_local, tag);
sa = leg->leg_agent;
if (!sa->sa_tag_3261 &&
/* Use default tag only if this is "reply leg" */
(leg->leg_local_is_to || (leg->leg_remote && leg->leg_remote->a_tag)))
return sip_to_tag(leg->leg_home, leg->leg_local, sa->sa_2543_tag);
if (tag) {
if (sip_to_tag(leg->leg_home, leg->leg_local, tag) < 0)
return NULL;
return leg->leg_local->a_tag;
}
/* Use different tag */
tag = nta_agent_newtag(leg->leg_home, "tag=%s", leg->leg_agent);
if (tag)
return sip_to_add_param(leg->leg_home, leg->leg_local, tag);
else
return -1;
if (!tag || sip_to_add_param(leg->leg_home, leg->leg_local, tag) < 0)
return NULL;
return leg->leg_local->a_tag;
}
/** Get local tag. */
......@@ -3458,23 +3443,27 @@ char const *nta_leg_get_tag(nta_leg_t const *leg)
}
/** Add a remote tag to the leg.
*
* @note No remote tag is ever generated.
*
* @param leg leg to be tagged
* @param tag tag to be added (@b must be non-NULL)
*
* @return The function nta_leg_tag() returns 0 if successful,
* -1 otherwise.
* @return
* Pointer to tag if successful, NULL otherwise.
*/
int nta_leg_rtag(nta_leg_t *leg, char const *tag)
char const *nta_leg_rtag(nta_leg_t *leg, char const *tag)
{
assert(leg);
/* Add a tag parameter, unless there already is a tag */
if (leg && leg->leg_remote && tag) {
return sip_from_tag(leg->leg_home, leg->leg_remote, tag);
if (sip_from_tag(leg->leg_home, leg->leg_remote, tag) < 0)
return NULL;
}
return -1;
if (leg && leg->leg_remote)
return leg->leg_remote->a_tag;
else
return NULL;
}
/** Get remote tag. */
......@@ -4074,12 +4063,6 @@ nta_incoming_t *incoming_create(nta_agent_t *agent,
if (tag)
sip_to_tag(home, irq->irq_to, tag);
if (!(irq->irq_tag = irq->irq_to->a_tag) && !agent->sa_tag_3261) {
sip_to_tag(home, irq->irq_to, agent->sa_2543_tag);
irq->irq_tag = irq->irq_to->a_tag;
irq->irq_tag_set = 1;
}
if (method != sip_method_ack) {
int *use_rport = NULL;
int retry_without_rport = 0;
......@@ -4484,59 +4467,24 @@ void nta_incoming_bind(nta_incoming_t *irq,
irq->irq_magic = magic;
}
/** Set local tag to incoming request */
int nta_incoming_tag(nta_incoming_t *irq, char const *tag)
/** Add a To tag to incoming request if needed.
*
* If @a tag is NULL, a new tag is generated.
*/
char const *nta_incoming_tag(nta_incoming_t *irq, char const *tag)
{
nta_agent_t *sa;
if (!irq)
return -1;
sa = irq->irq_agent;
if (tag == NULL) {
if (irq->irq_tag)
tag = irq->irq_tag;
else if (!sa->sa_tag_3261 && sa->sa_2543_tag)
tag = sa->sa_2543_tag + strlen("tag=");
}
return NULL;
if (irq->irq_tag) {
char const *value;
if (!tag)
return -1;
value = strchr(tag, '=');
if (!value++)
value = tag;
if (strcmp(value, irq->irq_tag) == 0)
return 0; /* Trying to set identical tag */
else
return -1;
}
else {
if (tag)
irq->irq_tag = su_strdup(irq->irq_home, tag);
else
irq->irq_tag = nta_agent_newtag(irq->irq_home, NULL, irq->irq_agent);
if (irq->irq_tag) {
irq->irq_tag_set = 1;
return 0;
}
}
return -1;
}
if (tag && strchr(tag, '='))
tag = strchr(tag, '=') + 1;
/** Set local tag to incoming request */
char const *nta_incoming_tag_3261(nta_incoming_t *irq, char const *tag)
{
if (!irq)
if (tag && irq->irq_tag && strcasecmp(tag, irq->irq_tag))
return NULL;
if (!irq->irq_tag) {
if (tag == NULL)
tag = nta_agent_newtag(irq->irq_home, NULL, irq->irq_agent);
else if (strchr(tag, '='))
tag = strchr(tag, '=') + 1;
irq->irq_tag = tag;
irq->irq_tag_set = 1;
......@@ -5103,6 +5051,9 @@ int nta_incoming_mreply(nta_incoming_t *irq, msg_t *msg)
status = sip->sip_status->st_status;
if (!irq->irq_tag && status > 100)
nta_incoming_tag(irq, NULL);
if (/* (irq->irq_confirmed && status >= 200) || */
(irq->irq_completed && status >= 300)) {
SU_DEBUG_3(("%s: already %s transaction\n", __func__,
......
......@@ -187,13 +187,13 @@ void nta_leg_bind(nta_leg_t *leg,
nta_leg_magic_t *);
/** Add local tag. */
int nta_leg_tag(nta_leg_t *leg, char const *tag);
char const *nta_leg_tag(nta_leg_t *leg, char const *tag);
/** Get local tag. */
char const *nta_leg_get_tag(nta_leg_t const *leg);
/** Add remote tag. */
int nta_leg_rtag(nta_leg_t *leg, char const *tag);
char const *nta_leg_rtag(nta_leg_t *leg, char const *tag);
/** Get remote tag. */
char const *nta_leg_get_rtag(nta_leg_t const *leg);
......@@ -251,8 +251,7 @@ nta_incoming_t *nta_incoming_find(nta_agent_t const *agent,
sip_t const *sip,
sip_via_t const *v);
int nta_incoming_tag(nta_incoming_t *irq, char const *tag);
char const *nta_incoming_tag_3261(nta_incoming_t *irq, char const *tag);
char const *nta_incoming_tag(nta_incoming_t *irq, char const *tag);
int nta_incoming_status(nta_incoming_t const *irq);
sip_method_t nta_incoming_method(nta_incoming_t const *irq);
......
......@@ -104,7 +104,7 @@ NTA_DLL extern tag_typedef_t ntatag_contact_ref;
ntatag_contact_ref, siptag_contact_vr(&(x))
NTA_DLL extern tag_typedef_t ntatag_target;
/** Contact used by NTA. @HI */
/** Dialog target (contact) used by NTA. @HI */
#define NTATAG_TARGET(x) \
ntatag_target, siptag_contact_v((x))
......@@ -113,7 +113,7 @@ NTA_DLL extern tag_typedef_t ntatag_target_ref;
ntatag_target_ref, siptag_contact_vr(&(x))
NTA_DLL extern tag_typedef_t ntatag_aliases;
/** Aliases used by NTA. @HI */
/** Aliases used by NTA. @HI @deprecated */
#define NTATAG_ALIASES(x) \
ntatag_aliases, siptag_contact_v((x))
......
......@@ -322,9 +322,9 @@ int new_leg_callback_200(agent_t *ag,
SIPTAG_TO(sip->sip_from),
TAG_END());
TEST_1(ag->ag_bob_leg);
TEST(nta_leg_tag(ag->ag_bob_leg, NULL), 0);
TEST_1(nta_leg_tag(ag->ag_bob_leg, NULL));
TEST_1(nta_leg_get_tag(ag->ag_bob_leg));
TEST(nta_incoming_tag(irq, nta_leg_get_tag(ag->ag_bob_leg)), 0);
TEST_1(nta_incoming_tag(irq, nta_leg_get_tag(ag->ag_bob_leg)));
return 200;
......@@ -363,7 +363,8 @@ int outgoing_callback(agent_t *ag,
ag->ag_out_via = sip_via_dup(ag->ag_home, sip->sip_via);
if (ag->ag_tag_remote) {
TEST(nta_leg_rtag(ag->ag_tag_remote, sip->sip_to->a_tag), 0);
TEST_S(nta_leg_rtag(ag->ag_tag_remote, sip->sip_to->a_tag),
sip->sip_to->a_tag);
ag->ag_tag_remote = NULL;
}
......@@ -405,7 +406,7 @@ int outgoing_callback_with_api_test(agent_t *ag,
ag->ag_out_via = sip_via_dup(ag->ag_home, sip->sip_via);
if (ag->ag_tag_remote) {
TEST(nta_leg_rtag(ag->ag_tag_remote, sip->sip_to->a_tag), 0);
TEST_1(nta_leg_rtag(ag->ag_tag_remote, sip->sip_to->a_tag));
ag->ag_tag_remote = NULL;
}
......@@ -2092,7 +2093,7 @@ int test_dialog(agent_t *ag)
SIPTAG_FROM(ag->ag_alice),
SIPTAG_TO(ag->ag_bob),
TAG_END()));
TEST(nta_leg_tag(ag->ag_alice_leg, NULL), 0);
TEST_1(nta_leg_tag(ag->ag_alice_leg, NULL));
nta_leg_bind(ag->ag_server_leg, new_leg_callback_200, ag);
/* Send message from Alice to Bob establishing the dialog */
......@@ -2323,9 +2324,9 @@ int bob_leg_callback(agent_t *ag,
SIPTAG_TO(sip->sip_from),
TAG_END());
TEST_1(ag->ag_bob_leg);
TEST(nta_leg_tag(ag->ag_bob_leg, NULL), 0);
TEST_1(nta_leg_tag(ag->ag_bob_leg, NULL));
TEST_1(nta_leg_get_tag(ag->ag_bob_leg));
TEST(nta_incoming_tag(irq, nta_leg_get_tag(ag->ag_bob_leg)), 0);
TEST_1(nta_incoming_tag(irq, nta_leg_get_tag(ag->ag_bob_leg)));
TEST(nta_leg_server_route(ag->ag_bob_leg,
sip->sip_record_route,
sip->sip_contact), 0);
......@@ -2400,7 +2401,7 @@ int outgoing_invite_callback(agent_t *ag,
if (status < 300) {
nta_outgoing_t *ack;
TEST(nta_leg_rtag(ag->ag_call_leg, sip->sip_to->a_tag), 0);
TEST_1(nta_leg_rtag(ag->ag_call_leg, sip->sip_to->a_tag));
TEST(nta_leg_client_route(ag->ag_call_leg,
sip->sip_record_route,
......@@ -2449,7 +2450,7 @@ int test_call(agent_t *ag)
SIPTAG_FROM(ag->ag_alice),
SIPTAG_TO(ag->ag_bob),
TAG_END()));
TEST(nta_leg_tag(ag->ag_alice_leg, NULL), 0);
TEST_1(nta_leg_tag(ag->ag_alice_leg, NULL));
nta_leg_bind(ag->ag_server_leg, bob_leg_callback, ag);
/* Send INVITE */
......@@ -2601,9 +2602,9 @@ int bob_leg_callback2(agent_t *ag,
SIPTAG_TO(sip->sip_from),
TAG_END());
TEST_1(ag->ag_bob_leg);
TEST(nta_leg_tag(ag->ag_bob_leg, NULL), 0);
TEST_1(nta_leg_tag(ag->ag_bob_leg, NULL));
TEST_1(nta_leg_get_tag(ag->ag_bob_leg));
TEST(nta_incoming_tag(irq, nta_leg_get_tag(ag->ag_bob_leg)), 0);
TEST_1(nta_incoming_tag(irq, nta_leg_get_tag(ag->ag_bob_leg)));
TEST(nta_leg_server_route(ag->ag_bob_leg,
sip->sip_record_route,
sip->sip_contact), 0);
......@@ -2658,7 +2659,7 @@ int invite_prack_callback(agent_t *ag,
ag->ag_tag_status = status;
ag->ag_call_tag = su_strdup(ag->ag_home, sip->sip_to->a_tag);
TEST_S(ag->ag_call_tag, sip->sip_to->a_tag);
TEST(nta_leg_rtag(ag->ag_call_leg, ag->ag_call_tag), 0);
TEST_S(nta_leg_rtag(ag->ag_call_leg, ag->ag_call_tag), ag->ag_call_tag);
TEST(nta_leg_client_route(ag->ag_call_leg,
sip->sip_record_route,
sip->sip_contact), 0);
......@@ -2696,7 +2697,7 @@ int invite_prack_callback(agent_t *ag,
TEST_1(msg = nta_outgoing_getrequest(orq));
TEST_1(osip = sip_object(msg));
TEST(nta_leg_rtag(ag->ag_call_leg, sip->sip_to->a_tag), 0);
TEST_1(nta_leg_rtag(ag->ag_call_leg, sip->sip_to->a_tag));
TEST(nta_leg_client_route(ag->ag_call_leg,
sip->sip_record_route,
......@@ -2776,7 +2777,7 @@ int test_prack(agent_t *ag)
SIPTAG_FROM(ag->ag_alice),
SIPTAG_TO(ag->ag_bob),
TAG_END()));
TEST(nta_leg_tag(ag->ag_alice_leg, NULL), 0);
TEST_1(nta_leg_tag(ag->ag_alice_leg, NULL));
/* Send INVITE */
nta_leg_bind(ag->ag_server_leg, bob_leg_callback2, ag);
......@@ -2841,7 +2842,7 @@ int test_prack(agent_t *ag)
SIPTAG_FROM(ag->ag_alice),
SIPTAG_TO(ag->ag_bob),
TAG_END()));
TEST(nta_leg_tag(ag->ag_alice_leg, NULL), 0);
TEST_1(nta_leg_tag(ag->ag_alice_leg, NULL));
/* Send INVITE,
* send precious provisional response
......@@ -2976,7 +2977,7 @@ int test_fix_467(agent_t *ag)
SIPTAG_FROM(ag->ag_alice),
SIPTAG_TO(ag->ag_bob),
TAG_END()));
TEST(nta_leg_tag(ag->ag_alice_leg, NULL), 0);
TEST_1(nta_leg_tag(ag->ag_alice_leg, NULL));
ag->ag_bob_leg = NULL;
ag->ag_call_tag = NULL;
......@@ -3371,7 +3372,8 @@ static int test_api_errors(void)
TEST_VOID(nta_leg_destroy(NULL));
TEST(nta_leg_magic(NULL, NULL), NULL);
TEST_VOID(nta_leg_bind(NULL, NULL, NULL));
TEST(nta_leg_tag(NULL, "fidsafsa"), -1);
TEST(nta_leg_tag(NULL, "fidsafsa"), NULL);
TEST(nta_leg_rtag(NULL, "fidsafsa"), NULL);
TEST(nta_leg_get_tag(NULL), NULL);
TEST(nta_leg_client_route(NULL, NULL, NULL), -1);
TEST(nta_leg_server_route(NULL, NULL, NULL), -1);
......@@ -3397,7 +3399,7 @@ nta_incoming_t *nta_incoming_find(nta_agent_t const *agent,
sip_t const *sip,
sip_via_t const *v);
int nta_incoming_tag(nta_incoming_t *irq, char const *tag);
char const *nta_incoming_tag(nta_incoming_t *irq, char const *tag);
int nta_incoming_status(nta_incoming_t const *irq);
sip_method_t nta_incoming_method(nta_incoming_t const *irq);
......
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