1255570Strasz/*- 2330449Seadler * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3330449Seadler * 4255570Strasz * Copyright (c) 2012 The FreeBSD Foundation 5255570Strasz * All rights reserved. 6255570Strasz * 7255570Strasz * This software was developed by Edward Tomasz Napierala under sponsorship 8255570Strasz * from the FreeBSD Foundation. 9255570Strasz * 10255570Strasz * Redistribution and use in source and binary forms, with or without 11255570Strasz * modification, are permitted provided that the following conditions 12255570Strasz * are met: 13255570Strasz * 1. Redistributions of source code must retain the above copyright 14255570Strasz * notice, this list of conditions and the following disclaimer. 15255570Strasz * 2. Redistributions in binary form must reproduce the above copyright 16255570Strasz * notice, this list of conditions and the following disclaimer in the 17255570Strasz * documentation and/or other materials provided with the distribution. 18255570Strasz * 19255570Strasz * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20255570Strasz * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21255570Strasz * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22255570Strasz * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23255570Strasz * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24255570Strasz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25255570Strasz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26255570Strasz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27255570Strasz * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28255570Strasz * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29255570Strasz * SUCH DAMAGE. 30255570Strasz * 31255570Strasz * $FreeBSD: stable/11/usr.bin/iscsictl/iscsictl.h 330449 2018-03-05 07:26:05Z eadler $ 32255570Strasz */ 33255570Strasz 34255570Strasz#ifndef ISCSICTL_H 35255570Strasz#define ISCSICTL_H 36255570Strasz 37255570Strasz#include <sys/queue.h> 38255570Strasz#include <stdbool.h> 39255570Strasz#include <libutil.h> 40255570Strasz 41255570Strasz#define DEFAULT_CONFIG_PATH "/etc/iscsi.conf" 42255570Strasz#define DEFAULT_IQN "iqn.1994-09.org.freebsd:" 43255570Strasz 44255570Strasz#define MAX_NAME_LEN 223 45255570Strasz 46255570Strasz#define AUTH_METHOD_UNSPECIFIED 0 47255570Strasz#define AUTH_METHOD_NONE 1 48255570Strasz#define AUTH_METHOD_CHAP 2 49255570Strasz 50255570Strasz#define DIGEST_UNSPECIFIED 0 51255570Strasz#define DIGEST_NONE 1 52255570Strasz#define DIGEST_CRC32C 2 53255570Strasz 54255570Strasz#define SESSION_TYPE_UNSPECIFIED 0 55255570Strasz#define SESSION_TYPE_NORMAL 1 56255570Strasz#define SESSION_TYPE_DISCOVERY 2 57255570Strasz 58255570Strasz#define PROTOCOL_UNSPECIFIED 0 59255570Strasz#define PROTOCOL_ISCSI 1 60255570Strasz#define PROTOCOL_ISER 2 61255570Strasz 62301033Strasz#define ENABLE_UNSPECIFIED 0 63301033Strasz#define ENABLE_ON 1 64301033Strasz#define ENABLE_OFF 2 65301033Strasz 66255570Straszstruct target { 67255570Strasz TAILQ_ENTRY(target) t_next; 68255570Strasz struct conf *t_conf; 69255570Strasz char *t_nickname; 70255570Strasz char *t_name; 71255570Strasz char *t_address; 72255570Strasz char *t_initiator_name; 73255570Strasz char *t_initiator_address; 74255570Strasz char *t_initiator_alias; 75255570Strasz int t_header_digest; 76255570Strasz int t_data_digest; 77255570Strasz int t_auth_method; 78255570Strasz int t_session_type; 79301033Strasz int t_enable; 80255570Strasz int t_protocol; 81278232Strasz char *t_offload; 82255570Strasz char *t_user; 83255570Strasz char *t_secret; 84255570Strasz char *t_mutual_user; 85255570Strasz char *t_mutual_secret; 86255570Strasz}; 87255570Strasz 88255570Straszstruct conf { 89255570Strasz TAILQ_HEAD(, target) conf_targets; 90255570Strasz}; 91255570Strasz 92255570Straszstruct conf *conf_new(void); 93255570Straszstruct conf *conf_new_from_file(const char *path); 94255570Straszvoid conf_delete(struct conf *conf); 95255570Straszvoid conf_verify(struct conf *conf); 96255570Strasz 97255570Straszstruct target *target_new(struct conf *conf); 98255570Straszstruct target *target_find(struct conf *conf, const char *nickname); 99255570Straszvoid target_delete(struct target *ic); 100255570Strasz 101255570Straszvoid print_periphs(int session_id); 102255570Strasz 103255570Straszbool valid_iscsi_name(const char *name); 104301033Straszint parse_enable(const char *enable); 105255570Strasz 106255570Strasz#endif /* !ISCSICTL_H */ 107