diff --git a/src/libknot/sign/key.c b/src/libknot/sign/key.c index a67993d5c90b7f6de97f0a4b30ac0b04f3eaa217..558ea24810341e8e3e207751880fe5cd096200b0 100644 --- a/src/libknot/sign/key.c +++ b/src/libknot/sign/key.c @@ -87,11 +87,6 @@ static char *strndup_with_suffix(const char *base, int length, char *suffix) return result; } -static void key_scan_noop(const scanner_t *s) -{ - UNUSED(s); -} - /*! * \brief Reads RR in the public key file and retrieves basic key information. */ @@ -106,19 +101,13 @@ static int get_key_info_from_public_key(const char *filename, if (!keyfile) return KNOT_KEY_EPUBLIC_KEY_OPEN; - scanner_t *scanner = scanner_create(filename); + scanner_t *scanner = scanner_create(filename, ".", KNOT_CLASS_IN, 0, + NULL, NULL, NULL); if (!scanner) { fclose(keyfile); return KNOT_ENOMEM; } - scanner->process_record = key_scan_noop; - scanner->process_error = key_scan_noop; - scanner->default_ttl = 0; - scanner->default_class = KNOT_CLASS_IN; - scanner->zone_origin[0] = '\0'; - scanner->zone_origin_length = 1; - char *buffer = NULL; size_t buffer_size; ssize_t read = knot_getline(&buffer, &buffer_size, keyfile); diff --git a/src/utils/nsupdate/nsupdate_exec.c b/src/utils/nsupdate/nsupdate_exec.c index 705e7c01ecdb825b4c76c19eb743f745390896f9..195836d67c05866a66b718a86f648c67349cc41f 100644 --- a/src/utils/nsupdate/nsupdate_exec.c +++ b/src/utils/nsupdate/nsupdate_exec.c @@ -880,26 +880,6 @@ int cmd_key(const char* lp, nsupdate_params_t *params) return ret; } -/* - * Not implemented. - */ - -int cmd_gsstsig(const char* lp, nsupdate_params_t *params) -{ - UNUSED(params); - DBG("%s: lp='%s'\n", __func__, lp); - - return KNOT_ENOTSUP; -} - -int cmd_oldgsstsig(const char* lp, nsupdate_params_t *params) -{ - UNUSED(params); - DBG("%s: lp='%s'\n", __func__, lp); - - return KNOT_ENOTSUP; -} - int cmd_origin(const char* lp, nsupdate_params_t *params) { DBG("%s: lp='%s'\n", __func__, lp); @@ -920,6 +900,26 @@ int cmd_origin(const char* lp, nsupdate_params_t *params) return ret; } +/* + * Not implemented. + */ + +int cmd_gsstsig(const char* lp, nsupdate_params_t *params) +{ + UNUSED(params); + DBG("%s: lp='%s'\n", __func__, lp); + + return KNOT_ENOTSUP; +} + +int cmd_oldgsstsig(const char* lp, nsupdate_params_t *params) +{ + UNUSED(params); + DBG("%s: lp='%s'\n", __func__, lp); + + return KNOT_ENOTSUP; +} + int cmd_realm(const char* lp, nsupdate_params_t *params) { UNUSED(params); diff --git a/src/utils/nsupdate/nsupdate_params.c b/src/utils/nsupdate/nsupdate_params.c index 4d1f054596a877cdbbc5b5a9f079fc0020f55835..523b4ca17d5e1369401e76e6a122b7044643b563 100644 --- a/src/utils/nsupdate/nsupdate_params.c +++ b/src/utils/nsupdate/nsupdate_params.c @@ -46,11 +46,6 @@ static const style_t DEFAULT_STYLE_NSUPDATE = { .show_footer = false, }; -static void parse_rr(const scanner_t *s) -{ - UNUSED(s); -} - static void parse_err(const scanner_t *s) { ERR("failed to parse RR, %s\n", knot_strerror(s->error_code)); } @@ -69,7 +64,7 @@ static int parser_set_default(scanner_t *s, const char *fmt, ...) } /* fmt must contain newline */ - if (scanner_process(buf, buf + n, 0, s) < 0) { + if (scanner_process(buf, buf + n, 1, s) < 0) { return KNOT_EPARSEFAIL; } @@ -87,29 +82,28 @@ static int nsupdate_init(nsupdate_params_t *params) /* Default server. */ params->server = server_create(DEFAULT_IPV4_NAME, DEFAULT_DNS_PORT); - if (!params->server) return KNOT_ENOMEM; + if (!params->server) + return KNOT_ENOMEM; /* Default settings. */ params->ip = IP_ALL; params->protocol = PROTO_ALL; - params->retries = DEFAULT_RETRIES_NSUPDATE; - params->wait = DEFAULT_TIMEOUT_NSUPDATE; params->class_num = KNOT_CLASS_IN; params->type_num = KNOT_RRTYPE_SOA; + params->ttl = 0; + params->retries = DEFAULT_RETRIES_NSUPDATE; + params->wait = DEFAULT_TIMEOUT_NSUPDATE; + params->zone = strdup("."); + + /* Initialize RR parser. */ + params->rrp = scanner_create(NULL, ".", params->class_num, 0, NULL, + parse_err, NULL); + if (!params->rrp) + return KNOT_ENOMEM; /* Default style. */ params->style = DEFAULT_STYLE_NSUPDATE; - /* Initialize RR parser. */ - params->rrp = scanner_create("."); - if (!params->rrp) return KNOT_ENOMEM; - params->rrp->process_record = parse_rr; - params->rrp->process_error = parse_err; - params->rrp->default_class = params->class_num; - params->zone = strdup("."); - nsupdate_set_ttl(params, 0); - nsupdate_set_origin(params, "."); - return KNOT_EOK; } @@ -121,18 +115,17 @@ void nsupdate_clean(nsupdate_params_t *params) return; } + /* Free qfiles. */ + WALK_LIST_DELSAFE(n, nxt, params->qfiles) { + free(n); + } + server_free(params->server); server_free(params->srcif); free(params->zone); scanner_free(params->rrp); knot_packet_free(¶ms->pkt); knot_packet_free(¶ms->resp); - - /* Free qfiles. */ - WALK_LIST_DELSAFE(n, nxt, params->qfiles) { - free(n); - } - knot_free_key_params(¶ms->key_params); /* Clean up the structure. */ diff --git a/src/utils/nsupdate/nsupdate_params.h b/src/utils/nsupdate/nsupdate_params.h index 33308d9f5f2593f51e65e20dadf0a77c601d0cca..d9c42ae1f245e4bb697ead9ebb1c1bb94e0b4be2 100644 --- a/src/utils/nsupdate/nsupdate_params.h +++ b/src/utils/nsupdate/nsupdate_params.h @@ -51,7 +51,7 @@ typedef struct { server_t *server; /*!< Local interface (optional). */ server_t *srcif; - /*!< Operation mode. */ + /*!< Version of ip protocol to use. */ ip_t ip; /*!< Type (TCP, UDP) protocol to use. */ protocol_t protocol;