|
@@ -17,11 +17,6 @@
|
17
|
17
|
*
|
18
|
18
|
* IPv4 protocol
|
19
|
19
|
*
|
20
|
|
- * The gPXE IP stack is currently implemented on top of the uIP
|
21
|
|
- * protocol stack. This file provides wrappers around uIP so that
|
22
|
|
- * higher-level protocol implementations do not need to talk directly
|
23
|
|
- * to uIP (which has a somewhat baroque API).
|
24
|
|
- *
|
25
|
20
|
*/
|
26
|
21
|
|
27
|
22
|
/* Unique IP datagram identification number */
|
|
@@ -29,26 +24,8 @@ static uint16_t next_ident = 0;
|
29
|
24
|
|
30
|
25
|
struct net_protocol ipv4_protocol;
|
31
|
26
|
|
32
|
|
-/** An IPv4 address/routing table entry */
|
33
|
|
-struct ipv4_miniroute {
|
34
|
|
- /** List of miniroutes */
|
35
|
|
- struct list_head list;
|
36
|
|
-
|
37
|
|
- /** Network device */
|
38
|
|
- struct net_device *netdev;
|
39
|
|
- /** Reference to network device */
|
40
|
|
- struct reference netdev_ref;
|
41
|
|
-
|
42
|
|
- /** IPv4 address */
|
43
|
|
- struct in_addr address;
|
44
|
|
- /** Subnet mask */
|
45
|
|
- struct in_addr netmask;
|
46
|
|
- /** Gateway address */
|
47
|
|
- struct in_addr gateway;
|
48
|
|
-};
|
49
|
|
-
|
50
|
27
|
/** List of IPv4 miniroutes */
|
51
|
|
-static LIST_HEAD ( miniroutes );
|
|
28
|
+struct list_head ipv4_miniroutes = LIST_HEAD_INIT ( ipv4_miniroutes );
|
52
|
29
|
|
53
|
30
|
/** List of fragment reassembly buffers */
|
54
|
31
|
static LIST_HEAD ( frag_buffers );
|
|
@@ -90,9 +67,9 @@ static struct ipv4_miniroute * add_ipv4_miniroute ( struct net_device *netdev,
|
90
|
67
|
* to start of list.
|
91
|
68
|
*/
|
92
|
69
|
if ( gateway.s_addr != INADDR_NONE ) {
|
93
|
|
- list_add_tail ( &miniroute->list, &miniroutes );
|
|
70
|
+ list_add_tail ( &miniroute->list, &ipv4_miniroutes );
|
94
|
71
|
} else {
|
95
|
|
- list_add ( &miniroute->list, &miniroutes );
|
|
72
|
+ list_add ( &miniroute->list, &ipv4_miniroutes );
|
96
|
73
|
}
|
97
|
74
|
|
98
|
75
|
/* Record reference to net_device */
|
|
@@ -166,7 +143,7 @@ int add_ipv4_address ( struct net_device *netdev, struct in_addr address,
|
166
|
143
|
void del_ipv4_address ( struct net_device *netdev ) {
|
167
|
144
|
struct ipv4_miniroute *miniroute;
|
168
|
145
|
|
169
|
|
- list_for_each_entry ( miniroute, &miniroutes, list ) {
|
|
146
|
+ list_for_each_entry ( miniroute, &ipv4_miniroutes, list ) {
|
170
|
147
|
if ( miniroute->netdev == netdev ) {
|
171
|
148
|
del_ipv4_miniroute ( miniroute );
|
172
|
149
|
break;
|
|
@@ -186,7 +163,7 @@ static struct ipv4_miniroute * ipv4_route ( struct in_addr *dest ) {
|
186
|
163
|
int local;
|
187
|
164
|
int has_gw;
|
188
|
165
|
|
189
|
|
- list_for_each_entry ( miniroute, &miniroutes, list ) {
|
|
166
|
+ list_for_each_entry ( miniroute, &ipv4_miniroutes, list ) {
|
190
|
167
|
local = ( ( ( dest->s_addr ^ miniroute->address.s_addr )
|
191
|
168
|
& miniroute->netmask.s_addr ) == 0 );
|
192
|
169
|
has_gw = ( miniroute->gateway.s_addr != INADDR_NONE );
|
|
@@ -547,7 +524,7 @@ static int ipv4_arp_check ( struct net_device *netdev, const void *net_addr ) {
|
547
|
524
|
const struct in_addr *address = net_addr;
|
548
|
525
|
struct ipv4_miniroute *miniroute;
|
549
|
526
|
|
550
|
|
- list_for_each_entry ( miniroute, &miniroutes, list ) {
|
|
527
|
+ list_for_each_entry ( miniroute, &ipv4_miniroutes, list ) {
|
551
|
528
|
if ( ( miniroute->netdev == netdev ) &&
|
552
|
529
|
( miniroute->address.s_addr == address->s_addr ) ) {
|
553
|
530
|
/* Found matching address */
|