aboutsummaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-01-03 23:33:31 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2012-01-06 18:55:37 +0100
commit67a42f929b1434f647c63922fd02dc2b93b28060 (patch)
tree9c4313e815bd77e817f2dc5b796347d343458d0e /src/util.h
parent7486c64dd8436febbe59e82dbb875e83ad6b5194 (diff)
downloadbitcoin-67a42f929b1434f647c63922fd02dc2b93b28060.tar.xz
Network stack refactor
This introduces CNetAddr and CService, respectively wrapping an (IPv6) IP address and an IP+port combination. This functionality used to be part of CAddress, which also contains network flags and connection attempt information. These extra fields are however not always necessary. These classes, along with logic for creating connections and doing name lookups, are moved to netbase.{h,cpp}, which does not depend on headers.h. Furthermore, CNetAddr is mostly IPv6-ready, though IPv6 functionality is not yet enabled for the application itself.
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h30
1 files changed, 3 insertions, 27 deletions
diff --git a/src/util.h b/src/util.h
index 48fea023bf..1c24ed71e9 100644
--- a/src/util.h
+++ b/src/util.h
@@ -24,6 +24,7 @@
#include <openssl/sha.h>
#include <openssl/ripemd.h>
+#include "netbase.h"
typedef long long int64;
typedef unsigned long long uint64;
@@ -79,20 +80,7 @@ T* alignup(T* p)
#define S_IWUSR 0200
#endif
#define unlink _unlink
-typedef int socklen_t;
#else
-#define WSAGetLastError() errno
-#define WSAEINVAL EINVAL
-#define WSAEALREADY EALREADY
-#define WSAEWOULDBLOCK EWOULDBLOCK
-#define WSAEMSGSIZE EMSGSIZE
-#define WSAEINTR EINTR
-#define WSAEINPROGRESS EINPROGRESS
-#define WSAEADDRINUSE EADDRINUSE
-#define WSAENOTSOCK EBADF
-#define INVALID_SOCKET (SOCKET)(~0)
-#define SOCKET_ERROR -1
-typedef u_int SOCKET;
#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d)
#define strlwr(psz) to_lower(psz)
#define _strlwr(psz) to_lower(psz)
@@ -104,19 +92,6 @@ inline void Sleep(int64 n)
}
#endif
-inline int myclosesocket(SOCKET& hSocket)
-{
- if (hSocket == INVALID_SOCKET)
- return WSAENOTSOCK;
-#ifdef WIN32
- int ret = closesocket(hSocket);
-#else
- int ret = close(hSocket);
-#endif
- hSocket = INVALID_SOCKET;
- return ret;
-}
-#define closesocket(s) myclosesocket(s)
#if !defined(QT_GUI)
inline const char* _(const char* psz)
{
@@ -187,9 +162,9 @@ uint64 GetRand(uint64 nMax);
int64 GetTime();
void SetMockTime(int64 nMockTimeIn);
int64 GetAdjustedTime();
-void AddTimeData(unsigned int ip, int64 nTime);
std::string FormatFullVersion();
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments);
+void AddTimeData(const CNetAddr& ip, int64 nTime);
@@ -745,3 +720,4 @@ inline uint32_t ByteReverse(uint32_t value)
}
#endif
+