FtpNegotiationCommand.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* <!-- copyright */
  2. /*
  3. * aria2 - a simple utility for downloading files faster
  4. *
  5. * Copyright (C) 2006 Tatsuhiro Tsujikawa
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. /* copyright --> */
  22. #ifndef _D_FTP_NEGOTIATION_COMMAND_H_
  23. #define _D_FTP_NEGOTIATION_COMMAND_H_
  24. #include "AbstractCommand.h"
  25. #include "FtpConnection.h"
  26. class FtpNegotiationCommand : public AbstractCommand {
  27. private:
  28. enum Seq {
  29. SEQ_RECV_GREETING,
  30. SEQ_SEND_USER,
  31. SEQ_RECV_USER,
  32. SEQ_SEND_PASS,
  33. SEQ_RECV_PASS,
  34. SEQ_SEND_TYPE,
  35. SEQ_RECV_TYPE,
  36. SEQ_SEND_CWD,
  37. SEQ_RECV_CWD,
  38. SEQ_SEND_SIZE,
  39. SEQ_RECV_SIZE,
  40. SEQ_SEND_PORT,
  41. SEQ_RECV_PORT,
  42. SEQ_SEND_PASV,
  43. SEQ_RECV_PASV,
  44. SEQ_SEND_REST_PASV,
  45. SEQ_SEND_REST,
  46. SEQ_RECV_REST,
  47. SEQ_SEND_RETR,
  48. SEQ_RECV_RETR,
  49. SEQ_NEGOTIATION_COMPLETED,
  50. SEQ_RETRY
  51. };
  52. bool recvGreeting();
  53. bool sendUser();
  54. bool recvUser();
  55. bool sendPass();
  56. bool recvPass();
  57. bool sendType();
  58. bool recvType();
  59. bool sendCwd();
  60. bool recvCwd();
  61. bool sendSize();
  62. bool recvSize();
  63. bool sendPort();
  64. bool recvPort();
  65. bool sendPasv();
  66. bool recvPasv();
  67. bool sendRest(const Segment& segment);
  68. bool sendRestPasv(const Segment& segment);
  69. bool recvRest();
  70. bool sendRetr();
  71. bool recvRetr();
  72. bool processSequence(const Segment& segment);
  73. Socket* dataSocket;
  74. Socket* serverSocket;
  75. int sequence;
  76. FtpConnection* ftp;
  77. protected:
  78. bool executeInternal(Segment segment);
  79. public:
  80. FtpNegotiationCommand(int cuid, Request* req, DownloadEngine* e, const Socket* s);
  81. ~FtpNegotiationCommand();
  82. };
  83. #endif // _D_FTP_NEGOTIATION_COMMAND_H_