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

📄 ipaddrpairrewriter.hh

📁 COPE the first practical network coding scheme which is developped on click
💻 HH
字号:
// -*- mode: c++; c-basic-offset: 4 -*-#ifndef CLICK_IPADDRPAIRREWRITER_HH#define CLICK_IPADDRPAIRREWRITER_HH#include "elements/ip/iprw.hh"CLICK_DECLS/*=cIPAddrPairRewriter(INPUTSPEC1, ..., INPUTSPECn)=s TCPrewrites IP packets' addresses by address pair=dRewrites the source and/or destination addresses on IP packets, along withtheir checksums.  IPAddrPairRewriter implements per-address-pair networkaddress translation, a midpoint between Basic NAT (see IPAddrRewriter) andNAPT (see IPRewriter and TCPRewriter).IPAddrPairRewriter maintains a I<mapping table> that records how addresses arerewritten.  On receiving a packet, IPAddrPairRewriter first looks up thatpacket in the mapping table by source/destination address pair.  If the tablecontains a mapping, then the packet is rewritten according to the mapping andemitted on the specified output port.  If there was no mapping, the packet ishandled by the INPUTSPEC corresponding to the input port on which the packetarrived.  (There are as many input ports as INPUTSPECs.)  Most INPUTSPECsinstall new mappings, so that future packets from the same address are handledby the mapping table rather than some INPUTSPEC.  The six forms of INPUTSPEChandle input packets as follows:=over 5=item 'drop', 'pass OUTPUT', 'keep FOUTPUT ROUTPUT', 'ELEMENTNAME'These INPUTSPECs behave like those in IPRewriter.=item 'pattern SADDR[-SADDR2] DADDR FOUTPUT ROUTPUT'Creates a mapping according to the given pattern, 'SADDR DADDR'.  Eitherpattern field may be a dash '-', in which case the corresponding field is leftunchanged.  For instance, the pattern '1.0.0.1 -' will rewrite input packets'source address, but leave its destination address unchanged.  SADDR may be arange 'L-H' or prefix 'ADDR/PFX'; IPRewriter will choose an unallocatedaddress in that range, or drop the packet if no address is available.Normally addresses are chosen randomly within the range.  To allocateaddresses sequentially (which can make testing easier), append a pound sign tothe range, as in '1.0.0.1-1.255.255.254#'.Say a packet with address pair (SA, DA) is received, and the corresponding newaddresses are (SA', DA').  Then two mappings are installed:    (SA, DA) => (SA', DA') [FOUTPUT]    (DA', SA') => (DA, SA) [ROUTPUT]Thus, the input packet is rewritten and sent to FOUTPUT, and packets from thereply flow are rewritten to look like part of the original flow and sent toROUTPUT.=item 'pattern PATNAME FOUTPUT ROUTPUT'Behaves like the version in IPRewriter, except that PATNAME must name anIPAddrRewriter-like pattern.=backInput packets must have their IP header annotations set.  IPAddrRewriterchanges IP packet data and destination IP address annotations.=h mappings read-onlyReturns a human-readable description of the IPAddrRewriter's current set ofmappings.=h nmappings read-onlyReturns the number of currently installed mappings.=h patterns read-onlyReturns a human-readable description of the patterns associated with thisIPAddrRewriter.=a IPRewriter, IPAddrRewriter, TCPRewriter, IPRewriterPatterns,RoundRobinIPMapper, FTPPortMapper, ICMPRewriter, ICMPPingRewriter */class IPAddrPairRewriter : public IPRw { public:    class IPAddrPairMapping : public Mapping { public:	IPAddrPairMapping(bool dst_anno)	: Mapping(dst_anno) { }	IPAddrPairMapping *reverse() const { return static_cast<IPAddrPairMapping *>(reverse()); }	void apply(WritablePacket *p);	String unparse() const;        };    IPAddrPairRewriter();    ~IPAddrPairRewriter();    const char *class_name() const		{ return "IPAddrPairRewriter"; }    void *cast(const char *);    const char *processing() const		{ return PUSH; }    void notify_noutputs(int);    int configure(Vector<String> &, ErrorHandler *);    int initialize(ErrorHandler *);    void cleanup(CleanupStage);    //void take_state(Element *, ErrorHandler *);    void run_timer();    int notify_pattern(Pattern *, ErrorHandler *);    IPAddrPairMapping *apply_pattern(Pattern *, int ip_p, const IPFlowID &, int, int);    Mapping *get_mapping(int, const IPFlowID &) const;    void push(int, Packet *);    void add_handlers();  private:    Map _map;    Vector<InputSpec> _input_specs;    Timer _timer;    enum { GC_INTERVAL_SEC = 7200 };    static String dump_mappings_handler(Element *, void *);    static String dump_nmappings_handler(Element *, void *);    static String dump_patterns_handler(Element *, void *);};inline IPRw::Mapping *IPAddrPairRewriter::get_mapping(int, const IPFlowID &in_flow) const{    return _map[IPFlowID(in_flow.saddr(), 0, in_flow.daddr(), 0)];}CLICK_ENDDECLS#endif

⌨️ 快捷键说明

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