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

Daniel-Constantin Mierla miconda at gmail.com
Sun Sep 28 12:50:19 CEST 2014


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.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

---

 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 3ab1b55..b11ab27 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 c1c966d..4efb3bc 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