From c78d398cc1d4bc5dae90905a9785506b3940ea33 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Wed, 7 Oct 2015 13:49:20 +0000 Subject: [PATCH] patch from richard: sip: reverse order of transport enumeration for SRV-records if URI host is not ip, port is not specified, transport not set and NAPTR lookup fails we will check if SRV records exists for each supported transport in the order: TLS, TCP, UDP. If no SRV records found use UDP transport and A lookup. --- src/sip/request.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/sip/request.c b/src/sip/request.c index 4f39bce..ac3892e 100644 --- a/src/sip/request.c +++ b/src/sip/request.c @@ -281,6 +281,23 @@ static bool transp_next(struct sip *sip, enum sip_transp *tp) } +static bool transp_next_srv(struct sip *sip, enum sip_transp *tp) +{ + enum sip_transp i; + + for (i=(enum sip_transp)(*tp-1); i>SIP_TRANSP_NONE; i--) { + + if (!sip_transp_supported(sip, i, AF_UNSPEC)) + continue; + + *tp = i; + return true; + } + + return false; +} + + static bool rr_append_handler(struct dnsrr *rr, void *arg) { struct list *lst = arg; @@ -375,6 +392,12 @@ static void naptr_handler(int err, const struct dnshdr *hdr, struct list *ansl, rr = dns_rrlist_apply(ansl, NULL, DNS_TYPE_NAPTR, DNS_CLASS_IN, false, rr_naptr_handler, req); if (!rr) { + req->tp = SIP_TRANSPC; + if (!transp_next_srv(req->sip, &req->tp)) { + err = EPROTONOSUPPORT; + goto fail; + } + err = srv_lookup(req, req->host); if (err) goto fail; @@ -432,7 +455,7 @@ static void srv_handler(int err, const struct dnshdr *hdr, struct list *ansl, if (!req->srvl.head) { if (!req->tp_selected) { - if (transp_next(req->sip, &req->tp)) { + if (transp_next_srv(req->sip, &req->tp)) { err = srv_lookup(req, req->host); if (err)