(util_localname): return FQDN
Showing
1 changed file
with
14 additions
and
0 deletions
... | @@ -858,6 +858,7 @@ util_localname () | ... | @@ -858,6 +858,7 @@ util_localname () |
858 | char *name; | 858 | char *name; |
859 | int name_len = 256; | 859 | int name_len = 256; |
860 | int status; | 860 | int status; |
861 | struct hostent *hp; | ||
861 | 862 | ||
862 | name = malloc (name_len); | 863 | name = malloc (name_len); |
863 | while (name | 864 | while (name |
... | @@ -873,6 +874,19 @@ util_localname () | ... | @@ -873,6 +874,19 @@ util_localname () |
873 | exit (1); | 874 | exit (1); |
874 | } | 875 | } |
875 | 876 | ||
877 | hp = gethostbyname (name); | ||
878 | if (hp) | ||
879 | { | ||
880 | struct in_addr inaddr; | ||
881 | inaddr.s_addr = *(unsigned int*)hp->h_addr; | ||
882 | hp = gethostbyaddr ((const char *)&inaddr, | ||
883 | sizeof (struct in_addr), AF_INET); | ||
884 | if (hp) | ||
885 | { | ||
886 | free (name); | ||
887 | name = strdup ((char *)hp->h_name); | ||
888 | } | ||
889 | } | ||
876 | localname = name; | 890 | localname = name; |
877 | } | 891 | } |
878 | return localname; | 892 | return localname; | ... | ... |
-
Please register or sign in to post a comment