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.
7 * Intel License Agreement
9 * Copyright (c) 2000, Intel Corporation
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
16 * -Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
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
24 * -The name of Intel Corporation may not be used to endorse or
25 * promote products derived from this software without specific prior
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
41 #ifndef _PARAMETERS_H_
42 #define _PARAMETERS_H_
44 typedef struct MD5Context MD5Context_t
;
47 #define ISCSI_PARAM_MAX_LEN 256
48 #define ISCSI_PARAM_KEY_LEN 64
52 #define ISCSI_PARAM_TYPE_DECLARATIVE 1
53 #define ISCSI_PARAM_TYPE_DECLARE_MULTI 2 /* for TargetName and
55 #define ISCSI_PARAM_TYPE_NUMERICAL 3
56 #define ISCSI_PARAM_TYPE_NUMERICAL_Z 4 /* zero represents no limit */
57 #define ISCSI_PARAM_TYPE_BINARY_OR 5
58 #define ISCSI_PARAM_TYPE_BINARY_AND 6
59 #define ISCSI_PARAM_TYPE_LIST 7
61 #define ISCSI_CHAP_DATA_LENGTH 16
62 #define ISCSI_CHAP_STRING_LENGTH 256
64 #define ISCSI_PARAM_STATUS_AUTH_FAILED -2
65 #define ISCSI_PARAM_STATUS_FAILED -1
67 /* types of authentication which the initiator can select */
75 /* types of digest which the initiator can select */
80 /* these are bit masks, extend accordingly */
83 typedef struct iscsi_parameter_item_t
{
84 char value
[ISCSI_PARAM_MAX_LEN
];
85 struct iscsi_parameter_item_t
*next
;
86 } iscsi_parameter_value_t
;
88 /* this struct defines the credentials a user has */
89 typedef struct iscsi_cred_t
{
90 char *user
; /* user's name */
91 char *auth_type
; /* preferred authentication type */
92 char *shared_secret
; /* the shared secret */
96 * Structure for storing negotiated parameters that are frequently accessed
97 * on an active session
99 typedef struct iscsi_sess_param_t
{
100 uint32_t max_burst_length
;
101 uint32_t first_burst_length
;
102 uint32_t max_dataseg_len
;
105 uint8_t immediate_data
;
106 uint8_t header_digest
;
110 uint8_t digest_wanted
;
111 } iscsi_sess_param_t
;
113 typedef struct iscsi_parameter_t
{
114 char key
[ISCSI_PARAM_KEY_LEN
]; /* key */
115 int type
; /* type of parameter */
116 char valid
[ISCSI_PARAM_MAX_LEN
]; /* list of valid values */
117 char dflt
[ISCSI_PARAM_MAX_LEN
]; /* default value */
118 iscsi_parameter_value_t
*value_l
; /* value list */
119 char offer_rx
[ISCSI_PARAM_MAX_LEN
]; /* outgoing offer */
120 char offer_tx
[ISCSI_PARAM_MAX_LEN
]; /* incoming offer */
121 char answer_tx
[ISCSI_PARAM_MAX_LEN
]; /* outgoing answer */
122 char answer_rx
[ISCSI_PARAM_MAX_LEN
]; /* incoming answer */
123 char negotiated
[ISCSI_PARAM_MAX_LEN
]; /* negotiated value */
124 int tx_offer
; /* sent offer */
125 int rx_offer
; /* received offer */
126 int tx_answer
; /* sent answer */
127 int rx_answer
; /* received answer */
128 int reset
; /* reset value_l */
129 struct iscsi_parameter_t
*next
;
132 int param_list_add(iscsi_parameter_t
** , int , const char *, const char *, const char *);
133 int param_list_print(iscsi_parameter_t
* );
134 int param_list_destroy(iscsi_parameter_t
* );
135 int param_text_add(iscsi_parameter_t
*, const char *, const char *, char *, int *, int, int );
136 int param_text_parse(iscsi_parameter_t
*, iscsi_cred_t
*, char *, int , char *, int *, int, int);
137 int param_text_print(char *, uint32_t );
138 int param_num_vals(iscsi_parameter_t
* , char *);
139 int param_val_reset(iscsi_parameter_t
* , const char *);
140 char *param_val(iscsi_parameter_t
* , const char *);
141 char *param_val_which(iscsi_parameter_t
* , const char *, int );
142 char *param_offer(iscsi_parameter_t
* , char *);
143 char *param_answer(iscsi_parameter_t
* , char *);
144 iscsi_parameter_t
*param_get(iscsi_parameter_t
* , const char *);
145 int driver_atoi(const char *);
146 int param_atoi(iscsi_parameter_t
* , const char *);
147 int param_equiv(iscsi_parameter_t
* , const char *, const char *);
148 int param_commit(iscsi_parameter_t
* );
149 void set_session_parameters(iscsi_parameter_t
* , iscsi_sess_param_t
* );
155 #define PARAM_LIST_DESTROY(LIST, ELSE) \
156 if (param_list_destroy(LIST)!=0) { \
157 iscsi_err(__FILE__, __LINE__, "param_list_destroy() failed\n"); \
161 #define PARAM_LIST_ADD(LIST, TYPE, KEY, DFLT, VALID, ELSE) \
162 if (param_list_add(LIST, TYPE, KEY, DFLT, VALID)!=0) { \
163 iscsi_err(__FILE__, __LINE__, "param_list_add() failed\n"); \
167 #define PARAM_TEXT_ADD(LIST, KEY, VAL, TEXT, LEN, SIZE, OFFER, ELSE ) \
168 if (param_text_add(LIST, KEY, VAL, TEXT, LEN, SIZE, OFFER)!=0) { \
169 iscsi_err(__FILE__, __LINE__, "param_text_add() failed\n"); \
173 #define PARAM_TEXT_PARSE(LIST, CRED, TEXT, LEN, TEXT_OUT, LEN_OUT, SIZE, OFFER, ELSE ) \
174 if (param_text_parse(LIST, CRED, TEXT, LEN, TEXT_OUT, LEN_OUT, SIZE, OFFER)!=0) { \
175 iscsi_err(__FILE__, __LINE__, "param_text_parse_offer() failed\n"); \