Commit bad08e0f authored by Pekka Pessi's avatar Pekka Pessi
Browse files

Contact generated by nta now contains URL transport parameter.

The transport

darcs-hash:20051012101754-65a35-e369ea91bc0d2a9d8f442abc5357e8fffab89dfb.gz
parent 1a51b559
......@@ -1585,13 +1585,23 @@ static
int agent_init_contact(nta_agent_t *self)
{
sip_via_t const *v = agent_tport_via(tport_primaries(self->sa_tports));
char const *tp;
if (self->sa_contact)
return 0;
if (!v) return -1;
tp = strrchr(v->v_protocol, '/');
if (!tp++)
return -1;
if (strcasecmp(tp, "udp") == 0 && v->v_next &&
str0casecmp(v->v_next->v_protocol, sip_transport_tcp))
/* Do not include transport if we have both UDP and TCP */
tp = NULL;
self->sa_contact = sip_contact_create_from_via(self->sa_home, v, NULL);
self->sa_contact =
sip_contact_create_from_via_with_transport(self->sa_home, v, NULL, tp);
if (!self->sa_contact)
return -1;
......@@ -3888,7 +3898,8 @@ static void incoming_retransmit_reply(nta_incoming_t *irq, tport_t *tport);
* @param tag,value,... optional tagged parameters
*
* @TAGS
* @TAG NTATAG_TPORT() specify
* @TAG NTATAG_TPORT() specifies the transport used to receive the request
* and also default transport for sending the response.
*/
nta_incoming_t *nta_incoming_create(nta_agent_t *agent,
nta_leg_t *leg,
......@@ -5163,6 +5174,7 @@ int incoming_reply(nta_incoming_t *irq, msg_t *msg, sip_t *sip)
if (status >= 200 || irq->irq_status < 200) {
if (irq->irq_response)
msg_destroy(irq->irq_response);
assert(msg_home(msg) != irq->irq_home);
irq->irq_response = msg;
}
......
......@@ -121,25 +121,41 @@ sip_contact_create_from_via(su_home_t *home,
sip_via_t const *v,
char const *user)
{
const char *host, *port, *tp, *maddr, *comp;
char const *scheme = "sip";
const char *tp;
if (!v) return NULL;
tp = strrchr(v->v_protocol, '/');
if (tp)
tp++;
if (!tp++)
return NULL;
if (strcasecmp(tp, "udp") == 0) /* Default is UDP */
tp = NULL;
return sip_contact_create_from_via_with_transport(home, v, user, tp);
}
/** Convert a Via header to Contact header */
sip_contact_t *
sip_contact_create_from_via_with_transport(su_home_t *home,
sip_via_t const *v,
char const *user,
char const *transport)
{
const char *host, *port, *maddr, *comp;
char const *scheme = "sip";
if (!v) return NULL;
host = v->v_host;
port = v->v_port;
maddr = v->v_maddr;
if (tp == NULL || host == NULL)
if (host == NULL)
return NULL;
if (strcasecmp(tp, "udp") == 0) { /* Default is UDP */
tp = NULL;
} else if (strcasecmp(tp, "tls") == 0) {
scheme = "sips", tp = NULL;
if (transport && strcasecmp(transport, "tls") == 0) {
scheme = "sips", transport = NULL;
if (port && strcmp(port, "5061") == 0)
port = NULL;
}
......@@ -151,11 +167,13 @@ sip_contact_create_from_via(su_home_t *home,
scheme,
user ? user : "", user ? "@" : "",
host, port ? ":" : "", port ? port : "",
tp ? ";transport=" : "", tp ? tp : "",
transport ? ";transport=" : "",
transport ? transport : "",
maddr ? ";maddr=" : "", maddr ? maddr : "",
comp ? ";comp=" : "", comp ? comp : "");
}
/**Perform sanity check on a SIP message
*
* The function sip_sanity_check() checks that the SIP message has all the
......
......@@ -49,6 +49,12 @@ int sip_params_cmp(sip_param_t const a[], sip_param_t const b[]);
int sip_params_replace(su_home_t *, sip_param_t **pparams, sip_param_t param);
unsigned long sip_hash_string(char const *id);
sip_contact_t *
sip_contact_create_from_via_with_transport(su_home_t *home,
sip_via_t const *v,
char const *user,
char const *transport);
sip_contact_t *sip_contact_create_from_via(su_home_t *, sip_via_t const *,
char const *user);
......
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