Skip to content

Commit

Permalink
fixed compilation with modern systems, warnings removed, minor TCP bu…
Browse files Browse the repository at this point in the history
…g fixed with practially no real world effects.
  • Loading branch information
antirez committed Dec 5, 2010
1 parent 071893d commit ed951b8
Show file tree
Hide file tree
Showing 17 changed files with 170 additions and 111 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
.depend
*.o
yaku-ns
getzone
2 changes: 1 addition & 1 deletion assert.h
Expand Up @@ -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(); \
Expand Down
24 changes: 12 additions & 12 deletions axfr_out.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions cache.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
42 changes: 21 additions & 21 deletions config.c
Expand Up @@ -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);
}
Expand All @@ -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);
}

Expand All @@ -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;
}

Expand All @@ -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);
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit ed951b8

Please sign in to comment.