/[svn]/hopm/branches/1.0.x/src/firedns.c
ViewVC logotype

Diff of /hopm/branches/1.0.x/src/firedns.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5170 by michael, Fri Dec 26 18:53:10 2014 UTC revision 5171 by michael, Fri Dec 26 20:53:32 2014 UTC
# Line 26  Foundation, Inc., 59 Temple Place, Suite Line 26  Foundation, Inc., 59 Temple Place, Suite
26  #include <time.h>  #include <time.h>
27  #include <sys/types.h>  #include <sys/types.h>
28  #include <sys/socket.h>  #include <sys/socket.h>
 #include <netdb.h>  
29  #include <sys/poll.h>  #include <sys/poll.h>
30  #include <sys/time.h>  #include <sys/time.h>
31  #include <netinet/in.h>  #include <netinet/in.h>
# Line 205  void firedns_init(void) Line 204  void firedns_init(void)
204              /* glibc /etc/resolv.conf seems to allow ipv6 server names */              /* glibc /etc/resolv.conf seems to allow ipv6 server names */
205              if (i6 < FDNS_MAX)              if (i6 < FDNS_MAX)
206              {              {
207                 if (inet_pton6(&buf[i], (char *)&addr6) != NULL)                 if (inet_pton(AF_INET6, &buf[i], &addr6) > 0)
208                 {                 {
209                    memcpy(&servers6[i6++],&addr6,sizeof(struct in6_addr));                    memcpy(&servers6[i6++],&addr6,sizeof(struct in6_addr));
210                    continue;                    continue;
# Line 214  void firedns_init(void) Line 213  void firedns_init(void)
213  #endif  #endif
214              if (i4 < FDNS_MAX)              if (i4 < FDNS_MAX)
215              {              {
216                struct addrinfo hints, *res;                if (inet_pton(AF_INET, &buf[i], &addr4) > 0)
217                    memcpy(&servers4[i4++],&addr4,sizeof(struct in_addr));
               memset(&hints, 0, sizeof(hints));  
               hints.ai_family   = AF_INET;  
               hints.ai_socktype = SOCK_STREAM;  
               hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;  
   
               if (!getaddrinfo(&buf[i], NULL, &hints, &res))  
               {  
                 memcpy(&servers4[i4++], &((struct sockaddr_in *)res->ai_addr)->sin_addr, sizeof(struct in_addr));  
                 freeaddrinfo(res);  
               }  
218             }             }
219           }           }
220        }        }
# Line 239  void firedns_init(void) Line 228  void firedns_init(void)
228  #ifdef IPV6  #ifdef IPV6
229           if (i6 < FDNS_MAX)           if (i6 < FDNS_MAX)
230           {           {
231              if (inet_pton(AF_INET6, buf, (char *)&addr6))              if (inet_pton(AF_INET6, buf, &addr6) > 0)
232              {              {
233                 memcpy(&servers6[i6++], &addr6, sizeof(struct in6_addr));                 memcpy(&servers6[i6++], &addr6, sizeof(struct in6_addr));
234                 continue;                 continue;
# Line 248  void firedns_init(void) Line 237  void firedns_init(void)
237  #endif  #endif
238           if (i4 < FDNS_MAX)           if (i4 < FDNS_MAX)
239           {           {
240                struct addrinfo hints, *res;                if (inet_pton(AF_INET, buf, &addr4) > 0)
241                    memcpy(&servers4[i4++],&addr4,sizeof(struct in_addr));
               memset(&hints, 0, sizeof(hints));  
               hints.ai_family   = AF_INET;  
               hints.ai_socktype = SOCK_STREAM;  
               hints.ai_flags    = AI_PASSIVE | AI_NUMERICHOST;  
   
               if (!getaddrinfo(&buf[i], NULL, &hints, &res))  
               {  
                 memcpy(&servers4[i4++], &((struct sockaddr_in *)res->ai_addr)->sin_addr, sizeof(struct in_addr));  
                 freeaddrinfo(res);  
               }  
242           }           }
243        }        }
244     }     }
# Line 280  struct in_addr *firedns_resolveip4(const Line 259  struct in_addr *firedns_resolveip4(const
259  { /* immediate A query */  { /* immediate A query */
260     static struct in_addr addr;     static struct in_addr addr;
261    
262     if(inet_aton(name, &addr))     if (inet_pton(AF_INET, name, &addr) > 0)
263        return &addr;        return &addr;
264        
265     return (struct in_addr *) firedns_resolveip(FDNS_QRY_A, name);     return (struct in_addr *) firedns_resolveip(FDNS_QRY_A, name);

Legend:
Removed from v.5170  
changed lines
  Added in v.5171

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.26