Lines Matching +full:send +full:- +full:empty
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
48 bhstr = (struct iscsi_bhs_text_request *)request->pdu_bhs; in text_new_request()
49 bhstr->bhstr_opcode = ISCSI_BHS_OPCODE_TEXT_REQUEST | in text_new_request()
51 bhstr->bhstr_flags = BHSTR_FLAGS_FINAL; in text_new_request()
52 bhstr->bhstr_initiator_task_tag = 0; in text_new_request()
53 bhstr->bhstr_target_transfer_tag = ttt; in text_new_request()
55 bhstr->bhstr_cmdsn = conn->conn_cmdsn; in text_new_request()
56 bhstr->bhstr_expstatsn = htonl(conn->conn_statsn + 1); in text_new_request()
70 if ((request->pdu_bhs->bhs_opcode & ~ISCSI_BHS_OPCODE_IMMEDIATE) != in text_receive_request()
73 request->pdu_bhs->bhs_opcode); in text_receive_request()
74 bhstr = (struct iscsi_bhs_text_request *)request->pdu_bhs; in text_receive_request()
79 if ((bhstr->bhstr_flags & (BHSTR_FLAGS_FINAL | BHSTR_FLAGS_CONTINUE)) != in text_receive_request()
82 "flags: %u", bhstr->bhstr_flags); in text_receive_request()
83 if (ISCSI_SNLT(ntohl(bhstr->bhstr_cmdsn), conn->conn_cmdsn)) { in text_receive_request()
85 "was %u, is %u", conn->conn_cmdsn, ntohl(bhstr->bhstr_cmdsn)); in text_receive_request()
87 conn->conn_cmdsn = ntohl(bhstr->bhstr_cmdsn); in text_receive_request()
88 if ((bhstr->bhstr_opcode & ISCSI_BHS_OPCODE_IMMEDIATE) == 0) in text_receive_request()
89 conn->conn_cmdsn++; in text_receive_request()
103 bhstr = (struct iscsi_bhs_text_request *)request->pdu_bhs; in text_new_response()
104 conn = request->pdu_connection; in text_new_response()
107 bhstr2 = (struct iscsi_bhs_text_response *)response->pdu_bhs; in text_new_response()
108 bhstr2->bhstr_opcode = ISCSI_BHS_OPCODE_TEXT_RESPONSE; in text_new_response()
110 bhstr2->bhstr_flags = BHSTR_FLAGS_FINAL; in text_new_response()
112 bhstr2->bhstr_flags = BHSTR_FLAGS_CONTINUE; in text_new_response()
113 bhstr2->bhstr_lun = bhstr->bhstr_lun; in text_new_response()
114 bhstr2->bhstr_initiator_task_tag = bhstr->bhstr_initiator_task_tag; in text_new_response()
115 bhstr2->bhstr_target_transfer_tag = ttt; in text_new_response()
116 bhstr2->bhstr_statsn = htonl(conn->conn_statsn++); in text_new_response()
117 bhstr2->bhstr_expcmdsn = htonl(conn->conn_cmdsn); in text_new_response()
118 bhstr2->bhstr_maxcmdsn = htonl(conn->conn_cmdsn); in text_new_response()
133 if (response->pdu_bhs->bhs_opcode != ISCSI_BHS_OPCODE_TEXT_RESPONSE) in text_receive_response()
135 response->pdu_bhs->bhs_opcode); in text_receive_response()
136 bhstr = (struct iscsi_bhs_text_response *)response->pdu_bhs; in text_receive_response()
137 flags = bhstr->bhstr_flags & (BHSTR_FLAGS_FINAL | BHSTR_FLAGS_CONTINUE); in text_receive_response()
140 if (bhstr->bhstr_target_transfer_tag == 0xffffffff) in text_receive_response()
143 bhstr->bhstr_target_transfer_tag); in text_receive_response()
146 if (bhstr->bhstr_target_transfer_tag != 0xffffffff) in text_receive_response()
149 bhstr->bhstr_target_transfer_tag); in text_receive_response()
153 "flags: %u", bhstr->bhstr_flags); in text_receive_response()
155 if (ntohl(bhstr->bhstr_statsn) != conn->conn_statsn + 1) { in text_receive_response()
157 "is %u, should be %u", ntohl(bhstr->bhstr_statsn), in text_receive_response()
158 conn->conn_statsn + 1); in text_receive_response()
160 conn->conn_statsn = ntohl(bhstr->bhstr_statsn); in text_receive_response()
166 * Send a list of keys from the initiator to the target in a
176 if (request->pdu_data_len == 0) in text_send_request()
177 log_errx(1, "No keys to send in a TextRequest"); in text_send_request()
178 if (request->pdu_data_len > in text_send_request()
179 (size_t)conn->conn_max_send_data_segment_length) in text_send_request()
180 log_errx(1, "Keys to send in TextRequest are too long"); in text_send_request()
206 bhstr = (struct iscsi_bhs_text_response *)response->pdu_bhs; in text_read_response()
208 ttt = bhstr->bhstr_target_transfer_tag; in text_read_response()
209 keys_data = response->pdu_data; in text_read_response()
210 keys_len = response->pdu_data_len; in text_read_response()
211 response->pdu_data = NULL; in text_read_response()
214 keys_len + response->pdu_data_len); in text_read_response()
217 memcpy(keys_data + keys_len, response->pdu_data, in text_read_response()
218 response->pdu_data_len); in text_read_response()
219 keys_len += response->pdu_data_len; in text_read_response()
221 if ((bhstr->bhstr_flags & BHSTR_FLAGS_FINAL) != 0) { in text_read_response()
225 if (bhstr->bhstr_target_transfer_tag != ttt) in text_read_response()
226 log_errx(1, "received non-final TextRequest PDU with " in text_read_response()
228 bhstr->bhstr_target_transfer_tag); in text_read_response()
231 /* Send an empty request. */ in text_read_response()
254 bhstr = (struct iscsi_bhs_text_request *)request->pdu_bhs; in text_read_request()
255 if (bhstr->bhstr_target_transfer_tag != 0xffffffff) in text_read_request()
257 bhstr->bhstr_target_transfer_tag); in text_read_request()
258 if (ntohl(bhstr->bhstr_expstatsn) != conn->conn_statsn) { in text_read_request()
260 "is %u, should be %u", ntohl(bhstr->bhstr_expstatsn), in text_read_request()
261 conn->conn_statsn); in text_read_request()
271 * Send a response back to the initiator as a series of TextResponse
277 struct connection *conn = request->pdu_connection; in text_send_response()
292 todo = keys_len - keys_offset; in text_send_response()
293 if (todo > (size_t)conn->conn_max_send_data_segment_length) { in text_send_response()
295 todo = conn->conn_max_send_data_segment_length; in text_send_response()
302 response->pdu_data = keys_data + keys_offset; in text_send_response()
303 response->pdu_data_len = todo; in text_send_response()
307 response->pdu_data = NULL; in text_send_response()
314 * Wait for an empty request. in text_send_response()
316 * XXX: Linux's Open-iSCSI initiator doesn't update in text_send_response()
320 bhstr = (struct iscsi_bhs_text_request *)request2->pdu_bhs; in text_send_response()
321 if ((bhstr->bhstr_flags & BHSTR_FLAGS_FINAL) == 0) in text_send_response()
325 log_errx(1, "received non-empty continuation " in text_send_response()
327 if (bhstr->bhstr_target_transfer_tag != ttt) in text_send_response()
329 "TTT 0x%x", bhstr->bhstr_target_transfer_tag); in text_send_response()