Subversion Repositories Kolibri OS

Rev

Rev 4468 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4468 Rev 4655
Line 12... Line 12...
12
;;                                                                 ;;
12
;;                                                                 ;;
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 14... Line 14...
14
 
14
 
Line -... Line 15...
-
 
15
format binary as ""
-
 
16
 
-
 
17
__DEBUG__       = 0
15
format binary as ""
18
__DEBUG_LEVEL__ = 1
16
 
19
 
Line 17... Line 20...
17
use32
20
use32
18
        org     0x0
21
        org     0x0
Line 30... Line 33...
30
include '../../libio.inc'
33
include '../../libio.inc'
31
include '../../dll.inc'
34
include '../../dll.inc'
32
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
35
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
Line 33... Line 36...
33
 
36
 
-
 
37
include '../../network.inc'
Line 34... Line -...
34
include '../../network.inc'
-
 
35
 
-
 
36
 
38
include '../../debug-fdo.inc'
37
filebuffer_size = 4*4096        ; 16kb   (dont try to change it yet..)
39
 
Line 38... Line 40...
38
TIMEOUT         = 100
40
TIMEOUT         = 100
39
buffer_len      = 1500
41
buffer_len      = 4096
40
 
42
 
41
opcode_rrq      = 1
43
opcode_rrq      = 1 shl 8
42
opcode_wrq      = 2
44
opcode_wrq      = 2 shl 8
Line 43... Line 45...
43
opcode_data     = 3
45
opcode_data     = 3 shl 8
44
opcode_ack      = 4
46
opcode_ack      = 4 shl 8
45
opcode_error    = 5
47
opcode_error    = 5 shl 8
46
 
48
 
Line 79... Line 81...
79
 
81
 
80
        stdcall dll.Load, @IMPORT
82
        stdcall dll.Load, @IMPORT
81
        or      eax, eax
83
        or      eax, eax
Line 82... Line 84...
82
        jnz     exit
84
        jnz     exit
83
 
85
 
Line 84... Line 86...
84
stop_transfer:
86
home:
85
        mcall   40, EVM_MOUSE + EVM_MOUSE_FILTER + EVM_REDRAW + EVM_BUTTON + EVM_KEY + EVM_STACK
87
        mcall   40, EVM_MOUSE + EVM_MOUSE_FILTER + EVM_REDRAW + EVM_BUTTON + EVM_KEY + EVM_STACK
Line 86... Line -...
86
 
-
 
87
red_win:
88
 
88
        call    draw_window
89
redraw:
89
 
-
 
90
align 4
90
        call    draw_window
91
still:
91
 
92
        mcall   10
-
 
93
 
92
mainloop:
94
        dec     eax
93
        mcall   10
95
        jz      red_win
-
 
96
 
94
        dec     eax
97
        dec     eax
95
        jz      redraw
Line 98... Line 96...
98
        jz      key
96
        dec     eax
99
 
97
        jz      key
Line 106... Line 104...
106
        invoke  edit_box_mouse, edit4
104
        invoke  edit_box_mouse, edit4
Line 107... Line 105...
107
 
105
 
108
        invoke  option_box_mouse, Option_boxs1
106
        invoke  option_box_mouse, Option_boxs1
Line 109... Line 107...
109
        invoke  option_box_mouse, Option_boxs2
107
        invoke  option_box_mouse, Option_boxs2
Line 110... Line 108...
110
 
108
 
111
        jmp     still
109
        jmp     mainloop
Line 112... Line 110...
112
 
110
 
113
button:
111
button:
Line 114... Line 112...
114
        mcall   17
112
        mcall   17
115
 
113
 
Line 116... Line 114...
116
        cmp     ah, 0x10        ; connect button
114
        cmp     ah, 0x10        ; connect button
117
        je      start_transfer
115
        je      start_transfer
118
 
116
 
119
        test    ah , ah
117
        test    ah , ah
Line 127... Line 125...
127
        invoke  edit_box_key, edit1
125
        invoke  edit_box_key, edit1
128
        invoke  edit_box_key, edit2
126
        invoke  edit_box_key, edit2
129
        invoke  edit_box_key, edit3
127
        invoke  edit_box_key, edit3
130
        invoke  edit_box_key, edit4
128
        invoke  edit_box_key, edit4
Line 131... Line 129...
131
 
129
 
Line 132... Line 130...
132
        jmp still
130
        jmp     mainloop
133
 
131
 
134
 
132
 
Line 174... Line 172...
174
        invoke  option_box_draw, Option_boxs2
172
        invoke  option_box_draw, Option_boxs2
Line 175... Line 173...
175
 
173
 
176
        mov     esi, [sc.work_button]
174
        mov     esi, [sc.work_button]
Line -... Line 175...
-
 
175
        mcall   8, 210 shl 16 + 170, 105 shl 16 + 16, 0x10
-
 
176
 
-
 
177
        mcall   38, 10 shl 16 + 380, 130 shl 16 + 130, [sc.work_graph]
-
 
178
 
-
 
179
        cmp     [errormsg], 0
177
        mcall   8, 210 shl 16 + 170, 105 shl 16 + 16, 0x10
180
        je      .no_error
178
 
181
 
179
        mov     ecx, 0x80000000
182
        mov     ecx, 0x80000000
-
 
183
        or      ecx, [sc.work_text]
-
 
184
        mcall   4, 20 shl 16 + 137, , [errormsg]
Line -... Line 185...
-
 
185
        mcall   12, 2
180
        or      ecx, [sc.work_button_text]
186
        jmp     .draw_btn
181
        mcall   4, 260 shl 16 + 110, , str_transfer
187
 
182
 
188
  .no_error:
183
        mov     ecx, 0x80000000
189
        mov     ecx, 0x80000000
-
 
190
        or      ecx, [sc.work_text]
-
 
191
        mcall   4, 350 shl 16 + 137, , str_kb_s
Line -... Line 192...
-
 
192
        mcall   4, 50 shl 16 + 137, , str_complete
184
        or      ecx, [sc.work_text]
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
Line -... Line 195...
-
 
195
 
185
        mcall   4, 350 shl 16 + 137, , str_kb_s
196
  .draw_btn:
186
        mcall   4, 50 shl 16 + 137, , str_complete
197
        cmp     [socketnum], 0
Line 187... Line 198...
187
 
198
        je      .no_transfer
188
        mcall   38, 10 shl 16 + 380, 130 shl 16 + 130, [sc.work_graph]
-
 
189
 
199
 
Line -... Line 200...
-
 
200
        mov     ecx, 0x80000000
-
 
201
        or      ecx, [sc.work_button_text]
-
 
202
        mcall   4, 270 shl 16 + 110, , str_stop
-
 
203
 
Line -... Line 204...
-
 
204
        mcall   12, 2
-
 
205
        ret
Line 190... Line 206...
190
        mcall   47, 1 shl 31 + 7 shl 16 + 1, kbps, 305 shl 16 + 137, [sc.work_text]
206
 
Line 191... Line 207...
191
        mcall   47, 1 shl 31 + 3 shl 16 + 1, done, 25 shl 16 + 137, ;[sc.work_text]
207
  .no_transfer:
-
 
208
        mov     ecx, 0x80000000
Line 192... Line 209...
192
 
209
        or      ecx, [sc.work_button_text]
Line 193... Line 210...
193
        mcall   12, 2
210
        mcall   4, 260 shl 16 + 110, , str_transfer
194
 
211
 
Line 210... Line 227...
210
        push    dword SRV     ; first parameter
227
        push    dword SRV     ; first parameter
211
        call    [getaddrinfo]
228
        call    [getaddrinfo]
Line 212... Line 229...
212
 
229
 
Line 213... Line 230...
213
        pop     esi
230
        pop     esi
214
 
231
 
215
; test for error
232
        ; test for error
Line 216... Line 233...
216
        test    eax, eax
233
        test    eax, eax
217
        jnz     still
234
        jnz     home
218
 
235
 
Line 219... Line 236...
219
        mov     esi, [esi]
236
        mov     eax, [esi + addrinfo.ai_addr]
220
        mov     esi, [esi + sockaddr_in.sin_addr]
237
        mov     eax, [eax + sockaddr_in.sin_addr]
221
        mov     dword [IP], esi
238
        mov     [sockaddr.ip], eax
-
 
239
 
-
 
240
        ; free allocated memory
-
 
241
        push    esi
Line -... Line 242...
-
 
242
        call    [freeaddrinfo]
-
 
243
 
-
 
244
; Open a socket & connect to server
222
 
245
        mov     [errormsg], str_err_socket
Line 223... Line 246...
223
        mcall   socket, AF_INET4, SOCK_DGRAM, 0                ; socket_open
246
 
224
        cmp     eax, -1
247
        mcall   socket, AF_INET4, SOCK_DGRAM, 0
225
        je      still
248
        cmp     eax, -1
Line -... Line 249...
-
 
249
        je      home
226
 
250
        mov     [socketnum], eax
227
        mov     [socketnum], eax
251
 
228
 
252
        mcall   connect, [socketnum], sockaddr, sockaddr_len
229
        mcall   connect, [socketnum], sockaddr, sockaddr_len         ; socket_connect
253
        cmp     eax, -1
230
        cmp     eax, -1
254
        je      home
Line -... Line 255...
-
 
255
 
231
        je      still
256
; Create the read/write request packet
232
 
257
        mov     word[buffer], opcode_rrq
233
        mov     word [I_END], opcode_rrq
258
        cmp     [option_group2], op3
234
        cmp     [option_group2],op3
259
        je      @f
235
        je      @f
260
        mov     word[buffer], opcode_wrq
236
        mov     word [I_END], opcode_wrq
-
 
237
      @@:
-
 
238
 
261
      @@:
-
 
262
 
239
        xor     al , al
263
; Copy in the remote filename (asciiz)
-
 
264
        xor     al, al
Line -... Line 265...
-
 
265
        mov     edi, remote_addr
240
        mov     edi, remote_addr
266
        mov     ecx, 255
241
        mov     ecx, 250
267
        repnz   scasb
242
        repnz   scasb
-
 
243
        sub     edi, remote_addr-1
268
        lea     ecx, [edi - remote_addr - 1]
244
        mov     ecx, edi
269
        mov     esi, remote_addr
245
        mov     edi, I_END+2
270
        mov     edi, buffer+2
246
        mov     esi, remote_addr
-
 
247
        rep     movsb
271
        rep     movsb
Line 248... Line 272...
248
 
272
        stosb
249
        cmp     [option_group1], op1
-
 
250
        je      .ascii
273
 
251
 
274
; Append the data type (asciiz)
252
        mov     esi, octet
275
        cmp     [option_group1], op1
Line -... Line 276...
-
 
276
        je      .ascii
253
        movsd
277
        mov     esi, octet
254
        movsb
-
 
255
 
278
        movsd
256
        jmp     .send_request
279
        movsb
-
 
280
        jmp     .send_request
-
 
281
 
-
 
282
      .ascii:
-
 
283
        mov     esi, netascii
-
 
284
        movsd
Line 257... Line 285...
257
 
285
        movsd
258
      .ascii:
286
 
259
 
287
; Send the request to the server
260
        mov     esi, netascii
-
 
261
        movsd
-
 
Line 262... Line -...
262
        movsd
-
 
Line -... Line 288...
-
 
288
      .send_request:
Line -... Line 289...
-
 
289
        xor     al, al
-
 
290
        stosb
-
 
291
        lea     esi, [edi - buffer]
Line -... Line 292...
-
 
292
        xor     edi, edi
Line 263... Line 293...
263
 
293
        mcall   send, [socketnum], buffer
-
 
294
        cmp     eax, -1
-
 
295
        je      home
-
 
296
 
-
 
297
; Jump to send/receive code
-
 
298
        cmp     word[buffer], opcode_wrq
-
 
299
        je      tftp_send
-
 
300
 
-
 
301
 
-
 
302
tftp_receive:
-
 
303
 
-
 
304
        mcall   40, EVM_REDRAW + EVM_BUTTON + EVM_STACK
-
 
305
        mov     [last_ack], 0
Line -... Line 306...
-
 
306
        mov     [errormsg], 0
264
      .send_request:
307
 
265
 
-
 
266
        xor     al, al
308
        call    draw_window
267
        stosb
309
 
268
 
-
 
269
        sub     edi, I_END
310
; Open/create local file
-
 
311
        mov     [file_struct.subfn], 2
270
        mov     esi, edi
312
        mov     [file_struct.offset], 0
271
        mcall   send, [socketnum], I_END
-
 
Line 272... Line 313...
272
 
313
        mov     [file_struct.size], 0
-
 
314
        mcall   70, file_struct
-
 
315
 
Line -... Line 316...
-
 
316
; Truncate it to 0 bytes
-
 
317
        mov     [file_struct.subfn], 4
-
 
318
        mcall   70, file_struct
273
        mcall   40, EVM_REDRAW + EVM_BUTTON + EVM_STACK
319
 
274
 
320
; Set parameters for writing to file
Line -... Line 321...
-
 
321
        mov     [file_struct.subfn], 3
-
 
322
        mov     [file_struct.data], buffer + 4
-
 
323
 
275
        mov     [last_ack], 0
324
  .loop:
-
 
325
        mcall   23, TIMEOUT
276
 
326
        dec     eax
277
 
327
        jz      .red
278
 
328
        dec     eax
279
 
-
 
280
receive_data_loop:
329
        dec     eax
281
 
330
        jz      .button
282
        mcall   23, TIMEOUT
-
 
283
 
-
 
284
        dec     eax
-
 
285
        jz      .red
-
 
286
 
-
 
287
        dec     eax
-
 
288
        jz      .key
-
 
Line 289... Line 331...
289
 
331
 
-
 
332
        mcall   recv, [socketnum], buffer, buffer_len, MSG_DONTWAIT     ; receive data
-
 
333
        cmp     eax, -1
-
 
334
        je      .loop
-
 
335
 
Line -... Line 336...
-
 
336
        DEBUGF  1, "Got %u bytes\n", eax
290
 
337
        cmp     word[buffer], opcode_error
291
        mcall   recv, [socketnum], buffer, buffer_len, MSG_DONTWAIT     ; receive data
338
        je      tftp_error
-
 
339
        cmp     word[buffer], opcode_data
Line -... Line 340...
-
 
340
        jne     .error
-
 
341
 
292
 
342
; Verify ACK number
293
        cmp     word[buffer], opcode_data
-
 
294
        jne     .error
-
 
Line -... Line 343...
-
 
343
        mov     bx, word[buffer + 2]
295
 
344
        rol     bx, 8
-
 
345
        cmp     [last_ack], 0
Line 296... Line -...
296
        mov     bx, [last_ack]
-
 
297
        cmp     word [buffer + 2], bx
-
 
298
        jne     .packet_got_lost
-
 
299
        inc     [last_ack]
346
        je      @f
300
 
347
        cmp     [last_ack], bx
301
        cmp     eax, 4+512
348
        jne     .packet_got_lost
302
        je      .continue
349
        inc     bx
303
 
-
 
304
; last packet, or something else
-
 
305
.error:
-
 
306
 
-
 
307
.packet_got_lost:
-
 
308
 
-
 
309
 
-
 
Line -... Line 350...
-
 
350
      @@:
-
 
351
        mov     [last_ack], bx
Line -... Line 352...
-
 
352
 
-
 
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
Line -... Line 358...
-
 
358
 
-
 
359
; Send ACK
-
 
360
        mov     word[buffer], opcode_ack
310
 
361
        mcall   send, [socketnum], buffer, 4, 0
-
 
362
        jmp     .loop
-
 
363
 
Line -... Line 364...
-
 
364
  .packet_got_lost:
-
 
365
        ;TODO
-
 
366
        jmp     .loop
-
 
367
 
-
 
368
  .red:
-
 
369
        call    draw_window
Line 311... Line -...
311
.continue:
-
 
Line 312... Line -...
312
 
-
 
313
        mov     word[buffer], opcode_ack                ; send ack
-
 
314
        mcall   send, [socketnum], buffer, 4, 0
-
 
315
 
-
 
Line 316... Line -...
316
        jmp     receive_data_loop
-
 
317
 
-
 
318
.red:
370
        jmp     .loop
319
 
-
 
Line -... Line 371...
-
 
371
 
320
        call    draw_window
372
  .button:
321
 
373
        mcall   17
Line 322... Line 374...
322
        jmp     receive_data_loop
374
        cmp     ah, 1
Line 323... Line 375...
323
 
375
        jne     .abort
324
 
376
 
325
.key:
-
 
326
        mcall   2
377
        mcall   close, [socketnum]
327
        cmp     ah, 2
-
 
328
        jz      exit
-
 
329
 
378
        mcall   -1
330
        ; close socket ?
-
 
331
 
-
 
332
        jmp     receive_data_loop
-
 
333
 
-
 
334
 
379
 
335
 
380
  .abort:
336
 
-
 
337
 
-
 
338
 
-
 
339
;--------------------------------
-
 
340
 
-
 
341
 
381
        mcall   close, [socketnum]
342
send_:
382
        xor     eax, eax
343
 
383
        mov     [socketnum], eax
344
        invoke  file_open, local_addr, O_READ
384
        mov     [errormsg], str_abort
345
        or      eax, eax
385
        jmp     home
346
        jz      .exit
-
 
347
        mov     [fh], eax
-
 
348
 
-
 
349
        stdcall mem.Alloc, filebuffer_size
-
 
Line -... Line 386...
-
 
386
 
-
 
387
  .error:
-
 
388
        mcall   close, [socketnum]
-
 
389
        xor     eax, eax
Line 350... Line 390...
350
        or      eax, eax
390
        mov     [socketnum], eax
-
 
391
        mov     [errormsg], str_err_unexp
-
 
392
        jmp     home
-
 
393
 
-
 
394
  .done:
Line -... Line 395...
-
 
395
        mcall   close, [socketnum]
351
        jz      .exit
396
        xor     eax, eax
352
        mov     [fb], eax
-
 
353
 
397
        mov     [socketnum], eax
354
        mov     [last_ack], 0
398
        mov     [errormsg], str_success
355
        mov     [fo], 0
-
 
356
 
399
        jmp     home
-
 
400
 
357
.read_chunk:
401
 
Line 358... Line 402...
358
 
402
 
-
 
403
tftp_send:
-
 
404
 
Line -... Line 405...
-
 
405
        mcall   40, EVM_REDRAW + EVM_BUTTON + EVM_STACK
-
 
406
        mov     [last_ack], 0
359
        invoke  file_seek, [fh], [fo], SEEK_END
407
        mov     [errormsg], 0
360
        cmp     eax, -1
408
 
Line 361... Line 409...
361
        je      .exit
409
        call    draw_window
362
        invoke  file_read, [fh], [fb], filebuffer_size
410
 
363
        cmp     eax, -1
411
        mov     [file_struct.subfn], 0
364
        je      .exit
-
 
365
        add     [fo], filebuffer_size
-
 
366
        cmp     eax, filebuffer_size
-
 
367
        je      .packet
-
 
Line -... Line 412...
-
 
412
        mov     [file_struct.offset], 0
-
 
413
        mov     [file_struct.size], buffer_len
-
 
414
        mov     [file_struct.data], buffer + 4
-
 
415
 
Line -... Line 416...
-
 
416
  .next:
368
 
417
        mov     edi, buffer
Line -... Line 418...
-
 
418
        mov     ax, opcode_data
369
        ; ijhidfhfdsndsfqk
419
        stosw
370
 
-
 
371
.packet:
420
        mov     ax, [last_ack]
Line -... Line 421...
-
 
421
        stosw
-
 
422
 
-
 
423
        mcall   70, file_struct
-
 
424
        test    eax, eax
Line 372... Line -...
372
 
-
 
373
        movzx   esi, [last_ack]
425
;        jnz     .done
374
        and     esi, 0x000000001f   ; last five bits    BUFFER SIZE MUST BE 16 kb for this to work !!!
-
 
375
        shl     esi, 9              ; = * 512
426
        mov     [size], ebx
Line -... Line 427...
-
 
427
 
376
        add     esi, [fb]
428
  .resend:
-
 
429
        mov     ebx, [size]
-
 
430
        lea     esi, [ebx + 4]
-
 
431
        xor     edi, edi
-
 
432
        mcall   send, [socketnum], buffer
Line -... Line 433...
-
 
433
 
-
 
434
  .loop:
-
 
435
        mcall   23, TIMEOUT
-
 
436
        dec     eax
-
 
437
        jz      .red
377
        mov     edi, buffer
438
        dec     eax
-
 
439
        dec     eax
-
 
440
        jz      .button
-
 
441
 
-
 
442
        mcall   recv, [socketnum], buffer, buffer_len, MSG_DONTWAIT
-
 
443
        cmp     eax, -1
-
 
444
        je      .loop
-
 
445
 
Line 378... Line -...
378
        mov     ax, opcode_data
-
 
379
        stosw
-
 
380
        mov     ax, [last_ack]
-
 
Line -... Line 446...
-
 
446
        cmp     word[buffer], opcode_error
-
 
447
        je      tftp_error
-
 
448
        cmp     word[buffer], opcode_ack
-
 
449
        jne     .error
Line -... Line 450...
-
 
450
 
-
 
451
        mov     ax, [last_ack]
Line -... Line 452...
-
 
452
        cmp     word[buffer+2], ax
-
 
453
        jne     .resend
-
 
454
 
-
 
455
        mov     eax, [size]
-
 
456
        cmp     eax, buffer_len
-
 
457
        jb      .done
-
 
458
        add     [file_struct.offset], eax
-
 
459
 
-
 
460
        inc     [last_ack]
-
 
461
        jmp     .next
-
 
462
 
-
 
463
  .red:
-
 
464
        call    draw_window
-
 
465
        jmp     .loop
-
 
466
 
-
 
467
  .button:
-
 
468
        mcall   17
-
 
469
        cmp     ah, 1
-
 
470
        jne     .abort
-
 
471
 
-
 
472
        mcall   close, [socketnum]
-
 
473
        mcall   -1
-
 
474
 
-
 
475
  .abort:
-
 
476
        mcall   close, [socketnum]
-
 
477
        xor     eax, eax
-
 
478
        mov     [socketnum], eax
-
 
479
        mov     [errormsg], str_abort
-
 
480
        jmp     home
-
 
481
 
-
 
482
  .error:
-
 
483
        mcall   close, [socketnum]
-
 
484
        xor     eax, eax
-
 
485
        mov     [socketnum], eax
-
 
486
        mov     [errormsg], str_err_unexp
-
 
487
        jmp     home
-
 
488
 
-
 
489
  .done:
-
 
490
        mcall   close, [socketnum]
-
 
491
        xor     eax, eax
-
 
492
        mov     [socketnum], eax
Line 381... Line 493...
381
        stosw
493
        mov     [errormsg], str_success
382
        mov     ecx, 512/4
494
        jmp     home
Line 383... Line 495...
383
        rep     movsd
495
 
384
 
496
 
385
        mcall   send, [socketnum], buffer, 4+512, 0       ; send data
497
 
-
 
498
tftp_error:
Line 386... Line 499...
386
 
499
        mcall   close, [socketnum]
387
 
500
        xor     eax, eax
388
.loop:
501
        mov     [socketnum], eax
389
 
502
 
390
        mcall   23, TIMEOUT
-
 
391
 
503
        mov     ax, word[buffer+2]
Line -... Line 504...
-
 
504
        xchg    al, ah
-
 
505
 
-
 
506
        test    ax, ax
-
 
507
        jz      .0
-
 
508
        dec     ax
-
 
509
        jz      .1
-
 
510
        dec     ax
-
 
511
        jz      .2
-
 
512
        dec     ax
392
        dec     eax
513
        jz      .3
393
        jz      .red
514
        dec     ax
Line 394... Line 515...
394
 
515
        jz      .4
395
        dec     eax
-
 
396
        jz      .key
516
        dec     ax
Line 397... Line 517...
397
 
517
        jz      .5
398
        mcall   recv, [socketnum], buffer, buffer_len, MSG_DONTWAIT  ; receive ack
518
        dec     ax
399
 
519
        jz      .6
400
        cmp     word[buffer], opcode_ack
520
        dec     ax
401
        jne     .exit
521
        jz      .7
402
 
522
 
403
        mov     ax, [last_ack]
523
  .0:
404
        cmp     word[buffer+2], ax
524
        mov     [errormsg], str_error.0
405
        jne     .packet
525
        jmp     home
406
        inc     [last_ack]
526
  .1:
407
        test    [last_ack],0x001f
527
        mov     [errormsg], str_error.1
408
        jz      .read_chunk
528
        jmp     redraw
409
        jmp     .packet
-
 
410
 
-
 
411
 
-
 
412
.red:
-
 
413
 
-
 
414
        call    draw_window
-
 
415
 
-
 
416
        jmp     .loop
-
 
417
 
-
 
418
 
-
 
419
.key:
-
 
420
        mcall   2
-
 
421
        cmp     ah, 2
-
 
422
        jz      exit
-
 
423
 
-
 
Line 424... Line 529...
424
        ; close socket ?
529
  .2:
425
 
530
        mov     [errormsg], str_error.2
426
        jmp     .loop
531
        jmp     home
427
 
532
  .3:
Line 428... Line 533...
428
.exit:
533
        mov     [errormsg], str_error.3
429
        invoke  file_close, [fh]
534
        jmp     home
430
        jmp     still
535
  .4:
431
 
536
        mov     [errormsg], str_error.4
Line 432... Line 537...
432
 
537
        jmp     home
433
 
538
  .5:
Line 434... Line 539...
434
 
539
        mov     [errormsg], str_error.5
Line 512... Line 617...
512
str_method      db 'Method:', 0
617
str_method      db 'Method:', 0
513
str_blocksize   db 'Blocksize:', 0
618
str_blocksize   db 'Blocksize:', 0
514
str_kb_s        db 'kB/s', 0
619
str_kb_s        db 'kB/s', 0
515
str_complete    db '% complete', 0
620
str_complete    db '% complete', 0
516
str_transfer    db 'Transfer', 0
621
str_transfer    db 'Transfer', 0
-
 
622
str_stop        db 'Stop', 0
Line 517... Line 623...
517
 
623
 
518
str_error:
624
str_error:
519
._0 db 'Not defined, see error message (if any).', 0
625
.0              db 'Error.', 0                      ; not further defined error
520
._1 db 'File not found.', 0
626
.1              db 'File not found.', 0
521
._2 db 'Access violation.', 0
627
.2              db 'Access violation.', 0
522
._3 db 'Disk full or allocation exceeded.', 0
628
.3              db 'Disk full or allocation exceeded.', 0
523
._4 db 'Illegal TFTP operation.', 0
629
.4              db 'Illegal TFTP operation.', 0
524
._5 db 'Unknown transfer ID.', 0
630
.5              db 'Unknown transfer ID.', 0
525
._6 db 'File already exists.', 0
631
.6              db 'File already exists.', 0
526
._7 db 'No such user.', 0
632
.7              db 'No such user.', 0
-
 
633
 
-
 
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
527
 
639
str_abort       db 'Operation aborted by user.', 0
528
 
640
 
529
netascii db 'NetASCII'
641
netascii        db 'NetASCII'
530
octet    db 'Octet'
642
octet           db 'Octet'
531
get      db 'GET'
643
get             db 'GET'
532
put      db 'PUT'
644
put             db 'PUT'
533
 
645
 
534
BLK      db "512", 0, 0, 0
-
 
535
 
-
 
536
last_ack dw ?
-
 
537
 
-
 
538
fh       dd ?   ; file handle
-
 
539
fo       dd ?   ; file offset
-
 
Line 540... Line 646...
540
fb       dd ?   ; file buffer
646
BLK             db "512", 0, 0, 0
541
 
647
 
Line 542... Line 648...
542
SRV             db "192.168.1.115", 0
648
SRV             db "192.168.1.115", 0
543
                rb (SRV + 256 - $)
649
                rb (SRV + 256 - $)
Line 544... Line 650...
544
 
650
 
545
remote_addr     db "IMG00", 0
651
remote_addr     db "file", 0
Line -... Line 652...
-
 
652
                rb (remote_addr + 256 - $)
-
 
653
 
546
                rb (remote_addr + 256 - $)
654
local_addr      db "/tmp0/1/file", 0
Line -... Line 655...
-
 
655
                rb (local_addr + 256 - $)
-
 
656
 
-
 
657
include_debug_strings
-
 
658
 
547
 
659
I_END:
Line 548... Line -...
548
local_addr      db "/hd0/1/KolibriOS/kernel.mnt", 0
-
 
549
                rb (local_addr + 256 - $)
660
 
Line 550... Line 661...
550
 
661
last_ack        dw ?
551
I_END:
662
size            dd ?