Commit Diff
Diff:
0fc5c5ffa10da8c3d6e5ca31f2ad0aab25f2053a
15f412a961a65ec69976b06cb7b53404ef7e4178
Commit:
15f412a961a65ec69976b06cb7b53404ef7e4178
Tree:
7ff77efb92aa7d2faf9a5fe402d1095ba63d3bfc
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Fri Feb 8 13:50:35 2019 UTC
Message:
add the remaining raxfr's tlsa, srv, and naptr. This completes all functionality of delphinusdnsd presently. I don't think I should do more RR's unless per request.
blob - 8e65bfd8dd3104c76030ffe2841f5bbebe865965
blob + f1bd09d883aaf7ad313e2dbde47fe01968774a79
--- dddctl.c
+++ dddctl.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: dddctl.c,v 1.40 2019/02/08 10:35:55 pjp Exp $
+ * $Id: dddctl.c,v 1.41 2019/02/08 13:50:35 pjp Exp $
*/
#include "ddd-include.h"
@@ -259,6 +259,9 @@ struct rrtab *rrlookup(char *);
extern int raxfr_a(FILE *, u_char *, u_char *, u_char *, struct soa *, u_int16_t);
+extern int raxfr_tlsa(FILE *, u_char *, u_char *, u_char *, struct soa *, u_int16_t);
+extern int raxfr_srv(FILE *, u_char *, u_char *, u_char *, struct soa *, u_int16_t);
+extern int raxfr_naptr(FILE *, u_char *, u_char *, u_char *, struct soa *, u_int16_t);
extern int raxfr_aaaa(FILE *, u_char *, u_char *, u_char *, struct soa *, u_int16_t);
extern int raxfr_cname(FILE *, u_char *, u_char *, u_char *, struct soa *, u_int16_t);
extern int raxfr_ns(FILE *, u_char *, u_char *, u_char *, struct soa *, u_int16_t);
@@ -300,6 +303,9 @@ static struct raxfr_logic {
{ DNS_TYPE_NSEC3, 1, raxfr_nsec3 },
{ DNS_TYPE_DS, 1, raxfr_ds },
{ DNS_TYPE_SSHFP, 0, raxfr_sshfp },
+ { DNS_TYPE_TLSA, 0, raxfr_tlsa },
+ { DNS_TYPE_SRV, 0, raxfr_srv },
+ { DNS_TYPE_NAPTR, 0, raxfr_naptr },
{ 0, 0, NULL }
};
blob - 77b156fc4d4ae4b5f0033abf49bc447471ffa54b
blob + 84f449abc655d13546f79da7785ac61e73d0ee83
--- raxfr.c
+++ raxfr.c
@@ -26,7 +26,7 @@
*
*/
/*
- * $Id: raxfr.c,v 1.5 2019/02/08 10:36:59 pjp Exp $
+ * $Id: raxfr.c,v 1.6 2019/02/08 13:50:35 pjp Exp $
*/
#include "ddd-include.h"
@@ -46,6 +46,9 @@ int raxfr_nsec3param(FILE *, u_char *, u_char *, u_cha
int raxfr_nsec3(FILE *, u_char *, u_char *, u_char *, struct soa *, u_int16_t);
int raxfr_ds(FILE *, u_char *, u_char *, u_char *, struct soa *, u_int16_t);
int raxfr_sshfp(FILE *, u_char *, u_char *, u_char *, struct soa *, u_int16_t);
+int raxfr_tlsa(FILE *, u_char *, u_char *, u_char *, struct soa *, u_int16_t);
+int raxfr_srv(FILE *, u_char *, u_char *, u_char *, struct soa *, u_int16_t);
+int raxfr_naptr(FILE *, u_char *, u_char *, u_char *, struct soa *, u_int16_t);
u_int16_t raxfr_skip(FILE *, u_char *, u_char *);
int raxfr_soa(FILE *, u_char *, u_char *, u_char *, struct soa *, int, u_int32_t);
@@ -705,4 +708,161 @@ raxfr_a(FILE *f, u_char *p, u_char *estart, u_char *en
p += sizeof(*ia);
return (p - estart);
+}
+
+int
+raxfr_tlsa(FILE *f, u_char *p, u_char *estart, u_char *end, struct soa *mysoa, u_int16_t rdlen)
+{
+ struct tlsa t;
+
+ t.usage = *p++;
+ t.selector = *p++;
+ t.matchtype = *p++;
+
+ t.datalen = (rdlen - 3);
+
+ if (t.datalen > sizeof(t.data))
+ return -1;
+
+ memcpy(&t.data, p, t.datalen);
+ p += t.datalen;
+
+ if (f != NULL) {
+ fprintf(f, "%u,%u,%u,\"%s\"\n", t.usage, t.selector,
+ t.matchtype, bin2hex(t.data, t.datalen));
+ }
+
+ return (p - estart);
+}
+
+int
+raxfr_srv(FILE *f, u_char *p, u_char *estart, u_char *end, struct soa *mysoa, u_int16_t rdlen)
+{
+ u_int16_t *tmp16;
+ struct srv s;
+ char *save, *humanname;
+ u_char *q = p;
+ u_char expand[256];
+ int max = sizeof(expand);
+ int elen = 0;
+
+ tmp16 = (u_int16_t *)q;
+ s.priority = ntohs(*tmp16);
+ q += 2;
+ tmp16 = (u_int16_t *)q;
+ s.weight = ntohs(*tmp16);
+ q += 2;
+ tmp16 = (u_int16_t *)q;
+ s.port = ntohs(*tmp16);
+ q += 2;
+
+ memset(&expand, 0, sizeof(expand));
+ save = expand_compression(q, estart, end, (u_char *)&expand, &elen, max);
+ if (save == NULL) {
+ fprintf(stderr, "expanding compression failure 2\n");
+ return -1;
+ } else {
+ q = save;
+ }
+
+ humanname = convert_name(expand, elen);
+ if (humanname == NULL) {
+ return -1;
+ }
+
+ if (f != NULL) {
+ if (*humanname == '\0')
+ fprintf(f, "%u,%u,%u,.\n", s.priority, s.weight, s.port);
+ else
+ fprintf(f, "%u,%u,%u,%s\n", s.priority, s.weight,
+ s.port, humanname);
+ }
+
+ free(humanname);
+
+ return (q - estart);
+}
+
+int
+raxfr_naptr(FILE *f, u_char *p, u_char *estart, u_char *end, struct soa *mysoa, u_int16_t rdlen)
+{
+ u_int16_t *tmp16;
+ struct naptr n;
+ char *save, *humanname;
+ u_char *q = p;
+ u_char expand[256];
+ int max = sizeof(expand);
+ int elen = 0;
+ int len, i;
+
+ tmp16 = (u_int16_t *)q;
+ n.order = ntohs(*tmp16);
+ q += 2;
+ tmp16 = (u_int16_t *)q;
+ n.preference = ntohs(*tmp16);
+ q += 2;
+
+ if (f != NULL) {
+ fprintf(f, "%u,%u,", n.order, n.preference);
+ }
+
+
+ /* flags */
+ len = *q;
+ q++;
+
+ if (f != NULL) {
+ fprintf(f, "\"");
+ for (i = 0; i < len; i++) {
+ fprintf(f, "%c", *q++);
+ }
+ fprintf(f, "\",");
+ }
+ /* services */
+ len = *q;
+ q++;
+
+ if (f != NULL) {
+ fprintf(f, "\"");
+ for (i = 0; i < len; i++) {
+ fprintf(f, "%c", *q++);
+ }
+ fprintf(f, "\",");
+ }
+ /* regexp */
+ len = *q;
+ q++;
+
+ if (f != NULL) {
+ fprintf(f, "\"");
+ for (i = 0; i < len; i++) {
+ fprintf(f, "%c", *q++);
+ }
+ fprintf(f, "\",");
+ }
+
+ memset(&expand, 0, sizeof(expand));
+ save = expand_compression(q, estart, end, (u_char *)&expand, &elen, max);
+ if (save == NULL) {
+ fprintf(stderr, "expanding compression failure 2\n");
+ return -1;
+ } else {
+ q = save;
+ }
+
+ humanname = convert_name(expand, elen);
+ if (humanname == NULL) {
+ return -1;
+ }
+
+ if (f != NULL) {
+ if (*humanname == '\0')
+ fprintf(f, ".\n");
+ else
+ fprintf(f, "%s\n", humanname);
+ }
+
+ free(humanname);
+
+ return (q - estart);
}
repomaster@centroid.eu