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

📄 ipaddress.hh

📁 COPE the first practical network coding scheme which is developped on click
💻 HH
字号:
// -*- c-basic-offset: 4; related-file-name: "../../lib/ipaddress.cc" -*-#ifndef CLICK_IPADDRESS_HH#define CLICK_IPADDRESS_HH#include <click/string.hh>#include <click/glue.hh>#include <clicknet/ip.h>CLICK_DECLSclass StringAccum;class IPAddress { public:      IPAddress()			: _addr(0) { }    explicit IPAddress(const unsigned char*);    inline IPAddress(unsigned int);	// network byte order IP address    inline explicit IPAddress(int);	// network byte order IP address    inline explicit IPAddress(unsigned long); // network byte order IP address    inline explicit IPAddress(long);	// network byte order IP address    explicit IPAddress(const String&);	// "18.26.4.99"    inline IPAddress(struct in_addr);    static IPAddress make_prefix(int);      operator bool() const	{ return _addr != 0; }    operator uint32_t() const	{ return _addr; }    uint32_t addr() const	{ return _addr; }      inline operator struct in_addr() const;    inline struct in_addr in_addr() const;    inline unsigned char* data();    inline const unsigned char* data() const;      int mask_to_prefix_len() const;    inline bool matches_prefix(IPAddress addr, IPAddress mask) const;    inline bool mask_as_specific(IPAddress) const;    inline bool mask_more_specific(IPAddress) const;    // bool operator==(IPAddress, IPAddress);    // bool operator==(IPAddress, uint32_t);    // bool operator!=(IPAddress, IPAddress);    // bool operator!=(IPAddress, uint32_t);      // IPAddress operator&(IPAddress, IPAddress);    // IPAddress operator|(IPAddress, IPAddress);    // IPAddress operator^(IPAddress, IPAddress);    // IPAddress operator~(IPAddress);      inline IPAddress& operator&=(IPAddress);    inline IPAddress& operator|=(IPAddress);    inline IPAddress& operator^=(IPAddress);    String unparse() const;    String unparse_mask() const;    String unparse_with_mask(IPAddress) const;      operator String() const	{ return unparse(); }    String s() const		{ return unparse(); }  private:      uint32_t _addr;};inlineIPAddress::IPAddress(unsigned int a)    : _addr(a){}inlineIPAddress::IPAddress(int a)    : _addr(a){}inlineIPAddress::IPAddress(unsigned long a)    : _addr(a){}inlineIPAddress::IPAddress(long a)    : _addr(a){}inlineIPAddress::IPAddress(struct in_addr ina)    : _addr(ina.s_addr){}inline booloperator==(IPAddress a, IPAddress b){    return a.addr() == b.addr();}inline booloperator==(IPAddress a, uint32_t b){    return a.addr() == b;}inline booloperator!=(IPAddress a, IPAddress b){    return a.addr() != b.addr();}inline booloperator!=(IPAddress a, uint32_t b){    return a.addr() != b;}inline const unsigned char*IPAddress::data() const{    return reinterpret_cast<const unsigned char*>(&_addr);}inline unsigned char*IPAddress::data(){    return reinterpret_cast<unsigned char*>(&_addr);}inline struct in_addrIPAddress::in_addr() const{    struct in_addr ia;    ia.s_addr = _addr;    return ia;}inlineIPAddress::operator struct in_addr() const{    return in_addr();}StringAccum& operator<<(StringAccum&, IPAddress);inline boolIPAddress::matches_prefix(IPAddress a, IPAddress mask) const{    return ((addr() ^ a.addr()) & mask.addr()) == 0;}inline boolIPAddress::mask_as_specific(IPAddress mask) const{    return (addr() & mask.addr()) == mask.addr();}inline boolIPAddress::mask_more_specific(IPAddress mask) const{    return ((addr() << 1) & mask.addr()) == mask.addr();}inline IPAddressoperator&(IPAddress a, IPAddress b){    return IPAddress(a.addr() & b.addr());}inline IPAddress&IPAddress::operator&=(IPAddress a){    _addr &= a._addr;    return *this;}inline IPAddressoperator|(IPAddress a, IPAddress b){    return IPAddress(a.addr() | b.addr());}inline IPAddress&IPAddress::operator|=(IPAddress a){    _addr |= a._addr;    return *this;}inline IPAddressoperator^(IPAddress a, IPAddress b){    return IPAddress(a.addr() ^ b.addr());}inline IPAddress&IPAddress::operator^=(IPAddress a){    _addr ^= a._addr;    return *this;}inline IPAddressoperator~(IPAddress a){    return IPAddress(~a.addr());}inline unsignedhashcode(IPAddress a){    return a.addr();}CLICK_ENDDECLS#endif

⌨️ 快捷键说明

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