Browse Source

I have no idea how this ever worked before.

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
69b1f24a97
1 changed files with 10 additions and 5 deletions
  1. 10
    5
      src/net/ipv4.c

+ 10
- 5
src/net/ipv4.c View File

@@ -1,5 +1,6 @@
1 1
 #include <string.h>
2 2
 #include <stdint.h>
3
+#include <errno.h>
3 4
 #include <byteswap.h>
4 5
 #include <vsprintf.h>
5 6
 #include <gpxe/in.h>
@@ -24,6 +25,8 @@
24 25
  *
25 26
  */
26 27
 
28
+struct net_protocol ipv4_protocol;
29
+
27 30
 /** An IPv4 routing table entry */
28 31
 struct ipv4_route {
29 32
 	/** Network address */
@@ -156,16 +159,18 @@ static int ipv4_rx ( struct pk_buff *pkb ) {
156 159
 	 */
157 160
 	uip_len = pkb_len ( pkb );
158 161
 	memcpy ( uip_buf, pkb->data, uip_len );
162
+	free_pkb ( pkb );
159 163
 
160 164
 	/* Hand to uIP for processing */
161 165
 	uip_input ();
162 166
 	if ( uip_len > 0 ) {
163
-		pkb_empty ( pkb );
164
-		pkb_put ( pkb, uip_len );
165
-		memcpy ( pkb->data, uip_buf, uip_len );
167
+		pkb = alloc_pkb ( MAX_LL_HEADER_LEN + uip_len );
168
+		if ( ! pkb )
169
+			return -ENOMEM;
170
+		pkb->net_protocol = &ipv4_protocol;
171
+		pkb_reserve ( pkb, MAX_LL_HEADER_LEN );
172
+		memcpy ( pkb_put ( pkb, uip_len ), uip_buf, uip_len );
166 173
 		net_transmit ( pkb );
167
-	} else {
168
-		free_pkb ( pkb );
169 174
 	}
170 175
 	return 0;
171 176
 }

Loading…
Cancel
Save