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;
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++) {
105 curNode = xpathObj->nodesetval->nodeTab[i]->xmlChildrenNode;
107 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Locator")) {
108 locator = (
char *) xmlNodeGetContent(curNode);
109 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Algorithm")) {
110 algorithm = (
char *) xmlNodeGetContent(curNode);
111 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Flags")) {
112 flags = (
char *) xmlNodeGetContent(curNode);
113 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"KSK")) {
115 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"ZSK")) {
117 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Publish")) {
120 curNode = curNode->next;
122 if (locator && algorithm && flags) {
126 new_key->
algorithm == (uint8_t) atoi(algorithm) &&
127 new_key->
flags == (uint32_t) atoi(flags) &&
129 new_key->
ksk == ksk &&
130 new_key->
zsk == zsk) {
133 "to keylist, skipping", parser_str, locator);
136 (uint8_t) atoi(algorithm), (uint32_t) atoi(flags),
141 "is missing required elements, skipping",
145 free((
void*)algorithm);
149 xmlXPathFreeObject(xpathObj);
150 xmlXPathFreeContext(xpathCtx);
167 "//SignerConfiguration/Zone/Signatures/Resign",
183 "//SignerConfiguration/Zone/Signatures/Refresh",
199 "//SignerConfiguration/Zone/Signatures/Validity/Default",
215 "//SignerConfiguration/Zone/Signatures/Validity/Denial",
231 "//SignerConfiguration/Zone/Signatures/Jitter",
247 "//SignerConfiguration/Zone/Signatures/InceptionOffset",
263 "//SignerConfiguration/Zone/Keys/TTL",
279 "//SignerConfiguration/Zone/Denial/NSEC3/TTL",
295 "//SignerConfiguration/Zone/SOA/TTL",
311 "//SignerConfiguration/Zone/SOA/Minimum",
330 "//SignerConfiguration/Zone/Denial/NSEC3",
334 return LDNS_RR_TYPE_NSEC3;
337 "//SignerConfiguration/Zone/Denial/NSEC",
341 return LDNS_RR_TYPE_NSEC;
343 return LDNS_RR_TYPE_FIRST;
356 "//SignerConfiguration/Zone/Denial/NSEC3/Hash/Algorithm",
359 if (strlen(str) > 0) {
373 "//SignerConfiguration/Zone/Denial/NSEC3/Hash/Iterations",
376 if (strlen(str) > 0) {
390 "//SignerConfiguration/Zone/Denial/NSEC3/OptOut",
407 const char* dup = NULL;
410 "//SignerConfiguration/Zone/SOA/Serial",
424 const char* dup = NULL;
427 "//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)
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)
key_type * keylist_push(keylist_type *kl, const char *locator, uint8_t algorithm, uint32_t flags, int publish, int ksk, int zsk)
#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)