forked from DNS-OARC/validns
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaa.c
More file actions
76 lines (65 loc) · 1.98 KB
/
caa.c
File metadata and controls
76 lines (65 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Part of DNS zone file validator `validns`.
*
* Copyright 2011-2014 Anton Berezin <tobez@tobez.org>
* 2017 Casper Gielen <cgielen+validns@uvt.nl>
* Modified BSD license.
* (See LICENSE file in the distribution.)
*
*/
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "common.h"
#include "textparse.h"
#include "mempool.h"
#include "carp.h"
#include "rr.h"
static struct rr *caa_parse(char *name, long ttl, int type, char *s)
{
struct rr_caa *rr = getmem(sizeof(*rr));
rr->flags = extract_integer(&s, "CAA flag", NULL);
if (rr->flags != 0 && rr->flags != 128)
return bitch("unknown flag value %d", rr->flags);
rr->property = extract_label(&s, "CAA property", 0);
rr->value = extract_text(&s, "CAA property");
if ((strcmp(rr->property, "issue") != 0) \
&& (strcmp(rr->property, "issuewild") != 0) \
&& (strcmp(rr->property, "iodef") != 0)) {
return bitch("unkown CAA property %s", rr->property);
}
if (*s) {
return bitch("garbage after valid caa data");
}
return store_record(type, name, ttl, rr);
}
static char* caa_human(struct rr *rrv)
{
RRCAST(caa);
char s[1024];
snprintf(s, 1024, "%d %s \"%s\"",
rr->flags, rr->property, rr->value.data);
return quickstrdup_temp(s);
}
static struct binary_data caa_wirerdata(struct rr *rrv)
{
RRCAST(caa);
return compose_binary_data("1db", 1,
rr->flags, rr->property, rr->value);
}
/*
* todo: implement validate and look inside the record
static void *caa_validate(struct rr *rrv)
if ((strcmp(rr->property, "issue") == 0) \
|| (strcmp(rr->property, "issuewild") == 0) ) {
} else if(strcmp(rr->property, "iodef") == 0) {
if ((strcmp(rr->value, "mailto:") != 0) \
|| (strcmp(rr->value, "http://") != 0) \
|| (strcmp(rr->value, "https://") != 0) )
return bitch("only mailto: and http(s): links are supported");
} else {
}
*/
struct rr_methods caa_methods = { caa_parse, caa_human, caa_wirerdata, NULL, NULL };