示例#1
0
/*---------------------------------------------------------------------------*/
static void
check_for_tcp_syn(void)
{
  /* This is a hack that is needed to start the periodic TCP timer if
     an incoming packet contains a SYN: since uIP does not inform the
     application if a SYN arrives, we have no other way of starting
     this timer.  This function is called for every incoming IP packet
     to check for such SYNs. */
#define TCP_SYN 0x02
  if(UIP_IP_BUF->proto == UIP_PROTO_TCP &&
     (UIP_TCP_BUF->flags & TCP_SYN) == TCP_SYN) {
    start_periodic_tcp_timer();
  }
}
示例#2
0
/*---------------------------------------------------------------------------*/
void
tcpip_uipcall(void)
{
    static 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->p != PROCESS_NONE) {
                    ts->p = l->p;
                    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) {
#if SHORTCUTS_CONF_NETSTACK
        /* Directly invoke the relevant thread to reduce stack usage by 15 bytes */
        ts->p->thread(&ts->p->pt, tcpip_event, ts->state);
#else
        process_post_synch(ts->p, tcpip_event, ts->state);
#endif
    }
}
示例#3
0
文件: tcpip.c 项目: kamejoko80/emb6
/*---------------------------------------------------------------------------*/
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);

}
示例#4
0
文件: tcpip.c 项目: ajwlucas/lib_xtcp
/*---------------------------------------------------------------------------*/
void
tcpip_uipcall(void)
{
	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;
		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->p != PROCESS_NONE) {
#if NO_XMOS_PROJECT
					ts->p = l->p;
					ts->state = NULL;
#else
          printf("### %s: Here the process should be called.\n", __func__);
#endif
					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);
	}
}
示例#5
0
/*---------------------------------------------------------------------------*/
void
tcpip_uipcall(struct net_buf *buf)
{
  uip_udp_appstate_t *ts;
  
#if UIP_UDP
  if(uip_conn(buf) != NULL) {
    ts = &uip_conn(buf)->appstate;
  } else {
    ts = &uip_udp_conn(buf)->appstate;
  }
#else /* UIP_UDP */
  ts = &uip_conn(buf)->appstate;
#endif /* UIP_UDP */

#if UIP_TCP
 {
   static unsigned char i;
   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->p != PROCESS_NONE) {
	 ts->p = l->p;
	 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, buf);
  }
}
示例#6
0
/*---------------------------------------------------------------------------*/
static void
eventhandler(process_event_t ev, process_data_t data)
{
#if UIP_TCP
    static unsigned char i;
    register struct listenport *l;
#endif /*UIP_TCP*/
    struct process *p;

    switch(ev) {
    case PROCESS_EVENT_EXITED:
        /* This is the event we get if a process has exited. We go through
           the TCP/IP tables to see if this process had any open
           connections or listening TCP ports. If so, we'll close those
           connections. */

        p = (struct process *)data;
#if UIP_TCP
        l = s.listenports;
        for(i = 0; i < UIP_LISTENPORTS; ++i) {
            if(l->p == p) {
                uip_unlisten(l->port);
                l->port = 0;
                l->p = PROCESS_NONE;
            }
            ++l;
        }

        {
            struct uip_conn *cptr;

            for(cptr = &uip_conns[0]; cptr < &uip_conns[UIP_CONNS]; ++cptr) {
                if(cptr->appstate.p == p) {
                    cptr->appstate.p = PROCESS_NONE;
                    cptr->tcpstateflags = UIP_CLOSED;
                }
            }
        }
#endif /* UIP_TCP */
#if UIP_UDP
        {
            struct uip_udp_conn *cptr;

            for(cptr = &uip_udp_conns[0];
                    cptr < &uip_udp_conns[UIP_UDP_CONNS]; ++cptr) {
                if(cptr->appstate.p == p) {
                    cptr->lport = 0;
                }
            }
        }
#endif /* UIP_UDP */
        break;

    case PROCESS_EVENT_TIMER:
        /* We get this event if one of our timers have expired. */
    {
        /* Check the clock so see if we should call the periodic uIP
           processing. */
        if(data == &periodic &&
                etimer_expired(&periodic)) {
#if UIP_TCP
            for(i = 0; i < UIP_CONNS; ++i) {
                if(uip_conn_active(i)) {
                    /* Only restart the timer if there are active
                       connections. */
                    etimer_restart(&periodic);
                    uip_periodic(i);
#if UIP_CONF_IPV6
                    tcpip_ipv6_output();
#else
                    if(uip_len > 0) {
                        PRINTF("tcpip_output from periodic len %d\n", uip_len);
                        tcpip_output();
                        PRINTF("tcpip_output after periodic len %d\n", uip_len);
                    }
#endif /* UIP_CONF_IPV6 */
                }
            }
#endif /* UIP_TCP */
#if UIP_CONF_IP_FORWARD
            uip_fw_periodic();
#endif /* UIP_CONF_IP_FORWARD */
        }

#if UIP_CONF_IPV6
#if UIP_CONF_IPV6_REASSEMBLY
        /*
         * check the timer for reassembly
         */
        if(data == &uip_reass_timer &&
                etimer_expired(&uip_reass_timer)) {
            uip_reass_over();
            tcpip_ipv6_output();
        }
#endif /* UIP_CONF_IPV6_REASSEMBLY */
        /*
         * check the different timers for neighbor discovery and
         * stateless autoconfiguration
         */
        /*if(data == &uip_ds6_timer_periodic &&
           etimer_expired(&uip_ds6_timer_periodic)) {
          uip_ds6_periodic();
          tcpip_ipv6_output();
        }*/
#if !UIP_CONF_ROUTER
        if(data == &uip_ds6_timer_rs &&
                etimer_expired(&uip_ds6_timer_rs)) {
            uip_ds6_send_rs();
            tcpip_ipv6_output();
        }
#endif /* !UIP_CONF_ROUTER */
        if(data == &uip_ds6_timer_periodic &&
                etimer_expired(&uip_ds6_timer_periodic)) {
            uip_ds6_periodic();
            tcpip_ipv6_output();
        }
#endif /* UIP_CONF_IPV6 */
    }
    break;

#if UIP_TCP
    case TCP_POLL:
        if(data != NULL) {
            uip_poll_conn(data);
#if UIP_CONF_IPV6
            tcpip_ipv6_output();
#else /* UIP_CONF_IPV6 */
            if(uip_len > 0) {
                PRINTF("tcpip_output from tcp poll len %d\n", uip_len);
                tcpip_output();
            }
#endif /* UIP_CONF_IPV6 */
            /* Start the periodic polling, if it isn't already active. */
            start_periodic_tcp_timer();
        }
        break;
#endif /* UIP_TCP */
#if UIP_UDP
    case UDP_POLL:
        if(data != NULL) {
            uip_udp_periodic_conn(data);
#if UIP_CONF_IPV6
            tcpip_ipv6_output();
#else
            if(uip_len > 0) {
                tcpip_output();
            }
#endif /* UIP_UDP */
        }
        break;
#endif /* UIP_UDP */

    case PACKET_INPUT:
        packet_input();
        break;
    };
}
示例#7
0
文件: tcpip.c 项目: kamejoko80/emb6
/*---------------------------------------------------------------------------*/
static void
eventhandler(c_event_t ev, p_data_t data)
{
#if UIP_TCP
  static unsigned char i;
//  register struct listenport *l;
#endif /*UIP_TCP*/

  switch(ev) {
    case EVENT_TYPE_TIMER_EXP:
      /* We get this event if one of our timers have expired. */
      {
        /* Check the clock so see if we should call the periodic uIP
           processing. */
        if(data == &periodic &&
           etimer_expired(&periodic)) {
#if UIP_TCP
          for(i = 0; i < UIP_CONNS; ++i) {
            if(uip_conn_active(i)) {
              /* Only restart the timer if there are active
                 connections. */
              etimer_restart(&periodic);
              uip_periodic(i);
#if NETSTACK_CONF_WITH_IPV6
              tcpip_ipv6_output();
#else
              if(uip_len > 0) {
		PRINTF("tcpip_output from periodic len %d\n\r", uip_len);
                tcpip_output();
		PRINTF("tcpip_output after periodic len %d\n\r", uip_len);
              }
#endif /* NETSTACK_CONF_WITH_IPV6 */
            }
          }
#endif /* UIP_TCP */
#if UIP_CONF_IP_FORWARD
          uip_fw_periodic();
#endif /* UIP_CONF_IP_FORWARD */
        }
        
#if NETSTACK_CONF_WITH_IPV6
#if UIP_CONF_IPV6_REASSEMBLY
        /*
         * check the timer for reassembly
         */
        if(data == &uip_reass_timer &&
           etimer_expired(&uip_reass_timer)) {
          uip_reass_over();
          tcpip_ipv6_output();
        }
#endif /* UIP_CONF_IPV6_REASSEMBLY */
        /*
         * check the different timers for neighbor discovery and
         * stateless autoconfiguration
         */
        /*if(data == &uip_ds6_timer_periodic &&
           etimer_expired(&uip_ds6_timer_periodic)) {
          uip_ds6_periodic();
          tcpip_ipv6_output();
        }*/
#if !UIP_CONF_ROUTER
        if(data == &uip_ds6_timer_rs &&
           etimer_expired(&uip_ds6_timer_rs)) {
          uip_ds6_send_rs();
          tcpip_ipv6_output();
        }
#endif /* !UIP_CONF_ROUTER */
        if(data == &uip_ds6_timer_periodic &&
           etimer_expired(&uip_ds6_timer_periodic)) {
          uip_ds6_periodic();
          tcpip_ipv6_output();
        }
#endif /* NETSTACK_CONF_WITH_IPV6 */
      }
      break;
	 
#if UIP_TCP
    case EVENT_TYPE_TCP_POLL:
      if(data != NULL) {
        uip_poll_conn(data);
#if NETSTACK_CONF_WITH_IPV6
        tcpip_ipv6_output();
#else /* NETSTACK_CONF_WITH_IPV6 */
        if(uip_len > 0) {
        	PRINTF("tcpip_output from tcp poll len %d\n\r", uip_len);
        	tcpip_output();
        }
#endif /* NETSTACK_CONF_WITH_IPV6 */
        /* Start the periodic polling, if it isn't already active. */
        start_periodic_tcp_timer();
      }
      break;
#endif /* UIP_TCP */
#if UIP_UDP
    case EVENT_TYPE_UDP_POLL:
      if(data != NULL) {
        uip_udp_periodic_conn(data);
#if NETSTACK_CONF_WITH_IPV6
        tcpip_ipv6_output();
#else
        if(uip_len > 0) {
          tcpip_output();
        }
#endif /* UIP_UDP */
      }
      break;
#endif /* UIP_UDP */

    case EVENT_TYPE_PCK_INPUT:
      packet_input();
      break;
  };
}