From 091c18bb40aa175051917412516a007efaa4fcfb Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Wed, 29 May 2013 13:17:11 +0000 Subject: [PATCH] Delete old network programs that have been converted to work on new stack. git-svn-id: svn://kolibrios.org@3569 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/network_old/VNCclient/ETH.INC | 671 ------- programs/network_old/VNCclient/VNCclient.asm | 330 ---- programs/network_old/VNCclient/build.bat | 2 - programs/network_old/VNCclient/copyrect.inc | 5 - programs/network_old/VNCclient/fdo.inc | 343 ---- programs/network_old/VNCclient/logon.inc | 257 --- programs/network_old/VNCclient/raw.inc | 153 -- programs/network_old/VNCclient/thread.inc | 188 -- .../network_old/downloader/trunk/build.bat | 6 - .../network_old/downloader/trunk/build.sh | 13 - .../downloader/trunk/downloader.asm | 1634 ----------------- programs/network_old/zeroconf/trunk/ETH.INC | 413 ----- programs/network_old/zeroconf/trunk/build.bat | 2 - .../network_old/zeroconf/trunk/debug-fdo.inc | 422 ----- programs/network_old/zeroconf/trunk/dhcp.inc | 263 --- .../network_old/zeroconf/trunk/zeroconf.asm | 492 ----- .../network_old/zeroconf/trunk/zeroconf.ini | 9 - 17 files changed, 5203 deletions(-) delete mode 100644 programs/network_old/VNCclient/ETH.INC delete mode 100644 programs/network_old/VNCclient/VNCclient.asm delete mode 100644 programs/network_old/VNCclient/build.bat delete mode 100644 programs/network_old/VNCclient/copyrect.inc delete mode 100644 programs/network_old/VNCclient/fdo.inc delete mode 100644 programs/network_old/VNCclient/logon.inc delete mode 100644 programs/network_old/VNCclient/raw.inc delete mode 100644 programs/network_old/VNCclient/thread.inc delete mode 100644 programs/network_old/downloader/trunk/build.bat delete mode 100644 programs/network_old/downloader/trunk/build.sh delete mode 100644 programs/network_old/downloader/trunk/downloader.asm delete mode 100644 programs/network_old/zeroconf/trunk/ETH.INC delete mode 100644 programs/network_old/zeroconf/trunk/build.bat delete mode 100644 programs/network_old/zeroconf/trunk/debug-fdo.inc delete mode 100644 programs/network_old/zeroconf/trunk/dhcp.inc delete mode 100644 programs/network_old/zeroconf/trunk/zeroconf.asm delete mode 100644 programs/network_old/zeroconf/trunk/zeroconf.ini diff --git a/programs/network_old/VNCclient/ETH.INC b/programs/network_old/VNCclient/ETH.INC deleted file mode 100644 index e01c00f303..0000000000 --- a/programs/network_old/VNCclient/ETH.INC +++ /dev/null @@ -1,671 +0,0 @@ -; -; ETH.INC -; -; made by hidnplayr (hidnplayr@gmail.com) for KolibriOS -; -; The given code before every macro is only a simple example -; -; -; HISTORY -; -; v1.0: 18 august 2006 original release -; v1.1: december 2006 bugfixes and improvements -; - -macro mov arg1,arg2 { - if arg1 eq arg2 - else - mov arg1,arg2 - end if -} - -TCB_LISTEN = 1 -TCB_SYN_SENT = 2 -TCB_SYN_RECEIVED = 3 -TCB_ESTABLISHED = 4 -TCB_FIN_WAIT_1 = 5 -TCB_FIN_WAIT_2 = 6 -TCB_CLOSE_WAIT = 7 -TCB_CLOSING = 8 -TCB_LAST_ASK = 9 -TCB_TIME_WAIT = 10 -TCB_CLOSED = 11 - -PASSIVE = 0 -ACTIVE = 1 - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -; eth.get_IP eax -; -; gets the current IP that is defined in Stack (return in eax in this example) -macro eth.get_IP IP { - mov ebx,1 - mov eax,52 - mcall - - mov IP ,eax -} - -; eth.get_GATEWAY eax -; -; gets the current GATEWAY that is defined in Stack (return in eax in this example) -macro eth.get_GATEWAY GATEWAY { - mov ebx,9 - mov eax,52 - mcall - move GATEWAY ,eax -} - -; eth.get_SUBNET eax -; -; gets the current SUBNET that is defined in Stack (return in eax in this example) -macro eth.get_SUBNET SUBNET { - mov ebx,10 - mov eax,52 - mcall - mov SUBNET ,eax -} - -; eth.get_DNS eax -; -; gets the current DNS that is defined in Stack (return in eax in this example) -macro eth.get_DNS DNS { - mov ebx,13 - mov eax,52 - mcall - mov DNS ,eax -} - -; eth.set_IP eax -; -; set a new IP in stack (input in eax in this example) -macro eth.set_IP IP { - mov ecx,IP - mov ebx,3 - mov eax,52 - mcall -} - -; eth.set_GATEWAY eax -; -; set a new GATEWAY in stack (input in eax in this example) -macro eth.set_GATEWAY GATEWAY { - mov ecx,GATEWAY - mov ebx,11 - mov eax,52 - mcall -} - -; eth.set_SUBNET eax -; -; set a new SUBNET in stack (input in eax in this example) -macro eth.set_SUBNET SUBNET { - mov ecx,SUBNET - mov ebx,12 - mov eax,52 - mcall -} - -; eth.set_DNS eax -; -; set a new DNS in stack (input in eax in this example) -macro eth.set_DNS DNS { - mov ecx,DNS - mov ebx,14 - mov eax,52 - mcall -} - -; eth.open eax,80,ebx,[socket] -; -; open a socket on local port in eax to port 80 on server on ebx -; the socketnumber will be returned in [socket] (dword) -macro eth.open_udp local,remote,ip,socket { - mov ecx, local - mov edx, remote - mov esi, ip - mov ebx, 0 - mov eax, 53 - mcall - - mov socket,eax -} - -; eth.close [socket] -; -; closes socket on socketnumber [socket] -macro eth.close_udp socket { - mov ecx, socket - mov ebx, 1 - mov eax, 53 - mcall -} - -; eth.poll [socket],eax -; -; polls [socket] for data -; eax = 0 when there is data -macro eth.poll socket { - mov ecx, socket - mov ebx, 2 - mov eax, 53 - mcall -} - -; eth.read_byte [socket], bl -; -; reads a byte from the socket and returns in bl -macro eth.read_byte socket, result { - mov ecx, socket - mov ebx, 3 - mov eax, 53 - mcall - - mov result,bl -} - -; eth.read_byte [socket], bl -; -; reads a byte from the socket and returns in bl -macro eth.read_packet socket, result { - mov edx, result - mov ecx, socket - mov ebx, 10 - mov eax, 53 - mcall -} - -; eth.write [socket],12,msg -; msg db 'hello world!' -; -; send message msg to socket -macro eth.write_udp socket,length,msg,verify { - mov ecx, socket - mov edx, length - mov esi, msg - mov ebx, 4 - mov eax, 53 - mcall - - if verify eq 1 - call verifysend - end if - -} - -verifysend: - test eax,eax - jnz @f - ret -@@: - pusha - mov eax,5 - mov ebx,100 - mcall - - popa - mcall -ret - -; eth.open_tcp 80,80,eax,0,[socket] -; -; opens a tcp socket on port 80 to port 80 on IP eax with passive open -; returns socket number in eax -macro eth.open_tcp local,remote,ip,passive,socket { - - mov ecx, local - mov edx, remote - mov esi, ip - mov edi, passive ; 0 = PASSIVE open - mov ebx, 5 - mov eax, 53 - mcall - - mov socket,eax -} - -; eth.socket_status [socket],eax -; -; returns socket status in eax -macro eth.socket_status socket,result { - mov ecx, socket - mov ebx, 6 - mov eax, 53 - mcall - - mov result,eax -} - -; eth.write_tcp [socket],12,msg -; -; msg db 'hello world!' -; -; send message to TCP socket -macro eth.write_tcp socket,length,msg,verify { - mov ecx, socket - mov edx, length - mov esi, msg - mov ebx, 7 - mov eax, 53 - mcall - - if verify eq 1 - call verifysend - end if -} - -; eth.close_tcp [socket] -; -; closes tcp socket [socket] -macro eth.close_tcp socket { - mov ecx, socket - mov ebx, 8 - mov eax, 53 - mcall -} - -; eth.check_port 165,eax -; -; checks if port 165 is used -; return is 0 when port is free -macro eth.check_port port,result { - mov ecx, port - mov ebx, 9 - mov eax, 53 - mcall - - mov result,eax -} - -; eth.status eax -; -; returns socket status in eax -macro eth.status status { - mov ebx, 255 - mov ecx, 6 - mov eax, 53 - mcall - - mov status,eax -} - -; eth.search 165,edx -; -; searches a free local port starting from 166 (165 + 1 !) -; returns in edx -macro eth.search_port port,result { - mov edx,port - @@: - inc edx - eth.check_port edx,eax - cmp eax,0 - je @r - mov result,edx -} - - - -; eth.read_data [socket],buffer,512 -; buffer rb 512 -; socket dd ? -; -; reads data from socket into a buffer, stops when there is no more data or buffer is full. -macro eth.read_data socket,dest,endptr,bufferl { -local .getdata,.loop,.end - mov eax, dest - mov endptr, eax - - ; we have data - this will be the response -.getdata: - mov eax,endptr - cmp eax,bufferl - jg .end - - eth.read_byte socket,bl - - ; Store the data in the response buffer - mov eax, endptr - mov [eax], bl - inc dword endptr - - eth.poll socket - - cmp eax,0 - jne .getdata ; yes, so get it - - ; now we are going to wait 30 times 10 ms (300ms) - - mov edx,0 -.loop: - mov eax,5 - mov ebx,1 - mcall - - eth.poll socket - - cmp eax, 0 - jne .getdata ; yes, so get it - - inc edx - cmp edx,100 - jl .loop - -.end: - -} - -; eth.wait_for_data [socket],60,abort -; eth.read_data .... -; abort: -; -; Waits for data with timeout - -macro eth.wait_for_data socket,TIMEOUT,abort { - - mov edx,TIMEOUT - - @@: - eth.poll socket - - cmp eax,0 - jne @f - - dec edx - jz abort - - mov eax,5 ; wait here for event - mov ebx,10 - mcall - - jmp @r - @@: - -} - - -; The function 'resolve' resolves the address in edx and puts the resulting IP in eax. -; When the input is an IP-adress, the function will output this IP in eax. -; If something goes wrong, the result in eax should be 0 -; -; example: -; -; resolve query1,IP,PORT -; resolve '192.168.0.1',IP,PORT -; resolve query2,IP,PORT -; -; query1 db 'www.google.com',0 -; query2 db '49.78.84.45',0 -; IP dd ? -; PORT dd ? - -macro resolve query,result { - -if query eqtype 0 - mov edx,query -else - local ..string, ..label - jmp ..label - ..string db query,0 - ..label: - mov edx,..string -end if - -call __resolve - -mov result,eax - -} - -if used __resolve - -__resolve: - -if __DEBUG__ eq 1 -DEBUGF 1,'Resolving started\n' -end if - - ; This code validates if the query is an IP containing 4 numbers and 3 dots - - - push edx ; push edx (query address) onto stack - xor al, al ; make al (dot count) zero - - @@: - cmp byte[edx],'0' ; check if this byte is a number, if not jump to no_IP - jl no_IP ; - cmp byte[edx],'9' ; - jg no_IP ; - - inc edx ; the byte was a number, so lets check the next byte - - cmp byte[edx],0 ; is this byte zero? (have we reached end of query?) - jz @f ; jump to next @@ then - cmp byte[edx],':' - jz @f - - cmp byte[edx],'.' ; is this byte a dot? - jne @r ; if not, jump to previous @@ - - inc al ; the byte was a dot so increment al(dot count) - inc edx ; next byte - jmp @r ; lets check for numbers again (jump to previous @@) - - @@: ; we reach this when end of query reached - cmp al,3 ; check if there where 3 dots - jnz no_IP ; if not, jump to no_IP (this is where the DNS will take over) - - ; The following code will convert this IP into a dword and output it in eax - ; If there is also a port number specified, this will be returned in ebx, otherwise ebx is -1 - - pop esi ; edx (query address) was pushed onto stack and is now popped in esi - - xor edx, edx ; result - xor eax, eax ; current character - xor ebx, ebx ; current byte - -.outer_loop: - shl edx, 8 - add edx, ebx - xor ebx, ebx -.inner_loop: - lodsb - test eax, eax - jz .finish - cmp al, '.' - jz .outer_loop - sub eax, '0' - imul ebx, 10 - add ebx, eax - jmp .inner_loop -.finish: - shl edx, 8 - add edx, ebx - - bswap edx ; we want little endian order - mov eax, edx - - ret - - -no_IP: - - pop edx - - ; The query is not an IP address, we will send the query to a DNS server and hope for answer ;) -if __DEBUG__ eq 1 - DEBUGF 1,'The query is no ip, Building request string from:%u\n',edx -end if - - ; Build the request string - mov eax, 0x00010100 - mov [dnsMsg], eax - mov eax, 0x00000100 - mov [dnsMsg+4], eax - mov eax, 0x00000000 - mov [dnsMsg+8], eax - - ; domain name goes in at dnsMsg+12 - mov esi, dnsMsg + 12 ; location of label length - mov edi, dnsMsg + 13 ; label start - mov ecx, 12 ; total string length so far - -td002: - mov [esi], byte 0 - inc ecx - -td0021: - mov al, [edx] - - cmp al, 0 - je td001 ; we have finished the string translation - - cmp al, '.' - je td004 ; we have finished the label - - inc byte [esi] - inc ecx - mov [edi], al - inc edi - inc edx - jmp td0021 - -td004: - mov esi, edi - inc edi - inc edx - jmp td002 - - ; write label len + label text -td001: - mov [edi], byte 0 - inc ecx - inc edi - mov [edi], dword 0x01000100 - add ecx, 4 - - mov [dnsMsgLen], ecx ; We'll need the length of the message when we send it - ; Now, lets send this and wait for an answer - - eth.search_port 1024,edx ; Find a free port starting from 1025 and store in edx - eth.get_DNS esi ; Read DNS IP from stack into esi - eth.open_udp edx,53,esi,[socketNum] ; First, open socket -if __DEBUG__ eq 1 - DEBUGF 1,'Socket opened: %u (port %u)\n',[socketNum],ecx -end if - eth.write_udp [socketNum],[dnsMsgLen],dnsMsg ; Write to socket ( request DNS lookup ) -if __DEBUG__ eq 1 - DEBUGF 1,'Data written, length:%u offset:%u\n',[dnsMsgLen],dnsMsg - DEBUGF 1,'Waiting for data: (timeout is %us)\n',TIMEOUT -end if - eth.wait_for_data [socketNum],TIMEOUT,abort ; Now, we wait for data from remote - eth.read_data [socketNum],dnsMsg,[dnsMsgLen],dnsMsg+BUFFER ; Read the data into the buffer -if __DEBUG__ eq 1 - DEBUGF 1,'Data received, offset:%u buffer size:%u length:%u\n',dnsMsg,BUFFER,esi-dnsMsg -end if - eth.close_udp [socketNum] ; We're done, close the socket -if __DEBUG__ eq 1 - DEBUGF 1,'Closed Socket\n' -end if - - ; Now parse the message to get the host IP. Man, this is complicated. It's described in RFC 1035 - ; 1) Validate that we have an answer with > 0 responses - ; 2) Find the answer record with TYPE 0001 ( host IP ) - ; 3) Finally, copy the IP address to the display - ; Note: The response is in dnsMsg, the end of the buffer is pointed to by [dnsMsgLen] - - mov esi, dnsMsg - - mov al, [esi+2] ; Is this a response to my question? - and al, 0x80 - cmp al, 0x80 - jne abort -if __DEBUG__ eq 1 - DEBUGF 1,'It was a response to my question\n' -end if - - mov al, [esi+3] ; Were there any errors? - and al, 0x0F - cmp al, 0x00 - jne abort - -if __DEBUG__ eq 1 - DEBUGF 1,'There were no errors\n' -end if - - mov ax, [esi+6] ; Is there ( at least 1 ) answer? - cmp ax, 0x00 - je abort - - ; Header validated. Scan through and get my answer - add esi, 12 ; Skip to the question field - call skipName ; Skip through the question field - add esi, 4 ; skip past the questions qtype, qclass - -ctr002z: - ; Now at the answer. There may be several answers, find the right one ( TYPE = 0x0001 ) - call skipName - mov ax, [esi] - cmp ax, 0x0100 ; Is this the IP address answer? - jne ctr002c - add esi, 10 ; Yes! Point eax to the first byte of the IP address - mov eax,[esi] - - ret - - -ctr002c: ; Skip through the answer, move to the next - add esi, 8 - movzx eax, byte [esi+1] - mov ah, [esi] - add esi, eax - add esi, 2 - - cmp esi, [dnsMsgLen] ; Have we reached the end of the msg? This is an error condition, should not happen - jl ctr002z ; Check next answer - -abort: -if __DEBUG__ eq 1 - DEBUGF 1,'Something went wrong, aborting\n' -end if - xor eax,eax - - ret - - -skipName: - ; Increment esi to the first byte past the name field - ; Names may use compressed labels. Normally do. - ; RFC 1035 page 30 gives details - mov al, [esi] - cmp al, 0 - je sn_exit - and al, 0xc0 - cmp al, 0xc0 - je sn001 - - movzx eax, byte [esi] - inc eax - add esi, eax - jmp skipName - -sn001: - add esi, 2 ; A pointer is always at the end - ret - -sn_exit: - inc esi - ret - -dnsMsgLen: dd 0 -socketNum: dd 0xFFFF - -if ~defined dnsMsg -dnsMsg: rb BUFFER -end if - -end if - - - - diff --git a/programs/network_old/VNCclient/VNCclient.asm b/programs/network_old/VNCclient/VNCclient.asm deleted file mode 100644 index b1644a1649..0000000000 --- a/programs/network_old/VNCclient/VNCclient.asm +++ /dev/null @@ -1,330 +0,0 @@ -; -; -; VNC Client for kolibrios by hidnplayr -; -; -; WORK IN PROGRESS... -; -; FEEL FREE TO CONTRIBUTE ! -; -; hidnplayr@gmail.com -; - -use32 - - org 0x0 - - db 'MENUET01' ; 8 byte id - dd 0x01 ; header version - dd START ; start of code - dd I_END ; size of image - dd IM_END ; memory for app - dd IM_END ; esp - dd 0x0 , 0x0 ; I_Param , I_Icon - -__DEBUG__ equ 1 -__DEBUG_LEVEL__ equ 1 - -STRLEN = 64 ; password and server max length -xpos = 4 ; coordinates of image -ypos = 22 ; - -TIMEOUT = 60 ; timeout in seconds -BUFFER = 1500 ; Buffer size for DNS - -include '..\..\macros.inc' -include 'fdo.inc' -include 'ETH.INC' -include 'logon.inc' -include 'raw.inc' -include 'copyrect.inc' -include 'thread.inc' - -START: ; start of execution - - call red_logon - - mov eax,40 ; Report events - mov ebx,00000000b ; Only Stack - mcall - - mov eax,67 ; resize the window (hide it) - xor ebx,ebx - mov ecx,ebx - mov edx,ebx - mov esi,ebx - mcall - - mov eax,51 - mov ebx,1 - mov ecx,thread_start - mov edx,thread_stack - mcall - - DEBUGF 1,'Thread created: %u\n',eax - - @@: - mov eax,5 - mov ebx,10 - mcall - - cmp byte[thread_ready],0 - je @r - - mov eax,40 ; report events - mov ebx,100111b ; mouse, button, key, redraw - mcall - - mov eax,67 ; resize the window - mov ebx,10 - mov ecx,10 - mov edx,dword[framebuffer] - bswap edx - movzx esi,dx - shr edx,16 - add edx,2*xpos - add esi,ypos+xpos - mcall - - mainloop: - eth.socket_status [socket],eax - cmp al,TCB_CLOSE_WAIT - je close - - mov eax,23 ; wait for event with timeout - mov ebx,50 ; 0,5 s - mcall - - cmp eax,1 - je redraw - cmp eax,2 ; key - je key - cmp eax,3 ; button - je button - cmp eax,6 ; mouse - je mouse - - call drawbuffer - - jmp mainloop - - key: - DEBUGF 1,'Sending key event\n' - - mov eax,2 - mcall - mov byte[keyevent.key+3],ah - - eth.write_tcp [socket],8,keyevent - - jmp mainloop - - mouse: - DEBUGF 1,'Sending mouse event\n' - - mov eax,37 - mov ebx,1 - mcall - - sub eax,xpos*65536+ypos - bswap eax - mov word[pointerevent.x],ax - shr eax,16 - mov word[pointerevent.y],ax - - mov eax,37 - mov ebx,2 - mcall - - test al,00000010b ; test if right button was pressed (bit 1 in kolibri) - jz @f - add al,00000010b ; in RFB protocol it is bit 2, so if we add bit 2 again, we'll get bit 3 and bit 1 will remain the same - @@: - - mov byte[pointerevent.mask],al - - eth.write_tcp [socket],6,pointerevent - - jmp mainloop - - redraw: - - DEBUGF 1,'Drawing window\n' - - mcall 12, 1 - - mov eax,0 ; draw window - mov ebx,dword[framebuffer] - bswap ebx - movzx ecx,bx - shr ebx,16 - add ebx,2*xpos - add ecx,ypos+xpos - mov edx,0xffffff - mcall - - mov eax,4 ; label - mov ebx,9*65536+8 - mov ecx,0x10ffffff - mov edx,name - mov esi,[name_length] - bswap esi - mcall - - call drawbuffer - - mcall 12, 2 - - jmp mainloop - - drawbuffer: - - mov eax,7 - mov ebx,framebuffer_data - mov ecx,dword[screen] - mov edx,xpos*65536+ypos - mcall - - ret - - - button: ; button - mov eax,17 ; get id - mcall - - close: - call read_data -; eth.close_tcp [socket] ; We're done, close the socket ;;; BUG WHEN CLOSING SOCKET !! - DEBUGF 1,'Socket closed\n' - - mov eax,-1 - mcall - - no_rfb: - DEBUGF 1,'This is no vnc server!\n' - jmp close - - invalid_security: - DEBUGF 1,'Security error: %s\n',receive_buffer+5 - jmp close - - -; DATA AREA - -include_debug_strings ; ALWAYS present in data section - -handshake db 'RFB 003.003',0x0a -shared db 0 -beep db 0x85,0x25,0x85,0x40,0 - -pixel_format32 db 0 ; setPixelformat - rb 3 ; padding -.bpp db 32 ; bits per pixel -.depth db 32 ; depth -.big_endian db 0 ; big-endian flag -.true_color db 1 ; true-colour flag -.red_max db 0,255 ; red-max -.green_max db 0,255 ; green-max -.blue_max db 0,255 ; blue-max -.red_shif db 0 ; red-shift -.green_shift db 8 ; green-shift -.blue_shift db 16 ; blue-shift - rb 3 ; padding - -pixel_format16 db 0 ; setPixelformat - rb 3 ; padding -.bpp db 16 ; bits per pixel -.depth db 15 ; depth -.big_endian db 0 ; big-endian flag -.true_color db 1 ; true-colour flag -.red_max db 0,31 ; red-max -.green_max db 0,31 ; green-max -.blue_max db 0,31 ; blue-max -.red_shif db 0 ; red-shift -.green_shift db 5 ; green-shift -.blue_shift db 10 ; blue-shift - rb 3 ; padding - -pixel_format8 db 0 ; setPixelformat - rb 3 ; padding -.bpp db 8 ; bits per pixel -.depth db 6 ; depth -.big_endian db 0 ; big-endian flag -.true_color db 1 ; true-colour flag -.red_max db 0,3 ; red-max -.green_max db 0,3 ; green-max -.blue_max db 0,3 ; blue-max -.red_shif db 0 ; red-shift -.green_shift db 2 ; green-shift -.blue_shift db 4 ; blue-shift - rb 3 ; padding - -encodings db 2 ; setEncodings - rb 1 ; padding - db 1,0 ; number of encodings - db 0,0,0,0 ; raw encoding (DWORD, Big endian order) - db 1,0,0,0 ; Copyrect encoding - -fbur db 3 ; frame buffer update request -.inc db 0 ; incremental -.x dw 0 -.y dw 0 -.width dw 0 -.height dw 0 - -keyevent db 4 ; keyevent -.down db 0 ; down-flag - dw 0 ; padding -.key dd 0 ; key - -pointerevent db 5 ; pointerevent -.mask db 0 ; button-mask -.x dw 0 ; x-position -.y dw 0 ; y-position - -I_END: - -framebuffer: -.width dw ? -.height dw ? -pixelformat: -.bpp db ? -.depth db ? -.big_endian db ? -.true_color db ? -.red_max dw ? -.green_max dw ? -.blue_max dw ? -.red_shift db ? -.green_shift db ? -.blue_shift db ? -.padding rb 3 -name_length dd ? -name rb 256 - -server_ip dd 0 -server_port dd 0 -socket dd 0 -datapointer dd 0 - -frame: -.width dw 0 -.height dw 0 -.x dw 0 -.y dw 0 - -screen: -.height dw 0 -.width dw 0 - -thread_ready db 0 - -dnsMsg: -receive_buffer rb 5*1024*1024 ; 5 mb buffer for received data (incoming frbupdate etc) -framebuffer_data rb 1024*768*3 ; framebuffer - -thread_stack rb 0x1000 - -IM_END: - - diff --git a/programs/network_old/VNCclient/build.bat b/programs/network_old/VNCclient/build.bat deleted file mode 100644 index 15ee691db2..0000000000 --- a/programs/network_old/VNCclient/build.bat +++ /dev/null @@ -1,2 +0,0 @@ -@fasm VNCclient.asm VNCclient -@pause \ No newline at end of file diff --git a/programs/network_old/VNCclient/copyrect.inc b/programs/network_old/VNCclient/copyrect.inc deleted file mode 100644 index d24878b3c6..0000000000 --- a/programs/network_old/VNCclient/copyrect.inc +++ /dev/null @@ -1,5 +0,0 @@ - encoding_copyrect: - DEBUGF 1,'FRAME: copyrect\n' - - - jmp next_rectangle \ No newline at end of file diff --git a/programs/network_old/VNCclient/fdo.inc b/programs/network_old/VNCclient/fdo.inc deleted file mode 100644 index 487a336cbd..0000000000 --- a/programs/network_old/VNCclient/fdo.inc +++ /dev/null @@ -1,343 +0,0 @@ -; -; Formatted Debug Output (FDO) -; Copyright (c) 2005-2006, mike.dld -; Created: 2005-01-29, Changed: 2006-07-20 -; -; For questions and bug reports, mail to mike.dld@gmail.com -; -; Available format specifiers are: %s, %d, %u, %x (with partial width support) -; - -; to be defined: -; __DEBUG__ equ 1 -; __DEBUG_LEVEL__ equ 5 - -macro debug_func name { - if used name - name@of@func equ name -} - -macro debug_beginf { - align 4 - name@of@func: -} - -debug_endf fix end if - -macro DEBUGS _sign,[_str] { - common - pushf - pushad - local ..str,..label,is_str - is_str = 0 - forward - if _str eqtype '' - is_str = 1 - end if - common - if is_str = 1 - jmp ..label - ..str db _str,0 - ..label: - add esp,4*8+4 - mov edx,..str - sub esp,4*8+4 - call fdo_debug_outstr - else - mov edx,_str - call fdo_debug_outstr - end if - popad - popf -} - -macro DEBUGD _sign,_dec { - pushf - pushad - if _dec eqtype eax - if _dec in - mov eax,_dec - else if ~_dec eq eax - if _sign = 1 - movsx eax,_dec - else - movzx eax,_dec - end if - end if - else if _dec eqtype 0 - mov eax,_dec - else - add esp,4*8+4 - local tp - tp equ 0 - match _num[_arg],_dec \{ - if _num = 1 - if _sign = 1 - movsx eax,byte[_arg] - else - movzx eax,byte[_arg] - end if - else if _num = 2 - if _sign = 1 - movsx eax,word[_arg] - else - movzx eax,word[_arg] - end if - else - mov eax,dword[_arg] - end if - tp equ 1 - \} - match =0 [_arg],tp _dec \{ - mov eax,dword[_arg] - \} - sub esp,4*8+4 - end if - mov cl,_sign - call fdo_debug_outdec - popad - popf -} - -macro DEBUGH _sign,_hex { - pushf - pushad - if _hex eqtype eax - if _hex in - if ~_hex eq eax - mov eax,_hex - end if - mov edx,8 - else if _hex in - if ~_hex eq ax - movzx eax,_hex - end if - shl eax,16 - mov edx,4 - else if _hex in - if ~_hex eq al - movzx eax,_hex - end if - shl eax,24 - mov edx,2 - end if - else if _hex eqtype 0 - mov eax,_hex - mov edx,8 - else - add esp,4*8+4 - local tp - tp equ 0 - match _num[_arg],_hex \{ - mov eax,dword[_arg] - mov edx,_num - tp equ 1 - \} - match =0 [_arg],tp _hex \{ - mov eax,dword[_arg] - mov edx,8 - \} - sub esp,4*8+4 - end if - call fdo_debug_outhex - popad - popf -} - -;----------------------------------------------------------------------------- - -debug_func fdo_debug_outchar -debug_beginf - pushad - mov cl,al - mov ebx,1 - mov eax,63 - mcall - popad - ret -debug_endf - -debug_func fdo_debug_outstr -debug_beginf - mov eax,63 - mov ebx,1 - .l1: mov cl,[edx] - or cl,cl - jz .l2 - mcall - inc edx - jmp .l1 - .l2: ret -debug_endf - -debug_func fdo_debug_outdec -debug_beginf - or cl,cl - jz @f - or eax,eax - jns @f - neg eax - push eax - mov al,'-' - call fdo_debug_outchar - pop eax - @@: push 10 - pop ecx - push -'0' - .l1: xor edx,edx - div ecx - push edx - test eax,eax - jnz .l1 - .l2: pop eax - add al,'0' - jz .l3 - call fdo_debug_outchar - jmp .l2 - .l3: ret -debug_endf - -debug_func fdo_debug_outhex - __fdo_hexdigits db '0123456789ABCDEF' -debug_beginf - mov cl,dl - neg cl - add cl,8 - shl cl,2 - rol eax,cl - .l1: rol eax,4 - push eax - and eax,0x0000000F - mov al,[__fdo_hexdigits+eax] - call fdo_debug_outchar - pop eax - dec edx - jnz .l1 - ret -debug_endf - -;----------------------------------------------------------------------------- - -macro DEBUGF _level,_format,[_arg] { - common - if __DEBUG__ = 1 & _level >= __DEBUG_LEVEL__ - local ..f1,f2,a1,a2,c1,c2,c3,..lbl - _debug_str_ equ __debug_str_ # a1 - a1 = 0 - c2 = 0 - c3 = 0 - f2 = 0 - repeat ..lbl-..f1 - virtual at 0 - db _format,0,0 - load c1 word from %-1 - end virtual - if c1 = '%s' - virtual at 0 - db _format,0,0 - store word 0 at %-1 - load c1 from f2-c2 - end virtual - if c1 <> 0 - DEBUGS 0,_debug_str_+f2-c2 - end if - c2 = c2 + 1 - f2 = %+1 - DEBUGF_HELPER S,a1,0,_arg - else if c1 = '%x' - virtual at 0 - db _format,0,0 - store word 0 at %-1 - load c1 from f2-c2 - end virtual - if c1 <> 0 - DEBUGS 0,_debug_str_+f2-c2 - end if - c2 = c2 + 1 - f2 = %+1 - DEBUGF_HELPER H,a1,0,_arg - else if c1 = '%d' | c1 = '%u' - local c4 - if c1 = '%d' - c4 = 1 - else - c4 = 0 - end if - virtual at 0 - db _format,0,0 - store word 0 at %-1 - load c1 from f2-c2 - end virtual - if c1 <> 0 - DEBUGS 0,_debug_str_+f2-c2 - end if - c2 = c2 + 1 - f2 = %+1 - DEBUGF_HELPER D,a1,c4,_arg - else if c1 = '\n' - c3 = c3 + 1 - end if - end repeat - virtual at 0 - db _format,0,0 - load c1 from f2-c2 - end virtual - if (c1<>0)&(f2<>..lbl-..f1-1) - DEBUGS 0,_debug_str_+f2-c2 - end if - virtual at 0 - ..f1 db _format,0 - ..lbl: - __debug_strings equ __debug_strings,_debug_str_,<_format>,..lbl-..f1-1-c2-c3 - end virtual - end if -} - -macro __include_debug_strings dummy,[_id,_fmt,_len] { - common - local c1,a1,a2 - forward - if defined _len & ~_len eq - _id: - a1 = 0 - a2 = 0 - repeat _len - virtual at 0 - db _fmt,0,0 - load c1 word from %+a2-1 - end virtual - if (c1='%s')|(c1='%x')|(c1='%d')|(c1='%u') - db 0 - a2 = a2 + 1 - else if (c1='\n') - dw $0A0D - a1 = a1 + 1 - a2 = a2 + 1 - else - db c1 and 0x0FF - end if - end repeat - db 0 - end if -} - -macro DEBUGF_HELPER _letter,_num,_sign,[_arg] { - common - local num - num = 0 - forward - if num = _num - DEBUG#_letter _sign,_arg - end if - num = num+1 - common - _num = _num+1 -} - -macro include_debug_strings { - if __DEBUG__ = 1 - match dbg_str,__debug_strings \{ - __include_debug_strings dbg_str - \} - end if -} diff --git a/programs/network_old/VNCclient/logon.inc b/programs/network_old/VNCclient/logon.inc deleted file mode 100644 index d2c7c9a904..0000000000 --- a/programs/network_old/VNCclient/logon.inc +++ /dev/null @@ -1,257 +0,0 @@ -red_logon: - call draw_window_logon ; at first, draw the window - -still_logon: ; main cycle of application begins here - mov eax,10 ; wait here for event - mcall - -checkevent_logon: ; Check what event was called _logon: this will be used to return from textbox focus - - dec eax ; redraw request ? - jz red_logon - dec eax ; key in buffer ? - jz key_logon - dec eax ; button in buffer ? - jz button_logon - - jmp still_logon - - key_logon: ; key event handler - mov al,2 ; eax was zero so will now be 2 - mcall ; just read it and ignore - - cmp ah,13 - jne still_logon ; return to main loop - - ret ; enter key was pressed => return to logon - - button_logon: ; eax was zero so will now be 17 - mov al,17 ; get id - mcall - - cmp ah,1 ; close ? - jz close_logon - cmp ah,2 ; logon ? - je connect_logon - cmp ah,5 ; first ? - jz dstbtn_logon - - srcbtn_logon: - mov dword[addr],first - jmp rk_logon - - dstbtn_logon: - mov dword[addr],second - - rk_logon: - mov edi,[addr] ; load the address of the string - xor al,al ; mov al,0 ; the symbol we will search for - mov ecx,STRLEN+1 ; length of the string (+1) - cld ; search forward - repne scasb ; do search now - inc ecx ; we've found a zero or ecx became 0 - mov eax,STRLEN+1 - sub eax,ecx ; eax = address of <0> character - mov [temp],eax ; position - - cmp dword[addr],dword second - jne @f - mov dword [passlen],eax - @@: - - call print_text_logon - - mov edi,[addr] ; address of string - add edi,[temp] ; cursor position - - .waitev_logon: - mov eax,10 ; wait for event - mcall - cmp eax,2 ; button presed ? - jne checkevent_logon ; a key is pressed or redraw is nessesary, goto checkevent - mcall ; eax = 2, read button - shr eax,8 - cmp eax,8 - jnz .nobs_logon ; BACKSPACE - cmp edi,[addr] - jz .waitev_logon - dec edi - mov byte[edi],0 - - cmp dword[addr],second - jne @f - dec [passlen] - @@: - - call print_text_logon - jmp .waitev_logon - .nobs_logon: - cmp eax,13 ; ENTER - je still_logon - cmp eax,192 - jne .noclear_logon - xor al,al - mov edi,[addr] - mov ecx,STRLEN - rep stosb - mov edi,[addr] - call print_text_logon - jmp .waitev_logon - - .noclear_logon: - mov [edi],al - - cmp dword[addr],second - jne @f - inc [passlen] - @@: - - call print_text_logon - - inc edi - mov esi,[addr] - add esi,STRLEN - cmp esi,edi - jnz .waitev_logon - - jmp still_logon - - -; print strings (source & destination) -print_text_logon: -pusha - - mov eax, 8 - mov ebx, 105*65536+200 - mov ecx, 31*65536+13 - mov edx, 4 - mov esi, 0xEBEBEB - mcall - - cmp byte[mode],0 - je @f - - mov ecx, 49*65536+12 - inc edx - mcall - - @@: - mov eax, 4 ; function 4 _logon: write text to window - mov ebx, 107*65536+34 ; [x start] *65536 + [y start] - xor ecx, ecx ; color of text RRGGBB - mov edx, first ; pointer to text beginning - mov esi, STRLEN ; text length - mcall - - cmp byte[mode],0 - je dont_draw_pass - - add ebx,16 - mov edi,[passlen] - - @@: - cmp edi,0 - jle dont_draw_pass - - dec edi - mov edx, passchar - mov esi, 1 - mcall - add ebx,6*65536 - jmp @r - - dont_draw_pass: - -popa - ret - -close_logon: - or eax,-1 - mcall - -connect_logon: - ret - -draw_window_logon: - - mcall 12, 1 ; start window draw - pusha - ; DRAW WINDOW - xor eax, eax ; function 0 _logon: define and draw window - mov ebx, 160*65536+330 ; [x start] *65536 + [x size] - mov ecx, 160*65536+100 ; [y start] *65536 + [y size] - mov edx, 0x13DDDDDD ; color of work area RRGGBB - mov edi, title ; WINDOW LABEL - mcall - - mov eax, 8 ; LOGON BUTTON - mov ebx, 220*65536+85 - mov ecx, 63*65536+16 - mov edx, 2 - mov esi, 0xCCCCCC - mcall - - - call print_text_logon - - cmp byte[mode], 0 - je servermode_ - - mov eax, 4 ; function 4 write text to window - mov ebx, 25*65536+33 ; [x start] *65536 + [y start] - xor ecx, ecx - mov edx, userstr ; pointer to text beginning - mov esi, passstr-userstr ; text length - mcall - - add bl,19 - mov edx, passstr ; pointer to text beginning - mov esi, connect-passstr ; text length - mcall - - jmp drawtherest_ - - servermode_: - - mov eax, 4 ; function 4 write text to window - mov ebx, 25*65536+33 ; [x start] *65536 + [y start] - xor ecx, ecx - mov edx, serverstr ; pointer to text beginning - mov esi, userstr-serverstr ; text length - mcall - - drawtherest_: - - mov ebx, 240*65536+67 ; [x start] *65536 + [y start] - mov edx, connect ; pointer to text beginning - mov esi, connect_e-connect ; text length - mcall - - popa - inc ebx - mcall - - ret - - -; DATA AREA -title db 'Kolibrios VNC client by HIDNPLAYR',0 - -first: db '192.168.1.5' - rb STRLEN -second: rb STRLEN - -passchar db '*' -passlen dd 0 - -addr dd 0 -temp dd 0 -mode db 0 ; 0 = connection details, 1 = authentication - -serverstr: db 'server:' -userstr: db 'username:' -passstr: db 'password:' -connect: db 'connect !' -connect_e: - -I_END_logon: diff --git a/programs/network_old/VNCclient/raw.inc b/programs/network_old/VNCclient/raw.inc deleted file mode 100644 index 9ba6d6e0a8..0000000000 --- a/programs/network_old/VNCclient/raw.inc +++ /dev/null @@ -1,153 +0,0 @@ - encoding_raw: - DEBUGF 1,'RAW\n' - - mov ax,[frame.y] ; - mov bx,[screen.width] ; - mul bx ; - shl edx,16 ; - mov dx,ax ; [screen.width]*[frame.y] - movzx eax,[frame.x] - add edx,eax ; [screen.width]*[frame.y]+[frame.x] - - mov eax,3 ; - mul edx ; ([screen.width]*[frame.y]+[frame.x])*3 - - add eax,framebuffer_data ; - push eax ; framebuffer_data+([screen.width]*[frame.y]+[frame.x])*3 - - mov ax,[frame.width] ; - mov bx,3 ; - mul bx ; - shl edx,16 ; - mov dx,ax ; [frame.width]*3 - - pop eax ; - add edx,eax ; framebuffer_data+([screen.width]*[frame.y]+[frame.x])*3+[frame.width]*3 - push eax ; - push edx ; - - mov ax,[frame.height] ; - dec ax ; - mov bx,3 ; - mul bx ; - mov bx,[screen.width] ; - mul bx ; - shl edx,16 ; - mov dx,ax ; - mov ecx,edx ; - pop edx ; - add ecx,edx ; mov ecx,edx+([frame.height]-1)*[screen.width]*3 - pop ebx - - .pixelloop32: - cmp ebx,ecx - jge next_rectangle - -; add esi,2 ; 32 bit code RAW - OK -; mov al,[esi] ; -; mov [ebx],al ; -; inc ebx ; -; dec esi ; -; ; -; mov al,[esi] ; -; mov [ebx],al ; -; inc ebx ; -; dec esi ; -; ; -; mov al,[esi] ; -; mov [ebx],al ; -; inc ebx ; -; add esi,4 ; - -; push ecx ; 16 bit code RAW -; mov cl,51 -; -; mov ax,[esi] ; -; xchg al,ah -; and al,00011111b ; -; xchg al,ah -; mul cl -; mov [ebx],al ; -; inc ebx ; -; -; mov ax,[esi] ; -; xchg al,ah -; shr ax,5 ; -; xchg al,ah -; and al,00011111b ; -; mul cl -; mov [ebx],al ; -; inc ebx ; -; -; mov ax,[esi] ; -; xchg al,ah -; shr ax,10 ; -; and al,00011111b ; -; mul cl -; mov [ebx],al ; -; inc ebx ; -; -; inc esi ; -; inc esi ; -; pop ecx - - push ecx ; 8 bit code RAW - OK - mov cl,85 ; - ; - mov al,[esi] ; - shr al,4 ; - and al,3 ; - mul cl ; - mov [ebx],al ; - inc ebx ; - ; - mov al,[esi] ; - shr al,2 ; - and al,3 ; - mul cl ; - mov [ebx],al ; - inc ebx ; - ; - mov al,[esi] ; - and al,3 ; - mul cl ; - mov byte[ebx],al ; - inc ebx ; - inc esi ; - pop ecx ; - - - cmp ebx,edx - jl .pixelloop32 - - push edx - push ebx - mov ax,[screen.width] - mov bx,3 - mul bx - shl edx,16 - mov dx,ax - mov eax,edx - pop ebx - pop edx - - add ebx,eax ; eax = [screen.width]*3 - add edx,eax - - push edx - push ebx - mov ax,[frame.width] - mov bx,3 - mul bx - shl edx,16 - mov dx,ax - mov eax,edx - pop ebx - pop edx - - sub ebx,eax ; eax = [frame.width]*3 - - jmp .pixelloop32 - - - diff --git a/programs/network_old/VNCclient/thread.inc b/programs/network_old/VNCclient/thread.inc deleted file mode 100644 index 8995e599bd..0000000000 --- a/programs/network_old/VNCclient/thread.inc +++ /dev/null @@ -1,188 +0,0 @@ - thread_start: - DEBUGF 1,'I am the thread!\n' - - mov eax,40 ; Report events - mov ebx,10000000b ; Only Stack - mcall - - resolve first,[server_ip] ; the input window putted the server @ 'first', resolve it into a real ip - mov [server_port],5900 ; no port input for now, only standard port 5900 - - DEBUGF 1,'connecting to %u.%u.%u.%u:%u\n',1[server_ip],1[server_ip+1],1[server_ip+2],1[server_ip+3],4[server_port] - eth.search_port 1000,edx ; Find a free port starting from 1001 and store in edx - eth.open_tcp edx,[server_port],[server_ip],1,[socket] ; open socket - DEBUGF 1,'Socket opened: %u (port %u)\n',[socket],ecx - - call read_data - cmp dword[receive_buffer+1],'RFB ' - jne no_rfb - eth.write_tcp [socket],12,handshake - DEBUGF 1,'Sending handshake: protocol version\n' - - call read_data - mov eax,receive_buffer+1 - mov eax,[eax] - bswap eax - cmp eax,0 - je invalid_security - cmp eax,1 - je no_security - cmp eax,2 - je vnc_security - - jmp close - - vnc_security: - mov byte[mode],1 - call red_logon - - no_security: - eth.write_tcp [socket],1,shared - DEBUGF 1,'Sending handshake: shared session?\n' - - eth.wait_for_data [socket],TIMEOUT*10,close - eth.read_data [socket],framebuffer,[datapointer],IM_END-receive_buffer ; now the server should send init message - DEBUGF 1,'Serverinit: bpp:%u depth:%u bigendian:%u truecolor:%u\n',1[pixelformat.bpp],1[pixelformat.depth],1[pixelformat.big_endian],1[pixelformat.true_color] - mov eax,dword[framebuffer] - bswap eax - mov dword[screen],eax - - eth.write_tcp [socket],20,pixel_format8 - DEBUGF 1,'Sending pixel format\n' - call read_data - -; eth.write_tcp [socket],8,encodings -; DEBUGF 1,'Sending encoding info\n' -; call read_data - - mov eax,dword[framebuffer.width] - mov dword[fbur.width],eax - - mov byte[thread_ready],1 - - request_rfb: - mov byte[fbur.inc],2 ;;;;;;;; - eth.write_tcp [socket],10,fbur ;;;;;;;;; - - thread_loop: - eth.wait_for_data [socket],1000,thread_loop - - call read_data ; Read the data into the buffer - - mov eax,[datapointer] ; at least 2 bytes should be received - sub eax,receive_buffer - cmp eax,1 - jle mainloop - - DEBUGF 1,'Data received, %u bytes\n',eax - - cmp byte[receive_buffer],0 - je framebufferupdate - - cmp byte[receive_buffer],1 - je setcolourmapentries - - cmp byte[receive_buffer],2 - je bell - - cmp byte[receive_buffer],3 - je servercuttext - - jmp thread_loop - - - framebufferupdate: - mov ax,word[receive_buffer+2] - xchg al,ah - mov di,ax - DEBUGF 1,'Framebufferupdate: %u frames\n',di - mov esi,receive_buffer+4 - jmp rectangle_loop - - next_rectangle: - call drawbuffer - - dec di - test di,di - jz request_rfb - - rectangle_loop: - mov edx,[esi] - bswap edx - mov ebx,edx - shr edx,16 - mov [frame.x],dx - mov [frame.y],bx - add esi,4 - mov ecx,[esi] - bswap ecx - mov eax,ecx - shr ecx,16 - mov [frame.width],cx - mov [frame.height],ax - add esi,4 - mov eax,[esi] - add esi,4 - - mov ebx,esi - sub ebx,receive_buffer+12 - DEBUGF 1,'frame: width=%u height=%u x=%u y=%u offset:%u encoding:',2[frame.width],2[frame.height],2[frame.x],2[frame.y],ebx - - cmp eax,0 - je encoding_raw - cmp eax,1 - je encoding_copyrect - cmp eax,2 - je encoding_RRE - cmp eax,5 - je encoding_hextile - cmp eax,16 - je encoding_ZRLE - - mov ebx,esi - sub ebx,receive_buffer+8 - DEBUGF 1,'\nunknown encoding: %u (offset %u)\n',eax,ebx - jmp bell - jmp thread_loop - - encoding_RRE: - DEBUGF 1,'RRE\n' - - jmp next_rectangle - - encoding_hextile: - DEBUGF 1,'hextile\n' - - jmp next_rectangle - - encoding_ZRLE: - DEBUGF 1,'ZRLE\n' - - jmp next_rectangle - - - setcolourmapentries: - DEBUGF 1,'Server sended SetColourMapEntries message\n' - - jmp thread_loop - - - bell: - mov eax,55 - mov ebx,eax - mov esi,beep - mcall - - jmp thread_loop - - - servercuttext: - DEBUGF 1,'Server cut text\n' - - jmp thread_loop - - - -read_data: - eth.read_data [socket],receive_buffer,[datapointer],IM_END-receive_buffer -ret \ No newline at end of file diff --git a/programs/network_old/downloader/trunk/build.bat b/programs/network_old/downloader/trunk/build.bat deleted file mode 100644 index 0e7bd76be4..0000000000 --- a/programs/network_old/downloader/trunk/build.bat +++ /dev/null @@ -1,6 +0,0 @@ -@erase lang.inc -@echo lang fix ru >lang.inc -@fasm downloader.asm downloader -@kpack downloader -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/downloader/trunk/build.sh b/programs/network_old/downloader/trunk/build.sh deleted file mode 100644 index b08e7ab319..0000000000 --- a/programs/network_old/downloader/trunk/build.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# This script does for linux the same as build.bat for DOS, -# it compiles the KoOS kernel, hopefully ;-) - - echo "lang fix ru" - echo "lang fix ru" > lang.inc - fasm -m 16384 downloader.asm downloader - rm -f lang.inc - exit 0 - - - - diff --git a/programs/network_old/downloader/trunk/downloader.asm b/programs/network_old/downloader/trunk/downloader.asm deleted file mode 100644 index 3140932776..0000000000 --- a/programs/network_old/downloader/trunk/downloader.asm +++ /dev/null @@ -1,1634 +0,0 @@ -; version: 0.6 - 0.62 -; last update: 04/06/2012 -; written by: Lipatov Kirill aka Leency -; changes: removed old code -; added edit_box -; using system colors -; indicates file saving -; download by pressing Enter -;----------------------------------------------------------- -; version: 0.5 -; date: 07/10/2010 -; written by: Marat Zakiyanov aka Mario79, aka Mario -; changes: reducing the size of the binary code, -; program uses far less memory while running -; (>0x7000, the old version used >0x100000), -; process only net event at start with parameter -;----------------------------------------------------------- -; version: 0.3 -0.4 -; written by: CleverMouse -; -;----------------------------------------------------------- -; wget 0.2 by barsuk -; based on Menuet Httpc - - -;TODO -;downloading status indication in window - - -; Enabling debugging puts stuff to the debug board -DEBUGGING_ENABLED equ 1 -DEBUGGING_DISABLED equ 0 -DEBUGGING_STATE equ DEBUGGING_ENABLED - -use32 - org 0x0 - db 'MENUET01' ; header - dd 0x01 ; header version - dd START ; entry point - dd IM_END ; image size - dd I_END ;0x100000 ; required memory - dd stacktop ; esp - dd params ; I_PARAM - dd 0x0 ; I_Path - -include 'lang.inc' -include '../../../macros.inc' -include '../../../proc32.inc' -include '../../../develop/libraries/box_lib/load_lib.mac' -include '../../../develop/libraries/box_lib/trunk/box_lib.mac' -include '../../../dll.inc' -include '../../../debug.inc' - -URLMAXLEN equ 256 ; maximum length of url string - -primary_buffer_size equ 4096 - -sc system_colors - -@use_library - -; Memory usage -; webpage headers at buf_headers - -START: ; start of execution -;dps <"Program started",13,10> -; prepare webAddr area - load_libraries l_libs_start,l_libs_end - mov ebp,lib_0 - cmp dword [ebp+ll_struc_size-4],0 - jz @f - mcall -1 ;exit not correct - @@: - - mov al,' ' - mov edi,webAddr - mov ecx,URLMAXLEN - cld - rep stosb - xor eax,eax - stosb -; prepare document area - mov al,'/' - mov edi,document - cld - stosb - mov al,' ' - mov ecx,URLMAXLEN-1 - rep stosb - -; create local heap - mcall 68,11 - - call load_settings - cmp [params],byte 0 - jz prepare_event ;red - - - mcall 40, 10000000b ; only net event!!! - -; we have an url - mov edi,document_user - mov al,' ' - mov ecx,URLMAXLEN - rep stosb - - mov esi,params - mov edi,document_user - -.copy_param: - mov al,[esi] - cmp al,0 - jz .done - - cmp al,' ' - jz .done_inc - - mov [edi],al - inc esi - inc edi - jmp .copy_param - -.done_inc: -; url is followed by shared memory name. - inc esi -.done: - mov [shared_name],esi - - mov ah,22 ; strange way to tell that socket should be opened... - call socket_commands - - jmp still - -prepare_event: -; Report events -; Stack 8 + defaults - mcall 40,10100111b - -red: ; redraw - call draw_window - -still: - mcall 23,1 ; wait here for event - cmp eax,1 ; redraw request ? - je red - - cmp eax,2 ; key in buffer ? - je key - - cmp eax,3 ; button in buffer ? - je button - - cmp eax,6 ; mouse in buffer ? - je mouse - - -; Get the web page data from the remote server - call read_incoming_data - mov eax,[status] - mov [prev_status],eax - mcall 53,6,[socket] - mov [status],eax - - cmp [prev_status],4 - jge no_send - - cmp [status],4 - jne no_send - - mov [onoff],1 - call send_request - -no_send: - call print_status - - cmp [prev_status],4 - jne no_close - cmp [status],4 ; connection closed by server - jbe no_close ; respond to connection close command -; draw page - call read_incoming_data - mcall 53,8,[socket] - mov [onoff],0 - -no_close: - jmp still - -key: - mcall 2 ; read key - - stdcall [edit_box_key], dword edit1 - - shr eax,8 - cmp eax,13 - je retkey - - jmp still - - -button: - - mcall 17 ; get id - cmp ah,26 - je save - cmp ah,1 ; button id=1 ? - jne noclose -; dps "Closing socket before exit... " - -close_end_exit: - -;dpd eax -;dps <13,10> - -exit: - or eax,-1 ; close this program - mcall - -mouse: - stdcall [edit_box_mouse], edit1 - jmp still - -save: -dps "file saved" -newline - mcall 70,fileinfo - - mov ecx,[sc.work_text] - or ecx,80000000h - mcall 4,<10,93>,,download_complete - - ;pregs - jmp still - -noclose: - cmp ah,31 - jne noup - sub [display_from],20 - jmp still - -noup: - cmp ah,32 - jne nourl - add [display_from],20 - jmp still - - -retkey: - mov ah,22 ; start load - -nourl: - call socket_commands ; opens or closes the connection - jmp still - -;**************************************************************************** -; Function -; send_request -; -; Description -; Transmits the GET request to the server. -; This is done as GET then URL then HTTP/1.1',13,10,13,10 in 3 packets -; -;**************************************************************************** -send_request: - pusha - mov esi,string0 - mov edi,request - movsd -; If proxy is used, make absolute URI - prepend http:// - cmp [proxyAddr],byte 0 - jz .noproxy - mov dword [edi],'http' - mov [edi+4],byte ':' - mov [edi+5],word '//' - add edi,7 - mov esi,webAddr - -.copy_host_loop: - lodsb - cmp al,' ' - jz .noproxy - stosb - jmp .copy_host_loop - -.noproxy: - xor edx,edx ; 0 - -.next_edx: -; Determine the length of the url to send in the GET request - mov al,[edx+document] - cmp al,' ' - je .document_done - mov [edi],al - inc edi - inc edx - jmp .next_edx - -.document_done: - mov esi,stringh - mov ecx,stringh_end-stringh - rep movsb - xor edx,edx ; 0 - -.webaddr_next: - mov al,[webAddr + edx] - cmp al,' ' - je .webaddr_done - mov [edi],al - inc edi - inc edx - jmp .webaddr_next - -.webaddr_done: - cmp [proxyUser],byte 0 - jz @f - call append_proxy_auth_header -@@: - mov esi,connclose - mov ecx,connclose_end-connclose - rep movsb - - pusha - mov eax,63 - mov ebx,1 - mov edx,request -@@: - mov cl,[edx] - cmp edx,edi - jz @f - mcall - inc edx - jmp @b -@@: - popa - - mov edx,edi - sub edx,request -;;;;now write \r\nConnection: Close \r\n\r\n - mcall 53,7,[socket],,request ;' HTTP/1.1 .. ' - popa - ret - -;**************************************************************************** -; Function -; print_status -; -; Description -; displays the socket/data received status information -; -;**************************************************************************** -print_status: - pusha - mcall 26,9 - cmp eax,[nextupdate] - jb status_return - - add eax,25 - mov [nextupdate],eax - - mov ecx,[winys] - shl ecx,16 - add ecx,-18*65536+10 - mcall 13,<5,100>,,0xffffff - - mov edx,12*65536-18 - add edx,[winys] - xor esi,esi - mcall 47,<3,0>,[status],, - - mov edx,40*65536-18 - add edx,[winys] - mcall ,<6,0>,[pos] - -status_return: - popa - ret - -;**************************************************************************** -; Function -; read_incoming_data -; -; Description -; receive the web page from the server, storing it without processing -; -;**************************************************************************** -read_incoming_data: - cmp [onoff],1 - je rid - ret - -rid: - push esi - push edi -dps "rid" -newline - -newbyteread: - ;call print_status - mcall 53,2,[socket] - cmp eax,0 - je no_more_data - - mcall 53,11,[socket],primary_buf,primary_buffer_size - -;dps "part " -;dph eax -;newline - mov edi,[pos] - add [pos],eax - push eax - mcall 68,20,[pos],[buf_ptr] - mov [buf_ptr],eax - add edi,eax - mov esi,primary_buf - pop ecx ; number of recently read bytes - lea edx,[ecx - 3] - rep movsb - -no_more_data: - mcall 53,6,[socket] - cmp eax,4 - jne no_more_data.finish - jmp newbyteread - -.finish: -;dps "finish " -;pregs - call parse_result - mov ecx,[shared_name] - test ecx, ecx - jz @f - cmp [ecx],byte 0 - jnz save_in_shared -@@: - - mcall 70,fileinfo - - mov ecx,[sc.work_text] - or ecx,80000000h - mcall 4,<10,93>,,download_complete -dps "file saved" -newline -;pregs -; jmp close_end_exit - pop edi - pop esi -; if called from command line, then exit - cmp [params],byte 0 - jnz exit - ret - -save_in_shared: - mov esi,1 ; SHM_OPEN+SHM_WRITE - mcall 68,22 - test eax,eax - jz save_in_shared_done - - sub edx,4 - jbe save_in_shared_done - - mov ecx,[final_size] - cmp ecx,edx - jb @f - - mov ecx,edx -@@: - mov [eax],ecx - lea edi,[eax+4] - mov esi,[final_buffer] - mov edx,ecx - shr ecx,2 - rep movsd - mov ecx,edx - and ecx,3 - rep movsb - -save_in_shared_done: - pop edi - pop esi - jmp exit - -; this function cuts header, and removes chunk sizes if doc is chunked -; in: buf_ptr, pos; out: buf_ptr, pos. - -parse_result: -; close socket - mcall 53,8,[socket] - -dps "close socket: " -dph eax -newline - mov edi,[buf_ptr] - mov edx,[pos] - mov [buf_size],edx -; mcall 70,fileinfo_tmp -dps "pos = " -dph edx -newline - -; first, find end of headers -.next_byte: - cmp [edi],dword 0x0d0a0d0a ; мне лень читать стандарт, пусть будут оба варианта - je .end_of_headers - cmp [edi],dword 0x0a0d0a0d - je .end_of_headers - inc edi - dec edx - jne .next_byte -; no end of headers. it's an error. let client see all those headers. - ret - -.end_of_headers: -; here we look at headers and search content-length or transfer-encoding headers -;dps "eoh " -;newline - sub edi,[buf_ptr] - add edi,4 - mov [body_pos],edi ; store position where document body starts - mov [is_chunked],0 -; find content-length in headers -; not good method, but should work for 'Content-Length:' - mov esi,[buf_ptr] - mov edi,s_contentlength - mov ebx,[body_pos] - xor edx,edx ; 0 -.cl_next: - mov al,[esi] - cmp al,[edi + edx] - jne .cl_fail - inc edx - cmp edx,len_contentlength - je .cl_found - jmp .cl_incr -.cl_fail: - xor edx,edx ; 0 -.cl_incr: - inc esi - dec ebx - je .cl_error - jmp .cl_next -.cl_error: -;pregs -;newline -;dph esi -;dps " content-length not found " -; find 'chunked' -; да, я копирую код, это ужасно, но мне хочется, чтобы поскорее заработало -; а там уж отрефакторю - mov esi,[buf_ptr] - mov edi,s_chunked - mov ebx,[body_pos] - xor edx,edx ; 0 - -.ch_next: - mov al,[esi] - cmp al,[edi + edx] - jne .ch_fail - inc edx - cmp edx,len_chunked - je .ch_found - jmp .ch_incr - -.ch_fail: - xor edx,edx ; 0 - -.ch_incr: - inc esi - dec ebx - je .ch_error - jmp .ch_next - -.ch_error: -; if neither of the 2 headers is found, it's an error -;dps "transfer-encoding: chunked not found " - mov eax,[pos] - sub eax,[body_pos] - jmp .write_final_size - -.ch_found: - mov [is_chunked],1 - mov eax,[body_pos] - add eax,[buf_ptr] - sub eax,2 - mov [prev_chunk_end],eax - jmp parse_chunks - -.cl_found: - call read_number ; eax = number from *esi - -.write_final_size: - mov [final_size],eax ; if this works, i will b very happy... - - mov ebx,[pos] ; we well check if it is right - sub ebx,[body_pos] - -;dps "check cl eax==ebx " -;pregs - -; everything is ok, so we return - mov eax,[body_pos] - mov ebx,[buf_ptr] - add ebx,eax - mov [final_buffer],ebx -; mov ebx,[pos] -; sub ebx,eax -; mov [final_size],ebx - ret - -parse_chunks: -;dps "parse chunks" -;newline - ; we have to look through the data and remove sizes of chunks we see - ; 1. read size of next chunk - ; 2. if 0, it's end. if not, continue. - ; 3. make a good buffer and copy a chunk there - xor eax,eax - mov [final_buffer],eax ; 0 - mov [final_size],eax ; 0 - -.read_size: - mov eax,[prev_chunk_end] - mov ebx,eax - sub ebx,[buf_ptr] - mov edx,eax -;dps "rs " -;pregs - cmp ebx,[pos] - jae chunks_end ; not good - - call read_hex ; in: eax=pointer to text. out:eax=hex number,ebx=end of text. - cmp eax,0 - jz chunks_end - - add ebx,1 - mov edx,ebx ; edx = size of size of chunk - - add ebx,eax - mov [prev_chunk_end],ebx - -;dps "sz " -;pregs -; do copying: from buf_ptr+edx to final_buffer+prev_final_size count eax -; realloc final buffer - push eax - push edx - push dword [final_size] - add [final_size],eax - mcall 68,20,[final_size],[final_buffer] - mov [final_buffer],eax -;dps "re " -;pregs - pop edi - pop esi - pop ecx -; add [pos],ecx - add edi,[final_buffer] -;dps "cp " -;pregs - rep movsb - jmp .read_size - -chunks_end: -; free old buffer -dps "chunks end" -newline - mcall 68,13,[buf_ptr] -; done! - ret - -; reads content-length from [edi+ecx], result in eax -read_number: - push ebx - xor eax,eax - xor ebx,ebx - -.next: - mov bl,[esi] -;dph ebx - cmp bl,'0' - jb .not_number - cmp bl,'9' - ja .not_number - sub bl,'0' - shl eax,1 - lea eax,[eax + eax * 4] ; eax *= 10 - add eax,ebx - -.not_number: - cmp bl,13 - jz .done - inc esi - jmp .next - -.done: - pop ebx -;newline -;dps "strtoint eax " -;pregs - ret - -; reads hex from eax,result in eax,end of text in ebx -read_hex: - add eax,2 - mov ebx,eax - mov eax,[ebx] - mov [deba],eax -; pushf -; pushad -; mov edx,deba -; call debug_outstr -; popad -; popf - xor eax,eax - xor ecx,ecx -.next: - mov cl,[ebx] - inc ebx - - cmp cl,0x0d - jz .done -;dph ebx - or cl,0x20 - sub cl,'0' - jb .bad - - cmp cl,0x9 - jbe .adding - - sub cl,'a'-'0'-10 - cmp cl,0x0a - jb .bad - - cmp cl,0x0f - ja .bad - -.adding: - shl eax,4 - or eax,ecx -; jmp .not_number -;.bad: -.bad: - jmp .next -.done: -;newline -;dps "hextoint eax " -;pregs - ret - -;**************************************************************************** -; Function -; socket_commands -; -; Description -; opens or closes the socket -; -;**************************************************************************** -socket_commands: - cmp ah,22 ; open socket - jnz tst3 - -dps "opening socket" -newline -; Clear all page memory - xor eax,eax - mov [prev_chunk_end],eax ; 0 - cmp [buf_ptr],eax ; 0 - jz no_free - - mcall 68,13,[buf_ptr] ; free buffer - -no_free: - xor eax,eax - mov [buf_size],eax ; 0 -; Parse the entered url - call parse_url -; Get a free port number - mov ecx,1000 ; local port starting at 1000 - -getlp1: - inc ecx - push ecx - mcall 53,9 - pop ecx - cmp eax,0 ; is this local port in use? - jz getlp1 ; yes - so try next - - mov edx,80 - cmp [proxyAddr],byte 0 - jz sc000 - mov edx,[proxyPort] -sc000: - mcall 53,5,,,[server_ip],1 - mov [socket],eax - mov [pagexs],80 - - push eax - xor eax,eax ; 0 - mov [pos],eax - mov [pagex],eax - mov [pagey],eax - mov [command_on_off],eax - mov [is_body],eax - pop eax - ret - -tst3: - cmp ah,24 ; close socket - jnz no_24 - - mcall 53,8,[socket] -no_24: - ret - -;**************************************************************************** -; Function -; parse_url -; -; Description -; parses the full url typed in by the user into a web address ( that -; can be turned into an IP address by DNS ) and the page to display -; DNS will be used to translate the web address into an IP address, if -; needed. -; url is at document_user and will be space terminated. -; web address goes to webAddr and is space terminated. -; ip address goes to server_ip -; page goes to document and is space terminated. -; -; Supported formats: -; address -; is optional, removed and ignored - only http supported -;
is required. It can be an ip address or web address -; is optional and must start with a leading / character -; -;**************************************************************************** -parse_url: -; First, reset destination variables - cld - mov al,' ' - mov edi,document - mov ecx,URLMAXLEN - rep stosb - mov edi,webAddr - mov ecx,URLMAXLEN - rep stosb - - mov al,'/' - mov [document],al - - mov esi,document_user -; remove any leading protocol text - mov ecx,URLMAXLEN - mov ax,'//' - -pu_000: - cmp [esi],byte ' ' ; end of text? - je pu_002 ; yep, so not found - cmp [esi],ax - je pu_001 ; Found it, so esi+2 is start - inc esi - loop pu_000 - -pu_002: -; not found, so reset esi to start - mov esi,document_user-2 - -pu_001: - add esi,2 - mov ebx,esi ; save address of start of web address - mov edi,document_user + URLMAXLEN ; end of string -; look for page delimiter - it's a '/' character -pu_003: - cmp [esi],byte ' ' ; end of text? - je pu_004 ; yep, so none found - cmp esi,edi ; end of string? - je pu_004 ; yep, so none found - cmp [esi],byte '/' ; delimiter? - je pu_005 ; yep - process it - inc esi - jmp pu_003 - -pu_005: -; copy page to document address -; esi = delimiter - push esi - mov ecx,edi ; end of document_user - mov edi,document - cld - -pu_006: - movsb - cmp esi,ecx - je pu_007 ; end of string? - cmp [esi],byte ' ' ; end of text -; je pu_007 ; дзен-ассемблер -; jmp pu_006 ; не надо плодить сущности по напрасну - jne pu_006 - -pu_007: - pop esi ; point esi to '/' delimiter - -pu_004: -; copy web address to webAddr -; start in ebx,end in esi-1 - mov ecx,esi - mov esi,ebx - mov edi,webAddr - cld - -pu_008: - movsb - cmp esi,ecx -; je pu_009 ; дзен-ассемблер -; jmp pu_008 ; не надо плодить сущности по напрасну - jne pu_008 - -pu_009: -; For debugging, display resulting strings -if DEBUGGING_STATE = DEBUGGING_ENABLED - mov esi,document_user - call debug_print_string - mov esi,webAddr - call debug_print_string - mov esi,document - call debug_print_string -end if -; Look up the ip address, or was it specified? - mov al,[proxyAddr] - cmp al,0 - jnz pu_015 - mov al,[webAddr] -pu_015: - cmp al,'0' - jb pu_010 ; Resolve address - cmp al,'9' - ja pu_010 ; Resolve address - -if DEBUGGING_STATE = DEBUGGING_ENABLED - mov esi,str2 ; print gotip - call debug_print_string -end if -; Convert address -; If proxy is given, get proxy address instead of server - mov esi,proxyAddr-1 - cmp byte [esi+1],0 - jnz pu_020 - mov esi,webAddr-1 - -pu_020: - mov edi,server_ip - xor eax,eax - -ip1: - inc esi - cmp [esi],byte '0' - jb ip2 - cmp [esi],byte '9' - jg ip2 - imul eax,10 - movzx ebx,byte [esi] - sub ebx,48 - add eax,ebx - jmp ip1 - -ip2: - mov [edi],al - xor eax,eax - inc edi - cmp edi,server_ip+3 - jbe ip1 - jmp pu_011 - -pu_010: -if DEBUGGING_STATE = DEBUGGING_ENABLED - mov esi,str1 ; print resolving - call debug_print_string -end if -; Resolve Address - call translateData ; Convert domain & DNS IP address - call resolveDomain ; get ip address - -if DEBUGGING_STATE = DEBUGGING_ENABLED - mov esi,str3 - call debug_print_string -end if - -pu_011: -; Done - ret - -;*************************************************************************** -; Function -; translateData -; -; Description -; Coverts the domain name and DNS IP address typed in by the user into -; a format suitable for the IP layer. -; -; The ename, in query, is converted and stored in dnsMsg -; -;*************************************************************************** -translateData: - ; first, get the IP address of the DNS server - ; Then, build up the request string. - - ; Build the request string - mov eax,0x00010100 - mov [dnsMsg],eax - mov eax,0x00000100 - mov [dnsMsg+4],eax - mov eax,0x00000000 - mov [dnsMsg+8],eax -; domain name goes in at dnsMsg+12 - mov esi,dnsMsg +12 ;location of label length - mov edi,dnsMsg + 13 ;label start - mov edx,proxyAddr - cmp byte [edx],0 - jnz td000 - mov edx,webAddr - -td000: - mov ecx,12 ; total string length so far - -td002: - mov [esi],byte 0 - inc ecx - -td0021: - mov al,[edx] - cmp al,' ' - je td001 ; we have finished the string translation - - cmp al,0 - je td001 - - cmp al,'.' ; we have finished the label - je td004 - - inc byte [esi] - inc ecx - mov [edi],al - inc edi - inc edx - jmp td0021 - -td004: - mov esi,edi - inc edi - inc edx - jmp td002 - -; write label len + label text -td001: - mov [edi],byte 0 - inc ecx - inc edi - mov [edi],dword 0x01000100 - add ecx,4 - mov [dnsMsgLen],ecx - ret - -;*************************************************************************** -; Function -; resolveDomain -; -; Description -; Sends a question to the dns server -; works out the IP address from the response from the DNS server -; -;*************************************************************************** -resolveDomain: -; Get a free port number - mov ecx,1000 ; local port starting at 1000 -getlp: - inc ecx - push ecx - mcall 53,9 - pop ecx - cmp eax,0 ; is this local port in use? - jz getlp ; yes - so try next - -; Get DNS IP - mcall 52,13 - mov esi,eax -; First, open socket - mov edx,53 ; remote port - dns -; mov esi,dword [dns_ip] - xor ebx,ebx ; 0 - mcall 53 - mov [socketNum],eax -; write to socket ( request DNS lookup ) - mcall 53,4,[socketNum],[dnsMsgLen],dnsMsg -; Setup the DNS response buffer - mov eax,dnsMsg - mov [dnsMsgLen],eax -; now, we wait for -; UI redraw -; UI close -; or data from remote - -ctr001: - mcall 10 ; wait here for event - cmp eax,1 ; redraw request ? - je ctr003 - - cmp eax,2 ; key in buffer ? - je ctr004 - - cmp eax,3 ; button in buffer ? - je ctr005 -; Any data in the UDP receive buffer? - mcall 53,2,[socketNum] - cmp eax,0 - je ctr001 - -; we have data - this will be the response -ctr002: - mcall 53,3,[socketNum] ; read byte - block (high byte) -; Store the data in the response buffer - mov eax,[dnsMsgLen] - mov [eax],bl - inc dword [dnsMsgLen] - - mcall 53,2,[socketNum] ; any more data? - cmp eax,0 - jne ctr002 ; yes, so get it - -; close socket - mcall 53,1,[socketNum] - mov [socketNum],dword 0xFFFF -; Now parse the message to get the host IP -; Man, this is complicated. It's described in -; RFC 1035 -if DEBUGGING_STATE = DEBUGGING_ENABLED - mov esi,str4 - call debug_print_string -end if - - ; 1) Validate that we have an answer with > 0 responses - ; 2) Find the answer record with TYPE 0001 ( host IP ) - ; 3) Finally, copy the IP address to the display - ; Note: The response is in dnsMsg - ; The end of the buffer is pointed to by [dnsMsgLen] - -; Clear the IP address text - mov [server_ip],dword 0 - mov esi,dnsMsg -; Is this a response to my question? - mov al,[esi+2] - and al,0x80 - cmp al,0x80 - jne ctr002a -; Were there any errors? - mov al,[esi+3] - and al,0x0F - cmp al,0x00 - jne ctr002a -; Is there ( at least 1 ) answer? - mov ax,[esi+6] - cmp ax,0x00 - je ctr002a -; Header valdated. Scan through and get my answer -if DEBUGGING_STATE = DEBUGGING_ENABLED - pusha - mov esi,str4 - call debug_print_string - popa -end if - add esi,12 ; Skip to the question field -; Skip through the question field - call skipName - add esi,4 ; skip past the questions qtype, qclass - -ctr002z: -; Now at the answer. There may be several answers, -; find the right one ( TYPE = 0x0001 ) - call skipName - mov ax,[esi] - cmp ax,0x0100 ; Is this the IP address answer? - jne ctr002c -; Yes! Point esi to the first byte of the IP address - add esi,10 - mov eax,[esi] - mov [server_ip],eax - ret - -ctr002c: ; Skip through the answer, move to the next - add esi,8 - movzx eax,byte [esi+1] - mov ah,[esi] - add esi,eax - add esi,2 -; Have we reached the end of the msg? -; This is an error condition, should not happen - cmp esi,[dnsMsgLen] - jl ctr002z ; Check next answer - jmp ctr002a ; abort - -ctr002a: - jmp ctr001 - -ctr003: ; redraw - call draw_window - jmp ctr001 - -ctr004: ; key - mcall 2 ; just read it and ignore - jmp ctr001 - -ctr005: ; button - mcall 17 ; get id - mov dl,ah - - ; close socket - mcall 53,1,[socketNum] - cmp dl,1 - je exit - - mov [socketNum],dword 0xFFFF - mov [server_ip],dword 0 - ret - -;*************************************************************************** -; Function -; skipName -; -; Description -; Increment esi to the first byte past the name field -; Names may use compressed labels. Normally do. -; RFC 1035 page 30 gives details -; -;*************************************************************************** -skipName: - mov al,[esi] - cmp al,0 - je sn_exit - and al,0xc0 - cmp al,0xc0 - je sn001 - - movzx eax,byte [esi] - inc eax - add esi,eax - jmp skipName - -sn001: - add esi,2 ; A pointer is always at the end - ret - -sn_exit: - inc esi - ret - -;*************************************************************************** -; Function -; load_settings -; -; Description -; Load settings from configuration file network.ini -; -;*************************************************************************** -load_settings: - stdcall dll.Load,@IMPORT - test eax,eax - jnz ls001 - invoke ini.get_str,inifile,sec_proxy,key_proxy,proxyAddr,256,proxyAddr - invoke ini.get_int,inifile,sec_proxy,key_proxyport,80 - mov [proxyPort],eax - invoke ini.get_str,inifile,sec_proxy,key_user, proxyUser,256,proxyUser - invoke ini.get_str,inifile,sec_proxy,key_password,proxyPassword,256,proxyPassword -ls001: - ret - -;*************************************************************************** -; Function -; append_proxy_auth_header -; -; Description -; Append header to HTTP request for proxy authentification -; -;*************************************************************************** -append_proxy_auth_header: - mov esi,proxy_auth_basic - mov ecx,proxy_auth_basic_end - proxy_auth_basic - rep movsb -; base64-encode string : - mov esi,proxyUser - -apah000: - lodsb - test al,al - jz apah001 - call encode_base64_byte - jmp apah000 - -apah001: - mov al,':' - call encode_base64_byte - mov esi,proxyPassword - -apah002: - lodsb - test al,al - jz apah003 - call encode_base64_byte - jmp apah002 - -apah003: - call encode_base64_final - ret - -encode_base64_byte: - inc ecx - shl edx,8 - mov dl,al - cmp ecx,3 - je ebb001 - ret - -ebb001: - shl edx,8 - inc ecx - -ebb002: - rol edx,6 - xor eax,eax - xchg al,dl - mov al,[base64_table+eax] - stosb - loop ebb002 - ret - -encode_base64_final: - mov al,0 - test ecx,ecx - jz ebf000 - call encode_base64_byte - test ecx,ecx - jz ebf001 - call encode_base64_byte - mov byte [edi-2],'=' - -ebf001: - mov byte [edi-1],'=' - -ebf000: - ret - -if DEBUGGING_STATE = DEBUGGING_ENABLED - -;**************************************************************************** -; Function -; debug_print_string -; -; Description -; prints a string to the debug board, in quotes -; -; esi holds ptr to msg to display, which is space or 0 terminated -; -; Nothing preserved; I'm assuming a pusha/popa is done before calling -; -;**************************************************************************** -debug_print_string: - push esi - mov cl,'"' - mcall 63,1 - pop esi - -dps_000: - mov cl,[esi] - cmp cl,0 - je dps_exit - - cmp cl,' ' - je dps_exit - jmp dps_001 - -dps_exit: - mov cl,'"' - mcall 63,1 - mov cl,13 - mcall - mov cl,10 - mcall - ret - -dps_001: - push esi - mcall 63,1 - pop esi - inc esi - jmp dps_000 -end if - -; ********************************************* -; ******* WINDOW DEFINITIONS AND DRAW ******** -; ********************************************* - -draw_window: - -; cmp [params],byte 0 -; jz .noret - -;.noret: - - mcall 12,1 - - mcall 48,3,sc,40 ;get system colors - - mov edx,[sc.work] - or edx,0x34000000 - mcall 0,<50,370>,<350,140>,,0,title ;draw window - - mov ecx,[sc.work_text] - or ecx,80000000h - mcall 4, <14,14>, ,type_pls ;"URL:" - - ;mov ecx,[winys] - ;shl ecx,16 - ;add ecx,[winys] - ;sub ecx,26*65536+26 - ;mcall 38,<5,545> - - edit_boxes_set_sys_color edit1,editboxes_end,sc - stdcall [edit_box_draw], edit1 - -; RELOAD - mcall 8,<90,68>,<54,16>,22,[sc.work_button] -; STOP - mcall ,<166,50>,<54,16>,24 -; SAVE - mcall ,<224,54>,,26 -; BUTTON TEXT - mov ecx,[sc.work_button_text] - or ecx,80000000h - mcall 4,<102,59>,,button_text - - mcall 12,2 ; end window redraw - ret -;----------------------------------------------------------------------------- -; Data area -;----------------------------------------------------------------------------- -align 4 -@IMPORT: - -library libini,'libini.obj' - -import libini, \ - ini.get_str,'ini_get_str', \ - ini.get_int,'ini_get_int' - -;--------------------------------------------------------------------- -fileinfo dd 2,0,0 -final_size dd 0 -final_buffer dd 0 - db '/rd/1/.download',0 - -body_pos dd 0 - -;fileinfo_tmp dd 2,0,0 -buf_size dd 0 -buf_ptr dd 0 -; db '/rd/1/1',0 - -deba dd 0 - db 0 -;--------------------------------------------------------------------- -if DEBUGGING_STATE = DEBUGGING_ENABLED -str1: db "Resolving...",0 -str3: db "Resolved",0 -str2: db "GotIP",0 -str4: db "GotResponse",0 -end if -;--------------------------------------------------------------------- -;Leency editbox -mouse_dd dd 0 -edit1 edit_box 295, 48, 10, 0xffffff, 0xff, 0x80ff, 0, 0x8000, URLMAXLEN, document_user, mouse_dd, ed_focus+ed_always_focus,7,7 -editboxes_end: - -head_f_i: head_f_l db 'System error',0 -system_dir_0 db '/sys/lib/' -lib_name_0 db 'box_lib.obj',0 -err_msg_found_lib_0 db 'ЌҐ ­ ©¤Ґ­  ЎЁЎ«Ё®вҐЄ  ',39,'box_lib.obj',39,0 -err_msg_import_0 db 'ЋиЁЎЄ  ЇаЁ Ё¬Ї®а⥠ЎЁЎ«Ё®вҐЄЁ ',39,'box_lib',39,0 - -l_libs_start: - lib_0 l_libs lib_name_0, sys_path, library_path, system_dir_0,\ - err_msg_found_lib_0,head_f_l,import_box_lib,err_msg_import_0,head_f_i -l_libs_end: - -align 4 -import_box_lib: - ;dd sz_init1 - edit_box_draw dd sz_edit_box_draw - edit_box_key dd sz_edit_box_key - edit_box_mouse dd sz_edit_box_mouse - ;edit_box_set_text dd sz_edit_box_set_text -dd 0,0 - ;sz_init1 db 'lib_init',0 - sz_edit_box_draw db 'edit_box',0 - sz_edit_box_key db 'edit_box_key',0 - sz_edit_box_mouse db 'edit_box_mouse',0 - ;sz_edit_box_set_text db 'edit_box_set_text',0 - - sys_path rb 4096 - library_path rb 4096 -;--------------------------------------------------------------------- - -type_pls db 'URL:',0 -button_text db 'DOWNLOAD STOP RESAVE',0 -download_complete db 'File saved as /rd/1/.download',0 -display_from dd 20 -pos dd 0x0 -pagex dd 0x0 -pagey dd 0x0 -pagexs dd 80 -command_on_off dd 0x0 -text_type db 1 -com2 dd 0x0 -script dd 0x0 -socket dd 0x0 - -addr dd 0x0 -ya dd 0x0 -len dd 0x00 - -title db 'Network Downloader',0 - -server_ip: db 207,44,212,20 -;dns_ip: db 194,145,128,1 -;--------------------------------------------------------------------- -;webAddr: -;times URLMAXLEN db ' ' -;db 0 - -;document: db '/' -;times URLMAXLEN-1 db ' ' -;--------------------------------------------------------------------- -s_contentlength db 'Content-Length:' -len_contentlength = 15 - -s_chunked db 'Transfer-Encoding: chunked' -len_chunked = $ - s_chunked - -is_body dd 0 ; 0 if headers, 1 if content -is_chunked dd 0 -prev_chunk_end dd 0 -cur_chunk_size dd 0 - -string0: db 'GET ' - -stringh: db ' HTTP/1.1',13,10,'Host: ' -stringh_end: -proxy_auth_basic: db 13,10,'Proxy-Authorization: Basic ' -proxy_auth_basic_end: -connclose: db 13,10,'User-Agent: Kolibrios Downloader',13,10,'Connection: Close',13,10,13,10 -connclose_end: - -base64_table db 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' - db '0123456789+/' - -inifile db '/sys/network/zeroconf.ini',0 - -sec_proxy: -key_proxy db 'proxy',0 -key_proxyport db 'port',0 -key_user db 'user',0 -key_password db 'password',0 - - -proxyPort dd 80 - -shared_name dd 0 - -;yandex: db 'menuetos.net' -;yandex_end: - -status dd 0x0 -prev_status dd 0x0 - -onoff dd 0x0 - -nextupdate: dd 0 -winys: dd 400 - -dnsMsgLen: dd 0 -socketNum: dd 0xFFFF -;--------------------------------------------------------------------- -document_user db 'http://',0 -;--------------------------------------------------------------------- -IM_END: - rb URLMAXLEN-(IM_END - document_user) -;--------------------------------------------------------------------- -align 4 -document: - rb URLMAXLEN -;--------------------------------------------------------------------- -align 4 -webAddr: - rb URLMAXLEN+1 -;--------------------------------------------------------------------- -align 4 -primary_buf: - rb primary_buffer_size -;--------------------------------------------------------------------- -align 4 -params: ; db 1024 dup(0) - rb 1024 -;--------------------------------------------------------------------- -align 4 -request: ; db 256 dup(0) - rb 256 -;--------------------------------------------------------------------- -align 4 -proxyAddr: ; db 256 dup(0) - rb 256 -;--------------------------------------------------------------------- -align 4 -proxyUser: ; db 256 dup(0) - rb 256 -;--------------------------------------------------------------------- -align 4 -proxyPassword: ; db 256 dup(0) - rb 256 -;--------------------------------------------------------------------- -align 4 -dnsMsg: - rb 4096 -; rb 0x100000 -;--------------------------------------------------------------------- -align 4 - rb 4096 -stacktop: -;--------------------------------------------------------------------- -I_END: -;--------------------------------------------------------------------- diff --git a/programs/network_old/zeroconf/trunk/ETH.INC b/programs/network_old/zeroconf/trunk/ETH.INC deleted file mode 100644 index 889b5a8c03..0000000000 --- a/programs/network_old/zeroconf/trunk/ETH.INC +++ /dev/null @@ -1,413 +0,0 @@ -; -; ETH.INC -; -; made by hidnplayr (hidnplayr@kolibrios.org) for KolibriOS -; -; The given code before every macro is only a simple example -; -; -; HISTORY -; -; v1.0: august 2006 original release -; v1.1: december 2006 bugfixes and improvements -; v1.2: february 2007 more bugfixes and improvements - -macro mov arg1,arg2 { - if arg1 eq arg2 - else - mov arg1,arg2 - end if -} - -TCB_LISTEN = 1 -TCB_SYN_SENT = 2 -TCB_SYN_RECEIVED = 3 -TCB_ESTABLISHED = 4 -TCB_FIN_WAIT_1 = 5 -TCB_FIN_WAIT_2 = 6 -TCB_CLOSE_WAIT = 7 -TCB_CLOSING = 8 -TCB_LAST_ASK = 9 -TCB_TIME_WAIT = 10 -TCB_CLOSED = 11 - -PASSIVE = 0 -ACTIVE = 1 - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -macro eth.get_IP IP { - mov ebx,1 - mov eax,52 - mcall - - mov IP ,eax -} - -macro eth.get_GATEWAY GATEWAY { - mov ebx,9 - mov eax,52 - mcall - mov GATEWAY ,eax -} - -macro eth.get_SUBNET SUBNET { - mov ebx,10 - mov eax,52 - mcall - mov SUBNET ,eax -} - -macro eth.get_DNS DNS { - mov ebx,13 - mov eax,52 - mcall - mov DNS ,eax -} - -macro eth.set_IP IP { - mov ecx,IP - mov ebx,3 - mov eax,52 - mcall -} - -macro eth.set_GATEWAY GATEWAY { - mov ecx,GATEWAY - mov ebx,11 - mov eax,52 - mcall -} - -macro eth.set_SUBNET SUBNET { - mov ecx,SUBNET - mov ebx,12 - mov eax,52 - mcall -} - -macro eth.set_DNS DNS { - mov ecx,DNS - mov ebx,14 - mov eax,52 - mcall -} - -macro eth.set_network_drv conf { - mov ecx,conf - mov ebx,2 - mov eax,52 - mcall -} - -macro eth.open_udp local,remote,ip,socket { - mov ecx, local - mov edx, remote - mov esi, ip - mov ebx, 0 - mov eax, 53 - mcall - - mov socket,eax -} - -macro eth.close_udp socket { - mov ecx, socket - mov ebx, 1 - mov eax, 53 - mcall -} - -macro eth.poll socket { - mov ecx, socket - mov ebx, 2 - mov eax, 53 - mcall -} - -macro eth.read_byte socket, result { - mov ecx, socket - mov ebx, 3 - mov eax, 53 - mcall - - mov result,bl -} - -macro eth.read_packet socket, result, buffersize { - mov esi, buffersize - mov edx, result - mov ecx, socket - mov ebx, 11 - mov eax, 53 - mcall -} - -macro eth.write_udp socket,length,msg,verify { - mov ecx, socket - mov edx, length - mov esi, msg - mov ebx, 4 - mov eax, 53 - mcall - - if verify eq 1 - call verifysend - end if - -} - -verifysend: - test eax,eax - jnz @f - ret -@@: - pusha - mov eax,5 - mov ebx,100 - mcall - popa - mcall -ret - -macro eth.open_tcp local,remote,ip,passive,socket { - - mov ecx, local - mov edx, remote - mov esi, ip - mov edi, passive ; 0 = PASSIVE open - mov ebx, 5 - mov eax, 53 - mcall - - mov socket,eax -} - -macro eth.socket_status socket,result { - mov ecx, socket - mov ebx, 6 - mov eax, 53 - mcall - - mov result,eax -} - -macro eth.write_tcp socket,length,msg,verify { - mov ecx, socket - mov edx, length - mov esi, msg - mov ebx, 7 - mov eax, 53 - mcall - - if verify eq 1 - call verifysend - end if -} - -macro eth.read_mac mac { - mov eax, 52 - mov ebx, 15 - xor ecx, ecx - pusha - mcall - mov dword[mac],eax - popa - add cl, 4 - mcall - mov word[mac+4],ax - -} - -macro eth.close_tcp socket { - mov ecx, socket - mov ebx, 8 - mov eax, 53 - mcall -} - -macro eth.check_port port,result { - mov ecx, port - mov ebx, 9 - mov eax, 53 - mcall - - mov result,eax -} - -macro eth.check_cable result { - mov ebx, 10 - mov eax, 53 - mcall - - mov result,eax -} - -macro eth.status status { - mov ebx, 255 - mov ecx, 6 - mov eax, 53 - mcall - - mov status,eax -} - -macro eth.search_port port,result { - mov edx,port - @@: - inc edx - eth.check_port edx,eax - cmp eax,0 - je @r - mov result,edx -} - -macro eth.ARP_PROBE address{ - - mov edx,address - mov eax,52 - mov ebx,16 - xor ecx,ecx - mcall - -} - - -macro eth.ARP_ANNOUNCE address{ - - mov edx,address - mov eax,52 - mov ebx,16 - xor ecx,ecx - inc ecx - mcall - -} - -macro eth.read_data socket,dest,endptr,bufferl { -local .getdata,.loop,.end - mov eax, dest - mov endptr, eax - -.getdata: - cmp endptr, bufferl - jg .end - - eth.read_packet socket, endptr, 0 - add endptr,eax - - test eax, eax - jnz .getdata - - xor edx, edx -.loop: - eth.poll socket - - test eax, eax - jnz .getdata - - mov eax,5 - mov ebx,1 - mcall - - inc edx - cmp edx,30 - jl .loop - -.end: -} - -macro eth.wait_for_data socket,TIMEOUT,abort { - mov edx,TIMEOUT - - @@: - eth.poll socket - - cmp eax,0 - jne @f - - dec edx - jz abort - - mov eax,5 ; wait here for event - mov ebx,10 - mcall - - jmp @r - @@: - -} - - - -Ip2dword: - push edx - - ; This code validates if the query is an IP containing 4 numbers and 3 dots - - xor al, al ; make al (dot count) zero - - @@: - cmp byte[edx],'0' ; check if this byte is a number, if not jump to no_IP - jl no_IP ; - cmp byte[edx],'9' ; - jg no_IP ; - - inc edx ; the byte was a number, so lets check the next byte - - cmp byte[edx],0 ; is this byte zero? (have we reached end of query?) - jz @f ; jump to next @@ then - cmp byte[edx],':' - jz @f - - cmp byte[edx],'.' ; is this byte a dot? - jne @r ; if not, jump to previous @@ - - inc al ; the byte was a dot so increment al(dot count) - inc edx ; next byte - jmp @r ; lets check for numbers again (jump to previous @@) - - @@: ; we reach this when end of query reached - cmp al,3 ; check if there where 3 dots - jnz no_IP ; if not, jump to no_IP - - ; The following code will convert this IP into a dword and output it in eax - ; If there is also a port number specified, this will be returned in ebx, otherwise ebx is -1 - - pop esi ; edx (query address) was pushed onto stack and is now popped in esi - - xor edx, edx ; result - xor eax, eax ; current character - xor ebx, ebx ; current byte - -.outer_loop: - shl edx, 8 - add edx, ebx - xor ebx, ebx -.inner_loop: - lodsb - test eax, eax - jz .finish - cmp al, '.' - jz .outer_loop - sub eax, '0' - imul ebx, 10 - add ebx, eax - jmp .inner_loop -.finish: - shl edx, 8 - add edx, ebx - - bswap edx ; we want little endian order - - ret - -no_IP: - pop edx - xor edx, edx - - ret - - - - diff --git a/programs/network_old/zeroconf/trunk/build.bat b/programs/network_old/zeroconf/trunk/build.bat deleted file mode 100644 index 97216911bb..0000000000 --- a/programs/network_old/zeroconf/trunk/build.bat +++ /dev/null @@ -1,2 +0,0 @@ -@fasm zeroconf.asm zeroconf -@pause \ No newline at end of file diff --git a/programs/network_old/zeroconf/trunk/debug-fdo.inc b/programs/network_old/zeroconf/trunk/debug-fdo.inc deleted file mode 100644 index 40b2cb00e4..0000000000 --- a/programs/network_old/zeroconf/trunk/debug-fdo.inc +++ /dev/null @@ -1,422 +0,0 @@ -; -; Formatted Debug Output (FDO) -; Copyright (c) 2005-2006, mike.dld -; Created: 2005-01-29, Changed: 2006-11-10 -; -; For questions and bug reports, mail to mike.dld@gmail.com -; -; Available format specifiers are: %s, %d, %u, %x (with partial width support) -; - -; to be defined: -; __DEBUG__ equ 1 -; __DEBUG_LEVEL__ equ 5 - -macro debug_func name { - if used name - name@of@func equ name -} - -macro debug_beginf { - align 4 - name@of@func: -} - -debug_endf fix end if - -macro DEBUGS _sign,[_str] { - common - local tp - tp equ 0 - match _arg:_num,_str \{ - DEBUGS_N _sign,_num,_arg - tp equ 1 - \} - match =0 _arg,tp _str \{ - DEBUGS_N _sign,,_arg - \} -} - -macro DEBUGS_N _sign,_num,[_str] { - common - pushf - pushad - local ..str,..label,is_str - is_str = 0 - forward - if _str eqtype '' - is_str = 1 - end if - common - if is_str = 1 - jmp ..label - ..str db _str,0 - ..label: - add esp,4*8+4 - mov edx,..str - sub esp,4*8+4 - else - mov edx,_str - end if - if ~_num eq - if _num eqtype eax - if _num in - mov esi,_num - else if ~_num eq esi - movzx esi,_num - end if - else if _num eqtype 0 - mov esi,_num - else - local tp - tp equ 0 - match [_arg],_num \{ - mov esi,dword[_arg] - tp equ 1 - \} - match =0 =dword[_arg],tp _num \{ - mov esi,dword[_arg] - tp equ 1 - \} - match =0 =word[_arg],tp _num \{ - movzx esi,word[_arg] - tp equ 1 - \} - match =0 =byte[_arg],tp _num \{ - movzx esi,byte[_arg] - tp equ 1 - \} - match =0,tp \{ - 'Error: specified string width is incorrect' - \} - end if - else - mov esi,0x7FFFFFFF - end if - call fdo_debug_outstr - popad - popf -} - -macro DEBUGD _sign,_dec { - local tp - tp equ 0 - match _arg:_num,_dec \{ - DEBUGD_N _sign,_num,_arg - tp equ 1 - \} - match =0 _arg,tp _dec \{ - DEBUGD_N _sign,,_arg - \} -} - -macro DEBUGD_N _sign,_num,_dec { - pushf - pushad - if (~_num eq) - if (_dec eqtype eax | _dec eqtype 0) - 'Error: precision allowed only for in-memory variables' - end if - if (~_num in <1,2,4>) - if _sign - 'Error: 1, 2 and 4 are only allowed for precision in %d' - else - 'Error: 1, 2 and 4 are only allowed for precision in %u' - end if - end if - end if - if _dec eqtype eax - if _dec in - mov eax,_dec - else if ~_dec eq eax - if _sign = 1 - movsx eax,_dec - else - movzx eax,_dec - end if - end if - else if _dec eqtype 0 - mov eax,_dec - else - add esp,4*8+4 - if _num eq - mov eax,dword _dec - else if _num = 1 - if _sign = 1 - movsx eax,byte _dec - else - movzx eax,byte _dec - end if - else if _num = 2 - if _sign = 1 - movsx eax,word _dec - else - movzx eax,word _dec - end if - else - mov eax,dword _dec - end if - sub esp,4*8+4 - end if - mov cl,_sign - call fdo_debug_outdec - popad - popf -} - -macro DEBUGH _sign,_hex { - local tp - tp equ 0 - match _arg:_num,_hex \{ - DEBUGH_N _sign,_num,_arg - tp equ 1 - \} - match =0 _arg,tp _hex \{ - DEBUGH_N _sign,,_arg - \} -} - -macro DEBUGH_N _sign,_num,_hex { - pushf - pushad - if (~_num eq) & (~_num in <1,2,3,4,5,6,7,8>) - 'Error: 1..8 are only allowed for precision in %x' - end if - if _hex eqtype eax - if _hex in - if ~_hex eq eax - mov eax,_hex - end if - else if _hex in - if ~_hex eq ax - movzx eax,_hex - end if - shl eax,16 - if (_num eq) - mov edx,4 - end if - else if _hex in - if ~_hex eq al - movzx eax,_hex - end if - shl eax,24 - if (_num eq) - mov edx,2 - end if - end if - else if _hex eqtype 0 - mov eax,_hex - else - add esp,4*8+4 - mov eax,dword _hex - sub esp,4*8+4 - end if - if ~_num eq - mov edx,_num - else - mov edx,8 - end if - call fdo_debug_outhex - popad - popf -} - -;----------------------------------------------------------------------------- - -debug_func fdo_debug_outchar -debug_beginf - pushad - mov cl,al - mov ebx,1 - mov eax,63 - mcall - popad - ret -debug_endf - -debug_func fdo_debug_outstr -debug_beginf - mov eax,63 - mov ebx,1 - .l1: dec esi - js .l2 - mov cl,[edx] - or cl,cl - jz .l2 - mcall - inc edx - jmp .l1 - .l2: ret -debug_endf - -debug_func fdo_debug_outdec -debug_beginf - or cl,cl - jz @f - or eax,eax - jns @f - neg eax - push eax - mov al,'-' - call fdo_debug_outchar - pop eax - @@: push 10 - pop ecx - push -'0' - .l1: xor edx,edx - div ecx - push edx - test eax,eax - jnz .l1 - .l2: pop eax - add al,'0' - jz .l3 - call fdo_debug_outchar - jmp .l2 - .l3: ret -debug_endf - -debug_func fdo_debug_outhex - __fdo_hexdigits db '0123456789ABCDEF' -debug_beginf - mov cl,dl - neg cl - add cl,8 - shl cl,2 - rol eax,cl - .l1: rol eax,4 - push eax - and eax,0x0000000F - mov al,[__fdo_hexdigits+eax] - call fdo_debug_outchar - pop eax - dec edx - jnz .l1 - ret -debug_endf - -;----------------------------------------------------------------------------- - -macro DEBUGF _level,_format,[_arg] { - common - if __DEBUG__ = 1 & _level >= __DEBUG_LEVEL__ - local ..f1,f2,a1,a2,c1,c2,c3,..lbl - _debug_str_ equ __debug_str_ # a1 - a1 = 0 - c2 = 0 - c3 = 0 - f2 = 0 - repeat ..lbl-..f1 - virtual at 0 - db _format,0,0 - load c1 word from %-1 - end virtual - if c1 = '%s' - virtual at 0 - db _format,0,0 - store word 0 at %-1 - load c1 from f2-c2 - end virtual - if c1 <> 0 - DEBUGS 0,_debug_str_+f2-c2 - end if - c2 = c2 + 1 - f2 = %+1 - DEBUGF_HELPER S,a1,0,_arg - else if c1 = '%x' - virtual at 0 - db _format,0,0 - store word 0 at %-1 - load c1 from f2-c2 - end virtual - if c1 <> 0 - DEBUGS 0,_debug_str_+f2-c2 - end if - c2 = c2 + 1 - f2 = %+1 - DEBUGF_HELPER H,a1,0,_arg - else if c1 = '%d' | c1 = '%u' - local c4 - if c1 = '%d' - c4 = 1 - else - c4 = 0 - end if - virtual at 0 - db _format,0,0 - store word 0 at %-1 - load c1 from f2-c2 - end virtual - if c1 <> 0 - DEBUGS 0,_debug_str_+f2-c2 - end if - c2 = c2 + 1 - f2 = %+1 - DEBUGF_HELPER D,a1,c4,_arg - else if c1 = '\n' - c3 = c3 + 1 - end if - end repeat - virtual at 0 - db _format,0,0 - load c1 from f2-c2 - end virtual - if (c1<>0)&(f2<>..lbl-..f1-1) - DEBUGS 0,_debug_str_+f2-c2 - end if - virtual at 0 - ..f1 db _format,0 - ..lbl: - __debug_strings equ __debug_strings,_debug_str_,<_format>,..lbl-..f1-1-c2-c3 - end virtual - end if -} - -macro __include_debug_strings dummy,[_id,_fmt,_len] { - common - local c1,a1,a2 - forward - if defined _len & ~_len eq - _id: - a1 = 0 - a2 = 0 - repeat _len - virtual at 0 - db _fmt,0,0 - load c1 word from %+a2-1 - end virtual - if (c1='%s')|(c1='%x')|(c1='%d')|(c1='%u') - db 0 - a2 = a2 + 1 - else if (c1='\n') - dw $0A0D - a1 = a1 + 1 - a2 = a2 + 1 - else - db c1 and 0x0FF - end if - end repeat - db 0 - end if -} - -macro DEBUGF_HELPER _letter,_num,_sign,[_arg] { - common - local num - num = 0 - forward - if num = _num - DEBUG#_letter _sign,_arg - end if - num = num+1 - common - _num = _num+1 -} - -macro include_debug_strings { - if __DEBUG__ = 1 - match dbg_str,__debug_strings \{ - __include_debug_strings dbg_str - \} - end if -} diff --git a/programs/network_old/zeroconf/trunk/dhcp.inc b/programs/network_old/zeroconf/trunk/dhcp.inc deleted file mode 100644 index afe6c8fbaf..0000000000 --- a/programs/network_old/zeroconf/trunk/dhcp.inc +++ /dev/null @@ -1,263 +0,0 @@ -;Name Number Length Meaning - -dhcp_pad_option equ 0 ; 0 None -dhcp_end_option equ 255 ; 0 None -dhcp_subnet_mask equ 1 ; 4 Subnet Mask Value -dhcp_time_offset equ 2 ; 4 Time Offset in Seconds from UTC -dhcp_router equ 3 ; NЧ4 Router addresses -dhcp_time_server equ 4 ; NЧ4 Timeserver addresses -dhcp_name_server equ 5 ; NЧ4 IEN-116 Server addresses -dhcp_domain_server equ 6 ; NЧ4 DNS Server addresses -dhcp_log_server equ 7 ; NЧ4 Logging Server addresses -dhcp_quotes_server equ 8 ; NЧ4 Quotes Server addresses -dhcp_lpr_server equ 9 ; NЧ4 Printer Server addresses -dhcp_impress_server equ 10 ; NЧ4 Impress Server addresses -dhcp_rlp_server equ 11 ; NЧ4 N RLP Server addresses -dhcp_hostname equ 12 ; N Hostname string -dhcp_boot_file_size equ 13 ; 2 Size of boot file in 512-octet blocks -dhcp_merit_dump_file equ 14 ; N Client to dump and name the file to dump it to -dhcp_domain_name equ 15 ; N The DNS domain name of the client -dhcp_swap_server equ 16 ; 4 Swap Server address -dhcp_root_path equ 17 ; N Path name for root disk -dhcp_extension_file equ 18 ; N Path name for more BOOTP info - -;IP Layer Parameters per Host - -dhcp_forward equ 19 ; 1 Enable/Disable IP Forwarding -dhcp_srcrte equ 20 ; 1 Enable/Disable Non-Local Source Routing -dhcp_policy equ 21 ; NЧ8 Non-Local Source Routing Policy Filters -dhcp_mag_dg_assembly equ 22 ; 2 Max Datagram Reassembly Size -dhcp_default_ip_tll equ 23 ; 1 Default IP Time to Live -dhcp_mtu_timeout equ 24 ; 4 Path MTU Aging Timeout -dhcp_mtu_plateau equ 25 ; NЧ2 Path MTU Plateau Table - -;IP Layer Parameters per Interface - -dhcp_mtu_interface equ 26 ; 2 Interface MTU Size -dhcp_mtu_subnet equ 27 ; 1 All Subnets are Local -dhcp_broadcast_address equ 28 ; 4 Broadcast Address -dhcp_mask_discovery equ 29 ; 1 Perform Mask Discovery -dhcp_mask_supplier equ 30 ; 1 Provide Mask to Others -dhcp_router_discovery equ 31 ; 1 Perform Router Discovery -dhcp_router_request equ 32 ; 4 Router Solicitation Address -dhcp_static_route equ 33 ; NЧ8 Static Routing Table - -;Link Layer Parameters per Interface - -dhcp_trailers equ 34 ; 1 Trailer Encapsulation -dhcp_arp_timeout equ 35 ; 4 ARP Cache Timeout -dhcp_ethernet equ 36 ; 1 Ethernet Encapsulation - -;TCP Parameters - -dhcp_default_tcp_tll equ 37 ; 1 Default TCP Time to Live -dhcp_keepalive_time equ 38 ; 4 TCP Keepalive Interval -dhcp_keepalive_data equ 39 ; 1 TCP Keepalive Garbage - -;Application and Service Parameters - -dhcp_nis_domain equ 40 ; N NIS Domain Name -dhcp_nis_servers equ 41 ; NЧ4 NIS Server Addresses -dhcp_ntp_servers equ 42 ; NЧ4 NTP Server Addresses -dhcp_vendor_specific equ 43 ; N Vendor Specific Information -dhcp_netbios_name_srv equ 44 ; NЧ4 NETBIOS Name Servers -dhcp_netbios_dist_srv equ 45 ; NЧ4 NETBIOS Datagram Distribution -dhcp_netbios_node_type equ 46 ; 1 NETBIOS Node Type -dhcp_netbios_scope equ 47 ; N NETBIOS Scope -dhcp_x_window_font equ 48 ; NЧ4 X Window Font Server -dhcp_x_window_manager equ 49 ; NЧ4 X Window Display Manager -dhcp_nis_domain_name equ 64 ; N NIS+ v3 Client Domain Name -dhcp_nis_server_addr equ 65 ; NЧ4 NIS+ v3 Server Addresses -dhcp_home_agent_addrs equ 68 ; NЧ4 Mobile IP Home Agent Addresses -dhcp_smtp_server equ 69 ; NЧ4 Simple Mail Server Addresses -dhcp_pop3_server equ 70 ; NЧ4 Post Office Server Addresses -dhcp_nntp_server equ 71 ; NЧ4 Network News Server Addresses -dhcp_www_server equ 72 ; NЧ4 WWW Server Addresses -dhcp_finger_server equ 73 ; NЧ4 Finger Server Addresses -dhcp_irc_server equ 74 ; NЧ4 Chat Server Addresses -dhcp_streettalk_server equ 75 ; NЧ4 StreetTalk Server Addresses -dhcp_stda_server equ 76 ; NЧ4 ST Directory Assist. Addresses - -;DHCP Extensions - -dhcp_address_request equ 50 ; 4 Requested IP Address -dhcp_address_time equ 51 ; 4 IP Address Lease Time -dhcp_option_overload equ 52 ; 1 Overload "sname" or "file" -dhcp_msg_type equ 53 ; 1 DHCP Message Type -dhcp_dhcp_server_id equ 54 ; 4 DHCP Server Identification -dhcp_parameter_list equ 55 ; N Parameter Request List -dhcp_dhcp_message equ 56 ; N DHCP Error Message -dhcp_dhcp_max_msg_size equ 57 ; 2 DHCP Maximum Message Size -dhcp_renewal_time equ 58 ; 4 DHCP Renewal (T1) Time -dhcp_rebinding_time equ 59 ; 4 DHCP Rebinding (T2) Time -dhcp_class_id equ 60 ; N Vendor Class Identifier -dhcp_client_id equ 61 ; N Client Identifier -dhcp_server_name equ 66 ; N TFTP Server Name -dhcp_bootfile_name equ 67 ; N Boot File Name - -;Newer extensions - -dhcp_netware_ip_domain equ 62 ; N Netware/IP Domain Name -dhcp_netware_ip_option equ 63 ; N Netware/IP sub Options -dhcp_user_class equ 77 ; N User Class Information -dhcp_directory_agent equ 78 ; N directory agent information -dhcp_service_scope equ 79 ; N service location agent scope -dhcp_rapid_commit equ 80 ; 0 Rapid Commit -dhcp_client_fqdn equ 81 ; N Fully Qualified Domain Name -dhcp_relay_agent_info equ 82 ; N Relay Agent Information, RFC 3046 -dhcp_isns equ 83 ; N Internet Storage Name Service -; 84 REMOVED/Unassigned -dhcp_nds_servers equ 85 ; N Novell Directory Services -dhcp_nds_tree_name equ 86 ; N Novell Directory Services -dhcp_nds_conext equ 87 ; N Novell Directory Services -dhcp_bcmcs equ 88 ; Controller Domain Name list -dhcp_bcmcs equ 89 ; Controller IPv4 address option -dhcp_authentication equ 90 ; N Authentication -; 91 REMOVED/Unassigned -; 92 REMOVED/Unassigned -dhcp_client_system equ 93 ; N Client System Architecture -dhcp_client_ndi equ 94 ; N Client Network Device Interface -dhcp_ldap equ 95 ; N Lightweight Directory Access Protocol -; 96 REMOVED/Unassigned -dhcp_uuid_guid equ 97 ; N UUID/GUID-based Client Identifier -dchp_user_auth equ 98 ; N Open Group's User Authentication -; 99 REMOVED/Unassigned -; 100 REMOVED/Unassigned -; 101 REMOVED/Unassigned -; 102 REMOVED/Unassigned -; 103 REMOVED/Unassigned -; 104 REMOVED/Unassigned -; 105 REMOVED/Unassigned -; 106 REMOVED/Unassigned -; 107 REMOVED/Unassigned -; 108 REMOVED/Unassigned -; 109 REMOVED/Unassigned -; 110 REMOVED/Unassigned -; 111 REMOVED/Unassigned -dhcp_netinfo_address equ 112 ; N NetInfo Parent Server Address -dhcp_netinfo_tag equ 113 ; N NetInfo Parent Server Tag -dhcp_url equ 114 ; N URL -; 115 REMOVED/Unassigned -dhcp_auto_config equ 116 ; N DHCP Auto-Configuration -dhcp_ns_search equ 117 ; N Name Service Search -dhcp_subnet_selection equ 118 ; 4 Subnet Selection Option -dhcp_domain_search equ 119 ; N DNS domain search list -dhcp_sip_servers equ 120 ; N SIP Servers DHCP Option -dhcp_cl_static_route equ 121 ; N Classless Static Route Option -dhcp_ccc equ 122 ; N CableLabs Client Configuration -dhcp_geoconf equ 123 ; 16 GeoConf Option -dhcp_v_i_vendor_class equ 124 ; Vendor-Identifying Vendor Class -dhcp_v_i_vendor_spec equ 125 ; Vendor-Identifying Vendor-Specific -; 126 REMOVED/Unassigned -; 127 REMOVED/Unassigned -dhcp_pxe equ 128 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) -dhcp_etherboot_sign equ 128 ; Etherboot signature. 6 bytes: E4:45:74:68:00:00 -dhcp_docsis equ 128 ; DOCSIS "full security" server IP address -dhcp_tftp_server_ip equ 128 ; TFTP Server IP address (for IP Phone software load) -dhcp_pxe equ 129 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) -dhcp_kernel_options equ 129 ; Kernel options. Variable length string -dhcp_call_server_ip equ 129 ; Call Server IP address -dhcp_pxe equ 130 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) -dhcp_ethernet_interface equ 130 ; Ethernet interface. Variable length string. -dhcp_siscrimination equ 130 ; Discrimination string (to identify vendor) -dhcp_pxe equ 131 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) -dhcp_remote_stat_server equ 131 ; Remote statistics server IP address -dhcp_pxe equ 132 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) -dhcp_802.1p equ 132 ; 802.1P VLAN ID -dhcp_pxe equ 133 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) -dhcp_802.1q equ 133 ; 802.1Q L2 Priority -dhcp_pxe equ 134 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) -dhcp_diffserv equ 134 ; Diffserv Code Point -dhcp_pxe equ 135 ; PXE - undefined (vendor specific) (Tentatively Assigned - 23 June 2005) -dhcp_http_proxy_psa equ 135 ; HTTP Proxy for phone-specific applications -; 136 REMOVED/Unassigned -; 137 REMOVED/Unassigned -; 138 REMOVED/Unassigned -; 139 REMOVED/Unassigned -; 140 REMOVED/Unassigned -; 141 REMOVED/Unassigned -; 142 REMOVED/Unassigned -; 143 REMOVED/Unassigned -; 144 REMOVED/Unassigned -; 145 REMOVED/Unassigned -; 146 REMOVED/Unassigned -; 147 REMOVED/Unassigned -; 148 REMOVED/Unassigned -; 149 REMOVED/Unassigned -dhcp_tftp_server_addr equ 150 ; TFTP server address (Tentatively Assigned - 23 June 2005) -dhcp_etherboot equ 150 ; Etherboot -dhcp_grub_conf_path equ 150 ; GRUB configuration path name -; 151 REMOVED/Unassigned -; 152 REMOVED/Unassigned -; 153 REMOVED/Unassigned -; 154 REMOVED/Unassigned -; 155 REMOVED/Unassigned -; 156 REMOVED/Unassigned -; 157 REMOVED/Unassigned -; 158 REMOVED/Unassigned -; 159 REMOVED/Unassigned -; 160 REMOVED/Unassigned -; 161 REMOVED/Unassigned -; 162 REMOVED/Unassigned -; 163 REMOVED/Unassigned -; 164 REMOVED/Unassigned -; 165 REMOVED/Unassigned -; 166 REMOVED/Unassigned -; 167 REMOVED/Unassigned -; 168 REMOVED/Unassigned -; 169 REMOVED/Unassigned -; 170 REMOVED/Unassigned -; 171 REMOVED/Unassigned -; 172 REMOVED/Unassigned -; 173 REMOVED/Unassigned -; 174 REMOVED/Unassigned -dhcp_etherboot equ 175 ; Etherboot (Tentatively Assigned - 23 June 2005) -dhcp_ip_telephone equ 176 ; IP Telephone (Tentatively Assigned - 23 June 2005) -dhcp_etherboot equ 177 ; Etherboot (Tentatively Assigned - 23 June 2005) -dhcp_packetcable equ 177 ; PacketCable and CableHome (replaced by 122) -; 178 REMOVED/Unassigned -; 179 REMOVED/Unassigned -; 180 REMOVED/Unassigned -; 181 REMOVED/Unassigned -; 182 REMOVED/Unassigned -; 183 REMOVED/Unassigned -; 184 REMOVED/Unassigned -; 185 REMOVED/Unassigned -; 186 REMOVED/Unassigned -; 187 REMOVED/Unassigned -; 188 REMOVED/Unassigned -; 189 REMOVED/Unassigned -; 190 REMOVED/Unassigned -; 191 REMOVED/Unassigned -; 192 REMOVED/Unassigned -; 193 REMOVED/Unassigned -; 194 REMOVED/Unassigned -; 195 REMOVED/Unassigned -; 196 REMOVED/Unassigned -; 197 REMOVED/Unassigned -; 198 REMOVED/Unassigned -; 199 REMOVED/Unassigned -; 200 REMOVED/Unassigned -; 201 REMOVED/Unassigned -; 202 REMOVED/Unassigned -; 203 REMOVED/Unassigned -; 204 REMOVED/Unassigned -; 205 REMOVED/Unassigned -; 206 REMOVED/Unassigned -; 207 REMOVED/Unassigned -dhcp_pxelinux.magic equ 208 ; pxelinux.magic (string) = F1:00:74:7E (241.0.116.126) (Tentatively Assigned - 23 June 2005) -dhcp_pxelinux.conffile equ 209 ; pxelinux.configfile (text) (Tentatively Assigned - 23 June 2005) -dhcp_pxelinux.path equ 210 ; pxelinux.pathprefix (text) (Tentatively Assigned - 23 June 2005) -dhcp_pxelinux.reboot equ 211 ; pxelinux.reboottime (unsigned integer 32 bits) (Tentatively Assigned - 23 June 2005) -; 212 REMOVED/Unassigned -; 213 REMOVED/Unassigned -; 214 REMOVED/Unassigned -; 215 REMOVED/Unassigned -; 216 REMOVED/Unassigned -; 217 REMOVED/Unassigned -; 218 REMOVED/Unassigned -; 219 REMOVED/Unassigned -dhcp_subnet_aloc equ 220 ; Subnet Allocation Option (Tentatively Assigned - 23 June 2005) -dhcp_virtual_subnet equ 221 ; Virtual Subnet Selection Option (Tentatively Assigned - 23 June 2005) -; 222 REMOVED/Unassigned -; 223 REMOVED/Unassigned diff --git a/programs/network_old/zeroconf/trunk/zeroconf.asm b/programs/network_old/zeroconf/trunk/zeroconf.asm deleted file mode 100644 index 8403ad3d98..0000000000 --- a/programs/network_old/zeroconf/trunk/zeroconf.asm +++ /dev/null @@ -1,492 +0,0 @@ -; Zero-config -; v 1.4 -; -; DHCP code is based on that by Mike Hibbet (DHCP client for menuetos) -; -; Written by HidnPlayr & Derpenguin - -use32 - org 0x0 - - db 'MENUET01' ; 8 byte id - dd 0x01 ; header version - dd START ; start of code - dd IM_END ; size of image - dd I_END ; memory for app - dd I_END ; esp - dd 0x0 , path ; I_Param , I_Icon - -; CONFIGURATION - - -TIMEOUT equ 60 ; in seconds -BUFFER equ 1024 ; in bytes -__DEBUG__ equ 1 ; enable/disable -__DEBUG_LEVEL__ equ 1 ; 1 = all, 2 = errors - -; CONFIGURATION FOR LINK-LOCAL - -PROBE_WAIT equ 1 ; second (initial random delay) -PROBE_MIN equ 1 ; second (minimum delay till repeated probe) -PROBE_MAX equ 2 ; seconds (maximum delay till repeated probe) -PROBE_NUM equ 3 ; (number of probe packets) - -ANNOUNCE_NUM equ 2 ; (number of announcement packets) -ANNOUNCE_INTERVAL equ 2 ; seconds (time between announcement packets) -ANNOUNCE_WAIT equ 2 ; seconds (delay before announcing) - -MAX_CONFLICTS equ 10 ; (max conflicts before rate limiting) - -RATE_LIMIT_INTERVAL equ 60 ; seconds (delay between successive attempts) - -DEFEND_INTERVAL equ 10 ; seconds (min. wait between defensive ARPs) - -include '../../../proc32.inc' -include '../../../macros.inc' -include 'ETH.INC' -include 'debug-fdo.inc' -include 'dhcp.inc' -include '../../../dll.inc' - -START: ; start of execution - - mcall 40, 0 - - eth.set_network_drv 0x00000383 - - DEBUGF 1,"Zero-config service:\n" - - eth.status eax ; Read the Stack status - test eax,eax ; if eax is zero, no driver was found - jnz @f - DEBUGF 1,"No Card found!\n" - jmp close - - @@: - DEBUGF 1,"Detected card: %x\n",eax - @@: - eth.check_cable eax - test al,al - jnz @f - DEBUGF 1,"Cable disconnected!\n" - mcall 5, 500 ; loop until cable is connected (check every 5 sec) - jmp @r - - @@: - eth.read_mac MAC - DEBUGF 1,"MAC: %x-%x-%x-%x-%x-%x\n",[MAC]:2,[MAC+1]:2,[MAC+2]:2,[MAC+3]:2,[MAC+4]:2,[MAC+5]:2 - - cld - mov edi, path ; Calculate the length of zero-terminated string - xor al , al - mov ecx, 1024 - repnz scas byte[es:edi] - dec edi - - mov esi, filename - mov ecx, 5 - rep movsb - - mcall 68,11 - - stdcall dll.Load,@IMPORT - or eax,eax - jnz skip_ini - - - invoke ini.get_str, path, str_ipconfig, str_type, inibuf, 16, 0 - - mov eax,dword[inibuf] - - cmp eax,'stat' - jne skip_ini - - invoke ini.get_str, path, str_ipconfig, str_ip, inibuf, 16, 0 - mov edx, inibuf - call Ip2dword - eth.set_IP edx - - invoke ini.get_str, path, str_ipconfig, str_gateway, inibuf, 16, 0 - mov edx, inibuf - call Ip2dword - eth.set_GATEWAY edx - - invoke ini.get_str, path, str_ipconfig, str_dns, inibuf, 16, 0 - mov edx, inibuf - call Ip2dword - eth.set_DNS edx - - invoke ini.get_str, path, str_ipconfig, str_subnet, inibuf, 16, 0 - mov edx, inibuf - call Ip2dword - eth.set_SUBNET edx - - - mcall -1 - - -skip_ini: - - eth.check_port 68,eax ; Check if port 68 is available - cmp eax,1 - je @f - - DEBUGF 1,"Port 68 is already in use!\n" - jmp close - - @@: - eth.open_udp 68,67,-1,[socketNum] ; open socket (local,remote,ip,socket) - ; Setup the first msg we will send - mov byte [dhcpMsgType], 0x01 ; DHCP discover - mov dword [dhcpLease], esi ; esi is still -1 (-1 = forever) - - mcall 26, 9 - imul eax,100 - mov [currTime],eax - -buildRequest: ; Creates a DHCP request packet. - stdcall mem.Alloc, BUFFER - mov [dhcpMsg], eax - test eax,eax - jz apipa - - - mov edi, eax - mov ecx,BUFFER - xor eax,eax - cld - rep stosb - - mov edx,[dhcpMsg] - - mov [edx], byte 0x01 ; Boot request - mov [edx+1], byte 0x01 ; Ethernet - mov [edx+2], byte 0x06 ; Ethernet h/w len - mov [edx+4], dword 0x11223344 ; xid - mov eax,[currTime] - mov [edx+8], eax ; secs, our uptime - mov [edx+10], byte 0x80 ; broadcast flag set - mov eax, dword [MAC] ; first 4 bytes of MAC - mov [edx+28],dword eax - mov ax, word [MAC+4] ; last 2 bytes of MAC - mov [edx+32],word ax - mov [edx+236], dword 0x63538263 ; magic number - mov [edx+240], word 0x0135 ; option DHCP msg type - mov al, [dhcpMsgType] - mov [edx+240+2], al - mov [edx+240+3], word 0x0433 ; option Lease time = infinity - mov eax, [dhcpLease] - mov [edx+240+5], eax - mov [edx+240+9], word 0x0432 ; option requested IP address - mov eax, [dhcpClientIP] - mov [edx+240+11], eax - mov [edx+240+15], word 0x0437 ; option request list - mov [edx+240+17], dword 0x0f060301 - - cmp [dhcpMsgType], byte 0x01 ; Check which msg we are sending - jne request_options - - mov [edx+240+21], byte 0xff ; "Discover" options - - mov [dhcpMsgLen], dword 262 ; end of options marker - jmp send_request - -request_options: - mov [edx+240+21], word 0x0436 ; server IP - mov eax, [dhcpServerIP] - mov [edx+240+23], eax - - mov [edx+240+27], byte 0xff ; end of options marker - - mov [dhcpMsgLen], dword 268 - -send_request: - eth.write_udp [socketNum],[dhcpMsgLen],[dhcpMsg] ; write to socket ( send broadcast request ) - - mov eax, [dhcpMsg] ; Setup the DHCP buffer to receive response - mov [dhcpMsgLen], eax ; Used as a pointer to the data - - mov eax,23 ; wait here for event (data from remote) - mov ebx,TIMEOUT*10 - mcall - - eth.poll [socketNum] - - test eax,eax - jnz read_data - - DEBUGF 2,"Timeout!\n" - eth.close_udp [socketNum] - jmp apipa ; no server found, lets try zeroconf - - -read_data: ; we have data - this will be the response - eth.read_packet [socketNum], [dhcpMsg], BUFFER - mov [dhcpMsgLen], eax - eth.close_udp [socketNum] - - ; depending on which msg we sent, handle the response - ; accordingly. - ; If the response is to a dhcp discover, then: - ; 1) If response is DHCP OFFER then - ; 1.1) record server IP, lease time & IP address. - ; 1.2) send a request packet - ; If the response is to a dhcp request, then: - ; 1) If the response is DHCP ACK then - ; 1.1) extract the DNS & subnet fields. Set them in the stack - - cmp [dhcpMsgType], byte 0x01 ; did we send a discover? - je discover - cmp [dhcpMsgType], byte 0x03 ; did we send a request? - je request - - jmp close ; really unknown, what we did - -discover: - call parseResponse - - cmp [dhcpMsgType], byte 0x02 ; Was the response an offer? - jne apipa ; NO - so we do zeroconf - mov [dhcpMsgType], byte 0x03 ; DHCP request - jmp buildRequest - -request: - call parseResponse - - cmp [dhcpMsgType], byte 0x05 ; Was the response an ACK? It should be - jne apipa ; NO - so we do zeroconf - - jmp close - -;*************************************************************************** -; Function -; parseResponse -; -; Description -; extracts the fields ( client IP address and options ) from -; a DHCP response -; The values go into -; dhcpMsgType,dhcpLease,dhcpClientIP,dhcpServerIP, -; dhcpDNSIP, dhcpSubnet -; The message is stored in dhcpMsg -; -;*************************************************************************** -parseResponse: - DEBUGF 1,"Data received, parsing response\n" - mov edx, [dhcpMsg] - - pusha - eth.set_IP [edx+16] - mov eax,[edx] - mov [dhcpClientIP],eax - DEBUGF 1,"Client: %u.%u.%u.%u\n",[edx+16]:1,[edx+17]:1,[edx+18]:1,[edx+19]:1 - popa - - add edx, 240 ; Point to first option - xor ecx, ecx - -next_option: - add edx, ecx -pr001: - mov al, [edx] - cmp al, 0xff ; End of options? - je pr_exit - - cmp al, dhcp_msg_type ; Msg type is a single byte option - jne @f - - mov al, [edx+2] - mov [dhcpMsgType], al - add edx, 3 - jmp pr001 ; Get next option - -@@: - inc edx - movzx ecx, byte [edx] - inc edx ; point to data - - cmp al, dhcp_dhcp_server_id ; server ip - jne @f - mov eax, [edx] - mov [dhcpServerIP], eax - DEBUGF 1,"Server: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1 - jmp next_option - -@@: - cmp al, dhcp_address_time - jne @f - - pusha - mov eax,[edx] - bswap eax - mov [dhcpLease],eax - DEBUGF 1,"lease: %d\n",eax - popa - - jmp next_option - -@@: - cmp al, dhcp_subnet_mask - jne @f - - pusha - eth.set_SUBNET [edx] - DEBUGF 1,"Subnet: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1 - popa - - jmp next_option - -@@: - cmp al, dhcp_router - jne @f - - pusha - eth.set_GATEWAY [edx] - DEBUGF 1,"Gateway: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1 - popa - - jmp next_option - - -@@: - cmp al, dhcp_domain_server - jne next_option - - pusha - eth.set_DNS [edx] - DEBUGF 1,"DNS: %u.%u.%u.%u\n",[edx]:1,[edx+1]:1,[edx+2]:1,[edx+3]:1 - popa - - jmp next_option - -pr_exit: - -; DEBUGF 1,"Sending ARP announce\n" -; eth.ARP_ANNOUNCE [dhcpClientIP] ; send an ARP announce packet - - jmp close - -apipa: - stdcall mem.Free, [dhcpMsg] - -link_local: - call random - mov ecx,0xfea9 ; IP 169.254.0.0 link local net, see RFC3927 - mov cx,ax - eth.set_IP ecx ; mask is 255.255.0.0 - DEBUGF 1,"Link Local IP assigned: 169.254.%u.%u\n",[generator+2]:1,[generator+3]:1 - eth.set_SUBNET 0xffff - eth.set_GATEWAY 0x0 - eth.set_DNS 0x0 - - mcall 5, PROBE_WAIT*100 - - xor esi,esi - probe_loop: - call random ; create a pseudo random number in eax (seeded by MAC) - - cmp al,PROBE_MIN*100 ; check if al is bigger then PROBE_MIN - jge @f ; all ok - add al,(PROBE_MAX-PROBE_MIN)*100 ; al is too small - @@: - - cmp al,PROBE_MAX*100 - jle @f - sub al,(PROBE_MAX-PROBE_MIN)*100 - @@: - - movzx ebx,al - DEBUGF 1,"Waiting %u0ms\n",ebx - mcall 5 - - DEBUGF 1,"Sending Probe\n" -; eth.ARP_PROBE MAC - inc esi - - cmp esi,PROBE_NUM - jl probe_loop - -; now we wait further ANNOUNCE_WAIT seconds and send ANNOUNCE_NUM ARP announces. If any other host has assigned -; IP within this time, we should create another adress, that have to be done later - - DEBUGF 1,"Waiting %us\n",ANNOUNCE_WAIT - mcall 5, ANNOUNCE_WAIT*100 - xor esi,esi - announce_loop: - - DEBUGF 1,"Sending Announce\n" -; eth.ARP_ANNOUNCE MAC - - inc esi - cmp esi,ANNOUNCE_NUM - je @f - - DEBUGF 1,"Waiting %us\n",ANNOUNCE_INTERVAL - mcall 5, ANNOUNCE_INTERVAL*100 - jmp announce_loop - @@: - ; we should, instead of closing, detect ARP conflicts and detect if cable keeps connected ;) - -close: - mcall -1 - - -random: ; Pseudo random actually - - mov eax,[generator] - add eax,-43ab45b5h - ror eax,1 - bswap eax - xor eax,dword[MAC] - ror eax,1 - xor eax,dword[MAC+2] - mov [generator],eax - -ret - -; DATA AREA - -align 16 -@IMPORT: - -library \ - libini,'libini.obj' - -import libini, \ - ini.get_str,'ini_get_str' - -include_debug_strings - -filename db '.ini',0 -str_ip db 'ip',0 -str_subnet db 'subnet',0 -str_gateway db 'gateway',0 -str_dns db 'dns',0 -str_ipconfig db 'ipconfig',0 -str_type db 'type',0 - - -IM_END: - -inibuf rb 16 - -dhcpClientIP dd ? -dhcpMsgType db ? -dhcpLease dd ? -dhcpServerIP dd ? - -dhcpMsgLen dd ? -socketNum dd ? - -MAC dp ? -currTime dd ? -renewTime dd ? -generator dd ? - -dhcpMsg dd ? - -I_END_2: - -path rb 1024+5 - -I_END: diff --git a/programs/network_old/zeroconf/trunk/zeroconf.ini b/programs/network_old/zeroconf/trunk/zeroconf.ini deleted file mode 100644 index 7d57752210..0000000000 --- a/programs/network_old/zeroconf/trunk/zeroconf.ini +++ /dev/null @@ -1,9 +0,0 @@ -[ipconfig] -; type should be static or zeroconf -; zeroconf means the service first tries to contact a DHCP server -; If dhcp is not available, it switches to link-local -type = static -ip = 192.168.1.150 -gateway = 192.168.1.1 -dns = 192.168.1.1 -subnet = 255.255.255.0 \ No newline at end of file