isdn4linux-web/workshop/linklevel/isdn_tty.c.shtml

3952 lines
200 KiB
Plaintext

<HTML>
<!-- Generated by c2html-1.0, Copyright 1998 by Dave Whittington -->
<HEAD>
<TITLE>isdn_tty.c</TITLE>
<!--#include virtual="/ssi/js.shtml" -->
<!--#include virtual="/ssi/buttondefs.shtml" -->
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<TABLE WIDTH="100%">
<TR>
<TD ALIGN=LEFT WIDTH="90"><!--#include virtual="/ssi/b_home.shtml" --></TD>
<TD ALIGN=RIGHT WIDTH="90"><!--#include virtual="/ssi/b_index.shtml" --></TD>
</TR>
</TABLE>
<CENTER><H1>isdn_tty.c</H1></CENTER>
<HR>
<PRE>
<FONT COLOR=#0000FF>/* $Id$
* Linux ISDN subsystem, tty functions and AT-command emulator (linklevel).
*
* Copyright 1994,95,96 by Fritz Elfert (fritz@wuemaus.franken.de)
* Copyright 1995,96 by Thinking Objects Software GmbH Wuerzburg
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log$
* Revision 1.57 1998/06/26 15:12:36 fritz
* Added handling of STAT_ICALL with incomplete CPN.
* Added AT&amp;L for ttyI emulator.
* Added more locking stuff in tty_write.
*
* Revision 1.56 1998/06/18 23:31:51 fritz
* Replaced cli()/restore_flags() in isdn_tty_write() by locking.
* Removed direct-senddown feature in isdn_tty_write because it will
* never succeed with locking and is useless anyway.
*
* Revision 1.55 1998/06/17 19:50:55 he
* merged with 2.1.10[34] (cosmetics and udelay() -&gt; mdelay())
* brute force fix to avoid Ugh's in isdn_tty_write()
* cleaned up some dead code
*
* Revision 1.54 1998/06/07 00:20:13 fritz
* abc cleanup.
*
* Revision 1.53 1998/06/02 12:10:16 detabc
* wegen einer einstweiliger verfuegung gegen DW ist zur zeit
* die abc-extension bis zur klaerung der rechtslage nicht verfuegbar
*
* Revision 1.52 1998/03/19 13:18:21 keil
* Start of a CAPI like interface for supplementary Service
* first service: SUSPEND
*
* Revision 1.51 1998/03/08 14:26:11 detabc
* change kfree_skb to dev_kfree_skb
* remove SET_SKB_FREE
*
* Revision 1.50 1998/03/08 13:14:28 detabc
* abc-extension support for kernels &gt; 2.1.x
* first try (sorry experimental)
*
* Revision 1.49 1998/03/08 00:01:59 fritz
* Bugfix: Lowlevel module usage and channel usage were not
* reset on NO DCHANNEL.
*
* Revision 1.48 1998/03/07 12:28:15 tsbogend
* fixed kernel unaligned traps on Linux/Alpha
*
* Revision 1.47 1998/02/22 19:44:14 fritz
* Bugfixes and improvements regarding V.110, V.110 now running.
*
* Revision 1.46 1998/02/20 17:23:08 fritz
* Changes for recent kernels.
* Merged in contributions by Thomas Pfeiffer (V.110 T.70+ Extended FAX stuff)
* Added symbolic constants for Modem-Registers.
*
* Revision 1.45 1998/01/31 22:07:49 keil
* changes for newer kernels
*
* Revision 1.44 1998/01/31 19:30:02 calle
* Merged changes from and for 2.1.82, not tested only compiled ...
*
* Revision 1.43 1997/10/09 21:29:04 fritz
* New HL&lt;-&gt;LL interface:
* New BSENT callback with nr. of bytes included.
* Sending without ACK.
* New L1 error status (not yet in use).
* Cleaned up obsolete structures.
* Implemented Cisco-SLARP.
* Changed local net-interface data to be dynamically allocated.
* Removed old 2.0 compatibility stuff.
*
* Revision 1.42 1997/10/01 09:20:49 fritz
* Removed old compatibility stuff for 2.0.X kernels.
* From now on, this code is for 2.1.X ONLY!
* Old stuff is still in the separate branch.
*
* Revision 1.41 1997/05/27 15:17:31 fritz
* Added changes for recent 2.1.x kernels:
* changed return type of isdn_close
* queue_task_* -&gt; queue_task
* clear/set_bit -&gt; test_and_... where apropriate.
* changed type of hard_header_cache parameter.
*
* Revision 1.40 1997/03/24 22:55:27 fritz
* Added debug code for status callbacks.
*
* Revision 1.39 1997/03/21 18:25:56 fritz
* Corrected CTS handling.
*
* Revision 1.38 1997/03/07 12:13:35 fritz
* Bugfix: Send audio in adpcm format was broken.
* Bugfix: CTS handling was wrong.
*
* Revision 1.37 1997/03/07 01:37:34 fritz
* Bugfix: Did not compile with CONFIG_ISDN_AUDIO disabled.
* Bugfix: isdn_tty_tint() did not handle lowlevel errors correctly.
* Bugfix: conversion was wrong when sending ulaw audio.
* Added proper ifdef's for CONFIG_ISDN_AUDIO
*
* Revision 1.36 1997/03/04 21:41:55 fritz
* Fix: Excessive stack usage of isdn_tty_senddown()
* and isdn_tty_end_vrx() could lead to problems.
*
* Revision 1.35 1997/03/02 19:05:52 fritz
* Bugfix: Avoid recursion.
*
* Revision 1.34 1997/03/02 14:29:22 fritz
* More ttyI related cleanup.
*
* Revision 1.33 1997/02/28 02:32:45 fritz
* Cleanup: Moved some tty related stuff from isdn_common.c
* to isdn_tty.c
* Bugfix: Bisync protocol did not behave like documented.
*
* Revision 1.32 1997/02/23 15:43:03 fritz
* Small change in handling of incoming calls
* documented in newest version of ttyI.4
*
* Revision 1.31 1997/02/21 13:05:57 fritz
* Bugfix: Remote hangup did not set location-info on ttyI's
*
* Revision 1.30 1997/02/18 09:41:05 fritz
* Added support for bitwise access to modem registers (ATSx.y=n, ATSx.y?).
* Beautified output of AT&amp;V.
*
* Revision 1.29 1997/02/16 12:11:51 fritz
* Added S13,Bit4 option.
*
* Revision 1.28 1997/02/10 22:07:08 fritz
* Added 2 modem registers for numbering plan and screening info.
*
* Revision 1.27 1997/02/10 21:31:14 fritz
* Changed setup-interface (incoming and outgoing).
*
* Revision 1.26 1997/02/10 20:12:48 fritz
* Changed interface for reporting incoming calls.
*
* Revision 1.25 1997/02/03 23:04:30 fritz
* Reformatted according CodingStyle.
* skb-&gt;free stuff replaced by macro.
* Finished full-duplex audio.
*
* Revision 1.24 1997/01/14 01:32:42 fritz
* Changed audio receive not to rely on skb-&gt;users and skb-&gt;lock.
* Added ATI2 and related variables.
* Started adding full-duplex audio capability.
*
* Revision 1.23 1996/10/22 23:14:02 fritz
* Changes for compatibility to 2.0.X and 2.1.X kernels.
*
* Revision 1.22 1996/10/19 18:56:43 fritz
* ATZ did not change the xmitbuf size.
*
* Revision 1.21 1996/06/24 17:40:28 fritz
* Bugfix: Did not compile without CONFIG_ISDN_AUDIO
*
* Revision 1.20 1996/06/15 14:59:39 fritz
* Fixed isdn_tty_tint() to handle partially sent
* sk_buffs.
*
* Revision 1.19 1996/06/12 15:53:56 fritz
* Bugfix: AT+VTX and AT+VRX could be executed without
* having a connection.
* Missing check for NULL tty in isdn_tty_flush_buffer().
*
* Revision 1.18 1996/06/07 11:17:33 tsbogend
* added missing #ifdef CONFIG_ISDN_AUDIO to make compiling without
* audio support possible
*
* Revision 1.17 1996/06/06 14:55:47 fritz
* Changed to support DTMF decoding on audio playback also.
* Bugfix: Added check for invalid info-&gt;isdn_driver in
* isdn_tty_senddown().
* Clear ncarrier flag on last close() of a tty.
*
* Revision 1.16 1996/06/05 02:24:12 fritz
* Added DTMF decoder for audio mode.
*
* Revision 1.15 1996/06/03 20:35:01 fritz
* Fixed typos.
*
* Revision 1.14 1996/06/03 20:12:19 fritz
* Fixed typos.
* Added call to write_wakeup via isdn_tty_flush_buffer()
* in isdn_tty_modem_hup().
*
* Revision 1.13 1996/05/31 01:33:29 fritz
* Changed buffering due to bad performance with mgetty.
* Now sk_buff is delayed allocated in isdn_tty_senddown
* using xmit_buff like in standard serial driver.
* Fixed module locking.
* Added DLE-DC4 handling in voice mode.
*
* Revision 1.12 1996/05/19 01:34:40 fritz
* Bugfix: ATS returned error.
* Register 20 made readonly.
*
* Revision 1.11 1996/05/18 01:37:03 fritz
* Added spelling corrections and some minor changes
* to stay in sync with kernel.
*
* Revision 1.10 1996/05/17 03:51:49 fritz
* Changed DLE handling for audio receive.
*
* Revision 1.9 1996/05/11 21:52:07 fritz
* Changed queue management to use sk_buffs.
*
* Revision 1.8 1996/05/10 08:49:43 fritz
* Checkin before major changes of tty-code.
*
* Revision 1.7 1996/05/07 09:15:09 fritz
* Reorganized and general cleanup.
* Bugfixes:
* - Audio-transmit working now.
* - "NO CARRIER" now reported, when hanging up with DTR low.
* - Corrected CTS handling.
*
* Revision 1.6 1996/05/02 03:59:25 fritz
* Bugfixes:
* - On dialout, layer-2 setup had been incomplete
* when using new auto-layer2 feature.
* - On hangup, "NO CARRIER" message sometimes missing.
*
* Revision 1.5 1996/04/30 21:05:25 fritz
* Test commit
*
* Revision 1.4 1996/04/20 16:39:54 fritz
* Changed all io to go through generic routines in isdn_common.c
* Fixed a real ugly bug in modem-emulator: 'ATA' had been accepted
* even when a call has been cancelled from the remote machine.
*
* Revision 1.3 1996/02/11 02:12:32 fritz
* Bugfixes according to similar fixes in standard serial.c of kernel.
*
* Revision 1.2 1996/01/22 05:12:25 fritz
* replaced my_atoi by simple_strtoul
*
* Revision 1.1 1996/01/09 04:13:18 fritz
* Initial revision
*
*/</FONT>
<FONT COLOR=#A521F7>#undef</FONT> ISDN_TTY_STAT_DEBUG
<FONT COLOR=#A521F7>#define</FONT> <A HREF="isdn_audio.c.shtml#__NO_VERSION__">__NO_VERSION__</A>
<FONT COLOR=#A521F7>#include</FONT> &lt;linux/config.h&gt;
<FONT COLOR=#A521F7>#include</FONT> &lt;linux/module.h&gt;
<FONT COLOR=#A521F7>#include</FONT> &lt;linux/isdn.h&gt;
<FONT COLOR=#A521F7>#include</FONT> <FONT COLOR="#FF0000">"isdn_common.h"</FONT>
<FONT COLOR=#A521F7>#include</FONT> <FONT COLOR="#FF0000">"isdn_tty.h"</FONT>
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR=#A521F7>#include</FONT> <FONT COLOR="#FF0000">"isdn_audio.h"</FONT>
<FONT COLOR=#A521F7>#define</FONT> <A NAME="VBUF">VBUF</A> 0x3e0
<FONT COLOR=#A521F7>#define</FONT> <A NAME="VBUFX">VBUFX</A> (<A HREF="#VBUF">VBUF</A>/16)
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR=#A521F7>#define</FONT> <A NAME="FIX_FILE_TRANSFER">FIX_FILE_TRANSFER</A>
<FONT COLOR=#0000FF>/* Prototypes */</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT> <A HREF="#isdn_tty_edit_at">isdn_tty_edit_at</A>(<FONT COLOR="#298C52">const</FONT> <FONT COLOR="#298C52">char</FONT> *, <FONT COLOR="#298C52">int</FONT>, <A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *, <FONT COLOR="#298C52">int</FONT>);
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT> <A HREF="#isdn_tty_check_esc">isdn_tty_check_esc</A>(<FONT COLOR="#298C52">const</FONT> u_char *, u_char, <FONT COLOR="#298C52">int</FONT>, <FONT COLOR="#298C52">int</FONT> *, <FONT COLOR="#298C52">int</FONT> *, <FONT COLOR="#298C52">int</FONT>);
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT> <A HREF="#isdn_tty_modem_reset_regs">isdn_tty_modem_reset_regs</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *, <FONT COLOR="#298C52">int</FONT>);
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT> <A HREF="#isdn_tty_cmd_ATA">isdn_tty_cmd_ATA</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *);
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT> <A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#298C52">char</FONT> *, <A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *);
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT> <A HREF="#isdn_tty_flush_buffer">isdn_tty_flush_buffer</A>(<FONT COLOR="#298C52">struct</FONT> tty_struct *);
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT> <A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(<FONT COLOR="#298C52">int</FONT>, <A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *);
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT> <A HREF="#isdn_tty_countDLE">isdn_tty_countDLE</A>(<FONT COLOR="#298C52">unsigned</FONT> <FONT COLOR="#298C52">char</FONT> *, <FONT COLOR="#298C52">int</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR=#0000FF>/* Leave this unchanged unless you know what you do! */</FONT>
<FONT COLOR=#A521F7>#define</FONT> <A NAME="MODEM_PARANOIA_CHECK">MODEM_PARANOIA_CHECK</A>
<FONT COLOR=#A521F7>#define</FONT> <A NAME="MODEM_DO_RESTART">MODEM_DO_RESTART</A>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">char</FONT> *isdn_ttyname_ttyI = <FONT COLOR="#FF0000">"ttyI"</FONT>;
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">char</FONT> *isdn_ttyname_cui = <FONT COLOR="#FF0000">"cui"</FONT>;
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT> bit2si[8] =
{1, 5, 7, 7, 7, 7, 7, 7};
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT> si2bit[8] =
{4, 1, 4, 4, 4, 4, 4, 4};
<FONT COLOR="#298C52">char</FONT> *isdn_tty_revision = <FONT COLOR="#FF0000">"$Revision$"</FONT>;
<FONT COLOR=#A521F7>#define</FONT> <A HREF="isdn_common.c.shtml#DLE">DLE</A> 0x10
<FONT COLOR=#A521F7>#define</FONT> <A NAME="ETX">ETX</A> 0x03
<FONT COLOR=#A521F7>#define</FONT> <A NAME="DC4">DC4</A> 0x14
<FONT COLOR=#0000FF>/*
* Definition of some special Registers of AT-Emulator
*/</FONT>
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_RINGATA">REG_RINGATA</A> 0
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_RINGCNT">REG_RINGCNT</A> 1
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_ESC">REG_ESC</A> 2
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_CR">REG_CR</A> 3
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_LF">REG_LF</A> 4
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_BS">REG_BS</A> 5
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_RESP">REG_RESP</A> 12
<FONT COLOR=#A521F7>#define</FONT> <A NAME="BIT_RESP">BIT_RESP</A> 1
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_RESPNUM">REG_RESPNUM</A> 12
<FONT COLOR=#A521F7>#define</FONT> <A NAME="BIT_RESPNUM">BIT_RESPNUM</A> 2
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_ECHO">REG_ECHO</A> 12
<FONT COLOR=#A521F7>#define</FONT> <A NAME="BIT_ECHO">BIT_ECHO</A> 4
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_DCD">REG_DCD</A> 12
<FONT COLOR=#A521F7>#define</FONT> <A NAME="BIT_DCD">BIT_DCD</A> 8
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_CTS">REG_CTS</A> 12
<FONT COLOR=#A521F7>#define</FONT> <A NAME="BIT_CTS">BIT_CTS</A> 16
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_DTRR">REG_DTRR</A> 12
<FONT COLOR=#A521F7>#define</FONT> <A NAME="BIT_DTRR">BIT_DTRR</A> 32
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_DSR">REG_DSR</A> 12
<FONT COLOR=#A521F7>#define</FONT> <A NAME="BIT_DSR">BIT_DSR</A> 64
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_CPPP">REG_CPPP</A> 12
<FONT COLOR=#A521F7>#define</FONT> <A NAME="BIT_CPPP">BIT_CPPP</A> 128
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_T70">REG_T70</A> 13
<FONT COLOR=#A521F7>#define</FONT> <A NAME="BIT_T70">BIT_T70</A> 2
<FONT COLOR=#A521F7>#define</FONT> <A NAME="BIT_T70_EXT">BIT_T70_EXT</A> 32
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_DTRHUP">REG_DTRHUP</A> 13
<FONT COLOR=#A521F7>#define</FONT> <A NAME="BIT_DTRHUP">BIT_DTRHUP</A> 4
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_RESPXT">REG_RESPXT</A> 13
<FONT COLOR=#A521F7>#define</FONT> <A NAME="BIT_RESPXT">BIT_RESPXT</A> 8
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_CIDONCE">REG_CIDONCE</A> 13
<FONT COLOR=#A521F7>#define</FONT> <A NAME="BIT_CIDONCE">BIT_CIDONCE</A> 16
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_RUNG">REG_RUNG</A> 13
<FONT COLOR=#A521F7>#define</FONT> <A NAME="BIT_RUNG">BIT_RUNG</A> 64
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_RESRXT">REG_RESRXT</A> 13
<FONT COLOR=#A521F7>#define</FONT> <A NAME="BIT_RESRXT">BIT_RESRXT</A> 128
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_L2PROT">REG_L2PROT</A> 14
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_L3PROT">REG_L3PROT</A> 15
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_PSIZE">REG_PSIZE</A> 16
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_WSIZE">REG_WSIZE</A> 17
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_SI1">REG_SI1</A> 18
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_SI2">REG_SI2</A> 19
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_SI1I">REG_SI1I</A> 20
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_PLAN">REG_PLAN</A> 21
<FONT COLOR=#A521F7>#define</FONT> <A NAME="REG_SCREEN">REG_SCREEN</A> 22
<FONT COLOR=#0000FF>/* isdn_tty_try_read() is called from within isdn_tty_rcv_skb()
* to stuff incoming data directly into a tty's flip-buffer. This
* is done to speed up tty-receiving if the receive-queue is empty.
* This routine MUST be called with interrupts off.
* Return:
* 1 = Success
* 0 = Failure, data has to be buffered and later processed by
* isdn_tty_readmodem().
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A HREF="#isdn_tty_try_read">isdn_tty_try_read</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info, <FONT COLOR="#298C52">struct</FONT> sk_buff *skb)
{
<FONT COLOR="#298C52">int</FONT> c;
<FONT COLOR="#298C52">int</FONT> len;
<FONT COLOR="#298C52">struct</FONT> tty_struct *tty;
<FONT COLOR="#298C52">if</FONT> (info-&gt;online) {
<FONT COLOR="#298C52">if</FONT> ((tty = info-&gt;tty)) {
<FONT COLOR="#298C52">if</FONT> (info-&gt;mcr &amp; UART_MCR_RTS) {
c = TTY_FLIPBUF_SIZE - tty-&gt;flip.count;
len = skb-&gt;len
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
+ <A HREF="../includes/isdn.h.shtml#ISDN_AUDIO_SKB_DLECOUNT">ISDN_AUDIO_SKB_DLECOUNT</A>(skb)
<FONT COLOR=#A521F7>#endif</FONT>
;
<FONT COLOR="#298C52">if</FONT> (c &gt;= len) {
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">if</FONT> (<A HREF="../includes/isdn.h.shtml#ISDN_AUDIO_SKB_DLECOUNT">ISDN_AUDIO_SKB_DLECOUNT</A>(skb))
<FONT COLOR="#298C52">while</FONT> (skb-&gt;len--) {
<FONT COLOR="#298C52">if</FONT> (*skb-&gt;data == <A HREF="isdn_common.c.shtml#DLE">DLE</A>)
tty_insert_flip_char(tty, <A HREF="isdn_common.c.shtml#DLE">DLE</A>, 0);
tty_insert_flip_char(tty, *skb-&gt;data++, 0);
} <FONT COLOR="#298C52">else</FONT> {
<FONT COLOR=#A521F7>#endif</FONT>
memcpy(tty-&gt;flip.char_buf_ptr,
skb-&gt;data, len);
tty-&gt;flip.count += len;
tty-&gt;flip.char_buf_ptr += len;
memset(tty-&gt;flip.flag_buf_ptr, 0, len);
tty-&gt;flip.flag_buf_ptr += len;
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
}
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (info-&gt;emu.mdmreg[<A HREF="#REG_CPPP">REG_CPPP</A>] &amp; <A HREF="#BIT_CPPP">BIT_CPPP</A>)
tty-&gt;flip.flag_buf_ptr[len - 1] = 0xff;
queue_task(&amp;tty-&gt;flip.tqueue, &amp;tq_timer);
kfree_skb(skb);
<FONT COLOR="#298C52">return</FONT> 1;
}
}
}
}
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR=#0000FF>/* isdn_tty_readmodem() is called periodically from within timer-interrupt.
* It tries getting received data from the receive queue an stuff it into
* the tty's flip-buffer.
*/</FONT>
<FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_readmodem">isdn_tty_readmodem</A>(<FONT COLOR="#298C52">void</FONT>)
{
<FONT COLOR="#298C52">int</FONT> resched = 0;
<FONT COLOR="#298C52">int</FONT> midx;
<FONT COLOR="#298C52">int</FONT> i;
<FONT COLOR="#298C52">int</FONT> c;
<FONT COLOR="#298C52">int</FONT> r;
ulong flags;
<FONT COLOR="#298C52">struct</FONT> tty_struct *tty;
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info;
<FONT COLOR="#298C52">for</FONT> (i = 0; i &lt; <A HREF="../includes/isdn.h.shtml#ISDN_MAX_CHANNELS">ISDN_MAX_CHANNELS</A>; i++) {
<FONT COLOR="#298C52">if</FONT> ((midx = dev-&gt;m_idx[i]) &gt;= 0) {
info = &amp;dev-&gt;mdm.info[midx];
<FONT COLOR="#298C52">if</FONT> (info-&gt;online) {
r = 0;
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<A HREF="isdn_audio.c.shtml#isdn_audio_eval_dtmf">isdn_audio_eval_dtmf</A>(info);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> ((tty = info-&gt;tty)) {
<FONT COLOR="#298C52">if</FONT> (info-&gt;mcr &amp; UART_MCR_RTS) {
c = TTY_FLIPBUF_SIZE - tty-&gt;flip.count;
<FONT COLOR="#298C52">if</FONT> (c &gt; 0) {
save_flags(flags);
<A HREF="kdebug.h.shtml#cli">cli</A>();
r = <A HREF="isdn_common.c.shtml#isdn_readbchan">isdn_readbchan</A>(info-&gt;isdn_driver, info-&gt;isdn_channel,
tty-&gt;flip.char_buf_ptr,
tty-&gt;flip.flag_buf_ptr, c, 0);
<FONT COLOR=#0000FF>/* CISCO AsyncPPP Hack */</FONT>
<FONT COLOR="#298C52">if</FONT> (!(info-&gt;emu.mdmreg[<A HREF="#REG_CPPP">REG_CPPP</A>] &amp; <A HREF="#BIT_CPPP">BIT_CPPP</A>))
memset(tty-&gt;flip.flag_buf_ptr, 0, r);
tty-&gt;flip.count += r;
tty-&gt;flip.flag_buf_ptr += r;
tty-&gt;flip.char_buf_ptr += r;
<FONT COLOR="#298C52">if</FONT> (r)
queue_task(&amp;tty-&gt;flip.tqueue, &amp;tq_timer);
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
}
} <FONT COLOR="#298C52">else</FONT>
r = 1;
} <FONT COLOR="#298C52">else</FONT>
r = 1;
<FONT COLOR="#298C52">if</FONT> (r) {
info-&gt;rcvsched = 0;
resched = 1;
} <FONT COLOR="#298C52">else</FONT>
info-&gt;rcvsched = 1;
}
}
}
<FONT COLOR="#298C52">if</FONT> (!resched)
<A HREF="isdn_common.c.shtml#isdn_timer_ctrl">isdn_timer_ctrl</A>(<A HREF="../includes/isdn.h.shtml#ISDN_TIMER_MODEMREAD">ISDN_TIMER_MODEMREAD</A>, 0);
}
<FONT COLOR="#298C52">int</FONT>
<A HREF="#isdn_tty_rcv_skb">isdn_tty_rcv_skb</A>(<FONT COLOR="#298C52">int</FONT> i, <FONT COLOR="#298C52">int</FONT> di, <FONT COLOR="#298C52">int</FONT> channel, <FONT COLOR="#298C52">struct</FONT> sk_buff *skb)
{
ulong flags;
<FONT COLOR="#298C52">int</FONT> midx;
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">int</FONT> ifmt;
<FONT COLOR=#A521F7>#endif</FONT>
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info;
<FONT COLOR="#298C52">if</FONT> ((midx = dev-&gt;m_idx[i]) &lt; 0) {
<FONT COLOR=#0000FF>/* if midx is invalid, packet is not for tty */</FONT>
<FONT COLOR="#298C52">return</FONT> 0;
}
info = &amp;dev-&gt;mdm.info[midx];
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
ifmt = 1;
<FONT COLOR="#298C52">if</FONT> (info-&gt;vonline)
<A HREF="isdn_audio.c.shtml#isdn_audio_calc_dtmf">isdn_audio_calc_dtmf</A>(info, skb-&gt;data, skb-&gt;len, ifmt);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> ((info-&gt;online &lt; 2)
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
&amp;&amp; (!(info-&gt;vonline &amp; 1))
<FONT COLOR=#A521F7>#endif</FONT>
) {
<FONT COLOR=#0000FF>/* If Modem not listening, drop data */</FONT>
kfree_skb(skb);
<FONT COLOR="#298C52">return</FONT> 1;
}
<FONT COLOR="#298C52">if</FONT> (info-&gt;emu.mdmreg[<A HREF="#REG_T70">REG_T70</A>] &amp; <A HREF="#BIT_T70">BIT_T70</A>) {
<FONT COLOR="#298C52">if</FONT> (info-&gt;emu.mdmreg[<A HREF="#REG_T70">REG_T70</A>] &amp; <A HREF="#BIT_T70_EXT">BIT_T70_EXT</A>) {
<FONT COLOR=#0000FF>/* T.70 decoding: throw away the T.70 header (2 or 4 bytes) */</FONT>
<FONT COLOR="#298C52">if</FONT> (skb-&gt;data[0] == 3) <FONT COLOR=#0000FF>/* pure data packet -&gt; 4 byte headers */</FONT>
skb_pull(skb, 4);
<FONT COLOR="#298C52">else</FONT>
<FONT COLOR="#298C52">if</FONT> (skb-&gt;data[0] == 1) <FONT COLOR=#0000FF>/* keepalive packet -&gt; 2 byte hdr */</FONT>
skb_pull(skb, 2);
} <FONT COLOR="#298C52">else</FONT>
<FONT COLOR=#0000FF>/* T.70 decoding: Simply throw away the T.70 header (4 bytes) */</FONT>
<FONT COLOR="#298C52">if</FONT> ((skb-&gt;data[0] == 1) &amp;&amp; ((skb-&gt;data[1] == 0) || (skb-&gt;data[1] == 1)))
skb_pull(skb, 4);
}
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">if</FONT> (skb_headroom(skb) &lt; <FONT COLOR="#298C52">sizeof</FONT>(<A HREF="../includes/isdn.h.shtml#isdn_audio_skb">isdn_audio_skb</A>)) {
printk(KERN_WARNING
<FONT COLOR="#FF0000">"isdn_audio: insufficient skb_headroom, dropping\n"</FONT>);
kfree_skb(skb);
<FONT COLOR="#298C52">return</FONT> 1;
}
<A HREF="../includes/isdn.h.shtml#ISDN_AUDIO_SKB_DLECOUNT">ISDN_AUDIO_SKB_DLECOUNT</A>(skb) = 0;
<A HREF="../includes/isdn.h.shtml#ISDN_AUDIO_SKB_LOCK">ISDN_AUDIO_SKB_LOCK</A>(skb) = 0;
<FONT COLOR="#298C52">if</FONT> (info-&gt;vonline &amp; 1) {
<FONT COLOR=#0000FF>/* voice conversion/compression */</FONT>
<FONT COLOR="#298C52">switch</FONT> (info-&gt;emu.vpar[3]) {
<FONT COLOR="#298C52">case</FONT> 2:
<FONT COLOR="#298C52">case</FONT> 3:
<FONT COLOR="#298C52">case</FONT> 4:
<FONT COLOR=#0000FF>/* adpcm
* Since compressed data takes less
* space, we can overwrite the buffer.
*/</FONT>
skb_trim(skb, <A HREF="isdn_audio.c.shtml#isdn_audio_xlaw2adpcm">isdn_audio_xlaw2adpcm</A>(info-&gt;adpcmr,
ifmt,
skb-&gt;data,
skb-&gt;data,
skb-&gt;len));
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 5:
<FONT COLOR=#0000FF>/* a-law */</FONT>
<FONT COLOR="#298C52">if</FONT> (!ifmt)
<A HREF="isdn_audio.c.shtml#isdn_audio_ulaw2alaw">isdn_audio_ulaw2alaw</A>(skb-&gt;data, skb-&gt;len);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 6:
<FONT COLOR=#0000FF>/* u-law */</FONT>
<FONT COLOR="#298C52">if</FONT> (ifmt)
<A HREF="isdn_audio.c.shtml#isdn_audio_alaw2ulaw">isdn_audio_alaw2ulaw</A>(skb-&gt;data, skb-&gt;len);
<FONT COLOR="#298C52">break</FONT>;
}
<A HREF="../includes/isdn.h.shtml#ISDN_AUDIO_SKB_DLECOUNT">ISDN_AUDIO_SKB_DLECOUNT</A>(skb) =
<A HREF="#isdn_tty_countDLE">isdn_tty_countDLE</A>(skb-&gt;data, skb-&gt;len);
}
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR=#0000FF>/* Try to deliver directly via tty-flip-buf if queue is empty */</FONT>
save_flags(flags);
<A HREF="kdebug.h.shtml#cli">cli</A>();
<FONT COLOR="#298C52">if</FONT> (skb_queue_empty(&amp;dev-&gt;drv[di]-&gt;rpqueue[channel]))
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_try_read">isdn_tty_try_read</A>(info, skb)) {
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
<FONT COLOR="#298C52">return</FONT> 1;
}
<FONT COLOR=#0000FF>/* Direct deliver failed or queue wasn't empty.
* Queue up for later dequeueing via timer-irq.
*/</FONT>
__skb_queue_tail(&amp;dev-&gt;drv[di]-&gt;rpqueue[channel], skb);
dev-&gt;drv[di]-&gt;rcvcount[channel] +=
(skb-&gt;len
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
+ <A HREF="../includes/isdn.h.shtml#ISDN_AUDIO_SKB_DLECOUNT">ISDN_AUDIO_SKB_DLECOUNT</A>(skb)
<FONT COLOR=#A521F7>#endif</FONT>
);
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
<FONT COLOR=#0000FF>/* Schedule dequeuing */</FONT>
<FONT COLOR="#298C52">if</FONT> ((dev-&gt;modempoll) &amp;&amp; (info-&gt;rcvsched))
<A HREF="isdn_common.c.shtml#isdn_timer_ctrl">isdn_timer_ctrl</A>(<A HREF="../includes/isdn.h.shtml#ISDN_TIMER_MODEMREAD">ISDN_TIMER_MODEMREAD</A>, 1);
<FONT COLOR="#298C52">return</FONT> 1;
}
<FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_cleanup_xmit">isdn_tty_cleanup_xmit</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
<FONT COLOR="#298C52">struct</FONT> sk_buff *skb;
<FONT COLOR="#298C52">unsigned</FONT> <FONT COLOR="#298C52">long</FONT> flags;
save_flags(flags);
<A HREF="kdebug.h.shtml#cli">cli</A>();
<FONT COLOR="#298C52">if</FONT> (skb_queue_len(&amp;info-&gt;xmit_queue))
<FONT COLOR="#298C52">while</FONT> ((skb = skb_dequeue(&amp;info-&gt;xmit_queue)))
kfree_skb(skb);
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">if</FONT> (skb_queue_len(&amp;info-&gt;dtmf_queue))
<FONT COLOR="#298C52">while</FONT> ((skb = skb_dequeue(&amp;info-&gt;dtmf_queue)))
kfree_skb(skb);
<FONT COLOR=#A521F7>#endif</FONT>
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_tint">isdn_tty_tint</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
<FONT COLOR="#298C52">struct</FONT> sk_buff *skb = skb_dequeue(&amp;info-&gt;xmit_queue);
<FONT COLOR="#298C52">int</FONT> len,
slen;
<FONT COLOR="#298C52">if</FONT> (!skb)
<FONT COLOR="#298C52">return</FONT>;
len = skb-&gt;len;
<FONT COLOR="#298C52">if</FONT> ((slen = <A HREF="isdn_common.c.shtml#isdn_writebuf_skb_stub">isdn_writebuf_skb_stub</A>(info-&gt;isdn_driver,
info-&gt;isdn_channel, 1, skb)) == len) {
<FONT COLOR="#298C52">struct</FONT> tty_struct *tty = info-&gt;tty;
info-&gt;send_outstanding++;
info-&gt;msr &amp;= ~UART_MSR_CTS;
info-&gt;lsr &amp;= ~UART_LSR_TEMT;
<FONT COLOR="#298C52">if</FONT> ((tty-&gt;flags &amp; (1 &lt;&lt; TTY_DO_WRITE_WAKEUP)) &amp;&amp;
tty-&gt;ldisc.write_wakeup)
(tty-&gt;ldisc.write_wakeup) (tty);
wake_up_interruptible(&amp;tty-&gt;write_wait);
<FONT COLOR="#298C52">return</FONT>;
}
<FONT COLOR="#298C52">if</FONT> (slen &lt; 0) {
<FONT COLOR=#0000FF>/* Error: no channel, already shutdown, or wrong parameter */</FONT>
dev_kfree_skb(skb);
<FONT COLOR="#298C52">return</FONT>;
}
skb_queue_head(&amp;info-&gt;xmit_queue, skb);
}
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A NAME="isdn_tty_countDLE">isdn_tty_countDLE</A>(<FONT COLOR="#298C52">unsigned</FONT> <FONT COLOR="#298C52">char</FONT> *buf, <FONT COLOR="#298C52">int</FONT> len)
{
<FONT COLOR="#298C52">int</FONT> count = 0;
<FONT COLOR="#298C52">while</FONT> (len--)
<FONT COLOR="#298C52">if</FONT> (*buf++ == <A HREF="isdn_common.c.shtml#DLE">DLE</A>)
count++;
<FONT COLOR="#298C52">return</FONT> count;
}
<FONT COLOR=#0000FF>/* This routine is called from within isdn_tty_write() to perform
* DLE-decoding when sending audio-data.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A HREF="#isdn_tty_handleDLEdown">isdn_tty_handleDLEdown</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info, <A HREF="../includes/isdn.h.shtml#atemu">atemu</A> * m, <FONT COLOR="#298C52">int</FONT> len)
{
<FONT COLOR="#298C52">unsigned</FONT> <FONT COLOR="#298C52">char</FONT> *p = &amp;info-&gt;xmit_buf[info-&gt;xmit_count];
<FONT COLOR="#298C52">int</FONT> count = 0;
<FONT COLOR="#298C52">while</FONT> (len &gt; 0) {
<FONT COLOR="#298C52">if</FONT> (m-&gt;lastDLE) {
m-&gt;lastDLE = 0;
<FONT COLOR="#298C52">switch</FONT> (*p) {
<FONT COLOR="#298C52">case</FONT> <A HREF="isdn_common.c.shtml#DLE">DLE</A>:
<FONT COLOR=#0000FF>/* Escape code */</FONT>
<FONT COLOR="#298C52">if</FONT> (len &gt; 1)
memmove(p, p + 1, len - 1);
p--;
count++;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="#ETX">ETX</A>:
<FONT COLOR=#0000FF>/* End of data */</FONT>
info-&gt;vonline |= 4;
<FONT COLOR="#298C52">return</FONT> count;
<FONT COLOR="#298C52">case</FONT> <A HREF="#DC4">DC4</A>:
<FONT COLOR=#0000FF>/* Abort RX */</FONT>
info-&gt;vonline &amp;= ~1;
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_VOICE
printk(KERN_DEBUG
<FONT COLOR="#FF0000">"DLEdown: got DLE-DC4, send DLE-ETX on ttyI%d\n"</FONT>,
info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\020\003"</FONT>, info);
<FONT COLOR="#298C52">if</FONT> (!info-&gt;vonline) {
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_VOICE
printk(KERN_DEBUG
<FONT COLOR="#FF0000">"DLEdown: send VCON on ttyI%d\n"</FONT>,
info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\nVCON\r\n"</FONT>, info);
}
<FONT COLOR=#0000FF>/* Fall through */</FONT>
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'q'</FONT>:
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'s'</FONT>:
<FONT COLOR=#0000FF>/* Silence */</FONT>
<FONT COLOR="#298C52">if</FONT> (len &gt; 1)
memmove(p, p + 1, len - 1);
p--;
<FONT COLOR="#298C52">break</FONT>;
}
} <FONT COLOR="#298C52">else</FONT> {
<FONT COLOR="#298C52">if</FONT> (*p == <A HREF="isdn_common.c.shtml#DLE">DLE</A>)
m-&gt;lastDLE = 1;
<FONT COLOR="#298C52">else</FONT>
count++;
}
p++;
len--;
}
<FONT COLOR="#298C52">if</FONT> (len &lt; 0) {
printk(KERN_WARNING <FONT COLOR="#FF0000">"isdn_tty: len&lt;0 in DLEdown\n"</FONT>);
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">return</FONT> count;
}
<FONT COLOR=#0000FF>/* This routine is called from within isdn_tty_write() when receiving
* audio-data. It interrupts receiving, if an character other than
* ^S or ^Q is sent.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A HREF="#isdn_tty_end_vrx">isdn_tty_end_vrx</A>(<FONT COLOR="#298C52">const</FONT> <FONT COLOR="#298C52">char</FONT> *buf, <FONT COLOR="#298C52">int</FONT> c, <FONT COLOR="#298C52">int</FONT> from_user)
{
<FONT COLOR="#298C52">char</FONT> ch;
<FONT COLOR="#298C52">while</FONT> (c--) {
<FONT COLOR="#298C52">if</FONT> (from_user)
get_user(ch, buf);
<FONT COLOR="#298C52">else</FONT>
ch = *buf;
<FONT COLOR="#298C52">if</FONT> ((ch != 0x11) &amp;&amp; (ch != 0x13))
<FONT COLOR="#298C52">return</FONT> 1;
buf++;
}
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT> voice_cf[7] =
{0, 0, 4, 3, 2, 0, 0};
<FONT COLOR=#A521F7>#endif</FONT> <FONT COLOR=#0000FF>/* CONFIG_ISDN_AUDIO */</FONT>
<FONT COLOR=#0000FF>/* isdn_tty_senddown() is called either directly from within isdn_tty_write()
* or via timer-interrupt from within isdn_tty_modem_xmit(). It pulls
* outgoing data from the tty's xmit-buffer, handles voice-decompression or
* T.70 if necessary, and finally queues it up for sending via isdn_tty_tint.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_senddown">isdn_tty_senddown</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
<FONT COLOR="#298C52">int</FONT> buflen;
<FONT COLOR="#298C52">int</FONT> skb_res;
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">int</FONT> audio_len;
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">struct</FONT> sk_buff *skb;
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">if</FONT> (info-&gt;vonline &amp; 4) {
info-&gt;vonline &amp;= ~6;
<FONT COLOR="#298C52">if</FONT> (!info-&gt;vonline) {
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_VOICE
printk(KERN_DEBUG
<FONT COLOR="#FF0000">"senddown: send VCON on ttyI%d\n"</FONT>,
info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\nVCON\r\n"</FONT>, info);
}
}
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (!(buflen = info-&gt;xmit_count))
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR="#298C52">if</FONT> ((info-&gt;emu.mdmreg[<A HREF="#REG_CTS">REG_CTS</A>] &amp; <A HREF="#BIT_CTS">BIT_CTS</A>) != 0)
info-&gt;msr &amp;= ~UART_MSR_CTS;
info-&gt;lsr &amp;= ~UART_LSR_TEMT;
<FONT COLOR=#0000FF>/* info-&gt;xmit_count is modified here and in isdn_tty_write().
* So we return here if isdn_tty_write() is in the
* critical section.
*/</FONT>
atomic_inc(&amp;info-&gt;xmit_lock);
<FONT COLOR="#298C52">if</FONT> (!(atomic_dec_and_test(&amp;info-&gt;xmit_lock)))
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR="#298C52">if</FONT> (info-&gt;isdn_driver &lt; 0) {
info-&gt;xmit_count = 0;
<FONT COLOR="#298C52">return</FONT>;
}
skb_res = dev-&gt;drv[info-&gt;isdn_driver]-&gt;interface-&gt;hl_hdrlen + 4;
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">if</FONT> (info-&gt;vonline &amp; 2)
audio_len = buflen * voice_cf[info-&gt;emu.vpar[3]];
<FONT COLOR="#298C52">else</FONT>
audio_len = 0;
skb = dev_alloc_skb(skb_res + buflen + audio_len);
<FONT COLOR=#A521F7>#else</FONT>
skb = dev_alloc_skb(skb_res + buflen);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (!skb) {
printk(KERN_WARNING
<FONT COLOR="#FF0000">"isdn_tty: Out of memory in ttyI%d senddown\n"</FONT>,
info-&gt;line);
<FONT COLOR="#298C52">return</FONT>;
}
skb_reserve(skb, skb_res);
memcpy(skb_put(skb, buflen), info-&gt;xmit_buf, buflen);
info-&gt;xmit_count = 0;
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">if</FONT> (info-&gt;vonline &amp; 2) {
<FONT COLOR=#0000FF>/* For now, ifmt is fixed to 1 (alaw), since this
* is used with ISDN everywhere in the world, except
* US, Canada and Japan.
* Later, when US-ISDN protocols are implemented,
* this setting will depend on the D-channel protocol.
*/</FONT>
<FONT COLOR="#298C52">int</FONT> ifmt = 1;
<FONT COLOR=#0000FF>/* voice conversion/decompression */</FONT>
<FONT COLOR="#298C52">switch</FONT> (info-&gt;emu.vpar[3]) {
<FONT COLOR="#298C52">case</FONT> 2:
<FONT COLOR="#298C52">case</FONT> 3:
<FONT COLOR="#298C52">case</FONT> 4:
<FONT COLOR=#0000FF>/* adpcm, compatible to ZyXel 1496 modem
* with ROM revision 6.01
*/</FONT>
audio_len = <A HREF="isdn_audio.c.shtml#isdn_audio_adpcm2xlaw">isdn_audio_adpcm2xlaw</A>(info-&gt;adpcms,
ifmt,
skb-&gt;data,
skb_put(skb, audio_len),
buflen);
skb_pull(skb, buflen);
skb_trim(skb, audio_len);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 5:
<FONT COLOR=#0000FF>/* a-law */</FONT>
<FONT COLOR="#298C52">if</FONT> (!ifmt)
<A HREF="isdn_audio.c.shtml#isdn_audio_alaw2ulaw">isdn_audio_alaw2ulaw</A>(skb-&gt;data,
buflen);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 6:
<FONT COLOR=#0000FF>/* u-law */</FONT>
<FONT COLOR="#298C52">if</FONT> (ifmt)
<A HREF="isdn_audio.c.shtml#isdn_audio_ulaw2alaw">isdn_audio_ulaw2alaw</A>(skb-&gt;data,
buflen);
<FONT COLOR="#298C52">break</FONT>;
}
}
<FONT COLOR=#A521F7>#endif</FONT> <FONT COLOR=#0000FF>/* CONFIG_ISDN_AUDIO */</FONT>
<FONT COLOR="#298C52">if</FONT> (info-&gt;emu.mdmreg[<A HREF="#REG_T70">REG_T70</A>] &amp; <A HREF="#BIT_T70">BIT_T70</A>) {
<FONT COLOR=#0000FF>/* Add T.70 simplified header */</FONT>
<FONT COLOR="#298C52">if</FONT> (info-&gt;emu.mdmreg[<A HREF="#REG_T70">REG_T70</A>] &amp; <A HREF="#BIT_T70_EXT">BIT_T70_EXT</A>)
memcpy(skb_push(skb, 2), <FONT COLOR="#FF0000">"\1\0"</FONT>, 2);
<FONT COLOR="#298C52">else</FONT>
memcpy(skb_push(skb, 4), <FONT COLOR="#FF0000">"\1\0\1\0"</FONT>, 4);
}
skb_queue_tail(&amp;info-&gt;xmit_queue, skb);
}
<FONT COLOR=#0000FF>/************************************************************
*
* Modem-functions
*
* mostly "stolen" from original Linux-serial.c and friends.
*
************************************************************/</FONT>
<FONT COLOR=#0000FF>/* The next routine is called once from within timer-interrupt
* triggered within isdn_tty_modem_ncarrier(). It calls
* isdn_tty_modem_result() to stuff a "NO CARRIER" Message
* into the tty's flip-buffer.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_modem_do_ncarrier">isdn_tty_modem_do_ncarrier</A>(<FONT COLOR="#298C52">unsigned</FONT> <FONT COLOR="#298C52">long</FONT> data)
{
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info = (<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *) data;
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(3, info);
}
<FONT COLOR=#0000FF>/* Next routine is called, whenever the DTR-signal is raised.
* It checks the ncarrier-flag, and triggers the above routine
* when necessary. The ncarrier-flag is set, whenever DTR goes
* low.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_modem_ncarrier">isdn_tty_modem_ncarrier</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
<FONT COLOR="#298C52">if</FONT> (info-&gt;ncarrier) {
info-&gt;nc_timer.expires = jiffies + HZ;
info-&gt;nc_timer.function = <A HREF="#isdn_tty_modem_do_ncarrier">isdn_tty_modem_do_ncarrier</A>;
info-&gt;nc_timer.data = (<FONT COLOR="#298C52">unsigned</FONT> <FONT COLOR="#298C52">long</FONT>) info;
add_timer(&amp;info-&gt;nc_timer);
}
}
<FONT COLOR=#0000FF>/* isdn_tty_dial() performs dialing of a tty an the necessary
* setup of the lower levels before that.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A HREF="#isdn_tty_dial">isdn_tty_dial</A>(<FONT COLOR="#298C52">char</FONT> *n, <A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info, <A HREF="../includes/isdn.h.shtml#atemu">atemu</A> * m)
{
<FONT COLOR="#298C52">int</FONT> usg = <A HREF="../includes/isdn.h.shtml#ISDN_USAGE_MODEM">ISDN_USAGE_MODEM</A>;
<FONT COLOR="#298C52">int</FONT> si = 7;
<FONT COLOR="#298C52">int</FONT> l2 = m-&gt;mdmreg[<A HREF="#REG_L2PROT">REG_L2PROT</A>];
<A HREF="../includes/isdnif.h.shtml#isdn_ctrl">isdn_ctrl</A> cmd;
ulong flags;
<FONT COLOR="#298C52">int</FONT> i;
<FONT COLOR="#298C52">int</FONT> j;
<FONT COLOR="#298C52">for</FONT> (j = 7; j &gt;= 0; j--)
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmreg[<A HREF="#REG_SI1">REG_SI1</A>] &amp; (1 &lt;&lt; j)) {
si = bit2si[j];
<FONT COLOR="#298C52">break</FONT>;
}
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">if</FONT> (si == 1) {
l2 = <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_TRANS">ISDN_PROTO_L2_TRANS</A>;
usg = <A HREF="../includes/isdn.h.shtml#ISDN_USAGE_VOICE">ISDN_USAGE_VOICE</A>;
}
<FONT COLOR=#A521F7>#endif</FONT>
m-&gt;mdmreg[<A HREF="#REG_SI1I">REG_SI1I</A>] = si2bit[si];
save_flags(flags);
<A HREF="kdebug.h.shtml#cli">cli</A>();
i = <A HREF="isdn_common.c.shtml#isdn_get_free_channel">isdn_get_free_channel</A>(usg, l2, m-&gt;mdmreg[<A HREF="#REG_L3PROT">REG_L3PROT</A>], -1, -1);
<FONT COLOR="#298C52">if</FONT> (i &lt; 0) {
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(6, info);
} <FONT COLOR="#298C52">else</FONT> {
info-&gt;isdn_driver = dev-&gt;drvmap[i];
info-&gt;isdn_channel = dev-&gt;chanmap[i];
info-&gt;drv_index = i;
dev-&gt;m_idx[i] = info-&gt;line;
dev-&gt;usage[i] |= <A HREF="../includes/isdn.h.shtml#ISDN_USAGE_OUTGOING">ISDN_USAGE_OUTGOING</A>;
info-&gt;last_dir = 1;
strcpy(info-&gt;last_num, n);
<A HREF="isdn_common.c.shtml#isdn_info_update">isdn_info_update</A>();
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
cmd.<A HREF="../includes/isdn.h.shtml#driver">driver</A> = info-&gt;isdn_driver;
cmd.arg = info-&gt;isdn_channel;
cmd.command = <A HREF="../includes/isdnif.h.shtml#ISDN_CMD_CLREAZ">ISDN_CMD_CLREAZ</A>;
<A HREF="isdn_common.c.shtml#isdn_command">isdn_command</A>(&amp;cmd);
strcpy(cmd.parm.num, <A HREF="isdn_common.c.shtml#isdn_map_eaz2msn">isdn_map_eaz2msn</A>(m-&gt;msn, info-&gt;isdn_driver));
cmd.<A HREF="../includes/isdn.h.shtml#driver">driver</A> = info-&gt;isdn_driver;
cmd.command = <A HREF="../includes/isdnif.h.shtml#ISDN_CMD_SETEAZ">ISDN_CMD_SETEAZ</A>;
<A HREF="isdn_common.c.shtml#isdn_command">isdn_command</A>(&amp;cmd);
cmd.<A HREF="../includes/isdn.h.shtml#driver">driver</A> = info-&gt;isdn_driver;
cmd.command = <A HREF="../includes/isdnif.h.shtml#ISDN_CMD_SETL2">ISDN_CMD_SETL2</A>;
info-&gt;last_l2 = l2;
cmd.arg = info-&gt;isdn_channel + (l2 &lt;&lt; 8);
<A HREF="isdn_common.c.shtml#isdn_command">isdn_command</A>(&amp;cmd);
cmd.<A HREF="../includes/isdn.h.shtml#driver">driver</A> = info-&gt;isdn_driver;
cmd.command = <A HREF="../includes/isdnif.h.shtml#ISDN_CMD_SETL3">ISDN_CMD_SETL3</A>;
cmd.arg = info-&gt;isdn_channel + (m-&gt;mdmreg[<A HREF="#REG_L3PROT">REG_L3PROT</A>] &lt;&lt; 8);
<A HREF="isdn_common.c.shtml#isdn_command">isdn_command</A>(&amp;cmd);
cmd.<A HREF="../includes/isdn.h.shtml#driver">driver</A> = info-&gt;isdn_driver;
cmd.arg = info-&gt;isdn_channel;
sprintf(cmd.parm.setup.<A HREF="isdn_common.c.shtml#phone">phone</A>, <FONT COLOR="#FF0000">"%s"</FONT>, n);
sprintf(cmd.parm.setup.eazmsn, <FONT COLOR="#FF0000">"%s"</FONT>,
<A HREF="isdn_common.c.shtml#isdn_map_eaz2msn">isdn_map_eaz2msn</A>(m-&gt;msn, info-&gt;isdn_driver));
cmd.parm.setup.si1 = si;
cmd.parm.setup.si2 = m-&gt;mdmreg[<A HREF="#REG_SI2">REG_SI2</A>];
cmd.command = <A HREF="../includes/isdnif.h.shtml#ISDN_CMD_DIAL">ISDN_CMD_DIAL</A>;
info-&gt;dialing = 1;
strcpy(dev-&gt;num[i], n);
<A HREF="isdn_common.c.shtml#isdn_info_update">isdn_info_update</A>();
<A HREF="isdn_common.c.shtml#isdn_command">isdn_command</A>(&amp;cmd);
}
}
<FONT COLOR=#0000FF>/* isdn_tty_hangup() disassociates a tty from the real
* ISDN-line (hangup). The usage-status is cleared
* and some cleanup is done also.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_modem_hup">isdn_tty_modem_hup</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info, <FONT COLOR="#298C52">int</FONT> local)
{
<A HREF="../includes/isdnif.h.shtml#isdn_ctrl">isdn_ctrl</A> cmd;
<FONT COLOR="#298C52">int</FONT> usage;
<FONT COLOR="#298C52">if</FONT> (!info)
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_HUP
printk(KERN_DEBUG <FONT COLOR="#FF0000">"Mhup ttyI%d\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
info-&gt;rcvsched = 0;
<A HREF="#isdn_tty_flush_buffer">isdn_tty_flush_buffer</A>(info-&gt;tty);
<FONT COLOR="#298C52">if</FONT> (info-&gt;online) {
info-&gt;last_lhup = local;
info-&gt;online = 0;
<FONT COLOR=#0000FF>/* NO CARRIER message */</FONT>
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(3, info);
}
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
info-&gt;vonline = 0;
<FONT COLOR="#298C52">if</FONT> (info-&gt;<A HREF="isdn_audio.h.shtml#dtmf_state">dtmf_state</A>) {
kfree(info-&gt;<A HREF="isdn_audio.h.shtml#dtmf_state">dtmf_state</A>);
info-&gt;<A HREF="isdn_audio.h.shtml#dtmf_state">dtmf_state</A> = NULL;
}
<FONT COLOR="#298C52">if</FONT> (info-&gt;adpcms) {
kfree(info-&gt;adpcms);
info-&gt;adpcms = NULL;
}
<FONT COLOR="#298C52">if</FONT> (info-&gt;adpcmr) {
kfree(info-&gt;adpcmr);
info-&gt;adpcmr = NULL;
}
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> ((info-&gt;msr &amp; UART_MSR_RI) &amp;&amp;
(info-&gt;emu.mdmreg[<A HREF="#REG_RUNG">REG_RUNG</A>] &amp; <A HREF="#BIT_RUNG">BIT_RUNG</A>))
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(12, info);
info-&gt;msr &amp;= ~(UART_MSR_DCD | UART_MSR_RI);
info-&gt;lsr |= UART_LSR_TEMT;
<FONT COLOR="#298C52">if</FONT> (info-&gt;isdn_driver &gt;= 0) {
<FONT COLOR="#298C52">if</FONT> (local) {
cmd.<A HREF="../includes/isdn.h.shtml#driver">driver</A> = info-&gt;isdn_driver;
cmd.command = <A HREF="../includes/isdnif.h.shtml#ISDN_CMD_HANGUP">ISDN_CMD_HANGUP</A>;
cmd.arg = info-&gt;isdn_channel;
<A HREF="isdn_common.c.shtml#isdn_command">isdn_command</A>(&amp;cmd);
}
<A HREF="isdn_common.c.shtml#isdn_all_eaz">isdn_all_eaz</A>(info-&gt;isdn_driver, info-&gt;isdn_channel);
info-&gt;emu.mdmreg[<A HREF="#REG_RINGCNT">REG_RINGCNT</A>] = 0;
usage = (info-&gt;emu.mdmreg[<A HREF="#REG_SI1I">REG_SI1I</A>] == 1) ?
<A HREF="../includes/isdn.h.shtml#ISDN_USAGE_VOICE">ISDN_USAGE_VOICE</A> : <A HREF="../includes/isdn.h.shtml#ISDN_USAGE_MODEM">ISDN_USAGE_MODEM</A>;
<A HREF="isdn_common.c.shtml#isdn_free_channel">isdn_free_channel</A>(info-&gt;isdn_driver, info-&gt;isdn_channel,
usage);
}
info-&gt;isdn_driver = -1;
info-&gt;isdn_channel = -1;
<FONT COLOR="#298C52">if</FONT> (info-&gt;drv_index &gt;= 0) {
dev-&gt;m_idx[info-&gt;drv_index] = -1;
info-&gt;drv_index = -1;
}
}
<FONT COLOR=#0000FF>/*
* Begin of a CAPI like interface, currently used only for
* supplementary service (CAPI 2.0 part III)
*/</FONT>
<FONT COLOR=#A521F7>#include</FONT> <FONT COLOR="#FF0000">"avmb1/capicmd.h"</FONT> <FONT COLOR=#0000FF>/* this should be moved in a common place */</FONT>
<FONT COLOR="#298C52">int</FONT>
<A NAME="isdn_tty_capi_facility">isdn_tty_capi_facility</A>(<A HREF="../includes/isdnif.h.shtml#capi_msg">capi_msg</A> *cm) {
<FONT COLOR="#298C52">return</FONT>(-1); <FONT COLOR=#0000FF>/* dummy */</FONT>
}
<FONT COLOR=#0000FF>/* isdn_tty_suspend() tries to suspend the current tty connection
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A HREF="#isdn_tty_suspend">isdn_tty_suspend</A>(<FONT COLOR="#298C52">char</FONT> *id, <A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info, <A HREF="../includes/isdn.h.shtml#atemu">atemu</A> * m)
{
<A HREF="../includes/isdnif.h.shtml#isdn_ctrl">isdn_ctrl</A> cmd;
<FONT COLOR="#298C52">int</FONT> l;
<FONT COLOR="#298C52">if</FONT> (!info)
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_SERVICES
printk(KERN_DEBUG <FONT COLOR="#FF0000">"Msusp ttyI%d\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
l = strlen(id);
<FONT COLOR="#298C52">if</FONT> ((info-&gt;isdn_driver &gt;= 0) &amp;&amp; l) {
cmd.parm.cmsg.Length = l+17;
cmd.parm.cmsg.Command = CAPI_FACILITY;
cmd.parm.cmsg.Subcommand = CAPI_REQ;
cmd.parm.cmsg.adr.Controller = info-&gt;isdn_driver + 1;
cmd.parm.cmsg.para[0] = 3; <FONT COLOR=#0000FF>/* 16 bit 0x0003 suplementary service */</FONT>
cmd.parm.cmsg.para[1] = 0;
cmd.parm.cmsg.para[2] = l + 3;
cmd.parm.cmsg.para[3] = 4; <FONT COLOR=#0000FF>/* 16 bit 0x0004 Suspend */</FONT>
cmd.parm.cmsg.para[4] = 0;
cmd.parm.cmsg.para[5] = l;
strncpy(&amp;cmd.parm.cmsg.para[6], id, l);
cmd.command = <A HREF="../includes/isdnif.h.shtml#CAPI_PUT_MESSAGE">CAPI_PUT_MESSAGE</A>;
cmd.<A HREF="../includes/isdn.h.shtml#driver">driver</A> = info-&gt;isdn_driver;
cmd.arg = info-&gt;isdn_channel;
<A HREF="isdn_common.c.shtml#isdn_command">isdn_command</A>(&amp;cmd);
}
}
<FONT COLOR=#0000FF>/* isdn_tty_resume() tries to resume a suspended call
* setup of the lower levels before that. unfortunatly here is no
* checking for compatibility of used protocols implemented by Q931
* It does the same things like isdn_tty_dial, the last command
* is different, may be we can merge it.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A HREF="#isdn_tty_resume">isdn_tty_resume</A>(<FONT COLOR="#298C52">char</FONT> *id, <A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info, <A HREF="../includes/isdn.h.shtml#atemu">atemu</A> * m)
{
<FONT COLOR="#298C52">int</FONT> usg = <A HREF="../includes/isdn.h.shtml#ISDN_USAGE_MODEM">ISDN_USAGE_MODEM</A>;
<FONT COLOR="#298C52">int</FONT> si = 7;
<FONT COLOR="#298C52">int</FONT> l2 = m-&gt;mdmreg[<A HREF="#REG_L2PROT">REG_L2PROT</A>];
<A HREF="../includes/isdnif.h.shtml#isdn_ctrl">isdn_ctrl</A> cmd;
ulong flags;
<FONT COLOR="#298C52">int</FONT> i;
<FONT COLOR="#298C52">int</FONT> j;
<FONT COLOR="#298C52">int</FONT> l;
l = strlen(id);
<FONT COLOR="#298C52">if</FONT> (!l) {
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(4, info);
<FONT COLOR="#298C52">return</FONT>;
}
<FONT COLOR="#298C52">for</FONT> (j = 7; j &gt;= 0; j--)
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmreg[<A HREF="#REG_SI1">REG_SI1</A>] &amp; (1 &lt;&lt; j)) {
si = bit2si[j];
<FONT COLOR="#298C52">break</FONT>;
}
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">if</FONT> (si == 1) {
l2 = <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_TRANS">ISDN_PROTO_L2_TRANS</A>;
usg = <A HREF="../includes/isdn.h.shtml#ISDN_USAGE_VOICE">ISDN_USAGE_VOICE</A>;
}
<FONT COLOR=#A521F7>#endif</FONT>
m-&gt;mdmreg[<A HREF="#REG_SI1I">REG_SI1I</A>] = si2bit[si];
save_flags(flags);
<A HREF="kdebug.h.shtml#cli">cli</A>();
i = <A HREF="isdn_common.c.shtml#isdn_get_free_channel">isdn_get_free_channel</A>(usg, l2, m-&gt;mdmreg[<A HREF="#REG_L3PROT">REG_L3PROT</A>], -1, -1);
<FONT COLOR="#298C52">if</FONT> (i &lt; 0) {
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(6, info);
} <FONT COLOR="#298C52">else</FONT> {
info-&gt;isdn_driver = dev-&gt;drvmap[i];
info-&gt;isdn_channel = dev-&gt;chanmap[i];
info-&gt;drv_index = i;
dev-&gt;m_idx[i] = info-&gt;line;
dev-&gt;usage[i] |= <A HREF="../includes/isdn.h.shtml#ISDN_USAGE_OUTGOING">ISDN_USAGE_OUTGOING</A>;
info-&gt;last_dir = 1;
<FONT COLOR=#0000FF>// strcpy(info-&gt;last_num, n);</FONT>
<A HREF="isdn_common.c.shtml#isdn_info_update">isdn_info_update</A>();
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
cmd.<A HREF="../includes/isdn.h.shtml#driver">driver</A> = info-&gt;isdn_driver;
cmd.arg = info-&gt;isdn_channel;
cmd.command = <A HREF="../includes/isdnif.h.shtml#ISDN_CMD_CLREAZ">ISDN_CMD_CLREAZ</A>;
<A HREF="isdn_common.c.shtml#isdn_command">isdn_command</A>(&amp;cmd);
strcpy(cmd.parm.num, <A HREF="isdn_common.c.shtml#isdn_map_eaz2msn">isdn_map_eaz2msn</A>(m-&gt;msn, info-&gt;isdn_driver));
cmd.<A HREF="../includes/isdn.h.shtml#driver">driver</A> = info-&gt;isdn_driver;
cmd.command = <A HREF="../includes/isdnif.h.shtml#ISDN_CMD_SETEAZ">ISDN_CMD_SETEAZ</A>;
<A HREF="isdn_common.c.shtml#isdn_command">isdn_command</A>(&amp;cmd);
cmd.<A HREF="../includes/isdn.h.shtml#driver">driver</A> = info-&gt;isdn_driver;
cmd.command = <A HREF="../includes/isdnif.h.shtml#ISDN_CMD_SETL2">ISDN_CMD_SETL2</A>;
info-&gt;last_l2 = l2;
cmd.arg = info-&gt;isdn_channel + (l2 &lt;&lt; 8);
<A HREF="isdn_common.c.shtml#isdn_command">isdn_command</A>(&amp;cmd);
cmd.<A HREF="../includes/isdn.h.shtml#driver">driver</A> = info-&gt;isdn_driver;
cmd.command = <A HREF="../includes/isdnif.h.shtml#ISDN_CMD_SETL3">ISDN_CMD_SETL3</A>;
cmd.arg = info-&gt;isdn_channel + (m-&gt;mdmreg[<A HREF="#REG_L3PROT">REG_L3PROT</A>] &lt;&lt; 8);
<A HREF="isdn_common.c.shtml#isdn_command">isdn_command</A>(&amp;cmd);
cmd.<A HREF="../includes/isdn.h.shtml#driver">driver</A> = info-&gt;isdn_driver;
cmd.arg = info-&gt;isdn_channel;
cmd.parm.cmsg.Length = l+17;
cmd.parm.cmsg.Command = CAPI_FACILITY;
cmd.parm.cmsg.Subcommand = CAPI_REQ;
cmd.parm.cmsg.adr.Controller = info-&gt;isdn_driver + 1;
cmd.parm.cmsg.para[0] = 3; <FONT COLOR=#0000FF>/* 16 bit 0x0003 suplementary service */</FONT>
cmd.parm.cmsg.para[1] = 0;
cmd.parm.cmsg.para[2] = l+3;
cmd.parm.cmsg.para[3] = 5; <FONT COLOR=#0000FF>/* 16 bit 0x0005 Resume */</FONT>
cmd.parm.cmsg.para[4] = 0;
cmd.parm.cmsg.para[5] = l;
strncpy(&amp;cmd.parm.cmsg.para[6], id, l);
cmd.command = <A HREF="../includes/isdnif.h.shtml#CAPI_PUT_MESSAGE">CAPI_PUT_MESSAGE</A>;
<FONT COLOR=#0000FF>/* info-&gt;dialing = 1;
strcpy(dev-&gt;num[i], n);
isdn_info_update();
*/</FONT>
<A HREF="isdn_common.c.shtml#isdn_command">isdn_command</A>(&amp;cmd);
}
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">inline</FONT> <FONT COLOR="#298C52">int</FONT>
<A HREF="#isdn_tty_paranoia_check">isdn_tty_paranoia_check</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info, kdev_t device, <FONT COLOR="#298C52">const</FONT> <FONT COLOR="#298C52">char</FONT> *routine)
{
<FONT COLOR=#A521F7>#ifdef</FONT> <A HREF="#MODEM_PARANOIA_CHECK">MODEM_PARANOIA_CHECK</A>
<FONT COLOR="#298C52">if</FONT> (!info) {
printk(KERN_WARNING <FONT COLOR="#FF0000">"isdn_tty: null info_struct for (%d, %d) in %s\n"</FONT>,
MAJOR(device), MINOR(device), routine);
<FONT COLOR="#298C52">return</FONT> 1;
}
<FONT COLOR="#298C52">if</FONT> (info-&gt;magic != <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_MAGIC">ISDN_ASYNC_MAGIC</A>) {
printk(KERN_WARNING <FONT COLOR="#FF0000">"isdn_tty: bad magic for modem struct (%d, %d) in %s\n"</FONT>,
MAJOR(device), MINOR(device), routine);
<FONT COLOR="#298C52">return</FONT> 1;
}
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR=#0000FF>/*
* This routine is called to set the UART divisor registers to match
* the specified baud rate for a serial port.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_change_speed">isdn_tty_change_speed</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
uint cflag,
cval,
fcr,
quot;
<FONT COLOR="#298C52">int</FONT> i;
<FONT COLOR="#298C52">if</FONT> (!info-&gt;tty || !info-&gt;tty-&gt;termios)
<FONT COLOR="#298C52">return</FONT>;
cflag = info-&gt;tty-&gt;termios-&gt;c_cflag;
quot = i = cflag &amp; CBAUD;
<FONT COLOR="#298C52">if</FONT> (i &amp; CBAUDEX) {
i &amp;= ~CBAUDEX;
<FONT COLOR="#298C52">if</FONT> (i &lt; 1 || i &gt; 2)
info-&gt;tty-&gt;termios-&gt;c_cflag &amp;= ~CBAUDEX;
<FONT COLOR="#298C52">else</FONT>
i += 15;
}
<FONT COLOR="#298C52">if</FONT> (quot) {
info-&gt;mcr |= UART_MCR_DTR;
<A HREF="#isdn_tty_modem_ncarrier">isdn_tty_modem_ncarrier</A>(info);
} <FONT COLOR="#298C52">else</FONT> {
info-&gt;mcr &amp;= ~UART_MCR_DTR;
<FONT COLOR="#298C52">if</FONT> (info-&gt;emu.mdmreg[<A HREF="#REG_DTRHUP">REG_DTRHUP</A>] &amp; <A HREF="#BIT_DTRHUP">BIT_DTRHUP</A>) {
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_HUP
printk(KERN_DEBUG <FONT COLOR="#FF0000">"Mhup in changespeed\n"</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (info-&gt;online)
info-&gt;ncarrier = 1;
<A HREF="#isdn_tty_modem_reset_regs">isdn_tty_modem_reset_regs</A>(info, 0);
<A HREF="#isdn_tty_modem_hup">isdn_tty_modem_hup</A>(info, 1);
}
<FONT COLOR="#298C52">return</FONT>;
}
<FONT COLOR=#0000FF>/* byte size and parity */</FONT>
cval = cflag &amp; (CSIZE | CSTOPB);
cval &gt;&gt;= 4;
<FONT COLOR="#298C52">if</FONT> (cflag &amp; PARENB)
cval |= UART_LCR_PARITY;
<FONT COLOR="#298C52">if</FONT> (!(cflag &amp; PARODD))
cval |= UART_LCR_EPAR;
fcr = 0;
<FONT COLOR=#0000FF>/* CTS flow control flag and modem status interrupts */</FONT>
<FONT COLOR="#298C52">if</FONT> (cflag &amp; CRTSCTS) {
info-&gt;flags |= <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CTS_FLOW">ISDN_ASYNC_CTS_FLOW</A>;
} <FONT COLOR="#298C52">else</FONT>
info-&gt;flags &amp;= ~<A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CTS_FLOW">ISDN_ASYNC_CTS_FLOW</A>;
<FONT COLOR="#298C52">if</FONT> (cflag &amp; CLOCAL)
info-&gt;flags &amp;= ~<A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CHECK_CD">ISDN_ASYNC_CHECK_CD</A>;
<FONT COLOR="#298C52">else</FONT> {
info-&gt;flags |= <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CHECK_CD">ISDN_ASYNC_CHECK_CD</A>;
}
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A NAME="isdn_tty_startup">isdn_tty_startup</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
ulong flags;
<FONT COLOR="#298C52">if</FONT> (info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_INITIALIZED">ISDN_ASYNC_INITIALIZED</A>)
<FONT COLOR="#298C52">return</FONT> 0;
save_flags(flags);
<A HREF="kdebug.h.shtml#cli">cli</A>();
<A HREF="isdn_common.c.shtml#isdn_MOD_INC_USE_COUNT">isdn_MOD_INC_USE_COUNT</A>();
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG <FONT COLOR="#FF0000">"starting up ttyi%d ...\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR=#0000FF>/*
* Now, initialize the UART
*/</FONT>
info-&gt;mcr = UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2;
<FONT COLOR="#298C52">if</FONT> (info-&gt;tty)
clear_bit(TTY_IO_ERROR, &amp;info-&gt;tty-&gt;flags);
<FONT COLOR=#0000FF>/*
* and set the speed of the serial port
*/</FONT>
<A HREF="#isdn_tty_change_speed">isdn_tty_change_speed</A>(info);
info-&gt;flags |= <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_INITIALIZED">ISDN_ASYNC_INITIALIZED</A>;
info-&gt;msr |= (UART_MSR_DSR | UART_MSR_CTS);
info-&gt;send_outstanding = 0;
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR=#0000FF>/*
* This routine will shutdown a serial port; interrupts are disabled, and
* DTR is dropped if the hangup on close termio flag is on.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_shutdown">isdn_tty_shutdown</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
ulong flags;
<FONT COLOR="#298C52">if</FONT> (!(info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_INITIALIZED">ISDN_ASYNC_INITIALIZED</A>))
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG <FONT COLOR="#FF0000">"Shutting down isdnmodem port %d ....\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
save_flags(flags);
<A HREF="kdebug.h.shtml#cli">cli</A>(); <FONT COLOR=#0000FF>/* Disable interrupts */</FONT>
<A HREF="isdn_common.c.shtml#isdn_MOD_DEC_USE_COUNT">isdn_MOD_DEC_USE_COUNT</A>();
info-&gt;msr &amp;= ~UART_MSR_RI;
<FONT COLOR="#298C52">if</FONT> (!info-&gt;tty || (info-&gt;tty-&gt;termios-&gt;c_cflag &amp; HUPCL)) {
info-&gt;mcr &amp;= ~(UART_MCR_DTR | UART_MCR_RTS);
<FONT COLOR="#298C52">if</FONT> (info-&gt;emu.mdmreg[<A HREF="#REG_DTRHUP">REG_DTRHUP</A>] &amp; <A HREF="#BIT_DTRHUP">BIT_DTRHUP</A>) {
<A HREF="#isdn_tty_modem_reset_regs">isdn_tty_modem_reset_regs</A>(info, 0);
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_HUP
printk(KERN_DEBUG <FONT COLOR="#FF0000">"Mhup in isdn_tty_shutdown\n"</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
<A HREF="#isdn_tty_modem_hup">isdn_tty_modem_hup</A>(info, 1);
}
}
<FONT COLOR="#298C52">if</FONT> (info-&gt;tty)
set_bit(TTY_IO_ERROR, &amp;info-&gt;tty-&gt;flags);
info-&gt;flags &amp;= ~<A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_INITIALIZED">ISDN_ASYNC_INITIALIZED</A>;
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
}
<FONT COLOR=#0000FF>/* isdn_tty_write() is the main send-routine. It is called from the upper
* levels within the kernel to perform sending data. Depending on the
* online-flag it either directs output to the at-command-interpreter or
* to the lower level. Additional tasks done here:
* - If online, check for escape-sequence (+++)
* - If sending audio-data, call isdn_tty_DLEdown() to parse DLE-codes.
* - If receiving audio-data, call isdn_tty_end_vrx() to abort if needed.
* - If dialing, abort dial.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A HREF="#isdn_tty_write">isdn_tty_write</A>(<FONT COLOR="#298C52">struct</FONT> tty_struct *tty, <FONT COLOR="#298C52">int</FONT> from_user, <FONT COLOR="#298C52">const</FONT> u_char * buf, <FONT COLOR="#298C52">int</FONT> count)
{
<FONT COLOR="#298C52">int</FONT> c;
<FONT COLOR="#298C52">int</FONT> total = 0;
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info = (<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *) tty-&gt;driver_data;
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_paranoia_check">isdn_tty_paranoia_check</A>(info, tty-&gt;device, <FONT COLOR="#FF0000">"isdn_tty_write"</FONT>))
<FONT COLOR="#298C52">return</FONT> 0;
<FONT COLOR="#298C52">if</FONT> (!tty)
<FONT COLOR="#298C52">return</FONT> 0;
<FONT COLOR="#298C52">if</FONT> (from_user)
down(&amp;info-&gt;write_sem);
<FONT COLOR=#0000FF>/* See isdn_tty_senddown() */</FONT>
atomic_inc(&amp;info-&gt;xmit_lock);
<FONT COLOR="#298C52">while</FONT> (1) {
c = <A HREF="isdn_hybrid.c.shtml#MIN">MIN</A>(count, info-&gt;xmit_size - info-&gt;xmit_count);
<FONT COLOR="#298C52">if</FONT> (info-&gt;isdn_driver &gt;= 0)
c = <A HREF="isdn_hybrid.c.shtml#MIN">MIN</A>(c, dev-&gt;drv[info-&gt;isdn_driver]-&gt;maxbufsize);
<FONT COLOR="#298C52">if</FONT> (c &lt;= 0)
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">if</FONT> ((info-&gt;online &gt; 1)
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
|| (info-&gt;vonline &amp; 3)
<FONT COLOR=#A521F7>#endif</FONT>
) {
<A HREF="../includes/isdn.h.shtml#atemu">atemu</A> *m = &amp;info-&gt;emu;
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">if</FONT> (!info-&gt;vonline)
<FONT COLOR=#A521F7>#endif</FONT>
<A HREF="#isdn_tty_check_esc">isdn_tty_check_esc</A>(buf, m-&gt;mdmreg[<A HREF="#REG_ESC">REG_ESC</A>], c,
&amp;(m-&gt;pluscount),
&amp;(m-&gt;lastplus),
from_user);
<FONT COLOR="#298C52">if</FONT> (from_user)
copy_from_user(&amp;(info-&gt;xmit_buf[info-&gt;xmit_count]), buf, c);
<FONT COLOR="#298C52">else</FONT>
memcpy(&amp;(info-&gt;xmit_buf[info-&gt;xmit_count]), buf, c);
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">if</FONT> (info-&gt;vonline) {
<FONT COLOR="#298C52">int</FONT> cc = <A HREF="#isdn_tty_handleDLEdown">isdn_tty_handleDLEdown</A>(info, m, c);
<FONT COLOR="#298C52">if</FONT> (info-&gt;vonline &amp; 2) {
<FONT COLOR="#298C52">if</FONT> (!cc) {
<FONT COLOR=#0000FF>/* If DLE decoding results in zero-transmit, but
* c originally was non-zero, do a wakeup.
*/</FONT>
<FONT COLOR="#298C52">if</FONT> ((tty-&gt;flags &amp; (1 &lt;&lt; TTY_DO_WRITE_WAKEUP)) &amp;&amp;
tty-&gt;ldisc.write_wakeup)
(tty-&gt;ldisc.write_wakeup) (tty);
wake_up_interruptible(&amp;tty-&gt;write_wait);
info-&gt;msr |= UART_MSR_CTS;
info-&gt;lsr |= UART_LSR_TEMT;
}
info-&gt;xmit_count += cc;
}
<FONT COLOR="#298C52">if</FONT> ((info-&gt;vonline &amp; 3) == 1) {
<FONT COLOR=#0000FF>/* Do NOT handle Ctrl-Q or Ctrl-S
* when in full-duplex audio mode.
*/</FONT>
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_end_vrx">isdn_tty_end_vrx</A>(buf, c, from_user)) {
info-&gt;vonline &amp;= ~1;
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_VOICE
printk(KERN_DEBUG
<FONT COLOR="#FF0000">"got !^Q/^S, send DLE-ETX,VCON on ttyI%d\n"</FONT>,
info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\020\003\r\nVCON\r\n"</FONT>, info);
}
}
} <FONT COLOR="#298C52">else</FONT>
<FONT COLOR=#A521F7>#endif</FONT>
info-&gt;xmit_count += c;
} <FONT COLOR="#298C52">else</FONT> {
info-&gt;msr |= UART_MSR_CTS;
info-&gt;lsr |= UART_LSR_TEMT;
<FONT COLOR="#298C52">if</FONT> (info-&gt;dialing) {
info-&gt;dialing = 0;
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_HUP
printk(KERN_DEBUG <FONT COLOR="#FF0000">"Mhup in isdn_tty_write\n"</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(3, info);
<A HREF="#isdn_tty_modem_hup">isdn_tty_modem_hup</A>(info, 1);
} <FONT COLOR="#298C52">else</FONT>
c = <A HREF="#isdn_tty_edit_at">isdn_tty_edit_at</A>(buf, c, info, from_user);
}
buf += c;
count -= c;
total += c;
}
<FONT COLOR="#298C52">if</FONT> ((info-&gt;xmit_count) || (skb_queue_len(&amp;info-&gt;xmit_queue)))
<A HREF="isdn_common.c.shtml#isdn_timer_ctrl">isdn_timer_ctrl</A>(<A HREF="../includes/isdn.h.shtml#ISDN_TIMER_MODEMXMIT">ISDN_TIMER_MODEMXMIT</A>, 1);
atomic_dec(&amp;info-&gt;xmit_lock);
<FONT COLOR="#298C52">if</FONT> (from_user)
up(&amp;info-&gt;write_sem);
<FONT COLOR="#298C52">return</FONT> total;
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A NAME="isdn_tty_write_room">isdn_tty_write_room</A>(<FONT COLOR="#298C52">struct</FONT> tty_struct *tty)
{
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info = (<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *) tty-&gt;driver_data;
<FONT COLOR="#298C52">int</FONT> ret;
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_paranoia_check">isdn_tty_paranoia_check</A>(info, tty-&gt;device, <FONT COLOR="#FF0000">"isdn_tty_write_room"</FONT>))
<FONT COLOR="#298C52">return</FONT> 0;
<FONT COLOR="#298C52">if</FONT> (!info-&gt;online)
<FONT COLOR="#298C52">return</FONT> info-&gt;xmit_size;
ret = info-&gt;xmit_size - info-&gt;xmit_count;
<FONT COLOR="#298C52">return</FONT> (ret &lt; 0) ? 0 : ret;
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A NAME="isdn_tty_chars_in_buffer">isdn_tty_chars_in_buffer</A>(<FONT COLOR="#298C52">struct</FONT> tty_struct *tty)
{
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info = (<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *) tty-&gt;driver_data;
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_paranoia_check">isdn_tty_paranoia_check</A>(info, tty-&gt;device, <FONT COLOR="#FF0000">"isdn_tty_chars_in_buffer"</FONT>))
<FONT COLOR="#298C52">return</FONT> 0;
<FONT COLOR="#298C52">if</FONT> (!info-&gt;online)
<FONT COLOR="#298C52">return</FONT> 0;
<FONT COLOR="#298C52">return</FONT> (info-&gt;xmit_count);
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_flush_buffer">isdn_tty_flush_buffer</A>(<FONT COLOR="#298C52">struct</FONT> tty_struct *tty)
{
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info;
<FONT COLOR="#298C52">unsigned</FONT> <FONT COLOR="#298C52">long</FONT> flags;
save_flags(flags);
<A HREF="kdebug.h.shtml#cli">cli</A>();
<FONT COLOR="#298C52">if</FONT> (!tty) {
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
<FONT COLOR="#298C52">return</FONT>;
}
info = (<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *) tty-&gt;driver_data;
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_paranoia_check">isdn_tty_paranoia_check</A>(info, tty-&gt;device, <FONT COLOR="#FF0000">"isdn_tty_flush_buffer"</FONT>)) {
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
<FONT COLOR="#298C52">return</FONT>;
}
<A HREF="#isdn_tty_cleanup_xmit">isdn_tty_cleanup_xmit</A>(info);
info-&gt;xmit_count = 0;
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
wake_up_interruptible(&amp;tty-&gt;write_wait);
<FONT COLOR="#298C52">if</FONT> ((tty-&gt;flags &amp; (1 &lt;&lt; TTY_DO_WRITE_WAKEUP)) &amp;&amp;
tty-&gt;ldisc.write_wakeup)
(tty-&gt;ldisc.write_wakeup) (tty);
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_flush_chars">isdn_tty_flush_chars</A>(<FONT COLOR="#298C52">struct</FONT> tty_struct *tty)
{
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info = (<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *) tty-&gt;driver_data;
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_paranoia_check">isdn_tty_paranoia_check</A>(info, tty-&gt;device, <FONT COLOR="#FF0000">"isdn_tty_flush_chars"</FONT>))
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR="#298C52">if</FONT> ((info-&gt;xmit_count) || (skb_queue_len(&amp;info-&gt;xmit_queue)))
<A HREF="isdn_common.c.shtml#isdn_timer_ctrl">isdn_timer_ctrl</A>(<A HREF="../includes/isdn.h.shtml#ISDN_TIMER_MODEMXMIT">ISDN_TIMER_MODEMXMIT</A>, 1);
}
<FONT COLOR=#0000FF>/*
* ------------------------------------------------------------
* isdn_tty_throttle()
*
* This routine is called by the upper-layer tty layer to signal that
* incoming characters should be throttled.
* ------------------------------------------------------------
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_throttle">isdn_tty_throttle</A>(<FONT COLOR="#298C52">struct</FONT> tty_struct *tty)
{
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info = (<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *) tty-&gt;driver_data;
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_paranoia_check">isdn_tty_paranoia_check</A>(info, tty-&gt;device, <FONT COLOR="#FF0000">"isdn_tty_throttle"</FONT>))
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR="#298C52">if</FONT> (I_IXOFF(tty))
info-&gt;x_char = STOP_CHAR(tty);
info-&gt;mcr &amp;= ~UART_MCR_RTS;
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_unthrottle">isdn_tty_unthrottle</A>(<FONT COLOR="#298C52">struct</FONT> tty_struct *tty)
{
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info = (<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *) tty-&gt;driver_data;
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_paranoia_check">isdn_tty_paranoia_check</A>(info, tty-&gt;device, <FONT COLOR="#FF0000">"isdn_tty_unthrottle"</FONT>))
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR="#298C52">if</FONT> (I_IXOFF(tty)) {
<FONT COLOR="#298C52">if</FONT> (info-&gt;x_char)
info-&gt;x_char = 0;
<FONT COLOR="#298C52">else</FONT>
info-&gt;x_char = START_CHAR(tty);
}
info-&gt;mcr |= UART_MCR_RTS;
}
<FONT COLOR=#0000FF>/*
* ------------------------------------------------------------
* isdn_tty_ioctl() and friends
* ------------------------------------------------------------
*/</FONT>
<FONT COLOR=#0000FF>/*
* isdn_tty_get_lsr_info - get line status register info
*
* Purpose: Let user call ioctl() to get info when the UART physically
* is emptied. On bus types like RS485, the transmitter must
* release the bus after transmitting. This must be done when
* the transmit shift register is empty, not be done when the
* transmit holding register is empty. This functionality
* allows RS485 driver to be written in user space.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A HREF="#isdn_tty_get_lsr_info">isdn_tty_get_lsr_info</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info, uint * value)
{
u_char status;
uint result;
ulong flags;
save_flags(flags);
<A HREF="kdebug.h.shtml#cli">cli</A>();
status = info-&gt;lsr;
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
result = ((status &amp; UART_LSR_TEMT) ? TIOCSER_TEMT : 0);
put_user(result, (uint *) value);
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A HREF="#isdn_tty_get_modem_info">isdn_tty_get_modem_info</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info, uint * value)
{
u_char control,
status;
uint result;
ulong flags;
control = info-&gt;mcr;
save_flags(flags);
<A HREF="kdebug.h.shtml#cli">cli</A>();
status = info-&gt;msr;
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
result = ((control &amp; UART_MCR_RTS) ? TIOCM_RTS : 0)
| ((control &amp; UART_MCR_DTR) ? TIOCM_DTR : 0)
| ((status &amp; UART_MSR_DCD) ? TIOCM_CAR : 0)
| ((status &amp; UART_MSR_RI) ? TIOCM_RNG : 0)
| ((status &amp; UART_MSR_DSR) ? TIOCM_DSR : 0)
| ((status &amp; UART_MSR_CTS) ? TIOCM_CTS : 0);
put_user(result, (uint *) value);
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A HREF="#isdn_tty_set_modem_info">isdn_tty_set_modem_info</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info, uint cmd, uint * value)
{
uint arg;
<FONT COLOR="#298C52">int</FONT> pre_dtr;
get_user(arg, (uint *) value);
<FONT COLOR="#298C52">switch</FONT> (cmd) {
<FONT COLOR="#298C52">case</FONT> TIOCMBIS:
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_IOCTL
printk(KERN_DEBUG <FONT COLOR="#FF0000">"ttyI%d ioctl TIOCMBIS\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (arg &amp; TIOCM_RTS) {
info-&gt;mcr |= UART_MCR_RTS;
}
<FONT COLOR="#298C52">if</FONT> (arg &amp; TIOCM_DTR) {
info-&gt;mcr |= UART_MCR_DTR;
<A HREF="#isdn_tty_modem_ncarrier">isdn_tty_modem_ncarrier</A>(info);
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> TIOCMBIC:
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_IOCTL
printk(KERN_DEBUG <FONT COLOR="#FF0000">"ttyI%d ioctl TIOCMBIC\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (arg &amp; TIOCM_RTS) {
info-&gt;mcr &amp;= ~UART_MCR_RTS;
}
<FONT COLOR="#298C52">if</FONT> (arg &amp; TIOCM_DTR) {
info-&gt;mcr &amp;= ~UART_MCR_DTR;
<FONT COLOR="#298C52">if</FONT> (info-&gt;emu.mdmreg[<A HREF="#REG_DTRHUP">REG_DTRHUP</A>] &amp; <A HREF="#BIT_DTRHUP">BIT_DTRHUP</A>) {
<A HREF="#isdn_tty_modem_reset_regs">isdn_tty_modem_reset_regs</A>(info, 0);
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_HUP
printk(KERN_DEBUG <FONT COLOR="#FF0000">"Mhup in TIOCMBIC\n"</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (info-&gt;online)
info-&gt;ncarrier = 1;
<A HREF="#isdn_tty_modem_hup">isdn_tty_modem_hup</A>(info, 1);
}
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> TIOCMSET:
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_IOCTL
printk(KERN_DEBUG <FONT COLOR="#FF0000">"ttyI%d ioctl TIOCMSET\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
pre_dtr = (info-&gt;mcr &amp; UART_MCR_DTR);
info-&gt;mcr = ((info-&gt;mcr &amp; ~(UART_MCR_RTS | UART_MCR_DTR))
| ((arg &amp; TIOCM_RTS) ? UART_MCR_RTS : 0)
| ((arg &amp; TIOCM_DTR) ? UART_MCR_DTR : 0));
<FONT COLOR="#298C52">if</FONT> (pre_dtr |= (info-&gt;mcr &amp; UART_MCR_DTR)) {
<FONT COLOR="#298C52">if</FONT> (!(info-&gt;mcr &amp; UART_MCR_DTR)) {
<FONT COLOR="#298C52">if</FONT> (info-&gt;emu.mdmreg[<A HREF="#REG_DTRHUP">REG_DTRHUP</A>] &amp; <A HREF="#BIT_DTRHUP">BIT_DTRHUP</A>) {
<A HREF="#isdn_tty_modem_reset_regs">isdn_tty_modem_reset_regs</A>(info, 0);
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_HUP
printk(KERN_DEBUG <FONT COLOR="#FF0000">"Mhup in TIOCMSET\n"</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (info-&gt;online)
info-&gt;ncarrier = 1;
<A HREF="#isdn_tty_modem_hup">isdn_tty_modem_hup</A>(info, 1);
}
} <FONT COLOR="#298C52">else</FONT>
<A HREF="#isdn_tty_modem_ncarrier">isdn_tty_modem_ncarrier</A>(info);
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<FONT COLOR="#298C52">return</FONT> -EINVAL;
}
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A HREF="#isdn_tty_ioctl">isdn_tty_ioctl</A>(<FONT COLOR="#298C52">struct</FONT> tty_struct *tty, <FONT COLOR="#298C52">struct</FONT> file *file,
uint cmd, ulong arg)
{
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info = (<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *) tty-&gt;driver_data;
<FONT COLOR="#298C52">int</FONT> error;
<FONT COLOR="#298C52">int</FONT> retval;
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_paranoia_check">isdn_tty_paranoia_check</A>(info, tty-&gt;device, <FONT COLOR="#FF0000">"isdn_tty_ioctl"</FONT>))
<FONT COLOR="#298C52">return</FONT> -ENODEV;
<FONT COLOR="#298C52">if</FONT> (tty-&gt;flags &amp; (1 &lt;&lt; TTY_IO_ERROR))
<FONT COLOR="#298C52">return</FONT> -EIO;
<FONT COLOR="#298C52">switch</FONT> (cmd) {
<FONT COLOR="#298C52">case</FONT> TCSBRK: <FONT COLOR=#0000FF>/* SVID version: non-zero arg --&gt; no break */</FONT>
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_IOCTL
printk(KERN_DEBUG <FONT COLOR="#FF0000">"ttyI%d ioctl TCSBRK\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
retval = tty_check_change(tty);
<FONT COLOR="#298C52">if</FONT> (retval)
<FONT COLOR="#298C52">return</FONT> retval;
tty_wait_until_sent(tty, 0);
<FONT COLOR="#298C52">return</FONT> 0;
<FONT COLOR="#298C52">case</FONT> TCSBRKP: <FONT COLOR=#0000FF>/* support for POSIX tcsendbreak() */</FONT>
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_IOCTL
printk(KERN_DEBUG <FONT COLOR="#FF0000">"ttyI%d ioctl TCSBRKP\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
retval = tty_check_change(tty);
<FONT COLOR="#298C52">if</FONT> (retval)
<FONT COLOR="#298C52">return</FONT> retval;
tty_wait_until_sent(tty, 0);
<FONT COLOR="#298C52">return</FONT> 0;
<FONT COLOR="#298C52">case</FONT> TIOCGSOFTCAR:
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_IOCTL
printk(KERN_DEBUG <FONT COLOR="#FF0000">"ttyI%d ioctl TIOCGSOFTCAR\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
error = verify_area(VERIFY_WRITE, (<FONT COLOR="#298C52">void</FONT> *) arg, <FONT COLOR="#298C52">sizeof</FONT>(<FONT COLOR="#298C52">long</FONT>));
<FONT COLOR="#298C52">if</FONT> (error)
<FONT COLOR="#298C52">return</FONT> error;
put_user(C_CLOCAL(tty) ? 1 : 0, (ulong *) arg);
<FONT COLOR="#298C52">return</FONT> 0;
<FONT COLOR="#298C52">case</FONT> TIOCSSOFTCAR:
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_IOCTL
printk(KERN_DEBUG <FONT COLOR="#FF0000">"ttyI%d ioctl TIOCSSOFTCAR\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
error = verify_area(VERIFY_READ, (<FONT COLOR="#298C52">void</FONT> *) arg, <FONT COLOR="#298C52">sizeof</FONT>(<FONT COLOR="#298C52">long</FONT>));
<FONT COLOR="#298C52">if</FONT> (error)
<FONT COLOR="#298C52">return</FONT> error;
get_user(arg, (ulong *) arg);
tty-&gt;termios-&gt;c_cflag =
((tty-&gt;termios-&gt;c_cflag &amp; ~CLOCAL) |
(arg ? CLOCAL : 0));
<FONT COLOR="#298C52">return</FONT> 0;
<FONT COLOR="#298C52">case</FONT> TIOCMGET:
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_IOCTL
printk(KERN_DEBUG <FONT COLOR="#FF0000">"ttyI%d ioctl TIOCMGET\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
error = verify_area(VERIFY_WRITE, (<FONT COLOR="#298C52">void</FONT> *) arg, <FONT COLOR="#298C52">sizeof</FONT>(uint));
<FONT COLOR="#298C52">if</FONT> (error)
<FONT COLOR="#298C52">return</FONT> error;
<FONT COLOR="#298C52">return</FONT> <A HREF="#isdn_tty_get_modem_info">isdn_tty_get_modem_info</A>(info, (uint *) arg);
<FONT COLOR="#298C52">case</FONT> TIOCMBIS:
<FONT COLOR="#298C52">case</FONT> TIOCMBIC:
<FONT COLOR="#298C52">case</FONT> TIOCMSET:
error = verify_area(VERIFY_READ, (<FONT COLOR="#298C52">void</FONT> *) arg, <FONT COLOR="#298C52">sizeof</FONT>(uint));
<FONT COLOR="#298C52">if</FONT> (error)
<FONT COLOR="#298C52">return</FONT> error;
<FONT COLOR="#298C52">return</FONT> <A HREF="#isdn_tty_set_modem_info">isdn_tty_set_modem_info</A>(info, cmd, (uint *) arg);
<FONT COLOR="#298C52">case</FONT> TIOCSERGETLSR: <FONT COLOR=#0000FF>/* Get line status register */</FONT>
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_IOCTL
printk(KERN_DEBUG <FONT COLOR="#FF0000">"ttyI%d ioctl TIOCSERGETLSR\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
error = verify_area(VERIFY_WRITE, (<FONT COLOR="#298C52">void</FONT> *) arg, <FONT COLOR="#298C52">sizeof</FONT>(uint));
<FONT COLOR="#298C52">if</FONT> (error)
<FONT COLOR="#298C52">return</FONT> error;
<FONT COLOR="#298C52">else</FONT>
<FONT COLOR="#298C52">return</FONT> <A HREF="#isdn_tty_get_lsr_info">isdn_tty_get_lsr_info</A>(info, (uint *) arg);
<FONT COLOR="#298C52">default</FONT>:
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_IOCTL
printk(KERN_DEBUG <FONT COLOR="#FF0000">"UNKNOWN ioctl 0x%08x on ttyi%d\n"</FONT>, cmd, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">return</FONT> -ENOIOCTLCMD;
}
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A HREF="#isdn_tty_set_termios">isdn_tty_set_termios</A>(<FONT COLOR="#298C52">struct</FONT> tty_struct *tty, <FONT COLOR="#298C52">struct</FONT> termios *old_termios)
{
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info = (<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *) tty-&gt;driver_data;
<FONT COLOR="#298C52">if</FONT> (!old_termios)
<A HREF="#isdn_tty_change_speed">isdn_tty_change_speed</A>(info);
<FONT COLOR="#298C52">else</FONT> {
<FONT COLOR="#298C52">if</FONT> (tty-&gt;termios-&gt;c_cflag == old_termios-&gt;c_cflag)
<FONT COLOR="#298C52">return</FONT>;
<A HREF="#isdn_tty_change_speed">isdn_tty_change_speed</A>(info);
<FONT COLOR="#298C52">if</FONT> ((old_termios-&gt;c_cflag &amp; CRTSCTS) &amp;&amp;
!(tty-&gt;termios-&gt;c_cflag &amp; CRTSCTS)) {
tty-&gt;hw_stopped = 0;
}
}
}
<FONT COLOR=#0000FF>/*
* ------------------------------------------------------------
* isdn_tty_open() and friends
* ------------------------------------------------------------
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A HREF="#isdn_tty_block_til_ready">isdn_tty_block_til_ready</A>(<FONT COLOR="#298C52">struct</FONT> tty_struct *tty, <FONT COLOR="#298C52">struct</FONT> file *filp, <A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
<FONT COLOR="#298C52">struct</FONT> wait_queue wait =
{current, NULL};
<FONT COLOR="#298C52">int</FONT> do_clocal = 0;
<FONT COLOR="#298C52">unsigned</FONT> <FONT COLOR="#298C52">long</FONT> flags;
<FONT COLOR="#298C52">int</FONT> retval;
<FONT COLOR=#0000FF>/*
* If the device is in the middle of being closed, then block
* until it's done, and then try again.
*/</FONT>
<FONT COLOR="#298C52">if</FONT> (tty_hung_up_p(filp) ||
(info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CLOSING">ISDN_ASYNC_CLOSING</A>)) {
<FONT COLOR="#298C52">if</FONT> (info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CLOSING">ISDN_ASYNC_CLOSING</A>)
interruptible_sleep_on(&amp;info-&gt;close_wait);
<FONT COLOR=#A521F7>#ifdef</FONT> <A HREF="#MODEM_DO_RESTART">MODEM_DO_RESTART</A>
<FONT COLOR="#298C52">if</FONT> (info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_HUP_NOTIFY">ISDN_ASYNC_HUP_NOTIFY</A>)
<FONT COLOR="#298C52">return</FONT> -EAGAIN;
<FONT COLOR="#298C52">else</FONT>
<FONT COLOR="#298C52">return</FONT> -ERESTARTSYS;
<FONT COLOR=#A521F7>#else</FONT>
<FONT COLOR="#298C52">return</FONT> -EAGAIN;
<FONT COLOR=#A521F7>#endif</FONT>
}
<FONT COLOR=#0000FF>/*
* If this is a callout device, then just make sure the normal
* device isn't being used.
*/</FONT>
<FONT COLOR="#298C52">if</FONT> (tty-&gt;<A HREF="../includes/isdn.h.shtml#driver">driver</A>.subtype == <A HREF="../includes/isdn.h.shtml#ISDN_SERIAL_TYPE_CALLOUT">ISDN_SERIAL_TYPE_CALLOUT</A>) {
<FONT COLOR="#298C52">if</FONT> (info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_NORMAL_ACTIVE">ISDN_ASYNC_NORMAL_ACTIVE</A>)
<FONT COLOR="#298C52">return</FONT> -EBUSY;
<FONT COLOR="#298C52">if</FONT> ((info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CALLOUT_ACTIVE">ISDN_ASYNC_CALLOUT_ACTIVE</A>) &amp;&amp;
(info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_SESSION_LOCKOUT">ISDN_ASYNC_SESSION_LOCKOUT</A>) &amp;&amp;
(info-&gt;session != current-&gt;session))
<FONT COLOR="#298C52">return</FONT> -EBUSY;
<FONT COLOR="#298C52">if</FONT> ((info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CALLOUT_ACTIVE">ISDN_ASYNC_CALLOUT_ACTIVE</A>) &amp;&amp;
(info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_PGRP_LOCKOUT">ISDN_ASYNC_PGRP_LOCKOUT</A>) &amp;&amp;
(info-&gt;pgrp != current-&gt;pgrp))
<FONT COLOR="#298C52">return</FONT> -EBUSY;
info-&gt;flags |= <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CALLOUT_ACTIVE">ISDN_ASYNC_CALLOUT_ACTIVE</A>;
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR=#0000FF>/*
* If non-blocking mode is set, then make the check up front
* and then exit.
*/</FONT>
<FONT COLOR="#298C52">if</FONT> ((filp-&gt;f_flags &amp; O_NONBLOCK) ||
(tty-&gt;flags &amp; (1 &lt;&lt; TTY_IO_ERROR))) {
<FONT COLOR="#298C52">if</FONT> (info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CALLOUT_ACTIVE">ISDN_ASYNC_CALLOUT_ACTIVE</A>)
<FONT COLOR="#298C52">return</FONT> -EBUSY;
info-&gt;flags |= <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_NORMAL_ACTIVE">ISDN_ASYNC_NORMAL_ACTIVE</A>;
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">if</FONT> (info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CALLOUT_ACTIVE">ISDN_ASYNC_CALLOUT_ACTIVE</A>) {
<FONT COLOR="#298C52">if</FONT> (info-&gt;normal_termios.c_cflag &amp; CLOCAL)
do_clocal = 1;
} <FONT COLOR="#298C52">else</FONT> {
<FONT COLOR="#298C52">if</FONT> (tty-&gt;termios-&gt;c_cflag &amp; CLOCAL)
do_clocal = 1;
}
<FONT COLOR=#0000FF>/*
* Block waiting for the carrier detect and the line to become
* free (i.e., not in use by the callout). While we are in
* this loop, info-&gt;count is dropped by one, so that
* isdn_tty_close() knows when to free things. We restore it upon
* exit, either normal or abnormal.
*/</FONT>
retval = 0;
add_wait_queue(&amp;info-&gt;open_wait, &amp;wait);
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty_block_til_ready before block: ttyi%d, count = %d\n"</FONT>,
info-&gt;line, info-&gt;count);
<FONT COLOR=#A521F7>#endif</FONT>
save_flags(flags);
<A HREF="kdebug.h.shtml#cli">cli</A>();
<FONT COLOR="#298C52">if</FONT> (!(tty_hung_up_p(filp)))
info-&gt;count--;
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
info-&gt;blocked_open++;
<FONT COLOR="#298C52">while</FONT> (1) {
current-&gt;state = TASK_INTERRUPTIBLE;
<FONT COLOR="#298C52">if</FONT> (tty_hung_up_p(filp) ||
!(info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_INITIALIZED">ISDN_ASYNC_INITIALIZED</A>)) {
<FONT COLOR=#A521F7>#ifdef</FONT> <A HREF="#MODEM_DO_RESTART">MODEM_DO_RESTART</A>
<FONT COLOR="#298C52">if</FONT> (info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_HUP_NOTIFY">ISDN_ASYNC_HUP_NOTIFY</A>)
retval = -EAGAIN;
<FONT COLOR="#298C52">else</FONT>
retval = -ERESTARTSYS;
<FONT COLOR=#A521F7>#else</FONT>
retval = -EAGAIN;
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">break</FONT>;
}
<FONT COLOR="#298C52">if</FONT> (!(info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CALLOUT_ACTIVE">ISDN_ASYNC_CALLOUT_ACTIVE</A>) &amp;&amp;
!(info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CLOSING">ISDN_ASYNC_CLOSING</A>) &amp;&amp;
(do_clocal || (info-&gt;msr &amp; UART_MSR_DCD))) {
<FONT COLOR="#298C52">break</FONT>;
}
<FONT COLOR="#298C52">if</FONT> (signal_pending(current)) {
retval = -ERESTARTSYS;
<FONT COLOR="#298C52">break</FONT>;
}
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty_block_til_ready blocking: ttyi%d, count = %d\n"</FONT>,
info-&gt;line, info-&gt;count);
<FONT COLOR=#A521F7>#endif</FONT>
schedule();
}
current-&gt;state = TASK_RUNNING;
remove_wait_queue(&amp;info-&gt;open_wait, &amp;wait);
<FONT COLOR="#298C52">if</FONT> (!tty_hung_up_p(filp))
info-&gt;count++;
info-&gt;blocked_open--;
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty_block_til_ready after blocking: ttyi%d, count = %d\n"</FONT>,
info-&gt;line, info-&gt;count);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (retval)
<FONT COLOR="#298C52">return</FONT> retval;
info-&gt;flags |= <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_NORMAL_ACTIVE">ISDN_ASYNC_NORMAL_ACTIVE</A>;
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR=#0000FF>/*
* This routine is called whenever a serial port is opened. It
* enables interrupts for a serial port, linking in its async structure into
* the IRQ chain. It also performs the serial-specific
* initialization for the tty structure.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A HREF="#isdn_tty_open">isdn_tty_open</A>(<FONT COLOR="#298C52">struct</FONT> tty_struct *tty, <FONT COLOR="#298C52">struct</FONT> file *filp)
{
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info;
<FONT COLOR="#298C52">int</FONT> retval,
line;
line = MINOR(tty-&gt;device) - tty-&gt;<A HREF="../includes/isdn.h.shtml#driver">driver</A>.minor_start;
<FONT COLOR="#298C52">if</FONT> (line &lt; 0 || line &gt; <A HREF="../includes/isdn.h.shtml#ISDN_MAX_CHANNELS">ISDN_MAX_CHANNELS</A>)
<FONT COLOR="#298C52">return</FONT> -ENODEV;
info = &amp;dev-&gt;mdm.info[line];
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_paranoia_check">isdn_tty_paranoia_check</A>(info, tty-&gt;device, <FONT COLOR="#FF0000">"isdn_tty_open"</FONT>))
<FONT COLOR="#298C52">return</FONT> -ENODEV;
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty_open %s%d, count = %d\n"</FONT>, tty-&gt;<A HREF="../includes/isdn.h.shtml#driver">driver</A>.<A HREF="isdn_common.c.shtml#name">name</A>,
info-&gt;line, info-&gt;count);
<FONT COLOR=#A521F7>#endif</FONT>
info-&gt;count++;
tty-&gt;driver_data = info;
info-&gt;tty = tty;
<FONT COLOR=#0000FF>/*
* Start up serial port
*/</FONT>
retval = <A HREF="#isdn_tty_startup">isdn_tty_startup</A>(info);
<FONT COLOR="#298C52">if</FONT> (retval) {
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty_open return after startup\n"</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">return</FONT> retval;
}
retval = <A HREF="#isdn_tty_block_til_ready">isdn_tty_block_til_ready</A>(tty, filp, info);
<FONT COLOR="#298C52">if</FONT> (retval) {
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty_open return after isdn_tty_block_til_ready \n"</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">return</FONT> retval;
}
<FONT COLOR="#298C52">if</FONT> ((info-&gt;count == 1) &amp;&amp; (info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_SPLIT_TERMIOS">ISDN_ASYNC_SPLIT_TERMIOS</A>)) {
<FONT COLOR="#298C52">if</FONT> (tty-&gt;<A HREF="../includes/isdn.h.shtml#driver">driver</A>.subtype == <A HREF="../includes/isdn.h.shtml#ISDN_SERIAL_TYPE_NORMAL">ISDN_SERIAL_TYPE_NORMAL</A>)
*tty-&gt;termios = info-&gt;normal_termios;
<FONT COLOR="#298C52">else</FONT>
*tty-&gt;termios = info-&gt;callout_termios;
<A HREF="#isdn_tty_change_speed">isdn_tty_change_speed</A>(info);
}
info-&gt;session = current-&gt;session;
info-&gt;pgrp = current-&gt;pgrp;
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty_open ttyi%d successful...\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
dev-&gt;modempoll++;
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty_open normal exit\n"</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A HREF="#isdn_tty_close">isdn_tty_close</A>(<FONT COLOR="#298C52">struct</FONT> tty_struct *tty, <FONT COLOR="#298C52">struct</FONT> file *filp)
{
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info = (<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *) tty-&gt;driver_data;
ulong flags;
ulong timeout;
<FONT COLOR="#298C52">if</FONT> (!info || <A HREF="#isdn_tty_paranoia_check">isdn_tty_paranoia_check</A>(info, tty-&gt;device, <FONT COLOR="#FF0000">"isdn_tty_close"</FONT>))
<FONT COLOR="#298C52">return</FONT>;
save_flags(flags);
<A HREF="kdebug.h.shtml#cli">cli</A>();
<FONT COLOR="#298C52">if</FONT> (tty_hung_up_p(filp)) {
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty_close return after tty_hung_up_p\n"</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">return</FONT>;
}
<FONT COLOR="#298C52">if</FONT> ((tty-&gt;count == 1) &amp;&amp; (info-&gt;count != 1)) {
<FONT COLOR=#0000FF>/*
* Uh, oh. tty-&gt;count is 1, which means that the tty
* structure will be freed. Info-&gt;count should always
* be one in these conditions. If it's greater than
* one, we've got real problems, since it means the
* serial port won't be shutdown.
*/</FONT>
printk(KERN_ERR <FONT COLOR="#FF0000">"isdn_tty_close: bad port count; tty-&gt;count is 1, "</FONT>
<FONT COLOR="#FF0000">"info-&gt;count is %d\n"</FONT>, info-&gt;count);
info-&gt;count = 1;
}
<FONT COLOR="#298C52">if</FONT> (--info-&gt;count &lt; 0) {
printk(KERN_ERR <FONT COLOR="#FF0000">"isdn_tty_close: bad port count for ttyi%d: %d\n"</FONT>,
info-&gt;line, info-&gt;count);
info-&gt;count = 0;
}
<FONT COLOR="#298C52">if</FONT> (info-&gt;count) {
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty_close after info-&gt;count != 0\n"</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">return</FONT>;
}
info-&gt;flags |= <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CLOSING">ISDN_ASYNC_CLOSING</A>;
<FONT COLOR=#0000FF>/*
* Save the termios structure, since this port may have
* separate termios for callout and dialin.
*/</FONT>
<FONT COLOR="#298C52">if</FONT> (info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_NORMAL_ACTIVE">ISDN_ASYNC_NORMAL_ACTIVE</A>)
info-&gt;normal_termios = *tty-&gt;termios;
<FONT COLOR="#298C52">if</FONT> (info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CALLOUT_ACTIVE">ISDN_ASYNC_CALLOUT_ACTIVE</A>)
info-&gt;callout_termios = *tty-&gt;termios;
tty-&gt;closing = 1;
<FONT COLOR=#0000FF>/*
* At this point we stop accepting input. To do this, we
* disable the receive line status interrupts, and tell the
* interrupt driver to stop checking the data ready bit in the
* line status register.
*/</FONT>
<FONT COLOR="#298C52">if</FONT> (info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_INITIALIZED">ISDN_ASYNC_INITIALIZED</A>) {
tty_wait_until_sent(tty, 3000); <FONT COLOR=#0000FF>/* 30 seconds timeout */</FONT>
<FONT COLOR=#0000FF>/*
* Before we drop DTR, make sure the UART transmitter
* has completely drained; this is especially
* important if there is a transmit FIFO!
*/</FONT>
timeout = jiffies + HZ;
<FONT COLOR="#298C52">while</FONT> (!(info-&gt;lsr &amp; UART_LSR_TEMT)) {
current-&gt;state = TASK_INTERRUPTIBLE;
current-&gt;timeout = jiffies + 20;
schedule();
<FONT COLOR="#298C52">if</FONT> (jiffies &gt; timeout)
<FONT COLOR="#298C52">break</FONT>;
}
}
dev-&gt;modempoll--;
<A HREF="#isdn_tty_shutdown">isdn_tty_shutdown</A>(info);
<FONT COLOR="#298C52">if</FONT> (tty-&gt;<A HREF="../includes/isdn.h.shtml#driver">driver</A>.flush_buffer)
tty-&gt;<A HREF="../includes/isdn.h.shtml#driver">driver</A>.flush_buffer(tty);
<FONT COLOR="#298C52">if</FONT> (tty-&gt;ldisc.flush_buffer)
tty-&gt;ldisc.flush_buffer(tty);
info-&gt;tty = 0;
info-&gt;ncarrier = 0;
tty-&gt;closing = 0;
<FONT COLOR="#298C52">if</FONT> (info-&gt;blocked_open) {
current-&gt;state = TASK_INTERRUPTIBLE;
current-&gt;timeout = jiffies + 50;
schedule();
wake_up_interruptible(&amp;info-&gt;open_wait);
}
info-&gt;flags &amp;= ~(<A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_NORMAL_ACTIVE">ISDN_ASYNC_NORMAL_ACTIVE</A> | <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CALLOUT_ACTIVE">ISDN_ASYNC_CALLOUT_ACTIVE</A> |
<A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CLOSING">ISDN_ASYNC_CLOSING</A>);
wake_up_interruptible(&amp;info-&gt;close_wait);
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_OPEN
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty_close normal exit\n"</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
}
<FONT COLOR=#0000FF>/*
* isdn_tty_hangup() --- called by tty_hangup() when a hangup is signaled.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_hangup">isdn_tty_hangup</A>(<FONT COLOR="#298C52">struct</FONT> tty_struct *tty)
{
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info = (<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *) tty-&gt;driver_data;
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_paranoia_check">isdn_tty_paranoia_check</A>(info, tty-&gt;device, <FONT COLOR="#FF0000">"isdn_tty_hangup"</FONT>))
<FONT COLOR="#298C52">return</FONT>;
<A HREF="#isdn_tty_shutdown">isdn_tty_shutdown</A>(info);
info-&gt;count = 0;
info-&gt;flags &amp;= ~(<A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_NORMAL_ACTIVE">ISDN_ASYNC_NORMAL_ACTIVE</A> | <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CALLOUT_ACTIVE">ISDN_ASYNC_CALLOUT_ACTIVE</A>);
info-&gt;tty = 0;
wake_up_interruptible(&amp;info-&gt;open_wait);
}
<FONT COLOR=#0000FF>/* This routine initializes all emulator-data.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_reset_profile">isdn_tty_reset_profile</A>(<A HREF="../includes/isdn.h.shtml#atemu">atemu</A> * m)
{
m-&gt;profile[0] = 0;
m-&gt;profile[1] = 0;
m-&gt;profile[2] = 43;
m-&gt;profile[3] = 13;
m-&gt;profile[4] = 10;
m-&gt;profile[5] = 8;
m-&gt;profile[6] = 3;
m-&gt;profile[7] = 60;
m-&gt;profile[8] = 2;
m-&gt;profile[9] = 6;
m-&gt;profile[10] = 7;
m-&gt;profile[11] = 70;
m-&gt;profile[12] = 0x45;
m-&gt;profile[13] = 4;
m-&gt;profile[14] = <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_X75I">ISDN_PROTO_L2_X75I</A>;
m-&gt;profile[15] = <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L3_TRANS">ISDN_PROTO_L3_TRANS</A>;
m-&gt;profile[16] = <A HREF="../includes/isdn.h.shtml#ISDN_SERIAL_XMIT_SIZE">ISDN_SERIAL_XMIT_SIZE</A> / 16;
m-&gt;profile[17] = <A HREF="../includes/isdn.h.shtml#ISDN_MODEM_WINSIZE">ISDN_MODEM_WINSIZE</A>;
m-&gt;profile[18] = 4;
m-&gt;profile[19] = 0;
m-&gt;profile[20] = 0;
m-&gt;pmsn[0] = <FONT COLOR="#FF0000">'\0'</FONT>;
m-&gt;plmsn[0] = <FONT COLOR="#FF0000">'\0'</FONT>;
}
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_modem_reset_vpar">isdn_tty_modem_reset_vpar</A>(<A HREF="../includes/isdn.h.shtml#atemu">atemu</A> * m)
{
m-&gt;vpar[0] = 2; <FONT COLOR=#0000FF>/* Voice-device (2 = phone line) */</FONT>
m-&gt;vpar[1] = 0; <FONT COLOR=#0000FF>/* Silence detection level (0 = none ) */</FONT>
m-&gt;vpar[2] = 70; <FONT COLOR=#0000FF>/* Silence interval (7 sec. ) */</FONT>
m-&gt;vpar[3] = 2; <FONT COLOR=#0000FF>/* Compression type (1 = ADPCM-2 ) */</FONT>
}
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A HREF="#isdn_tty_modem_reset_regs">isdn_tty_modem_reset_regs</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info, <FONT COLOR="#298C52">int</FONT> force)
{
<A HREF="../includes/isdn.h.shtml#atemu">atemu</A> *m = &amp;info-&gt;emu;
<FONT COLOR="#298C52">if</FONT> ((m-&gt;mdmreg[<A HREF="#REG_DTRR">REG_DTRR</A>] &amp; <A HREF="#BIT_DTRR">BIT_DTRR</A>) || force) {
memcpy(m-&gt;mdmreg, m-&gt;profile, <A HREF="../includes/isdn.h.shtml#ISDN_MODEM_ANZREG">ISDN_MODEM_ANZREG</A>);
memcpy(m-&gt;msn, m-&gt;pmsn, <A HREF="../includes/isdn.h.shtml#ISDN_MSNLEN">ISDN_MSNLEN</A>);
memcpy(m-&gt;lmsn, m-&gt;plmsn, <A HREF="../includes/isdn.h.shtml#ISDN_LMSNLEN">ISDN_LMSNLEN</A>);
info-&gt;xmit_size = m-&gt;mdmreg[<A HREF="#REG_PSIZE">REG_PSIZE</A>] * 16;
}
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<A HREF="#isdn_tty_modem_reset_vpar">isdn_tty_modem_reset_vpar</A>(m);
<FONT COLOR=#A521F7>#endif</FONT>
m-&gt;mdmcmdl = 0;
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="modem_write_profile">modem_write_profile</A>(<A HREF="../includes/isdn.h.shtml#atemu">atemu</A> * m)
{
memcpy(m-&gt;profile, m-&gt;mdmreg, <A HREF="../includes/isdn.h.shtml#ISDN_MODEM_ANZREG">ISDN_MODEM_ANZREG</A>);
memcpy(m-&gt;pmsn, m-&gt;msn, <A HREF="../includes/isdn.h.shtml#ISDN_MSNLEN">ISDN_MSNLEN</A>);
memcpy(m-&gt;plmsn, m-&gt;lmsn, <A HREF="../includes/isdn.h.shtml#ISDN_LMSNLEN">ISDN_LMSNLEN</A>);
<FONT COLOR="#298C52">if</FONT> (dev-&gt;profd)
send_sig(SIGIO, dev-&gt;profd, 1);
}
<FONT COLOR="#298C52">int</FONT>
<A NAME="isdn_tty_modem_init">isdn_tty_modem_init</A>(<FONT COLOR="#298C52">void</FONT>)
{
<A HREF="../includes/isdn.h.shtml#modem">modem</A> *m;
<FONT COLOR="#298C52">int</FONT> i;
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info;
m = &amp;dev-&gt;mdm;
memset(&amp;m-&gt;tty_modem, 0, <FONT COLOR="#298C52">sizeof</FONT>(<FONT COLOR="#298C52">struct</FONT> tty_driver));
m-&gt;tty_modem.magic = TTY_DRIVER_MAGIC;
m-&gt;tty_modem.<A HREF="isdn_common.c.shtml#name">name</A> = isdn_ttyname_ttyI;
m-&gt;tty_modem.major = <A HREF="../includes/isdn.h.shtml#ISDN_TTY_MAJOR">ISDN_TTY_MAJOR</A>;
m-&gt;tty_modem.minor_start = 0;
m-&gt;tty_modem.num = <A HREF="../includes/isdn.h.shtml#ISDN_MAX_CHANNELS">ISDN_MAX_CHANNELS</A>;
m-&gt;tty_modem.type = TTY_DRIVER_TYPE_SERIAL;
m-&gt;tty_modem.subtype = <A HREF="../includes/isdn.h.shtml#ISDN_SERIAL_TYPE_NORMAL">ISDN_SERIAL_TYPE_NORMAL</A>;
m-&gt;tty_modem.init_termios = tty_std_termios;
m-&gt;tty_modem.init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
m-&gt;tty_modem.flags = TTY_DRIVER_REAL_RAW;
m-&gt;tty_modem.refcount = &amp;m-&gt;refcount;
m-&gt;tty_modem.table = m-&gt;modem_table;
m-&gt;tty_modem.termios = m-&gt;modem_termios;
m-&gt;tty_modem.termios_locked = m-&gt;modem_termios_locked;
m-&gt;tty_modem.open = <A HREF="#isdn_tty_open">isdn_tty_open</A>;
m-&gt;tty_modem.close = <A HREF="#isdn_tty_close">isdn_tty_close</A>;
m-&gt;tty_modem.write = <A HREF="#isdn_tty_write">isdn_tty_write</A>;
m-&gt;tty_modem.put_char = NULL;
m-&gt;tty_modem.flush_chars = <A HREF="#isdn_tty_flush_chars">isdn_tty_flush_chars</A>;
m-&gt;tty_modem.write_room = <A HREF="#isdn_tty_write_room">isdn_tty_write_room</A>;
m-&gt;tty_modem.chars_in_buffer = <A HREF="#isdn_tty_chars_in_buffer">isdn_tty_chars_in_buffer</A>;
m-&gt;tty_modem.flush_buffer = <A HREF="#isdn_tty_flush_buffer">isdn_tty_flush_buffer</A>;
m-&gt;tty_modem.ioctl = <A HREF="#isdn_tty_ioctl">isdn_tty_ioctl</A>;
m-&gt;tty_modem.throttle = <A HREF="#isdn_tty_throttle">isdn_tty_throttle</A>;
m-&gt;tty_modem.unthrottle = <A HREF="#isdn_tty_unthrottle">isdn_tty_unthrottle</A>;
m-&gt;tty_modem.set_termios = <A HREF="#isdn_tty_set_termios">isdn_tty_set_termios</A>;
m-&gt;tty_modem.stop = NULL;
m-&gt;tty_modem.start = NULL;
m-&gt;tty_modem.hangup = <A HREF="#isdn_tty_hangup">isdn_tty_hangup</A>;
m-&gt;tty_modem.driver_name = <FONT COLOR="#FF0000">"isdn_tty"</FONT>;
<FONT COLOR=#0000FF>/*
* The callout device is just like normal device except for
* major number and the subtype code.
*/</FONT>
m-&gt;cua_modem = m-&gt;tty_modem;
m-&gt;cua_modem.<A HREF="isdn_common.c.shtml#name">name</A> = isdn_ttyname_cui;
m-&gt;cua_modem.major = <A HREF="../includes/isdn.h.shtml#ISDN_TTYAUX_MAJOR">ISDN_TTYAUX_MAJOR</A>;
m-&gt;tty_modem.minor_start = 0;
m-&gt;cua_modem.subtype = <A HREF="../includes/isdn.h.shtml#ISDN_SERIAL_TYPE_CALLOUT">ISDN_SERIAL_TYPE_CALLOUT</A>;
<FONT COLOR="#298C52">if</FONT> (tty_register_driver(&amp;m-&gt;tty_modem)) {
printk(KERN_WARNING <FONT COLOR="#FF0000">"isdn_tty: Couldn't register modem-device\n"</FONT>);
<FONT COLOR="#298C52">return</FONT> -1;
}
<FONT COLOR="#298C52">if</FONT> (tty_register_driver(&amp;m-&gt;cua_modem)) {
printk(KERN_WARNING <FONT COLOR="#FF0000">"isdn_tty: Couldn't register modem-callout-device\n"</FONT>);
<FONT COLOR="#298C52">return</FONT> -2;
}
<FONT COLOR="#298C52">for</FONT> (i = 0; i &lt; <A HREF="../includes/isdn.h.shtml#ISDN_MAX_CHANNELS">ISDN_MAX_CHANNELS</A>; i++) {
info = &amp;m-&gt;info[i];
info-&gt;write_sem = MUTEX;
sprintf(info-&gt;last_cause, <FONT COLOR="#FF0000">"0000"</FONT>);
sprintf(info-&gt;last_num, <FONT COLOR="#FF0000">"none"</FONT>);
info-&gt;last_dir = 0;
info-&gt;last_lhup = 1;
info-&gt;last_l2 = -1;
info-&gt;last_si = 0;
<A HREF="#isdn_tty_reset_profile">isdn_tty_reset_profile</A>(&amp;info-&gt;emu);
<A HREF="#isdn_tty_modem_reset_regs">isdn_tty_modem_reset_regs</A>(info, 1);
info-&gt;magic = <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_MAGIC">ISDN_ASYNC_MAGIC</A>;
info-&gt;line = i;
info-&gt;tty = 0;
info-&gt;x_char = 0;
info-&gt;count = 0;
info-&gt;blocked_open = 0;
info-&gt;callout_termios = m-&gt;cua_modem.init_termios;
info-&gt;normal_termios = m-&gt;tty_modem.init_termios;
info-&gt;open_wait = 0;
info-&gt;close_wait = 0;
info-&gt;isdn_driver = -1;
info-&gt;isdn_channel = -1;
info-&gt;drv_index = -1;
info-&gt;xmit_size = <A HREF="../includes/isdn.h.shtml#ISDN_SERIAL_XMIT_SIZE">ISDN_SERIAL_XMIT_SIZE</A>;
skb_queue_head_init(&amp;info-&gt;xmit_queue);
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
skb_queue_head_init(&amp;info-&gt;dtmf_queue);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (!(info-&gt;xmit_buf = kmalloc(<A HREF="../includes/isdn.h.shtml#ISDN_SERIAL_XMIT_MAX">ISDN_SERIAL_XMIT_MAX</A> + 5, GFP_KERNEL))) {
printk(KERN_ERR <FONT COLOR="#FF0000">"Could not allocate modem xmit-buffer\n"</FONT>);
<FONT COLOR="#298C52">return</FONT> -3;
}
<FONT COLOR=#0000FF>/* Make room for T.70 header */</FONT>
info-&gt;xmit_buf += 4;
}
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A HREF="#isdn_tty_match_icall">isdn_tty_match_icall</A>(<FONT COLOR="#298C52">char</FONT> *cid, <A HREF="../includes/isdn.h.shtml#atemu">atemu</A> *emu, <FONT COLOR="#298C52">int</FONT> di)
{
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_ICALL
printk(KERN_DEBUG <FONT COLOR="#FF0000">"m_fi: msn=%s lmsn=%s mmsn=%s mreg[SI1]=%d mreg[SI2]=%d\n"</FONT>,
emu-&gt;msn, emu-&gt;lmsn, <A HREF="isdn_common.c.shtml#isdn_map_eaz2msn">isdn_map_eaz2msn</A>(emu-&gt;msn, di),
emu-&gt;mdmreg[<A HREF="#REG_SI1">REG_SI1</A>], emu-&gt;mdmreg[<A HREF="#REG_SI2">REG_SI2</A>]);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (strlen(emu-&gt;lmsn)) {
<FONT COLOR="#298C52">char</FONT> *p = emu-&gt;lmsn;
<FONT COLOR="#298C52">char</FONT> *q;
<FONT COLOR="#298C52">int</FONT> tmp;
<FONT COLOR="#298C52">int</FONT> ret = 0;
<FONT COLOR="#298C52">while</FONT> (1) {
<FONT COLOR="#298C52">if</FONT> ((q = strchr(p, <FONT COLOR="#FF0000">';'</FONT>)))
*q = <FONT COLOR="#FF0000">'\0'</FONT>;
<FONT COLOR="#298C52">if</FONT> ((tmp = <A HREF="isdn_common.c.shtml#isdn_wildmat">isdn_wildmat</A>(cid, <A HREF="isdn_common.c.shtml#isdn_map_eaz2msn">isdn_map_eaz2msn</A>(p, di))) &gt; ret)
ret = tmp;
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_ICALL
printk(KERN_DEBUG <FONT COLOR="#FF0000">"m_fi: lmsnX=%s mmsn=%s -&gt; tmp=%d\n"</FONT>,
p, <A HREF="isdn_common.c.shtml#isdn_map_eaz2msn">isdn_map_eaz2msn</A>(emu-&gt;msn, di), tmp);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (q) {
*q = <FONT COLOR="#FF0000">';'</FONT>;
p = q;
p++;
}
<FONT COLOR="#298C52">if</FONT> (!tmp)
<FONT COLOR="#298C52">return</FONT> 0;
<FONT COLOR="#298C52">if</FONT> (!q)
<FONT COLOR="#298C52">break</FONT>;
}
<FONT COLOR="#298C52">return</FONT> ret;
} <FONT COLOR="#298C52">else</FONT>
<FONT COLOR="#298C52">return</FONT> <A HREF="isdn_common.c.shtml#isdn_wildmat">isdn_wildmat</A>(cid, <A HREF="isdn_common.c.shtml#isdn_map_eaz2msn">isdn_map_eaz2msn</A>(emu-&gt;msn, di));
}
<FONT COLOR=#0000FF>/*
* An incoming call-request has arrived.
* Search the tty-devices for an appropriate device and bind
* it to the ISDN-Channel.
* Return:
*
* 0 = No matching device found.
* 1 = A matching device found.
* 3 = No match found, but eventually would match, if
* CID is longer.
*/</FONT>
<FONT COLOR="#298C52">int</FONT>
<A HREF="#isdn_tty_find_icall">isdn_tty_find_icall</A>(<FONT COLOR="#298C52">int</FONT> di, <FONT COLOR="#298C52">int</FONT> ch, <A HREF="../includes/isdnif.h.shtml#setup_parm">setup_parm</A> setup)
{
<FONT COLOR="#298C52">char</FONT> *eaz;
<FONT COLOR="#298C52">int</FONT> i;
<FONT COLOR="#298C52">int</FONT> wret;
<FONT COLOR="#298C52">int</FONT> idx;
<FONT COLOR="#298C52">int</FONT> si1;
<FONT COLOR="#298C52">int</FONT> si2;
<FONT COLOR="#298C52">char</FONT> nr[32];
ulong flags;
<FONT COLOR="#298C52">if</FONT> (!setup.<A HREF="isdn_common.c.shtml#phone">phone</A>[0]) {
nr[0] = <FONT COLOR="#FF0000">'0'</FONT>;
nr[1] = <FONT COLOR="#FF0000">'\0'</FONT>;
printk(KERN_INFO <FONT COLOR="#FF0000">"isdn_tty: Incoming call without OAD, assuming '0'\n"</FONT>);
} <FONT COLOR="#298C52">else</FONT>
strcpy(nr, setup.<A HREF="isdn_common.c.shtml#phone">phone</A>);
si1 = (<FONT COLOR="#298C52">int</FONT>) setup.si1;
si2 = (<FONT COLOR="#298C52">int</FONT>) setup.si2;
<FONT COLOR="#298C52">if</FONT> (!setup.eazmsn[0]) {
printk(KERN_WARNING <FONT COLOR="#FF0000">"isdn_tty: Incoming call without CPN, assuming '0'\n"</FONT>);
eaz = <FONT COLOR="#FF0000">"0"</FONT>;
} <FONT COLOR="#298C52">else</FONT>
eaz = setup.eazmsn;
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_ICALL
printk(KERN_DEBUG <FONT COLOR="#FF0000">"m_fi: eaz=%s si1=%d si2=%d\n"</FONT>, eaz, si1, si2);
<FONT COLOR=#A521F7>#endif</FONT>
wret = 0;
save_flags(flags);
<A HREF="kdebug.h.shtml#cli">cli</A>();
<FONT COLOR="#298C52">for</FONT> (i = 0; i &lt; <A HREF="../includes/isdn.h.shtml#ISDN_MAX_CHANNELS">ISDN_MAX_CHANNELS</A>; i++) {
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info = &amp;dev-&gt;mdm.info[i];
<FONT COLOR="#298C52">if</FONT> ((info-&gt;emu.mdmreg[<A HREF="#REG_SI1">REG_SI1</A>] &amp; si2bit[si1]) &amp;&amp; <FONT COLOR=#0000FF>/* SI1 is matching */</FONT>
(info-&gt;emu.mdmreg[<A HREF="#REG_SI2">REG_SI2</A>] == si2)) { <FONT COLOR=#0000FF>/* SI2 is matching */</FONT>
idx = <A HREF="isdn_common.c.shtml#isdn_dc2minor">isdn_dc2minor</A>(di, ch);
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_ICALL
printk(KERN_DEBUG <FONT COLOR="#FF0000">"m_fi: match1\n"</FONT>);
printk(KERN_DEBUG <FONT COLOR="#FF0000">"m_fi: idx=%d flags=%08lx drv=%d ch=%d usg=%d\n"</FONT>, idx,
info-&gt;flags, info-&gt;isdn_driver, info-&gt;isdn_channel,
dev-&gt;usage[idx]);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (
<FONT COLOR=#A521F7>#ifndef</FONT> <A HREF="#FIX_FILE_TRANSFER">FIX_FILE_TRANSFER</A>
(info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_NORMAL_ACTIVE">ISDN_ASYNC_NORMAL_ACTIVE</A>) &amp;&amp;
<FONT COLOR=#A521F7>#endif</FONT>
(info-&gt;isdn_driver == -1) &amp;&amp;
(info-&gt;isdn_channel == -1) &amp;&amp;
(<A HREF="../includes/isdn.h.shtml#USG_NONE">USG_NONE</A>(dev-&gt;usage[idx]))) {
<FONT COLOR="#298C52">int</FONT> matchret;
<FONT COLOR="#298C52">if</FONT> ((matchret = <A HREF="#isdn_tty_match_icall">isdn_tty_match_icall</A>(eaz, &amp;info-&gt;emu, di)) &gt; wret)
wret = matchret;
<FONT COLOR="#298C52">if</FONT> (!matchret) { <FONT COLOR=#0000FF>/* EAZ is matching */</FONT>
info-&gt;isdn_driver = di;
info-&gt;isdn_channel = ch;
info-&gt;drv_index = idx;
dev-&gt;m_idx[idx] = info-&gt;line;
dev-&gt;usage[idx] &amp;= <A HREF="../includes/isdn.h.shtml#ISDN_USAGE_EXCLUSIVE">ISDN_USAGE_EXCLUSIVE</A>;
dev-&gt;usage[idx] |= (si1 == 1) ? <A HREF="../includes/isdn.h.shtml#ISDN_USAGE_VOICE">ISDN_USAGE_VOICE</A> : <A HREF="../includes/isdn.h.shtml#ISDN_USAGE_MODEM">ISDN_USAGE_MODEM</A>;
strcpy(dev-&gt;num[idx], nr);
strcpy(info-&gt;emu.cpn, eaz);
info-&gt;emu.mdmreg[<A HREF="#REG_SI1I">REG_SI1I</A>] = si2bit[si1];
info-&gt;emu.mdmreg[<A HREF="#REG_PLAN">REG_PLAN</A>] = setup.plan;
info-&gt;emu.mdmreg[<A HREF="#REG_SCREEN">REG_SCREEN</A>] = setup.screen;
<A HREF="isdn_common.c.shtml#isdn_info_update">isdn_info_update</A>();
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
printk(KERN_INFO <FONT COLOR="#FF0000">"isdn_tty: call from %s, -&gt; RING on ttyI%d\n"</FONT>, nr,
info-&gt;line);
info-&gt;msr |= UART_MSR_RI;
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(2, info);
<A HREF="isdn_common.c.shtml#isdn_timer_ctrl">isdn_timer_ctrl</A>(<A HREF="../includes/isdn.h.shtml#ISDN_TIMER_MODEMRING">ISDN_TIMER_MODEMRING</A>, 1);
<FONT COLOR="#298C52">return</FONT> 1;
}
}
}
}
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
printk(KERN_INFO <FONT COLOR="#FF0000">"isdn_tty: call from %s -&gt; %s %s\n"</FONT>, nr, eaz,
(dev-&gt;drv[di]-&gt;reject_bus &amp;&amp; (wret != 2))? <FONT COLOR="#FF0000">"rejected"</FONT> : <FONT COLOR="#FF0000">"ignored"</FONT>);
<FONT COLOR="#298C52">return</FONT> (wret == 2)?3:0;
}
<FONT COLOR=#A521F7>#define</FONT> <A HREF="#TTY_IS_ACTIVE">TTY_IS_ACTIVE</A>(info) \
(info-&gt;flags &amp; (<A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_NORMAL_ACTIVE">ISDN_ASYNC_NORMAL_ACTIVE</A> | <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CALLOUT_ACTIVE">ISDN_ASYNC_CALLOUT_ACTIVE</A>))
<FONT COLOR="#298C52">int</FONT>
<A NAME="isdn_tty_stat_callback">isdn_tty_stat_callback</A>(<FONT COLOR="#298C52">int</FONT> i, <A HREF="../includes/isdnif.h.shtml#isdn_ctrl">isdn_ctrl</A> * c)
{
<FONT COLOR="#298C52">int</FONT> mi;
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info;
<FONT COLOR="#298C52">char</FONT> *e;
<FONT COLOR="#298C52">if</FONT> (i &lt; 0)
<FONT COLOR="#298C52">return</FONT> 0;
<FONT COLOR="#298C52">if</FONT> ((mi = dev-&gt;m_idx[i]) &gt;= 0) {
info = &amp;dev-&gt;mdm.info[mi];
<FONT COLOR="#298C52">switch</FONT> (c-&gt;command) {
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_STAT_CINF">ISDN_STAT_CINF</A>:
printk(KERN_DEBUG <FONT COLOR="#FF0000">"CHARGEINFO on ttyI%d: %ld %s\n"</FONT>, info-&gt;line, c-&gt;arg, c-&gt;parm.num);
info-&gt;emu.charge = (<FONT COLOR="#298C52">unsigned</FONT>) simple_strtoul(c-&gt;parm.num, &amp;e, 10);
<FONT COLOR="#298C52">if</FONT> (e == (<FONT COLOR="#298C52">char</FONT> *)c-&gt;parm.num)
info-&gt;emu.charge = 0;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_STAT_BSENT">ISDN_STAT_BSENT</A>:
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_TTY_STAT_DEBUG
printk(KERN_DEBUG <FONT COLOR="#FF0000">"tty_STAT_BSENT ttyI%d\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> ((info-&gt;isdn_driver == c-&gt;<A HREF="../includes/isdn.h.shtml#driver">driver</A>) &amp;&amp;
(info-&gt;isdn_channel == c-&gt;arg)) {
info-&gt;msr |= UART_MSR_CTS;
<FONT COLOR="#298C52">if</FONT> (info-&gt;send_outstanding)
<FONT COLOR="#298C52">if</FONT> (!(--info-&gt;send_outstanding))
info-&gt;lsr |= UART_LSR_TEMT;
<A HREF="#isdn_tty_tint">isdn_tty_tint</A>(info);
<FONT COLOR="#298C52">return</FONT> 1;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_STAT_CAUSE">ISDN_STAT_CAUSE</A>:
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_TTY_STAT_DEBUG
printk(KERN_DEBUG <FONT COLOR="#FF0000">"tty_STAT_CAUSE ttyI%d\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR=#0000FF>/* Signal cause to tty-device */</FONT>
strncpy(info-&gt;last_cause, c-&gt;parm.num, 5);
<FONT COLOR="#298C52">return</FONT> 1;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_STAT_DCONN">ISDN_STAT_DCONN</A>:
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_TTY_STAT_DEBUG
printk(KERN_DEBUG <FONT COLOR="#FF0000">"tty_STAT_DCONN ttyI%d\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (<A HREF="#TTY_IS_ACTIVE">TTY_IS_ACTIVE</A>(info)) {
<FONT COLOR="#298C52">if</FONT> (info-&gt;dialing == 1) {
info-&gt;dialing = 2;
<FONT COLOR="#298C52">return</FONT> 1;
}
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_STAT_DHUP">ISDN_STAT_DHUP</A>:
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_TTY_STAT_DEBUG
printk(KERN_DEBUG <FONT COLOR="#FF0000">"tty_STAT_DHUP ttyI%d\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (<A HREF="#TTY_IS_ACTIVE">TTY_IS_ACTIVE</A>(info)) {
<FONT COLOR="#298C52">if</FONT> (info-&gt;dialing == 1) {
info-&gt;dialing = 0;
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(7, info);
}
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_HUP
printk(KERN_DEBUG <FONT COLOR="#FF0000">"Mhup in ISDN_STAT_DHUP\n"</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
<A HREF="#isdn_tty_modem_hup">isdn_tty_modem_hup</A>(info, 0);
<FONT COLOR="#298C52">return</FONT> 1;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_STAT_BCONN">ISDN_STAT_BCONN</A>:
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_TTY_STAT_DEBUG
printk(KERN_DEBUG <FONT COLOR="#FF0000">"tty_STAT_BCONN ttyI%d\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR=#0000FF>/* Schedule CONNECT-Message to any tty
* waiting for it and
* set DCD-bit of its modem-status.
*/</FONT>
<FONT COLOR="#298C52">if</FONT> (<A HREF="#TTY_IS_ACTIVE">TTY_IS_ACTIVE</A>(info)) {
info-&gt;msr |= UART_MSR_DCD;
info-&gt;emu.charge = 0;
<FONT COLOR="#298C52">if</FONT> (info-&gt;dialing) {
info-&gt;dialing = 0;
info-&gt;last_dir = 1;
} <FONT COLOR="#298C52">else</FONT>
info-&gt;last_dir = 0;
info-&gt;rcvsched = 1;
<FONT COLOR="#298C52">if</FONT> (<A HREF="../includes/isdn.h.shtml#USG_MODEM">USG_MODEM</A>(dev-&gt;usage[i]))
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(5, info);
<FONT COLOR="#298C52">if</FONT> (<A HREF="../includes/isdn.h.shtml#USG_VOICE">USG_VOICE</A>(dev-&gt;usage[i]))
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(11, info);
<FONT COLOR="#298C52">return</FONT> 1;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_STAT_BHUP">ISDN_STAT_BHUP</A>:
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_TTY_STAT_DEBUG
printk(KERN_DEBUG <FONT COLOR="#FF0000">"tty_STAT_BHUP ttyI%d\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (<A HREF="#TTY_IS_ACTIVE">TTY_IS_ACTIVE</A>(info)) {
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_HUP
printk(KERN_DEBUG <FONT COLOR="#FF0000">"Mhup in ISDN_STAT_BHUP\n"</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
<A HREF="#isdn_tty_modem_hup">isdn_tty_modem_hup</A>(info, 0);
<FONT COLOR="#298C52">return</FONT> 1;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_STAT_NODCH">ISDN_STAT_NODCH</A>:
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_TTY_STAT_DEBUG
printk(KERN_DEBUG <FONT COLOR="#FF0000">"tty_STAT_NODCH ttyI%d\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">if</FONT> (<A HREF="#TTY_IS_ACTIVE">TTY_IS_ACTIVE</A>(info)) {
<FONT COLOR="#298C52">if</FONT> (info-&gt;dialing) {
info-&gt;dialing = 0;
info-&gt;last_l2 = -1;
info-&gt;last_si = 0;
sprintf(info-&gt;last_cause, <FONT COLOR="#FF0000">"0000"</FONT>);
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(6, info);
}
<A HREF="#isdn_tty_modem_hup">isdn_tty_modem_hup</A>(info, 0);
<FONT COLOR="#298C52">return</FONT> 1;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_STAT_UNLOAD">ISDN_STAT_UNLOAD</A>:
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_TTY_STAT_DEBUG
printk(KERN_DEBUG <FONT COLOR="#FF0000">"tty_STAT_UNLOAD ttyI%d\n"</FONT>, info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">for</FONT> (i = 0; i &lt; <A HREF="../includes/isdn.h.shtml#ISDN_MAX_CHANNELS">ISDN_MAX_CHANNELS</A>; i++) {
info = &amp;dev-&gt;mdm.info[i];
<FONT COLOR="#298C52">if</FONT> (info-&gt;isdn_driver == c-&gt;<A HREF="../includes/isdn.h.shtml#driver">driver</A>) {
<FONT COLOR="#298C52">if</FONT> (info-&gt;online)
<A HREF="#isdn_tty_modem_hup">isdn_tty_modem_hup</A>(info, 1);
}
}
<FONT COLOR="#298C52">return</FONT> 1;
}
}
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR=#0000FF>/*********************************************************************
Modem-Emulator-Routines
*********************************************************************/</FONT>
<FONT COLOR=#A521F7>#define</FONT> <A NAME="cmdchar">cmdchar</A>(c) ((c&gt;<FONT COLOR="#FF0000">' '</FONT>)&amp;&amp;(c&lt;=0x7f))
<FONT COLOR=#0000FF>/*
* Put a message from the AT-emulator into receive-buffer of tty,
* convert CR, LF, and BS to values in modem-registers 3, 4 and 5.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#298C52">char</FONT> *msg, <A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
<FONT COLOR="#298C52">struct</FONT> tty_struct *tty;
<A HREF="../includes/isdn.h.shtml#atemu">atemu</A> *m = &amp;info-&gt;emu;
<FONT COLOR="#298C52">char</FONT> *p;
<FONT COLOR="#298C52">char</FONT> c;
ulong flags;
<FONT COLOR="#298C52">if</FONT> (!msg) {
printk(KERN_WARNING <FONT COLOR="#FF0000">"isdn_tty: Null-Message in isdn_tty_at_cout\n"</FONT>);
<FONT COLOR="#298C52">return</FONT>;
}
save_flags(flags);
<A HREF="kdebug.h.shtml#cli">cli</A>();
tty = info-&gt;tty;
<FONT COLOR="#298C52">for</FONT> (p = msg; *p; p++) {
<FONT COLOR="#298C52">switch</FONT> (*p) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'\r'</FONT>:
c = m-&gt;mdmreg[<A HREF="#REG_CR">REG_CR</A>];
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'\n'</FONT>:
c = m-&gt;mdmreg[<A HREF="#REG_LF">REG_LF</A>];
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'\b'</FONT>:
c = m-&gt;mdmreg[<A HREF="#REG_BS">REG_BS</A>];
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
c = *p;
}
<FONT COLOR="#298C52">if</FONT> ((info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CLOSING">ISDN_ASYNC_CLOSING</A>) || (!tty)) {
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
<FONT COLOR="#298C52">return</FONT>;
}
<FONT COLOR="#298C52">if</FONT> (tty-&gt;flip.count &gt;= TTY_FLIPBUF_SIZE)
<FONT COLOR="#298C52">break</FONT>;
tty_insert_flip_char(tty, c, 0);
}
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
queue_task(&amp;tty-&gt;flip.tqueue, &amp;tq_timer);
}
<FONT COLOR=#0000FF>/*
* Perform ATH Hangup
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_on_hook">isdn_tty_on_hook</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
<FONT COLOR="#298C52">if</FONT> (info-&gt;isdn_channel &gt;= 0) {
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_HUP
printk(KERN_DEBUG <FONT COLOR="#FF0000">"Mhup in isdn_tty_on_hook\n"</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
<A HREF="#isdn_tty_modem_hup">isdn_tty_modem_hup</A>(info, 1);
}
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_off_hook">isdn_tty_off_hook</A>(<FONT COLOR="#298C52">void</FONT>)
{
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty_off_hook\n"</FONT>);
}
<FONT COLOR=#A521F7>#define</FONT> <A NAME="PLUSWAIT1">PLUSWAIT1</A> (HZ/2) <FONT COLOR=#0000FF>/* 0.5 sec. */</FONT>
<FONT COLOR=#A521F7>#define</FONT> <A NAME="PLUSWAIT2">PLUSWAIT2</A> (HZ*3/2) <FONT COLOR=#0000FF>/* 1.5 sec */</FONT>
<FONT COLOR=#0000FF>/*
* Check Buffer for Modem-escape-sequence, activate timer-callback to
* isdn_tty_modem_escape() if sequence found.
*
* Parameters:
* p pointer to databuffer
* plus escape-character
* count length of buffer
* pluscount count of valid escape-characters so far
* lastplus timestamp of last character
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A HREF="#isdn_tty_check_esc">isdn_tty_check_esc</A>(<FONT COLOR="#298C52">const</FONT> u_char * p, u_char plus, <FONT COLOR="#298C52">int</FONT> count, <FONT COLOR="#298C52">int</FONT> *pluscount,
<FONT COLOR="#298C52">int</FONT> *lastplus, <FONT COLOR="#298C52">int</FONT> from_user)
{
<FONT COLOR="#298C52">char</FONT> cbuf[3];
<FONT COLOR="#298C52">if</FONT> (plus &gt; 127)
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR="#298C52">if</FONT> (count &gt; 3) {
p += count - 3;
count = 3;
*pluscount = 0;
}
<FONT COLOR="#298C52">if</FONT> (from_user) {
copy_from_user(cbuf, p, count);
p = cbuf;
}
<FONT COLOR="#298C52">while</FONT> (count &gt; 0) {
<FONT COLOR="#298C52">if</FONT> (*(p++) == plus) {
<FONT COLOR="#298C52">if</FONT> ((*pluscount)++) {
<FONT COLOR=#0000FF>/* Time since last '+' &gt; 0.5 sec. ? */</FONT>
<FONT COLOR="#298C52">if</FONT> ((jiffies - *lastplus) &gt; <A HREF="#PLUSWAIT1">PLUSWAIT1</A>)
*pluscount = 1;
} <FONT COLOR="#298C52">else</FONT> {
<FONT COLOR=#0000FF>/* Time since last non-'+' &lt; 1.5 sec. ? */</FONT>
<FONT COLOR="#298C52">if</FONT> ((jiffies - *lastplus) &lt; <A HREF="#PLUSWAIT2">PLUSWAIT2</A>)
*pluscount = 0;
}
<FONT COLOR="#298C52">if</FONT> ((*pluscount == 3) &amp;&amp; (count = 1))
<A HREF="isdn_common.c.shtml#isdn_timer_ctrl">isdn_timer_ctrl</A>(<A HREF="../includes/isdn.h.shtml#ISDN_TIMER_MODEMPLUS">ISDN_TIMER_MODEMPLUS</A>, 1);
<FONT COLOR="#298C52">if</FONT> (*pluscount &gt; 3)
*pluscount = 1;
} <FONT COLOR="#298C52">else</FONT>
*pluscount = 0;
*lastplus = jiffies;
count--;
}
}
<FONT COLOR=#0000FF>/*
* Return result of AT-emulator to tty-receive-buffer, depending on
* modem-register 12, bit 0 and 1.
* For CONNECT-messages also switch to online-mode.
* For RING-message handle auto-ATA if register 0 != 0
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(<FONT COLOR="#298C52">int</FONT> code, <A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
<A HREF="../includes/isdn.h.shtml#atemu">atemu</A> *m = &amp;info-&gt;emu;
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">char</FONT> *msg[] =
{<FONT COLOR="#FF0000">"OK"</FONT>, <FONT COLOR="#FF0000">"CONNECT"</FONT>, <FONT COLOR="#FF0000">"RING"</FONT>, <FONT COLOR="#FF0000">"NO CARRIER"</FONT>, <FONT COLOR="#FF0000">"ERROR"</FONT>,
<FONT COLOR="#FF0000">"CONNECT 64000"</FONT>, <FONT COLOR="#FF0000">"NO DIALTONE"</FONT>, <FONT COLOR="#FF0000">"BUSY"</FONT>, <FONT COLOR="#FF0000">"NO ANSWER"</FONT>,
<FONT COLOR="#FF0000">"RINGING"</FONT>, <FONT COLOR="#FF0000">"NO MSN/EAZ"</FONT>, <FONT COLOR="#FF0000">"VCON"</FONT>, <FONT COLOR="#FF0000">"RUNG"</FONT>};
ulong flags;
<FONT COLOR="#298C52">char</FONT> s[<A HREF="../includes/isdn.h.shtml#ISDN_MSNLEN">ISDN_MSNLEN</A>+10];
<FONT COLOR="#298C52">switch</FONT> (code) {
<FONT COLOR="#298C52">case</FONT> 2:
m-&gt;mdmreg[<A HREF="#REG_RINGCNT">REG_RINGCNT</A>]++; <FONT COLOR=#0000FF>/* RING */</FONT>
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmreg[<A HREF="#REG_RINGCNT">REG_RINGCNT</A>] == m-&gt;mdmreg[<A HREF="#REG_RINGATA">REG_RINGATA</A>])
<FONT COLOR=#0000FF>/* Automatically accept incoming call */</FONT>
<A HREF="#isdn_tty_cmd_ATA">isdn_tty_cmd_ATA</A>(info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 3:
<FONT COLOR=#0000FF>/* NO CARRIER */</FONT>
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_HUP
printk(KERN_DEBUG <FONT COLOR="#FF0000">"modem_result: NO CARRIER %d %d\n"</FONT>,
(info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CLOSING">ISDN_ASYNC_CLOSING</A>),
(!info-&gt;tty));
<FONT COLOR=#A521F7>#endif</FONT>
save_flags(flags);
<A HREF="kdebug.h.shtml#cli">cli</A>();
m-&gt;mdmreg[<A HREF="#REG_RINGCNT">REG_RINGCNT</A>] = 0;
del_timer(&amp;info-&gt;nc_timer);
info-&gt;ncarrier = 0;
<FONT COLOR="#298C52">if</FONT> ((info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CLOSING">ISDN_ASYNC_CLOSING</A>) || (!info-&gt;tty)) {
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
<FONT COLOR="#298C52">return</FONT>;
}
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">if</FONT> (info-&gt;vonline &amp; 1) {
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_VOICE
printk(KERN_DEBUG <FONT COLOR="#FF0000">"res3: send DLE-ETX on ttyI%d\n"</FONT>,
info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR=#0000FF>/* voice-recording, add DLE-ETX */</FONT>
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\020\003"</FONT>, info);
}
<FONT COLOR="#298C52">if</FONT> (info-&gt;vonline &amp; 2) {
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_VOICE
printk(KERN_DEBUG <FONT COLOR="#FF0000">"res3: send DLE-DC4 on ttyI%d\n"</FONT>,
info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR=#0000FF>/* voice-playing, add DLE-DC4 */</FONT>
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\020\024"</FONT>, info);
}
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 1:
<FONT COLOR="#298C52">case</FONT> 5:
sprintf(info-&gt;last_cause, <FONT COLOR="#FF0000">"0000"</FONT>);
<FONT COLOR="#298C52">if</FONT> (!info-&gt;online)
info-&gt;online = 2;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 11:
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_MODEM_VOICE
printk(KERN_DEBUG <FONT COLOR="#FF0000">"res3: send VCON on ttyI%d\n"</FONT>,
info-&gt;line);
<FONT COLOR=#A521F7>#endif</FONT>
sprintf(info-&gt;last_cause, <FONT COLOR="#FF0000">"0000"</FONT>);
<FONT COLOR="#298C52">if</FONT> (!info-&gt;online)
info-&gt;online = 1;
<FONT COLOR="#298C52">break</FONT>;
}
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmreg[<A HREF="#REG_RESP">REG_RESP</A>] &amp; <A HREF="#BIT_RESP">BIT_RESP</A>) {
<FONT COLOR=#0000FF>/* Show results */</FONT>
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\n"</FONT>, info);
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmreg[<A HREF="#REG_RESPNUM">REG_RESPNUM</A>] &amp; <A HREF="#BIT_RESPNUM">BIT_RESPNUM</A>) {
<FONT COLOR=#0000FF>/* Show numeric results */</FONT>
sprintf(s, <FONT COLOR="#FF0000">"%d"</FONT>, code);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(s, info);
} <FONT COLOR="#298C52">else</FONT> {
<FONT COLOR="#298C52">if</FONT> ((code == 2) &amp;&amp;
(m-&gt;mdmreg[<A HREF="#REG_RUNG">REG_RUNG</A>] &amp; <A HREF="#BIT_RUNG">BIT_RUNG</A>) &amp;&amp;
(m-&gt;mdmreg[<A HREF="#REG_RINGCNT">REG_RINGCNT</A>] &gt; 1))
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR="#298C52">if</FONT> ((code == 2) &amp;&amp; (!(m-&gt;mdmreg[<A HREF="#REG_CIDONCE">REG_CIDONCE</A>] &amp; <A HREF="#BIT_CIDONCE">BIT_CIDONCE</A>))) {
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"CALLER NUMBER: "</FONT>, info);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(dev-&gt;num[info-&gt;drv_index], info);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\n"</FONT>, info);
}
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(msg[code], info);
<FONT COLOR="#298C52">switch</FONT> (code) {
<FONT COLOR="#298C52">case</FONT> 2:
<FONT COLOR=#0000FF>/* Append CPN, if enabled */</FONT>
<FONT COLOR="#298C52">if</FONT> ((m-&gt;mdmreg[<A HREF="#REG_RESRXT">REG_RESRXT</A>] &amp; <A HREF="#BIT_RESRXT">BIT_RESRXT</A>)) {
sprintf(s, <FONT COLOR="#FF0000">"/%s"</FONT>, m-&gt;cpn);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(s, info);
}
<FONT COLOR=#0000FF>/* Print CID only once, _after_ 1.st RING */</FONT>
<FONT COLOR="#298C52">if</FONT> ((m-&gt;mdmreg[<A HREF="#REG_CIDONCE">REG_CIDONCE</A>] &amp; <A HREF="#BIT_CIDONCE">BIT_CIDONCE</A>) &amp;&amp;
(m-&gt;mdmreg[<A HREF="#REG_RINGCNT">REG_RINGCNT</A>] == 1)) {
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\n"</FONT>, info);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"CALLER NUMBER: "</FONT>, info);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(dev-&gt;num[info-&gt;drv_index], info);
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 3:
<FONT COLOR="#298C52">case</FONT> 6:
<FONT COLOR="#298C52">case</FONT> 7:
<FONT COLOR="#298C52">case</FONT> 8:
m-&gt;mdmreg[<A HREF="#REG_RINGCNT">REG_RINGCNT</A>] = 0;
<FONT COLOR=#0000FF>/* Append Cause-Message if enabled */</FONT>
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmreg[<A HREF="#REG_RESPXT">REG_RESPXT</A>] &amp; <A HREF="#BIT_RESPXT">BIT_RESPXT</A>) {
sprintf(s, <FONT COLOR="#FF0000">"/%s"</FONT>, info-&gt;last_cause);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(s, info);
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 5:
<FONT COLOR=#0000FF>/* Append Protocol to CONNECT message */</FONT>
<FONT COLOR="#298C52">switch</FONT> (m-&gt;mdmreg[<A HREF="#REG_L2PROT">REG_L2PROT</A>]) {
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_X75I">ISDN_PROTO_L2_X75I</A>:
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_X75UI">ISDN_PROTO_L2_X75UI</A>:
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_X75BUI">ISDN_PROTO_L2_X75BUI</A>:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"/X.75"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_HDLC">ISDN_PROTO_L2_HDLC</A>:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"/HDLC"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_V11096">ISDN_PROTO_L2_V11096</A>:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"/V110/9600"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_V11019">ISDN_PROTO_L2_V11019</A>:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"/V110/19200"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_V11038">ISDN_PROTO_L2_V11038</A>:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"/V110/38400"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
}
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmreg[<A HREF="#REG_T70">REG_T70</A>] &amp; <A HREF="#BIT_T70">BIT_T70</A>) {
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"/T.70"</FONT>, info);
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmreg[<A HREF="#REG_T70">REG_T70</A>] &amp; <A HREF="#BIT_T70_EXT">BIT_T70_EXT</A>)
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"+"</FONT>, info);
}
<FONT COLOR="#298C52">break</FONT>;
}
}
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\n"</FONT>, info);
}
<FONT COLOR="#298C52">if</FONT> (code == 3) {
save_flags(flags);
<A HREF="kdebug.h.shtml#cli">cli</A>();
<FONT COLOR="#298C52">if</FONT> ((info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CLOSING">ISDN_ASYNC_CLOSING</A>) || (!info-&gt;tty)) {
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
<FONT COLOR="#298C52">return</FONT>;
}
<FONT COLOR="#298C52">if</FONT> (info-&gt;tty-&gt;ldisc.flush_buffer)
info-&gt;tty-&gt;ldisc.flush_buffer(info-&gt;tty);
<FONT COLOR="#298C52">if</FONT> ((info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CHECK_CD">ISDN_ASYNC_CHECK_CD</A>) &amp;&amp;
(!((info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CALLOUT_ACTIVE">ISDN_ASYNC_CALLOUT_ACTIVE</A>) &amp;&amp;
(info-&gt;flags &amp; <A HREF="../includes/isdn.h.shtml#ISDN_ASYNC_CALLOUT_NOHUP">ISDN_ASYNC_CALLOUT_NOHUP</A>)))) {
tty_hangup(info-&gt;tty);
}
<A HREF="kdebug.h.shtml#restore_flags">restore_flags</A>(flags);
}
}
<FONT COLOR=#0000FF>/*
* Display a modem-register-value.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A HREF="#isdn_tty_show_profile">isdn_tty_show_profile</A>(<FONT COLOR="#298C52">int</FONT> ridx, <A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
<FONT COLOR="#298C52">char</FONT> v[6];
sprintf(v, <FONT COLOR="#FF0000">"\r\n%d"</FONT>, info-&gt;emu.mdmreg[ridx]);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(v, info);
}
<FONT COLOR=#0000FF>/*
* Get MSN-string from char-pointer, set pointer to end of number
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_get_msnstr">isdn_tty_get_msnstr</A>(<FONT COLOR="#298C52">char</FONT> *n, <FONT COLOR="#298C52">char</FONT> **p)
{
<FONT COLOR="#298C52">while</FONT> ((*p[0] &gt;= <FONT COLOR="#FF0000">'0'</FONT> &amp;&amp; *p[0] &lt;= <FONT COLOR="#FF0000">'9'</FONT>) ||
<FONT COLOR=#0000FF>/* Why a comma ??? */</FONT>
(*p[0] == <FONT COLOR="#FF0000">','</FONT>))
*n++ = *p[0]++;
*n = <FONT COLOR="#FF0000">'\0'</FONT>;
}
<FONT COLOR=#0000FF>/*
* Get phone-number from modem-commandbuffer
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_getdial">isdn_tty_getdial</A>(<FONT COLOR="#298C52">char</FONT> *p, <FONT COLOR="#298C52">char</FONT> *q,<FONT COLOR="#298C52">int</FONT> cnt)
{
<FONT COLOR="#298C52">int</FONT> first = 1;
<FONT COLOR="#298C52">int</FONT> limit=39; <FONT COLOR=#0000FF>/* MUST match the size in isdn_tty_parse to avoid
buffer overflow */</FONT>
<FONT COLOR="#298C52">while</FONT> (strchr(<FONT COLOR="#FF0000">"0123456789,#.*WPTS-"</FONT>, *p) &amp;&amp; *p &amp;&amp; --cnt&gt;0) {
<FONT COLOR="#298C52">if</FONT> ((*p &gt;= <FONT COLOR="#FF0000">'0'</FONT> &amp;&amp; *p &lt;= <FONT COLOR="#FF0000">'9'</FONT>) || ((*p == <FONT COLOR="#FF0000">'S'</FONT>) &amp;&amp; first))
*q++ = *p;
p++;
<FONT COLOR="#298C52">if</FONT>(!--limit)
<FONT COLOR="#298C52">break</FONT>;
first = 0;
}
*q = 0;
}
<FONT COLOR=#A521F7>#define</FONT> <A NAME="PARSE_ERROR">PARSE_ERROR</A> { <A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(4, info); <FONT COLOR="#298C52">return</FONT>; }
<FONT COLOR=#A521F7>#define</FONT> <A NAME="PARSE_ERROR1">PARSE_ERROR1</A> { <A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(4, info); <FONT COLOR="#298C52">return</FONT> 1; }
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_report">isdn_tty_report</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
<A HREF="../includes/isdn.h.shtml#atemu">atemu</A> *m = &amp;info-&gt;emu;
<FONT COLOR="#298C52">char</FONT> s[80];
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\nStatistics of last connection:\r\n\r\n"</FONT>, info);
sprintf(s, <FONT COLOR="#FF0000">" Remote Number: %s\r\n"</FONT>, info-&gt;last_num);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(s, info);
sprintf(s, <FONT COLOR="#FF0000">" Direction: %s\r\n"</FONT>, info-&gt;last_dir ? <FONT COLOR="#FF0000">"outgoing"</FONT> : <FONT COLOR="#FF0000">"incoming"</FONT>);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(s, info);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">" Layer-2 Protocol: "</FONT>, info);
<FONT COLOR="#298C52">switch</FONT> (info-&gt;last_l2) {
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_X75I">ISDN_PROTO_L2_X75I</A>:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"X.75i"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_X75UI">ISDN_PROTO_L2_X75UI</A>:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"X.75ui"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_X75BUI">ISDN_PROTO_L2_X75BUI</A>:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"X.75bui"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_HDLC">ISDN_PROTO_L2_HDLC</A>:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"HDLC"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_V11096">ISDN_PROTO_L2_V11096</A>:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"V.110 9600 Baud"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_V11019">ISDN_PROTO_L2_V11019</A>:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"V.110 19200 Baud"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_V11038">ISDN_PROTO_L2_V11038</A>:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"V.110 38400 Baud"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_TRANS">ISDN_PROTO_L2_TRANS</A>:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"transparent"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"unknown"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
}
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmreg[<A HREF="#REG_T70">REG_T70</A>] &amp; <A HREF="#BIT_T70">BIT_T70</A>) {
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"/T.70"</FONT>, info);
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmreg[<A HREF="#REG_T70">REG_T70</A>] &amp; <A HREF="#BIT_T70_EXT">BIT_T70_EXT</A>)
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"+"</FONT>, info);
}
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\n"</FONT>, info);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">" Service: "</FONT>, info);
<FONT COLOR="#298C52">switch</FONT> (info-&gt;last_si) {
<FONT COLOR="#298C52">case</FONT> 1:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"audio\r\n"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 5:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"btx\r\n"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 7:
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"data\r\n"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
sprintf(s, <FONT COLOR="#FF0000">"%d\r\n"</FONT>, info-&gt;last_si);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(s, info);
<FONT COLOR="#298C52">break</FONT>;
}
sprintf(s, <FONT COLOR="#FF0000">" Hangup location: %s\r\n"</FONT>, info-&gt;last_lhup ? <FONT COLOR="#FF0000">"local"</FONT> : <FONT COLOR="#FF0000">"remote"</FONT>);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(s, info);
sprintf(s, <FONT COLOR="#FF0000">" Last cause: %s\r\n"</FONT>, info-&gt;last_cause);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(s, info);
}
<FONT COLOR=#0000FF>/*
* Parse AT&amp;.. commands.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A NAME="isdn_tty_cmd_ATand">isdn_tty_cmd_ATand</A>(<FONT COLOR="#298C52">char</FONT> **p, <A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
<A HREF="../includes/isdn.h.shtml#atemu">atemu</A> *m = &amp;info-&gt;emu;
<FONT COLOR="#298C52">int</FONT> i;
<FONT COLOR="#298C52">char</FONT> rb[100];
<FONT COLOR=#A521F7>#define</FONT> <A NAME="MAXRB">MAXRB</A> (<FONT COLOR="#298C52">sizeof</FONT>(rb) - 1)
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'B'</FONT>:
<FONT COLOR=#0000FF>/* &amp;B - Set Buffersize */</FONT>
p[0]++;
i = <A HREF="isdn_common.c.shtml#isdn_getnum">isdn_getnum</A>(p);
<FONT COLOR="#298C52">if</FONT> ((i &lt; 0) || (i &gt; <A HREF="../includes/isdn.h.shtml#ISDN_SERIAL_XMIT_MAX">ISDN_SERIAL_XMIT_MAX</A>))
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">if</FONT> ((m-&gt;mdmreg[<A HREF="#REG_SI1">REG_SI1</A>] &amp; 1) &amp;&amp; (i &gt; <A HREF="#VBUF">VBUF</A>))
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
<FONT COLOR=#A521F7>#endif</FONT>
m-&gt;mdmreg[<A HREF="#REG_PSIZE">REG_PSIZE</A>] = i / 16;
info-&gt;xmit_size = m-&gt;mdmreg[<A HREF="#REG_PSIZE">REG_PSIZE</A>] * 16;
<FONT COLOR="#298C52">switch</FONT> (m-&gt;mdmreg[<A HREF="#REG_L2PROT">REG_L2PROT</A>]) {
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_V11096">ISDN_PROTO_L2_V11096</A>:
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_V11019">ISDN_PROTO_L2_V11019</A>:
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_V11038">ISDN_PROTO_L2_V11038</A>:
info-&gt;xmit_size /= 10;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'D'</FONT>:
<FONT COLOR=#0000FF>/* &amp;D - Set DCD-Low-behavior */</FONT>
p[0]++;
<FONT COLOR="#298C52">switch</FONT> (<A HREF="isdn_common.c.shtml#isdn_getnum">isdn_getnum</A>(p)) {
<FONT COLOR="#298C52">case</FONT> 0:
m-&gt;mdmreg[<A HREF="#REG_DTRHUP">REG_DTRHUP</A>] &amp;= ~<A HREF="#BIT_DTRHUP">BIT_DTRHUP</A>;
m-&gt;mdmreg[<A HREF="#REG_DTRR">REG_DTRR</A>] &amp;= ~<A HREF="#BIT_DTRR">BIT_DTRR</A>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 2:
m-&gt;mdmreg[<A HREF="#REG_DTRHUP">REG_DTRHUP</A>] |= <A HREF="#BIT_DTRHUP">BIT_DTRHUP</A>;
m-&gt;mdmreg[<A HREF="#REG_DTRR">REG_DTRR</A>] &amp;= ~<A HREF="#BIT_DTRR">BIT_DTRR</A>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 3:
m-&gt;mdmreg[<A HREF="#REG_DTRHUP">REG_DTRHUP</A>] |= <A HREF="#BIT_DTRHUP">BIT_DTRHUP</A>;
m-&gt;mdmreg[<A HREF="#REG_DTRR">REG_DTRR</A>] |= <A HREF="#BIT_DTRR">BIT_DTRR</A>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'E'</FONT>:
<FONT COLOR=#0000FF>/* &amp;E -Set EAZ/MSN */</FONT>
p[0]++;
<A HREF="#isdn_tty_get_msnstr">isdn_tty_get_msnstr</A>(m-&gt;msn, p);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'F'</FONT>:
<FONT COLOR=#0000FF>/* &amp;F -Set Factory-Defaults */</FONT>
p[0]++;
<A HREF="#isdn_tty_reset_profile">isdn_tty_reset_profile</A>(m);
<A HREF="#isdn_tty_modem_reset_regs">isdn_tty_modem_reset_regs</A>(info, 1);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'L'</FONT>:
<FONT COLOR=#0000FF>/* &amp;L -Set Numbers to listen on */</FONT>
p[0]++;
i = 0;
<FONT COLOR="#298C52">while</FONT> ((strchr(<FONT COLOR="#FF0000">"0123456789,*[]?;"</FONT>, *p[0])) &amp;&amp;
(i &lt; <A HREF="../includes/isdn.h.shtml#ISDN_LMSNLEN">ISDN_LMSNLEN</A>))
m-&gt;lmsn[i++] = *p[0]++;
m-&gt;lmsn[i] = <FONT COLOR="#FF0000">'\0'</FONT>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'R'</FONT>:
<FONT COLOR=#0000FF>/* &amp;R - Set V.110 bitrate adaption */</FONT>
p[0]++;
i = <A HREF="isdn_common.c.shtml#isdn_getnum">isdn_getnum</A>(p);
<FONT COLOR="#298C52">switch</FONT> (i) {
<FONT COLOR="#298C52">case</FONT> 0:
<FONT COLOR=#0000FF>/* Switch off V.110, back to X.75 */</FONT>
m-&gt;mdmreg[<A HREF="#REG_L2PROT">REG_L2PROT</A>] = <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_X75I">ISDN_PROTO_L2_X75I</A>;
m-&gt;mdmreg[<A HREF="#REG_SI2">REG_SI2</A>] = 0;
info-&gt;xmit_size = m-&gt;mdmreg[<A HREF="#REG_PSIZE">REG_PSIZE</A>] * 16;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 9600:
m-&gt;mdmreg[<A HREF="#REG_L2PROT">REG_L2PROT</A>] = <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_V11096">ISDN_PROTO_L2_V11096</A>;
m-&gt;mdmreg[<A HREF="#REG_SI2">REG_SI2</A>] = 197;
info-&gt;xmit_size = m-&gt;mdmreg[<A HREF="#REG_PSIZE">REG_PSIZE</A>] * 16 / 10;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 19200:
m-&gt;mdmreg[<A HREF="#REG_L2PROT">REG_L2PROT</A>] = <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_V11019">ISDN_PROTO_L2_V11019</A>;
m-&gt;mdmreg[<A HREF="#REG_SI2">REG_SI2</A>] = 199;
info-&gt;xmit_size = m-&gt;mdmreg[<A HREF="#REG_PSIZE">REG_PSIZE</A>] * 16 / 10;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 38400:
m-&gt;mdmreg[<A HREF="#REG_L2PROT">REG_L2PROT</A>] = <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_V11038">ISDN_PROTO_L2_V11038</A>;
m-&gt;mdmreg[<A HREF="#REG_SI2">REG_SI2</A>] = 198; <FONT COLOR=#0000FF>/* no existing standard for this */</FONT>
info-&gt;xmit_size = m-&gt;mdmreg[<A HREF="#REG_PSIZE">REG_PSIZE</A>] * 16 / 10;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR=#0000FF>/* Switch off T.70 */</FONT>
m-&gt;mdmreg[<A HREF="#REG_T70">REG_T70</A>] &amp;= ~(<A HREF="#BIT_T70">BIT_T70</A> | <A HREF="#BIT_T70_EXT">BIT_T70_EXT</A>);
<FONT COLOR=#0000FF>/* Set Service 7 */</FONT>
m-&gt;mdmreg[<A HREF="#REG_SI1">REG_SI1</A>] |= 4;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'S'</FONT>:
<FONT COLOR=#0000FF>/* &amp;S - Set Windowsize */</FONT>
p[0]++;
i = <A HREF="isdn_common.c.shtml#isdn_getnum">isdn_getnum</A>(p);
<FONT COLOR="#298C52">if</FONT> ((i &gt; 0) &amp;&amp; (i &lt; 9))
m-&gt;mdmreg[<A HREF="#REG_WSIZE">REG_WSIZE</A>] = i;
<FONT COLOR="#298C52">else</FONT>
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'V'</FONT>:
<FONT COLOR=#0000FF>/* &amp;V - Show registers */</FONT>
p[0]++;
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\n"</FONT>, info);
<FONT COLOR="#298C52">for</FONT> (i = 0; i &lt; <A HREF="../includes/isdn.h.shtml#ISDN_MODEM_ANZREG">ISDN_MODEM_ANZREG</A>; i++) {
sprintf(rb, <FONT COLOR="#FF0000">"S%02d=%03d%s"</FONT>, i,
m-&gt;mdmreg[i], ((i + 1) % 10) ? <FONT COLOR="#FF0000">" "</FONT> : <FONT COLOR="#FF0000">"\r\n"</FONT>);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(rb, info);
}
sprintf(rb, <FONT COLOR="#FF0000">"\r\nEAZ/MSN: %.50s\r\n"</FONT>,
strlen(m-&gt;msn) ? m-&gt;msn : <FONT COLOR="#FF0000">"None"</FONT>);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(rb, info);
<FONT COLOR="#298C52">if</FONT> (strlen(m-&gt;lmsn)) {
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\nListen: "</FONT>, info);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(m-&gt;lmsn, info);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\n"</FONT>, info);
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'W'</FONT>:
<FONT COLOR=#0000FF>/* &amp;W - Write Profile */</FONT>
p[0]++;
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'0'</FONT>:
p[0]++;
<A HREF="#modem_write_profile">modem_write_profile</A>(m);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'X'</FONT>:
<FONT COLOR=#0000FF>/* &amp;X - Switch to BTX-Mode and T.70 */</FONT>
p[0]++;
<FONT COLOR="#298C52">switch</FONT> (<A HREF="isdn_common.c.shtml#isdn_getnum">isdn_getnum</A>(p)) {
<FONT COLOR="#298C52">case</FONT> 0:
m-&gt;mdmreg[<A HREF="#REG_T70">REG_T70</A>] &amp;= ~(<A HREF="#BIT_T70">BIT_T70</A> | <A HREF="#BIT_T70_EXT">BIT_T70_EXT</A>);
info-&gt;xmit_size = m-&gt;mdmreg[<A HREF="#REG_PSIZE">REG_PSIZE</A>] * 16;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 1:
m-&gt;mdmreg[<A HREF="#REG_T70">REG_T70</A>] |= <A HREF="#BIT_T70">BIT_T70</A>;
m-&gt;mdmreg[<A HREF="#REG_T70">REG_T70</A>] &amp;= ~<A HREF="#BIT_T70_EXT">BIT_T70_EXT</A>;
m-&gt;mdmreg[<A HREF="#REG_L2PROT">REG_L2PROT</A>] = <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_X75I">ISDN_PROTO_L2_X75I</A>;
info-&gt;xmit_size = 112;
m-&gt;mdmreg[<A HREF="#REG_SI1">REG_SI1</A>] = 4;
m-&gt;mdmreg[<A HREF="#REG_SI2">REG_SI2</A>] = 0;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 2:
m-&gt;mdmreg[<A HREF="#REG_T70">REG_T70</A>] |= (<A HREF="#BIT_T70">BIT_T70</A> | <A HREF="#BIT_T70_EXT">BIT_T70_EXT</A>);
m-&gt;mdmreg[<A HREF="#REG_L2PROT">REG_L2PROT</A>] = <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_X75I">ISDN_PROTO_L2_X75I</A>;
info-&gt;xmit_size = 112;
m-&gt;mdmreg[<A HREF="#REG_SI1">REG_SI1</A>] = 4;
m-&gt;mdmreg[<A HREF="#REG_SI2">REG_SI2</A>] = 0;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A HREF="#isdn_tty_check_ats">isdn_tty_check_ats</A>(<FONT COLOR="#298C52">int</FONT> mreg, <FONT COLOR="#298C52">int</FONT> mval, <A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info, <A HREF="../includes/isdn.h.shtml#atemu">atemu</A> * m)
{
<FONT COLOR=#0000FF>/* Some plausibility checks */</FONT>
<FONT COLOR="#298C52">switch</FONT> (mreg) {
<FONT COLOR="#298C52">case</FONT> <A HREF="#REG_L2PROT">REG_L2PROT</A>:
<FONT COLOR="#298C52">if</FONT> (mval &gt; <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_MAX">ISDN_PROTO_L2_MAX</A>)
<FONT COLOR="#298C52">return</FONT> 1;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="#REG_PSIZE">REG_PSIZE</A>:
<FONT COLOR="#298C52">if</FONT> ((mval * 16) &gt; <A HREF="../includes/isdn.h.shtml#ISDN_SERIAL_XMIT_MAX">ISDN_SERIAL_XMIT_MAX</A>)
<FONT COLOR="#298C52">return</FONT> 1;
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">if</FONT> ((m-&gt;mdmreg[<A HREF="#REG_SI1">REG_SI1</A>] &amp; 1) &amp;&amp; (mval &gt; <A HREF="#VBUFX">VBUFX</A>))
<FONT COLOR="#298C52">return</FONT> 1;
<FONT COLOR=#A521F7>#endif</FONT>
info-&gt;xmit_size = mval * 16;
<FONT COLOR="#298C52">switch</FONT> (m-&gt;mdmreg[<A HREF="#REG_L2PROT">REG_L2PROT</A>]) {
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_V11096">ISDN_PROTO_L2_V11096</A>:
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_V11019">ISDN_PROTO_L2_V11019</A>:
<FONT COLOR="#298C52">case</FONT> <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_V11038">ISDN_PROTO_L2_V11038</A>:
info-&gt;xmit_size /= 10;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <A HREF="#REG_SI1I">REG_SI1I</A>:
<FONT COLOR="#298C52">case</FONT> <A HREF="#REG_PLAN">REG_PLAN</A>:
<FONT COLOR="#298C52">case</FONT> <A HREF="#REG_SCREEN">REG_SCREEN</A>:
<FONT COLOR=#0000FF>/* readonly registers */</FONT>
<FONT COLOR="#298C52">return</FONT> 1;
}
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR=#0000FF>/*
* Perform ATS command
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A NAME="isdn_tty_cmd_ATS">isdn_tty_cmd_ATS</A>(<FONT COLOR="#298C52">char</FONT> **p, <A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
<A HREF="../includes/isdn.h.shtml#atemu">atemu</A> *m = &amp;info-&gt;emu;
<FONT COLOR="#298C52">int</FONT> bitpos;
<FONT COLOR="#298C52">int</FONT> mreg;
<FONT COLOR="#298C52">int</FONT> mval;
<FONT COLOR="#298C52">int</FONT> bval;
mreg = <A HREF="isdn_common.c.shtml#isdn_getnum">isdn_getnum</A>(p);
<FONT COLOR="#298C52">if</FONT> (mreg &lt; 0 || mreg &gt; <A HREF="../includes/isdn.h.shtml#ISDN_MODEM_ANZREG">ISDN_MODEM_ANZREG</A>)
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'='</FONT>:
p[0]++;
mval = <A HREF="isdn_common.c.shtml#isdn_getnum">isdn_getnum</A>(p);
<FONT COLOR="#298C52">if</FONT> (mval &lt; 0 || mval &gt; 255)
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_check_ats">isdn_tty_check_ats</A>(mreg, mval, info, m))
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
m-&gt;mdmreg[mreg] = mval;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'.'</FONT>:
<FONT COLOR=#0000FF>/* Set/Clear a single bit */</FONT>
p[0]++;
bitpos = <A HREF="isdn_common.c.shtml#isdn_getnum">isdn_getnum</A>(p);
<FONT COLOR="#298C52">if</FONT> ((bitpos &lt; 0) || (bitpos &gt; 7))
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'='</FONT>:
p[0]++;
bval = <A HREF="isdn_common.c.shtml#isdn_getnum">isdn_getnum</A>(p);
<FONT COLOR="#298C52">if</FONT> (bval &lt; 0 || bval &gt; 1)
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
<FONT COLOR="#298C52">if</FONT> (bval)
mval = m-&gt;mdmreg[mreg] | (1 &lt;&lt; bitpos);
<FONT COLOR="#298C52">else</FONT>
mval = m-&gt;mdmreg[mreg] &amp; ~(1 &lt;&lt; bitpos);
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_check_ats">isdn_tty_check_ats</A>(mreg, mval, info, m))
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
m-&gt;mdmreg[mreg] = mval;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'?'</FONT>:
p[0]++;
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\n"</FONT>, info);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>((m-&gt;mdmreg[mreg] &amp; (1 &lt;&lt; bitpos)) ? <FONT COLOR="#FF0000">"1"</FONT> : <FONT COLOR="#FF0000">"0"</FONT>,
info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'?'</FONT>:
p[0]++;
<A HREF="#isdn_tty_show_profile">isdn_tty_show_profile</A>(mreg, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
<FONT COLOR="#298C52">break</FONT>;
}
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR=#0000FF>/*
* Perform ATA command
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_cmd_ATA">isdn_tty_cmd_ATA</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
<A HREF="../includes/isdn.h.shtml#atemu">atemu</A> *m = &amp;info-&gt;emu;
<A HREF="../includes/isdnif.h.shtml#isdn_ctrl">isdn_ctrl</A> cmd;
<FONT COLOR="#298C52">int</FONT> l2;
<FONT COLOR="#298C52">if</FONT> (info-&gt;msr &amp; UART_MSR_RI) {
<FONT COLOR=#0000FF>/* Accept incoming call */</FONT>
info-&gt;last_dir = 0;
strcpy(info-&gt;last_num, dev-&gt;num[info-&gt;drv_index]);
m-&gt;mdmreg[<A HREF="#REG_RINGCNT">REG_RINGCNT</A>] = 0;
info-&gt;msr &amp;= ~UART_MSR_RI;
l2 = m-&gt;mdmreg[<A HREF="#REG_L2PROT">REG_L2PROT</A>];
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR=#0000FF>/* If more than one bit set in reg18, autoselect Layer2 */</FONT>
<FONT COLOR="#298C52">if</FONT> ((m-&gt;mdmreg[<A HREF="#REG_SI1">REG_SI1</A>] &amp; m-&gt;mdmreg[<A HREF="#REG_SI1I">REG_SI1I</A>]) != m-&gt;mdmreg[<A HREF="#REG_SI1">REG_SI1</A>]) {
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmreg[<A HREF="#REG_SI1I">REG_SI1I</A>] == 1)
l2 = <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_TRANS">ISDN_PROTO_L2_TRANS</A>;
<FONT COLOR="#298C52">else</FONT>
l2 = <A HREF="../includes/isdnif.h.shtml#ISDN_PROTO_L2_X75I">ISDN_PROTO_L2_X75I</A>;
}
<FONT COLOR=#A521F7>#endif</FONT>
cmd.<A HREF="../includes/isdn.h.shtml#driver">driver</A> = info-&gt;isdn_driver;
cmd.command = <A HREF="../includes/isdnif.h.shtml#ISDN_CMD_SETL2">ISDN_CMD_SETL2</A>;
cmd.arg = info-&gt;isdn_channel + (l2 &lt;&lt; 8);
info-&gt;last_l2 = l2;
<A HREF="isdn_common.c.shtml#isdn_command">isdn_command</A>(&amp;cmd);
cmd.<A HREF="../includes/isdn.h.shtml#driver">driver</A> = info-&gt;isdn_driver;
cmd.command = <A HREF="../includes/isdnif.h.shtml#ISDN_CMD_SETL3">ISDN_CMD_SETL3</A>;
cmd.arg = info-&gt;isdn_channel + (m-&gt;mdmreg[<A HREF="#REG_L3PROT">REG_L3PROT</A>] &lt;&lt; 8);
<A HREF="isdn_common.c.shtml#isdn_command">isdn_command</A>(&amp;cmd);
cmd.<A HREF="../includes/isdn.h.shtml#driver">driver</A> = info-&gt;isdn_driver;
cmd.arg = info-&gt;isdn_channel;
cmd.command = <A HREF="../includes/isdnif.h.shtml#ISDN_CMD_ACCEPTD">ISDN_CMD_ACCEPTD</A>;
<A HREF="isdn_common.c.shtml#isdn_command">isdn_command</A>(&amp;cmd);
} <FONT COLOR="#298C52">else</FONT>
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(8, info);
}
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR=#0000FF>/*
* Parse AT+F.. commands
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A NAME="isdn_tty_cmd_PLUSF">isdn_tty_cmd_PLUSF</A>(<FONT COLOR="#298C52">char</FONT> **p, <A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
<A HREF="../includes/isdn.h.shtml#atemu">atemu</A> *m = &amp;info-&gt;emu;
<FONT COLOR="#298C52">int</FONT> par;
<FONT COLOR="#298C52">char</FONT> rs[20];
<FONT COLOR="#298C52">if</FONT> (!strncmp(p[0], <FONT COLOR="#FF0000">"CLASS"</FONT>, 5)) {
p[0] += 5;
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'?'</FONT>:
p[0]++;
sprintf(rs, <FONT COLOR="#FF0000">"\r\n%d"</FONT>,
(m-&gt;mdmreg[<A HREF="#REG_SI1">REG_SI1</A>] &amp; 1) ? 8 : 0);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(rs, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'='</FONT>:
p[0]++;
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'0'</FONT>:
p[0]++;
m-&gt;mdmreg[<A HREF="#REG_SI1">REG_SI1</A>] = 4;
info-&gt;xmit_size =
m-&gt;mdmreg[<A HREF="#REG_PSIZE">REG_PSIZE</A>] * 16;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'2'</FONT>:
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty: FCLASS=2\n"</FONT>);
p[0]++;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'8'</FONT>:
p[0]++;
m-&gt;mdmreg[<A HREF="#REG_SI1">REG_SI1</A>] = 5;
info-&gt;xmit_size = <A HREF="#VBUF">VBUF</A>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'?'</FONT>:
p[0]++;
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\n0,2,8"</FONT>,
info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">if</FONT> (!strncmp(p[0], <FONT COLOR="#FF0000">"AA"</FONT>, 2)) {
p[0] += 2;
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'?'</FONT>:
p[0]++;
sprintf(rs, <FONT COLOR="#FF0000">"\r\n%d"</FONT>,
m-&gt;mdmreg[<A HREF="#REG_RINGATA">REG_RINGATA</A>]);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(rs, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'='</FONT>:
p[0]++;
par = <A HREF="isdn_common.c.shtml#isdn_getnum">isdn_getnum</A>(p);
<FONT COLOR="#298C52">if</FONT> ((par &lt; 0) || (par &gt; 255))
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
m-&gt;mdmreg[<A HREF="#REG_RINGATA">REG_RINGATA</A>] = par;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">if</FONT> (!strncmp(p[0], <FONT COLOR="#FF0000">"TBC="</FONT>, 4)) { <FONT COLOR=#0000FF>/* UNKLAR !! */</FONT>
p[0] += 4;
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty: Fax FTBC=%c\n"</FONT>, *p[0]);
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'0'</FONT>:
p[0]++;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">if</FONT> (!strncmp(p[0], <FONT COLOR="#FF0000">"BOR="</FONT>, 4)) { <FONT COLOR=#0000FF>/* UNKLAR !! */</FONT>
p[0] += 4;
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty: Fax FBOR=%c\n"</FONT>, *p[0]);
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'0'</FONT>:
p[0]++;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">if</FONT> (!strncmp(p[0], <FONT COLOR="#FF0000">"DCC="</FONT>, 4)) { <FONT COLOR=#0000FF>/* SETUP irgendwie !! */</FONT>
<FONT COLOR="#298C52">int</FONT> i, val[]={0,0,0,0,0,0,0,0};
p[0] += 4;
<FONT COLOR="#298C52">if</FONT> (*p[0] == <FONT COLOR="#FF0000">'?'</FONT>) {
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\n(0,1),(0-5),(0-2),(0-2),(0,1),(0),(0),(0-7)"</FONT>,info);
p[0]++;
} <FONT COLOR="#298C52">else</FONT> {
<FONT COLOR="#298C52">for</FONT> (i=0; (*p[0]&gt;=<FONT COLOR="#FF0000">'0'</FONT>) &amp;&amp; (*p[0]&lt;=<FONT COLOR="#FF0000">'9'</FONT>); i++) {
val[i] = *p[0] - 48;
p[0]++;
<FONT COLOR="#298C52">if</FONT> (*p[0] == <FONT COLOR="#FF0000">','</FONT>)
p[0]++;
}
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty: Fax Setup values=%d,%d,%d,%d,%d,%d,%d,%d\n"</FONT>,
val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]);
}
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">if</FONT> (!strncmp(p[0], <FONT COLOR="#FF0000">"LID="</FONT>, 4)) { <FONT COLOR=#0000FF>/* set sender ID !! */</FONT>
<FONT COLOR="#298C52">char</FONT> senderID[80];
<FONT COLOR="#298C52">int</FONT> i;
p[0] += 4;
<FONT COLOR="#298C52">if</FONT> (*p[0] ==<FONT COLOR="#FF0000">'"'</FONT>)
p[0]++;
<FONT COLOR="#298C52">for</FONT>(i=0; (*p[0]) &amp;&amp; (*p[0] != <FONT COLOR="#FF0000">'"'</FONT>); i++)
senderID[i] = *p[0]++;
senderID[i] = 0;
<FONT COLOR="#298C52">if</FONT> (*p[0] ==<FONT COLOR="#FF0000">'"'</FONT>)
p[0]++;
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty: Fax sender=&gt;%s&lt;\n"</FONT>, senderID);
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">if</FONT> (!strncmp(p[0], <FONT COLOR="#FF0000">"MFR?"</FONT>, 4)) {
p[0] += 4;
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty: FMFR?\n"</FONT>);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\nISDNfax"</FONT>, info);
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">if</FONT> (!strncmp(p[0], <FONT COLOR="#FF0000">"MDL?"</FONT>, 4)) {
p[0] += 4;
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty: FMDL?\n"</FONT>);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\nAVM-B1"</FONT>, info);
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">if</FONT> (!strncmp(p[0], <FONT COLOR="#FF0000">"AP=?"</FONT>, 4)) {
p[0] += 4;
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty: FAP=?\n"</FONT>);
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">if</FONT> (!strncmp(p[0], <FONT COLOR="#FF0000">"PHCTO="</FONT>, 6)) {
<FONT COLOR=#0000FF>/* beim trace mit dem zyxel folgt der wert 30 ;*/</FONT>
p[0] += 6;
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty: FPHCTO=%s\n"</FONT>, p[0]);
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR="#298C52">if</FONT> (!strncmp(p[0], <FONT COLOR="#FF0000">"CR="</FONT>, 3)) {
p[0] += 3;
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty: FCR=%s\n"</FONT>, p[0]);
<FONT COLOR="#298C52">return</FONT> 0;
}
printk(KERN_DEBUG <FONT COLOR="#FF0000">"isdn_tty: unknown token=&gt;AT+F%s&lt;\n"</FONT>, p[0]);
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR=#0000FF>/*
* Parse AT+V.. commands
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A NAME="isdn_tty_cmd_PLUSV">isdn_tty_cmd_PLUSV</A>(<FONT COLOR="#298C52">char</FONT> **p, <A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
<A HREF="../includes/isdn.h.shtml#atemu">atemu</A> *m = &amp;info-&gt;emu;
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">char</FONT> *vcmd[] =
{<FONT COLOR="#FF0000">"NH"</FONT>, <FONT COLOR="#FF0000">"IP"</FONT>, <FONT COLOR="#FF0000">"LS"</FONT>, <FONT COLOR="#FF0000">"RX"</FONT>, <FONT COLOR="#FF0000">"SD"</FONT>, <FONT COLOR="#FF0000">"SM"</FONT>, <FONT COLOR="#FF0000">"TX"</FONT>, NULL};
<FONT COLOR="#298C52">int</FONT> i;
<FONT COLOR="#298C52">int</FONT> par1;
<FONT COLOR="#298C52">int</FONT> par2;
<FONT COLOR="#298C52">char</FONT> rs[20];
i = 0;
<FONT COLOR="#298C52">while</FONT> (vcmd[i]) {
<FONT COLOR="#298C52">if</FONT> (!strncmp(vcmd[i], p[0], 2)) {
p[0] += 2;
<FONT COLOR="#298C52">break</FONT>;
}
i++;
}
<FONT COLOR="#298C52">switch</FONT> (i) {
<FONT COLOR="#298C52">case</FONT> 0:
<FONT COLOR=#0000FF>/* AT+VNH - Auto hangup feature */</FONT>
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'?'</FONT>:
p[0]++;
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\n1"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'='</FONT>:
p[0]++;
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'1'</FONT>:
p[0]++;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'?'</FONT>:
p[0]++;
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\n1"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 1:
<FONT COLOR=#0000FF>/* AT+VIP - Reset all voice parameters */</FONT>
<A HREF="#isdn_tty_modem_reset_vpar">isdn_tty_modem_reset_vpar</A>(m);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 2:
<FONT COLOR=#0000FF>/* AT+VLS - Select device, accept incoming call */</FONT>
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'?'</FONT>:
p[0]++;
sprintf(rs, <FONT COLOR="#FF0000">"\r\n%d"</FONT>, m-&gt;vpar[0]);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(rs, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'='</FONT>:
p[0]++;
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'0'</FONT>:
p[0]++;
m-&gt;vpar[0] = 0;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'2'</FONT>:
p[0]++;
m-&gt;vpar[0] = 2;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'?'</FONT>:
p[0]++;
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\n0,2"</FONT>, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 3:
<FONT COLOR=#0000FF>/* AT+VRX - Start recording */</FONT>
<FONT COLOR="#298C52">if</FONT> (!m-&gt;vpar[0])
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
<FONT COLOR="#298C52">if</FONT> (info-&gt;online != 1) {
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(8, info);
<FONT COLOR="#298C52">return</FONT> 1;
}
info-&gt;<A HREF="isdn_audio.h.shtml#dtmf_state">dtmf_state</A> = <A HREF="isdn_audio.c.shtml#isdn_audio_dtmf_init">isdn_audio_dtmf_init</A>(info-&gt;<A HREF="isdn_audio.h.shtml#dtmf_state">dtmf_state</A>);
<FONT COLOR="#298C52">if</FONT> (!info-&gt;<A HREF="isdn_audio.h.shtml#dtmf_state">dtmf_state</A>) {
printk(KERN_WARNING <FONT COLOR="#FF0000">"isdn_tty: Couldn't malloc dtmf state\n"</FONT>);
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">if</FONT> (m-&gt;vpar[3] &lt; 5) {
info-&gt;adpcmr = <A HREF="isdn_audio.c.shtml#isdn_audio_adpcm_init">isdn_audio_adpcm_init</A>(info-&gt;adpcmr, m-&gt;vpar[3]);
<FONT COLOR="#298C52">if</FONT> (!info-&gt;adpcmr) {
printk(KERN_WARNING <FONT COLOR="#FF0000">"isdn_tty: Couldn't malloc adpcm state\n"</FONT>);
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
}
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_AT
printk(KERN_DEBUG <FONT COLOR="#FF0000">"AT: +VRX\n"</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
info-&gt;vonline |= 1;
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(1, info);
<FONT COLOR="#298C52">return</FONT> 0;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 4:
<FONT COLOR=#0000FF>/* AT+VSD - Silence detection */</FONT>
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'?'</FONT>:
p[0]++;
sprintf(rs, <FONT COLOR="#FF0000">"\r\n&lt;%d&gt;,&lt;%d&gt;"</FONT>,
m-&gt;vpar[1],
m-&gt;vpar[2]);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(rs, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'='</FONT>:
p[0]++;
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'0'</FONT>:
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'1'</FONT>:
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'2'</FONT>:
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'3'</FONT>:
par1 = <A HREF="isdn_common.c.shtml#isdn_getnum">isdn_getnum</A>(p);
<FONT COLOR="#298C52">if</FONT> ((par1 &lt; 0) || (par1 &gt; 31))
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
<FONT COLOR="#298C52">if</FONT> (*p[0] != <FONT COLOR="#FF0000">','</FONT>)
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
p[0]++;
par2 = <A HREF="isdn_common.c.shtml#isdn_getnum">isdn_getnum</A>(p);
<FONT COLOR="#298C52">if</FONT> ((par2 &lt; 0) || (par2 &gt; 255))
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
m-&gt;vpar[1] = par1;
m-&gt;vpar[2] = par2;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'?'</FONT>:
p[0]++;
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\n&lt;0-31&gt;,&lt;0-255&gt;"</FONT>,
info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 5:
<FONT COLOR=#0000FF>/* AT+VSM - Select compression */</FONT>
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'?'</FONT>:
p[0]++;
sprintf(rs, <FONT COLOR="#FF0000">"\r\n&lt;%d&gt;,&lt;%d&gt;&lt;8000&gt;"</FONT>,
m-&gt;vpar[3],
m-&gt;vpar[1]);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(rs, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'='</FONT>:
p[0]++;
<FONT COLOR="#298C52">switch</FONT> (*p[0]) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'2'</FONT>:
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'3'</FONT>:
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'4'</FONT>:
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'5'</FONT>:
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'6'</FONT>:
par1 = <A HREF="isdn_common.c.shtml#isdn_getnum">isdn_getnum</A>(p);
<FONT COLOR="#298C52">if</FONT> ((par1 &lt; 2) || (par1 &gt; 6))
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
m-&gt;vpar[3] = par1;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'?'</FONT>:
p[0]++;
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\n2;ADPCM;2;0;(8000)\r\n"</FONT>,
info);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"3;ADPCM;3;0;(8000)\r\n"</FONT>,
info);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"4;ADPCM;4;0;(8000)\r\n"</FONT>,
info);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"5;ALAW;8;0;(8000)"</FONT>,
info);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"6;ULAW;8;0;(8000)"</FONT>,
info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 6:
<FONT COLOR=#0000FF>/* AT+VTX - Start sending */</FONT>
<FONT COLOR="#298C52">if</FONT> (!m-&gt;vpar[0])
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
<FONT COLOR="#298C52">if</FONT> (info-&gt;online != 1) {
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(8, info);
<FONT COLOR="#298C52">return</FONT> 1;
}
info-&gt;<A HREF="isdn_audio.h.shtml#dtmf_state">dtmf_state</A> = <A HREF="isdn_audio.c.shtml#isdn_audio_dtmf_init">isdn_audio_dtmf_init</A>(info-&gt;<A HREF="isdn_audio.h.shtml#dtmf_state">dtmf_state</A>);
<FONT COLOR="#298C52">if</FONT> (!info-&gt;<A HREF="isdn_audio.h.shtml#dtmf_state">dtmf_state</A>) {
printk(KERN_WARNING <FONT COLOR="#FF0000">"isdn_tty: Couldn't malloc dtmf state\n"</FONT>);
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">if</FONT> (m-&gt;vpar[3] &lt; 5) {
info-&gt;adpcms = <A HREF="isdn_audio.c.shtml#isdn_audio_adpcm_init">isdn_audio_adpcm_init</A>(info-&gt;adpcms, m-&gt;vpar[3]);
<FONT COLOR="#298C52">if</FONT> (!info-&gt;adpcms) {
printk(KERN_WARNING <FONT COLOR="#FF0000">"isdn_tty: Couldn't malloc adpcm state\n"</FONT>);
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
}
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_AT
printk(KERN_DEBUG <FONT COLOR="#FF0000">"AT: +VTX\n"</FONT>);
<FONT COLOR=#A521F7>#endif</FONT>
m-&gt;lastDLE = 0;
info-&gt;vonline |= 2;
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(1, info);
<FONT COLOR="#298C52">return</FONT> 0;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR1">PARSE_ERROR1</A>;
}
<FONT COLOR="#298C52">return</FONT> 0;
}
<FONT COLOR=#A521F7>#endif</FONT> <FONT COLOR=#0000FF>/* CONFIG_ISDN_AUDIO */</FONT>
<FONT COLOR=#0000FF>/*
* Parse and perform an AT-command-line.
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_parse_at">isdn_tty_parse_at</A>(<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info)
{
<A HREF="../includes/isdn.h.shtml#atemu">atemu</A> *m = &amp;info-&gt;emu;
<FONT COLOR="#298C52">char</FONT> *p;
<FONT COLOR="#298C52">char</FONT> ds[40];
<FONT COLOR=#A521F7>#ifdef</FONT> ISDN_DEBUG_AT
printk(KERN_DEBUG <FONT COLOR="#FF0000">"AT: '%s'\n"</FONT>, m-&gt;mdmcmd);
<FONT COLOR=#A521F7>#endif</FONT>
<FONT COLOR="#298C52">for</FONT> (p = &amp;m-&gt;mdmcmd[2]; *p;) {
<FONT COLOR="#298C52">switch</FONT> (*p) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'A'</FONT>:
<FONT COLOR=#0000FF>/* A - Accept incoming call */</FONT>
p++;
<A HREF="#isdn_tty_cmd_ATA">isdn_tty_cmd_ATA</A>(info);
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'D'</FONT>:
<FONT COLOR=#0000FF>/* D - Dial */</FONT>
<A HREF="#isdn_tty_getdial">isdn_tty_getdial</A>(++p, ds, <FONT COLOR="#298C52">sizeof</FONT> ds);
p += strlen(p);
<FONT COLOR="#298C52">if</FONT> (!strlen(m-&gt;msn))
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(10, info);
<FONT COLOR="#298C52">else</FONT> <FONT COLOR="#298C52">if</FONT> (strlen(ds))
<A HREF="#isdn_tty_dial">isdn_tty_dial</A>(ds, info, m);
<FONT COLOR="#298C52">else</FONT>
<A HREF="#PARSE_ERROR">PARSE_ERROR</A>;
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'E'</FONT>:
<FONT COLOR=#0000FF>/* E - Turn Echo on/off */</FONT>
p++;
<FONT COLOR="#298C52">switch</FONT> (<A HREF="isdn_common.c.shtml#isdn_getnum">isdn_getnum</A>(&amp;p)) {
<FONT COLOR="#298C52">case</FONT> 0:
m-&gt;mdmreg[<A HREF="#REG_ECHO">REG_ECHO</A>] &amp;= ~<A HREF="#BIT_ECHO">BIT_ECHO</A>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 1:
m-&gt;mdmreg[<A HREF="#REG_ECHO">REG_ECHO</A>] |= <A HREF="#BIT_ECHO">BIT_ECHO</A>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR">PARSE_ERROR</A>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'H'</FONT>:
<FONT COLOR=#0000FF>/* H - On/Off-hook */</FONT>
p++;
<FONT COLOR="#298C52">switch</FONT> (*p) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'0'</FONT>:
p++;
<A HREF="#isdn_tty_on_hook">isdn_tty_on_hook</A>(info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'1'</FONT>:
p++;
<A HREF="#isdn_tty_off_hook">isdn_tty_off_hook</A>();
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#isdn_tty_on_hook">isdn_tty_on_hook</A>(info);
<FONT COLOR="#298C52">break</FONT>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'I'</FONT>:
<FONT COLOR=#0000FF>/* I - Information */</FONT>
p++;
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\r\nLinux ISDN"</FONT>, info);
<FONT COLOR="#298C52">switch</FONT> (*p) {
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'0'</FONT>:
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'1'</FONT>:
p++;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'2'</FONT>:
p++;
<A HREF="#isdn_tty_report">isdn_tty_report</A>(info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'3'</FONT>:
p++;
sprintf(ds, <FONT COLOR="#FF0000">"\r\n%d"</FONT>, info-&gt;emu.charge);
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(ds, info);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'O'</FONT>:
<FONT COLOR=#0000FF>/* O - Go online */</FONT>
p++;
<FONT COLOR="#298C52">if</FONT> (info-&gt;msr &amp; UART_MSR_DCD)
<FONT COLOR=#0000FF>/* if B-Channel is up */</FONT>
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(5, info);
<FONT COLOR="#298C52">else</FONT>
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(3, info);
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'Q'</FONT>:
<FONT COLOR=#0000FF>/* Q - Turn Emulator messages on/off */</FONT>
p++;
<FONT COLOR="#298C52">switch</FONT> (<A HREF="isdn_common.c.shtml#isdn_getnum">isdn_getnum</A>(&amp;p)) {
<FONT COLOR="#298C52">case</FONT> 0:
m-&gt;mdmreg[<A HREF="#REG_RESP">REG_RESP</A>] |= <A HREF="#BIT_RESP">BIT_RESP</A>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 1:
m-&gt;mdmreg[<A HREF="#REG_RESP">REG_RESP</A>] &amp;= ~<A HREF="#BIT_RESP">BIT_RESP</A>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR">PARSE_ERROR</A>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'S'</FONT>:
<FONT COLOR=#0000FF>/* S - Set/Get Register */</FONT>
p++;
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_cmd_ATS">isdn_tty_cmd_ATS</A>(&amp;p, info))
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'V'</FONT>:
<FONT COLOR=#0000FF>/* V - Numeric or ASCII Emulator-messages */</FONT>
p++;
<FONT COLOR="#298C52">switch</FONT> (<A HREF="isdn_common.c.shtml#isdn_getnum">isdn_getnum</A>(&amp;p)) {
<FONT COLOR="#298C52">case</FONT> 0:
m-&gt;mdmreg[<A HREF="#REG_RESP">REG_RESP</A>] |= <A HREF="#BIT_RESPNUM">BIT_RESPNUM</A>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 1:
m-&gt;mdmreg[<A HREF="#REG_RESP">REG_RESP</A>] &amp;= ~<A HREF="#BIT_RESPNUM">BIT_RESPNUM</A>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR">PARSE_ERROR</A>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'Z'</FONT>:
<FONT COLOR=#0000FF>/* Z - Load Registers from Profile */</FONT>
p++;
<A HREF="#isdn_tty_modem_reset_regs">isdn_tty_modem_reset_regs</A>(info, 1);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'+'</FONT>:
p++;
<FONT COLOR="#298C52">switch</FONT> (*p) {
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'F'</FONT>:
p++;
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_cmd_PLUSF">isdn_tty_cmd_PLUSF</A>(&amp;p, info))
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'V'</FONT>:
<FONT COLOR="#298C52">if</FONT> (!(m-&gt;mdmreg[<A HREF="#REG_SI1">REG_SI1</A>] &amp; 1))
<A HREF="#PARSE_ERROR">PARSE_ERROR</A>;
p++;
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_cmd_PLUSV">isdn_tty_cmd_PLUSV</A>(&amp;p, info))
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR=#A521F7>#endif</FONT> <FONT COLOR=#0000FF>/* CONFIG_ISDN_AUDIO */</FONT>
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'S'</FONT>: <FONT COLOR=#0000FF>/* SUSPEND */</FONT>
p++;
<A HREF="#isdn_tty_get_msnstr">isdn_tty_get_msnstr</A>(ds, &amp;p);
<A HREF="#isdn_tty_suspend">isdn_tty_suspend</A>(ds, info, m);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'R'</FONT>: <FONT COLOR=#0000FF>/* RESUME */</FONT>
<A HREF="#isdn_tty_get_msnstr">isdn_tty_get_msnstr</A>(ds, &amp;p);
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR">PARSE_ERROR</A>;
}
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> <FONT COLOR="#FF0000">'&amp;'</FONT>:
p++;
<FONT COLOR="#298C52">if</FONT> (<A HREF="#isdn_tty_cmd_ATand">isdn_tty_cmd_ATand</A>(&amp;p, info))
<FONT COLOR="#298C52">return</FONT>;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
<A HREF="#PARSE_ERROR">PARSE_ERROR</A>;
}
}
<FONT COLOR=#A521F7>#ifdef</FONT> CONFIG_ISDN_AUDIO
<FONT COLOR="#298C52">if</FONT> (!info-&gt;vonline)
<FONT COLOR=#A521F7>#endif</FONT>
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(0, info);
}
<FONT COLOR=#0000FF>/* Need own toupper() because standard-toupper is not available
* within modules.
*/</FONT>
<FONT COLOR=#A521F7>#define</FONT> <A HREF="#my_toupper">my_toupper</A>(c) (((c&gt;=<FONT COLOR="#FF0000">'a'</FONT>)&amp;&amp;(c&lt;=<FONT COLOR="#FF0000">'z'</FONT>))?(c&amp;0xdf):c)
<FONT COLOR=#0000FF>/*
* Perform line-editing of AT-commands
*
* Parameters:
* p inputbuffer
* count length of buffer
* channel index to line (minor-device)
* user flag: buffer is in userspace
*/</FONT>
<FONT COLOR="#298C52">static</FONT> <FONT COLOR="#298C52">int</FONT>
<A HREF="#isdn_tty_edit_at">isdn_tty_edit_at</A>(<FONT COLOR="#298C52">const</FONT> <FONT COLOR="#298C52">char</FONT> *p, <FONT COLOR="#298C52">int</FONT> count, <A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> * info, <FONT COLOR="#298C52">int</FONT> user)
{
<A HREF="../includes/isdn.h.shtml#atemu">atemu</A> *m = &amp;info-&gt;emu;
<FONT COLOR="#298C52">int</FONT> total = 0;
u_char c;
<FONT COLOR="#298C52">char</FONT> eb[2];
<FONT COLOR="#298C52">int</FONT> cnt;
<FONT COLOR="#298C52">for</FONT> (cnt = count; cnt &gt; 0; p++, cnt--) {
<FONT COLOR="#298C52">if</FONT> (user)
get_user(c, p);
<FONT COLOR="#298C52">else</FONT>
c = *p;
total++;
<FONT COLOR="#298C52">if</FONT> (c == m-&gt;mdmreg[<A HREF="#REG_CR">REG_CR</A>] || c == m-&gt;mdmreg[<A HREF="#REG_LF">REG_LF</A>]) {
<FONT COLOR=#0000FF>/* Separator (CR oder LF) */</FONT>
m-&gt;mdmcmd[m-&gt;mdmcmdl] = 0;
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmreg[<A HREF="#REG_ECHO">REG_ECHO</A>] &amp; <A HREF="#BIT_ECHO">BIT_ECHO</A>) {
eb[0] = c;
eb[1] = 0;
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(eb, info);
}
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmcmdl &gt;= 2)
<A HREF="#isdn_tty_parse_at">isdn_tty_parse_at</A>(info);
m-&gt;mdmcmdl = 0;
<FONT COLOR="#298C52">continue</FONT>;
}
<FONT COLOR="#298C52">if</FONT> (c == m-&gt;mdmreg[<A HREF="#REG_BS">REG_BS</A>] &amp;&amp; m-&gt;mdmreg[<A HREF="#REG_BS">REG_BS</A>] &lt; 128) {
<FONT COLOR=#0000FF>/* Backspace-Funktion */</FONT>
<FONT COLOR="#298C52">if</FONT> ((m-&gt;mdmcmdl &gt; 2) || (!m-&gt;mdmcmdl)) {
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmcmdl)
m-&gt;mdmcmdl--;
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmreg[<A HREF="#REG_ECHO">REG_ECHO</A>] &amp; <A HREF="#BIT_ECHO">BIT_ECHO</A>)
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(<FONT COLOR="#FF0000">"\b"</FONT>, info);
}
<FONT COLOR="#298C52">continue</FONT>;
}
<FONT COLOR="#298C52">if</FONT> (<A HREF="#cmdchar">cmdchar</A>(c)) {
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmreg[<A HREF="#REG_ECHO">REG_ECHO</A>] &amp; <A HREF="#BIT_ECHO">BIT_ECHO</A>) {
eb[0] = c;
eb[1] = 0;
<A HREF="#isdn_tty_at_cout">isdn_tty_at_cout</A>(eb, info);
}
<FONT COLOR="#298C52">if</FONT> (m-&gt;mdmcmdl &lt; 255) {
c = <A HREF="#my_toupper">my_toupper</A>(c);
<FONT COLOR="#298C52">switch</FONT> (m-&gt;mdmcmdl) {
<FONT COLOR="#298C52">case</FONT> 0:
<FONT COLOR="#298C52">if</FONT> (c == <FONT COLOR="#FF0000">'A'</FONT>)
m-&gt;mdmcmd[m-&gt;mdmcmdl++] = c;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">case</FONT> 1:
<FONT COLOR="#298C52">if</FONT> (c == <FONT COLOR="#FF0000">'T'</FONT>)
m-&gt;mdmcmd[m-&gt;mdmcmdl++] = c;
<FONT COLOR="#298C52">break</FONT>;
<FONT COLOR="#298C52">default</FONT>:
m-&gt;mdmcmd[m-&gt;mdmcmdl++] = c;
}
}
}
}
<FONT COLOR="#298C52">return</FONT> total;
}
<FONT COLOR=#0000FF>/*
* Switch all modem-channels who are online and got a valid
* escape-sequence 1.5 seconds ago, to command-mode.
* This function is called every second via timer-interrupt from within
* timer-dispatcher isdn_timer_function()
*/</FONT>
<FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_modem_escape">isdn_tty_modem_escape</A>(<FONT COLOR="#298C52">void</FONT>)
{
<FONT COLOR="#298C52">int</FONT> ton = 0;
<FONT COLOR="#298C52">int</FONT> i;
<FONT COLOR="#298C52">int</FONT> midx;
<FONT COLOR="#298C52">for</FONT> (i = 0; i &lt; <A HREF="../includes/isdn.h.shtml#ISDN_MAX_CHANNELS">ISDN_MAX_CHANNELS</A>; i++)
<FONT COLOR="#298C52">if</FONT> (<A HREF="../includes/isdn.h.shtml#USG_MODEM">USG_MODEM</A>(dev-&gt;usage[i]))
<FONT COLOR="#298C52">if</FONT> ((midx = dev-&gt;m_idx[i]) &gt;= 0) {
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info = &amp;dev-&gt;mdm.info[midx];
<FONT COLOR="#298C52">if</FONT> (info-&gt;online) {
ton = 1;
<FONT COLOR="#298C52">if</FONT> ((info-&gt;emu.pluscount == 3) &amp;&amp;
((jiffies - info-&gt;emu.lastplus) &gt; <A HREF="#PLUSWAIT2">PLUSWAIT2</A>)) {
info-&gt;emu.pluscount = 0;
info-&gt;online = 0;
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(0, info);
}
}
}
<A HREF="isdn_common.c.shtml#isdn_timer_ctrl">isdn_timer_ctrl</A>(<A HREF="../includes/isdn.h.shtml#ISDN_TIMER_MODEMPLUS">ISDN_TIMER_MODEMPLUS</A>, ton);
}
<FONT COLOR=#0000FF>/*
* Put a RING-message to all modem-channels who have the RI-bit set.
* This function is called every second via timer-interrupt from within
* timer-dispatcher isdn_timer_function()
*/</FONT>
<FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_modem_ring">isdn_tty_modem_ring</A>(<FONT COLOR="#298C52">void</FONT>)
{
<FONT COLOR="#298C52">int</FONT> ton = 0;
<FONT COLOR="#298C52">int</FONT> i;
<FONT COLOR="#298C52">for</FONT> (i = 0; i &lt; <A HREF="../includes/isdn.h.shtml#ISDN_MAX_CHANNELS">ISDN_MAX_CHANNELS</A>; i++) {
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info = &amp;dev-&gt;mdm.info[i];
<FONT COLOR="#298C52">if</FONT> (info-&gt;msr &amp; UART_MSR_RI) {
ton = 1;
<A HREF="#isdn_tty_modem_result">isdn_tty_modem_result</A>(2, info);
}
}
<A HREF="isdn_common.c.shtml#isdn_timer_ctrl">isdn_timer_ctrl</A>(<A HREF="../includes/isdn.h.shtml#ISDN_TIMER_MODEMRING">ISDN_TIMER_MODEMRING</A>, ton);
}
<FONT COLOR=#0000FF>/*
* For all online tty's, try sending data to
* the lower levels.
*/</FONT>
<FONT COLOR="#298C52">void</FONT>
<A NAME="isdn_tty_modem_xmit">isdn_tty_modem_xmit</A>(<FONT COLOR="#298C52">void</FONT>)
{
<FONT COLOR="#298C52">int</FONT> ton = 1;
<FONT COLOR="#298C52">int</FONT> i;
<FONT COLOR="#298C52">for</FONT> (i = 0; i &lt; <A HREF="../includes/isdn.h.shtml#ISDN_MAX_CHANNELS">ISDN_MAX_CHANNELS</A>; i++) {
<A HREF="../includes/isdn.h.shtml#modem_info">modem_info</A> *info = &amp;dev-&gt;mdm.info[i];
<FONT COLOR="#298C52">if</FONT> (info-&gt;online) {
ton = 1;
<A HREF="#isdn_tty_senddown">isdn_tty_senddown</A>(info);
<A HREF="#isdn_tty_tint">isdn_tty_tint</A>(info);
}
}
<A HREF="isdn_common.c.shtml#isdn_timer_ctrl">isdn_timer_ctrl</A>(<A HREF="../includes/isdn.h.shtml#ISDN_TIMER_MODEMXMIT">ISDN_TIMER_MODEMXMIT</A>, ton);
}
</BODY>
</HTML>