Changeset 9520af7 in mainline for uspace/srv/net/tcp/conn.c


Ignore:
Timestamp:
2017-09-12T15:48:01Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1d40c93d
Parents:
0a1e7e4
Message:

Allow TCP conn tests that involve transferring data by enabling an internal loopback. Add simple →SYN, ←RST test.

File:
1 edited

Legend:

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

    r0a1e7e4 r9520af7  
    4747#include "iqueue.h"
    4848#include "pdu.h"
     49#include "rqueue.h"
    4950#include "segment.h"
    5051#include "seq_no.h"
     
    6566/** Connection association map */
    6667static amap_t *amap;
     68/** Taken after tcp_conn_t lock */
    6769static FIBRIL_MUTEX_INITIALIZE(amap_lock);
     70
     71/** Internal loopback configuration */
     72tcp_lb_t tcp_conn_lb = tcp_lb_none;
    6873
    6974static void tcp_conn_seg_process(tcp_conn_t *, tcp_segment_t *);
     
    7176static void tcp_conn_tw_timer_clear(tcp_conn_t *);
    7277static void tcp_transmit_segment(inet_ep2_t *, tcp_segment_t *);
     78static void tcp_conn_trim_seg_to_wnd(tcp_conn_t *, tcp_segment_t *);
     79static void tcp_reply_rst(inet_ep2_t *, tcp_segment_t *);
    7380
    7481static tcp_tqueue_cb_t tcp_conn_tqueue_cb = {
     
    324331 * Remove connection from the connection map.
    325332 */
    326 void tcp_conn_remove(tcp_conn_t *conn)
     333static void tcp_conn_remove(tcp_conn_t *conn)
    327334{
    328335        if (!conn->mapped)
     
    369376void tcp_conn_sync(tcp_conn_t *conn)
    370377{
     378        assert(fibril_mutex_is_locked(&conn->lock));
     379
    371380        /* XXX select ISS */
    372381        conn->iss = 1;
     
    13581367 * @param seg           Segment
    13591368 */
    1360 void tcp_conn_trim_seg_to_wnd(tcp_conn_t *conn, tcp_segment_t *seg)
     1369static void tcp_conn_trim_seg_to_wnd(tcp_conn_t *conn, tcp_segment_t *seg)
    13611370{
    13621371        uint32_t left, right;
     
    13821391}
    13831392
     1393/** Transmit segment over network.
     1394 *
     1395 * @param epp Endpoint pair with source and destination information
     1396 * @param seg Segment (ownership retained by caller)
     1397 */
    13841398static void tcp_transmit_segment(inet_ep2_t *epp, tcp_segment_t *seg)
    13851399{
     1400        tcp_pdu_t *pdu;
     1401        tcp_segment_t *dseg;
     1402        inet_ep2_t rident;
     1403
    13861404        log_msg(LOG_DEFAULT, LVL_DEBUG,
    13871405            "tcp_transmit_segment(l:(%u),f:(%u), %p)",
     
    13931411        tcp_segment_dump(seg);
    13941412
    1395 //      tcp_rqueue_bounce_seg(sp, seg);
    1396 //      tcp_ncsim_bounce_seg(sp, seg);
    1397 
    1398         tcp_pdu_t *pdu;
     1413        if (tcp_conn_lb == tcp_lb_segment) {
     1414                /* Loop back segment */
     1415//              tcp_ncsim_bounce_seg(sp, seg);
     1416
     1417                /* Reverse the identification */
     1418                tcp_ep2_flipped(epp, &rident);
     1419
     1420                /* Insert segment back into rqueue */
     1421                dseg = tcp_segment_dup(seg);
     1422                tcp_rqueue_insert_seg(&rident, dseg);
     1423                return;
     1424        }
    13991425
    14001426        if (tcp_pdu_encode(epp, seg, &pdu) != EOK) {
     
    14031429        }
    14041430
     1431        if (tcp_conn_lb == tcp_lb_pdu) {
     1432                /* Loop back PDU */
     1433                if (tcp_pdu_decode(pdu, &rident, &dseg) != EOK) {
     1434                        log_msg(LOG_DEFAULT, LVL_WARN, "Not enough memory. Segment dropped.");
     1435                        tcp_pdu_delete(pdu);
     1436                        return;
     1437                }
     1438
     1439                tcp_pdu_delete(pdu);
     1440
     1441                /* Insert decoded segment into rqueue */
     1442                tcp_rqueue_insert_seg(&rident, dseg);
     1443                return;
     1444        }
     1445
    14051446        tcp_transmit_pdu(pdu);
    14061447        tcp_pdu_delete(pdu);
     
    14251466 * @param seg           Incoming segment
    14261467 */
    1427 void tcp_reply_rst(inet_ep2_t *epp, tcp_segment_t *seg)
     1468static void tcp_reply_rst(inet_ep2_t *epp, tcp_segment_t *seg)
    14281469{
    14291470        tcp_segment_t *rseg;
Note: See TracChangeset for help on using the changeset viewer.