nss_wrapper: restructure parts of the testsuite.
[samba.git] / lib / util / util_net.c
index eb5e2255c99df9a41044aef788d043ebe6746c8f..d1dadc24942de8215f21c26a9df115f53ee01232 100644 (file)
@@ -360,7 +360,7 @@ bool same_net(const struct sockaddr *ip1,
  * Are two sockaddr 's the same family and address ? Ignore port etc.
  */
 
-bool addr_equal(const struct sockaddr *ip1,
+bool sockaddr_equal(const struct sockaddr *ip1,
                const struct sockaddr *ip2)
 {
        if (ip1->sa_family != ip2->sa_family) {
@@ -408,3 +408,17 @@ bool is_address_any(const struct sockaddr *psa)
        }
        return false;
 }
+
+void set_sockaddr_port(struct sockaddr *psa, uint16_t port)
+{
+#if defined(HAVE_IPV6)
+       if (psa->sa_family == AF_INET6) {
+               ((struct sockaddr_in6 *)psa)->sin6_port = htons(port);
+       }
+#endif
+       if (psa->sa_family == AF_INET) {
+               ((struct sockaddr_in *)psa)->sin_port = htons(port);
+       }
+}
+
+