Beispiel #1
0
void
tcpip_poll_tcp(struct uip_conn *conn)
{
	evproc_putEvent(E_EVPROC_HEAD,EVENT_TYPE_TCP_POLL,conn);
//	evproc_pushEvent(EVENT_TYPE_TCP_POLL,conn);
  //process_post(&tcpip_process, TCP_POLL, conn);
}
Beispiel #2
0
/*---------------------------------------------------------------------------*/
void
tcpip_input(void)
{
	evproc_putEvent(E_EVPROC_EXEC,EVENT_TYPE_PCK_INPUT,NULL);
//	evproc_pushEvent(EVENT_TYPE_PCK_INPUT, NULL);
  //process_post_synch(&tcpip_process, PACKET_INPUT, NULL);
  uip_len = 0;
#if NETSTACK_CONF_WITH_IPV6
  uip_ext_len = 0;
#endif /*NETSTACK_CONF_WITH_IPV6*/
}
Beispiel #3
0
void
tcpip_icmp6_call(uint8_t type)
{
  if(uip_icmp6_conns.appstate.conn_id != 0) {
    /* XXX: This is a hack that needs to be updated. Passing a pointer (&type)
       like this only works with process_post_synch. */
	  evproc_putEvent(E_EVPROC_EXEC,EVENT_TYPE_ICMP6,&type);
	  //evproc_pushEvent(EVENT_TYPE_ICMP6,&type);
    //process_post_synch(uip_icmp6_conns.appstate.p, tcpip_icmp6_event, &type);
  }
  return;
}
Beispiel #4
0
/*---------------------------------------------------------------------------*/
void
tcpip_uipcall(void)
{
  register uip_udp_appstate_t *ts;
#if UIP_UDP
  if(uip_conn != NULL) {
    ts = &uip_conn->appstate;
  } else {
    ts = &uip_udp_conn->appstate;
  }
#else /* UIP_UDP */
  ts = &uip_conn->appstate;
#endif /* UIP_UDP */

#if UIP_TCP
 {
   static unsigned char i;
   register struct listenport *l;
   
   /* If this is a connection request for a listening port, we must
      mark the connection with the right process ID. */
   if(uip_connected()) {
     l = &s.listenports[0];
     for(i = 0; i < UIP_LISTENPORTS; ++i) {
       if(l->port == uip_conn->lport &&
    		   l->conn_id != 0) {
    	   ts->conn_id = l->conn_id;
    	   ts->state = NULL;
    	   break;
       }
       ++l;
     }
     
     /* Start the periodic polling, if it isn't already active. */
     start_periodic_tcp_timer();
   }
 }
#endif /* UIP_TCP */
//  if(ts->p != NULL) {
//	process_post_synch(ts->p, tcpip_event, ts->state);
// 	}
 	 if (ts->conn_id != 0)
 		 evproc_putEvent(E_EVPROC_EXEC,EVENT_TYPE_TCPIP,ts->state);

// 	 evproc_pushEvent(EVENT_TYPE_TCPIP,ts->state);

}
Beispiel #5
0
int conn_udp_sendto(const void *data, size_t len, const void *src, size_t src_len,
                    const void *dst, size_t dst_len, int family, uint16_t sport,
                    uint16_t dport)
{
    int res;
    _send_cmd_t send_cmd;

    if (!send_registered) {
        if (evproc_regCallback(EVENT_TYPE_CONN_SEND, _output_callback) != E_SUCCESS) {
            return -EIO;
        }
        else {
            send_registered = true;
        }
    }
    mutex_init(&send_cmd.mutex);
    if ((len > (UIP_BUFSIZE - (UIP_LLH_LEN + UIP_IPUDPH_LEN))) ||
        (len > UINT16_MAX)) {
        return -EMSGSIZE;
    }
    if ((dst_len > sizeof(ipv6_addr_t)) || (family != AF_INET6)) {
        return -EAFNOSUPPORT;
    }
    mutex_lock(&send_cmd.mutex);
    send_cmd.data = data;
    send_cmd.data_len = (uint16_t)len;
    if ((res = _reg_and_bind(&send_cmd.sock, NULL, NULL, sport)) < 0) {
        mutex_unlock(&send_cmd.mutex);
        return res;
    }
    udp_socket_connect(&send_cmd.sock, (uip_ipaddr_t *)dst, dport); /* can't fail at this point */
    /* change to emb6 thread context */
    if (evproc_putEvent(E_EVPROC_TAIL, EVENT_TYPE_CONN_SEND, &send_cmd) != E_SUCCESS) {
        udp_socket_close(&send_cmd.sock);
        mutex_unlock(&send_cmd.mutex);
        return -EIO;
    }
    /* block thread until data was send */
    mutex_lock(&send_cmd.mutex);
    udp_socket_close(&send_cmd.sock);
    mutex_unlock(&send_cmd.mutex);

    return send_cmd.res;
}
Beispiel #6
0
int sock_udp_send(sock_udp_t *sock, const void *data, size_t len,
                  const sock_udp_ep_t *remote)
{
    struct udp_socket tmp;
    _send_cmd_t send_cmd = { .block = MUTEX_INIT,
                             .remote = remote,
                             .data = data,
                             .len = len };

    assert((sock != NULL) || (remote != NULL));
    assert((len == 0) || (data != NULL));   /* (len != 0) => (data != NULL) */
    /* we want the send in the uip thread (which udp_socket_send does not offer)
     * so we need to do it manually */
    if (!send_registered) {
        if (evproc_regCallback(EVENT_TYPE_SOCK_SEND, _output_callback) != E_SUCCESS) {
            return -ENOMEM;
        }
        else {
            send_registered = true;
        }
    }
    if ((len > (UIP_BUFSIZE - (UIP_LLH_LEN + UIP_IPUDPH_LEN))) ||
        (len > UINT16_MAX)) {
        return -ENOMEM;
    }
    if (remote != NULL) {
        if (remote->family != AF_INET6) {
            return -EAFNOSUPPORT;
        }
        if (remote->port == 0) {
            return -EINVAL;
        }
        send_cmd.remote = remote;
    }
    else if (sock->sock.udp_conn->rport == 0) {
        return -ENOTCONN;
    }
    /* cppcheck-supress nullPointerRedundantCheck
     * remote == NULL implies that sock != NULL (see assert at start of
     * function) * that's why it is okay in the if-statement above to check
     * sock->... without checking (sock != NULL) first => this check afterwards
     * isn't redundant */
    if (sock == NULL) {
        int res;
        if ((res = _reg(&tmp, NULL, NULL, NULL, NULL)) < 0) {
            return res;
        }
        send_cmd.sock = &tmp;
    }
    else {
        send_cmd.sock = &sock->sock;
    }
    mutex_lock(&send_cmd.block);
    /* change to emb6 thread context */
    if (evproc_putEvent(E_EVPROC_TAIL, EVENT_TYPE_SOCK_SEND, &send_cmd) == E_SUCCESS) {
        /* block thread until data was sent */
        mutex_lock(&send_cmd.block);
    }
    else {
        /* most likely error: event queue was full */
        send_cmd.res = -ENOMEM;
    }
    if (send_cmd.sock == &tmp) {
        udp_socket_close(&tmp);
    }
    mutex_unlock(&send_cmd.block);

    return send_cmd.res;
}