Changeset 32105348 in mainline for uspace/srv/net/tl/tcp/conn.c
- Timestamp:
- 2011-10-04T18:12:41Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d9ce049
- Parents:
- 032bbe7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tl/tcp/conn.c
r032bbe7 r32105348 48 48 49 49 #define RCV_BUF_SIZE 4096 50 #define SND_BUF_SIZE 4096 50 51 51 52 LIST_INITIALIZE(conn_list); … … 77 78 } 78 79 80 /** Allocate send buffer */ 81 conn->snd_buf_size = SND_BUF_SIZE; 82 conn->snd_buf_used = 0; 83 conn->snd_buf = calloc(1, conn->snd_buf_size); 84 if (conn->snd_buf == NULL) { 85 free(conn); 86 return NULL; 87 } 88 79 89 /* Set up receive window. */ 80 90 conn->rcv_wnd = conn->rcv_buf_size; … … 171 181 172 182 return NULL; 183 } 184 185 /** Determine if SYN has been received. 186 * 187 * @param conn Connection 188 * @return @c true if SYN has been received, @c false otherwise. 189 */ 190 bool tcp_conn_got_syn(tcp_conn_t *conn) 191 { 192 switch (conn->cstate) { 193 case st_listen: 194 case st_syn_sent: 195 return false; 196 case st_syn_received: 197 case st_established: 198 case st_fin_wait_1: 199 case st_fin_wait_2: 200 case st_close_wait: 201 case st_closing: 202 case st_last_ack: 203 case st_time_wait: 204 return true; 205 case st_closed: 206 assert(false); 207 } 208 209 assert(false); 173 210 } 174 211 … … 273 310 274 311 log_msg(LVL_DEBUG, "Sent SYN, got SYN."); 312 313 /* 314 * Surprisingly the spec does not deal with initial window setting. 315 * Set SND.WND = SEG.WND and set SND.WL1 so that next segment 316 * will always be accepted as new window setting. 317 */ 318 log_msg(LVL_DEBUG, "SND.WND := %" PRIu32 ", SND.WL1 := %" PRIu32 ", " 319 "SND.WL2 = %" PRIu32, seg->wnd, seg->seq, seg->seq); 320 conn->snd_wnd = seg->wnd; 321 conn->snd_wl1 = seg->seq; 322 conn->snd_wl2 = seg->seq; 275 323 276 324 if (seq_no_syn_acked(conn)) { … … 618 666 tcp_segment_text_copy(seg, conn->rcv_buf, xfer_size); 619 667 668 log_msg(LVL_DEBUG, "Received %zu bytes of data.", xfer_size); 669 620 670 /* Advance RCV.NXT */ 621 671 conn->rcv_nxt += xfer_size; … … 764 814 /** Compute flipped socket pair for response. 765 815 * 766 * Flipped socket pair has local and foreign socke s exchanged.816 * Flipped socket pair has local and foreign sockets exchanged. 767 817 * 768 818 * @param sp Socket pair
Note:
See TracChangeset
for help on using the changeset viewer.