[SEBA-624] Implementation of radius server operational status

Cherry-picked from aaa-1.10

Change-Id: I3b70ddfc45c4b9e57c587df671088580c7426a89
diff --git a/api/src/main/java/org/opencord/aaa/RadiusOperationalStatusEvent.java b/api/src/main/java/org/opencord/aaa/RadiusOperationalStatusEvent.java
new file mode 100644
index 0000000..7ba9534
--- /dev/null
+++ b/api/src/main/java/org/opencord/aaa/RadiusOperationalStatusEvent.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.opencord.aaa;
+
+import org.onosproject.event.AbstractEvent;
+
+public class RadiusOperationalStatusEvent extends
+              AbstractEvent<RadiusOperationalStatusEvent.Type, String> {
+
+    public RadiusOperationalStatusEvent(Type type, String subject) {
+         super(type, subject);
+    }
+
+    public enum Type {
+         RADIUS_OPERATIONAL_STATUS
+    }
+
+}
diff --git a/api/src/main/java/org/opencord/aaa/RadiusOperationalStatusEventDelegate.java b/api/src/main/java/org/opencord/aaa/RadiusOperationalStatusEventDelegate.java
new file mode 100644
index 0000000..f4d5d5d
--- /dev/null
+++ b/api/src/main/java/org/opencord/aaa/RadiusOperationalStatusEventDelegate.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.opencord.aaa;
+
+import org.onosproject.store.StoreDelegate;
+
+public interface RadiusOperationalStatusEventDelegate
+              extends StoreDelegate<RadiusOperationalStatusEvent> {
+
+}
diff --git a/api/src/main/java/org/opencord/aaa/RadiusOperationalStatusEventListener.java b/api/src/main/java/org/opencord/aaa/RadiusOperationalStatusEventListener.java
new file mode 100644
index 0000000..defffcc
--- /dev/null
+++ b/api/src/main/java/org/opencord/aaa/RadiusOperationalStatusEventListener.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.opencord.aaa;
+
+import org.onosproject.event.EventListener;
+
+public interface RadiusOperationalStatusEventListener extends
+                  EventListener<RadiusOperationalStatusEvent>  {
+
+}
diff --git a/api/src/main/java/org/opencord/aaa/RadiusOperationalStatusService.java b/api/src/main/java/org/opencord/aaa/RadiusOperationalStatusService.java
new file mode 100644
index 0000000..10c5d8b
--- /dev/null
+++ b/api/src/main/java/org/opencord/aaa/RadiusOperationalStatusService.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.opencord.aaa;
+
+import org.onlab.packet.RADIUS;
+import org.onosproject.event.ListenerService;
+
+/**
+ * Service for interacting with operational status module.
+ */
+
+public interface RadiusOperationalStatusService extends
+             ListenerService<RadiusOperationalStatusEvent, RadiusOperationalStatusEventListener> {
+   /**
+     * Return RadiusOperationalStatusEventDelegate object.
+     *
+     * @return RadiusOperationalStatusEventDelegate
+    */
+    RadiusOperationalStatusEventDelegate getRadiusOprStDelegate();
+
+    /**
+     * Return String object.
+     *
+     * @return String
+    */
+    String getRadiusServerOperationalStatus();
+
+    /**
+     * Set the value of statusServerReqSent flag.
+     *
+     * @param statusServerReqSent statusServerReqSent flag
+    */
+    void setStatusServerReqSent(boolean statusServerReqSent);
+
+    /**
+     * Set the value of radiusOperationalStatus Evaluation Mode.
+     *
+     * @param radiusOperationalStatusEvaluationMode radiusOperationalStatusEvaluationMode value
+    */
+    void setRadiusOperationalStatusEvaluationMode(
+            RadiusOperationalStatusEvaluationMode radiusOperationalStatusEvaluationMode);
+
+    /**
+     * Set the value of Operational Status Server Timeout In Milliseconds.
+     *
+     * @param operationalStatusServerTimeoutInMillis operationalStatusServerTimeoutInMillis
+    */
+    void setOperationalStatusServerTimeoutInMillis(long operationalStatusServerTimeoutInMillis);
+
+    /**
+     * Determine the operational status of server.
+    */
+    void checkServerOperationalStatus();
+
+    /**
+     * Check if radius response is for operational status.
+     *
+     * @param identifier identifier value of radius packet
+     * @return boolean
+    */
+    boolean isRadiusResponseForOperationalStatus(byte identifier);
+
+    /**
+     * handle incoming radius packet for operational status.
+     *
+     * @param radiusPacket radiusPacket of incoming operational status
+    */
+    void handleRadiusPacketForOperationalStatus(RADIUS radiusPacket);
+
+    /**
+     * initialize radiusOperationalStatusService.
+     *
+     * @param address address of radius server
+     * @param secret secret key for radius server
+     * @param impl impl of RadiusCommunicator
+    */
+    void initialize(byte[] address, String secret, RadiusCommunicator impl);
+
+    /**
+     * set packet outgoing time in milliseconds.
+     *
+     * @param identifier identifier of outgoing packet
+    */
+    void setOutTimeInMillis(byte identifier);
+
+    enum OperationalStatus {
+        UNAVAILABLE,
+        UNKNOWN,
+        IN_USE,
+    }
+
+    enum RadiusOperationalStatusEvaluationMode {
+
+        STATUS_REQUEST, ACCESS_REQUEST, AUTO;
+
+        public static RadiusOperationalStatusEvaluationMode getValue(String value) {
+
+            for (RadiusOperationalStatusEvaluationMode mode: RadiusOperationalStatusEvaluationMode.values()) {
+                if (mode.toString().equalsIgnoreCase(value)) {
+                   return mode;
+                }
+            }
+            return null;
+        }
+    }
+
+}