Permalink
Browse files

fixed compilation with modern systems, warnings removed, minor TCP bu…

…g fixed with practially no real world effects.
  • Loading branch information...
1 parent 071893d commit ed951b83e09e4652cf153f2b649d47e805fa855d @antirez committed Dec 5, 2010
Showing with 170 additions and 111 deletions.
  1. +4 −0 .gitignore
  2. +1 −1 assert.h
  3. +12 −12 axfr_out.c
  4. +2 −2 cache.c
  5. +21 −21 config.c
  6. +45 −44 core.c
  7. +6 −5 dns.c
  8. +2 −2 ens.h
  9. +2 −2 forward.c
  10. +1 −1 getzone.c
  11. +10 −10 local.c
  12. +2 −2 log.c
  13. +1 −1 misc.c
  14. +2 −2 nameser.h
  15. +4 −4 signal.c
  16. +2 −2 utils.h
  17. +53 −0 yakuendian.h
View
@@ -0,0 +1,4 @@
+.depend
+*.o
+yaku-ns
+getzone
View
@@ -21,7 +21,7 @@
#define assert(x) \
do { \
if ((x) == 0) { \
- log(VERB_FORCE, \
+ ylog(VERB_FORCE, \
"assert failed: %s is false in %s at line %d\n", \
#x, __FILE__, __LINE__); \
abort(); \
View
@@ -75,7 +75,6 @@
#include <string.h>
#include <stdlib.h>
#include <signal.h>
-#include <wait.h>
#define AXFR_CLIENT_MAX 50
#define AXFR_CLIENT_TIMEOUT 120 /* At least 2 min, see RFC1034 */
@@ -132,7 +131,7 @@ int axfr_init(void)
} else {
struct in_addr tmp;
if (inet_aton(bindaddr, &tmp) == 0) {
- log(VERB_FORCE, "[axfr_init] bad IP address "
+ ylog(VERB_FORCE, "[axfr_init] bad IP address "
"for binding\n");
exit(1);
}
@@ -184,10 +183,11 @@ void tcp_handler(void)
{
HEADER *hdr;
byte tmp[2];
- byte request[512]; /* even under TCP we limit to 512 bytes */
+ char request[512]; /* even under TCP we limit to 512 bytes */
byte *data; /* points after the DNS header */
int data_size; /* data size left */
- int new, addrlen; /* the new socket fd and the accept addrlen */
+ socklen_t addrlen;
+ int new; /* new socket fd */
int query_count; /* question sections in the query */
unsigned int size; /* query size */
int retval, n_read;
@@ -213,14 +213,14 @@ void tcp_handler(void)
/* Check the ACL */
if (acl_check_axfr(straddr) == ACL_DENY) {
- log(VERB_MED, "AXFR: access denied to client %s-%d\n",
+ ylog(VERB_MED, "AXFR: access denied to client %s-%d\n",
straddr, ntohs(newsa.sin_port));
goto out;
}
/* Max number of clients reached? */
if (axfr_clients >= AXFR_CLIENT_MAX) {
- log(VERB_MED, "AXFR: too many AXFR clients, "
+ ylog(VERB_MED, "AXFR: too many AXFR clients, "
"access denied to %s-%d\n",
straddr, ntohs(newsa.sin_port));
goto out;
@@ -268,14 +268,14 @@ void tcp_handler(void)
hdr->opcode != 0)
goto child_out;
data_size = size;
- data = request + sizeof(HEADER);
+ data = (unsigned char*)request + sizeof(HEADER);
query_count = ntohs(hdr->qdcount);
if (query_count != 1)
goto child_out;
/* parse the query */
- retval = name_decode(data, data_size, request,
- &name, 1);
+ retval = name_decode(data, data_size,
+ (unsigned char*)request, &name, 1);
if (name == NULL)
goto child_out;
updatep(retval);
@@ -288,19 +288,19 @@ void tcp_handler(void)
/* The only two accepted requests under TCP are
* IN/AXFR and IN/SOA */
if (qclass == C_IN && qtype == T_AXFR) {
- log(VERB_LOW, "AXFR requested for (%s) from "
+ ylog(VERB_LOW, "AXFR requested for (%s) from "
"%s-%d\n", name, straddr,
ntohs(newsa.sin_port));
send_zone(hdr, request+sizeof(HEADER), retval+4,
name, new);
} else if (qclass == C_IN && qtype == T_SOA) {
- log(VERB_MED, "TCP IN SOA requested for (%s) from "
+ ylog(VERB_MED, "TCP IN SOA requested for (%s) from "
"%s-%d\n", name, straddr,
ntohs(newsa.sin_port));
send_soa(hdr, request+sizeof(HEADER), retval+4,
name, new);
} else {
- log(VERB_MED, "TCP unaccepted request (%s %s) "
+ ylog(VERB_MED, "TCP unaccepted request (%s %s) "
"from %s-%d\n",
qclass_to_str(qclass),
qtype_to_str(qtype),
View
@@ -187,7 +187,7 @@ int cache_free_expired(void)
}
current = ht_value(&cache_table, index);
if (current->creat_timestamp + current->ttl <= (unsigned)now) {
- log(VERB_HIG, "Expired cache entry %s %s %s\n",
+ ylog(VERB_HIG, "Expired cache entry %s %s %s\n",
qtype_to_str(current->qtype),
qclass_to_str(current->qclass),
current->name);
@@ -217,7 +217,7 @@ struct cacheentry *cache_search_entry(char *name, int qclass, int qtype)
/* Expired? Free the entry and return NULL */
if (opt_cachenoexpire == 0 &&
cache->creat_timestamp + cache->ttl <= (unsigned)now) {
- log(VERB_HIG, "Expired cache entry %s %s %s\n",
+ ylog(VERB_HIG, "Expired cache entry %s %s %s\n",
qtype_to_str(cache->qtype),
qclass_to_str(cache->qclass),
cache->name);
View
@@ -145,10 +145,10 @@ int config_read(char *filename)
} else {
fp = fopen(filename, "r");
if (fp == NULL) {
- log(VERB_FORCE, "Can't open the config file %s\n",
+ ylog(VERB_FORCE, "Can't open the config file %s\n",
filename);
perror("fopen");
- log(VERB_FORCE, "Remember that you MUST "
+ ylog(VERB_FORCE, "Remember that you MUST "
"specify the absolute path\n");
exit(1);
}
@@ -170,8 +170,8 @@ int config_read(char *filename)
static void config_error(int linenum, char *line, char *errormsg)
{
- log(VERB_FORCE, "--\n`%s' at line %d\n", errormsg, linenum);
- log(VERB_FORCE, "%d: %s--\n", linenum, line);
+ ylog(VERB_FORCE, "--\n`%s' at line %d\n", errormsg, linenum);
+ ylog(VERB_FORCE, "%d: %s--\n", linenum, line);
exit(1);
}
@@ -190,9 +190,9 @@ static int op_include(int argc, char **argv)
if (securelevel >= 1)
return CERROR_PERM;
- log(VERB_HIG, "> include %s\n", argv[1]);
+ ylog(VERB_HIG, "> include %s\n", argv[1]);
config_read(argv[1]);
- log(VERB_HIG, "< end of inclusion of %s\n", argv[1]);
+ ylog(VERB_HIG, "< end of inclusion of %s\n", argv[1]);
return CERROR_SUCCESS;
}
@@ -206,7 +206,7 @@ static int op_forwarder(int argc, char **argv)
&forward_server[forward_server_count]) == 0)
return CERROR_BADIP;
opt_forward = 1;
- log(VERB_HIG, "(forwarding) external server: %s\n", argv[1]);
+ ylog(VERB_HIG, "(forwarding) external server: %s\n", argv[1]);
forward_server_count++;
/* accept responses from this external server */
acl_add_rule(argv[1], &acl_dns_allow_head, &acl_dns_allow_tail);
@@ -221,9 +221,9 @@ static int op_forward_max(int argc, char **argv)
if (forward_max <= 0) {
forward_max = 0;
opt_forward = 0;
- log(VERB_MED, "forwarding disabled\n");
+ ylog(VERB_MED, "forwarding disabled\n");
} else {
- log(VERB_HIG, "forwarding: max queue %d\n", forward_max);
+ ylog(VERB_HIG, "forwarding: max queue %d\n", forward_max);
}
return CERROR_SUCCESS;
}
@@ -236,7 +236,7 @@ static int op_forward_entry_timeout(int argc, char **argv)
if (forward_timeout <= 0) {
return CERROR_INVALID;
} else {
- log(VERB_HIG, "forwarding: entry timeout %d\n", forward_timeout);
+ ylog(VERB_HIG, "forwarding: entry timeout %d\n", forward_timeout);
}
return CERROR_SUCCESS;
}
@@ -249,7 +249,7 @@ static int op_forward_next_timeout(int argc, char **argv)
if (next_server_timeout < 0) {
return CERROR_INVALID;
} else {
- log(VERB_HIG, "forwarding: next server timeout %d\n",
+ ylog(VERB_HIG, "forwarding: next server timeout %d\n",
next_server_timeout);
}
return CERROR_SUCCESS;
@@ -263,9 +263,9 @@ static int op_cache_max(int argc, char **argv)
if (cache_max <= 0) {
cache_max = 0;
opt_cache = 0;
- log(VERB_MED, "cache: disabled\n");
+ ylog(VERB_MED, "cache: disabled\n");
} else {
- log(VERB_HIG, "cache: max size %d\n", cache_max);
+ ylog(VERB_HIG, "cache: max size %d\n", cache_max);
}
return CERROR_SUCCESS;
}
@@ -275,7 +275,7 @@ static int op_cache_minttl(int argc, char **argv)
ARG_UNUSED(argc)
cache_minttl = atoi(argv[1]);
- log(VERB_HIG, "cache: min TTL %d\n", cache_minttl);
+ ylog(VERB_HIG, "cache: min TTL %d\n", cache_minttl);
return CERROR_SUCCESS;
}
@@ -284,7 +284,7 @@ static int op_cache_maxttl(int argc, char **argv)
ARG_UNUSED(argc)
cache_maxttl = atoi(argv[1]);
- log(VERB_HIG, "cache: max TTL %d\n", cache_maxttl);
+ ylog(VERB_HIG, "cache: max TTL %d\n", cache_maxttl);
return CERROR_SUCCESS;
}
@@ -326,7 +326,7 @@ static int op_ttl(int argc, char **argv)
ARG_UNUSED(argc)
local_ttl = atoi(argv[1]);
- log(VERB_HIG, "> Time To Live is %u\n", local_ttl);
+ ylog(VERB_HIG, "> Time To Live is %u\n", local_ttl);
return CERROR_SUCCESS;
}
@@ -335,7 +335,7 @@ static int op_tcp_requests_for_connection(int argc, char **argv)
ARG_UNUSED(argc)
opt_tcp_requests_for_connection = atoi(argv[1]);
- log(VERB_HIG, "TCP requests for connection set to %d\n",
+ ylog(VERB_HIG, "TCP requests for connection set to %d\n",
opt_tcp_requests_for_connection);
return CERROR_SUCCESS;
}
@@ -346,13 +346,13 @@ static int op_class(int argc, char **argv)
if (!strcasecmp(argv[1], "IN")) {
local_class = C_IN;
- log(VERB_HIG, "> Class is IN\n");
+ ylog(VERB_HIG, "> Class is IN\n");
} else if (!strcasecmp(argv[1], "CHAOS")) {
local_class = C_CHAOS;
- log(VERB_HIG, "> Class is CHAOS\n");
+ ylog(VERB_HIG, "> Class is CHAOS\n");
} else if (!strcasecmp(argv[1], "ANY")) {
local_class = C_ANY;
- log(VERB_HIG, "> Class is ANY\n");
+ ylog(VERB_HIG, "> Class is ANY\n");
} else {
return CERROR_INVALID;
}
@@ -396,7 +396,7 @@ static int op_acl(int argc, char **argv)
return CERROR_BADACL;
}
acl_add_rule(argv[j], head, tail);
- log(VERB_HIG, "acl: loaded %s %s\n", argv[1], argv[j]);
+ ylog(VERB_HIG, "acl: loaded %s %s\n", argv[1], argv[j]);
}
return CERROR_SUCCESS;
}
Oops, something went wrong.

0 comments on commit ed951b8

Please sign in to comment.