ONOS-4086 to ONOS-4091, ONOS-4098 to ONOS-4100:ISIS controller implementation
Change-Id: I7be52805652fe762baf808515401d6b5042b2aa5
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisHelloPduSender.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisHelloPduSender.java
new file mode 100755
index 0000000..87338f5
--- /dev/null
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisHelloPduSender.java
@@ -0,0 +1,88 @@
+/*
+ * 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.isis.controller.impl;
+
+import com.google.common.primitives.Bytes;
+import org.jboss.netty.channel.Channel;
+import org.onosproject.isis.controller.IsisInterface;
+import org.onosproject.isis.controller.IsisNetworkType;
+import org.onosproject.isis.controller.IsisRouterType;
+import org.onosproject.isis.io.util.IsisUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Representation of an ISIS hello pdu sender task.
+ */
+public class IsisHelloPduSender implements Runnable {
+ private static final Logger log = LoggerFactory.getLogger(IsisHelloPduSender.class);
+ private Channel channel = null;
+ private IsisInterface isisInterface = null;
+
+ /**
+ * Creates an instance of Hello PDU Sender task.
+ *
+ * @param channel netty channel instance
+ * @param isisInterface ISIS interface instance
+ */
+ public IsisHelloPduSender(Channel channel, IsisInterface isisInterface) {
+ this.channel = channel;
+ this.isisInterface = isisInterface;
+ }
+
+ @Override
+ public void run() {
+ if (channel != null) {
+ try {
+ byte[] helloPdu = null;
+ byte[] interfaceIndex = {(byte) isisInterface.interfaceIndex()};
+
+ if (isisInterface.networkType() == IsisNetworkType.P2P) {
+ helloPdu = IsisUtil.getP2pHelloPdu(isisInterface, true);
+ helloPdu = Bytes.concat(helloPdu, interfaceIndex);
+ channel.write(helloPdu);
+ } else if (isisInterface.networkType() == IsisNetworkType.BROADCAST) {
+ switch (IsisRouterType.get(isisInterface.reservedPacketCircuitType())) {
+ case L1:
+ helloPdu = IsisUtil.getL1HelloPdu(isisInterface, true);
+ helloPdu = Bytes.concat(helloPdu, interfaceIndex);
+ channel.write(helloPdu);
+ break;
+ case L2:
+ helloPdu = IsisUtil.getL2HelloPdu(isisInterface, true);
+ helloPdu = Bytes.concat(helloPdu, interfaceIndex);
+ channel.write(helloPdu);
+ break;
+ case L1L2:
+ helloPdu = IsisUtil.getL1HelloPdu(isisInterface, true);
+ helloPdu = Bytes.concat(helloPdu, interfaceIndex);
+ channel.write(helloPdu);
+
+ helloPdu = IsisUtil.getL2HelloPdu(isisInterface, true);
+ helloPdu = Bytes.concat(helloPdu, interfaceIndex);
+ channel.write(helloPdu);
+ break;
+ default:
+ log.debug("IsisHelloPduSender::Unknown circuit type...!!!");
+ break;
+ }
+ }
+ } catch (Exception e) {
+ log.debug("Exception @IsisHelloPduSender:: {}", e.getMessage());
+ }
+ }
+ }
+}
\ No newline at end of file