Patent ID: 7100043

Claim:
A lookup method applied to an SAD in an IPSEC, wherein a complete SAD stored in a software level is handled by a CPU and a part of the SAD includes M+1 (M is a positive integer) items of data in which every item comprises an SAD_index field and an SAD_key field, the M+1 items of data are allocated in an ASIC in numerical order (from item 0 to item M), the lookup method comprising the following steps: (1) receiving an incoming packet; (2) assigning a default value “0” to a variable i; (3) using the ASIC to compare the packet with the SAD_index field of item i, if perfectly matched, then jumping to step 6; (4) identifying whether the numerical value of the variable i is equal to M, if “YES”, then jumping to step 7; (5) setting the numerical value of the variable i to equal the previous value plus 1, then returning to step 3; (6) reading out the SAD_index field of item i, and storing the data of item i in an intermediate storage, then moving respective items (i−1), (i−2) . . . , 1, 0 to locations i, (i−1), . . . 2, 1 in sequence, and finally, moving the data stored in an intermediate storage to location 0 and jumping to step 9; (7) using the ASIC to issue an interrupt to inform the CPU, and after receiving the interrupt, the CPU entering the aforementioned software level and successively comparing each item being allocated in the software level with the aforementioned packet in terms of each bit of the SAD_index field until the CPU finds the perfectly matched item; (8) reading out the SAD_index field of the aforementioned item that makes a perfect match with the packet, then respectively moving items (M−1), (M−2) . . . , 1, 0 to locations M, (M−1), . . . 2, 1 in sequence, and finally, moving the aforementioned item that makes a perfect match with the packet to location 0; and (9) ending.