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 +#include +#include + +#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; +}