From 3537c5625a717a7f7503ceff7d8454e4acd78dcd Mon Sep 17 00:00:00 2001 From: Maximilian Fridrich Date: Wed, 10 Jul 2024 17:14:23 +0200 Subject: [PATCH] sipreg/reg: add peer address to sipreg --- include/re_sipreg.h | 1 + src/sipreg/reg.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) 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 *