/* All callback functions below are called from the LwIP-thread. For ESP, this is the FreeRTOS LwIP-thread. Copy data to the reading threads' buffer and resume the thread.  */
static void udp_recv_from_copy_resume(struct socket_t *socket_p, struct pbuf *pbuf_p)
/* All callback functions below are called from the LwIP-thread. For ESP, this is the FreeRTOS LwIP-thread. Copy data to the reading threads' buffer and resume the thread.  */
static void udp_recv_from_copy_resume(struct socket_t *socket_p, struct pbuf *pbuf_p)
{
    struct recv_from_args_t *args_p;
    ssize_t size;
    args_p = socket_p->input.cb.args_p;
    size = args_p->size;
    if (size > pbuf_p->tot_len) {
        size = pbuf_p->tot_len;
    }
    fs_counter_increment(&module.udp_rx_bytes, size);
    pbuf_copy_partial(pbuf_p, args_p->buf_p, size, 0);
    pbuf_free(pbuf_p);
    if (args_p->remote_addr_p != NULL) {
        *args_p->remote_addr_p = socket_p->input.u.recvfrom.remote_addr;
    }
    resume_thrd(socket_p->input.cb.thrd_p, size);
}