|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.teleal.cling.transport.impl.NetworkAddressFactoryImpl
public class NetworkAddressFactoryImpl
Default implementation of network interface and address configuration/discovery.
Field Summary | |
---|---|
protected List<InetAddress> |
bindAddresses
|
static int |
DEFAULT_TCP_HTTP_LISTEN_PORT
|
protected List<NetworkInterface> |
networkInterfaces
|
protected int |
streamListenPort
|
protected Set<String> |
useAddresses
|
protected Set<String> |
useInterfaces
|
Fields inherited from interface org.teleal.cling.transport.spi.NetworkAddressFactory |
---|
SYSTEM_PROPERTY_NET_ADDRESSES, SYSTEM_PROPERTY_NET_IFACES |
Constructor Summary | |
---|---|
NetworkAddressFactoryImpl()
Defaults to an ephemeral port. |
|
NetworkAddressFactoryImpl(int streamListenPort)
|
Method Summary | |
---|---|
protected void |
discoverBindAddresses()
|
protected void |
discoverNetworkInterfaces()
|
InetAddress[] |
getBindAddresses()
|
protected InetAddress |
getBindAddressInSubnetOf(InetAddress inetAddress)
|
InetAddress |
getBroadcastAddress(InetAddress inetAddress)
|
byte[] |
getHardwareAddress(InetAddress inetAddress)
|
protected List<InetAddress> |
getInetAddresses(NetworkInterface networkInterface)
|
protected List<InterfaceAddress> |
getInterfaceAddresses(NetworkInterface networkInterface)
|
InetAddress |
getLocalAddress(NetworkInterface networkInterface,
boolean isIPv6,
InetAddress remoteAddress)
Best-effort attempt finding a reachable local address for a given remote host. |
InetAddress |
getMulticastGroup()
|
int |
getMulticastPort()
|
NetworkInterface[] |
getNetworkInterfaces()
|
int |
getStreamListenPort()
|
protected boolean |
isInSubnet(byte[] ip,
byte[] network,
short prefix)
|
protected boolean |
isUsableAddress(NetworkInterface networkInterface,
InetAddress address)
Validation of every discovered local address. |
protected boolean |
isUsableNetworkInterface(NetworkInterface iface)
Validation of every discovered network interface. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_TCP_HTTP_LISTEN_PORT
protected Set<String> useInterfaces
protected Set<String> useAddresses
protected List<NetworkInterface> networkInterfaces
protected List<InetAddress> bindAddresses
protected int streamListenPort
Constructor Detail |
---|
public NetworkAddressFactoryImpl() throws InitializationException
InitializationException
public NetworkAddressFactoryImpl(int streamListenPort) throws InitializationException
InitializationException
Method Detail |
---|
public InetAddress getMulticastGroup()
getMulticastGroup
in interface NetworkAddressFactory
public int getMulticastPort()
getMulticastPort
in interface NetworkAddressFactory
public int getStreamListenPort()
getStreamListenPort
in interface NetworkAddressFactory
public NetworkInterface[] getNetworkInterfaces()
getNetworkInterfaces
in interface NetworkAddressFactory
public InetAddress[] getBindAddresses()
getBindAddresses
in interface NetworkAddressFactory
public byte[] getHardwareAddress(InetAddress inetAddress)
getHardwareAddress
in interface NetworkAddressFactory
inetAddress
- An address of a local network interface.
null
if no
hardware address could be obtained.public InetAddress getBroadcastAddress(InetAddress inetAddress)
getBroadcastAddress
in interface NetworkAddressFactory
inetAddress
- An address of a local network interface.
null
if no
broadcast address could be obtained.public InetAddress getLocalAddress(NetworkInterface networkInterface, boolean isIPv6, InetAddress remoteAddress)
NetworkAddressFactory
This method is called whenever a multicast datagram has been received. We need to be able to communicate with the sender using UDP unicast and we need to tell the sender how we are reachable with TCP requests. We need a local address that is in the same subnet as the senders address, that is reachable from the senders point of view.
getLocalAddress
in interface NetworkAddressFactory
networkInterface
- The network interface to examine.isIPv6
- True if the given remote address is an IPv6 address.remoteAddress
- The remote address for which to find a local address in the same subnet.
protected List<InterfaceAddress> getInterfaceAddresses(NetworkInterface networkInterface)
protected List<InetAddress> getInetAddresses(NetworkInterface networkInterface)
protected InetAddress getBindAddressInSubnetOf(InetAddress inetAddress)
protected boolean isInSubnet(byte[] ip, byte[] network, short prefix)
protected void discoverNetworkInterfaces() throws InitializationException
InitializationException
protected boolean isUsableNetworkInterface(NetworkInterface iface) throws Exception
Override this method to customize which network interfaces are used.
The given implementation ignores interfaces which are
iface
- The interface to validate.
Exception
- If any validation test failed with an un-recoverable error.protected void discoverBindAddresses() throws InitializationException
InitializationException
protected boolean isUsableAddress(NetworkInterface networkInterface, InetAddress address)
Override this method to customize which network addresses are used.
The given implementation ignores addresses which are
networkInterface
- The interface to validate.address
- The address of this interface to validate.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |