: Class PPP

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.dalsemi.tininet.ppp
Class PPP

    java.lang.Object
      |
      +--java.lang.Thread
            |
            +--com.dalsemi.tininet.ppp.PPP

public class PPP
extends Thread

This class implements the Point-to-Point Protocol (PPP), which provides IP packet transport over a serial link. PPP exists as a layer between the IP network-layer and a physical interface. Being a point-to-point protocol, PPP does not distinguish between a client and a server operation. For the purposes of this documentation, a peer which requires a remote peer to authenticate and provides an IP address to the remote peer will be known as a server. A peer which does not require a remote peer to authenticate and uses a server assigned IP address will be know as a client. Many variations exist between these configurations and are not covered in this documentation.

To satisfy the physical interface requirement, user application code must open, initialize and pass a serial port object to an instance of PPP. After passing the serial port object to PPP, the user application should not attempt to read or write operations on the serial port until PPP has signaled a closed event. This does not preclude the application code from implementing the `SerialPortEventListener` interface or from polling the serial port status signals.

An application that creates a PPP object must provide a listener to receive notification of PPP events. The listener is an instance of a class that implements the `PPPEventListener` interface.

### Usage

  #### Example 1

  Setup a PPP connection using the already configured serial object 'so'.

        (code example)

  #### Example 2

  Use the ppp instance 'pppConnection' that was configured in Example 1.

        (code example)

  #### Example 3

  Close the ppp connection 'pppConnection'.

        (code example)

See Also:
  `PPPEventListener`, `PPPEvent`, `SerialPort`

Field Summary
`static byte` | `PEER_ID` Peer ID parameter to getUsernamePassword
`static byte` | `PEER_PASSWORD` Peer password parameter to getUsernamePassword

Fields inherited from class java.lang.Thread
`MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

Constructor Summary
`PPP()` Default constructor

Method Summary
`void` | `addEventListener(PPPEventListener eventListener)` Adds a PPP event listener.
`void` | `addInterface(String name)` Adds a PPP interface to the network interface table.
`void` | `authenticate(boolean value)` Indicates if access should be granted to remote peer.
`void` | `close()` Invoked to close PPP.
`void` | `down()` Invoked when serial channel is no longer available for PPP traffic.
`void` | `freeInterfaceWrapper()` Frees native PPP interface.
`int` | `getACCM()` Gets the current Asynchronous Control Character Map (ACCM).
`boolean` | `getAuthenticate()` Gets current value of remote peer authenticate flag.
`boolean` | `getDefaultInterface()` Gets the current value of the default interface flag.
`byte[]` | `getLocalAddress()` Gets the local IP address for this interface.
`int` | `getMaxConfig()` Gets the maximum number of configuration retries allowed.
`int` | `getMaxFailure()` Gets the maximum number of configuration failures allowed.
`int` | `getMaxTerminate()` Gets the maximum number of termination retries allowed.
`boolean` | `getPassive()` Gets the current state of the passive mode option.
`String` | `getPeerID()` Gets the remote peers authentication ID.
`String` | `getPeerPassword()` Gets the remote peers authentication password.
`byte[]` | `getRemoteAddress()` Gets the IP address of the remote peer.
`int` | `getRestartPeriod()` Gets the timeout period.
`static int` | `getTransmitter(byte index)` Gets the transmitter routine.
`int` | `getUsernamePassword(int option, byte[] value)` Deprecated. Gets remote peers username/password. Used during authentication phase to retreive remote peers ID and password. Invoking this method with value as null returns length of option.
`boolean` | `getXonXoffEscape()` Gets the current mode of XON/XOFF escaping.
`void` | `open()` Invoked to open PPP.
`void` | `removeEventListener(PPPEventListener eventListener)` Removes a PPP event listener.
`void` | `removeInterface(String name)` Removes the named PPP interface from the network interface table.
`void` | `run()` Implements PPP deamon thread which propagates pppEvents to event listeners.
`void` | `setACCM(int newACCM)` Sets the value of the Asynchronous Control Character Map (ACCM).
`void` | `setAuthenticate(boolean value)` Sets the remote peer authentication option.
`void` | `setDefaultInterface(boolean value)` Sets the default interface flag.
`void` | `setLocalAddress(byte[] address)` Sets the local IP address for this interface.
`void` | `setMaxConfig(int count)` Sets the maximum number of unanswered configuration requests that will be sent (1 - 20).
`void` | `setMaxFailure(int count)` Sets the maximum number of configuration failures allowed (1 - 20).
`void` | `setMaxTerminate(int count)` Sets the maximum number of termination requests that will be sent (1 - 20).
`void` | `setPassive(boolean value)` Sets passive mode option.
`void` | `setPassword(String password)` Sets the password sent to a remote peer during authentication.
`void` | `setRemoteAddress(byte[] address)` Sets the IP address of the remote peer.
`void` | `setRestartPeriod(int timeout)` Sets the restart time period in seconds (1 - 30).
`void` | `setUsername(String userName)` Sets the user name sent to a remote peer during authentication.
`void` | `setXonXoffEscape(boolean value)` Sets XON/XOFF flows control character escaping.
`void` | `stopPPPThread()` Terminates internal PPP event notification thread.
`void` | `up(javax.comm.SerialPort sp)` Invoked when serial channel is ready for PPP traffic.

Methods inherited from class java.lang.Thread
`activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### PEER_ID

    public static final byte PEER_ID

  Peer ID parameter to getUsernamePassword

### PEER_PASSWORD

    public static final byte PEER_PASSWORD

  Peer password parameter to getUsernamePassword

Constructor Detail

### PPP

    public PPP()

  Default constructor

Method Detail

### getTransmitter

    public static int getTransmitter(byte index)

  Gets the transmitter routine.
  Parameters:
    `index` - interface index

### setACCM

    public void setACCM(int newACCM)

  Sets the value of the Asynchronous Control Character Map (ACCM). If a bit in a specified position is 1, the corresponding character is escaped otherwise it is transmitted normaly. For example an ACCM value of 0x80000001 will escape only characters 0 and 31. By default the ACCM value is 0xffffffff, escape all characters in the range 0x00 - 0x1f. Usefull ACCM values are 0x00000000, escape no characters, and 0x000a0000, escape 0x11 and 0x13 for channels using XON/XOFF flow control.
  Parameters:
    `newACCM` - Asynchronous Control Character Map (ACCM)

### getACCM

    public int getACCM()

  Gets the current Asynchronous Control Character Map (ACCM).
  Returns:
    Asynchronous Control Character Map (ACCM)
  See Also:
    `setACCM()`

### setAuthenticate

    public void setAuthenticate(boolean value)

  Sets the remote peer authentication option. When this option is set `true` this peer will require the remote peer to authenticate before a connection is established.
  Parameters:
    `value` - `true` if remote peer authentication is required

### getAuthenticate

    public boolean getAuthenticate()

  Gets current value of remote peer authenticate flag.
  Returns:
    current value of authentication flag
  See Also:
    `setAuthenticate()`

### setDefaultInterface

    public void setDefaultInterface(boolean value)

  Sets the default interface flag. When this option is set `true` this interface will be set to the default network interface once a connection is established.
  Parameters:
    `value` - `true` if this interface should be set a default network interface

### getDefaultInterface

    public boolean getDefaultInterface()

  Gets the current value of the default interface flag.
  Returns:
    current value of default interface flag
  See Also:
    `setDefaultInterface`

### setLocalAddress

    public void setLocalAddress(byte[] address)

  Sets the local IP address for this interface. If the remote peer is vending an address this address must match the vended address or PPP will fail to negotiate the link.
  Parameters:
    `address` - local IP address, index 0 is MSB of four byte network address

### getLocalAddress

    public byte[] getLocalAddress()

  Gets the local IP address for this interface.
  Returns:
    local IP address, index 0 is MSB of four byte network address
  See Also:
    `setLocalAddress()`

### setPassive

    public void setPassive(boolean value)

  Sets passive mode option. Passive mode effects the earliest phase of of connection establishment, Line Control Protocol (LCP) negotiation. By default passive mode is set to false and LCP attempts to initiate a connection by sending configuration request messages to the remote peer. If no response is received LCP times out and generates a stopped event. When passive mode is true LCP will time out but not generate as stopped event and will wait indefinitly for the remote peer to transmit a configuration request.
  Parameters:
    `value` - `true` for passive mode operation

### getPassive

    public boolean getPassive()

  Gets the current state of the passive mode option.
  Returns:
    current state of passive mode option
  See Also:
    `setPassive()`

### setPassword

    public void setPassword(String password)
                     throws PPPException

  Sets the password sent to a remote peer during authentication.
  Parameters:
    `password` - user password
  Throws:
    PPPException - Password exceeds maximum length

### setUsername

    public void setUsername(String userName)
                     throws PPPException

  Sets the user name sent to a remote peer during authentication.
  Parameters:
    `userName` - user name
  Throws:
    PPPException - Username exceeds maximum length

### setRemoteAddress

    public void setRemoteAddress(byte[] address)

  Sets the IP address of the remote peer. Used when this peer is operating as a server and needs to vend an IP address to the remote peer.
  Parameters:
    `address` - remote IP address, index 0 is MSB of four byte network address

### getRemoteAddress

    public byte[] getRemoteAddress()

  Gets the IP address of the remote peer.
  Returns:
    remote IP address, index 0 is MSB of four byte network address
  See Also:
    `setRemoteAddress()`

### setRestartPeriod

    public void setRestartPeriod(int timeout)
                          throws PPPException

  Sets the restart time period in seconds (1 - 30). Expiration of the restart time is used by the underlying state machine to retransmit configuration-request and terminate-request packets. The default restart time is three seconds.
  Parameters:
    `timeout` - restart time in seconds
  Throws:
    PPPException - Maximum time exceeded, Minimum time exceeded

### getRestartPeriod

    public int getRestartPeriod()

  Gets the timeout period.
  Returns:
    timeout period in seconds
  See Also:
    `setRestartPeriod()`

### setMaxConfig

    public void setMaxConfig(int count)
                      throws PPPException

  Sets the maximum number of unanswered configuration requests that will be sent (1 - 20). The default value is ten.
  Parameters:
    `count` - the maximum number of configuration retries
  Throws:
    PPPException - Invalid maximum/minimum retry count

### getMaxConfig

    public int getMaxConfig()

  Gets the maximum number of configuration retries allowed.
  Returns:
    maximum retries
  See Also:
    `setMaxConfig()`

### setMaxTerminate

    public void setMaxTerminate(int count)
                         throws PPPException

  Sets the maximum number of termination requests that will be sent (1 - 20). The default value is two.
  Parameters:
    `count` - the maximum number of termination retries
  Throws:
    PPPException - Maximum count exceeded

### getMaxTerminate

    public int getMaxTerminate()

  Gets the maximum number of termination retries allowed.
  Returns:
    maximum retries
  See Also:
    `setMaxTerminate()`

### setMaxFailure

    public void setMaxFailure(int count)
                       throws PPPException

  Sets the maximum number of configuration failures allowed (1 - 20). The default value is five.
  Parameters:
    `count` - the maximum number of failures allowed
  Throws:
    PPPException - Maximum count exceeded

### getMaxFailure

    public int getMaxFailure()

  Gets the maximum number of configuration failures allowed.
  Returns:
    maximum failures
  See Also:
    `setMaxFailure()`

### setXonXoffEscape

    public void setXonXoffEscape(boolean value)

  Sets XON/XOFF flows control character escaping. Default operation is not to escape XON/XOFF characters.
  Parameters:
    `value` - `true` for XON/XOFF character escaping

### getXonXoffEscape

    public boolean getXonXoffEscape()

  Gets the current mode of XON/XOFF escaping.
  Returns:
    escaping mode

### addEventListener

    public void addEventListener(PPPEventListener eventListener)
                          throws TooManyListenersException

  Adds a PPP event listener.
  Parameters:
    `eventListener` - PPPEventListener object
  Throws:
    TooManyListenersException -

### removeEventListener

    public void removeEventListener(PPPEventListener eventListener)

  Removes a PPP event listener.
  Parameters:
    `eventListener` - PPPEventListener object

### run

    public final void run()

  Implements PPP deamon thread which propagates pppEvents to event listeners. Overrides java.lang.Thread.run method.
  Overrides:
    run in class Thread

### up

    public void up(javax.comm.SerialPort sp)

  Invoked when serial channel is ready for PPP traffic.
  Parameters:
    `sp` - SerialPort object

### down

    public void down()

  Invoked when serial channel is no longer available for PPP traffic.

### open

    public void open()

  Invoked to open PPP.

### close

    public void close()

  Invoked to close PPP.

### getUsernamePassword

    public int getUsernamePassword(int option,
                                   byte[] value)

  Deprecated. Gets remote peers username/password. Used during authentication phase to retreive remote peers ID and password. Invoking this method with value as null returns length of option.

  Parameters:
    `option` - indicates which value to retreive, PEER_ID or PEER_PASSWORD
    `value` - receives option value
  Returns:
    length of username/password
  See Also:
    `getPeerID()`, `getPeerPassword()`

### authenticate

    public void authenticate(boolean value)

  Indicates if access should be granted to remote peer.
  Parameters:
    `value` - True to allows access, False to deny accesss

### addInterface

    public void addInterface(String name)

  Adds a PPP interface to the network interface table.
  Parameters:
    `name` - interface name

### removeInterface

    public void removeInterface(String name)

  Removes the named PPP interface from the network interface table.
  Parameters:
    `name` - interface name

### freeInterfaceWrapper

    public void freeInterfaceWrapper()

  Frees native PPP interface. If an application exits or is killed the interface will freed automatically. If ana application does not exit but removes all references to a PPP object the native interface will not be freed. This method allow an application to fre the native interface cleanly.

### getPeerID

    public String getPeerID()

  Gets the remote peers authentication ID.
  Returns:
    remote peers authentication ID

### getPeerPassword

    public String getPeerPassword()

  Gets the remote peers authentication password.
  Returns:
    remote peers authentication password

### stopPPPThread

    public void stopPPPThread()

  Terminates internal PPP event notification thread. The PPP event notification thread is marked as a daemon thread and is destroyed on application exit. If an application does not exit but removes all references to a PPP object the event thread will not terminate. This method allows an application to destroy the daemon thread prior to releasing the PPP object.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD