1/*
2 * IMPORTANT:  READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
3 * By downloading, copying, installing or using the software you agree
4 * to this license.  If you do not agree to this license, do not
5 * download, install, copy or use the software.
6 *
7 * Intel License Agreement
8 *
9 * Copyright (c) 2000, Intel Corporation
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 *
16 * -Redistributions of source code must retain the above copyright
17 *  notice, this list of conditions and the following disclaimer.
18 *
19 * -Redistributions in binary form must reproduce the above copyright
20 *  notice, this list of conditions and the following disclaimer in the
21 *  documentation and/or other materials provided with the
22 *  distribution.
23 *
24 * -The name of Intel Corporation may not be used to endorse or
25 *  promote products derived from this software without specific prior
26 *  written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL INTEL
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
35 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
37 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
38 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * SUCH DAMAGE.
40 */
41#ifndef _TARGET_H_
42#define _TARGET_H_
43
44#include "iscsiprotocol.h"
45#include "iscsiutil.h"
46#include "parameters.h"
47#include "storage.h"
48#include "iscsi.h"
49
50/* Default configuration */
51#define DEFAULT_TARGET_MAX_SESSIONS 16	/* n+1 */
52#define DEFAULT_TARGET_NUM_LUNS     1
53#define DEFAULT_TARGET_BLOCK_LEN    512
54#define DEFAULT_TARGET_NUM_BLOCKS   204800
55#define DEFAULT_TARGET_NAME         "iqn.1994-04.org.netbsd.iscsi-target"
56#define DEFAULT_TARGET_QUEUE_DEPTH  8
57#define DEFAULT_TARGET_TCQ          0
58
59enum {
60	MAX_INITIATOR_ADDRESS_SIZE = 256
61
62};
63
64/* session parameters */
65typedef struct target_session_t {
66	int             id;
67	int             d;
68	int  		sock;
69	uint16_t        cid;
70	uint32_t        StatSN;
71	uint32_t        ExpCmdSN;
72	uint32_t        MaxCmdSN;
73	uint8_t        *buff;
74	int             UsePhaseCollapsedRead;
75	int             IsFullFeature;
76	int             IsLoggedIn;
77	int             LoginStarted;
78	uint64_t        isid;
79	int             tsih;
80	iscsi_target_t	*target;
81	iscsi_worker_t  worker;
82	iscsi_parameter_t *params;
83	iscsi_sess_param_t sess_params;
84	char		initiator[MAX_INITIATOR_ADDRESS_SIZE];
85	int		address_family;
86	int32_t		last_tsih;
87} target_session_t;
88
89typedef struct target_cmd_t {
90	iscsi_scsi_cmd_args_t *scsi_cmd;
91	int             (*callback) (void *);
92	void           *callback_arg;
93} target_cmd_t;
94
95int target_transfer_data(target_session_t *, iscsi_scsi_cmd_args_t *, struct iovec *, int);
96
97int find_target_tsih(iscsi_target_t *, int);
98int find_target_iqn(target_session_t *);
99
100#endif /* _TARGET_H_ */
101