mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 19:45:23 -04:00
PS2: Use lower level DNS lookup API
This commit is contained in:
parent
56053e919d
commit
82962a98b3
@ -488,36 +488,25 @@ int lwip_send(int s, const void *dataptr, size_t size, int flags);
|
|||||||
int lwip_socket(int domain, int type, int protocol);
|
int lwip_socket(int domain, int type, int protocol);
|
||||||
int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout);
|
int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout);
|
||||||
int lwip_ioctl(int s, long cmd, void *argp);
|
int lwip_ioctl(int s, long cmd, void *argp);
|
||||||
int lwip_getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res);
|
|
||||||
void lwip_freeaddrinfo(struct addrinfo *ai);
|
|
||||||
int ip4addr_aton(const char *cp, ip4_addr_t *addr);
|
int ip4addr_aton(const char *cp, ip4_addr_t *addr);
|
||||||
|
int netconn_gethostbyname(const char *name, ip4_addr_t *addr);
|
||||||
|
|
||||||
static cc_result ParseHost(const char* host, int port, cc_sockaddr* addrs, int* numValidAddrs) {
|
static cc_result ParseHost(const char* host, int port, cc_sockaddr* addrs, int* numValidAddrs) {
|
||||||
char portRaw[32]; cc_string portStr;
|
struct sockaddr_in* addr4 = (struct sockaddr_in*)addrs[0].data;
|
||||||
struct addrinfo hints = { 0 };
|
ip4_addr_t addr;
|
||||||
struct addrinfo* result;
|
|
||||||
struct addrinfo* cur;
|
|
||||||
int res, i = 0;
|
|
||||||
|
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
int res = netconn_gethostbyname(host, &addr);
|
||||||
hints.ai_protocol = IPPROTO_TCP;
|
|
||||||
|
|
||||||
String_InitArray(portStr, portRaw);
|
|
||||||
String_AppendInt(&portStr, port);
|
|
||||||
portRaw[portStr.length] = '\0';
|
|
||||||
|
|
||||||
res = lwip_getaddrinfo(host, portRaw, &hints, &result);
|
|
||||||
if (res == -NO_DATA) return SOCK_ERR_UNKNOWN_HOST;
|
if (res == -NO_DATA) return SOCK_ERR_UNKNOWN_HOST;
|
||||||
if (res) return res;
|
if (res) return res;
|
||||||
|
|
||||||
for (cur = result; cur && i < SOCKET_MAX_ADDRS; cur = cur->ai_next, i++)
|
addr4->sin_addr.s_addr = addr.addr;
|
||||||
{
|
addr4->sin_family = AF_INET;
|
||||||
SocketAddr_Set(&addrs[i], cur->ai_addr, cur->ai_addrlen);
|
addr4->sin_port = htons(port);
|
||||||
}
|
|
||||||
|
|
||||||
lwip_freeaddrinfo(result);
|
addrs[0].size = sizeof(*addr4);
|
||||||
*numValidAddrs = i;
|
*numValidAddrs = 1;
|
||||||
return i == 0 ? ERR_INVALID_ARGUMENT : 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Socket_ParseAddress(const cc_string* address, int port, cc_sockaddr* addrs, int* numValidAddrs) {
|
cc_result Socket_ParseAddress(const cc_string* address, int port, cc_sockaddr* addrs, int* numValidAddrs) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user