summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Dieter Wallnöfer <mdw@samba.org>2010-04-27 15:27:40 +0200
committerMatthias Dieter Wallnöfer <mdw@samba.org>2010-04-27 18:45:40 +0200
commit7efb43669838245cd240ac2c5aa443ba0d285b9c (patch)
tree9403989bd6406bedba869f2e5b30ef207327cc0e
parent8f8e7c788a12d1e0bda9183ed765cc1048e105f7 (diff)
downloadsamba-7efb43669838245cd240ac2c5aa443ba0d285b9c.tar.gz
samba-7efb43669838245cd240ac2c5aa443ba0d285b9c.tar.bz2
samba-7efb43669838245cd240ac2c5aa443ba0d285b9c.zip
s4:torture - DsRAddressToSitenames[Ex]W testsuite - make it IPv4-only compatible
-rw-r--r--source4/torture/rpc/netlogon.c60
1 files changed, 56 insertions, 4 deletions
diff --git a/source4/torture/rpc/netlogon.c b/source4/torture/rpc/netlogon.c
index d6bc013e8a..ae6a757135 100644
--- a/source4/torture/rpc/netlogon.c
+++ b/source4/torture/rpc/netlogon.c
@@ -2366,7 +2366,9 @@ static bool test_netr_DsRAddressToSitenamesW(struct torture_context *tctx,
struct netr_DsRAddressToSitenamesW r;
struct netr_DsRAddress addrs[6];
struct sockaddr_in *addr;
+#ifdef HAVE_IPV6
struct sockaddr_in6 *addr6;
+#endif
struct netr_DsRAddressToSitenamesWCtr *ctr;
struct dcerpc_binding_handle *b = p->binding_handle;
uint32_t i;
@@ -2406,10 +2408,10 @@ static bool test_netr_DsRAddressToSitenamesW(struct torture_context *tctx,
addrs[2].buffer = talloc_zero_array(tctx, uint8_t, addrs[2].size);
addr = (struct sockaddr_in *) addrs[2].buffer;
addr->sin_family = AF_INET;
- ret = inet_pton(AF_INET, "255.255.255.255",
- &((struct sockaddr_in *)addrs[2].buffer)->sin_addr);
+ ret = inet_pton(AF_INET, "255.255.255.255", &addr->sin_addr);
torture_assert(tctx, ret > 0, "inet_pton failed");
+#ifdef HAVE_IPV6
addrs[3].size = sizeof(struct sockaddr_in6);
addrs[3].buffer = talloc_zero_array(tctx, uint8_t, addrs[3].size);
addr6 = (struct sockaddr_in6 *) addrs[3].buffer;
@@ -2430,6 +2432,30 @@ static bool test_netr_DsRAddressToSitenamesW(struct torture_context *tctx,
addr6->sin6_family = AF_INET6;
ret = inet_pton(AF_INET6, "ff02::1", &addr6->sin6_addr);
torture_assert(tctx, ret > 0, "inet_pton failed");
+#else
+ /* the test cases are repeated to have exactly 6. This is for
+ * compatibility with IPv4-only machines */
+ addrs[3].size = sizeof(struct sockaddr_in);
+ addrs[3].buffer = talloc_zero_array(tctx, uint8_t, addrs[3].size);
+ addr = (struct sockaddr_in *) addrs[3].buffer;
+ addr->sin_family = AF_INET;
+ ret = inet_pton(AF_INET, "127.0.0.1", &addr->sin_addr);
+ torture_assert(tctx, ret > 0, "inet_pton failed");
+
+ addrs[4].size = sizeof(struct sockaddr_in);
+ addrs[4].buffer = talloc_zero_array(tctx, uint8_t, addrs[4].size);
+ addr = (struct sockaddr_in *) addrs[4].buffer;
+ addr->sin_family = AF_INET;
+ ret = inet_pton(AF_INET, "0.0.0.0", &addr->sin_addr);
+ torture_assert(tctx, ret > 0, "inet_pton failed");
+
+ addrs[5].size = sizeof(struct sockaddr_in);
+ addrs[5].buffer = talloc_zero_array(tctx, uint8_t, addrs[5].size);
+ addr = (struct sockaddr_in *) addrs[5].buffer;
+ addr->sin_family = AF_INET;
+ ret = inet_pton(AF_INET, "255.255.255.255", &addr->sin_addr);
+ torture_assert(tctx, ret > 0, "inet_pton failed");
+#endif
ctr = talloc(tctx, struct netr_DsRAddressToSitenamesWCtr);
@@ -2515,7 +2541,9 @@ static bool test_netr_DsRAddressToSitenamesExW(struct torture_context *tctx,
struct netr_DsRAddressToSitenamesExW r;
struct netr_DsRAddress addrs[6];
struct sockaddr_in *addr;
+#ifdef HAVE_IPV6
struct sockaddr_in6 *addr6;
+#endif
struct netr_DsRAddressToSitenamesExWCtr *ctr;
struct dcerpc_binding_handle *b = p->binding_handle;
uint32_t i;
@@ -2555,10 +2583,10 @@ static bool test_netr_DsRAddressToSitenamesExW(struct torture_context *tctx,
addrs[2].buffer = talloc_zero_array(tctx, uint8_t, addrs[2].size);
addr = (struct sockaddr_in *) addrs[2].buffer;
addr->sin_family = AF_INET;
- ret = inet_pton(AF_INET, "255.255.255.255",
- &((struct sockaddr_in *)addrs[2].buffer)->sin_addr);
+ ret = inet_pton(AF_INET, "255.255.255.255", &addr->sin_addr);
torture_assert(tctx, ret > 0, "inet_pton failed");
+#ifdef HAVE_IPV6
addrs[3].size = sizeof(struct sockaddr_in6);
addrs[3].buffer = talloc_zero_array(tctx, uint8_t, addrs[3].size);
addr6 = (struct sockaddr_in6 *) addrs[3].buffer;
@@ -2579,6 +2607,30 @@ static bool test_netr_DsRAddressToSitenamesExW(struct torture_context *tctx,
addr6->sin6_family = AF_INET6;
ret = inet_pton(AF_INET6, "ff02::1", &addr6->sin6_addr);
torture_assert(tctx, ret > 0, "inet_pton failed");
+#else
+ /* the test cases are repeated to have exactly 6. This is for
+ * compatibility with IPv4-only machines */
+ addrs[3].size = sizeof(struct sockaddr_in);
+ addrs[3].buffer = talloc_zero_array(tctx, uint8_t, addrs[3].size);
+ addr = (struct sockaddr_in *) addrs[3].buffer;
+ addr->sin_family = AF_INET;
+ ret = inet_pton(AF_INET, "127.0.0.1", &addr->sin_addr);
+ torture_assert(tctx, ret > 0, "inet_pton failed");
+
+ addrs[4].size = sizeof(struct sockaddr_in);
+ addrs[4].buffer = talloc_zero_array(tctx, uint8_t, addrs[4].size);
+ addr = (struct sockaddr_in *) addrs[4].buffer;
+ addr->sin_family = AF_INET;
+ ret = inet_pton(AF_INET, "0.0.0.0", &addr->sin_addr);
+ torture_assert(tctx, ret > 0, "inet_pton failed");
+
+ addrs[5].size = sizeof(struct sockaddr_in);
+ addrs[5].buffer = talloc_zero_array(tctx, uint8_t, addrs[5].size);
+ addr = (struct sockaddr_in *) addrs[5].buffer;
+ addr->sin_family = AF_INET;
+ ret = inet_pton(AF_INET, "255.255.255.255", &addr->sin_addr);
+ torture_assert(tctx, ret > 0, "inet_pton failed");
+#endif
ctr = talloc(tctx, struct netr_DsRAddressToSitenamesExWCtr);