home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / MISC / NETWORK / DRIVERSS.ZIP / PKTMULTI.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-01-27  |  5.7 KB  |  290 lines

  1. version    equ    0
  2.  
  3. ;  Russell Nelson, Clarkson University.  December 24, 1989
  4. ;  Copyright, 1989, Russell Nelson
  5.  
  6. ;   This program is free software; you can redistribute it and/or modify
  7. ;   it under the terms of the GNU General Public License as published by
  8. ;   the Free Software Foundation, version 1.
  9. ;
  10. ;   This program is distributed in the hope that it will be useful,
  11. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ;   GNU General Public License for more details.
  14. ;
  15. ;   You should have received a copy of the GNU General Public License
  16. ;   along with this program; if not, write to the Free Software
  17. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.     include    defs.asm
  20.  
  21. code    segment word public
  22.     assume    cs:code, ds:code
  23.  
  24.     org    80h
  25. phd_dioa    label    byte
  26.  
  27.     org    100h
  28. start:
  29.     jmp    start_1
  30.  
  31. copyleft_msg    label    byte
  32.  db "Packet multicast version ",'0'+majver,".",'0'+version," copyright 1990, Russell Nelson.",CR,LF
  33.  db "This program is free software; see the file COPYING for details.",CR,LF
  34.  db "NO WARRANTY; see the file COPYING for details.",CR,LF
  35. crlf_msg    db    CR,LF,'$'
  36.  
  37. int_pkt    macro
  38.     pushf
  39.     cli
  40.     call    their_isr
  41.     endm
  42.  
  43. their_isr    dd    ?
  44. packet_int_no    db    ?,?
  45. handle        dw    ?
  46.  
  47. multi_count    dw    -1        ;default to not setting any.
  48.  
  49. signature    db    'PKT DRVR',0
  50. signature_len    equ    $-signature
  51.  
  52. no_signature_msg    db    "No packet driver at that address",'$'
  53. usage_msg    db    "usage: pktmulti <packet_int_no> [-f <filename> | <address> ...]",'$'
  54. file_not_found    db    "File not found",'$'
  55. read_trouble    db    "Trouble reading the file",'$'
  56.  
  57. line_buffer    db    128 dup(?)
  58.  
  59. usage_error:
  60.     mov    dx,offset usage_msg
  61. error:
  62.     mov    ah,9
  63.     int    21h
  64.     int    20h
  65.  
  66. start_1:
  67.     cld
  68.  
  69.     mov    dx,offset copyleft_msg
  70.     mov    ah,9
  71.     int    21h
  72.  
  73.     mov    si,offset phd_dioa+1
  74.     cmp    byte ptr [si],CR    ;end of line?
  75.     je    usage_error
  76.  
  77.     mov    di,offset packet_int_no
  78.     call    get_number
  79.  
  80.     call    skip_blanks
  81.     cmp    al,CR            ;did they just give an interrupt?
  82.     jne    have_arguments
  83.     jmp    start_noset        ;yes, don't set any addresses.
  84. have_arguments:
  85.  
  86.     mov    al,[si]            ;did the give the packet inline?
  87.     cmp    al,'-'            ;did they specify a switch?
  88.     jne    not_switch
  89.     cmp    byte ptr [si+1],'f'    ;did they specify '-f'?
  90.     jne    usage_error        ;no, must be an error.
  91.     add    si,2
  92.     call    skip_blanks
  93.     jmp    start_file
  94. not_switch:
  95.     jmp    start_inline        ;yes.
  96.  
  97. start_file:
  98.     mov    dx,si            ;remember where the filename starts.
  99. start_3:
  100.     lodsb
  101.     cmp    al,' '
  102.     je    start_4
  103.     cmp    al,CR
  104.     jne    start_3
  105. start_4:
  106.     dec    si
  107.     mov    byte ptr [si],0
  108.  
  109. ;read the packet bytes from the named file.
  110.  
  111.     mov    ax,3d00h        ;open for reading.
  112.     int    21h
  113.     mov    dx,offset file_not_found
  114.     jc    error
  115.     mov    handle,ax
  116.  
  117.     mov    di,offset our_buffer
  118. start_line:
  119.     mov    si,offset line_buffer
  120. again_line:
  121.     mov    ah,3fh            ;read a single character.
  122.     mov    bx,handle
  123.     mov    cx,1
  124.     mov    dx,si
  125.     int    21h
  126.     mov    dx,offset read_trouble
  127.     jc    error
  128.     cmp    ax,1            ;did we actually read one?
  129.     jne    start_file_eof
  130.  
  131.     lodsb                ;get the character we just read.
  132.     cmp    al,LF            ;got the LF?
  133.     jne    again_line        ;no, read again.
  134.  
  135.     mov    si,offset line_buffer
  136. again_chars:
  137.     push    ds
  138.     pop    es
  139.     call    get_eaddr
  140.     add    di,EADDR_LEN
  141.     call    skip_blanks
  142.     cmp    al,CR
  143.     jne    again_chars        ;keep going to the end.
  144.  
  145.     jmp    start_line
  146.  
  147. start_file_eof:
  148.     mov    [si],byte ptr CR    ;add an extra LF, just in case.
  149.     mov    si,offset line_buffer    ;and get the last address, just
  150.     push    ds
  151.     pop    es
  152.     call    get_eaddr        ;  in case they didn't CRLF after it.
  153. start_file_1:
  154.     mov    ah,3eh            ;close the file.
  155.     mov    bx,handle
  156.     int    21h
  157.     jmp    short start_gotit
  158.  
  159. start_inline:
  160. ;read the multicast addresses off the command line.
  161.     mov    di,offset our_buffer
  162. start_2:
  163.     push    ds
  164.     pop    es
  165.     call    get_eaddr        ;get an address.
  166.     call    skip_blanks
  167.     cmp    al,CR
  168.     jne    start_2            ;keep going to the end.
  169.  
  170. start_gotit:
  171.  
  172.     sub    di,offset our_buffer
  173.     mov    multi_count,di
  174.  
  175. start_noset:
  176.  
  177.     mov    ah,35h            ;get their packet interrupt.
  178.     mov    al,packet_int_no
  179.     int    21h
  180.     mov    their_isr.offs,bx
  181.     mov    their_isr.segm,es
  182.  
  183.     lea    di,3[bx]
  184.     mov    si,offset signature
  185.     mov    cx,signature_len
  186.     repe    cmpsb
  187.     je    signature_ok
  188.     jmp    no_signature_err
  189. signature_ok:
  190.  
  191.     push    ds
  192.     mov    ax,1ffh            ;driver_info
  193.     int_pkt
  194.     pop    ds
  195.     call    fatal_error
  196.  
  197.     mov    ah,2            ;access all packets.
  198.     mov    al,ch            ;their class from driver_info().
  199.     mov    bx,dx            ;their type from driver_info().
  200.     mov    dl,cl            ;their number from driver_info().
  201.     mov    cx,0            ;type length of zero.
  202.     push    cs            ;es:di -> our receiver.
  203.     pop    es
  204.     mov    di,offset our_recv
  205.     int_pkt
  206.     call    fatal_error
  207.     mov    handle,ax
  208.  
  209.     cmp    multi_count,-1        ;should we not set any?
  210.     je    just_print        ;yes, just print the current list.
  211.  
  212.     mov    ah,22            ;set_multicast_list
  213.     push    ds
  214.     pop    es
  215.     mov    di,offset our_buffer    ;ds:si -> buffer.
  216.     mov    cx,multi_count
  217.     int_pkt
  218.     call    print_error
  219.  
  220. just_print:
  221.     mov    ah,23            ;get_multicast_list
  222.     int_pkt
  223.     call    print_error
  224.  
  225.     push    ds
  226.     mov    ax,es
  227.     mov    ds,ax
  228.     mov    si,di
  229.     jmp    short print_countdown
  230. print_another_address:
  231.     push    cx
  232.  
  233.     call    print_ether_addr
  234.  
  235.     push    ds
  236.     mov    ax,cs
  237.     mov    ds,ax
  238.     mov    dx,offset crlf_msg
  239.     mov    ah,9
  240.     int    21h
  241.     pop    ds
  242.  
  243.     pop    cx
  244. print_countdown:
  245.     sub    cx,EADDR_LEN
  246.     jae    print_another_address
  247.  
  248.     pop    ds
  249.  
  250.     mov    ah,3            ;release the handle.
  251.     mov    bx,handle
  252.     int_pkt
  253.     call    print_error
  254.  
  255.     int    20h
  256.  
  257. no_signature_err:
  258.     mov    dx,offset no_signature_msg
  259.     mov    ah,9
  260.     int    21h
  261.     int    20h
  262.  
  263.  
  264. our_recv:
  265.     or    ax,ax            ;first or second call?
  266.     jne    our_recv_1        ;second -- we ignore the packet
  267.     push    cs
  268.     pop    es
  269.     mov    di,offset our_buffer
  270. our_recv_1:
  271.     db    0cbh            ;masm 4.0 doesn't grok "retf"
  272.  
  273.  
  274.     assume    ds:code
  275.  
  276.     include    getea.asm
  277.     include    printea.asm
  278.     include    getnum.asm
  279.     include    skipblk.asm
  280.     include    getdig.asm
  281.     include    digout.asm
  282.     include    chrout.asm
  283.     include    pkterr.asm
  284.  
  285. our_buffer    label    byte
  286.  
  287. code    ends
  288.  
  289.     end    start
  290.