1/* $NetBSD: rdatatype.h,v 1.6 2024/02/21 22:52:10 christos Exp $ */ 2 3/* 4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 5 * 6 * SPDX-License-Identifier: MPL-2.0 7 * 8 * This Source Code Form is subject to the terms of the Mozilla Public 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 11 * 12 * See the COPYRIGHT file distributed with this work for additional 13 * information regarding copyright ownership. 14 */ 15 16#pragma once 17 18/*! \file dns/rdatatype.h */ 19 20#include <isc/lang.h> 21 22#include <dns/types.h> 23 24ISC_LANG_BEGINDECLS 25 26isc_result_t 27dns_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source); 28/*%< 29 * Convert the text 'source' refers to into a DNS rdata type. 30 * 31 * Requires: 32 *\li 'typep' is a valid pointer. 33 * 34 *\li 'source' is a valid text region. 35 * 36 * Returns: 37 *\li ISC_R_SUCCESS on success 38 *\li DNS_R_UNKNOWN type is unknown 39 */ 40 41isc_result_t 42dns_rdatatype_totext(dns_rdatatype_t type, isc_buffer_t *target); 43/*%< 44 * Put a textual representation of type 'type' into 'target'. 45 * 46 * Requires: 47 *\li 'type' is a valid type. 48 * 49 *\li 'target' is a valid text buffer. 50 * 51 * Ensures, 52 * if the result is success: 53 *\li The used space in 'target' is updated. 54 * 55 * Returns: 56 *\li #ISC_R_SUCCESS on success 57 *\li #ISC_R_NOSPACE target buffer is too small 58 */ 59 60isc_result_t 61dns_rdatatype_tounknowntext(dns_rdatatype_t type, isc_buffer_t *target); 62/*%< 63 * Put textual RFC3597 TYPEXXXX representation of type 'type' into 64 * 'target'. 65 * 66 * Requires: 67 *\li 'type' is a valid type. 68 * 69 *\li 'target' is a valid text buffer. 70 * 71 * Ensures, 72 * if the result is success: 73 *\li The used space in 'target' is updated. 74 * 75 * Returns: 76 *\li #ISC_R_SUCCESS on success 77 *\li #ISC_R_NOSPACE target buffer is too small 78 */ 79 80void 81dns_rdatatype_format(dns_rdatatype_t rdtype, char *array, unsigned int size); 82/*%< 83 * Format a human-readable representation of the type 'rdtype' 84 * into the character array 'array', which is of size 'size'. 85 * The resulting string is guaranteed to be null-terminated. 86 */ 87 88#define DNS_RDATATYPE_FORMATSIZE sizeof("NSEC3PARAM") 89 90/*%< 91 * Minimum size of array to pass to dns_rdatatype_format(). 92 * May need to be adjusted if a new RR type with a very long 93 * name is defined. 94 */ 95 96ISC_LANG_ENDDECLS 97