rpatricia.git about / heads / tags
see http://www.goto.info.waseda.ac.jp/~tatsuya/rpatricia/
$ git log --pretty=format:'%h %s (%cs)%d' v0.09 --
a5be0f7 rpatricia 0.09 (2012-07-31)
(tag: v0.09)
e594c55 patricia: fix bounds error in ascii2prefix (2012-07-13)
(for-tatsuya)
85ef3f2 rpatricia 0.08 - IPv6 support (2011-08-12)
(tag: v0.08)
930f0de add Eric Wong's email to AUTHORS section (2011-08-12)
b5a3112 rpatricia: add missing prototypes for functions (2011-06-16)
(ipv6)
dbe6146 rpatricia: fix unused variable warnings in Ruby interface (2011-06-16)
2ced6d0 proper return value for init_copy function (2011-06-16)
5e580a4 test_ipv6: improve tests for ipv6 (2011-06-06)
cbead61 use StringValueCStr for string conversions (2011-06-03)
12e0668 patricia.c: fix some minor compiler warnings (2011-06-03)
...
$ git cat-file blob v0.09:README
README for Ruby wrapper of Net::Patricia
---------------------------------------
rPatricia - A ruby wrapper of Net::Patricia
DESCRIPTION
-----------
This is a ruby wrapper of Net::Patricia, which has been developed by
Dave Plonka. The original Net::Patricia and its C API are available
from:
http://net.doit.wisc.edu/~plonka/Net-Patricia/
Net::Patricia is a module for fast IP address/prefix lookups.
I have modified some interfaces for the Ruby wrapper version.
NO WARANTY
----------
THE PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
WITHOUT ANY WARRANTY. IT IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR
OR CORRECTION.
INSTALLATION
------------
This package extracts, builds, installs in the usual fashion, i.e.:
$ tar xvfz rpatricia.tar.gz
$ cd rpatricia
$ ruby extconf.rb
$ make
$ ruby test.rb
# make install
SYNOPSIS
--------
require 'rpatricia'
pt = Patricia.new
pt.add("192.168.1.0/24")
pt.add("127.0.0.0/8", "user_data")
node = pt.search_best("127.0.0.1")
puts node.data
puts node.prefix
puts node.network
puts node.prefixlen
pt.remove("127.0.0.0/8")
puts pt.num_nodes
pt.show_nodes
pt.clear
METHODS
-------
new:
pt = Patricia.new
This is the class' constructor - it returns a Patricia object for
handling IPv4 addresses. To handle IPv6 addresses (only),
Patricia.new may be called with an additional argument:
pt = Patricia.new(:AF_INET6)
The Patricia object will be destroyed automatically when there are
no longer any references to it.
add:
pt.add(key_string[,user_data])
The first argument, key_string, is a network or subnet
specification in canonical form, e.g. ``10.0.0.0/8'', where the
number after the slash represents the number of bits in the
netmask. If no mask width is specified, the longest possible mask
is assumed, i.e. 32 bits for AF_INET addresses and 128 bits for
AF_INET6 addresses.
The second argument, user_data, is optional. If supplied, it
should be a STRING object specifying the user data that will be
stored in the Patricia Trie node. Subsequently, this value will
be returned by the match methods described below to indicate a
successful search.
If no second argument is passed, the key_string will be stored as
the user data and therfore will likewise be returned by the match
functions.
On success, this method returns the object of the Patricia Trie
node.
family:
Returns either :AF_INET or :AF_INET6 symbol depending on how the
object was initialized. A Patricia object may only handle IPv4 or
IPv6 addresses.
add_node: An alias of add.
search_best:
pt.search_best(key_string);
This method searches the Patricia Trie to find a matching node,
according to normal subnetting rules for the address and mask
specified.
The key_string argument is a network or subnet specification in
canonical form, e.g. ``10.0.0.0/8'', where the number after the
slash represents the number of bits in the netmask. If no mask
width value is specified, the longest mask is assumed, i.e. 32
bits for AF_INET addresses and 128 bits for AF_INET6 addresses.
If a matching node is found in the Patricia Trie, this method
returns the object of the node. This method returns nil on
failure.
match_best: An alias of search_best.
search_exact:
pt.search_exact(key_string);
This method searches the Patricia Trie to find a matching
node. Its semantics are exactly the same as those described for
search_best except that the key must match a node exactly. I.e.,
it is not sufficient that the address and mask specified merely
falls within the subnet specified by a particular node.
match_exact: An alias of search_exact.
include?:
pt.include?(key_string);
This method behaves like match_best, but returns true on success
and false on failure. This method is more efficient than match_best
as it does not allocate a new object.
remove:
pt.remove(key_string);
This method removes the node which exactly matches the the address
and mask specified from the Patricia Trie.
If the matching node is found in the Patricia Trie, it is removed,
and this method returns the true. This method returns false on
failure.
remove_node: An alias of remove
num_nodes:
pt.num_nodes
This method returns the number of nodes in the Patricia Trie.
show_nodes:
pt.print_nodes
This method prints all the nodes in the Patricia Trie.
data:
node.data
This method returns the user data of the Patricia Trie node.
network:
node.network
This method returns the network of the Patricia Trie node.
prefix:
node.prefix
This method returns the prefix of the Patricia Trie node.
prefixlen:
node.prefixlen
This method returns the prefix length of the Patricia Trie
node.
AUTHORS
-------
Tatsuya Mori <mori.tatsuya@gmail.com>
Eric Wong <normalperson@yhbt.net>
# heads (aka `branches'):
$ git for-each-ref --sort=-creatordate refs/heads \
--format='%(HEAD) %(refname:short) %(subject) (%(creatordate:short))'
* master rpatricia 1.0.1 (2014-01-28)
0.09-proposed rpatricia 0.09pre1 (2012-07-18)
for-tatsuya patricia: fix bounds error in ascii2prefix (2012-07-13)
ipv6 rpatricia: add missing prototypes for functions (2011-06-16)
reorg move extension code into ext/ (2010-03-12)
# tags:
$ git for-each-ref --sort=-creatordate refs/tags \
--format='%(refname:short) %(subject) (%(creatordate:short))'
v1.0.1 rpatricia 1.0.1 (2014-01-28) tar.gz
v1.0 rpatricia 1.0 (2012-10-04) tar.gz
v0.09 rpatricia 0.09 (2012-07-31) tar.gz
v0.08 rpatricia 0.08 - IPv6 support (2011-08-12) tar.gz
v0.07 rpatricia 0.07 (2010-09-23) tar.gz
v0.06 rpatricia 0.06 (2010-09-14) tar.gz
v0.05 rpatricia 0.05 gem (2010-03-14) tar.gz
v0.04 rpatrica 0.04 (2010-03-12) tar.gz
git clone https://yhbt.net/rpatricia.git