Преглед изворни кода

Handle TargetAddress

tags/v0.9.3
Michael Brown пре 17 година
родитељ
комит
6842dd3222
2 измењених фајлова са 36 додато и 0 уклоњено
  1. 6
    0
      src/include/gpxe/iscsi.h
  2. 30
    0
      src/net/tcp/iscsi.c

+ 6
- 0
src/include/gpxe/iscsi.h Прегледај датотеку

221
 /** Login response opcode */
221
 /** Login response opcode */
222
 #define ISCSI_OPCODE_LOGIN_RESPONSE 0x23
222
 #define ISCSI_OPCODE_LOGIN_RESPONSE 0x23
223
 
223
 
224
+/* Login response status codes */
225
+#define ISCSI_STATUS_SUCCESS		0x00
226
+#define ISCSI_STATUS_REDIRECT		0x01
227
+#define ISCSI_STATUS_INITIATOR_ERROR	0x02
228
+#define ISCSI_STATUS_TARGET_ERROR	0x03
229
+
224
 /**
230
 /**
225
  * iSCSI SCSI command basic header segment
231
  * iSCSI SCSI command basic header segment
226
  *
232
  *

+ 30
- 0
src/net/tcp/iscsi.c Прегледај датотеку

505
 		   len - iscsi->tx_offset );
505
 		   len - iscsi->tx_offset );
506
 }
506
 }
507
 
507
 
508
+/**
509
+ * Handle iSCSI TargetAddress text value
510
+ *
511
+ * @v iscsi		iSCSI session
512
+ * @v value		TargetAddress value
513
+ */
514
+static void iscsi_handle_targetaddress_value ( struct iscsi_session *iscsi,
515
+					       const char *value ) {
516
+	struct in_addr address;
517
+	struct sockaddr_in *sin = ( struct sockaddr_in * ) &iscsi->tcp.peer;
518
+
519
+	if ( inet_aton ( value, &address ) == 0 ) {
520
+		DBG ( "iSCSI %p received invalid TargetAddress \"%s\"\n",
521
+		      iscsi, value );
522
+		return;
523
+	}
524
+
525
+	DBG ( "iSCSI %p will redirect to %s\n", iscsi, value );
526
+	sin->sin_addr = address;
527
+}
528
+
508
 /**
529
 /**
509
  * Handle iSCSI AuthMethod text value
530
  * Handle iSCSI AuthMethod text value
510
  *
531
  *
629
 
650
 
630
 /** iSCSI text strings that we want to handle */
651
 /** iSCSI text strings that we want to handle */
631
 struct iscsi_string_type iscsi_string_types[] = {
652
 struct iscsi_string_type iscsi_string_types[] = {
653
+	{ "TargetAddress=", iscsi_handle_targetaddress_value },
632
 	{ "AuthMethod=", iscsi_handle_authmethod_value },
654
 	{ "AuthMethod=", iscsi_handle_authmethod_value },
633
 	{ "CHAP_A=", iscsi_handle_chap_a_value },
655
 	{ "CHAP_A=", iscsi_handle_chap_a_value },
634
 	{ "CHAP_I=", iscsi_handle_chap_i_value },
656
 	{ "CHAP_I=", iscsi_handle_chap_i_value },
710
 	iscsi_handle_strings ( iscsi, iscsi->rx_buffer, iscsi->rx_len );
732
 	iscsi_handle_strings ( iscsi, iscsi->rx_buffer, iscsi->rx_len );
711
 	iscsi_rx_buffered_data_done ( iscsi );
733
 	iscsi_rx_buffered_data_done ( iscsi );
712
 
734
 
735
+	/* Check for login redirection */
736
+	if ( response->status_class == ISCSI_STATUS_REDIRECT ) {
737
+		DBG ( "iSCSI %p redirecting to new server\n", iscsi );
738
+		iscsi_close ( iscsi, -EINPROGRESS );
739
+		tcp_connect ( &iscsi->tcp );
740
+		return;
741
+	}
742
+
713
 	/* Check for fatal errors */
743
 	/* Check for fatal errors */
714
 	if ( response->status_class != 0 ) {
744
 	if ( response->status_class != 0 ) {
715
 		printf ( "iSCSI login failure: class %02x detail %02x\n",
745
 		printf ( "iSCSI login failure: class %02x detail %02x\n",

Loading…
Откажи
Сачувај