Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
5.7 KiB

  1. // FSM.cpp : This file contains the Finite State Machine ...
  2. // Created: Feb '98
  3. // Author : a-rakeba
  4. // History:
  5. // Copyright (C) 1998 Microsoft Corporation
  6. // All rights reserved.
  7. // Microsoft Confidential
  8. #include "telnet.h"
  9. #include "FSM.h"
  10. #include "RFCProto.h"
  11. FSM_TRANSITION telnetTransTable[] = {
  12. // State Input Next State Action
  13. // ----- ----- ---------- ------
  14. { TS_DATA, TC_IAC, TS_IAC, &CRFCProtocol::NoOp },
  15. { TS_DATA, TC_ANY, TS_DATA, &CRFCProtocol::PutBack},
  16. { TS_IAC, TC_IAC, TS_DATA, &CRFCProtocol::PutBack},
  17. { TS_IAC, TC_SB, TS_SUBNEG, &CRFCProtocol::NoOp },
  18. // Telnet Commands
  19. { TS_IAC, TC_NOP, TS_DATA, &CRFCProtocol::NoOp },
  20. { TS_IAC, TC_DM, TS_DATA, &CRFCProtocol::DataMark},
  21. { TS_IAC, TC_GA, TS_DATA, &CRFCProtocol::GoAhead },
  22. { TS_IAC, TC_EL, TS_DATA, &CRFCProtocol::EraseLine},
  23. { TS_IAC, TC_EC, TS_DATA, &CRFCProtocol::EraseChar},
  24. { TS_IAC, TC_AYT, TS_DATA, &CRFCProtocol::AreYouThere},
  25. { TS_IAC, TC_AO, TS_DATA, &CRFCProtocol::AbortOutput},
  26. { TS_IAC, TC_IP, TS_DATA, &CRFCProtocol::InterruptProcess},
  27. { TS_IAC, TC_BREAK, TS_DATA, &CRFCProtocol::Break},
  28. // Option Negotiation
  29. { TS_IAC, TC_WILL, TS_WOPT, &CRFCProtocol::RecordOption},
  30. { TS_IAC, TC_WONT, TS_WOPT, &CRFCProtocol::RecordOption},
  31. { TS_IAC, TC_DO, TS_DOPT, &CRFCProtocol::RecordOption},
  32. { TS_IAC, TC_DONT, TS_DOPT, &CRFCProtocol::RecordOption},
  33. { TS_IAC, TC_ANY, TS_DATA, &CRFCProtocol::NoOp },
  34. // Option Subnegotiation
  35. { TS_SUBNEG, TC_IAC, TS_SUBIAC, &CRFCProtocol::NoOp },
  36. { TS_SUBNEG, TC_ANY, TS_SUBNEG, &CRFCProtocol::SubOption},
  37. { TS_SUBIAC, TC_SE, TS_DATA, &CRFCProtocol::SubEnd },
  38. { TS_SUBIAC, TC_ANY, TS_SUBNEG, &CRFCProtocol::SubOption},
  39. { TS_WOPT, TO_ECHO, TS_DATA, &CRFCProtocol::DoEcho },
  40. { TS_WOPT, TO_NAWS, TS_DATA, &CRFCProtocol::DoNaws },
  41. { TS_WOPT, TO_SGA, TS_DATA, &CRFCProtocol::DoSuppressGA},
  42. { TS_WOPT, TO_TXBINARY,TS_DATA, &CRFCProtocol::DoTxBinary},
  43. { TS_WOPT, TO_TERMTYPE,TS_DATA, &CRFCProtocol::DoTermType},
  44. { TS_WOPT, TO_AUTH, TS_DATA, &CRFCProtocol::DoAuthentication},
  45. { TS_WOPT, TO_NEW_ENVIRON,TS_DATA, &CRFCProtocol::DoNewEnviron},
  46. { TS_WOPT, TC_ANY, TS_DATA, &CRFCProtocol::DoNotSup},
  47. { TS_DOPT, TO_TXBINARY,TS_DATA, &CRFCProtocol::WillTxBinary},
  48. { TS_DOPT, TO_SGA, TS_DATA, &CRFCProtocol::WillSuppressGA},
  49. { TS_DOPT, TO_ECHO, TS_DATA, &CRFCProtocol::WillEcho},
  50. { TS_DOPT, TC_ANY, TS_DATA, &CRFCProtocol::WillNotSup},
  51. { FS_INVALID, TC_ANY, FS_INVALID, &CRFCProtocol::Abort},
  52. };
  53. #define NUM_TRANSITIONS (sizeof(telnetTransTable)/sizeof(telnetTransTable[0]))
  54. FSM_TRANSITION subNegTransTable[] = {
  55. // State Input Next State Action
  56. // ----- ----- ---------- ------
  57. { SS_START, TO_TERMTYPE,SS_TERMTYPE, &CRFCProtocol::NoOp },
  58. { SS_START, TO_AUTH, SS_AUTH1, &CRFCProtocol::NoOp },
  59. { SS_START, TO_NAWS, SS_NAWS, &CRFCProtocol::NoOp },
  60. { SS_START, TO_NEW_ENVIRON, SS_NEW_ENVIRON1, &CRFCProtocol::NoOp },
  61. { SS_START, TC_ANY, SS_END_FAIL, &CRFCProtocol::NoOp },
  62. { SS_NAWS, TC_ANY, SS_NAWS, &CRFCProtocol::SubNaws},
  63. { SS_TERMTYPE,TT_IS, SS_END_SUCC, &CRFCProtocol::NoOp },
  64. { SS_TERMTYPE,TC_ANY, SS_END_FAIL, &CRFCProtocol::NoOp },
  65. { SS_NEW_ENVIRON1,IS, SS_NEW_ENVIRON2,&CRFCProtocol::SubNewEnvShowLoginPrompt },
  66. { SS_NEW_ENVIRON1,INFO, SS_NEW_ENVIRON2,&CRFCProtocol::NoOp },
  67. { SS_NEW_ENVIRON1,TC_ANY, SS_END_FAIL, &CRFCProtocol::NoOp },
  68. { SS_NEW_ENVIRON2,VAR, SS_NEW_ENVIRON3,&CRFCProtocol::NoOp},
  69. { SS_NEW_ENVIRON2,USERVAR,SS_NEW_ENVIRON3,&CRFCProtocol::NoOp},
  70. { SS_NEW_ENVIRON2,TC_ANY, SS_END_FAIL, &CRFCProtocol::NoOp},
  71. { SS_NEW_ENVIRON3,VAR, SS_NEW_ENVIRON3,&CRFCProtocol::NoOp },
  72. { SS_NEW_ENVIRON3,USERVAR,SS_NEW_ENVIRON3,&CRFCProtocol::NoOp },
  73. { SS_NEW_ENVIRON3,VALUE, SS_NEW_ENVIRON3,&CRFCProtocol::NoOp },
  74. { SS_NEW_ENVIRON3,ENV_ESC,SS_NEW_ENVIRON5,&CRFCProtocol::NoOp },
  75. { SS_NEW_ENVIRON3,TC_ANY, SS_NEW_ENVIRON4,&CRFCProtocol::SubNewEnvGetString},
  76. { SS_NEW_ENVIRON4,VAR, SS_NEW_ENVIRON3,&CRFCProtocol::SubNewEnvGetValue},
  77. { SS_NEW_ENVIRON4,USERVAR,SS_NEW_ENVIRON3,&CRFCProtocol::SubNewEnvGetValue},
  78. { SS_NEW_ENVIRON4,VALUE, SS_NEW_ENVIRON3,&CRFCProtocol::SubNewEnvGetVariable},
  79. { SS_NEW_ENVIRON4,ENV_ESC,SS_NEW_ENVIRON5,&CRFCProtocol::NoOp},
  80. { SS_NEW_ENVIRON4,TC_ANY, SS_NEW_ENVIRON4,&CRFCProtocol::SubNewEnvGetString},
  81. { SS_NEW_ENVIRON5,TC_ANY, SS_NEW_ENVIRON4,&CRFCProtocol::SubNewEnvGetString},
  82. { SS_AUTH1, AU_IS, SS_AUTH2, &CRFCProtocol::NoOp },
  83. { SS_AUTH1, TC_ANY, SS_END_FAIL, &CRFCProtocol::NoOp },
  84. { SS_AUTH2, TC_ANY, SS_AUTH2, &CRFCProtocol::SubAuth},
  85. { SS_END_FAIL,TC_ANY, SS_END_FAIL, &CRFCProtocol::NoOp },
  86. { SS_END_SUCC,TC_ANY, SS_END_SUCC, &CRFCProtocol::SubTermType},
  87. { FS_INVALID, TC_ANY, FS_INVALID, &CRFCProtocol::Abort },
  88. };