|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.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. |
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()
|
String |
getExternalIPAddress()
|
InetAddress |
getLocalAddress()
|
NetworkInterface |
getNetworkInterface()
|
static NatPMPDeviceImpl |
getSingletonObject(NATPMPDeviceAdapter adapter)
|
String |
intArrayString(int[] buf)
|
byte[] |
intToByteArray(int v)
Convert a 32-bit int into a 4 byte array |
protected void |
log(String str)
|
int |
portMappingProtocol(boolean tcp,
int publicPort,
int privatePort,
int lifetime)
General port mapping protocol |
DatagramPacket |
sendNATMsg(InetAddress dstInet,
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 Exception
Exception
protected void checkRouterAddress() throws Exception
Exception
public DatagramPacket sendNATMsg(InetAddress dstInet, DatagramPacket dstPkt, byte[] recBuf) throws Exception
dstInet
- destination address (should be the private NAT address)dstPkt
- packet to sendrecBuf
- byte buffer big enough to hold received
Exception
public boolean connect() throws Exception
connect
in interface NatPMPDevice
Exception
public int addPortMapping(boolean tcp, int publicPort, int privatePort) throws Exception
addPortMapping
in interface NatPMPDevice
tcp
- true TCP, false UDP
Exception
public void deletePortMapping(boolean tcp, int publicPort, int privatePort) throws Exception
deletePortMapping
in interface NatPMPDevice
tcp
- true TCP, false UDP portpublicPort
- the public port to closeprivatePort
- the private port that it is mapped to
Exception
public int portMappingProtocol(boolean tcp, int publicPort, int privatePort, int lifetime) throws Exception
Exception
public InetAddress getLocalAddress()
getLocalAddress
in interface NatPMPDevice
public NetworkInterface getNetworkInterface()
getNetworkInterface
in interface NatPMPDevice
public String getExternalIPAddress()
getExternalIPAddress
in interface NatPMPDevice
public int getEpoch()
getEpoch
in interface NatPMPDevice
protected void log(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 String intArrayString(int[] buf)
public String byteArrayString(byte[] buf)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |