Skip to content

Commit

Permalink
net,sip: remove net_dst_is_source_addr()
Browse files Browse the repository at this point in the history
  • Loading branch information
cspiel1 committed Jun 16, 2021
1 parent d0fc317 commit 0e24082
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
1 change: 0 additions & 1 deletion include/re_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ struct sa;
/* Net generic */
int net_hostaddr(int af, struct sa *ip);
int net_dst_source_addr_get(const struct sa *dst, struct sa *ip);
int net_dst_is_source_addr(const struct sa *dst, const struct sa *ip);
int net_default_source_addr_get(int af, struct sa *ip);
int net_default_gateway_get(int af, struct sa *gw);

Expand Down
16 changes: 0 additions & 16 deletions src/net/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,6 @@ int net_dst_source_addr_get(const struct sa *dst, struct sa *ip)
}


int net_dst_is_source_addr(const struct sa *dst, const struct sa *ip)
{
struct sa src;
int err;

err = net_dst_source_addr_get(dst, &src);
if (err)
return err;

if (!sa_cmp(ip, &src, SA_ADDR))
return ECONNREFUSED;

return 0;
}


/**
* Get the default source IP address
*
Expand Down
14 changes: 9 additions & 5 deletions src/sip/transp.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,28 @@ static const struct sip_transport *transp_find(struct sip *sip,
for (le = sip->transpl.head; le; le = le->next) {

const struct sip_transport *transp = le->data;
const struct sa *src = &transp->laddr;
const struct sa *laddr = &transp->laddr;
struct sa src;

if (transp->tp != tp)
continue;

if (af != AF_UNSPEC && sa_af(src) != af)
if (af != AF_UNSPEC && sa_af(laddr) != af)
continue;

if (!sa_isset(dst, SA_ADDR))
return transp;

if (sa_is_linklocal(src) != sa_is_linklocal(dst))
if (sa_is_linklocal(laddr) != sa_is_linklocal(dst))
continue;

sa_cpy(&dsttmp, dst);
sa_set_scopeid(&dsttmp, sa_scopeid(src));
sa_set_scopeid(&dsttmp, sa_scopeid(laddr));

if (net_dst_is_source_addr(&dsttmp, src))
if (net_dst_source_addr_get(&dsttmp, &src))
continue;

if (!sa_cmp(&src, laddr, SA_ADDR))
continue;

return transp;
Expand Down

0 comments on commit 0e24082

Please sign in to comment.