📄 text_param.h
字号:
/* common/text_param.h * * vi: set autoindent tabstop=8 shiftwidth=8 : * * This defines the generic functions used in the Login phase * by both the iSCSI target and the iSCSI initiator for parameter * negotiation. * * Copyright (C) 2001-2004 InterOperability Lab (IOL) * University of New Hampshire (UNH) * Durham, NH 03824 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * * The name of IOL and/or UNH may not be used to endorse or promote * products derived from this software without specific prior * written permission.*/#ifndef _TEXT_PARAM_H#define _TEXT_PARAM_H/* * Define the Login/Text Parameters */#define HEADERDIGEST "HeaderDigest"#define DATADIGEST "DataDigest"#define MAXCONNECTIONS "MaxConnections"#define SENDTARGETS "SendTargets"#define TARGETNAME "TargetName"#define INITIATORNAME "InitiatorName"#define TARGETALIAS "TargetAlias"#define INITIATORALIAS "InitiatorAlias"#define TARGETADDRESS "TargetAddress"#define INITIALR2T "InitialR2T"#define IMMEDIATEDATA "ImmediateData"#define MAXRECVDATASEGMENTLENGTH "MaxRecvDataSegmentLength"#define MAXBURSTLENGTH "MaxBurstLength"#define FIRSTBURSTLENGTH "FirstBurstLength"#define MAXOUTSTANDINGR2T "MaxOutstandingR2T"#define DATAPDUINORDER "DataPDUInOrder"#define DATASEQUENCEINORDER "DataSequenceInOrder"#define ERRORRECOVERYLEVEL "ErrorRecoveryLevel"#define SESSIONTYPE "SessionType"#define AUTHMETHOD "AuthMethod"#define DEFAULTTIME2WAIT "DefaultTime2Wait"#define DEFAULTTIME2RETAIN "DefaultTime2Retain"#define IFMARKER "IFMarker"#define OFMARKER "OFMarker"#define IFMARKINT "IFMarkInt"#define OFMARKINT "OFMarkInt"#define TARGETPORTALGROUPTAG "TargetPortalGroupTag"#define X_EXTENSIONKEY "X-edu.unh.iol-extension-key-1"/* Following Macros Added for Error Recovery - SAI*/#define PAYLOAD_DIGERR 0x00000000#define HEADER_DIGERR 0x00000001#define SEQUENCE_ERR 0x00000010/* * Define the Options available for the Parameters *//* common for all */#define NONE "None"#define REJECT "Reject"#define IRRELEVANT "Irrelevant"/* For Digests - (HeaderDigest, DataDigest) */#define CRC32C "CRC32C"/* Different Authentication Methods supported */#define KRB5 "KRB5" /* RFC1510 */#define SPKM1 "SPKM1" /* RFC2025 */#define SPKM2 "SPKM2" /* RFC2025 */#define SRP "SRP" /* RFC2945 */#define CHAP "CHAP" /* RFC1994 *//* chap and srp support - CHONG */#define MAX_CHAP_BINARY_LENGTH 1024#define MAX_SRP_BINARY_LENGTH 1024/* Draft 20, Section 11.1.4 Challenge Handshake Authentication * Protocol(CHAP) *//* The keys used at various steps in the handshake exchange */#define CHAP_A "CHAP_A"#define CHAP_I "CHAP_I"#define CHAP_C "CHAP_C"#define CHAP_N "CHAP_N"#define CHAP_R "CHAP_R"/* Draft 20, Section 11.1.3 Secure Remote Password (SRP) *//* The keys used at various steps in the handshake exchange */#define SRP_TARGETAUTH "TargetAuth"#define SRP_U "SRP_U"#define SRP_A "SRP_A"#define SRP_GROUP "SRP_GROUP"#define SRP_S "SRP_s"#define SRP_B "SRP_B"#define SRP_M "SRP_M"#define SRP_HM "SRP_HM"/* Bit masks to mark security keys that we got from other side * during security phase. These are separate from the security * steps because a single step may require that multiple keys be * received and these keys can come in any order. *//* Draft 20, Section 11.1.4 Challenge Handshake * Authentication Protocol(CHAP) */#define GOT_CHAP_A 0x0001#define GOT_CHAP_I 0x0002#define GOT_CHAP_C 0x0004#define GOT_CHAP_N 0x0008#define GOT_CHAP_R 0x0010/* Draft 20, Section 11.1.3 Secure Remote Password (SRP) */#define GOT_SRP_GROUP 0x0020#define GOT_SRP_S 0x0040#define GOT_SRP_B 0x0080#define GOT_SRP_HM 0x0100#define GOT_SRP_U 0x0200#define GOT_SRP_TARGETAUTH 0x0400#define GOT_SRP_A 0x0800#define GOT_SRP_M 0x1000/*******************************************************************//* For Parameter types *//* * byte-3 byte-2 byte-1 byte-0 * XX XX XX XX *//* following constants use the byte-3 and byte-2 for specifying type */#define SECURITY_PARAM 0x80000000#define OPERATIONAL_PARAM 0x40000000#define INFORMATIONAL_PARAM 0x20000000#define LEADING_ONLY 0x10000000#define INITIAL_ONLY 0x08000000#define FULL_FEATURE_ONLY 0x04000000#define ALL 0x02000000#define USE_BY_INITIATOR 0x01000000#define USE_BY_TARGET 0x00800000#define NORMAL_RETURN 0x00400000 /*TAddress in normal loginRPS */#define REDIRECT_RETURN 0x00200000 /*TAddress for redirection */#define SENDTARGET_RETURN 0x00100000 /*TAddr in return to SendTargets *//* byte-2 for denoting whether an offer of the parameter * can be nothing, just a single value, a 2-value range, or a list of values */#define KEY_NO_VALUE 0x00080000 /* follow = with <= 1 value */#define KEY_SINGLE_VALUE 0x00040000 /* follow = with == 1 value */#define KEY_TWO_VALUE 0x00020000 /* follow = with range low[~top] */#define KEY_MULTI_VALUE 0x00010000 /* follow = with list >= 1 value *//* following constants use the byte-1 for specifying type */#define NUMBER 0x00008000 /* numeric values only */#define STRING 0x00004000 /* arbitrary strings */#define ENUMERATED 0x00002000 /* set of specific strings */#define BOOL_AND 0x00001000 /* boolean values only */#define BOOL_OR 0x00000800 /* boolean values only */#define MIN_NUMBER 0x00000400 /* numeric values only */#define MAX_NUMBER 0x00000200 /* numeric values only */#define NUMBER_RANGE 0x00000100 /* range of 2 numeric values *//* byte-0 qualifies the byte-1 *//* if the byte-1 specifies the type to be NUMBER */#define ONE_TO_65535 0x00000080#define N512_TO_16777215 0x00000040#define ZERO_TO_3600 0x00000020#define ZERO_TO_2 0x00000008#define ZERO_TO_65535 0x00000002/* if the byte-1 specifies the type to be STRING */#define UTF_8 0x00000080 /* <UTF-8 string> */#define ISCSI_NAME 0x00000040 /* <iSCSI-Name> */#define TARGET_ADDRESS_TYPE 0x00000020 /* domainname[:port][,tag] iSCSI-Name *//* if the byte-1 specifies the type to be ENUMERATED */#define DIGEST_PARAM 0x00000080 /* Key is a Digest key */#define AUTH_PARAM 0x00000040 /* Key is a Authentication key */#define DISCOVERY_NORMAL 0x00000020 /* <Session Type> *//********************************************************************//* NOTE: Whenever a new key is added to the array * struct parameter_type config_params[MAX_CONFIG_PARAMS] * then MAX_CONFIG_PARAMS must be incremented too! */#define MAX_CONFIG_PARAMS 28/* These defines are to be used in the special_key_flag field of the * struct parameter_type to identify only those keys that need "special" * processing. Introducing these flags eliminates the need for * a lot of costly "strcmp()" operations. The bit assigned to each * flag is totally arbitrary as long as it is different for each key. * Most, but not every, key has a bit assigned to it -- only the * following 4 keys do not have a bit assigned: * TargetAlias * InitiatorAlias * TargetAddress * X-edu.unh.iol.extension-key * * Some of these defines are also used in login_flags. * When asked for, they are set if the corresponding special key is * found in the input by scan_input_and_process(). *//* The first set of 35 flags is used in the special_key_flag field of keys. * They must not conflict with the defines in the login_flags */#define TARGETPORTALGROUPTAG_FLAG 0x0080000000LL#define TARGETNAME_FLAG 0x0040000000LL#define INITIATORNAME_FLAG 0x0020000000LL#define SESSIONTYPE_FLAG 0x0010000000LL#define HEADERDIGEST_FLAG 0x0008000000LL#define DATADIGEST_FLAG 0x0004000000LL#define SENDTARGETS_FLAG 0x0002000000LL#define OFMARKER_FLAG 0x0000080000LL#define IFMARKER_FLAG 0x0000040000LL#define OFMARKINT_FLAG 0x0000008000LL#define IFMARKINT_FLAG 0x0000004000LL#define DEFAULTTIME2WAIT_FLAG 0x0000000800LL#define DEFAULTTIME2RETAIN_FLAG 0x0000000400LL#define AUTHMETHOD_FLAG 0x0000000200LL#define INITIALR2T_FLAG 0x0000000100LL#define IMMEDIATEDATA_FLAG 0x0000000040LL#define DATAPDUINORDER_FLAG 0x0000000020LL#define DATASEQUENCEINORDER_FLAG 0x0000000010LL#define MAXCONNECTIONS_FLAG 0x0000000008LL#define MAXOUTSTANDINGR2T_FLAG 0x0000000004LL#define ERRORRECOVERYLEVEL_FLAG 0x0000000002LL#define X_EXTENSIONKEY_FLAG 0x0000000001LL#define MAXRECVDATASEGMENTLENGTH_FLAG 0x1000000000LL#define MAXBURSTLENGTH_FLAG 0x2000000000LL#define FIRSTBURSTLENGTH_FLAG 0x4000000000LL#define TARGETADDRESS_FLAG 0x8000000000LL/* The following defines are used in login_flags only. * They are set and reset during processing, and must not * conflict with the special key flags defined above. * * The second set of 2 flags is never used in the special_key_flag field * of keys, only in login_flags. Therefore, they are 64-bits, as is the * login_flags variable. *//* set when there are more keys to add to output than fit in one PDU */#define MORE_TO_SEND_FLAG 0x0100000000LL/* set when processing first Login Request/Response, else reset */#define FIRST_FLAG 0x0200000000LL/* set when in the discovery session, else in normal session */#define DISCOVERY_FLAG 0x0400000000LL/************************************************************************/#define ALLOCATE_MAX_TEXT_LEN(str) \do { \ if( !((str) = (char *)kmalloc( MAX_TEXT_LEN, GFP_KERNEL)) ) \ { \ TRACE_ERROR("unable to allocate memory for" #str "\n"); \ return -1; \ } \ } \while(0)#define FREE_STRING(str) if(str) \ { \ kfree(str); \ }/********************************************************************/#define YES "Yes"#define NO "No"#define NORMAL "Normal"#define DISCOVERY "Discovery"#define NOTUNDERSTOOD "NotUnderstood"#define INITIAL_FIRSTBURSTLENGTH 65536#define INITIAL_MAXBURSTLENGTH 262144/* This structure holds the parameters required for login-text * negotiation */struct parameter_type { /* Name of the parameter */ char *parameter_name; /* Type of the parameter: * Byte 3 - Security, operational etc.. * Byte 2 - Number of values that can be sent with the key * Byte 1 - number, string, enumerated, boolean, etc.. * Byte 0 - further qualifies the type depending on Byte-1 */ __u32 type; /* used only if the type is NUMBER or NUMBER_RANGE, * not STRING or ENUMERATED or BOOLEAN */ __u32 int_value; /* used only if the type is STRING or ENUMERATED or BOOLEAN or * NUMBER_RANGE, not NUMBER */ char *str_value; /* used only if the type is STRING or ENUMERATED or BOOLEAN or
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -