Skip to content

Commit

Permalink
Use AF_UNSPEC etc. instead of PF_UNSPEC to comply with POSIX.
Browse files Browse the repository at this point in the history
Closes #863.

Thanks to denigmus and Patrick TJ McPhee.

Signed-off-by: Roger A. Light <[email protected]>
  • Loading branch information
ralight committed Aug 1, 2018
1 parent 9fd55c0 commit 286400a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Broker:
- Fix plugin cleanup function not being called on exit of the broker.
Closes #900.
- Print more OpenSSL errors when loading certificates/keys fail.
- Use AF_UNSPEC etc. instead of PF_UNSPEC to comply with POSIX. Closes #863.


1.5 - 20180502
Expand Down
10 changes: 5 additions & 5 deletions lib/net_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ int net__try_connect_step2(struct mosquitto *mosq, uint16_t port, mosq_sock_t *s
*sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if(*sock == INVALID_SOCKET) continue;

if(rp->ai_family == PF_INET){
if(rp->ai_family == AF_INET){
((struct sockaddr_in *)rp->ai_addr)->sin_port = htons(port);
}else if(rp->ai_family == PF_INET6){
}else if(rp->ai_family == AF_INET6){
((struct sockaddr_in6 *)rp->ai_addr)->sin6_port = htons(port);
}else{
COMPAT_CLOSE(*sock);
Expand Down Expand Up @@ -310,7 +310,7 @@ int net__try_connect(struct mosquitto *mosq, const char *host, uint16_t port, mo

*sock = INVALID_SOCKET;
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = PF_UNSPEC;
hints.ai_family = AF_UNSPEC;
hints.ai_flags = AI_ADDRCONFIG;
hints.ai_socktype = SOCK_STREAM;

Expand All @@ -333,9 +333,9 @@ int net__try_connect(struct mosquitto *mosq, const char *host, uint16_t port, mo
*sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if(*sock == INVALID_SOCKET) continue;

if(rp->ai_family == PF_INET){
if(rp->ai_family == AF_INET){
((struct sockaddr_in *)rp->ai_addr)->sin_port = htons(port);
}else if(rp->ai_family == PF_INET6){
}else if(rp->ai_family == AF_INET6){
((struct sockaddr_in6 *)rp->ai_addr)->sin6_port = htons(port);
}else{
COMPAT_CLOSE(*sock);
Expand Down
2 changes: 1 addition & 1 deletion src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static int conf__attempt_resolve(const char *host, const char *text, int log, co
int rc;

memset(&gai_hints, 0, sizeof(struct addrinfo));
gai_hints.ai_family = PF_UNSPEC;
gai_hints.ai_family = AF_UNSPEC;
gai_hints.ai_flags = AI_ADDRCONFIG;
gai_hints.ai_socktype = SOCK_STREAM;
gai_res = NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ int net__socket_listen(struct mosquitto__listener *listener)

snprintf(service, 10, "%d", listener->port);
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = PF_UNSPEC;
hints.ai_family = AF_UNSPEC;
hints.ai_flags = AI_PASSIVE;
hints.ai_socktype = SOCK_STREAM;

Expand Down

0 comments on commit 286400a

Please sign in to comment.