Commit c891a2e0 authored by Pekka Pessi's avatar Pekka Pessi

Using sip_via_port(). Renamed NTATAG_RPORT as NTATAG_CLIENT_RPORT.

Documented sip_via_port().

darcs-hash:20060310182116-65a35-bcb6c38e760118ed72a43db2450fc30cf8c39e5f.gz
parent aa336e09
......@@ -1745,13 +1745,13 @@ int outgoing_insert_via(nta_outgoing_t *orq,
/** Get destination name from Via.
*
* If using_rport is non-NULL, use value from rport.
* If @a using_rport is non-null, try rport.
* If *using_rport is non-zero, try rport even if <protocol> is not UDP.
* If <protocol> is UDP, set *using_rport to zero.
*/
static
int nta_tpn_by_via(tp_name_t *tpn, sip_via_t const *v, int *using_rport)
{
char const *rport;
if (!v)
return -1;
......@@ -2507,7 +2507,7 @@ int nta_msg_tsend(nta_agent_t *agent, msg_t *msg, url_string_t const *u,
tport = tport_by_protocol(agent->sa_tports, tpn->tpn_proto);
if (retry_without_rport)
tpn->tpn_port = SIP_PORT(sip->sip_via->v_port);
tpn->tpn_port = sip_via_port(sip->sip_via, NULL);
#if HAVE_SIGCOMP
if (tport && tpn->tpn_comp && cc == NONE)
......@@ -2649,7 +2649,7 @@ int nta_msg_mreply(nta_agent_t *agent,
}
if (retry_without_rport)
tpn->tpn_port = SIP_PORT(sip->sip_via->v_port);
tpn->tpn_port = sip_via_port(sip->sip_via, NULL);
#if HAVE_SIGCOMP
if (tport && tpn->tpn_comp) {
......
......@@ -98,7 +98,7 @@ tag_typedef_t ntatag_rel100 = BOOLTAG_TYPEDEF(rel100);
tag_typedef_t ntatag_no_dialog = BOOLTAG_TYPEDEF(no_dialog);
tag_typedef_t ntatag_use_timestamp = BOOLTAG_TYPEDEF(use_timestamp);
tag_typedef_t ntatag_sipflags = UINTTAG_TYPEDEF(sipflags);
tag_typedef_t ntatag_rport = BOOLTAG_TYPEDEF(rport);
tag_typedef_t ntatag_client_rport = BOOLTAG_TYPEDEF(client_rport);
tag_typedef_t ntatag_server_rport = BOOLTAG_TYPEDEF(server_rport);
tag_typedef_t ntatag_tcp_rport = BOOLTAG_TYPEDEF(tcp_rport);
tag_typedef_t ntatag_preload = UINTTAG_TYPEDEF(preload);
......
......@@ -128,8 +128,7 @@ nta_agent_t *nta_agent_create(su_root_t *root,
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);
char const *nta_agent_version(nta_agent_t const *a);
nta_agent_magic_t *nta_agent_magic(nta_agent_t const *a);
......@@ -137,6 +136,10 @@ int nta_agent_add_tport(nta_agent_t *agent,
url_string_t const *url,
tag_type_t tag, tag_value_t value, ...);
sip_contact_t *nta_agent_contact(nta_agent_t const *a);
sip_via_t *nta_agent_via(nta_agent_t const *a);
sip_via_t *nta_agent_public_via(nta_agent_t const *a);
char const *nta_agent_newtag(su_home_t *, char const *fmt, nta_agent_t *);
int nta_agent_set_params(nta_agent_t *agent,
......
......@@ -396,12 +396,15 @@ NTA_DLL extern tag_typedef_t ntatag_sipflags;
NTA_DLL extern tag_typedef_t ntatag_sipflags_ref;
#define NTATAG_SIPFLAGS_REF(x) ntatag_sipflags_ref, tag_uint_vr(&(x))
NTA_DLL extern tag_typedef_t ntatag_rport;
NTA_DLL extern tag_typedef_t ntatag_client_rport;
/** Add rport at client. @HI */
#define NTATAG_RPORT(x) ntatag_rport, tag_bool_v((x))
#define NTATAG_CLIENT_RPORT(x) ntatag_client_rport, tag_bool_v((x))
NTA_DLL extern tag_typedef_t ntatag_rport_ref;
#define NTATAG_RPORT_REF(x) ntatag_rport_ref, tag_bool_vr(&(x))
NTA_DLL extern tag_typedef_t ntatag_client_rport_ref;
#define NTATAG_CLIENT_RPORT_REF(x) ntatag_client_rport_ref, tag_bool_vr(&(x))
#define NTATAG_RPORT(x) ntatag_client_rport, tag_bool_v((x))
#define NTATAG_RPORT_REF(x) ntatag_client_rport_ref, tag_bool_vr(&(x))
NTA_DLL extern tag_typedef_t ntatag_server_rport;
/** Use rport at server. @HI */
......
......@@ -1085,9 +1085,9 @@ sip_call_id_t *sip_call_id_create(su_home_t *home, char const *domain)
su_guid_generate(guid);
/*
* Guid looks like "NNNNNNNN-NNNN-NNNN-NNNN-XX:XX:XX:XX:XX:XX"
* Guid looks like "NNNNNNNN-NNNN-NNNN-NNNN-XXXXXXXXXXXX"
* where NNNNNNNN-NNNN-NNNN-NNNN is timestamp and XX is MAC address
* (but we use random ID for MAC because we do not have
* (but we use usually random ID for MAC because we do not have
* guid generator available for all processes within node)
*/
su_guid_sprintf(b, su_guid_strlen + 1, guid);
......@@ -2795,27 +2795,35 @@ sip_via_t *sip_via_create(su_home_t *home,
/**@ingroup sip_via
*
* Get port number corresponding to a Via line.
*
* Get port number corresponding to a Via line.
*
* If @a using_rport is non-null, try rport.
* If *using_rport is non-zero, try rport even if <protocol> is not UDP.
* If <protocol> is UDP, set *using_rport to zero.
*/
char const *sip_via_port(sip_via_t const *v, int *using_rport)
{
char const *port;
if (v == NULL)
return NULL;
if (v->v_maddr || !using_rport)
port = NULL;
else if (strcasecmp(v->v_protocol, "SIP/2.0/UDP") == 0)
port = v->v_rport, *using_rport = 0;
else if (*using_rport)
port = v->v_rport;
else
port = NULL;
if (using_rport) {
char const *port;
if (port && port[0])
return port;
if (v->v_rport && !v->v_maddr /* multicast */) {
if (v->v_protocol == sip_transport_udp ||
strcasecmp(v->v_protocol, sip_transport_udp) == 0)
port = v->v_rport, *using_rport = 0;
else if (*using_rport)
port = v->v_rport;
else
port = NULL;
if (port && port[0])
return port;
}
if (using_rport)
*using_rport = 0;
*using_rport = 0; /* No, we don't... */
}
if (v->v_port)
return v->v_port;
......
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