Rev 3704 | Rev 3842 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3704 | Rev 3735 | ||
---|---|---|---|
Line 270... | Line 270... | ||
270 | mov eax, [dhcp.ip] |
270 | mov eax, [dhcp.ip] |
271 | mov [edx+240+11], eax |
271 | mov [edx+240+11], eax |
272 | mov [edx+240+15], word 0x0437 ; option request list |
272 | mov [edx+240+15], word 0x0437 ; option request list |
273 | mov [edx+240+17], dword 0x0f060301 |
273 | mov [edx+240+17], dword 0x0f060301 |
Line 274... | Line 274... | ||
274 | 274 | ||
275 | cmp [dhcpMsgType], byte 0x01 ; Check which msg we are sending |
275 | cmp [dhcpMsgType], 0x01 ; Check which msg we are sending |
Line 276... | Line 276... | ||
276 | jne request_options |
276 | jne request_options |
Line 277... | Line 277... | ||
277 | 277 | ||
Line 290... | Line 290... | ||
290 | mov [dhcpMsgLen], 268 ; length |
290 | mov [dhcpMsgLen], 268 ; length |
Line 291... | Line 291... | ||
291 | 291 | ||
292 | send_dhcpmsg: |
292 | send_dhcpmsg: |
293 | DEBUGF 1,"Sending DHCP discover/request\n" |
293 | DEBUGF 1,"Sending DHCP discover/request\n" |
- | 294 | mcall 75, 6, [socketNum], [dhcpMsg], [dhcpMsgLen] ; write to socket ( send broadcast request ) |
|
294 | mcall 75, 6, [socketNum], [dhcpMsg], [dhcpMsgLen] ; write to socket ( send broadcast request ) |
295 | .wait: |
Line 295... | Line 296... | ||
295 | mcall 23, TIMEOUT*100 ; wait for data |
296 | mcall 23, TIMEOUT*100 ; wait for data |
296 | 297 | ||
297 | read_data: ; we have data - this will be the response |
298 | read_data: ; we have data - this will be the response |
298 | mcall 75, 7, [socketNum], [dhcpMsg], BUFFER, MSG_DONTWAIT ; read data from socket |
299 | mcall 75, 7, [socketNum], [dhcpMsg], BUFFER, MSG_DONTWAIT ; read data from socket |
- | 300 | cmp eax, -1 |
|
- | 301 | jne @f |
|
299 | cmp eax, -1 |
302 | cmp ebx, 6 ; EWOULDBLOCK |
300 | jne @f |
303 | je send_dhcpmsg.wait |
301 | DEBUGF 1,"No answer from DHCP server\n" |
304 | DEBUGF 1,"No answer from DHCP server\n" |
302 | dec [tries] |
305 | dec [tries] |
Line 327... | Line 330... | ||
327 | jmp exit |
330 | jmp exit |
Line 328... | Line 331... | ||
328 | 331 | ||
329 | discover: |
332 | discover: |
Line 330... | Line 333... | ||
330 | call parse_response |
333 | call parse_response |
331 | 334 | ||
Line 332... | Line 335... | ||
332 | cmp [dhcpMsgType], 0x02 ; Was the response an offer? |
335 | cmp [dhcpMsgType2], 0x02 ; Was the response an offer? |
333 | je send_request |
336 | je send_request |
Line 341... | Line 344... | ||
341 | jmp build_request |
344 | jmp build_request |
Line 342... | Line 345... | ||
342 | 345 | ||
343 | request: |
346 | request: |
Line 344... | Line 347... | ||
344 | call parse_response |
347 | call parse_response |
345 | 348 | ||
Line 346... | Line 349... | ||
346 | cmp [dhcpMsgType], 0x05 ; Was the response an ACK? It should be |
349 | cmp [dhcpMsgType2], 0x05 ; Was the response an ACK? It should be |
Line 347... | Line 350... | ||
347 | jne read_data ; NO - read next packets |
350 | jne read_data ; NO - read next packets |
Line 383... | Line 386... | ||
383 | ;*************************************************************************** |
386 | ;*************************************************************************** |
384 | parse_response: |
387 | parse_response: |
Line 385... | Line 388... | ||
385 | 388 | ||
386 | DEBUGF 1,"Data received, parsing response\n" |
389 | DEBUGF 1,"Data received, parsing response\n" |
- | 390 | mov edx, [dhcpMsg] |
|
Line 387... | Line 391... | ||
387 | mov edx, [dhcpMsg] |
391 | mov [dhcpMsgType2], 0 |
388 | 392 | ||
389 | push dword [edx+16] |
393 | push dword [edx+16] |
Line 439... | Line 443... | ||
439 | inc ecx |
443 | inc ecx |
440 | jmp .next_option |
444 | jmp .next_option |
Line 441... | Line 445... | ||
441 | 445 | ||
442 | .msgtype: |
446 | .msgtype: |
443 | mov al, [edx] |
447 | mov al, [edx] |
Line 444... | Line 448... | ||
444 | mov [dhcpMsgType], al |
448 | mov [dhcpMsgType2], al |
445 | 449 | ||
Line 446... | Line 450... | ||
446 | DEBUGF 1,"DHCP Msg type: %u\n", al |
450 | DEBUGF 1,"DHCP Msg type: %u\n", al |
Line 556... | Line 560... | ||
556 | 560 | ||
557 | 561 | ||
558 | error: |
562 | error: |
- | 563 | DEBUGF 2,"Socket error\n" |
|
559 | DEBUGF 2,"Socket error\n" |
564 | exit: ; we should, instead of closing, detect ARP conflicts and detect if cable keeps connected ;) |
Line 560... | Line 565... | ||
560 | exit: ; we should, instead of closing, detect ARP conflicts and detect if cable keeps connected ;) |
565 | DEBUGF 2,"Exiting\n" |
Line 618... | Line 623... | ||
618 | 623 | ||
619 | device db 1 |
624 | device db 1 |
620 | inibuf rb 16 |
625 | inibuf rb 16 |
Line 621... | Line 626... | ||
621 | tries db ? |
626 | tries db ? |
- | 627 | ||
622 | 628 | dhcpMsgType db ? ; sent |
|
623 | dhcpMsgType db ? |
629 | dhcpMsgType2 db ? ; received |
Line 624... | Line 630... | ||
624 | dhcpLease dd ? |
630 | dhcpLease dd ? |
625 | dhcpServerIP dd ? |
631 | dhcpServerIP dd ? |