Module: kamailio Branch: master Commit: 22a72f3a7725d56f00e22bdc52d44bd53da7c091 URL: https://github.com/kamailio/kamailio/commit/22a72f3a7725d56f00e22bdc52d44bd5...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2021-08-13T08:57:10+02:00
core: ip addr - use POSIX INET6_ADDRSTRLEN and INET_ADDRSTRLEN to define sizes
- set the values of IP4_MAX_STR_SIZE and IP6_MAX_STR_SIZE based on them, if defined, or to 15 and 45 - cope with IPv6 with IPv4 tunneling representation (RFC 4291 section 2.2) - cover the requirements of using inet_ntop() - GH #2823
---
Modified: src/core/ip_addr.h
---
Diff: https://github.com/kamailio/kamailio/commit/22a72f3a7725d56f00e22bdc52d44bd5... Patch: https://github.com/kamailio/kamailio/commit/22a72f3a7725d56f00e22bdc52d44bd5...
---
diff --git a/src/core/ip_addr.h b/src/core/ip_addr.h index 546c822423..132f653255 100644 --- a/src/core/ip_addr.h +++ b/src/core/ip_addr.h @@ -510,8 +510,20 @@ int hostent2su(union sockaddr_union* su,
/* maximum size of a str returned by ip_addr2str */ -#define IP6_MAX_STR_SIZE 39 /*1234:5678:9012:3456:7890:1234:5678:9012*/ -#define IP4_MAX_STR_SIZE 15 /*123.456.789.012*/ +/* POSIX INET6_ADDRSTRLEN (RFC 4291 section 2.2) - IPv6 with IPv4 tunneling + * (39): 1234:5678:9012:3456:7890:1234:5678:9012 + * (45): ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255 */ +#ifdef INET6_ADDRSTRLEN +#define IP6_MAX_STR_SIZE (INET6_ADDRSTRLEN-1) +#else +#define IP6_MAX_STR_SIZE 45 +#endif +/*123.456.789.123*/ +#ifdef INET_ADDRSTRLEN +#define IP4_MAX_STR_SIZE (INET_ADDRSTRLEN-1) +#else +#define IP4_MAX_STR_SIZE 15 +#endif
/* converts a raw ipv6 addr (16 bytes) to ascii */ int ip6tosbuf(unsigned char* ip6, char* buff, int len);