Example #1
0
/** Segment arrived */
void tcp_as_segment_arrived(inet_ep2_t *epp, tcp_segment_t *seg)
{
	tcp_conn_t *conn;

	log_msg(LOG_DEFAULT, LVL_DEBUG,
	    "tcp_as_segment_arrived(f:(%u), l:(%u))",
	    epp->remote.port, epp->local.port);

	conn = tcp_conn_find_ref(epp);
	if (conn == NULL) {
		log_msg(LOG_DEFAULT, LVL_WARN, "No connection found.");
		tcp_unexpected_segment(epp, seg);
		return;
	}

	tcp_conn_segment_arrived(conn, epp, seg);
	tcp_conn_delref(conn);
}
Example #2
0
/** Segment arrived */
void tcp_as_segment_arrived(tcp_sockpair_t *sp, tcp_segment_t *seg)
{
	tcp_conn_t *conn;

	log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_as_segment_arrived(f:(%x,%u), l:(%x,%u))",
	    sp->foreign.addr.ipv4, sp->foreign.port,
	    sp->local.addr.ipv4, sp->local.port);

	conn = tcp_conn_find_ref(sp);
	if (conn == NULL) {
		log_msg(LOG_DEFAULT, LVL_WARN, "No connection found.");
		tcp_unexpected_segment(sp, seg);
		return;
	}

	fibril_mutex_lock(&conn->lock);

	if (conn->cstate == st_closed) {
		log_msg(LOG_DEFAULT, LVL_WARN, "Connection is closed.");
		tcp_unexpected_segment(sp, seg);
		fibril_mutex_unlock(&conn->lock);
		tcp_conn_delref(conn);
		return;
	}

	if (conn->ident.foreign.addr.ipv4 == TCP_IPV4_ANY)
		conn->ident.foreign.addr.ipv4 = sp->foreign.addr.ipv4;
	if (conn->ident.foreign.port == TCP_PORT_ANY)
		conn->ident.foreign.port = sp->foreign.port;
	if (conn->ident.local.addr.ipv4 == TCP_IPV4_ANY)
		conn->ident.local.addr.ipv4 = sp->local.addr.ipv4;

	tcp_conn_segment_arrived(conn, seg);

	fibril_mutex_unlock(&conn->lock);
	tcp_conn_delref(conn);
}