diff --git a/include/re_sipreg.h b/include/re_sipreg.h index f5661337f..6e7d74bf5 100644 --- a/include/re_sipreg.h +++ b/include/re_sipreg.h @@ -27,6 +27,7 @@ int sipreg_send(struct sipreg *reg); int sipreg_set_rwait(struct sipreg *reg, uint32_t rwait); const struct sa *sipreg_laddr(const struct sipreg *reg); +const struct sa *sipreg_paddr(const struct sipreg *reg); uint32_t sipreg_proxy_expires(const struct sipreg *reg); bool sipreg_registered(const struct sipreg *reg); diff --git a/src/sipreg/reg.c b/src/sipreg/reg.c index 7dff7bd1f..57308217d 100644 --- a/src/sipreg/reg.c +++ b/src/sipreg/reg.c @@ -28,6 +28,7 @@ enum { struct sipreg { struct sip_loopstate ls; struct sa laddr; + struct sa paddr; struct tmr tmr; struct sip *sip; struct sip_keepalive *ka; @@ -201,6 +202,8 @@ static void response_handler(int err, const struct sip_msg *msg, void *arg) goto out; } + reg->paddr = msg->src; + if (msg->scode < 200) { return; } @@ -565,6 +568,19 @@ const struct sa *sipreg_laddr(const struct sipreg *reg) } +/** + * Get the peer address for a SIP Registration client + * + * @param reg SIP Registration client + * + * @return Peer address + */ +const struct sa *sipreg_paddr(const struct sipreg *reg) +{ + return reg ? ®->paddr : NULL; +} + + /** * Get the proxy expires value of a SIP registration client *