comparison dbutil.c @ 160:7ceceb46d655

Fix so that getnameinfo() is passed the address-specific structure size. This lets it work on Solaris (and probably other platforms)
author Matt Johnston <matt@ucc.asn.au>
date Sun, 02 Jan 2005 12:04:45 +0000
parents 82fcf3185616
children b9d3f725e00b
comparison
equal deleted inserted replaced
159:4bd4fc8023bd 160:7ceceb46d655
355 char *retstring = NULL; 355 char *retstring = NULL;
356 int ret; 356 int ret;
357 unsigned int len; 357 unsigned int len;
358 358
359 len = sizeof(struct sockaddr_storage); 359 len = sizeof(struct sockaddr_storage);
360 /* Some platforms such as Solaris 8 require that len is the length
361 * of the specific structure. */
362 if (addr->ss_family == AF_INET) {
363 len = sizeof(struct sockaddr_in);
364 }
365 #ifdef AF_INET6
366 if (addr->ss_family == AF_INET6) {
367 len = sizeof(struct sockaddr_in6);
368 }
369 #endif
360 370
361 ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf), 371 ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf),
362 sbuf, sizeof(sbuf), NI_NUMERICSERV | NI_NUMERICHOST); 372 sbuf, sizeof(sbuf), NI_NUMERICSERV | NI_NUMERICHOST);
363 373
364 if (ret != 0) { 374 if (ret != 0) {
387 char sbuf[NI_MAXSERV]; 397 char sbuf[NI_MAXSERV];
388 int ret; 398 int ret;
389 unsigned int len; 399 unsigned int len;
390 400
391 len = sizeof(struct sockaddr_storage); 401 len = sizeof(struct sockaddr_storage);
402 /* Some platforms such as Solaris 8 require that len is the length
403 * of the specific structure. */
404 if (addr->ss_family == AF_INET) {
405 len = sizeof(struct sockaddr_in);
406 }
407 #ifdef AF_INET6
408 if (addr->ss_family == AF_INET6) {
409 len = sizeof(struct sockaddr_in6);
410 }
411 #endif
392 412
393 ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf), 413 ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf),
394 sbuf, sizeof(sbuf), NI_NUMERICSERV); 414 sbuf, sizeof(sbuf), NI_NUMERICSERV);
395 415
396 if (ret != 0) { 416 if (ret != 0) {