summaryrefslogtreecommitdiffstats
path: root/src/net/ipv4.c
diff options
context:
space:
mode:
authorMichael Brown2006-05-27 15:43:56 +0200
committerMichael Brown2006-05-27 15:43:56 +0200
commit69b1f24a972563766a4b6a3bb85aec06de0895ba (patch)
treec3e3775c1c4f0b2e16f19cd63dd25255059eb2cd /src/net/ipv4.c
parentMake PKB_ZLEN the minimum possible size of packet buffer (to allow for (diff)
downloadipxe-69b1f24a972563766a4b6a3bb85aec06de0895ba.tar.gz
ipxe-69b1f24a972563766a4b6a3bb85aec06de0895ba.tar.xz
ipxe-69b1f24a972563766a4b6a3bb85aec06de0895ba.zip
I have no idea how this ever worked before.
Diffstat (limited to 'src/net/ipv4.c')
-rw-r--r--src/net/ipv4.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/net/ipv4.c b/src/net/ipv4.c
index b82dfe58..ddc8281d 100644
--- a/src/net/ipv4.c
+++ b/src/net/ipv4.c
@@ -1,5 +1,6 @@
#include <string.h>
#include <stdint.h>
+#include <errno.h>
#include <byteswap.h>
#include <vsprintf.h>
#include <gpxe/in.h>
@@ -24,6 +25,8 @@
*
*/
+struct net_protocol ipv4_protocol;
+
/** An IPv4 routing table entry */
struct ipv4_route {
/** Network address */
@@ -156,16 +159,18 @@ static int ipv4_rx ( struct pk_buff *pkb ) {
*/
uip_len = pkb_len ( pkb );
memcpy ( uip_buf, pkb->data, uip_len );
+ free_pkb ( pkb );
/* Hand to uIP for processing */
uip_input ();
if ( uip_len > 0 ) {
- pkb_empty ( pkb );
- pkb_put ( pkb, uip_len );
- memcpy ( pkb->data, uip_buf, uip_len );
+ pkb = alloc_pkb ( MAX_LL_HEADER_LEN + uip_len );
+ if ( ! pkb )
+ return -ENOMEM;
+ pkb->net_protocol = &ipv4_protocol;
+ pkb_reserve ( pkb, MAX_LL_HEADER_LEN );
+ memcpy ( pkb_put ( pkb, uip_len ), uip_buf, uip_len );
net_transmit ( pkb );
- } else {
- free_pkb ( pkb );
}
return 0;
}