; IBANPKT.ASM - Adapter provides Packet Driver interface over Banyan's VINES/IP ; ; IBANPKT (c) Copyright Daniel D. Lanciani 1992-1995 ; All rights reserved. ; ; IBANPKT is licensed free of charge for personal and internal ; business use only. IBANPKT may not be distributed for profit, ; nor may it be included in products or otherwise distributed by ; commercial entities to their clients or customers without the ; prior written permission of the author. ; ; TO THE EXTENT ALLOWED BY APPLICABLE LAW, IBANPKT IS PROVIDED ; "AS IS", WITH NO EXPRESS OR IMPLIED WARRANTY, INCLUDING, BUT ; NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND ; FITNESS FOR A PARTICULAR PURPOSE. ; ; IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL THE AUTHOR BE ; LIABLE FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL ; OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO ; USE IBANPKT EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY ; OF SUCH DAMAGES. ; ; These copyright, license, and disclaimer notices must be included ; with all copies of IBANPKT. version equ 5 ; for driver_info iftype equ 71 ; for driver_info/access_type nhand equ 8 ; max active handles mmatch equ 8 ; max length of header match pkvec equ 69h ; default control vector bsize equ 1464 ; max frame size hinfo struc ; per-handle data nmatch dw -1 ; header match length match db mmatch dup (?) ; header match bytes recvo dw ? ; receiver offset recvs dw ? ; receiver segment hinfo ends CODE segment word public 'CODE' assume cs:CODE, ds:CODE, es:nothing, ss:CODE org 100h stack label byte at100h: jmp start copyright db 'IBANPKT 1.4', 13, 10 db '(c) Copyright Daniel Lanciani 1992-1995. All rights reserved.' db 13, 10, 'This software is provided with NO WARRANTY.', 13, 10 db '$' myname db 'BANPKT', 0 ; for driver_info class db 1 ; for driver_info align 2 savpko dw 0 ; saved vector offset savpks dw 0 ; saved vector segment myvec dw 4 * pkvec ; 4 * my vector alen dw 6 ; address length off dw 12 ; header offset for match rmode dw 3 ; current receiver mode srvaddr db 6 dup (?) myaddr db 6 dup (?) magicf equ 80h sendb db 'ST@*@Servers', 0 db (bsize - 13) dup (0) sendab dw 0, 0, 0, offset sendb + 14, 0, 0+magicf dw 3, 0, 0, 0, 1400h, 15, 0, 0 dw -1, 0, 1 sendcb dw 2, offset sendab, 0, 0, 0 sendab2 dw 0, 0, 0, offset sendb + 14, 0, 0+magicf dw 3, 0, 0, 0, 1500h, 15, 0, 0 dw -1, 0, 1 recb db 1, 0 db (bsize - 2) dup (0) recab dw 0, 0, 0, offset recb + 14, bsize - 14, 5+magicf dw 3, 0, 0, 0, 0, 0, 0, 0 dw -1, 0, 1 reccb dw 3, offset recab, 0, 0, 0 recab2 dw 0, 0, 0, offset recb + 14, bsize - 14, 5+magicf dw 3, 0, 0, 0, 0, 0, 0, 0 dw -1, 0, 1 closecb dw 4, offset sendab + 4, 0, 0, 0 closecb2 dw 4, offset sendab2 + 4, 0, 0, 0 intab dw offset upcall, offset stack, -1 intcb dw 0bh, offset intab, 0, 0, 0 htab hinfo nhand dup (<>) ; the handle table htabe label byte stab dw 14 dup (0) ; for get_statistics ptab db 1, 9, 14, 6 ; for get_parameters dw 1464, 0, 0, 0, 0 upcall proc far cld cli push bp mov bp, sp mov bx, 6[bp] pop bp add stab, 1 adc stab + 2, 0 mov cx, [bx] add stab + 8, cx adc stab + 10, 0 mov si, offset myaddr mov di, offset recb mov cx, 3 rep movsw lea si, 14[bx] mov di, offset recb + 6 mov cx, 3 rep movsw mov word ptr recb + 12, 0008h cmp bx, offset recab jz @f mov word ptr recb + 12, 0608h mov word ptr recb + 14, 0100h @@: mov dx, bx add word ptr [bx], 14 cmp word ptr [bx], 60 jnc @f mov word ptr [bx], 60 @@: mov bx, offset htab recv1: mov cx, [bx].nmatch cmp cx, -1 jz recv5 jcxz recv2 mov di, offset recb add di, off lea si, [bx].match repe cmpsb jnz recv5 recv2: push bx xchg dx, bx mov cx, [bx] xchg dx, bx xor ax, ax push dx call dword ptr [bx].recvo pop dx pop bx cld cli mov ax, cs mov ds, ax mov ax, es or ax, di jz recv7 push di mov si, offset recb xchg dx, bx mov cx, [bx] xchg dx, bx push cx shr cx, 1 rep movsw jnc recv3 movsb recv3: pop cx pop si mov ax, es mov ds, ax push bx mov ax, 1 push dx call dword ptr cs:[bx].recvo pop dx pop bx cld cli mov ax, cs mov ds, ax recv5: add bx, size hinfo cmp bx, offset htabe jnc recv6 jmp recv1 recv7: cli mov ax, cs mov ds, ax add stab + 24, 1 adc stab + 26, 0 jmp short recv5 recv6: mov bx, offset reccb mov reccb + 2, dx call doban mov ax, -1 ret upcall endp doban: mov ax, 1 dobani: int 60h ret nofunc: mov dh, 11 jmp bad driver_info:pop bx mov bx, cs mov ds, bx mov bx, version mov ch, class mov dx, iftype xor cl, cl mov si, offset myname mov al, 6 jmp good1 access_type:pop bx push ds push cs pop ds cmp al, class jz access_type1 mov dh, 2 jmp short access_type5 access_type1:cmp bx, iftype jz access_type7 cmp bx, -1 jz access_type7 ; mov dh, 3 ; jmp short access_type5 access_type7:and dl, dl jz access_type2 mov dh, 4 jmp short access_type5 access_type2:cmp cx, mmatch + 1 jc access_type3 mov dh, 14 jmp short access_type5 access_type3:mov bx, offset htab access_type4:cmp [bx].nmatch, -1 jz access_type6 add bx, size hinfo cmp bx, offset htabe jc access_type4 mov dh, 9 access_type5:pop ds jmp bad1 access_type6:mov [bx].nmatch, cx mov [bx].recvo, di mov [bx].recvs, es mov di, ds mov es, di lea di, [bx].match pop ds rep movsb mov ax, bx jmp good1 release_type:pop bx push ds mov ax, cs mov ds, ax mov [bx].nmatch, -1 pop ds jmp good1 send_pkt:sti mov ax, cs mov es, ax cmp cx, bsize + 1 jc @f mov dh, 12 jmp bad @@: mov di, offset sendb push cx shr cx, 1 rep movsw jnc send_pkt1 movsb send_pkt1:pop cx push ds mov ds, ax add stab + 4, 1 adc stab + 6, 0 add stab + 12, cx adc stab + 14, 0 sub cx, 14 test sendb, 1 jz @f push cx mov si, offset srvaddr mov di, offset sendb mov cx, 3 rep movsw pop cx @@: mov bx, offset sendab cmp word ptr sendb + 12, 0608h jnz notarp mov si, offset sendb + 28 mov di, offset sendb + 38 mov cx, 4 repe cmpsb jnz @f mov word ptr sendb + 38, 0 mov word ptr sendb + 40, 0 mov si, offset srvaddr mov di, offset sendb + 32 mov cx, 3 rep movsw @@: mov bx, offset sendab2 mov word ptr sendb + 14, 0ad0bh mov cx, 28 notarp: mov 8[bx], cx mov si, offset sendb lea di, 14[bx] mov cx, 3 rep movsw mov sendcb + 2, bx mov bx, offset sendcb call doban or ax, sendcb + 4 jnz send_pkt2 pop ds jmp good send_pkt2:add stab + 20, 1 adc stab + 22, 0 pop ds mov dh, 12 jmp bad terminate:push ds mov ax, cs mov ds, ax xor ax, ax mov es, ax mov bx, myvec mov ax, savpko mov es:[bx], ax mov ax, savpks mov es:2[bx], ax mov intab, 0 mov bx, offset intcb call doban mov bx, offset closecb call doban mov bx, offset closecb2 call doban mov ax, cs mov es, ax mov ah, 49h int 21h pop ds jmp good get_address:cmp cx, cs:alen jnc get_address1 mov dh, 9 jmp bad get_address1:push ds mov ax, cs mov ds, ax mov si, offset myaddr mov cx, alen cld rep movsb mov cx, alen pop ds jmp good reset_interface:mov dh, 15 jmp bad get_parameters:mov di, cs mov es, di mov di, offset ptab jmp good set_rcv_mode:mov bx, cx dec bx cmp bx, 6 jnc set_rcv_mode1 mov cs:rmode, cx jmp good set_rcv_mode1:mov dh, 8 jmp bad get_rcv_mode:mov ax, cs:rmode jmp good get_statistics:mov si, cs mov ds, si mov si, offset stab jmp good set_address:mov dh, 13 jmp bad funcs dw nofunc dw driver_info dw access_type dw release_type dw send_pkt dw terminate dw get_address dw reset_interface dw nofunc dw nofunc dw get_parameters dw nofunc dw nofunc dw nofunc dw nofunc dw nofunc dw nofunc dw nofunc dw nofunc dw nofunc dw set_rcv_mode dw get_rcv_mode dw nofunc dw nofunc dw get_statistics dw set_address nfuncs equ ($ - offset funcs) / 2 intpk proc far jmp short dopk nop sig db 'PKT DRVR', 0 dopk: cli cld push bx cmp ah, nfuncs jc dopk1 jmp nofunc dopk1: mov bl, ah xor bh, bh shl bx, 1 jmp cs:funcs[bx] bad: pop bx bad1: stc sti ret 2 good: pop bx good1: clc sti ret 2 intpk endp start: mov ax, cs mov ds, ax cld mov dx, offset copyright mov ah, 9 int 21h mov bx, 81h call space cmp byte ptr [bx], ' ' jc start0 mov di, offset sendb snl: mov al, [bx] cmp al, '"' jnz notq snl1: inc bx mov al, [bx] cmp al, '"' jz cont cmp al, ' ' jnc @f mov dx, offset badq jmp pexit @@: stosb jmp short snl1 notq: stosb cont: inc bx cmp al, ' ' + 1 jnc snl mov byte ptr -1[di], 0 call space call number jc start0 add ax, ax add ax, ax mov myvec, ax start0: xor ax, ax mov es, ax mov bx, myvec les di, es:[bx] add di, 3 mov si, offset sig mov cx, 9 repe cmpsb jnz start1 mov dx, offset already pexit: mov ah, 9 int 21h int 20h start1: mov cx, 7 mov si, 180h start11:xor ax, ax mov ds, ax lds ax, [si] mov di, ax or di, di jz start12 sub di, 4 mov ax, [di] cmp ax, 4142h jnz start12 mov ax, 2[di] cmp ax, 564eh jz start13 start12:add si, 4 loop start11 mov ax, cs mov ds, ax mov dx, offset noban jmp short pexit start13:mov ax, cs mov ds, ax mov es, ax mov ax, si shr ax, 1 shr ax, 1 mov byte ptr dobani + 1, al mov ax, 7 mov bx, 2 mov dx, offset sendb mov di, offset recb call dobani or ax, ax jz @f mov dx, offset stfail jmp short pexit @@: cmp recb, 1 jnc @f mov dx, offset nostp jmp short pexit @@: mov si, offset recb + 5 mov di, offset srvaddr mov cx, 3 rep movsw mov bx, offset sesscb call doban mov bx, offset sockcb2 call doban or ax, sockcb2 + 4 jz @f mov dx, offset nosock2 jmp pexit @@: mov si, offset sockad2 + 2 mov di, offset myaddr mov cx, 3 rep movsw mov bx, offset sockcb call doban or ax, sockcb + 4 jz start14 mov bx, offset closecb2 call doban mov dx, offset nosock jmp pexit start14:mov ax, sendab + 4 mov recab + 4, ax mov ax, sendab2 + 4 mov recab2 + 4, ax mov intcb + 8, cs mov bx, offset intcb call doban or ax, intcb + 4 jz start15 mov bx, offset closecb call doban mov bx, offset closecb2 call doban mov dx, offset noint jmp pexit start15:mov bx, offset reccb mov reccb + 2, offset recab call doban or ax, reccb + 4 jz @f mov intab, 0 mov bx, offset intcb call doban mov bx, offset closecb call doban mov bx, offset closecb2 call doban mov dx, offset norec jmp pexit @@: mov bx, offset reccb mov reccb + 2, offset recab2 call doban or ax, reccb + 4 jz start16 mov intab, 0 mov bx, offset intcb call doban mov bx, offset closecb call doban mov bx, offset closecb2 call doban mov dx, offset norec2 jmp pexit start16:xor ax, ax mov es, ax pushf cli mov bx, myvec mov ax, es:[bx] mov savpko, ax mov ax, es:2[bx] mov savpks, ax mov es:[bx], offset intpk mov es:2[bx], cs popf mov dx, offset goodins mov ah, 9 int 21h mov es, ds:[2ch] mov ah, 49h int 21h mov word ptr ds:[2ch], 0 mov cx, 5 xor bx, bx cloop: mov ah, 3eh int 21h inc bx loop cloop mov dx, offset start int 27h number: xor ax, ax mov cx, -1 mov base, 10 cmp byte ptr [bx], '0' jnz number1 xor cx, cx mov base, 8 inc bx cmp byte ptr [bx], 'x' jz @f cmp byte ptr [bx], 'X' jnz number1 @@: mov base, 16 inc bx number1:mov dl, byte ptr [bx] cmp dl, '0' jc @f cmp dl, '9' + 1 jnc @f sub dl, '0' jmp short number2 @@: cmp dl, 'a' jc @f cmp dl, 'f' + 1 jnc @f sub dl, 'a' - 10 jmp short number2 @@: cmp dl, 'A' jc number3 cmp dl, 'F' + 1 jnc number2 sub dl, 'A' - 10 number2:xor dh, dh cmp dx, base jnc number3 xor cx, cx push dx mov dx, base mul dx pop dx add ax, dx inc bx jmp short number1 number3:add cx, 1 ret space: cmp byte ptr [bx], ' ' jz space1 cmp byte ptr [bx], 9 jz space1 ret space1: inc bx jmp short space base dw 10 badq db 'Syntax error - unclosed quote.', 13, 10, '$' already db 'A driver is already installed at this vector.', 13, 10, '$' noban db 'Vines is not loaded.', 13, 10, '$' stfail db 'Cannot locate server.', 13, 10, '$' nostp db 'Server address not found.', 13, 10, '$' nosock db 'Cannot allocate Vines IP socket.', 13, 10, '$' nosock2 db 'Cannot allocate Vines ARP socket.', 13, 10, '$' noint db 'Cannot set Vines interrupt.', 13, 10, '$' norec db 'Cannot start Vines IP receive.', 13, 10, '$' norec2 db 'Cannot start Vines ARP receive.', 13, 10, '$' goodins db 'IBANPKT is installed and ready.', 13, 10, '$' sesscb dw 8, 2, 0, 0, 0 sockad dw 3, 0, 0, 0, 1400h, 0, 0, 0 sockab dw offset sendab + 4, 3, 1, -1, offset sockad, 14h sockcb dw 1, offset sockab, 0, 0, 0 sockad2 dw 3, 0, 0, 0, 1500h, 0, 0, 0 sockab2 dw offset sendab2 + 4, 3, 1, -1, offset sockad2, 15h sockcb2 dw 1, offset sockab2, 0, 0, 0 CODE ends end at100h