mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-23 16:20:26 -05:00
Listen to both 4 and 6.
git-svn-id: file:///svn/unbound/trunk@57 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
e8a3ab8b2f
commit
bfe5459835
4 changed files with 53 additions and 19 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
- Created udp4 and udp6 port arrays to provide service for both
|
- Created udp4 and udp6 port arrays to provide service for both
|
||||||
address families.
|
address families.
|
||||||
- uses IPV6_USE_MIN_MTU for udp6 ,IPV6_V6ONLY to make ip6 sockets.
|
- 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
|
1 February 2007: Wouter
|
||||||
- outside network more UDP work.
|
- outside network more UDP work.
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "services/listen_dnsport.h"
|
#include "services/listen_dnsport.h"
|
||||||
|
#include "services/outside_network.h"
|
||||||
#include "util/netevent.h"
|
#include "util/netevent.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
|
|
@ -69,11 +70,11 @@ verbose_print_addr(struct addrinfo *addr)
|
||||||
(socklen_t)sizeof(buf)) == 0) {
|
(socklen_t)sizeof(buf)) == 0) {
|
||||||
strncpy(buf, "(null)", sizeof(buf));
|
strncpy(buf, "(null)", sizeof(buf));
|
||||||
}
|
}
|
||||||
verbose(VERB_ALGO, "creating %s %s socket %s %d",
|
verbose(VERB_ALGO, "creating %s%s socket %s %d",
|
||||||
addr->ai_family==AF_INET?"inet":
|
|
||||||
addr->ai_family==AF_INET6?"inet6":"otherfamily",
|
|
||||||
addr->ai_socktype==SOCK_DGRAM?"udp":
|
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,
|
buf,
|
||||||
ntohs(((struct sockaddr_in*)addr->ai_addr)->sin_port));
|
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) {
|
if(!do_ip4 && !do_ip6) {
|
||||||
listen_delete(front);
|
listen_delete(front);
|
||||||
return NULL;
|
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(num_ifs == 0) {
|
||||||
if(!listen_create_if(NULL, front, base, port,
|
if(do_ip6) {
|
||||||
do_udp, do_tcp, &hints, bufsize, cb, cb_arg)) {
|
hints.ai_family = AF_INET6;
|
||||||
listen_delete(front);
|
if(!listen_create_if(NULL, front, base, port,
|
||||||
return NULL;
|
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++) {
|
} else for(i = 0; i<num_ifs; i++) {
|
||||||
if(!listen_create_if(ifs[i], front, base, port,
|
if(str_is_ip6(ifs[i])) {
|
||||||
do_udp, do_tcp, &hints, bufsize, cb, cb_arg)) {
|
if(!do_ip6)
|
||||||
listen_delete(front);
|
continue;
|
||||||
return NULL;
|
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;
|
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. */
|
/** 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, ':'))
|
if(strchr(str, ':'))
|
||||||
return 1;
|
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);
|
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 */
|
#endif /* OUTSIDE_NETWORK_H */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue