162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci========================================
462306a36Sopenharmony_ciPPP Generic Driver and Channel Interface
562306a36Sopenharmony_ci========================================
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci			   Paul Mackerras
862306a36Sopenharmony_ci			   paulus@samba.org
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci			      7 Feb 2002
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ciThe generic PPP driver in linux-2.4 provides an implementation of the
1362306a36Sopenharmony_cifunctionality which is of use in any PPP implementation, including:
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci* the network interface unit (ppp0 etc.)
1662306a36Sopenharmony_ci* the interface to the networking code
1762306a36Sopenharmony_ci* PPP multilink: splitting datagrams between multiple links, and
1862306a36Sopenharmony_ci  ordering and combining received fragments
1962306a36Sopenharmony_ci* the interface to pppd, via a /dev/ppp character device
2062306a36Sopenharmony_ci* packet compression and decompression
2162306a36Sopenharmony_ci* TCP/IP header compression and decompression
2262306a36Sopenharmony_ci* detecting network traffic for demand dialling and for idle timeouts
2362306a36Sopenharmony_ci* simple packet filtering
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ciFor sending and receiving PPP frames, the generic PPP driver calls on
2662306a36Sopenharmony_cithe services of PPP ``channels``.  A PPP channel encapsulates a
2762306a36Sopenharmony_cimechanism for transporting PPP frames from one machine to another.  A
2862306a36Sopenharmony_ciPPP channel implementation can be arbitrarily complex internally but
2962306a36Sopenharmony_cihas a very simple interface with the generic PPP code: it merely has
3062306a36Sopenharmony_cito be able to send PPP frames, receive PPP frames, and optionally
3162306a36Sopenharmony_cihandle ioctl requests.  Currently there are PPP channel
3262306a36Sopenharmony_ciimplementations for asynchronous serial ports, synchronous serial
3362306a36Sopenharmony_ciports, and for PPP over ethernet.
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ciThis architecture makes it possible to implement PPP multilink in a
3662306a36Sopenharmony_cinatural and straightforward way, by allowing more than one channel to
3762306a36Sopenharmony_cibe linked to each ppp network interface unit.  The generic layer is
3862306a36Sopenharmony_ciresponsible for splitting datagrams on transmit and recombining them
3962306a36Sopenharmony_cion receive.
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ciPPP channel API
4362306a36Sopenharmony_ci---------------
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciSee include/linux/ppp_channel.h for the declaration of the types and
4662306a36Sopenharmony_cifunctions used to communicate between the generic PPP layer and PPP
4762306a36Sopenharmony_cichannels.
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ciEach channel has to provide two functions to the generic PPP layer,
5062306a36Sopenharmony_civia the ppp_channel.ops pointer:
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci* start_xmit() is called by the generic layer when it has a frame to
5362306a36Sopenharmony_ci  send.  The channel has the option of rejecting the frame for
5462306a36Sopenharmony_ci  flow-control reasons.  In this case, start_xmit() should return 0
5562306a36Sopenharmony_ci  and the channel should call the ppp_output_wakeup() function at a
5662306a36Sopenharmony_ci  later time when it can accept frames again, and the generic layer
5762306a36Sopenharmony_ci  will then attempt to retransmit the rejected frame(s).  If the frame
5862306a36Sopenharmony_ci  is accepted, the start_xmit() function should return 1.
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci* ioctl() provides an interface which can be used by a user-space
6162306a36Sopenharmony_ci  program to control aspects of the channel's behaviour.  This
6262306a36Sopenharmony_ci  procedure will be called when a user-space program does an ioctl
6362306a36Sopenharmony_ci  system call on an instance of /dev/ppp which is bound to the
6462306a36Sopenharmony_ci  channel.  (Usually it would only be pppd which would do this.)
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ciThe generic PPP layer provides seven functions to channels:
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci* ppp_register_channel() is called when a channel has been created, to
6962306a36Sopenharmony_ci  notify the PPP generic layer of its presence.  For example, setting
7062306a36Sopenharmony_ci  a serial port to the PPPDISC line discipline causes the ppp_async
7162306a36Sopenharmony_ci  channel code to call this function.
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci* ppp_unregister_channel() is called when a channel is to be
7462306a36Sopenharmony_ci  destroyed.  For example, the ppp_async channel code calls this when
7562306a36Sopenharmony_ci  a hangup is detected on the serial port.
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci* ppp_output_wakeup() is called by a channel when it has previously
7862306a36Sopenharmony_ci  rejected a call to its start_xmit function, and can now accept more
7962306a36Sopenharmony_ci  packets.
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci* ppp_input() is called by a channel when it has received a complete
8262306a36Sopenharmony_ci  PPP frame.
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci* ppp_input_error() is called by a channel when it has detected that a
8562306a36Sopenharmony_ci  frame has been lost or dropped (for example, because of a FCS (frame
8662306a36Sopenharmony_ci  check sequence) error).
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci* ppp_channel_index() returns the channel index assigned by the PPP
8962306a36Sopenharmony_ci  generic layer to this channel.  The channel should provide some way
9062306a36Sopenharmony_ci  (e.g. an ioctl) to transmit this back to user-space, as user-space
9162306a36Sopenharmony_ci  will need it to attach an instance of /dev/ppp to this channel.
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci* ppp_unit_number() returns the unit number of the ppp network
9462306a36Sopenharmony_ci  interface to which this channel is connected, or -1 if the channel
9562306a36Sopenharmony_ci  is not connected.
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ciConnecting a channel to the ppp generic layer is initiated from the
9862306a36Sopenharmony_cichannel code, rather than from the generic layer.  The channel is
9962306a36Sopenharmony_ciexpected to have some way for a user-level process to control it
10062306a36Sopenharmony_ciindependently of the ppp generic layer.  For example, with the
10162306a36Sopenharmony_cippp_async channel, this is provided by the file descriptor to the
10262306a36Sopenharmony_ciserial port.
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ciGenerally a user-level process will initialize the underlying
10562306a36Sopenharmony_cicommunications medium and prepare it to do PPP.  For example, with an
10662306a36Sopenharmony_ciasync tty, this can involve setting the tty speed and modes, issuing
10762306a36Sopenharmony_cimodem commands, and then going through some sort of dialog with the
10862306a36Sopenharmony_ciremote system to invoke PPP service there.  We refer to this process
10962306a36Sopenharmony_cias ``discovery``.  Then the user-level process tells the medium to
11062306a36Sopenharmony_cibecome a PPP channel and register itself with the generic PPP layer.
11162306a36Sopenharmony_ciThe channel then has to report the channel number assigned to it back
11262306a36Sopenharmony_cito the user-level process.  From that point, the PPP negotiation code
11362306a36Sopenharmony_ciin the PPP daemon (pppd) can take over and perform the PPP
11462306a36Sopenharmony_cinegotiation, accessing the channel through the /dev/ppp interface.
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ciAt the interface to the PPP generic layer, PPP frames are stored in
11762306a36Sopenharmony_ciskbuff structures and start with the two-byte PPP protocol number.
11862306a36Sopenharmony_ciThe frame does *not* include the 0xff ``address`` byte or the 0x03
11962306a36Sopenharmony_ci``control`` byte that are optionally used in async PPP.  Nor is there
12062306a36Sopenharmony_ciany escaping of control characters, nor are there any FCS or framing
12162306a36Sopenharmony_cicharacters included.  That is all the responsibility of the channel
12262306a36Sopenharmony_cicode, if it is needed for the particular medium.  That is, the skbuffs
12362306a36Sopenharmony_cipresented to the start_xmit() function contain only the 2-byte
12462306a36Sopenharmony_ciprotocol number and the data, and the skbuffs presented to ppp_input()
12562306a36Sopenharmony_cimust be in the same format.
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ciThe channel must provide an instance of a ppp_channel struct to
12862306a36Sopenharmony_cirepresent the channel.  The channel is free to use the ``private`` field
12962306a36Sopenharmony_cihowever it wishes.  The channel should initialize the ``mtu`` and
13062306a36Sopenharmony_ci``hdrlen`` fields before calling ppp_register_channel() and not change
13162306a36Sopenharmony_cithem until after ppp_unregister_channel() returns.  The ``mtu`` field
13262306a36Sopenharmony_cirepresents the maximum size of the data part of the PPP frames, that
13362306a36Sopenharmony_ciis, it does not include the 2-byte protocol number.
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ciIf the channel needs some headroom in the skbuffs presented to it for
13662306a36Sopenharmony_citransmission (i.e., some space free in the skbuff data area before the
13762306a36Sopenharmony_cistart of the PPP frame), it should set the ``hdrlen`` field of the
13862306a36Sopenharmony_cippp_channel struct to the amount of headroom required.  The generic
13962306a36Sopenharmony_ciPPP layer will attempt to provide that much headroom but the channel
14062306a36Sopenharmony_cishould still check if there is sufficient headroom and copy the skbuff
14162306a36Sopenharmony_ciif there isn't.
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ciOn the input side, channels should ideally provide at least 2 bytes of
14462306a36Sopenharmony_ciheadroom in the skbuffs presented to ppp_input().  The generic PPP
14562306a36Sopenharmony_cicode does not require this but will be more efficient if this is done.
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ciBuffering and flow control
14962306a36Sopenharmony_ci--------------------------
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ciThe generic PPP layer has been designed to minimize the amount of data
15262306a36Sopenharmony_cithat it buffers in the transmit direction.  It maintains a queue of
15362306a36Sopenharmony_citransmit packets for the PPP unit (network interface device) plus a
15462306a36Sopenharmony_ciqueue of transmit packets for each attached channel.  Normally the
15562306a36Sopenharmony_citransmit queue for the unit will contain at most one packet; the
15662306a36Sopenharmony_ciexceptions are when pppd sends packets by writing to /dev/ppp, and
15762306a36Sopenharmony_ciwhen the core networking code calls the generic layer's start_xmit()
15862306a36Sopenharmony_cifunction with the queue stopped, i.e. when the generic layer has
15962306a36Sopenharmony_cicalled netif_stop_queue(), which only happens on a transmit timeout.
16062306a36Sopenharmony_ciThe start_xmit function always accepts and queues the packet which it
16162306a36Sopenharmony_ciis asked to transmit.
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ciTransmit packets are dequeued from the PPP unit transmit queue and
16462306a36Sopenharmony_cithen subjected to TCP/IP header compression and packet compression
16562306a36Sopenharmony_ci(Deflate or BSD-Compress compression), as appropriate.  After this
16662306a36Sopenharmony_cipoint the packets can no longer be reordered, as the decompression
16762306a36Sopenharmony_cialgorithms rely on receiving compressed packets in the same order that
16862306a36Sopenharmony_cithey were generated.
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ciIf multilink is not in use, this packet is then passed to the attached
17162306a36Sopenharmony_cichannel's start_xmit() function.  If the channel refuses to take
17262306a36Sopenharmony_cithe packet, the generic layer saves it for later transmission.  The
17362306a36Sopenharmony_cigeneric layer will call the channel's start_xmit() function again
17462306a36Sopenharmony_ciwhen the channel calls  ppp_output_wakeup() or when the core
17562306a36Sopenharmony_cinetworking code calls the generic layer's start_xmit() function
17662306a36Sopenharmony_ciagain.  The generic layer contains no timeout and retransmission
17762306a36Sopenharmony_cilogic; it relies on the core networking code for that.
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ciIf multilink is in use, the generic layer divides the packet into one
18062306a36Sopenharmony_cior more fragments and puts a multilink header on each fragment.  It
18162306a36Sopenharmony_cidecides how many fragments to use based on the length of the packet
18262306a36Sopenharmony_ciand the number of channels which are potentially able to accept a
18362306a36Sopenharmony_cifragment at the moment.  A channel is potentially able to accept a
18462306a36Sopenharmony_cifragment if it doesn't have any fragments currently queued up for it
18562306a36Sopenharmony_cito transmit.  The channel may still refuse a fragment; in this case
18662306a36Sopenharmony_cithe fragment is queued up for the channel to transmit later.  This
18762306a36Sopenharmony_cischeme has the effect that more fragments are given to higher-
18862306a36Sopenharmony_cibandwidth channels.  It also means that under light load, the generic
18962306a36Sopenharmony_cilayer will tend to fragment large packets across all the channels,
19062306a36Sopenharmony_cithus reducing latency, while under heavy load, packets will tend to be
19162306a36Sopenharmony_citransmitted as single fragments, thus reducing the overhead of
19262306a36Sopenharmony_cifragmentation.
19362306a36Sopenharmony_ci
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ciSMP safety
19662306a36Sopenharmony_ci----------
19762306a36Sopenharmony_ci
19862306a36Sopenharmony_ciThe PPP generic layer has been designed to be SMP-safe.  Locks are
19962306a36Sopenharmony_ciused around accesses to the internal data structures where necessary
20062306a36Sopenharmony_cito ensure their integrity.  As part of this, the generic layer
20162306a36Sopenharmony_cirequires that the channels adhere to certain requirements and in turn
20262306a36Sopenharmony_ciprovides certain guarantees to the channels.  Essentially the channels
20362306a36Sopenharmony_ciare required to provide the appropriate locking on the ppp_channel
20462306a36Sopenharmony_cistructures that form the basis of the communication between the
20562306a36Sopenharmony_cichannel and the generic layer.  This is because the channel provides
20662306a36Sopenharmony_cithe storage for the ppp_channel structure, and so the channel is
20762306a36Sopenharmony_cirequired to provide the guarantee that this storage exists and is
20862306a36Sopenharmony_civalid at the appropriate times.
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_ciThe generic layer requires these guarantees from the channel:
21162306a36Sopenharmony_ci
21262306a36Sopenharmony_ci* The ppp_channel object must exist from the time that
21362306a36Sopenharmony_ci  ppp_register_channel() is called until after the call to
21462306a36Sopenharmony_ci  ppp_unregister_channel() returns.
21562306a36Sopenharmony_ci
21662306a36Sopenharmony_ci* No thread may be in a call to any of ppp_input(), ppp_input_error(),
21762306a36Sopenharmony_ci  ppp_output_wakeup(), ppp_channel_index() or ppp_unit_number() for a
21862306a36Sopenharmony_ci  channel at the time that ppp_unregister_channel() is called for that
21962306a36Sopenharmony_ci  channel.
22062306a36Sopenharmony_ci
22162306a36Sopenharmony_ci* ppp_register_channel() and ppp_unregister_channel() must be called
22262306a36Sopenharmony_ci  from process context, not interrupt or softirq/BH context.
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_ci* The remaining generic layer functions may be called at softirq/BH
22562306a36Sopenharmony_ci  level but must not be called from a hardware interrupt handler.
22662306a36Sopenharmony_ci
22762306a36Sopenharmony_ci* The generic layer may call the channel start_xmit() function at
22862306a36Sopenharmony_ci  softirq/BH level but will not call it at interrupt level.  Thus the
22962306a36Sopenharmony_ci  start_xmit() function may not block.
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ci* The generic layer will only call the channel ioctl() function in
23262306a36Sopenharmony_ci  process context.
23362306a36Sopenharmony_ci
23462306a36Sopenharmony_ciThe generic layer provides these guarantees to the channels:
23562306a36Sopenharmony_ci
23662306a36Sopenharmony_ci* The generic layer will not call the start_xmit() function for a
23762306a36Sopenharmony_ci  channel while any thread is already executing in that function for
23862306a36Sopenharmony_ci  that channel.
23962306a36Sopenharmony_ci
24062306a36Sopenharmony_ci* The generic layer will not call the ioctl() function for a channel
24162306a36Sopenharmony_ci  while any thread is already executing in that function for that
24262306a36Sopenharmony_ci  channel.
24362306a36Sopenharmony_ci
24462306a36Sopenharmony_ci* By the time a call to ppp_unregister_channel() returns, no thread
24562306a36Sopenharmony_ci  will be executing in a call from the generic layer to that channel's
24662306a36Sopenharmony_ci  start_xmit() or ioctl() function, and the generic layer will not
24762306a36Sopenharmony_ci  call either of those functions subsequently.
24862306a36Sopenharmony_ci
24962306a36Sopenharmony_ci
25062306a36Sopenharmony_ciInterface to pppd
25162306a36Sopenharmony_ci-----------------
25262306a36Sopenharmony_ci
25362306a36Sopenharmony_ciThe PPP generic layer exports a character device interface called
25462306a36Sopenharmony_ci/dev/ppp.  This is used by pppd to control PPP interface units and
25562306a36Sopenharmony_cichannels.  Although there is only one /dev/ppp, each open instance of
25662306a36Sopenharmony_ci/dev/ppp acts independently and can be attached either to a PPP unit
25762306a36Sopenharmony_cior a PPP channel.  This is achieved using the file->private_data field
25862306a36Sopenharmony_cito point to a separate object for each open instance of /dev/ppp.  In
25962306a36Sopenharmony_cithis way an effect similar to Solaris' clone open is obtained,
26062306a36Sopenharmony_ciallowing us to control an arbitrary number of PPP interfaces and
26162306a36Sopenharmony_cichannels without having to fill up /dev with hundreds of device names.
26262306a36Sopenharmony_ci
26362306a36Sopenharmony_ciWhen /dev/ppp is opened, a new instance is created which is initially
26462306a36Sopenharmony_ciunattached.  Using an ioctl call, it can then be attached to an
26562306a36Sopenharmony_ciexisting unit, attached to a newly-created unit, or attached to an
26662306a36Sopenharmony_ciexisting channel.  An instance attached to a unit can be used to send
26762306a36Sopenharmony_ciand receive PPP control frames, using the read() and write() system
26862306a36Sopenharmony_cicalls, along with poll() if necessary.  Similarly, an instance
26962306a36Sopenharmony_ciattached to a channel can be used to send and receive PPP frames on
27062306a36Sopenharmony_cithat channel.
27162306a36Sopenharmony_ci
27262306a36Sopenharmony_ciIn multilink terms, the unit represents the bundle, while the channels
27362306a36Sopenharmony_cirepresent the individual physical links.  Thus, a PPP frame sent by a
27462306a36Sopenharmony_ciwrite to the unit (i.e., to an instance of /dev/ppp attached to the
27562306a36Sopenharmony_ciunit) will be subject to bundle-level compression and to fragmentation
27662306a36Sopenharmony_ciacross the individual links (if multilink is in use).  In contrast, a
27762306a36Sopenharmony_ciPPP frame sent by a write to the channel will be sent as-is on that
27862306a36Sopenharmony_cichannel, without any multilink header.
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ciA channel is not initially attached to any unit.  In this state it can
28162306a36Sopenharmony_cibe used for PPP negotiation but not for the transfer of data packets.
28262306a36Sopenharmony_ciIt can then be connected to a PPP unit with an ioctl call, which
28362306a36Sopenharmony_cimakes it available to send and receive data packets for that unit.
28462306a36Sopenharmony_ci
28562306a36Sopenharmony_ciThe ioctl calls which are available on an instance of /dev/ppp depend
28662306a36Sopenharmony_cion whether it is unattached, attached to a PPP interface, or attached
28762306a36Sopenharmony_cito a PPP channel.  The ioctl calls which are available on an
28862306a36Sopenharmony_ciunattached instance are:
28962306a36Sopenharmony_ci
29062306a36Sopenharmony_ci* PPPIOCNEWUNIT creates a new PPP interface and makes this /dev/ppp
29162306a36Sopenharmony_ci  instance the "owner" of the interface.  The argument should point to
29262306a36Sopenharmony_ci  an int which is the desired unit number if >= 0, or -1 to assign the
29362306a36Sopenharmony_ci  lowest unused unit number.  Being the owner of the interface means
29462306a36Sopenharmony_ci  that the interface will be shut down if this instance of /dev/ppp is
29562306a36Sopenharmony_ci  closed.
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ci* PPPIOCATTACH attaches this instance to an existing PPP interface.
29862306a36Sopenharmony_ci  The argument should point to an int containing the unit number.
29962306a36Sopenharmony_ci  This does not make this instance the owner of the PPP interface.
30062306a36Sopenharmony_ci
30162306a36Sopenharmony_ci* PPPIOCATTCHAN attaches this instance to an existing PPP channel.
30262306a36Sopenharmony_ci  The argument should point to an int containing the channel number.
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_ciThe ioctl calls available on an instance of /dev/ppp attached to a
30562306a36Sopenharmony_cichannel are:
30662306a36Sopenharmony_ci
30762306a36Sopenharmony_ci* PPPIOCCONNECT connects this channel to a PPP interface.  The
30862306a36Sopenharmony_ci  argument should point to an int containing the interface unit
30962306a36Sopenharmony_ci  number.  It will return an EINVAL error if the channel is already
31062306a36Sopenharmony_ci  connected to an interface, or ENXIO if the requested interface does
31162306a36Sopenharmony_ci  not exist.
31262306a36Sopenharmony_ci
31362306a36Sopenharmony_ci* PPPIOCDISCONN disconnects this channel from the PPP interface that
31462306a36Sopenharmony_ci  it is connected to.  It will return an EINVAL error if the channel
31562306a36Sopenharmony_ci  is not connected to an interface.
31662306a36Sopenharmony_ci
31762306a36Sopenharmony_ci* PPPIOCBRIDGECHAN bridges a channel with another. The argument should
31862306a36Sopenharmony_ci  point to an int containing the channel number of the channel to bridge
31962306a36Sopenharmony_ci  to. Once two channels are bridged, frames presented to one channel by
32062306a36Sopenharmony_ci  ppp_input() are passed to the bridge instance for onward transmission.
32162306a36Sopenharmony_ci  This allows frames to be switched from one channel into another: for
32262306a36Sopenharmony_ci  example, to pass PPPoE frames into a PPPoL2TP session. Since channel
32362306a36Sopenharmony_ci  bridging interrupts the normal ppp_input() path, a given channel may
32462306a36Sopenharmony_ci  not be part of a bridge at the same time as being part of a unit.
32562306a36Sopenharmony_ci  This ioctl will return an EALREADY error if the channel is already
32662306a36Sopenharmony_ci  part of a bridge or unit, or ENXIO if the requested channel does not
32762306a36Sopenharmony_ci  exist.
32862306a36Sopenharmony_ci
32962306a36Sopenharmony_ci* PPPIOCUNBRIDGECHAN performs the inverse of PPPIOCBRIDGECHAN, unbridging
33062306a36Sopenharmony_ci  a channel pair.  This ioctl will return an EINVAL error if the channel
33162306a36Sopenharmony_ci  does not form part of a bridge.
33262306a36Sopenharmony_ci
33362306a36Sopenharmony_ci* All other ioctl commands are passed to the channel ioctl() function.
33462306a36Sopenharmony_ci
33562306a36Sopenharmony_ciThe ioctl calls that are available on an instance that is attached to
33662306a36Sopenharmony_cian interface unit are:
33762306a36Sopenharmony_ci
33862306a36Sopenharmony_ci* PPPIOCSMRU sets the MRU (maximum receive unit) for the interface.
33962306a36Sopenharmony_ci  The argument should point to an int containing the new MRU value.
34062306a36Sopenharmony_ci
34162306a36Sopenharmony_ci* PPPIOCSFLAGS sets flags which control the operation of the
34262306a36Sopenharmony_ci  interface.  The argument should be a pointer to an int containing
34362306a36Sopenharmony_ci  the new flags value.  The bits in the flags value that can be set
34462306a36Sopenharmony_ci  are:
34562306a36Sopenharmony_ci
34662306a36Sopenharmony_ci	================	========================================
34762306a36Sopenharmony_ci	SC_COMP_TCP		enable transmit TCP header compression
34862306a36Sopenharmony_ci	SC_NO_TCP_CCID		disable connection-id compression for
34962306a36Sopenharmony_ci				TCP header compression
35062306a36Sopenharmony_ci	SC_REJ_COMP_TCP		disable receive TCP header decompression
35162306a36Sopenharmony_ci	SC_CCP_OPEN		Compression Control Protocol (CCP) is
35262306a36Sopenharmony_ci				open, so inspect CCP packets
35362306a36Sopenharmony_ci	SC_CCP_UP		CCP is up, may (de)compress packets
35462306a36Sopenharmony_ci	SC_LOOP_TRAFFIC		send IP traffic to pppd
35562306a36Sopenharmony_ci	SC_MULTILINK		enable PPP multilink fragmentation on
35662306a36Sopenharmony_ci				transmitted packets
35762306a36Sopenharmony_ci	SC_MP_SHORTSEQ		expect short multilink sequence
35862306a36Sopenharmony_ci				numbers on received multilink fragments
35962306a36Sopenharmony_ci	SC_MP_XSHORTSEQ		transmit short multilink sequence nos.
36062306a36Sopenharmony_ci	================	========================================
36162306a36Sopenharmony_ci
36262306a36Sopenharmony_ci  The values of these flags are defined in <linux/ppp-ioctl.h>.  Note
36362306a36Sopenharmony_ci  that the values of the SC_MULTILINK, SC_MP_SHORTSEQ and
36462306a36Sopenharmony_ci  SC_MP_XSHORTSEQ bits are ignored if the CONFIG_PPP_MULTILINK option
36562306a36Sopenharmony_ci  is not selected.
36662306a36Sopenharmony_ci
36762306a36Sopenharmony_ci* PPPIOCGFLAGS returns the value of the status/control flags for the
36862306a36Sopenharmony_ci  interface unit.  The argument should point to an int where the ioctl
36962306a36Sopenharmony_ci  will store the flags value.  As well as the values listed above for
37062306a36Sopenharmony_ci  PPPIOCSFLAGS, the following bits may be set in the returned value:
37162306a36Sopenharmony_ci
37262306a36Sopenharmony_ci	================	=========================================
37362306a36Sopenharmony_ci	SC_COMP_RUN		CCP compressor is running
37462306a36Sopenharmony_ci	SC_DECOMP_RUN		CCP decompressor is running
37562306a36Sopenharmony_ci	SC_DC_ERROR		CCP decompressor detected non-fatal error
37662306a36Sopenharmony_ci	SC_DC_FERROR		CCP decompressor detected fatal error
37762306a36Sopenharmony_ci	================	=========================================
37862306a36Sopenharmony_ci
37962306a36Sopenharmony_ci* PPPIOCSCOMPRESS sets the parameters for packet compression or
38062306a36Sopenharmony_ci  decompression.  The argument should point to a ppp_option_data
38162306a36Sopenharmony_ci  structure (defined in <linux/ppp-ioctl.h>), which contains a
38262306a36Sopenharmony_ci  pointer/length pair which should describe a block of memory
38362306a36Sopenharmony_ci  containing a CCP option specifying a compression method and its
38462306a36Sopenharmony_ci  parameters.  The ppp_option_data struct also contains a ``transmit``
38562306a36Sopenharmony_ci  field.  If this is 0, the ioctl will affect the receive path,
38662306a36Sopenharmony_ci  otherwise the transmit path.
38762306a36Sopenharmony_ci
38862306a36Sopenharmony_ci* PPPIOCGUNIT returns, in the int pointed to by the argument, the unit
38962306a36Sopenharmony_ci  number of this interface unit.
39062306a36Sopenharmony_ci
39162306a36Sopenharmony_ci* PPPIOCSDEBUG sets the debug flags for the interface to the value in
39262306a36Sopenharmony_ci  the int pointed to by the argument.  Only the least significant bit
39362306a36Sopenharmony_ci  is used; if this is 1 the generic layer will print some debug
39462306a36Sopenharmony_ci  messages during its operation.  This is only intended for debugging
39562306a36Sopenharmony_ci  the generic PPP layer code; it is generally not helpful for working
39662306a36Sopenharmony_ci  out why a PPP connection is failing.
39762306a36Sopenharmony_ci
39862306a36Sopenharmony_ci* PPPIOCGDEBUG returns the debug flags for the interface in the int
39962306a36Sopenharmony_ci  pointed to by the argument.
40062306a36Sopenharmony_ci
40162306a36Sopenharmony_ci* PPPIOCGIDLE returns the time, in seconds, since the last data
40262306a36Sopenharmony_ci  packets were sent and received.  The argument should point to a
40362306a36Sopenharmony_ci  ppp_idle structure (defined in <linux/ppp_defs.h>).  If the
40462306a36Sopenharmony_ci  CONFIG_PPP_FILTER option is enabled, the set of packets which reset
40562306a36Sopenharmony_ci  the transmit and receive idle timers is restricted to those which
40662306a36Sopenharmony_ci  pass the ``active`` packet filter.
40762306a36Sopenharmony_ci  Two versions of this command exist, to deal with user space
40862306a36Sopenharmony_ci  expecting times as either 32-bit or 64-bit time_t seconds.
40962306a36Sopenharmony_ci
41062306a36Sopenharmony_ci* PPPIOCSMAXCID sets the maximum connection-ID parameter (and thus the
41162306a36Sopenharmony_ci  number of connection slots) for the TCP header compressor and
41262306a36Sopenharmony_ci  decompressor.  The lower 16 bits of the int pointed to by the
41362306a36Sopenharmony_ci  argument specify the maximum connection-ID for the compressor.  If
41462306a36Sopenharmony_ci  the upper 16 bits of that int are non-zero, they specify the maximum
41562306a36Sopenharmony_ci  connection-ID for the decompressor, otherwise the decompressor's
41662306a36Sopenharmony_ci  maximum connection-ID is set to 15.
41762306a36Sopenharmony_ci
41862306a36Sopenharmony_ci* PPPIOCSNPMODE sets the network-protocol mode for a given network
41962306a36Sopenharmony_ci  protocol.  The argument should point to an npioctl struct (defined
42062306a36Sopenharmony_ci  in <linux/ppp-ioctl.h>).  The ``protocol`` field gives the PPP protocol
42162306a36Sopenharmony_ci  number for the protocol to be affected, and the ``mode`` field
42262306a36Sopenharmony_ci  specifies what to do with packets for that protocol:
42362306a36Sopenharmony_ci
42462306a36Sopenharmony_ci	=============	==============================================
42562306a36Sopenharmony_ci	NPMODE_PASS	normal operation, transmit and receive packets
42662306a36Sopenharmony_ci	NPMODE_DROP	silently drop packets for this protocol
42762306a36Sopenharmony_ci	NPMODE_ERROR	drop packets and return an error on transmit
42862306a36Sopenharmony_ci	NPMODE_QUEUE	queue up packets for transmit, drop received
42962306a36Sopenharmony_ci			packets
43062306a36Sopenharmony_ci	=============	==============================================
43162306a36Sopenharmony_ci
43262306a36Sopenharmony_ci  At present NPMODE_ERROR and NPMODE_QUEUE have the same effect as
43362306a36Sopenharmony_ci  NPMODE_DROP.
43462306a36Sopenharmony_ci
43562306a36Sopenharmony_ci* PPPIOCGNPMODE returns the network-protocol mode for a given
43662306a36Sopenharmony_ci  protocol.  The argument should point to an npioctl struct with the
43762306a36Sopenharmony_ci  ``protocol`` field set to the PPP protocol number for the protocol of
43862306a36Sopenharmony_ci  interest.  On return the ``mode`` field will be set to the network-
43962306a36Sopenharmony_ci  protocol mode for that protocol.
44062306a36Sopenharmony_ci
44162306a36Sopenharmony_ci* PPPIOCSPASS and PPPIOCSACTIVE set the ``pass`` and ``active`` packet
44262306a36Sopenharmony_ci  filters.  These ioctls are only available if the CONFIG_PPP_FILTER
44362306a36Sopenharmony_ci  option is selected.  The argument should point to a sock_fprog
44462306a36Sopenharmony_ci  structure (defined in <linux/filter.h>) containing the compiled BPF
44562306a36Sopenharmony_ci  instructions for the filter.  Packets are dropped if they fail the
44662306a36Sopenharmony_ci  ``pass`` filter; otherwise, if they fail the ``active`` filter they are
44762306a36Sopenharmony_ci  passed but they do not reset the transmit or receive idle timer.
44862306a36Sopenharmony_ci
44962306a36Sopenharmony_ci* PPPIOCSMRRU enables or disables multilink processing for received
45062306a36Sopenharmony_ci  packets and sets the multilink MRRU (maximum reconstructed receive
45162306a36Sopenharmony_ci  unit).  The argument should point to an int containing the new MRRU
45262306a36Sopenharmony_ci  value.  If the MRRU value is 0, processing of received multilink
45362306a36Sopenharmony_ci  fragments is disabled.  This ioctl is only available if the
45462306a36Sopenharmony_ci  CONFIG_PPP_MULTILINK option is selected.
45562306a36Sopenharmony_ci
45662306a36Sopenharmony_ciLast modified: 7-feb-2002
457