sde1000 / NanodeUIP

Port of uIP library to Nanode
http://wiki.hackspace.org.uk/wiki/Project:Nanode/UIP
38 stars 22 forks source link

[PATCH] Packet slicer: DHCP with <400-byte uip buffer #10

Closed maniacbug closed 12 years ago

maniacbug commented 12 years ago

From 5f386f339e69a3ce7e62cd06ae8e412abf3cae67 Mon Sep 17 00:00:00 2001 From: maniacbug maniacbug@ymail.com Date: Sun, 8 Jan 2012 14:24:33 -0800 Subject: [PATCH] Packet slicer.

Allows processing of (and ignores checksums on) packets which are smaller than the packet header believes. This is very useful in highly-constrained memory environments. The most likely case of a sliced packet is the network later truncated it because the packet is larger than the UIP buffer.

A good example of where this helps is DHCP. The official minimum size of a DHCP packet is 590, but we don't want to have a UIP buffer of 590, we'd rather have 400. Fortunately, only the bottom 330 bytes have any data, so we can safely ignore the sliced off part. This allows DHCP without wasting RAM on otherwise unneeded UIP buffer space.

uip.cpp | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/uip.cpp b/uip.cpp index 8e577a9..5618d50 100644 --- a/uip.cpp +++ b/uip.cpp @@ -690,6 +690,8 @@ void uip_process(u8_t flag) { register struct uip_conn *uip_connr = uip_conn;

@@ -1100,7 +1106,10 @@ uip_process(u8_t flag) UIP_STAT(++uip_stat.udp.drop); UIP_STAT(++uip_stat.udp.chkerr); UIP_LOG("udp: bad checksum.");