Changeset 032bbe7 in mainline for uspace/srv/net/tl/tcp/conn.c
- Timestamp:
- 2011-09-22T19:53:07Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 32105348
- Parents:
- 0093ab6
- File:
-
- 1 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 {
Note:
See TracChangeset
for help on using the changeset viewer.