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