[SEBA-937] Multi Tcont support by DhcpL2Relay app.
Change-Id: Id9b8e4b507e5608a92a040b72c8d497cc5783ba8
diff --git a/app/src/test/java/org/opencord/dhcpl2relay/impl/DhcpL2RelayTest.java b/app/src/test/java/org/opencord/dhcpl2relay/impl/DhcpL2RelayTest.java
index 9841953..a0cab4a 100755
--- a/app/src/test/java/org/opencord/dhcpl2relay/impl/DhcpL2RelayTest.java
+++ b/app/src/test/java/org/opencord/dhcpl2relay/impl/DhcpL2RelayTest.java
@@ -18,6 +18,7 @@
import static org.junit.Assert.assertEquals;
import java.nio.ByteBuffer;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
@@ -65,6 +66,7 @@
dhcpL2Relay.sadisService = new MockSadisService();
dhcpL2Relay.hostService = new MockHostService();
dhcpL2Relay.mastershipService = new MockMastershipService();
+ dhcpL2Relay.dhcpL2RelayCounters = new MockDhcpL2RelayCountersStore();
TestUtils.setField(dhcpL2Relay, "eventDispatcher", new TestEventDispatcher());
dhcpL2Relay.refreshService = new MockExecutor(dhcpL2Relay.refreshService);
dhcpL2Relay.activate(new DhcpL2RelayTestBase.MockComponentContext());
@@ -241,6 +243,7 @@
sent.setSourceMACAddress(OLT_MAC_ADDRESS);
sent.setQinQVID(CLIENT_S_TAG.toShort());
sent.setVlanID(CLIENT_C_TAG.toShort());
+ sent.setPriorityCode((byte) CLIENT_C_PBIT);
IPv4 ipv4Packet = (IPv4) sent.getPayload();
UDP udpPacket = (UDP) ipv4Packet.getPayload();
@@ -263,7 +266,8 @@
public void compareServerPackets(Ethernet sent, Ethernet relayed) {
sent.setDestinationMACAddress(CLIENT_MAC);
- sent.setQinQVID(CLIENT_S_TAG.toShort());
+ sent.setQinQVID(NOT_PROVIDED);
+ sent.setQinQPriorityCode((byte) NOT_PROVIDED);
sent.setVlanID(CLIENT_C_TAG.toShort());
final ByteBuffer byteBuffer = ByteBuffer.wrap(sent.serialize());
@@ -276,4 +280,31 @@
assertEquals(expectedPacket, relayed);
}
+
+ private class MockDhcpL2RelayCountersStore implements DhcpL2RelayCountersStore {
+ @Override
+ public void initCounters(String counterClass) {
+
+ }
+
+ @Override
+ public void incrementCounter(String counterClass, DhcpL2RelayCounters counterType) {
+
+ }
+
+ @Override
+ public void setCounter(String counterClass, DhcpL2RelayCounters counterType, Long value) {
+
+ }
+
+ @Override
+ public Map<DhcpL2RelayCountersIdentifier, AtomicLong> getCountersMap() {
+ return new HashMap<>();
+ }
+
+ @Override
+ public void resetCounters(String counterClass) {
+
+ }
+ }
}
\ No newline at end of file
diff --git a/app/src/test/java/org/opencord/dhcpl2relay/impl/DhcpL2RelayTestBase.java b/app/src/test/java/org/opencord/dhcpl2relay/impl/DhcpL2RelayTestBase.java
index bae3575..85854ab 100755
--- a/app/src/test/java/org/opencord/dhcpl2relay/impl/DhcpL2RelayTestBase.java
+++ b/app/src/test/java/org/opencord/dhcpl2relay/impl/DhcpL2RelayTestBase.java
@@ -85,6 +85,7 @@
import org.opencord.sadis.BaseInformationService;
import org.opencord.sadis.SadisService;
import org.opencord.sadis.SubscriberAndDeviceInformation;
+import org.opencord.sadis.UniTagInformation;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -100,11 +101,13 @@
public class DhcpL2RelayTestBase {
private final Logger log = LoggerFactory.getLogger(getClass());
- static final VlanId CLIENT_C_TAG = VlanId.vlanId((short) 999);
- static final VlanId CLIENT_S_TAG = VlanId.vlanId((short) 111);
+ static final VlanId CLIENT_C_TAG = VlanId.vlanId((short) 2);
+ static final VlanId CLIENT_S_TAG = VlanId.vlanId((short) 4);
+ static final short CLIENT_C_PBIT = 7;
static final String CLIENT_ID_1 = "SUBSCRIBER_ID_1";
static final String CLIENT_NAS_PORT_ID = "PON 1/1";
static final String CLIENT_CIRCUIT_ID = "CIR-PON 1/1";
+ static final short NOT_PROVIDED = 0;
static final MacAddress CLIENT_MAC = MacAddress.valueOf("00:00:00:00:00:01");
static final MacAddress SERVER_MAC = MacAddress.valueOf("bb:bb:bb:bb:bb:bb");
@@ -317,18 +320,27 @@
class MockSubscriberAndDeviceInformation extends SubscriberAndDeviceInformation {
- MockSubscriberAndDeviceInformation(String id, VlanId ctag,
- VlanId stag, String nasPortId,
+ MockSubscriberAndDeviceInformation(String id, VlanId cTag,
+ VlanId sTag, String nasPortId,
String circuitId, MacAddress hardId,
Ip4Address ipAddress, int uplinkPort) {
- this.setCTag(ctag);
this.setHardwareIdentifier(hardId);
this.setId(id);
this.setIPAddress(ipAddress);
- this.setSTag(stag);
this.setNasPortId(nasPortId);
this.setCircuitId(circuitId);
this.setUplinkPort(uplinkPort);
+
+ List<UniTagInformation> uniTagInformationList = new ArrayList<>();
+
+ UniTagInformation uniTagInformation = new UniTagInformation.Builder()
+ .setPonCTag(cTag)
+ .setPonSTag(sTag)
+ .setUsPonCTagPriority(CLIENT_C_PBIT)
+ .setIsDhcpRequired(true)
+ .build();
+ uniTagInformationList.add(uniTagInformation);
+ this.setUniTagList(uniTagInformationList);
}
}
@@ -589,8 +601,13 @@
ethPkt.setSourceMACAddress(srcMac);
ethPkt.setDestinationMACAddress(dstMac);
ethPkt.setEtherType(Ethernet.TYPE_IPV4);
- ethPkt.setVlanID((short) 2);
- ethPkt.setPriorityCode((byte) 6);
+ ethPkt.setVlanID(CLIENT_C_TAG.toShort());
+ ethPkt.setPriorityCode((byte) CLIENT_C_PBIT);
+
+ if (DHCP.OPCODE_REPLY == dhcpReqRsp) {
+ ethPkt.setQinQPriorityCode((byte) 3);
+ ethPkt.setQinQVID((short) 4);
+ }
// IP Packet
IPv4 ipv4Reply = new IPv4();