Rev 1168 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1168 | Rev 1369 | ||
---|---|---|---|
Line 17... | Line 17... | ||
17 | ;; ;; |
17 | ;; ;; |
18 | ;;10.01.2007 Bugfix for checksum function from Paolo Franchetti ;; |
18 | ;;10.01.2007 Bugfix for checksum function from Paolo Franchetti ;; |
19 | ;; ;; |
19 | ;; ;; |
20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 21... | Line 21... | ||
21 | 21 | ||
Line 22... | Line 22... | ||
22 | $Revision: 1168 $ |
22 | $Revision: 1369 $ |
23 | 23 | ||
24 | 24 | ||
Line 359... | Line 359... | ||
359 | ; Description |
359 | ; Description |
360 | ; This is an application service, called by int 0x40, function 52 |
360 | ; This is an application service, called by int 0x40, function 52 |
361 | ; It provides application access to the network interface layer |
361 | ; It provides application access to the network interface layer |
362 | ; |
362 | ; |
363 | ;*************************************************************************** |
363 | ;*************************************************************************** |
- | 364 | iglobal |
|
- | 365 | align 4 |
|
- | 366 | f52call: |
|
- | 367 | dd app_stack_handler.00 |
|
- | 368 | dd app_stack_handler.01 |
|
- | 369 | dd app_stack_handler.02 |
|
- | 370 | dd app_stack_handler.03 |
|
- | 371 | dd app_stack_handler.fail ;04 |
|
- | 372 | dd app_stack_handler.fail ;05 |
|
- | 373 | dd stack_insert_packet ;app_stack_handler.06 |
|
- | 374 | dd app_stack_handler.fail ;07 |
|
- | 375 | dd stack_get_packet ;app_stack_handler.08 |
|
- | 376 | dd app_stack_handler.09 |
|
- | 377 | dd app_stack_handler.10 |
|
- | 378 | dd app_stack_handler.11 |
|
- | 379 | dd app_stack_handler.12 |
|
- | 380 | dd app_stack_handler.13 |
|
- | 381 | dd app_stack_handler.14 |
|
- | 382 | dd app_stack_handler.15 |
|
- | 383 | endg |
|
364 | app_stack_handler: |
384 | app_stack_handler: |
- | 385 | ;in ebx,ecx |
|
- | 386 | ;out eax |
|
365 | cmp eax, 0 |
387 | cmp ebx,15 |
- | 388 | ja .fail ;if more than 15 then exit |
|
- | 389 | ||
366 | jnz not0 |
390 | jmp dword [f52call+ebx*4] |
- | 391 | ||
- | 392 | ||
- | 393 | .00: |
|
367 | ; Read the configuration word |
394 | ; Read the configuration word |
368 | mov eax, [stack_config] |
395 | mov eax, [stack_config] |
369 | ret |
396 | ret |
Line 370... | Line 397... | ||
370 | 397 | ||
371 | not0: |
- | |
372 | cmp eax, 1 |
- | |
373 | jnz not1 |
398 | .01: |
374 | ; read the IP address |
- | |
375 | 399 | ; read the IP address |
|
376 | mov eax, [stack_ip] |
400 | mov eax, [stack_ip] |
Line 377... | Line 401... | ||
377 | ret |
401 | ret |
378 | - | ||
379 | not1: |
- | |
380 | cmp eax, 2 |
- | |
381 | jnz not2 |
402 | |
382 | 403 | .02: |
|
Line 383... | Line 404... | ||
383 | ; write the configuration word |
404 | ; write the configuration word |
384 | mov [stack_config], ebx |
405 | mov [stack_config], ecx |
385 | 406 | ||
386 | ; |
407 | ; |
387 | ; If ethernet now enabled, probe for the card, reset it and empty |
408 | ; If ethernet now enabled, probe for the card, reset it and empty |
388 | ; the packet buffer |
409 | ; the packet buffer |
Line 389... | Line 410... | ||
389 | ; If all successfull, enable the card. |
410 | ; If all successfull, enable the card. |
390 | ; If ethernet now disabled, set it as disabled. Should really |
411 | ; If ethernet now disabled, set it as disabled. Should really |
391 | ; empty the tcpip data area too. |
412 | ; empty the tcpip data area too. |
392 | - | ||
393 | ; ethernet interface is '3' in ls 7 bits |
413 | |
394 | and bl, 0x7f |
414 | ; ethernet interface is '3' in ls 7 bits |
395 | cmp bl, 3 |
415 | and cl, 0x7f |
396 | - | ||
397 | je ash_eth_enable |
- | |
398 | ; Ethernet isn't enabled, so make sure that the card is disabled |
- | |
399 | mov [ethernet_active], byte 0 |
- | |
400 | - | ||
401 | ret |
- | |
402 | - | ||
403 | ash_eth_enable: |
- | |
404 | ; Probe for the card. This will reset it and enable the interface |
- | |
405 | ; if found |
- | |
406 | call eth_probe |
- | |
407 | cmp eax, 0 |
- | |
408 | je ash_eth_done ; Abort if no hardware found |
- | |
409 | 416 | cmp cl, 3 |
|
Line 410... | Line 417... | ||
410 | mov [ethernet_active], byte 1 |
417 | je ash_eth_enable |
411 | - | ||
412 | ash_eth_done: |
- | |
413 | ret |
418 | ; Ethernet isn't enabled, so make sure that the card is disabled |
414 | 419 | mov [ethernet_active], byte 0 |
|
415 | not2: |
420 | ret |
416 | cmp eax, 3 |
- | |
417 | jnz not3 |
421 | |
418 | ; write the IP Address |
- | |
419 | mov [stack_ip], ebx |
422 | .03: |
420 | ret |
- | |
421 | - | ||
422 | ;old functions was deleted |
- | |
423 | 423 | ; write the IP Address |
|
424 | not3: |
424 | mov [stack_ip], ecx |
425 | cmp eax, 6 |
425 | ret |
426 | jnz not6 |
- | |
427 | - | ||
428 | ; Insert an IP packet into the stacks received packet queue |
- | |
429 | call stack_insert_packet |
- | |
Line 430... | Line 426... | ||
430 | ret |
426 | ;old functions was deleted |
Line 431... | Line 427... | ||
431 | 427 | ;.06: |
|
432 | not6: |
- | |
433 | cmp eax, 7 |
- | |
434 | jnz not7 |
- | |
435 | 428 | ; Insert an IP packet into the stacks received packet queue |
|
436 | ; Test for any packets queued for transmission over the network |
429 | ; call stack_insert_packet |
437 | 430 | ; ret |
|
438 | not7: |
- | |
439 | cmp eax, 8 |
- | |
440 | jnz not8 |
- | |
441 | - | ||
Line -... | Line 431... | ||
- | 431 | ||
442 | call stack_get_packet |
432 | ; Test for any packets queued for transmission over the network |
443 | ; Extract a packet queued for transmission by the network |
- | |
444 | ret |
433 | |
445 | 434 | ;.08: |
|
Line 446... | Line 435... | ||
446 | not8: |
435 | ; call stack_get_packet |
447 | cmp eax, 9 |
- | |
448 | jnz not9 |
- | |
449 | - | ||
450 | ; read the gateway IP address |
436 | ; Extract a packet queued for transmission by the network |
451 | - | ||
452 | mov eax, [gateway_ip] |
437 | ; ret |
453 | ret |
438 | |
454 | - | ||
455 | not9: |
439 | .09: |
456 | cmp eax, 10 |
- | |
457 | jnz not10 |
- | |
458 | - | ||
459 | ; read the subnet mask |
440 | ; read the gateway IP address |
460 | 441 | mov eax, [gateway_ip] |
|
461 | mov eax, [subnet_mask] |
- | |
462 | ret |
442 | ret |
Line 463... | Line 443... | ||
463 | 443 | ||
464 | not10: |
- | |
465 | cmp eax, 11 |
- | |
466 | jnz not11 |
- | |
467 | 444 | .10: |
|
468 | ; write the gateway IP Address |
445 | ; read the subnet mask |
469 | mov [gateway_ip], ebx |
- | |
470 | - | ||
471 | ret |
446 | mov eax, [subnet_mask] |
472 | - | ||
473 | not11: |
- | |
Line -... | Line 447... | ||
- | 447 | ret |
|
474 | cmp eax, 12 |
448 | .11: |
475 | jnz not12 |
- | |
476 | 449 | ; write the gateway IP Address |
|
477 | ; write the subnet mask |
450 | mov [gateway_ip], ecx |
Line 478... | Line 451... | ||
478 | mov [subnet_mask], ebx |
451 | ret |
479 | - | ||
480 | - | ||
481 | not12: |
- | |
482 | cmp eax, 13 |
452 | |
483 | jnz not13 |
453 | .12: |
484 | - | ||
485 | ; read the dns |
454 | ; write the subnet mask |
Line -... | Line 455... | ||
- | 455 | mov [subnet_mask], ecx |
|
486 | 456 | ret |
|
487 | mov eax, [dns_ip] |
- | |
488 | ret |
- | |
489 | - | ||
490 | not13: |
- | |
491 | cmp eax, 14 |
457 | |
492 | jnz not14 |
- | |
493 | - | ||
494 | ; write the dns IP Address |
- | |
495 | mov [dns_ip], ebx |
458 | .13: |
496 | 459 | ; read the dns |
|
497 | ret |
460 | mov eax, [dns_ip] |
Line 498... | Line 461... | ||
498 | 461 | ret |
|
499 | ; |
- | |
500 | not14: |
462 | |
501 | cmp eax, 15 |
- | |
502 | jnz not15 |
- | |
503 | - | ||
504 | ; in ebx we need 4 to read the last 2 bytes |
- | |
505 | cmp ebx, dword 4 |
- | |
506 | je read |
463 | .14: |
Line -... | Line 464... | ||
- | 464 | ; write the dns IP Address |
|
- | 465 | mov [dns_ip], ecx |
|
- | 466 | ret |
|
Line -... | Line 467... | ||
- | 467 | ||
507 | 468 | .15: |
|
508 | ; or we need 0 to read the first 4 bytes |
469 | ; |
509 | cmp ebx, dword 0 |
470 | ; in ecx we need 4 to read the last 2 bytes |
510 | jnz param_error |
- | |
511 | - | ||
512 | ; read MAC, returned (in mirrored byte order) in eax |
471 | ; or we need 0 to read the first 4 bytes |
513 | read: |
- | |
514 | mov eax, [node_addr + ebx] |
- | |
515 | jmp @f |
- | |
516 | 472 | cmp ecx,4 |
|
Line 517... | Line 473... | ||
517 | param_error: |
473 | ja .param_error |
518 | mov eax, -1 ; params not accepted |
474 | |
- | 475 | ; read MAC, returned (in mirrored byte order) in eax |
|
- | 476 | mov eax, [node_addr + ecx] |
|
- | 477 | ret |
|
Line 519... | Line 478... | ||
519 | @@: |
478 | |
520 | ret |
479 | .param_error: |
Line 521... | Line -... | ||
521 | - | ||
522 | - | ||
523 | ; 0 -> arp_probe |
- | |
524 | ; 1 -> arp_announce |
480 | or eax, -1 ; params not accepted |
525 | ; 2 -> arp_responce (not supported yet) |
481 | ret |
526 | 482 | ||
527 | not15: ; ARP stuff |
483 | .16: |
528 | cmp eax, 16 |
484 | ; 0 -> arp_probe |
Line 529... | Line 485... | ||
529 | jnz not16 |
485 | ; 1 -> arp_announce |
530 | 486 | ; 2 -> arp_responce (not supported yet) |
|
531 | cmp ebx, 0 |
487 | test ecx,ecx |
532 | je a_probe |
488 | je a_probe |
Line 533... | Line 489... | ||
533 | 489 | ||
534 | cmp ebx, 1 |
490 | dec ebx |
Line 535... | Line 491... | ||
535 | je a_ann ; arp announce |
491 | jz a_ann ; arp announce |
536 | 492 | .fail: |
|
537 | ; cmp ebx,2 |
493 | or eax, -1 |
538 | ; jne a_resp ; arp response |
494 | ret |
539 | 495 | ||
540 | jmp param15_error |
496 | ; cmp ebx,2 |
541 | - | ||
542 | - | ||
543 | ; arp probe, sender IP must be set to 0.0.0.0, target IP is set to address being probed |
- | |
544 | ; ecx: pointer to target MAC, MAC should set to 0 by application |
- | |
545 | ; edx: target IP |
- | |
546 | a_probe: |
- | |
547 | push dword [stack_ip] |
497 | ; jne a_resp ; arp response |
- | 498 | ||
- | 499 | ; arp probe, sender IP must be set to 0.0.0.0, target IP is set to address being probed |
|
548 | 500 | ; ecx: pointer to target MAC, MAC should set to 0 by application |
|
549 | mov edx, [stack_ip] |
501 | ; edx: target IP |
Line 550... | Line 502... | ||
550 | mov [stack_ip], dword 0 |
502 | a_probe: |
551 | mov esi, ecx ; pointer to target MAC address |
503 | push dword [stack_ip] |
552 | call arp_request |
- | |
553 | - | ||
554 | pop dword [stack_ip] |
- | |
555 | jmp @f |
- | |
556 | 504 | ||
557 | ; arp announce, sender IP must be set to target IP |
505 | mov edx, [stack_ip] |
558 | ; ecx: pointer to target MAC |
- | |
559 | a_ann: |
506 | and [stack_ip], dword 0 |
560 | mov edx, [stack_ip] |
507 | mov esi, ecx ; pointer to target MAC address |
Line -... | Line 508... | ||
- | 508 | call arp_request |
|
561 | mov esi, ecx ; pointer to target MAC address |
509 | |
- | 510 | pop dword [stack_ip] |
|
562 | call arp_request |
511 | ret |
563 | jmp @f |
512 | |
564 | 513 | ; arp announce, sender IP must be set to target IP |
|
- | 514 | ; ecx: pointer to target MAC |
|
Line -... | Line 515... | ||
- | 515 | a_ann: |
|
- | 516 | mov edx, [stack_ip] |
|
- | 517 | mov esi, ecx ; pointer to target MAC address |
|
565 | param15_error: |
518 | call arp_request |
566 | mov eax, -1 |
519 | ret |
567 | 520 | ||
568 | @@: |
521 | .17: |
569 | ret |
522 | ; |
570 | ; |
523 | ; modified by [smb] |
571 | ; modified by [smb] |
524 | |
572 | 525 | ; |
|
573 | ; |
526 | ; ARPTable manager interface |
574 | ; ARPTable manager interface |
527 | ;see "proc arp_table_manager" for more details |
575 | not16: |
- | |
576 | cmp eax, 17 |
- | |
577 | jnz stack_driver_end |
- | |
578 | - | ||
579 | ;see "proc arp_table_manager" for more details |
- | |
580 | stdcall arp_table_manager,ebx,ecx,edx ;Opcode,Index,Extra |
528 | stdcall arp_table_manager,ecx,edx,esi ;Opcode,Index,Extra |
581 | - | ||
582 | ret |
- | |
583 | ; |
- | |
584 | - | ||
585 | stack_driver_end: |
- | |
586 | ret |
- | |
587 | 529 | ret |
|
588 | - | ||
589 | 530 | ; |
|
590 | ;*************************************************************************** |
531 | |
591 | ; Function |
532 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
592 | ; app_socket_handler |
- | |
593 | ; |
533 | ash_eth_enable: |
594 | ; Description |
- | |
595 | ; This is an application service, called by int 0x40, function 53 |
- | |
596 | ; It provides application access to stack socket services |
- | |
597 | ; such as opening sockets |
- | |
598 | ; |
- | |
599 | ;*************************************************************************** |
- | |
600 | app_socket_handler: |
534 | ; Probe for the card. This will reset it and enable the interface |
601 | cmp eax, 0 |
- | |
602 | jnz nots0 |
- | |
603 | - | ||
604 | call socket_open |
- | |
605 | ret |
- | |
606 | - | ||
607 | nots0: |
535 | ; if found |
608 | cmp eax, 1 |
- | |
609 | jnz nots1 |
- | |
610 | - | ||
611 | call socket_close |
- | |
612 | ret |
- | |
613 | - | ||
614 | nots1: |
536 | call eth_probe |
615 | cmp eax, 2 |
- | |
616 | jnz nots2 |
- | |
617 | - | ||
618 | call socket_poll |
- | |
619 | ret |
- | |
620 | - | ||
621 | nots2: |
537 | test eax,eax |
622 | cmp eax, 3 |
- | |
623 | jnz nots3 |
- | |
624 | - | ||
625 | call socket_read |
538 | jz ash_eth_done ; Abort if no hardware found |
626 | ret |
539 | |
627 | - | ||
628 | nots3: |
540 | mov [ethernet_active], byte 1 |
629 | cmp eax, 4 |
- | |
630 | jnz nots4 |
- | |
631 | - | ||
632 | call socket_write |
541 | ash_eth_done: |
633 | ret |
- | |
634 | - | ||
635 | nots4: |
542 | ret |
636 | cmp eax, 5 |
543 | ;*************************************************************************** |
Line -... | Line 544... | ||
- | 544 | ; Function |
|
- | 545 | ; app_socket_handler |
|
637 | jnz nots5 |
546 | ; |
638 | 547 | ; Description |
|
639 | call socket_open_tcp |
548 | ; This is an application service, called by int 0x40, function 53 |
Line -... | Line 549... | ||
- | 549 | ; It provides application access to stack socket services |
|
640 | ret |
550 | ; such as opening sockets |
641 | - | ||
Line 642... | Line -... | ||
642 | nots5: |
- | |
643 | cmp eax, 6 |
551 | ; |
644 | jnz nots6 |
- | |
Line -... | Line 552... | ||
- | 552 | ;*************************************************************************** |
|
645 | 553 | iglobal |
|
646 | call socket_status |
554 | align 4 |
647 | ret |
555 | f53call: |
648 | 556 | dd socket_open ;00 |
|
649 | nots6: |
557 | dd socket_close ;01 |
650 | cmp eax, 7 |
- | |
651 | jnz nots7 |
558 | dd socket_poll ;02 |
652 | 559 | dd socket_read ;03 |
|
653 | call socket_write_tcp |
- | |
654 | ret |
- | |
Line 655... | Line 560... | ||
655 | 560 | dd socket_write ;04 |
|
656 | nots7: |
561 | dd socket_open_tcp ;05 |
657 | cmp eax, 8 |
- | |
658 | jnz nots8 |
- | |
659 | - | ||
660 | call socket_close_tcp |
562 | dd socket_status ;06 |
- | 563 | dd socket_write_tcp ;07 |
|
- | 564 | dd socket_close_tcp ;08 |
|
- | 565 | dd is_localport_unused ;09 |
|
- | 566 | dd app_socket_handler.10 |
|
Line -... | Line 567... | ||
- | 567 | dd socket_read_packet ;11 |
|
661 | ret |
568 | endg |
662 | 569 | ||
663 | nots8: |
- | |
664 | cmp eax, 9 |
570 | app_socket_handler: |
665 | jnz nots9 |
571 | ;in ebx,ecx,edx,wsi |
666 | - | ||
- | 572 | ;out eax |
|
667 | call is_localport_unused |
573 | cmp eax,255 |
668 | ret |
574 | je stack_internal_status |
669 | 575 | ||
- | 576 | cmp eax,11 |
|
670 | nots9: |
577 | ja .fail ;if more than 15 then exit |
- | 578 | ||
671 | cmp eax, 10 |
579 | jmp dword [f53call+eax*4] |
672 | jnz nots10 |
580 | |
673 | 581 | .10: |
|
674 | mov eax,dword[drvr_cable] |
582 | mov eax,dword[drvr_cable] |
675 | test eax,eax |
583 | test eax,eax |
676 | jnz @f ; if function is not implented, return -1 |
584 | jnz @f ; if function is not implented, return -1 |
677 | mov al,-1 |
585 | or al,-1 |
Line 720... | Line 628... | ||
720 | ; 4 : return number of received packets dumped |
628 | ; 4 : return number of received packets dumped |
721 | ; 5 : return number of arp packets received |
629 | ; 5 : return number of arp packets received |
722 | ; 6 : return status of packet driver |
630 | ; 6 : return status of packet driver |
723 | ; ( 0 == not active, FFFFFFFF = successful ) |
631 | ; ( 0 == not active, FFFFFFFF = successful ) |
Line 724... | Line -... | ||
724 | - | ||
725 | call stack_internal_status |
- | |
726 | ret |
- | |
727 | - | ||
728 | notsdebug: |
- | |
729 | ; Invalid Option |
- | |
Line 730... | Line -... | ||
730 | ret |
- | |
731 | - | ||
732 | - | ||
733 | uglobal |
- | |
734 | ARPTmp: |
- | |
735 | times 14 db 0 |
- | |
736 | endg |
- | |
737 | - | ||
738 | ;*************************************************************************** |
- | |
739 | ; Function |
- | |
740 | ; stack_internal_status |
- | |
741 | ; |
- | |
742 | ; Description |
- | |
743 | ; Returns information about the internal status of the stack |
- | |
744 | ; This is only useful for debugging |
- | |
745 | ; It works with the ethernet driver |
- | |
746 | ; sub function in ebx |
- | |
747 | ; return requested data in eax |
- | |
748 | ; |
632 | |
749 | ;*************************************************************************** |
633 | |
750 | stack_internal_status: |
634 | stack_internal_status: |
Line 751... | Line 635... | ||
751 | cmp ebx, 100 |
635 | cmp ebx, 100 |