Exemplo n.º 1
0
void xtcpd_accept_partial_ack(int conn_id)
{
  xtcpd_state_t *s = lookup_xtcpd_state(conn_id);
  if (s != NULL) {
    s->s.accepts_partial_ack = 1;
  }
}
Exemplo n.º 2
0
/* -------------------------------------------------------------------------- */
void xtcpd_pause(int conn_id)
{
  xtcpd_state_t *s = lookup_xtcpd_state(conn_id);
  if (s != NULL) {
    ((struct uip_conn *) s->s.uip_conn)->tcpstateflags |= UIP_STOPPED;
  }
}
Exemplo n.º 3
0
/* -------------------------------------------------------------------------- */
void xtcpd_close(int linknum, int conn_id)
{
  xtcpd_state_t *s = lookup_xtcpd_state(conn_id);
  if (s != NULL) {
    s->s.close_request = 1;
  }
}
Exemplo n.º 4
0
/* -------------------------------------------------------------------------- */
void xtcpd_ack_recv_mode(int conn_id)
{
  xtcpd_state_t *s = lookup_xtcpd_state(conn_id);
  if (s != NULL) {
    s->s.ack_recv_mode = 1;
  }
}
Exemplo n.º 5
0
/* -------------------------------------------------------------------------- */
void xtcpd_set_appstate(int linknum, int conn_id, xtcp_appstate_t appstate)
{
  xtcpd_state_t *s = lookup_xtcpd_state(conn_id);
  if (s != NULL) {
    s->conn.appstate = appstate;
  }
}
Exemplo n.º 6
0
/* -------------------------------------------------------------------------- */
void xtcpd_abort(int linknum, int conn_id)
{
  xtcpd_state_t *s = lookup_xtcpd_state(conn_id);
  if (s != NULL) {
    s->s.abort_request = 1;
  }
}
Exemplo n.º 7
0
void xtcpd_ack_recv(int conn_id)
{
    xtcpd_state_t *s = lookup_xtcpd_state(conn_id);
    if (s != NULL) {
        ((struct uip_conn *) s->s.uip_conn)->tcpstateflags &= ~UIP_STOPPED;
    }
}
Exemplo n.º 8
0
void xtcpd_init_send(int linknum, int conn_id)
{
    xtcpd_state_t *s = lookup_xtcpd_state(conn_id);
    if (s != NULL) {
        s->s.send_request++;
    }
}
Exemplo n.º 9
0
/* -----------------------------------------------------------------------------
 *
 * -------------------------------------------------------------------------- */
void xtcpd_set_poll_interval(int linknum, int conn_id, int poll_interval)
{
  xtcpd_state_t *s = lookup_xtcpd_state(conn_id);
  if (s != NULL && s->conn.protocol == XTCP_PROTOCOL_UDP) {
    s->s.poll_interval = poll_interval;
    timer_set(&(s->s.tmr), poll_interval * CLOCK_SECOND/1000);
  }
}
Exemplo n.º 10
0
/* -------------------------------------------------------------------------- */
void xtcpd_unpause(int conn_id)
{
  xtcpd_state_t *s = lookup_xtcpd_state(conn_id);
  if (s != NULL) {
    ((struct uip_conn *) s->s.uip_conn)->tcpstateflags &= ~UIP_STOPPED;
    s->s.ack_request = 1;
  }
}
Exemplo n.º 11
0
/* -----------------------------------------------------------------------------
 *
 * -------------------------------------------------------------------------- */
void xtcpd_bind_local(int linknum, int conn_id, int port_number)
{
  xtcpd_state_t *s = lookup_xtcpd_state(conn_id);
  s->conn.local_port = port_number;
  if (s->conn.protocol == XTCP_PROTOCOL_UDP)
    ((struct uip_udp_conn *) s->s.uip_conn)->lport = HTONS(port_number);
  else
    ((struct uip_conn *) s->s.uip_conn)->lport = HTONS(port_number);
}
Exemplo n.º 12
0
void xtcpd_bind_remote(int linknum,
                       int conn_id,
                       xtcp_ipaddr_t addr,
                       int port_number)
{
    xtcpd_state_t *s = lookup_xtcpd_state(conn_id);
    if (s->conn.protocol == XTCP_PROTOCOL_UDP) {
        struct uip_udp_conn *conn = (struct uip_udp_conn *) s->s.uip_conn;
        s->conn.remote_port = port_number;
        conn->rport = HTONS(port_number);
        XTCP_IPADDR_CPY(s->conn.remote_addr, addr);
        conn->ripaddr[0] = (addr[1] << 8) | addr[0];
        conn->ripaddr[1] = (addr[3] << 8) | addr[2];
    }
}
Exemplo n.º 13
0
/* -----------------------------------------------------------------------------
 *
 * -------------------------------------------------------------------------- */
static void init_xtcpd_state(xtcpd_state_t *s,
							 xtcp_protocol_t protocol,
							 xtcp_ipaddr_t remote_addr,
							 int local_port,
							 int remote_port,
							 void *conn) {
  int linknum;
  int connect_request = s->s.connect_request;
  int connection_type = s->conn.connection_type;

  if (connect_request) {
    linknum = s->linknum;
  } else {
    connection_type = XTCP_SERVER_CONNECTION;
    if (protocol == XTCP_PROTOCOL_TCP) {
      linknum = get_listener_linknum(tcp_listeners, NUM_TCP_LISTENERS, local_port);
    }
    else {
      linknum = get_listener_linknum(udp_listeners, NUM_UDP_LISTENERS, local_port);
    }
  }

  memset(s, 0, sizeof(xtcpd_state_t));

  // Find and use a GUID that is not being used by another connection
  while (lookup_xtcpd_state(guid) != NULL)
  {
    guid++;
    if (guid > MAX_GUID)
      guid = 1;
  }

  s->conn.connection_type = connection_type;
  s->linknum = linknum;
  s->conn.id = guid;
  s->conn.local_port = HTONS(local_port);
  s->conn.remote_port = HTONS(remote_port);
  s->conn.protocol = protocol;
  s->s.uip_conn = (int) conn;
#ifdef XTCP_ENABLE_PARTIAL_PACKET_ACK
  s->s.accepts_partial_ack = 0;
#endif
  XTCP_IPADDR_CPY(s->conn.remote_addr.u8, remote_addr.u8);
}