diff --git a/CodingStyle b/CodingStyle index 7ad5893365896643f35959b5b3c2f882e490b2df..26bc28d9d6119e6301d3eb8e34ba756e641770f9 100644 --- a/CodingStyle +++ b/CodingStyle @@ -5,7 +5,7 @@ Coding style * Max line width: 80 chars * Pointer asterisk attached to the name of the variable * Own structures/types: _t suffix (f.e. nameserver_t) -* Header guard format: _KNOT_HEADER_H_ +* Header guard format: _KNOTDHEADER_H_ * Spaces around binary operators * Space between keyword and bracket (f.e. "if (predicate)") * No space between variable and typecast (f.e. "return (int)val;") diff --git a/src/common/acl.h b/src/common/acl.h index a3cc5c794febdf9bce7a1c6cf88da8a030f3820b..d58ecf9e95efc6666f2e348b3baed9309ccd9be6 100644 --- a/src/common/acl.h +++ b/src/common/acl.h @@ -12,8 +12,8 @@ * @{ */ -#ifndef _KNOT_ACL_H_ -#define _KNOT_ACL_H_ +#ifndef _KNOTDACL_H_ +#define _KNOTDACL_H_ #include "common/skip-list.h" #include "common/sockaddr.h" @@ -118,6 +118,6 @@ static inline skip_list_t* acl_rules(acl_t *acl) { return acl->rules; } -#endif /* _KNOT_ACL_H_ */ +#endif /* _KNOTDACL_H_ */ /*! @} */ diff --git a/src/common/dynamic-array.h b/src/common/dynamic-array.h index 3f390f6320ad0f7d3530c223f02d74b236c7ae44..0c4bd21928df0f74bcb28b9499f9df7e404db147 100644 --- a/src/common/dynamic-array.h +++ b/src/common/dynamic-array.h @@ -13,8 +13,8 @@ * @{ */ -#ifndef _KNOT_COMMON_DYNAMIC_ARRAY_H_ -#define _KNOT_COMMON_DYNAMIC_ARRAY_H_ +#ifndef _KNOTDCOMMON_DYNAMIC_ARRAY_H_ +#define _KNOTDCOMMON_DYNAMIC_ARRAY_H_ #include <string.h> #include <pthread.h> @@ -136,6 +136,6 @@ unsigned da_get_count(const da_array_t *array); /*----------------------------------------------------------------------------*/ -#endif /* _KNOT_COMMON_DYNAMIC_ARRAY_H_ */ +#endif /* _KNOTDCOMMON_DYNAMIC_ARRAY_H_ */ /*! @} */ diff --git a/src/common/errors.c b/src/common/errors.c index ec034cc5fd9b8863add15b8694b856fcc2a9f6d2..9d9a293fdaae09494d290e9a592628f4cdca3da4 100644 --- a/src/common/errors.c +++ b/src/common/errors.c @@ -42,7 +42,7 @@ int _map_errno(int fallback_value, int arg0, ...) va_list ap; va_start(ap, arg0); - /* KNOT_ERROR serves as a sentinel. */ + /* KNOTDERROR serves as a sentinel. */ for (int c = arg0; c != 0; c = va_arg(ap, int)) { /* Error code matches with mapped. */ diff --git a/src/common/errors.h b/src/common/errors.h index 4f32cfd82b9aab31d00fccf2438a3bd694a4cae0..25ee04d4bab471c5d49b5843245d5b8497346211 100644 --- a/src/common/errors.h +++ b/src/common/errors.h @@ -10,8 +10,8 @@ * @{ */ -#ifndef _KNOT_COMMON_ERROR_H_ -#define _KNOT_COMMON_ERROR_H_ +#ifndef _KNOTDCOMMON_ERROR_H_ +#define _KNOTDCOMMON_ERROR_H_ #include <errno.h> @@ -60,6 +60,6 @@ const char *error_to_str(const error_table_t *table, int code); */ int _map_errno(int fallback_value, int arg0, ...); -#endif /* _KNOT_COMMON_ERROR_H_ */ +#endif /* _KNOTDCOMMON_ERROR_H_ */ /*! @} */ diff --git a/src/common/evqueue.h b/src/common/evqueue.h index d5eed9d0b931384248cbbdc9107473dce0dc1cc3..89713198410218b0bd1328886703f2209a7fc0ff 100644 --- a/src/common/evqueue.h +++ b/src/common/evqueue.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_COMMON_EVQUEUE_H_ -#define _KNOT_COMMON_EVQUEUE_H_ +#ifndef _KNOTDCOMMON_EVQUEUE_H_ +#define _KNOTDCOMMON_EVQUEUE_H_ #include <pthread.h> #include <signal.h> // sigset_t @@ -179,6 +179,6 @@ static inline void evqueue_set(evqueue_t *q) { s_evqueue = q; } -#endif /* _KNOT_COMMON_EVQUEUE_H_ */ +#endif /* _KNOTDCOMMON_EVQUEUE_H_ */ /*! @} */ diff --git a/src/common/evsched.h b/src/common/evsched.h index 727d601318db126586c89e9703d028b0b759676d..d674b3fc4172917bd3e81bc2f6fd867c33fec4d2 100644 --- a/src/common/evsched.h +++ b/src/common/evsched.h @@ -48,8 +48,8 @@ * @{ */ -#ifndef _KNOT_COMMON_EVSCHED_H_ -#define _KNOT_COMMON_EVSCHED_H_ +#ifndef _KNOTDCOMMON_EVSCHED_H_ +#define _KNOTDCOMMON_EVSCHED_H_ #include <pthread.h> #include "common/slab/slab.h" @@ -198,6 +198,6 @@ static inline void evsched_set(evsched_t *s) { } -#endif /* _KNOT_COMMON_EVSCHED_H_ */ +#endif /* _KNOTDCOMMON_EVSCHED_H_ */ /*! @} */ diff --git a/src/common/general-tree.h b/src/common/general-tree.h index bde9575ea874c49fb5220369fec40c4fd23a0673..c152e105affda4e74982752ed05eca617527363d 100644 --- a/src/common/general-tree.h +++ b/src/common/general-tree.h @@ -1,5 +1,5 @@ -#ifndef _KNOT_COMMON_GENERAL_TREE_H_ -#define _KNOT_COMMON_GENERAL_TREE_H_ +#ifndef _KNOTDCOMMON_GENERAL_TREE_H_ +#define _KNOTDCOMMON_GENERAL_TREE_H_ #include "common/modified_tree.h" @@ -52,4 +52,4 @@ int gen_tree_find_less_or_equal(general_tree_t *tree, general_tree_t *gen_tree_shallow_copy(general_tree_t *tree); -#endif // _KNOT_COMMON_GENERAL_TREE_H_ +#endif // _KNOTDCOMMON_GENERAL_TREE_H_ diff --git a/src/common/latency.h b/src/common/latency.h index 293fae1bac2204269fcd54eddc9ebe26c378f5d2..1705290d3331dd6ac00b38b68ee8fb3f98d1aade 100644 --- a/src/common/latency.h +++ b/src/common/latency.h @@ -12,8 +12,8 @@ * @{ */ -#ifndef _KNOT_COMMON_LATENCY_H_ -#define _KNOT_COMMON_LATENCY_H_ +#ifndef _KNOTDCOMMON_LATENCY_H_ +#define _KNOTDCOMMON_LATENCY_H_ /* Optional. */ #ifdef PROF_LATENCY @@ -95,6 +95,6 @@ int pf_pthread_mutex_unlock(pthread_mutex_t *mutex, #define perf_end(d) #endif // PROF_LATENCY -#endif // _KNOT_COMMON_LATENCY_H_ +#endif // _KNOTDCOMMON_LATENCY_H_ /*! @} */ diff --git a/src/common/print.h b/src/common/print.h index 18d5c086df325ac3892609a993ec6b620ea75a28..675d2d4ab3762ed4c7aa9b6ab5c6876feef81b6b 100644 --- a/src/common/print.h +++ b/src/common/print.h @@ -12,8 +12,8 @@ * @{ */ -#ifndef _KNOT_COMMON_PRINT_H_ -#define _KNOT_COMMON_PRINT_H_ +#ifndef _KNOTDCOMMON_PRINT_H_ +#define _KNOTDCOMMON_PRINT_H_ typedef int (*printf_t)(const char *fmt, ...); @@ -52,6 +52,6 @@ void bit_print(const char *data, int length); */ void bit_printf(const char *data, int length, printf_t print_handler); -#endif /* _KNOT_COMMON_PRINT_H_ */ +#endif /* _KNOTDCOMMON_PRINT_H_ */ /*! @} */ diff --git a/src/common/ref.h b/src/common/ref.h index 03bda19505992a39e86427c9d8e318d073fe4a04..2326e83fe2c427c46c4b8b2c01dcaf04b2908d67 100644 --- a/src/common/ref.h +++ b/src/common/ref.h @@ -12,8 +12,8 @@ * @{ */ -#ifndef _KNOT_REF_H_ -#define _KNOT_REF_H_ +#ifndef _KNOTDREF_H_ +#define _KNOTDREF_H_ #include <stddef.h> @@ -70,6 +70,6 @@ void ref_retain(ref_t *p); */ void ref_release(ref_t *p); -#endif /* _KNOT_REF_H_ */ +#endif /* _KNOTDREF_H_ */ /*! @} */ diff --git a/src/common/skip-list.h b/src/common/skip-list.h index 7726a5496814fdc8bffbcc66af7e994004c5e107..c30c7d75969deead2b1a7fa9e3ea5d07bc713a2c 100644 --- a/src/common/skip-list.h +++ b/src/common/skip-list.h @@ -41,8 +41,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Retrieved from: http://en.literateprograms.org/Skip_list_(C)?oldid=12811 */ -#ifndef _KNOT_COMMON_SKIP_LIST_H_ -#define _KNOT_COMMON_SKIP_LIST_H_ +#ifndef _KNOTDCOMMON_SKIP_LIST_H_ +#define _KNOTDCOMMON_SKIP_LIST_H_ /*----------------------------------------------------------------------------*/ /*! @@ -210,6 +210,6 @@ void skip_print_list(const skip_list_t *list, */ skip_list_t *skip_copy_list(const skip_list_t *list); -#endif /* _KNOT_COMMON_SKIP_LIST_H_ */ +#endif /* _KNOTDCOMMON_SKIP_LIST_H_ */ /*! @} */ diff --git a/src/common/slab/alloc-common.h b/src/common/slab/alloc-common.h index 4ce97172c95de43b56d109dc724ffb682f433fab..00dfae0703ccd0f822a11bde74dd76e46f3b35d3 100644 --- a/src/common/slab/alloc-common.h +++ b/src/common/slab/alloc-common.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_COMMON_ALLOC_COMMON_H_ -#define _KNOT_COMMON_ALLOC_COMMON_H_ +#ifndef _KNOTDCOMMON_ALLOC_COMMON_H_ +#define _KNOTDCOMMON_ALLOC_COMMON_H_ #include <stdio.h> @@ -41,6 +41,6 @@ #endif -#endif /* _KNOT_COMMON_ALLOC_COMMON_H_ */ +#endif /* _KNOTDCOMMON_ALLOC_COMMON_H_ */ /*! @} */ diff --git a/src/common/slab/malloc.h b/src/common/slab/malloc.h index 6bd2e95e520e435043152cae514a86d264b85b19..4f3d11e78b076cf783f193e986f08ebdcfb96f3d 100644 --- a/src/common/slab/malloc.h +++ b/src/common/slab/malloc.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_COMMON_MALLOC_H_ -#define _KNOT_COMMON_MALLOC_H_ +#ifndef _KNOTDCOMMON_MALLOC_H_ +#define _KNOTDCOMMON_MALLOC_H_ #include <stdlib.h> @@ -23,6 +23,6 @@ */ void usage_dump(); -#endif // _KNOT_COMMON_MALLOC_H_ +#endif // _KNOTDCOMMON_MALLOC_H_ /*! @} */ diff --git a/src/common/slab/slab.h b/src/common/slab/slab.h index 09b8e05a5ec25bf3397753fcf8d05bc6513fef30..3bc7be70a17b4f1d22a72a59b5bef7b138a75eb0 100644 --- a/src/common/slab/slab.h +++ b/src/common/slab/slab.h @@ -67,8 +67,8 @@ * @{ */ -#ifndef _KNOT_COMMON_SLAB_H_ -#define _KNOT_COMMON_SLAB_H_ +#ifndef _KNOTDCOMMON_SLAB_H_ +#define _KNOTDCOMMON_SLAB_H_ #include <pthread.h> #include <stdint.h> @@ -333,6 +333,6 @@ void *slab_alloc_realloc(slab_alloc_t* alloc, void *ptr, size_t size); */ void slab_alloc_stats(slab_alloc_t* alloc); -#endif /* _KNOT_COMMON_SLAB_H_ */ +#endif /* _KNOTDCOMMON_SLAB_H_ */ /*! @} */ diff --git a/src/common/sockaddr.h b/src/common/sockaddr.h index d93fc6a353fcb9547a9019214ddc04ec6703cbc5..aeee2f089f8b1315e3d17177ceebd45cbabbf979 100644 --- a/src/common/sockaddr.h +++ b/src/common/sockaddr.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_SOCKADDR_H_ -#define _KNOT_SOCKADDR_H_ +#ifndef _KNOTDSOCKADDR_H_ +#define _KNOTDSOCKADDR_H_ /* BSD IPv6 */ #ifndef __POSIX_VISIBLE @@ -100,6 +100,6 @@ int sockaddr_tostr(sockaddr_t *addr, char *dst, size_t size); */ int sockaddr_portnum(sockaddr_t *addr); -#endif /* _KNOT_SOCKADDR_H_ */ +#endif /* _KNOTDSOCKADDR_H_ */ /*! @} */ diff --git a/src/dnslib/changesets.c b/src/dnslib/changesets.c index f73c9e119c25f2f3de1f47da5ab560d228c4ebfc..f2b63353c73cced64002c0ceaa91eee04eff7ab0 100644 --- a/src/dnslib/changesets.c +++ b/src/dnslib/changesets.c @@ -7,10 +7,10 @@ #include "dnslib/rrset.h" #include "dnslib/error.h" -static const size_t DNSLIB_CHANGESET_COUNT = 5; -static const size_t DNSLIB_CHANGESET_STEP = 5; -static const size_t DNSLIB_CHANGESET_RRSET_COUNT = 5; -static const size_t DNSLIB_CHANGESET_RRSET_STEP = 5; +static const size_t KNOT_CHANGESET_COUNT = 5; +static const size_t KNOT_CHANGESET_STEP = 5; +static const size_t KNOT_CHANGESET_RRSET_COUNT = 5; +static const size_t KNOT_CHANGESET_RRSET_STEP = 5; /*----------------------------------------------------------------------------*/ @@ -20,21 +20,21 @@ static int knot_changeset_check_count(knot_rrset_t ***rrsets, size_t count, // this should also do for the initial case (*rrsets == NULL) if (count == *allocated) { knot_rrset_t **rrsets_new = (knot_rrset_t **)calloc( - *allocated + DNSLIB_CHANGESET_RRSET_STEP, + *allocated + KNOT_CHANGESET_RRSET_STEP, sizeof(knot_rrset_t *)); if (rrsets_new == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } memcpy(rrsets_new, *rrsets, count); knot_rrset_t **rrsets_old = *rrsets; *rrsets = rrsets_new; - *allocated += DNSLIB_CHANGESET_RRSET_STEP; + *allocated += KNOT_CHANGESET_RRSET_STEP; free(rrsets_old); } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -42,8 +42,8 @@ static int knot_changeset_check_count(knot_rrset_t ***rrsets, size_t count, static int knot_changeset_rrsets_match(const knot_rrset_t *rrset1, const knot_rrset_t *rrset2) { - return knot_rrset_compare(rrset1, rrset2, DNSLIB_RRSET_COMPARE_HEADER) - && (knot_rrset_type(rrset1) != DNSLIB_RRTYPE_RRSIG + return knot_rrset_compare(rrset1, rrset2, KNOT_RRSET_COMPARE_HEADER) + && (knot_rrset_type(rrset1) != KNOT_RRTYPE_RRSIG || knot_rdata_rrsig_type_covered( knot_rrset_rdata(rrset1)) == knot_rdata_rrsig_type_covered( @@ -59,7 +59,7 @@ int knot_changeset_allocate(knot_changesets_t **changesets) calloc(1, sizeof(knot_changesets_t))); if (*changesets == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } assert((*changesets)->allocated == 0); @@ -76,13 +76,13 @@ int knot_changeset_add_rrset(knot_rrset_t ***rrsets, knot_rrset_t *rrset) { int ret = knot_changeset_check_count(rrsets, *count, allocated); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } (*rrsets)[(*count)++] = rrset; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -100,14 +100,14 @@ int knot_changeset_add_rr(knot_rrset_t ***rrsets, size_t *count, if (i < *count) { // found RRSet to merge the new one into if (knot_rrset_merge((void **)&(*rrsets)[i], - (void **)&rr) != DNSLIB_EOK) { - return DNSLIB_ERROR; + (void **)&rr) != KNOT_EOK) { + return KNOT_ERROR; } // remove the RR knot_rrset_deep_free(&rr, 1, 1, 1); - return DNSLIB_EOK; + return KNOT_EOK; } else { return knot_changeset_add_rrset(rrsets, count, allocated, rr); } @@ -143,7 +143,7 @@ int knot_changeset_add_new_rr(knot_changeset_t *changeset, assert(allocated != NULL); int ret = knot_changeset_add_rr(rrsets, count, allocated, rrset); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } @@ -178,7 +178,7 @@ int knot_changeset_add_soa(knot_changeset_t *changeset, knot_rrset_t *soa, } /*! \todo Remove return value? */ - return DNSLIB_EOK; + return KNOT_EOK; } /*---------------------------------------------------------------------------*/ @@ -187,21 +187,21 @@ int knot_changesets_check_size(knot_changesets_t *changesets) { if (changesets->allocated == changesets->count) { knot_changeset_t *sets = (knot_changeset_t *)calloc( - changesets->allocated + DNSLIB_CHANGESET_STEP, + changesets->allocated + KNOT_CHANGESET_STEP, sizeof(knot_changeset_t)); if (sets == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } /*! \todo realloc() may be more effective. */ memcpy(sets, changesets->sets, changesets->count); knot_changeset_t *old_sets = changesets->sets; changesets->sets = sets; - changesets->count += DNSLIB_CHANGESET_STEP; + changesets->count += KNOT_CHANGESET_STEP; free(old_sets); } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ diff --git a/src/dnslib/changesets.h b/src/dnslib/changesets.h index d03182e874154f4814e1214d8fd53f31c1510897..c64e55e67c80387898822550c8e2aff8d5f6dba8 100644 --- a/src/dnslib/changesets.h +++ b/src/dnslib/changesets.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_CHANGESETS_H_ -#define _KNOT_DNSLIB_CHANGESETS_H_ +#ifndef _KNOTDKNOT_CHANGESETS_H_ +#define _KNOTDKNOT_CHANGESETS_H_ #include "dnslib/rrset.h" @@ -79,6 +79,6 @@ int knot_changesets_check_size(knot_changesets_t *changesets); void knot_free_changesets(knot_changesets_t **changesets); -#endif /* _KNOT_DNSLIB_CHANGESETS_H_ */ +#endif /* _KNOTDKNOT_CHANGESETS_H_ */ /*! @} */ diff --git a/src/dnslib/consts.h b/src/dnslib/consts.h index ef2f3cf8c4ae8b5870cb4c28de7b9d41d68849cd..819acfcc440a789816a88057aad1c05bb95b3b21 100644 --- a/src/dnslib/consts.h +++ b/src/dnslib/consts.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_CONSTS_H_ -#define _KNOT_DNSLIB_CONSTS_H_ +#ifndef _KNOTDKNOT_CONSTS_H_ +#define _KNOTDKNOT_CONSTS_H_ #include <stdint.h> #include "dnslib/descriptor.h" @@ -19,12 +19,12 @@ * OPCODEs */ typedef enum knot_opcode { - DNSLIB_OPCODE_QUERY = 0, /* a standard query (QUERY) */ - DNSLIB_OPCODE_IQUERY = 1, /* an inverse query (IQUERY) */ - DNSLIB_OPCODE_STATUS = 2, /* a server status request (STATUS) */ - DNSLIB_OPCODE_NOTIFY = 4, /* NOTIFY */ - DNSLIB_OPCODE_UPDATE = 5, /* Dynamic update */ - DNSLIB_OPCODE_OFFSET = 14 + KNOT_OPCODE_QUERY = 0, /* a standard query (QUERY) */ + KNOT_OPCODE_IQUERY = 1, /* an inverse query (IQUERY) */ + KNOT_OPCODE_STATUS = 2, /* a server status request (STATUS) */ + KNOT_OPCODE_NOTIFY = 4, /* NOTIFY */ + KNOT_OPCODE_UPDATE = 5, /* Dynamic update */ + KNOT_OPCODE_OFFSET = 14 } knot_opcode_t; /*! @@ -34,54 +34,54 @@ typedef enum knot_opcode { * OPCODE and the QTYPE. */ typedef enum knot_packet_type { - DNSLIB_QUERY_NORMAL, /*!< Normal query. */ - DNSLIB_QUERY_AXFR, /*!< Request for AXFR transfer. */ - DNSLIB_QUERY_IXFR, /*!< Request for IXFR transfer. */ - DNSLIB_QUERY_NOTIFY, /*!< NOTIFY query. */ - DNSLIB_QUERY_UPDATE, /*!< Dynamic update. */ - DNSLIB_RESPONSE_NORMAL, /*!< Normal response. */ - DNSLIB_RESPONSE_AXFR, /*!< AXFR transfer response. */ - DNSLIB_RESPONSE_IXFR, /*!< IXFR transfer response. */ - DNSLIB_RESPONSE_NOTIFY /*!< NOTIFY response. */ + KNOT_QUERY_NORMAL, /*!< Normal query. */ + KNOT_QUERY_AXFR, /*!< Request for AXFR transfer. */ + KNOT_QUERY_IXFR, /*!< Request for IXFR transfer. */ + KNOT_QUERY_NOTIFY, /*!< NOTIFY query. */ + KNOT_QUERY_UPDATE, /*!< Dynamic update. */ + KNOT_RESPONSE_NORMAL, /*!< Normal response. */ + KNOT_RESPONSE_AXFR, /*!< AXFR transfer response. */ + KNOT_RESPONSE_IXFR, /*!< IXFR transfer response. */ + KNOT_RESPONSE_NOTIFY /*!< NOTIFY response. */ } knot_packet_type_t; /* * RCODEs */ typedef enum knot_rcode { - DNSLIB_RCODE_NOERROR = 0, /* No error condition */ - DNSLIB_RCODE_FORMERR = 1, /* Format error */ - DNSLIB_RCODE_SERVFAIL = 2, /* Server failure */ - DNSLIB_RCODE_NXDOMAIN = 3, /* Name Error */ - DNSLIB_RCODE_NOTIMPL = 4, /* Not implemented */ - DNSLIB_RCODE_REFUSED = 5, /* Refused */ - DNSLIB_RCODE_YXDOMAIN = 6, /* name should not exist */ - DNSLIB_RCODE_YXRRSET = 7, /* rrset should not exist */ - DNSLIB_RCODE_NXRRSET = 8, /* rrset does not exist */ - DNSLIB_RCODE_NOTAUTH = 9, /* server not authoritative */ - DNSLIB_RCODE_NOTZONE = 10 /* name not inside zone */ + KNOT_RCODE_NOERROR = 0, /* No error condition */ + KNOT_RCODE_FORMERR = 1, /* Format error */ + KNOT_RCODE_SERVFAIL = 2, /* Server failure */ + KNOT_RCODE_NXDOMAIN = 3, /* Name Error */ + KNOT_RCODE_NOTIMPL = 4, /* Not implemented */ + KNOT_RCODE_REFUSED = 5, /* Refused */ + KNOT_RCODE_YXDOMAIN = 6, /* name should not exist */ + KNOT_RCODE_YXRRSET = 7, /* rrset should not exist */ + KNOT_RCODE_NXRRSET = 8, /* rrset does not exist */ + KNOT_RCODE_NOTAUTH = 9, /* server not authoritative */ + KNOT_RCODE_NOTZONE = 10 /* name not inside zone */ } knot_rcode_t; /* * CLASSes */ //typedef enum knot_class { -// DNSLIB_CLASS_IN = 1, /* Class IN */ -// DNSLIB_CLASS_CS = 2, /* Class CS */ -// DNSLIB_CLASS_CH = 3, /* Class CHAOS */ -// DNSLIB_CLASS_HS = 4, /* Class HS */ -// DNSLIB_CLASS_NONE = 254, /* Class NONE rfc2136 */ -// DNSLIB_CLASS_ANY = 255 /* Class ANY */ +// KNOT_CLASS_IN = 1, /* Class IN */ +// KNOT_CLASS_CS = 2, /* Class CS */ +// KNOT_CLASS_CH = 3, /* Class CHAOS */ +// KNOT_CLASS_HS = 4, /* Class HS */ +// KNOT_CLASS_NONE = 254, /* Class NONE rfc2136 */ +// KNOT_CLASS_ANY = 255 /* Class ANY */ //} knot_class_t; /* * Other */ typedef enum knot_const { - DNSLIB_MAX_DNAME_LENGTH = 255, - DNSLIB_MAX_DNAME_LABELS = 127 // 1-char labels + KNOT_MAX_DNAME_LENGTH = 255, + KNOT_MAX_DNAME_LABELS = 127 // 1-char labels } knot_const_t; -#endif /* _KNOT_DNSLIB_CONSTS_H_ */ +#endif /* _KNOTDKNOT_CONSTS_H_ */ /*! @} */ diff --git a/src/dnslib/debug.c b/src/dnslib/debug.c index fd0da7f4a9f45d4ef96c3b7668097115e9385cd9..afb5dffd6f8e6921c73aaa2a3b189ea55bf7ff62 100644 --- a/src/dnslib/debug.c +++ b/src/dnslib/debug.c @@ -11,7 +11,7 @@ void knot_rdata_dump(knot_rdata_t *rdata, uint32_t type, char loaded_zone) { -#if defined(DNSLIB_ZONE_DEBUG) || defined(DNSLIB_RDATA_DEBUG) +#if defined(KNOT_ZONE_DEBUG) || defined(KNOT_RDATA_DEBUG) printf(" ------- RDATA -------\n"); if (rdata == NULL) { printf(" There are no rdata in this RRset!\n"); @@ -23,9 +23,9 @@ void knot_rdata_dump(knot_rdata_t *rdata, uint32_t type, char loaded_zone) char *name; for (int i = 0; i < rdata->count; i++) { - if (desc->wireformat[i] == DNSLIB_RDATA_WF_COMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_LITERAL_DNAME ) { + if (desc->wireformat[i] == KNOT_RDATA_WF_COMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_UNCOMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_LITERAL_DNAME ) { assert(rdata->items[i].dname != NULL); name = knot_dname_to_str(rdata->items[i].dname); printf(" DNAME: %d: %s\n", @@ -61,7 +61,7 @@ void knot_rdata_dump(knot_rdata_t *rdata, uint32_t type, char loaded_zone) void knot_rrset_dump(knot_rrset_t *rrset, char loaded_zone) { -#if defined(DNSLIB_ZONE_DEBUG) || defined(DNSLIB_RRSET_DEBUG) +#if defined(KNOT_ZONE_DEBUG) || defined(KNOT_RRSET_DEBUG) printf(" ------- RRSET -------\n"); printf(" %p\n", rrset); char *name = knot_dname_to_str(rrset->owner); @@ -99,7 +99,7 @@ void knot_rrset_dump(knot_rrset_t *rrset, char loaded_zone) void knot_node_dump(knot_node_t *node, void *loaded_zone) { -#if defined(DNSLIB_ZONE_DEBUG) || defined(DNSLIB_NODE_DEBUG) +#if defined(KNOT_ZONE_DEBUG) || defined(KNOT_NODE_DEBUG) //char loaded_zone = *((char*) data); char *name; @@ -174,7 +174,7 @@ void knot_node_dump(knot_node_t *node, void *loaded_zone) void knot_zone_contents_dump(knot_zone_contents_t *zone, char loaded_zone) { -#if defined(DNSLIB_ZONE_DEBUG) +#if defined(KNOT_ZONE_DEBUG) printf("------- ZONE --------\n"); knot_zone_contents_tree_apply_inorder(zone, knot_node_dump, (void *)&loaded_zone); diff --git a/src/dnslib/debug.h b/src/dnslib/debug.h index 140e30ccdaa0135f5a4965a3ca4ea04521731c0a..5c753da8a2696705c5f32e05595a7bab41cfb314 100644 --- a/src/dnslib/debug.h +++ b/src/dnslib/debug.h @@ -10,8 +10,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_DEBUG_H_ -#define _KNOT_DNSLIB_DEBUG_H_ +#ifndef _KNOTDKNOT_DEBUG_H_ +#define _KNOTDKNOT_DEBUG_H_ #include <stdint.h> #include <stdio.h> @@ -25,7 +25,7 @@ /*! * \brief Dumps RDATA of the given type. * - * This function is empty if neither DNSLIB_ZONE_DEBUG nor DNSLIB_RDATA_DEBUG + * This function is empty if neither KNOT_ZONE_DEBUG nor KNOT_RDATA_DEBUG * is defined. * * \param rdata RDATA to dump. @@ -38,7 +38,7 @@ void knot_rdata_dump(knot_rdata_t *rdata, uint32_t type, char loaded_zone); /*! * \brief Dumps RRSet. * - * This function is empty if neither DNSLIB_ZONE_DEBUG nor DNSLIB_RRSET_DEBUG + * This function is empty if neither KNOT_ZONE_DEBUG nor KNOT_RRSET_DEBUG * is defined. * * \param rrset RRSet to dump. @@ -50,7 +50,7 @@ void knot_rrset_dump(knot_rrset_t *rrset, char loaded_zone); /*! * \brief Dumps zone node. * - * This function is empty if neither DNSLIB_ZONE_DEBUG nor DNSLIB_NODE_DEBUG + * This function is empty if neither KNOT_ZONE_DEBUG nor KNOT_NODE_DEBUG * is defined. * * \param node Node to dump. @@ -62,7 +62,7 @@ void knot_node_dump(knot_node_t *node, void *loaded_zone); /*! * \brief Dumps the whole zone. * - * This function is empty if DNSLIB_ZONE_DEBUG is not defined. + * This function is empty if KNOT_ZONE_DEBUG is not defined. * * \param zone Zone to dump. * \param loaded_zone Set to <> 0 if the node is part of a zone loaded into @@ -73,126 +73,126 @@ void knot_zone_contents_dump(knot_zone_contents_t *zone, char loaded_zone); /* * Debug macros */ -//#define DNSLIB_ZONE_DEBUG -//#define DNSLIB_RESPONSE_DEBUG -//#define DNSLIB_ZONEDB_DEBUG -//#define DNSLIB_DNAME_DEBUG -//#define DNSLIB_NODE_DEBUG -//#define DNSLIB_RESPONSE_DEBUG -//#define DNSLIB_PACKET_DEBUG -//#define DNSLIB_EDNS_DEBUG -//#define DNSLIB_RRSET_DEBUG -//#define DNSLIB_NSEC3_DEBUG -//#define DNSLIB_ZDUMP_DEBUG -//#define DNSLIB_ZLOAD_DEBUG +//#define KNOT_ZONE_DEBUG +//#define KNOT_RESPONSE_DEBUG +//#define KNOT_ZONEDB_DEBUG +//#define KNOT_DNAME_DEBUG +//#define KNOT_NODE_DEBUG +//#define KNOT_RESPONSE_DEBUG +//#define KNOT_PACKET_DEBUG +//#define KNOT_EDNS_DEBUG +//#define KNOT_RRSET_DEBUG +//#define KNOT_NSEC3_DEBUG +//#define KNOT_ZDUMP_DEBUG +//#define KNOT_ZLOAD_DEBUG //#define CUCKOO_DEBUG //#define CUCKOO_DEBUG_HASH -//#define DNSLIB_NS_DEBUG -//#define DNSLIB_XFR_DEBUG +//#define KNOT_NS_DEBUG +//#define KNOT_XFR_DEBUG -#ifdef DNSLIB_XFR_DEBUG +#ifdef KNOT_XFR_DEBUG #define debug_knot_xfr(msg...) fprintf(stderr, msg) #define debug_knot_xfr_hex(data, len) hex_print((data), (len)) -#define DEBUG_DNSLIB_NS(cmds) do { cmds } while (0) +#define DEBUG_KNOT_NS(cmds) do { cmds } while (0) #else #define debug_knot_xfr(msg...) #define debug_knot_xfr_hex(data, len) -#define DEBUG_DNSLIB_XFR(cmds) +#define DEBUG_KNOT_XFR(cmds) #endif -#ifdef DNSLIB_NS_DEBUG +#ifdef KNOT_NS_DEBUG #define debug_knot_ns(msg...) fprintf(stderr, msg) #define debug_knot_ns_hex(data, len) hex_print((data), (len)) -#define DEBUG_DNSLIB_NS(cmds) do { cmds } while (0) +#define DEBUG_KNOT_NS(cmds) do { cmds } while (0) #else #define debug_knot_ns(msg...) #define debug_knot_ns_hex(data, len) -#define DEBUG_DNSLIB_NS(cmds) +#define DEBUG_KNOT_NS(cmds) #endif -#ifdef DNSLIB_DNAME_DEBUG +#ifdef KNOT_DNAME_DEBUG #define debug_knot_dname(msg...) fprintf(stderr, msg) #define debug_knot_dname_hex(data, len) hex_print((data), (len)) -#define DEBUG_DNSLIB_DNAME(cmds) do { cmds } while (0) +#define DEBUG_KNOT_DNAME(cmds) do { cmds } while (0) #else #define debug_knot_dname(msg...) #define debug_knot_dname_hex(data, len) -#define DEBUG_DNSLIB_DNAME(cmds) +#define DEBUG_KNOT_DNAME(cmds) #endif -#ifdef DNSLIB_NODE_DEBUG +#ifdef KNOT_NODE_DEBUG #define debug_knot_node(msg...) fprintf(stderr, msg) #define debug_knot_node_hex(data, len) hex_print((data), (len)) -#define DEBUG_DNSLIB_node(cmds) do { cmds } while (0) +#define DEBUG_KNOT_node(cmds) do { cmds } while (0) #else #define debug_knot_node(msg...) #define debug_knot_node_hex(data, len) -#define DEBUG_DNSLIB_NODE(cmds) +#define DEBUG_KNOT_NODE(cmds) #endif -#ifdef DNSLIB_ZONE_DEBUG +#ifdef KNOT_ZONE_DEBUG #define debug_knot_zone(msg...) fprintf(stderr, msg) #define debug_knot_zone_hex(data, len) hex_print((data), (len)) -#define DEBUG_DNSLIB_ZONE(cmds) do { cmds } while (0) +#define DEBUG_KNOT_ZONE(cmds) do { cmds } while (0) #else #define debug_knot_zone(msg...) #define debug_knot_zone_hex(data, len) -#define DEBUG_DNSLIB_ZONE(cmds) +#define DEBUG_KNOT_ZONE(cmds) #endif -#ifdef DNSLIB_ZONEDB_DEBUG +#ifdef KNOT_ZONEDB_DEBUG #define debug_knot_zonedb(msg...) fprintf(stderr, msg) -#define DEBUG_DNSLIB_ZONEDB(cmds) do { cmds } while (0) +#define DEBUG_KNOT_ZONEDB(cmds) do { cmds } while (0) #else #define debug_knot_zonedb(msg...) -#define DEBUG_DNSLIB_ZONEDB(cmds) +#define DEBUG_KNOT_ZONEDB(cmds) #endif -#ifdef DNSLIB_RESPONSE_DEBUG +#ifdef KNOT_RESPONSE_DEBUG #define debug_knot_response(msg...) fprintf(stderr, msg) #define debug_knot_response_hex(data, len) hex_print((data), (len)) -#define DEBUG_DNSLIB_RESPONSE(cmds) do { cmds } while (0) +#define DEBUG_KNOT_RESPONSE(cmds) do { cmds } while (0) #else #define debug_knot_response(msg...) #define debug_knot_response_hex(data, len) -#define DEBUG_DNSLIB_RESPONSE(cmds) +#define DEBUG_KNOT_RESPONSE(cmds) #endif -#ifdef DNSLIB_PACKET_DEBUG +#ifdef KNOT_PACKET_DEBUG #define debug_knot_packet(msg...) fprintf(stderr, msg) #define debug_knot_packet_hex(data, len) hex_print((data), (len)) -#define DEBUG_DNSLIB_PACKET(cmds) do { cmds } while (0) +#define DEBUG_KNOT_PACKET(cmds) do { cmds } while (0) #else #define debug_knot_packet(msg...) #define debug_knot_packet_hex(data, len) -#define DEBUG_DNSLIB_PACKET(cmds) +#define DEBUG_KNOT_PACKET(cmds) #endif -#ifdef DNSLIB_EDNS_DEBUG +#ifdef KNOT_EDNS_DEBUG #define debug_knot_edns(msg...) fprintf(stderr, msg) #else #define debug_knot_edns(msg...) #endif -#ifdef DNSLIB_NSEC3_DEBUG +#ifdef KNOT_NSEC3_DEBUG #define debug_knot_nsec3(msg...) fprintf(stderr, msg) #define debug_knot_nsec3_hex(data, len) hex_print((data), (len)) -#define DEBUG_DNSLIB_NSEC3(cmds) do { cmds } while (0) +#define DEBUG_KNOT_NSEC3(cmds) do { cmds } while (0) #else #define debug_knot_nsec3(msg...) #define debug_knot_nsec3_hex(data, len) -#define DEBUG_DNSLIB_NSEC3(cmds) +#define DEBUG_KNOT_NSEC3(cmds) #endif -#ifdef DNSLIB_ZDUMP_DEBUG +#ifdef KNOT_ZDUMP_DEBUG #define debug_knot_zdump(msg...) fprintf(stderr, msg) -#define DEBUG_DNSLIB_ZDUMP(cmds) do { cmds } while (0) +#define DEBUG_KNOT_ZDUMP(cmds) do { cmds } while (0) #else #define debug_knot_zdump(msg...) -#define DEBUG_DNSLIB_ZDUMP(cmds) +#define DEBUG_KNOT_ZDUMP(cmds) #endif -#ifdef DNSLIB_ZLOAD_DEBUG +#ifdef KNOT_ZLOAD_DEBUG #define debug_knot_zload(msg...) fprintf(stderr, msg) #else #define debug_knot_zload(msg...) @@ -214,14 +214,14 @@ void knot_zone_contents_dump(knot_zone_contents_t *zone, char loaded_zone); #define debug_ck_rehash(msg...) #endif -#ifdef DNSLIB_XFR_DEBUG +#ifdef KNOT_XFR_DEBUG #define debug_knot_xfr(msg...) fprintf(stderr, msg) #define debug_knot_xfr_hex(data, len) hex_print((data), (len)) -#define DEBUG_DNSLIB_XFR(cmds) do { cmds } while (0) +#define DEBUG_KNOT_XFR(cmds) do { cmds } while (0) #else #define debug_knot_xfr(msg...) #define debug_knot_xfr_hex(data, len) -#define DEBUG_DNSLIB_XFR(cmds) +#define DEBUG_KNOT_XFR(cmds) #endif #endif diff --git a/src/dnslib/descriptor.c b/src/dnslib/descriptor.c index cfc817ee35f5de497ec726f4e982329ed9182ad4..4d3f644b41c7e42958a66f9b164501cfd9e78e12 100644 --- a/src/dnslib/descriptor.c +++ b/src/dnslib/descriptor.c @@ -9,352 +9,352 @@ #include "dnslib/dnslib.h" -enum desclen { DNSLIB_RRTYPE_DESCRIPTORS_LENGTH = 32770 }; // used to be 101 +enum desclen { KNOT_RRTYPE_DESCRIPTORS_LENGTH = 32770 }; // used to be 101 /*! * \brief Table for linking RR class constants to their textual representation. */ static knot_lookup_table_t dns_rrclasses[] = { - { DNSLIB_CLASS_IN, "IN" }, /* the Internet */ - { DNSLIB_CLASS_CS, "CS" }, /* the CSNET class (Obsolete) */ - { DNSLIB_CLASS_CH, "CH" }, /* the CHAOS class */ - { DNSLIB_CLASS_HS, "HS" }, /* Hesiod */ + { KNOT_CLASS_IN, "IN" }, /* the Internet */ + { KNOT_CLASS_CS, "CS" }, /* the CSNET class (Obsolete) */ + { KNOT_CLASS_CH, "CH" }, /* the CHAOS class */ + { KNOT_CLASS_HS, "HS" }, /* Hesiod */ { 0, NULL } }; /*! \brief RR type descriptors. */ static knot_rrtype_descriptor_t - knot_rrtype_descriptors[DNSLIB_RRTYPE_DESCRIPTORS_LENGTH] = { + knot_rrtype_descriptors[KNOT_RRTYPE_DESCRIPTORS_LENGTH] = { /* 0 */ - { 0, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, { DNSLIB_RDATA_ZF_UNKNOWN }, true }, + { 0, NULL, 1, { KNOT_RDATA_WF_BINARY }, { KNOT_RDATA_ZF_UNKNOWN }, true }, /* 1 */ - { DNSLIB_RRTYPE_A, "A", 1, { DNSLIB_RDATA_WF_A }, { DNSLIB_RDATA_ZF_A }, true }, + { KNOT_RRTYPE_A, "A", 1, { KNOT_RDATA_WF_A }, { KNOT_RDATA_ZF_A }, true }, /* 2 */ - { DNSLIB_RRTYPE_NS, "NS", 1, - { DNSLIB_RDATA_WF_COMPRESSED_DNAME }, { DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_NS, "NS", 1, + { KNOT_RDATA_WF_COMPRESSED_DNAME }, { KNOT_RDATA_ZF_DNAME }, true }, /* 3 */ - { DNSLIB_RRTYPE_MD, "MD", 1, - { DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, { DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_MD, "MD", 1, + { KNOT_RDATA_WF_UNCOMPRESSED_DNAME }, { KNOT_RDATA_ZF_DNAME }, true }, /* 4 */ - { DNSLIB_RRTYPE_MF, "MF", 1, - { DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, { DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_MF, "MF", 1, + { KNOT_RDATA_WF_UNCOMPRESSED_DNAME }, { KNOT_RDATA_ZF_DNAME }, true }, /* 5 */ - { DNSLIB_RRTYPE_CNAME, "CNAME", 1, - { DNSLIB_RDATA_WF_COMPRESSED_DNAME }, { DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_CNAME, "CNAME", 1, + { KNOT_RDATA_WF_COMPRESSED_DNAME }, { KNOT_RDATA_ZF_DNAME }, true }, /* 6 */ - { DNSLIB_RRTYPE_SOA, "SOA", 7, - { DNSLIB_RDATA_WF_COMPRESSED_DNAME, DNSLIB_RDATA_WF_COMPRESSED_DNAME, - DNSLIB_RDATA_WF_LONG, DNSLIB_RDATA_WF_LONG, DNSLIB_RDATA_WF_LONG, - DNSLIB_RDATA_WF_LONG, DNSLIB_RDATA_WF_LONG }, - { DNSLIB_RDATA_ZF_DNAME, DNSLIB_RDATA_ZF_DNAME, DNSLIB_RDATA_ZF_PERIOD, DNSLIB_RDATA_ZF_PERIOD, - DNSLIB_RDATA_ZF_PERIOD, DNSLIB_RDATA_ZF_PERIOD, DNSLIB_RDATA_ZF_PERIOD }, + { KNOT_RRTYPE_SOA, "SOA", 7, + { KNOT_RDATA_WF_COMPRESSED_DNAME, KNOT_RDATA_WF_COMPRESSED_DNAME, + KNOT_RDATA_WF_LONG, KNOT_RDATA_WF_LONG, KNOT_RDATA_WF_LONG, + KNOT_RDATA_WF_LONG, KNOT_RDATA_WF_LONG }, + { KNOT_RDATA_ZF_DNAME, KNOT_RDATA_ZF_DNAME, KNOT_RDATA_ZF_PERIOD, KNOT_RDATA_ZF_PERIOD, + KNOT_RDATA_ZF_PERIOD, KNOT_RDATA_ZF_PERIOD, KNOT_RDATA_ZF_PERIOD }, true }, /* 7 */ - { DNSLIB_RRTYPE_MB, "MB", 1, - { DNSLIB_RDATA_WF_COMPRESSED_DNAME }, { DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_MB, "MB", 1, + { KNOT_RDATA_WF_COMPRESSED_DNAME }, { KNOT_RDATA_ZF_DNAME }, true }, /* 8 */ - { DNSLIB_RRTYPE_MG, "MG", 1, - { DNSLIB_RDATA_WF_COMPRESSED_DNAME }, { DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_MG, "MG", 1, + { KNOT_RDATA_WF_COMPRESSED_DNAME }, { KNOT_RDATA_ZF_DNAME }, true }, /* 9 */ - { DNSLIB_RRTYPE_MR, "MR", 1, - { DNSLIB_RDATA_WF_COMPRESSED_DNAME }, { DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_MR, "MR", 1, + { KNOT_RDATA_WF_COMPRESSED_DNAME }, { KNOT_RDATA_ZF_DNAME }, true }, /* 10 */ - { DNSLIB_RRTYPE_NULL, NULL, 1, - { DNSLIB_RDATA_WF_BINARY }, { DNSLIB_RDATA_ZF_UNKNOWN }, true }, + { KNOT_RRTYPE_NULL, NULL, 1, + { KNOT_RDATA_WF_BINARY }, { KNOT_RDATA_ZF_UNKNOWN }, true }, /* 11 */ - { DNSLIB_RRTYPE_WKS, "WKS", 2, - { DNSLIB_RDATA_WF_A, DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_A, DNSLIB_RDATA_ZF_SERVICES }, true }, + { KNOT_RRTYPE_WKS, "WKS", 2, + { KNOT_RDATA_WF_A, KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_A, KNOT_RDATA_ZF_SERVICES }, true }, /* 12 */ - { DNSLIB_RRTYPE_PTR, "PTR", 1, - { DNSLIB_RDATA_WF_COMPRESSED_DNAME }, - { DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_PTR, "PTR", 1, + { KNOT_RDATA_WF_COMPRESSED_DNAME }, + { KNOT_RDATA_ZF_DNAME }, true }, /* 13 */ - { DNSLIB_RRTYPE_HINFO, "HINFO", 2, - { DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT }, - { DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT }, true }, + { KNOT_RRTYPE_HINFO, "HINFO", 2, + { KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT }, + { KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT }, true }, /* 14 */ - { DNSLIB_RRTYPE_MINFO, "MINFO", 2, - { DNSLIB_RDATA_WF_COMPRESSED_DNAME, - DNSLIB_RDATA_WF_COMPRESSED_DNAME }, - { DNSLIB_RDATA_ZF_DNAME, DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_MINFO, "MINFO", 2, + { KNOT_RDATA_WF_COMPRESSED_DNAME, + KNOT_RDATA_WF_COMPRESSED_DNAME }, + { KNOT_RDATA_ZF_DNAME, KNOT_RDATA_ZF_DNAME }, true }, /* 15 */ - { DNSLIB_RRTYPE_MX, "MX", 2, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_COMPRESSED_DNAME }, - { DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_MX, "MX", 2, + { KNOT_RDATA_WF_SHORT, KNOT_RDATA_WF_COMPRESSED_DNAME }, + { KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_DNAME }, true }, /* 16 */ /* This is obscure, but I guess there's no other way */ - { DNSLIB_RRTYPE_TXT, "TXT", DNSLIB_MAX_RDATA_ITEMS, - { DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT }, - { DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT }, + { KNOT_RRTYPE_TXT, "TXT", KNOT_MAX_RDATA_ITEMS, + { KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT }, + { KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT }, false }, /* 17 */ - { DNSLIB_RRTYPE_RP, "RP", 2, - { DNSLIB_RDATA_WF_COMPRESSED_DNAME, - DNSLIB_RDATA_WF_COMPRESSED_DNAME }, - { DNSLIB_RDATA_ZF_DNAME, DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_RP, "RP", 2, + { KNOT_RDATA_WF_COMPRESSED_DNAME, + KNOT_RDATA_WF_COMPRESSED_DNAME }, + { KNOT_RDATA_ZF_DNAME, KNOT_RDATA_ZF_DNAME }, true }, /* 18 */ - { DNSLIB_RRTYPE_AFSDB, "AFSDB", 2, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_COMPRESSED_DNAME }, - { DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_AFSDB, "AFSDB", 2, + { KNOT_RDATA_WF_SHORT, KNOT_RDATA_WF_COMPRESSED_DNAME }, + { KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_DNAME }, true }, /* 19 */ - { DNSLIB_RRTYPE_X25, "X25", 1, - { DNSLIB_RDATA_WF_TEXT }, - { DNSLIB_RDATA_ZF_TEXT }, true }, + { KNOT_RRTYPE_X25, "X25", 1, + { KNOT_RDATA_WF_TEXT }, + { KNOT_RDATA_ZF_TEXT }, true }, /* 20 */ - { DNSLIB_RRTYPE_ISDN, "ISDN", 2, - { DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT }, - { DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT }, false }, + { KNOT_RRTYPE_ISDN, "ISDN", 2, + { KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT }, + { KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT }, false }, /* 21 */ - { DNSLIB_RRTYPE_RT, "RT", 2, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_COMPRESSED_DNAME }, - { DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_RT, "RT", 2, + { KNOT_RDATA_WF_SHORT, KNOT_RDATA_WF_COMPRESSED_DNAME }, + { KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_DNAME }, true }, /* 22 */ - { DNSLIB_RRTYPE_NSAP, "NSAP", 1, - { DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_NSAP }, true }, + { KNOT_RRTYPE_NSAP, "NSAP", 1, + { KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_NSAP }, true }, /* 23 */ - { 23, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_UNKNOWN }, true }, + { 23, NULL, 1, { KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_UNKNOWN }, true }, /* 24 */ - { DNSLIB_RRTYPE_SIG, "SIG", 9, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BYTE, - DNSLIB_RDATA_WF_LONG, DNSLIB_RDATA_WF_LONG, DNSLIB_RDATA_WF_LONG, - DNSLIB_RDATA_WF_SHORT,DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME, - DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_RRTYPE, DNSLIB_RDATA_ZF_BYTE, DNSLIB_RDATA_ZF_BYTE, DNSLIB_RDATA_ZF_PERIOD, - DNSLIB_RDATA_ZF_TIME, DNSLIB_RDATA_ZF_TIME, DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_DNAME, - DNSLIB_RDATA_ZF_BASE64 }, + { KNOT_RRTYPE_SIG, "SIG", 9, + { KNOT_RDATA_WF_SHORT, KNOT_RDATA_WF_BYTE, KNOT_RDATA_WF_BYTE, + KNOT_RDATA_WF_LONG, KNOT_RDATA_WF_LONG, KNOT_RDATA_WF_LONG, + KNOT_RDATA_WF_SHORT,KNOT_RDATA_WF_UNCOMPRESSED_DNAME, + KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_RRTYPE, KNOT_RDATA_ZF_BYTE, KNOT_RDATA_ZF_BYTE, KNOT_RDATA_ZF_PERIOD, + KNOT_RDATA_ZF_TIME, KNOT_RDATA_ZF_TIME, KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_DNAME, + KNOT_RDATA_ZF_BASE64 }, true }, /* 25 */ - { DNSLIB_RRTYPE_KEY, "KEY", 4, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE, - DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_BYTE, DNSLIB_RDATA_ZF_ALGORITHM, - DNSLIB_RDATA_ZF_BASE64 }, true }, + { KNOT_RRTYPE_KEY, "KEY", 4, + { KNOT_RDATA_WF_SHORT, KNOT_RDATA_WF_BYTE, + KNOT_RDATA_WF_BYTE, KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_BYTE, KNOT_RDATA_ZF_ALGORITHM, + KNOT_RDATA_ZF_BASE64 }, true }, /* 26 */ - { DNSLIB_RRTYPE_PX, "PX", 3, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME, - DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, - { DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_DNAME, DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_PX, "PX", 3, + { KNOT_RDATA_WF_SHORT, KNOT_RDATA_WF_UNCOMPRESSED_DNAME, + KNOT_RDATA_WF_UNCOMPRESSED_DNAME }, + { KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_DNAME, KNOT_RDATA_ZF_DNAME }, true }, /* 27 */ - { 27, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, { DNSLIB_RDATA_ZF_UNKNOWN }, true }, + { 27, NULL, 1, { KNOT_RDATA_WF_BINARY }, { KNOT_RDATA_ZF_UNKNOWN }, true }, /* 28 */ - { DNSLIB_RRTYPE_AAAA, "AAAA", 1, - { DNSLIB_RDATA_WF_AAAA }, - { DNSLIB_RDATA_ZF_AAAA }, true }, + { KNOT_RRTYPE_AAAA, "AAAA", 1, + { KNOT_RDATA_WF_AAAA }, + { KNOT_RDATA_ZF_AAAA }, true }, /* 29 */ - { DNSLIB_RRTYPE_LOC, "LOC", 1, - { DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_LOC }, true }, + { KNOT_RRTYPE_LOC, "LOC", 1, + { KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_LOC }, true }, /* 30 */ - { DNSLIB_RRTYPE_NXT, "NXT", 2, - { DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME, - DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_DNAME, DNSLIB_RDATA_ZF_NXT }, true }, + { KNOT_RRTYPE_NXT, "NXT", 2, + { KNOT_RDATA_WF_UNCOMPRESSED_DNAME, + KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_DNAME, KNOT_RDATA_ZF_NXT }, true }, /* 31 */ - { 31, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, { DNSLIB_RDATA_ZF_UNKNOWN }, true }, + { 31, NULL, 1, { KNOT_RDATA_WF_BINARY }, { KNOT_RDATA_ZF_UNKNOWN }, true }, /* 32 */ - { 32, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, { DNSLIB_RDATA_ZF_UNKNOWN }, true }, + { 32, NULL, 1, { KNOT_RDATA_WF_BINARY }, { KNOT_RDATA_ZF_UNKNOWN }, true }, /* 33 */ - { DNSLIB_RRTYPE_SRV, "SRV", 4, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_SHORT, - DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, - { DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_DNAME }, + { KNOT_RRTYPE_SRV, "SRV", 4, + { KNOT_RDATA_WF_SHORT, KNOT_RDATA_WF_SHORT, + KNOT_RDATA_WF_SHORT, KNOT_RDATA_WF_UNCOMPRESSED_DNAME }, + { KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_DNAME }, true }, /* 34 */ - { 34, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, { DNSLIB_RDATA_ZF_UNKNOWN }, true }, + { 34, NULL, 1, { KNOT_RDATA_WF_BINARY }, { KNOT_RDATA_ZF_UNKNOWN }, true }, /* 35 */ - { DNSLIB_RRTYPE_NAPTR, "NAPTR", 6, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, - { DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_NAPTR, "NAPTR", 6, + { KNOT_RDATA_WF_SHORT, KNOT_RDATA_WF_SHORT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_UNCOMPRESSED_DNAME }, + { KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_DNAME }, true }, /* 36 */ - { DNSLIB_RRTYPE_KX, "KX", 2, - { DNSLIB_RDATA_WF_SHORT, - DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, - { DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_KX, "KX", 2, + { KNOT_RDATA_WF_SHORT, + KNOT_RDATA_WF_UNCOMPRESSED_DNAME }, + { KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_DNAME }, true }, /* 37 */ - { DNSLIB_RRTYPE_CERT, "CERT", 4, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_SHORT, - DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_CERTIFICATE_TYPE, DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_ALGORITHM, - DNSLIB_RDATA_ZF_BASE64 }, true }, + { KNOT_RRTYPE_CERT, "CERT", 4, + { KNOT_RDATA_WF_SHORT, KNOT_RDATA_WF_SHORT, + KNOT_RDATA_WF_BYTE, KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_CERTIFICATE_TYPE, KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_ALGORITHM, + KNOT_RDATA_ZF_BASE64 }, true }, /* 38 */ - { DNSLIB_RRTYPE_A6, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_UNKNOWN }, true }, + { KNOT_RRTYPE_A6, NULL, 1, { KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_UNKNOWN }, true }, /* 39 */ - { DNSLIB_RRTYPE_DNAME, "DNAME", 1, - { DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME }, - { DNSLIB_RDATA_ZF_DNAME }, true }, + { KNOT_RRTYPE_DNAME, "DNAME", 1, + { KNOT_RDATA_WF_UNCOMPRESSED_DNAME }, + { KNOT_RDATA_ZF_DNAME }, true }, /* 40 */ - { 40, NULL, 1, { DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_UNKNOWN }, true }, + { 40, NULL, 1, { KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_UNKNOWN }, true }, /* 41 */ /* OPT has its parser token, but should never be in zone file... */ - { DNSLIB_RRTYPE_OPT, "OPT", 1, - { DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_UNKNOWN }, true }, + { KNOT_RRTYPE_OPT, "OPT", 1, + { KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_UNKNOWN }, true }, /* 42 */ - { DNSLIB_RRTYPE_APL, "APL", DNSLIB_MAX_RDATA_ITEMS, - { DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL, - DNSLIB_RDATA_WF_APL, DNSLIB_RDATA_WF_APL }, - { DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, - DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, - DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, - DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, - DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, - DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, - DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, - DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, - DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, - DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, - DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, - DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, - DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, - DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, - DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, - DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL, DNSLIB_RDATA_ZF_APL }, false }, + { KNOT_RRTYPE_APL, "APL", KNOT_MAX_RDATA_ITEMS, + { KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL, + KNOT_RDATA_WF_APL, KNOT_RDATA_WF_APL }, + { KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, + KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, + KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, + KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, + KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, + KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, + KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, + KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, + KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, + KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, + KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, + KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, + KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, + KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, + KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, + KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL, KNOT_RDATA_ZF_APL }, false }, /* 43 */ - { DNSLIB_RRTYPE_DS, "DS", 4, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE, - DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_ALGORITHM, DNSLIB_RDATA_ZF_BYTE, DNSLIB_RDATA_ZF_HEX }, true }, + { KNOT_RRTYPE_DS, "DS", 4, + { KNOT_RDATA_WF_SHORT, KNOT_RDATA_WF_BYTE, + KNOT_RDATA_WF_BYTE, KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_ALGORITHM, KNOT_RDATA_ZF_BYTE, KNOT_RDATA_ZF_HEX }, true }, /* 44 */ - { DNSLIB_RRTYPE_SSHFP, "SSHFP", 3, - { DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BYTE, - DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_BYTE, DNSLIB_RDATA_ZF_BYTE, DNSLIB_RDATA_ZF_HEX }, + { KNOT_RRTYPE_SSHFP, "SSHFP", 3, + { KNOT_RDATA_WF_BYTE, KNOT_RDATA_WF_BYTE, + KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_BYTE, KNOT_RDATA_ZF_BYTE, KNOT_RDATA_ZF_HEX }, true }, /* 45 */ - { DNSLIB_RRTYPE_IPSECKEY, "IPSECKEY", 5, - { DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BYTE, - DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_IPSECGATEWAY, - DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_BYTE, DNSLIB_RDATA_ZF_BYTE, DNSLIB_RDATA_ZF_BYTE, DNSLIB_RDATA_ZF_IPSECGATEWAY, - DNSLIB_RDATA_ZF_BASE64 }, false }, + { KNOT_RRTYPE_IPSECKEY, "IPSECKEY", 5, + { KNOT_RDATA_WF_BYTE, KNOT_RDATA_WF_BYTE, + KNOT_RDATA_WF_BYTE, KNOT_RDATA_WF_IPSECGATEWAY, + KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_BYTE, KNOT_RDATA_ZF_BYTE, KNOT_RDATA_ZF_BYTE, KNOT_RDATA_ZF_IPSECGATEWAY, + KNOT_RDATA_ZF_BASE64 }, false }, /* 46 */ - { DNSLIB_RRTYPE_RRSIG, "RRSIG", 9, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE, - DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_LONG, - DNSLIB_RDATA_WF_LONG, DNSLIB_RDATA_WF_LONG, - DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_LITERAL_DNAME, - DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_RRTYPE, DNSLIB_RDATA_ZF_ALGORITHM, - DNSLIB_RDATA_ZF_BYTE, DNSLIB_RDATA_ZF_PERIOD, - DNSLIB_RDATA_ZF_TIME, DNSLIB_RDATA_ZF_TIME, - DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_LITERAL_DNAME, - DNSLIB_RDATA_ZF_BASE64 }, true }, + { KNOT_RRTYPE_RRSIG, "RRSIG", 9, + { KNOT_RDATA_WF_SHORT, KNOT_RDATA_WF_BYTE, + KNOT_RDATA_WF_BYTE, KNOT_RDATA_WF_LONG, + KNOT_RDATA_WF_LONG, KNOT_RDATA_WF_LONG, + KNOT_RDATA_WF_SHORT, KNOT_RDATA_WF_LITERAL_DNAME, + KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_RRTYPE, KNOT_RDATA_ZF_ALGORITHM, + KNOT_RDATA_ZF_BYTE, KNOT_RDATA_ZF_PERIOD, + KNOT_RDATA_ZF_TIME, KNOT_RDATA_ZF_TIME, + KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_LITERAL_DNAME, + KNOT_RDATA_ZF_BASE64 }, true }, /* 47 */ - { DNSLIB_RRTYPE_NSEC, "NSEC", 2, - { DNSLIB_RDATA_WF_LITERAL_DNAME, DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_LITERAL_DNAME, DNSLIB_RDATA_ZF_NSEC }, + { KNOT_RRTYPE_NSEC, "NSEC", 2, + { KNOT_RDATA_WF_LITERAL_DNAME, KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_LITERAL_DNAME, KNOT_RDATA_ZF_NSEC }, true }, /* 48 */ - { DNSLIB_RRTYPE_DNSKEY, "DNSKEY", 4, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE, - DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_BYTE, - DNSLIB_RDATA_ZF_ALGORITHM, DNSLIB_RDATA_ZF_BASE64 }, true }, + { KNOT_RRTYPE_DNSKEY, "DNSKEY", 4, + { KNOT_RDATA_WF_SHORT, KNOT_RDATA_WF_BYTE, + KNOT_RDATA_WF_BYTE, KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_BYTE, + KNOT_RDATA_ZF_ALGORITHM, KNOT_RDATA_ZF_BASE64 }, true }, /* 49 */ - { DNSLIB_RRTYPE_DHCID, "DHCID", 1, { DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_BASE64 }, true }, + { KNOT_RRTYPE_DHCID, "DHCID", 1, { KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_BASE64 }, true }, /* 50 */ - { DNSLIB_RRTYPE_NSEC3, "NSEC3", 6, - { DNSLIB_RDATA_WF_BYTE, /* hash type */ - DNSLIB_RDATA_WF_BYTE, /* flags */ - DNSLIB_RDATA_WF_SHORT, /* iterations */ - DNSLIB_RDATA_WF_BINARYWITHLENGTH, /* salt */ - DNSLIB_RDATA_WF_BINARYWITHLENGTH, /* next hashed name */ - DNSLIB_RDATA_WF_BINARY /* type bitmap */ }, - { DNSLIB_RDATA_ZF_BYTE, DNSLIB_RDATA_ZF_BYTE, DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_HEX_LEN, - DNSLIB_RDATA_ZF_BASE32, DNSLIB_RDATA_ZF_NSEC }, + { KNOT_RRTYPE_NSEC3, "NSEC3", 6, + { KNOT_RDATA_WF_BYTE, /* hash type */ + KNOT_RDATA_WF_BYTE, /* flags */ + KNOT_RDATA_WF_SHORT, /* iterations */ + KNOT_RDATA_WF_BINARYWITHLENGTH, /* salt */ + KNOT_RDATA_WF_BINARYWITHLENGTH, /* next hashed name */ + KNOT_RDATA_WF_BINARY /* type bitmap */ }, + { KNOT_RDATA_ZF_BYTE, KNOT_RDATA_ZF_BYTE, KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_HEX_LEN, + KNOT_RDATA_ZF_BASE32, KNOT_RDATA_ZF_NSEC }, true }, /* 51 */ - { DNSLIB_RRTYPE_NSEC3PARAM, "NSEC3PARAM", 4, - { DNSLIB_RDATA_WF_BYTE, /* hash type */ - DNSLIB_RDATA_WF_BYTE, /* flags */ - DNSLIB_RDATA_WF_SHORT, /* iterations */ - DNSLIB_RDATA_WF_BINARYWITHLENGTH /* salt */ }, - { DNSLIB_RDATA_ZF_BYTE, DNSLIB_RDATA_ZF_BYTE, - DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_HEX_LEN }, true }, + { KNOT_RRTYPE_NSEC3PARAM, "NSEC3PARAM", 4, + { KNOT_RDATA_WF_BYTE, /* hash type */ + KNOT_RDATA_WF_BYTE, /* flags */ + KNOT_RDATA_WF_SHORT, /* iterations */ + KNOT_RDATA_WF_BINARYWITHLENGTH /* salt */ }, + { KNOT_RDATA_ZF_BYTE, KNOT_RDATA_ZF_BYTE, + KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_HEX_LEN }, true }, /* 52 */ @@ -365,70 +365,70 @@ static knot_rrtype_descriptor_t /* There's a GNU extension that works like this: [first ... last] = value */ /* 99 */ - [99] = { DNSLIB_RRTYPE_SPF, "SPF", DNSLIB_MAX_RDATA_ITEMS, - { DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT, - DNSLIB_RDATA_WF_TEXT, DNSLIB_RDATA_WF_TEXT }, - { DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, - DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT, DNSLIB_RDATA_ZF_TEXT }, + [99] = { KNOT_RRTYPE_SPF, "SPF", KNOT_MAX_RDATA_ITEMS, + { KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT, + KNOT_RDATA_WF_TEXT, KNOT_RDATA_WF_TEXT }, + { KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, + KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT, KNOT_RDATA_ZF_TEXT }, false }, /* 32769 */ - [32769] = { DNSLIB_RRTYPE_DLV, "DLV", 4, - { DNSLIB_RDATA_WF_SHORT, DNSLIB_RDATA_WF_BYTE, - DNSLIB_RDATA_WF_BYTE, DNSLIB_RDATA_WF_BINARY }, - { DNSLIB_RDATA_ZF_SHORT, DNSLIB_RDATA_ZF_ALGORITHM, DNSLIB_RDATA_ZF_BYTE, DNSLIB_RDATA_ZF_HEX }, + [32769] = { KNOT_RRTYPE_DLV, "DLV", 4, + { KNOT_RDATA_WF_SHORT, KNOT_RDATA_WF_BYTE, + KNOT_RDATA_WF_BYTE, KNOT_RDATA_WF_BINARY }, + { KNOT_RDATA_ZF_SHORT, KNOT_RDATA_ZF_ALGORITHM, KNOT_RDATA_ZF_BYTE, KNOT_RDATA_ZF_HEX }, true }, }; knot_rrtype_descriptor_t *knot_rrtype_descriptor_by_type(uint16_t type) { - if (type < DNSLIB_RRTYPE_LAST + 1) { + if (type < KNOT_RRTYPE_LAST + 1) { return &knot_rrtype_descriptors[type]; - } else if (type == DNSLIB_RRTYPE_DLV) { - return &knot_rrtype_descriptors[DNSLIB_RRTYPE_DLV]; + } else if (type == KNOT_RRTYPE_DLV) { + return &knot_rrtype_descriptors[KNOT_RRTYPE_DLV]; } return &knot_rrtype_descriptors[0]; } @@ -439,17 +439,17 @@ knot_rrtype_descriptor_t *knot_rrtype_descriptor_by_name(const char *name) { int i; - for (i = 0; i < DNSLIB_RRTYPE_LAST + 1; ++i) { + for (i = 0; i < KNOT_RRTYPE_LAST + 1; ++i) { if (knot_rrtype_descriptors[i].name && strcasecmp(knot_rrtype_descriptors[i].name, name) == 0) { return &knot_rrtype_descriptors[i]; } } - if (knot_rrtype_descriptors[DNSLIB_RRTYPE_DLV].name && - strcasecmp(knot_rrtype_descriptors[DNSLIB_RRTYPE_DLV].name, + if (knot_rrtype_descriptors[KNOT_RRTYPE_DLV].name && + strcasecmp(knot_rrtype_descriptors[KNOT_RRTYPE_DLV].name, name) == 0) { - return &knot_rrtype_descriptors[DNSLIB_RRTYPE_DLV]; + return &knot_rrtype_descriptors[KNOT_RRTYPE_DLV]; } return NULL; @@ -555,16 +555,16 @@ uint16_t knot_rrclass_from_string(const char *name) size_t knot_wireformat_size(unsigned int wire_type) { switch(wire_type) { - case DNSLIB_RDATA_WF_BYTE: + case KNOT_RDATA_WF_BYTE: return 1; break; - case DNSLIB_RDATA_WF_SHORT: + case KNOT_RDATA_WF_SHORT: return 2; break; - case DNSLIB_RDATA_WF_LONG: + case KNOT_RDATA_WF_LONG: return 4; break; - case DNSLIB_RDATA_WF_A: + case KNOT_RDATA_WF_A: return 4; break; default: /* unknown size */ diff --git a/src/dnslib/descriptor.h b/src/dnslib/descriptor.h index ccb13d4f15e36281248ca689d691b5a1f087cfce..4819b395b932fff42db29bcb14c25caa43ce7080 100644 --- a/src/dnslib/descriptor.h +++ b/src/dnslib/descriptor.h @@ -13,8 +13,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_DESCRIPTOR_H_ -#define _KNOT_DNSLIB_DESCRIPTOR_H_ +#ifndef _KNOTDKNOT_DESCRIPTOR_H_ +#define _KNOTDKNOT_DESCRIPTOR_H_ #include <stdint.h> #include <stdbool.h> @@ -22,12 +22,12 @@ enum knot_mxrdtln { /*! \brief Maximum items in RDATA wireformat. */ - DNSLIB_MAX_RDATA_ITEMS = 64, + KNOT_MAX_RDATA_ITEMS = 64, /*! \brief Maximum size of one item in RDATA wireformat. */ - DNSLIB_MAX_RDATA_ITEM_SIZE = 65534, + KNOT_MAX_RDATA_ITEM_SIZE = 65534, /*! \brief Maximum wire size of one RDATA. */ - DNSLIB_MAX_RDATA_WIRE_SIZE = - DNSLIB_MAX_RDATA_ITEMS * DNSLIB_MAX_RDATA_ITEM_SIZE + KNOT_MAX_RDATA_WIRE_SIZE = + KNOT_MAX_RDATA_ITEMS * KNOT_MAX_RDATA_ITEM_SIZE }; typedef enum knot_mxrdtln knot_mxrdtln_t; @@ -39,12 +39,12 @@ typedef enum knot_mxrdtln knot_mxrdtln_t; * \brief Resource record class codes. */ enum knot_rr_class { - DNSLIB_CLASS_IN = 1, - DNSLIB_CLASS_CS, - DNSLIB_CLASS_CH, - DNSLIB_CLASS_HS, - DNSLIB_CLASS_NONE = 254, - DNSLIB_CLASS_ANY = 255 + KNOT_CLASS_IN = 1, + KNOT_CLASS_CS, + KNOT_CLASS_CH, + KNOT_CLASS_HS, + KNOT_CLASS_NONE = 254, + KNOT_CLASS_ANY = 255 }; typedef enum knot_rr_class knot_rr_class_t; @@ -54,88 +54,88 @@ typedef enum knot_rr_class knot_rr_class_t; * \todo Not all indices can be used for indexing. */ enum knot_rr_type { - DNSLIB_RRTYPE_UNKNOWN, /*!< 0 - an unknown type */ - DNSLIB_RRTYPE_A, /*!< 1 - a host address */ - DNSLIB_RRTYPE_NS, /*!< 2 - an authoritative name server */ - DNSLIB_RRTYPE_MD, /*!< 3 - a mail destination (Obsolete - use MX) */ - DNSLIB_RRTYPE_MF, /*!< 4 - a mail forwarder (Obsolete - use MX) */ - DNSLIB_RRTYPE_CNAME, /*!< 5 - the canonical name for an alias */ - DNSLIB_RRTYPE_SOA, /*!< 6 - marks the start of a zone of authority */ - DNSLIB_RRTYPE_MB, /*!< 7 - a mailbox domain name (EXPERIMENTAL) */ - DNSLIB_RRTYPE_MG, /*!< 8 - a mail group member (EXPERIMENTAL) */ - DNSLIB_RRTYPE_MR, /*!< 9 - a mail rename domain name (EXPERIMENTAL) */ - DNSLIB_RRTYPE_NULL, /*!< 10 - a null RR (EXPERIMENTAL) */ - DNSLIB_RRTYPE_WKS, /*!< 11 - a well known service description */ - DNSLIB_RRTYPE_PTR, /*!< 12 - a domain name pointer */ - DNSLIB_RRTYPE_HINFO, /*!< 13 - host information */ - DNSLIB_RRTYPE_MINFO, /*!< 14 - mailbox or mail list information */ - DNSLIB_RRTYPE_MX, /*!< 15 - mail exchange */ - DNSLIB_RRTYPE_TXT, /*!< 16 - text strings */ - DNSLIB_RRTYPE_RP, /*!< 17 - RFC1183 */ - DNSLIB_RRTYPE_AFSDB, /*!< 18 - RFC1183 */ - DNSLIB_RRTYPE_X25, /*!< 19 - RFC1183 */ - DNSLIB_RRTYPE_ISDN, /*!< 20 - RFC1183 */ - DNSLIB_RRTYPE_RT, /*!< 21 - RFC1183 */ - DNSLIB_RRTYPE_NSAP, /*!< 22 - RFC1706 */ - - DNSLIB_RRTYPE_SIG = 24, /*!< 24 - 2535typecode */ - DNSLIB_RRTYPE_KEY, /*!< 25 - 2535typecode */ - DNSLIB_RRTYPE_PX, /*!< 26 - RFC2163 */ - - DNSLIB_RRTYPE_AAAA = 28, /*!< 28 - ipv6 address */ - DNSLIB_RRTYPE_LOC, /*!< 29 - LOC record RFC1876 */ - DNSLIB_RRTYPE_NXT, /*!< 30 - 2535typecode */ - - DNSLIB_RRTYPE_SRV = 33, /*!< 33 - SRV record RFC2782 */ - - DNSLIB_RRTYPE_NAPTR = 35, /*!< 35 - RFC2915 */ - DNSLIB_RRTYPE_KX, /*!< 36 - RFC2230 Key Exchange Delegation Record */ - DNSLIB_RRTYPE_CERT, /*!< 37 - RFC2538 */ - DNSLIB_RRTYPE_A6, /*!< 38 - RFC2874 */ - DNSLIB_RRTYPE_DNAME, /*!< 39 - RFC2672 */ - - DNSLIB_RRTYPE_OPT = 41, /*!< 41 - Pseudo OPT record... */ - DNSLIB_RRTYPE_APL, /*!< 42 - RFC3123 */ - DNSLIB_RRTYPE_DS, /*!< 43 - RFC 4033, 4034, and 4035 */ - DNSLIB_RRTYPE_SSHFP, /*!< 44 - SSH Key Fingerprint */ - DNSLIB_RRTYPE_IPSECKEY, /*!< 45 - public key for ipsec use. RFC 4025 */ - DNSLIB_RRTYPE_RRSIG, /*!< 46 - RFC 4033, 4034, and 4035 */ - DNSLIB_RRTYPE_NSEC, /*!< 47 - RFC 4033, 4034, and 4035 */ - DNSLIB_RRTYPE_DNSKEY, /*!< 48 - RFC 4033, 4034, and 4035 */ - DNSLIB_RRTYPE_DHCID, /*!< 49 - RFC4701 DHCP information */ + KNOT_RRTYPE_UNKNOWN, /*!< 0 - an unknown type */ + KNOT_RRTYPE_A, /*!< 1 - a host address */ + KNOT_RRTYPE_NS, /*!< 2 - an authoritative name server */ + KNOT_RRTYPE_MD, /*!< 3 - a mail destination (Obsolete - use MX) */ + KNOT_RRTYPE_MF, /*!< 4 - a mail forwarder (Obsolete - use MX) */ + KNOT_RRTYPE_CNAME, /*!< 5 - the canonical name for an alias */ + KNOT_RRTYPE_SOA, /*!< 6 - marks the start of a zone of authority */ + KNOT_RRTYPE_MB, /*!< 7 - a mailbox domain name (EXPERIMENTAL) */ + KNOT_RRTYPE_MG, /*!< 8 - a mail group member (EXPERIMENTAL) */ + KNOT_RRTYPE_MR, /*!< 9 - a mail rename domain name (EXPERIMENTAL) */ + KNOT_RRTYPE_NULL, /*!< 10 - a null RR (EXPERIMENTAL) */ + KNOT_RRTYPE_WKS, /*!< 11 - a well known service description */ + KNOT_RRTYPE_PTR, /*!< 12 - a domain name pointer */ + KNOT_RRTYPE_HINFO, /*!< 13 - host information */ + KNOT_RRTYPE_MINFO, /*!< 14 - mailbox or mail list information */ + KNOT_RRTYPE_MX, /*!< 15 - mail exchange */ + KNOT_RRTYPE_TXT, /*!< 16 - text strings */ + KNOT_RRTYPE_RP, /*!< 17 - RFC1183 */ + KNOT_RRTYPE_AFSDB, /*!< 18 - RFC1183 */ + KNOT_RRTYPE_X25, /*!< 19 - RFC1183 */ + KNOT_RRTYPE_ISDN, /*!< 20 - RFC1183 */ + KNOT_RRTYPE_RT, /*!< 21 - RFC1183 */ + KNOT_RRTYPE_NSAP, /*!< 22 - RFC1706 */ + + KNOT_RRTYPE_SIG = 24, /*!< 24 - 2535typecode */ + KNOT_RRTYPE_KEY, /*!< 25 - 2535typecode */ + KNOT_RRTYPE_PX, /*!< 26 - RFC2163 */ + + KNOT_RRTYPE_AAAA = 28, /*!< 28 - ipv6 address */ + KNOT_RRTYPE_LOC, /*!< 29 - LOC record RFC1876 */ + KNOT_RRTYPE_NXT, /*!< 30 - 2535typecode */ + + KNOT_RRTYPE_SRV = 33, /*!< 33 - SRV record RFC2782 */ + + KNOT_RRTYPE_NAPTR = 35, /*!< 35 - RFC2915 */ + KNOT_RRTYPE_KX, /*!< 36 - RFC2230 Key Exchange Delegation Record */ + KNOT_RRTYPE_CERT, /*!< 37 - RFC2538 */ + KNOT_RRTYPE_A6, /*!< 38 - RFC2874 */ + KNOT_RRTYPE_DNAME, /*!< 39 - RFC2672 */ + + KNOT_RRTYPE_OPT = 41, /*!< 41 - Pseudo OPT record... */ + KNOT_RRTYPE_APL, /*!< 42 - RFC3123 */ + KNOT_RRTYPE_DS, /*!< 43 - RFC 4033, 4034, and 4035 */ + KNOT_RRTYPE_SSHFP, /*!< 44 - SSH Key Fingerprint */ + KNOT_RRTYPE_IPSECKEY, /*!< 45 - public key for ipsec use. RFC 4025 */ + KNOT_RRTYPE_RRSIG, /*!< 46 - RFC 4033, 4034, and 4035 */ + KNOT_RRTYPE_NSEC, /*!< 47 - RFC 4033, 4034, and 4035 */ + KNOT_RRTYPE_DNSKEY, /*!< 48 - RFC 4033, 4034, and 4035 */ + KNOT_RRTYPE_DHCID, /*!< 49 - RFC4701 DHCP information */ /*! * \brief 50 - NSEC3, secure denial, prevents zonewalking */ - DNSLIB_RRTYPE_NSEC3, + KNOT_RRTYPE_NSEC3, /*! * \brief 51 - NSEC3PARAM at zone apex nsec3 parameters */ - DNSLIB_RRTYPE_NSEC3PARAM, + KNOT_RRTYPE_NSEC3PARAM, /* TODO consider some better way of doing this, indices too high */ - DNSLIB_RRTYPE_SPF = 99, /*!< RFC 4408 */ + KNOT_RRTYPE_SPF = 99, /*!< RFC 4408 */ // not designating any RRs - DNSLIB_RRTYPE_TSIG = 250, /*!< TSIG (not an actual RR). */ - DNSLIB_RRTYPE_IXFR = 251, /*!< IXFR (not an actual RR). */ - DNSLIB_RRTYPE_AXFR = 252, /*!< AXFR (not an actual RR). */ + KNOT_RRTYPE_TSIG = 250, /*!< TSIG (not an actual RR). */ + KNOT_RRTYPE_IXFR = 251, /*!< IXFR (not an actual RR). */ + KNOT_RRTYPE_AXFR = 252, /*!< AXFR (not an actual RR). */ /*! * \brief A request for mailbox-related records (MB, MG or MR) */ - DNSLIB_RRTYPE_MAILB = 253, + KNOT_RRTYPE_MAILB = 253, /*! * \brief A request for mail agent RRs (Obsolete - see MX) */ - DNSLIB_RRTYPE_MAILA = 254, - DNSLIB_RRTYPE_ANY = 255, /*!< any type (wildcard) */ + KNOT_RRTYPE_MAILA = 254, + KNOT_RRTYPE_ANY = 255, /*!< any type (wildcard) */ // totally weird numbers (cannot use for indexing) - DNSLIB_RRTYPE_TA = 32768, /*!< DNSSEC Trust Authorities */ - DNSLIB_RRTYPE_DLV = 32769, /*!< RFC 4431 */ + KNOT_RRTYPE_TA = 32768, /*!< DNSSEC Trust Authorities */ + KNOT_RRTYPE_DLV = 32769, /*!< RFC 4431 */ /*! \brief Last normal RR type. */ - DNSLIB_RRTYPE_LAST = DNSLIB_RRTYPE_NSEC3PARAM + KNOT_RRTYPE_LAST = KNOT_RRTYPE_NSEC3PARAM }; typedef enum knot_rr_type knot_rr_type_t; @@ -145,52 +145,52 @@ enum knot_rdata_wireformat { /*! * \brief Possibly compressed domain name. */ - DNSLIB_RDATA_WF_COMPRESSED_DNAME = 50, - DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME = 51, /*!< Uncompressed domain name. */ - DNSLIB_RDATA_WF_LITERAL_DNAME = 52, /*!< Literal (not downcased) dname. */ - DNSLIB_RDATA_WF_BYTE = 1, /*!< 8-bit integer. */ - DNSLIB_RDATA_WF_SHORT = 2, /*!< 16-bit integer. */ - DNSLIB_RDATA_WF_LONG = 4, /*!< 32-bit integer. */ - DNSLIB_RDATA_WF_TEXT = 53, /*!< Text string. */ - DNSLIB_RDATA_WF_A = 58, /*!< 32-bit IPv4 address. */ - DNSLIB_RDATA_WF_AAAA = 16, /*!< 128-bit IPv6 address. */ - DNSLIB_RDATA_WF_BINARY = 54, /*!< Binary data (unknown length). */ + KNOT_RDATA_WF_COMPRESSED_DNAME = 50, + KNOT_RDATA_WF_UNCOMPRESSED_DNAME = 51, /*!< Uncompressed domain name. */ + KNOT_RDATA_WF_LITERAL_DNAME = 52, /*!< Literal (not downcased) dname. */ + KNOT_RDATA_WF_BYTE = 1, /*!< 8-bit integer. */ + KNOT_RDATA_WF_SHORT = 2, /*!< 16-bit integer. */ + KNOT_RDATA_WF_LONG = 4, /*!< 32-bit integer. */ + KNOT_RDATA_WF_TEXT = 53, /*!< Text string. */ + KNOT_RDATA_WF_A = 58, /*!< 32-bit IPv4 address. */ + KNOT_RDATA_WF_AAAA = 16, /*!< 128-bit IPv6 address. */ + KNOT_RDATA_WF_BINARY = 54, /*!< Binary data (unknown length). */ /*! * \brief Binary data preceded by 1 byte length */ - DNSLIB_RDATA_WF_BINARYWITHLENGTH = 55, - DNSLIB_RDATA_WF_APL = 56, /*!< APL data. */ - DNSLIB_RDATA_WF_IPSECGATEWAY = 57 /*!< IPSECKEY gateway ip4, ip6 or dname. */ + KNOT_RDATA_WF_BINARYWITHLENGTH = 55, + KNOT_RDATA_WF_APL = 56, /*!< APL data. */ + KNOT_RDATA_WF_IPSECGATEWAY = 57 /*!< IPSECKEY gateway ip4, ip6 or dname. */ }; /*! \brief Constants characterising the format of RDATA items in zone file. */ enum knot_rdata_zoneformat { - DNSLIB_RDATA_ZF_DNAME, /* Domain name. */ - DNSLIB_RDATA_ZF_LITERAL_DNAME, /* DNS name (not lowercased domain name). */ - DNSLIB_RDATA_ZF_TEXT, /* Text string. */ - DNSLIB_RDATA_ZF_BYTE, /* 8-bit integer. */ - DNSLIB_RDATA_ZF_SHORT, /* 16-bit integer. */ - DNSLIB_RDATA_ZF_LONG, /* 32-bit integer. */ - DNSLIB_RDATA_ZF_A, /* 32-bit IPv4 address. */ - DNSLIB_RDATA_ZF_AAAA, /* 128-bit IPv6 address. */ - DNSLIB_RDATA_ZF_RRTYPE, /* RR type. */ - DNSLIB_RDATA_ZF_ALGORITHM, /* Cryptographic algorithm. */ - DNSLIB_RDATA_ZF_CERTIFICATE_TYPE, - DNSLIB_RDATA_ZF_PERIOD, /* Time period. */ - DNSLIB_RDATA_ZF_TIME, - DNSLIB_RDATA_ZF_BASE64, /* Base-64 binary data. */ - DNSLIB_RDATA_ZF_BASE32, /* Base-32 binary data. */ - DNSLIB_RDATA_ZF_HEX, /* Hexadecimal binary data. */ - DNSLIB_RDATA_ZF_HEX_LEN, /* Hexadecimal binary data. Skip initial length byte. */ - DNSLIB_RDATA_ZF_NSAP, /* NSAP. */ - DNSLIB_RDATA_ZF_APL, /* APL. */ - DNSLIB_RDATA_ZF_IPSECGATEWAY, /* IPSECKEY gateway ip4, ip6 or dname. */ - DNSLIB_RDATA_ZF_SERVICES, /* Protocol and port number bitmap. */ - DNSLIB_RDATA_ZF_NXT, /* NXT type bitmap. */ - DNSLIB_RDATA_ZF_NSEC, /* NSEC type bitmap. */ - DNSLIB_RDATA_ZF_LOC, /* Location data. */ - DNSLIB_RDATA_ZF_UNKNOWN /* Unknown data. */ + KNOT_RDATA_ZF_DNAME, /* Domain name. */ + KNOT_RDATA_ZF_LITERAL_DNAME, /* DNS name (not lowercased domain name). */ + KNOT_RDATA_ZF_TEXT, /* Text string. */ + KNOT_RDATA_ZF_BYTE, /* 8-bit integer. */ + KNOT_RDATA_ZF_SHORT, /* 16-bit integer. */ + KNOT_RDATA_ZF_LONG, /* 32-bit integer. */ + KNOT_RDATA_ZF_A, /* 32-bit IPv4 address. */ + KNOT_RDATA_ZF_AAAA, /* 128-bit IPv6 address. */ + KNOT_RDATA_ZF_RRTYPE, /* RR type. */ + KNOT_RDATA_ZF_ALGORITHM, /* Cryptographic algorithm. */ + KNOT_RDATA_ZF_CERTIFICATE_TYPE, + KNOT_RDATA_ZF_PERIOD, /* Time period. */ + KNOT_RDATA_ZF_TIME, + KNOT_RDATA_ZF_BASE64, /* Base-64 binary data. */ + KNOT_RDATA_ZF_BASE32, /* Base-32 binary data. */ + KNOT_RDATA_ZF_HEX, /* Hexadecimal binary data. */ + KNOT_RDATA_ZF_HEX_LEN, /* Hexadecimal binary data. Skip initial length byte. */ + KNOT_RDATA_ZF_NSAP, /* NSAP. */ + KNOT_RDATA_ZF_APL, /* APL. */ + KNOT_RDATA_ZF_IPSECGATEWAY, /* IPSECKEY gateway ip4, ip6 or dname. */ + KNOT_RDATA_ZF_SERVICES, /* Protocol and port number bitmap. */ + KNOT_RDATA_ZF_NXT, /* NXT type bitmap. */ + KNOT_RDATA_ZF_NSEC, /* NSEC type bitmap. */ + KNOT_RDATA_ZF_LOC, /* Location data. */ + KNOT_RDATA_ZF_UNKNOWN /* Unknown data. */ }; /*! \brief Constants characterising the wire format of RDATA items. */ @@ -206,10 +206,10 @@ struct knot_rrtype_descriptor { uint8_t length; /*!< Maximum number of RDATA items. */ /*! \brief Wire format specification for the RDATA. */ - uint8_t wireformat[DNSLIB_MAX_RDATA_ITEMS]; + uint8_t wireformat[KNOT_MAX_RDATA_ITEMS]; /*! \brief Zone file format specification for the RDATA. */ - uint8_t zoneformat[DNSLIB_MAX_RDATA_ITEMS]; + uint8_t zoneformat[KNOT_MAX_RDATA_ITEMS]; bool fixed_items; /*!< Has fixed number of RDATA items? */ }; @@ -288,7 +288,7 @@ uint16_t knot_rrclass_from_string(const char *name); */ size_t knot_wireformat_size(unsigned int wire_type); -#endif /* _KNOT_DNSLIB_DESCRIPTOR_H_ */ +#endif /* _KNOTDKNOT_DESCRIPTOR_H_ */ /*! @} */ diff --git a/src/dnslib/dname-table.c b/src/dnslib/dname-table.c index 46e847c88a6d92898ed7572de77a9c31829050a6..d127542c62780a94527f456385c444036108c614 100644 --- a/src/dnslib/dname-table.c +++ b/src/dnslib/dname-table.c @@ -71,13 +71,13 @@ static int knot_dname_table_copy_node(const struct dname_table_node *from, struct dname_table_node **to) { if (from == NULL) { - return DNSLIB_EOK; + return KNOT_EOK; } *to = (struct dname_table_node *) malloc(sizeof(struct dname_table_node)); if (*to == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } (*to)->dname = from->dname; @@ -86,19 +86,19 @@ static int knot_dname_table_copy_node(const struct dname_table_node *from, int ret = knot_dname_table_copy_node(from->avl.avl_left, &(*to)->avl.avl_left); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } ret = knot_dname_table_copy_node(from->avl.avl_right, &(*to)->avl.avl_right); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { knot_dname_table_delete_subtree((*to)->avl.avl_left); (*to)->avl.avl_left = NULL; return ret; } - return DNSLIB_EOK; + return KNOT_EOK; } knot_dname_table_t *knot_dname_table_new() @@ -147,13 +147,13 @@ int knot_dname_table_add_dname(knot_dname_table_t *table, knot_dname_t *dname) { if (dname == NULL || table == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } /* Node for insertion has to be created */ struct dname_table_node *node = malloc(sizeof(struct dname_table_node)); - CHECK_ALLOC_LOG(node, DNSLIB_ENOMEM); + CHECK_ALLOC_LOG(node, KNOT_ENOMEM); node->dname = dname; node->avl.avl_height = 0; @@ -168,7 +168,7 @@ int knot_dname_table_add_dname(knot_dname_table_t *table, knot_dname_retain(dname); TREE_INSERT(table->tree, dname_table_node, avl, node); - return DNSLIB_EOK; + return KNOT_EOK; } int knot_dname_table_add_dname2(knot_dname_table_t *table, @@ -177,7 +177,7 @@ int knot_dname_table_add_dname2(knot_dname_table_t *table, knot_dname_t *found_dname = NULL; if (table == NULL || dname == NULL || *dname == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } // char *name = knot_dname_to_str(*dname); @@ -213,7 +213,7 @@ int knot_dname_table_add_dname2(knot_dname_table_t *table, // printf("Done.\n"); - return DNSLIB_EOK; + return KNOT_EOK; } int knot_dname_table_shallow_copy(knot_dname_table_t *from, @@ -225,7 +225,7 @@ int knot_dname_table_shallow_copy(knot_dname_table_t *from, to->tree = malloc(sizeof(table_tree_t)); if (to->tree == NULL) { ERR_ALLOC_FAILED; - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } TREE_INIT(to->tree, compare_dname_table_nodes); diff --git a/src/dnslib/dname-table.h b/src/dnslib/dname-table.h index 3c84c000147ec02ffa0fdabc3a9ba7a83b22aae9..e4078a1a4512a272f25b8becc2408f6b5c509107 100644 --- a/src/dnslib/dname-table.h +++ b/src/dnslib/dname-table.h @@ -10,8 +10,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_DNAME_TABLE_H_ -#define _KNOT_DNSLIB_DNAME_TABLE_H_ +#ifndef _KNOTDKNOT_DNAME_TABLE_H_ +#define _KNOTDKNOT_DNAME_TABLE_H_ #include <config.h> @@ -77,8 +77,8 @@ knot_dname_t *knot_dname_table_find_dname(const knot_dname_table_t *table, * * \note This function encapsulates dname in a structure and saves it to a tree. * - * \retval DNSLIB_EOK on success. - * \retval DNSLIB_ENOMEM when memory runs out. + * \retval KNOT_EOK on success. + * \retval KNOT_ENOMEM when memory runs out. */ int knot_dname_table_add_dname(knot_dname_table_t *table, knot_dname_t *dname); @@ -92,8 +92,8 @@ int knot_dname_table_add_dname(knot_dname_table_t *table, * \note This function encapsulates dname in a structure and saves it to a tree. * \note If a duplicate is found, \a dname is replaced by the name from table. * - * \retval DNSLIB_EOK on success. - * \retval DNSLIB_ENOMEM when memory runs out. + * \retval KNOT_EOK on success. + * \retval KNOT_ENOMEM when memory runs out. */ int knot_dname_table_add_dname2(knot_dname_table_t *table, knot_dname_t **dname); @@ -139,7 +139,7 @@ void knot_dname_table_tree_inorder_apply(const knot_dname_table_t *table, void *data); -#endif // _KNOT_DNSLIB_DNAME_TABLE_H_ +#endif // _KNOTDKNOT_DNAME_TABLE_H_ /*! @} */ diff --git a/src/dnslib/dname.c b/src/dnslib/dname.c index 155be88abf41d7d41821f3236ca77e1e03fd0bc5..f067b752fcdf84a733a147ec4b0228fc48d8978d 100644 --- a/src/dnslib/dname.c +++ b/src/dnslib/dname.c @@ -124,7 +124,7 @@ static int knot_dname_set(knot_dname_t *dname, uint8_t *wire, static int knot_dname_str_to_wire(const char *name, uint size, knot_dname_t *dname) { - if (size > DNSLIB_MAX_DNAME_LENGTH) { + if (size > KNOT_MAX_DNAME_LENGTH) { return -1; } @@ -138,7 +138,7 @@ static int knot_dname_str_to_wire(const char *name, uint size, } uint8_t *wire; - uint8_t labels[DNSLIB_MAX_DNAME_LABELS]; + uint8_t labels[KNOT_MAX_DNAME_LABELS]; short label_count = 0; // signed / unsigned issues?? @@ -245,7 +245,7 @@ static int knot_dname_find_labels(knot_dname_t *dname, int alloc) const uint8_t *pos = name; const uint size = dname->size; - uint8_t labels[DNSLIB_MAX_DNAME_LABELS]; + uint8_t labels[KNOT_MAX_DNAME_LABELS]; short label_count = 0; while (pos - name < size && *pos != '\0') { @@ -264,7 +264,7 @@ static int knot_dname_find_labels(knot_dname_t *dname, int alloc) if (alloc) { dname->labels = (uint8_t *)malloc(label_count * sizeof(uint8_t)); - CHECK_ALLOC_LOG(dname->labels, DNSLIB_ENOMEM); + CHECK_ALLOC_LOG(dname->labels, KNOT_ENOMEM); } memcpy(dname->labels, labels, label_count); @@ -278,7 +278,7 @@ static int knot_dname_find_labels(knot_dname_t *dname, int alloc) static int knot_dname_cmp(const knot_dname_t *d1, const knot_dname_t *d2, int cs) { -DEBUG_DNSLIB_DNAME( +DEBUG_KNOT_DNAME( char *name1 = knot_dname_to_str(d1); char *name2 = knot_dname_to_str(d2); @@ -409,7 +409,7 @@ knot_dname_t *knot_dname_new_from_str(const char *name, uint size, // uint size) //{ // int i = 0; -// uint8_t labels[DNSLIB_MAX_DNAME_LABELS]; +// uint8_t labels[KNOT_MAX_DNAME_LABELS]; // int label_i = 0; // while (name[i] != 0) { @@ -467,8 +467,8 @@ knot_dname_t *knot_dname_parse_from_wire(const uint8_t *wire, size_t *pos, size_t size, knot_node_t *node) { - uint8_t name[DNSLIB_MAX_DNAME_LENGTH]; - uint8_t labels[DNSLIB_MAX_DNAME_LABELS]; + uint8_t name[KNOT_MAX_DNAME_LENGTH]; + uint8_t labels[KNOT_MAX_DNAME_LABELS]; short l = 0; size_t i = 0, p = *pos; @@ -549,7 +549,7 @@ int knot_dname_from_wire(const uint8_t *name, uint size, struct knot_node *node, knot_dname_t *target) { if (name == NULL || target == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } memcpy(target->name, name, size); @@ -751,7 +751,7 @@ void knot_dname_left_chop_no_copy(knot_dname_t *dname) int knot_dname_is_subdomain(const knot_dname_t *sub, const knot_dname_t *domain) { -DEBUG_DNSLIB_DNAME( +DEBUG_KNOT_DNAME( char *name1 = knot_dname_to_str(sub); char *name2 = knot_dname_to_str(domain); @@ -868,7 +868,7 @@ knot_dname_t *knot_dname_replace_suffix(const knot_dname_t *dname, int size, const knot_dname_t *suffix) { -DEBUG_DNSLIB_DNAME( +DEBUG_KNOT_DNAME( char *name = knot_dname_to_str(dname); debug_knot_dname("Replacing suffix of name %s, size %d with ", name, size); diff --git a/src/dnslib/dname.h b/src/dnslib/dname.h index 25345d5973bdd84e345d2040af867ef9fdc330da..551b7b4eb13ecf2e20c7924201b8a42e7197d08b 100644 --- a/src/dnslib/dname.h +++ b/src/dnslib/dname.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_DNAME_H_ -#define _KNOT_DNSLIB_DNAME_H_ +#ifndef _KNOTDKNOT_DNAME_H_ +#define _KNOTDKNOT_DNAME_H_ #include <stdint.h> #include <string.h> @@ -120,9 +120,9 @@ knot_dname_t *knot_dname_parse_from_wire(const uint8_t *wire, * applicable. * \param target Domain name structure to initialize. * - * \retval DNSLIB_EOK on success. - * \retval DNSLIB_ENOMEM if allocation of labels info failed. - * \retval DNSLIB_EBADARG if name or target is null. + * \retval KNOT_EOK on success. + * \retval KNOT_ENOMEM if allocation of labels info failed. + * \retval KNOT_EBADARG if name or target is null. * * \todo This function does not check if the given data is in correct wire * format at all. It thus creates a invalid domain name, which if passed @@ -399,6 +399,6 @@ static inline void knot_dname_release(knot_dname_t *dname) { knot_dname_release_((d)) */ -#endif /* _KNOT_DNSLIB_DNAME_H_ */ +#endif /* _KNOTDKNOT_DNAME_H_ */ /*! @} */ diff --git a/src/dnslib/dnslib-common.h b/src/dnslib/dnslib-common.h index f8a069a831cfe64096f7b182f2cdc3dbf788c8e8..eaa13b6f3e96c473623b6948d6e4ec4ff6590f20 100644 --- a/src/dnslib/dnslib-common.h +++ b/src/dnslib/dnslib-common.h @@ -14,11 +14,11 @@ #define TEST_WITH_LDNS #endif -#ifndef _KNOT_DNSLIB_COMMON_H_ -#define _KNOT_DNSLIB_COMMON_H_ +#ifndef _KNOTDKNOT_COMMON_H_ +#define _KNOTDKNOT_COMMON_H_ -#define DNSLIB_NAME "dnslib" // Project name -#define DNSLIB_VER 0x000100 // 0xMMIIRR (MAJOR,MINOR,REVISION) +#define KNOT_NAME "dnslib" // Project name +#define KNOT_VER 0x000100 // 0xMMIIRR (MAJOR,MINOR,REVISION) #ifndef UINT_DEFINED typedef unsigned int uint; /*!< \brief Unsigned. */ @@ -61,7 +61,7 @@ typedef unsigned int uint; /*!< \brief Unsigned. */ /*! \todo Refactor theese. We should have an allocator function handling this.*/ #ifndef ERR_ALLOC_FAILED #define ERR_ALLOC_FAILED fprintf(stderr, "Allocation failed at %s:%d (%s ver.%x)\n", \ - __FILE__, __LINE__, DNSLIB_NAME, DNSLIB_VER) + __FILE__, __LINE__, KNOT_NAME, KNOT_VER) #endif #ifndef CHECK_ALLOC_LOG @@ -83,6 +83,6 @@ typedef unsigned int uint; /*!< \brief Unsigned. */ } while (0) #endif -#endif /* _KNOT_DNSLIB_COMMON_H_ */ +#endif /* _KNOTDKNOT_COMMON_H_ */ /*! @} */ diff --git a/src/dnslib/dnslib-error.c b/src/dnslib/dnslib-error.c index 3900fc92f4567654b597891c1594fb0117fe7446..8b0a4ebf315c8f33aae77385d3e209c3ae37e48f 100644 --- a/src/dnslib/dnslib-error.c +++ b/src/dnslib/dnslib-error.c @@ -3,23 +3,23 @@ #include "common/errors.h" -const error_table_t knot_error_msgs2[DNSLIB_ERROR_COUNT] = { - {DNSLIB_EOK, "OK"}, - {DNSLIB_ERROR, "General dnslib error."}, - {DNSLIB_ENOMEM, "Not enough memory."}, - {DNSLIB_EBADARG, "Wrong argument supported."}, - {DNSLIB_EFEWDATA, "Not enough data to parse."}, - {DNSLIB_ESPACE, "Not enough space provided."}, - {DNSLIB_EMALF, "Malformed data."}, - {DNSLIB_ECRYPTO, "Error in crypto library."}, - {DNSLIB_ENSEC3PAR, "Missing or wrong NSEC3PARAM record."}, - {DNSLIB_EBADZONE, "Domain name does not belong to the given zone."}, - {DNSLIB_EHASH, "Error in hash table."}, - {DNSLIB_EZONEIN, "Error inserting zone."}, - {DNSLIB_ENOZONE, "No such zone found."}, - {DNSLIB_ENONODE, "No such node in zone found."}, - {DNSLIB_EDNAMEPTR, "Domain name pointer larger than allowed."}, - {DNSLIB_EPAYLOAD, "Payload in OPT RR larger than max wire size."}, - {DNSLIB_ECRC, "CRC check failed."}, - {DNSLIB_ERROR, 0} +const error_table_t knot_error_msgs2[KNOT_ERROR_COUNT] = { + {KNOT_EOK, "OK"}, + {KNOT_ERROR, "General dnslib error."}, + {KNOT_ENOMEM, "Not enough memory."}, + {KNOT_EBADARG, "Wrong argument supported."}, + {KNOT_EFEWDATA, "Not enough data to parse."}, + {KNOT_ESPACE, "Not enough space provided."}, + {KNOT_EMALF, "Malformed data."}, + {KNOT_ECRYPTO, "Error in crypto library."}, + {KNOT_ENSEC3PAR, "Missing or wrong NSEC3PARAM record."}, + {KNOT_EBADZONE, "Domain name does not belong to the given zone."}, + {KNOT_EHASH, "Error in hash table."}, + {KNOT_EZONEIN, "Error inserting zone."}, + {KNOT_ENOZONE, "No such zone found."}, + {KNOT_ENONODE, "No such node in zone found."}, + {KNOT_EDNAMEPTR, "Domain name pointer larger than allowed."}, + {KNOT_EPAYLOAD, "Payload in OPT RR larger than max wire size."}, + {KNOT_ECRC, "CRC check failed."}, + {KNOT_ERROR, 0} }; diff --git a/src/dnslib/dnslib.h b/src/dnslib/dnslib.h index 08b08a6641c00b4e7549dc7b7dab3336ed55af4b..eaf3a9e0b9f1380d78afa413e7da626f735cc238 100644 --- a/src/dnslib/dnslib.h +++ b/src/dnslib/dnslib.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_DNSLIB_H_ -#define _KNOT_DNSLIB_DNSLIB_H_ +#ifndef _KNOTDKNOT_DNSLIB_H_ +#define _KNOTDKNOT_DNSLIB_H_ #include "dnslib/consts.h" #include "dnslib/descriptor.h" diff --git a/src/dnslib/edns.c b/src/dnslib/edns.c index 2c95dd29f928f2283f8694df5644229d3be67f0b..c8423916237f2a13ebd3bd75b51f611e93900b82 100644 --- a/src/dnslib/edns.c +++ b/src/dnslib/edns.c @@ -11,13 +11,13 @@ /*! \brief Various EDNS constatns. */ enum knot_edns_consts { /*! \brief Mask for the DO bit. */ - DNSLIB_EDNS_DO_MASK = (uint16_t)0x8000, + KNOT_EDNS_DO_MASK = (uint16_t)0x8000, /*! \brief Step for allocation of space for option entries. */ - DNSLIB_EDNS_OPTION_STEP = 1 + KNOT_EDNS_OPTION_STEP = 1 }; /*! \brief Minimum size of EDNS OPT RR in wire format. */ -static const short DNSLIB_EDNS_MIN_SIZE = 11; +static const short KNOT_EDNS_MIN_SIZE = 11; /*----------------------------------------------------------------------------*/ @@ -26,7 +26,7 @@ knot_opt_rr_t *knot_edns_new() knot_opt_rr_t *opt_rr = (knot_opt_rr_t *)malloc( sizeof(knot_opt_rr_t)); CHECK_ALLOC_LOG(opt_rr, NULL); - opt_rr->size = DNSLIB_EDNS_MIN_SIZE; + opt_rr->size = KNOT_EDNS_MIN_SIZE; opt_rr->option_count = 0; opt_rr->options_max = 0; @@ -46,27 +46,27 @@ int knot_edns_new_from_wire(knot_opt_rr_t *opt_rr, const uint8_t *wire, int parsed = 0; if (pos == NULL || max_size == 0 || opt_rr == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } - if (max_size < DNSLIB_EDNS_MIN_SIZE) { + if (max_size < KNOT_EDNS_MIN_SIZE) { debug_knot_edns("Not enough data to parse OPT RR header.\n"); - return DNSLIB_EFEWDATA; + return KNOT_EFEWDATA; } // owner of EDNS OPT RR must be root (0) if (*pos != 0) { debug_knot_edns("EDNS packet malformed (expected root " "domain as owner).\n"); - return DNSLIB_EMALF; + return KNOT_EMALF; } pos += 1; // check the type of the record (must be OPT) - if (knot_wire_read_u16(pos) != DNSLIB_RRTYPE_OPT) { + if (knot_wire_read_u16(pos) != KNOT_RRTYPE_OPT) { debug_knot_edns("EDNS packet malformed (expected OPT type" ".\n"); - return DNSLIB_EMALF; + return KNOT_EMALF; } pos += 2; @@ -79,7 +79,7 @@ int knot_edns_new_from_wire(knot_opt_rr_t *opt_rr, const uint8_t *wire, opt_rr->flags = knot_wire_read_u16(pos); pos += 2; - parsed = DNSLIB_EDNS_MIN_SIZE; + parsed = KNOT_EDNS_MIN_SIZE; // ignore RDATA, but move pos behind them uint16_t rdlength = knot_wire_read_u16(pos); @@ -87,14 +87,14 @@ int knot_edns_new_from_wire(knot_opt_rr_t *opt_rr, const uint8_t *wire, if (max_size - parsed < rdlength) { debug_knot_edns("Not enough data to parse OPT RR.\n"); - return DNSLIB_EFEWDATA; + return KNOT_EFEWDATA; } - while (parsed < rdlength + DNSLIB_EDNS_MIN_SIZE) { + while (parsed < rdlength + KNOT_EDNS_MIN_SIZE) { if (max_size - parsed < 4) { debug_knot_edns("Not enough data to parse OPT RR" " OPTION header.\n"); - return DNSLIB_EFEWDATA; + return KNOT_EFEWDATA; } uint16_t code = knot_wire_read_u16(pos); pos += 2; @@ -105,7 +105,7 @@ int knot_edns_new_from_wire(knot_opt_rr_t *opt_rr, const uint8_t *wire, if (max_size - parsed - 4 < length) { debug_knot_edns("Not enough data to parse OPT RR" " OPTION data.\n"); - return DNSLIB_EFEWDATA; + return KNOT_EFEWDATA; } int ret; if ((ret = @@ -126,8 +126,8 @@ int knot_edns_new_from_rr(knot_opt_rr_t *opt_rr, const knot_rrset_t *rrset) { if (opt_rr == NULL || rrset == NULL - || knot_rrset_type(rrset) != DNSLIB_RRTYPE_OPT) { - return DNSLIB_EBADARG; + || knot_rrset_type(rrset) != KNOT_RRTYPE_OPT) { + return KNOT_EBADARG; } debug_knot_edns("Parsing payload.\n"); @@ -168,14 +168,14 @@ int knot_edns_new_from_rr(knot_opt_rr_t *opt_rr, (const uint8_t *)(knot_rdata_item(rdata, 2)->raw_data + 1)); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { return rc; } rdata = knot_rrset_rdata_next(rrset, rdata); } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -241,11 +241,11 @@ uint16_t knot_edns_get_flags(const knot_opt_rr_t *opt_rr) int knot_edns_do(const knot_opt_rr_t *opt_rr) { if (opt_rr == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } debug_knot_edns("Flags: %u\n", opt_rr->flags); - return (opt_rr->flags & DNSLIB_EDNS_DO_MASK); + return (opt_rr->flags & KNOT_EDNS_DO_MASK); } /*----------------------------------------------------------------------------*/ @@ -256,7 +256,7 @@ void knot_edns_set_do(knot_opt_rr_t *opt_rr) return; } - opt_rr->flags |= DNSLIB_EDNS_DO_MASK; + opt_rr->flags |= KNOT_EDNS_DO_MASK; } /*----------------------------------------------------------------------------*/ @@ -265,18 +265,18 @@ int knot_edns_add_option(knot_opt_rr_t *opt_rr, uint16_t code, uint16_t length, const uint8_t *data) { if (opt_rr == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } if (opt_rr->option_count == opt_rr->options_max) { knot_opt_option_t *options_new = (knot_opt_option_t *)calloc( - (opt_rr->options_max + DNSLIB_EDNS_OPTION_STEP), + (opt_rr->options_max + KNOT_EDNS_OPTION_STEP), sizeof(knot_opt_option_t)); - CHECK_ALLOC_LOG(options_new, DNSLIB_ENOMEM); + CHECK_ALLOC_LOG(options_new, KNOT_ENOMEM); memcpy(options_new, opt_rr->options, opt_rr->option_count); opt_rr->options = options_new; - opt_rr->options_max += DNSLIB_EDNS_OPTION_STEP; + opt_rr->options_max += KNOT_EDNS_OPTION_STEP; } debug_knot_edns("Adding option.\n"); @@ -285,7 +285,7 @@ int knot_edns_add_option(knot_opt_rr_t *opt_rr, uint16_t code, debug_knot_edns("Data: %p.\n", data); opt_rr->options[opt_rr->option_count].data = (uint8_t *)malloc(length); - CHECK_ALLOC_LOG(opt_rr->options[opt_rr->option_count].data, DNSLIB_ENOMEM); + CHECK_ALLOC_LOG(opt_rr->options[opt_rr->option_count].data, KNOT_ENOMEM); memcpy(opt_rr->options[opt_rr->option_count].data, data, length); opt_rr->options[opt_rr->option_count].code = code; @@ -294,7 +294,7 @@ int knot_edns_add_option(knot_opt_rr_t *opt_rr, uint16_t code, ++opt_rr->option_count; opt_rr->size += 4 + length; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -302,7 +302,7 @@ int knot_edns_add_option(knot_opt_rr_t *opt_rr, uint16_t code, int knot_edns_has_option(const knot_opt_rr_t *opt_rr, uint16_t code) { if (opt_rr == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } int i = 0; @@ -321,19 +321,19 @@ short knot_edns_to_wire(const knot_opt_rr_t *opt_rr, uint8_t *wire, size_t max_size) { if (opt_rr == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } - assert(DNSLIB_EDNS_MIN_SIZE <= max_size); + assert(KNOT_EDNS_MIN_SIZE <= max_size); if (max_size < opt_rr->size) { debug_knot_edns("Not enough place for OPT RR wire format.\n"); - return DNSLIB_ESPACE; + return KNOT_ESPACE; } uint8_t *pos = wire; *(pos++) = 0; - knot_wire_write_u16(pos, DNSLIB_RRTYPE_OPT); + knot_wire_write_u16(pos, KNOT_RRTYPE_OPT); pos += 2; knot_wire_write_u16(pos, opt_rr->payload); pos += 2; @@ -367,7 +367,7 @@ short knot_edns_to_wire(const knot_opt_rr_t *opt_rr, uint8_t *wire, short knot_edns_size(knot_opt_rr_t *opt_rr) { if (opt_rr == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } return opt_rr->size; diff --git a/src/dnslib/edns.h b/src/dnslib/edns.h index b4801a6bdae755c570fbe319553ccace422614b3..d113b59e2b8195982e873cb449927256c6a9f3ce 100644 --- a/src/dnslib/edns.h +++ b/src/dnslib/edns.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_EDNS_H_ -#define _KNOT_DNSLIB_EDNS_H_ +#ifndef _KNOTDKNOT_EDNS_H_ +#define _KNOTDKNOT_EDNS_H_ #include <stdint.h> @@ -83,10 +83,10 @@ knot_opt_rr_t *knot_edns_new(); * than acutal size of the OPT RR). * * \return Size of the parserd OPT RR in bytes if successful (always > 0). - * \retval DNSLIB_EBADARG - * \retval DNSLIB_EFEWDATA - * \retval DNSLIB_EMALF - * \retval DNSLIB_ENOMEM + * \retval KNOT_EBADARG + * \retval KNOT_EFEWDATA + * \retval KNOT_EMALF + * \retval KNOT_ENOMEM */ int knot_edns_new_from_wire(knot_opt_rr_t *opt_rr, const uint8_t *wire, size_t max_size); @@ -207,8 +207,8 @@ void knot_edns_set_do(knot_opt_rr_t *opt_rr); * \param length Option data length in bytes. * \param data Option data. * - * \retval DNSLIB_EOK - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_ENOMEM */ int knot_edns_add_option(knot_opt_rr_t *opt_rr, uint16_t code, uint16_t length, const uint8_t *data); @@ -232,7 +232,7 @@ int knot_edns_has_option(const knot_opt_rr_t *opt_rr, uint16_t code); * \param max_size Maximum space available for the wire format in bytes. * * \return Size of the wire format in bytes if successful. - * \retval DNSLIB_ESPACE + * \retval KNOT_ESPACE */ short knot_edns_to_wire(const knot_opt_rr_t *opt_rr, uint8_t *wire, size_t max_size); @@ -253,6 +253,6 @@ short knot_edns_size(knot_opt_rr_t *opt_rr); */ void knot_edns_free(knot_opt_rr_t **opt_rr); -#endif /* _KNOT_DNSLIB_EDNS_H_ */ +#endif /* _KNOTDKNOT_EDNS_H_ */ /*! @} */ diff --git a/src/dnslib/error.h b/src/dnslib/error.h index 41e2b9f69667f64df85a0116e75a5901cfb38c0f..40ce5b1e80ffcd71b64aa6fb257c800d433906b1 100644 --- a/src/dnslib/error.h +++ b/src/dnslib/error.h @@ -9,38 +9,38 @@ * @{ */ -#ifndef _KNOT_DNSLIB_ERROR_H_ -#define _KNOT_DNSLIB_ERROR_H_ +#ifndef _KNOTDKNOT_ERROR_H_ +#define _KNOTDKNOT_ERROR_H_ #include "common/errors.h" /*! \brief Error codes used in the dnslib library. */ enum knot_error { - DNSLIB_EOK = 0, /*!< OK */ - DNSLIB_ERROR = -10000, /*!< General dnslib error. */ - DNSLIB_ENOMEM, /*!< Not enough memory. */ - DNSLIB_ENOTSUP, /*!< Operation not supported. */ - DNSLIB_EAGAIN, /*!< OS lacked necessary resources. */ - DNSLIB_ERANGE, /*!< Value is out of range. */ - DNSLIB_EBADARG, /*!< Wrong argument supported. */ - DNSLIB_EFEWDATA, /*!< Not enough data to parse. */ - DNSLIB_ESPACE, /*!< Not enough space provided. */ - DNSLIB_EMALF, /*!< Malformed data. */ - DNSLIB_ECRYPTO, /*!< Error in crypto library. */ - DNSLIB_ENSEC3PAR, /*!< Missing or wrong NSEC3PARAM record. */ - DNSLIB_EBADZONE, /*!< Domain name does not belong to the zone. */ - DNSLIB_EHASH, /*!< Error in hash table. */ - DNSLIB_EZONEIN, /*!< Error inserting zone. */ - DNSLIB_ENOZONE, /*!< No such zone found. */ - DNSLIB_ENONODE, /*!< No such node in zone found. */ - DNSLIB_EDNAMEPTR, /*!< Domain name pointer larger than allowed. */ - DNSLIB_EPAYLOAD, /*!< Payload in OPT RR larger than max wire size. */ - DNSLIB_ECRC, /*!< Wrong dump CRC. */ - DNSLIB_ERROR_COUNT = 18 + KNOT_EOK = 0, /*!< OK */ + KNOT_ERROR = -10000, /*!< General dnslib error. */ + KNOT_ENOMEM, /*!< Not enough memory. */ + KNOT_ENOTSUP, /*!< Operation not supported. */ + KNOT_EAGAIN, /*!< OS lacked necessary resources. */ + KNOT_ERANGE, /*!< Value is out of range. */ + KNOT_EBADARG, /*!< Wrong argument supported. */ + KNOT_EFEWDATA, /*!< Not enough data to parse. */ + KNOT_ESPACE, /*!< Not enough space provided. */ + KNOT_EMALF, /*!< Malformed data. */ + KNOT_ECRYPTO, /*!< Error in crypto library. */ + KNOT_ENSEC3PAR, /*!< Missing or wrong NSEC3PARAM record. */ + KNOT_EBADZONE, /*!< Domain name does not belong to the zone. */ + KNOT_EHASH, /*!< Error in hash table. */ + KNOT_EZONEIN, /*!< Error inserting zone. */ + KNOT_ENOZONE, /*!< No such zone found. */ + KNOT_ENONODE, /*!< No such node in zone found. */ + KNOT_EDNAMEPTR, /*!< Domain name pointer larger than allowed. */ + KNOT_EPAYLOAD, /*!< Payload in OPT RR larger than max wire size. */ + KNOT_ECRC, /*!< Wrong dump CRC. */ + KNOT_ERROR_COUNT = 18 }; /*! \brief Table linking error messages to error codes. */ -extern const error_table_t knot_error_msgs2[DNSLIB_ERROR_COUNT]; +extern const error_table_t knot_error_msgs2[KNOT_ERROR_COUNT]; /*! * \brief Returns error message for the given error code. @@ -54,6 +54,6 @@ static inline const char *knot_strerror2(int code) return error_to_str((const error_table_t*)knot_error_msgs2, code); } -#endif /* _KNOT_DNSLIB_ERROR_H_ */ +#endif /* _KNOTDKNOT_ERROR_H_ */ /*! @} */ diff --git a/src/dnslib/hash/cuckoo-hash-table.h b/src/dnslib/hash/cuckoo-hash-table.h index 8c47693cc38ab5f1e5f9f9aac8bbc04a65e6f6f7..dac4826213a6c251da73e15b0e3c748c7e73bf48 100644 --- a/src/dnslib/hash/cuckoo-hash-table.h +++ b/src/dnslib/hash/cuckoo-hash-table.h @@ -18,8 +18,8 @@ * \addtogroup hashing * @{ */ -#ifndef _KNOT_CUCKOO_HASH_TABLE_H_ -#define _KNOT_CUCKOO_HASH_TABLE_H_ +#ifndef _KNOTDCUCKOO_HASH_TABLE_H_ +#define _KNOTDCUCKOO_HASH_TABLE_H_ #include <stdint.h> /* uint32_t */ #include <stdlib.h> /* size_t */ @@ -278,6 +278,6 @@ void ck_dump_table(const ck_hash_table_t *table); /*----------------------------------------------------------------------------*/ -#endif /* _KNOT_CUCKOO_HASH_TABLE_H_ */ +#endif /* _KNOTDCUCKOO_HASH_TABLE_H_ */ /*! @} */ diff --git a/src/dnslib/hash/hash-functions.h b/src/dnslib/hash/hash-functions.h index 83d24ffac7278f6a57a6c4704f1f88e270f2d48e..e790c244b3550f79bfbe71ec072e00318b9e8670 100644 --- a/src/dnslib/hash/hash-functions.h +++ b/src/dnslib/hash/hash-functions.h @@ -13,8 +13,8 @@ * @{ */ -#ifndef _KNOT_HASH_FUNCTIONS_H_ -#define _KNOT_HASH_FUNCTIONS_H_ +#ifndef _KNOTDHASH_FUNCTIONS_H_ +#define _KNOTDHASH_FUNCTIONS_H_ typedef unsigned long int u4; /* unsigned 4-byte type */ typedef unsigned char u1; /* unsigned 1-byte type */ @@ -96,6 +96,6 @@ unsigned long djb_hash(const unsigned char *key, int size); */ unsigned long elf_hash(const unsigned char *key, int size); -#endif /* _KNOT_HASH_FUNCTIONS_H_ */ +#endif /* _KNOTDHASH_FUNCTIONS_H_ */ /*! @} */ diff --git a/src/dnslib/hash/universal-system.h b/src/dnslib/hash/universal-system.h index 8d7b65a3851dfdce76f8f44142c4d03cd5791c4d..7461f1d82c5aae98da0ec00039edacb227a3f4b7 100644 --- a/src/dnslib/hash/universal-system.h +++ b/src/dnslib/hash/universal-system.h @@ -24,8 +24,8 @@ * @{ */ -#ifndef _KNOT_UNIVERSAL_SYSTEM_H_ -#define _KNOT_UNIVERSAL_SYSTEM_H_ +#ifndef _KNOTDUNIVERSAL_SYSTEM_H_ +#define _KNOTDUNIVERSAL_SYSTEM_H_ #include <stdint.h> #include "dnslib/dnslib-common.h" @@ -89,6 +89,6 @@ uint32_t us_hash(const us_system_t *system, uint32_t value, uint table_exp, /*----------------------------------------------------------------------------*/ -#endif /* _KNOT_UNIVERSAL_SYSTEM_H_ */ +#endif /* _KNOTDUNIVERSAL_SYSTEM_H_ */ /*! @} */ diff --git a/src/dnslib/name-server.c b/src/dnslib/name-server.c index 2e74555c78558fd0f27a1e1626ed05a5199a9ee4..36504aa38030c6c58bfd5de301c19bc691c20f8b 100644 --- a/src/dnslib/name-server.c +++ b/src/dnslib/name-server.c @@ -77,7 +77,7 @@ static const knot_zone_t *ns_get_zone_for_qname(knot_zonedb_t *zdb, * the zone (but use whole qname in search for the record), as the DS * records are only present in a parent zone. */ - if (qtype == DNSLIB_RRTYPE_DS) { + if (qtype == KNOT_RRTYPE_DS) { /*! \todo Optimize, do not deep copy dname. */ knot_dname_t *name = knot_dname_left_chop(qname); zone = knot_zonedb_find_zone_for_name(zdb, name); @@ -197,9 +197,9 @@ static void ns_check_wildcard(const knot_dname_t *name, knot_packet_t *resp, * \param tc Set to 1 if omitting the RRSIG RRSet should result in setting the * TC bit in the response. * - * \return DNSLIB_EOK - * \return DNSLIB_ENOMEM - * \return DNSLIB_ESPACE + * \return KNOT_EOK + * \return KNOT_ENOMEM + * \return KNOT_ESPACE */ static int ns_add_rrsigs(const knot_rrset_t *rrset, knot_packet_t *resp, const knot_dname_t *name, @@ -229,7 +229,7 @@ static int ns_add_rrsigs(const knot_rrset_t *rrset, knot_packet_t *resp, return add_rrset_to_resp(resp, rrsigs, tc, 0, 0); } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -257,7 +257,7 @@ static void ns_follow_cname(const knot_node_t **node, const knot_rrset_t *cname_rrset; while (*node != NULL - && (cname_rrset = knot_node_rrset(*node, DNSLIB_RRTYPE_CNAME)) + && (cname_rrset = knot_node_rrset(*node, KNOT_RRTYPE_CNAME)) != NULL) { /* put the CNAME record to answer, but replace the possible wildcard name with qname */ @@ -277,7 +277,7 @@ static void ns_follow_cname(const knot_node_t **node, add_rrset_to_resp(resp, rrset, tc, 0, 0); ns_add_rrsigs(rrset, resp, *qname, add_rrset_to_resp, tc); -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name = knot_dname_to_str(knot_rrset_owner(rrset)); debug_knot_ns("CNAME record for owner %s put to response.\n", name); @@ -306,7 +306,7 @@ DEBUG_DNSLIB_NS( * * \param node Node where to take the RRSet from. * \param name Actual searched name (used in case of wildcard RRSet(s)). - * \param type Type of the RRSet(s). If set to DNSLIB_RRTYPE_ANY, all RRSets + * \param type Type of the RRSet(s). If set to KNOT_RRTYPE_ANY, all RRSets * from the node will be added to the answer. * \param resp Response where to add the RRSets. * @@ -316,14 +316,14 @@ static int ns_put_answer(const knot_node_t *node, const knot_dname_t *name, uint16_t type, knot_packet_t *resp) { int added = 0; -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name_str = knot_dname_to_str(node->owner); debug_knot_ns("Putting answers from node %s.\n", name_str); free(name_str); ); switch (type) { - case DNSLIB_RRTYPE_ANY: { + case KNOT_RRTYPE_ANY: { debug_knot_ns("Returning all RRTYPES.\n"); const knot_rrset_t **rrsets = knot_node_rrsets(node); if (rrsets == NULL) { @@ -360,7 +360,7 @@ DEBUG_DNSLIB_NS( } break; } - case DNSLIB_RRTYPE_RRSIG: { + case KNOT_RRTYPE_RRSIG: { debug_knot_ns("Returning all RRSIGs.\n"); const knot_rrset_t **rrsets = knot_node_rrsets(node); if (rrsets == NULL) { @@ -411,7 +411,7 @@ DEBUG_DNSLIB_NS( } } - knot_response2_set_rcode(resp, DNSLIB_RCODE_NOERROR); + knot_response2_set_rcode(resp, KNOT_RCODE_NOERROR); return added; } @@ -466,13 +466,13 @@ static void ns_put_additional_for_rrset(knot_packet_t *resp, const knot_rrset_t *rrset_add; if (node != NULL) { -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name = knot_dname_to_str(node->owner); debug_knot_ns("Putting additional from node %s\n", name); free(name); ); debug_knot_ns("Checking CNAMEs...\n"); - if (knot_node_rrset(node, DNSLIB_RRTYPE_CNAME) + if (knot_node_rrset(node, KNOT_RRTYPE_CNAME) != NULL) { debug_knot_ns("Found CNAME in node, following...\n"); const knot_dname_t *dname @@ -483,7 +483,7 @@ DEBUG_DNSLIB_NS( // A RRSet debug_knot_ns("A RRSets...\n"); - rrset_add = knot_node_rrset(node, DNSLIB_RRTYPE_A); + rrset_add = knot_node_rrset(node, KNOT_RRTYPE_A); if (rrset_add != NULL) { debug_knot_ns("Found A RRsets.\n"); const knot_rrset_t *rrset_add2 = rrset_add; @@ -496,7 +496,7 @@ DEBUG_DNSLIB_NS( // AAAA RRSet debug_knot_ns("AAAA RRSets...\n"); - rrset_add = knot_node_rrset(node, DNSLIB_RRTYPE_AAAA); + rrset_add = knot_node_rrset(node, KNOT_RRTYPE_AAAA); if (rrset_add != NULL) { debug_knot_ns("Found AAAA RRsets.\n"); const knot_rrset_t *rrset_add2 = rrset_add; @@ -527,9 +527,9 @@ DEBUG_DNSLIB_NS( */ static int ns_additional_needed(uint16_t qtype) { - return (qtype == DNSLIB_RRTYPE_MX || - qtype == DNSLIB_RRTYPE_NS || - qtype == DNSLIB_RRTYPE_SRV); + return (qtype == KNOT_RRTYPE_MX || + qtype == KNOT_RRTYPE_NS || + qtype == KNOT_RRTYPE_SRV); } /*----------------------------------------------------------------------------*/ @@ -575,7 +575,7 @@ static void ns_put_authority_ns(const knot_zone_contents_t *zone, knot_packet_t *resp) { const knot_rrset_t *ns_rrset = knot_node_rrset( - knot_zone_contents_apex(zone), DNSLIB_RRTYPE_NS); + knot_zone_contents_apex(zone), KNOT_RRTYPE_NS); if (ns_rrset != NULL) { knot_response2_add_rrset_authority(resp, ns_rrset, 0, 1, 0); @@ -596,7 +596,7 @@ static void ns_put_authority_soa(const knot_zone_contents_t *zone, knot_packet_t *resp) { const knot_rrset_t *soa_rrset = knot_node_rrset( - knot_zone_contents_apex(zone), DNSLIB_RRTYPE_SOA); + knot_zone_contents_apex(zone), KNOT_RRTYPE_SOA); assert(soa_rrset != NULL); knot_response2_add_rrset_authority(resp, soa_rrset, 0, 0, 0); @@ -657,7 +657,7 @@ static void ns_put_nsec3_from_node(const knot_node_t *node, && knot_query_dnssec_requested(knot_packet_query(resp))); const knot_rrset_t *rrset = knot_node_rrset(node, - DNSLIB_RRTYPE_NSEC3); + KNOT_RRTYPE_NSEC3); assert(rrset != NULL); int res = knot_response2_add_rrset_authority(resp, rrset, 1, 1, 0); @@ -676,7 +676,7 @@ static void ns_put_nsec3_from_node(const knot_node_t *node, * \param name Domain name to cover. * \param resp Response where to add the RRSets. * - * \retval DNSLIB_EOK + * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL if a runtime collision occured. The server should * respond with SERVFAIL in such case. */ @@ -689,7 +689,7 @@ static int ns_put_covering_nsec3(const knot_zone_contents_t *zone, &node, &prev); assert(match >= 0); - if (match == DNSLIB_ZONE_NAME_FOUND){ + if (match == KNOT_ZONE_NAME_FOUND){ // run-time collision => SERVFAIL return NS_ERR_SERVFAIL; } @@ -700,7 +700,7 @@ static int ns_put_covering_nsec3(const knot_zone_contents_t *zone, // assert(prev != NULL); // } -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name = knot_dname_to_str(prev->owner); debug_knot_ns("Covering NSEC3 node: %s\n", name); free(name); @@ -708,7 +708,7 @@ DEBUG_DNSLIB_NS( ns_put_nsec3_from_node(prev, resp); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -728,7 +728,7 @@ DEBUG_DNSLIB_NS( * \param qname Searched (non-existent) name. * \param resp Response where to add the NSEC3s. * - * \retval DNSLIB_EOK + * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL */ static int ns_put_nsec3_closest_encloser_proof( @@ -744,16 +744,16 @@ static int ns_put_nsec3_closest_encloser_proof( assert(resp != NULL); if (knot_zone_contents_nsec3params(zone) == NULL) { -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name = knot_dname_to_str(knot_node_owner( knot_zone_contents_apex(zone))); debug_knot_ns("No NSEC3PARAM found in zone %s.\n", name); free(name); ); - return DNSLIB_EOK; + return KNOT_EOK; } -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name = knot_dname_to_str(knot_node_owner(*closest_encloser)); debug_knot_ns("Closest encloser: %s\n", name); free(name); @@ -773,7 +773,7 @@ DEBUG_DNSLIB_NS( assert(nsec3_node != NULL); -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name = knot_dname_to_str((*closest_encloser)->owner); debug_knot_ns("Closest provable encloser: %s\n", name); free(name); @@ -800,7 +800,7 @@ DEBUG_DNSLIB_NS( if (next_closer == NULL) { return NS_ERR_SERVFAIL; } -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name = knot_dname_to_str(next_closer); debug_knot_ns("Next closer name: %s\n", name); free(name); @@ -839,7 +839,7 @@ static knot_dname_t *ns_wildcard_child_name(const knot_dname_t *name) return NULL; } -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name = knot_dname_to_str(wildcard); debug_knot_ns("Wildcard: %s\n", name); free(name); @@ -859,7 +859,7 @@ DEBUG_DNSLIB_NS( * \param node Node whose non-existent wildcard child should be covered. * \param resp Response where to add the NSEC3s. * - * \retval DNSLIB_EOK + * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL */ static int ns_put_nsec3_no_wildcard_child(const knot_zone_contents_t *zone, @@ -906,9 +906,9 @@ static void ns_put_nsec_nsec3_nodata(const knot_node_t *node, const knot_node_t *nsec3_node = knot_node_nsec3_node(node, 1); const knot_rrset_t *rrset = NULL; - if ((rrset = knot_node_rrset(node, DNSLIB_RRTYPE_NSEC)) != NULL + if ((rrset = knot_node_rrset(node, KNOT_RRTYPE_NSEC)) != NULL || (nsec3_node != NULL && (rrset = - knot_node_rrset(nsec3_node, DNSLIB_RRTYPE_NSEC3)) != NULL)) { + knot_node_rrset(nsec3_node, KNOT_RRTYPE_NSEC3)) != NULL)) { knot_response2_add_rrset_authority(resp, rrset, 1, 0, 0); // add RRSIG for the RRSet if ((rrset = knot_rrset_rrsigs(rrset)) != NULL) { @@ -933,7 +933,7 @@ static void ns_put_nsec_nsec3_nodata(const knot_node_t *node, * \param closest_encloser Closest encloser of \a qname. Must not be NULL. * \param resp Response where to put the NSECs. * - * \retval DNSLIB_EOK + * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL */ static int ns_put_nsec_nxdomain(const knot_dname_t *qname, @@ -952,7 +952,7 @@ static int ns_put_nsec_nxdomain(const knot_dname_t *qname, } // 1) NSEC proving that there is no node with the searched name - rrset = knot_node_rrset(previous, DNSLIB_RRTYPE_NSEC); + rrset = knot_node_rrset(previous, KNOT_RRTYPE_NSEC); if (rrset == NULL) { // no NSEC records return NS_ERR_SERVFAIL; @@ -994,7 +994,7 @@ static int ns_put_nsec_nxdomain(const knot_dname_t *qname, knot_dname_free(&wildcard); if (prev_new != previous) { - rrset = knot_node_rrset(prev_new, DNSLIB_RRTYPE_NSEC); + rrset = knot_node_rrset(prev_new, KNOT_RRTYPE_NSEC); assert(rrset != NULL); knot_response2_add_rrset_authority(resp, rrset, 1, 0, 0); rrset = knot_rrset_rrsigs(rrset); @@ -1002,7 +1002,7 @@ static int ns_put_nsec_nxdomain(const knot_dname_t *qname, knot_response2_add_rrset_authority(resp, rrset, 1, 0, 0); } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1018,7 +1018,7 @@ static int ns_put_nsec_nxdomain(const knot_dname_t *qname, * in the zone. * \param resp Response where to put the NSEC3s. * - * \retval DNSLIB_EOK + * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL */ static int ns_put_nsec3_nxdomain(const knot_zone_contents_t *zone, @@ -1031,7 +1031,7 @@ static int ns_put_nsec3_nxdomain(const knot_zone_contents_t *zone, int ret = ns_put_nsec3_closest_encloser_proof(zone, &closest_encloser, qname, resp); // 2) NSEC3 covering non-existent wildcard - if (ret == DNSLIB_EOK) { + if (ret == KNOT_EOK) { ret = ns_put_nsec3_no_wildcard_child(zone, closest_encloser, resp); } @@ -1055,7 +1055,7 @@ static int ns_put_nsec3_nxdomain(const knot_zone_contents_t *zone, * zone). * \param resp Response where to put the NSECs. * - * \retval DNSLIB_EOK + * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL */ static int ns_put_nsec_nsec3_nxdomain(const knot_zone_contents_t *zone, @@ -1092,7 +1092,7 @@ static int ns_put_nsec_nsec3_nxdomain(const knot_zone_contents_t *zone, * query. * \param resp Response to put the NSEC3s into. * - * \retval DNSLIB_EOK + * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL */ static int ns_put_nsec3_wildcard(const knot_zone_contents_t *zone, @@ -1116,7 +1116,7 @@ static int ns_put_nsec3_wildcard(const knot_zone_contents_t *zone, if (next_closer == NULL) { return NS_ERR_SERVFAIL; } -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name = knot_dname_to_str(next_closer); debug_knot_ns("Next closer name: %s\n", name); free(name); @@ -1158,7 +1158,7 @@ static void ns_put_nsec_wildcard(const knot_zone_contents_t *zone, } const knot_rrset_t *rrset = - knot_node_rrset(previous, DNSLIB_RRTYPE_NSEC); + knot_node_rrset(previous, KNOT_RRTYPE_NSEC); if (rrset != NULL) { // NSEC proving that there is no node with the searched name knot_response2_add_rrset_authority(resp, rrset, 1, 0, 0); @@ -1182,7 +1182,7 @@ static void ns_put_nsec_wildcard(const knot_zone_contents_t *zone, * \param qname Actual searched domain name. * \param resp Response where to put the NSECs and NSEC3s. * - * \retval DNSLIB_EOK + * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL */ static int ns_put_nsec_nsec3_wildcard_nodata(const knot_node_t *node, @@ -1192,7 +1192,7 @@ static int ns_put_nsec_nsec3_wildcard_nodata(const knot_node_t *node, const knot_dname_t *qname, knot_packet_t *resp) { - int ret = DNSLIB_EOK; + int ret = KNOT_EOK; if (DNSSEC_ENABLED && knot_query_dnssec_requested(knot_packet_query(resp))) { if (knot_zone_contents_nsec3_enabled(zone)) { @@ -1227,7 +1227,7 @@ static int ns_put_nsec_nsec3_wildcard_nodata(const knot_node_t *node, * \param qname Actual searched domain name. * \param resp Response where to put the NSECs and NSEC3s. * - * \retval DNSLIB_EOK + * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL */ static int ns_put_nsec_nsec3_wildcard_answer(const knot_node_t *node, @@ -1237,7 +1237,7 @@ static int ns_put_nsec_nsec3_wildcard_answer(const knot_node_t *node, const knot_dname_t *qname, knot_packet_t *resp) { - int r = DNSLIB_EOK; + int r = KNOT_EOK; if (DNSSEC_ENABLED && knot_query_dnssec_requested(knot_packet_query(resp)) && knot_dname_is_wildcard(knot_node_owner(node))) { @@ -1266,7 +1266,7 @@ static int ns_put_nsec_nsec3_wildcard_answer(const knot_node_t *node, * \param qname Searched name (which caused the referral). * \param resp Response. * - * \retval DNSLIB_EOK + * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL */ static inline int ns_referral(const knot_node_t *node, @@ -1282,7 +1282,7 @@ static inline int ns_referral(const knot_node_t *node, node = knot_node_parent(node, 1); } - const knot_rrset_t *rrset = knot_node_rrset(node, DNSLIB_RRTYPE_NS); + const knot_rrset_t *rrset = knot_node_rrset(node, KNOT_RRTYPE_NS); assert(rrset != NULL); // TODO: wildcards?? @@ -1292,14 +1292,14 @@ static inline int ns_referral(const knot_node_t *node, ns_add_rrsigs(rrset, resp, node->owner, knot_response2_add_rrset_authority, 1); - int ret = DNSLIB_EOK; + int ret = KNOT_EOK; // add DS records debug_knot_ns("DNSSEC requested: %d\n", knot_query_dnssec_requested(knot_packet_query(resp))); - debug_knot_ns("DS records: %p\n", knot_node_rrset(node, DNSLIB_RRTYPE_DS)); + debug_knot_ns("DS records: %p\n", knot_node_rrset(node, KNOT_RRTYPE_DS)); if (DNSSEC_ENABLED && knot_query_dnssec_requested(knot_packet_query(resp))) { - rrset = knot_node_rrset(node, DNSLIB_RRTYPE_DS); + rrset = knot_node_rrset(node, KNOT_RRTYPE_DS); if (rrset != NULL) { knot_response2_add_rrset_authority(resp, rrset, 1, 0, 0); @@ -1323,9 +1323,9 @@ static inline int ns_referral(const knot_node_t *node, } } - if (ret == DNSLIB_EOK) { + if (ret == KNOT_EOK) { ns_put_additional(resp); - knot_response2_set_rcode(resp, DNSLIB_RCODE_NOERROR); + knot_response2_set_rcode(resp, KNOT_RCODE_NOERROR); } return ret; } @@ -1352,7 +1352,7 @@ static inline int ns_referral(const knot_node_t *node, * \param qtype Searched RR type. * \param resp Response. * - * \retval DNSLIB_EOK + * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL */ static int ns_answer_from_node(const knot_node_t *node, @@ -1366,7 +1366,7 @@ static int ns_answer_from_node(const knot_node_t *node, debug_knot_ns("Putting answers from found node to the response...\n"); int answers = ns_put_answer(node, qname, qtype, resp); - int ret = DNSLIB_EOK; + int ret = KNOT_EOK; if (answers == 0) { // if NODATA response, put SOA if (knot_node_rrset_count(node) == 0) { // node is an empty non-terminal => NSEC for NXDOMAIN @@ -1390,7 +1390,7 @@ static int ns_answer_from_node(const knot_node_t *node, ns_put_authority_ns(zone, resp); } - if (ret == DNSLIB_EOK) { + if (ret == KNOT_EOK) { ns_put_additional(resp); } return ret; @@ -1421,7 +1421,7 @@ static knot_rrset_t *ns_cname_from_dname(const knot_rrset_t *dname_rrset, } knot_rrset_t *cname_rrset = knot_rrset_new( - owner, DNSLIB_RRTYPE_CNAME, DNSLIB_CLASS_IN, SYNTH_CNAME_TTL); + owner, KNOT_RRTYPE_CNAME, KNOT_CLASS_IN, SYNTH_CNAME_TTL); /* Release owner, as it's retained in rrset. */ knot_dname_release(owner); @@ -1434,7 +1434,7 @@ static knot_rrset_t *ns_cname_from_dname(const knot_rrset_t *dname_rrset, knot_dname_t *cname = knot_dname_replace_suffix(qname, knot_dname_size(knot_rrset_owner(dname_rrset)), knot_rdata_get_item(knot_rrset_rdata(dname_rrset), 0)->dname); -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name = knot_dname_to_str(cname); debug_knot_ns("CNAME canonical name: %s.\n", name); free(name); @@ -1468,7 +1468,7 @@ static int ns_dname_is_too_long(const knot_rrset_t *dname_rrset, - knot_dname_label_count(knot_rrset_owner(dname_rrset)) + knot_dname_label_count(knot_rdata_get_item( knot_rrset_rdata(dname_rrset), 0)->dname) - > DNSLIB_MAX_DNAME_LENGTH) { + > KNOT_MAX_DNAME_LENGTH) { return 1; } else { return 0; @@ -1492,7 +1492,7 @@ static void ns_process_dname(const knot_rrset_t *dname_rrset, const knot_dname_t *qname, knot_packet_t *resp) { -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name = knot_dname_to_str(knot_rrset_owner(dname_rrset)); debug_knot_ns("Processing DNAME for owner %s...\n", name); free(name); @@ -1505,7 +1505,7 @@ DEBUG_DNSLIB_NS( knot_response2_add_rrset_answer, 1); if (ns_dname_is_too_long(dname_rrset, qname)) { - knot_response2_set_rcode(resp, DNSLIB_RCODE_YXDOMAIN); + knot_response2_set_rcode(resp, KNOT_RCODE_YXDOMAIN); return; } @@ -1532,7 +1532,7 @@ DEBUG_DNSLIB_NS( static void ns_add_dnskey(const knot_node_t *apex, knot_packet_t *resp) { const knot_rrset_t *rrset = - knot_node_rrset(apex, DNSLIB_RRTYPE_DNSKEY); + knot_node_rrset(apex, KNOT_RRTYPE_DNSKEY); if (rrset != NULL) { knot_response2_add_rrset_additional(resp, rrset, 0, 0, 0); ns_add_rrsigs(rrset, resp, apex->owner, @@ -1551,7 +1551,7 @@ static void ns_add_dnskey(const knot_node_t *apex, knot_packet_t *resp) * \param qtype QTYPE from the query. * \param resp Response to fill in. * - * \retval DNSLIB_EOK + * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL * * \todo Describe the answering logic in detail. @@ -1572,11 +1572,11 @@ search: find_ret = knot_zone_contents_find_dname(zone, qname, &node, &closest_encloser, &previous); #endif - if (find_ret == DNSLIB_EBADARG) { + if (find_ret == KNOT_EBADARG) { return NS_ERR_SERVFAIL; } -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name; if (node) { name = knot_dname_to_str(node->owner); @@ -1601,10 +1601,10 @@ DEBUG_DNSLIB_NS( debug_knot_ns(" and previous node: (nil).\n"); } ); - if (find_ret == DNSLIB_EBADZONE) { + if (find_ret == KNOT_EBADZONE) { // possible only if we followed cname assert(cname != 0); - knot_response2_set_rcode(resp, DNSLIB_RCODE_NOERROR); + knot_response2_set_rcode(resp, KNOT_RCODE_NOERROR); auth_soa = 1; knot_response2_set_aa(resp); goto finalize; @@ -1623,10 +1623,10 @@ have_node: goto finalize; } - if (find_ret == DNSLIB_ZONE_NAME_NOT_FOUND) { + if (find_ret == KNOT_ZONE_NAME_NOT_FOUND) { // DNAME? const knot_rrset_t *dname_rrset = knot_node_rrset( - closest_encloser, DNSLIB_RRTYPE_DNAME); + closest_encloser, KNOT_RRTYPE_DNAME); if (dname_rrset != NULL) { ns_process_dname(dname_rrset, qname, resp); auth_soa = 1; @@ -1645,14 +1645,14 @@ have_node: debug_knot_ns("Setting NXDOMAIN RCODE.\n"); // return NXDOMAIN knot_response2_set_rcode(resp, - DNSLIB_RCODE_NXDOMAIN); + KNOT_RCODE_NXDOMAIN); if (ns_put_nsec_nsec3_nxdomain(zone, previous, closest_encloser, qname, resp) != 0) { return NS_ERR_SERVFAIL; } } else { knot_response2_set_rcode(resp, - DNSLIB_RCODE_NOERROR); + KNOT_RCODE_NOERROR); } knot_response2_set_aa(resp); goto finalize; @@ -1667,8 +1667,8 @@ have_node: goto finalize; } - if (knot_node_rrset(node, DNSLIB_RRTYPE_CNAME) != NULL) { -DEBUG_DNSLIB_NS( + if (knot_node_rrset(node, KNOT_RRTYPE_CNAME) != NULL) { +DEBUG_KNOT_NS( char *name = knot_dname_to_str(node->owner); debug_knot_ns("Node %s has CNAME record, resolving...\n", name); @@ -1677,7 +1677,7 @@ DEBUG_DNSLIB_NS( const knot_dname_t *act_name = qname; ns_follow_cname(&node, &act_name, resp, knot_response2_add_rrset_answer, 1); -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name2 = knot_dname_to_str(act_name); debug_knot_ns("Canonical name: %s, node found: %p\n", name2, node); @@ -1691,7 +1691,7 @@ DEBUG_DNSLIB_NS( goto search; } else if (node->owner != act_name) { // the stored node is closest encloser - find_ret = DNSLIB_ZONE_NAME_NOT_FOUND; + find_ret = KNOT_ZONE_NAME_NOT_FOUND; closest_encloser = node; node = NULL; goto have_node; @@ -1700,11 +1700,11 @@ DEBUG_DNSLIB_NS( ret = ns_answer_from_node(node, closest_encloser, previous, zone, qname, qtype, resp); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { goto finalize; } knot_response2_set_aa(resp); - knot_response2_set_rcode(resp, DNSLIB_RCODE_NOERROR); + knot_response2_set_rcode(resp, KNOT_RCODE_NOERROR); // this is the only case when the servers answers from // particular node, i.e. the only case when it may return SOA @@ -1712,12 +1712,12 @@ DEBUG_DNSLIB_NS( if (DNSSEC_ENABLED && knot_query_dnssec_requested(knot_packet_query(resp)) && node == knot_zone_contents_apex(zone) - && (qtype == DNSLIB_RRTYPE_SOA || qtype == DNSLIB_RRTYPE_NS)) { + && (qtype == KNOT_RRTYPE_SOA || qtype == KNOT_RRTYPE_NS)) { ns_add_dnskey(node, resp); } finalize: - if (ret == DNSLIB_EOK && auth_soa) { + if (ret == KNOT_EOK && auth_soa) { ns_put_authority_soa(zone, resp); } @@ -1735,7 +1735,7 @@ finalize: * \param db Zone database to use for answering. * \param resp Response that holds the parsed query. * - * \retval DNSLIB_EOK + * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL */ static int ns_answer(knot_zonedb_t *db, knot_packet_t *resp) @@ -1744,7 +1744,7 @@ static int ns_answer(knot_zonedb_t *db, knot_packet_t *resp) assert(qname != NULL); uint16_t qtype = knot_packet_qtype(resp); -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name_str = knot_dname_to_str(qname); debug_knot_ns("Trying to find zone for QNAME %s\n", name_str); free(name_str); @@ -1756,11 +1756,11 @@ DEBUG_DNSLIB_NS( // if no zone found, return REFUSED if (zone == NULL) { debug_knot_ns("No zone found.\n"); - knot_response2_set_rcode(resp, DNSLIB_RCODE_REFUSED); + knot_response2_set_rcode(resp, KNOT_RCODE_REFUSED); //knot_dname_free(&qname); - return DNSLIB_EOK; + return KNOT_EOK; } -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name_str2 = knot_dname_to_str(zone->contents->apex->owner); debug_knot_ns("Found zone for QNAME %s\n", name_str2); free(name_str2); @@ -1783,7 +1783,7 @@ DEBUG_DNSLIB_NS( * \param wire_size In: space available for the wire format in bytes. * Out: actual size of the wire format in bytes. * - * \retval DNSLIB_EOK + * \retval KNOT_EOK * \retval NS_ERR_SERVFAIL */ static int ns_response_to_wire(knot_packet_t *resp, uint8_t *wire, @@ -1794,7 +1794,7 @@ static int ns_response_to_wire(knot_packet_t *resp, uint8_t *wire, int ret = 0; if ((ret = knot_packet_to_wire(resp, &rwire, &rsize)) - != DNSLIB_EOK) { + != KNOT_EOK) { debug_knot_ns("Error converting response packet " "to wire format (error %d).\n", ret); return NS_ERR_SERVFAIL; @@ -1810,7 +1810,7 @@ static int ns_response_to_wire(knot_packet_t *resp, uint8_t *wire, *wire_size = rsize; //free(rwire); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1839,7 +1839,7 @@ static int ns_axfr_send_and_clear(knot_ns_xfr_t *xfr) // // send back SERVFAIL (as this is our problem) // ns_error_response(nameserver, // knot_wire_get_id(query_wire), -// DNSLIB_RCODE_SERVFAIL, response_wire, +// KNOT_RCODE_SERVFAIL, response_wire, // rsize); } @@ -1863,7 +1863,7 @@ static int ns_axfr_send_and_clear(knot_ns_xfr_t *xfr) debug_knot_ns("Response structure after clearing:\n"); knot_packet_dump(xfr->response); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1875,7 +1875,7 @@ static void ns_axfr_from_node(knot_node_t *node, void *data) ns_axfr_params_t *params = (ns_axfr_params_t *)data; - if (params->ret != DNSLIB_EOK) { + if (params->ret != KNOT_EOK) { // just skip (will be called on next node with the same params debug_knot_ns("Params contain error, skipping node...\n"); return; @@ -1885,7 +1885,7 @@ static void ns_axfr_from_node(knot_node_t *node, void *data) const knot_rrset_t **rrsets = knot_node_rrsets(node); if (rrsets == NULL) { - params->ret = DNSLIB_ENOMEM; + params->ret = KNOT_ENOMEM; return; } @@ -1900,7 +1900,7 @@ rrset: knot_rrtype_to_string(knot_rrset_type(rrset))); // do not add SOA - if (knot_rrset_type(rrset) == DNSLIB_RRTYPE_SOA) { + if (knot_rrset_type(rrset) == KNOT_RRTYPE_SOA) { ++i; continue; } @@ -1908,20 +1908,20 @@ rrset: ret = knot_response2_add_rrset_answer(params->xfr->response, rrset, 0, 0, 1); - if (ret == DNSLIB_ESPACE) { + if (ret == KNOT_ESPACE) { // TODO: send the packet and clean the structure debug_knot_ns("Packet full, sending..\n"); ret = ns_axfr_send_and_clear(params->xfr); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { // some wierd problem, we should end - params->ret = DNSLIB_ERROR; + params->ret = KNOT_ERROR; break; } // otherwise try once more with the same RRSet goto rrset; - } else if (ret != DNSLIB_EOK) { + } else if (ret != KNOT_EOK) { // some wierd problem, we should end - params->ret = DNSLIB_ERROR; + params->ret = KNOT_ERROR; break; } @@ -1936,20 +1936,20 @@ rrsigs: ret = knot_response2_add_rrset_answer(params->xfr->response, rrset, 0, 0, 1); - if (ret == DNSLIB_ESPACE) { + if (ret == KNOT_ESPACE) { // TODO: send the packet and clean the structure debug_knot_ns("Packet full, sending..\n"); ret = ns_axfr_send_and_clear(params->xfr); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { // some wierd problem, we should end - params->ret = DNSLIB_ERROR; + params->ret = KNOT_ERROR; break; } // otherwise try once more with the same RRSet goto rrsigs; - } else if (ret != DNSLIB_EOK) { + } else if (ret != KNOT_EOK) { // some wierd problem, we should end - params->ret = DNSLIB_ERROR; + params->ret = KNOT_ERROR; break; } @@ -1963,7 +1963,7 @@ rrsigs: } /*! \todo maybe distinguish some error codes. */ - //params->ret = (ret == 0) ? DNSLIB_EOK : DNSLIB_ERROR; + //params->ret = (ret == 0) ? KNOT_EOK : KNOT_ERROR; } /*----------------------------------------------------------------------------*/ @@ -1978,7 +1978,7 @@ static int ns_axfr_from_zone(knot_zone_contents_t *zone, knot_ns_xfr_t *xfr) ns_axfr_params_t params; params.xfr = xfr; - params.ret = DNSLIB_EOK; + params.ret = KNOT_EOK; /* * First SOA @@ -1986,10 +1986,10 @@ static int ns_axfr_from_zone(knot_zone_contents_t *zone, knot_ns_xfr_t *xfr) // retrieve SOA - must be send as first and last RR const knot_rrset_t *soa_rrset = knot_node_rrset( - knot_zone_contents_apex(zone), DNSLIB_RRTYPE_SOA); + knot_zone_contents_apex(zone), KNOT_RRTYPE_SOA); if (soa_rrset == NULL) { // some really serious error - return DNSLIB_ERROR; + return KNOT_ERROR; } int ret; @@ -1997,32 +1997,32 @@ static int ns_axfr_from_zone(knot_zone_contents_t *zone, knot_ns_xfr_t *xfr) // add SOA RR to the response ret = knot_response2_add_rrset_answer(xfr->response, soa_rrset, 0, 0, 1); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { // something is really wrong - return DNSLIB_ERROR; + return KNOT_ERROR; } // add the SOA's RRSIG const knot_rrset_t *rrset = knot_rrset_rrsigs(soa_rrset); if (rrset != NULL && (ret = knot_response2_add_rrset_answer(xfr->response, rrset, - 0, 0, 1)) != DNSLIB_EOK) { + 0, 0, 1)) != KNOT_EOK) { // something is really wrong, these should definitely fit in - return DNSLIB_ERROR; + return KNOT_ERROR; } knot_zone_contents_tree_apply_inorder(zone, ns_axfr_from_node, ¶ms); - if (params.ret != DNSLIB_EOK) { - return DNSLIB_ERROR; // maybe do something with the code + if (params.ret != KNOT_EOK) { + return KNOT_ERROR; // maybe do something with the code } knot_zone_contents_nsec3_apply_inorder(zone, ns_axfr_from_node, ¶ms); - if (params.ret != DNSLIB_EOK) { - return DNSLIB_ERROR; // maybe do something with the code + if (params.ret != KNOT_EOK) { + return KNOT_ERROR; // maybe do something with the code } /* @@ -2032,24 +2032,24 @@ static int ns_axfr_from_zone(knot_zone_contents_t *zone, knot_ns_xfr_t *xfr) // try to add the SOA to the response again (last RR) ret = knot_response2_add_rrset_answer(xfr->response, soa_rrset, 0, 0, 1); - if (ret == DNSLIB_ESPACE) { + if (ret == KNOT_ESPACE) { // if there is not enough space, send the response and // add the SOA record to a new packet debug_knot_ns("Packet full, sending..\n"); ret = ns_axfr_send_and_clear(xfr); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } ret = knot_response2_add_rrset_answer(xfr->response, soa_rrset, 0, 0, 1); - if (ret != DNSLIB_EOK) { - return DNSLIB_ERROR; + if (ret != KNOT_EOK) { + return KNOT_ERROR; } - } else if (ret != DNSLIB_EOK) { + } else if (ret != KNOT_EOK) { // something is really wrong - return DNSLIB_ERROR; + return KNOT_ERROR; } debug_knot_ns("Sending packet...\n"); @@ -2062,8 +2062,8 @@ static int ns_ixfr_put_rrset(knot_ns_xfr_t *xfr, const knot_rrset_t *rrset) { int res = knot_response2_add_rrset_answer(xfr->response, rrset, 0, 0, 0); - if (res == DNSLIB_ESPACE) { - knot_response2_set_rcode(xfr->response, DNSLIB_RCODE_NOERROR); + if (res == KNOT_ESPACE) { + knot_response2_set_rcode(xfr->response, KNOT_RCODE_NOERROR); /*! \todo Probably rename the function. */ ns_axfr_send_and_clear(xfr); @@ -2071,19 +2071,19 @@ static int ns_ixfr_put_rrset(knot_ns_xfr_t *xfr, const knot_rrset_t *rrset) rrset, 0, 0, 0); } - if (res != DNSLIB_EOK) { + if (res != KNOT_EOK) { debug_knot_ns("Error putting origin SOA to IXFR reply: %s\n", knot_strerror2(res)); /*! \todo Probably send back AXFR instead. */ knot_response2_set_rcode(xfr->response, - DNSLIB_RCODE_SERVFAIL); + KNOT_RCODE_SERVFAIL); /*! \todo Probably rename the function. */ ns_axfr_send_and_clear(xfr); //socket_close(xfr->session); /*! \todo Remove for UDP.*/ - return DNSLIB_ERROR; + return KNOT_ERROR; } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -2092,33 +2092,33 @@ static int ns_ixfr_put_changeset(knot_ns_xfr_t *xfr, const knot_changeset_t *chg { // 1) put origin SOA int res = ns_ixfr_put_rrset(xfr, chgset->soa_from); - if (res != DNSLIB_EOK) { + if (res != KNOT_EOK) { return res; } // 2) put remove RRSets for (int i = 0; i < chgset->remove_count; ++i) { res = ns_ixfr_put_rrset(xfr, chgset->remove[i]); - if (res != DNSLIB_EOK) { + if (res != KNOT_EOK) { return res; } } // 1) put target SOA res = ns_ixfr_put_rrset(xfr, chgset->soa_to); - if (res != DNSLIB_EOK) { + if (res != KNOT_EOK) { return res; } // 2) put remove RRSets for (int i = 0; i < chgset->add_count; ++i) { res = ns_ixfr_put_rrset(xfr, chgset->add[i]); - if (res != DNSLIB_EOK) { + if (res != KNOT_EOK) { return res; } } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -2136,7 +2136,7 @@ static int ns_ixfr_from_zone(knot_ns_xfr_t *xfr) // const knot_rrset_t *zone_soa = // knot_node_rrset(knot_zone_contents_apex( // knot_zone_contents(xfr->zone)), -// DNSLIB_RRTYPE_SOA); +// KNOT_RRTYPE_SOA); // // retrieve origin (xfr) serial and target (zone) serial // uint32_t zone_serial = knot_rdata_soa_serial( // knot_rrset_rdata(zone_soa)); @@ -2148,11 +2148,11 @@ static int ns_ixfr_from_zone(knot_ns_xfr_t *xfr) // calloc(1, sizeof(knot_changesets_t)); // int res = xfr_load_changesets(xfr->zone, chgsets, xfr_serial, // zone_serial); -// if (res != DNSLIB_EOK) { +// if (res != KNOT_EOK) { // debug_knot_ns("IXFR query cannot be answered: %s.\n", // knot_strerror2(res)); // /*! \todo Probably send back AXFR instead. */ -// knot_response2_set_rcode(xfr->response, DNSLIB_RCODE_SERVFAIL); +// knot_response2_set_rcode(xfr->response, KNOT_RCODE_SERVFAIL); // /*! \todo Probably rename the function. */ // ns_axfr_send_and_clear(xfr); // //socket_close(xfr->session); /*! \todo Remove for UDP. */ @@ -2166,16 +2166,16 @@ static int ns_ixfr_from_zone(knot_ns_xfr_t *xfr) const knot_rrset_t *zone_soa = knot_node_rrset(knot_zone_contents_apex( knot_zone_contents(xfr->zone)), - DNSLIB_RRTYPE_SOA); + KNOT_RRTYPE_SOA); // 4) put the zone SOA as the first Answer RR int res = knot_response2_add_rrset_answer(xfr->response, zone_soa, 0, 0, 0); - if (res != DNSLIB_EOK) { + if (res != KNOT_EOK) { debug_knot_ns("IXFR query cannot be answered: %s.\n", knot_strerror2(res)); knot_response2_set_rcode(xfr->response, - DNSLIB_RCODE_SERVFAIL); + KNOT_RCODE_SERVFAIL); /*! \todo Probably rename the function. */ ns_axfr_send_and_clear(xfr); // socket_close(xfr->session); /*! \todo Remove for UDP.*/ @@ -2185,22 +2185,22 @@ static int ns_ixfr_from_zone(knot_ns_xfr_t *xfr) // 5) put the changesets into the response while they fit in for (int i = 0; i < chgsets->count; ++i) { res = ns_ixfr_put_changeset(xfr, &chgsets->sets[i]); - if (res != DNSLIB_EOK) { + if (res != KNOT_EOK) { // answer is sent, socket is closed - return DNSLIB_EOK; + return KNOT_EOK; } } res = ns_ixfr_put_rrset(xfr, zone_soa); - if (res == DNSLIB_EOK) { + if (res == KNOT_EOK) { /*! \todo Probably rename the function. */ ns_axfr_send_and_clear(xfr); //socket_close(xfr->session); /*! \todo Remove for UDP.*/ return 1; } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -2210,13 +2210,13 @@ static int ns_ixfr(knot_ns_xfr_t *xfr) assert(xfr != NULL); assert(xfr->query != NULL); assert(xfr->response != NULL); - assert(knot_packet_qtype(xfr->response) == DNSLIB_RRTYPE_IXFR); + assert(knot_packet_qtype(xfr->response) == KNOT_RRTYPE_IXFR); // check if there is the required authority record if ((knot_packet_authority_rrset_count(xfr->query) <= 0)) { // malformed packet debug_knot_ns("IXFR query does not contain authority record.\n"); - knot_response2_set_rcode(xfr->response, DNSLIB_RCODE_FORMERR); + knot_response2_set_rcode(xfr->response, KNOT_RCODE_FORMERR); /*! \todo Probably rename the function. */ ns_axfr_send_and_clear(xfr); //socket_close(xfr->session); @@ -2228,12 +2228,12 @@ static int ns_ixfr(knot_ns_xfr_t *xfr) const knot_dname_t *qname = knot_packet_qname(xfr->response); // check if XFR QNAME and SOA correspond - if (knot_packet_qtype(xfr->query) != DNSLIB_RRTYPE_SOA - || knot_rrset_type(soa) != DNSLIB_RRTYPE_SOA + if (knot_packet_qtype(xfr->query) != KNOT_RRTYPE_SOA + || knot_rrset_type(soa) != KNOT_RRTYPE_SOA || knot_dname_compare(qname, knot_rrset_owner(soa)) != 0) { // malformed packet debug_knot_ns("IXFR query is malformed.\n"); - knot_response2_set_rcode(xfr->response, DNSLIB_RCODE_FORMERR); + knot_response2_set_rcode(xfr->response, KNOT_RCODE_FORMERR); /*! \todo Probably rename the function. */ ns_axfr_send_and_clear(xfr); //socket_close(xfr->session); /*! \todo Remove for UDP. */ @@ -2266,7 +2266,7 @@ knot_nameserver_t *knot_ns_create() } // prepare empty response with SERVFAIL error - knot_packet_t *err = knot_packet_new(DNSLIB_PACKET_PREALLOC_NONE); + knot_packet_t *err = knot_packet_new(KNOT_PACKET_PREALLOC_NONE); if (err == NULL) { ERR_ALLOC_FAILED; free(ns); @@ -2275,8 +2275,8 @@ knot_nameserver_t *knot_ns_create() debug_knot_ns("Created default empty response...\n"); - int rc = knot_packet_set_max_size(err, DNSLIB_WIRE_HEADER_SIZE); - if (rc != DNSLIB_EOK) { + int rc = knot_packet_set_max_size(err, KNOT_WIRE_HEADER_SIZE); + if (rc != KNOT_EOK) { debug_knot_ns("Error creating default error response: %s.\n", knot_strerror2(rc)); free(ns); @@ -2285,7 +2285,7 @@ knot_nameserver_t *knot_ns_create() } rc = knot_response2_init(err); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { debug_knot_ns("Error initializing default error response:" " %s.\n", knot_strerror2(rc)); free(ns); @@ -2293,7 +2293,7 @@ knot_nameserver_t *knot_ns_create() return NULL; } - knot_response2_set_rcode(err, DNSLIB_RCODE_SERVFAIL); + knot_response2_set_rcode(err, KNOT_RCODE_SERVFAIL); ns->err_resp_size = 0; debug_knot_ns("Converting default empty response to wire format...\n"); @@ -2351,14 +2351,14 @@ int knot_ns_parse_packet(const uint8_t *query_wire, size_t qsize, { if (packet == NULL || query_wire == NULL || type == NULL) { debug_knot_ns("Missing parameter to query parsing.\n"); - return DNSLIB_EBADARG; + return KNOT_EBADARG; } debug_knot_ns("ns_parse_packet() called with query size %zu.\n", qsize); debug_knot_ns_hex((char *)query_wire, qsize); if (qsize < 2) { - return DNSLIB_EMALF; + return KNOT_EMALF; } // 1) create empty response @@ -2372,42 +2372,42 @@ int knot_ns_parse_packet(const uint8_t *query_wire, size_t qsize, debug_knot_ns("Error while parsing packet, " "dnslib error '%s'.\n", knot_strerror2(ret)); // knot_response_free(&parsed); - return DNSLIB_RCODE_FORMERR; + return KNOT_RCODE_FORMERR; } // 3) determine the query type switch (knot_packet_opcode(packet)) { - case DNSLIB_OPCODE_QUERY: + case KNOT_OPCODE_QUERY: switch (knot_packet_qtype(packet)) { - case DNSLIB_RRTYPE_AXFR: + case KNOT_RRTYPE_AXFR: *type = (knot_packet_is_query(packet)) - ? DNSLIB_QUERY_AXFR : DNSLIB_RESPONSE_AXFR; + ? KNOT_QUERY_AXFR : KNOT_RESPONSE_AXFR; break; - case DNSLIB_RRTYPE_IXFR: + case KNOT_RRTYPE_IXFR: *type = (knot_packet_is_query(packet)) - ? DNSLIB_QUERY_IXFR : DNSLIB_RESPONSE_IXFR; + ? KNOT_QUERY_IXFR : KNOT_RESPONSE_IXFR; break; default: *type = (knot_packet_is_query(packet)) - ? DNSLIB_QUERY_NORMAL : DNSLIB_RESPONSE_NORMAL; + ? KNOT_QUERY_NORMAL : KNOT_RESPONSE_NORMAL; } break; - case DNSLIB_OPCODE_NOTIFY: + case KNOT_OPCODE_NOTIFY: *type = (knot_packet_is_query(packet)) - ? DNSLIB_QUERY_NOTIFY : DNSLIB_RESPONSE_NOTIFY; + ? KNOT_QUERY_NOTIFY : KNOT_RESPONSE_NOTIFY; break; - case DNSLIB_OPCODE_UPDATE: + case KNOT_OPCODE_UPDATE: assert(knot_packet_is_query(packet)); - *type = DNSLIB_QUERY_UPDATE; + *type = KNOT_QUERY_UPDATE; break; default: - return DNSLIB_RCODE_NOTIMPL; + return KNOT_RCODE_NOTIMPL; } // knot_packet_free(&packet); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -2441,12 +2441,12 @@ int knot_ns_answer_normal(knot_nameserver_t *nameserver, knot_packet_t *query, if (query->parsed < query->size) { ret = knot_packet_parse_rest(query); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_ns("Failed to parse rest of the query: " "%s.\n", knot_strerror2(ret)); knot_ns_error_response(nameserver, query->header.id, - DNSLIB_RCODE_SERVFAIL, response_wire, rsize); - return DNSLIB_EOK; + KNOT_RCODE_SERVFAIL, response_wire, rsize); + return KNOT_EOK; } } @@ -2463,35 +2463,35 @@ int knot_ns_answer_normal(knot_nameserver_t *nameserver, knot_packet_t *query, // initialize response packet structure knot_packet_t *response = knot_packet_new( - DNSLIB_PACKET_PREALLOC_RESPONSE); + KNOT_PACKET_PREALLOC_RESPONSE); if (response == NULL) { debug_knot_ns("Failed to create packet structure.\n"); knot_ns_error_response(nameserver, query->header.id, - DNSLIB_RCODE_SERVFAIL, response_wire, rsize); + KNOT_RCODE_SERVFAIL, response_wire, rsize); rcu_read_unlock(); - return DNSLIB_EOK; + return KNOT_EOK; } ret = knot_packet_set_max_size(response, *rsize); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_ns("Failed to init response structure.\n"); knot_ns_error_response(nameserver, query->header.id, - DNSLIB_RCODE_SERVFAIL, response_wire, rsize); + KNOT_RCODE_SERVFAIL, response_wire, rsize); rcu_read_unlock(); knot_packet_free(&response); - return DNSLIB_EOK; + return KNOT_EOK; } ret = knot_response2_init_from_query(response, query); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_ns("Failed to init response structure.\n"); knot_ns_error_response(nameserver, query->header.id, - DNSLIB_RCODE_SERVFAIL, response_wire, rsize); + KNOT_RCODE_SERVFAIL, response_wire, rsize); rcu_read_unlock(); knot_packet_free(&response); - return DNSLIB_EOK; + return KNOT_EOK; } debug_knot_ns("EDNS supported in query: %d\n", @@ -2500,7 +2500,7 @@ int knot_ns_answer_normal(knot_nameserver_t *nameserver, knot_packet_t *query, // set the OPT RR to the response if (knot_query_edns_supported(query)) { ret = knot_response2_add_opt(response, nameserver->opt_rr, 0); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_ns("Failed to set OPT RR to the response" ": %s\n",knot_strerror2(ret)); } @@ -2510,7 +2510,7 @@ int knot_ns_answer_normal(knot_nameserver_t *nameserver, knot_packet_t *query, if (ret != 0) { // now only one type of error (SERVFAIL), later maybe more knot_ns_error_response(nameserver, query->header.id, - DNSLIB_RCODE_SERVFAIL, response_wire, rsize); + KNOT_RCODE_SERVFAIL, response_wire, rsize); } else { debug_knot_ns("Created response packet.\n"); //knot_response_dump(resp); @@ -2520,7 +2520,7 @@ int knot_ns_answer_normal(knot_nameserver_t *nameserver, knot_packet_t *query, if (ns_response_to_wire(response, response_wire, rsize) != 0) { // send back SERVFAIL (as this is our problem) knot_ns_error_response(nameserver, query->header.id, - DNSLIB_RCODE_SERVFAIL, response_wire, + KNOT_RCODE_SERVFAIL, response_wire, rsize); } } @@ -2531,7 +2531,7 @@ int knot_ns_answer_normal(knot_nameserver_t *nameserver, knot_packet_t *query, debug_knot_ns("Returning response with wire size %zu\n", *rsize); debug_knot_ns_hex((char *)response_wire, *rsize); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -2541,7 +2541,7 @@ int knot_ns_init_xfr(knot_nameserver_t *nameserver, knot_ns_xfr_t *xfr) debug_knot_ns("knot_ns_init_xfr()\n"); if (nameserver == NULL || xfr == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } // no need to parse rest of the packet @@ -2549,12 +2549,12 @@ int knot_ns_init_xfr(knot_nameserver_t *nameserver, knot_ns_xfr_t *xfr) // initialize response packet structure knot_packet_t *response = knot_packet_new( - DNSLIB_PACKET_PREALLOC_RESPONSE); + KNOT_PACKET_PREALLOC_RESPONSE); if (response == NULL) { debug_knot_ns("Failed to create packet structure.\n"); /*! \todo xfr->wire is not NULL, will fail on assert! */ knot_ns_error_response(nameserver, xfr->query->header.id, - DNSLIB_RCODE_SERVFAIL, xfr->wire, + KNOT_RCODE_SERVFAIL, xfr->wire, &xfr->wire_size); int res = xfr->send(xfr->session, &xfr->addr, xfr->wire, xfr->wire_size); @@ -2564,11 +2564,11 @@ int knot_ns_init_xfr(knot_nameserver_t *nameserver, knot_ns_xfr_t *xfr) int ret = knot_packet_set_max_size(response, xfr->wire_size); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_ns("Failed to init response structure.\n"); /*! \todo xfr->wire is not NULL, will fail on assert! */ knot_ns_error_response(nameserver, xfr->query->header.id, - DNSLIB_RCODE_SERVFAIL, xfr->wire, + KNOT_RCODE_SERVFAIL, xfr->wire, &xfr->wire_size); int res = xfr->send(xfr->session, &xfr->addr, xfr->wire, xfr->wire_size); @@ -2578,11 +2578,11 @@ int knot_ns_init_xfr(knot_nameserver_t *nameserver, knot_ns_xfr_t *xfr) ret = knot_response2_init_from_query(response, xfr->query); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_ns("Failed to init response structure.\n"); /*! \todo xfr->wire is not NULL, will fail on assert! */ knot_ns_error_response(nameserver, xfr->query->header.id, - DNSLIB_RCODE_SERVFAIL, xfr->wire, + KNOT_RCODE_SERVFAIL, xfr->wire, &xfr->wire_size); int res = xfr->send(xfr->session, &xfr->addr, xfr->wire, xfr->wire_size); @@ -2596,9 +2596,9 @@ int knot_ns_init_xfr(knot_nameserver_t *nameserver, knot_ns_xfr_t *xfr) const knot_dname_t *qname = knot_packet_qname(xfr->response); - assert(knot_packet_qtype(xfr->response) == DNSLIB_RRTYPE_AXFR); + assert(knot_packet_qtype(xfr->response) == KNOT_RRTYPE_AXFR); -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name_str = knot_dname_to_str(qname); debug_knot_ns("Trying to find zone with name %s\n", name_str); free(name_str); @@ -2609,19 +2609,19 @@ DEBUG_DNSLIB_NS( // if no zone found, return NotAuth if (zone == NULL) { debug_knot_ns("No zone found.\n"); - knot_response2_set_rcode(xfr->response, DNSLIB_RCODE_NOTAUTH); + knot_response2_set_rcode(xfr->response, KNOT_RCODE_NOTAUTH); ns_axfr_send_and_clear(xfr); - return DNSLIB_ERROR; + return KNOT_ERROR; } -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( char *name_str2 = knot_dname_to_str(zone->contents->apex->owner); debug_knot_ns("Found zone for QNAME %s\n", name_str2); free(name_str2); ); xfr->zone = zone; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -2638,7 +2638,7 @@ int knot_ns_xfr_send_error(knot_ns_xfr_t *xfr, knot_rcode_t rcode) int knot_ns_answer_axfr(knot_nameserver_t *nameserver, knot_ns_xfr_t *xfr) { if (xfr == NULL || nameserver == NULL || xfr->zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } rcu_read_lock(); @@ -2657,12 +2657,12 @@ int knot_ns_answer_axfr(knot_nameserver_t *nameserver, knot_ns_xfr_t *xfr) // now only one type of error (SERVFAIL), later maybe more /*! \todo xfr->wire is not NULL, will fail on assert! */ knot_ns_error_response(nameserver, xfr->query->header.id, - DNSLIB_RCODE_SERVFAIL, xfr->wire, + KNOT_RCODE_SERVFAIL, xfr->wire, &xfr->wire_size); ret = xfr->send(xfr->session, &xfr->addr, xfr->wire, xfr->wire_size); } else if (ret > 0) { - ret = DNSLIB_ERROR; + ret = KNOT_ERROR; } rcu_read_unlock(); @@ -2678,23 +2678,23 @@ int knot_ns_answer_ixfr(knot_nameserver_t *nameserver, knot_ns_xfr_t *xfr) { if (nameserver == NULL || xfr == NULL || xfr->zone == NULL || xfr->response == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } // parse rest of the packet (we need the Authority record) int ret = knot_packet_parse_rest(xfr->query); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_ns("Failed to parse rest of the packet.\n"); /*! \todo Extract this to some function. */ - knot_response2_set_rcode(xfr->response, DNSLIB_RCODE_FORMERR); + knot_response2_set_rcode(xfr->response, KNOT_RCODE_FORMERR); uint8_t *wire = NULL; size_t size = 0; ret = knot_packet_to_wire(xfr->response, &wire, &size); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { knot_ns_error_response(nameserver, xfr->query->header.id, - DNSLIB_RCODE_FORMERR, wire, + KNOT_RCODE_FORMERR, wire, &size); } @@ -2715,20 +2715,20 @@ int knot_ns_answer_ixfr(knot_nameserver_t *nameserver, knot_ns_xfr_t *xfr) // now only one type of error (SERVFAIL), later maybe more /*! \todo Extract this to some function. */ - knot_response2_set_rcode(xfr->response, DNSLIB_RCODE_SERVFAIL); + knot_response2_set_rcode(xfr->response, KNOT_RCODE_SERVFAIL); uint8_t *wire = NULL; size_t size = 0; ret = knot_packet_to_wire(xfr->response, &wire, &size); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { knot_ns_error_response(nameserver, xfr->query->header.id, - DNSLIB_RCODE_SERVFAIL, wire, + KNOT_RCODE_SERVFAIL, wire, &size); } ret = xfr->send(xfr->session, &xfr->addr, wire, size); } else if (ret > 0) { - ret = DNSLIB_ERROR; + ret = KNOT_ERROR; } knot_packet_free(&xfr->response); @@ -2766,8 +2766,8 @@ int knot_ns_process_axfrin(knot_nameserver_t *nameserver, knot_ns_xfr_t *xfr) /* Create and fill hash table */ debug_knot_ns("ns_process_axfrin: filling hash table.\n"); int rc = knot_zone_contents_create_and_fill_hash_table(zone); - if (rc != DNSLIB_EOK) { - return DNSLIB_ERROR; // TODO: change error code + if (rc != KNOT_EOK) { + return KNOT_ERROR; // TODO: change error code } knot_zone_contents_dump(zone, 0); @@ -2782,7 +2782,7 @@ int knot_ns_switch_zone(knot_nameserver_t *nameserver, knot_ns_xfr_t *xfr) { if (xfr == NULL || nameserver == NULL || xfr->data == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } knot_zone_contents_t *zone = (knot_zone_contents_t *)xfr->data; @@ -2819,7 +2819,7 @@ int knot_ns_switch_zone(knot_nameserver_t *nameserver, debug_knot_ns("Freeing old zone: %p\n", old); knot_zone_contents_deep_free(&old); -DEBUG_DNSLIB_NS( +DEBUG_KNOT_NS( debug_knot_ns("Zone db contents:\n"); knot_zone_t **zones = knot_zonedb_zones(nameserver->zone_db); @@ -2832,7 +2832,7 @@ DEBUG_DNSLIB_NS( } ); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -2840,7 +2840,7 @@ DEBUG_DNSLIB_NS( int knot_ns_apply_ixfr_changes(knot_zone_t *zone, knot_changesets_t *chgsets) { /*! \todo Apply changes to the zone when they are parsed. */ - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -2868,7 +2868,7 @@ int knot_ns_process_ixfrin(knot_nameserver_t *nameserver, knot_changesets_t *chgsets = (knot_changesets_t *)xfr->data; if (chgsets == NULL || chgsets->count == 0) { // nothing to be done?? - return DNSLIB_EOK; + return KNOT_EOK; } // find zone associated with the changesets @@ -2879,11 +2879,11 @@ int knot_ns_process_ixfrin(knot_nameserver_t *nameserver, debug_knot_ns("No zone found for incoming IXFR!\n"); knot_free_changesets( (knot_changesets_t **)(&xfr->data)); - return DNSLIB_ENOZONE; /*! \todo Other error code? */ + return KNOT_ENOZONE; /*! \todo Other error code? */ } // ret = xfrin_store_changesets(zone, chgsets); -// if (ret != DNSLIB_EOK) { +// if (ret != KNOT_EOK) { // debug_knot_ns("Failed to save changesets to journal.\n"); // xfrin_free_changesets( // (knot_changesets_t **)(&xfr->data)); @@ -2891,7 +2891,7 @@ int knot_ns_process_ixfrin(knot_nameserver_t *nameserver, // } // ret = knot_ns_apply_ixfr_changes(zone, chgsets); -// if (ret != DNSLIB_EOK) { +// if (ret != KNOT_EOK) { // debug_knot_ns("Failed to apply changes to the zone."); // // left the changes to be applied later..? // // they are already stored diff --git a/src/dnslib/name-server.h b/src/dnslib/name-server.h index 1121976a0b8ee8d704d8b1fde782227b9c301dac..971c88ee972cec5e59455708b22a672508d9e2fb 100644 --- a/src/dnslib/name-server.h +++ b/src/dnslib/name-server.h @@ -17,8 +17,8 @@ * @{ */ -#ifndef _KNOT_NAME_SERVER_H_ -#define _KNOT_NAME_SERVER_H_ +#ifndef _KNOTDNAME_SERVER_H_ +#define _KNOTDNAME_SERVER_H_ #include <stdint.h> #include <string.h> @@ -94,17 +94,17 @@ knot_nameserver_t *knot_ns_create(); * \param packet Packet structure to be filled with the parsed query. * \param type Type of the query. * - * \retval KNOT_EOK - * \retval KNOT_EMALF if the query is totally unusable. Such query must be + * \retval KNOTDEOK + * \retval KNOTDEMALF if the query is totally unusable. Such query must be * ignored. - * \retval DNSLIB_RCODE_SERVFAIL if there was some internal error. Call + * \retval KNOT_RCODE_SERVFAIL if there was some internal error. Call * ns_error_response() with \a rcode set to this * value to get proper error response. - * \retval DNSLIB_RCODE_FORMERR if the query was malformed, but can be used to + * \retval KNOT_RCODE_FORMERR if the query was malformed, but can be used to * construct an error response. Call * ns_error_response() with \a rcode set to this * value to get proper error response. - * \retval DNSLIB_RCODE_NOTIMPL if the query has an unsupported type. Call + * \retval KNOT_RCODE_NOTIMPL if the query has an unsupported type. Call * ns_error_response() with \a rcode set to this * value to get proper error response. */ @@ -137,8 +137,8 @@ void knot_ns_error_response(knot_nameserver_t *nameserver, uint16_t query_id, * \param rsize Input: maximum acceptable size of the response. Output: real * size of the response. * - * \retval KNOT_EOK if a valid response was created. - * \retval KNOT_EMALF if an error occured and the response is not valid. + * \retval KNOTDEOK if a valid response was created. + * \retval KNOTDEMALF if an error occured and the response is not valid. */ int knot_ns_answer_normal(knot_nameserver_t *nameserver, knot_packet_t *query, uint8_t *response_wire, size_t *rsize); @@ -160,10 +160,10 @@ int knot_ns_xfr_send_error(knot_ns_xfr_t *xfr, knot_rcode_t rcode); * \note Currently only a stub which sends one error response using the given * callback. * - * \retval KNOT_EOK - * \retval KNOT_EINVAL - * \retval KNOT_ENOMEM - * \retval KNOT_ERROR + * \retval KNOTDEOK + * \retval KNOTDEINVAL + * \retval KNOTDENOMEM + * \retval KNOTDERROR * * \todo Maybe the place for the wire format should be passed in as in * the ns_answer_request() function...? @@ -213,6 +213,6 @@ int knot_ns_process_ixfrin(knot_nameserver_t *nameserver, void knot_ns_destroy(knot_nameserver_t **nameserver); -#endif /* _KNOT_NAME_SERVER_H_ */ +#endif /* _KNOTDNAME_SERVER_H_ */ /*! @} */ diff --git a/src/dnslib/node.c b/src/dnslib/node.c index 67f0ddadad223dd31ec507a289820e2cd9b0acad..02af667c4c374520ca169b3c44a56006fb5315fa 100644 --- a/src/dnslib/node.c +++ b/src/dnslib/node.c @@ -26,7 +26,7 @@ */ static inline uint8_t knot_node_flags_get_deleg(uint8_t flags) { - return flags & DNSLIB_NODE_FLAGS_DELEG; + return flags & KNOT_NODE_FLAGS_DELEG; } /*----------------------------------------------------------------------------*/ @@ -37,7 +37,7 @@ static inline uint8_t knot_node_flags_get_deleg(uint8_t flags) */ static inline void knot_node_flags_set_deleg(uint8_t *flags) { - *flags |= DNSLIB_NODE_FLAGS_DELEG; + *flags |= KNOT_NODE_FLAGS_DELEG; } /*----------------------------------------------------------------------------*/ @@ -51,7 +51,7 @@ static inline void knot_node_flags_set_deleg(uint8_t *flags) */ static inline uint8_t knot_node_flags_get_nonauth(uint8_t flags) { - return flags & DNSLIB_NODE_FLAGS_NONAUTH; + return flags & KNOT_NODE_FLAGS_NONAUTH; } /*----------------------------------------------------------------------------*/ @@ -62,7 +62,7 @@ static inline uint8_t knot_node_flags_get_nonauth(uint8_t flags) */ static inline void knot_node_flags_set_nonauth(uint8_t *flags) { - *flags |= DNSLIB_NODE_FLAGS_NONAUTH; + *flags |= KNOT_NODE_FLAGS_NONAUTH; } /*----------------------------------------------------------------------------*/ @@ -75,7 +75,7 @@ static inline void knot_node_flags_set_nonauth(uint8_t *flags) */ static inline uint8_t knot_node_flags_get_old(uint8_t flags) { - return flags & DNSLIB_NODE_FLAGS_OLD; + return flags & KNOT_NODE_FLAGS_OLD; } /*----------------------------------------------------------------------------*/ @@ -86,7 +86,7 @@ static inline uint8_t knot_node_flags_get_old(uint8_t flags) */ static inline void knot_node_flags_set_new(uint8_t *flags) { - *flags |= DNSLIB_NODE_FLAGS_NEW; + *flags |= KNOT_NODE_FLAGS_NEW; } /*----------------------------------------------------------------------------*/ @@ -99,7 +99,7 @@ static inline void knot_node_flags_set_new(uint8_t *flags) */ static inline uint8_t knot_node_flags_get_new(uint8_t flags) { - return flags & DNSLIB_NODE_FLAGS_NEW; + return flags & KNOT_NODE_FLAGS_NEW; } /*----------------------------------------------------------------------------*/ @@ -110,21 +110,21 @@ static inline uint8_t knot_node_flags_get_new(uint8_t flags) */ static inline void knot_node_flags_set_old(uint8_t *flags) { - *flags |= DNSLIB_NODE_FLAGS_OLD; + *flags |= KNOT_NODE_FLAGS_OLD; } /*----------------------------------------------------------------------------*/ static inline void knot_node_flags_clear_new(uint8_t *flags) { - *flags &= ~DNSLIB_NODE_FLAGS_NEW; + *flags &= ~KNOT_NODE_FLAGS_NEW; } /*----------------------------------------------------------------------------*/ static inline void knot_node_flags_clear_old(uint8_t *flags) { - *flags &= ~DNSLIB_NODE_FLAGS_OLD; + *flags &= ~KNOT_NODE_FLAGS_OLD; } /*----------------------------------------------------------------------------*/ @@ -199,12 +199,12 @@ int knot_node_add_rrset(knot_node_t *node, knot_rrset_t *rrset, // knot_rrtype_to_string(rrset->type)); if ((ret = (gen_tree_add(node->rrset_tree, rrset, (merge) ? knot_rrset_merge : NULL))) != 0) { - return DNSLIB_ERROR; + return KNOT_ERROR; } if (ret == 0) { node->rrset_count += unique_rrset_type; - return DNSLIB_EOK; + return KNOT_EOK; } else { return 1; } @@ -821,7 +821,7 @@ int knot_node_shallow_copy(const knot_node_t *from, knot_node_t **to) // create new node *to = knot_node_new(from->owner, from->parent, from->flags); if (*to == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } // copy references @@ -835,8 +835,8 @@ int knot_node_shallow_copy(const knot_node_t *from, knot_node_t **to) // if ((*to)->rrsets == NULL) { // free(*to); // *to = NULL; -// return DNSLIB_ENOMEM; +// return KNOT_ENOMEM; // } - return DNSLIB_EOK; + return KNOT_EOK; } diff --git a/src/dnslib/node.h b/src/dnslib/node.h index 1c4b310a480f003d3fcd325847c44179f559cf4d..7d089f5d7592b0988e0f4c64736d304701709aab 100644 --- a/src/dnslib/node.h +++ b/src/dnslib/node.h @@ -10,8 +10,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_NODE_H_ -#define _KNOT_DNSLIB_NODE_H_ +#ifndef _KNOTDKNOT_NODE_H_ +#define _KNOTDKNOT_NODE_H_ #include "dnslib/dname.h" #include "common/skip-list.h" @@ -94,13 +94,13 @@ typedef struct knot_node knot_node_t; /*! \brief Flags used to mark nodes with some property. */ typedef enum { /*! \brief Node is a delegation point (i.e. marking a zone cut). */ - DNSLIB_NODE_FLAGS_DELEG = (uint8_t)0x01, + KNOT_NODE_FLAGS_DELEG = (uint8_t)0x01, /*! \brief Node is not authoritative (i.e. below a zone cut). */ - DNSLIB_NODE_FLAGS_NONAUTH = (uint8_t)0x02, + KNOT_NODE_FLAGS_NONAUTH = (uint8_t)0x02, /*! \brief Node is old and will be removed (during update). */ - DNSLIB_NODE_FLAGS_OLD = (uint8_t)0x80, + KNOT_NODE_FLAGS_OLD = (uint8_t)0x80, /*! \brief Node is new and should not be used while zoen is old. */ - DNSLIB_NODE_FLAGS_NEW = (uint8_t)0x40 + KNOT_NODE_FLAGS_NEW = (uint8_t)0x40 } knot_node_flags_t; /*----------------------------------------------------------------------------*/ @@ -126,8 +126,8 @@ knot_node_t *knot_node_new(knot_dname_t *owner, knot_node_t *parent, * \param node Node to add the RRSet to. * \param rrset RRSet to add. * - * \retval DNSLIB_EOK on success. - * \retval DNSLIB_ERROR if the RRSet could not be inserted. + * \retval KNOT_EOK on success. + * \retval KNOT_ERROR if the RRSet could not be inserted. */ int knot_node_add_rrset(knot_node_t *node, knot_rrset_t *rrset, int merge); @@ -414,6 +414,6 @@ int knot_node_compare(knot_node_t *node1, knot_node_t *node2); int knot_node_shallow_copy(const knot_node_t *from, knot_node_t **to); -#endif /* _KNOT_DNSLIB_NODE_H_ */ +#endif /* _KNOTDKNOT_NODE_H_ */ /*! @} */ diff --git a/src/dnslib/nsec3.c b/src/dnslib/nsec3.c index 4a1dfa0a41737fc217cd109f47e358cbe00d364e..eb6c0ae09b4dabc66543df58a83ae5d5cfa24574 100644 --- a/src/dnslib/nsec3.c +++ b/src/dnslib/nsec3.c @@ -19,7 +19,7 @@ int knot_nsec3_params_from_wire(knot_nsec3_params_t *params, const knot_rrset_t *nsec3param) { - assert(knot_rrset_type(nsec3param) == DNSLIB_RRTYPE_NSEC3PARAM); + assert(knot_rrset_type(nsec3param) == KNOT_RRTYPE_NSEC3PARAM); const knot_rdata_t *rdata = knot_rrset_rdata(nsec3param); assert(rdata->count == 4); @@ -58,7 +58,7 @@ int knot_nsec3_params_from_wire(knot_nsec3_params_t *params, debug_knot_nsec3("none\n"); } - return DNSLIB_EOK; + return KNOT_EOK; } static uint8_t *knot_nsec3_to_lowercase(const uint8_t *data, size_t size) @@ -74,13 +74,13 @@ static uint8_t *knot_nsec3_to_lowercase(const uint8_t *data, size_t size) } /*----------------------------------------------------------------------------*/ -#if DNSLIB_NSEC3_SHA_USE_EVP +#if KNOT_NSEC3_SHA_USE_EVP int knot_nsec3_sha1(const knot_nsec3_params_t *params, const uint8_t *data, size_t size, uint8_t **digest, size_t *digest_size) { if (digest == NULL || digest_size == NULL || data == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } uint8_t *salt = params->salt; @@ -107,14 +107,14 @@ int knot_nsec3_sha1(const knot_nsec3_params_t *params, int res = 0; -#ifdef DNSLIB_NSEC3_DEBUG +#ifdef KNOT_NSEC3_DEBUG unsigned long long total_time = 0; unsigned long calls = 0; long time = 0; #endif for (int i = 0; i <= iterations; ++i) { -#ifdef DNSLIB_NSEC3_DEBUG +#ifdef KNOT_NSEC3_DEBUG perf_begin(); #endif @@ -130,7 +130,7 @@ int knot_nsec3_sha1(const knot_nsec3_params_t *params, in = *digest; in_size = *digest_size; -#ifdef DNSLIB_NSEC3_DEBUG +#ifdef KNOT_NSEC3_DEBUG perf_end(time); total_time += time; ++calls; @@ -161,7 +161,7 @@ int knot_nsec3_sha1(const knot_nsec3_params_t *params, size_t *digest_size) { if (digest == NULL || digest_size == NULL || data == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } uint8_t *salt = params->salt; @@ -186,13 +186,13 @@ int knot_nsec3_sha1(const knot_nsec3_params_t *params, *digest = (uint8_t *)malloc(SHA_DIGEST_LENGTH); if (*digest == NULL) { ERR_ALLOC_FAILED; - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } uint8_t *data_low = knot_nsec3_to_lowercase(data, size); if (data_low == NULL) { free(*digest); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } const uint8_t *in = data_low; @@ -200,7 +200,7 @@ int knot_nsec3_sha1(const knot_nsec3_params_t *params, int res = 0; -#ifdef DNSLIB_NSEC3_DEBUG +#ifdef KNOT_NSEC3_DEBUG long time = 0; unsigned long long total_time = 0; unsigned long calls = 0; @@ -208,7 +208,7 @@ int knot_nsec3_sha1(const knot_nsec3_params_t *params, // other iterations for (int i = 0; i <= iterations; ++i) { -#ifdef DNSLIB_NSEC3_DEBUG +#ifdef KNOT_NSEC3_DEBUG perf_begin(); #endif @@ -225,7 +225,7 @@ int knot_nsec3_sha1(const knot_nsec3_params_t *params, in = *digest; in_size = SHA_DIGEST_LENGTH; -#ifdef DNSLIB_NSEC3_DEBUG +#ifdef KNOT_NSEC3_DEBUG perf_end(time); total_time += time; ++calls; @@ -235,7 +235,7 @@ int knot_nsec3_sha1(const knot_nsec3_params_t *params, debug_knot_nsec3("Error calculating SHA-1 hash.\n"); free(data_low); free(*digest); - return DNSLIB_ECRYPTO; + return KNOT_ECRYPTO; } } @@ -249,7 +249,7 @@ int knot_nsec3_sha1(const knot_nsec3_params_t *params, debug_knot_nsec3("\n"); free(data_low); - return DNSLIB_EOK; + return KNOT_EOK; } #endif diff --git a/src/dnslib/nsec3.h b/src/dnslib/nsec3.h index d2dd39bde585058eff124455c90c71401b5d32ad..a01eeafa1ce8f30a6ced2307f7230f549d457c42 100644 --- a/src/dnslib/nsec3.h +++ b/src/dnslib/nsec3.h @@ -9,15 +9,15 @@ * @{ */ -#ifndef _KNOT_DNSLIB_NSEC3_H_ -#define _KNOT_DNSLIB_NSEC3_H_ +#ifndef _KNOTDKNOT_NSEC3_H_ +#define _KNOTDKNOT_NSEC3_H_ #include <stdint.h> #include <string.h> #include "dnslib/rrset.h" -#define DNSLIB_NSEC3_SHA_USE_EVP 0 +#define KNOT_NSEC3_SHA_USE_EVP 0 /*----------------------------------------------------------------------------*/ /*! @@ -40,7 +40,7 @@ typedef struct knot_nsec3_params knot_nsec3_params_t; * \param params NSEC3PARAM structure to initialize. * \param nsec3param The NSEC3PARAM RRset. * - * \retval DNSLIB_EOK on success (always). + * \retval KNOT_EOK on success (always). */ int knot_nsec3_params_from_wire(knot_nsec3_params_t *params, const knot_rrset_t *nsec3param); @@ -55,10 +55,10 @@ int knot_nsec3_params_from_wire(knot_nsec3_params_t *params, * \param[out] digest Result will be store here. * \param[out] digest_size Size of the result in octets will be stored here. * - * \retval DNSLIB_EOK if successful. - * \retval DNSLIB_ENOMEM - * \retval DNSLIB_EBADARG - * \retval DNSLIB_ECRYPTO + * \retval KNOT_EOK if successful. + * \retval KNOT_ENOMEM + * \retval KNOT_EBADARG + * \retval KNOT_ECRYPTO */ int knot_nsec3_sha1(const knot_nsec3_params_t *params, const uint8_t *data, size_t size, uint8_t **digest, size_t *digest_size); @@ -72,6 +72,6 @@ void knot_nsec3_params_free(knot_nsec3_params_t *params); /*----------------------------------------------------------------------------*/ -#endif /* _KNOT_DNSLIB_NSEC3_H_ */ +#endif /* _KNOTDKNOT_NSEC3_H_ */ /*! @} */ diff --git a/src/dnslib/packet.c b/src/dnslib/packet.c index ea88eccccecbd7bf1d6437e8fb580f4f6ff9527b..8c28507bf46b648f897812011498128125c9b09a 100644 --- a/src/dnslib/packet.c +++ b/src/dnslib/packet.c @@ -13,18 +13,18 @@ #define DEFAULT_RRCOUNT(type) DEFAULT_##type##COUNT #define DEFAULT_RRSET_COUNT(type, packet) \ - ((packet->prealloc_type == DNSLIB_PACKET_PREALLOC_NONE) \ + ((packet->prealloc_type == KNOT_PACKET_PREALLOC_NONE) \ ? 0 \ - : (packet->prealloc_type == DNSLIB_PACKET_PREALLOC_QUERY) \ + : (packet->prealloc_type == KNOT_PACKET_PREALLOC_QUERY) \ ? DEFAULT_##type##_QUERY \ : DEFAULT_##type) typedef enum { - DNSLIB_PACKET_DUPL_IGNORE, - DNSLIB_PACKET_DUPL_SKIP, - DNSLIB_PACKET_DUPL_MERGE + KNOT_PACKET_DUPL_IGNORE, + KNOT_PACKET_DUPL_SKIP, + KNOT_PACKET_DUPL_MERGE } knot_packet_duplicate_handling_t; /*----------------------------------------------------------------------------*/ /* Non-API functions */ @@ -189,8 +189,8 @@ static void knot_packet_init_pointers_query(knot_packet_t *pkt) * \param[in,out] remaining Remaining size of the wire format. * \param[out] header Header structure to fill in. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EFEWDATA + * \retval KNOT_EOK + * \retval KNOT_EFEWDATA */ static int knot_packet_parse_header(const uint8_t *wire, size_t *pos, size_t size, knot_header_t *header) @@ -199,9 +199,9 @@ static int knot_packet_parse_header(const uint8_t *wire, size_t *pos, assert(pos != NULL); assert(header != NULL); - if (size - *pos < DNSLIB_WIRE_HEADER_SIZE) { + if (size - *pos < KNOT_WIRE_HEADER_SIZE) { debug_knot_response("Not enough data to parse header.\n"); - return DNSLIB_EFEWDATA; + return KNOT_EFEWDATA; } header->id = knot_wire_get_id(wire); @@ -217,9 +217,9 @@ static int knot_packet_parse_header(const uint8_t *wire, size_t *pos, header->nscount = knot_wire_get_nscount(wire); header->arcount = knot_wire_get_arcount(wire); - *pos += DNSLIB_WIRE_HEADER_SIZE; + *pos += KNOT_WIRE_HEADER_SIZE; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -233,9 +233,9 @@ static int knot_packet_parse_header(const uint8_t *wire, size_t *pos, * \param[in,out] remaining Remaining size of the wire format. * \param[out] question DNS Question structure to be filled. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EFEWDATA - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_EFEWDATA + * \retval KNOT_ENOMEM */ static int knot_packet_parse_question(const uint8_t *wire, size_t *pos, size_t size, @@ -245,9 +245,9 @@ static int knot_packet_parse_question(const uint8_t *wire, size_t *pos, assert(wire != NULL); assert(question != NULL); - if (size - *pos < DNSLIB_WIRE_QUESTION_MIN_SIZE) { + if (size - *pos < KNOT_WIRE_QUESTION_MIN_SIZE) { debug_knot_response("Not enough data to parse question.\n"); - return DNSLIB_EFEWDATA; // malformed + return KNOT_EFEWDATA; // malformed } debug_knot_response("Parsing Question starting on position %zu.\n", @@ -261,7 +261,7 @@ static int knot_packet_parse_question(const uint8_t *wire, size_t *pos, if (size - i - 1 < 4) { debug_knot_response("Not enough data to parse question.\n"); - return DNSLIB_EFEWDATA; // no 0 found or not enough data left + return KNOT_EFEWDATA; // no 0 found or not enough data left } debug_knot_response("Parsing dname starting on position %zu and " @@ -271,13 +271,13 @@ static int knot_packet_parse_question(const uint8_t *wire, size_t *pos, question->qname = knot_dname_new_from_wire( wire + *pos, i - *pos + 1, NULL); if (question->qname == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } } else { int res = knot_dname_from_wire(wire + *pos, i - *pos + 1, NULL, question->qname); - if (res != DNSLIB_EOK) { - assert(res != DNSLIB_EBADARG); + if (res != KNOT_EOK) { + assert(res != KNOT_EBADARG); return res; } } @@ -290,7 +290,7 @@ static int knot_packet_parse_question(const uint8_t *wire, size_t *pos, *pos += 4; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -303,8 +303,8 @@ static int knot_packet_parse_question(const uint8_t *wire, size_t *pos, * the response structure was initialized. * \param step How much the space should be increased. * - * \retval DNSLIB_EOK - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_ENOMEM */ static int knot_packet_realloc_rrsets(const knot_rrset_t ***rrsets, short *max_count, @@ -318,7 +318,7 @@ static int knot_packet_realloc_rrsets(const knot_rrset_t ***rrsets, short new_max_count = *max_count + step; const knot_rrset_t **new_rrsets = (const knot_rrset_t **)malloc( new_max_count * sizeof(knot_rrset_t *)); - CHECK_ALLOC_LOG(new_rrsets, DNSLIB_ENOMEM); + CHECK_ALLOC_LOG(new_rrsets, KNOT_ENOMEM); memcpy(new_rrsets, *rrsets, (*max_count) * sizeof(knot_rrset_t *)); @@ -329,7 +329,7 @@ static int knot_packet_realloc_rrsets(const knot_rrset_t ***rrsets, free(old); } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -350,7 +350,7 @@ static knot_rdata_t *knot_packet_parse_rdata(const uint8_t *wire, int rc = knot_rdata_from_wire(rdata, wire, pos, total_size, rdlength, desc); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { debug_knot_packet("rdata_from_wire() returned: %s\n", knot_strerror2(rc)); knot_rdata_free(&rdata); @@ -376,7 +376,7 @@ static knot_rrset_t *knot_packet_parse_rr(const uint8_t *wire, size_t *pos, return NULL; } -DEBUG_DNSLIB_PACKET( +DEBUG_KNOT_PACKET( char *name = knot_dname_to_str(owner); debug_knot_packet("Parsed name: %s\n", name); free(name); @@ -441,7 +441,7 @@ DEBUG_DNSLIB_PACKET( return NULL; } - if (knot_rrset_add_rdata(rrset, rdata) != DNSLIB_EOK) { + if (knot_rrset_add_rdata(rrset, rdata) != KNOT_EOK) { debug_knot_packet("Malformed RR: Could not add RDATA to RRSet" ".\n"); knot_rdata_free(&rdata); @@ -469,7 +469,7 @@ static int knot_packet_add_rrset(knot_rrset_t *rrset, assert(rrset_count != NULL); assert(max_rrsets != NULL); -DEBUG_DNSLIB_PACKET( +DEBUG_KNOT_PACKET( char *name = knot_dname_to_str(rrset->owner); debug_knot_packet("packet_add_rrset(), owner: %s, type: %s\n", name, knot_rrtype_to_string(rrset->type)); @@ -478,22 +478,22 @@ DEBUG_DNSLIB_PACKET( if (*rrset_count == *max_rrsets && knot_packet_realloc_rrsets(rrsets, max_rrsets, default_rrsets, - STEP_ANCOUNT) != DNSLIB_EOK) { - return DNSLIB_ENOMEM; + STEP_ANCOUNT) != KNOT_EOK) { + return KNOT_ENOMEM; } - if (dupl == DNSLIB_PACKET_DUPL_SKIP && - knot_packet_contains(packet, rrset, DNSLIB_RRSET_COMPARE_PTR)) { + if (dupl == KNOT_PACKET_DUPL_SKIP && + knot_packet_contains(packet, rrset, KNOT_RRSET_COMPARE_PTR)) { /*! \todo This should also return > 0, as it means that the RRSet was not used actually. */ - return DNSLIB_EOK; + return KNOT_EOK; } - if (dupl == DNSLIB_PACKET_DUPL_MERGE) { + if (dupl == KNOT_PACKET_DUPL_MERGE) { // try to find the RRSet in this array of RRSets for (int i = 0; i < *rrset_count; ++i) { -DEBUG_DNSLIB_PACKET( +DEBUG_KNOT_PACKET( char *name = knot_dname_to_str((*rrsets)[i]->owner); debug_knot_packet("Comparing to RRSet: owner: %s, " "type: %s\n", name, @@ -503,12 +503,12 @@ DEBUG_DNSLIB_PACKET( ); if (knot_rrset_compare((*rrsets)[i], rrset, - DNSLIB_RRSET_COMPARE_HEADER)) { + KNOT_RRSET_COMPARE_HEADER)) { //const knot_rrset_t *r = (*rrsets) /*! \todo Test this!!! */ int rc = knot_rrset_merge( (void **)((*rrsets) + i), (void **)&rrset); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { return rc; } return 1; @@ -519,7 +519,7 @@ DEBUG_DNSLIB_PACKET( (*rrsets)[*rrset_count] = rrset; ++(*rrset_count); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -550,20 +550,20 @@ static int knot_packet_parse_rrs(const uint8_t *wire, size_t *pos, * We must parse all RRs separately and try to add them to already * parsed RRSets. */ - int err = DNSLIB_EOK; + int err = KNOT_EOK; knot_rrset_t *rrset = NULL; for (int i = 0; i < rr_count; ++i) { rrset = knot_packet_parse_rr(wire, pos, size); if (rrset == NULL) { debug_knot_packet("Failed to parse RR!\n"); - err = DNSLIB_EMALF; + err = KNOT_EMALF; break; } err = knot_packet_add_rrset(rrset, rrsets, rrset_count, max_rrsets, default_rrsets, packet, - DNSLIB_PACKET_DUPL_MERGE); + KNOT_PACKET_DUPL_MERGE); if (err < 0) { break; } else if (err > 0) { // merged @@ -573,7 +573,7 @@ static int knot_packet_parse_rrs(const uint8_t *wire, size_t *pos, } err = knot_packet_add_tmp_rrset(packet, rrset); - if (err != DNSLIB_EOK) { + if (err != KNOT_EOK) { // remove the last RRSet from the list of RRSets // - just decrement the count --(*rrset_count); @@ -582,7 +582,7 @@ static int knot_packet_parse_rrs(const uint8_t *wire, size_t *pos, } } - return (err < 0) ? err : DNSLIB_EOK; + return (err < 0) ? err : KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -595,7 +595,7 @@ static int knot_packet_parse_rrs(const uint8_t *wire, size_t *pos, static void knot_packet_free_allocated_space(knot_packet_t *pkt) { debug_knot_packet("Freeing additional space in packet.\n"); - if (pkt->prealloc_type == DNSLIB_PACKET_PREALLOC_NONE) { + if (pkt->prealloc_type == KNOT_PACKET_PREALLOC_NONE) { debug_knot_packet("Freeing QNAME.\n"); knot_dname_release(pkt->question.qname); } @@ -637,7 +637,7 @@ static int knot_packet_parse_rr_sections(knot_packet_t *packet, if ((err = knot_packet_parse_rrs(packet->wireformat, pos, packet->size, packet->header.ancount, &packet->answer, &packet->an_rrsets, &packet->max_an_rrsets, - DEFAULT_RRSET_COUNT(ANCOUNT, packet), packet)) != DNSLIB_EOK) { + DEFAULT_RRSET_COUNT(ANCOUNT, packet), packet)) != KNOT_EOK) { return err; } @@ -645,7 +645,7 @@ static int knot_packet_parse_rr_sections(knot_packet_t *packet, if ((err = knot_packet_parse_rrs(packet->wireformat, pos, packet->size, packet->header.nscount, &packet->authority, &packet->ns_rrsets, &packet->max_ns_rrsets, - DEFAULT_RRSET_COUNT(NSCOUNT, packet), packet)) != DNSLIB_EOK) { + DEFAULT_RRSET_COUNT(NSCOUNT, packet), packet)) != KNOT_EOK) { return err; } @@ -653,7 +653,7 @@ static int knot_packet_parse_rr_sections(knot_packet_t *packet, if ((err = knot_packet_parse_rrs(packet->wireformat, pos, packet->size, packet->header.arcount, &packet->additional, &packet->ar_rrsets, &packet->max_ar_rrsets, - DEFAULT_RRSET_COUNT(ARCOUNT, packet), packet)) != DNSLIB_EOK) { + DEFAULT_RRSET_COUNT(ARCOUNT, packet), packet)) != KNOT_EOK) { return err; } @@ -661,11 +661,11 @@ static int knot_packet_parse_rr_sections(knot_packet_t *packet, for (int i = 0; i < packet->header.arcount; ++i) { if (knot_rrset_type(packet->additional[i]) - == DNSLIB_RRTYPE_OPT) { + == KNOT_RRTYPE_OPT) { debug_knot_packet("Found OPT RR, filling.\n"); err = knot_edns_new_from_rr(&packet->opt_rr, packet->additional[i]); - if (err != DNSLIB_EOK) { + if (err != KNOT_EOK) { return err; } break; @@ -680,7 +680,7 @@ static int knot_packet_parse_rr_sections(knot_packet_t *packet, packet->parsed = packet->size; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -694,14 +694,14 @@ knot_packet_t *knot_packet_new(knot_packet_prealloc_type_t prealloc) size_t size = 0; switch (prealloc) { - case DNSLIB_PACKET_PREALLOC_NONE: + case KNOT_PACKET_PREALLOC_NONE: size = sizeof(knot_packet_t); break; - case DNSLIB_PACKET_PREALLOC_QUERY: + case KNOT_PACKET_PREALLOC_QUERY: size = PREALLOC_QUERY; init_pointers = knot_packet_init_pointers_query; break; - case DNSLIB_PACKET_PREALLOC_RESPONSE: + case KNOT_PACKET_PREALLOC_RESPONSE: size = PREALLOC_RESPONSE; init_pointers = knot_packet_init_pointers_response; break; @@ -729,7 +729,7 @@ int knot_packet_parse_from_wire(knot_packet_t *packet, int question_only) { if (packet == NULL || wireformat == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } int err; @@ -747,7 +747,7 @@ int knot_packet_parse_from_wire(knot_packet_t *packet, debug_knot_packet("Parsing wire format of packet.\nHeader...\n"); if ((err = knot_packet_parse_header(wireformat, &pos, size, - &packet->header)) != DNSLIB_EOK) { + &packet->header)) != KNOT_EOK) { return err; } @@ -757,8 +757,8 @@ int knot_packet_parse_from_wire(knot_packet_t *packet, packet->prealloc_type); if ((err = knot_packet_parse_question(wireformat, &pos, size, &packet->question, - packet->prealloc_type == DNSLIB_PACKET_PREALLOC_NONE) - ) != DNSLIB_EOK) { + packet->prealloc_type == KNOT_PACKET_PREALLOC_NONE) + ) != KNOT_EOK) { return err; } packet->header.qdcount = 1; @@ -766,7 +766,7 @@ int knot_packet_parse_from_wire(knot_packet_t *packet, packet->parsed = pos; if (question_only) { - return DNSLIB_EOK; + return KNOT_EOK; } /*! \todo Replace by call to parse_rest()? */ @@ -776,7 +776,7 @@ int knot_packet_parse_from_wire(knot_packet_t *packet, // if ((err = knot_packet_parse_rrs(wireformat, &pos, size, // packet->header.ancount, &packet->answer, &packet->an_rrsets, // &packet->max_an_rrsets, DEFAULT_RRSET_COUNT(ANCOUNT, packet), -// packet)) != DNSLIB_EOK) { +// packet)) != KNOT_EOK) { // return err; // } @@ -784,7 +784,7 @@ int knot_packet_parse_from_wire(knot_packet_t *packet, // if ((err = knot_packet_parse_rrs(wireformat, &pos, size, // packet->header.nscount, &packet->authority, &packet->ns_rrsets, // &packet->max_ns_rrsets, DEFAULT_RRSET_COUNT(NSCOUNT, packet), -// packet)) != DNSLIB_EOK) { +// packet)) != KNOT_EOK) { // return err; // } @@ -792,7 +792,7 @@ int knot_packet_parse_from_wire(knot_packet_t *packet, // if ((err = knot_packet_parse_rrs(wireformat, &pos, size, // packet->header.arcount, &packet->additional, &packet->ar_rrsets, // &packet->max_ar_rrsets, DEFAULT_RRSET_COUNT(ARCOUNT, packet), -// packet)) != DNSLIB_EOK) { +// packet)) != KNOT_EOK) { // return err; // } @@ -804,9 +804,9 @@ int knot_packet_parse_from_wire(knot_packet_t *packet, // packet->parsed = size; -#ifdef DNSLIB_PACKET_DEBUG +#ifdef KNOT_PACKET_DEBUG knot_packet_dump(packet); -#endif /* DNSLIB_RESPONSE_DEBUG */ +#endif /* KNOT_RESPONSE_DEBUG */ return err; } @@ -816,11 +816,11 @@ int knot_packet_parse_from_wire(knot_packet_t *packet, int knot_packet_parse_rest(knot_packet_t *packet) { if (packet == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } if (packet->parsed >= packet->size) { - return DNSLIB_EOK; + return KNOT_EOK; } size_t pos = packet->parsed; @@ -834,12 +834,12 @@ int knot_packet_parse_next_rr_answer(knot_packet_t *packet, knot_rrset_t **rr) { if (packet == NULL || rr == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } if (packet->parsed >= packet->size || packet->an_rrsets == packet->header.ancount) { - return DNSLIB_EOK; + return KNOT_EOK; } size_t pos = packet->parsed; @@ -848,7 +848,7 @@ int knot_packet_parse_next_rr_answer(knot_packet_t *packet, *rr = knot_packet_parse_rr(packet->wireformat, &pos, packet->size); if (*rr == NULL) { debug_knot_packet("Failed to parse RR!\n"); - return DNSLIB_EMALF; + return KNOT_EMALF; } packet->parsed = pos; @@ -856,7 +856,7 @@ int knot_packet_parse_next_rr_answer(knot_packet_t *packet, // in the packet; it is OK, because packet->answer is NULL ++packet->an_rrsets; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -864,7 +864,7 @@ int knot_packet_parse_next_rr_answer(knot_packet_t *packet, int knot_packet_set_max_size(knot_packet_t *packet, int max_size) { if (packet == NULL || max_size <= 0) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } if (packet->max_size < max_size) { @@ -872,7 +872,7 @@ int knot_packet_set_max_size(knot_packet_t *packet, int max_size) // that might have been there before uint8_t *wire_new = (uint8_t *)malloc(max_size); if (wire_new == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } uint8_t *wire_old = packet->wireformat; @@ -890,7 +890,7 @@ int knot_packet_set_max_size(knot_packet_t *packet, int max_size) // set max size packet->max_size = max_size; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -941,7 +941,7 @@ uint16_t knot_packet_qclass(const knot_packet_t *packet) int knot_packet_is_query(const knot_packet_t *packet) { if (packet == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } return (knot_wire_flags_get_qr(packet->header.flags1) == 0); @@ -963,7 +963,7 @@ const knot_packet_t *knot_packet_query(const knot_packet_t *packet) short knot_packet_answer_rrset_count(const knot_packet_t *packet) { if (packet == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } return packet->an_rrsets; @@ -974,7 +974,7 @@ short knot_packet_answer_rrset_count(const knot_packet_t *packet) short knot_packet_authority_rrset_count(const knot_packet_t *packet) { if (packet == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } return packet->ns_rrsets; @@ -985,7 +985,7 @@ short knot_packet_authority_rrset_count(const knot_packet_t *packet) short knot_packet_additional_rrset_count(const knot_packet_t *packet) { if (packet == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } return packet->ar_rrsets; @@ -1034,7 +1034,7 @@ int knot_packet_contains(const knot_packet_t *packet, knot_rrset_compare_type_t cmp) { if (packet == NULL || rrset == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } for (int i = 0; i < packet->header.ancount; ++i) { @@ -1064,22 +1064,22 @@ int knot_packet_add_tmp_rrset(knot_packet_t *packet, knot_rrset_t *tmp_rrset) { if (packet == NULL || tmp_rrset == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } if (packet->tmp_rrsets_count == packet->tmp_rrsets_max && knot_packet_realloc_rrsets(&packet->tmp_rrsets, &packet->tmp_rrsets_max, DEFAULT_RRSET_COUNT(TMP_RRSETS, packet), - STEP_TMP_RRSETS) != DNSLIB_EOK) { - return DNSLIB_ENOMEM; + STEP_TMP_RRSETS) != KNOT_EOK) { + return KNOT_ENOMEM; } packet->tmp_rrsets[packet->tmp_rrsets_count++] = tmp_rrset; debug_knot_packet("Current tmp RRSets count: %d, max count: %d\n", packet->tmp_rrsets_count, packet->tmp_rrsets_max); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1095,7 +1095,7 @@ void knot_packet_free_tmp_rrsets(knot_packet_t *pkt) } for (int i = 0; i < pkt->tmp_rrsets_count; ++i) { -DEBUG_DNSLIB_PACKET( +DEBUG_KNOT_PACKET( char *name = knot_dname_to_str( (((knot_rrset_t **)(pkt->tmp_rrsets))[i])->owner); debug_knot_packet("Freeing tmp RRSet on ptr: %p (ptr to ptr:" @@ -1131,8 +1131,8 @@ void knot_packet_header_to_wire(const knot_header_t *header, knot_wire_set_nscount(*pos, header->nscount); knot_wire_set_arcount(*pos, header->arcount); - *pos += DNSLIB_WIRE_HEADER_SIZE; - *size += DNSLIB_WIRE_HEADER_SIZE; + *pos += KNOT_WIRE_HEADER_SIZE; + *size += KNOT_WIRE_HEADER_SIZE; } /*----------------------------------------------------------------------------*/ @@ -1140,21 +1140,21 @@ void knot_packet_header_to_wire(const knot_header_t *header, int knot_packet_question_to_wire(knot_packet_t *packet) { if (packet == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } - if (packet->size > DNSLIB_WIRE_HEADER_SIZE) { - return DNSLIB_ERROR; + if (packet->size > KNOT_WIRE_HEADER_SIZE) { + return KNOT_ERROR; } // TODO: get rid of the numeric constants size_t qsize = 4 + knot_dname_size(packet->question.qname); - if (qsize > packet->max_size - DNSLIB_WIRE_HEADER_SIZE) { - return DNSLIB_ESPACE; + if (qsize > packet->max_size - KNOT_WIRE_HEADER_SIZE) { + return KNOT_ESPACE; } // create the wireformat of Question - uint8_t *pos = packet->wireformat + DNSLIB_WIRE_HEADER_SIZE; + uint8_t *pos = packet->wireformat + KNOT_WIRE_HEADER_SIZE; memcpy(pos, knot_dname_name(packet->question.qname), knot_dname_size(packet->question.qname)); @@ -1167,13 +1167,13 @@ int knot_packet_question_to_wire(knot_packet_t *packet) // TODO: put the qname into the compression table // // TODO: get rid of the numeric constants // if ((err = knot_response_store_dname_pos(&packet->compression, -// packet->question.qname,0, 12, 12)) != DNSLIB_EOK) { +// packet->question.qname,0, 12, 12)) != KNOT_EOK) { // return err; // } packet->size += knot_dname_size(packet->question.qname) + 4; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1181,7 +1181,7 @@ int knot_packet_question_to_wire(knot_packet_t *packet) int knot_packet_edns_to_wire(knot_packet_t *packet) { if (packet == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } packet->size += knot_edns_to_wire(&packet->opt_rr, @@ -1190,7 +1190,7 @@ int knot_packet_edns_to_wire(knot_packet_t *packet) packet->header.arcount += 1; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1200,7 +1200,7 @@ int knot_packet_to_wire(knot_packet_t *packet, { if (packet == NULL || wire == NULL || wire_size == NULL || *wire != NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } assert(packet->size <= packet->max_size); @@ -1224,7 +1224,7 @@ int knot_packet_to_wire(knot_packet_t *packet, *wire = packet->wireformat; *wire_size = packet->size; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1256,7 +1256,7 @@ void knot_packet_free(knot_packet_t **packet) } /*----------------------------------------------------------------------------*/ -#ifdef DNSLIB_PACKET_DEBUG +#ifdef KNOT_PACKET_DEBUG static void knot_packet_dump_rrsets(const knot_rrset_t **rrsets, int count) { @@ -1275,7 +1275,7 @@ void knot_packet_dump(const knot_packet_t *packet) return; } -#ifdef DNSLIB_PACKET_DEBUG +#ifdef KNOT_PACKET_DEBUG debug_knot_packet("DNS packet:\n-----------------------------\n"); debug_knot_packet("\nHeader:\n"); diff --git a/src/dnslib/packet.h b/src/dnslib/packet.h index 35187f00bbda10d455a1518883d1ad46d1244724..a3bc0734264451382c870b59cd6ef0aa48d6637c 100644 --- a/src/dnslib/packet.h +++ b/src/dnslib/packet.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_PACKET_H_ -#define _KNOT_DNSLIB_PACKET_H_ +#ifndef _KNOTDKNOT_PACKET_H_ +#define _KNOTDKNOT_PACKET_H_ #include <stdint.h> #include <string.h> @@ -66,9 +66,9 @@ struct knot_question { typedef struct knot_question knot_question_t; enum knot_packet_prealloc_type { - DNSLIB_PACKET_PREALLOC_NONE, - DNSLIB_PACKET_PREALLOC_QUERY, - DNSLIB_PACKET_PREALLOC_RESPONSE + KNOT_PACKET_PREALLOC_NONE, + KNOT_PACKET_PREALLOC_QUERY, + KNOT_PACKET_PREALLOC_RESPONSE }; typedef enum knot_packet_prealloc_type knot_packet_prealloc_type_t; @@ -248,7 +248,7 @@ knot_packet_t *knot_packet_new(knot_packet_prealloc_type_t prealloc); * packet. In such case the parsing will end after the * Question section. Set to 0 to parse the whole packet. * - * \retval DNSLIB_EOK + * \retval KNOT_EOK */ int knot_packet_parse_from_wire(knot_packet_t *packet, const uint8_t *wireformat, size_t size, @@ -275,9 +275,9 @@ int knot_packet_parse_next_rr_answer(knot_packet_t *packet, * \param packet Packet to set the maximum size of. * \param max_size Maximum size of the packet in bytes. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_EBADARG + * \retval KNOT_ENOMEM * * \todo Needs test. */ @@ -415,8 +415,8 @@ int knot_packet_contains(const knot_packet_t *packet, * \param response Response to which the temporary RRSet should be added. * \param tmp_rrset Temporary RRSet to be stored in the response. * - * \retval DNSLIB_EOK - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_ENOMEM */ int knot_packet_add_tmp_rrset(knot_packet_t *response, knot_rrset_t *tmp_rrset); @@ -456,8 +456,8 @@ int knot_packet_edns_to_wire(knot_packet_t *packet); * be set to NULL (to avoid leaks). * \param wire_size The size of the packet in wire format will be stored here. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG + * \retval KNOT_EOK + * \retval KNOT_EBADARG */ int knot_packet_to_wire(knot_packet_t *packet, uint8_t **wire, size_t *wire_size); @@ -472,12 +472,12 @@ void knot_packet_free(knot_packet_t **packet); /*! * \brief Dumps the whole packet in human-readable form. * - * \note This function is empty unless DNSLIB_PACKET_DEBUG is defined. + * \note This function is empty unless KNOT_PACKET_DEBUG is defined. * * \param resp Packet to dump. */ void knot_packet_dump(const knot_packet_t *packet); -#endif /* _KNOT_DNSLIB_PACKET_H_ */ +#endif /* _KNOTDKNOT_PACKET_H_ */ /*! @} */ diff --git a/src/dnslib/query.c b/src/dnslib/query.c index e413540c0e9839e99b3e01703427567912a864a9..1b0796966e80afc1b1d4d998d41e87e22d47d0b2 100644 --- a/src/dnslib/query.c +++ b/src/dnslib/query.c @@ -36,7 +36,7 @@ int knot_query_init(knot_packet_t *query) uint8_t *pos = query->wireformat; knot_packet_header_to_wire(&query->header, &pos, &query->size); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -45,7 +45,7 @@ int knot_query_set_question(knot_packet_t *query, const knot_question_t *question) { if (query == NULL || question == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } query->question.qname = question->qname; @@ -56,7 +56,7 @@ int knot_query_set_question(knot_packet_t *query, // convert the Question to wire format right away knot_packet_question_to_wire(query); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -64,12 +64,12 @@ int knot_query_set_question(knot_packet_t *query, int knot_query_set_opcode(knot_packet_t *query, uint8_t opcode) { if (query == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } // set the OPCODE in the structure knot_wire_flags_set_opcode(&query->header.flags1, opcode); // set the OPCODE in the wire format knot_wire_set_opcode(query->wireformat, opcode); - return DNSLIB_EOK; + return KNOT_EOK; } diff --git a/src/dnslib/query.h b/src/dnslib/query.h index d7d7367e676814e58d9a5c06e03540e024304884..97934b42bf4ae13444068cb76057de6b148c3edc 100644 --- a/src/dnslib/query.h +++ b/src/dnslib/query.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_QUERY_H_ -#define _KNOT_DNSLIB_QUERY_H_ +#ifndef _KNOTDKNOT_QUERY_H_ +#define _KNOTDKNOT_QUERY_H_ #include <stdint.h> #include <string.h> @@ -59,6 +59,6 @@ int knot_query_set_question(knot_packet_t *query, int knot_query_set_opcode(knot_packet_t *query, uint8_t opcode); -#endif /* _KNOT_DNSLIB_QUERY_H_ */ +#endif /* _KNOTDKNOT_QUERY_H_ */ /*! @} */ diff --git a/src/dnslib/rdata.c b/src/dnslib/rdata.c index 4f443331c10a9081a376cdf8d55b5f13bea9163d..2a0b787e505c50d01f594a4d4ee2c40e245aefe4 100644 --- a/src/dnslib/rdata.c +++ b/src/dnslib/rdata.c @@ -162,12 +162,12 @@ int knot_rdata_from_wire(knot_rdata_t *rdata, const uint8_t *wire, if (rdlength == 0) { rdata->items = NULL; - return DNSLIB_EOK; + return KNOT_EOK; } knot_rdata_item_t *items = (knot_rdata_item_t *)malloc( desc->length * sizeof(knot_rdata_item_t)); - CHECK_ALLOC_LOG(items, DNSLIB_ENOMEM); + CHECK_ALLOC_LOG(items, KNOT_ENOMEM); size_t item_size; uint8_t gateway_type = 0; // only to handle IPSECKEY record @@ -186,16 +186,16 @@ int knot_rdata_from_wire(knot_rdata_t *rdata, const uint8_t *wire, size_t pos2; switch (item_type) { - case DNSLIB_RDATA_WF_COMPRESSED_DNAME: - case DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME: - case DNSLIB_RDATA_WF_LITERAL_DNAME: + case KNOT_RDATA_WF_COMPRESSED_DNAME: + case KNOT_RDATA_WF_UNCOMPRESSED_DNAME: + case KNOT_RDATA_WF_LITERAL_DNAME: // printf("Next item - domain name, pos: %zu.\n", *pos); pos2 = *pos; dname = knot_dname_parse_from_wire( wire, &pos2, total_size, NULL); if (dname == NULL) { free(items); - return DNSLIB_ERROR; + return KNOT_ERROR; } items[i].dname = dname; //*pos += dname->size; @@ -203,47 +203,47 @@ int knot_rdata_from_wire(knot_rdata_t *rdata, const uint8_t *wire, *pos = pos2; dname = 0; break; - case DNSLIB_RDATA_WF_BYTE: + case KNOT_RDATA_WF_BYTE: // printf("Next item - byte.\n"); - if (desc->type == DNSLIB_RRTYPE_IPSECKEY && i == 1) { + if (desc->type == KNOT_RRTYPE_IPSECKEY && i == 1) { gateway_type = *(wire + *pos); } item_size = 1; break; - case DNSLIB_RDATA_WF_SHORT: + case KNOT_RDATA_WF_SHORT: // printf("Next item - short.\n"); item_size = 2; break; - case DNSLIB_RDATA_WF_LONG: + case KNOT_RDATA_WF_LONG: // printf("Next item - long, pos: %zu.\n", *pos); item_size = 4; break; - case DNSLIB_RDATA_WF_TEXT: + case KNOT_RDATA_WF_TEXT: // printf("Next item - text.\n"); // TODO!!! break; - case DNSLIB_RDATA_WF_A: + case KNOT_RDATA_WF_A: // printf("Next item - A.\n"); item_size = 4; break; - case DNSLIB_RDATA_WF_AAAA: + case KNOT_RDATA_WF_AAAA: // printf("Next item - AAAA.\n"); item_size = 16; break; - case DNSLIB_RDATA_WF_BINARY: + case KNOT_RDATA_WF_BINARY: // printf("Next item - Binary data.\n"); // the rest of the RDATA is this item item_size = rdlength - parsed; // printf("Binary item, size: %zu\n", item_size); break; - case DNSLIB_RDATA_WF_BINARYWITHLENGTH: + case KNOT_RDATA_WF_BINARYWITHLENGTH: // printf("Next item - Binary with length.\n"); item_size = *(wire + *pos); break; - case DNSLIB_RDATA_WF_APL: + case KNOT_RDATA_WF_APL: // WTF? what to do with this?? break; - case DNSLIB_RDATA_WF_IPSECGATEWAY: + case KNOT_RDATA_WF_IPSECGATEWAY: // determine size based on the 'gateway type' field switch (gateway_type) { case 0: @@ -261,7 +261,7 @@ int knot_rdata_from_wire(knot_rdata_t *rdata, const uint8_t *wire, knot_dname_parse_from_wire( wire, &pos2, total_size, NULL); if (dname == NULL) { - return DNSLIB_ERROR; + return KNOT_ERROR; } items[i].dname = dname; //*pos += dname->size; @@ -276,7 +276,7 @@ int knot_rdata_from_wire(knot_rdata_t *rdata, const uint8_t *wire, break; default: // printf("Next item - unknown.\n"); - return DNSLIB_EMALF; + return KNOT_EMALF; } @@ -285,13 +285,13 @@ int knot_rdata_from_wire(knot_rdata_t *rdata, const uint8_t *wire, // item_size); if (parsed + item_size > rdlength) { free(items); - return DNSLIB_EFEWDATA; + return KNOT_EFEWDATA; } items[i].raw_data = (uint16_t *)malloc(item_size + 2); if (items[i].raw_data == NULL) { free(items); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } // TODO: save size to the RDATA item!!! // printf("Read: %u\n", knot_wire_read_u32(wire + *pos)); @@ -317,7 +317,7 @@ int knot_rdata_set_item(knot_rdata_t *rdata, uint pos, knot_rdata_item_t item) { if (pos >= rdata->count) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } /*! \todo As in set_items() we should increment refcounter for dnames, @@ -325,7 +325,7 @@ int knot_rdata_set_item(knot_rdata_t *rdata, uint pos, */ rdata->items[pos] = item; // this should copy the union; or use memcpy? - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -342,14 +342,14 @@ int knot_rdata_set_items(knot_rdata_t *rdata, { if (rdata == NULL || items == NULL || count == 0 || rdata->items != NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } assert(rdata->count == 0); if ((rdata->items = (knot_rdata_item_t *)malloc( count * sizeof(knot_rdata_item_t))) == NULL) { ERR_ALLOC_FAILED; - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } memcpy(rdata->items, items, count * sizeof(knot_rdata_item_t)); @@ -359,7 +359,7 @@ int knot_rdata_set_items(knot_rdata_t *rdata, * refcounters should be increased in caller. */ - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -392,7 +392,7 @@ int knot_rdata_item_set_dname(knot_rdata_t *rdata, uint pos, knot_dname_t *dname) { if (pos >= rdata->count) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } /* Retain dname. */ @@ -400,7 +400,7 @@ int knot_rdata_item_set_dname(knot_rdata_t *rdata, uint pos, rdata->items[pos].dname = dname; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -409,12 +409,12 @@ int knot_rdata_item_set_raw_data(knot_rdata_t *rdata, uint pos, uint16_t *raw_data) { if (pos >= rdata->count) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } rdata->items[pos].raw_data = raw_data; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -451,9 +451,9 @@ void knot_rdata_deep_free(knot_rdata_t **rdata, uint type, if (&((*rdata)->items[i]) == NULL) { continue; } - if (desc->wireformat[i] == DNSLIB_RDATA_WF_COMPRESSED_DNAME - || desc->wireformat[i] == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME - || desc->wireformat[i] == DNSLIB_RDATA_WF_LITERAL_DNAME ) { + if (desc->wireformat[i] == KNOT_RDATA_WF_COMPRESSED_DNAME + || desc->wireformat[i] == KNOT_RDATA_WF_UNCOMPRESSED_DNAME + || desc->wireformat[i] == KNOT_RDATA_WF_LITERAL_DNAME ) { if (((*rdata)->items[i].dname != NULL)) { /*! \todo This is hack to prevent memory errors, * as the rdata_set_items() cannot determine @@ -487,33 +487,33 @@ void knot_rdata_deep_free(knot_rdata_t **rdata, uint type, // for (int i = 0; i < rdata->count; ++i) { // switch (format[i]) { -// case DNSLIB_RDATA_WF_COMPRESSED_DNAME: -// case DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME: -// case DNSLIB_RDATA_WF_LITERAL_DNAME: +// case KNOT_RDATA_WF_COMPRESSED_DNAME: +// case KNOT_RDATA_WF_UNCOMPRESSED_DNAME: +// case KNOT_RDATA_WF_LITERAL_DNAME: // size += knot_dname_size(rdata->items[i].dname); // break; -// case DNSLIB_RDATA_WF_BYTE: +// case KNOT_RDATA_WF_BYTE: // size += 1; // break; -// case DNSLIB_RDATA_WF_SHORT: +// case KNOT_RDATA_WF_SHORT: // size += 2; // break; -// case DNSLIB_RDATA_WF_LONG: +// case KNOT_RDATA_WF_LONG: // size += 4; // break; -// case DNSLIB_RDATA_WF_A: +// case KNOT_RDATA_WF_A: // size += 4; // break; -// case DNSLIB_RDATA_WF_AAAA: +// case KNOT_RDATA_WF_AAAA: // size += 16; // break; -// case DNSLIB_RDATA_WF_BINARY: -// case DNSLIB_RDATA_WF_APL: // saved as binary -// case DNSLIB_RDATA_WF_IPSECGATEWAY: // saved as binary +// case KNOT_RDATA_WF_BINARY: +// case KNOT_RDATA_WF_APL: // saved as binary +// case KNOT_RDATA_WF_IPSECGATEWAY: // saved as binary // size += rdata->items[i].raw_data[0]; // break; -// case DNSLIB_RDATA_WF_TEXT: -// case DNSLIB_RDATA_WF_BINARYWITHLENGTH: +// case KNOT_RDATA_WF_TEXT: +// case KNOT_RDATA_WF_BINARYWITHLENGTH: // size += rdata->items[i].raw_data[0] + 1; // break; // default: @@ -529,47 +529,47 @@ void knot_rdata_deep_free(knot_rdata_t **rdata, uint type, // uint8_t *buffer, uint buf_size) //{ // uint copied = 0; -// uint8_t tmp[DNSLIB_MAX_RDATA_WIRE_SIZE]; +// uint8_t tmp[KNOT_MAX_RDATA_WIRE_SIZE]; // uint8_t *to = tmp; // for (int i = 0; i < rdata->count; ++i) { -// assert(copied < DNSLIB_MAX_RDATA_WIRE_SIZE); +// assert(copied < KNOT_MAX_RDATA_WIRE_SIZE); // const uint8_t *from = (uint8_t *)rdata->items[i].raw_data; // uint size = 0; // switch (format[i]) { -// case DNSLIB_RDATA_WF_COMPRESSED_DNAME: -// case DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME: -// case DNSLIB_RDATA_WF_LITERAL_DNAME: +// case KNOT_RDATA_WF_COMPRESSED_DNAME: +// case KNOT_RDATA_WF_UNCOMPRESSED_DNAME: +// case KNOT_RDATA_WF_LITERAL_DNAME: // size = knot_dname_size(rdata->items[i].dname); // from = knot_dname_name(rdata->items[i].dname); // break; -// case DNSLIB_RDATA_WF_BYTE: +// case KNOT_RDATA_WF_BYTE: // size = 1; // break; -// case DNSLIB_RDATA_WF_SHORT: +// case KNOT_RDATA_WF_SHORT: // size = 2; // break; -// case DNSLIB_RDATA_WF_LONG: +// case KNOT_RDATA_WF_LONG: // size = 4; // break; -// case DNSLIB_RDATA_WF_A: +// case KNOT_RDATA_WF_A: // size = 4; // break; -// case DNSLIB_RDATA_WF_AAAA: +// case KNOT_RDATA_WF_AAAA: // size = 16; // break; -// case DNSLIB_RDATA_WF_TEXT: -// case DNSLIB_RDATA_WF_BINARYWITHLENGTH: +// case KNOT_RDATA_WF_TEXT: +// case KNOT_RDATA_WF_BINARYWITHLENGTH: // // size stored in the first two bytes, but in little // // endian and we need only the lower byte from it // *to = *from; // lower byte is the first in little endian // to += 1; -// case DNSLIB_RDATA_WF_BINARY: -// case DNSLIB_RDATA_WF_APL: // saved as binary -// case DNSLIB_RDATA_WF_IPSECGATEWAY: // saved as binary +// case KNOT_RDATA_WF_BINARY: +// case KNOT_RDATA_WF_APL: // saved as binary +// case KNOT_RDATA_WF_IPSECGATEWAY: // saved as binary // // size stored in the first two bytes, those bytes // // must not be copied // size = rdata->items[i].raw_data[0]; @@ -580,7 +580,7 @@ void knot_rdata_deep_free(knot_rdata_t **rdata, uint type, // } // assert(size != 0); -// assert(copied + size < DNSLIB_MAX_RDATA_WIRE_SIZE); +// assert(copied + size < KNOT_MAX_RDATA_WIRE_SIZE); // memcpy(to, from, size); // to += size; @@ -622,9 +622,9 @@ knot_rdata_t *knot_rdata_deep_copy(const knot_rdata_t *rdata, // copy all items one by one for (int i = 0; i < copy->count; ++i) { - if (d->wireformat[i] == DNSLIB_RDATA_WF_COMPRESSED_DNAME - || d->wireformat[i] == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME - || d->wireformat[i] == DNSLIB_RDATA_WF_LITERAL_DNAME) { + if (d->wireformat[i] == KNOT_RDATA_WF_COMPRESSED_DNAME + || d->wireformat[i] == KNOT_RDATA_WF_UNCOMPRESSED_DNAME + || d->wireformat[i] == KNOT_RDATA_WF_LITERAL_DNAME) { copy->items[i].dname = knot_dname_deep_copy(rdata->items[i].dname); } else { @@ -656,9 +656,9 @@ int knot_rdata_compare(const knot_rdata_t *r1, const knot_rdata_t *r2, // const uint8_t *data1, *data2; // int size1, size2; - if (format[i] == DNSLIB_RDATA_WF_COMPRESSED_DNAME || - format[i] == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME || - format[i] == DNSLIB_RDATA_WF_LITERAL_DNAME) { + if (format[i] == KNOT_RDATA_WF_COMPRESSED_DNAME || + format[i] == KNOT_RDATA_WF_UNCOMPRESSED_DNAME || + format[i] == KNOT_RDATA_WF_LITERAL_DNAME) { cmp = knot_dname_compare(r1->items[i].dname, r2->items[i].dname); // data1 = knot_dname_name(r1->items[i].dname); @@ -716,13 +716,13 @@ const knot_dname_t *knot_rdata_get_name(const knot_rdata_t *rdata, // iterate over the rdata items or act as if we knew where the name is? switch (type) { - case DNSLIB_RRTYPE_NS: + case KNOT_RRTYPE_NS: return knot_rdata_ns_name(rdata); - case DNSLIB_RRTYPE_MX: + case KNOT_RRTYPE_MX: return knot_rdata_mx_name(rdata); - case DNSLIB_RRTYPE_SRV: + case KNOT_RRTYPE_SRV: return knot_rdata_srv_name(rdata); - case DNSLIB_RRTYPE_CNAME: + case KNOT_RRTYPE_CNAME: return knot_rdata_cname_name(rdata); } diff --git a/src/dnslib/rdata.h b/src/dnslib/rdata.h index c0a69da2a983dc43e88becbc2eadc9b0153fe681..78ec76221cc0551600d74528e8f0d5fe9cfb4fa3 100644 --- a/src/dnslib/rdata.h +++ b/src/dnslib/rdata.h @@ -10,8 +10,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_RDATA_H_ -#define _KNOT_DNSLIB_RDATA_H_ +#ifndef _KNOTDKNOT_RDATA_H_ +#define _KNOTDKNOT_RDATA_H_ #include <stdint.h> #include <string.h> @@ -98,11 +98,11 @@ knot_rdata_t *knot_rdata_new(); * \param rdlength Size of the RDATA to parse in bytes. * \param desc RR type descriptor for the RDATA type. * - * \retval DNSLIB_ENOMEM - * \retval DNSLIB_EFEWDATA - * \retval DNSLIB_EMALF - * \retval DNSLIB_ERROR - * \retval DNSLIB_EOK + * \retval KNOT_ENOMEM + * \retval KNOT_EFEWDATA + * \retval KNOT_EMALF + * \retval KNOT_ERROR + * \retval KNOT_EOK */ int knot_rdata_from_wire(knot_rdata_t *rdata, const uint8_t *wire, size_t *pos, size_t total_size, size_t rdlength, @@ -115,8 +115,8 @@ int knot_rdata_from_wire(knot_rdata_t *rdata, const uint8_t *wire, * \param pos Position of the RDATA item to be set. * \param item RDATA item value to be set. * - * \retval DNSLIB_EOK if successful. - * \retval DNSLIB_EBADARG if \a pos is not a valid position. + * \retval KNOT_EOK if successful. + * \retval KNOT_EBADARG if \a pos is not a valid position. * * \todo Use the union or a pointer to it as parameter? IMHO there is always * only one pointer that is copied, so it doesn't matter. @@ -137,8 +137,8 @@ int knot_rdata_set_item(knot_rdata_t *rdata, unsigned int pos, * \param count Count of RDATA items to be stored. * * \retval 0 if successful. - * \retval DNSLIB_EBADARG - * \retval DNSLIB_ENOMEM + * \retval KNOT_EBADARG + * \retval KNOT_ENOMEM */ int knot_rdata_set_items(knot_rdata_t *rdata, const knot_rdata_item_t *items, @@ -186,8 +186,8 @@ const knot_rdata_item_t *knot_rdata_item(const knot_rdata_t *rdata, * \param pos Position of the RDATA item to set. * \param dname Domain name to set to the item. * - * \retval DNSLIB_EOK if successful. - * \retval DNSLIB_EBADARG + * \retval KNOT_EOK if successful. + * \retval KNOT_EBADARG */ int knot_rdata_item_set_dname(knot_rdata_t *rdata, unsigned int pos, knot_dname_t *dname); @@ -199,8 +199,8 @@ int knot_rdata_item_set_dname(knot_rdata_t *rdata, unsigned int pos, * \param pos Position of the RDATA item to set. * \param raw_data Raw data to set to the item. * - * \retval DNSLIB_EOK if successful. - * \retval DNSLIB_EBADARG + * \retval KNOT_EOK if successful. + * \retval KNOT_EBADARG */ int knot_rdata_item_set_raw_data(knot_rdata_t *rdata, unsigned int pos, uint16_t *raw_data); @@ -293,10 +293,10 @@ const knot_dname_t *knot_rdata_dname_target(const knot_rdata_t *rdata); * \brief Retrieves the domain name from RDATA of given type. * * Supported types: - * - DNSLIB_RRTYPE_NS - * - DNSLIB_RRTYPE_MX - * - DNSLIB_RRTYPE_SRV - * - DNSLIB_RRTYPE_CNAME + * - KNOT_RRTYPE_NS + * - KNOT_RRTYPE_MX + * - KNOT_RRTYPE_SRV + * - KNOT_RRTYPE_CNAME * * \note This is only convenience function. It does not (and cannot) check if * the given RDATA is of the right type, so it always returns the RDATA @@ -319,6 +319,6 @@ uint32_t knot_rdata_soa_expire(const knot_rdata_t *rdata); uint16_t knot_rdata_rrsig_type_covered(const knot_rdata_t *rdata); -#endif /* _KNOT_DNSLIB_RDATA_H */ +#endif /* _KNOTDKNOT_RDATA_H */ /*! @} */ diff --git a/src/dnslib/response.c b/src/dnslib/response.c index f940e496786fac8bdce320932ff207cb53951b2c..981239b1765a09f263f7ec92928d39d75495c3cb 100644 --- a/src/dnslib/response.c +++ b/src/dnslib/response.c @@ -19,7 +19,7 @@ * * This size must be supported by all servers and clients. */ -static const short DNSLIB_MAX_RESPONSE_SIZE = 512; +static const short KNOT_MAX_RESPONSE_SIZE = 512; /*! * \brief Default sizes for response structure parts and steps for increasing @@ -133,7 +133,7 @@ typedef struct knot_compr knot_compr_t; //static int COMPRESS_DNAMES = 1; -static const size_t DNSLIB_RESPONSE_MAX_PTR = 16383; +static const size_t KNOT_RESPONSE_MAX_PTR = 16383; /*----------------------------------------------------------------------------*/ /* Non-API functions */ @@ -233,8 +233,8 @@ static void knot_response_init_pointers(knot_response_t *resp) * \param opt_rr OPT RR to be put to the response. * \param max_size Maximum size of the wire format of the response. * - * \retval DNSLIB_EOK - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_ENOMEM */ static int knot_response_init(knot_response_t *resp, const knot_opt_rr_t *opt_rr, @@ -254,7 +254,7 @@ static int knot_response_init(knot_response_t *resp, resp->edns_response.size = opt_rr->size; if (max_size > 0 && max_size < opt_rr->payload) { - return DNSLIB_EPAYLOAD; + return KNOT_EPAYLOAD; } resp->max_size = resp->edns_response.payload; @@ -265,20 +265,20 @@ static int knot_response_init(knot_response_t *resp, // pre-allocate space for wire format of the packet resp->wireformat = (uint8_t *)malloc(resp->max_size); if (resp->wireformat == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } // save default pointers to the space after the structure knot_response_init_pointers(resp); // set header to all 0s - memset(resp->wireformat, 0, DNSLIB_WIRE_HEADER_SIZE); + memset(resp->wireformat, 0, KNOT_WIRE_HEADER_SIZE); // set the QR bit knot_wire_set_qr(resp->wireformat); // set the size to the size of header - resp->size = DNSLIB_WIRE_HEADER_SIZE; + resp->size = KNOT_WIRE_HEADER_SIZE; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -293,8 +293,8 @@ static int knot_response_init(knot_response_t *resp, * \param[in,out] remaining Remaining size of the wire format. * \param[out] header Header structure to fill in. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EFEWDATA + * \retval KNOT_EOK + * \retval KNOT_EFEWDATA */ static int knot_response_parse_header(const uint8_t **pos, size_t *remaining, knot_header_t *header) @@ -304,9 +304,9 @@ static int knot_response_parse_header(const uint8_t **pos, size_t *remaining, assert(remaining != NULL); assert(header != NULL); - if (*remaining < DNSLIB_WIRE_HEADER_SIZE) { + if (*remaining < KNOT_WIRE_HEADER_SIZE) { debug_knot_response("Not enough data to parse header.\n"); - return DNSLIB_EFEWDATA; + return KNOT_EFEWDATA; } header->id = knot_wire_get_id(*pos); @@ -322,10 +322,10 @@ static int knot_response_parse_header(const uint8_t **pos, size_t *remaining, header->nscount = knot_wire_get_nscount(*pos); header->arcount = knot_wire_get_arcount(*pos); - *pos += DNSLIB_WIRE_HEADER_SIZE; - *remaining -= DNSLIB_WIRE_HEADER_SIZE; + *pos += KNOT_WIRE_HEADER_SIZE; + *remaining -= KNOT_WIRE_HEADER_SIZE; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -350,8 +350,8 @@ static void knot_response_header_to_wire(const knot_header_t *header, knot_wire_set_nscount(*pos, header->nscount); knot_wire_set_arcount(*pos, header->arcount); - *pos += DNSLIB_WIRE_HEADER_SIZE; - *size += DNSLIB_WIRE_HEADER_SIZE; + *pos += KNOT_WIRE_HEADER_SIZE; + *size += KNOT_WIRE_HEADER_SIZE; } /*----------------------------------------------------------------------------*/ @@ -365,9 +365,9 @@ static void knot_response_header_to_wire(const knot_header_t *header, * \param[in,out] remaining Remaining size of the wire format. * \param[out] question DNS Question structure to be filled. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EFEWDATA - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_EFEWDATA + * \retval KNOT_ENOMEM */ static int knot_response_parse_question(const uint8_t **pos, size_t *remaining, @@ -379,9 +379,9 @@ static int knot_response_parse_question(const uint8_t **pos, assert(question != NULL); assert(question->qname != NULL); - if (*remaining < DNSLIB_WIRE_QUESTION_MIN_SIZE) { + if (*remaining < KNOT_WIRE_QUESTION_MIN_SIZE) { debug_knot_response("Not enough data to parse question.\n"); - return DNSLIB_EFEWDATA; // malformed + return KNOT_EFEWDATA; // malformed } // domain name must end with 0, so just search for 0 @@ -392,12 +392,12 @@ static int knot_response_parse_question(const uint8_t **pos, if (i == *remaining || *remaining - i - 1 < 4) { debug_knot_response("Not enough data to parse question.\n"); - return DNSLIB_EFEWDATA; // no 0 found or not enough data left + return KNOT_EFEWDATA; // no 0 found or not enough data left } int res = knot_dname_from_wire(*pos, i + 1, NULL, question->qname); - if (res != DNSLIB_EOK) { - assert(res != DNSLIB_EBADARG); + if (res != KNOT_EOK) { + assert(res != KNOT_EBADARG); return res; } @@ -409,7 +409,7 @@ static int knot_response_parse_question(const uint8_t **pos, *remaining -= (i + 5); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -450,10 +450,10 @@ static void knot_response_question_to_wire(knot_question_t *question, * \param remaining Remaining size of the wire format. * \param client_opt OPT RR structure to fill in. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG - * \retval DNSLIB_EFEWDATA - * \retval DNSLIB_EMALF + * \retval KNOT_EOK + * \retval KNOT_EBADARG + * \retval KNOT_EFEWDATA + * \retval KNOT_EMALF */ static int knot_response_parse_client_edns(const uint8_t **pos, size_t *remaining, @@ -472,7 +472,7 @@ static int knot_response_parse_client_edns(const uint8_t **pos, *remaining -= parsed; *pos += parsed; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -481,8 +481,8 @@ static int knot_response_parse_client_edns(const uint8_t **pos, * * \param table Compression table to reallocate space for. * - * \retval DNSLIB_EOK - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_ENOMEM */ static int knot_response_realloc_compr(knot_compressed_dnames_t *table) { @@ -500,7 +500,7 @@ static int knot_response_realloc_compr(knot_compressed_dnames_t *table) if (new_dnames == NULL) { ERR_ALLOC_FAILED; free(new_offsets); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } memcpy(new_offsets, table->offsets, table->max * sizeof(size_t)); @@ -516,7 +516,7 @@ static int knot_response_realloc_compr(knot_compressed_dnames_t *table) free(old_dnames); } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -563,30 +563,30 @@ static void knot_response_compr_save(knot_compressed_dnames_t *table, * \param pos Position of the domain name in the wire format of the packet. * \param unmatched_offset Position of the unmatched parent domain of \a dname. * - * \retval DNSLIB_EOK - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_ENOMEM */ static int knot_response_store_dname_pos(knot_compressed_dnames_t *table, const knot_dname_t *dname, int not_matched, size_t pos, size_t unmatched_offset) { -DEBUG_DNSLIB_RESPONSE( +DEBUG_KNOT_RESPONSE( char *name = knot_dname_to_str(dname); debug_knot_response("Putting dname %s into compression table." " Labels not matched: %d, position: %d," ", pointer: %p\n", name, not_matched, pos, dname); free(name); ); - if (pos > DNSLIB_RESPONSE_MAX_PTR) { + if (pos > KNOT_RESPONSE_MAX_PTR) { debug_knot_response("Pointer larger than it can be, not" " saving\n"); - return DNSLIB_EDNAMEPTR; + return KNOT_EDNAMEPTR; } if (table->count == table->max && knot_response_realloc_compr(table) != 0) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } // store the position of the name @@ -618,7 +618,7 @@ DEBUG_DNSLIB_RESPONSE( parent_pos = unmatched_offset; } -DEBUG_DNSLIB_RESPONSE( +DEBUG_KNOT_RESPONSE( char *name = knot_dname_to_str(to_save); debug_knot_response("Putting dname %s into compression table." " Position: %d, pointer: %p\n", @@ -629,7 +629,7 @@ DEBUG_DNSLIB_RESPONSE( if (table->count == table->max && knot_response_realloc_compr(table) != 0) { debug_knot_response("Unable to realloc.\n"); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } // debug_knot_response("Saving..\n"); @@ -648,7 +648,7 @@ DEBUG_DNSLIB_RESPONSE( ++i; } - return DNSLIB_EOK; + return KNOT_EOK; } /*---------------------------------------------------------------------------*/ @@ -670,7 +670,7 @@ static size_t knot_response_find_dname_pos( for (int i = 0; i < table->count; ++i) { debug_knot_response("Comparing dnames %p and %p\n", dname, table->dnames[i]); -DEBUG_DNSLIB_RESPONSE( +DEBUG_KNOT_RESPONSE( char *name = knot_dname_to_str(dname); debug_knot_response("(%s and ", name); name = knot_dname_to_str(table->dnames[i]); @@ -705,7 +705,7 @@ DEBUG_DNSLIB_RESPONSE( * \param max Maximum available size of the place for the wire format. * * \return Size of the compressed domain name put into the wire format or - * DNSLIB_ESPACE if it did not fit. + * KNOT_ESPACE if it did not fit. */ static int knot_response_put_dname_ptr(const knot_dname_t *dname, int not_matched, size_t offset, @@ -714,7 +714,7 @@ static int knot_response_put_dname_ptr(const knot_dname_t *dname, // put the not matched labels short size = knot_dname_size_part(dname, not_matched); if (size + 2 > max) { - return DNSLIB_ESPACE; + return KNOT_ESPACE; } memcpy(wire, knot_dname_name(dname), size); @@ -735,7 +735,7 @@ static int knot_response_put_dname_ptr(const knot_dname_t *dname, * \param compr_cs Set to <> 0 if dname compression should use case sensitive * comparation. Set to 0 otherwise. * - * \return Size of the domain name's wire format or DNSLIB_ESPACE if it did not + * \return Size of the domain name's wire format or KNOT_ESPACE if it did not * fit into the provided space. */ static int knot_response_compress_dname(const knot_dname_t *dname, @@ -760,7 +760,7 @@ static int knot_response_compress_dname(const knot_dname_t *dname, int not_matched = 0; while (to_find != NULL && knot_dname_label_count(to_find) != 0) { -DEBUG_DNSLIB_RESPONSE( +DEBUG_KNOT_RESPONSE( char *name = knot_dname_to_str(to_find); debug_knot_response("Searching for name %s in the compression" " table, not matched labels: %d\n", name, @@ -819,17 +819,17 @@ DEBUG_DNSLIB_RESPONSE( if (offset > 0) { // found such dname somewhere in the packet debug_knot_response("Found name in the compression table.\n"); - assert(offset >= DNSLIB_WIRE_HEADER_SIZE); + assert(offset >= KNOT_WIRE_HEADER_SIZE); size = knot_response_put_dname_ptr(dname, not_matched, offset, dname_wire, max); if (size <= 0) { - return DNSLIB_ESPACE; + return KNOT_ESPACE; } } else { debug_knot_response("Not found, putting whole name.\n"); // now just copy the dname without compressing if (dname->size > max) { - return DNSLIB_ESPACE; + return KNOT_ESPACE; } memcpy(dname_wire, dname->name, dname->size); @@ -859,7 +859,7 @@ DEBUG_DNSLIB_RESPONSE( * \param[in] compr_cs Set to <> 0 if dname compression should use case * sensitive comparation. Set to 0 otherwise. * - * \return Size of the RR's wire format or DNSLIB_ESPACE if it did not fit into + * \return Size of the RR's wire format or KNOT_ESPACE if it did not fit into * the provided space. */ static int knot_response_rr_to_wire(const knot_rrset_t *rrset, @@ -872,7 +872,7 @@ static int knot_response_rr_to_wire(const knot_rrset_t *rrset, if (size + ((compr->owner.pos == 0) ? compr->owner.size : 2) + 10 > max_size) { - return DNSLIB_ESPACE; + return KNOT_ESPACE; } debug_knot_response("Owner position: %zu\n", compr->owner.pos); @@ -926,13 +926,13 @@ static int knot_response_rr_to_wire(const knot_rrset_t *rrset, for (int i = 0; i < rdata->count; ++i) { switch (desc->wireformat[i]) { - case DNSLIB_RDATA_WF_COMPRESSED_DNAME: { + case KNOT_RDATA_WF_COMPRESSED_DNAME: { int ret = knot_response_compress_dname( knot_rdata_item(rdata, i)->dname, compr, *rrset_wire, max_size - size, compr_cs); if (ret < 0) { - return DNSLIB_ESPACE; + return KNOT_ESPACE; } debug_knot_response("Compressed dname size: %d\n", @@ -943,12 +943,12 @@ static int knot_response_rr_to_wire(const knot_rrset_t *rrset, // TODO: compress domain name break; } - case DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME: - case DNSLIB_RDATA_WF_LITERAL_DNAME: { + case KNOT_RDATA_WF_UNCOMPRESSED_DNAME: + case KNOT_RDATA_WF_LITERAL_DNAME: { knot_dname_t *dname = knot_rdata_item(rdata, i)->dname; if (size + dname->size > max_size) { - return DNSLIB_ESPACE; + return KNOT_ESPACE; } // save whole domain name @@ -960,12 +960,12 @@ static int knot_response_rr_to_wire(const knot_rrset_t *rrset, compr->wire_pos += dname->size; break; } -// case DNSLIB_RDATA_WF_BINARYWITHLENGTH: { +// case KNOT_RDATA_WF_BINARYWITHLENGTH: { // uint16_t *raw_data = // knot_rdata_item(rdata, i)->raw_data; // if (size + raw_data[0] + 1 > max_size) { -// return DNSLIB_ESPACE; +// return KNOT_ESPACE; // } // // copy also the rdata item size @@ -985,7 +985,7 @@ static int knot_response_rr_to_wire(const knot_rrset_t *rrset, knot_rdata_item(rdata, i)->raw_data; if (size + raw_data[0] > max_size) { - return DNSLIB_ESPACE; + return KNOT_ESPACE; } // copy just the rdata item data (without size) @@ -1021,7 +1021,7 @@ static int knot_response_rr_to_wire(const knot_rrset_t *rrset, * \param compr_cs Set to <> 0 if dname compression should use case sensitive * comparation. Set to 0 otherwise. * - * \return Size of the RRSet's wire format or DNSLIB_ESPACE if it did not fit + * \return Size of the RRSet's wire format or KNOT_ESPACE if it did not fit * into the provided space. */ static int knot_response_rrset_to_wire(const knot_rrset_t *rrset, @@ -1031,7 +1031,7 @@ static int knot_response_rrset_to_wire(const knot_rrset_t *rrset, knot_compressed_dnames_t *compr, int compr_cs) { -DEBUG_DNSLIB_RESPONSE( +DEBUG_KNOT_RESPONSE( char *name = knot_dname_to_str(rrset->owner); debug_knot_response("Converting RRSet with owner %s, type %s\n", name, knot_rrtype_to_string(rrset->type)); @@ -1041,7 +1041,7 @@ DEBUG_DNSLIB_RESPONSE( // if no RDATA in RRSet, return if (rrset->rdata == NULL) { - return DNSLIB_EOK; + return KNOT_EOK; } //uint8_t *rrset_wire = (uint8_t *)malloc(PREALLOC_RRSET_WIRE); @@ -1069,7 +1069,7 @@ DEBUG_DNSLIB_RESPONSE( debug_knot_response(" Owner size: %d, position: %zu\n", compr_info.owner.size, compr_info.owner.pos); if (compr_info.owner.size < 0) { - return DNSLIB_ESPACE; + return KNOT_ESPACE; } int rrs = 0; @@ -1087,7 +1087,7 @@ DEBUG_DNSLIB_RESPONSE( // some RR didn't fit in, so no RRs should be used // TODO: remove last entries from compression table debug_knot_response("Some RR didn't fit in.\n"); - return DNSLIB_ESPACE; + return KNOT_ESPACE; } debug_knot_response("RR of size %d added.\n", ret); @@ -1163,8 +1163,8 @@ static void knot_response_free_allocated_space(knot_response_t *resp) * the response structure was initialized. * \param step How much the space should be increased. * - * \retval DNSLIB_EOK - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_ENOMEM */ static int knot_response_realloc_rrsets(const knot_rrset_t ***rrsets, short *max_count, @@ -1176,7 +1176,7 @@ static int knot_response_realloc_rrsets(const knot_rrset_t ***rrsets, short new_max_count = *max_count + step; const knot_rrset_t **new_rrsets = (const knot_rrset_t **)malloc( new_max_count * sizeof(knot_rrset_t *)); - CHECK_ALLOC_LOG(new_rrsets, DNSLIB_ENOMEM); + CHECK_ALLOC_LOG(new_rrsets, KNOT_ENOMEM); memcpy(new_rrsets, *rrsets, (*max_count) * sizeof(knot_rrset_t *)); @@ -1187,7 +1187,7 @@ static int knot_response_realloc_rrsets(const knot_rrset_t ***rrsets, free(old); } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1210,14 +1210,14 @@ static int knot_response_realloc_rrsets(const knot_rrset_t ***rrsets, // for (int i = 0; i < rdata->count; ++i) { // switch (desc->wireformat[i]) { -// case DNSLIB_RDATA_WF_COMPRESSED_DNAME: -// case DNSLIB_RDATA_WF_LITERAL_DNAME: -// case DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME: +// case KNOT_RDATA_WF_COMPRESSED_DNAME: +// case KNOT_RDATA_WF_LITERAL_DNAME: +// case KNOT_RDATA_WF_UNCOMPRESSED_DNAME: // debug_knot_response("dname size: %d\n", // rdata->items[i].dname->size); // size += rdata->items[i].dname->size; // break; -// case DNSLIB_RDATA_WF_BINARYWITHLENGTH: +// case KNOT_RDATA_WF_BINARYWITHLENGTH: // debug_knot_response("raw data size: %d\n", // rdata->items[i].raw_data[0] + 1); // size += rdata->items[i].raw_data[0] + 1; @@ -1256,7 +1256,7 @@ static int knot_response_realloc_rrsets(const knot_rrset_t ***rrsets, * \param compr_cs Set to <> 0 if dname compression should use case sensitive * comparation. Set to 0 otherwise. * - * \return Count of RRs added to the response or DNSLIB_ESPACE if the RRSet did + * \return Count of RRs added to the response or KNOT_ESPACE if the RRSet did * not fit in the available space. */ static int knot_response_try_add_rrset(const knot_rrset_t **rrsets, @@ -1268,7 +1268,7 @@ static int knot_response_try_add_rrset(const knot_rrset_t **rrsets, { //short size = knot_response_rrset_size(rrset, &resp->compression); -DEBUG_DNSLIB_RESPONSE( +DEBUG_KNOT_RESPONSE( char *name = knot_dname_to_str(rrset->owner); debug_knot_response("\nAdding RRSet with owner %s and type %s: \n", name, knot_rrtype_to_string(rrset->type)); @@ -1359,7 +1359,7 @@ knot_response_t *knot_response_new_empty(const knot_opt_rr_t *opt_rr) knot_response_t *resp = (knot_response_t *)malloc(PREALLOC_TOTAL); CHECK_ALLOC_LOG(resp, NULL); - if (knot_response_init(resp, opt_rr, DNSLIB_MAX_RESPONSE_SIZE) != 0) { + if (knot_response_init(resp, opt_rr, KNOT_MAX_RESPONSE_SIZE) != 0) { free(resp); return NULL; } @@ -1386,8 +1386,8 @@ knot_response_t *knot_response_new(size_t max_wire_size) void knot_response_clear(knot_response_t *resp, int clear_question) { - resp->size = (clear_question) ? DNSLIB_WIRE_HEADER_SIZE - : DNSLIB_WIRE_HEADER_SIZE + 4 + resp->size = (clear_question) ? KNOT_WIRE_HEADER_SIZE + : KNOT_WIRE_HEADER_SIZE + 4 + knot_dname_size(resp->question.qname); resp->an_rrsets = 0; resp->ns_rrsets = 0; @@ -1407,7 +1407,7 @@ int knot_response_add_opt(knot_response_t *resp, int override_max_size) { if (resp == NULL || opt_rr == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } // copy the OPT RR @@ -1421,7 +1421,7 @@ int knot_response_add_opt(knot_response_t *resp, if (override_max_size && resp->max_size > 0 && resp->max_size < opt_rr->payload) { - return DNSLIB_EPAYLOAD; + return KNOT_EPAYLOAD; } // if (resp->max_size < resp->edns_response.payload) { @@ -1430,7 +1430,7 @@ int knot_response_add_opt(knot_response_t *resp, // uint8_t *wire_new = (uint8_t *)malloc( // resp->edns_response.payload); // if (wire_new == NULL) { -// return DNSLIB_ENOMEM; +// return KNOT_ENOMEM; // } // memcpy(wire_new, resp->wireformat, resp->max_size); @@ -1442,7 +1442,7 @@ int knot_response_add_opt(knot_response_t *resp, resp->max_size = resp->edns_response.payload; } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1450,7 +1450,7 @@ int knot_response_add_opt(knot_response_t *resp, int knot_response_set_max_size(knot_response_t *resp, int max_size) { if (resp == NULL || max_size <= 0) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } if (resp->max_size < max_size) { @@ -1458,7 +1458,7 @@ int knot_response_set_max_size(knot_response_t *resp, int max_size) // that might have been there before uint8_t *wire_new = (uint8_t *)malloc(max_size); if (wire_new == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } memcpy(wire_new, resp->wireformat, resp->max_size); @@ -1468,7 +1468,7 @@ int knot_response_set_max_size(knot_response_t *resp, int max_size) // set max size resp->max_size = max_size; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1478,7 +1478,7 @@ int knot_response_parse_query(knot_response_t *resp, { if (resp == NULL || query_wire == NULL || resp->question.qname == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } int err = 0; @@ -1491,7 +1491,7 @@ int knot_response_parse_query(knot_response_t *resp, // header parsing is maybe useless, we may just copy the wire format if ((err = knot_response_parse_header( - &pos, &remaining, &resp->header)) != DNSLIB_EOK) { + &pos, &remaining, &resp->header)) != KNOT_EOK) { return err; } @@ -1499,17 +1499,17 @@ int knot_response_parse_query(knot_response_t *resp, debug_knot_response("Converted header, size so far: %d\n", size); if (pos == NULL) { - return DNSLIB_EMALF; + return KNOT_EMALF; } if ((err = knot_response_parse_question( - &pos, &remaining, &resp->question)) != DNSLIB_EOK) { + &pos, &remaining, &resp->question)) != KNOT_EOK) { return err; } resp->header.qdcount = 1; // put the qname into the compression table if ((err = knot_response_store_dname_pos(&resp->compression, - resp->question.qname, 0, size, size)) != DNSLIB_EOK) { + resp->question.qname, 0, size, size)) != KNOT_EOK) { return err; } @@ -1522,7 +1522,7 @@ int knot_response_parse_query(knot_response_t *resp, if (resp->header.arcount > 0) { // expecting EDNS OPT RR if ((err = knot_response_parse_client_edns( &pos, &remaining, &resp->edns_query))) { - return DNSLIB_EMALF; + return KNOT_EMALF; } if (knot_edns_get_payload(&resp->edns_query) && knot_edns_get_payload(&resp->edns_query) @@ -1551,10 +1551,10 @@ int knot_response_parse_query(knot_response_t *resp, debug_knot_response("response: %zu bytes of trailing garbage " "in query.\n", remaining); } -#ifdef DNSLIB_RESPONSE_DEBUG +#ifdef KNOT_RESPONSE_DEBUG knot_response_dump(resp); -#endif /* DNSLIB_RESPONSE_DEBUG */ - return DNSLIB_EOK; +#endif /* KNOT_RESPONSE_DEBUG */ + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1592,7 +1592,7 @@ int knot_response_add_rrset_answer(knot_response_t *response, int check_duplicates, int compr_cs) { if (response == NULL || rrset == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } debug_knot_response("add_rrset_answer()\n"); @@ -1602,12 +1602,12 @@ int knot_response_add_rrset_answer(knot_response_t *response, if (response->an_rrsets == response->max_an_rrsets && knot_response_realloc_rrsets(&response->answer, &response->max_an_rrsets, DEFAULT_ANCOUNT, STEP_ANCOUNT) - != DNSLIB_EOK) { - return DNSLIB_ENOMEM; + != KNOT_EOK) { + return KNOT_ENOMEM; } if (check_duplicates && knot_response_contains(response, rrset)) { - return DNSLIB_EOK; + return KNOT_EOK; } debug_knot_response("Trying to add RRSet to Answer section.\n"); @@ -1623,10 +1623,10 @@ int knot_response_add_rrset_answer(knot_response_t *response, if (rrs >= 0) { response->header.ancount += rrs; - return DNSLIB_EOK; + return KNOT_EOK; } - return DNSLIB_ESPACE; + return KNOT_ESPACE; } /*----------------------------------------------------------------------------*/ @@ -1636,7 +1636,7 @@ int knot_response_add_rrset_authority(knot_response_t *response, int check_duplicates, int compr_cs) { if (response == NULL || rrset == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } assert(response->header.arcount == 0); @@ -1645,11 +1645,11 @@ int knot_response_add_rrset_authority(knot_response_t *response, && knot_response_realloc_rrsets(&response->authority, &response->max_ns_rrsets, DEFAULT_NSCOUNT, STEP_NSCOUNT) != 0) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } if (check_duplicates && knot_response_contains(response, rrset)) { - return DNSLIB_EOK; + return KNOT_EOK; } debug_knot_response("Trying to add RRSet to Authority section.\n"); @@ -1663,10 +1663,10 @@ int knot_response_add_rrset_authority(knot_response_t *response, if (rrs >= 0) { response->header.nscount += rrs; - return DNSLIB_EOK; + return KNOT_EOK; } - return DNSLIB_ESPACE; + return KNOT_ESPACE; } /*----------------------------------------------------------------------------*/ @@ -1676,7 +1676,7 @@ int knot_response_add_rrset_additional(knot_response_t *response, int check_duplicates, int compr_cs) { if (response == NULL || rrset == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } // if this is the first additional RRSet, add EDNS OPT RR first @@ -1690,11 +1690,11 @@ int knot_response_add_rrset_additional(knot_response_t *response, && knot_response_realloc_rrsets(&response->additional, &response->max_ar_rrsets, DEFAULT_ARCOUNT, STEP_ARCOUNT) != 0) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } if (check_duplicates && knot_response_contains(response, rrset)) { - return DNSLIB_EOK; + return KNOT_EOK; } debug_knot_response("Trying to add RRSet to Additional section.\n"); @@ -1707,10 +1707,10 @@ int knot_response_add_rrset_additional(knot_response_t *response, if (rrs >= 0) { response->header.arcount += rrs; - return DNSLIB_EOK; + return KNOT_EOK; } - return DNSLIB_ESPACE; + return KNOT_ESPACE; } /*----------------------------------------------------------------------------*/ @@ -1745,13 +1745,13 @@ int knot_response_add_tmp_rrset(knot_response_t *response, if (response->tmp_rrsets_count == response->tmp_rrsets_max && knot_response_realloc_rrsets(&response->tmp_rrsets, &response->tmp_rrsets_max, DEFAULT_TMP_RRSETS, - STEP_TMP_RRSETS) != DNSLIB_EOK) { - return DNSLIB_ENOMEM; + STEP_TMP_RRSETS) != KNOT_EOK) { + return KNOT_ENOMEM; } response->tmp_rrsets[response->tmp_rrsets_count++] = tmp_rrset; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1841,7 +1841,7 @@ int knot_response_to_wire(knot_response_t *resp, { if (resp == NULL || resp_wire == NULL || resp_size == NULL || *resp_wire != NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } assert(resp->size <= resp->max_size); @@ -1864,7 +1864,7 @@ int knot_response_to_wire(knot_response_t *resp, *resp_wire = resp->wireformat; *resp_size = resp->size; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1893,7 +1893,7 @@ void knot_response_free(knot_response_t **response) } /*----------------------------------------------------------------------------*/ -#ifdef DNSLIB_RESPONSE_DEBUG +#ifdef KNOT_RESPONSE_DEBUG static void knot_response_dump_rrsets(const knot_rrset_t **rrsets, int count) { @@ -1916,15 +1916,15 @@ static void knot_response_dump_rrsets(const knot_rrset_t **rrsets, while (rdata != NULL) { for (int j = 0; j < rdata->count; ++j) { switch (desc->wireformat[j]) { - case DNSLIB_RDATA_WF_COMPRESSED_DNAME: - case DNSLIB_RDATA_WF_LITERAL_DNAME: - case DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME: + case KNOT_RDATA_WF_COMPRESSED_DNAME: + case KNOT_RDATA_WF_LITERAL_DNAME: + case KNOT_RDATA_WF_UNCOMPRESSED_DNAME: name = knot_dname_to_str( rdata->items[j].dname); debug_knot_response("%s \n",name); free(name); break; - case DNSLIB_RDATA_WF_BINARYWITHLENGTH: + case KNOT_RDATA_WF_BINARYWITHLENGTH: debug_knot_response_hex( (char *)rdata->items[j].raw_data, rdata->items[j].raw_data[0]); @@ -1945,7 +1945,7 @@ static void knot_response_dump_rrsets(const knot_rrset_t **rrsets, void knot_response_dump(const knot_response_t *resp) { -#ifdef DNSLIB_RESPONSE_DEBUG +#ifdef KNOT_RESPONSE_DEBUG debug_knot_response("DNS response:\n-----------------------------\n"); debug_knot_response("\nHeader:\n"); diff --git a/src/dnslib/response.h b/src/dnslib/response.h index 40493119cedd5ee9c0c20390d1941cba749f8ea5..cc2371f2d6401546827b66308b8e16b48ad3cdca 100644 --- a/src/dnslib/response.h +++ b/src/dnslib/response.h @@ -12,8 +12,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_RESPONSE_H_ -#define _KNOT_DNSLIB_RESPONSE_H_ +#ifndef _KNOTDKNOT_RESPONSE_H_ +#define _KNOTDKNOT_RESPONSE_H_ #include <stdint.h> #include <string.h> @@ -164,9 +164,9 @@ void knot_response_clear(knot_response_t *resp, int clear_question); * \param resp Response to set the OPT RR to. * \param opt_rr OPT RR to set. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_EBADARG + * \retval KNOT_ENOMEM * * \todo Needs test. */ @@ -190,9 +190,9 @@ int knot_response_add_opt(knot_response_t *resp, * \param resp Response to set the maximum size of. * \param max_size Maximum size of the response. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_EBADARG + * \retval KNOT_ENOMEM * * \todo Needs test. */ @@ -209,10 +209,10 @@ int knot_response_set_max_size(knot_response_t *resp, int max_size); * \param query_wire Query in wire format. * \param query_size Size of the query in bytes. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EMALF - * \retval DNSLIB_EFEWDATA - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_EMALF + * \retval KNOT_EFEWDATA + * \retval KNOT_ENOMEM */ int knot_response_parse_query(knot_response_t *response, const uint8_t *query_wire, size_t query_size); @@ -265,9 +265,9 @@ uint16_t knot_response_qclass(const knot_response_t *response); * \param compr_cs Set to <> 0 if dname compression should use case sensitive * comparation. Set to 0 otherwise. * - * \retval DNSLIB_EOK if successful, or the RRSet was already in the answer. - * \retval DNSLIB_ENOMEM - * \retval DNSLIB_ESPACE + * \retval KNOT_EOK if successful, or the RRSet was already in the answer. + * \retval KNOT_ENOMEM + * \retval KNOT_ESPACE */ int knot_response_add_rrset_answer(knot_response_t *response, const knot_rrset_t *rrset, int tc, @@ -285,9 +285,9 @@ int knot_response_add_rrset_answer(knot_response_t *response, * \param compr_cs Set to <> 0 if dname compression should use case sensitive * comparation. Set to 0 otherwise. * - * \retval DNSLIB_EOK if successful, or the RRSet was already in the answer. - * \retval DNSLIB_ENOMEM - * \retval DNSLIB_ESPACE + * \retval KNOT_EOK if successful, or the RRSet was already in the answer. + * \retval KNOT_ENOMEM + * \retval KNOT_ESPACE */ int knot_response_add_rrset_authority(knot_response_t *response, const knot_rrset_t *rrset, int tc, @@ -305,9 +305,9 @@ int knot_response_add_rrset_authority(knot_response_t *response, * \param compr_cs Set to <> 0 if dname compression should use case sensitive * comparation. Set to 0 otherwise. * - * \retval DNSLIB_EOK if successful, or the RRSet was already in the answer. - * \retval DNSLIB_ENOMEM - * \retval DNSLIB_ESPACE + * \retval KNOT_EOK if successful, or the RRSet was already in the answer. + * \retval KNOT_ENOMEM + * \retval KNOT_ESPACE */ int knot_response_add_rrset_additional(knot_response_t *response, const knot_rrset_t *rrset, int tc, @@ -343,8 +343,8 @@ void knot_response_set_tc(knot_response_t *response); * \param response Response to which the temporary RRSet should be added. * \param tmp_rrset Temporary RRSet to be stored in the response. * - * \retval DNSLIB_EOK - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_ENOMEM */ int knot_response_add_tmp_rrset(knot_response_t *response, knot_rrset_t *tmp_rrset); @@ -439,8 +439,8 @@ int knot_response_nsid_requested(const knot_response_t *response); * \param data NSID data. * \param length Size of NSID data in bytes. * - * \retval DNSLIB_EOK - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_ENOMEM */ int knot_response_add_nsid(knot_response_t *response, const uint8_t *data, uint16_t length); @@ -454,8 +454,8 @@ int knot_response_add_nsid(knot_response_t *response, const uint8_t *data, * be set to NULL (to avoid leaks). * \param resp_size The size of the response in wire format will be stored here. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG + * \retval KNOT_EOK + * \retval KNOT_EBADARG */ int knot_response_to_wire(knot_response_t *response, uint8_t **resp_wire, size_t *resp_size); @@ -470,12 +470,12 @@ void knot_response_free(knot_response_t **response); /*! * \brief Dumps the whole response in human-readable form. * - * \note This function is empty unless DNSLIB_RESPONSE_DEBUG is defined. + * \note This function is empty unless KNOT_RESPONSE_DEBUG is defined. * * \param resp Response to dump. */ void knot_response_dump(const knot_response_t *resp); -#endif /* _KNOT_DNSLIB_RESPONSE_H_ */ +#endif /* _KNOTDKNOT_RESPONSE_H_ */ /*! @} */ diff --git a/src/dnslib/response2.c b/src/dnslib/response2.c index 4e9dec5a739fcdad48a64263b2f7e8abcf981979..990c65b2a0296c3b5b7d451f72a9108a5deb55ab 100644 --- a/src/dnslib/response2.c +++ b/src/dnslib/response2.c @@ -44,7 +44,7 @@ struct knot_compr { typedef struct knot_compr knot_compr_t; -static const size_t DNSLIB_RESPONSE_MAX_PTR = 16383; +static const size_t KNOT_RESPONSE_MAX_PTR = 16383; /*----------------------------------------------------------------------------*/ /* Non-API functions */ @@ -54,8 +54,8 @@ static const size_t DNSLIB_RESPONSE_MAX_PTR = 16383; * * \param table Compression table to reallocate space for. * - * \retval DNSLIB_EOK - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_ENOMEM */ static int knot_response_realloc_compr(knot_compressed_dnames_t *table) { @@ -73,7 +73,7 @@ static int knot_response_realloc_compr(knot_compressed_dnames_t *table) if (new_dnames == NULL) { ERR_ALLOC_FAILED; free(new_offsets); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } memcpy(new_offsets, table->offsets, table->max * sizeof(size_t)); @@ -89,7 +89,7 @@ static int knot_response_realloc_compr(knot_compressed_dnames_t *table) free(old_dnames); } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -136,30 +136,30 @@ static void knot_response_compr_save(knot_compressed_dnames_t *table, * \param pos Position of the domain name in the wire format of the packet. * \param unmatched_offset Position of the unmatched parent domain of \a dname. * - * \retval DNSLIB_EOK - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_ENOMEM */ static int knot_response_store_dname_pos(knot_compressed_dnames_t *table, const knot_dname_t *dname, int not_matched, size_t pos, size_t unmatched_offset) { -DEBUG_DNSLIB_RESPONSE( +DEBUG_KNOT_RESPONSE( char *name = knot_dname_to_str(dname); debug_knot_response("Putting dname %s into compression table." " Labels not matched: %d, position: %d," ", pointer: %p\n", name, not_matched, pos, dname); free(name); ); - if (pos > DNSLIB_RESPONSE_MAX_PTR) { + if (pos > KNOT_RESPONSE_MAX_PTR) { debug_knot_response("Pointer larger than it can be, not" " saving\n"); - return DNSLIB_EDNAMEPTR; + return KNOT_EDNAMEPTR; } if (table->count == table->max && knot_response_realloc_compr(table) != 0) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } // store the position of the name @@ -191,7 +191,7 @@ DEBUG_DNSLIB_RESPONSE( parent_pos = unmatched_offset; } -DEBUG_DNSLIB_RESPONSE( +DEBUG_KNOT_RESPONSE( char *name = knot_dname_to_str(to_save); debug_knot_response("Putting dname %s into compression table." " Position: %d, pointer: %p\n", @@ -202,7 +202,7 @@ DEBUG_DNSLIB_RESPONSE( if (table->count == table->max && knot_response_realloc_compr(table) != 0) { debug_knot_response("Unable to realloc.\n"); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } // debug_knot_response("Saving..\n"); @@ -221,7 +221,7 @@ DEBUG_DNSLIB_RESPONSE( ++i; } - return DNSLIB_EOK; + return KNOT_EOK; } /*---------------------------------------------------------------------------*/ @@ -243,7 +243,7 @@ static size_t knot_response_find_dname_pos( for (int i = 0; i < table->count; ++i) { debug_knot_response("Comparing dnames %p and %p\n", dname, table->dnames[i]); -DEBUG_DNSLIB_RESPONSE( +DEBUG_KNOT_RESPONSE( char *name = knot_dname_to_str(dname); debug_knot_response("(%s and ", name); name = knot_dname_to_str(table->dnames[i]); @@ -278,7 +278,7 @@ DEBUG_DNSLIB_RESPONSE( * \param max Maximum available size of the place for the wire format. * * \return Size of the compressed domain name put into the wire format or - * DNSLIB_ESPACE if it did not fit. + * KNOT_ESPACE if it did not fit. */ static int knot_response_put_dname_ptr(const knot_dname_t *dname, int not_matched, size_t offset, @@ -287,7 +287,7 @@ static int knot_response_put_dname_ptr(const knot_dname_t *dname, // put the not matched labels short size = knot_dname_size_part(dname, not_matched); if (size + 2 > max) { - return DNSLIB_ESPACE; + return KNOT_ESPACE; } memcpy(wire, knot_dname_name(dname), size); @@ -308,7 +308,7 @@ static int knot_response_put_dname_ptr(const knot_dname_t *dname, * \param compr_cs Set to <> 0 if dname compression should use case sensitive * comparation. Set to 0 otherwise. * - * \return Size of the domain name's wire format or DNSLIB_ESPACE if it did not + * \return Size of the domain name's wire format or KNOT_ESPACE if it did not * fit into the provided space. */ static int knot_response_compress_dname(const knot_dname_t *dname, @@ -333,7 +333,7 @@ static int knot_response_compress_dname(const knot_dname_t *dname, int not_matched = 0; while (to_find != NULL && knot_dname_label_count(to_find) != 0) { -DEBUG_DNSLIB_RESPONSE( +DEBUG_KNOT_RESPONSE( char *name = knot_dname_to_str(to_find); debug_knot_response("Searching for name %s in the compression" " table, not matched labels: %d\n", name, @@ -392,17 +392,17 @@ DEBUG_DNSLIB_RESPONSE( if (offset > 0) { // found such dname somewhere in the packet debug_knot_response("Found name in the compression table.\n"); - assert(offset >= DNSLIB_WIRE_HEADER_SIZE); + assert(offset >= KNOT_WIRE_HEADER_SIZE); size = knot_response_put_dname_ptr(dname, not_matched, offset, dname_wire, max); if (size <= 0) { - return DNSLIB_ESPACE; + return KNOT_ESPACE; } } else { debug_knot_response("Not found, putting whole name.\n"); // now just copy the dname without compressing if (dname->size > max) { - return DNSLIB_ESPACE; + return KNOT_ESPACE; } memcpy(dname_wire, dname->name, dname->size); @@ -432,7 +432,7 @@ DEBUG_DNSLIB_RESPONSE( * \param[in] compr_cs Set to <> 0 if dname compression should use case * sensitive comparation. Set to 0 otherwise. * - * \return Size of the RR's wire format or DNSLIB_ESPACE if it did not fit into + * \return Size of the RR's wire format or KNOT_ESPACE if it did not fit into * the provided space. */ static int knot_response_rr_to_wire(const knot_rrset_t *rrset, @@ -445,7 +445,7 @@ static int knot_response_rr_to_wire(const knot_rrset_t *rrset, if (size + ((compr->owner.pos == 0) ? compr->owner.size : 2) + 10 > max_size) { - return DNSLIB_ESPACE; + return KNOT_ESPACE; } debug_knot_response("Owner position: %zu\n", compr->owner.pos); @@ -499,13 +499,13 @@ static int knot_response_rr_to_wire(const knot_rrset_t *rrset, for (int i = 0; i < rdata->count; ++i) { switch (desc->wireformat[i]) { - case DNSLIB_RDATA_WF_COMPRESSED_DNAME: { + case KNOT_RDATA_WF_COMPRESSED_DNAME: { int ret = knot_response_compress_dname( knot_rdata_item(rdata, i)->dname, compr, *rrset_wire, max_size - size, compr_cs); if (ret < 0) { - return DNSLIB_ESPACE; + return KNOT_ESPACE; } debug_knot_response("Compressed dname size: %d\n", @@ -516,12 +516,12 @@ static int knot_response_rr_to_wire(const knot_rrset_t *rrset, // TODO: compress domain name break; } - case DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME: - case DNSLIB_RDATA_WF_LITERAL_DNAME: { + case KNOT_RDATA_WF_UNCOMPRESSED_DNAME: + case KNOT_RDATA_WF_LITERAL_DNAME: { knot_dname_t *dname = knot_rdata_item(rdata, i)->dname; if (size + dname->size > max_size) { - return DNSLIB_ESPACE; + return KNOT_ESPACE; } // save whole domain name @@ -533,12 +533,12 @@ static int knot_response_rr_to_wire(const knot_rrset_t *rrset, compr->wire_pos += dname->size; break; } -// case DNSLIB_RDATA_WF_BINARYWITHLENGTH: { +// case KNOT_RDATA_WF_BINARYWITHLENGTH: { // uint16_t *raw_data = // knot_rdata_item(rdata, i)->raw_data; // if (size + raw_data[0] + 1 > max_size) { -// return DNSLIB_ESPACE; +// return KNOT_ESPACE; // } // // copy also the rdata item size @@ -558,7 +558,7 @@ static int knot_response_rr_to_wire(const knot_rrset_t *rrset, knot_rdata_item(rdata, i)->raw_data; if (size + raw_data[0] > max_size) { - return DNSLIB_ESPACE; + return KNOT_ESPACE; } // copy just the rdata item data (without size) @@ -594,7 +594,7 @@ static int knot_response_rr_to_wire(const knot_rrset_t *rrset, * \param compr_cs Set to <> 0 if dname compression should use case sensitive * comparation. Set to 0 otherwise. * - * \return Size of the RRSet's wire format or DNSLIB_ESPACE if it did not fit + * \return Size of the RRSet's wire format or KNOT_ESPACE if it did not fit * into the provided space. */ static int knot_response_rrset_to_wire(const knot_rrset_t *rrset, @@ -604,7 +604,7 @@ static int knot_response_rrset_to_wire(const knot_rrset_t *rrset, knot_compressed_dnames_t *compr, int compr_cs) { -DEBUG_DNSLIB_RESPONSE( +DEBUG_KNOT_RESPONSE( char *name = knot_dname_to_str(rrset->owner); debug_knot_response("Converting RRSet with owner %s, type %s\n", name, knot_rrtype_to_string(rrset->type)); @@ -614,7 +614,7 @@ DEBUG_DNSLIB_RESPONSE( // if no RDATA in RRSet, return if (rrset->rdata == NULL) { - return DNSLIB_EOK; + return KNOT_EOK; } //uint8_t *rrset_wire = (uint8_t *)malloc(PREALLOC_RRSET_WIRE); @@ -642,7 +642,7 @@ DEBUG_DNSLIB_RESPONSE( debug_knot_response(" Owner size: %d, position: %zu\n", compr_info.owner.size, compr_info.owner.pos); if (compr_info.owner.size < 0) { - return DNSLIB_ESPACE; + return KNOT_ESPACE; } int rrs = 0; @@ -660,7 +660,7 @@ DEBUG_DNSLIB_RESPONSE( // some RR didn't fit in, so no RRs should be used // TODO: remove last entries from compression table debug_knot_response("Some RR didn't fit in.\n"); - return DNSLIB_ESPACE; + return KNOT_ESPACE; } debug_knot_response("RR of size %d added.\n", ret); @@ -701,7 +701,7 @@ DEBUG_DNSLIB_RESPONSE( * \param compr_cs Set to <> 0 if dname compression should use case sensitive * comparation. Set to 0 otherwise. * - * \return Count of RRs added to the response or DNSLIB_ESPACE if the RRSet did + * \return Count of RRs added to the response or KNOT_ESPACE if the RRSet did * not fit in the available space. */ static int knot_response_try_add_rrset(const knot_rrset_t **rrsets, @@ -713,7 +713,7 @@ static int knot_response_try_add_rrset(const knot_rrset_t **rrsets, { //short size = knot_response_rrset_size(rrset, &resp->compression); -DEBUG_DNSLIB_RESPONSE( +DEBUG_KNOT_RESPONSE( char *name = knot_dname_to_str(rrset->owner); debug_knot_response("\nAdding RRSet with owner %s and type %s: \n", name, knot_rrtype_to_string(rrset->type)); @@ -749,8 +749,8 @@ DEBUG_DNSLIB_RESPONSE( * the response structure was initialized. * \param step How much the space should be increased. * - * \retval DNSLIB_EOK - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_ENOMEM */ static int knot_response_realloc_rrsets(const knot_rrset_t ***rrsets, short *max_count, @@ -762,7 +762,7 @@ static int knot_response_realloc_rrsets(const knot_rrset_t ***rrsets, short new_max_count = *max_count + step; const knot_rrset_t **new_rrsets = (const knot_rrset_t **)malloc( new_max_count * sizeof(knot_rrset_t *)); - CHECK_ALLOC_LOG(new_rrsets, DNSLIB_ENOMEM); + CHECK_ALLOC_LOG(new_rrsets, KNOT_ENOMEM); memcpy(new_rrsets, *rrsets, (*max_count) * sizeof(knot_rrset_t *)); @@ -773,7 +773,7 @@ static int knot_response_realloc_rrsets(const knot_rrset_t ***rrsets, free(old); } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -783,11 +783,11 @@ static int knot_response_realloc_rrsets(const knot_rrset_t ***rrsets, int knot_response2_init(knot_packet_t *response) { if (response == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } - if (response->max_size < DNSLIB_WIRE_HEADER_SIZE) { - return DNSLIB_ESPACE; + if (response->max_size < KNOT_WIRE_HEADER_SIZE) { + return KNOT_ESPACE; } // set the qr bit to 1 @@ -797,7 +797,7 @@ int knot_response2_init(knot_packet_t *response) knot_packet_header_to_wire(&response->header, &pos, &response->size); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -806,7 +806,7 @@ int knot_response2_init_from_query(knot_packet_t *response, knot_packet_t *query) { if (response == NULL || query == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } // copy the header from the query @@ -820,7 +820,7 @@ int knot_response2_init_from_query(knot_packet_t *response, // put the qname into the compression table // TODO: get rid of the numeric constants if ((err = knot_response_store_dname_pos(&response->compression, - response->question.qname, 0, 12, 12)) != DNSLIB_EOK) { + response->question.qname, 0, 12, 12)) != KNOT_EOK) { return err; } @@ -843,7 +843,7 @@ int knot_response2_init_from_query(knot_packet_t *response, response->query = query; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -854,8 +854,8 @@ void knot_response2_clear(knot_packet_t *resp, int clear_question) return; } - resp->size = (clear_question) ? DNSLIB_WIRE_HEADER_SIZE - : DNSLIB_WIRE_HEADER_SIZE + 4 + resp->size = (clear_question) ? KNOT_WIRE_HEADER_SIZE + : KNOT_WIRE_HEADER_SIZE + 4 + knot_dname_size(resp->question.qname); resp->an_rrsets = 0; resp->ns_rrsets = 0; @@ -875,7 +875,7 @@ int knot_response2_add_opt(knot_packet_t *resp, int override_max_size) { if (resp == NULL || opt_rr == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } // copy the OPT RR @@ -889,7 +889,7 @@ int knot_response2_add_opt(knot_packet_t *resp, if (override_max_size && resp->max_size > 0 && resp->max_size < opt_rr->payload) { - return DNSLIB_EPAYLOAD; + return KNOT_EPAYLOAD; } // set max size (less is OK) @@ -898,7 +898,7 @@ int knot_response2_add_opt(knot_packet_t *resp, //resp->max_size = resp->opt_rr.payload; } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -908,7 +908,7 @@ int knot_response2_add_rrset_answer(knot_packet_t *response, int check_duplicates, int compr_cs) { if (response == NULL || rrset == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } debug_knot_response("add_rrset_answer()\n"); @@ -918,13 +918,13 @@ int knot_response2_add_rrset_answer(knot_packet_t *response, if (response->an_rrsets == response->max_an_rrsets && knot_response_realloc_rrsets(&response->answer, &response->max_an_rrsets, DEFAULT_ANCOUNT, STEP_ANCOUNT) - != DNSLIB_EOK) { - return DNSLIB_ENOMEM; + != KNOT_EOK) { + return KNOT_ENOMEM; } if (check_duplicates && knot_packet_contains(response, rrset, - DNSLIB_RRSET_COMPARE_PTR)) { - return DNSLIB_EOK; + KNOT_RRSET_COMPARE_PTR)) { + return KNOT_EOK; } debug_knot_response("Trying to add RRSet to Answer section.\n"); @@ -940,10 +940,10 @@ int knot_response2_add_rrset_answer(knot_packet_t *response, if (rrs >= 0) { response->header.ancount += rrs; - return DNSLIB_EOK; + return KNOT_EOK; } - return DNSLIB_ESPACE; + return KNOT_ESPACE; } /*----------------------------------------------------------------------------*/ @@ -953,7 +953,7 @@ int knot_response2_add_rrset_authority(knot_packet_t *response, int check_duplicates, int compr_cs) { if (response == NULL || rrset == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } assert(response->header.arcount == 0); @@ -962,12 +962,12 @@ int knot_response2_add_rrset_authority(knot_packet_t *response, && knot_response_realloc_rrsets(&response->authority, &response->max_ns_rrsets, DEFAULT_NSCOUNT, STEP_NSCOUNT) != 0) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } if (check_duplicates && knot_packet_contains(response, rrset, - DNSLIB_RRSET_COMPARE_PTR)) { - return DNSLIB_EOK; + KNOT_RRSET_COMPARE_PTR)) { + return KNOT_EOK; } debug_knot_response("Trying to add RRSet to Authority section.\n"); @@ -981,10 +981,10 @@ int knot_response2_add_rrset_authority(knot_packet_t *response, if (rrs >= 0) { response->header.nscount += rrs; - return DNSLIB_EOK; + return KNOT_EOK; } - return DNSLIB_ESPACE; + return KNOT_ESPACE; } /*----------------------------------------------------------------------------*/ @@ -994,7 +994,7 @@ int knot_response2_add_rrset_additional(knot_packet_t *response, int check_duplicates, int compr_cs) { if (response == NULL || rrset == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } int ret; @@ -1002,7 +1002,7 @@ int knot_response2_add_rrset_additional(knot_packet_t *response, // if this is the first additional RRSet, add EDNS OPT RR first if (response->header.arcount == 0 && response->opt_rr.version != EDNS_NOT_SUPPORTED - && (ret = knot_packet_edns_to_wire(response)) != DNSLIB_EOK) { + && (ret = knot_packet_edns_to_wire(response)) != KNOT_EOK) { return ret; } @@ -1010,12 +1010,12 @@ int knot_response2_add_rrset_additional(knot_packet_t *response, && knot_response_realloc_rrsets(&response->additional, &response->max_ar_rrsets, DEFAULT_ARCOUNT, STEP_ARCOUNT) != 0) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } if (check_duplicates && knot_packet_contains(response, rrset, - DNSLIB_RRSET_COMPARE_PTR)) { - return DNSLIB_EOK; + KNOT_RRSET_COMPARE_PTR)) { + return KNOT_EOK; } debug_knot_response("Trying to add RRSet to Additional section.\n"); @@ -1028,10 +1028,10 @@ int knot_response2_add_rrset_additional(knot_packet_t *response, if (rrs >= 0) { response->header.arcount += rrs; - return DNSLIB_EOK; + return KNOT_EOK; } - return DNSLIB_ESPACE; + return KNOT_ESPACE; } /*----------------------------------------------------------------------------*/ @@ -1076,7 +1076,7 @@ int knot_response2_add_nsid(knot_packet_t *response, const uint8_t *data, uint16_t length) { if (response == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } return knot_edns_add_option(&response->opt_rr, diff --git a/src/dnslib/response2.h b/src/dnslib/response2.h index c10a4ae664c9189ac12027d42b744c20fd2bd287..f35791c7e28a1614af70b126819f5df41d5f5e2a 100644 --- a/src/dnslib/response2.h +++ b/src/dnslib/response2.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_RESPONSE2_H_ -#define _KNOT_DNSLIB_RESPONSE2_H_ +#ifndef _KNOTDKNOT_RESPONSE2_H_ +#define _KNOTDKNOT_RESPONSE2_H_ #include <stdint.h> #include <string.h> @@ -26,7 +26,7 @@ * * This size must be supported by all servers and clients. */ -static const short DNSLIB_MAX_RESPONSE_SIZE = 512; +static const short KNOT_MAX_RESPONSE_SIZE = 512; /*----------------------------------------------------------------------------*/ int knot_response2_init(knot_packet_t *response); @@ -44,7 +44,7 @@ int knot_response2_init(knot_packet_t *response); * \param response Packet structure representing the response. * \param query Packet structure representing the query. * - * \retval DNSLIB_EOK + * \retval KNOT_EOK */ int knot_response2_init_from_query(knot_packet_t *response, knot_packet_t *query); @@ -73,9 +73,9 @@ void knot_response2_clear(knot_packet_t *resp, int clear_question); * \param resp Response to set the OPT RR to. * \param opt_rr OPT RR to set. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_EBADARG + * \retval KNOT_ENOMEM * * \todo Needs test. */ @@ -95,9 +95,9 @@ int knot_response2_add_opt(knot_packet_t *resp, * \param compr_cs Set to <> 0 if dname compression should use case sensitive * comparation. Set to 0 otherwise. * - * \retval DNSLIB_EOK if successful, or the RRSet was already in the answer. - * \retval DNSLIB_ENOMEM - * \retval DNSLIB_ESPACE + * \retval KNOT_EOK if successful, or the RRSet was already in the answer. + * \retval KNOT_ENOMEM + * \retval KNOT_ESPACE */ int knot_response2_add_rrset_answer(knot_packet_t *response, const knot_rrset_t *rrset, int tc, @@ -115,9 +115,9 @@ int knot_response2_add_rrset_answer(knot_packet_t *response, * \param compr_cs Set to <> 0 if dname compression should use case sensitive * comparation. Set to 0 otherwise. * - * \retval DNSLIB_EOK if successful, or the RRSet was already in the answer. - * \retval DNSLIB_ENOMEM - * \retval DNSLIB_ESPACE + * \retval KNOT_EOK if successful, or the RRSet was already in the answer. + * \retval KNOT_ENOMEM + * \retval KNOT_ESPACE */ int knot_response2_add_rrset_authority(knot_packet_t *response, const knot_rrset_t *rrset, int tc, @@ -135,9 +135,9 @@ int knot_response2_add_rrset_authority(knot_packet_t *response, * \param compr_cs Set to <> 0 if dname compression should use case sensitive * comparation. Set to 0 otherwise. * - * \retval DNSLIB_EOK if successful, or the RRSet was already in the answer. - * \retval DNSLIB_ENOMEM - * \retval DNSLIB_ESPACE + * \retval KNOT_EOK if successful, or the RRSet was already in the answer. + * \retval KNOT_ENOMEM + * \retval KNOT_ESPACE */ int knot_response2_add_rrset_additional(knot_packet_t *response, const knot_rrset_t *rrset, int tc, @@ -172,12 +172,12 @@ void knot_response2_set_tc(knot_packet_t *response); * \param data NSID data. * \param length Size of NSID data in bytes. * - * \retval DNSLIB_EOK - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_ENOMEM */ int knot_response2_add_nsid(knot_packet_t *response, const uint8_t *data, uint16_t length); -#endif /* _KNOT_DNSLIB_RESPONSE2_H_ */ +#endif /* _KNOTDKNOT_RESPONSE2_H_ */ /*! @} */ diff --git a/src/dnslib/rrset.c b/src/dnslib/rrset.c index 2bf9523d054179259fe2daab9e6781b139768486..3db06fbc5e4ce9eb0db0674db396bbc58dc9b910 100644 --- a/src/dnslib/rrset.c +++ b/src/dnslib/rrset.c @@ -71,7 +71,7 @@ knot_rrset_t *knot_rrset_new(knot_dname_t *owner, uint16_t type, int knot_rrset_add_rdata(knot_rrset_t *rrset, knot_rdata_t *rdata) { if (rrset == NULL || rdata == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } if (rrset->rdata == NULL) { @@ -88,7 +88,7 @@ int knot_rrset_add_rdata(knot_rrset_t *rrset, knot_rdata_t *rdata) rdata->next = tmp->next; tmp->next = rdata; } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -127,11 +127,11 @@ knot_rdata_t *knot_rrset_remove_rdata(knot_rrset_t *rrset, int knot_rrset_set_rrsigs(knot_rrset_t *rrset, knot_rrset_t *rrsigs) { if (rrset == NULL || rrsigs == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } rrset->rrsigs = rrsigs; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -141,29 +141,29 @@ int knot_rrset_add_rrsigs(knot_rrset_t *rrset, knot_rrset_t *rrsigs, { if (rrset == NULL || rrsigs == NULL || knot_dname_compare(rrset->owner, rrsigs->owner) != 0) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } int rc; if (rrset->rrsigs != NULL) { - if (dupl == DNSLIB_RRSET_DUPL_MERGE) { + if (dupl == KNOT_RRSET_DUPL_MERGE) { rc = knot_rrset_merge((void **)&rrset->rrsigs, (void **)&rrsigs); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { return rc; } else { return 1; } - } else if (dupl == DNSLIB_RRSET_DUPL_SKIP) { + } else if (dupl == KNOT_RRSET_DUPL_SKIP) { return 2; - } else if (dupl == DNSLIB_RRSET_DUPL_REPLACE) { + } else if (dupl == KNOT_RRSET_DUPL_REPLACE) { rrset->rrsigs = rrsigs; } } else { rrset->rrsigs = rrsigs; } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -283,7 +283,7 @@ int knot_rrset_compare(const knot_rrset_t *r1, const knot_rrset_t *r2, knot_rrset_compare_type_t cmp) { - if (cmp == DNSLIB_RRSET_COMPARE_PTR) { + if (cmp == KNOT_RRSET_COMPARE_PTR) { return (r1 == r2); } @@ -292,7 +292,7 @@ int knot_rrset_compare(const knot_rrset_t *r1, && (r1->ttl == r2->ttl) && knot_dname_compare(r1->owner, r2->owner) == 0); - if (cmp == DNSLIB_RRSET_COMPARE_WHOLE && res) { + if (cmp == KNOT_RRSET_COMPARE_WHOLE && res) { knot_rrtype_descriptor_t *desc = knot_rrtype_descriptor_by_type(r1->type); @@ -312,11 +312,11 @@ int knot_rrset_compare(const knot_rrset_t *r1, int knot_rrset_shallow_copy(const knot_rrset_t *from, knot_rrset_t **to) { *to = (knot_rrset_t *)malloc(sizeof(knot_rrset_t)); - CHECK_ALLOC_LOG(*to, DNSLIB_ENOMEM); + CHECK_ALLOC_LOG(*to, KNOT_ENOMEM); memcpy(*to, from, sizeof(knot_rrset_t)); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -387,7 +387,7 @@ int knot_rrset_merge(void **r1, void **r2) || rrset1->rclass != rrset2->rclass || rrset1->type != rrset2->type || rrset1->ttl != rrset2->ttl) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } // add all RDATAs from rrset2 to rrset1 (i.e. concatenate linked lists) @@ -396,13 +396,13 @@ int knot_rrset_merge(void **r1, void **r2) assert(rrset1 && rrset2); if (rrset1->rdata == NULL) { rrset1->rdata = rrset2->rdata; - return DNSLIB_EOK; + return KNOT_EOK; } knot_rdata_t *tmp_rdata = rrset1->rdata; if (!tmp_rdata) { - return DNSLIB_EOK; + return KNOT_EOK; } while (tmp_rdata->next != rrset1->rdata) { @@ -419,5 +419,5 @@ int knot_rrset_merge(void **r1, void **r2) tmp_rdata->next = rrset1->rdata; - return DNSLIB_EOK; + return KNOT_EOK; } diff --git a/src/dnslib/rrset.h b/src/dnslib/rrset.h index 77b381861b28178bb526de640e57ccc47caa6d76..4f50341d421dbac0f34b0639f669fb07ba01c1a1 100644 --- a/src/dnslib/rrset.h +++ b/src/dnslib/rrset.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_RRSET_H_ -#define _KNOT_DNSLIB_RRSET_H_ +#ifndef _KNOTDKNOT_RRSET_H_ +#define _KNOTDKNOT_RRSET_H_ #include <stdint.h> @@ -49,15 +49,15 @@ typedef struct knot_rrset knot_rrset_t; /*----------------------------------------------------------------------------*/ typedef enum { - DNSLIB_RRSET_COMPARE_PTR, - DNSLIB_RRSET_COMPARE_HEADER, - DNSLIB_RRSET_COMPARE_WHOLE + KNOT_RRSET_COMPARE_PTR, + KNOT_RRSET_COMPARE_HEADER, + KNOT_RRSET_COMPARE_WHOLE } knot_rrset_compare_type_t; typedef enum { - DNSLIB_RRSET_DUPL_MERGE, - DNSLIB_RRSET_DUPL_REPLACE, - DNSLIB_RRSET_DUPL_SKIP + KNOT_RRSET_DUPL_MERGE, + KNOT_RRSET_DUPL_REPLACE, + KNOT_RRSET_DUPL_SKIP } knot_rrset_dupl_handling_t; /*----------------------------------------------------------------------------*/ @@ -83,8 +83,8 @@ knot_rrset_t *knot_rrset_new(knot_dname_t *owner, uint16_t type, * \param rrset RRSet to add the RDATA to. * \param rdata RDATA to add to the RRSet. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG + * \retval KNOT_EOK + * \retval KNOT_EBADARG * * \todo Provide some function for comparing RDATAs. */ @@ -99,8 +99,8 @@ knot_rdata_t * knot_rrset_remove_rdata(knot_rrset_t *rrset, * \param rrset RRSet to add the signatures into. * \param rrsigs Set of RRSIGs covering this RRSet. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG + * \retval KNOT_EOK + * \retval KNOT_EBADARG */ int knot_rrset_set_rrsigs(knot_rrset_t *rrset, knot_rrset_t *rrsigs); @@ -256,12 +256,12 @@ void knot_rrset_deep_free(knot_rrset_t **rrset, int free_owner, * \param r1 Pointer to RRSet to be merged into. * \param r2 Poitner to RRSet to be merged. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG if the RRSets could not be merged, because their + * \retval KNOT_EOK + * \retval KNOT_EBADARG if the RRSets could not be merged, because their * Owner, Type, Class or TTL does not match. */ int knot_rrset_merge(void **r1, void **r2); -#endif /* _KNOT_DNSLIB_RRSET_H_ */ +#endif /* _KNOTDKNOT_RRSET_H_ */ /*! @} */ diff --git a/src/dnslib/tests/dnslib/cuckoo_tests.h b/src/dnslib/tests/dnslib/cuckoo_tests.h index 56400ba164f74b3580fd37f263f22163c7b8043b..48af8b640c4a344e9179ed7fc93b1f42ab8c45dc 100644 --- a/src/dnslib/tests/dnslib/cuckoo_tests.h +++ b/src/dnslib/tests/dnslib/cuckoo_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_CUCKOO_TESTS_H_ -#define _KNOT_CUCKOO_TESTS_H_ +#ifndef _KNOTDCUCKOO_TESTS_H_ +#define _KNOTDCUCKOO_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api cuckoo_tests_api; -#endif /* _KNOT_CUCKOO_TESTS_H_ */ +#endif /* _KNOTDCUCKOO_TESTS_H_ */ diff --git a/src/dnslib/tests/dnslib/dname_table_tests.c b/src/dnslib/tests/dnslib/dname_table_tests.c index 04020d4c457f293894efbc5953c0bd700589ef47..7bf4e80d9ad2b75cfb1e85a7e2d2c05da61231fc 100644 --- a/src/dnslib/tests/dnslib/dname_table_tests.c +++ b/src/dnslib/tests/dnslib/dname_table_tests.c @@ -84,25 +84,25 @@ static int test_dname_table_adding() CHECK_ALLOC(table, 0); /* Add NULL */ - if (knot_dname_table_add_dname(table, NULL) != DNSLIB_EBADARG) { + if (knot_dname_table_add_dname(table, NULL) != KNOT_EBADARG) { diag("Adding NULL dname did not result in an error!"); errors++; } /* Add to NULL table*/ - if (knot_dname_table_add_dname(NULL, NULL) != DNSLIB_EBADARG) { + if (knot_dname_table_add_dname(NULL, NULL) != KNOT_EBADARG) { diag("Adding to NULL table did not result in an error!"); errors++; } /* Add NULL */ - if (knot_dname_table_add_dname2(table, NULL) != DNSLIB_EBADARG) { + if (knot_dname_table_add_dname2(table, NULL) != KNOT_EBADARG) { diag("Adding NULL dname did not result in an error!"); errors++; } /* Add to NULL table*/ - if (knot_dname_table_add_dname2(NULL, NULL) != DNSLIB_EBADARG) { + if (knot_dname_table_add_dname2(NULL, NULL) != KNOT_EBADARG) { diag("Adding to NULL table did not result in an error!"); errors++; } @@ -117,7 +117,7 @@ static int test_dname_table_adding() errors++; continue; } - if (knot_dname_table_add_dname(table, dname) != DNSLIB_EOK) { + if (knot_dname_table_add_dname(table, dname) != KNOT_EOK) { diag("Could not add dname! (%s)", DNAME_TABLE_DNAMES[i].str); errors++; @@ -175,7 +175,7 @@ static int test_dname_table_adding() if (knot_dname_table_add_dname(table, dname_from_test_dname_str(&DNAME_TABLE_DNAMES[0])) != - DNSLIB_EOK) { + KNOT_EOK) { diag("Could not add dname to table once it's already there!"); /* Next test would not make sense. */ knot_dname_table_deep_free(&table); @@ -223,7 +223,7 @@ static int test_dname_table_adding() dname_from_test_dname_str(&DNAME_TABLE_DNAMES[0]); assert(tmp_dname); - if (knot_dname_table_add_dname2(table, &tmp_dname) != DNSLIB_EOK) { + if (knot_dname_table_add_dname2(table, &tmp_dname) != KNOT_EOK) { diag("Could not add dname using dname_table_add_dname2!"); knot_dname_table_deep_free(&table); knot_dname_free(&tmp_dname); @@ -288,7 +288,7 @@ static int test_dname_table_find() errors++; continue; } - if (knot_dname_table_add_dname(table, dname) != DNSLIB_EOK) { + if (knot_dname_table_add_dname(table, dname) != KNOT_EOK) { diag("Could not add dname! (%s)", DNAME_TABLE_DNAMES[i].str); errors++; @@ -340,14 +340,14 @@ static int test_dname_table_find() return (errors == 0); } -static const int DNSLIB_DNAME_TABLE_TEST_COUNT = 3; +static const int KNOT_DNAME_TABLE_TEST_COUNT = 3; /*! This helper routine should report number of * scheduled tests for given parameters. */ static int knot_dname_table_tests_count(int argc, char *argv[]) { - return DNSLIB_DNAME_TABLE_TEST_COUNT; + return KNOT_DNAME_TABLE_TEST_COUNT; } /*! Run all scheduled tests for given parameters. diff --git a/src/dnslib/tests/dnslib/dname_table_tests.h b/src/dnslib/tests/dnslib/dname_table_tests.h index 52ae3998c7c03db886b2ecc339ad10a28bf044d9..99c42c1b27a74601fb6fdf2bba7f7b9b31cd07ca 100644 --- a/src/dnslib/tests/dnslib/dname_table_tests.h +++ b/src/dnslib/tests/dnslib/dname_table_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_DNAME_TABLE_TESTS_H_ -#define _KNOT_DNAME_TABLE_TESTS_H_ +#ifndef _KNOTDDNAME_TABLE_TESTS_H_ +#define _KNOTDDNAME_TABLE_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api dname_table_tests_api; -#endif /* _KNOT_DNAME_TABLE_TESTS_H_ */ +#endif /* _KNOTDDNAME_TABLE_TESTS_H_ */ diff --git a/src/dnslib/tests/dnslib/dname_tests.c b/src/dnslib/tests/dnslib/dname_tests.c index 5ccf0716c8de70041f4b91035d0adcbaa1c1685a..ce9a56e37ea59cf60f8aca35f6afe6e81d683fd9 100644 --- a/src/dnslib/tests/dnslib/dname_tests.c +++ b/src/dnslib/tests/dnslib/dname_tests.c @@ -762,14 +762,14 @@ static int test_dname_getters(uint type) return (errors == 0); } -static const int DNSLIB_DNAME_TEST_COUNT = 15; +static const int KNOT_DNAME_TEST_COUNT = 15; /*! This helper routine should report number of * scheduled tests for given parameters. */ static int knot_dname_tests_count(int argc, char *argv[]) { - return DNSLIB_DNAME_TEST_COUNT; + return KNOT_DNAME_TEST_COUNT; } /*! Run all scheduled tests for given parameters. diff --git a/src/dnslib/tests/dnslib/dname_tests.h b/src/dnslib/tests/dnslib/dname_tests.h index 6f1281792808279b20ac7c082ebc447db30e015d..d1dc923f8cace941bd1364dbcc38fa782f4b6e68 100644 --- a/src/dnslib/tests/dnslib/dname_tests.h +++ b/src/dnslib/tests/dnslib/dname_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_DNAME_TESTS_H_ -#define _KNOT_DNAME_TESTS_H_ +#ifndef _KNOTDDNAME_TESTS_H_ +#define _KNOTDDNAME_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api dname_tests_api; -#endif /* _KNOT_DNAME_TESTS_H_ */ +#endif /* _KNOTDDNAME_TESTS_H_ */ diff --git a/src/dnslib/tests/dnslib/edns_tests.c b/src/dnslib/tests/dnslib/edns_tests.c index 04bca1619819904a6ca2dcedbb9e118bfdc2919e..8935fd42983a0243d1d003a4908463a907df42c1 100644 --- a/src/dnslib/tests/dnslib/edns_tests.c +++ b/src/dnslib/tests/dnslib/edns_tests.c @@ -51,7 +51,7 @@ test_edns_t test_edns_data[TEST_EDNS] = { }; enum edns_mask { - DNSLIB_EDNS_DO_MASK = (uint16_t)0x8000 + KNOT_EDNS_DO_MASK = (uint16_t)0x8000 }; /* Creates actual knot_opt_rr_t variable from test_edns_t variable */ @@ -186,7 +186,7 @@ static int test_edns_do(const knot_opt_rr_t *edns, test_edns_t *test_edns) { if (knot_edns_do(edns) != - (test_edns->flags & DNSLIB_EDNS_DO_MASK)) { + (test_edns->flags & KNOT_EDNS_DO_MASK)) { return 0; } else { return 1; @@ -507,14 +507,14 @@ static int test_edns_has_option() return 1; } -static const int DNSLIB_EDNS_TESTS_COUNT = 12; +static const int KNOT_EDNS_TESTS_COUNT = 12; /*! This helper routine should report number of * scheduled tests for given parameters. */ static int knot_edns_tests_count(int argc, char *argv[]) { - return DNSLIB_EDNS_TESTS_COUNT; + return KNOT_EDNS_TESTS_COUNT; } /*! Run all scheduled tests for given parameters. diff --git a/src/dnslib/tests/dnslib/edns_tests.h b/src/dnslib/tests/dnslib/edns_tests.h index 09aa74ec21b2e635ad065cb3bfe6df57217b4610..95519be101bde07c0dddab46b7e5fb6bc41f7f3b 100644 --- a/src/dnslib/tests/dnslib/edns_tests.h +++ b/src/dnslib/tests/dnslib/edns_tests.h @@ -8,12 +8,12 @@ * Contains tests for: * - ENDS API */ -#ifndef _KNOT_EDNS_TESTS_H_ -#define _KNOT_EDNS_TESTS_H_ +#ifndef _KNOTDEDNS_TESTS_H_ +#define _KNOTDEDNS_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api edns_tests_api; -#endif /* _KNOT_EDNS_TESTS_H_ */ +#endif /* _KNOTDEDNS_TESTS_H_ */ diff --git a/src/dnslib/tests/dnslib/node_tests.c b/src/dnslib/tests/dnslib/node_tests.c index d87d17046518562a962384eeab672f02f1ba3912..b4671cc7f285ab30076a1b20548449d4ce9401a9 100644 --- a/src/dnslib/tests/dnslib/node_tests.c +++ b/src/dnslib/tests/dnslib/node_tests.c @@ -278,14 +278,14 @@ static int test_node_free_rrsets() return (errors == 0); } -static const int DNSLIB_NODE_TEST_COUNT = 8; +static const int KNOT_NODE_TEST_COUNT = 8; /*! This helper routine should report number of * scheduled tests for given parameters. */ static int knot_node_tests_count(int argc, char *argv[]) { - return DNSLIB_NODE_TEST_COUNT; + return KNOT_NODE_TEST_COUNT; } /*! Run all scheduled tests for given parameters. diff --git a/src/dnslib/tests/dnslib/node_tests.h b/src/dnslib/tests/dnslib/node_tests.h index eebaf6934b8c040a8740111b92561f45c4b09b95..fca5ed7d19f4ac461bb52ec8493bf7b7f44d8f53 100644 --- a/src/dnslib/tests/dnslib/node_tests.h +++ b/src/dnslib/tests/dnslib/node_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_NODE_TESTS_H_ -#define _KNOT_NODE_TESTS_H_ +#ifndef _KNOTDNODE_TESTS_H_ +#define _KNOTDNODE_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api node_tests_api; -#endif /* _KNOT_NODE_TESTS_H_ */ +#endif /* _KNOTDNODE_TESTS_H_ */ diff --git a/src/dnslib/tests/dnslib/nsec3_tests.c b/src/dnslib/tests/dnslib/nsec3_tests.c index 582dab751e3183d2c9f69c28cf8e07f995ae981c..c429836f33ad3940636331cb7579b914343d7a84 100644 --- a/src/dnslib/tests/dnslib/nsec3_tests.c +++ b/src/dnslib/tests/dnslib/nsec3_tests.c @@ -44,11 +44,11 @@ static int test_nsec3_params_from_wire() knot_rrset_t *rrset = knot_rrset_new(knot_dname_new_from_str("cz.", strlen("cz."), NULL), - DNSLIB_RRTYPE_NSEC3PARAM, - DNSLIB_CLASS_IN, + KNOT_RRTYPE_NSEC3PARAM, + KNOT_CLASS_IN, 3600); assert(rrset); - assert(knot_rrset_add_rdata(rrset, rdata) == DNSLIB_EOK); + assert(knot_rrset_add_rdata(rrset, rdata) == KNOT_EOK); knot_nsec3_params_t nsec3_tests_params; UNUSED(nsec3_tests_params); @@ -57,21 +57,21 @@ static int test_nsec3_params_from_wire() int lived = 0; lives_ok({ if (knot_nsec3_params_from_wire(NULL, NULL) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { errors++; } lived = 1; lived = 0; if (knot_nsec3_params_from_wire(&nsec3_test_params, NULL) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { errors++; } lived = 1; lived = 0; if (knot_nsec3_params_from_wire(NULL, rrset) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { errors++; } lived = 1; @@ -80,7 +80,7 @@ static int test_nsec3_params_from_wire() errors += lived != 1; if (knot_nsec3_params_from_wire(&nsec3_test_params, -rrset) != DNSLIB_EOK) { +rrset) != KNOT_EOK) { diag("Could not convert nsec3 params to wire!"); return 0; } @@ -123,14 +123,14 @@ static int test_nsec3_sha1() lives_ok({ if (knot_nsec3_sha1(NULL, NULL, 1, NULL, NULL) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { errors++; } lived = 1; lived = 0; if (knot_nsec3_sha1(&nsec3_test_params, NULL, 1, NULL, NULL) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { errors++; } uint8_t data[20]; @@ -138,7 +138,7 @@ static int test_nsec3_sha1() lived = 0; if (knot_nsec3_sha1(&nsec3_test_params, data, 20, NULL, NULL) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { errors++; } uint8_t *digest = NULL; @@ -146,7 +146,7 @@ static int test_nsec3_sha1() lived = 0; if (knot_nsec3_sha1(&nsec3_test_params, data, 20, &digest, NULL) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { errors++; } size_t size = 0; @@ -154,13 +154,13 @@ static int test_nsec3_sha1() lived = 0; if (knot_nsec3_sha1(&nsec3_test_params, data, 20, &digest, &size) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { errors++; } lived = 1; }, "NSEC3: nsec3 sha1 NULL tests"); if (errors) { - diag("Does not return DNSLIB_EBADARG after " + diag("Does not return KNOT_EBADARG after " "execution with wrong arguments!"); } @@ -171,7 +171,7 @@ static int test_nsec3_sha1() if (knot_nsec3_sha1(&nsec3_test_params, (uint8_t *)"\2ns\3nic\2cz", strlen("\2ns\3nic\2cz"), &digest, - &digest_size) != DNSLIB_EOK) { + &digest_size) != KNOT_EOK) { diag("Could not hash name!"); return 0; } @@ -215,14 +215,14 @@ static int test_nsec3_sha1() return (errors == 0); } -static const int DNSLIB_NSEC3_TESTS_COUNT = 2; +static const int KNOT_NSEC3_TESTS_COUNT = 2; /*! This helper routine should report number of * scheduled tests for given parameters. */ static int knot_nsec3_tests_count(int argc, char *argv[]) { - return DNSLIB_NSEC3_TESTS_COUNT; + return KNOT_NSEC3_TESTS_COUNT; } /*! Run all scheduled tests for given parameters. diff --git a/src/dnslib/tests/dnslib/nsec3_tests.h b/src/dnslib/tests/dnslib/nsec3_tests.h index 90d377d71fbda9a81550a2eb554411681663b704..8785597f324bfed059e1e35a22e587210c897467 100644 --- a/src/dnslib/tests/dnslib/nsec3_tests.h +++ b/src/dnslib/tests/dnslib/nsec3_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_NSEC3_TESTS_H_ -#define _KNOT_NSEC3_TESTS_H_ +#ifndef _KNOTDNSEC3_TESTS_H_ +#define _KNOTDNSEC3_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api nsec3_tests_api; -#endif /* _KNOT_NSEC3_TESTS_H_ */ +#endif /* _KNOTDNSEC3_TESTS_H_ */ diff --git a/src/dnslib/tests/dnslib/packet_tests.c b/src/dnslib/tests/dnslib/packet_tests.c index a7916f208099c8f36b6cb764d87dfe12770e532b..b95253354589cb5b32a098cb8cffa99e8fbc5650 100644 --- a/src/dnslib/tests/dnslib/packet_tests.c +++ b/src/dnslib/tests/dnslib/packet_tests.c @@ -25,21 +25,21 @@ static int test_packet_new() { int errors = 0; knot_packet_t *packet = - knot_packet_new(DNSLIB_PACKET_PREALLOC_NONE); + knot_packet_new(KNOT_PACKET_PREALLOC_NONE); if (packet == NULL) { diag("Could not create packet using prealloc_node constant!"); errors++; } knot_packet_free(&packet); - packet = knot_packet_new(DNSLIB_PACKET_PREALLOC_QUERY); + packet = knot_packet_new(KNOT_PACKET_PREALLOC_QUERY); if (packet == NULL) { diag("Could not create packet using prealloc_query constant!"); errors++; } knot_packet_free(&packet); - packet = knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + packet = knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); if (packet == NULL) { diag("Could not create packet using prealloc_resp constant!"); errors++; @@ -55,31 +55,31 @@ static int test_packet_parse_from_wire() { int errors = 0; knot_packet_t *packet = - knot_packet_new(DNSLIB_PACKET_PREALLOC_QUERY); + knot_packet_new(KNOT_PACKET_PREALLOC_QUERY); int tmp = 0; lives_ok({ if (knot_packet_parse_from_wire(NULL, NULL, 0, 0) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { diag("Trying to parse NULL packet with NULL wire " - "did not return DNSLIB_EBADARG!"); + "did not return KNOT_EBADARG!"); errors++; } tmp = 1; tmp = 0; if (knot_packet_parse_from_wire(packet, NULL, 0, 0) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { diag("Trying to parse with NULL wire " - "did not return DNSLIB_EBADARG!"); + "did not return KNOT_EBADARG!"); errors++; } tmp = 1; tmp = 0; if (knot_packet_parse_from_wire(packet, (uint8_t *)0xbeef, 0, 0) != - DNSLIB_EFEWDATA) { + KNOT_EFEWDATA) { diag("Trying to parse 0 lengt" - "did not return DNSLIB_EOK!"); + "did not return KNOT_EOK!"); errors++; } tmp = 1; @@ -95,26 +95,26 @@ static int test_packet_parse_next_rr_answer() { int errors = 0; knot_packet_t *packet = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); assert(packet); int tmp = 0; lives_ok({ int ret = 0; if (knot_packet_parse_next_rr_answer(NULL, NULL) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { diag("Trying to parse next RR answer with " "NULL packet with and NULL RRSet " - "did not return DNSLIB_EBADARG!"); + "did not return KNOT_EBADARG!"); errors++; } tmp = 1; tmp = 0; if ((ret = knot_packet_parse_next_rr_answer(packet, NULL)) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { diag("Trying to parse next RR with NULL RRSet pointer " - "did not return DNSLIB_EBADARG! Got %d.", + "did not return KNOT_EBADARG! Got %d.", ret); errors++; } @@ -123,10 +123,10 @@ static int test_packet_parse_next_rr_answer() tmp = 0; if (knot_packet_parse_next_rr_answer(packet, &rrset) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { diag("Trying to parse next RR answer with rrset pointer" " not pointing to NULL did not " - "return DNSLIB_EBADARG!"); + "return KNOT_EBADARG!"); errors++; } tmp = 1; @@ -145,7 +145,7 @@ static int test_packet_parse_rest() "packet: parse rest NULL test"); knot_packet_t *packet = - knot_packet_new(DNSLIB_PACKET_PREALLOC_NONE); + knot_packet_new(KNOT_PACKET_PREALLOC_NONE); assert(packet); lives_ok({res *= knot_packet_parse_rest(packet);}, @@ -161,16 +161,16 @@ static int test_packet_set_max_size() { int errors = 0; knot_packet_t *packet = - knot_packet_new(DNSLIB_PACKET_PREALLOC_NONE); + knot_packet_new(KNOT_PACKET_PREALLOC_NONE); assert(packet); int lived = 0; lives_ok({ lived = 0; - if (knot_packet_set_max_size(NULL, 1) != DNSLIB_EBADARG) { + if (knot_packet_set_max_size(NULL, 1) != KNOT_EBADARG) { diag("Calling packet_set_max() with NULL packet " - "did not return DNSLIB_EBADARG"); + "did not return KNOT_EBADARG"); errors++; } lived = 1; @@ -178,15 +178,15 @@ static int test_packet_set_max_size() errors += lived != 1; - if (knot_packet_set_max_size(packet, 0) != DNSLIB_EBADARG) { + if (knot_packet_set_max_size(packet, 0) != KNOT_EBADARG) { diag("Calling packet_set_max() with size eqeal to 0 did not " - "return DNSLIB_EBADARG"); + "return KNOT_EBADARG"); errors++; } - if (knot_packet_set_max_size(packet, 10) != DNSLIB_EOK) { + if (knot_packet_set_max_size(packet, 10) != KNOT_EOK) { diag("Calling packet_set_max() with valid arguments did not " - "return DNSLIB_EOK"); + "return KNOT_EOK"); errors++; } @@ -204,39 +204,39 @@ static int test_packet_add_tmp_rrset() knot_rrset_t *rrset = (knot_rrset_t *)0xabcdef; knot_packet_t *packet = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); assert(packet); lives_ok({ if (knot_packet_add_tmp_rrset(NULL, rrset) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { diag("Trying to add to NULL packet did not return " - "DNSLIB_EBADARG!"); + "KNOT_EBADARG!"); errors++; } lived = 1; lived = 0; if (knot_packet_add_tmp_rrset(packet, NULL) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { diag("Trying to add NULL rrset did not return " - "DNSLIB_EBADARG!"); + "KNOT_EBADARG!"); errors++; } lived = 1; lived = 0; if (knot_packet_add_tmp_rrset(NULL, NULL) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { diag("Trying to add NULL rrset to NULL packet " - "did not return DNSLIB_EBADARG!"); + "did not return KNOT_EBADARG!"); errors++; } lived = 1; }, "packet: add tmp rrset NULL test"); errors += lived != 1; - if (knot_packet_add_tmp_rrset(packet, rrset) != DNSLIB_EOK) { + if (knot_packet_add_tmp_rrset(packet, rrset) != KNOT_EOK) { diag("Could not add valid RRSet to packet!"); errors++; } @@ -256,13 +256,13 @@ static int test_packet_add_tmp_rrset() // int lives = 0; // knot_packet_t *packet = -// knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); +// knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); // assert(packet); // lives_ok({ // if (knot_packet_contains(packet, NULL, -// DNSLIB_RRSET_COMPARE_PTR) != -// DNSLIB_EBADARG{ +// KNOT_RRSET_COMPARE_PTR) != +// KNOT_EBADARG{ // diag(); // } // }, "packet: contains NULL tests); @@ -276,7 +276,7 @@ static int test_packet_header_to_wire() int errors = 0; int lived = 0; knot_packet_t *packet = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); assert(packet); size_t size; @@ -298,23 +298,23 @@ static int test_packet_question_to_wire() int errors = 0 ; int lived = 0; knot_packet_t *packet = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); assert(packet); lives_ok({ - if (knot_packet_question_to_wire(NULL) != DNSLIB_EBADARG) { + if (knot_packet_question_to_wire(NULL) != KNOT_EBADARG) { diag("Calling packet_question_to_wire with " - "NULL pointer did not result to DNSLIB_EBADARG!"); + "NULL pointer did not result to KNOT_EBADARG!"); errors++; } lived = 1; }, "packet: question to wire NULL tests"); errors += lived != 1; - packet->size = DNSLIB_WIRE_HEADER_SIZE + 1; - if (knot_packet_question_to_wire(packet) != DNSLIB_ERROR) { + packet->size = KNOT_WIRE_HEADER_SIZE + 1; + if (knot_packet_question_to_wire(packet) != KNOT_ERROR) { diag("Calling packet_question_to_wire with oversized packet " - "did not return DNSLIB_ERROR!"); + "did not return KNOT_ERROR!"); errors++; } @@ -327,7 +327,7 @@ static int test_packet_edns_to_wire() int errors = 0 ; int lived = 0; knot_packet_t *packet = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); assert(packet); lives_ok({ @@ -345,32 +345,32 @@ static int test_packet_to_wire() int errors = 0 ; int lived = 0; knot_packet_t *packet = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); assert(packet); lives_ok({ - if (knot_packet_to_wire(NULL, NULL, NULL) != DNSLIB_EBADARG) { + if (knot_packet_to_wire(NULL, NULL, NULL) != KNOT_EBADARG) { diag("Calling packet_to_wire with " - "NULL pointers did not return DNSLIB_EBADARG!"); + "NULL pointers did not return KNOT_EBADARG!"); errors++; } lived = 1; size_t size; lived = 0; if (knot_packet_to_wire(packet, NULL, &size) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { diag("Calling packet_to_wire with " - "NULL wire did not return DNSLIB_EBADARG!"); + "NULL wire did not return KNOT_EBADARG!"); errors++; } lived = 1; uint8_t *wire = (uint8_t *)0xabcdef; lived = 0; if (knot_packet_to_wire(packet, &wire, &size) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { diag("Calling packet_to_wire with " "wire not pointing to NULL did not return" - " DNSLIB_EBADARG!"); + " KNOT_EBADARG!"); errors++; } lived = 1; @@ -381,11 +381,11 @@ static int test_packet_to_wire() return (errors == 0); } -static const uint DNSLIB_PACKET_TEST_COUNT = 21; +static const uint KNOT_PACKET_TEST_COUNT = 21; static int packet_tests_count(int argc, char *argv[]) { - return DNSLIB_PACKET_TEST_COUNT; + return KNOT_PACKET_TEST_COUNT; } static int packet_tests_run(int argc, char *argv[]) diff --git a/src/dnslib/tests/dnslib/packet_tests.h b/src/dnslib/tests/dnslib/packet_tests.h index 6189dc038f79f37b32aacb7b08403c29d0bc4477..c486624ff877e5bed414ccae3462a23c5fdf4bcb 100644 --- a/src/dnslib/tests/dnslib/packet_tests.h +++ b/src/dnslib/tests/dnslib/packet_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_PACKET_TESTS_H_ -#define _KNOT_PACKET_TESTS_H_ +#ifndef _KNOTDPACKET_TESTS_H_ +#define _KNOTDPACKET_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api packet_tests_api; -#endif /* _KNOT_PACKET_TESTS_H_ */ +#endif /* _KNOTDPACKET_TESTS_H_ */ diff --git a/src/dnslib/tests/dnslib/query_tests.c b/src/dnslib/tests/dnslib/query_tests.c index 19bf86c82c08ce7f8136b46342f7cc33b76481e0..6c372879c05a05c9c150f6b4e1e7bf4a4a993feb 100644 --- a/src/dnslib/tests/dnslib/query_tests.c +++ b/src/dnslib/tests/dnslib/query_tests.c @@ -22,11 +22,11 @@ unit_api query_tests_api = { &query_tests_run //! Run scheduled tests }; -static const uint DNSLIB_QUERY_TEST_COUNT = 1; +static const uint KNOT_QUERY_TEST_COUNT = 1; static int query_tests_count(int argc, char *argv[]) { - return DNSLIB_QUERY_TEST_COUNT; + return KNOT_QUERY_TEST_COUNT; } static int test_query_init() @@ -34,22 +34,22 @@ static int test_query_init() int errors = 0; int lived = 0; knot_packet_t *query = - knot_packet_new(DNSLIB_PACKET_PREALLOC_QUERY); + knot_packet_new(KNOT_PACKET_PREALLOC_QUERY); assert(query); lives_ok({ - if (knot_query_init(NULL) != DNSLIB_EBADARG) { + if (knot_query_init(NULL) != KNOT_EBADARG) { diag("Calling query_init with NULL query did " - "not return DNSLIB_EBADARG!"); + "not return KNOT_EBADARG!"); errors++; } lived = 1; }, "query: init NULL tests"); errors += lived != 1; - assert(knot_packet_set_max_size(query, 1024 * 10) == DNSLIB_EOK); - if (knot_query_init(query) != DNSLIB_EOK) { + assert(knot_packet_set_max_size(query, 1024 * 10) == KNOT_EOK); + if (knot_query_init(query) != KNOT_EOK) { diag("Calling query_init with valid query did not return " - "DNSLIB_EOK!"); + "KNOT_EOK!"); errors++; } @@ -67,16 +67,16 @@ static int test_query_set_question() int lived = 0; knot_packet_t *query = - knot_packet_new(DNSLIB_PACKET_PREALLOC_QUERY); + knot_packet_new(KNOT_PACKET_PREALLOC_QUERY); assert(query); - assert(knot_packet_set_max_size(query, 1024 * 10) == DNSLIB_EOK); + assert(knot_packet_set_max_size(query, 1024 * 10) == KNOT_EOK); knot_query_init(query); knot_rrset_t *rrset = knot_rrset_new(knot_dname_new_from_str("a.ns.cz.", strlen("a.ns.cz."), NULL), - DNSLIB_RRTYPE_A, DNSLIB_CLASS_IN, 3600); + KNOT_RRTYPE_A, KNOT_CLASS_IN, 3600); assert(rrset); knot_question_t *question = malloc(sizeof(knot_question_t)); @@ -86,19 +86,19 @@ static int test_query_set_question() question->qclass = rrset->rclass; lives_ok({ - if (knot_query_set_question(NULL, NULL) != DNSLIB_EBADARG) { + if (knot_query_set_question(NULL, NULL) != KNOT_EBADARG) { diag("Calling query_set_question with NULL"); errors++; } lived = 1; lived = 0; - if (knot_query_set_question(query, NULL) != DNSLIB_EBADARG) { + if (knot_query_set_question(query, NULL) != KNOT_EBADARG) { diag("Calling query_set_question with NULL"); errors++; } lived = 1; lived = 0; - if (knot_query_set_question(NULL, question) != DNSLIB_EBADARG) { + if (knot_query_set_question(NULL, question) != KNOT_EBADARG) { diag("Calling query_set_question with NULL"); errors++; } @@ -106,7 +106,7 @@ static int test_query_set_question() }, "query: set question NULL tests"); errors += lived != 1; - if (knot_query_set_question(query, question) != DNSLIB_EOK) { + if (knot_query_set_question(query, question) != KNOT_EOK) { diag("Calling query_set_question with valid arguments "); errors++; } diff --git a/src/dnslib/tests/dnslib/query_tests.h b/src/dnslib/tests/dnslib/query_tests.h index 590259659ec018e13dabf1eb89c60a2da323ee09..646c29c075f34873b32cf7c005ed2fdfdd5eb92d 100644 --- a/src/dnslib/tests/dnslib/query_tests.h +++ b/src/dnslib/tests/dnslib/query_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_QUERY_TESTS_H_ -#define _KNOT_QUERY_TESTS_H_ +#ifndef _KNOTDQUERY_TESTS_H_ +#define _KNOTDQUERY_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api query_tests_api; -#endif /* _KNOT_QUERY_TESTS_H_ */ +#endif /* _KNOTDQUERY_TESTS_H_ */ diff --git a/src/dnslib/tests/dnslib/rdata_tests.c b/src/dnslib/tests/dnslib/rdata_tests.c index bab3acb288a3feaeb4c1315b5fd828de91a1b763..336e4565d9a2f413ac04e80f88a4e9e5f5a9a513 100644 --- a/src/dnslib/tests/dnslib/rdata_tests.c +++ b/src/dnslib/tests/dnslib/rdata_tests.c @@ -174,9 +174,9 @@ static int fill_rdata(uint8_t *data, int max_size, uint16_t rrtype, int stored_size = 0; switch (desc->wireformat[i]) { - case DNSLIB_RDATA_WF_COMPRESSED_DNAME: - case DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME: - case DNSLIB_RDATA_WF_LITERAL_DNAME: + case KNOT_RDATA_WF_COMPRESSED_DNAME: + case KNOT_RDATA_WF_UNCOMPRESSED_DNAME: + case KNOT_RDATA_WF_LITERAL_DNAME: dname = knot_dname_new_from_wire( (uint8_t *)test_domains_ok[0].wire, test_domains_ok[0].size, NULL); @@ -187,7 +187,7 @@ static int fill_rdata(uint8_t *data, int max_size, uint16_t rrtype, domain = 1; size = knot_dname_size(dname); //note("Size of created domain name: %u", size); - assert(size < DNSLIB_MAX_RDATA_ITEM_SIZE); + assert(size < KNOT_MAX_RDATA_ITEM_SIZE); // store size of the domain name *(pos++) = size; // copy the domain name @@ -196,7 +196,7 @@ static int fill_rdata(uint8_t *data, int max_size, uint16_t rrtype, break; default: binary = 1; - size = rand() % DNSLIB_MAX_RDATA_ITEM_SIZE; + size = rand() % KNOT_MAX_RDATA_ITEM_SIZE; } if (binary) { @@ -272,9 +272,9 @@ static int check_rdata(const uint8_t *data, int max_size, uint16_t rrtype, //note(" item: %d", i); switch (desc->wireformat[i]) { - case DNSLIB_RDATA_WF_COMPRESSED_DNAME: - case DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME: - case DNSLIB_RDATA_WF_LITERAL_DNAME: + case KNOT_RDATA_WF_COMPRESSED_DNAME: + case KNOT_RDATA_WF_UNCOMPRESSED_DNAME: + case KNOT_RDATA_WF_LITERAL_DNAME: //note(" domain name"); domain = 1; size = knot_dname_size(knot_rdata_item( @@ -367,9 +367,9 @@ static int check_rdata(const uint8_t *data, int max_size, uint16_t rrtype, // uint to_copy = 0; // switch (desc->wireformat[i]) { -// case DNSLIB_RDATA_WF_COMPRESSED_DNAME: -// case DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME: -// case DNSLIB_RDATA_WF_LITERAL_DNAME: +// case KNOT_RDATA_WF_COMPRESSED_DNAME: +// case KNOT_RDATA_WF_UNCOMPRESSED_DNAME: +// case KNOT_RDATA_WF_LITERAL_DNAME: // // copy the domain name without its length // from = pos + 1; // to_copy = *pos; @@ -377,46 +377,46 @@ static int check_rdata(const uint8_t *data, int max_size, uint16_t rrtype, ///* note("Domain name in wire format (size %u): %s", // to_copy, (char *)from); */ // break; -// case DNSLIB_RDATA_WF_BYTE: +// case KNOT_RDATA_WF_BYTE: // //note(" 1byte int"); // from = pos; // to_copy = 1; // pos += 1; // break; -// case DNSLIB_RDATA_WF_SHORT: +// case KNOT_RDATA_WF_SHORT: // //note(" 2byte int"); // from = pos; // to_copy = 2; // pos += 2; // break; -// case DNSLIB_RDATA_WF_LONG: +// case KNOT_RDATA_WF_LONG: // //note(" 4byte int"); // from = pos; // to_copy = 4; // pos += 4; // break; -// case DNSLIB_RDATA_WF_A: +// case KNOT_RDATA_WF_A: // //note(" A"); // from = pos; // to_copy = 4; // pos += 4; // break; -// case DNSLIB_RDATA_WF_AAAA: +// case KNOT_RDATA_WF_AAAA: // //note(" AAAA"); // from = pos; // to_copy = 16; // pos += 16; // break; -// case DNSLIB_RDATA_WF_BINARY: -// case DNSLIB_RDATA_WF_APL: // saved as binary -// case DNSLIB_RDATA_WF_IPSECGATEWAY: // saved as binary +// case KNOT_RDATA_WF_BINARY: +// case KNOT_RDATA_WF_APL: // saved as binary +// case KNOT_RDATA_WF_IPSECGATEWAY: // saved as binary // //note(" binary"); // from = pos + 1; // to_copy = *pos; // pos += *pos + 1; // break; -// case DNSLIB_RDATA_WF_TEXT: -// case DNSLIB_RDATA_WF_BINARYWITHLENGTH: +// case KNOT_RDATA_WF_TEXT: +// case KNOT_RDATA_WF_BINARYWITHLENGTH: // //note(" text or binary with length (%u)", *pos); // to_copy = *pos + 1; // from = pos; @@ -462,13 +462,13 @@ static int test_rdata_set_item() return 0; } - uint8_t *data = malloc(sizeof(uint8_t) * DNSLIB_MAX_RDATA_WIRE_SIZE); + uint8_t *data = malloc(sizeof(uint8_t) * KNOT_MAX_RDATA_WIRE_SIZE); assert(data); - generate_rdata(data, DNSLIB_MAX_RDATA_WIRE_SIZE); + generate_rdata(data, KNOT_MAX_RDATA_WIRE_SIZE); // set items through set_items() and then call set_item() - uint16_t rrtype = rand() % DNSLIB_RRTYPE_LAST + 1; - if (fill_rdata(data, DNSLIB_MAX_RDATA_WIRE_SIZE, rrtype, rdata) < 0) { + uint16_t rrtype = rand() % KNOT_RRTYPE_LAST + 1; + if (fill_rdata(data, KNOT_MAX_RDATA_WIRE_SIZE, rrtype, rdata) < 0) { knot_rdata_free(&rdata); diag("Error filling RDATA"); return 0; @@ -480,9 +480,9 @@ static int test_rdata_set_item() knot_rrtype_descriptor_by_type(rrtype); // if the rdata on this position is domain name, free it to avoid leaks - if (desc->wireformat[pos] == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME - || desc->wireformat[pos] == DNSLIB_RDATA_WF_COMPRESSED_DNAME - || desc->wireformat[pos] == DNSLIB_RDATA_WF_LITERAL_DNAME) { + if (desc->wireformat[pos] == KNOT_RDATA_WF_UNCOMPRESSED_DNAME + || desc->wireformat[pos] == KNOT_RDATA_WF_COMPRESSED_DNAME + || desc->wireformat[pos] == KNOT_RDATA_WF_LITERAL_DNAME) { knot_dname_free(&(rdata->items[pos].dname)); } @@ -505,11 +505,11 @@ static int test_rdata_set_item() for (int x = 0; x < desc->length; x++) { if (x != pos && ( desc->wireformat[x] == - DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME || + KNOT_RDATA_WF_UNCOMPRESSED_DNAME || desc->wireformat[x] == - DNSLIB_RDATA_WF_COMPRESSED_DNAME || + KNOT_RDATA_WF_COMPRESSED_DNAME || desc->wireformat[x] == - DNSLIB_RDATA_WF_LITERAL_DNAME)) { + KNOT_RDATA_WF_LITERAL_DNAME)) { knot_dname_free(&(rdata->items[x].dname)); } } @@ -538,7 +538,7 @@ static int test_rdata_set_items() int errors = 0; // check error return values - if (knot_rdata_set_items(rdata, NULL, 0) != DNSLIB_EBADARG) { + if (knot_rdata_set_items(rdata, NULL, 0) != KNOT_EBADARG) { diag("Return value of knot_rdata_set_items() " "when rdata == NULL is wrong"); return 0; @@ -546,13 +546,13 @@ static int test_rdata_set_items() rdata = knot_rdata_new(); assert(rdata != NULL); - if (knot_rdata_set_items(rdata, NULL, 0) != DNSLIB_EBADARG) { + if (knot_rdata_set_items(rdata, NULL, 0) != KNOT_EBADARG) { diag("Return value of knot_rdata_set_items()" " when items == NULL is wrong"); knot_rdata_free(&rdata); return 0; } else if (knot_rdata_set_items(rdata, item, 0) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { diag("Return value of knot_rdata_set_items()" " when count == 0" "is wrong"); @@ -563,18 +563,18 @@ static int test_rdata_set_items() } // generate some random data - uint8_t *data = malloc(sizeof(uint8_t) * DNSLIB_MAX_RDATA_WIRE_SIZE); + uint8_t *data = malloc(sizeof(uint8_t) * KNOT_MAX_RDATA_WIRE_SIZE); assert(data); - generate_rdata(data, DNSLIB_MAX_RDATA_WIRE_SIZE); + generate_rdata(data, KNOT_MAX_RDATA_WIRE_SIZE); - for (int i = 0; i <= DNSLIB_RRTYPE_LAST; ++i) { + for (int i = 0; i <= KNOT_RRTYPE_LAST; ++i) { rdata = knot_rdata_new(); - if (fill_rdata(data, DNSLIB_MAX_RDATA_WIRE_SIZE, i, rdata) + if (fill_rdata(data, KNOT_MAX_RDATA_WIRE_SIZE, i, rdata) < 0) { ++errors; } - errors += check_rdata(data, DNSLIB_MAX_RDATA_WIRE_SIZE, i, + errors += check_rdata(data, KNOT_MAX_RDATA_WIRE_SIZE, i, rdata); knot_rrtype_descriptor_t *desc = @@ -582,11 +582,11 @@ static int test_rdata_set_items() for (int x = 0; x < desc->length; x++) { if (desc->wireformat[x] == - DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME || + KNOT_RDATA_WF_UNCOMPRESSED_DNAME || desc->wireformat[x] == - DNSLIB_RDATA_WF_COMPRESSED_DNAME || + KNOT_RDATA_WF_COMPRESSED_DNAME || desc->wireformat[x] == - DNSLIB_RDATA_WF_LITERAL_DNAME) { + KNOT_RDATA_WF_LITERAL_DNAME) { // printf("freeing %p\n", rdata->items[x].dname); knot_dname_free(&(rdata->items[x].dname)); } @@ -646,9 +646,9 @@ static int test_rdata_compare() { int errors = 0; - uint8_t format_rawdata = DNSLIB_RDATA_WF_BINARY; + uint8_t format_rawdata = KNOT_RDATA_WF_BINARY; - uint8_t format_dname = DNSLIB_RDATA_WF_LITERAL_DNAME; + uint8_t format_dname = KNOT_RDATA_WF_LITERAL_DNAME; /* 123456 \w 654321 -> result -1 */ if (knot_rdata_compare(&test_rdata[0], @@ -712,14 +712,14 @@ static int test_rdata_compare() // int errors = 0; // // generate some random data -// uint8_t data[DNSLIB_MAX_RDATA_WIRE_SIZE]; -// generate_rdata(data, DNSLIB_MAX_RDATA_WIRE_SIZE); +// uint8_t data[KNOT_MAX_RDATA_WIRE_SIZE]; +// generate_rdata(data, KNOT_MAX_RDATA_WIRE_SIZE); -// for (int i = 0; i <= DNSLIB_RRTYPE_LAST; ++i) { +// for (int i = 0; i <= KNOT_RRTYPE_LAST; ++i) { // rdata = knot_rdata_new(); // int size = -// fill_rdata(data, DNSLIB_MAX_RDATA_WIRE_SIZE, i, rdata); +// fill_rdata(data, KNOT_MAX_RDATA_WIRE_SIZE, i, rdata); // if (size < 0) { // ++errors; @@ -739,11 +739,11 @@ static int test_rdata_compare() // for (int x = 0; x < desc->length; x++) { // if (desc->wireformat[x] == -// DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME || +// KNOT_RDATA_WF_UNCOMPRESSED_DNAME || // desc->wireformat[x] == -// DNSLIB_RDATA_WF_COMPRESSED_DNAME || +// KNOT_RDATA_WF_COMPRESSED_DNAME || // desc->wireformat[x] == -// DNSLIB_RDATA_WF_LITERAL_DNAME) { +// KNOT_RDATA_WF_LITERAL_DNAME) { // knot_dname_free(&(rdata->items[x].dname)); // } // } @@ -761,19 +761,19 @@ static int test_rdata_compare() // int errors = 0; // // generate some random data -// uint8_t data[DNSLIB_MAX_RDATA_WIRE_SIZE]; -// uint8_t data_wire[DNSLIB_MAX_RDATA_WIRE_SIZE]; -// uint8_t rdata_wire[DNSLIB_MAX_RDATA_WIRE_SIZE]; -// generate_rdata(data, DNSLIB_MAX_RDATA_WIRE_SIZE); +// uint8_t data[KNOT_MAX_RDATA_WIRE_SIZE]; +// uint8_t data_wire[KNOT_MAX_RDATA_WIRE_SIZE]; +// uint8_t rdata_wire[KNOT_MAX_RDATA_WIRE_SIZE]; +// generate_rdata(data, KNOT_MAX_RDATA_WIRE_SIZE); -// for (int i = 0; i <= DNSLIB_RRTYPE_LAST; ++i) { +// for (int i = 0; i <= KNOT_RRTYPE_LAST; ++i) { // rdata = knot_rdata_new(); // int size = -// fill_rdata(data, DNSLIB_MAX_RDATA_WIRE_SIZE, i, rdata); +// fill_rdata(data, KNOT_MAX_RDATA_WIRE_SIZE, i, rdata); // int size_expected = -// convert_to_wire(data, DNSLIB_MAX_RDATA_WIRE_SIZE, i, +// convert_to_wire(data, KNOT_MAX_RDATA_WIRE_SIZE, i, // data_wire); // if (size < 0) { @@ -788,7 +788,7 @@ static int test_rdata_compare() // if (knot_rdata_to_wire(rdata, // knot_rrtype_descriptor_by_type(i)-> // wireformat, rdata_wire, -// DNSLIB_MAX_RDATA_WIRE_SIZE) != 0) { +// KNOT_MAX_RDATA_WIRE_SIZE) != 0) { // diag("Error while converting RDATA" // " to wire format."); // ++errors; @@ -810,11 +810,11 @@ static int test_rdata_compare() // for (int x = 0; x < desc->length; x++) { // if (desc->wireformat[x] == -// DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME || +// KNOT_RDATA_WF_UNCOMPRESSED_DNAME || // desc->wireformat[x] == -// DNSLIB_RDATA_WF_COMPRESSED_DNAME || +// KNOT_RDATA_WF_COMPRESSED_DNAME || // desc->wireformat[x] == -// DNSLIB_RDATA_WF_LITERAL_DNAME) { +// KNOT_RDATA_WF_LITERAL_DNAME) { // knot_dname_free(&(rdata->items[x].dname)); // } // } @@ -844,12 +844,12 @@ static int test_rdata_deep_free() knot_rdata_t *tmp_rdata; - uint8_t data[DNSLIB_MAX_RDATA_WIRE_SIZE]; + uint8_t data[KNOT_MAX_RDATA_WIRE_SIZE]; - for (int i = 0; i <= DNSLIB_RRTYPE_LAST; i++) { + for (int i = 0; i <= KNOT_RRTYPE_LAST; i++) { tmp_rdata = knot_rdata_new(); - fill_rdata(data, DNSLIB_MAX_RDATA_WIRE_SIZE, i, tmp_rdata); + fill_rdata(data, KNOT_MAX_RDATA_WIRE_SIZE, i, tmp_rdata); knot_rdata_deep_free(&tmp_rdata, i, 0); errors += (tmp_rdata != NULL); @@ -860,14 +860,14 @@ static int test_rdata_deep_free() /*----------------------------------------------------------------------------*/ -static const int DNSLIB_RDATA_TEST_COUNT = 8; +static const int KNOT_RDATA_TEST_COUNT = 8; /*! This helper routine should report number of * scheduled tests for given parameters. */ static int knot_rdata_tests_count(int argc, char *argv[]) { - return DNSLIB_RDATA_TEST_COUNT; + return KNOT_RDATA_TEST_COUNT; } /*! Run all scheduled tests for given parameters. diff --git a/src/dnslib/tests/dnslib/rdata_tests.h b/src/dnslib/tests/dnslib/rdata_tests.h index d28ddb7e630428d3b63de55a13f7e8c822e6fedd..579754a96e840a0add6c5f836c69f37d88087a09 100644 --- a/src/dnslib/tests/dnslib/rdata_tests.h +++ b/src/dnslib/tests/dnslib/rdata_tests.h @@ -26,12 +26,12 @@ * e.g. test whether knot_rdata_get_item() returns NULL when passed an * illegal position, etc. */ -#ifndef _KNOT_RDATA_TESTS_H_ -#define _KNOT_RDATA_TESTS_H_ +#ifndef _KNOTDRDATA_TESTS_H_ +#define _KNOTDRDATA_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api rdata_tests_api; -#endif /* _KNOT_RDATA_TESTS_H_ */ +#endif /* _KNOTDRDATA_TESTS_H_ */ diff --git a/src/dnslib/tests/dnslib/response2_tests.c b/src/dnslib/tests/dnslib/response2_tests.c index e65442defb30d12ead261a5f3142275cfb789e6b..df621e1fd86142fda52c6ea29cea10a74b4a6679 100644 --- a/src/dnslib/tests/dnslib/response2_tests.c +++ b/src/dnslib/tests/dnslib/response2_tests.c @@ -35,9 +35,9 @@ static int test_response_init() int errors = 0; int lived = 0; lives_ok({ - if (knot_response2_init(NULL) != DNSLIB_EBADARG) { + if (knot_response2_init(NULL) != KNOT_EBADARG) { diag("Calling response_init with NULL packet did " - "not return DNSLIB_EBADARG!"); + "not return KNOT_EBADARG!"); errors++; } lived = 1; @@ -45,11 +45,11 @@ static int test_response_init() errors += lived != 1; knot_packet_t *response = - knot_packet_new(DNSLIB_PACKET_PREALLOC_QUERY); - response->max_size = DNSLIB_WIRE_HEADER_SIZE - 1; - if (knot_response2_init(response) != DNSLIB_ESPACE) { + knot_packet_new(KNOT_PACKET_PREALLOC_QUERY); + response->max_size = KNOT_WIRE_HEADER_SIZE - 1; + if (knot_response2_init(response) != KNOT_ESPACE) { diag("Calling response_init too small packet did " - "not return DNSLIB_ESPACE!"); + "not return KNOT_ESPACE!"); errors++; } @@ -62,39 +62,39 @@ static int test_response_init_query() int lived = 0; lives_ok({ if (knot_response2_init_from_query(NULL, NULL) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { diag("Calling response_init_query with NULL packet and " - "NULL query did not return DNSLIB_EBADARG!"); + "NULL query did not return KNOT_EBADARG!"); errors++; } lived = 1; knot_packet_t *response = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); assert(response); knot_packet_set_max_size(response, - DNSLIB_PACKET_PREALLOC_RESPONSE); + KNOT_PACKET_PREALLOC_RESPONSE); knot_response2_init(response); lived = 0; if (knot_response2_init_from_query(response, NULL) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { diag("Calling response_init_query with NULL query " - "did not return DNSLIB_EBADARG!"); + "did not return KNOT_EBADARG!"); errors++; } lived = 1; knot_packet_t *query = - knot_packet_new(DNSLIB_PACKET_PREALLOC_QUERY); + knot_packet_new(KNOT_PACKET_PREALLOC_QUERY); if (knot_response2_init_from_query(NULL, query) != - DNSLIB_EBADARG) { + KNOT_EBADARG) { diag("Calling response_init_query with NULL response " - "did not return DNSLIB_EBADARG!"); + "did not return KNOT_EBADARG!"); errors++; } }, "response2: init from query NULL tests"); errors += lived != 1; /* Cannot test the rest of return values, since there is now constant - * controlling value that could return DNSLIB_EDNAMEPTR */ + * controlling value that could return KNOT_EDNAMEPTR */ return (errors == 0); } @@ -126,30 +126,30 @@ int compare_wires_simple(uint8_t *wire1, uint8_t *wire2, uint count) // */ // knot_packet_t *response = -// knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); -// knot_packet_set_max_size(response, DNSLIB_WIRE_HEADER_SIZE * 100); -// assert(knot_response2_init(response) == DNSLIB_EOK); +// knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); +// knot_packet_set_max_size(response, KNOT_WIRE_HEADER_SIZE * 100); +// assert(knot_response2_init(response) == KNOT_EOK); // uint8_t *original_wire = NULL; // size_t original_size = 0; // assert(knot_packet_to_wire(response, &original_wire, // &original_size) == -// DNSLIB_EOK); +// KNOT_EOK); // /* Do something in question section. */ //// test_dname_t test_dname; //// test_dname.str = "ns8.nic.cz."; //// knot_dname_t *dname = dname_from_test_dname_str(&test_dname); //// assert(dname); -// response->question.qtype = DNSLIB_RRTYPE_HINFO; -// response->question.qclass = DNSLIB_CLASS_CH; +// response->question.qtype = KNOT_RRTYPE_HINFO; +// response->question.qclass = KNOT_CLASS_CH; // uint8_t *question_changed_wire = NULL; // size_t question_changed_size = 0; // assert(knot_packet_to_wire(response, // &question_changed_wire, // &question_changed_size) == -// DNSLIB_EOK); +// KNOT_EOK); // knot_response2_set_aa(response); // knot_response2_set_tc(response); @@ -159,7 +159,7 @@ int compare_wires_simple(uint8_t *wire1, uint8_t *wire2, uint count) // uint8_t *new_wire = NULL; // size_t new_size = 0; // assert(knot_packet_to_wire(response, &new_wire, &new_size) == -// DNSLIB_EOK); +// KNOT_EOK); // if (question_changed_size != new_size) { // diag("Wrong wire size after calling response_clear! " // "got %d should be %d", new_size, question_changed_size); @@ -180,7 +180,7 @@ int compare_wires_simple(uint8_t *wire1, uint8_t *wire2, uint count) //// knot_response2_clear(response, 1); //// assert(knot_packet_to_wire(response, &new_wire, &new_size) == -//// DNSLIB_EOK); +//// KNOT_EOK); //// if (original_size != new_size) { //// diag("Wrong wire size after calling response_clear!"); @@ -217,29 +217,29 @@ static int test_response_add_opt() opt.size = 25; // does it matter? lives_ok({ - if (knot_response2_add_opt(NULL, NULL, 0) != DNSLIB_EBADARG) { + if (knot_response2_add_opt(NULL, NULL, 0) != KNOT_EBADARG) { diag("Calling response add opt with NULL arguments " - "did not result to DNSLIB_EBADARG"); + "did not result to KNOT_EBADARG"); errors++; } lived = 1; knot_packet_t *response = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); assert(response); lived = 0; if (knot_response2_add_opt(response, - NULL, 0) != DNSLIB_EBADARG) { + NULL, 0) != KNOT_EBADARG) { diag("Calling response add opt with NULL OPT RR " - "did not result to DNSLIB_EBADARG"); + "did not result to KNOT_EBADARG"); errors++; } lived = 1; lived = 0; if (knot_response2_add_opt(NULL, - &opt, 0) != DNSLIB_EBADARG) { + &opt, 0) != KNOT_EBADARG) { diag("Calling response add opt with NULL response " - "did not result to DNSLIB_EBADARG"); + "did not result to KNOT_EBADARG"); errors++; } lived = 1; @@ -248,28 +248,28 @@ static int test_response_add_opt() errors += lived != 1; knot_packet_t *response = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); assert(response); - knot_packet_set_max_size(response, DNSLIB_PACKET_PREALLOC_RESPONSE * 100); - assert(knot_response2_init(response) == DNSLIB_EOK);; + knot_packet_set_max_size(response, KNOT_PACKET_PREALLOC_RESPONSE * 100); + assert(knot_response2_init(response) == KNOT_EOK);; - if (knot_response2_add_opt(response, &opt, 0) != DNSLIB_EOK) { + if (knot_response2_add_opt(response, &opt, 0) != KNOT_EOK) { diag("Adding valid OPT RR to response " - "did not return DNSLIB_EOK"); + "did not return KNOT_EOK"); errors++; } opt.payload = response->max_size + 1; - if (knot_response2_add_opt(response, &opt, 1) != DNSLIB_EPAYLOAD) { + if (knot_response2_add_opt(response, &opt, 1) != KNOT_EPAYLOAD) { diag("If OPT RR payload is bigger than response max size " - "response_add_opt does not return DNSLIB_EPAYLOAD!"); + "response_add_opt does not return KNOT_EPAYLOAD!"); errors++; } opt.payload = 0; - if (knot_response2_add_opt(response, &opt, 1) != DNSLIB_EBADARG) { + if (knot_response2_add_opt(response, &opt, 1) != KNOT_EBADARG) { diag("Calling response_add_opt with OPT RR payload set to 0 " - "did not return DNSLIB_EBADARG"); + "did not return KNOT_EBADARG"); } knot_packet_free(&response); @@ -284,19 +284,19 @@ static int test_response_add_generic(int (*func)(knot_packet_t *, int lived = 0; lives_ok({ - if (func(NULL, NULL, 0, 0, 0) != DNSLIB_EBADARG) { + if (func(NULL, NULL, 0, 0, 0) != KNOT_EBADARG) { diag("Calling response add rrset with NULL " - "arguments did not return DNSLIB_EBADARG!"); + "arguments did not return KNOT_EBADARG!"); errors++; } lived = 1; knot_packet_t *response = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); assert(response); lived = 0; - if (func(response, NULL, 0, 0, 0) != DNSLIB_EBADARG) { + if (func(response, NULL, 0, 0, 0) != KNOT_EBADARG) { diag("Calling response add rrset with NULL rrset " - "did not return DNSLIB_EBADARG!"); + "did not return KNOT_EBADARG!"); errors++; } lived = 1; @@ -306,13 +306,13 @@ static int test_response_add_generic(int (*func)(knot_packet_t *, NULL); assert(owner); knot_rrset_t *rrset = - knot_rrset_new(owner, DNSLIB_RRTYPE_A, - DNSLIB_CLASS_IN, 3600); + knot_rrset_new(owner, KNOT_RRTYPE_A, + KNOT_CLASS_IN, 3600); assert(rrset); lived = 0; - if (func(NULL, rrset, 0, 0, 0) != DNSLIB_EBADARG) { + if (func(NULL, rrset, 0, 0, 0) != KNOT_EBADARG) { diag("Calling response add rrset with NULL response " - "did not return DNSLIB_EBADARG!"); + "did not return KNOT_EBADARG!"); errors++; } lived = 1; @@ -321,11 +321,11 @@ static int test_response_add_generic(int (*func)(knot_packet_t *, }, "response2: rrset adding NULL tests"); errors += lived != 1; - /*!< \todo Test case when DNSLIB_ESPACE should be returned. */ + /*!< \todo Test case when KNOT_ESPACE should be returned. */ /*!< \todo Compression and so on - should it be tested here? */ knot_packet_t *response = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); assert(response); knot_dname_t *owner = @@ -334,12 +334,12 @@ static int test_response_add_generic(int (*func)(knot_packet_t *, NULL); assert(owner); knot_rrset_t *rrset = - knot_rrset_new(owner, DNSLIB_RRTYPE_NS, - DNSLIB_CLASS_IN, 3600); + knot_rrset_new(owner, KNOT_RRTYPE_NS, + KNOT_CLASS_IN, 3600); assert(rrset); - if (func(response, rrset, 0, 0, 0) != DNSLIB_EOK) { + if (func(response, rrset, 0, 0, 0) != KNOT_EOK) { diag("Adding valid RRSet to response did not result to " - "DNSLIB_EOK"); + "KNOT_EOK"); errors++; } @@ -365,33 +365,33 @@ static int test_response_add_nsid() int lived = 0; knot_packet_t *response = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); assert(response); uint8_t *nsid = (uint8_t *)"knotDNS"; uint16_t nsid_size = strlen((char *)nsid); lives_ok({ if (knot_response2_add_nsid(NULL, - NULL, 1) != DNSLIB_EBADARG) { + NULL, 1) != KNOT_EBADARG) { diag("Calling response add nsid with NULL arguments " - "did not return DNSLIB_EBADARG"); + "did not return KNOT_EBADARG"); errors++; } lived = 1; lived = 0; if (knot_response2_add_nsid(NULL, nsid, - nsid_size) != DNSLIB_EBADARG) { + nsid_size) != KNOT_EBADARG) { diag("Calling response add nsid with NULL response " - "did not return DNSLIB_EBADARG"); + "did not return KNOT_EBADARG"); errors++; } lived = 1; lived = 0; if (knot_response2_add_nsid(response, nsid, - 0) != DNSLIB_EBADARG) { + 0) != KNOT_EBADARG) { diag("Calling response add nsid with zero size " - "did not return DNSLIB_EBADARG"); + "did not return KNOT_EBADARG"); errors++; } lived = 1; @@ -399,8 +399,8 @@ static int test_response_add_nsid() errors += lived != 1; if (knot_response2_add_nsid(response, nsid, - nsid_size) != DNSLIB_EOK) { - diag("Adding valid nsid to response did not return DNSLIB_EOK"); + nsid_size) != KNOT_EOK) { + diag("Adding valid nsid to response did not return KNOT_EOK"); errors++; } @@ -408,14 +408,14 @@ static int test_response_add_nsid() return (errors == 0); } -static const int DNSLIB_RESPONSE2_TEST_COUNT = 14; +static const int KNOT_RESPONSE2_TEST_COUNT = 14; /*! This helper routine should report number of * scheduled tests for given parameters. */ static int knot_response2_tests_count(int argc, char *argv[]) { - return DNSLIB_RESPONSE2_TEST_COUNT; + return KNOT_RESPONSE2_TEST_COUNT; } diff --git a/src/dnslib/tests/dnslib/response2_tests.h b/src/dnslib/tests/dnslib/response2_tests.h index d9dbdfc97667ac1c05b1ba3093b8c54e6e8d1cb6..48782c5cdc8223438075e7bd5346b956e32424f1 100644 --- a/src/dnslib/tests/dnslib/response2_tests.h +++ b/src/dnslib/tests/dnslib/response2_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_RESPONSE2_TESTS_H_ -#define _KNOT_RESPONSE2_TESTS_H_ +#ifndef _KNOTDRESPONSE2_TESTS_H_ +#define _KNOTDRESPONSE2_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api response2_tests_api; -#endif /* _KNOT_RESPONSE2_TESTS_H_ */ +#endif /* _KNOTDRESPONSE2_TESTS_H_ */ diff --git a/src/dnslib/tests/dnslib/response_tests.c b/src/dnslib/tests/dnslib/response_tests.c index 7eeb63ac0d74aa84eecb7329fe19d616ffe50eaf..9118f2559ba0b29b170816e13f5620bb4c44e995 100644 --- a/src/dnslib/tests/dnslib/response_tests.c +++ b/src/dnslib/tests/dnslib/response_tests.c @@ -120,7 +120,7 @@ static knot_rdata_item_t ITEMS[ITEMS_COUNT] = static knot_rdata_t RDATA[RDATA_COUNT] = { {&ITEMS[0], 1, &RDATA[0]} }; static knot_rrset_t TMP = - { &DNAMES[0], DNSLIB_RRTYPE_NS, 1, 3600, &RDATA[0], NULL }; + { &DNAMES[0], KNOT_RRTYPE_NS, 1, 3600, &RDATA[0], NULL }; static knot_rrset_t *RESPONSE_RRSETS[RRSETS_COUNT] = { &TMP }; @@ -133,19 +133,19 @@ static test_response_t RESPONSES[RESPONSE_COUNT] = size_t wireformat_size(uint wire_type) { switch(wire_type) { - case DNSLIB_RDATA_WF_BYTE: + case KNOT_RDATA_WF_BYTE: return 1; break; - case DNSLIB_RDATA_WF_SHORT: + case KNOT_RDATA_WF_SHORT: return 2; break; - case DNSLIB_RDATA_WF_LONG: + case KNOT_RDATA_WF_LONG: return 4; break; - case DNSLIB_RDATA_WF_A: + case KNOT_RDATA_WF_A: return 4; break; - case DNSLIB_RDATA_WF_AAAA: + case KNOT_RDATA_WF_AAAA: return 16; break; default: /* unknown size */ @@ -168,19 +168,19 @@ size_t wireformat_size(uint wire_type) //size_t wireformat_size_n(uint16_t type, knot_rdata_item_t *items, // uint n) //{ -// if (type == DNSLIB_RRTYPE_RRSIG) { +// if (type == KNOT_RRTYPE_RRSIG) { // assert(n == 8); // uint8_t alg = ((uint8_t *)items[1].raw_data)[2]; // return dns_algorithm_sizes[alg]; // } -// if (type == DNSLIB_RRTYPE_DNSKEY) { +// if (type == KNOT_RRTYPE_DNSKEY) { // assert(n == 3); // uint8_t alg = ((uint8_t *)items[1].raw_data)[2]; // return dns_algorithm_sizes[alg]; // } -// if (type == DNSLIB_RRTYPE_DS) { +// if (type == KNOT_RRTYPE_DS) { // assert(n == 3); // uint8_t alg = ((uint8_t *)items[1].raw_data)[2]; // return dns_algorithm_sizes[alg]; @@ -272,9 +272,9 @@ static knot_rdata_t *load_response_rdata(uint16_t type, const char **src, * does not provide this) */ /* TODO the are more types with no length for sure ... */ - if (type != DNSLIB_RRTYPE_A && - type != DNSLIB_RRTYPE_NS && - type != DNSLIB_RRTYPE_AAAA) { + if (type != KNOT_RRTYPE_A && + type != KNOT_RRTYPE_NS && + type != KNOT_RRTYPE_AAAA) { if (!mem_read(&total_raw_data_length, sizeof(total_raw_data_length), src, src_size)) { knot_rdata_free(&rdata); @@ -292,9 +292,9 @@ static knot_rdata_t *load_response_rdata(uint16_t type, const char **src, * in the dump - of minor importance, however */ for (i = 0; i < desc->length; i++) { - if ((desc->wireformat[i] == DNSLIB_RDATA_WF_COMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_LITERAL_DNAME)) { + if ((desc->wireformat[i] == KNOT_RDATA_WF_COMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_UNCOMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_LITERAL_DNAME)) { /* Dnames have to be read label by label */ items[i].dname = NULL; uint8_t label_size = 0; @@ -374,7 +374,7 @@ static knot_rdata_t *load_response_rdata(uint16_t type, const char **src, #endif } else { if (desc->wireformat[i] == - DNSLIB_RDATA_WF_BINARYWITHLENGTH) { + KNOT_RDATA_WF_BINARYWITHLENGTH) { if (!mem_read(&raw_data_length, sizeof(raw_data_length), src, src_size)) { return NULL; @@ -423,7 +423,7 @@ static knot_rdata_t *load_response_rdata(uint16_t type, const char **src, */ if ((i != desc->length - 1) && desc->wireformat[i] != - DNSLIB_RDATA_WF_TEXT ) { + KNOT_RDATA_WF_TEXT ) { diag("I dont know how " "to parse this type: %d", type); @@ -433,7 +433,7 @@ static knot_rdata_t *load_response_rdata(uint16_t type, const char **src, total_raw_data_length - total_read; if (desc->wireformat[i] == - DNSLIB_RDATA_WF_TEXT) { + KNOT_RDATA_WF_TEXT) { break; } @@ -469,7 +469,7 @@ static knot_rdata_t *load_response_rdata(uint16_t type, const char **src, items[i].raw_data[0]); */ if (desc->zoneformat[i] == - DNSLIB_RDATA_ZF_ALGORITHM) { + KNOT_RDATA_ZF_ALGORITHM) { diag("alg in load:"); hex_print((char *)items[i].raw_data, @@ -1114,9 +1114,9 @@ int compare_rr_rdata(knot_rdata_t *rdata, ldns_rr *rr, for (int i = 0; i < rdata->count; i++) { /* check for ldns "descriptors" as well */ - if (desc->wireformat[i] == DNSLIB_RDATA_WF_COMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_LITERAL_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME) { + if (desc->wireformat[i] == KNOT_RDATA_WF_COMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_LITERAL_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_UNCOMPRESSED_DNAME) { if (rdata->items[i].dname->size != ldns_rdf_size(ldns_rr_rdf(rr, i))) { diag("%s", rdata->items[i].dname->name); @@ -1475,7 +1475,7 @@ static int test_response_to_wire(test_response_t **responses, for (int j = 0; j < responses[i]->arcount; j++) { if (responses[i]->additional[j]->type == - DNSLIB_RRTYPE_OPT) { + KNOT_RRTYPE_OPT) { parsed_opt = responses[i]->additional[j]; } } @@ -1537,7 +1537,7 @@ static int test_response_to_wire(test_response_t **responses, for (int j = 0; j < responses[i]->arcount; j++) { if (&(responses[i]->additional[j])) { if (responses[i]->additional[j]->type == - DNSLIB_RRTYPE_OPT) { + KNOT_RRTYPE_OPT) { continue; } if (knot_response_add_rrset_additional(resp, @@ -1842,14 +1842,14 @@ static int test_response_setters(uint type) return (errors == 0); } -static const int DNSLIB_RESPONSE_TEST_COUNT = 12; +static const int KNOT_RESPONSE_TEST_COUNT = 12; /*! This helper routine should report number of * scheduled tests for given parameters. */ static int knot_response_tests_count(int argc, char *argv[]) { - return DNSLIB_RESPONSE_TEST_COUNT; + return KNOT_RESPONSE_TEST_COUNT; } /*! Run all scheduled tests for given parameters. diff --git a/src/dnslib/tests/dnslib/response_tests.h b/src/dnslib/tests/dnslib/response_tests.h index fbc810e82f699dbca2d0eb627178317a2d1cf469..2e8e5f31113a3d818a75d6760cf11b713100f873 100644 --- a/src/dnslib/tests/dnslib/response_tests.h +++ b/src/dnslib/tests/dnslib/response_tests.h @@ -9,13 +9,13 @@ * - Response API * - \todo */ -#ifndef _KNOT_RESPONSE_TESTS_H_ -#define _KNOT_RESPONSE_TESTS_H_ +#ifndef _KNOTDRESPONSE_TESTS_H_ +#define _KNOTDRESPONSE_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api response_tests_api; -#endif /* _KNOT_RESPONSE_TESTS_H_ */ +#endif /* _KNOTDRESPONSE_TESTS_H_ */ diff --git a/src/dnslib/tests/dnslib/rrset_tests.c b/src/dnslib/tests/dnslib/rrset_tests.c index 9ccd17f6cdc25f47f6be406bc3d78e4736ed7a06..08775ddab238bb5fdcd9daa845152e7fb52628d9 100644 --- a/src/dnslib/tests/dnslib/rrset_tests.c +++ b/src/dnslib/tests/dnslib/rrset_tests.c @@ -108,17 +108,17 @@ static const struct test_domain }; static struct test_rrset test_rrsets[TEST_RRSETS] = { - { "example.com.", DNSLIB_RRTYPE_NS, DNSLIB_CLASS_IN, + { "example.com.", KNOT_RRTYPE_NS, KNOT_CLASS_IN, 3600, NULL, NULL }, - { "example2.com.", DNSLIB_RRTYPE_NS, DNSLIB_CLASS_IN, + { "example2.com.", KNOT_RRTYPE_NS, KNOT_CLASS_IN, 3600, NULL, NULL }, - { "example3.com.", DNSLIB_RRTYPE_NS, DNSLIB_CLASS_IN, + { "example3.com.", KNOT_RRTYPE_NS, KNOT_CLASS_IN, 3600, NULL, NULL }, - { "example.com.", DNSLIB_RRTYPE_NS, DNSLIB_CLASS_IN, + { "example.com.", KNOT_RRTYPE_NS, KNOT_CLASS_IN, 3600, NULL, NULL }, - { "example.com.", DNSLIB_RRTYPE_NS, DNSLIB_CLASS_IN, + { "example.com.", KNOT_RRTYPE_NS, KNOT_CLASS_IN, 3600, NULL, NULL }, - { "example.com.", DNSLIB_RRTYPE_NS, DNSLIB_CLASS_IN, + { "example.com.", KNOT_RRTYPE_NS, KNOT_CLASS_IN, 3600, NULL, NULL } }; @@ -167,9 +167,9 @@ static int fill_rdata_r(uint8_t *data, int max_size, uint16_t rrtype, int stored_size = 0; switch (desc->wireformat[i]) { - case DNSLIB_RDATA_WF_COMPRESSED_DNAME: - case DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME: - case DNSLIB_RDATA_WF_LITERAL_DNAME: + case KNOT_RDATA_WF_COMPRESSED_DNAME: + case KNOT_RDATA_WF_UNCOMPRESSED_DNAME: + case KNOT_RDATA_WF_LITERAL_DNAME: dname = knot_dname_new_from_wire( (uint8_t *)test_domains_ok[0].wire, test_domains_ok[0].size, NULL); @@ -180,7 +180,7 @@ static int fill_rdata_r(uint8_t *data, int max_size, uint16_t rrtype, domain = 1; size = knot_dname_size(dname); // note("Size of created domain name: %u", size); - assert(size < DNSLIB_MAX_RDATA_ITEM_SIZE); + assert(size < KNOT_MAX_RDATA_ITEM_SIZE); // store size of the domain name *(pos++) = size; // copy the domain name @@ -189,7 +189,7 @@ static int fill_rdata_r(uint8_t *data, int max_size, uint16_t rrtype, break; default: binary = 1; - size = rand() % DNSLIB_MAX_RDATA_ITEM_SIZE; + size = rand() % KNOT_MAX_RDATA_ITEM_SIZE; } if (binary) { @@ -238,7 +238,7 @@ static void create_rdata() knot_rdata_t *r; uint8_t *data = - malloc(sizeof(uint8_t) * DNSLIB_MAX_RDATA_WIRE_SIZE); + malloc(sizeof(uint8_t) * KNOT_MAX_RDATA_WIRE_SIZE); assert(data); @@ -247,8 +247,8 @@ static void create_rdata() r = knot_rdata_new(); /* from rdata tests */ - generate_rdata(data, DNSLIB_MAX_RDATA_WIRE_SIZE); - if (fill_rdata_r(data, DNSLIB_MAX_RDATA_WIRE_SIZE, + generate_rdata(data, KNOT_MAX_RDATA_WIRE_SIZE); + if (fill_rdata_r(data, KNOT_MAX_RDATA_WIRE_SIZE, test_rrsets[i].type, r) <= 0) { diag("Error creating rdata!"); @@ -799,14 +799,14 @@ static int test_rrset_deep_free() /*----------------------------------------------------------------------------*/ -static const int DNSLIB_RRSET_TEST_COUNT = 13; +static const int KNOT_RRSET_TEST_COUNT = 13; /*! This helper routine should report number of * scheduled tests for given parameters. */ static int knot_rrset_tests_count(int argc, char *argv[]) { - return DNSLIB_RRSET_TEST_COUNT; + return KNOT_RRSET_TEST_COUNT; } /*! Run all scheduled tests for given parameters. diff --git a/src/dnslib/tests/dnslib/rrset_tests.h b/src/dnslib/tests/dnslib/rrset_tests.h index 96d75bed5bdc12cd303dfd4fe4597b79547841f3..06dd642cc673484cd9be92619539d4eb8c7007a7 100644 --- a/src/dnslib/tests/dnslib/rrset_tests.h +++ b/src/dnslib/tests/dnslib/rrset_tests.h @@ -8,12 +8,12 @@ * Contains tests for: * - */ -#ifndef _KNOT_RRSET_TESTS_H_ -#define _KNOT_RRSET_TESTS_H_ +#ifndef _KNOTDRRSET_TESTS_H_ +#define _KNOTDRRSET_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api rrset_tests_api; -#endif /* _KNOT_RRSET_TESTS_H_ */ +#endif /* _KNOTDRRSET_TESTS_H_ */ diff --git a/src/dnslib/tests/dnslib/zone_tests.c b/src/dnslib/tests/dnslib/zone_tests.c index 737334e018f423fb248cec5701e42be184c52961..6ecd603b9a9c1c2bd1651076af3fbd708a5d5665 100644 --- a/src/dnslib/tests/dnslib/zone_tests.c +++ b/src/dnslib/tests/dnslib/zone_tests.c @@ -134,10 +134,10 @@ static int test_zone_add_node(knot_zone_t *zone, int nsec3) if ((res = ((nsec3) ? knot_zone_add_nsec3_node(zone, node, 0, 1) : knot_zone_add_node(zone, node, 0, 1))) != - DNSLIB_EBADZONE) { + KNOT_EBADZONE) { diag("zone: Inserting wrong node did not result in" "proper return value (%d instead of %d).", res, - DNSLIB_EBADZONE); + KNOT_EBADZONE); ++errors; } knot_node_free(&node, 0, 0); @@ -155,10 +155,10 @@ static int test_zone_add_node(knot_zone_t *zone, int nsec3) } if ((res = ((nsec3) ? knot_zone_add_nsec3_node(NULL, node, 0, 1) - : knot_zone_add_node(NULL, node, 0, 1))) != DNSLIB_EBADARG) { + : knot_zone_add_node(NULL, node, 0, 1))) != KNOT_EBADARG) { diag("zone: Inserting node to NULL zone did not result in" "proper return value (%d instead of %d)", res, - DNSLIB_EBADARG); + KNOT_EBADARG); ++errors; } @@ -168,10 +168,10 @@ static int test_zone_add_node(knot_zone_t *zone, int nsec3) note("Inserting NULL node...\n"); if ((res = ((nsec3) ? knot_zone_add_nsec3_node(zone, NULL, 0, 1) - : knot_zone_add_node(zone, NULL, 0, 1))) != DNSLIB_EBADARG) { + : knot_zone_add_node(zone, NULL, 0, 1))) != KNOT_EBADARG) { diag("zone: Inserting NULL node to zone did not result in" "proper return value (%d instead of %d)", res, - DNSLIB_EBADARG); + KNOT_EBADARG); ++errors; } @@ -187,10 +187,10 @@ static int test_zone_add_node(knot_zone_t *zone, int nsec3) //note("Apex again"); if ((res = knot_zone_add_node(zone, node, 0, 1)) != - DNSLIB_EBADZONE) { + KNOT_EBADZONE) { diag("zone: Inserting zone apex again did not result in" "proper return value (%d instead of -2)", - DNSLIB_EBADZONE); + KNOT_EBADZONE); ++errors; } @@ -505,32 +505,32 @@ static int test_zone_shallow_copy() knot_node_new(apex_dname, NULL, 0); assert(apex_node); lives_ok({ - if (knot_zone_contents_shallow_copy(NULL, NULL) != DNSLIB_EBADARG) { + if (knot_zone_contents_shallow_copy(NULL, NULL) != KNOT_EBADARG) { diag("Calling zone_shallow_copy with NULL " - "arguments did not return DNSLIB_EBADARG!"); + "arguments did not return KNOT_EBADARG!"); errors++; } lived = 1; lived = 0; knot_zone_contents_t *zone = knot_zone_contents_new(apex_node, 0, 1, 0); - if (knot_zone_contents_shallow_copy(zone, NULL) != DNSLIB_EBADARG) { + if (knot_zone_contents_shallow_copy(zone, NULL) != KNOT_EBADARG) { diag("Calling zone_shallow_copy with NULL destination " - "zone argument did not return DNSLIB_EBADARG!"); + "zone argument did not return KNOT_EBADARG!"); errors++; } lived = 1; lived = 0; - if (knot_zone_contents_shallow_copy(NULL, &zone) != DNSLIB_EBADARG) { + if (knot_zone_contents_shallow_copy(NULL, &zone) != KNOT_EBADARG) { diag("Calling zone_shallow_copy with NULL source " - "zone argument did not return DNSLIB_EBADARG!"); + "zone argument did not return KNOT_EBADARG!"); errors++; } lived = 1; lived = 0; - if (knot_zone_contents_shallow_copy(zone, &zone) != DNSLIB_EBADARG) { + if (knot_zone_contents_shallow_copy(zone, &zone) != KNOT_EBADARG) { diag("Calling zone_shallow_copy with identical source " - "and destination zone did not return DNSLIB_EBADARG!"); + "and destination zone did not return KNOT_EBADARG!"); errors++; } lived = 1; @@ -554,7 +554,7 @@ static int test_zone_shallow_copy() return 0; } - if (knot_zone_contents_add_node(from, node, 1, 1, 1) != DNSLIB_EOK) { + if (knot_zone_contents_add_node(from, node, 1, 1, 1) != KNOT_EOK) { diag("zone: Could not add node. %s", knot_dname_to_str(node->owner)); // return 0; @@ -564,7 +564,7 @@ static int test_zone_shallow_copy() /* Make a copy of zone */ knot_zone_contents_t *to = NULL; int ret = 0; - if ((ret = knot_zone_contents_shallow_copy(from, &to) != DNSLIB_EOK)) { + if ((ret = knot_zone_contents_shallow_copy(from, &to) != KNOT_EOK)) { diag("Could not copy zone! %s", knot_strerror2(ret)); return 0; } @@ -751,14 +751,14 @@ static int test_zone_shallow_copy() // return (*zone == NULL); //} -static const int DNSLIB_ZONE_TEST_COUNT = 10; +static const int KNOT_ZONE_TEST_COUNT = 10; /*! This helper routine should report number of * scheduled tests for given parameters. */ static int knot_zone_tests_count(int argc, char *argv[]) { - return DNSLIB_ZONE_TEST_COUNT; + return KNOT_ZONE_TEST_COUNT; } /*! Run all scheduled tests for given parameters. diff --git a/src/dnslib/tests/dnslib/zone_tests.h b/src/dnslib/tests/dnslib/zone_tests.h index 6b57dc7ec8e3022ef87dd4998e9bc98d87b4c48a..131aa18dcaa770a0c729ac6cbdf17ec607c63387 100644 --- a/src/dnslib/tests/dnslib/zone_tests.h +++ b/src/dnslib/tests/dnslib/zone_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_ZONE_TESTS_H_ -#define _KNOT_ZONE_TESTS_H_ +#ifndef _KNOTDZONE_TESTS_H_ +#define _KNOTDZONE_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api zone_tests_api; -#endif /* _KNOT_ZONE_TESTS_H_ */ +#endif /* _KNOTDZONE_TESTS_H_ */ diff --git a/src/dnslib/tests/dnslib/zonedb_tests.h b/src/dnslib/tests/dnslib/zonedb_tests.h index 2499dad25edf412c158b56f747e1f18816ef0624..dae385b9176dd7904e1668dce372d5482495d56e 100644 --- a/src/dnslib/tests/dnslib/zonedb_tests.h +++ b/src/dnslib/tests/dnslib/zonedb_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_ZONEDB_TESTS_H_ -#define _KNOT_ZONEDB_TESTS_H_ +#ifndef _KNOTDZONEDB_TESTS_H_ +#define _KNOTDZONEDB_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api zonedb_tests_api; -#endif /* _KNOT_ZONEDB_TESTS_H_ */ +#endif /* _KNOTDZONEDB_TESTS_H_ */ diff --git a/src/dnslib/tests/realdata/dnslib/dname_tests_realdata.c b/src/dnslib/tests/realdata/dnslib/dname_tests_realdata.c index 42676831a76855ee8072562ee90a1f521fe7a776..dc091ee7ffc8e584c3e45d854f8a605359104c02 100644 --- a/src/dnslib/tests/realdata/dnslib/dname_tests_realdata.c +++ b/src/dnslib/tests/realdata/dnslib/dname_tests_realdata.c @@ -340,14 +340,14 @@ static int test_dname_is_fqdn(const list *dname_list) // return (errors == 0); //} -static const int DNSLIB_DNAME_TEST_COUNT = 4; +static const int KNOT_DNAME_TEST_COUNT = 4; /*! This helper routine should report number of * scheduled tests for given parameters. */ static int knot_dname_tests_count(int argc, char *argv[]) { - return DNSLIB_DNAME_TEST_COUNT; + return KNOT_DNAME_TEST_COUNT; } /*! Run all scheduled tests for given parameters. diff --git a/src/dnslib/tests/realdata/dnslib/dname_tests_realdata.h b/src/dnslib/tests/realdata/dnslib/dname_tests_realdata.h index 6f1281792808279b20ac7c082ebc447db30e015d..d1dc923f8cace941bd1364dbcc38fa782f4b6e68 100644 --- a/src/dnslib/tests/realdata/dnslib/dname_tests_realdata.h +++ b/src/dnslib/tests/realdata/dnslib/dname_tests_realdata.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_DNAME_TESTS_H_ -#define _KNOT_DNAME_TESTS_H_ +#ifndef _KNOTDDNAME_TESTS_H_ +#define _KNOTDDNAME_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api dname_tests_api; -#endif /* _KNOT_DNAME_TESTS_H_ */ +#endif /* _KNOTDDNAME_TESTS_H_ */ diff --git a/src/dnslib/tests/realdata/dnslib/edns_tests_realdata.c b/src/dnslib/tests/realdata/dnslib/edns_tests_realdata.c index d5fb754a6f7c0ce7346e34533efc8d05de01454a..fcf0c1dd1e7438a0d4b1391e5a017cb0b84d474a 100644 --- a/src/dnslib/tests/realdata/dnslib/edns_tests_realdata.c +++ b/src/dnslib/tests/realdata/dnslib/edns_tests_realdata.c @@ -152,7 +152,7 @@ unit_api edns_tests_api = { // test_edns_t *test_edns) //{ // if (knot_edns_do(edns) != -// (test_edns->flags & DNSLIB_EDNS_DO_MASK)) { +// (test_edns->flags & KNOT_EDNS_DO_MASK)) { // return 0; // } else { // return 1; @@ -474,14 +474,14 @@ unit_api edns_tests_api = { // return 1; //} -static const int DNSLIB_EDNS_TESTS_COUNT = 0; +static const int KNOT_EDNS_TESTS_COUNT = 0; ///*! This helper routine should report number of // * scheduled tests for given parameters. // */ static int knot_edns_tests_count(int argc, char *argv[]) { - return DNSLIB_EDNS_TESTS_COUNT; + return KNOT_EDNS_TESTS_COUNT; } ///*! Run all scheduled tests for given parameters. diff --git a/src/dnslib/tests/realdata/dnslib/edns_tests_realdata.h b/src/dnslib/tests/realdata/dnslib/edns_tests_realdata.h index 09aa74ec21b2e635ad065cb3bfe6df57217b4610..95519be101bde07c0dddab46b7e5fb6bc41f7f3b 100644 --- a/src/dnslib/tests/realdata/dnslib/edns_tests_realdata.h +++ b/src/dnslib/tests/realdata/dnslib/edns_tests_realdata.h @@ -8,12 +8,12 @@ * Contains tests for: * - ENDS API */ -#ifndef _KNOT_EDNS_TESTS_H_ -#define _KNOT_EDNS_TESTS_H_ +#ifndef _KNOTDEDNS_TESTS_H_ +#define _KNOTDEDNS_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api edns_tests_api; -#endif /* _KNOT_EDNS_TESTS_H_ */ +#endif /* _KNOTDEDNS_TESTS_H_ */ diff --git a/src/dnslib/tests/realdata/dnslib/node_tests_realdata.c b/src/dnslib/tests/realdata/dnslib/node_tests_realdata.c index 31cbe4f3ba115bb2f3e5a872579080ee2abe0158..ff02d174e95149ca3d21b241ca1e429886b784af 100644 --- a/src/dnslib/tests/realdata/dnslib/node_tests_realdata.c +++ b/src/dnslib/tests/realdata/dnslib/node_tests_realdata.c @@ -319,14 +319,14 @@ static int test_node_add_rrset(list *rrset_list) // return (errors == 0); //} -static const int DNSLIB_NODE_TEST_COUNT = 2; +static const int KNOT_NODE_TEST_COUNT = 2; /*! This helper routine should report number of * scheduled tests for given parameters. */ static int knot_node_tests_count(int argc, char *argv[]) { - return DNSLIB_NODE_TEST_COUNT; + return KNOT_NODE_TEST_COUNT; } /*! Run all scheduled tests for given parameters. diff --git a/src/dnslib/tests/realdata/dnslib/node_tests_realdata.h b/src/dnslib/tests/realdata/dnslib/node_tests_realdata.h index eebaf6934b8c040a8740111b92561f45c4b09b95..fca5ed7d19f4ac461bb52ec8493bf7b7f44d8f53 100644 --- a/src/dnslib/tests/realdata/dnslib/node_tests_realdata.h +++ b/src/dnslib/tests/realdata/dnslib/node_tests_realdata.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_NODE_TESTS_H_ -#define _KNOT_NODE_TESTS_H_ +#ifndef _KNOTDNODE_TESTS_H_ +#define _KNOTDNODE_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api node_tests_api; -#endif /* _KNOT_NODE_TESTS_H_ */ +#endif /* _KNOTDNODE_TESTS_H_ */ diff --git a/src/dnslib/tests/realdata/dnslib/packet_tests_realdata.c b/src/dnslib/tests/realdata/dnslib/packet_tests_realdata.c index 72e0061ab96dbc0bc505219a1169eb6d927ec0fd..8194b404db7857ebb5277eff70793348c163a225 100644 --- a/src/dnslib/tests/realdata/dnslib/packet_tests_realdata.c +++ b/src/dnslib/tests/realdata/dnslib/packet_tests_realdata.c @@ -206,7 +206,7 @@ knot_packet_t *packet_from_test_response(test_response_t *test_packet) for (int j = 0; j < test_packet->arcount; j++) { if (test_packet->additional[j]->type == - DNSLIB_RRTYPE_OPT) { + KNOT_RRTYPE_OPT) { parsed_opt = rrset_from_test_rrset( test_packet->additional[j]); @@ -225,7 +225,7 @@ knot_packet_t *packet_from_test_response(test_response_t *test_packet) } knot_packet_t *packet = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); assert(packet); knot_packet_set_max_size(packet, 1024 * 10); @@ -272,7 +272,7 @@ knot_packet_t *packet_from_test_response(test_response_t *test_packet) for (int j = 0; j < test_packet->arcount; j++) { if (&(test_packet->additional[j])) { if (test_packet->additional[j]->type == - DNSLIB_RRTYPE_OPT) { + KNOT_RRTYPE_OPT) { continue; } packet->additional[packet->ar_rrsets++] = @@ -292,12 +292,12 @@ static int test_packet_parse_from_wire(list raw_response_list) WALK_LIST(n ,raw_response_list) { test_raw_packet_t *raw_packet = (test_raw_packet_t *)n; knot_packet_t *packet = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); int ret = 0; if ((ret = knot_packet_parse_from_wire(packet, raw_packet->data, raw_packet->size, 0)) != - DNSLIB_EOK) { + KNOT_EOK) { diag("Warning: could not parse wire! " "(might be caused by malformed dump) - " "dnslib error: %s", knot_strerror2(ret)); @@ -377,12 +377,12 @@ static int test_packet_to_wire(list raw_response_list) WALK_LIST(n, raw_response_list) { /* Create packet from raw response. */ knot_packet_t *packet = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); assert(packet); test_raw_packet_t *raw_packet = (test_raw_packet_t *)n; if (knot_packet_parse_from_wire(packet, raw_packet->data, raw_packet->size, 0) != - DNSLIB_EOK) { + KNOT_EOK) { diag("Warning: could not parse wire! " "(might be caused be malformed dump)"); continue; @@ -390,7 +390,7 @@ static int test_packet_to_wire(list raw_response_list) /* Use this packet to create wire */ uint8_t *wire = NULL; size_t size = 0; - if (knot_packet_to_wire(packet, &wire ,&size) != DNSLIB_EOK) { + if (knot_packet_to_wire(packet, &wire ,&size) != KNOT_EOK) { diag("Could not convert packet to wire"); } /* Create ldns packet from created wire */ @@ -424,11 +424,11 @@ static int test_packet_to_wire(list raw_response_list) #endif } -static const uint DNSLIB_PACKET_TEST_COUNT = 2; +static const uint KNOT_PACKET_TEST_COUNT = 2; static int packet_tests_count(int argc, char *argv[]) { - return DNSLIB_PACKET_TEST_COUNT; + return KNOT_PACKET_TEST_COUNT; } static int packet_tests_run(int argc, char *argv[]) diff --git a/src/dnslib/tests/realdata/dnslib/packet_tests_realdata.h b/src/dnslib/tests/realdata/dnslib/packet_tests_realdata.h index 91b9116d3dda7fb7b5b64a7d913f134ac69cdc47..e1fee11f04714f9a93a9bbf30f748a0635ec4f41 100644 --- a/src/dnslib/tests/realdata/dnslib/packet_tests_realdata.h +++ b/src/dnslib/tests/realdata/dnslib/packet_tests_realdata.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_PACKET_REALDATA_TESTS_H_ -#define _KNOT_PACKET_REALDATA_TESTS_H_ +#ifndef _KNOTDPACKET_REALDATA_TESTS_H_ +#define _KNOTDPACKET_REALDATA_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api packet_tests_api; -#endif /* _KNOT_PACKET_REALDATA_TESTS_H_ */ +#endif /* _KNOTDPACKET_REALDATA_TESTS_H_ */ diff --git a/src/dnslib/tests/realdata/dnslib/rdata_tests_realdata.c b/src/dnslib/tests/realdata/dnslib/rdata_tests_realdata.c index 3e52ee0dd70d93b2bcafc428cbb3c5aa43300582..2d1a4b98faf23b788d01d03198b004e9c7294e34 100644 --- a/src/dnslib/tests/realdata/dnslib/rdata_tests_realdata.c +++ b/src/dnslib/tests/realdata/dnslib/rdata_tests_realdata.c @@ -51,9 +51,9 @@ static int check_rdata(const knot_rdata_t *rdata, uint size = 0; switch (desc->wireformat[i]) { - case DNSLIB_RDATA_WF_COMPRESSED_DNAME: - case DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME: - case DNSLIB_RDATA_WF_LITERAL_DNAME: + case KNOT_RDATA_WF_COMPRESSED_DNAME: + case KNOT_RDATA_WF_UNCOMPRESSED_DNAME: + case KNOT_RDATA_WF_LITERAL_DNAME: size = knot_dname_size(knot_rdata_item( rdata, i)->dname); if (check_domain_name(rdata->items[i].dname, @@ -237,14 +237,14 @@ static int test_rdata_get_item(list rdata_list) // int errors = 0; // // generate some random data -// uint8_t data[DNSLIB_MAX_RDATA_WIRE_SIZE]; -// generate_rdata(data, DNSLIB_MAX_RDATA_WIRE_SIZE); +// uint8_t data[KNOT_MAX_RDATA_WIRE_SIZE]; +// generate_rdata(data, KNOT_MAX_RDATA_WIRE_SIZE); -// for (int i = 0; i <= DNSLIB_RRTYPE_LAST; ++i) { +// for (int i = 0; i <= KNOT_RRTYPE_LAST; ++i) { // rdata = knot_rdata_new(); // int size = -// fill_rdata(data, DNSLIB_MAX_RDATA_WIRE_SIZE, i, rdata); +// fill_rdata(data, KNOT_MAX_RDATA_WIRE_SIZE, i, rdata); // if (size < 0) { // ++errors; @@ -264,11 +264,11 @@ static int test_rdata_get_item(list rdata_list) // for (int x = 0; x < desc->length; x++) { // if (desc->wireformat[x] == -// DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME || +// KNOT_RDATA_WF_UNCOMPRESSED_DNAME || // desc->wireformat[x] == -// DNSLIB_RDATA_WF_COMPRESSED_DNAME || +// KNOT_RDATA_WF_COMPRESSED_DNAME || // desc->wireformat[x] == -// DNSLIB_RDATA_WF_LITERAL_DNAME) { +// KNOT_RDATA_WF_LITERAL_DNAME) { // knot_dname_free(&(rdata->items[x].dname)); // } // } @@ -282,14 +282,14 @@ static int test_rdata_get_item(list rdata_list) /*----------------------------------------------------------------------------*/ -static const int DNSLIB_RDATA_TEST_COUNT = 2; +static const int KNOT_RDATA_TEST_COUNT = 2; /*! This helper routine should report number of * scheduled tests for given parameters. */ static int knot_rdata_tests_count(int argc, char *argv[]) { - return DNSLIB_RDATA_TEST_COUNT; + return KNOT_RDATA_TEST_COUNT; } /*! Run all scheduled tests for given parameters. diff --git a/src/dnslib/tests/realdata/dnslib/rdata_tests_realdata.h b/src/dnslib/tests/realdata/dnslib/rdata_tests_realdata.h index d28ddb7e630428d3b63de55a13f7e8c822e6fedd..579754a96e840a0add6c5f836c69f37d88087a09 100644 --- a/src/dnslib/tests/realdata/dnslib/rdata_tests_realdata.h +++ b/src/dnslib/tests/realdata/dnslib/rdata_tests_realdata.h @@ -26,12 +26,12 @@ * e.g. test whether knot_rdata_get_item() returns NULL when passed an * illegal position, etc. */ -#ifndef _KNOT_RDATA_TESTS_H_ -#define _KNOT_RDATA_TESTS_H_ +#ifndef _KNOTDRDATA_TESTS_H_ +#define _KNOTDRDATA_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api rdata_tests_api; -#endif /* _KNOT_RDATA_TESTS_H_ */ +#endif /* _KNOTDRDATA_TESTS_H_ */ diff --git a/src/dnslib/tests/realdata/dnslib/response2_tests_realdata.c b/src/dnslib/tests/realdata/dnslib/response2_tests_realdata.c index dd8f7e4488530468dc6a72444d04f80d0a54ca4e..c0aeb261ca5bc4b40e4614127d1a86699b225b1d 100644 --- a/src/dnslib/tests/realdata/dnslib/response2_tests_realdata.c +++ b/src/dnslib/tests/realdata/dnslib/response2_tests_realdata.c @@ -47,14 +47,14 @@ static int test_response_init_from_query(list query_list) node *n = NULL; WALK_LIST(n, query_list) { knot_packet_t *response = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); assert(response); knot_packet_t *query = packet_from_test_response((test_response_t *)n); assert(query); knot_packet_set_max_size(response, 1024 * 10); if (knot_response2_init_from_query(response, - query) != DNSLIB_EOK) { + query) != KNOT_EOK) { diag("Could not init response from query!"); errors++; } @@ -70,13 +70,13 @@ static int test_response_init_from_query(list query_list) // node *n = NULL; // WALK_LIST(n, query_list) { // knot_packet_t *response = -// knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); +// knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); // assert(response); // knot_opt_rr_t *opt = // opt_from_test_opt((test_opt_t *)n); // assert(query); // if (knot_response2_add_opt(response, -// opt, 1)!= DNSLIB_EOK) { +// opt, 1)!= KNOT_EOK) { // diag("Could not add OPT RR to response!"); // errors++; // } @@ -98,18 +98,18 @@ static int test_response_add_generic(int (*func)(knot_packet_t *, node *n = NULL; WALK_LIST(n, rrset_list) { knot_packet_t *response = - knot_packet_new(DNSLIB_PACKET_PREALLOC_RESPONSE); + knot_packet_new(KNOT_PACKET_PREALLOC_RESPONSE); assert(response); knot_packet_set_max_size(response, - DNSLIB_PACKET_PREALLOC_RESPONSE * 100); - assert(knot_response2_init(response) == DNSLIB_EOK); + KNOT_PACKET_PREALLOC_RESPONSE * 100); + assert(knot_response2_init(response) == KNOT_EOK); knot_rrset_t *rrset = rrset_from_test_rrset((test_rrset_t *)n); assert(rrset); int ret = 0; - if ((ret = func(response, rrset, 0, 1, 0)) != DNSLIB_EOK) { + if ((ret = func(response, rrset, 0, 1, 0)) != KNOT_EOK) { diag("Could not add RRSet to response! Returned: %d", ret); diag("(owner: %s type %s)", @@ -138,11 +138,11 @@ static void test_response_add_rrset(list rrset_list) "response: add additional rrset"); } -static const uint DNSLIB_RESPONSE2_TEST_COUNT = 4; +static const uint KNOT_RESPONSE2_TEST_COUNT = 4; static int response2_tests_count(int argc, char *argv[]) { - return DNSLIB_RESPONSE2_TEST_COUNT; + return KNOT_RESPONSE2_TEST_COUNT; } static int response2_tests_run(int argc, char *argv[]) diff --git a/src/dnslib/tests/realdata/dnslib/response2_tests_realdata.h b/src/dnslib/tests/realdata/dnslib/response2_tests_realdata.h index d693e26a7ad57a92048e4208c2767730b3b60fe3..727c88123e9260e948760a94a4bd96e9563e1980 100644 --- a/src/dnslib/tests/realdata/dnslib/response2_tests_realdata.h +++ b/src/dnslib/tests/realdata/dnslib/response2_tests_realdata.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_PACKET_RESPONSE2_TESTS_H_ -#define _KNOT_PACKET_RESPONSE2_TESTS_H_ +#ifndef _KNOTDPACKET_RESPONSE2_TESTS_H_ +#define _KNOTDPACKET_RESPONSE2_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api response2_tests_api; -#endif /* _KNOT_PACKET_RESPONSE2_TESTS_H_ */ +#endif /* _KNOTDPACKET_RESPONSE2_TESTS_H_ */ diff --git a/src/dnslib/tests/realdata/dnslib/response_tests_realdata.c b/src/dnslib/tests/realdata/dnslib/response_tests_realdata.c index 35fa05b377db7d44b7166d9894b39bf837c4fe12..f37284cd48059c9bd7a0f0cc9881c2e27825b440 100644 --- a/src/dnslib/tests/realdata/dnslib/response_tests_realdata.c +++ b/src/dnslib/tests/realdata/dnslib/response_tests_realdata.c @@ -398,9 +398,9 @@ int compare_rr_rdata(knot_rdata_t *rdata, ldns_rr *rr, for (int i = 0; i < rdata->count; i++) { /* check for ldns "descriptors" as well */ - if (desc->wireformat[i] == DNSLIB_RDATA_WF_COMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_LITERAL_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME) { + if (desc->wireformat[i] == KNOT_RDATA_WF_COMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_LITERAL_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_UNCOMPRESSED_DNAME) { if (rdata->items[i].dname->size != ldns_rdf_size(ldns_rr_rdf(rr, i))) { diag("%s", rdata->items[i].dname->name); @@ -760,7 +760,7 @@ static int test_response_to_wire(list response_list, for (int j = 0; j < test_response->arcount; j++) { if (test_response->additional[j]->type == - DNSLIB_RRTYPE_OPT) { + KNOT_RRTYPE_OPT) { parsed_opt = rrset_from_test_rrset(test_response->additional[j]); } @@ -821,7 +821,7 @@ static int test_response_to_wire(list response_list, for (int j = 0; j < test_response->arcount; j++) { if (&(test_response->additional[j])) { if (test_response->additional[j]->type == - DNSLIB_RRTYPE_OPT) { + KNOT_RRTYPE_OPT) { continue; } if (knot_response_add_rrset_additional(resp, @@ -904,11 +904,11 @@ static int test_response_to_wire(list response_list, return (errors == 0); } -static const int DNSLIB_RESPONSE_TEST_COUNT = 4; +static const int KNOT_RESPONSE_TEST_COUNT = 4; int knot_response_tests_count(int argc, char *argv[]) { - return DNSLIB_RESPONSE_TEST_COUNT; + return KNOT_RESPONSE_TEST_COUNT; } int knot_response_tests_run(int argc, char *argv[]) diff --git a/src/dnslib/tests/realdata/dnslib/response_tests_realdata.h b/src/dnslib/tests/realdata/dnslib/response_tests_realdata.h index fbc810e82f699dbca2d0eb627178317a2d1cf469..2e8e5f31113a3d818a75d6760cf11b713100f873 100644 --- a/src/dnslib/tests/realdata/dnslib/response_tests_realdata.h +++ b/src/dnslib/tests/realdata/dnslib/response_tests_realdata.h @@ -9,13 +9,13 @@ * - Response API * - \todo */ -#ifndef _KNOT_RESPONSE_TESTS_H_ -#define _KNOT_RESPONSE_TESTS_H_ +#ifndef _KNOTDRESPONSE_TESTS_H_ +#define _KNOTDRESPONSE_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api response_tests_api; -#endif /* _KNOT_RESPONSE_TESTS_H_ */ +#endif /* _KNOTDRESPONSE_TESTS_H_ */ diff --git a/src/dnslib/tests/realdata/dnslib/rrset_tests_realdata.c b/src/dnslib/tests/realdata/dnslib/rrset_tests_realdata.c index 26d67802493e2db2bb1dc2d63d6170c73a0a9c5d..b60889801206d2c8e4329a3eadc0bba99093d5ff 100644 --- a/src/dnslib/tests/realdata/dnslib/rrset_tests_realdata.c +++ b/src/dnslib/tests/realdata/dnslib/rrset_tests_realdata.c @@ -79,9 +79,9 @@ knot_rrset_t *rrset_from_test_rrset(const test_rrset_t *test_rrset) } // diag("Rdata type: %s\n", knot_rrtype_to_string(test_rrset->type)); for (int i = 0; i < desc->length; i++) { - if (desc->wireformat[i] == DNSLIB_RDATA_WF_COMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_LITERAL_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME) { + if (desc->wireformat[i] == KNOT_RDATA_WF_COMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_LITERAL_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_UNCOMPRESSED_DNAME) { // diag("%p\n", test_rdata->items[i].raw_data); assert(test_rdata->items[i].type == TEST_ITEM_DNAME); rdata->items[i].dname = @@ -171,9 +171,9 @@ int check_rrset(const knot_rrset_t *rrset, WALK_LIST(n, test_rrset->rdata_list) { test_rdata_t *test_rdata = (test_rdata_t *)n; for (int i = 0; i < desc->length; i++) { - if (desc->wireformat[i] == DNSLIB_RDATA_WF_COMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_LITERAL_DNAME) { + if (desc->wireformat[i] == KNOT_RDATA_WF_COMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_UNCOMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_LITERAL_DNAME) { errors += check_domain_name(tmp_rdata->items[i].dname, test_rdata->items[i].dname); } else { @@ -243,14 +243,14 @@ static int test_rrset_add_rdata(list rrset_list) return (errors == 0); } -static const int DNSLIB_RRSET_TEST_COUNT = 2; +static const int KNOT_RRSET_TEST_COUNT = 2; /*! This helper routine should report number of * scheduled tests for given parameters. */ static int knot_rrset_tests_count(int argc, char *argv[]) { - return DNSLIB_RRSET_TEST_COUNT; + return KNOT_RRSET_TEST_COUNT; } /*! Run all scheduled tests for given parameters. diff --git a/src/dnslib/tests/realdata/dnslib/rrset_tests_realdata.h b/src/dnslib/tests/realdata/dnslib/rrset_tests_realdata.h index 96d75bed5bdc12cd303dfd4fe4597b79547841f3..06dd642cc673484cd9be92619539d4eb8c7007a7 100644 --- a/src/dnslib/tests/realdata/dnslib/rrset_tests_realdata.h +++ b/src/dnslib/tests/realdata/dnslib/rrset_tests_realdata.h @@ -8,12 +8,12 @@ * Contains tests for: * - */ -#ifndef _KNOT_RRSET_TESTS_H_ -#define _KNOT_RRSET_TESTS_H_ +#ifndef _KNOTDRRSET_TESTS_H_ +#define _KNOTDRRSET_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api rrset_tests_api; -#endif /* _KNOT_RRSET_TESTS_H_ */ +#endif /* _KNOTDRRSET_TESTS_H_ */ diff --git a/src/dnslib/tests/realdata/dnslib/zone_tests_realdata.c b/src/dnslib/tests/realdata/dnslib/zone_tests_realdata.c index 8697eef88d831aeb86f152364650d190da019648..edecbbc94dfe42fdb178db633a7f51c9b6465f1c 100644 --- a/src/dnslib/tests/realdata/dnslib/zone_tests_realdata.c +++ b/src/dnslib/tests/realdata/dnslib/zone_tests_realdata.c @@ -110,10 +110,10 @@ static int test_zone_create(list node_list) // if ((res = ((nsec3) ? knot_zone_add_nsec3_node(zone, node) // : knot_zone_add_node(zone, node))) != -// DNSLIB_EBADZONE) { +// KNOT_EBADZONE) { // diag("zone: Inserting wrong node did not result in" // "proper return value (%d instead of %d).", res, -// DNSLIB_EBADZONE); +// KNOT_EBADZONE); // ++errors; // } // knot_node_free(&node, 0); @@ -261,14 +261,14 @@ static int test_zone_create(list node_list) // return (errors == 0); //} -static const int DNSLIB_ZONE_TEST_COUNT = 1; +static const int KNOT_ZONE_TEST_COUNT = 1; /*! This helper routine should report number of * scheduled tests for given parameters. */ static int knot_zone_tests_count(int argc, char *argv[]) { - return DNSLIB_ZONE_TEST_COUNT; + return KNOT_ZONE_TEST_COUNT; } /*! Run all scheduled tests for given parameters. diff --git a/src/dnslib/tests/realdata/dnslib/zone_tests_realdata.h b/src/dnslib/tests/realdata/dnslib/zone_tests_realdata.h index 6b57dc7ec8e3022ef87dd4998e9bc98d87b4c48a..131aa18dcaa770a0c729ac6cbdf17ec607c63387 100644 --- a/src/dnslib/tests/realdata/dnslib/zone_tests_realdata.h +++ b/src/dnslib/tests/realdata/dnslib/zone_tests_realdata.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_ZONE_TESTS_H_ -#define _KNOT_ZONE_TESTS_H_ +#ifndef _KNOTDZONE_TESTS_H_ +#define _KNOTDZONE_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api zone_tests_api; -#endif /* _KNOT_ZONE_TESTS_H_ */ +#endif /* _KNOTDZONE_TESTS_H_ */ diff --git a/src/dnslib/tests/realdata/dnslib/zonedb_tests_realdata.h b/src/dnslib/tests/realdata/dnslib/zonedb_tests_realdata.h index 2499dad25edf412c158b56f747e1f18816ef0624..dae385b9176dd7904e1668dce372d5482495d56e 100644 --- a/src/dnslib/tests/realdata/dnslib/zonedb_tests_realdata.h +++ b/src/dnslib/tests/realdata/dnslib/zonedb_tests_realdata.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_ZONEDB_TESTS_H_ -#define _KNOT_ZONEDB_TESTS_H_ +#ifndef _KNOTDZONEDB_TESTS_H_ +#define _KNOTDZONEDB_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api zonedb_tests_api; -#endif /* _KNOT_ZONEDB_TESTS_H_ */ +#endif /* _KNOTDZONEDB_TESTS_H_ */ diff --git a/src/dnslib/tests/realdata/dnslib_tests_loader_realdata.c b/src/dnslib/tests/realdata/dnslib_tests_loader_realdata.c index 860e91eaf65d54863f82cc4161d0187264da129f..5580ad7032e7197246374dc438fd8f539afbdb33 100644 --- a/src/dnslib/tests/realdata/dnslib_tests_loader_realdata.c +++ b/src/dnslib/tests/realdata/dnslib_tests_loader_realdata.c @@ -81,19 +81,19 @@ static int load_raw_packets(test_data_t *data, uint32_t *count, size_t wireformat_size_load(uint wire_type) { switch(wire_type) { - case DNSLIB_RDATA_WF_BYTE: + case KNOT_RDATA_WF_BYTE: return 1; break; - case DNSLIB_RDATA_WF_SHORT: + case KNOT_RDATA_WF_SHORT: return 2; break; - case DNSLIB_RDATA_WF_LONG: + case KNOT_RDATA_WF_LONG: return 4; break; - case DNSLIB_RDATA_WF_A: + case KNOT_RDATA_WF_A: return 4; break; - case DNSLIB_RDATA_WF_AAAA: + case KNOT_RDATA_WF_AAAA: return 16; break; default: /* unknown size */ @@ -348,9 +348,9 @@ static test_rdata_t *load_response_rdata(uint16_t type, */ /* TODO the are more types with no length for sure ... */ - if (type != DNSLIB_RRTYPE_A && - type != DNSLIB_RRTYPE_NS && - type != DNSLIB_RRTYPE_AAAA) { + if (type != KNOT_RRTYPE_A && + type != KNOT_RRTYPE_NS && + type != KNOT_RRTYPE_AAAA) { if (!mem_read(&total_raw_data_length, sizeof(total_raw_data_length), src, src_size)) { free(rdata); @@ -369,9 +369,9 @@ static test_rdata_t *load_response_rdata(uint16_t type, * in the dump - of minor importance, however */ for (i = 0; i < desc->length; i++) { - if ((desc->wireformat[i] == DNSLIB_RDATA_WF_COMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_LITERAL_DNAME)) { + if ((desc->wireformat[i] == KNOT_RDATA_WF_COMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_UNCOMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_LITERAL_DNAME)) { unsigned tmp_remaining = *src_size; items[i].dname = load_test_dname(src, src_size); @@ -395,7 +395,7 @@ static test_rdata_t *load_response_rdata(uint16_t type, total_read += tmp_remaining - *src_size; } else { if (desc->wireformat[i] == - DNSLIB_RDATA_WF_BINARYWITHLENGTH) { + KNOT_RDATA_WF_BINARYWITHLENGTH) { if (!mem_read(&raw_data_length, sizeof(raw_data_length), src, src_size)) { return NULL; @@ -451,7 +451,7 @@ static test_rdata_t *load_response_rdata(uint16_t type, */ if ((i != desc->length - 1) && desc->wireformat[i] != - DNSLIB_RDATA_WF_TEXT ) { + KNOT_RDATA_WF_TEXT ) { fprintf(stderr, "I dont know how " "to parse this type: %d\n", @@ -462,7 +462,7 @@ static test_rdata_t *load_response_rdata(uint16_t type, total_raw_data_length - total_read; if (desc->wireformat[i] == - DNSLIB_RDATA_WF_TEXT) { + KNOT_RDATA_WF_TEXT) { break; } @@ -512,7 +512,7 @@ static test_rdata_t *load_response_rdata(uint16_t type, items[i].raw_data[0]); */ if (desc->zoneformat[i] == - DNSLIB_RDATA_ZF_ALGORITHM) { + KNOT_RDATA_ZF_ALGORITHM) { hex_print((char *)items[i].raw_data, items[i].raw_data[0] + 2); } else { @@ -821,9 +821,9 @@ static void test_dname_free(test_dname_t **dname) static int wire_is_dname(uint type) { - return (type == DNSLIB_RDATA_WF_COMPRESSED_DNAME || - type == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME || - type == DNSLIB_RDATA_WF_LITERAL_DNAME); + return (type == KNOT_RDATA_WF_COMPRESSED_DNAME || + type == KNOT_RDATA_WF_UNCOMPRESSED_DNAME || + type == KNOT_RDATA_WF_LITERAL_DNAME); } static void test_rdata_free(test_rdata_t **rdata) @@ -915,9 +915,9 @@ static void get_and_save_data_from_rdata(test_rdata_t *rdata, } for(int i = 0; i < rdata->count; i++) { - if ((desc->wireformat[i] == DNSLIB_RDATA_WF_COMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_LITERAL_DNAME)) { + if ((desc->wireformat[i] == KNOT_RDATA_WF_COMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_UNCOMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_LITERAL_DNAME)) { add_tail(&data->dname_list, (node *)rdata->items[i].dname); test_item_t *temp_item = malloc(sizeof(test_item_t)); diff --git a/src/dnslib/tests/realdata/dnslib_tests_loader_realdata.h b/src/dnslib/tests/realdata/dnslib_tests_loader_realdata.h index ff42da77b56314f4d48c83cb2ae81824b2ef2f27..56356d1d3f62474ae2c1084551ec0dc049c32867 100644 --- a/src/dnslib/tests/realdata/dnslib_tests_loader_realdata.h +++ b/src/dnslib/tests/realdata/dnslib_tests_loader_realdata.h @@ -1,5 +1,5 @@ -#ifndef DNSLIB_TESTS_LOADER_H -#define DNSLIB_TESTS_LOADER_H +#ifndef KNOT_TESTS_LOADER_H +#define KNOT_TESTS_LOADER_H #include <stdint.h> @@ -160,4 +160,4 @@ test_data_t *create_test_data_from_dump(); test_data_t *data_for_knot_tests; -#endif // DNSLIB_TESTS_LOADER_H +#endif // KNOT_TESTS_LOADER_H diff --git a/src/dnslib/tolower.h b/src/dnslib/tolower.h index c9c6793ef895988826f7e2902927660c6cedb055..b8231128f805a3c065cb91bf5852945a3eb5f4b3 100644 --- a/src/dnslib/tolower.h +++ b/src/dnslib/tolower.h @@ -9,17 +9,17 @@ * @{ */ -#ifndef _KNOT_DNSLIB_TOLOWER_H_ -#define _KNOT_DNSLIB_TOLOWER_H_ +#ifndef _KNOTDKNOT_TOLOWER_H_ +#define _KNOTDKNOT_TOLOWER_H_ #include <stdint.h> /*! \brief Size of the character conversion table. */ -#define DNSLIB_CHAR_TABLE_SIZE 256 +#define KNOT_CHAR_TABLE_SIZE 256 enum { /*! \brief Size of the character conversion table. */ - CHAR_TABLE_SIZE = DNSLIB_CHAR_TABLE_SIZE + CHAR_TABLE_SIZE = KNOT_CHAR_TABLE_SIZE }; /*! \brief Character table mapping uppercase letters to lowercase. */ @@ -33,10 +33,10 @@ extern const uint8_t char_table[CHAR_TABLE_SIZE]; * \return \a c converted to lowercase (or \a c if not applicable). */ static inline uint8_t knot_tolower(uint8_t c) { -#if DNSLIB_CHAR_TABLE_SIZE < 256 +#if KNOT_CHAR_TABLE_SIZE < 256 assert(c < CHAR_TABLE_SIZE); #endif return char_table[c]; } -#endif /* _KNOT_DNSLIB_TOLOWER_H_ */ +#endif /* _KNOTDKNOT_TOLOWER_H_ */ diff --git a/src/dnslib/utils.h b/src/dnslib/utils.h index 936ca740318385b20f66bdc65ec071db323c1de2..1611d3e8262a3d46349eaf30082deb91d6049113 100644 --- a/src/dnslib/utils.h +++ b/src/dnslib/utils.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_UTILS_H_ -#define _KNOT_DNSLIB_UTILS_H_ +#ifndef _KNOTDKNOT_UTILS_H_ +#define _KNOTDKNOT_UTILS_H_ #include <string.h> #include <stdint.h> @@ -132,7 +132,7 @@ static inline void knot_wire_write_u32(uint8_t *pos, uint32_t data) */ size_t knot_quick_rand(); -#endif /* _KNOT_DNSLIB_UTILS_H_ */ +#endif /* _KNOTDKNOT_UTILS_H_ */ /*! @} */ diff --git a/src/dnslib/wire.h b/src/dnslib/wire.h index 262329d96887dd75e9388fd65be21e7a4f8e1806..8e6548689aa4830bd3172d149ca2a9c6cab2bef1 100644 --- a/src/dnslib/wire.h +++ b/src/dnslib/wire.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_WIRE_H_ -#define _KNOT_DNSLIB_WIRE_H_ +#ifndef _KNOTDKNOT_WIRE_H_ +#define _KNOTDKNOT_WIRE_H_ #include <stdint.h> #include <assert.h> @@ -19,20 +19,20 @@ /*! \brief Offset of DNS header fields in wireformat. */ enum knot_wire_offsets { - DNSLIB_WIRE_OFFSET_ID = 0, - DNSLIB_WIRE_OFFSET_FLAGS1 = 2, - DNSLIB_WIRE_OFFSET_FLAGS2 = 3, - DNSLIB_WIRE_OFFSET_QDCOUNT = 4, - DNSLIB_WIRE_OFFSET_ANCOUNT = 6, - DNSLIB_WIRE_OFFSET_NSCOUNT = 8, - DNSLIB_WIRE_OFFSET_ARCOUNT = 10 + KNOT_WIRE_OFFSET_ID = 0, + KNOT_WIRE_OFFSET_FLAGS1 = 2, + KNOT_WIRE_OFFSET_FLAGS2 = 3, + KNOT_WIRE_OFFSET_QDCOUNT = 4, + KNOT_WIRE_OFFSET_ANCOUNT = 6, + KNOT_WIRE_OFFSET_NSCOUNT = 8, + KNOT_WIRE_OFFSET_ARCOUNT = 10 }; /*! \brief Minimum size for some parts of the DNS packet. */ enum knot_wire_sizes { - DNSLIB_WIRE_HEADER_SIZE = 12, - DNSLIB_WIRE_QUESTION_MIN_SIZE = 5, - DNSLIB_WIRE_RR_MIN_SIZE = 11 + KNOT_WIRE_HEADER_SIZE = 12, + KNOT_WIRE_QUESTION_MIN_SIZE = 5, + KNOT_WIRE_RR_MIN_SIZE = 11 }; /* @@ -48,7 +48,7 @@ enum knot_wire_sizes { */ static inline uint16_t knot_wire_get_id(const uint8_t *packet) { - return knot_wire_read_u16(packet + DNSLIB_WIRE_OFFSET_ID); + return knot_wire_read_u16(packet + KNOT_WIRE_OFFSET_ID); } /*! @@ -59,7 +59,7 @@ static inline uint16_t knot_wire_get_id(const uint8_t *packet) */ static inline void knot_wire_set_id(uint8_t *packet, uint16_t id) { - knot_wire_write_u16(packet + DNSLIB_WIRE_OFFSET_ID, id); + knot_wire_write_u16(packet + KNOT_WIRE_OFFSET_ID, id); } /*! @@ -71,7 +71,7 @@ static inline void knot_wire_set_id(uint8_t *packet, uint16_t id) */ static inline uint8_t knot_wire_get_flags1(const uint8_t *packet) { - return *(packet + DNSLIB_WIRE_OFFSET_FLAGS1); + return *(packet + KNOT_WIRE_OFFSET_FLAGS1); } /*! @@ -82,7 +82,7 @@ static inline uint8_t knot_wire_get_flags1(const uint8_t *packet) */ static inline uint8_t knot_wire_set_flags1(uint8_t *packet, uint8_t flags1) { - return *(packet + DNSLIB_WIRE_OFFSET_FLAGS1) = flags1; + return *(packet + KNOT_WIRE_OFFSET_FLAGS1) = flags1; } /*! @@ -94,7 +94,7 @@ static inline uint8_t knot_wire_set_flags1(uint8_t *packet, uint8_t flags1) */ static inline uint8_t knot_wire_get_flags2(const uint8_t *packet) { - return *(packet + DNSLIB_WIRE_OFFSET_FLAGS2); + return *(packet + KNOT_WIRE_OFFSET_FLAGS2); } /*! @@ -105,7 +105,7 @@ static inline uint8_t knot_wire_get_flags2(const uint8_t *packet) */ static inline uint8_t knot_wire_set_flags2(uint8_t *packet, uint8_t flags2) { - return *(packet + DNSLIB_WIRE_OFFSET_FLAGS2) = flags2; + return *(packet + KNOT_WIRE_OFFSET_FLAGS2) = flags2; } /*! @@ -118,7 +118,7 @@ static inline uint8_t knot_wire_set_flags2(uint8_t *packet, uint8_t flags2) */ static inline uint16_t knot_wire_get_qdcount(const uint8_t *packet) { - return knot_wire_read_u16(packet + DNSLIB_WIRE_OFFSET_QDCOUNT); + return knot_wire_read_u16(packet + KNOT_WIRE_OFFSET_QDCOUNT); } /*! @@ -130,7 +130,7 @@ static inline uint16_t knot_wire_get_qdcount(const uint8_t *packet) */ static inline void knot_wire_set_qdcount(uint8_t *packet, uint16_t qdcount) { - knot_wire_write_u16(packet + DNSLIB_WIRE_OFFSET_QDCOUNT, qdcount); + knot_wire_write_u16(packet + KNOT_WIRE_OFFSET_QDCOUNT, qdcount); } /*! @@ -143,7 +143,7 @@ static inline void knot_wire_set_qdcount(uint8_t *packet, uint16_t qdcount) */ static inline uint16_t knot_wire_get_ancount(const uint8_t *packet) { - return knot_wire_read_u16(packet + DNSLIB_WIRE_OFFSET_ANCOUNT); + return knot_wire_read_u16(packet + KNOT_WIRE_OFFSET_ANCOUNT); } /*! @@ -155,7 +155,7 @@ static inline uint16_t knot_wire_get_ancount(const uint8_t *packet) */ static inline void knot_wire_set_ancount(uint8_t *packet, uint16_t ancount) { - knot_wire_write_u16(packet + DNSLIB_WIRE_OFFSET_ANCOUNT, ancount); + knot_wire_write_u16(packet + KNOT_WIRE_OFFSET_ANCOUNT, ancount); } /*! @@ -168,7 +168,7 @@ static inline void knot_wire_set_ancount(uint8_t *packet, uint16_t ancount) */ static inline uint16_t knot_wire_get_nscount(const uint8_t *packet) { - return knot_wire_read_u16(packet + DNSLIB_WIRE_OFFSET_NSCOUNT); + return knot_wire_read_u16(packet + KNOT_WIRE_OFFSET_NSCOUNT); } /*! @@ -180,7 +180,7 @@ static inline uint16_t knot_wire_get_nscount(const uint8_t *packet) */ static inline void knot_wire_set_nscount(uint8_t *packet, uint16_t nscount) { - knot_wire_write_u16(packet + DNSLIB_WIRE_OFFSET_NSCOUNT, nscount); + knot_wire_write_u16(packet + KNOT_WIRE_OFFSET_NSCOUNT, nscount); } /*! @@ -193,7 +193,7 @@ static inline void knot_wire_set_nscount(uint8_t *packet, uint16_t nscount) */ static inline uint16_t knot_wire_get_arcount(const uint8_t *packet) { - return knot_wire_read_u16(packet + DNSLIB_WIRE_OFFSET_ARCOUNT); + return knot_wire_read_u16(packet + KNOT_WIRE_OFFSET_ARCOUNT); } /*! @@ -205,7 +205,7 @@ static inline uint16_t knot_wire_get_arcount(const uint8_t *packet) */ static inline void knot_wire_set_arcount(uint8_t *packet, uint16_t arcount) { - knot_wire_write_u16(packet + DNSLIB_WIRE_OFFSET_ARCOUNT, arcount); + knot_wire_write_u16(packet + KNOT_WIRE_OFFSET_ARCOUNT, arcount); } /* @@ -213,30 +213,30 @@ static inline void knot_wire_set_arcount(uint8_t *packet, uint16_t arcount) */ /*! \brief Constants for DNS header flags in the first flags byte. */ enum knot_wire_flags1_consts { - DNSLIB_WIRE_RD_MASK = (uint8_t)0x01U, /*!< RD bit mask. */ - DNSLIB_WIRE_RD_SHIFT = 0, /*!< RD bit shift. */ - DNSLIB_WIRE_TC_MASK = (uint8_t)0x02U, /*!< TC bit mask. */ - DNSLIB_WIRE_TC_SHIFT = 1, /*!< TC bit shift. */ - DNSLIB_WIRE_AA_MASK = (uint8_t)0x04U, /*!< AA bit mask. */ - DNSLIB_WIRE_AA_SHIFT = 2, /*!< AA bit shift. */ - DNSLIB_WIRE_OPCODE_MASK = (uint8_t)0x78U, /*!< OPCODE mask. */ - DNSLIB_WIRE_OPCODE_SHIFT = 3, /*!< OPCODE shift. */ - DNSLIB_WIRE_QR_MASK = (uint8_t)0x80U, /*!< QR bit mask. */ - DNSLIB_WIRE_QR_SHIFT = 7 /*!< QR bit shift. */ + KNOT_WIRE_RD_MASK = (uint8_t)0x01U, /*!< RD bit mask. */ + KNOT_WIRE_RD_SHIFT = 0, /*!< RD bit shift. */ + KNOT_WIRE_TC_MASK = (uint8_t)0x02U, /*!< TC bit mask. */ + KNOT_WIRE_TC_SHIFT = 1, /*!< TC bit shift. */ + KNOT_WIRE_AA_MASK = (uint8_t)0x04U, /*!< AA bit mask. */ + KNOT_WIRE_AA_SHIFT = 2, /*!< AA bit shift. */ + KNOT_WIRE_OPCODE_MASK = (uint8_t)0x78U, /*!< OPCODE mask. */ + KNOT_WIRE_OPCODE_SHIFT = 3, /*!< OPCODE shift. */ + KNOT_WIRE_QR_MASK = (uint8_t)0x80U, /*!< QR bit mask. */ + KNOT_WIRE_QR_SHIFT = 7 /*!< QR bit shift. */ }; /*! \brief Constants for DNS header flags in the second flags byte. */ enum knot_wire_flags2_consts { - DNSLIB_WIRE_RCODE_MASK = (uint8_t)0x0fU, /*!< RCODE mask. */ - DNSLIB_WIRE_RCODE_SHIFT = 0, /*!< RCODE shift. */ - DNSLIB_WIRE_CD_MASK = (uint8_t)0x10U, /*!< CD bit mask. */ - DNSLIB_WIRE_CD_SHIFT = 4, /*!< CD bit shift. */ - DNSLIB_WIRE_AD_MASK = (uint8_t)0x20U, /*!< AD bit mask. */ - DNSLIB_WIRE_AD_SHIFT = 5, /*!< AD bit shift. */ - DNSLIB_WIRE_Z_MASK = (uint8_t)0x40U, /*!< Zero bit mask. */ - DNSLIB_WIRE_Z_SHIFT = 6, /*!< Zero bit shift. */ - DNSLIB_WIRE_RA_MASK = (uint8_t)0x80U, /*!< RA bit mask. */ - DNSLIB_WIRE_RA_SHIFT = 7 /*!< RA bit shift. */ + KNOT_WIRE_RCODE_MASK = (uint8_t)0x0fU, /*!< RCODE mask. */ + KNOT_WIRE_RCODE_SHIFT = 0, /*!< RCODE shift. */ + KNOT_WIRE_CD_MASK = (uint8_t)0x10U, /*!< CD bit mask. */ + KNOT_WIRE_CD_SHIFT = 4, /*!< CD bit shift. */ + KNOT_WIRE_AD_MASK = (uint8_t)0x20U, /*!< AD bit mask. */ + KNOT_WIRE_AD_SHIFT = 5, /*!< AD bit shift. */ + KNOT_WIRE_Z_MASK = (uint8_t)0x40U, /*!< Zero bit mask. */ + KNOT_WIRE_Z_SHIFT = 6, /*!< Zero bit shift. */ + KNOT_WIRE_RA_MASK = (uint8_t)0x80U, /*!< RA bit mask. */ + KNOT_WIRE_RA_SHIFT = 7 /*!< RA bit shift. */ }; /* @@ -252,7 +252,7 @@ enum knot_wire_flags2_consts { */ static inline uint8_t knot_wire_get_rd(const uint8_t *packet) { - return *(packet + DNSLIB_WIRE_OFFSET_FLAGS1) & DNSLIB_WIRE_RD_MASK; + return *(packet + KNOT_WIRE_OFFSET_FLAGS1) & KNOT_WIRE_RD_MASK; } /*! @@ -262,7 +262,7 @@ static inline uint8_t knot_wire_get_rd(const uint8_t *packet) */ static inline void knot_wire_set_rd(uint8_t *packet) { - *(packet + DNSLIB_WIRE_OFFSET_FLAGS1) |= DNSLIB_WIRE_RD_MASK; + *(packet + KNOT_WIRE_OFFSET_FLAGS1) |= KNOT_WIRE_RD_MASK; } /*! @@ -272,7 +272,7 @@ static inline void knot_wire_set_rd(uint8_t *packet) */ static inline void knot_wire_flags_clear_rd(uint8_t *packet) { - *(packet + DNSLIB_WIRE_OFFSET_FLAGS1) &= ~DNSLIB_WIRE_RD_MASK; + *(packet + KNOT_WIRE_OFFSET_FLAGS1) &= ~KNOT_WIRE_RD_MASK; } /*! @@ -284,7 +284,7 @@ static inline void knot_wire_flags_clear_rd(uint8_t *packet) */ static inline uint8_t knot_wire_get_tc(const uint8_t *packet) { - return *(packet + DNSLIB_WIRE_OFFSET_FLAGS1) & DNSLIB_WIRE_TC_MASK; + return *(packet + KNOT_WIRE_OFFSET_FLAGS1) & KNOT_WIRE_TC_MASK; } /*! @@ -294,7 +294,7 @@ static inline uint8_t knot_wire_get_tc(const uint8_t *packet) */ static inline void knot_wire_set_tc(uint8_t *packet) { - *(packet + DNSLIB_WIRE_OFFSET_FLAGS1) |= DNSLIB_WIRE_TC_MASK; + *(packet + KNOT_WIRE_OFFSET_FLAGS1) |= KNOT_WIRE_TC_MASK; } /*! @@ -304,7 +304,7 @@ static inline void knot_wire_set_tc(uint8_t *packet) */ static inline void knot_wire_clear_tc(uint8_t *packet) { - *(packet + DNSLIB_WIRE_OFFSET_FLAGS1) &= ~DNSLIB_WIRE_TC_MASK; + *(packet + KNOT_WIRE_OFFSET_FLAGS1) &= ~KNOT_WIRE_TC_MASK; } /*! @@ -316,7 +316,7 @@ static inline void knot_wire_clear_tc(uint8_t *packet) */ static inline uint8_t knot_wire_get_aa(const uint8_t *packet) { - return *(packet + DNSLIB_WIRE_OFFSET_FLAGS1) & DNSLIB_WIRE_AA_MASK; + return *(packet + KNOT_WIRE_OFFSET_FLAGS1) & KNOT_WIRE_AA_MASK; } /*! @@ -326,7 +326,7 @@ static inline uint8_t knot_wire_get_aa(const uint8_t *packet) */ static inline void knot_wire_set_aa(uint8_t *packet) { - *(packet + DNSLIB_WIRE_OFFSET_FLAGS1) |= DNSLIB_WIRE_AA_MASK; + *(packet + KNOT_WIRE_OFFSET_FLAGS1) |= KNOT_WIRE_AA_MASK; } /*! @@ -336,7 +336,7 @@ static inline void knot_wire_set_aa(uint8_t *packet) */ static inline void knot_wire_clear_aa(uint8_t *packet) { - *(packet + DNSLIB_WIRE_OFFSET_FLAGS1) &= ~DNSLIB_WIRE_AA_MASK; + *(packet + KNOT_WIRE_OFFSET_FLAGS1) &= ~KNOT_WIRE_AA_MASK; } /*! @@ -348,8 +348,8 @@ static inline void knot_wire_clear_aa(uint8_t *packet) */ static inline uint8_t knot_wire_get_opcode(const uint8_t *packet) { - return (*(packet + DNSLIB_WIRE_OFFSET_FLAGS1) - & DNSLIB_WIRE_OPCODE_MASK) >> DNSLIB_WIRE_OPCODE_SHIFT; + return (*(packet + KNOT_WIRE_OFFSET_FLAGS1) + & KNOT_WIRE_OPCODE_MASK) >> KNOT_WIRE_OPCODE_SHIFT; } /*! @@ -360,9 +360,9 @@ static inline uint8_t knot_wire_get_opcode(const uint8_t *packet) */ static inline void knot_wire_set_opcode(uint8_t *packet, short opcode) { - uint8_t *flags1 = packet + DNSLIB_WIRE_OFFSET_FLAGS1; - *flags1 = (*flags1 & ~DNSLIB_WIRE_OPCODE_MASK) - | ((opcode) << DNSLIB_WIRE_OPCODE_SHIFT); + uint8_t *flags1 = packet + KNOT_WIRE_OFFSET_FLAGS1; + *flags1 = (*flags1 & ~KNOT_WIRE_OPCODE_MASK) + | ((opcode) << KNOT_WIRE_OPCODE_SHIFT); } /*! @@ -374,7 +374,7 @@ static inline void knot_wire_set_opcode(uint8_t *packet, short opcode) */ static inline uint8_t knot_wire_get_qr(const uint8_t *packet) { - return *(packet + DNSLIB_WIRE_OFFSET_FLAGS1) & DNSLIB_WIRE_QR_MASK; + return *(packet + KNOT_WIRE_OFFSET_FLAGS1) & KNOT_WIRE_QR_MASK; } /*! @@ -384,7 +384,7 @@ static inline uint8_t knot_wire_get_qr(const uint8_t *packet) */ static inline void knot_wire_set_qr(uint8_t *packet) { - *(packet + DNSLIB_WIRE_OFFSET_FLAGS1) |= DNSLIB_WIRE_QR_MASK; + *(packet + KNOT_WIRE_OFFSET_FLAGS1) |= KNOT_WIRE_QR_MASK; } /*! @@ -394,7 +394,7 @@ static inline void knot_wire_set_qr(uint8_t *packet) */ static inline void knot_wire_clear_qr(uint8_t *packet) { - *(packet + DNSLIB_WIRE_OFFSET_FLAGS1) &= ~DNSLIB_WIRE_QR_MASK; + *(packet + KNOT_WIRE_OFFSET_FLAGS1) &= ~KNOT_WIRE_QR_MASK; } /*! @@ -406,8 +406,8 @@ static inline void knot_wire_clear_qr(uint8_t *packet) */ static inline uint8_t knot_wire_get_rcode(const uint8_t *packet) { - return *(packet + DNSLIB_WIRE_OFFSET_FLAGS2) - & DNSLIB_WIRE_RCODE_MASK; + return *(packet + KNOT_WIRE_OFFSET_FLAGS2) + & KNOT_WIRE_RCODE_MASK; } /*! @@ -418,8 +418,8 @@ static inline uint8_t knot_wire_get_rcode(const uint8_t *packet) */ static inline void knot_wire_set_rcode(uint8_t *packet, short rcode) { - uint8_t *flags2 = packet + DNSLIB_WIRE_OFFSET_FLAGS2; - *flags2 = (*flags2 & ~DNSLIB_WIRE_RCODE_MASK) | (rcode); + uint8_t *flags2 = packet + KNOT_WIRE_OFFSET_FLAGS2; + *flags2 = (*flags2 & ~KNOT_WIRE_RCODE_MASK) | (rcode); } /*! @@ -431,7 +431,7 @@ static inline void knot_wire_set_rcode(uint8_t *packet, short rcode) */ static inline uint8_t knot_wire_get_cd(const uint8_t *packet) { - return *(packet + DNSLIB_WIRE_OFFSET_FLAGS2) & DNSLIB_WIRE_CD_MASK; + return *(packet + KNOT_WIRE_OFFSET_FLAGS2) & KNOT_WIRE_CD_MASK; } /*! @@ -441,7 +441,7 @@ static inline uint8_t knot_wire_get_cd(const uint8_t *packet) */ static inline void knot_wire_set_cd(uint8_t *packet) { - *(packet + DNSLIB_WIRE_OFFSET_FLAGS2) |= DNSLIB_WIRE_CD_MASK; + *(packet + KNOT_WIRE_OFFSET_FLAGS2) |= KNOT_WIRE_CD_MASK; } /*! @@ -451,7 +451,7 @@ static inline void knot_wire_set_cd(uint8_t *packet) */ static inline void knot_wire_clear_cd(uint8_t *packet) { - *(packet + DNSLIB_WIRE_OFFSET_FLAGS2) &= ~DNSLIB_WIRE_CD_MASK; + *(packet + KNOT_WIRE_OFFSET_FLAGS2) &= ~KNOT_WIRE_CD_MASK; } /*! @@ -463,7 +463,7 @@ static inline void knot_wire_clear_cd(uint8_t *packet) */ static inline uint8_t knot_wire_get_ad(const uint8_t *packet) { - return *(packet + DNSLIB_WIRE_OFFSET_FLAGS2) & DNSLIB_WIRE_AD_MASK; + return *(packet + KNOT_WIRE_OFFSET_FLAGS2) & KNOT_WIRE_AD_MASK; } /*! @@ -473,7 +473,7 @@ static inline uint8_t knot_wire_get_ad(const uint8_t *packet) */ static inline void knot_wire_set_ad(uint8_t *packet) { - *(packet + DNSLIB_WIRE_OFFSET_FLAGS2) |= DNSLIB_WIRE_AD_MASK; + *(packet + KNOT_WIRE_OFFSET_FLAGS2) |= KNOT_WIRE_AD_MASK; } /*! @@ -483,7 +483,7 @@ static inline void knot_wire_set_ad(uint8_t *packet) */ static inline void knot_wire_clear_ad(uint8_t *packet) { - *(packet + DNSLIB_WIRE_OFFSET_FLAGS2) &= ~DNSLIB_WIRE_AD_MASK; + *(packet + KNOT_WIRE_OFFSET_FLAGS2) &= ~KNOT_WIRE_AD_MASK; } /*! @@ -495,7 +495,7 @@ static inline void knot_wire_clear_ad(uint8_t *packet) */ static inline uint8_t knot_wire_get_z(const uint8_t *packet) { - return *(packet + DNSLIB_WIRE_OFFSET_FLAGS2) & DNSLIB_WIRE_Z_MASK; + return *(packet + KNOT_WIRE_OFFSET_FLAGS2) & KNOT_WIRE_Z_MASK; } /*! @@ -505,7 +505,7 @@ static inline uint8_t knot_wire_get_z(const uint8_t *packet) */ static inline void knot_wire_set_z(uint8_t *packet) { - *(packet + DNSLIB_WIRE_OFFSET_FLAGS2) |= DNSLIB_WIRE_Z_MASK; + *(packet + KNOT_WIRE_OFFSET_FLAGS2) |= KNOT_WIRE_Z_MASK; } /*! @@ -515,7 +515,7 @@ static inline void knot_wire_set_z(uint8_t *packet) */ static inline void knot_wire_clear_z(uint8_t *packet) { - *(packet + DNSLIB_WIRE_OFFSET_FLAGS2) &= ~DNSLIB_WIRE_Z_MASK; + *(packet + KNOT_WIRE_OFFSET_FLAGS2) &= ~KNOT_WIRE_Z_MASK; } /*! @@ -527,7 +527,7 @@ static inline void knot_wire_clear_z(uint8_t *packet) */ static inline uint8_t knot_wire_get_ra(const uint8_t *packet) { - return *(packet + DNSLIB_WIRE_OFFSET_FLAGS2) & DNSLIB_WIRE_RA_MASK; + return *(packet + KNOT_WIRE_OFFSET_FLAGS2) & KNOT_WIRE_RA_MASK; } /*! @@ -537,7 +537,7 @@ static inline uint8_t knot_wire_get_ra(const uint8_t *packet) */ static inline void knot_wire_set_ra(uint8_t *packet) { - *(packet + DNSLIB_WIRE_OFFSET_FLAGS2) |= DNSLIB_WIRE_RA_MASK; + *(packet + KNOT_WIRE_OFFSET_FLAGS2) |= KNOT_WIRE_RA_MASK; } /*! @@ -547,7 +547,7 @@ static inline void knot_wire_set_ra(uint8_t *packet) */ static inline void knot_wire_clear_ra(uint8_t *packet) { - *(packet + DNSLIB_WIRE_OFFSET_FLAGS2) &= ~DNSLIB_WIRE_RA_MASK; + *(packet + KNOT_WIRE_OFFSET_FLAGS2) &= ~KNOT_WIRE_RA_MASK; } /* @@ -564,7 +564,7 @@ static inline void knot_wire_clear_ra(uint8_t *packet) */ static inline uint8_t knot_wire_flags_get_rd(uint8_t flags1) { - return flags1 & DNSLIB_WIRE_RD_MASK; + return flags1 & KNOT_WIRE_RD_MASK; } /*! @@ -574,7 +574,7 @@ static inline uint8_t knot_wire_flags_get_rd(uint8_t flags1) */ static inline void knot_wire_flags_set_rd(uint8_t *flags1) { - *flags1 |= DNSLIB_WIRE_RD_MASK; + *flags1 |= KNOT_WIRE_RD_MASK; } /*! @@ -584,7 +584,7 @@ static inline void knot_wire_flags_set_rd(uint8_t *flags1) */ static inline void knot_wire_flags_flags_clear_rd(uint8_t *flags1) { - *flags1 &= ~DNSLIB_WIRE_RD_MASK; + *flags1 &= ~KNOT_WIRE_RD_MASK; } /*! @@ -597,7 +597,7 @@ static inline void knot_wire_flags_flags_clear_rd(uint8_t *flags1) */ static inline uint8_t knot_wire_flags_get_tc(uint8_t flags1) { - return flags1 & DNSLIB_WIRE_TC_MASK; + return flags1 & KNOT_WIRE_TC_MASK; } /*! @@ -607,7 +607,7 @@ static inline uint8_t knot_wire_flags_get_tc(uint8_t flags1) */ static inline void knot_wire_flags_set_tc(uint8_t *flags1) { - *flags1 |= DNSLIB_WIRE_TC_MASK; + *flags1 |= KNOT_WIRE_TC_MASK; } /*! @@ -617,7 +617,7 @@ static inline void knot_wire_flags_set_tc(uint8_t *flags1) */ static inline void knot_wire_flags_clear_tc(uint8_t *flags1) { - *flags1 &= ~DNSLIB_WIRE_TC_MASK; + *flags1 &= ~KNOT_WIRE_TC_MASK; } /*! @@ -630,7 +630,7 @@ static inline void knot_wire_flags_clear_tc(uint8_t *flags1) */ static inline uint8_t knot_wire_flags_get_aa(uint8_t flags1) { - return flags1 & DNSLIB_WIRE_AA_MASK; + return flags1 & KNOT_WIRE_AA_MASK; } /*! @@ -640,7 +640,7 @@ static inline uint8_t knot_wire_flags_get_aa(uint8_t flags1) */ static inline void knot_wire_flags_set_aa(uint8_t *flags1) { - *flags1 |= DNSLIB_WIRE_AA_MASK; + *flags1 |= KNOT_WIRE_AA_MASK; } /*! @@ -650,7 +650,7 @@ static inline void knot_wire_flags_set_aa(uint8_t *flags1) */ static inline void knot_wire_flags_clear_aa(uint8_t *flags1) { - *flags1 &= ~DNSLIB_WIRE_AA_MASK; + *flags1 &= ~KNOT_WIRE_AA_MASK; } /*! @@ -662,8 +662,8 @@ static inline void knot_wire_flags_clear_aa(uint8_t *flags1) */ static inline uint8_t knot_wire_flags_get_opcode(uint8_t flags1) { - return (flags1 & DNSLIB_WIRE_OPCODE_MASK) - >> DNSLIB_WIRE_OPCODE_SHIFT; + return (flags1 & KNOT_WIRE_OPCODE_MASK) + >> KNOT_WIRE_OPCODE_SHIFT; } /*! @@ -674,8 +674,8 @@ static inline uint8_t knot_wire_flags_get_opcode(uint8_t flags1) */ static inline void knot_wire_flags_set_opcode(uint8_t *flags1, short opcode) { - *flags1 = (*flags1 & ~DNSLIB_WIRE_OPCODE_MASK) - | ((opcode) << DNSLIB_WIRE_OPCODE_SHIFT); + *flags1 = (*flags1 & ~KNOT_WIRE_OPCODE_MASK) + | ((opcode) << KNOT_WIRE_OPCODE_SHIFT); } /*! @@ -688,7 +688,7 @@ static inline void knot_wire_flags_set_opcode(uint8_t *flags1, short opcode) */ static inline uint8_t knot_wire_flags_get_qr(uint8_t flags1) { - return flags1 & DNSLIB_WIRE_QR_MASK; + return flags1 & KNOT_WIRE_QR_MASK; } /*! @@ -698,7 +698,7 @@ static inline uint8_t knot_wire_flags_get_qr(uint8_t flags1) */ static inline void knot_wire_flags_set_qr(uint8_t *flags1) { - *flags1 |= DNSLIB_WIRE_QR_MASK; + *flags1 |= KNOT_WIRE_QR_MASK; } /*! @@ -708,7 +708,7 @@ static inline void knot_wire_flags_set_qr(uint8_t *flags1) */ static inline void knot_wire_flags_clear_qr(uint8_t *flags1) { - *flags1 &= ~DNSLIB_WIRE_QR_MASK; + *flags1 &= ~KNOT_WIRE_QR_MASK; } /*! @@ -720,7 +720,7 @@ static inline void knot_wire_flags_clear_qr(uint8_t *flags1) */ static inline uint8_t knot_wire_flags_get_rcode(uint8_t flags2) { - return flags2 & DNSLIB_WIRE_RCODE_MASK; + return flags2 & KNOT_WIRE_RCODE_MASK; } /*! @@ -731,7 +731,7 @@ static inline uint8_t knot_wire_flags_get_rcode(uint8_t flags2) */ static inline void knot_wire_flags_set_rcode(uint8_t *flags2, short rcode) { - *flags2 = (*flags2 & ~DNSLIB_WIRE_RCODE_MASK) | (rcode); + *flags2 = (*flags2 & ~KNOT_WIRE_RCODE_MASK) | (rcode); } /*! @@ -744,7 +744,7 @@ static inline void knot_wire_flags_set_rcode(uint8_t *flags2, short rcode) */ static inline uint8_t knot_wire_flags_get_cd(uint8_t flags2) { - return flags2 & DNSLIB_WIRE_CD_MASK; + return flags2 & KNOT_WIRE_CD_MASK; } /*! @@ -754,7 +754,7 @@ static inline uint8_t knot_wire_flags_get_cd(uint8_t flags2) */ static inline void knot_wire_flags_set_cd(uint8_t *flags2) { - *flags2 |= DNSLIB_WIRE_CD_MASK; + *flags2 |= KNOT_WIRE_CD_MASK; } /*! @@ -764,7 +764,7 @@ static inline void knot_wire_flags_set_cd(uint8_t *flags2) */ static inline void knot_wire_flags_clear_cd(uint8_t *flags2) { - *flags2 &= ~DNSLIB_WIRE_CD_MASK; + *flags2 &= ~KNOT_WIRE_CD_MASK; } /*! @@ -777,7 +777,7 @@ static inline void knot_wire_flags_clear_cd(uint8_t *flags2) */ static inline uint8_t knot_wire_flags_get_ad(uint8_t flags2) { - return flags2 & DNSLIB_WIRE_AD_MASK; + return flags2 & KNOT_WIRE_AD_MASK; } /*! @@ -787,7 +787,7 @@ static inline uint8_t knot_wire_flags_get_ad(uint8_t flags2) */ static inline void knot_wire_flags_set_ad(uint8_t *flags2) { - *flags2 |= DNSLIB_WIRE_AD_MASK; + *flags2 |= KNOT_WIRE_AD_MASK; } /*! @@ -797,7 +797,7 @@ static inline void knot_wire_flags_set_ad(uint8_t *flags2) */ static inline void knot_wire_flags_clear_ad(uint8_t *flags2) { - *flags2 &= ~DNSLIB_WIRE_AD_MASK; + *flags2 &= ~KNOT_WIRE_AD_MASK; } /*! @@ -810,7 +810,7 @@ static inline void knot_wire_flags_clear_ad(uint8_t *flags2) */ static inline uint8_t knot_wire_flags_get_z(uint8_t flags2) { - return flags2 & DNSLIB_WIRE_Z_MASK; + return flags2 & KNOT_WIRE_Z_MASK; } /*! @@ -820,7 +820,7 @@ static inline uint8_t knot_wire_flags_get_z(uint8_t flags2) */ static inline void knot_wire_flags_set_z(uint8_t *flags2) { - *flags2 |= DNSLIB_WIRE_Z_MASK; + *flags2 |= KNOT_WIRE_Z_MASK; } /*! @@ -830,7 +830,7 @@ static inline void knot_wire_flags_set_z(uint8_t *flags2) */ static inline void knot_wire_flags_clear_z(uint8_t *flags2) { - *flags2 &= ~DNSLIB_WIRE_Z_MASK; + *flags2 &= ~KNOT_WIRE_Z_MASK; } /*! @@ -843,7 +843,7 @@ static inline void knot_wire_flags_clear_z(uint8_t *flags2) */ static inline uint8_t knot_wire_flags_get_ra(uint8_t flags2) { - return flags2 & DNSLIB_WIRE_RA_MASK; + return flags2 & KNOT_WIRE_RA_MASK; } /*! @@ -853,7 +853,7 @@ static inline uint8_t knot_wire_flags_get_ra(uint8_t flags2) */ static inline void knot_wire_flags_set_ra(uint8_t *flags2) { - *flags2 |= DNSLIB_WIRE_RA_MASK; + *flags2 |= KNOT_WIRE_RA_MASK; } /*! @@ -863,7 +863,7 @@ static inline void knot_wire_flags_set_ra(uint8_t *flags2) */ static inline void knot_wire_flags_clear_ra(uint8_t *flags2) { - *flags2 &= ~DNSLIB_WIRE_RA_MASK; + *flags2 &= ~KNOT_WIRE_RA_MASK; } /* @@ -872,7 +872,7 @@ static inline void knot_wire_flags_clear_ra(uint8_t *flags2) enum knot_wire_pointer_consts { /*! \brief DNS packet pointer designation (first two bits set to 1). */ - DNSLIB_WIRE_PTR = (uint8_t)0xc0U + KNOT_WIRE_PTR = (uint8_t)0xc0U }; /*! @@ -886,13 +886,13 @@ static inline void knot_wire_put_pointer(uint8_t *pos, size_t ptr) { uint16_t p = ptr; knot_wire_write_u16(pos, p); - assert((pos[0] & DNSLIB_WIRE_PTR) == 0); - pos[0] |= DNSLIB_WIRE_PTR; + assert((pos[0] & KNOT_WIRE_PTR) == 0); + pos[0] |= KNOT_WIRE_PTR; } static inline int knot_wire_is_pointer(const uint8_t *pos) { - return ((pos[0] & DNSLIB_WIRE_PTR) != 0); + return ((pos[0] & KNOT_WIRE_PTR) != 0); } static inline size_t knot_wire_get_pointer(const uint8_t *pos) @@ -900,12 +900,12 @@ static inline size_t knot_wire_get_pointer(const uint8_t *pos) /*! \todo memcpy() is not needed, may be directly assigned. */ uint16_t p = 0; memcpy(&p, pos, 2); - p &= ~DNSLIB_WIRE_PTR; + p &= ~KNOT_WIRE_PTR; uint16_t p2 = knot_wire_read_u16((uint8_t *)&p); return p2; } -#endif /* _KNOT_DNSLIB_WIRE_H_ */ +#endif /* _KNOTDKNOT_WIRE_H_ */ /*! @} */ diff --git a/src/dnslib/xfr-in.c b/src/dnslib/xfr-in.c index 7afa3a4bbf46ff90d7bf0d969094a15aca0c1032..bd38128b33b124f7881a4aa53fdc5c90e8cd756e 100644 --- a/src/dnslib/xfr-in.c +++ b/src/dnslib/xfr-in.c @@ -21,20 +21,20 @@ static int xfrin_create_query(const knot_zone_contents_t *zone, uint16_t qtype, uint16_t qclass, uint8_t *buffer, size_t *size) { - knot_packet_t *pkt = knot_packet_new(DNSLIB_PACKET_PREALLOC_QUERY); - CHECK_ALLOC_LOG(pkt, DNSLIB_ENOMEM); + knot_packet_t *pkt = knot_packet_new(KNOT_PACKET_PREALLOC_QUERY); + CHECK_ALLOC_LOG(pkt, KNOT_ENOMEM); /*! \todo Get rid of the numeric constant. */ int rc = knot_packet_set_max_size(pkt, 512); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { knot_packet_free(&pkt); - return DNSLIB_ERROR; + return KNOT_ERROR; } rc = knot_query_init(pkt); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { knot_packet_free(&pkt); - return DNSLIB_ERROR; + return KNOT_ERROR; } knot_question_t question; @@ -51,10 +51,10 @@ static int xfrin_create_query(const knot_zone_contents_t *zone, uint16_t qtype, question.qclass = qclass; rc = knot_query_set_question(pkt, &question); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { knot_dname_release(question.qname); knot_packet_free(&pkt); - return DNSLIB_ERROR; + return KNOT_ERROR; } /*! \todo Set some random ID!! */ @@ -64,17 +64,17 @@ static int xfrin_create_query(const knot_zone_contents_t *zone, uint16_t qtype, uint8_t *wire = NULL; size_t wire_size = 0; rc = knot_packet_to_wire(pkt, &wire, &wire_size); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { knot_dname_release(question.qname); knot_packet_free(&pkt); - return DNSLIB_ERROR; + return KNOT_ERROR; } if (wire_size > *size) { debug_knot_xfr("Not enough space provided for the wire " "format of the query.\n"); knot_packet_free(&pkt); - return DNSLIB_ESPACE; + return KNOT_ESPACE; } memcpy(buffer, wire, wire_size); @@ -88,7 +88,7 @@ static int xfrin_create_query(const knot_zone_contents_t *zone, uint16_t qtype, /* Release qname. */ knot_dname_release(question.qname); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -164,8 +164,8 @@ static uint32_t xfrin_serial_difference(uint32_t local, uint32_t remote) int xfrin_create_soa_query(const knot_zone_contents_t *zone, uint8_t *buffer, size_t *size) { - return xfrin_create_query(zone, DNSLIB_RRTYPE_SOA, - DNSLIB_CLASS_IN, buffer, size); + return xfrin_create_query(zone, KNOT_RRTYPE_SOA, + KNOT_CLASS_IN, buffer, size); } /*----------------------------------------------------------------------------*/ @@ -181,8 +181,8 @@ int xfrin_transfer_needed(const knot_zone_contents_t *zone, if (soa_response->parsed < soa_response->size) { ret = knot_packet_parse_rest(soa_response); - if (ret != DNSLIB_EOK) { - return DNSLIB_EMALF; + if (ret != KNOT_EOK) { + return KNOT_EMALF; } } @@ -191,13 +191,13 @@ int xfrin_transfer_needed(const knot_zone_contents_t *zone, */ const knot_rrset_t *soa_rrset = knot_node_rrset(knot_zone_contents_apex(zone), - DNSLIB_RRTYPE_SOA); + KNOT_RRTYPE_SOA); if (soa_rrset == NULL) { char *name = knot_dname_to_str(knot_node_owner( knot_zone_contents_apex(zone))); debug_knot_xfr("SOA RRSet missing in the zone %s!\n", name); free(name); - return DNSLIB_ERROR; + return KNOT_ERROR; } int64_t local_serial = knot_rdata_soa_serial( @@ -206,7 +206,7 @@ int xfrin_transfer_needed(const knot_zone_contents_t *zone, char *name = knot_dname_to_str(knot_rrset_owner(soa_rrset)); debug_knot_xfr("Malformed data in SOA of zone %s\n", name); free(name); - return DNSLIB_EMALF; // maybe some other error + return KNOT_EMALF; // maybe some other error } /* @@ -215,14 +215,14 @@ int xfrin_transfer_needed(const knot_zone_contents_t *zone, // the SOA should be the first (and only) RRSet in the response soa_rrset = knot_packet_answer_rrset(soa_response, 0); if (soa_rrset == NULL - || knot_rrset_type(soa_rrset) != DNSLIB_RRTYPE_SOA) { - return DNSLIB_EMALF; + || knot_rrset_type(soa_rrset) != KNOT_RRTYPE_SOA) { + return KNOT_EMALF; } int64_t remote_serial = knot_rdata_soa_serial( knot_rrset_rdata(soa_rrset)); if (remote_serial < 0) { - return DNSLIB_EMALF; // maybe some other error + return KNOT_EMALF; // maybe some other error } uint32_t diff = xfrin_serial_difference(local_serial, remote_serial); @@ -234,8 +234,8 @@ int xfrin_transfer_needed(const knot_zone_contents_t *zone, int xfrin_create_axfr_query(const knot_zone_contents_t *zone, uint8_t *buffer, size_t *size) { - return xfrin_create_query(zone, DNSLIB_RRTYPE_AXFR, - DNSLIB_CLASS_IN, buffer, size); + return xfrin_create_query(zone, KNOT_RRTYPE_AXFR, + KNOT_CLASS_IN, buffer, size); } /*----------------------------------------------------------------------------*/ @@ -243,8 +243,8 @@ int xfrin_create_axfr_query(const knot_zone_contents_t *zone, uint8_t *buffer, int xfrin_create_ixfr_query(const knot_zone_contents_t *zone, uint8_t *buffer, size_t *size) { - return xfrin_create_query(zone, DNSLIB_RRTYPE_IXFR, - DNSLIB_CLASS_IN, buffer, size); + return xfrin_create_query(zone, KNOT_RRTYPE_IXFR, + KNOT_CLASS_IN, buffer, size); } /*----------------------------------------------------------------------------*/ @@ -254,41 +254,41 @@ int xfrin_process_axfr_packet(const uint8_t *pkt, size_t size, { if (pkt == NULL || zone == NULL) { debug_knot_xfr("Wrong parameters supported.\n"); - return DNSLIB_EBADARG; + return KNOT_EBADARG; } knot_packet_t *packet = - knot_packet_new(DNSLIB_PACKET_PREALLOC_NONE); + knot_packet_new(KNOT_PACKET_PREALLOC_NONE); if (packet == NULL) { debug_knot_xfr("Could not create packet structure.\n"); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } int ret = knot_packet_parse_from_wire(packet, pkt, size, 1); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Could not parse packet: %s.\n", knot_strerror2(ret)); knot_packet_free(&packet); /*! \todo Cleanup. */ - return DNSLIB_EMALF; + return KNOT_EMALF; } knot_rrset_t *rr = NULL; ret = knot_packet_parse_next_rr_answer(packet, &rr); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Could not parse first Answer RR: %s.\n", knot_strerror(ret)); knot_packet_free(&packet); /*! \todo Cleanup. */ - return DNSLIB_EMALF; + return KNOT_EMALF; } if (rr == NULL) { debug_knot_xfr("No RRs in the packet.\n"); knot_packet_free(&packet); /*! \todo Cleanup. */ - return DNSLIB_EMALF; + return KNOT_EMALF; } knot_node_t *node = NULL; @@ -297,19 +297,19 @@ int xfrin_process_axfr_packet(const uint8_t *pkt, size_t size, if (*zone == NULL) { // create new zone /*! \todo Ensure that the packet is the first one. */ - if (knot_rrset_type(rr) != DNSLIB_RRTYPE_SOA) { + if (knot_rrset_type(rr) != KNOT_RRTYPE_SOA) { debug_knot_xfr("No zone created, but the first RR in Answer" " is not a SOA RR.\n"); knot_packet_free(&packet); knot_node_free(&node, 0, 0); knot_rrset_deep_free(&rr, 1, 1, 1); /*! \todo Cleanup. */ - return DNSLIB_EMALF; + return KNOT_EMALF; } if (knot_dname_compare(knot_rrset_owner(rr), knot_packet_qname(packet)) != 0) { -DEBUG_DNSLIB_XFR( +DEBUG_KNOT_XFR( char *rr_owner = knot_dname_to_str(knot_rrset_owner(rr)); char *qname = knot_dname_to_str( @@ -325,7 +325,7 @@ DEBUG_DNSLIB_XFR( knot_packet_free(&packet); knot_node_free(&node, 0, 0); knot_rrset_deep_free(&rr, 1, 1, 1); - return DNSLIB_EMALF; + return KNOT_EMALF; } node = knot_node_new(rr->owner, NULL, 0); @@ -333,7 +333,7 @@ DEBUG_DNSLIB_XFR( debug_knot_xfr("Failed to create new node.\n"); knot_packet_free(&packet); knot_rrset_deep_free(&rr, 1, 1, 1); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } // the first RR is SOA and its owner and QNAME are the same @@ -346,7 +346,7 @@ DEBUG_DNSLIB_XFR( knot_node_free(&node, 0, 0); knot_rrset_deep_free(&rr, 1, 1, 1); /*! \todo Cleanup. */ - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } in_zone = 1; @@ -354,7 +354,7 @@ DEBUG_DNSLIB_XFR( // add the RRSet to the node //ret = knot_node_add_rrset(node, rr, 0); ret = knot_zone_contents_add_rrset(*zone, rr, &node, - DNSLIB_RRSET_DUPL_MERGE, 1); + KNOT_RRSET_DUPL_MERGE, 1); if (ret < 0) { debug_knot_xfr("Failed to add RRSet to zone node: %s.\n", knot_strerror2(ret)); @@ -362,7 +362,7 @@ DEBUG_DNSLIB_XFR( knot_node_free(&node, 0, 0); knot_rrset_deep_free(&rr, 1, 1, 1); /*! \todo Cleanup. */ - return DNSLIB_ERROR; + return KNOT_ERROR; } else if (ret > 0) { // merged, free the RRSet knot_rrset_deep_free(&rr, 1, 0, 0); @@ -372,7 +372,7 @@ DEBUG_DNSLIB_XFR( ret = knot_packet_parse_next_rr_answer(packet, &rr); } - while (ret == DNSLIB_EOK && rr != NULL) { + while (ret == KNOT_EOK && rr != NULL) { // process the parsed RR debug_knot_xfr("\nNext RR:\n\n"); @@ -391,31 +391,31 @@ DEBUG_DNSLIB_XFR( node = NULL; } - if (knot_rrset_type(rr) == DNSLIB_RRTYPE_SOA) { + if (knot_rrset_type(rr) == KNOT_RRTYPE_SOA) { // this must be the last SOA, do not do anything more // discard the RR assert(knot_zone_contents_apex((*zone)) != NULL); assert(knot_node_rrset(knot_zone_contents_apex( (*zone)), - DNSLIB_RRTYPE_SOA) != NULL); + KNOT_RRTYPE_SOA) != NULL); debug_knot_xfr("Found last SOA, transfer finished.\n"); knot_rrset_deep_free(&rr, 1, 1, 1); knot_packet_free(&packet); return 1; } - if (knot_rrset_type(rr) == DNSLIB_RRTYPE_RRSIG) { + if (knot_rrset_type(rr) == KNOT_RRTYPE_RRSIG) { // RRSIGs require special handling, as there are no // nodes for them knot_rrset_t *tmp_rrset = NULL; ret = knot_zone_contents_add_rrsigs(*zone, rr, - &tmp_rrset, &node, DNSLIB_RRSET_DUPL_MERGE, 1); + &tmp_rrset, &node, KNOT_RRSET_DUPL_MERGE, 1); if (ret < 0) { debug_knot_xfr("Failed to add RRSIGs.\n"); knot_packet_free(&packet); knot_node_free(&node, 1, 0); // ??? knot_rrset_deep_free(&rr, 1, 1, 1); - return DNSLIB_ERROR; /*! \todo Other error code. */ + return KNOT_ERROR; /*! \todo Other error code. */ } else if (ret == 1) { knot_rrset_deep_free(&rr, 1, 0, 0); } else if (ret == 2) { @@ -438,7 +438,7 @@ DEBUG_DNSLIB_XFR( uint8_t, int) = NULL; - if (knot_rrset_type(rr) == DNSLIB_RRTYPE_NSEC3) { + if (knot_rrset_type(rr) == KNOT_RRTYPE_NSEC3) { get_node = knot_zone_contents_get_nsec3_node; add_node = knot_zone_contents_add_nsec3_node; } else { @@ -461,7 +461,7 @@ DEBUG_DNSLIB_XFR( debug_knot_xfr("Failed to create new node.\n"); knot_packet_free(&packet); knot_rrset_deep_free(&rr, 1, 1, 1); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } debug_knot_xfr("Created new node for the record.\n"); @@ -472,7 +472,7 @@ DEBUG_DNSLIB_XFR( knot_packet_free(&packet); knot_node_free(&node, 1, 0); // ??? knot_rrset_deep_free(&rr, 1, 1, 1); - return DNSLIB_ERROR; + return KNOT_ERROR; } else if (ret > 0) { // should not happen, this is new node assert(0); @@ -480,12 +480,12 @@ DEBUG_DNSLIB_XFR( } ret = add_node(*zone, node, 1, 0, 1); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to add node to zone.\n"); knot_packet_free(&packet); knot_node_free(&node, 1, 0); // ??? knot_rrset_deep_free(&rr, 1, 1, 1); - return DNSLIB_ERROR; + return KNOT_ERROR; } in_zone = 1; @@ -493,11 +493,11 @@ DEBUG_DNSLIB_XFR( assert(in_zone); ret = knot_zone_contents_add_rrset(*zone, rr, &node, - DNSLIB_RRSET_DUPL_MERGE, 1); + KNOT_RRSET_DUPL_MERGE, 1); if (ret < 0) { debug_knot_xfr("Failed to add RRSet to zone: %s.\n", knot_strerror2(ret)); - return DNSLIB_ERROR; + return KNOT_ERROR; } else if (ret > 0) { // merged, free the RRSet knot_rrset_deep_free(&rr, 1, 0, 0); @@ -511,7 +511,7 @@ DEBUG_DNSLIB_XFR( ret = knot_packet_parse_next_rr_answer(packet, &rr); } - assert(ret != DNSLIB_EOK || rr == NULL); + assert(ret != KNOT_EOK || rr == NULL); if (ret < 0) { // some error in parsing @@ -521,28 +521,28 @@ DEBUG_DNSLIB_XFR( knot_node_free(&node, 0, 0); knot_rrset_deep_free(&rr, 1, 1, 1); /*! \todo Cleanup. */ - return DNSLIB_EMALF; + return KNOT_EMALF; } - assert(ret == DNSLIB_EOK); + assert(ret == KNOT_EOK); assert(rr == NULL); // if the last node is not yet in the zone, insert if (!in_zone) { assert(node != NULL); ret = knot_zone_contents_add_node(*zone, node, 1, 0, 1); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to add last node into zone.\n"); knot_packet_free(&packet); knot_node_free(&node, 1, 0); - return DNSLIB_ERROR; /*! \todo Other error */ + return KNOT_ERROR; /*! \todo Other error */ } } knot_packet_free(&packet); debug_knot_xfr("Processed one AXFR packet successfully.\n"); - return (ret == DNSLIB_EOK) ? DNSLIB_EOK : DNSLIB_EMALF; + return (ret == KNOT_EOK) ? KNOT_EOK : KNOT_EMALF; } /*----------------------------------------------------------------------------*/ @@ -550,30 +550,30 @@ DEBUG_DNSLIB_XFR( static int xfrin_parse_first_rr(knot_packet_t **packet, const uint8_t *pkt, size_t size, knot_rrset_t **rr) { - *packet = knot_packet_new(DNSLIB_PACKET_PREALLOC_NONE); + *packet = knot_packet_new(KNOT_PACKET_PREALLOC_NONE); if (packet == NULL) { debug_knot_xfr("Could not create packet structure.\n"); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } int ret = knot_packet_parse_from_wire(*packet, pkt, size, 1); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Could not parse packet: %s.\n", knot_strerror2(ret)); knot_packet_free(packet); - return DNSLIB_EMALF; + return KNOT_EMALF; } ret = knot_packet_parse_next_rr_answer(*packet, rr); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Could not parse first Answer RR: %s.\n", knot_strerror2(ret)); knot_packet_free(packet); - return DNSLIB_EMALF; + return KNOT_EMALF; } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -594,12 +594,12 @@ static int xfrin_parse_first_rr(knot_packet_t **packet, const uint8_t *pkt, // uint8_t *binary = NULL; // size_t actual_size = 0; // int ret = knot_zdump_rrset_serialize(rrset, &binary, &actual_size); -// if (ret != DNSLIB_EOK) { -// return DNSLIB_ERROR; /*! \todo Other code? */ +// if (ret != KNOT_EOK) { +// return KNOT_ERROR; /*! \todo Other code? */ // } // ret = xfrin_check_binary_size(data, allocated, *size + actual_size); -// if (ret != DNSLIB_EOK) { +// if (ret != KNOT_EOK) { // free(binary); // return ret; // } @@ -608,7 +608,7 @@ static int xfrin_parse_first_rr(knot_packet_t **packet, const uint8_t *pkt, // *size += actual_size; // free(binary); -// return DNSLIB_EOK; +// return KNOT_EOK; //} /*----------------------------------------------------------------------------*/ @@ -632,7 +632,7 @@ static int xfrin_parse_first_rr(knot_packet_t **packet, const uint8_t *pkt, // // 1) origin SOA // ret = xfrin_changeset_rrset_to_binary(&ch->data, &ch->size, // &ch->allocated, ch->soa_from); -// if (ret != DNSLIB_EOK) { +// if (ret != KNOT_EOK) { // free(ch->data); // ch->data = NULL; // return ret; @@ -647,7 +647,7 @@ static int xfrin_parse_first_rr(knot_packet_t **packet, const uint8_t *pkt, // &ch->size, // &ch->allocated, // ch->remove[j]); -// if (ret != DNSLIB_EOK) { +// if (ret != KNOT_EOK) { // free(ch->data); // ch->data = NULL; // return ret; @@ -657,7 +657,7 @@ static int xfrin_parse_first_rr(knot_packet_t **packet, const uint8_t *pkt, // // 3) new SOA // ret = xfrin_changeset_rrset_to_binary(&ch->data, &ch->size, // &ch->allocated, ch->soa_to); -// if (ret != DNSLIB_EOK) { +// if (ret != KNOT_EOK) { // free(ch->data); // ch->data = NULL; // return ret; @@ -670,7 +670,7 @@ static int xfrin_parse_first_rr(knot_packet_t **packet, const uint8_t *pkt, // &ch->size, // &ch->allocated, // ch->add[j]); -// if (ret != DNSLIB_EOK) { +// if (ret != KNOT_EOK) { // free(ch->data); // ch->data = NULL; // return ret; @@ -678,7 +678,7 @@ static int xfrin_parse_first_rr(knot_packet_t **packet, const uint8_t *pkt, // } // } -// return DNSLIB_EOK; +// return KNOT_EOK; //} /*----------------------------------------------------------------------------*/ @@ -687,7 +687,7 @@ int xfrin_process_ixfr_packet(const uint8_t *pkt, size_t size, { if (pkt == NULL || changesets == NULL) { debug_knot_xfr("Wrong parameters supported.\n"); - return DNSLIB_EBADARG; + return KNOT_EBADARG; } knot_packet_t *packet = NULL; @@ -698,7 +698,7 @@ int xfrin_process_ixfr_packet(const uint8_t *pkt, size_t size, int ret; if ((ret = xfrin_parse_first_rr(&packet, pkt, size, &soa1)) - != DNSLIB_EOK) { + != KNOT_EOK) { return ret; } @@ -708,23 +708,23 @@ int xfrin_process_ixfr_packet(const uint8_t *pkt, size_t size, debug_knot_xfr("No RRs in the packet.\n"); knot_packet_free(&packet); /*! \todo Some other action??? */ - return DNSLIB_EMALF; + return KNOT_EMALF; } assert(soa1 != NULL); if (*changesets == NULL - && (ret = knot_changeset_allocate(changesets)) != DNSLIB_EOK) { + && (ret = knot_changeset_allocate(changesets)) != KNOT_EOK) { knot_packet_free(&packet); return ret; } /*! \todo Do some checking about what is the first and second SOA. */ - if (knot_rrset_type(soa1) != DNSLIB_RRTYPE_SOA) { + if (knot_rrset_type(soa1) != KNOT_RRTYPE_SOA) { debug_knot_xfr("First RR is not a SOA RR!\n"); knot_packet_free(&packet); - return DNSLIB_EMALF; + return KNOT_EMALF; } // we may drop this SOA, not needed right now; parse the next one @@ -733,10 +733,10 @@ int xfrin_process_ixfr_packet(const uint8_t *pkt, size_t size, /*! \todo replace by (*changesets)->count */ int i = 0; - while (ret == DNSLIB_EOK && rr != NULL) { - if (knot_rrset_type(rr) != DNSLIB_RRTYPE_SOA) { + while (ret == KNOT_EOK && rr != NULL) { + if (knot_rrset_type(rr) != KNOT_RRTYPE_SOA) { debug_knot_xfr("Next RR is not a SOA RR as it should be!\n"); - ret = DNSLIB_EMALF; + ret = KNOT_EMALF; goto cleanup; } @@ -747,7 +747,7 @@ int xfrin_process_ixfr_packet(const uint8_t *pkt, size_t size, } if ((ret = knot_changesets_check_size(*changesets)) - != DNSLIB_EOK) { + != KNOT_EOK) { knot_rrset_deep_free(&rr, 1, 1, 1); goto cleanup; } @@ -755,21 +755,21 @@ int xfrin_process_ixfr_packet(const uint8_t *pkt, size_t size, // save the origin SOA of the remove part ret = knot_changeset_add_soa( &(*changesets)->sets[i], rr, XFRIN_CHANGESET_REMOVE); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { knot_rrset_deep_free(&rr, 1, 1, 1); goto cleanup; } ret = knot_packet_parse_next_rr_answer(packet, &rr); - while (ret == DNSLIB_EOK && rr != NULL) { - if (knot_rrset_type(rr) == DNSLIB_RRTYPE_SOA) { + while (ret == KNOT_EOK && rr != NULL) { + if (knot_rrset_type(rr) == KNOT_RRTYPE_SOA) { break; } - assert(knot_rrset_type(rr) != DNSLIB_RRTYPE_SOA); + assert(knot_rrset_type(rr) != KNOT_RRTYPE_SOA); if ((ret = knot_changeset_add_new_rr( &(*changesets)->sets[i], rr, - XFRIN_CHANGESET_REMOVE)) != DNSLIB_EOK) { + XFRIN_CHANGESET_REMOVE)) != KNOT_EOK) { knot_rrset_deep_free(&rr, 1, 1, 1); goto cleanup; } @@ -777,26 +777,26 @@ int xfrin_process_ixfr_packet(const uint8_t *pkt, size_t size, /*! \todo Replace by check. */ assert(rr != NULL - && knot_rrset_type(rr) == DNSLIB_RRTYPE_SOA); + && knot_rrset_type(rr) == KNOT_RRTYPE_SOA); // save the origin SOA of the add part ret = knot_changeset_add_soa( &(*changesets)->sets[i], rr, XFRIN_CHANGESET_ADD); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { knot_rrset_deep_free(&rr, 1, 1, 1); goto cleanup; } ret = knot_packet_parse_next_rr_answer(packet, &rr); - while (ret == DNSLIB_EOK && rr != NULL) { - if (knot_rrset_type(rr) == DNSLIB_RRTYPE_SOA) { + while (ret == KNOT_EOK && rr != NULL) { + if (knot_rrset_type(rr) == KNOT_RRTYPE_SOA) { break; } - assert(knot_rrset_type(rr) != DNSLIB_RRTYPE_SOA); + assert(knot_rrset_type(rr) != KNOT_RRTYPE_SOA); if ((ret = knot_changeset_add_new_rr( &(*changesets)->sets[i], rr, - XFRIN_CHANGESET_ADD)) != DNSLIB_EOK) { + XFRIN_CHANGESET_ADD)) != KNOT_EOK) { knot_rrset_deep_free(&rr, 1, 1, 1); goto cleanup; } @@ -804,29 +804,29 @@ int xfrin_process_ixfr_packet(const uint8_t *pkt, size_t size, /*! \todo Replace by check. */ assert(rr != NULL - && knot_rrset_type(rr) == DNSLIB_RRTYPE_SOA); + && knot_rrset_type(rr) == KNOT_RRTYPE_SOA); // next chunk, continue the whole loop ++i; } - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Could not parse next Answer RR: %s.\n", knot_strerror2(ret)); - ret = DNSLIB_EMALF; + ret = KNOT_EMALF; goto cleanup; } /*! \todo Replace by checks? */ assert(soa2 != NULL); - assert(knot_rrset_type(soa2) == DNSLIB_RRTYPE_SOA); + assert(knot_rrset_type(soa2) == KNOT_RRTYPE_SOA); assert(knot_rdata_soa_serial(knot_rrset_rdata(soa1)) == knot_rdata_soa_serial(knot_rrset_rdata(soa2))); knot_rrset_deep_free(&soa2, 1, 1, 1); // // everything is ready, convert the changesets -// if ((ret = knot_changesets_to_binary(*changesets)) != DNSLIB_EOK) { +// if ((ret = knot_changesets_to_binary(*changesets)) != KNOT_EOK) { // // free the changesets // debug_knot_xfr("Failed to convert changesets to binary format.\n"); // xfrin_free_changesets(changesets); @@ -914,14 +914,14 @@ static int xfrin_changes_check_rrsets(knot_rrset_t ***rrsets, knot_rrset_t **rrsets_new = (knot_rrset_t **)calloc(new_count, sizeof(knot_rrset_t *)); if (rrsets_new == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } memcpy(rrsets_new, *rrsets, *count); *rrsets = rrsets_new; *allocated = new_count; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -937,14 +937,14 @@ static int xfrin_changes_check_nodes(knot_node_t ***nodes, knot_node_t **nodes_new = (knot_node_t **)calloc(new_count, sizeof(knot_node_t *)); if (nodes_new == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } memcpy(nodes_new, *nodes, *count); *nodes = nodes_new; *allocated = new_count; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -960,14 +960,14 @@ static int xfrin_changes_check_nodes(knot_node_t ***nodes, // knot_dname_t **dnames_new = // (knot_dname_t **)calloc(new_count, sizeof(knot_dname_t *)); // if (dnames_new == NULL) { -// return DNSLIB_ENOMEM; +// return KNOT_ENOMEM; // } // memcpy(dnames_new, *dnames, *count); // *dnames = dnames_new; // *allocated = new_count; -// return DNSLIB_EOK; +// return KNOT_EOK; //} /*----------------------------------------------------------------------------*/ @@ -1054,9 +1054,9 @@ static int xfrin_get_node_copy(knot_node_t **node, xfrin_changes_t *changes) if (new_node == NULL) { debug_knot_xfr("Creating copy of node.\n"); int ret = knot_node_shallow_copy(*node, &new_node); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to create node copy.\n"); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } // save the copy of the node @@ -1064,7 +1064,7 @@ static int xfrin_get_node_copy(knot_node_t **node, xfrin_changes_t *changes) &changes->new_nodes, &changes->new_nodes_count, &changes->new_nodes_allocated); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to add new node to list.\n"); knot_node_free(&new_node, 0, 0); return ret; @@ -1075,7 +1075,7 @@ static int xfrin_get_node_copy(knot_node_t **node, xfrin_changes_t *changes) &changes->old_nodes, &changes->old_nodes_count, &changes->old_nodes_allocated); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to add old node to list.\n"); knot_node_free(&new_node, 0, 0); return ret; @@ -1092,7 +1092,7 @@ static int xfrin_get_node_copy(knot_node_t **node, xfrin_changes_t *changes) } *node = new_node; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1102,16 +1102,16 @@ static int xfrin_copy_old_rrset(knot_rrset_t *old, { // create new RRSet by copying the old one int ret = knot_rrset_shallow_copy(old, copy); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to create RRSet copy.\n"); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } // add the RRSet to the list of new RRSets ret = xfrin_changes_check_rrsets(&changes->new_rrsets, &changes->new_rrsets_count, &changes->new_rrsets_allocated); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to add new RRSet to list.\n"); knot_rrset_free(copy); return ret; @@ -1123,7 +1123,7 @@ static int xfrin_copy_old_rrset(knot_rrset_t *old, ret = xfrin_changes_check_rrsets(&changes->old_rrsets, &changes->old_rrsets_count, &changes->old_rrsets_allocated); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to add old RRSet to list.\n"); return ret; } @@ -1132,12 +1132,12 @@ static int xfrin_copy_old_rrset(knot_rrset_t *old, // // replace the RRSet in the node copy by the new one // ret = knot_node_add_rrset(node, *copy, 0); -// if (ret != DNSLIB_EOK) { +// if (ret != KNOT_EOK) { // debug_knot_xfr("Failed to add RRSet copy to node\n"); -// return DNSLIB_ERROR; +// return KNOT_ERROR; // } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1153,18 +1153,18 @@ static int xfrin_copy_rrset(knot_node_t *node, knot_rr_type_t type, } int ret = xfrin_copy_old_rrset(old, rrset, changes); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } // replace the RRSet in the node copy by the new one ret = knot_node_add_rrset(node, *rrset, 0); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to add RRSet copy to node\n"); - return DNSLIB_ERROR; + return KNOT_ERROR; } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1178,7 +1178,7 @@ static int xfrin_apply_remove_rrsigs(xfrin_changes_t *changes, assert(remove != NULL); assert(node != NULL); assert(rrset != NULL); - assert(knot_rrset_type(remove) == DNSLIB_RRTYPE_RRSIG); + assert(knot_rrset_type(remove) == KNOT_RRTYPE_RRSIG); /*! \todo These optimalizations may be useless as there may be only * one RRSet of each type and owner in the changeset. @@ -1197,7 +1197,7 @@ static int xfrin_apply_remove_rrsigs(xfrin_changes_t *changes, // copy the rrset ret = xfrin_copy_rrset(node, type, rrset, changes); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } } else { @@ -1219,13 +1219,13 @@ static int xfrin_apply_remove_rrsigs(xfrin_changes_t *changes, /*! \todo This may be done unnecessarily more times. */ knot_rrset_t *rrsigs; ret = xfrin_copy_old_rrset(old, &rrsigs, changes); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } // set the RRSIGs to the new RRSet copy - if (knot_rrset_set_rrsigs(*rrset, rrsigs) != DNSLIB_EOK) { - return DNSLIB_ERROR; + if (knot_rrset_set_rrsigs(*rrset, rrsigs) != KNOT_EOK) { + return KNOT_ERROR; } @@ -1250,7 +1250,7 @@ static int xfrin_apply_remove_rrsigs(xfrin_changes_t *changes, ret = xfrin_changes_check_rrsets(&changes->old_rrsets, &changes->old_rrsets_count, &changes->old_rrsets_allocated); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to add empty RRSet to the " "list of old RRSets."); // delete the RRSet right away @@ -1272,7 +1272,7 @@ static int xfrin_apply_remove_rrsigs(xfrin_changes_t *changes, ret = xfrin_changes_check_rrsets(&changes->old_rrsets, &changes->old_rrsets_count, &changes->old_rrsets_allocated); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to add empty RRSet to the " "list of old RRSets."); // delete the RRSet right away @@ -1289,7 +1289,7 @@ static int xfrin_apply_remove_rrsigs(xfrin_changes_t *changes, rdata->next = changes->old_rdata; changes->old_rdata = rdata; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1321,7 +1321,7 @@ static int xfrin_apply_remove_normal(xfrin_changes_t *changes, */ ret = xfrin_copy_rrset(node, knot_rrset_type(remove), rrset, changes); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } } @@ -1331,7 +1331,7 @@ static int xfrin_apply_remove_normal(xfrin_changes_t *changes, return 1; } -DEBUG_DNSLIB_XFR( +DEBUG_KNOT_XFR( char *name = knot_dname_to_str(knot_rrset_owner(*rrset)); debug_knot_xfr("Updating RRSet with owner %s, type %s\n", name, knot_rrtype_to_string(knot_rrset_type(*rrset))); @@ -1357,7 +1357,7 @@ DEBUG_DNSLIB_XFR( ret = xfrin_changes_check_rrsets(&changes->old_rrsets, &changes->old_rrsets_count, &changes->old_rrsets_allocated); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to add empty RRSet to the " "list of old RRSets."); // delete the RRSet right away @@ -1372,7 +1372,7 @@ DEBUG_DNSLIB_XFR( rdata->next = changes->old_rdata; changes->old_rdata = rdata; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1406,7 +1406,7 @@ static int xfrin_apply_remove(knot_zone_contents_t *contents, // create a copy of the node if not already created if (!knot_node_is_new(node)) { ret = xfrin_get_node_copy(&node, changes); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } } @@ -1415,7 +1415,7 @@ static int xfrin_apply_remove(knot_zone_contents_t *contents, assert(knot_node_is_new(node)); if (knot_rrset_type(chset->remove[i]) - == DNSLIB_RRTYPE_RRSIG) { + == KNOT_RRTYPE_RRSIG) { ret = xfrin_apply_remove_rrsigs(changes, chset->remove[i], node, &rrset); @@ -1427,12 +1427,12 @@ static int xfrin_apply_remove(knot_zone_contents_t *contents, if (ret > 0) { continue; - } else if (ret != DNSLIB_EOK) { + } else if (ret != KNOT_EOK) { return ret; } } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1443,7 +1443,7 @@ static knot_node_t *xfrin_add_new_node(knot_zone_contents_t *contents, return NULL; knot_node_t *node = knot_node_new(knot_rrset_get_owner(rrset), - NULL, DNSLIB_NODE_FLAGS_NEW); + NULL, KNOT_NODE_FLAGS_NEW); if (node == NULL) { debug_knot_xfr("Failed to create a new node.\n"); return NULL; @@ -1453,21 +1453,21 @@ static knot_node_t *xfrin_add_new_node(knot_zone_contents_t *contents, // insert the node into zone structures and create parents if // necessary - if (knot_rrset_type(rrset) == DNSLIB_RRTYPE_NSEC3) { + if (knot_rrset_type(rrset) == KNOT_RRTYPE_NSEC3) { ret = knot_zone_contents_add_nsec3_node(contents, node, 1, 0, 1); } else { ret = knot_zone_contents_add_node(contents, node, 1, - DNSLIB_NODE_FLAGS_NEW, 1); + KNOT_NODE_FLAGS_NEW, 1); } - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to add new node to zone contents.\n"); return NULL; } // find previous node and connect the new one to it knot_node_t *prev = NULL; - if (knot_rrset_type(rrset) == DNSLIB_RRTYPE_NSEC3) { + if (knot_rrset_type(rrset) == KNOT_RRTYPE_NSEC3) { prev = knot_zone_contents_get_previous_nsec3(contents, knot_rrset_owner(rrset)); } else { @@ -1512,23 +1512,23 @@ static int xfrin_apply_add_normal(xfrin_changes_t *changes, * zone-contents' version of this function?? */ ret = knot_node_add_rrset(node, add, 0); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to add RRSet to node.\n"); - return DNSLIB_ERROR; + return KNOT_ERROR; } - return DNSLIB_EOK; // done, continue + return KNOT_EOK; // done, continue } knot_rrset_t *old = *rrset; -DEBUG_DNSLIB_XFR( +DEBUG_KNOT_XFR( char *name = knot_dname_to_str(knot_rrset_owner(*rrset)); debug_knot_xfr("Found RRSet with owner %s, type %s\n", name, knot_rrtype_to_string(knot_rrset_type(*rrset))); free(name); ); ret = xfrin_copy_old_rrset(old, rrset, changes); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } @@ -1544,9 +1544,9 @@ DEBUG_DNSLIB_XFR( * TODO: add the 'add' rrset to list of old RRSets? */ ret = knot_rrset_merge((void **)rrset, (void **)&add); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to merge changeset RRSet to copy.\n"); - return DNSLIB_ERROR; + return KNOT_ERROR; } } @@ -1561,7 +1561,7 @@ static int xfrin_apply_add_rrsig(xfrin_changes_t *changes, assert(remove != NULL); assert(node != NULL); assert(rrset != NULL); - assert(knot_rrset_type(add) == DNSLIB_RRTYPE_RRSIG); + assert(knot_rrset_type(add) == KNOT_RRTYPE_RRSIG); int ret; @@ -1594,18 +1594,18 @@ static int xfrin_apply_add_rrsig(xfrin_changes_t *changes, knot_rrset_ttl(add)); if (*rrset == NULL) { debug_knot_xfr("Failed to create new RRSet for RRSIGs.\n"); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } // add the RRSet from the changeset to the node ret = knot_node_add_rrset(node, *rrset, 0); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to add RRSet to node.\n"); - return DNSLIB_ERROR; + return KNOT_ERROR; } } -DEBUG_DNSLIB_XFR( +DEBUG_KNOT_XFR( char *name = knot_dname_to_str(knot_rrset_owner(*rrset)); debug_knot_xfr("Found RRSet with owner %s, type %s\n", name, knot_rrtype_to_string(knot_rrset_type(*rrset))); @@ -1614,19 +1614,19 @@ DEBUG_DNSLIB_XFR( if (knot_rrset_rrsigs(*rrset) == NULL) { ret = knot_rrset_set_rrsigs(*rrset, add); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to add RRSIGs to the RRSet.\n"); - return DNSLIB_ERROR; + return KNOT_ERROR; } - return DNSLIB_EOK; + return KNOT_EOK; } else { knot_rrset_t *old = knot_rrset_get_rrsigs(*rrset); assert(old != NULL); knot_rrset_t *rrsig; ret = xfrin_copy_old_rrset(old, &rrsig, changes); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } @@ -1638,13 +1638,13 @@ DEBUG_DNSLIB_XFR( * */ ret = knot_rrset_merge((void **)&rrsig, (void **)&add); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to merge changeset RRSet to copy.\n"); - return DNSLIB_ERROR; + return KNOT_ERROR; } } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1674,7 +1674,7 @@ static int xfrin_apply_add(knot_zone_contents_t *contents, if (node == NULL) { debug_knot_xfr("Failed to create new node " "in zone.\n"); - return DNSLIB_ERROR; + return KNOT_ERROR; } continue; // continue with another RRSet } @@ -1688,7 +1688,7 @@ static int xfrin_apply_add(knot_zone_contents_t *contents, assert(node != NULL); assert(knot_node_is_new(node)); - if (knot_rrset_type(chset->add[i]) == DNSLIB_RRTYPE_RRSIG) { + if (knot_rrset_type(chset->add[i]) == KNOT_RRTYPE_RRSIG) { ret = xfrin_apply_add_rrsig(changes, chset->add[i], node, &rrset); } else { @@ -1696,12 +1696,12 @@ static int xfrin_apply_add(knot_zone_contents_t *contents, node, &rrset); } - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1743,7 +1743,7 @@ static int xfrin_apply_replace_soa(knot_zone_contents_t *contents, // create a copy of the node if not already created if (!knot_node_is_new(node)) { ret = xfrin_get_node_copy(&node, changes); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } } @@ -1752,14 +1752,14 @@ static int xfrin_apply_replace_soa(knot_zone_contents_t *contents, // remove the SOA RRSet from the apex knot_rrset_t *rrset = knot_node_remove_rrset(node, - DNSLIB_RRTYPE_SOA); + KNOT_RRTYPE_SOA); assert(rrset != NULL); // add the old RRSet to the list of old RRSets ret = xfrin_changes_check_rrsets(&changes->old_rrsets, &changes->old_rrsets_count, &changes->old_rrsets_allocated); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to add old RRSet to list.\n"); return ret; } @@ -1768,12 +1768,12 @@ static int xfrin_apply_replace_soa(knot_zone_contents_t *contents, // and just insert the new SOA RRSet to the node ret = knot_node_add_rrset(node, chset->soa_to, 0); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to add RRSet to node.\n"); - return DNSLIB_ERROR; + return KNOT_ERROR; } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1784,21 +1784,21 @@ static int xfrin_apply_changeset(knot_zone_contents_t *contents, { // check if serial matches const knot_rrset_t *soa = knot_node_rrset(contents->apex, - DNSLIB_RRTYPE_SOA); + KNOT_RRTYPE_SOA); if (soa == NULL || knot_rdata_soa_serial(knot_rrset_rdata(soa)) != chset->serial_from) { debug_knot_xfr("SOA serials do not match!!\n"); - return DNSLIB_ERROR; + return KNOT_ERROR; } int ret = xfrin_apply_remove(contents, chset, changes); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { xfrin_clean_changes_after_fail(changes); return ret; } ret = xfrin_apply_add(contents, chset, changes); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { xfrin_clean_changes_after_fail(changes); return ret; } @@ -1853,7 +1853,7 @@ static void xfrin_check_node_in_tree(knot_zone_tree_node_t *tnode, void *data) if (xfrin_changes_check_nodes(&changes->old_nodes, &changes->old_nodes_count, &changes->old_nodes_allocated) - != DNSLIB_EOK) { + != KNOT_EOK) { /*! \todo Notify about the error!!! */ return; } @@ -1884,7 +1884,7 @@ static int xfrin_finalize_remove_nodes(knot_zone_contents_t *contents, if (knot_node_is_old(node) && knot_node_new_node(node) == NULL) { - if (knot_node_rrset(node, DNSLIB_RRTYPE_NSEC3) + if (knot_node_rrset(node, KNOT_RRTYPE_NSEC3) != NULL) { removed = knot_zone_contents_remove_nsec3_node( @@ -1895,13 +1895,13 @@ static int xfrin_finalize_remove_nodes(knot_zone_contents_t *contents, } if (removed == NULL) { debug_knot_xfr("Failed to remove node from zone!\n"); - return DNSLIB_ENONODE; + return KNOT_ENONODE; } assert(removed == node); } } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -2022,7 +2022,7 @@ int xfrin_apply_changesets_to_zone(knot_zone_t *zone, */ /*! \todo Implement. */ - return DNSLIB_ENOTSUP; + return KNOT_ENOTSUP; knot_zone_contents_t *old_contents = knot_zone_get_contents(zone); @@ -2034,7 +2034,7 @@ int xfrin_apply_changesets_to_zone(knot_zone_t *zone, // abort debug_knot_zone("Trying to apply changesets to zone that is " "being updated. Aborting.\n"); - return DNSLIB_EAGAIN; + return KNOT_EAGAIN; } /* @@ -2045,7 +2045,7 @@ int xfrin_apply_changesets_to_zone(knot_zone_t *zone, int ret = knot_zone_contents_shallow_copy(old_contents, &contents_copy); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("Failed to create shallow copy of zone: %s\n", knot_strerror2(ret)); return ret; @@ -2068,7 +2068,7 @@ int xfrin_apply_changesets_to_zone(knot_zone_t *zone, for (int i = 0; i < chsets->count; ++i) { if ((ret = xfrin_apply_changeset(contents_copy, &changes, - &chsets->sets[i])) != DNSLIB_EOK) { + &chsets->sets[i])) != KNOT_EOK) { xfrin_rollback_update(contents_copy, &changes); debug_knot_xfr("Failed to apply changesets to zone: %s\n", knot_strerror2(ret)); @@ -2087,7 +2087,7 @@ int xfrin_apply_changesets_to_zone(knot_zone_t *zone, * Finalize the zone contents. */ ret = xfrin_finalize_contents(contents_copy, &changes); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { xfrin_rollback_update(contents_copy, &changes); debug_knot_xfr("Failed to finalize new zone contents: %s\n", knot_strerror2(ret)); @@ -2108,7 +2108,7 @@ int xfrin_apply_changesets_to_zone(knot_zone_t *zone, */ /*! \todo This operation must not fail!!! .*/ ret = xfrin_fix_references(contents_copy); - assert(ret == DNSLIB_EOK); + assert(ret == KNOT_EOK); /* * Wait until all readers finish reading @@ -2121,5 +2121,5 @@ int xfrin_apply_changesets_to_zone(knot_zone_t *zone, xfrin_zone_contents_free(&old_contents); xfrin_cleanup_update(&changes); - return DNSLIB_EOK; + return KNOT_EOK; } diff --git a/src/dnslib/xfr-in.h b/src/dnslib/xfr-in.h index 4ab9a415e7a0db3605c25baeb4e9678fd8277f19..e794d81f0d51d1f54e35e155f856a31e31e6031f 100644 --- a/src/dnslib/xfr-in.h +++ b/src/dnslib/xfr-in.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_XFR_IN_H_ -#define _KNOT_XFR_IN_H_ +#ifndef _KNOTDXFR_IN_H_ +#define _KNOTDXFR_IN_H_ #include <stdint.h> #include <string.h> @@ -29,9 +29,9 @@ * \param size In: available space in the buffer. Out: actual size of the * message in bytes. * - * \retval KNOT_EOK - * \retval KNOT_ESPACE - * \retval KNOT_ERROR + * \retval KNOTDEOK + * \retval KNOTDESPACE + * \retval KNOTDERROR */ int xfrin_create_soa_query(const knot_zone_contents_t *zone, uint8_t *buffer, size_t *size); @@ -58,9 +58,9 @@ int xfrin_transfer_needed(const knot_zone_contents_t *zone, * \param size In: available space in the buffer. Out: actual size of the * message in bytes. * - * \retval KNOT_EOK - * \retval KNOT_ESPACE - * \retval KNOT_ERROR + * \retval KNOTDEOK + * \retval KNOTDESPACE + * \retval KNOTDERROR */ int xfrin_create_axfr_query(const knot_zone_contents_t *zone, uint8_t *buffer, size_t *size); @@ -73,9 +73,9 @@ int xfrin_create_axfr_query(const knot_zone_contents_t *zone, uint8_t *buffer, * \param size In: available space in the buffer. Out: actual size of the * message in bytes. * - * \retval KNOT_EOK - * \retval KNOT_ESPACE - * \retval KNOT_ERROR + * \retval KNOTDEOK + * \retval KNOTDESPACE + * \retval KNOTDERROR */ int xfrin_create_ixfr_query(const knot_zone_contents_t *zone, uint8_t *buffer, size_t *size); @@ -86,7 +86,7 @@ int xfrin_create_ixfr_query(const knot_zone_contents_t *zone, uint8_t *buffer, * \param nameserver Name server to update. * \param zone Zone build from transfer. * - * \retval KNOT_ENOTSUP + * \retval KNOTDENOTSUP */ int xfrin_zone_transferred(knot_nameserver_t *nameserver, knot_zone_contents_t *zone); @@ -101,7 +101,7 @@ int xfrin_zone_transferred(knot_nameserver_t *nameserver, * first packet, \a *zone may be set to NULL, in which case a new * zone structure is created). * - * \retval KNOT_EOK + * \retval KNOTDEOK * * \todo Refactor!!! */ @@ -125,10 +125,10 @@ void xfrin_free_changesets(knot_changesets_t **changesets); * \param size Size of the packet in bytes. * \param changesets Changesets to be filled in. * - * \retval KNOT_EOK - * \retval KNOT_EINVAL - * \retval KNOT_EMALF - * \retval KNOT_ENOMEM + * \retval KNOTDEOK + * \retval KNOTDEINVAL + * \retval KNOTDEMALF + * \retval KNOTDENOMEM */ int xfrin_process_ixfr_packet(const uint8_t *pkt, size_t size, knot_changesets_t **changesets); @@ -136,6 +136,6 @@ int xfrin_process_ixfr_packet(const uint8_t *pkt, size_t size, int xfrin_apply_changesets_to_zone(knot_zone_t *zone, knot_changesets_t *chsets); -#endif /* _KNOT_XFR_IN_H_ */ +#endif /* _KNOTDXFR_IN_H_ */ /*! @} */ diff --git a/src/dnslib/zone-contents.c b/src/dnslib/zone-contents.c index f0c98b962781952a4ae2803c5b9ab53f1cb3d552..53d396e0c578f30964583a097ea86f7238fd56c4 100644 --- a/src/dnslib/zone-contents.c +++ b/src/dnslib/zone-contents.c @@ -44,16 +44,16 @@ static void knot_zone_tree_apply(knot_zone_tree_node_t *node, * \param zone Zone to which the node is going to be inserted. * \param node Node to check. * - * \retval DNSLIB_EOK if both arguments are non-NULL and the node belongs to the + * \retval KNOT_EOK if both arguments are non-NULL and the node belongs to the * zone. - * \retval DNSLIB_EBADARG if either of the arguments is NULL. - * \retval DNSLIB_EBADZONE if the node does not belong to the zone. + * \retval KNOT_EBADARG if either of the arguments is NULL. + * \retval KNOT_EBADZONE if the node does not belong to the zone. */ static int knot_zone_contents_check_node( const knot_zone_contents_t *contents, const knot_node_t *node) { if (contents == NULL || node == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } // assert or just check?? @@ -61,7 +61,7 @@ static int knot_zone_contents_check_node( if (!knot_dname_is_subdomain(node->owner, knot_node_owner(contents->apex))) { -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( char *node_owner = knot_dname_to_str(knot_node_owner(node)); char *apex_owner = knot_dname_to_str(contents->apex->owner); debug_knot_zone("zone: Trying to insert foreign node to a " @@ -70,9 +70,9 @@ DEBUG_DNSLIB_ZONE( free(node_owner); free(apex_owner); ); - return DNSLIB_EBADZONE; + return KNOT_EBADZONE; } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -179,15 +179,15 @@ static void knot_zone_contents_adjust_rdata_item(knot_rdata_t *rdata, // n = knot_zone_find_node(zone, dname); - if (ret == DNSLIB_EBADARG || ret == DNSLIB_EBADZONE) { + if (ret == KNOT_EBADARG || ret == KNOT_EBADZONE) { // TODO: do some cleanup if needed return; } - assert(ret != DNSLIB_ZONE_NAME_FOUND + assert(ret != KNOT_ZONE_NAME_FOUND || n == closest_encloser); - if (ret != DNSLIB_ZONE_NAME_FOUND + if (ret != KNOT_ZONE_NAME_FOUND && (closest_encloser != NULL)) { debug_knot_zdump("Saving closest encloser to RDATA." "\n"); @@ -235,11 +235,11 @@ static void knot_zone_contents_adjust_rdata_in_rrset(knot_rrset_t *rrset, while (rdata->next != rdata_first) { for (int i = 0; i < rdata->count; ++i) { if (desc->wireformat[i] - == DNSLIB_RDATA_WF_COMPRESSED_DNAME + == KNOT_RDATA_WF_COMPRESSED_DNAME || desc->wireformat[i] - == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME + == KNOT_RDATA_WF_UNCOMPRESSED_DNAME || desc->wireformat[i] - == DNSLIB_RDATA_WF_LITERAL_DNAME) { + == KNOT_RDATA_WF_LITERAL_DNAME) { debug_knot_zone("Adjusting domain name at " "position %d of RDATA of record with owner " "%s and type %s.\n", @@ -257,11 +257,11 @@ static void knot_zone_contents_adjust_rdata_in_rrset(knot_rrset_t *rrset, for (int i = 0; i < rdata->count; ++i) { if (desc->wireformat[i] - == DNSLIB_RDATA_WF_COMPRESSED_DNAME + == KNOT_RDATA_WF_COMPRESSED_DNAME || desc->wireformat[i] - == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME + == KNOT_RDATA_WF_UNCOMPRESSED_DNAME || desc->wireformat[i] - == DNSLIB_RDATA_WF_LITERAL_DNAME) { + == KNOT_RDATA_WF_LITERAL_DNAME) { debug_knot_zone("Adjusting domain name at " "position %d of RDATA of record with owner " "%s and type %s.\n", @@ -328,7 +328,7 @@ static void knot_zone_contents_adjust_node(knot_node_t *node, knot_zone_contents_t *zone) { -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( char *name = knot_dname_to_str(node->owner); debug_knot_zone("----- Adjusting node %s -----\n", name); free(name); @@ -337,7 +337,7 @@ DEBUG_DNSLIB_ZONE( // adjust domain names in RDATA knot_zone_contents_adjust_rrsets(node, zone); -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( if (knot_node_parent(node, 1)) { char *name = knot_dname_to_str(knot_node_owner( knot_node_parent(node, 1))); @@ -358,7 +358,7 @@ DEBUG_DNSLIB_ZONE( && (knot_node_is_deleg_point(knot_node_parent(node, 1)) || knot_node_is_non_auth(knot_node_parent(node, 1)))) { knot_node_set_non_auth(node); - } else if (knot_node_rrset(node, DNSLIB_RRTYPE_NS) != NULL + } else if (knot_node_rrset(node, KNOT_RRTYPE_NS) != NULL && node != zone->apex) { knot_node_set_deleg_point(node); } @@ -380,7 +380,7 @@ DEBUG_DNSLIB_ZONE( int match = knot_zone_contents_find_nsec3_for_name(zone, knot_node_owner(node), &nsec3, &prev); - if (match != DNSLIB_ZONE_NAME_FOUND) { + if (match != KNOT_ZONE_NAME_FOUND) { nsec3 = NULL; } @@ -407,7 +407,7 @@ static void knot_zone_contents_adjust_nsec3_node(knot_node_t *node, knot_zone_contents_t *zone) { -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( char *name = knot_dname_to_str(node->owner); debug_knot_zone("----- Adjusting node %s -----\n", name); free(name); @@ -496,10 +496,10 @@ static void knot_zone_contents_adjust_nsec3_node_in_tree( * \param name Domain name to hash. * \param nsec3_name Hashed name. * - * \retval DNSLIB_EOK - * \retval DNSLIB_ENSEC3PAR - * \retval DNSLIB_ECRYPTO - * \retval DNSLIB_ERROR if an error occured while creating a new domain name + * \retval KNOT_EOK + * \retval KNOT_ENSEC3PAR + * \retval KNOT_ECRYPTO + * \retval KNOT_ERROR if an error occured while creating a new domain name * from the hash or concatenating it with the zone name. */ static int knot_zone_contents_nsec3_name(const knot_zone_contents_t *zone, @@ -514,18 +514,18 @@ static int knot_zone_contents_nsec3_name(const knot_zone_contents_t *zone, knot_zone_contents_nsec3params(zone); if (nsec3_params == NULL) { -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( char *n = knot_dname_to_str(zone->apex->owner); debug_knot_zone("No NSEC3PARAM for zone %s.\n", n); free(n); ); - return DNSLIB_ENSEC3PAR; + return KNOT_ENSEC3PAR; } uint8_t *hashed_name = NULL; size_t hash_size = 0; -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( char *n = knot_dname_to_str(name); debug_knot_zone("Hashing name %s.\n", n); free(n); @@ -539,7 +539,7 @@ DEBUG_DNSLIB_ZONE( char *n = knot_dname_to_str(name); debug_knot_zone("Error while hashing name %s.\n", n); free(n); - return DNSLIB_ECRYPTO; + return KNOT_ECRYPTO; } debug_knot_zone("Hash: "); @@ -558,7 +558,7 @@ DEBUG_DNSLIB_ZONE( if (name_b32 != NULL) { free(name_b32); } - return DNSLIB_ECRYPTO; + return KNOT_ECRYPTO; } assert(name_b32 != NULL); @@ -574,7 +574,7 @@ DEBUG_DNSLIB_ZONE( if (*nsec3_name == NULL) { debug_knot_zone("Error while creating domain name for hashed" " name.\n"); - return DNSLIB_ERROR; + return KNOT_ERROR; } assert(zone->apex->owner != NULL); @@ -584,12 +584,12 @@ DEBUG_DNSLIB_ZONE( debug_knot_zone("Error while creating NSEC3 domain name for " "hashed name.\n"); knot_dname_release(*nsec3_name); - return DNSLIB_ERROR; + return KNOT_ERROR; } assert(ret == *nsec3_name); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -667,7 +667,7 @@ static void knot_zone_contents_node_to_hash(knot_zone_tree_node_t *tnode, */ #ifdef USE_HASH_TABLE -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( char *name = knot_dname_to_str(node->owner); debug_knot_zone("Adding node with owner %s to hash table.\n", name); free(name); @@ -695,11 +695,11 @@ static int knot_zone_contents_dnames_from_rdata_to_table( // for each RDATA item for (unsigned int j = 0; j < count; ++j) { if (d->wireformat[j] - == DNSLIB_RDATA_WF_COMPRESSED_DNAME + == KNOT_RDATA_WF_COMPRESSED_DNAME || d->wireformat[j] - == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME + == KNOT_RDATA_WF_UNCOMPRESSED_DNAME || d->wireformat[j] - == DNSLIB_RDATA_WF_LITERAL_DNAME) { + == KNOT_RDATA_WF_LITERAL_DNAME) { debug_knot_zone("Saving dname from " "rdata to dname table" ".\n"); @@ -714,7 +714,7 @@ static int knot_zone_contents_dnames_from_rdata_to_table( } debug_knot_zone("RDATA OK.\n"); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -736,14 +736,14 @@ static int knot_zone_contents_dnames_from_rrset_to_table( if (desc == NULL) { // not recognized RR type, ignore debug_knot_zone("RRSet type not recognized.\n"); - return DNSLIB_EOK; + return KNOT_EOK; } // for each RDATA in RRSet knot_rdata_t *rdata = knot_rrset_get_rdata(rrset); while (rdata != NULL) { int rc = knot_zone_contents_dnames_from_rdata_to_table(table, rdata, desc); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { return rc; } @@ -751,7 +751,7 @@ static int knot_zone_contents_dnames_from_rrset_to_table( } debug_knot_zone("RRSet OK.\n"); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -790,7 +790,7 @@ static int knot_zone_contents_dnames_from_node_to_table( debug_knot_zone("Inserting RRSets from node to table.\n"); rc = knot_zone_contents_dnames_from_rrset_to_table(table, rrsets[i], replace_owner, node->owner); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { return rc; } } @@ -798,7 +798,7 @@ static int knot_zone_contents_dnames_from_node_to_table( free(rrsets); debug_knot_zone("Node OK\n"); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -857,13 +857,13 @@ knot_zone_contents_t *knot_zone_contents_new(knot_node_t *apex, contents->nsec3_params.salt = NULL; debug_knot_zone("Initializing zone trees.\n"); - if (knot_zone_tree_init(contents->nodes) != DNSLIB_EOK - || knot_zone_tree_init(contents->nsec3_nodes) != DNSLIB_EOK) { + if (knot_zone_tree_init(contents->nodes) != KNOT_EOK + || knot_zone_tree_init(contents->nsec3_nodes) != KNOT_EOK) { goto cleanup; } debug_knot_zone("Inserting apex into the zone tree.\n"); - if (knot_zone_tree_insert(contents->nodes, apex) != DNSLIB_EOK) { + if (knot_zone_tree_insert(contents->nodes, apex) != KNOT_EOK) { debug_knot_zone("Failed to insert apex to the zone tree.\n"); goto cleanup; } @@ -896,7 +896,7 @@ knot_zone_contents_t *knot_zone_contents_new(knot_node_t *apex, debug_knot_zone("Inserting names from apex to table.\n"); int rc = knot_zone_contents_dnames_from_node_to_table( contents->dname_table, apex); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { ck_destroy_table(&contents->table, NULL, 0); goto cleanup; } @@ -934,7 +934,7 @@ int knot_zone_contents_add_node(knot_zone_contents_t *zone, uint8_t flags, int use_domain_table) { if (zone == NULL || node == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } int ret = 0; @@ -943,13 +943,13 @@ int knot_zone_contents_add_node(knot_zone_contents_t *zone, } ret = knot_zone_tree_insert(zone->nodes, node); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_zone("Failed to insert node into zone tree.\n"); return ret; } #ifdef USE_HASH_TABLE -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( char *name = knot_dname_to_str(node->owner); debug_knot_zone("Adding node with owner %s to hash table.\n", name); free(name); @@ -962,7 +962,7 @@ DEBUG_DNSLIB_ZONE( node->owner->size, (void *)node) != 0) { debug_knot_zone("Error inserting node into hash table!\n"); /*! \todo Remove the node from the tree. */ - return DNSLIB_EHASH; + return KNOT_EHASH; } #endif assert(knot_zone_contents_find_node(zone, node->owner)); @@ -970,7 +970,7 @@ DEBUG_DNSLIB_ZONE( if (use_domain_table) { ret = knot_zone_contents_dnames_from_node_to_table( zone->dname_table, node); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { /*! \todo Remove node from the tree and hash table.*/ debug_knot_zone("Failed to add dnames into table.\n"); return ret; @@ -980,7 +980,7 @@ DEBUG_DNSLIB_ZONE( knot_node_set_zone(node, zone->zone); if (!create_parents) { - return DNSLIB_EOK; + return KNOT_EOK; } debug_knot_zone("Creating parents of the node.\n"); @@ -1000,13 +1000,13 @@ DEBUG_DNSLIB_ZONE( if (next_node == NULL) { /* Directly discard. */ knot_dname_free(&chopped); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } if (use_domain_table) { ret = knot_zone_contents_dnames_from_node_to_table( zone->dname_table, next_node); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { /*! \todo Will next_node leak? */ knot_dname_release(chopped); return ret; @@ -1027,7 +1027,7 @@ DEBUG_DNSLIB_ZONE( ret = knot_zone_tree_insert(zone->nodes, next_node); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_zone("Failed to insert new node " "to zone tree.\n"); /*! \todo Delete the node?? */ @@ -1037,7 +1037,7 @@ DEBUG_DNSLIB_ZONE( } #ifdef USE_HASH_TABLE -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( char *name = knot_dname_to_str( knot_node_owner(next_node)); debug_knot_zone("Adding new node with owner %s to " @@ -1056,7 +1056,7 @@ DEBUG_DNSLIB_ZONE( /*! \todo Delete the node?? */ /* Directly discard. */ knot_dname_release(chopped); - return DNSLIB_EHASH; + return KNOT_EHASH; } // set parent @@ -1094,7 +1094,7 @@ DEBUG_DNSLIB_ZONE( /*! \todo This may be double-release. */ knot_dname_release(chopped); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1106,7 +1106,7 @@ int knot_zone_contents_add_rrset(knot_zone_contents_t *zone, { if (zone == NULL || rrset == NULL || zone->apex == NULL || zone->apex->owner == NULL || node == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } // check if the RRSet belongs to the zone @@ -1114,13 +1114,13 @@ int knot_zone_contents_add_rrset(knot_zone_contents_t *zone, zone->apex->owner) != 0 && !knot_dname_is_subdomain(knot_rrset_owner(rrset), zone->apex->owner)) { - return DNSLIB_EBADZONE; + return KNOT_EBADZONE; } if ((*node) == NULL && (*node = knot_zone_contents_get_node(zone, knot_rrset_owner(rrset))) == NULL) { - return DNSLIB_ENONODE; + return KNOT_ENONODE; } assert(*node != NULL); @@ -1130,7 +1130,7 @@ int knot_zone_contents_add_rrset(knot_zone_contents_t *zone, /*! \todo REMOVE RRSET */ rc = knot_node_add_rrset(*node, rrset, - dupl == DNSLIB_RRSET_DUPL_MERGE); + dupl == KNOT_RRSET_DUPL_MERGE); if (rc < 0) { debug_knot_zone("Failed to add RRSet to node.\n"); return rc; @@ -1142,7 +1142,7 @@ int knot_zone_contents_add_rrset(knot_zone_contents_t *zone, debug_knot_zone("Saving RRSet to table.\n"); rc = knot_zone_contents_dnames_from_rrset_to_table( zone->dname_table, rrset, 0, (*node)->owner); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { debug_knot_zone("Error saving domain names from " "RRSIGs to the domain name table.\n " "The zone may be in an inconsistent " @@ -1157,7 +1157,7 @@ int knot_zone_contents_add_rrset(knot_zone_contents_t *zone, // replace RRSet's owner with the node's owner (that is already in the // table) /*! \todo Do even if domain table is not used?? */ - if (ret == DNSLIB_EOK && rrset->owner != (*node)->owner) { + if (ret == KNOT_EOK && rrset->owner != (*node)->owner) { knot_rrset_set_owner(rrset, (*node)->owner); } @@ -1176,7 +1176,7 @@ int knot_zone_contents_add_rrsigs(knot_zone_contents_t *zone, { if (zone == NULL || rrsigs == NULL || rrset == NULL || node == NULL || zone->apex == NULL || zone->apex->owner == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } // check if the RRSet belongs to the zone @@ -1185,14 +1185,14 @@ int knot_zone_contents_add_rrsigs(knot_zone_contents_t *zone, zone->apex->owner) != 0 && !knot_dname_is_subdomain(knot_rrset_owner(*rrset), zone->apex->owner)) { - return DNSLIB_EBADZONE; + return KNOT_EBADZONE; } // check if the RRSIGs belong to the RRSet if (*rrset != NULL && (knot_dname_compare(knot_rrset_owner(rrsigs), knot_rrset_owner(*rrset)) != 0)) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } // if no RRSet given, try to find the right RRSet @@ -1202,7 +1202,7 @@ int knot_zone_contents_add_rrsigs(knot_zone_contents_t *zone, knot_node_t *(*get_node)(const knot_zone_contents_t *, const knot_dname_t *) = (knot_rdata_rrsig_type_covered( - knot_rrset_rdata(rrsigs)) == DNSLIB_RRTYPE_NSEC3) + knot_rrset_rdata(rrsigs)) == KNOT_RRTYPE_NSEC3) ? knot_zone_contents_get_nsec3_node : knot_zone_contents_get_node; @@ -1210,7 +1210,7 @@ int knot_zone_contents_add_rrsigs(knot_zone_contents_t *zone, && (*node = get_node( zone, knot_rrset_owner(rrsigs))) == NULL) { debug_knot_zone("Failed to find node for RRSIGs.\n"); - return DNSLIB_EBADARG; /*! \todo Other error code? */ + return KNOT_EBADARG; /*! \todo Other error code? */ } assert(*node != NULL); @@ -1226,7 +1226,7 @@ int knot_zone_contents_add_rrsigs(knot_zone_contents_t *zone, knot_rrset_rdata(rrsigs))); if (*rrset == NULL) { debug_knot_zone("Failed to find RRSet for RRSIGs.\n"); - return DNSLIB_EBADARG; /*! \todo Other error code? */ + return KNOT_EBADARG; /*! \todo Other error code? */ } } @@ -1234,14 +1234,14 @@ int knot_zone_contents_add_rrsigs(knot_zone_contents_t *zone, // add all domain names from the RRSet to domain name table int rc; - int ret = DNSLIB_EOK; + int ret = KNOT_EOK; rc = knot_rrset_add_rrsigs(*rrset, rrsigs, dupl); if (rc < 0) { debug_knot_dname("Failed to add RRSIGs to RRSet.\n"); return rc; } else if (rc > 0) { - assert(dupl == DNSLIB_RRSET_DUPL_MERGE); + assert(dupl == KNOT_RRSET_DUPL_MERGE); ret = 1; } @@ -1249,7 +1249,7 @@ int knot_zone_contents_add_rrsigs(knot_zone_contents_t *zone, debug_knot_zone("Saving RRSIG RRSet to table.\n"); rc = knot_zone_contents_dnames_from_rrset_to_table( zone->dname_table, rrsigs, 0, (*rrset)->owner); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { debug_knot_zone("Error saving domain names from " "RRSIGs to the domain name table.\n " "The zone may be in an inconsistent " @@ -1281,7 +1281,7 @@ int knot_zone_contents_add_nsec3_node(knot_zone_contents_t *zone, UNUSED(flags); if (zone == NULL || node == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } int ret = 0; @@ -1296,7 +1296,7 @@ int knot_zone_contents_add_nsec3_node(knot_zone_contents_t *zone, if (use_domain_table) { ret = knot_zone_contents_dnames_from_node_to_table( zone->dname_table, node); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { /*! \todo Remove the node from the tree. */ debug_knot_zone("Failed to add dnames into table.\n"); return ret; @@ -1312,7 +1312,7 @@ int knot_zone_contents_add_nsec3_node(knot_zone_contents_t *zone, // cannot be wildcard child, so nothing to be done - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1325,7 +1325,7 @@ int knot_zone_contents_add_nsec3_rrset(knot_zone_contents_t *zone, { if (zone == NULL || rrset == NULL || zone->apex == NULL || zone->apex->owner == NULL || node == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } // check if the RRSet belongs to the zone @@ -1333,13 +1333,13 @@ int knot_zone_contents_add_nsec3_rrset(knot_zone_contents_t *zone, zone->apex->owner) != 0 && !knot_dname_is_subdomain(knot_rrset_owner(rrset), zone->apex->owner)) { - return DNSLIB_EBADZONE; + return KNOT_EBADZONE; } if ((*node) == NULL && (*node = knot_zone_contents_get_nsec3_node( zone, knot_rrset_owner(rrset))) == NULL) { - return DNSLIB_ENONODE; + return KNOT_ENONODE; } assert(*node != NULL); @@ -1349,7 +1349,7 @@ int knot_zone_contents_add_nsec3_rrset(knot_zone_contents_t *zone, /*! \todo REMOVE RRSET */ rc = knot_node_add_rrset(*node, rrset, - dupl == DNSLIB_RRSET_DUPL_MERGE); + dupl == KNOT_RRSET_DUPL_MERGE); if (rc < 0) { return rc; } @@ -1360,7 +1360,7 @@ int knot_zone_contents_add_nsec3_rrset(knot_zone_contents_t *zone, debug_knot_zone("Saving NSEC3 RRSet to table.\n"); rc = knot_zone_contents_dnames_from_rrset_to_table( zone->dname_table, rrset, 0, (*node)->owner); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { debug_knot_zone("Error saving domain names from " "RRSIGs to the domain name table.\n " "The zone may be in an inconsistent " @@ -1405,7 +1405,7 @@ knot_node_t *knot_zone_contents_remove_node( // 2) remove the node from the zone tree knot_node_t *n = NULL; ret = knot_zone_tree_remove(contents->nodes, owner, &n); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return NULL; } @@ -1426,7 +1426,7 @@ knot_node_t *knot_zone_contents_remove_nsec3_node( // remove the node from the zone tree int ret = knot_zone_tree_remove(contents->nsec3_nodes, owner, &n); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return NULL; } @@ -1439,7 +1439,7 @@ int knot_zone_contents_create_and_fill_hash_table( knot_zone_contents_t *zone) { if (zone == NULL || zone->apex == NULL || zone->apex->owner == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } /* * 1) Create hash table. @@ -1448,7 +1448,7 @@ int knot_zone_contents_create_and_fill_hash_table( if (zone->node_count > 0) { zone->table = ck_create_table(zone->node_count); if (zone->table == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } // insert the apex into the hash table @@ -1456,11 +1456,11 @@ int knot_zone_contents_create_and_fill_hash_table( (const char *)zone->apex->owner->name, zone->apex->owner->size, (void *)zone->apex) != 0) { - return DNSLIB_EHASH; + return KNOT_EHASH; } } else { zone->table = NULL; - return DNSLIB_EOK; // OK? + return KNOT_EOK; // OK? } /* @@ -1474,13 +1474,13 @@ int knot_zone_contents_create_and_fill_hash_table( /*! \todo Replace by zone tree. */ int ret = knot_zone_tree_forward_apply_inorder(zone->nodes, knot_zone_contents_node_to_hash, zone); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_zone("Failed to insert nodes to hash table.\n"); return ret; } #endif - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1499,7 +1499,7 @@ knot_node_t *knot_zone_contents_get_node(const knot_zone_contents_t *zone, knot_node_t *n; int ret = knot_zone_tree_get(zone->nodes, name, &n); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_zone("Failed to find name in the zone tree.\n"); return NULL; } @@ -1523,7 +1523,7 @@ knot_node_t *knot_zone_contents_get_nsec3_node( knot_node_t *n; int ret = knot_zone_tree_get(zone->nsec3_nodes, name, &n); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_zone("Failed to find NSEC3 name in the zone tree." "\n"); return NULL; @@ -1551,10 +1551,10 @@ int knot_zone_contents_find_dname(const knot_zone_contents_t *zone, if (zone == NULL || name == NULL || node == NULL || closest_encloser == NULL || previous == NULL || zone->apex == NULL || zone->apex->owner == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( char *name_str = knot_dname_to_str(name); char *zone_str = knot_dname_to_str(zone->apex->owner); debug_knot_zone("Searching for name %s in zone %s...\n", @@ -1566,13 +1566,13 @@ DEBUG_DNSLIB_ZONE( if (knot_dname_compare(name, zone->apex->owner) == 0) { *node = zone->apex; *closest_encloser = *node; - return DNSLIB_ZONE_NAME_FOUND; + return KNOT_ZONE_NAME_FOUND; } if (!knot_dname_is_subdomain(name, zone->apex->owner)) { *node = NULL; *closest_encloser = NULL; - return DNSLIB_EBADZONE; + return KNOT_EBADZONE; } knot_node_t *found = NULL, *prev = NULL; @@ -1583,7 +1583,7 @@ DEBUG_DNSLIB_ZONE( *node = found; *previous = prev; -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( char *name_str = (*node) ? knot_dname_to_str((*node)->owner) : "(nil)"; char *name_str2 = (*previous != NULL) @@ -1605,7 +1605,7 @@ DEBUG_DNSLIB_ZONE( // there must be at least one node with domain name less or equal to // the searched name if the name belongs to the zone (the root) if (*node == NULL) { - return DNSLIB_EBADZONE; + return KNOT_EBADZONE; } // TODO: this could be replaced by saving pointer to closest encloser @@ -1621,7 +1621,7 @@ DEBUG_DNSLIB_ZONE( assert(*closest_encloser); } } -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( char *n = knot_dname_to_str(knot_node_owner((*closest_encloser))); debug_knot_zone("Closest encloser: %s\n", n); free(n); @@ -1630,8 +1630,8 @@ DEBUG_DNSLIB_ZONE( debug_knot_zone("find_dname() returning %d\n", exact_match); return (exact_match) - ? DNSLIB_ZONE_NAME_FOUND - : DNSLIB_ZONE_NAME_NOT_FOUND; + ? KNOT_ZONE_NAME_FOUND + : KNOT_ZONE_NAME_NOT_FOUND; } /*----------------------------------------------------------------------------*/ @@ -1697,10 +1697,10 @@ int knot_zone_contents_find_dname_hash(const knot_zone_contents_t *zone, { if (zone == NULL || name == NULL || node == NULL || closest_encloser == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( char *name_str = knot_dname_to_str(name); char *zone_str = knot_dname_to_str(zone->apex->owner); debug_knot_zone("Searching for name %s in zone %s...\n", @@ -1712,13 +1712,13 @@ DEBUG_DNSLIB_ZONE( if (knot_dname_compare(name, zone->apex->owner) == 0) { *node = zone->apex; *closest_encloser = *node; - return DNSLIB_ZONE_NAME_FOUND; + return KNOT_ZONE_NAME_FOUND; } if (!knot_dname_is_subdomain(name, zone->apex->owner)) { *node = NULL; *closest_encloser = NULL; - return DNSLIB_EBADZONE; + return KNOT_EBADZONE; } const ck_hash_table_item_t *item = ck_find_item(zone->table, @@ -1734,7 +1734,7 @@ DEBUG_DNSLIB_ZONE( knot_dname_label_count((*node)->owner)); assert(*node != NULL); assert(*closest_encloser != NULL); - return DNSLIB_ZONE_NAME_FOUND; + return KNOT_ZONE_NAME_FOUND; } *node = NULL; @@ -1743,7 +1743,7 @@ DEBUG_DNSLIB_ZONE( // copy the name for chopping /* Local allocation, will be discarded. */ knot_dname_t *name_copy = knot_dname_deep_copy(name); -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( char *n = knot_dname_to_str(name_copy); debug_knot_zone("Finding closest encloser..\nStarting with: %s\n", n); free(n); @@ -1751,7 +1751,7 @@ DEBUG_DNSLIB_ZONE( while (item == NULL) { knot_dname_left_chop_no_copy(name_copy); -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( char *n = knot_dname_to_str(name_copy); debug_knot_zone("Chopped leftmost label: %s (%.*s, size %u)" "\n", n, name_copy->size, name_copy->name, @@ -1772,7 +1772,7 @@ DEBUG_DNSLIB_ZONE( assert(item != NULL); *closest_encloser = (const knot_node_t *)item->value; - return DNSLIB_ZONE_NAME_NOT_FOUND; + return KNOT_ZONE_NAME_NOT_FOUND; } #endif /*----------------------------------------------------------------------------*/ @@ -1792,17 +1792,17 @@ int knot_zone_contents_find_nsec3_for_name(const knot_zone_contents_t *zone, { if (zone == NULL || name == NULL || nsec3_node == NULL || nsec3_previous == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } knot_dname_t *nsec3_name = NULL; int ret = knot_zone_contents_nsec3_name(zone, name, &nsec3_name); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( char *n = knot_dname_to_str(nsec3_name); debug_knot_zone("NSEC3 node name: %s.\n", n); free(n); @@ -1817,7 +1817,7 @@ DEBUG_DNSLIB_ZONE( knot_dname_release(nsec3_name); -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( if (found) { char *n = knot_dname_to_str(found->owner); debug_knot_zone("Found NSEC3 node: %s.\n", n); @@ -1851,8 +1851,8 @@ DEBUG_DNSLIB_ZONE( debug_knot_zone("find_nsec3_for_name() returning %d\n", exact_match); return (exact_match) - ? DNSLIB_ZONE_NAME_FOUND - : DNSLIB_ZONE_NAME_NOT_FOUND; + ? KNOT_ZONE_NAME_FOUND + : KNOT_ZONE_NAME_NOT_FOUND; } /*----------------------------------------------------------------------------*/ @@ -1894,7 +1894,7 @@ knot_node_t *knot_zone_contents_get_apex(const knot_zone_contents_t *zone) int knot_zone_contents_adjust_dnames(knot_zone_contents_t *zone) { if (zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } // load NSEC3PARAM (needed on adjusting function) @@ -1908,7 +1908,7 @@ int knot_zone_contents_adjust_dnames(knot_zone_contents_t *zone) int ret = knot_zone_tree_forward_apply_inorder(zone->nodes, knot_zone_contents_adjust_node_in_tree, &adjust_arg); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } @@ -1936,11 +1936,11 @@ int knot_zone_contents_adjust_dnames(knot_zone_contents_t *zone) int knot_zone_contents_load_nsec3param(knot_zone_contents_t *zone) { if (zone == NULL || zone->apex == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } const knot_rrset_t *rrset = knot_node_rrset(zone->apex, - DNSLIB_RRTYPE_NSEC3PARAM); + KNOT_RRTYPE_NSEC3PARAM); if (rrset != NULL) { knot_nsec3_params_from_wire(&zone->nsec3_params, rrset); @@ -1948,7 +1948,7 @@ int knot_zone_contents_load_nsec3param(knot_zone_contents_t *zone) memset(&zone->nsec3_params, 0, sizeof(knot_nsec3_params_t)); } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1956,7 +1956,7 @@ int knot_zone_contents_load_nsec3param(knot_zone_contents_t *zone) int knot_zone_contents_nsec3_enabled(const knot_zone_contents_t *zone) { if (zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } return (zone->nsec3_params.algorithm != 0); @@ -1985,7 +1985,7 @@ int knot_zone_contents_tree_apply_postorder(knot_zone_contents_t *zone, void *data) { if (zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } knot_zone_tree_func_t f; @@ -2003,7 +2003,7 @@ int knot_zone_contents_tree_apply_inorder(knot_zone_contents_t *zone, void *data) { if (zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } knot_zone_tree_func_t f; @@ -2021,7 +2021,7 @@ int knot_zone_contents_tree_apply_inorder_reverse( void (*function)(knot_node_t *node, void *data), void *data) { if (zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } knot_zone_tree_func_t f; @@ -2039,7 +2039,7 @@ int knot_zone_contents_nsec3_apply_postorder(knot_zone_contents_t *zone, void *data) { if (zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } knot_zone_tree_func_t f; @@ -2057,7 +2057,7 @@ int knot_zone_contents_nsec3_apply_inorder(knot_zone_contents_t *zone, void *data) { if (zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } knot_zone_tree_func_t f; @@ -2075,7 +2075,7 @@ int knot_zone_contents_nsec3_apply_inorder_reverse( void (*function)(knot_node_t *node, void *data), void *data) { if (zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } knot_zone_tree_func_t f; @@ -2110,13 +2110,13 @@ int knot_zone_contents_dname_table_apply(knot_zone_contents_t *contents, void *data) { if (contents == NULL || function == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } knot_dname_table_tree_inorder_apply(contents->dname_table, function, data); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -2125,16 +2125,16 @@ int knot_zone_contents_shallow_copy(const knot_zone_contents_t *from, knot_zone_contents_t **to) { if (from == NULL || to == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } - int ret = DNSLIB_EOK; + int ret = KNOT_EOK; knot_zone_contents_t *contents = (knot_zone_contents_t *)calloc( 1, sizeof(knot_zone_contents_t)); if (contents == NULL) { ERR_ALLOC_FAILED; - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } contents->apex = from->apex; @@ -2142,14 +2142,14 @@ int knot_zone_contents_shallow_copy(const knot_zone_contents_t *from, contents->nodes = malloc(sizeof(knot_zone_tree_t)); if (contents->nodes == NULL) { ERR_ALLOC_FAILED; - ret = DNSLIB_ENOMEM; + ret = KNOT_ENOMEM; goto cleanup; } contents->nsec3_nodes = malloc(sizeof(knot_zone_tree_t)); if (contents->nsec3_nodes == NULL) { ERR_ALLOC_FAILED; - ret = DNSLIB_ENOMEM; + ret = KNOT_ENOMEM; goto cleanup; } @@ -2157,11 +2157,11 @@ int knot_zone_contents_shallow_copy(const knot_zone_contents_t *from, contents->dname_table = knot_dname_table_new(); if (contents->dname_table == NULL) { ERR_ALLOC_FAILED; - ret = DNSLIB_ENOMEM; + ret = KNOT_ENOMEM; goto cleanup; } if ((ret = knot_dname_table_shallow_copy(from->dname_table, - contents->dname_table)) != DNSLIB_EOK) { + contents->dname_table)) != KNOT_EOK) { goto cleanup; } } else { @@ -2176,9 +2176,9 @@ int knot_zone_contents_shallow_copy(const knot_zone_contents_t *from, sizeof(knot_nsec3_params_t)); if ((ret = knot_zone_tree_shallow_copy(from->nodes, - contents->nodes)) != DNSLIB_EOK + contents->nodes)) != KNOT_EOK || (ret = knot_zone_tree_shallow_copy(from->nsec3_nodes, - contents->nsec3_nodes)) != DNSLIB_EOK) { + contents->nsec3_nodes)) != KNOT_EOK) { goto cleanup; } @@ -2186,14 +2186,14 @@ int knot_zone_contents_shallow_copy(const knot_zone_contents_t *from, if (from->table != NULL) { ret = ck_copy_table(from->table, &contents->table); if (ret != 0) { - ret = DNSLIB_ERROR; + ret = KNOT_ERROR; goto cleanup; } } #endif *to = contents; - return DNSLIB_EOK; + return KNOT_EOK; cleanup: knot_zone_tree_free(&contents->nodes); diff --git a/src/dnslib/zone-contents.h b/src/dnslib/zone-contents.h index 07a00899dfb00c256751ed263e6794036a2958da..c4d20092a1f332f122f0eed498876b4bc0c89200 100644 --- a/src/dnslib/zone-contents.h +++ b/src/dnslib/zone-contents.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_ZONE_CONTENTS_H_ -#define _KNOT_DNSLIB_ZONE_CONTENTS_H_ +#ifndef _KNOTDKNOT_ZONE_CONTENTS_H_ +#define _KNOTDKNOT_ZONE_CONTENTS_H_ //#include <time.h> @@ -78,10 +78,10 @@ void knot_zone_contents_switch_generation(knot_zone_contents_t *contents); * \param zone Zone to add the node into. * \param node Node to add into the zone. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG - * \retval DNSLIB_EBADZONE - * \retval DNSLIB_EHASH + * \retval KNOT_EOK + * \retval KNOT_EBADARG + * \retval KNOT_EBADZONE + * \retval KNOT_EHASH */ int knot_zone_contents_add_node(knot_zone_contents_t *contents, knot_node_t *node, int create_parents, @@ -105,9 +105,9 @@ int knot_zone_contents_add_node(knot_zone_contents_t *contents, * given zone.) If set to NULL, the function will find proper node * and set it to this parameter. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG - * \retval DNSLIB_EBADZONE + * \retval KNOT_EOK + * \retval KNOT_EBADARG + * \retval KNOT_EBADZONE */ int knot_zone_contents_add_rrset(knot_zone_contents_t *contents, knot_rrset_t *rrset, @@ -132,9 +132,9 @@ int knot_zone_contents_add_rrsigs(knot_zone_contents_t *contents, * \param zone Zone to add the node into. * \param node Node to add into the zone. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG - * \retval DNSLIB_EBADZONE + * \retval KNOT_EOK + * \retval KNOT_EBADARG + * \retval KNOT_EBADZONE */ int knot_zone_contents_add_nsec3_node(knot_zone_contents_t *contents, knot_node_t *node, int create_parents, @@ -209,10 +209,10 @@ const knot_node_t *knot_zone_contents_find_node( * \param[out] closest_encloser Closest encloser of the given name in the zone. * \param[out] previous Previous domain name in canonical order. * - * \retval DNSLIB_ZONE_NAME_FOUND if node with owner \a name was found. - * \retval DNSLIB_ZONE_NAME_NOT_FOUND if it was not found. - * \retval DNSLIB_EBADARG - * \retval DNSLIB_EBADZONE + * \retval KNOT_ZONE_NAME_FOUND if node with owner \a name was found. + * \retval KNOT_ZONE_NAME_NOT_FOUND if it was not found. + * \retval KNOT_EBADARG + * \retval KNOT_EBADZONE */ int knot_zone_contents_find_dname(const knot_zone_contents_t *contents, const knot_dname_t *name, @@ -251,10 +251,10 @@ knot_node_t *knot_zone_contents_get_previous_nsec3( * \param[out] closest_encloser Closest encloser of the given name in the zone. * \param[out] previous Previous domain name in canonical order. * - * \retval DNSLIB_ZONE_NAME_FOUND if node with owner \a name was found. - * \retval DNSLIB_ZONE_NAME_NOT_FOUND if it was not found. - * \retval DNSLIB_EBADARG - * \retval DNSLIB_EBADZONE + * \retval KNOT_ZONE_NAME_FOUND if node with owner \a name was found. + * \retval KNOT_ZONE_NAME_NOT_FOUND if it was not found. + * \retval KNOT_EBADARG + * \retval KNOT_EBADZONE */ int knot_zone_contents_find_dname_hash(const knot_zone_contents_t *contents, const knot_dname_t *name, @@ -291,12 +291,12 @@ const knot_node_t *knot_zone_contents_find_nsec3_node( * \param[out] nsec3_previous The NSEC3 node immediately preceding hashed domain * name corresponding to \a name in canonical order. * - * \retval DNSLIB_ZONE_NAME_FOUND if the corresponding NSEC3 node was found. - * \retval DNSLIB_ZONE_NAME_NOT_FOUND if it was not found. - * \retval DNSLIB_EBADARG - * \retval DNSLIB_ENSEC3PAR - * \retval DNSLIB_ECRYPTO - * \retval DNSLIB_ERROR + * \retval KNOT_ZONE_NAME_FOUND if the corresponding NSEC3 node was found. + * \retval KNOT_ZONE_NAME_NOT_FOUND if it was not found. + * \retval KNOT_EBADARG + * \retval KNOT_ENSEC3PAR + * \retval KNOT_ECRYPTO + * \retval KNOT_ERROR */ int knot_zone_contents_find_nsec3_for_name( const knot_zone_contents_t *contents, @@ -333,7 +333,7 @@ int knot_zone_contents_adjust_dnames(knot_zone_contents_t *contents); * This function properly fills in the nsec3_params field of the zone structure * according to data stored in the NSEC3PARAM record. This is necessary to do * before any NSEC3 operations on the zone are requested, otherwise they will - * fail (error DNSLIB_ENSEC3PAR). + * fail (error KNOT_ENSEC3PAR). * * \note If there is no NSEC3PARAM record in the zone, this function clears * the nsec3_params field of the zone structure (fills it with zeros). @@ -499,9 +499,9 @@ int knot_zone_contents_dname_table_apply(knot_zone_contents_t *contents, * \param from Original zone. * \param to Copy of the zone. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_EBADARG + * \retval KNOT_ENOMEM */ int knot_zone_contents_shallow_copy(const knot_zone_contents_t *from, knot_zone_contents_t **to); diff --git a/src/dnslib/zone-dump-text.c b/src/dnslib/zone-dump-text.c index 6e6706b17327f2dfb047a1c24507ee964a506e3f..a5e9396f36d4adc78fbaacb5e52e437797e8c3b8 100644 --- a/src/dnslib/zone-dump-text.c +++ b/src/dnslib/zone-dump-text.c @@ -810,7 +810,7 @@ char *rdata_loc_to_string(knot_rdata_item_t item) typedef char * (*item_to_string_t)(knot_rdata_item_t); -static item_to_string_t item_to_string_table[DNSLIB_RDATA_ZF_UNKNOWN + 1] = { +static item_to_string_t item_to_string_table[KNOT_RDATA_ZF_UNKNOWN + 1] = { rdata_dname_to_string, rdata_dns_name_to_string, rdata_text_to_string, @@ -858,7 +858,7 @@ void rdata_dump_text(knot_rdata_t *rdata, uint16_t type, FILE *f) rdata->items[i]); if (item_str == NULL) { item_str = - rdata_item_to_string(DNSLIB_RDATA_ZF_UNKNOWN, + rdata_item_to_string(KNOT_RDATA_ZF_UNKNOWN, rdata->items[i]); } if (i != desc->length - 1) { @@ -887,12 +887,12 @@ void rrsig_set_dump_text(knot_rrset_t *rrsig, FILE *f) knot_rdata_t *tmp = rrsig->rdata; while (tmp->next != rrsig->rdata) { - rdata_dump_text(tmp, DNSLIB_RRTYPE_RRSIG, f); + rdata_dump_text(tmp, KNOT_RRTYPE_RRSIG, f); dump_rrset_header(rrsig, f); tmp = tmp->next; } - rdata_dump_text(tmp, DNSLIB_RRTYPE_RRSIG, f); + rdata_dump_text(tmp, KNOT_RRTYPE_RRSIG, f); } @@ -922,7 +922,7 @@ struct dump_param { void apex_node_dump_text(knot_node_t *node, FILE *f) { knot_rrset_t dummy_rrset; - dummy_rrset.type = DNSLIB_RRTYPE_SOA; + dummy_rrset.type = KNOT_RRTYPE_SOA; knot_rrset_t *tmp_rrset = (knot_rrset_t *)gen_tree_find(node->rrset_tree, &dummy_rrset); @@ -933,7 +933,7 @@ void apex_node_dump_text(knot_node_t *node, FILE *f) knot_node_rrsets(node); for (int i = 0; i < node->rrset_count; i++) { - if (rrsets[i]->type != DNSLIB_RRTYPE_SOA) { + if (rrsets[i]->type != KNOT_RRTYPE_SOA) { rrset_dump_text(rrsets[i], f); } } @@ -968,13 +968,13 @@ int zone_dump_text(knot_zone_contents_t *zone, const char *filename) { FILE *f = fopen(filename, "w"); if (f == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } - fprintf(f, ";Dumped using %s v. %d.%d.%d\n", DNSLIB_NAME, - DNSLIB_VER / 10000, - (DNSLIB_VER / 100) % 100, - DNSLIB_VER % 100); + fprintf(f, ";Dumped using %s v. %d.%d.%d\n", KNOT_NAME, + KNOT_VER / 10000, + (KNOT_VER / 100) % 100, + KNOT_VER % 100); struct dump_param param; param.f = f; @@ -984,5 +984,5 @@ int zone_dump_text(knot_zone_contents_t *zone, const char *filename) knot_zone_contents_nsec3_apply_inorder(zone, node_dump_text, ¶m); fclose(f); - return DNSLIB_EOK; + return KNOT_EOK; } diff --git a/src/dnslib/zone-dump-text.h b/src/dnslib/zone-dump-text.h index 95d4b95e285cbbe2dab683bf141c551aaac51045..9a1e698ffb2e7eaf7d1922176407a7f9d961685f 100644 --- a/src/dnslib/zone-dump-text.h +++ b/src/dnslib/zone-dump-text.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_ZONE_DUMP_TEXT_H_ -#define _KNOT_DNSLIB_ZONE_DUMP_TEXT_H_ +#ifndef _KNOTDKNOT_ZONE_DUMP_TEXT_H_ +#define _KNOTDKNOT_ZONE_DUMP_TEXT_H_ #include "dnslib/descriptor.h" #include "dnslib/zone.h" @@ -21,11 +21,11 @@ * \param zone Zone to be saved. * \param filename Name of file to be created. * - * \retval DNSLIB_EOK on success. - * \retval DNSLIB_EBADARG if the specified file is not valid for writing. + * \retval KNOT_EOK on success. + * \retval KNOT_EBADARG if the specified file is not valid for writing. */ int zone_dump_text(knot_zone_contents_t *zone, const char *filename); -#endif // _KNOT_DNSLIB_ZONE_DUMP_TEXT_H_ +#endif // _KNOTDKNOT_ZONE_DUMP_TEXT_H_ /*! @} */ diff --git a/src/dnslib/zone-dump.c b/src/dnslib/zone-dump.c index 339a1c039d44371c2a3bfb4c9e99c275db419f0d..370c38a304fca57ebb757935a46962fd02866e5c 100644 --- a/src/dnslib/zone-dump.c +++ b/src/dnslib/zone-dump.c @@ -252,7 +252,7 @@ static void log_error_from_node(err_handler_t *handler, * \param node Node with semantic error in it. * \param error Type of error. * - * \retval DNSLIB_EOK on success. + * \retval KNOT_EOK on success. * \retval ZC_ERR_UNKNOWN if unknown error. * \retval ZC_ERR_ALLOC if memory error. */ @@ -316,7 +316,7 @@ static int err_handler_handle_error(err_handler_t *handler, handler->errors[-error]++; - return DNSLIB_EOK; + return KNOT_EOK; } /*! @@ -356,7 +356,7 @@ typedef struct arg arg_t; * \param zone Zone containing the RRSet. * \param rrset RRSet to be tested. * - * \retval DNSLIB_EOK when there is no cycle. + * \retval KNOT_EOK when there is no cycle. * \retval ZC_ERR_CNAME_CYCLE when cycle is present. */ static int check_cname_cycles_in_zone(knot_zone_contents_t *zone, @@ -385,7 +385,7 @@ static int check_cname_cycles_in_zone(knot_zone_contents_t *zone, if (next_node != NULL) { next_rrset = knot_node_rrset(next_node, - DNSLIB_RRTYPE_CNAME); + KNOT_RRTYPE_CNAME); if (next_rrset != NULL) { next_dname = knot_rdata_cname_name(next_rrset->rdata); @@ -404,7 +404,7 @@ static int check_cname_cycles_in_zone(knot_zone_contents_t *zone, return ZC_ERR_CNAME_CYCLE; } - return DNSLIB_EOK; + return KNOT_EOK; } /*! @@ -434,7 +434,7 @@ uint16_t type_covered_from_rdata(const knot_rdata_t *rdata) * * \param rdata DNSKEY rdata to be checked. * - * \retval DNSLIB_EOK when rdata are OK. + * \retval KNOT_EOK when rdata are OK. * \retval ZC_ERR_RRSIG_RDATA_DNSKEY_OWNER when rdata are not OK. */ static int check_dnskey_rdata(const knot_rdata_t *rdata) @@ -448,7 +448,7 @@ static int check_dnskey_rdata(const knot_rdata_t *rdata) (knot_rdata_item(rdata, 0))); if (flags & mask) { - return DNSLIB_EOK; + return KNOT_EOK; } else { /* This error does not exactly fit, but it's better * than a new one */ @@ -519,8 +519,8 @@ static inline uint16_t rdata_item_size(const knot_rdata_item_t *item) * \param wire Created wire. * \param size Size of created wire. * - * \retval DNSLIB_EOK on success. - * \retval DNSLIB_ENOMEM on memory error. + * \retval KNOT_EOK on success. + * \retval KNOT_ENOMEM on memory error. */ static int dnskey_to_wire(const knot_rdata_t *rdata, uint8_t **wire, uint *size) @@ -529,7 +529,7 @@ static int dnskey_to_wire(const knot_rdata_t *rdata, uint8_t **wire, /* flags + algorithm + protocol + keysize */ *size = 2 + 1 + 1 + knot_rdata_item(rdata, 3)->raw_data[0]; *wire = malloc(sizeof(uint8_t) * *size); - CHECK_ALLOC_LOG(*wire, DNSLIB_ENOMEM); + CHECK_ALLOC_LOG(*wire, KNOT_ENOMEM); /* copy the wire octet by octet */ @@ -544,7 +544,7 @@ static int dnskey_to_wire(const knot_rdata_t *rdata, uint8_t **wire, memcpy(*wire + 4, knot_rdata_item(rdata, 3)->raw_data + 1, knot_rdata_item(rdata, 3)->raw_data[0]); - return DNSLIB_EOK; + return KNOT_EOK; } /*! @@ -554,7 +554,7 @@ static int dnskey_to_wire(const knot_rdata_t *rdata, uint8_t **wire, * \param rrset RRSet containing the rdata. * \param dnskey_rrset RRSet containing zone's DNSKEY * - * \retval DNSLIB_EOK if rdata are OK. + * \retval KNOT_EOK if rdata are OK. * * \return Appropriate error code if error was found. */ @@ -660,7 +660,7 @@ static int check_rrsig_rdata(const knot_rdata_t *rdata_rrsig, return ZC_ERR_RRSIG_RDATA_SIGNED_WRONG; } - return DNSLIB_EOK; + return KNOT_EOK; } /*! @@ -670,7 +670,7 @@ static int check_rrsig_rdata(const knot_rdata_t *rdata_rrsig, * \param dnskey_rrset * \param nsec3 NSEC3 active. * - * \retval DNSLIB_EOK on success. + * \retval KNOT_EOK on success. * * \return Appropriate error code if error was found. */ @@ -731,7 +731,7 @@ static int check_rrsig_in_rrset(const knot_rrset_t *rrset, return ZC_ERR_RRSIG_NOT_ALL; } - return DNSLIB_EOK; + return KNOT_EOK; } /*! @@ -758,8 +758,8 @@ static int get_bit(uint8_t *bits, size_t index) * \param array Array to be created. * \param count Count of items in array. * - * \retval DNSLIB_OK on success. - * \retval DNSLIB_NOMEM on memory error. + * \retval KNOT_OK on success. + * \retval KNOT_NOMEM on memory error. */ static int rdata_nsec_to_type_array(const knot_rdata_item_t *item, uint16_t **array, @@ -794,7 +794,7 @@ static int rdata_nsec_to_type_array(const knot_rdata_item_t *item, void *tmp = realloc(*array, sizeof(uint16_t) * *count); - CHECK_ALLOC_LOG(tmp, DNSLIB_ENOMEM); + CHECK_ALLOC_LOG(tmp, KNOT_ENOMEM); *array = tmp; (*array)[*count - 1] = j + window * 256; } @@ -802,7 +802,7 @@ static int rdata_nsec_to_type_array(const knot_rdata_item_t *item, free(bitmap); } - return DNSLIB_EOK; + return KNOT_EOK; } /* should write error, not return values !!! */ @@ -814,7 +814,7 @@ static int rdata_nsec_to_type_array(const knot_rdata_item_t *item, * \param node Node to be checked. * \param handler Error handler * - * \retval DNSLIB_EOK if no error was found. + * \retval KNOT_EOK if no error was found. * * \return Appropriate error code if error was found. */ @@ -827,7 +827,7 @@ static int check_nsec3_node_in_zone(knot_zone_contents_t *zone, knot_node_t *nod if (nsec3_node == NULL) { /* I know it's probably not what RFCs say, but it will have to * do for now. */ - if (knot_node_rrset(node, DNSLIB_RRTYPE_DS) != NULL) { + if (knot_node_rrset(node, KNOT_RRTYPE_DS) != NULL) { err_handler_handle_error(handler, node, ZC_ERR_NSEC3_UNSECURED_DELEGATION); } else { @@ -854,7 +854,7 @@ static int check_nsec3_node_in_zone(knot_zone_contents_t *zone, knot_node_t *nod const knot_rrset_t *previous_rrset = knot_node_rrset(nsec3_previous, - DNSLIB_RRTYPE_NSEC3); + KNOT_RRTYPE_NSEC3); assert(previous_rrset); @@ -873,7 +873,7 @@ static int check_nsec3_node_in_zone(knot_zone_contents_t *zone, knot_node_t *nod } const knot_rrset_t *nsec3_rrset = - knot_node_rrset(nsec3_node, DNSLIB_RRTYPE_NSEC3); + knot_node_rrset(nsec3_node, KNOT_RRTYPE_NSEC3); assert(nsec3_rrset); @@ -883,7 +883,7 @@ static int check_nsec3_node_in_zone(knot_zone_contents_t *zone, knot_node_t *nod knot_rdata_item( knot_rrset_rdata( knot_node_rrset( - knot_zone_contents_apex(zone), DNSLIB_RRTYPE_SOA)), 6))); + knot_zone_contents_apex(zone), KNOT_RRTYPE_SOA)), 6))); /* Are those getters even worth this? * Now I have no idea what this code does. */ @@ -902,7 +902,7 @@ static int check_nsec3_node_in_zone(knot_zone_contents_t *zone, knot_node_t *nod (char **)&next_dname_decoded)) <= 0) || (next_dname_decoded == NULL)) { fprintf(stderr, "Could not encode base32 string!\n"); - return DNSLIB_ERROR; + return KNOT_ERROR; } /* This is why we allocate maximum length of decoded string + 1 */ @@ -913,14 +913,14 @@ static int check_nsec3_node_in_zone(knot_zone_contents_t *zone, knot_node_t *nod knot_dname_t *next_dname = knot_dname_new_from_wire(next_dname_decoded, real_size + 1, NULL); - CHECK_ALLOC_LOG(next_dname, DNSLIB_ENOMEM); + CHECK_ALLOC_LOG(next_dname, KNOT_ENOMEM); free(next_dname_decoded); if (knot_dname_cat(next_dname, knot_node_owner(knot_zone_contents_apex(zone))) == NULL) { fprintf(stderr, "Could not concatenate dnames!\n"); - return DNSLIB_ERROR; + return KNOT_ERROR; } @@ -943,14 +943,14 @@ static int check_nsec3_node_in_zone(knot_zone_contents_t *zone, knot_node_t *nod &array, &count) != 0) { err_handler_handle_error(handler, node, ZC_ERR_ALLOC); - return DNSLIB_ERROR; + return KNOT_ERROR; } uint16_t type = 0; for (int j = 0; j < count; j++) { /* test for each type's presence */ type = array[j]; - if (type == DNSLIB_RRTYPE_RRSIG) { + if (type == KNOT_RRTYPE_RRSIG) { continue; } if (knot_node_rrset(node, @@ -971,7 +971,7 @@ static int check_nsec3_node_in_zone(knot_zone_contents_t *zone, knot_node_t *nod free(array); - return DNSLIB_EOK; + return KNOT_EOK; } /*! @@ -982,7 +982,7 @@ static int check_nsec3_node_in_zone(knot_zone_contents_t *zone, knot_node_t *nod * \param do_checks Level of checks to be done. * \param handler Error handler. * - * \retval DNSLIB_EOK if no error was found. + * \retval KNOT_EOK if no error was found. * * \return Appropriate error code if error was found. */ @@ -993,10 +993,10 @@ static int semantic_checks_plain(knot_zone_contents_t *zone, { assert(handler); const knot_rrset_t *cname_rrset = - knot_node_rrset(node, DNSLIB_RRTYPE_CNAME); + knot_node_rrset(node, KNOT_RRTYPE_CNAME); if (cname_rrset != NULL) { if (check_cname_cycles_in_zone(zone, cname_rrset) != - DNSLIB_EOK) { + KNOT_EOK) { err_handler_handle_error(handler, node, ZC_ERR_CNAME_CYCLE); } @@ -1012,8 +1012,8 @@ static int semantic_checks_plain(knot_zone_contents_t *zone, } else if (cname_rrset && knot_node_rrset_count(node) != 1) { /* With DNSSEC node can contain RRSIG or NSEC */ - if (!(knot_node_rrset(node, DNSLIB_RRTYPE_RRSIG) || - knot_node_rrset(node, DNSLIB_RRTYPE_NSEC))) { + if (!(knot_node_rrset(node, KNOT_RRTYPE_RRSIG) || + knot_node_rrset(node, KNOT_RRTYPE_NSEC))) { err_handler_handle_error(handler, node, ZC_ERR_CNAME_EXTRA_RECORDS_DNSSEC); } @@ -1030,7 +1030,7 @@ static int semantic_checks_plain(knot_zone_contents_t *zone, /* check for glue records at zone cuts */ if (knot_node_is_deleg_point(node)) { const knot_rrset_t *ns_rrset = - knot_node_rrset(node, DNSLIB_RRTYPE_NS); + knot_node_rrset(node, KNOT_RRTYPE_NS); assert(ns_rrset); //FIXME this should be an error as well ! (i guess) @@ -1050,16 +1050,16 @@ static int semantic_checks_plain(knot_zone_contents_t *zone, ZC_ERR_GLUE_NODE); } else { if ((knot_node_rrset(glue_node, - DNSLIB_RRTYPE_A) == NULL) && + KNOT_RRTYPE_A) == NULL) && (knot_node_rrset(glue_node, - DNSLIB_RRTYPE_AAAA) == NULL)) { + KNOT_RRTYPE_AAAA) == NULL)) { err_handler_handle_error(handler, node, ZC_ERR_GLUE_RECORD); } } } } - return DNSLIB_EOK; + return KNOT_EOK; } /*! @@ -1072,7 +1072,7 @@ static int semantic_checks_plain(knot_zone_contents_t *zone, * \param handler Error handler. * \param nsec3 NSEC3 used. * - * \retval DNSLIB_EOK if no error was found. + * \retval KNOT_EOK if no error was found. * * \return Appropriate error code if error was found. */ @@ -1091,7 +1091,7 @@ static int semantic_checks_dnssec(knot_zone_contents_t *zone, const knot_rrset_t **rrsets = knot_node_rrsets(node); const knot_rrset_t *dnskey_rrset = knot_node_rrset(knot_zone_contents_apex(zone), - DNSLIB_RRTYPE_DNSKEY); + KNOT_RRTYPE_DNSKEY); int ret = 0; @@ -1111,7 +1111,7 @@ static int semantic_checks_dnssec(knot_zone_contents_t *zone, /* check for NSEC record */ const knot_rrset_t *nsec_rrset = knot_node_rrset(node, - DNSLIB_RRTYPE_NSEC); + KNOT_RRTYPE_NSEC); if (nsec_rrset == NULL) { err_handler_handle_error(handler, node, @@ -1146,7 +1146,7 @@ static int semantic_checks_dnssec(knot_zone_contents_t *zone, for (int j = 0; j < count; j++) { /* test for each type's presence */ type = array[j]; - if (type == DNSLIB_RRTYPE_RRSIG) { + if (type == KNOT_RRTYPE_RRSIG) { continue; } if (knot_node_rrset(node, @@ -1226,7 +1226,7 @@ static int semantic_checks_dnssec(knot_zone_contents_t *zone, } else if (nsec3 && (auth || deleg)) { /* nsec3 */ int ret = check_nsec3_node_in_zone(zone, node, handler); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { free(rrsets); return ret; } @@ -1234,7 +1234,7 @@ static int semantic_checks_dnssec(knot_zone_contents_t *zone, } free(rrsets); - return DNSLIB_EOK; + return KNOT_EOK; } /*! @@ -1353,12 +1353,12 @@ static inline int fwrite_to_stream(const void *src, memcpy(knot_dump_stream + knot_dump_stream_size, src, size * n); knot_dump_stream_size += (size * n) * sizeof(uint8_t); - return DNSLIB_EOK; + return KNOT_EOK; } else { free(knot_dump_stream); knot_dump_stream = NULL; knot_dump_stream_size = 0; - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } } @@ -1402,7 +1402,7 @@ static void dump_dname_with_id(const knot_dname_t *dname, FILE *f) fwrite_wrapper(&id, sizeof(id), 1, f); knot_dname_dump_binary(dname, f); /* if (!fwrite_wrapper_safe(&dname->id, sizeof(dname->id), 1, f)) { - return DNSLIB_ERROR; + return KNOT_ERROR; } */ } @@ -1429,9 +1429,9 @@ static void knot_rdata_dump_binary(knot_rdata_t *rdata, continue; } debug_knot_zdump("Item n: %d\n", i); - if (desc->wireformat[i] == DNSLIB_RDATA_WF_COMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_LITERAL_DNAME ) { + if (desc->wireformat[i] == KNOT_RDATA_WF_COMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_UNCOMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_LITERAL_DNAME ) { /* some temp variables - this is way too long */ assert(rdata->items[i].dname != NULL); knot_dname_t *wildcard = NULL; @@ -1498,7 +1498,7 @@ static void knot_rrsig_set_dump_binary(knot_rrset_t *rrsig, arg_t *data, { debug_knot_zdump("Dumping rrset \\w owner: %s\n", knot_dname_to_str(rrsig->owner)); - assert(rrsig->type == DNSLIB_RRTYPE_RRSIG); + assert(rrsig->type == KNOT_RRTYPE_RRSIG); assert(rrsig->rdata); FILE *f = (FILE *)((arg_t *)data)->arg1; fwrite_wrapper(&rrsig->type, sizeof(rrsig->type), 1, f); @@ -1517,11 +1517,11 @@ static void knot_rrsig_set_dump_binary(knot_rrset_t *rrsig, arg_t *data, tmp_rdata = rrsig->rdata; while (tmp_rdata->next != rrsig->rdata) { - knot_rdata_dump_binary(tmp_rdata, DNSLIB_RRTYPE_RRSIG, data, + knot_rdata_dump_binary(tmp_rdata, KNOT_RRTYPE_RRSIG, data, use_ids); tmp_rdata = tmp_rdata->next; } - knot_rdata_dump_binary(tmp_rdata, DNSLIB_RRTYPE_RRSIG, data, use_ids); + knot_rdata_dump_binary(tmp_rdata, KNOT_RRTYPE_RRSIG, data, use_ids); } /*! @@ -1665,11 +1665,11 @@ static void knot_node_dump_binary(knot_node_t *node, void *data) static int zone_is_secure(knot_zone_contents_t *zone) { if (knot_node_rrset(knot_zone_contents_apex(zone), - DNSLIB_RRTYPE_DNSKEY) == NULL) { + KNOT_RRTYPE_DNSKEY) == NULL) { return 0; } else { if (knot_node_rrset(knot_zone_contents_apex(zone), - DNSLIB_RRTYPE_NSEC3PARAM) != NULL) { + KNOT_RRTYPE_NSEC3PARAM) != NULL) { return 2; } else { return 1; @@ -1698,7 +1698,7 @@ static void log_cyclic_errors_in_zone(err_handler_t *handler, assert(last_nsec3_node && first_nsec3_node); const knot_rrset_t *nsec3_rrset = knot_node_rrset(last_nsec3_node, - DNSLIB_RRTYPE_NSEC3); + KNOT_RRTYPE_NSEC3); if (nsec3_rrset == NULL) { err_handler_handle_error(handler, last_nsec3_node, ZC_ERR_NSEC3_RDATA_CHAIN); @@ -1771,7 +1771,7 @@ static void log_cyclic_errors_in_zone(err_handler_t *handler, } else { const knot_rrset_t *nsec_rrset = knot_node_rrset(last_node, - DNSLIB_RRTYPE_NSEC); + KNOT_RRTYPE_NSEC); if (nsec_rrset == NULL) { err_handler_handle_error(handler, last_node, @@ -1835,7 +1835,7 @@ static int knot_dump_dname_table(const knot_dname_table_t *dname_table, // TREE_FORWARD_APPLY(dname_table->tree, dname_table_node, avl, // dump_dname_from_tree, (void *)f); - return DNSLIB_EOK; + return KNOT_EOK; } static void save_node_from_tree(knot_node_t *node, void *data) @@ -1856,7 +1856,7 @@ int knot_zdump_binary(knot_zone_contents_t *zone, const char *filename, FILE *f; f = fopen(filename, "wb"); if (f == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } fwrite_wrapper = fwrite_to_file_crc; @@ -1898,7 +1898,7 @@ int knot_zdump_binary(knot_zone_contents_t *zone, const char *filename, do_checks = 0; } else { /* Do check for SOA right now */ if (knot_node_rrset(knot_zone_contents_apex(zone), - DNSLIB_RRTYPE_SOA) == NULL) { + KNOT_RRTYPE_SOA) == NULL) { err_handler_handle_error(handler, knot_zone_contents_apex(zone), ZC_ERR_MISSING_SOA); @@ -1949,8 +1949,8 @@ int knot_zdump_binary(knot_zone_contents_t *zone, const char *filename, /* Write dname table. */ if (knot_dump_dname_table(zone->dname_table, f) - != DNSLIB_EOK) { - return DNSLIB_ERROR; + != KNOT_EOK) { + return KNOT_ERROR; } arguments.arg1 = f; @@ -1970,7 +1970,7 @@ int knot_zdump_binary(knot_zone_contents_t *zone, const char *filename, malloc(sizeof(char) * (strlen(filename) + strlen(".crc") + 1)); if (unlikely(!crc_path)) { fclose(f); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } memset(crc_path, 0, sizeof(char) * (strlen(filename) + strlen(".crc") + 1)); @@ -1992,7 +1992,7 @@ int knot_zdump_binary(knot_zone_contents_t *zone, const char *filename, fclose(f); - return DNSLIB_EOK; + return KNOT_EOK; } int knot_zdump_rrset_serialize(const knot_rrset_t *rrset, uint8_t **stream, @@ -2001,7 +2001,7 @@ int knot_zdump_rrset_serialize(const knot_rrset_t *rrset, uint8_t **stream, /*!< \todo LOCK? might not be thread safe. Probably isn't! */ fwrite_wrapper = fwrite_to_stream; if (*stream != NULL || rrset == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } assert(knot_dump_stream == NULL); @@ -2011,7 +2011,7 @@ int knot_zdump_rrset_serialize(const knot_rrset_t *rrset, uint8_t **stream, arguments.arg1 = NULL; knot_rrset_dump_binary(rrset, &arguments, 0); if (knot_dump_stream == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } /* Make a copy of stream. */ @@ -2020,7 +2020,7 @@ int knot_zdump_rrset_serialize(const knot_rrset_t *rrset, uint8_t **stream, free(knot_dump_stream); knot_dump_stream = NULL; knot_dump_stream_size = 0; - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } memcpy(*stream, knot_dump_stream, knot_dump_stream_size); @@ -2030,5 +2030,5 @@ int knot_zdump_rrset_serialize(const knot_rrset_t *rrset, uint8_t **stream, knot_dump_stream = NULL; knot_dump_stream_size = 0; - return DNSLIB_EOK; + return KNOT_EOK; } diff --git a/src/dnslib/zone-dump.h b/src/dnslib/zone-dump.h index 9ea78c966e68e146dfa14f877afde8623ec0f9e6..5e8f007ba5dba8d32c8da14b4fef8d333e9bb1a5 100644 --- a/src/dnslib/zone-dump.h +++ b/src/dnslib/zone-dump.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_ZONEDUMP_H_ -#define _KNOT_DNSLIB_ZONEDUMP_H_ +#ifndef _KNOTDKNOT_ZONEDUMP_H_ +#define _KNOTDKNOT_ZONEDUMP_H_ #include "dnslib/zone.h" @@ -32,8 +32,8 @@ enum { * \param do_checks Set to 1 to enable checking the zone for semantic errors. * \param sfilename Source filename of the text zone file. * - * \retval DNSLIB_EOK on success. - * \retval DNSLIB_EBADARG if the file cannot be opened for writing. + * \retval KNOT_EOK on success. + * \retval KNOT_EBADARG if the file cannot be opened for writing. */ int knot_zdump_binary(knot_zone_contents_t *zone, const char *filename, int do_checks, const char *sfilename); @@ -46,9 +46,9 @@ int knot_zdump_binary(knot_zone_contents_t *zone, const char *filename, * \param stream Stream containing serialized RRSet. * \param size Length of created stream. * - * \retval DNSLIB_EOK on success. - * \retval DNSLIB_EBADARG if wrong arguments are supplied. - * \retval DNSLIB_ENOMEM on memory error. + * \retval KNOT_EOK on success. + * \retval KNOT_EBADARG if wrong arguments are supplied. + * \retval KNOT_ENOMEM on memory error. */ int knot_zdump_rrset_serialize(const knot_rrset_t *rrset, uint8_t **stream, size_t *size); @@ -61,13 +61,13 @@ int knot_zdump_rrset_serialize(const knot_rrset_t *rrset, uint8_t **stream, * \param stream Stream containing serialized RRSet. * \param size Length of created stream. * - * \retval DNSLIB_EOK on success. - * \retval DNSLIB_EBADARG if wrong arguments are supplied. - * \retval DNSLIB_ENOMEM on memory error. + * \retval KNOT_EOK on success. + * \retval KNOT_EBADARG if wrong arguments are supplied. + * \retval KNOT_ENOMEM on memory error. */ int knot_zdump_rrset_serialize(const knot_rrset_t *rrset, uint8_t **stream, size_t *size); -#endif /* _DNSLIB_ZONEDUMP_H_ */ +#endif /* _KNOT_ZONEDUMP_H_ */ /*! @} */ diff --git a/src/dnslib/zone-load.c b/src/dnslib/zone-load.c index 690cfc5b0fa40592ecf5996c7220a8029502ca31..53a67aec6ffcca3ded14ab61b53511c5b1efdb40 100644 --- a/src/dnslib/zone-load.c +++ b/src/dnslib/zone-load.c @@ -122,9 +122,9 @@ static void load_rdata_purge(knot_rdata_t *rdata, */ unsigned i = 0; switch(type) { - case DNSLIB_RDATA_WF_COMPRESSED_DNAME: - case DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME: - case DNSLIB_RDATA_WF_LITERAL_DNAME: + case KNOT_RDATA_WF_COMPRESSED_DNAME: + case KNOT_RDATA_WF_UNCOMPRESSED_DNAME: + case KNOT_RDATA_WF_LITERAL_DNAME: for (i = 0; i < count; ++i) { knot_dname_retain(items[i].dname); } @@ -232,9 +232,9 @@ static knot_rdata_t *knot_load_rdata(uint16_t type, FILE *f, debug_knot_zload("current type: %s\n", knot_rrtype_to_string(type)); for (int i = 0; i < desc->length; i++) { - if (desc->wireformat[i] == DNSLIB_RDATA_WF_COMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_LITERAL_DNAME ) { + if (desc->wireformat[i] == KNOT_RDATA_WF_COMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_UNCOMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_LITERAL_DNAME ) { /* TODO maybe this does not need to be stored this big*/ @@ -340,7 +340,7 @@ static knot_rrset_t *knot_load_rrsig(FILE *f, knot_dname_t **id_array, return NULL; } - if (rrset_type != DNSLIB_RRTYPE_RRSIG) { + if (rrset_type != KNOT_RRTYPE_RRSIG) { fprintf(stderr, "!! Error: rrsig has wrong type\n"); return NULL; } @@ -366,7 +366,7 @@ static knot_rrset_t *knot_load_rrsig(FILE *f, knot_dname_t **id_array, debug_knot_zload("loading %d rdata entries\n", rdata_count); for (int i = 0; i < rdata_count; i++) { - tmp_rdata = knot_load_rdata(DNSLIB_RRTYPE_RRSIG, f, + tmp_rdata = knot_load_rdata(KNOT_RRTYPE_RRSIG, f, id_array, use_ids); if (tmp_rdata) { knot_rrset_add_rdata(rrsig, tmp_rdata); @@ -711,7 +711,7 @@ zloader_t *knot_zload_open(const char *filename) "file '%s'\n", filename); fclose(f); - errno = DNSLIB_ECRC; + errno = KNOT_ECRC; return NULL; } @@ -807,7 +807,7 @@ static void cleanup_id_array(knot_dname_t **id_array, // return NULL; // } // if (knot_dname_table_add_dname(dname_table, -// loaded_dname) != DNSLIB_EOK) { +// loaded_dname) != KNOT_EOK) { // } // } @@ -833,7 +833,7 @@ static knot_dname_table_t *create_dname_table_from_array( for (uint i = 1; i < max_id; i++) { assert(array[i]); if (knot_dname_table_add_dname(ret, - array[i]) != DNSLIB_EOK) { + array[i]) != KNOT_EOK) { debug_knot_zload("Could not add: %s\n", knot_dname_to_str(array[i])); knot_dname_table_deep_free(&ret); @@ -1125,7 +1125,7 @@ int knot_zload_rrset_deserialize(knot_rrset_t **rrset, uint8_t *stream, size_t *size) { if (stream == NULL || size == 0 || *rrset != NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } fread_wrapper = read_from_stream; @@ -1139,7 +1139,7 @@ int knot_zload_rrset_deserialize(knot_rrset_t **rrset, knot_zload_stream = NULL; knot_zload_stream_remaining = 0; knot_zload_stream_size = 0; - return DNSLIB_EMALF; + return KNOT_EMALF; } // printf("knot_zload_stream_size: %d, knot_zload_stream_remaning: %d\n", @@ -1152,6 +1152,6 @@ int knot_zload_rrset_deserialize(knot_rrset_t **rrset, knot_zload_stream_remaining = 0; knot_zload_stream_size = 0; - return DNSLIB_EOK; + return KNOT_EOK; } diff --git a/src/dnslib/zone-load.h b/src/dnslib/zone-load.h index 675828321cca7758866b61008cbe6f81060140ee..0495dbd5140dc932185a04d106479f8a5ca50548 100644 --- a/src/dnslib/zone-load.h +++ b/src/dnslib/zone-load.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_ZONELOAD_H_ -#define _KNOT_DNSLIB_ZONELOAD_H_ +#ifndef _KNOTDKNOT_ZONELOAD_H_ +#define _KNOTDKNOT_ZONELOAD_H_ #include <stdio.h> @@ -76,13 +76,13 @@ void knot_zload_close(zloader_t *loader); * \note If RRSet contains RRSIGs, their owners are not copies, but only links * to the owner of RRSet. All RDATA dnames are copied. * - * \retval DNSLIB_EOK on success. - * \retval DNSLIB_EBADAG on wrong arguments. - * \retval DNSLIB_EMALF when stream is malformed. + * \retval KNOT_EOK on success. + * \retval KNOT_EBADAG on wrong arguments. + * \retval KNOT_EMALF when stream is malformed. */ int knot_zload_rrset_deserialize(knot_rrset_t **rrset, uint8_t *stream, size_t *size); -#endif /* _KNOT_ZONELOAD_H_ */ +#endif /* _KNOTDZONELOAD_H_ */ /*! @} */ diff --git a/src/dnslib/zone-tree.c b/src/dnslib/zone-tree.c index 69a1bccba1b4151147a544773d0ebd448069ba81..3762946fe1707f0270b25dbcb7ad6939576bd048 100644 --- a/src/dnslib/zone-tree.c +++ b/src/dnslib/zone-tree.c @@ -48,13 +48,13 @@ static int knot_zone_tree_copy_node(knot_zone_tree_node_t *from, { if (from == NULL) { *to = NULL; - return DNSLIB_EOK; + return KNOT_EOK; } *to = (knot_zone_tree_node_t *) malloc(sizeof(knot_zone_tree_node_t)); if (*to == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } (*to)->node = from->node; @@ -62,19 +62,19 @@ static int knot_zone_tree_copy_node(knot_zone_tree_node_t *from, int ret = knot_zone_tree_copy_node(from->avl.avl_left, &(*to)->avl.avl_left); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } ret = knot_zone_tree_copy_node(from->avl.avl_right, &(*to)->avl.avl_right); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { knot_zone_tree_delete_subtree((*to)->avl.avl_left); (*to)->avl.avl_left = NULL; return ret; } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -104,11 +104,11 @@ static void knot_zone_tree_free_node(knot_zone_tree_node_t *node, int knot_zone_tree_init(knot_zone_tree_t *tree) { if (tree == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } TREE_INIT(tree, knot_zone_tree_node_compare); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -116,13 +116,13 @@ int knot_zone_tree_init(knot_zone_tree_t *tree) int knot_zone_tree_insert(knot_zone_tree_t *tree, knot_node_t *node) { if (tree == NULL || node == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } knot_zone_tree_node_t *znode = (knot_zone_tree_node_t *)malloc( sizeof(knot_zone_tree_node_t)); if (znode == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } znode->node = node; @@ -133,7 +133,7 @@ int knot_zone_tree_insert(knot_zone_tree_t *tree, knot_node_t *node) /*! \todo How to know if this was successful? */ TREE_INSERT(tree, knot_zone_tree_node, avl, znode); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -153,7 +153,7 @@ int knot_zone_tree_get(knot_zone_tree_t *tree, const knot_dname_t *owner, knot_node_t **found) { if (tree == NULL || owner == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } *found = NULL; @@ -162,7 +162,7 @@ int knot_zone_tree_get(knot_zone_tree_t *tree, const knot_dname_t *owner, knot_zone_tree_node_t *tmp = (knot_zone_tree_node_t *)malloc( sizeof(knot_zone_tree_node_t)); if (tmp == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } // create dummy data node to use for lookup @@ -170,7 +170,7 @@ int knot_zone_tree_get(knot_zone_tree_t *tree, const knot_dname_t *owner, (knot_dname_t *)owner, NULL, 0); if (tmp_data == NULL) { free(tmp); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } tmp->node = tmp_data; @@ -184,7 +184,7 @@ int knot_zone_tree_get(knot_zone_tree_t *tree, const knot_dname_t *owner, *found = n->node; } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -212,7 +212,7 @@ int knot_zone_tree_get_less_or_equal(knot_zone_tree_t *tree, { if (tree == NULL || owner == NULL || found == NULL || previous == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } knot_zone_tree_node_t *f = NULL, *prev = NULL; @@ -221,7 +221,7 @@ int knot_zone_tree_get_less_or_equal(knot_zone_tree_t *tree, knot_zone_tree_node_t *tmp = (knot_zone_tree_node_t *)malloc( sizeof(knot_zone_tree_node_t)); if (tmp == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } // create dummy data node to use for lookup @@ -229,7 +229,7 @@ int knot_zone_tree_get_less_or_equal(knot_zone_tree_t *tree, (knot_dname_t *)owner, NULL, 0); if (tmp_data == NULL) { free(tmp); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } tmp->node = tmp_data; @@ -290,14 +290,14 @@ int knot_zone_tree_remove(knot_zone_tree_t *tree, knot_node_t **removed) { if (tree == NULL || owner == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } // create dummy node to use for lookup knot_zone_tree_node_t *tmp = (knot_zone_tree_node_t *)malloc( sizeof(knot_zone_tree_node_t)); if (tmp == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } // create dummy data node to use for lookup @@ -305,7 +305,7 @@ int knot_zone_tree_remove(knot_zone_tree_t *tree, (knot_dname_t *)owner, NULL, 0); if (tmp_data == NULL) { free(tmp); - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } tmp->node = tmp_data; @@ -321,7 +321,7 @@ int knot_zone_tree_remove(knot_zone_tree_t *tree, *removed = n->node; free(n); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -333,13 +333,13 @@ int knot_zone_tree_forward_apply_inorder(knot_zone_tree_t *tree, void *data) { if (tree == NULL || function == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } TREE_FORWARD_APPLY(tree, knot_zone_tree_node, avl, function, data); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -351,13 +351,13 @@ int knot_zone_tree_forward_apply_postorder(knot_zone_tree_t *tree, void *data) { if (tree == NULL || function == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } TREE_POST_ORDER_APPLY(tree, knot_zone_tree_node, avl, function, data); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -369,13 +369,13 @@ int knot_zone_tree_reverse_apply_inorder(knot_zone_tree_t *tree, void *data) { if (tree == NULL || function == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } TREE_REVERSE_APPLY(tree, knot_zone_tree_node, avl, function, data); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -387,13 +387,13 @@ int knot_zone_tree_reverse_apply_postorder(knot_zone_tree_t *tree, void *data) { if (tree == NULL || function == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } TREE_REVERSE_APPLY_POST(tree, knot_zone_tree_node, avl, function, data); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ diff --git a/src/dnslib/zone-tree.h b/src/dnslib/zone-tree.h index 30f8442056b778d978b95780ba5a2b0ed2c5d9a1..1f4dea9e4afcdec91c8b857b60bfe5f89a592ba3 100644 --- a/src/dnslib/zone-tree.h +++ b/src/dnslib/zone-tree.h @@ -11,8 +11,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_ZONE_TREE_H_ -#define _KNOT_DNSLIB_ZONE_TREE_H_ +#ifndef _KNOTDKNOT_ZONE_TREE_H_ +#define _KNOTDKNOT_ZONE_TREE_H_ #include "common/tree.h" #include "dnslib/node.h" @@ -40,8 +40,8 @@ typedef TREE_HEAD(knot_zone_tree, knot_zone_tree_node) knot_zone_tree_t; * * \param tree Zone tree structure to initialize. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG + * \retval KNOT_EOK + * \retval KNOT_EBADARG */ int knot_zone_tree_init(knot_zone_tree_t *tree); @@ -51,9 +51,9 @@ int knot_zone_tree_init(knot_zone_tree_t *tree); * \param tree Zone tree to insert the node into. * \param node Node to insert. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_EBADARG + * \retval KNOT_ENOMEM */ int knot_zone_tree_insert(knot_zone_tree_t *tree, knot_node_t *node); @@ -63,9 +63,9 @@ int knot_zone_tree_insert(knot_zone_tree_t *tree, knot_node_t *node); * \param tree Zone tree to search in. * \param owner Owner of the node to find. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_EBADARG + * \retval KNOT_ENOMEM */ int knot_zone_tree_find(knot_zone_tree_t *tree, const knot_dname_t *owner, @@ -80,9 +80,9 @@ int knot_zone_tree_find(knot_zone_tree_t *tree, * \param tree Zone tree to search in. * \param owner Owner of the node to find. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_EBADARG + * \retval KNOT_ENOMEM */ int knot_zone_tree_get(knot_zone_tree_t *tree, const knot_dname_t *owner, @@ -104,8 +104,8 @@ int knot_zone_tree_get(knot_zone_tree_t *tree, * \a previous is set properly. * \retval 0 if the domain name was not found. \a found may hold any (or none) * node. \a previous is set properly. - * \retval DNSLIB_EBADARG - * \retval DNSLIB_ENOMEM + * \retval KNOT_EBADARG + * \retval KNOT_ENOMEM */ int knot_zone_tree_find_less_or_equal(knot_zone_tree_t *tree, const knot_dname_t *owner, @@ -131,8 +131,8 @@ int knot_zone_tree_find_less_or_equal(knot_zone_tree_t *tree, * \a previous is set properly. * \retval 0 if the domain name was not found. \a found may hold any (or none) * node. \a previous is set properly. - * \retval DNSLIB_EBADARG - * \retval DNSLIB_ENOMEM + * \retval KNOT_EBADARG + * \retval KNOT_ENOMEM */ int knot_zone_tree_get_less_or_equal(knot_zone_tree_t *tree, const knot_dname_t *owner, @@ -166,8 +166,8 @@ int knot_zone_tree_remove(knot_zone_tree_t *tree, * \param function Function to be applied to each node of the zone. * \param data Arbitrary data to be passed to the function. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG + * \retval KNOT_EOK + * \retval KNOT_EBADARG */ int knot_zone_tree_forward_apply_inorder(knot_zone_tree_t *tree, void (*function)( @@ -188,8 +188,8 @@ int knot_zone_tree_forward_apply_inorder(knot_zone_tree_t *tree, * \param function Function to be applied to each node of the zone. * \param data Arbitrary data to be passed to the function. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG + * \retval KNOT_EOK + * \retval KNOT_EBADARG */ int knot_zone_tree_forward_apply_postorder(knot_zone_tree_t *tree, void (*function)( @@ -211,8 +211,8 @@ int knot_zone_tree_forward_apply_postorder(knot_zone_tree_t *tree, * \param function Function to be applied to each node of the zone. * \param data Arbitrary data to be passed to the function. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG + * \retval KNOT_EOK + * \retval KNOT_EBADARG */ int knot_zone_tree_reverse_apply_inorder(knot_zone_tree_t *tree, void (*function)( @@ -234,8 +234,8 @@ int knot_zone_tree_reverse_apply_inorder(knot_zone_tree_t *tree, * \param function Function to be applied to each node of the zone. * \param data Arbitrary data to be passed to the function. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG + * \retval KNOT_EOK + * \retval KNOT_EBADARG */ int knot_zone_tree_reverse_apply_postorder(knot_zone_tree_t *tree, void (*function)( @@ -253,8 +253,8 @@ int knot_zone_tree_reverse_apply_postorder(knot_zone_tree_t *tree, * \param from Original zone tree. * \param to Zone tree to copy the original one into. * - * \retval DNSLIB_EOK - * \retval DNSLIB_ENOMEM + * \retval KNOT_EOK + * \retval KNOT_ENOMEM */ int knot_zone_tree_shallow_copy(knot_zone_tree_t *from, knot_zone_tree_t *to); @@ -277,7 +277,7 @@ void knot_zone_tree_deep_free(knot_zone_tree_t **tree, int free_owners); /*----------------------------------------------------------------------------*/ -#endif // _KNOT_DNSLIB_ZONE_TREE_H_ +#endif // _KNOTDKNOT_ZONE_TREE_H_ /*! @} */ diff --git a/src/dnslib/zone.c b/src/dnslib/zone.c index f69764c653d00a1282a6d078d289fec00665e4a7..dc6863c559f3ad117da9cd8613bb35b3b9696e76 100644 --- a/src/dnslib/zone.c +++ b/src/dnslib/zone.c @@ -93,7 +93,7 @@ const knot_zone_contents_t *knot_zone_contents( time_t knot_zone_version(const knot_zone_t *zone) { if (zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } return zone->version; @@ -132,7 +132,7 @@ int knot_zone_add_node(knot_zone_t *zone, knot_node_t *node, int create_parents, int use_domain_table) { if (zone == NULL || node == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } knot_node_set_zone(node, zone); @@ -148,7 +148,7 @@ int knot_zone_add_nsec3_node(knot_zone_t *zone, knot_node_t *node, int create_parents, int use_domain_table) { if (zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } return knot_zone_contents_add_nsec3_node(zone->contents, node, @@ -222,7 +222,7 @@ int knot_zone_tree_apply_postorder(knot_zone_t *zone, void *data) { if (zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } return knot_zone_contents_tree_apply_postorder(zone->contents, @@ -236,7 +236,7 @@ int knot_zone_tree_apply_inorder(knot_zone_t *zone, void *data) { if (zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } return knot_zone_contents_tree_apply_inorder(zone->contents, @@ -250,7 +250,7 @@ int knot_zone_tree_apply_inorder_reverse(knot_zone_t *zone, void *data) { if (zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } return knot_zone_contents_tree_apply_inorder_reverse(zone->contents, @@ -264,7 +264,7 @@ int knot_zone_nsec3_apply_postorder(knot_zone_t *zone, void *data) { if (zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } return knot_zone_contents_nsec3_apply_postorder(zone->contents, @@ -278,7 +278,7 @@ int knot_zone_nsec3_apply_inorder(knot_zone_t *zone, void *data) { if (zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } return knot_zone_contents_nsec3_apply_inorder(zone->contents, @@ -292,7 +292,7 @@ int knot_zone_nsec3_apply_inorder_reverse(knot_zone_t *zone, void *data) { if (zone == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } return knot_zone_contents_nsec3_apply_inorder_reverse(zone->contents, @@ -359,7 +359,7 @@ void knot_zone_deep_free(knot_zone_t **zone, int free_rdata_dnames) "update.\n"); } -DEBUG_DNSLIB_ZONE( +DEBUG_KNOT_ZONE( char *name = knot_dname_to_str((*zone)->name); debug_knot_zone("Destroying zone %p, name: %s.\n", *zone, name); free(name); diff --git a/src/dnslib/zone.h b/src/dnslib/zone.h index 2b5e1ea86411783f37e209855eda317c9f4753df..3ca17399b6e8367d47897452bfeb8519e1068958 100644 --- a/src/dnslib/zone.h +++ b/src/dnslib/zone.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_ZONE_H_ -#define _KNOT_DNSLIB_ZONE_H_ +#ifndef _KNOTDKNOT_ZONE_H_ +#define _KNOTDKNOT_ZONE_H_ #include <time.h> @@ -37,8 +37,8 @@ * Used in knot_zone_find_dname() and knot_zone_find_dname_hash(). */ enum knot_zone_retvals { - DNSLIB_ZONE_NAME_FOUND = 1, - DNSLIB_ZONE_NAME_NOT_FOUND = 0 + KNOT_ZONE_NAME_FOUND = 1, + KNOT_ZONE_NAME_NOT_FOUND = 0 }; typedef enum knot_zone_retvals knot_zone_retvals_t; @@ -109,10 +109,10 @@ void knot_zone_set_data(knot_zone_t *zone, void *data); * \param zone Zone to add the node into. * \param node Node to add into the zone. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG - * \retval DNSLIB_EBADZONE - * \retval DNSLIB_EHASH + * \retval KNOT_EOK + * \retval KNOT_EBADARG + * \retval KNOT_EBADZONE + * \retval KNOT_EHASH * * \todo Replace tests of this function by tests of its zone-contents version. */ @@ -130,9 +130,9 @@ int knot_zone_add_node(knot_zone_t *zone, knot_node_t *node, * \param zone Zone to add the node into. * \param node Node to add into the zone. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EBADARG - * \retval DNSLIB_EBADZONE + * \retval KNOT_EOK + * \retval KNOT_EBADARG + * \retval KNOT_EBADZONE * * \todo Replace tests of this function by tests of its zone-contents version. */ diff --git a/src/dnslib/zonedb.c b/src/dnslib/zonedb.c index 4885cbe6d1ddfc2f52f30c554c579f0833bbabaa..1de07b78f7b61274045487cd28a89cdb9d6c8a4c 100644 --- a/src/dnslib/zonedb.c +++ b/src/dnslib/zonedb.c @@ -35,7 +35,7 @@ static int knot_zonedb_compare_zone_names(void *p1, void *p2) int ret = knot_dname_compare(zone1->name, zone2->name); -DEBUG_DNSLIB_ZONEDB( +DEBUG_KNOT_ZONEDB( char *name1 = knot_dname_to_str(zone1->name); char *name2 = knot_dname_to_str(zone2->name); debug_knot_zonedb("Compared names %s and %s, result: %d.\n", @@ -89,16 +89,16 @@ int knot_zonedb_add_zone(knot_zonedb_t *db, knot_zone_t *zone) { if (db == NULL || zone == NULL || zone->contents == NULL || zone->contents->apex == NULL) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } -DEBUG_DNSLIB_ZONEDB( +DEBUG_KNOT_ZONEDB( char *name = knot_dname_to_str(zone->name); debug_knot_zonedb("Inserting zone %s into zone db.\n", name); free(name); ); int ret = knot_zone_contents_load_nsec3param( knot_zone_get_contents(zone)); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } @@ -108,7 +108,7 @@ DEBUG_DNSLIB_ZONEDB( db->zone_count++; } - return (ret != 0) ? DNSLIB_EZONEIN : DNSLIB_EOK; + return (ret != 0) ? KNOT_EZONEIN : KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -123,7 +123,7 @@ int knot_zonedb_remove_zone(knot_zonedb_t *db, knot_dname_t *zone_name, &dummy_zone); if (z == NULL) { - return DNSLIB_ENOZONE; + return KNOT_ENOZONE; } // remove the zone from the skip list, but do not destroy it @@ -136,7 +136,7 @@ int knot_zonedb_remove_zone(knot_zonedb_t *db, knot_dname_t *zone_name, db->zone_count--; - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -212,7 +212,7 @@ const knot_zone_t *knot_zonedb_find_zone_for_name(knot_zonedb_t *db, knot_zone_t *zone = (found) ? (knot_zone_t *)found : NULL; -DEBUG_DNSLIB_ZONEDB( +DEBUG_KNOT_ZONEDB( char *name = knot_dname_to_str(dname); debug_knot_zonedb("Found zone for name %s: %p\n", name, zone); free(name); @@ -302,7 +302,7 @@ void knot_zonedb_deep_free(knot_zonedb_t **db) // debug_knot_zonedb("Is it empty (%p)? %s\n", // (*db)->zones, skip_is_empty((*db)->zones) ? "yes" : "no"); -//DEBUG_DNSLIB_ZONEDB( +//DEBUG_KNOT_ZONEDB( // int i = 1; // char *name = NULL; // while (zn != NULL) { diff --git a/src/dnslib/zonedb.h b/src/dnslib/zonedb.h index ae90cde7b08edd8b51a877cddfa2a77859318c55..dfd1880b30adcb1e928e1b54ee8947affaaebb80 100644 --- a/src/dnslib/zonedb.h +++ b/src/dnslib/zonedb.h @@ -12,8 +12,8 @@ * @{ */ -#ifndef _KNOT_DNSLIB_ZONEDB_H_ -#define _KNOT_DNSLIB_ZONEDB_H_ +#ifndef _KNOTDKNOT_ZONEDB_H_ +#define _KNOTDKNOT_ZONEDB_H_ #include "common/general-tree.h" #include "dnslib/zone.h" @@ -46,8 +46,8 @@ knot_zonedb_t *knot_zonedb_new(); * \param db Zone database to store the zone. * \param zone Parsed zone. * - * \retval DNSLIB_EOK - * \retval DNSLIB_EZONEIN + * \retval KNOT_EOK + * \retval KNOT_EZONEIN */ int knot_zonedb_add_zone(knot_zonedb_t *db, knot_zone_t *zone); @@ -64,8 +64,8 @@ int knot_zonedb_add_zone(knot_zonedb_t *db, knot_zone_t *zone); * zone after removing from zone database. Set to 0 * otherwise. * - * \retval DNSLIB_EOK - * \retval DNSLIB_ENOZONE + * \retval KNOT_EOK + * \retval KNOT_ENOZONE */ int knot_zonedb_remove_zone(knot_zonedb_t *db, knot_dname_t *zone_name, int destroy_zone); @@ -122,6 +122,6 @@ void knot_zonedb_deep_free(knot_zonedb_t **db); /*----------------------------------------------------------------------------*/ -#endif /* _KNOT_DNSLIB_ZONEDB_H_ */ +#endif /* _KNOTDKNOT_ZONEDB_H_ */ /*! @} */ diff --git a/src/knot/common.h b/src/knot/common.h index b0a5192a6a6811b50af9b275b875fb9284cfb3c5..00975b93451cd15e946b0bfd53652ac7a14c1700 100644 --- a/src/knot/common.h +++ b/src/knot/common.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_COMMON_H_ -#define _KNOT_COMMON_H_ +#ifndef _KNOTDCOMMON_H_ +#define _KNOTDCOMMON_H_ #include <signal.h> #include <stdint.h> @@ -114,6 +114,6 @@ typedef unsigned int uint; /*!< \brief Unsigned. */ } while (0) #endif -#endif /* _KNOT_COMMON_H_ */ +#endif /* _KNOTDCOMMON_H_ */ /*! @} */ diff --git a/src/knot/conf/conf.c b/src/knot/conf/conf.c index b75cc4a3ad8f111e483608eebe304578bd7e14a0..132cae40ce908d4406fc88d19a3e8fb57fdb98ee 100644 --- a/src/knot/conf/conf.c +++ b/src/knot/conf/conf.c @@ -70,7 +70,7 @@ void cf_error(const char *msg, void *scanner) new_config->filename, msg, cf_get_lineno(scanner), (char *)cf_get_text(scanner)); - _parser_res = KNOT_EPARSEFAIL; + _parser_res = KNOTDEPARSEFAIL; } /* @@ -298,10 +298,10 @@ void __attribute__ ((destructor)) conf_deinit() static int conf_fparser(conf_t *conf) { if (!conf->filename) { - return KNOT_EINVAL; + return KNOTDEINVAL; } - int ret = KNOT_EOK; + int ret = KNOTDEOK; pthread_mutex_lock(&_parser_lock); // { // Hook new configuration @@ -309,11 +309,11 @@ static int conf_fparser(conf_t *conf) FILE *f = fopen(conf->filename, "r"); if (f == 0) { pthread_mutex_unlock(&_parser_lock); - return KNOT_ENOENT; + return KNOTDENOENT; } // Parse config - _parser_res = KNOT_EOK; + _parser_res = KNOTDEOK; new_config->filename = conf->filename; void *scanner = NULL; cf_lex_init(&scanner); @@ -333,21 +333,21 @@ static int conf_fparser(conf_t *conf) static int conf_strparser(conf_t *conf, const char *src) { if (!src) { - return KNOT_EINVAL; + return KNOTDEINVAL; } - int ret = KNOT_EOK; + int ret = KNOTDEOK; pthread_mutex_lock(&_parser_lock); // { // Hook new configuration new_config = conf; if (src == 0) { pthread_mutex_unlock(&_parser_lock); - return KNOT_ENOENT; + return KNOTDENOENT; } // Parse config - _parser_res = KNOT_EOK; + _parser_res = KNOTDEOK; char *oldfn = new_config->filename; new_config->filename = "(stdin)"; void *scanner = NULL; @@ -397,7 +397,7 @@ int conf_add_hook(conf_t * conf, int sections, { conf_hook_t *hook = malloc(sizeof(conf_hook_t)); if (!hook) { - return KNOT_ENOMEM; + return KNOTDENOMEM; } hook->sections = sections; @@ -406,7 +406,7 @@ int conf_add_hook(conf_t * conf, int sections, add_tail(&conf->hooks, &hook->n); ++conf->hooks_count; - return KNOT_EOK; + return KNOTDEOK; } int conf_parse(conf_t *conf) @@ -421,10 +421,10 @@ int conf_parse(conf_t *conf) conf_update_hooks(conf); if (ret < 0) { - return KNOT_EPARSEFAIL; + return KNOTDEPARSEFAIL; } - return KNOT_EOK; + return KNOTDEOK; } int conf_parse_str(conf_t *conf, const char* src) @@ -439,10 +439,10 @@ int conf_parse_str(conf_t *conf, const char* src) conf_update_hooks(conf); if (ret < 0) { - return KNOT_EPARSEFAIL; + return KNOTDEPARSEFAIL; } - return KNOT_EOK; + return KNOTDEOK; } void conf_truncate(conf_t *conf, int unload_hooks) @@ -564,13 +564,13 @@ int conf_open(const char* path) { /* Check path. */ if (!path) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Check if exists. */ struct stat st; if (stat(path, &st) != 0) { - return KNOT_ENOENT; + return KNOTDENOENT; } /* Create new config. */ @@ -578,7 +578,7 @@ int conf_open(const char* path) /* Parse config. */ int ret = conf_fparser(nconf); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { conf_free(nconf); return ret; } @@ -610,7 +610,7 @@ int conf_open(const char* path) /* Update hooks. */ conf_update_hooks(nconf); - return KNOT_EOK; + return KNOTDEOK; } char* strcdup(const char *s1, const char *s2) diff --git a/src/knot/conf/conf.h b/src/knot/conf/conf.h index e19506a255739de296197e782252265e1d567d79..78003c2bc7a785071d97790768a49f487a5f1590 100644 --- a/src/knot/conf/conf.h +++ b/src/knot/conf/conf.h @@ -10,8 +10,8 @@ * @{ */ -#ifndef _KNOT_CONF_H_ -#define _KNOT_CONF_H_ +#ifndef _KNOTDCONF_H_ +#define _KNOTDCONF_H_ #include <sys/types.h> #include <sys/socket.h> @@ -221,8 +221,8 @@ conf_t *conf_new(const char* path); * \param on_update Callback. * \param data User specified data for hook. * - * \retval KNOT_EOK on success. - * \retval KNOT_ENOMEM out of memory error. + * \retval KNOTDEOK on success. + * \retval KNOTDENOMEM out of memory error. */ int conf_add_hook(conf_t * conf, int sections, int (*on_update)(const conf_t*, void*), void *data); @@ -234,8 +234,8 @@ int conf_add_hook(conf_t * conf, int sections, * * \param conf Configuration context. * - * \retval KNOT_EOK on success. - * \retval KNOT_EPARSEFAIL on parser error. + * \retval KNOTDEOK on success. + * \retval KNOTDEPARSEFAIL on parser error. */ int conf_parse(conf_t *conf); @@ -247,8 +247,8 @@ int conf_parse(conf_t *conf); * \param conf Configuration context. * \param src Source string. * - * \retval KNOT_EOK on success. - * \retval KNOT_EPARSEFAIL on parser error. + * \retval KNOTDEOK on success. + * \retval KNOTDEPARSEFAIL on parser error. */ int conf_parse_str(conf_t *conf, const char* src); @@ -289,9 +289,9 @@ char* conf_find_default(); * * \param path Path to configuration file. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on null path. - * \retval KNOT_ENOENT if the path doesn't exist. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on null path. + * \retval KNOTDENOENT if the path doesn't exist. */ int conf_open(const char* path); @@ -347,6 +347,6 @@ char* strcdup(const char *s1, const char *s2); */ char* strcpath(char *path); -#endif /* _KNOT_CONF_H_ */ +#endif /* _KNOTDCONF_H_ */ /*! @} */ diff --git a/src/knot/conf/logconf.c b/src/knot/conf/logconf.c index 50554a83c434103ca1503a4a96828656abdc27bb..7716d4fc6191d377f345f6ba52101ecb7d64b6c5 100644 --- a/src/knot/conf/logconf.c +++ b/src/knot/conf/logconf.c @@ -20,7 +20,7 @@ int log_conf_hook(const struct conf_t *conf, void *data) // Check if log declaration exists, otherwise ignore if (conf->logs_count < 1) { - return KNOT_EINVAL; + return KNOTDEINVAL; } // Find maximum log facility id @@ -81,6 +81,6 @@ int log_conf_hook(const struct conf_t *conf, void *data) log_levels_set(LOGT_STDERR, LOG_ANY, bmask); } - return KNOT_EOK; + return KNOTDEOK; } diff --git a/src/knot/conf/logconf.h b/src/knot/conf/logconf.h index 2f3df6e794ab81c44394626d3038d1f2ed858b43..ecdd3b7e729b0d074fef99ec1490b092c6475dce 100644 --- a/src/knot/conf/logconf.h +++ b/src/knot/conf/logconf.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_LOGCONF_H_ -#define _KNOT_LOGCONF_H_ +#ifndef _KNOTDLOGCONF_H_ +#define _KNOTDLOGCONF_H_ struct conf_t; @@ -19,12 +19,12 @@ struct conf_t; * * \see syslog.h * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. - * \retval KNOT_ENOMEM out of memory error. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. + * \retval KNOTDENOMEM out of memory error. */ int log_conf_hook(const struct conf_t *conf, void *data); -#endif /* _KNOT_LOGCONF_H_ */ +#endif /* _KNOTDLOGCONF_H_ */ /*! @} */ diff --git a/src/knot/ctl/knotc_main.c b/src/knot/ctl/knotc_main.c index f045c529e26d60a99ad7cd12e305a035e0b8b2fe..e580986b44c829479fb3e49e5e5d133c90ac3c7a 100644 --- a/src/knot/ctl/knotc_main.c +++ b/src/knot/ctl/knotc_main.c @@ -50,8 +50,8 @@ void help(int argc, char **argv) * \param db Path to zone db file. * \param source Path to zone source file. * - * \retval KNOT_EOK if up to date. - * \retval KNOT_ERROR if needs recompilation. + * \retval KNOTDEOK if up to date. + * \retval KNOTDERROR if needs recompilation. */ int check_zone(const char *db, const char* source) { @@ -59,14 +59,14 @@ int check_zone(const char *db, const char* source) /* Read zonedb header. */ zloader_t *zl = knot_zload_open(db); if (!zl) { - return KNOT_ERROR; + return KNOTDERROR; } /* Check source files and mtime. */ - int ret = KNOT_ERROR; + int ret = KNOTDERROR; int src_changed = strcmp(source, zl->source) != 0; if (!src_changed && !knot_zload_needs_update(zl)) { - ret = KNOT_EOK; + ret = KNOTDEOK; } knot_zload_close(zl); @@ -277,7 +277,7 @@ int execute(const char *action, char **argv, int argc, pid_t pid, int verbose, conf_zone_t *zone = (conf_zone_t*)n; // Check source files and mtime - if (check_zone(zone->db, zone->file) == KNOT_EOK) { + if (check_zone(zone->db, zone->file) == KNOTDEOK) { printf("Zone '%s' is up-to-date.\n", zone->name); diff --git a/src/knot/ctl/process.c b/src/knot/ctl/process.c index 0908cf0023d9775455aa8714114386e87414dca0..3ad60d1dabcc516cd18e593d7161ebda1711c073 100644 --- a/src/knot/ctl/process.c +++ b/src/knot/ctl/process.c @@ -33,7 +33,7 @@ pid_t pid_read(const char* fn) if (fn) { FILE *fp = fopen(fn, "r"); if (!fp) { - return KNOT_ENOENT; + return KNOTDENOENT; } int readb = 0; @@ -49,26 +49,26 @@ pid_t pid_read(const char* fn) // Check read result if (readb < 1) { - return KNOT_ENOENT; + return KNOTDENOENT; } // Convert pid char* ep = 0; unsigned long pid = strtoul(buf, &ep, 10); if ((errno == ERANGE) || (*ep && !isspace(*ep))) { - return KNOT_ERANGE; + return KNOTDERANGE; } return (pid_t)pid; } - return KNOT_EINVAL; + return KNOTDEINVAL; } int pid_write(const char* fn) { if (!fn) { - return KNOT_EINVAL; + return KNOTDEINVAL; } // Convert @@ -76,7 +76,7 @@ int pid_write(const char* fn) int wbytes = 0; wbytes = snprintf(buf, sizeof(buf), "%lu", (unsigned long) getpid()); if (wbytes < 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } // Write @@ -85,22 +85,22 @@ int pid_write(const char* fn) int rc = fwrite(buf, wbytes, 1, fp); fclose(fp); if (rc < 0) { - return KNOT_ERROR; + return KNOTDERROR; } return 0; } - return KNOT_ENOENT; + return KNOTDENOENT; } int pid_remove(const char* fn) { if (unlink(fn) < 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } - return KNOT_EOK; + return KNOTDEOK; } int pid_running(pid_t pid) diff --git a/src/knot/ctl/process.h b/src/knot/ctl/process.h index 1e7b69257a70739700ceaf0eff2654216369be2c..f4b5cd51667e1665fe9c9d7f1f82ee0269dd2df0 100644 --- a/src/knot/ctl/process.h +++ b/src/knot/ctl/process.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_PROCESS_H_ -#define _KNOT_PROCESS_H_ +#ifndef _KNOTDPROCESS_H_ +#define _KNOTDPROCESS_H_ #include <unistd.h> @@ -28,9 +28,9 @@ char* pid_filename(); * \param fn Filename containing PID. * * \retval PID on success (positive integer). - * \retval KNOT_EINVAL on null path. - * \retval KNOT_ENOENT if the filename content cannot be read. - * \retval KNOT_ERANGE if the stored PID is out of range. + * \retval KNOTDEINVAL on null path. + * \retval KNOTDENOENT if the filename content cannot be read. + * \retval KNOTDERANGE if the stored PID is out of range. */ pid_t pid_read(const char* fn); @@ -39,10 +39,10 @@ pid_t pid_read(const char* fn); * * \param fn Filename containing PID. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on null path. - * \retval KNOT_ENOENT filename cannot be opened for writing. - * \retval KNOT_ERROR unspecified error. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on null path. + * \retval KNOTDENOENT filename cannot be opened for writing. + * \retval KNOTDERROR unspecified error. */ int pid_write(const char* fn); @@ -53,8 +53,8 @@ int pid_write(const char* fn); * * \warning Filename content won't be checked. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL failed to remove filename. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL failed to remove filename. */ int pid_remove(const char* fn); @@ -68,6 +68,6 @@ int pid_remove(const char* fn); */ int pid_running(pid_t pid); -#endif // _KNOT_PROCESS_H_ +#endif // _KNOTDPROCESS_H_ /*! @} */ diff --git a/src/knot/main.c b/src/knot/main.c index fcfb12a4ecb2caf8406eec067077db2409eba3e8..0bb76564528e5142d8d1b7716e5d42553f3f770e 100644 --- a/src/knot/main.c +++ b/src/knot/main.c @@ -151,7 +151,7 @@ int main(int argc, char **argv) // Open configuration log_server_info("Parsing configuration '%s' ...\n", config_fn); - if (conf_open(config_fn) != KNOT_EOK) { + if (conf_open(config_fn) != KNOTDEOK) { log_server_error("Failed to parse configuration file '%s'.\n", config_fn); @@ -177,7 +177,7 @@ int main(int argc, char **argv) // Run server int res = 0; log_server_info("Starting server...\n"); - if ((res = server_start(server)) == KNOT_EOK) { + if ((res = server_start(server)) == KNOTDEOK) { // Save PID int rc = pid_write(pidfile); @@ -227,11 +227,11 @@ int main(int argc, char **argv) sig_req_reload = 0; int cf_ret = cf_ret = conf_open(config_fn); switch (cf_ret) { - case KNOT_EOK: + case KNOTDEOK: log_server_info("Configuration " "reloaded.\n"); break; - case KNOT_ENOENT: + case KNOTDENOENT: log_server_error("Configuration " "file '%s' " "not found.\n", @@ -257,7 +257,7 @@ int main(int argc, char **argv) } } - if ((res = server_wait(server)) != KNOT_EOK) { + if ((res = server_wait(server)) != KNOTDEOK) { log_server_error("An error occured while " "waiting for server to finish.\n"); } else { diff --git a/src/knot/other/debug.h b/src/knot/other/debug.h index cff353d09624b06fff7e41216ac9e0d7767070a2..2b5f5ee56debe769ee7e833943da1a87ba0868c7 100644 --- a/src/knot/other/debug.h +++ b/src/knot/other/debug.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_DEBUG_H_ -#define _KNOT_DEBUG_H_ +#ifndef _KNOTDDEBUG_H_ +#define _KNOTDDEBUG_H_ #include "knot/other/log.h" #include "common/print.h" @@ -93,6 +93,6 @@ #define DEBUG_XFR(cmds) #endif -#endif /* _KNOT_DEBUG_H_ */ +#endif /* _KNOTDDEBUG_H_ */ /*! @} */ diff --git a/src/knot/other/error.c b/src/knot/other/error.c index 18979db04f7ae539b7be8157df43918f8eb1cf1c..ec2f342f642aa47e172230c4281ba0cc0c50c2d2 100644 --- a/src/knot/other/error.c +++ b/src/knot/other/error.c @@ -4,26 +4,26 @@ const error_table_t knot_error_msgs[] = { /* Mapped errors. */ - {KNOT_EOK, "OK"}, - {KNOT_ENOMEM, "Not enough memory."}, - {KNOT_EINVAL, "Invalid parameter passed."}, - {KNOT_ENOTSUP, "Parameter not supported."}, - {KNOT_EBUSY, "Requested resource is busy."}, - {KNOT_EAGAIN, "The system lacked the necessary resource, try again."}, - {KNOT_EACCES, "Permission to perform requested operation is denied."}, - {KNOT_ECONNREFUSED, "Connection is refused."}, - {KNOT_EISCONN, "Already connected."}, - {KNOT_EADDRINUSE, "Address already in use."}, - {KNOT_ENOENT, "Resource not found."}, - {KNOT_ERANGE, "Value is out of range."}, + {KNOTDEOK, "OK"}, + {KNOTDENOMEM, "Not enough memory."}, + {KNOTDEINVAL, "Invalid parameter passed."}, + {KNOTDENOTSUP, "Parameter not supported."}, + {KNOTDEBUSY, "Requested resource is busy."}, + {KNOTDEAGAIN, "The system lacked the necessary resource, try again."}, + {KNOTDEACCES, "Permission to perform requested operation is denied."}, + {KNOTDECONNREFUSED, "Connection is refused."}, + {KNOTDEISCONN, "Already connected."}, + {KNOTDEADDRINUSE, "Address already in use."}, + {KNOTDENOENT, "Resource not found."}, + {KNOTDERANGE, "Value is out of range."}, /* Custom errors. */ - {KNOT_ERROR, "Generic error."}, - {KNOT_EZONEINVAL, "Invalid zone file."}, - {KNOT_ENOTRUNNING, "Resource is not running."}, - {KNOT_EPARSEFAIL, "Parser failed."}, - {KNOT_ENOIPV6, "IPv6 support disabled."}, - {KNOT_EMALF, "Malformed data."}, - {KNOT_ESPACE, "Not enough space provided."}, - {KNOT_ERROR, 0} + {KNOTDERROR, "Generic error."}, + {KNOTDEZONEINVAL, "Invalid zone file."}, + {KNOTDENOTRUNNING, "Resource is not running."}, + {KNOTDEPARSEFAIL, "Parser failed."}, + {KNOTDENOIPV6, "IPv6 support disabled."}, + {KNOTDEMALF, "Malformed data."}, + {KNOTDESPACE, "Not enough space provided."}, + {KNOTDERROR, 0} }; diff --git a/src/knot/other/error.h b/src/knot/other/error.h index a34b7fb8fc60fe950b980b59b723c7a40ec0a7a0..52c763df79c6027ba98db3ce429f288b9c977a97 100644 --- a/src/knot/other/error.h +++ b/src/knot/other/error.h @@ -10,8 +10,8 @@ * @{ */ -#ifndef _KNOT_ERROR_H_ -#define _KNOT_ERROR_H_ +#ifndef _KNOTDERROR_H_ +#define _KNOTDERROR_H_ #include <errno.h> @@ -26,33 +26,33 @@ enum knot_error_t { /* Directly mapped error codes. */ - KNOT_EOK = 0, - KNOT_ENOMEM = -ENOMEM, /*!< \brief Out of memory. */ - KNOT_EINVAL = -EINVAL, /*!< \brief Invalid parameter passed. */ - KNOT_ENOTSUP = -ENOTSUP, /*!< \brief Parameter not supported. */ - KNOT_EBUSY = -EBUSY, /*!< \brief Requested resource is busy. */ - KNOT_EAGAIN = -EAGAIN, /*!< \brief OS lacked necessary resources. */ - KNOT_EACCES = -EACCES, /*!< \brief Permission is denied. */ - KNOT_ECONNREFUSED = -ECONNREFUSED, /*!< \brief Connection is refused. */ - KNOT_EISCONN = -EISCONN, /*!< \brief Already connected. */ - KNOT_EADDRINUSE = -EADDRINUSE, /*!< \brief Address already in use. */ - KNOT_ENOENT = -ENOENT, /*!< \brief Resource not found. */ - KNOT_ERANGE = -ERANGE, /*!< \brief Value is out of range. */ + KNOTDEOK = 0, + KNOTDENOMEM = -ENOMEM, /*!< \brief Out of memory. */ + KNOTDEINVAL = -EINVAL, /*!< \brief Invalid parameter passed. */ + KNOTDENOTSUP = -ENOTSUP, /*!< \brief Parameter not supported. */ + KNOTDEBUSY = -EBUSY, /*!< \brief Requested resource is busy. */ + KNOTDEAGAIN = -EAGAIN, /*!< \brief OS lacked necessary resources. */ + KNOTDEACCES = -EACCES, /*!< \brief Permission is denied. */ + KNOTDECONNREFUSED = -ECONNREFUSED, /*!< \brief Connection is refused. */ + KNOTDEISCONN = -EISCONN, /*!< \brief Already connected. */ + KNOTDEADDRINUSE = -EADDRINUSE, /*!< \brief Address already in use. */ + KNOTDENOENT = -ENOENT, /*!< \brief Resource not found. */ + KNOTDERANGE = -ERANGE, /*!< \brief Value is out of range. */ /* Custom error codes. */ - KNOT_ERROR = -16384, /*!< \brief Generic error. */ - KNOT_EZONEINVAL, /*!< \brief Invalid zone file. */ - KNOT_ENOTRUNNING, /*!< \brief Resource is not running. */ - KNOT_EPARSEFAIL, /*!< \brief Parser fail. */ - KNOT_ENOIPV6, /*!< \brief No IPv6 support. */ - KNOT_EMALF, /*!< \brief Malformed data. */ - KNOT_ESPACE, /*!< \brief Not enough space provided. */ + KNOTDERROR = -16384, /*!< \brief Generic error. */ + KNOTDEZONEINVAL, /*!< \brief Invalid zone file. */ + KNOTDENOTRUNNING, /*!< \brief Resource is not running. */ + KNOTDEPARSEFAIL, /*!< \brief Parser fail. */ + KNOTDENOIPV6, /*!< \brief No IPv6 support. */ + KNOTDEMALF, /*!< \brief Malformed data. */ + KNOTDESPACE, /*!< \brief Not enough space provided. */ - KNOT_ERROR_COUNT = 20 + KNOTDERROR_COUNT = 20 }; /*! \brief Table linking error messages to error codes. */ -extern const error_table_t knot_error_msgs[KNOT_ERROR_COUNT]; +extern const error_table_t knot_error_msgs[KNOTDERROR_COUNT]; /*! * \brief Returns error message for the given error code. @@ -76,8 +76,8 @@ static inline const char *knot_strerror(int code) * * \return Mapped error code. */ -#define knot_map_errno(err...) map_errno(KNOT_ERROR, err); +#define knot_map_errno(err...) map_errno(KNOTDERROR, err); -#endif /* _KNOT_ERROR_H_ */ +#endif /* _KNOTDERROR_H_ */ /*! @} */ diff --git a/src/knot/other/log.c b/src/knot/other/log.c index f98958e38745ecd23b36d6c3320316424323dee2..0494e2733566aa5bc5e644c217e75bf4823f613c 100644 --- a/src/knot/other/log.c +++ b/src/knot/other/log.c @@ -24,7 +24,7 @@ int log_setup(int logfiles) { /* Check facilities count. */ if (logfiles < 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Ensure minimum facilities count. */ @@ -38,7 +38,7 @@ int log_setup(int logfiles) LOG_FCL_SIZE = 0; LOG_FCL = malloc(new_size); if (!LOG_FCL) { - return KNOT_ENOMEM; + return KNOTDENOMEM; } /* Reserve space for logfiles. */ @@ -47,14 +47,14 @@ int log_setup(int logfiles) if (!LOG_FDS) { free(LOG_FCL); LOG_FCL = 0; - return KNOT_ENOMEM; + return KNOTDENOMEM; } memset(LOG_FDS, 0, sizeof(FILE*) * logfiles); } memset(LOG_FCL, 0, new_size); LOG_FCL_SIZE = new_size; // Assign only when all is set - return KNOT_EOK; + return KNOTDEOK; } @@ -68,7 +68,7 @@ int log_init() LOG_FDS_OPEN = 0; /* Setup initial state. */ - int ret = KNOT_EOK; + int ret = KNOTDEOK; int emask = LOG_MASK(LOG_WARNING)|LOG_MASK(LOG_ERR)|LOG_MASK(LOG_FATAL); int imask = LOG_MASK(LOG_INFO)|LOG_MASK(LOG_NOTICE); @@ -121,13 +121,13 @@ int log_open_file(const char* filename) { // Check facility if (unlikely(!LOG_FCL_SIZE || LOGT_FILE + LOG_FDS_OPEN >= LOG_FCL_SIZE)) { - return KNOT_ERROR; + return KNOTDERROR; } // Open file LOG_FDS[LOG_FDS_OPEN] = fopen(filename, "w"); if (!LOG_FDS[LOG_FDS_OPEN]) { - return KNOT_EINVAL; + return KNOTDEINVAL; } // Disable buffering @@ -150,7 +150,7 @@ int log_levels_set(int facility, logsrc_t src, uint8_t levels) { // Check facility if (unlikely(!LOG_FCL_SIZE || facility >= LOG_FCL_SIZE)) { - return KNOT_EINVAL; + return KNOTDEINVAL; } // Get facility pointer from offset @@ -166,7 +166,7 @@ int log_levels_set(int facility, logsrc_t src, uint8_t levels) } } - return KNOT_EOK; + return KNOTDEOK; } int log_levels_add(int facility, logsrc_t src, uint8_t levels) @@ -178,7 +178,7 @@ int log_levels_add(int facility, logsrc_t src, uint8_t levels) static int _log_msg(logsrc_t src, int level, const char *msg) { if(!log_isopen()) { - return KNOT_ERROR; + return KNOTDERROR; } int ret = 0; @@ -217,7 +217,7 @@ static int _log_msg(logsrc_t src, int level, const char *msg) } if (ret < 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } return ret; diff --git a/src/knot/other/log.h b/src/knot/other/log.h index 5f66df1ac5c9d4ed203ab53fb16ad1b15ee32e6d..1d7770a61417320414604f041aa3dc969f7a3fbc 100644 --- a/src/knot/other/log.h +++ b/src/knot/other/log.h @@ -15,8 +15,8 @@ * @{ */ -#ifndef _KNOT_LOG_H_ -#define _KNOT_LOG_H_ +#ifndef _KNOTDLOG_H_ +#define _KNOTDLOG_H_ /* */ @@ -58,8 +58,8 @@ typedef enum { * * \param logfiles Number of extra logfiles. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL invalid number of logfiles (negative). + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL invalid number of logfiles (negative). */ int log_setup(int logfiles); @@ -68,8 +68,8 @@ int log_setup(int logfiles); * * \see syslog.h * - * \retval KNOT_EOK on success. - * \retval KNOT_ENOMEM out of memory error. + * \retval KNOTDEOK on success. + * \retval KNOTDENOMEM out of memory error. */ int log_init(); @@ -97,8 +97,8 @@ int log_isopen(); * \param filename File path. * * \retval associated facility index on success. - * \retval KNOT_EINVAL filename cannot be opened for writing. - * \retval KNOT_ERROR unspecified error. + * \retval KNOTDEINVAL filename cannot be opened for writing. + * \retval KNOTDERROR unspecified error. */ int log_open_file(const char* filename); @@ -120,8 +120,8 @@ uint8_t log_levels(int facility, logsrc_t src); * \param src Logging source (LOG_SERVER...LOG_ANY). * \param levels Bitmask of specified log levels. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL invalid parameters (facility out of range). + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL invalid parameters (facility out of range). */ int log_levels_set(int facility, logsrc_t src, uint8_t levels); @@ -135,8 +135,8 @@ int log_levels_set(int facility, logsrc_t src, uint8_t levels); * \param src Logging source (LOG_SERVER...LOG_ANY). * \param levels Bitmask of specified log levels. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL invalid parameters (facility out of range). + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL invalid parameters (facility out of range). */ int log_levels_add(int facility, logsrc_t src, uint8_t levels); @@ -151,8 +151,8 @@ int log_levels_add(int facility, logsrc_t src, uint8_t levels); * * \retval Number of logged bytes on success. * \retval 0 When the message is ignored. - * \retval KNOT_EINVAL invalid parameters. - * \retval KNOT_ERROR unspecified error. + * \retval KNOTDEINVAL invalid parameters. + * \retval KNOTDERROR unspecified error. */ int log_msg(logsrc_t src, int level, const char *msg, ...) __attribute__((format(printf, 3, 4))); @@ -188,6 +188,6 @@ void hex_log(int source, const char *data, int length); #define log_zone_info(msg...) log_msg(LOG_ZONE, LOG_INFO, msg) #define log_zone_debug(msg...) log_msg(LOG_ZONE, LOG_DEBUG, msg) -#endif /* _KNOT_LOG_H_ */ +#endif /* _KNOTDLOG_H_ */ /*! @} */ diff --git a/src/knot/server/dthreads.c b/src/knot/server/dthreads.c index 9b762358ef1ef31bc291a70791dd5571a6a6f4ee..b9a365470afea8f23e9ea895684a9f06f73f0d9a 100644 --- a/src/knot/server/dthreads.c +++ b/src/knot/server/dthreads.c @@ -41,13 +41,13 @@ static inline int dt_update_thread(dthread_t *thread, int state) { // Check if (thread == 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } // Cancel with lone thread dt_unit_t *unit = thread->unit; if (unit == 0) { - return KNOT_ENOTSUP; + return KNOTDENOTSUP; } // Cancel current runnable if running @@ -67,10 +67,10 @@ static inline int dt_update_thread(dthread_t *thread, int state) /* Unable to update thread, it is already dead. */ unlock_thread_rw(thread); pthread_mutex_unlock(&unit->_notify_mx); - return KNOT_EINVAL; + return KNOTDEINVAL; } - return KNOT_EOK; + return KNOTDEOK; } /*! @@ -408,7 +408,7 @@ int dt_resize(dt_unit_t *unit, int size) { // Check input if (unit == 0 || size <= 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } // Evaluate delta @@ -462,7 +462,7 @@ int dt_resize(dt_unit_t *unit, int size) // New threads vector dthread_t **threads = malloc(size * sizeof(dthread_t *)); if (threads == 0) { - return KNOT_ENOMEM; + return KNOTDENOMEM; } // Lock unit @@ -577,7 +577,7 @@ int dt_start(dt_unit_t *unit) { // Check input if (unit == 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } // Lock unit @@ -609,7 +609,7 @@ int dt_start_id(dthread_t *thread) { // Check input if (thread == 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } lock_thread_rw(thread); @@ -645,29 +645,29 @@ int dt_signalize(dthread_t *thread, int signum) { // Check input if (thread == 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } int ret = pthread_kill(thread->_thr, signum); /* Not thread id found or invalid signum. */ if (ret == EINVAL || ret == ESRCH) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Generic error. */ if (ret < 0) { - return KNOT_ERROR; + return KNOTDERROR; } - return KNOT_EOK; + return KNOTDEOK; } int dt_join(dt_unit_t *unit) { // Check input if (unit == 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } for (;;) { @@ -715,14 +715,14 @@ int dt_join(dt_unit_t *unit) pthread_mutex_unlock(&unit->_report_mx); } - return KNOT_EOK; + return KNOTDEOK; } int dt_stop_id(dthread_t *thread) { // Check input if (thread == 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } // Signalize active thread to stop @@ -741,14 +741,14 @@ int dt_stop_id(dthread_t *thread) pthread_mutex_unlock(&unit->_notify_mx); } - return KNOT_EOK; + return KNOTDEOK; } int dt_stop(dt_unit_t *unit) { // Check unit if (unit == 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } // Lock unit @@ -777,14 +777,14 @@ int dt_stop(dt_unit_t *unit) pthread_cond_broadcast(&unit->_notify); pthread_mutex_unlock(&unit->_notify_mx); - return KNOT_EOK; + return KNOTDEOK; } int dt_setprio(dthread_t *thread, int prio) { // Check input if (thread == 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } // Clamp priority @@ -809,20 +809,20 @@ int dt_setprio(dthread_t *thread, int prio) /* Map "not supported". */ if (ret == ENOTSUP) { - return KNOT_ENOTSUP; + return KNOTDENOTSUP; } - return KNOT_EINVAL; + return KNOTDEINVAL; } - return KNOT_EOK; + return KNOTDEOK; } int dt_repurpose(dthread_t *thread, runnable_t runnable, void *data) { // Check if (thread == 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } // Stop here if thread isn't a member of a unit @@ -831,7 +831,7 @@ int dt_repurpose(dthread_t *thread, runnable_t runnable, void *data) lock_thread_rw(thread); thread->state = ThreadActive | ThreadCancelled; unlock_thread_rw(thread); - return KNOT_ENOTSUP; + return KNOTDENOTSUP; } // Lock thread state changes @@ -857,7 +857,7 @@ int dt_repurpose(dthread_t *thread, runnable_t runnable, void *data) pthread_mutex_unlock(&unit->_notify_mx); } - return KNOT_EOK; + return KNOTDEOK; } int dt_activate(dthread_t *thread) @@ -874,7 +874,7 @@ int dt_compact(dt_unit_t *unit) { // Check input if (unit == 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } // Lock unit @@ -922,7 +922,7 @@ int dt_compact(dt_unit_t *unit) // Unlock unit dt_unit_unlock(unit); - return KNOT_EOK; + return KNOTDEOK; } int dt_optimal_size() @@ -959,7 +959,7 @@ int dt_unit_lock(dt_unit_t *unit) { // Check input if (unit == 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } int ret = pthread_mutex_lock(&unit->_mx); @@ -969,14 +969,14 @@ int dt_unit_lock(dt_unit_t *unit) return knot_map_errno(EINVAL, EAGAIN); } - return KNOT_EOK; + return KNOTDEOK; } int dt_unit_unlock(dt_unit_t *unit) { // Check input if (unit == 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } int ret = pthread_mutex_unlock(&unit->_mx); @@ -986,5 +986,5 @@ int dt_unit_unlock(dt_unit_t *unit) return knot_map_errno(EINVAL, EAGAIN); } - return KNOT_EOK; + return KNOTDEOK; } diff --git a/src/knot/server/dthreads.h b/src/knot/server/dthreads.h index 89e7210031af900b16c6a4288c405baa7a9bc80f..720f1f770cb197ff011386281610acfd8fd50ae5 100644 --- a/src/knot/server/dthreads.h +++ b/src/knot/server/dthreads.h @@ -21,8 +21,8 @@ * @{ */ -#ifndef _KNOT_DTHREADS_H_ -#define _KNOT_DTHREADS_H_ +#ifndef _KNOTDDTHREADS_H_ +#define _KNOTDDTHREADS_H_ #include <pthread.h> @@ -141,9 +141,9 @@ void dt_delete(dt_unit_t **unit); * \param unit Unit to be resized. * \param size New unit size. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. - * \retval KNOT_ENOMEM out of memory error. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. + * \retval KNOTDENOMEM out of memory error. */ int dt_resize(dt_unit_t *unit, int size); @@ -152,8 +152,8 @@ int dt_resize(dt_unit_t *unit, int size); * * \param unit Unit to be started. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters (unit is null). + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters (unit is null). */ int dt_start(dt_unit_t *unit); @@ -162,8 +162,8 @@ int dt_start(dt_unit_t *unit); * * \param thread Target thread instance. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. */ int dt_start_id(dthread_t *thread); @@ -177,9 +177,9 @@ int dt_start_id(dthread_t *thread); * \param thread Target thread instance. * \param signum Signal code. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. - * \retval KNOT_ERROR unspecified error. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. + * \retval KNOTDERROR unspecified error. */ int dt_signalize(dthread_t *thread, int signum); @@ -188,8 +188,8 @@ int dt_signalize(dthread_t *thread, int signum); * * \param unit Unit to be joined. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. */ int dt_join(dt_unit_t *unit); @@ -200,8 +200,8 @@ int dt_join(dt_unit_t *unit); * * \param thread Target thread instance. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. */ int dt_stop_id(dthread_t *thread); @@ -212,8 +212,8 @@ int dt_stop_id(dthread_t *thread); * * \param unit Unit to be stopped. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. */ int dt_stop(dt_unit_t *unit); @@ -223,8 +223,8 @@ int dt_stop(dt_unit_t *unit); * \param thread Target thread instance. * \param prio Requested priority (positive integer, default is 0). * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. */ int dt_setprio(dthread_t *thread, int prio); @@ -235,9 +235,9 @@ int dt_setprio(dthread_t *thread, int prio); * \param runnable Runnable function for target thread. * \param data Data passed to target thread. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. - * \retval KNOT_ENOTSUP operation not supported. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. + * \retval KNOTDENOTSUP operation not supported. */ int dt_repurpose(dthread_t *thread, runnable_t runnable, void *data); @@ -252,9 +252,9 @@ int dt_repurpose(dthread_t *thread, runnable_t runnable, void *data); * * \param thread Target thread instance. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. - * \retval KNOT_ENOTSUP operation not supported. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. + * \retval KNOTDENOTSUP operation not supported. */ int dt_activate(dthread_t *thread); @@ -269,8 +269,8 @@ int dt_activate(dthread_t *thread); * * \param thread Target thread instance. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. */ int dt_cancel(dthread_t *thread); @@ -279,8 +279,8 @@ int dt_cancel(dthread_t *thread); * * \param unit Target unit instance. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. */ int dt_compact(dt_unit_t *unit); @@ -312,10 +312,10 @@ int dt_is_cancelled(dthread_t *thread); * * \param unit Target unit instance. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. - * \retval KNOT_EAGAIN lack of resources to lock unit, try again. - * \retval KNOT_ERROR unspecified error. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. + * \retval KNOTDEAGAIN lack of resources to lock unit, try again. + * \retval KNOTDERROR unspecified error. */ int dt_unit_lock(dt_unit_t *unit); @@ -326,13 +326,13 @@ int dt_unit_lock(dt_unit_t *unit); * * \param unit Target unit instance. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. - * \retval KNOT_EAGAIN lack of resources to unlock unit, try again. - * \retval KNOT_ERROR unspecified error. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. + * \retval KNOTDEAGAIN lack of resources to unlock unit, try again. + * \retval KNOTDERROR unspecified error. */ int dt_unit_unlock(dt_unit_t *unit); -#endif // _KNOT_DTHREADS_H_ +#endif // _KNOTDDTHREADS_H_ /*! @} */ diff --git a/src/knot/server/journal.c b/src/knot/server/journal.c index 096a931299ff04f221f8ad2ecf901863934a0ccb..de08bcd04bc0d3f075ba205c4518f8f31e0cacfb 100644 --- a/src/knot/server/journal.c +++ b/src/knot/server/journal.c @@ -33,7 +33,7 @@ int journal_create(const char *fn, uint16_t max_nodes) FILE *fp = fopen(fn, "w"); if (!fp) { debug_journal("journal: failed to create file '%s'\n", fn); - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Disable buffering. */ @@ -44,7 +44,7 @@ int journal_create(const char *fn, uint16_t max_nodes) if (!sfwrite(&max_nodes, sizeof(uint16_t), fp)) { fclose(fp); remove(fn); - return KNOT_ERROR; + return KNOTDERROR; } /* Create empty queue head + tail. */ @@ -52,12 +52,12 @@ int journal_create(const char *fn, uint16_t max_nodes) if (!sfwrite(&zval, sizeof(uint16_t), fp)) { fclose(fp); remove(fn); - return KNOT_ERROR; + return KNOTDERROR; } if (!sfwrite(&zval, sizeof(uint16_t), fp)) { fclose(fp); remove(fn); - return KNOT_ERROR; + return KNOTDERROR; } debug_journal("journal: creating free segment descriptor\n"); @@ -71,7 +71,7 @@ int journal_create(const char *fn, uint16_t max_nodes) if (!sfwrite(&jn, sizeof(journal_node_t), fp)) { fclose(fp); remove(fn); - return KNOT_ERROR; + return KNOTDERROR; } /* Create nodes. */ @@ -81,13 +81,13 @@ int journal_create(const char *fn, uint16_t max_nodes) if (!sfwrite(&jn, sizeof(journal_node_t), fp)) { fclose(fp); remove(fn); - return KNOT_ERROR; + return KNOTDERROR; } } /* Journal file created. */ debug_journal("journal: file '%s' initialized\n", fn); - return KNOT_EOK; + return KNOTDEOK; } journal_t* journal_open(const char *fn, int fslimit, uint16_t bflags) @@ -188,11 +188,11 @@ int journal_fetch(journal_t *journal, uint64_t id, if (cf(journal->nodes[i].id, id) == 0) { *dst = journal->nodes + i; - return KNOT_EOK; + return KNOTDEOK; } } - return KNOT_ENOENT; + return KNOTDENOENT; } int journal_read(journal_t *journal, uint64_t id, journal_cmp_t cf, char *dst) @@ -201,13 +201,13 @@ int journal_read(journal_t *journal, uint64_t id, journal_cmp_t cf, char *dst) if(journal_fetch(journal, id, cf, &n) != 0) { debug_journal("journal: failed to fetch node with id=%d\n", id); - return KNOT_ENOENT; + return KNOTDENOENT; } /* Check valid flag. */ if (n->flags != JOURNAL_VALID) { debug_journal("journal: node with id=%d is invalid\n", id); - return KNOT_EINVAL; + return KNOTDEINVAL; } debug_journal("journal: reading node with id=%d, data=<%u, %u>\n", @@ -219,10 +219,10 @@ int journal_read(journal_t *journal, uint64_t id, journal_cmp_t cf, char *dst) /* Read journal node content. */ int ret = fread(dst, n->len, 1, journal->fp); if (ret != 1) { - return KNOT_ERROR; + return KNOTDERROR; } - return KNOT_EOK; + return KNOTDEOK; } int journal_write(journal_t *journal, uint64_t id, const char *src, size_t size) @@ -278,14 +278,14 @@ int journal_write(journal_t *journal, uint64_t id, const char *src, size_t size) /* Check if it has been synced to disk. */ if (head->flags & JOURNAL_DIRTY) { - return KNOT_EAGAIN; + return KNOTDEAGAIN; } /* Write back evicted node. */ head->flags = JOURNAL_FREE; fseek(journal->fp, JOURNAL_HSIZE + (journal->qhead + 1) * node_len, SEEK_SET); if (!sfwrite(head, node_len, journal->fp)) { - return KNOT_ERROR; + return KNOTDERROR; } debug_journal("journal: * evicted node=%u, growing by +%u\n", @@ -296,7 +296,7 @@ int journal_write(journal_t *journal, uint64_t id, const char *src, size_t size) uint16_t qstate[2] = {journal->qhead, journal->qtail}; fseek(journal->fp, JOURNAL_HSIZE - 2 * sizeof(uint16_t), SEEK_SET); if (!sfwrite(qstate, 2 * sizeof(uint16_t), journal->fp)) { - return KNOT_ERROR; + return KNOTDERROR; } /* Increase free segment. */ @@ -313,7 +313,7 @@ int journal_write(journal_t *journal, uint64_t id, const char *src, size_t size) /* Write data to permanent storage. */ fseek(journal->fp, n->pos, SEEK_SET); if (!sfwrite(src, size, journal->fp)) { - return KNOT_ERROR; + return KNOTDERROR; } /* Mark node as valid and write back. */ @@ -350,7 +350,7 @@ int journal_write(journal_t *journal, uint64_t id, const char *src, size_t size) /*! \todo Node is marked valid and failed to shrink free space, node will be overwritten on the next open - this may be a problem, how to solve it properly? */ - return KNOT_ERROR; + return KNOTDERROR; } /* Write back query state, not essential as it may be recovered. @@ -360,7 +360,7 @@ int journal_write(journal_t *journal, uint64_t id, const char *src, size_t size) uint16_t qstate[2] = {journal->qhead, journal->qtail}; fseek(journal->fp, JOURNAL_HSIZE - 2 * sizeof(uint16_t), SEEK_SET); if (!sfwrite(qstate, 2 * sizeof(uint16_t), journal->fp)) { - return KNOT_ERROR; + return KNOTDERROR; } /*! \todo Delayed write-back? */ @@ -368,32 +368,32 @@ int journal_write(journal_t *journal, uint64_t id, const char *src, size_t size) debug_journal("journal: write finished, nqueue=<%u, %u>\n", journal->qhead, journal->qtail); - return KNOT_EOK; + return KNOTDEOK; } int journal_walk(journal_t *journal, journal_apply_t apply) { - int ret = KNOT_EOK; + int ret = KNOTDEOK; size_t i = journal->qhead; for(; i != journal->qtail; i = (i + 1) % journal->max_nodes) { /* Apply function. */ ret = apply(journal, journal->nodes + i); } - return KNOT_EOK; + return KNOTDEOK; } int journal_update(journal_t *journal, journal_node_t *n) { if (!journal || !n) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Calculate node offset. */ const size_t node_len = sizeof(journal_node_t); size_t i = n - journal->nodes; if (i > journal->max_nodes) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Calculate node position in permanent storage. */ @@ -407,17 +407,17 @@ int journal_update(journal_t *journal, journal_node_t *n) if (!sfwrite(n, node_len, journal->fp)) { debug_journal("journal: failed to writeback node=%d to %ld\n", n->id, jn_fpos); - return KNOT_ERROR; + return KNOTDERROR; } - return KNOT_EOK; + return KNOTDEOK; } int journal_close(journal_t *journal) { /* Check journal. */ if (!journal) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Close file. */ @@ -428,5 +428,5 @@ int journal_close(journal_t *journal) /* Free allocated resources. */ free(journal); - return KNOT_EOK; + return KNOTDEOK; } diff --git a/src/knot/server/journal.h b/src/knot/server/journal.h index c40736de2aa483bd186fc4c3a2d26bc73f41221f..9adb0838c366d7c0625c56ed4b9c159472e2783c 100644 --- a/src/knot/server/journal.h +++ b/src/knot/server/journal.h @@ -23,8 +23,8 @@ * @{ */ -#ifndef _KNOT_JOURNAL_H_ -#define _KNOT_JOURNAL_H_ +#ifndef _KNOTDJOURNAL_H_ +#define _KNOTDJOURNAL_H_ #include <stdint.h> @@ -105,9 +105,9 @@ typedef int (*journal_apply_t)(journal_t *j, journal_node_t *n); * \param fn Journal file name, will be created if not exist. * \param max_nodes Maximum number of nodes in journal. * - * \retval KNOT_EOK if successful. - * \retval KNOT_EINVAL if the file with given name cannot be created. - * \retval KNOT_ERROR on I/O error. + * \retval KNOTDEOK if successful. + * \retval KNOTDEINVAL if the file with given name cannot be created. + * \retval KNOTDERROR on I/O error. */ int journal_create(const char *fn, uint16_t max_nodes); @@ -131,8 +131,8 @@ journal_t* journal_open(const char *fn, int fslimit, uint16_t bflags); * \param cf Compare function (NULL for equality). * \param dst Destination for journal entry. * - * \retval KNOT_EOK if successful. - * \retval KNOT_ENOENT if not found. + * \retval KNOTDEOK if successful. + * \retval KNOTDENOENT if not found. */ int journal_fetch(journal_t *journal, uint64_t id, journal_cmp_t cf, journal_node_t** dst); @@ -145,10 +145,10 @@ int journal_fetch(journal_t *journal, uint64_t id, * \param cf Compare function (NULL for equality). * \param dst Pointer to destination memory. * - * \retval KNOT_EOK if successful. - * \retval KNOT_ENOENT if the entry cannot be found. - * \retval KNOT_EINVAL if the entry is invalid. - * \retval KNOT_ERROR on I/O error. + * \retval KNOTDEOK if successful. + * \retval KNOTDENOENT if the entry cannot be found. + * \retval KNOTDEINVAL if the entry is invalid. + * \retval KNOTDERROR on I/O error. */ int journal_read(journal_t *journal, uint64_t id, journal_cmp_t cf, char *dst); @@ -159,9 +159,9 @@ int journal_read(journal_t *journal, uint64_t id, journal_cmp_t cf, char *dst); * \param id Entry identifier. * \param src Pointer to source data. * - * \retval KNOT_EOK if successful. - * \retval KNOT_EAGAIN if no free node is available, need to remove dirty nodes. - * \retval KNOT_ERROR on I/O error. + * \retval KNOTDEOK if successful. + * \retval KNOTDEAGAIN if no free node is available, need to remove dirty nodes. + * \retval KNOTDERROR on I/O error. */ int journal_write(journal_t *journal, uint64_t id, const char *src, size_t size); @@ -195,8 +195,8 @@ static inline journal_node_t *journal_end(journal_t *journal) { * \param journal Associated journal. * \param apply Function to apply to each node. * - * \retval KNOT_EOK if successful. - * \retval KNOT_EINVAL on invalid parameters. + * \retval KNOTDEOK if successful. + * \retval KNOTDEINVAL on invalid parameters. */ int journal_walk(journal_t *journal, journal_apply_t apply); @@ -208,8 +208,8 @@ int journal_walk(journal_t *journal, journal_apply_t apply); * \param journal Associated journal. * \param n Pointer to node (must belong to associated journal). * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. */ int journal_update(journal_t *journal, journal_node_t *n); @@ -218,9 +218,9 @@ int journal_update(journal_t *journal, journal_node_t *n); * * \param journal Associated journal. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameter. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameter. */ int journal_close(journal_t *journal); -#endif /* _KNOT_JOURNAL_H_ */ +#endif /* _KNOTDJOURNAL_H_ */ diff --git a/src/knot/server/notify.c b/src/knot/server/notify.c index a49d477503295c89a162fcc248af8c53466fd5b9..f3d48fff70a3d67ac75e8c350c68ba52cd876064 100644 --- a/src/knot/server/notify.c +++ b/src/knot/server/notify.c @@ -25,20 +25,20 @@ static int notify_request(const knot_rrset_t *rrset, uint8_t *buffer, size_t *size) { - knot_packet_t *pkt = knot_packet_new(DNSLIB_PACKET_PREALLOC_QUERY); - CHECK_ALLOC_LOG(pkt, KNOT_ENOMEM); + knot_packet_t *pkt = knot_packet_new(KNOT_PACKET_PREALLOC_QUERY); + CHECK_ALLOC_LOG(pkt, KNOTDENOMEM); /*! \todo Get rid of the numeric constant. */ int rc = knot_packet_set_max_size(pkt, 512); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { knot_packet_free(&pkt); - return KNOT_ERROR; + return KNOTDERROR; } rc = knot_query_init(pkt); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { knot_packet_free(&pkt); - return KNOT_ERROR; + return KNOTDERROR; } knot_question_t question; @@ -49,9 +49,9 @@ static int notify_request(const knot_rrset_t *rrset, question.qclass = rrset->rclass; rc = knot_query_set_question(pkt, &question); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { knot_packet_free(&pkt); - return KNOT_ERROR; + return KNOTDERROR; } /*! \todo Set some random ID!! */ @@ -59,7 +59,7 @@ static int notify_request(const knot_rrset_t *rrset, /*! \todo add the SOA RR to the Answer section as a hint */ /*! \todo this should not use response API!! */ // rc = knot_response2_add_rrset_answer(pkt, rrset, 0, 0, 0); -// if (rc != DNSLIB_EOK) { +// if (rc != KNOT_EOK) { // knot_packet_free(&pkt); // return rc; // } @@ -67,21 +67,21 @@ static int notify_request(const knot_rrset_t *rrset, /*! \todo this should not use response API!! */ knot_response2_set_aa(pkt); - knot_query_set_opcode(pkt, DNSLIB_OPCODE_NOTIFY); + knot_query_set_opcode(pkt, KNOT_OPCODE_NOTIFY); /*! \todo OPT RR ?? */ uint8_t *wire = NULL; size_t wire_size = 0; rc = knot_packet_to_wire(pkt, &wire, &wire_size); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { knot_packet_free(&pkt); - return KNOT_ERROR; + return KNOTDERROR; } if (wire_size > *size) { knot_packet_free(&pkt); - return KNOT_ESPACE; + return KNOTDESPACE; } memcpy(buffer, wire, wire_size); @@ -91,7 +91,7 @@ static int notify_request(const knot_rrset_t *rrset, knot_packet_free(&pkt); - return KNOT_EOK; + return KNOTDEOK; } /*----------------------------------------------------------------------------*/ @@ -100,8 +100,8 @@ int notify_create_response(knot_packet_t *request, uint8_t *buffer, size_t *size) { knot_packet_t *response = - knot_packet_new(DNSLIB_PACKET_PREALLOC_QUERY); - CHECK_ALLOC_LOG(response, KNOT_ENOMEM); + knot_packet_new(KNOT_PACKET_PREALLOC_QUERY); + CHECK_ALLOC_LOG(response, KNOTDENOMEM); knot_response2_init_from_query(response, request); @@ -110,14 +110,14 @@ int notify_create_response(knot_packet_t *request, uint8_t *buffer, uint8_t *wire = NULL; size_t wire_size = 0; int rc = knot_packet_to_wire(response, &wire, &wire_size); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { knot_packet_free(&response); return rc; } if (wire_size > *size) { knot_packet_free(&response); - return KNOT_ESPACE; + return KNOTDESPACE; } memcpy(buffer, wire, wire_size); @@ -127,7 +127,7 @@ int notify_create_response(knot_packet_t *request, uint8_t *buffer, knot_packet_free(&response); - return KNOT_EOK; + return KNOTDEOK; } /*----------------------------------------------------------------------------*/ @@ -138,9 +138,9 @@ int notify_create_request(const knot_zone_contents_t *zone, uint8_t *buffer, size_t *size) { const knot_rrset_t *soa_rrset = knot_node_rrset( - knot_zone_contents_apex(zone), DNSLIB_RRTYPE_SOA); + knot_zone_contents_apex(zone), KNOT_RRTYPE_SOA); if (soa_rrset == NULL) { - return KNOT_ERROR; + return KNOTDERROR; } return notify_request(soa_rrset, buffer, size); @@ -153,7 +153,7 @@ static int notify_check_and_schedule(const knot_nameserver_t *nameserver, sockaddr_t *from) { if (zone == NULL || from == NULL || knot_zone_data(zone) == NULL) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Check ACL for notify-in. */ @@ -166,7 +166,7 @@ static int notify_check_and_schedule(const knot_nameserver_t *nameserver, debug_notify("Unauthorized NOTIFY request " "from %s:%d.\n", straddr, sockaddr_portnum(from)); - return DNSLIB_ERROR; + return KNOT_ERROR; } else { debug_notify("notify: authorized NOTIFY query.\n"); } @@ -194,7 +194,7 @@ static int notify_check_and_schedule(const knot_nameserver_t *nameserver, evsched_schedule(sched, refresh_ev, 0); } - return KNOT_EOK; + return KNOTDEOK; } /*----------------------------------------------------------------------------*/ @@ -210,22 +210,22 @@ int notify_process_request(const knot_nameserver_t *nameserver, if (notify == NULL || nameserver == NULL || buffer == NULL || size == NULL || from == NULL) { - return KNOT_EINVAL; + return KNOTDEINVAL; } int ret; if (notify->parsed < notify->size) { ret = knot_packet_parse_rest(notify); - if (ret != DNSLIB_EOK) { - return KNOT_EMALF; + if (ret != KNOT_EOK) { + return KNOTDEMALF; } } // create NOTIFY response ret = notify_create_response(notify, buffer, size); - if (ret != KNOT_EOK) { - return KNOT_ERROR; /*! \todo Some other error. */ + if (ret != KNOTDEOK) { + return KNOTDERROR; /*! \todo Some other error. */ } // find the zone @@ -233,12 +233,12 @@ int notify_process_request(const knot_nameserver_t *nameserver, const knot_zone_t *z = knot_zonedb_find_zone_for_name( nameserver->zone_db, qname); if (z == NULL) { - return KNOT_ERROR; /*! \todo Some other error. */ + return KNOTDERROR; /*! \todo Some other error. */ } notify_check_and_schedule(nameserver, z, from); - return KNOT_EOK; + return KNOTDEOK; } /*----------------------------------------------------------------------------*/ @@ -250,7 +250,7 @@ int notify_process_response(const knot_nameserver_t *nameserver, { if (nameserver == NULL || notify == NULL || from == NULL || buffer == NULL || size == NULL) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Assert no response size. */ @@ -261,10 +261,10 @@ int notify_process_response(const knot_nameserver_t *nameserver, knot_zone_t *zone = knot_zonedb_find_zone(nameserver->zone_db, zone_name); if (!zone) { - return KNOT_ENOENT; + return KNOTDENOENT; } if (!knot_zone_data(zone)) { - return KNOT_ENOENT; + return KNOTDENOENT; } /* Match ID against awaited. */ @@ -282,7 +282,7 @@ int notify_process_response(const knot_nameserver_t *nameserver, if (!match) { debug_notify("notify: no pending NOTIFY query found for ID=%u\n", pkt_id); - return KNOT_ERROR; + return KNOTDERROR; } /* Cancel RETRY timer, NOTIFY is now finished. */ @@ -298,6 +298,6 @@ int notify_process_response(const knot_nameserver_t *nameserver, debug_notify("notify: received response for pending NOTIFY query ID=%u\n", pkt_id); - return KNOT_EOK; + return KNOTDEOK; } diff --git a/src/knot/server/notify.h b/src/knot/server/notify.h index 0175902531bfe1fd77b4c285fda4627a244d178b..03fc1f0964cb556901480fa1ec6bef4a0226a1db 100644 --- a/src/knot/server/notify.h +++ b/src/knot/server/notify.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_NOTIFY_H_ -#define _KNOT_NOTIFY_H_ +#ifndef _KNOTDNOTIFY_H_ +#define _KNOTDNOTIFY_H_ #include <stdint.h> #include <string.h> @@ -44,9 +44,9 @@ typedef struct notify_ev_t { * \param size In: available space in the buffer. Out: actual size of the * message in bytes. * - * \retval KNOT_EOK - * \retval KNOT_ESPACE - * \retval KNOT_ERROR + * \retval KNOTDEOK + * \retval KNOTDESPACE + * \retval KNOTDERROR */ int notify_create_request(const knot_zone_contents_t *zone, uint8_t *buffer, size_t *size); @@ -64,9 +64,9 @@ int notify_create_request(const knot_zone_contents_t *zone, uint8_t *buffer, * \param rsize Input: maximum acceptable size of the response. Output: real * size of the response. * - * \retval KNOT_EOK if a valid response was created. - * \retval KNOT_EACCES sender is not authorized to request NOTIFY. - * \retval KNOT_EMALF if an error occured and the response is not valid. + * \retval KNOTDEOK if a valid response was created. + * \retval KNOTDEACCES sender is not authorized to request NOTIFY. + * \retval KNOTDEMALF if an error occured and the response is not valid. */ /*! * \brief Evaluates incoming NOTIFY request and produces a reply. @@ -79,10 +79,10 @@ int notify_create_request(const knot_zone_contents_t *zone, uint8_t *buffer, * \param size In: available space in the buffer. Out: actual size of the * response message in bytes. * - * \retval KNOT_EOK - * \retval KNOT_EINVAL - * \retval KNOT_EMALF - * \retval KNOT_ERROR + * \retval KNOTDEOK + * \retval KNOTDEINVAL + * \retval KNOTDEMALF + * \retval KNOTDERROR */ int notify_process_request(const knot_nameserver_t *nameserver, knot_packet_t *notify, @@ -99,15 +99,15 @@ int notify_process_request(const knot_nameserver_t *nameserver, * \param rsize Input: maximum acceptable size of the response. Output: real * size of the response. * - * \retval KNOT_EOK if a valid response was created. - * \retval KNOT_EINVAL on invalid parameters or packet. - * \retval KNOT_EMALF if an error occured and the response is not valid. + * \retval KNOTDEOK if a valid response was created. + * \retval KNOTDEINVAL on invalid parameters or packet. + * \retval KNOTDEMALF if an error occured and the response is not valid. */ int notify_process_response(const knot_nameserver_t *nameserver, knot_packet_t *notify, sockaddr_t *from, uint8_t *buffer, size_t *size); -#endif /* _KNOT_NOTIFY_H_ */ +#endif /* _KNOTDNOTIFY_H_ */ /*! @} */ diff --git a/src/knot/server/server.c b/src/knot/server/server.c index 3d21b0e832526783c20ac6f454d32bae185e2f21..b2f38a4faea3b2e3626268f5bafdf78361097a38 100644 --- a/src/knot/server/server.c +++ b/src/knot/server/server.c @@ -28,7 +28,7 @@ static int evsched_run(dthread_t *thread) iohandler_t *sched_h = (iohandler_t *)thread->data; evsched_t *s = (evsched_t*)sched_h->data; if (!s) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Run event loop. */ @@ -37,7 +37,7 @@ static int evsched_run(dthread_t *thread) /* Error. */ if (!ev) { - return KNOT_ERROR; + return KNOTDERROR; } /* Process termination event. */ @@ -59,7 +59,7 @@ static int evsched_run(dthread_t *thread) } } - return KNOT_EOK; + return KNOTDEOK; } /*! \brief List item for generic pointers. */ @@ -179,7 +179,7 @@ static int server_init_iface(iface_t *new_if, conf_iface_t *cfg_if) new_if->type[TCP_ID] = cfg_if->family; new_if->port = cfg_if->port; new_if->addr = strdup(cfg_if->address); - return KNOT_EOK; + return KNOTDEOK; } /*! @@ -301,7 +301,7 @@ static int server_bind_sockets(server_t *server) static int server_bind_handlers(server_t *server) { if (!server || !server->ifaces) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Estimate number of threads/manager. */ @@ -358,7 +358,7 @@ static int server_bind_handlers(server_t *server) /* Unlock config. */ conf_read_unlock(); - return KNOT_EOK; + return KNOTDEOK; } server_t *server_create() @@ -448,7 +448,7 @@ int server_remove_handler(server_t *server, iohandler_t *h) { // Check if (h == 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Lock RCU. */ @@ -492,14 +492,14 @@ int server_remove_handler(server_t *server, iohandler_t *h) // Destroy dispatcher and worker dt_delete(&h->unit); free(h); - return KNOT_EOK; + return KNOTDEOK; } int server_start(server_t *server) { // Check server if (server == 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } debug_server("Starting handlers...\n"); @@ -511,7 +511,7 @@ int server_start(server_t *server) conf_read_lock(); // Start dispatchers - int ret = KNOT_EOK; + int ret = KNOTDEOK; server->state |= ServerRunning; iohandler_t *h = 0; WALK_LIST(h, server->handlers) { @@ -648,15 +648,15 @@ int server_conf_hook(const struct conf_t *conf, void *data) server_t *server = (server_t *)data; if (!server) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Update bound sockets. */ - int ret = KNOT_EOK; + int ret = KNOTDEOK; if ((ret = server_bind_sockets(server)) < 0) { log_server_error("Failed to bind configured " "interfaces.\n"); - return KNOT_ERROR; + return KNOTDERROR; } /* Update handlers. */ @@ -668,7 +668,7 @@ int server_conf_hook(const struct conf_t *conf, void *data) /* Exit if the server is not running. */ if (!(server->state & ServerRunning)) { - return KNOT_ENOTRUNNING; + return KNOTDENOTRUNNING; } /* Lock configuration. */ diff --git a/src/knot/server/server.h b/src/knot/server/server.h index 85c4e53e2f3f34c5dab0904b1db86cbbf078d281..246440763069d2252ff3b9df474b75a086e85e14 100644 --- a/src/knot/server/server.h +++ b/src/knot/server/server.h @@ -18,8 +18,8 @@ * @{ */ -#ifndef _KNOT_SERVER_H_ -#define _KNOT_SERVER_H_ +#ifndef _KNOTDSERVER_H_ +#define _KNOTDSERVER_H_ #include "knot/common.h" #include "dnslib/name-server.h" @@ -137,8 +137,8 @@ iohandler_t *server_create_handler(server_t *server, int fd, dt_unit_t *unit); * \param server Server structure to be used for operation. * \param ref I/O handler instance. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. */ int server_remove_handler(server_t *server, iohandler_t *ref); @@ -147,8 +147,8 @@ int server_remove_handler(server_t *server, iohandler_t *ref); * * \param server Server structure to be used for operation. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. * * \todo When a module for configuration is added, the filename parameter will * be removed. @@ -184,13 +184,13 @@ void server_destroy(server_t **server); * * Routine for dynamic server reconfiguration. * - * \retval KNOT_EOK on success. - * \retval KNOT_ENOTRUNNING if the server is not running. - * \retval KNOT_EINVAL on invalid parameters. - * \retval KNOT_ERROR unspecified error. + * \retval KNOTDEOK on success. + * \retval KNOTDENOTRUNNING if the server is not running. + * \retval KNOTDEINVAL on invalid parameters. + * \retval KNOTDERROR unspecified error. */ int server_conf_hook(const struct conf_t *conf, void *data); -#endif // _KNOT_SERVER_H_ +#endif // _KNOTDSERVER_H_ /*! @} */ diff --git a/src/knot/server/socket.c b/src/knot/server/socket.c index 605982bda0ff42b1ad89b357578a7eb14b1645ed..ac9f51d4a22063e03f16d1ec912ab2c74537e5f0 100644 --- a/src/knot/server/socket.c +++ b/src/knot/server/socket.c @@ -34,12 +34,12 @@ int socket_connect(int fd, const char *addr, unsigned short port) } /* Resolve address. */ - int ret = KNOT_EOK; + int ret = KNOTDEOK; struct addrinfo hints, *res; hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; if ((ret = getaddrinfo(addr, NULL, &hints, &res)) != 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Evaluate address type. */ @@ -69,7 +69,7 @@ int socket_connect(int fd, const char *addr, unsigned short port) ECONNREFUSED, EISCONN); } } else { - ret = KNOT_EINVAL; + ret = KNOTDEINVAL; } @@ -94,7 +94,7 @@ int socket_bind(int socket, int family, const char *addr, unsigned short port) paddr = (struct sockaddr*)&saddr; addrlen = sizeof(saddr); if (getsockname(socket, paddr, &addrlen) < 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Set address and port. */ @@ -113,13 +113,13 @@ int socket_bind(int socket, int family, const char *addr, unsigned short port) #ifdef DISABLE_IPV6 log_server_error("ipv6 support disabled\n"); - return KNOT_ENOIPV6; + return KNOTDENOIPV6; #else /* Initialize socket address. */ paddr = (struct sockaddr*)&saddr6; addrlen = sizeof(saddr6); if (getsockname(socket, paddr, &addrlen) < 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Set address and port. */ @@ -141,7 +141,7 @@ int socket_bind(int socket, int family, const char *addr, unsigned short port) int ret = setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag)); if (ret < 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Bind to specified address. */ @@ -152,7 +152,7 @@ int socket_bind(int socket, int family, const char *addr, unsigned short port) return knot_map_errno(EADDRINUSE, EINVAL, EACCES, ENOMEM); } - return KNOT_EOK; + return KNOTDEOK; } int socket_listen(int socket, int backlog_size) @@ -162,15 +162,15 @@ int socket_listen(int socket, int backlog_size) return knot_map_errno(EADDRINUSE); } - return KNOT_EOK; + return KNOTDEOK; } int socket_close(int socket) { if (close(socket) < 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } - return KNOT_EOK; + return KNOTDEOK; } diff --git a/src/knot/server/socket.h b/src/knot/server/socket.h index f6765e722912c90a186deaf722fc19f8d61ed404..881b554cc0e5ea9d69f6715f60319a6c3ccfdd0c 100644 --- a/src/knot/server/socket.h +++ b/src/knot/server/socket.h @@ -15,8 +15,8 @@ * @{ */ -#ifndef _KNOT_SOCKET_H_ -#define _KNOT_SOCKET_H_ +#ifndef _KNOTDSOCKET_H_ +#define _KNOTDSOCKET_H_ /* POSIX only. */ #include <sys/socket.h> @@ -34,10 +34,10 @@ typedef enum { * \param type Socket type (SOCK_STREAM, SOCK_DGRAM, SOCK_RAW). * * \retval new socket filedescriptor on success. - * \retval KNOT_EINVAL on invalid parameters. - * \retval KNOT_ENOMEM out of memory error. - * \retval KNOT_EACCES process does not have appropriate privileges. - * \retval KNOT_ERROR unspecified error. + * \retval KNOTDEINVAL on invalid parameters. + * \retval KNOTDENOMEM out of memory error. + * \retval KNOTDEACCES process does not have appropriate privileges. + * \retval KNOTDERROR unspecified error. */ int socket_create(int family, int type); @@ -48,14 +48,14 @@ int socket_create(int family, int type); * \param addr Requested address. * \param port Requested port. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL invalid parameters. - * \retval KNOT_EACCES process does not have appropriate privileges. - * \retval KNOT_EAGAIN lack of resources, try again. - * \retval KNOT_EADDRINUSE address already in use. - * \retval KNOT_ECONNREFUSED connection refused. - * \retval KNOT_EISCONN already connected. - * \retval KNOT_ERROR unspecified error. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL invalid parameters. + * \retval KNOTDEACCES process does not have appropriate privileges. + * \retval KNOTDEAGAIN lack of resources, try again. + * \retval KNOTDEADDRINUSE address already in use. + * \retval KNOTDECONNREFUSED connection refused. + * \retval KNOTDEISCONN already connected. + * \retval KNOTDERROR unspecified error. */ int socket_connect(int fd, const char *addr, unsigned short port); @@ -67,13 +67,13 @@ int socket_connect(int fd, const char *addr, unsigned short port); * \param addr Requested address. * \param port Requested port. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL invalid parameters. - * \retval KNOT_EACCES process does not have appropriate privileges. - * \retval KNOT_EADDRINUSE address already in use. - * \retval KNOT_ENOMEM out of memory error. - * \retval KNOT_ENOIPV6 IPv6 support is not available. - * \retval KNOT_ERROR unspecified error. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL invalid parameters. + * \retval KNOTDEACCES process does not have appropriate privileges. + * \retval KNOTDEADDRINUSE address already in use. + * \retval KNOTDENOMEM out of memory error. + * \retval KNOTDENOIPV6 IPv6 support is not available. + * \retval KNOTDERROR unspecified error. */ int socket_bind(int fd, int family, const char *addr, unsigned short port); @@ -83,9 +83,9 @@ int socket_bind(int fd, int family, const char *addr, unsigned short port); * \param fd Socket filedescriptor. * \param backlog_size Requested TCP backlog size. * - * \retval KNOT_EOK on success. - * \retval KNOT_EADDRINUSE address already in use. - * \retval KNOT_ERROR unspecified error. + * \retval KNOTDEOK on success. + * \retval KNOTDEADDRINUSE address already in use. + * \retval KNOTDERROR unspecified error. */ int socket_listen(int fd, int backlog_size); @@ -94,12 +94,12 @@ int socket_listen(int fd, int backlog_size); * * \param fd Socket filedescriptor. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL invalid parameters. */ int socket_close(int fd); -#endif // _KNOT_SOCKET_H_ +#endif // _KNOTDSOCKET_H_ /*! @} */ diff --git a/src/knot/server/tcp-handler.c b/src/knot/server/tcp-handler.c index f41f664214f67a6d809a8e2614294c8b4826cb2a..c13100e519b0ad6eef5c60da829c932060e41e68 100644 --- a/src/knot/server/tcp-handler.c +++ b/src/knot/server/tcp-handler.c @@ -94,7 +94,7 @@ static void tcp_handle(struct ev_loop *loop, ev_io *w, int revents) /* Check address type. */ sockaddr_t addr; - if (sockaddr_init(&addr, tcp_w->io_h->type) != KNOT_EOK) { + if (sockaddr_init(&addr, tcp_w->io_h->type) != KNOTDEOK) { log_server_error("Socket type %d is not supported, " "IPv6 support is probably disabled.\n", tcp_w->io_h->type); @@ -116,19 +116,19 @@ static void tcp_handle(struct ev_loop *loop, ev_io *w, int revents) size_t resp_len = qbuf_maxlen; // 64K /* Parse query. */ - knot_packet_type_t qtype = DNSLIB_QUERY_NORMAL; + knot_packet_type_t qtype = KNOT_QUERY_NORMAL; knot_packet_t *packet = - knot_packet_new(DNSLIB_PACKET_PREALLOC_QUERY); + knot_packet_new(KNOT_PACKET_PREALLOC_QUERY); if (packet == NULL) { uint16_t pkt_id = knot_wire_get_id(qbuf); - knot_ns_error_response(ns, pkt_id, DNSLIB_RCODE_SERVFAIL, + knot_ns_error_response(ns, pkt_id, KNOT_RCODE_SERVFAIL, qbuf, &resp_len); return; } int res = knot_ns_parse_packet(qbuf, n, packet, &qtype); - if (unlikely(res != KNOT_EOK)) { + if (unlikely(res != KNOTDEOK)) { /* Send error response on dnslib RCODE. */ if (res > 0) { @@ -144,22 +144,22 @@ static void tcp_handle(struct ev_loop *loop, ev_io *w, int revents) /* Handle query. */ knot_ns_xfr_t xfr; - res = KNOT_ERROR; + res = KNOTDERROR; switch(qtype) { /* Response types. */ - case DNSLIB_RESPONSE_NORMAL: - case DNSLIB_RESPONSE_AXFR: - case DNSLIB_RESPONSE_IXFR: - case DNSLIB_RESPONSE_NOTIFY: + case KNOT_RESPONSE_NORMAL: + case KNOT_RESPONSE_AXFR: + case KNOT_RESPONSE_IXFR: + case KNOT_RESPONSE_NOTIFY: /*! \todo Implement packet handling. */ break; /* Query types. */ - case DNSLIB_QUERY_NORMAL: + case KNOT_QUERY_NORMAL: res = knot_ns_answer_normal(ns, packet, qbuf, &resp_len); break; - case DNSLIB_QUERY_AXFR: + case KNOT_QUERY_AXFR: memset(&xfr, 0, sizeof(knot_ns_xfr_t)); xfr.type = XFR_TYPE_AOUT; xfr.query = packet; @@ -169,7 +169,7 @@ static void tcp_handle(struct ev_loop *loop, ev_io *w, int revents) xfr_request(xfr_h, &xfr); debug_net("tcp: enqueued AXFR query\n"); return; - case DNSLIB_QUERY_IXFR: + case KNOT_QUERY_IXFR: memset(&xfr, 0, sizeof(knot_ns_xfr_t)); xfr.type = XFR_TYPE_IOUT; xfr.query = packet; /* Will be freed after processing. */ @@ -179,8 +179,8 @@ static void tcp_handle(struct ev_loop *loop, ev_io *w, int revents) xfr_request(xfr_h, &xfr); debug_net("tcp: enqueued IXFR query\n"); return; - case DNSLIB_QUERY_NOTIFY: - case DNSLIB_QUERY_UPDATE: + case KNOT_QUERY_NOTIFY: + case KNOT_QUERY_UPDATE: break; } @@ -190,7 +190,7 @@ static void tcp_handle(struct ev_loop *loop, ev_io *w, int revents) knot_packet_free(&packet); /* Send answer. */ - if (res == KNOT_EOK) { + if (res == KNOTDEOK) { assert(resp_len > 0); res = tcp_send(w->fd, qbuf, resp_len); @@ -334,7 +334,7 @@ static int tcp_loop_run(dthread_t *thread) /* Stop whole unit. */ debug_net("tcp: loop finished\n"); - return KNOT_EOK; + return KNOTDEOK; } int tcp_loop_master_rr(dthread_t *thread) @@ -344,7 +344,7 @@ int tcp_loop_master_rr(dthread_t *thread) /* Check socket. */ if (handler->fd < 0) { debug_net("tcp_master: null socket recevied, finishing.\n"); - return KNOT_EINVAL; + return KNOTDEINVAL; } debug_net("tcp_master: threading unit master with %d workers\n", @@ -376,13 +376,13 @@ int tcp_send(int fd, uint8_t *msg, size_t msglen) unsigned short pktsize = htons(msglen); int sent = send(fd, &pktsize, sizeof(pktsize), 0); if (sent < 0) { - return KNOT_ERROR; + return KNOTDERROR; } /* Send message data. */ sent = send(fd, msg, msglen, 0); if (sent < 0) { - return KNOT_ERROR; + return KNOTDERROR; } #ifdef TCP_CORK @@ -399,14 +399,14 @@ int tcp_recv(int fd, uint8_t *buf, size_t len, sockaddr_t *addr) unsigned short pktsize = 0; int n = recv(fd, &pktsize, sizeof(unsigned short), 0); if (n < 0) { - return KNOT_ERROR; + return KNOTDERROR; } pktsize = ntohs(pktsize); // Check packet size for NULL if (pktsize == 0) { - return KNOT_ERROR; + return KNOTDERROR; } debug_net("tcp: incoming packet size=%hu on fd=%d\n", @@ -414,13 +414,13 @@ int tcp_recv(int fd, uint8_t *buf, size_t len, sockaddr_t *addr) // Check packet size if (len < pktsize) { - return KNOT_ENOMEM; + return KNOTDENOMEM; } /* Receive payload. */ n = recv(fd, buf, pktsize, 0); if (n <= 0) { - return KNOT_ERROR; + return KNOTDERROR; } /* Get peer name. */ @@ -456,7 +456,7 @@ int tcp_loop_master(dthread_t *thread) /* Check socket. */ if (handler->fd < 0) { debug_net("tcp_master: null socket recevied, finishing.\n"); - return KNOT_EINVAL; + return KNOTDEINVAL; } debug_net("tcp_master: created with %d workers\n", @@ -477,7 +477,7 @@ int tcp_loop_worker(dthread_t *thread) int tcp_loop_unit(dt_unit_t *unit) { if (unit->size < 1) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /*! \todo Implement working master+worker threads. */ @@ -493,5 +493,5 @@ int tcp_loop_unit(dt_unit_t *unit) dt_repurpose(unit->threads[i], tcp_loop_master, 0); } - return KNOT_EOK; + return KNOTDEOK; } diff --git a/src/knot/server/tcp-handler.h b/src/knot/server/tcp-handler.h index c2b11990c74a2e5494c984adbfa19ec41e6db2b9..e961425a8c1bce1692340de27c2b7f6e48f4dd84 100644 --- a/src/knot/server/tcp-handler.h +++ b/src/knot/server/tcp-handler.h @@ -15,8 +15,8 @@ * @{ */ -#ifndef _KNOT_TCPHANDLER_H_ -#define _KNOT_TCPHANDLER_H_ +#ifndef _KNOTDTCPHANDLER_H_ +#define _KNOTDTCPHANDLER_H_ #include <stdint.h> @@ -37,7 +37,7 @@ typedef void (*tcp_cb_t)(struct ev_loop *, ev_io*, int); * \param msglen Buffer maximum size. * * \retval Number of sent data on success. - * \retval KNOT_ERROR on error. + * \retval KNOTDERROR on error. */ int tcp_send(int fd, uint8_t *msg, size_t msglen); @@ -50,8 +50,8 @@ int tcp_send(int fd, uint8_t *msg, size_t msglen); * \param addr Source address. * * \retval Number of read bytes on success. - * \retval KNOT_ERROR on error. - * \retval KNOT_ENOMEM on potential buffer overflow. + * \retval KNOTDERROR on error. + * \retval KNOTDENOMEM on potential buffer overflow. */ int tcp_recv(int fd, uint8_t *buf, size_t len, sockaddr_t *addr); @@ -64,8 +64,8 @@ int tcp_recv(int fd, uint8_t *buf, size_t len, sockaddr_t *addr); * \param fd First descriptor to be watched (or -1). * \param cb Callback on fd event. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL invalid parameters. */ int tcp_loop(dthread_t *thread, int fd, tcp_cb_t cb); @@ -74,8 +74,8 @@ int tcp_loop(dthread_t *thread, int fd, tcp_cb_t cb); * * \param thread Associated thread from DThreads unit. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL invalid parameters. */ int tcp_loop_master(dthread_t *thread); @@ -84,8 +84,8 @@ int tcp_loop_master(dthread_t *thread); * * \param thread Associated thread from DThreads unit. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL invalid parameters. */ int tcp_loop_worker(dthread_t *thread); @@ -96,11 +96,11 @@ int tcp_loop_worker(dthread_t *thread); * * \param thread Associated thread from DThreads unit. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL invalid parameters. */ int tcp_loop_unit(dt_unit_t *unit); -#endif // _KNOT_TCPHANDLER_H_ +#endif // _KNOTDTCPHANDLER_H_ /*! @} */ diff --git a/src/knot/server/udp-handler.c b/src/knot/server/udp-handler.c index 947152987c4b9e026b74ffc548259599850f48f9..57db52ae557b49c89158ced4b4f8fb987891a125 100644 --- a/src/knot/server/udp-handler.c +++ b/src/knot/server/udp-handler.c @@ -31,16 +31,16 @@ int udp_master(dthread_t *thread) /* Check socket. */ if (sock < 0) { debug_net("udp_master: null socket recevied, finishing.\n"); - return KNOT_EINVAL; + return KNOTDEINVAL; } sockaddr_t addr; - if (sockaddr_init(&addr, handler->type) != KNOT_EOK) { + if (sockaddr_init(&addr, handler->type) != KNOTDEOK) { log_server_error("Socket type %d is not supported, " "IPv6 support is probably disabled.\n", handler->type); - return KNOT_ENOTSUP; + return KNOTDENOTSUP; } /* Set socket options. */ @@ -79,7 +79,7 @@ int udp_master(dthread_t *thread) int res = 0; ssize_t n = 0; uint8_t qbuf[SOCKET_MTU_SZ]; - knot_packet_type_t qtype = DNSLIB_QUERY_NORMAL; + knot_packet_type_t qtype = KNOT_QUERY_NORMAL; while (n >= 0) { n = recvfrom(sock, qbuf, sizeof(qbuf), 0, @@ -114,17 +114,17 @@ int udp_master(dthread_t *thread) //knot_response_t *resp = knot_response_new(4 * 1024); // 4K knot_packet_t *packet = - knot_packet_new(DNSLIB_PACKET_PREALLOC_QUERY); + knot_packet_new(KNOT_PACKET_PREALLOC_QUERY); if (packet == NULL) { uint16_t pkt_id = knot_wire_get_id(qbuf); - knot_ns_error_response(ns, pkt_id, DNSLIB_RCODE_SERVFAIL, + knot_ns_error_response(ns, pkt_id, KNOT_RCODE_SERVFAIL, qbuf, &resp_len); continue; } /* Parse query. */ res = knot_ns_parse_packet(qbuf, n, packet, &qtype); - if (unlikely(res != KNOT_EOK)) { + if (unlikely(res != KNOTDEOK)) { debug_net("udp: sending back error response.\n"); /* Send error response on dnslib RCODE. */ if (res > 0) { @@ -138,43 +138,43 @@ int udp_master(dthread_t *thread) } /* Handle query. */ - res = KNOT_ERROR; + res = KNOTDERROR; switch(qtype) { /* Response types. */ - case DNSLIB_RESPONSE_NORMAL: + case KNOT_RESPONSE_NORMAL: res = zones_process_response(ns, &addr, packet, qbuf, &resp_len); // res = knot_ns_process_response(); break; - case DNSLIB_RESPONSE_AXFR: - case DNSLIB_RESPONSE_IXFR: - case DNSLIB_RESPONSE_NOTIFY: + case KNOT_RESPONSE_AXFR: + case KNOT_RESPONSE_IXFR: + case KNOT_RESPONSE_NOTIFY: res = notify_process_response(ns, packet, &addr, qbuf, &resp_len); break; /* Query types. */ - case DNSLIB_QUERY_NORMAL: + case KNOT_QUERY_NORMAL: res = knot_ns_answer_normal(ns, packet, qbuf, &resp_len); break; - case DNSLIB_QUERY_AXFR: - case DNSLIB_QUERY_IXFR: + case KNOT_QUERY_AXFR: + case KNOT_QUERY_IXFR: /*! \todo Send error, not available on UDP. */ break; - case DNSLIB_QUERY_NOTIFY: + case KNOT_QUERY_NOTIFY: rcu_read_lock(); // const knot_zone_t *zone = NULL; // res = knot_ns_answer_notify(ns, packet, qbuf, // &resp_len, &zone); res = notify_process_request(ns, packet, &addr, qbuf, &resp_len); -// if (res == DNSLIB_EOK) { +// if (res == KNOT_EOK) { // res = zones_notify_schedule(zone, &addr); // } break; - case DNSLIB_QUERY_UPDATE: + case KNOT_QUERY_UPDATE: /*! \todo Implement query notify/update. */ break; } @@ -182,7 +182,7 @@ int udp_master(dthread_t *thread) knot_packet_free(&packet); /* Send answer. */ - if (res == KNOT_EOK && resp_len > 0) { + if (res == KNOTDEOK && resp_len > 0) { debug_net("udp: got answer of size %zd.\n", resp_len); @@ -208,6 +208,6 @@ int udp_master(dthread_t *thread) stat_free(thread_stat); debug_net("udp: worker %p finished.\n", thread); - return KNOT_EOK; + return KNOTDEOK; } diff --git a/src/knot/server/udp-handler.h b/src/knot/server/udp-handler.h index 00f11af1ca5743e9c4fed39a92315518b82529ed..1e5590e2edd40920de4df65d03eca05de1c41d51 100644 --- a/src/knot/server/udp-handler.h +++ b/src/knot/server/udp-handler.h @@ -13,8 +13,8 @@ * @{ */ -#ifndef _KNOT_UDPHANDLER_H_ -#define _KNOT_UDPHANDLER_H_ +#ifndef _KNOTDUDPHANDLER_H_ +#define _KNOTDUDPHANDLER_H_ #include "knot/server/socket.h" #include "knot/server/server.h" @@ -29,8 +29,8 @@ * * \param thread Associated thread from DThreads unit. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL invalid parameters. */ int udp_master(dthread_t *thread); diff --git a/src/knot/server/xfr-handler.c b/src/knot/server/xfr-handler.c index 400cc05b4bb216f75a565558f933d0932ed3b708..d7ab06b372939d6d9f04241a88e61c65c1dd96b5 100644 --- a/src/knot/server/xfr-handler.c +++ b/src/knot/server/xfr-handler.c @@ -82,7 +82,7 @@ static inline void xfr_client_ev(struct ev_loop *loop, ev_io *w, int revents) ret = knot_ns_process_ixfrin(xfr_w->h->ns, request); break; default: - ret = KNOT_EINVAL; + ret = KNOTDEINVAL; break; } @@ -98,12 +98,12 @@ static inline void xfr_client_ev(struct ev_loop *loop, ev_io *w, int revents) switch(request->type) { case XFR_TYPE_AIN: ret = zones_save_zone(request); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { /*! \todo Log error. */ return; } ret = knot_ns_switch_zone(xfr_w->h->ns, request); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { /*! \todo Log error. */ return; } @@ -111,19 +111,19 @@ static inline void xfr_client_ev(struct ev_loop *loop, ev_io *w, int revents) case XFR_TYPE_IIN: /* save changesets */ ret = zones_store_changesets(request); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { /*! \todo Log error */ return; } /* update zone */ ret = zones_apply_changesets(request); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { /*! \todo Log error */ return; } break; default: - ret = KNOT_EINVAL; + ret = KNOTDEINVAL; break; } /* Save finished zone and reload. */ @@ -197,7 +197,7 @@ static inline void xfr_bridge_ev(struct ev_loop *loop, ev_io *w, int revents) const knot_zone_contents_t *contents = knot_zone_contents(zone); /* Create XFR query. */ - ret = KNOT_ERROR; + ret = KNOTDERROR; size_t bufsize = req->wire_size; switch(req->type) { case XFR_TYPE_AIN: @@ -207,7 +207,7 @@ static inline void xfr_bridge_ev(struct ev_loop *loop, ev_io *w, int revents) ret = xfrin_create_ixfr_query(contents, req->wire, &bufsize); break; default: - ret = KNOT_EINVAL; + ret = KNOTDEINVAL; break; } @@ -215,7 +215,7 @@ static inline void xfr_bridge_ev(struct ev_loop *loop, ev_io *w, int revents) rcu_read_unlock(); /* Handle errors. */ - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { debug_xfr("xfr_in: failed to create XFR query type %d\n", req->type); socket_close(req->session); @@ -312,7 +312,7 @@ xfrhandler_t *xfr_create(size_t thrcount, knot_nameserver_t *ns) int xfr_free(xfrhandler_t *handler) { if (!handler) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Remove handler data. */ @@ -328,7 +328,7 @@ int xfr_free(xfrhandler_t *handler) dt_delete(&handler->unit); free(handler); - return KNOT_EOK; + return KNOTDEOK; } int xfr_stop(xfrhandler_t *handler) @@ -339,21 +339,21 @@ int xfr_stop(xfrhandler_t *handler) brk.data.session = -1; evqueue_write(handler->cq, &brk, sizeof(struct xfr_io_t)); - return KNOT_EOK; + return KNOTDEOK; } int xfr_request(xfrhandler_t *handler, knot_ns_xfr_t *req) { if (!handler || !req) { - return KNOT_EINVAL; + return KNOTDEINVAL; } int ret = evqueue_write(handler->q, req, sizeof(knot_ns_xfr_t)); if (ret < 0) { - return KNOT_ERROR; + return KNOTDERROR; } - return KNOT_EOK; + return KNOTDEOK; } int xfr_master(dthread_t *thread) @@ -363,7 +363,7 @@ int xfr_master(dthread_t *thread) /* Check data. */ if (xfrh < 0) { debug_xfr("xfr_master: no data recevied, finishing.\n"); - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Buffer for answering. */ @@ -379,13 +379,13 @@ int xfr_master(dthread_t *thread) /* Cancellation point. */ if (dt_is_cancelled(thread)) { debug_xfr("xfr_master: finished.\n"); - return KNOT_EOK; + return KNOTDEOK; } /* Check poll count. */ if (ret <= 0) { debug_xfr("xfr_master: queue poll returned %d.\n", ret); - return KNOT_ERROR; + return KNOTDERROR; } /* Read single request. */ @@ -393,7 +393,7 @@ int xfr_master(dthread_t *thread) ret = evqueue_read(xfrh->q, &xfr, sizeof(knot_ns_xfr_t)); if (ret != sizeof(knot_ns_xfr_t)) { debug_xfr("xfr_master: queue read returned %d.\n", ret); - return KNOT_ERROR; + return KNOTDERROR; } /* Update request. */ @@ -412,14 +412,14 @@ int xfr_master(dthread_t *thread) req_type = "axfr-out"; ret = knot_ns_init_xfr(xfrh->ns, &xfr); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_xfr("xfr_master: failed to init XFR: %s\n", knot_strerror2(ret)); socket_close(xfr.session); } ret = zones_xfr_check_zone(&xfr, &rcode); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { knot_ns_xfr_send_error(&xfr, rcode); socket_close(xfr.session); } @@ -427,7 +427,7 @@ int xfr_master(dthread_t *thread) ret = knot_ns_answer_axfr(xfrh->ns, &xfr); knot_packet_free(&xfr.query); /* Free query. */ debug_xfr("xfr_master: ns_answer_axfr() = %d.\n", ret); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { socket_close(xfr.session); } @@ -437,48 +437,48 @@ int xfr_master(dthread_t *thread) req_type = "ixfr-out"; ret = knot_ns_init_xfr(xfrh->ns, &xfr); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_xfr("xfr_master: failed to init XFR: %s\n", knot_strerror2(ret)); socket_close(xfr.session); } ret = zones_xfr_check_zone(&xfr, &rcode); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { knot_ns_xfr_send_error(&xfr, rcode); socket_close(xfr.session); } ret = zones_xfr_load_changesets(&xfr); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { knot_ns_xfr_send_error(&xfr, - DNSLIB_RCODE_SERVFAIL); + KNOT_RCODE_SERVFAIL); socket_close(xfr.session); } ret = knot_ns_answer_ixfr(xfrh->ns, &xfr); knot_packet_free(&xfr.query); /* Free query. */ debug_xfr("xfr_master: ns_answer_ixfr() = %d.\n", ret); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { socket_close(xfr.session); } break; case XFR_TYPE_AIN: req_type = "axfr-in"; evqueue_write(xfrh->cq, &xfr, sizeof(knot_ns_xfr_t)); - ret = KNOT_EOK; + ret = KNOTDEOK; break; case XFR_TYPE_IIN: req_type = "ixfr-in"; evqueue_write(xfrh->cq, &xfr, sizeof(knot_ns_xfr_t)); - ret = KNOT_EOK; + ret = KNOTDEOK; break; default: break; } /* Report. */ - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { log_server_error("%s request failed: %s\n", req_type, knot_strerror(ret)); } @@ -487,7 +487,7 @@ int xfr_master(dthread_t *thread) /* Stop whole unit. */ debug_xfr("xfr_master: finished.\n"); - return KNOT_EOK; + return KNOTDEOK; } int xfr_client(dthread_t *thread) @@ -497,7 +497,7 @@ int xfr_client(dthread_t *thread) /* Check data. */ if (data < 0) { debug_xfr("xfr_client: no data received, finishing.\n"); - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Install interrupt handler. */ @@ -518,7 +518,7 @@ int xfr_client(dthread_t *thread) /* Cancellation point. */ if (dt_is_cancelled(thread)) { debug_xfr("xfr_client: finished.\n"); - return KNOT_EOK; + return KNOTDEOK; } /* Run event loop. */ @@ -530,5 +530,5 @@ int xfr_client(dthread_t *thread) debug_xfr("xfr_client: finished.\n"); - return KNOT_EOK; + return KNOTDEOK; } diff --git a/src/knot/server/xfr-handler.h b/src/knot/server/xfr-handler.h index 1be452a94cb56a4496d205e24c39b9fad6fe4ded..4d1166fb9683db6f1327442891c3ab9fb556d341 100644 --- a/src/knot/server/xfr-handler.h +++ b/src/knot/server/xfr-handler.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_XFRHANDLER_H_ -#define _KNOT_XFRHANDLER_H_ +#ifndef _KNOTDXFRHANDLER_H_ +#define _KNOTDXFRHANDLER_H_ #include <ev.h> @@ -52,9 +52,9 @@ xfrhandler_t *xfr_create(size_t thrcount, knot_nameserver_t *ns); * * \param handler XFR handler. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on NULL handler. - * \retval KNOT_ERROR on error. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on NULL handler. + * \retval KNOTDERROR on error. */ int xfr_free(xfrhandler_t *handler); @@ -63,8 +63,8 @@ int xfr_free(xfrhandler_t *handler); * * \param handler XFR handler. * - * \retval KNOT_EOK on success. - * \retval KNOT_ERROR on error. + * \retval KNOTDEOK on success. + * \retval KNOTDERROR on error. */ static inline int xfr_start(xfrhandler_t *handler) { return dt_start(handler->unit); @@ -75,8 +75,8 @@ static inline int xfr_start(xfrhandler_t *handler) { * * \param handler XFR handler. * - * \retval KNOT_EOK on success. - * \retval KNOT_ERROR on error. + * \retval KNOTDEOK on success. + * \retval KNOTDERROR on error. */ int xfr_stop(xfrhandler_t *handler); @@ -85,8 +85,8 @@ int xfr_stop(xfrhandler_t *handler); * * \param handler XFR handler. * - * \retval KNOT_EOK on success. - * \retval KNOT_ERROR on error. + * \retval KNOTDEOK on success. + * \retval KNOTDERROR on error. */ static inline int xfr_join(xfrhandler_t *handler) { return dt_join(handler->unit); @@ -98,9 +98,9 @@ static inline int xfr_join(xfrhandler_t *handler) { * \param handler XFR handler instance. * \param req XFR request. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on NULL handler or request. - * \retval KNOT_ERROR on error. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on NULL handler or request. + * \retval KNOTDERROR on error. */ int xfr_request(xfrhandler_t *handler, knot_ns_xfr_t *req); @@ -112,8 +112,8 @@ int xfr_request(xfrhandler_t *handler, knot_ns_xfr_t *req); * * \param thread Associated thread from DThreads unit. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL invalid parameters. */ int xfr_master(dthread_t *thread); @@ -124,11 +124,11 @@ int xfr_master(dthread_t *thread); * * \param thread Associated thread from DThreads unit. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL invalid parameters. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL invalid parameters. */ int xfr_client(dthread_t *thread); -#endif // _KNOT_XFRHANDLER_H_ +#endif // _KNOTDXFRHANDLER_H_ /*! @} */ diff --git a/src/knot/server/zones.c b/src/knot/server/zones.c index f0f99a25656f4d70f1dd0a677e10203044e064af..5ccc18644cad5b60e1d1552546ed6613e736fce2 100644 --- a/src/knot/server/zones.c +++ b/src/knot/server/zones.c @@ -31,7 +31,7 @@ static int zonedata_destroy(knot_zone_t *zone) { zonedata_t *zd = (zonedata_t *)zone->data; if (!zd) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Destroy mutex. */ @@ -46,7 +46,7 @@ static int zonedata_destroy(knot_zone_t *zone) free(zd); - return KNOT_EOK; + return KNOTDEOK; } /*! \brief Zone data constructor function. */ @@ -54,7 +54,7 @@ static int zonedata_init(conf_zone_t *cfg, knot_zone_t *zone) { zonedata_t *zd = malloc(sizeof(zonedata_t)); if (!zd) { - return KNOT_ENOMEM; + return KNOTDENOMEM; } /* Link to config. */ @@ -100,15 +100,15 @@ static int zonedata_init(conf_zone_t *cfg, knot_zone_t *zone) /*! \todo Checks for NULL!!! */ const knot_zone_contents_t *contents = knot_zone_contents(zone); soa_rrs = knot_node_rrset(knot_zone_contents_apex(contents), - DNSLIB_RRTYPE_SOA); + KNOT_RRTYPE_SOA); soa_rr = knot_rrset_rdata(soa_rrs); int64_t serial = knot_rdata_soa_serial(soa_rr); zd->zonefile_serial = (uint32_t)serial; if (serial < 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } - return KNOT_EOK; + return KNOTDEOK; } /*! @@ -128,7 +128,7 @@ static uint32_t zones_soa_timer(knot_zone_t *zone, const knot_rdata_t *soa_rr = 0; soa_rrs = knot_node_rrset(knot_zone_contents_apex( knot_zone_contents((zone))), - DNSLIB_RRTYPE_SOA); + KNOT_RRTYPE_SOA); soa_rr = knot_rrset_rdata(soa_rrs); ret = rr_func(soa_rr); @@ -177,10 +177,10 @@ static int zones_axfrin_expire(event_t *e) debug_zones("axfrin: EXPIRE timer event\n"); knot_zone_t *zone = (knot_zone_t *)e->data; if (!zone) { - return KNOT_EINVAL; + return KNOTDEINVAL; } if (!zone->data) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Cancel pending timers. */ @@ -208,10 +208,10 @@ static int zones_axfrin_poll(event_t *e) debug_zones("axfrin: REFRESH or RETRY timer event\n"); knot_zone_t *zone = (knot_zone_t *)e->data; if (!zone) { - return KNOT_EINVAL; + return KNOTDEINVAL; } if (!zone->data) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Cancel pending timers. */ @@ -223,7 +223,7 @@ static int zones_axfrin_poll(event_t *e) /* Create query. */ int ret = xfrin_create_soa_query(knot_zone_contents(zone), qbuf, &buflen); - if (ret == KNOT_EOK && zd->xfr_in.ifaces) { + if (ret == KNOTDEOK && zd->xfr_in.ifaces) { int sock = -1; iface_t *i = 0; @@ -289,10 +289,10 @@ static int zones_notify_send(event_t *e) notify_ev_t *ev = (notify_ev_t *)e->data; knot_zone_t *zone = ev->zone; if (!zone) { - return KNOT_EINVAL; + return KNOTDEINVAL; } if (!knot_zone_data(zone)) { - return KNOT_EINVAL; + return KNOTDEINVAL; } debug_zones("notify: NOTIFY timer event\n"); @@ -305,7 +305,7 @@ static int zones_notify_send(event_t *e) zonedata_t *zd = (zonedata_t *)knot_zone_data(zone); int ret = notify_create_request(knot_zone_contents(zone), qbuf, &buflen); - if (ret == KNOT_EOK && zd->xfr_in.ifaces) { + if (ret == KNOTDEOK && zd->xfr_in.ifaces) { /*! \todo Bind to random port? See zones_axfrin_poll(). */ @@ -350,7 +350,7 @@ static int zones_notify_send(event_t *e) evsched_event_free(e->parent, ev->timer); rem_node(&ev->n); free(ev); - return KNOT_EMALF; + return KNOTDEMALF; } /* RFC suggests 60s, but it is configurable. */ @@ -376,7 +376,7 @@ static int zones_ixfrdb_sync_apply(journal_t *j, journal_node_t *n) journal_update(j, n); } - return KNOT_EOK; + return KNOTDEOK; } /*! @@ -389,10 +389,10 @@ static int zones_zonefile_sync_ev(event_t *e) /* Fetch zone. */ knot_zone_t *zone = (knot_zone_t *)e->data; if (!zone) { - return KNOT_EINVAL; + return KNOTDEINVAL; } if (!zone->data) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Fetch zone data. */ @@ -508,14 +508,14 @@ void zones_timers_update(knot_zone_t *zone, conf_zone_t *cfzone, evsched_t *sch) * \param acl Pointer to existing or NULL ACL. * \param acl_list List of remotes from configuration. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. - * \retval KNOT_ENOMEM on failed memory allocation. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. + * \retval KNOTDENOMEM on failed memory allocation. */ static int zones_set_acl(acl_t **acl, list* acl_list) { if (!acl || !acl_list) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Truncate old ACL. */ @@ -524,7 +524,7 @@ static int zones_set_acl(acl_t **acl, list* acl_list) /* Create new ACL. */ *acl = acl_new(ACL_DENY, 0); if (!*acl) { - return KNOT_ENOMEM; + return KNOTDENOMEM; } /* Load ACL rules. */ @@ -543,7 +543,7 @@ static int zones_set_acl(acl_t **acl, list* acl_list) } } - return KNOT_EOK; + return KNOTDEOK; } /*! @@ -554,9 +554,9 @@ static int zones_set_acl(acl_t **acl, list* acl_list) * \param source Path to zone file source. * \param filename Path to requested compiled zone file. * - * \retval KNOT_EOK - * \retval KNOT_EINVAL - * \retval KNOT_EZONEINVAL + * \retval KNOTDEOK + * \retval KNOTDEINVAL + * \retval KNOTDEZONEINVAL */ static int zones_load_zone(knot_zonedb_t *zonedb, const char *zone_name, const char *source, const char *filename) @@ -571,7 +571,7 @@ static int zones_load_zone(knot_zonedb_t *zonedb, const char *zone_name, log_server_error("Compiled db '%s' is too old, " " please recompile.\n", filename); - return KNOT_EZONEINVAL; + return KNOTDEZONEINVAL; } // Check if the db is up-to-date @@ -604,16 +604,16 @@ static int zones_load_zone(knot_zonedb_t *zonedb, const char *zone_name, log_server_error("Failed to load " "db '%s' for zone '%s'.\n", filename, zone_name); - return KNOT_EZONEINVAL; + return KNOTDEZONEINVAL; } } else { /* db is null. */ - return KNOT_EINVAL; + return KNOTDEINVAL; } // knot_zone_dump(zone, 1); - return KNOT_EOK; + return KNOTDEOK; } /*----------------------------------------------------------------------------*/ @@ -694,8 +694,8 @@ static int zones_changesets_from_binary(knot_changesets_t *chgsets) for (int i = 0; i < chgsets->count; ++i) { ret = knot_zload_rrset_deserialize(&rrset, chgsets->sets[i].data + parsed, &size); - if (ret != DNSLIB_EOK) { - return DNSLIB_EMALF; + if (ret != KNOT_EOK) { + return KNOT_EMALF; } while (rrset != NULL) { @@ -703,7 +703,7 @@ static int zones_changesets_from_binary(knot_changesets_t *chgsets) if (soa == 0) { assert(knot_rrset_type(rrset) - == DNSLIB_RRTYPE_SOA); + == KNOT_RRTYPE_SOA); /* in this special case (changesets loaded * from journal) the SOA serial should already @@ -721,7 +721,7 @@ static int zones_changesets_from_binary(knot_changesets_t *chgsets) if (soa == 1) { if (knot_rrset_type(rrset) - == DNSLIB_RRTYPE_SOA) { + == KNOT_RRTYPE_SOA) { /* in this special case (changesets * loaded from journal) the SOA serial * should already be set, check it. @@ -741,21 +741,21 @@ static int zones_changesets_from_binary(knot_changesets_t *chgsets) &chgsets->sets[i] .remove_allocated, rrset); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } } } else { if (knot_rrset_type(rrset) - == DNSLIB_RRTYPE_SOA) { - return DNSLIB_EMALF; + == KNOT_RRTYPE_SOA) { + return KNOT_EMALF; } else { ret = knot_changeset_add_rrset( &chgsets->sets[i].add, &chgsets->sets[i].add_count, &chgsets->sets[i].add_allocated, rrset); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { return ret; } } @@ -763,13 +763,13 @@ static int zones_changesets_from_binary(knot_changesets_t *chgsets) ret = knot_zload_rrset_deserialize(&rrset, chgsets->sets[i].data + parsed, &size); - if (ret != DNSLIB_EOK) { - return DNSLIB_EMALF; + if (ret != KNOT_EOK) { + return KNOT_EMALF; } } } - return DNSLIB_ENOTSUP; + return KNOT_ENOTSUP; } /*----------------------------------------------------------------------------*/ @@ -779,16 +779,16 @@ static int zones_load_changesets(const knot_zone_t *zone, uint32_t from, uint32_t to) { if (!zone || !dst) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } if (!zone->data) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } /* Fetch zone-specific data. */ zonedata_t *zd = (zonedata_t *)knot_zone_data(zone); if (!zd->ixfr_db) { - return DNSLIB_EBADARG; + return KNOT_EBADARG; } /* Read entries from starting serial until finished. */ @@ -805,7 +805,7 @@ static int zones_load_changesets(const knot_zone_t *zone, /* Check changesets size if needed. */ ++dst->count; ret = knot_changesets_check_size(dst); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("ixfr_db: failed to check changesets size\n"); --dst->count; return ret; @@ -818,16 +818,16 @@ static int zones_load_changesets(const knot_zone_t *zone, chs->data = malloc(n->len); if (!chs->data) { --dst->count; - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } /* Read journal entry. */ ret = journal_read(zd->ixfr_db, n->id, 0, (char*)chs->data); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { debug_knot_xfr("ixfr_db: failed to read data from journal\n"); --dst->count; - return DNSLIB_ERROR; + return KNOT_ERROR; } /* Next node. */ @@ -839,18 +839,18 @@ static int zones_load_changesets(const knot_zone_t *zone, /* Unpack binary data. */ ret = zones_changesets_from_binary(dst); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { debug_knot_xfr("ixfr_db: failed to unpack changesets from binary\n"); return ret; } /* Check for complete history. */ if (to != found_to) { - return DNSLIB_ERANGE; + return KNOT_ERANGE; } /* History reconstructed. */ - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -860,15 +860,15 @@ static int zones_load_changesets(const knot_zone_t *zone, * * \param zone Specified zone. * - * \retval KNOT_EOK if successful. - * \retval KNOT_EINVAL on invalid parameters. - * \retval KNOT_EOK on unspecified error. + * \retval KNOTDEOK if successful. + * \retval KNOTDEINVAL on invalid parameters. + * \retval KNOTDEOK on unspecified error. */ static int zones_journal_apply(knot_zone_t *zone) { /* Fetch zone. */ if (!zone) { - return KNOT_EINVAL; + return KNOTDEINVAL; } knot_zone_contents_t *contents = knot_zone_get_contents(zone); @@ -877,11 +877,11 @@ static int zones_journal_apply(knot_zone_t *zone) const knot_rrset_t *soa_rrs = 0; const knot_rdata_t *soa_rr = 0; soa_rrs = knot_node_rrset(knot_zone_contents_apex(contents), - DNSLIB_RRTYPE_SOA); + KNOT_RRTYPE_SOA); soa_rr = knot_rrset_rdata(soa_rrs); int64_t serial_ret = knot_rdata_soa_serial(soa_rr); if (serial_ret < 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } uint32_t serial = (uint32_t)serial_ret; @@ -890,7 +890,7 @@ static int zones_journal_apply(knot_zone_t *zone) knot_changesets_t* chsets = malloc(sizeof(knot_changesets_t)); memset(chsets, 0, sizeof(knot_changesets_t)); int ret = zones_load_changesets(zone, chsets, serial, serial - 1); - if (ret == KNOT_EOK || ret == KNOT_ERANGE) { + if (ret == KNOTDEOK || ret == KNOTDERANGE) { /* Apply changesets. */ debug_zones("update_zone: applying %u changesets\n", @@ -969,7 +969,7 @@ static int zones_insert_zones(knot_nameserver_t *ns, " version is old, loading...\n"); int ret = zones_load_zone(db_new, z->name, z->file, z->db); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { log_server_error("Error loading new zone to" " the new database: %s\n", knot_strerror(ret)); @@ -988,7 +988,7 @@ static int zones_insert_zones(knot_nameserver_t *ns, // just insert the zone into the new zone db debug_zones("Found in old database, copying to new.\n"); int ret = knot_zonedb_add_zone(db_new, zone); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { log_server_error("Error adding old zone to" " the new database: %s\n", knot_strerror(ret)); @@ -1054,8 +1054,8 @@ static int zones_insert_zones(knot_nameserver_t *ns, * \param zone_conf Zone configuration. * \param db_old Old zone database to remove zones from. * - * \retval KNOT_EOK - * \retval KNOT_ERROR + * \retval KNOTDEOK + * \retval KNOTDERROR */ static int zones_remove_zones(const list *zone_conf, knot_zonedb_t *db_old) { @@ -1071,7 +1071,7 @@ static int zones_remove_zones(const list *zone_conf, knot_zonedb_t *db_old) if (zone_name == NULL) { log_server_error("Error creating domain name from zone" " name\n"); - return KNOT_ERROR; + return KNOTDERROR; } debug_zones("Removing zone %s from the old database.\n", z->name); @@ -1081,7 +1081,7 @@ static int zones_remove_zones(const list *zone_conf, knot_zonedb_t *db_old) /* Directly discard. */ knot_dname_free(&zone_name); } - return KNOT_EOK; + return KNOTDEOK; } /*----------------------------------------------------------------------------*/ @@ -1093,7 +1093,7 @@ int zones_update_db_from_config(const conf_t *conf, knot_nameserver_t *ns, { // Check parameters if (conf == NULL || ns == NULL) { - return KNOT_EINVAL; + return KNOTDEINVAL; } // Lock RCU to ensure noone will deallocate any data under our hands. @@ -1104,13 +1104,13 @@ int zones_update_db_from_config(const conf_t *conf, knot_nameserver_t *ns, if (*db_old == NULL) { log_server_error("Missing zone database in nameserver structure" ".\n"); - return KNOT_ERROR; + return KNOTDERROR; } // Create new zone DB knot_zonedb_t *db_new = knot_zonedb_new(); if (db_new == NULL) { - return KNOT_ERROR; + return KNOTDERROR; } log_server_info("Loading %d zones...\n", conf->zones_count); @@ -1140,7 +1140,7 @@ int zones_update_db_from_config(const conf_t *conf, knot_nameserver_t *ns, * databases are already switched. */ int ret = zones_remove_zones(&conf->zones, *db_old); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { return ret; } @@ -1150,16 +1150,16 @@ int zones_update_db_from_config(const conf_t *conf, knot_nameserver_t *ns, debug_zones("Old database is empty (%p): %s\n", (*db_old)->zones, skip_is_empty((*db_old)->zones) ? "yes" : "no"); - return KNOT_EOK; + return KNOTDEOK; } int zones_zonefile_sync(knot_zone_t *zone) { if (!zone) { - return KNOT_EINVAL; + return KNOTDEINVAL; } if (!zone->data) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Fetch zone data. */ @@ -1174,11 +1174,11 @@ int zones_zonefile_sync(knot_zone_t *zone) const knot_rrset_t *soa_rrs = 0; const knot_rdata_t *soa_rr = 0; soa_rrs = knot_node_rrset(knot_zone_contents_apex(contents), - DNSLIB_RRTYPE_SOA); + KNOT_RRTYPE_SOA); soa_rr = knot_rrset_rdata(soa_rrs); int64_t serial_ret = knot_rdata_soa_serial(soa_rr); if (serial_ret < 0) { - return KNOT_EINVAL; + return KNOTDEINVAL; } uint32_t serial_to = (uint32_t)serial_ret; @@ -1206,7 +1206,7 @@ int zones_zonefile_sync(knot_zone_t *zone) /* Unlock zone data. */ pthread_mutex_unlock(&zd->lock); - return KNOT_EOK; + return KNOTDEOK; } /*----------------------------------------------------------------------------*/ @@ -1214,27 +1214,27 @@ int zones_zonefile_sync(knot_zone_t *zone) int zones_xfr_check_zone(knot_ns_xfr_t *xfr, knot_rcode_t *rcode) { if (xfr == NULL || xfr->zone == NULL || rcode == NULL) { - *rcode = DNSLIB_RCODE_SERVFAIL; - return KNOT_EINVAL; + *rcode = KNOT_RCODE_SERVFAIL; + return KNOTDEINVAL; } /* Check zone data. */ zonedata_t *zd = (zonedata_t *)xfr->zone->data; if (zd == NULL) { debug_zones("Invalid zone data.\n"); - *rcode = DNSLIB_RCODE_SERVFAIL; - return KNOT_ERROR; + *rcode = KNOT_RCODE_SERVFAIL; + return KNOTDERROR; } // Check xfr-out ACL if (acl_match(zd->xfr_out, &xfr->addr) == ACL_DENY) { debug_zones("Request for AXFR OUT is not authorized.\n"); - *rcode = DNSLIB_RCODE_REFUSED; - return KNOT_ERROR; + *rcode = KNOT_RCODE_REFUSED; + return KNOTDERROR; } else { debug_zones("Authorized AXFR OUT request.\n"); } - return KNOT_EOK; + return KNOTDEOK; } /*----------------------------------------------------------------------------*/ @@ -1258,14 +1258,14 @@ int zones_process_response(knot_nameserver_t *nameserver, { if (!packet || !rsize || nameserver == NULL || from == NULL || response_wire == NULL) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /*! \todo Handle SOA query response, cancel EXPIRE timer * and start AXFR transfer if needed. * Reset REFRESH timer on finish. */ - if (knot_packet_qtype(packet) == DNSLIB_RRTYPE_SOA) { + if (knot_packet_qtype(packet) == KNOT_RRTYPE_SOA) { /* No response. */ *rsize = 0; @@ -1277,17 +1277,17 @@ int zones_process_response(knot_nameserver_t *nameserver, nameserver->zone_db, zone_name); if (!zone) { - return KNOT_EINVAL; + return KNOTDEINVAL; } if (!knot_zone_data(zone)) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Match ID against awaited. */ zonedata_t *zd = (zonedata_t *)knot_zone_data(zone); uint16_t pkt_id = knot_packet_id(packet); if ((int)pkt_id != zd->xfr_in.next_id) { - return KNOT_ERROR; + return KNOTDERROR; } /* Cancel EXPIRE timer. */ @@ -1322,7 +1322,7 @@ int zones_process_response(knot_nameserver_t *nameserver, const knot_rdata_t *soa_rr = 0; soa_rrs = knot_node_rrset( knot_zone_contents_apex(contents), - DNSLIB_RRTYPE_SOA); + KNOT_RRTYPE_SOA); soa_rr = knot_rrset_rdata(soa_rrs); ref_tmr = knot_rdata_soa_refresh(soa_rr); ref_tmr *= 1000; /* Convert to miliseconds. */ @@ -1332,7 +1332,7 @@ int zones_process_response(knot_nameserver_t *nameserver, evsched_schedule(sched, refresh_ev, ref_tmr); rcu_read_unlock(); - return KNOT_EOK; + return KNOTDEOK; } /* Prepare XFR client transfer. */ @@ -1353,7 +1353,7 @@ int zones_process_response(knot_nameserver_t *nameserver, } - return KNOT_EOK; + return KNOTDEOK; } /*----------------------------------------------------------------------------*/ @@ -1377,7 +1377,7 @@ static int zones_find_zone_for_xfr(const knot_zone_contents_t *zone, knot_dname_t *zone_name = knot_dname_new_from_str( zone_conf->name, strlen(zone_conf->name), NULL); if (zone_name == NULL) { - return KNOT_ENOMEM; + return KNOTDENOMEM; } int r = knot_dname_compare(zone_name, knot_node_owner( @@ -1390,7 +1390,7 @@ static int zones_find_zone_for_xfr(const knot_zone_contents_t *zone, // found the right zone *zonefile = zone_conf->file; *zonedb = zone_conf->db; - return KNOT_EOK; + return KNOTDEOK; } } @@ -1400,7 +1400,7 @@ static int zones_find_zone_for_xfr(const knot_zone_contents_t *zone, "(%s).\n", name); free(name); - return KNOT_ENOENT; + return KNOTDENOENT; } /*----------------------------------------------------------------------------*/ @@ -1453,22 +1453,22 @@ static int zones_dump_xfr_zone_text(knot_zone_contents_t *zone, if (new_zonefile == NULL) { debug_zones("Failed to find free filename for temporary " "storage of the zone text file.\n"); - return KNOT_ERROR; /*! \todo New error code? */ + return KNOTDERROR; /*! \todo New error code? */ } int rc = zone_dump_text(zone, new_zonefile); - if (rc != KNOT_EOK) { + if (rc != KNOTDEOK) { debug_zones("Failed to save the zone to text zone file %s." "\n", new_zonefile); free(new_zonefile); - return KNOT_ERROR; + return KNOTDERROR; } /*! \todo if successful, replace the old file with the new one */ free(new_zonefile); - return KNOT_EOK; + return KNOTDEOK; } /*----------------------------------------------------------------------------*/ @@ -1484,22 +1484,22 @@ static int ns_dump_xfr_zone_binary(knot_zone_contents_t *zone, if (new_zonedb == NULL) { debug_zones("Failed to find free filename for temporary " "storage of the zone binary file.\n"); - return KNOT_ERROR; /*! \todo New error code? */ + return KNOTDERROR; /*! \todo New error code? */ } int rc = knot_zdump_binary(zone, new_zonedb, 0, zonefile); - if (rc != DNSLIB_EOK) { + if (rc != KNOT_EOK) { debug_zones("Failed to save the zone to binary zone db %s." "\n", new_zonedb); free(new_zonedb); - return KNOT_ERROR; + return KNOTDERROR; } /*! \todo if successful, replace the old file with the new one */ free(new_zonedb); - return KNOT_EOK; + return KNOTDEOK; } /*----------------------------------------------------------------------------*/ @@ -1507,7 +1507,7 @@ static int ns_dump_xfr_zone_binary(knot_zone_contents_t *zone, int zones_save_zone(const knot_ns_xfr_t *xfr) { if (xfr == NULL || xfr->data == NULL) { - return KNOT_EINVAL; + return KNOTDEINVAL; } knot_zone_contents_t *zone = @@ -1517,7 +1517,7 @@ int zones_save_zone(const knot_ns_xfr_t *xfr) const char *zonedb = NULL; int ret = zones_find_zone_for_xfr(zone, &zonefile, &zonedb); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { return ret; } @@ -1525,16 +1525,16 @@ int zones_save_zone(const knot_ns_xfr_t *xfr) // dump the zone into text zone file ret = zones_dump_xfr_zone_text(zone, zonefile); - if (ret != KNOT_EOK) { - return KNOT_ERROR; + if (ret != KNOTDEOK) { + return KNOTDERROR; } // dump the zone into binary db file ret = ns_dump_xfr_zone_binary(zone, zonedb, zonefile); - if (ret != KNOT_EOK) { - return KNOT_ERROR; + if (ret != KNOTDEOK) { + return KNOTDERROR; } - return KNOT_EOK; + return KNOTDEOK; } /*----------------------------------------------------------------------------*/ @@ -1547,7 +1547,7 @@ int zones_ns_conf_hook(const struct conf_t *conf, void *data) knot_zonedb_t *old_db = 0; int ret = zones_update_db_from_config(conf, ns, &old_db); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { return ret; } // Wait until all readers finish with reading the zones. @@ -1559,7 +1559,7 @@ int zones_ns_conf_hook(const struct conf_t *conf, void *data) // Delete all deprecated zones and delete the old database. knot_zonedb_deep_free(&old_db); - return KNOT_EOK; + return KNOTDEOK; } /*----------------------------------------------------------------------------*/ @@ -1574,7 +1574,7 @@ static int zones_check_binary_size(uint8_t **data, size_t *allocated, } uint8_t *new_data = (uint8_t *)malloc(new_size); if (new_data == NULL) { - return DNSLIB_ENOMEM; + return KNOT_ENOMEM; } memcpy(new_data, *data, *allocated); @@ -1584,7 +1584,7 @@ static int zones_check_binary_size(uint8_t **data, size_t *allocated, free(old_data); } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1605,12 +1605,12 @@ static int zones_changeset_rrset_to_binary(uint8_t **data, size_t *size, uint8_t *binary = NULL; size_t actual_size = 0; int ret = knot_zdump_rrset_serialize(rrset, &binary, &actual_size); - if (ret != DNSLIB_EOK) { - return DNSLIB_ERROR; /*! \todo Other code? */ + if (ret != KNOT_EOK) { + return KNOT_ERROR; /*! \todo Other code? */ } ret = zones_check_binary_size(data, allocated, *size + actual_size); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { free(binary); return ret; } @@ -1619,7 +1619,7 @@ static int zones_changeset_rrset_to_binary(uint8_t **data, size_t *size, *size += actual_size; free(binary); - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1643,7 +1643,7 @@ static int zones_changesets_to_binary(knot_changesets_t *chgsets) // 1) origin SOA ret = zones_changeset_rrset_to_binary(&ch->data, &ch->size, &ch->allocated, ch->soa_from); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { free(ch->data); ch->data = NULL; return ret; @@ -1658,7 +1658,7 @@ static int zones_changesets_to_binary(knot_changesets_t *chgsets) &ch->size, &ch->allocated, ch->remove[j]); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { free(ch->data); ch->data = NULL; return ret; @@ -1668,7 +1668,7 @@ static int zones_changesets_to_binary(knot_changesets_t *chgsets) // 3) new SOA ret = zones_changeset_rrset_to_binary(&ch->data, &ch->size, &ch->allocated, ch->soa_to); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { free(ch->data); ch->data = NULL; return ret; @@ -1681,7 +1681,7 @@ static int zones_changesets_to_binary(knot_changesets_t *chgsets) &ch->size, &ch->allocated, ch->add[j]); - if (ret != DNSLIB_EOK) { + if (ret != KNOT_EOK) { free(ch->data); ch->data = NULL; return ret; @@ -1689,7 +1689,7 @@ static int zones_changesets_to_binary(knot_changesets_t *chgsets) } } - return DNSLIB_EOK; + return KNOT_EOK; } /*----------------------------------------------------------------------------*/ @@ -1697,7 +1697,7 @@ static int zones_changesets_to_binary(knot_changesets_t *chgsets) int zones_store_changesets(knot_ns_xfr_t *xfr) { if (xfr == NULL || xfr->data == NULL || xfr->zone == NULL) { - return KNOT_EINVAL; + return KNOTDEINVAL; } knot_zone_t *zone = xfr->zone; @@ -1706,14 +1706,14 @@ int zones_store_changesets(knot_ns_xfr_t *xfr) /*! \todo Convert to binary format. */ int ret = zones_changesets_to_binary(src); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { return ret; } /* Fetch zone-specific data. */ zonedata_t *zd = (zonedata_t *)zone->data; if (!zd->ixfr_db) { - return KNOT_EINVAL; + return KNOTDEINVAL; } /* Begin writing to journal. */ @@ -1728,10 +1728,10 @@ int zones_store_changesets(knot_ns_xfr_t *xfr) chs->size); /* Check for errors. */ - while (ret != KNOT_EOK) { + while (ret != KNOTDEOK) { /* Sync to zonefile may be needed. */ - if (ret == KNOT_EAGAIN) { + if (ret == KNOTDEAGAIN) { /* Cancel sync timer. */ event_t *tmr = zd->ixfr_dbsync; @@ -1744,7 +1744,7 @@ int zones_store_changesets(knot_ns_xfr_t *xfr) /* Synchronize. */ debug_knot_xfr("ixfr_db: forcing zonefile SYNC\n"); ret = zones_zonefile_sync(zone); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { continue; } @@ -1770,13 +1770,13 @@ int zones_store_changesets(knot_ns_xfr_t *xfr) chs->size); } else { /* Other errors. */ - return KNOT_ERROR; + return KNOTDERROR; } } } /* Written changesets to journal. */ - return KNOT_EOK; + return KNOTDEOK; } /*----------------------------------------------------------------------------*/ @@ -1784,7 +1784,7 @@ int zones_store_changesets(knot_ns_xfr_t *xfr) int zones_xfr_load_changesets(knot_ns_xfr_t *xfr) { if (xfr == NULL || xfr->data == NULL || xfr->zone == NULL) { - return KNOT_EINVAL; + return KNOTDEINVAL; } const knot_zone_t *zone = xfr->zone; @@ -1795,7 +1795,7 @@ int zones_xfr_load_changesets(knot_ns_xfr_t *xfr) const knot_rrset_t *zone_soa = knot_node_rrset(knot_zone_contents_apex(contents), - DNSLIB_RRTYPE_SOA); + KNOT_RRTYPE_SOA); // retrieve origin (xfr) serial and target (zone) serial uint32_t zone_serial = knot_rdata_soa_serial( knot_rrset_rdata(zone_soa)); @@ -1803,12 +1803,12 @@ int zones_xfr_load_changesets(knot_ns_xfr_t *xfr) knot_packet_authority_rrset(xfr->query, 0))); int ret = zones_load_changesets(zone, chgsets, xfr_serial, zone_serial); - if (ret != KNOT_EOK) { + if (ret != KNOTDEOK) { return ret; } xfr->data = chgsets; - return KNOT_EOK; + return KNOTDEOK; } /*----------------------------------------------------------------------------*/ @@ -1816,7 +1816,7 @@ int zones_xfr_load_changesets(knot_ns_xfr_t *xfr) int zones_apply_changesets(knot_ns_xfr_t *xfr) { if (xfr == NULL || xfr->zone == NULL || xfr->data == NULL) { - return KNOT_EINVAL; + return KNOTDEINVAL; } return xfrin_apply_changesets_to_zone(xfr->zone, diff --git a/src/knot/server/zones.h b/src/knot/server/zones.h index 77731757b5cbf0b6cfcb8e4c8ce461f83988d544..4f4b9a8bdfb52d6e3e545a5b8b03e14b535afd73 100644 --- a/src/knot/server/zones.h +++ b/src/knot/server/zones.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_ZONES_H_ -#define _KNOT_ZONES_H_ +#ifndef _KNOTDZONES_H_ +#define _KNOTDZONES_H_ #include "common/lists.h" #include "common/acl.h" @@ -85,9 +85,9 @@ typedef enum xfr_type_t { * \param[out] db_old Old database, containing only zones which should be * deleted afterwards. * - * \retval KNOT_EOK - * \retval KNOT_EINVAL - * \retval KNOT_ERROR + * \retval KNOTDEOK + * \retval KNOTDEINVAL + * \retval KNOTDERROR */ int zones_update_db_from_config(const conf_t *conf, knot_nameserver_t *ns, knot_zonedb_t **db_old); @@ -102,9 +102,9 @@ int zones_update_db_from_config(const conf_t *conf, knot_nameserver_t *ns, * * \param zone Evaluated zone. * - * \retval KNOT_EOK if successful. - * \retval KNOT_EINVAL on invalid parameter. - * \retval KNOT_ERROR on unspecified error during processing. + * \retval KNOTDEOK if successful. + * \retval KNOTDEINVAL on invalid parameter. + * \retval KNOTDERROR on unspecified error during processing. */ int zones_zonefile_sync(knot_zone_t *zone); @@ -120,9 +120,9 @@ int zones_xfr_check_zone(knot_ns_xfr_t *xfr, knot_rcode_t *rcode); * \param rsize Input: maximum acceptable size of the response. Output: real * size of the response. * - * \retval KNOT_EOK if a valid response was created. - * \retval KNOT_EINVAL on invalid parameters or packet. - * \retval KNOT_EMALF if an error occured and the response is not valid. + * \retval KNOTDEOK if a valid response was created. + * \retval KNOTDEINVAL on invalid parameters or packet. + * \retval KNOTDEMALF if an error occured and the response is not valid. */ int zones_process_response(knot_nameserver_t *nameserver, sockaddr_t *from, @@ -149,9 +149,9 @@ int zones_save_zone(const knot_ns_xfr_t *xfr); * \param conf Current configuration. * \param data Instance of the nameserver structure to update. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL - * \retval KNOT_ERROR + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL + * \retval KNOTDERROR */ int zones_ns_conf_hook(const struct conf_t *conf, void *data); @@ -164,9 +164,9 @@ int zones_ns_conf_hook(const struct conf_t *conf, void *data); * \param zone Zone associated with the changeset. * \param src Changesets. * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. - * \retval KNOT_EAGAIN if journal needs to be synced with zonefile first. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. + * \retval KNOTDEAGAIN if journal needs to be synced with zonefile first. * * \todo Expects the xfr structure to be initialized in some way. */ @@ -178,7 +178,7 @@ int zones_store_changesets(knot_ns_xfr_t *xfr); * Changesets will be stored on a permanent storage. * Journal may be compacted, resulting in flattening changeset history. * - * In case of KNOT_ERANGE error, whole zone content should be sent instead, + * In case of KNOTDERANGE error, whole zone content should be sent instead, * as the changeset history cannot be recovered. * * \param zone Zone containing a changeset journal. @@ -186,9 +186,9 @@ int zones_store_changesets(knot_ns_xfr_t *xfr); * \param from Starting SOA serial (oldest). * \param to Ending SOA serial (newest). * - * \retval KNOT_EOK on success. - * \retval KNOT_EINVAL on invalid parameters. - * \retval KNOT_ERANGE when changeset history cannot be reconstructed. + * \retval KNOTDEOK on success. + * \retval KNOTDEINVAL on invalid parameters. + * \retval KNOTDERANGE when changeset history cannot be reconstructed. * * \todo Expects the xfr structure to be initialized in some way. */ @@ -203,11 +203,11 @@ int zones_xfr_load_changesets(knot_ns_xfr_t *xfr); * \param zone Zone to which the changesets should be applied. * \param chsets Changesets to be applied to the zone. * - * \retval KNOT_EOK - * \retval KNOT_EINVAL + * \retval KNOTDEOK + * \retval KNOTDEINVAL */ int zones_apply_changesets(knot_ns_xfr_t *xfr); -#endif // _KNOT_ZONES_H_ +#endif // _KNOTDZONES_H_ /*! @} */ diff --git a/src/knot/stat/gatherer.h b/src/knot/stat/gatherer.h index a610fdcd61ac52e4fa542af3966cf71c64345a17..f3894fc6155a221fa379dcf97e71b4e9007e07cb 100644 --- a/src/knot/stat/gatherer.h +++ b/src/knot/stat/gatherer.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_GATHERER_H_ -#define _KNOT_GATHERER_H_ +#ifndef _KNOTDGATHERER_H_ +#define _KNOTDGATHERER_H_ #include <stdint.h> @@ -90,6 +90,6 @@ gatherer_t *new_gatherer(); */ void gatherer_free(gatherer_t *gatherer); -#endif /* _KNOT_STAT_GATHERER_H_ */ +#endif /* _KNOTDSTAT_GATHERER_H_ */ /*! @} */ diff --git a/src/knot/stat/stat-common.h b/src/knot/stat/stat-common.h index 1f698fef2082d3c2ac490cdeffdeb143b326ca31..5c76d7860dd3172250e954b1f974250074da5848 100644 --- a/src/knot/stat/stat-common.h +++ b/src/knot/stat/stat-common.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_STAT_COMMON_H_ -#define _KNOT_STAT_COMMON_H_ +#ifndef _KNOTDSTAT_COMMON_H_ +#define _KNOTDSTAT_COMMON_H_ #include <stdio.h> @@ -26,6 +26,6 @@ #define debug_st(msg...) #endif -#endif /* _KNOT_STAT_COMMON_H_ */ +#endif /* _KNOTDSTAT_COMMON_H_ */ /*! @} */ diff --git a/src/knot/stat/stat.h b/src/knot/stat/stat.h index 602d2e55e5a2764ba7badcac7514e94e944bf08a..8104c67bbab46ad29a939ea4d7235148683e80ee 100644 --- a/src/knot/stat/stat.h +++ b/src/knot/stat/stat.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_STAT_H_ -#define _KNOT_STAT_H_ +#ifndef _KNOTDSTAT_H_ +#define _KNOTDSTAT_H_ #include <time.h> #include <stdbool.h> @@ -137,6 +137,6 @@ void stat_static_gath_free(); static inline void stat_static_gath_free() {} #endif /* STAT_COMPILE */ -#endif /* _KNOT_STAT_H_ */ +#endif /* _KNOTDSTAT_H_ */ /*! @} */ diff --git a/src/tests/common/acl_tests.h b/src/tests/common/acl_tests.h index 18c73cd0e6f748491994e6ac657ce1a4fb770794..ea745e927f4a7c0185cd79bdaf987252d183bea5 100644 --- a/src/tests/common/acl_tests.h +++ b/src/tests/common/acl_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_ACL_TESTS_H_ -#define _KNOT_ACL_TESTS_H_ +#ifndef _KNOTDACL_TESTS_H_ +#define _KNOTDACL_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api acl_tests_api; -#endif /* _KNOT_ACL_TESTS_H_ */ +#endif /* _KNOTDACL_TESTS_H_ */ diff --git a/src/tests/common/da_tests.h b/src/tests/common/da_tests.h index 5237ce20155e0b18b5eff9e5e5284f545a6765c1..38f1a10c6bae7d457fcef80e49bad71aee4858b2 100644 --- a/src/tests/common/da_tests.h +++ b/src/tests/common/da_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_DA_TESTS_H_ -#define _KNOT_DA_TESTS_H_ +#ifndef _KNOTDDA_TESTS_H_ +#define _KNOTDDA_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api da_tests_api; -#endif /* _KNOT_DA_TESTS_H_ */ +#endif /* _KNOTDDA_TESTS_H_ */ diff --git a/src/tests/common/events_tests.h b/src/tests/common/events_tests.h index edb55df0cba4629a49e98fe5cc0d4fdf6d8e4d1d..0f7b1c09bc0dff38a89161f032eea373089f8d0c 100644 --- a/src/tests/common/events_tests.h +++ b/src/tests/common/events_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_EVENTS_TESTS_H_ -#define _KNOT_EVENTS_TESTS_H_ +#ifndef _KNOTDEVENTS_TESTS_H_ +#define _KNOTDEVENTS_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api events_tests_api; -#endif /* _KNOT_EVENTS_TESTS_H_ */ +#endif /* _KNOTDEVENTS_TESTS_H_ */ diff --git a/src/tests/common/skiplist_tests.h b/src/tests/common/skiplist_tests.h index e18ff80bf4869e443545c9209507040715fd8f98..74fb15c0ddfa9c33a588935b637ae795018c8116 100644 --- a/src/tests/common/skiplist_tests.h +++ b/src/tests/common/skiplist_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_SKIPLIST_TESTS_H_ -#define _KNOT_SKIPLIST_TESTS_H_ +#ifndef _KNOTDSKIPLIST_TESTS_H_ +#define _KNOTDSKIPLIST_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api skiplist_tests_api; -#endif /* _KNOT_SKIPLIST_TESTS_H_ */ +#endif /* _KNOTDSKIPLIST_TESTS_H_ */ diff --git a/src/tests/common/slab_tests.h b/src/tests/common/slab_tests.h index d8cb23089a31e859f4bc3183ef09314c82ad24b2..603c68543c23a5cadf8445d19bde3be4ee4790d4 100644 --- a/src/tests/common/slab_tests.h +++ b/src/tests/common/slab_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_SLAB_TESTS_H_ -#define _KNOT_SLAB_TESTS_H_ +#ifndef _KNOTDSLAB_TESTS_H_ +#define _KNOTDSLAB_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api slab_tests_api; -#endif /* _KNOT_SLAB_TESTS_H_ */ +#endif /* _KNOTDSLAB_TESTS_H_ */ diff --git a/src/tests/knot/conf_tests.h b/src/tests/knot/conf_tests.h index 7069dd7dd60f8ef3e403fc7639c8e4a9cb2a532b..8a7e7d795e72286ef1aec55267c9625400bdd59e 100644 --- a/src/tests/knot/conf_tests.h +++ b/src/tests/knot/conf_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_CONF_TESTS_H_ -#define _KNOT_CONF_TESTS_H_ +#ifndef _KNOTDCONF_TESTS_H_ +#define _KNOTDCONF_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api conf_tests_api; -#endif /* _KNOT_CONF_TESTS_H_ */ +#endif /* _KNOTDCONF_TESTS_H_ */ diff --git a/src/tests/knot/dthreads_tests.h b/src/tests/knot/dthreads_tests.h index 933700261f9831b507e9489aac5f10cf8a2efff1..a31a9cde535473014f1aae546fdc6a93484f72ae 100644 --- a/src/tests/knot/dthreads_tests.h +++ b/src/tests/knot/dthreads_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_DTHREADS_TESTS_H_ -#define _KNOT_DTHREADS_TESTS_H_ +#ifndef _KNOTDDTHREADS_TESTS_H_ +#define _KNOTDDTHREADS_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api dthreads_tests_api; -#endif /* _KNOT_DTHREADS_TESTS_H_ */ +#endif /* _KNOTDDTHREADS_TESTS_H_ */ diff --git a/src/tests/knot/journal_tests.c b/src/tests/knot/journal_tests.c index 82b268bf37b9f88afc1926609ed3769b8eca28af..449b1610bb0cf119043b2c6bbd4f0bee3bef2023 100644 --- a/src/tests/knot/journal_tests.c +++ b/src/tests/knot/journal_tests.c @@ -52,7 +52,7 @@ static int journal_tests_run(int argc, char *argv[]) /* Test 2: Create journal. */ const char *jfilename = jfn_buf; int ret = journal_create(jfilename, jsize); - ok(ret == KNOT_EOK, "journal: create journal '%s'", jfilename); + ok(ret == KNOTDEOK, "journal: create journal '%s'", jfilename); /* Test 3: Open journal. */ journal_t *j = journal_open(jfilename, fsize, 0); @@ -61,12 +61,12 @@ static int journal_tests_run(int argc, char *argv[]) /* Test 4: Write entry to log. */ const char *sample = "deadbeef"; ret = journal_write(j, 0x0a, sample, strlen(sample)); - ok(ret == KNOT_EOK, "journal: write"); + ok(ret == KNOTDEOK, "journal: write"); /* Test 5: Read entry from log. */ char tmpbuf[64] = {'\0'}; ret = journal_read(j, 0x0a, 0, tmpbuf); - ok(ret == KNOT_EOK, "journal: read entry"); + ok(ret == KNOTDEOK, "journal: read entry"); /* Test 6: Compare read data. */ ret = strncmp(sample, tmpbuf, strlen(sample)); @@ -80,7 +80,7 @@ static int journal_tests_run(int argc, char *argv[]) for (int i = 0; i < itcount; ++i) { int key = rand() % 65535; randstr(tmpbuf, sizeof(tmpbuf)); - if (journal_write(j, key, tmpbuf, sizeof(tmpbuf)) != KNOT_EOK) { + if (journal_write(j, key, tmpbuf, sizeof(tmpbuf)) != KNOTDEOK) { ret = -1; break; } diff --git a/src/tests/knot/journal_tests.h b/src/tests/knot/journal_tests.h index be1d3c48ec6d66ee6876c73d4d31131a6ea661fb..f5e4b20432e4f17d1a7117a7b993e9308f3d557d 100644 --- a/src/tests/knot/journal_tests.h +++ b/src/tests/knot/journal_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_JOURNAL_TESTS_H_ -#define _KNOT_JOURNAL_TESTS_H_ +#ifndef _KNOTDJOURNAL_TESTS_H_ +#define _KNOTDJOURNAL_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api journal_tests_api; -#endif /* _KNOT_JOURNAL_TESTS_H_ */ +#endif /* _KNOTDJOURNAL_TESTS_H_ */ diff --git a/src/tests/knot/server_tests.h b/src/tests/knot/server_tests.h index 41f639e727de39668f5c7a20de635da92b5a4353..a1994ac2eb563a58a8817b8630ed7f22be801585 100644 --- a/src/tests/knot/server_tests.h +++ b/src/tests/knot/server_tests.h @@ -1,9 +1,9 @@ -#ifndef _KNOT_SERVER_TESTS_H_ -#define _KNOT_SERVER_TESTS_H_ +#ifndef _KNOTDSERVER_TESTS_H_ +#define _KNOTDSERVER_TESTS_H_ #include "common/libtap/tap_unit.h" /* Unit API. */ unit_api server_tests_api; -#endif /* _KNOT_SERVER_TESTS_H_ */ +#endif /* _KNOTDSERVER_TESTS_H_ */ diff --git a/src/zcompile/parser-descriptor.h b/src/zcompile/parser-descriptor.h index 182fb3e7275915eb37bcb03b0665144fe8821700..05fb12b3f5d8ef83542ef0d52045accdefcc0b60 100644 --- a/src/zcompile/parser-descriptor.h +++ b/src/zcompile/parser-descriptor.h @@ -9,8 +9,8 @@ * @{ */ -#ifndef _KNOT_PARSER_DESCRIPTOR_H_ -#define _KNOT_PARSER_DESCRIPTOR_H_ +#ifndef _KNOTDPARSER_DESCRIPTOR_H_ +#define _KNOTDPARSER_DESCRIPTOR_H_ #include <stdint.h> #include <stdbool.h> @@ -237,6 +237,6 @@ const char *parser_rrclass_to_string(uint16_t rrclass); */ uint16_t parser_rrclass_from_string(const char *name); -#endif /* _KNOT_PARSER_DESCRIPTOR_H_ */ +#endif /* _KNOTDPARSER_DESCRIPTOR_H_ */ /*! @} */ diff --git a/src/zcompile/parser-util.h b/src/zcompile/parser-util.h index 8d4b2503f395ac534b625580e0c5ffee9def6d87..f553fe53bd7442de46007ce1152ffd999e64cc6a 100644 --- a/src/zcompile/parser-util.h +++ b/src/zcompile/parser-util.h @@ -11,8 +11,8 @@ * @{ */ -#ifndef _KNOT_PARSER_UTIL_H_ -#define _KNOT_PARSER_UTIL_H_ +#ifndef _KNOTDPARSER_UTIL_H_ +#define _KNOTDPARSER_UTIL_H_ #include <assert.h> #include <fcntl.h> @@ -45,6 +45,6 @@ uint32_t strtoserial(const char *nptr, const char **endptr); void write_uint32(void *dst, uint32_t data); uint32_t strtottl(const char *nptr, const char **endptr); time_t mktime_from_utc(const struct tm *tm); -#endif /* _KNOT_PARSER_UTIL_H_ */ +#endif /* _KNOTDPARSER_UTIL_H_ */ /*! @} */ diff --git a/src/zcompile/tests/zcompile_tests.c b/src/zcompile/tests/zcompile_tests.c index 1163c3fcef4e3f66f0bf6d3a3534b4098a15e9c7..04aec9370f9e339d1b7e13544ff84439366ae928 100644 --- a/src/zcompile/tests/zcompile_tests.c +++ b/src/zcompile/tests/zcompile_tests.c @@ -44,9 +44,9 @@ static int compare_rr_rdata_silent(knot_rdata_t *rdata, ldns_rr *rr, knot_rrtype_descriptor_by_type(type); for (int i = 0; i < rdata->count; i++) { /* TODO check for ldns "descriptors" as well */ - if (desc->wireformat[i] == DNSLIB_RDATA_WF_COMPRESSED_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_LITERAL_DNAME || - desc->wireformat[i] == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME) { + if (desc->wireformat[i] == KNOT_RDATA_WF_COMPRESSED_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_LITERAL_DNAME || + desc->wireformat[i] == KNOT_RDATA_WF_UNCOMPRESSED_DNAME) { assert(ldns_rr_rdf(rr, i)); if (rdata->items[i].dname->size != ldns_rdf_size(ldns_rr_rdf(rr, i))) { @@ -243,7 +243,7 @@ int compare_zones(knot_zone_t *zone, ldns_rr_list *ldns_list, char verbose) if (tmp_rrset == NULL && (uint)(ldns_rr_get_type(ldns_rr_list_rr(ldns_rrset, 0))) != - (uint)DNSLIB_RRTYPE_RRSIG) { + (uint)KNOT_RRTYPE_RRSIG) { diag("Could not find rrset"); if (!verbose) { return 1; @@ -253,7 +253,7 @@ int compare_zones(knot_zone_t *zone, ldns_rr_list *ldns_list, char verbose) return 1; } else if ((uint)(ldns_rr_get_type(ldns_rr_list_rr(ldns_rrset, 0))) == - (uint)DNSLIB_RRTYPE_RRSIG) { + (uint)KNOT_RRTYPE_RRSIG) { knot_rrset_t *rrsigs = NULL; /* read type covered from ldns rrset */ for (int i = 0; i < ldns_rrset->_rr_count; i++) { diff --git a/src/zcompile/zcompile-error.c b/src/zcompile/zcompile-error.c index fa9df103464c4431c57fedc53addb947379196fb..756c5983f143acc9be8d0b1ba13d09f395ae4502 100644 --- a/src/zcompile/zcompile-error.c +++ b/src/zcompile/zcompile-error.c @@ -3,34 +3,34 @@ #include "common/errors.h" /*! \brief Table linking error messages to error codes. */ -const error_table_t knot_zcompile_error_msgs[KNOT_ZCOMPILE_ERROR_COUNT] = { +const error_table_t knot_zcompile_error_msgs[KNOTDZCOMPILE_ERROR_COUNT] = { /* Mapped errors. */ - {KNOT_ZCOMPILE_EOK, "OK"}, - {KNOT_ZCOMPILE_ENOMEM, "Not enough memory."}, - {KNOT_ZCOMPILE_EINVAL, "Invalid parameter passed."}, - {KNOT_ZCOMPILE_ENOTSUP, "Parameter not supported."}, - {KNOT_ZCOMPILE_EBUSY, "Requested resource is busy."}, - {KNOT_ZCOMPILE_EAGAIN, + {KNOTDZCOMPILE_EOK, "OK"}, + {KNOTDZCOMPILE_ENOMEM, "Not enough memory."}, + {KNOTDZCOMPILE_EINVAL, "Invalid parameter passed."}, + {KNOTDZCOMPILE_ENOTSUP, "Parameter not supported."}, + {KNOTDZCOMPILE_EBUSY, "Requested resource is busy."}, + {KNOTDZCOMPILE_EAGAIN, "The system lacked the necessary resource, try again."}, - {KNOT_ZCOMPILE_EACCES, + {KNOTDZCOMPILE_EACCES, "Permission to perform requested operation is denied."}, - {KNOT_ZCOMPILE_ECONNREFUSED, "Connection is refused."}, - {KNOT_ZCOMPILE_EISCONN, "Already connected."}, - {KNOT_ZCOMPILE_EADDRINUSE, "Address already in use."}, - {KNOT_ZCOMPILE_ENOENT, "Resource not found."}, - {KNOT_ZCOMPILE_ERANGE, "Value is out of range."}, + {KNOTDZCOMPILE_ECONNREFUSED, "Connection is refused."}, + {KNOTDZCOMPILE_EISCONN, "Already connected."}, + {KNOTDZCOMPILE_EADDRINUSE, "Address already in use."}, + {KNOTDZCOMPILE_ENOENT, "Resource not found."}, + {KNOTDZCOMPILE_ERANGE, "Value is out of range."}, /* Custom errors. */ - {KNOT_ZCOMPILE_ERROR, "Generic error."}, - {KNOT_ZCOMPILE_EBRDATA, "Malformed RDATA."}, - {KNOT_ZCOMPILE_ESOA, "Multiple SOA records."}, - {KNOT_ZCOMPILE_EBADSOA, "SOA record has different owner " + {KNOTDZCOMPILE_ERROR, "Generic error."}, + {KNOTDZCOMPILE_EBRDATA, "Malformed RDATA."}, + {KNOTDZCOMPILE_ESOA, "Multiple SOA records."}, + {KNOTDZCOMPILE_EBADSOA, "SOA record has different owner " "than in config - parser will not continue!"}, - {KNOT_ZCOMPILE_EBADNODE, "Error handling node."}, - {KNOT_ZCOMPILE_EZONEINVAL, "Invalid zone file."}, - {KNOT_ZCOMPILE_EPARSEFAIL, "Parser failed."}, - {KNOT_ZCOMPILE_ENOIPV6, "IPv6 support disabled."}, - {KNOT_ZCOMPILE_ESYNT, "Parser syntactic error."}, - {KNOT_ZCOMPILE_ERROR, 0} + {KNOTDZCOMPILE_EBADNODE, "Error handling node."}, + {KNOTDZCOMPILE_EZONEINVAL, "Invalid zone file."}, + {KNOTDZCOMPILE_EPARSEFAIL, "Parser failed."}, + {KNOTDZCOMPILE_ENOIPV6, "IPv6 support disabled."}, + {KNOTDZCOMPILE_ESYNT, "Parser syntactic error."}, + {KNOTDZCOMPILE_ERROR, 0} }; diff --git a/src/zcompile/zcompile-error.h b/src/zcompile/zcompile-error.h index 3a3056fcc1e24e2c87e4e8f99e7698d49cb15590..670ddcb61429b83a83dced98c3f5d213d42a64ec 100644 --- a/src/zcompile/zcompile-error.h +++ b/src/zcompile/zcompile-error.h @@ -11,8 +11,8 @@ * @{ */ -#ifndef _KNOT_ZCOMPILE_ERROR_H_ -#define _KNOT_ZCOMPILE_ERROR_H_ +#ifndef _KNOTDZCOMPILE_ERROR_H_ +#define _KNOTDZCOMPILE_ERROR_H_ #include "common/errors.h" @@ -25,51 +25,51 @@ enum knot_zcompile_error { /* Directly mapped error codes. */ - KNOT_ZCOMPILE_EOK = 0, - KNOT_ZCOMPILE_ENOMEM = -ENOMEM, /*!< \brief Out of memory. */ - KNOT_ZCOMPILE_EINVAL = -EINVAL, /*!< \brief Invalid parameter passed. */ + KNOTDZCOMPILE_EOK = 0, + KNOTDZCOMPILE_ENOMEM = -ENOMEM, /*!< \brief Out of memory. */ + KNOTDZCOMPILE_EINVAL = -EINVAL, /*!< \brief Invalid parameter passed. */ /*! * \brief Parameter not supported. */ - KNOT_ZCOMPILE_ENOTSUP = -ENOTSUP, - KNOT_ZCOMPILE_EBUSY = -EBUSY, /*!< \brief Requested resource is busy. */ + KNOTDZCOMPILE_ENOTSUP = -ENOTSUP, + KNOTDZCOMPILE_EBUSY = -EBUSY, /*!< \brief Requested resource is busy. */ /*! * \brief OS lacked necessary resources. */ - KNOT_ZCOMPILE_EAGAIN = -EAGAIN, - KNOT_ZCOMPILE_EACCES = -EACCES, /*!< \brief Permission is denied. */ + KNOTDZCOMPILE_EAGAIN = -EAGAIN, + KNOTDZCOMPILE_EACCES = -EACCES, /*!< \brief Permission is denied. */ /*! * \brief Connection is refused. */ - KNOT_ZCOMPILE_ECONNREFUSED = -ECONNREFUSED, - KNOT_ZCOMPILE_EISCONN = -EISCONN, /*!< \brief Already connected. */ + KNOTDZCOMPILE_ECONNREFUSED = -ECONNREFUSED, + KNOTDZCOMPILE_EISCONN = -EISCONN, /*!< \brief Already connected. */ /*! * \brief Address already in use. */ - KNOT_ZCOMPILE_EADDRINUSE = -EADDRINUSE, - KNOT_ZCOMPILE_ENOENT = -ENOENT, /*!< \brief Resource not found. */ - KNOT_ZCOMPILE_ERANGE = -ERANGE, /*!< \brief Value is out of range. */ + KNOTDZCOMPILE_EADDRINUSE = -EADDRINUSE, + KNOTDZCOMPILE_ENOENT = -ENOENT, /*!< \brief Resource not found. */ + KNOTDZCOMPILE_ERANGE = -ERANGE, /*!< \brief Value is out of range. */ /* Custom error codes. */ - KNOT_ZCOMPILE_ERROR = -16384, /*!< \brief Generic error. */ - KNOT_ZCOMPILE_ESYNT, /*!< \brief Syntax error. */ - KNOT_ZCOMPILE_EBADNODE, /*!< \brief Node error. */ - KNOT_ZCOMPILE_EBRDATA, /*!< \brief RDATA error. */ - KNOT_ZCOMPILE_EBADSOA, /*!< \brief SOA owner error. */ - KNOT_ZCOMPILE_ESOA, /*!< \brief Multiple SOA records. */ + KNOTDZCOMPILE_ERROR = -16384, /*!< \brief Generic error. */ + KNOTDZCOMPILE_ESYNT, /*!< \brief Syntax error. */ + KNOTDZCOMPILE_EBADNODE, /*!< \brief Node error. */ + KNOTDZCOMPILE_EBRDATA, /*!< \brief RDATA error. */ + KNOTDZCOMPILE_EBADSOA, /*!< \brief SOA owner error. */ + KNOTDZCOMPILE_ESOA, /*!< \brief Multiple SOA records. */ - KNOT_ZCOMPILE_EZONEINVAL, /*!< \brief Invalid zone file. */ - KNOT_ZCOMPILE_EPARSEFAIL, /*!< \brief Parser fail. */ - KNOT_ZCOMPILE_ENOIPV6, /*! \brief No IPv6 support. */ + KNOTDZCOMPILE_EZONEINVAL, /*!< \brief Invalid zone file. */ + KNOTDZCOMPILE_EPARSEFAIL, /*!< \brief Parser fail. */ + KNOTDZCOMPILE_ENOIPV6, /*! \brief No IPv6 support. */ - KNOT_ZCOMPILE_ERROR_COUNT = 22 + KNOTDZCOMPILE_ERROR_COUNT = 22 }; typedef enum knot_zcompile_error knot_zcompile_error_t; /*! \brief Table linking error messages to error codes. */ -extern const error_table_t knot_zcompile_error_msgs[KNOT_ZCOMPILE_ERROR_COUNT]; +extern const error_table_t knot_zcompile_error_msgs[KNOTDZCOMPILE_ERROR_COUNT]; -#endif /* _KNOT_ZCOMPILE_ERROR_H_ */ +#endif /* _KNOTDZCOMPILE_ERROR_H_ */ /*! @} */ diff --git a/src/zcompile/zcompile.c b/src/zcompile/zcompile.c index 37a79b9b65aecfd485a85f4cb6271d29c41052c8..47eb9a2169e83fc183992c848d30f8811ffb0b41 100644 --- a/src/zcompile/zcompile.c +++ b/src/zcompile/zcompile.c @@ -144,9 +144,9 @@ static inline int rdata_atom_is_domain(uint16_t type, size_t index) = knot_rrtype_descriptor_by_type(type); return (index < descriptor->length && (descriptor->wireformat[index] == - DNSLIB_RDATA_WF_COMPRESSED_DNAME || + KNOT_RDATA_WF_COMPRESSED_DNAME || descriptor->wireformat[index] == - DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME)); + KNOT_RDATA_WF_UNCOMPRESSED_DNAME)); } /*! @@ -212,26 +212,26 @@ static ssize_t rdata_wireformat_to_rdata_atoms(const uint16_t *wireformat, int required = descriptor->length; switch (rdata_atom_wireformat_type(rrtype, i)) { - case DNSLIB_RDATA_WF_COMPRESSED_DNAME: - case DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME: + case KNOT_RDATA_WF_COMPRESSED_DNAME: + case KNOT_RDATA_WF_UNCOMPRESSED_DNAME: is_domain = 1; is_normalized = 1; break; - case DNSLIB_RDATA_WF_LITERAL_DNAME: + case KNOT_RDATA_WF_LITERAL_DNAME: is_domain = 1; is_wirestore = 1; break; - case DNSLIB_RDATA_WF_BYTE: + case KNOT_RDATA_WF_BYTE: length = sizeof(uint8_t); break; - case DNSLIB_RDATA_WF_SHORT: + case KNOT_RDATA_WF_SHORT: length = sizeof(uint16_t); break; - case DNSLIB_RDATA_WF_LONG: + case KNOT_RDATA_WF_LONG: length = sizeof(uint32_t); break; - case DNSLIB_RDATA_WF_TEXT: - case DNSLIB_RDATA_WF_BINARYWITHLENGTH: + case KNOT_RDATA_WF_TEXT: + case KNOT_RDATA_WF_BINARYWITHLENGTH: /* Length is stored in the first byte. */ length = 1; if ((uint8_t *)wireformat + length <= (uint8_t *)end) { @@ -244,13 +244,13 @@ static ssize_t rdata_wireformat_to_rdata_atoms(const uint16_t *wireformat, length += buffer_current(packet)[length - 1]; }*/ break; - case DNSLIB_RDATA_WF_A: + case KNOT_RDATA_WF_A: length = sizeof(in_addr_t); break; - case DNSLIB_RDATA_WF_AAAA: + case KNOT_RDATA_WF_AAAA: length = IP6ADDRLEN; break; - case DNSLIB_RDATA_WF_BINARY: + case KNOT_RDATA_WF_BINARY: /* Remaining RDATA is binary. */ dbg_rdata("%d: guessing length from pointers: %p %p\n", i, @@ -258,7 +258,7 @@ static ssize_t rdata_wireformat_to_rdata_atoms(const uint16_t *wireformat, length = (uint8_t *)end - (uint8_t *)wireformat; // length = end - buffer_position(packet); break; - case DNSLIB_RDATA_WF_APL: + case KNOT_RDATA_WF_APL: length = (sizeof(uint16_t) /* address family */ + sizeof(uint8_t) /* prefix */ + sizeof(uint8_t)); /* length */ @@ -268,7 +268,7 @@ static ssize_t rdata_wireformat_to_rdata_atoms(const uint16_t *wireformat, & APL_LENGTH_MASK); } break; - case DNSLIB_RDATA_WF_IPSECGATEWAY: + case KNOT_RDATA_WF_IPSECGATEWAY: switch (rdata_atom_data(temp_rdatas[1])[0]) { /* gateway type */ default: @@ -306,7 +306,7 @@ static ssize_t rdata_wireformat_to_rdata_atoms(const uint16_t *wireformat, if (dname == NULL) { dbg_rdata("malformed dname!\n"); - return KNOT_ZCOMPILE_EBRDATA; + return KNOTDZCOMPILE_EBRDATA; } dbg_rdata("%d: created dname: %s\n", i, knot_dname_to_str(dname)); @@ -324,7 +324,7 @@ static ssize_t rdata_wireformat_to_rdata_atoms(const uint16_t *wireformat, if (temp_rdatas[i].raw_data == NULL) { ERR_ALLOC_FAILED; - return KNOT_ZCOMPILE_ENOMEM; + return KNOTDZCOMPILE_ENOMEM; } temp_rdatas[i].raw_data[0] = dname->size; @@ -344,7 +344,7 @@ static ssize_t rdata_wireformat_to_rdata_atoms(const uint16_t *wireformat, if (required) { /* Truncated RDATA. */ dbg_rdata("truncated rdata\n"); - return KNOT_ZCOMPILE_EBRDATA; + return KNOTDZCOMPILE_EBRDATA; } else { break; } @@ -387,7 +387,7 @@ static ssize_t rdata_wireformat_to_rdata_atoms(const uint16_t *wireformat, /* Trailing garbage. */ dbg_rdata("w: %p e: %p %d\n", wireformat, end, end - wireformat); // region_destroy(temp_region); - return KNOT_ZCOMPILE_EBRDATA; + return KNOTDZCOMPILE_EBRDATA; } *items = temp_rdatas; @@ -1467,7 +1467,7 @@ static int find_rrset_for_rrsig_in_zone(knot_zone_contents_t *zone, knot_node_t *tmp_node = NULL; - if (rrsig->type != DNSLIB_RRTYPE_NSEC3) { + if (rrsig->type != KNOT_RRTYPE_NSEC3) { tmp_node = knot_zone_contents_get_node(zone, rrsig->owner); } else { tmp_node = knot_zone_contents_get_nsec3_node(zone, @@ -1475,26 +1475,26 @@ static int find_rrset_for_rrsig_in_zone(knot_zone_contents_t *zone, } if (tmp_node == NULL) { - return KNOT_ZCOMPILE_EINVAL; + return KNOTDZCOMPILE_EINVAL; } knot_rrset_t *tmp_rrset = knot_node_get_rrset(tmp_node, rrsig->type); if (tmp_rrset == NULL) { - return KNOT_ZCOMPILE_EINVAL; + return KNOTDZCOMPILE_EINVAL; } if (tmp_rrset->rrsigs != NULL) { knot_zone_contents_add_rrsigs(zone, rrsig, &tmp_rrset, &tmp_node, - DNSLIB_RRSET_DUPL_MERGE, 1); + KNOT_RRSET_DUPL_MERGE, 1); knot_rrset_free(&rrsig); } else { knot_zone_contents_add_rrsigs(zone, rrsig, &tmp_rrset, &tmp_node, - DNSLIB_RRSET_DUPL_SKIP, 1); + KNOT_RRSET_DUPL_SKIP, 1); } - return KNOT_ZCOMPILE_EOK; + return KNOTDZCOMPILE_EOK; } static int find_rrset_for_rrsig_in_node(knot_zone_contents_t *zone, @@ -1511,25 +1511,25 @@ static int find_rrset_for_rrsig_in_node(knot_zone_contents_t *zone, knot_node_get_rrset(node, rrsig_type_covered(rrsig)); if (tmp_rrset == NULL) { - return KNOT_ZCOMPILE_EINVAL; + return KNOTDZCOMPILE_EINVAL; } if (tmp_rrset->rrsigs != NULL) { if (knot_zone_contents_add_rrsigs(zone, rrsig, &tmp_rrset, &node, - DNSLIB_RRSET_DUPL_MERGE, 1) < 0) { - return KNOT_ZCOMPILE_EINVAL; + KNOT_RRSET_DUPL_MERGE, 1) < 0) { + return KNOTDZCOMPILE_EINVAL; } knot_rrset_free(&rrsig); } else { if (knot_zone_contents_add_rrsigs(zone, rrsig, &tmp_rrset, &node, - DNSLIB_RRSET_DUPL_SKIP, 1) < 0) { - return KNOT_ZCOMPILE_EINVAL; + KNOT_RRSET_DUPL_SKIP, 1) < 0) { + return KNOTDZCOMPILE_EINVAL; } } assert(tmp_rrset->rrsigs != NULL); - return KNOT_ZCOMPILE_EOK; + return KNOTDZCOMPILE_EOK; } static knot_node_t *create_node(knot_zone_contents_t *zone, @@ -1591,12 +1591,12 @@ int process_rr(void) * to be created in NSEC3 part of the zone */ uint16_t type_covered = 0; - if (current_rrset->type == DNSLIB_RRTYPE_RRSIG) { + if (current_rrset->type == KNOT_RRTYPE_RRSIG) { type_covered = rrsig_type_covered(current_rrset); } - if (current_rrset->type != DNSLIB_RRTYPE_NSEC3 && - type_covered != DNSLIB_RRTYPE_NSEC3) { + if (current_rrset->type != KNOT_RRTYPE_NSEC3 && + type_covered != KNOT_RRTYPE_NSEC3) { node_add_func = &knot_zone_contents_add_node; node_get_func = &knot_zone_contents_get_node; } else { @@ -1604,10 +1604,10 @@ int process_rr(void) node_get_func = &knot_zone_contents_get_nsec3_node; } - if ((current_rrset->type == DNSLIB_RRTYPE_SOA) && (zone != NULL)) { + if ((current_rrset->type == KNOT_RRTYPE_SOA) && (zone != NULL)) { if (knot_node_rrset(knot_zone_contents_apex(contents), - DNSLIB_RRTYPE_SOA) != NULL) { - return KNOT_ZCOMPILE_ESOA; + KNOT_RRTYPE_SOA) != NULL) { + return KNOTDZCOMPILE_ESOA; } } @@ -1624,7 +1624,7 @@ int process_rr(void) // return 0; // } - if (current_rrset->type == DNSLIB_RRTYPE_SOA) { + if (current_rrset->type == KNOT_RRTYPE_SOA) { if (knot_dname_compare(current_rrset->owner, parser->origin->owner) != 0) { fprintf(stderr, "SOA record has a different " @@ -1632,15 +1632,15 @@ int process_rr(void) "in config!\n"); /* Such SOA cannot even be added, because * it would not be in the zone apex. */ - return KNOT_ZCOMPILE_EBADSOA; + return KNOTDZCOMPILE_EBADSOA; } } - if (current_rrset->type == DNSLIB_RRTYPE_RRSIG) { + if (current_rrset->type == KNOT_RRTYPE_RRSIG) { /*!< \todo Still a leak somewhere. */ knot_rrset_t *tmp_rrsig = knot_rrset_new(current_rrset->owner, - DNSLIB_RRTYPE_RRSIG, + KNOT_RRTYPE_RRSIG, current_rrset->rclass, current_rrset->ttl); @@ -1662,21 +1662,21 @@ int process_rr(void) current_rrset, node_add_func, node_get_func)) == NULL) { knot_rrset_free(&tmp_rrsig); - return KNOT_ZCOMPILE_EBADNODE; + return KNOTDZCOMPILE_EBADNODE; } } rrset_list_add(&parser->node_rrsigs, tmp_rrsig); - return KNOT_ZCOMPILE_EOK; + return KNOTDZCOMPILE_EOK; } - assert(current_rrset->type != DNSLIB_RRTYPE_RRSIG); + assert(current_rrset->type != KNOT_RRTYPE_RRSIG); knot_node_t *node; /* \note this could probably be much simpler */ - if (parser->last_node && current_rrset->type != DNSLIB_RRTYPE_SOA && + if (parser->last_node && current_rrset->type != KNOT_RRTYPE_SOA && knot_dname_compare(parser->last_node->owner, current_rrset->owner) == 0) { @@ -1702,7 +1702,7 @@ int process_rr(void) if ((node = create_node(contents, current_rrset, node_add_func, node_get_func)) == NULL) { - return KNOT_ZCOMPILE_EBADNODE; + return KNOTDZCOMPILE_EBADNODE; } } @@ -1717,19 +1717,19 @@ int process_rr(void) if (knot_rrset_add_rdata(rrset, current_rrset->rdata) != 0) { free(rrset); - return KNOT_ZCOMPILE_EBRDATA; + return KNOTDZCOMPILE_EBRDATA; } /* I chose skip, but there should not really be * any rrset to skip */ if (knot_zone_contents_add_rrset(contents, rrset, &node, - DNSLIB_RRSET_DUPL_SKIP, 1) < 0) { + KNOT_RRSET_DUPL_SKIP, 1) < 0) { free(rrset); - return KNOT_ZCOMPILE_EBRDATA; + return KNOTDZCOMPILE_EBRDATA; } } else { if (current_rrset->type != - DNSLIB_RRTYPE_RRSIG && rrset->ttl != + KNOT_RRTYPE_RRSIG && rrset->ttl != current_rrset->ttl) { fprintf(stderr, "TTL does not match the TTL of the RRset"); @@ -1737,9 +1737,9 @@ int process_rr(void) if (knot_zone_contents_add_rrset(contents, current_rrset, &node, - DNSLIB_RRSET_DUPL_MERGE, 1) < 0) { + KNOT_RRSET_DUPL_MERGE, 1) < 0) { free(rrset); - return KNOT_ZCOMPILE_EBRDATA; + return KNOTDZCOMPILE_EBRDATA; } // knot_rrset_merge((void *)&rrset, (void *)¤t_rrset); @@ -1754,20 +1754,20 @@ int process_rr(void) */ // if(current_rrset->type == -// DNSLIB_RRTYPE_DNAME && +// KNOT_RRTYPE_DNAME && // current_rrset->rdata->count > 1) { // fprintf(stderr, "multiple DNAMEs at the same name"); // } // /* \note this actually counts items, not the legth we would need */ // if(current_rrset->type == -// DNSLIB_RRTYPE_CNAME && +// KNOT_RRTYPE_CNAME && // current_rrset->rdata->count > 1) { // fprintf(stderr, "multiple CNAMEs at the same name"); // /* \note this actually counts items, not the legth we would need */ // } -// if((current_rrset->type == DNSLIB_RRTYPE_DNAME && +// if((current_rrset->type == KNOT_RRTYPE_DNAME && // knot_node_get_rrset(node, TYPE_CNAME)) || -// (current_rrset->type == DNSLIB_RRTYPE_CNAME && +// (current_rrset->type == KNOT_RRTYPE_CNAME && // knot_node_get_rrset(node, TYPE_DNAME))) { // fprintf(stderr, "DNAME and CNAME at the same name"); // } @@ -1788,7 +1788,7 @@ int process_rr(void) ++totalrrs; - return KNOT_ZCOMPILE_EOK; + return KNOTDZCOMPILE_EOK; } static uint find_rrsets_orphans(knot_zone_contents_t *zone, rrset_list_t @@ -1840,18 +1840,18 @@ int zone_read(const char *name, const char *zonefile, const char *outfile, void *scanner = NULL; zp_lex_init(&scanner); if (scanner == NULL) { - return KNOT_ZCOMPILE_ENOMEM; + return KNOTDZCOMPILE_ENOMEM; } - if (!zone_open(zonefile, 3600, DNSLIB_CLASS_IN, origin_node, scanner)) { + if (!zone_open(zonefile, 3600, KNOT_CLASS_IN, origin_node, scanner)) { fprintf(stderr, "Cannot open '%s'\n", zonefile); zparser_free(); - return KNOT_ZCOMPILE_EZONEINVAL; + return KNOTDZCOMPILE_EZONEINVAL; } if (zp_parse(scanner) != 0) { - return KNOT_ZCOMPILE_ESYNT; + return KNOTDZCOMPILE_ESYNT; } knot_zone_contents_t *contents = @@ -1875,11 +1875,11 @@ int zone_read(const char *name, const char *zonefile, const char *outfile, if (!(parser->current_zone && knot_node_rrset(parser->current_zone->contents->apex, - DNSLIB_RRTYPE_SOA))) { + KNOT_RRTYPE_SOA))) { fprintf(stderr, "Zone file does not contain SOA record!\n"); knot_zone_deep_free(&parser->current_zone, 0); zparser_free(); - return KNOT_ZCOMPILE_EZONEINVAL; + return KNOTDZCOMPILE_EZONEINVAL; } uint found_orphans; @@ -1920,9 +1920,9 @@ int zone_read(const char *name, const char *zonefile, const char *outfile, // assert(desc); // for (int i = 0; i < rdata->count; i++) { -// if (desc->wireformat[i] == DNSLIB_RDATA_WF_COMPRESSED_DNAME || -// desc->wireformat[i] == DNSLIB_RDATA_WF_UNCOMPRESSED_DNAME || -// desc->wireformat[i] == DNSLIB_RDATA_WF_LITERAL_DNAME) { +// if (desc->wireformat[i] == KNOT_RDATA_WF_COMPRESSED_DNAME || +// desc->wireformat[i] == KNOT_RDATA_WF_UNCOMPRESSED_DNAME || +// desc->wireformat[i] == KNOT_RDATA_WF_LITERAL_DNAME) { // /* See if dname is not in the table already. */ // knot_dname_t *found_dname = NULL; // knot_dname_t *searched_dname = rdata->items[i].dname; @@ -1949,7 +1949,7 @@ int zone_read(const char *name, const char *zonefile, const char *outfile, // knot_rrset_t *rrset) //{ // if (rrset == NULL) { -// return KNOT_ZCOMPILE_EINVAL; +// return KNOTDZCOMPILE_EINVAL; // } // /* Check and possibly delete the owner first */ // knot_dname_t *found_dname = NULL; @@ -1968,7 +1968,7 @@ int zone_read(const char *name, const char *zonefile, const char *outfile, // } else if (found_dname != rrset->owner) { // /* Insert the dname in the table. */ // if (knot_dname_table_add_dname(table, rrset->owner) != 0) { -// return KNOT_ZCOMPILE_ENOMEM; +// return KNOTDZCOMPILE_ENOMEM; // } // } @@ -1984,7 +1984,7 @@ int zone_read(const char *name, const char *zonefile, const char *outfile, // assert(rrset->owner != NULL); -// return KNOT_ZCOMPILE_EOK; +// return KNOTDZCOMPILE_EOK; //} /*! @} */ diff --git a/src/zcompile/zcompile.h b/src/zcompile/zcompile.h index 91f0db9475101edfaa7ed07032c216b0f51eed72..c3e741e9c52115ea37f77b9f96672c54788b91d8 100644 --- a/src/zcompile/zcompile.h +++ b/src/zcompile/zcompile.h @@ -12,8 +12,8 @@ * @{ */ -#ifndef _KNOT_ZONEPARSER_H_ -#define _KNOT_ZONEPARSER_H_ +#ifndef _KNOTDZONEPARSER_H_ +#define _KNOTDZONEPARSER_H_ #include <stdio.h> @@ -433,6 +433,6 @@ void zparser_free(); int save_dnames_in_table(knot_dname_table_t *table, knot_rrset_t *rrset); -#endif /* _KNOT_ZONEPARSER_H_ */ +#endif /* _KNOTDZONEPARSER_H_ */ /*! @} */ diff --git a/src/zcompile/zparser.y b/src/zcompile/zparser.y index ed4f36b4a379a57ac9150d774c7e63fb57d3bbfb..9e64570129e295148a1798e359ea0eab0a506f14 100644 --- a/src/zcompile/zparser.y +++ b/src/zcompile/zparser.y @@ -192,7 +192,7 @@ line: NL parser->current_rrset->type, 0); - if (ret == KNOT_ZCOMPILE_EBADSOA) { + if (ret == KNOTDZCOMPILE_EBADSOA) { /*!< \todo this will crash! */ knot_rdata_free(&tmp_rdata); knot_rrset_deep_free(&(parser->current_rrset),