Skip to content

Commit

Permalink
LibCore: Add declarations for getaddrinfo in sockaddr-win.h
Browse files Browse the repository at this point in the history
  • Loading branch information
stasoid committed Dec 1, 2024
1 parent 83230ba commit 5c39209
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Libraries/LibCore/sockaddr-win.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ typedef unsigned long ULONG;
typedef unsigned short USHORT;
typedef char CHAR;
typedef unsigned char UCHAR;
typedef const CHAR* PCSTR;
typedef USHORT ADDRESS_FAMILY;

#define WINAPI_FAMILY_PARTITION(x) 1
Expand All @@ -25,6 +26,13 @@ typedef USHORT ADDRESS_FAMILY;
#define AF_INET 2
#define AF_INET6 23

enum IPPROTO {
IPPROTO_TCP = 6,
};

#define INET_ADDRSTRLEN 22
#define INET6_ADDRSTRLEN 65

struct in6_addr {
union {
UCHAR Byte[16];
Expand Down Expand Up @@ -64,6 +72,7 @@ struct sockaddr {
ADDRESS_FAMILY sa_family;
CHAR sa_data[14];
};
using SOCKADDR = sockaddr;
using LPSOCKADDR = sockaddr*;

struct addrinfo {
Expand All @@ -76,6 +85,8 @@ struct addrinfo {
sockaddr* ai_addr;
addrinfo* ai_next;
};
using ADDRINFOA = addrinfo;
using PADDRINFOA = addrinfo*;

struct SOCKET_ADDRESS {
sockaddr* lpSockaddr;
Expand Down Expand Up @@ -112,6 +123,9 @@ struct WSAMSG {
};
using LPWSAMSG = WSAMSG*;

extern "C" USHORT __stdcall htons(USHORT hostshort);
extern "C" __stdcall USHORT htons(USHORT hostshort);
extern "C" __stdcall INT getaddrinfo(PCSTR pNodeName, PCSTR pServiceName, const ADDRINFOA* pHints, PADDRINFOA* ppResult);
extern "C" __stdcall void freeaddrinfo(PADDRINFOA pAddrInfo);
extern "C" __stdcall PCSTR inet_ntop(int Family, void const* pAddr, char* pStringBuf, size_t StringBufSize);

#define _WS2DEF_ // don't include ws2def.h

0 comments on commit 5c39209

Please sign in to comment.