Browse Source

m_win32 and m_win64

release/v0.1
jl777 9 years ago
parent
commit
73d7bde3a5
  1. 2
      .gitignore
  2. 4
      README.md
  3. 449
      crypto777/OS_nonportable.c
  4. 21
      crypto777/OS_portable.c
  5. 22
      crypto777/OS_portable.h
  6. 4
      crypto777/OS_time.c
  7. 6
      crypto777/hmac/tiger.c
  8. 4
      crypto777/iguana_OS.c
  9. 47
      crypto777/inet.c
  10. 0
      crypto777/pnacl_libs/libcrypto.a
  11. 0
      crypto777/pnacl_libs/libcurl.a
  12. 0
      crypto777/pnacl_libs/libnanomsg.a
  13. 0
      crypto777/pnacl_libs/libssl.a
  14. 0
      crypto777/pnacl_libs/libz.a
  15. 887
      deprecated/iguana_recv.c
  16. 2
      iguana/iguana777.c
  17. 7
      iguana/iguana777.h
  18. 10
      iguana/iguana_peers.c
  19. 10
      iguana/iguana_pubkeys.c
  20. 50
      iguana/iguana_ramchain.c
  21. 10
      iguana/iguana_rpc.c
  22. 3
      iguana/m_win32
  23. 14
      iguana/mingw
  24. 9
      iguana/mingw32
  25. 9
      iguana/mingw64
  26. 4
      includes/nonportable.h
  27. 2
      includes/openssl/aes.h
  28. 14
      includes/openssl/asn1.h
  29. 2
      includes/openssl/asn1_mac.h
  30. 4
      includes/openssl/asn1t.h
  31. 4
      includes/openssl/bio.h
  32. 2
      includes/openssl/blowfish.h
  33. 6
      includes/openssl/bn.h
  34. 2
      includes/openssl/buffer.h
  35. 2
      includes/openssl/camellia.h
  36. 2
      includes/openssl/cast.h
  37. 2
      includes/openssl/cmac.h
  38. 2
      includes/openssl/cms.h
  39. 2
      includes/openssl/comp.h
  40. 12
      includes/openssl/conf.h
  41. 4
      includes/openssl/conf_api.h
  42. 14
      includes/openssl/crypto.h
  43. 0
      includes/openssl/curl.h
  44. 0
      includes/openssl/curlbuild.h
  45. 0
      includes/openssl/curlrules.h
  46. 0
      includes/openssl/curlver.h
  47. 2
      includes/openssl/des.h
  48. 6
      includes/openssl/des_old.h
  49. 8
      includes/openssl/dh.h
  50. 12
      includes/openssl/dsa.h
  51. 2
      includes/openssl/dso.h
  52. 4
      includes/openssl/dtls1.h
  53. 741
      includes/openssl/e_os.h
  54. 2
      includes/openssl/e_os2.h
  55. 0
      includes/openssl/easy.h
  56. 0
      includes/openssl/ebcdic.h
  57. 8
      includes/openssl/ec.h
  58. 8
      includes/openssl/ecdh.h
  59. 8
      includes/openssl/ecdsa.h
  60. 26
      includes/openssl/engine.h
  61. 8
      includes/openssl/err.h
  62. 12
      includes/openssl/evp.h
  63. 4
      includes/openssl/hmac.h
  64. 2
      includes/openssl/idea.h
  65. 2
      includes/openssl/krb5_asn.h
  66. 2
      includes/openssl/kssl.h
  67. 4
      includes/openssl/lhash.h
  68. 2
      includes/openssl/md4.h
  69. 2
      includes/openssl/md5.h
  70. 2
      includes/openssl/mdc2.h
  71. 0
      includes/openssl/modes.h
  72. 0
      includes/openssl/mprintf.h
  73. 0
      includes/openssl/multi.h
  74. 0
      includes/openssl/obj_mac.h
  75. 6
      includes/openssl/objects.h
  76. 8
      includes/openssl/ocsp.h
  77. 0
      includes/openssl/opensslconf.h
  78. 0
      includes/openssl/opensslv.h
  79. 2
      includes/openssl/ossl_typ.h
  80. 14
      includes/openssl/pem.h
  81. 0
      includes/openssl/pem2.h
  82. 4
      includes/openssl/pkcs12.h
  83. 10
      includes/openssl/pkcs7.h
  84. 0
      includes/openssl/pqueue.h
  85. 4
      includes/openssl/rand.h
  86. 2
      includes/openssl/rc2.h
  87. 2
      includes/openssl/rc4.h
  88. 2
      includes/openssl/ripemd.h
  89. 10
      includes/openssl/rsa.h
  90. 2
      includes/openssl/safestack.h
  91. 6
      includes/openssl/seed.h
  92. 2
      includes/openssl/sha.h
  93. 6
      includes/openssl/srp.h
  94. 0
      includes/openssl/srtp.h
  95. 36
      includes/openssl/ssl.h
  96. 0
      includes/openssl/ssl2.h
  97. 0
      includes/openssl/ssl23.h
  98. 8
      includes/openssl/ssl3.h
  99. 0
      includes/openssl/stack.h
  100. 0
      includes/openssl/stdcheaders.h

2
.gitignore

@ -4,3 +4,5 @@
agents/iguana
agents/libcrypto777.a
agents/iguana.exe

4
README.md

@ -20,7 +20,9 @@ Just make sure you have the dev versions of openssl and curl installed:
```sudo apt-get install libcurl4-gnutls-dev libssl-dev```
##For native (win32, win64)##
This still needs to be ported, pthreads is the only non-native windows system functions being used. OS_portable.c and OS_nonportable.c have the few windows functions that are needed to be ported and also a compile/link process needs to be done. I think cygwin or even mingw would work, alternatively compiling the codebase with VS shouldnt be too much work. Until this is done the instructions below about m_win32 and m_win64 wont actually work.
TOOL_DIR := /usr/local/gcc-4.8.0-qt-4.8.4-for-mingw32/win32-gcc/bin
MINGW := i586-mingw32
The above two definitions need to be changed to match the mingw install on your system. m_win32 and m_win64 just invokes the makefile in mingw32 and mingw64
##For chrome app##
You need to make sure the nacl sdk is properly installed and you are able to build the examples.

449
crypto777/OS_nonportable.c

@ -30,7 +30,6 @@ void *OS_nonportable_tmpalloc(char *dirname,char *name,struct OS_memspace *mem,l
}
#elif _WIN32
#include <sys/mman.h>
#include <io.h>
#include <share.h>
#include <errno.h>
@ -38,7 +37,6 @@ void *OS_nonportable_tmpalloc(char *dirname,char *name,struct OS_memspace *mem,l
#include <windows.h>
#include <inttypes.h>
#include <winsock2.h>
#include <in6addr.h>
#include <ws2tcpip.h>
#include <errno.h>
#include <fcntl.h> /* _O_BINARY */
@ -49,6 +47,449 @@ void *OS_nonportable_tmpalloc(char *dirname,char *name,struct OS_memspace *mem,l
#include <tlhelp32.h>
#include <time.h>
#include <windows.h>
#include <errno.h>
#include <io.h>
#include "../win/mman.h"
#ifndef FILE_MAP_EXECUTE
#define FILE_MAP_EXECUTE 0x0020
#endif /* FILE_MAP_EXECUTE */
static int __map_mman_error(const DWORD err, const int deferr)
{
if (err == 0)
return 0;
//TODO: implement
return err;
}
static DWORD __map_mmap_prot_page(const int prot)
{
DWORD protect = 0;
if (prot == PROT_NONE)
return protect;
if ((prot & PROT_EXEC) != 0)
{
protect = ((prot & PROT_WRITE) != 0) ?
PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ;
}
else
{
protect = ((prot & PROT_WRITE) != 0) ?
PAGE_READWRITE : PAGE_READONLY;
}
return protect;
}
static DWORD __map_mmap_prot_file(const int prot)
{
DWORD desiredAccess = 0;
if (prot == PROT_NONE)
return desiredAccess;
if ((prot & PROT_READ) != 0)
desiredAccess |= FILE_MAP_READ;
if ((prot & PROT_WRITE) != 0)
desiredAccess |= FILE_MAP_WRITE;
if ((prot & PROT_EXEC) != 0)
desiredAccess |= FILE_MAP_EXECUTE;
return desiredAccess;
}
void* mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off)
{
HANDLE fm, h;
void * map = MAP_FAILED;
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4293)
#endif
const DWORD dwFileOffsetLow = (sizeof(off_t) <= sizeof(DWORD)) ?
(DWORD)off : (DWORD)(off & 0xFFFFFFFFL);
const DWORD dwFileOffsetHigh = (sizeof(off_t) <= sizeof(DWORD)) ?
(DWORD)0 : (DWORD)((off >> 32) & 0xFFFFFFFFL);
const DWORD protect = __map_mmap_prot_page(prot);
const DWORD desiredAccess = __map_mmap_prot_file(prot);
const off_t maxSize = off + (off_t)len;
const DWORD dwMaxSizeLow = (sizeof(off_t) <= sizeof(DWORD)) ?
(DWORD)maxSize : (DWORD)(maxSize & 0xFFFFFFFFL);
const DWORD dwMaxSizeHigh = (sizeof(off_t) <= sizeof(DWORD)) ?
(DWORD)0 : (DWORD)((maxSize >> 32) & 0xFFFFFFFFL);
#ifdef _MSC_VER
#pragma warning(pop)
#endif
errno = 0;
if (len == 0
/* Unsupported flag combinations */
|| (flags & MAP_FIXED) != 0
/* Usupported protection combinations */
|| prot == PROT_EXEC)
{
errno = EINVAL;
return MAP_FAILED;
}
h = ((flags & MAP_ANONYMOUS) == 0) ?
(HANDLE)_get_osfhandle(fildes) : INVALID_HANDLE_VALUE;
if ((flags & MAP_ANONYMOUS) == 0 && h == INVALID_HANDLE_VALUE)
{
errno = EBADF;
return MAP_FAILED;
}
fm = CreateFileMapping(h, NULL, protect, dwMaxSizeHigh, dwMaxSizeLow, NULL);
if (fm == NULL)
{
errno = __map_mman_error(GetLastError(), EPERM);
return MAP_FAILED;
}
map = MapViewOfFile(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len);
CloseHandle(fm);
if (map == NULL)
{
errno = __map_mman_error(GetLastError(), EPERM);
return MAP_FAILED;
}
return map;
}
int munmap(void *addr, size_t len)
{
if (UnmapViewOfFile(addr))
return 0;
errno = __map_mman_error(GetLastError(), EPERM);
return -1;
}
int _mprotect(void *addr, size_t len, int prot)
{
DWORD newProtect = __map_mmap_prot_page(prot);
DWORD oldProtect = 0;
if (VirtualProtect(addr, len, newProtect, &oldProtect))
return 0;
errno = __map_mman_error(GetLastError(), EPERM);
return -1;
}
int msync(void *addr, size_t len, int flags)
{
if (FlushViewOfFile(addr, len))
return 0;
errno = __map_mman_error(GetLastError(), EPERM);
return -1;
}
int mlock(const void *addr, size_t len)
{
if (VirtualLock((LPVOID)addr, len))
return 0;
errno = __map_mman_error(GetLastError(), EPERM);
return -1;
}
int munlock(const void *addr, size_t len)
{
if (VirtualUnlock((LPVOID)addr, len))
return 0;
errno = __map_mman_error(GetLastError(), EPERM);
return -1;
}
#undef socket
#undef connect
#undef accept
#undef shutdown
#include <string.h>
#include <errno.h>
#include <assert.h>
int win32_poll(struct pollfd *fds, unsigned int nfds, int timo)
{
struct timeval timeout, *toptr;
fd_set ifds, ofds, efds, *ip, *op;
unsigned int i, rc;
/* Set up the file-descriptor sets in ifds, ofds and efds. */
FD_ZERO(&ifds);
FD_ZERO(&ofds);
FD_ZERO(&efds);
for (i = 0, op = ip = 0; i < nfds; ++i) {
fds[i].revents = 0;
if(fds[i].events & (POLLIN|POLLPRI)) {
ip = &ifds;
FD_SET(fds[i].fd, ip);
}
if(fds[i].events & POLLOUT) {
op = &ofds;
FD_SET(fds[i].fd, op);
}
FD_SET(fds[i].fd, &efds);
}
/* Set up the timeval structure for the timeout parameter */
if(timo < 0) {
toptr = 0;
} else {
toptr = &timeout;
timeout.tv_sec = timo / 1000;
timeout.tv_usec = (timo - timeout.tv_sec * 1000) * 1000;
}
#ifdef DEBUG_POLL
printf("Entering select() sec=%ld usec=%ld ip=%lx op=%lx\n",
(long)timeout.tv_sec, (long)timeout.tv_usec, (long)ip, (long)op);
#endif
rc = select(0, ip, op, &efds, toptr);
#ifdef DEBUG_POLL
printf("Exiting select rc=%d\n", rc);
#endif
if(rc <= 0)
return rc;
if(rc > 0) {
for ( i = 0; i < nfds; ++i) {
int fd = fds[i].fd;
if(fds[i].events & (POLLIN|POLLPRI) && FD_ISSET(fd, &ifds))
fds[i].revents |= POLLIN;
if(fds[i].events & POLLOUT && FD_ISSET(fd, &ofds))
fds[i].revents |= POLLOUT;
if(FD_ISSET(fd, &efds))
/* Some error was detected ... should be some way to know. */
fds[i].revents |= POLLHUP;
#ifdef DEBUG_POLL
printf("%d %d %d revent = %x\n",
FD_ISSET(fd, &ifds), FD_ISSET(fd, &ofds), FD_ISSET(fd, &efds),
fds[i].revents
);
#endif
}
}
return rc;
}
static void
set_connect_errno(int winsock_err)
{
switch(winsock_err) {
case WSAEINVAL:
case WSAEALREADY:
case WSAEWOULDBLOCK:
errno = EINPROGRESS;
break;
default:
errno = winsock_err;
break;
}
}
static void
set_socket_errno(int winsock_err)
{
switch(winsock_err) {
case WSAEWOULDBLOCK:
errno = EAGAIN;
break;
default:
errno = winsock_err;
break;
}
}
/*
* A wrapper around the socket() function. The purpose of this wrapper
* is to ensure that the global errno symbol is set if an error occurs,
* even if we are using winsock.
*/
SOCKET
win32_socket(int domain, int type, int protocol)
{
SOCKET fd = socket(domain, type, protocol);
if(fd == INVALID_SOCKET) {
set_socket_errno(WSAGetLastError());
}
return fd;
}
/*
* A wrapper around the connect() function. The purpose of this wrapper
* is to ensure that the global errno symbol is set if an error occurs,
* even if we are using winsock.
*/
int
win32_connect(SOCKET fd, struct sockaddr *addr, socklen_t addr_len)
{
int rc = connect(fd, addr, addr_len);
assert(rc == 0 || rc == SOCKET_ERROR);
if(rc == SOCKET_ERROR) {
set_connect_errno(WSAGetLastError());
}
return rc;
}
/*
* A wrapper around the accept() function. The purpose of this wrapper
* is to ensure that the global errno symbol is set if an error occurs,
* even if we are using winsock.
*/
SOCKET
win32_accept(SOCKET fd, struct sockaddr *addr, socklen_t *addr_len)
{
SOCKET newfd = accept(fd, addr, addr_len);
if(newfd == INVALID_SOCKET) {
set_socket_errno(WSAGetLastError());
newfd = -1;
}
return newfd;
}
/*
* A wrapper around the shutdown() function. The purpose of this wrapper
* is to ensure that the global errno symbol is set if an error occurs,
* even if we are using winsock.
*/
int
win32_shutdown(SOCKET fd, int mode)
{
int rc = shutdown(fd, mode);
assert(rc == 0 || rc == SOCKET_ERROR);
if(rc == SOCKET_ERROR) {
set_socket_errno(WSAGetLastError());
}
return rc;
}
int win32_close_socket(SOCKET fd)
{
int rc = closesocket(fd);
if(rc == SOCKET_ERROR) {
set_socket_errno(WSAGetLastError());
}
return rc;
}
ssize_t win32_write_socket(SOCKET fd, void *buf, int n)
{
int rc = send(fd, buf, n, 0);
if(rc == SOCKET_ERROR) {
set_socket_errno(WSAGetLastError());
}
return rc;
}
ssize_t win32_read_socket(SOCKET fd, void *buf, int n)
{
int rc = recv(fd, buf, n, 0);
if(rc == SOCKET_ERROR) {
set_socket_errno(WSAGetLastError());
}
return rc;
}
char * win32_strtok_r(char *s, const char *delim, char **lasts)
{
register char *spanp;
register int c, sc;
char *tok;
if (s == NULL && (s = *lasts) == NULL)
return (NULL);
/*
* Skip (span) leading delimiters (s += strspn(s, delim), sort of).
*/
cont:
c = *s++;
for (spanp = (char *)delim; (sc = *spanp++) != 0;) {
if (c == sc)
goto cont;
}
if (c == 0) { /* no non-delimiter characters */
*lasts = NULL;
return (NULL);
}
tok = s - 1;
/*
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
* Note that delim must have one NUL; we stop if we see that, too.
*/
for (;;) {
c = *s++;
spanp = (char *)delim;
do {
if ((sc = *spanp++) == c) {
if (c == 0)
s = NULL;
else
s[-1] = 0;
*lasts = s;
return (tok);
}
} while (sc != 0);
}
/* NOTREACHED */
}
char *win32_strsep (char **stringp, const char *delim)
{
register char *s;
register const char *spanp;
register int c, sc;
char *tok;
if ((s = *stringp) == NULL)
return (NULL);
for (tok = s;;) {
c = *s++;
spanp = delim;
do {
if ((sc = *spanp++) == c) {
if (c == 0)
s = NULL;
else
s[-1] = 0;
*stringp = s;
return (tok);
}
} while (sc != 0);
}
/* NOTREACHED */
}
char *OS_nonportable_path(char *str)
{
int32_t i;
@ -92,10 +533,10 @@ void *OS_nonportable_mapfile(char *fname,uint64_t *filesizep,int32_t enablewrite
int32_t OS_nonportable_renamefile(char *fname,char *newfname)
{
char cmdstr[1024],tmp[512];
strcpt(tmp,fname);
strcpy(tmp,fname);
OS_nonportable_path(tmp);
sprintf(cmdstr,"del %s",tmp);
if ( system() != 0 )
if ( system(cmdstr) != 0 )
printf("error deleting file.(%s)\n",cmdstr);
else return(1);
}

21
crypto777/OS_portable.c

@ -63,12 +63,18 @@ void OS_portable_randombytes(unsigned char *x,long xlen)
int32_t OS_portable_truncate(char *fname,long filesize)
{
#ifdef _WIN32
printf("need to implement truncate()\n");
return(-1);
#else
return(truncate(fname,filesize));
#endif
}
char *OS_portable_path(char *str)
{
#ifdef _WIN32
char *OS_nonportable_path(char *str);
return(OS_nonportable_path(str));
#else
return(str);
@ -79,10 +85,10 @@ int32_t OS_portable_renamefile(char *fname,char *newfname)
{
#ifdef _WIN32
char cmdstr[1024],tmp[512];
strcpt(tmp,fname);
iguana_compatible_path(tmp);
strcpy(tmp,fname);
OS_portable_path(tmp);
sprintf(cmdstr,"del %s",tmp);
if ( system() != 0 )
if ( system(cmdstr) != 0 )
printf("error deleting file.(%s)\n",cmdstr);
else return(1);
#else
@ -94,10 +100,10 @@ int32_t OS_portable_removefile(char *fname)
{
#ifdef _WIN32
char cmdstr[1024],tmp[512];
strcpt(tmp,fname);
iguana_compatible_path(tmp);
strcpy(tmp,fname);
OS_portable_path(tmp);
sprintf(cmdstr,"del %s",tmp);
if ( system() != 0 )
if ( system(cmdstr) != 0 )
printf("error deleting file.(%s)\n",cmdstr);
else return(1);
#else
@ -108,7 +114,8 @@ int32_t OS_portable_removefile(char *fname)
void *OS_portable_mapfile(char *fname,long *filesizep,int32_t enablewrite)
{
#ifdef _WIN32
return(OS_nonportable_mapfile(fname,filesizep,enablewrite);
void *OS_nonportable_mapfile(char *fname,long *filesizep,int32_t enablewrite);
return(OS_nonportable_mapfile(fname,filesizep,enablewrite));
#else
int32_t fd,rwflags,flags = MAP_FILE|MAP_SHARED;
uint64_t filesize;

22
crypto777/OS_portable.h

@ -24,19 +24,31 @@
#include <ctype.h>
#include <fcntl.h>
#include <math.h>
#include <pthread.h>
#include <poll.h>
#include <errno.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#ifdef __MINGW
#define sleep(x) Sleep(1000*(x))
#include "../win/mingw.h"
#include "../win/mman.h"
#else
#include <poll.h>
#include <netdb.h>
#include <pthread.h>
#include <netinet/in.h>
#include <sys/mman.h>
#include <sys/socket.h>
#define closesocket close
#endif
#include "../includes/libgfshare.h"
#include "../includes/utlist.h"
#include "../includes/uthash.h"
#include "../includes/curve25519.h"
#include "../includes/cJSON.h"
#ifndef MAP_FILE
#define MAP_FILE 0

4
crypto777/OS_time.c

@ -42,6 +42,10 @@ struct tm *gmtime_r(const time_t *timep,struct tm *result)
return(p);
}
struct tm *_gmtime32(const time_t *timep,struct tm *result) { return(gmtime_r(timep,result)); }
time_t _time32(struct tm *tm) { return(time(NULL)); }
time_t _localtime32(struct tm *tm) { return(time(NULL)); }
#include <Windows.h>
#include <stdint.h> // portable: uint64_t MSVC: __int64

6
crypto777/hmac/tiger.c

@ -37,7 +37,7 @@ const struct ltc_hash_descriptor tiger_desc =
};
#define t1 (table)
#define t2 (table+256)
#define t256 (table+256)
#define t3 (table+256*2)
#define t4 (table+256*3)
@ -566,8 +566,8 @@ INLINE static void tiger_round(ulong64 *a, ulong64 *b, ulong64 *c, ulong64 x, in
{
ulong64 tmp;
tmp = (*c ^= x);
*a -= t1[byte(tmp, 0)] ^ t2[byte(tmp, 2)] ^ t3[byte(tmp, 4)] ^ t4[byte(tmp, 6)];
tmp = (*b += t4[byte(tmp, 1)] ^ t3[byte(tmp, 3)] ^ t2[byte(tmp,5)] ^ t1[byte(tmp,7)]);
*a -= t1[byte(tmp, 0)] ^ t256[byte(tmp, 2)] ^ t3[byte(tmp, 4)] ^ t4[byte(tmp, 6)];
tmp = (*b += t4[byte(tmp, 1)] ^ t3[byte(tmp, 3)] ^ t256[byte(tmp,5)] ^ t1[byte(tmp,7)]);
switch (mul) {
case 5: *b = (tmp << 2) + tmp; break;
case 7: *b = (tmp << 3) - tmp; break;

4
crypto777/iguana_OS.c

@ -118,7 +118,7 @@ void *queueitem(char *str)
}
item->allocsize = (uint32_t)allocsize;
item->type = type;
data = (void *)((uint64_t)item + sizeof(*item));
data = (void *)(long)((long)item + sizeof(*item));
memcpy(data,str,n);
//printf("(%c) queueitem.%p itemdata.%p n.%d allocsize.%d\n",type,item,data,n,allocsize);
//portable_mutex_unlock(&MEMmutex);
@ -400,7 +400,7 @@ void *iguana_memalloc(struct OS_memspace *mem,long size,int32_t clearflag)
#endif
if ( (mem->used + size) <= mem->totalsize )
{
ptr = (void *)((uint64_t)mem->ptr + (uint64_t)mem->used);
ptr = (void *)(long)((long)(mem->ptr + mem->used));
mem->used += size;
if ( size*clearflag != 0 )
memset(ptr,0,size);

47
crypto777/inet.c

@ -16,34 +16,25 @@
*/
#ifdef DEFINES_ONLY
#ifndef crypto777_inet_h
#define crypto777_inet_h
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <stdint.h>
#include <errno.h>
#ifdef _WIN32
#include <nonportable.h>
#else
#include "../includes/nonportable.h"
#endif
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#else
#include "OS_portable.h"
#ifndef crypto777_system777_c
#define crypto777_system777_c
#ifdef _WIN32
#include <windows.h>
#include <io.h>
#include <winsock2.h>
#define in6_addr sockaddr
#define in_addr_t struct sockaddr_storage
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#ifndef crypto777_system777_h
#define DEFINES_ONLY
#include "inet.c"
#undef DEFINES_ONLY
struct sockaddr_in6 {
short sin6_family;
u_short sin6_port;
u_long sin6_flowinfo;
struct in6_addr sin6_addr;
u_long sin6_scope_id;
};
#endif
static int inet_ntop4(unsigned char *src, char *dst, size_t size);
@ -502,7 +493,7 @@ char *conv_ipv6(char *ipv6addr)
char ipv4str[4096];
struct sockaddr_in6 ipv6sa;
in_addr_t *ipv4bin;
unsigned char *bytes;
unsigned char *bytes = 0;
int32_t isok;
memset(IPV4CHECK,0,sizeof(IPV4CHECK));
strcpy(ipv4str,ipv6addr);
@ -511,7 +502,12 @@ char *conv_ipv6(char *ipv6addr)
isok = portable_pton(AF_INET6,ipv6addr,&ipv6sa.sin6_addr);
if ( isok == 0 )
{
#ifdef _WIN32
printf("need to figure this out for win32\n");
//bytes = ((struct sockaddr_in6 *)&ipv6sa)->sin6_addr.s6_addr;
#else
bytes = ((struct sockaddr_in6 *)&ipv6sa)->sin6_addr.s6_addr;
#endif
if ( memcmp(bytes,IPV4CHECK,sizeof(IPV4CHECK)) != 0 ) // check its IPV4 really
{
bytes += 12;
@ -601,5 +597,4 @@ uint16_t parse_endpoint(int32_t *ip6flagp,char *transport,char *ipbuf,char *retb
}
#endif
#endif

0
libs/libcrypto.a → crypto777/pnacl_libs/libcrypto.a

0
libs/libcurl.a → crypto777/pnacl_libs/libcurl.a

0
libs/libnanomsg.a → crypto777/pnacl_libs/libnanomsg.a

0
libs/libssl.a → crypto777/pnacl_libs/libssl.a

0
libs/libz.a → crypto777/pnacl_libs/libz.a

887
deprecated/iguana_recv.c

@ -0,0 +1,887 @@
/******************************************************************************
* Copyright © 2014-2015 The SuperNET Developers. *
* *
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* SuperNET software, including this file may be copied, modified, propagated *
* or distributed except according to the terms contained in the LICENSE file *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
#include "iguana777.h"
// peer context, ie massively multithreaded -> bundlesQ
struct iguana_bundlereq *iguana_bundlereq(struct iguana_info *coin,struct iguana_peer *addr,int32_t type,int32_t datalen)
{
struct iguana_bundlereq *req; int32_t allocsize;
allocsize = (uint32_t)sizeof(*req) + datalen;
req = mycalloc(type,1,allocsize);
req->allocsize = allocsize;
req->datalen = datalen;
req->addr = addr;
req->coin = coin;
req->type = type;
return(req);
}
/*struct iguana_block *iguana_blockrequest(struct iguana_info *coin,struct iguana_bundle *bp,int32_t bundlei,bits256 hash2,uint32_t now,int32_t iamthreadsafe)
{
struct iguana_block *block = 0;
if( bp != 0 && bundlei >= 0 && bundlei < bp->n )
block = bp->blocks[bundlei];
if ( block == 0 && iamthreadsafe != 0 )
block = iguana_blockfind(coin,hash2);
if ( block != 0 )
{
//block->issued = now;
if ( block->numrequests < 100 )
block->numrequests++;
}
return(block);
}*/
int32_t iguana_sendblockreq(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_bundle *bp,int32_t bundlei,bits256 hash2,int32_t iamthreadsafe)
{
int32_t len; uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(uint32_t)*32 + sizeof(bits256)];
char hexstr[65]; init_hexbytes_noT(hexstr,hash2.bytes,sizeof(hash2));
if ( (len= iguana_getdata(coin,serialized,MSG_BLOCK,hexstr)) > 0 )
{
iguana_send(coin,addr,serialized,len);
coin->numreqsent++;
addr->pendblocks++;
addr->pendtime = (uint32_t)time(NULL);
//iguana_blockrequest(coin,bp,bundlei,hash2,addr->pendtime,iamthreadsafe);
//printf("REQ.%s bundlei.%d hdrsi.%d\n",bits256_str(hexstr,hash2),bundlei,bp!=0?bp->hdrsi:-1);
} else printf("MSG_BLOCK null datalen.%d\n",len);
return(len);
}
int32_t iguana_sendtxidreq(struct iguana_info *coin,struct iguana_peer *addr,bits256 hash2)
{
uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(uint32_t)*32 + sizeof(bits256)];
int32_t len,i,r,j; char hexstr[65]; init_hexbytes_noT(hexstr,hash2.bytes,sizeof(hash2));
if ( (len= iguana_getdata(coin,serialized,MSG_TX,hexstr)) > 0 )
{
if ( addr == 0 )
{
r = rand();
for (i=0; i<coin->MAXPEERS; i++)
{
j = (i + r) % coin->MAXPEERS;
addr = &coin->peers.active[j];
if ( coin->peers.active[j].usock >= 0 && coin->peers.active[j].dead == 0 )
{
iguana_send(coin,addr,serialized,len);
break;
}
}
} else iguana_send(coin,addr,serialized,len);
} else printf("MSG_TX null datalen.%d\n",len);
printf("send MSG_TX.%d\n",len);
return(len);
}
int32_t iguana_txidreq(struct iguana_info *coin,char **retstrp,bits256 txid)
{
int32_t i;
while ( coin->numreqtxids >= sizeof(coin->reqtxids)/sizeof(*coin->reqtxids) )
{
printf("txidreq full, wait\n");
sleep(1);
}
char str[65]; printf("txidreq.%s\n",bits256_str(str,txid));
coin->reqtxids[coin->numreqtxids++] = txid;
for (i=0; i<coin->MAXPEERS; i++)
if ( coin->peers.active[i].usock >= 0 )
iguana_sendtxidreq(coin,coin->peers.ranked[i],txid);
return(0);
}
void iguana_gotunconfirmedM(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_msgtx *tx,uint8_t *data,int32_t datalen)
{
struct iguana_bundlereq *req;
char str[65]; printf("%s unconfirmed.%s\n",addr->ipaddr,bits256_str(str,tx->txid));
req = iguana_bundlereq(coin,addr,'U',datalen);
req->datalen = datalen;
req->txid = tx->txid;
memcpy(req->serialized,data,datalen);
queue_enqueue("bundlesQ",&coin->bundlesQ,&req->DL,0);
}
void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_txblock *origtxdata,struct iguana_msgtx *txarray,struct iguana_msghdr *H,uint8_t *data,int32_t recvlen)
{
struct iguana_bundlereq *req; struct iguana_txblock *txdata = 0; int32_t i,j,copyflag; char fname[1024];
if ( 0 )
{
for (i=0; i<txdata->space[0]; i++)
if ( txdata->space[i] != 0 )
break;
if ( i != txdata->space[0] )
{
for (i=0; i<txdata->space[0]; i++)
printf("%02x ",txdata->space[i]);
printf("extra\n");
}
}
if ( coin->numreqtxids > 0 )
{
for (i=0; i<origtxdata->block.RO.txn_count; i++)
{
for (j=0; j<coin->numreqtxids; j++)
{
if ( memcmp(coin->reqtxids[j].bytes,txarray[i].txid.bytes,sizeof(bits256)) == 0 )
{
char str[65]; printf("i.%d j.%d found txid.%s\n",i,j,bits256_str(str,coin->reqtxids[j]));
}
}
}
}
copyflag = 1 * (strcmp(coin->symbol,"BTC") != 0);
req = iguana_bundlereq(coin,addr,'B',copyflag * recvlen);
req->recvlen = recvlen;
if ( copyflag != 0 && recvlen != 0 )
{
//printf("copy %p serialized[%d]\n",req->serialized,req->recvlen);
req->H = *H;
memcpy(req->serialized,data,recvlen), req->copyflag = 1;
}
txdata = origtxdata;
if ( addr != 0 )
{
if ( addr->pendblocks > 0 )
addr->pendblocks--;
addr->lastblockrecv = (uint32_t)time(NULL);
addr->recvblocks += 1.;
addr->recvtotal += recvlen;
if ( iguana_ramchain_data(coin,addr,origtxdata,txarray,origtxdata->block.RO.txn_count,data,recvlen) >= 0 )
{
txdata->block.fpipbits = addr->ipbits;
req->datalen = txdata->datalen;
req->ipbits = txdata->block.fpipbits;
if ( 0 )
{
struct iguana_txblock *checktxdata; struct OS_memspace checkmem; int32_t checkbundlei;
memset(&checkmem,0,sizeof(checkmem));
iguana_meminit(&checkmem,"checkmem",0,txdata->datalen + 4096,0);
if ( (checktxdata= iguana_peertxdata(coin,&checkbundlei,fname,&checkmem,addr->ipbits,txdata->block.RO.hash2)) != 0 )
{
printf("check datalen.%d bundlei.%d T.%d U.%d S.%d P.%d X.%d\n",checktxdata->datalen,checkbundlei,checktxdata->numtxids,checktxdata->numunspents,checktxdata->numspends,checktxdata->numpkinds,checktxdata->numexternaltxids);
}
iguana_mempurge(&checkmem);
}
}
}
//printf("recvlen.%d\n",req->recvlen);
req->block = txdata->block;
req->block.RO.txn_count = req->numtx = txdata->block.RO.txn_count;
coin->recvcount++;
coin->recvtime = (uint32_t)time(NULL);
req->addr = addr;
queue_enqueue("bundlesQ",&coin->bundlesQ,&req->DL,0);
}
void iguana_gottxidsM(struct iguana_info *coin,struct iguana_peer *addr,bits256 *txids,int32_t n)
{
struct iguana_bundlereq *req;
printf("got %d txids from %s\n",n,addr->ipaddr);
req = iguana_bundlereq(coin,addr,'T',0);
req->hashes = txids, req->n = n;
queue_enqueue("bundlesQ",&coin->bundlesQ,&req->DL,0);
}
void iguana_gotheadersM(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_block *blocks,int32_t n)
{
struct iguana_bundlereq *req;
if ( addr != 0 )
{
addr->recvhdrs++;
if ( addr->pendhdrs > 0 )
addr->pendhdrs--;
//printf("%s blocks[%d] ht.%d gotheaders pend.%d %.0f\n",addr->ipaddr,n,blocks[0].height,addr->pendhdrs,milliseconds());
}
req = iguana_bundlereq(coin,addr,'H',0);
req->blocks = blocks, req->n = n;
queue_enqueue("bundlesQ",&coin->bundlesQ,&req->DL,0);
}
void iguana_gotblockhashesM(struct iguana_info *coin,struct iguana_peer *addr,bits256 *blockhashes,int32_t n)
{
struct iguana_bundlereq *req;
if ( addr != 0 )
{
addr->recvhdrs++;
if ( addr->pendhdrs > 0 )
addr->pendhdrs--;
}
req = iguana_bundlereq(coin,addr,'S',0);
req->hashes = blockhashes, req->n = n;
//printf("bundlesQ blockhashes.%p[%d]\n",blockhashes,n);
queue_enqueue("bundlesQ",&coin->bundlesQ,&req->DL,0);
}
void iguana_patch(struct iguana_info *coin,struct iguana_block *block)
{
int32_t i,j,origheight,height; struct iguana_block *prev,*next; struct iguana_bundle *bp;
prev = iguana_blockhashset(coin,-1,block->RO.prev_block,1);
block->hh.prev = prev;
if ( prev != 0 )
{
if ( prev->mainchain != 0 )
{
prev->hh.next = block;
if ( memcmp(block->RO.prev_block.bytes,coin->blocks.hwmchain.RO.hash2.bytes,sizeof(bits256)) == 0 )
{
_iguana_chainlink(coin,block);
//printf("link block %d\n",block->height);
}
if ( (next= block->hh.next) != 0 && bits256_nonz(next->RO.hash2) > 0 )
{
next->height = block->height + 1;
//printf("autoreq %d\n",next->height);
if ( 0 && strcmp(coin->symbol,"BTC") != 0 )
iguana_blockQ(coin,coin->bundles[(block->height+1)/coin->chain->bundlesize],(block->height+1)%coin->chain->bundlesize,next->RO.hash2,0);
}
}
else if ( block->height < 0 )
{
for (i=0; i<1; i++)
{
if ( (prev= prev->hh.prev) == 0 )
break;
if ( prev->mainchain != 0 && prev->height >= 0 )
{
j = i;
origheight = (prev->height + i + 2);
prev = block->hh.prev;
height = (origheight - 1);
while ( i > 0 && prev != 0 )
{
if ( prev->mainchain != 0 && prev->height != height )
{
printf("mainchain height mismatch j.%d at i.%d %d != %d\n",j,i,prev->height,height);
break;
}
prev = prev->hh.prev;
height--;
}
if ( i == 0 )
{
//printf("SET HEIGHT.%d j.%d\n",origheight,j);
if ( (bp= coin->bundles[origheight / coin->chain->bundlesize]) != 0 )
{
iguana_bundlehash2add(coin,0,bp,origheight % coin->chain->bundlesize,block->RO.hash2);
block->height = origheight;
block->mainchain = 1;
prev = block->hh.prev;
prev->hh.next = block;
}
} //else printf("break at i.%d for j.%d origheight.%d\n",i,j,origheight);
break;
}
}
}
}
}
int32_t iguana_allhashcmp(struct iguana_info *coin,struct iguana_bundle *bp,bits256 *blockhashes,int32_t num)
{
bits256 allhash; int32_t err,i,n; struct iguana_block *block;
if ( bits256_nonz(bp->allhash) > 0 && num >= coin->chain->bundlesize )
{
for (i=0; i<bp->n; i++)
if ( bits256_nonz(blockhashes[i]) == 0 )
blockhashes[i] = bp->hashes[i];
vcalc_sha256(0,allhash.bytes,blockhashes[0].bytes,coin->chain->bundlesize * sizeof(*blockhashes));
if ( memcmp(allhash.bytes,bp->allhash.bytes,sizeof(allhash)) == 0 )
{
for (i=n=0; i<coin->chain->bundlesize&&i<bp->n; i++)
{
if ( (err= iguana_bundlehash2add(coin,0,bp,i,blockhashes[i])) < 0 )
return(err);
if ( bp->emitfinish == 0 && (block= bp->blocks[i]) != 0 && (block->queued == 0 && block->fpipbits == 0) && block->numrequests < 3 )
iguana_blockQ(coin,bp,i,block->RO.hash2,0), n++;
}
//printf("ALLHASHES FOUND! %d requested.%d\n",bp->bundleheight,n);
return(i);
}
}
return(-1);
}
// main context, ie single threaded
struct iguana_bundle *iguana_bundleset(struct iguana_info *coin,struct iguana_block **blockp,int32_t *bundleip,struct iguana_block *origblock)
{
struct iguana_block *block; bits256 zero; struct iguana_bundle *bp = 0;
int32_t bundlei = -2;
*bundleip = -2; *blockp = 0;
if ( origblock == 0 )
return(0);
memset(zero.bytes,0,sizeof(zero));
if ( (block= iguana_blockhashset(coin,-1,origblock->RO.hash2,1)) != 0 )
{
if ( block != origblock )
iguana_blockcopy(coin,block,origblock);
*blockp = block;
//if ( bits256_nonz(block->RO.prev_block) > 0 )
// iguana_patch(coin,block);
if ( (bp= iguana_bundlefind(coin,&bp,&bundlei,block->RO.hash2)) != 0 )
{
if ( bundlei < coin->chain->bundlesize )
{
block->bundlei = bundlei;
block->hdrsi = bp->hdrsi;
//iguana_hash2set(coin,"blockadd",bp,block->bundlei,block->hash2);
iguana_bundlehash2add(coin,0,bp,bundlei,block->RO.hash2);
if ( bundlei > 0 )
{
//char str[65],str2[65]; printf("call hash2add %d:[%d -1] %s prev.%s\n",bp->hdrsi,bundlei,bits256_str(str2,block->RO.hash2),bits256_str(str,block->RO.prev_block));
iguana_bundlehash2add(coin,0,bp,bundlei-1,block->RO.prev_block);
}
else if ( bp->hdrsi > 0 && (bp= coin->bundles[bp->hdrsi-1]) != 0 )
iguana_bundlehash2add(coin,0,bp,coin->chain->bundlesize-1,block->RO.prev_block);
}
}
if ( (bp= iguana_bundlefind(coin,&bp,&bundlei,block->RO.prev_block)) != 0 )
{
//printf("found prev.%d\n",bp->bundleheight+bundlei);
if ( bundlei < coin->chain->bundlesize )
{
if ( bundlei == coin->chain->bundlesize-1 )
{
//if ( coin->bundlescount < bp->hdrsi+1 )
{
//char str[65]; printf("autoextend CREATE.%d new bundle.%s\n",bp->bundleheight + coin->chain->bundlesize,bits256_str(str,block->RO.hash2));
iguana_bundlecreate(coin,&bundlei,bp->bundleheight + coin->chain->bundlesize,block->RO.hash2,zero,1);
}
}
else if ( bundlei < coin->chain->bundlesize-1 )
iguana_bundlehash2add(coin,0,bp,bundlei+1,block->RO.hash2);
}
}
//char str[65]; printf("iguana_recvblock (%s) %d %d[%d] %p\n",bits256_str(str,block->hash2),block->havebundle,block->hdrsi,bundlei,bp);
} else printf("iguana_bundleset: error adding blockhash\n");
return(iguana_bundlefind(coin,&bp,bundleip,origblock->RO.hash2));
}
struct iguana_bundlereq *iguana_recvblockhdrs(struct iguana_info *coin,struct iguana_bundlereq *req,struct iguana_block *blocks,int32_t n,int32_t *newhwmp)
{
int32_t i,bundlei; struct iguana_block *block; struct iguana_bundle *bp;
if ( blocks == 0 )
{
printf("iguana_recvblockhdrs null blocks?\n");
return(req);
}
if ( blocks != 0 && n > 0 )
{
for (i=0; i<n; i++)
{
//fprintf(stderr,"i.%d of %d bundleset\n",i,n);
if ( (bp= iguana_bundleset(coin,&block,&bundlei,&blocks[i])) != 0 && bp->hdrsi < IGUANA_MAXACTIVEBUNDLES )
{
//if ( 0 && i < bp->n && bp->requests[i] == 0 )
// iguana_blockQ(coin,bp,bundlei,blocks[i].RO.hash2,0);
}
}
}
return(req);
}
struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct iguana_bundlereq *req,bits256 *blockhashes,int32_t num)
{
int32_t bundlei,i,n = 0; struct iguana_block *block; struct iguana_bundle *bp;// char str[65];
bp = 0, bundlei = -2, iguana_bundlefind(coin,&bp,&bundlei,blockhashes[1]);
if ( bp != 0 )
{
blockhashes[0] = bp->hashes[0];
if ( num >= coin->chain->bundlesize )
{
bp->hdrtime = (uint32_t)time(NULL);
if ( iguana_allhashcmp(coin,bp,blockhashes,num) == 0 )
return(req);
}
for (i=0; i<num; i++)
{
if ( bits256_nonz(blockhashes[i]) > 0 && (block= iguana_blockhashset(coin,-1,blockhashes[i],1)) != 0 )
{
if ( block->hdrsi == bp->hdrsi && block->bundlei == i )
n++;
}
}
//printf("got [%d] num.%d matched hashes\n",n,num);
}
else
{
//char str[65]; printf("blockhashes[%d] %s\n",num,bits256_str(str,blockhashes[1]));
iguana_blockQ(coin,0,-1,blockhashes[1],1);
}
//iguana_blockQ(coin,0,-1,blockhashes[num-1],1);
/*if ( (block= iguana_blockhashset(coin,-1,blockhashes[1],1)) != 0 && num > 2 )
{
if ( block->rawdata != 0 )
{
if ( block->copyflag != 0 )
myfree(block->rawdata,block->RO.recvlen), block->copyflag = 0;
else myfree(block->rawdata,block->numhashes * sizeof(bits256));
}
//char str[65]; printf("got %d unmatched hashes %d:%d %s\n",num,bp==0?-1:bp->bundleheight,bundlei,bits256_str(str,blockhashes[1]));
block->rawdata = blockhashes, block->numhashes = num, block->havehashes = 1;
req->hashes = 0;
}
if ( 0 && num >= coin->chain->bundlesize+1 )
{
char str[65]; bits256_str(str,blockhashes[coin->chain->bundlesize]);
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(str),1);
}*/
return(req);
}
struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_bundlereq *req,struct iguana_block *origblock,int32_t numtx,int32_t datalen,int32_t recvlen,int32_t *newhwmp)
{
struct iguana_bundle *prevbp=0,*bp=0; int32_t prevbundlei=-2,bundlei = -2; struct iguana_block *prevblock,*block;
bp = iguana_bundleset(coin,&block,&bundlei,origblock);
//char str[65]; printf("RECV %s [%d:%d] block.%p\n",bits256_str(str,origblock->RO.hash2),bp!=0?bp->hdrsi:-1,bundlei,block);
iguana_bundlefind(coin,&prevbp,&prevbundlei,origblock->RO.prev_block);
if ( prevbp != 0 && prevbundlei >= 0 && prevbp->blocks[prevbundlei] == 0 && (prevblock= iguana_blockfind(coin,origblock->RO.prev_block)) != 0 )
{
prevbp->blocks[prevbundlei] = prevblock;
//printf("PREV %s prevbp.%p[%d]\n",bits256_str(str,origblock->RO.prev_block),prevbp,prevbundlei);
}
if ( block != 0 )
{
if ( bp != 0 && bundlei >= 0 )
bp->blocks[bundlei] = block;
block->RO.recvlen = recvlen;
if ( req->copyflag != 0 && block->queued == 0 )//block->rawdata == 0 )
{
//char str[65]; printf("%s copyflag.%d %d data %d %d\n",bits256_str(str,block->RO.hash2),req->copyflag,block->height,req->recvlen,recvlen);
//block->rawdata = mycalloc('n',1,block->RO.recvlen);
//memcpy(block->rawdata,req->serialized,block->RO.recvlen);
//block->copyflag = 1;
coin->numcached++;
block->queued = 1;
queue_enqueue("cacheQ",&coin->cacheQ,&req->DL,0);
return(0);
}
//printf("datalen.%d ipbits.%x\n",datalen,req->ipbits);
} else printf("cant create block.%llx block.%p bp.%p bundlei.%d\n",(long long)origblock->RO.hash2.txid,block,bp,bundlei);
return(req);
}
struct iguana_bundlereq *iguana_recvtxids(struct iguana_info *coin,struct iguana_bundlereq *req,bits256 *txids,int32_t n)
{
return(req);
}
struct iguana_bundlereq *iguana_recvunconfirmed(struct iguana_info *coin,struct iguana_bundlereq *req,uint8_t *data,int32_t datalen)
{
int32_t i;
for (i=0; i<coin->numreqtxids; i++)
{
if ( memcmp(req->txid.bytes,coin->reqtxids[i].bytes,sizeof(req->txid)) == 0 )
{
char str[65]; printf("got reqtxid.%s datalen.%d | numreqs.%d\n",bits256_str(str,req->txid),req->datalen,coin->numreqtxids);
coin->reqtxids[i] = coin->reqtxids[--coin->numreqtxids];
}
}
return(req);
}
int32_t iguana_processbundlesQ(struct iguana_info *coin,int32_t *newhwmp) // single threaded
{
int32_t flag = 0; struct iguana_bundlereq *req;
*newhwmp = 0;
while ( flag < IGUANA_BUNDLELOOP && (req= queue_dequeue(&coin->bundlesQ,0)) != 0 )
{
//printf("%s bundlesQ.%p type.%c n.%d\n",req->addr != 0 ? req->addr->ipaddr : "0",req,req->type,req->n);
if ( req->type == 'B' ) // one block with all txdata
req = iguana_recvblock(coin,req->addr,req,&req->block,req->numtx,req->datalen,req->recvlen,newhwmp);
else if ( req->type == 'H' ) // blockhdrs (doesnt have txn_count!)
{
if ( (req= iguana_recvblockhdrs(coin,req,req->blocks,req->n,newhwmp)) != 0 )
{
if ( req->blocks != 0 )
myfree(req->blocks,sizeof(*req->blocks) * req->n), req->blocks = 0;
}
}
else if ( req->type == 'S' ) // blockhashes
{
if ( (req= iguana_recvblockhashes(coin,req,req->hashes,req->n)) != 0 && req->hashes != 0 )
myfree(req->hashes,sizeof(*req->hashes) * req->n), req->hashes = 0;
}
else if ( req->type == 'U' ) // unconfirmed tx
req = iguana_recvunconfirmed(coin,req,req->serialized,req->datalen);
else if ( req->type == 'T' ) // txids from inv
{
if ( (req= iguana_recvtxids(coin,req,req->hashes,req->n)) != 0 )
myfree(req->hashes,(req->n+1) * sizeof(*req->hashes)), req->hashes = 0;
}
else printf("iguana_updatebundles unknown type.%c\n",req->type);
flag++;
//printf("done %s bundlesQ.%p type.%c n.%d\n",req->addr != 0 ? req->addr->ipaddr : "0",req,req->type,req->n);
if ( req != 0 )
myfree(req,req->allocsize), req = 0;
}
return(flag);
}
int32_t iguana_needhdrs(struct iguana_info *coin)
{
if ( coin->longestchain == 0 || coin->blocks.hashblocks < coin->longestchain-coin->chain->bundlesize )
return(1);
else return(0);
}
int32_t iguana_reqhdrs(struct iguana_info *coin)
{
int32_t i,lag,n = 0; struct iguana_bundle *bp; char hashstr[65];
if ( iguana_needhdrs(coin) > 0 && queue_size(&coin->hdrsQ) == 0 )
{
if ( coin->zcount++ > 1 )
{
for (i=0; i<coin->bundlescount; i++)
{
if ( (bp= coin->bundles[i]) != 0 && bp->emitfinish < coin->startutc )
{
if ( i == coin->bundlescount-1 )
lag = 5;
else lag = 30 + (rand() % 30);
if ( i < coin->bundlescount-1 && (bp->numhashes >= (rand() % bp->n) || time(NULL) < bp->hdrtime+lag) )
continue;
if ( bp->numhashes < bp->n && bp->bundleheight+bp->numhashes < coin->longestchain && time(NULL) > bp->issuetime+lag )
{
//printf("LAG.%ld hdrsi.%d numhashes.%d:%d needhdrs.%d qsize.%d zcount.%d\n",time(NULL)-bp->hdrtime,i,bp->numhashes,bp->n,iguana_needhdrs(coin),queue_size(&coin->hdrsQ),coin->zcount);
if ( bp->issuetime == 0 )
coin->numpendings++;
char str[65];
bits256_str(str,bp->hashes[0]);
//printf("(%s %d).%d ",str,bp->bundleheight,i);
//printf("%d ",bp->bundleheight);
init_hexbytes_noT(hashstr,bp->hashes[0].bytes,sizeof(bits256));
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1);
/*if ( strcmp(coin->symbol,"BTC") != 0 && bits256_nonz(bp->hashes[1]) > 0 )
{
if ( (block= iguana_blockfind(coin,bp->hashes[1])) != 0 )
{
if ( block->havehashes != 0 && block->rawdata != 0 )
iguana_allhashcmp(coin,bp,block->rawdata,block->numhashes);
//iguana_blockQ(coin,bp,1,bp->hashes[1],1);
}
}*/
n++;
bp->hdrtime = bp->issuetime = (uint32_t)time(NULL);
}
}
}
if ( n > 0 )
printf("REQ HDRS pending.%d\n",n);
coin->zcount = 0;
}
} else coin->zcount = 0;
return(n);
}
struct iguana_blockreq { struct queueitem DL; bits256 hash2,*blockhashes; struct iguana_bundle *bp; int32_t n,height,bundlei; };
int32_t iguana_blockQ(struct iguana_info *coin,struct iguana_bundle *bp,int32_t bundlei,bits256 hash2,int32_t priority)
{
queue_t *Q; char *str; struct iguana_blockreq *req; struct iguana_block *block = 0;
if ( bits256_nonz(hash2) == 0 )
{
printf("cant queue zerohash bundlei.%d\n",bundlei);
return(-1);
}
if ( (bp != 0 && (block= iguana_blockfind(coin,bp->hashes[bundlei])) == 0) || priority != 0 || bp == 0 )
{
if ( block != 0 )
{
if ( block->fpipbits != 0 || block->queued != 0 )
return(0);
/*if ( block->rawdata != 0 && block->RO.recvlen != 0 )
{
printf("free cached copy recvlen.%d need to process it here\n",block->RO.recvlen);
myfree(block->rawdata,block->RO.recvlen);
block->rawdata = 0;
block->RO.recvlen = 0;
}*/
}
if ( priority != 0 )
str = "priorityQ", Q = &coin->priorityQ;
else str = "blocksQ", Q = &coin->blocksQ;
if ( Q != 0 )
{
req = mycalloc('r',1,sizeof(*req));
req->hash2 = hash2;
req->bp = bp;
req->bundlei = bundlei;
if ( bp != 0 && bundlei >= 0 && bundlei < bp->n )
{
//bp->issued[bundlei] = (uint32_t)time(NULL);
if ( bp->bundleheight >= 0 )
req->height = (bp->bundleheight + bundlei);
}
char str[65];
bits256_str(str,hash2);
if ( 0 && (bundlei % 250) == 0 )
printf("%s %d %s recv.%d numranked.%d qsize.%d\n",str,req->height,str,coin->blocks.recvblocks,coin->peers.numranked,queue_size(Q));
queue_enqueue(str,Q,&req->DL,0);
return(1);
} else printf("null Q\n");
} //else printf("queueblock skip priority.%d bundlei.%d\n",bundlei,priority);
return(0);
}
int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr)
{
uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(uint32_t)*32 + sizeof(bits256)];
char *hashstr=0; bits256 hash2; uint32_t now; struct iguana_block *block; struct iguana_blockreq *req=0;
int32_t i,r,diff,j,k,n,m; double metric,bestmetric = -1.; struct iguana_bundle *bp,*bestbp = 0;
int32_t limit,refbundlei,height=-1,incr,datalen,flag = 0; double val;
now = (uint32_t)time(NULL);
if ( iguana_needhdrs(coin) != 0 && addr->pendhdrs < IGUANA_MAXPENDHDRS )
{
//printf("%s check hdrsQ\n",addr->ipaddr);
if ( (hashstr= queue_dequeue(&coin->hdrsQ,1)) != 0 )
{
if ( (datalen= iguana_gethdrs(coin,serialized,coin->chain->gethdrsmsg,hashstr)) > 0 )
{
decode_hex(hash2.bytes,sizeof(hash2),hashstr);
if ( bits256_nonz(hash2) > 0 )
{
//printf("%s request hdr.(%s)\n",addr!=0?addr->ipaddr:"local",hashstr);
iguana_send(coin,addr,serialized,datalen);
addr->pendhdrs++;
flag++;
}
free_queueitem(hashstr);
return(flag);
} else printf("datalen.%d from gethdrs\n",datalen);
free_queueitem(hashstr);
hashstr = 0;
}
}
if ( (limit= addr->recvblocks) > coin->MAXPENDING )
limit = coin->MAXPENDING;
if ( limit < 1 )
limit = 1;
//if ( addr->pendblocks >= limit )
// printf("%s %d overlimit.%d\n",addr->ipaddr,addr->pendblocks,limit);
if ( coin->bundlescount > 0 && (req= queue_dequeue(&coin->priorityQ,0)) == 0 && addr->pendblocks < limit )//&& now > addr->lastpoll )
{
if ( 1 )//strcmp("BTC",coin->symbol) != 0 )
{
int32_t bundlei;
incr = coin->peers.numranked == 0 ? coin->MAXPEERS : coin->peers.numranked;
if ( (rand() % 100) < 50 )
height = addr->rank * _IGUANA_MAXPENDING;
else if ( (rand() % 100) < 50 )
height = addr->addrind + (addr->rank * (coin->longestchain - coin->blocks.hwmchain.height) / (coin->peers.numranked+1));
else if ( (rand() % 100) < 50 )
{
height = (addr->lastheight + 1);
if ( height >= coin->longestchain-coin->chain->bundlesize )
height = addr->rank*incr*_IGUANA_MAXPENDING;
}
else
{
height = coin->longestchain - (rand() % incr) * 1000;
if ( height < 0 )
height = coin->blocks.hwmchain.height;
}
for (; height<coin->bundlescount*coin->chain->bundlesize; height+=incr)
{
if ( height > coin->longestchain )
height = addr->rank*incr*_IGUANA_MAXPENDING;
if ( height > addr->lastheight )
addr->lastheight = height;
if ( (bp= coin->bundles[height/coin->chain->bundlesize]) != 0 && bp->emitfinish == 0 )
{
bundlei = (height % coin->chain->bundlesize);
if ( bundlei < bp->n && bits256_nonz(bp->hashes[bundlei]) > 0 && (block= bp->blocks[bundlei]) != 0 && block->numrequests <= bp->minrequests && block->fpipbits == 0 )//&& block->queued == 0 )//(bp->issued[bundlei] == 0 || now > bp->issued[bundlei]+10) )
{
if ( block->numrequests < 100 )
block->numrequests++;
//block->issued = (uint32_t)time(NULL);;
if ( 0 && (rand() % 100) == 0 )
printf("%s Send auto blockreq.%d [%d] minreq.%d\n",addr->ipaddr,bp->bundleheight+bundlei,block->numrequests,bp->minrequests);
iguana_sendblockreq(coin,addr,bp,bundlei,bp->hashes[bundlei],0);
return(1);
}
}
}
}
else
{
//printf("%s lastpoll.%u %u\n",addr->ipaddr,addr->lastpoll,now);
addr->lastpoll = now;
for (i=n=0; i<coin->bundlescount; i++)
if ( coin->bundles[i] != 0 && coin->bundles[i]->emitfinish == 0 )
n++;
if ( n >= coin->bundlescount-(coin->bundlescount>>3) || (addr->ipbits % 10) < 5 )
refbundlei = (addr->ipbits % coin->bundlescount);
else
{
if ( n*2 < coin->bundlescount )
{
for (i=refbundlei=0; i<IGUANA_MAXPEERS; i++)
{
if ( addr->usock == coin->peers.active[i].usock )
break;
if ( coin->peers.active[i].usock >= 0 )
refbundlei++;
}
//printf("half done\n");
} else refbundlei = ((addr->addrind*100) % coin->bundlescount);
}
for (i=0; i<coin->bundlescount; i++)
{
if ( (diff= (i - refbundlei)) < 0 )
diff = -diff;
if ( (bp= coin->bundles[i]) != 0 && bp->emitfinish == 0 )
{
metric = (1 + diff * ((addr->addrind&1) == 0 ? 1 : 1) * (1. + bp->metric));// / (i*((addr->addrind&1) != 0 ? 1 : i) + 1);
//printf("%f ",bp->metric);
if ( bestmetric < 0. || metric < bestmetric )
bestmetric = metric, bestbp = bp;
}
}
if ( bestbp != 0 && bp->emitfinish == 0 )
{
for (k=0; k<coin->bundlescount; k++)
{
i = (bestbp->hdrsi + k) % coin->bundlescount;
if ( (bp= coin->bundles[i]) == 0 || bp->emitfinish != 0 )
continue;
printf("%.15f ref.%d addrind.%d bestbp.%d\n",bestmetric,refbundlei,addr->addrind,bp->hdrsi);
m = coin->chain->bundlesize;
if ( bp->n < m )
m = bp->n;
j = (addr->addrind*3 + 0) % m;
val = (bp->threshold / 1000.);
for (r=0; r<m; r++,j++)
{
if ( j >= m )
j = 0;
if ( (block= bp->blocks[j]) != 0 && block->fpipbits == 0 && block->queued == 0 && block->numrequests <= bp->minrequests )
{
if ( block->numrequests < 100 )
block->numrequests++;
//block->issued = (uint32_t)time(NULL);;
printf("%s Send auto blockreq.%d\n",addr->ipaddr,bp->bundleheight+j);
iguana_sendblockreq(coin,addr,bp,j,hash2,0);
return(1);
}
}
}
}
}
}
int32_t priority;
if ( addr->rank != 1 && req == 0 )
{
priority = 0;
req = queue_dequeue(&coin->blocksQ,0);
} else priority = 1;
if ( req != 0 )
{
hash2 = req->hash2;
height = req->height;
block = 0;
if ( priority == 0 && (bp= req->bp) != 0 && req->bundlei >= 0 && req->bundlei < bp->n && req->bundlei < coin->chain->bundlesize && (block= bp->blocks[req->bundlei]) != 0 && (block->fpipbits != 0 || block->queued != 0) )
{
//if ( 0 && priority != 0 )
printf("SKIP %p[%d] %d\n",bp,bp!=0?bp->bundleheight:-1,req->bundlei);
}
else
{
char str[65];
if ( 0 && priority != 0 )
printf(" issue.%s\n",bits256_str(str,hash2));
if ( block != 0 && block->numrequests < 100 )
block->numrequests++;
iguana_sendblockreq(coin,addr,req->bp,req->bundlei,hash2,0);
}
flag++;
myfree(req,sizeof(*req));
}
return(flag);
}
int32_t iguana_processrecv(struct iguana_info *coin) // single threaded
{
int32_t newhwm = 0,h,lflag,bundlei,flag = 0; bits256 hash2; struct iguana_block *next,*block; struct iguana_bundle *bp;
//printf("process bundlesQ\n");
flag += iguana_processbundlesQ(coin,&newhwm);
flag += iguana_reqhdrs(coin);
lflag = 1;
while ( lflag != 0 )
{
lflag = 0;
h = coin->blocks.hwmchain.height / coin->chain->bundlesize;
if ( (next= iguana_blockfind(coin,iguana_blockhash(coin,coin->blocks.hwmchain.height+1))) == 0 )
{
if ( (block= iguana_blockfind(coin,coin->blocks.hwmchain.RO.hash2)) != 0 )
next = block->hh.next, block->mainchain = 1;
}
if ( next != 0 )
{
//printf("have next\n");
if ( memcmp(next->RO.prev_block.bytes,coin->blocks.hwmchain.RO.hash2.bytes,sizeof(bits256)) == 0 )
{
if ( _iguana_chainlink(coin,next) != 0 )
lflag++;
//else printf("chainlink error for %d\n",coin->blocks.hwmchain.height+1);
}
else if ( 1 )
{
double threshold,lag = OS_milliseconds() - coin->backstopmillis;
threshold = (10 + coin->longestchain - coin->blocksrecv);
if ( threshold < 1 )
threshold = 1.;
if ( (bp= coin->bundles[(coin->blocks.hwmchain.height+1)/coin->chain->bundlesize]) != 0 )
threshold = (bp->avetime + coin->avetime) * .5;
else threshold = coin->avetime;
threshold *= 100. * sqrt(threshold) * .000777;
if ( strcmp(coin->symbol,"BTC") != 0 )
threshold = 400;
else threshold = 1000;
if ( coin->blocks.hwmchain.height+1 < coin->longestchain && (coin->backstop != coin->blocks.hwmchain.height+1 || lag > threshold) )
{
coin->backstop = coin->blocks.hwmchain.height+1;
hash2 = iguana_blockhash(coin,coin->backstop);
if ( bits256_nonz(hash2) > 0 )
{
bp = coin->bundles[(coin->blocks.hwmchain.height+1)/coin->chain->bundlesize];
bundlei = (coin->blocks.hwmchain.height+1) % coin->chain->bundlesize;
if ( bp != 0 )
{
coin->backstopmillis = OS_milliseconds();
iguana_blockQ(coin,bp,bundlei,iguana_blockhash(coin,coin->backstop),1);
//iguana_blockrequest(coin,bp,bundlei,hash2,(uint32_t)time(NULL),1);
/*if ( (bp= coin->bundles[(coin->blocks.hwmchain.height+1)/coin->chain->bundlesize]) == 0 || bp->fpos[bundlei] >= 0 )
{
if ( bp != 0 && coin->backstop == coin->blocks.hwmchain.height+1 )
{
iguana_bundleiclear(coin,bp,bundlei);
}
iguana_blockQ(coin,bp,bundlei,next->RO.hash2,1);
}*/
if ( (rand() % 100) == 0 )
printf("MAINCHAIN.%d threshold %.3f %.3f lag %.3f\n",coin->blocks.hwmchain.height+1,threshold,coin->backstopmillis,lag);
}
}
}
else if ( 0 && bits256_nonz(next->RO.prev_block) > 0 )
printf("next prev cmp error nonz.%d\n",bits256_nonz(next->RO.prev_block));
}
}
if ( h != coin->blocks.hwmchain.height / coin->chain->bundlesize )
iguana_savehdrs(coin);
}
return(flag);
}

2
iguana/iguana777.c

@ -182,7 +182,7 @@ int32_t iguana_peermetrics(struct iguana_info *coin)
void *iguana_kviAddriterator(struct iguana_info *coin,struct iguanakv *kv,struct iguana_kvitem *item,uint64_t args,void *key,void *value,int32_t valuesize)
{
char ipaddr[64]; int32_t i; FILE *fp = (FILE *)args; struct iguana_peer *addr; struct iguana_iAddr *iA = value;
char ipaddr[64]; int32_t i; FILE *fp = (FILE *)(long)args; struct iguana_peer *addr; struct iguana_iAddr *iA = value;
if ( fp != 0 && iA != 0 && iA->numconnects > 0 && iA->lastconnect > time(NULL)-IGUANA_RECENTPEER )
{
for (i=0; i<coin->peers.numranked; i++)

7
iguana/iguana777.h

@ -72,19 +72,18 @@ struct iguana_txdatabits { uint64_t addrind:IGUANA_LOG2MAXPEERS,filecount:10,fpo
#endif
#include "../includes/cJSON.h"
#ifdef __PNACL
void PostMessage(const char* format, ...);
void PNACL_message(const char* format, ...);
#endif
extern int32_t IGUANA_NUMHELPERS;
#ifdef __PNACL
#define printf PostMessage
#define printf PNACL_message
#define MS_ASYNC 1 /* Sync memory asynchronously. */
#define MS_SYNC 4 /* Synchronous memory sync. */
#else
#define PostMessage printf
#define PNACL_message printf
#endif
#ifndef MSG_NOSIGNAL

10
iguana/iguana_peers.c

@ -228,7 +228,7 @@ void iguana_iAkill(struct iguana_info *coin,struct iguana_peer *addr,int32_t mar
rank = addr->rank;
strcpy(ipaddr,addr->ipaddr);
if ( addr->usock >= 0 )
close(addr->usock), addr->usock = -1;
closesocket(addr->usock), addr->usock = -1;
if ( addr == coin->peers.localaddr )
coin->peers.localaddr = 0;
//printf("iAkill.(%s)\n",addr->ipaddr);
@ -256,7 +256,7 @@ void iguana_iAkill(struct iguana_info *coin,struct iguana_peer *addr,int32_t mar
int32_t opt; struct sockaddr_in addr; socklen_t addrlen = sizeof(addr);
struct hostent* hostent = gethostbyname(hostname);
if (hostent == NULL) {
PostMessage("gethostbyname() returned error: %d", errno);
PNACL_message("gethostbyname() returned error: %d", errno);
return -1;
}
addr.sin_family = AF_INET;
@ -278,7 +278,7 @@ void iguana_iAkill(struct iguana_info *coin,struct iguana_peer *addr,int32_t mar
int result = bind(sock, (struct sockaddr*)&addr, addrlen);
if (result != 0) {
printf("bind() failed: %s", strerror(errno));
close(sock);
closesocket(sock);
return -1;
}
return(sock);
@ -333,14 +333,14 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port)
if ( errno != ECONNRESET && errno != ENOTCONN && errno != ECONNREFUSED && errno != ETIMEDOUT && errno != EHOSTUNREACH )
printf("connect(%s) port.%d failed: %s sock.%d. errno.%d\n",hostname,port,strerror(errno),sock,errno);
if ( sock >= 0 )
close(sock);
closesocket(sock);
return(-1);
}
if ( bindflag != 0 && listen(sock,128) != 0 )
{
printf("listen(%s) port.%d failed: %s sock.%d. errno.%d\n",hostname,port,strerror(errno),sock,errno);
if ( sock >= 0 )
close(sock);
closesocket(sock);
return(-1);
}
return(sock);

10
iguana/iguana_pubkeys.c

@ -15,11 +15,11 @@
#include "iguana777.h"
#include <stdbool.h>
#include <openssl/ec.h>
#include <openssl/ecdsa.h>
#include <openssl/obj_mac.h>
#include <openssl/ripemd.h>
#include <openssl/sha.h>
#include "../includes/openssl/ec.h"
#include "../includes/openssl/ecdsa.h"
#include "../includes/openssl/obj_mac.h"
//#include "../includes/openssl/ripemd.h"
//#include "../includes/openssl/sha.h"
#define SCRIPT_OP_IF 0x63
#define SCRIPT_OP_ELSE 0x67

50
iguana/iguana_ramchain.c

@ -155,7 +155,7 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl
sparsemax = i;
return(setind);
}
else if ( memcmp((void *)((long)refdata + x*refsize),key,keylen) == 0 )
else if ( memcmp((void *)(long)((long)refdata + x*refsize),key,keylen) == 0 )
{
if ( setind == 0 )
sparsehits++;
@ -205,8 +205,8 @@ struct iguana_txid *iguana_txidfind(struct iguana_info *coin,int32_t *heightp,st
ramchain = &bp->ramchain;
if ( ramchain->H.data != 0 )
{
TXbits = (void *)((long)ramchain->H.data + ramchain->H.data->TXoffset);
T = (void *)((long)ramchain->H.data + ramchain->H.data->Toffset);
TXbits = (void *)(long)((long)ramchain->H.data + ramchain->H.data->TXoffset);
T = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Toffset);
//printf("search bp.%p TXbits.%p T.%p %d %d\n",bp,TXbits,T,(int32_t)ramchain->H.data->TXoffset,(int32_t)ramchain->H.data->Toffset);
if ( (txidind= iguana_sparseaddtx(TXbits,ramchain->H.data->txsparsebits,ramchain->H.data->numtxsparse,txid,T,0)) > 0 )
{
@ -233,8 +233,8 @@ struct iguana_pkhash *iguana_pkhashfind(struct iguana_info *coin,struct iguana_p
if ( (bp= coin->bundles[i]) != 0 )
{
ramchain = &bp->ramchain;
PKbits = (void *)((long)ramchain->H.data + ramchain->H.data->PKoffset);
P = (void *)((long)ramchain->H.data + ramchain->H.data->Poffset);
PKbits = (void *)(long)((long)ramchain->H.data + ramchain->H.data->PKoffset);
P = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Poffset);
if ( (pkind= iguana_sparseaddpk(PKbits,ramchain->H.data->pksparsebits,ramchain->H.data->numpksparse,rmd160,P,0)) > 0 )
{
*p = P[pkind];
@ -594,17 +594,17 @@ int64_t iguana_hashmemsize(uint32_t numtxids,uint32_t numunspents,uint32_t numsp
void _iguana_ramchain_setptrs(RAMCHAIN_PTRPS,struct iguana_ramchaindata *rdata)
{
*B = (void *)((long)rdata + (long)rdata->Boffset);
*T = (void *)((long)rdata + (long)rdata->Toffset);
*B = (void *)(long)((long)rdata + (long)rdata->Boffset);
*T = (void *)(long)((long)rdata + (long)rdata->Toffset);
if ( ramchain->expanded != 0 )
{
*Ux = (void *)((long)rdata + (long)rdata->Uoffset);
*Sx = (void *)((long)rdata + (long)rdata->Soffset);
*P = (void *)((long)rdata + (long)rdata->Poffset);
*X = (void *)((long)rdata + (long)rdata->Xoffset);
//ramchain->roU2 = (void *)((long)rdata + (long)rdata->U2offset);
//ramchain->roP2 = (void *)((long)rdata + (long)rdata->P2offset);
ramchain->roA = (void *)((long)rdata + (long)rdata->Aoffset);
*Ux = (void *)(long)((long)rdata + (long)rdata->Uoffset);
*Sx = (void *)(long)((long)rdata + (long)rdata->Soffset);
*P = (void *)(long)((long)rdata + (long)rdata->Poffset);
*X = (void *)(long)((long)rdata + (long)rdata->Xoffset);
//ramchain->roU2 = (void *)(long)((long)rdata + (long)rdata->U2offset);
//ramchain->roP2 = (void *)(long)((long)rdata + (long)rdata->P2offset);
ramchain->roA = (void *)(long)(long)((long)rdata + (long)rdata->Aoffset);
//if ( (*U2= ramchain->U2) == 0 )
// *U2 = ramchain->U2 = ramchain->roU2;
//if ( (*P2= ramchain->P2) == 0 )
@ -612,21 +612,21 @@ void _iguana_ramchain_setptrs(RAMCHAIN_PTRPS,struct iguana_ramchaindata *rdata)
if ( (*A= ramchain->A) == 0 )
*A = ramchain->A = ramchain->roA;
//printf("T.%p Ux.%p Sx.%p P.%p\n",*T,*Ux,*Sx,*P);
*TXbits = (void *)((long)rdata + (long)rdata->TXoffset);
*PKbits = (void *)((long)rdata + (long)rdata->PKoffset);
*TXbits = (void *)(long)((long)rdata + (long)rdata->TXoffset);
*PKbits = (void *)(long)((long)rdata + (long)rdata->PKoffset);
*U = 0, *S = 0;
}
else
{
*U = (void *)((long)rdata + (long)rdata->Uoffset);
*S = (void *)((long)rdata + (long)rdata->Soffset);
*U = (void *)(long)((long)rdata + (long)rdata->Uoffset);
*S = (void *)(long)((long)rdata + (long)rdata->Soffset);
*Ux = 0, *Sx = 0, *P = 0, *X = 0, *A = 0, *TXbits = 0, *PKbits = 0; //*U2 = 0, *P2 = 0,
}
}
void *iguana_ramchain_offset(void *dest,uint8_t *lhash,FILE *fp,uint64_t fpos,void *srcptr,uint64_t *offsetp,uint64_t len,uint64_t srcsize)
{
void *destptr = (void *)((long)dest + *offsetp);
void *destptr = (void *)(long)((long)dest + *offsetp);
if ( (lhash != 0 || fp != 0) && (*offsetp + len) > srcsize )
{
printf("ramchain_offset overflow (%p %p) offset.%ld + len.%ld %ld > %ld srcsize\n",fp,lhash,(long)*offsetp,(long)len,(long)(*offsetp + len),(long)srcsize);
@ -644,7 +644,7 @@ void *iguana_ramchain_offset(void *dest,uint8_t *lhash,FILE *fp,uint64_t fpos,vo
//else printf("fp.(%ld <- %d) ",ftell(fp),(int32_t)len);
}
(*offsetp) += len;
return((void *)((long)destptr + fpos));
return((void *)(long)((long)destptr + fpos));
}
int64_t _iguana_rdata_action(FILE *fp,bits256 lhashes[IGUANA_NUMLHASHES],void *destptr,uint64_t fpos,uint32_t expanded,uint32_t numtxids,uint32_t numunspents,uint32_t numspends,uint32_t numpkinds,uint32_t numexternaltxids,uint32_t txsparsebits,uint64_t numtxsparse,uint32_t pksparsebits,uint64_t numpksparse,uint64_t srcsize,RAMCHAIN_FUNC,int32_t numblocks)
@ -1124,7 +1124,7 @@ struct iguana_ramchain *iguana_ramchain_map(struct iguana_info *coin,char *fname
if ( ramchain->fileptr != 0 && ramchain->filesize > 0 )
{
// verify hashes
ramchain->H.data = (void *)((long)ramchain->fileptr + fpos);
ramchain->H.data = (void *)(long)((long)ramchain->fileptr + fpos);
ramchain->H.ROflag = 1;
ramchain->expanded = expanded;
ramchain->numblocks = (bp == 0) ? 1 : bp->n;
@ -1503,7 +1503,7 @@ long iguana_ramchain_data(struct iguana_info *coin,struct iguana_peer *addr,stru
mapchain->fileptr = 0, mapchain->filesize = 0;
iguana_ramchain_free(mapchain,1);
memset(&R,0,sizeof(R));
R.H.data = (void *)((long)ptr + fpos), R.filesize = fsize;
R.H.data = (void *)(long)((long)ptr + fpos), R.filesize = fsize;
iguana_ramchain_link(&R,origtxdata->block.RO.hash2,origtxdata->block.RO.hash2,bp->hdrsi,bp->bundleheight+bundlei,bundlei,1,firsti,1);
}
if ( (err= iguana_ramchain_cmp(ramchain,&R,0)) != 0 )
@ -1695,8 +1695,8 @@ struct iguana_ramchain *iguana_bundleload(struct iguana_info *coin,struct iguana
{
iguana_ramchain_link(mapchain,bp->hashes[0],bp->ramchain.lasthash2,bp->hdrsi,bp->bundleheight,0,bp->ramchain.numblocks,firsti,1);
//char str[65]; printf("bp.%d: T.%d U.%d S.%d P%d X.%d MAPPED %s %p\n",bp->hdrsi,bp->ramchain.H.data->numtxids,bp->ramchain.H.data->numunspents,bp->ramchain.H.data->numspends,bp->ramchain.H.data->numpkinds,bp->ramchain.H.data->numexternaltxids,mbstr(str,bp->ramchain.H.data->allocsize),bp->ramchain.H.data);
B = (void *)((long)mapchain->H.data + mapchain->H.data->Boffset);
T = (void *)((long)mapchain->H.data + mapchain->H.data->Toffset);
B = (void *)(long)((long)mapchain->H.data + mapchain->H.data->Boffset);
T = (void *)(long)((long)mapchain->H.data + mapchain->H.data->Toffset);
for (i=0; i<bp->n; i++)
{
if ( (block= bp->blocks[i]) != 0 || (block= iguana_blockhashset(coin,bp->bundleheight+i,bp->hashes[i],1)) != 0 )
@ -1767,7 +1767,7 @@ int32_t iguana_bundlesaveHT(struct iguana_info *coin,struct OS_memspace *mem,str
}
mapchain->fileptr = ptr;
mapchain->filesize = filesize;
mapchain->H.data = (void *)((long)ptr + fpos);
mapchain->H.data = (void *)(long)((long)ptr + fpos);
mapchain->H.ROflag = 1;
if ( fpos+mapchain->H.data->allocsize > filesize || iguana_ramchain_size(MAPCHAIN_ARG,1) != mapchain->H.data->allocsize )
{

10
iguana/iguana_rpc.c

@ -185,9 +185,9 @@ void iguana_vinset(struct iguana_info *coin,int32_t height,struct iguana_msgvin
memset(vin,0,sizeof(*vin));
if ( height >= 0 && height < coin->chain->bundlesize*coin->bundlescount && (bp= coin->bundles[height / coin->chain->bundlesize]) != 0 && (rdata= bp->ramchain.H.data) != 0 )
{
S = (void *)((long)rdata + rdata->Soffset);
X = (void *)((long)rdata + rdata->Xoffset);
T = (void *)((long)rdata + rdata->Toffset);
S = (void *)(long)((long)rdata + rdata->Soffset);
X = (void *)(long)((long)rdata + rdata->Xoffset);
T = (void *)(long)((long)rdata + rdata->Toffset);
spendind = (tx->firstvin + i);
s = &S[spendind];
if ( s->diffsequence == 0 )
@ -204,8 +204,8 @@ int32_t iguana_voutset(struct iguana_info *coin,uint8_t *scriptspace,char *asmst
memset(vout,0,sizeof(*vout));
if ( height >= 0 && height < coin->chain->bundlesize*coin->bundlescount && (bp= coin->bundles[height / coin->chain->bundlesize]) != 0 && (rdata= bp->ramchain.H.data) != 0 )
{
U = (void *)((long)rdata + rdata->Uoffset);
P = (void *)((long)rdata + rdata->Poffset);
U = (void *)(long)((long)rdata + rdata->Uoffset);
P = (void *)(long)((long)rdata + rdata->Poffset);
unspentind = (tx->firstvout + i);
u = &U[unspentind];
if ( u->txidind != tx->txidind || u->vout != i || u->hdrsi != height / coin->chain->bundlesize )

3
iguana/m_win32

@ -1 +1,2 @@
echo do equivalent of: gcc -o ../agents/iguana -O2 *.c ../agents/libcrypto777.a -lssl -lcrypto -lpthread -lm
make -f mingw32

14
iguana/mingw

@ -0,0 +1,14 @@
SOURCES := iguana_pubkeys.c iguana_recv.c iguana_bundles.c iguana_msg.c iguana_rpc.c iguana777.c iguana_chains.c iguana_peers.c iguana_accept.c iguana_html.c iguana_bitmap.c iguana_init.c iguana_ramchain.c iguana_blocks.c iguana_json.c ../crypto777/cJSON.c ../crypto777/iguana_utils.c ../crypto777/OS_nonportable.c ../crypto777/curve25519-donna.c ../crypto777/inet.c ../crypto777/OS_portable.c ../crypto777/curve25519.c ../crypto777/libgfshare.c ../crypto777/OS_time.c ../crypto777/hmac_sha512.c ../crypto777/ramcoder.c ../crypto777/SaM.c ../crypto777/iguana_OS.c ../crypto777/iguana_serdes.c ../crypto777/jpeg/jaricom.c ../crypto777/jpeg/jcapimin.c ../crypto777/jpeg/jcapistd.c ../crypto777/jpeg/jcarith.c ../crypto777/jpeg/jccoefct.c ../crypto777/jpeg/jccolor.c \
../crypto777/jpeg/jcdctmgr.c ../crypto777/jpeg/jchuff.c ../crypto777/jpeg/jcinit.c ../crypto777/jpeg/jcmainct.c ../crypto777/jpeg/jcmarker.c ../crypto777/jpeg/jcmaster.c \
../crypto777/jpeg/jcomapi.c ../crypto777/jpeg/jcparam.c ../crypto777/jpeg/jcprepct.c ../crypto777/jpeg/jcsample.c ../crypto777/jpeg/jctrans.c ../crypto777/jpeg/jdapimin.c \
../crypto777/jpeg/jdapistd.c ../crypto777/jpeg/jdarith.c ../crypto777/jpeg/jdatadst.c ../crypto777/jpeg/jdatasrc.c ../crypto777/jpeg/jdcoefct.c ../crypto777/jpeg/jdcolor.c \
../crypto777/jpeg/jddctmgr.c ../crypto777/jpeg/jdhuff.c ../crypto777/jpeg/jdinput.c ../crypto777/jpeg/jdmainct.c ../crypto777/jpeg/jdmarker.c ../crypto777/jpeg/jdmaster.c \
../crypto777/jpeg/jdmerge.c ../crypto777/jpeg/jdpostct.c ../crypto777/jpeg/jdsample.c ../crypto777/jpeg/jdtrans.c ../crypto777/jpeg/jerror.c ../crypto777/jpeg/jfdctflt.c \
../crypto777/jpeg/jfdctfst.c ../crypto777/jpeg/jfdctint.c ../crypto777/jpeg/jidctflt.c ../crypto777/jpeg/jidctfst.c ../crypto777/jpeg/jidctint.c ../crypto777/jpeg/jquant1.c \
../crypto777/jpeg/jquant2.c ../crypto777/jpeg/jutils.c ../crypto777/jpeg/jmemmgr.c ../crypto777/jpeg/jmemnobs.c main.c
all:
$(TOOL_DIR)/$(MINGW)-gcc -o ../agents/iguana.exe -D __MINGW $(SOURCES) $(LIBS)
$(TOOL_DIR)/$(MINGW)-strip --strip-all ../agents/iguana.exe

9
iguana/mingw32

@ -0,0 +1,9 @@
TOOL_DIR := /usr/local/gcc-4.8.0-qt-4.8.4-for-mingw32/win32-gcc/bin
MINGW := i586-mingw32
LIBS := ../win/libcrypto.a ../win/libssl.a ../win/libpthreadGC2.a -lws2_32 -lgdi32
include mingw
all:
$(TOOL_DIR)/$(MINGW)-gcc -o ../agents/iguana.exe -D __MINGW $(SOURCES) $(LIBS)
$(TOOL_DIR)/$(MINGW)-strip --strip-all ../agents/iguana.exe

9
iguana/mingw64

@ -0,0 +1,9 @@
TOOL_DIR := /usr/local/gcc-4.8.0-qt-4.8.4-for-mingw64/win64-gcc/bin
MINGW := i686-mingw64
LIBS := ../win/libcrypto.a ../win/libs/libssl.a ../win/libpthreadGC2_64.a -lws2_64 -lgdi64
include mingw
all:
$(TOOL_DIR)/$(MINGW)-gcc -o ../agents/iguana.exe -D __MINGW $(SOURCES) $(LIBS)
$(TOOL_DIR)/$(MINGW)-strip --strip-all ../agents/iguana.exe

4
includes/nonportable.h

@ -1,4 +1,4 @@
// MIT license
/*
#ifndef _NONPORTABLELINUX_H
#define _NONPORTABLELINUX_H
@ -8,4 +8,4 @@
#include <netdb.h>
#include <sys/mman.h>
#endif
#endif*/

2
libs/include/aes.h → includes/openssl/aes.h

@ -52,7 +52,7 @@
#ifndef HEADER_AES_H
#define HEADER_AES_H
#include <openssl/opensslconf.h>
#include "opensslconf.h"
#ifdef OPENSSL_NO_AES
#error AES is disabled.

14
libs/include/asn1.h → includes/openssl/asn1.h

@ -60,18 +60,18 @@
#define HEADER_ASN1_H
#include <time.h>
#include <openssl/e_os2.h>
#include "e_os2.h"
#ifndef OPENSSL_NO_BIO
#include <openssl/bio.h>
#include "bio.h"
#endif
#include <openssl/stack.h>
#include <openssl/safestack.h>
#include "stack.h"
#include "safestack.h"
#include <openssl/symhacks.h>
#include "symhacks.h"
#include <openssl/ossl_typ.h>
#include "ossl_typ.h"
#ifndef OPENSSL_NO_DEPRECATED
#include <openssl/bn.h>
#include "bn.h"
#endif
#ifdef OPENSSL_BUILD_SHLIBCRYPTO

2
libs/include/asn1_mac.h → includes/openssl/asn1_mac.h

@ -59,7 +59,7 @@
#ifndef HEADER_ASN1_MAC_H
#define HEADER_ASN1_MAC_H
#include <openssl/asn1.h>
#include "asn1.h"
#ifdef __cplusplus
extern "C" {

4
libs/include/asn1t.h → includes/openssl/asn1t.h

@ -59,8 +59,8 @@
#define HEADER_ASN1T_H
#include <stddef.h>
#include <openssl/e_os2.h>
#include <openssl/asn1.h>
#include "e_os2.h"
#include "asn1.h"
#ifdef OPENSSL_BUILD_SHLIBCRYPTO
# undef OPENSSL_EXTERN

4
libs/include/bio.h → includes/openssl/bio.h

@ -59,14 +59,14 @@
#ifndef HEADER_BIO_H
#define HEADER_BIO_H
#include <openssl/e_os2.h>
#include "e_os2.h"
#ifndef OPENSSL_NO_FP_API
# include <stdio.h>
#endif
#include <stdarg.h>
#include <openssl/crypto.h>
#include "crypto.h"
#ifndef OPENSSL_NO_SCTP
# ifndef OPENSSL_SYS_VMS

2
libs/include/blowfish.h → includes/openssl/blowfish.h

@ -59,7 +59,7 @@
#ifndef HEADER_BLOWFISH_H
#define HEADER_BLOWFISH_H
#include <openssl/e_os2.h>
#include "e_os2.h"
#ifdef __cplusplus
extern "C" {

6
libs/include/bn.h → includes/openssl/bn.h

@ -125,12 +125,12 @@
#ifndef HEADER_BN_H
#define HEADER_BN_H
#include <openssl/e_os2.h>
#include "e_os2.h"
#ifndef OPENSSL_NO_FP_API
#include <stdio.h> /* FILE */
#endif
#include <openssl/ossl_typ.h>
#include <openssl/crypto.h>
#include "ossl_typ.h"
#include "crypto.h"
#ifdef __cplusplus
extern "C" {

2
libs/include/buffer.h → includes/openssl/buffer.h

@ -59,7 +59,7 @@
#ifndef HEADER_BUFFER_H
#define HEADER_BUFFER_H
#include <openssl/ossl_typ.h>
#include "ossl_typ.h"
#ifdef __cplusplus
extern "C" {

2
libs/include/camellia.h → includes/openssl/camellia.h

@ -52,7 +52,7 @@
#ifndef HEADER_CAMELLIA_H
#define HEADER_CAMELLIA_H
#include <openssl/opensslconf.h>
#include "opensslconf.h"
#ifdef OPENSSL_NO_CAMELLIA
#error CAMELLIA is disabled.

2
libs/include/cast.h → includes/openssl/cast.h

@ -63,7 +63,7 @@
extern "C" {
#endif
#include <openssl/opensslconf.h>
#include "opensslconf.h"
#ifdef OPENSSL_NO_CAST
#error CAST is disabled.

2
libs/include/cmac.h → includes/openssl/cmac.h

@ -59,7 +59,7 @@
extern "C" {
#endif
#include <openssl/evp.h>
#include "evp.h"
/* Opaque */
typedef struct CMAC_CTX_st CMAC_CTX;

2
libs/include/cms.h → includes/openssl/cms.h

@ -55,7 +55,7 @@
#ifndef HEADER_CMS_H
#define HEADER_CMS_H
#include <openssl/x509.h>
#include "x509.h"
#ifdef OPENSSL_NO_CMS
#error CMS is disabled.

2
libs/include/comp.h → includes/openssl/comp.h

@ -2,7 +2,7 @@
#ifndef HEADER_COMP_H
#define HEADER_COMP_H
#include <openssl/crypto.h>
#include "crypto.h"
#ifdef __cplusplus
extern "C" {

12
libs/include/conf.h → includes/openssl/conf.h

@ -59,13 +59,13 @@
#ifndef HEADER_CONF_H
#define HEADER_CONF_H
#include <openssl/bio.h>
#include <openssl/lhash.h>
#include <openssl/stack.h>
#include <openssl/safestack.h>
#include <openssl/e_os2.h>
#include "bio.h"
#include "lhash.h"
#include "stack.h"
#include "safestack.h"
#include "e_os2.h"
#include <openssl/ossl_typ.h>
#include "ossl_typ.h"
#ifdef __cplusplus
extern "C" {

4
libs/include/conf_api.h → includes/openssl/conf_api.h

@ -59,8 +59,8 @@
#ifndef HEADER_CONF_API_H
#define HEADER_CONF_API_H
#include <openssl/lhash.h>
#include <openssl/conf.h>
#include "lhash.h"
#include "conf.h"
#ifdef __cplusplus
extern "C" {

14
libs/include/crypto.h → includes/openssl/crypto.h

@ -119,24 +119,24 @@
#include <stdlib.h>
#include <openssl/e_os2.h>
#include "e_os2.h"
#ifndef OPENSSL_NO_FP_API
#include <stdio.h>
#endif
#include <openssl/stack.h>
#include <openssl/safestack.h>
#include <openssl/opensslv.h>
#include <openssl/ossl_typ.h>
#include "stack.h"
#include "safestack.h"
#include "opensslv.h"
#include "ossl_typ.h"
#ifdef CHARSET_EBCDIC
#include <openssl/ebcdic.h>
#include "ebcdic.h"
#endif
/* Resolve problems on some operating systems with symbol names that clash
one way or another */
#include <openssl/symhacks.h>
#include "symhacks.h"
#ifdef __cplusplus
extern "C" {

0
libs/include/curl.h → includes/openssl/curl.h

0
libs/include/curlbuild.h → includes/openssl/curlbuild.h

0
libs/include/curlrules.h → includes/openssl/curlrules.h

0
libs/include/curlver.h → includes/openssl/curlver.h

2
libs/include/des.h → includes/openssl/des.h

@ -59,7 +59,7 @@
#ifndef HEADER_NEW_DES_H
#define HEADER_NEW_DES_H
#include <openssl/e_os2.h> /* OPENSSL_EXTERN, OPENSSL_NO_DES,
#include "e_os2.h" /* OPENSSL_EXTERN, OPENSSL_NO_DES,
DES_LONG (via openssl/opensslconf.h */
#ifdef OPENSSL_NO_DES

6
libs/include/des_old.h → includes/openssl/des_old.h

@ -91,7 +91,7 @@
#ifndef HEADER_DES_H
#define HEADER_DES_H
#include <openssl/e_os2.h> /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG */
#include "e_os2.h" /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG */
#ifdef OPENSSL_NO_DES
#error DES is disabled.
@ -105,7 +105,7 @@
#error <openssl/des_old.h> replaces <kerberos/des.h>.
#endif
#include <openssl/symhacks.h>
#include "symhacks.h"
#ifdef OPENSSL_BUILD_SHLIBCRYPTO
# undef OPENSSL_EXTERN
@ -441,6 +441,6 @@ void _ossl_096_des_random_seed(des_cblock *key);
#endif
/* for DES_read_pw_string et al */
#include <openssl/ui_compat.h>
#include "ui_compat.h"
#endif

8
libs/include/dh.h → includes/openssl/dh.h

@ -59,18 +59,18 @@
#ifndef HEADER_DH_H
#define HEADER_DH_H
#include <openssl/e_os2.h>
#include "e_os2.h"
#ifdef OPENSSL_NO_DH
#error DH is disabled.
#endif
#ifndef OPENSSL_NO_BIO
#include <openssl/bio.h>
#include "bio.h"
#endif
#include <openssl/ossl_typ.h>
#include "ossl_typ.h"
#ifndef OPENSSL_NO_DEPRECATED
#include <openssl/bn.h>
#include "bn.h"
#endif
#ifndef OPENSSL_DH_MAX_MODULUS_BITS

12
libs/include/dsa.h → includes/openssl/dsa.h

@ -65,22 +65,22 @@
#ifndef HEADER_DSA_H
#define HEADER_DSA_H
#include <openssl/e_os2.h>
#include "e_os2.h"
#ifdef OPENSSL_NO_DSA
#error DSA is disabled.
#endif
#ifndef OPENSSL_NO_BIO
#include <openssl/bio.h>
#include "bio.h"
#endif
#include <openssl/crypto.h>
#include <openssl/ossl_typ.h>
#include "crypto.h"
#include "ossl_typ.h"
#ifndef OPENSSL_NO_DEPRECATED
#include <openssl/bn.h>
#include "bn.h"
#ifndef OPENSSL_NO_DH
# include <openssl/dh.h>
#include "dh.h"
#endif
#endif

2
libs/include/dso.h → includes/openssl/dso.h

@ -59,7 +59,7 @@
#ifndef HEADER_DSO_H
#define HEADER_DSO_H
#include <openssl/crypto.h>
#include "crypto.h"
#ifdef __cplusplus
extern "C" {

4
libs/include/dtls1.h → includes/openssl/dtls1.h

@ -60,8 +60,8 @@
#ifndef HEADER_DTLS1_H
#define HEADER_DTLS1_H
#include <openssl/buffer.h>
#include <openssl/pqueue.h>
#include "buffer.h"
#include "pqueue.h"
#ifdef OPENSSL_SYS_VMS
#include <resource.h>
#include <sys/timeb.h>

741
includes/openssl/e_os.h

@ -0,0 +1,741 @@
/* e_os.h */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
#ifndef HEADER_E_OS_H
#define HEADER_E_OS_H
#include <openssl/opensslconf.h>
#include <openssl/e_os2.h>
/* <openssl/e_os2.h> contains what we can justify to make visible
* to the outside; this file e_os.h is not part of the exported
* interface. */
#ifdef __cplusplus
extern "C" {
#endif
/* Used to checking reference counts, most while doing perl5 stuff :-) */
#ifdef REF_PRINT
#undef REF_PRINT
#define REF_PRINT(a,b) fprintf(stderr,"%08X:%4d:%s\n",(int)b,b->references,a)
#endif
#ifndef DEVRANDOM
/* set this to a comma-separated list of 'random' device files to try out.
* My default, we will try to read at least one of these files */
#define DEVRANDOM "/dev/urandom","/dev/random","/dev/srandom"
#endif
#ifndef DEVRANDOM_EGD
/* set this to a comma-seperated list of 'egd' sockets to try out. These
* sockets will be tried in the order listed in case accessing the device files
* listed in DEVRANDOM did not return enough entropy. */
#define DEVRANDOM_EGD "/var/run/egd-pool","/dev/egd-pool","/etc/egd-pool","/etc/entropy"
#endif
#if defined(OPENSSL_SYS_VXWORKS)
# define NO_SYS_PARAM_H
# define NO_CHMOD
# define NO_SYSLOG
#endif
#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
# if macintosh==1
# ifndef MAC_OS_GUSI_SOURCE
# define MAC_OS_pre_X
# define NO_SYS_TYPES_H
# endif
# define NO_SYS_PARAM_H
# define NO_CHMOD
# define NO_SYSLOG
# undef DEVRANDOM
# define GETPID_IS_MEANINGLESS
# endif
#endif
/********************************************************************
The Microsoft section
********************************************************************/
/* The following is used because of the small stack in some
* Microsoft operating systems */
#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYSNAME_WIN32)
# define MS_STATIC static
#else
# define MS_STATIC
#endif
#if defined(OPENSSL_SYS_WIN32) && !defined(WIN32)
# define WIN32
#endif
#if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS)
# define WINDOWS
#endif
#if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS)
# define MSDOS
#endif
#if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)
# define GETPID_IS_MEANINGLESS
#endif
#ifdef WIN32
#define get_last_sys_error() GetLastError()
#define clear_sys_error() SetLastError(0)
#if !defined(WINNT)
#define WIN_CONSOLE_BUG
#endif
#else
#define get_last_sys_error() errno
#define clear_sys_error() errno=0
#endif
#if defined(WINDOWS)
#define get_last_socket_error() WSAGetLastError()
#define clear_socket_error() WSASetLastError(0)
#define readsocket(s,b,n) recv((s),(b),(n),0)
#define writesocket(s,b,n) send((s),(b),(n),0)
#elif defined(__DJGPP__)
#define WATT32
#define get_last_socket_error() errno
#define clear_socket_error() errno=0
#define closesocket(s) close_s(s)
#define readsocket(s,b,n) read_s(s,b,n)
#define writesocket(s,b,n) send(s,b,n,0)
#elif defined(MAC_OS_pre_X)
#define get_last_socket_error() errno
#define clear_socket_error() errno=0
#define closesocket(s) MacSocket_close(s)
#define readsocket(s,b,n) MacSocket_recv((s),(b),(n),true)
#define writesocket(s,b,n) MacSocket_send((s),(b),(n))
#elif defined(OPENSSL_SYS_VMS)
#define get_last_socket_error() errno
#define clear_socket_error() errno=0
#define ioctlsocket(a,b,c) ioctl(a,b,c)
#define closesocket(s) close(s)
#define readsocket(s,b,n) recv((s),(b),(n),0)
#define writesocket(s,b,n) send((s),(b),(n),0)
#elif defined(OPENSSL_SYS_VXWORKS)
#define get_last_socket_error() errno
#define clear_socket_error() errno=0
#define ioctlsocket(a,b,c) ioctl((a),(b),(int)(c))
#define closesocket(s) close(s)
#define readsocket(s,b,n) read((s),(b),(n))
#define writesocket(s,b,n) write((s),(char *)(b),(n))
#elif defined(OPENSSL_SYS_BEOS_R5)
#define get_last_socket_error() errno
#define clear_socket_error() errno=0
#define FIONBIO SO_NONBLOCK
#define ioctlsocket(a,b,c) setsockopt((a),SOL_SOCKET,(b),(c),sizeof(*(c)))
#define readsocket(s,b,n) recv((s),(b),(n),0)
#define writesocket(s,b,n) send((s),(b),(n),0)
#elif defined(OPENSSL_SYS_NETWARE)
#if defined(NETWARE_BSDSOCK)
#define get_last_socket_error() errno
#define clear_socket_error() errno=0
#define closesocket(s) close(s)
#define ioctlsocket(a,b,c) ioctl(a,b,c)
#if defined(NETWARE_LIBC)
#define readsocket(s,b,n) recv((s),(b),(n),0)
#define writesocket(s,b,n) send((s),(b),(n),0)
#else
#define readsocket(s,b,n) recv((s),(char*)(b),(n),0)
#define writesocket(s,b,n) send((s),(char*)(b),(n),0)
#endif
#else
#define get_last_socket_error() WSAGetLastError()
#define clear_socket_error() WSASetLastError(0)
#define readsocket(s,b,n) recv((s),(b),(n),0)
#define writesocket(s,b,n) send((s),(b),(n),0)
#endif
#else
#define get_last_socket_error() errno
#define clear_socket_error() errno=0
#define ioctlsocket(a,b,c) ioctl(a,b,c)
#define closesocket(s) close(s)
#define readsocket(s,b,n) read((s),(b),(n))
#define writesocket(s,b,n) write((s),(b),(n))
#endif
#ifdef WIN16 /* never the case */
# define MS_CALLBACK _far _loadds
# define MS_FAR _far
#else
# define MS_CALLBACK
# define MS_FAR
#endif
#ifdef OPENSSL_NO_STDIO
# undef OPENSSL_NO_FP_API
# define OPENSSL_NO_FP_API
#endif
#if (defined(WINDOWS) || defined(MSDOS))
# ifdef __DJGPP__
# include <unistd.h>
# include <sys/stat.h>
# include <sys/socket.h>
# include <tcp.h>
# include <netdb.h>
# define _setmode setmode
# define _O_TEXT O_TEXT
# define _O_BINARY O_BINARY
# undef DEVRANDOM
# define DEVRANDOM "/dev/urandom\x24"
# endif /* __DJGPP__ */
# ifndef S_IFDIR
# define S_IFDIR _S_IFDIR
# endif
# ifndef S_IFMT
# define S_IFMT _S_IFMT
# endif
# if !defined(WINNT) && !defined(__DJGPP__)
# define NO_SYSLOG
# endif
# define NO_DIRENT
# ifdef WINDOWS
# if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)
/*
* Defining _WIN32_WINNT here in e_os.h implies certain "discipline."
* Most notably we ought to check for availability of each specific
* routine with GetProcAddress() and/or guard NT-specific calls with
* GetVersion() < 0x80000000. One can argue that in latter "or" case
* we ought to /DELAYLOAD some .DLLs in order to protect ourselves
* against run-time link errors. This doesn't seem to be necessary,
* because it turned out that already Windows 95, first non-NT Win32
* implementation, is equipped with at least NT 3.51 stubs, dummy
* routines with same name, but which do nothing. Meaning that it's
* apparently sufficient to guard "vanilla" NT calls with GetVersion
* alone, while NT 4.0 and above interfaces ought to be linked with
* GetProcAddress at run-time.
*/
# define _WIN32_WINNT 0x0400
# endif
# if !defined(OPENSSL_NO_SOCK) && defined(_WIN32_WINNT)
/*
* Just like defining _WIN32_WINNT including winsock2.h implies
* certain "discipline" for maintaining [broad] binary compatibility.
* As long as structures are invariant among Winsock versions,
* it's sufficient to check for specific Winsock2 API availability
* at run-time [DSO_global_lookup is recommended]...
*/
# include <winsock2.h>
# include <ws2tcpip.h>
/* yes, they have to be #included prior to <windows.h> */
# endif
# include <windows.h>
# include <stdio.h>
# include <stddef.h>
# include <errno.h>
# include <string.h>
# ifdef _WIN64
# define strlen(s) _strlen31(s)
/* cut strings to 2GB */
static unsigned int _strlen31(const char *str)
{
unsigned int len=0;
while (*str && len<0x80000000U) str++, len++;
return len&0x7FFFFFFF;
}
# endif
# include <malloc.h>
# if defined(_MSC_VER) && _MSC_VER<=1200 && defined(_MT) && defined(isspace)
/* compensate for bug in VC6 ctype.h */
# undef isspace
# undef isdigit
# undef isalnum
# undef isupper
# undef isxdigit
# endif
# if defined(_MSC_VER) && !defined(_DLL) && defined(stdin)
# if _MSC_VER>=1300
# undef stdin
# undef stdout
# undef stderr
FILE *__iob_func();
# define stdin (&__iob_func()[0])
# define stdout (&__iob_func()[1])
# define stderr (&__iob_func()[2])
# elif defined(I_CAN_LIVE_WITH_LNK4049)
# undef stdin
# undef stdout
# undef stderr
/* pre-1300 has __p__iob(), but it's available only in msvcrt.lib,
* or in other words with /MD. Declaring implicit import, i.e.
* with _imp_ prefix, works correctly with all compiler options,
* but without /MD results in LINK warning LNK4049:
* 'locally defined symbol "__iob" imported'.
*/
extern FILE *_imp___iob;
# define stdin (&_imp___iob[0])
# define stdout (&_imp___iob[1])
# define stderr (&_imp___iob[2])
# endif
# endif
# endif
# include <io.h>
# include <fcntl.h>
# ifdef OPENSSL_SYS_WINCE
# define OPENSSL_NO_POSIX_IO
# endif
# if defined (__BORLANDC__)
# define _setmode setmode
# define _O_TEXT O_TEXT
# define _O_BINARY O_BINARY
# define _int64 __int64
# define _kbhit kbhit
# endif
# define EXIT(n) exit(n)
# define LIST_SEPARATOR_CHAR ';'
# ifndef X_OK
# define X_OK 0
# endif
# ifndef W_OK
# define W_OK 2
# endif
# ifndef R_OK
# define R_OK 4
# endif
# define OPENSSL_CONF "openssl.cnf"
# define SSLEAY_CONF OPENSSL_CONF
# define NUL_DEV "nul"
# define RFILE ".rnd"
# ifdef OPENSSL_SYS_WINCE
# define DEFAULT_HOME ""
# else
# define DEFAULT_HOME "C:"
# endif
/* Avoid Windows 8 SDK GetVersion deprecated problems */
#if defined(_MSC_VER) && _MSC_VER>=1800
# define check_winnt() (1)
#else
# define check_winnt() (GetVersion() < 0x80000000)
#endif
#else /* The non-microsoft world */
# ifdef OPENSSL_SYS_VMS
# define VMS 1
/* some programs don't include stdlib, so exit() and others give implicit
function warnings */
# include <stdlib.h>
# if defined(__DECC)
# include <unistd.h>
# else
# include <unixlib.h>
# endif
# define OPENSSL_CONF "openssl.cnf"
# define SSLEAY_CONF OPENSSL_CONF
# define RFILE ".rnd"
# define LIST_SEPARATOR_CHAR ','
# define NUL_DEV "NLA0:"
/* We don't have any well-defined random devices on VMS, yet... */
# undef DEVRANDOM
/* We need to do this since VMS has the following coding on status codes:
Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ...
The important thing to know is that odd numbers are considered
good, while even ones are considered errors.
Bits 3-15: actual status number
Bits 16-27: facility number. 0 is considered "unknown"
Bits 28-31: control bits. If bit 28 is set, the shell won't try to
output the message (which, for random codes, just looks ugly)
So, what we do here is to change 0 to 1 to get the default success status,
and everything else is shifted up to fit into the status number field, and
the status is tagged as an error, which I believe is what is wanted here.
-- Richard Levitte
*/
# define EXIT(n) do { int __VMS_EXIT = n; \
if (__VMS_EXIT == 0) \
__VMS_EXIT = 1; \
else \
__VMS_EXIT = (n << 3) | 2; \
__VMS_EXIT |= 0x10000000; \
exit(__VMS_EXIT); } while(0)
# define NO_SYS_PARAM_H
# elif defined(OPENSSL_SYS_NETWARE)
# include <fcntl.h>
# include <unistd.h>
# define NO_SYS_TYPES_H
# undef DEVRANDOM
# ifdef NETWARE_CLIB
# define getpid GetThreadID
extern int GetThreadID(void);
/* # include <conio.h> */
extern int kbhit(void);
# else
# include <screen.h>
# endif
# define NO_SYSLOG
# define _setmode setmode
# define _kbhit kbhit
# define _O_TEXT O_TEXT
# define _O_BINARY O_BINARY
# define OPENSSL_CONF "openssl.cnf"
# define SSLEAY_CONF OPENSSL_CONF
# define RFILE ".rnd"
# define LIST_SEPARATOR_CHAR ';'
# define EXIT(n) { if (n) printf("ERROR: %d\n", (int)n); exit(n); }
# else
/* !defined VMS */
# ifdef OPENSSL_SYS_MPE
# define NO_SYS_PARAM_H
# endif
# ifdef OPENSSL_UNISTD
# include OPENSSL_UNISTD
# else
# include <unistd.h>
# endif
# ifndef NO_SYS_TYPES_H
# include <sys/types.h>
# endif
# if defined(NeXT) || defined(OPENSSL_SYS_NEWS4)
# define pid_t int /* pid_t is missing on NEXTSTEP/OPENSTEP
* (unless when compiling with -D_POSIX_SOURCE,
* which doesn't work for us) */
# endif
# ifdef OPENSSL_SYS_NEWS4 /* setvbuf is missing on mips-sony-bsd */
# define setvbuf(a, b, c, d) setbuffer((a), (b), (d))
typedef unsigned long clock_t;
# endif
# ifdef OPENSSL_SYS_WIN32_CYGWIN
# include <io.h>
# include <fcntl.h>
# endif
# define OPENSSL_CONF "openssl.cnf"
# define SSLEAY_CONF OPENSSL_CONF
# define RFILE ".rnd"
# define LIST_SEPARATOR_CHAR ':'
# define NUL_DEV "/dev/null"
# define EXIT(n) exit(n)
# endif
# define SSLeay_getpid() getpid()
#endif
/*************/
#ifdef USE_SOCKETS
# if defined(WINDOWS) || defined(MSDOS)
/* windows world */
# ifdef OPENSSL_NO_SOCK
# define SSLeay_Write(a,b,c) (-1)
# define SSLeay_Read(a,b,c) (-1)
# define SHUTDOWN(fd) close(fd)
# define SHUTDOWN2(fd) close(fd)
# elif !defined(__DJGPP__)
# if defined(_WIN32_WCE) && _WIN32_WCE<410
# define getservbyname _masked_declaration_getservbyname
# endif
# if !defined(IPPROTO_IP)
/* winsock[2].h was included already? */
# include <winsock.h>
# endif
# ifdef getservbyname
# undef getservbyname
/* this is used to be wcecompat/include/winsock_extras.h */
struct servent* PASCAL getservbyname(const char*,const char*);
# endif
# ifdef _WIN64
/*
* Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
* the value constitutes an index in per-process table of limited size
* and not a real pointer.
*/
# define socket(d,t,p) ((int)socket(d,t,p))
# define accept(s,f,l) ((int)accept(s,f,l))
# endif
# define SSLeay_Write(a,b,c) send((a),(b),(c),0)
# define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
# define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
# define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
# else
# define SSLeay_Write(a,b,c) write_s(a,b,c,0)
# define SSLeay_Read(a,b,c) read_s(a,b,c)
# define SHUTDOWN(fd) close_s(fd)
# define SHUTDOWN2(fd) close_s(fd)
# endif
# elif defined(MAC_OS_pre_X)
# include "MacSocket.h"
# define SSLeay_Write(a,b,c) MacSocket_send((a),(b),(c))
# define SSLeay_Read(a,b,c) MacSocket_recv((a),(b),(c),true)
# define SHUTDOWN(fd) MacSocket_close(fd)
# define SHUTDOWN2(fd) MacSocket_close(fd)
# elif defined(OPENSSL_SYS_NETWARE)
/* NetWare uses the WinSock2 interfaces by default, but can be configured for BSD
*/
# if defined(NETWARE_BSDSOCK)
# include <sys/socket.h>
# include <netinet/in.h>
# include <sys/time.h>
# if defined(NETWARE_CLIB)
# include <sys/bsdskt.h>
# else
# include <sys/select.h>
# endif
# define INVALID_SOCKET (int)(~0)
# else
# include <novsock2.h>
# endif
# define SSLeay_Write(a,b,c) send((a),(b),(c),0)
# define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
# define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
# define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
# else
# ifndef NO_SYS_PARAM_H
# include <sys/param.h>
# endif
# ifdef OPENSSL_SYS_VXWORKS
# include <time.h>
# elif !defined(OPENSSL_SYS_MPE)
# include <sys/time.h> /* Needed under linux for FD_XXX */
# endif
# include <netdb.h>
# if defined(OPENSSL_SYS_VMS_NODECC)
# include <socket.h>
# include <in.h>
# include <inet.h>
# else
# include <sys/socket.h>
# ifdef FILIO_H
# include <sys/filio.h> /* Added for FIONBIO under unixware */
# endif
# include <netinet/in.h>
# if !defined(OPENSSL_SYS_BEOS_R5)
# include <arpa/inet.h>
# endif
# endif
# if defined(NeXT) || defined(_NEXT_SOURCE)
# include <sys/fcntl.h>
# include <sys/types.h>
# endif
# ifdef OPENSSL_SYS_AIX
# include <sys/select.h>
# endif
# ifdef __QNX__
# include <sys/select.h>
# endif
# if defined(sun)
# include <sys/filio.h>
# else
# ifndef VMS
# include <sys/ioctl.h>
# else
/* ioctl is only in VMS > 7.0 and when socketshr is not used */
# if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
# include <sys/ioctl.h>
# endif
# endif
# endif
# ifdef VMS
# include <unixio.h>
# if defined(TCPIP_TYPE_SOCKETSHR)
# include <socketshr.h>
# endif
# endif
# define SSLeay_Read(a,b,c) read((a),(b),(c))
# define SSLeay_Write(a,b,c) write((a),(b),(c))
# define SHUTDOWN(fd) { shutdown((fd),0); closesocket((fd)); }
# define SHUTDOWN2(fd) { shutdown((fd),2); closesocket((fd)); }
# ifndef INVALID_SOCKET
# define INVALID_SOCKET (-1)
# endif /* INVALID_SOCKET */
# endif
/* Some IPv6 implementations are broken, disable them in known bad
* versions.
*/
# if !defined(OPENSSL_USE_IPV6)
# if defined(AF_INET6) && !defined(OPENSSL_SYS_BEOS_BONE) && !defined(NETWARE_CLIB)
# define OPENSSL_USE_IPV6 1
# else
# define OPENSSL_USE_IPV6 0
# endif
# endif
#endif
#if defined(sun) && !defined(__svr4__) && !defined(__SVR4)
/* include headers first, so our defines don't break it */
#include <stdlib.h>
#include <string.h>
/* bcopy can handle overlapping moves according to SunOS 4.1.4 manpage */
# define memmove(s1,s2,n) bcopy((s2),(s1),(n))
# define strtoul(s,e,b) ((unsigned long int)strtol((s),(e),(b)))
extern char *sys_errlist[]; extern int sys_nerr;
# define strerror(errnum) \
(((errnum)<0 || (errnum)>=sys_nerr) ? NULL : sys_errlist[errnum])
/* Being signed SunOS 4.x memcpy breaks ASN1_OBJECT table lookup */
#include "crypto/o_str.h"
# define memcmp OPENSSL_memcmp
#endif
#ifndef OPENSSL_EXIT
# if defined(MONOLITH) && !defined(OPENSSL_C)
# define OPENSSL_EXIT(n) return(n)
# else
# define OPENSSL_EXIT(n) do { EXIT(n); return(n); } while(0)
# endif
#endif
/***********************************************/
#define DG_GCC_BUG /* gcc < 2.6.3 on DGUX */
#ifdef sgi
#define IRIX_CC_BUG /* all version of IRIX I've tested (4.* 5.*) */
#endif
#ifdef OPENSSL_SYS_SNI
#define IRIX_CC_BUG /* CDS++ up to V2.0Bsomething suffered from the same bug.*/
#endif
#if defined(OPENSSL_SYS_WINDOWS)
# define strcasecmp _stricmp
# define strncasecmp _strnicmp
#elif defined(OPENSSL_SYS_VMS)
/* VMS below version 7.0 doesn't have strcasecmp() */
# include "o_str.h"
# define strcasecmp OPENSSL_strcasecmp
# define strncasecmp OPENSSL_strncasecmp
# define OPENSSL_IMPLEMENTS_strncasecmp
#elif defined(OPENSSL_SYS_OS2) && defined(__EMX__)
# define strcasecmp stricmp
# define strncasecmp strnicmp
#elif defined(OPENSSL_SYS_NETWARE)
# include <string.h>
# if defined(NETWARE_CLIB)
# define strcasecmp stricmp
# define strncasecmp strnicmp
# endif /* NETWARE_CLIB */
#endif
#if defined(OPENSSL_SYS_OS2) && defined(__EMX__)
# include <io.h>
# include <fcntl.h>
# define NO_SYSLOG
#endif
/* vxworks */
#if defined(OPENSSL_SYS_VXWORKS)
#include <ioLib.h>
#include <tickLib.h>
#include <sysLib.h>
#define TTY_STRUCT int
#define sleep(a) taskDelay((a) * sysClkRateGet())
#include <vxWorks.h>
#include <sockLib.h>
#include <taskLib.h>
#define getpid taskIdSelf
/* NOTE: these are implemented by helpers in database app!
* if the database is not linked, we need to implement them
* elswhere */
struct hostent *gethostbyname(const char *name);
struct hostent *gethostbyaddr(const char *addr, int length, int type);
struct servent *getservbyname(const char *name, const char *proto);
#endif
/* end vxworks */
/* beos */
#if defined(OPENSSL_SYS_BEOS_R5)
#define SO_ERROR 0
#define NO_SYS_UN
#define IPPROTO_IP 0
#include <OS.h>
#endif
#ifdef __cplusplus
}
#endif
#endif

2
libs/include/e_os2.h → includes/openssl/e_os2.h

@ -53,7 +53,7 @@
*
*/
#include <openssl/opensslconf.h>
#include "opensslconf.h"
#ifndef HEADER_E_OS2_H
#define HEADER_E_OS2_H

0
libs/include/easy.h → includes/openssl/easy.h

0
libs/include/ebcdic.h → includes/openssl/ebcdic.h

8
libs/include/ec.h → includes/openssl/ec.h

@ -76,16 +76,16 @@
#ifndef HEADER_EC_H
#define HEADER_EC_H
#include <openssl/opensslconf.h>
#include "opensslconf.h"
#ifdef OPENSSL_NO_EC
#error EC is disabled.
#endif
#include <openssl/asn1.h>
#include <openssl/symhacks.h>
#include "asn1.h"
#include "symhacks.h"
#ifndef OPENSSL_NO_DEPRECATED
#include <openssl/bn.h>
#include "bn.h"
#endif
#ifdef __cplusplus

8
libs/include/ecdh.h → includes/openssl/ecdh.h

@ -69,16 +69,16 @@
#ifndef HEADER_ECDH_H
#define HEADER_ECDH_H
#include <openssl/opensslconf.h>
#include "opensslconf.h"
#ifdef OPENSSL_NO_ECDH
#error ECDH is disabled.
#endif
#include <openssl/ec.h>
#include <openssl/ossl_typ.h>
#include "ec.h"
#include "ossl_typ.h"
#ifndef OPENSSL_NO_DEPRECATED
#include <openssl/bn.h>
#include "bn.h"
#endif
#ifdef __cplusplus

8
libs/include/ecdsa.h → includes/openssl/ecdsa.h

@ -59,16 +59,16 @@
#ifndef HEADER_ECDSA_H
#define HEADER_ECDSA_H
#include <openssl/opensslconf.h>
#include "opensslconf.h"
#ifdef OPENSSL_NO_ECDSA
#error ECDSA is disabled.
#endif
#include <openssl/ec.h>
#include <openssl/ossl_typ.h>
#include "ec.h"
#include "ossl_typ.h"
#ifndef OPENSSL_NO_DEPRECATED
#include <openssl/bn.h>
#include "bn.h"
#endif
#ifdef __cplusplus

26
libs/include/engine.h → includes/openssl/engine.h

@ -64,38 +64,38 @@
#ifndef HEADER_ENGINE_H
#define HEADER_ENGINE_H
#include <openssl/opensslconf.h>
#include "opensslconf.h"
#ifdef OPENSSL_NO_ENGINE
#error ENGINE is disabled.
#endif
#ifndef OPENSSL_NO_DEPRECATED
#include <openssl/bn.h>
#include "bn.h"
#ifndef OPENSSL_NO_RSA
#include <openssl/rsa.h>
#include "rsa.h"
#endif
#ifndef OPENSSL_NO_DSA
#include <openssl/dsa.h>
#include "dsa.h"
#endif
#ifndef OPENSSL_NO_DH
#include <openssl/dh.h>
#include "dh.h"
#endif
#ifndef OPENSSL_NO_ECDH
#include <openssl/ecdh.h>
#include "ecdh.h"
#endif
#ifndef OPENSSL_NO_ECDSA
#include <openssl/ecdsa.h>
#include "ecdsa.h"
#endif
#include <openssl/rand.h>
#include <openssl/ui.h>
#include <openssl/err.h>
#include "rand.h"
#include "ui.h"
#include "err.h"
#endif
#include <openssl/ossl_typ.h>
#include <openssl/symhacks.h>
#include "ossl_typ.h"
#include "symhacks.h"
#include <openssl/x509.h>
#include "x509.h"
#ifdef __cplusplus
extern "C" {

8
libs/include/err.h → includes/openssl/err.h

@ -112,19 +112,19 @@
#ifndef HEADER_ERR_H
#define HEADER_ERR_H
#include <openssl/e_os2.h>
#include "e_os2.h"
#ifndef OPENSSL_NO_FP_API
#include <stdio.h>
#include <stdlib.h>
#endif
#include <openssl/ossl_typ.h>
#include "ossl_typ.h"
#ifndef OPENSSL_NO_BIO
#include <openssl/bio.h>
#include "bio.h"
#endif
#ifndef OPENSSL_NO_LHASH
#include <openssl/lhash.h>
#include "lhash.h"
#endif
#ifdef __cplusplus

12
libs/include/evp.h → includes/openssl/evp.h

@ -60,19 +60,19 @@
#define HEADER_ENVELOPE_H
#ifdef OPENSSL_ALGORITHM_DEFINES
# include <openssl/opensslconf.h>
#include "opensslconf.h"
#else
# define OPENSSL_ALGORITHM_DEFINES
# include <openssl/opensslconf.h>
#include "opensslconf.h"
# undef OPENSSL_ALGORITHM_DEFINES
#endif
#include <openssl/ossl_typ.h>
#include "ossl_typ.h"
#include <openssl/symhacks.h>
#include "symhacks.h"
#ifndef OPENSSL_NO_BIO
#include <openssl/bio.h>
#include "bio.h"
#endif
/*
@ -91,7 +91,7 @@
/* Default PKCS#5 iteration count */
#define PKCS5_DEFAULT_ITER 2048
#include <openssl/objects.h>
#include "objects.h"
#define EVP_PK_RSA 0x0001
#define EVP_PK_DSA 0x0002

4
libs/include/hmac.h → includes/openssl/hmac.h

@ -58,13 +58,13 @@
#ifndef HEADER_HMAC_H
#define HEADER_HMAC_H
#include <openssl/opensslconf.h>
#include "opensslconf.h"
#ifdef OPENSSL_NO_HMAC
#error HMAC is disabled.
#endif
#include <openssl/evp.h>
#include "evp.h"
#define HMAC_MAX_MD_CBLOCK 128 /* largest known is SHA512 */

2
libs/include/idea.h → includes/openssl/idea.h

@ -59,7 +59,7 @@
#ifndef HEADER_IDEA_H
#define HEADER_IDEA_H
#include <openssl/opensslconf.h> /* IDEA_INT, OPENSSL_NO_IDEA */
#include "opensslconf.h" /* IDEA_INT, OPENSSL_NO_IDEA */
#ifdef OPENSSL_NO_IDEA
#error IDEA is disabled.

2
libs/include/krb5_asn.h → includes/openssl/krb5_asn.h

@ -63,7 +63,7 @@
/*
#include <krb5.h>
*/
#include <openssl/safestack.h>
#include "safestack.h"
#ifdef __cplusplus
extern "C" {

2
libs/include/kssl.h → includes/openssl/kssl.h

@ -63,7 +63,7 @@
#ifndef KSSL_H
#define KSSL_H
#include <openssl/opensslconf.h>
#include "opensslconf.h"
#ifndef OPENSSL_NO_KRB5

4
libs/include/lhash.h → includes/openssl/lhash.h

@ -63,13 +63,13 @@
#ifndef HEADER_LHASH_H
#define HEADER_LHASH_H
#include <openssl/e_os2.h>
#include "e_os2.h"
#ifndef OPENSSL_NO_FP_API
#include <stdio.h>
#endif
#ifndef OPENSSL_NO_BIO
#include <openssl/bio.h>
#include "bio.h"
#endif
#ifdef __cplusplus

2
libs/include/md4.h → includes/openssl/md4.h

@ -59,7 +59,7 @@
#ifndef HEADER_MD4_H
#define HEADER_MD4_H
#include <openssl/e_os2.h>
#include "e_os2.h"
#include <stddef.h>
#ifdef __cplusplus

2
libs/include/md5.h → includes/openssl/md5.h

@ -59,7 +59,7 @@
#ifndef HEADER_MD5_H
#define HEADER_MD5_H
#include <openssl/e_os2.h>
#include "e_os2.h"
#include <stddef.h>
#ifdef __cplusplus

2
libs/include/mdc2.h → includes/openssl/mdc2.h

@ -59,7 +59,7 @@
#ifndef HEADER_MDC2_H
#define HEADER_MDC2_H
#include <openssl/des.h>
#include "des.h"
#ifdef __cplusplus
extern "C" {

0
libs/include/modes.h → includes/openssl/modes.h

0
libs/include/mprintf.h → includes/openssl/mprintf.h

0
libs/include/multi.h → includes/openssl/multi.h

0
libs/include/obj_mac.h → includes/openssl/obj_mac.h

6
libs/include/objects.h → includes/openssl/objects.h

@ -62,7 +62,7 @@
#define USE_OBJ_MAC
#ifdef USE_OBJ_MAC
#include <openssl/obj_mac.h>
#include "obj_mac.h"
#else
#define SN_undef "UNDEF"
#define LN_undef "undefined"
@ -956,8 +956,8 @@
#define OBJ_OCSP_sign OBJ_id_kp,9L
#endif /* USE_OBJ_MAC */
#include <openssl/bio.h>
#include <openssl/asn1.h>
#include "bio.h"
#include "asn1.h"
#define OBJ_NAME_TYPE_UNDEF 0x00
#define OBJ_NAME_TYPE_MD_METH 0x01

8
libs/include/ocsp.h → includes/openssl/ocsp.h

@ -64,10 +64,10 @@
#ifndef HEADER_OCSP_H
#define HEADER_OCSP_H
#include <openssl/ossl_typ.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <openssl/safestack.h>
#include "ossl_typ.h"
#include "x509.h"
#include "x509v3.h"
#include "safestack.h"
#ifdef __cplusplus
extern "C" {

0
libs/include/opensslconf.h → includes/openssl/opensslconf.h

0
libs/include/opensslv.h → includes/openssl/opensslv.h

2
libs/include/ossl_typ.h → includes/openssl/ossl_typ.h

@ -55,7 +55,7 @@
#ifndef HEADER_OPENSSL_TYPES_H
#define HEADER_OPENSSL_TYPES_H
#include <openssl/e_os2.h>
#include "e_os2.h"
#ifdef NO_ASN1_TYPEDEFS
#define ASN1_INTEGER ASN1_STRING

14
libs/include/pem.h → includes/openssl/pem.h

@ -59,16 +59,16 @@
#ifndef HEADER_PEM_H
#define HEADER_PEM_H
#include <openssl/e_os2.h>
#include "e_os2.h"
#ifndef OPENSSL_NO_BIO
#include <openssl/bio.h>
#include "bio.h"
#endif
#ifndef OPENSSL_NO_STACK
#include <openssl/stack.h>
#include "stack.h"
#endif
#include <openssl/evp.h>
#include <openssl/x509.h>
#include <openssl/pem2.h>
#include "evp.h"
#include "x509.h"
#include "pem2.h"
#ifdef __cplusplus
extern "C" {
@ -454,7 +454,7 @@ void PEM_proc_type(char *buf, int type);
void PEM_dek_info(char *buf, const char *type, int len, char *str);
#include <openssl/symhacks.h>
#include "symhacks.h"
DECLARE_PEM_rw(X509, X509)

0
libs/include/pem2.h → includes/openssl/pem2.h

4
libs/include/pkcs12.h → includes/openssl/pkcs12.h

@ -59,8 +59,8 @@
#ifndef HEADER_PKCS12_H
#define HEADER_PKCS12_H
#include <openssl/bio.h>
#include <openssl/x509.h>
#include "bio.h"
#include "x509.h"
#ifdef __cplusplus
extern "C" {

10
libs/include/pkcs7.h → includes/openssl/pkcs7.h

@ -59,12 +59,12 @@
#ifndef HEADER_PKCS7_H
#define HEADER_PKCS7_H
#include <openssl/asn1.h>
#include <openssl/bio.h>
#include <openssl/e_os2.h>
#include "asn1.h"
#include "bio.h"
#include "e_os2.h"
#include <openssl/symhacks.h>
#include <openssl/ossl_typ.h>
#include "symhacks.h"
#include "ossl_typ.h"
#ifdef __cplusplus
extern "C" {

0
libs/include/pqueue.h → includes/openssl/pqueue.h

4
libs/include/rand.h → includes/openssl/rand.h

@ -60,8 +60,8 @@
#define HEADER_RAND_H
#include <stdlib.h>
#include <openssl/ossl_typ.h>
#include <openssl/e_os2.h>
#include "ossl_typ.h"
#include "e_os2.h"
#if defined(OPENSSL_SYS_WINDOWS)
#include <windows.h>

2
libs/include/rc2.h → includes/openssl/rc2.h

@ -59,7 +59,7 @@
#ifndef HEADER_RC2_H
#define HEADER_RC2_H
#include <openssl/opensslconf.h> /* OPENSSL_NO_RC2, RC2_INT */
#include "opensslconf.h" /* OPENSSL_NO_RC2, RC2_INT */
#ifdef OPENSSL_NO_RC2
#error RC2 is disabled.
#endif

2
libs/include/rc4.h → includes/openssl/rc4.h

@ -59,7 +59,7 @@
#ifndef HEADER_RC4_H
#define HEADER_RC4_H
#include <openssl/opensslconf.h> /* OPENSSL_NO_RC4, RC4_INT */
#include "opensslconf.h" /* OPENSSL_NO_RC4, RC4_INT */
#ifdef OPENSSL_NO_RC4
#error RC4 is disabled.
#endif

2
libs/include/ripemd.h → includes/openssl/ripemd.h

@ -59,7 +59,7 @@
#ifndef HEADER_RIPEMD_H
#define HEADER_RIPEMD_H
#include <openssl/e_os2.h>
#include "e_os2.h"
#include <stddef.h>
#ifdef __cplusplus

10
libs/include/rsa.h → includes/openssl/rsa.h

@ -59,15 +59,15 @@
#ifndef HEADER_RSA_H
#define HEADER_RSA_H
#include <openssl/asn1.h>
#include "asn1.h"
#ifndef OPENSSL_NO_BIO
#include <openssl/bio.h>
#include "bio.h"
#endif
#include <openssl/crypto.h>
#include <openssl/ossl_typ.h>
#include "crypto.h"
#include "ossl_typ.h"
#ifndef OPENSSL_NO_DEPRECATED
#include <openssl/bn.h>
#include "bn.h"
#endif
#ifdef OPENSSL_NO_RSA

2
libs/include/safestack.h → includes/openssl/safestack.h

@ -55,7 +55,7 @@
#ifndef HEADER_SAFESTACK_H
#define HEADER_SAFESTACK_H
#include <openssl/stack.h>
#include "stack.h"
#ifndef CHECKED_PTR_OF
#define CHECKED_PTR_OF(type, p) \

6
libs/include/seed.h → includes/openssl/seed.h

@ -81,9 +81,9 @@
#ifndef HEADER_SEED_H
#define HEADER_SEED_H
#include <openssl/opensslconf.h>
#include <openssl/e_os2.h>
#include <openssl/crypto.h>
#include "opensslconf.h"
#include "e_os2.h"
#include "crypto.h"
#ifdef OPENSSL_NO_SEED
#error SEED is disabled.

2
libs/include/sha.h → includes/openssl/sha.h

@ -59,7 +59,7 @@
#ifndef HEADER_SHA_H
#define HEADER_SHA_H
#include <openssl/e_os2.h>
#include "e_os2.h"
#include <stddef.h>
#ifdef __cplusplus

6
libs/include/srp.h → includes/openssl/srp.h

@ -68,9 +68,9 @@
extern "C" {
#endif
#include <openssl/safestack.h>
#include <openssl/bn.h>
#include <openssl/crypto.h>
#include "safestack.h"
#include "bn.h"
#include "crypto.h"
typedef struct SRP_gN_cache_st
{

0
libs/include/srtp.h → includes/openssl/srtp.h

36
libs/include/ssl.h → includes/openssl/ssl.h

@ -143,28 +143,28 @@
#ifndef HEADER_SSL_H
#define HEADER_SSL_H
#include <openssl/e_os2.h>
#include "e_os2.h"
#ifndef OPENSSL_NO_COMP
#include <openssl/comp.h>
#include "comp.h"
#endif
#ifndef OPENSSL_NO_BIO
#include <openssl/bio.h>
#include "bio.h"
#endif
#ifndef OPENSSL_NO_DEPRECATED
#ifndef OPENSSL_NO_X509
#include <openssl/x509.h>
#include "x509.h"
#endif
#include <openssl/crypto.h>
#include <openssl/lhash.h>
#include <openssl/buffer.h>
#include "crypto.h"
#include "lhash.h"
#include "buffer.h"
#endif
#include <openssl/pem.h>
#include <openssl/hmac.h>
#include "pem.h"
#include "hmac.h"
#include <openssl/kssl.h>
#include <openssl/safestack.h>
#include <openssl/symhacks.h>
#include "kssl.h"
#include "safestack.h"
#include "symhacks.h"
#ifdef __cplusplus
extern "C" {
@ -1369,12 +1369,12 @@ struct ssl_st
}
#endif
#include <openssl/ssl2.h>
#include <openssl/ssl3.h>
#include <openssl/tls1.h> /* This is mostly sslv3 with a few tweaks */
#include <openssl/dtls1.h> /* Datagram TLS */
#include <openssl/ssl23.h>
#include <openssl/srtp.h> /* Support for the use_srtp extension */
#include "ssl2.h"
#include "ssl3.h"
#include "tls1.h" /* This is mostly sslv3 with a few tweaks */
#include "dtls1.h" /* Datagram TLS */
#include "ssl23.h"
#include "srtp.h" /* Support for the use_srtp extension */
#ifdef __cplusplus
extern "C" {

0
libs/include/ssl2.h → includes/openssl/ssl2.h

0
libs/include/ssl23.h → includes/openssl/ssl23.h

8
libs/include/ssl3.h → includes/openssl/ssl3.h

@ -118,11 +118,11 @@
#define HEADER_SSL3_H
#ifndef OPENSSL_NO_COMP
#include <openssl/comp.h>
#include "comp.h"
#endif
#include <openssl/buffer.h>
#include <openssl/evp.h>
#include <openssl/ssl.h>
#include "buffer.h"
#include "evp.h"
#include "ssl.h"
#ifdef __cplusplus
extern "C" {

0
libs/include/stack.h → includes/openssl/stack.h

0
libs/include/stdcheaders.h → includes/openssl/stdcheaders.h

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save