Commit Diff
Diff:
18ef0de2d58f91119d85088c8fb7f82dff27c43d
130999a4e858ef84289b60edb67c2e31aa152ab1
Commit:
130999a4e858ef84289b60edb67c2e31aa152ab1
Tree:
a032b9efb37bde72dbbef314a4b7e1b4488b1b68
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Thu Oct 31 16:34:35 2019 UTC
Message:
move some functions around get_ns() -> delphinusdnsd.c Lookup_zone() -> util.c These may move again some day.
blob - 88654c309f23e0d78f884abe9e4c84ea5dcc9df0
blob + 668a9a323dcff164bd757de67800100f449a45c9
--- delphinusdnsd.c
+++ delphinusdnsd.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: delphinusdnsd.c,v 1.73 2019/10/30 12:14:36 pjp Exp $
+ * $Id: delphinusdnsd.c,v 1.74 2019/10/31 16:34:35 pjp Exp $
*/
@@ -116,6 +116,7 @@ extern void init_whitelist(void);
extern void init_tsig(void);
extern void init_notifyslave(void);
extern struct rbtree * lookup_zone(ddDB *, struct question *, int *, int *, char *);
+extern struct rbtree * Lookup_zone(ddDB *, char *, u_int16_t, u_int16_t, int);
extern int memcasecmp(u_char *, u_char *, int);
extern void receivelog(char *, int);
extern int reply_a(struct sreply *, ddDB *);
@@ -166,6 +167,7 @@ struct question *convert_question(struct parsequestio
void build_reply(struct sreply *, int, char *, int, struct question *, struct sockaddr *, socklen_t, struct rbtree *, struct rbtree *, u_int8_t, int, int, void *, char *);
int compress_label(u_char *, u_int16_t, int);
struct rbtree * get_soa(ddDB *, struct question *);
+struct rbtree * get_ns(ddDB *, struct rbtree *, int *);
void mainloop(struct cfg *, struct imsgbuf **);
void master_reload(int);
void master_shutdown(int);
@@ -1354,6 +1356,48 @@ out:
return (offset);
}
+
+/*
+ * GET_NS - walk to delegation name
+ */
+
+struct rbtree *
+get_ns(ddDB *db, struct rbtree *rbt, int *delegation)
+{
+ struct rrset *rrset = NULL;
+ struct rbtree *rbt0;
+ char *p;
+ int len;
+
+ if ((rrset = find_rr(rbt, DNS_TYPE_SOA)) == NULL) {
+ *delegation = 1;
+ } else {
+ *delegation = 0;
+ return (rbt);
+ }
+
+ p = rbt->zone;
+ len = rbt->zonelen;
+
+ while (*p && len > 0) {
+ rbt0 = Lookup_zone(db, p, len, DNS_TYPE_NS, 0);
+ if (rbt0 == NULL) {
+ p += (*p + 1);
+ len -= (*p + 1);
+
+ continue;
+ } else
+ break;
+ }
+
+ if ((rrset = find_rr(rbt0, DNS_TYPE_SOA)) != NULL) {
+ *delegation = 0;
+ free(rbt0);
+ return (rbt);
+ }
+
+ return (rbt0);
+}
/*
blob - d9568fe452cdb94b75944105bd691af92063a7ac
blob + 08d4d9aa4d7860f0e81797724cf0b03eb9f96f40
--- reply.c
+++ reply.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: reply.c,v 1.85 2019/10/30 12:14:36 pjp Exp $
+ * $Id: reply.c,v 1.86 2019/10/31 16:34:35 pjp Exp $
*/
#include <sys/types.h>
@@ -97,11 +97,11 @@ extern struct rbtree * find_nsec3_cover_next_closer(ch
extern struct rbtree * find_nsec3_match_closest(char *name, int namelen, struct rbtree *, ddDB *db);
extern struct rbtree * find_nsec3_wildcard_closest(char *name, int namelen, struct rbtree *, ddDB *db);
extern struct rbtree * find_nsec3_match_qname(char *name, int namelen, struct rbtree *, ddDB *db);
-extern struct rbtree * get_soa(ddDB *, struct question *);
+extern struct rbtree * get_soa(ddDB *, struct question *);
+extern struct rbtree * get_ns(ddDB *, struct rbtree *, int *);
+extern struct rbtree * Lookup_zone(ddDB *, char *, u_int16_t, u_int16_t, int);
-struct rbtree *Lookup_zone(ddDB *, char *, u_int16_t, u_int16_t, int);
-struct rbtree *get_ns(ddDB *, struct rbtree *, int *);
u_int16_t create_anyreply(struct sreply *, char *, int, int, int);
int reply_a(struct sreply *, ddDB *);
int reply_nsec3(struct sreply *, ddDB *);
@@ -5252,37 +5252,6 @@ out:
return (retlen);
}
-/*
- * Lookup_zone: wrapper for lookup_zone() et al.
- */
-
-struct rbtree *
-Lookup_zone(ddDB *db, char *name, u_int16_t namelen, u_int16_t type, int wildcard)
-{
- struct rbtree *rbt;
- struct question *fakequestion;
- char fakereplystring[DNS_MAXNAME + 1];
- int mytype;
- int lzerrno;
-
- fakequestion = build_fake_question(name, namelen, type, NULL, 0);
- if (fakequestion == 0) {
- dolog(LOG_INFO, "fakequestion(2) failed\n");
- return (NULL);
- }
-
- rbt = lookup_zone(db, fakequestion, &mytype, &lzerrno, (char *)&fakereplystring);
-
- if (rbt == 0) {
- free_question(fakequestion);
- return (NULL);
- }
-
- free_question(fakequestion);
-
- return (rbt);
-}
-
int
reply_any(struct sreply *sreply, ddDB *db)
{
@@ -6569,47 +6538,4 @@ int
reply_nodata(struct sreply *sreply, ddDB *db)
{
return (reply_noerror(sreply, db));
-}
-
-
-/*
- * GET_NS - walk to delegation name
- */
-
-struct rbtree *
-get_ns(ddDB *db, struct rbtree *rbt, int *delegation)
-{
- struct rrset *rrset = NULL;
- struct rbtree *rbt0;
- char *p;
- int len;
-
- if ((rrset = find_rr(rbt, DNS_TYPE_SOA)) == NULL) {
- *delegation = 1;
- } else {
- *delegation = 0;
- return (rbt);
- }
-
- p = rbt->zone;
- len = rbt->zonelen;
-
- while (*p && len > 0) {
- rbt0 = Lookup_zone(db, p, len, DNS_TYPE_NS, 0);
- if (rbt0 == NULL) {
- p += (*p + 1);
- len -= (*p + 1);
-
- continue;
- } else
- break;
- }
-
- if ((rrset = find_rr(rbt0, DNS_TYPE_SOA)) != NULL) {
- *delegation = 0;
- free(rbt0);
- return (rbt);
- }
-
- return (rbt0);
}
blob - 3df06b346a8c250b82ca5c2208d41870d7c84dd1
blob + 1f05f06634dd9cf4679cf0b44cddc7d7800e4651
--- util.c
+++ util.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: util.c,v 1.40 2019/10/30 12:14:36 pjp Exp $
+ * $Id: util.c,v 1.41 2019/10/31 16:34:35 pjp Exp $
*/
#include <sys/types.h>
@@ -88,6 +88,7 @@ char * dns_label(char *, int *);
void slave_shutdown(void);
int get_record_size(ddDB *, char *, int);
struct rbtree * lookup_zone(ddDB *, struct question *, int *, int *, char *);
+struct rbtree * Lookup_zone(ddDB *, char *, u_int16_t, u_int16_t, int);
u_int16_t check_qtype(struct rbtree *, u_int16_t, int, int *);
struct question *build_fake_question(char *, int, u_int16_t, char *, int);
@@ -358,6 +359,37 @@ lookup_zone(ddDB *db, struct question *question, int *
}
return(rbt);
+}
+
+/*
+ * Lookup_zone: wrapper for lookup_zone() et al.
+ */
+
+struct rbtree *
+Lookup_zone(ddDB *db, char *name, u_int16_t namelen, u_int16_t type, int wildcard)
+{
+ struct rbtree *rbt;
+ struct question *fakequestion;
+ char fakereplystring[DNS_MAXNAME + 1];
+ int mytype;
+ int lzerrno;
+
+ fakequestion = build_fake_question(name, namelen, type, NULL, 0);
+ if (fakequestion == 0) {
+ dolog(LOG_INFO, "fakequestion(2) failed\n");
+ return (NULL);
+ }
+
+ rbt = lookup_zone(db, fakequestion, &mytype, &lzerrno, (char *)&fakereplystring);
+
+ if (rbt == 0) {
+ free_question(fakequestion);
+ return (NULL);
+ }
+
+ free_question(fakequestion);
+
+ return (rbt);
}
/*
repomaster@centroid.eu