2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-04 16:45:24 +00:00

add dns_rdataslab_size(); remove dns_rdataslab_tordataset()

This commit is contained in:
Bob Halley
1999-02-06 00:07:09 +00:00
parent 1366b7833c
commit e800570a5a
2 changed files with 27 additions and 29 deletions

View File

@@ -30,14 +30,14 @@
* This module deals with low-level byte streams. Errors in any of * This module deals with low-level byte streams. Errors in any of
* the functions are likely to crash the server or corrupt memory. * the functions are likely to crash the server or corrupt memory.
* *
* If the caller passes invalid memory references, these functions are
* likely to crash the server or corrupt memory.
*
* Resources: * Resources:
* None. * None.
* *
* Security: * Security:
* * None.
* Very little range checking is done in these functions for rdata
* copied in or out. It is assumed that the caller knows what is
* going on.
* *
* Standards: * Standards:
* None. * None.
@@ -77,26 +77,16 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
* <XXX others> * <XXX others>
*/ */
unsigned int
dns_result_t dns_rdataslab_size(unsigned char *slab, unsigned int reservelen);
dns_rdataslab_tordataset(dns_rdataset_t *rdataset, isc_region_t *region,
unsigned int reservelen);
/* /*
* Unslabify a rdataset. The slab is not deallocated. * Return the total size of an rdataslab.
* *
* Requires: * Requires:
* 'rdataset' is valid. * 'slab' points to a slab.
*
* 'region' points to a region of memory that contains the slabified
* data at offset 'reservelen'.
*
* Ensures:
* 'rdataset' contains the structure version of data in 'region'.
* *
* Returns: * Returns:
* DNS_R_SUCCESS - successful completion * The number of bytes in the slab, including the reservelen.
* DNS_R_NOMEM - no memory.
* <XXX others>
*/ */
#endif /* DNS_RDATADLAB_H */ #endif /* DNS_RDATADLAB_H */

View File

@@ -15,7 +15,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: rdataslab.c,v 1.1 1999/01/27 08:44:10 explorer Exp $ */ /* $Id: rdataslab.c,v 1.2 1999/02/06 00:07:08 halley Exp $ */
#include <config.h> #include <config.h>
@@ -104,14 +104,22 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
return (DNS_R_SUCCESS); return (DNS_R_SUCCESS);
} }
dns_result_t unsigned int
dns_rdataslab_tordataset(dns_rdataset_t *rdataset, isc_region_t *region, dns_rdataslab_size(unsigned char *slab, unsigned int reservelen) {
unsigned int reservelen) unsigned int count, length;
{ unsigned char *current;
/* XXX shut up compiler */
rdataset = rdataset;
region = region;
reservelen = reservelen;
return (DNS_R_NOTIMPLEMENTED); REQUIRE(slab != NULL);
current = slab + reservelen;
count = *current++ * 256;
count += *current++;
while (count > 0) {
count--;
length = *current++ * 256;
length += *current++;
current += length;
}
return ((unsigned int)(current - slab));
} }