/** * Create an {@link IpNetwork} instance which represents the IP address * specified by the given {@link IpAddress} instance. * * @param ip An {@link IpAddress} instance which represents the IP * address. * @return An {@link IpNetwork} instance which represents the given * IP address. Note that {@code null} is returned if {@code ip} * is {@code null} or it does not contain valid value. * @throws IllegalArgumentException * The given {@link IpAddress} instance is invalid. * @since Beryllium */ public static final IpNetwork create(IpAddress ip) { if (ip != null) { Ip4Network ip4 = Ip4Network.create(ip.getIpv4Address()); if (ip4 != null) { return ip4; } if (ip.getIpv6Address() != null) { throw getUnsupportedAddressException(ip); } } return null; }
/** * Send a packet for probing the specified host. * * @param ident The identifier for the target vBridge. * @param outq An {@link PacketOutQueue} instance associated with the * current MD-SAL datastore transaction. * @param egress A {@link SalPort} instance that specifies the egress * switch port. * @param vid A VLAN ID to be set in an ARP request. * @param tha The target hardware address. * @param tpa The target protocol address. */ private void probe(BridgeIdentifier<Vbridge> ident, PacketOutQueue outq, SalPort egress, int vid, EtherAddress tha, IpAddress tpa) { if (tpa != null) { Ip4Network ip4 = Ip4Network.create(tpa.getIpv4Address()); if (ip4 != null) { // Send an ARP request. if (LOG.isTraceEnabled()) { LOG.trace("{}: Sending an ARP request: mac={}, ip={}, " + "vid={}, port={}", ident, tha.getText(), ip4.getText(), vid, egress); } Ethernet ether = new ArpPacketBuilder(vid). build(senderAddress, tha, ip4); outq.enqueue(egress, ether); } } }