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 2026/10/08 05:29:58 UTC
(nuttx) branch master updated (8308e4b782d -> 45de63940b4)
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
from 8308e4b782d fs/v9fs: Do not copy the comma after the virtio tag.
new 35e0427bef4 drivers/net/telnet: Fix nxstyle issues.
new 9f523735585 drivers/net/telnet: Send CR LF as end of line.
new 45de63940b4 drivers/net/telnet: Send a bare carriage return as CR NUL.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
drivers/net/telnet.c | 188 ++++++++++++++++++++++++++-------------------------
1 file changed, 97 insertions(+), 91 deletions(-)
(nuttx) 01/03: drivers/net/telnet: Fix nxstyle issues.
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 35e0427bef44c517995f14bce8a0976617948a56
Author: raiden00pl <ra...@railab.me>
AuthorDate: Wed Oct 7 19:41:27 2026 +0200
drivers/net/telnet: Fix nxstyle issues.
Indent the switch cases in telnet_ioctl() and factory_ioctl(), align a
closing brace and wrap a long comment line. No functional change.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: raiden00pl <ra...@railab.me>
---
drivers/net/telnet.c | 148 +++++++++++++++++++++++++--------------------------
1 file changed, 74 insertions(+), 74 deletions(-)
diff --git a/drivers/net/telnet.c b/drivers/net/telnet.c
index b5811d04695..a76f4ab459b 100644
--- a/drivers/net/telnet.c
+++ b/drivers/net/telnet.c
@@ -352,7 +352,7 @@ static ssize_t telnet_receive(FAR struct telnet_dev_s *priv,
{
telnet_getchar(priv, ch, dest, &nread);
priv->td_state = STATE_NORMAL;
- }
+ }
else
{
switch (ch)
@@ -1095,19 +1095,19 @@ static int telnet_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
* process.
*/
- case TIOCSCTTY:
- {
- /* Check if the ISIG flag is set in the termios c_lflag to enable
- * this feature. This flag is set automatically for a serial console
- * device.
- */
+ case TIOCSCTTY:
+ {
+ /* Check if the ISIG flag is set in the termios c_lflag to enable
+ * this feature. This flag is set automatically for a serial
+ * console device.
+ */
- /* Save the PID of the recipient of the SIGINT signal. */
+ /* Save the PID of the recipient of the SIGINT signal. */
- priv->td_pid = (pid_t)arg;
- DEBUGASSERT((unsigned long)(priv->td_pid) == arg);
- }
- break;
+ priv->td_pid = (pid_t)arg;
+ DEBUGASSERT((unsigned long)(priv->td_pid) == arg);
+ }
+ break;
#endif
#ifdef CONFIG_TELNET_SUPPORT_NAWS
@@ -1120,54 +1120,54 @@ static int telnet_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
pw->ws_row = priv->td_rows;
pw->ws_col = priv->td_cols;
}
- break;
+ break;
#endif
- /* Handle TERMIOS command */
+ /* Handle TERMIOS command */
- case TCGETS:
- {
- termiosp = (FAR struct termios *)((uintptr_t)arg);
- DEBUGASSERT(termiosp != NULL);
+ case TCGETS:
+ {
+ termiosp = (FAR struct termios *)((uintptr_t)arg);
+ DEBUGASSERT(termiosp != NULL);
- cfmakeraw(termiosp);
+ cfmakeraw(termiosp);
- termiosp->c_lflag = priv->td_lflag;
- }
- break;
+ termiosp->c_lflag = priv->td_lflag;
+ }
+ break;
- case TCSETS:
- {
- termiosp = (FAR struct termios *)((uintptr_t)arg);
- DEBUGASSERT(termiosp != NULL);
+ case TCSETS:
+ {
+ termiosp = (FAR struct termios *)((uintptr_t)arg);
+ DEBUGASSERT(termiosp != NULL);
- /* Save the termios settings */
+ /* Save the termios settings */
- priv->td_lflag = termiosp->c_lflag;
+ priv->td_lflag = termiosp->c_lflag;
- if ((priv->td_lflag & ECHO) != 0)
- {
- /* If ECHO is set, then we need to send the won't echo option
- * to the client, let the client do echo to emulate
- * the behavior of a real terminal.
- */
+ if ((priv->td_lflag & ECHO) != 0)
+ {
+ /* If ECHO is set, then we need to send the won't echo option
+ * to the client, let the client do echo to emulate
+ * the behavior of a real terminal.
+ */
- telnet_sendopt(priv, TELNET_WONT, TELNET_ECHO);
- }
- else
- {
- /* Otherwise, we need to send the will echo option to the
- * client, let the client don't echo to disable the echo.
- */
+ telnet_sendopt(priv, TELNET_WONT, TELNET_ECHO);
+ }
+ else
+ {
+ /* Otherwise, we need to send the will echo option to the
+ * client, let the client don't echo to disable the echo.
+ */
- telnet_sendopt(priv, TELNET_WILL, TELNET_ECHO);
- }
- }
- break;
+ telnet_sendopt(priv, TELNET_WILL, TELNET_ECHO);
+ }
+ }
+ break;
- default:
- ret = psock_ioctl(&priv->td_psock, cmd, arg);
- break;
+ default:
+ ret = psock_ioctl(&priv->td_psock, cmd, arg);
+ break;
}
return ret;
@@ -1223,32 +1223,32 @@ static int factory_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
switch (cmd)
{
- /* Command: SIOCTELNET
- * Description: Create a Telnet sessions.
- * Argument: A pointer to a write-able instance of struct
- * telnet_session_s.
- * Dependencies: CONFIG_NETDEV_TELNET
- */
-
- case SIOCTELNET:
- {
- FAR struct telnet_session_s *session =
- (FAR struct telnet_session_s *)((uintptr_t)arg);
-
- if (session == NULL)
- {
- ret = -EINVAL;
- }
- else
- {
- ret = telnet_session(session);
- }
- }
- break;
-
- default:
- ret = -ENOTTY;
- break;
+ /* Command: SIOCTELNET
+ * Description: Create a Telnet sessions.
+ * Argument: A pointer to a write-able instance of struct
+ * telnet_session_s.
+ * Dependencies: CONFIG_NETDEV_TELNET
+ */
+
+ case SIOCTELNET:
+ {
+ FAR struct telnet_session_s *session =
+ (FAR struct telnet_session_s *)((uintptr_t)arg);
+
+ if (session == NULL)
+ {
+ ret = -EINVAL;
+ }
+ else
+ {
+ ret = telnet_session(session);
+ }
+ }
+ break;
+
+ default:
+ ret = -ENOTTY;
+ break;
}
return ret;
(nuttx) 02/03: drivers/net/telnet: Send CR LF as end of line.
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 9f52373558578a1184df19fe7645b41efef35def
Author: raiden00pl <ra...@railab.me>
AuthorDate: Wed Oct 7 16:09:47 2026 +0200
drivers/net/telnet: Send CR LF as end of line.
telnet_putchar() appended the carriage return after the line feed, so
every output line ended with LF CR. RFC 854 defines the telnet end of
line as CR LF.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: raiden00pl <ra...@railab.me>
---
drivers/net/telnet.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/telnet.c b/drivers/net/telnet.c
index a76f4ab459b..daee0692d94 100644
--- a/drivers/net/telnet.c
+++ b/drivers/net/telnet.c
@@ -591,17 +591,14 @@ static bool telnet_putchar(FAR struct telnet_dev_s *priv, uint8_t ch,
if (ch != TELNET_CR)
{
- /* Add all other characters to the destination buffer */
-
index = *nread;
- priv->td_txbuffer[index++] = ch;
- /* Check for line feeds */
+ /* Telnet end of line is CR LF (RFC 854): put the carriage return
+ * before the line feed.
+ */
if (ch == TELNET_NL)
{
- /* Now add the carriage return */
-
priv->td_txbuffer[index++] = TELNET_CR;
/* End of line */
@@ -609,6 +606,9 @@ static bool telnet_putchar(FAR struct telnet_dev_s *priv, uint8_t ch,
ret = true;
}
+ /* Add all other characters to the destination buffer */
+
+ priv->td_txbuffer[index++] = ch;
*nread = index;
}
(nuttx) 03/03: drivers/net/telnet: Send a bare carriage return as CR NUL.
Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 45de63940b45363690ef62dd3048a3733e7acc9d
Author: raiden00pl <ra...@railab.me>
AuthorDate: Wed Oct 7 20:11:03 2026 +0200
drivers/net/telnet: Send a bare carriage return as CR NUL.
telnet_putchar() dropped every CR from the user buffer. RFC 854
requires a CR to be followed by LF or NUL, so send it and add a NUL
if the next character is not LF.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: raiden00pl <ra...@railab.me>
---
drivers/net/telnet.c | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/drivers/net/telnet.c b/drivers/net/telnet.c
index daee0692d94..78bff9addb0 100644
--- a/drivers/net/telnet.c
+++ b/drivers/net/telnet.c
@@ -69,6 +69,7 @@
/* Telnet protocol stuff ****************************************************/
+#define TELNET_NUL 0x00
#define TELNET_NL 0x0a
#define TELNET_CR 0x0d
@@ -119,6 +120,7 @@ struct telnet_dev_s
uint8_t td_crefs; /* The number of open references to the session */
uint8_t td_minor; /* Minor device number */
bool td_sb_iac; /* Saw IAC within sub-negotiation payload */
+ bool td_txcr; /* Last byte sent was a CR */
uint16_t td_offset; /* Offset to the valid, pending bytes in the rxbuffer */
uint16_t td_pending; /* Number of valid, pending bytes in the rxbuffer */
#ifdef CONFIG_TELNET_SUPPORT_NAWS
@@ -582,36 +584,40 @@ static ssize_t telnet_receive(FAR struct telnet_dev_s *priv,
static bool telnet_putchar(FAR struct telnet_dev_s *priv, uint8_t ch,
int *nread)
{
- register int index;
+ register int index = *nread;
bool ret = false;
- /* Ignore carriage returns (we will put these in automatically as
- * necessary).
+ /* Telnet end of line is CR LF and a carriage return alone is CR NUL
+ * (RFC 854): a CR must be followed by LF or NUL. A CR from the user
+ * buffer is sent at once; the next character decides whether a NUL is
+ * needed after it.
*/
- if (ch != TELNET_CR)
+ if (priv->td_txcr && ch != TELNET_NL)
{
- index = *nread;
+ priv->td_txbuffer[index++] = TELNET_NUL;
+ }
- /* Telnet end of line is CR LF (RFC 854): put the carriage return
- * before the line feed.
+ if (ch == TELNET_NL)
+ {
+ /* Put the carriage return before the line feed, unless it was
+ * already sent.
*/
- if (ch == TELNET_NL)
+ if (!priv->td_txcr)
{
priv->td_txbuffer[index++] = TELNET_CR;
-
- /* End of line */
-
- ret = true;
}
- /* Add all other characters to the destination buffer */
+ /* End of line */
- priv->td_txbuffer[index++] = ch;
- *nread = index;
+ ret = true;
}
+ priv->td_txbuffer[index++] = ch;
+ priv->td_txcr = (ch == TELNET_CR);
+ *nread = index;
+
return ret;
}