Commit 65126ecb authored by Pekka Pessi's avatar Pekka Pessi

Added test for comp

The comp

darcs-hash:20051230135927-65a35-8df1edaf5476f934a8da15ddb8b7fe3b5fc24d61.gz
parent 78c98b64
......@@ -159,8 +159,8 @@ int agent_sigcomp_accept(nta_agent_t *sa, tport_t *tp, msg_t *msg);
#define agent_sigcomp_accept NULL
#endif
static msg_param_t stateful_branch(su_home_t *home, nta_agent_t *);
static msg_param_t stateless_branch(nta_agent_t *, msg_t *, sip_t const *,
static char const * stateful_branch(su_home_t *home, nta_agent_t *);
static char const * stateless_branch(nta_agent_t *, msg_t *, sip_t const *,
tp_name_t const *tp);
#define NTA_BRANCH_PRIME SU_U64_C(0xB9591D1C361C6521)
......@@ -1169,7 +1169,7 @@ int nta_agent_get_stats(nta_agent_t *agent,
* agent was initialized.
*
*/
msg_param_t nta_agent_newtag(su_home_t *home, char const *fmt, nta_agent_t *sa)
char const *nta_agent_newtag(su_home_t *home, char const *fmt, nta_agent_t *sa)
{
char tag[(8 * 8 + 4)/ 5 + 1];
......@@ -1190,7 +1190,7 @@ msg_param_t nta_agent_newtag(su_home_t *home, char const *fmt, nta_agent_t *sa)
/**
* Calculate branch value.
*/
static msg_param_t stateful_branch(su_home_t *home, nta_agent_t *sa)
static char const *stateful_branch(su_home_t *home, nta_agent_t *sa)
{
char branch[(8 * 8 + 4)/ 5 + 1];
......@@ -1211,7 +1211,7 @@ static msg_param_t stateful_branch(su_home_t *home, nta_agent_t *sa)
* XXX - should include HMAC of previous Via line.
*/
static
msg_param_t stateless_branch(nta_agent_t *sa,
char const *stateless_branch(nta_agent_t *sa,
msg_t *msg,
sip_t const *sip,
tp_name_t const *tpn)
......@@ -1704,19 +1704,18 @@ int outgoing_insert_via(nta_outgoing_t *orq,
return -1;
if (orq->orq_method != sip_method_ack) {
if (self->sa_rport && !sip_params_find(v->v_params, "rport="))
clear = 1, sip_via_add_param(msg_home(msg), v, "rport");
} else {
/* msg_params_remove((msg_param_t *)&v->v_params, "comp="); */
if (self->sa_rport && !v->v_rport)
msg_header_add_param(msg_home(msg), v->v_common, "rport");
}
if (!orq->orq_tpn->tpn_comp) {
if (msg_params_remove((msg_param_t *)&v->v_params, "comp="))
clear = 1;
else {
/* msg_header_remove_param(v->v_common, "comp"); */
}
if (!orq->orq_tpn->tpn_comp)
msg_header_remove_param(v->v_common, "comp");
if (branch && branch != v->v_branch)
clear = 1, sip_via_add_param(msg_home(msg), v, branch);
msg_header_add_param(msg_home(msg), v->v_common, branch);
if (via->v_protocol != v->v_protocol &&
strcasecmp(via->v_protocol, v->v_protocol))
......@@ -1773,7 +1772,7 @@ int nta_tpn_by_via(tp_name_t *tpn, sip_via_t const *v, int *using_rport)
else
tpn->tpn_port = SIP_PORT(v->v_port), using_rport ? *using_rport = 0 : 0;
tpn->tpn_comp = sip_params_find(v->v_params, "comp=");
tpn->tpn_comp = v->v_comp;
tpn->tpn_ident = NULL;
......@@ -2161,8 +2160,7 @@ int agent_check_request_via(nta_agent_t *agent,
tport_hostport(hostport, TPORT_HOSTPORTSIZE, from, 1);
SU_DEBUG_1(("nta: Via check: extra received=%s from %s\n",
v->v_received, hostport));
msg_params_remove((msg_param_t *)v->v_params, "received");
sip_fragment_clear(v->v_common);
msg_header_remove_param(v->v_common, "received");
}
if (!tport_hostport(hostport, TPORT_HOSTPORTSIZE, from, 0))
......@@ -2179,20 +2177,21 @@ int agent_check_request_via(nta_agent_t *agent,
hostport[rlen] = '\0';
}
sip_via_add_param(msg_home(msg), v, su_strdup(msg_home(msg), received));
msg_header_replace_param(msg_home(msg), v->v_common,
su_strdup(msg_home(msg), received));
SU_DEBUG_5(("nta: Via check: %s\n", received));
}
if (!agent->sa_server_rport) {
/*Xyzzy*/;
}
else if ((rport = sip_params_find(v->v_params, "rport"))) {
else if (v->v_rport) {
rport = su_sprintf(msg_home(msg), "rport=%u", ntohs(from->su_port));
sip_via_add_param(msg_home(msg), v, rport);
msg_header_replace_param(msg_home(msg), v->v_common, rport);
}
else if (tport_is_tcp(tport)) {
rport = su_sprintf(msg_home(msg), "rport=%u", ntohs(from->su_port));
sip_via_add_param(msg_home(msg), v, rport);
msg_header_replace_param(msg_home(msg), v->v_common, rport);
}
return 0;
......@@ -7886,7 +7885,7 @@ int outgoing_reply(nta_outgoing_t *orq, int status, char const *phrase,
if (!orq->orq_stateless &&
!(orq->orq_callback == outgoing_default_cb) &&
!(status == 408 && !orq->orq_agent->sa_timeout_408)) {
msg_param_t to_tag;
char const *to_tag;
msg = nta_msg_create(agent, NTA_INTERNAL_MSG);
......@@ -9063,7 +9062,7 @@ int reliable_send(nta_incoming_t *irq,
sip_rseq_init(rseq);
if (sip->sip_require)
msg_params_replace(home, (msg_param_t **)&sip->sip_require, "100rel");
msg_header_replace_param(home, sip->sip_require->k_common, "100rel");
else
sip_add_make(msg, sip, sip_require_class, "100rel");
......@@ -9408,7 +9407,7 @@ int outgoing_recv_reliable(nta_outgoing_t *orq,
nta_outgoing_t *nta_outgoing_tagged(nta_outgoing_t *orq,
nta_response_f *callback,
nta_outgoing_magic_t *magic,
msg_param_t to_tag,
char const *to_tag,
sip_rseq_t const *rseq)
{
nta_agent_t *agent;
......
......@@ -132,7 +132,7 @@ int nta_agent_add_tport(nta_agent_t *agent,
url_string_t const *url,
tag_type_t tag, tag_value_t value, ...);
msg_param_t nta_agent_newtag(su_home_t *, char const *fmt, nta_agent_t *);
char const *nta_agent_newtag(su_home_t *, char const *fmt, nta_agent_t *);
int nta_agent_set_params(nta_agent_t *agent,
tag_type_t tag, tag_value_t value, ...);
......@@ -322,7 +322,7 @@ msg_t *nta_outgoing_getrequest(nta_outgoing_t *orq);
nta_outgoing_t *nta_outgoing_tagged(nta_outgoing_t *orq,
nta_response_f *callback,
nta_outgoing_magic_t *magic,
msg_param_t to_tag,
char const *to_tag,
sip_rseq_t const *rseq);
int nta_outgoing_cancel(nta_outgoing_t *);
......
......@@ -111,7 +111,7 @@ struct nta_agent_s
uint64_t sa_branch; /**< Counter for generating branch parameter */
uint64_t sa_tags; /**< Counter for generating tag parameters */
msg_param_t sa_2543_tag; /**< Fixed tag added to To when responding */
char const *sa_2543_tag; /**< Fixed tag added to To when responding */
#if HAVE_SOFIA_SRESOLV
sres_resolver_t *sa_resolver; /**< DNS resolver */
......@@ -469,7 +469,7 @@ struct nta_outgoing_s
sip_cseq_t const *orq_cseq;
sip_call_id_t const *orq_call_id;
msg_param_t orq_tag; /**< Tag from final response. */
char const *orq_tag; /**< Tag from final response. */
su_time_t orq_sent; /**< When request was sent? */
unsigned orq_delay; /**< RTT estimate */
......@@ -515,16 +515,15 @@ struct nta_outgoing_s
url_t *orq_route; /**< Route URL */
tp_name_t orq_tpn[1]; /**< Where to send request */
char const *orq_scheme; /**< Transport URL type */
char const *orq_compress; /**< What compression to use */
tport_t *orq_tport;
struct sigcomp_compartment *orq_cc;
tagi_t *orq_tags; /**< Tport tag items */
int orq_pending; /**< Request is pending in tport */
msg_param_t orq_branch; /**< Transaction branch */
msg_param_t orq_via_branch; /**< Via branch */
url_t const *orq_url; /**< Original RequestURI */
char const *orq_branch; /**< Transaction branch */
char const *orq_via_branch; /**< Via branch */
url_t const *orq_url; /**< Original RequestURI */
msg_t *orq_request;
msg_t *orq_response;
......
......@@ -383,62 +383,6 @@ int outgoing_callback(agent_t *ag,
END();
}
/* */
int outgoing_callback_with_api_test(agent_t *ag,
nta_outgoing_t *orq,
sip_t const *sip)
{
msg_t *msg;
int status;
BEGIN();
status = sip->sip_status->st_status;
if (tstflags & tst_verbatim) {
printf("%s: %s: %s %03d %s\n", name, __func__,
sip->sip_status->st_version,
sip->sip_status->st_status,
sip->sip_status->st_phrase);
}
ag->ag_status = status;
if (status < 200)
return 0;
if (ag->ag_out_via == NULL)
ag->ag_out_via = sip_via_dup(ag->ag_home, sip->sip_via);
if (ag->ag_tag_remote) {
TEST_1(nta_leg_rtag(ag->ag_tag_remote, sip->sip_to->a_tag));
ag->ag_tag_remote = NULL;
}
TEST_1(sip->sip_to && sip->sip_to->a_tag);
/* Test API functions */
TEST(nta_outgoing_status(orq), status);
TEST_1(nta_outgoing_request_uri(orq));
TEST(nta_outgoing_route_uri(orq) != NULL, ag->ag_obp != NULL);
TEST(nta_outgoing_method(orq), sip->sip_cseq->cs_method);
TEST(nta_outgoing_cseq(orq), sip->sip_cseq->cs_seq);
TEST_1(nta_outgoing_delay(orq) < UINT_MAX);
TEST_1(msg = nta_outgoing_getresponse(orq));
msg_destroy(msg);
TEST_1(msg = nta_outgoing_getrequest(orq));
msg_destroy(msg);
nta_outgoing_destroy(orq);
nta_outgoing_destroy(orq);
ag->ag_orq = NULL;
END();
}
static
int test_magic_branch(agent_t *ag, sip_t const *sip)
{
......@@ -762,15 +706,19 @@ int test_tports(agent_t *ag)
* Send a message from default leg to default leg
*/
char const p_acid[] = "P-Access-Network-Info: IEEE-802.11g\n";
url_t url[1];
*url = *ag->ag_contact->m_url;
url->url_params = NULL;
ag->ag_expect_leg = ag->ag_default_leg;
su_free(ag->ag_home, (void *)ag->ag_out_via), ag->ag_out_via = NULL;
TEST_1(ag->ag_orq =
nta_outgoing_tcreate(ag->ag_default_leg,
outgoing_callback, ag,
ag->ag_obp,
SIP_METHOD_MESSAGE,
(url_string_t *)ag->ag_contact->m_url,
(url_string_t *)url,
SIPTAG_SUBJECT_STR("Test 0.1"),
SIPTAG_FROM(ag->ag_alice),
SIPTAG_TO(ag->ag_bob),
......@@ -784,6 +732,8 @@ int test_tports(agent_t *ag)
TEST(ag->ag_latest_leg, ag->ag_default_leg);
TEST_1(ag->ag_request);
TEST_1(ag->ag_out_via->v_comp == NULL);
nta_leg_bind(ag->ag_default_leg, leg_callback_200, ag);
}
......@@ -805,6 +755,8 @@ int test_tports(agent_t *ag)
TEST_1(pl = test_payload(ag->ag_home, size));
ag->ag_expect_leg = ag->ag_server_leg;
su_free(ag->ag_home, (void *)ag->ag_out_via), ag->ag_out_via = NULL;
TEST_1(ag->ag_orq =
nta_outgoing_tcreate(ag->ag_default_leg, outgoing_callback, ag,
ag->ag_obp,
......@@ -825,6 +777,7 @@ int test_tports(agent_t *ag)
nta_compartment_decref(&ag->ag_client_compartment);
TEST(ag->ag_orq, NULL);
TEST(ag->ag_latest_leg, ag->ag_server_leg);
TEST_S(ag->ag_out_via->v_comp, "sigcomp");
}
/* Test 0.2
......@@ -839,12 +792,7 @@ int test_tports(agent_t *ag)
*url = *ag->ag_aliases->m_url;
url->url_user = "alice";
#if 0
if (url->url_params)
url->url_params = su_sprintf(NULL, "%s;transport=tcp", url->url_params);
else
#endif
url->url_params = "transport=tcp";
url->url_params = "transport=tcp";
TEST_1(pl = test_payload(ag->ag_home, size));
......
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