#ifndef _SQUID_IP_IPADDRESS_H
#define _SQUID_IP_IPADDRESS_H
-#include "config.h"
-
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
-#ifdef _SQUID_MSWIN_
+#if HAVE_NETINET_IP_H
+#include <netinet/ip.h>
+#endif
+#if _SQUID_MSWIN_
#include <ws2tcpip.h>
#endif
#if HAVE_NETDB_H
public:
/** @name Constructors and Destructor */
/*@{*/
- Address();
+ Address() { SetEmpty(); }
Address(const Address &);
/**
Address(const struct hostent &);
Address(const struct addrinfo &);
Address(const char*);
- /// Default destructor.
- ~Address();
+ ~Address() {}
/*@}*/
/** @name Assignment Operators */
/* methods */
/** Test whether content can be used as an IPv4 address
- \retval true if content was received as an IPv4 address
\retval true if content was received as an IPv4-Mapped address
\retval false if content was received as a non-mapped IPv6 native address.
*/
bool IsIPv4() const;
/** Test whether content can be used as an IPv6 address.
- \retval true if --enable-ipv6 has been compiled.
- \retval false if --disable-ipv6 has been compiled.
- \retval false if --with-ipv6-split-stack has been compiled AND content is IPv4-mapped.
+ \retval true if content is a non IPv4-mapped address.
+ \retval false if content is IPv4-mapped.
*/
bool IsIPv6() const;
bool IsLocalhost() const;
/** Test whether content is an IPv6 Site-Local address.
- \retval true if address begins with fe80::/10.
+ \retval true if address begins with fd00::/8.
\retval false if --disable-ipv6 has been compiled.
- \retval false if address does not match fe80::/10
+ \retval false if address does not match fd00::/8
*/
bool IsSiteLocal6() const;
\retval 0 Port is unset or an error occured.
\retval n Port associated with this address in host native -endian.
*/
- u_short GetPort() const;
+ unsigned short GetPort() const;
/** Set the Port value for an address.
* Replaces any previously existing Port value.
\retval 0 Port is unset or an error occured.
\retval n Port associated with this address in host native -endian.
*/
- u_short SetPort(u_short port);
+ unsigned short SetPort(unsigned short port);
/// Set object to contain the specific IP case ANY_ADDR (format-neutral).
/// see IsAnyAddr() for more detail.
/** Apply a mask to the stored address.
\param mask Netmask format to be bit-mask-AND'd over the stored address.
*/
- const int ApplyMask(const Address &mask);
+ int ApplyMask(const Address &mask);
/** Apply a mask to the stored address.
* CIDR will be converted appropriate to map the stored content.
*/
bool ApplyMask(const unsigned int cidr, int mtype);
-
/** Return the ASCII equivalent of the address
* Semantically equivalent to the IPv4 inet_ntoa()
* eg. 127.0.0.1 (IPv4) or ::1 (IPv6)
* eg. 127.0.0.1 (IPv4) or [::1] (IPv6)
\param buf Allocated buffer to write address to
\param len byte length of buffer available for writing.
- \return pointer to buffer received.
+ \return amount of buffer filled.
*/
unsigned int ToHostname(char *buf, const unsigned int len) const;
static const struct in6_addr v6_noaddr;
};
-
inline std::ostream &
operator << (std::ostream &os, const Address &ipa)
{
Address_list *next;
};
-}; // namespace Ip
+} // namespace Ip
extern void parse_IpAddress_list_token(Ip::Address_list **, char *);