Changeset 32aea9f4 in mainline for uspace/srv/net/tl/tcp/seq_no.c


Ignore:
Timestamp:
2011-10-23T02:23:46Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f343a16
Parents:
8c7a054
Message:

Sort incoming segments by sequence order.

File:
1 edited

Legend:

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

    r8c7a054 r32aea9f4  
    178178
    179179/** Calculate the amount of trim needed to fit segment in receive window. */
    180 extern void seq_no_seg_trim_calc(tcp_conn_t *conn, tcp_segment_t *seg,
     180void seq_no_seg_trim_calc(tcp_conn_t *conn, tcp_segment_t *seg,
    181181    uint32_t *left, uint32_t *right)
    182182{
     
    207207}
    208208
     209/** Segment order comparison.
     210 *
     211 * Compare sequence order of two acceptable segments.
     212 *
     213 * @param conn          Connection
     214 * @param sa            Segment A
     215 * @param sb            Segment B
     216 *
     217 * @return              -1, 0, 1, resp. if A < B, A == B, A > B in terms
     218 *                      of sequence order of the beginning of the segment.
     219 */
     220int seq_no_seg_cmp(tcp_conn_t *conn, tcp_segment_t *sa, tcp_segment_t *sb)
     221{
     222        assert(seq_no_segment_acceptable(conn, sa));
     223        assert(seq_no_segment_acceptable(conn, sb));
     224
     225        if (seq_no_lt_le(sa->seq, sb->seq, conn->rcv_nxt + conn->rcv_wnd))
     226                return -1;
     227
     228        if (seq_no_lt_le(sb->seq, sa->seq, conn->rcv_nxt + conn->rcv_wnd))
     229                return +1;
     230
     231        assert(sa->seq == sb->seq);
     232        return 0;
     233}
     234
    209235/**
    210236 * @}
Note: See TracChangeset for help on using the changeset viewer.