Rev 4655 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3618 | hidnplayr | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
6836 | hidnplayr | 3 | ;; Copyright (C) KolibriOS team 2010-2017. All rights reserved. ;; |
3618 | hidnplayr | 4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
||
6 | ;; tftpc.asm - TFTP client for KolibriOS ;; |
||
7 | ;; ;; |
||
8 | ;; Written by hidnplayr@kolibrios.org ;; |
||
9 | ;; ;; |
||
10 | ;; GNU GENERAL PUBLIC LICENSE ;; |
||
11 | ;; Version 2, June 1991 ;; |
||
12 | ;; ;; |
||
13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
14 | |||
3545 | hidnplayr | 15 | format binary as "" |
16 | |||
4655 | hidnplayr | 17 | __DEBUG__ = 0 |
18 | __DEBUG_LEVEL__ = 1 |
||
19 | |||
3545 | hidnplayr | 20 | use32 |
3618 | hidnplayr | 21 | org 0x0 |
3545 | hidnplayr | 22 | |
3618 | hidnplayr | 23 | db 'MENUET01' |
24 | dd 0x1 |
||
25 | dd START |
||
26 | dd I_END |
||
27 | dd IM_END+0x1000 |
||
28 | dd IM_END+0x1000 |
||
29 | dd 0, 0 |
||
3545 | hidnplayr | 30 | |
3618 | hidnplayr | 31 | include '../../proc32.inc' |
32 | include '../../macros.inc' |
||
6836 | hidnplayr | 33 | include '../../develop/libraries/libs-dev/libio/libio.inc' |
3618 | hidnplayr | 34 | include '../../dll.inc' |
3549 | yogev_ezra | 35 | include '../../develop/libraries/box_lib/trunk/box_lib.mac' |
3545 | hidnplayr | 36 | |
3618 | hidnplayr | 37 | include '../../network.inc' |
4655 | hidnplayr | 38 | include '../../debug-fdo.inc' |
3545 | hidnplayr | 39 | |
3618 | hidnplayr | 40 | TIMEOUT = 100 |
4655 | hidnplayr | 41 | buffer_len = 4096 |
3545 | hidnplayr | 42 | |
4655 | hidnplayr | 43 | opcode_rrq = 1 shl 8 |
44 | opcode_wrq = 2 shl 8 |
||
45 | opcode_data = 3 shl 8 |
||
46 | opcode_ack = 4 shl 8 |
||
47 | opcode_error = 5 shl 8 |
||
3545 | hidnplayr | 48 | |
49 | ; read/write request packet |
||
50 | ; |
||
51 | ; 2 bytes string 1 byte string 1 byte |
||
52 | ; ------------------------------------------------ |
||
53 | ; | Opcode | Filename | 0 | Mode | 0 | |
||
54 | ; ------------------------------------------------ |
||
55 | |||
56 | ; data packet |
||
57 | ; |
||
58 | ; 2 bytes 2 bytes n bytes |
||
59 | ; ---------------------------------- |
||
60 | ; | Opcode | Block # | Data | |
||
61 | ; ---------------------------------- |
||
62 | |||
63 | ; acknowledgement packet |
||
64 | ; |
||
65 | ; 2 bytes 2 bytes |
||
66 | ; --------------------- |
||
67 | ; | Opcode | Block # | |
||
68 | ; --------------------- |
||
69 | |||
70 | ; error packet |
||
71 | ; |
||
72 | ; 2 bytes 2 bytes string 1 byte |
||
73 | ; ---------------------------------------- |
||
74 | ; | Opcode | ErrorCode | ErrMsg | 0 | |
||
75 | ; ---------------------------------------- |
||
76 | |||
77 | |||
78 | START: |
||
79 | |||
80 | mcall 68, 11 |
||
81 | |||
82 | stdcall dll.Load, @IMPORT |
||
83 | or eax, eax |
||
84 | jnz exit |
||
85 | |||
4655 | hidnplayr | 86 | home: |
4468 | hidnplayr | 87 | mcall 40, EVM_MOUSE + EVM_MOUSE_FILTER + EVM_REDRAW + EVM_BUTTON + EVM_KEY + EVM_STACK |
3545 | hidnplayr | 88 | |
4655 | hidnplayr | 89 | redraw: |
4468 | hidnplayr | 90 | call draw_window |
3545 | hidnplayr | 91 | |
4655 | hidnplayr | 92 | mainloop: |
3545 | hidnplayr | 93 | mcall 10 |
94 | dec eax |
||
4655 | hidnplayr | 95 | jz redraw |
3545 | hidnplayr | 96 | dec eax |
97 | jz key |
||
98 | dec eax |
||
99 | jz button |
||
100 | |||
4468 | hidnplayr | 101 | invoke edit_box_mouse, edit1 |
102 | invoke edit_box_mouse, edit2 |
||
103 | invoke edit_box_mouse, edit3 |
||
104 | invoke edit_box_mouse, edit4 |
||
3545 | hidnplayr | 105 | |
4468 | hidnplayr | 106 | invoke option_box_mouse, Option_boxs1 |
107 | invoke option_box_mouse, Option_boxs2 |
||
3545 | hidnplayr | 108 | |
4655 | hidnplayr | 109 | jmp mainloop |
3545 | hidnplayr | 110 | |
111 | button: |
||
112 | mcall 17 |
||
113 | |||
4468 | hidnplayr | 114 | cmp ah, 0x10 ; connect button |
3545 | hidnplayr | 115 | je start_transfer |
116 | |||
117 | test ah , ah |
||
4655 | hidnplayr | 118 | jz mainloop |
3545 | hidnplayr | 119 | |
4468 | hidnplayr | 120 | exit: |
121 | mcall -1 |
||
3545 | hidnplayr | 122 | key: |
123 | mcall 2 |
||
124 | |||
4468 | hidnplayr | 125 | invoke edit_box_key, edit1 |
126 | invoke edit_box_key, edit2 |
||
127 | invoke edit_box_key, edit3 |
||
128 | invoke edit_box_key, edit4 |
||
3545 | hidnplayr | 129 | |
4655 | hidnplayr | 130 | jmp mainloop |
3545 | hidnplayr | 131 | |
132 | |||
133 | draw_window: |
||
4468 | hidnplayr | 134 | ; get system colors |
135 | mcall 48, 3, sc, 40 |
||
3545 | hidnplayr | 136 | |
4468 | hidnplayr | 137 | mcall 12, 1 |
3545 | hidnplayr | 138 | |
4468 | hidnplayr | 139 | mov edx, [sc.work] |
140 | or edx, 0x34000000 |
||
141 | xor esi, esi |
||
142 | mov edi, str_title |
||
143 | mcall 0, 50 shl 16 + 400, 30 shl 16 + 180 |
||
144 | |||
145 | mov ebx, 35 shl 16 + 10 |
||
146 | mov ecx, 0x80000000 |
||
147 | or ecx, [sc.work_text] |
||
148 | mov edx, str_server |
||
149 | mcall 4 |
||
150 | mov ebx, 5 shl 16 + 30 |
||
3545 | hidnplayr | 151 | mov edx, str_source |
152 | mcall |
||
4468 | hidnplayr | 153 | mov ebx, 11 shl 16 + 50 |
3545 | hidnplayr | 154 | mov edx, str_destination |
155 | mcall |
||
4468 | hidnplayr | 156 | mov ebx, 47 shl 16 + 72 |
3545 | hidnplayr | 157 | mov edx, str_mode |
158 | mcall |
||
4468 | hidnplayr | 159 | mov ebx, 160 shl 16 + 72 |
3545 | hidnplayr | 160 | mov edx, str_method |
161 | mcall |
||
4468 | hidnplayr | 162 | mov ebx, 270 shl 16 + 72 |
3545 | hidnplayr | 163 | mov edx, str_blocksize |
164 | mcall |
||
165 | |||
4468 | hidnplayr | 166 | invoke edit_box_draw, edit1 |
167 | invoke edit_box_draw, edit2 |
||
168 | invoke edit_box_draw, edit3 |
||
169 | invoke edit_box_draw, edit4 |
||
3545 | hidnplayr | 170 | |
4468 | hidnplayr | 171 | invoke option_box_draw, Option_boxs1 |
172 | invoke option_box_draw, Option_boxs2 |
||
3545 | hidnplayr | 173 | |
4468 | hidnplayr | 174 | mov esi, [sc.work_button] |
175 | mcall 8, 210 shl 16 + 170, 105 shl 16 + 16, 0x10 |
||
3545 | hidnplayr | 176 | |
4655 | hidnplayr | 177 | mcall 38, 10 shl 16 + 380, 130 shl 16 + 130, [sc.work_graph] |
178 | |||
179 | cmp [errormsg], 0 |
||
180 | je .no_error |
||
181 | |||
4468 | hidnplayr | 182 | mov ecx, 0x80000000 |
4655 | hidnplayr | 183 | or ecx, [sc.work_text] |
184 | mcall 4, 20 shl 16 + 137, , [errormsg] |
||
185 | mcall 12, 2 |
||
186 | jmp .draw_btn |
||
3545 | hidnplayr | 187 | |
4655 | hidnplayr | 188 | .no_error: |
4468 | hidnplayr | 189 | mov ecx, 0x80000000 |
190 | or ecx, [sc.work_text] |
||
191 | mcall 4, 350 shl 16 + 137, , str_kb_s |
||
192 | mcall 4, 50 shl 16 + 137, , str_complete |
||
4655 | hidnplayr | 193 | mcall 47, 1 shl 31 + 7 shl 16 + 1, kbps, 305 shl 16 + 137, [sc.work_text] |
194 | mcall 47, 1 shl 31 + 3 shl 16 + 1, done, 25 shl 16 + 137 |
||
3545 | hidnplayr | 195 | |
4655 | hidnplayr | 196 | .draw_btn: |
197 | cmp [socketnum], 0 |
||
198 | je .no_transfer |
||
3545 | hidnplayr | 199 | |
4655 | hidnplayr | 200 | mov ecx, 0x80000000 |
201 | or ecx, [sc.work_button_text] |
||
202 | mcall 4, 270 shl 16 + 110, , str_stop |
||
3545 | hidnplayr | 203 | |
4468 | hidnplayr | 204 | mcall 12, 2 |
3545 | hidnplayr | 205 | ret |
206 | |||
4655 | hidnplayr | 207 | .no_transfer: |
208 | mov ecx, 0x80000000 |
||
209 | or ecx, [sc.work_button_text] |
||
210 | mcall 4, 260 shl 16 + 110, , str_transfer |
||
3545 | hidnplayr | 211 | |
4655 | hidnplayr | 212 | mcall 12, 2 |
213 | ret |
||
3545 | hidnplayr | 214 | |
215 | |||
216 | |||
217 | start_transfer: |
||
218 | |||
4655 | hidnplayr | 219 | ; resolve the hostname |
220 | mov [errormsg], str_err_resolve |
||
3545 | hidnplayr | 221 | |
222 | push esp ; reserve stack place |
||
223 | |||
224 | push esp ; fourth parameter |
||
225 | push 0 ; third parameter |
||
226 | push 0 ; second parameter |
||
227 | push dword SRV ; first parameter |
||
228 | call [getaddrinfo] |
||
229 | |||
230 | pop esi |
||
231 | |||
4655 | hidnplayr | 232 | ; test for error |
3545 | hidnplayr | 233 | test eax, eax |
4655 | hidnplayr | 234 | jnz home |
3545 | hidnplayr | 235 | |
4655 | hidnplayr | 236 | mov eax, [esi + addrinfo.ai_addr] |
237 | mov eax, [eax + sockaddr_in.sin_addr] |
||
238 | mov [sockaddr.ip], eax |
||
3545 | hidnplayr | 239 | |
4655 | hidnplayr | 240 | ; free allocated memory |
241 | push esi |
||
242 | call [freeaddrinfo] |
||
243 | |||
244 | ; Open a socket & connect to server |
||
245 | mov [errormsg], str_err_socket |
||
246 | |||
247 | mcall socket, AF_INET4, SOCK_DGRAM, 0 |
||
3545 | hidnplayr | 248 | cmp eax, -1 |
4655 | hidnplayr | 249 | je home |
3545 | hidnplayr | 250 | mov [socketnum], eax |
251 | |||
4655 | hidnplayr | 252 | mcall connect, [socketnum], sockaddr, sockaddr_len |
3545 | hidnplayr | 253 | cmp eax, -1 |
4655 | hidnplayr | 254 | je home |
3545 | hidnplayr | 255 | |
4655 | hidnplayr | 256 | ; Create the read/write request packet |
257 | mov word[buffer], opcode_rrq |
||
258 | cmp [option_group2], op3 |
||
3545 | hidnplayr | 259 | je @f |
4655 | hidnplayr | 260 | mov word[buffer], opcode_wrq |
3545 | hidnplayr | 261 | @@: |
262 | |||
4655 | hidnplayr | 263 | ; Copy in the remote filename (asciiz) |
264 | xor al, al |
||
3545 | hidnplayr | 265 | mov edi, remote_addr |
4655 | hidnplayr | 266 | mov ecx, 255 |
3545 | hidnplayr | 267 | repnz scasb |
4655 | hidnplayr | 268 | lea ecx, [edi - remote_addr - 1] |
3545 | hidnplayr | 269 | mov esi, remote_addr |
4655 | hidnplayr | 270 | mov edi, buffer+2 |
3545 | hidnplayr | 271 | rep movsb |
4655 | hidnplayr | 272 | stosb |
3545 | hidnplayr | 273 | |
4655 | hidnplayr | 274 | ; Append the data type (asciiz) |
3545 | hidnplayr | 275 | cmp [option_group1], op1 |
276 | je .ascii |
||
277 | mov esi, octet |
||
278 | movsd |
||
279 | movsb |
||
280 | jmp .send_request |
||
281 | |||
282 | .ascii: |
||
283 | mov esi, netascii |
||
284 | movsd |
||
285 | movsd |
||
286 | |||
4655 | hidnplayr | 287 | ; Send the request to the server |
3545 | hidnplayr | 288 | .send_request: |
289 | xor al, al |
||
290 | stosb |
||
4655 | hidnplayr | 291 | lea esi, [edi - buffer] |
292 | xor edi, edi |
||
293 | mcall send, [socketnum], buffer |
||
294 | cmp eax, -1 |
||
295 | je home |
||
3545 | hidnplayr | 296 | |
4655 | hidnplayr | 297 | ; Jump to send/receive code |
298 | cmp word[buffer], opcode_wrq |
||
299 | je tftp_send |
||
3545 | hidnplayr | 300 | |
4655 | hidnplayr | 301 | |
302 | tftp_receive: |
||
303 | |||
4468 | hidnplayr | 304 | mcall 40, EVM_REDRAW + EVM_BUTTON + EVM_STACK |
3545 | hidnplayr | 305 | mov [last_ack], 0 |
4655 | hidnplayr | 306 | mov [errormsg], 0 |
3545 | hidnplayr | 307 | |
4655 | hidnplayr | 308 | call draw_window |
3545 | hidnplayr | 309 | |
4655 | hidnplayr | 310 | ; Open/create local file |
311 | mov [file_struct.subfn], 2 |
||
312 | mov [file_struct.offset], 0 |
||
313 | mov [file_struct.size], 0 |
||
314 | mcall 70, file_struct |
||
3545 | hidnplayr | 315 | |
4655 | hidnplayr | 316 | ; Truncate it to 0 bytes |
317 | mov [file_struct.subfn], 4 |
||
318 | mcall 70, file_struct |
||
3545 | hidnplayr | 319 | |
4655 | hidnplayr | 320 | ; Set parameters for writing to file |
321 | mov [file_struct.subfn], 3 |
||
322 | mov [file_struct.data], buffer + 4 |
||
3545 | hidnplayr | 323 | |
4655 | hidnplayr | 324 | .loop: |
3545 | hidnplayr | 325 | mcall 23, TIMEOUT |
326 | dec eax |
||
327 | jz .red |
||
328 | dec eax |
||
4655 | hidnplayr | 329 | dec eax |
330 | jz .button |
||
3545 | hidnplayr | 331 | |
3704 | hidnplayr | 332 | mcall recv, [socketnum], buffer, buffer_len, MSG_DONTWAIT ; receive data |
4655 | hidnplayr | 333 | cmp eax, -1 |
334 | je .loop |
||
3545 | hidnplayr | 335 | |
4655 | hidnplayr | 336 | DEBUGF 1, "Got %u bytes\n", eax |
337 | cmp word[buffer], opcode_error |
||
338 | je tftp_error |
||
3545 | hidnplayr | 339 | cmp word[buffer], opcode_data |
340 | jne .error |
||
341 | |||
4655 | hidnplayr | 342 | ; Verify ACK number |
343 | mov bx, word[buffer + 2] |
||
344 | rol bx, 8 |
||
345 | cmp [last_ack], 0 |
||
346 | je @f |
||
347 | cmp [last_ack], bx |
||
3545 | hidnplayr | 348 | jne .packet_got_lost |
4655 | hidnplayr | 349 | inc bx |
350 | @@: |
||
351 | mov [last_ack], bx |
||
3545 | hidnplayr | 352 | |
4655 | hidnplayr | 353 | ; Write to the file |
354 | lea ecx, [eax - 4] |
||
355 | mov [file_struct.size], ecx |
||
356 | mcall 70, file_struct |
||
357 | add [file_struct.offset], ecx |
||
3545 | hidnplayr | 358 | |
4655 | hidnplayr | 359 | ; Send ACK |
360 | mov word[buffer], opcode_ack |
||
3545 | hidnplayr | 361 | mcall send, [socketnum], buffer, 4, 0 |
4655 | hidnplayr | 362 | jmp .loop |
3545 | hidnplayr | 363 | |
4655 | hidnplayr | 364 | .packet_got_lost: |
365 | ;TODO |
||
366 | jmp .loop |
||
3545 | hidnplayr | 367 | |
4655 | hidnplayr | 368 | .red: |
3545 | hidnplayr | 369 | call draw_window |
4655 | hidnplayr | 370 | jmp .loop |
3545 | hidnplayr | 371 | |
4655 | hidnplayr | 372 | .button: |
373 | mcall 17 |
||
374 | cmp ah, 1 |
||
375 | jne .abort |
||
3545 | hidnplayr | 376 | |
4655 | hidnplayr | 377 | mcall close, [socketnum] |
378 | mcall -1 |
||
3545 | hidnplayr | 379 | |
4655 | hidnplayr | 380 | .abort: |
381 | mcall close, [socketnum] |
||
382 | xor eax, eax |
||
383 | mov [socketnum], eax |
||
384 | mov [errormsg], str_abort |
||
385 | jmp home |
||
3545 | hidnplayr | 386 | |
4655 | hidnplayr | 387 | .error: |
388 | mcall close, [socketnum] |
||
389 | xor eax, eax |
||
390 | mov [socketnum], eax |
||
391 | mov [errormsg], str_err_unexp |
||
392 | jmp home |
||
3545 | hidnplayr | 393 | |
4655 | hidnplayr | 394 | .done: |
395 | mcall close, [socketnum] |
||
396 | xor eax, eax |
||
397 | mov [socketnum], eax |
||
398 | mov [errormsg], str_success |
||
399 | jmp home |
||
3545 | hidnplayr | 400 | |
401 | |||
402 | |||
4655 | hidnplayr | 403 | tftp_send: |
3545 | hidnplayr | 404 | |
4655 | hidnplayr | 405 | mcall 40, EVM_REDRAW + EVM_BUTTON + EVM_STACK |
3545 | hidnplayr | 406 | mov [last_ack], 0 |
4655 | hidnplayr | 407 | mov [errormsg], 0 |
3545 | hidnplayr | 408 | |
4655 | hidnplayr | 409 | call draw_window |
3545 | hidnplayr | 410 | |
4655 | hidnplayr | 411 | mov [file_struct.subfn], 0 |
412 | mov [file_struct.offset], 0 |
||
413 | mov [file_struct.size], buffer_len |
||
414 | mov [file_struct.data], buffer + 4 |
||
3545 | hidnplayr | 415 | |
4655 | hidnplayr | 416 | .next: |
3545 | hidnplayr | 417 | mov edi, buffer |
418 | mov ax, opcode_data |
||
419 | stosw |
||
420 | mov ax, [last_ack] |
||
421 | stosw |
||
422 | |||
4655 | hidnplayr | 423 | mcall 70, file_struct |
424 | test eax, eax |
||
425 | ; jnz .done |
||
426 | mov [size], ebx |
||
3545 | hidnplayr | 427 | |
4655 | hidnplayr | 428 | .resend: |
429 | mov ebx, [size] |
||
430 | lea esi, [ebx + 4] |
||
431 | xor edi, edi |
||
432 | mcall send, [socketnum], buffer |
||
3545 | hidnplayr | 433 | |
4655 | hidnplayr | 434 | .loop: |
3545 | hidnplayr | 435 | mcall 23, TIMEOUT |
436 | dec eax |
||
437 | jz .red |
||
438 | dec eax |
||
4655 | hidnplayr | 439 | dec eax |
440 | jz .button |
||
3545 | hidnplayr | 441 | |
4655 | hidnplayr | 442 | mcall recv, [socketnum], buffer, buffer_len, MSG_DONTWAIT |
443 | cmp eax, -1 |
||
444 | je .loop |
||
3545 | hidnplayr | 445 | |
4655 | hidnplayr | 446 | cmp word[buffer], opcode_error |
447 | je tftp_error |
||
3545 | hidnplayr | 448 | cmp word[buffer], opcode_ack |
4655 | hidnplayr | 449 | jne .error |
3545 | hidnplayr | 450 | |
451 | mov ax, [last_ack] |
||
452 | cmp word[buffer+2], ax |
||
4655 | hidnplayr | 453 | jne .resend |
3545 | hidnplayr | 454 | |
4655 | hidnplayr | 455 | mov eax, [size] |
456 | cmp eax, buffer_len |
||
457 | jb .done |
||
458 | add [file_struct.offset], eax |
||
3545 | hidnplayr | 459 | |
4655 | hidnplayr | 460 | inc [last_ack] |
461 | jmp .next |
||
3545 | hidnplayr | 462 | |
4655 | hidnplayr | 463 | .red: |
3545 | hidnplayr | 464 | call draw_window |
465 | jmp .loop |
||
466 | |||
4655 | hidnplayr | 467 | .button: |
468 | mcall 17 |
||
469 | cmp ah, 1 |
||
470 | jne .abort |
||
3545 | hidnplayr | 471 | |
4655 | hidnplayr | 472 | mcall close, [socketnum] |
473 | mcall -1 |
||
3545 | hidnplayr | 474 | |
4655 | hidnplayr | 475 | .abort: |
476 | mcall close, [socketnum] |
||
477 | xor eax, eax |
||
478 | mov [socketnum], eax |
||
479 | mov [errormsg], str_abort |
||
480 | jmp home |
||
3545 | hidnplayr | 481 | |
4655 | hidnplayr | 482 | .error: |
483 | mcall close, [socketnum] |
||
484 | xor eax, eax |
||
485 | mov [socketnum], eax |
||
486 | mov [errormsg], str_err_unexp |
||
487 | jmp home |
||
3545 | hidnplayr | 488 | |
4655 | hidnplayr | 489 | .done: |
490 | mcall close, [socketnum] |
||
491 | xor eax, eax |
||
492 | mov [socketnum], eax |
||
493 | mov [errormsg], str_success |
||
494 | jmp home |
||
3545 | hidnplayr | 495 | |
496 | |||
497 | |||
4655 | hidnplayr | 498 | tftp_error: |
499 | mcall close, [socketnum] |
||
500 | xor eax, eax |
||
501 | mov [socketnum], eax |
||
3545 | hidnplayr | 502 | |
4655 | hidnplayr | 503 | mov ax, word[buffer+2] |
504 | xchg al, ah |
||
3545 | hidnplayr | 505 | |
4655 | hidnplayr | 506 | test ax, ax |
507 | jz .0 |
||
508 | dec ax |
||
509 | jz .1 |
||
510 | dec ax |
||
511 | jz .2 |
||
512 | dec ax |
||
513 | jz .3 |
||
514 | dec ax |
||
515 | jz .4 |
||
516 | dec ax |
||
517 | jz .5 |
||
518 | dec ax |
||
519 | jz .6 |
||
520 | dec ax |
||
521 | jz .7 |
||
522 | |||
523 | .0: |
||
524 | mov [errormsg], str_error.0 |
||
525 | jmp home |
||
526 | .1: |
||
527 | mov [errormsg], str_error.1 |
||
528 | jmp redraw |
||
529 | .2: |
||
530 | mov [errormsg], str_error.2 |
||
531 | jmp home |
||
532 | .3: |
||
533 | mov [errormsg], str_error.3 |
||
534 | jmp home |
||
535 | .4: |
||
536 | mov [errormsg], str_error.4 |
||
537 | jmp home |
||
538 | .5: |
||
539 | mov [errormsg], str_error.5 |
||
540 | jmp home |
||
541 | .6: |
||
542 | mov [errormsg], str_error.6 |
||
543 | jmp home |
||
544 | .7: |
||
545 | mov [errormsg], str_error.7 |
||
546 | jmp home |
||
547 | |||
3545 | hidnplayr | 548 | ;------------------------- |
549 | ; DATA |
||
550 | |||
4468 | hidnplayr | 551 | socketnum dd 0 |
552 | kbps dd 0 |
||
553 | done dd 0 |
||
4655 | hidnplayr | 554 | errormsg dd str_welcome |
3545 | hidnplayr | 555 | |
556 | sockaddr: |
||
4468 | hidnplayr | 557 | dw AF_INET4 |
558 | dw 0x4500 ; 69 |
||
4655 | hidnplayr | 559 | .ip dd ? |
3545 | hidnplayr | 560 | sockaddr_len = $ - sockaddr |
561 | |||
4655 | hidnplayr | 562 | file_struct: |
563 | .subfn dd ? |
||
564 | .offset dd ? |
||
565 | dd 0 |
||
566 | .size dd ? |
||
567 | .data dd ? |
||
568 | db 0 |
||
569 | .filename dd local_addr |
||
570 | |||
3545 | hidnplayr | 571 | align 16 |
572 | @IMPORT: |
||
573 | |||
4655 | hidnplayr | 574 | library box_lib , 'box_lib.obj' ,\ |
575 | network , 'network.obj' |
||
3545 | hidnplayr | 576 | |
577 | import box_lib ,\ |
||
4655 | hidnplayr | 578 | edit_box_draw , 'edit_box' ,\ |
579 | edit_box_key , 'edit_box_key' ,\ |
||
580 | edit_box_mouse , 'edit_box_mouse' ,\ |
||
581 | version_ed , 'version_ed' ,\ |
||
582 | init_checkbox , 'init_checkbox2' ,\ |
||
583 | check_box_draw , 'check_box_draw2' ,\ |
||
584 | check_box_mouse , 'check_box_mouse2' ,\ |
||
585 | version_ch , 'version_ch2' ,\ |
||
586 | option_box_draw , 'option_box_draw' ,\ |
||
587 | option_box_mouse, 'option_box_mouse' ,\ |
||
588 | version_op , 'version_op' |
||
3545 | hidnplayr | 589 | |
4468 | hidnplayr | 590 | import network ,\ |
591 | inet_ntoa , 'inet_ntoa' ,\ |
||
592 | getaddrinfo , 'getaddrinfo' ,\ |
||
593 | freeaddrinfo , 'freeaddrinfo' |
||
3545 | hidnplayr | 594 | |
595 | |||
4655 | hidnplayr | 596 | edit1 edit_box 300, 80, 5, 0xffffff, 0x6f9480, 0, 0, 0, 255, SRV, mouse_dd, ed_focus, 13, 13 |
597 | edit2 edit_box 300, 80, 25, 0xffffff, 0x6f9480, 0, 0, 0, 255, remote_addr, mouse_dd, 0, 4, 4 |
||
598 | edit3 edit_box 300, 80, 45, 0xffffff, 0x6f9480, 0, 0, 0, 255, local_addr, mouse_dd, 0, 12, 12 |
||
599 | edit4 edit_box 40, 340, 68, 0xffffff, 0x6f9480, 0, 0, 0, 5, BLK, mouse_dd, ed_figure_only, 3, 3 |
||
3545 | hidnplayr | 600 | |
4468 | hidnplayr | 601 | op1 option_box option_group1, 80, 68, 6, 12, 0xffffff, 0, 0, netascii, octet-netascii |
602 | op2 option_box option_group1, 80, 85, 6, 12, 0xFFFFFF, 0, 0, octet, get-octet |
||
3545 | hidnplayr | 603 | |
4468 | hidnplayr | 604 | op3 option_box option_group2, 210, 68, 6, 12, 0xffffff, 0, 0, get, put-get |
605 | op4 option_box option_group2, 210, 85, 6, 12, 0xFFFFFF, 0, 0, put, BLK-put |
||
3545 | hidnplayr | 606 | |
607 | option_group1 dd op1 |
||
608 | option_group2 dd op3 |
||
4468 | hidnplayr | 609 | Option_boxs1 dd op1, op2, 0 |
610 | Option_boxs2 dd op3, op4, 0 |
||
3545 | hidnplayr | 611 | |
4468 | hidnplayr | 612 | str_title db 'TFTP client', 0 |
613 | str_server db 'Server:', 0 |
||
614 | str_source db 'Remote file:', 0 |
||
615 | str_destination db 'Local file:', 0 |
||
616 | str_mode db 'Mode:', 0 |
||
617 | str_method db 'Method:', 0 |
||
618 | str_blocksize db 'Blocksize:', 0 |
||
619 | str_kb_s db 'kB/s', 0 |
||
620 | str_complete db '% complete', 0 |
||
621 | str_transfer db 'Transfer', 0 |
||
4655 | hidnplayr | 622 | str_stop db 'Stop', 0 |
3545 | hidnplayr | 623 | |
624 | str_error: |
||
4655 | hidnplayr | 625 | .0 db 'Error.', 0 ; not further defined error |
626 | .1 db 'File not found.', 0 |
||
627 | .2 db 'Access violation.', 0 |
||
628 | .3 db 'Disk full or allocation exceeded.', 0 |
||
629 | .4 db 'Illegal TFTP operation.', 0 |
||
630 | .5 db 'Unknown transfer ID.', 0 |
||
631 | .6 db 'File already exists.', 0 |
||
632 | .7 db 'No such user.', 0 |
||
3545 | hidnplayr | 633 | |
4655 | hidnplayr | 634 | str_welcome db 'Welcome.', 0 |
635 | str_err_resolve db 'Unable to resolve server address.', 0 |
||
636 | str_err_socket db 'Socket error.', 0 |
||
637 | str_err_unexp db 'Unexpected command from server.', 0 |
||
638 | str_success db 'Operation completed successfully.', 0 |
||
639 | str_abort db 'Operation aborted by user.', 0 |
||
3545 | hidnplayr | 640 | |
4655 | hidnplayr | 641 | netascii db 'NetASCII' |
642 | octet db 'Octet' |
||
643 | get db 'GET' |
||
644 | put db 'PUT' |
||
3545 | hidnplayr | 645 | |
4655 | hidnplayr | 646 | BLK db "512", 0, 0, 0 |
3545 | hidnplayr | 647 | |
4468 | hidnplayr | 648 | SRV db "192.168.1.115", 0 |
649 | rb (SRV + 256 - $) |
||
3545 | hidnplayr | 650 | |
4655 | hidnplayr | 651 | remote_addr db "file", 0 |
4468 | hidnplayr | 652 | rb (remote_addr + 256 - $) |
3545 | hidnplayr | 653 | |
4655 | hidnplayr | 654 | local_addr db "/tmp0/1/file", 0 |
4468 | hidnplayr | 655 | rb (local_addr + 256 - $) |
3545 | hidnplayr | 656 | |
4655 | hidnplayr | 657 | include_debug_strings |
658 | |||
3545 | hidnplayr | 659 | I_END: |
4468 | hidnplayr | 660 | |
4655 | hidnplayr | 661 | last_ack dw ? |
662 | size dd ? |
||
663 | mouse_dd dd ? |
||
664 | |||
4468 | hidnplayr | 665 | sc system_colors |
666 | |||
667 | buffer rb buffer_len |
||
3545 | hidnplayr | 668 | |
669 | IM_END: |