@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!this.getClass().isInstance(obj)) { return false; } IllegalIpV6NeighborDiscoveryOption other = (IllegalIpV6NeighborDiscoveryOption) obj; return type.equals(other.type) && Arrays.equals(other.rawData, rawData); }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!this.getClass().isInstance(obj)) { return false; } UnknownIpV6NeighborDiscoveryOption other = (UnknownIpV6NeighborDiscoveryOption) obj; return type.equals(other.type) && length == other.length && Arrays.equals(data, other.data); }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!this.getClass().isInstance(obj)) { return false; } IllegalIpV6NeighborDiscoveryOption other = (IllegalIpV6NeighborDiscoveryOption) obj; return type.equals(other.type) && Arrays.equals(other.rawData, rawData); }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!this.getClass().isInstance(obj)) { return false; } UnknownIpV6NeighborDiscoveryOption other = (UnknownIpV6NeighborDiscoveryOption) obj; return type.equals(other.type) && length == other.length && Arrays.equals(data, other.data); }
private static void cacheByNa(Packet packet, NdpCache ndpCache) { IcmpV6NeighborAdvertisementPacket naPacket = packet.get(IcmpV6NeighborAdvertisementPacket.class); InetAddress ipAddr = naPacket.getHeader().getTargetAddress(); MacAddress macAddr = null; for (IpV6NeighborDiscoveryOption opt: naPacket.getHeader().getOptions()) { if (opt.getType().equals(IpV6NeighborDiscoveryOptionType.TARGET_LINK_LAYER_ADDRESS)) { macAddr = ((IpV6NeighborDiscoveryTargetLinkLayerAddressOption)opt).getLinkLayerAddressAsMacAddress(); } } if (macAddr == null) { return; } // According to RFC 2461, If no entry exists, the advertisement SHOULD be silently discarded. // But cache it here with no check for entry existance. NeighborDiscoveryHelper.cache(ndpCache, ipAddr, macAddr); }
private static void cacheByNs(Packet packet, NdpCache ndpCache) { IpV6Packet ipv6Packet = packet.get(IpV6Packet.class); if (ipv6Packet == null) { return; } Inet6Address srcAddr = ipv6Packet.getHeader().getSrcAddr(); if (srcAddr.equals(IpV6Helper.UNSPECIFIED_ADDRESS)) { return; } IcmpV6NeighborSolicitationPacket nsPacket = packet.get(IcmpV6NeighborSolicitationPacket.class); IpV6NeighborDiscoverySourceLinkLayerAddressOption srcLinkOpt = null; for (IpV6NeighborDiscoveryOption opt: nsPacket.getHeader().getOptions()) { if (opt.getType().equals(IpV6NeighborDiscoveryOptionType.SOURCE_LINK_LAYER_ADDRESS)) { srcLinkOpt = (IpV6NeighborDiscoverySourceLinkLayerAddressOption)opt; break; } } if (srcLinkOpt == null) { return; } // if new, isRouter flag of Neighbor Cache is false. // if update, isRouter is not changed. NeighborDiscoveryHelper.cache(ndpCache, srcAddr, srcLinkOpt.getLinkLayerAddressAsMacAddress()); }