Changeset 32105348 in mainline for uspace/srv/net/tl/tcp/conn.c


Ignore:
Timestamp:
2011-10-04T18:12:41Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d9ce049
Parents:
032bbe7
Message:

Send buffer, sketch data transmission.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/tl/tcp/conn.c

    r032bbe7 r32105348  
    4848
    4949#define RCV_BUF_SIZE 4096
     50#define SND_BUF_SIZE 4096
    5051
    5152LIST_INITIALIZE(conn_list);
     
    7778        }
    7879
     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
    7989        /* Set up receive window. */
    8090        conn->rcv_wnd = conn->rcv_buf_size;
     
    171181
    172182        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 */
     190bool 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);
    173210}
    174211
     
    273310
    274311        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;
    275323
    276324        if (seq_no_syn_acked(conn)) {
     
    618666        tcp_segment_text_copy(seg, conn->rcv_buf, xfer_size);
    619667
     668        log_msg(LVL_DEBUG, "Received %zu bytes of data.", xfer_size);
     669
    620670        /* Advance RCV.NXT */
    621671        conn->rcv_nxt += xfer_size;
     
    764814/** Compute flipped socket pair for response.
    765815 *
    766  * Flipped socket pair has local and foreign sockes exchanged.
     816 * Flipped socket pair has local and foreign sockets exchanged.
    767817 *
    768818 * @param sp            Socket pair
Note: See TracChangeset for help on using the changeset viewer.