ReactOS 0.4.15-dev-7906-g1b85a5f
inet_ntop.c File Reference
#include <stdio.h>
Include dependency graph for inet_ntop.c:

Go to the source code of this file.

Macros

#define IN6ADDRSZ   16
 
#define INT16SZ   2
 
#define SPRINTF(x)   ((size_t)sprintf x)
 

Functions

static const charinet_ntop4 (const u_char *src, char *dst, size_t size)
 
PCSTR WSAAPI inet_ntop (INT Family, PVOID pAddr, PSTR pStringBuf, size_t StringBufSize)
 

Macro Definition Documentation

◆ IN6ADDRSZ

#define IN6ADDRSZ   16

Definition at line 22 of file inet_ntop.c.

◆ INT16SZ

#define INT16SZ   2

Definition at line 26 of file inet_ntop.c.

◆ SPRINTF

#define SPRINTF (   x)    ((size_t)sprintf x)

Definition at line 32 of file inet_ntop.c.

Function Documentation

◆ inet_ntop()

PCSTR WSAAPI inet_ntop ( INT  Family,
PVOID  pAddr,
PSTR  pStringBuf,
size_t  StringBufSize 
)

Definition at line 57 of file inet_ntop.c.

58{
59
60 switch (Family) {
61 case AF_INET:
62 return (inet_ntop4(pAddr, pStringBuf, StringBufSize));
63#ifdef INET6
64 case AF_INET6:
65 return (inet_ntop6(pAddr, pStringBuf, StringBufSize));
66#endif
67 default:
69 return (NULL);
70 }
71 /* NOTREACHED */
72}
#define NULL
Definition: types.h:112
VOID WSAAPI WSASetLastError(IN INT iError)
Definition: dllmain.c:123
#define AF_INET
Definition: tcpip.h:117
PWDF_CHILD_ADDRESS_DESCRIPTION_HEADER pAddr
static int Family
Definition: ping.c:62
#define WSAEAFNOSUPPORT
Definition: winerror.h:1960
static const char * inet_ntop4(const u_char *src, char *dst, size_t size)
Definition: inet_ntop.c:86
#define AF_INET6
Definition: winsock.h:369

◆ inet_ntop4()

static const char * inet_ntop4 ( const u_char src,
char dst,
size_t  size 
)
static

Definition at line 86 of file inet_ntop.c.

87{
88 static const char fmt[] = "%u.%u.%u.%u";
89 char tmp[sizeof "255.255.255.255"];
90
91 if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size) {
93 return (NULL);
94 }
95 strcpy(dst, tmp);
96 return (dst);
97}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
GLsizeiptr size
Definition: glext.h:5919
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
Definition: dsound.c:943
#define WSAEINVAL
Definition: winerror.h:1946
#define SPRINTF(x)
Definition: inet_ntop.c:32

Referenced by inet_ntop().