Commit Diff
Diff:
9593fb7afc49f7cd62b580c39ed4415ae34557fa
1a591502e2b903b178997ed1871067fe50f6368c
Commit:
1a591502e2b903b178997ed1871067fe50f6368c
Tree:
f798e19cf3b7c32deaf5bee79e799c8ed30bff79
Author:
pbug <pbug@delphinusdns.org>
Committer:
pbug <pbug@delphinusdns.org>
Date:
Sun Mar 28 20:18:26 2010 UTC
Message:
* change struct domain to use pointers instead of having character arrays for every address. This saves memory and may speed things up a tad. Tested on OpenBSD, Ubuntu 64, FreeBSD 64
blob - b359f895ee6f2d559fd9419a307da98fe52a8a19
blob + 43fc25cf0edc3da1af49c2e0c50c965a5577bb0b
--- additional.c
+++ additional.c
@@ -36,7 +36,7 @@ int additional_ptr(char *, int, struct domain *, char
extern int compress_label(char *, int, int);
-static const char rcsid[] = "$Id: additional.c,v 1.7 2010/03/09 15:38:22 pbug Exp $";
+static const char rcsid[] = "$Id: additional.c,v 1.8 2010/03/28 20:18:26 pbug Exp $";
/*
@@ -190,7 +190,7 @@ additional_aaaa(char *name, int namelen, struct domain
answer->rdlength = htons(sizeof(struct in6_addr));
- memcpy((char *)&answer->rdata, (char *)&sd->aaaa[aaaa_count], sizeof(struct in6_addr));
+ memcpy((char *)&answer->rdata, (char *)sd->aaaa[aaaa_count], sizeof(struct in6_addr));
offset += sizeof(struct answer);
(*retcount)++;
@@ -223,7 +223,7 @@ additional_aaaa(char *name, int namelen, struct domain
answer->rdlength = htons(sizeof(struct in6_addr));
- memcpy((char *)&answer->rdata, (char *)&sd->aaaa[aaaa_count], sizeof(struct in6_addr));
+ memcpy((char *)&answer->rdata, (char *)sd->aaaa[aaaa_count], sizeof(struct in6_addr));
offset += sizeof(struct answer);
(*retcount)++;
}
@@ -288,25 +288,25 @@ additional_mx(char *name, int namelen, struct domain *
answer->type = htons(DNS_TYPE_MX);
answer->class = htons(DNS_CLASS_IN);
answer->ttl = htonl(sd->ttl);
- answer->mx_priority = htons(sd->mx[mx_count].preference);
+ answer->mx_priority = htons(sd->mx[mx_count]->preference);
offset += sizeof(struct answer);
- if ((offset + sd->mx[mx_count].exchangelen) > replylen) {
+ if ((offset + sd->mx[mx_count]->exchangelen) > replylen) {
offset = rroffset;
goto out;
}
- memcpy((char *)&reply[offset], (char *)&sd->mx[mx_count].exchange, sd->mx[mx_count].exchangelen);
+ memcpy((char *)&reply[offset], (char *)sd->mx[mx_count]->exchange, sd->mx[mx_count]->exchangelen);
- offset += sd->mx[mx_count].exchangelen;
- tmplen = compress_label(reply, offset, sd->mx[mx_count].exchangelen);
+ offset += sd->mx[mx_count]->exchangelen;
+ tmplen = compress_label(reply, offset, sd->mx[mx_count]->exchangelen);
if (tmplen != 0) {
- answer->rdlength = htons((sd->mx[mx_count].exchangelen - (offset - tmplen)) + sizeof(u_int16_t));
+ answer->rdlength = htons((sd->mx[mx_count]->exchangelen - (offset - tmplen)) + sizeof(u_int16_t));
offset = tmplen;
} else
- answer->rdlength = htons(sd->mx[mx_count].exchangelen + sizeof(u_int16_t));
+ answer->rdlength = htons(sd->mx[mx_count]->exchangelen + sizeof(u_int16_t));
(*retcount)++;
@@ -341,22 +341,22 @@ additional_mx(char *name, int namelen, struct domain *
offset += sizeof(struct answer);
- if ((offset + sd->mx[mx_count].exchangelen) > replylen) {
+ if ((offset + sd->mx[mx_count]->exchangelen) > replylen) {
offset = rroffset;
goto out;
}
- memcpy((char *)&reply[offset], (char *)&sd->mx[mx_count].exchange, sd->mx[mx_count].exchangelen);
+ memcpy((char *)&reply[offset], (char *)sd->mx[mx_count]->exchange, sd->mx[mx_count]->exchangelen);
- offset += sd->mx[mx_count].exchangelen;
- tmplen = compress_label(reply, offset, sd->mx[mx_count].exchangelen);
+ offset += sd->mx[mx_count]->exchangelen;
+ tmplen = compress_label(reply, offset, sd->mx[mx_count]->exchangelen);
if (tmplen != 0) {
- answer->rdlength = htons((sd->mx[mx_count].exchangelen - (offset - tmplen)) + sizeof(u_int16_t));
+ answer->rdlength = htons((sd->mx[mx_count]->exchangelen - (offset - tmplen)) + sizeof(u_int16_t));
offset = tmplen;
} else
- answer->rdlength = htons(sd->mx[mx_count].exchangelen + sizeof(u_int16_t));
+ answer->rdlength = htons(sd->mx[mx_count]->exchangelen + sizeof(u_int16_t));
(*retcount)++;
}
@@ -420,7 +420,7 @@ additional_ptr(char *name, int namelen, struct domain
goto out;
}
- memcpy((char *)&reply[offset], (char *)&sd->ptr, sd->ptrlen);
+ memcpy((char *)&reply[offset], (char *)sd->ptr, sd->ptrlen);
offset += sd->ptrlen;
tmplen = compress_label(reply, offset, sd->ptrlen);
blob - 87b13b17feaf3cc13cf2aedb5d02f00b9b5fea8d
blob + be9905a731cd75f0f93b62d8b852f4efd3b00a60
--- db.h
+++ db.h
@@ -51,18 +51,18 @@ struct soa {
struct smx {
u_int16_t preference; /* MX preference */
char exchange[DNS_MAXNAME]; /* name of exchange server */
- u_int8_t exchangelen; /* length of exchange server name */
+ int exchangelen; /* length of exchange server name */
} __attribute__((packed));
struct ns {
char nsserver[DNS_MAXNAME]; /* NS name */
- u_int8_t nslen; /* length of NS */
+ int nslen; /* length of NS */
} __attribute__((packed));
struct domain {
- char zone[DNS_MAXNAME]; /* name of zone in dns name format */
+ char *zone; /* name of zone in dns name format */
int zonelen; /* length of zone, above */
- char zonename[DNS_MAXNAME + 1]; /* name of zone in human readable */
+ char *zonename; /* name of zone in human readable */
u_int16_t flags; /* flags of zone */
#define DOMAIN_HAVE_A 0x1
#define DOMAIN_HAVE_SOA 0x2
@@ -72,28 +72,28 @@ struct domain {
#define DOMAIN_HAVE_AAAA 0x20
#define DOMAIN_HAVE_NS 0x40
#define DOMAIN_HAVE_TXT 0x80
- struct soa soa; /* start of authority */
+ struct soa *soa; /* start of authority */
u_int32_t ttl; /* time to live */
in_addr_t a[10]; /* IP addresses */
u_int8_t region[10]; /* region of IP address */
int a_count; /* IP address count (max 10) */
int a_ptr; /* pointer to last used address */
- struct in6_addr aaaa[10]; /* IPv6 addresses */
+ struct in6_addr *aaaa[10]; /* IPv6 addresses */
int aaaa_count; /* IPv6 address count (max 10) */
int aaaa_ptr; /* pointer to last used IPv6 address */
- struct smx mx[10]; /* MX addresses */
+ struct smx *mx[10]; /* MX addresses */
int mx_count; /* MX address count, max 10 */
int mx_ptr; /* pointer to last used MX adddress */
- struct ns ns[10]; /* NS resource records (max 10) */
+ struct ns *ns[10]; /* NS resource records (max 10) */
int ns_count; /* count of NS records, (max 10) */
int ns_ptr; /* pointer to last used NS address */
int ns_delegate; /* set if it's a delegation */
- char cname[DNS_MAXNAME]; /* CNAME RR */
- u_int8_t cnamelen; /* len of CNAME */
- char ptr[DNS_MAXNAME]; /* PTR RR */
- u_int8_t ptrlen; /* len of PTR */
- char txt[DNS_MAXNAME]; /* TXT string */
- u_int8_t txtlen; /* len of TXT */
+ char *cname; /* CNAME RR */
+ int cnamelen; /* len of CNAME */
+ char *ptr; /* PTR RR */
+ int ptrlen; /* len of PTR */
+ char *txt; /* TXT string */
+ int txtlen; /* len of TXT */
} __attribute__((packed));
struct sreply {
blob - cc032048119c78cfff3923d1349d3a0bf1e5c212
blob + 07ccec3ef117399180204c5f88f15b9a52ebbd80
--- example7.conf
+++ example7.conf
@@ -104,7 +104,7 @@ region "RIPE" {
; this should work because the higher the prefix the more
; precedence the region has, let's give it a shot.
;
-
+ ::/0;
0.0.0.0/0;
192.168.0.0/16;
147.102.0.0/16;
blob - 8d9a0c6f129fd6a80042f00de2b115cdace6bd5a
blob + 4f13e91ad5adf5bdda62e199bf8842378916462f
--- include.h
+++ include.h
@@ -55,6 +55,10 @@
#include <dirent.h>
#include <signal.h>
+#ifdef __linux__
+#include <grp.h>
+#endif
+
#ifndef NTOHS
#include "endian.h"
#endif
blob - 9cb0d377244ac6f1d7952acd840f5fd10cec0100
blob + 9b6458a41631c57ab446714ad0540f6dc0b8caa0
--- main.c
+++ main.c
@@ -104,7 +104,7 @@ struct tcps {
} *tn1, *tn2, *tnp;
-static const char rcsid[] = "$Id: main.c,v 1.47 2010/03/28 10:51:22 pbug Exp $";
+static const char rcsid[] = "$Id: main.c,v 1.48 2010/03/28 20:18:26 pbug Exp $";
/*
* MAIN - set up arguments, set up database, set up sockets, call mainloop
@@ -853,7 +853,7 @@ out:
*compressor |= 0xc000;
/* network byte order */
- NTOHS(*compressor);
+ HTONS(*compressor);
offset += sizeof(u_int16_t);
blob - 590f4750b73e164a4408f781e4c4765ed9882f90
blob + 52a0517a11cfcece55d19568ac920d31387a62b5
--- parse.c
+++ parse.c
@@ -74,7 +74,7 @@ struct cmd_lookup {
static u_int32_t config = 0;
-static const char rcsid[] = "$Id: parse.c,v 1.21 2010/03/28 09:48:29 pbug Exp $";
+static const char rcsid[] = "$Id: parse.c,v 1.22 2010/03/28 20:18:26 pbug Exp $";
/*
* PARSE_FILE - parse the configfile XXX rewrite me in yacc :(
@@ -370,12 +370,21 @@ parse_file(DB *db, char *file)
#endif
}
+ if (sdomain.zonename == NULL) {
+ sdomain.zonename = (char *) malloc(DNS_MAXNAME + 1);
+ if (sdomain.zonename == NULL) {
+ syslog(LOG_INFO, "malloc(1): %m");
+ fclose(f);
+ return (-1);
+ }
+ }
+
#if __linux__
- strncpy((char *)&sdomain.zonename[0], (char *)&domainname[0],
- sizeof(sdomain.zonename));
- sdomain.zonename[sizeof(sdomain.zonename) - 1] = 0;
+ strncpy((char *)sdomain.zonename, (char *)&domainname[0],
+ DNS_MAXNAME);
+ sdomain.zonename[DNS_MAXNAME] = 0;
#else
- strlcpy((char *)&sdomain.zonename[0], (char *)&domainname[0], sizeof(sdomain.zonename));
+ strlcpy((char *)sdomain.zonename, (char *)&domainname[0], DNS_MAXNAME + 1);
#endif
if (++p >= endline) {
@@ -514,7 +523,15 @@ parse_file(DB *db, char *file)
save = *p;
*p = 0;
if (sdomain.aaaa_count < 10) {
- ia6 = (struct in6_addr *) &sdomain.aaaa[sdomain.aaaa_count];
+ if (sdomain.aaaa[sdomain.aaaa_count] == NULL) {
+ sdomain.aaaa[sdomain.aaaa_count] = (struct in6_addr *)malloc(sizeof(struct in6_addr));
+ if (sdomain.aaaa[sdomain.aaaa_count] == NULL) {
+ syslog(LOG_INFO, "malloc(2): %m");
+ fclose(f);
+ return (-1);
+ }
+ }
+ ia6 = (struct in6_addr *)sdomain.aaaa[sdomain.aaaa_count];
sdomain.aaaa_count++;
} else {
fprintf(stderr, "too many aaaa records for zone \"%s\", skipping line %d\n", domainname, line);
@@ -548,8 +565,17 @@ parse_file(DB *db, char *file)
save = *p;
*p = 0;
+ if (sdomain.mx[sdomain.mx_count] == NULL) {
+ sdomain.mx[sdomain.mx_count] = (struct smx *)malloc(sizeof(struct smx));
+ if (sdomain.mx[sdomain.mx_count] == NULL) {
+ syslog(LOG_INFO, "malloc(3): %m");
+ fclose(f);
+ return (-1);
+ }
+ }
+
if (sdomain.mx_count < 10) {
- sdomain.mx[sdomain.mx_count].preference = atoi(starttoken);
+ sdomain.mx[sdomain.mx_count]->preference = atoi(starttoken);
} else {
fprintf(stderr, "too many mx records for zone \"%s\", skipping line %d\n", domainname, line);
break;
@@ -573,13 +599,13 @@ parse_file(DB *db, char *file)
char *name;
char *n;
- if ((name = dns_label(starttoken, (int *)&sdomain.mx[sdomain.mx_count].exchangelen)) == NULL) {
+ if ((name = dns_label(starttoken, (int *)&sdomain.mx[sdomain.mx_count]->exchangelen)) == NULL) {
fprintf(stderr, "illegal mx server, skipping line %d\n", line);
goto skip;
}
- n = (char *)sdomain.mx[sdomain.mx_count].exchange;
+ n = (char *)sdomain.mx[sdomain.mx_count]->exchange;
- memcpy((char *)n, name, sdomain.mx[sdomain.mx_count].exchangelen);
+ memcpy((char *)n, name, sdomain.mx[sdomain.mx_count]->exchangelen);
free (name);
}
@@ -600,15 +626,24 @@ parse_file(DB *db, char *file)
save = *p;
*p = 0;
+ if (sdomain.soa == NULL) {
+ sdomain.soa = (struct soa*)malloc(sizeof(struct soa));
+ if (sdomain.soa == NULL) {
+ syslog(LOG_INFO, "malloc(4): %m");
+ fclose(f);
+ return (-1);
+ }
+ }
+
{
char *name;
- if ((name = dns_label(starttoken, (int *)&sdomain.soa.nsserver_len)) == NULL) {
+ if ((name = dns_label(starttoken, (int *)&sdomain.soa->nsserver_len)) == NULL) {
fprintf(stderr, "illegal nameserver, skipping line %d\n", line);
goto skip;
}
- memcpy((char *)&sdomain.soa.nsserver[0], name, sdomain.soa.nsserver_len);
+ memcpy((char *)&sdomain.soa->nsserver[0], name, sdomain.soa->nsserver_len);
free (name);
}
@@ -636,12 +671,12 @@ parse_file(DB *db, char *file)
{
char *name;
- if ((name = dns_label(starttoken, (int *)&sdomain.soa.rp_len)) == NULL) {
+ if ((name = dns_label(starttoken, (int *)&sdomain.soa->rp_len)) == NULL) {
fprintf(stderr, "illegal nameserver, skipping line %d\n", line);
goto skip;
}
- memcpy((char *)&sdomain.soa.responsible_person[0], name, sdomain.soa.rp_len);
+ memcpy((char *)&sdomain.soa->responsible_person[0], name, sdomain.soa->rp_len);
free (name);
}
@@ -666,7 +701,7 @@ parse_file(DB *db, char *file)
save = *p;
*p = 0;
- sdomain.soa.serial = atoi(starttoken);
+ sdomain.soa->serial = atoi(starttoken);
*p = save;
@@ -689,7 +724,7 @@ parse_file(DB *db, char *file)
save = *p;
*p = 0;
- sdomain.soa.refresh = atoi(starttoken);
+ sdomain.soa->refresh = atoi(starttoken);
*p = save;
@@ -712,7 +747,7 @@ parse_file(DB *db, char *file)
save = *p;
*p = 0;
- sdomain.soa.retry = atoi(starttoken);
+ sdomain.soa->retry = atoi(starttoken);
*p = save;
@@ -735,7 +770,7 @@ parse_file(DB *db, char *file)
save = *p;
*p = 0;
- sdomain.soa.expire = atoi(starttoken);
+ sdomain.soa->expire = atoi(starttoken);
*p = save;
@@ -752,7 +787,7 @@ parse_file(DB *db, char *file)
save = *p;
*p = 0;
- sdomain.soa.minttl = atoi(starttoken);
+ sdomain.soa->minttl = atoi(starttoken);
*p = save;
sdomain.flags |= DOMAIN_HAVE_SOA;
@@ -763,6 +798,15 @@ parse_file(DB *db, char *file)
save = *p;
*p = 0;
+ if (sdomain.ptr == NULL) {
+ sdomain.ptr = (char *)malloc(DNS_MAXNAME);
+ if (sdomain.ptr == NULL) {
+ syslog(LOG_INFO, "malloc(5): %m");
+ fclose(f);
+ return (-1);
+ }
+ }
+
{
char *name;
@@ -786,17 +830,26 @@ parse_file(DB *db, char *file)
save = *p;
*p = 0;
+ if (sdomain.ns[sdomain.ns_count] == NULL) {
+ sdomain.ns[sdomain.ns_count] = (struct ns*)malloc(sizeof(struct ns));
+ if (sdomain.ns[sdomain.ns_count] == NULL) {
+ syslog(LOG_INFO, "malloc(6): %m");
+ fclose(f);
+ return (-1);
+ }
+ }
+
{
char *name;
char *n;
- if ((name = dns_label(starttoken, (int *)&sdomain.ns[sdomain.ns_count].nslen)) == NULL) {
+ if ((name = dns_label(starttoken, &(sdomain.ns[sdomain.ns_count]->nslen))) == NULL) {
fprintf(stderr, "illegal mx server, skipping line %d\n", line);
goto skip;
}
- n = (char *)sdomain.ns[sdomain.ns_count].nsserver;
+ n = (char *)sdomain.ns[sdomain.ns_count]->nsserver;
- memcpy((char *)n, name, sdomain.ns[sdomain.ns_count].nslen);
+ memcpy((char *)n, name, sdomain.ns[sdomain.ns_count]->nslen);
free (name);
}
@@ -820,6 +873,15 @@ parse_file(DB *db, char *file)
save = *p;
*p = 0;
+ if (sdomain.cname == NULL) {
+ sdomain.cname = (char *)malloc(DNS_MAXNAME);
+ if (sdomain.cname == NULL) {
+ syslog(LOG_INFO, "malloc(7): %m");
+ fclose(f);
+ return (-1);
+ }
+ }
+
{
char *name;
@@ -828,7 +890,7 @@ parse_file(DB *db, char *file)
goto skip;
}
- memcpy((char *)&sdomain.cname[0], name, sdomain.cnamelen);
+ memcpy((char *)sdomain.cname, name, sdomain.cnamelen);
free (name);
}
@@ -860,7 +922,16 @@ parse_file(DB *db, char *file)
* let's remember to put that in reply_txt()
*/
- memcpy(&sdomain.txt, starttoken, tokenlen);
+ if (sdomain.txt == NULL) {
+ sdomain.txt = (char *)malloc(DNS_MAXNAME);
+ if (sdomain.txt == NULL) {
+ syslog(LOG_INFO, "malloc(7): %m");
+ fclose(f);
+ return (-1);
+ }
+ }
+
+ memcpy(sdomain.txt, starttoken, tokenlen);
sdomain.txtlen = tokenlen;
*p = save;
@@ -879,6 +950,15 @@ parse_file(DB *db, char *file)
key.data = (char *)converted_name;
key.size = converted_namelen;
+
+ if (sdomain.zone == NULL) {
+ sdomain.zone = (char *)malloc(DNS_MAXNAME);
+ if (sdomain.zone == NULL) {
+ syslog(LOG_INFO, "malloc(X): %m");
+ fclose(f);
+ return (-1);
+ }
+ }
memcpy(sdomain.zone, converted_name, converted_namelen);
sdomain.zonelen = converted_namelen;
blob - ea81b3ce5f9773f1f6aac61e4029afce5cc6aa16
blob + f86de02b0dd340cbf6d7106de51b6de5a76d08e3
--- reply.c
+++ reply.c
@@ -67,7 +67,7 @@ struct collects {
} *cn1, *cn2, *cnp;
-static const char rcsid[] = "$Id: reply.c,v 1.19 2010/03/27 15:40:10 pbug Exp $";
+static const char rcsid[] = "$Id: reply.c,v 1.20 2010/03/28 20:18:26 pbug Exp $";
/*
* REPLY_A() - replies a DNS question (*q) on socket (so)
@@ -315,7 +315,7 @@ reply_aaaa(struct sreply *sreply, DB *db)
answer->rdlength = htons(sizeof(struct in6_addr));
- memcpy((char *)&answer->rdata, (char *)&sd->aaaa[pos++ % mod], sizeof(struct in6_addr));
+ memcpy((char *)&answer->rdata, (char *)sd->aaaa[pos++ % mod], sizeof(struct in6_addr));
outlen += 28;
/* can we afford to write another header? if no truncate */
@@ -427,13 +427,13 @@ reply_mx(struct sreply *sreply, DB *db)
answer->class = q->hdr->qclass;
answer->ttl = htonl(sd->ttl);
- answer->rdlength = htons(sizeof(u_int16_t) + sd->mx[mx_count].exchangelen);
+ answer->rdlength = htons(sizeof(u_int16_t) + sd->mx[mx_count]->exchangelen);
- answer->mx_priority = htons(sd->mx[mx_count].preference);
- memcpy((char *)&answer->exchange, (char *)&sd->mx[mx_count].exchange, sd->mx[mx_count].exchangelen);
+ answer->mx_priority = htons(sd->mx[mx_count]->preference);
+ memcpy((char *)&answer->exchange, (char *)sd->mx[mx_count]->exchange, sd->mx[mx_count]->exchangelen);
- name = sd->mx[mx_count].exchange;
- namelen = sd->mx[mx_count].exchangelen;
+ name = sd->mx[mx_count]->exchange;
+ namelen = sd->mx[mx_count]->exchangelen;
sd0 = Lookup_zone(db, name, namelen, htons(DNS_TYPE_A));
if (sd0 != NULL) {
@@ -466,10 +466,10 @@ reply_mx(struct sreply *sreply, DB *db)
}
}
- outlen += (12 + 2 + sd->mx[mx_count].exchangelen);
+ outlen += (12 + 2 + sd->mx[mx_count]->exchangelen);
/* can we afford to write another header? if no truncate */
- if (sd->mx_count > 1 && (outlen + 12 + 2 + sd->mx[mx_count].exchangelen) > DNS_MAXUDP) {
+ if (sd->mx_count > 1 && (outlen + 12 + 2 + sd->mx[mx_count]->exchangelen) > DNS_MAXUDP) {
NTOHS(odh->query);
SET_DNS_TRUNCATION(odh);
HTONS(odh->query);
@@ -628,8 +628,8 @@ reply_ns(struct sreply *sreply, DB *db)
answer->class = q->hdr->qclass;
answer->ttl = htonl(sd->ttl);
- name = sd->ns[pos % mod].nsserver;
- namelen = sd->ns[pos % mod].nslen;
+ name = sd->ns[pos % mod]->nsserver;
+ namelen = sd->ns[pos % mod]->nslen;
answer->rdlength = htons(namelen);
@@ -673,7 +673,7 @@ reply_ns(struct sreply *sreply, DB *db)
/* can we afford to write another header? if no truncate */
- if (sd->ns_count > 1 && (outlen + 12 + sd->ns[pos % mod].nslen) > DNS_MAXUDP) {
+ if (sd->ns_count > 1 && (outlen + 12 + sd->ns[pos % mod]->nslen) > DNS_MAXUDP) {
NTOHS(odh->query);
SET_DNS_TRUNCATION(odh);
HTONS(odh->query);
@@ -1093,15 +1093,8 @@ reply_soa(struct sreply *sreply)
struct domain *sd = sreply->sd1;
int istcp = sreply->istcp;
-#if 0
- struct soa mysoa = { "neptune.solarsail.org.", "pbug.neptune.solarsail.org", 1, 3600, 1800, (14 * 24 * 3600), 0xffffffff };
+ /* st */
-#endif
-
-#if 0
- memset(&reply, 0, sizeof(reply));
-#endif
-
odh = (struct dns_header *)&reply[0];
outlen = sizeof(struct dns_header);
@@ -1140,13 +1133,13 @@ reply_soa(struct sreply *sreply)
p = (char *)&answer->rdata;
#if 0
- label = dns_label((char *)mysoa.nsserver, &labellen);
+ label = dns_label((char *)mysoa->nsserver, &labellen);
if (label == NULL)
return;
#endif
- label = &sd->soa.nsserver[0];
- labellen = sd->soa.nsserver_len;
+ label = sd->soa->nsserver;
+ labellen = sd->soa->nsserver_len;
plabel = label;
@@ -1169,8 +1162,8 @@ reply_soa(struct sreply *sreply)
outlen = tmplen;
}
- label = &sd->soa.responsible_person[0];
- labellen = sd->soa.rp_len;
+ label = sd->soa->responsible_person;
+ labellen = sd->soa->rp_len;
plabel = label;
for (i = outlen; i < sizeof(reply); i++) {
@@ -1193,41 +1186,43 @@ reply_soa(struct sreply *sreply)
}
- if ((outlen + sizeof(sd->soa.serial)) > sizeof(reply)) {
+ /* XXX */
+ if ((outlen + sizeof(sd->soa->serial)) > sizeof(reply)) {
/* XXX server error reply? */
return;
}
soa_val = (u_int32_t *)&reply[outlen];
- *soa_val = htonl(sd->soa.serial);
- outlen += sizeof(sd->soa.serial);
+ *soa_val = htonl(sd->soa->serial);
+ outlen += sizeof(sd->soa->serial); /* XXX */
- if ((outlen + sizeof(sd->soa.refresh)) > sizeof(reply)) {
+ /* XXX */
+ if ((outlen + sizeof(sd->soa->refresh)) > sizeof(reply)) {
return;
}
soa_val = (u_int32_t *)&reply[outlen];
- *soa_val = htonl(sd->soa.refresh);
- outlen += sizeof(sd->soa.refresh);
+ *soa_val = htonl(sd->soa->refresh);
+ outlen += sizeof(sd->soa->refresh); /* XXX */
- if ((outlen + sizeof(sd->soa.retry)) > sizeof(reply)) {
+ if ((outlen + sizeof(sd->soa->retry)) > sizeof(reply)) {
return;
}
soa_val = (u_int32_t *)&reply[outlen];
- *soa_val = htonl(sd->soa.retry);
- outlen += sizeof(sd->soa.retry);
+ *soa_val = htonl(sd->soa->retry);
+ outlen += sizeof(sd->soa->retry); /* XXX */
- if ((outlen + sizeof(sd->soa.expire)) > sizeof(reply)) {
+ if ((outlen + sizeof(sd->soa->expire)) > sizeof(reply)) {
return;
}
soa_val = (u_int32_t *)&reply[outlen];
- *soa_val = htonl(sd->soa.expire);
- outlen += sizeof(sd->soa.expire);
+ *soa_val = htonl(sd->soa->expire);
+ outlen += sizeof(sd->soa->expire);
- if ((outlen + sizeof(sd->soa.minttl)) > sizeof(reply)) {
+ if ((outlen + sizeof(sd->soa->minttl)) > sizeof(reply)) {
return;
}
soa_val = (u_int32_t *)&reply[outlen];
- *soa_val = htonl(sd->soa.minttl);
- outlen += sizeof(sd->soa.minttl);
+ *soa_val = htonl(sd->soa->minttl);
+ outlen += sizeof(sd->soa->minttl);
answer->rdlength = htons(&reply[outlen] - &answer->rdata);
@@ -1552,13 +1547,13 @@ reply_nxdomain(struct sreply *sreply)
p = (char *)&answer->rdata;
#if 0
- label = dns_label((char *)mysoa.nsserver, &labellen);
+ label = dns_label((char *)mysoa->nsserver, &labellen);
if (label == NULL)
return;
#endif
- label = &sd->soa.nsserver[0];
- labellen = sd->soa.nsserver_len;
+ label = sd->soa->nsserver;
+ labellen = sd->soa->nsserver_len;
plabel = label;
@@ -1581,8 +1576,8 @@ reply_nxdomain(struct sreply *sreply)
outlen = tmplen;
}
- label = &sd->soa.responsible_person[0];
- labellen = sd->soa.rp_len;
+ label = sd->soa->responsible_person;
+ labellen = sd->soa->rp_len;
plabel = label;
for (i = outlen; i < sizeof(reply); i++) {
@@ -1605,41 +1600,42 @@ reply_nxdomain(struct sreply *sreply)
}
- if ((outlen + sizeof(sd->soa.serial)) > sizeof(reply)) {
+ /* XXX */
+ if ((outlen + sizeof(sd->soa->serial)) > sizeof(reply)) {
/* XXX server error reply? */
return;
}
soa_val = (u_int32_t *)&reply[outlen];
- *soa_val = htonl(sd->soa.serial);
- outlen += sizeof(sd->soa.serial);
+ *soa_val = htonl(sd->soa->serial);
+ outlen += sizeof(sd->soa->serial);
- if ((outlen + sizeof(sd->soa.refresh)) > sizeof(reply)) {
+ if ((outlen + sizeof(sd->soa->refresh)) > sizeof(reply)) {
return;
}
soa_val = (u_int32_t *)&reply[outlen];
- *soa_val = htonl(sd->soa.refresh);
- outlen += sizeof(sd->soa.refresh);
+ *soa_val = htonl(sd->soa->refresh);
+ outlen += sizeof(sd->soa->refresh);
- if ((outlen + sizeof(sd->soa.retry)) > sizeof(reply)) {
+ if ((outlen + sizeof(sd->soa->retry)) > sizeof(reply)) {
return;
}
soa_val = (u_int32_t *)&reply[outlen];
- *soa_val = htonl(sd->soa.retry);
- outlen += sizeof(sd->soa.retry);
+ *soa_val = htonl(sd->soa->retry);
+ outlen += sizeof(sd->soa->retry);
- if ((outlen + sizeof(sd->soa.expire)) > sizeof(reply)) {
+ if ((outlen + sizeof(sd->soa->expire)) > sizeof(reply)) {
return;
}
soa_val = (u_int32_t *)&reply[outlen];
- *soa_val = htonl(sd->soa.expire);
- outlen += sizeof(sd->soa.expire);
+ *soa_val = htonl(sd->soa->expire);
+ outlen += sizeof(sd->soa->expire);
- if ((outlen + sizeof(sd->soa.minttl)) > sizeof(reply)) {
+ if ((outlen + sizeof(sd->soa->minttl)) > sizeof(reply)) {
return;
}
soa_val = (u_int32_t *)&reply[outlen];
- *soa_val = htonl(sd->soa.minttl);
- outlen += sizeof(sd->soa.minttl);
+ *soa_val = htonl(sd->soa->minttl);
+ outlen += sizeof(sd->soa->minttl);
answer->rdlength = htons(&reply[outlen] - &answer->rdata);
@@ -1857,15 +1853,9 @@ reply_noerror(struct sreply *sreply)
p = (char *)&answer->rdata;
-#if 0
- label = dns_label((char *)mysoa.nsserver, &labellen);
- if (label == NULL)
- return;
-#endif
+ label = sd->soa->nsserver;
+ labellen = sd->soa->nsserver_len;
- label = &sd->soa.nsserver[0];
- labellen = sd->soa.nsserver_len;
-
plabel = label;
/* copy label to reply */
@@ -1887,8 +1877,8 @@ reply_noerror(struct sreply *sreply)
outlen = tmplen;
}
- label = &sd->soa.responsible_person[0];
- labellen = sd->soa.rp_len;
+ label = sd->soa->responsible_person;
+ labellen = sd->soa->rp_len;
plabel = label;
for (i = outlen; i < sizeof(reply); i++) {
@@ -1911,41 +1901,42 @@ reply_noerror(struct sreply *sreply)
}
- if ((outlen + sizeof(sd->soa.serial)) > sizeof(reply)) {
+ /* XXX */
+ if ((outlen + sizeof(sd->soa->serial)) > sizeof(reply)) {
/* XXX server error reply? */
return;
}
soa_val = (u_int32_t *)&reply[outlen];
- *soa_val = htonl(sd->soa.serial);
- outlen += sizeof(sd->soa.serial);
+ *soa_val = htonl(sd->soa->serial);
+ outlen += sizeof(sd->soa->serial);
- if ((outlen + sizeof(sd->soa.refresh)) > sizeof(reply)) {
+ if ((outlen + sizeof(sd->soa->refresh)) > sizeof(reply)) {
return;
}
soa_val = (u_int32_t *)&reply[outlen];
- *soa_val = htonl(sd->soa.refresh);
- outlen += sizeof(sd->soa.refresh);
+ *soa_val = htonl(sd->soa->refresh);
+ outlen += sizeof(sd->soa->refresh);
- if ((outlen + sizeof(sd->soa.retry)) > sizeof(reply)) {
+ if ((outlen + sizeof(sd->soa->retry)) > sizeof(reply)) {
return;
}
soa_val = (u_int32_t *)&reply[outlen];
- *soa_val = htonl(sd->soa.retry);
- outlen += sizeof(sd->soa.retry);
+ *soa_val = htonl(sd->soa->retry);
+ outlen += sizeof(sd->soa->retry);
- if ((outlen + sizeof(sd->soa.expire)) > sizeof(reply)) {
+ if ((outlen + sizeof(sd->soa->expire)) > sizeof(reply)) {
return;
}
soa_val = (u_int32_t *)&reply[outlen];
- *soa_val = htonl(sd->soa.expire);
- outlen += sizeof(sd->soa.expire);
+ *soa_val = htonl(sd->soa->expire);
+ outlen += sizeof(sd->soa->expire);
- if ((outlen + sizeof(sd->soa.minttl)) > sizeof(reply)) {
+ if ((outlen + sizeof(sd->soa->minttl)) > sizeof(reply)) {
return;
}
soa_val = (u_int32_t *)&reply[outlen];
- *soa_val = htonl(sd->soa.minttl);
- outlen += sizeof(sd->soa.minttl);
+ *soa_val = htonl(sd->soa->minttl);
+ outlen += sizeof(sd->soa->minttl);
answer->rdlength = htons(&reply[outlen] - &answer->rdata);
repomaster@centroid.eu