version 1.1, 2019/10/21 14:25:31
|
version 1.1.1.2, 2021/03/17 00:07:30
|
Line 11
|
Line 11
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
GNU General Public License for more details. |
GNU General Public License for more details. |
|
|
You should have received a copy of the GNU General Public License | You should have received a copy of the GNU General Public License along |
along with this program; if not, write to the Free Software | with this program; if not, write to the Free Software Foundation, Inc., |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
*/ |
*/ |
|
|
/* |
/* |
Line 41
|
Line 41
|
#include "dns.h" |
#include "dns.h" |
#include "net.h" |
#include "net.h" |
#include "utils.h" |
#include "utils.h" |
|
#include "packet/sockaddr.h" |
|
|
struct dns_results { |
struct dns_results { |
ip_t ip; |
ip_t ip; |
Line 105 static struct dns_results *findip(
|
Line 106 static struct dns_results *findip(
|
struct dns_results *t; |
struct dns_results *t; |
|
|
for (t = results; t; t = t->next) { |
for (t = results; t; t = t->next) { |
if (addrcmp((void *) ip, (void *) &t->ip, ctl->af) == 0) | if (addrcmp(ip, &t->ip, ctl->af) == 0) |
return t; |
return t; |
} |
} |
|
|
Line 117 static void set_sockaddr_ip(
|
Line 118 static void set_sockaddr_ip(
|
struct sockaddr_storage *sa, |
struct sockaddr_storage *sa, |
ip_t * ip) |
ip_t * ip) |
{ |
{ |
struct sockaddr_in *sa_in; |
|
struct sockaddr_in6 *sa_in6; |
|
|
|
memset(sa, 0, sizeof(struct sockaddr_storage)); |
memset(sa, 0, sizeof(struct sockaddr_storage)); |
switch (ctl->af) { | sa->ss_family = ctl->af; |
case AF_INET: | memcpy(sockaddr_addr_offset(sa), ip, sockaddr_addr_size(sa)); |
sa_in = (struct sockaddr_in *) sa; | |
sa_in->sin_family = ctl->af; | |
addrcpy((void *) &sa_in->sin_addr, (void *) ip, ctl->af); | |
break; | |
case AF_INET6: | |
sa_in6 = (struct sockaddr_in6 *) sa; | |
sa_in6->sin6_family = ctl->af; | |
addrcpy((void *) &sa_in6->sin6_addr, (void *) ip, ctl->af); | |
break; | |
} | |
} |
} |
|
|
void dns_open( |
void dns_open( |
Line 162 void dns_open(
|
Line 150 void dns_open(
|
error(EXIT_FAILURE, errno, "signal"); |
error(EXIT_FAILURE, errno, "signal"); |
} |
} |
|
|
/* Close all unneccessary FDs. | /* Close all unnecessary FDs. |
for debugging and error reporting, keep std-in/out/err. */ |
for debugging and error reporting, keep std-in/out/err. */ |
for (i = 3; i < fromdns[1]; i++) { |
for (i = 3; i < fromdns[1]; i++) { |
if (i == todns[0]) |
if (i == todns[0]) |
Line 276 char *dns_lookup2(
|
Line 264 char *dns_lookup2(
|
/* we've got a result. */ |
/* we've got a result. */ |
if (r->name) |
if (r->name) |
return r->name; |
return r->name; |
else |
|
return strlongip(ctl, ip); |
|
} else { |
} else { |
r = xmalloc(sizeof(struct dns_results)); |
r = xmalloc(sizeof(struct dns_results)); |
memcpy(&r->ip, ip, sizeof(r->ip)); |
memcpy(&r->ip, ip, sizeof(r->ip)); |
Line 289 char *dns_lookup2(
|
Line 275 char *dns_lookup2(
|
if (rv < 0) |
if (rv < 0) |
error(0, errno, "couldn't write to resolver process"); |
error(0, errno, "couldn't write to resolver process"); |
} |
} |
return strlongip(ctl, ip); | return NULL; |
} |
} |
|
|
|
|
Line 302 char *dns_lookup(
|
Line 288 char *dns_lookup(
|
if (!ctl->dns || !ctl->use_dns) |
if (!ctl->dns || !ctl->use_dns) |
return NULL; |
return NULL; |
t = dns_lookup2(ctl, ip); |
t = dns_lookup2(ctl, ip); |
return t; | return t ? t : strlongip(ctl, ip); |
} |
} |
|
|
/* XXX check if necessary/exported. */ |
/* XXX check if necessary/exported. */ |