diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2020-02-24 17:47:51 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2020-02-24 17:47:51 +0000 |
commit | 5f72427e05f3e4d5add75014bef30d0eaf1c7dbb (patch) | |
tree | c78b34292560b27d248881bbcd28953b48d35800 /usr.bin/dig | |
parent | 0ceb7b59c86af9efa7f1400fb460d85dc4d483b6 (diff) |
Delete a few more fromstruct_*, tostruct_* and freestruct_* functions
missed in previous. Also delete now unused utility functions.
Diffstat (limited to 'usr.bin/dig')
-rw-r--r-- | usr.bin/dig/lib/dns/rdata.c | 51 | ||||
-rw-r--r-- | usr.bin/dig/lib/dns/rdata/generic/ds_43.c | 66 | ||||
-rw-r--r-- | usr.bin/dig/lib/dns/rdata/generic/hip_55.c | 34 | ||||
-rw-r--r-- | usr.bin/dig/lib/dns/rdata/generic/key_25.c | 83 | ||||
-rw-r--r-- | usr.bin/dig/lib/dns/rdata/generic/tlsa_52.c | 63 | ||||
-rw-r--r-- | usr.bin/dig/lib/dns/rdata/generic/txt_16.c | 63 |
6 files changed, 4 insertions, 356 deletions
diff --git a/usr.bin/dig/lib/dns/rdata.c b/usr.bin/dig/lib/dns/rdata.c index 3f1177a3b1a..e6fff4612dc 100644 --- a/usr.bin/dig/lib/dns/rdata.c +++ b/usr.bin/dig/lib/dns/rdata.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdata.c,v 1.21 2020/02/24 17:45:25 florian Exp $ */ +/* $Id: rdata.c,v 1.22 2020/02/24 17:47:50 florian Exp $ */ /*! \file */ @@ -109,9 +109,6 @@ static isc_result_t uint16_tobuffer(uint32_t, isc_buffer_t *target); static isc_result_t -uint8_tobuffer(uint32_t, isc_buffer_t *target); - -static isc_result_t name_tobuffer(dns_name_t *name, isc_buffer_t *target); static uint32_t @@ -146,15 +143,6 @@ generic_totext_key(ARGS_TOTEXT); static inline isc_result_t generic_fromwire_key(ARGS_FROMWIRE); -static inline isc_result_t -generic_fromstruct_key(ARGS_FROMSTRUCT); - -static inline isc_result_t -generic_tostruct_key(ARGS_TOSTRUCT); - -static inline void -generic_freestruct_key(ARGS_FREESTRUCT); - static isc_result_t generic_totext_txt(ARGS_TOTEXT); @@ -162,41 +150,17 @@ static isc_result_t generic_fromwire_txt(ARGS_FROMWIRE); static isc_result_t -generic_fromstruct_txt(ARGS_FROMSTRUCT); - -static isc_result_t -generic_tostruct_txt(ARGS_TOSTRUCT); - -static void -generic_freestruct_txt(ARGS_FREESTRUCT); - -static isc_result_t generic_totext_ds(ARGS_TOTEXT); static isc_result_t -generic_tostruct_ds(ARGS_TOSTRUCT); - -static isc_result_t generic_fromwire_ds(ARGS_FROMWIRE); static isc_result_t -generic_fromstruct_ds(ARGS_FROMSTRUCT); - -static isc_result_t generic_totext_tlsa(ARGS_TOTEXT); static isc_result_t generic_fromwire_tlsa(ARGS_FROMWIRE); -static isc_result_t -generic_fromstruct_tlsa(ARGS_FROMSTRUCT); - -static isc_result_t -generic_tostruct_tlsa(ARGS_TOSTRUCT); - -static void -generic_freestruct_tlsa(ARGS_FREESTRUCT); - static inline isc_result_t name_duporclone(dns_name_t *source, dns_name_t *target) { @@ -1104,19 +1068,6 @@ uint16_tobuffer(uint32_t value, isc_buffer_t *target) { } static isc_result_t -uint8_tobuffer(uint32_t value, isc_buffer_t *target) { - isc_region_t region; - - if (value > 0xff) - return (ISC_R_RANGE); - isc_buffer_availableregion(target, ®ion); - if (region.length < 1) - return (ISC_R_NOSPACE); - isc_buffer_putuint8(target, (uint8_t)value); - return (ISC_R_SUCCESS); -} - -static isc_result_t name_tobuffer(dns_name_t *name, isc_buffer_t *target) { isc_region_t r; dns_name_toregion(name, &r); diff --git a/usr.bin/dig/lib/dns/rdata/generic/ds_43.c b/usr.bin/dig/lib/dns/rdata/generic/ds_43.c index 18bcff348d6..dc2571b5488 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/ds_43.c +++ b/usr.bin/dig/lib/dns/rdata/generic/ds_43.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ds_43.c,v 1.9 2020/02/24 17:45:26 florian Exp $ */ +/* $Id: ds_43.c,v 1.10 2020/02/24 17:47:50 florian Exp $ */ /* RFC3658 */ @@ -153,68 +153,4 @@ towire_ds(ARGS_TOWIRE) { return (mem_tobuffer(target, sr.base, sr.length)); } - -static inline isc_result_t -generic_fromstruct_ds(ARGS_FROMSTRUCT) { - dns_rdata_ds_t *ds = source; - - REQUIRE(source != NULL); - REQUIRE(ds->common.rdtype == type); - REQUIRE(ds->common.rdclass == rdclass); - - UNUSED(type); - UNUSED(rdclass); - - switch (ds->digest_type) { - case DNS_DSDIGEST_SHA1: - REQUIRE(ds->length == ISC_SHA1_DIGESTLENGTH); - break; - case DNS_DSDIGEST_SHA256: - REQUIRE(ds->length == ISC_SHA256_DIGESTLENGTH); - break; - case DNS_DSDIGEST_SHA384: - REQUIRE(ds->length == ISC_SHA384_DIGESTLENGTH); - break; - } - - RETERR(uint16_tobuffer(ds->key_tag, target)); - RETERR(uint8_tobuffer(ds->algorithm, target)); - RETERR(uint8_tobuffer(ds->digest_type, target)); - - return (mem_tobuffer(target, ds->digest, ds->length)); -} - - -static inline isc_result_t -generic_tostruct_ds(ARGS_TOSTRUCT) { - dns_rdata_ds_t *ds = target; - isc_region_t region; - - REQUIRE(target != NULL); - REQUIRE(rdata->length != 0); - REQUIRE(ds->common.rdtype == rdata->type); - REQUIRE(ds->common.rdclass == rdata->rdclass); - REQUIRE(!ISC_LINK_LINKED(&ds->common, link)); - - dns_rdata_toregion(rdata, ®ion); - - ds->key_tag = uint16_fromregion(®ion); - isc_region_consume(®ion, 2); - ds->algorithm = uint8_fromregion(®ion); - isc_region_consume(®ion, 1); - ds->digest_type = uint8_fromregion(®ion); - isc_region_consume(®ion, 1); - ds->length = region.length; - - ds->digest = mem_maybedup(region.base, region.length); - if (ds->digest == NULL) - return (ISC_R_NOMEMORY); - - return (ISC_R_SUCCESS); -} - - - - - #endif /* RDATA_GENERIC_DS_43_C */ diff --git a/usr.bin/dig/lib/dns/rdata/generic/hip_55.c b/usr.bin/dig/lib/dns/rdata/generic/hip_55.c index 71f2611e715..5c60d0870dd 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/hip_55.c +++ b/usr.bin/dig/lib/dns/rdata/generic/hip_55.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: hip_55.c,v 1.9 2020/02/24 17:45:26 florian Exp $ */ +/* $Id: hip_55.c,v 1.10 2020/02/24 17:47:50 florian Exp $ */ /* reviewed: TBC */ @@ -144,36 +144,4 @@ towire_hip(ARGS_TOWIRE) { dns_rdata_toregion(rdata, ®ion); return (mem_tobuffer(target, region.base, region.length)); } - - - - - - -isc_result_t -dns_rdata_hip_first(dns_rdata_hip_t *hip) { - if (hip->servers_len == 0) - return (ISC_R_NOMORE); - hip->offset = 0; - return (ISC_R_SUCCESS); -} - -isc_result_t -dns_rdata_hip_next(dns_rdata_hip_t *hip) { - isc_region_t region; - dns_name_t name; - - if (hip->offset >= hip->servers_len) - return (ISC_R_NOMORE); - - region.base = hip->servers + hip->offset; - region.length = hip->servers_len - hip->offset; - dns_name_init(&name, NULL); - dns_name_fromregion(&name, ®ion); - hip->offset += name.length; - INSIST(hip->offset <= hip->servers_len); - return (ISC_R_SUCCESS); -} - - #endif /* RDATA_GENERIC_HIP_5_C */ diff --git a/usr.bin/dig/lib/dns/rdata/generic/key_25.c b/usr.bin/dig/lib/dns/rdata/generic/key_25.c index 22cee401752..b53b1ad9ae1 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/key_25.c +++ b/usr.bin/dig/lib/dns/rdata/generic/key_25.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: key_25.c,v 1.8 2020/02/24 17:45:26 florian Exp $ */ +/* $Id: key_25.c,v 1.9 2020/02/24 17:47:50 florian Exp $ */ /* * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley. @@ -200,85 +200,4 @@ towire_key(ARGS_TOWIRE) { return (mem_tobuffer(target, sr.base, sr.length)); } - -static inline isc_result_t -generic_fromstruct_key(ARGS_FROMSTRUCT) { - dns_rdata_key_t *key = source; - - REQUIRE(key != NULL); - REQUIRE(key->common.rdtype == type); - REQUIRE(key->common.rdclass == rdclass); - - UNUSED(type); - UNUSED(rdclass); - - /* Flags */ - RETERR(uint16_tobuffer(key->flags, target)); - - /* Protocol */ - RETERR(uint8_tobuffer(key->protocol, target)); - - /* Algorithm */ - RETERR(uint8_tobuffer(key->algorithm, target)); - - /* Data */ - return (mem_tobuffer(target, key->data, key->datalen)); -} - -static inline isc_result_t -generic_tostruct_key(ARGS_TOSTRUCT) { - dns_rdata_key_t *key = target; - isc_region_t sr; - - REQUIRE(rdata != NULL); - REQUIRE(rdata->length != 0); - - REQUIRE(key != NULL); - REQUIRE(key->common.rdclass == rdata->rdclass); - REQUIRE(key->common.rdtype == rdata->type); - REQUIRE(!ISC_LINK_LINKED(&key->common, link)); - - dns_rdata_toregion(rdata, &sr); - - /* Flags */ - if (sr.length < 2) - return (ISC_R_UNEXPECTEDEND); - key->flags = uint16_fromregion(&sr); - isc_region_consume(&sr, 2); - - /* Protocol */ - if (sr.length < 1) - return (ISC_R_UNEXPECTEDEND); - key->protocol = uint8_fromregion(&sr); - isc_region_consume(&sr, 1); - - /* Algorithm */ - if (sr.length < 1) - return (ISC_R_UNEXPECTEDEND); - key->algorithm = uint8_fromregion(&sr); - isc_region_consume(&sr, 1); - - /* Data */ - key->datalen = sr.length; - key->data = mem_maybedup(sr.base, key->datalen); - if (key->data == NULL) - return (ISC_R_NOMEMORY); - - return (ISC_R_SUCCESS); -} - -static inline void -generic_freestruct_key(ARGS_FREESTRUCT) { - dns_rdata_key_t *key = (dns_rdata_key_t *) source; - - REQUIRE(key != NULL); - - free(key->data); -} - - - - - - #endif /* RDATA_GENERIC_KEY_25_C */ diff --git a/usr.bin/dig/lib/dns/rdata/generic/tlsa_52.c b/usr.bin/dig/lib/dns/rdata/generic/tlsa_52.c index d16e5f0e48d..2f4727589bf 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/tlsa_52.c +++ b/usr.bin/dig/lib/dns/rdata/generic/tlsa_52.c @@ -121,67 +121,4 @@ towire_tlsa(ARGS_TOWIRE) { return (mem_tobuffer(target, sr.base, sr.length)); } - -static inline isc_result_t -generic_fromstruct_tlsa(ARGS_FROMSTRUCT) { - dns_rdata_tlsa_t *tlsa = source; - - REQUIRE(source != NULL); - REQUIRE(tlsa->common.rdtype == type); - REQUIRE(tlsa->common.rdclass == rdclass); - - UNUSED(type); - UNUSED(rdclass); - - RETERR(uint8_tobuffer(tlsa->usage, target)); - RETERR(uint8_tobuffer(tlsa->selector, target)); - RETERR(uint8_tobuffer(tlsa->match, target)); - - return (mem_tobuffer(target, tlsa->data, tlsa->length)); -} - -static inline isc_result_t -generic_tostruct_tlsa(ARGS_TOSTRUCT) { - dns_rdata_tlsa_t *tlsa = target; - isc_region_t region; - - REQUIRE(target != NULL); - REQUIRE(rdata->length != 0); - - tlsa->common.rdclass = rdata->rdclass; - tlsa->common.rdtype = rdata->type; - ISC_LINK_INIT(&tlsa->common, link); - - dns_rdata_toregion(rdata, ®ion); - - tlsa->usage = uint8_fromregion(®ion); - isc_region_consume(®ion, 1); - tlsa->selector = uint8_fromregion(®ion); - isc_region_consume(®ion, 1); - tlsa->match = uint8_fromregion(®ion); - isc_region_consume(®ion, 1); - tlsa->length = region.length; - - tlsa->data = mem_maybedup(region.base, region.length); - if (tlsa->data == NULL) - return (ISC_R_NOMEMORY); - - return (ISC_R_SUCCESS); -} - -static inline void -generic_freestruct_tlsa(ARGS_FREESTRUCT) { - dns_rdata_tlsa_t *tlsa = source; - - REQUIRE(tlsa != NULL); - - if (tlsa->data != NULL) - free(tlsa->data); -} - - - - - - #endif /* RDATA_GENERIC_TLSA_52_C */ diff --git a/usr.bin/dig/lib/dns/rdata/generic/txt_16.c b/usr.bin/dig/lib/dns/rdata/generic/txt_16.c index 14d67b41c7c..4cf55f23007 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/txt_16.c +++ b/usr.bin/dig/lib/dns/rdata/generic/txt_16.c @@ -82,67 +82,4 @@ towire_txt(ARGS_TOWIRE) { return (mem_tobuffer(target, rdata->data, rdata->length)); } - -static inline isc_result_t -generic_fromstruct_txt(ARGS_FROMSTRUCT) { - dns_rdata_txt_t *txt = source; - isc_region_t region; - uint8_t length; - - REQUIRE(source != NULL); - REQUIRE(txt->common.rdtype == type); - REQUIRE(txt->common.rdclass == rdclass); - REQUIRE(txt->txt != NULL && txt->txt_len != 0); - - UNUSED(type); - UNUSED(rdclass); - - region.base = txt->txt; - region.length = txt->txt_len; - while (region.length > 0) { - length = uint8_fromregion(®ion); - isc_region_consume(®ion, 1); - if (region.length < length) - return (ISC_R_UNEXPECTEDEND); - isc_region_consume(®ion, length); - } - - return (mem_tobuffer(target, txt->txt, txt->txt_len)); -} - -static inline isc_result_t -generic_tostruct_txt(ARGS_TOSTRUCT) { - dns_rdata_txt_t *txt = target; - isc_region_t r; - - REQUIRE(target != NULL); - REQUIRE(txt->common.rdclass == rdata->rdclass); - REQUIRE(txt->common.rdtype == rdata->type); - REQUIRE(!ISC_LINK_LINKED(&txt->common, link)); - - dns_rdata_toregion(rdata, &r); - txt->txt_len = r.length; - txt->txt = mem_maybedup(r.base, r.length); - if (txt->txt == NULL) - return (ISC_R_NOMEMORY); - - txt->offset = 0; - return (ISC_R_SUCCESS); -} - -static inline void -generic_freestruct_txt(ARGS_FREESTRUCT) { - dns_rdata_txt_t *txt = source; - - REQUIRE(source != NULL); - - if (txt->txt != NULL) - free(txt->txt); -} - - - - - - #endif /* RDATA_GENERIC_TXT_16_C */ |