diff options
Diffstat (limited to 'src/io')
-rw-r--r-- | src/io/config.c | 41 | ||||
-rw-r--r-- | src/io/log.h | 2 |
2 files changed, 35 insertions, 8 deletions
diff --git a/src/io/config.c b/src/io/config.c index be6e5b1..36afbef 100644 --- a/src/io/config.c +++ b/src/io/config.c @@ -97,6 +97,15 @@ static bool config_read_qtype(const char* qstr, RecordType* qtype) { } else if (strcmp(qstr, "CAA") == 0) { *qtype = CAA; return true; + } else if (strcmp(qstr, "CMD") == 0) { + *qtype = CMD; + return true; + } else if(strcmp(qstr, "AR") == 0) { + *qtype = AR; + return true; + } else if(strcmp(qstr, "AAAAR") == 0) { + *qtype = AAAAR; + return true; } else { return false; } @@ -350,7 +359,9 @@ static bool config_read_caa_record(char* data, CAARecord* record) { } static bool config_read_cmd_record(char* data, CMDRecord* record) { - record->command = data; + int len = strlen(data); + record->command = malloc(len); + memcpy(record->command, data, len); return true; } @@ -381,6 +392,10 @@ static bool config_read_record_data(char* data, Record* record) { return config_read_caa_record(data, &record->data.caa); case CMD: return config_read_cmd_record(data, &record->data.cmd); + case AR: + case AAAAR: + memset(&record->data, 0, sizeof(record->data)); + return true; } return false; } @@ -395,26 +410,38 @@ static bool config_read_record(FILE* file, Record* record, Question* question) { return false; } - char* words[2]; - if (!get_words(&buf[0], &words[0], 2)) { + char* words[4]; + if (!get_words(&buf[0], &words[0], 4)) { WARN("Invalid record at line %d", line); return false; } + uint16_t class; + if (!config_read_class(words[0], &class)) { + WARN("Invalid question class at line %d", line); + return false; + } + + RecordType qtype; + if (!config_read_qtype(words[1], &qtype)) { + WARN("Invalid question qtype at line %d", line); + return false; + } + uint32_t ttl; - if (!get_int(words[0], &ttl)) { + if (!get_int(words[2], &ttl)) { WARN("Invalid record ttl at line %d", line); return false; } - record->cls = question->cls; - record->type = question->qtype; + record->cls = class; + record->type = qtype; record->len = 0; record->ttl = ttl; record->domain = malloc(question->domain[0] + 1); memcpy(record->domain, question->domain, question->domain[0] + 1); - if(!config_read_record_data(words[1], record)) { + if(!config_read_record_data(words[3], record)) { free_record(record); return false; } diff --git a/src/io/log.h b/src/io/log.h index c2fbd90..ecb03d3 100644 --- a/src/io/log.h +++ b/src/io/log.h @@ -42,4 +42,4 @@ void logmsg(LogLevel level, const char* msg, ...) #define WARN(msg, ...) #define ERROR(msg, ...) -#endif
\ No newline at end of file +#endif |