39 #include <libxml/parser.h>
40 #include <libxml/xpath.h>
41 #include <libxml/xpathInternals.h>
42 #include <libxml/xmlreader.h>
45 static const char* parser_str =
"parser";
56 xmlXPathContextPtr xpathCtx = NULL;
57 xmlXPathObjectPtr xpathObj = NULL;
58 xmlNode* curNode = NULL;
59 xmlChar* xexpr = NULL;
64 char* algorithm = NULL;
65 int ksk, zsk, publish, i;
67 if (!cfgfile || !sc) {
71 doc = xmlParseFile(cfgfile);
74 "xmlParseFile() failed", parser_str);
78 xpathCtx = xmlXPathNewContext(doc);
79 if(xpathCtx == NULL) {
82 "xmlXPathNewContext() failed", parser_str);
86 xexpr = (xmlChar*)
"//SignerConfiguration/Zone/Keys/Key";
87 xpathObj = xmlXPathEvalExpression(xexpr, xpathCtx);
88 if(xpathObj == NULL) {
89 xmlXPathFreeContext(xpathCtx);
92 "xmlXPathEvalExpression() failed", parser_str);
98 if (xpathObj->nodesetval && xpathObj->nodesetval->nodeNr > 0) {
99 for (i = 0; i < xpathObj->nodesetval->nodeNr; i++) {
107 curNode = xpathObj->nodesetval->nodeTab[i]->xmlChildrenNode;
109 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Locator")) {
110 locator = (
char *) xmlNodeGetContent(curNode);
111 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Algorithm")) {
112 algorithm = (
char *) xmlNodeGetContent(curNode);
113 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Flags")) {
114 flags = (
char *) xmlNodeGetContent(curNode);
115 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"KSK")) {
117 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"ZSK")) {
119 }
else if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Publish")) {
122 curNode = curNode->next;
124 if (locator && algorithm && flags) {
128 new_key->
algorithm == (uint8_t) atoi(algorithm) &&
129 new_key->
flags == (uint32_t) atoi(flags) &&
131 new_key->
ksk == ksk &&
132 new_key->
zsk == zsk) {
135 "to keylist, skipping", parser_str, locator);
138 (uint8_t) atoi(algorithm), (uint32_t) atoi(flags),
143 "is missing required elements, skipping",
147 free((
void*)algorithm);
151 xmlXPathFreeObject(xpathObj);
152 xmlXPathFreeContext(xpathCtx);
169 "//SignerConfiguration/Zone/Signatures/Resign",
185 "//SignerConfiguration/Zone/Signatures/Refresh",
201 "//SignerConfiguration/Zone/Signatures/Validity/Default",
217 "//SignerConfiguration/Zone/Signatures/Validity/Denial",
233 "//SignerConfiguration/Zone/Signatures/Jitter",
249 "//SignerConfiguration/Zone/Signatures/InceptionOffset",
265 "//SignerConfiguration/Zone/Keys/TTL",
281 "//SignerConfiguration/Zone/Denial/NSEC3/TTL",
297 "//SignerConfiguration/Zone/SOA/TTL",
313 "//SignerConfiguration/Zone/SOA/Minimum",
332 "//SignerConfiguration/Zone/Denial/NSEC3",
336 return LDNS_RR_TYPE_NSEC3;
339 "//SignerConfiguration/Zone/Denial/NSEC",
343 return LDNS_RR_TYPE_NSEC;
345 return LDNS_RR_TYPE_FIRST;
358 "//SignerConfiguration/Zone/Denial/NSEC3/Hash/Algorithm",
361 if (strlen(str) > 0) {
375 "//SignerConfiguration/Zone/Denial/NSEC3/Hash/Iterations",
378 if (strlen(str) > 0) {
392 "//SignerConfiguration/Zone/Denial/NSEC3/OptOut",
409 const char* dup = NULL;
412 "//SignerConfiguration/Zone/SOA/Serial",
426 const char* dup = NULL;
429 "//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)