nshlib: Make nsh_telnetmain() in public

Summary:
- This commit makes nsh_telnetmain() in public so that we can
  call it from applications.
- Also, CONFIG_NSH_DISABLE_TELNETSTART is introduced so that
  we can disable nsh_telnetstart()

Impact:
- nsh with telnet daemon

Testing:
- Tested with sabre-6quad:netknsh (will be updated later)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
Masayuki Ishikawa 2022-08-05 14:37:28 +09:00 committed by Xiang Xiao
parent 000d1455b4
commit 3f70a78dd3
3 changed files with 31 additions and 6 deletions

View File

@ -126,6 +126,27 @@ void nsh_initialize(void);
int nsh_consolemain(int argc, FAR char *argv[]);
/****************************************************************************
* Name: nsh_telnetmain
*
* Description:
* This interface may be called or started with task_start to start a
* single NSH instance that operates on stdin and stdout for telnet daemon.
* This function does not return.
*
* Input Parameters:
* Standard task start-up arguments. These are not used. argc may be
* zero and argv may be NULL.
*
* Returned Values:
* This function does not normally return. exit() is usually called to
* terminate the NSH session. This function will return in the event of
* an error. In that case, a non-zero value is returned (EXIT_FAILURE=1).
****************************************************************************/
int nsh_telnetmain(int argc, FAR char *argv[]);
/****************************************************************************
* Name: nsh_telnetstart
*

View File

@ -1157,6 +1157,12 @@ config NSH_IOBUFFER_SIZE
Determines the size of the I/O buffer to use for sending/
receiving TELNET commands/responses. Default: 512
config NSH_DISABLE_TELNETSTART
bool "Disable to start telnetd"
default false
---help---
Determines if the nsh starts telnetd automatically
endif # NSH_TELNET
endmenu # Telnet Configuration

View File

@ -59,14 +59,14 @@ enum telnetd_state_e
};
/****************************************************************************
* Private Functions
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nsh_telnetmain
****************************************************************************/
static int nsh_telnetmain(int argc, char *argv[])
int nsh_telnetmain(int argc, FAR char *argv[])
{
FAR struct console_stdio_s *pstate = nsh_newconsole(true);
FAR struct nsh_vtbl_s *vtbl;
@ -192,10 +192,6 @@ static int nsh_telnetmain(int argc, char *argv[])
return OK;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nsh_telnetstart
*
@ -218,6 +214,7 @@ static int nsh_telnetmain(int argc, char *argv[])
*
****************************************************************************/
#ifndef CONFIG_NSH_DISABLE_TELNETSTART
int nsh_telnetstart(sa_family_t family)
{
static enum telnetd_state_e state = TELNETD_NOTRUNNING;
@ -325,6 +322,7 @@ int nsh_telnetstart(sa_family_t family)
return ret;
}
#endif
/****************************************************************************
* Name: cmd_telnetd