Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                                 ;;
  3. ;;  CHAT.INC                                                       ;;
  4. ;;                                                                 ;;
  5. ;;  Modem Chat Initiator for PPP Dialer                            ;;
  6. ;;                                                                 ;;
  7. ;;  Version 3    2nd May 2003                                      ;;
  8. ;;                                                                 ;;
  9. ;;  Copyright 2002 Shrirang Bhagwat, b_shrirang@hotmail.com        ;;
  10. ;;                                                                 ;;
  11. ;;  See file COPYING for details                                   ;;
  12. ;;                                                                 ;;
  13. ;;  2/5/03 - Shrirang - Added Abort Strings For sendwait        ;;
  14. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  15.  
  16.  
  17. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  18. ; Request And Response Chat Strings
  19. ; Following Data Structure is used for Request Response Chatting
  20. ; with the modem, for each request there is an expected response
  21. ; chatreq <-> chatres, 0 (NULL) is delimeter for 1 string
  22. ; '`' is delimiter for the section, modify according to your
  23. ; modem dialing scheme; in future MenuetOS might provide a graphical
  24. ; client to generate this kind of data structure and the PAP packet
  25. ; for username and password!
  26. ; Aborts strings are used to get outta sendwait early...
  27. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  28.  
  29. ; REQUESTS
  30. chatreq db 'ATH',13,0  ; 0 (NULL) is required by sendwait
  31.         db 'ATZ',13,0
  32.         db 'ATM1',13,0
  33.         db 'ATX1',13,0  ; My Modem doesn't connect without this
  34.  ;       db 'ATDT;',13,0
  35.         db 'ATDT phonenumber',13,0
  36.         db '`'   ; <- End Marker
  37.  
  38. ; RESPONSES
  39. chatres db 'OK',0
  40.         db 'OK',0
  41.         db 'OK',0
  42.         db 'OK',0
  43.  ;       db 'OK',0
  44.         db 'CONNECT',0
  45.         db '`'   ; <- End Marker
  46.  
  47. ; ABORTS
  48. aborts  db 'ERROR',0
  49.         db 'NO CARRIER',0
  50.         db 'NO DIALTONE',0
  51.         db 'BUSY',0
  52.         db 'LINE IN USE',0
  53.         db 'NO ANSWER',0
  54.         db '`'   ; <- End Marker
  55. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  56.  
  57. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  58. ;
  59. ;  modem_chat   -  chats with the modem to initiate a connection
  60. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  61. modem_chat:
  62.  
  63.  push edi
  64.  push esi
  65.  push edx
  66.  
  67.  mov edi, chatreq ; init everytime, safe, stateless
  68.  mov esi, chatres
  69.  
  70. chat_now:
  71.  
  72.  cmp byte [esi], '`' ; are we done?
  73.  je chatover
  74.  
  75.  mov edx, 6000 ; strings like "atdt;" take long on my modem
  76.  call sendwait
  77.  
  78.  and eax, eax
  79.  jz timeoutoccured
  80.  
  81. updatereq:
  82.  
  83.  inc edi
  84.  cmp byte [edi], '`'
  85.  je updateres
  86.  
  87.  cmp byte [edi], 0
  88.  jne updatereq
  89.  
  90.  inc edi
  91.  
  92. updateres:
  93.  
  94.  inc esi
  95.  cmp byte [esi], '`'
  96.  je chatover
  97.  
  98.  cmp byte [esi], 0
  99.  jne updateres
  100.  
  101.  inc esi
  102.  
  103.  jmp chat_now
  104.  
  105.  
  106. chatover:
  107.  
  108.  xor eax, eax ; SUCCESS!
  109.  inc eax
  110.  
  111.  pop edx
  112.  pop esi
  113.  pop edi
  114.  
  115.  ret
  116.  
  117. timeoutoccured:
  118.  
  119.  xor eax, eax ; FAIL!
  120.  
  121.  pop edx
  122.  pop esi
  123.  pop edi
  124.  
  125.  ret
  126.  
  127.  
  128. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  129. ;
  130. ;  scanaborts   -  scans the response from modem for abort srings
  131. ;     ESI - Response from modem
  132. ;     EDI - Pointer to Abort Table
  133. ;     ECX - Response Length
  134. ;     Returns 1 if abort detected, 0 otherwise
  135. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  136. scanaborts:
  137.  
  138.  push esi
  139.  push edi
  140.  push ecx
  141.  
  142. checkit:
  143.  
  144.  push esi
  145.  repe cmpsb   ; any abort matches?
  146.  je abortdetected
  147.     pop  esi
  148.  
  149.  
  150. updatetbl:
  151.  
  152.  inc edi
  153.  cmp byte [edi], '`'
  154.  je noabortfound
  155.  
  156.  cmp byte [edi], 0
  157.  jne updatetbl
  158.  
  159.  inc edi
  160.  
  161.  jmp checkit
  162.  
  163. abortdetected:
  164.  
  165.  pop  esi
  166.  pop  ecx
  167.  pop  edi
  168.  pop  esi
  169.  
  170.  xor eax, eax  ; SUCCESS!
  171.     inc eax
  172.  ret
  173.  
  174. noabortfound :
  175.  
  176.  pop  ecx
  177.  pop  edi
  178.  pop  esi
  179.  
  180.  
  181.  xor eax, eax  ; FAILED!
  182.  ret
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.