com.dalsemi.tininet.ppp
Class PPP

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

public class PPP
extends java.lang.Thread
implements QueueEventListener

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.


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(java.lang.String name)
          Adds a PPP interface to the network interface table.
 void addInterface(java.lang.String name, int mss, int timeout)
          Adds a PPP interface to the network interface table.
 void close()
          Invoked to close PPP.
 void finish()
          Kill the PPP thread and inetrrupt timer thread
 void freeNativeInterface()
          Free the native interface used by this PPP instance
 void freePort()
          Free the serial port for use by Java
 byte[] getLocalAddress()
          Gets the local peers address.
 java.lang.String getPrimaryDNS()
          Gets the primary DNS address.
 byte[] getRemoteAddress()
          Gets the remote peers address.
 java.lang.String getSecondaryDNS()
          Gets the secondary DNS address.
 void open()
          Invoked to open PPP.
 void QueueEvent(ProtocolEvent ev)
          Queue event listener interface.
 void removeEventListener(PPPEventListener eventListener)
          Removes a PPP event listener.
 void removeInterface(java.lang.String name)
          Removes the named PPP interface from the network interface table.
 void run()
          Thread run method
 void setAuthenticate(boolean authenticate, boolean strong)
          Sets the remote peer authentication option.
 void setDefaultInterface(boolean value)
          Set new PPP netwrok interface to default interface.
 void setLocalAccm(long accm)
          The local ACCM will be the logical OR of this value ans the ACCM received from the remote peer.
 void setLocalAddress(byte[] localAddr)
          Sets the local IP address for this interface.
 void setPassive(boolean val)
          Sets passive mode option.
 void setPassword(java.lang.String password)
          Sets the password sent to a remote peer during authentication.
 void setRemoteAccm(long accm)
          Sets the value of the Asynchronous Control Character Map (ACCM).
 void setRemoteAddress(byte[] remoteAddr)
          Sets the IP address of the remote peer.
 void setUsername(java.lang.String userName)
          Sets the user name sent to a remote peer during authentication.
 void up(PPPDevice pppDevice)
          Invoked when serial channel is ready for PPP traffic.
 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, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, 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
 

Constructor Detail

PPP

public PPP()
Default constructor
Method Detail

addEventListener

public void addEventListener(PPPEventListener eventListener)
                      throws java.util.TooManyListenersException
Adds a PPP event listener.
Parameters:
eventListener - PPPEventListener object
Throws:
java.util.TooManyListenersException -  

removeEventListener

public void removeEventListener(PPPEventListener eventListener)
Removes a PPP event listener.
Parameters:
eventListener - PPPEventListener object

up

public void up(javax.comm.SerialPort sp)
Invoked when serial channel is ready for PPP traffic.
Parameters:
sp - SerialPort object

up

public void up(PPPDevice pppDevice)
Invoked when serial channel is ready for PPP traffic.
Parameters:
pppDevice - PPPDevice object

close

public void close()
Invoked to close PPP.

open

public void open()
Invoked to open PPP.

run

public void run()
Thread run method
Overrides:
run in class java.lang.Thread

QueueEvent

public void QueueEvent(ProtocolEvent ev)
Queue event listener interface.
Specified by:
QueueEvent in interface QueueEventListener
Parameters:
ev - event

setPassive

public void setPassive(boolean val)
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:
val - true for passive mode operation

setLocalAccm

public void setLocalAccm(long accm)
The local ACCM will be the logical OR of this value ans the ACCM received from the remote peer.
Parameters:
accm - local ACCM
See Also:
setRemoteAccm()

setRemoteAccm

public void setRemoteAccm(long accm)
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:
accm - Asynchronous Control Character Map (ACCM)

setUsername

public void setUsername(java.lang.String userName)
Sets the user name sent to a remote peer during authentication.
Parameters:
userName - user name

setPassword

public void setPassword(java.lang.String password)
Sets the password sent to a remote peer during authentication.
Parameters:
password - user password

setLocalAddress

public void setLocalAddress(byte[] localAddr)
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:
localAddr - local IP address, index 0 is MSB of four byte network address

setRemoteAddress

public void setRemoteAddress(byte[] remoteAddr)
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:
remoteAddr - remote IP address, index 0 is MSB of four byte network address

setAuthenticate

public void setAuthenticate(boolean authenticate,
                            boolean strong)
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:
authenticate - true if remote peer authentication is required
strong - true if CHAP authentication is required

addInterface

public void addInterface(java.lang.String name)
Adds a PPP interface to the network interface table. The MSS and timeout are set to default value of 256 and 128
Parameters:
name - interface name

addInterface

public void addInterface(java.lang.String name,
                         int mss,
                         int timeout)
Adds a PPP interface to the network interface table.
Parameters:
name - interface name
mss - maximum TCP segment size sent
timeout - initial TCP timeout

removeInterface

public void removeInterface(java.lang.String name)
Removes the named PPP interface from the network interface table.
Parameters:
name - interface name

freePort

public void freePort()
Free the serial port for use by Java

freeNativeInterface

public void freeNativeInterface()
Free the native interface used by this PPP instance

finish

public void finish()
Kill the PPP thread and inetrrupt timer thread

getLocalAddress

public byte[] getLocalAddress()
Gets the local peers address. Return value undefined if connection is not active.
Returns:
Local peers address

getRemoteAddress

public byte[] getRemoteAddress()
Gets the remote peers address. Return value undefined if connection is not active.
Returns:
Remote peers address

getPrimaryDNS

public java.lang.String getPrimaryDNS()
Gets the primary DNS address. Return value undefined if connection is not active.
Returns:
Primary DNS address

getSecondaryDNS

public java.lang.String getSecondaryDNS()
Gets the secondary DNS address. Return value undefined if connection is not active.
Returns:
Secondary DNS address

setDefaultInterface

public void setDefaultInterface(boolean value)
Set new PPP netwrok interface to default interface.
Parameters:
value - true for default interface


Also see:
o TINI 1.16 API
o TINI Home Page
o 1-Wire API

o JDK 1.1

Last update Wed Jun 8 17:19:36 CDT 2005