diff options
author | Michael Brown | 2006-12-05 02:41:32 +0100 |
---|---|---|
committer | Michael Brown | 2006-12-05 02:41:32 +0100 |
commit | 6842dd3222e9ae4baedbfc783d3d527b55efc54b (patch) | |
tree | d31ba49e8186dd0f067bc452476e94216879aa86 /src/net/tcp/iscsi.c | |
parent | Handle strings as complete units, instead of a byte at a time. (diff) | |
download | ipxe-6842dd3222e9ae4baedbfc783d3d527b55efc54b.tar.gz ipxe-6842dd3222e9ae4baedbfc783d3d527b55efc54b.tar.xz ipxe-6842dd3222e9ae4baedbfc783d3d527b55efc54b.zip |
Handle TargetAddress
Diffstat (limited to 'src/net/tcp/iscsi.c')
-rw-r--r-- | src/net/tcp/iscsi.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/net/tcp/iscsi.c b/src/net/tcp/iscsi.c index ae198c4e..31d5a1b9 100644 --- a/src/net/tcp/iscsi.c +++ b/src/net/tcp/iscsi.c @@ -506,6 +506,27 @@ static void iscsi_tx_login_request ( struct iscsi_session *iscsi, } /** + * Handle iSCSI TargetAddress text value + * + * @v iscsi iSCSI session + * @v value TargetAddress value + */ +static void iscsi_handle_targetaddress_value ( struct iscsi_session *iscsi, + const char *value ) { + struct in_addr address; + struct sockaddr_in *sin = ( struct sockaddr_in * ) &iscsi->tcp.peer; + + if ( inet_aton ( value, &address ) == 0 ) { + DBG ( "iSCSI %p received invalid TargetAddress \"%s\"\n", + iscsi, value ); + return; + } + + DBG ( "iSCSI %p will redirect to %s\n", iscsi, value ); + sin->sin_addr = address; +} + +/** * Handle iSCSI AuthMethod text value * * @v iscsi iSCSI session @@ -629,6 +650,7 @@ struct iscsi_string_type { /** iSCSI text strings that we want to handle */ struct iscsi_string_type iscsi_string_types[] = { + { "TargetAddress=", iscsi_handle_targetaddress_value }, { "AuthMethod=", iscsi_handle_authmethod_value }, { "CHAP_A=", iscsi_handle_chap_a_value }, { "CHAP_I=", iscsi_handle_chap_i_value }, @@ -710,6 +732,14 @@ static void iscsi_rx_login_response ( struct iscsi_session *iscsi, void *data, iscsi_handle_strings ( iscsi, iscsi->rx_buffer, iscsi->rx_len ); iscsi_rx_buffered_data_done ( iscsi ); + /* Check for login redirection */ + if ( response->status_class == ISCSI_STATUS_REDIRECT ) { + DBG ( "iSCSI %p redirecting to new server\n", iscsi ); + iscsi_close ( iscsi, -EINPROGRESS ); + tcp_connect ( &iscsi->tcp ); + return; + } + /* Check for fatal errors */ if ( response->status_class != 0 ) { printf ( "iSCSI login failure: class %02x detail %02x\n", |