Commit 7855da00 authored by james's avatar james
Browse files

Added many Telnet option and command constants. Still messing with ways to

make TELNET-STREAM do what I want, and trying to figure out what I want.
parent a1e4c479
;;;; ltelnetd.lisp -- Lisp Telnet daemon.
;;;;
;;;; $Id: $
;;;; $Id: ltelnetd.lisp,v 1.1.1.1 2004/01/22 16:01:06 james Exp $
;;;;
;;;; Copyfnord (K) 3170 James A. Crippen <james@unlambda.com>,
;;;; Martin Rydstrom <rydis@cd.chalmers.se>
......@@ -247,11 +247,9 @@ in LISTENER."
;;;;;; Telnet Stream
;;
;;; FIXME: What should this class really inherit from? SB-SYS:FD-STREAM is a
;;; structure, and is internal, so should probably not be inherited. But it's
;;; what we use to create the stream from the socket. Is SB-SYS:FD-STREAM a
;;; FILE-STREAM? Or what? Perhaps we should just wrap up the socket->stream
;;; stuff and create a SOCKET-STREAM class for it to use.
;;; FIXME: What should this class really inherit from? In SBCL we use
;;; SB-BSD-SOCKETS:SOCKET-MAKE-STREAM, but this gives us a FILE-STREAM (aka
;;; FD-STREAM) which might not be what we want.
;;;
;;; Networking in Lisp is so icky nowadays. How I pine for the Lisp Machines.
(defclass telnet-stream (file-stream)
......@@ -273,19 +271,10 @@ in LISTENER."
(convert-telnet-characters :initform nil :type (member nil t)
:accessor stream-convert-telnet-characters)))
;;; The READ-CHAR and WRITE-CHAR functions are what users should use for I/O
;;; with a Telnet stream. They're supposed to transparently handle all Telnet
;;; commands discovered in the stream. To send Telnet commands to the client
;;; use the appropriate SEND-TELNET-COMMAND-* functions, not WRITE-CHAR.
(defmethod read-char ((stream telnet-stream))
(let ((char (if (stream-unread-chars stream)
(pop (stream-unread-chars stream))
(read-char stream))))
(case char
(+nvt-iac+ (setf (stream-got-iac stream) t)
(process-telnet-command stream))
(t char))))
(let ((char (peek-char stream)))
(if (char-equal char +nvt-iac+)
(process-telnet-command-stream stream))))
(defmethod write-char ((stream telnet-stream) char)
(when (and (eq (stream-remote-echo stream) t)
......@@ -299,41 +288,69 @@ in LISTENER."
;;;;;; Command Processing.
;;
(defmethod negotiate-telnet-options ((stream telnet-stream))
())
(defmethod process-telnet-option ((stream telnet-stream))
)
(defmethod process-telnet-command ((stream telnet-stream))
"Processes a Telnet protocol command. Expects STREAM to have command contents
in queue without preceding +NVT-IAC+ character. Returns STREAM."
(setf (stream-command-mode stream) t))
(setf (stream-command-mode stream) t)
)
;;
;;;;;; NVT Support.
;;
;;; Telnet escape character.
(defconstant +nvt-iac+ (code-char 255))
;;; Option negotiation commands.
(defconstant +nvt-will+ (code-char 251))
(defconstant +nvt-wont+ (code-char 252))
(defconstant +nvt-do+ (code-char 253))
(defconstant +nvt-dont+ (code-char 254))
(defconstant +option-negotiation-list+
(list +nvt-will+ +nvt-wont+ +nvt-do+ +nvt-dont+))
;;; Commands.
(defconstant +nvt-se+ (code-char 240) "Subnegotiation End")
(defconstant +nvt-nop+ (code-char 241) "No-op")
(defconstant +nvt-dm+ (code-char 242) "Data Mark")
(defconstant +nvt-break+ (code-char 243) "Break")
(defconstant +nvt-ip+ (code-char 244) "Interrupt Process")
(defconstant +nvt-ao+ (code-char 245) "Abort Output")
(defconstant +nvt-ayt+ (code-char 246) "Are You There?")
(defconstant +nvt-ec+ (code-char 247) "Erase Character")
(defconstant +nvt-el+ (code-char 248) "Erase Line")
(defconstant +nvt-ga+ (code-char 249) "Go Ahead")
(defconstant +nvt-sb+ (code-char 250) "Subnegotiation Begin")
(defconstant +nvt-bell+ (code-char 7) "Bell")
;;; Options
(defconstant +nvt-echo+ (code-char 1))
(defconstant +nvt-supress-go-ahead+ (code-char 3))
;;; IAC
;;;
;;; IAC ("Interpret As Command") is the Official Telnet Escape Character.
(defconstant +iac+ (code-char 255) "IAC")
;;; IAC Commands.
;;;
;;; These are commands that may be issued or received (with preceding IAC) at
;;; any point in the Telnet stream.
(defconstant +cmd-se+ (code-char 240) "Subnegotiation End")
(defconstant +cmd-nop+ (code-char 241) "No Operation")
(defconstant +cmd-dm+ (code-char 242) "Data Mark")
(defconstant +cmd-break+ (code-char 243) "Break")
(defconstant +cmd-ip+ (code-char 244) "Interrupt Process")
(defconstant +cmd-ao+ (code-char 245) "Abort Output")
(defconstant +cmd-ayt+ (code-char 246) "Are You There?")
(defconstant +cmd-ec+ (code-char 247) "Erase Character")
(defconstant +cmd-el+ (code-char 248) "Erase Line")
(defconstant +cmd-ga+ (code-char 249) "Go Ahead")
(defconstant +cmd-sb+ (code-char 250) "Subnegotiation Begin")
(defconstant +cmd-will+ (code-char 251) "WILL")
(defconstant +cmd-wont+ (code-char 252) "WON'T")
(defconstant +cmd-do+ (code-char 253) "DO")
(defconstant +cmd-dont+ (code-char 254) "DON'T")
(defconstant +cmd-submsg+ (code-char 257) "Subliminal Message")
(defconstant +nvt-exopl+ (code-char 255) "Extended Options List")
;;; Option Codes.
;;;
;;; These are options which may only be received as part of an option
;;; negotiation (ie, preceded by "IAC {DO,DONT,WILL,WONT}").
(defconstant +nvt-echo+ (code-char 1) "Echo")
(defconstant +nvt-supress-go-ahead+ (code-char 3) "Suppress Go Ahead")
(defconstant +nvt-status+ (code-char 5) "Status")
(defconstant +nvt-timing-mark+ (code-char 6) "Timing Mark")
(defconstant +nvt-bell+ (code-char 7) "Bell")
(defconstant +nvt-terminal-type+ (code-char 24) "Terminal Type")
(defconstant +nvt-end-of-record+ (code-char 25) "End of Record")
(defconstant +nvt-ttyloc+ (code-char 26) "Terminal Location Number")
(defconstant +nvt-naws+ (code-char 31) "Negotiate About Window Size")
(defconstant +nvt-terminal-speed+ (code-char 32) "Terminal Speed")
(defconstant +nvt-toggle-flow-ctrl+ (code-char 33) "Toggle Flow Control")
(defconstant +nvt-linemode+ (code-char 34) "Line Mode")
(defconstant +nvt-xdisploc+ (code-char 35) "X Display Location")
(defconstant +nvt-environ+ (code-char 36) "Environment")
(defconstant +nvt-eor+ (code-char 239) "End of Record")
(defconstant +nvt-is+ (code-char 0) "IS")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment