mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-27 11:52:03 +00:00
parent
3dade5fe59
commit
1c99633848
1 changed files with 7 additions and 5 deletions
|
@ -60,7 +60,7 @@ p9dialparse(char *addr, char **pnet, char **punix, void *phost, int *pport)
|
||||||
|
|
||||||
ss = phost;
|
ss = phost;
|
||||||
|
|
||||||
memset(ss, 0, sizeof(ss));
|
memset(ss, 0, sizeof *ss);
|
||||||
|
|
||||||
*punix = nil;
|
*punix = nil;
|
||||||
net = addr;
|
net = addr;
|
||||||
|
@ -108,14 +108,17 @@ p9dialparse(char *addr, char **pnet, char **punix, void *phost, int *pport)
|
||||||
/* translate host */
|
/* translate host */
|
||||||
if(strcmp(host, "*") == 0){
|
if(strcmp(host, "*") == 0){
|
||||||
ss->ss_family = AF_INET6;
|
ss->ss_family = AF_INET6;
|
||||||
|
ss->ss_len = sizeof(struct sockaddr_in6);
|
||||||
((struct sockaddr_in6*)ss)->sin6_addr = in6addr_any;
|
((struct sockaddr_in6*)ss)->sin6_addr = in6addr_any;
|
||||||
}else if((he = gethostbyname(host)) != nil){
|
}else if((he = gethostbyname(host)) != nil){
|
||||||
ss->ss_family = he->h_addrtype;
|
ss->ss_family = he->h_addrtype;
|
||||||
switch(ss->ss_family){
|
switch(ss->ss_family){
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
|
ss->ss_len = sizeof(struct sockaddr_in);
|
||||||
((struct sockaddr_in*)ss)->sin_addr = *(struct in_addr*) *(he->h_addr_list);
|
((struct sockaddr_in*)ss)->sin_addr = *(struct in_addr*) *(he->h_addr_list);
|
||||||
break;
|
break;
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
|
ss->ss_len = sizeof(struct sockaddr_in6);
|
||||||
((struct sockaddr_in6*)ss)->sin6_addr = *(struct in6_addr*) *(he->h_addr_list);
|
((struct sockaddr_in6*)ss)->sin6_addr = *(struct in6_addr*) *(he->h_addr_list);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -123,13 +126,12 @@ p9dialparse(char *addr, char **pnet, char **punix, void *phost, int *pport)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}else if(getaddrinfo(host, NULL, NULL, &result) == 0) {
|
}else if(getaddrinfo(host, NULL, NULL, &result) == 0) {
|
||||||
ss->ss_family = result->ai_family;
|
switch (result->ai_family) {
|
||||||
switch (ss->ss_family) {
|
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
memcpy((struct sockaddr_in*)ss, result->ai_addr, result->ai_addrlen);
|
memmove((struct sockaddr_in*)ss, result->ai_addr, result->ai_addrlen);
|
||||||
break;
|
break;
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
memcpy((struct sockaddr_in6*)ss, result->ai_addr, result->ai_addrlen);
|
memmove((struct sockaddr_in6*)ss, result->ai_addr, result->ai_addrlen);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
errstr("unknown protocol family %d", ss->ss_family);
|
errstr("unknown protocol family %d", ss->ss_family);
|
||||||
|
|
Loading…
Reference in a new issue