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

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date:   Tue May 25 21:10:32 2010 +0200

core: socket_str enclose IPv6 addresses in betwen [ ]

- string representation of socket string takes in consideration IPv6
  addresses

---

 socket_info.c |    9 +++++++++
 socket_info.h |    2 +-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/socket_info.c b/socket_info.c
index aca7793..5cdc790 100644
--- a/socket_info.c
+++ b/socket_info.c
@@ -328,6 +328,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");
@@ -338,8 +341,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;
diff --git a/socket_info.h b/socket_info.h
index 6da9437..7923e65 100644
--- a/socket_info.h
+++ b/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);
 


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to