Переглянути джерело

core: socket_str enclose IPv6 addresses in betwen [ ]

- string representation of socket string takes in consideration IPv6
  addresses
(cherry picked from commit 426c6b7e2103d38aca47ca9728d22355bd44b7e9)

Conflicts:

	pkg/kamailio/debian-lenny
Daniel-Constantin Mierla 15 роки тому
батько
коміт
fc67150b32
3 змінених файлів з 10 додано та 2 видалено
  1. 0 1
      pkg/kamailio/debian-lenny
  2. 9 0
      socket_info.c
  3. 1 1
      socket_info.h

+ 0 - 1
pkg/kamailio/debian-lenny

@@ -1 +0,0 @@
-debian

+ 9 - 0
socket_info.c

@@ -321,6 +321,9 @@ int socket2str(char* s, int* len, struct socket_info* si)
 	proto.len = strlen(proto.s);
 	
 	l = proto.len + si->address_str.len + si->port_no_str.len + 2;
+
+	if(si->address.af==AF_INET6)
+		l += 2;
 	
 	if (*len < l) {
 		ERR("socket2str: Destionation buffer too short\n");
@@ -331,8 +334,14 @@ int socket2str(char* s, int* len, struct socket_info* si)
 	memcpy(s, proto.s, proto.len);
 	s += proto.len;
 	*s = ':'; s++;
+	if(si->address.af==AF_INET6) {
+		*s = '['; s++;
+	}
 	memcpy(s, si->address_str.s, si->address_str.len);
 	s += si->address_str.len;
+	if(si->address.af==AF_INET6) {
+		*s = ']'; s++;
+	}
 	*s = ':'; s++;
 	memcpy(s, si->port_no_str.s, si->port_no_str.len);
 	s += si->port_no_str.len;

+ 1 - 1
socket_info.h

@@ -47,7 +47,7 @@
  * the text description of any socket, not counting the terminating zero added
  * by socket2str */
 #define MAX_SOCKET_STR (sizeof("unknown") - 1 + IP_ADDR_MAX_STR_SIZE + \
-	INT2STR_MAX_LEN + 2)
+	INT2STR_MAX_LEN + 2 + 2)
 
 int socket2str(char* s, int* len, struct socket_info* si);