157416Smarkm/* 257416Smarkm * Copyright (c) 1989, 1993 357416Smarkm * The Regents of the University of California. All rights reserved. 457416Smarkm * 557416Smarkm * Redistribution and use in source and binary forms, with or without 657416Smarkm * modification, are permitted provided that the following conditions 757416Smarkm * are met: 857416Smarkm * 1. Redistributions of source code must retain the above copyright 957416Smarkm * notice, this list of conditions and the following disclaimer. 1057416Smarkm * 2. Redistributions in binary form must reproduce the above copyright 1157416Smarkm * notice, this list of conditions and the following disclaimer in the 1257416Smarkm * documentation and/or other materials provided with the distribution. 1357416Smarkm * 3. All advertising materials mentioning features or use of this software 1457416Smarkm * must display the following acknowledgement: 1557416Smarkm * This product includes software developed by the University of 1657416Smarkm * California, Berkeley and its contributors. 1757416Smarkm * 4. Neither the name of the University nor the names of its contributors 1857416Smarkm * may be used to endorse or promote products derived from this software 1957416Smarkm * without specific prior written permission. 2057416Smarkm * 2157416Smarkm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2257416Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2357416Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2457416Smarkm * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2557416Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2657416Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2757416Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2857416Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2957416Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3057416Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3157416Smarkm * SUCH DAMAGE. 3257416Smarkm */ 3357416Smarkm 3457416Smarkm#include "telnetd.h" 3557416Smarkm 36233294SstasRCSID("$Id$"); 3757416Smarkm 3857416Smarkm/* 3957416Smarkm * local variables 4057416Smarkm */ 4157416Smarkmint def_tspeed = -1, def_rspeed = -1; 4257416Smarkm#ifdef TIOCSWINSZ 4357416Smarkmint def_row = 0, def_col = 0; 4457416Smarkm#endif 4557416Smarkm 4657416Smarkm/* 4757416Smarkm * flowstat 4857416Smarkm * 4957416Smarkm * Check for changes to flow control 5057416Smarkm */ 5157416Smarkmvoid 5290926Snectarflowstat(void) 5357416Smarkm{ 5457416Smarkm if (his_state_is_will(TELOPT_LFLOW)) { 5557416Smarkm if (tty_flowmode() != flowmode) { 5657416Smarkm flowmode = tty_flowmode(); 5757416Smarkm output_data("%c%c%c%c%c%c", 5857416Smarkm IAC, SB, TELOPT_LFLOW, 5957416Smarkm flowmode ? LFLOW_ON : LFLOW_OFF, 6057416Smarkm IAC, SE); 6157416Smarkm } 6257416Smarkm if (tty_restartany() != restartany) { 6357416Smarkm restartany = tty_restartany(); 6457416Smarkm output_data("%c%c%c%c%c%c", 6557416Smarkm IAC, SB, TELOPT_LFLOW, 6657416Smarkm restartany ? LFLOW_RESTART_ANY 6757416Smarkm : LFLOW_RESTART_XON, 6857416Smarkm IAC, SE); 6957416Smarkm } 7057416Smarkm } 7157416Smarkm} 7257416Smarkm 7357416Smarkm/* 7457416Smarkm * clientstat 7557416Smarkm * 7657416Smarkm * Process linemode related requests from the client. 7757416Smarkm * Client can request a change to only one of linemode, editmode or slc's 7857416Smarkm * at a time, and if using kludge linemode, then only linemode may be 7957416Smarkm * affected. 8057416Smarkm */ 8157416Smarkmvoid 8257416Smarkmclientstat(int code, int parm1, int parm2) 8357416Smarkm{ 8457416Smarkm /* 8557416Smarkm * Get a copy of terminal characteristics. 8657416Smarkm */ 8757416Smarkm init_termbuf(); 8857416Smarkm 8957416Smarkm /* 9057416Smarkm * Process request from client. code tells what it is. 9157416Smarkm */ 9257416Smarkm switch (code) { 9357416Smarkm case TELOPT_NAWS: 9457416Smarkm#ifdef TIOCSWINSZ 9557416Smarkm { 9657416Smarkm struct winsize ws; 9757416Smarkm 9857416Smarkm def_col = parm1; 9957416Smarkm def_row = parm2; 10057416Smarkm 10157416Smarkm /* 10257416Smarkm * Change window size as requested by client. 10357416Smarkm */ 10457416Smarkm 10557416Smarkm ws.ws_col = parm1; 10657416Smarkm ws.ws_row = parm2; 10757416Smarkm ioctl(ourpty, TIOCSWINSZ, (char *)&ws); 10857416Smarkm } 10957416Smarkm#endif /* TIOCSWINSZ */ 11057416Smarkm 11157416Smarkm break; 11257416Smarkm 11357416Smarkm case TELOPT_TSPEED: 11457416Smarkm { 11557416Smarkm def_tspeed = parm1; 11657416Smarkm def_rspeed = parm2; 11757416Smarkm /* 11857416Smarkm * Change terminal speed as requested by client. 11957416Smarkm * We set the receive speed first, so that if we can't 12057416Smarkm * store seperate receive and transmit speeds, the transmit 12157416Smarkm * speed will take precedence. 12257416Smarkm */ 12357416Smarkm tty_rspeed(parm2); 12457416Smarkm tty_tspeed(parm1); 12557416Smarkm set_termbuf(); 12657416Smarkm 12757416Smarkm break; 12857416Smarkm 12957416Smarkm } /* end of case TELOPT_TSPEED */ 13057416Smarkm 13157416Smarkm default: 13257416Smarkm /* What? */ 13357416Smarkm break; 13457416Smarkm } /* end of switch */ 13557416Smarkm 13657416Smarkm netflush(); 13757416Smarkm 13857416Smarkm} 139