[sr-dev] git:master: core: be prepared to get Via received param with brackets around ipv6 addr

Daniel-Constantin Mierla miconda at gmail.com
Thu Oct 2 17:35:42 CEST 2014


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Thu Oct  2 17:31:34 2014 +0200

core: be prepared to get Via received param with brackets around ipv6 addr

- helper function to generate similar value

---

 config.h  |    2 +-
 ip_addr.h |   20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/config.h b/config.h
index 687e6a6..a240f7b 100644
--- a/config.h
+++ b/config.h
@@ -166,7 +166,7 @@
 #define BUF_SIZE 65535
 
 #define MAX_VIA_LINE_SIZE	240	/*!< forwarding  -- Via buffer dimensioning */
-#define MAX_RECEIVED_SIZE	57	/*!< forwarding  -- Via buffer dimensioning - Received header */
+#define MAX_RECEIVED_SIZE	59	/*!< forwarding  -- Via buffer dimensioning - Received header */
 #define MAX_RPORT_SIZE		13	/*!< forwarding  -- Via buffer dimensioning - Rport */
 
 #define MAX_BRANCHES    	12	/*!< maximum number of branches per transaction */
diff --git a/ip_addr.h b/ip_addr.h
index 4efb3bc..3cdecc6 100644
--- a/ip_addr.h
+++ b/ip_addr.h
@@ -692,7 +692,27 @@ static inline char* ip_addr2a(struct ip_addr* ip)
 	return buff;
 }
 
+/* full address in text representation, including [] for ipv6 */
+static inline char* ip_addr2strz(struct ip_addr* ip)
+{
+
+	static char buff[IP_ADDR_MAX_STR_SIZE+2];
+	char *p;
+	int len;
+
+	p = buff;
+	if(ip->af==AF_INET6) {
+		*p++ = '[';
+	}
+	len=ip_addr2sbuf(ip, p, sizeof(buff)-3);
+	p += len;
+	if(ip->af==AF_INET6) {
+		*p++ = ']';
+	}
+	*p=0;
 
+	return buff;
+}
 
 #define SU2A_MAX_STR_SIZE  (IP6_MAX_STR_SIZE + 2 /* [] */+\
 								1 /* : */ + USHORT2SBUF_MAX_LEN + 1 /* \0 */)




More information about the sr-dev mailing list