Fix so that getnameinfo() is passed the address-specific structure size. This

lets it work on Solaris (and probably other platforms)

--HG--
extra : convert_revision : b486b773f163af8462b0ef6565ac4285a54708eb
This commit is contained in:
Matt Johnston 2005-01-02 12:04:45 +00:00
parent 6d75298284
commit e6c957caaa

View File

@ -357,6 +357,16 @@ unsigned char * getaddrstring(struct sockaddr_storage* addr, int withport) {
unsigned int len;
len = sizeof(struct sockaddr_storage);
/* Some platforms such as Solaris 8 require that len is the length
* of the specific structure. */
if (addr->ss_family == AF_INET) {
len = sizeof(struct sockaddr_in);
}
#ifdef AF_INET6
if (addr->ss_family == AF_INET6) {
len = sizeof(struct sockaddr_in6);
}
#endif
ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf),
sbuf, sizeof(sbuf), NI_NUMERICSERV | NI_NUMERICHOST);
@ -389,6 +399,16 @@ char* getaddrhostname(struct sockaddr_storage * addr) {
unsigned int len;
len = sizeof(struct sockaddr_storage);
/* Some platforms such as Solaris 8 require that len is the length
* of the specific structure. */
if (addr->ss_family == AF_INET) {
len = sizeof(struct sockaddr_in);
}
#ifdef AF_INET6
if (addr->ss_family == AF_INET6) {
len = sizeof(struct sockaddr_in6);
}
#endif
ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf),
sbuf, sizeof(sbuf), NI_NUMERICSERV);