Mechanisms for storing and searching a hierarchy of policies and
associations thereof are disclosed which may be particularly useful for
implementing security protocols, such as, but not limited to Internet
Protocol security (IPsec). For example, a hierarchy of policies is stored
in a search priority order in an associative memory, with each
association of a particular policy stored higher in the search priority
than its associated policy and after any other policy. Therefore, a
lookup operation on the associative memory will identify a matching
association, if one, else its matching policy. A match of a policy
instead of an association may result in a corresponding association being
added in the appropriate location. For IPsec implementations, the lookup
word is typically derived from the packet, with this packet being
typically processed based on the identified policy or association.