Changeset 32105348 in mainline for uspace/srv/net/tl/tcp/tqueue.c
- Timestamp:
- 2011-10-04T18:12:41Z (14 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/tqueue.c
r032bbe7 r32105348 37 37 #include <byteorder.h> 38 38 #include <io/log.h> 39 #include <macros.h> 40 #include <mem.h> 41 #include "conn.h" 39 42 #include "header.h" 40 43 #include "rqueue.h" … … 50 53 51 54 seg = tcp_segment_make_ctrl(ctrl); 52 seg->seq = conn->snd_nxt;53 seg->ack = conn->rcv_nxt;54 55 tcp_tqueue_seg(conn, seg); 55 56 } … … 60 61 /* XXX queue */ 61 62 63 /* 64 * Always send ACK once we have received SYN, except for RST segments. 65 * (Spec says we should always send ACK once connection has been 66 * established.) 67 */ 68 if (tcp_conn_got_syn(conn) && (seg->ctrl & CTL_RST) == 0) 69 seg->ctrl |= CTL_ACK; 70 71 seg->seq = conn->snd_nxt; 72 seg->wnd = conn->rcv_wnd; 73 74 if ((seg->ctrl & CTL_ACK) != 0) 75 seg->ack = conn->rcv_nxt; 76 else 77 seg->ack = 0; 78 62 79 conn->snd_nxt += seg->len; 80 63 81 tcp_transmit_segment(&conn->ident, seg); 82 } 83 84 /** Transmit data from the send buffer. 85 * 86 * @param conn Connection 87 */ 88 void tcp_tqueue_new_data(tcp_conn_t *conn) 89 { 90 size_t data_size; 91 tcp_segment_t *seg; 92 93 log_msg(LVL_DEBUG, "tcp_tqueue_new_data()"); 94 95 data_size = min(conn->snd_buf_used, conn->snd_wnd); 96 log_msg(LVL_DEBUG, "conn->snd_buf_used = %zu, SND.WND = %zu, " 97 "data_size = %zu", conn->snd_buf_used, conn->snd_wnd, data_size); 98 99 if (data_size == 0) 100 return; 101 102 /* XXX Do not always send immediately */ 103 104 seg = tcp_segment_make_data(0, conn->snd_buf, data_size); 105 if (seg == NULL) { 106 log_msg(LVL_ERROR, "Memory allocation failure."); 107 return; 108 } 109 110 /* Remove data from send buffer */ 111 memmove(conn->snd_buf, conn->snd_buf + data_size, 112 conn->snd_buf_used - data_size); 113 conn->snd_buf_used -= data_size; 114 115 tcp_tqueue_seg(conn, seg); 64 116 } 65 117
Note:
See TracChangeset
for help on using the changeset viewer.