winutils.h revision 2e848e79ccf2e4285250a0af98ddb9eb28864878
#ifndef __WINUTILS_H_
# define __WINUTILS_H_
# ifdef RT_OS_WINDOWS
# include <WinSock2.h>
# include <Windows.h>
/**
* of hton-family functions in LWIP and windock's headers.
*/
# ifndef PF_LOCAL
# endif
# ifdef DEBUG
AssertMsgFailed((__VA_ARGS__)); \
}while(0)
#else
DPRINTF0((__VA_ARGS__)); \
ExitProcess(code); \
}while(0)
#endif
# define __func__ __FUNCTION__
# define __attribute__(x) /* IGNORE */
{
switch (af_family) {
case AF_INET: {
break;
}
case AF_INET6: {
#if 0
#else
/* RTNetStrToIPv6Addr isn't implemented yet. */
return -1;
#endif
break;
}
default:
}
return 0;
}
/**
* tftpd emulation we're using POSIX operations which needs "DOS errno". see proxy_tftpd.c
*/
# ifndef _USE_WINSTD_ERRNO
/**
* http://msdn.microsoft.com/en-us/library/windows/desktop/ms737828(v=vs.85).aspx
* "Error Codes - errno, h_errno and WSAGetLastError" says "Error codes set by Windows Sockets are
* not made available through the errno variable."
*/
# include <errno.h>
# ifdef errno
# endif
# define errno (WSAGetLastError())
# endif
/* Missing errno codes */
/**
* http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx#WSAEHOSTDOWN
* Corresponds to WSAEHOSTDOWN (10064) WSAGetLastError()
*/
# define EHOSTDOWN WSAEHOSTDOWN
/**
* http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx#WSAEHOSTUNREACH
*/
# define EHOSTUNREAH WSAEHOSTUNREACH
/**
* parameters to shutdown (2) with Winsock2
* http://msdn.microsoft.com/en-us/library/windows/desktop/ms740481(v=vs.85).aspx
*/
# define SHUT_RD SD_RECEIVE
typedef int socklen_t;
# else /* !RT_OS_WINDOWS */
# define ioctlsocket ioctl
# define closesocket close
# define SOCKET int
# define INVALID_SOCKET (-1)
# define SOCKET_ERROR (-1)
# endif
#endif