- patches.fixes/iscsi-target-fix-heap-buffer-overflow-on-error.patch:
[opensuse:kernel.git] / drivers / target / iscsi / iscsi_target_parameters.h
1 #ifndef ISCSI_PARAMETERS_H
2 #define ISCSI_PARAMETERS_H
3
4 #include <scsi/iscsi_proto.h>
5
6 struct iscsi_extra_response {
7         char key[KEY_MAXLEN];
8         char value[32];
9         struct list_head er_list;
10 } ____cacheline_aligned;
11
12 struct iscsi_param {
13         char *name;
14         char *value;
15         u8 set_param;
16         u8 phase;
17         u8 scope;
18         u8 sender;
19         u8 type;
20         u8 use;
21         u16 type_range;
22         u32 state;
23         struct list_head p_list;
24 } ____cacheline_aligned;
25
26 extern int iscsi_login_rx_data(struct iscsi_conn *, char *, int);
27 extern int iscsi_login_tx_data(struct iscsi_conn *, char *, char *, int);
28 extern void iscsi_dump_conn_ops(struct iscsi_conn_ops *);
29 extern void iscsi_dump_sess_ops(struct iscsi_sess_ops *);
30 extern void iscsi_print_params(struct iscsi_param_list *);
31 extern int iscsi_create_default_params(struct iscsi_param_list **);
32 extern int iscsi_set_keys_to_negotiate(int, struct iscsi_param_list *);
33 extern int iscsi_set_keys_irrelevant_for_discovery(struct iscsi_param_list *);
34 extern int iscsi_copy_param_list(struct iscsi_param_list **,
35                         struct iscsi_param_list *, int);
36 extern int iscsi_change_param_value(char *, struct iscsi_param_list *, int);
37 extern void iscsi_release_param_list(struct iscsi_param_list *);
38 extern struct iscsi_param *iscsi_find_param_from_key(char *, struct iscsi_param_list *);
39 extern int iscsi_extract_key_value(char *, char **, char **);
40 extern int iscsi_update_param_value(struct iscsi_param *, char *);
41 extern int iscsi_decode_text_input(u8, u8, char *, u32, struct iscsi_param_list *);
42 extern int iscsi_encode_text_output(u8, u8, char *, u32 *,
43                         struct iscsi_param_list *);
44 extern int iscsi_check_negotiated_keys(struct iscsi_param_list *);
45 extern void iscsi_set_connection_parameters(struct iscsi_conn_ops *,
46                         struct iscsi_param_list *);
47 extern void iscsi_set_session_parameters(struct iscsi_sess_ops *,
48                         struct iscsi_param_list *, int);
49
50 #define YES                             "Yes"
51 #define NO                              "No"
52 #define ALL                             "All"
53 #define IRRELEVANT                      "Irrelevant"
54 #define NONE                            "None"
55 #define NOTUNDERSTOOD                   "NotUnderstood"
56 #define REJECT                          "Reject"
57
58 /*
59  * The Parameter Names.
60  */
61 #define AUTHMETHOD                      "AuthMethod"
62 #define HEADERDIGEST                    "HeaderDigest"
63 #define DATADIGEST                      "DataDigest"
64 #define MAXCONNECTIONS                  "MaxConnections"
65 #define SENDTARGETS                     "SendTargets"
66 #define TARGETNAME                      "TargetName"
67 #define INITIATORNAME                   "InitiatorName"
68 #define TARGETALIAS                     "TargetAlias"
69 #define INITIATORALIAS                  "InitiatorAlias"
70 #define TARGETADDRESS                   "TargetAddress"
71 #define TARGETPORTALGROUPTAG            "TargetPortalGroupTag"
72 #define INITIALR2T                      "InitialR2T"
73 #define IMMEDIATEDATA                   "ImmediateData"
74 #define MAXRECVDATASEGMENTLENGTH        "MaxRecvDataSegmentLength"
75 #define MAXBURSTLENGTH                  "MaxBurstLength"
76 #define FIRSTBURSTLENGTH                "FirstBurstLength"
77 #define DEFAULTTIME2WAIT                "DefaultTime2Wait"
78 #define DEFAULTTIME2RETAIN              "DefaultTime2Retain"
79 #define MAXOUTSTANDINGR2T               "MaxOutstandingR2T"
80 #define DATAPDUINORDER                  "DataPDUInOrder"
81 #define DATASEQUENCEINORDER             "DataSequenceInOrder"
82 #define ERRORRECOVERYLEVEL              "ErrorRecoveryLevel"
83 #define SESSIONTYPE                     "SessionType"
84 #define IFMARKER                        "IFMarker"
85 #define OFMARKER                        "OFMarker"
86 #define IFMARKINT                       "IFMarkInt"
87 #define OFMARKINT                       "OFMarkInt"
88 #define X_EXTENSIONKEY                  "X-com.sbei.version"
89 #define X_EXTENSIONKEY_CISCO_NEW        "X-com.cisco.protocol"
90 #define X_EXTENSIONKEY_CISCO_OLD        "X-com.cisco.iscsi.draft"
91
92 /*
93  * For AuthMethod.
94  */
95 #define KRB5                            "KRB5"
96 #define SPKM1                           "SPKM1"
97 #define SPKM2                           "SPKM2"
98 #define SRP                             "SRP"
99 #define CHAP                            "CHAP"
100
101 /*
102  * Initial values for Parameter Negotiation.
103  */
104 #define INITIAL_AUTHMETHOD                      CHAP
105 #define INITIAL_HEADERDIGEST                    "CRC32C,None"
106 #define INITIAL_DATADIGEST                      "CRC32C,None"
107 #define INITIAL_MAXCONNECTIONS                  "1"
108 #define INITIAL_SENDTARGETS                     ALL
109 #define INITIAL_TARGETNAME                      "LIO.Target"
110 #define INITIAL_INITIATORNAME                   "LIO.Initiator"
111 #define INITIAL_TARGETALIAS                     "LIO Target"
112 #define INITIAL_INITIATORALIAS                  "LIO Initiator"
113 #define INITIAL_TARGETADDRESS                   "0.0.0.0:0000,0"
114 #define INITIAL_TARGETPORTALGROUPTAG            "1"
115 #define INITIAL_INITIALR2T                      YES
116 #define INITIAL_IMMEDIATEDATA                   YES
117 #define INITIAL_MAXRECVDATASEGMENTLENGTH        "8192"
118 #define INITIAL_MAXBURSTLENGTH                  "262144"
119 #define INITIAL_FIRSTBURSTLENGTH                "65536"
120 #define INITIAL_DEFAULTTIME2WAIT                "2"
121 #define INITIAL_DEFAULTTIME2RETAIN              "20"
122 #define INITIAL_MAXOUTSTANDINGR2T               "1"
123 #define INITIAL_DATAPDUINORDER                  YES
124 #define INITIAL_DATASEQUENCEINORDER             YES
125 #define INITIAL_ERRORRECOVERYLEVEL              "0"
126 #define INITIAL_SESSIONTYPE                     NORMAL
127 #define INITIAL_IFMARKER                        NO
128 #define INITIAL_OFMARKER                        NO
129 #define INITIAL_IFMARKINT                       "2048~65535"
130 #define INITIAL_OFMARKINT                       "2048~65535"
131
132 /*
133  * For [Header,Data]Digests.
134  */
135 #define CRC32C                          "CRC32C"
136
137 /*
138  * For SessionType.
139  */
140 #define DISCOVERY                       "Discovery"
141 #define NORMAL                          "Normal"
142
143 /*
144  * struct iscsi_param->use
145  */
146 #define USE_LEADING_ONLY                0x01
147 #define USE_INITIAL_ONLY                0x02
148 #define USE_ALL                         0x04
149
150 #define IS_USE_LEADING_ONLY(p)          ((p)->use & USE_LEADING_ONLY)
151 #define IS_USE_INITIAL_ONLY(p)          ((p)->use & USE_INITIAL_ONLY)
152 #define IS_USE_ALL(p)                   ((p)->use & USE_ALL)
153
154 #define SET_USE_INITIAL_ONLY(p)         ((p)->use |= USE_INITIAL_ONLY)
155
156 /*
157  * struct iscsi_param->sender
158  */
159 #define SENDER_INITIATOR                0x01
160 #define SENDER_TARGET                   0x02
161 #define SENDER_BOTH                     0x03
162 /* Used in iscsi_check_key() */
163 #define SENDER_RECEIVER                 0x04
164
165 #define IS_SENDER_INITIATOR(p)          ((p)->sender & SENDER_INITIATOR)
166 #define IS_SENDER_TARGET(p)             ((p)->sender & SENDER_TARGET)
167 #define IS_SENDER_BOTH(p)               ((p)->sender & SENDER_BOTH)
168
169 /*
170  * struct iscsi_param->scope
171  */
172 #define SCOPE_CONNECTION_ONLY           0x01
173 #define SCOPE_SESSION_WIDE              0x02
174
175 #define IS_SCOPE_CONNECTION_ONLY(p)     ((p)->scope & SCOPE_CONNECTION_ONLY)
176 #define IS_SCOPE_SESSION_WIDE(p)        ((p)->scope & SCOPE_SESSION_WIDE)
177
178 /*
179  * struct iscsi_param->phase
180  */
181 #define PHASE_SECURITY                  0x01
182 #define PHASE_OPERATIONAL               0x02
183 #define PHASE_DECLARATIVE               0x04
184 #define PHASE_FFP0                      0x08
185
186 #define IS_PHASE_SECURITY(p)            ((p)->phase & PHASE_SECURITY)
187 #define IS_PHASE_OPERATIONAL(p)         ((p)->phase & PHASE_OPERATIONAL)
188 #define IS_PHASE_DECLARATIVE(p)         ((p)->phase & PHASE_DECLARATIVE)
189 #define IS_PHASE_FFP0(p)                ((p)->phase & PHASE_FFP0)
190
191 /*
192  * struct iscsi_param->type
193  */
194 #define TYPE_BOOL_AND                   0x01
195 #define TYPE_BOOL_OR                    0x02
196 #define TYPE_NUMBER                     0x04
197 #define TYPE_NUMBER_RANGE               0x08
198 #define TYPE_STRING                     0x10
199 #define TYPE_VALUE_LIST                 0x20
200
201 #define IS_TYPE_BOOL_AND(p)             ((p)->type & TYPE_BOOL_AND)
202 #define IS_TYPE_BOOL_OR(p)              ((p)->type & TYPE_BOOL_OR)
203 #define IS_TYPE_NUMBER(p)               ((p)->type & TYPE_NUMBER)
204 #define IS_TYPE_NUMBER_RANGE(p)         ((p)->type & TYPE_NUMBER_RANGE)
205 #define IS_TYPE_STRING(p)               ((p)->type & TYPE_STRING)
206 #define IS_TYPE_VALUE_LIST(p)           ((p)->type & TYPE_VALUE_LIST)
207
208 /*
209  * struct iscsi_param->type_range
210  */
211 #define TYPERANGE_BOOL_AND              0x0001
212 #define TYPERANGE_BOOL_OR               0x0002
213 #define TYPERANGE_0_TO_2                0x0004
214 #define TYPERANGE_0_TO_3600             0x0008
215 #define TYPERANGE_0_TO_32767            0x0010
216 #define TYPERANGE_0_TO_65535            0x0020
217 #define TYPERANGE_1_TO_65535            0x0040
218 #define TYPERANGE_2_TO_3600             0x0080
219 #define TYPERANGE_512_TO_16777215       0x0100
220 #define TYPERANGE_AUTH                  0x0200
221 #define TYPERANGE_DIGEST                0x0400
222 #define TYPERANGE_ISCSINAME             0x0800
223 #define TYPERANGE_MARKINT               0x1000
224 #define TYPERANGE_SESSIONTYPE           0x2000
225 #define TYPERANGE_TARGETADDRESS         0x4000
226 #define TYPERANGE_UTF8                  0x8000
227
228 #define IS_TYPERANGE_0_TO_2(p)          ((p)->type_range & TYPERANGE_0_TO_2)
229 #define IS_TYPERANGE_0_TO_3600(p)       ((p)->type_range & TYPERANGE_0_TO_3600)
230 #define IS_TYPERANGE_0_TO_32767(p)      ((p)->type_range & TYPERANGE_0_TO_32767)
231 #define IS_TYPERANGE_0_TO_65535(p)      ((p)->type_range & TYPERANGE_0_TO_65535)
232 #define IS_TYPERANGE_1_TO_65535(p)      ((p)->type_range & TYPERANGE_1_TO_65535)
233 #define IS_TYPERANGE_2_TO_3600(p)       ((p)->type_range & TYPERANGE_2_TO_3600)
234 #define IS_TYPERANGE_512_TO_16777215(p) ((p)->type_range & \
235                                                 TYPERANGE_512_TO_16777215)
236 #define IS_TYPERANGE_AUTH_PARAM(p)      ((p)->type_range & TYPERANGE_AUTH)
237 #define IS_TYPERANGE_DIGEST_PARAM(p)    ((p)->type_range & TYPERANGE_DIGEST)
238 #define IS_TYPERANGE_SESSIONTYPE(p)     ((p)->type_range & \
239                                                 TYPERANGE_SESSIONTYPE)
240
241 /*
242  * struct iscsi_param->state
243  */
244 #define PSTATE_ACCEPTOR                 0x01
245 #define PSTATE_NEGOTIATE                0x02
246 #define PSTATE_PROPOSER                 0x04
247 #define PSTATE_IRRELEVANT               0x08
248 #define PSTATE_REJECT                   0x10
249 #define PSTATE_REPLY_OPTIONAL           0x20
250 #define PSTATE_RESPONSE_GOT             0x40
251 #define PSTATE_RESPONSE_SENT            0x80
252
253 #define IS_PSTATE_ACCEPTOR(p)           ((p)->state & PSTATE_ACCEPTOR)
254 #define IS_PSTATE_NEGOTIATE(p)          ((p)->state & PSTATE_NEGOTIATE)
255 #define IS_PSTATE_PROPOSER(p)           ((p)->state & PSTATE_PROPOSER)
256 #define IS_PSTATE_IRRELEVANT(p)         ((p)->state & PSTATE_IRRELEVANT)
257 #define IS_PSTATE_REJECT(p)             ((p)->state & PSTATE_REJECT)
258 #define IS_PSTATE_REPLY_OPTIONAL(p)     ((p)->state & PSTATE_REPLY_OPTIONAL)
259 #define IS_PSTATE_RESPONSE_GOT(p)       ((p)->state & PSTATE_RESPONSE_GOT)
260 #define IS_PSTATE_RESPONSE_SENT(p)      ((p)->state & PSTATE_RESPONSE_SENT)
261
262 #define SET_PSTATE_ACCEPTOR(p)          ((p)->state |= PSTATE_ACCEPTOR)
263 #define SET_PSTATE_NEGOTIATE(p)         ((p)->state |= PSTATE_NEGOTIATE)
264 #define SET_PSTATE_PROPOSER(p)          ((p)->state |= PSTATE_PROPOSER)
265 #define SET_PSTATE_IRRELEVANT(p)        ((p)->state |= PSTATE_IRRELEVANT)
266 #define SET_PSTATE_REJECT(p)            ((p)->state |= PSTATE_REJECT)
267 #define SET_PSTATE_REPLY_OPTIONAL(p)    ((p)->state |= PSTATE_REPLY_OPTIONAL)
268 #define SET_PSTATE_RESPONSE_GOT(p)      ((p)->state |= PSTATE_RESPONSE_GOT)
269 #define SET_PSTATE_RESPONSE_SENT(p)     ((p)->state |= PSTATE_RESPONSE_SENT)
270
271 #endif /* ISCSI_PARAMETERS_H */