Rev 485 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ; |
2 | ; PPP.ASM |
||
3 | ; |
||
4 | ; Compile with FASM for Menuet |
||
5 | ; This program dials into an ISP and establishes a PPP connection |
||
6 | ; |
||
7 | ; Version 11 26th January 2004 |
||
8 | ; |
||
9 | ; This code is a port of the PPP dialer program by Microchip, from |
||
10 | ; their application note AN724 |
||
11 | ; It has been ported by Mike Hibbett mikeh@oceanfree.net for Menuet |
||
12 | ; |
||
13 | ; 26/1/04 - Mike Hibbett - added support for com port selected by |
||
14 | ; stackcfg |
||
15 | ; 2/5/03 - Shrirang - Added Abort Strings To sendwait to get out early |
||
16 | ; if modem sends abort strings like NO CARRIER etc. |
||
17 | ; |
||
18 | ; The original copyright statement follows |
||
19 | ;////////////////////////////////////////////////////////////////////////// |
||
20 | ;// |
||
21 | ;//PING.C version 1.10 July 29/99 (C)opyright by Microchip Technology Inc |
||
22 | ;// |
||
23 | ;////////////////////////////////////////////////////////////////////////// |
||
24 | |||
25 | FALSE equ 0 |
||
26 | TRUE equ 1 |
||
27 | DEBUG_OUTPUT equ TRUE ; If FALSE, not debugging info outputted |
||
28 | DEBUG_PPP_OUTPUT equ TRUE ; write PPP status msgs to debug board? |
||
29 | DEBUG_PORT2_OUTPUT equ TRUE ; write debug data also to com2 |
||
30 | |||
31 | |||
32 | BAUD_9600 equ 12 |
||
33 | BAUD_57600 equ 2 |
||
34 | ; The next line sets the baud rate of the connection to the modem |
||
35 | BAUDRATE equ BAUD_57600 |
||
36 | |||
37 | |||
38 | LINE_END equ 0x0D ; End of input data character |
||
39 | |||
40 | |||
41 | ; Defines for Internet constants |
||
42 | REQ equ 1 ; Request options list for PPP negotiations |
||
43 | PPP_ACK equ 2 ; Acknowledge options list for PPP negotiations |
||
44 | PPP_NAK equ 3 ; Not acknowledged options list for PPP neg |
||
45 | REJ equ 4 ; Reject options list for PPP negotiations |
||
46 | TERM equ 5 ; Termination packet for LCP to close connectio |
||
47 | LCP_ECHO_REQ equ 9 |
||
48 | LCP_ECHO_REP equ 10 |
||
49 | IP equ 0x0021 ; Internet Protocol packet |
||
50 | IPCP equ 0x8021 ; Internet Protocol Configure Protocol packet |
||
51 | CCP equ 0x80FD ; Compression Configure Protocol packet |
||
52 | LCP equ 0xC021 ; Link Configure Protocol packet |
||
53 | PAP equ 0xC023 ; Password Authenication Protocol packet |
||
54 | |||
55 | |||
56 | MaxRx equ 1500 |
||
57 | MaxTx equ 1500 |
||
58 | |||
59 | |||
60 | |||
61 | |||
62 | use32 |
||
485 | heavyiron | 63 | org 0x0 |
64 | db 'MENUET01' ; header |
||
65 | dd 0x01 ; header version |
||
66 | dd STARTAPP ; entry point |
||
67 | dd I_END ; image size |
||
68 | dd I_END+0x10000 ; required memory |
||
69 | dd I_END+0x10000 ; esp |
||
70 | dd 0x0 , 0x0 ; I_Param , I_Path |
||
31 | halyavin | 71 | |
72 | |||
73 | include "lang.inc" |
||
485 | heavyiron | 74 | include "..\..\..\macros.inc" |
31 | halyavin | 75 | include "chat.inc" ; Hosts modem chatting routine |
76 | |||
77 | |||
78 | STARTAPP: |
||
79 | ; mov eax, 0x3f8 |
||
80 | ; mov [comport], eax |
||
81 | ; mov eax, 4 |
||
82 | ; mov [comirq], eax |
||
83 | |||
84 | ; Get the com port & IRQ to use from the kernel stack config option |
||
85 | |||
86 | mov eax, 52 ; Stack Interface |
||
87 | mov ebx, 0 ; read configuration word |
||
485 | heavyiron | 88 | mcall |
31 | halyavin | 89 | mov ecx, eax |
90 | shr ecx, 16 ; get the port address |
||
91 | mov [comport], ecx |
||
92 | shr eax, 8 |
||
93 | and eax, 0x000000FF ; get the irq |
||
94 | mov [comirq], eax |
||
95 | |||
96 | |||
97 | mov eax, [comport] |
||
98 | add eax, 0x01000000 |
||
99 | mov [irqtable], eax |
||
100 | |||
101 | |||
102 | call enable_port |
||
103 | |||
104 | appdsp: |
||
105 | mov eax, welcomep |
||
106 | mov [prompt], eax ; set up prompt to display |
||
107 | mov al, [welcomep_len] |
||
108 | mov [prompt_len], al |
||
109 | |||
485 | heavyiron | 110 | red: |
31 | halyavin | 111 | call draw_window ; at first, draw the window |
112 | |||
113 | apploop: |
||
114 | mov eax, 23 ; wait here for event |
||
115 | mov ebx, 20 |
||
485 | heavyiron | 116 | mcall |
31 | halyavin | 117 | |
118 | cmp eax, 1 ; redraw request ? |
||
119 | je red |
||
120 | cmp eax, 2 ; key in buffer ? |
||
121 | je key |
||
122 | cmp eax, 3 ; button in buffer ? |
||
123 | je button |
||
124 | mov ebx, [comirq] |
||
125 | add ebx, 16 |
||
126 | cmp eax, ebx |
||
127 | je flush_input ; Dont want serial data yet |
||
128 | jmp apploop |
||
129 | |||
130 | key: ; key - ignore |
||
131 | mov eax, 2 ; just read it |
||
485 | heavyiron | 132 | mcall |
31 | halyavin | 133 | jmp apploop |
134 | |||
135 | button: ; button |
||
136 | mov eax, 17 ; get id |
||
485 | heavyiron | 137 | mcall |
31 | halyavin | 138 | |
139 | cmp ah, 1 ; close program ? |
||
140 | jne noclose |
||
141 | |||
142 | mov esi, hangupWait |
||
143 | mov edi, hangupSend |
||
144 | mov edx, 1000 ; Allow sendwait 10s |
||
145 | call sendwait |
||
146 | |||
147 | call disable_port |
||
148 | |||
485 | heavyiron | 149 | or eax, -1 ; close this program |
150 | mcall |
||
31 | halyavin | 151 | jmp apploop |
152 | |||
153 | noclose: |
||
154 | cmp ah, 2 ; Dial Button pressed? |
||
155 | jne apploop |
||
156 | |||
157 | mov eax, conp |
||
158 | mov [prompt], eax ; set up prompt to display |
||
159 | mov al,[conp_len] |
||
160 | mov [prompt_len], al |
||
161 | call draw_window |
||
162 | |||
163 | jmp dialloop ; connect to the host |
||
164 | |||
165 | |||
166 | ; Data received, so get it, and throw it away at this point |
||
167 | flush_input: |
||
168 | mov eax,42 |
||
169 | mov ebx, [comirq] |
||
485 | heavyiron | 170 | mcall |
31 | halyavin | 171 | |
172 | mov eax,11 ; This will return 0 most of the time |
||
485 | heavyiron | 173 | mcall |
31 | halyavin | 174 | mov ebx, [comirq] |
175 | add ebx, 16 |
||
176 | cmp eax, ebx |
||
177 | je flush_input |
||
178 | jmp apploop |
||
179 | |||
180 | |||
181 | dialloop: |
||
182 | call modem_chat ; Try chatting with the modem |
||
183 | |||
184 | cmp eax, 1 ; Did it work? ( = 1) |
||
185 | jne appdsp |
||
186 | |||
187 | ; OK, we are now connected. |
||
188 | |||
189 | mov eax, pppOnp |
||
190 | mov [prompt], eax ; set up prompt to display |
||
191 | mov al,[pppOnp_len] |
||
192 | mov [prompt_len], al |
||
193 | call draw_window |
||
194 | |||
195 | mov eax, 23 |
||
196 | mov ebx, 100 |
||
485 | heavyiron | 197 | mcall ; wait for 1s to display message |
31 | halyavin | 198 | |
199 | call PPPStateMachine ; This is the main code |
||
200 | |||
201 | jmp appdsp |
||
202 | |||
203 | |||
204 | |||
205 | |||
206 | ;**************************************************************************** |
||
207 | ; Function |
||
208 | ; PPPStateMachine |
||
209 | ; |
||
210 | ; Description |
||
211 | ; Handles PPP link establishment |
||
212 | ; |
||
213 | ;**************************************************************************** |
||
214 | PPPStateMachine: |
||
215 | ; Start the timer |
||
216 | xor eax, eax |
||
217 | call settimer |
||
218 | |||
219 | PPPLoop: |
||
220 | |||
221 | mov eax, 11 ; check event |
||
485 | heavyiron | 222 | mcall |
31 | halyavin | 223 | cmp eax, 3 |
224 | jne PPPLred |
||
225 | ; button pressed |
||
226 | mov eax, 17 ; get id |
||
485 | heavyiron | 227 | mcall |
31 | halyavin | 228 | |
229 | |||
230 | mov eax, hangp |
||
231 | mov [prompt], eax ; set up prompt to display |
||
232 | mov al,[hangp_len] |
||
233 | mov [prompt_len], al |
||
234 | call draw_window |
||
235 | |||
236 | mov esi, hangupWait |
||
237 | mov edi, hangupSend |
||
238 | mov edx, 1000 ; Allow sendwait 10s |
||
239 | call sendwait |
||
240 | |||
241 | call disable_port |
||
242 | mov eax, -1 ; close this program |
||
485 | heavyiron | 243 | mcall |
31 | halyavin | 244 | jmp PPPLoop |
245 | |||
246 | PPPLred: |
||
247 | cmp eax, 1 ; redraw request ? |
||
248 | jne PPPLoop0 |
||
249 | |||
250 | call draw_window |
||
251 | jmp PPPLoop |
||
252 | |||
253 | PPPLoop0: |
||
254 | mov ebx, [comirq] |
||
255 | add ebx, 16 |
||
256 | cmp eax, ebx |
||
257 | jne ppp_002 ; check for tx to send |
||
258 | |||
259 | |||
260 | ; we have data in the rx buffer, get it |
||
261 | |||
262 | mov eax, 42 |
||
263 | mov ebx, [comirq] ; ecx will return 0 =data read, 1 =no data |
||
485 | heavyiron | 264 | mcall ; or 2 =not irq owner |
31 | halyavin | 265 | |
266 | inc dword [rxbytes] |
||
267 | |||
268 | cmp bl, 0x7E |
||
269 | jne ppp_001a |
||
270 | |||
271 | mov eax, [rx_ptr] |
||
272 | cmp eax, 0 |
||
273 | jz ppp_001 |
||
274 | mov eax, [checksum1] |
||
275 | cmp eax, 0xf0b8 |
||
276 | jne ppp_001 |
||
277 | |||
278 | |||
279 | movzx eax, byte [rx_str + 3] |
||
280 | mov ah, [rx_str + 2] |
||
281 | mov [packet], eax |
||
282 | |||
283 | ppp_001: |
||
284 | mov eax, [extended] |
||
285 | and eax, 0x7e |
||
286 | mov [extended], eax |
||
287 | xor eax, eax |
||
288 | mov [rx_ptr], eax |
||
289 | |||
290 | mov eax, 0xffff |
||
291 | mov [checksum1], eax |
||
292 | jmp ppp_003 |
||
293 | |||
294 | ppp_001a: |
||
295 | cmp bl, 0x7D |
||
296 | jne ppp_001b |
||
297 | |||
298 | mov eax, [extended] |
||
299 | or eax, 0x01 |
||
300 | mov [extended], eax |
||
301 | jmp ppp_003 |
||
302 | |||
303 | ppp_001b: |
||
304 | mov eax, [extended] |
||
305 | test eax, 0x01 |
||
306 | jz ppp_001c |
||
307 | |||
308 | xor bl, 0x20 |
||
309 | and eax, 0xFE |
||
310 | mov [extended], eax |
||
311 | |||
312 | ppp_001c: |
||
313 | mov edx, [rx_ptr] |
||
314 | cmp edx, 0 |
||
315 | jnz ppp_001d |
||
316 | cmp bl, 0xff |
||
317 | je ppp_001d |
||
318 | |||
319 | mov [rx_str + edx], byte 0xff |
||
320 | inc edx |
||
321 | |||
322 | ppp_001d: |
||
323 | cmp edx, 1 |
||
324 | jnz ppp_001e |
||
325 | cmp bl, 0x03 |
||
326 | je ppp_001e |
||
327 | |||
328 | mov [rx_str + edx], byte 0x03 |
||
329 | inc edx |
||
330 | |||
331 | ppp_001e: |
||
332 | cmp edx, 2 |
||
333 | jnz ppp_001f |
||
334 | test bl, 0x01 |
||
335 | jz ppp_001f |
||
336 | |||
337 | mov [rx_str + edx], byte 0 |
||
338 | inc edx |
||
339 | |||
340 | ppp_001f: |
||
341 | mov [rx_str + edx], bl |
||
342 | inc edx |
||
343 | mov [rx_ptr], edx |
||
344 | |||
345 | cmp edx, MaxRx |
||
346 | jle ppp_001g |
||
347 | mov edx, MaxRx |
||
348 | mov [rx_ptr], edx |
||
349 | |||
350 | ppp_001g: |
||
351 | ; do checksum calc |
||
352 | mov eax, [checksum1] |
||
353 | xor bh, bh |
||
354 | xor ax, bx |
||
355 | call calc |
||
356 | mov ebx, [checksum1] |
||
357 | and ebx, 0xffff |
||
358 | shr ebx, 8 |
||
359 | xor eax, ebx |
||
360 | mov [checksum1], eax |
||
361 | jmp ppp_003 |
||
362 | |||
363 | ppp_002: |
||
364 | mov eax, [tx_end] |
||
365 | cmp eax, 0 |
||
366 | jz ppp_003 |
||
367 | |||
368 | mov ebx, [tx_ptr] |
||
369 | mov cl, [tx_str + ebx] |
||
370 | |||
371 | cmp ebx, eax |
||
372 | jne ppp_002a |
||
373 | mov [tx_end], dword 0 |
||
374 | mov cl, '~' |
||
375 | jmp ppp_002d |
||
376 | |||
377 | ppp_002a: |
||
378 | mov eax, [extended] |
||
379 | and eax, 0x02 |
||
380 | jz ppp_002b |
||
381 | |||
382 | xor cl, 0x20 |
||
383 | mov eax, [extended] |
||
384 | and eax, 0xFD |
||
385 | mov [extended], eax |
||
386 | inc [tx_ptr] |
||
387 | jmp ppp_002d |
||
388 | |||
389 | ppp_002b: |
||
390 | cmp cl, 0x20 |
||
391 | jl ppp_002b1 |
||
392 | cmp cl, 0x7d |
||
393 | je ppp_002b1 |
||
394 | cmp cl, 0x7e |
||
395 | je ppp_002b1 |
||
396 | jmp ppp_002c |
||
397 | |||
398 | ppp_002b1: |
||
399 | mov eax, [extended] |
||
400 | or eax, 0x02 |
||
401 | mov [extended], eax |
||
402 | mov cl, 0x7d |
||
403 | jmp ppp_002d |
||
404 | |||
405 | ppp_002c: |
||
406 | mov eax, [tx_ptr] |
||
407 | cmp eax, 0 |
||
408 | jnz ppp_002c1 |
||
409 | mov cl, '~' |
||
410 | |||
411 | ppp_002c1: |
||
412 | inc [tx_ptr] |
||
413 | |||
414 | ppp_002d: |
||
415 | ; Test for tx ready. |
||
416 | |||
417 | push ecx |
||
418 | |||
419 | wait_txd2: |
||
420 | mov eax,43 |
||
421 | mov ecx, [comport] |
||
422 | add ecx, 0x80000000 + 5 |
||
485 | heavyiron | 423 | mcall |
31 | halyavin | 424 | and bl, 0x40 |
425 | cmp bl, 0 |
||
426 | jz wait_txd2 ; loop until free |
||
427 | |||
428 | pop ebx |
||
429 | |||
430 | |||
431 | ; send the character |
||
432 | |||
433 | inc dword [txbytes] |
||
434 | |||
435 | mov ecx, [comport] |
||
436 | mov eax, 43 |
||
485 | heavyiron | 437 | mcall |
31 | halyavin | 438 | |
439 | ppp_003: |
||
440 | mov eax, [packet] |
||
441 | cmp eax, LCP |
||
442 | jne ppp_004 |
||
443 | |||
444 | mov al, [rx_str + 4] |
||
445 | cmp al, REQ |
||
446 | jne ppp_003b |
||
447 | |||
448 | ; Debugging output to debug board |
||
449 | pusha |
||
450 | mov esi, RX_LCP_REQ |
||
451 | call debug_output |
||
452 | popa |
||
453 | |||
454 | mov eax, [state] |
||
455 | and eax, 0xfd |
||
456 | mov [state], eax |
||
457 | |||
458 | mov ebx, 0xc6 |
||
459 | push eax |
||
460 | call TestOptions |
||
461 | pop eax |
||
462 | cmp edx, 0 |
||
463 | jz ppp_003g |
||
464 | |||
465 | cmp edx, 1 |
||
466 | jle ppp_003h |
||
467 | |||
468 | mov edx, PPP_ACK |
||
469 | cmp eax, 3 |
||
470 | jge ppp_003i |
||
471 | |||
472 | or eax, 0x02 |
||
473 | mov [state], eax |
||
474 | jmp ppp_003i |
||
475 | |||
476 | ppp_003h: |
||
477 | mov bl, 0xc0 |
||
478 | mov [rx_str + 10], bl |
||
479 | mov edx, PPP_NAK |
||
480 | jmp ppp_003i |
||
481 | |||
482 | ppp_003g: |
||
483 | mov edx, REJ |
||
484 | |||
485 | ppp_003i: |
||
486 | |||
487 | mov ebx, LCP |
||
488 | mov ecx, edx |
||
489 | movzx edx, byte [rx_str + 5] |
||
490 | mov esi, rx_str + 7 |
||
491 | call MakePacket |
||
492 | |||
493 | mov eax, 0 |
||
494 | call settimer |
||
495 | jmp ppp_003a |
||
496 | |||
497 | ppp_003b: |
||
498 | cmp al, PPP_ACK |
||
499 | jne ppp_003c |
||
500 | |||
501 | ; Debugging output to debug board |
||
502 | pusha |
||
503 | mov esi, RX_LCP_ACK |
||
504 | call debug_output |
||
505 | popa |
||
506 | |||
507 | mov eax, [number] |
||
508 | cmp al, [rx_str+5] |
||
509 | jne ppp_003a |
||
510 | |||
511 | mov eax, [state] |
||
512 | cmp eax, 3 |
||
513 | jge ppp_003a |
||
514 | or eax, 0x01 |
||
515 | mov [state], eax |
||
516 | jmp ppp_003a |
||
517 | |||
518 | ppp_003c: |
||
519 | cmp al, PPP_NAK |
||
520 | jne ppp_003d |
||
521 | |||
522 | ; Debugging output to debug board |
||
523 | pusha |
||
524 | mov esi, RX_LCP_NAK |
||
525 | call debug_output |
||
526 | popa |
||
527 | |||
528 | mov eax, [state] |
||
529 | and eax, 0xfe |
||
530 | mov [state], eax |
||
531 | jmp ppp_003a |
||
532 | |||
533 | ppp_003d: |
||
534 | cmp al, REJ |
||
535 | jne ppp_003e |
||
536 | |||
537 | ; Debugging output to debug board |
||
538 | pusha |
||
539 | mov esi, RX_LCP_REJ |
||
540 | call debug_output |
||
541 | popa |
||
542 | |||
543 | mov eax, [state] |
||
544 | and eax, 0xfe |
||
545 | mov [state], eax |
||
546 | jmp ppp_003a |
||
547 | |||
548 | ppp_003e: |
||
549 | cmp al, TERM |
||
550 | jne ppp_003j |
||
551 | jmp ppp_003a |
||
552 | |||
553 | ppp_003j: |
||
554 | cmp al, LCP_ECHO_REQ |
||
555 | jne ppp_003a |
||
556 | |||
557 | ; Debugging output to debug board |
||
558 | pusha |
||
559 | mov esi, RX_LCP_ECHO_REQ |
||
560 | call debug_output |
||
561 | popa |
||
562 | |||
563 | mov al, 0 |
||
564 | mov [rx_str+8],al |
||
565 | mov [rx_str+9],al |
||
566 | mov [rx_str+10],al |
||
567 | mov [rx_str+11],al |
||
568 | |||
569 | mov ebx, LCP |
||
570 | mov ecx, LCP_ECHO_REP |
||
571 | movzx edx, byte [rx_str + 5] |
||
572 | mov esi, rx_str + 7 |
||
573 | call MakePacket |
||
574 | |||
575 | ppp_003a: |
||
576 | mov eax, [state] |
||
577 | cmp eax, 3 |
||
578 | jne ppp_013 |
||
579 | |||
580 | mov eax, 4 |
||
581 | mov [state], eax |
||
582 | |||
583 | jmp ppp_013 |
||
584 | |||
585 | |||
586 | ppp_004: |
||
587 | cmp eax, PAP |
||
588 | jne ppp_005 |
||
589 | |||
590 | mov al, [rx_str + 4] |
||
591 | cmp al, PPP_ACK |
||
592 | jne ppp_013 |
||
593 | |||
594 | ; Debugging output to debug board |
||
595 | pusha |
||
596 | mov esi, RX_PAP_ACK |
||
597 | call debug_output |
||
598 | popa |
||
599 | |||
600 | mov eax, 5 |
||
601 | mov [state],eax |
||
602 | jmp ppp_013 |
||
603 | |||
604 | ppp_005: |
||
605 | cmp eax, IPCP |
||
606 | jne ppp_006 |
||
607 | |||
608 | mov al, [rx_str + 4] |
||
609 | cmp al, REQ |
||
610 | jne ppp_005a |
||
611 | |||
612 | ; Debugging output to debug board |
||
613 | pusha |
||
614 | mov esi, RX_IPCP_REQ |
||
615 | call debug_output |
||
616 | popa |
||
617 | |||
618 | mov ebx, 0x04 |
||
619 | call TestOptions |
||
620 | cmp edx, 0 |
||
621 | jz ppp_005b |
||
622 | mov ecx, PPP_ACK |
||
623 | mov eax, 6 |
||
624 | mov [state], eax |
||
625 | jmp ppp_005c |
||
626 | ppp_005b: |
||
627 | mov ecx, REJ |
||
628 | |||
629 | ppp_005c: |
||
630 | mov ebx, IPCP |
||
631 | movzx edx, byte [rx_str + 5] |
||
632 | mov esi, rx_str + 7 |
||
633 | call MakePacket |
||
634 | jmp ppp_013 |
||
635 | |||
636 | ppp_005a: |
||
637 | cmp al, PPP_ACK |
||
638 | jne ppp_005d |
||
639 | |||
640 | ; Debugging output to debug board |
||
641 | pusha |
||
642 | mov esi, RX_IPCP_ACK |
||
643 | call debug_output |
||
644 | popa |
||
645 | |||
646 | mov al, [rx_str + 5] |
||
647 | mov ecx, [number] |
||
648 | cmp al, cl |
||
649 | jne ppp_013 |
||
650 | |||
651 | mov eax, 7 |
||
652 | mov [state], eax |
||
653 | mov eax, 5800 |
||
654 | call settimer |
||
655 | |||
656 | mov eax, IPOnp |
||
657 | mov [prompt], eax ; set up prompt to display |
||
658 | mov al,[IPOnp_len] |
||
659 | mov [prompt_len], al |
||
660 | call draw_window |
||
661 | |||
662 | jmp ppp_013 |
||
663 | |||
664 | ppp_005d: |
||
665 | cmp al, PPP_NAK |
||
666 | jne ppp_005e |
||
667 | |||
668 | ; Debugging output to debug board |
||
669 | pusha |
||
670 | mov esi, RX_IPCP_NAK |
||
671 | call debug_output |
||
672 | popa |
||
673 | |||
674 | mov al, [rx_str + 10] |
||
675 | mov [addr1], al |
||
676 | mov al, [rx_str + 11] |
||
677 | mov [addr2], al |
||
678 | mov al, [rx_str + 12] |
||
679 | mov [addr3], al |
||
680 | mov al, [rx_str + 13] |
||
681 | mov [addr4], al |
||
682 | |||
683 | pusha |
||
684 | call draw_window |
||
685 | |||
686 | mov eax,52 |
||
687 | mov ebx,3 |
||
688 | mov cl, [addr4] |
||
689 | shl ecx, 8 |
||
690 | mov cl, [addr3] |
||
691 | shl ecx, 8 |
||
692 | mov cl, [addr2] |
||
693 | shl ecx, 8 |
||
694 | mov cl, [addr1] |
||
485 | heavyiron | 695 | mcall ; Set the stacks IP address |
31 | halyavin | 696 | |
697 | popa |
||
698 | |||
699 | mov ebx, IPCP ;; added 28/4/03 |
||
700 | mov ecx, REQ |
||
701 | movzx edx, byte [rx_str + 5] |
||
702 | mov esi, rx_str + 7 |
||
703 | call MakePacket |
||
704 | jmp ppp_013 |
||
705 | |||
706 | ppp_005e: |
||
707 | cmp al, REJ |
||
708 | jne ppp_005f |
||
709 | jmp ppp_013 |
||
710 | |||
711 | ppp_005f: |
||
712 | cmp al, TERM |
||
713 | jne ppp_013 |
||
714 | jmp ppp_013 |
||
715 | |||
716 | ppp_006: |
||
717 | cmp eax, IP |
||
718 | jne ppp_007 |
||
719 | |||
720 | |||
721 | ;; |
||
722 | ;; |
||
723 | ;; |
||
724 | ;; This is where we will pass the IP packet up to the stack |
||
725 | ;; |
||
726 | ;; |
||
727 | ;; |
||
728 | mov eax, 52 |
||
729 | mov ebx, 6 |
||
730 | mov edx, 1500 ; this should be exact amount |
||
731 | mov esi, rx_str + 4 |
||
485 | heavyiron | 732 | mcall |
31 | halyavin | 733 | |
734 | ; Debugging output to debug board |
||
735 | pusha |
||
736 | mov esi, RX_IP |
||
737 | call debug_output |
||
738 | popa |
||
739 | |||
740 | jmp ppp_013 |
||
741 | |||
742 | ppp_007: |
||
743 | cmp eax, CCP |
||
744 | jne ppp_008 |
||
745 | |||
746 | mov al, [rx_str + 4] |
||
747 | cmp al, REQ |
||
748 | jne ppp_013 |
||
749 | |||
750 | ; Debugging output to debug board |
||
751 | pusha |
||
752 | mov esi, RX_CCP_REQ |
||
753 | call debug_output |
||
754 | popa |
||
755 | |||
756 | mov ebx, 0x04 |
||
757 | call TestOptions |
||
758 | cmp edx, 0 |
||
759 | jz ppp_007b |
||
760 | mov ecx, PPP_ACK |
||
761 | jmp ppp_007c |
||
762 | ppp_007b: |
||
763 | mov ecx, REJ |
||
764 | |||
765 | ppp_007c: |
||
766 | mov ebx, CCP |
||
767 | movzx edx, byte [rx_str + 5] |
||
768 | mov esi, rx_str + 7 |
||
769 | call MakePacket |
||
770 | |||
771 | jmp ppp_013 |
||
772 | |||
773 | ppp_008: |
||
774 | cmp eax, 0 |
||
775 | jz ppp_009 |
||
776 | |||
777 | jmp ppp_013 |
||
778 | |||
779 | ppp_009: |
||
780 | mov eax, [tx_end] |
||
781 | cmp eax, 0 |
||
782 | jnz ppp_010 |
||
783 | call gettimer |
||
784 | cmp eax, 100 |
||
785 | jle ppp_010 |
||
786 | |||
787 | mov eax, [state] |
||
788 | cmp eax, 0 |
||
789 | je ppp_009a |
||
790 | cmp eax, 2 |
||
791 | jne ppp_010 |
||
792 | |||
793 | ppp_009a: |
||
794 | |||
795 | ; Debugging output to debug board |
||
796 | pusha |
||
797 | mov esi, TX_LCP_REQ |
||
798 | call debug_output |
||
799 | popa |
||
800 | |||
801 | inc [number] |
||
802 | mov eax, 0 |
||
803 | call settimer |
||
804 | |||
805 | mov ebx, LCP |
||
806 | mov ecx, REQ |
||
807 | mov edx, [number] |
||
808 | mov esi, LCPREQStr |
||
809 | call MakePacket |
||
810 | |||
811 | jmp ppp_013 |
||
812 | |||
813 | ppp_010: |
||
814 | mov eax, [tx_end] |
||
815 | cmp eax, 0 |
||
816 | jnz ppp_011 |
||
817 | call gettimer |
||
818 | cmp eax, 100 |
||
819 | jle ppp_011 |
||
820 | mov eax, [state] |
||
821 | cmp eax, 4 |
||
822 | jne ppp_011 |
||
823 | mov eax, 0 |
||
824 | call settimer |
||
825 | inc [number] |
||
826 | |||
827 | ; Debugging output to debug board |
||
828 | pusha |
||
829 | mov esi, TX_PAP_REQ |
||
830 | call debug_output |
||
831 | popa |
||
832 | |||
833 | mov ebx, PAP |
||
834 | mov ecx, REQ |
||
835 | mov edx, [number] |
||
836 | mov esi, PAPREQStr |
||
837 | call MakePacket |
||
838 | |||
839 | jmp ppp_013 |
||
840 | |||
841 | ppp_011: |
||
842 | mov eax, [tx_end] |
||
843 | cmp eax, 0 |
||
844 | jnz ppp_012 |
||
845 | call gettimer |
||
846 | cmp eax, 100 |
||
847 | jle ppp_012 |
||
848 | mov eax, [state] |
||
849 | cmp eax, 6 |
||
850 | jne ppp_012 |
||
851 | inc [number] |
||
852 | mov eax, 0 |
||
853 | call settimer |
||
854 | |||
855 | ; Debugging output to debug board |
||
856 | pusha |
||
857 | mov esi, TX_IPCP_REQ |
||
858 | call debug_output |
||
859 | popa |
||
860 | |||
861 | mov ebx, IPCP |
||
862 | mov ecx, REQ |
||
863 | mov edx, [number] |
||
864 | mov esi, IPCPREQStr |
||
865 | call MakePacket |
||
866 | |||
867 | jmp ppp_013 |
||
868 | |||
869 | ppp_012: |
||
870 | mov eax, [tx_end] |
||
871 | cmp eax, 0 |
||
872 | jnz ppp_013 |
||
873 | mov eax, [state] |
||
874 | cmp eax, 7 |
||
875 | jne ppp_013 |
||
876 | |||
877 | ; 10ms Delay suggested by Ville |
||
878 | mov eax,23 ; over here |
||
879 | mov ebx,1 |
||
485 | heavyiron | 880 | mcall |
31 | halyavin | 881 | |
882 | |||
883 | |||
884 | call gettimer |
||
885 | cmp eax, 200 |
||
886 | jle ppp_012a |
||
887 | |||
888 | ; every 2s, when things are quiet, redraw window |
||
889 | call draw_window_limited |
||
890 | |||
891 | mov eax, 0 |
||
892 | call settimer |
||
893 | |||
894 | ppp_012a: |
||
895 | |||
896 | mov eax, 52 |
||
897 | mov ebx, 8 |
||
898 | mov esi, ip_buff |
||
485 | heavyiron | 899 | mcall |
31 | halyavin | 900 | |
901 | cmp eax, 0 |
||
902 | je ppp_013 |
||
903 | |||
904 | call MakeIPPacket |
||
905 | |||
906 | ; Debugging output to debug board |
||
907 | pusha |
||
908 | mov esi, TX_IP |
||
909 | call debug_output |
||
910 | popa |
||
911 | |||
912 | ppp_013: |
||
913 | mov eax, [packet] |
||
914 | cmp eax, 0 |
||
915 | jz PPPLoop |
||
916 | |||
917 | mov eax, 0 |
||
918 | mov [packet], eax |
||
919 | |||
920 | mov edi, rx_str |
||
921 | mov ecx, MaxRx + 1 |
||
922 | rep stosb |
||
923 | jmp PPPLoop |
||
924 | |||
925 | |||
926 | |||
927 | ;**************************************************************************** |
||
928 | ; Function |
||
929 | ; calc |
||
930 | ; |
||
931 | ; Description |
||
932 | ; Adds a character to the CRC checksum |
||
933 | ; byte in lsb of eax |
||
934 | ; |
||
935 | ; |
||
936 | ;**************************************************************************** |
||
937 | calc: |
||
938 | and eax, 0xFF |
||
939 | push ecx |
||
940 | mov ecx, 8 |
||
941 | calc_001: |
||
942 | test al, 0x01 |
||
943 | jz calc_002 |
||
944 | shr eax, 1 |
||
945 | xor eax, 0x8408 |
||
946 | and eax, 0xffff |
||
947 | jmp calc_003 |
||
948 | calc_002: |
||
949 | shr eax, 1 |
||
950 | calc_003: |
||
951 | loop calc_001 |
||
952 | pop ecx |
||
953 | ret |
||
954 | |||
955 | |||
956 | ;**************************************************************************** |
||
957 | ; Function |
||
958 | ; add2tx |
||
959 | ; |
||
960 | ; Description |
||
961 | ; Adds a character into the tx buffer |
||
962 | ; byte in low byte of eax |
||
963 | ; |
||
964 | ; |
||
965 | ;**************************************************************************** |
||
966 | add2tx: |
||
967 | pusha |
||
968 | mov esi, tx_str |
||
969 | add esi, [tx_ptr] |
||
970 | inc [tx_ptr] |
||
971 | mov [esi], al ; Save byte in buffer |
||
972 | mov ecx, [checksum2] |
||
973 | and eax, 0xff |
||
974 | xor eax, ecx |
||
975 | call calc |
||
976 | shr ecx, 8 |
||
977 | and ecx, 0xff |
||
978 | xor eax, ecx |
||
979 | mov [checksum2], eax |
||
980 | popa |
||
981 | ret |
||
982 | |||
983 | |||
984 | |||
985 | ;**************************************************************************** |
||
986 | ; Function |
||
987 | ; MakeIPPacket |
||
988 | ; |
||
989 | ; Description |
||
990 | ; Creates a PPP packet for transmission to the host from the |
||
991 | ; IP packet extracted from the stack |
||
992 | ; |
||
993 | ; IP data is in ip_buff |
||
994 | ; |
||
995 | ;**************************************************************************** |
||
996 | MakeIPPacket: |
||
997 | mov [tx_ptr], dword 1 |
||
998 | mov edi, tx_str |
||
999 | mov [edi], byte ' ' |
||
1000 | mov eax, 0xffff |
||
1001 | mov [checksum2], eax |
||
1002 | mov al, 0xff |
||
1003 | call add2tx |
||
1004 | mov al, 3 |
||
1005 | call add2tx |
||
1006 | mov al, IP / 256 |
||
1007 | call add2tx |
||
1008 | mov al, IP |
||
1009 | call add2tx |
||
1010 | |||
1011 | movzx ecx, byte [ip_buff + 3] |
||
1012 | mov ch, byte [ip_buff + 2] |
||
1013 | |||
1014 | mov esi, ip_buff |
||
1015 | |||
1016 | mip001: |
||
1017 | mov al, byte [esi] |
||
1018 | call add2tx |
||
1019 | inc esi |
||
1020 | loop mip001 |
||
1021 | |||
1022 | mov eax, [checksum2] |
||
1023 | not eax |
||
1024 | call add2tx |
||
1025 | shr eax, 8 |
||
1026 | call add2tx |
||
1027 | |||
1028 | mov eax, [tx_ptr] |
||
1029 | mov [tx_end], eax |
||
1030 | xor eax, eax |
||
1031 | mov [tx_ptr], eax |
||
1032 | ret |
||
1033 | |||
1034 | |||
1035 | ;**************************************************************************** |
||
1036 | ; Function |
||
1037 | ; MakePacket |
||
1038 | ; |
||
1039 | ; Description |
||
1040 | ; Creates a PPP packet for transmission to the host |
||
1041 | ; |
||
1042 | ; Packet type in ebx |
||
1043 | ; Code is in ecx |
||
1044 | ; num is in edx |
||
1045 | ; str is pointed to by esi |
||
1046 | ; |
||
1047 | ;**************************************************************************** |
||
1048 | MakePacket: |
||
1049 | mov [tx_ptr], dword 1 |
||
1050 | mov edi, tx_str |
||
1051 | mov [edi], byte ' ' |
||
1052 | mov eax, 0xffff |
||
1053 | mov [checksum2], eax |
||
1054 | mov al, 0xff |
||
1055 | call add2tx |
||
1056 | mov al, 3 |
||
1057 | call add2tx |
||
1058 | mov al, bh ; packet/256 |
||
1059 | call add2tx |
||
1060 | mov al, bl ; packet&255 |
||
1061 | call add2tx |
||
1062 | |||
1063 | cmp ebx, IP ; is packet type IP? |
||
1064 | jne mp_001 ; No - its a lower layer packet |
||
1065 | |||
1066 | ; Do IP packet assembly |
||
1067 | |||
1068 | jmp mp_002 |
||
1069 | |||
1070 | mp_001: |
||
1071 | ; Do PPP layer packet assembly |
||
1072 | mov al, cl |
||
1073 | call add2tx |
||
1074 | mov al, dl |
||
1075 | call add2tx |
||
1076 | mov al, 0 |
||
1077 | call add2tx |
||
1078 | |||
1079 | movzx ecx, byte [esi] ; length = *str - 3 |
||
1080 | sub ecx, 3 |
||
1081 | |||
1082 | mp_002: ; Now copy the data acros |
||
1083 | mov al, byte [esi] |
||
1084 | call add2tx |
||
1085 | inc esi |
||
1086 | loop mp_002 |
||
1087 | |||
1088 | mov eax, [checksum2] |
||
1089 | not eax |
||
1090 | call add2tx |
||
1091 | shr eax, 8 |
||
1092 | call add2tx |
||
1093 | |||
1094 | mov eax, [tx_ptr] |
||
1095 | mov [tx_end], eax |
||
1096 | xor eax, eax |
||
1097 | mov [tx_ptr], eax |
||
1098 | ret |
||
1099 | |||
1100 | |||
1101 | ;**************************************************************************** |
||
1102 | ; Function |
||
1103 | ; TestOptions |
||
1104 | ; |
||
1105 | ; Description |
||
1106 | ; Test a PPP packets options fields for valid entries |
||
1107 | ; |
||
1108 | ; option ebx |
||
1109 | ; |
||
1110 | ; Returns result in edx, but may also modify rx_str |
||
1111 | ; |
||
1112 | ;**************************************************************************** |
||
1113 | TestOptions: |
||
1114 | mov esi, 8 ; ptr1 |
||
1115 | mov edi, 8 ; ptr2 |
||
1116 | mov edx, 3 ; edx is the return value |
||
1117 | movzx ecx, byte [rx_str + 7] |
||
1118 | add ecx, 4 ; ecx is size |
||
1119 | cmp ecx, MaxRx |
||
1120 | jle to_001 |
||
1121 | mov ecx, MaxRx |
||
1122 | to_001: |
||
1123 | cmp esi, ecx |
||
1124 | jge to_002 |
||
1125 | mov al, byte [esi + rx_str] |
||
1126 | cmp al, 3 |
||
1127 | jne to_001a |
||
1128 | mov al, byte [esi + rx_str + 2] |
||
1129 | cmp al, 0x80 |
||
1130 | je to_001a |
||
1131 | ; bug fix for chap authenticate reject below |
||
1132 | mov al, byte [esi + rx_str + 2] |
||
1133 | cmp al, 0xc2 |
||
1134 | jne to_001a |
||
1135 | and edx, 0xfd |
||
1136 | to_001a: |
||
1137 | push ecx |
||
1138 | mov cl, [esi + rx_str] |
||
1139 | dec cl |
||
1140 | mov eax, 1 |
||
1141 | shl eax, cl |
||
1142 | and eax, ebx |
||
1143 | and eax, 0xffff |
||
1144 | pop ecx |
||
1145 | cmp eax, 0 |
||
1146 | jnz to_001b |
||
1147 | xor edx,edx |
||
1148 | to_001b: |
||
1149 | movzx eax, byte [esi+rx_str+1] |
||
1150 | add esi, eax |
||
1151 | jmp to_001 |
||
1152 | to_002: |
||
1153 | ; if (!(pass&2))... |
||
1154 | test edx, 2 |
||
1155 | jnz to_exit |
||
1156 | test edx, 1 |
||
1157 | jz to_002a |
||
1158 | mov ebx, 0xFFFB |
||
1159 | to_002a: |
||
1160 | mov esi, 8 |
||
1161 | to_002b: ; for loop |
||
1162 | cmp esi, ecx |
||
1163 | jge to_003 |
||
1164 | |||
1165 | push ecx |
||
1166 | mov cl, [esi + rx_str] |
||
1167 | dec cl |
||
1168 | mov eax, 1 |
||
1169 | shl eax, cl |
||
1170 | and eax, ebx |
||
1171 | and eax, 0xffff |
||
1172 | pop ecx |
||
1173 | cmp eax, 0 |
||
1174 | jnz to_002c |
||
1175 | movzx edx, byte [esi+rx_str+1] |
||
1176 | to_002d: |
||
1177 | cmp esi, ecx |
||
1178 | jge to_002b |
||
1179 | cmp edx, 0 |
||
1180 | jz to_002b |
||
1181 | mov al, [esi + rx_str] |
||
1182 | mov [edi + rx_str], al |
||
1183 | inc esi |
||
1184 | inc edi |
||
1185 | dec edx |
||
1186 | jmp to_002d |
||
1187 | to_002c: |
||
1188 | movzx eax, byte [esi+rx_str+1] |
||
1189 | add esi, eax |
||
1190 | jmp to_002b ; end of for loop |
||
1191 | to_003: |
||
1192 | mov eax, edi |
||
1193 | sub al, 4 |
||
1194 | mov [rx_str+7], al |
||
1195 | xor edx, edx |
||
1196 | cmp ebx, 0xfffb |
||
1197 | jne to_exit |
||
1198 | inc edx |
||
1199 | to_exit: |
||
1200 | ; Return value in EDX |
||
1201 | ret |
||
1202 | |||
1203 | |||
1204 | |||
1205 | ;*************************************************************************** |
||
1206 | ; Function |
||
1207 | ; disable_port |
||
1208 | ; |
||
1209 | ; Description; |
||
1210 | ; Releases this applications use of the com port |
||
1211 | ; |
||
1212 | ;*************************************************************************** |
||
1213 | disable_port: |
||
1214 | if DEBUG_PORT2_OUTPUT = TRUE |
||
1215 | mov eax, 46 ; free port area |
||
1216 | mov ebx, 1 |
||
1217 | |||
1218 | mov ecx, 0x2f8 |
||
1219 | and ecx, 0xFF0 |
||
1220 | mov edx, ecx |
||
1221 | or edx, 0x00F |
||
485 | heavyiron | 1222 | mcall |
31 | halyavin | 1223 | end if |
1224 | |||
1225 | mov eax, 45 ; free irq 4 |
||
1226 | mov ebx, 1 |
||
1227 | mov ecx, [comirq] |
||
485 | heavyiron | 1228 | mcall |
31 | halyavin | 1229 | |
1230 | mov eax, 46 ; free port area |
||
1231 | mov ebx, 1 |
||
1232 | |||
1233 | mov ecx, [comport] |
||
1234 | and ecx, 0xFF0 |
||
1235 | mov edx, ecx |
||
1236 | or edx, 0x00F |
||
485 | heavyiron | 1237 | mcall |
31 | halyavin | 1238 | ret |
1239 | |||
1240 | |||
1241 | |||
1242 | ;*************************************************************************** |
||
1243 | ; Function |
||
1244 | ; enable_port |
||
1245 | ; |
||
1246 | ; Description; |
||
1247 | ; Takes control of the com port, defining the IRQ table and initialising |
||
1248 | ; the uart chip. |
||
1249 | ; |
||
1250 | ;*************************************************************************** |
||
1251 | enable_port: |
||
1252 | pusha |
||
1253 | if DEBUG_PORT2_OUTPUT = TRUE |
||
1254 | mov eax, 46 |
||
1255 | mov ebx, 0 |
||
1256 | mov ecx, 0x2f8 |
||
1257 | and ecx, 0xFF0 |
||
1258 | mov edx, ecx |
||
1259 | or edx, 0x00F |
||
485 | heavyiron | 1260 | mcall ; reseve port memory to this process |
31 | halyavin | 1261 | |
1262 | mov eax, 45 ; reserve irq 3 |
||
1263 | mov ebx, 0 |
||
1264 | mov ecx, 3 |
||
485 | heavyiron | 1265 | mcall |
31 | halyavin | 1266 | |
1267 | |||
1268 | mov ecx, 0x2f8 ; data format register |
||
1269 | add ecx, 3 |
||
1270 | mov bl, 0x80 ; enable access to divisor latch |
||
1271 | mov eax, 43 ; send data to device - com port setup |
||
485 | heavyiron | 1272 | mcall |
31 | halyavin | 1273 | |
1274 | mov ecx, 0x2f8 ; interrupt enable register |
||
1275 | inc ecx |
||
1276 | mov bl, 0 ; No interruts enabled |
||
1277 | mov eax, 43 ; send data to device (modem) |
||
485 | heavyiron | 1278 | mcall |
31 | halyavin | 1279 | |
1280 | mov ecx, 0x2f8 ; Divisor latch LSB |
||
1281 | mov bl, BAUDRATE ; set baud rate |
||
1282 | mov eax, 43 ; send data to device (modem) |
||
485 | heavyiron | 1283 | mcall |
31 | halyavin | 1284 | |
1285 | mov ecx, 0x2f8 ; Data format register |
||
1286 | add ecx, 3 |
||
1287 | mov bl, 3 ; 8 data bits |
||
1288 | mov eax, 43 ; send data to device (modem) |
||
485 | heavyiron | 1289 | mcall |
31 | halyavin | 1290 | |
1291 | mov ecx, 0x2f8 ; Modem control register |
||
1292 | add ecx, 4 ; ** bl must be 0x0b for modem to dial! |
||
1293 | mov bl, 0x0b ; 0x08 -> out2 enabled. No handshaking. |
||
1294 | ; 0xb -> out2 enabled, RTS/DTR enabled |
||
1295 | mov eax, 43 ; send data to device (modem) |
||
485 | heavyiron | 1296 | mcall |
31 | halyavin | 1297 | |
1298 | ; mov ecx, 0x2f8 ; interrupt enable register |
||
1299 | ; inc ecx |
||
1300 | ; mov bl, 1 ; rx data interrupt enabled, othrs not |
||
1301 | ; mov eax, 43 ; send data to device (modem) |
||
485 | heavyiron | 1302 | ; mcall |
31 | halyavin | 1303 | |
1304 | end if |
||
1305 | |||
1306 | mov eax, 46 |
||
1307 | mov ebx, 0 |
||
1308 | mov ecx, [comport] |
||
1309 | and ecx, 0xFF0 |
||
1310 | mov edx, ecx |
||
1311 | or edx, 0x00F |
||
485 | heavyiron | 1312 | mcall ; reseve port memory to this process |
31 | halyavin | 1313 | |
1314 | mov eax, 45 ; reserve irq 4 |
||
1315 | mov ebx, 0 |
||
1316 | mov ecx, [comirq] |
||
485 | heavyiron | 1317 | mcall |
31 | halyavin | 1318 | |
1319 | mov eax, 44 ; setup irq table |
||
1320 | mov ebx, irqtable |
||
1321 | mov ecx, [comirq] |
||
485 | heavyiron | 1322 | mcall |
31 | halyavin | 1323 | |
1324 | mov ecx, [comport] ; data format register |
||
1325 | add ecx, 3 |
||
1326 | mov bl, 0x80 ; enable access to divisor latch |
||
1327 | mov eax, 43 ; send data to device - com port setup |
||
485 | heavyiron | 1328 | mcall |
31 | halyavin | 1329 | |
1330 | mov ecx, [comport] ; interrupt enable register |
||
1331 | inc ecx |
||
1332 | mov bl, 0 ; No interruts enabled |
||
1333 | mov eax, 43 ; send data to device (modem) |
||
485 | heavyiron | 1334 | mcall |
31 | halyavin | 1335 | |
1336 | mov ecx, [comport] ; Divisor latch LSB |
||
1337 | mov bl, BAUDRATE ; set baud rate |
||
1338 | mov eax, 43 ; send data to device (modem) |
||
485 | heavyiron | 1339 | mcall |
31 | halyavin | 1340 | |
1341 | mov ecx, [comport] ; Data format register |
||
1342 | add ecx, 3 |
||
1343 | mov bl, 3 ; 8 data bits |
||
1344 | mov eax, 43 ; send data to device (modem) |
||
485 | heavyiron | 1345 | mcall |
31 | halyavin | 1346 | |
1347 | mov ecx, [comport] ; Modem control register |
||
1348 | add ecx, 4 ; ** bl must be 0x0b for modem to dial! |
||
1349 | mov bl, 0x0b ; 0x08 -> out2 enabled. No handshaking. |
||
1350 | ; 0xb -> out2 enabled, RTS/DTR enabled |
||
1351 | mov eax, 43 ; send data to device (modem) |
||
485 | heavyiron | 1352 | mcall |
31 | halyavin | 1353 | |
1354 | mov ecx, [comport] ; interrupt enable register |
||
1355 | inc ecx |
||
1356 | mov bl, 1 ; rx data interrupt enabled, othrs not |
||
1357 | mov eax, 43 ; send data to device (modem) |
||
485 | heavyiron | 1358 | mcall |
31 | halyavin | 1359 | |
1360 | mov ecx, [comirq] |
||
1361 | add ecx, 16 |
||
1362 | mov ebx, 1 |
||
1363 | shl ebx, cl |
||
1364 | add ebx, 111b |
||
1365 | mov eax,40 ; enable irq 4 data |
||
485 | heavyiron | 1366 | mcall |
31 | halyavin | 1367 | |
1368 | popa |
||
1369 | ret |
||
1370 | |||
1371 | |||
1372 | |||
1373 | ;************************************************************************** |
||
1374 | ; Function |
||
1375 | ; draw_window |
||
1376 | ; |
||
1377 | ; Description; |
||
1378 | ; Normal window definition and text layout for application |
||
1379 | ;************************************************************************** |
||
1380 | draw_window: |
||
1381 | mov eax, 12 ; function 12:tell os about windowdraw |
||
1382 | mov ebx, 1 ; 1, start of draw |
||
485 | heavyiron | 1383 | mcall |
31 | halyavin | 1384 | ; DRAW WINDOW |
1385 | mov eax, 0 ; function 0 : define and draw window |
||
1386 | mov ebx, 100*65536+250 ; [x start] *65536 + [x size] |
||
1387 | mov ecx, 100*65536+150 ; [y start] *65536 + [y size] |
||
551 | spraid | 1388 | mov edx,0x14224466 ; color of work area RRGGBB |
485 | heavyiron | 1389 | mov edi,title ; color of frames RRGGBB |
1390 | mcall |
||
1391 | |||
31 | halyavin | 1392 | ; DIAL BUTTON |
1393 | mov eax, 8 ; function 8 : define and draw button |
||
1394 | mov ebx, (50)*65536+40 ; [x start] *65536 + [x size] |
||
1395 | mov ecx, 130*65536+12 ; [y start] *65536 + [y size] |
||
1396 | mov edx, 2 ; button id |
||
1397 | mov esi, 0x5599cc ; button color RRGGBB |
||
485 | heavyiron | 1398 | mcall |
31 | halyavin | 1399 | |
1400 | mov ebx, 55*65536+133 ; Draw button text |
||
1401 | mov ecx, 0x00FFFFFF |
||
1402 | mov edx, button1_text |
||
1403 | xor eax, eax |
||
1404 | mov al, [button1_text_len] |
||
1405 | mov esi, eax |
||
1406 | mov eax, 4 |
||
485 | heavyiron | 1407 | mcall |
31 | halyavin | 1408 | ; DISCONNECT BUTTON |
1409 | mov eax, 8 ; function 8 : define and draw button |
||
1410 | mov ebx, (150)*65536+65 ; [x start] *65536 + [x size] |
||
1411 | mov ecx, 130*65536+12 ; [y start] *65536 + [y size] |
||
1412 | mov edx, 3 ; button id |
||
1413 | mov esi, 0x5599cc ; button color RRGGBB |
||
485 | heavyiron | 1414 | mcall |
31 | halyavin | 1415 | |
1416 | mov ebx, 155*65536+133 ; Draw button text |
||
1417 | mov ecx, 0x00FFFFFF |
||
1418 | mov edx, button3_text |
||
1419 | xor eax, eax |
||
1420 | mov al, [button3_text_len] |
||
1421 | mov esi, eax |
||
1422 | mov eax, 4 |
||
485 | heavyiron | 1423 | mcall |
31 | halyavin | 1424 | |
1425 | mov ebx, 5*65536+40 ; draw info text with function 4 |
||
1426 | mov ecx, 0x00FFFFFF |
||
1427 | mov edx, [prompt] |
||
1428 | xor eax, eax |
||
1429 | mov al, [prompt_len] |
||
1430 | mov esi, eax |
||
1431 | mov eax, 4 |
||
485 | heavyiron | 1432 | mcall |
31 | halyavin | 1433 | |
1434 | ; Draw IP address |
||
1435 | mov edx, 10*65536+60 |
||
1436 | mov esi, 0x00FFFFFF |
||
1437 | mov ebx, 0x00030000 |
||
1438 | movzx ecx, byte [addr1] |
||
1439 | mov eax, 47 |
||
485 | heavyiron | 1440 | mcall |
31 | halyavin | 1441 | mov edx, 31*65536+60 |
1442 | mov esi, 0x00FFFFFF |
||
1443 | mov ebx, 0x00030000 |
||
1444 | movzx ecx, byte [addr2] |
||
1445 | mov eax, 47 |
||
485 | heavyiron | 1446 | mcall |
31 | halyavin | 1447 | mov edx, 52*65536+60 |
1448 | mov esi, 0x00FFFFFF |
||
1449 | mov ebx, 0x00030000 |
||
1450 | movzx ecx, byte [addr3] |
||
1451 | mov eax, 47 |
||
485 | heavyiron | 1452 | mcall |
31 | halyavin | 1453 | mov edx, 73*65536+60 |
1454 | mov esi, 0x00FFFFFF |
||
1455 | mov ebx, 0x00030000 |
||
1456 | movzx ecx, byte [addr4] |
||
1457 | mov eax, 47 |
||
485 | heavyiron | 1458 | mcall |
31 | halyavin | 1459 | |
1460 | ; Status byte |
||
1461 | mov edx, 100*65536+60 |
||
1462 | mov esi, 0x00FFFFFF |
||
1463 | mov ebx, 0x00010000 |
||
1464 | movzx ecx, byte [state] |
||
1465 | mov eax, 47 |
||
485 | heavyiron | 1466 | mcall |
31 | halyavin | 1467 | |
1468 | ; bytes sent / received |
||
1469 | mov eax, 4 ; function 4 : write text to window |
||
1470 | mov ebx, 10*65536+80 ; [x start] *65536 + [y start] |
||
1471 | mov ecx, 0x00ffffff ; color of text RRGGBB |
||
1472 | mov edx, txmsg ; pointer to text beginning |
||
1473 | mov esi, txmsglen-txmsg ; text length |
||
485 | heavyiron | 1474 | mcall |
31 | halyavin | 1475 | |
1476 | mov eax, 4 ; function 4 : write text to window |
||
1477 | mov ebx, 10*65536+100 ; [x start] *65536 + [y start] |
||
1478 | mov ecx, 0x00ffffff ; color of text RRGGBB |
||
1479 | mov edx, rxmsg ; pointer to text beginning |
||
1480 | mov esi, rxmsglen-rxmsg ; text length |
||
485 | heavyiron | 1481 | mcall |
31 | halyavin | 1482 | |
1483 | call draw_window_limited |
||
1484 | |||
1485 | mov eax, 12 ; end of redraw |
||
1486 | mov ebx, 2 |
||
485 | heavyiron | 1487 | mcall |
31 | halyavin | 1488 | |
1489 | ret |
||
1490 | |||
1491 | |||
1492 | |||
1493 | draw_window_limited: |
||
1494 | mov eax,13 |
||
1495 | mov ebx,80*65536+10*6 |
||
1496 | mov ecx,80*65536+10 |
||
1497 | mov edx,0x03224466 |
||
485 | heavyiron | 1498 | mcall |
31 | halyavin | 1499 | mov ecx,100*65536+10 |
485 | heavyiron | 1500 | mcall |
31 | halyavin | 1501 | |
1502 | mov ebx, 0x000A0000 |
||
1503 | mov ecx, [txbytes] |
||
1504 | mov esi, 0x00ffffff ; color of text RRGGBB |
||
1505 | mov eax, 47 ; function 47 : write number to window |
||
1506 | mov edx, 80*65536+80 ; [x start] *65536 + [y start] |
||
485 | heavyiron | 1507 | mcall |
31 | halyavin | 1508 | |
1509 | mov ebx, 0x000A0000 |
||
1510 | mov ecx, [rxbytes] |
||
1511 | mov esi, 0x00ffffff ; color of text RRGGBB |
||
1512 | mov eax, 47 ; function 47 : write number to window |
||
1513 | mov edx, 80*65536+100 ; [x start] *65536 + [y start] |
||
485 | heavyiron | 1514 | mcall |
31 | halyavin | 1515 | ret |
1516 | |||
1517 | |||
1518 | ;**************************************************************************** |
||
1519 | ; Function |
||
1520 | ; settimer |
||
1521 | ; |
||
1522 | ; Description |
||
1523 | ; sets the general purpose timer to a given value in eax |
||
1524 | ; All times are in 1/100s |
||
1525 | ; |
||
1526 | ; |
||
1527 | ;**************************************************************************** |
||
1528 | settimer: |
||
1529 | push eax |
||
1530 | mov eax, 26 |
||
1531 | mov ebx, 9 |
||
485 | heavyiron | 1532 | mcall ; get 100th second counter |
31 | halyavin | 1533 | pop ebx |
1534 | sub eax, ebx ; This could have some funny side effecs if PPP |
||
1535 | ; called within ebx seconds of startup |
||
1536 | mov [timerValue], eax |
||
1537 | ret |
||
1538 | |||
1539 | |||
1540 | ;**************************************************************************** |
||
1541 | ; Function |
||
1542 | ; gettimer |
||
1543 | ; |
||
1544 | ; Description |
||
1545 | ; gets the general purpose timer count in eax |
||
1546 | ; All times are in 1/100s |
||
1547 | ; |
||
1548 | ; |
||
1549 | ;**************************************************************************** |
||
1550 | gettimer: |
||
1551 | mov eax, 26 |
||
1552 | mov ebx, 9 |
||
485 | heavyiron | 1553 | mcall ; get 100th second counter |
31 | halyavin | 1554 | |
1555 | sub eax, [timerValue] |
||
1556 | ret |
||
1557 | |||
1558 | |||
1559 | |||
1560 | |||
1561 | ;**************************************************************************** |
||
1562 | ; Function |
||
1563 | ; sendwait |
||
1564 | ; |
||
1565 | ; Description |
||
1566 | ; Sends a command string to the modem, then waits for a defined rsp |
||
1567 | ; |
||
1568 | ; esi points to string to wait for |
||
1569 | ; edi points to string to send |
||
1570 | ; edx holds wait time, in ms |
||
1571 | ; |
||
1572 | ; Returns 1 if OK or 0 if timeout occurred |
||
1573 | ; |
||
1574 | ;**************************************************************************** |
||
1575 | sendwait: |
||
1576 | mov [sendwaitTime], edx |
||
1577 | |||
1578 | ; Shrirang 2/5/03 |
||
1579 | mov byte [abortcnt], 0 ; reset the abort counter |
||
1580 | ;--! |
||
1581 | |||
1582 | ; Start the timer |
||
1583 | xor eax, eax |
||
1584 | call settimer |
||
1585 | |||
1586 | ; Check for incoming data |
||
1587 | |||
1588 | xor edx, edx |
||
1589 | xor eax, eax |
||
1590 | |||
1591 | sw_001: |
||
1592 | push eax |
||
1593 | push edx |
||
1594 | |||
1595 | ; Has connection timer expired? |
||
1596 | call gettimer |
||
1597 | cmp eax, [sendwaitTime] |
||
1598 | jl sw_000 |
||
1599 | |||
1600 | pop edx |
||
1601 | pop eax |
||
1602 | |||
1603 | xor eax, eax |
||
1604 | |||
1605 | jmp sw_exit ; Exit indicating an error ( timeout ) |
||
1606 | |||
1607 | sw_000: |
||
1608 | ; any data from modem? |
||
1609 | |||
1610 | mov eax,11 ; This will return 0 most of the time |
||
485 | heavyiron | 1611 | mcall |
31 | halyavin | 1612 | mov ecx, eax |
1613 | pop edx |
||
1614 | pop eax |
||
1615 | |||
1616 | |||
1617 | cmp ecx, 1 ; redraw request ? |
||
1618 | je red1 |
||
1619 | cmp ecx, 3 ; button in buffer ? |
||
1620 | je button1 |
||
1621 | mov ebx, [comirq] |
||
1622 | add ebx, 16 |
||
1623 | cmp ecx,ebx |
||
1624 | jne sw_002 |
||
1625 | jmp sw_000a |
||
1626 | |||
1627 | red1: |
||
1628 | pusha |
||
1629 | call draw_window |
||
1630 | popa |
||
1631 | push eax |
||
1632 | push edx |
||
1633 | |||
1634 | jmp sw_000 |
||
1635 | |||
1636 | button1: |
||
1637 | mov eax, 0 |
||
1638 | jmp sw_exit |
||
1639 | |||
1640 | sw_000a: |
||
1641 | ; there was data, so get it |
||
1642 | |||
1643 | push edx |
||
1644 | push eax |
||
1645 | mov eax,42 |
||
1646 | mov ebx, [comirq] |
||
485 | heavyiron | 1647 | mcall |
31 | halyavin | 1648 | pop eax |
1649 | pop edx |
||
1650 | |||
1651 | |||
1652 | ; Shrirang 2/5/03 |
||
1653 | ; Now that the expected response is not got we check if we |
||
1654 | ; got the abort part, before we reset the fsm |
||
1655 | |||
1656 | cmp bl, 0x0d ; AT commands normally start and end with \r\n |
||
1657 | je checkabort |
||
1658 | |||
1659 | cmp bl, 0x0a |
||
1660 | je checkabort |
||
1661 | |||
1662 | push eax |
||
1663 | xor eax, eax |
||
1664 | mov al, [abortcnt] |
||
1665 | mov byte [abortres+eax], bl ; update abort response |
||
1666 | inc byte [abortcnt] |
||
1667 | pop eax |
||
1668 | |||
1669 | jmp noabort |
||
1670 | |||
1671 | |||
1672 | checkabort : |
||
1673 | |||
1674 | cmp byte [abortcnt], 2 ; if we got valid abort this cannot happen! |
||
1675 | jbe noabortflush |
||
1676 | |||
1677 | push eax |
||
1678 | push esi |
||
1679 | push edi |
||
1680 | push ecx |
||
1681 | |||
1682 | mov esi, abortres |
||
1683 | mov edi, aborts |
||
1684 | xor ecx, ecx |
||
1685 | mov cl, byte [abortcnt] |
||
1686 | call scanaborts ; scan 'em |
||
1687 | |||
1688 | pop ecx |
||
1689 | pop edi |
||
1690 | pop esi |
||
1691 | |||
1692 | and eax, eax |
||
1693 | jz noabortdec |
||
1694 | |||
1695 | pop eax |
||
1696 | xor eax, eax |
||
1697 | jmp sw_exit |
||
1698 | |||
1699 | noabortdec: |
||
1700 | |||
1701 | pop eax |
||
1702 | |||
1703 | noabortflush: |
||
1704 | |||
1705 | mov byte [abortcnt], 0 |
||
1706 | |||
1707 | noabort: |
||
1708 | |||
1709 | ;--! |
||
1710 | |||
1711 | cmp [esi+edx], bl |
||
1712 | je sw_003 |
||
1713 | |||
1714 | |||
1715 | xor edx, edx |
||
1716 | |||
1717 | ; Added 28/4/03 |
||
1718 | cmp [esi+edx], bl |
||
1719 | je sw_003 |
||
1720 | |||
1721 | jmp sw_001 |
||
1722 | |||
1723 | sw_003: ; They are the same |
||
1724 | inc edx |
||
1725 | cmp [esi+edx], byte 0 |
||
1726 | jne sw_001 |
||
1727 | |||
1728 | |||
1729 | xor eax, eax |
||
1730 | inc eax |
||
1731 | jmp sw_exit |
||
1732 | |||
1733 | sw_002: |
||
1734 | ; Test for data to send to modem |
||
1735 | cmp [ edi + eax ], byte 0 |
||
1736 | je sw_001 |
||
1737 | |||
1738 | ; Is it a '|' character? |
||
1739 | cmp [ edi + eax ], byte '|' |
||
1740 | jne sw_004 |
||
1741 | |||
1742 | push eax |
||
1743 | call gettimer |
||
1744 | cmp eax, 100 |
||
1745 | pop eax |
||
1746 | jl sw_001 |
||
1747 | |||
1748 | ; restart the timer |
||
1749 | push eax |
||
1750 | xor eax, eax |
||
1751 | call settimer |
||
1752 | pop eax |
||
1753 | |||
1754 | ; Move to next character |
||
1755 | inc eax |
||
1756 | jmp sw_001 |
||
1757 | |||
1758 | |||
1759 | sw_004: |
||
1760 | push edx |
||
1761 | push eax |
||
1762 | |||
1763 | ; restart the timer |
||
1764 | xor eax, eax |
||
1765 | call settimer |
||
1766 | |||
1767 | ; Test for tx ready. |
||
1768 | ; OR, wait then send |
||
1769 | push edi |
||
1770 | mov eax, 5 |
||
1771 | mov ebx, 1 |
||
485 | heavyiron | 1772 | mcall ; 10ms delay |
31 | halyavin | 1773 | pop edi |
1774 | |||
1775 | ; send the character |
||
1776 | pop eax |
||
1777 | mov bl, [edi + eax] |
||
1778 | |||
1779 | mov ecx, [comport] |
||
1780 | inc eax |
||
1781 | push eax |
||
1782 | mov eax, 43 |
||
485 | heavyiron | 1783 | mcall |
31 | halyavin | 1784 | |
1785 | pop eax |
||
1786 | pop edx |
||
1787 | |||
1788 | cmp [ edi + eax ], byte 0 |
||
1789 | jne sw_001 |
||
1790 | |||
1791 | cmp [ esi + edx ], byte 0 |
||
1792 | jne sw_001 |
||
1793 | |||
1794 | xor eax, eax |
||
1795 | inc eax |
||
1796 | |||
1797 | sw_exit: |
||
1798 | ; return success (1) or failure (0) in eax |
||
1799 | ret |
||
1800 | |||
1801 | |||
1802 | |||
1803 | |||
1804 | if DEBUG_OUTPUT = TRUE |
||
1805 | |||
1806 | ;**************************************************************************** |
||
1807 | ; Function |
||
1808 | ; debug_output |
||
1809 | ; |
||
1810 | ; Description |
||
1811 | ; prints a description of the PPP protocol's data exchanges to the |
||
1812 | ; debug board |
||
1813 | ; |
||
1814 | ; esi holds ptr to msg to display |
||
1815 | ; |
||
1816 | ; Nothing preserved; I'm assuming a pusha/popa is done before calling |
||
1817 | ; |
||
1818 | ;**************************************************************************** |
||
1819 | debug_output: |
||
1820 | cmp esi, RX_IP |
||
1821 | jne do_001 |
||
1822 | |||
1823 | call debug_print_string |
||
1824 | |||
1825 | call debug_print_rx_ip |
||
1826 | |||
1827 | mov esi, IP_DATA1 |
||
1828 | call debug_print_string |
||
1829 | mov esi, CRLF |
||
1830 | call debug_print_string |
||
1831 | mov esi, IP_DATA2 |
||
1832 | call debug_print_string |
||
1833 | ret |
||
1834 | |||
1835 | do_001: |
||
1836 | cmp esi, TX_IP |
||
1837 | jne do_002 |
||
1838 | |||
1839 | call debug_print_string |
||
1840 | |||
1841 | call debug_print_tx_ip |
||
1842 | |||
1843 | mov esi, IP_DATA1 |
||
1844 | call debug_print_string |
||
1845 | mov esi, CRLF |
||
1846 | call debug_print_string |
||
1847 | mov esi, IP_DATA2 |
||
1848 | call debug_print_string |
||
1849 | ret |
||
1850 | |||
1851 | do_002: |
||
1852 | ; Print PPP protocol information |
||
1853 | if DEBUG_PPP_OUTPUT = TRUE |
||
1854 | call debug_print_string |
||
1855 | mov esi, CRLF |
||
1856 | call debug_print_string |
||
1857 | end if |
||
1858 | ret |
||
1859 | |||
1860 | |||
1861 | |||
1862 | txCom2: |
||
1863 | push ecx |
||
1864 | |||
1865 | wait_txd2t: |
||
1866 | mov eax,43 |
||
1867 | mov ecx,0x80000000 + 0x2f8 + 5 |
||
485 | heavyiron | 1868 | mcall |
31 | halyavin | 1869 | and bl, 0x40 |
1870 | cmp bl, 0 |
||
1871 | jz wait_txd2t ; loop until free |
||
1872 | |||
1873 | pop ebx |
||
1874 | |||
1875 | |||
1876 | ; send the character |
||
1877 | |||
1878 | mov ecx, 0x2f8 |
||
1879 | mov eax, 43 |
||
485 | heavyiron | 1880 | mcall |
31 | halyavin | 1881 | ret |
1882 | |||
1883 | |||
1884 | ;**************************************************************************** |
||
1885 | ; Function |
||
1886 | ; debug_print_string |
||
1887 | ; |
||
1888 | ; Description |
||
1889 | ; prints a string to the debug board |
||
1890 | ; |
||
1891 | ; esi holds ptr to msg to display |
||
1892 | ; |
||
1893 | ; Nothing preserved; I'm assuming a pusha/popa is done before calling |
||
1894 | ; |
||
1895 | ;**************************************************************************** |
||
1896 | debug_print_string: |
||
1897 | mov cl, [esi] |
||
1898 | cmp cl, 0 |
||
1899 | jnz dps_001 |
||
1900 | ret |
||
1901 | |||
1902 | dps_001: |
||
1903 | if DEBUG_PORT2_OUTPUT = TRUE |
||
1904 | pusha |
||
1905 | call txCom2 |
||
1906 | popa |
||
1907 | end if |
||
1908 | mov eax,63 |
||
1909 | mov ebx, 1 |
||
1910 | push esi |
||
485 | heavyiron | 1911 | mcall |
31 | halyavin | 1912 | pop esi |
1913 | inc esi |
||
1914 | jmp debug_print_string |
||
1915 | |||
1916 | |||
1917 | ; This is used for translating hex to ASCII for display or output |
||
1918 | hexchars db '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' |
||
1919 | |||
1920 | IP_DATA1 db 'TCP From: xxxxxxxx To: xxxxxxxx SrcP: xxxx DestP: xxxx',0 |
||
1921 | IP_DATA2 db 'Seq: xxxxxxxx Ack: xxxxxxxx Flags: xx dataLen: xxxx',13,10,0 |
||
1922 | |||
1923 | |||
1924 | |||
1925 | debug_print_rx_ip: |
||
1926 | mov esi, rx_str + 4 ; The ip buffer address start |
||
1927 | |||
1928 | mov edi, IP_DATA1 |
||
1929 | |||
1930 | cmp [esi+9], byte 1 |
||
1931 | jne rnICMP |
||
1932 | mov eax,'ICMP' |
||
1933 | jmp drp |
||
1934 | rnICMP: |
||
1935 | cmp [esi+9], byte 6 |
||
1936 | jne rnTCP |
||
1937 | mov eax,'TCP ' |
||
1938 | jmp drp |
||
1939 | rnTCP: |
||
1940 | cmp [esi+9], byte 17 |
||
1941 | jne rnUDP |
||
1942 | mov eax,'UDP ' |
||
1943 | jmp drp |
||
1944 | rnUDP: |
||
1945 | |||
1946 | drp: |
||
1947 | mov [edi], eax |
||
1948 | |||
1949 | call fillData |
||
1950 | |||
1951 | ret |
||
1952 | |||
1953 | |||
1954 | debug_print_tx_ip: |
||
1955 | mov esi, ip_buff ; The ip buffer address start |
||
1956 | |||
1957 | mov edi, IP_DATA1 |
||
1958 | |||
1959 | cmp [esi+9], byte 1 |
||
1960 | jne tnICMP |
||
1961 | mov eax,'ICMP' |
||
1962 | jmp dtp |
||
1963 | tnICMP: |
||
1964 | cmp [esi+9], byte 6 |
||
1965 | jne tnTCP |
||
1966 | mov eax,'TCP ' |
||
1967 | jmp dtp |
||
1968 | tnTCP: |
||
1969 | cmp [esi+9], byte 17 |
||
1970 | jne tnUDP |
||
1971 | mov eax,'UDP ' |
||
1972 | jmp dtp |
||
1973 | tnUDP: |
||
1974 | |||
1975 | dtp: |
||
1976 | mov [edi], eax |
||
1977 | |||
1978 | call fillData |
||
1979 | |||
1980 | ret |
||
1981 | |||
1982 | |||
1983 | fillData: |
||
1984 | ; Display from IP |
||
1985 | mov cl, [esi+12] |
||
1986 | mov edx, 11 |
||
1987 | call wbyte ; byte in cl, dest in edi+edx |
||
1988 | mov cl, [esi+13] |
||
1989 | mov edx, 13 |
||
1990 | call wbyte ; byte in cl, dest in edi+edx |
||
1991 | mov cl, [esi+14] |
||
1992 | mov edx, 15 |
||
1993 | call wbyte ; byte in cl, dest in edi+edx |
||
1994 | mov cl, [esi+15] |
||
1995 | mov edx, 17 |
||
1996 | call wbyte ; byte in cl, dest in edi+edx |
||
1997 | |||
1998 | ; Display to IP |
||
1999 | mov cl, [esi+16] |
||
2000 | mov edx, 24 |
||
2001 | call wbyte ; byte in cl, dest in edi+edx |
||
2002 | mov cl, [esi+17] |
||
2003 | mov edx, 26 |
||
2004 | call wbyte ; byte in cl, dest in edi+edx |
||
2005 | mov cl, [esi+18] |
||
2006 | mov edx, 28 |
||
2007 | call wbyte ; byte in cl, dest in edi+edx |
||
2008 | mov cl, [esi+19] |
||
2009 | mov edx, 30 |
||
2010 | call wbyte ; byte in cl, dest in edi+edx |
||
2011 | |||
2012 | ; Only display extra data for TCP |
||
2013 | cmp [esi+9], byte 6 ; TCP? |
||
2014 | je nTCP |
||
2015 | |||
2016 | ; display source port |
||
2017 | mov [edi+32], byte 0 |
||
2018 | mov edi, IP_DATA2 |
||
2019 | mov [edi], byte 0 |
||
2020 | ret |
||
2021 | |||
2022 | nTCP: |
||
2023 | mov [edi+32], byte ' ' |
||
2024 | |||
2025 | mov cl, [esi+20] |
||
2026 | mov edx, 39 |
||
2027 | call wbyte ; byte in cl, dest in edi+edx |
||
2028 | mov cl, [esi+21] |
||
2029 | mov edx, 41 |
||
2030 | call wbyte ; byte in cl, dest in edi+edx |
||
2031 | |||
2032 | mov cl, [esi+22] |
||
2033 | mov edx, 51 |
||
2034 | call wbyte ; byte in cl, dest in edi+edx |
||
2035 | mov cl, [esi+23] |
||
2036 | mov edx, 53 |
||
2037 | call wbyte ; byte in cl, dest in edi+edx |
||
2038 | |||
2039 | |||
2040 | mov edi, IP_DATA2 |
||
2041 | mov [edi], byte 'S' |
||
2042 | |||
2043 | mov cl, [esi+24] |
||
2044 | mov edx, 5 |
||
2045 | call wbyte ; byte in cl, dest in edi+edx |
||
2046 | mov cl, [esi+25] |
||
2047 | mov edx, 7 |
||
2048 | call wbyte ; byte in cl, dest in edi+edx |
||
2049 | mov cl, [esi+26] |
||
2050 | mov edx, 9 |
||
2051 | call wbyte ; byte in cl, dest in edi+edx |
||
2052 | mov cl, [esi+27] |
||
2053 | mov edx, 11 |
||
2054 | call wbyte ; byte in cl, dest in edi+edx |
||
2055 | |||
2056 | mov cl, [esi+28] |
||
2057 | mov edx, 19 |
||
2058 | call wbyte ; byte in cl, dest in edi+edx |
||
2059 | mov cl, [esi+29] |
||
2060 | mov edx, 21 |
||
2061 | call wbyte ; byte in cl, dest in edi+edx |
||
2062 | mov cl, [esi+30] |
||
2063 | mov edx, 23 |
||
2064 | call wbyte ; byte in cl, dest in edi+edx |
||
2065 | mov cl, [esi+31] |
||
2066 | mov edx, 25 |
||
2067 | call wbyte ; byte in cl, dest in edi+edx |
||
2068 | |||
2069 | mov cl, [esi+33] |
||
2070 | and cl, 0x3F |
||
2071 | mov edx, 35 |
||
2072 | call wbyte ; byte in cl, dest in edi+edx |
||
2073 | |||
2074 | ; Display the size of the received packet |
||
2075 | mov dh, [esi + 2] |
||
2076 | mov dl, [esi + 3] |
||
2077 | sub dx, 40 |
||
2078 | mov cl, dh |
||
2079 | mov edx, 48 |
||
2080 | call wbyte ; byte in cl, dest in edi+edx |
||
2081 | mov dh, [esi + 2] |
||
2082 | mov dl, [esi + 3] |
||
2083 | sub dx, 40 |
||
2084 | mov cl, dl |
||
2085 | mov edx, 50 |
||
2086 | call wbyte ; byte in cl, dest in edi+edx |
||
2087 | |||
2088 | |||
2089 | ret |
||
2090 | |||
2091 | |||
2092 | wbyte: ; byte in cl, dest in edi+edx, edi unchanged |
||
2093 | xor eax, eax |
||
2094 | mov al, cl |
||
2095 | shr al, 4 |
||
2096 | mov bl, [eax + hexchars] |
||
2097 | mov [edi+edx], bl |
||
2098 | inc edx |
||
2099 | mov al, cl |
||
2100 | and al, 0x0f |
||
2101 | mov bl, [eax + hexchars] |
||
2102 | mov [edi+edx], bl |
||
2103 | ret |
||
2104 | |||
2105 | else |
||
2106 | debug_output: |
||
2107 | ret |
||
2108 | end if |
||
2109 | |||
2110 | ; DATA AREA |
||
2111 | |||
2112 | |||
2113 | ; debug msgs |
||
2114 | RX_IP db 'R: ',0 |
||
2115 | TX_IP db 'T: ',0 |
||
2116 | CRLF db 13,10,0 |
||
2117 | RX_LCP_REQ db 'RX_LCP_REQ',0 |
||
2118 | RX_LCP_ACK db 'RX_LCP_ACK',0 |
||
2119 | RX_LCP_NAK db 'RX_LCP_NAK',0 |
||
2120 | RX_LCP_REJ db 'RX_LCP_REJ',0 |
||
2121 | RX_LCP_ECHO_REQ db 'RX_LCP_ECHO_REQ',0 |
||
2122 | RX_PAP_ACK db 'RX_PAP_ACK',0 |
||
2123 | RX_IPCP_REQ db 'RX_IPCP_REQ',0 |
||
2124 | RX_IPCP_ACK db 'RX_IPCP_ACK',0 |
||
2125 | RX_IPCP_NAK db 'RX_IPCP_NAK ( IP Address assigned )',0 |
||
2126 | RX_CCP_REQ db 'RX_CCP_REQ',0 |
||
2127 | TX_LCP_REQ db 'TX_LCP_REQ',0 |
||
2128 | TX_PAP_REQ db 'TX_PAP_REQ',0 |
||
2129 | TX_IPCP_REQ db 'TX_IPCP_REQ',0 |
||
2130 | |||
2131 | |||
2132 | ; Labels for GUI buttons |
||
2133 | button1_text db 'DIAL' |
||
2134 | button1_text_len db 4 |
||
2135 | button3_text db 'DISCONNECT' |
||
2136 | button3_text_len db 10 |
||
2137 | |||
2138 | comport dd 0 |
||
2139 | comirq dd 0 |
||
2140 | |||
2141 | ; Pointer to prompt shown to user |
||
2142 | prompt dd 0 |
||
2143 | prompt_len db 0 |
||
2144 | |||
2145 | ; Application Title |
||
485 | heavyiron | 2146 | title db 'PPP Dialer',0 |
31 | halyavin | 2147 | |
2148 | txmsg: db 'Tx bytes :' |
||
2149 | txmsglen: |
||
2150 | rxmsg: db 'Rx bytes :' |
||
2151 | rxmsglen: |
||
2152 | |||
2153 | timerValue dd 0 |
||
2154 | sendwaitTime dd 0 |
||
2155 | |||
2156 | |||
2157 | ; Prompts displayed to the user |
||
2158 | welcomep db 'Select an option below, see ppp.txt' |
||
2159 | welcomep_len db 35 |
||
2160 | |||
2161 | dialfp db 'Connect Failed...' |
||
2162 | dialfp_len db 17 |
||
2163 | |||
2164 | connectedp db 'Connected to Host' |
||
2165 | connectedp_len db 17 |
||
2166 | |||
2167 | conp db 'Connecting to Host' |
||
2168 | conp_len db 18 |
||
2169 | |||
2170 | pppOnp db 'PPP Started' |
||
2171 | pppOnp_len db 11 |
||
2172 | |||
2173 | IPOnp db 'IP Link established' |
||
2174 | IPOnp_len db 19 |
||
2175 | |||
2176 | discp db 'Disconnected from Host' |
||
2177 | discp_len db 22 |
||
2178 | |||
2179 | hangp db 'Hanging up Modem......' |
||
2180 | hangp_len db 22 |
||
2181 | |||
2182 | PPPconSend db 0x7e,0xff,0x7d,0x23,0x08,0x08,0x08,0x08,0 |
||
2183 | PPPconWait db '~~',0 |
||
2184 | hangupWait db 'ATZ',0 |
||
2185 | hangupSend db '|||+++|||',10,13,'ATH',10,13,'|ATZ',10,13,0 |
||
2186 | |||
2187 | ; Shrirang 2/5/03 |
||
2188 | |||
2189 | abortres: times(50) db 0 |
||
2190 | abortcnt db 0 |
||
2191 | |||
2192 | ;--! |
||
2193 | |||
2194 | LCPREQStr db 0x0e,0x02,0x06,0x00, 0x0a, 0x00, 0x00, 0x07, 0x02, 0x08, 0x02 |
||
2195 | PAPREQStr db 14, 4, 'free', 4, 'free' |
||
2196 | IPCPREQStr db 10, 3, 6, 0, 0, 0, 0 |
||
2197 | |||
2198 | irqtable: dd 0x3f8 + 0x01000000 ; read port 0x3f8, byte |
||
2199 | dd 0 |
||
2200 | dd 0 |
||
2201 | dd 0 |
||
2202 | dd 0 |
||
2203 | dd 0 |
||
2204 | dd 0 |
||
2205 | dd 0 |
||
2206 | dd 0 |
||
2207 | dd 0 |
||
2208 | dd 0 |
||
2209 | dd 0 |
||
2210 | dd 0 |
||
2211 | dd 0 |
||
2212 | dd 0 |
||
2213 | dd 0 |
||
2214 | checksum1 dd 0 |
||
2215 | checksum2 dd 0 |
||
2216 | packet dd 0 |
||
2217 | state dd 0 |
||
2218 | extended dd 0 |
||
2219 | number dd 0 |
||
2220 | tx_end dd 0 |
||
2221 | tx_ptr dd 0 |
||
2222 | rx_ptr dd 0 |
||
2223 | addr1 db 0 |
||
2224 | addr2 db 0 |
||
2225 | addr3 db 0 |
||
2226 | addr4 db 0 |
||
2227 | rxbytes dd 0 |
||
2228 | txbytes dd 0 |
||
2229 | |||
2230 | |||
2231 | ; End of application code and data marker |
||
2232 | |||
2233 | I_END: |
||
2234 | |||
2235 | rx_str: rb MaxRx + 1 |
||
2236 | tx_str: rb MaxTx + 1 |
||
2237 | ip_buff: rb 1500 |
||
2238 |