Пример #1
0
static inline void recvfrom_newudpdata(FAR struct uip_driver_s *dev,
                                       FAR struct recvfrom_s *pstate)
{
  /* Take as much data from the packet as we can */

  (void)recvfrom_newdata(dev, pstate);

  /* Indicate no data in the buffer */

  dev->d_len = 0;
}
Пример #2
0
static inline void recvfrom_newtcpdata(FAR struct uip_driver_s *dev,
                                       FAR struct recvfrom_s *pstate)
{
    /* Take as much data from the packet as we can */

    size_t recvlen = recvfrom_newdata(dev, pstate);

    /* If there is more data left in the packet that we could not buffer, than
     * add it to the read-ahead buffers.
     */

    if (recvlen < dev->d_len)
    {
#if CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
        FAR struct uip_conn *conn   = (FAR struct uip_conn *)pstate->rf_sock->s_conn;
        FAR uint8_t         *buffer = (FAR uint8_t *)dev->d_appdata + recvlen;
        uint16_t             buflen = dev->d_len - recvlen;
#ifdef CONFIG_DEBUG_NET
        uint16_t             nsaved;

        nsaved = uip_datahandler(conn, buffer, buflen);
#else
        (void)uip_datahandler(conn, buffer, buflen);
#endif

        /* There are complicated buffering issues that are not addressed fully
         * here.  For example, what if up_datahandler() cannot buffer the
         * remainder of the packet?  In that case, the data will be dropped but
         * still ACKed.  Therefore it would not be resent.
         *
         * This is probably not an issue here because we only get here if the
         * read-ahead buffers are empty and there would have to be something
         * serioulsy wrong with the configuration not to be able to buffer a
         * partial packet in this context.
         */

#ifdef CONFIG_DEBUG_NET
        if (nsaved < buflen)
        {
            ndbg("ERROR: packet data not saved (%d bytes)\n", buflen - nsaved);
        }
#endif
#else
        ndbg("ERROR: packet data lost (%d bytes)\n", dev->d_len - recvlen);
#endif
    }

    /* Indicate no data in the buffer */

    dev->d_len = 0;
}