FileDocCategorySizeDatePackage
GenericIPMreq.javaAPI DocAndroid 1.5 API3765Wed May 06 22:41:04 BST 2009org.apache.harmony.luni.net

GenericIPMreq

public final class GenericIPMreq extends Object
This class provides is used to pass the information required in an ip_mreq or ip6_mreq structure to java natives. We don't have accessor methods as it is more straight forward in the natives to simply access the fields directly

Fields Summary
private InetAddress
multiaddr
private InetAddress
interfaceAddr
private boolean
isIPV6Address
private int
interfaceIdx
Constructors Summary
GenericIPMreq(InetAddress addr)
This constructor is used to create an instance of the object

param
addr multicast address to join/leave

        multiaddr = addr;
        interfaceAddr = null;
        interfaceIdx = 0;
        init();
    
GenericIPMreq(InetAddress addr, NetworkInterface netInterface)
This constructor is used to create an instance of the object

param
addr multicast address to join/leave
param
netInterface the NetworkInterface object identifying the interface on which to join/leave

        multiaddr = addr;
        if (null != netInterface) {
            // TODO  check if necessary
            //interfaceIdx = netInterface.getIndex();

            /*
             * here we need to get the first IPV4 address as we only use it if
             * we are setting the interface for an IPV4 multicast socket. For
             * adds/drops on IPV6 addresses we use the index within the
             * networkInterface
             */
            interfaceAddr = null;
            Enumeration<InetAddress> theAddresses = netInterface.getInetAddresses();
            if ((addr instanceof Inet4Address) && (theAddresses != null)) {
                boolean found = false;
                while ((theAddresses.hasMoreElements()) && (found != true)) {
                    InetAddress theAddress = theAddresses.nextElement();
                    if (theAddress instanceof Inet4Address) {
                        interfaceAddr = theAddress;
                        found = true;
                    }
                }
            }
        } else {
            /*
             * network interface is null so we just want to defer the decision
             * to the system
             */
            interfaceIdx = 0;
            interfaceAddr = null;
        }
        init();
    
Methods Summary
private voidinit()
This method does any required initialization for the constructors

        /*
         * set the flag indicating if the multicast address is an IPV6 address
         * or not
         */
        isIPV6Address = ((multiaddr != null) && (multiaddr instanceof Inet6Address));