summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3b92b82)
raw | patch | inline | side by side (parent: 3b92b82)
author | Florian Forster <octo@verplant.org> | |
Sat, 3 Jun 2006 08:33:47 +0000 (10:33 +0200) | ||
committer | Florian Forster <octo@verplant.org> | |
Sat, 3 Jun 2006 08:33:47 +0000 (10:33 +0200) |
This will follow PTR records. `www.verplant.org' is changed to `verplant.org',
for example. It's not what I intended (I wanted a reverse lookup of
IP-addresses), but still better than what we had originally. I don't know if
I'll leave it like this. Might be though..
for example. It's not what I intended (I wanted a reverse lookup of
IP-addresses), but still better than what we had originally. I don't know if
I'll leave it like this. Might be though..
src/liboping.c | patch | blob | history |
diff --git a/src/liboping.c b/src/liboping.c
index debd432fd7f7793d7345858094c575aad0997c01..6131107a03509c320168e0c36d9cffd0edcc2fff 100644 (file)
--- a/src/liboping.c
+++ b/src/liboping.c
ai_hints.ai_flags = 0;
#ifdef AI_ADDRCONFIG
ai_hints.ai_flags |= AI_ADDRCONFIG;
+#endif
+#ifdef AI_CANONNAME
+ ai_hints.ai_flags |= AI_CANONNAME;
#endif
ai_hints.ai_family = obj->addrfamily;
ai_hints.ai_socktype = SOCK_RAW;
ph->addrlen = ai_ptr->ai_addrlen;
ph->addrfamily = ai_ptr->ai_family;
+#ifdef AI_CANONNAME
+ if ((ai_ptr->ai_canonname != NULL)
+ && (strcmp (ph->hostname, ai_ptr->ai_canonname) != 0))
+ {
+ char *old_hostname;
+
+ dprintf ("ph->hostname = %s; ai_ptr->ai_canonname = %s;\n",
+ ph->hostname, ai_ptr->ai_canonname);
+
+ old_hostname = ph->hostname;
+ if ((ph->hostname = strdup (ai_ptr->ai_canonname)) == NULL)
+ {
+ /* strdup failed, falling back to old hostname */
+ ph->hostname = old_hostname;
+ }
+ else if (old_hostname != NULL)
+ {
+ free (old_hostname);
+ }
+ }
+#endif /* AI_CANONNAME */
+
break;
}