Changeset 1620
- Timestamp:
- 05/25/10 22:26:23 (3 years ago)
- Location:
- trunk/pdns/pdns
- Files:
-
- 4 modified
-
iputils.hh (modified) (2 diffs)
-
misc.cc (modified) (1 diff)
-
misc.hh (modified) (1 diff)
-
pdns_recursor.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/iputils.hh
r1472 r1620 116 116 if(!IpToU32(str, (uint32_t*)&sin4.sin_addr.s_addr)) { 117 117 sin6.sin6_family = AF_INET6; 118 if( Utility::inet_pton(AF_INET6, str.c_str(), &sin6.sin6_addr) <=0)118 if(makeIPv6sockaddr(str, &sin6) < 0) 119 119 throw AhuException("Unable to convert presentation address '"+ str +"'"); 120 120 } … … 187 187 if(Utility::inet_pton(AF_INET, str.c_str(), &address.sin4.sin_addr) <= 0) { 188 188 address.sin4.sin_family=AF_INET6; 189 if( Utility::inet_pton(AF_INET6, str.c_str(), &address.sin6.sin6_addr) <=0)189 if(makeIPv6sockaddr(str, &address.sin6) < 0) 190 190 throw NetmaskException("Unable to convert '"+str+"' to a netmask"); 191 191 } -
trunk/pdns/pdns/misc.cc
r1605 r1620 666 666 return a+"."+b; 667 667 } 668 669 int makeIPv6sockaddr(const std::string& addr, struct sockaddr_in6* ret) 670 { 671 struct addrinfo* res; 672 struct addrinfo hints; 673 memset(&hints, 0, sizeof(hints)); 674 675 hints.ai_family = AF_INET6; 676 hints.ai_flags = AI_NUMERICHOST; 677 678 if(getaddrinfo(addr.c_str(), 0, &hints, &res) < 0) { 679 perror("getaddrinfo"); 680 return -1; 681 } 682 683 memcpy(ret, res->ai_addr, sizeof(*ret)); 684 685 freeaddrinfo(res); 686 return 0; 687 } -
trunk/pdns/pdns/misc.hh
r1605 r1620 384 384 string labelReverse(const std::string& qname); 385 385 std::string dotConcat(const std::string& a, const std::string &b); 386 386 int makeIPv6sockaddr(const std::string& addr, struct sockaddr_in6* ret); 387 387 #endif -
trunk/pdns/pdns/pdns_recursor.cc
r1559 r1620 904 904 if(!IpToU32(st.host, (uint32_t*)&sin.sin4.sin_addr.s_addr)) { 905 905 sin.sin6.sin6_family = AF_INET6; 906 if( Utility::inet_pton(AF_INET6, st.host.c_str(), &sin.sin6.sin6_addr) <=0)906 if(makeIPv6sockaddr(st.host, &sin.sin6) < 0) 907 907 throw AhuException("Unable to resolve local address for TCP server on '"+ st.host +"'"); 908 908 } … … 968 968 if(!IpToU32(st.host.c_str() , (uint32_t*)&sin.sin4.sin_addr.s_addr)) { 969 969 sin.sin6.sin6_family = AF_INET6; 970 if( Utility::inet_pton(AF_INET6, st.host.c_str(), &sin.sin6.sin6_addr) <=0)970 if(makeIPv6sockaddr(st.host, &sin.sin6) < 0) 971 971 throw AhuException("Unable to resolve local address for UDP server on '"+ st.host +"'"); 972 972 }