mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 19:18:19 +00:00
IPAddr: minor cleanup
- Mark empty constructors/destructors as default - Initialization cleanup - Remove unnecessary elses from before returns
This commit is contained in:
parent
8424b68d77
commit
e3ecaa1297
1 changed files with 17 additions and 17 deletions
34
src/IPAddr.h
34
src/IPAddr.h
|
@ -136,7 +136,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~IPAddr() { };
|
~IPAddr() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the address' family.
|
* Returns the address' family.
|
||||||
|
@ -145,8 +145,8 @@ public:
|
||||||
{
|
{
|
||||||
if ( memcmp(in6.s6_addr, v4_mapped_prefix, 12) == 0 )
|
if ( memcmp(in6.s6_addr, v4_mapped_prefix, 12) == 0 )
|
||||||
return IPv4;
|
return IPv4;
|
||||||
else
|
|
||||||
return IPv6;
|
return IPv6;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,8 +161,8 @@ public:
|
||||||
{
|
{
|
||||||
if ( GetFamily() == IPv4 )
|
if ( GetFamily() == IPv4 )
|
||||||
return in6.s6_addr[12] == 224;
|
return in6.s6_addr[12] == 224;
|
||||||
else
|
|
||||||
return in6.s6_addr[0] == 0xff;
|
return in6.s6_addr[0] == 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -173,8 +173,8 @@ public:
|
||||||
if ( GetFamily() == IPv4 )
|
if ( GetFamily() == IPv4 )
|
||||||
return ((in6.s6_addr[12] == 0xff) && (in6.s6_addr[13] == 0xff)
|
return ((in6.s6_addr[12] == 0xff) && (in6.s6_addr[13] == 0xff)
|
||||||
&& (in6.s6_addr[14] == 0xff) && (in6.s6_addr[15] == 0xff));
|
&& (in6.s6_addr[14] == 0xff) && (in6.s6_addr[15] == 0xff));
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -305,25 +305,25 @@ public:
|
||||||
* will be returned in dotted representation, IPv6 addresses in
|
* will be returned in dotted representation, IPv6 addresses in
|
||||||
* compressed hex.
|
* compressed hex.
|
||||||
*/
|
*/
|
||||||
string AsString() const;
|
std::string AsString() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string representation of the address suitable for inclusion
|
* Returns a string representation of the address suitable for inclusion
|
||||||
* in an URI. For IPv4 addresses, this is the same as AsString(), but
|
* in an URI. For IPv4 addresses, this is the same as AsString(), but
|
||||||
* IPv6 addresses are encased in square brackets.
|
* IPv6 addresses are encased in square brackets.
|
||||||
*/
|
*/
|
||||||
string AsURIString() const
|
std::string AsURIString() const
|
||||||
{
|
{
|
||||||
if ( GetFamily() == IPv4 )
|
if ( GetFamily() == IPv4 )
|
||||||
return AsString();
|
return AsString();
|
||||||
else
|
|
||||||
return string("[") + AsString() + "]";
|
return string("[") + AsString() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a host-order, plain hex string representation of the address.
|
* Returns a host-order, plain hex string representation of the address.
|
||||||
*/
|
*/
|
||||||
string AsHexString() const;
|
std::string AsHexString() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string representation of the address. This returns the
|
* Returns a string representation of the address. This returns the
|
||||||
|
@ -335,7 +335,7 @@ public:
|
||||||
* Returns a reverse pointer name associated with the IP address.
|
* Returns a reverse pointer name associated with the IP address.
|
||||||
* For example, 192.168.0.1's reverse pointer is 1.0.168.192.in-addr.arpa.
|
* For example, 192.168.0.1's reverse pointer is 1.0.168.192.in-addr.arpa.
|
||||||
*/
|
*/
|
||||||
string PtrName() const;
|
std::string PtrName() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comparison operator for IP address.
|
* Comparison operator for IP address.
|
||||||
|
@ -528,7 +528,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Constructs a prefix 0/0.
|
* Constructs a prefix 0/0.
|
||||||
*/
|
*/
|
||||||
IPPrefix() : length(0) {}
|
IPPrefix() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a prefix instance from an IPv4 address and a prefix
|
* Constructs a prefix instance from an IPv4 address and a prefix
|
||||||
|
@ -575,7 +575,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Destructor.
|
* Destructor.
|
||||||
*/
|
*/
|
||||||
~IPPrefix() { }
|
~IPPrefix() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the prefix in the form of an IP address. The address will
|
* Returns the prefix in the form of an IP address. The address will
|
||||||
|
@ -625,7 +625,7 @@ public:
|
||||||
* will be returned in dotted representation, IPv6 addresses in
|
* will be returned in dotted representation, IPv6 addresses in
|
||||||
* compressed hex.
|
* compressed hex.
|
||||||
*/
|
*/
|
||||||
string AsString() const;
|
std::string AsString() const;
|
||||||
|
|
||||||
operator std::string() const { return AsString(); }
|
operator std::string() const { return AsString(); }
|
||||||
|
|
||||||
|
@ -715,5 +715,5 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IPAddr prefix; // We store it as an address with the non-prefix bits masked out via Mask().
|
IPAddr prefix; // We store it as an address with the non-prefix bits masked out via Mask().
|
||||||
uint8_t length; // The bit length of the prefix relative to full IPv6 addr.
|
uint8_t length = 0; // The bit length of the prefix relative to full IPv6 addr.
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue