Revision: 14610
Author: adrian.chadd
Date: Sat Apr 17 21:02:56 2010
Log: Issue #94 - properly generate stuff for getnameinfo()
http://code.google.com/p/lusca-cache/source/detail?r=14610
Modified:
/branches/LUSCA_HEAD/libcore/radix.c
=======================================
--- /branches/LUSCA_HEAD/libcore/radix.c Sun Apr 11 04:08:58 2010
+++ /branches/LUSCA_HEAD/libcore/radix.c Sat Apr 17 21:02:56 2010
@@ -693,7 +693,25 @@
const char *
prefix_addr_ntop(prefix_t *prefix, char *buf, size_t len)
{
- if (getnameinfo(&prefix->add, sizeof(prefix->add), NULL, 0, buf, len,
NI_NUMERICHOST) == 0)
+ struct sockaddr *s = NULL;
+ socklen_t sl;
+ struct sockaddr_in sin;
+ struct sockaddr_in6 sin6;
+
+ if (prefix->family == AF_INET) {
+ bzero(&sin, sizeof(sin));
+ memcpy(&sin.sin_addr, &prefix->add.sin, sizeof(sin.sin_addr));
+ s = (struct sockaddr *) &sin;
+ sl = sizeof(sin);
+ } else if (prefix->family == AF_INET6) {
+ bzero(&sin6, sizeof(sin6));
+ memcpy(&sin6.sin6_addr, &prefix->add.sin6,
sizeof(sin6.sin6_addr));
+ s = (struct sockaddr *) &sin6;
+ sl = sizeof(sin6);
+ } else
+ return NULL;
+
+ if (getnameinfo(s, sl, NULL, 0, buf, len, NI_NUMERICHOST) == 0)
return buf;
return NULL;
--
You received this message because you are subscribed to the Google Groups
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/lusca-commit?hl=en.