Commit Diff
Diff:
748695f5c0b0ed6dc6b93073f03ef095a8eba491
701145635a171d9360f586686177b5ddf643210c
Commit:
701145635a171d9360f586686177b5ddf643210c
Tree:
f983fe446d0b40d08b13f3095439dfeca309221e
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Mon Nov 11 05:04:21 2019 UTC
Message:
move get_soa() and get_ns() to util.c
blob - e44b5069368c574a5964af4562b6903c9a186b0d
blob + e673b61594885fe4a27e6d4affe21542aa9dfa11
--- delphinusdnsd.c
+++ delphinusdnsd.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: delphinusdnsd.c,v 1.82 2019/11/09 08:04:39 pjp Exp $
+ * $Id: delphinusdnsd.c,v 1.83 2019/11/11 05:04:21 pjp Exp $
*/
@@ -163,13 +163,13 @@ extern int add_rr(struct rbtree *, char *, int, u_int
extern int display_rr(struct rrset *rrset);
extern int notifysource(struct question *, struct sockaddr_storage *);
extern int drop_privs(char *, struct passwd *);
+extern struct rbtree * get_soa(ddDB *, struct question *);
+extern struct rbtree * get_ns(ddDB *, struct rbtree *, int *);
struct question *convert_question(struct parsequestion *);
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);
@@ -1429,91 +1429,6 @@ out:
}
-/*
- * 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, htons(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);
-}
-
-
-/*
- * GET_SOA - get authoritative soa for a particular domain
- */
-
-struct rbtree *
-get_soa(ddDB *db, struct question *question)
-{
- struct rbtree *rbt = NULL;
-
- int plen;
- char *p;
-
- p = question->hdr->name;
- plen = question->hdr->namelen;
-
- do {
- struct rrset *rrset;
-
- rbt = find_rrset(db, p, plen);
- if (rbt == NULL) {
- if (*p == '\0')
- return (NULL);
-
- plen -= (*p + 1);
- p = (p + (*p + 1));
- continue;
- }
-
- rrset = find_rr(rbt, DNS_TYPE_SOA);
- if (rrset != NULL) {
- /* we'll take this one */
- return (rbt);
- } else {
- plen -= (*p + 1);
- p = (p + (*p + 1));
- }
-
- free(rbt);
- } while (*p);
-
- return (NULL);
-}
/*
* MAINLOOP - does the polling of tcp & udp descriptors and if ready receives the
blob - a990e9863fda9130e04cf7822e47dcd5fb9d5619
blob + 492534130a18afef791374f41394a09b32663dcf
--- util.c
+++ util.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: util.c,v 1.48 2019/11/06 13:25:06 pjp Exp $
+ * $Id: util.c,v 1.49 2019/11/11 05:04:21 pjp Exp $
*/
#include <sys/types.h>
@@ -87,6 +87,8 @@ int label_count(char *);
char * dns_label(char *, int *);
void slave_shutdown(void);
int get_record_size(ddDB *, char *, int);
+struct rbtree * get_soa(ddDB *, struct question *);
+struct rbtree * get_ns(ddDB *, struct rbtree *, 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 *);
@@ -413,6 +415,93 @@ lookup_zone(ddDB *db, struct question *question, int *
return(rbt);
}
+
+/*
+ * GET_SOA - get authoritative soa for a particular domain
+ */
+
+struct rbtree *
+get_soa(ddDB *db, struct question *question)
+{
+ struct rbtree *rbt = NULL;
+
+ int plen;
+ char *p;
+
+ p = question->hdr->name;
+ plen = question->hdr->namelen;
+
+ do {
+ struct rrset *rrset;
+
+ rbt = find_rrset(db, p, plen);
+ if (rbt == NULL) {
+ if (*p == '\0')
+ return (NULL);
+
+ plen -= (*p + 1);
+ p = (p + (*p + 1));
+ continue;
+ }
+
+ rrset = find_rr(rbt, DNS_TYPE_SOA);
+ if (rrset != NULL) {
+ /* we'll take this one */
+ return (rbt);
+ } else {
+ plen -= (*p + 1);
+ p = (p + (*p + 1));
+ }
+
+ free(rbt);
+ } while (*p);
+
+ return (NULL);
+}
+
+/*
+ * 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, htons(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);
+}
+
+
/*
* Lookup_zone: wrapper for lookup_zone() et al. type must be htons()'ed!
repomaster@centroid.eu