|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.aelitis.net.natpmp.impl.NatPMPDeviceImpl
public class NatPMPDeviceImpl
Main class
| Method Summary | |
|---|---|
int |
addPortMapping(boolean tcp,
int publicPort,
int privatePort)
Asks for a public port to be mapped to a private port from this host. |
java.lang.String |
byteArrayString(byte[] buf)
|
protected void |
checkRouterAddress()
|
boolean |
connect()
Try to connect with a NAT-PMP device. |
void |
deletePortMapping(boolean tcp,
int publicPort,
int privatePort)
Delete a mapped public port |
int |
getEpoch()
|
java.lang.String |
getExternalIPAddress()
|
java.net.InetAddress |
getLocalAddress()
|
java.net.NetworkInterface |
getNetworkInterface()
|
static NatPMPDeviceImpl |
getSingletonObject(NATPMPDeviceAdapter adapter)
|
java.lang.String |
intArrayString(int[] buf)
|
byte[] |
intToByteArray(int v)
Convert a 32-bit int into a 4 byte array |
protected void |
log(java.lang.String str)
|
int |
portMappingProtocol(boolean tcp,
int publicPort,
int privatePort,
int lifetime)
General port mapping protocol |
java.net.DatagramPacket |
sendNATMsg(java.net.InetAddress dstInet,
java.net.DatagramPacket dstPkt,
byte[] recBuf)
Send a request and wait for reply This class should be threaded!!! This sends to the default NATPMP_PORT. |
byte[] |
shortToByteArray(short v)
Convert a 16-bit short into a 2 byte array |
static int |
unsigned16ByteArrayToInt(byte[] b,
int offset)
Convert the byte array containing 16-bits to an int starting from the given offset. |
static int |
unsigned32ByteArrayToInt(byte[] b,
int offset)
Convert the byte array containing 32-bit to an int starting from the given offset. |
static int |
unsigned8ByteArrayToInt(byte[] b,
int offset)
Convert the byte array containing 8-bits to an int starting from the given offset. |
short |
unsignedByteArrayToShort(byte[] buf)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static NatPMPDeviceImpl getSingletonObject(NATPMPDeviceAdapter adapter)
throws java.lang.Exception
java.lang.Exception
protected void checkRouterAddress()
throws java.lang.Exception
java.lang.Exception
public java.net.DatagramPacket sendNATMsg(java.net.InetAddress dstInet,
java.net.DatagramPacket dstPkt,
byte[] recBuf)
throws java.lang.Exception
dstInet - destination address (should be the private NAT address)dstPkt - packet to sendrecBuf - byte buffer big enough to hold received
java.lang.Exception
public boolean connect()
throws java.lang.Exception
connect in interface NatPMPDevicejava.lang.Exception
public int addPortMapping(boolean tcp,
int publicPort,
int privatePort)
throws java.lang.Exception
addPortMapping in interface NatPMPDevicetcp - true TCP, false UDP
java.lang.Exception
public void deletePortMapping(boolean tcp,
int publicPort,
int privatePort)
throws java.lang.Exception
deletePortMapping in interface NatPMPDevicetcp - true TCP, false UDP portpublicPort - the public port to closeprivatePort - the private port that it is mapped to
java.lang.Exception
public int portMappingProtocol(boolean tcp,
int publicPort,
int privatePort,
int lifetime)
throws java.lang.Exception
java.lang.Exceptionpublic java.net.InetAddress getLocalAddress()
getLocalAddress in interface NatPMPDevicepublic java.net.NetworkInterface getNetworkInterface()
getNetworkInterface in interface NatPMPDevicepublic java.lang.String getExternalIPAddress()
getExternalIPAddress in interface NatPMPDevicepublic int getEpoch()
getEpoch in interface NatPMPDeviceprotected void log(java.lang.String str)
public static int unsigned32ByteArrayToInt(byte[] b,
int offset)
b - The byte arrayoffset - The array offset
public static int unsigned16ByteArrayToInt(byte[] b,
int offset)
b - The byte arrayoffset - The array offset
public static int unsigned8ByteArrayToInt(byte[] b,
int offset)
b - The byte arrayoffset - The array offset
public short unsignedByteArrayToShort(byte[] buf)
public byte[] shortToByteArray(short v)
public byte[] intToByteArray(int v)
public java.lang.String intArrayString(int[] buf)
public java.lang.String byteArrayString(byte[] buf)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||