소스 검색

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

- helper function to generate similar value
Daniel-Constantin Mierla 11 년 전
부모
커밋
b7bc7a5450
2개의 변경된 파일21개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      config.h
  2. 20 0
      ip_addr.h

+ 1 - 1
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 */

+ 20 - 0
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 */)