Bring in ISCSI initiator support.
[dragonfly.git] / sbin / iscontrol / pdu.h
1 /*-
2  * Copyright (c) 2005 Daniel Braniss <danny@cs.huji.ac.il>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28 /*
29  | $Id: pdu.h,v 2.1 2006/11/12 08:06:51 danny Exp $
30  */
31
32 /*
33  | keep in BIG endian order (network byte order).
34  */
35
36 typedef struct login_req {
37      char       cmd;    // 0x03
38
39      u_char     NSG:2;
40      u_char     CSG:2;
41      u_char     _:2;
42      u_char     C:1;
43      u_char     T:1;
44
45      char       v_max;
46      char       v_min;
47
48      int        len;    // remapped via standard bhs
49      char       isid[6];
50      short      tsih;
51      int        itt;    // Initiator Task Tag;
52
53      int        CID:16;
54      int        rsv:16;
55
56      int        cmdSN;
57      int        expStatSN;
58      int        unused[4];
59 } login_req_t;
60
61 typedef struct login_rsp {
62      char       cmd;    // 0x23
63      u_char     NSG:2;
64      u_char     CSG:2;
65      u_char     _1:2;
66      u_char     C:1;
67      u_char     T:1;
68
69      char       v_max;
70      char       v_act;
71
72      int        len;    // remapped via standard bhs
73      char       isid[6];
74      short      tsih;
75      int        itt;    // Initiator Task Tag;
76      int        _2;
77      rsp_sn_t   sn;
78      int        status:16;
79      int        _3:16;
80      int        _4[2];
81 } login_rsp_t;
82
83 typedef struct text_req {
84      char       cmd;    // 0x04
85
86      u_char     _1:6;
87      u_char     C:1;    // Continuation
88      u_char     F:1;    // Final
89      char       _2[2];
90
91      int        len;
92      int        itt;            // Initiator Task Tag
93      int        LUN[2];
94      int        ttt;            // Target Transfer Tag
95      int        cmdSN;
96      int        expStatSN;
97      int        unused[4];
98 } text_req_t;
99
100 /*
101  | Responses
102  */
103 typedef struct logout_req {
104      char       cmd;    // 0x06
105      char       reason; // 0 - close session
106                         // 1 - close connection
107                         // 2 - remove the connection for recovery
108      char       _2[2];
109
110      int        len;
111      int        _r[2];
112      int        itt;    // Initiator Task Tag;
113
114      u_int      CID:16;
115      u_int      rsv:16;
116
117      int        cmdSN;
118      int        expStatSN;
119      int        unused[4];
120 } logout_req_t;
121
122 typedef struct logout_rsp {
123      char       cmd;    // 0x26
124      char       cbits;
125      char       _1[2];
126      int        len;
127      int        _2[2];
128      int        itt;
129      int        _3;
130      rsp_sn_t   sn;
131      short      time2wait;
132      short      time2retain;
133      int        _4;
134 } logout_rsp_t;