Changeset 1ddbf81 in mainline
- Timestamp:
- 2017-09-03T09:22:21Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 20c82e3
- Parents:
- e73dbc1
- Location:
- uspace/srv/net/tcp
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/Makefile
re73dbc1 r1ddbf81 56 56 TEST_SOURCES = \ 57 57 $(SOURCES_COMMON) \ 58 test/iqueue.c \ 58 59 test/main.c \ 59 60 test/pdu.c \ -
uspace/srv/net/tcp/iqueue.c
re73dbc1 r1ddbf81 84 84 tcp_iqueue_entry_t, link); 85 85 86 if (seq_no_seg_cmp(iqueue->conn, iqe->seg, qe->seg) >=0)86 if (seq_no_seg_cmp(iqueue->conn, iqe->seg, qe->seg) < 0) 87 87 break; 88 89 link = list_next(link, &iqueue->list); 88 90 } 89 91 … … 92 94 else 93 95 list_append(&iqe->link, &iqueue->list); 96 } 97 98 /** Remove segment from incoming queue. 99 * 100 * @param iqueue Incoming queue 101 * @param seg Segment 102 */ 103 void tcp_iqueue_remove_seg(tcp_iqueue_t *iqueue, tcp_segment_t *seg) 104 { 105 tcp_iqueue_entry_t *qe; 106 link_t *link; 107 108 log_msg(LOG_DEFAULT, LVL_NOTE, "tcp_iqueue_remove_seg()"); 109 110 link = list_first(&iqueue->list); 111 while (link != NULL) { 112 log_msg(LOG_DEFAULT, LVL_NOTE, "tcp_iqueue_remove_seg() - next"); 113 qe = list_get_instance(link, 114 tcp_iqueue_entry_t, link); 115 116 if (qe->seg == seg) { 117 log_msg(LOG_DEFAULT, LVL_NOTE, "tcp_iqueue_remove_seg() - found, DONE"); 118 list_remove(&qe->link); 119 free(qe); 120 return; 121 } 122 123 link = list_next(link, &iqueue->list); 124 } 125 126 log_msg(LOG_DEFAULT, LVL_NOTE, "tcp_iqueue_remove_seg() - not found"); 127 assert(false); 94 128 } 95 129 -
uspace/srv/net/tcp/iqueue.h
re73dbc1 r1ddbf81 40 40 extern void tcp_iqueue_init(tcp_iqueue_t *, tcp_conn_t *); 41 41 extern void tcp_iqueue_insert_seg(tcp_iqueue_t *, tcp_segment_t *); 42 extern void tcp_iqueue_remove_seg(tcp_iqueue_t *, tcp_segment_t *); 42 43 extern int tcp_iqueue_get_ready_seg(tcp_iqueue_t *, tcp_segment_t **); 43 44 -
uspace/srv/net/tcp/test/main.c
re73dbc1 r1ddbf81 57 57 PCUT_INIT 58 58 59 PCUT_IMPORT(iqueue); 59 60 PCUT_IMPORT(pdu); 60 61 PCUT_IMPORT(segment); -
uspace/srv/net/tcp/test/seq_no.c
re73dbc1 r1ddbf81 242 242 } 243 243 244 /** Test seq_no_segment_ready() */ 245 PCUT_TEST(segment_ready) 246 { 247 tcp_conn_t *conn; 248 inet_ep2_t epp; 249 tcp_segment_t *seg; 250 uint8_t *data; 251 size_t dsize; 252 253 inet_ep2_init(&epp); 254 conn = tcp_conn_new(&epp); 255 PCUT_ASSERT_NOT_NULL(conn); 256 257 dsize = 15; 258 data = calloc(dsize, 1); 259 PCUT_ASSERT_NOT_NULL(data); 260 261 seg = tcp_segment_make_data(0, data, dsize); 262 PCUT_ASSERT_NOT_NULL(seg); 263 264 /* Segment must be acceptable. Ready iff intersects RCV.NXT */ 265 266 conn->rcv_nxt = 30; 267 conn->rcv_wnd = 20; 268 269 PCUT_ASSERT_INT_EQUALS(dsize, seg->len); 270 271 seg->seq = 16; 272 PCUT_ASSERT_TRUE(seq_no_segment_ready(conn, seg)); 273 274 seg->seq = 17; 275 PCUT_ASSERT_TRUE(seq_no_segment_ready(conn, seg)); 276 277 seg->seq = 29; 278 PCUT_ASSERT_TRUE(seq_no_segment_ready(conn, seg)); 279 280 seg->seq = 30; 281 PCUT_ASSERT_TRUE(seq_no_segment_ready(conn, seg)); 282 283 seg->seq = 31; 284 PCUT_ASSERT_FALSE(seq_no_segment_ready(conn, seg)); 285 286 tcp_segment_delete(seg); 287 tcp_conn_delete(conn); 288 free(data); 289 } 290 244 291 /** Test seq_no_segment_acceptable() */ 245 292 PCUT_TEST(segment_acceptable)
Note:
See TracChangeset
for help on using the changeset viewer.