Telnet.cci
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief Telnet inline non-template implementation */
16 
17 //#include "Telnet.ih"
18 
19 // Custom includes
20 
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::term::BaseTelnetProtocol::OptInfo
26 
27 prefix_ senf::term::BaseTelnetProtocol::OptInfo::OptInfo()
28  : local (false), option (0u), wantState (DISABLED), optionState (NONE), enabled (false)
29 {}
30 
31 prefix_ senf::term::BaseTelnetProtocol::OptInfo::OptInfo(bool l, option_type o)
32  : local (l), option (o), wantState (DISABLED), optionState (NONE), enabled (false)
33 {}
34 
35 //-/////////////////////////////////////////////////////////////////////////////////////////////////
36 // senf::term::BaseTelnetProtocol::TelnetHandler
37 
38 prefix_ senf::term::BaseTelnetProtocol::TelnetHandler::~TelnetHandler()
39 {}
40 
41 prefix_ std::string const & senf::term::telnethandler::TerminalType::terminalType()
42  const
43 {
44  return type_;
45 }
46 
47 //-/////////////////////////////////////////////////////////////////////////////////////////////////
48 // senf::term::telnethandler::NAWS
49 
50 prefix_ unsigned senf::term::telnethandler::NAWS::width()
51  const
52 {
53  return width_;
54 }
55 
56 prefix_ unsigned senf::term::telnethandler::NAWS::height()
57  const
58 {
59  return height_;
60 }
61 
62 //-/////////////////////////////////////////////////////////////////////////////////////////////////
63 // senf::term::BaseTelnetProtocol
64 
65 prefix_ senf::term::BaseTelnetProtocol::~BaseTelnetProtocol()
66 {}
67 
68 prefix_ senf::term::BaseTelnetProtocol::Handle senf::term::BaseTelnetProtocol::handle()
69 {
70  return handle_;
71 }
72 
73 prefix_ bool senf::term::BaseTelnetProtocol::requestsPending()
74 {
75  return pendingRequests_ > 0u;
76 }
77 
78 prefix_ void senf::term::BaseTelnetProtocol::sendNOP()
79 {
80  transmit(CMD_IAC);
81  transmit(CMD_NOP);
82 }
83 
84 prefix_ void senf::term::BaseTelnetProtocol::sendBRK()
85 {
86  transmit(CMD_IAC);
87  transmit(CMD_BRK);
88 }
89 
90 prefix_ void senf::term::BaseTelnetProtocol::sendIP()
91 {
92  transmit(CMD_IAC);
93  transmit(CMD_IP);
94 }
95 
96 prefix_ void senf::term::BaseTelnetProtocol::sendAO()
97 {
98  transmit(CMD_IAC);
99  transmit(CMD_AO);
100 }
101 
102 prefix_ void senf::term::BaseTelnetProtocol::sendAYT()
103 {
104  transmit(CMD_IAC);
105  transmit(CMD_AYT);
106 }
107 
108 prefix_ void senf::term::BaseTelnetProtocol::sendEC()
109 {
110  transmit(CMD_IAC);
111  transmit(CMD_EC);
112 }
113 
114 prefix_ void senf::term::BaseTelnetProtocol::sendEL()
115 {
116  transmit(CMD_IAC);
117  transmit(CMD_EL);
118 }
119 
120 prefix_ void senf::term::BaseTelnetProtocol::sendGA()
121 {
122  transmit(CMD_IAC);
123  transmit(CMD_GA);
124 }
125 
126 prefix_ void senf::term::BaseTelnetProtocol::requestLocalOption(option_type option,
127  bool enabled)
128 {
129  request(getOption(true, option), enabled);
130 }
131 
132 prefix_ void senf::term::BaseTelnetProtocol::acceptLocalOption(option_type option,
133  bool enabled)
134 {
135  getOption(true, option).wantState = OptInfo::ACCEPTED;
136 }
137 
138 prefix_ void senf::term::BaseTelnetProtocol::requestPeerOption(option_type option,
139  bool enabled)
140 {
141  request(getOption(false, option), enabled);
142 }
143 
144 prefix_ void senf::term::BaseTelnetProtocol::acceptPeerOption(option_type option,
145  bool enabled)
146 {
147  getOption(false, option).wantState = OptInfo::ACCEPTED;
148 }
149 
150 prefix_ bool senf::term::BaseTelnetProtocol::localOption(option_type option)
151 {
152  return getOption(true, option).enabled;
153 }
154 
155 prefix_ bool senf::term::BaseTelnetProtocol::peerOption(option_type option)
156 {
157  return getOption(false, option).enabled;
158 }
159 
160 prefix_ void senf::term::BaseTelnetProtocol::emit(char c)
161 {
162  v_charReceived(c);
163 }
164 
165 //-/////////////////////////////////////////////////////////////////////////////////////////////////
166 #undef prefix_
167 
168 
169 // Local Variables:
170 // mode: c++
171 // fill-column: 100
172 // comment-column: 40
173 // c-file-style: "senf"
174 // indent-tabs-mode: nil
175 // ispell-local-dictionary: "american"
176 // compile-command: "scons -u test"
177 // End: