xref: /freebsd/usr.sbin/ctld/ctld.h (revision d42a73fb6a85b2dd4692cb003065be5c68863860)
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 CTLD_H
32009ea47eSEdward Tomasz Napierala #define	CTLD_H
33009ea47eSEdward Tomasz Napierala 
34703b03a8SJohn Baldwin #include <sys/_nv.h>
35009ea47eSEdward Tomasz Napierala #include <sys/queue.h>
368eab95d6SEdward Tomasz Napierala #ifdef ICL_KERNEL_PROXY
378eab95d6SEdward Tomasz Napierala #include <sys/types.h>
388eab95d6SEdward Tomasz Napierala #endif
39073edb1cSAlexander Motin #include <sys/socket.h>
40009ea47eSEdward Tomasz Napierala #include <stdbool.h>
4163783933SJohn Baldwin #include <libiscsiutil.h>
42009ea47eSEdward Tomasz Napierala #include <libutil.h>
43009ea47eSEdward Tomasz Napierala 
44009ea47eSEdward Tomasz Napierala #define	DEFAULT_CONFIG_PATH		"/etc/ctl.conf"
45009ea47eSEdward Tomasz Napierala #define	DEFAULT_PIDFILE			"/var/run/ctld.pid"
46009ea47eSEdward Tomasz Napierala #define	DEFAULT_BLOCKSIZE		512
476f2f92a5SAlexander Motin #define	DEFAULT_CD_BLOCKSIZE		2048
48009ea47eSEdward Tomasz Napierala 
49920c6cbaSAlexander Motin #define	MAX_LUNS			1024
508b94b583SAlexander Motin #define	SOCKBUF_SIZE			1048576
51009ea47eSEdward Tomasz Napierala 
52009ea47eSEdward Tomasz Napierala struct auth {
53009ea47eSEdward Tomasz Napierala 	TAILQ_ENTRY(auth)		a_next;
54009ea47eSEdward Tomasz Napierala 	struct auth_group		*a_auth_group;
55009ea47eSEdward Tomasz Napierala 	char				*a_user;
56009ea47eSEdward Tomasz Napierala 	char				*a_secret;
57009ea47eSEdward Tomasz Napierala 	char				*a_mutual_user;
58009ea47eSEdward Tomasz Napierala 	char				*a_mutual_secret;
59009ea47eSEdward Tomasz Napierala };
60009ea47eSEdward Tomasz Napierala 
618cb2e958SEdward Tomasz Napierala struct auth_name {
628cb2e958SEdward Tomasz Napierala 	TAILQ_ENTRY(auth_name)		an_next;
638cb2e958SEdward Tomasz Napierala 	struct auth_group		*an_auth_group;
64bdbc2a6fSAlexander Motin 	char				*an_initiator_name;
658cb2e958SEdward Tomasz Napierala };
668cb2e958SEdward Tomasz Napierala 
678cb2e958SEdward Tomasz Napierala struct auth_portal {
688cb2e958SEdward Tomasz Napierala 	TAILQ_ENTRY(auth_portal)	ap_next;
698cb2e958SEdward Tomasz Napierala 	struct auth_group		*ap_auth_group;
70a3434cdcSAlexander Motin 	char				*ap_initiator_portal;
71073edb1cSAlexander Motin 	struct sockaddr_storage		ap_sa;
72073edb1cSAlexander Motin 	int				ap_mask;
738cb2e958SEdward Tomasz Napierala };
748cb2e958SEdward Tomasz Napierala 
75009ea47eSEdward Tomasz Napierala #define	AG_TYPE_UNKNOWN			0
76e76ce448SEdward Tomasz Napierala #define	AG_TYPE_DENY			1
77e76ce448SEdward Tomasz Napierala #define	AG_TYPE_NO_AUTHENTICATION	2
78e76ce448SEdward Tomasz Napierala #define	AG_TYPE_CHAP			3
79e76ce448SEdward Tomasz Napierala #define	AG_TYPE_CHAP_MUTUAL		4
80009ea47eSEdward Tomasz Napierala 
81009ea47eSEdward Tomasz Napierala struct auth_group {
82009ea47eSEdward Tomasz Napierala 	TAILQ_ENTRY(auth_group)		ag_next;
83009ea47eSEdward Tomasz Napierala 	struct conf			*ag_conf;
84009ea47eSEdward Tomasz Napierala 	char				*ag_name;
85009ea47eSEdward Tomasz Napierala 	struct target			*ag_target;
86009ea47eSEdward Tomasz Napierala 	int				ag_type;
87009ea47eSEdward Tomasz Napierala 	TAILQ_HEAD(, auth)		ag_auths;
888cb2e958SEdward Tomasz Napierala 	TAILQ_HEAD(, auth_name)		ag_names;
898cb2e958SEdward Tomasz Napierala 	TAILQ_HEAD(, auth_portal)	ag_portals;
90009ea47eSEdward Tomasz Napierala };
91009ea47eSEdward Tomasz Napierala 
92009ea47eSEdward Tomasz Napierala struct portal {
93009ea47eSEdward Tomasz Napierala 	TAILQ_ENTRY(portal)		p_next;
94009ea47eSEdward Tomasz Napierala 	struct portal_group		*p_portal_group;
95009ea47eSEdward Tomasz Napierala 	bool				p_iser;
96009ea47eSEdward Tomasz Napierala 	char				*p_listen;
97009ea47eSEdward Tomasz Napierala 	struct addrinfo			*p_ai;
988cab2ed4SEdward Tomasz Napierala #ifdef ICL_KERNEL_PROXY
998cab2ed4SEdward Tomasz Napierala 	int				p_id;
1008cab2ed4SEdward Tomasz Napierala #endif
101009ea47eSEdward Tomasz Napierala 
102009ea47eSEdward Tomasz Napierala 	TAILQ_HEAD(, target)		p_targets;
103009ea47eSEdward Tomasz Napierala 	int				p_socket;
104009ea47eSEdward Tomasz Napierala };
105009ea47eSEdward Tomasz Napierala 
10605374883SEdward Tomasz Napierala #define	PG_FILTER_UNKNOWN		0
10705374883SEdward Tomasz Napierala #define	PG_FILTER_NONE			1
10805374883SEdward Tomasz Napierala #define	PG_FILTER_PORTAL		2
10905374883SEdward Tomasz Napierala #define	PG_FILTER_PORTAL_NAME		3
11005374883SEdward Tomasz Napierala #define	PG_FILTER_PORTAL_NAME_AUTH	4
11105374883SEdward Tomasz Napierala 
112009ea47eSEdward Tomasz Napierala struct portal_group {
113009ea47eSEdward Tomasz Napierala 	TAILQ_ENTRY(portal_group)	pg_next;
114009ea47eSEdward Tomasz Napierala 	struct conf			*pg_conf;
115703b03a8SJohn Baldwin 	nvlist_t			*pg_options;
116009ea47eSEdward Tomasz Napierala 	char				*pg_name;
117009ea47eSEdward Tomasz Napierala 	struct auth_group		*pg_discovery_auth_group;
11805374883SEdward Tomasz Napierala 	int				pg_discovery_filter;
119450a84c2SJohn Baldwin 	bool				pg_foreign;
120009ea47eSEdward Tomasz Napierala 	bool				pg_unassigned;
121009ea47eSEdward Tomasz Napierala 	TAILQ_HEAD(, portal)		pg_portals;
12292847ee1SAlexander Motin 	TAILQ_HEAD(, port)		pg_ports;
123a9d78210SEdward Tomasz Napierala 	char				*pg_offload;
1246dbdbf82SEdward Tomasz Napierala 	char				*pg_redirection;
12564ffe6d4SRichard Scheffenegger 	int				pg_dscp;
126ea8f1280SRichard Scheffenegger 	int				pg_pcp;
127009ea47eSEdward Tomasz Napierala 
128009ea47eSEdward Tomasz Napierala 	uint16_t			pg_tag;
129009ea47eSEdward Tomasz Napierala };
130009ea47eSEdward Tomasz Napierala 
131969876fcSAlan Somers /* Ports created by the kernel.  Perhaps the "p" means "physical" ? */
132057abcb0SAlexander Motin struct pport {
133057abcb0SAlexander Motin 	TAILQ_ENTRY(pport)		pp_next;
134057abcb0SAlexander Motin 	TAILQ_HEAD(, port)		pp_ports;
135969876fcSAlan Somers 	struct kports			*pp_kports;
136057abcb0SAlexander Motin 	char				*pp_name;
137057abcb0SAlexander Motin 
138057abcb0SAlexander Motin 	uint32_t			pp_ctl_port;
139057abcb0SAlexander Motin };
140057abcb0SAlexander Motin 
14192847ee1SAlexander Motin struct port {
14292847ee1SAlexander Motin 	TAILQ_ENTRY(port)		p_next;
14392847ee1SAlexander Motin 	TAILQ_ENTRY(port)		p_pgs;
144057abcb0SAlexander Motin 	TAILQ_ENTRY(port)		p_pps;
14592847ee1SAlexander Motin 	TAILQ_ENTRY(port)		p_ts;
14692847ee1SAlexander Motin 	struct conf			*p_conf;
14792847ee1SAlexander Motin 	char				*p_name;
14892847ee1SAlexander Motin 	struct auth_group		*p_auth_group;
14992847ee1SAlexander Motin 	struct portal_group		*p_portal_group;
150057abcb0SAlexander Motin 	struct pport			*p_pport;
15192847ee1SAlexander Motin 	struct target			*p_target;
15292847ee1SAlexander Motin 
153450a84c2SJohn Baldwin 	bool				p_ioctl_port;
1548951f055SMarcelo Araujo 	int				p_ioctl_pp;
1558951f055SMarcelo Araujo 	int				p_ioctl_vp;
15692847ee1SAlexander Motin 	uint32_t			p_ctl_port;
15792847ee1SAlexander Motin };
15892847ee1SAlexander Motin 
159009ea47eSEdward Tomasz Napierala struct lun {
160009ea47eSEdward Tomasz Napierala 	TAILQ_ENTRY(lun)		l_next;
161920c6cbaSAlexander Motin 	struct conf			*l_conf;
162703b03a8SJohn Baldwin 	nvlist_t			*l_options;
163920c6cbaSAlexander Motin 	char				*l_name;
164009ea47eSEdward Tomasz Napierala 	char				*l_backend;
16591be33dcSAlexander Motin 	uint8_t				l_device_type;
166009ea47eSEdward Tomasz Napierala 	int				l_blocksize;
167009ea47eSEdward Tomasz Napierala 	char				*l_device_id;
168009ea47eSEdward Tomasz Napierala 	char				*l_path;
169920c6cbaSAlexander Motin 	char				*l_scsiname;
170009ea47eSEdward Tomasz Napierala 	char				*l_serial;
171*d42a73fbSJohn Baldwin 	uint64_t			l_size;
172009ea47eSEdward Tomasz Napierala 
173009ea47eSEdward Tomasz Napierala 	int				l_ctl_lun;
174009ea47eSEdward Tomasz Napierala };
175009ea47eSEdward Tomasz Napierala 
176009ea47eSEdward Tomasz Napierala struct target {
177009ea47eSEdward Tomasz Napierala 	TAILQ_ENTRY(target)		t_next;
178009ea47eSEdward Tomasz Napierala 	struct conf			*t_conf;
179920c6cbaSAlexander Motin 	struct lun			*t_luns[MAX_LUNS];
180009ea47eSEdward Tomasz Napierala 	struct auth_group		*t_auth_group;
18192847ee1SAlexander Motin 	TAILQ_HEAD(, port)		t_ports;
182f7ae5bf8SEdward Tomasz Napierala 	char				*t_name;
183009ea47eSEdward Tomasz Napierala 	char				*t_alias;
1846dbdbf82SEdward Tomasz Napierala 	char				*t_redirection;
185969876fcSAlan Somers 	/* Name of this target's physical port, if any, i.e. "isp0" */
186969876fcSAlan Somers 	char				*t_pport;
187009ea47eSEdward Tomasz Napierala };
188009ea47eSEdward Tomasz Napierala 
189829603e2SAlexander Motin struct isns {
190829603e2SAlexander Motin 	TAILQ_ENTRY(isns)		i_next;
191829603e2SAlexander Motin 	struct conf			*i_conf;
192829603e2SAlexander Motin 	char				*i_addr;
193829603e2SAlexander Motin 	struct addrinfo			*i_ai;
194829603e2SAlexander Motin };
195829603e2SAlexander Motin 
196009ea47eSEdward Tomasz Napierala struct conf {
197009ea47eSEdward Tomasz Napierala 	char				*conf_pidfile_path;
198920c6cbaSAlexander Motin 	TAILQ_HEAD(, lun)		conf_luns;
199009ea47eSEdward Tomasz Napierala 	TAILQ_HEAD(, target)		conf_targets;
200009ea47eSEdward Tomasz Napierala 	TAILQ_HEAD(, auth_group)	conf_auth_groups;
20192847ee1SAlexander Motin 	TAILQ_HEAD(, port)		conf_ports;
202009ea47eSEdward Tomasz Napierala 	TAILQ_HEAD(, portal_group)	conf_portal_groups;
203829603e2SAlexander Motin 	TAILQ_HEAD(, isns)		conf_isns;
204829603e2SAlexander Motin 	int				conf_isns_period;
205829603e2SAlexander Motin 	int				conf_isns_timeout;
206009ea47eSEdward Tomasz Napierala 	int				conf_debug;
207009ea47eSEdward Tomasz Napierala 	int				conf_timeout;
208009ea47eSEdward Tomasz Napierala 	int				conf_maxproc;
209009ea47eSEdward Tomasz Napierala 
2108cab2ed4SEdward Tomasz Napierala #ifdef ICL_KERNEL_PROXY
2118cab2ed4SEdward Tomasz Napierala 	int				conf_portal_id;
2128cab2ed4SEdward Tomasz Napierala #endif
213009ea47eSEdward Tomasz Napierala 	struct pidfh			*conf_pidfh;
214252d941cSEdward Tomasz Napierala 
215252d941cSEdward Tomasz Napierala 	bool				conf_default_pg_defined;
216252d941cSEdward Tomasz Napierala 	bool				conf_default_ag_defined;
217a113ac05SEdward Tomasz Napierala 	bool				conf_kernel_port_on;
218009ea47eSEdward Tomasz Napierala };
219009ea47eSEdward Tomasz Napierala 
220969876fcSAlan Somers /* Physical ports exposed by the kernel */
221969876fcSAlan Somers struct kports {
222969876fcSAlan Somers 	TAILQ_HEAD(, pport)		pports;
223969876fcSAlan Somers };
224969876fcSAlan Somers 
225009ea47eSEdward Tomasz Napierala #define	CONN_SESSION_TYPE_NONE		0
226009ea47eSEdward Tomasz Napierala #define	CONN_SESSION_TYPE_DISCOVERY	1
227009ea47eSEdward Tomasz Napierala #define	CONN_SESSION_TYPE_NORMAL	2
228009ea47eSEdward Tomasz Napierala 
22963783933SJohn Baldwin struct ctld_connection {
23063783933SJohn Baldwin 	struct connection	conn;
231009ea47eSEdward Tomasz Napierala 	struct portal		*conn_portal;
23292847ee1SAlexander Motin 	struct port		*conn_port;
233009ea47eSEdward Tomasz Napierala 	struct target		*conn_target;
234009ea47eSEdward Tomasz Napierala 	int			conn_session_type;
235009ea47eSEdward Tomasz Napierala 	char			*conn_initiator_name;
236009ea47eSEdward Tomasz Napierala 	char			*conn_initiator_addr;
237009ea47eSEdward Tomasz Napierala 	char			*conn_initiator_alias;
2386d81c129SAlexander Motin 	uint8_t			conn_initiator_isid[6];
239073edb1cSAlexander Motin 	struct sockaddr_storage	conn_initiator_sa;
24059c6e3a5SAlexander Motin 	int			conn_max_recv_data_segment_limit;
24159c6e3a5SAlexander Motin 	int			conn_max_send_data_segment_limit;
24259c6e3a5SAlexander Motin 	int			conn_max_burst_limit;
24359c6e3a5SAlexander Motin 	int			conn_first_burst_limit;
24405374883SEdward Tomasz Napierala 	const char		*conn_user;
24505374883SEdward Tomasz Napierala 	struct chap		*conn_chap;
246009ea47eSEdward Tomasz Napierala };
247009ea47eSEdward Tomasz Napierala 
2489e425a8aSJohn Baldwin extern int ctl_fd;
2499e425a8aSJohn Baldwin 
250*d42a73fbSJohn Baldwin bool			uclparse_conf(const char *path);
2515c734b04SJakub Wojciech Klama 
252009ea47eSEdward Tomasz Napierala struct conf		*conf_new(void);
253969876fcSAlan Somers struct conf		*conf_new_from_kernel(struct kports *kports);
254009ea47eSEdward Tomasz Napierala void			conf_delete(struct conf *conf);
255*d42a73fbSJohn Baldwin void			conf_finish(void);
256*d42a73fbSJohn Baldwin void			conf_start(struct conf *new_conf);
257450a84c2SJohn Baldwin bool			conf_verify(struct conf *conf);
258009ea47eSEdward Tomasz Napierala 
259009ea47eSEdward Tomasz Napierala struct auth_group	*auth_group_new(struct conf *conf, const char *name);
260009ea47eSEdward Tomasz Napierala void			auth_group_delete(struct auth_group *ag);
261d6093026SEdward Tomasz Napierala struct auth_group	*auth_group_find(const struct conf *conf,
262d6093026SEdward Tomasz Napierala 			    const char *name);
263009ea47eSEdward Tomasz Napierala 
264*d42a73fbSJohn Baldwin bool			auth_new_chap(struct auth_group *ag, const char *user,
265*d42a73fbSJohn Baldwin 			    const char *secret);
266*d42a73fbSJohn Baldwin bool			auth_new_chap_mutual(struct auth_group *ag,
267009ea47eSEdward Tomasz Napierala 			    const char *user, const char *secret,
268009ea47eSEdward Tomasz Napierala 			    const char *user2, const char *secret2);
269d6093026SEdward Tomasz Napierala const struct auth	*auth_find(const struct auth_group *ag,
270009ea47eSEdward Tomasz Napierala 			    const char *user);
271009ea47eSEdward Tomasz Napierala 
272*d42a73fbSJohn Baldwin bool			auth_name_new(struct auth_group *ag,
2738cb2e958SEdward Tomasz Napierala 			    const char *initiator_name);
2748cb2e958SEdward Tomasz Napierala bool			auth_name_defined(const struct auth_group *ag);
2758cb2e958SEdward Tomasz Napierala const struct auth_name	*auth_name_find(const struct auth_group *ag,
2768cb2e958SEdward Tomasz Napierala 			    const char *initiator_name);
277450a84c2SJohn Baldwin bool			auth_name_check(const struct auth_group *ag,
278e867e162SEdward Tomasz Napierala 			    const char *initiator_name);
2798cb2e958SEdward Tomasz Napierala 
280*d42a73fbSJohn Baldwin bool				auth_portal_new(struct auth_group *ag,
2818cb2e958SEdward Tomasz Napierala 				    const char *initiator_portal);
2828cb2e958SEdward Tomasz Napierala bool			auth_portal_defined(const struct auth_group *ag);
2838cb2e958SEdward Tomasz Napierala const struct auth_portal	*auth_portal_find(const struct auth_group *ag,
284073edb1cSAlexander Motin 				    const struct sockaddr_storage *sa);
285450a84c2SJohn Baldwin bool				auth_portal_check(const struct auth_group *ag,
286e867e162SEdward Tomasz Napierala 				    const struct sockaddr_storage *sa);
2878cb2e958SEdward Tomasz Napierala 
288009ea47eSEdward Tomasz Napierala struct portal_group	*portal_group_new(struct conf *conf, const char *name);
289009ea47eSEdward Tomasz Napierala void			portal_group_delete(struct portal_group *pg);
290d6093026SEdward Tomasz Napierala struct portal_group	*portal_group_find(const struct conf *conf,
291d6093026SEdward Tomasz Napierala 			    const char *name);
292*d42a73fbSJohn Baldwin bool			portal_group_add_portal(struct portal_group *pg,
293*d42a73fbSJohn Baldwin 			    const char *value, bool iser);
294009ea47eSEdward Tomasz Napierala 
295450a84c2SJohn Baldwin bool			isns_new(struct conf *conf, const char *addr);
296829603e2SAlexander Motin void			isns_delete(struct isns *is);
297829603e2SAlexander Motin void			isns_register(struct isns *isns, struct isns *oldisns);
298829603e2SAlexander Motin void			isns_check(struct isns *isns);
299829603e2SAlexander Motin void			isns_deregister(struct isns *isns);
300829603e2SAlexander Motin 
301969876fcSAlan Somers struct pport		*pport_new(struct kports *kports, const char *name,
302057abcb0SAlexander Motin 			    uint32_t ctl_port);
303969876fcSAlan Somers struct pport		*pport_find(const struct kports *kports,
304969876fcSAlan Somers 			    const char *name);
305969876fcSAlan Somers struct pport		*pport_copy(struct pport *pp, struct kports *kports);
306057abcb0SAlexander Motin void			pport_delete(struct pport *pport);
307057abcb0SAlexander Motin 
30892847ee1SAlexander Motin struct port		*port_new(struct conf *conf, struct target *target,
30992847ee1SAlexander Motin 			    struct portal_group *pg);
310969876fcSAlan Somers struct port		*port_new_ioctl(struct conf *conf,
311969876fcSAlan Somers 			    struct kports *kports, struct target *target,
3128951f055SMarcelo Araujo 			    int pp, int vp);
313057abcb0SAlexander Motin struct port		*port_new_pp(struct conf *conf, struct target *target,
314057abcb0SAlexander Motin 			    struct pport *pp);
31592847ee1SAlexander Motin struct port		*port_find(const struct conf *conf, const char *name);
31692847ee1SAlexander Motin struct port		*port_find_in_pg(const struct portal_group *pg,
31792847ee1SAlexander Motin 			    const char *target);
31892847ee1SAlexander Motin void			port_delete(struct port *port);
319450a84c2SJohn Baldwin bool			port_is_dummy(struct port *port);
32092847ee1SAlexander Motin 
321f7ae5bf8SEdward Tomasz Napierala struct target		*target_new(struct conf *conf, const char *name);
322009ea47eSEdward Tomasz Napierala void			target_delete(struct target *target);
323009ea47eSEdward Tomasz Napierala struct target		*target_find(struct conf *conf,
324f7ae5bf8SEdward Tomasz Napierala 			    const char *name);
325009ea47eSEdward Tomasz Napierala 
326920c6cbaSAlexander Motin struct lun		*lun_new(struct conf *conf, const char *name);
327009ea47eSEdward Tomasz Napierala void			lun_delete(struct lun *lun);
328920c6cbaSAlexander Motin struct lun		*lun_find(const struct conf *conf, const char *name);
329920c6cbaSAlexander Motin void			lun_set_scsiname(struct lun *lun, const char *value);
330009ea47eSEdward Tomasz Napierala 
331703b03a8SJohn Baldwin bool			option_new(nvlist_t *nvl,
332009ea47eSEdward Tomasz Napierala 			    const char *name, const char *value);
333009ea47eSEdward Tomasz Napierala 
334009ea47eSEdward Tomasz Napierala void			kernel_init(void);
335009ea47eSEdward Tomasz Napierala int			kernel_lun_add(struct lun *lun);
336a3977beaSAlexander Motin int			kernel_lun_modify(struct lun *lun);
337009ea47eSEdward Tomasz Napierala int			kernel_lun_remove(struct lun *lun);
33863783933SJohn Baldwin void			kernel_handoff(struct ctld_connection *conn);
33992847ee1SAlexander Motin int			kernel_port_add(struct port *port);
340828524c1SAlexander Motin int			kernel_port_update(struct port *port, struct port *old);
34192847ee1SAlexander Motin int			kernel_port_remove(struct port *port);
342009ea47eSEdward Tomasz Napierala void			kernel_capsicate(void);
343009ea47eSEdward Tomasz Napierala 
3448eab95d6SEdward Tomasz Napierala #ifdef ICL_KERNEL_PROXY
3458cab2ed4SEdward Tomasz Napierala void			kernel_listen(struct addrinfo *ai, bool iser,
3468cab2ed4SEdward Tomasz Napierala 			    int portal_id);
3478eab95d6SEdward Tomasz Napierala void			kernel_accept(int *connection_id, int *portal_id,
3488eab95d6SEdward Tomasz Napierala 			    struct sockaddr *client_sa,
3498eab95d6SEdward Tomasz Napierala 			    socklen_t *client_salen);
350009ea47eSEdward Tomasz Napierala void			kernel_send(struct pdu *pdu);
351009ea47eSEdward Tomasz Napierala void			kernel_receive(struct pdu *pdu);
3528eab95d6SEdward Tomasz Napierala #endif
353009ea47eSEdward Tomasz Napierala 
35463783933SJohn Baldwin void			login(struct ctld_connection *conn);
355009ea47eSEdward Tomasz Napierala 
35663783933SJohn Baldwin void			discovery(struct ctld_connection *conn);
357009ea47eSEdward Tomasz Napierala 
358829603e2SAlexander Motin void			set_timeout(int timeout, int fatal);
359009ea47eSEdward Tomasz Napierala 
360009ea47eSEdward Tomasz Napierala #endif /* !CTLD_H */
361