summaryrefslogtreecommitdiff
path: root/devel/intel-iscsi
diff options
context:
space:
mode:
authoragc <agc@pkgsrc.org>2005-10-30 21:02:57 +0000
committeragc <agc@pkgsrc.org>2005-10-30 21:02:57 +0000
commitef51593a9398723772c40193ebb65cea3e114d12 (patch)
tree6bdd3bc2b59ea2bf2ee787fb5e702295ffdf3f65 /devel/intel-iscsi
parentcafff1c469b9157a4a421990f48d67b9c47d59a1 (diff)
downloadpkgsrc-ef51593a9398723772c40193ebb65cea3e114d12.tar.gz
Initial import of Intel's reference implementation of an iSCSI target (with
a userlevel iSCSI test-quality initiator). This project is Intel Lab's software reference implementation of iSCSI. It has been tested to interoperate with the Cisco initiator, and conforms to RFC 3720. There are 3 forms of the iSCSI target that are produced: ufsdisk - standard iSCSI target ufsdisk_mmap - an mmap(2)-based iSCSI target uramdisk - a ramdisk iSCSI target and a testing-quality user-level iSCSI initiator called utest, which can exercise the targets above.
Diffstat (limited to 'devel/intel-iscsi')
-rw-r--r--devel/intel-iscsi/DESCR12
-rw-r--r--devel/intel-iscsi/Makefile25
-rw-r--r--devel/intel-iscsi/PLIST7
-rw-r--r--devel/intel-iscsi/distinfo24
-rw-r--r--devel/intel-iscsi/patches/patch-aa489
-rw-r--r--devel/intel-iscsi/patches/patch-ab21
-rw-r--r--devel/intel-iscsi/patches/patch-ac22
-rw-r--r--devel/intel-iscsi/patches/patch-ad200
-rw-r--r--devel/intel-iscsi/patches/patch-ae25
-rw-r--r--devel/intel-iscsi/patches/patch-af55
-rw-r--r--devel/intel-iscsi/patches/patch-ag13
-rw-r--r--devel/intel-iscsi/patches/patch-ah87
-rw-r--r--devel/intel-iscsi/patches/patch-ai1203
-rw-r--r--devel/intel-iscsi/patches/patch-ak117
-rw-r--r--devel/intel-iscsi/patches/patch-al197
-rw-r--r--devel/intel-iscsi/patches/patch-am434
-rw-r--r--devel/intel-iscsi/patches/patch-an46
-rw-r--r--devel/intel-iscsi/patches/patch-ao22
-rw-r--r--devel/intel-iscsi/patches/patch-ap93
-rw-r--r--devel/intel-iscsi/patches/patch-as20
-rw-r--r--devel/intel-iscsi/patches/patch-at41
-rw-r--r--devel/intel-iscsi/patches/patch-au90
-rw-r--r--devel/intel-iscsi/patches/patch-av88
23 files changed, 3331 insertions, 0 deletions
diff --git a/devel/intel-iscsi/DESCR b/devel/intel-iscsi/DESCR
new file mode 100644
index 00000000000..e079f8e4085
--- /dev/null
+++ b/devel/intel-iscsi/DESCR
@@ -0,0 +1,12 @@
+This project is Intel Lab's software reference implementation of
+iSCSI. It has been tested to interoperate with the Cisco initiator,
+and conforms to RFC 3720.
+
+There are 3 forms of the iSCSI target that are produced:
+
+ ufsdisk - standard iSCSI target
+ ufsdisk_mmap - an mmap(2)-based iSCSI target
+ uramdisk - a ramdisk iSCSI target
+
+and a testing-quality user-level iSCSI initiator called utest, which
+can exercise the targets above.
diff --git a/devel/intel-iscsi/Makefile b/devel/intel-iscsi/Makefile
new file mode 100644
index 00000000000..d9251fc6415
--- /dev/null
+++ b/devel/intel-iscsi/Makefile
@@ -0,0 +1,25 @@
+# $NetBSD: Makefile,v 1.1.1.1 2005/10/30 21:02:57 agc Exp $
+
+DISTNAME= iscsi-Jan15
+PKGNAME= intel-iscsi-20040115
+CATEGORIES= devel
+MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=intel-iscsi/}
+EXTRACT_SUFX= .tgz
+
+MAINTAINER= tech-pkg@NetBSD.org
+HOMEPAGE= http://sourceforge.net/projects/intel-iscsi
+COMMENT= Intel Lab's software reference implementation of iSCSI RFC 3720
+
+WRKSRC= ${WRKDIR}/IntelLabs-v20-011504
+
+do-build:
+ cd ${WRKSRC}/src && ${MAKE} ufsdisk uramdisk ufsdisk_mmap usocktest utest ktest
+
+do-install:
+ for f in ufsdisk uramdisk ufsdisk_mmap usocktest utest ktest; do \
+ ${INSTALL_PROGRAM} ${WRKSRC}/src/$$f ${PREFIX}/bin; \
+ done
+
+.include "../../mk/pthread.buildlink3.mk"
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/devel/intel-iscsi/PLIST b/devel/intel-iscsi/PLIST
new file mode 100644
index 00000000000..52bb2cb5919
--- /dev/null
+++ b/devel/intel-iscsi/PLIST
@@ -0,0 +1,7 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2005/10/30 21:02:57 agc Exp $
+bin/ufsdisk
+bin/uramdisk
+bin/ufsdisk_mmap
+bin/usocktest
+bin/utest
+bin/ktest
diff --git a/devel/intel-iscsi/distinfo b/devel/intel-iscsi/distinfo
new file mode 100644
index 00000000000..d35fcc0bb05
--- /dev/null
+++ b/devel/intel-iscsi/distinfo
@@ -0,0 +1,24 @@
+$NetBSD: distinfo,v 1.1.1.1 2005/10/30 21:02:57 agc Exp $
+
+SHA1 (iscsi-Jan15.tgz) = 9928feca21448cd7ebe628067f98201e0499cf25
+RMD160 (iscsi-Jan15.tgz) = b334fb52c5906d1dd5689e74300edc4529292a33
+Size (iscsi-Jan15.tgz) = 114431 bytes
+SHA1 (patch-aa) = 57ce4429360399d7381c6e1fb3d215629d2eca50
+SHA1 (patch-ab) = da3236d030f30bd3c70d5aff639369dd70846e38
+SHA1 (patch-ac) = 74ba11f527611aa7ceecaf6bb3a2e5c4271088fc
+SHA1 (patch-ad) = 0493fcf87a889fdb6c98525ae86543aa04f2e83d
+SHA1 (patch-ae) = 478cda607f8b58217b6a8c7f93c335c08230723e
+SHA1 (patch-af) = 45294ce185c6e34b24531ae1f67dc1fb5fc4c8e9
+SHA1 (patch-ag) = 98c76d4c5da97f9c2289584e50bb88d1cdf18ad3
+SHA1 (patch-ah) = 8a1af68c604bb5f52011509d68678cef894eafbc
+SHA1 (patch-ai) = 11447ee63e17ffa9348dc6d8963053e2afba1cac
+SHA1 (patch-ak) = d57505b3e4a6a1236b088318574db63fcdbe3988
+SHA1 (patch-al) = a9d066277c04867881b8932a8ac1a29d9c2d8ad1
+SHA1 (patch-am) = 48783443ad456f7103cd86d9e894c4aa814bcba6
+SHA1 (patch-an) = 23e399d7748972031036a05555c823cd08085902
+SHA1 (patch-ao) = febfe42a7b4b5deafd25bf5ed0554f2013f9cb22
+SHA1 (patch-ap) = a6e307edc30b1c781cfd0ddfe17d5db9b36a4415
+SHA1 (patch-as) = b3dca3b8574e5b78067a1c8d980dcd579fed83ed
+SHA1 (patch-at) = f198963a44cac79ecd769fda864b97e29c42a6bc
+SHA1 (patch-au) = a25dedf289ec77942bfc192bc6cfa9d43686fd16
+SHA1 (patch-av) = cd596bbfaf58998f9d3b254e3b60e8a1b7ec9d5c
diff --git a/devel/intel-iscsi/patches/patch-aa b/devel/intel-iscsi/patches/patch-aa
new file mode 100644
index 00000000000..c2f87402cba
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-aa
@@ -0,0 +1,489 @@
+$NetBSD: patch-aa,v 1.1.1.1 2005/10/30 21:02:57 agc Exp $
+
+--- include/iscsi.h 8 Oct 2005 22:21:15 -0000 1.1.1.1
++++ include/iscsi.h 10 Oct 2005 21:49:19 -0000
+@@ -120,15 +120,15 @@
+ #define ISCSI_TASK_CMD_TARGET_REASSIGN 8
+
+ typedef struct iscsi_task_cmd_t {
+- int immediate;
+- unsigned char function;
+- unsigned long long lun;
+- unsigned tag;
+- unsigned ref_tag;
+- unsigned CmdSN;
+- unsigned ExpStatSN;
+- unsigned RefCmdSN;
+- unsigned ExpDataSN;
++ int32_t immediate;
++ uint8_t function;
++ uint64_t lun;
++ uint32_t tag;
++ uint32_t ref_tag;
++ uint32_t CmdSN;
++ uint32_t ExpStatSN;
++ uint32_t RefCmdSN;
++ uint32_t ExpDataSN;
+ } ISCSI_TASK_CMD_T;
+
+ int iscsi_task_cmd_encap(unsigned char *header, ISCSI_TASK_CMD_T *cmd);
+@@ -153,12 +153,12 @@
+ #define ISCSI_TASK_QUAL_NOT_AUTHORIZED 1
+
+ typedef struct iscsi_task_rsp_t {
+- unsigned char response;
+- unsigned length;
+- unsigned tag;
+- unsigned StatSN;
+- unsigned ExpCmdSN;
+- unsigned MaxCmdSN;
++ uint8_t response;
++ uint32_t length;
++ uint32_t tag;
++ uint32_t StatSN;
++ uint32_t ExpCmdSN;
++ uint32_t MaxCmdSN;
+ } ISCSI_TASK_RSP_T;
+
+ int iscsi_task_rsp_encap(unsigned char *header, ISCSI_TASK_RSP_T *rsp);
+@@ -171,14 +171,14 @@
+
+
+ typedef struct iscsi_nop_out_args_t {
+- int immediate;
+- unsigned length;
+- unsigned long long lun;
+- unsigned tag;
+- unsigned transfer_tag;
+- unsigned CmdSN;
+- unsigned ExpStatSN;
+- unsigned char *data;
++ int32_t immediate;
++ uint32_t length;
++ uint64_t lun;
++ uint32_t tag;
++ uint32_t transfer_tag;
++ uint32_t CmdSN;
++ uint32_t ExpStatSN;
++ uint8_t *data;
+ } ISCSI_NOP_OUT_T;
+
+ int iscsi_nop_out_encap(unsigned char *header, ISCSI_NOP_OUT_T *cmd);
+@@ -191,13 +191,13 @@
+
+
+ typedef struct iscsi_nop_in_args_t {
+- unsigned length;
+- unsigned long long lun;
+- unsigned tag;
+- unsigned transfer_tag;
+- unsigned StatSN;
+- unsigned ExpCmdSN;
+- unsigned MaxCmdSN;
++ uint32_t length;
++ uint64_t lun;
++ uint32_t tag;
++ uint32_t transfer_tag;
++ uint32_t StatSN;
++ uint32_t ExpCmdSN;
++ uint32_t MaxCmdSN;
+ } ISCSI_NOP_IN_T;
+
+ int iscsi_nop_in_encap(unsigned char *header, ISCSI_NOP_IN_T *cmd);
+@@ -210,15 +210,15 @@
+
+
+ typedef struct iscsi_text_cmd_args_t {
+- int immediate;
+- int final;
+- int cont;
+- unsigned length;
+- unsigned long long lun;
+- unsigned tag;
+- unsigned transfer_tag;
+- unsigned CmdSN;
+- unsigned ExpStatSN;
++ int32_t immediate;
++ int32_t final;
++ int32_t cont;
++ uint32_t length;
++ uint64_t lun;
++ uint32_t tag;
++ uint32_t transfer_tag;
++ uint32_t CmdSN;
++ uint32_t ExpStatSN;
+ char *text;
+ } ISCSI_TEXT_CMD_T;
+
+@@ -232,15 +232,15 @@
+
+
+ typedef struct iscsi_text_rsp_args_t {
+- int final;
+- int cont;
+- unsigned length;
+- unsigned long long lun;
+- unsigned tag;
+- unsigned transfer_tag;
+- unsigned StatSN;
+- unsigned ExpCmdSN;
+- unsigned MaxCmdSN;
++ int32_t final;
++ int32_t cont;
++ uint32_t length;
++ uint64_t lun;
++ uint32_t tag;
++ uint32_t transfer_tag;
++ uint32_t StatSN;
++ uint32_t ExpCmdSN;
++ uint32_t MaxCmdSN;
+ } ISCSI_TEXT_RSP_T;
+
+ int iscsi_text_rsp_encap(unsigned char *header, ISCSI_TEXT_RSP_T *rsp);
+@@ -253,20 +253,20 @@
+
+
+ typedef struct iscsi_login_cmd_args_t {
+- int transit;
+- int cont;
+- unsigned char csg;
+- unsigned char nsg;
+- char version_max;
+- char version_min;
+- unsigned char AHSlength;
+- unsigned length;
+- unsigned long long isid;
+- unsigned short tsih;
+- unsigned tag;
+- unsigned short cid;
+- unsigned CmdSN;
+- unsigned ExpStatSN;
++ int32_t transit;
++ int32_t cont;
++ uint8_t csg;
++ uint8_t nsg;
++ int8_t version_max;
++ int8_t version_min;
++ uint8_t AHSlength;
++ uint32_t length;
++ uint64_t isid;
++ uint16_t tsih;
++ uint32_t tag;
++ uint16_t cid;
++ uint32_t CmdSN;
++ uint32_t ExpStatSN;
+ char *text;
+ } ISCSI_LOGIN_CMD_T;
+
+@@ -280,22 +280,22 @@
+
+
+ typedef struct iscsi_login_rsp_args_t {
+- int transit;
+- int cont;
+- unsigned char csg;
+- unsigned char nsg;
+- char version_max;
+- char version_active;
+- unsigned char AHSlength;
+- unsigned length;
+- unsigned long long isid;
+- unsigned short tsih;
+- unsigned tag;
+- unsigned StatSN;
+- unsigned ExpCmdSN;
+- unsigned MaxCmdSN;
+- unsigned char status_class;
+- unsigned char status_detail;
++ int32_t transit;
++ int32_t cont;
++ uint8_t csg;
++ uint8_t nsg;
++ int8_t version_max;
++ int8_t version_active;
++ uint8_t AHSlength;
++ uint32_t length;
++ uint64_t isid;
++ uint16_t tsih;
++ uint32_t tag;
++ uint32_t StatSN;
++ uint32_t ExpCmdSN;
++ uint32_t MaxCmdSN;
++ uint8_t status_class;
++ uint8_t status_detail;
+ } ISCSI_LOGIN_RSP_T;
+
+ int iscsi_login_rsp_encap(unsigned char *header, ISCSI_LOGIN_RSP_T *rsp);
+@@ -308,12 +308,12 @@
+
+
+ typedef struct iscsi_logout_cmd_args_t {
+- int immediate;
+- unsigned char reason;
+- unsigned tag;
+- unsigned short cid;
+- unsigned CmdSN;
+- unsigned ExpStatSN;
++ int32_t immediate;
++ uint8_t reason;
++ uint32_t tag;
++ uint16_t cid;
++ uint32_t CmdSN;
++ uint32_t ExpStatSN;
+ } ISCSI_LOGOUT_CMD_T;
+
+ int iscsi_logout_cmd_encap(unsigned char *header, ISCSI_LOGOUT_CMD_T *cmd);
+@@ -326,14 +326,14 @@
+
+
+ typedef struct iscsi_logout_rsp_args_t {
+- unsigned char response;
+- unsigned length;
+- unsigned tag;
+- unsigned StatSN;
+- unsigned ExpCmdSN;
+- unsigned MaxCmdSN;
+- unsigned short Time2Wait;
+- unsigned short Time2Retain;
++ uint8_t response;
++ uint32_t length;
++ uint32_t tag;
++ uint32_t StatSN;
++ uint32_t ExpCmdSN;
++ uint32_t MaxCmdSN;
++ uint16_t Time2Wait;
++ uint16_t Time2Retain;
+ } ISCSI_LOGOUT_RSP_T;
+
+ int iscsi_logout_rsp_encap(unsigned char *header, ISCSI_LOGOUT_RSP_T *rsp);
+@@ -346,29 +346,29 @@
+
+
+ typedef struct iscsi_scsi_cmd_args_t {
+- int immediate;
+- int final;
+- int input;
+- int output;
+- unsigned char attr;
+- unsigned length;
+- unsigned long long lun;
+- unsigned tag;
+- unsigned trans_len;
+- unsigned bidi_trans_len;
+- unsigned CmdSN;
+- unsigned ExpStatSN;
+- unsigned char *cdb;
+- unsigned char *ext_cdb;
+- unsigned char *ahs;
+- unsigned char ahs_len;
+- unsigned char *send_data;
+- int send_sg_len;
+- unsigned char *recv_data;
+- int recv_sg_len;
+- unsigned char status;
+- unsigned bytes_sent;
+- unsigned bytes_recv;
++ int32_t immediate;
++ int32_t final;
++ int32_t input;
++ int32_t output;
++ uint8_t attr;
++ uint32_t length;
++ uint64_t lun;
++ uint32_t tag;
++ uint32_t trans_len;
++ uint32_t bidi_trans_len;
++ uint32_t CmdSN;
++ uint32_t ExpStatSN;
++ uint8_t *cdb;
++ uint8_t *ext_cdb;
++ uint8_t *ahs;
++ uint8_t ahs_len;
++ uint8_t *send_data;
++ int32_t send_sg_len;
++ uint8_t *recv_data;
++ int32_t recv_sg_len;
++ uint8_t status;
++ uint32_t bytes_sent;
++ uint32_t bytes_recv;
+ } ISCSI_SCSI_CMD_T;
+
+ int iscsi_scsi_cmd_encap(unsigned char *header, ISCSI_SCSI_CMD_T *cmd);
+@@ -381,23 +381,23 @@
+
+
+ typedef struct iscsi_scsi_rsp_args_t {
+- int bidi_overflow;
+- int bidi_underflow;
+- int overflow;
+- int underflow;
+-
+-
+- unsigned char response;
+- unsigned char status;
+- unsigned ahs_len;
+- unsigned length;
+- unsigned tag;
+- unsigned StatSN;
+- unsigned ExpCmdSN;
+- unsigned MaxCmdSN;
+- unsigned ExpDataSN;
+- unsigned bidi_res_cnt;
+- unsigned basic_res_cnt;
++ int32_t bidi_overflow;
++ int32_t bidi_underflow;
++ int32_t overflow;
++ int32_t underflow;
++
++
++ uint8_t response;
++ uint8_t status;
++ uint32_t ahs_len;
++ uint32_t length;
++ uint32_t tag;
++ uint32_t StatSN;
++ uint32_t ExpCmdSN;
++ uint32_t MaxCmdSN;
++ uint32_t ExpDataSN;
++ uint32_t bidi_res_cnt;
++ uint32_t basic_res_cnt;
+ } ISCSI_SCSI_RSP_T;
+
+ int iscsi_scsi_rsp_encap(unsigned char *header, ISCSI_SCSI_RSP_T *rsp);
+@@ -410,16 +410,16 @@
+
+
+ typedef struct iscsi_r2t_args_t {
+- unsigned AHSlength;
+- unsigned long long lun;
+- unsigned tag;
+- unsigned transfer_tag;
+- unsigned StatSN;
+- unsigned ExpCmdSN;
+- unsigned MaxCmdSN;
+- unsigned R2TSN;
+- unsigned offset;
+- unsigned length;
++ uint32_t AHSlength;
++ uint64_t lun;
++ uint32_t tag;
++ uint32_t transfer_tag;
++ uint32_t StatSN;
++ uint32_t ExpCmdSN;
++ uint32_t MaxCmdSN;
++ uint32_t R2TSN;
++ uint32_t offset;
++ uint32_t length;
+ } ISCSI_R2T_T;
+
+ int iscsi_r2t_encap(unsigned char *header, ISCSI_R2T_T *cmd);
+@@ -432,14 +432,14 @@
+
+
+ typedef struct iscsi_write_data_args_t {
+- int final;
+- unsigned length;
+- unsigned long long lun;
+- unsigned tag;
+- unsigned transfer_tag;
+- unsigned ExpStatSN;
+- unsigned DataSN;
+- unsigned offset;
++ int32_t final;
++ uint32_t length;
++ uint64_t lun;
++ uint32_t tag;
++ uint32_t transfer_tag;
++ uint32_t ExpStatSN;
++ uint32_t DataSN;
++ uint32_t offset;
+ } ISCSI_WRITE_DATA_T;
+
+ int iscsi_write_data_encap(unsigned char *header, ISCSI_WRITE_DATA_T *cmd);
+@@ -452,22 +452,22 @@
+
+
+ typedef struct iscsi_read_data_args_t {
+- int final;
+- int ack;
+- int overflow;
+- int underflow;
+- int S_bit;
+- unsigned char status;
+- unsigned length;
+- unsigned long long lun;
+- unsigned task_tag;
+- unsigned transfer_tag;
+- unsigned StatSN;
+- unsigned ExpCmdSN;
+- unsigned MaxCmdSN;
+- unsigned DataSN;
+- unsigned offset;
+- unsigned res_count;
++ int32_t final;
++ int32_t ack;
++ int32_t overflow;
++ int32_t underflow;
++ int32_t S_bit;
++ uint8_t status;
++ uint32_t length;
++ uint64_t lun;
++ uint32_t task_tag;
++ uint32_t transfer_tag;
++ uint32_t StatSN;
++ uint32_t ExpCmdSN;
++ uint32_t MaxCmdSN;
++ uint32_t DataSN;
++ uint32_t offset;
++ uint32_t res_count;
+ } ISCSI_READ_DATA_T;
+
+ int iscsi_read_data_encap(unsigned char *header, ISCSI_READ_DATA_T *cmd);
+@@ -479,12 +479,12 @@
+ */
+
+ typedef struct iscsi_reject_args_t {
+- unsigned char reason;
+- unsigned length;
+- unsigned StatSN;
+- unsigned ExpCmdSN;
+- unsigned MaxCmdSN;
+- unsigned DataSN;
++ uint8_t reason;
++ uint32_t length;
++ uint32_t StatSN;
++ uint32_t ExpCmdSN;
++ uint32_t MaxCmdSN;
++ uint32_t DataSN;
+ char *header;
+
+ } ISCSI_REJECT_T;
+@@ -497,16 +497,20 @@
+ */
+
+ typedef struct iscsi_async_msg_args_t {
+- unsigned char AHSlength;
+- unsigned long long lun;
+- unsigned StatSN;
+- unsigned ExpCmdSN;
+- unsigned MaxCmdSN;
+- unsigned length;
+- unsigned char AsyncEvent;
+- unsigned char AsyncVCode;
++ uint8_t AHSlength;
++ uint64_t lun;
++ uint32_t StatSN;
++ uint32_t ExpCmdSN;
++ uint32_t MaxCmdSN;
++ uint32_t length;
++ uint8_t AsyncEvent;
++ uint8_t AsyncVCode;
+ } ISCSI_AMSG_T;
+
+ int iscsi_amsg_decap(unsigned char *header, ISCSI_AMSG_T *msg);
+
++#ifndef SOL_TCP
++#define SOL_TCP IPPROTO_TCP
++#endif
++
+ #endif /* ISCSI_H */
diff --git a/devel/intel-iscsi/patches/patch-ab b/devel/intel-iscsi/patches/patch-ab
new file mode 100644
index 00000000000..8e842c2274e
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-ab
@@ -0,0 +1,21 @@
+$NetBSD: patch-ab,v 1.1.1.1 2005/10/30 21:02:57 agc Exp $
+
+--- include/parameters.h 8 Oct 2005 22:21:15 -0000 1.1.1.1
++++ include/parameters.h 8 Oct 2005 22:36:27 -0000 1.2
+@@ -69,11 +69,11 @@
+ * frequently accessed on an active session
+ */
+ typedef struct iscsi_sess_param_t {
+- __u32 max_burst_length;
+- __u32 first_burst_length;
+- __u32 max_data_seg_length;
+- __u8 initial_r2t;
+- __u8 immediate_data;
++ uint32_t max_burst_length;
++ uint32_t first_burst_length;
++ uint32_t max_data_seg_length;
++ uint8_t initial_r2t;
++ uint8_t immediate_data;
+ } ISCSI_SESS_PARAM_T;
+
+ typedef struct iscsi_parameter_t {
diff --git a/devel/intel-iscsi/patches/patch-ac b/devel/intel-iscsi/patches/patch-ac
new file mode 100644
index 00000000000..8a2cb96896e
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-ac
@@ -0,0 +1,22 @@
+$NetBSD: patch-ac,v 1.1.1.1 2005/10/30 21:02:57 agc Exp $
+
+--- /dev/null 1 Jan 1970 00:00:00 -0000
++++ include/scsi_cmd_codes.h 8 Oct 2005 23:08:56 -0000 1.1
+@@ -0,0 +1,17 @@
++/* taken from http://www.arkeia.com/resources/scsi_rsc.html */
++
++#ifndef SCSI_CMD_CODES_H_
++#define SCSI_CMD_CODES_H_
++
++enum {
++ TEST_UNIT_READY = 0x00,
++ WRITE_6 = 0x06,
++ READ_6 = 0x08,
++ INQUIRY = 0x12,
++ READ_CAPACITY = 0x25,
++ READ_10 = 0x28,
++ WRITE_10 = 0x2a,
++ VERIFY = 0x2f
++};
++
++#endif /* !SCSI_CMD_CODES_H_ */
diff --git a/devel/intel-iscsi/patches/patch-ad b/devel/intel-iscsi/patches/patch-ad
new file mode 100644
index 00000000000..54cca6dbe2d
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-ad
@@ -0,0 +1,200 @@
+$NetBSD: patch-ad,v 1.1.1.1 2005/10/30 21:02:57 agc Exp $
+
+--- include/util.h 8 Oct 2005 22:21:15 -0000 1.1.1.1
++++ include/util.h 10 Oct 2005 21:43:03 -0000 1.4
+@@ -33,17 +33,19 @@
+
+ #ifndef _UTIL_H_
+ #define _UTIL_H_
+-#ifdef __KERNEL__
+-#include <linux/smp_lock.h>
+-#else
++
++#include <sys/types.h>
++#include <sys/uio.h>
++#include <sys/socket.h>
++
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <pthread.h>
+ #include <unistd.h>
+-#include <sys/uio.h>
+-#include <sys/socket.h>
+ #include <fcntl.h>
++
++#ifdef __linux__
+ #include <linux/types.h>
+ #endif
+
+@@ -51,21 +53,21 @@
+ *
+ */
+
+-#define HTONLL6(x) (uint64_t) \
+- ( ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x0000ff0000000000uL) >> 40)) \
+- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x000000ff00000000uL) >> 24)) \
+- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x00000000ff000000uL) >> 8)) \
+- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x0000000000ff0000uL) << 8)) \
+- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x000000000000ff00uL) << 24)) \
+- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x00000000000000ffuL) << 40)))
+-
+-#define NTOHLL6(x) (uint64_t) \
+- ( ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x0000ff0000000000uL) >> 40)) \
+- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x000000ff00000000uL) >> 24)) \
+- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x00000000ff000000uL) >> 8)) \
+- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x0000000000ff0000uL) << 8)) \
+- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x000000000000ff00uL) << 24)) \
+- | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x00000000000000ffuL) << 40)))
++#define ISCSI_HTONLL6(x) (uint64_t) \
++ ( ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x0000ff0000000000uLL) >> 40)) \
++ | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x000000ff00000000uLL) >> 24)) \
++ | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x00000000ff000000uLL) >> 8)) \
++ | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x0000000000ff0000uLL) << 8)) \
++ | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x000000000000ff00uLL) << 24)) \
++ | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x00000000000000ffuLL) << 40)))
++
++#define ISCSI_NTOHLL6(x) (uint64_t) \
++ ( ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x0000ff0000000000uLL) >> 40)) \
++ | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x000000ff00000000uLL) >> 24)) \
++ | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x00000000ff000000uLL) >> 8)) \
++ | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x0000000000ff0000uLL) << 8)) \
++ | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x000000000000ff00uLL) << 24)) \
++ | ((uint64_t)( ((uint64_t)(x) & (uint64_t)0x00000000000000ffuLL) << 40)))
+
+ /*
+ * Debugging Levels
+@@ -105,9 +107,10 @@
+ * in Makefile.
+ */
+
+-// static unsigned iscsi_debug_level = TRACE_OSD;
+-// static unsigned iscsi_debug_level = TRACE_ALL;
+-static unsigned iscsi_debug_level = TRACE_SCSI_CMD;
++/* static unsigned iscsi_debug_level = TRACE_OSD; */
++/* static unsigned iscsi_debug_level = TRACE_ALL; */
++/* static unsigned iscsi_debug_level = TRACE_SCSI_CMD; */
++static unsigned iscsi_debug_level = 0;
+
+ /*
+ * Debugging Functions
+@@ -161,77 +164,68 @@
+ * Byte Order
+ */
+
+-#include <asm/byteorder.h>
+-#include <byteswap.h>
++#ifdef __linux__
++# include <asm/byteorder.h>
++# include <byteswap.h>
++
++# ifdef __KERNEL__
++# ifndef __BYTE_ORDER
++# ifdef __BIG_ENDIAN
++# define __BYTE_ORDER __BIG_ENDIAN
++# endif
++# ifdef __LITTLE_ENDIAN
++# define __BYTE_ORDER __LITTLE_ENDIAN
++# endif
++# endif
++# endif
+
+-#ifdef __KERNEL__
+-#ifndef __BYTE_ORDER
+-#ifdef __BIG_ENDIAN
+-#define __BYTE_ORDER __BIG_ENDIAN
+-#endif
+-#ifdef __LITTLE_ENDIAN
+-#define __BYTE_ORDER __LITTLE_ENDIAN
+-#endif
+-#endif
+-#endif
+-
+-#if __BYTE_ORDER == __BIG_ENDIAN
++# if __BYTE_ORDER == __BIG_ENDIAN
+ BIG??
+-#define NTOHLL(x) (x)
+-#define HTONLL(x) (x)
+-#define NTOHL(x) (x)
+-#define HTONL(x) (x)
+-#define NTOHS(x) (x)
+-#define HTONS(x) (x)
+-#else
+-#define NTOHLL(x) bswap_64(x)
+-#define HTONLL(x) bswap_64(x)
+-#define NTOHL(x) bswap_32(x)
+-#define HTONL(x) bswap_32(x)
+-#define NTOHS(x) bswap_16(x)
+-#define HTONS(x) bswap_16(x)
+-#endif
++# define ISCSI_NTOHLL(x) (x)
++# define ISCSI_HTONLL(x) (x)
++# define ISCSI_NTOHL(x) (x)
++# define ISCSI_HTONL(x) (x)
++# define ISCSI_NTOHS(x) (x)
++# define ISCSI_HTONS(x) (x)
++# else
++# define ISCSI_NTOHLL(x) bswap_64(x)
++# define ISCSI_HTONLL(x) bswap_64(x)
++# define ISCSI_NTOHL(x) bswap_32(x)
++# define ISCSI_HTONL(x) bswap_32(x)
++# define ISCSI_NTOHS(x) bswap_16(x)
++# define ISCSI_HTONS(x) bswap_16(x)
++# endif
++#else
++# include <machine/endian.h>
++# define __BYTE_ORDER _BYTE_ORDER
++# define __BIG_ENDIAN _BIG_ENDIAN
++# define __LITTLE_ENDIAN _LITTLE_ENDIAN
++# define ISCSI_NTOHLL(x) be64toh(x)
++# define ISCSI_HTONLL(x) htobe64(x)
++# define ISCSI_NTOHL(x) ntohl(x)
++# define ISCSI_HTONL(x) htonl(x)
++# define ISCSI_NTOHS(x) ntohs(x)
++# define ISCSI_HTONS(x) htons(x)
++#endif /* !__linux__ */
++
+
+ /*
+ * printf and printk
+ */
+
+-#ifdef __KERNEL__
+-#define PRINT printk
+-#else
+ #define PRINT printf
+-#endif
+
+ /*
+ * Process ID
+ */
+
+-#ifdef __KERNEL__
+-#define ISCSI_GETPID current->pid
+-#else
+ #define ISCSI_GETPID getpid()
+-#endif
+
+ /*
+ * Sleeping
+ */
+
+-#ifdef __KERNEL__
+-#define ISCSI_SLEEP(N) {unsigned future = jiffies+N*HZ; while (jiffies<future) ISCSI_SPIN;}
+-#else
+ #define ISCSI_SLEEP(N) sleep(N)
+-#endif
+-
+-/*
+- * Kernel Versioning
+- */
+-
+-#ifdef __KERNEL__
+-#if !defined(LINUX_VERSION_CODE)
+-#include <linux/version.h>
+-#endif
+-#define LinuxVersionCode(v, p, s) (((v)<<16)+((p)<<8)+(s))
+-#endif
+
+ /*
+ * Memory
diff --git a/devel/intel-iscsi/patches/patch-ae b/devel/intel-iscsi/patches/patch-ae
new file mode 100644
index 00000000000..2d524ffa2f7
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-ae
@@ -0,0 +1,25 @@
+$NetBSD: patch-ae,v 1.1.1.1 2005/10/30 21:02:57 agc Exp $
+
+--- src/Makefile 8 Oct 2005 22:21:15 -0000 1.1.1.1
++++ src/Makefile 8 Oct 2005 22:24:25 -0000 1.2
+@@ -3,7 +3,6 @@
+ # Compiler Flags. Warning: -O causes problems w/ pthread
+ #
+
+-SRC = /usr/src/linux
+ INCLUDE = ../include
+ BIN = ../bin
+ CFLAGS = -g -O2
+@@ -14,9 +13,9 @@
+
+ CFLAGS_KERN = $(CFLAGS) -D__KERNEL__ -DMODULE -I$(SRC)/include -I$(SRC)/drivers/scsi
+
+-ifeq ($(shell grep 'define CONFIG_MODVERSIONS' $(SRC)/include/linux/autoconf.h | wc -l | sed 's/ //g'),1)
+-CFLAGS_KERN += -DMODVERSIONS -include $(SRC)/include/linux/modversions.h
+-endif
++#ifeq ($(shell grep 'define CONFIG_MODVERSIONS' $(SRC)/include/linux/autoconf.h | wc -l | sed 's/ //g'),1)
++#CFLAGS_KERN += -DMODVERSIONS -include $(SRC)/include/linux/modversions.h
++#endif
+
+ #
+ # Compilation Targets
diff --git a/devel/intel-iscsi/patches/patch-af b/devel/intel-iscsi/patches/patch-af
new file mode 100644
index 00000000000..d18d5b65b6d
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-af
@@ -0,0 +1,55 @@
+$NetBSD: patch-af,v 1.1.1.1 2005/10/30 21:02:57 agc Exp $
+
+--- src/disk.c 8 Oct 2005 22:21:15 -0000 1.1.1.1
++++ src/disk.c 8 Oct 2005 23:37:34 -0000 1.3
+@@ -58,9 +58,15 @@
+ #include <unistd.h>
+ #endif
+ #endif
+-#ifndef FreeBSD
++
++#ifdef __linux__
+ #include <scsi/scsi.h>
+ #endif
++
++#ifdef __NetBSD__
++#include "scsi_cmd_codes.h"
++#endif
++
+ #include "iscsi.h"
+ #include "util.h"
+ #include "device.h"
+@@ -272,8 +278,13 @@
+
+ TRACE(TRACE_SCSI_CMD, "READ_CAPACITY\n");
+ data = args->send_data;
+- *((unsigned *) data) = HTONL(disk_num_blocks-1); // Max LBA
+- *((unsigned *) (data+4)) = HTONL(disk_block_len); // Block len
++ {
++ uint32_t maxLBA;
++
++ maxLBA = (disk_num_blocks - 1); /* Max LBA */
++ *((unsigned *) data) = ISCSI_HTONL(maxLBA); /* Max LBA */
++ }
++ *((unsigned *) (data+4)) = ISCSI_HTONL(disk_block_len); /* Block len */
+ args->input = 8;
+ args->length = 8;
+ args->status = 0;
+@@ -281,7 +292,7 @@
+
+ case WRITE_6:
+
+- lba = NTOHL(*((unsigned *)cdb))&0x001fffff;
++ lba = ISCSI_NTOHL(*((unsigned *)cdb))&0x001fffff;
+ len = cdb[4];
+ if (!len) len = 256;
+ TRACE(TRACE_SCSI_CMD, "WRITE_6(lba %u, len %u blocks)\n", lba, len);
+@@ -295,7 +306,7 @@
+
+ case READ_6:
+
+- lba = NTOHL(*((unsigned *)cdb))&0x001fffff;
++ lba = ISCSI_NTOHL(*((unsigned *)cdb))&0x001fffff;
+ len = cdb[4];
+ if (!len) len = 256;
+ TRACE(TRACE_SCSI_CMD, "READ_6(lba %u, len %u blocks)\n", lba, len);
diff --git a/devel/intel-iscsi/patches/patch-ag b/devel/intel-iscsi/patches/patch-ag
new file mode 100644
index 00000000000..6ba7140418c
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-ag
@@ -0,0 +1,13 @@
+$NetBSD: patch-ag,v 1.1.1.1 2005/10/30 21:02:57 agc Exp $
+
+--- src/driver.c 8 Oct 2005 22:21:15 -0000 1.1.1.1
++++ src/driver.c 8 Oct 2005 23:37:34 -0000 1.2
+@@ -396,7 +396,7 @@
+ return -1;
+ }
+ memset(scsi_cmd->ahs, 0, 4);
+- *((uint16_t *)scsi_cmd->ahs) = HTONS(SCpnt->cmd_len-15); // AHS length
++ *((uint16_t *)scsi_cmd->ahs) = ISCSI_HTONS(SCpnt->cmd_len-15); // AHS length
+ scsi_cmd->ahs[2] = 0x01; // Type
+ memcpy(scsi_cmd->ahs+4, SCpnt->cmnd+16, SCpnt->cmd_len-16); // Copy in remaining CDB
+ scsi_cmd->ahs_len = SCpnt->cmd_len-16;
diff --git a/devel/intel-iscsi/patches/patch-ah b/devel/intel-iscsi/patches/patch-ah
new file mode 100644
index 00000000000..3d5e550033b
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-ah
@@ -0,0 +1,87 @@
+$NetBSD: patch-ah,v 1.1.1.1 2005/10/30 21:02:57 agc Exp $
+
+--- src/initiator.c 8 Oct 2005 22:21:15 -0000 1.1.1.1
++++ src/initiator.c 8 Oct 2005 23:52:25 -0000
+@@ -47,21 +47,27 @@
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stdio.h>
+-#include <linux/fs.h>
+
+
+ #endif
+
+-#ifndef FreeBSD
++#ifdef __linux__
++#include <linux/fs.h>
+ #include <scsi/scsi.h>
+ #endif
+
++#ifdef __NetBSD__
++#include "scsi_cmd_codes.h"
++#endif
++
+ #include "iscsi.h"
+ #include "initiator.h"
+
+-#ifdef __KERNEL__
+-#include <linux/fs.h>
+-#include <linux/module.h>
++#ifdef __linux__
++# ifdef __KERNEL__
++# include <linux/fs.h>
++# include <linux/module.h>
++# endif
+ #endif
+
+ /*
+@@ -76,8 +82,8 @@
+
+ static INITIATOR_TARGET_T g_target[CONFIG_INITIATOR_NUM_TARGETS] = {
+
+-// {"150.0.1.1", ISCSI_PORT, "", NULL, 0},
+- {"151.0.1.1", ISCSI_PORT, "", NULL, 0}};
++/* {"150.0.1.1", ISCSI_PORT, "", NULL, 0}, */
++ {"127.0.0.1", ISCSI_PORT, "", NULL, 0}};
+
+
+ #endif
+@@ -270,7 +276,7 @@
+ }
+
+ # else /* not KERNEL */
+- if (!strcmp(g_target[0].ip,"151.0.1.1")) {
++ if (!strcmp(g_target[0].ip,"127.0.0.1")) {
+ int i, num_targets = -1;
+ printf("No target IP address set, enter number of targets or 0 to exit\n");fflush(stdout);
+ scanf("%d",&num_targets);
+@@ -606,9 +612,10 @@
+
+ TRACE(TRACE_ISCSI_DEBUG, "enqueing text command to tx worker %llu\n", sess->isid);
+ ISCSI_LOCK_ELSE(&wait.mutex, FFN_ERROR);
++ ISCSI_LOCK_ELSE(&sess->tx_worker.work_mutex, FFN_ERROR);
+ if (iscsi_queue_insert(&sess->tx_queue, cmd)==-1) {
+ TRACE_ERROR("iscsi_queue_insert() failed\n");
+- FFN_ERROR;
++ ISCSI_UNLOCK_ELSE(&wait.mutex, FFN_ERROR);
+ }
+ ISCSI_SIGNAL_ELSE(&sess->tx_worker.work_cond, FFN_ERROR);
+ ISCSI_UNLOCK_ELSE(&sess->tx_worker.work_mutex, FFN_ERROR);
+@@ -1362,7 +1369,7 @@
+ // Get cmd ptr from hash table
+
+ if ((ISCSI_OPCODE(header)!=ISCSI_REJECT)&&(ISCSI_OPCODE(header)!=ISCSI_ASYNC)) {
+- tag = NTOHL(*((unsigned *)(header+16)));
++ tag = ISCSI_NTOHL(*((unsigned *)(header+16)));
+ if (tag != 0xffffffff) {
+
+ /* remove command from g_tag_hash, cmd is local so we only need to lock the
+@@ -2374,7 +2381,7 @@
+ TRACE_ERROR("iscsi_sock_msg() failed\n");
+ return -1;
+ }
+- tag = NTOHL(*((unsigned *)(bad_header+16)));
++ tag = ISCSI_NTOHL(*((unsigned *)(bad_header+16)));
+ TRACE_ERROR("REJECT PDU: tag 0x%x (reason 0x%x)\n", tag, reject.reason);
+ if (tag != 0xffffffff) {
+ if ((cmd = hash_remove(&g_tag_hash, tag))==NULL) {
diff --git a/devel/intel-iscsi/patches/patch-ai b/devel/intel-iscsi/patches/patch-ai
new file mode 100644
index 00000000000..32103524d0c
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-ai
@@ -0,0 +1,1203 @@
+$NetBSD: patch-ai,v 1.1.1.1 2005/10/30 21:02:57 agc Exp $
+
+--- src/iscsi.c 8 Oct 2005 22:21:15 -0000 1.1.1.1
++++ src/iscsi.c 8 Oct 2005 23:37:34 -0000 1.3
+@@ -62,16 +62,16 @@
+
+ memset(header, 0, ISCSI_HEADER_LEN);
+
+- header[0] |= ISCSI_TASK_CMD; // Opcode
+- if (cmd->immediate) header[0] |= 0x40; // Immediate bit
+- header[1] = cmd->function&0x80; // Function
+- *((unsigned long long*)(header+8)) = HTONLL6(cmd->lun); // LUN
+- *((unsigned *)(header+16)) = HTONL(cmd->tag); // Tag
+- *((unsigned *)(header+20)) = HTONL(cmd->ref_tag); // Reference Tag
+- *((unsigned *)(header+24)) = HTONL(cmd->CmdSN); // CmdSN
+- *((unsigned *)(header+28)) = HTONL(cmd->ExpStatSN); // ExpStatSN
+- *((unsigned *)(header+32)) = HTONL(cmd->RefCmdSN); // RefCmdSN
+- *((unsigned *)(header+36)) = HTONL(cmd->ExpDataSN); // ExpDataSN
++ header[0] |= ISCSI_TASK_CMD; /* Opcode */
++ if (cmd->immediate) header[0] |= 0x40; /* Immediate bit */
++ header[1] = cmd->function&0x80; /* Function */
++ *((uint64_t*)(header+8)) = ISCSI_HTONLL6(cmd->lun); /* LUN */
++ *((uint32_t *)(header+16)) = ISCSI_HTONL(cmd->tag); /* Tag */
++ *((uint32_t *)(header+20)) = ISCSI_HTONL(cmd->ref_tag); /* Reference Tag */
++ *((uint32_t *)(header+24)) = ISCSI_HTONL(cmd->CmdSN); /* CmdSN */
++ *((uint32_t *)(header+28)) = ISCSI_HTONL(cmd->ExpStatSN); /* ExpStatSN */
++ *((uint32_t *)(header+32)) = ISCSI_HTONL(cmd->RefCmdSN); /* RefCmdSN */
++ *((uint32_t *)(header+36)) = ISCSI_HTONL(cmd->ExpDataSN); /* ExpDataSN */
+
+ return 0;
+ }
+@@ -80,22 +80,22 @@
+
+ RETURN_NOT_EQUAL("Opcode", ISCSI_OPCODE(header), ISCSI_TASK_CMD, NO_CLEANUP, -1);
+
+- cmd->immediate = ((header[0]&0x40)==0x40); // Immediate bit
+- cmd->function = header[1]&0x80; // Function
+- cmd->lun = NTOHLL6(*((unsigned long long *)(header+8))); // LUN
+- cmd->tag = NTOHL(*((unsigned *)(header+16))); // Tag
+- cmd->ref_tag = NTOHL(*((unsigned *)(header+20))); // Reference Tag
+- cmd->CmdSN = NTOHL(*((unsigned *)(header+24))); // CmdSN
+- cmd->ExpStatSN = NTOHL(*((unsigned *)(header+28))); // ExpStatSN
+- cmd->RefCmdSN = NTOHL(*((unsigned *)(header+32))); // RefCmdSN
+- cmd->ExpDataSN = NTOHL(*((unsigned *)(header+36))); // ExpDataSN
++ cmd->immediate = ((header[0]&0x40)==0x40); /* Immediate bit */
++ cmd->function = header[1]&0x80; /* Function */
++ cmd->lun = ISCSI_NTOHLL6(*((uint64_t *)(header+8))); /* LUN */
++ cmd->tag = ISCSI_NTOHL(*((uint32_t *)(header+16))); /* Tag */
++ cmd->ref_tag = ISCSI_NTOHL(*((uint32_t *)(header+20))); /* Reference Tag */
++ cmd->CmdSN = ISCSI_NTOHL(*((uint32_t *)(header+24))); /* CmdSN */
++ cmd->ExpStatSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpStatSN */
++ cmd->RefCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+32))); /* RefCmdSN */
++ cmd->ExpDataSN = ISCSI_NTOHL(*((uint32_t *)(header+36))); /* ExpDataSN */
+
+ RETURN_NOT_EQUAL("Byte 1, bit 0", header[1]&0x80, 0x80, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 2", header[2], 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 3", header[3], 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 4-7", *((unsigned *)(header+4)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 40-43", *((unsigned *)(header+40)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 44-47", *((unsigned *)(header+44)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 4-7", *((uint32_t *)(header+4)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *)(header+40)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *)(header+44)), 0, NO_CLEANUP, 1);
+
+ TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate);
+ TRACE(TRACE_ISCSI_ARGS, "Function: %u\n", cmd->function);
+@@ -115,6 +115,7 @@
+ */
+
+ int iscsi_task_rsp_encap(unsigned char *header, ISCSI_TASK_RSP_T *rsp) {
++ uint32_t length;
+
+ TRACE(TRACE_ISCSI_ARGS, "Response: %u\n", rsp->response);
+ TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", rsp->length);
+@@ -125,14 +126,15 @@
+
+ memset(header, 0, ISCSI_HEADER_LEN);
+
+- header[0] |= ISCSI_TASK_RSP; // Opcode
+- header[1] |= 0x80; // Byte 1 bit 0
+- header[2] = rsp->response; // Response
+- *((unsigned *)(header+4)) = HTONL(rsp->length&0x00ffffff); // Length
+- *((unsigned *)(header+16)) = HTONL(rsp->tag); // Tag
+- *((unsigned *)(header+24)) = HTONL(rsp->StatSN); // StatSN
+- *((unsigned *)(header+28)) = HTONL(rsp->ExpCmdSN); // ExpCmdSN
+- *((unsigned *)(header+32)) = HTONL(rsp->MaxCmdSN); // MaxCmdSN
++ header[0] |= ISCSI_TASK_RSP; /* Opcode */
++ header[1] |= 0x80; /* Byte 1 bit 0 */
++ header[2] = rsp->response; /* Response */
++ length = (rsp->length & 0x00ffffff);
++ *((uint32_t *)(header+4)) = ISCSI_HTONL(length); /* Length */
++ *((uint32_t *)(header+16)) = ISCSI_HTONL(rsp->tag); /* Tag */
++ *((uint32_t *)(header+24)) = ISCSI_HTONL(rsp->StatSN); /* StatSN */
++ *((uint32_t *)(header+28)) = ISCSI_HTONL(rsp->ExpCmdSN); /* ExpCmdSN */
++ *((uint32_t *)(header+32)) = ISCSI_HTONL(rsp->MaxCmdSN); /* MaxCmdSN */
+
+ return 0;
+ }
+@@ -141,22 +143,22 @@
+
+ RETURN_NOT_EQUAL("Opcode", ISCSI_OPCODE(header), ISCSI_TASK_RSP, NO_CLEANUP, 1);
+
+- rsp->response = header[2]; // Response
+- rsp->tag = NTOHL(*((unsigned *)(header+16))); // Tag
+- rsp->StatSN = NTOHL(*((unsigned *)(header+24))); // StatSN
+- rsp->ExpCmdSN = NTOHL(*((unsigned *)(header+28))); // ExpCmdSN
+- rsp->MaxCmdSN = NTOHL(*((unsigned *)(header+32))); // MaxCmdSN
++ rsp->response = header[2]; /* Response */
++ rsp->tag = ISCSI_NTOHL(*((uint32_t *)(header+16))); /* Tag */
++ rsp->StatSN = ISCSI_NTOHL(*((uint32_t *)(header+24))); /* StatSN */
++ rsp->ExpCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpCmdSN */
++ rsp->MaxCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+32))); /* MaxCmdSN */
+
+ RETURN_NOT_EQUAL("Byte 0, bits 0-1", header[0]&0x00, 0x00, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 1, bit 0", header[1]&0x80, 0x80, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 3", header[3], 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 4-7", *((unsigned *)(header+4)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 8-11", *((unsigned *)(header+8)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 12-15", *((unsigned *)(header+12)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 20-23", *((unsigned *)(header+23)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 36-39", *((unsigned *)(header+36)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 40-43", *((unsigned *)(header+40)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 44-47", *((unsigned *)(header+44)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 4-7", *((uint32_t *)(header+4)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 8-11", *((uint32_t *)(header+8)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 12-15", *((uint32_t *)(header+12)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 20-23", *((uint32_t *)(header+23)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 36-39", *((uint32_t *)(header+36)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *)(header+40)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *)(header+44)), 0, NO_CLEANUP, 1);
+
+ TRACE(TRACE_ISCSI_ARGS, "Response: %u\n", rsp->response);
+ TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", rsp->tag);
+@@ -172,6 +174,7 @@
+ */
+
+ int iscsi_nop_out_encap(unsigned char *header, ISCSI_NOP_OUT_T *cmd) {
++ uint32_t length;
+
+ TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate);
+ TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length);
+@@ -183,15 +186,16 @@
+
+ memset(header, 0, ISCSI_HEADER_LEN);
+
+- header[0] = ISCSI_NOP_OUT; // Opcode
+- if (cmd->immediate) header[0] |= 0x40; // Immediate bit
+- header[1] |= 0x80; // Byte 1 bit 0 and Reserved
+- *((unsigned *)(header+4)) = HTONL(cmd->length&0x00ffffff); // Length
+- *((unsigned long long*)(header+8)) = HTONLL6(cmd->lun); // LUN
+- *((unsigned *)(header+16)) = HTONL(cmd->tag); // Tag
+- *((unsigned *)(header+20)) = HTONL(cmd->transfer_tag); // Target Transfer Tag
+- *((unsigned *)(header+24)) = HTONL(cmd->CmdSN); // CmdSN
+- *((unsigned *)(header+28)) = HTONL(cmd->ExpStatSN); // ExpStatSN
++ header[0] = ISCSI_NOP_OUT; /* Opcode */
++ if (cmd->immediate) header[0] |= 0x40; /* Immediate bit */
++ header[1] |= 0x80; /* Byte 1 bit 0 and Reserved */
++ length = (cmd->length & 0x00ffffff); /* Length */
++ *((uint32_t *)(header+4)) = ISCSI_HTONL(length); /* Length */
++ *((uint64_t*)(header+8)) = ISCSI_HTONLL6(cmd->lun); /* LUN */
++ *((uint32_t *)(header+16)) = ISCSI_HTONL(cmd->tag); /* Tag */
++ *((uint32_t *)(header+20)) = ISCSI_HTONL(cmd->transfer_tag); /* Target Transfer Tag */
++ *((uint32_t *)(header+24)) = ISCSI_HTONL(cmd->CmdSN); /* CmdSN */
++ *((uint32_t *)(header+28)) = ISCSI_HTONL(cmd->ExpStatSN); /* ExpStatSN */
+
+ return 0;
+ }
+@@ -200,22 +204,22 @@
+
+ RETURN_NOT_EQUAL("Opcode", ISCSI_OPCODE(header), ISCSI_NOP_OUT, NO_CLEANUP, 1);
+
+- cmd->immediate = ((header[0]&0x40)==0x40); // Immediate bit
+- cmd->length = NTOHL(*((unsigned *)(header+4))); // Length
+- cmd->lun = NTOHLL6(*((unsigned long long *)(header+8))); // LUN
+- cmd->tag = NTOHL(*((unsigned *)(header+16))); // Tag
+- cmd->transfer_tag = NTOHL(*((unsigned *)(header+20))); // Target Tranfer Tag
+- cmd->CmdSN = NTOHL(*((unsigned *)(header+24))); // CmdSN
+- cmd->ExpStatSN = NTOHL(*((unsigned *)(header+28))); // ExpStatSN
++ cmd->immediate = ((header[0]&0x40)==0x40); /* Immediate bit */
++ cmd->length = ISCSI_NTOHL(*((uint32_t *)(header+4))); /* Length */
++ cmd->lun = ISCSI_NTOHLL6(*((uint64_t *)(header+8))); /* LUN */
++ cmd->tag = ISCSI_NTOHL(*((uint32_t *)(header+16))); /* Tag */
++ cmd->transfer_tag = ISCSI_NTOHL(*((uint32_t *)(header+20))); /* Target Tranfer Tag */
++ cmd->CmdSN = ISCSI_NTOHL(*((uint32_t *)(header+24))); /* CmdSN */
++ cmd->ExpStatSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpStatSN */
+
+ RETURN_NOT_EQUAL("Byte 1", header[1], 0x80, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 2", header[2], 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 3", header[3], 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 4", header[4], 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 32-35", *((unsigned *)(header+32)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 36-39", *((unsigned *)(header+36)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 40-43", *((unsigned *)(header+40)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 44-47", *((unsigned *)(header+44)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 32-35", *((uint32_t *)(header+32)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 36-39", *((uint32_t *)(header+36)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *)(header+40)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *)(header+44)), 0, NO_CLEANUP, 1);
+
+ TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate);
+ TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length);
+@@ -234,6 +238,8 @@
+
+ int iscsi_nop_in_encap(unsigned char *header, ISCSI_NOP_IN_T *cmd) {
+
++ uint32_t length;
++
+ TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+ TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag);
+@@ -244,15 +250,16 @@
+
+ memset(header, 0, ISCSI_HEADER_LEN);
+
+- header[0] = 0x00|ISCSI_NOP_IN; // Opcode
+- header[1] |= 0x80; // Reserved
+- *((unsigned *)(header+4)) = HTONL(cmd->length&0x00ffffff); // Length
+- *((unsigned long long*)(header+8)) = HTONLL6(cmd->lun); // LUN
+- *((unsigned *)(header+16)) = HTONL(cmd->tag); // Tag
+- *((unsigned *)(header+20)) = HTONL(cmd->transfer_tag); // Target Transfer Tag
+- *((unsigned *)(header+24)) = HTONL(cmd->StatSN); // StatSN
+- *((unsigned *)(header+28)) = HTONL(cmd->ExpCmdSN); // ExpCmdSN
+- *((unsigned *)(header+32)) = HTONL(cmd->MaxCmdSN); // MaxCmdSN
++ header[0] = 0x00|ISCSI_NOP_IN; /* Opcode */
++ header[1] |= 0x80; /* Reserved */
++ length = (cmd->length & 0x00ffffff); /* Length */
++ *((uint32_t *)(header+4)) = ISCSI_HTONL(length); /* Length */
++ *((uint64_t*)(header+8)) = ISCSI_HTONLL6(cmd->lun); /* LUN */
++ *((uint32_t *)(header+16)) = ISCSI_HTONL(cmd->tag); /* Tag */
++ *((uint32_t *)(header+20)) = ISCSI_HTONL(cmd->transfer_tag); /* Target Transfer Tag */
++ *((uint32_t *)(header+24)) = ISCSI_HTONL(cmd->StatSN); /* StatSN */
++ *((uint32_t *)(header+28)) = ISCSI_HTONL(cmd->ExpCmdSN); /* ExpCmdSN */
++ *((uint32_t *)(header+32)) = ISCSI_HTONL(cmd->MaxCmdSN); /* MaxCmdSN */
+
+ return 0;
+ }
+@@ -263,22 +270,22 @@
+
+
+
+- cmd->length = NTOHL(*((unsigned *)(header+4))); // Length
+- cmd->lun = NTOHLL6(*((unsigned long long *)(header+8))); // LUN
+- cmd->tag = NTOHL(*((unsigned *)(header+16))); // Tag
+- cmd->transfer_tag = NTOHL(*((unsigned *)(header+20))); // Target Transfer Tag
+- cmd->StatSN = NTOHL(*((unsigned *)(header+24))); // StatSN
+- cmd->ExpCmdSN = NTOHL(*((unsigned *)(header+28))); // ExpCmdSN
+- cmd->MaxCmdSN = NTOHL(*((unsigned *)(header+32))); // MaxCmdSN
++ cmd->length = ISCSI_NTOHL(*((uint32_t *)(header+4))); /* Length */
++ cmd->lun = ISCSI_NTOHLL6(*((uint64_t *)(header+8))); /* LUN */
++ cmd->tag = ISCSI_NTOHL(*((uint32_t *)(header+16))); /* Tag */
++ cmd->transfer_tag = ISCSI_NTOHL(*((uint32_t *)(header+20))); /* Target Transfer Tag */
++ cmd->StatSN = ISCSI_NTOHL(*((uint32_t *)(header+24))); /* StatSN */
++ cmd->ExpCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpCmdSN */
++ cmd->MaxCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+32))); /* MaxCmdSN */
+
+ RETURN_NOT_EQUAL("Byte 0, bits 0-1", header[0]&0xc0, 0x00, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 1", header[1], 0x80, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 2", header[2], 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 3", header[3], 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 4", header[4], 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 36-39", *((unsigned *)(header+36)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 40-43", *((unsigned *)(header+40)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 44-47", *((unsigned *)(header+44)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 36-39", *((uint32_t *)(header+36)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *)(header+40)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *)(header+44)), 0, NO_CLEANUP, 1);
+
+ TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+@@ -296,6 +303,8 @@
+
+ int iscsi_text_cmd_encap(unsigned char *header, ISCSI_TEXT_CMD_T *cmd) {
+
++ uint32_t length;
++
+ TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate);
+ TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final);
+ TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", cmd->cont);
+@@ -308,16 +317,17 @@
+
+ memset(header, 0, ISCSI_HEADER_LEN);
+
+- header[0] |= ISCSI_TEXT_CMD; // Opcode
+- if (cmd->immediate) header[0] |= 0x40; // Immediate bit
+- if (cmd->final) header[1] |= 0x80; // Final bit
+- if (cmd->cont) header[1] |= 0x40; // Continue bit
+- *((unsigned *)(header+4)) = HTONL(cmd->length&0x00ffffff); // Length
+- *((unsigned long long*)(header+8)) = HTONLL6(cmd->lun); // LUN
+- *((unsigned *)(header+16)) = HTONL(cmd->tag); // Tag
+- *((unsigned *)(header+20)) = HTONL(cmd->transfer_tag); // Transfer Tag
+- *((unsigned *)(header+24)) = HTONL(cmd->CmdSN); // CmdSN
+- *((unsigned *)(header+28)) = HTONL(cmd->ExpStatSN); // ExpStatSN
++ header[0] |= ISCSI_TEXT_CMD; /* Opcode */
++ if (cmd->immediate) header[0] |= 0x40; /* Immediate bit */
++ if (cmd->final) header[1] |= 0x80; /* Final bit */
++ if (cmd->cont) header[1] |= 0x40; /* Continue bit */
++ length = (cmd->length & 0x00ffffff); /* Length */
++ *((uint32_t *)(header+4)) = ISCSI_HTONL(length); /* Length */
++ *((uint64_t*)(header+8)) = ISCSI_HTONLL6(cmd->lun); /* LUN */
++ *((uint32_t *)(header+16)) = ISCSI_HTONL(cmd->tag); /* Tag */
++ *((uint32_t *)(header+20)) = ISCSI_HTONL(cmd->transfer_tag); /* Transfer Tag */
++ *((uint32_t *)(header+24)) = ISCSI_HTONL(cmd->CmdSN); /* CmdSN */
++ *((uint32_t *)(header+28)) = ISCSI_HTONL(cmd->ExpStatSN); /* ExpStatSN */
+
+ return 0;
+ }
+@@ -326,26 +336,26 @@
+
+ RETURN_NOT_EQUAL("Opcode", ISCSI_OPCODE(header), ISCSI_TEXT_CMD, NO_CLEANUP, 1);
+
+- cmd->immediate = ((header[0]&0x40)==0x40); // Immediate bit
+- cmd->final = ((header[1]&0x80)==0x80); // Final bit
+- cmd->cont = ((header[1]&0x40)==0x40); // Continue bit
+- cmd->length = NTOHL(*((unsigned *)(header+4))); // Length
+- cmd->lun = NTOHLL6(*((unsigned long long *)(header+8))); // LUN
+- cmd->tag = NTOHL(*((unsigned *)(header+16))); // Tag
+- cmd->transfer_tag = NTOHL(*((unsigned *)(header+20))); // Transfer Tag
+- cmd->CmdSN = NTOHL(*((unsigned *)(header+24))); // CmdSN
+- cmd->ExpStatSN = NTOHL(*((unsigned *)(header+28))); // ExpStatSN
++ cmd->immediate = ((header[0]&0x40)==0x40); /* Immediate bit */
++ cmd->final = ((header[1]&0x80)==0x80); /* Final bit */
++ cmd->cont = ((header[1]&0x40)==0x40); /* Continue bit */
++ cmd->length = ISCSI_NTOHL(*((uint32_t *)(header+4))); /* Length */
++ cmd->lun = ISCSI_NTOHLL6(*((uint64_t *)(header+8))); /* LUN */
++ cmd->tag = ISCSI_NTOHL(*((uint32_t *)(header+16))); /* Tag */
++ cmd->transfer_tag = ISCSI_NTOHL(*((uint32_t *)(header+20))); /* Transfer Tag */
++ cmd->CmdSN = ISCSI_NTOHL(*((uint32_t *)(header+24))); /* CmdSN */
++ cmd->ExpStatSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpStatSN */
+
+ RETURN_NOT_EQUAL("Byte 1, Bits 2-7", header[1]&0x00, 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 2", header[2], 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 3", header[3], 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 4", header[4], 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 8-11", *((unsigned *)(header+8)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 12-15", *((unsigned *)(header+12)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 32-35", *((unsigned *)(header+32)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 36-39", *((unsigned *)(header+36)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 40-43", *((unsigned *)(header+40)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 44-47", *((unsigned *)(header+44)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 8-11", *((uint32_t *)(header+8)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 12-15", *((uint32_t *)(header+12)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 32-35", *((uint32_t *)(header+32)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 36-39", *((uint32_t *)(header+36)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *)(header+40)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *)(header+44)), 0, NO_CLEANUP, 1);
+
+ TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate);
+ TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final);
+@@ -366,6 +376,8 @@
+
+ int iscsi_text_rsp_encap(unsigned char *header, ISCSI_TEXT_RSP_T *rsp) {
+
++ uint32_t length;
++
+ TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", rsp->final);
+ TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", rsp->cont);
+ TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", rsp->length);
+@@ -377,16 +389,17 @@
+ TRACE(TRACE_ISCSI_ARGS, "MaxCmdSN: %u\n", rsp->MaxCmdSN);
+
+ memset(header, 0, ISCSI_HEADER_LEN);
+- header[0] |= 0x00|ISCSI_TEXT_RSP; // Opcode
+- if (rsp->final) header[1] |= 0x80; // Final bit
+- if (rsp->cont) header[1] |= 0x40; // Continue
+- *((unsigned *)(header+4)) = HTONL(rsp->length&0x00ffffff); // Length
+- *((unsigned long long*)(header+8)) = HTONLL6(rsp->lun); // LUN
+- *((unsigned *)(header+16)) = HTONL(rsp->tag); // Tag
+- *((unsigned *)(header+20)) = HTONL(rsp->transfer_tag); // Transfer Tag
+- *((unsigned *)(header+24)) = HTONL(rsp->StatSN); // StatSN
+- *((unsigned *)(header+28)) = HTONL(rsp->ExpCmdSN); // ExpCmdSN
+- *((unsigned *)(header+32)) = HTONL(rsp->MaxCmdSN); // MaxCmdSN
++ header[0] |= 0x00|ISCSI_TEXT_RSP; /* Opcode */
++ if (rsp->final) header[1] |= 0x80; /* Final bit */
++ if (rsp->cont) header[1] |= 0x40; /* Continue */
++ length = (rsp->length & 0x00ffffff); /* Length */
++ *((uint32_t *)(header+4)) = ISCSI_HTONL(length); /* Length */
++ *((uint64_t*)(header+8)) = ISCSI_HTONLL6(rsp->lun); /* LUN */
++ *((uint32_t *)(header+16)) = ISCSI_HTONL(rsp->tag); /* Tag */
++ *((uint32_t *)(header+20)) = ISCSI_HTONL(rsp->transfer_tag); /* Transfer Tag */
++ *((uint32_t *)(header+24)) = ISCSI_HTONL(rsp->StatSN); /* StatSN */
++ *((uint32_t *)(header+28)) = ISCSI_HTONL(rsp->ExpCmdSN); /* ExpCmdSN */
++ *((uint32_t *)(header+32)) = ISCSI_HTONL(rsp->MaxCmdSN); /* MaxCmdSN */
+
+ return 0;
+ }
+@@ -395,25 +408,25 @@
+
+ RETURN_NOT_EQUAL("Opcode", ISCSI_OPCODE(header), ISCSI_TEXT_RSP, NO_CLEANUP, 1);
+
+- rsp->final = ((header[1]&0x80)==0x80); // Final bit
+- rsp->cont = ((header[1]&0x40)==0x40); // Continue bit
+- rsp->length = NTOHL(*((unsigned *)(header+4))); // Length
+- rsp->lun = NTOHLL6(*((unsigned long long *)(header+8))); // LUN
+- rsp->tag = NTOHL(*((unsigned *)(header+16))); // Tag
+- rsp->transfer_tag = NTOHL(*((unsigned *)(header+20))); // Transfer Tag
+- rsp->StatSN = NTOHL(*((unsigned *)(header+24))); // StatSN
+- rsp->ExpCmdSN = NTOHL(*((unsigned *)(header+28))); // ExpCmdSN
+- rsp->MaxCmdSN = NTOHL(*((unsigned *)(header+32))); // MaxCmdSN
++ rsp->final = ((header[1]&0x80)==0x80); /* Final bit */
++ rsp->cont = ((header[1]&0x40)==0x40); /* Continue bit */
++ rsp->length = ISCSI_NTOHL(*((uint32_t *)(header+4))); /* Length */
++ rsp->lun = ISCSI_NTOHLL6(*((uint64_t *)(header+8))); /* LUN */
++ rsp->tag = ISCSI_NTOHL(*((uint32_t *)(header+16))); /* Tag */
++ rsp->transfer_tag = ISCSI_NTOHL(*((uint32_t *)(header+20))); /* Transfer Tag */
++ rsp->StatSN = ISCSI_NTOHL(*((uint32_t *)(header+24))); /* StatSN */
++ rsp->ExpCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpCmdSN */
++ rsp->MaxCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+32))); /* MaxCmdSN */
+
+ RETURN_NOT_EQUAL("Byte 1, Bits 2-7", header[1]&0x3f, 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 2", header[2], 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 3", header[3], 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 4", header[4], 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 8-11", *((unsigned *)(header+8)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 12-15", *((unsigned *)(header+12)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 36-39", *((unsigned *)(header+36)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 40-43", *((unsigned *)(header+40)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 44-47", *((unsigned *)(header+44)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 8-11", *((uint32_t *)(header+8)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 12-15", *((uint32_t *)(header+12)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 36-39", *((uint32_t *)(header+36)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *)(header+40)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *)(header+44)), 0, NO_CLEANUP, 1);
+
+ TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", rsp->final);
+ TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", rsp->cont);
+@@ -433,6 +446,7 @@
+ */
+
+ int iscsi_login_cmd_encap(unsigned char *header, ISCSI_LOGIN_CMD_T *cmd) {
++ uint32_t length;
+
+ TRACE(TRACE_ISCSI_ARGS, "Transit: %i\n", cmd->transit);
+ TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", cmd->cont);
+@@ -451,21 +465,22 @@
+
+ memset(header, 0, ISCSI_HEADER_LEN);
+
+- header[0] |= 0x40|ISCSI_LOGIN_CMD; // Opcode
+- if (cmd->transit) header[1]|=0x80; // Transit
+- if (cmd->cont) header[1]|=0x40; // Continue
+- header[1] |= ((cmd->csg)<<2)&0x0c; // CSG
+- header[1] |= (cmd->nsg)&0x03; // NSG
+- header[2] = cmd->version_max; // Version-Max
+- header[3] = cmd->version_min; // Version-Min
+- header[4] = cmd->AHSlength; // TotalAHSLength
+- *((unsigned *)(header+4)) = HTONL(cmd->length&0x00ffffff); // Length
+- *((unsigned long long*)(header+8)) = HTONLL6(cmd->isid); // ISID
+- *((unsigned short *)(header+14)) = HTONS(cmd->tsih); // TSIH
+- *((unsigned *)(header+16)) = HTONL(cmd->tag); // Task Tag
+- *((unsigned short *)(header+20)) = HTONS(cmd->cid); // CID
+- *((unsigned *)(header+24)) = HTONL(cmd->CmdSN); // CmdSN
+- *((unsigned *)(header+28)) = HTONL(cmd->ExpStatSN); // ExpStatSN
++ header[0] |= 0x40|ISCSI_LOGIN_CMD; /* Opcode */
++ if (cmd->transit) header[1]|=0x80; /* Transit */
++ if (cmd->cont) header[1]|=0x40; /* Continue */
++ header[1] |= ((cmd->csg)<<2)&0x0c; /* CSG */
++ header[1] |= (cmd->nsg)&0x03; /* NSG */
++ header[2] = cmd->version_max; /* Version-Max */
++ header[3] = cmd->version_min; /* Version-Min */
++ header[4] = cmd->AHSlength; /* TotalAHSLength */
++ length = (cmd->length & 0x00ffffff); /* Length */
++ *((uint32_t *)(header+4)) = ISCSI_HTONL(length); /* Length */
++ *((uint64_t*)(header+8)) = ISCSI_HTONLL6(cmd->isid); /* ISID */
++ *((uint16_t *)(header+14)) = ISCSI_HTONS(cmd->tsih); /* TSIH */
++ *((uint32_t *)(header+16)) = ISCSI_HTONL(cmd->tag); /* Task Tag */
++ *((uint16_t *)(header+20)) = ISCSI_HTONS(cmd->cid); /* CID */
++ *((uint32_t *)(header+24)) = ISCSI_HTONL(cmd->CmdSN); /* CmdSN */
++ *((uint32_t *)(header+28)) = ISCSI_HTONL(cmd->ExpStatSN); /* ExpStatSN */
+
+ return 0;
+ }
+@@ -474,20 +489,20 @@
+
+ RETURN_NOT_EQUAL("Opcode", ISCSI_OPCODE(header), ISCSI_LOGIN_CMD, NO_CLEANUP, 1);
+
+- cmd->transit = (header[1]&0x80)?1:0; // Transit
+- cmd->cont = (header[1]&0x40)?1:0; // Continue
+- cmd->csg = (header[1]&0x0c)>>2; // CSG
+- cmd->nsg = header[1]&0x03; // NSG
+- cmd->version_max = header[2]; // Version-Max
+- cmd->version_min = header[3]; // Version-Min
+- cmd->AHSlength = header[4]; // TotalAHSLength
+- cmd->length = NTOHL(*((unsigned *)(header+4))); // Length
+- cmd->isid = NTOHLL6(*((unsigned long long *)(header+8))); // ISID
+- cmd->tsih = NTOHS(*((unsigned short *)(header+14))); // TSIH
+- cmd->tag = NTOHL(*((unsigned *)(header+16))); // Task Tag
+- cmd->cid = NTOHS(*((unsigned short *)(header+20))); // CID
+- cmd->CmdSN = NTOHL(*((unsigned *)(header+24))); // CmdSN
+- cmd->ExpStatSN = NTOHL(*((unsigned *)(header+28))); // ExpStatSN
++ cmd->transit = (header[1]&0x80)?1:0; /* Transit */
++ cmd->cont = (header[1]&0x40)?1:0; /* Continue */
++ cmd->csg = (header[1]&0x0c)>>2; /* CSG */
++ cmd->nsg = header[1]&0x03; /* NSG */
++ cmd->version_max = header[2]; /* Version-Max */
++ cmd->version_min = header[3]; /* Version-Min */
++ cmd->AHSlength = header[4]; /* TotalAHSLength */
++ cmd->length = ISCSI_NTOHL(*((uint32_t *)(header+4))); /* Length */
++ cmd->isid = ISCSI_NTOHLL6(*((uint64_t *)(header+8))); /* ISID */
++ cmd->tsih = ISCSI_NTOHS(*((uint16_t *)(header+14))); /* TSIH */
++ cmd->tag = ISCSI_NTOHL(*((uint32_t *)(header+16))); /* Task Tag */
++ cmd->cid = ISCSI_NTOHS(*((uint16_t *)(header+20))); /* CID */
++ cmd->CmdSN = ISCSI_NTOHL(*((uint32_t *)(header+24))); /* CmdSN */
++ cmd->ExpStatSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpStatSN */
+
+ TRACE(TRACE_ISCSI_ARGS, "Transit: %i\n", cmd->transit);
+ TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", cmd->cont);
+@@ -505,11 +520,11 @@
+ TRACE(TRACE_ISCSI_ARGS, "ExpStatSN: %u\n", cmd->ExpStatSN);
+
+ RETURN_NOT_EQUAL("Byte 1, bits 2-3", (header[1]&0x30)>>4, 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 22-23", *((unsigned short *)(header+22)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 32-35", *((unsigned *)(header+32)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 36-39", *((unsigned *)(header+36)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 40-43", *((unsigned *)(header+40)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 44-47", *((unsigned *)(header+44)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 22-23", *((uint16_t *)(header+22)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 32-35", *((uint32_t *)(header+32)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 36-39", *((uint32_t *)(header+36)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *)(header+40)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *)(header+44)), 0, NO_CLEANUP, 1);
+
+ if (cmd->transit) {
+ if (cmd->nsg <= cmd->csg) return -1;
+@@ -545,23 +560,23 @@
+
+ memset(header, 0, ISCSI_HEADER_LEN);
+
+- header[0] |= 0x00|ISCSI_LOGIN_RSP; // Opcode
+- if (rsp->transit) header[1] |= 0x80; // Transit
+- if (rsp->cont) header[1] |= 0x40; // Continue
+- header[1] |= ((rsp->csg)<<2)&0x0c; // CSG
+- if (rsp->transit) header[1] |= (rsp->nsg)&0x03; // NSG
+- header[2] = rsp->version_max; // Version-max
+- header[3] = rsp->version_active; // Version-active
+- header[4] = rsp->AHSlength; // TotalAHSLength
+- *((unsigned *)(header+4)) = HTONL(rsp->length); // Length
+- *((unsigned long long*)(header+8)) = HTONLL6(rsp->isid);// ISID
+- *((unsigned short *)(header+14)) = HTONS(rsp->tsih); // TSIH
+- *((unsigned *)(header+16)) = HTONL(rsp->tag); // Tag
+- *((unsigned *)(header+24)) = HTONL(rsp->StatSN); // StatRn
+- *((unsigned *)(header+28)) = HTONL(rsp->ExpCmdSN); // ExpCmdSN
+- *((unsigned *)(header+32)) = HTONL(rsp->MaxCmdSN); // MaxCmdSN
+- header[36] = rsp->status_class; // Status-Class
+- header[37] = rsp->status_detail; // Status-Detail
++ header[0] |= 0x00|ISCSI_LOGIN_RSP; /* Opcode */
++ if (rsp->transit) header[1] |= 0x80; /* Transit */
++ if (rsp->cont) header[1] |= 0x40; /* Continue */
++ header[1] |= ((rsp->csg)<<2)&0x0c; /* CSG */
++ if (rsp->transit) header[1] |= (rsp->nsg)&0x03; /* NSG */
++ header[2] = rsp->version_max; /* Version-max */
++ header[3] = rsp->version_active; /* Version-active */
++ header[4] = rsp->AHSlength; /* TotalAHSLength */
++ *((uint32_t *)(header+4)) = ISCSI_HTONL(rsp->length); /* Length */
++ *((uint64_t*)(header+8)) = ISCSI_HTONLL6(rsp->isid);/* ISID */
++ *((uint16_t *)(header+14)) = ISCSI_HTONS(rsp->tsih); /* TSIH */
++ *((uint32_t *)(header+16)) = ISCSI_HTONL(rsp->tag); /* Tag */
++ *((uint32_t *)(header+24)) = ISCSI_HTONL(rsp->StatSN); /* StatRn */
++ *((uint32_t *)(header+28)) = ISCSI_HTONL(rsp->ExpCmdSN); /* ExpCmdSN */
++ *((uint32_t *)(header+32)) = ISCSI_HTONL(rsp->MaxCmdSN); /* MaxCmdSN */
++ header[36] = rsp->status_class; /* Status-Class */
++ header[37] = rsp->status_detail; /* Status-Detail */
+
+ return 0;
+ }
+@@ -570,22 +585,22 @@
+
+ RETURN_NOT_EQUAL("Opcode", ISCSI_OPCODE(header), ISCSI_LOGIN_RSP, NO_CLEANUP, 1);
+
+- rsp->transit = (header[1]&0x80)>>7; // Transit
+- rsp->cont = (header[1]&0x40)>>6; // Continue
+- rsp->csg = (header[1]&0x0c)>>2; // CSG
+- rsp->nsg = header[1]&0x03; // NSG
+- rsp->version_max = header[2]; // Version-max
+- rsp->version_active = header[3]; // Version-active
+- rsp->AHSlength = header[4]; // TotalAHSLength
+- rsp->length = NTOHL(*((unsigned *)(header+4))); // Length
+- rsp->isid = NTOHLL6(*((unsigned long long*)(header+8)));// ISID
+- rsp->tsih = NTOHS(*((unsigned short *)(header+14))); // TSIH
+- rsp->tag = NTOHL(*((unsigned *)(header+16))); // Tag
+- rsp->StatSN = NTOHL(*((unsigned *)(header+24))); // StatSN
+- rsp->ExpCmdSN = NTOHL(*((unsigned *)(header+28))); // ExpCmdSN
+- rsp->MaxCmdSN = NTOHL(*((unsigned *)(header+32))); // MaxCmdSN
+- rsp->status_class = header[36]; // Status-Class
+- rsp->status_detail = header[37]; // Status-Detail
++ rsp->transit = (header[1]&0x80)>>7; /* Transit */
++ rsp->cont = (header[1]&0x40)>>6; /* Continue */
++ rsp->csg = (header[1]&0x0c)>>2; /* CSG */
++ rsp->nsg = header[1]&0x03; /* NSG */
++ rsp->version_max = header[2]; /* Version-max */
++ rsp->version_active = header[3]; /* Version-active */
++ rsp->AHSlength = header[4]; /* TotalAHSLength */
++ rsp->length = ISCSI_NTOHL(*((uint32_t *)(header+4))); /* Length */
++ rsp->isid = ISCSI_NTOHLL6(*((uint64_t*)(header+8)));/* ISID */
++ rsp->tsih = ISCSI_NTOHS(*((uint16_t *)(header+14))); /* TSIH */
++ rsp->tag = ISCSI_NTOHL(*((uint32_t *)(header+16))); /* Tag */
++ rsp->StatSN = ISCSI_NTOHL(*((uint32_t *)(header+24))); /* StatSN */
++ rsp->ExpCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpCmdSN */
++ rsp->MaxCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+32))); /* MaxCmdSN */
++ rsp->status_class = header[36]; /* Status-Class */
++ rsp->status_detail = header[37]; /* Status-Detail */
+
+ TRACE(TRACE_ISCSI_ARGS, "Transit: %i\n", rsp->transit);
+ TRACE(TRACE_ISCSI_ARGS, "Continue: %i\n", rsp->cont);
+@@ -606,11 +621,11 @@
+ TRACE(TRACE_ISCSI_ARGS, "Status-Detail: %u\n", rsp->status_detail);
+
+ RETURN_NOT_EQUAL("Byte 1, bits 2-3", (header[1]&0x30)>>4, 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 20-23", *((unsigned *)(header+20)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 20-23", *((uint32_t *)(header+20)), 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 38", header[38], 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 39", header[39], 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 40-43", *((unsigned *)(header+40)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 44-47", *((unsigned *)(header+44)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *)(header+40)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *)(header+44)), 0, NO_CLEANUP, 1);
+
+ return 0;
+ }
+@@ -630,13 +645,13 @@
+
+ memset(header, 0, ISCSI_HEADER_LEN);
+
+- header[0] = ISCSI_LOGOUT_CMD; // Opcode
+- if (cmd->immediate) header[0] |= 0x40; // Immediate
+- header[1] = cmd->reason|0x80; // Reason
+- *((unsigned *)(header+16)) = HTONL(cmd->tag); // Tag
+- *((unsigned short *)(header+20)) = HTONS(cmd->cid); // CID
+- *((unsigned *) (header+24)) = HTONL(cmd->CmdSN); // CmdSN
+- *((unsigned *) (header+28)) = HTONL(cmd->ExpStatSN); // ExpStatSN
++ header[0] = ISCSI_LOGOUT_CMD; /* Opcode */
++ if (cmd->immediate) header[0] |= 0x40; /* Immediate */
++ header[1] = cmd->reason|0x80; /* Reason */
++ *((uint32_t *)(header+16)) = ISCSI_HTONL(cmd->tag); /* Tag */
++ *((uint16_t *)(header+20)) = ISCSI_HTONS(cmd->cid); /* CID */
++ *((uint32_t *) (header+24)) = ISCSI_HTONL(cmd->CmdSN); /* CmdSN */
++ *((uint32_t *) (header+28)) = ISCSI_HTONL(cmd->ExpStatSN); /* ExpStatSN */
+
+ return 0;
+ }
+@@ -645,12 +660,12 @@
+
+ RETURN_NOT_EQUAL("Opcode", ISCSI_OPCODE(header), ISCSI_LOGOUT_CMD, NO_CLEANUP, 1);
+
+- cmd->immediate = (header[0]&0x40)?1:0; // Immediate
+- cmd->reason = header[1]&0x7f; // Reason
+- cmd->tag = NTOHL(*((unsigned *)(header+16))); // Tag
+- cmd->cid = NTOHS(*((unsigned short *)(header+20))); // CID
+- cmd->CmdSN = NTOHL(*((unsigned *)(header+24))); // CmdSN
+- cmd->ExpStatSN = NTOHL(*((unsigned *)(header+28))); // ExpStatSN
++ cmd->immediate = (header[0]&0x40)?1:0; /* Immediate */
++ cmd->reason = header[1]&0x7f; /* Reason */
++ cmd->tag = ISCSI_NTOHL(*((uint32_t *)(header+16))); /* Tag */
++ cmd->cid = ISCSI_NTOHS(*((uint16_t *)(header+20))); /* CID */
++ cmd->CmdSN = ISCSI_NTOHL(*((uint32_t *)(header+24))); /* CmdSN */
++ cmd->ExpStatSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpStatSN */
+
+ TRACE(TRACE_ISCSI_ARGS, "Immediate: %i\n", cmd->immediate);
+ TRACE(TRACE_ISCSI_ARGS, "Reason: %u\n", cmd->reason);
+@@ -664,14 +679,14 @@
+ RETURN_NOT_EQUAL("Byte 1 bit 0", header[1]>>7, 1, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 2", header[2], 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 3", header[3], 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 4-7", *((unsigned *)(header+4)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 8-11", *((unsigned *)(header+8)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 12-15", *((unsigned *)(header+12)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 22-23", *((unsigned *)(header+22)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 32-35", *((unsigned *)(header+32)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 36-39", *((unsigned *)(header+36)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 40-43", *((unsigned *)(header+40)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 44-47", *((unsigned *)(header+44)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 4-7", *((uint32_t *)(header+4)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 8-11", *((uint32_t *)(header+8)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 12-15", *((uint32_t *)(header+12)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 22-23", *((uint32_t *)(header+22)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 32-35", *((uint32_t *)(header+32)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 36-39", *((uint32_t *)(header+36)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *)(header+40)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *)(header+44)), 0, NO_CLEANUP, 1);
+
+ return 0;
+ }
+@@ -694,16 +709,16 @@
+
+ memset(header, 0, ISCSI_HEADER_LEN);
+
+- header[0] |= 0x00|ISCSI_LOGOUT_RSP; // Opcode
+- header[1] |= 0x80; // Reserved
+- header[2] = rsp->response; // Response
+- *((unsigned *)(header+4)) = HTONL(rsp->length); // Length
+- *((unsigned *)(header+16)) = HTONL(rsp->tag); // Tag
+- *((unsigned *)(header+24)) = HTONL(rsp->StatSN); // StatSN
+- *((unsigned *)(header+28)) = HTONL(rsp->ExpCmdSN); // ExpCmdSN
+- *((unsigned *)(header+32)) = HTONL(rsp->MaxCmdSN); // MaxCmdSN
+- *((unsigned *)(header+40)) = HTONS(rsp->Time2Wait); // Time2Wait
+- *((unsigned *)(header+42)) = HTONS(rsp->Time2Retain); // Time2Retain
++ header[0] |= 0x00|ISCSI_LOGOUT_RSP; /* Opcode */
++ header[1] |= 0x80; /* Reserved */
++ header[2] = rsp->response; /* Response */
++ *((uint32_t *)(header+4)) = ISCSI_HTONL(rsp->length); /* Length */
++ *((uint32_t *)(header+16)) = ISCSI_HTONL(rsp->tag); /* Tag */
++ *((uint32_t *)(header+24)) = ISCSI_HTONL(rsp->StatSN); /* StatSN */
++ *((uint32_t *)(header+28)) = ISCSI_HTONL(rsp->ExpCmdSN); /* ExpCmdSN */
++ *((uint32_t *)(header+32)) = ISCSI_HTONL(rsp->MaxCmdSN); /* MaxCmdSN */
++ *((uint32_t *)(header+40)) = ISCSI_HTONS(rsp->Time2Wait); /* Time2Wait */
++ *((uint32_t *)(header+42)) = ISCSI_HTONS(rsp->Time2Retain); /* Time2Retain */
+
+ return 0;
+ }
+@@ -712,24 +727,24 @@
+
+ RETURN_NOT_EQUAL("Opcode", ISCSI_OPCODE(header), ISCSI_LOGOUT_RSP, NO_CLEANUP, 1);
+
+- rsp->response = header[2]; // Response
+- rsp->length = NTOHL(*((unsigned *)(header+4))); // Length
+- rsp->tag = NTOHL(*((unsigned *)(header+16))); // Tag
+- rsp->StatSN = NTOHL(*((unsigned *)(header+24))); // StatSN
+- rsp->ExpCmdSN = NTOHL(*((unsigned *)(header+28))); // ExpCmdSN
+- rsp->MaxCmdSN = NTOHL(*((unsigned *)(header+32))); // MaxCmdSN
+- rsp->Time2Wait = NTOHS(*((unsigned *)(header+40))); // Time2Wait
+- rsp->Time2Retain = NTOHS(*((unsigned *)(header+42))); // Time2Retain
++ rsp->response = header[2]; /* Response */
++ rsp->length = ISCSI_NTOHL(*((uint32_t *)(header+4))); /* Length */
++ rsp->tag = ISCSI_NTOHL(*((uint32_t *)(header+16))); /* Tag */
++ rsp->StatSN = ISCSI_NTOHL(*((uint32_t *)(header+24))); /* StatSN */
++ rsp->ExpCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpCmdSN */
++ rsp->MaxCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+32))); /* MaxCmdSN */
++ rsp->Time2Wait = ISCSI_NTOHS(*((uint32_t *)(header+40))); /* Time2Wait */
++ rsp->Time2Retain = ISCSI_NTOHS(*((uint32_t *)(header+42))); /* Time2Retain */
+
+ RETURN_NOT_EQUAL("Byte 0 bits 0-1", (header[0]&0x20), 0x20, NO_CLEANUP, -1);
+ RETURN_NOT_EQUAL("Byte 1 bit 0", header[1]&0x80, 0x80, NO_CLEANUP, -1);
+ RETURN_NOT_EQUAL("Byte 3", header[3], 0, NO_CLEANUP, -1);
+- RETURN_NOT_EQUAL("Bytes 4-7", *((unsigned *)(header+4)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 8-11", *((unsigned *)(header+8)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 12-15", *((unsigned *)(header+12)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 20-23", *((unsigned *)(header+20)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 36-39", *((unsigned *)(header+36)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 44-47", *((unsigned *)(header+44)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 4-7", *((uint32_t *)(header+4)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 8-11", *((uint32_t *)(header+8)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 12-15", *((uint32_t *)(header+12)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 20-23", *((uint32_t *)(header+20)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 36-39", *((uint32_t *)(header+36)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *)(header+44)), 0, NO_CLEANUP, 1);
+
+ TRACE(TRACE_ISCSI_ARGS, "Response: %u\n", rsp->response);
+ TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", rsp->length);
+@@ -765,20 +780,20 @@
+
+ memset(header, 0, ISCSI_HEADER_LEN);
+
+- header[0] |= ISCSI_SCSI_CMD; // Opcode
+- if (cmd->immediate) header[0] |= 0x40; // Immediate
+- if (cmd->final) header[1] |= 0x80; // Final
+- if (cmd->input) header[1] |= 0x40; // Input bit
+- if (cmd->output) header[1] |= 0x20; // Output bit
+- header[1] |= cmd->attr&0x07; // ATTR
+- *((unsigned *)(header+4)) = HTONL(cmd->length); // DataSegmentLength
+- header[4] = cmd->ahs_len; // TotalAHSLength
+- *((unsigned long long *)(header+8)) = HTONLL6(cmd->lun); // LUN
+- *((unsigned *)(header+16)) = HTONL(cmd->tag); // Task Tag
+- *((unsigned *)(header+20)) = HTONL(cmd->trans_len); // Expected Transfer Length
+- *((unsigned *)(header+24)) = HTONL(cmd->CmdSN); // CmdSN
+- *((unsigned *)(header+28)) = HTONL(cmd->ExpStatSN); // ExpStatSN
+- memcpy(header+32, cmd->cdb, 16); // CDB
++ header[0] |= ISCSI_SCSI_CMD; /* Opcode */
++ if (cmd->immediate) header[0] |= 0x40; /* Immediate */
++ if (cmd->final) header[1] |= 0x80; /* Final */
++ if (cmd->input) header[1] |= 0x40; /* Input bit */
++ if (cmd->output) header[1] |= 0x20; /* Output bit */
++ header[1] |= cmd->attr&0x07; /* ATTR */
++ *((uint32_t *)(header+4)) = ISCSI_HTONL(cmd->length); /* DataSegmentLength */
++ header[4] = cmd->ahs_len; /* TotalAHSLength */
++ *((uint64_t *)(header+8)) = ISCSI_HTONLL6(cmd->lun); /* LUN */
++ *((uint32_t *)(header+16)) = ISCSI_HTONL(cmd->tag); /* Task Tag */
++ *((uint32_t *)(header+20)) = ISCSI_HTONL(cmd->trans_len); /* Expected Transfer Length */
++ *((uint32_t *)(header+24)) = ISCSI_HTONL(cmd->CmdSN); /* CmdSN */
++ *((uint32_t *)(header+28)) = ISCSI_HTONL(cmd->ExpStatSN); /* ExpStatSN */
++ memcpy(header+32, cmd->cdb, 16); /* CDB */
+
+ return 0;
+ }
+@@ -787,19 +802,19 @@
+
+ RETURN_NOT_EQUAL("Opcode", ISCSI_OPCODE(header), ISCSI_SCSI_CMD, NO_CLEANUP, 1);
+
+- cmd->immediate = (header[0]&0x40)?1:0; // Immediate
+- cmd->final = (header[1]&0x80)?1:0; // Final
+- cmd->input = (header[1]&0x40)?1:0; // Input
+- cmd->output = (header[1]&0x20)?1:0; // Output
+- cmd->attr = header[1]&0x07; // ATTR
++ cmd->immediate = (header[0]&0x40)?1:0; /* Immediate */
++ cmd->final = (header[1]&0x80)?1:0; /* Final */
++ cmd->input = (header[1]&0x40)?1:0; /* Input */
++ cmd->output = (header[1]&0x20)?1:0; /* Output */
++ cmd->attr = header[1]&0x07; /* ATTR */
+ cmd->ahs_len = header[4]; header[4] = 0x00;
+- cmd->length = NTOHL(*((unsigned *)(header+4))); // DataSegmentLength
+- cmd->lun = NTOHLL6(*((unsigned long long *)(header+8))); // LUN
+- cmd->tag = NTOHL(*((unsigned *)(header+16))); // Task Tag
+- cmd->trans_len = NTOHL(*((unsigned *)(header+20))); // Expected Transfer Length
+- cmd->CmdSN = NTOHL(*((unsigned *)(header+24))); // CmdSN
+- cmd->ExpStatSN = NTOHL(*((unsigned *)(header+28))); // ExpStatSN
+- cmd->cdb = header+32; // CDB
++ cmd->length = ISCSI_NTOHL(*((uint32_t *)(header+4))); /* DataSegmentLength */
++ cmd->lun = ISCSI_NTOHLL6(*((uint64_t *)(header+8))); /* LUN */
++ cmd->tag = ISCSI_NTOHL(*((uint32_t *)(header+16))); /* Task Tag */
++ cmd->trans_len = ISCSI_NTOHL(*((uint32_t *)(header+20))); /* Expected Transfer Length */
++ cmd->CmdSN = ISCSI_NTOHL(*((uint32_t *)(header+24))); /* CmdSN */
++ cmd->ExpStatSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpStatSN */
++ cmd->cdb = header+32; /* CDB */
+
+ RETURN_NOT_EQUAL("Byte 1, Bits 3-4", header[1]&0x18, 0,NO_CLEANUP, -1);
+ RETURN_NOT_EQUAL("Byte 2", header[2], 0, NO_CLEANUP, 1);
+@@ -845,23 +860,23 @@
+
+ memset(header, 0, ISCSI_HEADER_LEN);
+
+- header[0] |= 0x00|ISCSI_SCSI_RSP; // Opcode
+- header[1] |= 0x80; // Byte 1 bit 7
+- if (rsp->bidi_overflow) header[1] |= 0x10; // Bidi overflow
+- if (rsp->bidi_underflow) header[1] |= 0x08; // Bidi underflow
+- if (rsp->overflow) header[1] |= 0x04; // Overflow
+- if (rsp->underflow) header[1] |= 0x02; // Underflow
+- header[2] = rsp->response; // iSCSI Response
+- header[3] = rsp->status; // SCSI Status
+- header[4] = rsp->ahs_len; // TotalAHSLength
+- *((unsigned *)(header+4)) = HTONL(rsp->length); // DataSegmentLength
+- *((unsigned *)(header+16)) = HTONL(rsp->tag); // Task Tag
+- *((unsigned *)(header+24)) = HTONL(rsp->StatSN); // StatSN
+- *((unsigned *)(header+28)) = HTONL(rsp->ExpCmdSN); // ExpCmdSN
+- *((unsigned *)(header+32)) = HTONL(rsp->MaxCmdSN); // MaxCmdSN
+- *((unsigned *)(header+36)) = HTONL(rsp->ExpDataSN); // ExpDataSN
+- *((unsigned *)(header+40)) = HTONL(rsp->bidi_res_cnt); // Bidi Residual Count
+- *((unsigned *)(header+44)) = HTONL(rsp->basic_res_cnt); // Residual Count
++ header[0] |= 0x00|ISCSI_SCSI_RSP; /* Opcode */
++ header[1] |= 0x80; /* Byte 1 bit 7 */
++ if (rsp->bidi_overflow) header[1] |= 0x10; /* Bidi overflow */
++ if (rsp->bidi_underflow) header[1] |= 0x08; /* Bidi underflow */
++ if (rsp->overflow) header[1] |= 0x04; /* Overflow */
++ if (rsp->underflow) header[1] |= 0x02; /* Underflow */
++ header[2] = rsp->response; /* iSCSI Response */
++ header[3] = rsp->status; /* SCSI Status */
++ header[4] = rsp->ahs_len; /* TotalAHSLength */
++ *((uint32_t *)(header+4)) = ISCSI_HTONL(rsp->length); /* DataSegmentLength */
++ *((uint32_t *)(header+16)) = ISCSI_HTONL(rsp->tag); /* Task Tag */
++ *((uint32_t *)(header+24)) = ISCSI_HTONL(rsp->StatSN); /* StatSN */
++ *((uint32_t *)(header+28)) = ISCSI_HTONL(rsp->ExpCmdSN); /* ExpCmdSN */
++ *((uint32_t *)(header+32)) = ISCSI_HTONL(rsp->MaxCmdSN); /* MaxCmdSN */
++ *((uint32_t *)(header+36)) = ISCSI_HTONL(rsp->ExpDataSN); /* ExpDataSN */
++ *((uint32_t *)(header+40)) = ISCSI_HTONL(rsp->bidi_res_cnt); /* Bidi Residual Count */
++ *((uint32_t *)(header+44)) = ISCSI_HTONL(rsp->basic_res_cnt); /* Residual Count */
+
+ return 0;
+ }
+@@ -870,22 +885,22 @@
+
+ RETURN_NOT_EQUAL("Opcode", ISCSI_OPCODE(header), ISCSI_SCSI_RSP, NO_CLEANUP, 1);
+
+- rsp->bidi_overflow = (header[1]&0x10)?1:0; // Bidi overflow
+- rsp->bidi_underflow = (header[1]&0x08)?1:0; // Bidi underflow
+- rsp->overflow = (header[1]&0x04)?1:0; // Overflow
+- rsp->underflow = (header[1]&0x02)?1:0; // Underflow
+-
+- rsp->response = header[2]; // iSCSI Response
+- rsp->status = header[3]; // SCSI Status
+- rsp->ahs_len = header[4]; // TotalAHSLength
+- rsp->length = NTOHL(*((unsigned *)(header+4))); // DataSegmentLength
+- rsp->tag = NTOHL(*((unsigned *)(header+16))); // Task Tag
+- rsp->StatSN = NTOHL(*((unsigned *)(header+24))); // StatSN
+- rsp->ExpCmdSN = NTOHL(*((unsigned *)(header+28))); // ExpCmdSN
+- rsp->MaxCmdSN = NTOHL(*((unsigned *)(header+32))); // MaxCmdSN
+- rsp->ExpDataSN = NTOHL(*((unsigned *)(header+36))); // ExpDataSN
+- rsp->bidi_res_cnt = NTOHL(*((unsigned *)(header+40))); // Bidi Residual Count
+- rsp->basic_res_cnt = NTOHL(*((unsigned *)(header+44))); // Residual Count
++ rsp->bidi_overflow = (header[1]&0x10)?1:0; /* Bidi overflow */
++ rsp->bidi_underflow = (header[1]&0x08)?1:0; /* Bidi underflow */
++ rsp->overflow = (header[1]&0x04)?1:0; /* Overflow */
++ rsp->underflow = (header[1]&0x02)?1:0; /* Underflow */
++
++ rsp->response = header[2]; /* iSCSI Response */
++ rsp->status = header[3]; /* SCSI Status */
++ rsp->ahs_len = header[4]; /* TotalAHSLength */
++ rsp->length = ISCSI_NTOHL(*((uint32_t *)(header+4))); /* DataSegmentLength */
++ rsp->tag = ISCSI_NTOHL(*((uint32_t *)(header+16))); /* Task Tag */
++ rsp->StatSN = ISCSI_NTOHL(*((uint32_t *)(header+24))); /* StatSN */
++ rsp->ExpCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpCmdSN */
++ rsp->MaxCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+32))); /* MaxCmdSN */
++ rsp->ExpDataSN = ISCSI_NTOHL(*((uint32_t *)(header+36))); /* ExpDataSN */
++ rsp->bidi_res_cnt = ISCSI_NTOHL(*((uint32_t *)(header+40))); /* Bidi Residual Count */
++ rsp->basic_res_cnt = ISCSI_NTOHL(*((uint32_t *)(header+44))); /* Residual Count */
+
+ RETURN_NOT_EQUAL("Byte 0 bits 0-1", header[0]&0x00, 0x00, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 1 bit 0", header[1]&0x80, 0x80, NO_CLEANUP, 1);
+@@ -919,6 +934,8 @@
+
+ int iscsi_r2t_encap(unsigned char *header, ISCSI_R2T_T *cmd) {
+
++ uint32_t AHS_length;
++
+ TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", cmd->AHSlength);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+ TRACE(TRACE_ISCSI_ARGS, "Tag: 0x%x\n", cmd->tag);
+@@ -932,18 +949,19 @@
+
+ memset(header, 0, ISCSI_HEADER_LEN);
+
+- header[0] |= 0x00|ISCSI_R2T; // Opcode
++ header[0] |= 0x00|ISCSI_R2T; /* Opcode */
+ header[1] |= 0x80;
+- *((unsigned *)(header+4)) = HTONL(cmd->AHSlength&0x00ffffff); // AHSLength
+- *((unsigned long long *)(header+8)) = HTONLL6(cmd->lun); // LUN
+- *((unsigned *)(header+16)) = HTONL(cmd->tag); // Tag
+- *((unsigned *)(header+20)) = HTONL(cmd->transfer_tag); // Transfer Tag
+- *((unsigned *)(header+24)) = HTONL(cmd->StatSN); // StatSN
+- *((unsigned *)(header+28)) = HTONL(cmd->ExpCmdSN); // ExpCmdSN
+- *((unsigned *)(header+32)) = HTONL(cmd->MaxCmdSN); // MaxCmdSN
+- *((unsigned *)(header+36)) = HTONL(cmd->R2TSN); // R2TSN
+- *((unsigned *)(header+40)) = HTONL(cmd->offset); // Buffer Offset
+- *((unsigned *)(header+44)) = HTONL(cmd->length); // Transfer Length
++ AHS_length = (cmd->AHSlength & 0x00ffffff); /* AHSLength */
++ *((uint32_t *)(header+4)) = ISCSI_HTONL(AHS_length); /* AHSLength */
++ *((uint64_t *)(header+8)) = ISCSI_HTONLL6(cmd->lun); /* LUN */
++ *((uint32_t *)(header+16)) = ISCSI_HTONL(cmd->tag); /* Tag */
++ *((uint32_t *)(header+20)) = ISCSI_HTONL(cmd->transfer_tag); /* Transfer Tag */
++ *((uint32_t *)(header+24)) = ISCSI_HTONL(cmd->StatSN); /* StatSN */
++ *((uint32_t *)(header+28)) = ISCSI_HTONL(cmd->ExpCmdSN); /* ExpCmdSN */
++ *((uint32_t *)(header+32)) = ISCSI_HTONL(cmd->MaxCmdSN); /* MaxCmdSN */
++ *((uint32_t *)(header+36)) = ISCSI_HTONL(cmd->R2TSN); /* R2TSN */
++ *((uint32_t *)(header+40)) = ISCSI_HTONL(cmd->offset); /* Buffer Offset */
++ *((uint32_t *)(header+44)) = ISCSI_HTONL(cmd->length); /* Transfer Length */
+
+ return 0;
+ }
+@@ -952,23 +970,23 @@
+
+ RETURN_NOT_EQUAL("Opcode", ISCSI_OPCODE(header), ISCSI_R2T, NO_CLEANUP, 1);
+
+- cmd->AHSlength = NTOHL(*((unsigned *)(header+4))); // TotalAHSLength
+- cmd->lun = NTOHLL6(*((unsigned long long *)(header+8))); // LUN
+- cmd->tag = NTOHL(*((unsigned *)(header+16))); // Tag
+- cmd->transfer_tag = NTOHL(*((unsigned *)(header+20))); // Transfer Tag
+- cmd->StatSN = NTOHL(*((unsigned *)(header+24))); // StatSN
+- cmd->ExpCmdSN = NTOHL(*((unsigned *)(header+28))); // ExpCmdSN
+- cmd->MaxCmdSN = NTOHL(*((unsigned *)(header+32))); // MaxCmdSN
+- cmd->R2TSN = NTOHL(*((unsigned *)(header+36))); // R2TSN
+- cmd->offset = NTOHL(*((unsigned *)(header+40))); // Offset
+- cmd->length = NTOHL(*((unsigned *)(header+44))); // Transfer Length
++ cmd->AHSlength = ISCSI_NTOHL(*((uint32_t *)(header+4))); /* TotalAHSLength */
++ cmd->lun = ISCSI_NTOHLL6(*((uint64_t *)(header+8))); /* LUN */
++ cmd->tag = ISCSI_NTOHL(*((uint32_t *)(header+16))); /* Tag */
++ cmd->transfer_tag = ISCSI_NTOHL(*((uint32_t *)(header+20))); /* Transfer Tag */
++ cmd->StatSN = ISCSI_NTOHL(*((uint32_t *)(header+24))); /* StatSN */
++ cmd->ExpCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpCmdSN */
++ cmd->MaxCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+32))); /* MaxCmdSN */
++ cmd->R2TSN = ISCSI_NTOHL(*((uint32_t *)(header+36))); /* R2TSN */
++ cmd->offset = ISCSI_NTOHL(*((uint32_t *)(header+40))); /* Offset */
++ cmd->length = ISCSI_NTOHL(*((uint32_t *)(header+44))); /* Transfer Length */
+
+ RETURN_NOT_EQUAL("Byte 1, Bits 1-7", header[1]&0x7f, 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 2", header[2], 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 3", header[3], 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 4-7", *((unsigned *)(header+4)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 8-11", *((unsigned *)(header+8)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 12-15", *((unsigned *)(header+12)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 4-7", *((uint32_t *)(header+4)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 8-11", *((uint32_t *)(header+8)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 12-15", *((uint32_t *)(header+12)), 0, NO_CLEANUP, 1);
+
+ TRACE(TRACE_ISCSI_ARGS, "AHSLength: %u\n", cmd->AHSlength);
+ TRACE(TRACE_ISCSI_ARGS, "LUN: %llu\n", cmd->lun);
+@@ -999,15 +1017,15 @@
+ TRACE(TRACE_ISCSI_ARGS, "Buffer Offset: %u\n", cmd->offset);
+
+ memset(header, 0, ISCSI_HEADER_LEN);
+- header[0] = 0x00|ISCSI_WRITE_DATA; // Opcode
+- if (cmd->final) header[1] |= 0x80; // Final
+- *((unsigned *)(header+4)) = HTONL(cmd->length); // Length
+- *((unsigned long long*)(header+8)) = HTONLL6(cmd->lun); // LUN
+- *((unsigned *)(header+16)) = HTONL(cmd->tag); // Tag
+- *((unsigned *)(header+20)) = HTONL(cmd->transfer_tag); // Transfer Tag
+- *((unsigned *)(header+28)) = HTONL(cmd->ExpStatSN); // ExpStatSN
+- *((unsigned *)(header+36)) = HTONL(cmd->DataSN); // DataSN
+- *((unsigned *)(header+40)) = HTONL(cmd->offset); // Buffer Offset
++ header[0] = 0x00|ISCSI_WRITE_DATA; /* Opcode */
++ if (cmd->final) header[1] |= 0x80; /* Final */
++ *((uint32_t *)(header+4)) = ISCSI_HTONL(cmd->length); /* Length */
++ *((uint64_t*)(header+8)) = ISCSI_HTONLL6(cmd->lun); /* LUN */
++ *((uint32_t *)(header+16)) = ISCSI_HTONL(cmd->tag); /* Tag */
++ *((uint32_t *)(header+20)) = ISCSI_HTONL(cmd->transfer_tag); /* Transfer Tag */
++ *((uint32_t *)(header+28)) = ISCSI_HTONL(cmd->ExpStatSN); /* ExpStatSN */
++ *((uint32_t *)(header+36)) = ISCSI_HTONL(cmd->DataSN); /* DataSN */
++ *((uint32_t *)(header+40)) = ISCSI_HTONL(cmd->offset); /* Buffer Offset */
+
+ return 0;
+ }
+@@ -1016,22 +1034,22 @@
+
+ RETURN_NOT_EQUAL("Opcode", ISCSI_OPCODE(header), ISCSI_WRITE_DATA,NO_CLEANUP, 1);
+
+- cmd->final = (header[1]&0x80)?1:0; // Final
+- cmd->length = NTOHL(*((unsigned *)(header+4))); // Length
+- cmd->lun = NTOHLL6(*((unsigned long long *)(header+8))); // LUN
+- cmd->tag = NTOHL(*((unsigned *)(header+16))); // Tag
+- cmd->transfer_tag = NTOHL(*((unsigned *)(header+20))); // Transfer Tag
+- cmd->ExpStatSN = NTOHL(*((unsigned *)(header+28))); // ExpStatSN
+- cmd->DataSN = NTOHL(*((unsigned *)(header+36))); // DataSN
+- cmd->offset = NTOHL(*((unsigned *)(header+40))); // Buffer Offset
++ cmd->final = (header[1]&0x80)?1:0; /* Final */
++ cmd->length = ISCSI_NTOHL(*((uint32_t *)(header+4))); /* Length */
++ cmd->lun = ISCSI_NTOHLL6(*((uint64_t *)(header+8))); /* LUN */
++ cmd->tag = ISCSI_NTOHL(*((uint32_t *)(header+16))); /* Tag */
++ cmd->transfer_tag = ISCSI_NTOHL(*((uint32_t *)(header+20))); /* Transfer Tag */
++ cmd->ExpStatSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpStatSN */
++ cmd->DataSN = ISCSI_NTOHL(*((uint32_t *)(header+36))); /* DataSN */
++ cmd->offset = ISCSI_NTOHL(*((uint32_t *)(header+40))); /* Buffer Offset */
+
+ RETURN_NOT_EQUAL("Byte 1, Bits 1-7", header[1]&0x7f, 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 2", header[2], 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 3", header[3], 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 4", header[4], 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Byte 24-27", *((unsigned *)(header+24)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Byte 32-35", *((unsigned *)(header+32)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Byte 44-47", *((unsigned *)(header+44)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Byte 24-27", *((uint32_t *)(header+24)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Byte 32-35", *((uint32_t *)(header+32)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Byte 44-47", *((uint32_t *)(header+44)), 0, NO_CLEANUP, 1);
+
+ TRACE(TRACE_ISCSI_ARGS, "Final: %u\n", cmd->final);
+ TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", cmd->length);
+@@ -1070,26 +1088,26 @@
+
+ memset(header, 0, ISCSI_HEADER_LEN);
+
+- header[0] = 0x00|ISCSI_READ_DATA; // Opcode
+- if (cmd->final) header[1] |= 0x80; // Final
+- if (cmd->ack) header[1] |= 0x40; // ACK
+- if (cmd->overflow) header[1] |= 0x04; // Overflow
+- if (cmd->underflow) header[1] |= 0x02; // Underflow
+- if (cmd->S_bit) header[1] |= 0x01; // S Bit
++ header[0] = 0x00|ISCSI_READ_DATA; /* Opcode */
++ if (cmd->final) header[1] |= 0x80; /* Final */
++ if (cmd->ack) header[1] |= 0x40; /* ACK */
++ if (cmd->overflow) header[1] |= 0x04; /* Overflow */
++ if (cmd->underflow) header[1] |= 0x02; /* Underflow */
++ if (cmd->S_bit) header[1] |= 0x01; /* S Bit */
+ if (cmd->S_bit)
+- header[3] = cmd->status; // Status
+- *((unsigned *)(header+4)) = HTONL(cmd->length); // Length
+- *((unsigned long long*)(header+8)) = HTONLL6(cmd->lun); // LUN
+- *((unsigned *)(header+16)) = HTONL(cmd->task_tag); // Task Tag
+- *((unsigned *)(header+20)) = HTONL(cmd->transfer_tag); // Transfer Tag
++ header[3] = cmd->status; /* Status */
++ *((uint32_t *)(header+4)) = ISCSI_HTONL(cmd->length); /* Length */
++ *((uint64_t*)(header+8)) = ISCSI_HTONLL6(cmd->lun); /* LUN */
++ *((uint32_t *)(header+16)) = ISCSI_HTONL(cmd->task_tag); /* Task Tag */
++ *((uint32_t *)(header+20)) = ISCSI_HTONL(cmd->transfer_tag); /* Transfer Tag */
+ if (cmd->S_bit)
+- *((unsigned *)(header+24)) = HTONL(cmd->StatSN); // StatSN
+- *((unsigned *)(header+28)) = HTONL(cmd->ExpCmdSN); // ExpCmdSN
+- *((unsigned *)(header+32)) = HTONL(cmd->MaxCmdSN); // MaxCmdSN
+- *((unsigned *)(header+36)) = HTONL(cmd->DataSN); // DataSN
+- *((unsigned *)(header+40)) = HTONL(cmd->offset); // Buffer Offset
++ *((uint32_t *)(header+24)) = ISCSI_HTONL(cmd->StatSN); /* StatSN */
++ *((uint32_t *)(header+28)) = ISCSI_HTONL(cmd->ExpCmdSN); /* ExpCmdSN */
++ *((uint32_t *)(header+32)) = ISCSI_HTONL(cmd->MaxCmdSN); /* MaxCmdSN */
++ *((uint32_t *)(header+36)) = ISCSI_HTONL(cmd->DataSN); /* DataSN */
++ *((uint32_t *)(header+40)) = ISCSI_HTONL(cmd->offset); /* Buffer Offset */
+ if (cmd->S_bit)
+- *((unsigned *)(header+44)) = HTONL(cmd->res_count); // Residual Count
++ *((uint32_t *)(header+44)) = ISCSI_HTONL(cmd->res_count); /* Residual Count */
+
+ return 0;
+ }
+@@ -1098,30 +1116,30 @@
+
+ RETURN_NOT_EQUAL("Opcode", ISCSI_OPCODE(header), ISCSI_READ_DATA, NO_CLEANUP, 1);
+
+- cmd->final = (header[1]&0x80)?1:0; // Final
+- cmd->ack = (header[1]&0x40)?1:0; // Acknowledge
+- cmd->overflow = (header[1]&0x04)?1:0; // Overflow
+- cmd->underflow = (header[1]&0x02)?1:0; // Underflow
+- cmd->S_bit = (header[1]&0x01)?1:0; // S Bit
+- cmd->status = header[3]; // Status
+- cmd->length = NTOHL(*((unsigned *)(header+4))); // Length
+- cmd->lun = NTOHLL6(*((unsigned long long*)(header+8))); // LUN
+- cmd->task_tag = NTOHL(*((unsigned *)(header+16))); // Task Tag
+- cmd->transfer_tag = NTOHL(*((unsigned *)(header+20))); // Transfer Tag
+- cmd->StatSN = NTOHL(*((unsigned *)(header+24))); // StatSN
+- cmd->ExpCmdSN = NTOHL(*((unsigned *)(header+28))); // ExpCmdSN
+- cmd->MaxCmdSN = NTOHL(*((unsigned *)(header+32))); // MaxCmdSN
+- cmd->DataSN = NTOHL(*((unsigned *)(header+36))); // DataSN
+- cmd->offset = NTOHL(*((unsigned *)(header+40))); // Buffer Offset
+- cmd->res_count = NTOHL( *((unsigned *)(header+44))); // Residual Count
++ cmd->final = (header[1]&0x80)?1:0; /* Final */
++ cmd->ack = (header[1]&0x40)?1:0; /* Acknowledge */
++ cmd->overflow = (header[1]&0x04)?1:0; /* Overflow */
++ cmd->underflow = (header[1]&0x02)?1:0; /* Underflow */
++ cmd->S_bit = (header[1]&0x01)?1:0; /* S Bit */
++ cmd->status = header[3]; /* Status */
++ cmd->length = ISCSI_NTOHL(*((uint32_t *)(header+4))); /* Length */
++ cmd->lun = ISCSI_NTOHLL6(*((uint64_t*)(header+8))); /* LUN */
++ cmd->task_tag = ISCSI_NTOHL(*((uint32_t *)(header+16))); /* Task Tag */
++ cmd->transfer_tag = ISCSI_NTOHL(*((uint32_t *)(header+20))); /* Transfer Tag */
++ cmd->StatSN = ISCSI_NTOHL(*((uint32_t *)(header+24))); /* StatSN */
++ cmd->ExpCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpCmdSN */
++ cmd->MaxCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+32))); /* MaxCmdSN */
++ cmd->DataSN = ISCSI_NTOHL(*((uint32_t *)(header+36))); /* DataSN */
++ cmd->offset = ISCSI_NTOHL(*((uint32_t *)(header+40))); /* Buffer Offset */
++ cmd->res_count = ISCSI_NTOHL( *((uint32_t *)(header+44))); /* Residual Count */
+
+ RETURN_NOT_EQUAL("Byte 0, Bits 0-1", header[0]&0xc0, 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 1, Bits 2-4", header[1]&0x38, 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 2", header[2], 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 4", header[4], 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 8-11", *((unsigned *)(header+8)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 12-15", *((unsigned *)(header+12)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 44-47", *((unsigned *)(header+44)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 8-11", *((uint32_t *)(header+8)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 12-15", *((uint32_t *)(header+12)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *)(header+44)), 0, NO_CLEANUP, 1);
+
+ TRACE(TRACE_ISCSI_ARGS, "Final: %i\n", cmd->final);
+ TRACE(TRACE_ISCSI_ARGS, "Acknowledge: %i\n", cmd->ack);
+@@ -1155,14 +1173,14 @@
+
+ memset(header, 0, ISCSI_HEADER_LEN);
+
+- header[0] |= 0x00|ISCSI_REJECT; // Opcode
++ header[0] |= 0x00|ISCSI_REJECT; /* Opcode */
+ header[1] |= 0x80;
+- header[2] = cmd->reason; // Reason
+- *((unsigned *)(header+4)) = HTONL(cmd->length); // Length
+- *((unsigned *)(header+24)) = HTONL(cmd->StatSN); // StatSN
+- *((unsigned *)(header+28)) = HTONL(cmd->ExpCmdSN); // ExpCmdSN
+- *((unsigned *)(header+32)) = HTONL(cmd->MaxCmdSN); // MaxCmdSN
+- *((unsigned *)(header+36)) = HTONL(cmd->DataSN); // DataSN
++ header[2] = cmd->reason; /* Reason */
++ *((uint32_t *)(header+4)) = ISCSI_HTONL(cmd->length); /* Length */
++ *((uint32_t *)(header+24)) = ISCSI_HTONL(cmd->StatSN); /* StatSN */
++ *((uint32_t *)(header+28)) = ISCSI_HTONL(cmd->ExpCmdSN); /* ExpCmdSN */
++ *((uint32_t *)(header+32)) = ISCSI_HTONL(cmd->MaxCmdSN); /* MaxCmdSN */
++ *((uint32_t *)(header+36)) = ISCSI_HTONL(cmd->DataSN); /* DataSN */
+
+ return 0;
+ }
+@@ -1171,22 +1189,22 @@
+
+ RETURN_NOT_EQUAL("Opcode", ISCSI_OPCODE(header), ISCSI_REJECT, NO_CLEANUP, 1);
+
+- cmd->reason = header[2]; // Reason
+- cmd->length = NTOHL(*((unsigned *)(header+4))); // Length
+- cmd->StatSN = NTOHL(*((unsigned *)(header+24))); // StatSN
+- cmd->ExpCmdSN = NTOHL(*((unsigned *)(header+28))); // ExpCmdSN
+- cmd->MaxCmdSN = NTOHL(*((unsigned *)(header+32))); // MaxCmdSN
+- cmd->DataSN = NTOHL(*((unsigned *)(header+36))); // DataSN
++ cmd->reason = header[2]; /* Reason */
++ cmd->length = ISCSI_NTOHL(*((uint32_t *)(header+4))); /* Length */
++ cmd->StatSN = ISCSI_NTOHL(*((uint32_t *)(header+24))); /* StatSN */
++ cmd->ExpCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpCmdSN */
++ cmd->MaxCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+32))); /* MaxCmdSN */
++ cmd->DataSN = ISCSI_NTOHL(*((uint32_t *)(header+36))); /* DataSN */
+
+ RETURN_NOT_EQUAL("Byte 0, Bits 0-1", header[0]&0xc0, 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 1, Bits 1-7", header[1]&0x7f, 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 3", header[3], 0, NO_CLEANUP, 1);
+ RETURN_NOT_EQUAL("Byte 4", header[4], 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 8-11", *((unsigned *)(header+8)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 12-15", *((unsigned *)(header+12)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 20-23", *((unsigned *)(header+20)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 40-43", *((unsigned *)(header+40)), 0, NO_CLEANUP, 1);
+- RETURN_NOT_EQUAL("Bytes 44-47", *((unsigned *)(header+44)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 8-11", *((uint32_t *)(header+8)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 12-15", *((uint32_t *)(header+12)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 20-23", *((uint32_t *)(header+20)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 40-43", *((uint32_t *)(header+40)), 0, NO_CLEANUP, 1);
++ RETURN_NOT_EQUAL("Bytes 44-47", *((uint32_t *)(header+44)), 0, NO_CLEANUP, 1);
+
+ TRACE(TRACE_ISCSI_ARGS, "Reason: %u\n", cmd->reason);
+ TRACE(TRACE_ISCSI_ARGS, "Length: %u\n", cmd->length);
+@@ -1201,14 +1219,14 @@
+
+ RETURN_NOT_EQUAL("Opcode", ISCSI_OPCODE(header), ISCSI_ASYNC, NO_CLEANUP, 1);
+
+- msg->AHSlength = header[4]; // TotalAHSLength
+- msg->length = NTOHL(*((unsigned *)(header+4))); // Length
+- msg->lun = NTOHLL6(*((unsigned long long*)(header+8))); // LUN
+- msg->StatSN = NTOHL(*((unsigned *)(header+24))); // StatSN
+- msg->ExpCmdSN = NTOHL(*((unsigned *)(header+28))); // ExpCmdSN
+- msg->MaxCmdSN = NTOHL(*((unsigned *)(header+32))); // MaxCmdSN
+- msg->AsyncEvent = header[36]; // Async Event
+- msg->AsyncVCode = header[37]; // Async Vendor Code
++ msg->AHSlength = header[4]; /* TotalAHSLength */
++ msg->length = ISCSI_NTOHL(*((uint32_t *)(header+4))); /* Length */
++ msg->lun = ISCSI_NTOHLL6(*((uint64_t*)(header+8))); /* LUN */
++ msg->StatSN = ISCSI_NTOHL(*((uint32_t *)(header+24))); /* StatSN */
++ msg->ExpCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+28))); /* ExpCmdSN */
++ msg->MaxCmdSN = ISCSI_NTOHL(*((uint32_t *)(header+32))); /* MaxCmdSN */
++ msg->AsyncEvent = header[36]; /* Async Event */
++ msg->AsyncVCode = header[37]; /* Async Vendor Code */
+
+ TRACE(TRACE_ISCSI_ARGS, "TotalAHSLength: %u\n", msg->AHSlength);
+ TRACE(TRACE_ISCSI_ARGS, "DataSegmentLength: %u\n", msg->length);
diff --git a/devel/intel-iscsi/patches/patch-ak b/devel/intel-iscsi/patches/patch-ak
new file mode 100644
index 00000000000..888e017afbe
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-ak
@@ -0,0 +1,117 @@
+$NetBSD: patch-ak,v 1.1.1.1 2005/10/30 21:02:57 agc Exp $
+
+--- src/osd.c 8 Oct 2005 22:21:15 -0000 1.1.1.1
++++ src/osd.c 8 Oct 2005 23:37:34 -0000 1.2
+@@ -305,9 +305,9 @@
+
+ TRACE(TRACE_OSD, "OSD_SET_ATTR(lun %llu, GroupID 0x%x, UserID 0x%llx)\n", args->lun, osd_args.GroupID, osd_args.UserID);
+ for (i=0; i<osd_args.set_attributes_list_length;) {
+- page = NTOHL(*((uint32_t *)(&(set_list[i])))); i+=4;
+- attr = NTOHL(*((uint32_t *)(&(set_list[i])))); i+=4;
+- len = NTOHS(*((uint16_t *)(&(set_list[i])))); i+=2;
++ page = ISCSI_NTOHL(*((uint32_t *)(&(set_list[i])))); i+=4;
++ attr = ISCSI_NTOHL(*((uint32_t *)(&(set_list[i])))); i+=4;
++ len = ISCSI_NTOHS(*((uint16_t *)(&(set_list[i])))); i+=2;
+ sprintf(FileName, "%s/lun_%llu/0x%x/0x%llx.0x%x.%u",
+ base_dir, args->lun, osd_args.GroupID, osd_args.UserID, page, attr);
+ if ((rc=open(FileName, O_WRONLY|O_CREAT, 0644))==-1) {
+@@ -474,18 +474,18 @@
+ int i;
+
+ for (i=0; i<osd_args.get_attributes_list_length;) {
+- page = NTOHL(*((uint32_t *)(&(get_list[i])))); i+=4;
+- index = NTOHL(*((uint32_t *)(&(get_list[i])))); i+=4;
++ page = ISCSI_NTOHL(*((uint32_t *)(&(get_list[i])))); i+=4;
++ index = ISCSI_NTOHL(*((uint32_t *)(&(get_list[i])))); i+=4;
+ TRACE(TRACE_OSD, "GET(0x%x,%u)\n", page, index);
+
+ switch(page) {
+ case (0x40000001):
+ switch(index) {
+ case (0x1):
+- *((uint32_t *)&get_data[attr_len]) = HTONL(page); attr_len +=4;
+- *((uint32_t *)&get_data[attr_len]) = HTONL(index); attr_len +=4;
+- *((uint16_t *)&get_data[attr_len]) = HTONS(4); attr_len +=2;
+- *((uint32_t *)&get_data[attr_len]) = HTONL(GroupID); attr_len += 4;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(page); attr_len +=4;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(index); attr_len +=4;
++ *((uint16_t *)&get_data[attr_len]) = ISCSI_HTONS(4); attr_len +=2;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(GroupID); attr_len += 4;
+ break;
+ default:
+ TRACE_ERROR("unknown attr index %u\n", index);
+@@ -495,16 +495,16 @@
+ case (0x00000001):
+ switch(index) {
+ case (0x1):
+- *((uint32_t *)&get_data[attr_len]) = HTONL(page); attr_len +=4;
+- *((uint32_t *)&get_data[attr_len]) = HTONL(index); attr_len +=4;
+- *((uint16_t *)&get_data[attr_len]) = HTONS(4); attr_len +=2;
+- *((uint32_t *)&get_data[attr_len]) = HTONL(GroupID); attr_len += 4;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(page); attr_len +=4;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(index); attr_len +=4;
++ *((uint16_t *)&get_data[attr_len]) = ISCSI_HTONS(4); attr_len +=2;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(GroupID); attr_len += 4;
+ break;
+ case (0x2):
+- *((uint32_t *)&get_data[attr_len]) = HTONL(page); attr_len +=4;
+- *((uint32_t *)&get_data[attr_len]) = HTONL(index); attr_len +=4;
+- *((uint16_t *)&get_data[attr_len]) = HTONS(8); attr_len +=2;
+- *((uint64_t *)&get_data[attr_len]) = HTONLL(UserID); attr_len += 8;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(page); attr_len +=4;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(index); attr_len +=4;
++ *((uint16_t *)&get_data[attr_len]) = ISCSI_HTONS(8); attr_len +=2;
++ *((uint64_t *)&get_data[attr_len]) = ISCSI_HTONLL(UserID); attr_len += 8;
+ break;
+ default:
+ TRACE_ERROR("unknown attr index %u\n", index);
+@@ -517,9 +517,9 @@
+ case (0x30000000):
+ switch(index) {
+ case (0x1):
+- *((uint32_t *)&get_data[attr_len]) = HTONL(page); attr_len +=4;
+- *((uint32_t *)&get_data[attr_len]) = HTONL(index); attr_len +=4;
+- *((uint16_t *)&get_data[attr_len]) = HTONS(480); attr_len +=2;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(page); attr_len +=4;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(index); attr_len +=4;
++ *((uint16_t *)&get_data[attr_len]) = ISCSI_HTONS(480); attr_len +=2;
+ sprintf(FileName, "%s/lun_%llu/0x%x/0x%llx.0x%x.%u",
+ base_dir, args->lun, osd_args.GroupID, osd_args.UserID, page, index);
+ if ((rc=open(FileName, O_RDONLY, 0644))==-1) {
+@@ -557,25 +557,25 @@
+ switch (osd_args.get_attributes_page) {
+ case (0x40000001):
+ index = 1;
+- *((uint32_t *)&get_data[attr_len]) = HTONL(page); attr_len +=4;
+- *((uint32_t *)&get_data[attr_len]) = HTONL(index); attr_len +=4;
+- *((uint16_t *)&get_data[attr_len]) = HTONS(4); attr_len +=2;
+- *((uint32_t *)&get_data[attr_len]) = HTONL(GroupID); attr_len += 4;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(page); attr_len +=4;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(index); attr_len +=4;
++ *((uint16_t *)&get_data[attr_len]) = ISCSI_HTONS(4); attr_len +=2;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(GroupID); attr_len += 4;
+ break;
+
+ case (0x00000001):
+ index = 2;
+- *((uint32_t *)&get_data[attr_len]) = HTONL(page); attr_len +=4;
+- *((uint32_t *)&get_data[attr_len]) = HTONL(index); attr_len +=4;
+- *((uint16_t *)&get_data[attr_len]) = HTONS(8); attr_len +=2;
+- *((uint64_t *)&get_data[attr_len]) = HTONLL(UserID); attr_len += 8;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(page); attr_len +=4;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(index); attr_len +=4;
++ *((uint16_t *)&get_data[attr_len]) = ISCSI_HTONS(8); attr_len +=2;
++ *((uint64_t *)&get_data[attr_len]) = ISCSI_HTONLL(UserID); attr_len += 8;
+ break;
+
+ case (0x30000000):
+ index = 1;
+- *((uint32_t *)&get_data[attr_len]) = HTONL(page); attr_len +=4;
+- *((uint32_t *)&get_data[attr_len]) = HTONL(index); attr_len +=4;
+- *((uint16_t *)&get_data[attr_len]) = HTONS(480); attr_len +=2;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(page); attr_len +=4;
++ *((uint32_t *)&get_data[attr_len]) = ISCSI_HTONL(index); attr_len +=4;
++ *((uint16_t *)&get_data[attr_len]) = ISCSI_HTONS(480); attr_len +=2;
+ sprintf(FileName, "%s/lun_%llu/0x%x/0x%llx.0x%x.%u",
+ base_dir, args->lun, osd_args.GroupID, osd_args.UserID, page, index);
+ if ((rc=open(FileName, O_RDONLY, 0644))==-1) {
diff --git a/devel/intel-iscsi/patches/patch-al b/devel/intel-iscsi/patches/patch-al
new file mode 100644
index 00000000000..d0c1a03294e
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-al
@@ -0,0 +1,197 @@
+$NetBSD: patch-al,v 1.1.1.1 2005/10/30 21:02:57 agc Exp $
+
+--- src/osdfs.c 8 Oct 2005 22:21:15 -0000 1.1.1.1
++++ src/osdfs.c 8 Oct 2005 23:37:34 -0000 1.2
+@@ -152,7 +152,7 @@
+ }
+ OSD_ENCAP_CDB(args, cdb);
+
+- // Exec SCSI command
++ /* Exec SCSI command */
+
+ scsi_wait_req(SRpnt, cdb, ptr, len, 5*HZ, 5);
+ if (SRpnt->sr_result!=0) {
+@@ -225,14 +225,14 @@
+ struct inode inode;
+ uint16_t len;
+
+- // Get size of directory
++ /* Get size of directory */
+
+ if (osd_get_one_attr((void *)&dev, root_gid, uid, 0x30000000, 0x0, sizeof(struct inode), &osd_exec_via_scsi, &len, (void *) &inode)!=0) {
+ TRACE_ERROR("osd_get_one_attr() failed\n");
+ return -1;
+ }
+
+- // Write entry at end
++ /* Write entry at end */
+
+ sprintf(entry, "%s\n", name);
+ sprintf(entry+strlen(entry), "%li\n", entry_ino);
+@@ -251,7 +251,7 @@
+ uint64_t size;
+ uint64_t dir_uid = (unsigned) dir_ino;
+
+- // Read
++ /* Read */
+
+ if (entries_get(dev, dir_ino, &entries, &num_entries, &size)!=0) {
+ TRACE_ERROR("entries_get() failed\n");
+@@ -349,8 +349,8 @@
+ TRACE(TRACE_OSDFS, "osdfs_get_inode(\"%s\", mode %i (%s))\n", name, mode,
+ S_ISDIR(mode)?"DIR":(S_ISREG(mode)?"REG":"LNK"));
+
+- // iget() gets a free VFS inode and subsequently call
+- // osdfds_read_inode() to fill the inode structure.
++ /* iget() gets a free VFS inode and subsequently call */
++ /* osdfds_read_inode() to fill the inode structure. */
+
+ if ((inode=iget(sb, ino))==NULL) {
+ TRACE_ERROR("iget() failed\n");
+@@ -376,7 +376,7 @@
+ TRACE(TRACE_OSDFS, "osdfs_read_inode(ino 0x%x, major %i, minor %i)\n",
+ (unsigned) ino, MAJOR(dev), MINOR(dev));
+
+- // Get object attributes for rest of inode
++ /* Get object attributes for rest of inode */
+
+ if ((attr=iscsi_malloc_atomic(sizeof(struct inode)))==NULL) {
+ TRACE_ERROR("iscsi_malloc_atomic() failed\n");
+@@ -516,7 +516,7 @@
+
+ TRACE(TRACE_OSDFS, "osdfs_lookup(\"%s\" in dir ino %lu)\n", name, dir->i_ino);
+
+- // Get directory entries
++ /* Get directory entries */
+
+ ISCSI_LOCK_ELSE(&g_mutex, return NULL);
+ if (entries_get(dev, uid, &entries, &num_entries, &size)!=0) {
+@@ -527,7 +527,7 @@
+ ISCSI_UNLOCK_ELSE(&g_mutex, return NULL);
+ TRACE(TRACE_OSDFS, "ino %li has %i entries\n", dir->i_ino, num_entries);
+
+- // Search for this entry
++ /* Search for this entry */
+
+ if (num_entries) {
+ char *ptr = entries;
+@@ -660,14 +660,14 @@
+
+ TRACE(TRACE_OSDFS, "osdfs_mknod(\"%s\")\n", dentry->d_name.name);
+
+- // Create object
++ /* Create object */
+
+ if (osd_create((void *)&dev, root_gid, &osd_exec_via_scsi, &uid)!=0) {
+ TRACE_ERROR("osd_create() failed\n");
+ return -1;
+ }
+
+- // Initialize object attributes
++ /* Initialize object attributes */
+
+ memset(&attr, 0, sizeof(struct inode));
+ attr.i_mode = mode;
+@@ -683,7 +683,7 @@
+ return -1;
+ }
+
+- // Assign to an inode
++ /* Assign to an inode */
+
+ if ((inode = osdfs_get_inode(dir->i_sb, mode, dev, name, uid))==NULL) {
+ TRACE_ERROR("osdfs_get_inode() failed\n");
+@@ -691,7 +691,7 @@
+ }
+ d_instantiate(dentry, inode);
+
+- // Add entry to parent directory
++ /* Add entry to parent directory */
+
+ if (inode->i_ino != 1) {
+ ISCSI_LOCK_ELSE(&g_mutex, return -1);
+@@ -725,7 +725,7 @@
+ * of osdfs_unlink() and osdfs_create().
+ */
+
+- // Delete entry from old directory
++ /* Delete entry from old directory */
+
+ ISCSI_LOCK_ELSE(&g_mutex, return -1);
+ if (entry_del(dev, old_dir_ino, old_ino, old_name, &old_dir->i_size)!=0) {
+@@ -736,7 +736,7 @@
+ osdfs_write_inode(old_dir, 0);
+ ISCSI_UNLOCK_ELSE(&g_mutex, return -1);
+
+- // Unlink entry from new directory
++ /* Unlink entry from new directory */
+
+ if (new_dentry->d_inode) {
+ TRACE(TRACE_OSDFS, "unlinking existing file\n");
+@@ -746,7 +746,7 @@
+ }
+ }
+
+- // Add entry to new directory (might be the same dir)
++ /* Add entry to new directory (might be the same dir) */
+
+ ISCSI_LOCK_ELSE(&g_mutex, return -1);
+ if (entry_add(dev, new_dir_ino, new_ino, new_name, &new_dir->i_size)!=0) {
+@@ -818,9 +818,9 @@
+ }
+ ISCSI_UNLOCK_ELSE(&g_mutex, return -1);
+
+- // Update the offset if our number of entries has changed since the last
+- // call to osdfs_readdir(). filp->private_data stores the number of
+- // entries this directory had on the last call.
++ /* Update the offset if our number of entries has changed since the last */
++ /* call to osdfs_readdir(). filp->private_data stores the number of */
++ /* entries this directory had on the last call. */
+
+ if (offset) {
+ if (((int)filp->private_data)>num_entries) {
+@@ -1001,7 +1001,7 @@
+ }
+ }
+
+- // Initialize superblock
++ /* Initialize superblock */
+
+ sb->s_blocksize = PAGE_CACHE_SIZE;
+ sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
+@@ -1010,7 +1010,7 @@
+
+ if ((root_uid==0)||(root_gid==0)) {
+
+- // Create group object for root directory
++ /* Create group object for root directory */
+
+ if (osd_create_group((void *)&sb->s_dev, &osd_exec_via_scsi, &root_gid)!=0) {
+ TRACE_ERROR("osd_create_group() failed\n");
+@@ -1018,7 +1018,7 @@
+ }
+ PRINT("** ROOT DIRECTORY GROUP OBJECT IS 0x%x **\n", root_gid);
+
+- // Create user object for root directory
++ /* Create user object for root directory */
+
+ if (osd_create((void *)&sb->s_dev, root_gid, &osd_exec_via_scsi, &root_uid)!=0) {
+ TRACE_ERROR("osd_create() failed\n");
+@@ -1026,7 +1026,7 @@
+ }
+ PRINT("** ROOT DIRECTORY USER OBJECT IS 0x%llx **\n", root_uid);
+
+- // Initialize Attributes
++ /* Initialize Attributes */
+
+ memset(&attr, 0, sizeof(struct inode));
+ attr.i_mode = S_IFDIR | 0755;
+@@ -1038,7 +1038,7 @@
+ TRACE(TRACE_OSDFS, "using root directory in 0x%x:0x%llx\n", root_gid, root_uid);
+ }
+
+- // Create inode for root directory
++ /* Create inode for root directory */
+
+ if ((inode=osdfs_get_inode(sb, S_IFDIR | 0755, 0, "/", root_uid))==NULL) {
+ TRACE_ERROR("osdfs_get_inode() failed\n");
diff --git a/devel/intel-iscsi/patches/patch-am b/devel/intel-iscsi/patches/patch-am
new file mode 100644
index 00000000000..771c44c6a8b
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-am
@@ -0,0 +1,434 @@
+$NetBSD: patch-am,v 1.1.1.1 2005/10/30 21:02:58 agc Exp $
+
+--- src/parameters.c 8 Oct 2005 22:21:15 -0000 1.1.1.1
++++ src/parameters.c 8 Oct 2005 23:37:34 -0000 1.2
+@@ -44,7 +44,7 @@
+ int param_list_add(ISCSI_PARAMETER_T **head, int type, char *key, char *dflt, char *valid) {
+ ISCSI_PARAMETER_T *param;
+
+- // Allocated new parameter type
++ /* Allocated new parameter type */
+
+ if (*head==NULL) {
+ if ((*head=iscsi_malloc_atomic(sizeof(ISCSI_PARAMETER_T)))==NULL) {
+@@ -61,21 +61,21 @@
+ param = param->next;
+ }
+
+- // Initilized parameter
++ /* Initilized parameter */
+
+- param->type = type; // type
+- strcpy(param->key, key); // key
+- strcpy(param->dflt, dflt); // default value
+- strcpy(param->valid, valid); // list of valid values
+- param->tx_offer = 0; // sent offer
+- param->rx_offer = 0; // received offer
+- param->tx_answer = 0; // sent answer
+- param->rx_answer = 0; // received answer
+- param->reset = 0; // used to erase value_l on next parse
+- param->next = NULL; // terminate list
++ param->type = type; /* type */
++ strcpy(param->key, key); /* key */
++ strcpy(param->dflt, dflt); /* default value */
++ strcpy(param->valid, valid); /* list of valid values */
++ param->tx_offer = 0; /* sent offer */
++ param->rx_offer = 0; /* received offer */
++ param->tx_answer = 0; /* sent answer */
++ param->rx_answer = 0; /* received answer */
++ param->reset = 0; /* used to erase value_l on next parse */
++ param->next = NULL; /* terminate list */
+
+- // Allocated space for value list and set first item to default; and
+- // set offer and answer lists to NULL
++ /* Allocated space for value list and set first item to default; and */
++ /* set offer and answer lists to NULL */
+
+ if ((param->value_l=iscsi_malloc_atomic(sizeof(ISCSI_PARAMETER_VALUE_T)))==NULL) {
+ TRACE_ERROR("iscsi_malloc_atomic() failed\n");
+@@ -84,7 +84,7 @@
+ param->value_l->next = NULL;
+ strcpy(param->value_l->value, dflt);
+
+- // Arg check
++ /* Arg check */
+
+ switch(type) {
+ case ISCSI_PARAM_TYPE_DECLARATIVE:
+@@ -130,11 +130,11 @@
+ if (tmp->value_l) {
+ for (item_ptr=tmp->value_l; item_ptr!=NULL; item_ptr=next) {
+ next = item_ptr->next;
+- //TRACE(TRACE_ISCSI_PARAM, "freeing \"%s\" (%p)\n", item_ptr->value, item_ptr);
++ /* TRACE(TRACE_ISCSI_PARAM, "freeing \"%s\" (%p)\n", item_ptr->value, item_ptr); */
+ iscsi_free_atomic(item_ptr);
+ }
+ }
+- //TRACE(TRACE_ISCSI_PARAM, "freeing %p\n", tmp);
++ /* TRACE(TRACE_ISCSI_PARAM, "freeing %p\n", tmp); */
+ iscsi_free_atomic(tmp);
+ }
+ return 0;
+@@ -297,7 +297,7 @@
+
+ for (ptr=text; ptr-text<text_len; ptr+=(strlen(ptr)+1)) {
+
+- // Skip over any NULLs
++ /* Skip over any NULLs */
+
+ while (!(*ptr)&&((ptr-text)<text_len)) ptr++;
+ if ((ptr-text)>=text_len) break;
+@@ -372,8 +372,8 @@
+ if (!param_in->rx_offer) {
+ param= param_get(head, "CHAP_A");
+ if (param == NULL) PPS_ERROR;
+- param->tx_offer = 1; // sending an offer
+- param->rx_offer = 0; // reset
++ param->tx_offer = 1; /* sending an offer */
++ param->rx_offer = 0; /* reset */
+ strcpy(param->offer_tx, param->valid);
+ PARAM_TEXT_ADD_ELSE(head, param->key, param->valid,
+ text_out, text_len_out, 0, PPS_ERROR);
+@@ -388,8 +388,8 @@
+
+ param= param_get(head, "CHAP_I");
+ if (param == NULL) PPS_ERROR;
+- param->tx_offer = 1; // sending an offer
+- param->rx_offer = 0; // reset
++ param->tx_offer = 1; /* sending an offer */
++ param->rx_offer = 0; /* reset */
+ GenRandomData(idData, 1);
+ sprintf(chapstring, "%d", idData[0]);
+ strcpy(param->offer_tx, chapstring);
+@@ -398,8 +398,8 @@
+
+ param= param_get(head, "CHAP_C");
+ if (param == NULL) PPS_ERROR;
+- param->tx_offer = 1; // sending an offer
+- param->rx_offer = 0; // reset
++ param->tx_offer = 1; /* sending an offer */
++ param->rx_offer = 0; /* reset */
+ GenRandomData(chapdata, ISCSI_CHAP_DATA_LENGTH);
+ HexDataToText(chapdata, ISCSI_CHAP_DATA_LENGTH,
+ chapstring, ISCSI_CHAP_STRING_LENGTH);
+@@ -411,7 +411,7 @@
+
+ } else if (strcmp(param_in->key, "CHAP_I") == 0) {
+
+- if (param_in->rx_offer) //received answer
++ if (param_in->rx_offer) /* received answer */
+ idData[0] = driver_atoi(param_in->offer_rx);
+ else
+ idData[0] = driver_atoi(param_in->answer_rx);
+@@ -429,8 +429,8 @@
+
+ param= param_get(head, "CHAP_N");
+ if (param == NULL) PPS_ERROR;
+- param->tx_offer = 1; // sending an offer
+- param->rx_offer = 0; // reset
++ param->tx_offer = 1; /* sending an offer */
++ param->rx_offer = 0; /* reset */
+
+ if (param_in->rx_offer)
+ strcpy(param->offer_tx, ISCSI_CHAP_INUSER);
+@@ -442,8 +442,8 @@
+
+ param= param_get(head, "CHAP_R");
+ if (param == NULL) PPS_ERROR;
+- param->tx_offer = 1; // sending an offer
+- param->rx_offer = 0; // reset
++ param->tx_offer = 1; /* sending an offer */
++ param->rx_offer = 0; /* reset */
+ MD5Init(context);
+ MD5Update(context, idData, 1);
+
+@@ -468,8 +468,8 @@
+
+ param= param_get(head, "CHAP_I");
+ if (param == NULL) PPS_ERROR;
+- param->tx_offer = 1; // sending an offer
+- param->rx_offer = 0; // reset
++ param->tx_offer = 1; /* sending an offer */
++ param->rx_offer = 0; /* reset */
+ GenRandomData(idData, 1);
+ sprintf(chapstring, "%d", idData[0]);
+ strcpy(param->offer_tx, chapstring);
+@@ -478,8 +478,8 @@
+
+ param= param_get(head, "CHAP_C");
+ if (param == NULL) PPS_ERROR;
+- param->tx_offer = 1; // sending an offer
+- param->rx_offer = 0; // reset
++ param->tx_offer = 1; /* sending an offer */
++ param->rx_offer = 0; /* reset */
+ GenRandomData(chapdata, ISCSI_CHAP_DATA_LENGTH);
+ HexDataToText(chapdata, ISCSI_CHAP_DATA_LENGTH,
+ chapstring, ISCSI_CHAP_STRING_LENGTH);
+@@ -565,9 +565,9 @@
+ char c;
+ int ret;
+
+- // Whether incoming or outgoing, some of the params might be offers and some answers. Incoming
+- // text has the potential for creating outgoing text - and this will happen when the incoming
+- // text has offers that need an answer.
++ /* Whether incoming or outgoing, some of the params might be offers and some answers. Incoming */
++ /* text has the potential for creating outgoing text - and this will happen when the incoming */
++ /* text has offers that need an answer. */
+
+ TRACE(TRACE_ISCSI_PARAM, "parsing %i %s bytes of text parameters\n", text_len_in, outgoing?"outgoing":"incoming");
+
+@@ -617,12 +617,12 @@
+
+ for (ptr=text_in; ptr-text_in<text_len_in; ptr+=(strlen(ptr)+1)) {
+
+- // Skip over any NULLs
++ /* Skip over any NULLs */
+
+ while (!(*ptr)&&((ptr-text_in)<text_len_in)) ptr++;
+ if ((ptr-text_in)>=text_len_in) break;
+
+- // Extract <key>=<value> token from text_in
++ /* Extract <key>=<value> token from text_in */
+
+ if ((delim_ptr=strchr(ptr, '='))==NULL) {
+ TRACE_ERROR("delimiter \'=\' not found in token \"%s\"\n", ptr);
+@@ -633,7 +633,7 @@
+ if(tmp_key) {
+ strncpy(tmp_key, ptr, delim_ptr-ptr);
+ tmp_key[delim_ptr-ptr] = '\0';
+- // Key not understood.
++ /* Key not understood. */
+ PARAM_TEXT_ADD_ELSE(head, tmp_key, "NotUnderstood", text_out, text_len_out, 0, PTP_ERROR);
+ }
+ } else {
+@@ -645,14 +645,14 @@
+ value = delim_ptr+1;
+ }
+
+- // Find key in param list
++ /* Find key in param list */
+
+ for (param=head; param!=NULL; param=param->next) {
+ if (strcmp(param->key, key)==0) break;
+ }
+ if (param==NULL) {
+ if( !outgoing ) {
+- // Key not understood.
++ /* Key not understood. */
+ PARAM_TEXT_ADD_ELSE(head, key, "NotUnderstood", text_out, text_len_out, 0, PTP_ERROR);
+ } else {
+ PRINT("ignoring \"%s\"\n", key);
+@@ -662,18 +662,18 @@
+
+ RETURN_GREATER("strlen(value)", strlen(value), ISCSI_PARAM_MAX_LEN, PTP_CLEANUP, -1);
+
+- // We're sending|receiving an offer|answer
++ /* We're sending|receiving an offer|answer */
+
+ if (outgoing) {
+ if (param->rx_offer) {
+- param->tx_answer = 1; // sending an answer
++ param->tx_answer = 1; /* sending an answer */
+ strcpy(param->answer_tx, value);
+ TRACE(TRACE_ISCSI_PARAM, "sending answer \"%s\"=\"%s\" for offer \"%s\"\n",
+ param->key, param->answer_tx, param->offer_rx);
+ goto negotiate;
+ } else {
+- param->tx_offer = 1; // sending an offer
+- param->rx_offer = 0; // reset
++ param->tx_offer = 1; /* sending an offer */
++ param->rx_offer = 0; /* reset */
+ strcpy(param->offer_tx, value);
+ TRACE(TRACE_ISCSI_PARAM, "sending offer \"%s\"=\"%s\"\n", param->key, param->offer_tx);
+ if ((param->type == ISCSI_PARAM_TYPE_DECLARATIVE)||
+@@ -684,8 +684,8 @@
+ }
+ } else {
+ if (param->tx_offer) {
+- param->rx_answer = 1; // received an answer
+- param->tx_offer = 0; // reset
++ param->rx_answer = 1; /* received an answer */
++ param->tx_offer = 0; /* reset */
+ strcpy(param->answer_rx, value);
+ TRACE(TRACE_ISCSI_PARAM, "received answer \"%s\"=\"%s\" for offer \"%s\"\n",
+ param->key, param->answer_rx, param->offer_tx);
+@@ -707,7 +707,7 @@
+ PTP_CLEANUP;
+ return (ISCSI_PARAM_STATUS_AUTH_FAILED);
+ } else {
+- param->rx_offer = 1; // received an offer
++ param->rx_offer = 1; /* received an offer */
+ strcpy(param->offer_rx, value);
+ TRACE(TRACE_ISCSI_PARAM, "received offer \"%s\"=\"%s\"\n", param->key, param->offer_rx);
+
+@@ -729,7 +729,7 @@
+ }
+ }
+
+- // Answer the offer if it is an inquiry or the type is not DECLARATIVE
++ /* Answer the offer if it is an inquiry or the type is not DECLARATIVE */
+
+ if ((strcmp(param->offer_rx, "?")!=0) && ((param->type == ISCSI_PARAM_TYPE_DECLARATIVE)||(param->type == ISCSI_PARAM_TYPE_DECLARE_MULTI))) {
+ goto negotiate;
+@@ -741,7 +741,7 @@
+
+ answer:
+
+- // Answer with current value if this is an inquiry (<key>=?)
++ /* Answer with current value if this is an inquiry (<key>=?) */
+
+ if (!strcmp(value, "?")) {
+ TRACE(TRACE_ISCSI_PARAM, "got inquiry for param \"%s\"\n", param->key);
+@@ -759,7 +759,7 @@
+ goto add_answer;
+ }
+
+- // Generate answer according to the parameter type
++ /* Generate answer according to the parameter type */
+
+ switch(param->type) {
+
+@@ -773,9 +773,9 @@
+ goto add_answer;
+ }
+ if (strchr(param->valid, ',')!=NULL) {
+- strcpy(param->answer_tx, value); // we accept both yes and no, so answer w/ their offer
++ strcpy(param->answer_tx, value); /* we accept both yes and no, so answer w/ their offer */
+ } else {
+- strcpy(param->answer_tx, param->valid); // answer with the only value we support
++ strcpy(param->answer_tx, param->valid); /* answer with the only value we support */
+ }
+ break;
+
+@@ -812,7 +812,7 @@
+ }
+ }
+
+- // Find the first valid offer that we support
++ /* Find the first valid offer that we support */
+
+ for (p1=p2=param->offer_rx; p2; p1=p2+1) {
+ if ((p2=strchr(p1, ','))) {
+@@ -854,19 +854,19 @@
+ max_i = iscsi_atoi(param->valid);
+ if (param->type == ISCSI_PARAM_TYPE_NUMERICAL_Z) {
+ if (max_i == 0) {
+- answer_i = offer_i; // we support anything, so return whatever they offered
++ answer_i = offer_i; /* we support anything, so return whatever they offered */
+ } else if (offer_i == 0) {
+- answer_i = max_i; // return only what we can support
++ answer_i = max_i; /* return only what we can support */
+ } else if (offer_i>max_i) {
+- answer_i = max_i; // we are the lower of the two
++ answer_i = max_i; /* we are the lower of the two */
+ } else {
+- answer_i = offer_i; // they are the lower of the two
++ answer_i = offer_i; /* they are the lower of the two */
+ }
+ } else {
+ if (offer_i>max_i) {
+- answer_i = max_i; // we are the lower of the two
++ answer_i = max_i; /* we are the lower of the two */
+ } else {
+- answer_i = offer_i; // they are the lower of the two
++ answer_i = offer_i; /* they are the lower of the two */
+ }
+ }
+ sprintf(param->answer_tx, "%i", answer_i);
+@@ -880,7 +880,7 @@
+ goto next;
+
+
+- // Negotiate after receiving|sending an answer
++ /* Negotiate after receiving|sending an answer */
+
+ negotiate: switch(param->type) {
+ case ISCSI_PARAM_TYPE_DECLARE_MULTI:
+@@ -903,11 +903,11 @@
+ } else {
+ strcpy(val1, param->answer_rx);
+ strcpy(val2, param->offer_tx);
+- // Make sure the answer is valid
++ /* Make sure the answer is valid */
+ if( strcmp(val1, "Yes") && strcmp(val1, "No") &&
+ strcmp(val1, "yes") && strcmp(val1, "no") &&
+ strcmp(val1, "Irrelevant")) {
+- // Invalid value returned as answer.
++ /* Invalid value returned as answer. */
+ TRACE_ERROR("Invalid answer (%s) for key (%s)\n",
+ val1, key);
+ PTP_ERROR;
+@@ -962,28 +962,28 @@
+ case ISCSI_PARAM_TYPE_LIST:
+ if (outgoing) {
+ if (param->tx_offer) {
+- TRACE_ERROR("we should not be here\n"); // error - we're sending an offer
++ TRACE_ERROR("we should not be here\n"); /* error - we're sending an offer */
+ PTP_ERROR;
+ } else if (param->tx_answer) {
+- strcpy(val1, param->answer_tx); // we're sending an answer
++ strcpy(val1, param->answer_tx); /* we're sending an answer */
+ } else {
+ TRACE_ERROR("unexpected error\n");
+ PTP_ERROR;
+ }
+ } else {
+ if (param->rx_offer) {
+- TRACE_ERROR("we should not be here\n"); // error - we received an offer
++ TRACE_ERROR("we should not be here\n"); /* error - we received an offer */
+ PTP_ERROR;
+ } else if (param->rx_answer) {
+- strcpy(val1, param->answer_rx); // we received an answer
++ strcpy(val1, param->answer_rx); /* we received an answer */
+ } else {
+ TRACE_ERROR("unexpected error\n");
+ PTP_ERROR;
+ }
+ }
+
+- // Make sure incoming or outgoing answer is valid
+- // None, Reject, Irrelevant and NotUnderstood are valid
++ /* Make sure incoming or outgoing answer is valid */
++ /* None, Reject, Irrelevant and NotUnderstood are valid */
+ if ((!strcmp(val1, "None")) || (!strcmp(val1, "Reject")) ||
+ (!strcmp(val1, "Irrelevant")) || (!strcmp(val1, "NotUnderstood"))) {
+ goto value_ok;
+@@ -1013,22 +1013,22 @@
+
+ TRACE(TRACE_ISCSI_PARAM, "negotiated \"%s\"=\"%s\"\n", param->key, param->negotiated);
+
+- // For inquiries, we don't commit the value.
++ /* For inquiries, we don't commit the value. */
+
+ if (param->tx_offer&&!strcmp(param->offer_tx, "?")) {
+- // we're offering an inquiry
++ /* we're offering an inquiry */
+ TRACE(TRACE_ISCSI_PARAM, "sending an inquiry for \"%s\"\n", param->key);
+ goto next;
+ } else if (param->rx_offer&&!strcmp(param->offer_rx, "?")) {
+- // we're receiving an inquiry
++ /* we're receiving an inquiry */
+ TRACE(TRACE_ISCSI_PARAM, "received an inquiry for \"%s\"\n", param->key);
+ goto next;
+ } else if (param->tx_answer&&!strcmp(param->offer_rx, "?")) {
+- // we're answering an inquiry
++ /* we're answering an inquiry */
+ TRACE(TRACE_ISCSI_PARAM, "answering an inquiry for \"%s\"\n", param->key);
+ goto next;
+ } else if (param->rx_answer&&!strcmp(param->offer_tx, "?")) {
+- // we're receiving an answer for our inquiry
++ /* we're receiving an answer for our inquiry */
+ TRACE(TRACE_ISCSI_PARAM, "received an answer for inquiry on \"%s\"\n", param->key);
+ goto next;
+ }
+@@ -1083,8 +1083,8 @@
+
+ void set_session_parameters( ISCSI_PARAMETER_T *head,
+ ISCSI_SESS_PARAM_T *sess_params ) {
+- // These parameters are standard and assuming that they are always
+- // present in the list (head).
++ /* These parameters are standard and assuming that they are always */
++ /* present in the list (head). */
+ memset( sess_params, 0, sizeof(ISCSI_SESS_PARAM_T) );
+ sess_params->max_burst_length = param_atoi(head, "MaxBurstLength");
+ sess_params->first_burst_length = param_atoi(head, "FirstBurstLength");
diff --git a/devel/intel-iscsi/patches/patch-an b/devel/intel-iscsi/patches/patch-an
new file mode 100644
index 00000000000..0516b2c8137
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-an
@@ -0,0 +1,46 @@
+$NetBSD: patch-an,v 1.1.1.1 2005/10/30 21:02:58 agc Exp $
+
+--- src/so.c 8 Oct 2005 22:21:15 -0000 1.1.1.1
++++ src/so.c 8 Oct 2005 23:37:34 -0000 1.2
+@@ -678,7 +678,7 @@
+ SRpnt->sr_device->remap = 1;
+ SRpnt->sr_device->sector_size = 512;
+
+- //printk("%s : block size assumed to be 512 bytes, osd size 1GB. \n", nbuff);
++ /* printk("%s : block size assumed to be 512 bytes, osd size 1GB. \n", nbuff); */
+
+ /* Wake up a process waiting for device */
+
+@@ -772,10 +772,10 @@
+ /* Initialize Things */
+
+ for (i=0; i<so_template.dev_max; i++) {
+- so_blocksizes[i] = 1024; // minimum request/block size
+- so_sizes[i] = 1; // number of blocks
+- so_hardsizes[i] = 512; // sector size
+- so[i].nr_sects = 2; // number of sectors
++ so_blocksizes[i] = 1024; /* minimum request/block size */
++ so_sizes[i] = 1; /* number of blocks */
++ so_hardsizes[i] = 512; /* sector size */
++ so[i].nr_sects = 2; /* number of sectors */
+ }
+
+ /* ??? */
+@@ -937,7 +937,7 @@
+
+ for (i = max_p - 1; i >= 0; i--) {
+ int index = start + i;
+- //invalidate_device(MKDEV(MAJOR(index),MINOR(index)), 1);
++ /* invalidate_device(MKDEV(MAJOR(index),MINOR(index)), 1); */
+ so_gendisk.part[index].start_sect = 0;
+ so_gendisk.part[index].nr_sects = 0;
+ /*
+@@ -987,7 +987,7 @@
+
+ for (j = max_p - 1; j >= 0; j--) {
+ int index = start + j;
+- //invalidate_device(MKDEV(MAJOR(index),MINOR(index)), 1);
++ /* invalidate_device(MKDEV(MAJOR(index),MINOR(index)), 1); */
+ so_gendisk.part[index].start_sect = 0;
+ so_gendisk.part[index].nr_sects = 0;
+ so_sizes[index] = 0;
diff --git a/devel/intel-iscsi/patches/patch-ao b/devel/intel-iscsi/patches/patch-ao
new file mode 100644
index 00000000000..79faccc1da8
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-ao
@@ -0,0 +1,22 @@
+$NetBSD: patch-ao,v 1.1.1.1 2005/10/30 21:02:58 agc Exp $
+
+--- src/target.c 8 Oct 2005 22:21:15 -0000 1.1.1.1
++++ src/target.c 8 Oct 2005 23:37:34 -0000 1.2
+@@ -394,7 +394,7 @@
+ TRACE(TRACE_ISCSI_DEBUG, "read %i bytes AHS\n", scsi_cmd.ahs_len);
+ ahs_ptr = scsi_cmd.ahs;
+ while (ahs_ptr<(scsi_cmd.ahs+scsi_cmd.ahs_len-1)) {
+- ahs_len = NTOHS(*((unsigned short *)ahs_ptr));
++ ahs_len = ISCSI_NTOHS(*((unsigned short *)ahs_ptr));
+ RETURN_EQUAL("AHS Length", ahs_len, 0, AHS_CLEANUP, -1);
+ ahs_type = *(ahs_ptr+2);
+ switch(ahs_type) {
+@@ -403,7 +403,7 @@
+ scsi_cmd.ext_cdb = ahs_ptr+4;
+ break;
+ case 0x02:
+- scsi_cmd.bidi_trans_len = NTOHL(*((unsigned *)(ahs_ptr+4)));
++ scsi_cmd.bidi_trans_len = ISCSI_NTOHL(*((unsigned *)(ahs_ptr+4)));
+ TRACE(TRACE_ISCSI_DEBUG, "Got Bidirectional Read AHS (expected read length %u)\n", scsi_cmd.bidi_trans_len);
+ break;
+ default:
diff --git a/devel/intel-iscsi/patches/patch-ap b/devel/intel-iscsi/patches/patch-ap
new file mode 100644
index 00000000000..fcb599cbb30
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-ap
@@ -0,0 +1,93 @@
+$NetBSD: patch-ap,v 1.1.1.1 2005/10/30 21:02:58 agc Exp $
+
+--- src/tests.c 8 Oct 2005 22:21:15 -0000 1.1.1.1
++++ src/tests.c 8 Oct 2005 23:37:34 -0000 1.3
+@@ -45,10 +45,14 @@
+ #include <sys/types.h>
+ #include <utime.h>
+
+-#ifndef FreeBSD
++#ifdef __linux__
+ #include <scsi/scsi.h>
+ #endif
+
++#ifdef __NetBSD__
++#include "scsi_cmd_codes.h"
++#endif
++
+ #include <unistd.h>
+ #include <netinet/in.h>
+ #include <sys/uio.h>
+@@ -188,8 +192,8 @@
+ }
+ TRACE(TRACE_SCSI_DEBUG, "Max LBA (lun %u): %u\n", lun, *max_lba);
+ TRACE(TRACE_SCSI_DEBUG, "Block Len (lun %u): %u\n", lun, *block_len);
+- *max_lba = NTOHL(*((unsigned *)(data)));
+- *block_len = NTOHL(*((unsigned *)(data+4)));
++ *max_lba = ISCSI_NTOHL(*((unsigned *)(data)));
++ *block_len = ISCSI_NTOHL(*((unsigned *)(data+4)));
+ if (*max_lba == 0) {
+ TRACE_ERROR("Device returned Maximum LBA of zero\n");
+ return -1;
+@@ -255,7 +259,7 @@
+ #endif
+
+ } else {
+- *((unsigned *)(cdb+0)) = HTONL(i);
++ *((unsigned *)(cdb+0)) = ISCSI_HTONL(i);
+ cdb[0] = WRITE_6;
+ cdb[1] = (cdb[1]&0x1f)|lun<<5;
+ cdb[4] = len;
+@@ -309,7 +313,7 @@
+ #endif
+
+ } else {
+- *((unsigned *)(cdb+0)) = HTONL(i);
++ *((unsigned *)(cdb+0)) = ISCSI_HTONL(i);
+ cdb[0] = READ_6;
+ cdb[1] = (cdb[1]&0x1f)|lun<<5;
+ cdb[4] = len;
+@@ -1160,8 +1164,8 @@
+ PRINT("inquiry() PASSED: device type 0x%x\n", device_type);
+ PRINT("##END INITIAL TESTS[%i:%i]##\n\n", tid, lun);
+
+-#if 0
+- // iSCSI Latency Tests
++#if 1
++ /* iSCSI Latency Tests */
+
+ PRINT("##BEGIN iSCSI LATENCY TESTS[%i:%i]##\n", tid, lun);
+ if (nop_test(tid, lun, 1000)!=0) {
+@@ -1219,10 +1223,13 @@
+ // Build AHS for expected bidi read length
+
+ if (m->send_len && m->recv_len) {
++ uint32_t AHS_length;
++
+ memset(ahs_ptr, 0, 8);
+- *((unsigned *)ahs_ptr) = HTONS(8); // AHS length
+- ahs_ptr[2] = 0x02; // Type
+- *((unsigned *)(ahs_ptr+4)) = HTONL(m->recv_len); // Expected Read length
++ AHS_length = 8;
++ *((unsigned *)ahs_ptr) = ISCSI_HTONL(AHS_length); /* AHS length */
++ ahs_ptr[2] = 0x02; /* Type */
++ *((unsigned *)(ahs_ptr+4)) = ISCSI_HTONL(m->recv_len); /* Expected Read length */
+ ahs_ptr += 8; ahs_len += 8;
+ }
+
+@@ -1231,9 +1238,12 @@
+ OSD_ENCAP_CDB(args, cdb);
+ //OSD_PRINT_CDB(cdb, cdb+16);
+ memset(ahs_ptr, 0, 4);
+- *((uint16_t *)ahs_ptr) = HTONS(CONFIG_OSD_CDB_LEN-15); // AHS length
+- ahs_ptr[2] = 0x01; // Type
+- memcpy(ahs_ptr+4, cdb+16, CONFIG_OSD_CDB_LEN-16); // Copy remaining CDB
++ {
++ uint16_t AHS_length = (CONFIG_OSD_CDB_LEN - 15); /* AHS length */
++ *((uint16_t *)ahs_ptr) = ISCSI_HTONS(AHS_length); /* AHS length */
++ }
++ ahs_ptr[2] = 0x01; /* Type */
++ memcpy(ahs_ptr+4, cdb+16, CONFIG_OSD_CDB_LEN-16); /* Copy remaining CDB */
+ ahs_ptr += CONFIG_OSD_CDB_LEN-15; ahs_len += CONFIG_OSD_CDB_LEN-15;
+
+ // Build ISCSI_SCSI_CMD_T
diff --git a/devel/intel-iscsi/patches/patch-as b/devel/intel-iscsi/patches/patch-as
new file mode 100644
index 00000000000..cbf59a47af7
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-as
@@ -0,0 +1,20 @@
+$NetBSD: patch-as,v 1.1.1.1 2005/10/30 21:02:58 agc Exp $
+
+--- src/utest.c 8 Oct 2005 22:21:15 -0000 1.1.1.1
++++ src/utest.c 8 Oct 2005 23:37:34 -0000 1.3
+@@ -41,10 +41,14 @@
+ #include <unistd.h>
+ #include <signal.h>
+
+-#ifndef FreeBSD
++#ifdef __linux__
+ #include <scsi/scsi.h>
+ #endif
+
++#ifdef __NetBSD__
++#include "scsi_cmd_codes.h"
++#endif
++
+ #include "iscsi.h"
+ #include "initiator.h"
+ #include "tests.h"
diff --git a/devel/intel-iscsi/patches/patch-at b/devel/intel-iscsi/patches/patch-at
new file mode 100644
index 00000000000..49f3c426434
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-at
@@ -0,0 +1,41 @@
+$NetBSD: patch-at,v 1.1.1.1 2005/10/30 21:02:58 agc Exp $
+
+--- src/util.c 8 Oct 2005 22:21:15 -0000 1.1.1.1
++++ src/util.c 10 Oct 2005 21:42:24 -0000 1.4
+@@ -545,7 +545,7 @@
+ memset((char *)&laddr, 0, sizeof(laddr));
+ laddr.sin_family = AF_INET;
+ laddr.sin_addr.s_addr = INADDR_ANY;
+- laddr.sin_port = HTONS(port);
++ laddr.sin_port = ISCSI_HTONS(port);
+ #ifdef __KERNEL__
+ if ((rc=sock->ops->bind(sock, (struct sockaddr*) &laddr, sizeof(laddr)))<0) {
+ TRACE_ERROR("sock->ops->bind() failed: rc %i\n", rc);
+@@ -717,7 +717,7 @@
+
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+- addr.sin_port = HTONS(port);
++ addr.sin_port = ISCSI_HTONS(port);
+ addr.sin_family = AF_INET;
+
+ for (i=0; i<ISCSI_SOCK_CONNECT_TIMEOUT; i++) {
+@@ -830,7 +830,7 @@
+ // the iovec will get altered below on partial sends/recvs.
+
+ #ifdef CONFIG_ISCSI_DEBUG
+- if ((iov_orig=iscsi_malloc_atomic(iov_len*sizeof(struct iovec)))==NULL) {
++ if ((iov_orig=iscsi_malloc_atomic((iov_len + 1)*sizeof(struct iovec)))==NULL) {
+ TRACE_ERROR("iscsi_malloc_atomic() failed\n");
+ return -1;
+ }
+@@ -996,7 +996,9 @@
+ #else
+ pthread_mutexattr_t mattr;
+ pthread_mutexattr_init(&mattr);
++# ifdef PTHREAD_MUTEX_ADAPTIVE_NP
+ pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_ADAPTIVE_NP);
++# endif
+ if(pthread_mutex_init(lock, &mattr)!=0)
+ return -1;
+ #endif
diff --git a/devel/intel-iscsi/patches/patch-au b/devel/intel-iscsi/patches/patch-au
new file mode 100644
index 00000000000..c299bc96879
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-au
@@ -0,0 +1,90 @@
+$NetBSD: patch-au,v 1.1.1.1 2005/10/30 21:02:58 agc Exp $
+
+--- src/osd_ops.c 2005/10/27 19:19:42 1.1
++++ src/osd_ops.c 2005/10/27 19:27:44
+@@ -45,17 +45,17 @@
+ int i = 0;
+
+ for (i=0; i<length;) {
+- if (NTOHL(*(uint32_t *)(data+i))!=page) {
+- TRACE_ERROR("page mismatch: got 0x%x, expected 0x%x\n", NTOHL(*(uint32_t *)(data+i)), page);
++ if (ISCSI_NTOHL(*(uint32_t *)(data+i))!=page) {
++ TRACE_ERROR("page mismatch: got 0x%x, expected 0x%x\n", ISCSI_NTOHL(*(uint32_t *)(data+i)), page);
+ return -1;
+ }
+ i+=4;
+- if (NTOHL(*(uint32_t *)(data+i))!=index) {
++ if (ISCSI_NTOHL(*(uint32_t *)(data+i))!=index) {
+ TRACE_ERROR("index mismatch\n");
+ return -1;
+ }
+ i+=4;
+- if (NTOHS(*(uint16_t *)(data+i))!=len) {
++ if (ISCSI_NTOHS(*(uint16_t *)(data+i))!=len) {
+ TRACE_ERROR("len mismatch\n");
+ return -1;
+ }
+@@ -88,8 +88,8 @@
+ #if 0
+ args.length = 8;
+ args.get_attributes_list_length = 8;
+- *((unsigned long*)get_list) = HTONL(0x40000001);
+- *((unsigned long*)(get_list+4)) = HTONL(0x1);
++ *((unsigned long*)get_list) = ISCSI_HTONL(0x40000001);
++ *((unsigned long*)(get_list+4)) = ISCSI_HTONL(0x1);
+ mem.send_data = get_list; mem.send_len = 8; mem.send_sg = 0;
+ #else
+ args.get_attributes_page = 0x40000001;
+@@ -105,7 +105,7 @@
+ TRACE_ERROR("extract_attributes() failed\n");
+ return -1;
+ }
+- *GroupID = NTOHL(*GroupID);
++ *GroupID = ISCSI_NTOHL(*GroupID);
+ TRACE(TRACE_OSD, "osd_create_group() OK --> GroupID 0x%x\n", *GroupID);
+
+ return 0;
+@@ -131,8 +131,8 @@
+ #if 0
+ args.length = 8;
+ args.get_attributes_list_length = 8;
+- *((unsigned long*)get_list) = HTONL(0x00000001);
+- *((unsigned long*)(get_list+4)) = HTONL(0x2);
++ *((unsigned long*)get_list) = ISCSI_HTONL(0x00000001);
++ *((unsigned long*)(get_list+4)) = ISCSI_HTONL(0x2);
+ mem.send_data = get_list; mem.send_len = 8; mem.send_sg = 0;
+ #else
+ args.get_attributes_page = 0x000000001;
+@@ -148,7 +148,7 @@
+ TRACE_ERROR("extract_attributes() failed\n");
+ return -1;
+ }
+- *UserID = NTOHLL(*UserID);
++ *UserID = ISCSI_NTOHLL(*UserID);
+ TRACE(TRACE_OSD, "osd_create(GroupID 0x%x) OK --> UserID 0x%llx\n", GroupID, *UserID);
+
+ return 0;
+@@ -264,9 +264,9 @@
+ args.UserID = UserID;
+ args.length = 10+len;
+ args.set_attributes_list_length = 10+len;
+- *((uint32_t *) (list+0)) = HTONL(page);
+- *((uint32_t *) (list+4)) = HTONL(index);
+- *((uint16_t *) (list+8)) = HTONS(len);
++ *((uint32_t *) (list+0)) = ISCSI_HTONL(page);
++ *((uint32_t *) (list+4)) = ISCSI_HTONL(index);
++ *((uint16_t *) (list+8)) = ISCSI_HTONS(len);
+ #if 0
+ sg[0].iov_base = list;
+ sg[0].iov_len = 10;
+@@ -316,8 +316,8 @@
+ args.UserID = UserID;
+ if (index) {
+ args.length = 8;
+- *((uint32_t *)(list_out+0)) = HTONL(page);
+- *((uint32_t *)(list_out+4)) = HTONL(index);
++ *((uint32_t *)(list_out+0)) = ISCSI_HTONL(page);
++ *((uint32_t *)(list_out+4)) = ISCSI_HTONL(index);
+ args.get_attributes_list_length = 8;
+ mem.send_data = list_out; mem.send_len = 8; mem.send_sg = 0;
+ } else {
diff --git a/devel/intel-iscsi/patches/patch-av b/devel/intel-iscsi/patches/patch-av
new file mode 100644
index 00000000000..d50d627a3de
--- /dev/null
+++ b/devel/intel-iscsi/patches/patch-av
@@ -0,0 +1,88 @@
+$NetBSD: patch-av,v 1.1.1.1 2005/10/30 21:02:58 agc Exp $
+
+--- include/osd.h 2005/10/27 20:12:05 1.1
++++ include/osd.h 2005/10/27 20:12:53
+@@ -88,53 +88,53 @@
+ (CDB)[1] = (ARGS)->control; \
+ (CDB)[6] = (ARGS)->security; \
+ (CDB)[7] = (ARGS)->add_cdb_len; \
+-*((uint16_t *)((CDB)+8)) = HTONS((ARGS)->service_action); \
++*((uint16_t *)((CDB)+8)) = ISCSI_HTONS((ARGS)->service_action); \
+ (CDB)[10] = (ARGS)->options_byte; \
+ (CDB)[11] = (ARGS)->second_options_byte; \
+-*((uint32_t *)((CDB)+12)) = HTONL((ARGS)->GroupID); \
+-*((uint64_t *)((CDB)+16)) = HTONLL((ARGS)->UserID); \
+-*((uint32_t *)((CDB)+24)) = HTONL((ARGS)->SessionID); \
+-*((uint64_t *)((CDB)+28)) = HTONLL((ARGS)->length); \
+-*((uint64_t *)((CDB)+36)) = HTONLL((ARGS)->offset); \
+-*((uint32_t *)((CDB)+44)) = HTONL((ARGS)->get_attributes_page); \
+-*((uint32_t *)((CDB)+48)) = HTONL((ARGS)->get_attributes_list_length); \
+-*((uint32_t *)((CDB)+52)) = HTONL((ARGS)->get_attributes_allocation_length); \
+-*((uint32_t *)((CDB)+72)) = HTONL((ARGS)->set_attributes_list_length);
++*((uint32_t *)((CDB)+12)) = ISCSI_HTONL((ARGS)->GroupID); \
++*((uint64_t *)((CDB)+16)) = ISCSI_HTONLL((ARGS)->UserID); \
++*((uint32_t *)((CDB)+24)) = ISCSI_HTONL((ARGS)->SessionID); \
++*((uint64_t *)((CDB)+28)) = ISCSI_HTONLL((ARGS)->length); \
++*((uint64_t *)((CDB)+36)) = ISCSI_HTONLL((ARGS)->offset); \
++*((uint32_t *)((CDB)+44)) = ISCSI_HTONL((ARGS)->get_attributes_page); \
++*((uint32_t *)((CDB)+48)) = ISCSI_HTONL((ARGS)->get_attributes_list_length); \
++*((uint32_t *)((CDB)+52)) = ISCSI_HTONL((ARGS)->get_attributes_allocation_length); \
++*((uint32_t *)((CDB)+72)) = ISCSI_HTONL((ARGS)->set_attributes_list_length);
+
+ #define OSD_DECAP_CDB(CDB, EXT_CDB, ARGS) \
+ (ARGS)->opcode = (CDB)[0]; \
+ (ARGS)->control = (CDB)[1]; \
+ (ARGS)->security = (CDB)[6]; \
+ (ARGS)->add_cdb_len = (CDB)[7]; \
+-(ARGS)->service_action = NTOHS(*((uint16_t *)((CDB)+8))); \
++(ARGS)->service_action = ISCSI_NTOHS(*((uint16_t *)((CDB)+8))); \
+ (ARGS)->options_byte = (CDB)[10]; \
+ (ARGS)->second_options_byte = (CDB)[11]; \
+-(ARGS)->GroupID = NTOHL(*((uint32_t *)((CDB)+12))); \
+-(ARGS)->UserID = NTOHLL(*((uint64_t *)((EXT_CDB)-16+16))); \
+-(ARGS)->SessionID = NTOHL(*((uint32_t *)((EXT_CDB)-16+24))); \
+-(ARGS)->length = NTOHLL(*((uint64_t *)((EXT_CDB)-16+28))); \
+-(ARGS)->offset = NTOHLL(*((uint64_t *)((EXT_CDB)-16+36))); \
+-(ARGS)->get_attributes_page = NTOHL(*((uint32_t *)((EXT_CDB)-16+44))); \
+-(ARGS)->get_attributes_list_length = NTOHL(*((uint32_t *)((EXT_CDB)-16+48))); \
+-(ARGS)->get_attributes_allocation_length = NTOHL(*((uint32_t *)((EXT_CDB)-16+52))); \
+-(ARGS)->set_attributes_list_length = NTOHL(*((uint32_t *)((EXT_CDB)-16+72)));
++(ARGS)->GroupID = ISCSI_NTOHL(*((uint32_t *)((CDB)+12))); \
++(ARGS)->UserID = ISCSI_NTOHLL(*((uint64_t *)((EXT_CDB)-16+16))); \
++(ARGS)->SessionID = ISCSI_NTOHL(*((uint32_t *)((EXT_CDB)-16+24))); \
++(ARGS)->length = ISCSI_NTOHLL(*((uint64_t *)((EXT_CDB)-16+28))); \
++(ARGS)->offset = ISCSI_NTOHLL(*((uint64_t *)((EXT_CDB)-16+36))); \
++(ARGS)->get_attributes_page = ISCSI_NTOHL(*((uint32_t *)((EXT_CDB)-16+44))); \
++(ARGS)->get_attributes_list_length = ISCSI_NTOHL(*((uint32_t *)((EXT_CDB)-16+48))); \
++(ARGS)->get_attributes_allocation_length = ISCSI_NTOHL(*((uint32_t *)((EXT_CDB)-16+52))); \
++(ARGS)->set_attributes_list_length = ISCSI_NTOHL(*((uint32_t *)((EXT_CDB)-16+72)));
+
+ #define OSD_PRINT_CDB(CDB, EXT_CDB) \
+ PRINT("opcode = 0x%x\n", CDB[0]); \
+ PRINT("control = 0x%x\n", CDB[1]); \
+ PRINT("security = 0x%x\n", CDB[6]); \
+ PRINT("add_cdb_len = %u\n", CDB[7]); \
+-PRINT("service_action = 0x%x\n", NTOHS(*(uint16_t*)(CDB+8))); \
++PRINT("service_action = 0x%x\n", ISCSI_NTOHS(*(uint16_t*)(CDB+8))); \
+ PRINT("options byte 1 = 0x%x\n", CDB[10]); \
+ PRINT("options byte 2 = 0x%x\n", CDB[11]); \
+-PRINT("group id = 0x%x\n", NTOHL(*(uint32_t*)(CDB+12))); \
+-PRINT("user id = 0x%llx\n", NTOHLL(*(uint64_t*)(EXT_CDB-16+16))); \
+-PRINT("session id = 0x%x\n", NTOHL(*(uint32_t*)(EXT_CDB-16+24))); \
+-PRINT("length = %llu\n", NTOHLL(*(uint64_t*)(EXT_CDB-16+28))); \
+-PRINT("offset = %llu\n", NTOHLL(*(uint64_t*)(EXT_CDB-16+36))); \
+-PRINT("get attr page = %u\n", NTOHL(*(uint32_t*)(EXT_CDB-16+44))); \
+-PRINT("get list len = %u\n", NTOHL(*(uint32_t*)(EXT_CDB-16+48))); \
+-PRINT("get alloc len = %u\n", NTOHL(*(uint32_t*)(EXT_CDB-16+52))); \
+-PRINT("set list len = %u\n", NTOHL(*(uint32_t*)(EXT_CDB-16+72)));
++PRINT("group id = 0x%x\n", ISCSI_NTOHL(*(uint32_t*)(CDB+12))); \
++PRINT("user id = 0x%llx\n", ISCSI_NTOHLL(*(uint64_t*)(EXT_CDB-16+16))); \
++PRINT("session id = 0x%x\n", ISCSI_NTOHL(*(uint32_t*)(EXT_CDB-16+24))); \
++PRINT("length = %llu\n", ISCSI_NTOHLL(*(uint64_t*)(EXT_CDB-16+28))); \
++PRINT("offset = %llu\n", ISCSI_NTOHLL(*(uint64_t*)(EXT_CDB-16+36))); \
++PRINT("get attr page = %u\n", ISCSI_NTOHL(*(uint32_t*)(EXT_CDB-16+44))); \
++PRINT("get list len = %u\n", ISCSI_NTOHL(*(uint32_t*)(EXT_CDB-16+48))); \
++PRINT("get alloc len = %u\n", ISCSI_NTOHL(*(uint32_t*)(EXT_CDB-16+52))); \
++PRINT("set list len = %u\n", ISCSI_NTOHL(*(uint32_t*)(EXT_CDB-16+72)));
+
+ #endif /* OSD_H */