⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iscsi-session.h

📁 这个linux源代码是很全面的~基本完整了~使用c编译的~由于时间问题我没有亲自测试~但就算用来做参考资料也是非常好的
💻 H
字号:
#ifndef ISCSI_SESSION_H_#define ISCSI_SESSION_H_/* * iSCSI driver for Linux * Copyright (C) 2001 Cisco Systems, Inc. * maintained by linux-iscsi@cisco.com * * 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 of the License, 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. * * See the file COPYING included with this distribution for more details. * * $Id: iscsi-session.h,v 1.11 2002/10/08 20:10:33 smferris Exp $ * * iscsi-session.h * *   define the iSCSI session structure needed by the login library *  */#include "iscsi-common.h"#include "iscsiAuthClient.h"#if defined(LINUX) && defined(__KERNEL__)# include <linux/version.h># include <linux/blkdev.h># include <linux/sched.h># include <asm/current.h># include <asm/uaccess.h># include <linux/smp_lock.h># if ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0) )#   include <asm/semaphore.h># else#   include <asm/spinlock.h># endif# include <scsi/sg.h># include <sd.h># include <scsi.h># include <hosts.h># include "iscsi-limits.h"# include "iscsi-kernel.h"# include "iscsi-task.h"# include "iscsi-portal.h"#define LUN_BITMAP_SIZE ((ISCSI_MAX_LUN + sizeof(unsigned long) - 1) / sizeof(unsigned long))/* used for replying to NOPs */typedef struct iscsi_nop_info {    struct iscsi_nop_info *next;    uint32_t ttt;    unsigned int dlength;    unsigned char lun[8];    unsigned char data[1];} iscsi_nop_info_t;typedef struct iscsi_session {    atomic_t                refcount;    volatile unsigned long  generation;    struct iscsi_session    *next;    struct iscsi_session    *prev;    struct iscsi_session    *probe_next;    struct iscsi_session    *probe_prev;    struct iscsi_hba        *hba;    struct socket           *socket;    int                     iscsi_bus;    int                     host_no;    int                     channel;    int                     target_id;    volatile unsigned long  luns_detected[LUN_BITMAP_SIZE];    volatile unsigned long  luns_activated[LUN_BITMAP_SIZE];     uint32_t                num_luns;    int                     probe_order;    struct semaphore        probe_sem;    int                     ip_length;    unsigned char           ip_address[16];    int                     port;    int                     tcp_window_size;    char                    username[iscsiAuthStringMaxLength];    unsigned char           password[iscsiAuthStringMaxLength];    int                     password_length;    unsigned char           InitiatorName[TARGET_NAME_MAXLEN + 1];    unsigned char           InitiatorAlias[TARGET_NAME_MAXLEN + 1];    unsigned char           TargetName[TARGET_NAME_MAXLEN + 1];    unsigned char           TargetAlias[TARGET_NAME_MAXLEN + 1];    unsigned char           *log_name;    char                    target_link_dir[LINK_PATH_MAX + 1 + 3 + 10 + 1 + 6 + 10 + 1 + 3 + 10 + 1 + 7 + 1];     mode_t                  dir_mode;    IscsiAuthClient         *auth_client;    spinlock_t              portal_lock;    iscsi_portal_info_t     *portals;    unsigned int            num_portals;    unsigned int            current_portal;    volatile unsigned int   requested_portal;    unsigned int            auth_failures;    int                     ever_established;    int                     (*update_address)(struct iscsi_session *session, char *address);    /* the queue of SCSI commands that we need to send on this session */    spinlock_t              scsi_cmnd_lock;    Scsi_Cmnd               *scsi_cmnd_head;    Scsi_Cmnd               *scsi_cmnd_tail;    atomic_t                num_cmnds;    Scsi_Cmnd               *ignored_cmnd_head;    Scsi_Cmnd               *ignored_cmnd_tail;    atomic_t                num_ignored_cmnds;    uint8_t                 isid[6];    uint16_t                tsid;    unsigned int            CmdSn;    volatile uint32_t       ExpCmdSn;    volatile uint32_t       MaxCmdSn;    volatile uint32_t       last_peak_window_size;    volatile uint32_t       current_peak_window_size;    unsigned long           window_peak_check;    int                     ImmediateData;    int                     InitialR2T;    int                     MaxRecvDataSegmentLength;  /* the value we declare */    int                     MaxXmitDataSegmentLength;  /* the value declared by the target */    int                     FirstBurstLength;    int                     MaxBurstLength;    int                     DataPDUInOrder;    int                     DataSequenceInOrder;    int                     DefaultTime2Wait;    int                     DefaultTime2Retain;    int                     type;    int                     current_phase;    int                     next_phase;    int                     partial_response;    int                     portal_group_tag;    uint32_t                itt;    int                     ping_test_data_length;    int                     ping_test_rx_length;    unsigned long           ping_test_start;    unsigned long           ping_test_rx_start;    unsigned char           *ping_test_tx_buffer;    volatile unsigned long  last_rx;    volatile unsigned long  last_ping;    unsigned long           last_window_check;    unsigned long           last_kill;    unsigned long           login_phase_timer;    int                     login_timeout;    int                     auth_timeout;    int		            active_timeout;    int		            idle_timeout;    int                     ping_timeout;    int		            abort_timeout;    int		            reset_timeout;    int		            replacement_timeout;    /* the following fields may have to move if we decide to implement multiple connections,     * per session, and decide to have threads for each connection rather than for each session.     */    /* the queue of SCSI commands that have been sent on this session, and for which we're waiting for a reply */    spinlock_t              task_lock;    iscsi_task_collection_t arrival_order;    iscsi_task_collection_t rx_tasks;    iscsi_task_collection_t tx_tasks;    iscsi_task_collection_t completing_tasks;    iscsi_task_collection_t rx_abort_tasks;    iscsi_task_collection_t tx_abort_tasks;    iscsi_task_collection_t aborted_tasks;    iscsi_task_collection_t tx_lun_reset_tasks;    iscsi_task_collection_t rx_lun_reset_tasks;    iscsi_task_collection_t lun_reset_tasks;    atomic_t                num_active_tasks;    iscsi_nop_info_t        nop_reply;    iscsi_nop_info_t        *nop_reply_head;    iscsi_nop_info_t        *nop_reply_tail;    wait_queue_head_t       tx_wait_q;    wait_queue_head_t       tx_blocked_wait_q;    wait_queue_head_t       login_wait_q;    wait_queue_head_t       reset_wait_q;    volatile unsigned long  control_bits;    volatile uint32_t       warm_reset_itt;    volatile uint32_t       cold_reset_itt;    volatile pid_t          rx_pid;    volatile pid_t          tx_pid;    volatile unsigned long  session_drop_time;    /* the following fields are per-connection, not per session, and will need to move if      * we decide to support multiple connections per session.     */    unsigned long           logout_deadline;    unsigned long           logout_response_deadline;    uint32_t                logout_itt;    long                    time2wait;    unsigned int            ExpStatSn;    struct iovec            RxIov[(ISCSI_MAX_SG+1)];    /* all data + pad */    unsigned char           RxBuf[ISCSI_RXCTRL_SIZE];    struct iovec            TxIov[(1+ISCSI_MAX_SG+1)];  /* header + all data + pad */} iscsi_session_t;/* session control bits */#define TX_WAKE       0#define TX_PING       1  /* NopOut, reply requested */#define TX_PING_DATA  2  /* NopOut, reply requested, with data */#define TX_NOP_REPLY  3  /* reply to a Nop-in from the target */#define TX_SCSI_COMMAND 4#define TX_DATA         5#define TX_ABORT        6#define TX_LUN_RESET    7#define TX_COLD_TARGET_RESET 8#define TX_WARM_TARGET_RESET 9#define TX_LOGOUT            10#define TX_THREAD_BLOCKED    12#define SESSION_ESTABLISHED          20#define SESSION_NEEDS_ERROR_RECOVERY 21#define SESSION_REPLACEMENT_TIMEDOUT 22#define SESSION_DROPPED              23#define SESSION_TASK_ALLOC_FAILED    24#define SESSION_RESETTING            25#define SESSION_RESET                26#define SESSION_LOGOUT_REQUESTED     27#define SESSION_LOGGED_OUT       28#define SESSION_WINDOW_CLOSED    29#define SESSION_TERMINATING      30#define SESSION_TERMINATED       31#else/* daemon's session structure */typedef struct iscsi_session {    int	        socket_fd;    int         login_timeout;    int         auth_timeout;    int         active_timeout;    int         idle_timeout;    int		ping_timeout;    uint32_t    itt;    uint32_t    CmdSn;    uint32_t    ExpCmdSn;    uint32_t    MaxCmdSn;    uint32_t    ExpStatSn;    int         ImmediateData;    int         InitialR2T;    int         MaxRecvDataSegmentLength;  /* the value we declare */    int         MaxXmitDataSegmentLength;  /* the value declared by the target */    int         FirstBurstLength;    int         MaxBurstLength;    int         DataPDUInOrder;    int         DataSequenceInOrder;    int         DefaultTime2Wait;    int         DefaultTime2Retain;    int         type;    int         current_phase;    int         next_phase;    int         partial_response;    int         portal_group_tag;    uint8_t	isid[6];    uint16_t	tsid;    int         iscsi_bus;    int		target_id;    char	TargetName[TARGET_NAME_MAXLEN+1];    char	TargetAlias[TARGET_NAME_MAXLEN+1];    char        *InitiatorName;    char        *InitiatorAlias;    int         ip_length;    uint8_t     ip_address[16];    int		port;    int         (*update_address)(struct iscsi_session *session, char *address);    IscsiAuthClient *auth_client;      char        username[iscsiAuthStringMaxLength];    uint8_t     password[iscsiAuthStringMaxLength];    int         password_length;} iscsi_session_t;#endif#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -