Skip to content
Snippets Groups Projects
Commit e2400f8f authored by g0dil's avatar g0dil
Browse files

Utils/Console: Small code cleanup in telnet implementation

parent 0b84d744
No related branches found
No related tags found
No related merge requests found
...@@ -399,18 +399,14 @@ prefix_ void senf::console::detail::BaseTelnetProtocol::response(OptInfo & info, ...@@ -399,18 +399,14 @@ prefix_ void senf::console::detail::BaseTelnetProtocol::response(OptInfo & info,
} }
else if (enabled != info.enabled) { else if (enabled != info.enabled) {
// Request to change the current state // Request to change the current state
bool accept (enabled);
if (!enabled || if (!enabled ||
enabled && (info.wantState == OptInfo::WANTED || info.wantState == OptInfo::ACCEPTED)) { enabled && (info.wantState == OptInfo::WANTED || info.wantState == OptInfo::ACCEPTED)) {
// Accept the request // accept the request
info.optionState = OptInfo::ACKNOWLEDGED; info.optionState = OptInfo::ACKNOWLEDGED;
info.enabled = enabled; info.enabled = enabled;
} } // else reject the request
else
// Reject the request
accept = info.enabled;
transmit(CMD_IAC); transmit(CMD_IAC);
transmit((info.local ? CMD_WILL : CMD_DO) + (accept ? 0 : 1)); transmit((info.local ? CMD_WILL : CMD_DO) + (info.enabled ? 0 : 1));
transmit(info.option); transmit(info.option);
} }
else else
...@@ -421,8 +417,8 @@ prefix_ void senf::console::detail::BaseTelnetProtocol::response(OptInfo & info, ...@@ -421,8 +417,8 @@ prefix_ void senf::console::detail::BaseTelnetProtocol::response(OptInfo & info,
i->second->v_init(); i->second->v_init();
} }
if (decrementCount) if (decrementCount)
// This call must be AFTER calling v_init since v_init might increment the request count // This call must be AFTER calling v_init since v_init might increment the request count.
// again. Otherwise v_setupComplete might be called prematurely // and v_setupComplete() might be called prematurely.
decrementRequestCounter(); decrementRequestCounter();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment