11#ifndef SQUID_SRC_IP_ADDRESS_H
12#define SQUID_SRC_IP_ADDRESS_H
19#include <sys/socket.h>
22#include <netinet/in.h>
25#include <netinet/ip.h>
52 static std::optional<Address>
Parse(
const char *);
57 Address(
const struct in_addr &);
58 Address(
const struct sockaddr_in &);
59 Address(
const struct in6_addr &);
60 Address(
const struct sockaddr_in6 &);
61 Address(
const struct hostent &);
62 Address(
const struct addrinfo &);
157 unsigned short port()
const;
165 unsigned short port(
unsigned short port);
228 char*
toStr(
char *buf,
const unsigned int blen,
int force = AF_UNSPEC)
const;
238 char*
toUrl(
char *buf,
unsigned int len)
const;
248 unsigned int toHostStr(
char *buf,
const unsigned int len)
const;
253 bool fromHost(
const char *hostWithoutPort);
296 void getAddrInfo(
struct addrinfo *&ai,
int force = AF_UNSPEC)
const;
301 static void FreeAddr(
struct addrinfo *&ai);
309 static void InitAddr(
struct addrinfo *&ai);
334 void getSockAddr(
struct sockaddr_storage &addr,
const int family)
const;
347 void map4to6(
const struct in_addr &src,
struct in6_addr &dest)
const;
349 void map6to4(
const struct in6_addr &src,
struct in_addr &dest)
const;
char * toStr(char *buf, const unsigned int blen, int force=AF_UNSPEC) const
void map4to6(const struct in_addr &src, struct in6_addr &dest) const
bool isSiteLocal6() const
void setEmpty()
Fast reset of the stored content to what would be after default constructor.
static void InitAddr(struct addrinfo *&ai)
void getSockAddr(struct sockaddr_storage &addr, const int family) const
bool operator==(Address const &s) const
static const unsigned int STRLEN_IP4A
unsigned int toHostStr(char *buf, const unsigned int len) const
bool operator>(Address const &rhs) const
int compareWhole(const Ip::Address &rhs) const
static void FreeAddr(struct addrinfo *&ai)
bool lookupHostIP(const char *s, bool nodns)
static std::optional< Address > Parse(const char *)
bool getReverseString6(char buf[MAX_IPSTRLEN], const struct in6_addr &dat) const
void getAddrInfo(struct addrinfo *&ai, int force=AF_UNSPEC) const
bool operator>=(Address const &rhs) const
bool GetHostByName(const char *s)
void applyClientMask(const Address &mask)
static const unsigned int MAX_IP4_STRLEN
bool getReverseString4(char buf[MAX_IPSTRLEN], const struct in_addr &dat) const
static const Address & NoAddr()
bool fromHost(const char *hostWithoutPort)
static const unsigned int MAX_IP6_STRLEN
int matchIPAddr(const Address &rhs) const
struct sockaddr_in6 mSocketAddr_
void turnMaskedBitsOn(const Address &mask)
static const struct in6_addr v6_noaddr
bool isSiteLocalAuto() const
bool operator<(Address const &rhs) const
bool operator!=(Address const &s) const
static const struct in6_addr v4_noaddr
static const unsigned int STRLEN_IP4S
bool getReverseString(char buf[MAX_IPSTRLEN], int show_type=AF_UNSPEC) const
Address & operator=(struct sockaddr_in const &s)
char * toUrl(char *buf, unsigned int len) const
bool getInAddr(struct in_addr &) const
int applyMask(const Address &mask)
void setAnyAddr()
NOTE: Does NOT clear the Port stored. Only the Address and Type.
static const unsigned int STRLEN_IP6S
static const unsigned int STRLEN_IP6R
bool operator<=(Address const &rhs) const
static const struct in6_addr v4_localhost
static const unsigned int STRLEN_IP6A
unsigned short port() const
static const struct in6_addr v4_anyaddr
void map6to4(const struct in6_addr &src, struct in_addr &dest) const
static const unsigned int STRLEN_IP4R
void parse_IpAddress_list_token(Ip::Address_list **, char *)
#define MAX_IPSTRLEN
Length of buffer that needs to be allocated to old a null-terminated IP-string.
std::ostream & operator<<(std::ostream &os, const std::optional< Address > &optional)