summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp')
-rw-r--r--framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/NeighborAdvertisement.java278
-rw-r--r--framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/NeighborDiscoveryOptions.java281
-rw-r--r--framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/NeighborSolicitation.java192
-rw-r--r--framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/Redirect.java225
-rw-r--r--framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/RouterAdvertisement.java325
-rw-r--r--framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/RouterSolicitation.java155
-rw-r--r--framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/package-info.java21
7 files changed, 0 insertions, 1477 deletions
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/NeighborAdvertisement.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/NeighborAdvertisement.java
deleted file mode 100644
index 99fa0dd6..00000000
--- a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/NeighborAdvertisement.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onlab.packet.ndp;
-
-import org.onlab.packet.BasePacket;
-import org.onlab.packet.Deserializer;
-import org.onlab.packet.IPacket;
-import org.onlab.packet.Ip6Address;
-
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.onlab.packet.PacketUtils.checkInput;
-
-/**
- * Implements ICMPv6 Neighbor Advertisement packet format (RFC 4861).
- */
-public class NeighborAdvertisement extends BasePacket {
- public static final byte HEADER_LENGTH = 20; // bytes
-
- protected byte routerFlag;
- protected byte solicitedFlag;
- protected byte overrideFlag;
- protected byte[] targetAddress = new byte[Ip6Address.BYTE_LENGTH];
-
- private final NeighborDiscoveryOptions options =
- new NeighborDiscoveryOptions();
-
- /**
- * Gets router flag.
- *
- * @return the router flag
- */
- public byte getRouterFlag() {
- return this.routerFlag;
- }
-
- /**
- * Sets router flag.
- *
- * @param routerFlag the router flag to set
- * @return this
- */
- public NeighborAdvertisement setRouterFlag(final byte routerFlag) {
- this.routerFlag = routerFlag;
- return this;
- }
-
- /**
- * Gets solicited flag.
- *
- * @return the solicited flag
- */
- public byte getSolicitedFlag() {
- return this.solicitedFlag;
- }
-
- /**
- * Sets solicited flag.
- *
- * @param solicitedFlag the solicited flag to set
- * @return this
- */
- public NeighborAdvertisement setSolicitedFlag(final byte solicitedFlag) {
- this.solicitedFlag = solicitedFlag;
- return this;
- }
-
- /**
- * Gets override flag.
- *
- * @return the override flag
- */
- public byte getOverrideFlag() {
- return this.overrideFlag;
- }
-
- /**
- * Sets override flag.
- *
- * @param overrideFlag the override flag to set
- * @return this
- */
- public NeighborAdvertisement setOverrideFlag(final byte overrideFlag) {
- this.overrideFlag = overrideFlag;
- return this;
- }
-
- /**
- * Gets target address.
- *
- * @return the target IPv6 address
- */
- public byte[] getTargetAddress() {
- return this.targetAddress;
- }
-
- /**
- * Sets target address.
- *
- * @param targetAddress the target IPv6 address to set
- * @return this
- */
- public NeighborAdvertisement setTargetAddress(final byte[] targetAddress) {
- this.targetAddress =
- Arrays.copyOfRange(targetAddress, 0, Ip6Address.BYTE_LENGTH);
- return this;
- }
-
- /**
- * Gets the Neighbor Discovery Protocol packet options.
- *
- * @return the Neighbor Discovery Protocol packet options
- */
- public List<NeighborDiscoveryOptions.Option> getOptions() {
- return this.options.options();
- }
-
- /**
- * Adds a Neighbor Discovery Protocol packet option.
- *
- * @param type the option type
- * @param data the option data
- * @return this
- */
- public NeighborAdvertisement addOption(final byte type,
- final byte[] data) {
- this.options.addOption(type, data);
- return this;
- }
-
- @Override
- public byte[] serialize() {
- byte[] optionsData = null;
- if (this.options.hasOptions()) {
- optionsData = this.options.serialize();
- }
-
- int optionsLength = 0;
- if (optionsData != null) {
- optionsLength = optionsData.length;
- }
-
- final byte[] data = new byte[HEADER_LENGTH + optionsLength];
- final ByteBuffer bb = ByteBuffer.wrap(data);
-
- bb.putInt((this.routerFlag & 0x1) << 31 |
- (this.solicitedFlag & 0x1) << 30 |
- (this.overrideFlag & 0x1) << 29);
- bb.put(this.targetAddress, 0, Ip6Address.BYTE_LENGTH);
- if (optionsData != null) {
- bb.put(optionsData);
- }
-
- return data;
- }
-
- @Override
- public IPacket deserialize(byte[] data, int offset, int length) {
- final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
- int iscratch;
-
- iscratch = bb.getInt();
- this.routerFlag = (byte) (iscratch >> 31 & 0x1);
- this.solicitedFlag = (byte) (iscratch >> 30 & 0x1);
- this.overrideFlag = (byte) (iscratch >> 29 & 0x1);
- bb.get(this.targetAddress, 0, Ip6Address.BYTE_LENGTH);
-
- this.options.deserialize(data, bb.position(),
- bb.limit() - bb.position());
-
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 5807;
- int result = super.hashCode();
- ByteBuffer bb;
- result = prime * result + this.routerFlag;
- result = prime * result + this.solicitedFlag;
- result = prime * result + this.overrideFlag;
- bb = ByteBuffer.wrap(this.targetAddress);
- for (int i = 0; i < this.targetAddress.length / 4; i++) {
- result = prime * result + bb.getInt();
- }
- result = prime * result + this.options.hashCode();
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof NeighborAdvertisement)) {
- return false;
- }
- final NeighborAdvertisement other = (NeighborAdvertisement) obj;
- if (this.routerFlag != other.routerFlag) {
- return false;
- }
- if (this.solicitedFlag != other.solicitedFlag) {
- return false;
- }
- if (this.overrideFlag != other.overrideFlag) {
- return false;
- }
- if (!Arrays.equals(this.targetAddress, other.targetAddress)) {
- return false;
- }
- if (!this.options.equals(other.options)) {
- return false;
- }
- return true;
- }
-
- /**
- * Deserializer function for neighbor advertisement packets.
- *
- * @return deserializer function
- */
- public static Deserializer<NeighborAdvertisement> deserializer() {
- return (data, offset, length) -> {
- checkInput(data, offset, length, HEADER_LENGTH);
-
- NeighborAdvertisement neighborAdvertisement = new NeighborAdvertisement();
-
- ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
-
- int iscratch;
-
- iscratch = bb.getInt();
- neighborAdvertisement.routerFlag = (byte) (iscratch >> 31 & 0x1);
- neighborAdvertisement.solicitedFlag = (byte) (iscratch >> 30 & 0x1);
- neighborAdvertisement.overrideFlag = (byte) (iscratch >> 29 & 0x1);
- bb.get(neighborAdvertisement.targetAddress, 0, Ip6Address.BYTE_LENGTH);
-
- if (bb.limit() - bb.position() > 0) {
- NeighborDiscoveryOptions options = NeighborDiscoveryOptions.deserializer()
- .deserialize(data, bb.position(), bb.limit() - bb.position());
-
- for (NeighborDiscoveryOptions.Option option : options.options()) {
- neighborAdvertisement.addOption(option.type(), option.data());
- }
- }
-
- return neighborAdvertisement;
- };
- }
-}
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/NeighborDiscoveryOptions.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/NeighborDiscoveryOptions.java
deleted file mode 100644
index 00a26068..00000000
--- a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/NeighborDiscoveryOptions.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onlab.packet.ndp;
-
-import org.onlab.packet.BasePacket;
-import org.onlab.packet.DeserializationException;
-import org.onlab.packet.Deserializer;
-import org.onlab.packet.IPacket;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.onlab.packet.PacketUtils.checkInput;
-
-/**
- * Neighbor Discovery Protocol packet options.
- */
-public class NeighborDiscoveryOptions extends BasePacket {
- public static final byte TYPE_SOURCE_LL_ADDRESS = 1;
- public static final byte TYPE_TARGET_LL_ADDRESS = 2;
- public static final byte TYPE_PREFIX_INFORMATION = 3;
- public static final byte TYPE_REDIRECTED_HEADER = 4;
- public static final byte TYPE_MTU = 5;
-
- public static final byte INITIAL_HEADER_REQUIRED = 2;
-
- private static final String BUFFER_UNDERFLOW_ERROR =
- "Not enough bytes in buffer to read option";
-
- private final List<Option> options = new ArrayList<>();
-
- /**
- * Packet option.
- */
- public final class Option {
- private final byte type;
- private final byte[] data;
-
- /**
- * Constructor.
- *
- * @param type the option type
- * @param data the option data
- */
- private Option(byte type, byte[] data) {
- this.type = type;
- this.data = Arrays.copyOfRange(data, 0, data.length);
- }
-
- /**
- * Gets the option type.
- *
- * @return the option type
- */
- public byte type() {
- return this.type;
- }
-
- /**
- * Gets the option data.
- *
- * @return the option data
- */
- public byte[] data() {
- return this.data;
- }
-
- /**
- * Gets the option data length (in number of octets).
- *
- * @return the option data length (in number of octets)
- */
- public int dataLength() {
- return data.length;
- }
-
- /**
- * Gets the option length (in number of octets), including the type and
- * length fields (one octet each).
- *
- * @return the option length (in number of octets), including the type
- * and length fields
- */
- private int optionLength() {
- return 2 + dataLength();
- }
-
- /**
- * Gets the option length field value (in units of 8 octets).
- *
- * @return the option length field value (in units of 8 octets)
- */
- private byte optionLengthField() {
- return (byte) ((optionLength() + 7) / 8);
- }
-
- /**
- * Gets the option length on the wire (in number of octets).
- *
- * @return the option length on the wire (in number of octets)
- */
- private int optionWireLength() {
- return 8 * optionLengthField();
- }
- }
-
- /**
- * Adds a Neighbor Discovery Protocol packet option.
- *
- * @param type the option type
- * @param data the option data
- * @return this
- */
- public NeighborDiscoveryOptions addOption(byte type, byte[] data) {
- options.add(new Option(type, data));
- return this;
- }
-
- /**
- * Gets the Neighbor Discovery Protocol packet options.
- *
- * @return the Neighbor Discovery Protocol packet options
- */
- public List<NeighborDiscoveryOptions.Option> options() {
- return this.options;
- }
-
- /**
- * Checks whether any options are included.
- *
- * @return true if options are included, otherwise false
- */
- public boolean hasOptions() {
- return !this.options.isEmpty();
- }
-
- @Override
- public byte[] serialize() {
- // Compute first the total length on the wire for all options
-
- int wireLength = 0;
-
- for (Option option : this.options) {
- wireLength += option.optionWireLength();
- }
-
- final byte[] data = new byte[wireLength];
- final ByteBuffer bb = ByteBuffer.wrap(data);
-
- //
- // Serialize all options
- //
- for (Option option : this.options) {
- bb.put(option.type());
- bb.put(option.optionLengthField());
- bb.put(option.data());
- // Add the padding
- int paddingLength =
- option.optionWireLength() - option.optionLength();
- for (int i = 0; i < paddingLength; i++) {
- bb.put((byte) 0);
- }
- }
-
- return data;
- }
-
- @Override
- public IPacket deserialize(byte[] data, int offset, int length) {
- final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
-
- options.clear();
-
- //
- // Deserialize all options
- //
- while (bb.hasRemaining()) {
- byte type = bb.get();
- if (!bb.hasRemaining()) {
- break;
- }
- byte lengthField = bb.get();
- int dataLength = lengthField * 8; // The data length field is in
- // unit of 8 octets
-
- // Exclude the type and length fields
- if (dataLength < 2) {
- break;
- }
- dataLength -= 2;
-
- if (bb.remaining() < dataLength) {
- break;
- }
- byte[] optionData = new byte[dataLength];
- bb.get(optionData, 0, optionData.length);
- addOption(type, optionData);
- }
-
- return this;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
-
- for (Option option : this.options) {
- result = prime * result + option.type();
- result = prime * result + Arrays.hashCode(option.data());
- }
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof NeighborDiscoveryOptions) {
- NeighborDiscoveryOptions other = (NeighborDiscoveryOptions) obj;
- return this.options.equals(other.options);
- }
- return false;
- }
-
- public static Deserializer<NeighborDiscoveryOptions> deserializer() {
- return (data, offset, length) -> {
- checkInput(data, offset, length, INITIAL_HEADER_REQUIRED);
-
- final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
-
- NeighborDiscoveryOptions ndo = new NeighborDiscoveryOptions();
-
- ndo.options.clear();
-
- //
- // Deserialize all options
- //
- while (bb.hasRemaining()) {
- byte type = bb.get();
- if (!bb.hasRemaining()) {
- throw new DeserializationException(BUFFER_UNDERFLOW_ERROR);
- }
- byte lengthField = bb.get();
- int dataLength = lengthField * 8; // The data length field is in
- // unit of 8 octets
-
- // Exclude the type and length fields
- if (dataLength < 2) {
- break;
- }
- dataLength -= 2;
-
- if (bb.remaining() < dataLength) {
- throw new DeserializationException(BUFFER_UNDERFLOW_ERROR);
- }
- byte[] optionData = new byte[dataLength];
- bb.get(optionData, 0, optionData.length);
- ndo.addOption(type, optionData);
- }
-
- return ndo;
- };
- }
-}
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/NeighborSolicitation.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/NeighborSolicitation.java
deleted file mode 100644
index 77c119a0..00000000
--- a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/NeighborSolicitation.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onlab.packet.ndp;
-
-import org.onlab.packet.BasePacket;
-import org.onlab.packet.Deserializer;
-import org.onlab.packet.IPacket;
-import org.onlab.packet.Ip6Address;
-
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.onlab.packet.PacketUtils.checkInput;
-
-/**
- * Implements ICMPv6 Neighbor Solicitation packet format. (RFC 4861)
- */
-public class NeighborSolicitation extends BasePacket {
- public static final byte HEADER_LENGTH = 20; // bytes
-
- protected byte[] targetAddress = new byte[Ip6Address.BYTE_LENGTH];
-
- private final NeighborDiscoveryOptions options =
- new NeighborDiscoveryOptions();
-
- /**
- * Gets target address.
- *
- * @return the target IPv6 address
- */
- public byte[] getTargetAddress() {
- return this.targetAddress;
- }
-
- /**
- * Sets target address.
- *
- * @param targetAddress the target IPv6 address to set
- * @return this
- */
- public NeighborSolicitation setTargetAddress(final byte[] targetAddress) {
- this.targetAddress =
- Arrays.copyOfRange(targetAddress, 0, Ip6Address.BYTE_LENGTH);
- return this;
- }
-
- /**
- * Gets the Neighbor Discovery Protocol packet options.
- *
- * @return the Neighbor Discovery Protocol packet options
- */
- public List<NeighborDiscoveryOptions.Option> getOptions() {
- return this.options.options();
- }
-
- /**
- * Adds a Neighbor Discovery Protocol packet option.
- *
- * @param type the option type
- * @param data the option data
- * @return this
- */
- public NeighborSolicitation addOption(final byte type,
- final byte[] data) {
- this.options.addOption(type, data);
- return this;
- }
-
- @Override
- public byte[] serialize() {
- byte[] optionsData = null;
- if (this.options.hasOptions()) {
- optionsData = this.options.serialize();
- }
-
- int optionsLength = 0;
- if (optionsData != null) {
- optionsLength = optionsData.length;
- }
-
- final byte[] data = new byte[HEADER_LENGTH + optionsLength];
- final ByteBuffer bb = ByteBuffer.wrap(data);
-
- bb.putInt(0);
- bb.put(this.targetAddress, 0, Ip6Address.BYTE_LENGTH);
- if (optionsData != null) {
- bb.put(optionsData);
- }
-
- return data;
- }
-
- @Override
- public IPacket deserialize(byte[] data, int offset, int length) {
- final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
-
- bb.getInt();
- bb.get(this.targetAddress, 0, Ip6Address.BYTE_LENGTH);
-
- this.options.deserialize(data, bb.position(),
- bb.limit() - bb.position());
-
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 5807;
- int result = super.hashCode();
- ByteBuffer bb;
- bb = ByteBuffer.wrap(this.targetAddress);
- for (int i = 0; i < this.targetAddress.length / 4; i++) {
- result = prime * result + bb.getInt();
- }
- result = prime * result + this.options.hashCode();
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof NeighborSolicitation)) {
- return false;
- }
- final NeighborSolicitation other = (NeighborSolicitation) obj;
- if (!Arrays.equals(this.targetAddress, other.targetAddress)) {
- return false;
- }
- if (!this.options.equals(other.options)) {
- return false;
- }
- return true;
- }
-
- /**
- * Deserializer function for neighbor solicitation packets.
- *
- * @return deserializer function
- */
- public static Deserializer<NeighborSolicitation> deserializer() {
- return (data, offset, length) -> {
- checkInput(data, offset, length, HEADER_LENGTH);
-
- NeighborSolicitation neighborSolicitation = new NeighborSolicitation();
-
- ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
-
- bb.getInt();
- bb.get(neighborSolicitation.targetAddress, 0, Ip6Address.BYTE_LENGTH);
-
- if (bb.limit() - bb.position() > 0) {
- NeighborDiscoveryOptions options = NeighborDiscoveryOptions.deserializer()
- .deserialize(data, bb.position(), bb.limit() - bb.position());
-
- for (NeighborDiscoveryOptions.Option option : options.options()) {
- neighborSolicitation.addOption(option.type(), option.data());
- }
- }
-
- return neighborSolicitation;
- };
- }
-}
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/Redirect.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/Redirect.java
deleted file mode 100644
index 51256d41..00000000
--- a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/Redirect.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onlab.packet.ndp;
-
-import org.onlab.packet.BasePacket;
-import org.onlab.packet.Deserializer;
-import org.onlab.packet.IPacket;
-import org.onlab.packet.Ip6Address;
-
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.onlab.packet.PacketUtils.checkInput;
-
-/**
- * Implements ICMPv6 Redirect packet format. (RFC 4861)
- */
-public class Redirect extends BasePacket {
- public static final byte HEADER_LENGTH = 36; // bytes
-
- protected byte[] targetAddress = new byte[Ip6Address.BYTE_LENGTH];
- protected byte[] destinationAddress = new byte[Ip6Address.BYTE_LENGTH];
-
- private final NeighborDiscoveryOptions options =
- new NeighborDiscoveryOptions();
-
- /**
- * Gets target address.
- *
- * @return the target IPv6 address
- */
- public byte[] getTargetAddress() {
- return this.targetAddress;
- }
-
- /**
- * Sets target address.
- *
- * @param targetAddress the target IPv6 address to set
- * @return this
- */
- public Redirect setTargetAddress(final byte[] targetAddress) {
- this.targetAddress =
- Arrays.copyOfRange(targetAddress, 0, Ip6Address.BYTE_LENGTH);
- return this;
- }
-
- /**
- * Gets destination address.
- *
- * @return the destination IPv6 address
- */
- public byte[] getDestinationAddress() {
- return this.destinationAddress;
- }
-
- /**
- * Sets destination address.
- *
- * @param destinationAddress the destination IPv6 address to set
- * @return this
- */
- public Redirect setDestinationAddress(final byte[] destinationAddress) {
- this.destinationAddress =
- Arrays.copyOfRange(destinationAddress, 0, Ip6Address.BYTE_LENGTH);
- return this;
- }
-
- /**
- * Gets the Neighbor Discovery Protocol packet options.
- *
- * @return the Neighbor Discovery Protocol packet options
- */
- public List<NeighborDiscoveryOptions.Option> getOptions() {
- return this.options.options();
- }
-
- /**
- * Adds a Neighbor Discovery Protocol packet option.
- *
- * @param type the option type
- * @param data the option data
- * @return this
- */
- public Redirect addOption(final byte type, final byte[] data) {
- this.options.addOption(type, data);
- return this;
- }
-
- @Override
- public byte[] serialize() {
- byte[] optionsData = null;
- if (this.options.hasOptions()) {
- optionsData = this.options.serialize();
- }
-
- int optionsLength = 0;
- if (optionsData != null) {
- optionsLength = optionsData.length;
- }
-
- final byte[] data = new byte[HEADER_LENGTH + optionsLength];
- final ByteBuffer bb = ByteBuffer.wrap(data);
-
- bb.putInt(0);
- bb.put(this.targetAddress, 0, Ip6Address.BYTE_LENGTH);
- bb.put(this.destinationAddress, 0, Ip6Address.BYTE_LENGTH);
- if (optionsData != null) {
- bb.put(optionsData);
- }
-
- return data;
- }
-
- @Override
- public IPacket deserialize(byte[] data, int offset, int length) {
- final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
-
- bb.getInt();
- bb.get(this.targetAddress, 0, Ip6Address.BYTE_LENGTH);
- bb.get(this.destinationAddress, 0, Ip6Address.BYTE_LENGTH);
-
- this.options.deserialize(data, bb.position(),
- bb.limit() - bb.position());
-
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 5807;
- int result = super.hashCode();
- ByteBuffer bb;
- bb = ByteBuffer.wrap(this.targetAddress);
- for (int i = 0; i < this.targetAddress.length / 4; i++) {
- result = prime * result + bb.getInt();
- }
- bb = ByteBuffer.wrap(this.destinationAddress);
- for (int i = 0; i < this.destinationAddress.length / 4; i++) {
- result = prime * result + bb.getInt();
- }
- result = prime * result + this.options.hashCode();
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof Redirect)) {
- return false;
- }
- final Redirect other = (Redirect) obj;
- if (!Arrays.equals(this.targetAddress, other.targetAddress)) {
- return false;
- }
- if (!Arrays.equals(this.destinationAddress,
- other.destinationAddress)) {
- return false;
- }
- if (!this.options.equals(other.options)) {
- return false;
- }
- return true;
- }
-
- /**
- * Deserializer function for redirect packets.
- *
- * @return deserializer function
- */
- public static Deserializer<Redirect> deserializer() {
- return (data, offset, length) -> {
- checkInput(data, offset, length, HEADER_LENGTH);
-
- Redirect redirect = new Redirect();
-
- ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
-
- bb.getInt();
-
- bb.get(redirect.targetAddress, 0, Ip6Address.BYTE_LENGTH);
- bb.get(redirect.destinationAddress, 0, Ip6Address.BYTE_LENGTH);
-
- if (bb.limit() - bb.position() > 0) {
- NeighborDiscoveryOptions options = NeighborDiscoveryOptions.deserializer()
- .deserialize(data, bb.position(), bb.limit() - bb.position());
-
- for (NeighborDiscoveryOptions.Option option : options.options()) {
- redirect.addOption(option.type(), option.data());
- }
- }
-
- return redirect;
- };
- }
-}
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/RouterAdvertisement.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/RouterAdvertisement.java
deleted file mode 100644
index 597fc9f8..00000000
--- a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/RouterAdvertisement.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onlab.packet.ndp;
-
-import org.onlab.packet.BasePacket;
-import org.onlab.packet.Deserializer;
-import org.onlab.packet.IPacket;
-
-import java.nio.ByteBuffer;
-import java.util.List;
-
-import static org.onlab.packet.PacketUtils.checkInput;
-
-/**
- * Implements ICMPv6 Router Advertisement packet format. (RFC 4861)
- */
-public class RouterAdvertisement extends BasePacket {
- public static final byte HEADER_LENGTH = 12; // bytes
-
- protected byte currentHopLimit;
- protected byte mFlag;
- protected byte oFlag;
- protected short routerLifetime;
- protected int reachableTime;
- protected int retransmitTimer;
-
- private final NeighborDiscoveryOptions options =
- new NeighborDiscoveryOptions();
-
- /**
- * Gets current hop limit.
- *
- * @return the current hop limit
- */
- public byte getCurrentHopLimit() {
- return this.currentHopLimit;
- }
-
- /**
- * Sets current hop limit.
- *
- * @param currentHopLimit the current hop limit to set
- * @return this
- */
- public RouterAdvertisement setCurrentHopLimit(final byte currentHopLimit) {
- this.currentHopLimit = currentHopLimit;
- return this;
- }
-
- /**
- * Gets managed address configuration flag.
- *
- * @return the managed address configuration flag
- */
- public byte getMFlag() {
- return this.mFlag;
- }
-
- /**
- * Sets managed address configuration flag.
- *
- * @param mFlag the managed address configuration flag to set
- * @return this
- */
- public RouterAdvertisement setMFlag(final byte mFlag) {
- this.mFlag = mFlag;
- return this;
- }
-
- /**
- * Gets other configuration flag.
- *
- * @return the other configuration flag
- */
- public byte getOFlag() {
- return this.oFlag;
- }
-
- /**
- * Sets other configuration flag.
- *
- * @param oFlag the other configuration flag to set
- * @return this
- */
- public RouterAdvertisement setOFlag(final byte oFlag) {
- this.oFlag = oFlag;
- return this;
- }
-
- /**
- * Gets router lifetime.
- *
- * @return the router lifetime
- */
- public short getRouterLifetime() {
- return this.routerLifetime;
- }
-
- /**
- * Sets router lifetime.
- *
- * @param routerLifetime the router lifetime to set
- * @return this
- */
- public RouterAdvertisement setRouterLifetime(final short routerLifetime) {
- this.routerLifetime = routerLifetime;
- return this;
- }
-
- /**
- * Gets reachable time.
- *
- * @return the reachable time
- */
- public int getReachableTime() {
- return this.reachableTime;
- }
-
- /**
- * Sets reachable time.
- *
- * @param reachableTime the reachable time to set
- * @return this
- */
- public RouterAdvertisement setReachableTime(final int reachableTime) {
- this.reachableTime = reachableTime;
- return this;
- }
-
- /**
- * Gets retransmission timer.
- *
- * @return the retransmission timer
- */
- public int getRetransmitTimer() {
- return this.retransmitTimer;
- }
-
- /**
- * Sets retransmission timer.
- *
- * @param retransmitTimer the retransmission timer to set
- * @return this
- */
- public RouterAdvertisement setRetransmitTimer(final int retransmitTimer) {
- this.retransmitTimer = retransmitTimer;
- return this;
- }
-
- /**
- * Gets the Neighbor Discovery Protocol packet options.
- *
- * @return the Neighbor Discovery Protocol packet options
- */
- public List<NeighborDiscoveryOptions.Option> getOptions() {
- return this.options.options();
- }
-
- /**
- * Adds a Neighbor Discovery Protocol packet option.
- *
- * @param type the option type
- * @param data the option data
- * @return this
- */
- public RouterAdvertisement addOption(final byte type, final byte[] data) {
- this.options.addOption(type, data);
- return this;
- }
-
- @Override
- public byte[] serialize() {
- byte[] optionsData = null;
- if (this.options.hasOptions()) {
- optionsData = this.options.serialize();
- }
-
- int optionsLength = 0;
- if (optionsData != null) {
- optionsLength = optionsData.length;
- }
-
- final byte[] data = new byte[HEADER_LENGTH + optionsLength];
- final ByteBuffer bb = ByteBuffer.wrap(data);
-
- bb.put(this.currentHopLimit);
- bb.put((byte) ((this.mFlag & 0x1) << 7 | (this.oFlag & 0x1) << 6));
- bb.putShort(routerLifetime);
- bb.putInt(reachableTime);
- bb.putInt(retransmitTimer);
-
- if (optionsData != null) {
- bb.put(optionsData);
- }
-
- return data;
- }
-
- @Override
- public IPacket deserialize(byte[] data, int offset, int length) {
- final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
- int bscratch;
-
- this.currentHopLimit = bb.get();
- bscratch = bb.get();
- this.mFlag = (byte) ((bscratch >> 7) & 0x1);
- this.oFlag = (byte) ((bscratch >> 6) & 0x1);
- this.routerLifetime = bb.getShort();
- this.reachableTime = bb.getInt();
- this.retransmitTimer = bb.getInt();
-
- this.options.deserialize(data, bb.position(),
- bb.limit() - bb.position());
-
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 5807;
- int result = super.hashCode();
- result = prime * result + this.currentHopLimit;
- result = prime * result + this.mFlag;
- result = prime * result + this.oFlag;
- result = prime * result + this.routerLifetime;
- result = prime * result + this.reachableTime;
- result = prime * result + this.retransmitTimer;
- result = prime * result + this.options.hashCode();
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof RouterAdvertisement)) {
- return false;
- }
- final RouterAdvertisement other = (RouterAdvertisement) obj;
- if (this.currentHopLimit != other.currentHopLimit) {
- return false;
- }
- if (this.mFlag != other.mFlag) {
- return false;
- }
- if (this.oFlag != other.oFlag) {
- return false;
- }
- if (this.routerLifetime != other.routerLifetime) {
- return false;
- }
- if (this.reachableTime != other.reachableTime) {
- return false;
- }
- if (this.retransmitTimer != other.retransmitTimer) {
- return false;
- }
- if (!this.options.equals(other.options)) {
- return false;
- }
- return true;
- }
-
- /**
- * Deserializer function for router advertisement packets.
- *
- * @return deserializer function
- */
- public static Deserializer<RouterAdvertisement> deserializer() {
- return (data, offset, length) -> {
- checkInput(data, offset, length, HEADER_LENGTH);
-
- RouterAdvertisement routerAdvertisement = new RouterAdvertisement();
-
- ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
- int bscratch;
-
- routerAdvertisement.currentHopLimit = bb.get();
- bscratch = bb.get();
- routerAdvertisement.mFlag = (byte) ((bscratch >> 7) & 0x1);
- routerAdvertisement.oFlag = (byte) ((bscratch >> 6) & 0x1);
- routerAdvertisement.routerLifetime = bb.getShort();
- routerAdvertisement.reachableTime = bb.getInt();
- routerAdvertisement.retransmitTimer = bb.getInt();
-
- if (bb.limit() - bb.position() > 0) {
- NeighborDiscoveryOptions options = NeighborDiscoveryOptions.deserializer()
- .deserialize(data, bb.position(), bb.limit() - bb.position());
-
- for (NeighborDiscoveryOptions.Option option : options.options()) {
- routerAdvertisement.addOption(option.type(), option.data());
- }
- }
-
- return routerAdvertisement;
- };
- }
-}
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/RouterSolicitation.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/RouterSolicitation.java
deleted file mode 100644
index e279a404..00000000
--- a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/RouterSolicitation.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onlab.packet.ndp;
-
-import org.onlab.packet.BasePacket;
-import org.onlab.packet.Deserializer;
-import org.onlab.packet.IPacket;
-
-import java.nio.ByteBuffer;
-import java.util.List;
-
-import static org.onlab.packet.PacketUtils.checkInput;
-
-/**
- * Implements ICMPv6 Router Solicitation packet format. (RFC 4861)
- */
-public class RouterSolicitation extends BasePacket {
- public static final byte HEADER_LENGTH = 4; // bytes
-
- private final NeighborDiscoveryOptions options = new NeighborDiscoveryOptions();
-
- /**
- * Gets the Neighbor Discovery Protocol packet options.
- *
- * @return the Neighbor Discovery Protocol packet options
- */
- public List<NeighborDiscoveryOptions.Option> getOptions() {
- return this.options.options();
- }
-
- /**
- * Adds a Neighbor Discovery Protocol packet option.
- *
- * @param type the option type
- * @param data the option data
- * @return this
- */
- public RouterSolicitation addOption(final byte type, final byte[] data) {
- this.options.addOption(type, data);
- return this;
- }
-
- @Override
- public byte[] serialize() {
- byte[] optionsData = null;
- if (this.options.hasOptions()) {
- optionsData = this.options.serialize();
- }
-
- int optionsLength = 0;
- if (optionsData != null) {
- optionsLength = optionsData.length;
- }
-
- final byte[] data = new byte[HEADER_LENGTH + optionsLength];
- final ByteBuffer bb = ByteBuffer.wrap(data);
-
- bb.putInt(0);
-
- if (optionsData != null) {
- bb.put(optionsData);
- }
-
- return data;
- }
-
- @Override
- public IPacket deserialize(byte[] data, int offset, int length) {
- final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
-
- bb.getInt();
-
- this.options.deserialize(data, bb.position(),
- bb.limit() - bb.position());
-
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 5807;
- int result = super.hashCode();
- result = prime * result + this.options.hashCode();
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof RouterSolicitation)) {
- return false;
- }
- final RouterSolicitation other = (RouterSolicitation) obj;
- if (!this.options.equals(other.options)) {
- return false;
- }
- return true;
- }
-
- /**
- * Deserializer function for router solicitation packets.
- *
- * @return deserializer function
- */
- public static Deserializer<RouterSolicitation> deserializer() {
- return (data, offset, length) -> {
- checkInput(data, offset, length, HEADER_LENGTH);
-
- RouterSolicitation routerSolicitation = new RouterSolicitation();
-
- ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
-
- bb.getInt();
-
- if (bb.limit() - bb.position() > 0) {
- NeighborDiscoveryOptions options = NeighborDiscoveryOptions.deserializer()
- .deserialize(data, bb.position(), bb.limit() - bb.position());
-
- for (NeighborDiscoveryOptions.Option option : options.options()) {
- routerSolicitation.addOption(option.type(), option.data());
- }
- }
-
- return routerSolicitation;
- };
- }
-}
diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/package-info.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/package-info.java
deleted file mode 100644
index c62b1fba..00000000
--- a/framework/src/onos/utils/misc/src/main/java/org/onlab/packet/ndp/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Utilities for decoding and encoding packets of Neighbor Discovery Protocol
- * for IPv6 (RFC 4861).
- */
-package org.onlab.packet.ndp;