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

📄 lineariplookup.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_LINEARIPLOOKUP_HH#define CLICK_LINEARIPLOOKUP_HH#include "iproutetable.hh"CLICK_DECLS/*=cLinearIPLookup(ADDR1/MASK1 [GW1] OUT1, ADDR2/MASK2 [GW2] OUT2, ...)=s iproutesimple IP routing table=dB<Note:> Lookups and table updates with LinearIPLookup are extremely slow; theRadixIPLookup and DirectIPLookup elements should be preferred in almost allcases.  See IPRouteTable for a performance comparison.  We provideLinearIPLookup nevertheless for its simplicity.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.LinearIPLookup uses a linear search algorithm that may look at every route oneach packet. It is therefore most suitable for small routing tables.=eThis example delivers broadcasts and packets addressed to the localhost (18.26.4.24) to itself, packets to net 18.26.4 to thelocal interface, and all others via gateway 18.26.4.1:  ... -> GetIPAddress(16) -> rt;  rt :: LinearIPLookup(18.26.4.24/32 0,                       18.26.4.255/32 0,                       18.26.4.0/32 0,                       18.26.4/24 1,                       0/0 18.26.4.1 1);  rt[0] -> ToHost;  rt[1] -> ... -> ToDevice(eth0);=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>'.Fails if a route for C<ADDR/MASK> already exists.=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.=a RadixIPLookup, DirectIPLookup, RangeIPLookup, StaticIPLookup,SortedIPLookup, LinuxIPLookup, IPRouteTable */#define IP_RT_CACHE2 1class LinearIPLookup : public IPRouteTable { public:    LinearIPLookup();    ~LinearIPLookup();    const char *class_name() const	{ return "LinearIPLookup"; }    const char *port_count() const	{ return "1/-"; }    const char *processing() const	{ return PUSH; }    int initialize(ErrorHandler *);    void push(int port, Packet *p);    int add_route(const IPRoute&, bool, IPRoute*, ErrorHandler *);    int remove_route(const IPRoute&, IPRoute*, ErrorHandler *);    int lookup_route(IPAddress, IPAddress&) const;    String dump_routes();    bool check() const;  protected:    Vector<IPRoute> _t;    int _zero_route;    IPAddress _last_addr;    int _last_entry;#ifdef IP_RT_CACHE2    IPAddress _last_addr2;    int _last_entry2;#endif    int lookup_entry(IPAddress) const;};CLICK_ENDDECLS#endif

⌨️ 快捷键说明

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