xref: /freebsd/usr.bin/iscsictl/iscsictl.h (revision 31ac8806885f22d6b3a3948a8f660ba0cf24e9cf)
1009ea47eSEdward Tomasz Napierala /*-
24d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
31de7b4b8SPedro F. Giffuni  *
4009ea47eSEdward Tomasz Napierala  * Copyright (c) 2012 The FreeBSD Foundation
5009ea47eSEdward Tomasz Napierala  *
6009ea47eSEdward Tomasz Napierala  * This software was developed by Edward Tomasz Napierala under sponsorship
7009ea47eSEdward Tomasz Napierala  * from the FreeBSD Foundation.
8009ea47eSEdward Tomasz Napierala  *
9009ea47eSEdward Tomasz Napierala  * Redistribution and use in source and binary forms, with or without
10009ea47eSEdward Tomasz Napierala  * modification, are permitted provided that the following conditions
11009ea47eSEdward Tomasz Napierala  * are met:
12009ea47eSEdward Tomasz Napierala  * 1. Redistributions of source code must retain the above copyright
13009ea47eSEdward Tomasz Napierala  *    notice, this list of conditions and the following disclaimer.
14009ea47eSEdward Tomasz Napierala  * 2. Redistributions in binary form must reproduce the above copyright
15009ea47eSEdward Tomasz Napierala  *    notice, this list of conditions and the following disclaimer in the
16009ea47eSEdward Tomasz Napierala  *    documentation and/or other materials provided with the distribution.
17009ea47eSEdward Tomasz Napierala  *
18009ea47eSEdward Tomasz Napierala  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19009ea47eSEdward Tomasz Napierala  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20009ea47eSEdward Tomasz Napierala  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21009ea47eSEdward Tomasz Napierala  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22009ea47eSEdward Tomasz Napierala  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23009ea47eSEdward Tomasz Napierala  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24009ea47eSEdward Tomasz Napierala  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25009ea47eSEdward Tomasz Napierala  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26009ea47eSEdward Tomasz Napierala  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27009ea47eSEdward Tomasz Napierala  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28009ea47eSEdward Tomasz Napierala  * SUCH DAMAGE.
29009ea47eSEdward Tomasz Napierala  */
30009ea47eSEdward Tomasz Napierala 
31009ea47eSEdward Tomasz Napierala #ifndef ISCSICTL_H
32009ea47eSEdward Tomasz Napierala #define	ISCSICTL_H
33009ea47eSEdward Tomasz Napierala 
34009ea47eSEdward Tomasz Napierala #include <sys/queue.h>
35009ea47eSEdward Tomasz Napierala #include <stdbool.h>
36009ea47eSEdward Tomasz Napierala #include <libutil.h>
37009ea47eSEdward Tomasz Napierala 
38009ea47eSEdward Tomasz Napierala #define	DEFAULT_CONFIG_PATH		"/etc/iscsi.conf"
39009ea47eSEdward Tomasz Napierala #define	DEFAULT_IQN			"iqn.1994-09.org.freebsd:"
40009ea47eSEdward Tomasz Napierala 
41*31ac8806SBram #define	ISCSICTL_XO_VERSION		"1"
42*31ac8806SBram 
43009ea47eSEdward Tomasz Napierala #define	MAX_NAME_LEN			223
44009ea47eSEdward Tomasz Napierala 
45009ea47eSEdward Tomasz Napierala #define	AUTH_METHOD_UNSPECIFIED		0
46009ea47eSEdward Tomasz Napierala #define	AUTH_METHOD_NONE		1
47009ea47eSEdward Tomasz Napierala #define	AUTH_METHOD_CHAP		2
48009ea47eSEdward Tomasz Napierala 
49009ea47eSEdward Tomasz Napierala #define	DIGEST_UNSPECIFIED		0
50009ea47eSEdward Tomasz Napierala #define	DIGEST_NONE			1
51009ea47eSEdward Tomasz Napierala #define	DIGEST_CRC32C			2
52009ea47eSEdward Tomasz Napierala 
53009ea47eSEdward Tomasz Napierala #define	SESSION_TYPE_UNSPECIFIED	0
54009ea47eSEdward Tomasz Napierala #define	SESSION_TYPE_NORMAL		1
55009ea47eSEdward Tomasz Napierala #define	SESSION_TYPE_DISCOVERY		2
56009ea47eSEdward Tomasz Napierala 
57009ea47eSEdward Tomasz Napierala #define	PROTOCOL_UNSPECIFIED		0
58009ea47eSEdward Tomasz Napierala #define	PROTOCOL_ISCSI			1
59009ea47eSEdward Tomasz Napierala #define	PROTOCOL_ISER			2
60009ea47eSEdward Tomasz Napierala 
61ba165a31SEdward Tomasz Napierala #define	ENABLE_UNSPECIFIED		0
62ba165a31SEdward Tomasz Napierala #define	ENABLE_ON			1
63ba165a31SEdward Tomasz Napierala #define	ENABLE_OFF			2
64ba165a31SEdward Tomasz Napierala 
65009ea47eSEdward Tomasz Napierala struct target {
66009ea47eSEdward Tomasz Napierala 	TAILQ_ENTRY(target)	t_next;
67009ea47eSEdward Tomasz Napierala 	struct conf		*t_conf;
68009ea47eSEdward Tomasz Napierala 	char			*t_nickname;
69009ea47eSEdward Tomasz Napierala 	char			*t_name;
70009ea47eSEdward Tomasz Napierala 	char			*t_address;
71009ea47eSEdward Tomasz Napierala 	char			*t_initiator_name;
72009ea47eSEdward Tomasz Napierala 	char			*t_initiator_address;
73009ea47eSEdward Tomasz Napierala 	char			*t_initiator_alias;
74009ea47eSEdward Tomasz Napierala 	int			t_header_digest;
75009ea47eSEdward Tomasz Napierala 	int			t_data_digest;
76009ea47eSEdward Tomasz Napierala 	int			t_auth_method;
77009ea47eSEdward Tomasz Napierala 	int			t_session_type;
78ba165a31SEdward Tomasz Napierala 	int			t_enable;
79009ea47eSEdward Tomasz Napierala 	int			t_protocol;
80bfabdadeSRichard Scheffenegger 	int			t_dscp;
814dfbcffbSRichard Scheffenegger 	int			t_pcp;
82bd6bb493SRichard Scheffenegger 	int			t_pingtimeout;
83bd6bb493SRichard Scheffenegger 	int			t_logintimeout;
8482babffbSEdward Tomasz Napierala 	char			*t_offload;
85009ea47eSEdward Tomasz Napierala 	char			*t_user;
86009ea47eSEdward Tomasz Napierala 	char			*t_secret;
87009ea47eSEdward Tomasz Napierala 	char			*t_mutual_user;
88009ea47eSEdward Tomasz Napierala 	char			*t_mutual_secret;
89009ea47eSEdward Tomasz Napierala };
90009ea47eSEdward Tomasz Napierala 
91009ea47eSEdward Tomasz Napierala struct conf {
92009ea47eSEdward Tomasz Napierala 	TAILQ_HEAD(, target)	conf_targets;
93009ea47eSEdward Tomasz Napierala };
94009ea47eSEdward Tomasz Napierala 
95009ea47eSEdward Tomasz Napierala struct conf	*conf_new(void);
96009ea47eSEdward Tomasz Napierala struct conf	*conf_new_from_file(const char *path);
97009ea47eSEdward Tomasz Napierala void		conf_delete(struct conf *conf);
98009ea47eSEdward Tomasz Napierala void		conf_verify(struct conf *conf);
99009ea47eSEdward Tomasz Napierala 
100009ea47eSEdward Tomasz Napierala struct target	*target_new(struct conf *conf);
101009ea47eSEdward Tomasz Napierala struct target	*target_find(struct conf *conf, const char *nickname);
102009ea47eSEdward Tomasz Napierala void		target_delete(struct target *ic);
103009ea47eSEdward Tomasz Napierala 
104009ea47eSEdward Tomasz Napierala void		print_periphs(int session_id);
105009ea47eSEdward Tomasz Napierala 
106009ea47eSEdward Tomasz Napierala bool		valid_iscsi_name(const char *name);
107ba165a31SEdward Tomasz Napierala int		parse_enable(const char *enable);
108009ea47eSEdward Tomasz Napierala 
109009ea47eSEdward Tomasz Napierala #endif /* !ISCSICTL_H */
110