131
131
run_lwip (void ) {
132
132
struct ip_addr ipaddr , netmask , gw ;
133
133
struct netif netif ;
134
+ int first = 1 ;
134
135
135
136
mem_init ();
136
137
memp_init ();
@@ -161,8 +162,14 @@ run_lwip (void) {
161
162
LPCmodSettings .OSsettings .staticMask [3 ]);
162
163
163
164
netif_add (& netif , & ipaddr , & netmask , & gw , NULL , ebd_init , ip_input );
164
- if (LPCmodSettings .OSsettings .useDHCP )
165
+ if (LPCmodSettings .OSsettings .useDHCP ){
165
166
dhcp_start (& netif );
167
+ printk ("\n DHCP Attempt - Received %u.%u.%u.%u" ,
168
+ (netif .dhcp -> offered_ip_addr .addr & 0xff000000 ) >> 24 ,
169
+ (netif .dhcp -> offered_ip_addr .addr & 0x00ff0000 ) >> 16 ,
170
+ (netif .dhcp -> offered_ip_addr .addr & 0x0000ff00 ) >> 8 ,
171
+ netif .dhcp -> offered_ip_addr .addr & 0x000000ff );
172
+ }
166
173
else {
167
174
//Not necessary, but polite.
168
175
dhcp_stop (& netif );
@@ -178,15 +185,18 @@ run_lwip (void) {
178
185
httpd_init ();
179
186
180
187
int divisor = 0 ;
181
- int first = 1 ;
182
188
while (1 ) {
183
189
//printk ("while(1)");
184
190
if (!ebd_wait (& netif , TCP_TMR_INTERVAL )) {
185
191
//printk ("!ebd_wait");
186
192
if (divisor ++ == 60 * 4 ) {
187
193
if (first ) {
188
194
if (netif .dhcp -> state != DHCP_BOUND && LPCmodSettings .OSsettings .useDHCP ) {
189
- printk (" DHCP FAILED - Falling back to 192.168.0.250\n" );
195
+ printk ("\n DHCP FAILED - Falling back to %u.%u.%u.%u" ,
196
+ (ipaddr .addr & 0xff000000 ) >> 24 ,
197
+ (ipaddr .addr & 0x00ff0000 ) >> 16 ,
198
+ (ipaddr .addr & 0x0000ff00 ) >> 8 ,
199
+ ipaddr .addr & 0x000000ff );
190
200
dhcp_stop (& netif );
191
201
netif_set_addr (& netif , & ipaddr , & netmask , & gw );
192
202
}
@@ -195,8 +205,8 @@ run_lwip (void) {
195
205
((netif .ip_addr .addr ) >> 16 & 0xff ),
196
206
((netif .ip_addr .addr ) >> 8 & 0xff ),
197
207
((netif .ip_addr .addr ) & 0xff ));
208
+ first = 0 ;
198
209
}
199
- first = 0 ;
200
210
dhcp_coarse_tmr ();
201
211
divisor = 0 ;
202
212
}
0 commit comments