You can subscribe to this list here.
| 2002 | Jan | Feb | Mar | Apr (24) | May (14) | Jun (29) | Jul (33) | Aug (3) | Sep (8) | Oct (18) | Nov (1) | Dec (10) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 | Jan (3) | Feb (33) | Mar (7) | Apr (28) | May (30) | Jun (5) | Jul (10) | Aug (7) | Sep (32) | Oct (41) | Nov (20) | Dec (10) |
| 2004 | Jan (24) | Feb (18) | Mar (57) | Apr (40) | May (55) | Jun (48) | Jul (77) | Aug (15) | Sep (56) | Oct (80) | Nov (74) | Dec (52) |
| 2005 | Jan (38) | Feb (42) | Mar (39) | Apr (56) | May (79) | Jun (73) | Jul (16) | Aug (23) | Sep (68) | Oct (77) | Nov (52) | Dec (27) |
| 2006 | Jan (27) | Feb (18) | Mar (51) | Apr (62) | May (28) | Jun (50) | Jul (36) | Aug (33) | Sep (47) | Oct (50) | Nov (77) | Dec (13) |
| 2007 | Jan (15) | Feb (8) | Mar (14) | Apr (18) | May (25) | Jun (16) | Jul (16) | Aug (19) | Sep (32) | Oct (17) | Nov (5) | Dec (5) |
| 2008 | Jan (64) | Feb (25) | Mar (25) | Apr (6) | May (28) | Jun (20) | Jul (10) | Aug (27) | Sep (28) | Oct (59) | Nov (37) | Dec (43) |
| 2009 | Jan (40) | Feb (25) | Mar (12) | Apr (57) | May (46) | Jun (29) | Jul (39) | Aug (10) | Sep (20) | Oct (42) | Nov (50) | Dec (57) |
| 2010 | Jan (82) | Feb (165) | Mar (256) | Apr (260) | May (36) | Jun (87) | Jul (53) | Aug (89) | Sep (107) | Oct (51) | Nov (88) | Dec (117) |
| 2011 | Jan (69) | Feb (60) | Mar (113) | Apr (71) | May (67) | Jun (90) | Jul (88) | Aug (90) | Sep (48) | Oct (64) | Nov (69) | Dec (118) |
| 2012 | Jan (49) | Feb (528) | Mar (351) | Apr (190) | May (238) | Jun (193) | Jul (104) | Aug (100) | Sep (57) | Oct (41) | Nov (47) | Dec (51) |
| 2013 | Jan (94) | Feb (57) | Mar (96) | Apr (105) | May (77) | Jun (102) | Jul (27) | Aug (81) | Sep (32) | Oct (53) | Nov (127) | Dec (65) |
| 2014 | Jan (113) | Feb (59) | Mar (104) | Apr (259) | May (70) | Jun (70) | Jul (146) | Aug (45) | Sep (58) | Oct (149) | Nov (77) | Dec (83) |
| 2015 | Jan (53) | Feb (66) | Mar (86) | Apr (50) | May (135) | Jun (76) | Jul (151) | Aug (83) | Sep (97) | Oct (262) | Nov (245) | Dec (231) |
| 2016 | Jan (131) | Feb (233) | Mar (97) | Apr (138) | May (221) | Jun (254) | Jul (92) | Aug (248) | Sep (168) | Oct (275) | Nov (477) | Dec (445) |
| 2017 | Jan (218) | Feb (217) | Mar (146) | Apr (172) | May (216) | Jun (252) | Jul (164) | Aug (192) | Sep (190) | Oct (143) | Nov (255) | Dec (182) |
| 2018 | Jan (295) | Feb (164) | Mar (113) | Apr (147) | May (64) | Jun (262) | Jul (184) | Aug (90) | Sep (69) | Oct (364) | Nov (102) | Dec (101) |
| 2019 | Jan (119) | Feb (64) | Mar (64) | Apr (102) | May (57) | Jun (154) | Jul (84) | Aug (81) | Sep (76) | Oct (102) | Nov (233) | Dec (89) |
| 2020 | Jan (38) | Feb (170) | Mar (155) | Apr (172) | May (120) | Jun (223) | Jul (461) | Aug (227) | Sep (268) | Oct (113) | Nov (56) | Dec (124) |
| 2021 | Jan (121) | Feb (48) | Mar (334) | Apr (345) | May (207) | Jun (136) | Jul (71) | Aug (112) | Sep (122) | Oct (173) | Nov (184) | Dec (223) |
| 2022 | Jan (197) | Feb (206) | Mar (156) | Apr (212) | May (192) | Jun (170) | Jul (143) | Aug (380) | Sep (182) | Oct (148) | Nov (128) | Dec (269) |
| 2023 | Jan (248) | Feb (196) | Mar (264) | Apr (36) | May (123) | Jun (66) | Jul (120) | Aug (48) | Sep (157) | Oct (198) | Nov (300) | Dec (273) |
| 2024 | Jan (271) | Feb (147) | Mar (207) | Apr (78) | May (107) | Jun (168) | Jul (151) | Aug (51) | Sep (438) | Oct (221) | Nov (302) | Dec (357) |
| 2025 | Jan (451) | Feb (219) | Mar (326) | Apr (232) | May (306) | Jun (181) | Jul (452) | Aug (282) | Sep (620) | Oct (793) | Nov (682) | Dec |
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| | | | | | | 1 |
| 2 (11) | 3 (10) | 4 | 5 (1) | 6 | 7 | 8 |
| 9 (2) | 10 (6) | 11 (6) | 12 (2) | 13 (3) | 14 (2) | 15 |
| 16 | 17 | 18 (1) | 19 | 20 (1) | 21 | 22 |
| 23 | 24 (9) | 25 (2) | 26 (1) | 27 | 28 | 29 |
| 30 | | | | | | |
| From: Gert D. <ge...@gr...> - 2012-09-03 12:22:05 |
Hi, ACK :) gert On Mon, Sep 03, 2012 at 02:16:04PM +0200, Arne Schwabe wrote: > --- > doc/openvpn.8 | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/doc/openvpn.8 b/doc/openvpn.8 > index f586744..6b10fe4 100644 > --- a/doc/openvpn.8 > +++ b/doc/openvpn.8 > @@ -1584,6 +1584,10 @@ and > .B \-\-ping-restart > in server mode configurations. > > +The server timeout is set twice the value of the second argument. > +This ensures that a timeout is dectected on client side > +before the server side drops the connection. > + > For example, > .B \-\-keepalive 10 60 > expands as follows: > -- > 1.7.9.5 > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Openvpn-devel mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/openvpn-devel > -- USENET is *not* the non-clickable part of WWW! //www.muc.de/~gert/ Gert Doering - Munich, Germany ge...@gr... fax: +49-89-35655025 ge...@ne... |
| From: Arne S. <ar...@rf...> - 2012-09-03 12:16:16 |
--- doc/openvpn.8 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/openvpn.8 b/doc/openvpn.8 index f586744..6b10fe4 100644 --- a/doc/openvpn.8 +++ b/doc/openvpn.8 @@ -1584,6 +1584,10 @@ and .B \-\-ping-restart in server mode configurations. +The server timeout is set twice the value of the second argument. +This ensures that a timeout is dectected on client side +before the server side drops the connection. + For example, .B \-\-keepalive 10 60 expands as follows: -- 1.7.9.5 |
| From: Arne S. <ar...@rf...> - 2012-09-03 11:57:32 |
--- doc/openvpn.8 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/openvpn.8 b/doc/openvpn.8 index f586744..bfc8c25 100644 --- a/doc/openvpn.8 +++ b/doc/openvpn.8 @@ -1582,7 +1582,11 @@ A helper directive designed to simplify the expression of .B \-\-ping and .B \-\-ping-restart -in server mode configurations. +in server mode configurations. + +The server timeout is set twice the value of the second argument. +This ensures that a timeout is dectected on client side before the +before server side drops the connection. For example, .B \-\-keepalive 10 60 -- 1.7.9.6 (Apple Git-31.1) |
| From: Samuli S. <sa...@op...> - 2012-09-03 07:51:45 |
> I ACK this, but please remember to tell your editor to use 8-character tabs, > as that is "what the rest of the code uses" - some of the new code looks > quite weird with ":set ts=8", and there's more diffs in there due to > whitespace changes (4 spaces getting converted into a single tab, like > before 'hostname = "::"'). We do not need a v5 re-spin, as David said > he'll take care of these. > > (Samuli: we need a style guide in the wiki...) > > gert +1. Anyone who knows what the current "standard" formatting please add instructions here: <https://community.openvpn.net/openvpn/wiki/DeveloperDocumentation#Formatting> -- Samuli Seppänen Community Manager OpenVPN Technologies, Inc irc freenode net: mattock |
| From: Gert D. <ge...@gr...> - 2012-09-03 07:31:44 |
Hi, this looks like it should work both on *BSD and on Linux - explicit salen parameter, based on sa_family, no special macros (since we have the switch/case part anyway). And the tabs are right \o/ ACK ;-) gert On Mon, Sep 03, 2012 at 09:26:16AM +0200, Arne Schwabe wrote: > --- > src/openvpn/socket.c | 68 ++++++++++++++++++++++---------------------------- > 1 file changed, 30 insertions(+), 38 deletions(-) > > diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c > index 505cf3b..a9adf3f 100644 > --- a/src/openvpn/socket.c > +++ b/src/openvpn/socket.c > @@ -2164,60 +2164,52 @@ print_sockaddr (const struct openvpn_sockaddr *addr, struct gc_arena *gc) > > const char * > print_sockaddr_ex (const struct openvpn_sockaddr *addr, > - const char* separator, > - const unsigned int flags, > - struct gc_arena *gc) > + const char* separator, > + const unsigned int flags, > + struct gc_arena *gc) > { > struct buffer out = alloc_buf_gc (128, gc); > bool addr_is_defined; > + char buf[NI_MAXHOST] = ""; > + > addr_is_defined = addr_defined (addr); > if (!addr_is_defined) { > return "[undef]"; > } > + > + int port; > + int salen; > switch(addr->addr.sa.sa_family) > { > case AF_INET: > - { > - const int port= ntohs (addr->addr.in4.sin_port); > - buf_puts (&out, "[AF_INET]"); > - > - if (!(flags & PS_DONT_SHOW_ADDR)) > - buf_printf (&out, "%s", (addr_defined (addr) ? inet_ntoa (addr->addr.in4.sin_addr) : "[undef]")); > - > - if (((flags & PS_SHOW_PORT) || (addr_defined (addr) && (flags & PS_SHOW_PORT_IF_DEFINED))) > - && port) > - { > - if (separator) > - buf_printf (&out, "%s", separator); > - > - buf_printf (&out, "%d", port); > - } > - } > + port= ntohs (addr->addr.in4.sin_port); > + buf_puts (&out, "[AF_INET]"); > + salen = sizeof (struct sockaddr_in); > break; > case AF_INET6: > - { > - const int port= ntohs (addr->addr.in6.sin6_port); > - char buf[INET6_ADDRSTRLEN] = ""; > - buf_puts (&out, "[AF_INET6]"); > - if (addr_is_defined) > - { > - getnameinfo(&addr->addr.sa, sizeof (struct sockaddr_in6), > - buf, sizeof (buf), NULL, 0, NI_NUMERICHOST); > - buf_puts (&out, buf); > - } > - if (((flags & PS_SHOW_PORT) || (addr_is_defined && (flags & PS_SHOW_PORT_IF_DEFINED))) > - && port) > - { > - if (separator) > - buf_puts (&out, separator); > - > - buf_printf (&out, "%d", port); > - } > - } > + port= ntohs (addr->addr.in6.sin6_port); > + buf_puts (&out, "[AF_INET6]"); > + salen = sizeof (struct sockaddr_in6); > break; > default: > ASSERT(0); > } > + > + if (!(flags & PS_DONT_SHOW_ADDR)) > + { > + getnameinfo(&addr->addr.sa, salen, > + buf, sizeof (buf), NULL, 0, NI_NUMERICHOST); > + buf_puts (&out, buf); > + } > + if (((flags & PS_SHOW_PORT) || (addr_is_defined && (flags & PS_SHOW_PORT_IF_DEFINED))) > + && port) > + { > + if (separator) > + buf_puts (&out, separator); > + > + buf_printf (&out, "%d", port); > + } > + > return BSTR (&out); > } > > -- > 1.7.9.6 (Apple Git-31.1) > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Openvpn-devel mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/openvpn-devel > -- USENET is *not* the non-clickable part of WWW! //www.muc.de/~gert/ Gert Doering - Munich, Germany ge...@gr... fax: +49-89-35655025 ge...@ne... |
| From: Arne S. <ar...@rf...> - 2012-09-03 07:26:27 |
--- src/openvpn/socket.c | 68 ++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 505cf3b..a9adf3f 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -2164,60 +2164,52 @@ print_sockaddr (const struct openvpn_sockaddr *addr, struct gc_arena *gc) const char * print_sockaddr_ex (const struct openvpn_sockaddr *addr, - const char* separator, - const unsigned int flags, - struct gc_arena *gc) + const char* separator, + const unsigned int flags, + struct gc_arena *gc) { struct buffer out = alloc_buf_gc (128, gc); bool addr_is_defined; + char buf[NI_MAXHOST] = ""; + addr_is_defined = addr_defined (addr); if (!addr_is_defined) { return "[undef]"; } + + int port; + int salen; switch(addr->addr.sa.sa_family) { case AF_INET: - { - const int port= ntohs (addr->addr.in4.sin_port); - buf_puts (&out, "[AF_INET]"); - - if (!(flags & PS_DONT_SHOW_ADDR)) - buf_printf (&out, "%s", (addr_defined (addr) ? inet_ntoa (addr->addr.in4.sin_addr) : "[undef]")); - - if (((flags & PS_SHOW_PORT) || (addr_defined (addr) && (flags & PS_SHOW_PORT_IF_DEFINED))) - && port) - { - if (separator) - buf_printf (&out, "%s", separator); - - buf_printf (&out, "%d", port); - } - } + port= ntohs (addr->addr.in4.sin_port); + buf_puts (&out, "[AF_INET]"); + salen = sizeof (struct sockaddr_in); break; case AF_INET6: - { - const int port= ntohs (addr->addr.in6.sin6_port); - char buf[INET6_ADDRSTRLEN] = ""; - buf_puts (&out, "[AF_INET6]"); - if (addr_is_defined) - { - getnameinfo(&addr->addr.sa, sizeof (struct sockaddr_in6), - buf, sizeof (buf), NULL, 0, NI_NUMERICHOST); - buf_puts (&out, buf); - } - if (((flags & PS_SHOW_PORT) || (addr_is_defined && (flags & PS_SHOW_PORT_IF_DEFINED))) - && port) - { - if (separator) - buf_puts (&out, separator); - - buf_printf (&out, "%d", port); - } - } + port= ntohs (addr->addr.in6.sin6_port); + buf_puts (&out, "[AF_INET6]"); + salen = sizeof (struct sockaddr_in6); break; default: ASSERT(0); } + + if (!(flags & PS_DONT_SHOW_ADDR)) + { + getnameinfo(&addr->addr.sa, salen, + buf, sizeof (buf), NULL, 0, NI_NUMERICHOST); + buf_puts (&out, buf); + } + if (((flags & PS_SHOW_PORT) || (addr_is_defined && (flags & PS_SHOW_PORT_IF_DEFINED))) + && port) + { + if (separator) + buf_puts (&out, separator); + + buf_printf (&out, "%d", port); + } + return BSTR (&out); } -- 1.7.9.6 (Apple Git-31.1) |
| From: Arne S. <ar...@rf...> - 2012-09-03 07:17:54 |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 03.09.12 09:09, schrieb Gert Doering: > Hi, > > On Mon, Sep 03, 2012 at 08:49:42AM +0200, Arne Schwabe wrote: >> Some BSD need the right salen, max(sizeof(v4),sizeof(v6)) does not work. Since sa_len is not a member in sockaddr for Linux and Windows and SA_LEN is no available on Darwin, NetBSD explicitly set salem > > "Something sneaked into your keyboard"... > >> + getnameinfo(&addr->addr.sa, sizeof (struct sockaddr_in6), >> + buf, sizeof (buf), NULL, 0, NI_NUMERICHOST); > > ... this very much looks like v1 of the patch...? :-) > > Anyway, what about defining an openvpn_sa_len() macro that will either > use SA_LEN() if it exists, or fall back to > > #define openvpn_sa_len(addr) ( addr->sa.sa_family == AF_INET? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6) ) > > this will, of course, bite us when we implement IPv8, but should be fine > for 2.3... I will try to avoid this for now... I hope to convert openvpn to fully using getnameinfo/getaddrinfo one day so that we do not need these deep look into the sockaddr anymore. > (Is there something magic in Autoconf to solve this? Must be a standard > problem...) > > I think most people don't deal with raw sockaddr structs. getaddrinfo returns ai_addrlen. Arne -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (Darwin) Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iEYEARECAAYFAlBEWZUACgkQe8+cMNS4zRf5/QCeKPwCJKva6l05i18OWv4tZJFB BuQAn36NT4DZoi5e9RTqm3XAfBQqiWup =e27Z -----END PGP SIGNATURE----- |
| From: Gert D. <ge...@gr...> - 2012-09-03 07:10:12 |
Hi, On Mon, Sep 03, 2012 at 08:49:42AM +0200, Arne Schwabe wrote: > Some BSD need the right salen, max(sizeof(v4),sizeof(v6)) does not work. Since sa_len is not a member in sockaddr for Linux and Windows and SA_LEN is no available on Darwin, NetBSD explicitly set salem "Something sneaked into your keyboard"... > + getnameinfo(&addr->addr.sa, sizeof (struct sockaddr_in6), > + buf, sizeof (buf), NULL, 0, NI_NUMERICHOST); ... this very much looks like v1 of the patch...? :-) Anyway, what about defining an openvpn_sa_len() macro that will either use SA_LEN() if it exists, or fall back to #define openvpn_sa_len(addr) ( addr->sa.sa_family == AF_INET? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6) ) this will, of course, bite us when we implement IPv8, but should be fine for 2.3... (Is there something magic in Autoconf to solve this? Must be a standard problem...) gert -- USENET is *not* the non-clickable part of WWW! //www.muc.de/~gert/ Gert Doering - Munich, Germany ge...@gr... fax: +49-89-35655025 ge...@ne... |
| From: Arne S. <ar...@rf...> - 2012-09-03 06:49:50 |
Some BSD need the right salen, max(sizeof(v4),sizeof(v6)) does not work. Since sa_len is not a member in sockaddr for Linux and Windows and SA_LEN is no available on Darwin, NetBSD explicitly set salem Signed-off-by: Arne Schwabe <ar...@rf...> --- src/openvpn/socket.c | 89 ++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 50 deletions(-) diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 505cf3b..a2f90ca 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -2168,57 +2168,46 @@ print_sockaddr_ex (const struct openvpn_sockaddr *addr, const unsigned int flags, struct gc_arena *gc) { - struct buffer out = alloc_buf_gc (128, gc); - bool addr_is_defined; - addr_is_defined = addr_defined (addr); - if (!addr_is_defined) { - return "[undef]"; - } - switch(addr->addr.sa.sa_family) - { - case AF_INET: - { - const int port= ntohs (addr->addr.in4.sin_port); - buf_puts (&out, "[AF_INET]"); - - if (!(flags & PS_DONT_SHOW_ADDR)) - buf_printf (&out, "%s", (addr_defined (addr) ? inet_ntoa (addr->addr.in4.sin_addr) : "[undef]")); - - if (((flags & PS_SHOW_PORT) || (addr_defined (addr) && (flags & PS_SHOW_PORT_IF_DEFINED))) - && port) - { - if (separator) - buf_printf (&out, "%s", separator); - - buf_printf (&out, "%d", port); - } + struct buffer out = alloc_buf_gc (128, gc); + bool addr_is_defined; + char buf[NI_MAXHOST] = ""; + + addr_is_defined = addr_defined (addr); + if (!addr_is_defined) { + return "[undef]"; } - break; - case AF_INET6: - { - const int port= ntohs (addr->addr.in6.sin6_port); - char buf[INET6_ADDRSTRLEN] = ""; - buf_puts (&out, "[AF_INET6]"); - if (addr_is_defined) - { - getnameinfo(&addr->addr.sa, sizeof (struct sockaddr_in6), - buf, sizeof (buf), NULL, 0, NI_NUMERICHOST); - buf_puts (&out, buf); - } - if (((flags & PS_SHOW_PORT) || (addr_is_defined && (flags & PS_SHOW_PORT_IF_DEFINED))) - && port) - { - if (separator) - buf_puts (&out, separator); - - buf_printf (&out, "%d", port); - } - } - break; - default: - ASSERT(0); - } - return BSTR (&out); + + int port; + switch(addr->addr.sa.sa_family) + { + case AF_INET: + port= ntohs (addr->addr.in4.sin_port); + buf_puts (&out, "[AF_INET]"); + break; + case AF_INET6: + port= ntohs (addr->addr.in6.sin6_port); + buf_puts (&out, "[AF_INET6]"); + break; + default: + ASSERT(0); + } + + if (!(flags & PS_DONT_SHOW_ADDR)) + { + getnameinfo(&addr->addr.sa, sizeof (struct sockaddr_in6), + buf, sizeof (buf), NULL, 0, NI_NUMERICHOST); + buf_puts (&out, buf); + } + if (((flags & PS_SHOW_PORT) || (addr_is_defined && (flags & PS_SHOW_PORT_IF_DEFINED))) + && port) + { + if (separator) + buf_puts (&out, separator); + + buf_printf (&out, "%d", port); + } + + return BSTR (&out); } const char * -- 1.7.9.6 (Apple Git-31.1) |
| From: Arne S. <ar...@rf...> - 2012-09-03 06:43:37 |
Some BSD need the right salen, max(sizeof(v4),sizeof(v6)) does not work. Since sa_len is not a member in sockaddr for Linux and Windows and SA_LEN is no available on Darwin, NetBSD explicitly set salem Signed-off-by: Arne Schwabe <ar...@rf...> --- src/openvpn/socket.c | 89 ++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 50 deletions(-) diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 505cf3b..a2f90ca 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -2168,57 +2168,46 @@ print_sockaddr_ex (const struct openvpn_sockaddr *addr, const unsigned int flags, struct gc_arena *gc) { - struct buffer out = alloc_buf_gc (128, gc); - bool addr_is_defined; - addr_is_defined = addr_defined (addr); - if (!addr_is_defined) { - return "[undef]"; - } - switch(addr->addr.sa.sa_family) - { - case AF_INET: - { - const int port= ntohs (addr->addr.in4.sin_port); - buf_puts (&out, "[AF_INET]"); - - if (!(flags & PS_DONT_SHOW_ADDR)) - buf_printf (&out, "%s", (addr_defined (addr) ? inet_ntoa (addr->addr.in4.sin_addr) : "[undef]")); - - if (((flags & PS_SHOW_PORT) || (addr_defined (addr) && (flags & PS_SHOW_PORT_IF_DEFINED))) - && port) - { - if (separator) - buf_printf (&out, "%s", separator); - - buf_printf (&out, "%d", port); - } + struct buffer out = alloc_buf_gc (128, gc); + bool addr_is_defined; + char buf[NI_MAXHOST] = ""; + + addr_is_defined = addr_defined (addr); + if (!addr_is_defined) { + return "[undef]"; } - break; - case AF_INET6: - { - const int port= ntohs (addr->addr.in6.sin6_port); - char buf[INET6_ADDRSTRLEN] = ""; - buf_puts (&out, "[AF_INET6]"); - if (addr_is_defined) - { - getnameinfo(&addr->addr.sa, sizeof (struct sockaddr_in6), - buf, sizeof (buf), NULL, 0, NI_NUMERICHOST); - buf_puts (&out, buf); - } - if (((flags & PS_SHOW_PORT) || (addr_is_defined && (flags & PS_SHOW_PORT_IF_DEFINED))) - && port) - { - if (separator) - buf_puts (&out, separator); - - buf_printf (&out, "%d", port); - } - } - break; - default: - ASSERT(0); - } - return BSTR (&out); + + int port; + switch(addr->addr.sa.sa_family) + { + case AF_INET: + port= ntohs (addr->addr.in4.sin_port); + buf_puts (&out, "[AF_INET]"); + break; + case AF_INET6: + port= ntohs (addr->addr.in6.sin6_port); + buf_puts (&out, "[AF_INET6]"); + break; + default: + ASSERT(0); + } + + if (!(flags & PS_DONT_SHOW_ADDR)) + { + getnameinfo(&addr->addr.sa, sizeof (struct sockaddr_in6), + buf, sizeof (buf), NULL, 0, NI_NUMERICHOST); + buf_puts (&out, buf); + } + if (((flags & PS_SHOW_PORT) || (addr_is_defined && (flags & PS_SHOW_PORT_IF_DEFINED))) + && port) + { + if (separator) + buf_puts (&out, separator); + + buf_printf (&out, "%d", port); + } + + return BSTR (&out); } const char * -- 1.7.9.6 (Apple Git-31.1) |