Deleted Added
full compact
ctld.h (274853) ctld.h (278037)
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 *
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: head/usr.sbin/ctld/ctld.h 274853 2014-11-22 15:09:18Z mav $
29 * $FreeBSD: head/usr.sbin/ctld/ctld.h 278037 2015-02-01 21:50:28Z mav $
30 */
31
32#ifndef CTLD_H
33#define CTLD_H
34
35#include <sys/queue.h>
36#ifdef ICL_KERNEL_PROXY
37#include <sys/types.h>
38#endif
39#include <sys/socket.h>
40#include <stdbool.h>
41#include <libutil.h>
42#include <openssl/md5.h>
43
44#define DEFAULT_CONFIG_PATH "/etc/ctl.conf"
45#define DEFAULT_PIDFILE "/var/run/ctld.pid"
46#define DEFAULT_BLOCKSIZE 512
47
30 */
31
32#ifndef CTLD_H
33#define CTLD_H
34
35#include <sys/queue.h>
36#ifdef ICL_KERNEL_PROXY
37#include <sys/types.h>
38#endif
39#include <sys/socket.h>
40#include <stdbool.h>
41#include <libutil.h>
42#include <openssl/md5.h>
43
44#define DEFAULT_CONFIG_PATH "/etc/ctl.conf"
45#define DEFAULT_PIDFILE "/var/run/ctld.pid"
46#define DEFAULT_BLOCKSIZE 512
47
48#define MAX_LUNS 1024
48#define MAX_NAME_LEN 223
49#define MAX_DATA_SEGMENT_LENGTH (128 * 1024)
50#define MAX_BURST_LENGTH 16776192
51#define SOCKBUF_SIZE 1048576
52
53struct auth {
54 TAILQ_ENTRY(auth) a_next;
55 struct auth_group *a_auth_group;
56 char *a_user;
57 char *a_secret;
58 char *a_mutual_user;
59 char *a_mutual_secret;
60};
61
62struct auth_name {
63 TAILQ_ENTRY(auth_name) an_next;
64 struct auth_group *an_auth_group;
65 char *an_initator_name;
66};
67
68struct auth_portal {
69 TAILQ_ENTRY(auth_portal) ap_next;
70 struct auth_group *ap_auth_group;
71 char *ap_initator_portal;
72 struct sockaddr_storage ap_sa;
73 int ap_mask;
74};
75
76#define AG_TYPE_UNKNOWN 0
77#define AG_TYPE_DENY 1
78#define AG_TYPE_NO_AUTHENTICATION 2
79#define AG_TYPE_CHAP 3
80#define AG_TYPE_CHAP_MUTUAL 4
81
82struct auth_group {
83 TAILQ_ENTRY(auth_group) ag_next;
84 struct conf *ag_conf;
85 char *ag_name;
86 struct target *ag_target;
87 int ag_type;
88 TAILQ_HEAD(, auth) ag_auths;
89 TAILQ_HEAD(, auth_name) ag_names;
90 TAILQ_HEAD(, auth_portal) ag_portals;
91};
92
93struct portal {
94 TAILQ_ENTRY(portal) p_next;
95 struct portal_group *p_portal_group;
96 bool p_iser;
97 char *p_listen;
98 struct addrinfo *p_ai;
99#ifdef ICL_KERNEL_PROXY
100 int p_id;
101#endif
102
103 TAILQ_HEAD(, target) p_targets;
104 int p_socket;
105};
106
107#define PG_FILTER_UNKNOWN 0
108#define PG_FILTER_NONE 1
109#define PG_FILTER_PORTAL 2
110#define PG_FILTER_PORTAL_NAME 3
111#define PG_FILTER_PORTAL_NAME_AUTH 4
112
113struct portal_group {
114 TAILQ_ENTRY(portal_group) pg_next;
115 struct conf *pg_conf;
116 char *pg_name;
117 struct auth_group *pg_discovery_auth_group;
118 int pg_discovery_filter;
119 bool pg_unassigned;
120 TAILQ_HEAD(, portal) pg_portals;
121 char *pg_redirection;
122
123 uint16_t pg_tag;
124};
125
126struct lun_option {
127 TAILQ_ENTRY(lun_option) lo_next;
128 struct lun *lo_lun;
129 char *lo_name;
130 char *lo_value;
131};
132
133struct lun {
134 TAILQ_ENTRY(lun) l_next;
49#define MAX_NAME_LEN 223
50#define MAX_DATA_SEGMENT_LENGTH (128 * 1024)
51#define MAX_BURST_LENGTH 16776192
52#define SOCKBUF_SIZE 1048576
53
54struct auth {
55 TAILQ_ENTRY(auth) a_next;
56 struct auth_group *a_auth_group;
57 char *a_user;
58 char *a_secret;
59 char *a_mutual_user;
60 char *a_mutual_secret;
61};
62
63struct auth_name {
64 TAILQ_ENTRY(auth_name) an_next;
65 struct auth_group *an_auth_group;
66 char *an_initator_name;
67};
68
69struct auth_portal {
70 TAILQ_ENTRY(auth_portal) ap_next;
71 struct auth_group *ap_auth_group;
72 char *ap_initator_portal;
73 struct sockaddr_storage ap_sa;
74 int ap_mask;
75};
76
77#define AG_TYPE_UNKNOWN 0
78#define AG_TYPE_DENY 1
79#define AG_TYPE_NO_AUTHENTICATION 2
80#define AG_TYPE_CHAP 3
81#define AG_TYPE_CHAP_MUTUAL 4
82
83struct auth_group {
84 TAILQ_ENTRY(auth_group) ag_next;
85 struct conf *ag_conf;
86 char *ag_name;
87 struct target *ag_target;
88 int ag_type;
89 TAILQ_HEAD(, auth) ag_auths;
90 TAILQ_HEAD(, auth_name) ag_names;
91 TAILQ_HEAD(, auth_portal) ag_portals;
92};
93
94struct portal {
95 TAILQ_ENTRY(portal) p_next;
96 struct portal_group *p_portal_group;
97 bool p_iser;
98 char *p_listen;
99 struct addrinfo *p_ai;
100#ifdef ICL_KERNEL_PROXY
101 int p_id;
102#endif
103
104 TAILQ_HEAD(, target) p_targets;
105 int p_socket;
106};
107
108#define PG_FILTER_UNKNOWN 0
109#define PG_FILTER_NONE 1
110#define PG_FILTER_PORTAL 2
111#define PG_FILTER_PORTAL_NAME 3
112#define PG_FILTER_PORTAL_NAME_AUTH 4
113
114struct portal_group {
115 TAILQ_ENTRY(portal_group) pg_next;
116 struct conf *pg_conf;
117 char *pg_name;
118 struct auth_group *pg_discovery_auth_group;
119 int pg_discovery_filter;
120 bool pg_unassigned;
121 TAILQ_HEAD(, portal) pg_portals;
122 char *pg_redirection;
123
124 uint16_t pg_tag;
125};
126
127struct lun_option {
128 TAILQ_ENTRY(lun_option) lo_next;
129 struct lun *lo_lun;
130 char *lo_name;
131 char *lo_value;
132};
133
134struct lun {
135 TAILQ_ENTRY(lun) l_next;
136 struct conf *l_conf;
135 TAILQ_HEAD(, lun_option) l_options;
137 TAILQ_HEAD(, lun_option) l_options;
136 struct target *l_target;
137 int l_lun;
138 char *l_name;
138 char *l_backend;
139 int l_blocksize;
140 char *l_device_id;
141 char *l_path;
139 char *l_backend;
140 int l_blocksize;
141 char *l_device_id;
142 char *l_path;
143 char *l_scsiname;
142 char *l_serial;
143 int64_t l_size;
144
145 int l_ctl_lun;
146};
147
148struct target {
149 TAILQ_ENTRY(target) t_next;
144 char *l_serial;
145 int64_t l_size;
146
147 int l_ctl_lun;
148};
149
150struct target {
151 TAILQ_ENTRY(target) t_next;
150 TAILQ_HEAD(, lun) t_luns;
151 struct conf *t_conf;
152 struct conf *t_conf;
153 struct lun *t_luns[MAX_LUNS];
152 struct auth_group *t_auth_group;
153 struct portal_group *t_portal_group;
154 char *t_name;
155 char *t_alias;
156 char *t_redirection;
154 struct auth_group *t_auth_group;
155 struct portal_group *t_portal_group;
156 char *t_name;
157 char *t_alias;
158 char *t_redirection;
159
160 uint32_t t_ctl_port;
157};
158
159struct isns {
160 TAILQ_ENTRY(isns) i_next;
161 struct conf *i_conf;
162 char *i_addr;
163 struct addrinfo *i_ai;
164};
165
166struct conf {
167 char *conf_pidfile_path;
161};
162
163struct isns {
164 TAILQ_ENTRY(isns) i_next;
165 struct conf *i_conf;
166 char *i_addr;
167 struct addrinfo *i_ai;
168};
169
170struct conf {
171 char *conf_pidfile_path;
172 TAILQ_HEAD(, lun) conf_luns;
168 TAILQ_HEAD(, target) conf_targets;
169 TAILQ_HEAD(, auth_group) conf_auth_groups;
170 TAILQ_HEAD(, portal_group) conf_portal_groups;
171 TAILQ_HEAD(, isns) conf_isns;
172 int conf_isns_period;
173 int conf_isns_timeout;
174 int conf_debug;
175 int conf_timeout;
176 int conf_maxproc;
177
178 uint16_t conf_last_portal_group_tag;
179#ifdef ICL_KERNEL_PROXY
180 int conf_portal_id;
181#endif
182 struct pidfh *conf_pidfh;
183
184 bool conf_default_pg_defined;
185 bool conf_default_ag_defined;
186 bool conf_kernel_port_on;
187};
188
189#define CONN_SESSION_TYPE_NONE 0
190#define CONN_SESSION_TYPE_DISCOVERY 1
191#define CONN_SESSION_TYPE_NORMAL 2
192
193#define CONN_DIGEST_NONE 0
194#define CONN_DIGEST_CRC32C 1
195
196struct connection {
197 struct portal *conn_portal;
198 struct target *conn_target;
199 int conn_socket;
200 int conn_session_type;
201 char *conn_initiator_name;
202 char *conn_initiator_addr;
203 char *conn_initiator_alias;
204 uint8_t conn_initiator_isid[6];
205 struct sockaddr_storage conn_initiator_sa;
206 uint32_t conn_cmdsn;
207 uint32_t conn_statsn;
208 size_t conn_max_data_segment_length;
209 size_t conn_max_burst_length;
210 int conn_immediate_data;
211 int conn_header_digest;
212 int conn_data_digest;
213 const char *conn_user;
214 struct chap *conn_chap;
215};
216
217struct pdu {
218 struct connection *pdu_connection;
219 struct iscsi_bhs *pdu_bhs;
220 char *pdu_data;
221 size_t pdu_data_len;
222};
223
224#define KEYS_MAX 1024
225
226struct keys {
227 char *keys_names[KEYS_MAX];
228 char *keys_values[KEYS_MAX];
229 char *keys_data;
230 size_t keys_data_len;
231};
232
233#define CHAP_CHALLENGE_LEN 1024
234
235struct chap {
236 unsigned char chap_id;
237 char chap_challenge[CHAP_CHALLENGE_LEN];
238 char chap_response[MD5_DIGEST_LENGTH];
239};
240
241struct rchap {
242 char *rchap_secret;
243 unsigned char rchap_id;
244 void *rchap_challenge;
245 size_t rchap_challenge_len;
246};
247
248struct chap *chap_new(void);
249char *chap_get_id(const struct chap *chap);
250char *chap_get_challenge(const struct chap *chap);
251int chap_receive(struct chap *chap, const char *response);
252int chap_authenticate(struct chap *chap,
253 const char *secret);
254void chap_delete(struct chap *chap);
255
256struct rchap *rchap_new(const char *secret);
257int rchap_receive(struct rchap *rchap,
258 const char *id, const char *challenge);
259char *rchap_get_response(struct rchap *rchap);
260void rchap_delete(struct rchap *rchap);
261
262struct conf *conf_new(void);
263struct conf *conf_new_from_file(const char *path);
264struct conf *conf_new_from_kernel(void);
265void conf_delete(struct conf *conf);
266int conf_verify(struct conf *conf);
267
268struct auth_group *auth_group_new(struct conf *conf, const char *name);
269void auth_group_delete(struct auth_group *ag);
270struct auth_group *auth_group_find(const struct conf *conf,
271 const char *name);
272int auth_group_set_type(struct auth_group *ag,
273 const char *type);
274
275const struct auth *auth_new_chap(struct auth_group *ag,
276 const char *user, const char *secret);
277const struct auth *auth_new_chap_mutual(struct auth_group *ag,
278 const char *user, const char *secret,
279 const char *user2, const char *secret2);
280const struct auth *auth_find(const struct auth_group *ag,
281 const char *user);
282
283const struct auth_name *auth_name_new(struct auth_group *ag,
284 const char *initiator_name);
285bool auth_name_defined(const struct auth_group *ag);
286const struct auth_name *auth_name_find(const struct auth_group *ag,
287 const char *initiator_name);
288int auth_name_check(const struct auth_group *ag,
289 const char *initiator_name);
290
291const struct auth_portal *auth_portal_new(struct auth_group *ag,
292 const char *initiator_portal);
293bool auth_portal_defined(const struct auth_group *ag);
294const struct auth_portal *auth_portal_find(const struct auth_group *ag,
295 const struct sockaddr_storage *sa);
296int auth_portal_check(const struct auth_group *ag,
297 const struct sockaddr_storage *sa);
298
299struct portal_group *portal_group_new(struct conf *conf, const char *name);
300void portal_group_delete(struct portal_group *pg);
301struct portal_group *portal_group_find(const struct conf *conf,
302 const char *name);
303int portal_group_add_listen(struct portal_group *pg,
304 const char *listen, bool iser);
305int portal_group_set_filter(struct portal_group *pg,
306 const char *filter);
307int portal_group_set_redirection(struct portal_group *pg,
308 const char *addr);
309
310int isns_new(struct conf *conf, const char *addr);
311void isns_delete(struct isns *is);
312void isns_register(struct isns *isns, struct isns *oldisns);
313void isns_check(struct isns *isns);
314void isns_deregister(struct isns *isns);
315
316struct target *target_new(struct conf *conf, const char *name);
317void target_delete(struct target *target);
318struct target *target_find(struct conf *conf,
319 const char *name);
320int target_set_redirection(struct target *target,
321 const char *addr);
173 TAILQ_HEAD(, target) conf_targets;
174 TAILQ_HEAD(, auth_group) conf_auth_groups;
175 TAILQ_HEAD(, portal_group) conf_portal_groups;
176 TAILQ_HEAD(, isns) conf_isns;
177 int conf_isns_period;
178 int conf_isns_timeout;
179 int conf_debug;
180 int conf_timeout;
181 int conf_maxproc;
182
183 uint16_t conf_last_portal_group_tag;
184#ifdef ICL_KERNEL_PROXY
185 int conf_portal_id;
186#endif
187 struct pidfh *conf_pidfh;
188
189 bool conf_default_pg_defined;
190 bool conf_default_ag_defined;
191 bool conf_kernel_port_on;
192};
193
194#define CONN_SESSION_TYPE_NONE 0
195#define CONN_SESSION_TYPE_DISCOVERY 1
196#define CONN_SESSION_TYPE_NORMAL 2
197
198#define CONN_DIGEST_NONE 0
199#define CONN_DIGEST_CRC32C 1
200
201struct connection {
202 struct portal *conn_portal;
203 struct target *conn_target;
204 int conn_socket;
205 int conn_session_type;
206 char *conn_initiator_name;
207 char *conn_initiator_addr;
208 char *conn_initiator_alias;
209 uint8_t conn_initiator_isid[6];
210 struct sockaddr_storage conn_initiator_sa;
211 uint32_t conn_cmdsn;
212 uint32_t conn_statsn;
213 size_t conn_max_data_segment_length;
214 size_t conn_max_burst_length;
215 int conn_immediate_data;
216 int conn_header_digest;
217 int conn_data_digest;
218 const char *conn_user;
219 struct chap *conn_chap;
220};
221
222struct pdu {
223 struct connection *pdu_connection;
224 struct iscsi_bhs *pdu_bhs;
225 char *pdu_data;
226 size_t pdu_data_len;
227};
228
229#define KEYS_MAX 1024
230
231struct keys {
232 char *keys_names[KEYS_MAX];
233 char *keys_values[KEYS_MAX];
234 char *keys_data;
235 size_t keys_data_len;
236};
237
238#define CHAP_CHALLENGE_LEN 1024
239
240struct chap {
241 unsigned char chap_id;
242 char chap_challenge[CHAP_CHALLENGE_LEN];
243 char chap_response[MD5_DIGEST_LENGTH];
244};
245
246struct rchap {
247 char *rchap_secret;
248 unsigned char rchap_id;
249 void *rchap_challenge;
250 size_t rchap_challenge_len;
251};
252
253struct chap *chap_new(void);
254char *chap_get_id(const struct chap *chap);
255char *chap_get_challenge(const struct chap *chap);
256int chap_receive(struct chap *chap, const char *response);
257int chap_authenticate(struct chap *chap,
258 const char *secret);
259void chap_delete(struct chap *chap);
260
261struct rchap *rchap_new(const char *secret);
262int rchap_receive(struct rchap *rchap,
263 const char *id, const char *challenge);
264char *rchap_get_response(struct rchap *rchap);
265void rchap_delete(struct rchap *rchap);
266
267struct conf *conf_new(void);
268struct conf *conf_new_from_file(const char *path);
269struct conf *conf_new_from_kernel(void);
270void conf_delete(struct conf *conf);
271int conf_verify(struct conf *conf);
272
273struct auth_group *auth_group_new(struct conf *conf, const char *name);
274void auth_group_delete(struct auth_group *ag);
275struct auth_group *auth_group_find(const struct conf *conf,
276 const char *name);
277int auth_group_set_type(struct auth_group *ag,
278 const char *type);
279
280const struct auth *auth_new_chap(struct auth_group *ag,
281 const char *user, const char *secret);
282const struct auth *auth_new_chap_mutual(struct auth_group *ag,
283 const char *user, const char *secret,
284 const char *user2, const char *secret2);
285const struct auth *auth_find(const struct auth_group *ag,
286 const char *user);
287
288const struct auth_name *auth_name_new(struct auth_group *ag,
289 const char *initiator_name);
290bool auth_name_defined(const struct auth_group *ag);
291const struct auth_name *auth_name_find(const struct auth_group *ag,
292 const char *initiator_name);
293int auth_name_check(const struct auth_group *ag,
294 const char *initiator_name);
295
296const struct auth_portal *auth_portal_new(struct auth_group *ag,
297 const char *initiator_portal);
298bool auth_portal_defined(const struct auth_group *ag);
299const struct auth_portal *auth_portal_find(const struct auth_group *ag,
300 const struct sockaddr_storage *sa);
301int auth_portal_check(const struct auth_group *ag,
302 const struct sockaddr_storage *sa);
303
304struct portal_group *portal_group_new(struct conf *conf, const char *name);
305void portal_group_delete(struct portal_group *pg);
306struct portal_group *portal_group_find(const struct conf *conf,
307 const char *name);
308int portal_group_add_listen(struct portal_group *pg,
309 const char *listen, bool iser);
310int portal_group_set_filter(struct portal_group *pg,
311 const char *filter);
312int portal_group_set_redirection(struct portal_group *pg,
313 const char *addr);
314
315int isns_new(struct conf *conf, const char *addr);
316void isns_delete(struct isns *is);
317void isns_register(struct isns *isns, struct isns *oldisns);
318void isns_check(struct isns *isns);
319void isns_deregister(struct isns *isns);
320
321struct target *target_new(struct conf *conf, const char *name);
322void target_delete(struct target *target);
323struct target *target_find(struct conf *conf,
324 const char *name);
325int target_set_redirection(struct target *target,
326 const char *addr);
327void target_set_ctl_port(struct target *target,
328 uint32_t value);
322
329
323struct lun *lun_new(struct target *target, int lun_id);
330struct lun *lun_new(struct conf *conf, const char *name);
324void lun_delete(struct lun *lun);
331void lun_delete(struct lun *lun);
325struct lun *lun_find(const struct target *target, int lun_id);
332struct lun *lun_find(const struct conf *conf, const char *name);
326void lun_set_backend(struct lun *lun, const char *value);
327void lun_set_blocksize(struct lun *lun, size_t value);
328void lun_set_device_id(struct lun *lun, const char *value);
329void lun_set_path(struct lun *lun, const char *value);
333void lun_set_backend(struct lun *lun, const char *value);
334void lun_set_blocksize(struct lun *lun, size_t value);
335void lun_set_device_id(struct lun *lun, const char *value);
336void lun_set_path(struct lun *lun, const char *value);
337void lun_set_scsiname(struct lun *lun, const char *value);
330void lun_set_serial(struct lun *lun, const char *value);
331void lun_set_size(struct lun *lun, size_t value);
332void lun_set_ctl_lun(struct lun *lun, uint32_t value);
333
334struct lun_option *lun_option_new(struct lun *lun,
335 const char *name, const char *value);
336void lun_option_delete(struct lun_option *clo);
337struct lun_option *lun_option_find(const struct lun *lun,
338 const char *name);
339void lun_option_set(struct lun_option *clo,
340 const char *value);
341
342void kernel_init(void);
343int kernel_lun_add(struct lun *lun);
344int kernel_lun_resize(struct lun *lun);
345int kernel_lun_remove(struct lun *lun);
346void kernel_handoff(struct connection *conn);
347int kernel_port_add(struct target *targ);
338void lun_set_serial(struct lun *lun, const char *value);
339void lun_set_size(struct lun *lun, size_t value);
340void lun_set_ctl_lun(struct lun *lun, uint32_t value);
341
342struct lun_option *lun_option_new(struct lun *lun,
343 const char *name, const char *value);
344void lun_option_delete(struct lun_option *clo);
345struct lun_option *lun_option_find(const struct lun *lun,
346 const char *name);
347void lun_option_set(struct lun_option *clo,
348 const char *value);
349
350void kernel_init(void);
351int kernel_lun_add(struct lun *lun);
352int kernel_lun_resize(struct lun *lun);
353int kernel_lun_remove(struct lun *lun);
354void kernel_handoff(struct connection *conn);
355int kernel_port_add(struct target *targ);
356int kernel_port_update(struct target *targ);
348int kernel_port_remove(struct target *targ);
349void kernel_capsicate(void);
350
351#ifdef ICL_KERNEL_PROXY
352void kernel_listen(struct addrinfo *ai, bool iser,
353 int portal_id);
354void kernel_accept(int *connection_id, int *portal_id,
355 struct sockaddr *client_sa,
356 socklen_t *client_salen);
357void kernel_send(struct pdu *pdu);
358void kernel_receive(struct pdu *pdu);
359#endif
360
361struct keys *keys_new(void);
362void keys_delete(struct keys *keys);
363void keys_load(struct keys *keys, const struct pdu *pdu);
364void keys_save(struct keys *keys, struct pdu *pdu);
365const char *keys_find(struct keys *keys, const char *name);
366int keys_find_int(struct keys *keys, const char *name);
367void keys_add(struct keys *keys,
368 const char *name, const char *value);
369void keys_add_int(struct keys *keys,
370 const char *name, int value);
371
372struct pdu *pdu_new(struct connection *conn);
373struct pdu *pdu_new_response(struct pdu *request);
374void pdu_delete(struct pdu *pdu);
375void pdu_receive(struct pdu *request);
376void pdu_send(struct pdu *response);
377
378void login(struct connection *conn);
379
380void discovery(struct connection *conn);
381
382void log_init(int level);
383void log_set_peer_name(const char *name);
384void log_set_peer_addr(const char *addr);
385void log_err(int, const char *, ...)
386 __dead2 __printflike(2, 3);
387void log_errx(int, const char *, ...)
388 __dead2 __printflike(2, 3);
389void log_warn(const char *, ...) __printflike(1, 2);
390void log_warnx(const char *, ...) __printflike(1, 2);
391void log_debugx(const char *, ...) __printflike(1, 2);
392
393char *checked_strdup(const char *);
394bool valid_iscsi_name(const char *name);
395void set_timeout(int timeout, int fatal);
396bool timed_out(void);
397
398#endif /* !CTLD_H */
357int kernel_port_remove(struct target *targ);
358void kernel_capsicate(void);
359
360#ifdef ICL_KERNEL_PROXY
361void kernel_listen(struct addrinfo *ai, bool iser,
362 int portal_id);
363void kernel_accept(int *connection_id, int *portal_id,
364 struct sockaddr *client_sa,
365 socklen_t *client_salen);
366void kernel_send(struct pdu *pdu);
367void kernel_receive(struct pdu *pdu);
368#endif
369
370struct keys *keys_new(void);
371void keys_delete(struct keys *keys);
372void keys_load(struct keys *keys, const struct pdu *pdu);
373void keys_save(struct keys *keys, struct pdu *pdu);
374const char *keys_find(struct keys *keys, const char *name);
375int keys_find_int(struct keys *keys, const char *name);
376void keys_add(struct keys *keys,
377 const char *name, const char *value);
378void keys_add_int(struct keys *keys,
379 const char *name, int value);
380
381struct pdu *pdu_new(struct connection *conn);
382struct pdu *pdu_new_response(struct pdu *request);
383void pdu_delete(struct pdu *pdu);
384void pdu_receive(struct pdu *request);
385void pdu_send(struct pdu *response);
386
387void login(struct connection *conn);
388
389void discovery(struct connection *conn);
390
391void log_init(int level);
392void log_set_peer_name(const char *name);
393void log_set_peer_addr(const char *addr);
394void log_err(int, const char *, ...)
395 __dead2 __printflike(2, 3);
396void log_errx(int, const char *, ...)
397 __dead2 __printflike(2, 3);
398void log_warn(const char *, ...) __printflike(1, 2);
399void log_warnx(const char *, ...) __printflike(1, 2);
400void log_debugx(const char *, ...) __printflike(1, 2);
401
402char *checked_strdup(const char *);
403bool valid_iscsi_name(const char *name);
404void set_timeout(int timeout, int fatal);
405bool timed_out(void);
406
407#endif /* !CTLD_H */