Home | History | Annotate | Line # | Download | only in include
      1  1.1  agc /*
      2  1.2  agc  * IMPORTANT:  READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
      3  1.2  agc  * By downloading, copying, installing or using the software you agree
      4  1.2  agc  * to this license.  If you do not agree to this license, do not
      5  1.2  agc  * download, install, copy or use the software.
      6  1.1  agc  *
      7  1.1  agc  * Intel License Agreement
      8  1.1  agc  *
      9  1.1  agc  * Copyright (c) 2000, Intel Corporation
     10  1.1  agc  * All rights reserved.
     11  1.1  agc  *
     12  1.2  agc  * Redistribution and use in source and binary forms, with or without
     13  1.2  agc  * modification, are permitted provided that the following conditions
     14  1.2  agc  * are met:
     15  1.2  agc  *
     16  1.2  agc  * -Redistributions of source code must retain the above copyright
     17  1.2  agc  *  notice, this list of conditions and the following disclaimer.
     18  1.2  agc  *
     19  1.2  agc  * -Redistributions in binary form must reproduce the above copyright
     20  1.2  agc  *  notice, this list of conditions and the following disclaimer in the
     21  1.2  agc  *  documentation and/or other materials provided with the
     22  1.2  agc  *  distribution.
     23  1.2  agc  *
     24  1.2  agc  * -The name of Intel Corporation may not be used to endorse or
     25  1.2  agc  *  promote products derived from this software without specific prior
     26  1.2  agc  *  written permission.
     27  1.2  agc  *
     28  1.2  agc  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     29  1.2  agc  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     30  1.2  agc  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     31  1.2  agc  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL INTEL
     32  1.2  agc  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     33  1.2  agc  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     34  1.2  agc  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
     35  1.2  agc  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     36  1.2  agc  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     37  1.2  agc  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     38  1.2  agc  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     39  1.2  agc  * SUCH DAMAGE.
     40  1.1  agc  */
     41  1.1  agc #ifndef _PARAMETERS_H_
     42  1.1  agc #define _PARAMETERS_H_
     43  1.1  agc 
     44  1.1  agc typedef struct MD5Context MD5Context_t;
     45  1.1  agc 
     46  1.1  agc 
     47  1.1  agc #define ISCSI_PARAM_MAX_LEN 256
     48  1.1  agc #define ISCSI_PARAM_KEY_LEN 64
     49  1.1  agc 
     50  1.1  agc /* Parameter Type */
     51  1.1  agc 
     52  1.1  agc #define ISCSI_PARAM_TYPE_DECLARATIVE    1
     53  1.1  agc #define ISCSI_PARAM_TYPE_DECLARE_MULTI  2	/* for TargetName and
     54  1.1  agc 						 * TargetAddress */
     55  1.1  agc #define ISCSI_PARAM_TYPE_NUMERICAL      3
     56  1.1  agc #define ISCSI_PARAM_TYPE_NUMERICAL_Z    4	/* zero represents no limit */
     57  1.1  agc #define ISCSI_PARAM_TYPE_BINARY_OR      5
     58  1.1  agc #define ISCSI_PARAM_TYPE_BINARY_AND     6
     59  1.1  agc #define ISCSI_PARAM_TYPE_LIST           7
     60  1.1  agc 
     61  1.1  agc #define ISCSI_CHAP_DATA_LENGTH          16
     62  1.1  agc #define ISCSI_CHAP_STRING_LENGTH        256
     63  1.1  agc 
     64  1.1  agc #define ISCSI_PARAM_STATUS_AUTH_FAILED	-2
     65  1.1  agc #define ISCSI_PARAM_STATUS_FAILED	-1
     66  1.1  agc 
     67  1.1  agc /* types of authentication which the initiator can select */
     68  1.1  agc enum {
     69  1.1  agc 	AuthNone,
     70  1.1  agc 	AuthCHAP,
     71  1.1  agc 	AuthKerberos,
     72  1.1  agc 	AuthSRP
     73  1.1  agc };
     74  1.1  agc 
     75  1.1  agc /* types of digest which the initiator can select */
     76  1.1  agc enum {
     77  1.1  agc 	DigestNone	= 0x0,
     78  1.1  agc 	DigestHeader	= 0x01,
     79  1.1  agc 	DigestData	= 0x02
     80  1.1  agc 	/* these are bit masks, extend accordingly */
     81  1.1  agc };
     82  1.1  agc 
     83  1.1  agc typedef struct iscsi_parameter_item_t {
     84  1.3  agc 	char				 value[ISCSI_PARAM_MAX_LEN];
     85  1.3  agc 	struct iscsi_parameter_item_t	*next;
     86  1.3  agc } iscsi_parameter_value_t;
     87  1.1  agc 
     88  1.1  agc /* this struct defines the credentials a user has */
     89  1.1  agc typedef struct iscsi_cred_t {
     90  1.3  agc 	char		*user;		/* user's name */
     91  1.3  agc 	char		*auth_type;	/* preferred authentication type */
     92  1.3  agc 	char		*shared_secret;	/* the shared secret */
     93  1.1  agc } iscsi_cred_t;
     94  1.1  agc 
     95  1.1  agc /*
     96  1.1  agc  * Structure for storing negotiated parameters that are frequently accessed
     97  1.1  agc  * on an active session
     98  1.1  agc  */
     99  1.1  agc typedef struct iscsi_sess_param_t {
    100  1.1  agc 	uint32_t        max_burst_length;
    101  1.1  agc 	uint32_t        first_burst_length;
    102  1.3  agc 	uint32_t        max_dataseg_len;
    103  1.1  agc 	iscsi_cred_t	cred;
    104  1.1  agc 	uint8_t         initial_r2t;
    105  1.1  agc 	uint8_t         immediate_data;
    106  1.1  agc 	uint8_t		header_digest;
    107  1.1  agc 	uint8_t		data_digest;
    108  1.1  agc 	uint8_t		auth_type;
    109  1.1  agc 	uint8_t		mutual_auth;
    110  1.1  agc 	uint8_t		digest_wanted;
    111  1.1  agc } iscsi_sess_param_t;
    112  1.1  agc 
    113  1.1  agc typedef struct iscsi_parameter_t {
    114  1.1  agc 	char            key[ISCSI_PARAM_KEY_LEN];	/* key */
    115  1.1  agc 	int             type;	/* type of parameter */
    116  1.1  agc 	char            valid[ISCSI_PARAM_MAX_LEN];	/* list of valid values */
    117  1.1  agc 	char            dflt[ISCSI_PARAM_MAX_LEN];	/* default value */
    118  1.1  agc 	iscsi_parameter_value_t *value_l;	/* value list */
    119  1.1  agc 	char            offer_rx[ISCSI_PARAM_MAX_LEN];	/* outgoing offer */
    120  1.1  agc 	char            offer_tx[ISCSI_PARAM_MAX_LEN];	/* incoming offer */
    121  1.1  agc 	char            answer_tx[ISCSI_PARAM_MAX_LEN];	/* outgoing answer */
    122  1.1  agc 	char            answer_rx[ISCSI_PARAM_MAX_LEN];	/* incoming answer */
    123  1.1  agc 	char            negotiated[ISCSI_PARAM_MAX_LEN];	/* negotiated value */
    124  1.1  agc 	int             tx_offer;	/* sent offer  */
    125  1.1  agc 	int             rx_offer;	/* received offer  */
    126  1.1  agc 	int             tx_answer;	/* sent answer */
    127  1.1  agc 	int             rx_answer;	/* received answer */
    128  1.1  agc 	int             reset;	/* reset value_l */
    129  1.1  agc 	struct iscsi_parameter_t *next;
    130  1.3  agc } iscsi_parameter_t;
    131  1.1  agc 
    132  1.1  agc int             param_list_add(iscsi_parameter_t ** , int , const char *, const char *, const char *);
    133  1.1  agc int             param_list_print(iscsi_parameter_t * );
    134  1.1  agc int             param_list_destroy(iscsi_parameter_t * );
    135  1.1  agc int             param_text_add(iscsi_parameter_t *, const char *, const char *, char *, int *, int, int );
    136  1.1  agc int             param_text_parse(iscsi_parameter_t *, iscsi_cred_t *, char *, int , char *, int *, int, int);
    137  1.1  agc int             param_text_print(char *, uint32_t );
    138  1.1  agc int             param_num_vals(iscsi_parameter_t * , char *);
    139  1.1  agc int             param_val_reset(iscsi_parameter_t * , const char *);
    140  1.1  agc char           *param_val(iscsi_parameter_t * , const char *);
    141  1.1  agc char           *param_val_which(iscsi_parameter_t * , const char *, int );
    142  1.1  agc char           *param_offer(iscsi_parameter_t * , char *);
    143  1.1  agc char           *param_answer(iscsi_parameter_t * , char *);
    144  1.1  agc iscsi_parameter_t *param_get(iscsi_parameter_t * , const char *);
    145  1.1  agc int		driver_atoi(const char *);
    146  1.1  agc int             param_atoi(iscsi_parameter_t * , const char *);
    147  1.1  agc int             param_equiv(iscsi_parameter_t * , const char *, const char *);
    148  1.1  agc int             param_commit(iscsi_parameter_t * );
    149  1.1  agc void            set_session_parameters(iscsi_parameter_t * , iscsi_sess_param_t * );
    150  1.1  agc 
    151  1.1  agc /*
    152  1.1  agc  * Macros
    153  1.1  agc  */
    154  1.1  agc 
    155  1.1  agc #define PARAM_LIST_DESTROY(LIST, ELSE)                    \
    156  1.1  agc if (param_list_destroy(LIST)!=0) {                             \
    157  1.3  agc   iscsi_err(__FILE__, __LINE__, "param_list_destroy() failed\n");                \
    158  1.1  agc   ELSE;                                                        \
    159  1.1  agc }
    160  1.1  agc 
    161  1.1  agc #define PARAM_LIST_ADD(LIST, TYPE, KEY, DFLT, VALID, ELSE)   \
    162  1.1  agc if (param_list_add(LIST, TYPE, KEY, DFLT, VALID)!=0) {            \
    163  1.3  agc   iscsi_err(__FILE__, __LINE__, "param_list_add() failed\n");                       \
    164  1.1  agc   ELSE;                                                           \
    165  1.1  agc }
    166  1.1  agc 
    167  1.1  agc #define PARAM_TEXT_ADD(LIST, KEY, VAL, TEXT, LEN, SIZE, OFFER, ELSE )  \
    168  1.1  agc if (param_text_add(LIST, KEY, VAL, TEXT, LEN, SIZE, OFFER)!=0) {            \
    169  1.3  agc   iscsi_err(__FILE__, __LINE__, "param_text_add() failed\n");                           \
    170  1.1  agc   ELSE;                                                               \
    171  1.1  agc }
    172  1.1  agc 
    173  1.1  agc #define PARAM_TEXT_PARSE(LIST, CRED, TEXT, LEN, TEXT_OUT, LEN_OUT, SIZE, OFFER, ELSE )   \
    174  1.1  agc if (param_text_parse(LIST, CRED, TEXT, LEN, TEXT_OUT, LEN_OUT, SIZE, OFFER)!=0) {             \
    175  1.3  agc   iscsi_err(__FILE__, __LINE__, "param_text_parse_offer() failed\n");                               \
    176  1.1  agc   ELSE;                                                                           \
    177  1.1  agc }
    178  1.1  agc #endif
    179