X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=networking%2Fdnsd.c;h=37a80309d760e049333e7029504c67b2ad4a8e71;hb=ed4393bdc7a4d3b1b59293a3393eb1d6953bac99;hp=c76a54f9e53fd7d79dc879e2e0cc01b5b8693c3e;hpb=0ecc11659285337c0430f1b7004eb3b2901a93d3;p=oweals%2Fbusybox.git diff --git a/networking/dnsd.c b/networking/dnsd.c index c76a54f9e..37a80309d 100644 --- a/networking/dnsd.c +++ b/networking/dnsd.c @@ -6,7 +6,7 @@ * Copyright (C) 2005 Odd Arild Olsen (oao at fibula dot no) * Copyright (C) 2003 Paul Sheer * - * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + * Licensed under GPLv2 or later, see file LICENSE in this source tree. * * Odd Arild Olsen started out with the sheerdns [1] of Paul Sheer and rewrote * it into a shape which I believe is both easier to understand and maintain. @@ -16,6 +16,30 @@ * Some bugfix and minor changes was applied by Roberto A. Foglietta who made * the first porting of oao' scdns to busybox also. */ +//config:config DNSD +//config: bool "dnsd (9.8 kb)" +//config: default y +//config: help +//config: Small and static DNS server daemon. + +//applet:IF_DNSD(APPLET(dnsd, BB_DIR_USR_SBIN, BB_SUID_DROP)) + +//kbuild:lib-$(CONFIG_DNSD) += dnsd.o + +//usage:#define dnsd_trivial_usage +//usage: "[-dvs] [-c CONFFILE] [-t TTL_SEC] [-p PORT] [-i ADDR]" +//usage:#define dnsd_full_usage "\n\n" +//usage: "Small static DNS server daemon\n" +//usage: "\n -c FILE Config file" +//usage: "\n -t SEC TTL" +//usage: "\n -p PORT Listen on PORT" +//usage: "\n -i ADDR Listen on ADDR" +//usage: "\n -d Daemonize" +//usage: "\n -v Verbose" +//usage: "\n -s Send successful replies only. Use this if you want" +//usage: "\n to use /etc/resolv.conf with two nameserver lines:" +//usage: "\n nameserver DNSD_SERVER" +//usage: "\n nameserver NORMAL_DNS_SERVER" #include "libbb.h" #include @@ -44,10 +68,15 @@ struct dns_head { uint16_t nauth; uint16_t nadd; }; +/* Structure used to access type and class fields. + * They are totally unaligned, but gcc 4.3.4 thinks that pointer of type uint16_t* + * is 16-bit aligned and replaces 16-bit memcpy (in move_from_unaligned16 macro) + * with aligned halfword access on arm920t! + * Oh well. Slapping PACKED everywhere seems to help: */ struct type_and_class { - uint16_t type; - uint16_t class; -}; + uint16_t type PACKED; + uint16_t class PACKED; +} PACKED; /* element of known name, ip address and reversed ip address */ struct dns_entry { struct dns_entry *next; @@ -174,7 +203,7 @@ static char *table_lookup(struct dns_entry *d, if ((len != 1 || d->name[1] != '*') /* we assume (do not check) that query_string * ends in ".in-addr.arpa" */ - && strncmp(d->rip, query_string, strlen(d->rip)) == 0 + && is_prefixed_with(query_string, d->rip) ) { #if DEBUG fprintf(stderr, "Found name:%s\n", d->name); @@ -331,7 +360,7 @@ RDATA a variable length string of octets that describes the resource. In order to reduce the size of messages, domain names coan be compressed. An entire domain name or a list of labels at the end of a domain name -is replaced with a pointer to a prior occurance of the same name. +is replaced with a pointer to a prior occurrence of the same name. The pointer takes the form of a two octet sequence: +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ @@ -383,7 +412,7 @@ static int process_packet(struct dns_entry *conf_data, query_len = strlen(query_string) + 1; /* may be unaligned! */ unaligned_type_class = (void *)(query_string + query_len); - query_len += sizeof(unaligned_type_class); + query_len += sizeof(*unaligned_type_class); /* where to append answer block */ answb = (void *)(unaligned_type_class + 1);