Lines Matching +full:mutually +full:- +full:exclusive
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
60 TAILQ_INIT(&conf->conf_targets);
70 TAILQ_FOREACH(targ, &conf->conf_targets, t_next) {
71 if (targ->t_nickname != NULL &&
72 strcasecmp(targ->t_nickname, nickname) == 0)
87 targ->t_conf = conf;
88 targ->t_dscp = -1;
89 targ->t_pcp = -1;
90 targ->t_pingtimeout = -1;
91 targ->t_logintimeout = -1;
92 TAILQ_INSERT_TAIL(&conf->conf_targets, targ, t_next);
101 TAILQ_REMOVE(&targ->t_conf->conf_targets, targ, t_next);
119 namelen - strlen(DEFAULT_IQN));
148 TAILQ_FOREACH(targ, &conf->conf_targets, t_next) {
149 assert(targ->t_nickname != NULL);
150 if (targ->t_session_type == SESSION_TYPE_UNSPECIFIED)
151 targ->t_session_type = SESSION_TYPE_NORMAL;
152 if (targ->t_session_type == SESSION_TYPE_NORMAL &&
153 targ->t_name == NULL)
155 targ->t_nickname);
156 if (targ->t_session_type == SESSION_TYPE_DISCOVERY &&
157 targ->t_name != NULL)
159 "sessions for target \"%s\"", targ->t_nickname);
160 if (targ->t_name != NULL) {
161 if (valid_iscsi_name(targ->t_name, xo_warnx) == false)
163 targ->t_name);
165 if (targ->t_protocol == PROTOCOL_UNSPECIFIED)
166 targ->t_protocol = PROTOCOL_ISCSI;
167 if (targ->t_address == NULL)
169 targ->t_nickname);
170 if (targ->t_initiator_name == NULL)
171 targ->t_initiator_name = default_initiator_name();
172 if (valid_iscsi_name(targ->t_initiator_name, xo_warnx) == false)
174 targ->t_initiator_name);
175 if (targ->t_header_digest == DIGEST_UNSPECIFIED)
176 targ->t_header_digest = DIGEST_NONE;
177 if (targ->t_data_digest == DIGEST_UNSPECIFIED)
178 targ->t_data_digest = DIGEST_NONE;
179 if (targ->t_auth_method == AUTH_METHOD_UNSPECIFIED) {
180 if (targ->t_user != NULL || targ->t_secret != NULL ||
181 targ->t_mutual_user != NULL ||
182 targ->t_mutual_secret != NULL)
183 targ->t_auth_method =
186 targ->t_auth_method =
189 if (targ->t_auth_method == AUTH_METHOD_CHAP) {
190 if (targ->t_user == NULL) {
192 targ->t_nickname);
194 if (targ->t_secret == NULL)
196 targ->t_nickname);
197 if (targ->t_mutual_user != NULL ||
198 targ->t_mutual_secret != NULL) {
199 if (targ->t_mutual_user == NULL)
201 "target \"%s\"", targ->t_nickname);
202 if (targ->t_mutual_secret == NULL)
204 "target \"%s\"", targ->t_nickname);
219 if (targ->t_initiator_name != NULL)
220 strlcpy(conf->isc_initiator, targ->t_initiator_name,
221 sizeof(conf->isc_initiator));
222 if (targ->t_initiator_address != NULL)
223 strlcpy(conf->isc_initiator_addr, targ->t_initiator_address,
224 sizeof(conf->isc_initiator_addr));
225 if (targ->t_initiator_alias != NULL)
226 strlcpy(conf->isc_initiator_alias, targ->t_initiator_alias,
227 sizeof(conf->isc_initiator_alias));
228 if (targ->t_name != NULL)
229 strlcpy(conf->isc_target, targ->t_name,
230 sizeof(conf->isc_target));
231 if (targ->t_address != NULL)
232 strlcpy(conf->isc_target_addr, targ->t_address,
233 sizeof(conf->isc_target_addr));
234 if (targ->t_user != NULL)
235 strlcpy(conf->isc_user, targ->t_user,
236 sizeof(conf->isc_user));
237 if (targ->t_secret != NULL)
238 strlcpy(conf->isc_secret, targ->t_secret,
239 sizeof(conf->isc_secret));
240 if (targ->t_mutual_user != NULL)
241 strlcpy(conf->isc_mutual_user, targ->t_mutual_user,
242 sizeof(conf->isc_mutual_user));
243 if (targ->t_mutual_secret != NULL)
244 strlcpy(conf->isc_mutual_secret, targ->t_mutual_secret,
245 sizeof(conf->isc_mutual_secret));
246 if (targ->t_session_type == SESSION_TYPE_DISCOVERY)
247 conf->isc_discovery = 1;
248 if (targ->t_enable != ENABLE_OFF)
249 conf->isc_enable = 1;
250 if (targ->t_protocol == PROTOCOL_ISER)
251 conf->isc_iser = 1;
252 if (targ->t_offload != NULL)
253 strlcpy(conf->isc_offload, targ->t_offload,
254 sizeof(conf->isc_offload));
255 if (targ->t_header_digest == DIGEST_CRC32C)
256 conf->isc_header_digest = ISCSI_DIGEST_CRC32C;
258 conf->isc_header_digest = ISCSI_DIGEST_NONE;
259 if (targ->t_data_digest == DIGEST_CRC32C)
260 conf->isc_data_digest = ISCSI_DIGEST_CRC32C;
262 conf->isc_data_digest = ISCSI_DIGEST_NONE;
263 conf->isc_dscp = targ->t_dscp;
264 conf->isc_pcp = targ->t_pcp;
265 conf->isc_ping_timeout = targ->t_pingtimeout;
266 conf->isc_login_timeout = targ->t_logintimeout;
333 if (state->iss_id == session_id)
337 xo_errx(1, "session-id %u not found", session_id);
339 conf = &state->iss_conf;
342 strlcpy(conf->isc_target, target, sizeof(conf->isc_target));
344 strlcpy(conf->isc_target_addr, target_addr,
345 sizeof(conf->isc_target_addr));
347 strlcpy(conf->isc_user, user, sizeof(conf->isc_user));
349 strlcpy(conf->isc_secret, secret, sizeof(conf->isc_secret));
351 conf->isc_enable = 1;
353 conf->isc_enable = 0;
417 conf = &state->iss_conf;
422 * Display-only modifier as this information
425 xo_emit("{L:/%-26s}{V:sessionId/%u}\n",
426 "Session ID:", state->iss_id);
429 xo_emit("{L:/%-26s}{V:name/%s}\n",
430 "Initiator name:", conf->isc_initiator);
431 xo_emit("{L:/%-26s}{V:portal/%s}\n",
432 "Initiator portal:", conf->isc_initiator_addr);
433 xo_emit("{L:/%-26s}{V:alias/%s}\n",
434 "Initiator alias:", conf->isc_initiator_alias);
438 xo_emit("{L:/%-26s}{V:name/%s}\n",
439 "Target name:", conf->isc_target);
440 xo_emit("{L:/%-26s}{V:portal/%s}\n",
441 "Target portal:", conf->isc_target_addr);
442 xo_emit("{L:/%-26s}{V:alias/%s}\n",
443 "Target alias:", state->iss_target_alias);
444 if (conf->isc_dscp != -1)
445 xo_emit("{L:/%-26s}{V:dscp/0x%02x}\n",
446 "Target DSCP:", conf->isc_dscp);
447 if (conf->isc_pcp != -1)
448 xo_emit("{L:/%-26s}{V:pcp/0x%02x}\n",
449 "Target PCP:", conf->isc_pcp);
450 if (conf->isc_ping_timeout != -1)
451 xo_emit("{L:/%-26s}{V:PingTimeout/%d}\n",
453 conf->isc_ping_timeout);
454 if (conf->isc_login_timeout != -1)
455 xo_emit("{L:/%-26s}{V:LoginTimeout/%d}\n",
457 conf->isc_login_timeout);
461 xo_emit("{L:/%-26s}{V:user/%s}\n",
462 "User:", conf->isc_user);
463 xo_emit("{L:/%-26s}{V:secret/%s}\n",
464 "Secret:", conf->isc_secret);
465 xo_emit("{L:/%-26s}{V:mutualUser/%s}\n",
466 "Mutual user:", conf->isc_mutual_user);
467 xo_emit("{L:/%-26s}{V:mutualSecret/%s}\n",
468 "Mutual secret:", conf->isc_mutual_secret);
471 xo_emit("{L:/%-26s}{V:type/%s}\n",
473 conf->isc_discovery ? "Discovery" : "Normal");
474 xo_emit("{L:/%-26s}{V:enable/%s}\n",
476 conf->isc_enable ? "Yes" : "No");
477 xo_emit("{L:/%-26s}{V:state/%s}\n",
479 state->iss_connected ? "Connected" : "Disconnected");
480 xo_emit("{L:/%-26s}{V:failureReason/%s}\n",
481 "Failure reason:", state->iss_reason);
482 xo_emit("{L:/%-26s}{V:headerDigest/%s}\n",
484 state->iss_header_digest == ISCSI_DIGEST_CRC32C ?
486 xo_emit("{L:/%-26s}{V:dataDigest/%s}\n",
488 state->iss_data_digest == ISCSI_DIGEST_CRC32C ?
490 xo_emit("{L:/%-26s}{V:recvDataSegmentLen/%d}\n",
492 state->iss_max_recv_data_segment_length);
493 xo_emit("{L:/%-26s}{V:sendDataSegmentLen/%d}\n",
495 state->iss_max_send_data_segment_length);
496 xo_emit("{L:/%-26s}{V:maxBurstLen/%d}\n",
497 "MaxBurstLen:", state->iss_max_burst_length);
498 xo_emit("{L:/%-26s}{V:firstBurstLen/%d}\n",
499 "FirstBurstLen:", state->iss_first_burst_length);
500 xo_emit("{L:/%-26s}{V:immediateData/%s}\n",
501 "ImmediateData:", state->iss_immediate_data ? "Yes" : "No");
502 xo_emit("{L:/%-26s}{V:iSER/%s}\n",
503 "iSER (RDMA):", conf->isc_iser ? "Yes" : "No");
504 xo_emit("{L:/%-26s}{V:offloadDriver/%s}\n",
505 "Offload driver:", state->iss_offload);
506 xo_emit("{L:/%-26s}",
508 print_periphs(state->iss_id);
514 xo_emit("{T:/%-36s} {T:/%-16s} {T:/%s}\n",
522 conf = &state->iss_conf;
525 xo_emit("{V:name/%-36s/%s} {V:portal/%-16s/%s} ",
526 conf->isc_target, conf->isc_target_addr);
528 if (state->iss_reason[0] != '\0' &&
529 conf->isc_enable != 0) {
530 xo_emit("{V:state/%s}\n", state->iss_reason);
532 if (conf->isc_discovery) {
534 } else if (conf->isc_enable == 0) {
536 } else if (state->iss_connected) {
538 print_periphs(state->iss_id);
590 if (!state->iss_connected) {
602 timeout--;
613 xo_error("usage: iscsictl -A -p portal -t target "
614 "[-u user -s secret] [-w timeout] [-e on | off]\n");
615 xo_error(" iscsictl -A -d discovery-host "
616 "[-u user -s secret] [-e on | off]\n");
617 xo_error(" iscsictl -A -a [-c path]\n");
618 xo_error(" iscsictl -A -n nickname [-c path]\n");
619 xo_error(" iscsictl -M -i session-id [-p portal] "
620 "[-t target] [-u user] [-s secret] [-e on | off]\n");
621 xo_error(" iscsictl -M -i session-id -n nickname "
622 "[-c path]\n");
623 xo_error(" iscsictl -R [-p portal] [-t target]\n");
624 xo_error(" iscsictl -R -a\n");
625 xo_error(" iscsictl -R -n nickname [-c path]\n");
626 xo_error(" iscsictl -L [-v] [-w timeout]\n");
638 int timeout = -1, enable = ENABLE_UNSPECIFIED;
639 long long session_id = -1;
653 while ((ch = getopt(argc, argv, "AMRLac:d:e:i:n:p:rt:u:s:vw:")) != -1) {
679 xo_errx(1, "invalid argument to -e, "
685 if ((size_t)(end - optarg) != strlen(optarg))
686 xo_errx(1, "trailing characters after session-id");
688 xo_errx(1, "session-id cannot be negative");
690 xo_errx(1, "session-id cannot be greater than %u",
716 if ((size_t)(end - optarg) != strlen(optarg))
726 argc -= optind;
733 xo_errx(1, "at most one of -A, -M, -R, or -L may be specified");
736 * Note that we ignore unnecessary/inapplicable "-c" flag; so that
737 * people can do something like "alias ISCSICTL="iscsictl -c path"
743 xo_errx(1, "-a and -e are mutually exclusive");
745 xo_errx(1, "-a and -p are mutually exclusive");
747 xo_errx(1, "-a and -t are mutually exclusive");
749 xo_errx(1, "-a and -u are mutually exclusive");
751 xo_errx(1, "-a and -s are mutually exclusive");
753 xo_errx(1, "-a and -n are mutually exclusive");
755 xo_errx(1, "-a and -d are mutually exclusive");
757 xo_errx(1, "-a and -r are mutually exclusive");
760 xo_errx(1, "-n and -e are mutually exclusive");
762 xo_errx(1, "-n and -p are mutually exclusive");
764 xo_errx(1, "-n and -t are mutually exclusive");
766 xo_errx(1, "-n and -u are mutually exclusive");
768 xo_errx(1, "-n and -s are mutually exclusive");
770 xo_errx(1, "-n and -d are mutually exclusive");
772 xo_errx(1, "-n and -r are mutually exclusive");
775 xo_errx(1, "-d and -p are mutually exclusive");
777 xo_errx(1, "-d and -t are mutually exclusive");
780 xo_errx(1, "must specify -a, -n or -t/-p");
783 xo_errx(1, "-t must always be used with -p");
785 xo_errx(1, "-p must always be used with -t");
789 xo_errx(1, "-u must always be used with -s");
791 xo_errx(1, "-s must always be used with -u");
793 if (session_id != -1)
794 xo_errx(1, "-i cannot be used with -A");
796 xo_errx(1, "-v cannot be used with -A");
799 if (session_id == -1)
800 xo_errx(1, "-M requires -i");
804 xo_errx(1, "-n and -e are mutually exclusive");
806 xo_errx(1, "-n and -p are mutually exclusive");
808 xo_errx(1, "-n and -t are mutually exclusive");
810 xo_errx(1, "-n and -u are mutually exclusive");
812 xo_errx(1, "-n and -s are mutually exclusive");
816 xo_errx(1, "-a cannot be used with -M");
818 xo_errx(1, "-d cannot be used with -M");
820 xo_errx(1, "-r cannot be used with -M");
822 xo_errx(1, "-v cannot be used with -M");
823 if (timeout != -1)
824 xo_errx(1, "-w cannot be used with -M");
829 xo_errx(1, "-a and -p are mutually exclusive");
831 xo_errx(1, "-a and -t are mutually exclusive");
833 xo_errx(1, "-a and -n are mutually exclusive");
836 xo_errx(1, "-n and -p are mutually exclusive");
838 xo_errx(1, "-n and -t are mutually exclusive");
840 xo_errx(1, "must specify either -a, -n, -t, or -p");
844 xo_errx(1, "-d cannot be used with -R");
846 xo_errx(1, "-e cannot be used with -R");
847 if (session_id != -1)
848 xo_errx(1, "-i cannot be used with -R");
850 xo_errx(1, "-r cannot be used with -R");
852 xo_errx(1, "-u cannot be used with -R");
854 xo_errx(1, "-s cannot be used with -R");
856 xo_errx(1, "-v cannot be used with -R");
857 if (timeout != -1)
858 xo_errx(1, "-w cannot be used with -R");
864 xo_errx(1, "-d cannot be used with -L");
865 if (session_id != -1)
866 xo_errx(1, "-i cannot be used with -L");
868 xo_errx(1, "-n cannot be used with -L");
870 xo_errx(1, "-p cannot be used with -L");
872 xo_errx(1, "-r cannot be used with -L");
874 xo_errx(1, "-t cannot be used with -L");
876 xo_errx(1, "-u cannot be used with -L");
878 xo_errx(1, "-s cannot be used with -L");
885 if (retval != -1)
896 TAILQ_FOREACH(targ, &conf->conf_targets, t_next)
923 targ->t_initiator_name = default_initiator_name();
924 targ->t_header_digest = DIGEST_NONE;
925 targ->t_data_digest = DIGEST_NONE;
926 targ->t_name = target;
928 targ->t_session_type = SESSION_TYPE_DISCOVERY;
929 targ->t_address = discovery_host;
931 targ->t_session_type = SESSION_TYPE_NORMAL;
932 targ->t_address = portal;
934 targ->t_enable = enable;
936 targ->t_protocol = PROTOCOL_ISER;
937 targ->t_user = user;
938 targ->t_secret = secret;
948 if (timeout != -1)