⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 radixipseclookup.hh

📁 Click is a modular router toolkit. To use it you ll need to know how to compile and install the sof
💻 HH
字号:
// -*- c-basic-offset: 4 -*-#ifndef CLICK_RADIXIPSECLOOKUP_HH#define CLICK_RADIXIPSECLOOKUP_HH#include <click/glue.hh>#include <click/element.hh>#include "ipsecroutetable.hh"#include "satable.hh"#include "sadatatuple.hh"CLICK_DECLS/*=cRadixIPsecLookup(ADDR1/MASK1 [GW1] OUT1, ADDR2/MASK2 [GW2] OUT2, ...)=s ipsecrouteIP lookup using a radix trie=dPerforms IP lookup using a radix trie.  The first level of the trie has 256buckets; each succeeding level has 16.  The maximum number of levels that willbe traversed is thus 7.Expects a destination IP address annotation with each packet. Looks up thataddress in its routing table, using longest-prefix-match, sets the destinationannotation to the corresponding GW (if specified), and emits the packet on theindicated OUTput port.Each argument is a route, specifying a destination and mask, an optionalgateway IP address, and an output port.Uses the IPsecRouteTable interface; see IPsecRouteTable for description.=h table read-onlyOutputs a human-readable version of the current routing table.=h lookup read-onlyReports the OUTput port and GW corresponding to an address.=h add write-onlyAdds a route to the table. Format should be `C<ADDR/MASK [GW] OUT>'. Shouldfail if a route for C<ADDR/MASK> already exists, but currently does not.=h set write-onlySets a route, whether or not a route for the same prefix already exists.=h remove write-onlyRemoves a route from the table. Format should be `C<ADDR/MASK>'.=h ctrl write-onlyAdds or removes a group of routes. Write `C<add>/C<set ADDR/MASK [GW] OUT>' toadd a route, and `C<remove ADDR/MASK>' to remove a route. You can supplymultiple commands, one per line; all commands are executed as one atomicoperation.=nSee IPsecRouteTable for a performance comparison of the various IP routingelements.=a IPsecRouteTable, DirectIPLookup, RangeIPLookup, StaticIPLookup,LinearIPLookup, SortedIPLookup, LinuxIPLookup*///Changed to use ipsec extensionsclass RadixIPsecLookup : public IPsecRouteTable { public:    RadixIPsecLookup();    ~RadixIPsecLookup();    const char *class_name() const		{ return "RadixIPsecLookup"; }    const char *port_count() const		{ return "1/-"; }    const char *processing() const		{ return PUSH; }    void cleanup(CleanupStage);    int add_route(const IPsecRoute&, bool, IPsecRoute*, ErrorHandler *);    int remove_route(const IPsecRoute&, IPsecRoute*, ErrorHandler *);    int lookup_route(IPAddress, IPAddress&, unsigned int&, SADataTuple*&) const;    String dump_routes();  private:    class Radix;    // Simple routing table    Vector<IPsecRoute> _v;    int _vfree;    int32_t _default_key;    Radix* _radix;};class RadixIPsecLookup::Radix { public:    static Radix* make_radix(int bitshift, int n);    static void free_radix(Radix*);    Radix* change(uint32_t addr, uint32_t naddr, int key, uint32_t key_priority);    static int lookup(const Radix*, int, uint32_t addr);  private:    int32_t _route_index;    int _bitshift;    int _n;    int _nchildren;    struct Child {	int key;	uint32_t key_priority;	Radix* child;    } _children[0];    Radix()			{ }    ~Radix()			{ }    friend class RadixIPsecLookup;};inline intRadixIPsecLookup::Radix::lookup(const Radix* r, int cur, uint32_t addr){    while (r) {	int i1 = addr >> r->_bitshift;	addr &= (1 << r->_bitshift) - 1;	if (r->_children[i1].key >= 0)	    cur = r->_children[i1].key;	r = r->_children[i1].child;    }    return cur;}CLICK_ENDDECLS#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -