You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/08/09 15:17:33 UTC
[incubator-nuttx-apps] 03/04: system: telnetd: Add telnetd app
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit a86315050d080daed59ec95a8746ab838b43c0a7
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Mon Aug 8 09:54:22 2022 +0900
system: telnetd: Add telnetd app
Summary:
- This commit adds telnetd app
Impact:
- None
Testing:
- Tested with sabre-6quad:netknsh (will be updated later)
Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
system/telnetd/Kconfig | 39 +++++++++++++++++++++++++++++++
system/telnetd/Make.defs | 23 ++++++++++++++++++
system/telnetd/Makefile | 34 +++++++++++++++++++++++++++
system/telnetd/telnetd.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 157 insertions(+)
diff --git a/system/telnetd/Kconfig b/system/telnetd/Kconfig
new file mode 100644
index 000000000..46eb2181e
--- /dev/null
+++ b/system/telnetd/Kconfig
@@ -0,0 +1,39 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+config SYSTEM_TELNETD
+ tristate "Telnet daemon application"
+ default n
+ depends on NETUTILS_TELNETD
+ ---help---
+ Enable the Telnet daemon application
+
+config SYSTEM_TELNETD_PROGNAME
+ string "Telnetd program name"
+ default "telnetd"
+ depends on SYSTEM_TELNETD
+ ---help---
+ This is the name of the program that will be used when the NSH ELF
+ program is installed.
+
+config SYSTEM_TELNETD_PRIORITY
+ int "Telnetd task priority"
+ default 100
+ depends on SYSTEM_TELNETD
+
+config SYSTEM_TELNETD_STACKSIZE
+ int "Telnetd task stack size"
+ default DEFAULT_TASK_STACKSIZE
+ depends on SYSTEM_TELNETD
+
+config SYSTEM_TELNETD_SESSION_PRIORITY
+ int "Telnetd session task priority"
+ default 100
+ depends on SYSTEM_TELNETD
+
+config SYSTEM_TELNETD_SESSION_STACKSIZE
+ int "Telnetd session task stack size"
+ default 3072
+ depends on SYSTEM_TELNETD
diff --git a/system/telnetd/Make.defs b/system/telnetd/Make.defs
new file mode 100644
index 000000000..dceb475ea
--- /dev/null
+++ b/system/telnetd/Make.defs
@@ -0,0 +1,23 @@
+############################################################################
+# apps/system/telnetd/Make.defs
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership. The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+ifneq ($(CONFIG_SYSTEM_TELNETD),)
+CONFIGURED_APPS += $(APPDIR)/system/telnetd
+endif
diff --git a/system/telnetd/Makefile b/system/telnetd/Makefile
new file mode 100644
index 000000000..414e90ca5
--- /dev/null
+++ b/system/telnetd/Makefile
@@ -0,0 +1,34 @@
+############################################################################
+# apps/system/telnetd/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership. The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+
+# telnetd
+
+PROGNAME := $(CONFIG_SYSTEM_TELNETD_PROGNAME)
+PRIORITY := $(CONFIG_SYSTEM_TELNETD_PRIORITY)
+STACKSIZE := $(CONFIG_SYSTEM_TELNETD_STACKSIZE)
+MODULE := $(CONFIG_SYSTEM_TELNETD)
+
+# Files
+
+MAINSRC := telnetd.c
+
+include $(APPDIR)/Application.mk
diff --git a/system/telnetd/telnetd.c b/system/telnetd/telnetd.c
new file mode 100644
index 000000000..674f94160
--- /dev/null
+++ b/system/telnetd/telnetd.c
@@ -0,0 +1,61 @@
+/****************************************************************************
+ * apps/system/telnetd/telnetd.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "netutils/telnetd.h"
+#include "netutils/netlib.h"
+#include "nshlib/nshlib.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+int main(int argc, FAR char *argv[])
+{
+ FAR char *argv1[3];
+ char arg0[sizeof("0x1234567812345678")];
+ struct telnetd_s daemon;
+
+ /* Initialize the daemon structure */
+
+ daemon.port = HTONS(23);
+ daemon.family = AF_INET;
+ daemon.entry = nsh_telnetmain;
+
+ /* NOTE: Settings for telnet session task */
+
+ daemon.priority = CONFIG_SYSTEM_TELNETD_SESSION_PRIORITY;
+ daemon.stacksize = CONFIG_SYSTEM_TELNETD_SESSION_STACKSIZE;
+
+ snprintf(arg0, sizeof(arg0), "0x%" PRIxPTR, (uintptr_t)&daemon);
+ argv1[0] = "telnetd";
+ argv1[1] = arg0;
+ argv1[2] = NULL;
+
+ telnetd_daemon(2, argv1);
+ return 0;
+}