Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin Start to move the in-kernel iSCSI initiator, kindly con...
details: https://anonhg.NetBSD.org/src/rev/317efd74169b
branches: trunk
changeset: 770570:317efd74169b
user: agc <agc%NetBSD.org@localhost>
date: Sun Oct 23 21:11:23 2011 +0000
description:
Start to move the in-kernel iSCSI initiator, kindly contributed to the
NetBSD Foundation by Wasabi Systems, from
othersrc/external/bsd/iscsi/{iscsictl,iscsid}
to
src/sbin/{iscsictl,iscsid}
diffstat:
sbin/iscsictl/Makefile | 20 +
sbin/iscsictl/iscsic_daemonif.c | 1191 +++++++++++++++++++++++++++++++++++++++
sbin/iscsictl/iscsic_driverif.c | 621 ++++++++++++++++++++
sbin/iscsictl/iscsic_globals.h | 229 +++++++
sbin/iscsictl/iscsic_main.c | 603 +++++++++++++++++++
sbin/iscsictl/iscsic_parse.c | 920 ++++++++++++++++++++++++++++++
sbin/iscsictl/iscsic_test.c | 1145 +++++++++++++++++++++++++++++++++++++
sbin/iscsictl/iscsictl.8 | 221 +++++++
sbin/iscsid/Makefile | 25 +
sbin/iscsid/iscsid.8 | 84 ++
sbin/iscsid/iscsid.h | 913 +++++++++++++++++++++++++++++
sbin/iscsid/iscsid_discover.c | 922 ++++++++++++++++++++++++++++++
sbin/iscsid/iscsid_driverif.c | 992 ++++++++++++++++++++++++++++++++
sbin/iscsid/iscsid_globals.h | 524 +++++++++++++++++
sbin/iscsid/iscsid_lists.c | 943 ++++++++++++++++++++++++++++++
sbin/iscsid/iscsid_main.c | 633 ++++++++++++++++++++
sbin/iscsid/iscsid_targets.c | 1027 +++++++++++++++++++++++++++++++++
17 files changed, 11013 insertions(+), 0 deletions(-)
diffs (truncated from 11081 to 300 lines):
diff -r d3852715d556 -r 317efd74169b sbin/iscsictl/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/iscsictl/Makefile Sun Oct 23 21:11:23 2011 +0000
@@ -0,0 +1,20 @@
+# $wasabi: Makefile,v 1.2 2006/05/03 22:45:02 wrstuden Exp $
+
+PROG= iscsictl
+BINDIR= /sbin
+
+SRCS= iscsic_main.c iscsic_driverif.c iscsic_daemonif.c iscsic_parse.c \
+ iscsic_test.c
+
+CPPFLAGS+= -I${DESTDIR}/usr/include/dev/iscsi
+
+CPPFLAGS+= -I${.CURDIR}/../../sys/dev/iscsi
+CPPFLAGS+= -I${.CURDIR}/../../sys
+CPPFLAGS+= -I${.CURDIR}/../iscsid
+WARNS= 4
+
+MAN= iscsictl.8
+
+# CPPFLAGS+= -DISCSI_TEST_MODE -DISCSI_DEBUG
+
+.include <bsd.prog.mk>
diff -r d3852715d556 -r 317efd74169b sbin/iscsictl/iscsic_daemonif.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/iscsictl/iscsic_daemonif.c Sun Oct 23 21:11:23 2011 +0000
@@ -0,0 +1,1191 @@
+/* $NetBSD: iscsic_daemonif.c,v 1.1 2011/10/23 21:11:23 agc Exp $ */
+
+/*-
+ * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "iscsic_globals.h"
+
+/*
+ * do_add_target:
+ * Handle both the add_target and add_send_target commands.
+ *
+ * Parameter:
+ * argc, argv Shifted arguments
+ * kind Which list
+ *
+ * Returns: 0 if OK - else it doesn't return at all.
+ */
+
+STATIC int
+do_add_target(int argc, char **argv, iscsid_list_kind_t kind)
+{
+ iscsid_add_target_req_t *targ;
+ iscsid_set_target_authentication_req_t auth;
+ iscsid_get_set_target_options_t opt;
+ iscsid_response_t *rsp;
+ iscsid_add_target_rsp_t *res;
+ unsigned i;
+ int opts, auths, tlen;
+ uint32_t tid;
+
+ tlen = cl_get_target(&targ, argc, argv, kind != SEND_TARGETS_LIST);
+ if (tlen == 0) {
+ arg_missing("Target");
+ }
+ if (kind == SEND_TARGETS_LIST && !targ->num_portals) {
+ arg_missing("Target Address");
+ }
+ opts = cl_get_target_opts(&opt, argc, argv);
+ auths = cl_get_auth_opts(&auth, argc, argv);
+ cl_get_symname(targ->sym_name, argc, argv);
+ check_extra_args(argc, argv);
+
+ targ->list_kind = kind;
+
+ send_request(ISCSID_ADD_TARGET, tlen, targ);
+ rsp = get_response(FALSE);
+
+ if (rsp->status) {
+ status_error(rsp->status);
+ }
+ res = (iscsid_add_target_rsp_t *) rsp->parameter;
+ tid = res->target_id;
+
+ if (kind == SEND_TARGETS_LIST) {
+ printf("Added Send Target %d\n", res->target_id);
+ } else {
+ printf("Added Target %d", res->target_id);
+ if (res->num_portals) {
+ printf(", Portal ");
+ for (i = 0; i < res->num_portals; i++)
+ printf("%d ", res->portal_id[i]);
+ }
+ printf("\n");
+ }
+
+ free_response(rsp);
+
+ if (opts) {
+ opt.list_kind = kind;
+ opt.target_id.id = tid;
+ send_request(ISCSID_SET_TARGET_OPTIONS, sizeof(opt), &opt);
+ rsp = get_response(FALSE);
+ if (rsp->status) {
+ status_error(rsp->status);
+ }
+ free_response(rsp);
+ }
+
+ if (auths) {
+ auth.list_kind = kind;
+ auth.target_id.id = tid;
+ send_request(ISCSID_SET_TARGET_AUTHENTICATION, sizeof(auth), &auth);
+ rsp = get_response(FALSE);
+ if (rsp->status) {
+ status_error(rsp->status);
+ }
+ free_response(rsp);
+ }
+
+ return 0;
+}
+
+
+/*
+ * do_remove_target:
+ * Handle both the remove_target and remove_send_target commands.
+ *
+ * Parameter:
+ * argc, argv Shifted arguments
+ * kind Which list
+ *
+ * Returns: 0 if OK - else it doesn't return at all.
+ */
+
+STATIC int
+do_remove_target(int argc, char **argv, iscsid_list_kind_t kind)
+{
+ iscsid_list_id_t req;
+ iscsid_search_list_req_t srch;
+ iscsid_response_t *rsp;
+
+ if (!cl_get_id('I', &req.id, argc, argv)) {
+ if (!cl_get_string('n', (char *)srch.strval, argc, argv)) {
+ arg_missing("Target ID or Name");
+ }
+ check_extra_args(argc, argv);
+
+ srch.search_kind = FIND_TARGET_NAME;
+ srch.list_kind = kind;
+
+ send_request(ISCSID_SEARCH_LIST, sizeof(srch), &srch);
+ rsp = get_response(FALSE);
+ if (rsp->status) {
+ status_error_slist(rsp->status);
+ }
+ GET_SYM_ID(req.id.id, rsp->parameter);
+ free_response(rsp);
+ } else {
+ check_extra_args(argc, argv);
+ }
+ req.list_kind = kind;
+ send_request(ISCSID_REMOVE_TARGET, sizeof(req), &req);
+ rsp = get_response(TRUE);
+ if (rsp->status) {
+ status_error(rsp->status);
+ }
+ free_response(rsp);
+ printf("OK\n");
+ return 0;
+}
+
+
+/*
+ * do_refresh:
+ * Handle the refresh_targets and refresh_isns commands.
+ *
+ * Parameter:
+ * argc, argv Shifted arguments
+ * kind Which list
+ *
+ * Returns: 0 if OK - else it doesn't return at all.
+ */
+
+STATIC int
+do_refresh(int argc, char **argv, iscsid_list_kind_t kind)
+{
+ iscsid_sym_id_t id;
+ iscsid_response_t *rsp;
+ iscsid_refresh_req_t req;
+
+ req.kind = kind;
+
+ if (cl_get_id('I', &id, argc, argv)) {
+ check_extra_args(argc, argv);
+
+ if (!id.id) {
+ iscsid_search_list_req_t srch;
+
+ srch.search_kind = FIND_NAME;
+ srch.list_kind = kind;
+ strlcpy((char *)srch.strval, (char *)id.name,
+ sizeof(srch.strval));
+
+ send_request(ISCSID_SEARCH_LIST, sizeof(srch), &srch);
+ rsp = get_response(FALSE);
+ if (rsp->status) {
+ status_error_slist(rsp->status);
+ }
+ GET_SYM_ID(req.id[0], rsp->parameter);
+ free_response(rsp);
+ } else {
+ req.id[0] = id.id;
+ }
+ req.num_ids = 1;
+ } else {
+ req.num_ids = 0;
+ check_extra_args(argc, argv);
+ }
+
+ req.kind = kind;
+ send_request(ISCSID_REFRESH_TARGETS, sizeof(req), &req);
+
+ rsp = get_response(FALSE);
+ if (rsp->status) {
+ status_error(rsp->status);
+ }
+ printf("OK\n");
+ free_response(rsp);
+ return 0;
+}
+
+
+/*
+ * add_target:
+ * Handle the add_target command.
+ *
+ * Parameter: argc, argv (shifted)
+ *
+ * Returns: 0 if OK - else it doesn't return at all.
+ */
+
+int
+add_target(int argc, char **argv)
+{
+ return do_add_target(argc, argv, TARGET_LIST);
+}
+
+
+/*
+ * remove_target:
+ * Handle the remove_target command.
+ *
+ * Parameter: argc, argv (shifted)
+ *
+ * Returns: 0 if OK - else it doesn't return at all.
+ */
+
+int
+remove_target(int argc, char **argv)
+{
+ return do_remove_target(argc, argv, TARGET_LIST);
+}
+
+
+/*
+ * slp_find_targets:
+ * Handle the slp_find_targets command.
+ *
+ * Parameter: argc, argv (shifted)
+ *
+ * Returns: 0 if OK - else it doesn't return at all.
+ *
+ * ToDo: Implement.
+ */
+
+int
+slp_find_targets(int argc, char **argv)
Home |
Main Index |
Thread Index |
Old Index