mirror of
https://github.com/ChronosX88/netsukuku.git
synced 2024-11-22 10:12:18 +00:00
Massive experimental work done on implementing ntk netsplit as defined in the rfc http://netsukuku.freaknet.org/docs/main_doc/ntk_rfc/Ntk_net_split
This commit is contained in:
parent
dd2e7d5649
commit
09826bb34a
10
src/andns.c
10
src/andns.c
@ -104,6 +104,8 @@ store_ns(char *ns)
|
||||
|
||||
ai = &_andns_ns_[_andns_ns_count_];
|
||||
res = getaddrinfo(ns, DNS_PORT_STR, &_ns_filter_, ai);
|
||||
printf("store_ns getaddrinfo nameserver: %s "
|
||||
"res: %i: %s",ns ,res, gai_strerror(errno));
|
||||
if (res) {
|
||||
debug(DBG_NORMAL, "In store_ns(): gai `%s' -> %s", ns,
|
||||
gai_strerror(errno));
|
||||
@ -195,8 +197,8 @@ andns_init(int restricted, char *resolv_conf, int family)
|
||||
setzero(_andns_ns_, sizeof(struct addrinfo *) * MAXNSSERVERS);
|
||||
|
||||
memset(msg, 0, (INET_ADDRSTRLEN + 2) * MAXNSSERVERS);
|
||||
|
||||
if (_default_realm_ == NTK_REALM) {
|
||||
|
||||
if (_default_realm_ == NTK_REALM) {
|
||||
/* We are in NTK realm, every IP is assigned to Netsukuku,
|
||||
* therefore dns forwarding is meaningless */
|
||||
loginfo("We are in the ntk realm %s\n", strerror(errno));
|
||||
@ -663,7 +665,7 @@ dns_forward(dns_pkt * dp, char *msg, int msglen, char *answer)
|
||||
int res;
|
||||
|
||||
if (!_dns_forwarding_) {
|
||||
error("In rslv: dns forwardind is disable.");
|
||||
error("In rslv: dns forwarding is disabled.");
|
||||
goto safe_failing;
|
||||
}
|
||||
debug(DBG_INSANE, "Forwarding dns query to inet nameservers...");
|
||||
@ -937,7 +939,7 @@ nk_forward(andns_pkt * ap, char *msg, int msglen, char *answer)
|
||||
*
|
||||
* Returns:
|
||||
* NULL if the pkt has to be discarded.
|
||||
* A ptr to the answer to be sended if OK:
|
||||
* A ptr to the answer to be sent if OK:
|
||||
* in this case, answ_len is filled with
|
||||
* the answer len.
|
||||
*/
|
||||
|
@ -555,7 +555,7 @@ d_as_u(char *start_buf, char *buf, dns_pkt_a ** dpa, int limit_len,
|
||||
* Returns:
|
||||
* -1 on E_INTRPRT
|
||||
* 0 if pkt must be discarded.
|
||||
* Number of bytes readed otherwise
|
||||
* Number of bytes read otherwise
|
||||
*/
|
||||
int
|
||||
d_u(char *buf, int pktlen, dns_pkt ** dpp)
|
||||
|
58
src/getaddrinfodnstest.c
Normal file
58
src/getaddrinfodnstest.c
Normal file
@ -0,0 +1,58 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h> /* getaddrinfo, getnameinfo */
|
||||
#include <stdio.h> /* fprintf, printf */
|
||||
#include <stdlib.h> /* exit */
|
||||
#include <string.h> /* memset */
|
||||
|
||||
int
|
||||
getaddrinfodnsresolution(char *domain)
|
||||
{
|
||||
struct addrinfo hints, *res, *res0;
|
||||
int error;
|
||||
char host[NI_MAXHOST];
|
||||
|
||||
/*
|
||||
* Request only one socket type from getaddrinfo(). Else we
|
||||
* would get both SOCK_DGRAM and SOCK_STREAM, and print two
|
||||
* copies of each numeric address.
|
||||
*/
|
||||
memset(&hints, 0, sizeof hints);
|
||||
hints.ai_family = PF_UNSPEC; /* IPv4, IPv6, or anything */
|
||||
hints.ai_socktype = SOCK_DGRAM; /* Dummy socket type */
|
||||
|
||||
/*
|
||||
* Use getaddrinfo() to resolve "www.kame.net" and allocate
|
||||
* a linked list of addresses.
|
||||
*/
|
||||
error = getaddrinfo(domain, NULL, &hints, &res0);
|
||||
if (error) {
|
||||
fprintf(stderr, "%s\n", gai_strerror(error));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Iterate the linked list. */
|
||||
for (res = res0; res; res = res->ai_next) {
|
||||
/*
|
||||
* Use getnameinfo() to convert res->ai_addr to a
|
||||
* printable string.
|
||||
*
|
||||
* NI_NUMERICHOST means to present the numeric address
|
||||
* without doing reverse DNS to get a domain name.
|
||||
*/
|
||||
error = getnameinfo(res->ai_addr, res->ai_addrlen,
|
||||
host, sizeof host, NULL, 0, NI_NUMERICHOST);
|
||||
|
||||
if (error) {
|
||||
fprintf(stderr, "%s\n", gai_strerror(error));
|
||||
} else {
|
||||
/* Print the numeric address. */
|
||||
printf("%s\n", host);
|
||||
}
|
||||
}
|
||||
|
||||
/* Free the linked list. */
|
||||
freeaddrinfo(res0);
|
||||
|
||||
return 0;
|
||||
}
|
@ -179,8 +179,9 @@ usage(void)
|
||||
" -h Shows this help\n"
|
||||
" -v Shows the version you are using\n"
|
||||
" -k Kills the running instance of ntkd\n"
|
||||
" -C Runs the console server for Ntk-Console to connect to\n"
|
||||
" -e Excludes an interface from usage I.E all interfaces except this one\n");
|
||||
" -C Runs the console server for Ntk-Console to connect to\n"
|
||||
" -e Excludes an interface from usage I.E all interfaces except this one\n"
|
||||
" -n Experimental, Currently meaningless argument\n to implement ntk netsplit\n http://netsukuku.freaknet.org/docs/main_doc/ntk_rfc/Ntk_net_split\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -425,6 +426,7 @@ parse_options(int argc, char **argv)
|
||||
{"kill", 0, 0, 'k'},
|
||||
{"exclude", 1, 0, 'e'},
|
||||
{"console", 0, 0, 'C'},
|
||||
{"netsplit", 1, 0, 'n'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@ -434,6 +436,9 @@ parse_options(int argc, char **argv)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
case 'n':
|
||||
|
||||
break;
|
||||
case 'C':
|
||||
ntk_thread_creatation();
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user