From 659d2fcc625ad8088e50c60c4b617e17da086d17 Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Sat, 2 Nov 2013 16:45:08 +0000 Subject: [PATCH] Deleted old network programs that have been replaced. git-svn-id: svn://kolibrios.org@4151 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/network_old/airc/trunk/airc.asm | 2864 ----------------- programs/network_old/airc/trunk/build_en.bat | 5 - programs/network_old/airc/trunk/build_ru.bat | 5 - programs/network_old/airc/trunk/eth.inc | 670 ---- programs/network_old/airc/trunk/fdo.inc | 343 -- .../network_old/arpstat/trunk/arpstat.asm | 416 --- .../network_old/arpstat/trunk/build_en.bat | 5 - .../network_old/arpstat/trunk/build_ru.bat | 5 - programs/network_old/dhcp/trunk/build_en.bat | 5 - programs/network_old/dhcp/trunk/build_ru.bat | 5 - programs/network_old/dhcp/trunk/dhcp.asm | 582 ---- programs/network_old/dnsr/trunk/build_en.bat | 5 - programs/network_old/dnsr/trunk/build_ru.bat | 5 - programs/network_old/dnsr/trunk/dnsr.asm | 785 ----- .../network_old/ethstat/trunk/build_en.bat | 4 - .../network_old/ethstat/trunk/build_ru.bat | 4 - .../network_old/ethstat/trunk/ethstat.asm | 218 -- programs/network_old/ftps/trunk/FTPS.ASM | 1724 ---------- programs/network_old/ftps/trunk/build.bat | 2 - programs/network_old/popc/trunk/build_en.bat | 5 - programs/network_old/popc/trunk/build_ru.bat | 5 - programs/network_old/popc/trunk/popc.asm | 1019 ------ .../network_old/stackcfg/trunk/build_en.bat | 5 - .../network_old/stackcfg/trunk/build_ru.bat | 5 - .../network_old/stackcfg/trunk/readme.txt | 11 - .../network_old/stackcfg/trunk/stackcfg.asm | 701 ---- .../network_old/telnet/trunk/build_en.bat | 5 - .../network_old/telnet/trunk/build_ru.bat | 5 - programs/network_old/telnet/trunk/telnet.asm | 793 ----- .../network_old/terminal/trunk/build_en.bat | 5 - .../network_old/terminal/trunk/build_ru.bat | 5 - .../network_old/terminal/trunk/terminal.asm | 727 ----- programs/network_old/tftpc/trunk/build_en.bat | 5 - programs/network_old/tftpc/trunk/build_ru.bat | 5 - programs/network_old/tftpc/trunk/tftpc.asm | 977 ------ 35 files changed, 11930 deletions(-) delete mode 100644 programs/network_old/airc/trunk/airc.asm delete mode 100644 programs/network_old/airc/trunk/build_en.bat delete mode 100644 programs/network_old/airc/trunk/build_ru.bat delete mode 100644 programs/network_old/airc/trunk/eth.inc delete mode 100644 programs/network_old/airc/trunk/fdo.inc delete mode 100644 programs/network_old/arpstat/trunk/arpstat.asm delete mode 100644 programs/network_old/arpstat/trunk/build_en.bat delete mode 100644 programs/network_old/arpstat/trunk/build_ru.bat delete mode 100644 programs/network_old/dhcp/trunk/build_en.bat delete mode 100644 programs/network_old/dhcp/trunk/build_ru.bat delete mode 100644 programs/network_old/dhcp/trunk/dhcp.asm delete mode 100644 programs/network_old/dnsr/trunk/build_en.bat delete mode 100644 programs/network_old/dnsr/trunk/build_ru.bat delete mode 100644 programs/network_old/dnsr/trunk/dnsr.asm delete mode 100644 programs/network_old/ethstat/trunk/build_en.bat delete mode 100644 programs/network_old/ethstat/trunk/build_ru.bat delete mode 100644 programs/network_old/ethstat/trunk/ethstat.asm delete mode 100644 programs/network_old/ftps/trunk/FTPS.ASM delete mode 100644 programs/network_old/ftps/trunk/build.bat delete mode 100644 programs/network_old/popc/trunk/build_en.bat delete mode 100644 programs/network_old/popc/trunk/build_ru.bat delete mode 100644 programs/network_old/popc/trunk/popc.asm delete mode 100644 programs/network_old/stackcfg/trunk/build_en.bat delete mode 100644 programs/network_old/stackcfg/trunk/build_ru.bat delete mode 100644 programs/network_old/stackcfg/trunk/readme.txt delete mode 100644 programs/network_old/stackcfg/trunk/stackcfg.asm delete mode 100644 programs/network_old/telnet/trunk/build_en.bat delete mode 100644 programs/network_old/telnet/trunk/build_ru.bat delete mode 100644 programs/network_old/telnet/trunk/telnet.asm delete mode 100644 programs/network_old/terminal/trunk/build_en.bat delete mode 100644 programs/network_old/terminal/trunk/build_ru.bat delete mode 100644 programs/network_old/terminal/trunk/terminal.asm delete mode 100644 programs/network_old/tftpc/trunk/build_en.bat delete mode 100644 programs/network_old/tftpc/trunk/build_ru.bat delete mode 100644 programs/network_old/tftpc/trunk/tftpc.asm diff --git a/programs/network_old/airc/trunk/airc.asm b/programs/network_old/airc/trunk/airc.asm deleted file mode 100644 index 91b4f519c1..0000000000 --- a/programs/network_old/airc/trunk/airc.asm +++ /dev/null @@ -1,2864 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; IRC CLIENT for KolibriOS ;; -;; ;; -;; License: GPL / See file COPYING for details ;; -;; Copyright 2004 (c) Ville Turjanmaa ;; -;; Copyright 2009 (c) CleverMouse ;; -;; ;; -;; Compile with FASM for Kolibri ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -version equ '0.6' - - -;__DEBUG__ equ 1 -;__DEBUG_LEVEL__ equ 1 - -use32 - - org 0x0 - - db 'MENUET01' ; 8 byte id - dd 0x01 ; required os - dd START ; program start - dd initialized_size ; program image size - dd 0x100000 ; required amount of memory - dd 0x100000 - dd 0,0 - -include "../../../macros.inc" -include "../../../proc32.inc" -include "../../../develop/libraries/network/network.inc" -include "../../../dll.inc" -;include "fdo.inc" -include "eth.inc" -include "lang.inc" - -; connection statuses -STATUS_DISCONNECTED = 0 ; disconnected -STATUS_RESOLVING = 1 ; resolving server name -STATUS_CONNECTING = 2 ; connecting to server -STATUS_CONNECTED = 3 ; connected -; where to display status -STATUS_X = 25 + 22*6 -STATUS_Y = 183 + 7*12 - -; supported encodings -CP866 = 0 -CP1251 = 1 -UTF8 = 2 -; where to display encoding -ENCODING_X = 25 + 15*6 -ENCODING_Y = 183 + 3*12 - -def_server_name db 'chat.freenode.net',0 ; default server name - -user_nick dd 12 ; length - db 'kolibri_user ' ; string -user_nick_max = $ - user_nick - 4 - -user_real_name dd 14 ; length - db 'KolibriOS User ' ; string -user_real_name_max = $ - user_real_name - 4 - - -START: ; start of execution - - stdcall dll.Load, @IMPORT - test eax,eax - jnz exit - - mov eax,40 - mov ebx,11000111b - mcall - mcall 60, 1, ipcbuf, ipcbuf.size - mcall 9, 0xe0000, -1 - mov eax,[ebx+process_information.PID] - mov [main_PID],eax - - mov esi, def_server_name - mov edi, irc_server_name -@@: - lodsb - stosb - test al, al - jnz @b - - mov edi,I_END - mov ecx,60*120 - mov al,32 - cld - rep stosb - - mov eax,[rxs] - imul eax,11 - mov [pos],eax - - mov ebp,0 - mov edx,I_END - -redraw: ; redraw - call draw_window ; at first, draw the window - -still: - - mov eax,10 ; wait here for event - mcall - - dec eax ; redraw - je redraw - dec eax ; key - je main_window_key - dec eax ; button - je button - cmp al,4 - jz ipc - - call process_network_event - - cmp [I_END+120*60],byte 1 - jne no_main_update - mov [I_END+120*60],byte 0 - mov edx,I_END - call draw_channel_text - no_main_update: - - call print_channel_list - - jmp still - -button: ; button - - mov eax,17 ; get id - mcall - - cmp ah,1 ; close program - jne noclose -exit: - or eax,-1 - mcall - noclose: - cmp ah,21 - jne no_change_encoding - cmp byte[edx-1],0 - jnz still - mov eax,[encoding] - inc eax - mov edx,msgbox_struct - mov byte[edx],al - mov byte[edx-1],1 ; msgbox is running - push mb_stack - push edx - call [mb_create] - push msgbox_func_array - call [mb_setfunctions] - jmp still - no_change_encoding: - - call socket_commands - - jmp still - -ipc: - mov edx,msgbox_struct - cmp byte[edx-1],0 - jz @f - mov byte[edx-1],0 - mov al,[edx] - dec eax - mov byte[encoding],al - call update_encoding - jmp ipc_done -@@: - call process_command -ipc_done: - mov dword [ipcbuf+4], 8 - jmp still - -main_window_key: - - mov eax,2 - mcall - - shr eax,8 - - cmp eax,8 - jne no_bks2 - cmp [xpos],0 - je still - dec [xpos] - call print_entry - jmp still - no_bks2: - - cmp eax,20 - jbe no_character2 - mov ebx,[xpos] - mov [send_string+ebx],al - inc [xpos] - cmp [xpos],80 - jb noxposdec - mov [xpos],79 - noxposdec: - call print_entry - jmp still - no_character2: - - cmp eax,13 - jne no_send2 - cmp [xpos],0 - je no_send2 - cmp [send_string],byte '/' ; server command - jne no_send2 - call process_command - jmp still - no_send2: - - jmp still - - -socket_commands: - - cmp ah,22 ; connect - jnz tst3 - -; ignore if status is not "disconnected" - cmp [status], STATUS_DISCONNECTED - jnz .nothing - -; start name resolving - inc [status] ; was STATUS_DISCONNECTED, now STATUS_RESOLVING - push gai_reqdata - push ip_list - push 0 - push 0 - push irc_server_name - call [getaddrinfo_start] - test eax, eax - jns getaddrinfo_done - call update_status -.nothing: - ret - - tst3: - - - cmp ah,23 ; write userinfo - jnz tst4 - -; ignore if status is not "connected" - cmp [status], STATUS_CONNECTED - jnz .nothing - -; create packet in packetbuf - mov edi, packetbuf - mov edx, edi - mov esi, string0 - mov ecx, string0l-string0 - rep movsb - mov esi, user_real_name+4 - mov ecx, [esi-4] - rep movsb - mov al, 13 - stosb - mov al, 10 - stosb - mov esi, string1 - mov ecx, string1l-string1 - rep movsb - mov esi, user_nick+4 - mov ecx, [esi-4] - rep movsb - mov al, 13 - stosb - mov al, 10 - stosb -; send packet - xchg edx, edi - sub edx, edi - mov esi, edi - mcall 53, 7, [socket] - .nothing: - ret - - tst4: - - - cmp ah,24 ; close socket - jz disconnect - no_24: - - - ret - -getaddrinfo_done: -; The address resolving is done. -; If eax is zero, address is resolved, otherwise there was some problems. - test eax, eax - jz .good -.disconnect: -; Change status to "disconnected" and return. - and [status], 0 - call update_status - ret -.good: -; We got a list of IP addresses. Try to connect to first of them. - mov eax, [ip_list] - mov esi, [eax + addrinfo.ai_addr] - mov esi, [esi + sockaddr_in.sin_addr] - push eax - call [freeaddrinfo] - mcall 53, 5, 0, 6667, , 1 - cmp eax, -1 - jz .disconnect -; Socket has been opened. Save handle and change status to "connecting". - mov [socket], eax - inc [status] ; was STATUS_RESOLVING, now STATUS_CONNECTING - call update_status - ret - -process_network_event: -; values for status: 0, 1, 2, 3 - mov eax, [status] - dec eax -; 0 = STATUS_DISCONNECTED - do nothing -; (ignore network events if we are disconnected from network) - js .nothing -; 1 = STATUS_RESOLVING - jz .resolving -; 2 = STATUS_CONNECTING - dec eax - jz .connecting -; 3 = STATUS_CONNECTED - jmp .connected -.resolving: -; We are inside address resolving. Let the network library work. - push ip_list - push gai_reqdata - call [getaddrinfo_process] -; Negative returned value means that the resolving is not yet finished, -; and we continue the loop without status change. -; Zero and positive values are handled by getaddrinfo_done. - test eax, eax - jns getaddrinfo_done -.nothing: - ret -.connecting: -; We are connecting to the server, and socket status has changed. - mcall 53, 6, [socket] -; Possible values for status: SYN_SENT=2, SYN_RECEIVED=3, ESTABLISHED=4, CLOSE_WAIT=7 -; First two mean that we are still connecting, and we must continue wait loop -; without status change. -; Last means that server has immediately closed the connection, -; and status becomes "disconnected". - cmp eax, 4 - jb .nothing - jz .established - and [status], 0 - call update_status -; close socket - mcall 53, 8 - ret -.established: -; The connection has been established, change status from "connecting" to "connected". - inc [status] - call update_status -; Fall through to .connected, because some data can be already in buffer. -.connected: - call read_incoming_data -; Handle closing socket by the server. - mcall 53, 6, [socket] - cmp eax, 4 - jnz disconnect - ret - -disconnect: -; Release all allocated resources. -; Exact actions depend on current status. - mov eax, [status] - dec eax -; 0 = STATUS_DISCONNECTED - do nothing - js .nothing -; 1 = STATUS_RESOLVING - jz .resolving -; 2 = STATUS_CONNECTING, 3 = STATUS_CONNECTED -; In both cases we should close the socket. - mcall 53, 8, [socket] - jmp .disconnected -.resolving: -; Let the network library handle abort of resolving process. - push gai_reqdata - call [getaddrinfo_abort] -.disconnected: -; In all cases, set status to "disconnected". - and [status], 0 - call update_status -.nothing: - ret - -msgbox_notify: - inc byte [msgbox_running] - mcall 60,2,[main_PID],0,1 - ret - -print_channel_list: - - pusha - - mov eax,13 - mov ebx,415*65536+6*13 - mov ecx,27*65536+12*10 - mov edx,0xffffff - mcall - - mov eax,4 - mov ebx,415*65536+27 - mov ecx,[index_list_1] - mov edx,channel_list+32 - newch: - movzx esi,byte [edx+31] - and esi,0x1f - mcall - add edx,32 - add ebx,12 - cmp edx,channel_list+32*10 - jbe newch - - no_channel_list: - - popa - - ret - - -print_user_list: - - pusha - - newtry: - - mov edx,ebp - imul edx,120*80 - add edx,120*60+8+I_END - cmp [edx],byte 1 - je nonp - - mov edx,ebp - imul edx,120*80 - add edx,120*70+I_END - mov edi,edx - - mov eax,[edx-8] - mov ebx,[edx-4] - add ebx,edx - sub ebx,3 - inc eax - dec edx - newnss: - inc edx - dec eax - jz startuu - asdf: - cmp [edx],word ' ' - jne nodouble - inc edx - nodouble: - cmp [edx],byte ' ' - je newnss - inc edx - cmp edx,ebx - jbe asdf - dec dword [edi-8] - - popa - ret - - startuu: - - cmp [edx],byte ' ' - jne startpr - inc edx - startpr: - - pusha - mov eax,13 - mov ebx,415*65536+6*13 - mov ecx,27*65536+12*10 - mov edx,0xffffff - mcall - popa - - mov eax,4 - mov ebx,415*65536+27 - - mov ebp,0 - newuser: - - mov esi,0 - newusers: - cmp [edx+esi],byte ' ' - je do_print - inc esi - cmp esi,20 - jbe newusers - do_print: - - mov ecx,[index_list_1] - cmp [edx],byte '@' - jne no_op - mov ecx,[index_list_2] - no_op: - - mcall - - inc ebp - cmp ebp,10 - je nonp - - add ebx,12 - - add edx,esi - - inc edx - cmp [edx],byte ' ' - jne newuser - inc edx - jmp newuser - - nonp: - - popa - - ret - - -start_user_list_at dd 0x0 - -recode_to_cp866: - rep movsb - ret - -recode_to_cp1251: - xor eax, eax - jecxz .nothing - .loop: - lodsb - cmp al,0x80 - jb @f - mov al,[cp866_table-0x80+eax] - @@: stosb - loop .loop - .nothing: - ret - -recode_to_utf8: - jecxz .nothing - .loop: - lodsb - cmp al, 0x80 - jb .single_byte - and eax, 0x7F - mov ax, [utf8_table+eax*2] - stosw - loop .loop - ret - .single_byte: - stosb - loop .loop - .nothing: - ret - -recode: - mov eax, [encoding] - jmp [recode_proc+eax*4] - -process_command: - - pusha - - mov eax,[xpos] - mov [send_string+eax+0],byte 13 - mov [send_string+eax+1],byte 10 - - mov eax,[rxs] - imul eax,11 - mov [pos],eax - mov eax,[send_to_channel] - imul eax,120*80 - add eax,I_END - mov [text_start],eax - - cmp [send_string],byte '/' ; server command - je server_command - -; Ignore data commands when not connected. - cmp [status], STATUS_CONNECTED - jnz sdts_ret - - mov bl,13 - call print_character - mov bl,10 - call print_character - mov bl,'<' - call print_character - - mov esi,user_nick+4 - mov ecx,[user_nick] - newnp: - mov bl,[esi] - call print_character - inc esi - loop newnp - - mov bl,'>' - call print_character - mov bl,' ' - call print_character - - mov ecx,[xpos] - mov esi,send_string - newcw: - mov bl,[esi] - call print_character - inc esi - loop newcw - - mov eax,dword [send_to_channel] - shl eax,5 - add eax,channel_list - mov esi,eax - - mov edi,send_string_header+8 - movzx ecx,byte [eax+31] - cld - rep movsb - - mov [edi],word ' :' - - mov esi, send_string_header - mov ecx,10 - movzx ebx,byte [eax+31] - add ecx,ebx - - mov edi, packetbuf - rep movsb - - mov esi,send_string - mov ecx,[xpos] - inc ecx - - call recode - - mov esi, packetbuf - mov edx, edi - sub edx, esi - mcall 53, 7, [socket] - - mov [xpos], 0 - jmp sdts_ret - - server_command: - - cmp [send_string+1],dword 'anic' - jne no_set_nick - - mov ecx,[xpos] - sub ecx,7 - cmp ecx,user_nick_max - jb @f - mov ecx,user_nick_max - @@: - mov [user_nick],ecx - - mov esi,send_string+7 - mov edi,user_nick+4 - cld - rep movsb - - pusha - mov edi,text+70*1+15 - mov al,32 - mov ecx,15 - cld - rep stosb - popa - - mov esi,user_nick+4 - mov edi,text+70*1+15 - mov ecx,[esi-4] - cld - rep movsb - - mov [xpos],0 - call draw_window - - popa - ret - - no_set_nick: - - cmp [send_string+1],dword 'area' - jne no_set_real_name - - mov ecx,[xpos] - sub ecx,7 - cmp ecx,user_real_name_max - jb @f - mov ecx,user_real_name_max - @@: - mov [user_real_name],ecx - - mov esi,send_string+7 - mov edi,user_real_name+4 - cld - rep movsb - - pusha - mov edi,text+70*0+15 - mov al,32 - mov ecx,15 - cld - rep stosb - popa - - mov esi,user_real_name+4 - mov edi,text+70*0+15 - mov ecx,[esi-4] - rep movsb - - mov [xpos],0 - call draw_window - - popa - ret - - no_set_real_name: - - cmp [send_string+1],dword 'aser' - jne no_set_server - - mov ecx,[xpos] - sub ecx,7 - - mov esi,send_string+7 - mov edi,irc_server_name - rep movsb - mov al,0 - stosb - - pusha - mov edi,text+70*2+15 - mov al,32 - mov ecx,15 - cld - rep stosb - popa - - mov ecx,[xpos] - sub ecx,7 - mov esi,send_string+7 - mov edi,text+70*2+15 - rep movsb - - mov [xpos],0 - call draw_window - - popa - ret - - no_set_server: - -; All other commands require a connection to the server. - cmp [status], STATUS_CONNECTED - jnz sdts_ret - - - cmp [send_string+1],dword 'quer' - jne no_query_create - - mov edi,I_END+120*80 - mov eax,1 ; create channel window - search for empty slot - newse2: - mov ebx,eax - shl ebx,5 - cmp dword [channel_list+ebx],dword ' ' - je free_found2 - add edi,120*80 - inc eax - cmp eax,[max_windows] - jb newse2 - - free_found2: - - mov edx,send_string+7 - - mov ecx,[xpos] - sub ecx,7 - mov [channel_list+ebx+31],cl - - call create_channel_name - - push edi - push eax - mov [edi+120*60+8],byte 1 ; query window - mov al,32 - mov ecx,120*60 - cld - rep stosb - pop eax - pop edi - - ; eax has the free position -; mov [thread_screen],edi - call create_channel_window - - mov [xpos],0 - - popa - ret - - no_query_create: - - - mov esi, send_string+1 - mov ecx, [xpos] - inc ecx - mov edi, packetbuf - call recode - mov esi, packetbuf - mov edx, edi - sub edx, esi - - mov eax, 53 ; write server command - mov ebx, 7 - mov ecx, [socket] - mcall - - send_done: - - mov [xpos],0 - - cmp [send_string+1],dword 'quit' - jne no_quit_server - mov eax,5 - mov ebx,200 - mcall - - mov eax, 53 ; close socket - mov ebx, 8 - mov ecx, [socket] - mcall - - mov ecx,[max_windows] - mov edi,I_END - newclose: - mov [edi+120*60+4],byte 1 - call notify_channel_thread - add edi,120*80 - loop newclose - - popa - ret - - no_quit_server: - - sdts_ret: - - popa - ret - -get_next_byte: -; Load next byte from the packet, translating to cp866 if necessary -; At input esi = pointer to data, edx = limit of data -; Output is either (translated) byte in al with CF set or CF cleared. - mov eax, [encoding] - jmp [get_byte_table+eax*4] - -get_byte_cp866: - cmp esi, edx - jae .nothing - lodsb -.nothing: - ret - -get_byte_cp1251: - cmp esi, edx - jae .nothing - lodsb - cmp al, 0x80 - jb @f - and eax, 0x7F - mov al, [cp1251_table+eax] -@@: - stc -.nothing: - ret - -get_byte_utf8: -; UTF8 decoding is slightly complicated. -; One character can occupy one or more bytes. -; The boundary in packets theoretically can be anywhere in data, -; so this procedure keeps internal state between calls and handles -; one byte at a time, looping until character is read or packet is over. -; Globally, there are two distinct tasks: decode byte sequence to unicode char -; and convert this unicode char to our base encoding (that is cp866). -; 1. Check that there are data. - cmp esi, edx - jae .nothing -; 2. Load byte. - lodsb - movzx ecx, al -; 3. Bytes in an UTF8 sequence can be of any of three types. -; If most significant bit is cleared, sequence is one byte and usual ASCII char. -; First byte of a sequence must be 11xxxxxx, other bytes are 10yyyyyy. - and al, 0xC0 - jns .single_byte - jp .first_byte -; 4. This byte is not first in UTF8 sequence. -; 4a. Check that the sequence was started. If no, it is invalid byte -; and we simply ignore it. - cmp [utf8_bytes_rest], 0 - jz get_byte_utf8 -; 4b. Otherwise, it is really next byte and it gives some more bits of char. - mov eax, [utf8_char] - shl eax, 6 - lea eax, [eax+ecx-0x80] -; 4c. Decrement number of bytes rest in the sequence. -; If it goes to zero, character is read, so return it. - dec [utf8_bytes_rest] - jz .got_char - mov [utf8_char], eax - jmp get_byte_utf8 -; 5. If the byte is first in UTF8 sequence, calculate the number of leading 1s -; - it equals total number of bytes in the sequence; some other bits rest for -; leading bits in the character. -.first_byte: - mov eax, -1 -@@: - inc eax - add cl, cl - js @b - mov [utf8_bytes_rest], eax - xchg eax, ecx - inc ecx - shr al, cl - mov [utf8_char], eax - jmp get_byte_utf8 -; 6. If the byte is ASCII char, it is the character. -.single_byte: - xchg eax, ecx -.got_char: -; We got the character, now abandon a possible sequence in progress. - and [utf8_bytes_rest], 0 -; Now second task. The unicode character is in eax, and now we shall convert it -; to cp866. - cmp eax, 0x80 - jb .done -; 0x410-0x43F -> 0x80-0xAF, 0x440-0x44F -> 0xE0-0xEF, 0x401 -> 0xF0, 0x451 -> 0xF1 - cmp eax, 0x401 - jz .YO - cmp eax, 0x451 - jz .yo - cmp eax, 0x410 - jb .unrecognized - cmp eax, 0x440 - jb .part1 - cmp eax, 0x450 - jae .unrecognized - sub al, (0x40-0xE0) and 0xFF - ret -.part1: - sub al, 0x10-0x80 -.nothing: -.done: - ret -.unrecognized: - mov al, '?' - stc - ret -.YO: - mov al, 0xF0 - stc - ret -.yo: - mov al, 0xF1 - stc - ret - -read_incoming_data: - pusha -.packetloop: -.nextpacket: - mcall 53, 11, [socket], packetbuf, 1024 - test eax, eax - jz .nothing - mov esi, edx ; esi = pointer to data - add edx, eax ; edx = limit of data -.byteloop: - call get_next_byte - jnc .nextpacket - cmp al, 10 - jne .no_start_command - mov [cmd], 1 -.no_start_command: - cmp al, 13 - jne .no_end_command - mov ebx, [cmd] - mov byte [ebx+command-2], 0 - call analyze_command - mov edi, command - mov ecx, 250 - xor eax, eax - rep stosb - mov [cmd], eax - mov al, 13 -.no_end_command: - mov ebx, [cmd] - cmp ebx, 512 - jge @f - mov [ebx+command-2], al - inc [cmd] -@@: - jmp .byteloop -.nothing: - popa - ret - - -create_channel_name: - - pusha - - search_first_letter: - cmp [edx],byte ' ' - jne first_letter_found - inc edx - jmp search_first_letter - first_letter_found: - - mov esi,edx - mov edi,channel_list - add edi,ebx - mov ecx,30 - xor eax,eax - newcase: - mov al,[esi] - cmp eax,'a' - jb nocdec - cmp eax,'z' - jg nocdec - sub al,97-65 - nocdec: - mov [edi],al - inc esi - inc edi - loop newcase - - popa - - ret - - -create_channel_window: - - pusha - - mov [cursor_on_off],0 - -; mov [thread_nro],eax - - mov edx,[thread_stack] - sub edx,8 - mov [edx],eax - mov [edx+4],edi - mov eax,51 - mov ebx,1 - mov ecx,channel_thread - mcall - mov [edi+120*60+12], eax - - add [thread_stack],0x4000 -; add [thread_screen],120*80 - - popa - - ret - - -print_entry: - - pusha - - mov eax,13 - mov ebx,8*65536+6*80 - mov ecx,151*65536+13 - mov edx,0xffffff - mcall - - mov eax,4 - mov ebx,8*65536+154 - mov ecx,0x000000 - mov edx,send_string - mov esi,[xpos] - mcall - - popa - -; Fall through to draw_cursor. -; ret - -draw_cursor: - - pusha - - mov eax,9 - mov ebx,0xe0000 - mov ecx,-1 - mcall - - cmp ax,word [0xe0000+4] - setnz dl - movzx edx,dl - neg edx - and edx,0xffffff -; jne no_blink - -; call print_entry - - mov ebx,[xpos] - imul ebx,6 - add ebx,8 - mov cx,bx - shl ebx,16 - mov bx,cx - mov ecx,151*65536+163 - mov eax,38 - mcall - - popa - - ret - -; no_blink: -; -; mov eax,13 -; mov ebx,8*65536+6*60 -; mov ecx,151*65536+13 -; mov edx,0xffffff -; mcall - - popa - - ret - - - - - -set_channel: - - pusha - - ; UPPER / LOWER CASE CHECK - - mov esi,eax - mov edi,channel_temp - mov ecx,40 - xor eax,eax - newcase2: - mov al,[esi] - cmp eax,'#' - jb newcase_over2 - cmp eax,'a' - jb nocdec2 - cmp eax,'z' - jg nocdec2 - sub al,97-65 - nocdec2: - mov [edi],al - inc esi - inc edi - loop newcase2 - newcase_over2: - sub edi,channel_temp - mov [channel_temp_length],edi - - mov eax,channel_temp - - mov [text_start],I_END+120*80 - mov ebx,channel_list+32 - mov eax,[eax] - - mov edx,[channel_temp_length] - - stcl1: - cmp dl,[ebx+31] - jne notfound - - pusha - xor eax,eax - xor edx,edx - mov ecx,0 - stc4: - mov dl,[ebx+ecx] - mov al,[channel_temp+ecx] - cmp eax,edx - jne notfound2 - inc ecx - cmp ecx,[channel_temp_length] - jb stc4 - popa - - jmp found - - notfound2: - popa - - notfound: - add [text_start],120*80 - add ebx,32 - cmp ebx,channel_list+19*32 - jb stcl1 - - mov [text_start],I_END - - found: - - popa - - ret - - -channel_temp: times 100 db 0 -channel_temp_length dd 0x0 - - - -print_nick: - - pusha - - mov eax,command+1 - mov dl,'!' - call print_text - - popa - ret - - -analyze_command: - - pusha - - mov [text_start],I_END - mov ecx,[rxs] - imul ecx,11 - mov [pos],ecx - -; mov bl,13 -; call print_character -; mov bl,10 -; call print_character - -; mov ecx,[cmd] -; sub ecx,2 -; mov esi,command+0 -; newcmdc: -; mov bl,[esi] -; call print_character -; inc esi -; loop newcmdc - - mov edx,I_END -; call draw_channel_text - -; cmp [cmd],20 -; jge cmd_len_ok -; -; mov [cmd],0 -; -; popa -; ret - - - cmd_len_ok: - - cmp [command],dword 'PING' ; ping response - jne no_ping_responce - - call print_command_to_main - - mov [command],dword 'PONG' - - call print_command_to_main - - mov eax,4 - mov ebx,100*65536+3 - mov ecx,0xffffff - mov edx,command - mov esi,[cmd] - mov [command+esi-1],word '**' -; mcall - - mov eax,53 - mov ebx,7 - mov ecx,[socket] - mov edx,[cmd] - mov esi,command - mov word [esi+edx-2], 0x0a0d - mcall - - popa - ret - - no_ping_responce: - - mov eax,[rxs] - imul eax,11 - mov [pos],eax - - mov [command],byte '<' - - mov eax,command - mov ecx,100 - new_blank: - cmp [eax],byte ' ' - je bl_found - inc eax - loop new_blank - mov eax,50 - bl_found: - - inc eax - mov [command_position],eax - - mov esi,eax - mov edi,irc_command - mov ecx,8 - cld - rep movsb - - - cmp [irc_command],'PRIV' ; message to channel - jne no_privmsg - - ; compare nick - - mov eax,[command_position] - add eax,8 - call compare_to_nick - cmp [cresult],0 - jne no_query_msg - mov eax,command+1 - no_query_msg: - call set_channel - - mov ecx,100 ; [cmd] - mov eax,command+10 - acl3: - cmp [eax],byte ':' - je acl4 - inc eax - loop acl3 - mov eax,10 - acl4: - inc eax - - cmp [eax+1],dword 'ACTI' - jne no_action - push eax - mov eax,action_header_short - mov dl,0 - call print_text - mov eax,command+1 - mov dl,'!' - call print_text - mov bl,' ' - call print_character - pop eax - add eax,8 - mov dl,0 - call print_text - call notify_channel_thread - popa - ret - - no_action: - - push eax - mov bl,10 - call print_character - mov eax,command - mov dl,'!' - call print_text - mov bl,'>' - call print_character - mov bl,' ' - call print_character - pop eax - - mov dl,0 - call print_text - call notify_channel_thread - - popa - ret - - no_privmsg: - - - cmp [irc_command],'PART' ; channel leave - jne no_part - - ; compare nick - - mov eax,command+1 - call compare_to_nick - cmp [cresult],0 - jne no_close_window - - mov eax,[command_position] - add eax,5 - call set_channel - - mov edi,[text_start] - mov [edi+120*60+4],byte 1 - call notify_channel_thread - - popa - ret - - no_close_window: - - mov eax,[command_position] - add eax,5 - call set_channel - - mov eax,action_header_red - mov dl,0 - call print_text - mov eax,command+1 - mov dl,'!' - mov cl,' ' - call print_text - mov eax,has_left_channel - mov dl,0 - call print_text - mov eax,[command_position] - add eax,5 - mov dl,' ' - call print_text - call notify_channel_thread - - popa - ret - - no_part: - - - cmp [irc_command],'JOIN' ; channel join - jne no_join - - ; compare nick - - mov eax,command+1 - call compare_to_nick - cmp [cresult],0 - jne no_new_window - - mov edi,I_END+120*80 - mov eax,1 ; create channel window - search for empty slot - newse: - mov ebx,eax - shl ebx,5 - cmp dword [channel_list+ebx],dword ' ' - je free_found - add edi,120*80 - inc eax - cmp eax,[max_windows] - jb newse - - free_found: - - mov edx,[command_position] - add edx,6 - - push eax - push edx - mov ecx,0 - finde: - inc ecx - inc edx - movzx eax,byte [edx] - cmp eax,'#' - jge finde - mov [channel_list+ebx+31],cl - pop edx - pop eax - - call create_channel_name - - push edi - push eax - mov [edi+120*60+8],byte 0 ; channel window - mov al,32 - mov ecx,120*60 - cld - rep stosb - pop eax - pop edi - - ; eax has the free position -; mov [thread_screen],edi - call create_channel_window - - no_new_window: - - mov eax,[command_position] - add eax,6 - call set_channel - - mov eax,action_header_blue - mov dl,0 - call print_text - mov eax,command+1 - mov dl,'!' - mov cl,' ' - call print_text - - mov eax,joins_channel - mov dl,0 - call print_text - - mov eax,[command_position] - add eax,6 - mov dl,0 - call print_text - call notify_channel_thread - - popa - ret - - no_join: - - - cmp [irc_command],'NICK' ; nick change - jne no_nick_change - - add [command_position], 6 -; test for change of my nick - mov esi, command+1 - mov edi, user_nick+4 - mov ecx, [edi-4] - repz cmpsb - jnz .notmy - cmp byte [esi], '!' - jnz .notmy -; yes, this is my nick, set to new - mov esi, [command_position] - or ecx, -1 - mov edi, esi - xor eax, eax - repnz scasb - not ecx - dec ecx - cmp ecx, user_nick_max - jb @f - mov ecx, user_nick_max -@@: - mov edi, user_nick+4 - mov [edi-4], ecx - rep movsb - - mov edi, text+70*1+15 - mov al, ' ' - mov cl, 15 - push edi - rep stosb - pop edi - mov esi, user_nick+4 - mov ecx, [esi-4] - cmp ecx, 15 - jb @f - mov ecx, 15 -@@: - rep movsb - mov [xpos], 0 - call draw_window -.notmy: -; replace nick in all lists of users - mov ebx, I_END + 120*70 -.channels: - mov esi, ebx - mov edx, [esi-4] - add edx, esi -.nicks: - mov edi, command+1 - cmp byte [esi], '@' - jnz @f - inc esi -@@: - cmp esi, edx - jae .srcdone - lodsb - cmp al, ' ' - jz .srcdone - scasb - jz @b -@@: - cmp esi, edx - jae .nextchannel - lodsb - cmp al, ' ' - jnz @b -.nextnick: - cmp esi, edx - jae .nextchannel - lodsb - cmp al, ' ' - jz .nextnick - dec esi - jmp .nicks -.srcdone: - cmp byte [edi], '!' - jnz .nextnick -; here we have esi -> end of nick which must be replaced to [command_position]+6 - lea edx, [edi-command-1] - sub esi, edx - or ecx, -1 - xor eax, eax - mov edi, [command_position] - repnz scasb - not ecx - dec ecx - push ecx - cmp ecx, edx - jb .decrease - jz .copy -.increase: -; new nick is longer than the old - push esi - lea edi, [ebx+120*10] - lea esi, [edi+edx] - sub esi, ecx - mov ecx, esi - sub ecx, [esp] - dec esi - dec edi - std - rep movsb - cld - pop esi - jmp .copy -.decrease: -; new nick is shorter than the old - push esi - lea edi, [esi+ecx] - add esi, edx - lea ecx, [ebx+120*10] - sub ecx, edi - rep movsb - pop esi -.copy: -; copy nick - mov edi, esi - dec edi - mov esi, [command_position] - pop ecx - sub edx, ecx - sub [ebx-4], edx - rep movsb - mov al, ' ' - stosb -.nextchannel: - add ebx, 120*80 - cmp ebx, I_END + 120*70 + 120*80*19 - jb .channels - - mov [text_start],I_END - add [text_start],120*80 - - new_all_channels3: - - mov eax,action_header_short - mov dl,0 - call print_text - mov eax,command+1 - mov dl,'!' - call print_text - mov eax,is_now_known_as - mov dl,0 - call print_text - mov eax,[command_position] - mov dl,0 - call print_text - call notify_channel_thread - - add [text_start],120*80 - cmp [text_start],I_END+120*80*20 - jb new_all_channels3 - - popa - ret - - no_nick_change: - - - cmp [irc_command],'KICK' ; kick - jne no_kick - - mov [text_start],I_END - add [text_start],120*80 - - mov eax,[command_position] - add eax,5 - call set_channel - -; new_all_channels4: - - mov eax,action_header_short - mov dl,0 - call print_text - mov eax,command+1 - mov dl,'!' - call print_text - mov eax,kicked - mov dl,0 - call print_text - mov eax,[command_position] - add eax,5 - mov dl,0 - call print_text - call notify_channel_thread - -; add [text_start],120*80 -; cmp [text_start],I_END+120*80*20 -; jb new_all_channels4 - - popa - ret - - no_kick: - - - - - cmp [irc_command],'QUIT' ; irc quit - jne no_quit - - mov [text_start],I_END - add [text_start],120*80 - - new_all_channels2: - - mov eax,action_header_red - mov dl,0 - call print_text - mov eax,command+1 - mov dl,'!' - call print_text - mov eax,has_quit_irc - mov dl,0 - call print_text - call notify_channel_thread - - add [text_start],120*80 - cmp [text_start],I_END+120*80*20 - jb new_all_channels2 - - popa - ret - - no_quit: - - - cmp [irc_command],dword 'MODE' ; channel mode change - jne no_mode - - mov [text_start],I_END - add [text_start],120*80 - - mov eax,[command_position] - add eax,5 - call set_channel - - new_all_channels: - - mov eax,action_header_short - mov dl,0 - call print_text - - call print_nick - - mov eax,sets_mode - mov dl,0 - call print_text - - mov eax,[command_position] - add eax,5 - mov dl,0 - call print_text - call notify_channel_thread - -; add [text_start],120*80 -; cmp [text_start],I_END+120*80*20 -; jb new_all_channels - - popa - ret - - no_mode: - - - cmp [irc_command],dword '353 ' ; channel user names - jne no_user_list - - mov eax,[command_position] - finde2: - inc eax - cmp [eax],byte '#' - jne finde2 - call set_channel - - finde3: - inc eax - cmp [eax],byte ':' - jne finde3 - - pusha - cmp [user_list_pos],0 - jne no_clear_user_list - mov edi,[text_start] - add edi,120*70 - mov [edi-8],dword 0 - mov [edi-4],dword 0 - mov al,32 - mov ecx,1200 - cld - rep stosb - no_clear_user_list: - popa - - push eax - - mov esi,eax - inc esi - mov edi,[text_start] - add edi,120*70 - add edi,[user_list_pos] - mov edx,edi - mov ecx,command - add ecx,[cmd] - sub ecx,[esp] - sub ecx,3 - and ecx,0xfff - cld - rep movsb - - pop eax - mov ebx,command - add ebx,[cmd] - sub ebx,eax - sub ebx,2 - mov [edx+ebx-1],dword ' ' - - add [user_list_pos],ebx - - mov eax,[user_list_pos] - mov ebx,[text_start] - add ebx,120*70 - mov [ebx-4],eax - call notify_channel_thread - - popa - ret - - user_list_pos dd 0x0 - - no_user_list: - - - cmp [irc_command],dword '366 ' ; channel user names end - jne no_user_list_end - - mov [user_list_pos],0 - - popa - ret - - no_user_list_end: - - mov [command],byte '-' - call print_command_to_main - - popa - - ret - - -cresult db 0 - -compare_to_nick: - -; input : eax = start of compare -; output : [cresult] = 0 if match, [cresult]=1 if no match - - - pusha - - mov esi,eax - mov edi,0 - - new_nick_compare: - - mov bl,byte [esi] - mov cl,byte [user_nick+4+edi] - - cmp bl,cl - jne nonickm - - add esi,1 - add edi,1 - - cmp edi,[user_nick] - jb new_nick_compare - - movzx eax,byte [esi] - cmp eax,40 - jge nonickm - - popa - mov [cresult],0 - ret - - nonickm: - - popa - mov [cresult],1 - ret - - - - - -print_command_to_main: - - pusha - - mov [text_start],I_END - mov ecx,[rxs] - imul ecx,11 - mov [pos],ecx - - mov bl,13 - call print_character - mov bl,10 - call print_character - - mov ecx,[cmd] - sub ecx,2 - mov esi,command - newcmdc2: - mov bl,[esi] - call print_character - inc esi - loop newcmdc2 - - mov edx,I_END - call draw_channel_text - - popa - - ret - - - - -print_text: - - pusha - - mov ecx,command-2 - add ecx,[cmd] - - ptr2: - mov bl,[eax] - cmp bl,dl - je ptr_ret - cmp bl,0 - je ptr_ret - call print_character - inc eax - cmp eax,ecx - jbe ptr2 - - ptr_ret: - - mov eax,[text_start] - mov [eax+120*60],byte 1 - - popa - ret - - -cp1251_table: - db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; 8 - db '?','?','?','?','?',$F9,'?','?' , '?','?','?','?','?','?','?','?' ; 9 - db '?',$F6,$F7,'?',$FD,'?','?','?' , $F0,'?',$F2,'?','?','?','?',$F4 ; A - db $F8,'?','?','?','?','?','?',$FA , $F1,$FC,$F3,'?','?','?','?',$F5 ; B - db $80,$81,$82,$83,$84,$85,$86,$87 , $88,$89,$8A,$8B,$8C,$8D,$8E,$8F ; C - db $90,$91,$92,$93,$94,$95,$96,$97 , $98,$99,$9A,$9B,$9C,$9D,$9E,$9F ; D - db $A0,$A1,$A2,$A3,$A4,$A5,$A6,$A7 , $A8,$A9,$AA,$AB,$AC,$AD,$AE,$AF ; E - db $E0,$E1,$E2,$E3,$E4,$E5,$E6,$E7 , $E8,$E9,$EA,$EB,$EC,$ED,$EE,$EF ; F - -; 0 1 2 3 4 5 6 7 8 9 A B C D E F - -utf8_table: - times 80h dw 0x98C3 ; default placeholder -; 0x80-0xAF -> 0x90D0-0xBFD0 -repeat 0x30 -store byte 0xD0 at utf8_table+2*(%-1) -store byte 0x90+%-1 at utf8_table+2*%-1 -end repeat -; 0xE0-0xEF -> 0x80D1-0x8FD1 -repeat 0x10 -store byte 0xD1 at utf8_table+2*(0xE0-0x80+%-1) -store byte 0x80+%-1 at utf8_table+2*(0xE0-0x80+%)-1 -end repeat -; 0xF0 -> 0x81D0, 0xF1 -> 0x91D1 -store dword 0x91D181D0 at utf8_table+2*(0xF0-0x80) - -cp866_table: - db $C0,$C1,$C2,$C3,$C4,$C5,$C6,$C7 , $C8,$C9,$CA,$CB,$CC,$CD,$CE,$CF ; 8 - db $D0,$D1,$D2,$D3,$D4,$D5,$D6,$D7 , $D8,$D9,$DA,$DB,$DC,$DD,$DE,$DF ; 9 - db $E0,$E1,$E2,$E3,$E4,$E5,$E6,$E7 , $E8,$E9,$EA,$EB,$EC,$ED,$EE,$EF ; A - db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; B - db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; C - db '?','?','?','?','?','?','?','?' , '?','?','?','?','?','?','?','?' ; D - db $F0,$F1,$F2,$F3,$F4,$F5,$F6,$F7 , $F8,$F9,$FA,$FB,$FC,$FD,$FE,$FF ; E - db $A8,$B8,$AA,$BA,$AF,$BF,$A1,$A2 , $B0,$95,$B7,'?',$B9,$A4,'?','?' ; F - -; 0 1 2 3 4 5 6 7 8 9 A B C D E F - -print_character: - - pusha - - cmp bl,13 ; line beginning - jne nobol - mov ecx,[pos] - add ecx,1 - boll1: - sub ecx,1 - mov eax,ecx - xor edx,edx - mov ebx,[rxs] - div ebx - cmp edx,0 - jne boll1 - mov [pos],ecx - jmp newdata - nobol: - - cmp bl,10 ; line down - jne nolf - addx1: - add [pos],dword 1 - mov eax,[pos] - xor edx,edx - mov ecx,[rxs] - div ecx - cmp edx,0 - jnz addx1 - mov eax,[pos] - jmp cm1 - nolf: - no_lf_ret: - - - cmp bl,15 ; character - jbe newdata - - mov eax,[irc_data] - shl eax,8 - mov al,bl - mov [irc_data],eax - - mov eax,[pos] - call draw_data - - mov eax,[pos] - add eax,1 - cm1: - mov ebx,[scroll+4] - imul ebx,[rxs] - cmp eax,ebx - jb noeaxz - - mov esi,[text_start] - add esi,[rxs] - - mov edi,[text_start] - mov ecx,ebx - cld - rep movsb - - mov esi,[text_start] - mov ecx,[rxs] - imul ecx,61 - add esi,ecx - - mov edi,[text_start] - mov ecx,[rxs] - imul ecx,60 - add edi,ecx - mov ecx,ebx - cld - rep movsb - - mov eax,ebx - sub eax,[rxs] - noeaxz: - mov [pos],eax - - newdata: - - mov eax,[text_start] - mov [eax+120*60],byte 1 - - popa - ret - -notify_channel_thread: - pusha - mov eax, [text_start] - mov ecx, [eax+120*60+12] - mcall 60, 2, , 0, 1 - popa - ret - - -draw_data: - - pusha - - and ebx,0xff - add eax,[text_start] - mov [eax],bl - - popa - ret - - - -draw_window: - - pusha - - mov eax,12 - mov ebx,1 - mcall - - xor eax,eax ; draw window - mov ebx,5*65536+499 - mov ecx,5*65536+381 - mov edx,[wcolor] - add edx,0x14ffffff - mov edi,title - mcall - - mov eax,8 ; button: change encoding - mov ebx,(ENCODING_X-2)*65536+38 - mov ecx,(ENCODING_Y-2)*65536+12 - mov edx,21 - mov esi,[main_button] - mcall - -; mov eax,8 ; button: open socket - mov ebx,43*65536+22 - mov ecx,241*65536+10 -; mov edx,22 - inc edx - mcall - - ;mov eax,8 ; button: send userinfo - mov ebx,180*65536+22 - mov ecx,241*65536+10 -; mov edx,23 - inc edx - mcall - - ;mov eax,8 ; button: close socket - mov ebx,317*65536+22 - mov ecx,241*65536+10 -; mov edx,24 - inc edx - mcall - - mov eax,38 ; line - mov ebx,5*65536+494 - mov ecx,148*65536+148 - mov edx,[main_line] - mcall - add ecx,1*65536+1 - - mov eax,38 ; line - mov ebx,5*65536+494 - mov ecx,166*65536+166 - mcall - add ecx,1*65536+1 - - mov eax,38 ; line - mov ebx,410*65536+410 - mov ecx,22*65536+148 - mcall - add ebx,1*65536+1 - - mov ebx,25*65536+183 ; info text - mov ecx,0x000000 - mov edx,text - mov esi,70 - newline: - mov eax,4 - mcall - add ebx,12 - add edx,70 - cmp [edx],byte 'x' - jne newline - - mov edx,I_END ; text from server - call draw_channel_text - - call print_entry - - mov eax,12 - mov ebx,2 - mcall - - popa - - ret - -update_status: - pusha - mov esi, [status] - mov edi, text + 7*70 + 22 - mov ecx, status_text_len - push ecx - imul esi, ecx - add esi, status_text - mov edx, edi - rep movsb - pop esi - mcall 4, STATUS_X*65536+STATUS_Y, 0x40000000, , , 0xFFFFFF - popa - ret - -update_encoding: - pusha - mov edx, 21 - mcall 8 ; delete button - mov esi, [main_button] - mcall , <(ENCODING_X-2),38>, <(ENCODING_Y-2),12> ; recreate it - mov esi, [encoding] - mov edi, text + 3*70 + 15 - mov ecx, encoding_text_len - push ecx - imul esi, ecx - add esi, encoding_text - mov edx, edi - rep movsb - pop esi - mcall 4, ENCODING_X*65536+ENCODING_Y, 0 - popa - ret - -main_line dd 0x000000 -main_button dd 0x6565cc - -if lang eq ru -text: -db ' Ваше имя : KolibriOS User - меняйте так: /areal Jill User ' -db ' Ник : kolibri_user - меняйте так: /anick Jill ' -db ' Сервер : freenode.net - меняйте так: /aserv irc.by ' -db ' Кодировка : UTF-8 ' -db ' ' -db ' 1) Connect 2) Send userinfo 3) Disconnect ' -db ' ' -db ' Статус соединения: не соединено ' -db ' ' -db ' Команды, доступные после установки соединения: ' -db ' ' -db ' /join #ChannelName - например: /join #kolibrios ' -db ' /part #ChannelName - например: /part #windows ' -db ' /query Nickname - например: /query Mary ' -db ' /quit - Покинуть сервер и закрыть сокет ' -db 'x' ; <- END MARKER, DONT DELETE - -status_text: -db 'не соединено ' -db 'получаю имя сервера... ' -db 'соединение... ' -db 'соединено ' -status_text_len = 24 - -encoding_text: -db 'CP866 ' -db 'CP1251' -db 'UTF-8 ' -encoding_text_len = 6 - -else -text: -db ' Real name : KolibriOS User - change with eg /areal Jill User ' -db ' Nick : kolibri_user - change with eg /anick Jill ' -db ' Server : freenode.net - change with eg /aserv irc.by ' -db ' Encoding : UTF-8 ' -db ' ' -db ' 1) Connect 2) Send userinfo 3) Disconnect ' -db ' ' -db ' Connection status: disconnected ' -db ' ' -db ' Commands after established connection: ' -db ' ' -db ' /join #ChannelName - eg /join #kolibrios ' -db ' /part #ChannelName - eg /part #windows ' -db ' /query Nickname - eg /query Mary ' -db ' /quit - Quit server and Close socket ' -db 'x' ; <- END MARKER, DONT DELETE - -status_text: -db 'disconnected ' -db 'resolving server name...' -db 'connecting... ' -db 'connected ' -status_text_len = 24 - -encoding_text: -db 'CP866 ' -db 'CP1251' -db 'UTF-8 ' -encoding_text_len = 6 -end if - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; -; CHANNEL THREADS -; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - - -channel_thread: - -; mov ebp,[thread_nro] - pop ebp - pop edx - - mov eax,ebp - shl eax,14 - add eax,0x80000 - mov esp,eax - -; mov edi,ebp ; clear thread memory -; imul edi,120*80 -; add edi,I_END -; mov ecx,120*80 -; mov al,32 -; cld -; rep stosb - -; Create IPC buffer in the stack. - push eax - push eax - push eax - push 8 - push 0 - mov ecx, esp - push edx - mcall 60, 1, , 20 - pop edx - mcall 40, 1100111b - -; mov edx,[thread_screen] - - thread_redraw: - call thread_draw_window - call draw_channel_text - call print_user_list - call print_entry - - w_t: - - mov esi,ebp - imul esi,120*80 - add esi,I_END - cmp [esi+120*60+4],byte 1 - jne no_channel_leave - mov [esi+120*60+4],byte 0 - mov edi,ebp - shl edi,5 - mov dword [channel_list+edi],dword ' ' - mov byte [channel_list+edi+31],byte 1 - mov eax,-1 - mcall - no_channel_leave: - - mcall 10 - dec eax - jz thread_redraw - dec eax - jz thread_key - dec eax - jz thread_end - cmp al,4 - jz thread_ipc - call check_mouse - jmp w_t - thread_end: - mov eax,17 - mcall - mov eax,ebp - imul eax,120*80 - add eax,I_END - cmp [eax+120*60+8],byte 0 ; channel window - je not_close - mov eax,ebp - shl eax,5 - add eax,channel_list - mov [eax],dword ' ' - mov [eax+31],byte 1 - mov eax,-1 - mcall - not_close: - mov [text_start],eax - mov eax,nocl - newcc: - mov bl,[eax] - call print_character - inc eax - cmp [eax],byte 0 - jne newcc - call draw_channel_text - jmp w_t - nocl: db 13,10,'To exit channel, use PART or QUIT command.',0 - thread_ipc: - mov byte [esp+4], 8 ; erase message from IPC buffer - no_end: - - cmp [edx+120*60],byte 1 - jne no_update - mov [edx+120*60],byte 0 - call draw_channel_text - no_update: - - call print_user_list - - nopri2: - - jmp w_t - - - -check_mouse: - - pusha - - mov eax,37 - mov ebx,1 - mcall - - mov ebx,eax - shr eax,16 - and ebx,0xffff - - cmp eax,420 - jb no_mouse - cmp eax,494 - jg no_mouse - - cmp ebx,145 - jg no_mouse - cmp ebx,23 - jb no_mouse - - - cmp ebx,100 - jb no_plus - mov eax,ebp - imul eax,120*80 - add eax,120*70+I_END - inc dword [eax-8] - call print_user_list - mov eax,5 - mov ebx,8 - mcall - jmp no_mouse - no_plus: - - cmp ebx,80 - jg no_mouse - mov eax,ebp - imul eax,120*80 - add eax,120*70+I_END - cmp dword [eax-8],dword 0 - je no_mouse - dec dword [eax-8] - call print_user_list - mov eax,5 - mov ebx,8 - mcall - - no_minus: - - no_mouse: - - popa - - ret - - - - -thread_key: - - mov eax,2 - mcall - - shr eax,8 - - cmp eax,8 - jne no_bks - cmp [xpos],0 - je w_t - dec [xpos] - call print_entry - jmp w_t - no_bks: - - cmp eax,20 - jbe no_character - mov ebx,[xpos] - mov [send_string+ebx],al - inc [xpos] - cmp [xpos],80 - jb xpok - mov [xpos],79 - xpok: - call print_entry - jmp w_t - no_character: - - cmp eax,13 - jne no_send - cmp [xpos],0 - je no_send - mov dword [send_to_channel],ebp - pusha - mcall 60,2,[main_PID],0,1 - wait_for_sending: - mov eax,5 - mov ebx,1 - mcall - cmp dword [ipcbuf+4],8 - jne wait_for_sending - popa - call draw_channel_text - call print_entry - jmp w_t - no_send: - - jmp w_t - - - - - - -draw_channel_text: - - pusha - - mov eax,4 - mov ebx,10*65536+26 - mov ecx,12 - mov esi,[rxs] - dct: - pusha - mov cx,bx - shl ecx,16 - mov cx,9 - mov eax,13 - mov ebx,10*65536 - mov bx,word [rxs] - imul bx,6 - mov edx,0xffffff - mcall - popa - push ecx - mov eax,4 - mov ecx,0 - cmp [edx],word '* ' - jne no_red - mov ecx,0x0000ff - no_red: - cmp [edx],word '**' - jne no_light_blue - cmp [edx+2],byte '*' - jne no_light_blue - mov ecx,0x0000ff - no_light_blue: - cmp [edx],byte '#' - jne no_blue - mov ecx,0x0000ff - no_blue: - mcall - add edx,[rxs] - add ebx,10 - pop ecx - loop dct - - popa - ret - - - - - -thread_draw_window: - - pusha - - mov eax,12 - mov ebx,1 - mcall - - mov ebx,ebp ; draw window - shl ebx,16+4 - xor eax,eax - mov ecx,ebx - mov bx,499 - mov cx,170 - - mov edx,[wcolor] - add edx,0x03ffffff - mov esi,0x80555599 - mov edi,0x00ffffff - - mcall - - mov eax,ebp ; label - add eax,48 - mov [labelc+14],al - mov eax,ebp - shl eax,5 - add eax,channel_list - mov esi,eax - mov edi,labelc+17 - movzx ecx,byte [eax+31] - cld - rep movsb - - mov esi,17 ; print label - movzx ebx,byte [eax+31] - add esi,ebx - mov eax,4 - mov ebx,9*65536+8 - mov ecx,0x00ffffff - mov edx,labelc - mcall - - mov eax,38 ; line - mov ebx,5*65536+494 - mov ecx,148*65536+148 - mov edx,[channel_line_sun] - mcall - add ecx,1*65536+1 - mov edx,[channel_line_shadow] - mcall - - - ;mov eax,38 ; line - mov ebx,410*65536+410 - mov ecx,22*65536+148 - mov edx,[channel_line_sun] - mcall - add ebx,1*65536+1 - mov edx,[channel_line_shadow] - mcall - - mov eax,12 - mov ebx,2 - mcall - - popa - - ret - - -; DATA AREA - -socket dd 0x0 - -bgc dd 0x000000 - dd 0x000000 - dd 0x00ff00 - dd 0x0000ff - dd 0x005500 - dd 0xff00ff - dd 0x00ffff - dd 0x770077 - -tc dd 0xffffff - dd 0xff00ff - dd 0xffffff - dd 0xffffff - dd 0xffffff - dd 0xffffff - dd 0xffffff - dd 0xffffff - -channel_line_sun dd 0x9999ff -channel_line_shadow dd 0x666699 - -cursor_on_off dd 0x0 - -max_windows dd 20 - -thread_stack dd 0x9fff0 -;thread_nro dd 1 -;thread_screen dd I_END+120*80*1 - -action_header_blue db 10,'*** ',0 -action_header_red db 10,'*** ',0 - -action_header_short db 10,'* ',0 - -has_left_channel db ' has left ',0 -joins_channel db ' has joined ',0 -is_now_known_as db ' is now known as ',0 -has_quit_irc db ' has quit IRC',0 -sets_mode db ' sets mode ',0 -kicked db ' kicked from ',0 - -index_list_1 dd 0x0000bb -index_list_2 dd 0x0000ff - -posx dd 0x0 -incoming_pos dd 0x0 -incoming_string: times 128 db 0 - -pos dd 0x0 - -text_start dd I_END -irc_data dd 0x0 -print db 0x0 -cmd dd 0x0 -rxs dd 66 - -res: db 0,0 -command: times 600 db 0x0 - -nick dd 0,0,0 -irc_command dd 0,0 - -command_position dd 0x0 -counter dd 0 -send_to_server db 0 - -channel_list: times 32*20 db 32 -send_to_channel dd 0x0 - -send_string_header: db 'privmsg #eax :' - times 100 db 0x0 - -send_string: times 100 db 0x0 -xpos dd 0 - -string0: db 'USER guest ser1 ser2 :' -string0l: -string1: db 'nick ' -string1l: - -attribute dd 0 -scroll dd 1 - dd 12 - -numtext db ' ' - -wcolor dd 0x000000 - -labelc db 'AIRC - WINDOW X: #xxx ' -title db 'IRC client ',version,0 - -ipcbuf: - dd 0 - dd 8 - dd ? - dd ? - db ? -.size = $ - -align 4 -@IMPORT: - -library network, 'network.obj', msgbox, 'msgbox.obj' -import network, \ - getaddrinfo_start, 'getaddrinfo_start', \ - getaddrinfo_process, 'getaddrinfo_process', \ - getaddrinfo_abort, 'getaddrinfo_abort', \ - freeaddrinfo, 'freeaddrinfo' -import msgbox, mb_create, 'mb_create', mb_setfunctions, 'mb_setfunctions' - -msgbox_running db ? ; must be the byte before msgbox_struct - ; look to the handler of button 21 -msgbox_struct: -.default: - dw ? ; default button, will be filled with current encoding - db 'Encoding',0 - db 'Select encoding for all messages:',0 - db 'CP866',0 - db 'CP1251',0 - db 'UTF-8',0 - db 0 - -align 4 -status dd STATUS_DISCONNECTED -encoding dd UTF8 -recode_proc dd recode_to_cp866, recode_to_cp1251, recode_to_utf8 -get_byte_table dd get_byte_cp866, get_byte_cp1251, get_byte_utf8 -msgbox_func_array: -times 3 dd msgbox_notify -initialized_size: - -main_PID dd ? ; identifier of main thread -utf8_bytes_rest dd ? ; bytes rest in current UTF8 sequence -utf8_char dd ? ; first bits of current UTF8 character -gai_reqdata rb 32 ; buffer for getaddrinfo_start/process -ip_list dd ? ; will be filled as pointer to addrinfo list -irc_server_name rb 256 ; buffer for irc_server_name -packetbuf rb 1024 ; buffer for packets to server -mb_stack rb 1024 ; stack for messagebox thread - -;; -;; Channel data at I_END -;; -;; 120*80 * channel window (1+) -;; -;; At Size -;; -;; 00 , 120*60 window text 120 characters per row -;; 120*60 , 1 text is updated -;; 120*60+4 , 1 close yourself -;; 120*60+8 , 1 0 = channel window : 1 = private chat -;; 120*60+12 , 4 identifier of the thread -;; 120*61 , 256 channel name -;; 120*61+254 , 254 channel entry text from user -;; 120*61+255 , 1 length of entry text -;; 120*69+248 , 4 display names from n:th name -;; 120*69+252 , 4 length of names string -;; 120*70 , 1200 names separated with space -;; -I_END: diff --git a/programs/network_old/airc/trunk/build_en.bat b/programs/network_old/airc/trunk/build_en.bat deleted file mode 100644 index 3d976b72ec..0000000000 --- a/programs/network_old/airc/trunk/build_en.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix en >lang.inc -@fasm airc.asm airc -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/airc/trunk/build_ru.bat b/programs/network_old/airc/trunk/build_ru.bat deleted file mode 100644 index fbcd725c58..0000000000 --- a/programs/network_old/airc/trunk/build_ru.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix ru >lang.inc -@fasm airc.asm airc -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/airc/trunk/eth.inc b/programs/network_old/airc/trunk/eth.inc deleted file mode 100644 index aadf13252d..0000000000 --- a/programs/network_old/airc/trunk/eth.inc +++ /dev/null @@ -1,670 +0,0 @@ -; -; ETH.INC -; -; made by hidnplayr (hidnplayr@gmail.com) for KolibriOS and DEX4U -; -; The given code before every macro is only a simple example -; -; Change the OS value to DEX4U or MEOS -; -; HISTORY -; -; v1.0: 18 august 2006 -; - -MEOS equ 1 ; Dont change these ! -DEX4U equ 2 ; - -OS equ MEOS ; Change these instead ;) -TIMEOUT equ 60 ; timeout for DNS request -BUFFER equ 512 ; Buffer size for DNS - -macro int1 { - if OS eq MEOS - mcall - else if OS eq DEX4U - int 0x52 - end if -} - -macro int2 { - if OS eq MEOS - mcall - else if OS eq DEX4U - int 0x53 - end if -} - -macro mov arg1,arg2 { - - if arg1 eq arg2 - else - mov arg1,arg2 - end if - -} - -; eth.get_IP eax -; -; gets the current IP that is defined in Stack (return in eax in this example) -macro eth.get_IP IP { - if OS eq MEOS - mov eax,52 - end if - mov ebx,1 - int1 - - 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 { - if OS eq MEOS - mov eax,52 - end if - mov ebx,9 - int1 - 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 { - if OS eq MEOS - mov eax,52 - end if - mov ebx,10 - int1 - 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 { - if OS eq MEOS - mov eax,52 - end if - mov ebx,13 - int1 - 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 - if OS eq MEOS - mov eax,52 - end if - mov ebx,3 - int1 -} - -; eth.set_GATEWAY eax -; -; set a new GATEWAY in stack (input in eax in this example) -macro eth.set_GATEWAY GATEWAY { - mov ecx,GATEWAY - if OS eq MEOS - mov eax,52 - end if - mov ebx,11 - int1 -} - -; eth.set_SUBNET eax -; -; set a new SUBNET in stack (input in eax in this example) -macro eth.set_SUBNET SUBNET { - mov ecx,SUBNET - if OS eq MEOS - mov eax,52 - end if - mov ebx,12 - int1 -} - -; eth.set_DNS eax -; -; set a new DNS in stack (input in eax in this example) -macro eth.set_DNS DNS { - mov ecx,DNS - if OS eq MEOS - mov eax,52 - end if - mov ebx,14 - int1 -} - -; 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 local,remote,ip,socket { - mov ecx, local - mov edx, remote - mov esi, ip - if OS eq MEOS - mov eax,53 - end if - mov ebx, 0 - int2 - - mov socket,eax -} - -; eth.close [socket] -; -; closes socket on socketnumber [socket] -macro eth.close socket { - mov ecx, socket - if OS eq MEOS - mov eax,53 - end if - mov ebx, 1 - int2 -} - -; eth.poll [socket],eax -; -; polls [socket] for data -; eax = 0 when there is data -macro eth.poll socket,result { - mov ecx, socket - if OS eq MEOS - mov eax,53 - end if - mov ebx, 2 - int2 - - mov result, eax -} - -; eth.read_byte [socket], bl -; -; reads a byte from the socket and returns in bl -macro eth.read_byte socket, result { - mov ecx, socket - if OS eq MEOS - mov eax,53 - end if - mov ebx, 3 - int2 - - mov result,bl -} - -; eth.write [socket],12,msg -; msg db 'hello world!' -; -; send message msg to socket -macro eth.write socket,length,msg { - mov ecx, socket - mov edx, length - mov esi, msg - if OS eq MEOS - mov eax,53 - end if - mov ebx, 4 - int2 -} - -; 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 { - -pusha - mov ecx, local - mov edx, remote - mov esi, ip - mov edi, passive ; 0 = PASSIVE open - if OS eq MEOS - mov eax,53 - end if - mov ebx, 5 - int2 -popa - - mov socket,eax -} - -; eth.socket_status [socket],eax -; -; returns socket status in eax -macro eth.socket_status socket,result { - mov ecx, socket - if OS eq MEOS - mov eax,53 - end if - mov ebx, 6 - int2 - - 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 { - mov ecx, socket - mov edx, length - mov esi, msg - if OS eq MEOS - mov eax,53 - end if - mov ebx, 7 - int2 -} - -; eth.close_tcp [socket] -; -; closes tcp socket [socket] -macro eth.close_tcp socket { - mov ecx, socket - if OS eq MEOS - mov eax,53 - end if - mov ebx, 8 - int2 -} - -; eth.check_port 165,eax -; -; checks if port 165 is used -; return is 0 when port is free -macro eth.check_port port,result { - if OS eq MEOS - mov eax,53 - end if - mov ebx, 9 - mov ecx, port - int2 - - mov result,eax -} - -; eth.status eax -; -; returns socket status in eax -macro eth.status status { - if OS eq MEOS - mov eax,53 - end if - mov ebx, 255 - mov ecx, 6 - int2 - - 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 { - - mov eax, dest - mov endptr, eax - - ; we have data - this will be the response -@@: - mov eax,endptr - cmp eax,bufferl - jg @f - - mov eax, 53 - mov ebx, 3 - mov ecx, socket - mcall ; read byte - block (high byte) - - ; Store the data in the response buffer - mov eax, endptr - mov [eax], bl - inc dword endptr - - mov eax, 53 - mov ebx, 2 - mov ecx, socket - mcall ; any more data? - - cmp eax, 0 - jne @r ; yes, so get it -@@: - -} - -; 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,eax - - cmp eax,0 - jne @f - - dec edx - jz abort - - if OS eq MEOS - mov eax,5 ; wait here for event - mov ebx,100 - mcall - else if OS eq DEX4U - mov ax,18 - call [SetDelay] - call dword[stack_handler] - end if - - 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 -; resolve '192.168.0.1',IP -; resolve query2,IP -; -; query1 db 'www.google.com',0 -; query2 db '49.78.84.45',0 -; IP 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: - -;DEBUGF 1,'Resolving started\n' - - - ; 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],'.' ; 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 should convert this IP into a dword and output it in eax - - 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 - mov eax, edx - - ;DEBUGF 1,'The query was an IP: %x.%x.%x.%x\n',dh,dl,al,ah - - 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 ;) - - ;DEBUGF 1,'The query is no ip, Building request string from:%u\n',edx - - ; 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 edx,53,esi,[socketNum] ; First, open socket - ; DEBUGF 1,'Socket opened: %u (port %u)\n',[socketNum],ecx - eth.write [socketNum],[dnsMsgLen],dnsMsg ; Write to socket ( request DNS lookup ) - ; DEBUGF 1,'Data written, length:%u offset:%u\n',[dnsMsgLen],dnsMsg - ; DEBUGF 1,'Waiting for data: (timeout is %us)\n',TIMEOUT - eth.wait_for_data [socketNum],TIMEOUT,no_data; Now, we wait for data from remote - eth.read_data [socketNum],dnsMsg,[dnsMsgLen],dnsMsg+BUFFER ; Read the data into the buffer - ; DEBUGF 1,'Data received, offset:%u buffer size:%u length:%u\n',dnsMsg,BUFFER,esi-dnsMsg - eth.close [socketNum] ; We're done, close the socket - ; DEBUGF 1,'Closed Socket\n' - - ; 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 - - ;DEBUGF 1,'It was a response to my question\n' - - mov al, [esi+3] ; Were there any errors? - and al, 0x0F - cmp al, 0x00 - jne abort - - ;DEBUGF 1,'There were no errorst\n' - - 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] - - ;DEBUGF 1,'Found First Byte of IP\n' - - 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: - ;DEBUGF 1,'Something went wrong, aborting\n' - 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 - -no_data: - eth.close [socketNum] - xor eax,eax - - ret - -dnsMsgLen: dd 0 -socketNum: dd 0xFFFF - -if ~defined dnsMsg -dnsMsg: rb BUFFER -end if - -end if - - - - diff --git a/programs/network_old/airc/trunk/fdo.inc b/programs/network_old/airc/trunk/fdo.inc deleted file mode 100644 index 487a336cbd..0000000000 --- a/programs/network_old/airc/trunk/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/arpstat/trunk/arpstat.asm b/programs/network_old/arpstat/trunk/arpstat.asm deleted file mode 100644 index c620e00271..0000000000 --- a/programs/network_old/arpstat/trunk/arpstat.asm +++ /dev/null @@ -1,416 +0,0 @@ -; -; ARP Status Monitor -; -; Compile with FASM for Menuet -; -; This program displays the ARP table, and it's settings - -use32 - - org 0x0 - - db 'MENUET00' ; 8 byte id - dd 38 ; required os - dd START ; program start - dd I_END ; program image size - dd 0x100000 ; required amount of memory - dd 0x00000000 ; reserved=no extended header - include 'lang.inc' - include '..\..\..\macros.inc' - purge mov ; decrease kpack'ed size - -START: ; start of execution - call draw_window ; at first, draw the window - -still: - mov eax,23 ; wait here for event - mov ebx,200 ; Time out after 2s - mcall - - cmp eax,1 ; redraw request ? - jz red - cmp eax,2 ; key in buffer ? - jz key - cmp eax,3 ; button in buffer ? - jz button - - ; read the stack status data, and write it to the screen buffer - - mov eax, 53 - mov ebx, 255 - mov ecx, 200 - mcall - - push eax - mov ebx, text + 24 - call printhex - - mov eax, 53 - mov ebx, 255 - mov ecx, 201 - mcall - - mov ebx, text + 64 - call printhex - - - ; Fill the table with blanks - mov edi, text + 160 -doBlank: - mov esi, blank - mov ecx, 40 - rep movsb - - cmp edi, text + 560 - jne doBlank - - pop ecx ; The number of entries - - mov ebx, text+ 160 +1 ; the position for the first IP address line - - xor edx, edx ; edx is index into the ARP table - - cmp ecx, 10 - jle show_entries - mov ecx, 10 - - -; The following code is not very efficient; Sorry about that. -; ARPSTAT is a debugging tool, so I didn't want to put much effort in -show_entries: - ; Ecx now holds the number of entries to populate. - ; Ebx holds the place to put the data - ; edx is a counter - cmp ecx, 0 - je red - - push ecx - push edx - push ebx - - - ; select the arp table entry (in edx) - mov eax, 53 - mov ebx, 255 - mov ecx, 202 - mcall - - ; Read the IP address - mov eax, 53 - mov ebx, 255 - mov ecx, 203 - mcall - - ; IP in eax. Get the address to put it back - pop ebx - push ebx - - call writeDecimal ; Extract 1 byte from eax, store it in string - add ebx, 4 - shr eax, 8 - call writeDecimal ; Extract 1 byte from eax, store it in string - add ebx, 4 - shr eax, 8 - call writeDecimal ; Extract 1 byte from eax, store it in string - add ebx, 4 - shr eax, 8 - call writeDecimal ; Extract 1 byte from eax, store it in string - - add ebx, 4 - - ; Now display the 6 byte MAC - push ebx - mov eax, 53 - mov ebx, 255 - mov ecx, 204 - mcall - pop ebx - - mov ecx, eax - - shr eax, 4 - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - inc ebx - mov eax, ecx - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - inc ebx - mov eax, ecx - shr eax, 12 - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - inc ebx - mov eax, ecx - shr eax, 8 - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - inc ebx - mov eax, ecx - shr eax, 20 - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - inc ebx - mov eax, ecx - shr eax, 16 - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - inc ebx - mov eax, ecx - shr eax, 28 - mov al, [eax + hextable] - mov [ebx], al - inc ebx - mov eax, ecx - shr eax, 24 - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - inc ebx - - push ebx - mov eax, 53 - mov ebx, 255 - mov ecx, 205 - mcall - pop ebx - - mov ecx, eax - - shr eax, 4 - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - inc ebx - mov eax, ecx - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - inc ebx - mov eax, ecx - shr eax, 12 - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - inc ebx - mov eax, ecx - shr eax, 8 - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - - ; Now display the stat field - inc ebx - inc ebx - push ebx - mov eax, 53 - mov ebx, 255 - mov ecx, 206 - mcall - pop ebx - - mov ecx, eax - - shr eax, 4 - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - inc ebx - mov eax, ecx - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - inc ebx - mov eax, ecx - shr eax, 12 - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - inc ebx - mov eax, ecx - shr eax, 8 - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - - ; Now display the TTL field (this is intel word format) - inc ebx - inc ebx - push ebx - mov eax, 53 - mov ebx, 255 - mov ecx, 207 - mcall - pop ebx - - mov ecx, eax - - shr eax, 12 - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - inc ebx - mov eax, ecx - shr eax, 8 - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - inc ebx - mov eax, ecx - shr eax, 4 - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - inc ebx - mov eax, ecx - and eax, 0x0f - mov al, [eax + hextable] - mov [ebx], al - - - pop ebx - add ebx, 40 - pop edx - inc edx - pop ecx - dec ecx - jmp show_entries - -red: ; redraw - call draw_window - jmp still - -key: ; Keys are not valid at this part of the - mov eax,2 ; loop. Just read it and ignore - mcall - jmp still - -button: ; button - mov eax,17 ; get id - mcall - - cmp ah,1 ; button id=1 ? - jnz still - - mov eax,0xffffffff ; close this program - mcall - - -writeDecimal: - pusha - and eax, 0xff - mov dl, 100 - div dl - movzx ecx, ah - add al, '0' - mov [ebx], al - inc ebx - mov eax, ecx - mov dl, 10 - div dl - add ax, '00' - mov [ebx], ax - popa - ret - - -; ********************************************* -; ******* WINDOW DEFINITIONS AND DRAW ******** -; ********************************************* - - -draw_window: - - mov eax,12 ; function 12:tell os about windowdraw - mov ebx,1 ; 1, start of draw - mcall - - ; DRAW WINDOW - mov eax,0 ; function 0 : define and draw window - mov ebx,100*65536+280 ; [x start] *65536 + [x size] - mov ecx,100*65536+270 ; [y start] *65536 + [y size] - mov edx,0x14224466 ; color of work area RRGGBB - mov edi,title ; WINDOW LABEL - mcall - - - ; Re-draw the screen text - cld - mov eax,4 - mov ebx,25*65536+35 ; draw info text with function 4 - mov ecx,0xffffff - mov edx,text - mov esi,40 - newline: - mcall - add ebx,16 - add edx,esi - cmp [edx],byte 'x' - jnz newline - - - mov eax,12 ; function 12:tell os about windowdraw - mov ebx,2 ; 2, end of draw - mcall - - ret - -; Taken from PS.ASM -printhex: -; number in eax -; print to ebx -; xlat from hextable - pusha - mov esi, ebx - add esi, 8 - mov ebx, hextable - mov ecx, 8 -phex_loop: - mov edx, eax - and eax, 15 - xlatb - mov [esi], al - mov eax, edx - shr eax, 4 - dec esi - loop phex_loop - popa - ret - - -; DATA AREA - -text: - db ' Number of ARP entries: xxxxxxxx ' - db ' Maximum # of entries : xxxxxxxx ' - db ' ' - db ' IP Address MAC Stat TTL ' - db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' - db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' - db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' - db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' - db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' - db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' - db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' - db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' - db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' - db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' - db 'x' ; <- END MARKER, DONT DELETE - - -blank: - db ' xxx.xxx.xxx.xxx xxxxxxxxxxxx xxxx xxxx ' - - -title db 'ARP Table ( First 10 Entries )',0 - -hextable db '0123456789ABCDEF' - - -I_END: diff --git a/programs/network_old/arpstat/trunk/build_en.bat b/programs/network_old/arpstat/trunk/build_en.bat deleted file mode 100644 index 6953c4ef7d..0000000000 --- a/programs/network_old/arpstat/trunk/build_en.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix en >lang.inc -@fasm arpstat.asm arpstat -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/arpstat/trunk/build_ru.bat b/programs/network_old/arpstat/trunk/build_ru.bat deleted file mode 100644 index 4b24e0f662..0000000000 --- a/programs/network_old/arpstat/trunk/build_ru.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix ru >lang.inc -@fasm arpstat.asm arpstat -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/dhcp/trunk/build_en.bat b/programs/network_old/dhcp/trunk/build_en.bat deleted file mode 100644 index 04481fe022..0000000000 --- a/programs/network_old/dhcp/trunk/build_en.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix en >lang.inc -@fasm dhcp.asm dhcp -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/dhcp/trunk/build_ru.bat b/programs/network_old/dhcp/trunk/build_ru.bat deleted file mode 100644 index 670ab6d132..0000000000 --- a/programs/network_old/dhcp/trunk/build_ru.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix ru >lang.inc -@fasm dhcp.asm dhcp -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/dhcp/trunk/dhcp.asm b/programs/network_old/dhcp/trunk/dhcp.asm deleted file mode 100644 index abf9e8ff5e..0000000000 --- a/programs/network_old/dhcp/trunk/dhcp.asm +++ /dev/null @@ -1,582 +0,0 @@ -; -; DHCP Client -; -; Compile with FASM for Menuet -; - -include 'lang.inc' -include '..\..\..\macros.inc' - -use32 - - org 0x0 - - db 'MENUET01' ; 8 byte id - dd 0x01 ; header version - dd START ; start of code - dd I_END ; size of image - dd I_END+0x8000 ; memory for app - dd I_END+0x8000 ; esp - dd 0x0 , 0x0 ; I_Param , I_Icon - - -START: ; start of execution - mov eax,40 ; Report events - mov ebx,10000111b ; Stack 8 + defaults - int 0x40 - -red: ; redraw - call draw_window ; at first, draw the window - -still: - mov eax,10 ; wait here for event - mcall - - cmp eax,1 ; redraw request ? - jz red - cmp eax,2 ; key in buffer ? - jz key - cmp eax,3 ; button in buffer ? - jz button - - jmp still -key: ; Keys are not valid at this part of the - mov eax,2 ; loop. Just read it and ignore - mcall - jmp still - -button: ; button - mov eax,17 ; get id - mcall - - cmp ah,1 ; button id=1 ? - jnz noclose - - ; close socket before exiting - mov eax, 53 - mov ebx, 1 - mov ecx, [socketNum] - mcall - - mov eax,0xffffffff ; close this program - mcall - -noclose: - cmp ah,3 ; Resolve address? - jnz still - - call draw_window - - call contactDHCPServer - - jmp still - - -;*************************************************************************** -; 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: - mov edx, dhcpMsg - - mov eax, [edx+16] - mov [dhcpClientIP], eax - - ; Scan options - - add edx, 240 ; Point to first option - -pr001: - ; Get option id - mov al, [edx] - cmp al, 0xff ; End of options? - je pr_exit - - cmp al, 53 ; Msg type is a single byte option - jne pr002 - - mov al, [edx+2] - mov [dhcpMsgType], al - add edx, 3 - jmp pr001 ; Get next option - -pr002: - ; All other (accepted) options are 4 bytes in length - inc edx - movzx ecx, byte [edx] - inc edx ; point to data - - cmp al, 54 ; server id - jne pr0021 - mov eax, [edx] ; All options are 4 bytes, so get it - mov [dhcpServerIP], eax - jmp pr003 - -pr0021: - cmp al, 51 ; lease - jne pr0022 - mov eax, [edx] ; All options are 4 bytes, so get it - mov [dhcpLease], eax - jmp pr003 - -pr0022: - cmp al, 1 ; subnet mask - jne pr0023 - mov eax, [edx] ; All options are 4 bytes, so get it - mov [dhcpSubnet], eax - jmp pr003 - -pr0023: - cmp al, 6 ; dns ip - jne pr0024 - mov eax, [edx] ; All options are 4 bytes, so get it - mov [dhcpDNSIP], eax - -pr0024: - cmp al, 3 ; gateway ip - jne pr003 - mov eax, [edx] ; All options are 4 bytes, so get it - mov [dhcpGateway], eax - -pr003: - add edx, ecx - jmp pr001 - -pr_exit: - ret - - -;*************************************************************************** -; Function -; buildRequest -; -; Description -; Creates a DHCP request packet. -; -;*************************************************************************** -buildRequest: - ; Clear dhcpMsg to all zeros - xor eax,eax - mov edi,dhcpMsg - mov ecx,512 - 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 [edx+10], byte 0x80 ; broadcast flag set - mov [edx+236], dword 0x63538263 ; magic number - - ; option DHCP msg type - mov [edx+240], word 0x0135 - mov al, [dhcpMsgType] - mov [edx+240+2], al - - ; option Lease time = infinity - mov [edx+240+3], word 0x0433 - mov eax, [dhcpLease] - mov [edx+240+5], eax - - ; option requested IP address - mov [edx+240+9], word 0x0432 - mov eax, [dhcpClientIP] - mov [edx+240+11], eax - - ; option request list - mov [edx+240+15], word 0x0437 - mov [edx+240+17], dword 0x0f060301 - - ; Check which msg we are sending - cmp [dhcpMsgType], byte 0x01 - jne br001 - - ; "Discover" options - ; end of options marker - mov [edx+240+21], byte 0xff - - mov [dhcpMsgLen], dword 262 - jmp br_exit - -br001: - ; "Request" options - - ; server IP - mov [edx+240+21], word 0x0436 - mov eax, [dhcpServerIP] - mov [edx+240+23], eax - - ; end of options marker - mov [edx+240+27], byte 0xff - - mov [dhcpMsgLen], dword 268 - -br_exit: - ret - - - -;*************************************************************************** -; Function -; contactDHCPServer -; -; Description -; negotiates settings with a DHCP server -; -;*************************************************************************** -contactDHCPServer: - ; First, open socket - mov eax, 53 - mov ebx, 0 - mov ecx, 68 ; local port dhcp client - mov edx, 67 ; remote port - dhcp server - mov esi, 0xffffffff ; broadcast - mcall - - mov [socketNum], eax - - ; Setup the first msg we will send - mov [dhcpMsgType], byte 0x01 ; DHCP discover - mov [dhcpLease], dword 0xffffffff - mov [dhcpClientIP], dword 0 - mov [dhcpServerIP], dword 0 - - call buildRequest - -ctr000: - ; write to socket ( send broadcast request ) - mov eax, 53 - mov ebx, 4 - mov ecx, [socketNum] - mov edx, [dhcpMsgLen] - mov esi, dhcpMsg - mcall - - ; Setup the DHCP buffer to receive response - - mov eax, dhcpMsg - mov [dhcpMsgLen], eax ; Used as a pointer to the data - - ; now, we wait for - ; UI redraw - ; UI close - ; or data from remote - -ctr001: - mov eax,10 ; wait here for event - mcall - - 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? - mov eax, 53 - mov ebx, 2 - mov ecx, [socketNum] - mcall - - cmp eax, 0 - je ctr001 - - ; we have data - this will be the response -ctr002: - mov eax, 53 - mov ebx, 3 - mov ecx, [socketNum] - mcall ; read byte - block (high byte) - - ; Store the data in the response buffer - mov eax, [dhcpMsgLen] - mov [eax], bl - inc dword [dhcpMsgLen] - - mov eax, 53 - mov ebx, 2 - mov ecx, [socketNum] - mcall ; any more data? - - cmp eax, 0 - jne ctr002 ; yes, so get it - - ; 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 - ; 2) else exit ( display error ) - ; 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 - ; 2) else exit ( display error ) - - - cmp [dhcpMsgType], byte 0x01 ; did we send a discover? - je ctr007 - cmp [dhcpMsgType], byte 0x03 ; did we send a request? - je ctr008 - - ; should never get here - we only send discover or request - jmp ctr006 - -ctr007: - call parseResponse - - ; Was the response an offer? It should be - cmp [dhcpMsgType], byte 0x02 - jne ctr006 ; NO - so quit - - ; send request - mov [dhcpMsgType], byte 0x03 ; DHCP request - call buildRequest - jmp ctr000 - -ctr008: - call parseResponse - - ; Was the response an ACK? It should be - cmp [dhcpMsgType], byte 0x05 - jne ctr006 ; NO - so quit - - ; Set or display addresses here... - -ctr006: - ; close socket - mov eax, 53 - mov ebx, 1 - mov ecx, [socketNum] - mcall - - mov [socketNum], dword 0xFFFF - - call draw_window - - jmp ctr001 - -ctr003: ; redraw - call draw_window - jmp ctr001 - -ctr004: ; key - mov eax,2 ; just read it and ignore - mcall - jmp ctr001 - -ctr005: ; button - mov eax,17 ; get id - mcall - - ; close socket - mov eax, 53 - mov ebx, 1 - mov ecx, [socketNum] - mcall - - mov [socketNum], dword 0xFFFF - - call draw_window ; at first, draw the window - - ret - - - - -; ********************************************* -; ******* WINDOW DEFINITIONS AND DRAW ******** -; ********************************************* - - -; Pass in the IP address in edi -; row to display in [ya] -drawIP: -; mov edi,hostIP - mov ecx, edi - add ecx, 4 - mov edx,[ya] - add edx, 97*65536 - mov esi,0x00ffffff - mov ebx,3*65536 - -ipdisplay: - mov eax,47 - push ecx - movzx ecx,byte [edi] - mcall - pop ecx - add edx,6*4*65536 - inc edi - cmp edi,ecx - jb ipdisplay - ret - - -drawDHMS: - - mov eax,[edi] - bswap eax - - mov esi,dhms - mov ecx,16 - mov edi,text+40*4+12 - cmp eax,0xffffffff - jne nforever - mov esi,forever - cld - rep movsb - ret - nforever: - cld - rep movsb - - mov ecx,28 - xor edx,edx - mov ebx,60 - div ebx - call displayDHMS - xor edx,edx - div ebx - call displayDHMS - xor edx,edx - mov ebx,24 - div ebx - call displayDHMS - mov edx,eax - call displayDHMS - - ret - - -displayDHMS: - - pusha - mov eax,47 - mov ebx,3*65536 - mov edx,ecx - imul edx,6 - shl edx,16 - add edx,1*65536+99 - mov ecx,[esp+20] - mov esi,0xffffff - mcall - popa - sub ecx,4 - ret - - -draw_window: - - mov eax,12 ; function 12:tell os about windowdraw - mov ebx,1 ; 1, start of draw - mcall - ; DRAW WINDOW - mov eax,0 ; function 0 : define and draw window - mov ebx,100*65536+300 ; [x start] *65536 + [x size] - mov ecx,100*65536+156 ; [y start] *65536 + [y size] - mov edx,0x14224466 ; color of work area RRGGBB - mov edi,title ; WINDOW LABEL - mcall - - mov eax,8 ; Resolve - mov ebx,20*65536+90 - mov ecx,127*65536+15 - mov edx,3 - mov esi,0x557799 - mcall - - ; Pass in the IP address in edi - ; row to display in [ya] - mov edi, dhcpClientIP - mov eax, 35 - mov [ya], eax - call drawIP - mov edi, dhcpGateway - mov eax, 35 + 16 - mov [ya], eax - call drawIP - mov edi, dhcpSubnet - mov eax, 35 + 32 - mov [ya], eax - call drawIP - mov edi, dhcpDNSIP - mov eax, 35 + 48 - mov [ya], eax - call drawIP - mov edi, dhcpLease - call drawDHMS - - ; Re-draw the screen text - cld - mov eax,4 - mov ebx,25*65536+35 ; draw info text with function 4 - mov ecx,0xffffff - mov edx,text - mov esi,40 -newline: - mcall - add ebx,16 - add edx,40 - cmp [edx],byte 'x' - jnz newline - - - mov eax,12 ; function 12:tell os about windowdraw - mov ebx,2 ; 2, end of draw - mcall - - ret - - - -; DATA AREA - -ya dd 0x0 - -text: - db 'Client IP : . . . ' - db 'Gateway IP: . . . ' - db 'Subnet : . . . ' - db 'DNS IP : . . . ' - db 'Lease Time: d h m s ' - db ' ' - db ' SEND REQUEST ' - db 'x <- END MARKER, DONT DELETE ' - - -dhms db ' d h m s' -forever db 'Forever ' - -title db 'DHCP Client Test',0 - -dhcpMsgType: db 0 -dhcpLease: dd 0 -dhcpClientIP: dd 0 -dhcpServerIP: dd 0 -dhcpDNSIP: dd 0 -dhcpSubnet: dd 0 -dhcpGateway: dd 0 - -dhcpMsgLen: dd 0 -socketNum: dd 0xFFFF -dhcpMsg: -I_END: - - - - diff --git a/programs/network_old/dnsr/trunk/build_en.bat b/programs/network_old/dnsr/trunk/build_en.bat deleted file mode 100644 index 10d4451bbb..0000000000 --- a/programs/network_old/dnsr/trunk/build_en.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix en >lang.inc -@fasm dnsr.asm dnsr -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/dnsr/trunk/build_ru.bat b/programs/network_old/dnsr/trunk/build_ru.bat deleted file mode 100644 index 2ceaced014..0000000000 --- a/programs/network_old/dnsr/trunk/build_ru.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix ru >lang.inc -@fasm dnsr.asm dnsr -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/dnsr/trunk/dnsr.asm b/programs/network_old/dnsr/trunk/dnsr.asm deleted file mode 100644 index 2c02ab3fbf..0000000000 --- a/programs/network_old/dnsr/trunk/dnsr.asm +++ /dev/null @@ -1,785 +0,0 @@ -; -; DNS Domain name -> IP lookup -; -; Compile with FASM for Menuet -; - - -; If you like, you camd change the DNS server default by changing the -; IP address in the dnsServer string. - - -; Enabling debugging puts the received response to the -; debug board -DEBUGGING_ENABLED equ 1 -DEBUGGING_DISABLED equ 0 -DEBUGGING_STATE equ DEBUGGING_DISABLED - - -use32 - org 0x0 - db 'MENUET01' ; header - dd 0x01 ; header version - dd START ; entry point - dd I_END ; image size - dd I_END+0x10000 ; required memory - dd I_END+0x10000 ; esp - dd 0x0 , 0x0 ; I_Param , I_Path - -include 'lang.inc' -include 'macros.inc' - -START: ; start of execution - mov eax,40 ; Report events - mov ebx,10000111b ; Stack 8 + defaults - int 0x40 - - mov dword [prompt], p1 - mov dword [promptlen], p1len - p1 ; 'waiting for command' - -red: - call draw_window ; at first, draw the window - -still: - mov eax,10 ; wait here for event - mcall - - cmp eax,1 ; redraw request ? - jz red - cmp eax,2 ; key in buffer ? - jz key - cmp eax,3 ; button in buffer ? - jz button - - jmp still -key: ; Keys are not valid at this part of the - mov eax,2 ; loop. Just read it and ignore - mcall - jmp still - -button: ; button - mov eax,17 ; get id - mcall - - cmp ah,1 ; button id=1 ? - jnz noclose - - ; close socket before exiting - mov eax, 53 - mov ebx, 1 - mov ecx, [socketNum] - mcall - - mov eax,0xffffffff ; close this program - mcall - -noclose: - cmp ah,3 ; Resolve address? - jnz noresolve - - mov dword [prompt], p5 - mov dword [promptlen], p5len - p5 ; display 'Resolving' - call draw_window - - call translateData ; Convert domain & DNS IP address - - call resolveDomain - - jmp still - - -noresolve: - cmp ah,4 - jz f1 ; Enter domain name - cmp ah,5 - jz f2 ; enter DNS Server IP - jmp still - - -f1: - mov [addr],dword query - mov [ya],dword 35 - jmp rk - -f2: - mov [addr],dword dnsServer - mov [ya],dword 35+16 - -rk: - mov ecx,26 - mov edi,[addr] - mov al,' ' - rep stosb - - call print_text - - mov edi,[addr] - -f11: - mov eax,10 - mcall - cmp eax,2 - jz fbu - jmp still - -fbu: - mov eax,2 - mcall ; get key - shr eax,8 - cmp eax,8 - jnz nobs - cmp edi,[addr] - jz f11 - sub edi,1 - mov [edi],byte ' ' - call print_text - jmp f11 - -nobs: - cmp eax,dword 31 - jbe f11 - cmp eax,dword 95 - jb keyok - sub eax,32 - -keyok: - mov [edi],al - - call print_text - - add edi,1 - mov esi,[addr] - add esi,26 - cmp esi,edi - jnz f11 - - jmp still - - - -print_text: - mov eax,13 - mov ebx,103*65536+26*6 - mov ecx,[ya] - shl ecx,16 - mov cx,8 - mov edx,0x224466 - mcall - - mov eax,4 - mov ebx,103*65536 - add ebx,[ya] - mov ecx,0xffffff - mov edx,[addr] - mov esi,26 - mcall - - 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 -; The DNS ip, in dnsServer, is converted and stored in dnsIP -; -;*************************************************************************** -translateData: - - ; first, get the IP address of the DNS server - ; Then, build up the request string. - - xor eax, eax - mov dh, 10 - mov dl, al - mov [dnsIP], eax - - mov esi, dnsServer - mov edi, dnsIP - - mov ecx, 4 - -td003: - lodsb - sub al, '0' - add dl, al - lodsb - cmp al, '.' - je ipNext - cmp al, ' ' - je ipNext - mov dh, al - sub dh, '0' - mov al, 10 - mul dl - add al, dh - mov dl, al - lodsb - cmp al, '.' - je ipNext - cmp al, ' ' - je ipNext - mov dh, al - sub dh, '0' - mov al, 10 - mul dl - add al, dh - mov dl, al - lodsb - -ipNext: - mov [edi], dl - inc edi - mov dl, 0 - loop td003 - - ; 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, query - 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, '.' ; 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 - mov eax, 53 - mov ebx, 9 - mcall - pop ecx - cmp eax, 0 ; is this local port in use? - jz getlp ; yes - so try next - - ; First, open socket - mov eax, 53 - mov ebx, 0 - mov edx, 53 ; remote port - dns - mov esi, [dnsIP] - mcall - - mov [socketNum], eax - - ; write to socket ( request DNS lookup ) - mov eax, 53 - mov ebx, 4 - mov ecx, [socketNum] - mov edx, [dnsMsgLen] - mov esi, dnsMsg - mcall - - ; Setup the DNS response buffer - - mov eax, dnsMsg - mov [dnsMsgLen], eax - - ; now, we wait for - ; UI redraw - ; UI close - ; or data from remote - -ctr001: - mov eax,10 ; wait here for event - mcall - - 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? - mov eax, 53 - mov ebx, 2 - mov ecx, [socketNum] - mcall - - cmp eax, 0 - je ctr001 - - ; we have data - this will be the response -ctr002: - mov eax, 53 - mov ebx, 3 - mov ecx, [socketNum] - mcall ; read byte - block (high byte) - - ; Store the data in the response buffer - mov eax, [dnsMsgLen] - mov [eax], bl - inc dword [dnsMsgLen] - - -if DEBUGGING_STATE = DEBUGGING_ENABLED - call debug_print_rx_ip -end if - - mov eax, 53 - mov ebx, 2 - mov ecx, [socketNum] - mcall ; any more data? - - cmp eax, 0 - jne ctr002 ; yes, so get it - - ; close socket - mov eax, 53 - mov ebx, 1 - mov ecx, [socketNum] - mcall - - mov [socketNum], dword 0xFFFF - - ; 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] - - ; Clear the IP address text - mov [hostIP], 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 validated. Scan through and get my answer - - 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 [hostIP], eax - jmp ctr002a ; And exit... - - -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: - mov dword [prompt], p4 ; Display IP address - mov dword [promptlen], p4len - p4 - call draw_window - - jmp ctr001 - -ctr003: ; redraw - call draw_window - jmp ctr001 - -ctr004: ; key - mov eax,2 ; just read it and ignore - mcall - jmp ctr001 - -ctr005: ; button - mov eax,17 ; get id - mcall - - ; close socket - mov eax, 53 - mov ebx, 1 - mov ecx, [socketNum] - mcall - - mov [socketNum], dword 0xFFFF - mov [hostIP], dword 0 - - mov dword [prompt], p1 - mov dword [promptlen], p1len - p1 ; 'waiting for command' - - call draw_window ; at first, draw the window - - 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 - - -; ********************************************* -; ******* WINDOW DEFINITIONS AND DRAW ******** -; ********************************************* - - -draw_window: - mov eax,12 ; function 12:tell os about windowdraw - mov ebx,1 ; 1, start of draw - mcall - ; DRAW WINDOW - mov eax,0 ; function 0 : define and draw window - mov ebx,100*65536+300 ; [x start] *65536 + [x size] - mov ecx,100*65536+140 ; [y start] *65536 + [y size] - mov edx,0x14224466 ; color of work area RRGGBB - mov edi,title ; WINDOW LABEL; - mcall - - mov eax,8 ; Resolve - mov ebx,20*65536+190 - mov ecx,79*65536+15 - mov edx,3 - mov esi,0x557799 - mcall - - ;mov eax,8 - mov ebx,270*65536+10 - mov ecx,34*65536+10 - inc edx - mcall - - ;mov eax,8 - mov ebx,270*65536+10 - mov ecx,50*65536+10 - inc edx - mcall - - ; Copy the file name to the screen buffer - ; file name is same length as IP address, to - ; make the math easier later. - cld - mov esi,query - mov edi,text+13 - mov ecx,26 - rep movsb - - - ; copy the IP address to the screen buffer - mov esi,dnsServer - mov edi,text+40+13 - mov ecx,26 - rep movsb - - ; copy the prompt to the screen buffer - mov esi,[prompt] - mov edi,text+200 - mov ecx,[promptlen] - rep movsb - - ; Re-draw the screen text - cld - mov eax,4 - mov ebx,25*65536+35 ; draw info text with function 4 - mov ecx,0xffffff - mov edx,text - mov esi,40 -newline: - mcall - add ebx,16 - add edx,40 - cmp [edx],byte 'x' - jnz newline - - - ; Write the host IP, if we have one - mov eax, [hostIP] - cmp eax, 0 - je dw001 - - ; We have an IP address... display it - mov edi,hostIP - mov edx,97*65536+115 - mov esi,0x00ffffff - mov ebx,3*65536 - -ipdisplay: - mov eax,47 - movzx ecx,byte [edi] - mcall - add edx,6*4*65536 - inc edi - cmp edi,hostIP+4 - jb ipdisplay - -dw001: - mov eax,12 ; function 12:tell os about windowdraw - mov ebx,2 ; 2, end of draw - mcall - - ret - - -if DEBUGGING_STATE = DEBUGGING_ENABLED -;**************************************************************************** -; Function -; debug_print_string -; -; Description -; prints a string to the debug board -; -; esi holds ptr to msg to display -; -; Nothing preserved; I'm assuming a pusha/popa is done before calling -; -;**************************************************************************** -debug_print_string: - mov cl, [esi] - cmp cl, 0 - jnz dps_001 - ret - -dps_001: - mov eax,63 - mov ebx, 1 - push esi - mcall - - inc word [ind] - mov ax, [ind] - and ax, 0x1f - cmp ax, 0 - jne ds1 - - mov cl, 13 - mov eax,63 - mov ebx, 1 - mcall - mov cl, 10 - mov eax,63 - mov ebx, 1 - mcall - - -ds1: - pop esi - inc esi - jmp debug_print_string - - -ind: dw 0 -; This is used for translating hex to ASCII for display or output -hexchars db '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' -IP_STR db 'xx',0 - - -debug_print_rx_ip: - pusha - mov edi, IP_STR - - xor eax, eax - mov al, bl - shr al, 4 - mov ah, [eax + hexchars] - mov [edi], ah - inc edi - - xor eax, eax - mov al, bl - and al, 0x0f - mov ah, [eax + hexchars] - mov [edi], ah - mov esi, IP_STR - - call debug_print_string - popa - ret -end if - - -; DATA AREA - -addr dd 0x0 -ya dd 0x0 - -text: - - if lang eq ru - db 'Имя хоста : xxxxxxxxxxxxxxx ' - db 'DNS сервер : xxx.xxx.xxx.xxx ' - db ' ' - db ' Получить адрес ' - db ' ' - db ' ' - db 'x <- END MARKER, DONT DELETE ' - - else - db 'Host name : xxxxxxxxxxxxxxx ' - db 'DNS server : xxx.xxx.xxx.xxx ' - db ' ' - db ' RESOLVE ADDRESS ' - db ' ' - db ' ' - db 'x <- END MARKER, DONT DELETE ' - end if - -if lang eq ru -title db 'DNS Клиент',0 - -else -title db 'DNS Client',0 -end if - - -prompt: dd 0 -promptlen: dd 0 - - -if lang eq ru -p1: db 'Жду команды ' -p1len: - - -else -p1: db 'Waiting for Command ' -p1len: -end if - -p4: db 'IP Address: . . . ' -p4len: - -p5: db 'Resolving... ' -p5len: - - -dnsServer db '194.145.128.1 ' ; iolfree.ie DNS -query db 'WWW.MENUETOS.NET ' - -hostIP: dd 0 -dnsIP: dd 0 -dnsMsgLen: dd 0 -socketNum: dd 0xFFFF -dnsMsg: -I_END: diff --git a/programs/network_old/ethstat/trunk/build_en.bat b/programs/network_old/ethstat/trunk/build_en.bat deleted file mode 100644 index 96434f6965..0000000000 --- a/programs/network_old/ethstat/trunk/build_en.bat +++ /dev/null @@ -1,4 +0,0 @@ -@erase lang.inc -@echo lang fix en >lang.inc -@fasm ethstat.asm ethstat -@pause \ No newline at end of file diff --git a/programs/network_old/ethstat/trunk/build_ru.bat b/programs/network_old/ethstat/trunk/build_ru.bat deleted file mode 100644 index 0a2265d46d..0000000000 --- a/programs/network_old/ethstat/trunk/build_ru.bat +++ /dev/null @@ -1,4 +0,0 @@ -@erase lang.inc -@echo lang fix ru >lang.inc -@fasm ethstat.asm ethstat -@pause \ No newline at end of file diff --git a/programs/network_old/ethstat/trunk/ethstat.asm b/programs/network_old/ethstat/trunk/ethstat.asm deleted file mode 100644 index 4788bf2c29..0000000000 --- a/programs/network_old/ethstat/trunk/ethstat.asm +++ /dev/null @@ -1,218 +0,0 @@ -; -; Stack Status Monitor -; -; Compile with FASM for Menuet -; - -use32 - org 0x0 - db 'MENUET01' ; header - dd 0x01 ; header version - dd START ; entry point - dd I_END ; image size - dd I_END+0x10000 ; required memory - dd I_END+0x10000 ; esp - dd 0x0 , 0x0 ; I_Param , I_Path - -include 'lang.inc' -include '..\..\..\macros.inc' - -START: ; start of execution - - call draw_window ; at first, draw the window - -still: - mov eax,23 ; wait here for event - mov ebx,200 ; Time out after 2s - mcall - - cmp eax,1 ; redraw request ? - jz red - cmp eax,2 ; key in buffer ? - jz key - cmp eax,3 ; button in buffer ? - jz button - - ; read the stack status data, and write it to the screen buffer - - mov eax, 53 - mov ebx, 255 - mov ecx, 6 - mcall - - mov ebx, text + 24 - call printhex - - mov eax, 53 - mov ebx, 255 - mov ecx, 2 - mcall - - mov ebx, text + 107 - call printhex - - mov eax, 53 - mov ebx, 255 - mov ecx, 5 - mcall - - mov ebx, text + 107 + 40 - call printhex - - mov eax, 53 - mov ebx, 255 - mov ecx, 4 - mcall - - mov ebx, text + 107 + 80 - call printhex - - mov eax, 53 - mov ebx, 255 - mov ecx, 100 - mcall - - mov ebx, text + 258 - call printhex - - mov eax, 53 - mov ebx, 255 - mov ecx, 101 - mcall - - mov ebx, text + 258 + 40 - call printhex - - mov eax, 53 - mov ebx, 255 - mov ecx, 102 - mcall - - mov ebx, text + 258 + 80 - call printhex - - mov eax, 53 - mov ebx, 255 - mov ecx, 103 - mcall - - mov ebx, text + 258 + 120 - call printhex - -red: ; redraw - call draw_window - jmp still - -key: ; Keys are not valid at this part of the - mov eax,2 ; loop. Just read it and ignore - mcall - jmp still - -button: ; button - mov eax,17 ; get id - mcall - - cmp ah,1 ; button id=1 ? - jnz still - - or eax,-1 ; close this program - mcall - - jmp still - - - - -; ********************************************* -; ******* WINDOW DEFINITIONS AND DRAW ******** -; ********************************************* - - -draw_window: - - mov eax,12 ; function 12:tell os about windowdraw - mov ebx,1 ; 1, start of draw - mcall - - ; DRAW WINDOW - xor eax,eax ; function 0 : define and draw window - mov ebx,100*65536+260 ; [x start] *65536 + [x size] - mov ecx,100*65536+205 ; [y start] *65536 + [y size] - mov edx,0x14224466 ; color of work area RRGGBB - mov edi,title ; WINDOW LABEL - mcall - - - ; Re-draw the screen text - cld - mov eax,4 - mov ebx,25*65536+35 ; draw info text with function 4 - mov ecx,0xffffff - mov edx,text - mov esi,40 - newline: - mcall - add ebx,16 - add edx,40 - cmp [edx],byte 'x' - jnz newline - - - mov eax,12 ; function 12:tell os about windowdraw - mov ebx,2 ; 2, end of draw - mcall - - ret - -; Taken from PS.ASM -printhex: -; number in eax -; print to ebx -; xlat from hextable - pusha - mov esi, ebx - add esi, 8 - mov ebx, hextable - mov ecx, 8 -phex_loop: - mov edx, eax - and eax, 15 - xlatb - mov [esi], al - mov eax, edx - shr eax, 4 - dec esi - loop phex_loop - popa - ret - - -; DATA AREA - -text: - db ' Ethernet card status : xxxxxxxx ' - db ' ' - db ' IP packets received : xxxxxxxx ' - db ' ARP packets received : xxxxxxxx ' - db ' Dumped received packets : xxxxxxxx ' - db ' ' - db ' EMPTY QUEUE : xxxxxxxx ' - db ' IPOUT QUEUE : xxxxxxxx ' - db ' IPIN QUEUE : xxxxxxxx ' - db ' NET1OUT QUEUE : xxxxxxxx ' - db 'x <- END MARKER, DONT DELETE ' - - -title db 'Stack Status',0 - -hextable db '0123456789ABCDEF' - - -I_END: - - - - - - - diff --git a/programs/network_old/ftps/trunk/FTPS.ASM b/programs/network_old/ftps/trunk/FTPS.ASM deleted file mode 100644 index 46994a8461..0000000000 --- a/programs/network_old/ftps/trunk/FTPS.ASM +++ /dev/null @@ -1,1724 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; -; FTPS -; FTP Server -; -; Compile with FASM for Menuet -; - -; note: telnet == 23, ftp cmd == 21, data on 20 - -use32 - - org 0x0 - - db 'MENUET01' ; 8 byte id - dd 1 ; header version - dd START ; program start - dd I_END ; program image size - dd 0x170000 ; required amount of memory - dd 0x16FFF0 ; esp = 0x16FFF0 - dd 0, 0 ; no params, no path - -include '../../../macros.inc' -; Various states of client connection -USER_NONE equ 0 ; Awaiting a connection -USER_CONNECTED equ 1 ; User just connected, prompt given -USER_USERNAME equ 2 ; User given username -USER_LOGGED_IN equ 3 ; User given password - - - - - -START: ; start of execution - ; Clear the screen memory - mov eax, ' ' - mov edi,text - mov ecx,80*30 /4 - cld - rep stosd - - call draw_window - - ; init the receive buffer pointer - mov [buffptr], buff - - ; Init FTP server state machine - mov [state], USER_NONE - - ; Open the listening socket - call connect - -still: - ; check connection status - mov eax,53 - mov ebx,6 ; Get socket status - mov ecx,[CmdSocket] - mcall - - mov ebx, [CmdSocketStatus] - mov [CmdSocketStatus], eax - - cmp eax, ebx - je waitev - - ; If the socket closed by remote host, open it again. - cmp eax, 7 - je con - - ; If socket closed by Reset, open it again - cmp eax, 11 - je con - - ; If a user has just connected, start by outputting welcome msg - cmp eax, 4 - jne noc - - mov esi, loginStr0 - mov edx, loginStr0_end - loginStr0 - call outputStr - - mov [state], USER_CONNECTED - jmp noc - - -con: - ; Need to call disconnect, since a remote close does not fully - ; close the socket - call disconnect - mov eax,5 - mov ebx,10 ; Delay for 100ms - mcall - call connect - jmp noc - -noc: - ; Display the changed connected status - call draw_window - -waitev: - mov eax,23 ; wait here for event - mov ebx,1 ; Delay for up to 1s - mcall - - cmp eax,1 ; redraw request ? - je red - cmp eax,2 ; key in buffer ? - je key - cmp eax,3 ; button in buffer ? - je button - - ; any data from the socket? - - mov eax, 53 - mov ebx, 2 ; Get # of bytes in input queue - mov ecx, [CmdSocket] - mcall - test eax, eax - jz still - -read_input: - mov eax, 53 - mov ebx, 3 ; Get a byte from socket in bl - mov ecx, [CmdSocket] - mcall - - call ftpRxCmdData ; process incoming ftp command - - ; Keep processing data until there is no more to process - mov eax, 53 - mov ebx, 2 ; Get # of bytes in input queue - mov ecx, [CmdSocket] - mcall - cmp eax, 0 - jne read_input - - ; Now redraw the text text field. - ; Probably not required, since ftp requires no - ; console i/o. - ; Leave in for now, for debugging. -; (fall through to "red:") -; call draw_text -; jmp still - -red: ; REDRAW WINDOW - call draw_window - jmp still - -key: ; KEY - mov eax,2 ; get but ignore - mcall - jmp still - -button: - mov eax,17 - mcall - cmp ah,1 - jne still - - ; Exit button pressed, so close socket and quit - mov eax,53 - mov ebx,8 - mov ecx,[CmdSocket] - mcall - - ; ... terminate program - or eax,-1 - mcall - jmp still - - - -; ********************************************* -; ******* WINDOW DEFINITIONS AND DRAW ******** -; ********************************************* -draw_window: - pusha - - mov eax,12 - mov ebx,1 - mcall - - xor eax,eax ; DRAW WINDOW - mov ebx,100*65536+491 + 8 +15 - mov ecx,100*65536+270 + 20 ; 20 for status bar - mov edx,0x14000000 - mov edi,labelt - mcall - - ; draw status bar - mov eax, 13 - mov ebx, 4*65536+484 + 8 +15 - mov ecx, 270*65536 + 3 - mov edx, 0x00557799 - mcall - - - mov esi,contlen-contt ; display connected status - mov edx, contt - cmp [CmdSocketStatus], 4 ; 4 is connected - je pcon - mov esi,discontlen-discontt - mov edx, discontt -pcon: - - mov eax,4 ; status text - mov ebx,380*65536+276 - mov ecx,0x00ffffff - mcall - - ; Draw the text on the screen, clearing it first - ; This can go when we loose debuggin info. - xor eax,eax - mov edi,text+80*30 - mov ecx,80*30 /4 - cld - rep stosd - - call draw_text - - mov eax,12 - mov ebx,2 - mcall - - popa - - ret - - -;*************************************************************************** -; Function -; draw_text -; -; Description -; Updates the text on the screen. This is part of the debugging code -; -; Inputs -; Character to add in bl -; -;*************************************************************************** -draw_text: - - pusha - - mov esi,text - mov eax,0 - mov ebx,0 - newletter: - mov cl,[esi] - cmp cl,[esi+30*80] - jz noletter - yesletter: - mov [esi+30*80],cl - - ; erase character - - pusha - mov edx, 0 ; bg colour - mov ecx, ebx - add ecx, 26 - shl ecx, 16 - mov cx, 9 - mov ebx, eax - add ebx, 6 - shl ebx, 16 - mov bx, 6 - mov eax, 13 - mcall - popa - - ; draw character - - pusha - mov ecx, 0x00ffffff - push bx - mov ebx,eax - add ebx,6 - shl ebx,16 - pop bx - add bx,26 - mov eax,4 - mov edx,esi - mov esi,1 - mcall - popa - - noletter: - - add esi,1 - add eax,6 - cmp eax,80*6 - jb newletter - mov eax,0 - add ebx,10 - cmp ebx,24*10 - jb newletter - - popa - ret - - - -;*************************************************************************** -; Function -; ftpRxCmdData -; -; Description -; Prcoesses incoming command data, calling a handler for each command. -; Commands are built up in buff before being processed. -; -; Inputs -; Character to add in bl -; -;*************************************************************************** -ftpRxCmdData: - ; Quit if we are not connected - ;( This case shouldn't be necessary, but be safe ) - mov al, [state] - cmp al, USER_NONE - je frcd_exit - - ; Store the incoming character - mov esi, [buffptr] - mov [esi], bl - inc esi - mov [buffptr], esi - - ; For debugging, show the data coming in - pusha - call printChar - popa - - ; Do we have an end of line? (LF) - ; if not, just exit - cmp bl, 0x0a - jne frcd_exit - - ; OK we have a complete command. - ; Process, and send response - - ; There are a number of states involved in ftp, - ; to do with logging in. - - mov al, [state] - cmp al, USER_CONNECTED - jne fs001 - - ; This should be the username - - ; TODO validate username - - ; OK, username accepted - ask for password - mov esi, loginStr1 - mov edx, loginStr1_end - loginStr1 - call outputStr - - mov [state], USER_USERNAME - - ; init the receive buffer pointer - mov [buffptr], buff - - jmp frcd_exit - -fs001: - cmp al, USER_USERNAME - jne fs002 - - ; This should be the password - - ; TODO validate password - - ; OK, password accepted - show they are logged in - mov esi, loginStr2 - mov edx, loginStr2_end - loginStr2 - call outputStr - - mov [state], USER_LOGGED_IN - - ; init the receive buffer pointer - mov [buffptr], buff - - jmp frcd_exit - -fs002: - cmp al, USER_LOGGED_IN - jne fs003 - - ; This should be a cmd - call findCmd - mov eax, [cmdPtr] - cmp eax, 0 - - je fs002b - - call [cmdPtr] - -fs002a: - ; init the receive buffer pointer - mov [buffptr], buff - - jmp frcd_exit - -fs002b: - ; an unsupported command was entered. - ; Tell user that the command is not supported - - mov esi, unsupStr - mov edx, unsupStr_end - unsupStr - call outputStr - - jmp fs002a - -fs003: -frcd_exit: - ret - - - -;*************************************************************************** -; Function -; outputStr -; -; Description -; Sends a string over the 'Command' socket -; -; Inputs -; String in esi -; Length in edx -; -;*************************************************************************** -outputStr: - push esi - push edx - mov eax,53 - mov ebx,7 - mov ecx,[CmdSocket] - mcall - pop edx - pop esi - - cmp eax, 0 - je os_exit - - ; The TCP/IP transmit queue is full; Wait a bit, then retry - pusha - mov eax,5 - mov ebx,1 ; Delay for up 10ms - mcall - popa - jmp outputStr -os_exit: - ret - - - -;*************************************************************************** -; Function -; outputDataStr -; -; Description -; Sends a string over the 'Data' socket -; -; Inputs -; String in esi -; Length in edx -; -;*************************************************************************** -outputDataStr: - push esi - push edx - mov eax,53 - mov ebx,7 - mov ecx,[DataSocket] - mcall - pop edx - pop esi - - cmp eax, 0 - je ods_exit - - ; The TCP/IP transmit queue is full; Wait a bit, then retry - pusha - mov eax,5 - mov ebx,1 ; Delay for up 10ms - mcall - popa - jmp outputDataStr -ods_exit: - ret - - - -;*************************************************************************** -; Function -; printChar -; -; Description -; Writes a character to the screen; Used to display the data coming -; in from the user. Really only useful for debugging. -; -; Inputs -; Character in bl -; -;*************************************************************************** -printChar: - cmp bl,13 ; BEGINNING OF LINE - jne nobol - mov ecx,[pos] - add ecx,1 -boll1: - sub ecx,1 - mov eax,ecx - xor edx,edx - mov ebx,80 - div ebx - cmp edx,0 - jne boll1 - mov [pos],ecx - jmp newdata -nobol: - - cmp bl,10 ; LINE DOWN - jne nolf -addx1: - add [pos],dword 1 - mov eax,[pos] - xor edx,edx - mov ecx,80 - div ecx - cmp edx,0 - jnz addx1 - mov eax,[pos] - jmp cm1 -nolf: - - cmp bl,8 ; BACKSPACE - jne nobasp - mov eax,[pos] - dec eax - mov [pos],eax - mov [eax+text],byte 32 - mov [eax+text+60*80],byte 0 - jmp newdata -nobasp: - - cmp bl,15 ; CHARACTER - jbe newdata -putcha: - mov eax,[pos] - mov [eax+text],bl - mov eax,[pos] - add eax,1 -cm1: - mov ebx,[scroll+4] - imul ebx,80 - cmp eax,ebx - jb noeaxz - mov esi,text+80 - mov edi,text - mov ecx,ebx - cld - rep movsb - mov eax,ebx - sub eax,80 -noeaxz: - mov [pos],eax -newdata: - ret - - -;*************************************************************************** -; Function -; disconnect -; -; Description -; Closes the command socket -; -; Inputs -; None -; -;*************************************************************************** -disconnect: - mov eax, 53 ; Stack Interface - mov ebx,8 ; Close TCP socket - mov ecx,[CmdSocket] - mcall - ret - - - -;*************************************************************************** -; Function -; disconnectData -; -; Description -; Closes the data socket -; -; Inputs -; None -; -;*************************************************************************** -disconnectData: - ; This delay would be better done by allowing the socket code - ; to wait for all data to pass through the stack before closing - pusha - mov eax,5 - mov ebx,10 ; Delay for 100ms - mcall - popa - - mov eax, 53 ; Stack Interface - mov ebx,8 ; Close TCP socket - mov ecx,[DataSocket] - mcall - ret - - - - -;*************************************************************************** -; Function -; connect -; -; Description -; Opens the command socket -; -; Inputs -; None -; -;*************************************************************************** -connect: - pusha - - mov eax, 53 ; Stack Interface - mov ebx, 5 ; Open TCP socket - mov esi, 0 ; No remote IP address - mov edx, 0 ; No remote port - mov ecx, 21 ; ftp command port id - mov edi, 0 ; passive open - mcall - mov [CmdSocket], eax - - popa - - ret - - - -;*************************************************************************** -; Function -; connectData -; -; Description -; Opens the data socket -; -; Inputs -; None -; -;*************************************************************************** -connectData: - pusha - - mov eax, 53 ; Stack Interface - mov ebx, 5 ; Open TCP socket - mov esi, [DataIP] ; remote IP address - mov edx, [DataPort] ; remote port - mov ecx, 0 ; ftp data port id - mov edi, 1 ; active open - mcall - mov [DataSocket], eax - - popa - - ret - - - - -;*************************************************************************** -; Function -; findCmd -; -; Description -; Scans the command string for a valid command. The command string -; is in the global variable buff. -; -; Returns result in cmdPtr. This will be zero if none found -; -; Inputs -; None -; -;*************************************************************************** -findCmd: - ; Setup to return 'none' in cmdPtr, if we find no cmd - mov eax, 0 - mov [cmdPtr], eax - cld - mov esi, buff - mov edi, CMDList - -fc000: - cmp [edi], byte 0 ; Are we at the end of the CMDList? - je fc_exit - -fc000a: - cmpsb - - je fc_nextbyte - - ; Command is different - move to the next entry in cmd table - mov esi, buff - -fc001: - ; skip to the next command in the list - cmp [edi], byte 0 - je fc002 - inc edi - jmp fc001 -fc002: - add edi, 5 - jmp fc000 - -fc_nextbyte: - ; Have we reached the end of the CMD text? - cmp [edi], byte 0 - je fc_got ; Yes - so we have a match - jmp fc000a ; No - loop back - -fc_got: - ; Copy the function pointer for the selected command - inc edi - mov eax, [edi] - mov [cmdPtr], eax - -fc_exit: - ret - - - -;*************************************************************************** -; Function -; decStr2Byte -; -; Description -; Converts the decimal string pointed to by esi to a byte -; -; Inputs -; string ptr in esi -; -; Outputs -; esi points to next character not in string -; eax holds result ( 0..255) -; -;*************************************************************************** -decStr2Byte: - xor eax, eax - xor ebx, ebx - mov ecx, 3 - -dsb001: - mov bl, [esi] - - cmp bl, '0' - jb dsb_exit - cmp bl, '9' - ja dsb_exit - - imul eax, 10 - add eax, ebx - sub eax, '0' - inc esi - loop dsb001 - -dsb_exit: - ret - - - -;*************************************************************************** -; Function -; parsePortStr -; -; Description -; Converts the parameters of the PORT command, and stores them in the -; appropriate variables. -; -; Inputs -; None ( string in global variable buff ) -; -; Outputs -; None -; -;*************************************************************************** -parsePortStr: - ; skip past the PORT text to get the the parameters. The command format - ; is - ; PORT i,i,i,i,p,p,0x0d,0x0a - ; where i and p are decimal byte values, high byte first. - xor eax, eax - mov [DataIP], eax - mov [DataPort], eax - mov esi, buff + 4 ; Start at first space character - -pps001: - cmp [esi], byte ' ' ; Look for first non space character - jne pps002 - inc esi - jmp pps001 - -pps002: - call decStr2Byte - add [DataIP], eax - ror dword [DataIP], 8 - inc esi - call decStr2Byte - add [DataIP], eax - ror dword [DataIP], 8 - inc esi - call decStr2Byte - add [DataIP], eax - ror dword [DataIP], 8 - inc esi - call decStr2Byte - add [DataIP], eax - ror dword [DataIP], 8 - inc esi - call decStr2Byte - add [DataPort], eax - shl [DataPort], 8 - inc esi - call decStr2Byte - add [DataPort], eax - - ret - - - -;*************************************************************************** -; Function -; sendDir -; -; Description -; Transmits the directory listing over the data connection. -; The data connection is already open. -; -; Inputs -; None -; -; Outputs -; None -; -;*************************************************************************** -sendDir: - mov eax, text+0x4000 - mov [fsize], eax - mov ebx, dirinfoblock - and dword [ebx+4], 0 ; start from zero block -sd001: -; Read the next DirBlocksPerCall (=16) blocks - mov eax, 70 - mcall -; Did we read anything? - test eax, eax - jz @f - cmp eax, 6 - jnz sd_exit -@@: - test ebx, ebx - jz sd_exit -; Parse these blocks. There could be up to 16 files specified - mov esi, text + 0x1300 + 0x20 -sd002: - dec ebx - js sd004 - push ebx -; OK, lets parse the entry. Ignore volume entries - test byte [esi], 8 - jnz sd003 -; Valid file or directory. Start to compose the string we will send - mov edi, dirStr -; If we have been called as a result of an NLST command, we only display -; the filename - cmp [buff], byte 'N' - jz sd006 - - mov [edi], byte '-' - test byte [esi], 10h - jz @f - mov [edi], byte 'd' -@@: -; Ok, now copy across the directory listing text that will be constant -; ( I dont bother looking at the read only or archive bits ) - - mov ebx, tmplStr -@@: - inc edi - mov al, [ebx] - test al, al - jz @f - mov [edi], al - inc ebx - jmp @b -@@: -; point to the last character of the string; -; We will write the file size here, backwards - push edi ; Remember where the string ends - - dec edi -; eax holds the number - mov eax, [esi+32] - mov ebx, 10 -@@: - xor edx, edx - div ebx - add dl, '0' - mov [edi], dl - dec edi - test eax, eax - jnz @b - - pop edi -; now create the time & date fields -;timeStr: db ' Jan 1 2000 ',0 - mov al, ' ' - stosb - movzx eax, byte [esi+28+1] - mov eax, dword [months + (eax-1)*4] - stosd - mov al, byte [esi+28] - aam - test ah, ah - jz sd005a - xchg al, ah - add ax, '00' - jmp sd005b -sd005a: - add al, '0' - mov ah, ' ' -sd005b: - stosw - mov al, ' ' - mov ecx, 6 - rep stosb - push edi - movzx eax, word [esi+28+2] -@@: - xor edx, edx - div ebx - add dl, '0' - mov [edi], dl - dec edi - test eax, eax - jnz @b - pop edi - inc edi - mov al, ' ' - stosb -sd006: -; ** End of copying - -; now copy the filename across - lea ebx, [esi+40] -@@: - mov al, [ebx] - inc ebx - test al, al - jz @f - stosb - jmp @b -@@: -terminate: -; Now terminate the line by putting CRLF sequence in - mov al, 0x0D - stosb - mov al, 0x0A - stosb -; Send the completed line to the user over data socket - push esi - push edi - mov esi, dirStr - mov ecx, edi - sub ecx, esi - mov edi, [fsize] - cld - rep movsb - mov [fsize], edi - cmp edi, text+0x4400 - jb @f - mov esi, text+0x4000 - mov edx, [fsize] - sub edx, esi - mov [fsize], esi - call outputDataStr - -@@: - pop edi - pop esi - -sd003: ; Move to next entry in the block - pop ebx - add esi, 304 - jmp sd002 -sd004: - mov ebx, dirinfoblock - add dword [ebx+4], DirBlocksPerCall - jmp sd001 - -sd_exit: - mov esi, text+0x4000 - mov edx, [fsize] - sub edx, esi - call outputDataStr - ret - - - - - -;*************************************************************************** -; Function -; setupFilePath -; -; Description -; Copies the file name from the input request string into the -; file descriptor -; -; Inputs -; None -; -; Outputs -; None -; -;*************************************************************************** -setupFilePath: - mov esi, buff + 4 ; Point to (1 before) first character of file - - ; Skip any trailing spaces or / character -sfp001: - inc esi - cmp [esi], byte ' ' - je sfp001 - cmp [esi], byte '/' - je sfp001 - - ; esi points to start of filename. - cld - push esi - - ; Copy across the directory path '/' - ; into the fileinfoblock - mov esi, dirpath - mov edi, filename -sfp003: - movsb - cmp [esi], byte 0 - jne sfp003 - mov al, '/' - stosb - pop esi - - ; Copy across the filename -sfp002: - movsb - cmp [esi], byte 0x0d - jne sfp002 - mov [edi], byte 0 - ret - - - - -;*************************************************************************** -; Function -; sendFile -; -; Description -; Transmits the requested file over the open data socket -; The file to send is named in the buff string -; -; Inputs -; None -; -; Outputs -; None -; -;*************************************************************************** -sendFile: - call setupFilePath - - ; init fileblock descriptor, for file read - mov ebx, fileinfoblock - and dword [ebx], 0 ; read cmd - and dword [ebx+4], 0 ; first block - mov dword [ebx+12], 0x400 ; block size - -sf002a: - ; now read the file.. - mov eax,70 - mcall - test eax, eax - jz @f - cmp eax, 6 - jnz sf_exit -@@: - push eax - mov esi, text + 0x1300 - mov edx, ebx - call outputDataStr - pop eax - test eax, eax - jnz sf_exit -; wait a bit - mov eax, 5 - mov ebx, 1 - mcall - mov ebx, fileinfoblock - add dword [ebx+4], edx - jmp sf002a - -sf_exit: - ret - - -;*************************************************************************** -; Function -; getFile -; -; Description -; Receives the specified file over the open data socket -; The file to receive is named in the buff string -; -; Inputs -; None -; -; Outputs -; None -; -;*************************************************************************** -getFile: - call setupFilePath - - ; init fileblock descriptor, for file write - xor eax, eax - mov [fsize], eax ; Start filelength at 0 - mov [fileinfoblock+4], eax ; set to 0 - inc eax - inc eax - mov [fileinfoblock], eax ; write cmd - - ; Read data from the socket until the socket closes - ; loop - ; loop - ; read byte from socket - ; write byte to file buffer - ; until no more bytes in socket - ; sleep 100ms - ; until socket no longer connected - ; write file to ram - -gf000: - mov eax, 53 - mov ebx, 2 ; Get # of bytes in input queue - mov ecx, [DataSocket] - mcall - test eax, eax - je gf_sleep - - mov eax, 53 - mov ebx, 11 ; Get bytes from socket - mov ecx, [DataSocket] - mov edx, text + 0x1300 - add edx, dword [fsize] - xor esi, esi - mcall ; returned data len in eax - add dword [fsize], eax - - jmp gf000 - -gf_sleep: - ; Check to see if socket closed... - mov eax,53 - mov ebx,6 ; Get socket status - mov ecx,[DataSocket] - mcall - - cmp eax, 7 - jne gf001 ; still open, so just sleep a bit - - ; Finished, so write the file - mov eax, [fsize] - mov [fileinfoblock+12], eax - mov eax,70 - mov ebx,fileinfoblock - mcall - - ret ; Finished - -gf001: - ; wait a bit - mov eax,5 - mov ebx,1 ; Delay for up 10ms - mcall - jmp gf000 ; try for more data - - - - - -;*************************************************************************** -; COMMAND HANDLERS FOLLOW -; -; These handlers implement the functionality of each supported FTP Command -; -;*************************************************************************** - -cmdPWD: - cld - mov edi, text+0x1300 - - mov esi, curdir_1 - mov ecx, curdir_2-curdir_1 - rep movsb - - mov esi, [curdirptr] - cmp [esi], byte 0 - jne cpwd_000 - mov al, '/' - stosb - jmp cpwd_001 - -cpwd_000: - movsb - cmp [esi], byte 0 - jne cpwd_000 - -cpwd_001: - mov esi, curdir_2 - mov ecx, curdir_end-curdir_2 - rep movsb - - ; OK, show the directory name text - mov esi, text+0x1300 - mov edx, edi - sub edx, esi - call outputStr - - ret - - -cmdCWD: - lea esi, [buff+4] - mov edi, [curdirptr] - mov ecx, -1 - xor eax, eax - repne scasb - dec edi - cmp [esi], word '..' - je ccwd_002 - test [esi], byte 0xE0 - je ccwd_000 - push edi - mov al, '/' - stosb -@@: - movsb - cmp [esi], byte 0xD - jne @b - xor al, al - stosb - - mov eax, 70 - mov ebx, dirinfoblock - and dword [ebx+4], 0 - mcall - pop edi - test eax, eax - je @f - cmp eax, 6 - jne ccwd_000 -@@: - test ebx, ebx - je ccwd_000 - mov esi, text + 0x1300 + 0x20 - - mov al, byte [esi] - and al, 0x18 - cmp al, 0x10 - jne ccwd_000 - -ccwd_ok: - ; OK, show the directory name text - mov esi, chdir - mov edx, chdir_end - chdir - jmp ccwd_001 - -ccwd_002: - dec edi - cmp byte [edi], '/' - je ccwd_003 - cmp edi, [curdirptr] - ja ccwd_002 - jmp ccwd_ok -ccwd_003: - mov byte [edi], 0 - jmp ccwd_ok - -ccwd_000: - mov byte [edi], 0 - ; Tell user there is no such directory - mov esi, noFileStr - mov edx, noFileStr_end - noFileStr - -ccwd_001: - call outputStr - - ret - - -cmdQUIT: - ; The remote end will do the close; We just - ; say goodbye. - mov esi, byeStr - mov edx, byeStr_end - byeStr - call outputStr - ret - - -cmdABOR: - - ; Close port - call disconnectData - - mov esi, abortStr - mov edx, abortStr_end - abortStr - call outputStr - - ret - -cmdPORT: - ; TODO - ; Copy the IP and port values to DataIP and DataPort - - call parsePortStr - - ; Indicate the command was accepted - mov esi, cmdOKStr - mov edx, cmdOKStr_end - cmdOKStr - call outputStr - ret - -cmdnoop: - ; Indicate the command was accepted - mov esi, cmdOKStr - mov edx, cmdOKStr_end - cmdOKStr - call outputStr - ret - - -cmdTYPE: - ; TODO - ; Note the type field selected - reject if needed. - - ; Indicate the command was accepted - mov esi, cmdOKStr - mov edx, cmdOKStr_end - cmdOKStr - call outputStr - ret - -cmdsyst: - ; Indicate the system type - mov esi, systStr - mov edx, systStr_end - systStr - call outputStr - ret - - -cmdDELE: - call setupFilePath - - mov ebx, fileinfoblock - mov dword [ebx], 8 - and dword [ebx+4], 0 - push dword [ebx+12] - push dword [ebx+16] - and dword [ebx+12], 0 - and dword [ebx+16], 0 - mov eax, 70 - mcall - mov ebx, fileinfoblock - pop dword [ebx+16] - pop dword [ebx+12] - - test eax, eax - jne cmdDele_err - - mov esi, delokStr - mov edx, delokStr_end - delokStr - call outputStr - - jmp cmdDele_exit - -cmdDele_err: - mov esi, noFileStr - mov edx, noFileStr_end - noFileStr - call outputStr - - -cmdDele_exit: - ret - - -cmdNLST: -cmdLIST: - ; Indicate the command was accepted - mov esi, startStr - mov edx, startStr_end - startStr - call outputStr - - call connectData - - ; Wait for socket to establish - -cl001: - ; wait a bit - mov eax,5 - mov ebx,10 ; Delay for up 100ms - mcall - - ; check connection status - mov eax,53 - mov ebx,6 ; Get socket status - mov ecx,[DataSocket] - mcall - - cmp eax, 4 - jne cl001 - - ; send directory listing - call sendDir - - ; Close port - call disconnectData - - mov esi, endStr - mov edx, endStr_end - endStr - call outputStr - ret - -cmdRETR: - ; Indicate the command was accepted - mov esi, startStr - mov edx, startStr_end - startStr - call outputStr - - call connectData - - ; Wait for socket to establish - -cr001: - ; wait a bit - mov eax,5 - mov ebx,10 ; Delay for up 100ms - mcall - - ; check connection status - mov eax,53 - mov ebx,6 ; Get socket status - mov ecx,[DataSocket] - mcall - - cmp eax, 4 - jne cr001 - - ; send data to remote user - call sendFile - - ; Close port - call disconnectData - - mov esi, endStr - mov edx, endStr_end - endStr - call outputStr - - - ret - - -cmdSTOR: - ; Indicate the command was accepted - mov esi, storStr - mov edx, storStr_end - storStr - call outputStr - - call connectData - - ; Wait for socket to establish - -cs001: - ; wait a bit - mov eax,5 - mov ebx,10 ; Delay for up 100ms - mcall - - ; check connection status - mov eax,53 - mov ebx,6 ; Get socket status - mov ecx,[DataSocket] - mcall - - cmp eax, 4 - je @f - cmp eax, 7 - jne cs001 -@@: - - ; get data file from remote user - call getFile - - mov esi, endStr - mov edx, endStr_end - endStr - call outputStr - - ; Close port - call disconnectData - - ret - - - -; DATA AREA - -; This is the list of supported commands, and the function to call -; The list end with a NULL. -CMDList: - db 'pwd',0 - dd cmdPWD - - db 'PWD',0 - dd cmdPWD - - db 'XPWD',0 - dd cmdPWD - - db 'xpwd',0 - dd cmdPWD - - db 'QUIT',0 - dd cmdQUIT - - db 'quit',0 - dd cmdQUIT - - db 'PORT',0 - dd cmdPORT - - db 'port',0 - dd cmdPORT - - db 'LIST',0 - dd cmdLIST - - db 'list',0 - dd cmdLIST - - db 'NLST',0 - dd cmdNLST - - db 'nlst',0 - dd cmdNLST - - db 'TYPE',0 - dd cmdTYPE - - db 'type',0 - dd cmdTYPE - - db 'syst',0 - dd cmdsyst - - db 'noop',0 - dd cmdnoop - - db 'CWD',0 - dd cmdCWD - - db 'cwd',0 - dd cmdCWD - - db 'RETR',0 - dd cmdRETR - - db 'retr',0 - dd cmdRETR - - db 'DELE',0 - dd cmdDELE - - db 'dele',0 - dd cmdDELE - - db 'stor',0 - dd cmdSTOR - - db 'STOR',0 - dd cmdSTOR - - db 'ABOR',0 - dd cmdABOR - - db 'abor',0 - dd cmdABOR - - db 0xff,0xf4,0xff,0xf2,'ABOR',0 - dd cmdABOR - - db 0 - - -cmdPtr dd 0 -CmdSocket dd 0x0 -CmdSocketStatus dd 0x0 -DataSocket dd 0x0 -DataSocketStatus dd 0x0 -DataPort dd 0x00 -DataIP dd 0x00 -pos dd 80 * 1 -scroll dd 1 - dd 24 - -labelt db 'FTP Server v0.1',0 -contt db 'Connected' -contlen: -discontt db 'Disconnected' -discontlen: - -cmdOKStr: db '200 Command OK',0x0d,0x0a -cmdOKStr_end: - -loginStr0: db '220- Menuet FTP Server v0.1',0x0d,0x0a - db '220 Username and Password required',0x0d,0x0a -loginStr0_end: - -loginStr1: db '331 Password now required',0x0d,0x0a -loginStr1_end: - -loginStr2: db '230 You are now logged in.',0x0d,0x0a -loginStr2_end: - -byeStr: db '221 Bye bye!',0x0d,0x0a -byeStr_end: - -systStr: db '215 UNIX system type',0x0d,0x0a -systStr_end: - -curdir_1: db '257 "' -curdir_2: db '"',0x0d,0x0a -curdir_end: - -chdir: db '250 CWD command successful',0x0d,0x0a -chdir_end: - -unsupStr: db '500 Unsupported command',0x0d,0x0a -unsupStr_end: - -noFileStr: db '550 No such file',0x0d,0x0a -noFileStr_end: - -delokStr: db '250 DELE command successful',0x0d,0x0a -delokStr_end: - -startStr: db '150 Here it comes...',0x0d,0x0a -startStr_end: - -storStr: db '150 Connecting for STOR',0x0d,0x0a -storStr_end: - -endStr: db '226 Transfer OK, Closing connection',0x0d,0x0a -endStr_end: - -abortStr: db '225 Abort successful',0x0d,0x0a -abortStr_end: - - ; This is the buffer used for building up a directory listing line -dirStr: times 128 db 0 - -; This is template string used in building up a directory listing line -tmplStr: db 'rw-rw-rw- 1 0 0 ',0 - -months: - dd 'Jan ','Feb ','Mar ','Apr ','May ','Jun ' - dd 'Jul ','Aug ','Sep ','Oct ','Nov ','Dec ' - -fileinfoblock: - dd 0x00 - dd 0x00 - dd 0x00 - dd 0x200 ; bytes to read - dd text + 0x1300 ; data area -filename: times 256 db 0 - -; The following lines define data for reading a directory block -DirBlocksPerCall = 16 -dirinfoblock: - dd 1 - dd 0x00 - dd 0x00 - dd DirBlocksPerCall - dd text + 0x1300 ; data area -; The 'filename' for a directory listing -dirpath: db '/sys' - times 252 db 0 -curdirptr: dd dirpath+4 - -fsize: dd 0 - -state db 0 -buffptr dd 0 -buff: times 256 db 0 ; Could put this after iend - -; Ram use at the end of the application: -; text : 2400 bytes for screen memory -; text + 0x1300 : file data area -text: -I_END: diff --git a/programs/network_old/ftps/trunk/build.bat b/programs/network_old/ftps/trunk/build.bat deleted file mode 100644 index cc358c8c66..0000000000 --- a/programs/network_old/ftps/trunk/build.bat +++ /dev/null @@ -1,2 +0,0 @@ -@fasm ftps.asm ftps -@pause diff --git a/programs/network_old/popc/trunk/build_en.bat b/programs/network_old/popc/trunk/build_en.bat deleted file mode 100644 index d0f044b79c..0000000000 --- a/programs/network_old/popc/trunk/build_en.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix en >lang.inc -@fasm popc.asm popc -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/popc/trunk/build_ru.bat b/programs/network_old/popc/trunk/build_ru.bat deleted file mode 100644 index 1b1e24b509..0000000000 --- a/programs/network_old/popc/trunk/build_ru.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix ru >lang.inc -@fasm popc.asm popc -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/popc/trunk/popc.asm b/programs/network_old/popc/trunk/popc.asm deleted file mode 100644 index 37e7c92920..0000000000 --- a/programs/network_old/popc/trunk/popc.asm +++ /dev/null @@ -1,1019 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; ;; -;; POP CLIENT for MenuetOS ;; -;; - Modified from IRC client ;; -;; ;; -;; License: GPL / See file COPYING for details ;; -;; Copyright 2002 (c) Ville Turjanmaa ;; -;; ;; -;; Compile with FASM for Menuet ;; -;; ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -include 'macros.inc' -version equ '0.1' - -use32 - - org 0x0 - - db 'MENUET01' ; 8 byte id - dd 0x01 ; required os - dd START ; program start - dd I_END ; program image size - dd 0x200000 ; required amount of memory - dd 0xffff0 - dd 0,0 - -START: ; start of execution - - mov [file_start],0x100000 - - mov eax,70 - mov ebx,filel - mcall - - test eax,eax - jz @f - cmp eax,6 - jnz notfound -@@: - add [file_start],ebx - notfound: - - mov edi,I_END - mov ecx,60*120 - mov al,32 - cld - rep stosb - - mov eax,[rxs] - imul eax,11 - mov [pos],eax - - mov ebp,0 - mov edx,I_END - -redraw: ; redraw - call draw_window ; at first, draw the window - -still: - - mov eax,5 - mov ebx,1 - mcall - - mov eax,11 ; wait here for event - mcall - - cmp eax,1 ; redraw - je redraw - cmp eax,2 ; key - je key - cmp eax,3 ; button - je button - - cmp [I_END+120*60],byte 1 - jne no_main_update - mov [I_END+120*60],byte 0 - mov edx,I_END - call draw_server_data - no_main_update: - - cmp [server_active],0 - je noread - call read_incoming_data - noread: - - call print_status - - cmp [status],4 - je send_request - - jmp still - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Save the fetched mails -;; - - -save_file: - - pusha - - mov ebx,files - mov eax,[file_start] - sub eax,0x100000 - mov [ebx+12],eax - - mov eax,70 - mcall - - popa - - ret - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Send user id/passwd/mailrq -;; - - -send_request: - - inc [mcounter] - - cmp [mcounter],1000 - jbe no_send - - mov eax,[ccounter] - imul eax,32 - add eax,getmail - mov esi,eax - - inc [ccounter] - - mov edx,32 - - cmp [ccounter],1 - jne no1 - mov edx,5+2 - add edx,[l2] - no1: - - cmp [ccounter],2 - jne no2 - mov edx,5+2 - add edx,[l3] - no2: - - mov eax,53 - mov ebx,7 - mov ecx,[socket] - mcall - mov [mcounter],0 - - cmp [esi],dword 'quit' - je close_fetch - - - no_send: - - jmp still - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Close connection to server -;; - - -close_fetch: - - mov eax,53 - mov ebx,7 - mov ecx,[socket] - mov edx,14 - mov esi,quitc - mcall - mov [mcounter],0 - - mov eax,5 - mov ebx,150 - mcall - - call read_incoming_data - - mov eax,53 - mov ebx,8 - mov ecx,[socket] - mcall - - mov eax,5 - mov ebx,2 - mcall - - mov eax,53 - mov ebx,8 - mov ecx,[socket] - mcall - - mov [server_active],0 - - jmp still - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; User input processing -;; - - -key: - - mov eax,2 - mcall - - jmp still - - -button: ; button - - mov eax,17 ; get id - mcall - - cmp ah,60 - jne no_open - mov eax, 70 - mov ebx, tinypad_start - mcall - jmp still - no_open: - - cmp ah,1 ; close program - jne noclose - mov eax,-1 - mcall - noclose: - - cmp ah,51 - je read_string - cmp ah,52 - je read_string - cmp ah,53 - je read_string - - call socket_commands - - jmp still - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Socket open & close -;; - -socket_commands: - - cmp ah,22 ; open socket - jnz tst3 - - mov [server_active],1 - - mov [mcounter],900 - mov [ccounter],0 - - mov eax,3 - mcall - - mov eax,3 - mcall - mov ecx,eax - and ecx,0xffff - - mov eax,53 - mov ebx,5 - mov edx,110 - mov esi,dword [ip] - mov edi,1 - mcall - mov [socket], eax - - ret - tst3: - - - cmp ah,24 ; close socket - jnz no_24 - mov eax,53 - mov ebx,8 - mov ecx,[socket] - mcall - mov [header_sent],0 - mov [mail_rp],0 - mov [server_active],0 - - ret - no_24: - - ret - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Display connection status -;; - -old_status dd 0x0 - -print_status: - - pusha - - mov eax,53 - mov ebx,6 - mov ecx,[socket] - mcall - - mov [status],eax - - cmp eax,[old_status] - je nopr - - mov [old_status],eax - - push eax - - mov eax,13 - mov ebx,200*65536+30 - mov ecx,160*65536+10 - mov edx,0xffffff - mcall - - pop ecx - - cmp [server_active],1 - jne nopr - - mov eax,47 - mov ebx,3*65536 - mov edx,200*65536+160 - mov esi,0x000000 - mcall - - nopr: - - popa - - ret - - - - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Read data from server -;; - - -read_incoming_data: - - pusha - - read_new_byte: - - call read_incoming_byte - cmp ecx,-1 - je no_data_in_buffer - - mov eax,[file_start] - mov [eax],bl - inc [file_start] - - cmp bl,10 - jne no_start_command - mov [cmd],1 - no_start_command: - - cmp bl,13 - jne no_end_command - mov eax,[cmd] - mov [eax+command-2],byte 0 - call save_file - call analyze_data - mov edi,command - mov ecx,250 - mov eax,0 - cld - rep stosb - mov [cmd],0 - no_end_command: - - mov eax,[cmd] - cmp eax,250 - jge still - - mov [eax+command-2],bl - inc [cmd] - - jmp read_new_byte - - no_data_in_buffer: - - popa - - ret - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Read user input for ip/user/passwd -;; - - -read_string: - - shr eax,8 - sub eax,51 - mov ebx,eax - imul eax,12 - add eax,181 - - mov [len],ebx - shl [len],2 - add [len],l1 - - imul ebx,50 - add ebx,input1 - - mov [addr],ebx - mov [ya],eax - - mov edi,[addr] - mov eax,0 - mov ecx,30 - cld - rep stosb - - call print_input_text - - mov edi,[addr] - - f11: - mov eax,10 - mcall - cmp eax,2 - jne read_done - mov eax,2 - mcall - shr eax,8 - cmp eax,13 - je read_done - cmp eax,8 - jnz nobsl - cmp edi,[addr] - jz f11 - sub edi,1 - mov [edi],byte 32 - call print_text - jmp f11 - nobsl: - mov [edi],al - - call print_input_text - - add edi,1 - mov esi,[addr] - add esi,30 - cmp esi,edi - jnz f11 - - read_done: - - push edi - - mov ecx,40 - mov eax,32 - cld - rep stosb - - call print_input_text - - pop edi - sub edi,[addr] - mov eax,[len] - mov [eax],edi - - cmp [len],l1 - jne noip - mov esi,input1 - mov edi,ip_text+15 - mov ecx,16 - cld - rep movsb - call ip_set - noip: - - cmp [len],l2 - jne nol2 - mov esi,input2 - mov edi,l2_text+15 - mov ecx,22 - cld - rep movsb - mov esi,input2 - mov edi,getmail+5 - mov ecx,[l2] - cld - rep movsb - mov al,13 - stosb - mov al,10 - stosb - nol2: - - cmp [len],l3 - jne nol3 - mov esi,input3 - mov edi,getmail+32+5 - mov ecx,[l3] - cld - rep movsb - mov al,13 - stosb - mov al,10 - stosb - nol3: - - call draw_window - - jmp still - - - -print_input_text: - - pusha - - mov eax,13 - mov ebx,95*65536+23*6 - mov ecx,[ya] - shl ecx,16 - mov cx,9 - mov edx,0xffffff - mcall - - cmp [len],l3 - je noprt - - mov eax,4 - mov edx,[addr] - mov ebx,95*65536 - add ebx,[ya] - mov ecx,0x000000 - mov esi,23 - mcall - - noprt: - - popa - ret - - -ip_set: - - mov esi,input1-1 - mov edi,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,ip+3 - jbe ip1 - ret - no_read_ip: - - ret - - -analyze_data: - - pusha - - mov [text_start],I_END - mov ecx,[rxs] - imul ecx,11 - mov [pos],ecx - - mov bl,13 - call print_character - mov bl,10 - call print_character - - cmp [cmd],2 - jbe nott - mov ecx,[cmd] - sub ecx,2 - mov esi,command+0 - newcmdc: - mov bl,[esi] - call print_character - inc esi - loop newcmdc - - nott: - - mov edx,I_END - call draw_server_data - - cmd_len_ok: - - cmp [command],dword '-ERR' - je close_fetch - - cmp [command],word '+O' - jne nook - mov [mcounter],990 - nook: - - popa - - ret - - - -draw_data: - - push eax - - add eax,[text_start] - mov [eax],bl - - pop eax - ret - - - -print_text: - - pusha - - mov ecx,command-2 - add ecx,[cmd] - - ptr2: - mov bl,[eax] - cmp bl,dl - je ptr_ret - cmp bl,0 - je ptr_ret - call print_character - inc eax - cmp eax,ecx - jbe ptr2 - - ptr_ret: - - mov eax,[text_start] - mov [eax+120*60],byte 1 - - popa - ret - - - -print_character: - - pusha - - cmp bl,13 ; line beginning - jne nobol - mov ecx,[pos] - add ecx,1 - boll1: - sub ecx,1 - mov eax,ecx - xor edx,edx - mov ebx,[rxs] - div ebx - cmp edx,0 - jne boll1 - mov [pos],ecx - jmp newdata - nobol: - - cmp bl,10 ; line down - jne nolf - addx1: - add [pos],dword 1 - mov eax,[pos] - xor edx,edx - mov ecx,[rxs] - div ecx - cmp edx,0 - jnz addx1 - mov eax,[pos] - jmp cm1 - nolf: - no_lf_ret: - - - cmp bl,15 ; character - jbe newdata - - mov eax,[irc_data] - shl eax,8 - mov al,bl - mov [irc_data],eax - - mov eax,[pos] - call draw_data - - mov eax,[pos] - add eax,1 - cm1: - mov ebx,[scroll+4] - imul ebx,[rxs] - cmp eax,ebx - jb noeaxz - - mov esi,[text_start] - add esi,[rxs] - - mov edi,[text_start] - mov ecx,ebx - cld - rep movsb - - mov esi,[text_start] - mov ecx,[rxs] - imul ecx,61 - add esi,ecx - - mov edi,[text_start] - mov ecx,[rxs] - imul ecx,60 - add edi,ecx - mov ecx,ebx - cld - rep movsb - - mov eax,ebx - sub eax,[rxs] - noeaxz: - mov [pos],eax - - newdata: - - mov eax,[text_start] - mov [eax+120*60],byte 1 - - popa - ret - - - -read_incoming_byte: - - mov eax, 53 - mov ebx, 2 - mov ecx, [socket] - mcall - - mov ecx,-1 - - cmp eax,0 - je no_more_data - - mov eax, 53 - mov ebx, 3 - mov ecx, [socket] - mcall - - mov ecx,0 - - no_more_data: - - ret - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Window definitions -;; - - - -draw_window: - - pusha - - mov eax,12 - mov ebx,1 - mcall - - mov eax,0 ; draw window - mov ebx,5*65536+435 - mov ecx,5*65536+232 - mov edx,0x14ffffff - mov edi,labelt - mcall - - mov [old_status],300 - - mov eax,8 ; button: open socket - mov ebx,23*65536+22 - mov ecx,155*65536+10 - mov edx,22 - mov esi,0x44cc44 - mcall - -; mov eax,8 ; button: close socket - mov ebx,295*65536+22 - mov ecx,155*65536+10 - mov edx,24 - mov esi,0xcc4444 - mcall - -; mov eax,8 ; button: text entries - mov ebx,243*65536+8 - mov ecx,180*65536+8 - mov edx,51 - mov esi,0x4488dd - newi: - mcall - inc edx - add ecx,12*65536 - cmp edx,53 - jbe newi - -; mov eax,8 ; open inbox - mov ebx,295*65536+102 - mov ecx,190*65536+14 - mov edx,60 - mov esi,0x5577dd - mcall - - mov eax,38 ; line - mov ebx,5*65536+430 - mov ecx,114*65536+114 - mov edx,0x000000 - mcall - - mov ebx,5*65536+133 ; info text - mov ecx,0x000000 - mov edx,text - mov esi,70 - newline: - mov eax,4 - mcall - add ebx,12 - add edx,70 - cmp [edx],byte 'x' - jne newline - - mov edx,I_END ; text from server - call draw_server_data - - mov eax,12 - mov ebx,2 - mcall - - popa - - ret - - -draw_server_data: - - pusha - - mov eax,4 - mov ebx,10*65536+26 - mov ecx,8 - mov esi,[rxs] - dct: - pusha - mov ecx,ebx - shl ecx,16 - mov cl,9 - mov eax,13 - mov ebx,10*65536 - mov bx,word [rxs] - imul bx,6 - mov edx,0xffffff - mcall - popa - push ecx - mov eax,4 - mov ecx,0 - mcall - add edx,[rxs] - add ebx,10 - pop ecx - loop dct - - popa - ret - - - -text: - -db ' Incoming mails are written to /rd/1/popc.txt ' -db ' ' -db ' Check for mail. Force close ' -db ' ' -ip_text: -db ' Server IP : 192.168.1.200 < ' -l2_text: -db ' User : < Open popc.txt ' - l3_text: -db ' Password : (not shown) < ' - -db 'x' ; <- END MARKER, DONT DELETE - -file_start dd 0x100000 - -; max size is 0x100000 bytes, read to/write from 0x100000 -files: - dd 2,0,0,?,0x100000 - db 0 - dd pr -filel: - dd 0,0,0,0x100000,0x100000 -pr db '/sys/popc.txt',0 - -ip db 192,168,1,200 - -socket dd 0x0 - -posx dd 0x0 -incoming_pos dd 0x0 -incoming_string: times 128 db 0 -pos dd 0x0 - -text_start dd I_END -print db 0x0 -cmd dd 0x0 -rxs dd 66 - -res: db 0,0 -command: times 256 db 0x0 - -command_position dd 0 -counter dd 0 - -numtext db ' ' -labelt db 'POP client v ',version,0 -scroll: dd 1,8 - -tinypad_start: - dd 7 - dd 0 - dd pr - dd 0 - dd 0 - db '/sys/TINYPAD',0 - -getmail: - db 'user xyz ',13,10 - db 'pass xyz ',13,10 - db 'retr 1 ',13,10 - db 'retr 2 ',13,10 - db 'retr 3 ',13,10 - db 'retr 4 ',13,10 - db 'retr 5 ',13,10 - db 'retr 6 ',13,10 - db 'retr 7 ',13,10 - db 'retr 8 ',13,10 - db 'retr 9 ',13,10 - -quitc: - db 'quit ',13,10 - -mcounter dd 900 -ccounter dd 0 - -ld db 13,10 - -server_active db 0 - -header_sent db 0 - -close_connection dd 0x0 - -mail_rp dd 0 - -irc_data dd 0x0 -addr dd 0x0 -ya dd 0x0 -len dd 0x0 - -input1: times 50 db 32 -input2: times 50 db 32 -input3: times 50 db 32 - -l1 dd 0 -l2 dd 3 -l3 dd 3 - -status dd 0x0 - -I_END: diff --git a/programs/network_old/stackcfg/trunk/build_en.bat b/programs/network_old/stackcfg/trunk/build_en.bat deleted file mode 100644 index 62e160553d..0000000000 --- a/programs/network_old/stackcfg/trunk/build_en.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix en >lang.inc -@fasm stackcfg.asm stackcfg -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/stackcfg/trunk/build_ru.bat b/programs/network_old/stackcfg/trunk/build_ru.bat deleted file mode 100644 index eff4b4682e..0000000000 --- a/programs/network_old/stackcfg/trunk/build_ru.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix ru >lang.inc -@fasm stackcfg.asm stackcfg -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/stackcfg/trunk/readme.txt b/programs/network_old/stackcfg/trunk/readme.txt deleted file mode 100644 index 4775612710..0000000000 --- a/programs/network_old/stackcfg/trunk/readme.txt +++ /dev/null @@ -1,11 +0,0 @@ -╧ЁюуЁрььр фы  эрёЄЁющъ ёхЄхт√ї ярЁрьхЄЁют -28.10.06 Heavyiron -─юсртыхэ ярЁрьхЄЁ BOOT -╥хяхЁ№ ьюцэю т шёїюфэшъ тсшЄ№ эєцэ√х IP, ьрёъє, °ы■ч ш DNS, яхЁхъюьяшыышЁютрЄ№ яЁюуЁрььє ш чръшэєЄ№ хх т ртЄючруЁєчъє. ╤ыхфютрЄхы№эю ¤Єш эрёЄЁющъш эх яЁшфхЄё  ърцф√щ Ёрч тсштрЄ№ тЁєўэє■. -┬ autorun.dat эхюсїюфшью яюьхёЄшЄ№,эряЁшьхЁ, Єръє■ ёЄЁюъє: -/sys/stackcfg BOOT 30 # Set yor network settings, -эх чрс√т яЁш ¤Єюь єтхышўшЄ№ ъюышўхёЄтю чряєёърхь√ї яЁюуЁрьь эр юфэє -т ёрьюь эрўрых Їрщыр autorun.dat. - -TODO: -ёфхырЄ№ ўЄхэшх эрёЄЁюхъ шч Їрщыр network.dat, ўЄюс√ эх ЄЁхсютрырё№ яхЁхъюьяшыы Ўш  фы  шчьхэхэш  эрёЄЁюхъ. \ No newline at end of file diff --git a/programs/network_old/stackcfg/trunk/stackcfg.asm b/programs/network_old/stackcfg/trunk/stackcfg.asm deleted file mode 100644 index 9a7b1d37f2..0000000000 --- a/programs/network_old/stackcfg/trunk/stackcfg.asm +++ /dev/null @@ -1,701 +0,0 @@ - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; ; -; Stack Configuration Tool ; -; ; -; Compile with FASM for Menuet ; -; ; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - -memsize = 100000h - org 0 -PARAMS = memsize - 1024 - -use32 - - db 'MENUET01' ; 8 byte id - dd 0x01 ; header version - dd START ; start of code - dd I_END ; size of image - dd memsize ; memory for app - dd memsize - 1024 ; esp - dd PARAMS , 0x0 ; I_Param , I_Icon - -include 'lang.inc' -include '../../../macros.inc' - -START: ; start of execution - -read_stack_setup: - - mov eax,52 - mov ebx,0 - mcall - mov [config],eax - - mov eax,52 - mov ebx,1 - mcall - mov dword [ip_address],eax - - mov eax,52 - mov ebx,9 - mcall - mov dword [gateway_ip],eax - - mov eax,52 - mov ebx,10 - mcall - mov dword [subnet_mask],eax - - mov eax,52 - mov ebx,13 - mcall - mov dword [dns_ip],eax - - mov eax,[config] ; unwrap com IRQ - shr eax,8 - and eax,0xf - mov [com_irq],eax - - mov eax,[config] ; unwrap com PORT - shr eax,16 - and eax,0xfff - mov [com_add],eax - - mov eax,[config] ; unwrap IRQ - and eax,0xf - mov [interface],eax - - mov eax,[config] ; unwrap com PORT - shr eax,7 - and eax,1 - mov [assigned],eax - - red: - call draw_window ; at first, draw the window - -still: - - mov eax,10 ; wait here for event - mcall - - cmp eax,1 ; redraw request ? - jz red - cmp eax,2 ; key in buffer ? - jnz button - - key: ; key -; mov al,2 ; just read it and ignore - mcall - jmp still - - button: ; button - mov al,17 ; get id - mcall - - shr eax,8 - - dec eax ; button id=1 ? - jne noclose - or eax,-1 ; close this program - mcall - noclose: - - dec eax - je read_stack_setup - - dec eax - jne no_apply_stack_setup - call apply_stack_setup - jmp still - -no_apply_stack_setup: - dec eax ; GET COM PORT - dec eax - jne no_read_comport - mov [string_x],272 - mov [string_y],40 - mov [string_length],3 - call read_string - movzx eax,byte [string] - cmp eax,'A' - jb gcp1 - sub eax,'A'-'9'-1 - gcp1: - sub eax,48 - shl eax,8 - mov ebx,eax - movzx eax,byte [string+1] - cmp eax,'A' - jb gcp2 - sub eax,'A'-'9'-1 - gcp2: - sub eax,48 - shl eax,4 - add ebx,eax - movzx eax,byte [string+2] - cmp eax,'A' - jb gcp3 - sub eax,'A'-'9'-1 - gcp3: - sub eax,48 - add ebx,eax - mov [com_add],ebx - jmp red - no_read_comport: - - dec eax ; GET COM IRQ - jne no_read_comirq - mov [string_x],284 - mov [string_y],50 - mov [string_length],1 - call read_string - movzx eax,byte [string] - cmp eax,'A' - jb gci1 - sub eax,'A'-'9'-1 - gci1: - sub eax,48 - mov [com_irq],eax - jmp red - no_read_comirq: - - dec eax ; GET IP - jne no_read_ip - mov [string_x],205 - mov [string_y],80 - mov [string_length],15 - call read_string - mov esi,string-1 - mov edi,ip_address - ip0: - 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: - stosb - cmp edi,ip_address+3 - jbe ip0 - jmp red - no_read_ip: - - dec eax ; set gateway ip - jne no_set_gateway - - mov [string_x],205 - mov [string_y],90 - mov [string_length],15 - call read_string - mov esi,string-1 - mov edi,gateway_ip - gip0: - xor eax,eax - gip1: - inc esi - cmp [esi],byte '0' - jb gip2 - cmp [esi],byte '9' - jg gip2 - imul eax,10 - movzx ebx,byte [esi] - sub ebx,48 - add eax,ebx - jmp gip1 - gip2: - stosb - cmp edi,gateway_ip+3 - jbe gip0 - jmp red - - no_set_gateway: - - dec eax - jne no_set_subnet - - mov [string_x],205 - mov [string_y],100 - mov [string_length],15 - call read_string - mov esi,string-1 - mov edi,subnet_mask - sip0: - xor eax,eax - sip1: - inc esi - cmp [esi],byte '0' - jb sip2 - cmp [esi],byte '9' - jg sip2 - imul eax,10 - movzx ebx,byte [esi] - sub ebx,48 - add eax,ebx - jmp sip1 - sip2: - stosb - cmp edi,subnet_mask+3 - jbe sip0 - jmp red - - no_set_subnet: - dec eax - jne no_set_dns - - mov [string_x],205 - mov [string_y],110 - mov [string_length],15 - call read_string - mov esi,string-1 - mov edi,dns_ip - dip0: - xor eax,eax - dip1: - inc esi - cmp [esi],byte '0' - jb dip2 - cmp [esi],byte '9' - jg dip2 - imul eax,10 - movzx ebx,byte [esi] - sub ebx,48 - add eax,ebx - jmp dip1 - dip2: - stosb - cmp edi,dns_ip+3 - jbe dip0 - jmp red - - no_set_dns: - - dec eax - jb no_set_interface - cmp eax,14-11 - ja no_set_interface - mov [interface],eax - jmp red - no_set_interface: - - sub eax,21-11 - jb no_ip_sf - cmp eax,22-21 - ja no_ip_sf - xor eax,1 - mov [assigned],eax - jmp red - no_ip_sf: - jmp still - -apply_stack_setup: - - mov eax,[com_irq] - shl eax,8 - mov ebx,[com_add] - shl ebx,16 - add eax,ebx - add eax,[interface] - mov ebx,[assigned] - shl ebx,7 - add eax,ebx - mov [config],eax - - mov eax,52 - mov ebx,3 - mov ecx,dword [ip_address] - mcall - - mov eax,52 - mov ebx,11 - mov ecx,dword [gateway_ip] - mcall - - mov eax,52 - mov ebx,12 - mov ecx,dword [subnet_mask] - mcall - - mov eax,52 - mov ebx,14 - mov ecx,dword [dns_ip] - mcall - - mov eax,52 - mov ebx,2 - mov ecx,[config] - mcall - - ret - - -string_length dd 16 -string_x dd 200 -string_y dd 60 - -string db '________________' - - -read_string: - - mov edi,string - mov eax,'_' - mov ecx,[string_length] - cld - rep stosb - call print_text - - mov edi,string - f11: - mov eax,10 - mcall - cmp eax,2 - jne read_done -; mov eax,2 - mcall - shr eax,8 - cmp eax,13 - je read_done - cmp eax,8 - jnz nobsl - cmp edi,string - jz f11 - sub edi,1 - mov [edi],byte '_' - call print_text - jmp f11 - nobsl: - cmp eax,dword 31 - jbe f11 - cmp eax,dword 95 - jb keyok - sub eax,32 - keyok: - mov [edi],al - call print_text - - inc edi - mov esi,string - add esi,[string_length] - cmp esi,edi - jnz f11 - - read_done: - -print_text: - - pusha - - mov eax,13 - mov ebx,[string_x] - shl ebx,16 - add ebx,[string_length] - imul bx,6 - mov ecx,[string_y] - shl ecx,16 - mov cx,8 - mov edx,0xffffff - mcall - - mov eax,4 - mov ebx,[string_x] - shl ebx,16 - add ebx,[string_y] - mov ecx,0x000000 - mov edx,string - mov esi,[string_length] - mcall - - popa - ret - - - - - - - -; ********************************************* -; ******* WINDOW DEFINITIONS AND DRAW ******** -; ********************************************* - - -draw_window: - - mov eax,12 ; function 12:tell os about windowdraw - mov ebx,1 ; 1, start of draw - mcall - - ; DRAW WINDOW - mov eax,0 ; function 0 : define and draw window - mov ebx,100*65536+330 ; [x start] *65536 + [x size] - mov ecx,100*65536+157 ; [y start] *65536 + [y size] - mov edx,0x14ffffff ; color of work area RRGGBB,8->color gl - mov edi,title ; WINDOW LABEL - mcall - - - mov eax,8 ; BUTTON : READ SETUP - mov ebx,90*65536+65 - mov ecx,127*65536+12 - mov edx,2 - mov esi,[button_color] - mcall - - ;mov eax,8 ; BUTTON : APPLY SETUP - mov ebx,163*65536+65 - mov ecx,127*65536+12 - mov edx,3 - mcall - - ;mov eax,8 ; BUTTONS 11-14 : SELECT INTERFACE - mov ebx,29*65536+8 - mov ecx,39*65536+8 - mov edx,11 - interface_select: - mcall - add ecx,10*65536 - inc edx - cmp edx,11+4 - jb interface_select - - mov ebx,[interface] ; PRINT SELECTED INTERFACE 'X' - imul ebx,10 - add ebx,31*65536+39 - mov eax,4 - mov ecx,0xffffff - mov edx,xx - mov esi,1 - mcall - - mov eax,8 ; BUTTONS 21-22 : SERVER / MANUAL IP - mov ebx,143*65536+8 - mov ecx,69*65536+8 - mov edx,21 - mov esi,[button_color] - mcall - ;mov eax,8 - mov ebx,143*65536+8 - mov ecx,79*65536+8 - mov edx,22 - mcall - mov ebx,[assigned] ; PRINT SELECTED SERVER/MANUAL 'X' - not ebx - and ebx,1 - imul ebx,10 - add ebx,145*65536+69 - mov eax,4 - mov ecx,0xffffff - mov edx,xx - mov esi,1 - mcall - - mov eax,47 ; COM ADDRESS - mov ebx,3*65536+1*256 - mov ecx,[com_add] - mov edx,272*65536+40 - mov esi,0x000000 - mcall - - ;mov eax,47 ; COM IRQ - mov ebx,1*65536+1*256 - mov ecx,[com_irq] - mov edx,(266+3*6)*65536+50 - mov esi,0x000000 - mcall - - mov edi,ip_address - mov edx,205*65536+80 - mov esi,0x000000 - mov ebx,3*65536 - ipdisplay: - ;mov eax,47 - movzx ecx,byte [edi] - mcall - add edx,6*4*65536 - inc edi - cmp edi,ip_address+4 - jb ipdisplay - - mov edi,gateway_ip - mov edx,205*65536+90 - mov esi,0x000000 - mov ebx,3*65536 - gipdisplay: - ;mov eax,47 - movzx ecx,byte [edi] - mcall - add edx,6*4*65536 - inc edi - cmp edi,gateway_ip+4 - jb gipdisplay - - mov edi,subnet_mask - mov edx,205*65536+100 - mov esi,0x000000 - mov ebx,3*65536 - sipdisplay: - ;mov eax,47 - movzx ecx,byte [edi] - mcall - add edx,6*4*65536 - inc edi - cmp edi,subnet_mask+4 - jb sipdisplay - - mov edi,dns_ip - mov edx,205*65536+110 - mov esi,0x000000 - mov ebx,3*65536 - dipdisplay: - ;mov eax,47 - movzx ecx,byte [edi] - mcall - add edx,6*4*65536 - inc edi - cmp edi,dns_ip+4 - jb dipdisplay - - - mov eax,8 ; BUTTON 5 : SET PORT - mov ebx,299*65536+8 - mov ecx,39*65536+8 - mov edx,5 - mov esi,[button_color] - mcall - ;mov eax,8 ; BUTTON 6 : SET IRQ - mov ecx,49*65536+8 - inc edx - mcall - ;mov eax,8 ; BUTTON 7 : SET IP - mov ecx,79*65536+8 - inc edx - mcall - - ;mov eax,8 ; BUTTON 8 : SET gateway IP - mov ebx,299*65536+8 - mov ecx,89*65536+8 - inc edx - mcall - - ;mov eax,8 ; BUTTON 9 : SET subnet - mov ecx,99*65536+8 - inc edx - mcall - - ;mov eax,8 ; BUTTON 10 : SET dns ip - mov ecx,109*65536+8 - inc edx - mcall - - mov ebx,31*65536+40 ; draw info text with function 4 - mov edx,text - mov esi,49 - mov eax,4 - newline: - mov ecx,0x224466 - cmp [edx],byte 'w' - jne nowhite - mov ecx,0xeeeeee - nowhite: - inc edx - mcall - add ebx,10 - add edx,49 - cmp [edx],byte 'x' - jne newline - - mov eax,12 ; function 12:tell os about windowdraw - mov ebx,2 ; 2, end of draw - mcall - - ret - - -; DATA AREA - -if lang eq ru -title db 'Настройка сетевого стека',0 -text: - db ' Неактивный Модем на Com-порту: 0x < ' - db ' Slip Прерывание модема: 0x < ' - db ' PPP ' - db ' Драйвер пакетов IP назначается сервером ' - db ' (Ethernet) Фикс.: . . . < ' - db ' Шлюз: . . . < ' - db ' Подсеть: . . . < ' - db ' DNS IP: . . . < ' - db ' ' - db 'w Читать Применить ' - -else if lang eq nl -title db 'Netwerk configuratie',0 -text: - db ' Niet actief Modem Com Poort: 0x < ' - db ' Slip Modem Com Irq: 0x < ' - db ' PPP ' - db ' Pakket Driver Door IP-server toegekend ' - db ' (Ethernet) Vast IP: . . . < ' - db ' Gateway: . . . < ' - db ' Subnet: . . . < ' - db ' DNS IP: . . . < ' - db ' ' - db 'w Vernieuw Toepassen ' - -else if lang eq ua -title db 'Налаштування мережi' -text: - db ' Неактивний Модем на Com-порту 0x < ' - db ' Slip Com-порт модема: 0x < ' - db ' PPP ' - db ' Драйвер пакетiв IP призначається сервером ' - db ' (Ethernet) Фiкс.: . . . < ' - db ' Маршрут: . . . < ' - db ' Маска: . . . < ' - db ' DNS IP . . . < ' - db ' ' - db 'w Прочитати Застосувати ' - -else -title db 'Stack configuration',0 -text: - db ' Not active Modem Com Port: 0x < ' - db ' Slip Modem Com Irq: 0x < ' - db ' PPP ' - db ' Packet Driver IP server assigned ' - db ' (Ethernet) Fixed: . . . < ' - db ' Gateway: . . . < ' - db ' Subnet: . . . < ' - db ' DNS IP: . . . < ' - db ' ' - db 'w READ APPLY ' - end if - -xx: db 'x' ;<- END MARKER, DONT DELETE - -button_color dd 0x2254b9 - - - -ip_address dd ? -gateway_ip dd ? -subnet_mask dd ? -dns_ip dd ? - - -com_irq dd ? ; irq for slip/ppp -com_add dd ? ; com port address for slip/ppp -interface dd ? ; not active,slip,ppp,packet driver -assigned dd ? ; get ip from server - -config dd ? - -I_END: diff --git a/programs/network_old/telnet/trunk/build_en.bat b/programs/network_old/telnet/trunk/build_en.bat deleted file mode 100644 index 5195411ba8..0000000000 --- a/programs/network_old/telnet/trunk/build_en.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix en >lang.inc -@fasm telnet.asm telnet -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/telnet/trunk/build_ru.bat b/programs/network_old/telnet/trunk/build_ru.bat deleted file mode 100644 index 3e64ce994d..0000000000 --- a/programs/network_old/telnet/trunk/build_ru.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix ru >lang.inc -@fasm telnet.asm telnet -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/telnet/trunk/telnet.asm b/programs/network_old/telnet/trunk/telnet.asm deleted file mode 100644 index d507265802..0000000000 --- a/programs/network_old/telnet/trunk/telnet.asm +++ /dev/null @@ -1,793 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; -; TERMINAL -; -; Compile with FASM for Menuet -; - -use32 - org 0x0 - db 'MENUET01' ; header - dd 0x01 ; header version - dd START ; entry point - dd I_END ; image size - dd I_END+0x10000 ; required memory - dd I_END+0x10000 ; esp - dd 0x0 , 0x0 ; I_Param , I_Path - - -include 'lang.inc' -include 'macros.inc' - -START: ; start of execution - - ; Clear the screen memory - mov eax, ' ' - mov edi,text - mov ecx,80*30 /4 - cld - rep stosd - - - call draw_window - - -still: - ; check connection status - mov eax,53 - mov ebx,6 - mov ecx,[socket] - mcall - - mov ebx, [socket_status] - mov [socket_status], eax - - cmp eax, ebx - je waitev - -red: - call draw_window - -waitev: - mov eax,23 ; wait here for event - mov ebx,20 - mcall - - cmp eax,1 ; redraw request ? - je red - cmp eax,2 ; key in buffer ? - je key - cmp eax,3 ; button in buffer ? - je button - - ; any data from the socket? - - mov eax, 53 - mov ebx, 2 - mov ecx, [socket] - mcall - cmp eax, 0 - jne read_input - - jmp still - - -read_input: - - push ecx - mov eax, 53 - mov ebx, 3 - mov ecx, [socket] - mcall - pop ecx - - call handle_data - - push ecx - mov eax, 53 - mov ebx, 2 - mov ecx, [socket] - mcall - pop ecx - cmp eax, 0 - - - jne read_input - call draw_text - jmp still - - - -handle_data: - ; Telnet servers will want to negotiate options about our terminal window - ; just reject them all. - ; Telnet options start with the byte 0xff and are 3 bytes long. - - mov al, [telnetstate] - cmp al, 0 - je state0 - cmp al, 1 - je state1 - cmp al, 2 - je state2 - jmp hd001 - -state0: - cmp bl, 255 - jne hd001 - mov al, 1 - mov [telnetstate], al - ret - -state1: - mov al, 2 - mov [telnetstate], al - ret - -state2: - mov al, 0 - mov [telnetstate], al - mov [telnetrep+2], bl - - mov edx, 3 - mov eax,53 - mov ebx,7 - mov ecx,[socket] - mov esi, telnetrep - mcall - ret - -hd001: - cmp bl,13 ; BEGINNING OF LINE - jne nobol - mov ecx,[pos] - add ecx,1 - boll1: - sub ecx,1 - mov eax,ecx - xor edx,edx - mov ebx,80 - div ebx - cmp edx,0 - jne boll1 - mov [pos],ecx - jmp newdata - nobol: - - cmp bl,10 ; LINE DOWN - jne nolf - addx1: - add [pos],dword 1 - mov eax,[pos] - xor edx,edx - mov ecx,80 - div ecx - cmp edx,0 - jnz addx1 - mov eax,[pos] - jmp cm1 - nolf: - - cmp bl,8 ; BACKSPACE - jne nobasp - mov eax,[pos] - dec eax - mov [pos],eax - mov [eax+text],byte 32 - mov [eax+text+60*80],byte 0 - jmp newdata - nobasp: - - cmp bl,15 ; CHARACTER - jbe newdata - mov eax,[pos] - mov [eax+text],bl - mov eax,[pos] - add eax,1 - cm1: - mov ebx,[scroll+4] - imul ebx,80 - cmp eax,ebx - jb noeaxz - mov esi,text+80 - mov edi,text - mov ecx,ebx - cld - rep movsb - mov eax,ebx - sub eax,80 - noeaxz: - mov [pos],eax - newdata: - ret - - key: ; KEY - mov eax,2 ; send to modem - mcall - - mov ebx, [socket_status] - cmp ebx, 4 ; connection open? - jne still ; no, so ignore key - - shr eax,8 - cmp eax,178 ; ARROW KEYS - jne noaup - mov al,'A' - call arrow - jmp still - noaup: - cmp eax,177 - jne noadown - mov al,'B' - call arrow - jmp still - noadown: - cmp eax,179 - jne noaright - mov al,'C' - call arrow - jmp still - noaright: - cmp eax,176 - jne noaleft - mov al,'D' - call arrow - jmp still - noaleft: - modem_out: - - call to_modem - - jmp still - - button: ; BUTTON - mov eax,17 - mcall - cmp ah,1 ; CLOSE PROGRAM - jne noclose - - mov eax,53 - mov ebx,8 - mov ecx,[socket] - mcall - - or eax,-1 - mcall - noclose: - cmp ah, 2 ; Set IP - jne notip - - mov [string_x], dword 78 - mov [string_y], dword 276 - mov [string_length], dword 15 - call read_string - mov esi,string-1 - mov edi,ip_address - 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,ip_address+3 - jbe ip1 - call draw_window - - - jmp still - -notip: - cmp ah, 3 ; set port - jne notport - - mov [string_x], dword 215 - mov [string_y], dword 276 - mov [string_length], dword 4 - call read_string - mov esi,string-1 - mov edi,port - xor eax,eax - ip11: - inc esi - cmp [esi],byte '0' - jb ip21 - cmp [esi],byte '9' - jg ip21 - imul eax,10 - movzx ebx,byte [esi] - sub ebx,48 - add eax,ebx - jmp ip11 - ip21: - mov [edi],al - inc edi - mov [edi],ah - call draw_window - - - jmp still - -notport: - cmp ah, 4 ; connect - jne notcon - - mov eax, [socket_status] - cmp eax, 4 - je still - call connect - - jmp still - -notcon: - cmp ah,5 ; disconnect - jne notdiscon - - call disconnect - jmp still - -notdiscon: ; Echo Toggle - cmp ah, 6 - jne still - - mov al, [echo] - not al - mov [echo], al - - call draw_window - jmp still - -arrow: - - push eax - mov al,27 - call to_modem - mov al,'[' - call to_modem - pop eax - call to_modem - - ret - - -to_modem: - pusha - push ax - mov [tx_buff], al - mov edx, 1 - cmp al, 13 - jne tm_000 - mov edx, 2 -tm_000: - mov eax,53 - mov ebx,7 - mov ecx,[socket] - mov esi, tx_buff - mcall - pop bx - mov al, [echo] - cmp al, 0 - je tm_001 - - push bx - call handle_data - pop bx - - cmp bl, 13 - jne tm_002 - - mov bl, 10 - call handle_data - -tm_002: - call draw_text - -tm_001: - popa - ret - - - -disconnect: - mov eax,53 - mov ebx,8 - mov ecx,[socket] - mcall - ret - - - -connect: - pusha - - mov ecx, 1000 ; local port starting at 1000 - -getlp: - inc ecx - push ecx - mov eax, 53 - mov ebx, 9 - mcall - pop ecx - cmp eax, 0 ; is this local port in use? - jz getlp ; yes - so try next - - mov eax,53 - mov ebx,5 - mov dl, [ip_address + 3] - shl edx, 8 - mov dl, [ip_address + 2] - shl edx, 8 - mov dl, [ip_address + 1] - shl edx, 8 - mov dl, [ip_address] - mov esi, edx - movzx edx, word [port] ; telnet port id - mov edi,1 ; active open - mcall - mov [socket], eax - - popa - - ret - - - -; ********************************************* -; ******* WINDOW DEFINITIONS AND DRAW ******** -; ********************************************* - - -draw_window: - - pusha - - mov eax,12 - mov ebx,1 - mcall - - xor eax,eax ; DRAW WINDOW - mov ebx,100*65536+491 + 8 +15 - mov ecx,100*65536+270 + 20 ; 20 for status bar - mov edx,0x14000000 - mov edi,title - mcall - - ; draw status bar - mov eax, 13 - mov ebx, 4*65536+484 + 8 +15 - mov ecx, 270*65536 + 3 - mov edx, 0x00557799 - mcall - - mov eax,8 ; BUTTON 2: SET IP - mov ebx,4*65536+70 - mov ecx,273*65536+12 - mov esi, 0x00557799 - mov edx,2 - mcall - - mov eax,4 ; Button text - mov ebx,6*65536+276 - mov ecx,0x00ffffff - mov edx,setipt - mov esi,setiplen-setipt - mcall - - - mov eax,47 - mov edi,ip_address ; display IP address - mov edx,78*65536+276 - mov esi,0x00ffffff - mov ebx,3*65536 - ipdisplay: - movzx ecx,byte [edi] - mcall - add edx,6*4*65536 - inc edi - cmp edi,ip_address+4 - jb ipdisplay - - mov eax,8 ; BUTTON 3: SET PORT - mov ebx,173*65536+38 - mov ecx,273*65536+12 - mov edx,3 - mov esi, 0x00557799 - mcall - - mov eax,4 ; Button text - mov ebx,178*65536+276 - mov ecx,0x00ffffff - mov edx,setportt - mov esi,setportlen-setportt - mcall - - - mov edx,216*65536+276 ; display port - mov esi,0x00ffffff - mov ebx,4*65536 - mov eax,47 - movzx ecx,word [port] - mcall - - mov eax,8 ; BUTTON 4: Connect - mov ebx,250*65536+50 - mov ecx,273*65536+12 - mov esi, 0x00557799 - mov edx,4 - mcall - - mov eax,4 ; Button text - mov ebx,255*65536+276 - mov ecx,0x00ffffff - mov edx,cont - mov esi,conlen-cont - mcall - - - mov eax,8 ; BUTTON 5: disconnect - mov ebx,303*65536+70 - mov ecx,273*65536+12 - mov edx,5 - mov esi, 0x00557799 - mcall - - - mov eax,4 ; Button text - mov ebx,307*65536+276 - mov ecx,0x00ffffff - mov edx,dist - mov esi,dislen-dist - mcall - - - mov esi,contlen-contt ; display connected status - mov edx, contt - mov eax, [socket_status] - cmp eax, 4 ; 4 is connected - je pcon - mov esi,discontlen-discontt - mov edx, discontt -pcon: - - mov eax,4 ; status text - mov ebx,380*65536+276 - mov ecx,0x00ffffff - mcall - - - mov eax,8 ; BUTTON 6: echo - mov ebx,460*65536+50 - mov ecx,273*65536+12 - mov edx,6 - mov esi, 0x00557799 - mcall - - mov edx,echot - mov esi,echolen-echot - mov al, [echo] - cmp al, 0 - jne peo - mov edx,echoot - mov esi,echoolen-echoot - -peo: - mov eax,4 ; Button text - mov ebx,463*65536+276 - mov ecx,0x00ffffff - mcall - - - xor eax,eax - mov edi,text+80*30 - mov ecx,80*30 /4 - cld - rep stosd - - call draw_text - - mov eax,12 - mov ebx,2 - mcall - - popa - - ret - - -draw_text: - - pusha - - mov esi,text - mov eax,0 - mov ebx,0 - newletter: - mov cl,[esi] - cmp cl,[esi+30*80] - jne yesletter - jmp noletter - yesletter: - mov [esi+30*80],cl - - ; erase character - - pusha - mov edx, 0 ; bg colour - mov ecx, ebx - add ecx, 26 - shl ecx, 16 - mov cx, 9 - mov ebx, eax - add ebx, 6 - shl ebx, 16 - mov bx, 6 - mov eax, 13 - mcall - popa - - ; draw character - - pusha - mov ecx, 0x00ffffff - push bx - mov ebx,eax - add ebx,6 - shl ebx,16 - pop bx - add bx,26 - mov eax,4 - mov edx,esi - mov esi,1 - mcall - popa - - noletter: - - add esi,1 - add eax,6 - cmp eax,80*6 - jb newletter - mov eax,0 - add ebx,10 - cmp ebx,24*10 - jb newletter - - popa - ret - - -read_string: - - mov edi,string - mov eax,'_' - mov ecx,[string_length] - inc ecx - cld - rep stosb - call print_text - - mov edi,string - f11: - mov eax,10 - mcall - cmp eax,2 - jne read_done - mov eax,2 - mcall - shr eax,8 - cmp eax,13 - je read_done - cmp eax,8 - jnz nobsl - cmp edi,string - jz f11 - sub edi,1 - mov [edi],byte '_' - call print_text - jmp f11 - nobsl: - cmp eax,dword 31 - jbe f11 - cmp eax,dword 95 - jb keyok - sub eax,32 - keyok: - mov [edi],al - call print_text - - inc edi - mov esi,string - add esi,[string_length] - cmp esi,edi - jnz f11 - - read_done: - - call print_text - - ret - - -print_text: - - pusha - - mov eax,13 - mov ebx,[string_x] - shl ebx,16 - add ebx,[string_length] - imul bx,6 - mov ecx,[string_y] - shl ecx,16 - mov cx,8 - mov edx,0x00000000 - mcall - - mov eax,4 - mov ebx,[string_x] - shl ebx,16 - add ebx,[string_y] - mov ecx,0x00ffffff - mov edx,string - mov esi,[string_length] - mcall - - popa - ret - - - - -; DATA AREA - -telnetrep db 0xff,0xfc,0x00 -telnetstate db 0 - -string_length dd 16 -string_x dd 200 -string_y dd 60 - -string db '________________' - -tx_buff db 0, 10 -ip_address db 001,002,003,004 -port db 0,0 -echo db 0 -socket dd 0x0 -socket_status dd 0x0 -pos dd 80 * 1 -scroll dd 1 - dd 24 -wcolor dd 0x000000 -title db 'Telnet v0.1',0 -setipt db 'IP Address: . . .' -setiplen: -setportt db 'Port:' -setportlen: -cont db 'Connect' -conlen: -dist db 'Disconnect' -dislen: -contt db 'Connected' -contlen: -discontt db 'Disconnected' -discontlen: -echot db 'Echo On' -echolen: -echoot db 'Echo Off' -echoolen: - - - -text: -I_END: diff --git a/programs/network_old/terminal/trunk/build_en.bat b/programs/network_old/terminal/trunk/build_en.bat deleted file mode 100644 index 9a0b418c56..0000000000 --- a/programs/network_old/terminal/trunk/build_en.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix en >lang.inc -@fasm terminal.asm terminal -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/terminal/trunk/build_ru.bat b/programs/network_old/terminal/trunk/build_ru.bat deleted file mode 100644 index 25c9c8f0a4..0000000000 --- a/programs/network_old/terminal/trunk/build_ru.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix ru >lang.inc -@fasm terminal.asm terminal -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/terminal/trunk/terminal.asm b/programs/network_old/terminal/trunk/terminal.asm deleted file mode 100644 index dc0c6d3cad..0000000000 --- a/programs/network_old/terminal/trunk/terminal.asm +++ /dev/null @@ -1,727 +0,0 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; -; TERMINAL - -use32 - org 0x0 - db 'MENUET01' ; header - dd 0x01 ; header version - dd START ; entry point - dd I_END ; image size - dd I_END+0x10000 ; required memory - dd I_END+0x10000 ; esp - dd 0x0 , 0x0 ; I_Param , I_Path - -include 'lang.inc' -include '..\..\..\macros.inc' - - -START: ; start of execution - - call draw_window - - call set_variables - -still: - - mov eax,23 ; wait here for event - mov ebx,20 - mcall - - 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,16+4 - je read_input - - jmp still - - -read_input: - mcall 42,4,text+120*80 - test eax, eax - jle still - -read_input_loop: - mov bl,[ecx] - inc ecx - push eax ecx - cmp bl,27 ; ESCAPE COMMAND - jne no_esc - call esc_command - jmp newdata - no_esc: - - cmp bl,13 ; BEGINNING OF LINE - jne nobol - mov ecx,[pos] - add ecx,1 - boll1: - sub ecx,1 - mov eax,ecx - xor edx,edx - mov ebx,80 - div ebx - cmp edx,0 - jne boll1 - mov [pos],ecx - jmp newdata - nobol: - - cmp bl,10 ; LINE DOWN - jne nolf - addx1: - add [pos],dword 1 - mov eax,[pos] - xor edx,edx - mov ecx,80 - div ecx - cmp edx,0 - jnz addx1 - mov eax,[pos] - jmp cm1 - nolf: - - cmp bl,8 ; BACKSPACE - jne nobasp - mov eax,[pos] - dec eax - mov [pos],eax - mov [eax+text],byte 32 - mov [eax+text+60*80],byte 0 - jmp newdata - nobasp: - - cmp bl,15 ; CHARACTER - jbe newdata - mov eax,[pos] - call draw_data - mov eax,[pos] - add eax,1 - cm1: - mov ebx,[scroll+4] - imul ebx,80 - cmp eax,ebx - jb noeaxz - mov esi,text+80 - mov edi,text - mov ecx,ebx - cld - rep movsb - mov esi,text+80+60*80 - mov edi,text+60*80 - mov ecx,ebx - cld - rep movsb - mov eax,ebx - sub eax,80 - noeaxz: - mov [pos],eax - newdata: - pop ecx eax - dec eax - jnz read_input_loop - call draw_text - jmp still - - - red: ; REDRAW WINDOW - call draw_window - jmp still - - key: ; KEY - mov eax,2 ; send to modem - mcall - shr eax,8 - cmp eax,178 ; ARROW KEYS - jne noaup - mov al,'A' - call arrow - jmp still - noaup: - cmp eax,177 - jne noadown - mov al,'B' - call arrow - jmp still - noadown: - cmp eax,179 - jne noaright - mov al,'C' - call arrow - jmp still - noaright: - cmp eax,176 - jne noaleft - mov al,'D' - call arrow - jmp still - noaleft: - modem_out: - mov dx,0x3f8 - out dx,al - jmp still - - button: ; BUTTON - mov eax,17 - mcall - cmp ah,1 ; CLOSE PROGRAM - jne noclose - mov eax,45 ; FREE IRQ - mov ebx,1 - mov ecx,4 - mcall - mov eax,46 - mov ebx,1 - mov ecx,0x3f0 - mov edx,0x3ff - mcall - or eax,-1 - mcall - noclose: - - jmp still - - -arrow: - - push eax - mov al,27 - call to_modem - mov al,'[' - call to_modem - pop eax - call to_modem - - ret - - -to_modem: - - pusha - - mov dx,0x3f8 - out dx,al - mov eax,5 - mov ebx,5 - mcall - - popa - ret - - -draw_data: - - pusha - - cmp bl,0xe4 ; ┴ - jne noe4 - mov bl,0xc1 - noe4: - cmp bl,0xc4 ; ╔ - jne noc4 - mov bl,0xc9 - noc4: - mov [eax+text],bl - mov bl,byte [attribute] - mov [eax+text+60*80],bl - - popa - ret - - -irqtable: - - dd 0x3f8 + 0x01000000 ; read port 0x3f8, byte - dd 0 - dd 0 - dd 0 - dd 0 - dd 0 - dd 0 - dd 0 - dd 0 - dd 0 - dd 0 - dd 0 - dd 0 - dd 0 - dd 0 - dd 0 - - - - -set_variables: - - pusha - - mov eax,46 - mov ebx,0 - mov ecx,0x3f0 - mov edx,0x3ff - mcall - - mov eax,45 ; reserve irq 4 - mov ebx,0 - mov ecx,4 - mcall - - mov eax,44 - mov ebx,irqtable - mov ecx,4 - mcall - -; jmp noportint - - mov dx,0x3f8+3 - mov al,0x80 - out dx,al - - mov dx,0x3f8+1 - mov al,0 - out dx,al - - mov dx,0x3f8+0 - mov al,0x30 / 16 - out dx,al - - mov dx,0x3f8+3 - mov al,3 - out dx,al - - mov dx,0x3f8+4 - mov al,0xB - out dx,al - - mov dx,0x3f8+1 - mov al,1 - out dx,al - - noportint: - - mov eax,40 - mov ebx,0000000000010000b shl 16 + 111b - mcall - - popa - - ret - - - -; ********************************************* -; ******* WINDOW DEFINITIONS AND DRAW ******** -; ********************************************* - - -draw_window: - - pusha - - mov eax,12 - mov ebx,1 - mcall - - mov eax,0 ; DRAW WINDOW - mov ebx,100*65536+491 - mov ecx,100*65536+270 - mov edx,0x13000000 - mov edi,title - mcall - - xor eax,eax - mov edi,text+80*30 - mov ecx,80*30 /4 - cld - rep stosd - - call draw_text - - mov eax,12 - mov ebx,2 - mcall - - popa - - ret - - -bgc dd 0x000000 - dd 0x000000 - dd 0x00ff00 - dd 0x0000ff - dd 0x005500 - dd 0xff00ff - dd 0x00ffff - dd 0x770077 - -tc dd 0xffffff - dd 0xff00ff - dd 0xffffff - dd 0xffffff - dd 0xffffff - dd 0xffffff - dd 0xffffff - dd 0xffffff - - -draw_text: - - pusha - - mov esi,text - mov eax,0 - mov ebx,0 - newletter: - mov cl,[esi] - mov dl,[esi+60*80] - cmp cl,[esi+30*80] - jne yesletter - cmp dl,[esi+90*80] - jne yesletter - jmp noletter - yesletter: - mov [esi+30*80],cl - mov [esi+90*80],dl - - pusha - and edx,0xff - shl edx,2 - add edx,bgc - mov edx,[edx] - mov ecx,ebx - add ecx,26 - shl ecx,16 - mov cx,9 - mov ebx,eax - add ebx,6 - shl ebx,16 - mov bx,6 - mov eax,13 - mcall - popa - - pusha - and edx,0xff - shl edx,2 - add edx,tc - mov ecx,[edx] - push bx - mov ebx,eax - add ebx,6 - shl ebx,16 - pop bx - add bx,26 - mov eax,4 - mov edx,esi - mov esi,1 - mcall - popa - - noletter: - - add esi,1 - add eax,6 - cmp eax,80*6 - jb newletter - mov eax,0 - add ebx,10 - cmp ebx,24*10 - jb newletter - - popa - ret - - -esc_command: - - mov eax,32 - mov edi,esccmd - mov ecx,10 - cld - rep stosb - mov edi,esccmd - newescc: - mov eax,42 - mov ebx,4 - mcall - cmp ecx,0 - je escok - mov eax,5 - mov ebx,1 - mcall - jmp newescc - escok: - mov [edi],bl - add edi,1 - cmp edi,esccmd+20 - je dontunderstand - mov esi,escend - nec: - cmp bl,[esi] - jz com_ok - add esi,1 - cmp [esi],byte 0 - je newescc - jmp nec - com_ok: - - call get_numbers - - cmp bl,'H' ; SET CURSOR POSITION - jne no_cursor_position - cmp [escnumbers],0 - jne ncp1 - mov [pos],dword 0 - jmp cmd_done - ncp1: - mov eax,[escnumbers] - dec eax - imul eax,80 - add eax,[escnumbers+4] - dec eax - mov [pos],eax - jmp cmd_done - no_cursor_position: - - cmp bl,'K' ; ERASE LINE - jne no_erase_end_of_line - cmp [escnumbers],0 - jne no_end_line - mov ecx,[pos] - eeol: - mov [ecx+text],byte ' ' - mov [ecx+text+60*80],byte 0 - add ecx,1 - xor edx,edx - mov eax,ecx - mov ebx,80 - div ebx - cmp edx,0 - jne eeol - jmp cmd_done - no_end_line: - cmp [escnumbers],1 ; BEGINNING OF LINE - jne no_beg_line - mov ecx,[pos] - ebol: - mov [ecx+text],byte ' ' - mov [ecx+text+60*80],byte 0 - sub ecx,1 - xor edx,edx - mov eax,ecx - mov ebx,80 - div ebx - cmp edx,0 - jne ebol - mov [pos],ecx - jmp cmd_done - no_beg_line: - no_erase_end_of_line: - - cmp bl,'J' ; ERASE TO END OF SCREEN - jne no_erase_to_end_of_screen - cmp [escnumbers],dword 0 - jne no_erase_to_end_of_screen - mov ecx,[pos] - eteos: - mov [ecx+text],byte ' ' - mov [ecx+text+60*80],byte 0 - add ecx,1 - cmp ecx,80*24+1 - jb eteos - jmp cmd_done - no_erase_to_end_of_screen: - - cmp bl,'r' ; SET SCROLL REGION - jne no_scroll_region - mov eax,[escnumbers] - dec eax - mov [scroll+0],eax - mov eax,[escnumbers+4] - mov [scroll+4],eax - jmp cmd_done - no_scroll_region: - - cmp bl,'A' ; CURSOR UP - jne no_cursor_up - mov eax,[pos] - sub eax,80 - mov [pos],eax - jmp cmd_done - no_cursor_up: - - cmp bl,'C' ; CURSOR LEFT - jne no_cursor_left - mov eax,[pos] - mov ebx,[escnumbers] - sub eax,ebx - mov [pos],eax - call cmd_done - no_cursor_left: - - cmp bl,'m' ; CHARACTER ATTRIBUTE - jne no_char_attribute - mov eax,[escnumbers] - mov [attribute],eax - jmp cmd_done - no_char_attribute: - - cmp bl,'Z' ; TERMINAL TYPE - jne no_terminal_type - mov al,27 - call to_modem - mov al,'?' - call to_modem - mov al,'1' - call to_modem - mov al,';' - call to_modem - mov al,'0' - call to_modem - mov al,'c' - call to_modem - jmp cmd_done - no_terminal_type: - - dontunderstand: - - cmd_done: - - ret - - -draw_numbers: - - pusha - - mov eax,13 - mov ebx,250*65536+100 - mov ecx,8*65536+8 - mov edx,0x000000 - mcall - - mov eax,[escnumbers] - xor edx,edx - mov ebx,10 - div ebx - add eax,48 - add edx,48 - mov byte [numtext+0],al - mov byte [numtext+1],dl - - mov eax,[escnumbers+4] - xor edx,edx - mov ebx,10 - div ebx - add eax,48 - add edx,48 - mov [numtext+3],al - mov [numtext+4],dl - - mov eax,4 - mov ebx,250*65536+8 - mov ecx,0xffffff - mov edx,numtext - mov esi,10 - mcall - - popa - - ret - -draw_event: - - pusha - - mov eax,13 - mov ebx,150*65536+100 - mov ecx,8*65536+8 - mov edx,0xffffff - mcall - - mov eax,4 - mov ebx,150*65536+8 - mov ecx,0x000000 - mov edx,esccmd - mov esi,20 - mcall - - popa - ret - - -get_numbers: - - pusha - - mov [escnumbers+0],0 - mov [escnumbers+4],0 - mov [escnumbers+8],0 - mov ecx,esccmd - cmp [ecx+1],byte '0' - jb gn_over - cmp [ecx+1],byte '9' - jg gn_over - mov edi,escnumbers - gn_new: - add ecx,1 - movzx eax,byte [ecx] - sub eax,48 - add ecx,1 - cmp [ecx],byte '0' - jb gnl1 - cmp [ecx],byte '9' - jg gnl1 - mov ebx,10 - xor edx,edx - mul ebx - movzx ebx,byte[ecx] - add eax,ebx - sub eax,48 - add ecx,1 - gnl1: - mov [edi],eax - add edi,4 - cmp [ecx],byte ';' - je gn_new - gn_over: - popa - ret - - - - -; DATA AREA - - -pos dd 80*10 -irc_data dd 0x0 -print db 0x0 -attribute dd 0 -scroll dd 1 - dd 24 -numtext db ' ' -esccmd dd 0,0,0,0,0,0,0,0,0,0,0,0,0 -escend db 'ZrhlABCDHfDME=>NmKJgincoyq',0 -escnumbers dd 0,0,0,0,0 -wcolor dd 0x000000 -title db 'TERMINAL FOR MODEM IN COM1 0.03',0 - -text: -db ' ' -db ' ' -db '*** A TELNET APPLICATION FOR HAYES COMPATIBLE MODEMS IN COM1 ' -db ' ' -db '*** USE HAYES COMMANDS TO CONNECT TO A SERVER ' -db ' ' -db '*** ATDT (PHONENUMBER) ' -db ' ' -db ' ' -db ' ' - -I_END: diff --git a/programs/network_old/tftpc/trunk/build_en.bat b/programs/network_old/tftpc/trunk/build_en.bat deleted file mode 100644 index 24fdff3027..0000000000 --- a/programs/network_old/tftpc/trunk/build_en.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix en >lang.inc -@fasm tftpc.asm tftpc -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/tftpc/trunk/build_ru.bat b/programs/network_old/tftpc/trunk/build_ru.bat deleted file mode 100644 index 21b403ff00..0000000000 --- a/programs/network_old/tftpc/trunk/build_ru.bat +++ /dev/null @@ -1,5 +0,0 @@ -@erase lang.inc -@echo lang fix ru >lang.inc -@fasm tftpc.asm tftpc -@erase lang.inc -@pause \ No newline at end of file diff --git a/programs/network_old/tftpc/trunk/tftpc.asm b/programs/network_old/tftpc/trunk/tftpc.asm deleted file mode 100644 index 4bf145c420..0000000000 --- a/programs/network_old/tftpc/trunk/tftpc.asm +++ /dev/null @@ -1,977 +0,0 @@ -; -; TFTP Client - -use32 - org 0x0 - db 'MENUET01' ; header - dd 0x01 ; header version - dd START ; entry point - dd I_END ; image size - dd I_END+0x10000 ; required memory - dd I_END+0x10000 ; esp - dd 0x0 , 0x0 ; I_Param , I_Path - -include 'lang.inc' -include '..\..\..\macros.inc' - -START: ; start of execution - mov eax,40 ; Report events - mov ebx,10000111b ; Stack 8 + defaults - mcall - - mov dword [prompt], p1 - mov dword [promptlen], p1len - p1 - -red: - call draw_window ; at first, draw the window - -still: - mov eax,10 ; wait here for event - mcall - - cmp eax,1 ; redraw request ? - jz red - cmp eax,2 ; key in buffer ? - jz key - cmp eax,3 ; button in buffer ? - jz button - - jmp still - -key: ; Keys are not valid at this part of the - mov eax,2 ; loop. Just read it and ignore - mcall - jmp still - -button: ; button - mov eax,17 ; get id - mcall - - cmp ah,1 ; button id=1 ? - jnz noclose - - - ; close socket before exiting - mov eax, 53 - mov ebx, 1 - mov ecx, [socketNum] - int 0x40 - - mov [socketNum], dword 0 - - - or eax,-1 ; close this program - mcall - -noclose: - cmp ah,2 ; copy file to local machine? - jnz nocopyl - - mov dword [prompt], p5 - mov dword [promptlen], p5len - p5 - call draw_window ; - - ; Copy File from Remote Host to this machine - call translateData ; Convert Filename & IP address - mov edi, tftp_filename + 1 - mov [edi], byte 0x01 ; setup tftp msg - call copyFromRemote - - jmp still - -nocopyl: - - cmp ah,3 ; Copy file to host? - jnz nocopyh - - mov dword [prompt], p5 - mov dword [promptlen], p5len - p5 - call draw_window ; - - ; Copy File from this machine to Remote Host - call translateData ; Convert Filename & IP address - mov edi, tftp_filename + 1 - mov [edi], byte 0x02 ; setup tftp msg - call copyToRemote - - jmp still - -nocopyh: - cmp ah,4 - jz f1 - cmp ah,5 - jz f2 - jmp nof12 - - f1: - mov [addr],dword source - mov [ya],dword 35 - jmp rk - - f2: - mov [addr],dword destination - mov [ya],dword 35+16 - - rk: - mov ecx,15 - mov edi,[addr] - mov al,' ' - rep stosb - - call print_text - - mov edi,[addr] - - f11: - mov eax,10 - mcall - cmp eax,2 - jz fbu - jmp still - fbu: - mov eax,2 - mcall ; get key - shr eax,8 - cmp eax,8 - jnz nobs - cmp edi,[addr] - jz f11 - sub edi,1 - mov [edi],byte ' ' - call print_text - jmp f11 - nobs: - cmp eax,dword 31 - jbe f11 - cmp eax,dword 95 - jb keyok - sub eax,32 - keyok: - mov [edi],al - - call print_text - - add edi,1 - mov esi,[addr] - add esi,15 - cmp esi,edi - jnz f11 - - jmp still - -print_text: - - mov eax,13 - mov ebx,103*65536+15*6 - mov ecx,[ya] - shl ecx,16 - mov cx,8 - mov edx,0x224466 - mcall - - mov eax,4 - mov ebx,103*65536 - add ebx,[ya] - mov ecx,0xffffff - mov edx,[addr] - mov esi,15 - mcall - - ret - - - nof12: - jmp still - - -;*************************************************************************** -; Function -; translateData -; -; Description -; Coverts the filename and IP address typed in by the user into -; a format suitable for the IP layer. -; -; The filename, in source, is converted and stored in tftp_filename -; The host ip, in destination, is converted and stored in tftp_IP -; -;*************************************************************************** -translateData: - - ; first, build up the tftp command string. This includes the filename - ; and the transfer protocol - - - ; First, write 0,0 - mov al, 0 - mov edi, tftp_filename - mov [edi], al - inc edi - mov [edi], al - inc edi - - ; Now, write the file name itself, and null terminate it - mov ecx, 15 - mov ah, ' ' - mov esi, source - -td001: - lodsb - stosb - cmp al, ah - loopnz td001 - - cmp al,ah ; Was the entire buffer full of characters? - jne td002 - dec edi ; No - so remove ' ' character - -td002: - mov [edi], byte 0 - inc edi - mov [edi], byte 'O' - inc edi - mov [edi], byte 'C' - inc edi - mov [edi], byte 'T' - inc edi - mov [edi], byte 'E' - inc edi - mov [edi], byte 'T' - inc edi - mov [edi], byte 0 - - mov esi, tftp_filename - sub edi, esi - mov [tftp_len], edi - - - ; Now, convert the typed IP address into a real address - ; No validation is done on the number entered - ; ip addresses must be typed in normally, eg - ; 192.1.45.24 - - xor eax, eax - mov dh, 10 - mov dl, al - mov [tftp_IP], eax - - ; 192.168.24.1 1.1.1.1 1. 9.2.3. - - mov esi, destination - mov edi, tftp_IP - - mov ecx, 4 - -td003: - lodsb - sub al, '0' - add dl, al - lodsb - cmp al, '.' - je ipNext - cmp al, ' ' - je ipNext - mov dh, al - sub dh, '0' - mov al, 10 - mul dl - add al, dh - mov dl, al - lodsb - cmp al, '.' - je ipNext - cmp al, ' ' - je ipNext - mov dh, al - sub dh, '0' - mov al, 10 - mul dl - add al, dh - mov dl, al - lodsb - -ipNext: - mov [edi], dl - inc edi - mov dl, 0 - loop td003 - - ret - - - -;*************************************************************************** -; Function -; copyFromRemote -; -; Description -; -;*************************************************************************** -copyFromRemote: - xor eax, eax - mov [filesize], eax - mov eax, I_END + 512 ; This is the point where the file buffer is - mov [fileposition], eax - - ; Get a random # for the local socket port # - mov eax, 3 - int 0x40 - mov ecx, eax - shr ecx, 8 ; Set up the local port # with a random # - - ; open socket - mov eax, 53 - mov ebx, 0 - mov edx, 69 ; remote port - mov esi, [tftp_IP] ; remote IP ( in intenet format ) - int 0x40 - - mov [socketNum], eax - - ; make sure there is no data in the socket - there shouldn't be.. - -cfr001: - mov eax, 53 - mov ebx, 3 - mov ecx, [socketNum] - int 0x40 ; read byte - - mov eax, 53 - mov ebx, 2 - mov ecx, [socketNum] - int 0x40 ; any more data? - - cmp eax, 0 - jne cfr001 ; yes, so get it - - ; Now, request the file - mov eax, 53 - mov ebx, 4 - mov ecx, [socketNum] - mov edx, [tftp_len] - mov esi, tftp_filename - int 0x40 - -cfr002: - mov eax,10 ; wait here for event - mcall - - cmp eax,1 ; redraw request ? - je cfr003 - cmp eax,2 ; key in buffer ? - je cfr004 - cmp eax,3 ; button in buffer ? - je cfr005 - - ; Any data to fetch? - mov eax, 53 - mov ebx, 2 - mov ecx, [socketNum] - int 0x40 - - cmp eax, 0 - je cfr002 - - push eax ; eax holds # chars - - ; Update the text on the display - once - mov eax, [prompt] - cmp eax, p3 - je cfr008 - mov dword [prompt], p3 - mov dword [promptlen], p3len - p3 - call draw_window ; - -cfr008: - ; we have data - this will be a tftp frame - - ; read first two bytes - opcode - mov eax, 53 - mov ebx, 3 - mov ecx, [socketNum] - int 0x40 ; read byte - - mov eax, 53 - mov ebx, 3 - mov ecx, [socketNum] - int 0x40 ; read byte - - pop eax - ; bl holds tftp opcode. Can only be 3 (data) or 5 ( error ) - - cmp bl, 3 - jne cfrerr - - push eax - - ; do data stuff. Read block #. Read data. Send Ack. - mov eax, 53 - mov ebx, 3 - mov ecx, [socketNum] - int 0x40 ; read byte - - mov [blockNumber], bl - - mov eax, 53 - mov ebx, 3 - mov ecx, [socketNum] - int 0x40 ; read byte - - mov [blockNumber+1], bl - -cfr007: - - mov eax, 53 - mov ebx, 2 - mov ecx, [socketNum] - mcall ; any more data? - - cmp eax, 0 - je no_more_data ; no - - mov eax, 53 - mov ebx, 3 - mov ecx, [socketNum] - mcall ; read byte - - mov esi, [fileposition] - mov [esi], bl - inc dword [fileposition] - inc dword [filesize] - - jmp cfr007 - -no_more_data: - - ; write the block number into the ack - mov al, [blockNumber] - mov [ack + 2], al - - mov al, [blockNumber+1] - mov [ack + 3], al - - ; send an 'ack' - mov eax, 53 - mov ebx, 4 - mov ecx, [socketNum] - mov edx, ackLen - ack - mov esi, ack - int 0x40 - - ; If # of chars in the frame is less that 516, - ; this frame is the last - pop eax - cmp eax, 516 - je cfr002 - - ; Write the file - mov ebx, writeinfo - lea esi, [ebx + 20] -@@: - lodsb - test al, al - jnz @b -@@: - dec esi - cmp byte [esi-1], ' ' - jnz @b - mov byte [esi], 0 - mcall 70, writeinfo - mov byte [esi], ' ' - - jmp cfrexit - -cfrerr: - ; simple implementation on error - just read all data, and return - mov eax, 53 - mov ebx, 3 - mov ecx, [socketNum] - int 0x40 ; read byte - - mov eax, 53 - mov ebx, 2 - mov ecx, [socketNum] - int 0x40 ; any more data? - - cmp eax, 0 - jne cfrerr ; yes, so get it - - jmp cfr006 ; close socket and close app - -cfr003: ; redraw request - call draw_window - jmp cfr002 - -cfr004: ; key pressed - mov eax,2 ; just read it and ignore - mcall - jmp cfr002 - -cfr005: ; button - mov eax,17 ; get id - mcall - - cmp ah,1 ; button id=1 ? - jne cfr002 ; If not, ignore. - -cfr006: - ; close socket - mov eax, 53 - mov ebx, 1 - mov ecx, [socketNum] - int 0x40 - - mov [socketNum], dword 0 - - mov eax,-1 ; close this program - mcall - - jmp $ - -cfrexit: - ; close socket - mov eax, 53 - mov ebx, 1 - mov ecx, [socketNum] - int 0x40 - - mov [socketNum], dword 0 - - mov dword [prompt], p4 - mov dword [promptlen], p4len - p4 - call draw_window ; - - ret - - - -;*************************************************************************** -; Function -; copyToRemote -; -; Description -; -;*************************************************************************** -copyToRemote: - mov eax,6 ; Read file from floppy (image) - mov ebx,source - mov ecx,0 - mov edx,0xffffffff - mov esi,I_END + 512 - int 0x40 - - cmp eax,0xffffffff - jnz filefound - - mov dword [prompt], p6 - mov dword [promptlen], p6len - p6 - call draw_window ; - jmp ctr_exit - -filefound: - mov [filesize], eax - - ; First, set up the file pointers - mov eax, 0x01000300 - mov [blockBuffer], eax ; This makes sure our TFTP header is valid - - mov eax, I_END + 512 ; This is the point where the file buffer is - mov [fileposition], eax - - mov eax, [filesize] - cmp eax, 512 - jb ctr000 - mov eax, 512 -ctr000: - mov [fileblocksize], ax - - ; Get a random # for the local socket port # - mov eax, 3 - int 0x40 - mov ecx, eax - shr ecx, 8 ; Set up the local port # with a random # - - ; First, open socket - mov eax, 53 - mov ebx, 0 - mov edx, 69 ; remote port - mov esi, [tftp_IP] - int 0x40 - - mov [socketNum], eax - - ; write to socket ( request write file ) - mov eax, 53 - mov ebx, 4 - mov ecx, [socketNum] - mov edx, [tftp_len] - mov esi, tftp_filename - int 0x40 - - ; now, we wait for - ; UI redraw - ; UI close - ; or data from remote - -ctr001: - mov eax,10 ; wait here for event - int 0x40 - - 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? - mov eax, 53 - mov ebx, 2 - mov ecx, [socketNum] - int 0x40 - - cmp eax, 0 - je ctr001 - - ; Update the text on the display - once - mov eax, [prompt] - cmp eax, p2 - je ctr002 - - mov dword [prompt], p2 - mov dword [promptlen], p2len - p2 - call draw_window ; - - ; we have data - this will be the ack -ctr002: - mov eax, 53 - mov ebx, 3 - mov ecx, [socketNum] - int 0x40 ; read byte - opcode - - mov eax, 53 - mov ebx, 3 - mov ecx, [socketNum] - int 0x40 ; read byte - opcode - - mov eax, 53 - mov ebx, 3 - mov ecx, [socketNum] - int 0x40 ; read byte - block (high byte) - - mov [blockNumber], bl - - mov eax, 53 - mov ebx, 3 - mov ecx, [socketNum] - int 0x40 ; read byte - block (low byte ) - - mov [blockNumber+1], bl - -ctr0022: - mov eax, 53 - mov ebx, 3 - mov ecx, [socketNum] - int 0x40 ; read byte (shouldn't have worked) - - - mov eax, 53 - mov ebx, 2 - mov ecx, [socketNum] - int 0x40 ; any more data? - - cmp eax, 0 - jne ctr0022 ; yes, so get it, and dump it - - ; If the ack is 0, it is to the request - - mov bx, [blockNumber] - cmp bx, 0 - je txd - - ; now, the ack should be one more than the current field - otherwise, resend - - cmp bx, [blockBuffer+2] - jne txre ; not the same, so send again - - ; update the block number - mov esi, blockBuffer + 3 - mov al, [esi] - inc al - mov [esi], al - cmp al, 0 - jne ctr008 - dec esi - inc byte [esi] - -ctr008: - ; Move forward through the file - mov eax, [fileposition] - movzx ebx, word [fileblocksize] - add eax, ebx - mov [fileposition], eax - - ; new .. - ; fs = 0 , fbs = 512 -> send with fbs = 0 - - cmp [filesize],0 - jne no_special_end - cmp [fileblocksize],512 - jne no_special_end - mov ax,0 - jmp ctr006 -no_special_end: - - mov eax, [filesize] - cmp eax, 0 - je ctr009 - cmp eax, 512 - jb ctr006 - mov eax, 512 -ctr006: - mov [fileblocksize], ax - - -txd: - ; Readjust the file size variable ( before sending ) - mov eax, [filesize] - movzx ebx, word [fileblocksize] - sub eax, ebx - mov [filesize], eax - -txre: - ; Copy the fragment of the file to the block buffer - movzx ecx, word [fileblocksize] - mov esi, [fileposition] - mov edi, I_END - cld - rep movsb - - ; send the file data - mov eax, 53 - mov ebx, 4 - mov ecx, [socketNum] - movzx edx, word [fileblocksize] - add edx, 4 - mov esi, blockBuffer - int 0x40 - - jmp ctr001 - -ctr003: ; redraw - call draw_window - jmp ctr001 - -ctr004: ; key - mov eax,2 ; just read it and ignore - int 0x40 - jmp ctr001 - -ctr005: ; button - mov eax,17 ; get id - int 0x40 - - cmp ah,1 ; button id=1 ? - jne ctr001 - - ; close socket - mov eax, 53 - mov ebx, 1 - mov ecx, [socketNum] - int 0x40 - - mov [socketNum], dword 0 - - mov eax,-1 ; close this program - int 0x40 - jmp $ - -ctr009: - ; close socket - mov eax, 53 - mov ebx, 1 - mov ecx, [socketNum] - int 0x40 - - mov dword [prompt], p4 - mov dword [promptlen], p4len - p4 - call draw_window ; - -ctr_exit: - ret - - - - -; ********************************************* -; ******* WINDOW DEFINITIONS AND DRAW ******** -; ********************************************* - - -draw_window: - - mov eax,12 ; function 12:tell os about windowdraw - mov ebx,1 ; 1, start of draw - mcall - - ; DRAW WINDOW - mov eax,0 ; function 0 : define and draw window - mov ebx,100*65536+230 ; [x start] *65536 + [x size] - mov ecx,100*65536+170 ; [y start] *65536 + [y size] - mov edx,0x14224466 ; color of work area RRGGBB - mov edi,title - mcall - - mov eax,8 ; COPY BUTTON - mov ebx,20*65536+190 - mov ecx,79*65536+15 - mov edx,2 - mov esi,0x557799 - mcall - - ; mov eax,8 ; DELETE BUTTON - mov ebx,20*65536+190 - mov ecx,111*65536+15 - mov edx,3 - mcall - - ; mov eax,8 - ; mov ebx,200*65536+10 - mov ecx,34*65536+10 - mov edx,4 - mcall - - ; mov eax,8 - ; mov ebx,200*65536+10 - mov ecx,50*65536+10 - mov edx,5 - mcall - - - ; Copy the file name to the screen buffer - ; file name is same length as IP address, to - ; make the math easier later. - cld - mov esi,source - mov edi,text+13 - mov ecx,15 - rep movsb - - - ; copy the IP address to the screen buffer - mov esi,destination - mov edi,text+40+13 - mov ecx,15 - rep movsb - - ; copy the prompt to the screen buffer - mov esi,[prompt] - mov edi,text+280 - mov ecx,[promptlen] - rep movsb - - ; Re-draw the screen text - cld - mov eax,4 - mov ebx,25*65536+35 ; draw info text with function 4 - mov ecx,0xffffff - mov edx,text - mov esi,40 - newline: - mcall - add ebx,16 - add edx,40 - cmp [edx],byte 'x' - jnz newline - - - mov eax,12 ; function 12:tell os about windowdraw - mov ebx,2 ; 2, end of draw - mcall - - ret - - -; DATA AREA -; file name: source -; file data: I_END + 512 -; file size: [filesize] -writeinfo: - dd 2 - dd 0 - dd 0 -filesize dd 0 ; The number of bytes written / left to write - dd I_END + 512 -source db 'KERNEL.ASM ',0 -destination db '192.168.1.23 ' - - -tftp_filename: times 15 + 9 db 0 -tftp_IP: dd 0 -tftp_len: dd 0 - -addr dd 0x0 -ya dd 0x0 - -fileposition dd 0 ; Points to the current point in the file -fileblocksize dw 0 ; The number of bytes to send in this frame - -text: - db 'SOURCE FILE: xxxxxxxxxxxxxxx ' - db 'HOST IP ADD: xxx.xxx.xxx.xxx ' - db ' ' - db ' COPY HOST -> LOCAL ' - db ' ' - db ' COPY LOCAL -> HOST ' - db ' ' - db ' ' - db 'x' ; <- END MARKER, DONT DELETE - - -title db 'TFTP Client',0 - -prompt: dd 0 -promptlen: dd 0 - - -p1: db 'Waiting for Command' -p1len: - -p2: db 'Sending File ' -p2len: - -p3: db 'Receiving File ' -p3len: - -p4: db 'Tranfer Complete ' -p4len: - -p5: db 'Contacting Host... ' -p5len: - -p6: db 'File not found. ' -p6len: - -ack: - db 00,04,0,1 -ackLen: - -socketNum: - dd 0 - -blockNumber: - dw 0 - -; This must be the last part of the file, because the blockBuffer -; continues at I_END. -blockBuffer: - db 00, 03, 00, 01 -I_END: - - - - - - - \ No newline at end of file