Commit 45854420 authored by Marek Vavrusa's avatar Marek Vavrusa

nsupdate core functionality, no query building yet.

- parser doesn't work properly
- gsstsig, key, local, oldgsstsig, realm, show, del, answer, ttl not implemented
parent cc2db3e6
......@@ -89,8 +89,6 @@ typedef struct {
list servers;
/*!< List of DNS queries to process. */
list queries;
/*!< List of files with query data. */
list qfiles;
/*!< Operation mode. */
operation_t operation;
......@@ -116,10 +114,8 @@ typedef struct {
bool servfail_stop;
/*!< Verbose mode. */
format_t format;
/*!< Default port. */
unsigned port;
/*!< Default address. */
const char* addr;
/*!< Implementation specific ptr. */
void* d;
} params_t;
query_t* query_create(const char *name, const uint16_t type);
......
This diff is collapsed.
......@@ -32,7 +32,7 @@
#include "utils/nsupdate/nsupdate_params.h"
int nsupdate_exec(const params_t *params);
int nsupdate_exec(params_t *params);
#endif // _NSUPDATE__NSUPDATE_EXEC_H_
......
......@@ -30,17 +30,30 @@ static void nsupdate_params_init(params_t *params)
{
memset(params, 0, sizeof(*params));
// Lists
init_list(&params->qfiles);
// Default values.
/* Specific data ptr. */
params->d = malloc(sizeof(nsupdate_params_t));
memset(params->d, 0, sizeof(nsupdate_params_t));
nsupdate_params_t *npar = NSUP_PARAM(params);
/* Lists */
init_list(&npar->qfiles);
/* Default values. */
npar->port = DEFAULT_PORT;
params->operation = OPERATION_UPDATE;
params->port = DEFAULT_PORT;
params->protocol = PROTO_ALL;
params->udp_size = DEFAULT_UDP_SIZE;
params->retries = DEFAULT_RETRIES;
params->wait = DEFAULT_WAIT_INTERVAL;
params->format = FORMAT_NSUPDATE;
/* Initialize RR parser. */
npar->rrp = scanner_create("-");
const char *settings = "$ORIGIN example.com.\n";
npar->rrp->default_class = KNOT_CLASS_IN;
npar->rrp->default_ttl = 3600;
scanner_process(settings, settings + strlen(settings), 0, npar->rrp);
}
void nsupdate_params_clean(params_t *params)
......@@ -48,8 +61,25 @@ void nsupdate_params_clean(params_t *params)
if (params == NULL) {
return;
}
/* Free specific structure. */
nsupdate_params_t* npar = NSUP_PARAM(params);
if (npar) {
free(npar->addr);
free(npar->zone);
scanner_free(npar->rrp);
/* Free qfiles. */
strnode_t *n = NULL, *nxt = NULL;
WALK_LIST_DELSAFE(n, nxt, npar->qfiles) {
free(n);
}
free(npar);
params->d = NULL;
}
// Clean up the structure.
/* Clean up the structure. */
memset(params, 0, sizeof(*params));
}
......@@ -95,15 +125,16 @@ int nsupdate_params_parse(params_t *params, int argc, char *argv[])
return KNOT_ENOTSUP;
}
}
/* Process non-option parameters. */
nsupdate_params_t* npar = NSUP_PARAM(params);
for (; optind < argc; ++optind) {
strnode_t *n = malloc(sizeof(strnode_t));
if (!n) { /* Params will be cleaned on exit. */
return KNOT_ENOMEM;
}
n->str = argv[optind];
add_tail(&params->qfiles, &n->n);
add_tail(&npar->qfiles, &n->n);
}
return KNOT_EOK;
......
......@@ -32,6 +32,25 @@
#include "common/lists.h" // list
#include "utils/common/params.h" // protocol_t
#include "libknot/packet/query.h"
#include "zscanner/scanner.h"
/* nsupdate-specific params data */
typedef struct nsupdate_params_t {
/*!< List of files with query data. */
list qfiles;
/*!< Default port. */
unsigned port;
/*!< Default address. */
char *addr;
/*!< Current zone. */
char *zone;
/*!< RR parser. */
scanner_t *rrp;
/*!< Current packet. */
knot_packet_t *pkt;
} nsupdate_params_t;
#define NSUP_PARAM(p) ((nsupdate_params_t*)p->d)
int nsupdate_params_parse(params_t *params, int argc, char *argv[]);
void nsupdate_params_clean(params_t *params);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment