|
@@ -37,7 +37,7 @@ struct tcp_connection {
|
37
|
37
|
|
38
|
38
|
/** Remote socket address */
|
39
|
39
|
struct sockaddr_tcpip peer;
|
40
|
|
- /** Local port, in network byte order */
|
|
40
|
+ /** Local port */
|
41
|
41
|
unsigned int local_port;
|
42
|
42
|
|
43
|
43
|
/** Current TCP state */
|
|
@@ -166,7 +166,7 @@ tcp_dump_flags ( struct tcp_connection *tcp, unsigned int flags ) {
|
166
|
166
|
* Bind TCP connection to local port
|
167
|
167
|
*
|
168
|
168
|
* @v tcp TCP connection
|
169
|
|
- * @v port Local port number, in network-endian order
|
|
169
|
+ * @v port Local port number
|
170
|
170
|
* @ret rc Return status code
|
171
|
171
|
*
|
172
|
172
|
* If the port is 0, the connection is assigned an available port
|
|
@@ -182,7 +182,7 @@ static int tcp_bind ( struct tcp_connection *tcp, unsigned int port ) {
|
182
|
182
|
try_port++;
|
183
|
183
|
if ( try_port < 1024 )
|
184
|
184
|
continue;
|
185
|
|
- if ( tcp_bind ( tcp, htons ( try_port ) ) == 0 )
|
|
185
|
+ if ( tcp_bind ( tcp, try_port ) == 0 )
|
186
|
186
|
return 0;
|
187
|
187
|
}
|
188
|
188
|
DBGC ( tcp, "TCP %p could not bind: no free ports\n", tcp );
|
|
@@ -193,13 +193,13 @@ static int tcp_bind ( struct tcp_connection *tcp, unsigned int port ) {
|
193
|
193
|
list_for_each_entry ( existing, &tcp_conns, list ) {
|
194
|
194
|
if ( existing->local_port == port ) {
|
195
|
195
|
DBGC ( tcp, "TCP %p could not bind: port %d in use\n",
|
196
|
|
- tcp, ntohs ( port ) );
|
|
196
|
+ tcp, port );
|
197
|
197
|
return -EADDRINUSE;
|
198
|
198
|
}
|
199
|
199
|
}
|
200
|
200
|
tcp->local_port = port;
|
201
|
201
|
|
202
|
|
- DBGC ( tcp, "TCP %p bound to port %d\n", tcp, ntohs ( port ) );
|
|
202
|
+ DBGC ( tcp, "TCP %p bound to port %d\n", tcp, port );
|
203
|
203
|
return 0;
|
204
|
204
|
}
|
205
|
205
|
|
|
@@ -235,7 +235,7 @@ static int tcp_open ( struct interface *xfer, struct sockaddr *peer,
|
235
|
235
|
memcpy ( &tcp->peer, st_peer, sizeof ( tcp->peer ) );
|
236
|
236
|
|
237
|
237
|
/* Bind to local port */
|
238
|
|
- bind_port = ( st_local ? st_local->st_port : 0 );
|
|
238
|
+ bind_port = ( st_local ? ntohs ( st_local->st_port ) : 0 );
|
239
|
239
|
if ( ( rc = tcp_bind ( tcp, bind_port ) ) != 0 )
|
240
|
240
|
goto err;
|
241
|
241
|
|
|
@@ -480,7 +480,7 @@ static int tcp_xmit ( struct tcp_connection *tcp, int force_send ) {
|
480
|
480
|
flags |= TCP_PSH;
|
481
|
481
|
tcphdr = iob_push ( iobuf, sizeof ( *tcphdr ) );
|
482
|
482
|
memset ( tcphdr, 0, sizeof ( *tcphdr ) );
|
483
|
|
- tcphdr->src = tcp->local_port;
|
|
483
|
+ tcphdr->src = htons ( tcp->local_port );
|
484
|
484
|
tcphdr->dest = tcp->peer.st_port;
|
485
|
485
|
tcphdr->seq = htonl ( tcp->snd_seq );
|
486
|
486
|
tcphdr->ack = htonl ( tcp->rcv_ack );
|
|
@@ -612,7 +612,7 @@ static int tcp_xmit_reset ( struct tcp_connection *tcp,
|
612
|
612
|
/**
|
613
|
613
|
* Identify TCP connection by local port number
|
614
|
614
|
*
|
615
|
|
- * @v local_port Local port (in network-endian order)
|
|
615
|
+ * @v local_port Local port
|
616
|
616
|
* @ret tcp TCP connection, or NULL
|
617
|
617
|
*/
|
618
|
618
|
static struct tcp_connection * tcp_demux ( unsigned int local_port ) {
|
|
@@ -935,7 +935,7 @@ static int tcp_rx ( struct io_buffer *iobuf,
|
935
|
935
|
}
|
936
|
936
|
|
937
|
937
|
/* Parse parameters from header and strip header */
|
938
|
|
- tcp = tcp_demux ( tcphdr->dest );
|
|
938
|
+ tcp = tcp_demux ( ntohs ( tcphdr->dest ) );
|
939
|
939
|
start_seq = seq = ntohl ( tcphdr->seq );
|
940
|
940
|
ack = ntohl ( tcphdr->ack );
|
941
|
941
|
win = ntohs ( tcphdr->win );
|