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
 #include <string.h>
1
 #include <string.h>
2
 #include <stdint.h>
2
 #include <stdint.h>
3
+#include <errno.h>
3
 #include <byteswap.h>
4
 #include <byteswap.h>
4
 #include <vsprintf.h>
5
 #include <vsprintf.h>
5
 #include <gpxe/in.h>
6
 #include <gpxe/in.h>
24
  *
25
  *
25
  */
26
  */
26
 
27
 
28
+struct net_protocol ipv4_protocol;
29
+
27
 /** An IPv4 routing table entry */
30
 /** An IPv4 routing table entry */
28
 struct ipv4_route {
31
 struct ipv4_route {
29
 	/** Network address */
32
 	/** Network address */
156
 	 */
159
 	 */
157
 	uip_len = pkb_len ( pkb );
160
 	uip_len = pkb_len ( pkb );
158
 	memcpy ( uip_buf, pkb->data, uip_len );
161
 	memcpy ( uip_buf, pkb->data, uip_len );
162
+	free_pkb ( pkb );
159
 
163
 
160
 	/* Hand to uIP for processing */
164
 	/* Hand to uIP for processing */
161
 	uip_input ();
165
 	uip_input ();
162
 	if ( uip_len > 0 ) {
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
 		net_transmit ( pkb );
173
 		net_transmit ( pkb );
167
-	} else {
168
-		free_pkb ( pkb );
169
 	}
174
 	}
170
 	return 0;
175
 	return 0;
171
 }
176
 }

Loading…
Cancel
Save