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];
* \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
*/
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.
* 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.
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;
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);
}
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) {
(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;
}
}