iscsictl.h revision 330449
1/*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2012 The FreeBSD Foundation 5 * All rights reserved. 6 * 7 * This software was developed by Edward Tomasz Napierala under sponsorship 8 * from the FreeBSD Foundation. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * $FreeBSD: stable/11/usr.bin/iscsictl/iscsictl.h 330449 2018-03-05 07:26:05Z eadler $ 32 */ 33 34#ifndef ISCSICTL_H 35#define ISCSICTL_H 36 37#include <sys/queue.h> 38#include <stdbool.h> 39#include <libutil.h> 40 41#define DEFAULT_CONFIG_PATH "/etc/iscsi.conf" 42#define DEFAULT_IQN "iqn.1994-09.org.freebsd:" 43 44#define MAX_NAME_LEN 223 45 46#define AUTH_METHOD_UNSPECIFIED 0 47#define AUTH_METHOD_NONE 1 48#define AUTH_METHOD_CHAP 2 49 50#define DIGEST_UNSPECIFIED 0 51#define DIGEST_NONE 1 52#define DIGEST_CRC32C 2 53 54#define SESSION_TYPE_UNSPECIFIED 0 55#define SESSION_TYPE_NORMAL 1 56#define SESSION_TYPE_DISCOVERY 2 57 58#define PROTOCOL_UNSPECIFIED 0 59#define PROTOCOL_ISCSI 1 60#define PROTOCOL_ISER 2 61 62#define ENABLE_UNSPECIFIED 0 63#define ENABLE_ON 1 64#define ENABLE_OFF 2 65 66struct target { 67 TAILQ_ENTRY(target) t_next; 68 struct conf *t_conf; 69 char *t_nickname; 70 char *t_name; 71 char *t_address; 72 char *t_initiator_name; 73 char *t_initiator_address; 74 char *t_initiator_alias; 75 int t_header_digest; 76 int t_data_digest; 77 int t_auth_method; 78 int t_session_type; 79 int t_enable; 80 int t_protocol; 81 char *t_offload; 82 char *t_user; 83 char *t_secret; 84 char *t_mutual_user; 85 char *t_mutual_secret; 86}; 87 88struct conf { 89 TAILQ_HEAD(, target) conf_targets; 90}; 91 92struct conf *conf_new(void); 93struct conf *conf_new_from_file(const char *path); 94void conf_delete(struct conf *conf); 95void conf_verify(struct conf *conf); 96 97struct target *target_new(struct conf *conf); 98struct target *target_find(struct conf *conf, const char *nickname); 99void target_delete(struct target *ic); 100 101void print_periphs(int session_id); 102 103bool valid_iscsi_name(const char *name); 104int parse_enable(const char *enable); 105 106#endif /* !ISCSICTL_H */ 107