lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] do a copy of pbuf


From: Piero 74
Subject: [lwip-users] do a copy of pbuf
Date: Wed, 19 Mar 2008 17:48:26 +0100

Hi all.

i have a pbuf from pool, where my driver has copied a packet.

i used this code:

  /* We allocate a pbuf chain of pbufs from the pool. */
  p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
 
  if (p != NULL) {
   
#if ETH_PAD_SIZE
    pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
#endif
   
    // lock eth irq
    disableEthInterrupt();
   
    /* We iterate over the pbuf chain until we have read the entire
    * packet into the pbuf. */
    cpyix  = 0;
   
    for( q = p; q != NULL; q = q->next )
    {
      /* Read enough bytes to fill this pbuf in the chain. The
      * available data in the pbuf is given by the q->len
      * variable. */
     
      if (q->len >= len)
        cpylen = len;
      else
        cpylen = q->len;
     
      last = CopyFromFrameEMAC(q->payload, cpylen);
     
      len   = len - cpylen;
      cpyix = cpyix + cpylen;
    }

i have a caller function which get this pbuf, and i need to duplicate it in another similar pbuf.

Someone can suggest a simple piece of code? i have some problem to understing how manage pbufs.

thanks,
Piero

reply via email to

[Prev in Thread] Current Thread [Next in Thread]