Changeset 032bbe7 in mainline
- Timestamp:
- 2011-09-22T19:53:07Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 32105348
- Parents:
- 0093ab6
- Location:
- uspace/srv/net/tl/tcp
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tl/tcp/conn.c
r0093ab6 r032bbe7 32 32 33 33 /** 34 * @file 34 * @file TCP connection processing and state machine 35 35 */ 36 36 … … 53 53 static void tcp_conn_seg_process(tcp_conn_t *conn, tcp_segment_t *seg); 54 54 55 /** Create new segment structure. 56 * 57 * @param lsock Local socket (will be deeply copied) 58 * @param fsock Foreign socket (will be deeply copied) 59 * @return New segment or NULL 60 */ 55 61 tcp_conn_t *tcp_conn_new(tcp_sock_t *lsock, tcp_sock_t *fsock) 56 62 { … … 85 91 } 86 92 93 /** Enlist connection. 94 * 95 * Add connection to the connection map. 96 */ 87 97 void tcp_conn_add(tcp_conn_t *conn) 88 98 { … … 90 100 } 91 101 102 /** Synchronize connection. 103 * 104 * This is the first step of an active connection attempt, 105 * sends out SYN and sets up ISS and SND.xxx. 106 */ 92 107 void tcp_conn_sync(tcp_conn_t *conn) 93 108 { … … 101 116 } 102 117 118 /** Compare two sockets. 119 * 120 * Two sockets are equal if the address is equal and the port number 121 * is equal. 122 */ 103 123 static bool tcp_socket_equal(tcp_sock_t *a, tcp_sock_t *b) 104 124 { … … 117 137 } 118 138 139 /** Match socket with pattern. */ 119 140 static bool tcp_sockpair_match(tcp_sockpair_t *sp, tcp_sockpair_t *pattern) 120 141 { … … 130 151 } 131 152 153 /** Find connection structure for specified socket pair. 154 * 155 * A connection is uniquely identified by a socket pair. Look up our 156 * connection map and return connection structure based on socket pair. 157 * 158 * @param sp Socket pair 159 * @return Connection structure or NULL if not found. 160 */ 132 161 tcp_conn_t *tcp_conn_find(tcp_sockpair_t *sp) 133 162 { … … 144 173 } 145 174 175 /** Segment arrived in Listen state. 176 * 177 * @param conn Connection 178 * @param seg Segment 179 */ 146 180 static void tcp_conn_sa_listen(tcp_conn_t *conn, tcp_segment_t *seg) 147 181 { … … 196 230 } 197 231 232 /** Segment arrived in Syn-Sent state. 233 * 234 * @param conn Connection 235 * @param seg Segment 236 */ 198 237 static void tcp_conn_sa_syn_sent(tcp_conn_t *conn, tcp_segment_t *seg) 199 238 { … … 248 287 } 249 288 289 /** Segment arrived in state where segments are processed in sequence order. 290 * 291 * Queue segment in incoming segments queue for processing. 292 * 293 * @param conn Connection 294 * @param seg Segment 295 */ 250 296 static void tcp_conn_sa_queue(tcp_conn_t *conn, tcp_segment_t *seg) 251 297 { … … 269 315 } 270 316 317 /** Process segment RST field. 318 * 319 * @param conn Connection 320 * @param seg Segment 321 * @return cp_done if we are done with this segment, cp_continue 322 * if not 323 */ 271 324 static cproc_t tcp_conn_seg_proc_rst(tcp_conn_t *conn, tcp_segment_t *seg) 272 325 { … … 275 328 } 276 329 330 /** Process segment security and precedence fields. 331 * 332 * @param conn Connection 333 * @param seg Segment 334 * @return cp_done if we are done with this segment, cp_continue 335 * if not 336 */ 277 337 static cproc_t tcp_conn_seg_proc_sp(tcp_conn_t *conn, tcp_segment_t *seg) 278 338 { … … 281 341 } 282 342 343 /** Process segment SYN field. 344 * 345 * @param conn Connection 346 * @param seg Segment 347 * @return cp_done if we are done with this segment, cp_continue 348 * if not 349 */ 283 350 static cproc_t tcp_conn_seg_proc_syn(tcp_conn_t *conn, tcp_segment_t *seg) 284 351 { … … 287 354 } 288 355 356 /** Process segment ACK field in Syn-Received state. 357 * 358 * @param conn Connection 359 * @param seg Segment 360 * @return cp_done if we are done with this segment, cp_continue 361 * if not 362 */ 289 363 static cproc_t tcp_conn_seg_proc_ack_sr(tcp_conn_t *conn, tcp_segment_t *seg) 290 364 { … … 307 381 } 308 382 383 /** Process segment ACK field in Established state. 384 * 385 * @param conn Connection 386 * @param seg Segment 387 * @return cp_done if we are done with this segment, cp_continue 388 * if not 389 */ 309 390 static cproc_t tcp_conn_seg_proc_ack_est(tcp_conn_t *conn, tcp_segment_t *seg) 310 391 { … … 344 425 } 345 426 427 /** Process segment ACK field in Fin-Wait-1 state. 428 * 429 * @param conn Connection 430 * @param seg Segment 431 * @return cp_done if we are done with this segment, cp_continue 432 * if not 433 */ 346 434 static cproc_t tcp_conn_seg_proc_ack_fw1(tcp_conn_t *conn, tcp_segment_t *seg) 347 435 { … … 353 441 } 354 442 443 /** Process segment ACK field in Fin-Wait-2 state. 444 * 445 * @param conn Connection 446 * @param seg Segment 447 * @return cp_done if we are done with this segment, cp_continue 448 * if not 449 */ 355 450 static cproc_t tcp_conn_seg_proc_ack_fw2(tcp_conn_t *conn, tcp_segment_t *seg) 356 451 { … … 362 457 } 363 458 459 /** Process segment ACK field in Close-Wait state. 460 * 461 * @param conn Connection 462 * @param seg Segment 463 * @return cp_done if we are done with this segment, cp_continue 464 * if not 465 */ 364 466 static cproc_t tcp_conn_seg_proc_ack_cw(tcp_conn_t *conn, tcp_segment_t *seg) 365 467 { … … 368 470 } 369 471 472 /** Process segment ACK field in Closing state. 473 * 474 * @param conn Connection 475 * @param seg Segment 476 * @return cp_done if we are done with this segment, cp_continue 477 * if not 478 */ 370 479 static cproc_t tcp_conn_seg_proc_ack_cls(tcp_conn_t *conn, tcp_segment_t *seg) 371 480 { … … 377 486 } 378 487 488 /** Process segment ACK field in Last-Ack state. 489 * 490 * @param conn Connection 491 * @param seg Segment 492 * @return cp_done if we are done with this segment, cp_continue 493 * if not 494 */ 379 495 static cproc_t tcp_conn_seg_proc_ack_la(tcp_conn_t *conn, tcp_segment_t *seg) 380 496 { … … 386 502 } 387 503 504 /** Process segment ACK field in Time-Wait state. 505 * 506 * @param conn Connection 507 * @param seg Segment 508 * @return cp_done if we are done with this segment, cp_continue 509 * if not 510 */ 388 511 static cproc_t tcp_conn_seg_proc_ack_tw(tcp_conn_t *conn, tcp_segment_t *seg) 389 512 { … … 392 515 } 393 516 517 /** Process segment ACK field. 518 * 519 * @param conn Connection 520 * @param seg Segment 521 * @return cp_done if we are done with this segment, cp_continue 522 * if not 523 */ 394 524 static cproc_t tcp_conn_seg_proc_ack(tcp_conn_t *conn, tcp_segment_t *seg) 395 525 { … … 428 558 } 429 559 560 /** Process segment URG field. 561 * 562 * @param conn Connection 563 * @param seg Segment 564 * @return cp_done if we are done with this segment, cp_continue 565 * if not 566 */ 430 567 static cproc_t tcp_conn_seg_proc_urg(tcp_conn_t *conn, tcp_segment_t *seg) 431 568 { … … 433 570 } 434 571 435 /** Process segment text. */ 572 /** Process segment text. 573 * 574 * @param conn Connection 575 * @param seg Segment 576 * @return cp_done if we are done with this segment, cp_continue 577 * if not 578 */ 436 579 static cproc_t tcp_conn_seg_proc_text(tcp_conn_t *conn, tcp_segment_t *seg) 437 580 { … … 502 645 } 503 646 647 /** Process segment FIN field. 648 * 649 * @param conn Connection 650 * @param seg Segment 651 * @return cp_done if we are done with this segment, cp_continue 652 * if not 653 */ 504 654 static cproc_t tcp_conn_seg_proc_fin(tcp_conn_t *conn, tcp_segment_t *seg) 505 655 { … … 512 662 * of sequence number. This processes one segment taken from the 513 663 * connection incoming segments queue. 664 * 665 * @param conn Connection 666 * @param seg Segment 514 667 */ 515 668 static void tcp_conn_seg_process(tcp_conn_t *conn, tcp_segment_t *seg) … … 552 705 } 553 706 707 /** Segment arrived on a connection. 708 * 709 * @param conn Connection 710 * @param seg Segment 711 */ 554 712 void tcp_conn_segment_arrived(tcp_conn_t *conn, tcp_segment_t *seg) 555 713 { … … 576 734 } 577 735 736 /** Trim segment to the receive window. 737 * 738 * @param conn Connection 739 * @param seg Segment 740 */ 578 741 void tcp_conn_trim_seg_to_wnd(tcp_conn_t *conn, tcp_segment_t *seg) 579 742 { … … 584 747 } 585 748 749 /** Handle unexpected segment received on a socket pair. 750 * 751 * We reply with an RST unless the received segment has RST. 752 * 753 * @param sp Socket pair which received the segment 754 * @param seg Unexpected segment 755 */ 586 756 void tcp_unexpected_segment(tcp_sockpair_t *sp, tcp_segment_t *seg) 587 757 { … … 592 762 } 593 763 764 /** Compute flipped socket pair for response. 765 * 766 * Flipped socket pair has local and foreign sockes exchanged. 767 * 768 * @param sp Socket pair 769 * @param fsp Place to store flipped socket pair 770 */ 594 771 void tcp_sockpair_flipped(tcp_sockpair_t *sp, tcp_sockpair_t *fsp) 595 772 { … … 598 775 } 599 776 600 /** Send RST in response to an incoming segment. */ 777 /** Send RST in response to an incoming segment. 778 * 779 * @param sp Socket pair which received the segment 780 * @param seg Incoming segment 781 */ 601 782 void tcp_reply_rst(tcp_sockpair_t *sp, tcp_segment_t *seg) 602 783 { -
uspace/srv/net/tl/tcp/conn.h
r0093ab6 r032bbe7 30 30 * @{ 31 31 */ 32 /** @file TCP connection s32 /** @file TCP connection processing and state machine 33 33 */ 34 34 -
uspace/srv/net/tl/tcp/header.c
r0093ab6 r032bbe7 32 32 33 33 /** 34 * @file 34 * @file TCP header encoding and decoding 35 35 */ 36 36 -
uspace/srv/net/tl/tcp/header.h
r0093ab6 r032bbe7 30 30 * @{ 31 31 */ 32 /** @file TCP header definitions 33 * 34 * Based on IETF RFC 793 32 /** @file TCP header encoding and decoding 35 33 */ 36 34 -
uspace/srv/net/tl/tcp/iqueue.c
r0093ab6 r032bbe7 32 32 33 33 /** 34 * @file 34 * @file Connection incoming segments queue 35 * 36 * Segments are sorted in order of their sequence number. 35 37 */ 36 38 … … 44 46 #include "tcp_type.h" 45 47 48 /** Initialize incoming segments queue. 49 * 50 * @param iqueue Incoming queue 51 * @param conn Connection the queue is associated with 52 */ 46 53 void tcp_iqueue_init(tcp_iqueue_t *iqueue, tcp_conn_t *conn) 47 54 { … … 50 57 } 51 58 59 /** Insert segment into incoming queue. 60 * 61 * @param iqueue Incoming queue 62 * @param seg Segment 63 */ 52 64 void tcp_iqueue_insert_seg(tcp_iqueue_t *iqueue, tcp_segment_t *seg) 53 65 { … … 67 79 } 68 80 81 /** Get next ready segment from incoming queue. 82 * 83 * Return the segment with the earliest sequence number if it is ready. 84 * A segment is ready if its SEG.SEQ is earlier or equal to RCV.NXT. 85 * 86 * @param iqueue Incoming queue 87 * @param seg Place to store pointer to segment 88 * @return EOK on success, ENOENT if no segment is ready 89 */ 69 90 int tcp_iqueue_get_ready_seg(tcp_iqueue_t *iqueue, tcp_segment_t **seg) 70 91 { -
uspace/srv/net/tl/tcp/rqueue.c
r0093ab6 r032bbe7 32 32 33 33 /** 34 * @file 34 * @file Global segment receive queue 35 35 */ 36 36 … … 40 40 #include <stdlib.h> 41 41 #include <thread.h> 42 #include "conn.h" 42 43 #include "rqueue.h" 43 44 #include "state.h" … … 46 47 static prodcons_t rqueue; 47 48 49 /** Initialize segment receive queue. */ 48 50 void tcp_rqueue_init(void) 49 51 { … … 54 56 * 55 57 * This is for testing purposes only. 58 * 59 * @param sp Socket pair, oriented for transmission 60 * @param seg Segment 56 61 */ 57 62 void tcp_rqueue_bounce_seg(tcp_sockpair_t *sp, tcp_segment_t *seg) … … 62 67 63 68 /* Reverse the identification */ 64 rident.local = sp->foreign; 65 rident.foreign = sp->local; 69 tcp_sockpair_flipped(sp, &rident); 66 70 67 71 tcp_rqueue_insert_seg(&rident, seg); 68 72 } 69 73 74 /** Insert segment into receive queue. 75 * 76 * @param sp Socket pair, oriented for reception 77 * @param seg Segment 78 */ 70 79 void tcp_rqueue_insert_seg(tcp_sockpair_t *sp, tcp_segment_t *seg) 71 80 { … … 85 94 } 86 95 96 /** Receive queue handler thread. */ 87 97 static void tcp_rqueue_thread(void *arg) 88 98 { … … 100 110 } 101 111 112 /** Start receive queue handler thread. */ 102 113 void tcp_rqueue_thread_start(void) 103 114 { -
uspace/srv/net/tl/tcp/rqueue.h
r0093ab6 r032bbe7 30 30 * @{ 31 31 */ 32 /** @file Global segment rece ptionqueue32 /** @file Global segment receive queue 33 33 */ 34 34 -
uspace/srv/net/tl/tcp/segment.c
r0093ab6 r032bbe7 32 32 33 33 /** 34 * @file 34 * @file Segment processing 35 35 */ 36 36 … … 41 41 #include "tcp_type.h" 42 42 43 /** Alocate new segment structure. */ 43 44 tcp_segment_t *tcp_segment_new(void) 44 45 { … … 46 47 } 47 48 49 /** Delete segment. */ 48 50 void tcp_segment_delete(tcp_segment_t *seg) 49 51 { … … 51 53 } 52 54 53 /** Create a control segment. */ 55 /** Create a control segment. 56 * 57 * @return Control segment 58 */ 54 59 tcp_segment_t *tcp_segment_make_ctrl(tcp_control_t ctrl) 55 60 { … … 66 71 } 67 72 73 /** Create an RST segment. 74 * 75 * @param seg Segment we are replying to 76 * @return RST segment 77 */ 68 78 tcp_segment_t *tcp_segment_make_rst(tcp_segment_t *seg) 69 79 { … … 80 90 } 81 91 82 /** Trim segment to the specified interval.92 /** Trim segment from left and right by the specified amount. 83 93 * 84 * Trim any text or control whose sequence number is outside of [lo, hi) 85 * interval. 94 * Trim any text or control to remove the specified amount of sequence 95 * numbers from the left (lower sequence numbers) and right side 96 * (higher sequence numbers) of the segment. 97 * 98 * @param seg Segment, will be modified in place 99 * @param left Amount of sequence numbers to trim from the left 100 * @param right Amount of sequence numbers to trim from the right 86 101 */ 87 102 void tcp_segment_trim(tcp_segment_t *seg, uint32_t left, uint32_t right) … … 134 149 /** Copy out text data from segment. 135 150 * 151 * Data is copied from the beginning of the segment text up to @a size bytes. 152 * @a size must not be greater than the size of the segment text, but 153 * it can be less. 154 * 155 * @param seg Segment 156 * @param buf Destination buffer 157 * @param size Size of destination buffer 136 158 */ 137 159 void tcp_segment_text_copy(tcp_segment_t *seg, void *buf, size_t size) … … 141 163 } 142 164 143 /** Return number of bytes in segment text. */ 165 /** Return number of bytes in segment text. 166 * 167 * @param seg Segment 168 * @return Number of bytes in segment text 169 */ 144 170 size_t tcp_segment_text_size(tcp_segment_t *seg) 145 171 { -
uspace/srv/net/tl/tcp/segment.h
r0093ab6 r032bbe7 30 30 * @{ 31 31 */ 32 /** @file 32 /** @file Segment processing 33 33 */ 34 34 -
uspace/srv/net/tl/tcp/seq_no.c
r0093ab6 r032bbe7 32 32 33 33 /** 34 * @file 34 * @file Sequence number computations 35 35 */ 36 36 -
uspace/srv/net/tl/tcp/seq_no.h
r0093ab6 r032bbe7 30 30 * @{ 31 31 */ 32 /** @file TCP sequence numbers32 /** @file Sequence number computations 33 33 */ 34 34 -
uspace/srv/net/tl/tcp/state.c
r0093ab6 r032bbe7 32 32 33 33 /** 34 * @file 34 * @file TCP entry points (close to those defined in the RFC) 35 35 */ 36 36 -
uspace/srv/net/tl/tcp/state.h
r0093ab6 r032bbe7 30 30 * @{ 31 31 */ 32 /** @file TCP state machine32 /** @file TCP entry points (close to those defined in the RFC) 33 33 */ 34 34 -
uspace/srv/net/tl/tcp/tcp_type.h
r0093ab6 r032bbe7 30 30 * @{ 31 31 */ 32 /** @file 32 /** @file TCP type definitions 33 33 */ 34 34 -
uspace/srv/net/tl/tcp/test.c
r0093ab6 r032bbe7 32 32 33 33 /** 34 * @file 34 * @file Internal TCP test 35 35 */ 36 36 -
uspace/srv/net/tl/tcp/test.h
r0093ab6 r032bbe7 30 30 * @{ 31 31 */ 32 /** @file 32 /** @file Internal TCP test 33 33 */ 34 34 -
uspace/srv/net/tl/tcp/tqueue.c
r0093ab6 r032bbe7 32 32 33 33 /** 34 * @file 34 * @file TCP transmission queue 35 35 */ 36 36
Note:
See TracChangeset
for help on using the changeset viewer.