Lines Matching defs:cctx
35 dns_compress_init(dns_compress_t *cctx, isc_mem_t *mctx,
40 REQUIRE(cctx != NULL);
48 mask = ARRAY_SIZE(cctx->smallset) - 1;
49 set = cctx->smallset;
56 *cctx = (dns_compress_t){
66 dns_compress_invalidate(dns_compress_t *cctx) {
67 REQUIRE(CCTX_VALID(cctx));
68 if (cctx->set != cctx->smallset) {
69 isc_mem_free(cctx->mctx, cctx->set);
71 *cctx = (dns_compress_t){ 0 };
75 dns_compress_setpermitted(dns_compress_t *cctx, bool permitted) {
76 REQUIRE(CCTX_VALID(cctx));
78 cctx->flags |= DNS_COMPRESS_PERMITTED;
80 cctx->flags &= ~DNS_COMPRESS_PERMITTED;
85 dns_compress_getpermitted(dns_compress_t *cctx) {
86 REQUIRE(CCTX_VALID(cctx));
87 return (cctx->flags & DNS_COMPRESS_PERMITTED) != 0;
213 probe_distance(dns_compress_t *cctx, unsigned int slot) {
214 return (slot - cctx->set[slot].hash) & cctx->mask;
218 slot_index(dns_compress_t *cctx, unsigned int hash, unsigned int probe) {
219 return (hash + probe) & cctx->mask;
223 insert_label(dns_compress_t *cctx, isc_buffer_t *buffer, const dns_name_t *name,
231 if (coff >= 0x4000 || cctx->count > cctx->mask * 3 / 4) {
235 unsigned int slot = slot_index(cctx, hash, probe);
237 if (cctx->set[slot].coff == 0) {
238 cctx->set[slot].hash = hash;
239 cctx->set[slot].coff = coff;
240 cctx->count++;
244 if (probe > probe_distance(cctx, slot)) {
245 probe = probe_distance(cctx, slot);
246 ISC_SWAP(cctx->set[slot].hash, hash);
247 ISC_SWAP(cctx->set[slot].coff, coff);
257 insert(dns_compress_t *cctx, isc_buffer_t *buffer, const dns_name_t *name,
259 bool sensitive = (cctx->flags & DNS_COMPRESS_CASE) != 0;
265 while (insert_label(cctx, buffer, name, label, hash, probe) &&
276 dns_compress_name(dns_compress_t *cctx, isc_buffer_t *buffer,
279 REQUIRE(CCTX_VALID(cctx));
288 if ((cctx->flags & DNS_COMPRESS_DISABLED) != 0) {
292 bool sensitive = (cctx->flags & DNS_COMPRESS_CASE) != 0;
308 unsigned int slot = slot_index(cctx, hash, probe);
309 unsigned int coff = cctx->set[slot].coff;
317 if (coff == 0 || probe > probe_distance(cctx, slot)) {
318 insert(cctx, buffer, name, label, hash, probe);
326 if (hash == cctx->set[slot].hash &&
339 dns_compress_rollback(dns_compress_t *cctx, unsigned int coff) {
340 REQUIRE(CCTX_VALID(cctx));
342 for (unsigned int slot = 0; slot <= cctx->mask; slot++) {
343 if (cctx->set[slot].coff < coff) {
354 unsigned int next = slot_index(cctx, prev, 1);
355 while (cctx->set[next].coff != 0 &&
356 probe_distance(cctx, next) != 0)
358 cctx->set[prev] = cctx->set[next];
360 next = slot_index(cctx, prev, 1);
362 cctx->set[prev].coff = 0;
363 cctx->set[prev].hash = 0;
364 cctx->count--;