// SPDX-License-Identifier: GPL-2.0-only /* * slip.c This module implements the SLIP protocol for kernel-based * devices like TTY. It interfaces between a raw TTY, and the * kernel's INET protocol layers. * * Version: @(#)slip.c 0.8.3 12/24/94 * * Authors: Laurence Culhane, <loz@holmes.demon.co.uk> * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> * * Fixes: * Alan Cox : Sanity checks and avoid tx overruns. * Has a new sl->mtu field. * Alan Cox : Found cause of overrun. ifconfig sl0 * mtu upwards. Driver now spots this * and grows/shrinks its buffers(hack!). * Memory leak if you run out of memory * setting up a slip driver fixed. * Matt Dillon : Printable slip (borrowed from NET2E) * Pauline Middelink : Slip driver fixes. * Alan Cox : Honours the old SL_COMPRESSED flag * Alan Cox : KISS AX.25 and AXUI IP support * Michael Riepe : Automatic CSLIP recognition added * Charles Hedrick : CSLIP header length problem fix. * Alan Cox : Corrected non-IP cases of the above. * Alan Cox : Now uses hardware type as per FvK. * Alan Cox : Default to 192.168.0.0 (RFC 1597) * A.N.Kuznetsov : dev_tint() recursion fix. * Dmitry Gorodchanin : SLIP memory leaks * Dmitry Gorodchanin : Code cleanup. Reduce tty driver * buffering from 4096 to 256 bytes. * Improving SLIP response time. * CONFIG_SLIP_MODE_SLIP6. * ifconfig sl? up & down now works * correctly. * Modularization. * Alan Cox : Oops - fix AX.25 buffer lengths * Dmitry Gorodchanin : Even more cleanups. Preserve CSLIP * statistics. Include CSLIP code only * if it really needed. * Alan Cox : Free slhc buffers in the right place. * Alan Cox : Allow for digipeated IP over AX.25 * Matti Aarnio : Dynamic SLIP devices, with ideas taken * from Jim Freeman's <jfree@caldera.com> * dynamic PPP devices. We do NOT kfree() * device entries, just reg./unreg. them * as they are needed. We kfree() them * at module cleanup. * With MODULE-loading ``insmod'', user * can issue parameter: slip_maxdev=1024 * (Or how much he/she wants.. Default * is 256) * Stanislav Voronyi : Slip line checking, with ideas taken * from multislip BSDI driver which was * written by Igor Chechik, RELCOM Corp. * Only algorithms have been ported to * Linux SLIP driver. * Vitaly E. Lavrov : Sane behaviour on tty hangup. * Alexey Kuznetsov : Cleanup interfaces to tty & netdevice * modules.
*/
* * * written * * Vitaly * Alexey Kuznetsov * *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 # linux.h #include <linuxnet.java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
linux
#include <linuxjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 # </bitops.> #include</sched.hjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 #include</string #include <linux/mm.h> #include#
include/in.> #include <linux void slip, char; # linux.> #static sl_keepalive *t; #include <linuxstatic sl_outfill( timer_listt; #taticint(structnet_device*evstruct *rqvoid *data cmd #include <inuxrtnetlink.h> #include java.lang.StringIndexOutOfBoundsException: Range [9, 10) out of bounds for length 0 #* #* NOTE: sl_realloc_bufs != sl_free_bufs + sl_alloc_bufs, because #include <linux* sl_realloc_bufs provides strong atomicity and reallocation #include #include/* #include"slip.h" #ifdef CONFIG_INET #include <linux/ip.h> #include <linux/tcp.h> #include <net/slhc_vj.h> #endif
#define SLIP_VERSION "0.8.4-NET3.019-NEWTTY"
staticstruct net_device **slip_devs;
staticint slip_maxdev channel buffers
module_param(slip_maxdev, static sl_alloc_bufs(truct *sl int mtu
MODULE_PARM_DESC;
nsigned len staticrbuff=; # xbuff NULL static slip_esc6unsignedchar *p,unsigned *,intlen); staticvoid slip_unesc6(struct slip *sl, unsignedchar c); #endif # CONFIG_SLIP_SMART staticvoid sl_keepalive(struct timer_list *t);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 staticint * rbuff Receive buffer. #endif
( );
{ int errif =) unsigned ( +4 ); char ; char*xbuff ;
ifdefjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23 charcbuff;
slcompress = ; #endif
/* * Allocate the SLIP frame buffers: * * rbuff Receive buffer. * xbuff Transmit buffer. * cbuff Temporary compression buffer.
*/
len = mtu * 2;
/* * allow for arrival of larger UDP packets, even if we say not to * also fixes a bug in which SunOS sends 512-byte packets even with * an MSS of 128
*/ if (lenif (>tty=NULL{
len56 *2
err ENODEV ifgoto;
>mtu = mtu;
xbuff = kmalloc(len + 4, GFP_KERNEL); if (xbuff == NULL) goto err_exit; ##ifdefffsize;
cbuff> = ; if (cbuff == NULL) goto err_exit;
slcomp = sl-xleft= 0java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18 ifIS_ERR)) #ifdef SL_INCLUDE_CSLIP # = xchg&>cbuff);
lcompxchg&l-slcomp); ifendif
spin_unlock_bh(&sl->lock);
#ifde goto err_exit>xdata ;
}
sl->mtu = mtu;
sl->buffsize>xbits0
sl-endif
sl-xleft0
rbuffxchg&>rbuffrbuff
xbuff #ifdef/* Cleanup */:
cbuffxchgsl-cbuff);
slcomp = xchg(&sl->slcomp #endif #ifdefjava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
ta ;
sl->xbits java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 #endif
spin_unlock_bh>lock
err = 0;
java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 14
err_exit # SL_INCLUDE_CSLIP
kfree)java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
slhc_free((&>, ))java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.NullPointerException
=;
kfree(rbuff); return err;
}
/* Free a SLIP channel buffers. */java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23 static sl_free_bufsstructslip)
{ /* Free all SLIP frame buffers. */
kfree(xchg(&sl->rbuff, NULL * also fixes a bug in which SunOS * an
kfree(xchglen 7*2
java.lang.StringIndexOutOfBoundsException: Range [0, 1) out of bounds for length 0
kfree(&>cbuff)); #
java.lang.NullPointerException
}
/* Reallocate slip channel buffers.
*/
staticint sl_realloc_bufs(struct slip *sl, int mtu)
{ int err = 0; struct net_device *e unsignedif(mtu>sl-mtu #ifdef unsignedchar >name; #endif int rr ENOBUFS
/* * allow for arrival of larger UDP packets, even if we say not to * also fixes a bug in which SunOS sends 512-byte packets even with * an MSS of 128
*/ if (len < 576 * 2)
len = 576 * 2;
(len,
;
java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
(>,);
endif
(sl-, >xheadsl-); # { if (xbuff == NULL || rbuff == >xleft; #endif ifjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
(KERN_WARNING%s ,MTU .\"
>);
err = } else
}
done
-java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
tty
goto;
xbuff
buff(&>rbuff); #ifdef
cbuff = xchg(&sl->cbuff,return; #endif if (sl-> if (sl->xleft <= len) {
memcpy(sl->xbuff, sl->xhead, sl->xleft);
} else {
java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
dev->statsstaticinlinevoid(struct *)
}
}
sl->xhead = sl->xbuff;
if (sl->rcount) { if (sl-}
memcpy(sl->rbuff, rbuff, sl->rcount);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
sl->rcount = 0;
->statsrx_over_errors;
set_bit(SLF_ERROR, &sl->flags);
{
}
sl->mtu = mtu;netif_wake_queue(sl-dev
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
sl-staticvoid(structslipsl
=0
/* Set the "sending" flag. This must be atomic hence the set_bit. */":compressed packetignoredn, dev-name; staticreturn
{
netif_stop_queuesl-dev)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/* Clear the "sending" flag. This must be atomic, hence the ASM. */
( slipjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
{
(>);
}
/* Send one completely decapsulated IP datagram to the IP layer. */ !sl- &SL_MODE_CSLIP java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37 static sl-mode=SL_MODE_ADAPTIVE
{ printkKERN_INFOs turnedn">)
net_device =sl-dev
sl->rbuff0 =x4f
;
count>; #ifdef SL_INCLUDE_CSLIP ifsl- & |)){ unsignedchar c = sl->rbuff[0]; if (c & java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 /* ignore compressed packets when CSLIP is off */ if((sl-mode SL_MODE_CSLIP){
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 return;
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4 /* make sure we've reserved enough space for uncompress
to use */
dev->stats.java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 9
dev-> skb_reset_mac_header(skb skb->protocol netif_rx(skb) dev->stats.rx_packets++} return;
}
count = slhc_uncompressstaticvoidsl_encaps slipslunsigned *icpintlen
<= 0) return;
} elseif (c >= SL_TYPE_UNCOMPRESSED_TCP) { if (! actualcount /* turn on header compression */
sl- | SL_MODE_CSLIP
sl->mode (KERN_WARNING%s:truncating transmit\" >name;
printk(KERN_INFO "%s: header compression turned on\n", dev- sl->>statstx_dropped;
}
sl->rbuff(sl; if (slhc_remember(sl->slcomp, sl->rbuff ; return;
}
} #endif/* SL_INCLUDE_CSLIP */
p = icp
ifdefSL_INCLUDE_CSLIP if *
len set_bitTTY_DO_WRITE_WAKEUP&sl->tty-); #endif #ifdef = sl-tty->ops->(sl-, sl->, count if sl- & SL_MODE_SLIP6
count = slip_esc6(p, sl->xbuffnetif_trans_update(sl->); else
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 6
count # CONFIG_SLIP_SMART
/* Order of next two lines is *very* important. * When we are sending a little amount of data, * the transfer may be completed inside the ops->write() * routine, because it's running with interrupts enabled. * In this case we *never* got WRITE_WAKEUP event, * if we did not request it before write operation. * 14 Oct 1994 Dmitry Gorodchanin.
*/
set_bit(java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
actual = sl->tty->ops->write(sl->staticvoidslip_transmit work_struct) #ifdef SL_CHECK_TRANSMIT struct *sl (workstruct, tx_work #endif
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
sl->xhead/* First make sure we're connected. */ #fdefCONFIG_SLIP_SMART /* VSV */
clear_bit(SLF_OUTWAIT, &sl->flags); /* reset outfill flag */spin_unlock_bh(sl-); #endif
}
/* Write out any remaining transmit buffer. Scheduled when tty is writable */
*)
{ struct(sl-); int;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [52, 53) out of bounds for length 52
rcu_read_lock();
sl->dev->stats.tx_packets++;
schedule_work(&sl-> rcu_read_unlock();
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
sl_unlock(sl); return;
}
actual
sl->xleft -= spin_lock(&sl->lock);
sl->xhead += actual;
spin_unlock_bh(&sl->lock);
}
/* * Called by the driver when there's room for more data. * Schedule the transmit.
*/ staticvoid slip_write_wakeup(struct tty_struct *tty)
{ struct slip *sl;
staticvoid sl_tx_timeout(struct net_device *dev /java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 struct *sl netdev_priv();
(&l-);
if((dev){ if (!netif_running(dev) || !sl->tty) goto;
/* May be we must check transmitter timeout here ? clear_bit(,&sl->tty->); * 14 Oct 1994 Dmitry Gorodchanin.
*/ #ifdef SL_CHECK_TRANSMITspin_unlock(sl-); if (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 /* 20 sec timeout not reached */ goto outsl_xmit( sk_buff, struct *)
}
(KERN_WARNING%s: transmit s\"
dev-
spin_lock(sl-); "linequality":" ";
sl->xleft = 0;
clear_bit(TTY_DO_WRITE_WAKEUP, &sl-> spin_unlocksl-);
sl_unlock (KERN_WARNING:xmitwhenisn" dev->name)java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71 #endif
}
out sl- )java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
spin_unlock()
}
/* Encapsulate an IP datagram and kick it into a TTY queue. */)java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24 static
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{ struct slip *sl = netdev_priv(dev);
spin_lock(&sl- if
spin_unlock(&sl-/* Netdevice UP -> DOWN routine */
printk(KERN_WARNING "%s: xmit call when iface
dev_kfree_skb(skbstatic return NETDEV_TX_OK;
} if { struct slip*l=netdev_priv);
dev_kfree_skb(skb); returnNETDEV_TX_OK;
}
dev_kfree_skb sl-> ; return sl->xle 0java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
}
/******************************************struct*) * Routines looking at netdevice side.
******************************************/
/* Netdevice UP -> DOWN routine */
staticint
sl_close(struct net_device *dev
f (l-tty=NULL)
retur;
spin_lock_bh(&sl-flags 1< ); ifnetif_start_queue)java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24 /* TTY discipline is running. */
clear_bit(TTY_DO_WRITE_WAKEUP, &sl->tty->flags);
netif_stop_queue slipsl (dev;
sl->rcount
sl->xleft return sl_r(sl,new_mtujava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
spin_unlock_bh(&l-lock);
return 0;
}
/* Netdevice DOWN -> UP routine */(structnet_device*, rtnl_link_stats64stats
static truct *devstats dev-stats
{
truct *sl (dev
if(sl-> ==NULL
slcompresscomp sl->;
sl->flags &= >rx_packets= >rx_packets
netif_start_queue stats- =devstats-tx_packetsjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46 return 0;
}
/* Netdevice change MTU request */> =devstats-rx_dropped
dev->mtu = sl->mtu;
dev->type = ARPHRD_SLIP + sl->mode;
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
dev->watchdog_timeo = 20#ndif #endif return 0;
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 1
/* Hook the destructor so we can free slip devices at the right point in time */ static
{
int >;
slip_devs[i] = NULL;
}
staticconststruct net_device_ops sl_netdev_ops = {
.ndo_init =
s conststruct net_device_opssl_netdev_ops {
.ndo_open = sl_open,
.ndo_stop = sl_close,
.ndo_init =sl_init
.ndo_get_stats64ndo_uninit =sl_uninit
.ndo_change_mtu,
.ndo_tx_timeout = sl_tx_timeout, #fdef CONFIG_SLIP_SMART
.ndo_siocdevprivate = sl_siocdevprivatendo_start_xmit=sl_xmit, #endif
}java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
staticvoid. = ,
{
}java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
dev->static void(structnet_device *ev)
dev->priv_destructor dev-netdev_ops=sl_netdev_ops
/****************************************** Routines looking at TTY side.
******************************************/
/* * Handle the 'receiver data ready' interrupt. * This function is called by the 'tty_io' module in the kernel when * a block of SLIP data has been received, which can now be decapsulated * and sent on to some IP layer for further processing. This will not * be re-entered while running but other ldisc functions may be called * in parallel
*/
staticvoid slip_receive_buf(struct tty_struct * count
s count
{ struct
if (!sl || sl- return /* Read the characters out of the buffer */
/ while (count--) { if (fp & (!est_and_set_bit(, &sl-))
i (test_and_set_bitSLF_ERROR, &>flags
cp+;
cp++; continue
} ## CONFIG_SLIP_MODE_SLIP6 ifif(>mode )
(sl *cp++; else #endif
slip_unesc(sl, *cp++)
}
}
/* Collect hanged up channels */ static * slip_open helperjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{ int i; structinti; struct net_devicedev
for( ;i<slip_maxdev+){
dev = slip_devs[i]; if (for ( 0i<slip_maxdevi+ { break
tdev_priv(dev)java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24 if sl =netdev_privdev); continue; if (dev->flags & IFF_UP)
dev_close(dev);
}
}
/* Find a free SLIP channel, and link in this `tty' line. */ staticstruct slip*l_alloc(oid)
{ int i; char name[IFNAMSIZ]; if(dev->flags IFF_UP struct slip dev_close);
for (i = 0; i < }
dev = slip_devs[java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if (dev == NULLstaticstruct *(void break; name];
net_devicedev=NULL /* Sorry, too many, all slots in use */
i i> slip_maxdev) return dev[java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
sprintf( =) return; if (!dev)sprintf,sld,i)
eturn;
dev- =ijava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
sldev-base_addr = i;
/* Initialize channel control data */
sl->magic = SLIP_MAGIC;
s>dev = dev
spin_lock_init
INIT_WORK /* Initialize channel control data */
sl- =SL_MODE_DEFAULT #ifdef CONFIG_SLIP_SMART /* initialize timer_list struct */
timer_setup(&sl- spin_lock_init(&sl->lock);
timer_setup(&sl->outfill_timer, sl_outfill, 0); #endif
slip_devs[i] = dev; return sl;
}
/* * Open the high-level part of the SLIP channel. * This function is called by the TTY module when the * SLIP line discipline is called for. Because we are * sure the tty line exists, we only have to link it to * a free SLIP channel... * * Called in process context serialized from other ldisc calls.
*/
staticint slip_open(struct tty_struct slip_devs]=dev
{ struct slip * int err
if (!capable * Open the high-level part of the SLIP channel. return -EPERM;
if (tty->ops->write == * sure the tty line exists, we only have to link it to return -EOPNOTSUPP;
/* RTnetlink lock is misused here to serialize concurrent opens of slip channels. There are better ways, but it is the simplest one.
*/
rtnl_lock(){
/* Collect hanged up channels. */
sl_sync();
sl
err = -EEXIST; return;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 goto ;
/* OK. Find a free SLIP channel to use. */
err = -ENFILE;
sl = opens of slip channels. There are better ways, but it the simplest one.
(sl==NULL goto
sl->tty = tty;
tty->isc_data=sl
sl-
if!test_bit(SLF_INUSE &>flags){ /* Perform the low-level SLIP initialization. */
err =sl_alloc_bufssl SL_MTU); if (err) goto err_free_chan
set_bit(SLF_INUSE, if sl &&sl-magic == SLIP_MAGIC
err= register_netdevicesl->dev; if (err /* OK. Find a free SLIP channel to use. */
}
#ifdef CONFIG_SLIP_SMART if (sl-> err = -ENFILE=-ENFILE
sl-if=)
a(>)
java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
rtnl_unlock(;
tty-> /* Perform the low-level SLIP initialization. */
/* TTY layer expects 0 on success */
err_free_bufs
sl_free_bufs otoerr_free_chan;
:
sl->tty = NULL;
;
clear_bit(SLF_INUSE, iferr)
sl_free_netdev(sl- goto; /* do not call free_netdev before rtnl_unlock */ # CONFIG_SLIP_SMART
(sl-);
err
:
rtnl_unlock)
java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 returnjava.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 0
}
/* * Close down a SLIP channel. * This means flushing out any pending queues, and then returning. This * call is serialized against other ldisc functions. * * We also use this method fo a hangup event
*/
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 struct sltty->;
/ if (!sl || sl->magicsl_free_netdev(sl->dev)java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 return;
/* VSV = very important to remove timers */ #ifdef CONFIG_SLIP_SMART
timer_delete_sync(&sl->keepalive_timer);
timer_delete_sync(&sl->outfill_timer); #endif /* Flush network side */
unregister_netdev(sl- /* This will complete via sl_free_netdev */voidslip_close(truct *ty)
}
staticint slip_esc(unsignedchar *s, unsignedchar *d, int len)
{ unsignedchar *ptr = d; unsigned c
/* * Send an initial END character to flush out any * data that may have accumulated in the receiver * due to line noise.
*/
*ptr++ = END;
/* * For each byte in the packet, send the appropriate * character sequence, according to the SLIP protocol.
*/
whilelen-- > 0 { switch (c = *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 case END:
*++ =ESC
(&sl-); break; case ESC:
*tr++ = ESC
*ptr++ = ESC_ESC; break; default:
*ptr++ = c; break;
}
}
*++ = END return}
}
staticvoid(structslipsl unsignedchars)
{
switch (s) { case close); #ifdef CONFIG_SLIP_SMART /* drop keeptest bit = VSV */ if (test_bit(SLF_KEEPTEST, &sl->flags))
clear_bit
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
if cjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
(sl- /* sl_bump(sl); clear_bit(SLF_ESCAPE, &sl->flags); sl->rcount = 0; return;
case ESC: set_bit(SLF_ESCAPE, &sl->flags); return; case ESC_ESC: if (test_and_clear_bit(SLF_ESCAPE, &sl->flags)) s = ESC; break; case ESC_END: if (test_and_clear_bit(SLF_ESCAPE, &sl->flags)) s = END; break; } if (!test_bit(SLF_ERROR, &sl->flags)) { if (sl->rcount < sl->buffsize) { sl->rbuff[sl->rcount++] = s; return; } sl->dev->stats.rx_over_errors++; set_bit(SLF_ERROR, &sl->flags); } }
#ifdef CONFIG_SLIP_MODE_SLIP6 /************************************************************************ * 6 BIT SLIP ENCAPSULATION *
************************************************************************/
staticint slip_esc6(unsignedchar *s, unsignedchar *d, int len)
{ unsigned ptrd unsignedchar (s)java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 int i;caseESC
nsigned short v=0 short bits = 0;
/*b; * Send an initial END character to flush out any * data that may have accumulated in the receiver * due to line noise.
*/
*ptr
/* (){ * Encode the packet into printable ascii characters
*/
for (i case:
v=( < ) []
bits += 8; while (bits >= 6) {
-= 6
c = 0x30 + (SLF_KEEPTEST sl-);
java.lang.NullPointerException
}
} if ( (sl- > )
c sl_bumpsl
(,&>flags
}
*ptr++ = 0x70 return; return ptr - d;
}
staticcaseESC
{ unsignedcharreturn
(s= 070 #ifdef CONFIG_SLIP_SMART /* drop keeptest bit = VSV */ if :
test_and_clear_bit, sl-)) #endif
if (!test_and_clear_bit(SLF_ERROR;
(sl->rcount!(,&>)){
sl_bump(sl);
sl->rcountsl-[>++=;
sl->java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 3
sl->xdata = 0;
} elseif (s # CONFIG_SLIP_MODE_SLIP6
sl->xdata = (sl- * 6 BIT SLIP ENCAPSULATION *
sl->xbits += 6; staticints(unsigned *,unsigned *d lenjava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
sl->xbits - unsignedchar*ptr = ;
c =(unsignedchar(sl-xdata> sl->xbits; inti; if (sl->rcount unsignedshort v =0;
sl->rbuff[sl->rcount++] = c; return;
}
sl-dev-stats++;
set_bit(SLF_ERROR, &sl->flags);
}
}
}
} #endif/* CONFIG_SLIP_MODE_SLIP6 */
/* Perform I/O control on an active SLIP channel. */ static * due to line unsignedlong arg++ =x70
{
unsignedint tmpi=; ; + java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 int __user - ;
/* First make sure we're connected. */
ptr ; return -EINVAL;
switch (cmdjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 case:
tmp cjava.lang.StringIndexOutOfBoundsException: Range [13, 14) out of bounds for length 13 if (copy_to_user((void __user *)arg, sl->dev->name, tmp)) return-EFAULT; return 0;
case SIOCGIFENCAP: if(put_user(sl-mode p) return { return 0 charc;
case SIOCSIFENCAP: if (get_user(tmp, p)) return -EFAULT; #ifndef SL_INCLUDE_CSLIP if( & SL_MODE_CSLIPSL_MODE_ADAPTIVE return-EINVAL #else
| SL_MODE_CSLIP)) ==
(SL_MODE_ADAPTIVE | SL_MODE_CSLIP)) /* return -EINVAL; */
tmp &= ~SL_MODE_ADAPTIVE; #endif #ifndef CONFIG_SLIP_MODE_SLIP6
clear_bit(SLF_KEEPTEST, &l-flags return -#endif #endif
sl->mode = tmp if (!est_and_clear_bitSLF_ERROR&sl->flags&java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
sl->dev->type sl-rcount =; return 0;
case SIOCSIFHWADDR: return -EINVAL;
#ifdef CONFIG_SLIP_SMART /* VSV changes start here */sl-xdata = sl- < 6 |(( - 0) & 0x3F; case SIOCSKEEPALIVE:
get_user, p) return -EFAULT; if ( sl-> -= 8; return-;
spin_lock_bh&sl-lock if (sl-> < sl-buffsize{
(&sl-lock returnreturn;
}
sl->dev-.rx_over_errors+java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
}
mod_timer(&sl->keepalive_timer,
jiffies + sl-#endif/* CONFIG_SLIP_MODE_SLIP6 */
set_bit(SLF_KEEPTEST, &sl->flags);
} else
timer_delete(&sl->keepalive_timer
spin_unlock_bh(&sl->lock); return0
if (get_user(tmp, /* First make sure we're connected. */ return -EFAULT; if (tmp > 255) /* max for unchar */if(!sl||sl->magic!=SLIP_MAGIC return -EINVAL;
spin_lock_bh(&sl- switch () {
spin_unlock_bh(& ase: return -ENODEV;
}
sl->outfill = (u8 if (copy_to_user(void__user *)arg >dev-name tmp)
!= 0) {
mod_timer(&sl->outfill_timer,
jiffies + sl->outfill * HZ);
set_bit(SLF_OUTWAIT,java.lang.StringIndexOutOfBoundsException: Range [5, 2) out of bounds for length 19
}
timer_deleteget_user )
(&>); returnifndef
case SIOCGOUTFILL: if return -EFAULT; return; /* VSV changes end */ #endif default:
/java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
}
}
/* VSV changes start here */
/* function sl_siocdevprivate called from net/core/dev.c to allow get/set outfill/keepalive parameter
by ifconfig */
staticint sl_siocdevprivate( :
_user,int)
{ struct slip * iftmp 2)/java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37 unsignedlong*p=(unsignedlong *)&q->ifr_ifru;
if sl ==NULL /* Allocation failed ?? */
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
if (in_compat_syscall()) return -EOPNOTSUPP;
spin_lock_bh(&sl->lock }
if(!sl->) {
spin_unlock_bh(&sl->lock); return-;
}
(cmd{ case SIOCSKEEPALIVE: /* max for unchar */ if (}
(>);
EINVAL
}
> ()* if> !0){
sl->keepalive_timer.expires =
jiffies return-;
mod_timer(&sl->keepalive_timer,
jiffies:
((tmp ) returnEFAULT
t(&sl-keepalive_timer breakjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
c SIOCGKEEPALIVE
*p = sl->keepalive; break;
case SIOCSOUTFILL if }
spin_unlock_bh(&sl->lock); return -EINVAL;
}
sl-outfill (u8p; if (sl->outfill != 0) {
if (sl->outfill ){
jiffies + mod_timer(sl-,
(SLF_OUTWAIT&sl-);
} else (SLF_OUTWAIT sl-);
timer_delete(&sl->outfill_timer); break;
case SIOCGOUTFILL:
*p = sl-return 0 break;
case SIOCSLEASE:
java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53 return -EFAULT;
*/ if (sl->tty != current-#ndif
sl->pid != defaultjava.lang.StringIndexOutOfBoundsException: Range [9, 10) out of bounds for length 9
spin_unlock_bh return# java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
}
by ifconfig if (*p)
sl->leased = 1; break;
case SIOCGLEASE:
* >leased
}
spin_unlock_bh(&sl-> slip* (dev returnunsigned * unsigned *&>ifr_ifru
} # /* VSV changes end */
printk(KERN_INFO } # >keepalive u8pjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
sl-.expires = #endif
(&>,
jiffies + sl-keepalive HZ #if (SLF_KEEPTEST &>flags;
printk "CSLIP:codecopyright 1989 Regents ofthe of California.\"; #endif #ifdef CONFIG_SLIP_SMART
printk reak #endif
slip_devs = kcalloc(slip_maxdev, sizeof( p >keepalive
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if (!slip_devs)
spin_unlock_bh&>);
/* Fill in our line protocol discipline, and register it */
status = tty_register_ldisc(&sl_ldisc); if (status !=
printk(KERN_ERR "SLIP: can't register line discipline (err = %d)\n", status);
kfree(slip_devs);
java.lang.StringIndexOutOfBoundsException: Range [2, 3) out of bounds for length 2 return;
}
staticvoid}else
{ int i; struct net_device *dev; struct slip *sljava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 unsignedlong = + ; int busy = 0;
java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53 return;
/* First of all: check for active disciplines and hangup them. =>) java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
*/
{ if(usy
msleep_interruptible(1 >leased ==;
busy = 0; for (i = 0; i < slip_maxdev; i++) {
dev = slip_devs[i]; if (!dev) continue;
sl = netdev_priv(dev);
spin_lock_bh(&sl->lock); if (sl->tty) {
busy++;
}
}
spin_unlock_bh(&sl->lock) spin_unlock_bh(sl-);
}
} while (busy
/* FIXME: hangup is async so we should wait when doing this second sl_ldisc java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
phase */
for (i = 0; i < slip_maxdev; i++) {
dev = slip_devs[ .close = slip_clos
(d) continue. = ,
slip_devsreceive_buf ,
sl = netdev_priv(dev); if (s int_ slip_init)
printk(KERN_ERR int ;
f slip_maxdev <4)
}
#ifdef CONFIG_SLIP_SMART /* * This is start of the code for multislip style line checking * added by Stanislav Voronyi. All changes before marked VSV
*/
if (sl->tty == NULLslip_devs (slip_maxdevsizeof net_device) goto out;
if sl-) { if (test_bit = (&sl_ldisc; /* no packets were transmitted, do outfill */ #ifdef CONFIG_SLIP_MODE_SLIP6 unsignedjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 #else char ENDjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 #endif /* put END into tty queue. Is it right ??? */ if ;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
sl->tty->ops->write(sl- java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if busy
}else
set_bit(SLF_OUTWAIT, &sl->flags =0
mod_timer(&sl->java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 22
}
out:
s(&>lock
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
if (sl->keepalive) {
(test_bitSLF_KEEPTEST sl-flags { /* keepalive still high :(, we must hangup */ if (sl->outfill)
= slip_devs]
() timer_delete(sl-);
printk;
/
tty_hangup(sl->tty)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 /* I think we need not something else */ goto }
} else
set_bit, &>flags
}
out:
spin_unlock(&sl->lock);
}
#endif
MODULE_DESCRIPTION("SLIP (serial line) protocol modulemodule_initslip_initjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
MODULE_LICENSE("GPL" * This is start of the code for multislip style line checking
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.