#include "librpc/gen_ndr/ndr_security.h"
#include "librpc/gen_ndr/ndr_ioctl.h"
#include "../libcli/smb/smbXcli_base.h"
-
-#define DNAME "test_dir"
-#define FNAME DNAME "\\test_create.dat"
+#include "lib/cmdline/popt_common.h"
+#include "auth/credentials/credentials.h"
+#include "system/network.h"
+#include "lib/util/util_net.h"
#define CHECK_STATUS(status, correct) do { \
if (!NT_STATUS_EQUAL(status, correct)) { \
return false; \
}} while (0)
-static bool test_session_bind(struct torture_context *tctx,
- struct smb2_tree *tree)
+static bool retrieve_ipv4_address_from_net_interface_info(struct torture_context *tctx,
+ struct fsctl_net_iface_info *info,
+ const char **ipv4)
{
- //NTSTATUS status;
+ if (info->sockaddr.family != FSCTL_NET_IFACE_AF_INET) {
+ return false;
+ }
+
+ *ipv4 = talloc_strdup(tctx, info->sockaddr.saddr.saddr_in.ipv4);
+
+ return true;
+}
+
+static bool retrieve_ipv6_address_from_net_interface_info(struct torture_context *tctx,
+ struct fsctl_net_iface_info *info,
+ const char **ipv6)
+{
+ if (info->sockaddr.family != FSCTL_NET_IFACE_AF_INET6) {
+ return false;
+ }
+
+ *ipv6 = talloc_strdup(tctx, info->sockaddr.saddr.saddr_in6.ipv6);
return true;
}
return true;
}
+static bool test_session_bind_multiple_nics(struct torture_context *tctx,
+ struct smb2_tree *tree)
+{
+ const char *host = torture_setting_string(tctx, "host", NULL);
+ const char *share = torture_setting_string(tctx, "share", NULL);
+ struct smb2_transport *transport1 = tree->session->transport;
+ struct cli_credentials *credentials = cmdline_credentials;
+ struct smb2_tree *tree2 = NULL;
+ NTSTATUS status;
+ uint32_t caps;
+ struct fsctl_net_iface_info info;
+ struct sockaddr_storage *remote_ss;
+ char addr[INET6_ADDRSTRLEN];
+ const char *addr2;
+
+ caps = smb2cli_conn_server_capabilities(transport1->conn);
+ if (!(caps & SMB2_CAP_MULTI_CHANNEL)) {
+ torture_skip(tctx, "server doesn't support SMB2_CAP_MULTI_CHANNEL\n");
+ }
+
+ torture_assert(tctx,
+ test_ioctl_network_interface_info(tctx, tree, &info),
+ "failed to retrieve network interface info");
+
+ remote_ss = smbXcli_conn_remote_sockaddr(transport1->conn);
+
+ print_sockaddr(addr, sizeof(addr), remote_ss);
+
+ torture_assert(tctx,
+ retrieve_ipv4_address_from_net_interface_info(tctx, &info, &addr2),
+ "failed to retrieve ipv4 address");
+
+ torture_comment(tctx, "interface 1: %s\n", addr2);
+
+ if (strequal(addr, addr2)) {
+ torture_assert(tctx,
+ retrieve_ipv4_address_from_net_interface_info(tctx, info.next, &addr2),
+ "failed to retrieve ipv4 address");
+ torture_comment(tctx, "interface 2: %s\n", addr2);
+ }
+
+ if (strequal(addr, addr2)) {
+ torture_fail(tctx, talloc_asprintf(tctx, "cannot proceed as %s and %s are equal",
+ addr, addr2));
+ }
+
+ torture_comment(tctx,
+ "currently connected to %s\n", addr);
+
+ torture_comment(tctx,
+ "adding another interface %s\n", addr2);
+#if 0
+ compare transport1->conn->remote_ss (struct sockaddr_storage)
+ info.sockaddr.
+ struct fsctl_sockaddr_storage sockaddr;
+
+ /* check if interface info has another interface */
+
+ status = smb2_connect(tctx,
+ host,
+ lpcfg_smb_ports(tctx->lp_ctx),
+ share,
+ lpcfg_resolve_context(tctx->lp_ctx),
+ credentials,
+ &tree2,
+ tctx->ev,
+ &transport1->options,
+ lpcfg_socket_options(tctx->lp_ctx),
+ lpcfg_gensec_settings(tctx, tctx->lp_ctx)
+ );
+ torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+ "smb2_connect failed");
+
+
+ XXX
+
+#endif
+ return true;
+}
+
static bool test_multichannel_interface_info(struct torture_context *tctx,
struct smb2_tree *tree)
{
{
struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "multichannel");
- torture_suite_add_1smb2_test(suite, "session-bind", test_session_bind);
+ torture_suite_add_1smb2_test(suite, "session_bind_multipile_nics", test_session_bind_multiple_nics);
torture_suite_add_1smb2_test(suite, "interface_info", test_multichannel_interface_info);
suite->description = talloc_strdup(suite, "SMB2 Multichannel tests");