-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement inet_ntop to support Windows XP
- Loading branch information
1 parent
931432d
commit 7f06236
Showing
6 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -255,7 +255,7 @@ I: 492 | |
|
||
N: Jeff Tang | ||
W: https://github.com/mrjefftang | ||
I: 340, 529 | ||
I: 340, 529, 616 | ||
|
||
N: Yaolong Huang | ||
E: [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "inet_ntop.h" | ||
|
||
// From: https://memset.wordpress.com/2010/10/09/inet_ntop-for-win32/ | ||
PCSTR | ||
WSAAPI | ||
inet_ntop( | ||
__in INT Family, | ||
__in PVOID pAddr, | ||
__out_ecount(StringBufSize) PSTR pStringBuf, | ||
__in size_t StringBufSize | ||
) | ||
{ | ||
struct sockaddr_in srcaddr; | ||
|
||
memset(&srcaddr, 0, sizeof(struct sockaddr_in)); | ||
memcpy(&(srcaddr.sin_addr), pAddr, sizeof(srcaddr.sin_addr)); | ||
|
||
srcaddr.sin_family = Family; | ||
if (WSAAddressToString((struct sockaddr*) &srcaddr, sizeof(struct sockaddr_in), 0, pStringBuf, (LPDWORD) &StringBufSize) != 0) { | ||
DWORD rv = WSAGetLastError(); | ||
return NULL; | ||
} | ||
return pStringBuf; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <ws2tcpip.h> | ||
|
||
PCSTR | ||
WSAAPI | ||
inet_ntop( | ||
__in INT Family, | ||
__in PVOID pAddr, | ||
__out_ecount(StringBufSize) PSTR pStringBuf, | ||
__in size_t StringBufSize | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters