home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / packetdrivers.tar.gz / pd.tar / src / pktall.asm < prev    next >
Assembly Source File  |  1995-06-25  |  5KB  |  271 lines

  1. version    equ    0
  2.  
  3. ;  Copyright, 1988-1992, Russell Nelson, Crynwr Software
  4.  
  5. ;   This program is free software; you can redistribute it and/or modify
  6. ;   it under the terms of the GNU General Public License as published by
  7. ;   the Free Software Foundation, version 1.
  8. ;
  9. ;   This program is distributed in the hope that it will be useful,
  10. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. ;   GNU General Public License for more details.
  13. ;
  14. ;   You should have received a copy of the GNU General Public License
  15. ;   along with this program; if not, write to the Free Software
  16. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.     include    defs.asm
  19.  
  20. code    segment para public
  21.     assume    cs:code, ds:code
  22.  
  23.     org    80h
  24. phd_dioa    label    byte
  25.  
  26.     org    100h
  27. start:
  28.     jmp    start_1
  29.  
  30. copyleft_msg    label    byte
  31.  db "Packet receiver version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version," copyright 1990, Russell Nelson.",CR,LF
  32.  db "This program is free software; see the file COPYING for details.",CR,LF
  33.  db "NO WARRANTY; see the file COPYING for details.",CR,LF
  34. crlf_msg    db    CR,LF,'$'
  35.  
  36. their_isr    dd    ?
  37. their_mode    dw    ?
  38. entry_point    db    ?,?,?,?
  39. handle        dw    ?
  40.  
  41. no_signature_msg    db    "No packet driver at that address",'$'
  42. usage_msg    db    "usage: pktall <packet_int_no> [-v] [-p] [-a <enet_addr>]",'$'
  43. waiting_msg    label    byte
  44.     db    "Now waiting for packets to be received.  Press any key to exit.",CR,LF,'$'
  45.  
  46. verbose_switch    db    0
  47. pro_switch    db    0
  48. address_switch    db    0
  49. ether_addr    db    EADDR_LEN dup(-1)
  50.  
  51. queue_overflow    dw    0
  52.  
  53. usage_error:
  54.     mov    dx,offset usage_msg
  55. error:
  56.     mov    ah,9
  57.     int    21h
  58.     int    20h
  59.  
  60. start_1:
  61.     mov    dx,offset copyleft_msg
  62.     mov    ah,9
  63.     int    21h
  64.  
  65.     mov    si,offset phd_dioa+1
  66.     cmp    byte ptr [si],CR    ;end of line?
  67.     je    usage_error
  68.  
  69.     mov    di,offset entry_point
  70.     call    get_number
  71.  
  72. another_switch:
  73.     call    skip_blanks
  74.     cmp    al,'-'            ;did they specify a switch?
  75.     je    have_switch
  76.     jmp    not_switch
  77. have_switch:
  78.     cmp    byte ptr [si+1],'v'    ;did they specify '-v'?
  79.     je    got_verbose_switch
  80.     cmp    byte ptr [si+1],'p'    ;did they specify '-p'?
  81.     je    got_pro_switch
  82.     cmp    byte ptr [si+1],'a'    ;did they specify '-a'?
  83.     je    got_addr_switch
  84.     jmp    usage_error        ;no, must be an error.
  85. got_pro_switch:
  86.     add    si,2
  87.     mov    pro_switch,1
  88.     jmp    another_switch
  89. got_verbose_switch:
  90.     add    si,2
  91.     mov    verbose_switch,1
  92.     jmp    another_switch
  93. got_addr_switch:
  94.  
  95.     add    si,2
  96.  
  97.     mov    di,offset ether_addr
  98.     movseg    es,ds
  99.     call    get_eaddr
  100.  
  101.     mov    address_switch,1
  102.     mov    pro_switch,1        ;-a implies -p.
  103.     jmp    another_switch
  104. not_switch:
  105.     call    skip_blanks
  106.     cmp    al,CR
  107.     jne    usage_error
  108.  
  109.     call    queue_init
  110.  
  111.     call    verify_packet_int
  112.     jc    error
  113.     mov    dx,offset no_signature_msg
  114.     jne    error
  115.  
  116.     mov    their_isr.offs,bx
  117.     mov    their_isr.segm,es
  118.  
  119.     mov    ax,1ffh            ;driver_info
  120.     call    int_pkt
  121.     call    fatal_error
  122.  
  123.     mov    ah,2            ;access all packets.
  124.     mov    al,ch            ;their class from driver_info().
  125.     mov    bx,dx            ;their type from driver_info().
  126.     mov    dl,cl            ;their number from driver_info().
  127.     mov    cx,0            ;type length of zero.
  128.     movseg    es,cs
  129.     mov    di,offset our_recv
  130.     call    int_pkt
  131.     call    fatal_error
  132.     mov    handle,ax
  133.  
  134.     mov    ah,21            ;get the receive mode.
  135.     mov    bx,handle
  136.     call    int_pkt
  137.     call    fatal_error
  138.     mov    their_mode,ax
  139.  
  140.     cmp    pro_switch,0
  141.     je    not_pro
  142.  
  143.     mov    ah,20            ;set it to promiscuous mode.
  144.     mov    bx,handle
  145.     mov    cx,6
  146.     call    int_pkt
  147.     call    fatal_error
  148. not_pro:
  149.  
  150.     mov    dx,offset waiting_msg
  151.     mov    ah,9
  152.     int    21h
  153.  
  154. wait_for_key:
  155.     cmp    queue_overflow,0    ;did we drop a packet?
  156.     je    not_overflow
  157.     mov    queue_overflow,0
  158.     mov    al,'O'
  159.     call    chrout
  160. not_overflow:
  161.  
  162.     call    queue_pull
  163.     jc    no_packet
  164.  
  165.     cmp    verbose_switch,0
  166.     je    not_verbose
  167.     call    dump_hex
  168.     call    crlf
  169.     jmp    short no_packet
  170. not_verbose:
  171.     mov    al,'R'
  172.     call    chrout
  173.  
  174. no_packet:
  175.     mov    ah,1            ;check for any key.
  176.     int    16h
  177.     je    wait_for_key        ;no key -- keep waiting.
  178.  
  179.     mov    ah,0            ;fetch the key.
  180.     int    16h
  181.  
  182.     mov    ah,20            ;reset the receive mode.
  183.     mov    bx,handle
  184.     mov    cx,their_mode
  185.     call    int_pkt
  186.  
  187.     mov    ah,3
  188.     mov    bx,handle
  189.     call    int_pkt
  190.     call    fatal_error
  191.  
  192.     int    20h
  193.  
  194.     assume    ds:nothing
  195.  
  196. our_recv:
  197.     push    ds
  198.     push    cs
  199.     pop    ds
  200.     or    ax,ax            ;first or second call?
  201.     jne    our_recv_1        ;second -- bump the packet flag.
  202.     movseg    es,cs
  203.     call    queue_push
  204.     jnc    our_recv_exit
  205.     inc    queue_overflow
  206.     xor    di,di
  207.     mov    es,di
  208.     jmp    short our_recv_exit
  209. our_recv_1:
  210.     cmp    address_switch,0    ;are we looking for an address?
  211.     je    our_recv_exit        ;no.
  212.     push    es
  213.     push    di
  214.     push    si
  215.     mov    ax,cs
  216.     mov    es,ax
  217.     mov    di,offset ether_addr    ;is the destination our address?
  218.     mov    cx,EADDR_LEN/2
  219.     repe    cmpsw
  220.     je    our_recv_2
  221.     add    si,cx            ;move to source address.
  222.     mov    di,offset ether_addr    ;is the source our address?
  223.     mov    cx,EADDR_LEN/2
  224.     rep    cmpsw
  225. our_recv_2:
  226.     pop    si
  227.     pop    di
  228.     pop    es
  229.     je    our_recv_exit        ;yes.
  230.  
  231.     cmp    word ptr [si][0],-1    ;always receive broadcasts.
  232.     jne    our_recv_drop
  233.     cmp    word ptr [si][2],-1
  234.     jne    our_recv_drop
  235.     cmp    word ptr [si][4],-1
  236.     je    our_recv_exit
  237. our_recv_drop:
  238.     call    queue_unpush
  239. our_recv_exit:
  240.     pop    ds
  241.     retf
  242.  
  243. int_pkt:
  244.     push    ds
  245.     push    es
  246.     pushf
  247.     cli
  248.     call    their_isr
  249.     pop    es
  250.     pop    ds
  251.     ret
  252.  
  253.     include    queue.asm
  254.     include    pkterr.asm
  255.     include    getnum.asm
  256.     include    getdig.asm
  257.     include    skipblk.asm
  258.     include    digout.asm
  259.     include    chrout.asm
  260.     include    verifypi.asm
  261.     include    getea.asm
  262.     include    dumphex.asm
  263.     include    crlf.asm
  264.  
  265.     align    4
  266. queue_begin    label    byte
  267.  
  268. code    ends
  269.  
  270.     end    start
  271.