GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
dnsjit.lib.trie(3) FreeBSD Library Functions Manual dnsjit.lib.trie(3)

dnsjit.lib.trie - Prefix-tree data structure which addresses values by strings or byte arrays


local trie = require("dnsjit.lib.trie").new("uint64_t", true, 4)
-- assume we have a bunch of dnsjit.core.object.ip packets to process
for _, pkt in pairs(pkts) do
local node = trie:get_ins(pkt.src)
local value = node:get() -- new nodes' values are initialized to 0
node:set(value + 1)
end
-- iterate over unique IPs and print number of packets received from each
local iter = trie:iter()
local node = iter:node()
local p = require("dnsjit.lib.ip")
while node ~= nil do
local ip_bytes = node:key()
local npkts = tonumber(node:get())
print(ip.tostring(ip_bytes).." sent "..npkts.." packets")
iter:next()
node = iter:node()
end


local trie = require("dnsjit.lib.trie").new("core_object_t*")
local obj1 -- assume this contains cdata of type core_object_t*
local node = trie:get_ins("obj1")
node:set(obj1)
node = trie:get_try("obj1")
assert(node:get() == obj1)

Prefix-tree data structure that stores values indexed by strings or byte arrays, such as IP addresses. Values of size up to sizeof(size_t) can be stored directly, otherwise a pointer must be used.

Create a new Trie that stores ctype values as data. By default, keys are handled as strings. To use trie with byte arrays, set binary to true. Optionally, keylen may be specified as a default keylen for binary keys. For string keys, their string length is used by default.
Return the Log object to control logging of this instance or module.
Clear the trie instance (make it empty).
Return the number of keys in the trie.
Search the trie and return nil of failure.
Search the trie and insert an empty node (with value set to 0) on failure.
Return the first node (minimum).
Return a trie iterator. It is only valid as long as the key-set remains unchanged.

dnsjit.lib.trie.node(3),dnsjit.lib.trie.iter(3)

Jerry Lundström (DNS-OARC), Tomáš Křížek (CZ.NIC), Petr Špaček (ISC)

Maintained by DNS-OARC

https://www.dns-oarc.net/

For issues and feature requests please use:

https://github.com/DNS-OARC/dnsjit/issues

For question and help please use:

admin@dns-oarc.net
1.4.0 dnsjit

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.