diff --git a/include/re_sip.h b/include/re_sip.h index 8250911..e6dd358 100644 --- a/include/re_sip.h +++ b/include/re_sip.h @@ -234,6 +234,8 @@ int sip_alloc(struct sip **sipp, struct dnsc *dnsc, uint32_t ctsz, int sip_transp_add(struct sip *sip, enum sip_transp tp, const struct sa *laddr, ...); void sip_transp_flush(struct sip *sip); +bool sip_transp_isladdr(const struct sip *sip, enum sip_transp tp, + const struct sa *laddr); void sip_close(struct sip *sip, bool force); int sip_listen(struct sip_lsnr **lsnrp, struct sip *sip, bool req, sip_msg_h *msgh, void *arg); diff --git a/src/sip/transp.c b/src/sip/transp.c index 97b0b07..c8ee2c9 100644 --- a/src/sip/transp.c +++ b/src/sip/transp.c @@ -771,6 +771,31 @@ bool sip_transp_supported(struct sip *sip, enum sip_transp tp, int af) } +bool sip_transp_isladdr(const struct sip *sip, enum sip_transp tp, + const struct sa *laddr) +{ + struct le *le; + + if (!sip || !laddr) + return false; + + for (le=sip->transpl.head; le; le=le->next) { + + const struct sip_transport *transp = le->data; + + if (tp != SIP_TRANSP_NONE && transp->tp != tp) + continue; + + if (!sa_cmp(&transp->laddr, laddr, SA_ALL)) + continue; + + return true; + } + + return false; +} + + const char *sip_transp_name(enum sip_transp tp) { switch (tp) {