diff --git a/ChangeLog.txt b/ChangeLog.txt index 23cf4f508..3dc15e6b1 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -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 diff --git a/lib/net_mosq.c b/lib/net_mosq.c index daf8ce94b..11d7fad62 100644 --- a/lib/net_mosq.c +++ b/lib/net_mosq.c @@ -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); @@ -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; @@ -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); diff --git a/src/conf.c b/src/conf.c index f3d812dbc..9af80224d 100644 --- a/src/conf.c +++ b/src/conf.c @@ -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; diff --git a/src/net.c b/src/net.c index 2326918be..6093dee92 100644 --- a/src/net.c +++ b/src/net.c @@ -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;