Browse code

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

- helper function to generate similar value

Daniel-Constantin Mierla authored on 02/10/2014 15:31:34
Showing 2 changed files
... ...
@@ -166,7 +166,7 @@
166 166
 #define BUF_SIZE 65535
167 167
 
168 168
 #define MAX_VIA_LINE_SIZE	240	/*!< forwarding  -- Via buffer dimensioning */
169
-#define MAX_RECEIVED_SIZE	57	/*!< forwarding  -- Via buffer dimensioning - Received header */
169
+#define MAX_RECEIVED_SIZE	59	/*!< forwarding  -- Via buffer dimensioning - Received header */
170 170
 #define MAX_RPORT_SIZE		13	/*!< forwarding  -- Via buffer dimensioning - Rport */
171 171
 
172 172
 #define MAX_BRANCHES    	12	/*!< maximum number of branches per transaction */
... ...
@@ -692,7 +692,27 @@ static inline char* ip_addr2a(struct ip_addr* ip)
692 692
 	return buff;
693 693
 }
694 694
 
695
+/* full address in text representation, including [] for ipv6 */
696
+static inline char* ip_addr2strz(struct ip_addr* ip)
697
+{
698
+
699
+	static char buff[IP_ADDR_MAX_STR_SIZE+2];
700
+	char *p;
701
+	int len;
702
+
703
+	p = buff;
704
+	if(ip->af==AF_INET6) {
705
+		*p++ = '[';
706
+	}
707
+	len=ip_addr2sbuf(ip, p, sizeof(buff)-3);
708
+	p += len;
709
+	if(ip->af==AF_INET6) {
710
+		*p++ = ']';
711
+	}
712
+	*p=0;
695 713
 
714
+	return buff;
715
+}
696 716
 
697 717
 #define SU2A_MAX_STR_SIZE  (IP6_MAX_STR_SIZE + 2 /* [] */+\
698 718
 								1 /* : */ + USHORT2SBUF_MAX_LEN + 1 /* \0 */)