diff --git a/src/sip/transp.c b/src/sip/transp.c index 9794783f3..1b0f83c4e 100644 --- a/src/sip/transp.c +++ b/src/sip/transp.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "sip.h" @@ -150,19 +151,33 @@ static const struct sip_transport *transp_find(struct sip *sip, int af, const struct sa *dst) { struct le *le; - (void)dst; + struct sa dsttmp; for (le = sip->transpl.head; le; le = le->next) { const struct sip_transport *transp = le->data; + const struct sa *laddr = &transp->laddr; + struct sa src; if (transp->tp != tp) continue; - if (af != AF_UNSPEC && sa_af(&transp->laddr) != af) + if (af != AF_UNSPEC && sa_af(laddr) != af) + continue; + + if (!sa_isset(dst, SA_ADDR)) + return transp; + + if (sa_is_linklocal(laddr) != sa_is_linklocal(dst)) + continue; + + sa_cpy(&dsttmp, dst); + sa_set_scopeid(&dsttmp, sa_scopeid(laddr)); + + if (net_dst_source_addr_get(&dsttmp, &src)) continue; - if (sa_is_linklocal(&transp->laddr) != sa_is_linklocal(dst)) + if (!sa_cmp(&src, laddr, SA_ADDR)) continue; return transp;