finalized create/delete session and fixed store handling
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
index 27e6b8b..75a3067 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
@@ -17,14 +17,23 @@
package org.onosproject.fpcagent;
import org.apache.commons.lang.exception.ExceptionUtils;
-import org.apache.felix.scr.annotations.*;
+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.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.Service;
import org.onosproject.config.DynamicConfigService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.fpcagent.helpers.ConfigHelper;
import org.onosproject.fpcagent.workers.ZMQSBPublisherManager;
import org.onosproject.fpcagent.workers.ZMQSBSubscriberManager;
-import org.onosproject.net.config.*;
+import org.onosproject.net.config.ConfigFactory;
+import org.onosproject.net.config.NetworkConfigEvent;
+import org.onosproject.net.config.NetworkConfigListener;
+import org.onosproject.net.config.NetworkConfigRegistry;
+import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.net.config.basics.SubjectFactories;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.IetfDmmFpcagentService;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.ErrorTypeId;
@@ -38,7 +47,13 @@
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.result.ResultEnum;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.resultbody.resulttype.DefaultErr;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.resultbodydpn.resulttype.DefaultEmptyCase;
-import org.onosproject.yang.model.*;
+import org.onosproject.yang.model.DefaultModelObjectData;
+import org.onosproject.yang.model.ModelConverter;
+import org.onosproject.yang.model.ModelObject;
+import org.onosproject.yang.model.ResourceData;
+import org.onosproject.yang.model.RpcInput;
+import org.onosproject.yang.model.RpcOutput;
+import org.onosproject.yang.model.RpcRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -118,6 +133,9 @@
log.info("FPC Agent Stopped");
}
+ /**
+ * Initialize ZMQ Managers based on configuration.
+ */
private void init() {
fpcConfig.getConfig().ifPresent(
helper -> {
@@ -153,7 +171,7 @@
output.resultType(new DefaultEmptyCase());
try {
- tenantService.getModelObjects(rpcInput.data(), configureDpnResourceId).forEach(
+ tenantService.getModelObjects(rpcInput.data(), configureDpn).forEach(
modelObject -> {
DefaultConfigureDpnInput input = (DefaultConfigureDpnInput) modelObject;
String dpnId = input.inputDpnId().fpcIdentity().union().string();
@@ -183,7 +201,7 @@
DefaultConfigureOutput configureOutput = new DefaultConfigureOutput();
try {
- for (ModelObject modelObject : tenantService.getModelObjects(rpcInput.data(), configureResourceId)) {
+ for (ModelObject modelObject : tenantService.getModelObjects(rpcInput.data(), configure)) {
DefaultConfigureInput input = (DefaultConfigureInput) modelObject;
switch (input.opType()) {
case CREATE:
@@ -212,11 +230,10 @@
}
configureOutput.opId(input.opId());
}
- // TODO fix DELETE to update the NODE correctly.
- tenantService.getTenants().ifPresent(tenants -> tenantService.updateNode(tenants));
} catch (Exception e) {
+ // if there is an exception respond with an error.
DefaultErr defaultErr = new DefaultErr();
- defaultErr.errorInfo(ExceptionUtils.getFullStackTrace(e));
+ defaultErr.errorInfo(ExceptionUtils.getMessage(e));
defaultErr.errorTypeId(ErrorTypeId.of(0));
configureOutput.resultType(defaultErr);
configureOutput.result(Result.of(ResultEnum.ERR));
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcUtil.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcUtil.java
index 6f1ebf1..f0fed23 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcUtil.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcUtil.java
@@ -17,37 +17,31 @@
package org.onosproject.fpcagent;
import com.google.common.collect.Maps;
-import org.onosproject.restconf.utils.RestconfUtils;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.ClientIdentifier;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.DefaultTenants;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.OpIdentifier;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.DefaultTenant;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.TenantKeys;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.yangautoprefixnotify.value.DefaultDownlinkDataNotification;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.yangautoprefixnotify.value.DownlinkDataNotification;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcDpnId;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcIdentity;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.fpcidentity.FpcIdentityUnion;
-import org.onosproject.yang.model.DataNode;
-import org.onosproject.yang.model.DefaultResourceData;
-import org.onosproject.yang.model.ResourceData;
-import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.model.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigInteger;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Map;
-import static org.onosproject.fpcagent.helpers.Converter.fromIntToLong;
-import static org.onosproject.fpcagent.helpers.Converter.toBigInt;
+import static org.onosproject.fpcagent.helpers.Converter.*;
/**
* Helper class which stores all the static variables.
*/
public class FpcUtil {
- protected static final Logger log = LoggerFactory.getLogger(FpcUtil.class);
-
public static final int MAX_EVENTS = 1000;
public static final int MAX_BATCH_MS = 5000;
public static final int MAX_IDLE_MS = 1000;
@@ -55,9 +49,23 @@
public static final String UNKNOWN_EVENT = "FPC Agent listener: unknown event: {}";
public static final String EVENT_NULL = "Event cannot be null";
public static final String FPC_APP_ID = "org.onosproject.fpcagent";
-
+ protected static final Logger log = LoggerFactory.getLogger(FpcUtil.class);
private static final Map<String, FpcDpnId> uplinkDpnMap = Maps.newConcurrentMap();
private static final Map<String, Short> nodeToTopicMap = Maps.newConcurrentMap();
+ public static ModelConverter modelConverter = null;
+ // Resource ID for Configure DPN RPC command
+ public static ResourceId configureDpn;
+ // Resource ID for Configure RPC command
+ public static ResourceId configure;
+ // Resource ID for tenants data
+ public static ResourceId tenants;
+ public static ResourceId defaultTenant;
+ public static ResourceId defaultTenantMobility;
+ public static ResourceId module;
+ public static ResourceId registerClientResourceId;
+ public static ResourceId deregisterClientResourceId;
+
+ public static FpcIdentity defaultIdentity = getFpcIdentity.apply("default");
private static byte DPN_HELLO = 0b0000_0001;
private static byte DPN_BYE = 0b0000_0010;
@@ -67,34 +75,77 @@
private static byte DPN_REPLY = 0b0000_0100;
private static String DOWNLINK_DATA_NOTIFICATION_STRING = "Downlink-Data-Notification";
- // Resource ID for Configure DPN RPC command
- public static ResourceId configureDpnResourceId;
- // Resource ID for Configure RPC command
- public static ResourceId configureResourceId;
- // Resource ID for tenants data
- public static ResourceId tenantsResourceId;
- public static ResourceId registerClientResourceId;
- public static ResourceId deregisterClientResourceId;
+ /**
+ * Returns resource id from model converter.
+ *
+ * @param modelId model object id
+ * @return resource id
+ */
+ static ResourceId getResourceVal(ModelObjectId modelId) {
+ DefaultModelObjectData.Builder data = DefaultModelObjectData.builder()
+ .identifier(modelId);
+ ResourceData resData = modelConverter.createDataNode(data.build());
+ return resData.resourceId();
+ }
- static {
- try {
- configureDpnResourceId = RestconfUtils.convertUriToRid(
- new URI("/onos/restconf/operations/ietf-dmm-fpcagent:configure-dpn")
- );
- configureResourceId = RestconfUtils.convertUriToRid(
- new URI("/onos/restconf/operations/ietf-dmm-fpcagent:configure")
- );
- tenantsResourceId = RestconfUtils.convertUriToRid(
- new URI("/onos/restconf/data/ietf-dmm-fpcagent:tenants")
- );
- registerClientResourceId = RestconfUtils.convertUriToRid(
- new URI("/onos/restconf/data/fpc:register-client")
- );
- deregisterClientResourceId = RestconfUtils.convertUriToRid(
- new URI("/onos/restconf/data/fpc:deregister-client")
- );
- } catch (URISyntaxException ignored) {
- }
+ /**
+ * Returns the resource id, after constructing model object id and
+ * converting it.
+ */
+ static void getResourceId() {
+ ModelObjectId moduleId = ModelObjectId.builder().build();
+ module = getResourceVal(moduleId);
+
+ ModelObjectId tenantsId = ModelObjectId.builder()
+ .addChild(DefaultTenants.class)
+ .build();
+
+ tenants = getResourceVal(tenantsId);
+
+ TenantKeys tenantKeys = new TenantKeys();
+ tenantKeys.tenantId(defaultIdentity);
+
+ ModelObjectId defaultTenantId = ModelObjectId.builder()
+ .addChild(DefaultTenants.class)
+ .addChild(DefaultTenant.class, tenantKeys)
+ .build();
+
+ defaultTenant = getResourceVal(defaultTenantId);
+
+ configure = ResourceId.builder()
+ .addBranchPointSchema("/", null)
+ .addBranchPointSchema("configure", "urn:ietf:params:xml:ns:yang:fpcagent")
+ .build();
+
+ configureDpn = ResourceId.builder()
+ .addBranchPointSchema("/", null)
+ .addBranchPointSchema("configure-dpn", "urn:ietf:params:xml:ns:yang:fpcagent")
+ .build();
+ }
+
+ static ModelObjectId.Builder defaultTenantBuilder() {
+ TenantKeys tenantKeys = new TenantKeys();
+ tenantKeys.tenantId(defaultIdentity);
+
+ return ModelObjectId.builder()
+ .addChild(DefaultTenants.class)
+ .addChild(DefaultTenant.class, tenantKeys);
+ }
+
+ /**
+ * Returns resource id for the specific tenant ID.
+ *
+ * @param tenantId tenant id
+ * @return resource ids
+ */
+ static ResourceId getTenantResourceId(FpcIdentity tenantId) {
+ TenantKeys tenantKeys = new TenantKeys();
+ tenantKeys.tenantId(tenantId);
+
+ return getResourceVal(ModelObjectId.builder()
+ .addChild(DefaultTenants.class)
+ .addChild(DefaultTenant.class, tenantKeys)
+ .build());
}
/**
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantManager.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantManager.java
index dcadbc1..0fa75c2 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantManager.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantManager.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2017-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.onosproject.fpcagent;
import com.google.common.collect.Maps;
@@ -14,7 +30,6 @@
import org.onosproject.config.Filter;
import org.onosproject.fpcagent.helpers.DpnCommunicationService;
import org.onosproject.fpcagent.helpers.DpnNgicCommunicator;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.IetfDmmFpcagentOpParam;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.*;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.configure.DefaultConfigureOutput;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.instructions.instructions.instrtype.Instr3GppMob;
@@ -26,10 +41,11 @@
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.resultbody.resulttype.DefaultDeleteSuccess;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.resultbody.resulttype.DefaultErr;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.DefaultTenant;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.Tenant;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.DefaultFpcMobility;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.DefaultFpcPolicy;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.DefaultFpcTopology;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpcmobility.ContextsKeys;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpcmobility.DefaultContexts;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcIdentity;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.fpccontext.Dpns;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.mobilityinfo.mobprofileparameters.ThreegppTunnel;
@@ -48,16 +64,13 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.fpcagent.FpcUtil.*;
import static org.onosproject.fpcagent.helpers.Converter.convertContext;
-import static org.onosproject.fpcagent.helpers.Converter.getFpcIdentity;
@Component(immediate = true)
@Service
public class TenantManager implements TenantService {
private final Logger log = LoggerFactory.getLogger(getClass());
- private final IetfDmmFpcagentOpParam fpcAgentData = new IetfDmmFpcagentOpParam();
-
- private final Map<ClientIdentifier, Tenant> clientIdMap = Maps.newHashMap();
+ private final Map<ClientIdentifier, DefaultTenant> clientIdMap = Maps.newHashMap();
private final InternalConfigListener listener = new InternalConfigListener();
@@ -73,31 +86,29 @@
@Activate
protected void activate() {
+ FpcUtil.modelConverter = modelConverter;
+ getResourceId();
+
dpnCommunicationService = new DpnNgicCommunicator();
dynamicConfigService.addListener(listener);
- // Create the Default Tenant on activate
+ // Create the Default Tenant and added to the Tenants structure.
DefaultTenants tenants = new DefaultTenants();
-
DefaultTenant tenant = new DefaultTenant();
- tenant.tenantId(getFpcIdentity.apply("default"));
-
+ tenant.tenantId(defaultIdentity);
tenant.fpcTopology(new DefaultFpcTopology());
-
tenant.fpcPolicy(new DefaultFpcPolicy());
-
tenant.fpcMobility(new DefaultFpcMobility());
-
tenants.addToTenant(tenant);
+ // Initialize FPC™2 Agent Information.
DefaultFpcAgentInfo fpcAgentInfo = new DefaultFpcAgentInfo();
- fpcAgentData.tenants(tenants);
- fpcAgentData.fpcAgentInfo(fpcAgentInfo);
-
- createNode(tenants);
- createNode(fpcAgentInfo);
+ // Create nodes in dynamic configuration store for RESTCONF accessibility.
+ final ModelObjectId root = ModelObjectId.builder().build();
+ createNode(tenants, root);
+ createNode(fpcAgentInfo, root);
log.info("Tenant Service Started");
}
@@ -109,60 +120,73 @@
}
@Override
- public Optional<Tenant> getDefaultTenant() {
- return fpcAgentData.tenants().tenant().stream()
- .filter(tenant -> tenant.tenantId().equals(getFpcIdentity.apply("default")))
+ public Optional<DefaultTenant> getDefaultTenant() {
+ Filter filter = Filter.builder().build();
+ DataNode dataNode = dynamicConfigService.readNode(defaultTenant, filter);
+
+ return getModelObjects(dataNode, tenants)
+ .stream()
+ .map(modelObject -> (DefaultTenant) modelObject)
.findFirst();
}
@Override
public Optional<DefaultTenants> getTenants() {
- if (fpcAgentData.tenants() instanceof DefaultTenants) {
- return Optional.ofNullable((DefaultTenants) fpcAgentData.tenants());
- }
- return Optional.empty();
- }
+ Filter filter = Filter.builder().build();
+ DataNode dataNode = dynamicConfigService.readNode(tenants, filter);
- public Optional<Tenant> getTenant(FpcIdentity tenantId) {
- return fpcAgentData.tenants().tenant().stream()
- .filter(tenant -> tenant.tenantId().equals(tenantId))
+ return getModelObjects(dataNode, null)
+ .stream()
+ .map(modelObject -> (DefaultTenants) modelObject)
.findFirst();
}
- public Optional<Tenant> getTenant(ClientIdentifier clientId) {
+ @Override
+ public Optional<DefaultTenant> getTenant(FpcIdentity tenantId) {
+ Filter filter = Filter.builder().build();
+ DataNode dataNode = dynamicConfigService.readNode(getTenantResourceId(tenantId), filter);
+
+ return getModelObjects(dataNode, tenants)
+ .stream()
+ .map(modelObject -> (DefaultTenants) modelObject)
+ .findFirst()
+ .flatMap(defaultTenants ->
+ defaultTenants.tenant()
+ .stream()
+ .filter(defaultTenant ->
+ defaultTenant.tenantId().equals(tenantId))
+ .findFirst()
+ .map(defaultTenant -> (DefaultTenant) defaultTenant)
+ );
+ }
+
+ @Override
+ public Optional<DefaultTenant> getTenant(ClientIdentifier clientId) {
return Optional.ofNullable(clientIdMap.get(clientId));
}
- public Optional<Tenant> registerClient(ClientIdentifier clientId, FpcIdentity tenantId) {
+ @Override
+ public Optional<DefaultTenant> registerClient(ClientIdentifier clientId, FpcIdentity tenantId) {
return getTenant(tenantId).map(tenant -> clientIdMap.put(clientId, tenant));
}
- public Optional<Tenant> deregisterClient(ClientIdentifier clientId) {
+ @Override
+ public Optional<DefaultTenant> deregisterClient(ClientIdentifier clientId) {
return Optional.ofNullable(clientIdMap.remove(clientId));
}
- private ResourceData getResourceData(DataNode dataNode, ResourceId resId) {
- if (resId != null) {
- return DefaultResourceData.builder()
- .addDataNode(dataNode)
- .resourceId(resId)
- .build();
- } else {
- return DefaultResourceData.builder()
- .addDataNode(dataNode)
- .build();
- }
- }
-
+ @Override
public List<ModelObject> getModelObjects(DataNode dataNode, ResourceId resourceId) {
ResourceData data = getResourceData(dataNode, resourceId);
ModelObjectData modelData = modelConverter.createModel(data);
return modelData.modelObjects();
}
- public void createNode(InnerModelObject innerModelObject) {
+ @Override
+ public void createNode(InnerModelObject innerModelObject, ModelObjectId modelObjectId) {
ResourceData dataNode = modelConverter.createDataNode(
DefaultModelObjectData.builder()
+ .identifier(modelObjectId)
.addModelObject(innerModelObject)
.build()
);
@@ -171,9 +195,11 @@
);
}
- public void updateNode(InnerModelObject innerModelObject) {
+ @Override
+ public void updateNode(InnerModelObject innerModelObject, ModelObjectId modelObjectId) {
ResourceData dataNode = modelConverter.createDataNode(
DefaultModelObjectData.builder()
+ .identifier(modelObjectId)
.addModelObject(innerModelObject)
.build()
);
@@ -182,6 +208,7 @@
);
}
+ @Override
public DefaultConfigureOutput configureCreate(
CreateOrUpdate create,
ClientIdentifier clientId,
@@ -189,60 +216,67 @@
) {
DefaultConfigureOutput configureOutput = new DefaultConfigureOutput();
Collection<Callable<Object>> tasks = new ArrayList<>();
- DefaultCommonSuccess defaultCommonSuccess = new DefaultCommonSuccess();
try {
+ DefaultCommonSuccess defaultCommonSuccess = new DefaultCommonSuccess();
for (Contexts context : create.contexts()) {
+ // add context to response.
defaultCommonSuccess.addToContexts(context);
+ // check if mobility exists and if the context id exists.
if (getDefaultTenant().map(
tenant -> tenant.fpcMobility().contexts() != null && tenant.fpcMobility()
.contexts()
.stream()
.anyMatch(contexts -> contexts.contextId().equals(context.contextId()))
).orElse(false)) {
- throw new IllegalStateException("Context already exists.");
+ // throw exception if trying to create a Context that already exists.
+ throw new IllegalStateException("Context tried to create already exists. Please issue update operation..");
}
for (Dpns dpn : context.dpns()) {
+ // check if dpns exists and if there is a DPN registered for the wanted identifier.
if (getDefaultTenant().map(
tenant -> tenant.fpcTopology().dpns() == null ||
tenant.fpcTopology().dpns().stream()
.noneMatch(dpns -> dpns.dpnId().equals(dpn.dpnId()))
).orElse(false)) {
+ // throw exception if DPN ID is not registered.
throw new IllegalStateException("DPN ID is not registered to the topology.");
}
+ // handle only 3GPP instructions.
if (context.instructions().instrType() instanceof Instr3GppMob) {
- Instr3GppMob instr3GppMob = (Instr3GppMob) context.instructions().instrType();
- String commands = Bits.toString(instr3GppMob.instr3GppMob().bits());
-
- Ip4Address s1u_enodeb_ipv4 = Ip4Address.valueOf(context.ul().tunnelLocalAddress().toString()),
- s1u_sgw_ipv4 = Ip4Address.valueOf(context.ul().tunnelRemoteAddress().toString()),
- sgi_enodeb_ipv4 = Ip4Address.valueOf(context.dl().tunnelRemoteAddress().toString()),
- sgi_sgw_ipv4 = Ip4Address.valueOf(context.dl().tunnelLocalAddress().toString());
-
- long s1u_sgw_gtpu_teid, s1u_enb_gtpu_teid,
- client_id = clientId.fpcIdentity().union().int64(),
- session_id = context.contextId().fpcIdentity().union().int64();
-
- BigInteger op_id = operationId.uint64(),
- imsi = context.imsi().uint64();
-
- short default_ebi = context.ebi().uint8(),
- lbi = context.lbi().uint8();
-
+ // from DPN ID find the Network and Node Identifiers
Optional<String> key = getDefaultTenant().flatMap(tenant ->
tenant.fpcTopology()
.dpns()
.stream()
.filter(dpns -> dpns.dpnId().equals(dpn.dpnId()))
- .findFirst().map(node -> node.nodeId() + "/" + node.networkId())
+ .findFirst()
+ .map(node -> node.nodeId() + "/" + node.networkId())
);
if (key.isPresent()) {
- Short topic_id = FpcUtil.getTopicFromNode(key.get());
+ // get DPN Topic from Node/Network pair
+ Short topic_id = getTopicFromNode(key.get());
if (topic_id != null) {
+ Instr3GppMob instr3GppMob = (Instr3GppMob) context.instructions().instrType();
+ String commands = Bits.toString(instr3GppMob.instr3GppMob().bits());
+
+ Ip4Address s1u_enodeb_ipv4 = Ip4Address.valueOf(context.ul().tunnelLocalAddress().toString()),
+ s1u_sgw_ipv4 = Ip4Address.valueOf(context.ul().tunnelRemoteAddress().toString());
+
+ long s1u_sgw_gtpu_teid, s1u_enb_gtpu_teid,
+ client_id = clientId.fpcIdentity().union().int64(),
+ session_id = context.contextId().fpcIdentity().union().int64();
+
+ BigInteger op_id = operationId.uint64(),
+ imsi = context.imsi().uint64();
+
+ short default_ebi = context.ebi().uint8();
+
+ // parse tunnel identifiers. throw exception if mobility profile parameters are missing.
if (context.ul().mobilityTunnelParameters().mobprofileParameters() instanceof ThreegppTunnel) {
s1u_sgw_gtpu_teid = ((ThreegppTunnel) context.ul().mobilityTunnelParameters().mobprofileParameters()).tunnelIdentifier();
} else {
@@ -254,7 +288,7 @@
throw new IllegalArgumentException("mobprofileParameters are not instance of ThreegppTunnel");
}
-
+ // TODO try to make sense out of this...
if (commands.contains("session")) {
tasks.add(Executors.callable(() -> {
dpnCommunicationService.create_session(
@@ -269,9 +303,10 @@
op_id
);
- getDefaultTenant().ifPresent(
- tenant -> tenant.fpcMobility().addToContexts(convertContext(context))
- );
+ ModelObjectId modelObjectId = defaultTenantBuilder()
+ .addChild(DefaultFpcMobility.class)
+ .build();
+ createNode(convertContext(context), modelObjectId);
}));
if (commands.contains("downlink")) {
@@ -286,9 +321,10 @@
op_id
);
- getDefaultTenant().ifPresent(
- tenant -> tenant.fpcMobility().addToContexts(convertContext(context))
- );
+ ModelObjectId modelObjectId = defaultTenantBuilder()
+ .addChild(DefaultFpcMobility.class)
+ .build();
+ createNode(convertContext(context), modelObjectId);
}));
}
} else if (commands.contains("indirect-forward")) {
@@ -310,21 +346,25 @@
// }));
}
} else {
- throw new IllegalArgumentException("Could not find Topic ID");
+ throw new IllegalArgumentException("Could not find Topic ID.");
}
} else {
throw new IllegalArgumentException("DPN does not have node and network ID defined.");
}
+ } else {
+ throw new IllegalArgumentException("No 3GPP instructions where given.");
}
}
}
+ // execute all tasks.
ExecutorService executor = Executors.newWorkStealingPool();
executor.invokeAll(tasks).forEach(
future -> {
try {
future.get();
} catch (Exception e) {
+ log.error(ExceptionUtils.getFullStackTrace(e));
throw new IllegalStateException(e);
}
}
@@ -333,16 +373,18 @@
configureOutput.resultType(defaultCommonSuccess);
configureOutput.result(Result.of(ResultEnum.OK));
} catch (Exception e) {
+ // if there is an exception respond with an error.
log.error(ExceptionUtils.getFullStackTrace(e));
DefaultErr defaultErr = new DefaultErr();
configureOutput.resultType(defaultErr);
- defaultErr.errorInfo(ExceptionUtils.getFullStackTrace(e));
+ defaultErr.errorInfo(ExceptionUtils.getMessage(e));
defaultErr.errorTypeId(ErrorTypeId.of(0));
}
return configureOutput;
}
+ @Override
public DefaultConfigureOutput configureUpdate(
CreateOrUpdate update,
ClientIdentifier clientId,
@@ -350,12 +392,13 @@
) {
DefaultConfigureOutput configureOutput = new DefaultConfigureOutput();
Collection<Callable<Object>> tasks = new ArrayList<>();
-
try {
DefaultCommonSuccess defaultCommonSuccess = new DefaultCommonSuccess();
for (Contexts context : update.contexts()) {
+ // add updated context to response.
defaultCommonSuccess.addToContexts(context);
+ // check if contexts are populated and if they include the wanted context to update.
if (getDefaultTenant().map(
tenant -> tenant.fpcMobility().contexts() == null ||
tenant.fpcMobility()
@@ -363,34 +406,25 @@
.parallelStream()
.noneMatch(contexts -> contexts.contextId().equals(context.contextId()))
).orElse(false)) {
- throw new IllegalStateException("Context doesn't exist.");
+ // throw exception if wanted context does not exist.
+ throw new IllegalStateException("Context doesn't exist. Please issue create operation..");
}
for (Dpns dpn : context.dpns()) {
+ // check if dpns exists and if there is a DPN registered for the wanted identifier.
if (getDefaultTenant().map(
tenant -> tenant.fpcTopology().dpns() == null ||
tenant.fpcTopology().dpns()
.stream()
.noneMatch(dpns -> dpns.dpnId().equals(dpn.dpnId()))
).orElse(false)) {
+ // throw exception if DPN ID is not registered.
throw new IllegalStateException("DPN ID is not registered to the topology.");
}
+ // handle only 3GPP instructions.
if (context.instructions().instrType() instanceof Instr3GppMob) {
- Instr3GppMob instr3GppMob = (Instr3GppMob) context.instructions().instrType();
- String commands = Bits.toString(instr3GppMob.instr3GppMob().bits());
-
- Ip4Address s1u_enodeb_ipv4 = Ip4Address.valueOf(context.ul().tunnelLocalAddress().toString()),
- s1u_sgw_ipv4 = Ip4Address.valueOf(context.ul().tunnelRemoteAddress().toString()),
- sgi_enodeb_ipv4 = Ip4Address.valueOf(context.dl().tunnelRemoteAddress().toString()),
- sgi_sgw_ipv4 = Ip4Address.valueOf(context.dl().tunnelLocalAddress().toString());
-
- long s1u_sgw_gtpu_teid, s1u_enb_gtpu_teid,
- cId = clientId.fpcIdentity().union().int64(),
- contextId = context.contextId().fpcIdentity().union().int64();
-
- BigInteger opId = operationId.uint64();
-
+ // from DPN ID find the Network and Node Identifiers
Optional<String> key = getDefaultTenant().flatMap(tenant ->
tenant.fpcTopology()
.dpns()
@@ -400,14 +434,22 @@
);
if (key.isPresent()) {
- Short topic_id = FpcUtil.getTopicFromNode(key.get());
+ // get DPN Topic from Node/Network pair
+ Short topic_id = getTopicFromNode(key.get());
if (topic_id != null) {
- if (context.ul().mobilityTunnelParameters().mobprofileParameters() instanceof ThreegppTunnel) {
- s1u_sgw_gtpu_teid = ((ThreegppTunnel) context.ul().mobilityTunnelParameters().mobprofileParameters()).tunnelIdentifier();
- } else {
- throw new IllegalArgumentException("mobprofileParameters are not instance of ThreegppTunnel");
- }
+ Instr3GppMob instr3GppMob = (Instr3GppMob) context.instructions().instrType();
+ String commands = Bits.toString(instr3GppMob.instr3GppMob().bits());
+
+ Ip4Address s1u_enodeb_ipv4 = Ip4Address.valueOf(context.ul().tunnelLocalAddress().toString()),
+ s1u_sgw_ipv4 = Ip4Address.valueOf(context.ul().tunnelRemoteAddress().toString());
+
+ long s1u_enb_gtpu_teid,
+ cId = clientId.fpcIdentity().union().int64(),
+ contextId = context.contextId().fpcIdentity().union().int64();
+
+ BigInteger opId = operationId.uint64();
+
if (context.dl().mobilityTunnelParameters().mobprofileParameters() instanceof ThreegppTunnel) {
s1u_enb_gtpu_teid = ((ThreegppTunnel) context.dl().mobilityTunnelParameters().mobprofileParameters()).tunnelIdentifier();
} else {
@@ -416,17 +458,22 @@
if (commands.contains("downlink")) {
if (context.dl().lifetime() >= 0L) {
- tasks.add(Executors.callable(() ->
- dpnCommunicationService.modify_bearer(
- topic_id,
- s1u_sgw_ipv4,
- s1u_enb_gtpu_teid,
- s1u_enodeb_ipv4,
- contextId,
- cId,
- opId
- )
- ));
+ tasks.add(Executors.callable(() -> {
+ dpnCommunicationService.modify_bearer(
+ topic_id,
+ s1u_sgw_ipv4,
+ s1u_enb_gtpu_teid,
+ s1u_enodeb_ipv4,
+ contextId,
+ cId,
+ opId
+ );
+
+ ModelObjectId modelObjectId = defaultTenantBuilder()
+ .addChild(DefaultFpcMobility.class)
+ .build();
+ updateNode(convertContext(context), modelObjectId);
+ }));
} else {
// tasks.add(Executors.callable(() ->
// dpnCommunicationService.delete_bearer(
@@ -438,17 +485,22 @@
}
if (commands.contains("uplink")) {
if (context.ul().lifetime() >= 0L) {
- tasks.add(Executors.callable(() ->
- dpnCommunicationService.modify_bearer(
- topic_id,
- s1u_sgw_ipv4,
- s1u_enb_gtpu_teid,
- s1u_enodeb_ipv4,
- contextId,
- cId,
- opId
- )
- ));
+ tasks.add(Executors.callable(() -> {
+ dpnCommunicationService.modify_bearer(
+ topic_id,
+ s1u_sgw_ipv4,
+ s1u_enb_gtpu_teid,
+ s1u_enodeb_ipv4,
+ contextId,
+ cId,
+ opId
+ );
+
+ ModelObjectId modelObjectId = defaultTenantBuilder()
+ .addChild(DefaultFpcMobility.class)
+ .build();
+ updateNode(convertContext(context), modelObjectId);
+ }));
} else {
// tasks.add(Executors.callable(() ->
// dpnCommunicationService.delete_bearer(
@@ -464,16 +516,20 @@
} else {
throw new IllegalArgumentException("DPN does not have node and network ID defined.");
}
+ } else {
+ throw new IllegalArgumentException("No 3GPP instructions where given.");
}
}
}
+ // execute all tasks.
ExecutorService executor = Executors.newWorkStealingPool();
executor.invokeAll(tasks).forEach(
future -> {
try {
future.get();
} catch (Exception e) {
+ log.error(ExceptionUtils.getFullStackTrace(e));
throw new IllegalStateException(e);
}
}
@@ -481,16 +537,11 @@
configureOutput.resultType(defaultCommonSuccess);
configureOutput.result(Result.of(ResultEnum.OK));
-
- update.contexts().forEach(
- contexts -> getDefaultTenant().ifPresent(
- tenant -> tenant.fpcMobility().addToContexts(convertContext(contexts))
- )
- );
} catch (Exception e) {
+ // if there is an exception respond with an error.
log.error(ExceptionUtils.getFullStackTrace(e));
DefaultErr defaultErr = new DefaultErr();
- defaultErr.errorInfo(ExceptionUtils.getFullStackTrace(e));
+ defaultErr.errorInfo(ExceptionUtils.getMessage(e));
defaultErr.errorTypeId(ErrorTypeId.of(0));
configureOutput.resultType(defaultErr);
configureOutput.result(Result.of(ResultEnum.ERR));
@@ -499,6 +550,7 @@
return configureOutput;
}
+ @Override
public DefaultConfigureOutput configureDelete(
DeleteOrQuery delete,
ClientIdentifier clientId,
@@ -506,14 +558,16 @@
) {
DefaultConfigureOutput configureOutput = new DefaultConfigureOutput();
Collection<Callable<Object>> tasks = new ArrayList<>();
- DefaultDeleteSuccess defaultDeleteSuccess = new DefaultDeleteSuccess();
try {
+ DefaultDeleteSuccess defaultDeleteSuccess = new DefaultDeleteSuccess();
for (Targets target : delete.targets()) {
defaultDeleteSuccess.addToTargets(target);
+ // parse context id.
String targetStr = target.target().toString(),
s = StringUtils.substringBetween(targetStr, "contexts=", "/"),
trgt = s != null ? s : StringUtils.substringAfter(targetStr, "contexts=");
+ // find context that this target is about.
getDefaultTenant().map(
tenant -> {
if (tenant.fpcMobility().contexts() != null) {
@@ -531,6 +585,18 @@
).ifPresent(
context -> context.dpns().forEach(
dpn -> {
+ // check if dpns exists and if there is a DPN registered for the wanted identifier.
+ if (getDefaultTenant().map(
+ tenant -> tenant.fpcTopology().dpns() == null ||
+ tenant.fpcTopology().dpns()
+ .stream()
+ .noneMatch(dpns -> dpns.dpnId().equals(dpn.dpnId()))
+ ).orElse(false)) {
+ // throw exception if DPN ID is not registered.
+ throw new IllegalStateException("DPN ID is not registered to the topology.");
+ }
+
+ // from DPN ID find the Network and Node Identifiers
Optional<String> key = getDefaultTenant().flatMap(tenant ->
tenant.fpcTopology()
.dpns()
@@ -540,10 +606,13 @@
);
if (key.isPresent()) {
- Short topic_id = FpcUtil.getTopicFromNode(key.get());
+ // find DPN Topic from Node/Network ID pair.
+ Short topic_id = getTopicFromNode(key.get());
if (topic_id != null) {
+
Long teid;
+
if (context.ul().mobilityTunnelParameters().mobprofileParameters() instanceof ThreegppTunnel) {
teid = ((ThreegppTunnel) context.ul().mobilityTunnelParameters().mobprofileParameters()).tunnelIdentifier();
} else {
@@ -553,6 +622,7 @@
long client_id = clientId.fpcIdentity().union().int64();
BigInteger op_id = operationId.uint64();
+ // TODO figure out what is going on.
if (targetStr.endsWith("ul") || targetStr.endsWith("dl")) {
// tasks.add(Executors.callable(() -> {
// dpnCommunicationService.delete_bearer(
@@ -572,11 +642,14 @@
op_id
);
- getDefaultTenant().ifPresent(
- tenant -> tenant.fpcMobility()
- .contexts()
- .remove(context)
- );
+ ContextsKeys contextsKeys = new ContextsKeys();
+ contextsKeys.contextId(context.contextId());
+
+ ResourceId resourceVal = getResourceVal(defaultTenantBuilder()
+ .addChild(DefaultFpcMobility.class)
+ .addChild(DefaultContexts.class, contextsKeys)
+ .build());
+ dynamicConfigService.deleteNode(resourceVal);
}));
}
@@ -592,12 +665,14 @@
}
+ // execute all tasks
ExecutorService executor = Executors.newWorkStealingPool();
executor.invokeAll(tasks).forEach(
future -> {
try {
future.get();
} catch (Exception e) {
+ log.error(ExceptionUtils.getFullStackTrace(e));
throw new IllegalStateException(e);
}
}
@@ -605,12 +680,12 @@
configureOutput.resultType(defaultDeleteSuccess);
configureOutput.result(Result.of(ResultEnum.OK));
-
} catch (Exception e) {
+ // if there is an exception respond with an error.
log.error(ExceptionUtils.getFullStackTrace(e));
DefaultErr defaultErr = new DefaultErr();
configureOutput.resultType(defaultErr);
- defaultErr.errorInfo(ExceptionUtils.getFullStackTrace(e));
+ defaultErr.errorInfo(ExceptionUtils.getMessage(e));
defaultErr.errorTypeId(ErrorTypeId.of(0));
}
@@ -618,6 +693,26 @@
}
/**
+ * Extract Resource Data from specified DataNode and Resource Id.
+ *
+ * @param dataNode DataNode
+ * @param resId Resource Identifier
+ * @return Resource Data
+ */
+ private ResourceData getResourceData(DataNode dataNode, ResourceId resId) {
+ if (resId != null) {
+ return DefaultResourceData.builder()
+ .addDataNode(dataNode)
+ .resourceId(resId)
+ .build();
+ } else {
+ return DefaultResourceData.builder()
+ .addDataNode(dataNode)
+ .build();
+ }
+ }
+
+ /**
* Accumulates events to allow processing after a desired number of
* events were accumulated.
*/
@@ -638,14 +733,13 @@
switch (event.type()) {
case NODE_ADDED:
case NODE_DELETED:
- Filter filter = Filter.builder().build();
- DataNode node = dynamicConfigService.readNode(tenantsResourceId, filter);
- getModelObjects(node, null).forEach(
- modelObject -> fpcAgentData.tenants((DefaultTenants) modelObject)
- );
- break;
case NODE_UPDATED:
case NODE_REPLACED:
+// Filter filter = Filter.builder().build();
+// DataNode node = dynamicConfigService.readNode(FpcUtil.tenants, filter);
+// getModelObjects(node, null).forEach(
+// modelObject -> fpcAgentData.tenants((DefaultTenants) modelObject)
+// );
break;
default:
log.warn(UNKNOWN_EVENT, event.type());
@@ -669,10 +763,11 @@
* @return true if event is supported; false otherwise
*/
private boolean isSupported(DynamicConfigEvent event) {
- ResourceId rsId = event.subject();
- List<NodeKey> storeKeys = rsId.nodeKeys();
- List<NodeKey> tenantKeys = tenantsResourceId.nodeKeys();
- return storeKeys.size() >= 2 && storeKeys.get(0).equals(tenantKeys.get(1));
+// ResourceId rsId = event.subject();
+// List<NodeKey> storeKeys = rsId.nodeKeys();
+// List<NodeKey> tenantKeys = FpcUtil.tenants.nodeKeys();
+// return storeKeys.size() >= 2 && storeKeys.get(0).equals(tenantKeys.get(1));
+ return true;
}
@Override
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantService.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantService.java
index 4b88510..2542858 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantService.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantService.java
@@ -7,48 +7,105 @@
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.configure.DefaultConfigureOutput;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.opinput.opbody.CreateOrUpdate;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.opinput.opbody.DeleteOrQuery;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.Tenant;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.DefaultTenant;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcIdentity;
-import org.onosproject.yang.model.DataNode;
-import org.onosproject.yang.model.InnerModelObject;
-import org.onosproject.yang.model.ModelObject;
-import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.model.*;
import java.util.List;
import java.util.Optional;
@Beta
public interface TenantService {
+ /**
+ * Returns the root level node for Tenants.
+ * Tenants is an interface that includes a List of Tenant objects.
+ *
+ * @return Optional Tenants
+ */
Optional<DefaultTenants> getTenants();
- void createNode(InnerModelObject innerModelObject);
+ /**
+ * Creates a Node inside the Dynamic Configuration Store.
+ *
+ * @param innerModelObject inner model object to create
+ * @param modelObjectId Model Object ID
+ */
+ void createNode(InnerModelObject innerModelObject, ModelObjectId modelObjectId);
- void updateNode(InnerModelObject innerModelObject);
+ /**
+ * Updates a Node inside the Dynamic Configuration Store.
+ *
+ * @param innerModelObject inner model object to update
+ * @param modelObjectId Model Object ID
+ */
+ void updateNode(InnerModelObject innerModelObject, ModelObjectId modelObjectId);
+ /**
+ * Converts DataNode to a ModelObject.
+ *
+ * @param dataNode DataNode
+ * @param appId Resource Identifier
+ * @return Model Object
+ */
List<ModelObject> getModelObjects(DataNode dataNode, ResourceId appId);
- Optional<Tenant> getDefaultTenant();
+ /**
+ * Returns the Default Tenant.
+ *
+ * @return Optional Default Tenant
+ */
+ Optional<DefaultTenant> getDefaultTenant();
- Optional<Tenant> getTenant(FpcIdentity tenantId);
+ /**
+ * Get Tenant by its Identifier.
+ *
+ * @param tenantId Tenant Identifier
+ * @return Optional Tenant
+ */
+ Optional<DefaultTenant> getTenant(FpcIdentity tenantId);
- Optional<Tenant> getTenant(ClientIdentifier clientId);
+ Optional<DefaultTenant> getTenant(ClientIdentifier clientId);
- Optional<Tenant> registerClient(ClientIdentifier clientId, FpcIdentity tenantId);
+ Optional<DefaultTenant> registerClient(ClientIdentifier clientId, FpcIdentity tenantId);
- Optional<Tenant> deregisterClient(ClientIdentifier clientId);
+ Optional<DefaultTenant> deregisterClient(ClientIdentifier clientId);
+ /**
+ * Handles create configure operations that are invoked through RPC.
+ *
+ * @param create RPC Input converted
+ * @param clientId Client Identifier
+ * @param operationId Operation Identifier
+ * @return Result of the configuration
+ */
DefaultConfigureOutput configureCreate(
CreateOrUpdate create,
ClientIdentifier clientId,
OpIdentifier operationId
);
+ /**
+ * Handles update configure operations that are invoked through RPC.
+ *
+ * @param update RPC Input converted
+ * @param clientId Client Identifier
+ * @param operationId Operation Identifier
+ * @return Result of the configuration
+ */
DefaultConfigureOutput configureUpdate(
- CreateOrUpdate create,
+ CreateOrUpdate update,
ClientIdentifier clientId,
OpIdentifier operationId
);
+ /**
+ * Handles delete configure operations that are invoked through RPC.
+ *
+ * @param delete RPC Input converted
+ * @param clientId Client Identifier
+ * @param operationId Operation Identifier
+ * @return Result of the configuration
+ */
DefaultConfigureOutput configureDelete(
DeleteOrQuery delete,
ClientIdentifier clientId,
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/Converter.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/Converter.java
index d023cb8..c47bdd0 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/Converter.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/Converter.java
@@ -1,7 +1,6 @@
package org.onosproject.fpcagent.helpers;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.ClientIdentifier;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpcmobility.Contexts;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpcmobility.DefaultContexts;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcContextId;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcDpnGroupId;
@@ -113,8 +112,8 @@
public static Function<String, FpcIdentity> getFpcIdentity = (v) -> new FpcIdentity(new FpcIdentityUnion(v));
public static Function<String, ClientIdentifier> getClientIdentity = (v) -> new ClientIdentifier(getFpcIdentity.apply(v));
- public static Contexts convertContext(org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.payload.Contexts contexts) {
- Contexts ctx = new DefaultContexts();
+ public static DefaultContexts convertContext(org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.payload.Contexts contexts) {
+ DefaultContexts ctx = new DefaultContexts();
FpcContextId fpcContextId = contexts.contextId();
List<IpPrefix> ipPrefixes = contexts.delegatingIpPrefixes();
Dl dl = contexts.dl();
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnCommunicationService.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnCommunicationService.java
index 88dc2b5..9785a41 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnCommunicationService.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnCommunicationService.java
@@ -20,57 +20,76 @@
import java.math.BigInteger;
+/**
+ * Communication Service which sends packets to desired DPNs.
+ */
public interface DpnCommunicationService {
- /**
- * Creates Mobility Session
- * @param topicId - DPN
- * @param imsi - IMSI
- * @param default_ebi - Default EBI
- */
- void create_session(
- Short topicId,
- BigInteger imsi,
- Short default_ebi, Ip4Address ue_ipv4,
- Long s1u_sgw_teid, Ip4Address s1u_sgw_ipv4,
- Long session_id, Long client_id,
- BigInteger op_id
- );
/**
- * Modify Downlink Bearer.
- * @param topic_id - DPN
- * @param s1u_sgw_ipv4 - SGW GTP-U IPv4 Address
- * @param s1u_enodeb_teid - ENodeB TEID
- * @param s1u_enodeb_ipv4 - ENodeB GTP-U IPv4 Address
- * @param session_id - Session Id
- * @param client_id - Operation Identifier
- * @param op_id - Session Id
+ * Creates Mobility Session.
+ *
+ * @param topic_id - DPN Topic ID
+ * @param imsi - IMSI identifier
+ * @param default_ebi - EBI
+ * @param ue_ipv4 - UE IPv4 Address
+ * @param s1u_sgw_teid - SGW Tunnel Identifier
+ * @param s1u_sgw_ipv4 - SGW IPv4
+ * @param session_id - Context Identifier
+ * @param client_id - Client Identifier
+ * @param op_id - Operation Identifier
*/
- void modify_bearer(
+ void create_session(
Short topic_id,
- Ip4Address s1u_sgw_ipv4, Long s1u_enodeb_teid, Ip4Address s1u_enodeb_ipv4,
+ BigInteger imsi,
+ Short default_ebi,
+ Ip4Address ue_ipv4,
+ Long s1u_sgw_teid,
+ Ip4Address s1u_sgw_ipv4,
Long session_id,
Long client_id,
BigInteger op_id
);
/**
- * DeleteOrQuery Mobility Session.
- * @param topic_id - DPN
- * @param session_id - Session Id
- * @param client_id - Client Identifier
- * @param op_id - Operation Identifier
+ * Modifies Bearer.
+ *
+ * @param topic_id - DPN Topic ID
+ * @param s1u_sgw_ipv4 - SGW IPv4 Address
+ * @param s1u_enodeb_teid - ENodeB Tunnel Identifier
+ * @param s1u_enodeb_ipv4 - ENodeB IPv4 Address
+ * @param session_id - Context Identifier
+ * @param client_id - Client Identifier
+ * @param op_id - Operation Identifier
+ */
+ void modify_bearer(
+ Short topic_id,
+ Ip4Address s1u_sgw_ipv4,
+ Long s1u_enodeb_teid,
+ Ip4Address s1u_enodeb_ipv4,
+ Long session_id,
+ Long client_id,
+ BigInteger op_id
+ );
+
+ /**
+ * Deletes Mobility Session.
+ *
+ * @param topic_id - DPN Topic ID
+ * @param session_id - Context Identifier
+ * @param client_id - Client Identifier
+ * @param op_id - Operation Identifier
*/
void delete_session(
Short topic_id,
- Long session_id, Long client_id,
+ Long session_id,
+ Long client_id,
BigInteger op_id
);
/**
* Creates the byte buffer to send ADC rules over ZMQ
*
- * @param topic - DPN Topic
+ * @param topic - DPN Topic ID
* @param domain_name - domain
* @param ip - ipaddress/ipprefix (i.e. 127.0.0.1/32)
* @param drop - Drop if 1
@@ -80,8 +99,11 @@
*/
void send_ADC_rules(
Short topic,
- String domain_name, String ip,
- Short drop, Long rating_group,
- Long service_ID, String sponsor_ID
+ String domain_name,
+ String ip,
+ Short drop,
+ Long rating_group,
+ Long service_ID,
+ String sponsor_ID
);
}
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnNgicCommunicator.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnNgicCommunicator.java
index e93eb09..a315b55 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnNgicCommunicator.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/helpers/DpnNgicCommunicator.java
@@ -1,5 +1,20 @@
-package org.onosproject.fpcagent.helpers;
+/*
+ * Copyright 2017-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.onosproject.fpcagent.helpers;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip4Prefix;
@@ -14,7 +29,7 @@
import static org.onosproject.fpcagent.helpers.Converter.*;
/**
- * DPDK DPN API over ZeroMQ.
+ * DPDK DPN API over ZeroMQ for NGIC.
*/
public class DpnNgicCommunicator implements DpnCommunicationService {
protected static final Logger log = LoggerFactory.getLogger(DpnNgicCommunicator.class);
@@ -133,7 +148,6 @@
ZMQSBPublisherManager.getInstance().send(bb);
}
-
@Override
public void send_ADC_rules(
Short topic,
@@ -143,6 +157,7 @@
Long rating_group,
Long service_ID, String sponsor_ID
) {
+ // TODO take a look for this function. Not tested.
Ip4Prefix ip_prefix = null;
if (ip != null) {
ip_prefix = Ip4Prefix.valueOf(ip);
@@ -185,6 +200,8 @@
/**
* Following the NGIC message types.
+ *
+ * This type structure is defined in NGIC at interface/zmq/zmqsub.h:51
*/
enum s11MsgType {
CREATE_SESSION(1),
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/workers/ZMQSBSubscriberManager.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/workers/ZMQSBSubscriberManager.java
index f259883..7a53aaa 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/workers/ZMQSBSubscriberManager.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/workers/ZMQSBSubscriberManager.java
@@ -143,7 +143,7 @@
String node_id = new String(Arrays.copyOfRange(contents, 8, 8 + nodeIdLen));
String network_id = new String(Arrays.copyOfRange(contents, 9 + nodeIdLen, 9 + nodeIdLen + networkIdLen));
- if (toUint8(subscriberId) == topic || nodeId.equals(node_id) || networkId.equals(network_id)) {
+ if (toUint8(subscriberId) == topic || (nodeId.equals(node_id) && networkId.equals(network_id))) {
ByteBuffer bb = ByteBuffer.allocate(9 + nodeId.length() + networkId.length());
bb.put(toUint8(broadcastAllId))
.put(ASSIGN_CONFLICT)