37 #include <libxml/parser.h>
38 #include <libxml/xpath.h>
39 #include <libxml/xpathInternals.h>
40 #include <libxml/xmlreader.h>
43 static const char* parser_str =
"parser";
54 xmlXPathContextPtr xpathCtx = NULL;
55 xmlXPathObjectPtr xpathObj = NULL;
56 xmlNode* curNode = NULL;
57 xmlChar* xexpr = NULL;
62 char* algorithm = NULL;
63 int ksk, zsk, publish, i, rfc5011;
65 if (!cfgfile || !sc) {
69 doc = xmlParseFile(cfgfile);
72 "xmlParseFile() failed", parser_str);
76 xpathCtx = xmlXPathNewContext(doc);
77 if(xpathCtx == NULL) {
80 "xmlXPathNewContext() failed", parser_str);
84 xexpr = (xmlChar*)
"//SignerConfiguration/Zone/Keys/Key";
85 xpathObj = xmlXPathEvalExpression(xexpr, xpathCtx);
86 if(xpathObj == NULL) {
87 xmlXPathFreeContext(xpathCtx);
90 "xmlXPathEvalExpression() failed", parser_str);
96 if (xpathObj->nodesetval && xpathObj->nodesetval->nodeNr > 0) {
97 for (i = 0; i < xpathObj->nodesetval->nodeNr; i++) {
106 curNode = xpathObj->nodesetval->nodeTab[i]->xmlChildrenNode;
108 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Locator")) {
109 locator = (
char *) xmlNodeGetContent(curNode);
110 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Algorithm")) {
111 algorithm = (
char *) xmlNodeGetContent(curNode);
112 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Flags")) {
113 flags = (
char *) xmlNodeGetContent(curNode);
114 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"KSK")) {
116 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"ZSK")) {
118 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Publish")) {
120 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"RFC5011")) {
123 curNode = curNode->next;
125 if (locator && algorithm && flags) {
129 new_key->
algorithm == (uint8_t) atoi(algorithm) &&
130 new_key->
flags == (uint32_t) atoi(flags) &&
132 new_key->
ksk == ksk &&
133 new_key->
zsk == zsk) {
136 "to keylist, skipping", parser_str, locator);
139 (uint8_t) atoi(algorithm), (uint32_t) atoi(flags),
140 publish, ksk, zsk, rfc5011);
144 "is missing required elements, skipping",
148 free((
void*)algorithm);
152 xmlXPathFreeObject(xpathObj);
153 xmlXPathFreeContext(xpathCtx);
170 "//SignerConfiguration/Zone/Signatures/Resign",
186 "//SignerConfiguration/Zone/Signatures/Refresh",
202 "//SignerConfiguration/Zone/Signatures/Validity/Default",
218 "//SignerConfiguration/Zone/Signatures/Validity/Denial",
234 "//SignerConfiguration/Zone/Signatures/Jitter",
250 "//SignerConfiguration/Zone/Signatures/InceptionOffset",
266 "//SignerConfiguration/Zone/Keys/TTL",
282 "//SignerConfiguration/Zone/Denial/NSEC3/TTL",
298 "//SignerConfiguration/Zone/SOA/TTL",
314 "//SignerConfiguration/Zone/SOA/Minimum",
333 "//SignerConfiguration/Zone/Denial/NSEC3",
337 return LDNS_RR_TYPE_NSEC3;
340 "//SignerConfiguration/Zone/Denial/NSEC",
344 return LDNS_RR_TYPE_NSEC;
346 return LDNS_RR_TYPE_FIRST;
359 "//SignerConfiguration/Zone/Denial/NSEC3/Hash/Algorithm",
362 if (strlen(str) > 0) {
376 "//SignerConfiguration/Zone/Denial/NSEC3/Hash/Iterations",
379 if (strlen(str) > 0) {
393 "//SignerConfiguration/Zone/Denial/NSEC3/OptOut",
410 const char* dup = NULL;
413 "//SignerConfiguration/Zone/SOA/Serial",
427 const char* dup = NULL;
430 "//SignerConfiguration/Zone/Denial/NSEC3/Hash/Salt",
duration_type * parse_sc_sig_validity_default(const char *cfgfile)
duration_type * parse_sc_sig_validity_denial(const char *cfgfile)
key_type * keylist_push(keylist_type *kl, const char *locator, uint8_t algorithm, uint32_t flags, int publish, int ksk, int zsk, int rfc5011)
uint32_t parse_sc_nsec3_algorithm(const char *cfgfile)
key_type * keylist_lookup_by_locator(keylist_type *kl, const char *locator)
duration_type * parse_sc_soa_ttl(const char *cfgfile)
const char * parse_sc_soa_serial(allocator_type *allocator, const char *cfgfile)
void ods_log_error(const char *format,...)
duration_type * parse_sc_sig_inception_offset(const char *cfgfile)
const char * parse_sc_nsec3_salt(allocator_type *allocator, const char *cfgfile)
duration_type * parse_sc_dnskey_ttl(const char *cfgfile)
duration_type * parse_sc_sig_jitter(const char *cfgfile)
duration_type * parse_sc_nsec3param_ttl(const char *cfgfile)
char * allocator_strdup(allocator_type *allocator, const char *string)
duration_type * parse_sc_sig_refresh_interval(const char *cfgfile)
int parse_sc_nsec3_optout(const char *cfgfile)
duration_type * parse_sc_soa_min(const char *cfgfile)
const char * parse_conf_string(const char *cfgfile, const char *expr, int required)
keylist_type * keylist_create(void *sc)
keylist_type * parse_sc_keys(void *sc, const char *cfgfile)
ldns_rr_type parse_sc_nsec_type(const char *cfgfile)
#define ods_log_assert(x)
duration_type * duration_create_from_string(const char *str)
duration_type * parse_sc_sig_resign_interval(const char *cfgfile)
void ods_log_warning(const char *format,...)
uint32_t parse_sc_nsec3_iterations(const char *cfgfile)