annotate packages/redboot/current/src/net/bootp.c @ 1246:55fbbf4dffb2

Clean up warnings
author gthomas
date Fri, 26 Sep 2003 10:35:43 +0000
parents 844ff6aec80b
children c07ec2765e3e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
1 //==========================================================================
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
2 //
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
3 // net/bootp.c
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
4 //
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
5 // Stand-alone minimal BOOTP support for RedBoot
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
6 //
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
7 //==========================================================================
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
8 //####ECOSGPLCOPYRIGHTBEGIN####
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
9 // -------------------------------------------
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
10 // This file is part of eCos, the Embedded Configurable Operating System.
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
1122
92e31da869cc Add ^C abort functionality to BOOTP and PING operations.
gthomas
parents: 1117
diff changeset
12 // Copyright (C) 2002, 2003 Gary Thomas
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
13 //
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
14 // eCos is free software; you can redistribute it and/or modify it under
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
15 // the terms of the GNU General Public License as published by the Free
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
16 // Software Foundation; either version 2 or (at your option) any later version.
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
17 //
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
18 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
19 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
21 // for more details.
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
22 //
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
23 // You should have received a copy of the GNU General Public License along
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
24 // with eCos; if not, write to the Free Software Foundation, Inc.,
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
25 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
26 //
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
27 // As a special exception, if other files instantiate templates or use macros
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
28 // or inline functions from this file, or you compile this file and link it
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
29 // with other works to produce a work based on this file, this file does not
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
30 // by itself cause the resulting work to be covered by the GNU General Public
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
31 // License. However the source code for this file must still be made available
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
32 // in accordance with section (3) of the GNU General Public License.
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
33 //
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
34 // This exception does not invalidate any other reasons why a work based on
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
35 // this file might be covered by the GNU General Public License.
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
36 //
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
37 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
210
d2c90368aeef Merge from eCos master repository on 2002-05-23-21:39:14-BST
jlarmour
parents: 208
diff changeset
38 // at http://sources.redhat.com/ecos/ecos-license/
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
39 // -------------------------------------------
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 184
diff changeset
40 //####ECOSGPLCOPYRIGHTEND####
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
41 //==========================================================================
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
42 //#####DESCRIPTIONBEGIN####
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
43 //
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
44 // Author(s): gthomas
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
45 // Contributors: gthomas
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
46 // Date: 2000-07-14
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
47 // Purpose:
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
48 // Description:
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
49 //
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
50 // This code is part of RedBoot (tm).
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
51 //
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
52 //####DESCRIPTIONEND####
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
53 //
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
54 //==========================================================================
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
55
184
022f1e506033 Merge from eCos master repository on 2001-10-02-17:59:22-BST
jlarmour
parents: 165
diff changeset
56 #include <redboot.h>
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
57 #include <net/net.h>
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
58 #include <net/bootp.h>
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
59
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
60 #define SHOULD_BE_RANDOM 0x12345555
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
61
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
62 /* How many milliseconds to wait before retrying the request */
1245
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
63 #define RETRY_TIME 2000
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
64 #define MAX_RETRIES 8
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
65
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
66 static bootp_header_t *bp_info;
231
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
67
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
68 #ifdef CYGSEM_REDBOOT_NETWORKING_DHCP
231
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
69 static const unsigned char dhcpCookie[] = {99,130,83,99};
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
70 static const unsigned char dhcpEnd[] = {255};
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
71 static const unsigned char dhcpDiscover[] = {53,1,1};
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
72 static const unsigned char dhcpOffer[] = {53,1,2};
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
73 static const unsigned char dhcpRequest[] = {53,1,3};
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
74 static const unsigned char dhcpRequestIP[] = {50,4};
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
75 static const unsigned char dhcpAck[] = {53,1,5};
1245
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
76 static const unsigned char dhcpNak[] = {53,1,6};
1217
0e1c2770aa9d Add new options to DHCP request - from David Vrabel
gthomas
parents: 1122
diff changeset
77 static const unsigned char dhcpParamRequestList[] = {55,3,1,3,6};
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
78 static enum {
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
79 DHCP_NONE = 0,
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
80 DHCP_DISCOVER,
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
81 DHCP_OFFER,
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
82 DHCP_REQUEST,
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
83 DHCP_ACK
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
84 } dhcpState;
231
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
85 #endif
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
86
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
87 static void
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
88 bootp_handler(udp_socket_t *skt, char *buf, int len,
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
89 ip_route_t *src_route, word src_port)
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
90 {
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
91 bootp_header_t *b;
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
92 #ifdef CYGSEM_REDBOOT_NETWORKING_DHCP
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
93 unsigned char *p, *expected = 0;
231
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
94 #endif
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
95
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
96 b = (bootp_header_t *)buf;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
97 if (bp_info) {
231
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
98 memset(bp_info,0,sizeof *bp_info);
156
b939e9cada46 Merge from eCos master repository on 2001-03-29-21:44:39-BST
jlarmour
parents: 151
diff changeset
99 if (len > sizeof *bp_info)
b939e9cada46 Merge from eCos master repository on 2001-03-29-21:44:39-BST
jlarmour
parents: 151
diff changeset
100 len = sizeof *bp_info;
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
101 memcpy(bp_info, b, len);
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
102 }
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
103
231
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
104 // Only accept pure REPLY responses
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
105 if (b->bp_op != BOOTREPLY)
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
106 return;
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
107
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
108 // Must be sent to me, as well!
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
109 if (memcmp(b->bp_chaddr, __local_enet_addr, 6))
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
110 return;
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
111
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
112 #ifdef CYGSEM_REDBOOT_NETWORKING_DHCP
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
113 p = b->bp_vend;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
114 if (memcmp(p, dhcpCookie, sizeof(dhcpCookie)))
231
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
115 return;
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
116 p += 4;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
117
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
118 switch (dhcpState) {
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
119 case DHCP_DISCOVER:
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
120 // The discover message has been sent, only accept an offer reply
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
121 if (memcmp(p, dhcpOffer, sizeof(dhcpOffer)) == 0) {
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
122 dhcpState = DHCP_OFFER;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
123 return;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
124 } else {
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
125 expected = (unsigned char *)dhcpOffer;
231
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
126 }
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
127 break;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
128 case DHCP_REQUEST:
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
129 // The request message has been sent, only accept an ack reply
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
130 if (memcmp(p, dhcpAck, sizeof(dhcpAck)) == 0) {
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
131 dhcpState = DHCP_ACK;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
132 return;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
133 } else {
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
134 expected = (unsigned char *)dhcpAck;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
135 }
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
136 break;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
137 case DHCP_NONE:
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
138 case DHCP_OFFER:
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
139 case DHCP_ACK:
1245
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
140 // Quitely ignore these - they indicate repeated message from server
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
141 return;
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
142 }
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
143 // See if we've been NAK'd - if so, give up and try again
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
144 if (memcmp(p, dhcpNak, sizeof(dhcpNak)) == 0) {
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
145 dhcpState = DHCP_NONE;
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
146 return;
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
147 }
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
148 diag_printf("DHCP reply: %d/%d/%d, not %d/%d/%d\n",
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
149 p[0], p[1], p[2], expected[0], expected[1], expected[2]);
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
150 return;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
151 #else
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
152 // Simple BOOTP - this is all there is!
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
153 memcpy(__local_ip_addr, &b->bp_yiaddr, 4);
231
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
154 #endif
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
155 }
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
156
231
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
157 #define AddOption(p,d) do {memcpy(p,d,sizeof d); p += sizeof d;} while (0)
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
158
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
159 /*
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
160 * Find our IP address and copy to __local_ip_addr.
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
161 * Return zero if successful, -1 if not.
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
162 */
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
163 int
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
164 __bootp_find_local_ip(bootp_header_t *info)
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
165 {
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
166 udp_socket_t udp_skt;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
167 bootp_header_t b;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
168 ip_route_t r;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
169 int retry;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
170 unsigned long start;
165
d63db767121d Merge from eCos master repository on 2001-06-29-06:43:03-BST
jlarmour
parents: 156
diff changeset
171 ip_addr_t saved_ip_addr;
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
172 #ifdef CYGSEM_REDBOOT_NETWORKING_DHCP
231
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
173 unsigned char *p;
1245
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
174 int oldState;
231
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
175 #endif
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
176 int txSize;
1122
92e31da869cc Add ^C abort functionality to BOOTP and PING operations.
gthomas
parents: 1117
diff changeset
177 bool abort = false;
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
178 static int xid = SHOULD_BE_RANDOM;
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
179
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
180 #ifdef CYGSEM_REDBOOT_NETWORKING_DHCP
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
181 dhcpState = DHCP_NONE;
231
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
182 #endif
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
183
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
184 // Where we want the results saved
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
185 bp_info = info;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
186 // Preserve any IP address we currently have, just in case
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
187 memcpy(saved_ip_addr, __local_ip_addr, sizeof(__local_ip_addr));
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
188
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
189 // fill out route for a broadcast
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
190 r.ip_addr[0] = 255;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
191 r.ip_addr[1] = 255;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
192 r.ip_addr[2] = 255;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
193 r.ip_addr[3] = 255;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
194 r.enet_addr[0] = 255;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
195 r.enet_addr[1] = 255;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
196 r.enet_addr[2] = 255;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
197 r.enet_addr[3] = 255;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
198 r.enet_addr[4] = 255;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
199 r.enet_addr[5] = 255;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
200
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
201 // setup a socket listener for bootp replies
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
202 __udp_install_listener(&udp_skt, IPPORT_BOOTPC, bootp_handler);
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
203
1122
92e31da869cc Add ^C abort functionality to BOOTP and PING operations.
gthomas
parents: 1117
diff changeset
204 retry = MAX_RETRIES;
92e31da869cc Add ^C abort functionality to BOOTP and PING operations.
gthomas
parents: 1117
diff changeset
205 while (!abort && (retry-- > 0)) {
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
206 start = MS_TICKS();
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
207
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
208 // Build up the BOOTP/DHCP request
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
209 memset(&b, 0, sizeof(b));
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
210 b.bp_op = BOOTREQUEST;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
211 b.bp_htype = HTYPE_ETHERNET;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
212 b.bp_hlen = 6;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
213 b.bp_xid = xid++;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
214 memcpy(b.bp_chaddr, __local_enet_addr, 6);
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
215 memset(__local_ip_addr, 0, sizeof(__local_ip_addr));
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
216
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
217 #ifdef CYGSEM_REDBOOT_NETWORKING_DHCP
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
218 p = b.bp_vend;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
219 switch (dhcpState) {
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
220 case DHCP_NONE:
1242
bc69956ed7c9 Handle DHCP retries
gthomas
parents: 1227
diff changeset
221 case DHCP_DISCOVER:
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
222 AddOption(p,dhcpCookie);
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
223 AddOption(p,dhcpDiscover);
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
224 AddOption(p,dhcpParamRequestList);
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
225 AddOption(p,dhcpEnd);
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
226 dhcpState = DHCP_DISCOVER;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
227 break;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
228 case DHCP_OFFER:
1243
4f0c5ba87a3a Fix more DHCP buglets
gthomas
parents: 1242
diff changeset
229 retry = MAX_RETRIES;
1242
bc69956ed7c9 Handle DHCP retries
gthomas
parents: 1227
diff changeset
230 case DHCP_REQUEST:
1245
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
231 b.bp_xid = bp_info->bp_xid; // Match what server sent
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
232 AddOption(p,dhcpCookie);
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
233 AddOption(p,dhcpRequest);
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
234 AddOption(p,dhcpRequestIP);
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
235 memcpy(p, &bp_info->bp_yiaddr, 4); p += 4; // Ask for the address just given
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
236 AddOption(p,dhcpParamRequestList);
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
237 AddOption(p,dhcpEnd);
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
238 dhcpState = DHCP_REQUEST;
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
239 memset(&b.bp_yiaddr, 0xFF, 4);
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
240 memset(&b.bp_siaddr, 0xFF, 4);
1245
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
241 memset(&b.bp_yiaddr, 0x00, 4);
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
242 memset(&b.bp_siaddr, 0x00, 4);
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
243 break;
1246
55fbbf4dffb2 Clean up warnings
gthomas
parents: 1245
diff changeset
244 case DHCP_ACK:
55fbbf4dffb2 Clean up warnings
gthomas
parents: 1245
diff changeset
245 // Ignore these states (they won't happen)
55fbbf4dffb2 Clean up warnings
gthomas
parents: 1245
diff changeset
246 break;
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
247 }
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
248
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
249 // Some servers insist on a minimum amount of "vendor" data
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
250 if (p < &b.bp_vend[BP_MIN_VEND_SIZE]) p = &b.bp_vend[BP_MIN_VEND_SIZE];
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
251 txSize = p - (unsigned char*)&b;
1245
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
252 oldState = dhcpState;
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
253 #else
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
254 txSize = sizeof(b);
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
255 #endif
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
256
231
4ebdd3788c30 Merge gateway support from Grant Edwards
gthomas
parents: 210
diff changeset
257 __udp_send((char *)&b, txSize, &r, IPPORT_BOOTPS, IPPORT_BOOTPC);
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
258
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
259 do {
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
260 __enet_poll();
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
261 #ifdef CYGSEM_REDBOOT_NETWORKING_DHCP
1245
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
262 if (dhcpState != oldState) {
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
263 if (dhcpState == DHCP_ACK) {
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
264 unsigned char *end;
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
265 int optlen;
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
266 // Address information has now arrived!
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
267 memcpy(__local_ip_addr, &bp_info->bp_yiaddr, 4);
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
268 #ifdef CYGSEM_REDBOOT_NETWORKING_USE_GATEWAY
1245
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
269 memcpy(__local_ip_gate, &bp_info->bp_giaddr, 4);
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
270 #endif
1245
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
271 p = bp_info->bp_vend+4;
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
272 end = (unsigned char *)bp_info+sizeof(*bp_info);
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
273 while (p < end) {
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
274 unsigned char tag = *p;
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
275 if (tag == TAG_END)
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
276 break;
1245
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
277 if (tag == TAG_PAD)
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
278 optlen = 1;
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
279 else {
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
280 optlen = p[1];
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
281 p += 2;
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
282 switch (tag) {
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
283 case TAG_SUBNET_MASK: // subnet mask
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
284 memcpy(__local_ip_mask,p,4);
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
285 break;
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
286 #ifdef CYGSEM_REDBOOT_NETWORKING_USE_GATEWAY
1245
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
287 case TAG_GATEWAY: // router
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
288 memcpy(__local_ip_gate,p,4);
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
289 break;
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
290 #endif
1245
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
291 default:
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
292 break;
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
293 }
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
294 }
1245
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
295 p += optlen;
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
296 }
1245
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
297 __udp_remove_listener(IPPORT_BOOTPC);
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
298 return 0;
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
299 } else {
844ff6aec80b Improve DHCP again
gthomas
parents: 1243
diff changeset
300 break; // State changed, handle it
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
301 }
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
302 }
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
303 #else
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
304 // All done, if address response has arrived
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
305 if (__local_ip_addr[0] || __local_ip_addr[1] ||
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
306 __local_ip_addr[2] || __local_ip_addr[3]) {
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
307 /* success */
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
308 __udp_remove_listener(IPPORT_BOOTPC);
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
309 return 0;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
310 }
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
311 #endif
1122
92e31da869cc Add ^C abort functionality to BOOTP and PING operations.
gthomas
parents: 1117
diff changeset
312 if (_rb_break(1)) {
92e31da869cc Add ^C abort functionality to BOOTP and PING operations.
gthomas
parents: 1117
diff changeset
313 // The user typed ^C on the console
92e31da869cc Add ^C abort functionality to BOOTP and PING operations.
gthomas
parents: 1117
diff changeset
314 abort = true;
92e31da869cc Add ^C abort functionality to BOOTP and PING operations.
gthomas
parents: 1117
diff changeset
315 break;
92e31da869cc Add ^C abort functionality to BOOTP and PING operations.
gthomas
parents: 1117
diff changeset
316 }
92e31da869cc Add ^C abort functionality to BOOTP and PING operations.
gthomas
parents: 1117
diff changeset
317 MS_TICKS_DELAY(); // Count for ^C test
151
25e238959bae Merge from eCos master repository on 2001-02-12-23:44:24-GMT
jlarmour
parents: 115
diff changeset
318 } while ((MS_TICKS_DELAY() - start) < RETRY_TIME);
1122
92e31da869cc Add ^C abort functionality to BOOTP and PING operations.
gthomas
parents: 1117
diff changeset
319
92e31da869cc Add ^C abort functionality to BOOTP and PING operations.
gthomas
parents: 1117
diff changeset
320 // Warn the user that we're polling for BOOTP info
92e31da869cc Add ^C abort functionality to BOOTP and PING operations.
gthomas
parents: 1117
diff changeset
321 if (retry == (MAX_RETRIES-1)) {
92e31da869cc Add ^C abort functionality to BOOTP and PING operations.
gthomas
parents: 1117
diff changeset
322 diag_printf("... waiting for BOOTP information\n");
92e31da869cc Add ^C abort functionality to BOOTP and PING operations.
gthomas
parents: 1117
diff changeset
323 }
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
324 }
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
325
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
326 // timed out
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
327 __udp_remove_listener(IPPORT_BOOTPC);
1227
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
328 // Restore any previous IP address
54f8d0daacd4 Fix DHCP - BUG #1000053
gthomas
parents: 1217
diff changeset
329 memcpy(__local_ip_addr, saved_ip_addr, sizeof(__local_ip_addr));
115
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
330 return -1;
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
331 }
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
332
6ed91473a1cd Merge from eCos master repository on 2000-08-21-22:40:54-BST
jlarmour
parents:
diff changeset
333