Home

Awesome

Longest Prefix Match (LPM) library

Build Status

Longest Prefix Match (LPM) library supporting IPv4 and IPv6. The implementation is written in C99 and is distributed under the 2-clause BSD license.

Additionally, bindings are available for Lua and Java. Specifications to build RPM and DEB packages are also provided.

API

Examples

Lua

local lpm = require("lpm")

local acl = lpm.new()
local some_info = { val = "test" }

local addr, preflen = lpm.tobin("10.0.0.0/24")
if not acl:insert(addr, preflen, some_info) then
  print("acl:insert() failed")
  return -1
end

local ret = acl:lookup(lpm.tobin("10.0.0.100"))
print(ret.val)

Java

See README how to build the JAR and the test case as example how to use the Java API

Packages

Just build the package, install it and link the library using the -llpm flag.