Bump ONOS to 2.2 and build with Java 11
Change-Id: I215f7ca5cbded3acd9c440fe723f6f21d77f9ed5
diff --git a/app/src/main/java/org/opencord/dhcpl2relay/impl/DhcpL2RelayAllocationsCommand.java b/app/src/main/java/org/opencord/dhcpl2relay/cli/DhcpL2RelayAllocationsCommand.java
similarity index 85%
rename from app/src/main/java/org/opencord/dhcpl2relay/impl/DhcpL2RelayAllocationsCommand.java
rename to app/src/main/java/org/opencord/dhcpl2relay/cli/DhcpL2RelayAllocationsCommand.java
index adb0bf0..1e324aa 100644
--- a/app/src/main/java/org/opencord/dhcpl2relay/impl/DhcpL2RelayAllocationsCommand.java
+++ b/app/src/main/java/org/opencord/dhcpl2relay/cli/DhcpL2RelayAllocationsCommand.java
@@ -13,19 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.opencord.dhcpl2relay.impl;
+package org.opencord.dhcpl2relay.cli;
-import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.onosproject.cli.AbstractShellCommand;
+import org.opencord.dhcpl2relay.impl.DhcpL2Relay;
/**
* Shows the Successful DHCP allocations relayed by the dhcpl2relay.
*/
+@Service
@Command(scope = "onos", name = "dhcpl2relay-allocations",
description = "Shows the Successful DHCP allocations relayed by the dhcpl2relay")
public class DhcpL2RelayAllocationsCommand extends AbstractShellCommand {
@Override
- protected void execute() {
+ protected void doExecute() {
DhcpL2Relay.allocationMap().forEach((key, value) -> {
print("SubscriberId=%s,ConnectPoint=%s,State=%s,MAC=%s,CircuitId=%s" +
",IP Allocated=%s,Allocation Timestamp=%s",
diff --git a/app/src/main/java/org/opencord/dhcpl2relay/cli/package-info.java b/app/src/main/java/org/opencord/dhcpl2relay/cli/package-info.java
new file mode 100644
index 0000000..e55847a
--- /dev/null
+++ b/app/src/main/java/org/opencord/dhcpl2relay/cli/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2019-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.
+ */
+/**
+ * Karaf CLI commands for the dhcpl2relay app.
+ */
+package org.opencord.dhcpl2relay.cli;
\ No newline at end of file
diff --git a/app/src/main/java/org/opencord/dhcpl2relay/impl/DhcpL2Relay.java b/app/src/main/java/org/opencord/dhcpl2relay/impl/DhcpL2Relay.java
index cf35677..82de81b 100755
--- a/app/src/main/java/org/opencord/dhcpl2relay/impl/DhcpL2Relay.java
+++ b/app/src/main/java/org/opencord/dhcpl2relay/impl/DhcpL2Relay.java
@@ -15,31 +15,11 @@
*/
package org.opencord.dhcpl2relay.impl;
-import static org.onlab.packet.DHCP.DHCPOptionCode.OptionCode_MessageType;
-import static org.onlab.packet.MacAddress.valueOf;
-import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Dictionary;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.stream.Collectors;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Modified;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import org.onlab.packet.DHCP;
-import org.onlab.packet.DHCPPacketType;
import org.onlab.packet.Ethernet;
import org.onlab.packet.IPv4;
import org.onlab.packet.IpAddress;
@@ -91,19 +71,42 @@
import org.opencord.sadis.SadisService;
import org.opencord.sadis.SubscriberAndDeviceInformation;
import org.osgi.service.component.ComponentContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Modified;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Dictionary;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
+
+import static org.onlab.packet.DHCP.DHCPOptionCode.OptionCode_MessageType;
+import static org.onlab.packet.MacAddress.valueOf;
+import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
+import static org.opencord.dhcpl2relay.impl.OsgiPropertyConstants.ENABLE_DHCP_BROADCAST_REPLIES;
+import static org.opencord.dhcpl2relay.impl.OsgiPropertyConstants.ENABLE_DHCP_BROADCAST_REPLIES_DEFAULT;
+import static org.opencord.dhcpl2relay.impl.OsgiPropertyConstants.OPTION_82;
+import static org.opencord.dhcpl2relay.impl.OsgiPropertyConstants.OPTION_82_DEFAULT;
/**
* DHCP Relay Agent Application Component.
*/
-@Service
-@Component(immediate = true)
+@Component(immediate = true,
+property = {
+ OPTION_82 + ":Boolean=" + OPTION_82_DEFAULT,
+ ENABLE_DHCP_BROADCAST_REPLIES + ":Boolean=" + ENABLE_DHCP_BROADCAST_REPLIES_DEFAULT,
+})
public class DhcpL2Relay
extends AbstractListenerManager<DhcpL2RelayEvent, DhcpL2RelayListener>
implements DhcpL2RelayService {
@@ -126,40 +129,38 @@
}
);
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ @Reference(cardinality = ReferenceCardinality.MANDATORY)
protected NetworkConfigRegistry cfgService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ @Reference(cardinality = ReferenceCardinality.MANDATORY)
protected CoreService coreService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ @Reference(cardinality = ReferenceCardinality.MANDATORY)
protected PacketService packetService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ @Reference(cardinality = ReferenceCardinality.MANDATORY)
protected HostService hostService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ @Reference(cardinality = ReferenceCardinality.MANDATORY)
protected ComponentConfigService componentConfigService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ @Reference(cardinality = ReferenceCardinality.MANDATORY)
protected SadisService sadisService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ @Reference(cardinality = ReferenceCardinality.MANDATORY)
protected DeviceService deviceService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ @Reference(cardinality = ReferenceCardinality.MANDATORY)
protected MastershipService mastershipService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ @Reference(cardinality = ReferenceCardinality.MANDATORY)
protected FlowObjectiveService flowObjectiveService;
- @Property(name = "option82", boolValue = true,
- label = "Add option 82 to relayed packets")
- protected boolean option82 = true;
+ /** Add option 82 to relayed packets */
+ protected boolean option82 = OPTION_82_DEFAULT;
- @Property(name = "enableDhcpBroadcastReplies", boolValue = false,
- label = "Ask the DHCP Server to send back replies as L2 broadcast")
- protected boolean enableDhcpBroadcastReplies = false;
+ /** Ask the DHCP Server to send back replies as L2 broadcast */
+ protected boolean enableDhcpBroadcastReplies = ENABLE_DHCP_BROADCAST_REPLIES_DEFAULT;
private DhcpRelayPacketProcessor dhcpRelayPacketProcessor =
new DhcpRelayPacketProcessor();
@@ -228,12 +229,12 @@
Dictionary<?, ?> properties = context.getProperties();
- Boolean o = Tools.isPropertyEnabled(properties, "option82");
+ Boolean o = Tools.isPropertyEnabled(properties, OPTION_82);
if (o != null) {
option82 = o;
}
- o = Tools.isPropertyEnabled(properties, "enableDhcpBroadcastReplies");
+ o = Tools.isPropertyEnabled(properties, ENABLE_DHCP_BROADCAST_REPLIES);
if (o != null) {
enableDhcpBroadcastReplies = o;
}
@@ -610,12 +611,12 @@
}
// get the type of the DHCP packet
- private DHCPPacketType getDhcpPacketType(DHCP dhcpPayload) {
+ private DHCP.MsgType getDhcpPacketType(DHCP dhcpPayload) {
for (DhcpOption option : dhcpPayload.getOptions()) {
if (option.getCode() == OptionCode_MessageType.getValue()) {
byte[] data = option.getData();
- return DHCPPacketType.getType(data[0]);
+ return DHCP.MsgType.getType(data[0]);
}
}
return null;
@@ -629,7 +630,7 @@
return;
}
- DHCPPacketType incomingPacketType = getDhcpPacketType(dhcpPayload);
+ DHCP.MsgType incomingPacketType = getDhcpPacketType(dhcpPayload);
log.info("Received DHCP Packet of type {} from {}",
incomingPacketType, context.inPacket().receivedFrom());
@@ -749,10 +750,11 @@
ConnectPoint subsCp = getConnectPointOfClient(dstMac);
// If we can't find the subscriber, can't process further
if (subsCp == null) {
+ log.warn("Couldn't find connection point for mac address {} DHCPOFFERs won't be delivered", dstMac);
return null;
}
// if it's an ACK packet store the information for display purpose
- if (getDhcpPacketType(dhcpPayload) == DHCPPacketType.DHCPACK) {
+ if (getDhcpPacketType(dhcpPayload) == DHCP.MsgType.DHCPACK) {
String portId = nasPortId(subsCp);
SubscriberAndDeviceInformation sub = subsService.get(portId);
diff --git a/app/src/main/java/org/opencord/dhcpl2relay/impl/OsgiPropertyConstants.java b/app/src/main/java/org/opencord/dhcpl2relay/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..2612fdf
--- /dev/null
+++ b/app/src/main/java/org/opencord/dhcpl2relay/impl/OsgiPropertyConstants.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2019-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.dhcpl2relay.impl;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyConstants {
+
+ private OsgiPropertyConstants() {
+ }
+
+ public static final String OPTION_82 = "option82";
+ public static final boolean OPTION_82_DEFAULT = true;
+
+ public static final String ENABLE_DHCP_BROADCAST_REPLIES = "enableDhcpBroadcastReplies";
+ public static final boolean ENABLE_DHCP_BROADCAST_REPLIES_DEFAULT = false;
+}
diff --git a/app/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/app/src/main/resources/OSGI-INF/blueprint/shell-config.xml
deleted file mode 100644
index b5edcc3..0000000
--- a/app/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
- ~ Copyright 2016-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.
- -->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
- <command>
- <action class="org.opencord.dhcpl2relay.impl.DhcpL2RelayAllocationsCommand"/>
- </command>
- </command-bundle>
-</blueprint>
\ No newline at end of file