Listen to both 4 and 6.
git-svn-id: https://unbound.nlnetlabs.nl/svn/trunk@57 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
b495764c09
commit
d7e39e8e3b
@ -2,6 +2,7 @@
|
||||
- Created udp4 and udp6 port arrays to provide service for both
|
||||
address families.
|
||||
- uses IPV6_USE_MIN_MTU for udp6 ,IPV6_V6ONLY to make ip6 sockets.
|
||||
- listens on both ip4 and ip6 ports to provide correct return address.
|
||||
|
||||
1 February 2007: Wouter
|
||||
- outside network more UDP work.
|
||||
|
@ -40,6 +40,7 @@
|
||||
*/
|
||||
|
||||
#include "services/listen_dnsport.h"
|
||||
#include "services/outside_network.h"
|
||||
#include "util/netevent.h"
|
||||
#include "util/log.h"
|
||||
|
||||
@ -69,11 +70,11 @@ verbose_print_addr(struct addrinfo *addr)
|
||||
(socklen_t)sizeof(buf)) == 0) {
|
||||
strncpy(buf, "(null)", sizeof(buf));
|
||||
}
|
||||
verbose(VERB_ALGO, "creating %s %s socket %s %d",
|
||||
addr->ai_family==AF_INET?"inet":
|
||||
addr->ai_family==AF_INET6?"inet6":"otherfamily",
|
||||
verbose(VERB_ALGO, "creating %s%s socket %s %d",
|
||||
addr->ai_socktype==SOCK_DGRAM?"udp":
|
||||
addr->ai_socktype==SOCK_STREAM?"tcp":"otherprotocol",
|
||||
addr->ai_socktype==SOCK_STREAM?"tcp":"otherproto",
|
||||
addr->ai_family==AF_INET?"4":
|
||||
addr->ai_family==AF_INET6?"6":"_otherfam",
|
||||
buf,
|
||||
ntohs(((struct sockaddr_in*)addr->ai_addr)->sin_port));
|
||||
}
|
||||
@ -313,27 +314,52 @@ listen_create(struct comm_base* base, int num_ifs, const char* ifs[],
|
||||
if(!do_ip4 && !do_ip6) {
|
||||
listen_delete(front);
|
||||
return NULL;
|
||||
} else if(do_ip4 && do_ip6)
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
else if(do_ip4)
|
||||
hints.ai_family = AF_INET;
|
||||
else if(do_ip6) {
|
||||
hints.ai_family = AF_INET6;
|
||||
}
|
||||
|
||||
/* create ip4 and ip6 ports so that return addresses are nice. */
|
||||
if(num_ifs == 0) {
|
||||
if(!listen_create_if(NULL, front, base, port,
|
||||
do_udp, do_tcp, &hints, bufsize, cb, cb_arg)) {
|
||||
listen_delete(front);
|
||||
return NULL;
|
||||
if(do_ip6) {
|
||||
hints.ai_family = AF_INET6;
|
||||
if(!listen_create_if(NULL, front, base, port,
|
||||
do_udp, do_tcp, &hints, bufsize, cb, cb_arg)) {
|
||||
listen_delete(front);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if(do_ip4) {
|
||||
hints.ai_family = AF_INET;
|
||||
if(!listen_create_if(NULL, front, base, port,
|
||||
do_udp, do_tcp, &hints, bufsize, cb, cb_arg)) {
|
||||
listen_delete(front);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
} else for(i = 0; i<num_ifs; i++) {
|
||||
if(!listen_create_if(ifs[i], front, base, port,
|
||||
do_udp, do_tcp, &hints, bufsize, cb, cb_arg)) {
|
||||
listen_delete(front);
|
||||
return NULL;
|
||||
if(str_is_ip6(ifs[i])) {
|
||||
if(!do_ip6)
|
||||
continue;
|
||||
hints.ai_family = AF_INET6;
|
||||
if(!listen_create_if(ifs[i], front, base, port,
|
||||
do_udp, do_tcp, &hints, bufsize, cb, cb_arg)) {
|
||||
listen_delete(front);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
if(!do_ip4)
|
||||
continue;
|
||||
hints.ai_family = AF_INET;
|
||||
if(!listen_create_if(ifs[i], front, base, port,
|
||||
do_udp, do_tcp, &hints, bufsize, cb, cb_arg)) {
|
||||
listen_delete(front);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!front->cps) {
|
||||
log_err("Could not open sockets to accept queries.");
|
||||
listen_delete(front);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return front;
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ make_udp_range(struct comm_point** coms, const char* ifname,
|
||||
}
|
||||
|
||||
/** returns true is string addr is an ip6 specced address. */
|
||||
static int str_is_ip6(const char* str)
|
||||
int str_is_ip6(const char* str)
|
||||
{
|
||||
if(strchr(str, ':'))
|
||||
return 1;
|
||||
|
@ -141,4 +141,11 @@ void pending_udp_query(struct outside_network* outnet, ldns_buffer* packet,
|
||||
*/
|
||||
void pending_delete(struct outside_network* outnet, struct pending* p);
|
||||
|
||||
/**
|
||||
* See if string is ip4 or ip6.
|
||||
* @param str: IP specification.
|
||||
* @return: true is string addr is an ip6 specced address.
|
||||
*/
|
||||
int str_is_ip6(const char* str);
|
||||
|
||||
#endif /* OUTSIDE_NETWORK_H */
|
||||
|
Loading…
Reference in New Issue
Block a user