org.fourthline.cling.transport.spi
Interface NetworkAddressFactory

All Known Implementing Classes:
AndroidNetworkAddressFactory, NetworkAddressFactoryImpl

public interface NetworkAddressFactory

Configuration utility for network interfaces and addresses.

An implementation has to be thread-safe.

Author:
Christian Bauer

Field Summary
static String SYSTEM_PROPERTY_NET_ADDRESSES
           
static String SYSTEM_PROPERTY_NET_IFACES
           
 
Method Summary
 Short getAddressNetworkPrefixLength(InetAddress inetAddress)
           
 Iterator<InetAddress> getBindAddresses()
          The caller might remove() an address if initialization fails.
 InetAddress getBroadcastAddress(InetAddress inetAddress)
           
 byte[] getHardwareAddress(InetAddress inetAddress)
           
 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()
           
 Iterator<NetworkInterface> getNetworkInterfaces()
          The caller might remove() an interface if initialization fails.
 int getStreamListenPort()
           
 boolean hasUsableNetwork()
           
 void logInterfaceInformation()
          For debugging, logs all "usable" network interface(s) details with INFO level.
 

Field Detail

SYSTEM_PROPERTY_NET_IFACES

static final String SYSTEM_PROPERTY_NET_IFACES
See Also:
Constant Field Values

SYSTEM_PROPERTY_NET_ADDRESSES

static final String SYSTEM_PROPERTY_NET_ADDRESSES
See Also:
Constant Field Values
Method Detail

getMulticastGroup

InetAddress getMulticastGroup()
Returns:
The UDP multicast group to join.

getMulticastPort

int getMulticastPort()
Returns:
The UDP multicast port to listen on.

getStreamListenPort

int getStreamListenPort()
Returns:
The TCP (HTTP) stream request port to listen on.

getNetworkInterfaces

Iterator<NetworkInterface> getNetworkInterfaces()
The caller might remove() an interface if initialization fails.

Returns:
The local network interfaces on which multicast groups will be joined.

getBindAddresses

Iterator<InetAddress> getBindAddresses()
The caller might remove() an address if initialization fails.

Returns:
The local addresses of the network interfaces bound to sockets listening for unicast datagrams and TCP requests.

hasUsableNetwork

boolean hasUsableNetwork()
Returns:
true if there is at least one usable network interface and bind address.

getAddressNetworkPrefixLength

Short getAddressNetworkPrefixLength(InetAddress inetAddress)
Returns:
The network prefix length of this address or null.

getHardwareAddress

byte[] getHardwareAddress(InetAddress inetAddress)
Parameters:
inetAddress - An address of a local network interface.
Returns:
The MAC hardware address of the network interface or null if no hardware address could be obtained.

getBroadcastAddress

InetAddress getBroadcastAddress(InetAddress inetAddress)
Parameters:
inetAddress - An address of a local network interface.
Returns:
The broadcast address of the network (interface) or null if no broadcast address could be obtained.

getLocalAddress

InetAddress getLocalAddress(NetworkInterface networkInterface,
                            boolean isIPv6,
                            InetAddress remoteAddress)
                            throws IllegalStateException
Best-effort attempt finding a reachable local address for a given remote host.

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.

Parameters:
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.
Returns:
A local address that is reachable from the given remote address.
Throws:
IllegalStateException - If no local address reachable by the remote address has been found.

logInterfaceInformation

void logInterfaceInformation()
For debugging, logs all "usable" network interface(s) details with INFO level.



Copyright © 2013 4th Line GmbH, Switzerland. All Rights Reserved.