MCPcopy Create free account
hub / github.com/LUX-Core/lux / inet_pton

Function inet_pton

src/cryptopp/socketft.cpp:65–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63// Also see http://stackoverflow.com/a/20816961 and http://github.com/weidai11/cryptopp/issues/322
64#if defined(USE_WINDOWS_STYLE_SOCKETS)
65int inet_pton(int af, const char *src, void *dst)
66{
67#if CRYPTOPP_MSC_VERSION
68# pragma warning(push)
69# pragma warning(disable: 4996)
70#endif
71
72 // Posix states only src is validated. Avoid a bad dst dereference.
73 if(!src || !dst) return 0;
74
75 struct sockaddr_storage ss;
76 ZeroMemory(&ss, sizeof(ss));
77
78#if CRYPTOPP_MSC_VERSION >= 1400
79 char temp[MAX_ADDRSTRLEN];
80 strcpy_s(temp, sizeof(temp), src);
81#else
82 char temp[MAX_ADDRSTRLEN];
83 strncpy(temp, src, sizeof(temp));
84 temp[MAX_ADDRSTRLEN-1] = '\0';
85#endif
86
87
88 int size = sizeof(ss);
89 if (WSAStringToAddress(temp, af, NULL, (struct sockaddr *)&ss, &size) == 0) {
90 switch (af) {
91 case AF_INET:
92 *(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr;
93 return 1;
94 case AF_INET6:
95 *(struct in6_addr *)dst = ((struct sockaddr_in6 *)&ss)->sin6_addr;
96 return 1;
97 }
98 }
99
100 ((sockaddr_in *)dst)->sin_addr.s_addr = INADDR_NONE;
101 return 0;
102
103#if CRYPTOPP_MSC_VERSION
104# pragma warning(pop)
105#endif
106}
107#endif
108
109Socket::Err::Err(socket_t s, const std::string& operation, int error)

Callers 2

BindMethod · 0.85
ConnectMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected