[sr-dev] git:4.1: core: helper functions to get addr and port to be used in signaling from socket info

Juha Heinanen jh at tutpro.com
Sun Sep 28 20:16:31 CEST 2014


Module: sip-router
Branch: 4.1
Commit: a52c0024723a59d90c3c3966d5deadaf8b0d4440
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a52c0024723a59d90c3c3966d5deadaf8b0d4440

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Juha Heinanen <jh at tutpro.com>
Date:   Sun Sep 28 12:48:53 2014 +0200

core: helper functions to get addr and port to be used in signaling from socket info
(cherry picked from commit c725f1dec14863e069bfd1e5c26857a1005528d5)

---

 ip_addr.c |   21 +++++++++++++++++++++
 ip_addr.h |    2 ++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/ip_addr.c b/ip_addr.c
index 5f8881e..7175bd0 100644
--- a/ip_addr.c
+++ b/ip_addr.c
@@ -404,3 +404,24 @@ int ip_addr_match_net(ip_addr_t *iaddr, ip_addr_t *naddr,
 		return 0;
 	return -1;
 }
+
+int si_get_signaling_data(struct socket_info *si, str **addr, str **port)
+{
+	if(si==NULL)
+		return -1;
+	if(addr) {
+		if(si->useinfo.name.len>0) {
+			*addr = &si->useinfo.name;
+		} else {
+			*addr = &si->address_str;
+		}
+	}
+	if(port) {
+		if(si->useinfo.port_no>0) {
+			*port = &si->useinfo.port_no_str;
+		} else {
+			*port = &si->port_no_str;
+		}
+	}
+	return 0;
+}
diff --git a/ip_addr.h b/ip_addr.h
index 20b3ec2..5806122 100644
--- a/ip_addr.h
+++ b/ip_addr.h
@@ -807,4 +807,6 @@ inline static void init_dst_from_rcv(struct dest_info* dst,
  */
 int ip_addr_match_net(ip_addr_t *iaddr, ip_addr_t *naddr, int mask);
 
+int si_get_signaling_data(struct socket_info *si, str **addr, str **port);
+
 #endif




More information about the sr-dev mailing list