|
|
@ -191,17 +191,19 @@ TQString KIpAddress::toString() const
|
|
|
|
char buf[sizeof "1111:2222:3333:4444:5555:6666:255.255.255.255" + 2];
|
|
|
|
char buf[sizeof "1111:2222:3333:4444:5555:6666:255.255.255.255" + 2];
|
|
|
|
buf[0] = '\0';
|
|
|
|
buf[0] = '\0';
|
|
|
|
switch (m_version)
|
|
|
|
switch (m_version)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case 4:
|
|
|
|
case 4:
|
|
|
|
inet_ntop(AF_INET, m_data, buf, sizeof(buf) - 1);
|
|
|
|
inet_ntop(AF_INET, m_data, buf, sizeof(buf) - 1);
|
|
|
|
return TQString::fromLatin1(buf);
|
|
|
|
return TQString::fromLatin1(buf);
|
|
|
|
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
case 6:
|
|
|
|
|
|
|
|
{
|
|
|
|
#ifdef AF_INET6
|
|
|
|
#ifdef AF_INET6
|
|
|
|
inet_ntop(AF_INET6, m_data, buf, sizeof(buf) - 1);
|
|
|
|
inet_ntop(AF_INET6, m_data, buf, sizeof(buf) - 1);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
return TQString::fromLatin1(buf);
|
|
|
|
return TQString::fromLatin1(buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return TQString::null;
|
|
|
|
return TQString::null;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -294,11 +296,15 @@ public:
|
|
|
|
switch (addr.generic->sa_family)
|
|
|
|
switch (addr.generic->sa_family)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case AF_INET:
|
|
|
|
case AF_INET:
|
|
|
|
|
|
|
|
{
|
|
|
|
return; // nothing to do here
|
|
|
|
return; // nothing to do here
|
|
|
|
|
|
|
|
}
|
|
|
|
#ifdef AF_INET6
|
|
|
|
#ifdef AF_INET6
|
|
|
|
case AF_INET6:
|
|
|
|
case AF_INET6:
|
|
|
|
|
|
|
|
{
|
|
|
|
oldport = addr.in6->sin6_port;
|
|
|
|
oldport = addr.in6->sin6_port;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -319,12 +325,16 @@ public:
|
|
|
|
switch (addr.generic->sa_family)
|
|
|
|
switch (addr.generic->sa_family)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case AF_INET:
|
|
|
|
case AF_INET:
|
|
|
|
|
|
|
|
{
|
|
|
|
oldport = addr.in->sin_port;
|
|
|
|
oldport = addr.in->sin_port;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef AF_INET6
|
|
|
|
#ifdef AF_INET6
|
|
|
|
case AF_INET6:
|
|
|
|
case AF_INET6:
|
|
|
|
|
|
|
|
{
|
|
|
|
return; // nothing to do here
|
|
|
|
return; // nothing to do here
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -517,12 +527,15 @@ bool TDESocketAddress::operator ==(const TDESocketAddress& other) const
|
|
|
|
switch (d->addr.generic->sa_family)
|
|
|
|
switch (d->addr.generic->sa_family)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case AF_INET:
|
|
|
|
case AF_INET:
|
|
|
|
|
|
|
|
{
|
|
|
|
Q_ASSERT(d->reallen == SOCKADDR_IN_LEN);
|
|
|
|
Q_ASSERT(d->reallen == SOCKADDR_IN_LEN);
|
|
|
|
Q_ASSERT(other.d->reallen == SOCKADDR_IN_LEN);
|
|
|
|
Q_ASSERT(other.d->reallen == SOCKADDR_IN_LEN);
|
|
|
|
return memcmp(d->addr.in, other.d->addr.in, SOCKADDR_IN_LEN) == 0;
|
|
|
|
return memcmp(d->addr.in, other.d->addr.in, SOCKADDR_IN_LEN) == 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef AF_INET6
|
|
|
|
#ifdef AF_INET6
|
|
|
|
case AF_INET6:
|
|
|
|
case AF_INET6:
|
|
|
|
|
|
|
|
{
|
|
|
|
Q_ASSERT(d->reallen >= MIN_SOCKADDR_IN6_LEN);
|
|
|
|
Q_ASSERT(d->reallen >= MIN_SOCKADDR_IN6_LEN);
|
|
|
|
Q_ASSERT(other.d->reallen >= MIN_SOCKADDR_IN6_LEN);
|
|
|
|
Q_ASSERT(other.d->reallen >= MIN_SOCKADDR_IN6_LEN);
|
|
|
|
|
|
|
|
|
|
|
@ -540,6 +553,7 @@ bool TDESocketAddress::operator ==(const TDESocketAddress& other) const
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
|
|
return memcmp(d->addr.in6, other.d->addr.in6, d->reallen) == 0;
|
|
|
|
return memcmp(d->addr.in6, other.d->addr.in6, d->reallen) == 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
case AF_UNIX:
|
|
|
|
case AF_UNIX:
|
|
|
@ -566,10 +580,11 @@ TQString TDESocketAddress::nodeName() const
|
|
|
|
|
|
|
|
|
|
|
|
switch (d->addr.generic->sa_family)
|
|
|
|
switch (d->addr.generic->sa_family)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case AF_INET:
|
|
|
|
|
|
|
|
#ifdef AF_INET6
|
|
|
|
#ifdef AF_INET6
|
|
|
|
case AF_INET6:
|
|
|
|
case AF_INET6:
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case AF_INET:
|
|
|
|
|
|
|
|
#ifdef AF_INET6
|
|
|
|
TQString scopeid("%");
|
|
|
|
TQString scopeid("%");
|
|
|
|
if (d->addr.generic->sa_family == AF_INET6 && d->addr.in6->sin6_scope_id)
|
|
|
|
if (d->addr.generic->sa_family == AF_INET6 && d->addr.in6->sin6_scope_id)
|
|
|
|
scopeid += TQString::number(d->addr.in6->sin6_scope_id);
|
|
|
|
scopeid += TQString::number(d->addr.in6->sin6_scope_id);
|
|
|
@ -592,10 +607,10 @@ TQString TDESocketAddress::serviceName() const
|
|
|
|
|
|
|
|
|
|
|
|
switch (d->addr.generic->sa_family)
|
|
|
|
switch (d->addr.generic->sa_family)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case AF_INET:
|
|
|
|
|
|
|
|
#ifdef AF_INET6
|
|
|
|
#ifdef AF_INET6
|
|
|
|
case AF_INET6:
|
|
|
|
case AF_INET6:
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case AF_INET:
|
|
|
|
return TQString::number(d->ref.port());
|
|
|
|
return TQString::number(d->ref.port());
|
|
|
|
|
|
|
|
|
|
|
|
case AF_UNIX:
|
|
|
|
case AF_UNIX:
|
|
|
@ -652,11 +667,15 @@ int TDESocketAddress::ianaFamily(int af)
|
|
|
|
switch (af)
|
|
|
|
switch (af)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case AF_INET:
|
|
|
|
case AF_INET:
|
|
|
|
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef AF_INET6
|
|
|
|
#ifdef AF_INET6
|
|
|
|
case AF_INET6:
|
|
|
|
case AF_INET6:
|
|
|
|
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
@ -669,11 +688,15 @@ int TDESocketAddress::fromIanaFamily(int iana)
|
|
|
|
switch (iana)
|
|
|
|
switch (iana)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
{
|
|
|
|
return AF_INET;
|
|
|
|
return AF_INET;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef AF_INET6
|
|
|
|
#ifdef AF_INET6
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
{
|
|
|
|
return AF_INET6;
|
|
|
|
return AF_INET6;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
@ -743,11 +766,15 @@ int KInetSocketAddress::ipVersion() const
|
|
|
|
switch (d->addr.generic->sa_family)
|
|
|
|
switch (d->addr.generic->sa_family)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case AF_INET:
|
|
|
|
case AF_INET:
|
|
|
|
|
|
|
|
{
|
|
|
|
return 4;
|
|
|
|
return 4;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef AF_INET6
|
|
|
|
#ifdef AF_INET6
|
|
|
|
case AF_INET6:
|
|
|
|
case AF_INET6:
|
|
|
|
|
|
|
|
{
|
|
|
|
return 6;
|
|
|
|
return 6;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -762,10 +789,14 @@ KIpAddress KInetSocketAddress::ipAddress() const
|
|
|
|
switch (d->addr.generic->sa_family)
|
|
|
|
switch (d->addr.generic->sa_family)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case AF_INET:
|
|
|
|
case AF_INET:
|
|
|
|
|
|
|
|
{
|
|
|
|
return KIpAddress(&d->addr.in->sin_addr, 4);
|
|
|
|
return KIpAddress(&d->addr.in->sin_addr, 4);
|
|
|
|
|
|
|
|
}
|
|
|
|
#ifdef AF_INET6
|
|
|
|
#ifdef AF_INET6
|
|
|
|
case AF_INET6:
|
|
|
|
case AF_INET6:
|
|
|
|
|
|
|
|
{
|
|
|
|
return KIpAddress(&d->addr.in6->sin6_addr, 6);
|
|
|
|
return KIpAddress(&d->addr.in6->sin6_addr, 6);
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -803,11 +834,15 @@ TQ_UINT16 KInetSocketAddress::port() const
|
|
|
|
switch (d->addr.generic->sa_family)
|
|
|
|
switch (d->addr.generic->sa_family)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case AF_INET:
|
|
|
|
case AF_INET:
|
|
|
|
|
|
|
|
{
|
|
|
|
return ntohs(d->addr.in->sin_port);
|
|
|
|
return ntohs(d->addr.in->sin_port);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef AF_INET6
|
|
|
|
#ifdef AF_INET6
|
|
|
|
case AF_INET6:
|
|
|
|
case AF_INET6:
|
|
|
|
|
|
|
|
{
|
|
|
|
return ntohs(d->addr.in6->sin6_port);
|
|
|
|
return ntohs(d->addr.in6->sin6_port);
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -822,13 +857,17 @@ KInetSocketAddress& KInetSocketAddress::setPort(TQ_UINT16 port)
|
|
|
|
switch (d->addr.generic->sa_family)
|
|
|
|
switch (d->addr.generic->sa_family)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case AF_INET:
|
|
|
|
case AF_INET:
|
|
|
|
|
|
|
|
{
|
|
|
|
d->addr.in->sin_port = htons(port);
|
|
|
|
d->addr.in->sin_port = htons(port);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef AF_INET6
|
|
|
|
#ifdef AF_INET6
|
|
|
|
case AF_INET6:
|
|
|
|
case AF_INET6:
|
|
|
|
|
|
|
|
{
|
|
|
|
d->addr.in6->sin6_port = htons(port);
|
|
|
|
d->addr.in6->sin6_port = htons(port);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|