comparison dbutil.c @ 335:e17f0333c21e

Another stab at getting ss_family happy on older glibc
author Matt Johnston <matt@ucc.asn.au>
date Mon, 12 Jun 2006 15:57:14 +0000
parents 044bc108b9b3
children ed24dfc44904 9e2ad1023978
comparison
equal deleted inserted replaced
334:8f3ec7c104d9 335:e17f0333c21e
398 int ret; 398 int ret;
399 unsigned int len; 399 unsigned int len;
400 400
401 len = sizeof(struct sockaddr_storage); 401 len = sizeof(struct sockaddr_storage);
402 /* Some platforms such as Solaris 8 require that len is the length 402 /* Some platforms such as Solaris 8 require that len is the length
403 * of the specific structure. */ 403 * of the specific structure. Some older linux systems (glibc 2.1.3
404 * such as debian potato) have sockaddr_storage.__ss_family instead
405 * but we'll ignore them */
406 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY
404 if (addr->ss_family == AF_INET) { 407 if (addr->ss_family == AF_INET) {
405 len = sizeof(struct sockaddr_in); 408 len = sizeof(struct sockaddr_in);
406 } 409 }
407 #ifdef AF_INET6 410 #ifdef AF_INET6
408 if (addr->ss_family == AF_INET6) { 411 if (addr->ss_family == AF_INET6) {
409 len = sizeof(struct sockaddr_in6); 412 len = sizeof(struct sockaddr_in6);
410 } 413 }
414 #endif
411 #endif 415 #endif
412 416
413 ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf), 417 ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf),
414 sbuf, sizeof(sbuf), NI_NUMERICSERV | NI_NUMERICHOST); 418 sbuf, sizeof(sbuf), NI_NUMERICSERV | NI_NUMERICHOST);
415 419
446 #endif 450 #endif
447 451
448 len = sizeof(struct sockaddr_storage); 452 len = sizeof(struct sockaddr_storage);
449 /* Some platforms such as Solaris 8 require that len is the length 453 /* Some platforms such as Solaris 8 require that len is the length
450 * of the specific structure. */ 454 * of the specific structure. */
455 #ifdef HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY
451 if (addr->ss_family == AF_INET) { 456 if (addr->ss_family == AF_INET) {
452 len = sizeof(struct sockaddr_in); 457 len = sizeof(struct sockaddr_in);
453 } 458 }
454 #ifdef AF_INET6 459 #ifdef AF_INET6
455 if (addr->ss_family == AF_INET6) { 460 if (addr->ss_family == AF_INET6) {
456 len = sizeof(struct sockaddr_in6); 461 len = sizeof(struct sockaddr_in6);
457 } 462 }
463 #endif
458 #endif 464 #endif
459 465
460 466
461 ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf), 467 ret = getnameinfo((struct sockaddr*)addr, len, hbuf, sizeof(hbuf),
462 sbuf, sizeof(sbuf), flags); 468 sbuf, sizeof(sbuf), flags);