Browse code

core: helper functions to get addr and port to be used in signaling from socket info

Daniel-Constantin Mierla authored on 28/09/2014 10:48:53
Showing 2 changed files
... ...
@@ -404,3 +404,24 @@ int ip_addr_match_net(ip_addr_t *iaddr, ip_addr_t *naddr,
404 404
 		return 0;
405 405
 	return -1;
406 406
 }
407
+
408
+int si_get_signaling_data(struct socket_info *si, str **addr, str **port)
409
+{
410
+	if(si==NULL)
411
+		return -1;
412
+	if(addr) {
413
+		if(si->useinfo.name.len>0) {
414
+			*addr = &si->useinfo.name;
415
+		} else {
416
+			*addr = &si->address_str;
417
+		}
418
+	}
419
+	if(port) {
420
+		if(si->useinfo.port_no>0) {
421
+			*port = &si->useinfo.port_no_str;
422
+		} else {
423
+			*port = &si->port_no_str;
424
+		}
425
+	}
426
+	return 0;
427
+}
... ...
@@ -807,4 +807,6 @@ inline static void init_dst_from_rcv(struct dest_info* dst,
807 807
  */
808 808
 int ip_addr_match_net(ip_addr_t *iaddr, ip_addr_t *naddr, int mask);
809 809
 
810
+int si_get_signaling_data(struct socket_info *si, str **addr, str **port);
811
+
810 812
 #endif