diff options
author | rubidium <rubidium@openttd.org> | 2009-04-08 00:26:49 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-04-08 00:26:49 +0000 |
commit | 1eb4aa971ea329f18dd77b58bf7fc84d6240ea57 (patch) | |
tree | 1ad07f3d117ba228cdefef45c50d0fbc2baeed17 /src/network/core/address.h | |
parent | d466fa96727cdf0087367cb40dcba286ecec1878 (diff) | |
download | openttd-1eb4aa971ea329f18dd77b58bf7fc84d6240ea57.tar.xz |
(svn r15975) -Codechange: register each of the IPs we have bound to to the masterserver
Diffstat (limited to 'src/network/core/address.h')
-rw-r--r-- | src/network/core/address.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/network/core/address.h b/src/network/core/address.h index 4c0abdf63..0d0f61f7e 100644 --- a/src/network/core/address.h +++ b/src/network/core/address.h @@ -92,7 +92,13 @@ public: NetworkAddress(const char *hostname = "0.0.0.0", uint16 port = 0, int family = AF_INET) : address_length(0) { + /* Also handle IPv6 bracket enclosed hostnames */ + if (StrEmpty(hostname)) hostname = ""; + if (*hostname == '[') hostname++; strecpy(this->hostname, StrEmpty(hostname) ? "" : hostname, lastof(this->hostname)); + char *tmp = strrchr(hostname, ']'); + if (tmp != NULL) *tmp = '\0'; + memset(&this->address, 0, sizeof(this->address)); this->address.ss_family = family; this->SetPort(port); @@ -159,6 +165,13 @@ public: } /** + * Checks of this address is of the given family. + * @param family the family to check against + * @return true if it is of the given family + */ + bool IsFamily(int family); + + /** * Checks whether this IP address is contained by the given netmask. * @param netmask the netmask in CIDR notation to test against. * @note netmask without /n assumes all bits need to match. |