1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/// Number of first-octet radix buckets (`0..=255`).
pub const RADIX_BUCKET_COUNT: usize = 256;
/// Packed bucket sentinel indicating no CIDR ranges intersect the bucket.
pub const BUCKET_EMPTY: u64 = 0;
/// Packed bucket sentinel indicating the entire bucket is covered.
pub const BUCKET_FULL: u64 = 1u64 << 61;
/// Tag bit indicating an inline single IPv4 range packed directly in the bucket word.
pub const BUCKET_INLINE_FLAG: u64 = 1u64 << 63;
/// Tag bit indicating the bucket points to an adaptive L2 sub-table.
pub const BUCKET_SUBTABLE_FLAG: u64 = 1u64 << 62;
/// Mask extracting the lower 32-bit start index or sub-table offset from a packed bucket entry.
pub const BUCKET_LO_MASK: u64 = 0xFFFF_FFFF;
/// Bit shift for packing the upper 32-bit end index into a slice bucket entry.
pub const BUCKET_HI_SHIFT: u32 = 32;
/// Bit shift to extract the first octet of an IPv4 address.
pub const IPV4_FIRST_OCTET_SHIFT: u32 = 24;
/// Host-bit mask within a single IPv4 `/8` bucket.
pub const IPV4_BUCKET_HOST_MASK: u32 = 0x00FF_FFFF;
/// Bit shift for the upper 24-bit host bound in an inline IPv4 bucket entry.
pub const IPV4_INLINE_HI_SHIFT: u32 = 24;
/// Bit position of the 6-bit sub-table right-shift field inside an IPv4 L1 sub-table entry.
pub const SUBTABLE_SHIFT_POS: u32 = 56;
/// Mask extracting the 6-bit sub-table right-shift value.
pub const SUBTABLE_SHIFT_MASK: u64 = 0x3F;
/// Bit position of the sub-table index mask field inside an IPv4 L1 sub-table entry.
pub const SUBTABLE_MASK_POS: u32 = 32;
/// Mask extracting the 24-bit sub-table index mask field.
pub const SUBTABLE_MASK_BITS: u64 = 0x00FF_FFFF;
/// Minimum range count inside a `/8` bucket required to promote to an L2 sub-table.
pub const SUBTABLE_MIN_RANGES: usize = 8;
/// Range-count threshold selecting a medium 256-entry L2 sub-table.
pub const SUBTABLE_MEDIUM_RANGES: usize = 64;
/// Range-count threshold selecting a large L2 sub-table.
pub const SUBTABLE_LARGE_RANGES: usize = 512;
/// Stride bits for a small 16-entry L2 sub-table (`2^4`).
pub const SUBTABLE_SMALL_BITS: u32 = 4;
/// Stride bits for a medium 256-entry L2 sub-table (`2^8`).
pub const SUBTABLE_MEDIUM_BITS: u32 = 8;
/// Stride bits for a large 2048-entry IPv4 L2 sub-table (`2^11`).
pub const SUBTABLE_LARGE_BITS_V4: u32 = 11;
/// Stride bits for a large 1024-entry IPv6 L2 sub-table (`2^10`).
pub const SUBTABLE_LARGE_BITS_V6: u32 = 10;
/// Bit shift to extract the first byte of an IPv6 address.
pub const IPV6_FIRST_BYTE_SHIFT: u32 = 120;
/// Host-bit mask within a single IPv6 `/8` bucket.
pub const IPV6_BUCKET_HOST_MASK: u128 = - 1;
/// Mask extracting the 8-bit shift value from packed IPv6 sub-table metadata.
pub const IPV6_META_SHIFT_MASK: u32 = 0xFF;
/// Bit position of the sub-table index mask in packed IPv6 sub-table metadata.
pub const IPV6_META_MASK_POS: u32 = 8;
/// Threshold below which linear scan beats binary search inside a radix bucket.
pub const LINEAR_SCAN_THRESHOLD: usize = 4;