Selaa lähdekoodia

Make tcp_connect() void; it will eventually have no failure case.

tags/v0.9.3
Michael Brown 18 vuotta sitten
vanhempi
commit
7af478b30d
4 muutettua tiedostoa jossa 7 lisäystä ja 17 poistoa
  1. 1
    1
      src/include/gpxe/hello.h
  2. 1
    1
      src/include/gpxe/tcp.h
  3. 4
    13
      src/net/tcp.c
  4. 1
    2
      src/proto/iscsi.c

+ 1
- 1
src/include/gpxe/hello.h Näytä tiedosto

41
 	int complete;
41
 	int complete;
42
 };
42
 };
43
 
43
 
44
-extern int hello_connect ( struct hello_request *hello );
44
+extern void hello_connect ( struct hello_request *hello );
45
 
45
 
46
 #endif
46
 #endif

+ 1
- 1
src/include/gpxe/tcp.h Näytä tiedosto

94
 
94
 
95
 extern void *tcp_buffer;
95
 extern void *tcp_buffer;
96
 extern size_t tcp_buflen;
96
 extern size_t tcp_buflen;
97
-extern int tcp_connect ( struct tcp_connection *conn );
97
+extern void tcp_connect ( struct tcp_connection *conn );
98
 extern void tcp_send ( struct tcp_connection *conn, const void *data,
98
 extern void tcp_send ( struct tcp_connection *conn, const void *data,
99
 		       size_t len );
99
 		       size_t len );
100
 extern void tcp_close ( struct tcp_connection *conn );
100
 extern void tcp_close ( struct tcp_connection *conn );

+ 4
- 13
src/net/tcp.c Näytä tiedosto

64
  * Open a TCP connection
64
  * Open a TCP connection
65
  *
65
  *
66
  * @v conn	TCP connection
66
  * @v conn	TCP connection
67
- * @ret 0	Success
68
- * @ret <0	Failure
69
  * 
67
  * 
70
  * This sets up a new TCP connection to the remote host specified in
68
  * This sets up a new TCP connection to the remote host specified in
71
- * tcp_connection::sin.  The actual SYN packet will not be sent out
72
- * until run_tcpip() is called for the first time.
73
- *
74
- * @todo Use linked lists instead of a static buffer, and thereby
75
- *       remove the only potential failure case, giving this function
76
- *       a void return type.
69
+ * tcp_connection::sin.
77
  */
70
  */
78
-int tcp_connect ( struct tcp_connection *conn ) {
71
+void tcp_connect ( struct tcp_connection *conn ) {
79
 	struct uip_conn *uip_conn;
72
 	struct uip_conn *uip_conn;
80
 	u16_t ipaddr[2];
73
 	u16_t ipaddr[2];
81
 
74
 
86
 
79
 
87
 	* ( ( uint32_t * ) ipaddr ) = conn->sin.sin_addr.s_addr;
80
 	* ( ( uint32_t * ) ipaddr ) = conn->sin.sin_addr.s_addr;
88
 	uip_conn = uip_connect ( ipaddr, conn->sin.sin_port );
81
 	uip_conn = uip_connect ( ipaddr, conn->sin.sin_port );
89
-	if ( ! uip_conn )
90
-		return -1;
91
-
82
+#warning "Use linked lists so that uip_connect() cannot fail"
83
+	assert ( uip_conn != NULL );
92
 	*( ( void ** ) uip_conn->appstate ) = conn;
84
 	*( ( void ** ) uip_conn->appstate ) = conn;
93
-	return 0;
94
 }
85
 }
95
 
86
 
96
 /**
87
 /**

+ 1
- 2
src/proto/iscsi.c Näytä tiedosto

544
 	switch ( iscsi->state ) {
544
 	switch ( iscsi->state ) {
545
 	case ISCSI_STATE_NOT_CONNECTED:
545
 	case ISCSI_STATE_NOT_CONNECTED:
546
 	case ISCSI_STATE_FAILED:
546
 	case ISCSI_STATE_FAILED:
547
-		if ( tcp_connect ( &iscsi->tcp ) != 0 )
548
-			iscsi_fail ( iscsi );
547
+		tcp_connect ( &iscsi->tcp );
549
 		iscsi_start_login ( iscsi );
548
 		iscsi_start_login ( iscsi );
550
 		break;
549
 		break;
551
 	case ISCSI_STATE_IDLE:
550
 	case ISCSI_STATE_IDLE:

Loading…
Peruuta
Tallenna