cli_telnet.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * Copyright (C) 2010 Teluu Inc. (http://www.teluu.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef __PJLIB_UTIL_CLI_TELNET_H__
  19. #define __PJLIB_UTIL_CLI_TELNET_H__
  20. /**
  21. * @file cli_telnet.h
  22. * @brief Command Line Interface Telnet Front End API
  23. */
  24. #include <pjlib-util/cli_imp.h>
  25. PJ_BEGIN_DECL
  26. /**
  27. * @ingroup PJLIB_UTIL_CLI_IMP
  28. * @{
  29. *
  30. */
  31. /**
  32. * This structure contains the information about the telnet.
  33. * Application will get updated information each time the telnet is started/
  34. * restarted.
  35. */
  36. typedef struct pj_cli_telnet_info
  37. {
  38. /**
  39. * The telnet's ip address.
  40. */
  41. pj_str_t ip_address;
  42. /**
  43. * The telnet's port number.
  44. */
  45. pj_uint16_t port;
  46. /** Internal buffer for IP address */
  47. char buf_[32];
  48. } pj_cli_telnet_info;
  49. /**
  50. * This specifies the callback called when telnet is started
  51. *
  52. * @param status The status of telnet startup process.
  53. *
  54. */
  55. typedef void (*pj_cli_telnet_on_started)(pj_status_t status);
  56. /**
  57. * This structure contains various options to instantiate the telnet daemon.
  58. * Application must call pj_cli_telnet_cfg_default() to initialize
  59. * this structure with its default values.
  60. */
  61. typedef struct pj_cli_telnet_cfg
  62. {
  63. /**
  64. * Listening port number. The value may be 0 to let the system choose
  65. * the first available port.
  66. *
  67. * Default value: PJ_CLI_TELNET_PORT
  68. */
  69. pj_uint16_t port;
  70. /**
  71. * Ioqueue instance to be used. If this field is NULL, an internal
  72. * ioqueue and worker thread will be created.
  73. */
  74. pj_ioqueue_t *ioqueue;
  75. /**
  76. * Default log verbosity level for the session.
  77. *
  78. * Default value: PJ_CLI_TELNET_LOG_LEVEL
  79. */
  80. int log_level;
  81. /**
  82. * Specify a password to be asked to the end user to access the
  83. * application. Currently this is not implemented yet.
  84. *
  85. * Default: empty (no password)
  86. */
  87. pj_str_t passwd;
  88. /**
  89. * Specify text message to be displayed to newly connected users.
  90. * Currently this is not implemented yet.
  91. *
  92. * Default: empty
  93. */
  94. pj_str_t welcome_msg;
  95. /**
  96. * Specify text message as a prompt string to user.
  97. *
  98. * Default: empty
  99. */
  100. pj_str_t prompt_str;
  101. /**
  102. * Specify the pj_cli_telnet_on_started callback.
  103. *
  104. * Default: empty
  105. */
  106. pj_cli_telnet_on_started on_started;
  107. } pj_cli_telnet_cfg;
  108. /**
  109. * Initialize pj_cli_telnet_cfg with its default values.
  110. *
  111. * @param param The structure to be initialized.
  112. */
  113. PJ_DECL(void) pj_cli_telnet_cfg_default(pj_cli_telnet_cfg *param);
  114. /**
  115. * Create, initialize, and start a telnet daemon for the application.
  116. *
  117. * @param cli The CLI application instance.
  118. * @param param Optional parameters for creating the telnet daemon.
  119. * If this value is NULL, default parameters will be used.
  120. * @param p_fe Optional pointer to receive the front-end instance
  121. * of the telnet front-end just created.
  122. *
  123. * @return PJ_SUCCESS on success, or the appropriate error code.
  124. */
  125. PJ_DECL(pj_status_t) pj_cli_telnet_create(pj_cli_t *cli,
  126. pj_cli_telnet_cfg *param,
  127. pj_cli_front_end **p_fe);
  128. /**
  129. * Retrieve cli telnet info.
  130. *
  131. * @param fe The front end.
  132. * @param info The telnet runtime information.
  133. *
  134. * @return PJ_SUCCESS on success.
  135. */
  136. PJ_DECL(pj_status_t) pj_cli_telnet_get_info(pj_cli_front_end *fe,
  137. pj_cli_telnet_info *info);
  138. /**
  139. * @}
  140. */
  141. PJ_END_DECL
  142. #endif /* __PJLIB_UTIL_CLI_TELNET_H__ */