Clean up remaining references to global compression
It is simply called "compression" now, without any qualifiers. Also, improve some variable names in dns_name_towire2() so they are not two letter abbreviations for global something.
This commit is contained in:
@@ -205,8 +205,8 @@ dns_compress_getsensitive(dns_compress_t *cctx) {
|
||||
* If no match is found return false.
|
||||
*/
|
||||
bool
|
||||
dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
|
||||
dns_name_t *prefix, uint16_t *offset) {
|
||||
dns_compress_find(dns_compress_t *cctx, const dns_name_t *name,
|
||||
dns_name_t *prefix, uint16_t *offset) {
|
||||
dns_name_t tname;
|
||||
dns_compressnode_t *node = NULL;
|
||||
unsigned int labels, i, n;
|
||||
|
||||
@@ -61,7 +61,7 @@ struct dns_compress {
|
||||
bool permitted;
|
||||
bool disabled;
|
||||
bool sensitive;
|
||||
/*% Global compression table. */
|
||||
/*% Compression pointer table. */
|
||||
dns_compressnode_t *table[DNS_COMPRESS_TABLESIZE];
|
||||
/*% Preallocated arena for names. */
|
||||
unsigned char arena[DNS_COMPRESS_ARENA_SIZE];
|
||||
@@ -91,7 +91,8 @@ dns_compress_init(dns_compress_t *cctx, isc_mem_t *mctx);
|
||||
* \li 'cctx' is a valid dns_compress_t structure.
|
||||
* \li 'mctx' is an initialized memory context.
|
||||
* Ensures:
|
||||
* \li cctx->global is initialized.
|
||||
* \li 'cctx' is initialized.
|
||||
* \li 'cctx->permitted' is true.
|
||||
*
|
||||
* Returns:
|
||||
* \li #ISC_R_SUCCESS
|
||||
@@ -162,10 +163,10 @@ dns_compress_getsensitive(dns_compress_t *cctx);
|
||||
*/
|
||||
|
||||
bool
|
||||
dns_compress_findglobal(dns_compress_t *cctx, const dns_name_t *name,
|
||||
dns_name_t *prefix, uint16_t *offset);
|
||||
dns_compress_find(dns_compress_t *cctx, const dns_name_t *name,
|
||||
dns_name_t *prefix, uint16_t *offset);
|
||||
/*%<
|
||||
* Finds longest possible match of 'name' in the global compression table.
|
||||
* Finds longest possible match of 'name' in the compression table.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'cctx' to be initialized.
|
||||
@@ -194,13 +195,13 @@ dns_compress_add(dns_compress_t *cctx, const dns_name_t *name,
|
||||
* valid until the message compression is complete.
|
||||
*
|
||||
*\li 'prefix' must be a prefix returned by
|
||||
* dns_compress_findglobal(), or the same as 'name'.
|
||||
* dns_compress_find(), or the same as 'name'.
|
||||
*/
|
||||
|
||||
void
|
||||
dns_compress_rollback(dns_compress_t *cctx, uint16_t offset);
|
||||
/*%<
|
||||
* Remove any compression pointers from global table >= offset.
|
||||
* Remove any compression pointers from the table that are >= offset.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'cctx' is initialized.
|
||||
|
||||
@@ -757,8 +757,7 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx,
|
||||
* compression context 'cctx', and storing the result in 'target'.
|
||||
*
|
||||
* Notes:
|
||||
* \li If the compression context allows global compression, then the
|
||||
* global compression table may be updated.
|
||||
* \li If compression is permitted, then the cctx table may be updated.
|
||||
*
|
||||
* Requires:
|
||||
* \li 'name' is a valid name
|
||||
@@ -769,8 +768,7 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx,
|
||||
*
|
||||
* \li target is a valid buffer.
|
||||
*
|
||||
* \li Any offsets specified in a global compression table are valid
|
||||
* for buffer.
|
||||
* \li Any offsets in the compression table are valid for buffer.
|
||||
*
|
||||
* Ensures:
|
||||
*
|
||||
|
||||
@@ -328,16 +328,14 @@ dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx,
|
||||
* compression context 'cctx', and storing the result in 'target'.
|
||||
*
|
||||
* Notes:
|
||||
*\li If the compression context allows global compression, then the
|
||||
* global compression table may be updated.
|
||||
*\li If compression is permitted, then the cctx table may be updated.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'rdata' is a valid, non-empty rdata
|
||||
*
|
||||
*\li target is a valid buffer
|
||||
*
|
||||
*\li Any offsets specified in a global compression table are valid
|
||||
* for target.
|
||||
*\li Any offsets in the compression table are valid for target.
|
||||
*
|
||||
* Ensures,
|
||||
* if the result is success:
|
||||
|
||||
@@ -1919,10 +1919,10 @@ isc_result_t
|
||||
dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx,
|
||||
isc_buffer_t *target, uint16_t *comp_offsetp) {
|
||||
bool compress;
|
||||
uint16_t offset;
|
||||
dns_name_t gp; /* Global compression prefix */
|
||||
bool gf; /* Global compression target found */
|
||||
uint16_t go; /* Global compression offset */
|
||||
bool found;
|
||||
uint16_t here; /* start of the name we are adding to the message */
|
||||
uint16_t there; /* target of the compression pointer */
|
||||
dns_name_t prefix;
|
||||
dns_offsets_t clo;
|
||||
dns_name_t clname;
|
||||
|
||||
@@ -1947,9 +1947,8 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx,
|
||||
if (target->length - target->used < 2) {
|
||||
return (ISC_R_NOSPACE);
|
||||
}
|
||||
offset = *comp_offsetp;
|
||||
offset |= 0xc000;
|
||||
isc_buffer_putuint16(target, offset);
|
||||
here = *comp_offsetp;
|
||||
isc_buffer_putuint16(target, here | 0xc000);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1962,52 +1961,52 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx,
|
||||
dns_name_clone(name, &clname);
|
||||
name = &clname;
|
||||
}
|
||||
DNS_NAME_INIT(&gp, NULL);
|
||||
DNS_NAME_INIT(&prefix, NULL);
|
||||
|
||||
offset = target->used; /*XXX*/
|
||||
here = target->used; /*XXX*/
|
||||
|
||||
if (compress) {
|
||||
gf = dns_compress_findglobal(cctx, name, &gp, &go);
|
||||
found = dns_compress_find(cctx, name, &prefix, &there);
|
||||
} else {
|
||||
gf = false;
|
||||
found = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the offset is too high for 14 bit global compression, we're
|
||||
* out of luck.
|
||||
* If the offset does not fit in a 14 bit compression pointer,
|
||||
* we're out of luck.
|
||||
*/
|
||||
if (gf && go >= 0x4000) {
|
||||
gf = false;
|
||||
if (found && there >= 0x4000) {
|
||||
found = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Will the compression pointer reduce the message size?
|
||||
*/
|
||||
if (gf && (gp.length + 2) >= name->length) {
|
||||
gf = false;
|
||||
if (found && (prefix.length + 2) >= name->length) {
|
||||
found = false;
|
||||
}
|
||||
|
||||
if (gf) {
|
||||
if (target->length - target->used < gp.length) {
|
||||
if (found) {
|
||||
if (target->length - target->used < prefix.length) {
|
||||
return (ISC_R_NOSPACE);
|
||||
}
|
||||
if (gp.length != 0) {
|
||||
if (prefix.length != 0) {
|
||||
unsigned char *base = target->base;
|
||||
(void)memmove(base + target->used, gp.ndata,
|
||||
(size_t)gp.length);
|
||||
(void)memmove(base + target->used, prefix.ndata,
|
||||
(size_t)prefix.length);
|
||||
}
|
||||
isc_buffer_add(target, gp.length);
|
||||
isc_buffer_add(target, prefix.length);
|
||||
if (target->length - target->used < 2) {
|
||||
return (ISC_R_NOSPACE);
|
||||
}
|
||||
isc_buffer_putuint16(target, go | 0xc000);
|
||||
if (gp.length != 0) {
|
||||
dns_compress_add(cctx, name, &gp, offset);
|
||||
isc_buffer_putuint16(target, there | 0xc000);
|
||||
if (prefix.length != 0) {
|
||||
dns_compress_add(cctx, name, &prefix, here);
|
||||
if (comp_offsetp != NULL) {
|
||||
*comp_offsetp = offset;
|
||||
*comp_offsetp = here;
|
||||
}
|
||||
} else if (comp_offsetp != NULL) {
|
||||
*comp_offsetp = go;
|
||||
*comp_offsetp = there;
|
||||
}
|
||||
} else {
|
||||
if (target->length - target->used < name->length) {
|
||||
@@ -2019,9 +2018,9 @@ dns_name_towire2(const dns_name_t *name, dns_compress_t *cctx,
|
||||
(size_t)name->length);
|
||||
}
|
||||
isc_buffer_add(target, name->length);
|
||||
dns_compress_add(cctx, name, name, offset);
|
||||
dns_compress_add(cctx, name, name, here);
|
||||
if (comp_offsetp != NULL) {
|
||||
*comp_offsetp = offset;
|
||||
*comp_offsetp = here;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user