Skip to content

Commit

Permalink
net,sip: check if destination is reachable when selecting transport
Browse files Browse the repository at this point in the history
  • Loading branch information
cspiel1 committed Jun 28, 2021
1 parent 1300a3c commit aea47a8
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/sip/transp.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <re_http.h>
#include <re_websock.h>
#include <re_sip.h>
#include <re_net.h>
#include "sip.h"


Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit aea47a8

Please sign in to comment.