> > >> lwIP is a little bit cheeky and reuses the pbuf with the ICMP > > >> request to form the ICMP reply. It is therefore assuming that > > >> there is room at the front for the necessary headers. I suppose if > > >> your ethernet driver was being very efficient and had stripped off > > >> the ethernet header before creating the pbuf, this might not be the > > >> case. Can you show how you're > > > > Yes, that's what I am doing. > > In that case it's technically the fault of lwIP and we should > perhaps change our ICMP to not do this (or at least check the > pbuf to see if it's OK before it does). If you'd rather not > work around it, please file a bug so that it will eventually > get fixed.
Yes, please file a bug report! I'd change etharp.c to allocate a temporary pbuf for the MAC header as do all other protocolsm but we can discuss that on lwip-devel. > > If a ethernet frame with type IP arrives I strip the 14 byte ethernet > > header. But not because I want to save memory (RAM is not the big > > problem in my system) but because I need the IP header aligned at a 4 > > byte boundary. > > The normal way to achieve the IP header aligned on a 4-byte > boundary is to get your MAC to deliver the packet to a 2-byte > offset. Then, if you have a 14-byte ethernet header, the IP > header should be aligned as you require. Not all MACs > support this though I suppose, so your way should also be supported. If your "MAC" supports copying only the IP data, I suppose you copy it using memcpy(). Then you can copy to a 2-byte aligned pointer, too. I think normal way to achieve the 2-byte alignment is shown in ethernetif.c (using ETH_PAD_SIZE). > An easy workaround would be in this case to call pbuf_header > to reserve > 16 bytes before you copy in the packet data. This would > ensure there is space in the pbuf to put the outgoing > ethernet header, but is really a bit of a hack and the right > thing to do is fix it in lwIP's ICMP code. That would make ICMP dependent of the link layer! Simon _______________________________________________ lwip-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/lwip-users
