#ifndef _EMLXS_DHCHAP_H
#define _EMLXS_DHCHAP_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef DHCHAP_SUPPORT
#include <sys/random.h>
#define PASSWORD_TYPE_ASCII 1
#define PASSWORD_TYPE_BINARY 2
#define PASSWORD_TYPE_IGNORE 3
#define AUTH_MODE_DISABLED 1
#define AUTH_MODE_ACTIVE 2
#define AUTH_MODE_PASSIVE 3
#define ELX_DHCHAP 0x01
#define ELX_FCAP 0x02
#define ELX_FCPAP 0x03
#define ELX_KERBEROS 0x04
#define ELX_MD5 0x01
#define ELX_SHA1 0x02
#define ELX_GROUP_NULL 0x01
#define ELX_GROUP_1024 0x02
#define ELX_GROUP_1280 0x03
#define ELX_GROUP_1536 0x04
#define ELX_GROUP_2048 0x05
#define ELS_CMD_AUTH_CODE 0x90
#define AUTH_FINISH 0xFF
#define AUTH_ABORT 0xFE
#define AUTH_REJECT 0x0A
#define AUTH_NEGOTIATE 0x0B
#define AUTH_DONE 0x0C
#define DHCHAP_CHALLENGE 0x10
#define DHCHAP_REPLY 0x11
#define DHCHAP_SUCCESS 0x12
#ifdef EMLXS_BIG_ENDIAN
#define AUTH_DHCHAP 0x00000001
#define AUTH_FCAP 0x00000002
#define AUTH_FCPAP 0x00000003
#define AUTH_KERBEROS 0x00000004
#define HASH_LIST_TAG 0x0001
#define DHGID_LIST_TAG 0x0002
#define AUTH_SHA1 0x00000006
#define AUTH_MD5 0x00000005
#define GROUP_NULL 0x00000000
#define GROUP_1024 0x00000001
#define GROUP_1280 0x00000002
#define GROUP_1536 0x00000003
#define GROUP_2048 0x00000004
#define AUTH_TRAN_ID_MASK 0x000000FF
#endif
#ifdef EMLXS_LITTLE_ENDIAN
#define AUTH_DHCHAP 0x01000000
#define AUTH_FCAP 0x02000000
#define AUTH_FCPAP 0x03000000
#define AUTH_KERBEROS 0x04000000
#define HASH_LIST_TAG 0x0100
#define DHGID_LIST_TAG 0x0200
#define AUTH_SHA1 0x06000000
#define AUTH_MD5 0x05000000
#define GROUP_NULL 0x00000000
#define GROUP_1024 0x01000000
#define GROUP_1280 0x02000000
#define GROUP_1536 0x03000000
#define GROUP_2048 0x04000000
#define AUTH_TRAN_ID_MASK 0xFF000000
#endif
#define SHA1_LEN 0x00000014
#define MD5_LEN 0x00000010
#define HBA_SECURITY 0x20
#define AUTHRJT_FAILURE 0x01
#define AUTHRJT_LOGIC_ERR 0x02
#define LSRJT_AUTH_REQUIRED 0x03
#define LSRJT_AUTH_LOGICAL_BSY 0x05
#define LSRJT_AUTH_ELS_NOT_SUPPORTED 0x0B
#define LSRJT_AUTH_NOT_LOGGED_IN 0x09
#define AUTHEXP_MECH_UNUSABLE 0x01
#define AUTHEXP_DHGROUP_UNUSABLE 0x02
#define AUTHEXP_HASHFUNC_UNUSABLE 0x03
#define AUTHEXP_AUTHTRAN_STARTED 0x04
#define AUTHEXP_AUTH_FAILED 0x05
#define AUTHEXP_BAD_PAYLOAD 0x06
#define AUTHEXP_BAD_PROTOCOL 0x07
#define AUTHEXP_RESTART_AUTH 0x08
#define AUTHEXP_CONCAT_UNSUPP 0x09
#define AUTHEXP_BAD_PROTOVERS 0x0A
#define LSEXP_AUTH_REQUIRED 0x48
#define LSEXP_AUTH_ELS_NOT_SUPPORTED 0x2C
#define LSEXP_AUTH_ELS_NOT_LOGGED_IN 0x1E
#define LSEXP_AUTH_LOGICAL_BUSY 0x00
#define MAX_AUTH_MSA_SIZE 1024
#define MAX_AUTH_PID 0x4
#define HASH_LIST 0x0001
#define DHG_ID_LIST 0x0002
#ifdef EMLXS_BIG_ENDIAN
#define AUTH_NAME_ID 0x0001
#define AUTH_NAME_LEN 0x0008
#define AUTH_PROTO_NUM 0x00000001
#define AUTH_NULL_PARA_LEN 0x00000028
#endif
#ifdef EMLXS_LITTLE_ENDIAN
#define AUTH_NAME_ID 0x0100
#define AUTH_NAME_LEN 0x0800
#define AUTH_PROTO_NUM 0x01000000
#define AUTH_NULL_PARA_LEN 0x28000000
#endif
#define AUTH_NODE_NAME 0x0002
#define AUTH_PORT_NAME 0x0003
typedef struct emlxs_auth_cfg
{
NAME_TYPE local_entity;
NAME_TYPE remote_entity;
uint32_t authentication_timeout;
uint32_t authentication_mode;
uint32_t bidirectional:1;
uint32_t reserved:31;
uint32_t authentication_type_priority[4];
uint32_t hash_priority[4];
uint32_t dh_group_priority[8];
uint32_t reauthenticate_time_interval;
dfc_auth_status_t auth_status;
time_t auth_time;
struct emlxs_node *node;
struct emlxs_auth_cfg *prev;
struct emlxs_auth_cfg *next;
} emlxs_auth_cfg_t;
typedef struct emlxs_auth_key
{
NAME_TYPE local_entity;
NAME_TYPE remote_entity;
uint16_t local_password_length;
uint16_t local_password_type;
uint8_t local_password[128];
uint16_t remote_password_length;
uint16_t remote_password_type;
uint8_t remote_password[128];
struct emlxs_node *node;
struct emlxs_auth_key *prev;
struct emlxs_auth_key *next;
} emlxs_auth_key_t;
typedef struct emlxs_auth_misc
{
uint8_t bi_cval[20];
uint32_t bi_cval_len;
uint8_t pub_key[512];
uint32_t pubkey_len;
uint8_t ses_key[512];
uint32_t seskey_len;
uint8_t hrsp_cval[20];
uint32_t hrsp_cval_len;
uint8_t hrsp_priv_key[20];
uint8_t hrsp_pub_key[512];
uint32_t hrsp_pubkey_len;
uint8_t hrsp_ses_key[512];
uint32_t hrsp_seskey_len;
} emlxs_auth_misc_t;
typedef struct emlxs_port_dhc
{
int32_t state;
#define ELX_FABRIC_STATE_UNKNOWN 0x00
#define ELX_FABRIC_AUTH_DISABLED 0x01
#define ELX_FABRIC_AUTH_FAILED 0x02
#define ELX_FABRIC_AUTH_SUCCESS 0x03
#define ELX_FABRIC_IN_AUTH 0x04
#define ELX_FABRIC_IN_REAUTH 0x05
dfc_auth_status_t auth_status;
time_t auth_time;
} emlxs_port_dhc_t;
#define NODE_EVENT_DEVICE_RM 0x0
#define NODE_EVENT_DEVICE_RECOVERY 0x1
#define NODE_EVENT_RCV_AUTH_MSG 0x2
#define NODE_EVENT_CMPL_AUTH_MSG 0x3
#define NODE_EVENT_MAX_EVENT 0x4
typedef struct emlxs_node_dhc
{
uint16_t state;
#define NODE_STATE_UNKNOWN 0x00
#define NODE_STATE_AUTH_DISABLED 0x01
#define NODE_STATE_AUTH_FAILED 0x02
#define NODE_STATE_AUTH_SUCCESS 0x03
#define NODE_STATE_AUTH_NEGOTIATE_ISSUE 0x04
#define NODE_STATE_AUTH_NEGOTIATE_RCV 0x05
#define NODE_STATE_AUTH_NEGOTIATE_CMPL_WAIT4NEXT 0x06
#define NODE_STATE_DHCHAP_CHALLENGE_ISSUE 0x07
#define NODE_STATE_DHCHAP_REPLY_ISSUE 0x08
#define NODE_STATE_DHCHAP_CHALLENGE_CMPL_WAIT4NEXT 0x09
#define NODE_STATE_DHCHAP_REPLY_CMPL_WAIT4NEXT 0x0A
#define NODE_STATE_DHCHAP_SUCCESS_ISSUE 0x0B
#define NODE_STATE_DHCHAP_SUCCESS_ISSUE_WAIT4NEXT 0x0C
#define NODE_STATE_DHCHAP_SUCCESS_CMPL_WAIT4NEXT 0x0D
#define NODE_STATE_NOCHANGE 0xFFFFFFFF
uint16_t prev_state;
uint32_t disc_refcnt;
emlxs_auth_cfg_t auth_cfg;
emlxs_auth_key_t auth_key;
uint32_t nlp_authrsp_tmo;
uint32_t nlp_authrsp_tmocnt;
uint32_t nlp_auth_tranid_ini;
uint32_t nlp_auth_tranid_rsp;
uint32_t nlp_auth_flag;
uint32_t nlp_auth_limit;
uint32_t nlp_auth_hashid;
uint32_t nlp_auth_dhgpid;
uint32_t nlp_auth_bidir;
NAME_TYPE nlp_auth_wwn;
emlxs_auth_misc_t nlp_auth_misc;
uint32_t nlp_reauth_tmo;
uint16_t nlp_reauth_status;
#define NLP_HOST_REAUTH_DISABLED 0x0
#define NLP_HOST_REAUTH_ENABLED 0x1
#define NLP_HOST_REAUTH_IN_PROGRESS 0x2
uint32_t nlp_fb_vendor;
#define NLP_FABRIC_CISCO 0x1
#define NLP_FABRIC_OTHERS 0x2
uint32_t fc_dhchap_success_expected;
uint32_t hash_id;
uint32_t dhgp_id;
uint8_t bi_cval[20];
uint32_t bi_cval_len;
uint8_t pub_key[512];
uint32_t pubkey_len;
uint8_t ses_key[512];
uint32_t seskey_len;
uint8_t hrsp_cval[20];
uint32_t hrsp_cval_len;
uint8_t hrsp_priv_key[20];
uint8_t hrsp_pub_key[512];
uint32_t hrsp_pubkey_len;
uint8_t hrsp_ses_key[512];
uint32_t hrsp_seskey_len;
uint8_t *deferred_sbp;
uint8_t *deferred_ubp;
uint32_t flag;
#define NLP_REMOTE_AUTH 0x00000001
#define NLP_SET_REAUTH_TIME 0x00000002
emlxs_auth_cfg_t *parent_auth_cfg;
emlxs_auth_key_t *parent_auth_key;
} emlxs_node_dhc_t;
typedef struct _AUTH_NEGOT_PARAMS_1
{
uint16_t name_tag;
uint16_t name_len;
NAME_TYPE nodeName;
uint32_t proto_num;
uint32_t para_len;
uint32_t proto_id;
uint16_t HashList_tag;
uint16_t HashList_wcnt;
uint32_t HashList_value1;
uint16_t DHgIDList_tag;
uint16_t DHgIDList_wnt;
uint32_t DHgIDList_g0;
uint32_t DHgIDList_g1;
uint32_t DHgIDList_g2;
uint32_t DHgIDList_g3;
uint32_t DHgIDList_g4;
} AUTH_NEGOT_PARAMS_1;
typedef struct _AUTH_NEGOT_PARAMS_2
{
uint16_t name_tag;
uint16_t name_len;
NAME_TYPE nodeName;
uint32_t proto_num;
uint32_t para_len;
uint32_t proto_id;
uint16_t HashList_tag;
uint16_t HashList_wcnt;
uint32_t HashList_value1;
uint32_t HashList_value2;
uint16_t DHgIDList_tag;
uint16_t DHgIDList_wnt;
uint32_t DHgIDList_g0;
uint32_t DHgIDList_g1;
uint32_t DHgIDList_g2;
uint32_t DHgIDList_g3;
uint32_t DHgIDList_g4;
} AUTH_NEGOT_PARAMS_2;
typedef struct _AUTH_NEGOT_PARAMS
{
uint16_t name_tag;
uint16_t name_len;
NAME_TYPE nodeName;
uint32_t proto_num;
uint32_t para_len;
uint32_t proto_id;
uint16_t HashList_tag;
uint16_t HashList_wcnt;
uint32_t HashList_value1;
uint32_t HashList_value2;
uint16_t DHgIDList_tag;
uint16_t DHgIDList_wnt;
uint32_t DHgIDList_g0;
uint32_t DHgIDList_g1;
uint32_t DHgIDList_g2;
uint32_t DHgIDList_g3;
uint32_t DHgIDList_g4;
} AUTH_NEGOT_PARAMS;
typedef struct _AUTH_NEGOT_PARAMS_NULL_1
{
uint16_t name_tag;
uint16_t name_len;
NAME_TYPE nodeName;
uint32_t proto_num;
uint32_t para_len;
uint32_t proto_id;
uint16_t HashList_tag;
uint16_t HashList_wcnt;
uint32_t HashList_value1;
uint16_t DHgIDList_tag;
uint16_t DHgIDList_wnt;
uint32_t DHgIDList_g0;
} AUTH_NEGOT_PARAMS_NULL_1;
typedef struct _AUTH_NEGOT_PARAMS_NULL_2
{
uint16_t name_tag;
uint16_t name_len;
NAME_TYPE nodeName;
uint32_t proto_num;
uint32_t para_len;
uint32_t proto_id;
uint16_t HashList_tag;
uint16_t HashList_wcnt;
uint32_t HashList_value1;
uint32_t HashList_value2;
uint16_t DHgIDList_tag;
uint16_t DHgIDList_wnt;
uint32_t DHgIDList_g0;
} AUTH_NEGOT_PARAMS_NULL_2;
typedef struct _AUTH_MSG_HDR
{
uint8_t auth_els_code;
uint8_t auth_els_flags;
uint8_t auth_msg_code;
uint8_t proto_version;
uint32_t msg_len;
uint32_t tran_id;
uint16_t name_tag;
uint16_t name_len;
NAME_TYPE nodeName;
} AUTH_MSG_HDR;
typedef struct _SHA1_CVAL
{
uint8_t val[20];
} SHA1_CVAL;
typedef struct _MD5_CVAL
{
uint8_t val[16];
} MD5_CVAL;
union challenge_val
{
SHA1_CVAL sha1;
MD5_CVAL md5;
};
typedef struct _DHCHAP_REPLY_HDR
{
uint8_t auth_els_code;
uint8_t auth_els_flags;
uint8_t auth_msg_code;
uint8_t proto_version;
uint32_t msg_len;
uint32_t tran_id;
} DHCHAP_REPLY_HDR;
typedef struct _DHCHAP_CHALL_NULL
{
AUTH_MSG_HDR msg_hdr;
uint32_t hash_id;
uint32_t dhgp_id;
uint32_t cval_len;
} DHCHAP_CHALL_NULL;
typedef struct _DHCHAP_CHALL
{
DHCHAP_CHALL_NULL cnul;
uint8_t *dhval;
} DHCHAP_CHALL;
typedef struct _AUTH_MSG_NEGOT_1 {
uint8_t auth_els_code;
uint8_t auth_els_flags;
uint8_t auth_msg_code;
uint8_t proto_version;
uint32_t msg_len;
uint32_t tran_id;
AUTH_NEGOT_PARAMS_1 params;
} AUTH_MSG_NEGOT_1, *PAUTH_MSG_NEGOT_1;
typedef struct _AUTH_MSG_NEGOT_2 {
uint8_t auth_els_code;
uint8_t auth_els_flags;
uint8_t auth_msg_code;
uint8_t proto_version;
uint32_t msg_len;
uint32_t tran_id;
AUTH_NEGOT_PARAMS_2 params;
} AUTH_MSG_NEGOT_2, *PAUTH_MSG_NEGOT_2;
typedef struct _AUTH_MSG_NEGOT
{
uint8_t auth_els_code;
uint8_t auth_els_flags;
uint8_t auth_msg_code;
uint8_t proto_version;
uint32_t msg_len;
uint32_t tran_id;
AUTH_NEGOT_PARAMS params;
} AUTH_MSG_NEGOT, *PAUTH_MSG_NEGOT;
typedef struct _AUTH_MSG_NEGOT_NULL
{
uint8_t auth_els_code;
uint8_t auth_els_flags;
uint8_t auth_msg_code;
uint8_t proto_version;
uint32_t msg_len;
uint32_t tran_id;
} AUTH_MSG_NEGOT_NULL, *PAUTH_MSG_NEGOT_NULL;
typedef struct _AUTH_MSG_NEGOT_NULL_1
{
uint8_t auth_els_code;
uint8_t auth_els_flags;
uint8_t auth_msg_code;
uint8_t proto_version;
uint32_t msg_len;
uint32_t tran_id;
AUTH_NEGOT_PARAMS_NULL_1 params;
} AUTH_MSG_NEGOT_NULL_1, *PAUTH_MSG_NEGOT_NULL_1;
typedef struct _AUTH_MSG_NEGOT_NULL_2
{
uint8_t auth_els_code;
uint8_t auth_els_flags;
uint8_t auth_msg_code;
uint8_t proto_version;
uint32_t msg_len;
uint32_t tran_id;
AUTH_NEGOT_PARAMS_NULL_2 params;
} AUTH_MSG_NEGOT_NULL_2, *PAUTH_MSG_NEGOT_NULL_2;
#define AUTH_ELS_FLAGS_MASK 0x0f;
typedef struct _AUTH_RJT
{
uint8_t auth_els_code;
uint8_t auth_els_flags;
uint8_t auth_msg_code;
uint8_t proto_version;
uint32_t msg_len;
uint32_t tran_id;
uint8_t ReasonCode;
uint8_t ReasonCodeExplanation;
uint16_t Reserved;
} AUTH_RJT, *PAUTH_RJT;
typedef struct _DHCHAP_SUCCESS_HDR
{
uint8_t auth_els_code;
uint8_t auth_els_flags;
uint8_t auth_msg_code;
uint8_t proto_version;
uint32_t msg_len;
uint32_t tran_id;
uint32_t RspVal_len;
} DHCHAP_SUCCESS_HDR, *PDHCHAP_SUCCESS_HDR;
typedef struct dh_group_st
{
unsigned long groupid;
unsigned long length;
unsigned char value[256];
} DH_GROUP, *PDH_GROUP;
#pragma weak random_get_pseudo_bytes
#endif
#ifdef __cplusplus
}
#endif
#endif