OSPF protocol manual merge from 1.6, due to cherry pick merge conflict
Change-Id: I93653e745468722ce95533537a79e897b4292f5d
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/ChecksumCalculator.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/ChecksumCalculator.java
index 7b0140a..7ba504f 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/ChecksumCalculator.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/ChecksumCalculator.java
@@ -25,7 +25,7 @@
import org.onosproject.ospf.protocol.lsa.types.OpaqueLsa9;
import org.onosproject.ospf.protocol.lsa.types.RouterLsa;
import org.onosproject.ospf.protocol.lsa.types.SummaryLsa;
-import org.onosproject.ospf.protocol.ospfpacket.OspfMessage;
+import org.onosproject.ospf.controller.OspfMessage;
import org.onosproject.ospf.protocol.ospfpacket.types.DdPacket;
import org.onosproject.ospf.protocol.ospfpacket.types.HelloPacket;
import org.onosproject.ospf.protocol.ospfpacket.types.LsAcknowledge;
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfInterfaceState.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfInterfaceState.java
index 82a00f0..a8036b5 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfInterfaceState.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfInterfaceState.java
@@ -31,20 +31,55 @@
private int value;
/**
- * Creates an instance of Interface State.
+ * Creates an instance of interface state.
*
- * @param value Interface State value
+ * @param value Interface state value
*/
OspfInterfaceState(int value) {
this.value = value;
}
/**
- * Gets value for Interface State.
+ * Gets value for Interface state.
*
- * @return value Interface State
+ * @return value Interface state
*/
public int value() {
return value;
}
+
+ /**
+ * Gets interface state.
+ *
+ * @return interface state
+ */
+ public String interfaceState() {
+ String state = null;
+ switch (value) {
+ case 1:
+ state = "DOWN";
+ break;
+ case 2:
+ state = "LOOPBACK";
+ break;
+ case 3:
+ state = "WAITING";
+ break;
+ case 4:
+ state = "POINT2POINT";
+ break;
+ case 5:
+ state = "DROTHER";
+ break;
+ case 6:
+ state = "BDR";
+ break;
+ case 7:
+ state = "DR";
+ break;
+ default:
+ break;
+ }
+ return state;
+ }
}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfPacketType.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfPacketType.java
deleted file mode 100644
index 22832e2..0000000
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfPacketType.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2016-present 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.onosproject.ospf.protocol.util;
-
-/**
- * Representation of different OSPF packet types.
- */
-public enum OspfPacketType {
-
- HELLO(1),
- DD(2),
- LSREQUEST(3),
- LSUPDATE(4),
- LSAACK(5);
-
- private int value;
-
- /**
- * Creates instance of OSPF packet types.
- *
- * @param value
- */
- OspfPacketType(int value) {
- this.value = value;
- }
-
- /**
- * Gets the value.
- *
- * @return value
- */
- public int value() {
- return value;
- }
-}
\ No newline at end of file
diff --git a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfUtil.java b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfUtil.java
index 5372804..4509d32 100644
--- a/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfUtil.java
+++ b/protocols/ospf/protocol/src/main/java/org/onosproject/ospf/protocol/util/OspfUtil.java
@@ -36,10 +36,11 @@
* Representation of an OSPF constants and utility methods.
*/
public final class OspfUtil {
-
public static final int OSPF_VERSION_2 = 2;
public static final int OSPF_VERSION = OSPF_VERSION_2;
public static final int PACKET_MINIMUM_LENGTH = 24;
+ public static final int METADATA_LEN = 5;
+ public static final int MINIMUM_FRAME_LEN = 1487;
public static final int OSPF_HEADER_LENGTH = 24;
public static final int LSA_HEADER_LENGTH = 20;
public static final int DD_HEADER_LENGTH = OSPF_HEADER_LENGTH + 8;
@@ -52,6 +53,8 @@
public static final int LSAPACKET_CHECKSUM_POS2 = 17;
public static final Ip4Address ALL_SPF_ROUTERS = Ip4Address.valueOf("224.0.0.5");
public static final Ip4Address ALL_DROUTERS = Ip4Address.valueOf("224.0.0.6");
+ public static final Ip4Address DEFAULTIP = Ip4Address.valueOf("0.0.0.0");
+ public static final int RETRANSMITINTERVAL = 5;
public static final int ONLY_ALL_SPF_ROUTERS = 1;
public static final int JOIN_ALL_DROUTERS = 2;
public static final int INITIALIZE_SET = 1;
@@ -62,9 +65,16 @@
public static final int NOT_MASTER = 0;
public static final int NOT_ASSIGNED = 0;
public static final int FOUR_BYTES = 4;
+ public static final int FIVE_BYTES = 5;
public static final int EIGHT_BYTES = 8;
public static final int TWELVE_BYTES = 12;
public static final int EXTERNAL_DESTINATION_LENGTH = 12;
+ public static final String SHOST = "127.0.0.1";
+ public static final int SPORT = 7000;
+ public static final int MTU = 1500;
+ public static final char CONFIG_LENGTH = 1498;
+ public static final char ROUTER_PRIORITY = 0;
+ public static final int HELLO_PACKET_OPTIONS = 2;
private static final Logger log =
LoggerFactory.getLogger(OspfUtil.class);
@@ -398,18 +408,21 @@
/**
* Adds metadata to ospf packet like whether to join multi cast group and destination IP.
*
+ * @param interfaceIndex interface index
* @param ospfPacket OSPF packet
* @param allDroutersValue whether to join multi cast or not
* @param destinationIp destination ip address
* @return byte array
*/
- public static byte[] addMetadata(byte[] ospfPacket, int allDroutersValue, Ip4Address destinationIp) {
+ public static byte[] addMetadata(int interfaceIndex, byte[] ospfPacket, int allDroutersValue,
+ Ip4Address destinationIp) {
byte[] packet;
+ byte[] interfaceIndexByteVal = {(byte) interfaceIndex};
byte[] allDroutersByteVal = {(byte) allDroutersValue};
byte[] destIpAsBytes = destinationIp.toOctets();
- byte[] metadata = Bytes.concat(allDroutersByteVal, destIpAsBytes);
-
- packet = Bytes.concat(metadata, ospfPacket);
+ byte[] metadata = Bytes.concat(interfaceIndexByteVal, allDroutersByteVal);
+ metadata = Bytes.concat(metadata, destIpAsBytes);
+ packet = Bytes.concat(ospfPacket, metadata);
return packet;
}