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",