From a6d58bb6052ac8cb01805a48c4ad2f129126116f Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 24 Feb 2010 02:13:59 +0000 Subject: Added KDE3 version of kvirc git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kvirc@1095341 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/kvilib/net/kvi_netutils.h | 104 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 src/kvilib/net/kvi_netutils.h (limited to 'src/kvilib/net/kvi_netutils.h') diff --git a/src/kvilib/net/kvi_netutils.h b/src/kvilib/net/kvi_netutils.h new file mode 100644 index 00000000..b43326f0 --- /dev/null +++ b/src/kvilib/net/kvi_netutils.h @@ -0,0 +1,104 @@ +#ifndef _KVI_NETUTILS_H_ +#define _KVI_NETUTILS_H_ + +// +// File : kvi_netutlis.h +// Creation date : Sun Jun 18 2000 18:37:27 by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// + +#include "kvi_settings.h" +#include "kvi_inttypes.h" + +#ifdef COMPILE_ON_WINDOWS + #include + #ifdef COMPILE_IPV6_SUPPORT + #ifdef WIN2K + #include + #else + #include + //#include + #define in6_addr in_addr6 + #endif + #endif +#else + #include + #include + #include //in_addr + #include //inet_ntoa inet_ntop and inet_pton depend on this one. +#endif + +#include "kvi_string.h" + + +KVILIB_API extern bool kvi_isValidStringIp(const char * szIp); +KVILIB_API extern bool kvi_stringIpToBinaryIp(const char * szIp,struct in_addr * address); +KVILIB_API extern bool kvi_binaryIpToStringIp(struct in_addr in,QString &szBuffer); + +#ifdef COMPILE_IPV6_SUPPORT + KVILIB_API extern bool kvi_isValidStringIp_V6(const char * szIp); + KVILIB_API extern bool kvi_stringIpToBinaryIp_V6(const char * szIp,struct in6_addr * address); + KVILIB_API extern bool kvi_binaryIpToStringIp_V6(struct in6_addr in,QString &szBuffer); +#endif + +class KVILIB_API KviSockaddr +{ +public: + KviSockaddr(const char * szIpAddress,kvi_u32_t uPort,bool bIpV6,bool bUdp = false); + KviSockaddr(kvi_u32_t uPort,bool bIpV6,bool bUdp = false); // passive + ~KviSockaddr(); +private: + void * m_pData; //addrinfo +public: + struct sockaddr * socketAddress(); + size_t addressLength(); + int addressFamily(); + bool isIpV6(); + bool getStringAddress(QString &szBuffer); + kvi_u32_t port(); + +}; + + +KVILIB_API extern bool kvi_select(int fd,bool * bCanRead,bool * bCanWrite,int iUSecs = 0); +KVILIB_API extern bool kvi_getInterfaceAddress(const char * ifname,QString &buffer); + +// Warning : NOT THREAD SAFE! +KVILIB_API extern bool kvi_getLocalHostAddress(QString &buffer); +KVILIB_API extern bool kvi_isRoutableIp(const char * ipaddr); +KVILIB_API extern bool kvi_isRoutableIpString(const char * ipstring); + +namespace KviNetUtils +{ + KVILIB_API bool stringIpToBinaryIp(const QString &szStringIp,struct in_addr * address); + KVILIB_API bool isValidStringIp(const QString &szStringIp); + KVILIB_API bool binaryIpToStringIp(struct in_addr in,QString &szBuffer); + KVILIB_API bool getInterfaceAddress(const QString &szInterfaceName,QString &szBuffer); +#ifdef COMPILE_IPV6_SUPPORT + KVILIB_API bool isValidStringIp_V6(const QString &szStringIp); + KVILIB_API bool stringIpToBinaryIp_V6(const QString &szStringIp,struct in6_addr * address); + KVILIB_API bool binaryIpToStringIp_V6(struct in6_addr in,QString &szBuffer); +#endif + KVILIB_API bool isRoutableIp(const char * ipaddr); + KVILIB_API bool isRoutableIpString(const QString &szIpString); + KVILIB_API void formatNetworkBandwidthString(QString &szBuffer,unsigned int uBytesPerSec); +}; + + +#endif //!_KVI_NETUTILS_H_ -- cgit v1.2.1