2 * Copyright (c) 2009 Intel Corporation. All rights reserved.
\r
4 * This software is available to you under the OpenIB.org BSD license
\r
7 * Redistribution and use in source and binary forms, with or
\r
8 * without modification, are permitted provided that the following
\r
9 * conditions are met:
\r
11 * - Redistributions of source code must retain the above
\r
12 * copyright notice, this list of conditions and the following
\r
15 * - Redistributions in binary form must reproduce the above
\r
16 * copyright notice, this list of conditions and the following
\r
17 * disclaimer in the documentation and/or other materials
\r
18 * provided with the distribution.
\r
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AWV
\r
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
\r
24 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
25 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
32 #include <windows.h>
\r
33 #include <winsock2.h>
\r
34 #include <ws2tcpip.h>
\r
36 typedef unsigned __int8 uint8_t;
\r
37 typedef unsigned __int16 uint16_t;
\r
38 typedef unsigned __int32 uint32_t;
\r
39 typedef unsigned __int64 uint64_t;
\r
41 #define PRId64 "I64d"
\r
42 #define PRIx64 "I64x"
\r
43 #define PRIo64 "I64o"
\r
44 #define PRIu64 "I64u"
\r
46 #define MAD_EXPORT __declspec(dllexport)
\r
48 #if !defined( __cplusplus )
\r
49 #define inline __inline
\r
52 #define bswap_64 _byteswap_uint64
\r
53 #define getpid() GetCurrentProcessId()
54 #define snprintf _snprintf
55 #define strtoull _strtoui64
\r
56 #define __func__ __FUNCTION__
61 const char * _inet_ntop(int family, const void *addr, char *dst, size_t len)
\r
63 if (family == AF_INET)
\r
65 struct sockaddr_in in;
\r
66 in.sin_family = AF_INET;
\r
67 memcpy(&in.sin_addr, addr, 4);
\r
68 if (getnameinfo((struct sockaddr *)&in,
\r
69 (socklen_t) (sizeof(struct sockaddr_in)),
\r
70 dst, len, NULL, 0, NI_NUMERICHOST))
\r
73 else if (family == AF_INET6)
\r
75 struct sockaddr_in6 in6;
\r
76 memset(&in6, 0, sizeof in6);
\r
77 in6.sin6_family = AF_INET6;
\r
78 memcpy(&in6.sin6_addr, addr, sizeof(struct in_addr6));
\r
80 /* if no ipv6 support return simple IPv6 format rule:
\r
81 * A series of "0's in a 16bit block can be represented by "0"
\r
83 if (getnameinfo((struct sockaddr *)&in6, (socklen_t) (sizeof in6),
\r
84 dst, len, NULL, 0, NI_NUMERICHOST))
\r
86 char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
\r
89 if (len < sizeof(tmp))
\r
92 for (i = 0; i < 8; i++)
\r
93 n += sprintf(tmp+n, "%s%x",
\r
95 ntohs(((unsigned short*)addr)[i]));
\r
102 #define inet_ntop _inet_ntop
\r
104 #endif /* _MAD_OSD_H_ */