示例#1
0
文件: yport_net.c 项目: muccc/matemat
void yport_net_main(void)
{
  if(uip_connected()) {
    if (yport_conn == NULL) {
      yport_conn = uip_conn;
      uip_conn->wnd = YPORT_BUFFER_LEN - 1;
    }
    else 
      /* if we have already an connection, send an error */
      uip_send("ERROR: Connection blocked\n", 27);
  } else if (uip_acked()) {
    /* If the peer is not our connection, close it */
    if (yport_conn != uip_conn) 
      uip_close();
    else {
      /* Some data we have sent was acked, jipphie */
      /* disable interrupts */
      uint8_t sreg = SREG; cli();
      yport_recv_buffer.len -= yport_recv_buffer.sent;
      /* We should use memmove, because the data may overlap */
      memmove(yport_recv_buffer.data, 
              yport_recv_buffer.data + yport_recv_buffer.sent,
              yport_recv_buffer.len);
      /* enable interrupts again */
      SREG = sreg;
    }
  } else if (uip_closed() || uip_aborted() || uip_timedout()) {
    /* if the closed connection was our connection, clean yport_conn */
    if (yport_conn == uip_conn)
      yport_conn = NULL;
  } else if (uip_newdata()) {
    if (uip_len <= YPORT_BUFFER_LEN && yport_rxstart(uip_appdata, uip_len) != 0) {
      /* Prevent the other side from sending more data */
      uip_stop();
    }
  } 
  if (uip_poll() 
      && uip_conn == yport_conn 
      && uip_stopped(yport_conn)
      && yport_send_buffer.sent == yport_send_buffer.len)
    uip_restart();
  /* Send data */
  if ((uip_poll() 
       || uip_acked()
       || uip_rexmit())
      && yport_conn == uip_conn 
      && yport_recv_buffer.len > 0) {
    /* We have recieved data, lets propagade it */
    /* disable interrupts */
    uint8_t sreg = SREG; cli();
    /* Send the data */
    uip_send(yport_recv_buffer.data, yport_recv_buffer.len);
    /* so many data was send */
    yport_recv_buffer.sent = yport_recv_buffer.len;
    /* enable interrupts again */
    SREG = sreg;
  }
}
示例#2
0
/*---------------------------------------------------------------------------*/
void
telnetd_appcall(void *ts)
{
  if(uip_connected()) {
    if(!connected) {
      buf_init(&buf);
      s.bufptr = 0;
      s.state = STATE_NORMAL;
      connected = 1;
      shell_start();
      timer_set(&s.silence_timer, MAX_SILENCE_TIME);
      ts = (char *)0;
    } else {
      uip_send(telnetd_reject_text, strlen(telnetd_reject_text));
      ts = (char *)1;
    }
    tcp_markconn(uip_conn, ts);
  }

  if(!ts) {
    if(s.state == STATE_CLOSE) {
      s.state = STATE_NORMAL;
      uip_close();
      return;
    }
    if(uip_closed() ||
       uip_aborted() ||
       uip_timedout()) {
      shell_stop();
      connected = 0;
    }
    if(uip_acked()) {
      timer_set(&s.silence_timer, MAX_SILENCE_TIME);
      acked();
    }
    if(uip_newdata()) {
      timer_set(&s.silence_timer, MAX_SILENCE_TIME);
      newdata();
    }
    if(uip_rexmit() ||
       uip_newdata() ||
       uip_acked() ||
       uip_connected() ||
       uip_poll()) {
      senddata();
      if(s.numsent > 0) {
	timer_set(&s.silence_timer, MAX_SILENCE_TIME);
      }
    }
    if(uip_poll()) {
      if(timer_expired(&s.silence_timer)) {
        uip_close();
        tcp_markconn(uip_conn, NULL);
      }
    }
  }
}
示例#3
0
void uip_modbus_appcall(void)
{
    if(uip_connected())
    {
        PRINTF("connected!\r\n");
    }

    if(uip_closed())
    {
        PRINTF("closed\r\n");
    }

    if(uip_newdata())
    {
        PRINTF("request!\r\n");
        // 获得modbus请求
        memcpy(ucTCPRequestFrame, uip_appdata, uip_len );
        ucTCPRequestLen = uip_len;
        // 向 modbus poll发送消息
        xMBPortEventPost( EV_FRAME_RECEIVED );
    }

    if(uip_poll())
    {
        if(bFrameSent)
        {
            bFrameSent = FALSE;
            // uIP发送Modbus应答数据包
            uip_send( ucTCPResponseFrame , ucTCPResponseLen );
        }
    }
}
示例#4
0
/*---------------------------------------------------------------------------*/
void
httpd_appcall(void *state)
{
  struct httpd_state *s = (struct httpd_state *)state;

  if(uip_closed() || uip_aborted() || uip_timedout()) {
    if(s != NULL) {
      memb_free(&conns, s);
    }
  } else if(uip_connected()) {
    s = (struct httpd_state *)memb_alloc(&conns);
    if(s == NULL) {
      uip_abort();
      return;
    }
    tcp_markconn(uip_conn, s);
    PSOCK_INIT(&s->sin, s->inputbuf, sizeof(s->inputbuf) - 1);
    PSOCK_INIT(&s->sout, s->inputbuf, sizeof(s->inputbuf) - 1);
    PT_INIT(&s->outputpt);
    s->state = STATE_WAITING;
    timer_set(&s->timer, CLOCK_SECOND * 10);
    handle_connection(s);
  } else if(s != NULL) {
    if(uip_poll()) {
      if(timer_expired(&s->timer)) {
	uip_abort();
      }
    } else {
      timer_reset(&s->timer);
    }
    handle_connection(s);
  } else {
    uip_abort();
  }
}
示例#5
0
文件: telnetd.c 项目: EDAyele/ptunes
/*---------------------------------------------------------------------------*/
void
telnetd_appcall(void *ts)
{
  if(uip_connected()) {
    tcp_markconn(uip_conn, &s);
    buf_init(&buf);
    s.bufptr = 0;
    s.state = STATE_NORMAL;
    shell_start();
  }

  if(s.state == STATE_CLOSE) {
    s.state = STATE_NORMAL;
    uip_close();
    return;
  }
  if(uip_closed() ||
     uip_aborted() ||
     uip_timedout()) {
    closed();
  }
  if(uip_acked()) {
    acked();
  }
  if(uip_newdata()) {
    newdata();
  }
  if(uip_rexmit() ||
     uip_newdata() ||
     uip_acked() ||
     uip_connected() ||
     uip_poll()) {
    senddata();
  }
}
示例#6
0
/*DISPATCHER_UIPCALL(smtp_appcall, state)*/
void
smtp_appcall(void *state)
{
  if(uip_connected()) {
    /*    senddata();*/
    return;
  }
  if(uip_acked()) {
    acked();
  }
  if(uip_newdata()) {
    newdata();
  }
  if(uip_rexmit() ||
     uip_newdata() ||
     uip_acked()) {
    senddata();
  } else if(uip_poll()) {    
    senddata();
  }
  /*  if(uip_closed()) {
    printf("Dnoe\n");
    }*/


}
示例#7
0
static void
tty_vt100_main (void)
{
  if (uip_connected())
    STATE->send_all = 1;

  if (uip_acked())
    {
      if (STATE->send_all)
	STATE->send_all = 0;
      STATE->acked = STATE->sent;
    }

  if (uip_newdata ())
    {
      uint8_t len = uip_len;
      for (uint8_t i = 0; i < len; i ++)
	{
	  int8_t ch = ((char *) uip_appdata)[i];

	  if (ch == 12)		/* C-l, retransmit everything. */
	    {
	      STATE->send_all = 1;
	      continue;
	    }

	  _getch_queue (ch);
	}
    }

  if (uip_rexmit() || uip_newdata() || uip_acked() || uip_connected()
      || uip_poll())
    {
      /* Send new data, if any. */
      if (STATE->send_all)
	tty_vt100_send_all ();

      else
	{
	  /* we're just sending an update, ... */
	  if (vt100_head > STATE->acked)
	    {
	      uint8_t len = vt100_head - STATE->acked;
	      memcpy (uip_sappdata, STATE->acked, len);
	      uip_send (uip_sappdata, len);
	    }
	  else if (vt100_head < STATE->acked)
	    {
	      /* vt100_head wrapped around, let's be careful. */
	      uint8_t len = vt100_end - STATE->acked;
	      memcpy (uip_sappdata, STATE->acked, len);
	      uint8_t len2 = vt100_head - vt100_buf;
	      memcpy (uip_sappdata + len, vt100_buf, len2);
	      uip_send (uip_sappdata, len + len2);
	    }

	  STATE->sent = vt100_head;
	}
    }
}
示例#8
0
static int skel_txavail(struct uip_driver_s *dev)
{
  FAR struct skel_driver_s *skel = (FAR struct skel_driver_s *)dev->d_private;
  irqstate_t flags;

  /* Disable interrupts because this function may be called from interrupt
   * level processing.
   */

  flags = irqsave();

  /* Ignore the notification if the interface is not yet up */

  if (skel->sk_bifup)
    {
      /* Check if there is room in the hardware to hold another outgoing packet. */

      /* If so, then poll uIP for new XMIT data */

      (void)uip_poll(&skel->sk_dev, skel_uiptxpoll);
    }

  irqrestore(flags);
  return OK;
}
示例#9
0
// this function maps the current packet against the mappings
//   pointed to by the param
void uip_port_app_mapper(struct port_appcall_map* cur_map)
{
#ifdef __DHCPC_H__
    // if dhcpc is enabled and running we want our ip ASAP so skip all others
    if(dhcpc_running && uip_poll())
    {
        dhcpc_appcall();
        base_conn = NULL;
        return;    
    }
#endif


    // yes this will walk the entire list which is up to 4 items at the moment
    while ((base_conn != NULL) && (cur_map->an_appcall != NULL))
    {
        // Now match the app to the packet.
        // local AND/OR remote ports match
        // firs check remote port matches and local may or may not
        // then check local port matches
        // can't do it in one statement due to the l & r ports could both be zero and match all apps.
        if (((base_conn->rport == HTONS(cur_map->rport)) &&
            ((cur_map->lport == 0) || (base_conn->lport == HTONS(cur_map->lport)))) ||
            ((base_conn->lport == HTONS(cur_map->lport)) &&
             ((cur_map->rport == 0) || (base_conn->rport == HTONS(cur_map->rport)))))
        {
            cur_map->an_appcall();
            base_conn = NULL;
            break;
        }
        cur_map++;
    }
}
示例#10
0
文件: vnet.c 项目: l--putt/nuttx-bb
static int vnet_txavail(struct uip_driver_s *dev)
{
  FAR struct vnet_driver_s *vnet = (FAR struct vnet_driver_s *)dev->d_private;
  irqstate_t flags;

  /* Disable interrupts because this function may be called from interrupt
   * level processing.
   */

  flags = irqsave();

  /* Ignore the notification if the interface is not yet up */

  if (vnet->sk_bifup)
    {
      /* Check if there is room in the hardware to hold another outgoing packet. */
	if (vnet_is_txbuff_full(vnet->vnet)) {
#ifdef CONFIG_DEBUG
	    cprintf("VNET: TX buffer is full\n");
#endif
	    goto out;
	}

      /* If so, then poll uIP for new XMIT data */

      (void)uip_poll(&vnet->sk_dev, vnet_uiptxpoll);
    }

 out:
  irqrestore(flags);
  return OK;
}
示例#11
0
static int e1000_txavail(struct uip_driver_s *dev)
{
  struct e1000_dev *e1000 = (struct e1000_dev *)dev->d_private;
  int tail = e1000->tx_ring.tail;
  irqstate_t flags;

  /* Disable interrupts because this function may be called from interrupt
   * level processing.
   */

  flags = irqsave();

  /* Ignore the notification if the interface is not yet up */

  if (e1000->bifup)
    {
      /* Check if there is room in the hardware to hold another outgoing packet. */

      if (e1000->tx_ring.desc[tail].desc_status)
        {
          (void)uip_poll(&e1000->uip_dev, e1000_uiptxpoll);
        }
    }

  irqrestore(flags);
  return OK;
}
//这是一个TCP 服务器应用回调函数。
//该函数通过UIP_APPCALL(tcp_demo_appcall)调用,实现Web Server的功能.
//当uip事件发生时,UIP_APPCALL函数会被调用,根据所属端口(1200),确定是否执行该函数。
//例如 : 当一个TCP连接被创建时、有新的数据到达、数据已经被应答、数据需要重发等事件
void tcp_server_demo_appcall(void)
{
 	struct tcp_demo_appstate *s = (struct tcp_demo_appstate *)&uip_conn->appstate;
	if(uip_aborted())tcp_server_aborted();		//连接终止
 	if(uip_timedout())tcp_server_timedout();	//连接超时   
	if(uip_closed())tcp_server_closed();		//连接关闭	   
 	if(uip_connected())tcp_server_connected();	//连接成功	    
	if(uip_acked())tcp_server_acked();			//发送的数据成功送达 
	//接收到一个新的TCP数据包 
	if (uip_newdata())//收到客户端发过来的数据
	{
		if((tcp_server_sta&(1<<6))==0)//还未收到数据
		{
			if(uip_len>199)
			{		   
				((uint8_t*)uip_appdata)[199]=0;
			}		    
	    	strcpy((char*)tcp_server_databuf,uip_appdata);				   	  		  
			tcp_server_sta|=1<<6;//表示收到客户端数据
		}
	}else if(tcp_server_sta&(1<<5))//有数据需要发送
	{
		s->textptr=tcp_server_databuf;
		s->textlen=strlen((const char*)tcp_server_databuf);
		tcp_server_sta&=~(1<<5);//清除标记
	}   
	//当需要重发、新数据到达、数据包送达、连接建立时,通知uip发送数据 
	if(uip_rexmit()||uip_newdata()||uip_acked()||uip_connected()||uip_poll())
	{
		tcp_server_senddata();
	}
}	  
示例#13
0
/*---------------------------------------------------------------------------*/
void
httpd_appcall(void)
{
  struct httpd_state *s = (struct httpd_state *)&(uip_conn->appstate);

  if(uip_closed() || uip_aborted() || uip_timedout()) {
  } else if(uip_connected()) {
    PSOCK_INIT(&s->sin, s->inputbuf, sizeof(s->inputbuf) - 1);
    PSOCK_INIT(&s->sout, s->inputbuf, sizeof(s->inputbuf) - 1);
    PT_INIT(&s->outputpt);
    s->state = STATE_WAITING;
    /*    timer_set(&s->timer, CLOCK_SECOND * 100);*/
    s->timer = 0;
    handle_connection(s);
  } else if(s != NULL) {
    if(uip_poll()) {
      ++s->timer;
      if(s->timer >= 20) {
	uip_abort();
      }
    } else {
      s->timer = 0;
    }
    handle_connection(s);
  } else {
    uip_abort();
  }
}
void uip_task_appcall()
{  
	if(uip_connected()) 
	{
		socket_process_new_connect_();
	}else
	if(uip_poll())
	{
		if(uip_stopped(uip_conn))
		{
			socket_process_try_restart_();
		}
		
		socket_process_write_();
	}else
	if(uip_newdata())
	{
		socket_process_new_data_();
		socket_process_write_();
	}else
	if(uip_aborted() || uip_closed())
	{
		socket_process_close_();
	}else
	if(uip_timedout())
	{
		socket_process_timeout_();
		uip_close();
	}else
	if(uip_acked() || uip_rexmit())
	{
		socket_process_write_();
	}
}
示例#15
0
smcp_status_t
smcp_plat_process(smcp_t self) {
	SMCP_EMBEDDED_SELF_HOOK;

	if (!uip_udpconnection()) {
		goto bail;
	}

	if (uip_udp_conn != smcp_plat_get_udp_conn(smcp)) {
		goto bail;
	}

	if(uip_newdata()) {
		memcpy(&self->plat.sockaddr_remote.smcp_addr,&UIP_IP_BUF->srcipaddr,sizeof(smcp_addr_t));
		self->plat.sockaddr_remote.smcp_port = UIP_UDP_BUF->srcport;

		memcpy(&self->plat.sockaddr_local.smcp_addr,&UIP_IP_BUF->destipaddr,sizeof(smcp_addr_t));
		self->plat.sockaddr_local.smcp_port = UIP_UDP_BUF->destport;

		smcp_plat_set_session_type(SMCP_SESSION_TYPE_UDP);

		smcp_inbound_packet_process(smcp, uip_appdata, uip_datalen(), 0);
	} else if(uip_poll()) {
		smcp_set_current_instance(self);
		smcp_handle_timers(self);
	}

bail:
	smcp_set_current_instance(NULL);
	self->is_responding = false;

	return 0;
}
示例#16
0
static void
irc_main(void)
{
    if (uip_aborted() || uip_timedout()) {
	IRCDEBUG ("connection aborted\n");
	irc_conn = NULL;
    }

    if (uip_closed()) {
	IRCDEBUG ("connection closed\n");
	irc_conn = NULL;
    }

    if (uip_connected()) {
	IRCDEBUG ("new connection\n");
	STATE->stage = IRC_SEND_USERNICK;
	STATE->sent = IRC_SEND_INIT;
#ifdef ECMD_IRC_SUPPORT
	STATE->reparse = 0;
#endif
	*STATE->outbuf = 0;
    }

    if (STATE->stage == IRC_SEND_JOIN
	&& uip_acked ())
	STATE->stage ++;

    else if (STATE->stage == IRC_CONNECTED
	     && uip_acked ()) {
	*STATE->outbuf = 0;

#ifdef ECMD_IRC_SUPPORT
	if (STATE->reparse)
	    irc_handle_ecmd ();
#endif
    }

    else if (uip_newdata() && uip_len) {
	((char *) uip_appdata)[uip_len] = 0;
	IRCDEBUG ("received data: %s\n", uip_appdata);

	if (irc_parse ()) {
	    uip_close ();	/* Parse error */
	    return;
	}
    }

    if (uip_rexmit ())
	irc_send_data (STATE->sent);

    else if ((STATE->stage > STATE->sent || STATE->stage == IRC_CONNECTED)
	     && (uip_newdata()
		 || uip_acked()
		 || uip_connected()))
	irc_send_data (STATE->stage);

    else if (STATE->stage == IRC_CONNECTED && uip_poll() && *STATE->outbuf)
	irc_send_data (STATE->stage);
}
示例#17
0
文件: httpd.c 项目: AnDann/ethersex
void
httpd_main(void)
{
  if (uip_aborted() || uip_timedout())
  {
    printf("httpd: connection aborted\n");
    httpd_cleanup();
    return;
  }

  if (uip_closed())
  {
    printf("httpd: connection closed\n");
    httpd_cleanup();
    return;
  }

  if (uip_connected())
  {
    printf("httpd: new connection\n");

    /* initialize struct */
    STATE->handler = NULL;
    STATE->header_acked = 0;
    STATE->eof = 0;
    STATE->header_reparse = 0;
#ifdef HTTPD_AUTH_SUPPORT
    STATE->auth_state = PAM_UNKOWN;
#endif
  }

  if (uip_newdata() && (!STATE->handler || STATE->header_reparse))
  {
    printf("httpd: new data\n");
    httpd_handle_input();
  }

#ifdef HTTPD_AUTH_SUPPORT
  if (STATE->auth_state == PAM_DENIED && STATE->handler != httpd_handle_401)
  {
    httpd_cleanup();
    STATE->handler = httpd_handle_401;
    STATE->header_reparse = 0;
    printf("httpd: auth failed\n");
  }
  else if (STATE->auth_state == PAM_PENDING)
    return;                     /* Waiting for the PAM Layer */
#endif


  if (uip_rexmit() ||
      uip_newdata() || uip_acked() || uip_poll() || uip_connected())
  {

    /* Call associated handler, if set already. */
    if (STATE->handler && (!STATE->header_reparse))
      STATE->handler();
  }
}
示例#18
0
/*-----------------------------------------------------------------------------------*/
void
webclient_appcall(void)
{
  if(uip_connected()) {
    s.timer = 0;
    s.state = WEBCLIENT_STATE_STATUSLINE;
    senddata();
    webclient_connected();
    return;
  }

  if(s.state == WEBCLIENT_STATE_CLOSE) {
    webclient_closed();
    uip_abort();
    return;
  }

  if(uip_aborted()) {
    webclient_aborted();
  }
  if(uip_timedout()) {
    webclient_timedout();
  }

  
  if(uip_acked()) {
    s.timer = 0;
    acked();
  }
  if(uip_newdata()) {
    s.timer = 0;
    newdata();
  }
  if(uip_rexmit() ||
     uip_newdata() ||
     uip_acked()) {
    senddata();
  } else if(uip_poll()) {
    ++s.timer;
    if(s.timer == WEBCLIENT_TIMEOUT) {
      webclient_timedout();
      uip_abort();
      return;
    }
        /*    senddata();*/
  }

  if(uip_closed()) {
    if(s.httpflag != HTTPFLAG_MOVED) {
      /* Send NULL data to signal EOF. */
      webclient_datahandler(NULL, 0);
    } else {
      if(resolv_lookup(s.host) == NULL) {
	resolv_query(s.host);
      }
      webclient_get(s.host, s.port, s.file);
    }
  }
}
示例#19
0
void
i2c_udp_net_main(void)
{
  if (uip_poll()) 
    i2c_udp_periodic();
  if (uip_newdata())
    i2c_udp_newdata();
}
示例#20
0
文件: jabber.c 项目: AnDann/ethersex
static void
jabber_main(void)
{
  if (uip_aborted() || uip_timedout())
  {
    JABDEBUG("connection aborted\n");
    jabber_conn = NULL;
  }

  if (uip_closed())
  {
    JABDEBUG("connection closed\n");
    jabber_conn = NULL;
  }

  if (uip_connected())
  {
    JABDEBUG("new connection\n");
    STATE->stage = JABBER_OPEN_STREAM;
    STATE->sent = JABBER_INIT;

#ifdef JABBER_STARTUP_MESSAGE_SUPPORT
    strncpy_P(STATE->target, PSTR(CONF_JABBER_BUDDY), sizeof(STATE->target));
    strncpy_P(STATE->outbuf, jabber_startup_text, sizeof(STATE->outbuf));
    STATE->action = JABBER_ACTION_MESSAGE;
#endif /* JABBER_STARTUP_MESSAGE_SUPPORT */
  }

  if (uip_acked() && STATE->stage == JABBER_CONNECTED)
  {
    STATE->action = JABBER_ACTION_NONE;
    *STATE->outbuf = 0;
  }

  if (uip_newdata() && uip_len)
  {
    /* Zero-terminate */
    ((char *) uip_appdata)[uip_len] = 0;
    JABDEBUG("received data: %s\n", uip_appdata);

    if (jabber_parse())
    {
      uip_close();              /* Parse error */
      return;
    }
  }

  if (uip_rexmit())
    jabber_send_data(STATE->stage, STATE->action);

  else if ((STATE->stage > STATE->sent || STATE->stage == JABBER_CONNECTED)
           && (uip_newdata() || uip_acked() || uip_connected()))
    jabber_send_data(STATE->stage, STATE->action);
  else if (STATE->stage == JABBER_CONNECTED && uip_poll() && STATE->action)
    jabber_send_data(STATE->stage, STATE->action);

}
示例#21
0
void
syslog_net_main(void) 
{
  if (! uip_poll ())
    return;

#ifdef ENC28J60_SUPPORT
  if (uip_check_cache (&syslog_conn->ripaddr))
    uip_slen = 1;		/* Trigger xmit to do force ARP lookup. */
#endif
}
示例#22
0
文件: e1000.c 项目: 1015472/PX4NuttX
static irqreturn_t e1000_interrupt_handler(int irq, void *dev_id)
{
    struct e1000_dev *e1000 = (struct e1000_dev *)dev_id;
    
    /* Get and clear interrupt status bits */
    int intr_cause = e1000_inl(e1000, E1000_ICR);
    e1000_outl(e1000, E1000_ICR, intr_cause);

    // not for me
    if (intr_cause == 0) 
		return IRQ_NONE;

    /* Handle interrupts according to status bit settings */

    // Link status change
    if (intr_cause & (1<<2)) {
		if (e1000_inl(e1000, E1000_STATUS) & 2)
			e1000->bifup = true;
		else
			e1000->bifup = false;
    }
    
    /* Check if we received an incoming packet, if so, call skel_receive() */

    // Rx-descriptor Timer expired
    if (intr_cause & (1<<7))
		e1000_receive(e1000);

    // Tx queue empty
    if (intr_cause & (1<<1))
		wd_cancel(e1000->txtimeout);

    /* Check is a packet transmission just completed.  If so, call skel_txdone.
     * This may disable further Tx interrupts if there are no pending
     * tansmissions.
     */

    // Tx-descriptor Written back
    if (intr_cause & (1<<0))
		uip_poll(&e1000->uip_dev, e1000_uiptxpoll);
  

    // Rx-Descriptors Low
    if (intr_cause & (1<<4)) {
		int tail;
		tail = e1000->rx_ring.tail + e1000->rx_ring.free;
		tail %= CONFIG_E1000_N_RX_DESC;
		e1000->rx_ring.tail = tail;
		e1000->rx_ring.free = 0;
		e1000_outl(e1000, E1000_RDT, tail);
    }

    return IRQ_HANDLED;
}
示例#23
0
文件: udpds.c 项目: jaseg/avr-uip
/*---------------------------------------------------------------------------*/
void
udpds_appcall(void)
{
  if(uip_poll()) {
    if(udpds_enable_state && 
		timer_expired(&udpds_interval_timer)) {
      uip_udp_send(udpds_set_payload());
      timer_reset(&udpds_interval_timer);
	}
  }
}
示例#24
0
/*
 *  callback function for UDP stack
 *      uip_poll has to be called before uip_udp_send
 */
void
rc5_udp_recv(void)
{
  if (!uip_poll())
    return;

#ifdef ETHERNET_SUPPORT
  if (udpconn && uip_check_cache(&udpconn->ripaddr))
    uip_slen = 1;               /* Trigger xmit to do force ARP lookup. */
#endif
}
示例#25
0
/*---------------------------------------------------------------------------*/
void
resolv_appcall(void)
{
  if(uip_udp_conn->rport == UIP_HTONS(53)) {
    if(uip_poll()) {
      check_entries();
    }
    if(uip_newdata()) {
      newdata();
    }
  }
}
示例#26
0
static void skel_txtimeout(int argc, uint32_t arg, ...)
{
  FAR struct skel_driver_s *skel = (FAR struct skel_driver_s *)arg;

  /* Increment statistics and dump debug info */

  /* Then reset the hardware */

  /* Then poll uIP for new XMIT data */

  (void)uip_poll(&skel->sk_dev, skel_uiptxpoll);
}
示例#27
0
static void emac_txtimeout(int argc, uint32_t arg, ...)
{
  FAR struct emac_driver_s *priv = (FAR struct emac_driver_s *)arg;

  /* Increment statistics and dump debug info */

  /* Then reset the hardware */

  /* Then poll uIP for new XMIT data */

  (void)uip_poll(&priv->d_dev, emac_uiptxpoll);
}
示例#28
0
文件: e1000.c 项目: 1015472/PX4NuttX
static void e1000_txtimeout(int argc, uint32_t arg, ...)
{
    struct e1000_dev *e1000 = (struct e1000_dev *)arg;

    /* Increment statistics and dump debug info */

    /* Then reset the hardware */
    e1000_init(e1000);

    /* Then poll uIP for new XMIT data */

    (void)uip_poll(&e1000->uip_dev, e1000_uiptxpoll);
}
示例#29
0
/*****************************************************************************
 函 数 名  : udp_8899_app
 功能描述  : a uip udp function for local port is 8899
 输入参数  : void  
 输出参数  : 无
 返 回 值  : 
 调用函数  : 
 被调函数  : 
 
 修改历史      :
  1.日    期   : 2017年4月17日
    作    者   : QSWWD
    修改内容   : 新生成函数

*****************************************************************************/
static void udp_8899_app(void)
{
	if(uip_poll())
	{
		char *tmp_dat = "the auto send!\n\r";
		uip_send(tmp_dat,strlen(tmp_dat));
	}
	if(uip_newdata())
	{
		char *tmp_data = "receive the data!\n\r";
		uip_send(tmp_data,strlen(tmp_data));
	}
}
示例#30
0
/*---------------------------------------------------------------------------*/
void
httpd_appcall(void *state)
{
#if DEBUGLOGIC
  struct httpd_state *s;   //Enter here for debugging with output directed to TCPBUF
  s = sg = (struct httpd_state *)memb_alloc(&conns);
  if (1) {
#else
  struct httpd_state *s = (struct httpd_state *)state;
  if(uip_closed() || uip_aborted() || uip_timedout()) {
    if(s != NULL) {
      memb_free(&conns, s);
    }
  } else if(uip_connected()) {
    s = (struct httpd_state *)memb_alloc(&conns);
    if(s == NULL) {
      uip_abort();
      return;
    }
#endif
    tcp_markconn(uip_conn, s);
    PSOCK_INIT(&s->sin, (uint8_t *)s->inputbuf, sizeof(s->inputbuf) - 1);
    PSOCK_INIT(&s->sout, (uint8_t *)s->inputbuf, sizeof(s->inputbuf) - 1);
    PT_INIT(&s->outputpt);
    s->state = STATE_WAITING;
    /*    timer_set(&s->timer, CLOCK_SECOND * 100);*/
    s->timer = 0;
    handle_connection(s);
  } else if(s != NULL) {
    if(uip_poll()) {
      ++s->timer;
      if(s->timer >= 20) {
        uip_abort();
        memb_free(&conns, s);
      }
    } else {
      s->timer = 0;
    }
    handle_connection(s);
  } else {
    uip_abort();
  }
}
/*---------------------------------------------------------------------------*/
void
httpd_init(void)
{
  tcp_listen(UIP_HTONS(80));
  memb_init(&conns);
  httpd_cgi_init();
}