Exemplo n.º 1
0
void pkt_poll(FAR struct net_driver_s *dev, FAR struct pkt_conn_s *conn)
{
  ninfo("IN\n");

  /* Verify that the packet connection is valid */

  if (conn)
    {
      /* Setup for the application callback */

      dev->d_appdata = &dev->d_buf[NET_LL_HDRLEN(dev) + IPv4UDP_HDRLEN];
      dev->d_len     = 0;
      dev->d_sndlen  = 0;

      /* Perform the application callback */

      (void)pkt_callback(dev, conn, PKT_POLL);

      /* If the application has data to send, setup the UDP/IP header */

      if (dev->d_sndlen > 0)
        {
          //devif_pkt_send(dev, conn);
          return;
        }
    }

  /* Make sure that d_len is zero meaning that there is nothing to be sent */

  dev->d_len = 0;
}
Exemplo n.º 2
0
int pkt_input(struct net_driver_s *dev)
{
  FAR struct pkt_conn_s *conn;
  FAR struct eth_hdr_s  *pbuf = (struct eth_hdr_s *)dev->d_buf;
  int ret = OK;

  conn = pkt_active(pbuf);
  if (conn)
    {
      uint16_t flags;

      /* Setup for the application callback */

      dev->d_appdata = dev->d_buf;
      dev->d_sndlen  = 0;

      /* Perform the application callback */

      flags = pkt_callback(dev, conn, PKT_NEWDATA);

      /* If the operation was successful, the PKT_NEWDATA flag is removed
       * and thus the packet can be deleted (OK will be returned).
       */

      if ((flags & PKT_NEWDATA) != 0)
        {
          /* No.. the packet was not processed now.  Return ERROR so
           * that the driver may retry again later.
           */

          ret = ERROR;
        }
    }
  else
    {
      nlldbg("No listener\n");
    }

  return ret;
}