Commit 7fab5e8a authored by Pekka Pessi's avatar Pekka Pessi

Cleaned up nta module interfaces.

Use uint32_t instead of sip_u32_t.
Removed old funtions not using reference counting with messages:
Replaced nta_outgoing_getresponse() with nta_outgoing_getresponse_ref(),
and nta_outgoing_getrequest() with nta_outgoing_getrequest_ref().
Removed nta_incoming_getresponse(), nta_leg_stateful().
Removed nta_outgoing_tmcreate(): use nta_outgoing_mcreate() instead.

darcs-hash:20051107184721-65a35-8b883c5d253b03e04ff91060de6109116375ab8c.gz
parent acefc9a7
This diff is collapsed.
......@@ -120,7 +120,8 @@ nta_agent_t *nta_agent_create(su_root_t *root,
url_string_t const *name,
nta_message_f *callback,
nta_agent_magic_t *magic,
tag_type_t tag, /* tag_value_t value, */ ...);
tag_type_t tag, tag_value_t value, ...);
void nta_agent_destroy(nta_agent_t *agent);
sip_contact_t *nta_agent_contact(nta_agent_t const *a);
sip_via_t *nta_agent_via(nta_agent_t const *a);
......@@ -131,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, ...);
sip_param_t nta_agent_newtag(su_home_t *, char const *fmt, nta_agent_t *);
msg_param_t 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, ...);
......@@ -161,9 +162,6 @@ int nta_msg_request_complete(msg_t *msg,
char const *method_name,
url_string_t const *req_url);
int nta_msg_default_headers(nta_agent_t *agent,
tag_type_t tag, tag_value_t value, ...);
int nta_is_internal_msg(msg_t const *msg);
/* ----------------------------------------------------------------------
......@@ -259,15 +257,14 @@ char const *nta_incoming_tag_3261(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);
url_t const *nta_incoming_url(nta_incoming_t const *irq);
sip_u32_t nta_incoming_cseq(nta_incoming_t const *irq);
uint32_t nta_incoming_cseq(nta_incoming_t const *irq);
int nta_incoming_set_params(nta_incoming_t *irq,
tag_type_t tag, tag_value_t value, ...);
msg_t *nta_incoming_getrequest(nta_incoming_t *irq);
msg_t *nta_incoming_getresponse(nta_incoming_t *irq);
msg_t *nta_incoming_getrequest_ackcancel(nta_incoming_t *irq);
msg_t *nta_incoming_getresponse(nta_incoming_t *irq);
int nta_incoming_treply(nta_incoming_t *ireq,
int status, char const *phrase,
......@@ -293,23 +290,17 @@ nta_outgoing_t *nta_outgoing_tcreate(nta_leg_t *leg,
url_string_t const *request_uri,
tag_type_t tag, tag_value_t value, ...);
nta_outgoing_t *nta_outgoing_tmcreate(nta_agent_t *agent,
nta_response_f *callback,
nta_outgoing_magic_t *magic,
url_string_t const *route_url,
msg_t *msg,
tag_type_t tag, tag_value_t value, ...);
nta_outgoing_t *nta_outgoing_mcreate(nta_agent_t *agent,
nta_response_f *callback,
nta_outgoing_magic_t *magic,
url_string_t const *route_url,
msg_t *msg);
msg_t *msg,
tag_type_t tag, tag_value_t value, ...);
int nta_outgoing_status(nta_outgoing_t const *orq);
sip_method_t nta_outgoing_method(nta_outgoing_t const *orq);
char const *nta_outgoing_method_name(nta_outgoing_t const *orq);
sip_u32_t nta_outgoing_cseq(nta_outgoing_t const *orq);
uint32_t nta_outgoing_cseq(nta_outgoing_t const *orq);
unsigned nta_outgoing_delay(nta_outgoing_t const *orq);
......@@ -319,13 +310,10 @@ url_t const *nta_outgoing_route_uri(nta_outgoing_t const *orq);
msg_t *nta_outgoing_getresponse(nta_outgoing_t *orq);
msg_t *nta_outgoing_getrequest(nta_outgoing_t *orq);
msg_t *nta_outgoing_getresponse_ref(nta_outgoing_t *orq);
msg_t *nta_outgoing_getrequest_ref(nta_outgoing_t *orq);
nta_outgoing_t *nta_outgoing_tagged(nta_outgoing_t *orq,
nta_response_f *callback,
nta_outgoing_magic_t *magic,
sip_param_t to_tag,
msg_param_t to_tag,
sip_rseq_t const *rseq);
int nta_outgoing_cancel(nta_outgoing_t *);
......@@ -390,5 +378,10 @@ nta_reliable_t *nta_reliable_mreply(nta_incoming_t *irq,
void nta_reliable_destroy(nta_reliable_t *);
/* ----------------------------------------------------------------------
* Backward-compatibility stuff
*/
#define nta_outgoing_tmcreate nta_outgoing_mcreate
#endif
......@@ -72,10 +72,10 @@ int nta_agent_set_uas(nta_agent_t *agent, int value)
*
* @deprecated Use nta_agent_set_params() and NTATAG_BRANCH_KEY() instead.
*/
sip_param_t nta_agent_set_branch(nta_agent_t *agent,
sip_param_t branch)
msg_param_t nta_agent_set_branch(nta_agent_t *agent,
msg_param_t branch)
{
sip_param_t retval = "";
msg_param_t retval = "";
nta_agent_set_params(agent, NTATAG_BRANCH_KEY(branch), TAG_END());
nta_agent_get_params(agent, NTATAG_BRANCH_KEY_REF(retval), TAG_END());
......@@ -107,7 +107,7 @@ int nta_agent_set_proxy(nta_agent_t *agent, url_string_t const *u)
*
* @sa NTATAG_TAG_3261().
*/
sip_param_t nta_agent_tag(nta_agent_t const *agent)
msg_param_t nta_agent_tag(nta_agent_t const *agent)
{
return
(agent && agent->sa_2543_tag)
......@@ -141,8 +141,8 @@ int nta_msg_vreply(nta_agent_t *agent,
if (sip_add_headers(reply, sip, extra, headers) < 0)
sip = NULL;
return nta_msg_tmreply(agent, reply, sip,
status, phrase, req_msg, TAG_END());
return nta_msg_mreply(agent, reply, sip,
status, phrase, req_msg, TAG_END());
}
/** Send the message (stdarg version of nta_msg_send()). */
......@@ -224,6 +224,49 @@ nta_leg_t *nta_msg_leg(nta_agent_t *agent,
return leg;
}
static void sm_leg_recv(su_root_magic_t *rm,
su_msg_r msg,
union sm_arg_u *u);
/** Process msg statefully using the leg. */
int nta_leg_stateful(nta_leg_t *leg, msg_t *msg)
{
su_msg_r su_msg = SU_MSG_RINITIALIZER;
nta_agent_t *agent = leg->leg_agent;
su_root_t *root = agent->sa_root;
struct leg_recv_s *a;
/* Create a su message that is passed to NTA network thread */
if (su_msg_create(su_msg,
su_root_task(root),
su_root_task(root),
sm_leg_recv, /* Function to call */
sizeof(struct leg_recv_s)) == SU_FAILURE)
return -1;
agent->sa_stats->as_trless_to_tr++;
a = su_msg_data(su_msg)->a_leg_recv;
a->leg = leg;
a->msg = msg;
a->tport = tport_incref(tport_delivered_by(agent->sa_tports, msg));
return su_msg_send(su_msg);
}
/** @internal Delayed leg_recv(). */
static
void sm_leg_recv(su_root_magic_t *rm,
su_msg_r msg,
union sm_arg_u *u)
{
struct leg_recv_s *a = u->a_leg_recv;
leg_recv(a->leg, a->msg, sip_object(a->msg), a->tport);
tport_decref(&a->tport);
}
/**Create a new leg object
*
* @param agent agent object
......@@ -346,6 +389,89 @@ int nta_leg_route(nta_leg_t *leg,
return nta_leg_client_route(leg, route, contact);
}
#if 0
/**Get response message.
*
* The function nta_incoming_getresponse() retrieves a copy of the latest
* outgoing response message. The response message is copied; the original
* copy is kept by the transaction.
*
* @param irq incoming (server) transaction handle
*
* @retval
* A pointer to the copy of the response message is returned, or NULL if an
* error occurred.
*/
msg_t *nta_incoming_getresponse(nta_incoming_t *irq)
{
if (irq && irq->irq_response) {
msg_t *msg = nta_msg_create(irq->irq_agent, 0);
sip_t *sip = sip_object(msg);
msg_clone(msg, irq->irq_response);
/* Copy the SIP headers from the old message */
if (msg_copy_all(msg, sip, sip_object(irq->irq_response)) >= 0)
return msg;
msg_destroy(msg);
}
return NULL;
}
/**Get request message.
*
* The function nta_outgoing_getrequest() retrieves the request message sent
* to the network. The request message is copied; the original copy is kept
* by the transaction.
*
* @param orq outgoing transaction handle
*
* @retval
* A pointer to the copy of the request message is returned, or NULL if an
* error occurred.
*/
msg_t *nta_outgoing_getrequest(nta_outgoing_t *orq)
{
if (orq && orq->orq_request) {
msg_t *msg = nta_msg_create(orq->orq_agent, 0);
sip_t *sip = sip_object(msg);
msg_clone(msg, orq->orq_request);
/* Copy the SIP headers from the old message */
if (sip_copy_all(msg, sip, sip_object(orq->orq_request)) >= 0)
return msg;
msg_destroy(msg);
}
return NULL;
}
/**Get latest response message.
*
* The function nta_outgoing_getresponse() retrieves the latest incoming
* response message to the outgoing transaction. Note that the message is
* not copied, but removed from the transaction.
*
* @param orq outgoing transaction handle
*
* @retval
* A pointer to response message is returned, or NULL if no response message
* has been received or the response message has already been retrieved.
*/
msg_t *nta_outgoing_getresponse(nta_outgoing_t *orq)
{
msg_t *msg = NULL;
if (orq && orq->orq_response)
msg = orq->orq_response, orq->orq_response = NULL;
return msg;
}
#endif
/** Create an outgoing request belonging to the leg.
*
......
......@@ -127,6 +127,9 @@ nta_outgoing_t *nta_outgoing_tbye(nta_outgoing_t *orq,
url_string_t const *route_url,
tag_type_t tag, tag_value_t value, ...);
/** Process message statefully using @a leg. */
int nta_leg_stateful(nta_leg_t *leg, msg_t *msg);
typedef nta_ack_cancel_f nta_incoming_f;
#define nta_incoming_request nta_incoming_getrequest
......
......@@ -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 */
sip_param_t sa_2543_tag; /**< Fixed tag added to To when responding */
msg_param_t sa_2543_tag; /**< Fixed tag added to To when responding */
#if HAVE_SOFIA_SRESOLV
sres_resolver_t *sa_resolver; /**< DNS resolver */
......@@ -466,7 +466,7 @@ struct nta_outgoing_s
sip_cseq_t const *orq_cseq;
sip_call_id_t const *orq_call_id;
sip_param_t orq_tag; /**< Tag from final response. */
msg_param_t orq_tag; /**< Tag from final response. */
su_time_t orq_sent; /**< When request was sent? */
unsigned orq_delay; /**< RTT estimate */
......@@ -518,8 +518,8 @@ struct nta_outgoing_s
tagi_t *orq_tags; /**< Tport tag items */
int orq_pending; /**< Request is pending in tport */
sip_param_t orq_branch; /**< Transaction branch */
sip_param_t orq_via_branch; /**< Via branch */
msg_param_t orq_branch; /**< Transaction branch */
msg_param_t orq_via_branch; /**< Via branch */
url_t const *orq_url; /**< Original RequestURI */
msg_t *orq_request;
......@@ -528,13 +528,6 @@ struct nta_outgoing_s
nta_outgoing_t *orq_cancel; /**< CANCEL transaction */
};
/* ====================================================================== */
int nta_msg_mreply(nta_agent_t *agent,
msg_t *reply, sip_t *sip,
int status, char const *phrase,
msg_t *req_msg);
/* ====================================================================== */
/* Debug log settings */
......
......@@ -25,7 +25,6 @@
#ifndef NTA_STATELESS_H /** Defined when nta_stateless.h has been included. */
#define NTA_STATELESS_H
/**@file nta_stateless.h
* @brief NTA functions for stateless SIP processing.
*
......@@ -77,11 +76,11 @@ int nta_msg_tsend(nta_agent_t *agent, msg_t *msg, url_string_t const *u,
tag_type_t tag, tag_value_t value, ...);
/** Reply to a request message. */
int nta_msg_tmreply(nta_agent_t *agent,
msg_t *reply, sip_t *sip,
int status, char const *phrase,
msg_t *req_msg,
tag_type_t tag, tag_value_t value, ...);
int nta_msg_mreply(nta_agent_t *agent,
msg_t *reply, sip_t *sip,
int status, char const *phrase,
msg_t *req_msg,
tag_type_t tag, tag_value_t value, ...);
/** Reply to a request message. */
int nta_msg_treply(nta_agent_t *self,
......@@ -92,7 +91,4 @@ int nta_msg_treply(nta_agent_t *self,
/** ACK and BYE an unknown 200 OK response to INVITE. */
int nta_msg_ackbye(nta_agent_t *a, msg_t *msg);
/** Process message statefully using @a leg. */
int nta_leg_stateful(nta_leg_t *leg, msg_t *msg);
#endif /* !defined(NTA_STATELESS_H) */
......@@ -48,7 +48,7 @@ export PATH
me6="::1"
if ../su/localinfo -6 -n -g -s >& /dev/null ; then
ipv6=true aaaa=aaaa
ipv6=true aaaa=aaaa v6flag=-6
me6=$(../su/localinfo -6 -n -s -g | awk '{print $1; exit(0); }')
else
if ! ../su/localinfo '--help' >& /dev/null ; then
......@@ -62,10 +62,10 @@ fi
if type named >& /dev/null && ./portbind --help >& /dev/null
then
port=$(./portbind) sink=$port
port=$(./portbind $((port + 1))) down=$port
port=$(./portbind $((port + 1))) bind=$port
port=$(./portbind $((port + 1))) contact=$port
port=$(./portbind $v6flag) sink=$port
port=$(./portbind $v6flag $((port + 1))) down=$port
port=$(./portbind $v6flag $((port + 1))) bind=$port
port=$(./portbind $v6flag $((port + 1))) contact=$port
if eval $ipv6 ; then
listen="listen-on-v6 port $bind { any; };"
......
......@@ -194,7 +194,7 @@ void sl_allow_log(su_log_t *log, int level,
char const *fmt, sip_allow_t const *allow)
{
char *s, b[1024], *end = b + sizeof(b) - 1;
sip_param_t const *p;
msg_param_t const *p;
sip_allow_t const *k = allow;
s = b; *end = '\0';
......
......@@ -189,7 +189,7 @@ int sl_contact_print(FILE *stream, char const *fmt, sip_contact_t const *m)
int sl_allow_print(FILE *stream, char const *fmt, sip_allow_t const *allow)
{
char *s, b[1024], *end = b + sizeof(b) - 1;
sip_param_t const *p;
msg_param_t const *p;
sip_allow_t const *k = allow;
s = b; *end = '\0';
......
......@@ -136,7 +136,7 @@ struct agent_t {
* tags it with the tag from remote.
*/
int ag_tag_status; /**< Which response established dialog */
sip_param_t ag_call_tag; /**< Tag used to establish dialog */
msg_param_t ag_call_tag; /**< Tag used to establish dialog */
nta_reliable_t *ag_reliable;
......@@ -613,7 +613,7 @@ int test_init(agent_t *ag, char const *resolv_conf)
{
/* Initialize our headers */
// sip_param_t from_params[2] = { "tag=fdeadbeef", NULL };
// msg_param_t from_params[2] = { "tag=fdeadbeef", NULL };
sip_from_t from[1];
sip_to_t to[1];
sip_contact_t m[1];
......@@ -890,8 +890,8 @@ int test_tports(agent_t *ag)
SIPTAG_HEADER_STR(p_acid),
TAG_END()));
TEST(nta_outgoing_getresponse_ref(ag->ag_orq), NULL);
TEST_1(msg = nta_outgoing_getrequest_ref(ag->ag_orq));
TEST(nta_outgoing_getresponse(ag->ag_orq), NULL);
TEST_1(msg = nta_outgoing_getrequest(ag->ag_orq));
TEST_S(nta_outgoing_method_name(ag->ag_orq), "MESSAGE");
msg_destroy(msg);
......@@ -2376,7 +2376,7 @@ int outgoing_invite_callback(agent_t *ag,
{
msg_t *msg;
TEST_1(msg = nta_outgoing_getresponse_ref(orq));
TEST_1(msg = nta_outgoing_getresponse(orq));
TEST_1(msg->m_refs == 2);
TEST_1(sip_object(msg) == sip);
if (ag->ag_probe_msg == NULL)
......@@ -2693,7 +2693,7 @@ int invite_prack_callback(agent_t *ag,
msg_t *msg;
sip_t *osip;
TEST_1(msg = nta_outgoing_getrequest_ref(orq));
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);
......@@ -3379,12 +3379,11 @@ static int test_api_errors(void)
TEST(nta_leg_by_dialog(NULL, NULL, NULL, NULL, NULL, NULL, NULL), NULL);
TEST(nta_leg_by_dialog(nta, NULL, NULL, NULL, NULL, NULL, NULL), NULL);
TEST(nta_outgoing_tmcreate(NULL, NULL, NULL, NULL, NULL, TAG_END()), NULL);
TEST(nta_outgoing_mcreate(NULL, NULL, NULL, NULL, NULL, TAG_END()), NULL);
TEST(nta_outgoing_tcancel(NULL, NULL, NULL, TAG_END()), NULL);
TEST(nta_outgoing_method_name(NULL), NULL);
TEST(nta_outgoing_getresponse_ref(NULL), NULL);
TEST(nta_outgoing_getresponse(NULL), NULL);
TEST(nta_outgoing_getrequest(NULL), NULL);
TEST(nta_outgoing_getrequest_ref(NULL), NULL);
#if 0
void nta_incoming_bind(nta_incoming_t *irq,
......@@ -3403,10 +3402,7 @@ int 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);
url_t const *nta_incoming_url(nta_incoming_t const *irq);
sip_u32_t nta_incoming_cseq(nta_incoming_t const *irq);
msg_t *nta_incoming_getrequest(nta_incoming_t *irq);
msg_t *nta_incoming_getresponse(nta_incoming_t *irq);
uint32_t nta_incoming_cseq(nta_incoming_t const *irq);
int nta_incoming_treply(nta_incoming_t *ireq,
int status, char const *phrase,
......@@ -3432,22 +3428,16 @@ nta_outgoing_t *nta_outgoing_tcreate(nta_leg_t *leg,
url_string_t const *request_uri,
tag_type_t tag, tag_value_t value, ...);
nta_outgoing_t *nta_outgoing_tmcreate(nta_agent_t *agent,
nta_response_f *callback,
nta_outgoing_magic_t *magic,
url_string_t const *route_url,
msg_t *msg,
tag_type_t tag, tag_value_t value, ...);
nta_outgoing_t *nta_outgoing_mcreate(nta_agent_t *agent,
nta_response_f *callback,
nta_outgoing_magic_t *magic,
url_string_t const *route_url,
msg_t *msg);
url_string_t const *route_url,
msg_t *msg,
tag_type_t tag, tag_value_t value, ...);
int nta_outgoing_status(nta_outgoing_t const *orq);
sip_method_t nta_outgoing_method(nta_outgoing_t const *orq);
sip_u32_t nta_outgoing_cseq(nta_outgoing_t const *orq);
uint32_t nta_outgoing_cseq(nta_outgoing_t const *orq);
unsigned nta_outgoing_delay(nta_outgoing_t const *orq);
......@@ -3460,7 +3450,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,
sip_param_t to_tag,
msg_param_t to_tag,
sip_rseq_t const *rseq);
int nta_outgoing_cancel(nta_outgoing_t *);
......
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