Described are a system and computer-implemented method for searching and
updating a routing table for forwarding IP packets through a
communications network. Records containing IP address prefixes are
organized in a binary tree data structure. When inserting a new record,
one of the records in the binary tree data structure is identified as an
enclosing record having an associated record data range that encloses
record data of the new record. An enclosing pointer of the new record is
set to point to the identified enclosing record. When searching for a
longest matching prefix for a destination IP address, the binary tree
data structure is traversed and one of the records in the binary tree
data structure is identified as an enclosing record, which is returned as
the longest matching prefix.