瀏覽代碼

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

(cherry picked from commit a52c0024723a59d90c3c3966d5deadaf8b0d4440)

Daniel-Constantin Mierla 11 年之前
父節點
當前提交
c233c2b5fd
共有 2 個文件被更改,包括 23 次插入0 次删除
  1. 21 0
      ip_addr.c
  2. 2 0
      ip_addr.h

+ 21 - 0
ip_addr.c

@@ -415,3 +415,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;
+}

+ 2 - 0
ip_addr.h

@@ -843,4 +843,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